@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.
- package/dist/{Card-2l_y20FM.js → Card-CmlaSw7i.js} +2 -2
- package/dist/{Card-2l_y20FM.js.map → Card-CmlaSw7i.js.map} +1 -1
- package/dist/{Card-Gr4HDVbn.cjs → Card-EWN07XIl.cjs} +2 -2
- package/dist/{Card-Gr4HDVbn.cjs.map → Card-EWN07XIl.cjs.map} +1 -1
- package/dist/assets/index.css +1 -1
- package/dist/{index-B96WLmx6.js → index-CN3errpB.js} +3055 -3109
- package/dist/index-CN3errpB.js.map +1 -0
- package/dist/index-CcitzVoW.cjs +5 -0
- package/dist/index-CcitzVoW.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +56 -60
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/components/ChannelView.broadcast-name.integration.test.tsx +116 -0
- package/src/components/ChannelView.tsx +17 -3
- package/src/components/CustomLinkPreviewList/CustomLinkPreviewList.test.tsx +15 -0
- package/src/components/CustomLinkPreviewList/index.tsx +24 -26
- package/src/components/CustomMessage/BroadcastNameContext.test.ts +43 -0
- package/src/components/CustomMessage/BroadcastNameContext.ts +95 -0
- package/src/components/CustomMessage/CustomMessage.stories.tsx +54 -22
- package/src/components/CustomMessage/CustomMessage.test.tsx +48 -0
- package/src/components/CustomMessage/SentMessageDeliveryStatus.test.tsx +62 -0
- package/src/components/CustomMessage/SentMessageDeliveryStatus.tsx +8 -2
- package/src/components/CustomMessage/StreamAttachmentMessage.test.tsx +0 -33
- package/src/components/CustomMessage/StreamAttachmentMessage.tsx +0 -8
- package/src/components/CustomMessage/index.tsx +23 -3
- package/src/components/CustomMessageInput/CustomMessageInput.stories.tsx +50 -2
- package/src/components/CustomMessageInput/CustomMessageInput.test.tsx +180 -2
- package/src/components/CustomMessageInput/index.tsx +143 -16
- package/src/components/MessageAttachment/Audio/AudioAttachment.stories.tsx +57 -166
- package/src/components/MessageAttachment/Audio/index.tsx +77 -71
- package/src/components/MessageAttachment/MessageAttachment.test.tsx +75 -175
- package/src/components/MessageAttachment/index.tsx +9 -25
- package/src/components/MessageAttachment/types.ts +9 -19
- package/src/components/MessagingShell/index.tsx +2 -0
- package/src/index.ts +1 -0
- package/src/styles.css +5 -120
- package/src/types.ts +11 -0
- package/src/utils/formatRelativeTime.test.ts +63 -57
- package/src/utils/formatRelativeTime.ts +21 -20
- package/dist/index-B96WLmx6.js.map +0 -1
- package/dist/index-CCtHMrmO.cjs +0 -5
- package/dist/index-CCtHMrmO.cjs.map +0 -1
- package/src/components/MessageAttachment/Audio/WaveformAudioRow.tsx +0 -335
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";const r=require("react/jsx-runtime"),g=require("react"),Cr=require("@linktr.ee/messaging-core"),nt=require("stream-chat"),N=require("stream-chat-react"),E=require("classnames"),C=require("@phosphor-icons/react"),se=require("@linktr.ee/messaging-taxonomy"),_n=require("stream-chat-react/experimental"),ea=g.createContext({service:null,client:null,isConnected:!1,isLoading:!1,error:null,capabilities:{},refreshConnection:async()=>{},debug:!1}),wn=()=>g.useContext(ea),Sr=({children:e,user:t,serviceConfig:n,apiKey:s,capabilities:a={},debug:i=!1,client:o})=>{var I,A;const l=g.useCallback((L,...H)=>{i&&console.log(`🔥 [MessagingProvider] ${L}`,...H)},[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,f]=g.useState(null),[m,u]=g.useState(null),[h,d]=g.useState(!1),[v,y]=g.useState(!1),[x,p]=g.useState(null),b=g.useRef(!1),w=g.useRef(null),M=g.useRef(n);M.current=n;const z=g.useRef(i);z.current=i;const P=g.useRef({userId:t==null?void 0:t.id,apiKey:s,serviceConfig:n,capabilities:a}),F=g.useRef(0);F.current++,l("📊 RENDER INFO",{renderCount:F.current,currentProps:{userId:t==null?void 0:t.id,apiKey:(s==null?void 0:s.substring(0,8))+"..."},propChanges:{userChanged:P.current.userId!==(t==null?void 0:t.id),apiKeyChanged:P.current.apiKey!==s,serviceConfigChanged:P.current.serviceConfig!==n,capabilitiesChanged:P.current.capabilities!==a}}),P.current={userId:t==null?void 0:t.id,apiKey:s,serviceConfig:n,capabilities:a};const O=g.useRef(null);!o&&s&&((I=O.current)==null?void 0:I.apiKey)!==s&&(O.current={apiKey:s,client:new nt.StreamChat(s)});const V=o||(s?((A=O.current)==null?void 0:A.client)??null:null);g.useEffect(()=>{const L=F.current,H=M.current;if(o){w.current=null,f(null),u(null),d(!1),p(null),y(!1);return}if(!s||!V||!H){l("⚠️ SERVICE INIT SKIPPED",{renderCount:L,reason:"Missing apiKey, client, or serviceConfig"});return}l("🚀 CREATING SERVICE",{renderCount:L,apiKey:(s==null?void 0:s.substring(0,8))+"..."});const B=new Cr.StreamChatService({...H,apiKey:s,debug:z.current,client:V});w.current=B,f(B),l("✅ SERVICE SET",{renderCount:L,serviceInstance:!!B})},[s,V,o]);const $=g.useRef(null);g.useEffect(()=>{var H,B;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(((H=$.current)==null?void 0:H.serviceId)===c&&((B=$.current)==null?void 0:B.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,y(!0),p(null);try{l("📞 CALLING SERVICE.CONNECTUSER",{userId:t.id});const q=await c.connectUser(t);u(q),d(!0),$.current={serviceId:c,userId:t.id},l("✅ USER CONNECTION SUCCESS",{userId:t.id,clientId:q.userID})}catch(q){const K=q instanceof Error?q.message:"Connection failed";p(K),l("❌ USER CONNECTION ERROR",{userId:t.id,error:K})}finally{y(!1),b.current=!1,l("🔄 USER CONNECTION FINISHED",{userId:t.id,isConnected:h})}})()},[c,t,l,h,o]),g.useEffect(()=>{const L=V;return()=>{var H;L&&($.current=null,(H=w.current)==null||H.disconnectUser().catch(console.error))}},[V]);const S=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}),y(!0);try{l("🔌 DISCONNECTING FOR REFRESH"),await c.disconnectUser(),l("📞 RECONNECTING FOR REFRESH");const L=await c.connectUser(t);u(L),d(!0),p(null),l("✅ CONNECTION REFRESH SUCCESS",{userId:t.id})}catch(L){const H=L instanceof Error?L.message:"Refresh failed";p(H),l("❌ CONNECTION REFRESH ERROR",{userId:t.id,error:H})}finally{y(!1),l("🔄 CONNECTION REFRESH FINISHED",{userId:t.id})}}},[c,t,l,o]),D=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:S,debug:i}),[c,m,o,h,v,x,a,S,i,l]);return l("🔄 RENDER END",{renderCount:F.current,willRenderChat:!!V,contextValueReady:!!D}),r.jsx(ea.Provider,{value:D,children:V?r.jsx(N.Chat,{client:V,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})},ta=()=>wn(),na=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 Er=/^[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 sa(e){return Er.test(e.trim())}function xs(e,t){const n=e==null?void 0:e.trim();return!n||t&&n===t||t&&n===`Follower ${t}`?!1:!sa(n)}function Nn(e){return xs(e==null?void 0:e.name,e==null?void 0:e.id)?e.name.trim():xs(e==null?void 0:e.username,e==null?void 0:e.id)?e.username.trim():"Unknown member"}const ps=[{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 Ir(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 aa(e){return ps[Ir(e)%ps.length]}function Tr(e){return aa(e).emoji}function Rr(e){return aa(e).bgColor}const Me=({id:e,image:t,size:n=40,className:s,starred:a=!1,shape:i="squircle",dmAgentEnabled:o=!1})=>{const l=Tr(e),c=Rr(e),f=.45,u=n<32?Math.round(n*f):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:E("avatar-fallback flex h-full w-full items-center justify-center font-semibold select-none transition-colors"),style:{fontSize:u,lineHeight:1},children:l})});return r.jsxs("div",{className:E("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(C.StarIcon,{className:"size-3 text-yellow-600",weight:"duotone"})}),r.jsx("div",{"data-testid":"avatar-ring",className:E("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})]})},Lr="https://linktr.ee/s/about/trust-center/report",Ar=({channel:e,participant:t,showBlockParticipant:n=!0,enabled:s=!0,onLeaveConversation:a,onBlockParticipant:i,onDeleteConversationClick:o,onBlockParticipantClick:l,onReportParticipantClick:c,onActionComplete:f,logLabel:m="useChannelModerationActions"})=>{var D;const{service:u,debug:h}=wn(),d=(D=t==null?void 0:t.user)==null?void 0:D.id,v=!!(s&&n&&u&&d),[y,x]=g.useState(!1),[p,b]=g.useState(null),[w,M]=g.useState(!1),[z,P]=g.useState(!1),F=v&&((p==null?void 0:p.participantId)!==d||(p==null?void 0:p.service)!==u);return g.useEffect(()=>{if(!v||!u||!d){x(!1),b(null);return}let I=!1;return(async()=>{try{const A=await u.getBlockedUsers();if(I)return;x(A.some(L=>L.blocked_user_id===d))}catch(A){I||console.error(`[${m}] Failed to check blocked status:`,A)}finally{I||b({participantId:d,service:u})}})(),()=>{I=!0}},[v,u,d,m]),{isParticipantBlocked:y,isCheckingBlockedStatus:F,isLeaving:w,isUpdatingBlockStatus:z,handleLeaveConversation:async()=>{var I;if(!w){o==null||o(),h&&console.log(`[${m}] Leave conversation`,e.cid),M(!0);try{const A=((I=e._client)==null?void 0:I.userID)??null;await e.hide(A,!1),a&&await a(e),f==null||f()}catch(A){console.error(`[${m}] Failed to leave conversation`,A)}finally{M(!1)}}},handleBlockUser:async()=>{var I,A,L;if(!(z||!u)){l==null||l(),h&&console.log(`[${m}] Block member`,(I=t==null?void 0:t.user)==null?void 0:I.id),P(!0);try{await u.blockUser((A=t==null?void 0:t.user)==null?void 0:A.id),i&&await i((L=t==null?void 0:t.user)==null?void 0:L.id),f==null||f()}catch(H){console.error(`[${m}] Failed to block member`,H)}finally{P(!1)}}},handleUnblockUser:async()=>{var I,A,L;if(!(z||!u)){l==null||l(),h&&console.log(`[${m}] Unblock member`,(I=t==null?void 0:t.user)==null?void 0:I.id),P(!0);try{await u.unBlockUser((A=t==null?void 0:t.user)==null?void 0:A.id),i&&await i((L=t==null?void 0:t.user)==null?void 0:L.id),f==null||f()}catch(H){console.error(`[${m}] Failed to unblock member`,H)}finally{P(!1)}}},handleReportUser:()=>{c==null||c(),f==null||f(),window.open(Lr,"_blank","noopener,noreferrer")}}},Re=({variant:e="default",className:t,children:n,...s})=>{const a=e==="danger";return r.jsx("button",{type:"button",className:E("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:f,customChannelActions:m,triggerClassName:u})=>{const[h,d]=g.useState(!1),v=g.useRef(null),y=g.useId(),x=g.useCallback(()=>d(!1),[]),{isParticipantBlocked:p,isCheckingBlockedStatus:b,isLeaving:w,isUpdatingBlockStatus:M,handleLeaveConversation:z,handleBlockUser:P,handleUnblockUser:F,handleReportUser:O}=Ar({channel:e,participant:t,showBlockParticipant:s,enabled:h,onLeaveConversation:i,onBlockParticipant:o,onDeleteConversationClick:l,onBlockParticipantClick:c,onReportParticipantClick:f,onActionComplete:x,logLabel:"ChannelActionsMenu"});return g.useEffect(()=>{if(!h)return;const $=D=>{v.current&&!v.current.contains(D.target)&&d(!1)},S=D=>{D.key==="Escape"&&d(!1)};return document.addEventListener("mousedown",$),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",$),document.removeEventListener("keydown",S)}},[h]),!t||!(n||s||a||!!m)?null:r.jsxs("div",{ref:v,className:"relative",children:[r.jsxs("button",{className:u,type:"button","aria-haspopup":"true","aria-expanded":h,"aria-controls":h?y:void 0,onClick:()=>d($=>!$),children:[r.jsx(C.DotsThreeIcon,{className:"size-5 text-black/90"}),r.jsx("span",{className:"sr-only",children:"More options"})]}),h&&r.jsx("div",{id:y,"aria-label":"Conversation options",className:E("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(Re,{onClick:z,disabled:w,"aria-busy":w,children:[w?r.jsx(C.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):r.jsx(C.SignOutIcon,{className:"h-5 w-5"}),r.jsx("span",{children:"Delete Conversation"})]})}),s&&r.jsx("li",{children:b?r.jsxs(Re,{disabled:!0,"aria-busy":!0,children:[r.jsx(C.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}),r.jsx("span",{children:"Block"})]}):p?r.jsxs(Re,{onClick:F,disabled:M,"aria-busy":M,children:[M?r.jsx(C.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):r.jsx(C.ProhibitInsetIcon,{className:"h-5 w-5"}),r.jsx("span",{children:"Unblock"})]}):r.jsxs(Re,{onClick:P,disabled:M,"aria-busy":M,children:[M?r.jsx(C.SpinnerGapIcon,{className:"h-5 w-5 animate-spin"}):r.jsx(C.ProhibitInsetIcon,{className:"h-5 w-5"}),r.jsx("span",{children:"Block"})]})}),a&&r.jsx("li",{children:r.jsxs(Re,{variant:"danger",onClick:O,children:[r.jsx(C.FlagIcon,{className:"h-5 w-5"}),r.jsx("span",{children:"Report"})]})}),m]})})]})},Rt="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:f,onBlockParticipantClick:m,onReportParticipantClick:u,customChannelActions:h,renderChannelActions:d,showChannelInfo:v=!0,onParticipantNameClick:y})=>{var S,D,I,A;const{channel:x}=N.useChannelStateContext(),{client:p}=N.useChatContext(),b=g.useMemo(()=>{var L;return jn((L=x.state)==null?void 0:L.members,p==null?void 0:p.userID,x.type)},[(S=x.state)==null?void 0:S.members,p==null?void 0:p.userID,x.type]),w=Nn(b==null?void 0:b.user),M=(D=b==null?void 0:b.user)==null?void 0:D.image,z=na(x),P=$r((I=x.data)==null?void 0:I.customer_tag)&&(b==null?void 0:b.is_follower)===!0,F=s&&z,O=P||F||!!y,V=async()=>{try{z?await x.unpin():await x.pin()}catch(L){console.error("[ChannelHeaderRedesign] Failed to update pinned status:",L)}},$=r.jsxs(r.Fragment,{children:[r.jsx(Me,{id:((A=b==null?void 0:b.user)==null?void 0:A.id)||x.id||"unknown",name:w,image:M,shape:"circle",size:48,className:"-mb-2"}),r.jsx("span",{className:E("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",O?"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}),O&&r.jsxs("span",{className:"ml-2 flex gap-1",children:[P&&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(C.CurrencyDollarIcon,{className:"size-2.5",weight:"bold"})}),F&&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(C.StarIcon,{className:"size-2.5",weight:"fill"})}),y&&r.jsx(C.CaretRightIcon,{"aria-hidden":"true",className:"size-4 shrink-0 text-black/65",weight:"bold"})]})]})})]});return r.jsx("div",{className:E("@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:E(Rt,"messaging-channel-view-back-button-mobile messaging-channel-view-back-button-desktop"),onClick:t||(()=>{}),type:"button","aria-label":"Back to conversations",children:r.jsx(C.ArrowLeftIcon,{className:"size-5 text-black/90"})})}),r.jsx("div",{className:"flex min-w-0 justify-center","data-dd-privacy":"mask",children:y?r.jsx("button",{type:"button",onClick:y,"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:Rt,onClick:V,type:"button","aria-pressed":z,"aria-label":z?"Unstar conversation":"Star conversation",children:r.jsx(C.StarIcon,{className:E("size-5",{"text-[#FFD60A]":z,"text-black/90":!z}),weight:z?"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:f,onBlockParticipantClick:m,onReportParticipantClick:u,customChannelActions:h,triggerClassName:Rt}))]})]})})},Or=e=>r.jsx(N.DateSeparator,{...e,position:"center"}),ln="vote_up",cn="vote_down";function Fr(e){return e!=null&&e.length?e.some(t=>t.type===cn)?"down":e.some(t=>t.type===ln)?"up":null:null}function ra(e){const{channel:t}=N.useChannelStateContext(),{client:n}=N.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,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]),i=g.useCallback(async()=>{if(n!=null&&n.userID)try{s==="down"?await t.deleteReaction(e.id,cn):await t.sendReaction(e.id,{type:cn},{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 ia(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=ia(t);return s?((a=e==null?void 0:e.i18n)==null?void 0:a[`${s}_text`])??n:n}const Br=["linktr.ee"],bs="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 ve(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")===bs?t:(s.searchParams.set("io","true"),s.searchParams.set("size",bs),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 fe(e){return e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e.startsWith("image/")?"image":"document"}function oa(e){const t=Vr.find(([n])=>n.test(e));return t?t[1]:"generic"}const Gr={video:C.VideoCameraIcon,audio:C.SpeakerHighIcon,image:C.ImageIcon,document:C.FileIcon},qr={pdf:C.FilePdfIcon,doc:C.FileDocIcon,xls:C.FileXlsIcon,csv:C.FileCsvIcon,ppt:C.FilePptIcon,zip:C.FileZipIcon,text:C.FileTextIcon,markdown:C.FileMdIcon,generic:C.FileIcon};function Yr(e){const t=fe(e);return t!=="document"?Gr[t]:qr[oa(e)]}function ke(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:f})=>{const m=fe(t),u=g.useRef(null),h=g.useRef(null),d=g.useRef(null),v=g.useRef(a),[y,x]=g.useState(s),[p,b]=g.useState(0),[w,M]=g.useState(!1),[z,P]=g.useState(!1),[F,O]=g.useState(!1),[V,$]=g.useState(!1),[S,D]=g.useState(!0),[I,A]=g.useState(null),L=g.useCallback(()=>{O(!1),x(!0)},[]),H=g.useCallback(k=>{const T=h.current;if(!T)return 0;const W=T.getBoundingClientRect();return Math.max(0,Math.min(1,(Xr(k)-W.left)/W.width))},[]),B=g.useCallback(k=>{const T=u.current;T&&T.duration&&(T.currentTime=k*T.duration)},[]),q=k=>{k.stopPropagation(),M(!0);const T=H(k);b(T),B(T)};g.useEffect(()=>{a!==void 0&&a!==v.current&&(v.current=a,x(a))},[a]),g.useEffect(()=>{if(!y){d.current!==null&&(cancelAnimationFrame(d.current),d.current=null);return}const k=()=>{const T=u.current;T&&T.duration&&!w&&b(T.currentTime/T.duration),d.current=requestAnimationFrame(k)};return d.current=requestAnimationFrame(k),()=>{d.current!==null&&cancelAnimationFrame(d.current)}},[y,w]),g.useEffect(()=>{const k=u.current;k&&(y?k.play().catch(T=>{x(!1),O(!0)}):k.pause())},[y]),g.useEffect(()=>{if(!w)return;const k=W=>b(H(W)),T=W=>{M(!1),B(H(W))};return window.addEventListener("mousemove",k),window.addEventListener("mouseup",T),window.addEventListener("touchmove",k,{passive:!0}),window.addEventListener("touchend",T),()=>{window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",T),window.removeEventListener("touchmove",k),window.removeEventListener("touchend",T)}},[w,H,B]);const K=I?{aspectRatio:String(I)}:void 0,ie=I?"":" aspect-video",X=Math.round(p*100);return r.jsxs("div",{role:"button",tabIndex:0,className:`relative cursor-pointer overflow-hidden bg-black ${ie}`,style:K,onClick:k=>{if(f){f(k);return}F||o&&x(T=>!T)},onKeyDown:k=>{if(!(k.key!=="Enter"&&k.key!==" ")){if(k.preventDefault(),f){f(k);return}F||o&&x(T=>!T)}},children:[n&&(m==="audio"||S)&&r.jsx("img",{src:n,alt:"",className:"absolute inset-0 h-full w-full object-cover"}),!n&&(m==="audio"||S)&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:ke(t,{className:"size-12 text-black/20",weight:"regular"})}),r.jsx("div",{className:"absolute inset-0",children:m==="audio"?r.jsx("audio",{ref:u,src:e,loop:i,muted:c,style:{width:"100%",height:"100%"},onLoadStart:()=>$(!0),onCanPlay:()=>{$(!1),D(!1)},onWaiting:()=>$(!0),onPlay:()=>O(!1),onEnded:()=>{i||(x(!1),b(0))},children:r.jsx("track",{kind:"captions"})}):r.jsx("video",{ref:u,src:e,loop:i,muted:c,playsInline:!0,style:{width:"100%",height:"100%"},onLoadStart:()=>$(!0),onCanPlay:()=>{$(!1),D(!1)},onWaiting:()=>$(!0),onPlay:()=>O(!1),onLoadedMetadata:()=>{const k=u.current;k instanceof HTMLVideoElement&&k.videoWidth&&k.videoHeight&&A(k.videoWidth/k.videoHeight)},onEnded:()=>{i||(x(!1),b(0))},children:r.jsx("track",{kind:"captions"})})}),V&&!F&&r.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:r.jsx(C.CircleNotchIcon,{className:"size-8 animate-spin text-white/80",weight:"bold"})}),F&&!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(),L()},onKeyDown:k=>{k.key!=="Enter"&&k.key!==" "||(k.preventDefault(),k.stopPropagation(),L())},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(C.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":X,"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"&&B(Math.min(1,p+.05)),k.key==="ArrowLeft"&&B(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:`${X}%`}})})})}),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(T=>!T)},className:"shrink-0 text-white","aria-label":y?"Pause":"Play",children:y?r.jsx(C.PauseIcon,{className:"size-5",weight:"fill"}):r.jsx(C.PlayIcon,{className:"size-5 translate-x-px",weight:"fill"})}),r.jsxs("div",{role:"slider","aria-label":"Playback position","aria-valuenow":X,"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:()=>P(!0),onMouseLeave:()=>P(!1),onKeyDown:k=>{k.key==="ArrowRight"&&B(Math.min(1,p+.05)),k.key==="ArrowLeft"&&B(Math.max(0,p-.05))},children:[r.jsx("div",{className:`w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${z||w?"h-1.5":"h-1"}`,children:r.jsx("div",{className:"h-full rounded-full bg-white",style:{width:`${X}%`}})}),r.jsx("div",{className:`absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${z||w?"scale-100 opacity-100":"scale-0 opacity-0"}`,style:{left:`${X}%`}})]})]})]})},vs=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=fe(e),[c,f]=g.useState(!1),m=ve(t),u=ve(n);return t&&(l==="video"||l==="audio")?r.jsx(Wr,{source:t,mimeType:e,poster:u,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:()=>f(!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:u??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:()=>f(!0)})}):r.jsx("img",{src:u??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:ke(e,{className:vs(a),weight:"regular"})}):n?r.jsx("div",{className:`relative ${Zr(a)}`,children:r.jsx("img",{src:u??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:ke(e,{className:vs(a),weight:"regular"})})},la=({variant:e,thumbnail:t,title:n,placeholderTitle:s="Attachment title",mimeType:a,detail:i,statusBadge:o,action:l,topLeft:c,topRight:f,rootRef:m,"data-testid":u})=>{const h=e==="dark",d=h?n??s:n??"",v=h&&!n;return r.jsxs("div",{ref:m,"data-testid":u,className:E("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,f?r.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-50",children:f}):null,t,r.jsxs("div",{className:"px-4 pb-3 pt-3",children:[d.trim()!==""&&r.jsx("p",{className:E("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:[ke(a,{className:E("size-5 shrink-0",h?"text-white/55":"text-black/55"),weight:"regular"}),i!=null&&i!==""&&r.jsx("span",{className:E("text-xs font-medium",h?"text-white/55":"text-black/55"),children:i}),o]}),l]})]})};function ca(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,f=r.jsxs(g.Fragment,{children:[r.jsx("div",{className:"p-2",children:a?r.jsx("img",{src:ve(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(C.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:f}):r.jsx("div",{className:"block",children:f})};function En(e){return e.type==="link"||!!e.og_scrape_url&&!e.asset_url}function xt(e){var t;return(t=e.attachments)==null?void 0:t.find(En)}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(C.CircleNotchIcon,{className:"size-4 animate-spin text-white",weight:"bold"}):r.jsxs(g.Fragment,{children:[r.jsx(C.DownloadSimpleIcon,{className:"size-4 text-white",weight:"bold"}),"Download"]})})};function pt(e){var u,h,d,v;const t=(u=e.attachments)==null?void 0:u.find(y=>y.type==="video"&&y.asset_url),n=(h=e.attachments)==null?void 0:h.find(y=>y.type==="image"&&y.image_url),s=(d=e.attachments)==null?void 0:d.find(y=>y.type==="audio"&&y.asset_url),a=(v=e.attachments)==null?void 0:v.find(y=>y.type==="file"&&y.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,f=i==null?void 0:i.file_size,m=t==null?void 0:t.thumb_url;return{resolvedUrl:o,resolvedType:l,title:c,fileSize:f,thumbnailUrl:m}}const da=({resolvedUrl:e,resolvedType:t,title:n,fileSize:s,thumbnailUrl:a})=>{const i=s!==void 0?ca(s):void 0;return r.jsx(la,{variant:"dark",title:n,placeholderTitle:"",mimeType:t,detail:i,thumbnail:r.jsx(Mn,{mimeType:t,sourceUrl:e,thumbnailUrl:a,title:n,variant:"dark"})})},ua=({resolvedUrl:e,resolvedType:t,title:n,fileSize:s,thumbnailUrl:a})=>{const i=fe(t),o=s!==void 0?ca(s):void 0;return r.jsx(la,{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=xt(e),s=pt(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(Me,{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(da,{...s}):r.jsx(ua,{...s})})})})]})},ri=({message:e})=>{const t=xt(e);if(t)return r.jsx("div",{className:Cn(!0),"data-dd-privacy":"mask",children:r.jsx(Sn,{attachment:t,isMyMessage:!0})});const n=pt(e);return n?r.jsx("div",{style:{display:"contents"},"data-dd-privacy":"mask",children:r.jsx(da,{...n})}):null},ii=({message:e})=>{const t=xt(e);if(t)return r.jsx("div",{className:Cn(!1),"data-dd-privacy":"mask",children:r.jsx(Sn,{attachment:t,isMyMessage:!1})});const n=pt(e);return n?r.jsx("div",{style:{display:"contents"},"data-dd-privacy":"mask",children:r.jsx(ua,{...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]"}},Ve=({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":f})=>{const m=t!=null&&t!=="",u=o??fi[ui(e)][s];return r.jsxs("div",{"data-testid":f,"data-group-position":s,className:E("relative",a,"overflow-hidden",i,m&&"pb-0",u,li[e],ci[e],n&&"border",n&&di[e],l),children:[c,m?r.jsx("p",{className:E("whitespace-pre-wrap break-words leading-snug","pb-2 pt-2","px-2"),children:t}):null]})},Ge=({onClick:e,variant:t="overlay",ariaLabel:n="Dismiss attachment"})=>r.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),e()},"aria-label":n,className:E("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(C.XIcon,{className:"size-3",weight:"bold"})}),qe=e=>e==="received"?"light":"dark",fa=({firstOfGroup:e,endOfGroup:t,groupedByUser:n})=>!n||e&&t?"single":e?"first":t?"end":"middle",mi=({src:e,mimeType:t,filename:n,items:s})=>s&&s.length>0?s:e?[{src:e,mimeType:t,filename:n}]:[],hi=({item:e,preload:t,trailingAction:n})=>r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("audio",{src:e.src,controls:!0,preload:e.preload??t,className:"block min-w-0 flex-1",children:e.mimeType?r.jsx("source",{src:e.src,type:e.mimeType}):null}),n??null]}),In=({state:e,src:t,mimeType:n,filename:s,items:a,text:i,groupPosition:o,preload:l,onDismiss:c})=>{const f=qe(e),m=e==="composer"&&!!c,u=mi({src:t,mimeType:n,filename:s,items:a});if(u.length===0)return null;const h=l??(u.length>1?"none":"metadata");return r.jsx(Ve,{variant:f,text:i,groupPosition:o,"data-testid":"audio-attachment",children:r.jsx("div",{className:"flex flex-col gap-2",children:u.map((d,v)=>r.jsx(hi,{item:d,preload:h,trailingAction:m&&v===0?r.jsx(Ge,{onClick:c,variant:"inline"}):void 0},`${d.src}-${v}`))})})},gi=e=>r.jsx(In,{...e,state:"composer"}),xi=e=>r.jsx(In,{...e,state:"sent"}),pi=e=>r.jsx(In,{...e,state:"received"}),bi={Composer:gi,Sent:xi,Received:pi};function ma(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 vi={pdf:"PDF",doc:"DOC",xls:"XLS",csv:"CSV",ppt:"PPT",zip:"ZIP",text:"TXT",markdown:"MD"};function ha(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(fe(e)==="document"){const a=oa(e),i=vi[a];if(i)return i;if(e==="application/octet-stream")return}const s=e.split("/")[1];if(!(!s||s==="*"))return s.toUpperCase()}function ga(e,t,n){const s=ha(e,t),a=typeof n=="number"&&n>0?ma(n):void 0;return[s,a].filter(Boolean).join(" · ")||void 0}function ue(e){try{const n=new URL(e).pathname.split("/").pop();return n&&n.length>0?decodeURIComponent(n):"download"}catch{return"download"}}const yi={dark:"text-white/55",light:"text-black/65"},_i={dark:"bg-white/10",light:"bg-black/5"},wi={dark:"text-white/85",light:"text-black/85"},xa=({variant:e,filename:t,title:n,mimeType:s="application/octet-stream",fileSize:a,onActivate:i,activateLabel:o,trailingAction:l})=>{const c=n??t??"File",f=ga(s,t,a),m=r.jsx("div",{className:E("flex size-10 shrink-0 items-center justify-center rounded-sm",_i[e]),"aria-hidden":!0,children:ke(s,{className:E("size-6",wi[e]),weight:"regular"})}),u=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}),f?r.jsx("p",{className:E("truncate text-xs leading-4",yi[e]),children:f}):null]}),h=i?r.jsxs("button",{type:"button",onClick:i,"aria-label":o,className:E("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,u]}):r.jsxs(r.Fragment,{children:[m,u]});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]})};async function pa(e,t){const n=t??ue(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 ji=({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}]:[],Ni=({variant:e,item:t,index:n,onActivate:s,trailingAction:a})=>{const i=t.filename??ue(t.src);return r.jsx(xa,{variant:e,filename:i,title:t.title,mimeType:t.mimeType??"application/octet-stream",fileSize:t.fileSize,onActivate:()=>s(n),activateLabel:`Download ${i}`,trailingAction:a})},Tn=({state:e,src:t,filename:n,fileSize:s,mimeType:a,title:i,items:o,text:l,groupPosition:c,onClick:f,onDismiss:m})=>{const u=qe(e),h=e==="composer"&&!!m,d=ji({src:t,filename:n,fileSize:s,mimeType:a,title:i,items:o}),v=x=>{if((f==null?void 0:f(x))===!1)return;const p=d[x];if(!p)return;const b=p.filename??ue(p.src);pa(p.src,b)};if(d.length===0)return null;const y=r.jsx("span",{className:E("flex size-8 items-center justify-center rounded-full",u==="dark"?"text-white/70":"text-black/70"),"aria-hidden":!0,children:r.jsx(C.DownloadSimpleIcon,{className:"size-5",weight:"bold"})});return r.jsx(Ve,{variant:u,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(Ge,{onClick:m,variant:"inline"}):y;return r.jsx(Ni,{variant:u,item:x,index:p,onActivate:v,trailingAction:b},`${x.src}-${p}`)})})})},ki=e=>r.jsx(Tn,{...e,state:"composer"}),Mi=e=>r.jsx(Tn,{...e,state:"sent"}),Ci=e=>r.jsx(Tn,{...e,state:"received"}),Si={Composer:ki,Sent:Mi,Received:Ci},Rn=({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(C.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(C.CaretRightIcon,{size:20,weight:"bold","aria-hidden":!0})})]}),ba=({url:e,filename:t,variant:n="pill",label:s="Download",iconOnly:a,tone:i="dark",onTriggered:o})=>{const[l,c]=g.useState(!1),f=g.useCallback(d=>{d.stopPropagation(),!l&&(c(!0),pa(e,t).catch(()=>{}).finally(()=>{c(!1),o==null||o()}))},[l,e,t,o]),m=a??n!=="pill",h={className:E(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:f,disabled:l,"aria-label":s,className:E("flex size-8 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-70",d[i]),children:l?r.jsx(C.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):r.jsx(C.DownloadSimpleIcon,{className:"size-5 shrink-0",weight:"bold","aria-hidden":!0})})}return n==="viewer"?r.jsx("button",{type:"button",onClick:f,disabled:l,"aria-label":s,className:"mes-media-viewer__action",children:l?r.jsx(C.CircleNotchIcon,{size:20,weight:"bold","aria-hidden":!0}):r.jsx(C.DownloadSimpleIcon,{size:20,weight:"bold","aria-hidden":!0})}):r.jsxs("button",{type:"button",onClick:f,disabled:l,"aria-label":m?s:void 0,className:E("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(C.CircleNotchIcon,{className:"size-4 animate-spin",weight:"bold","aria-hidden":!0}):r.jsx(C.DownloadSimpleIcon,{...h,"aria-hidden":!0}),m?null:s]})},Lt=(e,t,n)=>Math.min(Math.max(e,t),n),Ln=({length:e,initialIndex:t,open:n})=>{const s=Lt(t,0,Math.max(e-1,0)),[a,i]=g.useState(s);g.useEffect(()=>{n&&i(Lt(t,0,Math.max(e-1,0)))},[n,t,e]),g.useEffect(()=>{i(c=>Lt(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=f=>{if(f.key!=="ArrowLeft"&&f.key!=="ArrowRight")return;const m=document.activeElement;m&&(m.tagName==="VIDEO"||m.tagName==="AUDIO")||(f.preventDefault(),f.key==="ArrowLeft"?o():l())};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[n,e,o,l]),{index:a,prev:o,next:l}},An=({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 u=l.current;if(u){if(e){if(!u.open)if(typeof u.showModal=="function")try{u.showModal()}catch{u.setAttribute("open","")}else u.setAttribute("open","");const d=typeof document<"u"?document.activeElement:null;return(h=c.current)==null||h.focus(),()=>{if(u.open)if(typeof u.close=="function")try{u.close()}catch{u.removeAttribute("open")}else u.removeAttribute("open");d&&document.body.contains(d)&&d.focus()}}if(u.open)if(typeof u.close=="function")try{u.close()}catch{u.removeAttribute("open")}else u.removeAttribute("open")}},[e]);const f=()=>{t()},m=u=>{u.target===l.current&&t()};return r.jsxs("dialog",{ref:l,className:"mes-media-viewer","aria-label":n??"Attachment viewer","data-testid":o,onClose:f,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(C.XIcon,{size:20,weight:"bold","aria-hidden":!0})})]})]}),r.jsx("div",{className:"mes-media-viewer__body",children:i})]})},va=({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?ue(l.src):"image"),[l]);return l?r.jsxs(An,{open:e,onClose:s,ariaLabel:c,counter:t.length>1?`${a+1} / ${t.length}`:void 0,actions:r.jsx(ba,{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(Rn,{onPrev:i,onNext:o,prevLabel:"Previous image",nextLabel:"Next image"}):null]}):null},Ei="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",Ii={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]"]},Ti="--mes-single-width-cap",Ri="[--mes-single-width-cap:309px] sm:[--mes-single-width-cap:326px]",Li=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,u,h)=>{var v;const d=E(Ei,"h-full w-full",(v=Ii[o.length])==null?void 0:v[u]);return t?r.jsxs("button",{type:"button",onClick:()=>t(u),"aria-label":m.ariaLabel??`Open media ${u+1}`,className:E(d,"cursor-zoom-in"),children:[m.content,h]},u):r.jsxs("div",{className:d,children:[m.content,h]},u)};let f;return s&&(f={aspectRatio:s,width:`min(var(${Ti}), ${Math.round(Li*s*100)/100}px)`,maxWidth:"100%"}),o.length===1?r.jsx("div",{className:E(s?Ri:"aspect-square w-full",a),style:f,children:c(o[0],0)}):o.length===2?r.jsx("div",{className:E("grid aspect-[16/9] w-full grid-cols-2 gap-0.5",a),children:o.map((m,u)=>c(m,u))}):o.length===3?r.jsxs("div",{className:E("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:E("grid aspect-[379/286] w-full grid-cols-2 grid-rows-2 gap-0.5",a),children:o.map((m,u)=>{const h=l>0&&u===o.length-1;return c(m,u,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)})})},Ye=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}},Ai=({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:ve(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"})}),zi=({src:e,alt:t,items:n})=>n&&n.length>0?n:e?[{src:e,alt:t}]:[],_a=(e,t)=>e.map((n,s)=>({src:n.src,alt:n.alt,filename:t&&e.length===1?t:t?`${t} (${s+1})`:void 0})),Pi=({src:e,alt:t,filename:n,loading:s="lazy",onClick:a,onDismiss:i})=>{const{viewerOpen:o,viewerIndex:l,handleActivate:c,closeViewer:f}=Ye(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:ve(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(Ge,{onClick:i})}):null,r.jsx(va,{open:o,items:_a([{src:e,alt:t}],n),initialIndex:l,onClose:f})]})},$i=326/246,Di=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 f=c.naturalWidth/c.naturalHeight;s(m=>m&&m.src===t&&m.ratio===f?m:{src:t,ratio:f})},[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??$i,imgRef:a,onLoad:i}},wa=({state:e,src:t,alt:n,filename:s,items:a,text:i,groupPosition:o,loading:l="lazy",onClick:c})=>{const f=zi({src:t,alt:n,items:a}),m=qe(e),{viewerOpen:u,viewerIndex:h,handleActivate:d,closeViewer:v}=Ye(c),y=f.length===1,x=Di(y?f[0]:void 0);if(f.length===0)return null;const p=f.map((b,w)=>Ai({item:b,index:w,totalCount:f.length,fallbackLoading:l,imgRef:y?x.imgRef:void 0,onLoad:y?x.onLoad:void 0}));return r.jsxs(Ve,{variant:m,text:i,groupPosition:o,bordered:!1,widthClassName:y?"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:y?x.ratio:void 0})}),r.jsx(va,{open:u,items:_a(f,s),initialIndex:h,onClose:v})]})},Oi=e=>r.jsx(Pi,{...e}),Fi=e=>r.jsx(wa,{...e,state:"sent"}),Bi=e=>r.jsx(wa,{...e,state:"received"}),Ui={Composer:Oi,Sent:Fi,Received:Bi},Hi=({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?ue(l.src):"document"),[l]),f=g.useMemo(()=>l?Vi(l.src):void 0,[l]);return!l||!f?null:r.jsxs(An,{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:f,title:c,className:"mes-media-viewer__iframe",sandbox:"allow-scripts allow-forms allow-popups allow-downloads"},`${a}:${l.src}`),t.length>1?r.jsx(Rn,{onPrev:i,onNext:o,prevLabel:"Previous document",nextLabel:"Next document"}):null]})},Vi=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()}`},Gi=({src:e,filename:t,fileSize:n,title:s,items:a})=>a&&a.length>0?a:e?[{src:e,filename:t,fileSize:n,title:s}]:[],qi=({variant:e,item:t,index:n,onActivate:s,trailingAction:a})=>{const i=t.filename??ue(t.src);return r.jsx(xa,{variant:e,filename:i,title:t.title,mimeType:"application/pdf",fileSize:t.fileSize,onActivate:()=>s(n),activateLabel:`Open ${i}`,trailingAction:a})},zn=({state:e,src:t,filename:n,fileSize:s,title:a,items:i,text:o,groupPosition:l,onClick:c,onDismiss:f})=>{const m=qe(e),u=Gi({src:t,filename:n,fileSize:s,title:a,items:i}),{viewerOpen:h,viewerIndex:d,handleActivate:v,closeViewer:y}=Ye(c),x=e==="composer"&&!!f;if(u.length===0)return null;const p=u.map(b=>({src:b.src,filename:b.filename??ue(b.src)}));return r.jsxs(Ve,{variant:m,text:o,groupPosition:l,"data-testid":"pdf-attachment",children:[r.jsx("div",{className:"flex flex-col gap-2",children:u.map((b,w)=>{const M=b.filename??ue(b.src),z=x&&w===0?r.jsx(Ge,{onClick:f,variant:"inline"}):e==="composer"?void 0:r.jsx(ba,{url:b.src,filename:M,variant:"inline",label:`Download ${M}`,tone:m});return r.jsx(qi,{variant:m,item:b,index:w,onActivate:v,trailingAction:z},`${b.src}-${w}`)})}),r.jsx(Hi,{open:h,items:p,initialIndex:d,onClose:y})]})},Yi=e=>r.jsx(zn,{...e,state:"composer"}),Xi=e=>r.jsx(zn,{...e,state:"sent"}),Wi=e=>r.jsx(zn,{...e,state:"received"}),Zi={Composer:Yi,Sent:Xi,Received:Wi},ja=({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?ue(l.src):"video"),[l]);return l?r.jsxs(An,{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(Rn,{onPrev:i,onNext:o,prevLabel:"Previous video",nextLabel:"Next video"}):null]}):null},Ki=()=>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(C.PlayIcon,{className:"size-6",weight:"fill","aria-hidden":!0})})}),Na=({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(C.VideoCameraIcon,{className:"size-16 text-white/30",weight:"regular","aria-hidden":!0})}),r.jsx(Ki,{})]}),Ji=(e,t,n)=>({ariaLabel:`Play video ${t+1} of ${n}`,content:r.jsx(Na,{item:e,index:t})}),Qi=({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}]:[],ka=(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})),eo=({src:e,poster:t,mimeType:n,filename:s,preload:a,onClick:i,onDismiss:o})=>{const{viewerOpen:l,viewerIndex:c,handleActivate:f,closeViewer:m}=Ye(i);return r.jsxs("div",{className:"relative w-fit",children:[r.jsx("button",{type:"button",onClick:()=>f(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(Na,{item:{src:e,poster:t,mimeType:n},index:0})}),o?r.jsx("div",{className:"absolute right-2 top-2 z-10",children:r.jsx(Ge,{onClick:o})}):null,r.jsx(ja,{open:l,items:ka([{src:e,poster:t,mimeType:n,preload:a}],s),initialIndex:c,onClose:m})]})},Ma=({state:e,src:t,poster:n,mimeType:s,filename:a,items:i,text:o,groupPosition:l,preload:c,onClick:f})=>{const m=Qi({src:t,poster:n,mimeType:s,preload:c,items:i}),u=qe(e),{viewerOpen:h,viewerIndex:d,handleActivate:v,closeViewer:y}=Ye(f);if(m.length===0)return null;const x=m.map((p,b)=>Ji(p,b,m.length));return r.jsxs(Ve,{variant:u,text:o,groupPosition:l,"data-testid":"video-attachment",children:[r.jsx("div",{className:"relative",children:r.jsx(ya,{tiles:x,onTileActivate:v})}),r.jsx(ja,{open:h,items:ka(m,a),initialIndex:d,onClose:y})]})},to=e=>r.jsx(eo,{...e}),no=e=>r.jsx(Ma,{...e,state:"sent"}),so=e=>r.jsx(Ma,{...e,state:"received"}),ao={Composer:to,Sent:no,Received:so},Le={Image:Ui,Video:ao,Audio:bi,Pdf:Zi,File:Si},Ca=g.createContext(void 0),ro=e=>{var n;const t=(n=e.metadata)==null?void 0:n.broadcast_id;return typeof t=="string"?t:void 0},io=(e,t)=>{if(!t||!(e!=null&&e.length))return;const n=new Set;let s;for(const a of e){const i=ro(a);if(!i||n.has(i))continue;n.add(i);const o=t(i);o&&(s??(s={}),s[i]=o)}return s},oo=(e,t)=>{if(e===t)return!0;if(!e||!t)return!1;const n=Object.keys(e),s=Object.keys(t);return n.length!==s.length?!1:n.every(a=>e[a]===t[a])},lo=(e,t)=>{const n=io(e,t),[s,a]=g.useState(n);return oo(s,n)?s:(a(n),n)},co={isUnlocking:()=>!1},uo={LockedAttachment:co},Sa=g.createContext({}),fo=Sa.Provider;function Ea(e){return g.useContext(Sa)[e]??uo[e]}const mo=g.lazy(()=>Promise.resolve().then(()=>require("./Card-415OfRhw.cjs"))),ho=g.lazy(()=>Promise.resolve().then(()=>require("./Card-EWN07XIl.cjs"))),go=()=>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}),Fe=e=>r.jsx(g.Suspense,{fallback:r.jsx(go,{}),children:e.contentType==="text"?r.jsx(mo,{...e}):r.jsx(ho,{...e})}),xo=({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})}),po=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===se.MESSAGE_CUSTOM_TYPE.TIP},Ia=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===se.MESSAGE_CUSTOM_TYPE.PAID},st=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===se.MESSAGE_CUSTOM_TYPE.CHATBOT},Pn=e=>{var t;return((t=e.metadata)==null?void 0:t.custom_type)===se.MESSAGE_CUSTOM_TYPE.ATTACHMENT},bo=e=>{var t;return Pn(e)&&((t=e.metadata)==null?void 0:t.attachment_content_type)==="text"},vo=e=>{var t;return Pn(e)&&((t=e.metadata)==null?void 0:t.attachment_content_type)!=="text"},Ta=e=>po(e)||Ia(e),yo=e=>{var t;return Ta(e)&&!((t=e.text)!=null&&t.trim())},At=({message:e,standalone:t=!1,isMyMessage:n=!1,hasAttachment:s=!1})=>{var u;const a=Ta(e),i=st(e);if(!a&&!i)return null;if(a){const h=(u=e.metadata)==null?void 0:u.amount_text;if(!h)return null;const d=t?"message-tip-standalone":"message-tag message-tag--tip",v=Ia(e)?"message":"tip",y=t?`${h} ${v}`:`Delivered with ${h} ${v}`;return r.jsxs("div",{className:d,children:[r.jsx(C.GiftIcon,{size:t?14:12}),r.jsx("span",{children:y})]})}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(" "),f=r.jsx("span",{className:"message-chatbot-indicator__label",children:l}),m=r.jsx("span",{className:"message-chatbot-indicator__icon",children:r.jsx(xo,{size:o?12:15})});return r.jsx("div",{className:c,"data-testid":"message-chatbot-indicator",children:n&&!o?r.jsxs(r.Fragment,{children:[f,m]}):r.jsxs(r.Fragment,{children:[m,f]})})},Ra=({selected:e,onVoteUp:t,onVoteDown:n})=>r.jsxs("div",{className:"message-vote-buttons",children:[r.jsx("button",{type:"button",className:E("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(C.ThumbsUpIcon,{size:16,weight:e==="up"?"fill":"regular"})}),r.jsx("button",{type:"button",className:E("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(C.ThumbsDownIcon,{size:16,weight:e==="down"?"fill":"regular"})})]}),$n=()=>{const{message:e}=N.useMessageContext("SentMessageDeliveryStatus"),{messages:t}=N.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},zt=()=>$n()?r.jsxs(r.Fragment,{children:[r.jsx(C.ChecksIcon,{weight:"bold","aria-hidden":"true"}),r.jsx("span",{"data-testid":"sent-message-delivery-status",children:"Delivered"})]}):null,_o=()=>$n()?r.jsxs(r.Fragment,{children:[r.jsx(C.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,wo=({broadcastId:e,broadcastName:t,resolvedBroadcastName:n,onBroadcastClick:s})=>{const a=n||t,i=a||"Broadcast",o=r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"sent-message-broadcast-badge","aria-hidden":"true",children:r.jsx(C.MegaphoneIcon,{weight:"fill"})}),r.jsx("span",{className:"sent-message-broadcast-name","data-testid":"sent-message-broadcast-status",children:i})]});return s?r.jsx("button",{type:"button",className:"sent-message-broadcast-link","aria-label":`View broadcast ${i}`,onClick:()=>s({id:e,...a?{name:a}:{}}),children:o}):o},jo=()=>r.jsxs("span",{className:"str-chat__message-status sent-message-status--failed",children:[r.jsx(C.WarningCircleIcon,{weight:"bold","aria-hidden":"true"}),r.jsx("span",{"data-testid":"sent-message-failed-status",children:"Failed to send"})]}),No=({onBroadcastClick:e,resolvedBroadcastName:t})=>{var u,h;const{isMyMessage:n,message:s,threadList:a}=N.useMessageContext("SentMessageDeliveryStatus"),i=n(),o=$n();if(a)return null;if(s.status==="failed"&&i&&s.type!=="error")return r.jsx(jo,{});if(!i)return null;const l=(u=s.metadata)==null?void 0:u.broadcast_id,c=(h=s.metadata)==null?void 0:h.broadcast_name,f=s.status!=="sending"&&s.status!=="failed"&&l?r.jsx(wo,{broadcastId:l,broadcastName:c,resolvedBroadcastName:t,onBroadcastClick:e}):null,m=r.jsx(N.MessageStatus,{MessageSentStatus:zt,MessageDeliveredStatus:zt,MessageReadStatus:zt,MessageSendingStatus:_o});return f?r.jsxs("span",{className:"sent-message-status-row",children:[m,o&&r.jsx("span",{className:"sent-message-broadcast-separator","aria-hidden":"true",children:"•"}),f]}):m},ko=/^([a-z][a-z0-9+.-]*):/i,Mo=new Set(["http","https","mailto","tel","sms"]);function Dn(e){if(typeof e!="string")return;const t=e.trim();if(t==="")return;const n=ko.exec(t);if(n){const s=n[1].toLowerCase();return Mo.has(s)?t:void 0}return t.startsWith("//")||t.startsWith("/")?t:`https://${t}`}const Co={dark:"bg-white text-[#121110] hover:bg-white/90",light:"bg-[#121110] text-white hover:bg-[#2a2928]"},So=({variant:e,cta:t})=>{const n=E("mt-2 inline-flex h-10 w-full items-center justify-center rounded-full px-4 text-sm font-medium leading-none transition-colors",Co[e]),s=Dn(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})},Eo={dark:"text-white",light:"text-black/90"},Io="text-white/30",To={dark:"text-white/55",light:"text-black/55"},Ro={dark:"bg-white/25",light:"bg-black/15"},On=({variant:e,chinTextColor:t,title:n,placeholderTitle:s,description:a,url:i,appIcon:o,cta:l,trailingAction:c,isLoading:f=!1})=>{const m=e==="dark",u=n??(m?s:void 0)??"",h=u.trim()!=="",d=a!=null&&a.trim()!=="",v=typeof i=="string"?i.trim():"",y=v!=="",x=l!=null;if(!f&&!h&&!d&&!y&&!x)return null;const p=m&&!n,b=E("line-clamp-2 text-[14px] font-medium leading-5 tracking-[0.28px]",t==null&&(p?Io:Eo[e])),w=E("truncate text-[12px] leading-4 tracking-[0.24px]",t==null&&To[e]);if(f){const z=E("animate-pulse rounded",Ro[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:E("h-5 w-3/4",z),"aria-hidden":!0}),r.jsx("div",{className:E("h-4 w-1/2",z),"aria-hidden":!0})]})})}const M=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:E("min-w-0",b),style:M,children:u})]}),d&&r.jsx("p",{className:w,style:M,children:a}),!x&&y&&r.jsx("p",{className:w,style:M,children:v})]}),c&&r.jsx("div",{className:"shrink-0",children:c})]}),l&&r.jsx(So,{variant:e,cta:l})]})},Lo="Loading link preview",Ao=E("relative w-[290px] select-none overflow-hidden","rounded-[20px]"),zo="flex h-[250px] flex-col",at=({variant:e,children:t,href:n,onClick:s,ariaLabel:a,rootRef:i,topRight:o,bgClassName:l,accentStyle:c,fixedHeight:f=!1,busy:m=!1,"data-testid":u})=>{const h=n!=null||s!=null,d=E(Ao,f?zo:"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":Lo}:void 0,y=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":u,className:d,style:c,...v,children:[t,y]}):s?r.jsxs("button",{ref:i,type:"button",onClick:s,"aria-label":a,"data-testid":u,className:E(d,"text-left"),style:c,...v,children:[t,y]}):r.jsxs("div",{ref:i,"data-testid":u,className:d,style:c,...v,children:[t,y]})},ys={dark:"bg-white/10",light:"bg-black/5"},Po={dark:"size-16 text-white/25",light:"size-16 text-black/25"},Xe=(e,t)=>!!t&&!!e&&fe(e)==="audio",Fn=(e,t)=>{if(!t||!e)return!1;const n=fe(e);return n==="video"||n==="audio"},$o="#F2F3F4",Bn="bg-[#F2F3F4]",rt=({variant:e,thumbnailUrl:t,sourceUrl:n,title:s,mimeType:a="image/*",topLeft:i,topRight:o,isLoading:l=!1,onImageError:c})=>{const f=fe(a),m=!!n&&f==="video",u=ve(t);return!l&&Xe(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:E("relative min-h-0 w-full flex-1 overflow-hidden",m&&"bg-black"),children:[l?r.jsx("div",{className:E("h-full w-full animate-pulse",ys[e]),"aria-hidden":!0}):m?r.jsxs(r.Fragment,{children:[r.jsx("video",{src:n,poster:u,controls:!0,playsInline:!0,preload:"metadata",className:"absolute inset-0 h-full w-full object-contain",children:r.jsx("track",{kind:"captions"})}),u&&c?r.jsx("img",{src:u,alt:"","aria-hidden":!0,onError:c,className:"hidden"}):null]}):t?r.jsx("img",{src:u??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:E("flex h-full w-full items-center justify-center",ys[e]),children:ke(a,{className:Po[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]})},La=(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}}},Do={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},Oo=e=>La(Do[e.toLowerCase()],6),Fo=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,Bo=e=>{let t;return(t=e.match(Fo))?La(parseInt(t[1],16),t[1].length):void 0},be="([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)",Ue=`${be}%`,Un=`(?:${be}%|${be})`,Uo=`(?:${be}(deg|grad|rad|turn)|${be})`,ze="\\s*,\\s*",Ho=new RegExp(`^rgba?\\(\\s*${be}${ze}${be}${ze}${be}\\s*(?:,\\s*${Un}\\s*)?\\)$`),Vo=new RegExp(`^rgba?\\(\\s*${Ue}${ze}${Ue}${ze}${Ue}\\s*(?:,\\s*${Un}\\s*)?\\)$`),Go=e=>{let t={mode:"rgb"},n;if(n=e.match(Ho))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(Vo))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},it=(e,t)=>e===void 0?void 0:typeof e!="object"?el(e):e.mode!==void 0?e:t?{...e,mode:t}:void 0,de=(e="rgb")=>t=>(t=it(t,e))!==void 0?t.mode===e?t:ce[t.mode][e]?ce[t.mode][e](t):e==="rgb"?ce[t.mode].rgb(t):ce.rgb[e](ce[t.mode].rgb(t)):void 0,ce={},Aa={},ot=[],za={},qo=e=>e,G=e=>(ce[e.mode]={...ce[e.mode],...e.toMode},Object.keys(e.fromMode||{}).forEach(t=>{ce[t]||(ce[t]={}),ce[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=qo)}),Aa[e.mode]=e,(e.parse||[]).forEach(t=>{Yo(t,e.mode)}),de(e.mode)),bt=e=>Aa[e],Yo=(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"&&ot.indexOf(e)<0&&ot.push(e)},dn=/[^\x00-\x7F]|[a-zA-Z_]/,Xo=/[^\x00-\x7F]|[-\w]/,_={Function:"function",Ident:"ident",Number:"number",Percentage:"percentage",ParenClose:")",None:"none",Hue:"hue",Alpha:"alpha"};let R=0;function et(e){let t=e[R],n=e[R+1];return t==="-"||t==="+"?/\d/.test(n)||n==="."&&/\d/.test(e[R+2]):t==="."?/\d/.test(n):/\d/.test(t)}function un(e){if(R>=e.length)return!1;let t=e[R];if(dn.test(t))return!0;if(t==="-"){if(e.length-R<2)return!1;let n=e[R+1];return!!(n==="-"||dn.test(n))}return!1}const Wo={deg:1,rad:180/Math.PI,grad:9/10,turn:360};function Oe(e){let t="";if((e[R]==="-"||e[R]==="+")&&(t+=e[R++]),t+=tt(e),e[R]==="."&&/\d/.test(e[R+1])&&(t+=e[R++]+tt(e)),(e[R]==="e"||e[R]==="E")&&((e[R+1]==="-"||e[R+1]==="+")&&/\d/.test(e[R+2])?t+=e[R++]+e[R++]+tt(e):/\d/.test(e[R+1])&&(t+=e[R++]+tt(e))),un(e)){let n=lt(e);return n==="deg"||n==="rad"||n==="turn"||n==="grad"?{type:_.Hue,value:t*Wo[n]}:void 0}return e[R]==="%"?(R++,{type:_.Percentage,value:+t}):{type:_.Number,value:+t}}function tt(e){let t="";for(;/\d/.test(e[R]);)t+=e[R++];return t}function lt(e){let t="";for(;R<e.length&&Xo.test(e[R]);)t+=e[R++];return t}function Zo(e){let t=lt(e);return e[R]==="("?(R++,{type:_.Function,value:t}):t==="none"?{type:_.None,value:void 0}:{type:_.Ident,value:t}}function Ko(e=""){let t=e.trim(),n=[],s;for(R=0;R<t.length;){if(s=t[R++],s===`
|
|
2
|
+
`||s===" "||s===" "){for(;R<t.length&&(t[R]===`
|
|
3
|
+
`||t[R]===" "||t[R]===" ");)R++;continue}if(s===",")return;if(s===")"){n.push({type:_.ParenClose});continue}if(s==="+"){if(R--,et(t)){n.push(Oe(t));continue}return}if(s==="-"){if(R--,et(t)){n.push(Oe(t));continue}if(un(t)){n.push({type:_.Ident,value:lt(t)});continue}return}if(s==="."){if(R--,et(t)){n.push(Oe(t));continue}return}if(s==="/"){for(;R<t.length&&(t[R]===`
|
|
4
|
+
`||t[R]===" "||t[R]===" ");)R++;let a;if(et(t)&&(a=Oe(t),a.type!==_.Hue)){n.push({type:_.Alpha,value:a});continue}if(un(t)&<(t)==="none"){n.push({type:_.Alpha,value:{type:_.None,value:void 0}});continue}return}if(/\d/.test(s)){R--,n.push(Oe(t));continue}if(dn.test(s)){R--,n.push(Zo(t));continue}return}return n}function Jo(e){e._i=0;let t=e[e._i++];if(!t||t.type!==_.Function||t.value!=="color"||(t=e[e._i++],t.type!==_.Ident))return;const n=za[t.value];if(!n)return;const s={mode:n},a=Pa(e,!1);if(!a)return;const i=bt(n).channels;for(let o=0,l,c;o<i.length;o++)l=a[o],c=i[o],l.type!==_.None&&(s[c]=l.type===_.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===_.None||s.type===_.Number||s.type===_.Alpha||s.type===_.Percentage||t&&s.type===_.Hue){n.push(s);continue}if(s.type===_.ParenClose){if(e._i<e.length)return;continue}return}if(!(n.length<3||n.length>4)){if(n.length===4){if(n[3].type!==_.Alpha)return;n[3]=n[3].value}return n.length===3&&n.push({type:_.None,value:void 0}),n.every(a=>a.type!==_.Alpha)?n:void 0}}function Qo(e,t){e._i=0;let n=e[e._i++];if(!n||n.type!==_.Function)return;let s=Pa(e,t);if(s)return s.unshift(n.value),s}const el=e=>{if(typeof e!="string")return;const t=Ko(e),n=t?Qo(t,!0):void 0;let s,a=0,i=ot.length;for(;a<i;)if((s=ot[a++](e,n))!==void 0)return s;return t?Jo(t):void 0};function tl(e,t){if(!t||t[0]!=="rgb"&&t[0]!=="rgba")return;const n={mode:"rgb"},[,s,a,i,o]=t;if(!(s.type===_.Hue||a.type===_.Hue||i.type===_.Hue))return s.type!==_.None&&(n.r=s.type===_.Number?s.value/255:s.value/100),a.type!==_.None&&(n.g=a.type===_.Number?a.value/255:a.value/100),i.type!==_.None&&(n.b=i.type===_.Number?i.value/255:i.value/100),o.type!==_.None&&(n.alpha=Math.min(1,Math.max(0,o.type===_.Number?o.value:o.value/100))),n}const nl=e=>e==="transparent"?{mode:"rgb",r:0,g:0,b:0,alpha:0}:void 0,sl=(e,t,n)=>e+n*(t-e),al=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},rl=e=>t=>{let n=al(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)}},j=rl(sl),Q=e=>{let t=!1,n=e.map(s=>s!==void 0?(t=!0,s):1);return t?n:e},Pe={mode:"rgb",channels:["r","g","b","alpha"],parse:[tl,Bo,Go,Oo,nl,"srgb"],serialize:"srgb",interpolate:{r:j,g:j,b:j,alpha:{use:j,fixup:Q}},gamut:!0,white:{r:1,g:1,b:1},black:{r:0,g:0,b:0}},Pt=(e=0)=>Math.pow(Math.abs(e),563/256)*Math.sign(e),_s=e=>{let t=Pt(e.r),n=Pt(e.g),s=Pt(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},$t=e=>Math.pow(Math.abs(e),256/563)*Math.sign(e),ws=({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:$t(e*2.0415879038107465-t*.5650069742788597-.3447313507783297*n),g:$t(e*-.9692436362808798+t*1.8759675015077206+.0415550574071756*n),b:$t(e*.0134442806320312-t*.1183623922310184+1.0151749943912058*n)};return s!==void 0&&(a.alpha=s),a},Dt=(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)},$e=({r:e,g:t,b:n,alpha:s})=>{let a={mode:"lrgb",r:Dt(e),g:Dt(t),b:Dt(n)};return s!==void 0&&(a.alpha=s),a},Ce=e=>{let{r:t,g:n,b:s,alpha:a}=$e(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},Ot=(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},De=({r:e,g:t,b:n,alpha:s},a="rgb")=>{let i={mode:a,r:Ot(e),g:Ot(t),b:Ot(n)};return s!==void 0&&(i.alpha=s),i},Se=({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=De({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},il={...Pe,mode:"a98",parse:["a98-rgb"],serialize:"a98-rgb",fromMode:{rgb:e=>ws(Ce(e)),xyz65:ws},toMode:{rgb:e=>Se(_s(e)),xyz65:_s}},te=e=>(e=e%360)<0?e+360:e,ol=(e,t)=>e.map((n,s,a)=>{if(n===void 0)return n;let i=te(n);return s===0||e[s-1]===void 0?i:t(i-te(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),[]),me=e=>ol(e,t=>Math.abs(t)<=180?t:t-360*Math.sign(t)),ee=[-.14861,1.78277,-.29227,-.90649,1.97294,0],ll=Math.PI/180,cl=180/Math.PI;let js=ee[3]*ee[4],Ns=ee[1]*ee[4],ks=ee[1]*ee[2]-ee[0]*ee[3];const dl=({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=(ks*n+e*js-t*Ns)/(ks+js-Ns),i=n-a,o=(ee[4]*(t-a)-ee[2]*i)/ee[3],l={mode:"cubehelix",l:a,s:a===0||a===1?void 0:Math.sqrt(i*i+o*o)/(ee[4]*a*(1-a))};return l.s&&(l.h=Math.atan2(o,i)*cl-120),s!==void 0&&(l.alpha=s),l},ul=({h:e,s:t,l:n,alpha:s})=>{let a={mode:"rgb"};e=(e===void 0?0:e+120)*ll,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*(ee[0]*o+ee[1]*l),a.g=n+i*(ee[2]*o+ee[3]*l),a.b=n+i*(ee[4]*o+ee[5]*l),s!==void 0&&(a.alpha=s),a},vt=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.s||!t.s)return 0;let n=te(e.h),s=te(t.h),a=Math.sin((s-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.s*t.s)*a},fl=(e,t)=>{if(e.h===void 0||t.h===void 0)return 0;let n=te(e.h),s=te(t.h);return Math.abs(s-n)>180?n-(s-360*Math.sign(s-n)):s-n},yt=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.c||!t.c)return 0;let n=te(e.h),s=te(t.h),a=Math.sin((s-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.c*t.c)*a},he=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},ml={mode:"cubehelix",channels:["h","s","l","alpha"],parse:["--cubehelix"],serialize:"--cubehelix",ranges:{h:[0,360],s:[0,4.614],l:[0,1]},fromMode:{rgb:dl},toMode:{rgb:ul},interpolate:{h:{use:j,fixup:me},s:j,l:j,alpha:{use:j,fixup:Q}},difference:{h:vt},average:{h:he}},ye=({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=te(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 Ft=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:Ft(i)*Ae.X,y:Ft(a)*Ae.Y,z:Ft(o)*Ae.Z};return s!==void 0&&(l.alpha=s),l},_t=e=>Se(Oa(e)),Bt=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=Bt(e/Ae.X),i=Bt(t/Ae.Y),o=Bt(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},wt=e=>{let t=Fa(Ce(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},ct=1,Ba=1,He=26/180*Math.PI,dt=Math.cos(He),ut=Math.sin(He),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*ct/Ua)-1)/.0039},i=(Math.exp(.0435*t*Ba*ct)-1)/.075,o=i*Math.cos(n/180*Math.PI-He),l=i*Math.sin(n/180*Math.PI-He);return a.a=o*dt-l/.83*ut,a.b=o*ut+l/.83*dt,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*dt+n*ut,i=.83*(n*dt-t*ut),o=Math.sqrt(a*a+i*i),l={mode:"dlch",l:Ua/ct*Math.log(1+.0039*e),c:Math.log(1+.075*o)/(.0435*Ba*ct)};return l.c&&(l.h=te((Math.atan2(i,a)+He)/Math.PI*180)),s!==void 0&&(l.alpha=s),l},Ms=e=>fn(ye(e,"dlch")),Cs=e=>_e(mn(e),"dlab"),hl={mode:"dlab",parse:["--din99o-lab"],serialize:"--din99o-lab",toMode:{lab65:Ms,rgb:e=>_t(Ms(e))},fromMode:{lab65:Cs,rgb:e=>Cs(wt(e))},channels:["l","a","b","alpha"],ranges:{l:[0,100],a:[-40.09,45.501],b:[-40.469,44.344]},interpolate:{l:j,a:j,b:j,alpha:{use:j,fixup:Q}}},gl={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=>ye(e,"dlch"),rgb:e=>mn(wt(e))},channels:["l","c","h","alpha"],ranges:{l:[0,100],c:[0,51.484],h:[0,360]},interpolate:{l:j,c:j,h:{use:j,fixup:me},alpha:{use:j,fixup:Q}},difference:{h:yt},average:{h:he}};function xl({h:e,s:t,i:n,alpha:s}){e=te(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 pl({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 bl={mode:"hsi",toMode:{rgb:xl},parse:["--hsi"],serialize:"--hsi",fromMode:{rgb:pl},channels:["h","s","i","alpha"],ranges:{h:[0,360]},gamut:"rgb",interpolate:{h:{use:j,fixup:me},s:j,i:j,alpha:{use:j,fixup:Q}},difference:{h:vt},average:{h:he}};function vl({h:e,s:t,l:n,alpha:s}){e=te(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 yl({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 _l=(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}},wl=new RegExp(`^hsla?\\(\\s*${Uo}${ze}${Ue}${ze}${Ue}\\s*(?:,\\s*${Un}\\s*)?\\)$`),jl=e=>{let t=e.match(wl);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=_l(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 Nl(e,t){if(!t||t[0]!=="hsl"&&t[0]!=="hsla")return;const n={mode:"hsl"},[,s,a,i,o]=t;if(s.type!==_.None){if(s.type===_.Percentage)return;n.h=s.value}if(a.type!==_.None){if(a.type===_.Hue)return;n.s=a.value/100}if(i.type!==_.None){if(i.type===_.Hue)return;n.l=i.value/100}return o.type!==_.None&&(n.alpha=Math.min(1,Math.max(0,o.type===_.Number?o.value:o.value/100))),n}const Ha={mode:"hsl",toMode:{rgb:vl},fromMode:{rgb:yl},channels:["h","s","l","alpha"],ranges:{h:[0,360]},gamut:"rgb",parse:[Nl,jl],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:j,fixup:me},s:j,l:j,alpha:{use:j,fixup:Q}},difference:{h:vt},average:{h:he}};function Va({h:e,s:t,v:n,alpha:s}){e=te(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:j,fixup:me},s:j,v:j,alpha:{use:j,fixup:Q}},difference:{h:vt},average:{h:he}};function kl({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 Ml(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 Cl(e,t){if(!t||t[0]!=="hwb")return;const n={mode:"hwb"},[,s,a,i,o]=t;if(s.type!==_.None){if(s.type===_.Percentage)return;n.h=s.value}if(a.type!==_.None){if(a.type===_.Hue)return;n.w=a.value/100}if(i.type!==_.None){if(i.type===_.Hue)return;n.b=i.value/100}return o.type!==_.None&&(n.alpha=Math.min(1,Math.max(0,o.type===_.Number?o.value:o.value/100))),n}const Sl={mode:"hwb",toMode:{rgb:kl},fromMode:{rgb:Ml},channels:["h","w","b","alpha"],ranges:{h:[0,360]},gamut:"rgb",parse:[Cl],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:j,fixup:me},w:j,b:j,alpha:{use:j,fixup:Q}},difference:{h:fl},average:{h:he}},Ya=203,jt=.1593017578125,Xa=78.84375,Nt=.8359375,kt=18.8515625,Mt=18.6875;function Ut(e){if(e<0)return 0;const t=Math.pow(e,1/Xa);return 1e4*Math.pow(Math.max(0,t-Nt)/(kt-Mt*t),1/jt)}function Ht(e){if(e<0)return 0;const t=Math.pow(e/1e4,jt);return Math.pow((Nt+kt*t)/(1+Mt*t),Xa)}const Vt=e=>Math.max(e/Ya,0),Ss=({i:e,t,p:n,alpha:s})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);const a=Ut(e+.008609037037932761*t+.11102962500302593*n),i=Ut(e-.00860903703793275*t-.11102962500302599*n),o=Ut(e+.5600313357106791*t-.32062717498731885*n),l={mode:"xyz65",x:Vt(2.070152218389422*a-1.3263473389671556*i+.2066510476294051*o),y:Vt(.3647385209748074*a+.680566024947227*i-.0453045459220346*o),z:Vt(-.049747207535812*a-.0492609666966138*i+1.1880659249923042*o)};return s!==void 0&&(l.alpha=s),l},Gt=(e=0)=>Math.max(e*Ya,0),Es=({x:e,y:t,z:n,alpha:s})=>{const a=Gt(e),i=Gt(t),o=Gt(n),l=Ht(.3592832590121217*a+.6976051147779502*i-.0358915932320289*o),c=Ht(-.1920808463704995*a+1.1004767970374323*i+.0753748658519118*o),f=Ht(.0070797844607477*a+.0748396662186366*i+.8433265453898765*o),m=.5*l+.5*c,u=1.61376953125*l-3.323486328125*c+1.709716796875*f,h=4.378173828125*l-4.24560546875*c-.132568359375*f,d={mode:"itp",i:m,t:u,p:h};return s!==void 0&&(d.alpha=s),d},El={mode:"itp",channels:["i","t","p","alpha"],parse:["--ictcp"],serialize:"--ictcp",toMode:{xyz65:Ss,rgb:e=>Se(Ss(e))},fromMode:{xyz65:Es,rgb:e=>Es(Ce(e))},ranges:{i:[0,.581],t:[-.369,.272],p:[-.164,.331]},interpolate:{i:j,t:j,p:j,alpha:{use:j,fixup:Q}}},Il=134.03437499999998,Tl=16295499532821565e-27,qt=e=>{if(e<0)return 0;let t=Math.pow(e/1e4,jt);return Math.pow((Nt+kt*t)/(1+Mt*t),Il)},Yt=(e=0)=>Math.max(e*203,0),Wa=({x:e,y:t,z:n,alpha:s})=>{e=Yt(e),t=Yt(t),n=Yt(n);let a=1.15*e-.15*n,i=.66*t+.34*e,o=qt(.41478972*a+.579999*i+.014648*n),l=qt(-.20151*a+1.120649*i+.0531008*n),c=qt(-.0166008*a+.2648*i+.6684799*n),f=(o+l)/2,m={mode:"jab",j:.44*f/(1-.56*f)-Tl,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},Rl=134.03437499999998,Is=16295499532821565e-27,Xt=e=>{if(e<0)return 0;let t=Math.pow(e,1/Rl);return 1e4*Math.pow((Nt-t)/(Mt*t-kt),1/jt)},Wt=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+Is)/(.44+.56*(e+Is)),i=Xt(a+.13860504*t+.058047316*n),o=Xt(a-.13860504*t-.058047316*n),l=Xt(a-.096019242*t-.8118919*n),c={mode:"xyz65",x:Wt(1.661373024652174*i-.914523081304348*o+.23136208173913045*l),y:Wt(-.3250758611844533*i+1.571847026732543*o-.21825383453227928*l),z:Wt(-.090982811*i-.31272829*o+1.5227666*l)};return s!==void 0&&(c.alpha=s),c},Ka=e=>{let t=Wa(Ce(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},Ja=e=>Se(Za(e)),Ll={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,a:j,b:j,alpha:{use:j,fixup:Q}}},Ts=({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=te(Math.atan2(n,t)*180/Math.PI)),s!==void 0&&(i.alpha=s),i},Rs=({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},Al={mode:"jch",parse:["--jzczhz"],serialize:"--jzczhz",toMode:{jab:Rs,rgb:e=>Ja(Rs(e))},fromMode:{rgb:e=>Ts(Ka(e)),jab:Ts},channels:["j","c","h","alpha"],ranges:{j:[0,.221],c:[0,.19],h:[0,360]},interpolate:{h:{use:j,fixup:me},c:j,j,alpha:{use:j,fixup:Q}},difference:{h:yt},average:{h:he}},Ct=Math.pow(29,3)/Math.pow(3,3),Hn=Math.pow(6,3)/Math.pow(29,3);let Zt=e=>Math.pow(e,3)>Hn?Math.pow(e,3):(116*e-16)/Ct;const Vn=({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:Zt(i)*Z.X,y:Zt(a)*Z.Y,z:Zt(o)*Z.Z};return s!==void 0&&(l.alpha=s),l},We=({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=De({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=>We(Vn(e)),Ze=e=>{let{r:t,g:n,b:s,alpha:a}=$e(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},Kt=e=>e>Hn?Math.cbrt(e):(Ct*e+16)/116,Gn=({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=Kt(e/Z.X),i=Kt(t/Z.Y),o=Kt(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=Gn(Ze(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t};function zl(e,t){if(!t||t[0]!=="lab")return;const n={mode:"lab"},[,s,a,i,o]=t;if(!(s.type===_.Hue||a.type===_.Hue||i.type===_.Hue))return s.type!==_.None&&(n.l=Math.min(Math.max(0,s.value),100)),a.type!==_.None&&(n.a=a.type===_.Number?a.value:a.value*125/100),i.type!==_.None&&(n.b=i.type===_.Number?i.value:i.value*125/100),o.type!==_.None&&(n.alpha=Math.min(1,Math.max(0,o.type===_.Number?o.value:o.value/100))),n}const qn={mode:"lab",toMode:{xyz50:Vn,rgb:Qa},fromMode:{xyz50:Gn,rgb:er},channels:["l","a","b","alpha"],ranges:{l:[0,100],a:[-125,125],b:[-125,125]},parse:[zl],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:j,a:j,b:j,alpha:{use:j,fixup:Q}}},Pl={...qn,mode:"lab65",parse:["--lab-d65"],serialize:"--lab-d65",toMode:{xyz65:Oa,rgb:_t},fromMode:{xyz65:Fa,rgb:wt},ranges:{l:[0,100],a:[-125,125],b:[-125,125]}};function $l(e,t){if(!t||t[0]!=="lch")return;const n={mode:"lch"},[,s,a,i,o]=t;if(s.type!==_.None){if(s.type===_.Hue)return;n.l=Math.min(Math.max(0,s.value),100)}if(a.type!==_.None&&(n.c=Math.max(0,a.type===_.Number?a.value:a.value*150/100)),i.type!==_.None){if(i.type===_.Percentage)return;n.h=i.value}return o.type!==_.None&&(n.alpha=Math.min(1,Math.max(0,o.type===_.Number?o.value:o.value/100))),n}const Yn={mode:"lch",toMode:{lab:_e,rgb:e=>Qa(_e(e))},fromMode:{rgb:e=>ye(er(e)),lab:ye},channels:["l","c","h","alpha"],ranges:{l:[0,100],c:[0,150],h:[0,360]},parse:[$l],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:j,fixup:me},c:j,l:j,alpha:{use:j,fixup:Q}},difference:{h:yt},average:{h:he}},Dl={...Yn,mode:"lch65",parse:["--lch-d65"],serialize:"--lch-d65",toMode:{lab65:e=>_e(e,"lab65"),rgb:e=>_t(_e(e,"lab65"))},fromMode:{rgb:e=>ye(wt(e),"lch65"),lab65:e=>ye(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=te(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),Ol=sr(Z.X,Z.Y,Z.Z),Fl=ar(Z.X,Z.Y,Z.Z),Bl=e=>e<=Hn?Ct*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=Bl(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-Ol),o=13*a*(o-Fl));let l={mode:"luv",l:a,u:i,v:o};return s!==void 0&&(l.alpha=s),l},Ul=(e,t,n)=>4*e/(e+15*t+3*n),Hl=(e,t,n)=>9*t/(e+15*t+3*n),Vl=Ul(Z.X,Z.Y,Z.Z),Gl=Hl(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)+Vl,i=n/(13*e)+Gl,o=Z.Y*(e<=8?e/Ct:Math.pow((e+16)/116,3)),l=o*(9*a)/(4*i),c=o*(12-3*a-20*i)/(4*i),f={mode:"xyz50",x:l,y:o,z:c};return s!==void 0&&(f.alpha=s),f},ql=e=>tr(hn(Ze(e))),Yl=e=>We(gn(nr(e))),Xl={mode:"lchuv",toMode:{luv:nr,rgb:Yl},fromMode:{rgb:ql,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:j,fixup:me},c:j,l:j,alpha:{use:j,fixup:Q}},difference:{h:yt},average:{h:he}},Wl={...Pe,mode:"lrgb",toMode:{rgb:De},fromMode:{rgb:$e},parse:["srgb-linear"],serialize:"srgb-linear"},Zl={mode:"luv",toMode:{xyz50:gn,rgb:e=>We(gn(e))},fromMode:{xyz50:hn,rgb:e=>hn(Ze(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:j,u:j,v:j,alpha:{use:j,fixup:Q}}},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},St=e=>{let t=rr($e(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},Ke=({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},Et=e=>De(Ke(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 ft(e){return(e*e+.206*e)/(1.170873786407767*(e+.03))}function Kl(e,t){let n,s,a,i,o,l,c,f;-1.88170328*e-.80936493*t>1?(n=1.19086277,s=1.76576728,a=.59662641,i=.75515197,o=.56771245,l=4.0767416621,c=-3.3077115913,f=.2309699292):1.81444104*e-1.19445276*t>1?(n=.73956515,s=-.45954404,a=.08285427,i=.1254107,o=.14503204,l=-1.2684380046,c=2.6097574011,f=-.3413193965):(n=1.35733652,s=-.00915799,a=-1.1513021,i=-.50559606,o=.00692167,l=-.0041960863,c=-.7034186147,f=1.707614701);let m=n+s*e+a*t+i*e*e+o*e*t,u=.3963377774*e+.2158037573*t,h=-.1055613458*e-.0638541728*t,d=-.0894841775*e-1.291485548*t;{let v=1+m*u,y=1+m*h,x=1+m*d,p=v*v*v,b=y*y*y,w=x*x*x,M=3*u*v*v,z=3*h*y*y,P=3*d*x*x,F=6*u*u*v,O=6*h*h*y,V=6*d*d*x,$=l*p+c*b+f*w,S=l*M+c*z+f*P,D=l*F+c*O+f*V;m=m-$*S/(S*S-.5*$*D)}return m}function Xn(e,t){let n=Kl(e,t),s=Ke({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 Jl(e,t,n,s,a,i=null){i||(i=Xn(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,f=.3963377774*e+.2158037573*t,m=-.1055613458*e-.0638541728*t,u=-.0894841775*e-1.291485548*t,h=l+c*f,d=l+c*m,v=l+c*u;{let y=a*(1-o)+o*n,x=o*s,p=y+x*f,b=y+x*m,w=y+x*u,M=p*p*p,z=b*b*b,P=w*w*w,F=3*h*p*p,O=3*d*b*b,V=3*v*w*w,$=6*h*h*p,S=6*d*d*b,D=6*v*v*w,I=4.0767416621*M-3.3077115913*z+.2309699292*P-1,A=4.0767416621*F-3.3077115913*O+.2309699292*V,L=4.0767416621*$-3.3077115913*S+.2309699292*D,H=A/(A*A-.5*I*L),B=-I*H,q=-1.2684380046*M+2.6097574011*z-.3413193965*P-1,K=-1.2684380046*F+2.6097574011*O-.3413193965*V,ie=-1.2684380046*$+2.6097574011*S-.3413193965*D,X=K/(K*K-.5*q*ie),k=-q*X,T=-.0041960863*M-.7034186147*z+1.707614701*P-1,W=-.0041960863*F-.7034186147*O+1.707614701*V,ae=-.0041960863*$-.7034186147*S+1.707614701*D,J=W/(W*W-.5*T*ae),re=-T*J;B=H>=0?B:1e6,k=X>=0?k:1e6,re=J>=0?re:1e6,o+=Math.min(B,Math.min(k,re))}}}return o}function Wn(e,t,n=null){n||(n=Xn(e,t));let s=n[0],a=n[1];return[a/s,a/(1-s)]}function ir(e,t,n){let s=Xn(t,n),a=Jl(t,n,e,1,e,s),i=Wn(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]),f=e*o,m=(1-e)*l,u=.9*c*Math.sqrt(Math.sqrt(1/(1/(f*f*f*f)+1/(m*m*m*m))));return f=e*.4,m=(1-e)*.8,[Math.sqrt(1/(1/(f*f)+1/(m*m))),u,a]}function Ls(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),f;if(i<l){let m=0,u=.8*o,h=1-u/l;f=(i-m)/(u+h*(i-m))*.8}else{let m=l,u=.2*l*l*1.25*1.25/o,h=1-u/(c-l);f=.8+.2*((i-m)/(u+h*(i-m)))}return f&&(a.s=f,a.h=te(Math.atan2(s,n)*180/Math.PI)),a}function As(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:ft(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,f]=ir(a.l,i,o),m,u,h,d;n<.8?(m=1.25*n,u=0,h=.8*l,d=1-h/c):(m=5*(n-.8),u=c,h=.2*c*c*1.25*1.25/l,d=1-h/(f-c));let v=u+m*h/(1-d*m);return a.a=v*i,a.b=v*o,a}const Ql={...Ha,mode:"okhsl",channels:["h","s","l","alpha"],parse:["--okhsl"],serialize:"--okhsl",fromMode:{oklab:Ls,rgb:e=>Ls(St(e))},toMode:{oklab:As,rgb:e=>Et(As(e))}};function zs(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]=Wn(i,o),f=.5,m=1-f/l,u=c/(a+t*c),h=u*t,d=u*a,v=ft(h),y=d*v/h,x=Ke({l:v,a:i*y,b:o*y}),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?(f+c)*d/(c*f+c*m*d):0,v:t?t/h:0};return b.s&&(b.h=te(Math.atan2(s,n)*180/Math.PI)),e.alpha!==void 0&&(b.alpha=e.alpha),b}function Ps(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]=Wn(i,o),f=.5,m=1-f/l,u=1-s*f/(f+c-c*m*s),h=s*c*f/(f+c-c*m*s),d=ft(u),v=h*d/u,y=Ke({l:d,a:i*v,b:o*v}),x=Math.cbrt(1/Math.max(y.r,y.g,y.b,0)),p=ft(a*u),b=h*p/u;return t.l=p*x,t.a=b*i*x,t.b=b*o*x,t}const ec={...qa,mode:"okhsv",channels:["h","s","v","alpha"],parse:["--okhsv"],serialize:"--okhsv",fromMode:{oklab:zs,rgb:e=>zs(St(e))},toMode:{oklab:Ps,rgb:e=>Et(Ps(e))}};function tc(e,t){if(!t||t[0]!=="oklab")return;const n={mode:"oklab"},[,s,a,i,o]=t;if(!(s.type===_.Hue||a.type===_.Hue||i.type===_.Hue))return s.type!==_.None&&(n.l=Math.min(Math.max(0,s.type===_.Number?s.value:s.value/100),1)),a.type!==_.None&&(n.a=a.type===_.Number?a.value:a.value*.4/100),i.type!==_.None&&(n.b=i.type===_.Number?i.value:i.value*.4/100),o.type!==_.None&&(n.alpha=Math.min(1,Math.max(0,o.type===_.Number?o.value:o.value/100))),n}const nc={...qn,mode:"oklab",toMode:{lrgb:Ke,rgb:Et},fromMode:{lrgb:rr,rgb:St},ranges:{l:[0,1],a:[-.4,.4],b:[-.4,.4]},parse:[tc],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 sc(e,t){if(!t||t[0]!=="oklch")return;const n={mode:"oklch"},[,s,a,i,o]=t;if(s.type!==_.None){if(s.type===_.Hue)return;n.l=Math.min(Math.max(0,s.type===_.Number?s.value:s.value/100),1)}if(a.type!==_.None&&(n.c=Math.max(0,a.type===_.Number?a.value:a.value*.4/100)),i.type!==_.None){if(i.type===_.Percentage)return;n.h=i.value}return o.type!==_.None&&(n.alpha=Math.min(1,Math.max(0,o.type===_.Number?o.value:o.value/100))),n}const ac={...Yn,mode:"oklch",toMode:{oklab:e=>_e(e,"oklab"),rgb:e=>Et(_e(e,"oklab"))},fromMode:{rgb:e=>ye(St(e),"oklch"),oklab:e=>ye(e,"oklch")},parse:[sc],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]}},$s=e=>{let{r:t,g:n,b:s,alpha:a}=$e(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},Ds=({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=De({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},rc={...Pe,mode:"p3",parse:["display-p3"],serialize:"display-p3",fromMode:{rgb:e=>Ds(Ce(e)),xyz65:Ds},toMode:{rgb:e=>Se($s(e)),xyz65:$s}},Jt=e=>{let t=Math.abs(e);return t>=1/512?Math.sign(e)*Math.pow(t,1/1.8):16*e},Os=({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:Jt(e*1.3457868816471585-t*.2555720873797946-.0511018649755453*n),g:Jt(e*-.5446307051249019+t*1.5082477428451466+.0205274474364214*n),b:Jt(e*0+t*0+1.2119675456389452*n)};return s!==void 0&&(a.alpha=s),a},Qt=(e=0)=>{let t=Math.abs(e);return t>=16/512?Math.sign(e)*Math.pow(t,1.8):e/16},Fs=e=>{let t=Qt(e.r),n=Qt(e.g),s=Qt(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},ic={...Pe,mode:"prophoto",parse:["prophoto-rgb"],serialize:"prophoto-rgb",fromMode:{xyz50:Os,rgb:e=>Os(Ze(e))},toMode:{xyz50:Fs,rgb:e=>We(Fs(e))}},Bs=1.09929682680944,oc=.018053968510807,en=e=>{const t=Math.abs(e);return t>oc?(Math.sign(e)||1)*(Bs*Math.pow(t,.45)-(Bs-1)):4.5*e},Us=({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:en(e*1.7166511879712683-t*.3556707837763925-.2533662813736599*n),g:en(e*-.6666843518324893+t*1.6164812366349395+.0157685458139111*n),b:en(e*.0176398574453108-t*.0427706132578085+.9421031212354739*n)};return s!==void 0&&(a.alpha=s),a},Hs=1.09929682680944,lc=.018053968510807,tn=(e=0)=>{let t=Math.abs(e);return t<lc*4.5?e/4.5:(Math.sign(e)||1)*Math.pow((t+Hs-1)/Hs,1/.45)},Vs=e=>{let t=tn(e.r),n=tn(e.g),s=tn(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},cc={...Pe,mode:"rec2020",fromMode:{xyz65:Us,rgb:e=>Us(Ce(e))},toMode:{xyz65:Vs,rgb:e=>Se(Vs(e))},parse:["rec2020"],serialize:"rec2020"},Ne=.0037930732552754493,or=Math.cbrt(Ne),nn=e=>Math.cbrt(e)-or,dc=e=>{const{r:t,g:n,b:s,alpha:a}=$e(e),i=nn(.3*t+.622*n+.078*s+Ne),o=nn(.23*t+.692*n+.078*s+Ne),l=nn(.2434226892454782*t+.2047674442449682*n+.5518098665095535*s+Ne),c={mode:"xyb",x:(i-o)/2,y:(i+o)/2,b:l-(i+o)/2};return a!==void 0&&(c.alpha=a),c},sn=e=>Math.pow(e+or,3),uc=({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=sn(e+t)-Ne,i=sn(t-e)-Ne,o=sn(n+t)-Ne,l=De({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},fc={mode:"xyb",channels:["x","y","b","alpha"],parse:["--xyb"],serialize:"--xyb",toMode:{rgb:uc},fromMode:{rgb:dc},ranges:{x:[-.0154,.0281],y:[0,.8453],b:[-.2778,.388]},interpolate:{x:j,y:j,b:j,alpha:{use:j,fixup:Q}}},mc={mode:"xyz50",parse:["xyz-d50"],serialize:"xyz-d50",toMode:{rgb:We,lab:Gn},fromMode:{rgb:Ze,lab:Vn},channels:["x","y","z","alpha"],ranges:{x:[0,.964],y:[0,.999],z:[0,.825]},interpolate:{x:j,y:j,z:j,alpha:{use:j,fixup:Q}}},hc=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},gc=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},xc={mode:"xyz65",toMode:{rgb:Se,xyz50:hc},fromMode:{rgb:Ce,xyz50:gc},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:j,y:j,z:j,alpha:{use:j,fixup:Q}}},pc=({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},bc=({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},vc={mode:"yiq",toMode:{rgb:bc},fromMode:{rgb:pc},channels:["y","i","q","alpha"],parse:["--yiq"],serialize:"--yiq",ranges:{i:[-.595,.595],q:[-.522,.522]},interpolate:{y:j,i:j,q:j,alpha:{use:j,fixup:Q}}},yc=e=>Math.max(0,Math.min(1,e||0)),an=e=>Math.round(yc(e)*255),_c=de("rgb"),wc=e=>{if(e===void 0)return;let t=an(e.r),n=an(e.g),s=an(e.b);return"#"+(1<<24|t<<16|n<<8|s).toString(16).slice(1)},jc=e=>wc(_c(e)),lr=de("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},Nc=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 kc(e){return dr(lr(e))}function ur(e="rgb"){const{gamut:t}=bt(e);if(!t)return s=>!0;const n=de(typeof t=="string"?t:e);return s=>dr(n(s))}function Mc(e="rgb"){const{gamut:t}=bt(e);if(!t)return i=>it(i);const n=typeof t=="string"?t:e,s=de(n),a=ur(n);return i=>{const o=it(i);if(!o)return;const l=s(o);if(a(l))return o;const c=cr(l);return o.mode===c.mode?c:de(o.mode)(c)}}function Cc(e,t="lch",n="rgb"){e=it(e);let s=n==="rgb"?kc:ur(n),a=n==="rgb"?Nc:Mc(n);if(e===void 0||s(e))return e;let i=de(e.mode);e=de(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,f=bt(t).ranges.c,m=(f[1]-f[0])/Math.pow(2,13),u=o.c;for(;c-l>m;)o.c=l+(c-l)*.5,s(o)?(u=o.c,l=o.c):c=o.c;return i(s(o)?o:{...o,c:u})}function Gs(e){let t=de("lrgb")(e);return .2126*t.r+.7152*t.g+.0722*t.b}function fr(e,t){let n=Gs(e),s=Gs(t);return(Math.max(n,s)+.05)/(Math.min(n,s)+.05)}G(il);G(ml);G(hl);G(gl);G(bl);G(Ha);G(qa);G(Sl);G(El);G(Ll);G(Al);G(qn);G(Pl);G(Yn);G(Dl);G(Xl);G(Wl);G(Zl);G(Ql);G(ec);G(nc);G(ac);G(rc);G(ic);G(cc);G(Pe);G(fc);G(mc);G(xc);G(vc);const pn=/^#?(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;function bn(e){const t=e.trim();return t.startsWith("#")?t:`#${t}`}const Sc=4.5,Ec={dark:"#1e2330",light:"#f1f0ee"},vn="#FFFFFF",yn="#040403";function qs(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 Ic(e){const t=qs(e,yn);if(!Number.isNaN(t))return t>=qs(e,vn)?yn:vn}const Tc={dark:.3,light:.9},Rc={dark:vn,light:yn},Lc=de("oklch");function Ac(e,t){if(e==null||!pn.test(e.trim()))return;const n=Lc(bn(e));if(!n)return;const s=jc(Cc({...n,l:Tc[t]},"oklch"));return fr(s,Rc[t])>=Sc?s:void 0}function Zn({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 f=g.useCallback(()=>{c(!0)},[]),m=Xe(i,o),h=s==="featured"&&!!a&&!m&&!l&&n==="ready"?Ac(t,e):void 0,d=h??(m?$o:Ec[e]);return{thumbnailUrl:l?void 0:a,accentStyle:h?{backgroundColor:h}:void 0,chinTextColor:Ic(d),tailColor:d,isLoading:n==="loading",onImageError:f}}const zc="flex size-6 items-center justify-center rounded-full bg-[#121110] text-white focus-ring",Pc="relative before:absolute before:-inset-[10px] before:content-['']",$c=({title:e,placeholderTitle:t,description:n,url:s,mimeType:a,thumbnailUrl:i,sourceUrl:o,layout:l="featured",appIcon:c,cta:f,accentColor:m,status:u="ready",onDismiss:h,onEditClick:d,dismissLabel:v="Dismiss attachment"})=>{const y=l==="classic",x=Xe(a,o),p=Zn({variant:"dark",accentColor:m,status:u,layout:l,thumbnailUrl:i,mimeType:a,sourceUrl:o}),b=h?r.jsx("button",{type:"button",onClick:h,"aria-label":v,className:E(zc,!x&&Pc),children:r.jsx(C.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(C.PencilSimpleIcon,{className:"size-5",weight:"regular"})}):void 0;return x&&!p.isLoading?r.jsx(at,{variant:"dark",bgClassName:Bn,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(rt,{variant:"dark",sourceUrl:o,title:e,mimeType:a})}),b&&r.jsx("div",{className:"shrink-0",children:b})]})}):r.jsxs(at,{variant:"dark",fixedHeight:!y,accentStyle:p.accentStyle,busy:p.isLoading,topRight:y?b:void 0,children:[!y&&r.jsx(rt,{variant:"dark",thumbnailUrl:p.thumbnailUrl,sourceUrl:o,title:e,mimeType:a,topRight:b,isLoading:p.isLoading,onImageError:p.onImageError}),r.jsx(On,{chinTextColor:p.chinTextColor,variant:"dark",title:e,placeholderTitle:t,description:n,url:s,appIcon:c,cta:f,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:E("messaging-link-card-tail",t==="receiver"&&"messaging-link-card-tail--received")})]}):r.jsx(r.Fragment,{children:s}),Dc=({title:e,description:t,url:n,mimeType:s,thumbnailUrl:a,sourceUrl:i,layout:o="featured",appIcon:l,cta:c,accentColor:f,status:m="ready",onClick:u,groupPosition:h="single"})=>{const d=Fn(s,i),v=Dn(n),y=c==null&&v!=null&&!d?v:void 0,x=c==null&&!d?u:void 0,p=m!=="loading"&&Xe(s,i)?Bn:void 0,b=c&&u?{...c,onClick:()=>{var M;u(),(M=c.onClick)==null||M.call(c)}}:c,w=Zn({variant:"light",accentColor:f,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(at,{variant:"light",href:y,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(rt,{variant:"light",thumbnailUrl:w.thumbnailUrl,sourceUrl:i,title:e,mimeType:s,isLoading:w.isLoading,onImageError:w.onImageError}),r.jsx(On,{chinTextColor:w.chinTextColor,variant:"light",title:e,description:t,url:n,appIcon:l,cta:b,isLoading:w.isLoading})]})})},Oc=({title:e,placeholderTitle:t,description:n,url:s,mimeType:a,thumbnailUrl:i,sourceUrl:o,layout:l="featured",appIcon:c,cta:f,accentColor:m,status:u="ready",onClick:h,groupPosition:d="single"})=>{const v=Fn(a,o),y=Dn(s),x=f==null&&y!=null&&!v?y:void 0,p=f==null&&!v&&x!=null?h:void 0,b=u!=="loading"&&Xe(a,o),w=Zn({variant:"dark",accentColor:m,status:u,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(at,{variant:"dark",href:x,onClick:p,fixedHeight:l==="featured"&&!b,accentStyle:w.accentStyle,busy:w.isLoading,bgClassName:b?Bn:void 0,children:[l==="featured"&&r.jsx(rt,{variant:"dark",thumbnailUrl:w.thumbnailUrl,sourceUrl:o,title:e,mimeType:a,isLoading:w.isLoading,onImageError:w.onImageError}),r.jsx(On,{chinTextColor:w.chinTextColor,variant:"dark",title:e,placeholderTitle:t,description:n,url:s,appIcon:c,cta:f,isLoading:w.isLoading})]})})},mt={Composer:$c,Sent:Oc,Received:Dc};function U(e){const t=e==null?void 0:e.trim();return t||void 0}function Ys(e){return e.trim().replace(/^https?:\/\//i,"").replace(/\/+$/,"").toLowerCase()}function Fc(e,t){if(!(e!=null&&e.trim())||!(t!=null&&t.trim()))return!1;const n=Ys(e),s=Ys(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 Xs(e){const t=U(e.og_scrape_url)??U(e.title_link),n=U(e.image_url)??U(e.thumb_url),s=U(e.asset_url),a=U(e.mime_type);return{title:U(e.title),description:U(e.text),url:t,thumbnailUrl:ve(n),sourceUrl:s,layout:n||Fn(a,s)?"featured":"classic",mimeType:a,accentColor:U(e.accent_color),status:"ready"}}function Bc(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=U(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=Bc(a);i&&n(i,a)}return t}function Uc(e){return e.filter(t=>t.type==="media").length}function Hc(e,t,n){return t<=1?n:e===0?"first":e===t-1?"end":"middle"}function Ws(e){return U(e.image_url)??U(e.asset_url)??""}function Vc(e){switch(e){case"image":return Le.Image;case"video":return Le.Video;case"audio":return Le.Audio;case"pdf":return Le.Pdf;default:return Le.File}}function Gc(e,t){if(t.length>1)switch(e){case"image":return{items:t.map(s=>({src:Ws(s),alt:U(s.title)}))};case"video":return{items:t.map(s=>({src:U(s.asset_url)??"",poster:U(s.thumb_url),mimeType:U(s.mime_type)}))};case"audio":return{items:t.map(s=>({src:U(s.asset_url)??"",mimeType:U(s.mime_type)??"audio/mpeg",filename:U(s.title)}))};case"pdf":return{items:t.map(s=>({src:U(s.asset_url)??"",filename:U(s.title),fileSize:s.file_size}))};case"file":return{items:t.map(s=>({src:U(s.asset_url)??"",filename:U(s.title),fileSize:s.file_size,mimeType:U(s.mime_type)??"application/octet-stream"}))}}const n=t[0];if(!n)return{};switch(e){case"image":return{src:Ws(n),alt:U(n.title)};case"video":return{src:U(n.asset_url)??"",poster:U(n.thumb_url),mimeType:U(n.mime_type)};case"audio":return{src:U(n.asset_url)??"",mimeType:U(n.mime_type)??"audio/mpeg",filename:U(n.title)};case"pdf":return{src:U(n.asset_url)??"",filename:U(n.title),fileSize:n.file_size};case"file":return{src:U(n.asset_url)??"",filename:U(n.title),fileSize:n.file_size,mimeType:U(n.mime_type)??"application/octet-stream"}}}function qc({groupPosition:e,isMyMessage:t,segment:n}){const s=Vc(n.kind),a={...Gc(n.kind,n.attachments),groupPosition:e};return t?r.jsx(s.Sent,{...a}):r.jsx(s.Received,{...a})}const Yc=({groupPosition:e,isMyMessage:t,message:n,renderText:s})=>{var y;const a=gr(n.attachments);if(a.length===0)return null;const i=Uc(a),o=(y=n.text)==null?void 0:y.trim(),l=a.find(x=>x.type==="link"),c=(l==null?void 0:l.type)==="link"?Xs(l.attachments[0]??{}).url:void 0,f=o&&Fc(o,c)?void 0:o;let m=0;const u=[],h=f?"middle":e,d=(x,p,b)=>{const w=t?mt.Sent:mt.Received;u.push(r.jsx(w,{...Xs(x),groupPosition:b?h:"middle"},p))},v=(x,p)=>{const b=Hc(m,i,e);m+=1,u.push(r.jsx(qc,{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,M)=>{d(w,`link-${p}-${M}`,b&&M===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:[u,!f&&r.jsx(N.MessageErrorIcon,{})]}),f?r.jsxs("div",{className:"str-chat__message-bubble",children:[r.jsx(N.MessageText,{message:n,renderText:s}),r.jsx(N.MessageErrorIcon,{})]}):null]})},Xc=e=>{var as,rs,is,os,ls,cs,ds,us,fs,ms;const{additionalMessageInputProps:t,chatbotVotingEnabled:n,editing:s,endOfGroup:a,firstOfGroup:i,groupedByUser:o,handleAction:l,handleOpenThread:c,handleRetry:f,highlighted:m,isMessageAIGenerated:u,isMyMessage:h,message:d,renderText:v,threadList:y,viewerLanguage:x,onBroadcastClick:p,resolvedBroadcastName:b}=e,{client:w}=N.useChatContext("CustomMessage"),{channel:M}=N.useChannelStateContext("CustomMessage"),{isUnlocking:z,onUnlockClick:P,onFetchSource:F,onDownloadClick:O}=Ea("LockedAttachment"),[V,$]=g.useState(!1),S=N.useMessageReminder(d.id),{selected:D,voteUp:I,voteDown:A}=ra(d),{Attachment:L=N.Attachment,EditMessageModal:H=N.EditMessageModal,MessageActions:B,MessageBlocked:q=N.MessageBlocked,MessageBouncePrompt:K=N.MessageBouncePrompt,MessageDeleted:ie=N.MessageDeleted,MessageIsThreadReplyInChannelButtonIndicator:X=N.MessageIsThreadReplyInChannelButtonIndicator,MessageRepliesCountButton:k=N.MessageRepliesCountButton,ReminderNotification:T=N.ReminderNotification,StreamedMessageText:W=N.StreamedMessageText,PinIndicator:ae}=N.useComponentContext("CustomMessage"),J=N.messageHasAttachments(d),re=N.messageHasReactions(d),ne=g.useMemo(()=>u==null?void 0:u(d),[u,d]),Y=g.useMemo(()=>{const je=d.attachments??[],Te=d.shared_location?[d.shared_location,...je]:je;if(!st(d))return Te;const hs=Te.filter(gs=>!("type"in gs)||!En(gs));return hs.length===Te.length?Te:hs},[d]),oe=g.useMemo(()=>gr(Y),[Y]),ge=g.useMemo(()=>{const je=kn({message:d,viewerLanguage:x});return je===d.text?d:{...d,text:je}},[d,x]),Je=oe.length>0,Qe=oe.reduce((je,Te)=>je+Te.attachments.length,0)===((Y==null?void 0:Y.length)??0),xe=fa({endOfGroup:a,firstOfGroup:i,groupedByUser:o});if(N.isDateSeparatorMessage(d))return null;if(d.deleted_at||d.type==="deleted")return r.jsx(ie,{message:d});if(N.isMessageBlocked(d))return r.jsx(q,{});const we=!y&&!!d.reply_count,pe=!y&&d.show_in_channel&&d.parent_id,Jn=d.status==="failed"&&((as=d.error)==null?void 0:as.status)!==403,Qn=N.isMessageBounced(d);let Ee;Jn?Ee=()=>f(d):Qn&&(Ee=()=>$(!0));const le=h(),Nr=E("str-chat__message str-chat__message-simple",`str-chat__message--${d.type}`,`str-chat__message--${d.status}`,le?"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":J,"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"&&((rs=d==null?void 0:d.error)==null?void 0:rs.status)!==403,"str-chat__message-with-thread-link":we||pe,"str-chat__virtual-message__wrapper--end":a,"str-chat__virtual-message__wrapper--first":i,"str-chat__virtual-message__wrapper--group":o}),It=d.poll_id&&w.polls.fromState(d.poll_id),es=yo(d),Ie=st(d),kr=Pn(d),Tt=!!(Y!=null&&Y.length&&!d.quoted_message),ts=Ie&&le&&Tt,Mr=Je&&Qe&&!d.quoted_message&&!It&&!ne&&!Ie,ns={contentType:"text",amountText:(is=d.metadata)==null?void 0:is.amount_text,paymentStatus:(os=d.metadata)==null?void 0:os.payment_status,renderedText:d.text&&r.jsx(N.MessageText,{message:ge,renderText:v})},ss={contentType:"media",title:(ls=d.metadata)==null?void 0:ls.attachment_title,mimeType:(cs=d.metadata)==null?void 0:cs.attachment_mime_type,thumbnailUrl:(ds=d.metadata)==null?void 0:ds.attachment_thumbnail,amountText:(us=d.metadata)==null?void 0:us.amount_text,detail:(fs=d.metadata)==null?void 0:fs.attachment_detail,paymentStatus:(ms=d.metadata)==null?void 0:ms.payment_status,onFetchSource:F?()=>F(d,M):void 0};return r.jsxs(r.Fragment,{children:[s&&r.jsx(H,{additionalMessageInputProps:t}),V&&r.jsx(N.MessageBounceModal,{MessageBouncePrompt:K,onClose:()=>$(!1),open:V}),r.jsxs("div",{className:Nr,"data-message-id":d.id,"data-dd-privacy":"mask",children:[ae&&r.jsx(ae,{}),!!S&&r.jsx(T,{reminder:S}),d.user&&r.jsx(Me,{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:Ie}),r.jsx("div",{className:E("str-chat__message-inner",{"str-chat__simple-message--error-failed":Jn||Qn}),"data-testid":"message-inner",onClick:Ee,onKeyDown:Ee,role:Ee?"button":void 0,tabIndex:Ee?0:void 0,style:{marginInlineEnd:0,marginInlineStart:0},children:es?r.jsx(At,{message:d,standalone:!0}):bo(d)?r.jsx("div",{className:"str-chat__message-bubble-wrapper",children:r.jsxs("div",{className:"flex items-center gap-2",children:[le&&B&&r.jsx(B,{}),le?r.jsx(Fe,{...ns,isMine:!0}):r.jsx(Fe,{...ns,isMine:!1,isUnlocking:z(d.id),onUnlockClick:()=>P==null?void 0:P(d,M)}),!le&&B&&r.jsx(B,{})]})}):vo(d)?r.jsxs("div",{className:"str-chat__message-bubble-wrapper",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[le&&B&&r.jsx(B,{}),le?r.jsx(Fe,{...ss,isMine:!0,onPreviewClick:()=>P?P(d,M):void 0}):r.jsx(Fe,{...ss,isMine:!1,isUnlocking:z(d.id),onUnlockClick:()=>P?P(d,M):void 0,onDownloadClick:()=>O?O(d,M):void 0}),!le&&B&&r.jsx(B,{})]}),d.text&&r.jsx("div",{className:"str-chat__message-bubble",children:r.jsx(N.MessageText,{message:ge,renderText:v})})]}):Mr?r.jsx(Yc,{groupPosition:xe,isMyMessage:le,message:{...ge,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:[Ie&&!ts&&r.jsx(At,{message:d,hasAttachment:Tt,isMyMessage:le}),It&&r.jsx(N.Poll,{poll:It}),Y!=null&&Y.length&&!d.quoted_message?r.jsx(L,{actionHandler:l,attachments:Y}):null,ne?r.jsx(W,{message:ge,renderText:v}):r.jsx(N.MessageText,{message:ge,renderText:v}),r.jsx(N.MessageErrorIcon,{})]})})}),!kr&&!es&&r.jsxs("div",{className:"str-chat__message-footer",children:[(!Ie||ts)&&r.jsx(At,{message:d,hasAttachment:Tt,isMyMessage:le}),n&&Ie&&r.jsx(Ra,{selected:D,onVoteUp:I,onVoteDown:A})]}),r.jsx(No,{onBroadcastClick:p,resolvedBroadcastName:b}),we&&r.jsx(k,{onClick:c,reply_count:d.reply_count}),pe&&r.jsx(X,{})]},d.id)]})},Wc=g.memo(Xc,(e,t)=>e.chatbotVotingEnabled!==t.chatbotVotingEnabled||e.viewerLanguage!==t.viewerLanguage||e.onBroadcastClick!==t.onBroadcastClick||e.resolvedBroadcastName!==t.resolvedBroadcastName?!1:N.areMessageUIPropsEqual(e,t)),Zc=e=>{var i;const t=N.useMessageContext("CustomMessage"),n=g.useContext(Ca),s=(i=t.message.metadata)==null?void 0:i.broadcast_id,a=typeof s=="string"?n==null?void 0:n[s]:void 0;return r.jsx(Wc,{...t,...e,resolvedBroadcastName:a})},Kc=()=>{var n;const{handleDelete:e,message:t}=N.useMessageContext("CustomMessageActions");return((n=t.metadata)==null?void 0:n.payment_status)==="paid"?null:r.jsx(_n.DefaultDropdownActionButton,{onClick:e,"aria-label":"Delete",title:"Delete",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:r.jsx(C.TrashSimpleIcon,{size:16,weight:"light","aria-hidden":!0})})},Jc=()=>{const{handleFlag:e}=N.useMessageContext("CustomMessageActions");return r.jsx(_n.DefaultDropdownActionButton,{onClick:e,"aria-label":"Report",title:"Report",className:"bg-marble rounded-full p-2 hover:bg-sand transition-all",children:r.jsx(C.FlagIcon,{size:16,weight:"light","aria-hidden":!0})})},Qc=()=>{var t;const{message:e}=N.useMessageContext("CustomMessageActions");return((t=e.metadata)==null?void 0:t.custom_type)!==se.MESSAGE_CUSTOM_TYPE.ATTACHMENT?null:r.jsx(_n.MessageActions,{messageActionSet:[{Component:Kc,placement:"quick",type:"delete"},{Component:Jc,placement:"quick",type:"flag"}]})},ed=e=>({linkPreviews:Array.from(e.previews.values()).filter(t=>nt.LinkPreviewsManager.previewIsLoaded(t)||nt.LinkPreviewsManager.previewIsLoading(t))}),td=()=>{const{linkPreviewsManager:e}=N.useMessageComposer(),{linkPreviews:t}=N.useStateStore(e.state,ed),n=a=>{e.dismissPreview(a)};return t.length>0?r.jsx("div",{className:"messaging-link-preview-list flex flex-col items-stretch w-full gap-2",children:t.map(a=>{const i=nt.LinkPreviewsManager.previewIsLoading(a);return r.jsx(mt.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},ht=g.createContext(!1),nd=200,sd=()=>g.useContext(ht),ad=({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(C.ArrowUpIcon,{weight:"bold",className:"size-4"})}),Zs=()=>{const e=g.useContext(ht),{handleSubmit:t}=N.useMessageInputContext(),n=N.useMessageComposerHasSendableData(),s=e||!n,{SendButton:a=ad,AttachmentPreviewList:i=N.AttachmentPreviewList}=N.useComponentContext("CustomMessageInput"),o=g.useRef(null);return g.useEffect(()=>{const l=o.current;if(!l||typeof ResizeObserver>"u")return;const c=new ResizeObserver(()=>{l.contains(document.activeElement)&&(l.scrollTop=l.scrollHeight)});return c.observe(l),()=>c.disconnect()},[]),g.useEffect(()=>{const l=o.current;if(!l)return;const c=f=>{var u;Array.from(((u=f.clipboardData)==null?void 0:u.items)??[]).some(h=>h.kind==="file")||f.stopPropagation()};return l.addEventListener("paste",c),()=>l.removeEventListener("paste",c)},[]),r.jsxs("div",{ref:o,className:"central-container flex flex-col min-w-0 w-full max-h-[calc(var(--messaging-surface-height,100dvh)*0.5)] overflow-y-auto overscroll-contain 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 flex-col gap-2 px-2 pt-2",children:[r.jsx(N.QuotedMessagePreview,{}),r.jsx(td,{}),r.jsx(i,{})]}),r.jsxs("div",{className:"messaging-composer-row flex items-start",children:[r.jsx(N.TextareaComposer,{"aria-disabled":e||void 0,containerClassName:"min-w-0 flex-1 leading-[0]",className:"w-full resize-none overflow-hidden bg-transparent py-3.5 pl-4 pr-4 outline-none leading-5 placeholder:text-black/30 text-sm",autoFocus:!e,enterKeyHint:"send",maxRows:1/0,readOnly:e,tabIndex:e?-1:void 0}),r.jsx("div",{className:"sticky bottom-2 mt-auto mb-2 mr-2 shrink-0 pt-2",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"})})]})]})},Ks=({renderActions:e,renderHeader:t,renderFooter:n,disabled:s=!1,disabledReason:a,composerInput:i})=>{var m;const{channel:o}=N.useChannelStateContext(),l=((m=o==null?void 0:o.data)==null?void 0:m.frozen)===!0,c=!!i,f=g.useRef(null);return g.useEffect(()=>{if(!c)return;const u=f.current,h=u==null?void 0:u.parentElement;if(!u||!h)return;let d=u.offsetHeight;const v=()=>{const x=u.offsetHeight,p=x>d;d=x;const b=Array.from(h.querySelectorAll(".str-chat__list")).find(M=>M.scrollHeight>M.clientHeight)??null,w=b?b.scrollHeight-b.scrollTop-b.clientHeight<nd:!1;h.style.setProperty("--messaging-composer-height",`${x}px`),p&&w&&b&&(b.scrollTop=b.scrollHeight)};if(v(),typeof ResizeObserver>"u")return;const y=new ResizeObserver(v);return y.observe(u),()=>{y.disconnect(),h.style.removeProperty("--messaging-composer-height")}},[c]),s?c?r.jsxs("div",{ref:f,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:f,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(ht.Provider,{value:l,children:r.jsx(N.MessageInput,{Input:i??Zs})})]}),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(ht.Provider,{value:l,children:r.jsx(N.MessageInput,{Input:Zs})})]}),n==null?void 0:n()]})},rd={SYSTEM_DM_AGENT_PAUSED:"DM Agent has left the conversation",SYSTEM_DM_AGENT_RESUMED:"DM Agent has rejoined the conversation"},id=["SYSTEM_AGE_SAFETY_BLOCKED"],od={SYSTEM_AGE_SAFETY_BLOCKED:"This user isn’t able to reply because they don’t meet our age safety guidelines."},rn="age safety guidelines.",ld="https://linktr.ee/s/about/contact",cd=e=>id.includes(e),dd=e=>{var t;return cd((t=e.metadata)==null?void 0:t.custom_type)},ud=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}},fd=e=>{const t=e.indexOf(rn);if(t===-1)return e;const n=t+rn.length;return r.jsxs(r.Fragment,{children:[e.slice(0,t),r.jsx("a",{href:ld,target:"_blank",rel:"noopener noreferrer",className:"mes-age-safety-system-message__emphasis font-medium text-inherit underline",children:rn}),e.slice(n)]})},md=e=>{var s,a;const t=!dd(e.message),n=ud(e.message);if((n==null?void 0:n.kind)==="dm-agent"){const i=((s=e.message.text)==null?void 0:s.trim())||rd[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(C.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(N.MessageTimestamp,{message:e.message})]})}if((n==null?void 0:n.kind)==="age-safety"){const i=((a=e.message.text)==null?void 0:a.trim())||od[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(C.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:fd(i)})})]}),!t&&r.jsx(N.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(N.MessageTimestamp,{message:e.message})]})},xr=g.createContext(!1),on=({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"})}),hd=new Set([N.AIStates.Thinking,N.AIStates.Generating,N.AIStates.ExternalSources]),gd=({threadList:e})=>{var v,y;const{channel:t,channelConfig:n,thread:s}=N.useChannelStateContext(),{client:a}=N.useChatContext(),{typing:i={}}=N.useTypingContext(),{aiState:o}=N.useAIState(t),l=g.useContext(xr);if(!e&&l&&hd.has(o)){const x=xd(t,(v=a.user)==null?void 0:v.id);return r.jsx(Js,{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 f=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)}):[],u=e?m:f;if(!u.length)return null;const h=(y=u[0])==null?void 0:y.user,d=h!=null&&h.id&&t.state.members[h.id]?t.state.members[h.id].user:void 0;return r.jsx(Js,{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"})},Js=({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(Me,{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(on,{cx:"4",index:0}),r.jsx(on,{cx:"16",index:1}),r.jsx(on,{cx:"28",index:2})]})})})})})})]})});function xd(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,pd=({className:e,message:t})=>r.jsxs("div",{className:E("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})]}),gt=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(pd,{className:"w-6 h-6"}),r.jsx("span",{className:"text-sm text-stone",children:"Loading messages"})]})}));gt.displayName="LoadingState";const bd=({onBack:e,showBackButton:t,renderMessageInputActions:n,renderMessageInputFooter:s,renderConversationFooter:a,onLeaveConversation:i,onBlockParticipant:o,showDeleteConversation:l=!0,onDeleteConversationClick:c,onBlockParticipantClick:f,onReportParticipantClick:m,showBlockParticipant:u=!0,showReportParticipant:h=!0,composerDisabled:d=!1,composerDisabledReason:v,showStarButton:y=!1,chatbotVotingEnabled:x=!1,renderChannelBanner:p,customChannelActions:b,renderChannelActions:w,renderMessage:M,viewerLanguage:z,showChannelInfo:P=!0,onParticipantNameClick:F,onBroadcastClick:O,resolveBroadcastName:V,composerInput:$})=>{const{channel:S,messages:D}=N.useChannelStateContext(),I=g.useRef(O);g.useEffect(()=>{I.current=O},[O]);const A=g.useCallback(X=>{var k;(k=I.current)==null||k.call(I,X)},[]),L=O?A:void 0,H=lo(D,V),B=S.state.messages.some(X=>X.type!=="deleted"),q=p?r.jsx(g.Fragment,{children:p()},"lt-channel-banner"):null,K=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:P,showStarButton:y,onLeaveConversation:i,onBlockParticipant:o,showDeleteConversation:l,showBlockParticipant:u,showReportParticipant:h,onDeleteConversationClick:c,onBlockParticipantClick:f,onReportParticipantClick:m,customChannelActions:b,renderChannelActions:w,onParticipantNameClick:F}),ie=g.useCallback(X=>{const{message:k}=N.useMessageContext("ChannelView"),T=r.jsx(Zc,{...X,chatbotVotingEnabled:x,viewerLanguage:z,onBroadcastClick:L});return!M||!k?T:M(T,k)},[x,L,M,z]);return r.jsx(Ca.Provider,{value:H,children:r.jsx(N.WithComponents,{overrides:{Message:ie,MessageActions:Qc,UnreadMessagesNotification:()=>null,UnreadMessagesSeparator:()=>null},children:r.jsx(N.Window,{children:$?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:[!B&&r.jsx("div",{className:"str-chat__list",children:r.jsxs("div",{className:"str-chat__message-list-scroll",children:[K,q]})}),r.jsx(N.MessageList,{head:B?r.jsxs("div",{className:"sticky top-0 z-10",children:[K,q]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},"lt-channel-message-list"),r.jsx(Ks,{...n&&{renderActions:()=>n==null?void 0:n(S)},...a&&{renderHeader:()=>a(S)},renderFooter:()=>s==null?void 0:s(S),disabled:d,disabledReason:v,composerInput:$},"lt-channel-message-input")]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[!B&&r.jsx("div",{className:"str-chat__list",children:r.jsxs("div",{className:"str-chat__message-list-scroll",children:[K,q]})}),r.jsx(N.MessageList,{head:B?r.jsxs("div",{className:"sticky top-0 z-10",children:[K,q]}):void 0,hideDeletedMessages:!0,hideNewMessageSeparator:!1})]},"lt-channel-message-list"),a?r.jsx(g.Fragment,{children:a(S)},"lt-channel-conversation-footer"):null,r.jsx(Ks,{...n&&{renderActions:()=>n==null?void 0:n(S)},renderFooter:()=>s==null?void 0:s(S),disabled:d,disabledReason:v,composerInput:$},"lt-channel-message-input")]})})})})},Kn=g.memo(({channel:e,onBack:t,showBackButton:n=!1,renderMessageInputActions:s,renderMessageInputFooter:a,renderConversationFooter:i,onLeaveConversation:o,onBlockParticipant:l,className:c,CustomChannelEmptyState:f=pr,showDeleteConversation:m=!0,onDeleteConversationClick:u,onBlockParticipantClick:h,onReportParticipantClick:d,showBlockParticipant:v=!0,showReportParticipant:y=!0,composerDisabled:x=!1,composerDisabledReason:p,dmAgentEnabled:b,messageMetadata:w,onMessageSent:M,showStarButton:z=!1,chatbotVotingEnabled:P=!1,renderChannelBanner:F,customChannelActions:O,renderChannelActions:V,renderMessage:$,onMessageLinkClick:S,sendButton:D,attachmentPreviewList:I,viewerLanguage:A,showChannelInfo:L=!0,onParticipantNameClick:H,onBroadcastClick:B,resolveBroadcastName:q,composerInput:K})=>{const ie=g.useCallback(async(k,T,W)=>{var oe;const ae=((oe=e.data)==null?void 0:oe.chatbot_paused)===!0,J=b&&!ae,re={...T,...J&&{silent:!0},...w&&{metadata:{...T.metadata??{},...w}}},ne={...W,...J&&{skip_push:!0}},Y=await e.sendMessage(re,ne);return M==null||M(Y),Y},[e,b,w,M]),X=g.useRef(null);return g.useEffect(()=>{if(!S)return;const k=X.current;if(!k)return;const T=W=>{const ae=W.target,J=ae==null?void 0:ae.closest("a[href]"),re=J==null?void 0:J.getAttribute("href");if(!re)return;const ne=J==null?void 0:J.closest("[data-message-id]"),Y=ne==null?void 0:ne.getAttribute("data-message-id"),oe=Y?e.state.messages.find(ge=>ge.id===Y):void 0;S(re,oe)};return k.addEventListener("click",T),()=>k.removeEventListener("click",T)},[S,e]),r.jsx("div",{ref:X,className:E("messaging-channel-view h-full flex flex-col",c),children:r.jsx(xr.Provider,{value:b??!1,children:r.jsx(N.Channel,{channel:e,MessageSystem:md,EmptyStateIndicator:f,LoadingIndicator:gt,DateSeparator:Or,TypingIndicator:gd,doSendMessageRequest:ie,...D?{SendButton:D}:{},...I?{AttachmentPreviewList:I}:{},children:r.jsx(bd,{onBack:t,showBackButton:n,renderMessageInputActions:s,renderMessageInputFooter:a,renderConversationFooter:i,onLeaveConversation:o,onBlockParticipant:l,CustomChannelEmptyState:f,showDeleteConversation:m,onDeleteConversationClick:u,onBlockParticipantClick:h,onReportParticipantClick:d,showBlockParticipant:v,showReportParticipant:y,composerDisabled:x,composerDisabledReason:p,showStarButton:z,chatbotVotingEnabled:P,renderChannelBanner:F,customChannelActions:O,renderChannelActions:V,renderMessage:$,viewerLanguage:A,showChannelInfo:L,onParticipantNameClick:H,onBroadcastClick:B,resolveBroadcastName:q,composerInput:K})})})})});Kn.displayName="ChannelView";const Be=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"})]})}));Be.displayName="ErrorState";const vd=({capabilities:e={},renderMessageInputActions:t,renderConversationFooter:n,onChannelSelect:s,onExitConversation:a,initialParticipantFilter:i,initialParticipantData:o,CustomChannelEmptyState:l,onBlockParticipantClick:c,onReportParticipantClick:f,dmAgentEnabled:m,onMessageSent:u,chatbotVotingEnabled:h=!1,viewerLanguage:d,renderChannelBanner:v,customChannelActions:y,renderChannelActions:x,onParticipantNameClick:p,onBroadcastClick:b,resolveBroadcastName:w,renderMessage:M,onMessageLinkClick:z,showChannelInfo:P,composerInput:F})=>{const{client:O,isConnected:V,isLoading:$,error:S,refreshConnection:D,service:I,debug:A}=ta(),[L,H]=g.useState(null),[B,q]=g.useState(null),[K,ie]=g.useState(!1),{showDeleteConversation:X=!0}=e,k=g.useRef(o);k.current=o;const T=g.useRef(s);T.current=s;const W=g.useRef(null),ae=g.useRef(null);g.useEffect(()=>{ae.current=L},[L]),g.useEffect(()=>{if(!O||!V)return;const ne=O.userID;if(!ne)return;const Y=`${ne}::${i}`;if(W.current===Y)return;W.current=Y;const oe=()=>{W.current===Y&&(W.current=null)};(async()=>{var Je,Qe;try{A&&console.log("[MessagingShell] Loading initial conversation with:",i);const xe=await O.queryChannels({type:"messaging",members:{$eq:[ne,i]}},{},{limit:1});if(xe.length>0){H(xe[0]),q(null),(Je=T.current)==null||Je.call(T,xe[0]),A&&console.log("[MessagingShell] Initial conversation loaded:",xe[0].id);return}const we=k.current;if(!we||!I){oe(),q("No conversation found with this account"),A&&console.log("[MessagingShell] No conversation found for:",i);return}try{const pe=await I.startChannelWithParticipant({id:we.id,name:we.name,phone:we.phone});H(pe),q(null),(Qe=T.current)==null||Qe.call(T,pe),A&&console.log("[MessagingShell] Channel created and loaded:",pe.id)}catch(pe){console.error("[MessagingShell] Failed to create conversation:",pe),oe(),q("Failed to create conversation")}}catch(xe){console.error("[MessagingShell] Failed to load initial conversation:",xe),oe(),ae.current||q("Failed to load conversation")}})()},[i,O,V,I,A]);const J=g.useRef(a);J.current=a;const re=g.useCallback(()=>{var ne;H(null),ie(!0),(ne=J.current)==null||ne.call(J)},[]);return $?r.jsx(gt,{}):S?r.jsx(Be,{message:S,onBack:D}):!V||!O?r.jsx(Be,{message:"Not connected to messaging service",onBack:D}):B?r.jsx(Be,{message:B}):K&&!L?r.jsx(Be,{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(Kn,{channel:L,renderMessageInputActions:t,renderConversationFooter:n,renderChannelBanner:v,onLeaveConversation:re,onBlockParticipant:re,CustomChannelEmptyState:l,showDeleteConversation:X,onBlockParticipantClick:c,onReportParticipantClick:f,dmAgentEnabled:m,onMessageSent:u,chatbotVotingEnabled:h,viewerLanguage:d,customChannelActions:y,renderChannelActions:x,onParticipantNameClick:p,onBroadcastClick:b,resolveBroadcastName:w,renderMessage:M,onMessageLinkClick:z,showChannelInfo:P,composerInput:F},L.id)})}):r.jsx(gt,{})};function yd(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}),_d=br.Provider,wd=()=>g.useContext(br),jd=(e,t)=>{const n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),s=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate());return Math.floor((s-n)/(1e3*60*60*24))},vr=e=>{const t=new Date;if(Math.floor((t.getTime()-e.getTime())/1e3)<60)return"Just now";const s=jd(e,t);return s===0?e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):s===1?"Yesterday":s<7?e.toLocaleDateString(void 0,{weekday:"short"}):e.getFullYear()===t.getFullYear()?e.toLocaleDateString(void 0,{month:"short",day:"numeric"}):e.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})},yr=g.memo(e=>{var O,V,$;const{channel:t,unread:n}=e,{selectedChannel:s,onChannelSelect:a,debug:i,channelPreview:o,renderMessagePreview:l,viewerLanguage:c}=wd(),{client:f}=N.useChatContext(),m=(s==null?void 0:s.id)===(t==null?void 0:t.id),u=na(t);if(o){const S=o;return r.jsx(S,{...e,active:m,selectedChannel:s,onChannelSelect:a,viewerLanguage:c})}const h=()=>{t&&a(t)},d=S=>{const D=S.key==="Enter"||S.key===" ",I=S.repeat;!D||I||(S.preventDefault(),h())},v=jn((O=t==null?void 0:t.state)==null?void 0:O.members,f==null?void 0:f.userID,t==null?void 0:t.type),y=Nn(v==null?void 0:v.user),x=(V=v==null?void 0:v.user)==null?void 0:V.image,p=(()=>{var D;const S=(D=t==null?void 0:t.state)==null?void 0:D.messages;if(S!=null&&S.length){for(let I=S.length-1;I>=0;I--)if(S[I].type!=="system")return S[I]}})(),w=(()=>{var L;const S=kn({message:p,viewerLanguage:c}),{custom_type:D,attachment_content_type:I}=(p==null?void 0:p.metadata)||{};if(D===se.MESSAGE_CUSTOM_TYPE.TIP)return S||"Sent a tip";if(D===se.MESSAGE_CUSTOM_TYPE.PAID)return S||"Sent a message";if(D===se.MESSAGE_CUSTOM_TYPE.ATTACHMENT){if(I==="text")return"🔒 Sent a locked message";if(I==="media")return"🔒 Sent a locked attachment"}if(S)return S;const A=(L=p==null?void 0:p.attachments)==null?void 0:L[0];return A?A.og_scrape_url?A.og_scrape_url:A.type==="image"?"📷 Sent an image":A.type==="video"?"🎥 Sent a video":A.type==="audio"?"🎵 Sent audio":A.type==="file"?"📎 Sent a file":"📎 Sent an attachment":"No messages yet"})(),M=p!=null&&p.created_at?vr(new Date(p.created_at)):"",z=p?st(p):!1,P=l?l(p,w):`${z?"✨ ":""}${w}`,F=n??0;return i&&console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER",{channelId:t==null?void 0:t.id,isSelected:m,participantName:y,unreadCount:F,hasTimestamp:!!M}),r.jsx("div",{role:"button",tabIndex:0,onClick:h,onKeyDown:d,className:E("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(Me,{id:(($=v==null?void 0:v.user)==null?void 0:$.id)||t.id||"unknown",name:y,image:x,size:48,starred:u}),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:E("text-sm font-medium truncate text-[#191918]"),children:[u&&r.jsx("span",{className:"sr-only",children:"Starred conversation. "}),y]}),M&&r.jsx("span",{className:"text-xs text-[#717070] flex-shrink-0",children:M})]}),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:P}),F>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:F>99?"99+":F})]})]})]})})});yr.displayName="CustomChannelPreview";const Nd={last_message_at:-1},_r=g.memo(({onChannelSelect:e,selectedChannel:t,filters:n,allowNewMessagesFromUnfilteredChannels:s=!1,channelRenderFilterFn:a,sort:i=Nd,className:o,customEmptyStateIndicator:l,channelListPaginator:c=N.InfiniteScroll,channelPreview:f,renderMessagePreview:m,viewerLanguage:u,lockChannelOrder:h,onMessageNewHandler:d,onMessageNew:v,onChannelVisible:y,onAddedToChannel:x,onChannelUpdated:p})=>{const b=g.useRef(0);b.current++;const{debug:w=!1}=wn(),M=g.useCallback(P=>{for(const F of P)yd(F);return a?a(P):P},[a]);w&&console.log("📺 [ChannelList] 🔄 RENDER START",{renderCount:b.current,selectedChannelId:t==null?void 0:t.id,filters:n});const z=g.useMemo(()=>({selectedChannel:t,onChannelSelect:e,debug:w,channelPreview:f,renderMessagePreview:m,viewerLanguage:u}),[t,e,w,f,m,u]);return r.jsx("div",{className:E("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(_d,{value:z,children:r.jsx(N.ChannelList,{filters:n,sort:i,options:{limit:30},allowNewMessagesFromUnfilteredChannels:s,channelRenderFilterFn:M,lockChannelOrder:h,onMessageNewHandler:d,onMessageNew:v,onChannelVisible:y,onAddedToChannel:x,onChannelUpdated:p,Paginator:c,Preview:yr,EmptyStateIndicator:l},`${JSON.stringify(n)}:${JSON.stringify(i)}`)})})})});_r.displayName="ChannelList";const Qs=`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%`,kd={sent:"var(--str-chat__own-message-bubble-background-color, #1e2330)",received:"var(--str-chat__message-bubble-background-color, #f1f0ee)"},Md=({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:kd[e],WebkitMask:Qs,mask:Qs}}),Cd={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:E("relative px-4 py-3","text-[0.875rem] leading-[1.3125rem] tracking-[0.14px]",a),style:{...Cd[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(Md,{variant:e})]}),Sd=({text:e,tail:t,header:n,className:s})=>r.jsx(wr,{variant:"received",text:e,tail:t,header:n,className:s}),Ed=({text:e,tail:t,className:n})=>r.jsx(wr,{variant:"sent",text:e,tail:t,className:n}),Id={Sent:Ed,Received:Sd},jr=({question:e,onClick:t,loading:n=!1,className:s})=>r.jsx("button",{type:"button",onClick:t,disabled:n,style:{backgroundColor:"#E6E5E3"},className:E("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}),Td=({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(Me,{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=Re;exports.AttachmentThumbnail=Mn;exports.Avatar=Me;exports.ChannelEmptyState=pr;exports.ChannelList=_r;exports.ChannelView=Kn;exports.CustomMessageProvider=fo;exports.FaqList=Td;exports.FaqListItem=jr;exports.LinkAttachment=mt;exports.LockedAttachment=Fe;exports.MediaMessage=oi;exports.MessageAttachment=Le;exports.MessageBubble=Id;exports.MessageVoteButtons=Ra;exports.MessagingProvider=Sr;exports.MessagingShell=vd;exports.bubbleGroupPositionFromStream=fa;exports.buildCompactMetaLabel=ga;exports.formatFileSize=ma;exports.formatRelativeTime=vr;exports.getFileExtensionLabel=ha;exports.getMessageDisplayText=kn;exports.getSourceType=fe;exports.isLinkAttachment=En;exports.isUuidLike=sa;exports.normalizeLanguageCode=ia;exports.optimizeMessagingAttachmentUrl=ve;exports.renderTypeIcon=ke;exports.resolveConversationParticipant=jn;exports.resolveLinkAttachment=xt;exports.resolveMediaFromMessage=pt;exports.resolveParticipantDisplayName=Nn;exports.useComposerLocked=sd;exports.useCustomMessage=Ea;exports.useMessageVote=ra;exports.useMessaging=ta;
|
|
5
|
+
//# sourceMappingURL=index-CcitzVoW.cjs.map
|