1import{r as c,j as e,h as Ee,k as tt}from"./react-vendor-MWwqr4Bj.js";import{u as ee,K as Te,J as le,_ as je,$ as oe,P as nt,a0 as at,a1 as st,a2 as rt,A as _e,G as $e,a3 as it}from"./index-Di18qMTG.js";import{k as ct,l as ke,m as ot,u as lt}from"./workspace-K1j3NXxq.js";import{e as dt,a as mt,b as ut,d as ht,f as pt}from"./campaignLifecycle-D1n3UwZr.js";import{s as ve,a as _t}from"./useEvents-CpEsLx4y.js";import{u as Ce}from"./usePoll-CfjecEDS.js";import{c as ft,a as gt,p as bt}from"./uploadsV2-C8YNcuYR.js";import{s as Ne}from"./chatStream-ClbkeCDQ.js";import{B as X}from"./BrandTile-CaCbS30t.js";import{P as we}from"./paperclip-CdfMUMiJ.js";import{M as ye,r as Se}from"./index-I1LvrIBu.js";import{C as Re}from"./chevron-right-BI87eizl.js";const xt="_wrap_1f6la_7",jt="_card_1f6la_9",kt="_bar_1f6la_19",vt="_mark_1f6la_26",Ct="_stack_1f6la_27",Nt="_name_1f6la_30",wt="_context_1f6la_34",yt="_chevron_1f6la_38",St="_panel_1f6la_45",Rt="_tile_1f6la_53",Lt="_tileMark_1f6la_60",Bt="_tileText_1f6la_61",qt="_tileName_1f6la_62",It="_tileSub_1f6la_66",Dt="_tileEyebrow_1f6la_70",Mt="_tileCheck_1f6la_74",Et="_tileInvite_1f6la_75",Tt="_tileCta_1f6la_76",$t="_inviteEyebrow_1f6la_82",At="_inviteCta_1f6la_86",h={wrap:xt,card:jt,bar:kt,mark:vt,stack:Ct,name:Nt,context:wt,chevron:yt,panel:St,tile:Rt,tileMark:Lt,tileText:Bt,tileName:qt,tileSub:It,tileEyebrow:Dt,tileCheck:Mt,tileInvite:Et,tileCta:Tt,inviteEyebrow:$t,inviteCta:At};function Pt({programmes:t,campaigns:n,invitations:s=[],scope:l,onSelect:d,onReviewInvitation:k,attachment:y}){const{t:p}=ee(),[x,m]=c.useState(!1),w=c.useRef(null),C=ct(n),S=t.length+C.length+s.length;if(c.useEffect(()=>{if(!x)return;const r=$=>{$.key==="Escape"&&m(!1)},_=$=>{w.current&&!w.current.contains($.target)&&m(!1)};return window.addEventListener("keydown",r),window.addEventListener("mousedown",_),window.addEventListener("touchstart",_),()=>{window.removeEventListener("keydown",r),window.removeEventListener("mousedown",_),window.removeEventListener("touchstart",_)}},[x]),S===0)return null;const v=l?.kind==="programme"?t.find(r=>r.membership_id===l.membershipId)??null:null,o=l?.kind==="campaign"?C.find(r=>r.campaign_id===l.campaignId)??null:null,D=!v&&!o&&S===1&&s.length===1?s[0]:null;if(D&&k)return e.jsx("div",{className:h.wrap,ref:w,children:e.jsxs("div",{className:h.card,children:[e.jsxs("button",{type:"button",className:h.bar,onClick:()=>k(D),children:[e.jsx(X,{name:D.brand_name||D.name,size:38,className:h.mark}),e.jsxs("span",{className:h.stack,children:[e.jsx("span",{className:h.inviteEyebrow,children:p("programmes.invitationEyebrow")}),e.jsx("span",{className:h.name,children:D.name})]}),e.jsx("span",{className:h.inviteCta,children:p("programmes.review")})]}),y]})});const B=v?.brand_name||o?.brand_name||null,u=v?ke(v.name,v.brand_name):o?ke(o.campaign_name,o.brand_name):p("scope.pickContext"),q=v?v.brand_name:o?[o.brand_name,p("campaign.standaloneChip")].filter(Boolean).join(" · "):null,I=e.jsxs(e.Fragment,{children:[e.jsx(X,{name:B||u,size:38,className:h.mark}),e.jsxs("span",{className:h.stack,children:[e.jsx("span",{className:h.name,children:u}),q&&e.jsx("span",{className:h.context,children:q})]})]}),M=r=>{m(!1),d(r)};return e.jsxs("div",{className:h.wrap,ref:w,children:[e.jsxs("div",{className:h.card,"data-interactive":"true",children:[e.jsxs("button",{type:"button",className:h.bar,"aria-haspopup":"listbox","aria-expanded":x,"aria-label":p("scope.switchLabel"),onClick:()=>m(r=>!r),children:[I,e.jsx(Te,{size:18,strokeWidth:2.2,className:h.chevron,"data-open":x,"aria-hidden":"true"})]}),y]}),x&&e.jsxs("div",{className:h.panel,role:"listbox","aria-label":p("scope.switchLabel"),children:[t.map(r=>{const _=l?.kind==="programme"&&l.membershipId===r.membership_id;return e.jsxs("button",{type:"button",role:"option","aria-selected":_,className:h.tile,"data-current":_,onClick:()=>M({kind:"programme",membershipId:r.membership_id}),children:[e.jsx(X,{name:r.brand_name||r.name,size:40,className:h.tileMark}),e.jsxs("span",{className:h.tileText,children:[e.jsx("span",{className:h.tileName,children:r.name}),e.jsx("span",{className:h.tileSub,children:r.brand_name})]}),_&&e.jsx(le,{size:16,strokeWidth:2.6,className:h.tileCheck,"aria-hidden":"true"})]},r.membership_id)}),C.map(r=>{const _=l?.kind==="campaign"&&l.campaignId===r.campaign_id;return e.jsxs("button",{type:"button",role:"option","aria-selected":_,className:h.tile,"data-current":_,onClick:()=>M({kind:"campaign",campaignId:r.campaign_id}),children:[e.jsx(X,{name:r.brand_name||r.campaign_name,size:40,className:h.tileMark}),e.jsxs("span",{className:h.tileText,children:[e.jsx("span",{className:h.tileName,children:r.campaign_name}),e.jsx("span",{className:h.tileSub,children:r.brand_name?`${r.brand_name} · ${p("campaign.standaloneChip")}`:p("campaign.standaloneChip")})]}),_&&e.jsx(le,{size:16,strokeWidth:2.6,className:h.tileCheck,"aria-hidden":"true"})]},r.campaign_id)}),k&&s.map(r=>e.jsxs("button",{type:"button",className:`${h.tile} ${h.tileInvite}`,onClick:()=>{m(!1),k(r)},children:[e.jsx(X,{name:r.brand_name||r.name,size:40,className:h.tileMark}),e.jsxs("span",{className:h.tileText,children:[e.jsx("span",{className:h.tileEyebrow,children:p("programmes.invitationEyebrow")}),e.jsx("span",{className:h.tileName,children:r.name})]}),e.jsx("span",{className:h.tileCta,children:p("programmes.review")})]},r.token))]})]})}const Le=t=>t.find(n=>(n.channel??"platform_chat")==="platform_chat")??null,he=(t,n)=>{const s=t.filter(l=>(l.channel??"platform_chat")==="platform_chat");return n.programmeId?s.find(l=>l.programme_id===n.programmeId)??null:n.campaignId?s.find(l=>!l.programme_id&&l.campaign_id===n.campaignId)??null:s.find(l=>!l.programme_id&&!l.campaign_id)??null},Ae=t=>t.filter(n=>n.channel==="platform_brand").sort((n,s)=>(s.updated_at??"").localeCompare(n.updated_at??"")),Be=t=>[...t.filter(s=>(s.channel??"platform_chat")==="platform_chat"),...Ae(t)],qe=t=>t?.brand_name||t?.campaign_name||"Brand",Ie=5e3,Pe=c.createContext(null);function We(){const t=c.useContext(Pe);if(!t)throw new Error("useLiaChat must be used inside LiaChatProvider");return t}function Wt({validationId:t,activeCampaign:n,scopeProgrammeId:s,campaigns:l,programmes:d,workspaceKey:k,campaignLanguage:y,isApproved:p,refreshTodos:x,children:m}){const{t:w}=ee(),C={programmeId:s,campaignId:n?.campaign_id??null},S=c.useCallback(i=>ot(i,d,l,k),[d,l,k]),[v,o]=c.useState([]),[D,B]=c.useState(""),[u,q]=c.useState([]),[I,M]=c.useState(!1),[r,_]=c.useState(null),[$,H]=c.useState([]),[O,N]=c.useState(null),[f,R]=c.useState(null),[A,Y]=c.useState(null),[F,P]=c.useState(!1),[Z,z]=c.useState("waiting"),K=c.useRef(null),V=c.useRef(0),G=c.useRef(0),Oe=i=>{z("typing"),P(!1),o([]),_(null),N(null),B(""),(async()=>{await new Promise(L=>setTimeout(L,600)),V.current+=1,P(!0),z("streaming");let g="";const j={role:"assistant",content:""};o([j]),K.current=Ne({validationId:t,conversationId:null,message:"hi",lang:i,campaignId:n?.campaign_id||null,programmeId:s||null,greeting:!0,onStart:({conversation_id:L})=>{_(L),N({id:L,title:"LIA",message_count:0,updated_at:new Date().toISOString(),channel:"platform_chat",status:"active",creator_id:A})},onTextDelta:L=>
1{g+=L,o([{...j,content:g}])},onStop:()=>{P(!1),z("done"),x(),se()},onError:()=>{o([{role:"assistant",content:w("chat.error")}]),P(!1),z("done")}})})()},Ve=s??n?.campaign_id??"__global__";c.useEffect(()=>{let i=!0;K.current?.abort(),P(!1),M(!1),R(null),q([]),B(""),V.current+=1;const b=++G.current;return z("waiting"),o([]),je(t).then(g=>{if(!i||b!==G.current)return;const j=S(g?.conversations||[]);H(Be(j));const L=he(j,C);if(L)return _(L.id),N(L),Y(L.creator_id??null),ve(L.creator_id),oe(t,L.id).then(T=>{!i||b!==G.current||(o(T?.messages||[]),z("done"))});_(null),N(null),Oe(y)}).catch(()=>{i&&b===G.current&&z("done")}),()=>{i=!1}},[t,Ve]),c.useEffect(()=>()=>K.current?.abort(),[]);const te=c.useRef(F);te.current=F;const ne=c.useRef(I);ne.current=I;const de=c.useRef(!1),[Ge,He]=c.useState(0),ae=c.useCallback(()=>{de.current=!0,He(i=>i+1)},[]),Q=c.useCallback(()=>{if(!r)return;if(te.current||ne.current){ae();return}const i=V.current,b=++G.current;oe(t,r).then(g=>{if(V.current!==i||te.current||ne.current){ae();return}if(b!==G.current)return;const j=g?.messages||[];j.length&&o(j)}).catch(()=>{})},[t,r,ae]),se=c.useCallback(()=>{je(t).then(i=>{const b=S(i?.conversations||[]),g=he(b,{programmeId:s,campaignId:n?.campaign_id??null})??Le(b),j=Be(b);H(j);const L=g?.creator_id??null;L&&(Y(L),ve(L)),N(T=>T?j.find(ce=>ce.id===T.id)??T:g)}).catch(()=>{})},[t,n,s,S]);c.useEffect(()=>{!F&&!I&&de.current&&(de.current=!1,Q())},[F,I,Ge,Q]);const Ke=c.useCallback(i=>{i.type==="chat.message"&&Q()},[Q]),{connected:Ue}=_t(A?[`creator-chat:${A}`]:[],Ke,{auth:nt()??void 0});Ce(Q,Ie,{enabled:!!r&&!F&&!Ue&&Z!=="waiting"}),Ce(se,Ie,{enabled:Z!=="waiting"}),c.useEffect(()=>{!p&&u.length&&q([])},[p,u.length]);const U=Ae($),re=O?.channel==="platform_brand",ie=re||O?.channel==="email"||O?.status==="escalated",fe=re||f?"brand":"lia",ge=(re?O:f)??U.find(i=>i.campaign_id===n?.campaign_id)??(n?{campaign_id:n.campaign_id,campaign_name:n.campaign_name,brand_name:n.brand_name}:null)??U[0]??null,Je=U.length>0||!!n&&p;c.useEffect(()=>{ie&&u.length&&q([])},[ie,u.length]);const me=i=>{K.current?.abort(),P(!1),M(!1),z("done"),R(null),_(i.id),N(i),q([]),o([]),V.current+=1;const b=V.current,g=++G.current;oe(t,i.id).then(j=>{if(V.current!==b||te.current||ne.current){ae();return}g===G.current&&o(j?.messages||[])}).catch(()=>{})},Qe=()=>{const i=he($,C)??Le($);i&&i.id!==r?me(i):(R(null),i&&N(i))},be=i=>({id:"",title:i.brand_name||i.campaign_name||"Brand",message_count:0,updated_at:new Date().toISOString(),channel:"platform_brand",status:"active",campaign_id:i.campaign_id,campaign_name:i.campaign_name,brand_name:i.brand_name}),Xe=()=>{const i=U.find(g=>g.campaign_id===n?.campaign_id)??U[0];if(i){me(i);return}if(!n)return;K.current?.abort(),P(!1),M(!1),z("done"),q([]),_(null),o([]);const b=be(n);R(b),N(b)},xe=c.useRef(n?.campaign_id);c.useEffect(()=>{const i=n?.campaign_id;if(i===xe.current||(xe.current=i,fe!=="brand"||!n))return;const b=U.find(g=>g.campaign_id===i);if(b)b.id!==r&&me(b);else{K.current?.abort(),P(!1),M(!1),z("done"),q([]),_(null),o([]);const g=be(n);R(g),N(g)}},[n?.campaign_id]);const Ye=async i=>{const b={role:"user",content:i};o(j=>[...j,b]);const g=ge?.campaign_id??n?.campaign_id;try{if(r)await at(t,r,i,g),Q();else if(f?.campaign_id){const j=await st(t,{campaignId:f.campaign_id},i);_(j.conversation_id),N(T=>T&&{...T,id:j.conversation_id}),R(null);const L=await oe(t,j.conversation_id);o(L?.messages||[b])}else{o(j=>j.slice(0,-1)),B(i);return}se()}catch{o(j=>[...j.slice(0,-1),{role:"system",content:w("chat.error")}]),B(i)}},Ze=async i=>{const b=[];for(const g of i){const j=g.type||"application/octet-stream",{upload_url:L,s3_key:T}=await gt(t,g.name,j,g.size,n?.campaign_id||null);await bt(L,g,j),b.push({path:T,type:j,original_name:g.name})}return b},et={messages:v,input:D,setInput:B,pendingFiles:u,setPendingFiles:q,uploading:I,streaming:F,phase:Z,conversationId:r,activeConvo:O,brandThreads:U,chatMode:fe,brandContext:ge,hasBrandAccess:Je,isBrandThread:re,isDirectThread:ie,enterLia:Qe,enterBrand:Xe,sendMessage:async i=>{const b=(typeof i=="string"?i:D).trim();if(ie){if(!b||F||I||Z==="waiting")return;B(""),q([]),await Ye(b);return}const g=p?u:[];if(!b&&g.length===0||F||I||Z==="waiting")return;V.current+=1;const L={role:"user",content:b||`ð ${g.map(E=>
1E.name).join(", ")}`};o(E=>[...E,L]),B(""),q([]);let T=[];if(g.length){M(!0);try{T=await Ze(g)}catch(E){const W=ft(E);console.warn(`[chat-attach] upload failed (${W})`,E),q(g),o(J=>[...J,{role:"assistant",content:w(W==="storage"?"home.uploadBlocked":W==="rejected"?"home.uploadRejected":"home.uploadFailed")}]),M(!1);return}M(!1)}P(!0);let ce="";const ue={role:"assistant",content:""};o(E=>[...E,ue]),K.current=Ne({validationId:t,conversationId:r,message:b,lang:y,campaignId:n?.campaign_id||null,programmeId:s||null,attachments:T.length?T:void 0,onStart:({conversation_id:E})=>{_(E);const W=$.find(J=>J.id===E);N(W??{id:E,title:"LIA",message_count:0,updated_at:new Date().toISOString(),channel:"platform_chat",status:"active",creator_id:A})},onTextDelta:E=>{ce+=E,o(W=>{const J=[...W];return J[J.length-1]={...ue,content:ce},J})},onStop:()=>{P(!1),x(),se()},onError:()=>{o(E=>{const W=[...E];return W[W.length-1]={...ue,content:w("chat.error")},W}),P(!1)}})}};return e.jsx(Pe.Provider,{value:et,children:m})}const Ft=/(!?)\[([^\]]*)\]\(\s*(<[^>]*>|[^)\s]+)?(?:\s+"[^"]*")?\s*\)/g,zt=t=>t.replace(/^[*_\s]+|[*_\s]+$/g,""),Ot=/^\*\*([\s\S]+)\*\*$/;function Vt(t){const n=[],s=new Set,l=t.replace(Ft,(x,m,w,C)=>{if(m)return x;const S=C?(C.startsWith("<")?C.slice(1,-1):C).trim():"",v=zt(w);return S?(s.has(S)||(s.add(S),n.push({label:v||S,href:S})),v?`**${v}**`:""):v?`**${v}**`:""}),d=new Set(n.map(x=>x.label)),y=l.split(/\n{2,}/).filter(x=>{const m=x.trim().match(Ot);return!(m&&d.has(m[1]))});return{text:y.length>0?y.join(` 2 3`):l,actions:n}}function Fe(t,n){try{const s=new URL(t,n);if(s.pathname.startsWith("/creator/"))return s.pathname+s.search+s.hash}catch{}return null}const Gt="_page_1qfr3_9",Ht="_aura_1qfr3_19",Kt="_auraViolet_1qfr3_20",Ut="_selectorSlot_1qfr3_26",Jt="_taskRow_1qfr3_37",Qt="_taskRing_1qfr3_44",Xt="_taskLabel_1qfr3_45",Yt="_taskChevron_1qfr3_51",Zt="_taskSteps_1qfr3_58",en="_taskStep_1qfr3_58",tn="_taskStepChevron_1qfr3_69",nn="_taskDot_1qfr3_71",an="_taskStepLabel_1qfr3_78",sn="_chat_1qfr3_98",rn="_chatInner_1qfr3_110",cn="_bubbleRow_1qfr3_116",on="_userMsg_1qfr3_117",ln="_avatar_1qfr3_118",dn="_msgCol_1qfr3_130",mn="_bubble_1qfr3_116",un="_actionRow_1qfr3_171",hn="_actionChip_1qfr3_172",pn="_actionChipLabel_1qfr3_193",_n="_actionChipArrow_1qfr3_194",fn="_brandLabel_1qfr3_197",gn="_brandHint_1qfr3_202",bn="_systemNote_1qfr3_203",xn="_typingLabel_1qfr3_209",jn="_typingDots_1qfr3_215",kn="_typingDot_1qfr3_215",vn="_userBubble_1qfr3_223",Cn="_userAvatar_1qfr3_231",Nn="_statusBanner_1qfr3_239",wn="_invitedCta_1qfr3_256",yn="_inputBar_1qfr3_266",Sn="_inputCol_1qfr3_273",Rn="_aiNote_1qfr3_275",Ln="_attachChips_1qfr3_281",Bn="_attachChip_1qfr3_281",qn="_attachRemove_1qfr3_287",In="_inputInner_1qfr3_293",Dn="_input_1qfr3_266",Mn="_attachBtn_1qfr3_311",En="_sendBtn_1qfr3_318",Tn="_spinner_1qfr3_331",a={page:Gt,aura:Ht,auraViolet:Kt,selectorSlot:Ut,taskRow:Jt,taskRing:Qt,taskLabel:Xt,taskChevron:Yt,taskSteps:Zt,taskStep:en,taskStepChevron:tn,taskDot:nn,taskStepLabel:an,chat:sn,chatInner:rn,bubbleRow:cn,userMsg:on,avatar:ln,msgCol:dn,bubble:mn,actionRow:un,actionChip:hn,actionChipLabel:pn,actionChipArrow:_n,brandLabel:fn,brandHint:gn,systemNote:bn,typingLabel:xn,typingDots:jn,typingDot:kn,userBubble:vn,userAvatar:Cn,statusBanner:Nn,invitedCta:wn,inputBar:yn,inputCol:Sn,aiNote:Rn,attachChips:Ln,attachChip:Bn,attachRemove:qn,inputInner:In,input:Dn,attachBtn:Mn,sendBtn:En,spinner:Tn},$n=t=>({a:({href:n,children:s,...l})=>{const d=n?Fe(n,window.location.origin):null;return d?e.jsx("a",{href:n,onClick:k=>{k.preventDefault(),t(d)},...l,children:s}):e.jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",...l,children:s})}});function An({actions:t,navigate:n}){return e.jsx("div",{className:a.actionRow,children:t.map(s=>{const l=Fe(s.href,window.location.origin);return l?e.jsxs("a",{href:s.href,className:a.actionChip,onClick:d=>{d.preventDefault(),n(l)},children:[e.jsx("span",{className:a.actionChipLabel,children:s.label}),e.jsx(_e,{size:15,strokeWidth:2.4,"aria-hidden":"true",className:a.actionChipArrow})]},s.href):e.jsxs("a",{href:s.href,className:a.actionChip,target:"_blank",rel:"noopener noreferrer",children:[e.jsx("span",{className:a.actionChipLabel,children:s.label}),e.jsx(_e,{size:15,strokeWidth:2.4,"aria-hidden":"true",className:a.actionChipArrow})]},s.href)})})}const ze=()=>e.jsxs("div",{className:a.typingDots,children:[e.jsx("span",{className:a.typingDot}),e.jsx("span",{className:a.typingDot}),e.jsx("span",{className:a.typingDot})]}),Pn=c.memo(function({role:n,content:s,isBrandThread:l,brandName:d,senderName:k,markdownComponents:y,attachmentFallbackText:p,brandTeamLabel:x,typingLabel:m,userInitials:w,grouped:C,showActions:S,navigate:v}){const o=n!=="user"&&n!=="system",{text:D,actions:B}=c.useMemo(()=>o?Vt(s):{text:s,actions:[]},[o,s]);if(n==="system")return e.jsx("div",{className:a.systemNote,children:s});if(n==="user")return e.jsxs("div",{className:a.userMsg,"data-grouped":C,children:[e.jsx("div",{className:a.userBubble,children:s.trim()||p}),e.jsx("span",{className:a.userAvatar,"aria-hidden":C,children:C?"":w})]});const u=S&&B.length>0?e.jsx(An,{actions:B,navigate:v}):null;return l?e.jsxs("div",{className:a.bubbleRow,"data-grouped":C,children:[e.jsx(X,{name:d,size:30,color:"var(--accent)",onColor:"var(--on-accent)"}),e.jsxs("div",{className:a.msgCol,children:[e.jsxs("div",{className:a.bubble,children:[e.jsx("span",{className:a.brandLabel,children:n==="brand"&&k||d}),e.jsx(ye,{remarkPlugins:[Se],components:y,children:D})]}),u]})]}):e.jsxs("div",{className:a.bubbleRow,"data-grouped":C,children:[e.jsx("div",{className:a.avatar,children:e.jsx("img",{src:$e,alt:"LIA"})}),e.jsxs("div",{className:a.msgCol,children:[e.jsxs("div",{className:a.bubble,children:[n==="brand"&&e.jsx("span",{className:a.brandLabel,children:k||x}),s?e.jsx(ye,{remarkPlugins:[Se],components:y,children:D}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:a.typingLabel,children:m}),e.jsx(ze,{})]})]}),u]})]})});function Wn({disabled:t,isApproved:n,banners:s,userInitials:l}){const{t:d}=ee(),k=Ee(),y=c.useMemo(()=>
3$n(k),[k]),{messages:p,input:x,setInput:m,pendingFiles:w,setPendingFiles:C,uploading:S,streaming:v,phase:o,isBrandThread:D,isDirectThread:B,brandContext:u,sendMessage:q}=We(),I=c.useRef(null),M=c.useRef(null),r=c.useRef(0),_=c.useRef(null);c.useEffect(()=>{const f=M.current,R=r.current,A=p.length!==R;if(r.current=p.length,!A&&f&&f.scrollHeight-f.scrollTop-f.clientHeight>140)return;const Y=R===0&&p.length>1?"auto":"smooth";I.current?.scrollIntoView({behavior:Y})},[p]);const $=f=>{f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),q())},H=qe(u),O=p.reduce((f,R,A)=>R.role!=="user"&&R.role!=="system"?A:f,-1),N=()=>e.jsxs(e.Fragment,{children:[o==="typing"&&e.jsxs("div",{className:a.bubbleRow,children:[e.jsx("div",{className:a.avatar,children:e.jsx("img",{src:$e,alt:"LIA"})}),e.jsxs("div",{className:a.bubble,children:[e.jsx("span",{className:a.typingLabel,children:d("home.typing")}),e.jsx(ze,{})]})]}),(o==="streaming"||o==="done")&&p.map((f,R)=>e.jsx(Pn,{role:f.role,content:f.content??"",isBrandThread:D,brandName:H,senderName:f.sender_name??null,markdownComponents:y,showActions:R===O,navigate:k,attachmentFallbackText:d("home.attachmentSent"),brandTeamLabel:d("chat.brandTeamLabel"),typingLabel:d("home.typing"),userInitials:l,grouped:R>0&&p[R-1].role===f.role&&f.role!=="system"},f.id??`i-${R}`)),e.jsx("div",{ref:I})]});return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:a.chat,ref:M,children:e.jsxs("div",{className:a.chatInner,children:[s,B&&p.length===0&&e.jsx("div",{className:a.brandHint,children:d("chat.brandReplyHint")}),N()]})}),e.jsx("div",{className:a.inputBar,children:e.jsxs("div",{className:a.inputCol,children:[!D&&!B&&e.jsx("p",{className:a.aiNote,children:d("home.aiDisclosure")}),w.length>0&&e.jsx("div",{className:a.attachChips,children:w.map((f,R)=>e.jsxs("span",{className:a.attachChip,children:[e.jsx(we,{size:13,strokeWidth:2,"aria-hidden":"true"})," ",f.name,e.jsx("button",{type:"button",className:a.attachRemove,"aria-label":d("home.removeAttachment"),onClick:()=>C(A=>A.filter((Y,F)=>F!==R)),children:"Ã"})]},`${f.name}-${R}`))}),e.jsxs("div",{className:a.inputInner,children:[e.jsx("input",{ref:_,type:"file",accept:"image/*,video/*",multiple:!0,style:{display:"none"},onChange:f=>{const R=Array.from(f.target.files||[]);R.length&&C(A=>[...A,...R]),f.target.value=""}}),e.jsx("button",{type:"button",className:a.attachBtn,"aria-label":d("home.attachFile"),title:d("home.attachFile"),onClick:()=>_.current?.click(),disabled:v||S||t||o==="waiting"||!n||B,children:e.jsx(we,{size:19,strokeWidth:2,"aria-hidden":"true"})}),e.jsx(rt,{rows:1,className:a.input,placeholder:t?d("home.chatDisabled"):D?`${d("chat.messagePrefix")} ${qe(u)}â¦`:d(B?"chat.contactBrand":"chat.messageLia"),value:x,onChange:f=>m(f.target.value),onKeyDown:$,disabled:v||S||t||o==="waiting"}),e.jsx("button",{onClick:()=>void q(),disabled:!x.trim()&&w.length===0||v||S||t||o==="waiting",className:a.sendBtn,children:v||S?e.jsx("div",{className:a.spinner}):e.jsx(_e,{size:19,strokeWidth:2.2,"aria-hidden":"true"})})]})]})})]})}const De=2*Math.PI*15;function Me({prefix:t,nextLabel:n,countLabel:s,percent:l,steps:d,onOpen:k}){const[y,p]=c.useState(!1),x=d===null;return e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:a.taskRow,"aria-expanded":x?void 0:y,onClick:x?k:()=>p(m=>!m),children:[e.jsxs("svg",{viewBox:"0 0 36 36",className:a.taskRing,"aria-hidden":"true",children:[e.jsx("circle",{cx:"18",cy:"18",r:"15",fill:"none",stroke:"var(--stone)",strokeWidth:"6"}),e.jsx("circle",{cx:"18",cy:"18",r:"15",fill:"none",stroke:"var(--accent)",strokeWidth:"6",strokeLinecap:"round",strokeDasharray:`${Math.min(Math.max(l,0),100)/100*De} ${De}`})]}),e.jsxs("span",{className:a.taskLabel,children:[t,": ",e.jsx("strong",{children:n}),s?` · ${s}`:""]}),x?e.jsx(Re,{size:16,strokeWidth:2.4,className:a.taskChevron,"aria-hidden":"true"}):e.jsx(Te,{size:16,strokeWidth:2.4,className:a.taskChevron,"data-open":y,"aria-hidden":"true"})]}),y&&d&&e.jsx("div",{className:a.taskSteps,children:d.map(m=>m.onOpen?e.jsxs("button",{type:"button",className:a.taskStep,"data-done":m.done,"data-current":m.current,onClick:m.onOpen,children:[e.jsx("span",{className:a.taskDot,"aria-hidden":"true",children:m.done&&e.jsx(le,{size:11,strokeWidth:3.4})}),e.jsx("span",{className:a.taskStepLabel,children:m.label}),e.jsx(Re,{size:14,strokeWidth:2.4,className:a.taskStepChevron,"aria-hidden":"true"})]},m.id):e.jsxs("div",{className:a.taskStep,"data-done":m.done,"data-current":m.current,children:[e.jsx("span",{className:a.taskDot,"aria-hidden":"true",children:m.done&&e.jsx(le,{size:11,strokeWidth:3.4})}),e.jsx("span",{className:a.taskStepLabel,children:m.label})]},m.id))})]})}const pe={contract:"contract",order:"order",brief:"brief",content:"content"};function ta(){const t=tt(),{active:n}=lt(),{language:s}=ee(),l=t.activeCampaign?.language||s,d=t.scope,k=d?.kind==="programme"?t.programmes.find(o=>o.membership_id===d.membershipId)??null:null,y=k?.programme_id??null,p=dt(t.activeCampaign?.decision,t.activeCampaign?null:k?.membership_status,t.profile.decision),x=mt(p),m=ut(p),w=!x&&!m,C=!!t.activeCampaign?.is_pool,S=x&&!t.activeCampaign&&!!k,v=m;return e.jsx(Wt,{validationId:t.validationId,activeCampaign:t.activeCampaign,scopeProgrammeId:y,campaigns:t.campaigns,programmes:t.programmes,workspaceKey:n?.key??null,campaignLanguage:l,isApproved:x,refreshTodos:t.refreshTodos,children:e.jsx(Fn,{...t,isApproved:x,isRejected:m,isReview:w,isPool:C,isApprovedNoMission:S,chatDisabled:v})})}function Fn({profile:t,validationId:n,activeCampaign:s,campaigns:l,programmes:d,invitations:k,scope:y,setScope:p,todos:x,todosCampaignId:m,isApproved:w,isRejected:C,isReview:S,isPool:v,isApprovedNoMission:o,chatDisabled:D}){const B=Ee(),{t:u}=ee(),{chatMode:q}=We(),I=y?.kind==="programme"?d.find(N=>N.membership_id===y.membershipId)??null:null,M=I&&I.membership_status==="approved"?{membershipId:I.membership_id,programmeName:I.incentive_name||I.name}:null,r=!y&&k.length>0?k[0]:null,_=s&&w&&m===s.campaign_id?ht(x,{approved:w,briefViewed:pt(s.campaign_id),programmeMission:!!s.programme_id,deliverableCount:s.deliverable_count,sendsProduct:s.product_seeding!==!1}):null,$=_?.steps.find(N=>!N.done&&pe[N.id])??null,H=s?it(n,s.campaign_id):null,O=C?null:M?e.jsx(Me,{prefix:u("home.nextStep"),nextLabel:u("home.card.signAgreement"),countLabel:u("home.stepCount").replace("{n}","0").replace("{m}","4"),percent:0,steps:[{id:"sign",label:u("home.card.signAgreement"),done:!1,current:!0,onOpen:()=>B(`/creator/${n}/programme?p=${M.membershipId}`)},{id:"order",label:u("campaign.stepOrderBox"),done:!1,current:!1},{id:"brief",label:u("campaign.stepGetBriefed"),done:!1,current:!1},{id:"content",label:u("campaign.stepSubmitContent"),done:!1,current:!1}]}):_&&$&&H?e.jsx(Me,{prefix:u("home.nextStep"),nextLabel:u($.key),countLabel:u("home.stepCount").replace("{n}",String(_.completed)).replace("{m}",String(_.total)),percent:_.percent,steps:_.steps.map((N,f)=>({id:N.id,label:u(N.key),done:N.done,current:f===_.currentIdx,onOpen:pe[N.id]?()=>B(`${H}/${pe[N.id]}`):void 0}))}):null;return e.jsxs("div",{className:a.page,"data-surface":"creator","data-chat-mode":q,children:[e.jsx("span",{className:`${a.aura} ${a.auraViolet}`}),!C&&e.jsx("div",{className:a.selectorSlot,children:e.jsx(Pt,{programmes:d,campaigns:l,invitations:k,scope:y,onSelect:p,onReviewInvitation:N=>B(`/creator/${n}/programme?invite=${N.token}`),attachment:O})}),e.jsx(Wn,{disabled:D,isApproved:w,banners:e.jsxs(e.Fragment,{children:[r&&e.jsxs("div",{className:a.statusBanner,"data-status":"invited",children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",width:"20",height:"20",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),e.jsxs("div",{children:[e.jsx("strong",{children:u("home.invitedTitle").replace("{brand}",r.brand_name||r.name)}),e.jsx("p",{style:{margin:"4px 0 0",opacity:.85},children:u("home.invitedBody")}),e.jsx("button",{type:"button",className:a.invitedCta,onClick:()=>B(`/creator/${n}/programme?invite=${r.token}`),children:u("programmes.review")})]})]}),o&&!r&&e.jsxs("div",{className:a.statusBanner,"data-status":"no-mission",children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",width:"20",height:"20",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 8v4l3 2"})]}),e.jsxs("div",{children:[e.jsx("strong",{children:u("home.noMissionTitle")}),e.jsx("p",{style:{margin:"4px 0 0",opacity:.85},children:u("home.noMissionBody")})]})]}),S&&!r&&e.jsxs("div",{className:a.statusBanner,"data-status":"review",children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",width:"20",height:"20",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12,6 12,12 16,14"})]}),e.jsxs("div",{children:[e.jsx("strong",{children:u(v?"home.poolTitle":"home.reviewTitle")}),e.jsx("p",{style:{margin:"4px 0 0",opacity:.85},children:u(v?"home.poolBody":"home.reviewBody")})]})]}),C&&e.jsxs("div",{className:a.statusBanner,"data-status":"rejected",children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",width:"20",height:"20",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e.jsxs("div",{children:[e.jsx("strong",{children:u("home.rejectedTitle")}),e.jsx("p",{style:{margin:"4px 0 0",opacity:.85},children:u("home.rejectedBody")})]})]})]}),userInitials:((t.first_name?.charAt(0)??"")+(t.last_name?.charAt(0)??"")||"U").toUpperCase()})]})}export{ta as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.