@linktr.ee/messaging-react 3.31.0-rc-1785485102 → 3.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/{Card-2l_y20FM.js → Card-CmlaSw7i.js} +2 -2
  2. package/dist/{Card-2l_y20FM.js.map → Card-CmlaSw7i.js.map} +1 -1
  3. package/dist/{Card-Gr4HDVbn.cjs → Card-EWN07XIl.cjs} +2 -2
  4. package/dist/{Card-Gr4HDVbn.cjs.map → Card-EWN07XIl.cjs.map} +1 -1
  5. package/dist/assets/index.css +1 -1
  6. package/dist/{index-B96WLmx6.js → index-CN3errpB.js} +3055 -3109
  7. package/dist/index-CN3errpB.js.map +1 -0
  8. package/dist/index-CcitzVoW.cjs +5 -0
  9. package/dist/index-CcitzVoW.cjs.map +1 -0
  10. package/dist/index.cjs +1 -1
  11. package/dist/index.d.ts +56 -60
  12. package/dist/index.js +1 -1
  13. package/package.json +2 -2
  14. package/src/components/ChannelView.broadcast-name.integration.test.tsx +116 -0
  15. package/src/components/ChannelView.tsx +17 -3
  16. package/src/components/CustomLinkPreviewList/CustomLinkPreviewList.test.tsx +15 -0
  17. package/src/components/CustomLinkPreviewList/index.tsx +24 -26
  18. package/src/components/CustomMessage/BroadcastNameContext.test.ts +43 -0
  19. package/src/components/CustomMessage/BroadcastNameContext.ts +95 -0
  20. package/src/components/CustomMessage/CustomMessage.stories.tsx +54 -22
  21. package/src/components/CustomMessage/CustomMessage.test.tsx +48 -0
  22. package/src/components/CustomMessage/SentMessageDeliveryStatus.test.tsx +62 -0
  23. package/src/components/CustomMessage/SentMessageDeliveryStatus.tsx +8 -2
  24. package/src/components/CustomMessage/StreamAttachmentMessage.test.tsx +0 -33
  25. package/src/components/CustomMessage/StreamAttachmentMessage.tsx +0 -8
  26. package/src/components/CustomMessage/index.tsx +23 -3
  27. package/src/components/CustomMessageInput/CustomMessageInput.stories.tsx +50 -2
  28. package/src/components/CustomMessageInput/CustomMessageInput.test.tsx +180 -2
  29. package/src/components/CustomMessageInput/index.tsx +143 -16
  30. package/src/components/MessageAttachment/Audio/AudioAttachment.stories.tsx +57 -166
  31. package/src/components/MessageAttachment/Audio/index.tsx +77 -71
  32. package/src/components/MessageAttachment/MessageAttachment.test.tsx +75 -175
  33. package/src/components/MessageAttachment/index.tsx +9 -25
  34. package/src/components/MessageAttachment/types.ts +9 -19
  35. package/src/components/MessagingShell/index.tsx +2 -0
  36. package/src/index.ts +1 -0
  37. package/src/styles.css +5 -120
  38. package/src/types.ts +11 -0
  39. package/src/utils/formatRelativeTime.test.ts +63 -57
  40. package/src/utils/formatRelativeTime.ts +21 -20
  41. package/dist/index-B96WLmx6.js.map +0 -1
  42. package/dist/index-CCtHMrmO.cjs +0 -5
  43. package/dist/index-CCtHMrmO.cjs.map +0 -1
  44. package/src/components/MessageAttachment/Audio/WaveformAudioRow.tsx +0 -335
@@ -1,5 +0,0 @@
1
- "use strict";const r=require("react/jsx-runtime"),g=require("react"),Cr=require("@linktr.ee/messaging-core"),et=require("stream-chat"),j=require("stream-chat-react"),S=require("classnames"),M=require("@phosphor-icons/react"),se=require("@linktr.ee/messaging-taxonomy"),yn=require("stream-chat-react/experimental"),na=g.createContext({service:null,client:null,isConnected:!1,isLoading:!1,error:null,capabilities:{},refreshConnection:async()=>{},debug:!1}),wn=()=>g.useContext(na),Sr=({children:e,user:t,serviceConfig:n,apiKey:s,capabilities:a={},debug:i=!1,client:o})=>{var I,L;const l=g.useCallback((P,...D)=>{i&&console.log(`🔥 [MessagingProvider] ${P}`,...D)},[i]);l("🔄 RENDER START",{userId:t==null?void 0:t.id,apiKey:(s==null?void 0:s.substring(0,8))+"...",serviceConfig:!!n,capabilities:Object.keys(a)});const[c,u]=g.useState(null),[m,f]=g.useState(null),[h,d]=g.useState(!1),[v,_]=g.useState(!1),[x,p]=g.useState(null),b=g.useRef(!1),w=g.useRef(null),C=g.useRef(n);C.current=n;const E=g.useRef(i);E.current=i;const R=g.useRef({userId:t==null?void 0:t.id,apiKey:s,serviceConfig:n,capabilities:a}),A=g.useRef(0);A.current++,l("📊 RENDER INFO",{renderCount:A.current,currentProps:{userId:t==null?void 0:t.id,apiKey:(s==null?void 0:s.substring(0,8))+"..."},propChanges:{userChanged:R.current.userId!==(t==null?void 0:t.id),apiKeyChanged:R.current.apiKey!==s,serviceConfigChanged:R.current.serviceConfig!==n,capabilitiesChanged:R.current.capabilities!==a}}),R.current={userId:t==null?void 0:t.id,apiKey:s,serviceConfig:n,capabilities:a};const B=g.useRef(null);!o&&s&&((I=B.current)==null?void 0:I.apiKey)!==s&&(B.current={apiKey:s,client:new et.StreamChat(s)});const U=o||(s?((L=B.current)==null?void 0:L.client)??null:null);g.useEffect(()=>{const P=A.current,D=C.current;if(o){w.current=null,u(null),f(null),d(!1),p(null),_(!1);return}if(!s||!U||!D){l("⚠️ SERVICE INIT SKIPPED",{renderCount:P,reason:"Missing apiKey, client, or serviceConfig"});return}l("🚀 CREATING SERVICE",{renderCount:P,apiKey:(s==null?void 0:s.substring(0,8))+"..."});const V=new Cr.StreamChatService({...D,apiKey:s,debug:E.current,client:U});w.current=V,u(V),l("✅ SERVICE SET",{renderCount:P,serviceInstance:!!V})},[s,U,o]);const $=g.useRef(null);g.useEffect(()=>{var D,V;if(l("🔗 USER CONNECTION EFFECT TRIGGERED",{hasService:!!c,hasUser:!!t,userId:t==null?void 0:t.id,isConnecting:b.current,isConnected:h,dependencies:{service:!!c,userId:t==null?void 0:t.id}}),o)return;if(!c||!t){l("⚠️ USER CONNECTION SKIPPED","Missing service or user");return}if(b.current){l("⚠️ USER CONNECTION SKIPPED","Already connecting");return}if(((D=$.current)==null?void 0:D.serviceId)===c&&((V=$.current)==null?void 0:V.userId)===t.id){l("⚠️ USER CONNECTION SKIPPED","Already connected this user with this service");return}(async()=>{l("🚀 STARTING USER CONNECTION",{userId:t.id}),b.current=!0,_(!0),p(null);try{l("📞 CALLING SERVICE.CONNECTUSER",{userId:t.id});const q=await c.connectUser(t);f(q),d(!0),$.current={serviceId:c,userId:t.id},l("✅ USER CONNECTION SUCCESS",{userId:t.id,clientId:q.userID})}catch(q){const W=q instanceof Error?q.message:"Connection failed";p(W),l("❌ USER CONNECTION ERROR",{userId:t.id,error:W})}finally{_(!1),b.current=!1,l("🔄 USER CONNECTION FINISHED",{userId:t.id,isConnected:h})}})()},[c,t,l,h,o]),g.useEffect(()=>{const P=U;return()=>{var D;P&&($.current=null,(D=w.current)==null||D.disconnectUser().catch(console.error))}},[U]);const T=g.useCallback(async()=>{if(l("🔄 REFRESH CONNECTION CALLED",{hasService:!!c,hasUser:!!t}),!o){if(!c||!t){l("⚠️ REFRESH CONNECTION SKIPPED","Missing service or user");return}l("🚀 STARTING CONNECTION REFRESH",{userId:t.id}),_(!0);try{l("🔌 DISCONNECTING FOR REFRESH"),await c.disconnectUser(),l("📞 RECONNECTING FOR REFRESH");const P=await c.connectUser(t);f(P),d(!0),p(null),l("✅ CONNECTION REFRESH SUCCESS",{userId:t.id})}catch(P){const D=P instanceof Error?P.message:"Refresh failed";p(D),l("❌ CONNECTION REFRESH ERROR",{userId:t.id,error:D})}finally{_(!1),l("🔄 CONNECTION REFRESH FINISHED",{userId:t.id})}}},[c,t,l,o]),O=g.useMemo(()=>(l("💫 CONTEXT VALUE MEMOIZATION",{hasService:!!c,hasClient:!!m,isConnected:h,isLoading:v,hasError:!!x,capabilitiesKeys:Object.keys(a)}),{service:o?null:c,client:o??m,isConnected:o?!0:h,isLoading:o?!1:v,error:o?null:x,capabilities:a,refreshConnection:T,debug:i}),[c,m,o,h,v,x,a,T,i,l]);return l("🔄 RENDER END",{renderCount:A.current,willRenderChat:!!U,contextValueReady:!!O}),r.jsx(na.Provider,{value:O,children:U?r.jsx(j.Chat,{client:U,customClasses:{channelList:"str-chat__channel-list str-chat__channel-list-react bg-transparent lg:border-r-2 border-r-0 border-[#0000000A]"},children:e}):e})},sa=()=>wn(),aa=e=>{var s,a;const[t,n]=g.useState(!!((a=(s=e==null?void 0:e.state)==null?void 0:s.membership)!=null&&a.pinned_at));return g.useEffect(()=>{var o;if(!e){n(!1);return}n(!!((o=e.state.membership)!=null&&o.pinned_at));const i=l=>{var c;n(l!=null&&l.member?!!l.member.pinned_at:!!((c=e.state.membership)!=null&&c.pinned_at))};return e.on("member.updated",i),()=>{e.off("member.updated",i)}},[e]),t};function jn(e,t,n){const s=Object.values(e||{});if(se.isOfficialChannel(n)){const a=s.find(i=>{var o;return((o=i.user)==null?void 0:o.id)===se.OFFICIAL_SENDER_USER_ID});if(a)return a}return s.find(a=>{var i;return((i=a.user)==null?void 0:i.id)&&a.user.id!==t})}const Tr=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function ra(e){return Tr.test(e.trim())}function ps(e,t){const n=e==null?void 0:e.trim();return!n||t&&n===t||t&&n===`Follower ${t}`?!1:!ra(n)}function Nn(e){return ps(e==null?void 0:e.name,e==null?void 0:e.id)?e.name.trim():ps(e==null?void 0:e.username,e==null?void 0:e.id)?e.username.trim():"Unknown member"}const bs=[{emoji:"🍎",bgColor:"#FFD1DD"},{emoji:"🍌",bgColor:"#FFF1C9"},{emoji:"🍇",bgColor:"#E6D9FF"},{emoji:"🍊",bgColor:"#D6F4FF"},{emoji:"🍓",bgColor:"#FFE0AE"},{emoji:"🥥",bgColor:"#F7E7D8"},{emoji:"🍒",bgColor:"#DFF4D8"},{emoji:"🥭",bgColor:"#FFD8C2"},{emoji:"🍉",bgColor:"#D6EBFF"},{emoji:"🍋",bgColor:"#CAEEB5"},{emoji:"🥝",bgColor:"#FFE7C7"},{emoji:"🫒",bgColor:"#F6E3B4"},{emoji:"🍈",bgColor:"#D9F7E1"}];function Er(e){let t=0;for(let n=0;n<e.length;n++){const s=e.charCodeAt(n);t=(t<<5)-t+s,t=t&t}return Math.abs(t)}function ia(e){return bs[Er(e)%bs.length]}function Ir(e){return ia(e).emoji}function Rr(e){return ia(e).bgColor}const ke=({id:e,image:t,size:n=40,className:s,starred:a=!1,shape:i="squircle",dmAgentEnabled:o=!1})=>{const l=Ir(e),c=Rr(e),u=.45,f=n<32?Math.round(n*u):n<56?14:n<120?18:36,h=n>=40?2:1,d=i==="circle"?{borderRadius:"50%"}:{borderRadius:"1rem"},v=r.jsx("div",{className:"h-full w-full overflow-hidden",style:d,children:t?r.jsx("img",{src:t,alt:"",className:"h-full w-full object-cover"}):r.jsx("div",{"aria-hidden":"true",className:S("avatar-fallback flex h-full w-full items-center justify-center font-semibold select-none transition-colors"),style:{fontSize:f,lineHeight:1},children:l})});return r.jsxs("div",{className:S("relative flex-shrink-0",s),style:{"--str-chat__avatar-size":`${n}px`,width:`${n}px`,height:`${n}px`,backgroundColor:t?void 0:c,...d},children:[a&&r.jsx("div",{"aria-hidden":"true",className:"absolute -left-1.5 -top-1.5 z-10 flex size-5 items-center justify-center rounded-full bg-white shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]",children:r.jsx(M.StarIcon,{className:"size-3 text-yellow-600",weight:"duotone"})}),r.jsx("div",{"data-testid":"avatar-ring",className:S("h-full w-full","bg-transparent"),style:{...d,...o&&{borderWidth:`${h}px`,borderStyle:"solid",borderColor:"var(--AI-Gradient, #7F22FE)",boxShadow:"inset 0 1px 2px 0 rgba(255, 255, 255, 0.5)"}},children:v})]})},Ar="https://linktr.ee/s/about/trust-center/report",Lr=({channel:e,participant:t,showBlockParticipant:n=!0,enabled:s=!0,onLeaveConversation:a,onBlockParticipant:i,onDeleteConversationClick:o,onBlockParticipantClick:l,onReportParticipantClick:c,onActionComplete:u,logLabel:m="useChannelModerationActions"})=>{var O;const{service:f,debug:h}=wn(),d=(O=t==null?void 0:t.user)==null?void 0:O.id,v=!!(s&&n&&f&&d),[_,x]=g.useState(!1),[p,b]=g.useState(null),[w,C]=g.useState(!1),[E,R]=g.useState(!1),A=v&&((p==null?void 0:p.participantId)!==d||(p==null?void 0:p.service)!==f);return g.useEffect(()=>{if(!v||!f||!d){x(!1),b(null);return}let I=!1;return(async()=>{try{const L=await f.getBlockedUsers();if(I)return;x(L.some(P=>P.blocked_user_id===d))}catch(L){I||console.error(`[${m}] Failed to check blocked status:`,L)}finally{I||b({participantId:d,service:f})}})(),()=>{I=!0}},[v,f,d,m]),{isParticipantBlocked:_,isCheckingBlockedStatus:A,isLeaving:w,isUpdatingBlockStatus:E,handleLeaveConversation:async()=>{var I;if(!w){o==null||o(),h&&console.log(`[${m}] Leave conversation`,e.cid),C(!0);try{const L=((I=e._client)==null?void 0:I.userID)??null;await e.hide(L,!1),a&&await a(e),u==null||u()}catch(L){console.error(`[${m}] Failed to leave conversation`,L)}finally{C(!1)}}},handleBlockUser:async()=>{var I,L,P;if(!(E||!f)){l==null||l(),h&&console.log(`[${m}] Block member`,(I=t==null?void 0:t.user)==null?void 0:I.id),R(!0);try{await f.blockUser((L=t==null?void 0:t.user)==null?void 0:L.id),i&&await i((P=t==null?void 0:t.user)==null?void 0:P.id),u==null||u()}catch(D){console.error(`[${m}] Failed to block member`,D)}finally{R(!1)}}},handleUnblockUser:async()=>{var I,L,P;if(!(E||!f)){l==null||l(),h&&console.log(`[${m}] Unblock member`,(I=t==null?void 0:t.user)==null?void 0:I.id),R(!0);try{await f.unBlockUser((L=t==null?void 0:t.user)==null?void 0:L.id),i&&await i((P=t==null?void 0:t.user)==null?void 0:P.id),u==null||u()}catch(D){console.error(`[${m}] Failed to unblock member`,D)}finally{R(!1)}}},handleReportUser:()=>{c==null||c(),u==null||u(),window.open(Ar,"_blank","noopener,noreferrer")}}},Ie=({variant:e="default",className:t,children:n,...s})=>{const a=e==="danger";return r.jsx("button",{type:"button",className:S("flex w-full items-center gap-3 rounded-lg px-4 py-3 text-left text-sm transition-colors focus-ring disabled:cursor-not-allowed disabled:opacity-60",a?"text-danger hover:bg-danger/50":"text-charcoal hover:bg-sand",t),...s,children:n})},zr=({channel:e,participant:t,showDeleteConversation:n=!0,showBlockParticipant:s=!0,showReportParticipant:a=!0,onLeaveConversation:i,onBlockParticipant:o,onDeleteConversationClick:l,onBlockParticipantClick:c,onReportParticipantClick:u,customChannelActions:m,triggerClassName:f})=>{const[h,d]=g.useState(!1),v=g.useRef(null),_=g.useId(),x=g.useCallback(()=>d(!1),[]),{isParticipantBlocked:p,isCheckingBlockedStatus:b,isLeaving:w,isUpdatingBlockStatus:C,handleLeaveConversation:E,handleBlockUser:R,handleUnblockUser:A,handleReportUser:B}=Lr({channel:e,participant:t,showBlockParticipant:s,enabled:h,onLeaveConversation:i,onBlockParticipant:o,onDeleteConversationClick:l,onBlockParticipantClick:c,onReportParticipantClick:u,onActionComplete:x,logLabel:"ChannelActionsMenu"});return g.useEffect(()=>{if(!h)return;const $=O=>{v.current&&!v.current.contains(O.target)&&d(!1)},T=O=>{O.key==="Escape"&&d(!1)};return document.addEventListener("mousedown",$),document.addEventListener("keydown",T),()=>{document.removeEventListener("mousedown",$),document.removeEventListener("keydown",T)}},[h]),!t||!(n||s||a||!!m)?null:r.jsxs("div",{ref:v,className:"relative",children:[r.jsxs("button",{className:f,type:"button","aria-haspopup":"true","aria-expanded":h,"aria-controls":h?_:void 0,onClick:()=>d($=>!$),children:[r.jsx(M.DotsThreeIcon,{className:"size-5 text-black/90"}),r.jsx("span",{className:"sr-only",children:"More options"})]}),h&&r.jsx("div",{id:_,"aria-label":"Conversation options",className:S("absolute right-0 top-full z-50 mt-2 w-56 overflow-hidden","rounded-lg border border-sand bg-white p-1 shadow-max-elevation-light"),children:r.jsxs("ul",{className:"flex flex-col gap-1",children:[n&&r.jsx("li",{children:r.jsxs(Ie,{onClick:E,disabled:w,"aria-busy":w,children:[w?r.jsx(M.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):r.jsx(M.SignOutIcon,{className:"h-5 w-5"}),r.jsx("span",{children:"Delete Conversation"})]})}),s&&r.jsx("li",{children:b?r.jsxs(Ie,{disabled:!0,"aria-busy":!0,children:[r.jsx(M.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}),r.jsx("span",{children:"Block"})]}):p?r.jsxs(Ie,{onClick:A,disabled:C,"aria-busy":C,children:[C?r.jsx(M.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):r.jsx(M.ProhibitInsetIcon,{className:"h-5 w-5"}),r.jsx("span",{children:"Unblock"})]}):r.jsxs(Ie,{onClick:R,disabled:C,"aria-busy":C,children:[C?r.jsx(M.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):r.jsx(M.ProhibitInsetIcon,{className:"h-5 w-5"}),r.jsx("span",{children:"Block"})]})}),a&&r.jsx("li",{children:r.jsxs(Ie,{variant:"danger",onClick:B,children:[r.jsx(M.FlagIcon,{className:"h-5 w-5"}),r.jsx("span",{children:"Report"})]})}),m]})})]})},It="flex size-10 flex-shrink-0 items-center justify-center rounded-full bg-white/65 shadow-[0px_4px_8px_0px_rgba(0,0,0,0.06),0px_0px_0px_1px_rgba(0,0,0,0.04)] backdrop-blur-[40px] transition-filter duration-150 hover:brightness-95 aria-expanded:brightness-95 focus-ring",Pr="CUSTOMER_PAID",$r=e=>typeof e=="string"&&e.trim().replace(/[\s-]+/g,"_").toUpperCase()===Pr,Dr=({className:e,onBack:t,showBackButton:n,showStarButton:s=!1,onLeaveConversation:a,onBlockParticipant:i,showDeleteConversation:o=!0,showBlockParticipant:l=!0,showReportParticipant:c=!0,onDeleteConversationClick:u,onBlockParticipantClick:m,onReportParticipantClick:f,customChannelActions:h,renderChannelActions:d,showChannelInfo:v=!0,onParticipantNameClick:_})=>{var T,O,I,L;const{channel:x}=j.useChannelStateContext(),{client:p}=j.useChatContext(),b=g.useMemo(()=>{var P;return jn((P=x.state)==null?void 0:P.members,p==null?void 0:p.userID,x.type)},[(T=x.state)==null?void 0:T.members,p==null?void 0:p.userID,x.type]),w=Nn(b==null?void 0:b.user),C=(O=b==null?void 0:b.user)==null?void 0:O.image,E=aa(x),R=$r((I=x.data)==null?void 0:I.customer_tag)&&(b==null?void 0:b.is_follower)===!0,A=s&&E,B=R||A||!!_,U=async()=>{try{E?await x.unpin():await x.pin()}catch(P){console.error("[ChannelHeaderRedesign] Failed to update pinned status:",P)}},$=r.jsxs(r.Fragment,{children:[r.jsx(ke,{id:((L=b==null?void 0:b.user)==null?void 0:L.id)||x.id||"unknown",name:w,image:C,shape:"circle",size:48,className:"-mb-2"}),r.jsx("span",{className:S("relative z-10 flex max-w-full flex-col items-center justify-center rounded-full border border-white/10 bg-white/65 py-1.5 shadow-[0px_0px_0px_0px_rgba(0,0,0,0.04),0px_1px_2px_0px_rgba(0,0,0,0.04),0px_8px_32px_0px_rgba(0,0,0,0.1)] backdrop-blur-[2px] transition-filter duration-150 group-hover:brightness-95",B?"pl-3 pr-2":"px-3"),children:r.jsxs("span",{className:"flex max-w-full items-center justify-center",children:[r.jsx("span",{className:"min-w-0 truncate text-sm font-bold leading-[1.43] tracking-[0.28px] text-black/90",children:w}),B&&r.jsxs("span",{className:"ml-2 flex gap-1",children:[R&&r.jsx("span",{"aria-label":"Paid customer",className:"flex size-4 shrink-0 items-center justify-center rounded-full bg-[#34C759] text-white",children:r.jsx(M.CurrencyDollarIcon,{className:"size-2.5",weight:"bold"})}),A&&r.jsx("span",{"aria-label":"Starred conversation",className:"flex size-4 shrink-0 items-center justify-center rounded-full bg-[#FFD60A] text-white",children:r.jsx(M.StarIcon,{className:"size-2.5",weight:"fill"})}),_&&r.jsx(M.CaretRightIcon,{"aria-hidden":"true",className:"size-4 shrink-0 text-black/65",weight:"bold"})]})]})})]});return r.jsx("div",{className:S("@container bg-[linear-gradient(180deg,#FBFAF9_0%,rgba(251,250,249,0.92)_58%,rgba(251,250,249,0)_100%)]",e),children:r.jsxs("div",{className:"grid min-h-[100px] grid-cols-[minmax(40px,1fr)_auto_minmax(40px,1fr)] items-start pb-2 pt-5 @lg:min-h-[104px] @lg:pt-6",children:[r.jsx("div",{className:"flex items-start",children:n&&r.jsx("button",{className:S(It,"messaging-channel-view-back-button-mobile messaging-channel-view-back-button-desktop"),onClick:t||(()=>{}),type:"button","aria-label":"Back to conversations",children:r.jsx(M.ArrowLeftIcon,{className:"size-5 text-black/90"})})}),r.jsx("div",{className:"flex min-w-0 justify-center","data-dd-privacy":"mask",children:_?r.jsx("button",{type:"button",onClick:_,"aria-label":`View details for ${w}`,className:"group flex min-w-0 max-w-full appearance-none flex-col items-center border-0 bg-transparent px-2 focus-ring focus-visible:outline-none",children:$}):r.jsx("div",{className:"flex min-w-0 max-w-full flex-col items-center px-2",children:$})}),r.jsxs("div",{className:"flex items-start justify-end gap-2",children:[s&&r.jsx("button",{className:It,onClick:U,type:"button","aria-pressed":E,"aria-label":E?"Unstar conversation":"Star conversation",children:r.jsx(M.StarIcon,{className:S("size-5",{"text-[#FFD60A]":E,"text-black/90":!E}),weight:E?"fill":"regular"})}),v&&(d!==void 0?d:r.jsx(zr,{channel:x,participant:b,showDeleteConversation:o,showBlockParticipant:l,showReportParticipant:c,onLeaveConversation:a,onBlockParticipant:i,onDeleteConversationClick:u,onBlockParticipantClick:m,onReportParticipantClick:f,customChannelActions:h,triggerClassName:It}))]})]})})},Or=e=>r.jsx(j.DateSeparator,{...e,position:"center"}),on="vote_up",ln="vote_down";function Fr(e){return e!=null&&e.length?e.some(t=>t.type===ln)?"down":e.some(t=>t.type===on)?"up":null:null}function oa(e){const{channel:t}=j.useChannelStateContext(),{client:n}=j.useChatContext("useMessageVote"),s=g.useMemo(()=>Fr(e.own_reactions),[e.own_reactions]),a=g.useCallback(async()=>{if(n!=null&&n.userID)try{s==="up"?await t.deleteReaction(e.id,on):await t.sendReaction(e.id,{type:on},{enforce_unique:!0,skip_push:!0})}catch{}},[t,n==null?void 0:n.userID,e.id,s]),i=g.useCallback(async()=>{if(n!=null&&n.userID)try{s==="down"?await t.deleteReaction(e.id,ln):await t.sendReaction(e.id,{type:ln},{enforce_unique:!0,skip_push:!0})}catch{}},[t,n==null?void 0:n.userID,e.id,s]);return{selected:s,voteUp:a,voteDown:i}}function la(e){return(e==null?void 0:e.trim().toLowerCase().split(/[-_]/)[0])||void 0}function kn({message:e,viewerLanguage:t}){var a;const n=e==null?void 0:e.text,s=la(t);return s?((a=e==null?void 0:e.i18n)==null?void 0:a[`${s}_text`])??n:n}const Br=["linktr.ee"],vs="messaging-attachment-v1_0";function Ur(e){try{return new URL(e).hostname.toLowerCase()}catch{return null}}function Hr(e){return Br.some(t=>e===t||e.endsWith(`.${t}`))}function be(e){const t=e==null?void 0:e.trim();if(!t)return;const n=Ur(t);if(!n||!Hr(n))return t;const s=new URL(t);return s.searchParams.get("io")==="true"&&s.searchParams.get("size")===vs?t:(s.searchParams.set("io","true"),s.searchParams.set("size",vs),s.toString())}const Vr=[[/pdf/,"pdf"],[/wordprocessingml|msword|\.doc/,"doc"],[/spreadsheetml|ms-excel|\.xls/,"xls"],[/csv/,"csv"],[/presentationml|ms-powerpoint|\.ppt/,"ppt"],[/zip|x-rar|x-7z|x-tar|x-gzip/,"zip"],[/plain|rtf/,"text"],[/markdown/,"markdown"]];function ue(e){return e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e.startsWith("image/")?"image":"document"}function ca(e){const t=Vr.find(([n])=>n.test(e));return t?t[1]:"generic"}const Gr={video:M.VideoCameraIcon,audio:M.SpeakerHighIcon,image:M.ImageIcon,document:M.FileIcon},qr={pdf:M.FilePdfIcon,doc:M.FileDocIcon,xls:M.FileXlsIcon,csv:M.FileCsvIcon,ppt:M.FilePptIcon,zip:M.FileZipIcon,text:M.FileTextIcon,markdown:M.FileMdIcon,generic:M.FileIcon};function Yr(e){const t=ue(e);return t!=="document"?Gr[t]:qr[ca(e)]}function Ne(e,t){return g.createElement(Yr(e),t)}const Xr=e=>{var t,n;return"touches"in e?((t=e.touches[0])==null?void 0:t.clientX)??((n=e.changedTouches[0])==null?void 0:n.clientX)??0:e.clientX},Wr=({source:e,mimeType:t,poster:n,autoPlay:s=!1,playing:a,loop:i=!1,controls:o=!0,showProgress:l=!1,muted:c=!1,onContainerClick:u})=>{const m=ue(t),f=g.useRef(null),h=g.useRef(null),d=g.useRef(null),v=g.useRef(a),[_,x]=g.useState(s),[p,b]=g.useState(0),[w,C]=g.useState(!1),[E,R]=g.useState(!1),[A,B]=g.useState(!1),[U,$]=g.useState(!1),[T,O]=g.useState(!0),[I,L]=g.useState(null),P=g.useCallback(()=>{B(!1),x(!0)},[]),D=g.useCallback(k=>{const F=h.current;if(!F)return 0;const X=F.getBoundingClientRect();return Math.max(0,Math.min(1,(Xr(k)-X.left)/X.width))},[]),V=g.useCallback(k=>{const F=f.current;F&&F.duration&&(F.currentTime=k*F.duration)},[]),q=k=>{k.stopPropagation(),C(!0);const F=D(k);b(F),V(F)};g.useEffect(()=>{a!==void 0&&a!==v.current&&(v.current=a,x(a))},[a]),g.useEffect(()=>{if(!_){d.current!==null&&(cancelAnimationFrame(d.current),d.current=null);return}const k=()=>{const F=f.current;F&&F.duration&&!w&&b(F.currentTime/F.duration),d.current=requestAnimationFrame(k)};return d.current=requestAnimationFrame(k),()=>{d.current!==null&&cancelAnimationFrame(d.current)}},[_,w]),g.useEffect(()=>{const k=f.current;k&&(_?k.play().catch(F=>{x(!1),B(!0)}):k.pause())},[_]),g.useEffect(()=>{if(!w)return;const k=X=>b(D(X)),F=X=>{C(!1),V(D(X))};return window.addEventListener("mousemove",k),window.addEventListener("mouseup",F),window.addEventListener("touchmove",k,{passive:!0}),window.addEventListener("touchend",F),()=>{window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",F),window.removeEventListener("touchmove",k),window.removeEventListener("touchend",F)}},[w,D,V]);const W=I?{aspectRatio:String(I)}:void 0,ae=I?"":" aspect-video",Q=Math.round(p*100);return r.jsxs("div",{role:"button",tabIndex:0,className:`relative cursor-pointer overflow-hidden bg-black ${ae}`,style:W,onClick:k=>{if(u){u(k);return}A||o&&x(F=>!F)},onKeyDown:k=>{if(!(k.key!=="Enter"&&k.key!==" ")){if(k.preventDefault(),u){u(k);return}A||o&&x(F=>!F)}},children:[n&&(m==="audio"||T)&&r.jsx("img",{src:n,alt:"",className:"absolute inset-0 h-full w-full object-cover"}),!n&&(m==="audio"||T)&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:Ne(t,{className:"size-12 text-black/20",weight:"regular"})}),r.jsx("div",{className:"absolute inset-0",children:m==="audio"?r.jsx("audio",{ref:f,src:e,loop:i,muted:c,style:{width:"100%",height:"100%"},onLoadStart:()=>$(!0),onCanPlay:()=>{$(!1),O(!1)},onWaiting:()=>$(!0),onPlay:()=>B(!1),onEnded:()=>{i||(x(!1),b(0))},children:r.jsx("track",{kind:"captions"})}):r.jsx("video",{ref:f,src:e,loop:i,muted:c,playsInline:!0,style:{width:"100%",height:"100%"},onLoadStart:()=>$(!0),onCanPlay:()=>{$(!1),O(!1)},onWaiting:()=>$(!0),onPlay:()=>B(!1),onLoadedMetadata:()=>{const k=f.current;k instanceof HTMLVideoElement&&k.videoWidth&&k.videoHeight&&L(k.videoWidth/k.videoHeight)},onEnded:()=>{i||(x(!1),b(0))},children:r.jsx("track",{kind:"captions"})})}),U&&!A&&r.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:r.jsx(M.CircleNotchIcon,{className:"size-8 animate-spin text-white/80",weight:"bold"})}),A&&!o&&r.jsx("div",{className:"absolute inset-0 z-30 flex cursor-pointer items-center justify-center bg-black/35",role:"button",tabIndex:0,"aria-label":"Play preview",onClick:k=>{k.stopPropagation(),P()},onKeyDown:k=>{k.key!=="Enter"&&k.key!==" "||(k.preventDefault(),k.stopPropagation(),P())},children:r.jsx("span",{className:"flex size-16 items-center justify-center rounded-full bg-white/20 text-white backdrop-blur-sm",children:r.jsx(M.PlayIcon,{className:"size-9 translate-x-0.5",weight:"fill"})})}),l&&!o&&r.jsx("div",{className:"absolute inset-x-0 bottom-0 px-3 pb-2.5 pt-6 bg-gradient-to-t from-black/40 to-transparent",children:r.jsx("div",{role:"slider","aria-label":"Playback position","aria-valuenow":Q,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:h,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:q,onTouchStart:q,onClick:k=>k.stopPropagation(),onKeyDown:k=>{k.key==="ArrowRight"&&V(Math.min(1,p+.05)),k.key==="ArrowLeft"&&V(Math.max(0,p-.05))},children:r.jsx("div",{className:"w-full overflow-hidden rounded-full bg-white/30 h-1",children:r.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${Q}%`}})})})}),o&&r.jsxs("div",{className:"absolute inset-x-0 bottom-0 flex items-center gap-2 bg-gradient-to-t from-black/60 to-transparent px-3 pb-2.5 pt-6 transition-all duration-200",children:[r.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),x(F=>!F)},className:"shrink-0 text-white","aria-label":_?"Pause":"Play",children:_?r.jsx(M.PauseIcon,{className:"size-5",weight:"fill"}):r.jsx(M.PlayIcon,{className:"size-5 translate-x-px",weight:"fill"})}),r.jsxs("div",{role:"slider","aria-label":"Playback position","aria-valuenow":Q,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,ref:h,className:"relative flex h-4 w-full cursor-pointer items-center",onMouseDown:q,onTouchStart:q,onClick:k=>k.stopPropagation(),onMouseEnter:()=>R(!0),onMouseLeave:()=>R(!1),onKeyDown:k=>{k.key==="ArrowRight"&&V(Math.min(1,p+.05)),k.key==="ArrowLeft"&&V(Math.max(0,p-.05))},children:[r.jsx("div",{className:`w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${E||w?"h-1.5":"h-1"}`,children:r.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${Q}%`}})}),r.jsx("div",{className:`absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${E||w?"scale-100 opacity-100":"scale-0 opacity-0"}`,style:{left:`${Q}%`}})]})]})]})},_s=e=>e==="dark"?"size-12 text-white/20":"size-12 text-black/20",Zr=e=>e==="dark"?"aspect-video overflow-hidden bg-white/10":"aspect-video overflow-hidden bg-black/5",Mn=({mimeType:e,sourceUrl:t,thumbnailUrl:n,title:s,variant:a,mediaPlayerProps:i,containedImage:o=!1})=>{const l=ue(e),[c,u]=g.useState(!1),m=be(t),f=be(n);return t&&(l==="video"||l==="audio")?r.jsx(Wr,{source:t,mimeType:e,poster:f,controls:!0,...i}):t&&l==="image"?o?r.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:r.jsx("img",{src:m??t,alt:s??"",className:`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${c?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>u(!0)})}):r.jsx("img",{src:m??t,alt:s??"",className:"block w-full",draggable:!1}):t&&l==="document"?n?o?r.jsx("div",{className:"relative aspect-video overflow-hidden bg-black/5",children:r.jsx("img",{src:f??n,alt:s??"",className:`absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${c?"opacity-100":"opacity-0"}`,draggable:!1,onLoad:()=>u(!0)})}):r.jsx("img",{src:f??n,alt:"",className:"block w-full",draggable:!1}):r.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${a==="dark"?"bg-white/10":"bg-black/5"}`,children:Ne(e,{className:_s(a),weight:"regular"})}):n?r.jsx("div",{className:`relative ${Zr(a)}`,children:r.jsx("img",{src:f??n,alt:s??"",draggable:!1,className:"absolute inset-0 h-full w-full object-cover"})}):r.jsx("div",{className:`flex aspect-video w-full items-center justify-center ${a==="dark"?"bg-white/10":"bg-black/5"}`,children:Ne(e,{className:_s(a),weight:"regular"})})},da=({variant:e,thumbnail:t,title:n,placeholderTitle:s="Attachment title",mimeType:a,detail:i,statusBadge:o,action:l,topLeft:c,topRight:u,rootRef:m,"data-testid":f})=>{const h=e==="dark",d=h?n??s:n??"",v=h&&!n;return r.jsxs("div",{ref:m,"data-testid":f,className:S("relative w-[280px] select-none overflow-hidden rounded-[24px] shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]",h?"bg-[#1e2330]":"bg-white"),children:[c?r.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-50",children:c}):null,u?r.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-50",children:u}):null,t,r.jsxs("div",{className:"px-4 pb-3 pt-3",children:[d.trim()!==""&&r.jsx("p",{className:S("mb-0.5 truncate text-base font-medium",{"text-black":!h,"text-white/30":h&&v,"text-white":h&&!v}),children:d}),r.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[Ne(a,{className:S("size-5 shrink-0",h?"text-white/55":"text-black/55"),weight:"regular"}),i!=null&&i!==""&&r.jsx("span",{className:S("text-xs font-medium",h?"text-white/55":"text-black/55"),children:i}),o]}),l]})]})};function ua(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Cn(e){return`w-[280px] select-none overflow-hidden rounded-[24px] ${e?"bg-[#1e2330]":"bg-[#F3F3F1]"} shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_4px_8px_rgba(0,0,0,0.06)]`}function Kr(e){return e?"bg-white/10":"bg-black/5"}function Jr(e){return e?"text-white":"text-black"}function Qr(e){return e?"text-white/55":"text-black/55"}function ei(e){return e?"text-white/40":"text-black/40"}function ti(e){return e?"text-white/20":"text-black/20"}const Sn=({attachment:e,isMyMessage:t})=>{const{title:n,text:s,image_url:a,og_scrape_url:i,title_link:o}=e,l=i??o,c=typeof l=="string"&&l.trim()!==""?l:void 0,u=r.jsxs(g.Fragment,{children:[r.jsx("div",{className:"p-2",children:a?r.jsx("img",{src:be(a)??a,alt:n??"",className:"aspect-video w-full rounded-[20px] object-cover"}):r.jsx("div",{className:`aspect-video w-full rounded-[20px] ${Kr(t)} flex items-center justify-center`,children:r.jsx(M.LinkIcon,{className:`size-12 ${ti(t)}`})})}),r.jsxs("div",{className:"px-3 pb-3",children:[n&&r.jsx("p",{className:`truncate text-[14px] font-medium leading-5 ${Jr(t)}`,children:n}),s&&r.jsx("p",{className:`truncate text-[12px] leading-4 ${Qr(t)}`,children:s}),c&&r.jsx("p",{className:`mt-1 truncate text-[12px] leading-4 ${ei(t)}`,children:c})]})]});return c?r.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"block no-underline",children:u}):r.jsx("div",{className:"block",children:u})};function Tn(e){return e.type==="link"||!!e.og_scrape_url&&!e.asset_url}function ht(e){var t;return(t=e.attachments)==null?void 0:t.find(Tn)}async function ni(e,t){let n;try{n=t??new URL(e).pathname.split("/").pop()??"download"}catch{n=t??"download"}const s=await fetch(e,{mode:"cors"});if(!s.ok)throw new Error(`HTTP ${s.status}`);const a=await s.blob(),i=URL.createObjectURL(a),o=document.createElement("a");o.href=i,o.download=n,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)}const si=({url:e,filename:t})=>{const[n,s]=g.useState(!1),a=i=>{i.stopPropagation();const o=window.open("","_blank","noopener,noreferrer");s(!0),ni(e,t).then(()=>{o==null||o.close()}).catch(()=>{o&&(o.location.href=e)}).finally(()=>s(!1))};return r.jsx("button",{type:"button",onClick:a,disabled:n,className:"mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounded-full bg-[#121110] px-4 text-sm font-medium leading-none text-white hover:bg-[#2a2928] disabled:opacity-70",children:n?r.jsx(M.CircleNotchIcon,{className:"size-4 animate-spin text-white",weight:"bold"}):r.jsxs(g.Fragment,{children:[r.jsx(M.DownloadSimpleIcon,{className:"size-4 text-white",weight:"bold"}),"Download"]})})};function gt(e){var f,h,d,v;const t=(f=e.attachments)==null?void 0:f.find(_=>_.type==="video"&&_.asset_url),n=(h=e.attachments)==null?void 0:h.find(_=>_.type==="image"&&_.image_url),s=(d=e.attachments)==null?void 0:d.find(_=>_.type==="audio"&&_.asset_url),a=(v=e.attachments)==null?void 0:v.find(_=>_.type==="file"&&_.asset_url),i=t??n??s??a,o=(t==null?void 0:t.asset_url)??(n==null?void 0:n.image_url)??(s==null?void 0:s.asset_url)??(a==null?void 0:a.asset_url);if(!o)return null;const l=(i==null?void 0:i.mime_type)??((i==null?void 0:i.type)==="image"?"image/jpeg":(i==null?void 0:i.type)==="video"?"video/mp4":(i==null?void 0:i.type)==="audio"?"audio/mpeg":"application/octet-stream"),c=i==null?void 0:i.title,u=i==null?void 0:i.file_size,m=t==null?void 0:t.thumb_url;return{resolvedUrl:o,resolvedType:l,title:c,fileSize:u,thumbnailUrl:m}}const fa=({resolvedUrl:e,resolvedType:t,title:n,fileSize:s,thumbnailUrl:a})=>{const i=s!==void 0?ua(s):void 0;return r.jsx(da,{variant:"dark",title:n,placeholderTitle:"",mimeType:t,detail:i,thumbnail:r.jsx(Mn,{mimeType:t,sourceUrl:e,thumbnailUrl:a,title:n,variant:"dark"})})},ma=({resolvedUrl:e,resolvedType:t,title:n,fileSize:s,thumbnailUrl:a})=>{const i=ue(t),o=s!==void 0?ua(s):void 0;return r.jsx(da,{variant:"light",title:n,mimeType:t,detail:o,thumbnail:r.jsx(Mn,{mimeType:t,sourceUrl:e,thumbnailUrl:a,title:n,variant:"light",containedImage:i==="image"||i==="document"}),action:r.jsx(si,{url:e,filename:n})})},ai=({message:e,isMyMessage:t=!1})=>{const n=ht(e),s=gt(e);if(!n&&!s)return null;const a=t?"str-chat__message str-chat__message-simple str-chat__message--me str-chat__message-simple--me":"str-chat__message str-chat__message-simple str-chat__message--other";return r.jsxs("div",{className:a,"data-dd-privacy":"mask",children:[!t&&e.user&&r.jsx(ke,{className:"str-chat__avatar str-chat__message-sender-avatar",id:e.user.id,image:e.user.image,name:e.user.name??e.user.id}),r.jsx("div",{className:"str-chat__message-inner",style:{marginInlineEnd:0,marginInlineStart:0},children:r.jsx("div",{className:"str-chat__message-bubble-wrapper",children:r.jsx("div",{className:"str-chat__message-bubble","data-attachment-bubble":"true",style:{padding:0,borderRadius:0,overflow:"visible",background:"transparent"},children:n?r.jsx("div",{className:Cn(t),children:r.jsx(Sn,{attachment:n,isMyMessage:t})}):t?r.jsx(fa,{...s}):r.jsx(ma,{...s})})})})]})},ri=({message:e})=>{const t=ht(e);if(t)return r.jsx("div",{className:Cn(!0),"data-dd-privacy":"mask",children:r.jsx(Sn,{attachment:t,isMyMessage:!0})});const n=gt(e);return n?r.jsx("div",{style:{display:"contents"},"data-dd-privacy":"mask",children:r.jsx(fa,{...n})}):null},ii=({message:e})=>{const t=ht(e);if(t)return r.jsx("div",{className:Cn(!1),"data-dd-privacy":"mask",children:r.jsx(Sn,{attachment:t,isMyMessage:!1})});const n=gt(e);return n?r.jsx("div",{style:{display:"contents"},"data-dd-privacy":"mask",children:r.jsx(ma,{...n})}):null},oi=Object.assign(ai,{Creator:ri,Visitor:ii}),li={dark:"bg-[#1e2330]",light:"bg-[#f2f1ef]"},ci={dark:"text-white",light:"text-[#000000]"},di={dark:"border-white/[0.08]",light:"border-black/[0.08]"},ui=e=>e==="dark"?"sender":"receiver",fi={sender:{single:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]",first:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[4px]",middle:"rounded-tl-[18px] rounded-tr-[4px] rounded-bl-[18px] rounded-br-[4px]",end:"rounded-tl-[18px] rounded-tr-[4px] rounded-bl-[18px] rounded-br-[18px]"},receiver:{single:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]",first:"rounded-tl-[18px] rounded-tr-[18px] rounded-bl-[4px] rounded-br-[18px]",middle:"rounded-tl-[4px] rounded-tr-[18px] rounded-bl-[4px] rounded-br-[18px]",end:"rounded-tl-[4px] rounded-tr-[18px] rounded-bl-[18px] rounded-br-[18px]"}},He=({variant:e,text:t,bordered:n=!0,groupPosition:s="single",widthClassName:a="w-[280px]",paddingClassName:i="px-2 py-2",radiusClassName:o,className:l,children:c,"data-testid":u})=>{const m=t!=null&&t!=="",f=o??fi[ui(e)][s];return r.jsxs("div",{"data-testid":u,"data-group-position":s,className:S("relative",a,"overflow-hidden",i,m&&"pb-0",f,li[e],ci[e],n&&"border",n&&di[e],l),children:[c,m?r.jsx("p",{className:S("whitespace-pre-wrap break-words leading-snug","pb-2 pt-2","px-2"),children:t}):null]})},Ve=e=>e==="received"?"light":"dark",ha=({firstOfGroup:e,endOfGroup:t,groupedByUser:n})=>!n||e&&t?"single":e?"first":t?"end":"middle";function ga(e){return!Number.isFinite(e)||e<0?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(2)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}const mi={pdf:"PDF",doc:"DOC",xls:"XLS",csv:"CSV",ppt:"PPT",zip:"ZIP",text:"TXT",markdown:"MD"};function xa(e,t){if(t){const a=t.lastIndexOf(".");if(a>0&&a<t.length-1){const i=t.slice(a+1);if(i&&i.length<=5)return i.toUpperCase()}}if(!e)return;if(ue(e)==="document"){const a=ca(e),i=mi[a];if(i)return i;if(e==="application/octet-stream")return}const s=e.split("/")[1];if(!(!s||s==="*"))return s.toUpperCase()}function pa(e,t,n){const s=xa(e,t),a=typeof n=="number"&&n>0?ga(n):void 0;return[s,a].filter(Boolean).join(" · ")||void 0}function de(e){try{const n=new URL(e).pathname.split("/").pop();return n&&n.length>0?decodeURIComponent(n):"download"}catch{return"download"}}async function En(e,t){const n=t??de(e);try{const s=await fetch(e,{mode:"cors"});if(!s.ok)throw new Error(`HTTP ${s.status}`);const a=await s.blob(),i=URL.createObjectURL(a),o=document.createElement("a");o.href=i,o.download=n,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)}catch{if(!window.open(e,"_blank","noopener,noreferrer")){const a=document.createElement("a");a.href=e,a.download=n,a.target="_blank",a.rel="noopener noreferrer",a.style.display="none",document.body.appendChild(a),a.click(),document.body.removeChild(a)}}}const cn=35,hi=Object.freeze(new Array(cn).fill(0)),gi="--:--",xi=e=>({canPlayRecord:e.canPlayRecord,isPlaying:e.isPlaying,progressPercent:e.progressPercent,secondsElapsed:e.secondsElapsed}),ys="flex size-8 shrink-0 items-center justify-center rounded-full backdrop-blur-[20px]",pi={dark:"bg-white text-black/90 disabled:bg-white/40",light:"bg-[#040403]/90 text-white disabled:bg-[#040403]/30"},bi={dark:"bg-[#040403]/80 text-white hover:bg-[#040403]",light:"bg-black/10 text-black/90 hover:bg-black/20"},vi=(e,t)=>{const[n,s]=g.useState();return g.useEffect(()=>{if(t!=null||!e)return;const a=document.createElement("audio");a.preload="metadata";const i=()=>{Number.isFinite(a.duration)&&a.duration>0&&s(a.duration)};return a.addEventListener("loadedmetadata",i),a.src=e,()=>{a.removeEventListener("loadedmetadata",i),a.removeAttribute("src"),s(void 0)}},[e,t]),t??n},_i=({item:e,variant:t,trailingAction:n,requester:s})=>{const a=g.useRef(null),[i,o]=g.useState(!1),l=g.useMemo(()=>{const R=e.waveformData;return!R||R.length===0?hi:R.length===cn?R:j.resampleWaveformData(R,cn)},[e.waveformData]),c=vi(e.src,e.durationSeconds),u=j.useAudioPlayer({durationSeconds:c,mimeType:e.mimeType,requester:s,src:e.src,title:e.filename}),{canPlayRecord:m=!1,isPlaying:f=!1,progressPercent:h=0,secondsElapsed:d=0}=j.useStateStore(u==null?void 0:u.state,xi)??{},v=Math.min(Math.max(h,0),100),_=!!u&&m,x=f||i,p=c==null?gi:j.displayDuration(c),b=d>0?j.displayDuration(d):p,w=()=>{!u||i||(o(!0),u.togglePlay().finally(()=>o(!1)))},C=R=>{const A=a.current;if(!u||!A)return;const B=Math.min(Math.max(Number(R.target.value)/100,0),1),U=A.getBoundingClientRect();u.seek({clientX:U.x+B*U.width,currentTarget:A})},E=e.filename?` — ${e.filename}`:"";return r.jsxs("div",{role:"group","aria-label":e.filename??"Audio attachment",className:"flex items-center","data-testid":"audio-attachment-row",children:[r.jsx("button",{type:"button",onClick:w,disabled:!_,"aria-busy":i||void 0,"aria-label":`${x?"Pause audio":"Play audio"}${E}`,className:S(ys,pi[t]),children:x?r.jsx(M.PauseIcon,{className:"size-3",weight:"fill","aria-hidden":!0}):r.jsx(M.PlayIcon,{className:"size-3",weight:"fill","aria-hidden":!0})}),r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2.5 px-3",children:[r.jsxs("div",{className:S("mes-audio-wave",t==="light"&&"mes-audio-wave--light"),children:[r.jsx("div",{ref:a,className:"mes-audio-wave__track","aria-hidden":!0,children:l.map((R,A)=>r.jsx("span",{"data-testid":"amplitude-bar",className:S("mes-audio-wave__bar",v>A/l.length*100&&"mes-audio-wave__bar--played"),style:{"--mes-audio-wave-bar":`${Math.min(Math.max(R,0),1)*100}%`}},A))}),r.jsx("input",{type:"range",className:"mes-audio-wave__seek",min:0,max:100,step:.1,value:v,onChange:C,disabled:!_,"aria-label":`Seek audio${E}`,"aria-valuetext":`${j.displayDuration(d)} of ${p}`})]}),r.jsx("span",{className:"shrink-0 text-xs leading-4 tracking-[0.24px] tabular-nums",children:b})]}),r.jsx("button",{type:"button",onClick:n.kind==="dismiss"?n.onDismiss:()=>{En(e.src,e.filename)},"aria-label":n.kind==="dismiss"?"Remove attachment":`Download audio${E}`,className:S(ys,bi[t]),children:n.kind==="dismiss"?r.jsx(M.XIcon,{className:"size-3",weight:"bold","aria-hidden":!0}):r.jsx(M.DownloadSimpleIcon,{className:"size-3",weight:"bold","aria-hidden":!0})})]})},yi="w-[299px]",wi="py-5 pl-5 pr-3",ji="rounded-[20px]",Ni=({src:e,mimeType:t,filename:n,durationSeconds:s,waveformData:a,items:i})=>i&&i.length>0?i:e?[{src:e,mimeType:t,filename:n,durationSeconds:s,waveformData:a}]:[],In=({state:e,src:t,mimeType:n,filename:s,items:a,durationSeconds:i,waveformData:o,text:l,groupPosition:c,onDismiss:u})=>{const{message:m,threadList:f}=j.useMessageContext(),h=Ve(e),d=Ni({src:t,mimeType:n,filename:s,durationSeconds:i,waveformData:o,items:a});if(d.length===0)return null;const v=m!=null&&m.id?`${f?m.parent_id??m.id:""}${m.id}`:void 0,_=e==="composer"&&u?{kind:"dismiss",onDismiss:u}:{kind:"download"};return r.jsx(He,{variant:h,text:l,groupPosition:c,bordered:!1,widthClassName:yi,paddingClassName:wi,radiusClassName:ji,"data-testid":"audio-attachment",children:r.jsx("div",{className:"flex flex-col gap-2",children:d.map((x,p)=>r.jsx(_i,{item:x,variant:h,requester:v,trailingAction:_},`${x.src}-${p}`))})})},ki=e=>r.jsx(In,{...e,state:"composer"}),Mi=e=>r.jsx(In,{...e,state:"sent"}),Ci=e=>r.jsx(In,{...e,state:"received"}),Si={Composer:ki,Sent:Mi,Received:Ci},Ti={dark:"text-white/55",light:"text-black/65"},Ei={dark:"bg-white/10",light:"bg-black/5"},Ii={dark:"text-white/85",light:"text-black/85"},ba=({variant:e,filename:t,title:n,mimeType:s="application/octet-stream",fileSize:a,onActivate:i,activateLabel:o,trailingAction:l})=>{const c=n??t??"File",u=pa(s,t,a),m=r.jsx("div",{className:S("flex size-10 shrink-0 items-center justify-center rounded-sm",Ei[e]),"aria-hidden":!0,children:Ne(s,{className:S("size-6",Ii[e]),weight:"regular"})}),f=r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col text-left",children:[r.jsx("p",{className:"truncate font-medium leading-snug",children:c}),u?r.jsx("p",{className:S("truncate text-xs leading-4",Ti[e]),children:u}):null]}),h=i?r.jsxs("button",{type:"button",onClick:i,"aria-label":o,className:S("flex min-w-0 flex-1 items-center gap-3 rounded-sm text-left transition-colors",e==="dark"?"hover:bg-white/[0.04]":"hover:bg-black/[0.04]"),children:[m,f]}):r.jsxs(r.Fragment,{children:[m,f]});return r.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[h,l?r.jsx("div",{className:"shrink-0",children:l}):null]})},xt=({onClick:e,variant:t="overlay",ariaLabel:n="Dismiss attachment"})=>r.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),e()},"aria-label":n,className:S("flex size-6 items-center justify-center rounded-full text-white",t==="overlay"?"bg-[#121110]/85 backdrop-blur":"bg-white/15 hover:bg-white/25"),children:r.jsx(M.XIcon,{className:"size-3",weight:"bold"})}),Ri=({src:e,filename:t,fileSize:n,mimeType:s,title:a,items:i})=>i&&i.length>0?i:e?[{src:e,filename:t,fileSize:n,mimeType:s,title:a}]:[],Ai=({variant:e,item:t,index:n,onActivate:s,trailingAction:a})=>{const i=t.filename??de(t.src);return r.jsx(ba,{variant:e,filename:i,title:t.title,mimeType:t.mimeType??"application/octet-stream",fileSize:t.fileSize,onActivate:()=>s(n),activateLabel:`Download ${i}`,trailingAction:a})},Rn=({state:e,src:t,filename:n,fileSize:s,mimeType:a,title:i,items:o,text:l,groupPosition:c,onClick:u,onDismiss:m})=>{const f=Ve(e),h=e==="composer"&&!!m,d=Ri({src:t,filename:n,fileSize:s,mimeType:a,title:i,items:o}),v=x=>{if((u==null?void 0:u(x))===!1)return;const p=d[x];if(!p)return;const b=p.filename??de(p.src);En(p.src,b)};if(d.length===0)return null;const _=r.jsx("span",{className:S("flex size-8 items-center justify-center rounded-full",f==="dark"?"text-white/70":"text-black/70"),"aria-hidden":!0,children:r.jsx(M.DownloadSimpleIcon,{className:"size-5",weight:"bold"})});return r.jsx(He,{variant:f,text:l,groupPosition:c,"data-testid":"file-attachment",children:r.jsx("div",{className:"flex flex-col gap-2",children:d.map((x,p)=>{const b=h&&p===0?r.jsx(xt,{onClick:m,variant:"inline"}):_;return r.jsx(Ai,{variant:f,item:x,index:p,onActivate:v,trailingAction:b},`${x.src}-${p}`)})})})},Li=e=>r.jsx(Rn,{...e,state:"composer"}),zi=e=>r.jsx(Rn,{...e,state:"sent"}),Pi=e=>r.jsx(Rn,{...e,state:"received"}),$i={Composer:Li,Sent:zi,Received:Pi},An=({onPrev:e,onNext:t,prevLabel:n="Previous",nextLabel:s="Next"})=>r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:e,"aria-label":n,className:"mes-media-viewer__nav mes-media-viewer__nav--prev",children:r.jsx(M.CaretLeftIcon,{size:20,weight:"bold","aria-hidden":!0})}),r.jsx("button",{type:"button",onClick:t,"aria-label":s,className:"mes-media-viewer__nav mes-media-viewer__nav--next",children:r.jsx(M.CaretRightIcon,{size:20,weight:"bold","aria-hidden":!0})})]}),va=({url:e,filename:t,variant:n="pill",label:s="Download",iconOnly:a,tone:i="dark",onTriggered:o})=>{const[l,c]=g.useState(!1),u=g.useCallback(d=>{d.stopPropagation(),!l&&(c(!0),En(e,t).catch(()=>{}).finally(()=>{c(!1),o==null||o()}))},[l,e,t,o]),m=a??n!=="pill",h={className:S(n==="pill"?"size-4":"size-5","shrink-0"),weight:"bold"};if(n==="inline"){const d={dark:"text-white/70 hover:bg-white/[0.08] hover:text-white",light:"text-black/70 hover:bg-black/[0.08] hover:text-black"};return r.jsx("button",{type:"button",onClick:u,disabled:l,"aria-label":s,className:S("flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70",d[i]),children:l?r.jsx(M.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):r.jsx(M.DownloadSimpleIcon,{className:"size-5 shrink-0",weight:"bold","aria-hidden":!0})})}return n==="viewer"?r.jsx("button",{type:"button",onClick:u,disabled:l,"aria-label":s,className:"mes-media-viewer__action",children:l?r.jsx(M.CircleNotchIcon,{size:20,weight:"bold","aria-hidden":!0}):r.jsx(M.DownloadSimpleIcon,{size:20,weight:"bold","aria-hidden":!0})}):r.jsxs("button",{type:"button",onClick:u,disabled:l,"aria-label":m?s:void 0,className:S("mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounded-full px-4 text-sm font-medium leading-none transition-colors disabled:opacity-70",i==="dark"?"bg-[#121110] text-white hover:bg-[#2a2928]":"bg-white text-[#121110] hover:bg-white/90"),children:[l?r.jsx(M.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):r.jsx(M.DownloadSimpleIcon,{...h,"aria-hidden":!0}),m?null:s]})},Rt=(e,t,n)=>Math.min(Math.max(e,t),n),Ln=({length:e,initialIndex:t,open:n})=>{const s=Rt(t,0,Math.max(e-1,0)),[a,i]=g.useState(s);g.useEffect(()=>{n&&i(Rt(t,0,Math.max(e-1,0)))},[n,t,e]),g.useEffect(()=>{i(c=>Rt(c,0,Math.max(e-1,0)))},[e]);const o=g.useCallback(()=>{e<=1||i(c=>c<=0?e-1:c-1)},[e]),l=g.useCallback(()=>{e<=1||i(c=>c>=e-1?0:c+1)},[e]);return g.useEffect(()=>{if(!n||e<=1)return;const c=u=>{if(u.key!=="ArrowLeft"&&u.key!=="ArrowRight")return;const m=document.activeElement;m&&(m.tagName==="VIDEO"||m.tagName==="AUDIO")||(u.preventDefault(),u.key==="ArrowLeft"?o():l())};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[n,e,o,l]),{index:a,prev:o,next:l}},zn=({open:e,onClose:t,ariaLabel:n,counter:s,actions:a,children:i,"data-testid":o})=>{const l=g.useRef(null),c=g.useRef(null);g.useEffect(()=>{var h;const f=l.current;if(f){if(e){if(!f.open)if(typeof f.showModal=="function")try{f.showModal()}catch{f.setAttribute("open","")}else f.setAttribute("open","");const d=typeof document<"u"?document.activeElement:null;return(h=c.current)==null||h.focus(),()=>{if(f.open)if(typeof f.close=="function")try{f.close()}catch{f.removeAttribute("open")}else f.removeAttribute("open");d&&document.body.contains(d)&&d.focus()}}if(f.open)if(typeof f.close=="function")try{f.close()}catch{f.removeAttribute("open")}else f.removeAttribute("open")}},[e]);const u=()=>{t()},m=f=>{f.target===l.current&&t()};return r.jsxs("dialog",{ref:l,className:"mes-media-viewer","aria-label":n??"Attachment viewer","data-testid":o,onClose:u,onClick:m,children:[r.jsxs("div",{className:"mes-media-viewer__chrome",children:[s?r.jsx("span",{className:"mes-media-viewer__counter",children:s}):null,r.jsxs("div",{className:"mes-media-viewer__actions",children:[a,r.jsx("button",{ref:c,type:"button",onClick:t,"aria-label":"Close viewer",className:"mes-media-viewer__action",children:r.jsx(M.XIcon,{size:20,weight:"bold","aria-hidden":!0})})]})]}),r.jsx("div",{className:"mes-media-viewer__body",children:i})]})},_a=({open:e,items:t,initialIndex:n=0,onClose:s})=>{const{index:a,prev:i,next:o}=Ln({length:t.length,initialIndex:n,open:e}),l=t[a],c=g.useMemo(()=>(l==null?void 0:l.filename)??(l?de(l.src):"image"),[l]);return l?r.jsxs(zn,{open:e,onClose:s,ariaLabel:c,counter:t.length>1?`${a+1} / ${t.length}`:void 0,actions:r.jsx(va,{url:l.src,filename:c,variant:"viewer",label:`Download ${c}`}),"data-testid":"image-viewer",children:[e?r.jsx("img",{src:l.src,alt:l.alt??c,draggable:!1,loading:"eager",decoding:"async",className:"mes-media-viewer__image"},`${a}:${l.src}`):null,t.length>1?r.jsx(An,{onPrev:i,onNext:o,prevLabel:"Previous image",nextLabel:"Next image"}):null]}):null},Di="relative block size-full overflow-hidden bg-black/5 outline-none after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-white/80 focus-visible:after:ring-offset-2 focus-visible:after:ring-offset-black",Oi={1:["rounded-[18px]"],2:["rounded-l-[18px]","rounded-r-[18px]"],3:["rounded-l-[18px]","rounded-tr-[18px]","rounded-br-[18px]"],4:["rounded-tl-[18px]","rounded-tr-[18px]","rounded-bl-[18px]","rounded-br-[18px]"]},Fi="--mes-single-width-cap",Bi="[--mes-single-width-cap:309px] sm:[--mes-single-width-cap:326px]",Ui=436,ya=({tiles:e,onTileActivate:t,maxVisible:n=4,singleAspectRatio:s,className:a})=>{const i=e.length;if(i===0)return null;const o=e.slice(0,Math.min(i,n)),l=i-o.length,c=(m,f,h)=>{var v;const d=S(Di,"h-full w-full",(v=Oi[o.length])==null?void 0:v[f]);return t?r.jsxs("button",{type:"button",onClick:()=>t(f),"aria-label":m.ariaLabel??`Open media ${f+1}`,className:S(d,"cursor-zoom-in"),children:[m.content,h]},f):r.jsxs("div",{className:d,children:[m.content,h]},f)};let u;return s&&(u={aspectRatio:s,width:`min(var(${Fi}), ${Math.round(Ui*s*100)/100}px)`,maxWidth:"100%"}),o.length===1?r.jsx("div",{className:S(s?Bi:"aspect-square w-full",a),style:u,children:c(o[0],0)}):o.length===2?r.jsx("div",{className:S("grid aspect-[16/9] w-full grid-cols-2 gap-0.5",a),children:o.map((m,f)=>c(m,f))}):o.length===3?r.jsxs("div",{className:S("grid aspect-[4/3] w-full grid-cols-2 grid-rows-2 gap-0.5",a),children:[r.jsx("div",{className:"row-span-2",children:c(o[0],0)}),c(o[1],1),c(o[2],2)]}):r.jsx("div",{className:S("grid aspect-[379/286] w-full grid-cols-2 grid-rows-2 gap-0.5",a),children:o.map((m,f)=>{const h=l>0&&f===o.length-1;return c(m,f,h?r.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-black/55 text-2xl font-semibold text-white",children:["+",l]}):null)})})},Ge=e=>{const[t,n]=g.useState(!1),[s,a]=g.useState(0),i=g.useCallback(l=>{(e==null?void 0:e(l))!==!1&&(a(l),n(!0))},[e]),o=g.useCallback(()=>n(!1),[]);return{viewerOpen:t,viewerIndex:s,handleActivate:i,closeViewer:o}},Hi=({item:e,index:t,totalCount:n,fallbackLoading:s,imgRef:a,onLoad:i})=>({ariaLabel:`Open image ${t+1} of ${n}`,content:r.jsx("img",{ref:a,src:be(e.src)??e.src,alt:e.alt??"",width:e.width,height:e.height,draggable:!1,loading:e.loading??s,decoding:"async",onLoad:i,className:"absolute inset-0 size-full object-cover"})}),Vi=({src:e,alt:t,items:n})=>n&&n.length>0?n:e?[{src:e,alt:t}]:[],wa=(e,t)=>e.map((n,s)=>({src:n.src,alt:n.alt,filename:t&&e.length===1?t:t?`${t} (${s+1})`:void 0})),Gi=({src:e,alt:t,filename:n,loading:s="lazy",onClick:a,onDismiss:i})=>{const{viewerOpen:o,viewerIndex:l,handleActivate:c,closeViewer:u}=Ge(a);return r.jsxs("div",{className:"relative w-fit",children:[r.jsx("button",{type:"button",onClick:()=>c(0),"aria-label":"Open image",className:"block size-[280px] cursor-zoom-in overflow-hidden rounded-md outline-none focus-visible:ring-2 focus-visible:ring-black/40",children:r.jsx("img",{src:be(e)??e,alt:t??"",draggable:!1,loading:s,decoding:"async",className:"size-full object-cover"})}),i?r.jsx("div",{className:"absolute right-2 top-2 z-10",children:r.jsx(xt,{onClick:i})}):null,r.jsx(_a,{open:o,items:wa([{src:e,alt:t}],n),initialIndex:l,onClose:u})]})},qi=326/246,Yi=e=>{const t=e==null?void 0:e.src,[n,s]=g.useState(),a=g.useCallback(c=>{if(!c||c.naturalWidth<=0||c.naturalHeight<=0||t===void 0)return;const u=c.naturalWidth/c.naturalHeight;s(m=>m&&m.src===t&&m.ratio===u?m:{src:t,ratio:u})},[t]),i=g.useCallback(c=>a(c.currentTarget),[a]),o=e!=null&&e.width&&(e!=null&&e.height)?e.width/e.height:void 0,l=n&&n.src===t?n.ratio:void 0;return{ratio:o??l??qi,imgRef:a,onLoad:i}},ja=({state:e,src:t,alt:n,filename:s,items:a,text:i,groupPosition:o,loading:l="lazy",onClick:c})=>{const u=Vi({src:t,alt:n,items:a}),m=Ve(e),{viewerOpen:f,viewerIndex:h,handleActivate:d,closeViewer:v}=Ge(c),_=u.length===1,x=Yi(_?u[0]:void 0);if(u.length===0)return null;const p=u.map((b,w)=>Hi({item:b,index:w,totalCount:u.length,fallbackLoading:l,imgRef:_?x.imgRef:void 0,onLoad:_?x.onLoad:void 0}));return r.jsxs(He,{variant:m,text:i,groupPosition:o,bordered:!1,widthClassName:_?"w-fit max-w-[313px] sm:max-w-[330px]":"w-[383px] max-w-full",paddingClassName:"p-0.5",radiusClassName:"rounded-[20px]","data-testid":"image-attachment",children:[r.jsx("div",{className:"relative",children:r.jsx(ya,{tiles:p,onTileActivate:d,singleAspectRatio:_?x.ratio:void 0})}),r.jsx(_a,{open:f,items:wa(u,s),initialIndex:h,onClose:v})]})},Xi=e=>r.jsx(Gi,{...e}),Wi=e=>r.jsx(ja,{...e,state:"sent"}),Zi=e=>r.jsx(ja,{...e,state:"received"}),Ki={Composer:Xi,Sent:Wi,Received:Zi},Ji=({open:e,items:t,initialIndex:n=0,onClose:s})=>{const{index:a,prev:i,next:o}=Ln({length:t.length,initialIndex:n,open:e}),l=t[a],c=g.useMemo(()=>(l==null?void 0:l.filename)??(l?de(l.src):"document"),[l]),u=g.useMemo(()=>l?Qi(l.src):void 0,[l]);return!l||!u?null:r.jsxs(zn,{open:e,onClose:s,ariaLabel:c,counter:t.length>1?`${a+1} / ${t.length}`:void 0,"data-testid":"pdf-viewer",children:[r.jsx("iframe",{src:u,title:c,className:"mes-media-viewer__iframe",sandbox:"allow-scripts allow-forms allow-popups allow-downloads"},`${a}:${l.src}`),t.length>1?r.jsx(An,{onPrev:i,onNext:o,prevLabel:"Previous document",nextLabel:"Next document"}):null]})},Qi=e=>{const t=e.indexOf("#"),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+1),a=new URLSearchParams(s);return a.has("toolbar")||a.set("toolbar","0"),a.has("navpanes")||a.set("navpanes","0"),`${n}#${a.toString()}`},eo=({src:e,filename:t,fileSize:n,title:s,items:a})=>a&&a.length>0?a:e?[{src:e,filename:t,fileSize:n,title:s}]:[],to=({variant:e,item:t,index:n,onActivate:s,trailingAction:a})=>{const i=t.filename??de(t.src);return r.jsx(ba,{variant:e,filename:i,title:t.title,mimeType:"application/pdf",fileSize:t.fileSize,onActivate:()=>s(n),activateLabel:`Open ${i}`,trailingAction:a})},Pn=({state:e,src:t,filename:n,fileSize:s,title:a,items:i,text:o,groupPosition:l,onClick:c,onDismiss:u})=>{const m=Ve(e),f=eo({src:t,filename:n,fileSize:s,title:a,items:i}),{viewerOpen:h,viewerIndex:d,handleActivate:v,closeViewer:_}=Ge(c),x=e==="composer"&&!!u;if(f.length===0)return null;const p=f.map(b=>({src:b.src,filename:b.filename??de(b.src)}));return r.jsxs(He,{variant:m,text:o,groupPosition:l,"data-testid":"pdf-attachment",children:[r.jsx("div",{className:"flex flex-col gap-2",children:f.map((b,w)=>{const C=b.filename??de(b.src),E=x&&w===0?r.jsx(xt,{onClick:u,variant:"inline"}):e==="composer"?void 0:r.jsx(va,{url:b.src,filename:C,variant:"inline",label:`Download ${C}`,tone:m});return r.jsx(to,{variant:m,item:b,index:w,onActivate:v,trailingAction:E},`${b.src}-${w}`)})}),r.jsx(Ji,{open:h,items:p,initialIndex:d,onClose:_})]})},no=e=>r.jsx(Pn,{...e,state:"composer"}),so=e=>r.jsx(Pn,{...e,state:"sent"}),ao=e=>r.jsx(Pn,{...e,state:"received"}),ro={Composer:no,Sent:so,Received:ao},Na=({open:e,items:t,initialIndex:n=0,onClose:s})=>{const{index:a,prev:i,next:o}=Ln({length:t.length,initialIndex:n,open:e}),l=t[a],c=g.useMemo(()=>(l==null?void 0:l.filename)??(l?de(l.src):"video"),[l]);return l?r.jsxs(zn,{open:e,onClose:s,ariaLabel:c,counter:t.length>1?`${a+1} / ${t.length}`:void 0,"data-testid":"video-viewer",children:[r.jsx("video",{src:l.src,poster:l.poster,controls:!0,autoPlay:!0,muted:!0,playsInline:!0,preload:l.preload??"metadata",className:"mes-media-viewer__video",children:l.mimeType?r.jsx("source",{src:l.src,type:l.mimeType}):null},`${a}:${l.src}`),t.length>1?r.jsx(An,{onPrev:i,onNext:o,prevLabel:"Previous video",nextLabel:"Next video"}):null]}):null},io=()=>r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:r.jsx("span",{className:"flex size-12 items-center justify-center rounded-full bg-black/55 text-white backdrop-blur",children:r.jsx(M.PlayIcon,{className:"size-6",weight:"fill","aria-hidden":!0})})}),ka=({item:e,index:t})=>r.jsxs("div",{className:"absolute inset-0 size-full bg-[#0d0d0d]",children:[e.poster?r.jsx("img",{src:e.poster,alt:`Video ${t+1} thumbnail`,draggable:!1,loading:"lazy",decoding:"async",className:"absolute inset-0 size-full object-cover"}):r.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:r.jsx(M.VideoCameraIcon,{className:"size-16 text-white/30",weight:"regular","aria-hidden":!0})}),r.jsx(io,{})]}),oo=(e,t,n)=>({ariaLabel:`Play video ${t+1} of ${n}`,content:r.jsx(ka,{item:e,index:t})}),lo=({src:e,poster:t,mimeType:n,preload:s,items:a})=>a&&a.length>0?s?a.map(i=>({...i,preload:i.preload??s})):a:e?[{src:e,poster:t,mimeType:n,preload:s}]:[],Ma=(e,t)=>e.map((n,s)=>({src:n.src,poster:n.poster,mimeType:n.mimeType,preload:n.preload,filename:t&&e.length===1?t:t?`${t} (${s+1})`:void 0})),co=({src:e,poster:t,mimeType:n,filename:s,preload:a,onClick:i,onDismiss:o})=>{const{viewerOpen:l,viewerIndex:c,handleActivate:u,closeViewer:m}=Ge(i);return r.jsxs("div",{className:"relative w-fit",children:[r.jsx("button",{type:"button",onClick:()=>u(0),"aria-label":"Play video",className:"relative block size-[280px] cursor-pointer overflow-hidden rounded-md outline-none focus-visible:ring-2 focus-visible:ring-black/40",children:r.jsx(ka,{item:{src:e,poster:t,mimeType:n},index:0})}),o?r.jsx("div",{className:"absolute right-2 top-2 z-10",children:r.jsx(xt,{onClick:o})}):null,r.jsx(Na,{open:l,items:Ma([{src:e,poster:t,mimeType:n,preload:a}],s),initialIndex:c,onClose:m})]})},Ca=({state:e,src:t,poster:n,mimeType:s,filename:a,items:i,text:o,groupPosition:l,preload:c,onClick:u})=>{const m=lo({src:t,poster:n,mimeType:s,preload:c,items:i}),f=Ve(e),{viewerOpen:h,viewerIndex:d,handleActivate:v,closeViewer:_}=Ge(u);if(m.length===0)return null;const x=m.map((p,b)=>oo(p,b,m.length));return r.jsxs(He,{variant:f,text:o,groupPosition:l,"data-testid":"video-attachment",children:[r.jsx("div",{className:"relative",children:r.jsx(ya,{tiles:x,onTileActivate:v})}),r.jsx(Na,{open:h,items:Ma(m,a),initialIndex:d,onClose:_})]})},uo=e=>r.jsx(co,{...e}),fo=e=>r.jsx(Ca,{...e,state:"sent"}),mo=e=>r.jsx(Ca,{...e,state:"received"}),ho={Composer:uo,Sent:fo,Received:mo},Re={Image:Ki,Video:ho,Audio:Si,Pdf:ro,File:$i},go={isUnlocking:()=>!1},xo={LockedAttachment:go},Sa=g.createContext({}),po=Sa.Provider;function Ta(e){return g.useContext(Sa)[e]??xo[e]}const bo=g.lazy(()=>Promise.resolve().then(()=>require("./Card-415OfRhw.cjs"))),vo=g.lazy(()=>Promise.resolve().then(()=>require("./Card-Gr4HDVbn.cjs"))),_o=()=>r.jsx("div",{className:"w-[280px] min-h-[200px] animate-pulse rounded-md bg-black/[0.06] shadow-[0_0_0_1px_rgba(0,0,0,0.04),0_1px_2px_rgba(0,0,0,0.04),0_8px_32px_rgba(0,0,0,0.1)]","aria-hidden":!0}),Oe=e=>r.jsx(g.Suspense,{fallback:r.jsx(_o,{}),children:e.contentType==="text"?r.jsx(bo,{...e}):r.jsx(vo,{...e})}),yo=({size:e=15})=>r.jsx("svg",{width:e,height:e,viewBox:"0 0 15 15",fill:"none","aria-hidden":"true",children:r.jsx("path",{d:"M12.003 9a.985.985 0 0 1-.652.934l-3.223 1.191-1.188 3.226a.995.995 0 0 1-1.867 0l-1.195-3.226L.65 9.937a.995.995 0 0 1 0-1.867l3.227-1.195 1.187-3.226a.995.995 0 0 1 1.868 0l1.195 3.226 3.226 1.187a.99.99 0 0 1 .649.938m3-5.83a.52.52 0 0 1-.344.492l-1.702.63-.627 1.703a.525.525 0 0 1-.986 0l-.63-1.704-1.704-.627a.525.525 0 0 1 0-.986l1.703-.63.627-1.704a.526.526 0 0 1 .986 0l.631 1.703 1.704.627a.52.52 0 0 1 .342.495",fill:"currentColor",fillOpacity:.55})}),wo=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===se.MESSAGE_CUSTOM_TYPE.TIP},Ea=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===se.MESSAGE_CUSTOM_TYPE.PAID},tt=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===se.MESSAGE_CUSTOM_TYPE.CHATBOT},$n=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===se.MESSAGE_CUSTOM_TYPE.ATTACHMENT},jo=e=>{var t;return $n(e)&&((t=e.metadata)==null?void 0:t.attachment_content_type)==="text"},No=e=>{var t;return $n(e)&&((t=e.metadata)==null?void 0:t.attachment_content_type)!=="text"},Ia=e=>wo(e)||Ea(e),ko=e=>{var t;return Ia(e)&&!((t=e.text)!=null&&t.trim())},At=({message:e,standalone:t=!1,isMyMessage:n=!1,hasAttachment:s=!1})=>{var f;const a=Ia(e),i=tt(e);if(!a&&!i)return null;if(a){const h=(f=e.metadata)==null?void 0:f.amount_text;if(!h)return null;const d=t?"message-tip-standalone":"message-tag message-tag--tip",v=Ea(e)?"message":"tip",_=t?`${h} ${v}`:`Delivered with ${h} ${v}`;return r.jsxs("div",{className:d,children:[r.jsx(M.GiftIcon,{size:t?14:12}),r.jsx("span",{children:_})]})}const o=n&&s,l=o?"Sent with AI":"Sent by AI Assistant",c=["message-chatbot-indicator",n?"message-chatbot-indicator--sender":"message-chatbot-indicator--receiver",o?"message-chatbot-indicator--attachment":"message-chatbot-indicator--text"].join(" "),u=r.jsx("span",{className:"message-chatbot-indicator__label",children:l}),m=r.jsx("span",{className:"message-chatbot-indicator__icon",children:r.jsx(yo,{size:o?12:15})});return r.jsx("div",{className:c,"data-testid":"message-chatbot-indicator",children:n&&!o?r.jsxs(r.Fragment,{children:[u,m]}):r.jsxs(r.Fragment,{children:[m,u]})})},Ra=({selected:e,onVoteUp:t,onVoteDown:n})=>r.jsxs("div",{className:"message-vote-buttons",children:[r.jsx("button",{type:"button",className:S("message-vote-button focus-ring",{"message-vote-button--selected":e==="up"}),onClick:t,"aria-label":"Good response","aria-pressed":e==="up","data-tooltip":"Good response",children:r.jsx(M.ThumbsUpIcon,{size:16,weight:e==="up"?"fill":"regular"})}),r.jsx("button",{type:"button",className:S("message-vote-button focus-ring",{"message-vote-button--selected":e==="down"}),onClick:n,"aria-label":"Bad response","aria-pressed":e==="down","data-tooltip":"Bad response",children:r.jsx(M.ThumbsDownIcon,{size:16,weight:e==="down"?"fill":"regular"})})]}),Dn=()=>{const{message:e}=j.useMessageContext("SentMessageDeliveryStatus"),{messages:t}=j.useChannelStateContext("SentMessageDeliveryStatus"),n=(()=>{if(t)for(let s=t.length-1;s>=0;s-=1){const a=t[s];if(!(a.type==="system"||a.type==="ephemeral"||a.type==="deleted"))return a.id}})();return e.id===n},Lt=()=>Dn()?r.jsxs(r.Fragment,{children:[r.jsx(M.ChecksIcon,{weight:"bold","aria-hidden":"true"}),r.jsx("span",{"data-testid":"sent-message-delivery-status",children:"Delivered"})]}):null,Mo=()=>Dn()?r.jsxs(r.Fragment,{children:[r.jsx(M.CircleNotchIcon,{className:"sent-message-status__spinner animate-spin",weight:"bold","aria-hidden":"true"}),r.jsx("span",{"data-testid":"sent-message-sending-status",children:"Sending"})]}):null,Co=({broadcastId:e,broadcastName:t,onBroadcastClick:n})=>{const s=t||"Broadcast",a=r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"sent-message-broadcast-badge","aria-hidden":"true",children:r.jsx(M.MegaphoneIcon,{weight:"fill"})}),r.jsx("span",{className:"sent-message-broadcast-name","data-testid":"sent-message-broadcast-status",children:s})]});return n?r.jsx("button",{type:"button",className:"sent-message-broadcast-link","aria-label":`View broadcast ${s}`,onClick:()=>n({id:e,...t?{name:t}:{}}),children:a}):a},So=()=>r.jsxs("span",{className:"str-chat__message-status sent-message-status--failed",children:[r.jsx(M.WarningCircleIcon,{weight:"bold","aria-hidden":"true"}),r.jsx("span",{"data-testid":"sent-message-failed-status",children:"Failed to send"})]}),To=({onBroadcastClick:e})=>{var m,f;const{isMyMessage:t,message:n,threadList:s}=j.useMessageContext("SentMessageDeliveryStatus"),a=t(),i=Dn();if(s)return null;if(n.status==="failed"&&a&&n.type!=="error")return r.jsx(So,{});if(!a)return null;const o=(m=n.metadata)==null?void 0:m.broadcast_id,l=(f=n.metadata)==null?void 0:f.broadcast_name,c=n.status!=="sending"&&n.status!=="failed"&&o?r.jsx(Co,{broadcastId:o,broadcastName:l,onBroadcastClick:e}):null,u=r.jsx(j.MessageStatus,{MessageSentStatus:Lt,MessageDeliveredStatus:Lt,MessageReadStatus:Lt,MessageSendingStatus:Mo});return c?r.jsxs("span",{className:"sent-message-status-row",children:[u,i&&r.jsx("span",{className:"sent-message-broadcast-separator","aria-hidden":"true",children:"•"}),c]}):u},Eo=/^([a-z][a-z0-9+.-]*):/i,Io=new Set(["http","https","mailto","tel","sms"]);function On(e){if(typeof e!="string")return;const t=e.trim();if(t==="")return;const n=Eo.exec(t);if(n){const s=n[1].toLowerCase();return Io.has(s)?t:void 0}return t.startsWith("//")||t.startsWith("/")?t:`https://${t}`}const Ro={dark:"bg-white text-[#121110] hover:bg-white/90",light:"bg-[#121110] text-white hover:bg-[#2a2928]"},Ao=({variant:e,cta:t})=>{const n=S("mt-2 inline-flex h-10 w-full items-center justify-center rounded-full px-4 text-sm font-medium leading-none transition-colors",Ro[e]),s=On(t.href);return s?r.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",onClick:a=>{var i;a.stopPropagation(),(i=t.onClick)==null||i.call(t)},className:`${n} no-underline`,children:t.label}):r.jsx("button",{type:"button",onClick:a=>{var i;a.stopPropagation(),(i=t.onClick)==null||i.call(t)},className:n,children:t.label})},Lo={dark:"text-white",light:"text-black/90"},zo="text-white/30",Po={dark:"text-white/55",light:"text-black/55"},$o={dark:"bg-white/25",light:"bg-black/15"},Fn=({variant:e,chinTextColor:t,title:n,placeholderTitle:s,description:a,url:i,appIcon:o,cta:l,trailingAction:c,isLoading:u=!1})=>{const m=e==="dark",f=n??(m?s:void 0)??"",h=f.trim()!=="",d=a!=null&&a.trim()!=="",v=typeof i=="string"?i.trim():"",_=v!=="",x=l!=null;if(!u&&!h&&!d&&!_&&!x)return null;const p=m&&!n,b=S("line-clamp-2 text-[14px] font-medium leading-5 tracking-[0.28px]",t==null&&(p?zo:Lo[e])),w=S("truncate text-[12px] leading-4 tracking-[0.24px]",t==null&&Po[e]);if(u){const E=S("animate-pulse rounded",$o[e]);return r.jsx("div",{className:"shrink-0 px-4 py-3",children:r.jsxs("div",{className:"flex min-w-0 flex-col gap-[2px]",children:[r.jsx("div",{className:S("h-5 w-3/4",E),"aria-hidden":!0}),r.jsx("div",{className:S("h-4 w-1/2",E),"aria-hidden":!0})]})})}const C=t?{color:t}:void 0;return r.jsxs("div",{className:"shrink-0 px-4 py-3",children:[r.jsxs("div",{className:"flex items-end gap-3",children:[r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-[2px]",children:[h&&r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[o?r.jsx("span",{className:"shrink-0",children:o}):null,r.jsx("p",{className:S("min-w-0",b),style:C,children:f})]}),d&&r.jsx("p",{className:w,style:C,children:a}),!x&&_&&r.jsx("p",{className:w,style:C,children:v})]}),c&&r.jsx("div",{className:"shrink-0",children:c})]}),l&&r.jsx(Ao,{variant:e,cta:l})]})},Do="Loading link preview",Oo=S("relative w-[290px] select-none overflow-hidden","rounded-[20px]"),Fo="flex h-[250px] flex-col",nt=({variant:e,children:t,href:n,onClick:s,ariaLabel:a,rootRef:i,topRight:o,bgClassName:l,accentStyle:c,fixedHeight:u=!1,busy:m=!1,"data-testid":f})=>{const h=n!=null||s!=null,d=S(Oo,u?Fo:"block",l??(e==="dark"?"bg-[#1e2330]":"bg-[#f1f0ee]"),h?"cursor-pointer no-underline focus-ring":null),v=m?{role:"status","aria-busy":!0,"aria-label":Do}:void 0,_=o?r.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:o}):null;return n?r.jsxs("a",{ref:i,href:n,target:"_blank",rel:"noopener noreferrer",onClick:s,"data-testid":f,className:d,style:c,...v,children:[t,_]}):s?r.jsxs("button",{ref:i,type:"button",onClick:s,"aria-label":a,"data-testid":f,className:S(d,"text-left"),style:c,...v,children:[t,_]}):r.jsxs("div",{ref:i,"data-testid":f,className:d,style:c,...v,children:[t,_]})},ws={dark:"bg-white/10",light:"bg-black/5"},Bo={dark:"size-16 text-white/25",light:"size-16 text-black/25"},qe=(e,t)=>!!t&&!!e&&ue(e)==="audio",Bn=(e,t)=>{if(!t||!e)return!1;const n=ue(e);return n==="video"||n==="audio"},Uo="#F2F3F4",Un="bg-[#F2F3F4]",st=({variant:e,thumbnailUrl:t,sourceUrl:n,title:s,mimeType:a="image/*",topLeft:i,topRight:o,isLoading:l=!1,onImageError:c})=>{const u=ue(a),m=!!n&&u==="video",f=be(t);return!l&&qe(a,n)?r.jsx("div",{className:"p-3",children:r.jsx("audio",{src:n,controls:!0,preload:"metadata",className:"block w-full",children:r.jsx("track",{kind:"captions"})})}):r.jsxs("div",{className:S("relative min-h-0 w-full flex-1 overflow-hidden",m&&"bg-black"),children:[l?r.jsx("div",{className:S("h-full w-full animate-pulse",ws[e]),"aria-hidden":!0}):m?r.jsxs(r.Fragment,{children:[r.jsx("video",{src:n,poster:f,controls:!0,playsInline:!0,preload:"metadata",className:"absolute inset-0 h-full w-full object-contain",children:r.jsx("track",{kind:"captions"})}),f&&c?r.jsx("img",{src:f,alt:"","aria-hidden":!0,onError:c,className:"hidden"}):null]}):t?r.jsx("img",{src:f??t,alt:s??"",draggable:!1,loading:"lazy",decoding:"async",onError:c,className:"absolute inset-0 h-full w-full object-cover"}):r.jsx("div",{className:S("flex h-full w-full items-center justify-center",ws[e]),children:Ne(a,{className:Bo[e],weight:"regular"})}),i?r.jsx("div",{className:"pointer-events-auto absolute left-3 top-3 z-10",children:i}):null,o?r.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-10",children:o}):null]})},Aa=(e,t)=>{if(typeof e=="number"){if(t===3)return{mode:"rgb",r:(e>>8&15|e>>4&240)/255,g:(e>>4&15|e&240)/255,b:(e&15|e<<4&240)/255};if(t===4)return{mode:"rgb",r:(e>>12&15|e>>8&240)/255,g:(e>>8&15|e>>4&240)/255,b:(e>>4&15|e&240)/255,alpha:(e&15|e<<4&240)/255};if(t===6)return{mode:"rgb",r:(e>>16&255)/255,g:(e>>8&255)/255,b:(e&255)/255};if(t===8)return{mode:"rgb",r:(e>>24&255)/255,g:(e>>16&255)/255,b:(e>>8&255)/255,alpha:(e&255)/255}}},Ho={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Vo=e=>Aa(Ho[e.toLowerCase()],6),Go=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,qo=e=>{let t;return(t=e.match(Go))?Aa(parseInt(t[1],16),t[1].length):void 0},pe="([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)",Be=`${pe}%`,Hn=`(?:${pe}%|${pe})`,Yo=`(?:${pe}(deg|grad|rad|turn)|${pe})`,Le="\\s*,\\s*",Xo=new RegExp(`^rgba?\\(\\s*${pe}${Le}${pe}${Le}${pe}\\s*(?:,\\s*${Hn}\\s*)?\\)$`),Wo=new RegExp(`^rgba?\\(\\s*${Be}${Le}${Be}${Le}${Be}\\s*(?:,\\s*${Hn}\\s*)?\\)$`),Zo=e=>{let t={mode:"rgb"},n;if(n=e.match(Xo))n[1]!==void 0&&(t.r=n[1]/255),n[2]!==void 0&&(t.g=n[2]/255),n[3]!==void 0&&(t.b=n[3]/255);else if(n=e.match(Wo))n[1]!==void 0&&(t.r=n[1]/100),n[2]!==void 0&&(t.g=n[2]/100),n[3]!==void 0&&(t.b=n[3]/100);else return;return n[4]!==void 0?t.alpha=Math.max(0,Math.min(1,n[4]/100)):n[5]!==void 0&&(t.alpha=Math.max(0,Math.min(1,+n[5]))),t},at=(e,t)=>e===void 0?void 0:typeof e!="object"?rl(e):e.mode!==void 0?e:t?{...e,mode:t}:void 0,ce=(e="rgb")=>t=>(t=at(t,e))!==void 0?t.mode===e?t:le[t.mode][e]?le[t.mode][e](t):e==="rgb"?le[t.mode].rgb(t):le.rgb[e](le[t.mode].rgb(t)):void 0,le={},La={},rt=[],za={},Ko=e=>e,G=e=>(le[e.mode]={...le[e.mode],...e.toMode},Object.keys(e.fromMode||{}).forEach(t=>{le[t]||(le[t]={}),le[t][e.mode]=e.fromMode[t]}),e.ranges||(e.ranges={}),e.difference||(e.difference={}),e.channels.forEach(t=>{if(e.ranges[t]===void 0&&(e.ranges[t]=[0,1]),!e.interpolate[t])throw new Error(`Missing interpolator for: ${t}`);typeof e.interpolate[t]=="function"&&(e.interpolate[t]={use:e.interpolate[t]}),e.interpolate[t].fixup||(e.interpolate[t].fixup=Ko)}),La[e.mode]=e,(e.parse||[]).forEach(t=>{Jo(t,e.mode)}),ce(e.mode)),pt=e=>La[e],Jo=(e,t)=>{if(typeof e=="string"){if(!t)throw new Error("'mode' required when 'parser' is a string");za[e]=t}else typeof e=="function"&&rt.indexOf(e)<0&&rt.push(e)},dn=/[^\x00-\x7F]|[a-zA-Z_]/,Qo=/[^\x00-\x7F]|[-\w]/,y={Function:"function",Ident:"ident",Number:"number",Percentage:"percentage",ParenClose:")",None:"none",Hue:"hue",Alpha:"alpha"};let z=0;function Je(e){let t=e[z],n=e[z+1];return t==="-"||t==="+"?/\d/.test(n)||n==="."&&/\d/.test(e[z+2]):t==="."?/\d/.test(n):/\d/.test(t)}function un(e){if(z>=e.length)return!1;let t=e[z];if(dn.test(t))return!0;if(t==="-"){if(e.length-z<2)return!1;let n=e[z+1];return!!(n==="-"||dn.test(n))}return!1}const el={deg:1,rad:180/Math.PI,grad:9/10,turn:360};function De(e){let t="";if((e[z]==="-"||e[z]==="+")&&(t+=e[z++]),t+=Qe(e),e[z]==="."&&/\d/.test(e[z+1])&&(t+=e[z++]+Qe(e)),(e[z]==="e"||e[z]==="E")&&((e[z+1]==="-"||e[z+1]==="+")&&/\d/.test(e[z+2])?t+=e[z++]+e[z++]+Qe(e):/\d/.test(e[z+1])&&(t+=e[z++]+Qe(e))),un(e)){let n=it(e);return n==="deg"||n==="rad"||n==="turn"||n==="grad"?{type:y.Hue,value:t*el[n]}:void 0}return e[z]==="%"?(z++,{type:y.Percentage,value:+t}):{type:y.Number,value:+t}}function Qe(e){let t="";for(;/\d/.test(e[z]);)t+=e[z++];return t}function it(e){let t="";for(;z<e.length&&Qo.test(e[z]);)t+=e[z++];return t}function tl(e){let t=it(e);return e[z]==="("?(z++,{type:y.Function,value:t}):t==="none"?{type:y.None,value:void 0}:{type:y.Ident,value:t}}function nl(e=""){let t=e.trim(),n=[],s;for(z=0;z<t.length;){if(s=t[z++],s===`
2
- `||s===" "||s===" "){for(;z<t.length&&(t[z]===`
3
- `||t[z]===" "||t[z]===" ");)z++;continue}if(s===",")return;if(s===")"){n.push({type:y.ParenClose});continue}if(s==="+"){if(z--,Je(t)){n.push(De(t));continue}return}if(s==="-"){if(z--,Je(t)){n.push(De(t));continue}if(un(t)){n.push({type:y.Ident,value:it(t)});continue}return}if(s==="."){if(z--,Je(t)){n.push(De(t));continue}return}if(s==="/"){for(;z<t.length&&(t[z]===`
4
- `||t[z]===" "||t[z]===" ");)z++;let a;if(Je(t)&&(a=De(t),a.type!==y.Hue)){n.push({type:y.Alpha,value:a});continue}if(un(t)&&it(t)==="none"){n.push({type:y.Alpha,value:{type:y.None,value:void 0}});continue}return}if(/\d/.test(s)){z--,n.push(De(t));continue}if(dn.test(s)){z--,n.push(tl(t));continue}return}return n}function sl(e){e._i=0;let t=e[e._i++];if(!t||t.type!==y.Function||t.value!=="color"||(t=e[e._i++],t.type!==y.Ident))return;const n=za[t.value];if(!n)return;const s={mode:n},a=Pa(e,!1);if(!a)return;const i=pt(n).channels;for(let o=0,l,c;o<i.length;o++)l=a[o],c=i[o],l.type!==y.None&&(s[c]=l.type===y.Number?l.value:l.value/100,c==="alpha"&&(s[c]=Math.max(0,Math.min(1,s[c]))));return s}function Pa(e,t){const n=[];let s;for(;e._i<e.length;){if(s=e[e._i++],s.type===y.None||s.type===y.Number||s.type===y.Alpha||s.type===y.Percentage||t&&s.type===y.Hue){n.push(s);continue}if(s.type===y.ParenClose){if(e._i<e.length)return;continue}return}if(!(n.length<3||n.length>4)){if(n.length===4){if(n[3].type!==y.Alpha)return;n[3]=n[3].value}return n.length===3&&n.push({type:y.None,value:void 0}),n.every(a=>a.type!==y.Alpha)?n:void 0}}function al(e,t){e._i=0;let n=e[e._i++];if(!n||n.type!==y.Function)return;let s=Pa(e,t);if(s)return s.unshift(n.value),s}const rl=e=>{if(typeof e!="string")return;const t=nl(e),n=t?al(t,!0):void 0;let s,a=0,i=rt.length;for(;a<i;)if((s=rt[a++](e,n))!==void 0)return s;return t?sl(t):void 0};function il(e,t){if(!t||t[0]!=="rgb"&&t[0]!=="rgba")return;const n={mode:"rgb"},[,s,a,i,o]=t;if(!(s.type===y.Hue||a.type===y.Hue||i.type===y.Hue))return s.type!==y.None&&(n.r=s.type===y.Number?s.value/255:s.value/100),a.type!==y.None&&(n.g=a.type===y.Number?a.value/255:a.value/100),i.type!==y.None&&(n.b=i.type===y.Number?i.value/255:i.value/100),o.type!==y.None&&(n.alpha=Math.min(1,Math.max(0,o.type===y.Number?o.value:o.value/100))),n}const ol=e=>e==="transparent"?{mode:"rgb",r:0,g:0,b:0,alpha:0}:void 0,ll=(e,t,n)=>e+n*(t-e),cl=e=>{let t=[];for(let n=0;n<e.length-1;n++){let s=e[n],a=e[n+1];s===void 0&&a===void 0?t.push(void 0):s!==void 0&&a!==void 0?t.push([s,a]):t.push(s!==void 0?[s,s]:[a,a])}return t},dl=e=>t=>{let n=cl(t);return s=>{let a=s*n.length,i=s>=1?n.length-1:Math.max(Math.floor(a),0),o=n[i];return o===void 0?void 0:e(o[0],o[1],a-i)}},N=dl(ll),J=e=>{let t=!1,n=e.map(s=>s!==void 0?(t=!0,s):1);return t?n:e},ze={mode:"rgb",channels:["r","g","b","alpha"],parse:[il,qo,Zo,Vo,ol,"srgb"],serialize:"srgb",interpolate:{r:N,g:N,b:N,alpha:{use:N,fixup:J}},gamut:!0,white:{r:1,g:1,b:1},black:{r:0,g:0,b:0}},zt=(e=0)=>Math.pow(Math.abs(e),563/256)*Math.sign(e),js=e=>{let t=zt(e.r),n=zt(e.g),s=zt(e.b),a={mode:"xyz65",x:.5766690429101305*t+.1855582379065463*n+.1882286462349947*s,y:.297344975250536*t+.6273635662554661*n+.0752914584939979*s,z:.0270313613864123*t+.0706888525358272*n+.9913375368376386*s};return e.alpha!==void 0&&(a.alpha=e.alpha),a},Pt=e=>Math.pow(Math.abs(e),256/563)*Math.sign(e),Ns=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a={mode:"a98",r:Pt(e*2.0415879038107465-t*.5650069742788597-.3447313507783297*n),g:Pt(e*-.9692436362808798+t*1.8759675015077206+.0415550574071756*n),b:Pt(e*.0134442806320312-t*.1183623922310184+1.0151749943912058*n)};return s!==void 0&&(a.alpha=s),a},$t=(e=0)=>{const t=Math.abs(e);return t<=.04045?e/12.92:(Math.sign(e)||1)*Math.pow((t+.055)/1.055,2.4)},Pe=({r:e,g:t,b:n,alpha:s})=>{let a={mode:"lrgb",r:$t(e),g:$t(t),b:$t(n)};return s!==void 0&&(a.alpha=s),a},Me=e=>{let{r:t,g:n,b:s,alpha:a}=Pe(e),i={mode:"xyz65",x:.4123907992659593*t+.357584339383878*n+.1804807884018343*s,y:.2126390058715102*t+.715168678767756*n+.0721923153607337*s,z:.0193308187155918*t+.119194779794626*n+.9505321522496607*s};return a!==void 0&&(i.alpha=a),i},Dt=(e=0)=>{const t=Math.abs(e);return t>.0031308?(Math.sign(e)||1)*(1.055*Math.pow(t,1/2.4)-.055):e*12.92},$e=({r:e,g:t,b:n,alpha:s},a="rgb")=>{let i={mode:a,r:Dt(e),g:Dt(t),b:Dt(n)};return s!==void 0&&(i.alpha=s),i},Ce=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=$e({r:e*3.2409699419045226-t*1.537383177570094-.4986107602930034*n,g:e*-.9692436362808796+t*1.8759675015077204+.0415550574071756*n,b:e*.0556300796969936-t*.2039769588889765+1.0569715142428784*n});return s!==void 0&&(a.alpha=s),a},ul={...ze,mode:"a98",parse:["a98-rgb"],serialize:"a98-rgb",fromMode:{rgb:e=>Ns(Me(e)),xyz65:Ns},toMode:{rgb:e=>Ce(js(e)),xyz65:js}},ne=e=>(e=e%360)<0?e+360:e,fl=(e,t)=>e.map((n,s,a)=>{if(n===void 0)return n;let i=ne(n);return s===0||e[s-1]===void 0?i:t(i-ne(a[s-1]))}).reduce((n,s)=>!n.length||s===void 0||n[n.length-1]===void 0?(n.push(s),n):(n.push(s+n[n.length-1]),n),[]),fe=e=>fl(e,t=>Math.abs(t)<=180?t:t-360*Math.sign(t)),te=[-.14861,1.78277,-.29227,-.90649,1.97294,0],ml=Math.PI/180,hl=180/Math.PI;let ks=te[3]*te[4],Ms=te[1]*te[4],Cs=te[1]*te[2]-te[0]*te[3];const gl=({r:e,g:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=(Cs*n+e*ks-t*Ms)/(Cs+ks-Ms),i=n-a,o=(te[4]*(t-a)-te[2]*i)/te[3],l={mode:"cubehelix",l:a,s:a===0||a===1?void 0:Math.sqrt(i*i+o*o)/(te[4]*a*(1-a))};return l.s&&(l.h=Math.atan2(o,i)*hl-120),s!==void 0&&(l.alpha=s),l},xl=({h:e,s:t,l:n,alpha:s})=>{let a={mode:"rgb"};e=(e===void 0?0:e+120)*ml,n===void 0&&(n=0);let i=t===void 0?0:t*n*(1-n),o=Math.cos(e),l=Math.sin(e);return a.r=n+i*(te[0]*o+te[1]*l),a.g=n+i*(te[2]*o+te[3]*l),a.b=n+i*(te[4]*o+te[5]*l),s!==void 0&&(a.alpha=s),a},bt=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.s||!t.s)return 0;let n=ne(e.h),s=ne(t.h),a=Math.sin((s-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.s*t.s)*a},pl=(e,t)=>{if(e.h===void 0||t.h===void 0)return 0;let n=ne(e.h),s=ne(t.h);return Math.abs(s-n)>180?n-(s-360*Math.sign(s-n)):s-n},vt=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.c||!t.c)return 0;let n=ne(e.h),s=ne(t.h),a=Math.sin((s-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.c*t.c)*a},me=e=>{let t=e.reduce((s,a)=>{if(a!==void 0){let i=a*Math.PI/180;s.sin+=Math.sin(i),s.cos+=Math.cos(i)}return s},{sin:0,cos:0}),n=Math.atan2(t.sin,t.cos)*180/Math.PI;return n<0?360+n:n},bl={mode:"cubehelix",channels:["h","s","l","alpha"],parse:["--cubehelix"],serialize:"--cubehelix",ranges:{h:[0,360],s:[0,4.614],l:[0,1]},fromMode:{rgb:gl},toMode:{rgb:xl},interpolate:{h:{use:N,fixup:fe},s:N,l:N,alpha:{use:N,fixup:J}},difference:{h:bt},average:{h:me}},ve=({l:e,a:t,b:n,alpha:s},a="lch")=>{t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.sqrt(t*t+n*n),o={mode:a,l:e,c:i};return i&&(o.h=ne(Math.atan2(n,t)*180/Math.PI)),s!==void 0&&(o.alpha=s),o},_e=({l:e,c:t,h:n,alpha:s},a="lab")=>{n===void 0&&(n=0);let i={mode:a,l:e,a:t?t*Math.cos(n/180*Math.PI):0,b:t?t*Math.sin(n/180*Math.PI):0};return s!==void 0&&(i.alpha=s),i},$a=Math.pow(29,3)/Math.pow(3,3),Da=Math.pow(6,3)/Math.pow(29,3),Z={X:.3457/.3585,Y:1,Z:(1-.3457-.3585)/.3585},Ae={X:.3127/.329,Y:1,Z:(1-.3127-.329)/.329};let Ot=e=>Math.pow(e,3)>Da?Math.pow(e,3):(116*e-16)/$a;const Oa=({l:e,a:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=(e+16)/116,i=t/500+a,o=a-n/200,l={mode:"xyz65",x:Ot(i)*Ae.X,y:Ot(a)*Ae.Y,z:Ot(o)*Ae.Z};return s!==void 0&&(l.alpha=s),l},_t=e=>Ce(Oa(e)),Ft=e=>e>Da?Math.cbrt(e):($a*e+16)/116,Fa=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Ft(e/Ae.X),i=Ft(t/Ae.Y),o=Ft(n/Ae.Z),l={mode:"lab65",l:116*i-16,a:500*(a-i),b:200*(i-o)};return s!==void 0&&(l.alpha=s),l},yt=e=>{let t=Fa(Me(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},ot=1,Ba=1,Ue=26/180*Math.PI,lt=Math.cos(Ue),ct=Math.sin(Ue),Ua=100/Math.log(139/100),fn=({l:e,c:t,h:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a={mode:"lab65",l:(Math.exp(e*ot/Ua)-1)/.0039},i=(Math.exp(.0435*t*Ba*ot)-1)/.075,o=i*Math.cos(n/180*Math.PI-Ue),l=i*Math.sin(n/180*Math.PI-Ue);return a.a=o*lt-l/.83*ct,a.b=o*ct+l/.83*lt,s!==void 0&&(a.alpha=s),a},mn=({l:e,a:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=t*lt+n*ct,i=.83*(n*lt-t*ct),o=Math.sqrt(a*a+i*i),l={mode:"dlch",l:Ua/ot*Math.log(1+.0039*e),c:Math.log(1+.075*o)/(.0435*Ba*ot)};return l.c&&(l.h=ne((Math.atan2(i,a)+Ue)/Math.PI*180)),s!==void 0&&(l.alpha=s),l},Ss=e=>fn(ve(e,"dlch")),Ts=e=>_e(mn(e),"dlab"),vl={mode:"dlab",parse:["--din99o-lab"],serialize:"--din99o-lab",toMode:{lab65:Ss,rgb:e=>_t(Ss(e))},fromMode:{lab65:Ts,rgb:e=>Ts(yt(e))},channels:["l","a","b","alpha"],ranges:{l:[0,100],a:[-40.09,45.501],b:[-40.469,44.344]},interpolate:{l:N,a:N,b:N,alpha:{use:N,fixup:J}}},_l={mode:"dlch",parse:["--din99o-lch"],serialize:"--din99o-lch",toMode:{lab65:fn,dlab:e=>_e(e,"dlab"),rgb:e=>_t(fn(e))},fromMode:{lab65:mn,dlab:e=>ve(e,"dlch"),rgb:e=>mn(yt(e))},channels:["l","c","h","alpha"],ranges:{l:[0,100],c:[0,51.484],h:[0,360]},interpolate:{l:N,c:N,h:{use:N,fixup:fe},alpha:{use:N,fixup:J}},difference:{h:vt},average:{h:me}};function yl({h:e,s:t,i:n,alpha:s}){e=ne(e!==void 0?e:0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.abs(e/60%2-1),i;switch(Math.floor(e/60)){case 0:i={r:n*(1+t*(3/(2-a)-1)),g:n*(1+t*(3*(1-a)/(2-a)-1)),b:n*(1-t)};break;case 1:i={r:n*(1+t*(3*(1-a)/(2-a)-1)),g:n*(1+t*(3/(2-a)-1)),b:n*(1-t)};break;case 2:i={r:n*(1-t),g:n*(1+t*(3/(2-a)-1)),b:n*(1+t*(3*(1-a)/(2-a)-1))};break;case 3:i={r:n*(1-t),g:n*(1+t*(3*(1-a)/(2-a)-1)),b:n*(1+t*(3/(2-a)-1))};break;case 4:i={r:n*(1+t*(3*(1-a)/(2-a)-1)),g:n*(1-t),b:n*(1+t*(3/(2-a)-1))};break;case 5:i={r:n*(1+t*(3/(2-a)-1)),g:n*(1-t),b:n*(1+t*(3*(1-a)/(2-a)-1))};break;default:i={r:n*(1-t),g:n*(1-t),b:n*(1-t)}}return i.mode="rgb",s!==void 0&&(i.alpha=s),i}function wl({r:e,g:t,b:n,alpha:s}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.max(e,t,n),i=Math.min(e,t,n),o={mode:"hsi",s:e+t+n===0?0:1-3*i/(e+t+n),i:(e+t+n)/3};return a-i!==0&&(o.h=(a===e?(t-n)/(a-i)+(t<n)*6:a===t?(n-e)/(a-i)+2:(e-t)/(a-i)+4)*60),s!==void 0&&(o.alpha=s),o}const jl={mode:"hsi",toMode:{rgb:yl},parse:["--hsi"],serialize:"--hsi",fromMode:{rgb:wl},channels:["h","s","i","alpha"],ranges:{h:[0,360]},gamut:"rgb",interpolate:{h:{use:N,fixup:fe},s:N,i:N,alpha:{use:N,fixup:J}},difference:{h:bt},average:{h:me}};function Nl({h:e,s:t,l:n,alpha:s}){e=ne(e!==void 0?e:0),t===void 0&&(t=0),n===void 0&&(n=0);let a=n+t*(n<.5?n:1-n),i=a-(a-n)*2*Math.abs(e/60%2-1),o;switch(Math.floor(e/60)){case 0:o={r:a,g:i,b:2*n-a};break;case 1:o={r:i,g:a,b:2*n-a};break;case 2:o={r:2*n-a,g:a,b:i};break;case 3:o={r:2*n-a,g:i,b:a};break;case 4:o={r:i,g:2*n-a,b:a};break;case 5:o={r:a,g:2*n-a,b:i};break;default:o={r:2*n-a,g:2*n-a,b:2*n-a}}return o.mode="rgb",s!==void 0&&(o.alpha=s),o}function kl({r:e,g:t,b:n,alpha:s}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.max(e,t,n),i=Math.min(e,t,n),o={mode:"hsl",s:a===i?0:(a-i)/(1-Math.abs(a+i-1)),l:.5*(a+i)};return a-i!==0&&(o.h=(a===e?(t-n)/(a-i)+(t<n)*6:a===t?(n-e)/(a-i)+2:(e-t)/(a-i)+4)*60),s!==void 0&&(o.alpha=s),o}const Ml=(e,t)=>{switch(t){case"deg":return+e;case"rad":return e/Math.PI*180;case"grad":return e/10*9;case"turn":return e*360}},Cl=new RegExp(`^hsla?\\(\\s*${Yo}${Le}${Be}${Le}${Be}\\s*(?:,\\s*${Hn}\\s*)?\\)$`),Sl=e=>{let t=e.match(Cl);if(!t)return;let n={mode:"hsl"};return t[3]!==void 0?n.h=+t[3]:t[1]!==void 0&&t[2]!==void 0&&(n.h=Ml(t[1],t[2])),t[4]!==void 0&&(n.s=Math.min(Math.max(0,t[4]/100),1)),t[5]!==void 0&&(n.l=Math.min(Math.max(0,t[5]/100),1)),t[6]!==void 0?n.alpha=Math.max(0,Math.min(1,t[6]/100)):t[7]!==void 0&&(n.alpha=Math.max(0,Math.min(1,+t[7]))),n};function Tl(e,t){if(!t||t[0]!=="hsl"&&t[0]!=="hsla")return;const n={mode:"hsl"},[,s,a,i,o]=t;if(s.type!==y.None){if(s.type===y.Percentage)return;n.h=s.value}if(a.type!==y.None){if(a.type===y.Hue)return;n.s=a.value/100}if(i.type!==y.None){if(i.type===y.Hue)return;n.l=i.value/100}return o.type!==y.None&&(n.alpha=Math.min(1,Math.max(0,o.type===y.Number?o.value:o.value/100))),n}const Ha={mode:"hsl",toMode:{rgb:Nl},fromMode:{rgb:kl},channels:["h","s","l","alpha"],ranges:{h:[0,360]},gamut:"rgb",parse:[Tl,Sl],serialize:e=>`hsl(${e.h!==void 0?e.h:"none"} ${e.s!==void 0?e.s*100+"%":"none"} ${e.l!==void 0?e.l*100+"%":"none"}${e.alpha<1?` / ${e.alpha}`:""})`,interpolate:{h:{use:N,fixup:fe},s:N,l:N,alpha:{use:N,fixup:J}},difference:{h:bt},average:{h:me}};function Va({h:e,s:t,v:n,alpha:s}){e=ne(e!==void 0?e:0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.abs(e/60%2-1),i;switch(Math.floor(e/60)){case 0:i={r:n,g:n*(1-t*a),b:n*(1-t)};break;case 1:i={r:n*(1-t*a),g:n,b:n*(1-t)};break;case 2:i={r:n*(1-t),g:n,b:n*(1-t*a)};break;case 3:i={r:n*(1-t),g:n*(1-t*a),b:n};break;case 4:i={r:n*(1-t*a),g:n*(1-t),b:n};break;case 5:i={r:n,g:n*(1-t),b:n*(1-t*a)};break;default:i={r:n*(1-t),g:n*(1-t),b:n*(1-t)}}return i.mode="rgb",s!==void 0&&(i.alpha=s),i}function Ga({r:e,g:t,b:n,alpha:s}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.max(e,t,n),i=Math.min(e,t,n),o={mode:"hsv",s:a===0?0:1-i/a,v:a};return a-i!==0&&(o.h=(a===e?(t-n)/(a-i)+(t<n)*6:a===t?(n-e)/(a-i)+2:(e-t)/(a-i)+4)*60),s!==void 0&&(o.alpha=s),o}const qa={mode:"hsv",toMode:{rgb:Va},parse:["--hsv"],serialize:"--hsv",fromMode:{rgb:Ga},channels:["h","s","v","alpha"],ranges:{h:[0,360]},gamut:"rgb",interpolate:{h:{use:N,fixup:fe},s:N,v:N,alpha:{use:N,fixup:J}},difference:{h:bt},average:{h:me}};function El({h:e,w:t,b:n,alpha:s}){if(t===void 0&&(t=0),n===void 0&&(n=0),t+n>1){let a=t+n;t/=a,n/=a}return Va({h:e,s:n===1?1:1-t/(1-n),v:1-n,alpha:s})}function Il(e){let t=Ga(e);if(t===void 0)return;let n=t.s!==void 0?t.s:0,s=t.v!==void 0?t.v:0,a={mode:"hwb",w:(1-n)*s,b:1-s};return t.h!==void 0&&(a.h=t.h),t.alpha!==void 0&&(a.alpha=t.alpha),a}function Rl(e,t){if(!t||t[0]!=="hwb")return;const n={mode:"hwb"},[,s,a,i,o]=t;if(s.type!==y.None){if(s.type===y.Percentage)return;n.h=s.value}if(a.type!==y.None){if(a.type===y.Hue)return;n.w=a.value/100}if(i.type!==y.None){if(i.type===y.Hue)return;n.b=i.value/100}return o.type!==y.None&&(n.alpha=Math.min(1,Math.max(0,o.type===y.Number?o.value:o.value/100))),n}const Al={mode:"hwb",toMode:{rgb:El},fromMode:{rgb:Il},channels:["h","w","b","alpha"],ranges:{h:[0,360]},gamut:"rgb",parse:[Rl],serialize:e=>`hwb(${e.h!==void 0?e.h:"none"} ${e.w!==void 0?e.w*100+"%":"none"} ${e.b!==void 0?e.b*100+"%":"none"}${e.alpha<1?` / ${e.alpha}`:""})`,interpolate:{h:{use:N,fixup:fe},w:N,b:N,alpha:{use:N,fixup:J}},difference:{h:pl},average:{h:me}},Ya=203,wt=.1593017578125,Xa=78.84375,jt=.8359375,Nt=18.8515625,kt=18.6875;function Bt(e){if(e<0)return 0;const t=Math.pow(e,1/Xa);return 1e4*Math.pow(Math.max(0,t-jt)/(Nt-kt*t),1/wt)}function Ut(e){if(e<0)return 0;const t=Math.pow(e/1e4,wt);return Math.pow((jt+Nt*t)/(1+kt*t),Xa)}const Ht=e=>Math.max(e/Ya,0),Es=({i:e,t,p:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);const a=Bt(e+.008609037037932761*t+.11102962500302593*n),i=Bt(e-.00860903703793275*t-.11102962500302599*n),o=Bt(e+.5600313357106791*t-.32062717498731885*n),l={mode:"xyz65",x:Ht(2.070152218389422*a-1.3263473389671556*i+.2066510476294051*o),y:Ht(.3647385209748074*a+.680566024947227*i-.0453045459220346*o),z:Ht(-.049747207535812*a-.0492609666966138*i+1.1880659249923042*o)};return s!==void 0&&(l.alpha=s),l},Vt=(e=0)=>Math.max(e*Ya,0),Is=({x:e,y:t,z:n,alpha:s})=>{const a=Vt(e),i=Vt(t),o=Vt(n),l=Ut(.3592832590121217*a+.6976051147779502*i-.0358915932320289*o),c=Ut(-.1920808463704995*a+1.1004767970374323*i+.0753748658519118*o),u=Ut(.0070797844607477*a+.0748396662186366*i+.8433265453898765*o),m=.5*l+.5*c,f=1.61376953125*l-3.323486328125*c+1.709716796875*u,h=4.378173828125*l-4.24560546875*c-.132568359375*u,d={mode:"itp",i:m,t:f,p:h};return s!==void 0&&(d.alpha=s),d},Ll={mode:"itp",channels:["i","t","p","alpha"],parse:["--ictcp"],serialize:"--ictcp",toMode:{xyz65:Es,rgb:e=>Ce(Es(e))},fromMode:{xyz65:Is,rgb:e=>Is(Me(e))},ranges:{i:[0,.581],t:[-.369,.272],p:[-.164,.331]},interpolate:{i:N,t:N,p:N,alpha:{use:N,fixup:J}}},zl=134.03437499999998,Pl=16295499532821565e-27,Gt=e=>{if(e<0)return 0;let t=Math.pow(e/1e4,wt);return Math.pow((jt+Nt*t)/(1+kt*t),zl)},qt=(e=0)=>Math.max(e*203,0),Wa=({x:e,y:t,z:n,alpha:s})=>{e=qt(e),t=qt(t),n=qt(n);let a=1.15*e-.15*n,i=.66*t+.34*e,o=Gt(.41478972*a+.579999*i+.014648*n),l=Gt(-.20151*a+1.120649*i+.0531008*n),c=Gt(-.0166008*a+.2648*i+.6684799*n),u=(o+l)/2,m={mode:"jab",j:.44*u/(1-.56*u)-Pl,a:3.524*o-4.066708*l+.542708*c,b:.199076*o+1.096799*l-1.295875*c};return s!==void 0&&(m.alpha=s),m},$l=134.03437499999998,Rs=16295499532821565e-27,Yt=e=>{if(e<0)return 0;let t=Math.pow(e,1/$l);return 1e4*Math.pow((jt-t)/(kt*t-Nt),1/wt)},Xt=e=>e/203,Za=({j:e,a:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=(e+Rs)/(.44+.56*(e+Rs)),i=Yt(a+.13860504*t+.058047316*n),o=Yt(a-.13860504*t-.058047316*n),l=Yt(a-.096019242*t-.8118919*n),c={mode:"xyz65",x:Xt(1.661373024652174*i-.914523081304348*o+.23136208173913045*l),y:Xt(-.3250758611844533*i+1.571847026732543*o-.21825383453227928*l),z:Xt(-.090982811*i-.31272829*o+1.5227666*l)};return s!==void 0&&(c.alpha=s),c},Ka=e=>{let t=Wa(Me(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},Ja=e=>Ce(Za(e)),Dl={mode:"jab",channels:["j","a","b","alpha"],parse:["--jzazbz"],serialize:"--jzazbz",fromMode:{rgb:Ka,xyz65:Wa},toMode:{rgb:Ja,xyz65:Za},ranges:{j:[0,.222],a:[-.109,.129],b:[-.185,.134]},interpolate:{j:N,a:N,b:N,alpha:{use:N,fixup:J}}},As=({j:e,a:t,b:n,alpha:s})=>{t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.sqrt(t*t+n*n),i={mode:"jch",j:e,c:a};return a&&(i.h=ne(Math.atan2(n,t)*180/Math.PI)),s!==void 0&&(i.alpha=s),i},Ls=({j:e,c:t,h:n,alpha:s})=>{n===void 0&&(n=0);let a={mode:"jab",j:e,a:t?t*Math.cos(n/180*Math.PI):0,b:t?t*Math.sin(n/180*Math.PI):0};return s!==void 0&&(a.alpha=s),a},Ol={mode:"jch",parse:["--jzczhz"],serialize:"--jzczhz",toMode:{jab:Ls,rgb:e=>Ja(Ls(e))},fromMode:{rgb:e=>As(Ka(e)),jab:As},channels:["j","c","h","alpha"],ranges:{j:[0,.221],c:[0,.19],h:[0,360]},interpolate:{h:{use:N,fixup:fe},c:N,j:N,alpha:{use:N,fixup:J}},difference:{h:vt},average:{h:me}},Mt=Math.pow(29,3)/Math.pow(3,3),Vn=Math.pow(6,3)/Math.pow(29,3);let Wt=e=>Math.pow(e,3)>Vn?Math.pow(e,3):(116*e-16)/Mt;const Gn=({l:e,a:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=(e+16)/116,i=t/500+a,o=a-n/200,l={mode:"xyz50",x:Wt(i)*Z.X,y:Wt(a)*Z.Y,z:Wt(o)*Z.Z};return s!==void 0&&(l.alpha=s),l},Ye=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=$e({r:e*3.1341359569958707-t*1.6173863321612538-.4906619460083532*n,g:e*-.978795502912089+t*1.916254567259524+.03344273116131949*n,b:e*.07195537988411677-t*.2289768264158322+1.405386058324125*n});return s!==void 0&&(a.alpha=s),a},Qa=e=>Ye(Gn(e)),Xe=e=>{let{r:t,g:n,b:s,alpha:a}=Pe(e),i={mode:"xyz50",x:.436065742824811*t+.3851514688337912*n+.14307845442264197*s,y:.22249319175623702*t+.7168870538238823*n+.06061979053616537*s,z:.013923904500943465*t+.09708128566574634*n+.7140993584005155*s};return a!==void 0&&(i.alpha=a),i},Zt=e=>e>Vn?Math.cbrt(e):(Mt*e+16)/116,qn=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Zt(e/Z.X),i=Zt(t/Z.Y),o=Zt(n/Z.Z),l={mode:"lab",l:116*i-16,a:500*(a-i),b:200*(i-o)};return s!==void 0&&(l.alpha=s),l},er=e=>{let t=qn(Xe(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t};function Fl(e,t){if(!t||t[0]!=="lab")return;const n={mode:"lab"},[,s,a,i,o]=t;if(!(s.type===y.Hue||a.type===y.Hue||i.type===y.Hue))return s.type!==y.None&&(n.l=Math.min(Math.max(0,s.value),100)),a.type!==y.None&&(n.a=a.type===y.Number?a.value:a.value*125/100),i.type!==y.None&&(n.b=i.type===y.Number?i.value:i.value*125/100),o.type!==y.None&&(n.alpha=Math.min(1,Math.max(0,o.type===y.Number?o.value:o.value/100))),n}const Yn={mode:"lab",toMode:{xyz50:Gn,rgb:Qa},fromMode:{xyz50:qn,rgb:er},channels:["l","a","b","alpha"],ranges:{l:[0,100],a:[-125,125],b:[-125,125]},parse:[Fl],serialize:e=>`lab(${e.l!==void 0?e.l:"none"} ${e.a!==void 0?e.a:"none"} ${e.b!==void 0?e.b:"none"}${e.alpha<1?` / ${e.alpha}`:""})`,interpolate:{l:N,a:N,b:N,alpha:{use:N,fixup:J}}},Bl={...Yn,mode:"lab65",parse:["--lab-d65"],serialize:"--lab-d65",toMode:{xyz65:Oa,rgb:_t},fromMode:{xyz65:Fa,rgb:yt},ranges:{l:[0,100],a:[-125,125],b:[-125,125]}};function Ul(e,t){if(!t||t[0]!=="lch")return;const n={mode:"lch"},[,s,a,i,o]=t;if(s.type!==y.None){if(s.type===y.Hue)return;n.l=Math.min(Math.max(0,s.value),100)}if(a.type!==y.None&&(n.c=Math.max(0,a.type===y.Number?a.value:a.value*150/100)),i.type!==y.None){if(i.type===y.Percentage)return;n.h=i.value}return o.type!==y.None&&(n.alpha=Math.min(1,Math.max(0,o.type===y.Number?o.value:o.value/100))),n}const Xn={mode:"lch",toMode:{lab:_e,rgb:e=>Qa(_e(e))},fromMode:{rgb:e=>ve(er(e)),lab:ve},channels:["l","c","h","alpha"],ranges:{l:[0,100],c:[0,150],h:[0,360]},parse:[Ul],serialize:e=>`lch(${e.l!==void 0?e.l:"none"} ${e.c!==void 0?e.c:"none"} ${e.h!==void 0?e.h:"none"}${e.alpha<1?` / ${e.alpha}`:""})`,interpolate:{h:{use:N,fixup:fe},c:N,l:N,alpha:{use:N,fixup:J}},difference:{h:vt},average:{h:me}},Hl={...Xn,mode:"lch65",parse:["--lch-d65"],serialize:"--lch-d65",toMode:{lab65:e=>_e(e,"lab65"),rgb:e=>_t(_e(e,"lab65"))},fromMode:{rgb:e=>ve(yt(e),"lch65"),lab65:e=>ve(e,"lch65")},ranges:{l:[0,100],c:[0,150],h:[0,360]}},tr=({l:e,u:t,v:n,alpha:s})=>{t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.sqrt(t*t+n*n),i={mode:"lchuv",l:e,c:a};return a&&(i.h=ne(Math.atan2(n,t)*180/Math.PI)),s!==void 0&&(i.alpha=s),i},nr=({l:e,c:t,h:n,alpha:s})=>{n===void 0&&(n=0);let a={mode:"luv",l:e,u:t?t*Math.cos(n/180*Math.PI):0,v:t?t*Math.sin(n/180*Math.PI):0};return s!==void 0&&(a.alpha=s),a},sr=(e,t,n)=>4*e/(e+15*t+3*n),ar=(e,t,n)=>9*t/(e+15*t+3*n),Vl=sr(Z.X,Z.Y,Z.Z),Gl=ar(Z.X,Z.Y,Z.Z),ql=e=>e<=Vn?Mt*e:116*Math.cbrt(e)-16,hn=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=ql(t/Z.Y),i=sr(e,t,n),o=ar(e,t,n);!isFinite(i)||!isFinite(o)?a=i=o=0:(i=13*a*(i-Vl),o=13*a*(o-Gl));let l={mode:"luv",l:a,u:i,v:o};return s!==void 0&&(l.alpha=s),l},Yl=(e,t,n)=>4*e/(e+15*t+3*n),Xl=(e,t,n)=>9*t/(e+15*t+3*n),Wl=Yl(Z.X,Z.Y,Z.Z),Zl=Xl(Z.X,Z.Y,Z.Z),gn=({l:e,u:t,v:n,alpha:s})=>{if(e===void 0&&(e=0),e===0)return{mode:"xyz50",x:0,y:0,z:0};t===void 0&&(t=0),n===void 0&&(n=0);let a=t/(13*e)+Wl,i=n/(13*e)+Zl,o=Z.Y*(e<=8?e/Mt:Math.pow((e+16)/116,3)),l=o*(9*a)/(4*i),c=o*(12-3*a-20*i)/(4*i),u={mode:"xyz50",x:l,y:o,z:c};return s!==void 0&&(u.alpha=s),u},Kl=e=>tr(hn(Xe(e))),Jl=e=>Ye(gn(nr(e))),Ql={mode:"lchuv",toMode:{luv:nr,rgb:Jl},fromMode:{rgb:Kl,luv:tr},channels:["l","c","h","alpha"],parse:["--lchuv"],serialize:"--lchuv",ranges:{l:[0,100],c:[0,176.956],h:[0,360]},interpolate:{h:{use:N,fixup:fe},c:N,l:N,alpha:{use:N,fixup:J}},difference:{h:vt},average:{h:me}},ec={...ze,mode:"lrgb",toMode:{rgb:$e},fromMode:{rgb:Pe},parse:["srgb-linear"],serialize:"srgb-linear"},tc={mode:"luv",toMode:{xyz50:gn,rgb:e=>Ye(gn(e))},fromMode:{xyz50:hn,rgb:e=>hn(Xe(e))},channels:["l","u","v","alpha"],parse:["--luv"],serialize:"--luv",ranges:{l:[0,100],u:[-84.936,175.042],v:[-125.882,87.243]},interpolate:{l:N,u:N,v:N,alpha:{use:N,fixup:J}}},rr=({r:e,g:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.cbrt(.412221469470763*e+.5363325372617348*t+.0514459932675022*n),i=Math.cbrt(.2119034958178252*e+.6806995506452344*t+.1073969535369406*n),o=Math.cbrt(.0883024591900564*e+.2817188391361215*t+.6299787016738222*n),l={mode:"oklab",l:.210454268309314*a+.7936177747023054*i-.0040720430116193*o,a:1.9779985324311684*a-2.42859224204858*i+.450593709617411*o,b:.0259040424655478*a+.7827717124575296*i-.8086757549230774*o};return s!==void 0&&(l.alpha=s),l},Ct=e=>{let t=rr(Pe(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},We=({l:e,a:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.pow(e+.3963377773761749*t+.2158037573099136*n,3),i=Math.pow(e-.1055613458156586*t-.0638541728258133*n,3),o=Math.pow(e-.0894841775298119*t-1.2914855480194092*n,3),l={mode:"lrgb",r:4.076741636075957*a-3.3077115392580616*i+.2309699031821044*o,g:-1.2684379732850317*a+2.6097573492876887*i-.3413193760026573*o,b:-.0041960761386756*a-.7034186179359362*i+1.7076146940746117*o};return s!==void 0&&(l.alpha=s),l},St=e=>$e(We(e));function xn(e){const s=1.170873786407767;return .5*(s*e-.206+Math.sqrt((s*e-.206)*(s*e-.206)+4*.03*s*e))}function dt(e){return(e*e+.206*e)/(1.170873786407767*(e+.03))}function nc(e,t){let n,s,a,i,o,l,c,u;-1.88170328*e-.80936493*t>1?(n=1.19086277,s=1.76576728,a=.59662641,i=.75515197,o=.56771245,l=4.0767416621,c=-3.3077115913,u=.2309699292):1.81444104*e-1.19445276*t>1?(n=.73956515,s=-.45954404,a=.08285427,i=.1254107,o=.14503204,l=-1.2684380046,c=2.6097574011,u=-.3413193965):(n=1.35733652,s=-.00915799,a=-1.1513021,i=-.50559606,o=.00692167,l=-.0041960863,c=-.7034186147,u=1.707614701);let m=n+s*e+a*t+i*e*e+o*e*t,f=.3963377774*e+.2158037573*t,h=-.1055613458*e-.0638541728*t,d=-.0894841775*e-1.291485548*t;{let v=1+m*f,_=1+m*h,x=1+m*d,p=v*v*v,b=_*_*_,w=x*x*x,C=3*f*v*v,E=3*h*_*_,R=3*d*x*x,A=6*f*f*v,B=6*h*h*_,U=6*d*d*x,$=l*p+c*b+u*w,T=l*C+c*E+u*R,O=l*A+c*B+u*U;m=m-$*T/(T*T-.5*$*O)}return m}function Wn(e,t){let n=nc(e,t),s=We({l:1,a:n*e,b:n*t}),a=Math.cbrt(1/Math.max(s.r,s.g,s.b)),i=a*n;return[a,i]}function sc(e,t,n,s,a,i=null){i||(i=Wn(e,t));let o;if((n-a)*i[1]-(i[0]-a)*s<=0)o=i[1]*a/(s*i[0]+i[1]*(a-n));else{o=i[1]*(a-1)/(s*(i[0]-1)+i[1]*(a-n));{let l=n-a,c=s,u=.3963377774*e+.2158037573*t,m=-.1055613458*e-.0638541728*t,f=-.0894841775*e-1.291485548*t,h=l+c*u,d=l+c*m,v=l+c*f;{let _=a*(1-o)+o*n,x=o*s,p=_+x*u,b=_+x*m,w=_+x*f,C=p*p*p,E=b*b*b,R=w*w*w,A=3*h*p*p,B=3*d*b*b,U=3*v*w*w,$=6*h*h*p,T=6*d*d*b,O=6*v*v*w,I=4.0767416621*C-3.3077115913*E+.2309699292*R-1,L=4.0767416621*A-3.3077115913*B+.2309699292*U,P=4.0767416621*$-3.3077115913*T+.2309699292*O,D=L/(L*L-.5*I*P),V=-I*D,q=-1.2684380046*C+2.6097574011*E-.3413193965*R-1,W=-1.2684380046*A+2.6097574011*B-.3413193965*U,ae=-1.2684380046*$+2.6097574011*T-.3413193965*O,Q=W/(W*W-.5*q*ae),k=-q*Q,F=-.0041960863*C-.7034186147*E+1.707614701*R-1,X=-.0041960863*A-.7034186147*B+1.707614701*U,ee=-.0041960863*$-.7034186147*T+1.707614701*O,re=X/(X*X-.5*F*ee),K=-F*re;V=D>=0?V:1e6,k=Q>=0?k:1e6,K=re>=0?K:1e6,o+=Math.min(V,Math.min(k,K))}}}return o}function Zn(e,t,n=null){n||(n=Wn(e,t));let s=n[0],a=n[1];return[a/s,a/(1-s)]}function ir(e,t,n){let s=Wn(t,n),a=sc(t,n,e,1,e,s),i=Zn(t,n,s),o=.11516993+1/(7.4477897+4.1590124*n+t*(-2.19557347+1.75198401*n+t*(-2.13704948-10.02301043*n+t*(-4.24894561+5.38770819*n+4.69891013*t)))),l=.11239642+1/(1.6132032-.68124379*n+t*(.40370612+.90148123*n+t*(-.27087943+.6122399*n+t*(.00299215-.45399568*n-.14661872*t)))),c=a/Math.min(e*i[0],(1-e)*i[1]),u=e*o,m=(1-e)*l,f=.9*c*Math.sqrt(Math.sqrt(1/(1/(u*u*u*u)+1/(m*m*m*m))));return u=e*.4,m=(1-e)*.8,[Math.sqrt(1/(1/(u*u)+1/(m*m))),f,a]}function zs(e){const t=e.l!==void 0?e.l:0,n=e.a!==void 0?e.a:0,s=e.b!==void 0?e.b:0,a={mode:"okhsl",l:xn(t)};e.alpha!==void 0&&(a.alpha=e.alpha);let i=Math.sqrt(n*n+s*s);if(!i)return a.s=0,a;let[o,l,c]=ir(t,n/i,s/i),u;if(i<l){let m=0,f=.8*o,h=1-f/l;u=(i-m)/(f+h*(i-m))*.8}else{let m=l,f=.2*l*l*1.25*1.25/o,h=1-f/(c-l);u=.8+.2*((i-m)/(f+h*(i-m)))}return u&&(a.s=u,a.h=ne(Math.atan2(s,n)*180/Math.PI)),a}function Ps(e){let t=e.h!==void 0?e.h:0,n=e.s!==void 0?e.s:0,s=e.l!==void 0?e.l:0;const a={mode:"oklab",l:dt(s)};if(e.alpha!==void 0&&(a.alpha=e.alpha),!n||s===1)return a.a=a.b=0,a;let i=Math.cos(t/180*Math.PI),o=Math.sin(t/180*Math.PI),[l,c,u]=ir(a.l,i,o),m,f,h,d;n<.8?(m=1.25*n,f=0,h=.8*l,d=1-h/c):(m=5*(n-.8),f=c,h=.2*c*c*1.25*1.25/l,d=1-h/(u-c));let v=f+m*h/(1-d*m);return a.a=v*i,a.b=v*o,a}const ac={...Ha,mode:"okhsl",channels:["h","s","l","alpha"],parse:["--okhsl"],serialize:"--okhsl",fromMode:{oklab:zs,rgb:e=>zs(Ct(e))},toMode:{oklab:Ps,rgb:e=>St(Ps(e))}};function $s(e){let t=e.l!==void 0?e.l:0,n=e.a!==void 0?e.a:0,s=e.b!==void 0?e.b:0,a=Math.sqrt(n*n+s*s),i=a?n/a:1,o=a?s/a:1,[l,c]=Zn(i,o),u=.5,m=1-u/l,f=c/(a+t*c),h=f*t,d=f*a,v=dt(h),_=d*v/h,x=We({l:v,a:i*_,b:o*_}),p=Math.cbrt(1/Math.max(x.r,x.g,x.b,0));t=t/p,a=a/p*xn(t)/t,t=xn(t);const b={mode:"okhsv",s:a?(u+c)*d/(c*u+c*m*d):0,v:t?t/h:0};return b.s&&(b.h=ne(Math.atan2(s,n)*180/Math.PI)),e.alpha!==void 0&&(b.alpha=e.alpha),b}function Ds(e){const t={mode:"oklab"};e.alpha!==void 0&&(t.alpha=e.alpha);const n=e.h!==void 0?e.h:0,s=e.s!==void 0?e.s:0,a=e.v!==void 0?e.v:0,i=Math.cos(n/180*Math.PI),o=Math.sin(n/180*Math.PI),[l,c]=Zn(i,o),u=.5,m=1-u/l,f=1-s*u/(u+c-c*m*s),h=s*c*u/(u+c-c*m*s),d=dt(f),v=h*d/f,_=We({l:d,a:i*v,b:o*v}),x=Math.cbrt(1/Math.max(_.r,_.g,_.b,0)),p=dt(a*f),b=h*p/f;return t.l=p*x,t.a=b*i*x,t.b=b*o*x,t}const rc={...qa,mode:"okhsv",channels:["h","s","v","alpha"],parse:["--okhsv"],serialize:"--okhsv",fromMode:{oklab:$s,rgb:e=>$s(Ct(e))},toMode:{oklab:Ds,rgb:e=>St(Ds(e))}};function ic(e,t){if(!t||t[0]!=="oklab")return;const n={mode:"oklab"},[,s,a,i,o]=t;if(!(s.type===y.Hue||a.type===y.Hue||i.type===y.Hue))return s.type!==y.None&&(n.l=Math.min(Math.max(0,s.type===y.Number?s.value:s.value/100),1)),a.type!==y.None&&(n.a=a.type===y.Number?a.value:a.value*.4/100),i.type!==y.None&&(n.b=i.type===y.Number?i.value:i.value*.4/100),o.type!==y.None&&(n.alpha=Math.min(1,Math.max(0,o.type===y.Number?o.value:o.value/100))),n}const oc={...Yn,mode:"oklab",toMode:{lrgb:We,rgb:St},fromMode:{lrgb:rr,rgb:Ct},ranges:{l:[0,1],a:[-.4,.4],b:[-.4,.4]},parse:[ic],serialize:e=>`oklab(${e.l!==void 0?e.l:"none"} ${e.a!==void 0?e.a:"none"} ${e.b!==void 0?e.b:"none"}${e.alpha<1?` / ${e.alpha}`:""})`};function lc(e,t){if(!t||t[0]!=="oklch")return;const n={mode:"oklch"},[,s,a,i,o]=t;if(s.type!==y.None){if(s.type===y.Hue)return;n.l=Math.min(Math.max(0,s.type===y.Number?s.value:s.value/100),1)}if(a.type!==y.None&&(n.c=Math.max(0,a.type===y.Number?a.value:a.value*.4/100)),i.type!==y.None){if(i.type===y.Percentage)return;n.h=i.value}return o.type!==y.None&&(n.alpha=Math.min(1,Math.max(0,o.type===y.Number?o.value:o.value/100))),n}const cc={...Xn,mode:"oklch",toMode:{oklab:e=>_e(e,"oklab"),rgb:e=>St(_e(e,"oklab"))},fromMode:{rgb:e=>ve(Ct(e),"oklch"),oklab:e=>ve(e,"oklch")},parse:[lc],serialize:e=>`oklch(${e.l!==void 0?e.l:"none"} ${e.c!==void 0?e.c:"none"} ${e.h!==void 0?e.h:"none"}${e.alpha<1?` / ${e.alpha}`:""})`,ranges:{l:[0,1],c:[0,.4],h:[0,360]}},Os=e=>{let{r:t,g:n,b:s,alpha:a}=Pe(e),i={mode:"xyz65",x:.486570948648216*t+.265667693169093*n+.1982172852343625*s,y:.2289745640697487*t+.6917385218365062*n+.079286914093745*s,z:0*t+.0451133818589026*n+1.043944368900976*s};return a!==void 0&&(i.alpha=a),i},Fs=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a=$e({r:e*2.4934969119414263-t*.9313836179191242-.402710784450717*n,g:e*-.8294889695615749+t*1.7626640603183465+.0236246858419436*n,b:e*.0358458302437845-t*.0761723892680418+.9568845240076871*n},"p3");return s!==void 0&&(a.alpha=s),a},dc={...ze,mode:"p3",parse:["display-p3"],serialize:"display-p3",fromMode:{rgb:e=>Fs(Me(e)),xyz65:Fs},toMode:{rgb:e=>Ce(Os(e)),xyz65:Os}},Kt=e=>{let t=Math.abs(e);return t>=1/512?Math.sign(e)*Math.pow(t,1/1.8):16*e},Bs=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a={mode:"prophoto",r:Kt(e*1.3457868816471585-t*.2555720873797946-.0511018649755453*n),g:Kt(e*-.5446307051249019+t*1.5082477428451466+.0205274474364214*n),b:Kt(e*0+t*0+1.2119675456389452*n)};return s!==void 0&&(a.alpha=s),a},Jt=(e=0)=>{let t=Math.abs(e);return t>=16/512?Math.sign(e)*Math.pow(t,1.8):e/16},Us=e=>{let t=Jt(e.r),n=Jt(e.g),s=Jt(e.b),a={mode:"xyz50",x:.7977666449006423*t+.1351812974005331*n+.0313477341283922*s,y:.2880748288194013*t+.7118352342418731*n+899369387256e-16*s,z:0*t+0*n+.8251046025104602*s};return e.alpha!==void 0&&(a.alpha=e.alpha),a},uc={...ze,mode:"prophoto",parse:["prophoto-rgb"],serialize:"prophoto-rgb",fromMode:{xyz50:Bs,rgb:e=>Bs(Xe(e))},toMode:{xyz50:Us,rgb:e=>Ye(Us(e))}},Hs=1.09929682680944,fc=.018053968510807,Qt=e=>{const t=Math.abs(e);return t>fc?(Math.sign(e)||1)*(Hs*Math.pow(t,.45)-(Hs-1)):4.5*e},Vs=({x:e,y:t,z:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let a={mode:"rec2020",r:Qt(e*1.7166511879712683-t*.3556707837763925-.2533662813736599*n),g:Qt(e*-.6666843518324893+t*1.6164812366349395+.0157685458139111*n),b:Qt(e*.0176398574453108-t*.0427706132578085+.9421031212354739*n)};return s!==void 0&&(a.alpha=s),a},Gs=1.09929682680944,mc=.018053968510807,en=(e=0)=>{let t=Math.abs(e);return t<mc*4.5?e/4.5:(Math.sign(e)||1)*Math.pow((t+Gs-1)/Gs,1/.45)},qs=e=>{let t=en(e.r),n=en(e.g),s=en(e.b),a={mode:"xyz65",x:.6369580483012911*t+.1446169035862083*n+.1688809751641721*s,y:.262700212011267*t+.6779980715188708*n+.059301716469862*s,z:0*t+.0280726930490874*n+1.0609850577107909*s};return e.alpha!==void 0&&(a.alpha=e.alpha),a},hc={...ze,mode:"rec2020",fromMode:{xyz65:Vs,rgb:e=>Vs(Me(e))},toMode:{xyz65:qs,rgb:e=>Ce(qs(e))},parse:["rec2020"],serialize:"rec2020"},je=.0037930732552754493,or=Math.cbrt(je),tn=e=>Math.cbrt(e)-or,gc=e=>{const{r:t,g:n,b:s,alpha:a}=Pe(e),i=tn(.3*t+.622*n+.078*s+je),o=tn(.23*t+.692*n+.078*s+je),l=tn(.2434226892454782*t+.2047674442449682*n+.5518098665095535*s+je),c={mode:"xyb",x:(i-o)/2,y:(i+o)/2,b:l-(i+o)/2};return a!==void 0&&(c.alpha=a),c},nn=e=>Math.pow(e+or,3),xc=({x:e,y:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);const a=nn(e+t)-je,i=nn(t-e)-je,o=nn(n+t)-je,l=$e({r:11.031566904639861*a-9.866943908131562*i-.16462299650829934*o,g:-3.2541473810744237*a+4.418770377582723*i-.16462299650829934*o,b:-3.6588512867136815*a+2.7129230459360922*i+1.9459282407775895*o});return s!==void 0&&(l.alpha=s),l},pc={mode:"xyb",channels:["x","y","b","alpha"],parse:["--xyb"],serialize:"--xyb",toMode:{rgb:xc},fromMode:{rgb:gc},ranges:{x:[-.0154,.0281],y:[0,.8453],b:[-.2778,.388]},interpolate:{x:N,y:N,b:N,alpha:{use:N,fixup:J}}},bc={mode:"xyz50",parse:["xyz-d50"],serialize:"xyz-d50",toMode:{rgb:Ye,lab:qn},fromMode:{rgb:Xe,lab:Gn},channels:["x","y","z","alpha"],ranges:{x:[0,.964],y:[0,.999],z:[0,.825]},interpolate:{x:N,y:N,z:N,alpha:{use:N,fixup:J}}},vc=e=>{let{x:t,y:n,z:s,alpha:a}=e;t===void 0&&(t=0),n===void 0&&(n=0),s===void 0&&(s=0);let i={mode:"xyz50",x:1.0479298208405488*t+.0229467933410191*n-.0501922295431356*s,y:.0296278156881593*t+.990434484573249*n-.0170738250293851*s,z:-.0092430581525912*t+.0150551448965779*n+.7518742899580008*s};return a!==void 0&&(i.alpha=a),i},_c=e=>{let{x:t,y:n,z:s,alpha:a}=e;t===void 0&&(t=0),n===void 0&&(n=0),s===void 0&&(s=0);let i={mode:"xyz65",x:.9554734527042182*t-.0230985368742614*n+.0632593086610217*s,y:-.0283697069632081*t+1.0099954580058226*n+.021041398966943*s,z:.0123140016883199*t-.0205076964334779*n+1.3303659366080753*s};return a!==void 0&&(i.alpha=a),i},yc={mode:"xyz65",toMode:{rgb:Ce,xyz50:vc},fromMode:{rgb:Me,xyz50:_c},ranges:{x:[0,.95],y:[0,1],z:[0,1.088]},channels:["x","y","z","alpha"],parse:["xyz","xyz-d65"],serialize:"xyz-d65",interpolate:{x:N,y:N,z:N,alpha:{use:N,fixup:J}}},wc=({r:e,g:t,b:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);const a={mode:"yiq",y:.29889531*e+.58662247*t+.11448223*n,i:.59597799*e-.2741761*t-.32180189*n,q:.21147017*e-.52261711*t+.31114694*n};return s!==void 0&&(a.alpha=s),a},jc=({y:e,i:t,q:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);const a={mode:"rgb",r:e+.95608445*t+.6208885*n,g:e-.27137664*t-.6486059*n,b:e-1.10561724*t+1.70250126*n};return s!==void 0&&(a.alpha=s),a},Nc={mode:"yiq",toMode:{rgb:jc},fromMode:{rgb:wc},channels:["y","i","q","alpha"],parse:["--yiq"],serialize:"--yiq",ranges:{i:[-.595,.595],q:[-.522,.522]},interpolate:{y:N,i:N,q:N,alpha:{use:N,fixup:J}}},kc=e=>Math.max(0,Math.min(1,e||0)),sn=e=>Math.round(kc(e)*255),Mc=ce("rgb"),Cc=e=>{if(e===void 0)return;let t=sn(e.r),n=sn(e.g),s=sn(e.b);return"#"+(1<<24|t<<16|n<<8|s).toString(16).slice(1)},Sc=e=>Cc(Mc(e)),lr=ce("rgb"),cr=e=>{const t={mode:e.mode,r:Math.max(0,Math.min(e.r!==void 0?e.r:0,1)),g:Math.max(0,Math.min(e.g!==void 0?e.g:0,1)),b:Math.max(0,Math.min(e.b!==void 0?e.b:0,1))};return e.alpha!==void 0&&(t.alpha=e.alpha),t},Tc=e=>cr(lr(e)),dr=e=>e!==void 0&&(e.r===void 0||e.r>=0&&e.r<=1)&&(e.g===void 0||e.g>=0&&e.g<=1)&&(e.b===void 0||e.b>=0&&e.b<=1);function Ec(e){return dr(lr(e))}function ur(e="rgb"){const{gamut:t}=pt(e);if(!t)return s=>!0;const n=ce(typeof t=="string"?t:e);return s=>dr(n(s))}function Ic(e="rgb"){const{gamut:t}=pt(e);if(!t)return i=>at(i);const n=typeof t=="string"?t:e,s=ce(n),a=ur(n);return i=>{const o=at(i);if(!o)return;const l=s(o);if(a(l))return o;const c=cr(l);return o.mode===c.mode?c:ce(o.mode)(c)}}function Rc(e,t="lch",n="rgb"){e=at(e);let s=n==="rgb"?Ec:ur(n),a=n==="rgb"?Tc:Ic(n);if(e===void 0||s(e))return e;let i=ce(e.mode);e=ce(t)(e);let o={...e,c:0};if(!s(o))return i(a(o));let l=0,c=e.c!==void 0?e.c:0,u=pt(t).ranges.c,m=(u[1]-u[0])/Math.pow(2,13),f=o.c;for(;c-l>m;)o.c=l+(c-l)*.5,s(o)?(f=o.c,l=o.c):c=o.c;return i(s(o)?o:{...o,c:f})}function Ys(e){let t=ce("lrgb")(e);return .2126*t.r+.7152*t.g+.0722*t.b}function fr(e,t){let n=Ys(e),s=Ys(t);return(Math.max(n,s)+.05)/(Math.min(n,s)+.05)}G(ul);G(bl);G(vl);G(_l);G(jl);G(Ha);G(qa);G(Al);G(Ll);G(Dl);G(Ol);G(Yn);G(Bl);G(Xn);G(Hl);G(Ql);G(ec);G(tc);G(ac);G(rc);G(oc);G(cc);G(dc);G(uc);G(hc);G(ze);G(pc);G(bc);G(yc);G(Nc);const pn=/^#?(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;function bn(e){const t=e.trim();return t.startsWith("#")?t:`#${t}`}const Ac=4.5,Lc={dark:"#1e2330",light:"#f1f0ee"},vn="#FFFFFF",_n="#040403";function Xs(e,t){return typeof e!="string"||typeof t!="string"||!pn.test(e.trim())||!pn.test(t.trim())?Number.NaN:fr(bn(e),bn(t))}function zc(e){const t=Xs(e,_n);if(!Number.isNaN(t))return t>=Xs(e,vn)?_n:vn}const Pc={dark:.3,light:.9},$c={dark:vn,light:_n},Dc=ce("oklch");function Oc(e,t){if(e==null||!pn.test(e.trim()))return;const n=Dc(bn(e));if(!n)return;const s=Sc(Rc({...n,l:Pc[t]},"oklch"));return fr(s,$c[t])>=Ac?s:void 0}function Kn({variant:e,accentColor:t,status:n="ready",layout:s="featured",thumbnailUrl:a,mimeType:i,sourceUrl:o}){const[l,c]=g.useState(!1);g.useEffect(()=>{c(!1)},[a]);const u=g.useCallback(()=>{c(!0)},[]),m=qe(i,o),h=s==="featured"&&!!a&&!m&&!l&&n==="ready"?Oc(t,e):void 0,d=h??(m?Uo:Lc[e]);return{thumbnailUrl:l?void 0:a,accentStyle:h?{backgroundColor:h}:void 0,chinTextColor:zc(d),tailColor:d,isLoading:n==="loading",onImageError:u}}const Fc="flex size-6 items-center justify-center rounded-full bg-[#121110] text-white focus-ring",Bc="relative before:absolute before:-inset-[10px] before:content-['']",Uc=({title:e,placeholderTitle:t,description:n,url:s,mimeType:a,thumbnailUrl:i,sourceUrl:o,layout:l="featured",appIcon:c,cta:u,accentColor:m,status:f="ready",onDismiss:h,onEditClick:d,dismissLabel:v="Dismiss attachment"})=>{const _=l==="classic",x=qe(a,o),p=Kn({variant:"dark",accentColor:m,status:f,layout:l,thumbnailUrl:i,mimeType:a,sourceUrl:o}),b=h?r.jsx("button",{type:"button",onClick:h,"aria-label":v,className:S(Fc,!x&&Bc),children:r.jsx(M.XIcon,{className:"size-3",weight:"bold"})}):void 0,w=d?r.jsx("button",{type:"button",onClick:d,"aria-label":"Edit attachment",className:"flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15",children:r.jsx(M.PencilSimpleIcon,{className:"size-5",weight:"regular"})}):void 0;return x&&!p.isLoading?r.jsx(nt,{variant:"dark",bgClassName:Un,children:r.jsxs("div",{className:"flex items-center gap-2 pr-3",children:[r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx(st,{variant:"dark",sourceUrl:o,title:e,mimeType:a})}),b&&r.jsx("div",{className:"shrink-0",children:b})]})}):r.jsxs(nt,{variant:"dark",fixedHeight:!_,accentStyle:p.accentStyle,busy:p.isLoading,topRight:_?b:void 0,children:[!_&&r.jsx(st,{variant:"dark",thumbnailUrl:p.thumbnailUrl,sourceUrl:o,title:e,mimeType:a,topRight:b,isLoading:p.isLoading,onImageError:p.onImageError}),r.jsx(Fn,{chinTextColor:p.chinTextColor,variant:"dark",title:e,placeholderTitle:t,description:n,url:s,appIcon:c,cta:u,trailingAction:w,isLoading:p.isLoading})]})},mr=({color:e,side:t,visible:n,children:s})=>n?r.jsxs("div",{className:"relative isolate w-fit",children:[s,r.jsx("span",{"aria-hidden":!0,"data-testid":"link-card-tail",style:{backgroundColor:e},className:S("messaging-link-card-tail",t==="receiver"&&"messaging-link-card-tail--received")})]}):r.jsx(r.Fragment,{children:s}),Hc=({title:e,description:t,url:n,mimeType:s,thumbnailUrl:a,sourceUrl:i,layout:o="featured",appIcon:l,cta:c,accentColor:u,status:m="ready",onClick:f,groupPosition:h="single"})=>{const d=Bn(s,i),v=On(n),_=c==null&&v!=null&&!d?v:void 0,x=c==null&&!d?f:void 0,p=m!=="loading"&&qe(s,i)?Un:void 0,b=c&&f?{...c,onClick:()=>{var C;f(),(C=c.onClick)==null||C.call(c)}}:c,w=Kn({variant:"light",accentColor:u,status:m,layout:o,thumbnailUrl:a,mimeType:s,sourceUrl:i});return r.jsx(mr,{color:w.tailColor,side:"receiver",visible:p==null&&(h==="single"||h==="end"),children:r.jsxs(nt,{variant:"light",href:_,onClick:x,ariaLabel:e??"Open attachment preview",fixedHeight:o==="featured"&&p==null,accentStyle:w.accentStyle,busy:w.isLoading,bgClassName:p,"data-testid":"link-attachment",children:[o==="featured"&&r.jsx(st,{variant:"light",thumbnailUrl:w.thumbnailUrl,sourceUrl:i,title:e,mimeType:s,isLoading:w.isLoading,onImageError:w.onImageError}),r.jsx(Fn,{chinTextColor:w.chinTextColor,variant:"light",title:e,description:t,url:n,appIcon:l,cta:b,isLoading:w.isLoading})]})})},Vc=({title:e,placeholderTitle:t,description:n,url:s,mimeType:a,thumbnailUrl:i,sourceUrl:o,layout:l="featured",appIcon:c,cta:u,accentColor:m,status:f="ready",onClick:h,groupPosition:d="single"})=>{const v=Bn(a,o),_=On(s),x=u==null&&_!=null&&!v?_:void 0,p=u==null&&!v&&x!=null?h:void 0,b=f!=="loading"&&qe(a,o),w=Kn({variant:"dark",accentColor:m,status:f,layout:l,thumbnailUrl:i,mimeType:a,sourceUrl:o});return r.jsx(mr,{color:w.tailColor,side:"sender",visible:!b&&(d==="single"||d==="end"),children:r.jsxs(nt,{variant:"dark",href:x,onClick:p,fixedHeight:l==="featured"&&!b,accentStyle:w.accentStyle,busy:w.isLoading,bgClassName:b?Un:void 0,children:[l==="featured"&&r.jsx(st,{variant:"dark",thumbnailUrl:w.thumbnailUrl,sourceUrl:o,title:e,mimeType:a,isLoading:w.isLoading,onImageError:w.onImageError}),r.jsx(Fn,{chinTextColor:w.chinTextColor,variant:"dark",title:e,placeholderTitle:t,description:n,url:s,appIcon:c,cta:u,isLoading:w.isLoading})]})})},ut={Composer:Uc,Sent:Vc,Received:Hc};function H(e){const t=e==null?void 0:e.trim();return t||void 0}function Ws(e){return e.trim().replace(/^https?:\/\//i,"").replace(/\/+$/,"").toLowerCase()}function Gc(e,t){if(!(e!=null&&e.trim())||!(t!=null&&t.trim()))return!1;const n=Ws(e),s=Ws(t);if(n===s)return!0;if(!n.includes(s))return!1;const a=n.split(s).join("");return!/[^\p{P}\p{Z}\p{C}]/u.test(a)}function Zs(e){const t=H(e.og_scrape_url)??H(e.title_link),n=H(e.image_url)??H(e.thumb_url),s=H(e.asset_url),a=H(e.mime_type);return{title:H(e.title),description:H(e.text),url:t,thumbnailUrl:be(n),sourceUrl:s,layout:n||Bn(a,s)?"featured":"classic",mimeType:a,accentColor:H(e.accent_color),status:"ready"}}function qc(e){var t;return hr(e)?null:e.type==="image"?e.image_url||e.asset_url?"image":null:e.type==="video"&&e.asset_url?"video":e.type==="audio"&&e.asset_url?"audio":e.type==="file"&&e.asset_url?e.mime_type==="application/pdf"?"pdf":(t=e.mime_type)!=null&&t.startsWith("audio/")?"audio":"file":null}function hr(e){const t=H(e.og_scrape_url);return e.type==="link"||!!t&&!e.asset_url}function gr(e){if(!(e!=null&&e.length))return[];const t=[],n=(a,i)=>{const o=t[t.length-1];if((o==null?void 0:o.type)==="media"&&o.kind===a){o.attachments.push(i);return}t.push({type:"media",kind:a,attachments:[i]})},s=a=>{const i=t[t.length-1];if((i==null?void 0:i.type)==="link"){i.attachments.push(a);return}t.push({type:"link",attachments:[a]})};for(const a of e){if(hr(a)){s(a);continue}const i=qc(a);i&&n(i,a)}return t}function Yc(e){return e.filter(t=>t.type==="media").length}function Xc(e,t,n){return t<=1?n:e===0?"first":e===t-1?"end":"middle"}function Ks(e){return H(e.image_url)??H(e.asset_url)??""}function Wc(e){switch(e){case"image":return Re.Image;case"video":return Re.Video;case"audio":return Re.Audio;case"pdf":return Re.Pdf;default:return Re.File}}function Zc(e,t){if(t.length>1)switch(e){case"image":return{items:t.map(s=>({src:Ks(s),alt:H(s.title)}))};case"video":return{items:t.map(s=>({src:H(s.asset_url)??"",poster:H(s.thumb_url),mimeType:H(s.mime_type)}))};case"audio":return{items:t.map(s=>({src:H(s.asset_url)??"",mimeType:H(s.mime_type)??"audio/mpeg",filename:H(s.title),durationSeconds:s.duration,waveformData:s.waveform_data}))};case"pdf":return{items:t.map(s=>({src:H(s.asset_url)??"",filename:H(s.title),fileSize:s.file_size}))};case"file":return{items:t.map(s=>({src:H(s.asset_url)??"",filename:H(s.title),fileSize:s.file_size,mimeType:H(s.mime_type)??"application/octet-stream"}))}}const n=t[0];if(!n)return{};switch(e){case"image":return{src:Ks(n),alt:H(n.title)};case"video":return{src:H(n.asset_url)??"",poster:H(n.thumb_url),mimeType:H(n.mime_type)};case"audio":return{src:H(n.asset_url)??"",mimeType:H(n.mime_type)??"audio/mpeg",filename:H(n.title),durationSeconds:n.duration,waveformData:n.waveform_data};case"pdf":return{src:H(n.asset_url)??"",filename:H(n.title),fileSize:n.file_size};case"file":return{src:H(n.asset_url)??"",filename:H(n.title),fileSize:n.file_size,mimeType:H(n.mime_type)??"application/octet-stream"}}}function Kc({groupPosition:e,isMyMessage:t,segment:n}){const s=Wc(n.kind),a={...Zc(n.kind,n.attachments),groupPosition:e};return t?r.jsx(s.Sent,{...a}):r.jsx(s.Received,{...a})}const Jc=({groupPosition:e,isMyMessage:t,message:n,renderText:s})=>{var _;const a=gr(n.attachments);if(a.length===0)return null;const i=Yc(a),o=(_=n.text)==null?void 0:_.trim(),l=a.find(x=>x.type==="link"),c=(l==null?void 0:l.type)==="link"?Zs(l.attachments[0]??{}).url:void 0,u=o&&Gc(o,c)?void 0:o;let m=0;const f=[],h=u?"middle":e,d=(x,p,b)=>{const w=t?ut.Sent:ut.Received;f.push(r.jsx(w,{...Zs(x),groupPosition:b?h:"middle"},p))},v=(x,p)=>{const b=Xc(m,i,e);m+=1,f.push(r.jsx(Kc,{groupPosition:b,isMyMessage:t,segment:x},p))};return a.forEach((x,p)=>{const b=p===a.length-1;if(x.type==="link"){x.attachments.forEach((w,C)=>{d(w,`link-${p}-${C}`,b&&C===x.attachments.length-1)});return}v(x,`media-${p}`)}),r.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[r.jsxs("div",{className:"str-chat__message-bubble","data-attachment-bubble":"true",style:{background:"transparent",borderRadius:0,overflow:"visible",padding:0},children:[f,!u&&r.jsx(j.MessageErrorIcon,{})]}),u?r.jsxs("div",{className:"str-chat__message-bubble",children:[r.jsx(j.MessageText,{message:n,renderText:s}),r.jsx(j.MessageErrorIcon,{})]}):null]})},Qc=e=>{var rs,is,os,ls,cs,ds,us,fs,ms,hs;const{additionalMessageInputProps:t,chatbotVotingEnabled:n,editing:s,endOfGroup:a,firstOfGroup:i,groupedByUser:o,handleAction:l,handleOpenThread:c,handleRetry:u,highlighted:m,isMessageAIGenerated:f,isMyMessage:h,message:d,renderText:v,threadList:_,viewerLanguage:x,onBroadcastClick:p}=e,{client:b}=j.useChatContext("CustomMessage"),{channel:w}=j.useChannelStateContext("CustomMessage"),{isUnlocking:C,onUnlockClick:E,onFetchSource:R,onDownloadClick:A}=Ta("LockedAttachment"),[B,U]=g.useState(!1),$=j.useMessageReminder(d.id),{selected:T,voteUp:O,voteDown:I}=oa(d),{Attachment:L=j.Attachment,EditMessageModal:P=j.EditMessageModal,MessageActions:D,MessageBlocked:V=j.MessageBlocked,MessageBouncePrompt:q=j.MessageBouncePrompt,MessageDeleted:W=j.MessageDeleted,MessageIsThreadReplyInChannelButtonIndicator:ae=j.MessageIsThreadReplyInChannelButtonIndicator,MessageRepliesCountButton:Q=j.MessageRepliesCountButton,ReminderNotification:k=j.ReminderNotification,StreamedMessageText:F=j.StreamedMessageText,PinIndicator:X}=j.useComponentContext("CustomMessage"),ee=j.messageHasAttachments(d),re=j.messageHasReactions(d),K=g.useMemo(()=>f==null?void 0:f(d),[f,d]),Y=g.useMemo(()=>{const we=d.attachments??[],Ee=d.shared_location?[d.shared_location,...we]:we;if(!tt(d))return Ee;const gs=Ee.filter(xs=>!("type"in xs)||!Tn(xs));return gs.length===Ee.length?Ee:gs},[d]),ie=g.useMemo(()=>gr(Y),[Y]),he=g.useMemo(()=>{const we=kn({message:d,viewerLanguage:x});return we===d.text?d:{...d,text:we}},[d,x]),Ze=ie.length>0,Ke=ie.reduce((we,Ee)=>we+Ee.attachments.length,0)===((Y==null?void 0:Y.length)??0),ge=ha({endOfGroup:a,firstOfGroup:i,groupedByUser:o});if(j.isDateSeparatorMessage(d))return null;if(d.deleted_at||d.type==="deleted")return r.jsx(W,{message:d});if(j.isMessageBlocked(d))return r.jsx(V,{});const ye=!_&&!!d.reply_count,xe=!_&&d.show_in_channel&&d.parent_id,Qn=d.status==="failed"&&((rs=d.error)==null?void 0:rs.status)!==403,es=j.isMessageBounced(d);let Se;Qn?Se=()=>u(d):es&&(Se=()=>U(!0));const oe=h(),Nr=S("str-chat__message str-chat__message-simple",`str-chat__message--${d.type}`,`str-chat__message--${d.status}`,oe?"str-chat__message--me str-chat__message-simple--me":"str-chat__message--other",d.text?"str-chat__message--has-text":"has-no-text",{"str-chat__message--has-attachment":ee,"str-chat__message--highlighted":m,"str-chat__message--pinned pinned-message":d.pinned,"str-chat__message--with-reactions":re,"str-chat__message-send-can-be-retried":(d==null?void 0:d.status)==="failed"&&((is=d==null?void 0:d.error)==null?void 0:is.status)!==403,"str-chat__message-with-thread-link":ye||xe,"str-chat__virtual-message__wrapper--end":a,"str-chat__virtual-message__wrapper--first":i,"str-chat__virtual-message__wrapper--group":o}),Tt=d.poll_id&&b.polls.fromState(d.poll_id),ts=ko(d),Te=tt(d),kr=$n(d),Et=!!(Y!=null&&Y.length&&!d.quoted_message),ns=Te&&oe&&Et,Mr=Ze&&Ke&&!d.quoted_message&&!Tt&&!K&&!Te,ss={contentType:"text",amountText:(os=d.metadata)==null?void 0:os.amount_text,paymentStatus:(ls=d.metadata)==null?void 0:ls.payment_status,renderedText:d.text&&r.jsx(j.MessageText,{message:he,renderText:v})},as={contentType:"media",title:(cs=d.metadata)==null?void 0:cs.attachment_title,mimeType:(ds=d.metadata)==null?void 0:ds.attachment_mime_type,thumbnailUrl:(us=d.metadata)==null?void 0:us.attachment_thumbnail,amountText:(fs=d.metadata)==null?void 0:fs.amount_text,detail:(ms=d.metadata)==null?void 0:ms.attachment_detail,paymentStatus:(hs=d.metadata)==null?void 0:hs.payment_status,onFetchSource:R?()=>R(d,w):void 0};return r.jsxs(r.Fragment,{children:[s&&r.jsx(P,{additionalMessageInputProps:t}),B&&r.jsx(j.MessageBounceModal,{MessageBouncePrompt:q,onClose:()=>U(!1),open:B}),r.jsxs("div",{className:Nr,"data-message-id":d.id,"data-dd-privacy":"mask",children:[X&&r.jsx(X,{}),!!$&&r.jsx(k,{reminder:$}),d.user&&r.jsx(ke,{className:"str-chat__avatar str-chat__message-sender-avatar",id:d.user.id,image:d.user.image,name:d.user.name||d.user.id,size:24,shape:"circle",dmAgentEnabled:Te}),r.jsx("div",{className:S("str-chat__message-inner",{"str-chat__simple-message--error-failed":Qn||es}),"data-testid":"message-inner",onClick:Se,onKeyDown:Se,role:Se?"button":void 0,tabIndex:Se?0:void 0,style:{marginInlineEnd:0,marginInlineStart:0},children:ts?r.jsx(At,{message:d,standalone:!0}):jo(d)?r.jsx("div",{className:"str-chat__message-bubble-wrapper",children:r.jsxs("div",{className:"flex items-center gap-2",children:[oe&&D&&r.jsx(D,{}),oe?r.jsx(Oe,{...ss,isMine:!0}):r.jsx(Oe,{...ss,isMine:!1,isUnlocking:C(d.id),onUnlockClick:()=>E==null?void 0:E(d,w)}),!oe&&D&&r.jsx(D,{})]})}):No(d)?r.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[oe&&D&&r.jsx(D,{}),oe?r.jsx(Oe,{...as,isMine:!0,onPreviewClick:()=>E?E(d,w):void 0}):r.jsx(Oe,{...as,isMine:!1,isUnlocking:C(d.id),onUnlockClick:()=>E?E(d,w):void 0,onDownloadClick:()=>A?A(d,w):void 0}),!oe&&D&&r.jsx(D,{})]}),d.text&&r.jsx("div",{className:"str-chat__message-bubble",children:r.jsx(j.MessageText,{message:he,renderText:v})})]}):Mr?r.jsx(Jc,{groupPosition:ge,isMyMessage:oe,message:{...he,attachments:Y,i18n:void 0},renderText:v}):r.jsx("div",{className:"str-chat__message-bubble-wrapper",children:r.jsxs("div",{className:"str-chat__message-bubble",children:[Te&&!ns&&r.jsx(At,{message:d,hasAttachment:Et,isMyMessage:oe}),Tt&&r.jsx(j.Poll,{poll:Tt}),Y!=null&&Y.length&&!d.quoted_message?r.jsx(L,{actionHandler:l,attachments:Y}):null,K?r.jsx(F,{message:he,renderText:v}):r.jsx(j.MessageText,{message:he,renderText:v}),r.jsx(j.MessageErrorIcon,{})]})})}),!kr&&!ts&&r.jsxs("div",{className:"str-chat__message-footer",children:[(!Te||ns)&&r.jsx(At,{message:d,hasAttachment:Et,isMyMessage:oe}),n&&Te&&r.jsx(Ra,{selected:T,onVoteUp:O,onVoteDown:I})]}),r.jsx(To,{onBroadcastClick:p}),ye&&r.jsx(Q,{onClick:c,reply_count:d.reply_count}),xe&&r.jsx(ae,{})]},d.id)]})},ed=g.memo(Qc,(e,t)=>e.chatbotVotingEnabled!==t.chatbotVotingEnabled||e.viewerLanguage!==t.viewerLanguage||e.onBroadcastClick!==t.onBroadcastClick?!1:j.areMessageUIPropsEqual(e,t)),td=e=>{const t=j.useMessageContext("CustomMessage");return r.jsx(ed,{...t,...e})},nd=()=>{var n;const{handleDelete:e,message:t}=j.useMessageContext("CustomMessageActions");return((n=t.metadata)==null?void 0:n.payment_status)==="paid"?null:r.jsx(yn.DefaultDropdownActionButton,{onClick:e,"aria-label":"Delete",title:"Delete",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:r.jsx(M.TrashSimpleIcon,{size:16,weight:"light","aria-hidden":!0})})},sd=()=>{const{handleFlag:e}=j.useMessageContext("CustomMessageActions");return r.jsx(yn.DefaultDropdownActionButton,{onClick:e,"aria-label":"Report",title:"Report",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:r.jsx(M.FlagIcon,{size:16,weight:"light","aria-hidden":!0})})},ad=()=>{var t;const{message:e}=j.useMessageContext("CustomMessageActions");return((t=e.metadata)==null?void 0:t.custom_type)!==se.MESSAGE_CUSTOM_TYPE.ATTACHMENT?null:r.jsx(yn.MessageActions,{messageActionSet:[{Component:nd,placement:"quick",type:"delete"},{Component:sd,placement:"quick",type:"flag"}]})},rd=e=>({linkPreviews:Array.from(e.previews.values()).filter(t=>et.LinkPreviewsManager.previewIsLoaded(t)||et.LinkPreviewsManager.previewIsLoading(t))}),id=()=>{const{linkPreviewsManager:e}=j.useMessageComposer(),{linkPreviews:t}=j.useStateStore(e.state,rd),n=a=>{e.dismissPreview(a)};return t.length>0?r.jsx("div",{className:"messaging-link-preview-list flex min-h-0 flex-col items-stretch w-full gap-2 overflow-y-auto overscroll-contain",children:t.map(a=>{const i=et.LinkPreviewsManager.previewIsLoading(a);return r.jsx("div",{className:"w-full shrink-0",children:r.jsx(ut.Composer,{title:a.title,url:a.og_scrape_url,thumbnailUrl:a.image_url,layout:i||a.image_url?"featured":"classic",status:i?"loading":"ready",onDismiss:()=>n(a.og_scrape_url)})},a.og_scrape_url)})}):null},ft=g.createContext(!1),od=200,ld=()=>g.useContext(ft),cd=({sendMessage:e,disabled:t,...n})=>r.jsx("button",{...n,type:"button","aria-label":"Send",disabled:t,onPointerDown:s=>s.preventDefault(),onClick:e,children:r.jsx(M.ArrowUpIcon,{weight:"bold",className:"size-4"})}),Js=()=>{const e=g.useContext(ft),{handleSubmit:t}=j.useMessageInputContext(),n=j.useMessageComposerHasSendableData(),s=e||!n,{SendButton:a=cd,AttachmentPreviewList:i=j.AttachmentPreviewList}=j.useComponentContext("CustomMessageInput");return r.jsxs("div",{className:"central-container flex min-h-0 flex-col min-w-0 w-full self-stretch bg-white rounded-[1.5rem] shadow-[0_4px_16px_0_rgba(0,0,0,0.08),0_1px_2px_0_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.04)] [&>:not(.messaging-composer-previews):not(.messaging-composer-row)]:p-2","data-dd-privacy":"mask",children:[r.jsxs("div",{className:"messaging-composer-previews empty:hidden flex min-h-0 flex-col gap-2 px-2 pt-2",children:[r.jsx(j.QuotedMessagePreview,{}),r.jsx(id,{}),r.jsx(i,{})]}),r.jsxs("div",{className:"messaging-composer-row flex shrink-0 items-start",children:[r.jsx(j.TextareaComposer,{"aria-disabled":e||void 0,containerClassName:"min-w-0 flex-1 leading-[0]",className:"w-full resize-none bg-transparent py-3.5 pl-4 pr-4 outline-none leading-5 placeholder:text-black/30 text-sm",autoFocus:!e,enterKeyHint:"send",maxRows:4,readOnly:e,tabIndex:e?-1:void 0}),r.jsx("div",{className:"mt-auto mb-2 mr-2 shrink-0",children:r.jsx(a,{sendMessage:t,"aria-label":"Send",className:"str-chat__send-button relative flex justify-center items-center rounded-full size-8 bg-[#121110] disabled:bg-[#F1F0EE] disabled:text-black/20 text-white focus-ring before:absolute before:-inset-2 before:content-['']","data-testid":"send-button",disabled:s,type:"button"})})]})]})},Qs=({renderActions:e,renderHeader:t,renderFooter:n,disabled:s=!1,disabledReason:a,composerInput:i})=>{var m;const{channel:o}=j.useChannelStateContext(),l=((m=o==null?void 0:o.data)==null?void 0:m.frozen)===!0,c=!!i,u=g.useRef(null);return g.useEffect(()=>{if(!c)return;const f=u.current,h=f==null?void 0:f.parentElement;if(!f||!h)return;let d=f.offsetHeight;const v=()=>{const x=f.offsetHeight,p=x>d;d=x;const b=Array.from(h.querySelectorAll(".str-chat__list")).find(C=>C.scrollHeight>C.clientHeight)??null,w=b?b.scrollHeight-b.scrollTop-b.clientHeight<od:!1;h.style.setProperty("--messaging-composer-height",`${x}px`),p&&w&&b&&(b.scrollTop=b.scrollHeight)};if(v(),typeof ResizeObserver>"u")return;const _=new ResizeObserver(v);return _.observe(f),()=>{_.disconnect(),h.style.removeProperty("--messaging-composer-height")}},[c]),s?c?r.jsxs("div",{ref:u,className:"messaging-composer-chrome messaging-composer-chrome--floating",children:[r.jsxs("div",{className:"messaging-composer-backdrop","aria-hidden":"true",children:[r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-gradient"})]}),r.jsxs("div",{className:"relative z-10 flex flex-col",children:[t==null?void 0:t(),r.jsx("div",{className:"messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4",children:a?r.jsx("p",{className:"max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40",children:a}):null}),n==null?void 0:n()]})]}):r.jsxs(r.Fragment,{children:[t==null?void 0:t(),r.jsx("div",{className:"messaging-composer-locked-panel flex w-full flex-col items-center justify-center gap-3 px-6 py-4",children:a?r.jsx("p",{className:"max-w-[345px] text-center text-xs font-normal leading-[1.3] tracking-[0.12px] text-black/40",children:a}):null}),n==null?void 0:n()]}):c?r.jsxs("div",{ref:u,className:"messaging-composer-chrome messaging-composer-chrome--floating",children:[r.jsxs("div",{className:"messaging-composer-backdrop","aria-hidden":"true",children:[r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-blur"}),r.jsx("div",{className:"messaging-composer-backdrop-gradient"})]}),r.jsxs("div",{className:"relative z-10 flex min-h-0 flex-col",children:[t==null?void 0:t(),r.jsxs("div",{className:"flex min-h-0 flex-col gap-4 p-4",children:[r.jsxs("div",{inert:l?"":void 0,"aria-disabled":l||void 0,className:"message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40",children:[e&&r.jsx("div",{className:"flex h-12 shrink-0 items-center justify-center",children:e()}),r.jsx(ft.Provider,{value:l,children:r.jsx(j.MessageInput,{Input:i??Js})})]}),n==null?void 0:n()]})]})]}):r.jsxs("div",{className:"flex min-h-0 flex-col gap-4 p-4",children:[t==null?void 0:t(),r.jsxs("div",{inert:l?"":void 0,"aria-disabled":l||void 0,className:"message-input flex min-h-0 items-end gap-4 aria-disabled:opacity-40",children:[e&&r.jsx("div",{className:"flex h-12 shrink-0 items-center justify-center",children:e()}),r.jsx(ft.Provider,{value:l,children:r.jsx(j.MessageInput,{Input:Js})})]}),n==null?void 0:n()]})},dd={SYSTEM_DM_AGENT_PAUSED:"DM Agent has left the conversation",SYSTEM_DM_AGENT_RESUMED:"DM Agent has rejoined the conversation"},ud=["SYSTEM_AGE_SAFETY_BLOCKED"],fd={SYSTEM_AGE_SAFETY_BLOCKED:"This user isn’t able to reply because they don’t meet our age safety guidelines."},an="age safety guidelines.",md="https://linktr.ee/s/about/contact",hd=e=>ud.includes(e),gd=e=>{var t;return hd((t=e.metadata)==null?void 0:t.custom_type)},xd=e=>{var s;const t=(s=e.metadata)==null?void 0:s.custom_type;if(se.isDmAgentSystemType(t))return{kind:"dm-agent",type:t};if(se.isAgeSafetySystemType(t))return{kind:"age-safety",type:t};const n=e.dm_agent_system_type;if(se.isDmAgentSystemType(n))return{kind:"dm-agent",type:n}},pd=e=>{const t=e.indexOf(an);if(t===-1)return e;const n=t+an.length;return r.jsxs(r.Fragment,{children:[e.slice(0,t),r.jsx("a",{href:md,target:"_blank",rel:"noopener noreferrer",className:"mes-age-safety-system-message__emphasis font-medium text-inherit underline",children:an}),e.slice(n)]})},bd=e=>{var s,a;const t=!gd(e.message),n=xd(e.message);if((n==null?void 0:n.kind)==="dm-agent"){const i=((s=e.message.text)==null?void 0:s.trim())||dd[n.type];return r.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[r.jsxs("div",{className:"mes-dm-agent-system-message mx-auto mb-2 inline-flex w-fit max-w-[min(100%,480px)] items-center justify-center gap-[10px] rounded-[12px] border border-[rgba(0,0,0,0.08)] p-3 text-[rgba(0,0,0,0.55)]","data-testid":"dm-agent-system-message","data-dm-agent-system-type":n.type,children:[r.jsx(M.SparkleIcon,{size:16,weight:"regular","aria-hidden":!0,className:"mes-dm-agent-system-message__sparkle shrink-0"}),r.jsx("p",{className:"mes-dm-agent-system-message__text m-0 text-center text-[14px] font-normal leading-5 tracking-[0.21px]",children:i})]}),!t&&r.jsx(j.MessageTimestamp,{message:e.message})]})}if((n==null?void 0:n.kind)==="age-safety"){const i=((a=e.message.text)==null?void 0:a.trim())||fd[n.type];return r.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[r.jsxs("div",{className:"mes-age-safety-system-message box-border mx-auto mb-2 flex w-full max-w-[329px] items-start justify-center gap-3 rounded-[12px] border border-[var(--border-secondary,rgba(0,0,0,0.08))] bg-[var(--bg-warning-subtle,#fef3c6)] px-2 py-4 pl-5 text-[color:var(--text-warning-on-warning,#894b00)]","data-testid":"age-safety-system-message","data-age-safety-system-type":n.type,children:[r.jsx(M.ProhibitIcon,{size:24,weight:"duotone","aria-hidden":!0,className:"mes-age-safety-system-message__icon shrink-0 text-[color:var(--text-warning-on-warning,#894b00)]","data-testid":"age-safety-system-message-icon"}),r.jsx("div",{className:"mes-age-safety-system-message__content min-w-0 flex-[1_0_0]",children:r.jsx("p",{className:"m-0 text-balance text-left text-[12px] font-normal leading-4 tracking-[0.21px] text-[color:var(--text-warning-on-warning,#894b00)]",children:pd(i)})})]}),!t&&r.jsx(j.MessageTimestamp,{message:e.message})]})}return r.jsxs("div",{className:"str-chat__message--system","data-testid":"message-system",children:[r.jsxs("div",{className:"str-chat__message--system__text",children:[r.jsx("div",{className:"str-chat__message--system__line"}),r.jsx("p",{children:e.message.text}),r.jsx("div",{className:"str-chat__message--system__line"})]}),!t&&r.jsx(j.MessageTimestamp,{message:e.message})]})},xr=g.createContext(!1),rn=({cx:e,index:t})=>r.jsx("circle",{cx:e,cy:"6.15",r:"3.9",fill:"#A0A0A0",children:r.jsx("animateTransform",{attributeName:"transform",type:"translate",values:"0 0; 0 -2.25; 0 0;",dur:"900ms",begin:`${120*t}ms`,repeatCount:"indefinite"})}),vd=new Set([j.AIStates.Thinking,j.AIStates.Generating,j.AIStates.ExternalSources]),_d=({threadList:e})=>{var v,_;const{channel:t,channelConfig:n,thread:s}=j.useChannelStateContext(),{client:a}=j.useChatContext(),{typing:i={}}=j.useTypingContext(),{aiState:o}=j.useAIState(t),l=g.useContext(xr);if(!e&&l&&vd.has(o)){const x=yd(t,(v=a.user)==null?void 0:v.id);return r.jsx(ea,{avatarId:(x==null?void 0:x.id)??"ai-agent",avatarName:(x==null?void 0:x.name)??(x==null?void 0:x.id)??"Agent",avatarImage:x==null?void 0:x.image,testId:"typing-indicator-ai"})}if((n==null?void 0:n.typing_events)===!1)return null;const u=e?[]:Object.values(i).filter(({parent_id:x,user:p})=>{var b;return(p==null?void 0:p.id)!==((b=a.user)==null?void 0:b.id)&&!x}),m=e?Object.values(i).filter(({parent_id:x,user:p})=>{var b;return(p==null?void 0:p.id)!==((b=a.user)==null?void 0:b.id)&&x===(s==null?void 0:s.id)}):[],f=e?m:u;if(!f.length)return null;const h=(_=f[0])==null?void 0:_.user,d=h!=null&&h.id&&t.state.members[h.id]?t.state.members[h.id].user:void 0;return r.jsx(ea,{avatarId:(h==null?void 0:h.id)??(d==null?void 0:d.id)??"typing-user",avatarName:(h==null?void 0:h.name)??(d==null?void 0:d.name)??(h==null?void 0:h.id)??"Typing user",avatarImage:(h==null?void 0:h.image)??(d==null?void 0:d.image),testId:"typing-indicator"})},ea=({avatarId:e,avatarName:t,avatarImage:n,testId:s})=>r.jsx("div",{className:"str-chat__li str-chat__li--single str-chat__typing-indicator !static","data-testid":s,style:{marginBottom:"var(--messaging-channel-input-spacer-height, 80px)"},children:r.jsxs("div",{className:"str-chat__message str-chat__message-simple str-chat__message--regular str-chat__message--received str-chat__message--other str-chat__message--has-text",children:[r.jsx(ke,{className:"str-chat__avatar str-chat__message-sender-avatar",id:e,name:t,image:n??void 0,size:24,shape:"circle"}),r.jsx("div",{className:"str-chat__message-inner mx-0",children:r.jsx("div",{className:"str-chat__message-bubble-wrapper",children:r.jsx("div",{className:"str-chat__message-bubble",children:r.jsx("div",{className:"str-chat__message-text min-h-11 flex items-center",children:r.jsx("div",{className:"str-chat__message-text-inner str-chat__message-simple-text-inner",children:r.jsxs("svg",{"aria-hidden":"true",className:"block overflow-visible",viewBox:"0 0 32 12.3",width:"32",height:"13",overflow:"visible",children:[r.jsx(rn,{cx:"4",index:0}),r.jsx(rn,{cx:"16",index:1}),r.jsx(rn,{cx:"28",index:2})]})})})})})})]})});function yd(e,t){var s;const n=((s=e==null?void 0:e.state)==null?void 0:s.members)??{};for(const a of Object.values(n)){const i=a==null?void 0:a.user;if(i&&i.id!==t)return i}}const pr=()=>null,wd=({className:e,message:t})=>r.jsxs("div",{className:S("flex items-center justify-center h-full",e),children:[r.jsxs("svg",{viewBox:"0 0 100 100",className:"size-8 fill-pebble",stroke:"none",children:[r.jsx("circle",{cx:"6",cy:"50",r:"6",children:r.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 15 ; 0 -15; 0 15",repeatCount:"indefinite",begin:"0.1"})}),r.jsx("circle",{cx:"30",cy:"50",r:"6",children:r.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 10 ; 0 -10; 0 10",repeatCount:"indefinite",begin:"0.2"})}),r.jsx("circle",{cx:"54",cy:"50",r:"6",children:r.jsx("animateTransform",{attributeName:"transform",dur:"1s",type:"translate",values:"0 5 ; 0 -5; 0 5",repeatCount:"indefinite",begin:"0.3"})})]}),t&&r.jsx("span",{className:"text-stone",children:t})]}),mt=g.memo(()=>r.jsx("div",{className:"messaging-loading-state flex items-center justify-center h-full",children:r.jsxs("div",{className:"flex items-center",children:[r.jsx(wd,{className:"w-6 h-6"}),r.jsx("span",{className:"text-sm text-stone",children:"Loading messages"})]})}));mt.displayName="LoadingState";const jd=({onBack:e,showBackButton:t,renderMessageInputActions:n,renderMessageInputFooter:s,renderConversationFooter:a,onLeaveConversation:i,onBlockParticipant:o,showDeleteConversation:l=!0,onDeleteConversationClick:c,onBlockParticipantClick:u,onReportParticipantClick:m,showBlockParticipant:f=!0,showReportParticipant:h=!0,composerDisabled:d=!1,composerDisabledReason:v,showStarButton:_=!1,chatbotVotingEnabled:x=!1,renderChannelBanner:p,customChannelActions:b,renderChannelActions:w,renderMessage:C,viewerLanguage:E,showChannelInfo:R=!0,onParticipantNameClick:A,onBroadcastClick:B,composerInput:U})=>{const{channel:$}=j.useChannelStateContext(),T=g.useRef(B);g.useEffect(()=>{T.current=B},[B]);const O=g.useCallback(q=>{var W;(W=T.current)==null||W.call(T,q)},[]),I=B?O:void 0,L=$.state.messages.some(q=>q.type!=="deleted"),P=p?r.jsx(g.Fragment,{children:p()},"lt-channel-banner"):null,D=r.jsx(Dr,{className:"-mx-[var(--str-chat\\_\\_spacing-2)] px-[var(--str-chat\\_\\_spacing-2)] md:-mx-[min(var(--str-chat\\_\\_spacing-10),4%)] md:px-[min(var(--str-chat\\_\\_spacing-10),4%)]",onBack:e,showBackButton:t,showChannelInfo:R,showStarButton:_,onLeaveConversation:i,onBlockParticipant:o,showDeleteConversation:l,showBlockParticipant:f,showReportParticipant:h,onDeleteConversationClick:c,onBlockParticipantClick:u,onReportParticipantClick:m,customChannelActions:b,renderChannelActions:w,onParticipantNameClick:A}),V=g.useCallback(q=>{const{message:W}=j.useMessageContext("ChannelView"),ae=r.jsx(td,{...q,chatbotVotingEnabled:x,viewerLanguage:E,onBroadcastClick:I});return!C||!W?ae:C(ae,W)},[x,I,C,E]);return r.jsx(r.Fragment,{children:r.jsx(j.WithComponents,{overrides:{Message:V,MessageActions:ad,UnreadMessagesNotification:()=>null,UnreadMessagesSeparator:()=>null},children:r.jsx(j.Window,{children:U?r.jsxs("div",{className:"messaging-channel-layout relative flex min-h-0 flex-1 flex-col",children:[r.jsxs("div",{className:"messaging-channel-message-list messaging-channel-message-list--floating relative min-h-0 flex-1 overflow-hidden",children:[!L&&r.jsx("div",{className:"str-chat__list",children:r.jsxs("div",{className:"str-chat__message-list-scroll",children:[D,P]})}),r.jsx(j.MessageList,{head:L?r.jsxs("div",{className:"sticky top-0 z-10",children:[D,P]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},"lt-channel-message-list"),r.jsx(Qs,{...n&&{renderActions:()=>n==null?void 0:n($)},...a&&{renderHeader:()=>a($)},renderFooter:()=>s==null?void 0:s($),disabled:d,disabledReason:v,composerInput:U},"lt-channel-message-input")]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[!L&&r.jsx("div",{className:"str-chat__list",children:r.jsxs("div",{className:"str-chat__message-list-scroll",children:[D,P]})}),r.jsx(j.MessageList,{head:L?r.jsxs("div",{className:"sticky top-0 z-10",children:[D,P]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},"lt-channel-message-list"),a?r.jsx(g.Fragment,{children:a($)},"lt-channel-conversation-footer"):null,r.jsx(Qs,{...n&&{renderActions:()=>n==null?void 0:n($)},renderFooter:()=>s==null?void 0:s($),disabled:d,disabledReason:v,composerInput:U},"lt-channel-message-input")]})})})})},Jn=g.memo(({channel:e,onBack:t,showBackButton:n=!1,renderMessageInputActions:s,renderMessageInputFooter:a,renderConversationFooter:i,onLeaveConversation:o,onBlockParticipant:l,className:c,CustomChannelEmptyState:u=pr,showDeleteConversation:m=!0,onDeleteConversationClick:f,onBlockParticipantClick:h,onReportParticipantClick:d,showBlockParticipant:v=!0,showReportParticipant:_=!0,composerDisabled:x=!1,composerDisabledReason:p,dmAgentEnabled:b,messageMetadata:w,onMessageSent:C,showStarButton:E=!1,chatbotVotingEnabled:R=!1,renderChannelBanner:A,customChannelActions:B,renderChannelActions:U,renderMessage:$,onMessageLinkClick:T,sendButton:O,attachmentPreviewList:I,viewerLanguage:L,showChannelInfo:P=!0,onParticipantNameClick:D,onBroadcastClick:V,composerInput:q})=>{const W=g.useCallback(async(Q,k,F)=>{var ie;const X=((ie=e.data)==null?void 0:ie.chatbot_paused)===!0,ee=b&&!X,re={...k,...ee&&{silent:!0},...w&&{metadata:{...k.metadata??{},...w}}},K={...F,...ee&&{skip_push:!0}},Y=await e.sendMessage(re,K);return C==null||C(Y),Y},[e,b,w,C]),ae=g.useRef(null);return g.useEffect(()=>{if(!T)return;const Q=ae.current;if(!Q)return;const k=F=>{const X=F.target,ee=X==null?void 0:X.closest("a[href]"),re=ee==null?void 0:ee.getAttribute("href");if(!re)return;const K=ee==null?void 0:ee.closest("[data-message-id]"),Y=K==null?void 0:K.getAttribute("data-message-id"),ie=Y?e.state.messages.find(he=>he.id===Y):void 0;T(re,ie)};return Q.addEventListener("click",k),()=>Q.removeEventListener("click",k)},[T,e]),r.jsx("div",{ref:ae,className:S("messaging-channel-view h-full flex flex-col",c),children:r.jsx(xr.Provider,{value:b??!1,children:r.jsx(j.Channel,{channel:e,MessageSystem:bd,EmptyStateIndicator:u,LoadingIndicator:mt,DateSeparator:Or,TypingIndicator:_d,doSendMessageRequest:W,...O?{SendButton:O}:{},...I?{AttachmentPreviewList:I}:{},children:r.jsx(jd,{onBack:t,showBackButton:n,renderMessageInputActions:s,renderMessageInputFooter:a,renderConversationFooter:i,onLeaveConversation:o,onBlockParticipant:l,CustomChannelEmptyState:u,showDeleteConversation:m,onDeleteConversationClick:f,onBlockParticipantClick:h,onReportParticipantClick:d,showBlockParticipant:v,showReportParticipant:_,composerDisabled:x,composerDisabledReason:p,showStarButton:E,chatbotVotingEnabled:R,renderChannelBanner:A,customChannelActions:B,renderChannelActions:U,renderMessage:$,viewerLanguage:L,showChannelInfo:P,onParticipantNameClick:D,onBroadcastClick:V,composerInput:q})})})})});Jn.displayName="ChannelView";const Fe=g.memo(({message:e,onBack:t})=>r.jsx("div",{className:"messaging-error-state flex items-center justify-center h-full p-8",children:r.jsxs("div",{className:"text-center max-w-sm",children:[r.jsx("div",{className:"w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6",children:r.jsx("span",{className:"text-4xl",children:"⚠️"})}),r.jsx("h2",{className:"font-semibold text-charcoal mb-2",children:"Oops!"}),r.jsx("p",{className:"text-stone text-sm mb-6",children:e}),t&&r.jsx("button",{type:"button",onClick:t,className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-[#7f22fe] hover:bg-primary-alt rounded-lg transition-colors focus-ring",children:"Go Back"})]})}));Fe.displayName="ErrorState";const Nd=({capabilities:e={},renderMessageInputActions:t,renderConversationFooter:n,onChannelSelect:s,onExitConversation:a,initialParticipantFilter:i,initialParticipantData:o,CustomChannelEmptyState:l,onBlockParticipantClick:c,onReportParticipantClick:u,dmAgentEnabled:m,onMessageSent:f,chatbotVotingEnabled:h=!1,viewerLanguage:d,renderChannelBanner:v,customChannelActions:_,renderChannelActions:x,onParticipantNameClick:p,onBroadcastClick:b,renderMessage:w,onMessageLinkClick:C,showChannelInfo:E,composerInput:R})=>{const{client:A,isConnected:B,isLoading:U,error:$,refreshConnection:T,service:O,debug:I}=sa(),[L,P]=g.useState(null),[D,V]=g.useState(null),[q,W]=g.useState(!1),{showDeleteConversation:ae=!0}=e,Q=g.useRef(o);Q.current=o;const k=g.useRef(s);k.current=s;const F=g.useRef(null),X=g.useRef(null);g.useEffect(()=>{X.current=L},[L]),g.useEffect(()=>{if(!A||!B)return;const K=A.userID;if(!K)return;const Y=`${K}::${i}`;if(F.current===Y)return;F.current=Y;const ie=()=>{F.current===Y&&(F.current=null)};(async()=>{var Ze,Ke;try{I&&console.log("[MessagingShell] Loading initial conversation with:",i);const ge=await A.queryChannels({type:"messaging",members:{$eq:[K,i]}},{},{limit:1});if(ge.length>0){P(ge[0]),V(null),(Ze=k.current)==null||Ze.call(k,ge[0]),I&&console.log("[MessagingShell] Initial conversation loaded:",ge[0].id);return}const ye=Q.current;if(!ye||!O){ie(),V("No conversation found with this account"),I&&console.log("[MessagingShell] No conversation found for:",i);return}try{const xe=await O.startChannelWithParticipant({id:ye.id,name:ye.name,phone:ye.phone});P(xe),V(null),(Ke=k.current)==null||Ke.call(k,xe),I&&console.log("[MessagingShell] Channel created and loaded:",xe.id)}catch(xe){console.error("[MessagingShell] Failed to create conversation:",xe),ie(),V("Failed to create conversation")}}catch(ge){console.error("[MessagingShell] Failed to load initial conversation:",ge),ie(),X.current||V("Failed to load conversation")}})()},[i,A,B,O,I]);const ee=g.useRef(a);ee.current=a;const re=g.useCallback(()=>{var K;P(null),W(!0),(K=ee.current)==null||K.call(ee)},[]);return U?r.jsx(mt,{}):$?r.jsx(Fe,{message:$,onBack:T}):!B||!A?r.jsx(Fe,{message:"Not connected to messaging service",onBack:T}):D?r.jsx(Fe,{message:D}):q&&!L?r.jsx(Fe,{message:"Conversation ended"}):L?r.jsx("div",{className:"messaging-shell h-full bg-background-primary overflow-hidden",children:r.jsx("div",{className:"flex h-full min-h-0 flex-col",children:r.jsx(Jn,{channel:L,renderMessageInputActions:t,renderConversationFooter:n,renderChannelBanner:v,onLeaveConversation:re,onBlockParticipant:re,CustomChannelEmptyState:l,showDeleteConversation:ae,onBlockParticipantClick:c,onReportParticipantClick:u,dmAgentEnabled:m,onMessageSent:f,chatbotVotingEnabled:h,viewerLanguage:d,customChannelActions:_,renderChannelActions:x,onParticipantNameClick:p,onBroadcastClick:b,renderMessage:w,onMessageLinkClick:C,showChannelInfo:E,composerInput:R},L.id)})}):r.jsx(mt,{})};function kd(e){const t=e.state.pending_messages;if(t!=null&&t.length)for(const n of t)e.state.addMessageSorted(n.message)}const br=g.createContext({selectedChannel:void 0,onChannelSelect:()=>{},debug:!1,renderMessagePreview:void 0,channelPreview:void 0,viewerLanguage:void 0}),Md=br.Provider,Cd=()=>g.useContext(br),Sd=(e,t)=>{const n=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())),a=new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())).getTime()-n.getTime();return Math.floor(a/(1e3*60*60*24))},vr=e=>{const t=new Date;if(Math.floor((t.getTime()-e.getTime())/1e3)<60)return"Just now";const s=Sd(e,t);return s===0?e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):s===1?"Yesterday":s<7?`${s}d`:s<28?`${Math.floor(s/7)}w`:e.toLocaleDateString(void 0,{day:"numeric",month:"short",year:"2-digit"})},_r=g.memo(e=>{var B,U,$;const{channel:t,unread:n}=e,{selectedChannel:s,onChannelSelect:a,debug:i,channelPreview:o,renderMessagePreview:l,viewerLanguage:c}=Cd(),{client:u}=j.useChatContext(),m=(s==null?void 0:s.id)===(t==null?void 0:t.id),f=aa(t);if(o){const T=o;return r.jsx(T,{...e,active:m,selectedChannel:s,onChannelSelect:a,viewerLanguage:c})}const h=()=>{t&&a(t)},d=T=>{const O=T.key==="Enter"||T.key===" ",I=T.repeat;!O||I||(T.preventDefault(),h())},v=jn((B=t==null?void 0:t.state)==null?void 0:B.members,u==null?void 0:u.userID,t==null?void 0:t.type),_=Nn(v==null?void 0:v.user),x=(U=v==null?void 0:v.user)==null?void 0:U.image,p=(()=>{var O;const T=(O=t==null?void 0:t.state)==null?void 0:O.messages;if(T!=null&&T.length){for(let I=T.length-1;I>=0;I--)if(T[I].type!=="system")return T[I]}})(),w=(()=>{var P;const T=kn({message:p,viewerLanguage:c}),{custom_type:O,attachment_content_type:I}=(p==null?void 0:p.metadata)||{};if(O===se.MESSAGE_CUSTOM_TYPE.TIP)return T||"Sent a tip";if(O===se.MESSAGE_CUSTOM_TYPE.PAID)return T||"Sent a message";if(O===se.MESSAGE_CUSTOM_TYPE.ATTACHMENT){if(I==="text")return"🔒 Sent a locked message";if(I==="media")return"🔒 Sent a locked attachment"}if(T)return T;const L=(P=p==null?void 0:p.attachments)==null?void 0:P[0];return L?L.og_scrape_url?L.og_scrape_url:L.type==="image"?"📷 Sent an image":L.type==="video"?"🎥 Sent a video":L.type==="audio"?"🎵 Sent audio":L.type==="file"?"📎 Sent a file":"📎 Sent an attachment":"No messages yet"})(),C=p!=null&&p.created_at?vr(new Date(p.created_at)):"",E=p?tt(p):!1,R=l?l(p,w):`${E?"✨ ":""}${w}`,A=n??0;return i&&console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER",{channelId:t==null?void 0:t.id,isSelected:m,participantName:_,unreadCount:A,hasTimestamp:!!C}),r.jsx("div",{role:"button",tabIndex:0,onClick:h,onKeyDown:d,className:S("group w-full px-4 py-3 transition-colors text-left max-w-full overflow-hidden focus-ring rounded-[12px] [&+&]:mt-2",{"bg-black/[0.04]":m,"hover:bg-black/[0.02]":!m}),"data-dd-privacy":"mask",children:r.jsxs("div",{className:"flex items-start gap-4",children:[r.jsx(ke,{id:(($=v==null?void 0:v.user)==null?void 0:$.id)||t.id||"unknown",name:_,image:x,size:48,starred:f}),r.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsxs("h3",{className:S("text-sm font-medium truncate text-[#191918]"),children:[f&&r.jsx("span",{className:"sr-only",children:"Starred conversation. "}),_]}),C&&r.jsx("span",{className:"text-xs text-[#717070] flex-shrink-0",children:C})]}),r.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[r.jsx("p",{className:"text-sm text-[#717070] flex-1 line-clamp-1",children:R}),A>0&&r.jsx("span",{className:"bg-[#7f22fe] text-white text-[10px] rounded-full h-4 flex items-center justify-center p-1 min-w-4 text-center flex-shrink-0",children:A>99?"99+":A})]})]})]})})});_r.displayName="CustomChannelPreview";const Td={last_message_at:-1},yr=g.memo(({onChannelSelect:e,selectedChannel:t,filters:n,allowNewMessagesFromUnfilteredChannels:s=!1,channelRenderFilterFn:a,sort:i=Td,className:o,customEmptyStateIndicator:l,channelListPaginator:c=j.InfiniteScroll,channelPreview:u,renderMessagePreview:m,viewerLanguage:f,lockChannelOrder:h,onMessageNewHandler:d,onMessageNew:v,onChannelVisible:_,onAddedToChannel:x,onChannelUpdated:p})=>{const b=g.useRef(0);b.current++;const{debug:w=!1}=wn(),C=g.useCallback(R=>{for(const A of R)kd(A);return a?a(R):R},[a]);w&&console.log("📺 [ChannelList] 🔄 RENDER START",{renderCount:b.current,selectedChannelId:t==null?void 0:t.id,filters:n});const E=g.useMemo(()=>({selectedChannel:t,onChannelSelect:e,debug:w,channelPreview:u,renderMessagePreview:m,viewerLanguage:f}),[t,e,w,u,m,f]);return r.jsx("div",{className:S("messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",o),children:r.jsx("div",{className:"flex-1 overflow-hidden min-w-0",children:r.jsx(Md,{value:E,children:r.jsx(j.ChannelList,{filters:n,sort:i,options:{limit:30},allowNewMessagesFromUnfilteredChannels:s,channelRenderFilterFn:C,lockChannelOrder:h,onMessageNewHandler:d,onMessageNew:v,onChannelVisible:_,onAddedToChannel:x,onChannelUpdated:p,Paginator:c,Preview:_r,EmptyStateIndicator:l},`${JSON.stringify(n)}:${JSON.stringify(i)}`)})})})});yr.displayName="ChannelList";const ta=`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='23' fill='none'%3E%3Cpath fill='black' d='M0 0H15C15 10.1934 15.859 15.2345 19.168 21.4893C19.527 22.168 19.039 22.9917 18.274 22.9178C5.176 21.6506 0.32 6.0737 0 0Z'/%3E%3C/svg%3E") no-repeat center / 100% 100%`,Ed={sent:"var(--str-chat__own-message-bubble-background-color, #1e2330)",received:"var(--str-chat__message-bubble-background-color, #f1f0ee)"},Id=({variant:e})=>r.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute bottom-0 z-[-1] h-[1.4375rem] w-5",style:{insetInlineEnd:e==="sent"?"calc(-1 * 0.25rem)":void 0,insetInlineStart:e==="received"?"calc(-1 * 0.25rem)":void 0,transform:e==="received"?"scaleX(-1)":void 0,transformOrigin:"center",backgroundColor:Ed[e],WebkitMask:ta,mask:ta}}),Rd={sent:{backgroundColor:"var(--str-chat__own-message-bubble-background-color, #1e2330)",color:"var(--str-chat__own-message-bubble-color, #fff)"},received:{backgroundColor:"var(--str-chat__message-bubble-background-color, #f1f0ee)",color:"var(--str-chat__message-bubble-color, #000000)"}},wr=({variant:e,text:t,tail:n=!0,header:s,className:a})=>r.jsxs("div",{"data-dd-privacy":"mask",className:S("relative px-4 py-3","text-[0.875rem] leading-[1.3125rem] tracking-[0.14px]",a),style:{...Rd[e],borderRadius:"var(--str-chat__message-bubble-border-radius, 1.5rem)",isolation:"isolate"},children:[s!=null&&r.jsx("div",{className:"mb-1 font-medium","data-testid":"message-bubble-header",children:s}),r.jsx("p",{className:"m-0 whitespace-pre-wrap break-words",children:t}),n&&r.jsx(Id,{variant:e})]}),Ad=({text:e,tail:t,header:n,className:s})=>r.jsx(wr,{variant:"received",text:e,tail:t,header:n,className:s}),Ld=({text:e,tail:t,className:n})=>r.jsx(wr,{variant:"sent",text:e,tail:t,className:n}),zd={Sent:Ld,Received:Ad},jr=({question:e,onClick:t,loading:n=!1,className:s})=>r.jsx("button",{type:"button",onClick:t,disabled:n,style:{backgroundColor:"#E6E5E3"},className:S("w-full text-center p-4 rounded-xl text-charcoal font-medium transition-colors focus-ring",{"hover:brightness-95 active:brightness-90":!n,"opacity-50 cursor-not-allowed":n},s),children:e}),Pd=({faqs:e,onFaqClick:t,loadingFaqId:n,headerText:s,className:a,avatarImage:i,avatarName:o})=>{const l=se.selectEnabledFaqs(e);return l.length===0?null:r.jsx("div",{className:a,children:r.jsxs("div",{className:"flex gap-3 items-end",children:[(i||o)&&r.jsx("div",{className:"flex-none",children:r.jsx(ke,{id:o||"account",name:o||"Account",image:i,size:24,shape:"circle"})}),r.jsxs("div",{className:"flex-1 flex flex-col gap-3 rounded-lg p-4",style:{backgroundColor:"#F1F0EE"},children:[s&&r.jsx("p",{className:"text-md text-charcoal mb-4",children:s}),l.map(c=>r.jsx(jr,{question:c.question,onClick:()=>t(c.id),loading:n===c.id},c.id))]})]})})};exports.ActionButton=Ie;exports.AttachmentThumbnail=Mn;exports.Avatar=ke;exports.ChannelEmptyState=pr;exports.ChannelList=yr;exports.ChannelView=Jn;exports.CustomMessageProvider=po;exports.FaqList=Pd;exports.FaqListItem=jr;exports.LinkAttachment=ut;exports.LockedAttachment=Oe;exports.MediaMessage=oi;exports.MessageAttachment=Re;exports.MessageBubble=zd;exports.MessageVoteButtons=Ra;exports.MessagingProvider=Sr;exports.MessagingShell=Nd;exports.bubbleGroupPositionFromStream=ha;exports.buildCompactMetaLabel=pa;exports.formatFileSize=ga;exports.formatRelativeTime=vr;exports.getFileExtensionLabel=xa;exports.getMessageDisplayText=kn;exports.getSourceType=ue;exports.isLinkAttachment=Tn;exports.isUuidLike=ra;exports.normalizeLanguageCode=la;exports.optimizeMessagingAttachmentUrl=be;exports.renderTypeIcon=Ne;exports.resolveConversationParticipant=jn;exports.resolveLinkAttachment=ht;exports.resolveMediaFromMessage=gt;exports.resolveParticipantDisplayName=Nn;exports.useComposerLocked=ld;exports.useCustomMessage=Ta;exports.useMessageVote=oa;exports.useMessaging=sa;
5
- //# sourceMappingURL=index-CCtHMrmO.cjs.map