@_solaris/messenger-widget 0.5.47 → 0.5.49

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.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),Ze=["connected","message","message_stream","conversation_updated","config_updated","action_status"],ce="/client",et=5*60*1e3,tt=10*60*1e3,nt=5*60*1e3;function ke(t){const n={baseUrl:rt(t.baseUrl||""),widgetId:t.widgetId||"",userId:"",origin:"",token:"",currentContext:{},listeners:new Map,eventSource:null,connection:"idle",visibilityHandler:null,started:!1,panelOpen:!1,pollTimer:null,burstTimer:null,hiddenGraceTimer:null,lastActivityAt:null};if(!n.baseUrl||!n.widgetId)throw new Error("[transport] baseUrl and widgetId are required");function r(c,h){return n.listeners.has(c)||n.listeners.set(c,new Set),n.listeners.get(c).add(h),()=>n.listeners.get(c).delete(h)}function s(c,h){const p=n.listeners.get(c);p&&p.forEach(w=>{try{w(h)}catch(B){console.error("[transport] listener",c,B)}})}function a(c){n.connection!==c&&(n.connection=c,s("connection",c))}function o(){return{"Content-Type":"application/json","X-Widget-Id":n.widgetId,...n.origin?{"X-Parent-Origin":n.origin}:{}}}async function i(c,h,p){const w=await fetch(`${n.baseUrl}${ce}${h}`,{method:c,credentials:"include",headers:o(),body:p!==void 0?JSON.stringify(p):void 0});if(!w.ok){const B=await l(w),E=new Error(`HTTP ${w.status} ${c} ${h} :: ${(B==null?void 0:B.error)||w.statusText}`);throw E.status=w.status,E.body=B,E}return w.status===204?null:w.json()}async function l(c){try{return await c.json()}catch{return null}}async function f(c){if(n.started)return n.lastBootstrap;if(!(c!=null&&c.origin))throw new Error("[transport] start requires origin");n.started=!0,n.origin=c.origin,n.token=c.token||"";const h=await fetch(`${n.baseUrl}${ce}/session`,{method:"POST",credentials:"include",headers:o(),body:JSON.stringify({origin:n.origin,...n.token?{token:n.token}:{},allowUnauthenticated:c.allowUnauthenticated===!0,...c.variables&&typeof c.variables=="object"?{variables:c.variables}:{}})});if(!h.ok){const O=await l(h),z=new Error(`Session bootstrap failed: HTTP ${h.status} :: ${(O==null?void 0:O.error)||h.statusText}`);throw z.status=h.status,z.body=O,z}const p=await h.json();n.userId=p.external_id;const[w,B]=await Promise.all([fetch(`${n.baseUrl}/widgets/${encodeURIComponent(n.widgetId)}/config`,{credentials:"include"}).then(async O=>{if(!O.ok){const z=await l(O);throw new Error(`HTTP ${O.status} GET /widgets/:id/config :: ${(z==null?void 0:z.error)||O.statusText}`)}return O.json()}),i("GET","/customers/me")]),E={config:w,customer:(B==null?void 0:B.customer)??null};return n.lastBootstrap=E,await y(),typeof document<"u"&&(n.visibilityHandler=u,document.addEventListener("visibilitychange",n.visibilityHandler)),ee(),E}async function y(){try{const c=await N();n.lastActivityAt=c.reduce((h,p)=>{const w=p==null?void 0:p.last_message_at;return w&&(!h||w>h)?w:h},null)}catch(c){console.error("[transport] initial /conversations failed",c)}}async function _(){const c=await i("GET","/customers/me");return(c==null?void 0:c.customer)??null}async function C(c){const h=await i("PATCH","/customers/me",c);return(h==null?void 0:h.customer)??null}async function N(){const c=await i("GET","/conversations");return(c==null?void 0:c.conversations)??[]}async function k(c={}){return(await i("POST","/conversations",c)).conversation}async function L(c){return(await i("GET",`/conversations/${encodeURIComponent(c)}`)).conversation}async function b(c,h){return(await i("PATCH",`/conversations/${encodeURIComponent(c)}`,h)).conversation}async function V(c,h){return i("PATCH",`/conversations/${encodeURIComponent(c)}/read`,{message_id:h})}async function M(c,h={}){const p=new URLSearchParams;h.before&&p.set("before",h.before),h.since&&p.set("since",h.since),h.limit&&p.set("limit",String(h.limit));const w=p.toString()?`?${p.toString()}`:"";return i("GET",`/conversations/${encodeURIComponent(c)}/messages${w}`)}async function A(c,h){W();const p={client_msg_id:h.client_msg_id,type:"content",text_md:h.text_md,author:{id:n.userId,type:"user"},created_at:h.created_at||new Date().toISOString()};return Array.isArray(h.attachments)&&h.attachments.length&&(p.payload={type:"content",attachments:h.attachments}),h.metadata&&typeof h.metadata=="object"&&(p.metadata=h.metadata),n.currentContext&&Object.keys(n.currentContext).length>0&&(p.context=n.currentContext),i("POST",`/conversations/${encodeURIComponent(c)}/messages`,p)}async function D(c,h,p){return W(),i("POST",`/messages/${encodeURIComponent(c)}/callbacks/${encodeURIComponent(h)}`,p?{inputs:p}:{})}async function U(c){const h=c.name||"attachment",p=c.type||"application/octet-stream",w=c.size||0,B=await i("POST","/attachments",{mime_type:p,size_bytes:w,name:h}),E=await fetch(B.upload_url,{method:"PUT",headers:{"Content-Type":p},body:c});if(!E.ok)throw new Error(`HTTP ${E.status} PUT signed upload`);return{type:ot(p),path:B.path,mime_type:p,size_bytes:w}}async function q(c){return i("GET",`/attachments/sign?path=${encodeURIComponent(c)}`)}function K(){const c=new URLSearchParams({widgetId:n.widgetId}).toString();return`${n.baseUrl}${ce}/stream?${c}`}function I(){if(!n.eventSource&&!(typeof document<"u"&&document.hidden)&&n.started)try{const c=new EventSource(K(),{withCredentials:!0});for(const h of Ze)c.addEventListener(h,p=>$(h,p.data));c.addEventListener("error",()=>s("error",new Error("SSE error"))),n.eventSource=c,a("open")}catch(c){console.error("[transport] SSE open failed",c),s("error",c)}}function $(c,h){try{const p=JSON.parse(h),w=p&&typeof p=="object"&&"data"in p?p.data:p;s(c,w)}catch(p){console.error("[transport] bad SSE payload",c,p)}}function F(){n.eventSource&&(n.eventSource.close(),n.eventSource=null),n.connection!=="paused"&&a("idle")}function W(){clearTimeout(n.burstTimer),I(),n.panelOpen||(n.burstTimer=setTimeout(()=>{n.panelOpen||F()},tt))}function Z(c){n.panelOpen=!!c,n.panelOpen?(clearTimeout(n.burstTimer),I()):W()}async function le(){try{const c=await N(),h=c.reduce((w,B)=>{const E=B==null?void 0:B.last_message_at;return E&&(!w||E>w)?E:w},null);h&&(!n.lastActivityAt||h>n.lastActivityAt)&&(n.lastActivityAt=h,s("activity",{conversations:c,latestAt:h}),W())}catch(c){console.error("[transport] poll failed",c)}}function ee(){d(),!(typeof document<"u"&&document.hidden)&&(n.pollTimer=setInterval(le,et))}function d(){n.pollTimer&&(clearInterval(n.pollTimer),n.pollTimer=null)}function u(){if(document.hidden)clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=setTimeout(()=>{n.hiddenGraceTimer=null,document.hidden&&(d(),F(),a("paused"))},nt);else{if(n.hiddenGraceTimer){clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=null;return}a("idle"),ee(),n.panelOpen&&I()}}function m(){d(),clearTimeout(n.burstTimer),clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=null,F(),n.visibilityHandler&&(document.removeEventListener("visibilitychange",n.visibilityHandler),n.visibilityHandler=null),n.started=!1}async function g(c){return!c||typeof c!="object"?null:i("POST","/update",c)}function v(c){if(!(!c||typeof c!="object"))for(const[h,p]of Object.entries(c)){if(p===null){delete n.currentContext[h];continue}typeof p=="object"&&!Array.isArray(p)&&(n.currentContext[h]={...p})}}return{on:r,start:f,stop:m,setPanelOpen:Z,update:g,context:v,getCustomer:_,patchCustomer:C,listConversations:N,createConversation:k,getConversation:L,patchConversation:b,markConversationRead:V,listMessages:M,postMessage:A,postCallback:D,uploadAttachment:U,signAttachment:q,get connection(){return n.connection}}}function rt(t){return t.endsWith("/")?t.slice(0,-1):t}function ot(t){return t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":"file"}function ue(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();const t=new Uint8Array(16);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(t);else for(let r=0;r<16;r++)t[r]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;const n=[...t].map(r=>r.toString(16).padStart(2,"0"));return n.slice(0,4).join("")+"-"+n.slice(4,6).join("")+"-"+n.slice(6,8).join("")+"-"+n.slice(8,10).join("")+"-"+n.slice(10,16).join("")}function we(t){const n=e.reactive({ready:!1,error:null,config:null,customer:null,conversations:[],messagesByConv:{},paginationByConv:{},streamingByMsgId:{},awaitingCallback:{},runningActionsByConv:{},connection:"idle"}),r=[];r.push(t.on("connection",d=>{n.connection=d})),r.push(t.on("message",d=>{const u=d==null?void 0:d.conversation_id,m=d==null?void 0:d.message;!u||!(m!=null&&m.id)||(I(u,m),m.client_msg_id&&delete n.streamingByMsgId[m.client_msg_id],W(u,m.created_at))})),r.push(t.on("message_stream",d=>{const u=d==null?void 0:d.message_id,m=d==null?void 0:d.token;!u||typeof m!="string"||(n.streamingByMsgId[u]=(n.streamingByMsgId[u]||"")+m)})),r.push(t.on("conversation_updated",d=>{const u=d==null?void 0:d.conversation_id,m=d==null?void 0:d.changes;if(!u||!m)return;const g=n.conversations.findIndex(v=>v.id===u);g!==-1&&(n.conversations[g]={...n.conversations[g],...m})})),r.push(t.on("config_updated",d=>{d!=null&&d.config&&(n.config=d.config)})),r.push(t.on("action_status",d=>{const u=d==null?void 0:d.conversation_id,m=d==null?void 0:d.action_id,g=d==null?void 0:d.action_name;if(!u||!m)return;const v=n.runningActionsByConv[u]||{};d.state==="running"?(v[m]=g||m,n.runningActionsByConv[u]={...v}):d.state==="done"&&(delete v[m],n.runningActionsByConv[u]={...v})})),r.push(t.on("activity",d=>{Array.isArray(d==null?void 0:d.conversations)&&(n.conversations=d.conversations)}));async function s(d){try{const u=new Promise((g,v)=>setTimeout(()=>v(new Error("bootstrap timeout (15s) — check baseUrl, CORS, and network")),15e3)),m=await Promise.race([t.start(d),u]);n.config=m.config,n.customer=m.customer,n.conversations=await Promise.race([t.listConversations(),u]),n.ready=!0}catch(u){console.error("[store] start failed",u),n.error=(u==null?void 0:u.message)||String(u)}}function a(){for(const d of r)try{d()}catch{}t.stop()}async function o(d){const u=le(d);if(!u)return n.customer;try{const m=await t.patchCustomer(u);m&&(n.customer=m)}catch(m){console.error("[store] applyCustomer failed",m)}return n.customer}async function i(d={}){const u=await t.createConversation(d),m=n.conversations.findIndex(g=>g.id===u.id);return m===-1?n.conversations=[u,...n.conversations]:n.conversations[m]=u,u}const l=50;async function f(d){const u=n.paginationByConv[d];if(!(u!=null&&u.loaded||u!=null&&u.loading)){_(d,{nextCursor:null,loading:!0,loaded:!1});try{const m=await t.listMessages(d,{limit:l}),g=(m==null?void 0:m.messages)??[],v=n.messagesByConv[d]||[],c=new Set;for(const p of g)(p==null?void 0:p.id)!=null&&c.add(`id:${String(p.id)}`),p!=null&&p.client_msg_id&&c.add(`c:${p.client_msg_id}`);const h=v.filter(p=>!((p==null?void 0:p.id)!=null&&c.has(`id:${String(p.id)}`)||p!=null&&p.client_msg_id&&c.has(`c:${p.client_msg_id}`)));n.messagesByConv[d]=[...g,...h].sort(Z),_(d,{nextCursor:(m==null?void 0:m.next_cursor)??null,loading:!1,loaded:!0})}catch(m){console.error("[store] openConversation failed",m),_(d,{nextCursor:null,loading:!1,loaded:!1})}}}async function y(d){var v;const u=n.paginationByConv[d];if(!u||u.loading||!u.nextCursor)return;const g=(v=(n.messagesByConv[d]||[]).find(c=>c==null?void 0:c.created_at))==null?void 0:v.created_at;if(g){_(d,{...u,loading:!0});try{const c=await t.listMessages(d,{before:g,limit:l}),h=(c==null?void 0:c.messages)??[],p=n.messagesByConv[d]||[],w=new Set;for(const E of p)(E==null?void 0:E.id)!=null&&w.add(`id:${String(E.id)}`),E!=null&&E.client_msg_id&&w.add(`c:${E.client_msg_id}`);const B=h.filter(E=>!((E==null?void 0:E.id)!=null&&w.has(`id:${String(E.id)}`)||E!=null&&E.client_msg_id&&w.has(`c:${E.client_msg_id}`)));n.messagesByConv[d]=[...B,...p],_(d,{nextCursor:(c==null?void 0:c.next_cursor)??null,loading:!1,loaded:!0})}catch(c){console.error("[store] loadMore failed",c),_(d,{...u,loading:!1})}}}function _(d,u){n.paginationByConv={...n.paginationByConv,[d]:u}}async function C(d,u){const m=await t.patchConversation(d,u),g=n.conversations.findIndex(v=>v.id===d);g!==-1&&(n.conversations[g]=m)}async function N(d){if(!d)return[];const u=n.messagesByConv[d]||[];let m="";for(const g of u)g!=null&&g.created_at&&g.created_at>m&&(m=g.created_at);try{const g=await t.listMessages(d,m?{since:m}:{}),v=(g==null?void 0:g.messages)||[];if(!v.length)return[];const c=new Set,h=new Set;for(const w of u)(w==null?void 0:w.id)!=null&&c.add(String(w.id)),w!=null&&w.client_msg_id&&h.add(w.client_msg_id);const p=[];for(const w of v){const B=(w==null?void 0:w.id)!=null&&c.has(String(w.id))||(w==null?void 0:w.client_msg_id)&&h.has(w.client_msg_id);I(d,w),B||p.push(w)}return p}catch(g){return console.error("[store] fetchSinceLast failed",g),[]}}async function k(d,u){if(!(!d||u==null))try{const m=await t.markConversationRead(d,u),g=(m==null?void 0:m.last_read_message_id)??u,v=n.conversations.findIndex(c=>(c==null?void 0:c.id)===d);v!==-1&&(n.conversations[v]={...n.conversations[v],last_read_message_id:g})}catch(m){console.error("[store] markConversationRead failed",m)}}async function L(d,u,{attachments:m,metadata:g}={}){var B;const v=(u||"").trim(),c=Array.isArray(m)&&m.length>0;if(!d||!v&&!c)return;const h=ue(),p=ee(d),w={id:h,client_msg_id:h,conversation_id:d,type:"content",text_md:v,author:{type:"user",id:((B=n.customer)==null?void 0:B.external_id)||null},created_at:p,_pending:!0,...c?{payload:{type:"content",attachments:m}}:{},...g&&typeof g=="object"?{metadata:g}:{}};I(d,w);try{await t.postMessage(d,{client_msg_id:h,text_md:v,created_at:p,...c?{attachments:m}:{},...g&&typeof g=="object"?{metadata:g}:{}})}catch(E){console.error("[store] send failed",E),F(d,h,{_failed:!0,_pending:!1})}}async function b(d,u,m){d!=null&&(n.awaitingCallback[d]=!0);try{await t.postCallback(d,u,m)}catch(g){console.error("[store] callback failed",g),d!=null&&delete n.awaitingCallback[d]}}const V=new Map;async function M(d){if(!d)return null;const u=V.get(d);if(u!=null&&u.url){const m=u.expires_at?Date.parse(u.expires_at):0;if(!m||m-Date.now()>6e4)return u.url}try{const m=await t.signAttachment(d);if(m!=null&&m.signed_url)return V.set(d,{url:m.signed_url,expires_at:m.expires_at}),m.signed_url}catch(m){console.error("[store] sign attachment failed",m)}return null}async function A(d,{rating:u,comment:m}={}){const g=n.conversations.find(h=>h.id===d),c={...(g==null?void 0:g.metadata)||{},feedback:{rating:u,comment:m||null,submitted_at:new Date().toISOString()}};await C(d,{metadata:c})}function D(d){var m,g;const u=n.messagesByConv[d]||[];for(let v=u.length-1;v>=0;v--){const c=u[v];if((c==null?void 0:c.type)==="action"&&((m=c==null?void 0:c.payload)==null?void 0:m.type)==="action"&&((g=c==null?void 0:c.payload)==null?void 0:g.state)==="pending"&&Array.isArray(c==null?void 0:c.callbacks)&&c.callbacks.length>0&&!n.awaitingCallback[c.id])return c}return null}function U(d){var m,g,v;const u=n.messagesByConv[d]||[];for(let c=u.length-1;c>=0;c--){const h=u[c];if(((m=h==null?void 0:h.author)==null?void 0:m.type)==="user"||(h==null?void 0:h.type)==="action"&&((g=h==null?void 0:h.payload)==null?void 0:g.state)==="pending")return null;const p=(v=h==null?void 0:h.metadata)==null?void 0:v.form;if(p&&Array.isArray(p.fields)&&p.fields.length>0)return{message:h,form:p}}return null}function q(d){const u=n.runningActionsByConv[d];if(!u)return null;const m=Object.keys(u);if(m.length===0)return null;const g=m[0];return{id:g,payload:{name:u[g]}}}function K(d){var m,g,v,c;const u=n.messagesByConv[d]||[];for(let h=u.length-1;h>=0;h--){const p=u[h];if(((m=p==null?void 0:p.author)==null?void 0:m.type)==="user")return[];if((p==null?void 0:p.type)==="action"&&((g=p==null?void 0:p.payload)==null?void 0:g.state)==="pending")return[];if(((v=p==null?void 0:p.author)==null?void 0:v.type)!=="agent_ia")continue;const w=(c=p==null?void 0:p.metadata)==null?void 0:c.suggested_replies;return Array.isArray(w)&&w.length?w.map(B=>{if(typeof B=="string"){const E=B.trim();return E?{label:E,kind:null}:null}if(B&&typeof B=="object"&&typeof B.label=="string"){const E=B.label.trim();if(!E)return null;const O=B.kind==="cta"||B.kind==="choice"||B.kind==="followup"?B.kind:null;return{label:E,kind:O}}return null}).filter(Boolean).slice(0,4):[]}return[]}function I(d,u){var c;const m=n.messagesByConv[d]||[];let g=-1;u!=null&&u.client_msg_id&&(g=m.findIndex(h=>(h==null?void 0:h.client_msg_id)&&h.client_msg_id===u.client_msg_id)),g===-1&&(u==null?void 0:u.id)!==void 0&&(u==null?void 0:u.id)!==null&&(g=m.findIndex(h=>$(h==null?void 0:h.id,u.id)));let v;g===-1?v=[...m,u].sort(Z):(v=m.slice(),v[g]={...m[g],...u,_pending:!1,_failed:!1}),n.messagesByConv[d]=v,(u==null?void 0:u.type)==="action"&&((c=u==null?void 0:u.payload)!=null&&c.state)&&u.payload.state!=="pending"&&(u==null?void 0:u.id)!=null&&n.awaitingCallback[u.id]&&delete n.awaitingCallback[u.id]}function $(d,u){return d===u?!0:d==null||u==null?!1:String(d)===String(u)}function F(d,u,m){const g=n.messagesByConv[d];if(!g)return;const v=g.findIndex(h=>h.id===u);if(v===-1)return;const c=g.slice();c[v]={...g[v],...m},n.messagesByConv[d]=c}function W(d,u){const m=n.conversations.findIndex(v=>v.id===d);if(m===-1)return;const g=n.conversations[m];if(u&&(!g.last_message_at||u>g.last_message_at)){const v=n.conversations.slice();v[m]={...g,last_message_at:u},v.sort((c,h)=>(h.last_message_at||"").localeCompare(c.last_message_at||"")),n.conversations=v}}function Z(d,u){return(d.created_at||"").localeCompare(u.created_at||"")}function le(d){if(!d||typeof d!="object")return null;const u={},m={};for(const[g,v]of Object.entries(d))v!==void 0&&(g==="name"||g==="email"||g==="language"?v!=null&&String(v).trim()!==""&&(u[g]=v):(g==="values"||g==="metadata")&&v&&typeof v=="object"?Object.assign(m,v):m[g]=v);return Object.keys(m).length&&(u.values=m),Object.keys(u).length?u:null}function ee(d){const u=n.messagesByConv[d]||[];let m="";for(const c of u)c!=null&&c.created_at&&c.created_at>m&&(m=c.created_at);const g=new Date().toISOString();return!m||g>m?g:new Date(Date.parse(m)+1).toISOString()}return{state:n,start:s,destroy:a,applyCustomer:o,createConversation:i,openConversation:f,loadMore:y,fetchSinceLast:N,patchConversation:C,markConversationRead:k,send:L,clickCallback:b,signAttachment:M,submitFeedback:A,getPendingApproval:D,getActionInFlight:q,getLatestSuggestions:K,getLatestForm:U,setPanelOpen:t.setPanelOpen}}const x={w:"#ffffff",g50:"#F9F9F7",g100:"#F2F1EE",g150:"#E8E6E2",g200:"#D9D6CF",g300:"#B4B0A8",g400:"#888480",g500:"#5A5753",g700:"#2B2926",g900:"#17161A",accent:"#5B5FEF",accentLight:"#EEEFFE",green:"#22C55E",red:"#B91C1C",redBg:"#FDECEC"},te=["#5B5FEF","#7C3AED","#DB2777","#0891B2","#D97706","#059669"];function oe(t=""){return t?te[t.charCodeAt(0)%te.length]:te[0]}function ae(t=""){return t.split(" ").map(n=>n[0]||"").join("").toUpperCase().slice(0,2)}function re(t=new Date,n="fr-FR"){return t.toLocaleTimeString(n,{hour:"2-digit",minute:"2-digit"})}const be=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),Qe=["connected","message","message_stream","conversation_updated","config_updated","action_status"],ce="/client",Ze=5*60*1e3,et=10*60*1e3,tt=5*60*1e3;function ve(t){const n={baseUrl:nt(t.baseUrl||""),widgetId:t.widgetId||"",userId:"",origin:"",token:"",currentContext:{},listeners:new Map,eventSource:null,connection:"idle",visibilityHandler:null,started:!1,panelOpen:!1,pollTimer:null,burstTimer:null,hiddenGraceTimer:null,lastActivityAt:null};if(!n.baseUrl||!n.widgetId)throw new Error("[transport] baseUrl and widgetId are required");function r(c,h){return n.listeners.has(c)||n.listeners.set(c,new Set),n.listeners.get(c).add(h),()=>n.listeners.get(c).delete(h)}function a(c,h){const p=n.listeners.get(c);p&&p.forEach(w=>{try{w(h)}catch(B){console.error("[transport] listener",c,B)}})}function s(c){n.connection!==c&&(n.connection=c,a("connection",c))}function o(){return{"Content-Type":"application/json","X-Widget-Id":n.widgetId,...n.origin?{"X-Parent-Origin":n.origin}:{}}}async function i(c,h,p){const w=await fetch(`${n.baseUrl}${ce}${h}`,{method:c,credentials:"include",headers:o(),body:p!==void 0?JSON.stringify(p):void 0});if(!w.ok){const B=await l(w),E=new Error(`HTTP ${w.status} ${c} ${h} :: ${(B==null?void 0:B.error)||w.statusText}`);throw E.status=w.status,E.body=B,E}return w.status===204?null:w.json()}async function l(c){try{return await c.json()}catch{return null}}async function f(c){if(n.started)return n.lastBootstrap;if(!(c!=null&&c.origin))throw new Error("[transport] start requires origin");n.started=!0,n.origin=c.origin,n.token=c.token||"";const h=await fetch(`${n.baseUrl}${ce}/session`,{method:"POST",credentials:"include",headers:o(),body:JSON.stringify({origin:n.origin,...n.token?{token:n.token}:{},allowUnauthenticated:c.allowUnauthenticated===!0,...c.variables&&typeof c.variables=="object"?{variables:c.variables}:{}})});if(!h.ok){const L=await l(h),U=new Error(`Session bootstrap failed: HTTP ${h.status} :: ${(L==null?void 0:L.error)||h.statusText}`);throw U.status=h.status,U.body=L,U}const p=await h.json();n.userId=p.external_id;const[w,B]=await Promise.all([fetch(`${n.baseUrl}/widgets/${encodeURIComponent(n.widgetId)}/config`,{credentials:"include"}).then(async L=>{if(!L.ok){const U=await l(L);throw new Error(`HTTP ${L.status} GET /widgets/:id/config :: ${(U==null?void 0:U.error)||L.statusText}`)}return L.json()}),i("GET","/customers/me")]),E={config:w,customer:(B==null?void 0:B.customer)??null};return n.lastBootstrap=E,await y(),typeof document<"u"&&(n.visibilityHandler=u,document.addEventListener("visibilitychange",n.visibilityHandler)),Z(),E}async function y(){try{const c=await N();n.lastActivityAt=c.reduce((h,p)=>{const w=p==null?void 0:p.last_message_at;return w&&(!h||w>h)?w:h},null)}catch(c){console.error("[transport] initial /conversations failed",c)}}async function _(){const c=await i("GET","/customers/me");return(c==null?void 0:c.customer)??null}async function C(c){const h=await i("PATCH","/customers/me",c);return(h==null?void 0:h.customer)??null}async function N(){const c=await i("GET","/conversations");return(c==null?void 0:c.conversations)??[]}async function k(c={}){return(await i("POST","/conversations",c)).conversation}async function O(c){return(await i("GET",`/conversations/${encodeURIComponent(c)}`)).conversation}async function b(c,h){return(await i("PATCH",`/conversations/${encodeURIComponent(c)}`,h)).conversation}async function V(c,h){return i("PATCH",`/conversations/${encodeURIComponent(c)}/read`,{message_id:h})}async function M(c,h={}){const p=new URLSearchParams;h.before&&p.set("before",h.before),h.since&&p.set("since",h.since),h.limit&&p.set("limit",String(h.limit));const w=p.toString()?`?${p.toString()}`:"";return i("GET",`/conversations/${encodeURIComponent(c)}/messages${w}`)}async function A(c,h){W();const p={client_msg_id:h.client_msg_id,type:"content",text_md:h.text_md,author:{id:n.userId,type:"user"},created_at:h.created_at||new Date().toISOString()};return Array.isArray(h.attachments)&&h.attachments.length&&(p.payload={type:"content",attachments:h.attachments}),h.metadata&&typeof h.metadata=="object"&&(p.metadata=h.metadata),n.currentContext&&Object.keys(n.currentContext).length>0&&(p.context=n.currentContext),i("POST",`/conversations/${encodeURIComponent(c)}/messages`,p)}async function D(c,h,p){return W(),i("POST",`/messages/${encodeURIComponent(c)}/callbacks/${encodeURIComponent(h)}`,p?{inputs:p}:{})}async function P(c){const h=c.name||"attachment",p=c.type||"application/octet-stream",w=c.size||0,B=await i("POST","/attachments",{mime_type:p,size_bytes:w,name:h}),E=await fetch(B.upload_url,{method:"PUT",headers:{"Content-Type":p},body:c});if(!E.ok)throw new Error(`HTTP ${E.status} PUT signed upload`);return{type:rt(p),path:B.path,mime_type:p,size_bytes:w}}async function $(c){return i("GET",`/attachments/sign?path=${encodeURIComponent(c)}`)}function q(){const c=new URLSearchParams({widgetId:n.widgetId}).toString();return`${n.baseUrl}${ce}/stream?${c}`}function I(){if(!n.eventSource&&!(typeof document<"u"&&document.hidden)&&n.started)try{const c=new EventSource(q(),{withCredentials:!0});for(const h of Qe)c.addEventListener(h,p=>K(h,p.data));c.addEventListener("error",()=>a("error",new Error("SSE error"))),n.eventSource=c,s("open")}catch(c){console.error("[transport] SSE open failed",c),a("error",c)}}function K(c,h){try{const p=JSON.parse(h),w=p&&typeof p=="object"&&"data"in p?p.data:p;a(c,w)}catch(p){console.error("[transport] bad SSE payload",c,p)}}function F(){n.eventSource&&(n.eventSource.close(),n.eventSource=null),n.connection!=="paused"&&s("idle")}function W(){clearTimeout(n.burstTimer),I(),n.panelOpen||(n.burstTimer=setTimeout(()=>{n.panelOpen||F()},et))}function Q(c){n.panelOpen=!!c,n.panelOpen?(clearTimeout(n.burstTimer),I()):W()}async function le(){try{const c=await N(),h=c.reduce((w,B)=>{const E=B==null?void 0:B.last_message_at;return E&&(!w||E>w)?E:w},null);h&&(!n.lastActivityAt||h>n.lastActivityAt)&&(n.lastActivityAt=h,a("activity",{conversations:c,latestAt:h}),W())}catch(c){console.error("[transport] poll failed",c)}}function Z(){d(),!(typeof document<"u"&&document.hidden)&&(n.pollTimer=setInterval(le,Ze))}function d(){n.pollTimer&&(clearInterval(n.pollTimer),n.pollTimer=null)}function u(){if(document.hidden)clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=setTimeout(()=>{n.hiddenGraceTimer=null,document.hidden&&(d(),F(),s("paused"))},tt);else{if(n.hiddenGraceTimer){clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=null;return}s("idle"),Z(),n.panelOpen&&I()}}function m(){d(),clearTimeout(n.burstTimer),clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=null,F(),n.visibilityHandler&&(document.removeEventListener("visibilitychange",n.visibilityHandler),n.visibilityHandler=null),n.started=!1}async function g(c){return!c||typeof c!="object"?null:i("POST","/update",c)}function v(c){if(!(!c||typeof c!="object"))for(const[h,p]of Object.entries(c)){if(p===null){delete n.currentContext[h];continue}typeof p=="object"&&!Array.isArray(p)&&(n.currentContext[h]={...p})}}return{on:r,start:f,stop:m,setPanelOpen:Q,update:g,context:v,getCustomer:_,patchCustomer:C,listConversations:N,createConversation:k,getConversation:O,patchConversation:b,markConversationRead:V,listMessages:M,postMessage:A,postCallback:D,uploadAttachment:P,signAttachment:$,get connection(){return n.connection}}}function nt(t){return t.endsWith("/")?t.slice(0,-1):t}function rt(t){return t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":"file"}function ue(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();const t=new Uint8Array(16);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(t);else for(let r=0;r<16;r++)t[r]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;const n=[...t].map(r=>r.toString(16).padStart(2,"0"));return n.slice(0,4).join("")+"-"+n.slice(4,6).join("")+"-"+n.slice(6,8).join("")+"-"+n.slice(8,10).join("")+"-"+n.slice(10,16).join("")}function ke(t){const n=e.reactive({ready:!1,error:null,config:null,customer:null,conversations:[],messagesByConv:{},paginationByConv:{},streamingByMsgId:{},awaitingCallback:{},runningActionsByConv:{},connection:"idle"}),r=[];r.push(t.on("connection",d=>{n.connection=d})),r.push(t.on("message",d=>{const u=d==null?void 0:d.conversation_id,m=d==null?void 0:d.message;!u||!(m!=null&&m.id)||(I(u,m),m.client_msg_id&&delete n.streamingByMsgId[m.client_msg_id],W(u,m.created_at))})),r.push(t.on("message_stream",d=>{const u=d==null?void 0:d.message_id,m=d==null?void 0:d.token;!u||typeof m!="string"||(n.streamingByMsgId[u]=(n.streamingByMsgId[u]||"")+m)})),r.push(t.on("conversation_updated",d=>{const u=d==null?void 0:d.conversation_id,m=d==null?void 0:d.changes;if(!u||!m)return;const g=n.conversations.findIndex(v=>v.id===u);g!==-1&&(n.conversations[g]={...n.conversations[g],...m})})),r.push(t.on("config_updated",d=>{d!=null&&d.config&&(n.config=d.config)})),r.push(t.on("action_status",d=>{const u=d==null?void 0:d.conversation_id,m=d==null?void 0:d.action_id,g=d==null?void 0:d.action_name;if(!u||!m)return;const v=n.runningActionsByConv[u]||{};d.state==="running"?(v[m]=g||m,n.runningActionsByConv[u]={...v}):d.state==="done"&&(delete v[m],n.runningActionsByConv[u]={...v})})),r.push(t.on("activity",d=>{Array.isArray(d==null?void 0:d.conversations)&&(n.conversations=d.conversations)}));async function a(d){try{const u=new Promise((g,v)=>setTimeout(()=>v(new Error("bootstrap timeout (15s) — check baseUrl, CORS, and network")),15e3)),m=await Promise.race([t.start(d),u]);n.config=m.config,n.customer=m.customer,n.conversations=await Promise.race([t.listConversations(),u]),n.ready=!0}catch(u){console.error("[store] start failed",u),n.error=(u==null?void 0:u.message)||String(u)}}function s(){for(const d of r)try{d()}catch{}t.stop()}async function o(d){const u=le(d);if(!u)return n.customer;try{const m=await t.patchCustomer(u);m&&(n.customer=m)}catch(m){console.error("[store] applyCustomer failed",m)}return n.customer}async function i(d={}){const u=await t.createConversation(d),m=n.conversations.findIndex(g=>g.id===u.id);return m===-1?n.conversations=[u,...n.conversations]:n.conversations[m]=u,u}const l=50;async function f(d){const u=n.paginationByConv[d];if(!(u!=null&&u.loaded||u!=null&&u.loading)){_(d,{nextCursor:null,loading:!0,loaded:!1});try{const m=await t.listMessages(d,{limit:l}),g=(m==null?void 0:m.messages)??[],v=n.messagesByConv[d]||[],c=new Set;for(const p of g)(p==null?void 0:p.id)!=null&&c.add(`id:${String(p.id)}`),p!=null&&p.client_msg_id&&c.add(`c:${p.client_msg_id}`);const h=v.filter(p=>!((p==null?void 0:p.id)!=null&&c.has(`id:${String(p.id)}`)||p!=null&&p.client_msg_id&&c.has(`c:${p.client_msg_id}`)));n.messagesByConv[d]=[...g,...h].sort(Q),_(d,{nextCursor:(m==null?void 0:m.next_cursor)??null,loading:!1,loaded:!0})}catch(m){console.error("[store] openConversation failed",m),_(d,{nextCursor:null,loading:!1,loaded:!1})}}}async function y(d){var v;const u=n.paginationByConv[d];if(!u||u.loading||!u.nextCursor)return;const g=(v=(n.messagesByConv[d]||[]).find(c=>c==null?void 0:c.created_at))==null?void 0:v.created_at;if(g){_(d,{...u,loading:!0});try{const c=await t.listMessages(d,{before:g,limit:l}),h=(c==null?void 0:c.messages)??[],p=n.messagesByConv[d]||[],w=new Set;for(const E of p)(E==null?void 0:E.id)!=null&&w.add(`id:${String(E.id)}`),E!=null&&E.client_msg_id&&w.add(`c:${E.client_msg_id}`);const B=h.filter(E=>!((E==null?void 0:E.id)!=null&&w.has(`id:${String(E.id)}`)||E!=null&&E.client_msg_id&&w.has(`c:${E.client_msg_id}`)));n.messagesByConv[d]=[...B,...p],_(d,{nextCursor:(c==null?void 0:c.next_cursor)??null,loading:!1,loaded:!0})}catch(c){console.error("[store] loadMore failed",c),_(d,{...u,loading:!1})}}}function _(d,u){n.paginationByConv={...n.paginationByConv,[d]:u}}async function C(d,u){const m=await t.patchConversation(d,u),g=n.conversations.findIndex(v=>v.id===d);g!==-1&&(n.conversations[g]=m)}async function N(d){if(!d)return[];const u=n.messagesByConv[d]||[];let m="";for(const g of u)g!=null&&g.created_at&&g.created_at>m&&(m=g.created_at);try{const g=await t.listMessages(d,m?{since:m}:{}),v=(g==null?void 0:g.messages)||[];if(!v.length)return[];const c=new Set,h=new Set;for(const w of u)(w==null?void 0:w.id)!=null&&c.add(String(w.id)),w!=null&&w.client_msg_id&&h.add(w.client_msg_id);const p=[];for(const w of v){const B=(w==null?void 0:w.id)!=null&&c.has(String(w.id))||(w==null?void 0:w.client_msg_id)&&h.has(w.client_msg_id);I(d,w),B||p.push(w)}return p}catch(g){return console.error("[store] fetchSinceLast failed",g),[]}}async function k(d,u){if(!(!d||u==null))try{const m=await t.markConversationRead(d,u),g=(m==null?void 0:m.last_read_message_id)??u,v=n.conversations.findIndex(c=>(c==null?void 0:c.id)===d);v!==-1&&(n.conversations[v]={...n.conversations[v],last_read_message_id:g})}catch(m){console.error("[store] markConversationRead failed",m)}}async function O(d,u,{attachments:m,metadata:g}={}){var B;const v=(u||"").trim(),c=Array.isArray(m)&&m.length>0;if(!d||!v&&!c)return;const h=ue(),p=Z(d),w={id:h,client_msg_id:h,conversation_id:d,type:"content",text_md:v,author:{type:"user",id:((B=n.customer)==null?void 0:B.external_id)||null},created_at:p,_pending:!0,...c?{payload:{type:"content",attachments:m}}:{},...g&&typeof g=="object"?{metadata:g}:{}};I(d,w);try{await t.postMessage(d,{client_msg_id:h,text_md:v,created_at:p,...c?{attachments:m}:{},...g&&typeof g=="object"?{metadata:g}:{}})}catch(E){console.error("[store] send failed",E),F(d,h,{_failed:!0,_pending:!1})}}async function b(d,u,m){d!=null&&(n.awaitingCallback[d]=!0);try{await t.postCallback(d,u,m)}catch(g){console.error("[store] callback failed",g),d!=null&&delete n.awaitingCallback[d]}}const V=new Map;async function M(d){if(!d)return null;const u=V.get(d);if(u!=null&&u.url){const m=u.expires_at?Date.parse(u.expires_at):0;if(!m||m-Date.now()>6e4)return u.url}try{const m=await t.signAttachment(d);if(m!=null&&m.signed_url)return V.set(d,{url:m.signed_url,expires_at:m.expires_at}),m.signed_url}catch(m){console.error("[store] sign attachment failed",m)}return null}async function A(d,{rating:u,comment:m}={}){const g=n.conversations.find(h=>h.id===d),c={...(g==null?void 0:g.metadata)||{},feedback:{rating:u,comment:m||null,submitted_at:new Date().toISOString()}};await C(d,{metadata:c})}function D(d){var m,g;const u=n.messagesByConv[d]||[];for(let v=u.length-1;v>=0;v--){const c=u[v];if((c==null?void 0:c.type)==="action"&&((m=c==null?void 0:c.payload)==null?void 0:m.type)==="action"&&((g=c==null?void 0:c.payload)==null?void 0:g.state)==="pending"&&Array.isArray(c==null?void 0:c.callbacks)&&c.callbacks.length>0&&!n.awaitingCallback[c.id])return c}return null}function P(d){var m,g,v;const u=n.messagesByConv[d]||[];for(let c=u.length-1;c>=0;c--){const h=u[c];if(((m=h==null?void 0:h.author)==null?void 0:m.type)==="user"||(h==null?void 0:h.type)==="action"&&((g=h==null?void 0:h.payload)==null?void 0:g.state)==="pending")return null;const p=(v=h==null?void 0:h.metadata)==null?void 0:v.form;if(p&&Array.isArray(p.fields)&&p.fields.length>0)return{message:h,form:p}}return null}function $(d){const u=n.runningActionsByConv[d];if(!u)return null;const m=Object.keys(u);if(m.length===0)return null;const g=m[0];return{id:g,payload:{name:u[g]}}}function q(d){var m,g,v,c;const u=n.messagesByConv[d]||[];for(let h=u.length-1;h>=0;h--){const p=u[h];if(((m=p==null?void 0:p.author)==null?void 0:m.type)==="user")return[];if((p==null?void 0:p.type)==="action"&&((g=p==null?void 0:p.payload)==null?void 0:g.state)==="pending")return[];if(((v=p==null?void 0:p.author)==null?void 0:v.type)!=="agent_ia")continue;const w=(c=p==null?void 0:p.metadata)==null?void 0:c.suggested_replies;return Array.isArray(w)&&w.length?w.map(B=>{if(typeof B=="string"){const E=B.trim();return E?{label:E,kind:null}:null}if(B&&typeof B=="object"&&typeof B.label=="string"){const E=B.label.trim();if(!E)return null;const L=B.kind==="cta"||B.kind==="choice"||B.kind==="followup"?B.kind:null;return{label:E,kind:L}}return null}).filter(Boolean).slice(0,4):[]}return[]}function I(d,u){var c;const m=n.messagesByConv[d]||[];let g=-1;u!=null&&u.client_msg_id&&(g=m.findIndex(h=>(h==null?void 0:h.client_msg_id)&&h.client_msg_id===u.client_msg_id)),g===-1&&(u==null?void 0:u.id)!==void 0&&(u==null?void 0:u.id)!==null&&(g=m.findIndex(h=>K(h==null?void 0:h.id,u.id)));let v;g===-1?v=[...m,u].sort(Q):(v=m.slice(),v[g]={...m[g],...u,_pending:!1,_failed:!1}),n.messagesByConv[d]=v,(u==null?void 0:u.type)==="action"&&((c=u==null?void 0:u.payload)!=null&&c.state)&&u.payload.state!=="pending"&&(u==null?void 0:u.id)!=null&&n.awaitingCallback[u.id]&&delete n.awaitingCallback[u.id]}function K(d,u){return d===u?!0:d==null||u==null?!1:String(d)===String(u)}function F(d,u,m){const g=n.messagesByConv[d];if(!g)return;const v=g.findIndex(h=>h.id===u);if(v===-1)return;const c=g.slice();c[v]={...g[v],...m},n.messagesByConv[d]=c}function W(d,u){const m=n.conversations.findIndex(v=>v.id===d);if(m===-1)return;const g=n.conversations[m];if(u&&(!g.last_message_at||u>g.last_message_at)){const v=n.conversations.slice();v[m]={...g,last_message_at:u},v.sort((c,h)=>(h.last_message_at||"").localeCompare(c.last_message_at||"")),n.conversations=v}}function Q(d,u){return(d.created_at||"").localeCompare(u.created_at||"")}function le(d){if(!d||typeof d!="object")return null;const u={},m={};for(const[g,v]of Object.entries(d))v!==void 0&&(g==="name"||g==="email"||g==="language"?v!=null&&String(v).trim()!==""&&(u[g]=v):(g==="values"||g==="metadata")&&v&&typeof v=="object"?Object.assign(m,v):m[g]=v);return Object.keys(m).length&&(u.values=m),Object.keys(u).length?u:null}function Z(d){const u=n.messagesByConv[d]||[];let m="";for(const c of u)c!=null&&c.created_at&&c.created_at>m&&(m=c.created_at);const g=new Date().toISOString();return!m||g>m?g:new Date(Date.parse(m)+1).toISOString()}return{state:n,start:a,destroy:s,applyCustomer:o,createConversation:i,openConversation:f,loadMore:y,fetchSinceLast:N,patchConversation:C,markConversationRead:k,send:O,clickCallback:b,signAttachment:M,submitFeedback:A,getPendingApproval:D,getActionInFlight:$,getLatestSuggestions:q,getLatestForm:P,setPanelOpen:t.setPanelOpen}}const x={w:"#ffffff",g50:"#F9F9F7",g100:"#F2F1EE",g150:"#E8E6E2",g200:"#D9D6CF",g300:"#B4B0A8",g400:"#888480",g500:"#5A5753",g700:"#2B2926",g900:"#17161A",accent:"#5B5FEF",accentLight:"#EEEFFE",green:"#22C55E",red:"#B91C1C",redBg:"#FDECEC"},ee=["#5B5FEF","#7C3AED","#DB2777","#0891B2","#D97706","#059669"];function re(t=""){return t?ee[t.charCodeAt(0)%ee.length]:ee[0]}function oe(t=""){return t.split(" ").map(n=>n[0]||"").join("").toUpperCase().slice(0,2)}function ne(t=new Date,n="fr-FR"){return t.toLocaleTimeString(n,{hour:"2-digit",minute:"2-digit"})}const we=`
2
2
  @import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500&display=swap');
3
3
 
4
4
  .wm-root {
@@ -45,14 +45,14 @@
45
45
  0% { transform: translateX(110%); opacity: 0; }
46
46
  100% { transform: translateX(0); opacity: 1; }
47
47
  }
48
- `,Ee="https://api.messenger.victorc.fr",at=/^[a-zA-Z]{3,32}$/,st=/^#[0-9a-fA-F]{3,8}$/,it=/^(rgb|rgba|hsl|hsla)\(\s*[\d.,%\s/]{1,60}\)$/;function Ce(t){return typeof t!="string"||!t||t.length>64?!1:st.test(t)||it.test(t)||at.test(t)}function lt(t){if(typeof t!="string"||!t||t.length>2048||/["'()\\;\s<>]/.test(t))return null;let n;try{n=new URL(t)}catch{return null}return n.protocol==="https:"||n.protocol==="http:"||n.protocol==="data:"&&/^data:image\//i.test(t)?t:null}const G="fr",Be=["fr","en"],he={fr:"fr-FR",en:"en-US"},de={fr:{"common.newConversation":"Nouvelle conversation","common.conversation":"Conversation","common.agent":"Agent","common.aiAssistant":"Assistant IA","common.system":"Système","common.you":"Vous","common.action":"Action","common.yes":"Oui","common.no":"Non","common.send":"Envoyer","common.sending":"Envoi…","common.cancel":"Annuler","common.save":"Enregistrer","common.close":"Fermer","common.open":"Ouvrir","loading.minimize":"Réduire","error.connectionFailed":"Connexion impossible","header.backToHome":"Retour à l'accueil","header.moreOptions":"Plus d'options","header.closeWidget":"Fermer le widget","launcher.open":"Ouvrir le messenger","launcher.openConversationWith":"Ouvrir la conversation avec {name}","launcher.theAgent":"l'agent","launcher.dismiss":"Ignorer","launcher.repliedToYou":" vous a répondu","launcher.unreadMessages":"{count} messages non lus","launcher.unreadConversationsOne":"{count} conversation non lue","launcher.unreadConversationsMany":"{count} conversations non lues","onboarding.start":"Commencer une conversation","onboarding.quickAccess":"Accès rapide","onboarding.recentConversations":"Conversations récentes","onboarding.search":"Rechercher dans vos messages","onboarding.unread":"Non lu","onboarding.noResults":"Aucun résultat pour « {query} ».","onboarding.greetingNamed":"Bonjour, je suis {name}","onboarding.greeting":"Bonjour, je suis votre assistant","onboarding.heroSub":`Posez-moi n'importe quelle question.
48
+ `,be="https://api.messenger.victorc.fr",ot=/^[a-zA-Z]{3,32}$/,st=/^#[0-9a-fA-F]{3,8}$/,at=/^(rgb|rgba|hsl|hsla)\(\s*[\d.,%\s/]{1,60}\)$/;function it(t){return typeof t!="string"||!t||t.length>64?!1:st.test(t)||at.test(t)||ot.test(t)}function lt(t){if(typeof t!="string"||!t||t.length>2048||/["'()\\;\s<>]/.test(t))return null;let n;try{n=new URL(t)}catch{return null}return n.protocol==="https:"||n.protocol==="http:"||n.protocol==="data:"&&/^data:image\//i.test(t)?t:null}const G="fr",Ee=["fr","en"],me={fr:"fr-FR",en:"en-US"},de={fr:{"common.newConversation":"Nouvelle conversation","common.conversation":"Conversation","common.agent":"Agent","common.aiAssistant":"Assistant IA","common.system":"Système","common.you":"Vous","common.action":"Action","common.yes":"Oui","common.no":"Non","common.send":"Envoyer","common.sending":"Envoi…","common.cancel":"Annuler","common.save":"Enregistrer","common.close":"Fermer","common.open":"Ouvrir","loading.minimize":"Réduire","error.connectionFailed":"Connexion impossible","header.backToHome":"Retour à l'accueil","header.moreOptions":"Plus d'options","header.closeWidget":"Fermer le widget","launcher.open":"Ouvrir le messenger","launcher.openConversationWith":"Ouvrir la conversation avec {name}","launcher.theAgent":"l'agent","launcher.dismiss":"Ignorer","launcher.repliedToYou":" vous a répondu","launcher.unreadMessages":"{count} messages non lus","launcher.unreadConversationsOne":"{count} conversation non lue","launcher.unreadConversationsMany":"{count} conversations non lues","onboarding.start":"Commencer une conversation","onboarding.quickAccess":"Accès rapide","onboarding.recentConversations":"Conversations récentes","onboarding.search":"Rechercher dans vos messages","onboarding.unread":"Non lu","onboarding.noResults":"Aucun résultat pour « {query} ».","onboarding.greetingNamed":"Bonjour, je suis {name}","onboarding.greeting":"Bonjour, je suis votre assistant","onboarding.heroSub":`Posez-moi n'importe quelle question.
49
49
  Je réponds en quelques secondes.`,"onboarding.newMessage":"Nouveau message","onboarding.statusInProgress":"En cours","onboarding.resume":"Reprendre","onboarding.unreadConversations":"Conversations non lues","onboarding.allConversations":"Toutes les conversations","onboarding.noConversations":"Aucune conversation pour le moment.","composer.placeholder":"Écrivez votre message…","composer.replyTo":"Répondre à {name}…","composer.agentTakingOver":"Un agent prend le relais…","composer.send":"Envoyer","composer.attach":"Joindre","composer.attachFile":"Joindre un fichier","composer.screenshot":"Capture d'écran","composer.recordScreen":"Enregistrer l'écran","composer.recording":"Enregistrement · {time}","composer.stop":"Arrêter","messageList.loadingHistory":"Chargement de l'historique…","messageList.conversationStart":"Début de la conversation","messageList.unread":"Non lus","messageList.today":"Aujourd'hui · {time}","messageList.approvalRequestSent":"Demande d'approbation envoyée","messageList.conversationUpdate":"Mise à jour de la conversation","messageList.anAgent":"Un agent","messageList.scrollToBottom":"Aller en bas","system.transferredToHuman":"Conversation transférée à un humain","system.assigned":"{name} a rejoint la conversation","system.unassigned":"L'agent a quitté la conversation","system.resolved":"Conversation résolue","system.reopened":"Conversation rouverte","system.idle":"Conversation en pause","action.title":"Confirmer l'action","action.inProgress":"{name} en cours, veuillez patienter…","action.rejectedByUser":"Action annulée par l'utilisateur.","approval.approve":"Autoriser","approval.reject":"Refuser","moreMenu.editTitle":"Modifier le titre","moreMenu.exportTranscript":"Exporter la transcription","moreMenu.sound":"Son","moreMenu.browserNotifications":"Notifications navigateur","moreMenu.serviceStatus":"Statut des services","moreMenu.helpCenter":"Centre d'aide","feedback.question":"Comment s'est passée cette conversation ?","feedback.subtitle":"Votre avis nous aide à améliorer l'assistant.","feedback.rating1":"Pas bien","feedback.rating2":"Moyen","feedback.rating3":"Bien","feedback.rating4":"Super","feedback.rating5":"Excellent","feedback.submit":"Envoyer mon avis","feedback.doneTitle":"Merci pour votre retour !","feedback.doneSubtitle":"Votre avis a bien été pris en compte.","rename.dialogTitle":"Modifier le titre de la conversation","rename.title":"Modifier le titre","rename.placeholder":"Titre de la conversation","form.title":"Formulaire","form.choose":"Choisir…","form.responseSent":"Réponse envoyée","form.sent":"Envoyé","form.fieldRequired":"« {label} » est requis.","ticket.dateAt":" à ","attachment.fallbackName":"Pièce jointe","attachment.remove":"Retirer","attachment.fileFallbackName":"fichier","attachment.bytes":"{size} o","attachment.kilobytes":"{size} ko","attachment.megabytes":"{size} Mo","notification.newMessage":"Nouveau message","notification.youHaveNewMessage":"Vous avez un nouveau message","export.createdOn":"Créée le : {date}"},en:{"common.newConversation":"New conversation","common.conversation":"Conversation","common.agent":"Agent","common.aiAssistant":"AI Assistant","common.system":"System","common.you":"You","common.action":"Action","common.yes":"Yes","common.no":"No","common.send":"Send","common.sending":"Sending…","common.cancel":"Cancel","common.save":"Save","common.close":"Close","common.open":"Open","loading.minimize":"Minimize","error.connectionFailed":"Connection failed","header.backToHome":"Back to home","header.moreOptions":"More options","header.closeWidget":"Close widget","launcher.open":"Open the messenger","launcher.openConversationWith":"Open the conversation with {name}","launcher.theAgent":"the agent","launcher.dismiss":"Dismiss","launcher.repliedToYou":" replied to you","launcher.unreadMessages":"{count} unread messages","launcher.unreadConversationsOne":"{count} unread conversation","launcher.unreadConversationsMany":"{count} unread conversations","onboarding.start":"Start a conversation","onboarding.quickAccess":"Quick access","onboarding.recentConversations":"Recent conversations","onboarding.search":"Search your messages","onboarding.unread":"Unread","onboarding.noResults":"No results for “{query}”.","onboarding.greetingNamed":"Hi, I'm {name}","onboarding.greeting":"Hi, I'm your assistant","onboarding.heroSub":`Ask me anything.
50
- I reply within seconds.`,"onboarding.newMessage":"New message","onboarding.statusInProgress":"In progress","onboarding.resume":"Resume","onboarding.unreadConversations":"Unread conversations","onboarding.allConversations":"All conversations","onboarding.noConversations":"No conversations yet.","composer.placeholder":"Type your message…","composer.replyTo":"Reply to {name}…","composer.agentTakingOver":"An agent is taking over…","composer.send":"Send","composer.attach":"Attach","composer.attachFile":"Attach a file","composer.screenshot":"Screenshot","composer.recordScreen":"Record screen","composer.recording":"Recording · {time}","composer.stop":"Stop","messageList.loadingHistory":"Loading history…","messageList.conversationStart":"Start of the conversation","messageList.unread":"Unread","messageList.today":"Today · {time}","messageList.approvalRequestSent":"Approval request sent","messageList.conversationUpdate":"Conversation update","messageList.anAgent":"An agent","messageList.scrollToBottom":"Scroll to bottom","system.transferredToHuman":"Conversation transferred to a human","system.assigned":"{name} joined the conversation","system.unassigned":"The agent left the conversation","system.resolved":"Conversation resolved","system.reopened":"Conversation reopened","system.idle":"Conversation paused","action.title":"Confirm the action","action.inProgress":"{name} in progress, please wait…","action.rejectedByUser":"Action cancelled by the user.","approval.approve":"Approve","approval.reject":"Decline","moreMenu.editTitle":"Edit title","moreMenu.exportTranscript":"Export transcript","moreMenu.sound":"Sound","moreMenu.browserNotifications":"Browser notifications","moreMenu.serviceStatus":"Service status","moreMenu.helpCenter":"Help center","feedback.question":"How was this conversation?","feedback.subtitle":"Your feedback helps us improve the assistant.","feedback.rating1":"Poor","feedback.rating2":"Okay","feedback.rating3":"Good","feedback.rating4":"Great","feedback.rating5":"Excellent","feedback.submit":"Send my feedback","feedback.doneTitle":"Thanks for your feedback!","feedback.doneSubtitle":"Your feedback has been recorded.","rename.dialogTitle":"Edit conversation title","rename.title":"Edit title","rename.placeholder":"Conversation title","form.title":"Form","form.choose":"Choose…","form.responseSent":"Response sent","form.sent":"Sent","form.fieldRequired":"“{label}” is required.","ticket.dateAt":" at ","attachment.fallbackName":"Attachment","attachment.remove":"Remove","attachment.fileFallbackName":"file","attachment.bytes":"{size} B","attachment.kilobytes":"{size} KB","attachment.megabytes":"{size} MB","notification.newMessage":"New message","notification.youHaveNewMessage":"You have a new message","export.createdOn":"Created on: {date}"}};function se(t){if(typeof t!="string")return G;const n=t.trim().toLowerCase().slice(0,2);return Be.includes(n)?n:G}function P(t){return he[se(t)]||he[G]}function T(t){const n=se(t),r=de[n]||de[G],s=de[G];return function(o,i){let l=r[o];return l==null&&(l=s[o]),l==null?o:(i&&(l=l.replace(/\{(\w+)\}/g,(f,y)=>i[y]!=null?String(i[y]):f)),l)}}function fe(t,n){if(!Array.isArray(t==null?void 0:t.options))return n;const r=t.options.find(s=>(s==null?void 0:s.value)===n);return(r==null?void 0:r.label)||n}function Ne(t,n,r){return Array.isArray(n)?n.map(s=>fe(t,String(s))).join(", "):typeof n=="boolean"?r(n?"common.yes":"common.no"):fe(t,String(n))}function ct(t,n,r=T()){if(!t||!n)return"";const s=Array.isArray(t.fields)?t.fields:[],a=[];for(const o of s){if(!(o!=null&&o.key)||!(o!=null&&o.label))continue;const i=n[o.key];if(i==null||i==="")continue;const l=Ne(o,i,r);l&&a.push(`${o.label} :
51
- ${l}`)}return a.join(`
50
+ I reply within seconds.`,"onboarding.newMessage":"New message","onboarding.statusInProgress":"In progress","onboarding.resume":"Resume","onboarding.unreadConversations":"Unread conversations","onboarding.allConversations":"All conversations","onboarding.noConversations":"No conversations yet.","composer.placeholder":"Type your message…","composer.replyTo":"Reply to {name}…","composer.agentTakingOver":"An agent is taking over…","composer.send":"Send","composer.attach":"Attach","composer.attachFile":"Attach a file","composer.screenshot":"Screenshot","composer.recordScreen":"Record screen","composer.recording":"Recording · {time}","composer.stop":"Stop","messageList.loadingHistory":"Loading history…","messageList.conversationStart":"Start of the conversation","messageList.unread":"Unread","messageList.today":"Today · {time}","messageList.approvalRequestSent":"Approval request sent","messageList.conversationUpdate":"Conversation update","messageList.anAgent":"An agent","messageList.scrollToBottom":"Scroll to bottom","system.transferredToHuman":"Conversation transferred to a human","system.assigned":"{name} joined the conversation","system.unassigned":"The agent left the conversation","system.resolved":"Conversation resolved","system.reopened":"Conversation reopened","system.idle":"Conversation paused","action.title":"Confirm the action","action.inProgress":"{name} in progress, please wait…","action.rejectedByUser":"Action cancelled by the user.","approval.approve":"Approve","approval.reject":"Decline","moreMenu.editTitle":"Edit title","moreMenu.exportTranscript":"Export transcript","moreMenu.sound":"Sound","moreMenu.browserNotifications":"Browser notifications","moreMenu.serviceStatus":"Service status","moreMenu.helpCenter":"Help center","feedback.question":"How was this conversation?","feedback.subtitle":"Your feedback helps us improve the assistant.","feedback.rating1":"Poor","feedback.rating2":"Okay","feedback.rating3":"Good","feedback.rating4":"Great","feedback.rating5":"Excellent","feedback.submit":"Send my feedback","feedback.doneTitle":"Thanks for your feedback!","feedback.doneSubtitle":"Your feedback has been recorded.","rename.dialogTitle":"Edit conversation title","rename.title":"Edit title","rename.placeholder":"Conversation title","form.title":"Form","form.choose":"Choose…","form.responseSent":"Response sent","form.sent":"Sent","form.fieldRequired":"“{label}” is required.","ticket.dateAt":" at ","attachment.fallbackName":"Attachment","attachment.remove":"Remove","attachment.fileFallbackName":"file","attachment.bytes":"{size} B","attachment.kilobytes":"{size} KB","attachment.megabytes":"{size} MB","notification.newMessage":"New message","notification.youHaveNewMessage":"You have a new message","export.createdOn":"Created on: {date}"}};function se(t){if(typeof t!="string")return G;const n=t.trim().toLowerCase().slice(0,2);return Ee.includes(n)?n:G}function z(t){return me[se(t)]||me[G]}function T(t){const n=se(t),r=de[n]||de[G],a=de[G];return function(o,i){let l=r[o];return l==null&&(l=a[o]),l==null?o:(i&&(l=l.replace(/\{(\w+)\}/g,(f,y)=>i[y]!=null?String(i[y]):f)),l)}}function he(t,n){if(!Array.isArray(t==null?void 0:t.options))return n;const r=t.options.find(a=>(a==null?void 0:a.value)===n);return(r==null?void 0:r.label)||n}function Ce(t,n,r){return Array.isArray(n)?n.map(a=>he(t,String(a))).join(", "):typeof n=="boolean"?r(n?"common.yes":"common.no"):he(t,String(n))}function ct(t,n,r=T()){if(!t||!n)return"";const a=Array.isArray(t.fields)?t.fields:[],s=[];for(const o of a){if(!(o!=null&&o.key)||!(o!=null&&o.label))continue;const i=n[o.key];if(i==null||i==="")continue;const l=Ce(o,i,r);l&&s.push(`${o.label} :
51
+ ${l}`)}return s.join(`
52
52
 
53
- `)}function dt(t,n,r=T()){const s=[],a=Array.isArray(t==null?void 0:t.fields)?t.fields:[];for(const o of a){if(!(o!=null&&o.key)||!(o!=null&&o.label))continue;const i=n==null?void 0:n[o.key];if(i==null||i==="")continue;const l=Ne(o,i,r);if(!l)continue;const f=o.type==="textarea"||typeof l=="string"&&(l.length>60||l.includes(`
54
- `));s.push({label:o.label,value:l,multiline:f})}return{kind:"form_response",data:{title:(t==null?void 0:t.title)||r("form.title"),fields:s}}}function Se(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ne(t){return/^(https?:\/\/|mailto:|tel:)/i.test(String(t).trim())}const pe="";function Y(t){let n=t;const r=[];return n=n.replace(/`([^`\n]+)`/g,(s,a)=>{const o=r.length;return r.push(a),`${pe}CODE${o}${pe}`}),n=n.replace(/\[([^\]\n]+)\]\(([^)\s]+)\)/g,(s,a,o)=>ne(o)?`<a href="${o}" target="_blank" rel="noopener noreferrer">${a}</a>`:a),n=n.replace(/\*\*([^\n*][^\n]*?)\*\*/g,"<strong>$1</strong>"),n=n.replace(/__([^\n_][^\n]*?)__/g,"<u>$1</u>"),n=n.replace(/~~([^\n~][^\n]*?)~~/g,"<s>$1</s>"),n=n.replace(/(^|[^\w*])\*([^\n*]+?)\*(?!\w)/g,"$1<em>$2</em>"),n=n.replace(/(^|[^\w_])_([^\n_]+?)_(?!\w)/g,"$1<em>$2</em>"),n=n.replace(/CODE(\d+)/g,(s,a)=>`<code class="wm-md-code">${r[+a]}</code>`),n}function me(t){if(!t)return"";const n=String(t).replace(/\[([^\]\n]+)\]\([^)\s]+\)/g,"$1");return Y(Se(n))}function Ae(t){if(!t)return"";const n=Se(t).split(`
55
- `),r=[];let s=0;for(;s<n.length;){const o=n[s];if(/^\s*```([\w-]*)\s*$/.exec(o)){s++;const y=[];for(;s<n.length&&!/^\s*```\s*$/.test(n[s]);)y.push(n[s]),s++;s<n.length&&s++,r.push({type:"block",html:`<pre class="wm-md-pre"><code>${y.join(`
56
- `)}</code></pre>`});continue}if(/^\s*[-*]\s+/.test(o)){const y=[];for(;s<n.length;){const C=/^\s*[-*]\s+(.*)$/.exec(n[s]);if(!C)break;y.push(C[1]),s++}const _=y.map(C=>`<li>${Y(C)}</li>`).join("");r.push({type:"block",html:`<ul class="wm-md-ul">${_}</ul>`});continue}const l=/^\s*(\d+)\.\s+(.*)$/.exec(o);if(l){const y=parseInt(l[1],10),_=[l[2]];for(s++;s<n.length;){const k=/^\s*\d+\.\s+(.*)$/.exec(n[s]);if(!k)break;_.push(k[1]),s++}const C=_.map(k=>`<li>${Y(k)}</li>`).join(""),N=y!==1?` start="${y}"`:"";r.push({type:"block",html:`<ol class="wm-md-ol"${N}>${C}</ol>`});continue}const f=/^(#{1,6})\s+(.*)$/.exec(o);if(f){const y=f[1].length;r.push({type:"block",html:`<h${y} class="wm-md-h wm-md-h${y}">${Y(f[2])}</h${y}>`}),s++;continue}r.push({type:"text",html:Y(o)}),s++}let a="";for(let o=0;o<r.length;o++){const i=r[o];a+=i.html;const l=r[o+1];l&&i.type!=="block"&&l.type!=="block"&&(a+=`
57
- `)}return a}function X(t){var r;const n=(r=t==null?void 0:t.author)==null?void 0:r.type;return n==="agent_ia"||n==="agent_human"}function R(t){if(t==null)return null;const n=typeof t=="number"?t:Number(t);return Number.isFinite(n)?n:null}function ge(t,n){let r=(t==null?void 0:t.last_message_at)||(t==null?void 0:t.updated_at)||(t==null?void 0:t.created_at)||"";for(const s of n)s!=null&&s.created_at&&s.created_at>r&&(r=s.created_at);return r}function ut(t,n){var r,s,a;for(let o=n.length-1;o>=0;o--){const i=n[o];if(!i)continue;const l=typeof i.text_md=="string"?i.text_md.trim():"";if(l)return(((r=i.author)==null?void 0:r.type)==="user"?"Vous : ":"")+l.replace(/\s+/g," ");const f=(s=i.payload)==null?void 0:s.attachments;if(Array.isArray(f)&&f.length)return"📎 Pièce jointe"}return(t==null?void 0:t.last_message_preview)||(t==null?void 0:t.preview)||((a=t==null?void 0:t.metadata)==null?void 0:a.last_preview)||""}function mt(t,n){return(t==null?void 0:t.name)||((t==null?void 0:t.type)==="user"?n("common.you"):(t==null?void 0:t.type)==="agent_human"?n("common.agent"):(t==null?void 0:t.type)==="agent_ia"?n("common.aiAssistant"):n("common.system"))}function ht(t,n,r,s){const a=[`# ${t.name||r("common.conversation")}`,t.created_at?r("export.createdOn",{date:new Date(t.created_at).toLocaleString(s)}):"",""];for(const o of n){if(!o)continue;const i=(o.text_md||"").trim();if(!i)continue;const l=mt(o.author,r),f=o.created_at?new Date(o.created_at).toLocaleString(s):"";a.push(`[${f}] ${l} :`),a.push(i),a.push("")}return a.join(`
58
- `)}function ft(t,n,r=T(),s){if(!t)return;const a=ht(t,n||[],r,P(s)),o=new Blob([a],{type:"text/plain;charset=utf-8"});try{const i=URL.createObjectURL(o),l=document.createElement("a");l.href=i,l.download=`${(t.name||"conversation").replace(/[^a-z0-9-_]+/gi,"_")}.txt`,document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(i),1e3)}catch(i){console.error("[ww-messenger] export failed",i)}}const pt={data(){const t=typeof Notification<"u";return{notifPermission:t?Notification.permission:"denied",soundEnabled:!0,browserNotifEnabled:t&&Notification.permission==="granted",_audioCtx:null}},methods:{teardownNotifications(){var t,n;if(this._audioCtx){try{(n=(t=this._audioCtx).close)==null||n.call(t)}catch{}this._audioCtx=null}},soundStorageKey(){return`wm:notif:sound:${this.widgetId||""}`},browserNotifStorageKey(){return`wm:notif:browser:${this.widgetId||""}`},hydrateNotifPref(){try{if(typeof localStorage>"u")return;const t=localStorage.getItem(this.soundStorageKey());t==="0"?this.soundEnabled=!1:t==="1"&&(this.soundEnabled=!0);const n=localStorage.getItem(this.browserNotifStorageKey());n==="0"?this.browserNotifEnabled=!1:n==="1"&&(this.browserNotifEnabled=typeof Notification<"u"&&Notification.permission==="granted")}catch{}},persistSoundPref(){try{if(typeof localStorage>"u")return;localStorage.setItem(this.soundStorageKey(),this.soundEnabled?"1":"0")}catch{}},persistBrowserNotifPref(){try{if(typeof localStorage>"u")return;localStorage.setItem(this.browserNotifStorageKey(),this.browserNotifEnabled?"1":"0")}catch{}},onSoundToggle(t){this.soundEnabled=!!t,this.persistSoundPref()},async onBrowserNotifToggle(t){if(typeof Notification>"u"){this.browserNotifEnabled=!1,this.persistBrowserNotifPref();return}if(!t){this.browserNotifEnabled=!1,this.persistBrowserNotifPref();return}let n=Notification.permission;if(n==="default"){try{n=await Notification.requestPermission()}catch(r){console.warn("[ww-messenger] notif permission request failed",r),n="denied"}this.notifPermission=n}this.browserNotifEnabled=n==="granted",this.persistBrowserNotifPref()},onMessageRevealed(t,n){var a;if(!this.soundEnabled&&!this.browserNotifEnabled||!n||!t||!X(t))return;const r=typeof document<"u"&&document.hidden;this.isOpen&&!r&&((a=this.currentConv)==null?void 0:a.id)===n||(this.soundEnabled&&this.playNotificationSound(),this.browserNotifEnabled&&this.showBrowserNotification(n,t))},playNotificationSound(){if(typeof window>"u")return;const t=window.AudioContext||window.webkitAudioContext;if(t)try{this._audioCtx||(this._audioCtx=new t);const n=this._audioCtx;if(n.state==="suspended")try{n.resume()}catch{}const r=n.currentTime,s=n.createOscillator(),a=n.createGain();s.connect(a),a.connect(n.destination),s.type="sine",s.frequency.setValueAtTime(880,r),s.frequency.exponentialRampToValueAtTime(1320,r+.08),a.gain.setValueAtTime(0,r),a.gain.linearRampToValueAtTime(.12,r+.02),a.gain.exponentialRampToValueAtTime(1e-4,r+.28),s.start(r),s.stop(r+.32)}catch{}},showBrowserNotification(t,n){if(typeof Notification>"u"||Notification.permission!=="granted")return;const r=n==null?void 0:n.author,s=!r||r.type==="agent_ia",o=((r==null?void 0:r.name)||(s?this.agentName:"")||this.t("launcher.theAgent"))+this.t("launcher.repliedToYou"),i=typeof(n==null?void 0:n.text_md)=="string"?n.text_md.trim():"",l=i?i.slice(0,140):this.t("notification.youHaveNewMessage");try{const f=new Notification(o,{body:l,tag:`wm-${t}`,renotify:!1,silent:!0});f.onclick=()=>{try{window.focus()}catch{}this.draftConv=null,this.showOnboarding=!1,this.activeConvId=t,this.isOpen=!0,this.store&&this.store.setPanelOpen(!0);try{f.close()}catch{}}}catch(f){console.warn("[ww-messenger] notification failed",f)}}}},gt=450,_t=50,yt=900,vt=12e3,kt=300,wt={data(){return{revealedAt:{},nextRevealAt:0,revealTimers:[],_liveRevealOff:null,_liveRevealConvSnapshot:null}},methods:{cancelReveals(){for(const t of this.revealTimers)clearTimeout(t);this.revealTimers=[]},resetRevealQueue(){this.cancelReveals(),this.revealedAt={},this.nextRevealAt=0},setupLiveReveal(){var r;if(!this.transport)return;this.teardownLiveReveal();const t=this.transport.on("message",s=>{const a=s==null?void 0:s.conversation_id,o=s==null?void 0:s.message;a&&o&&this.paceLiveMessage(o,a)});this._liveRevealConvSnapshot=new Map((((r=this.s)==null?void 0:r.conversations)||[]).map(s=>[s.id,(s==null?void 0:s.last_message_at)||""]));const n=this.transport.on("activity",s=>{this.handleLiveActivity(s)});this._liveRevealOff=()=>{try{t()}catch{}try{n()}catch{}}},teardownLiveReveal(){if(this._liveRevealOff){try{this._liveRevealOff()}catch{}this._liveRevealOff=null}this._liveRevealConvSnapshot=null},async handleLiveActivity(t){var a,o;const n=t==null?void 0:t.conversations;if(!Array.isArray(n)||!this.store)return;const r=this._liveRevealConvSnapshot||new Map,s=[];for(const i of n){if(!(i!=null&&i.id))continue;const l=i.last_message_at||"";if(!l)continue;const f=r.get(i.id)||"";l>f&&s.push(i.id)}this._liveRevealConvSnapshot=new Map(n.map(i=>[i.id,(i==null?void 0:i.last_message_at)||""]));for(const i of s)try{const l=await((o=(a=this.store).fetchSinceLast)==null?void 0:o.call(a,i));if(!Array.isArray(l))continue;for(const f of l)this.paceLiveMessage(f,i)}catch(l){console.error("[ww-messenger] activity delta fetch failed",l)}},scheduleReveal(t,n){const r=Date.now(),s=((t==null?void 0:t.text_md)||"").length,a=Math.min(vt,Math.max(yt,s*_t)),i=Math.max(r+gt,this.nextRevealAt+kt)+a;this.nextRevealAt=i;const l=Math.max(0,i-r),f=t.id,y=setTimeout(()=>{this.revealedAt={...this.revealedAt,[f]:Date.now()},this.revealTimers=this.revealTimers.filter(_=>_!==y),typeof this.onMessageRevealed=="function"&&this.onMessageRevealed(t,n)},l);this.revealTimers.push(y)},paceMessages(t,n){var a;if(!Array.isArray(t)||!t.length)return;const r=Date.now(),s={...this.revealedAt};for(const o of t){if((o==null?void 0:o.id)==null||s[o.id]!==void 0)continue;if(!X(o)){s[o.id]=r;continue}const i=o!=null&&o.created_at?Date.parse(o.created_at):NaN;if(!Number.isFinite(i)||i<this.convOpenedAt){s[o.id]=r;continue}const l=typeof(o==null?void 0:o.text_md)=="string"&&o.text_md.trim().length>0,f=Array.isArray((a=o==null?void 0:o.payload)==null?void 0:a.attachments)&&o.payload.attachments.length>0;if(!l&&!f){s[o.id]=r;continue}s[o.id]=0,this.scheduleReveal(o,n)}this.revealedAt=s},paceLiveMessage(t,n){var a;if(!(t!=null&&t.id)||this.revealedAt[t.id]!==void 0)return;if(!X(t)){this.revealedAt={...this.revealedAt,[t.id]:Date.now()};return}const r=typeof(t==null?void 0:t.text_md)=="string"&&t.text_md.trim().length>0,s=Array.isArray((a=t==null?void 0:t.payload)==null?void 0:a.attachments)&&t.payload.attachments.length>0;if(!r&&!s){this.revealedAt={...this.revealedAt,[t.id]:Date.now()};return}this.revealedAt={...this.revealedAt,[t.id]:0},this.scheduleReveal(t,n)}}},bt={data(){return{approvalSettled:!0,approvalSettleTimer:null,approvalLatchId:null}},methods:{resetApprovalPacing(){this.approvalSettleTimer&&(clearTimeout(this.approvalSettleTimer),this.approvalSettleTimer=null),this.approvalSettled=!0,this.approvalLatchId=null},bumpApprovalSettle(t=800){this.approvalSettled=!1,this.approvalSettleTimer&&clearTimeout(this.approvalSettleTimer),this.approvalSettleTimer=setTimeout(()=>{this.approvalSettled=!0,this.approvalSettleTimer=null},t)}}},Et=300,Ct={data(){return{unreadAnchorId:null,unreadBoundaryTs:""}},created(){this._readMarkerTimer=null,this._readMarkerPending=null},beforeUnmount(){this._readMarkerTimer&&(clearTimeout(this._readMarkerTimer),this._readMarkerTimer=null),this._readMarkerPending=null},methods:{markConvRead(t){var o,i;if(!(t!=null&&t.id)||t._draft||!this.store)return;const n=((i=(o=this.s)==null?void 0:o.messagesByConv)==null?void 0:i[t.id])||[],r=Bt(n);if(r==null)return;const s=R(t.last_read_message_id),a=R(r);a!=null&&(s!=null&&a<=s||(this._readMarkerPending={convId:t.id,messageId:r},!this._readMarkerTimer&&(this._readMarkerTimer=setTimeout(()=>{const l=this._readMarkerPending;this._readMarkerPending=null,this._readMarkerTimer=null,l&&this.store&&this.store.markConversationRead(l.convId,l.messageId)},Et))))}}};function Bt(t){for(let n=t.length-1;n>=0;n--){const r=t[n];if(!(!r||r._pending)&&R(r.id)!=null)return r.id}return null}const S=(t,n)=>{const r=t.__vccOpts||t;for(const[s,a]of n)r[s]=a;return r},Nt={name:"WmHumanAvatar",props:{name:{type:String,default:""},avatarUrl:{type:String,default:null},size:{type:Number,default:26},tail:{type:Boolean,default:!1}},computed:{bg(){return this.avatarUrl?"transparent":oe(this.name)},initials(){return ae(this.name)}}},St=["src","alt"];function At(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-huav",{"wm-huav--tail":r.tail}]),style:e.normalizeStyle({width:r.size+"px",height:r.size+"px","--wm-avr":Math.round(r.size*.32)+"px",background:o.bg})},[r.avatarUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.avatarUrl,alt:r.name||""},null,8,St)):(e.openBlock(),e.createElementBlock("span",{key:1,style:e.normalizeStyle({fontSize:r.size*.36+"px"})},e.toDisplayString(o.initials),5))],6)}const Q=S(Nt,[["render",At],["__scopeId","data-v-14e10c0d"]]),Vt=3,Mt={name:"WmLauncher",components:{HumanAvatar:Q},inject:{t:{default:()=>T()}},props:{unreadCount:{type:Number,default:0},peeks:{type:Array,default:()=>[]}},emits:["open","dismiss"],computed:{visiblePeeks(){return this.peeks.slice(0,Vt).reverse()}}},Tt=["aria-label","onClick","onKeydown"],xt=["aria-label","onClick"],Lt={class:"wm-peek__avatar"},Ot=["aria-label"],Dt={class:"wm-peek__body"},It={class:"wm-peek__head"},Rt={class:"wm-peek__name"},Ft={class:"wm-peek__action"},Pt={class:"wm-peek__text"},Ut=["onClick"],zt=["aria-label"],jt=["aria-label"];function Ht(t,n,r,s,a,o){const i=e.resolveComponent("HumanAvatar");return e.openBlock(),e.createElementBlock("div",{class:"wm-launcherWrap",onMouseenter:n[1]||(n[1]=l=>t.$emit("hover",!0)),onMouseleave:n[2]||(n[2]=l=>t.$emit("hover",!1)),onFocusin:n[3]||(n[3]=l=>t.$emit("hover",!0)),onFocusout:n[4]||(n[4]=l=>t.$emit("hover",!1))},[e.createVNode(e.Transition,{name:"wm-peek"},{default:e.withCtx(()=>[o.visiblePeeks.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["wm-peekStack",{"wm-peekStack--multi":o.visiblePeeks.length>1}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.visiblePeeks,(l,f)=>(e.openBlock(),e.createElementBlock("div",{key:l.convId,class:"wm-peek",style:e.normalizeStyle({"--depth":o.visiblePeeks.length-1-f,zIndex:f+1}),role:"button",tabindex:"0","aria-label":o.t("launcher.openConversationWith",{name:l.senderName||o.t("launcher.theAgent")}),onClick:y=>t.$emit("open",l.convId),onKeydown:[e.withKeys(e.withModifiers(y=>t.$emit("open",l.convId),["prevent"]),["enter"]),e.withKeys(e.withModifiers(y=>t.$emit("open",l.convId),["prevent"]),["space"])]},[e.createElementVNode("button",{type:"button",class:"wm-peek__close","aria-label":o.t("launcher.dismiss"),onClick:e.withModifiers(y=>t.$emit("dismiss",l.convId),["stop"])},[...n[5]||(n[5]=[e.createElementVNode("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,xt),e.createElementVNode("div",Lt,[e.createVNode(i,{name:l.senderName,"avatar-url":l.senderAvatarUrl,size:34},null,8,["name","avatar-url"]),l.count>1?(e.openBlock(),e.createElementBlock("span",{key:0,class:"wm-peek__avatarBadge","aria-label":o.t("launcher.unreadMessages",{count:l.count})},e.toDisplayString(l.count>9?"9+":l.count),9,Ot)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Dt,[e.createElementVNode("div",It,[e.createElementVNode("span",Rt,e.toDisplayString(l.senderName||o.t("common.agent")),1),e.createElementVNode("span",Ft,e.toDisplayString(o.t("launcher.repliedToYou")),1)]),e.createElementVNode("p",Pt,e.toDisplayString(l.preview),1)]),e.createElementVNode("button",{type:"button",class:"wm-peek__open",onClick:e.withModifiers(y=>t.$emit("open",l.convId),["stop"])},e.toDisplayString(o.t("common.open")),9,Ut)],44,Tt))),128))],2)):e.createCommentVNode("",!0)]),_:1}),e.createElementVNode("button",{type:"button",class:"wm-launcher","aria-label":o.t("launcher.open"),onClick:n[0]||(n[0]=l=>t.$emit("open"))},[n[6]||(n[6]=e.createElementVNode("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})],-1)),r.unreadCount>0?(e.openBlock(),e.createElementBlock("span",{key:0,class:"wm-launcher__badge","aria-label":r.unreadCount>1?o.t("launcher.unreadConversationsMany",{count:r.unreadCount}):o.t("launcher.unreadConversationsOne",{count:r.unreadCount})},e.toDisplayString(r.unreadCount>9?"9+":r.unreadCount),9,jt)):e.createCommentVNode("",!0)],8,zt)],32)}const Ve=S(Mt,[["render",Ht],["__scopeId","data-v-44ddf1a1"]]),qt={name:"WmAIAvatar",props:{size:{type:Number,default:26},pulse:{type:Boolean,default:!1},tail:{type:Boolean,default:!1},name:{type:String,default:""},imageUrl:{type:String,default:null}},computed:{initials(){return ae(this.name)},bgColor(){return oe(this.name)}}},Kt={key:0,class:"wm-aiav__pulse"},$t=["src","alt"],Wt=["width","height"];function Gt(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-aiav",{"wm-aiav--tail":r.tail}]),style:e.normalizeStyle({width:r.size+"px",height:r.size+"px","--wm-avr":r.size*.32+"px"})},[r.pulse?(e.openBlock(),e.createElementBlock("div",Kt)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["wm-aiav__inner",{"wm-aiav__inner--glow":r.pulse,"wm-aiav__inner--img":!!r.imageUrl,"wm-aiav__inner--initials":!r.imageUrl&&!!o.initials}]),style:e.normalizeStyle(!r.imageUrl&&o.initials?{background:o.bgColor}:null)},[r.imageUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.imageUrl,alt:r.name||""},null,8,$t)):o.initials?(e.openBlock(),e.createElementBlock("span",{key:1,style:e.normalizeStyle({fontSize:r.size*.36+"px"})},e.toDisplayString(o.initials),5)):(e.openBlock(),e.createElementBlock("svg",{key:2,width:r.size*.5,height:r.size*.5,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[...n[0]||(n[0]=[e.createElementVNode("path",{d:"M12 2 L13.5 9 L20 10.5 L13.5 12 L12 19 L10.5 12 L4 10.5 L10.5 9 Z",fill:"white",opacity:"0.92"},null,-1),e.createElementVNode("circle",{cx:"19",cy:"5",r:"1.5",fill:"white",opacity:"0.55"},null,-1),e.createElementVNode("circle",{cx:"5",cy:"18",r:"1",fill:"white",opacity:"0.38"},null,-1)])],8,Wt))],6)],6)}const H=S(qt,[["render",Gt],["__scopeId","data-v-6f7f685d"]]),Yt={name:"WmTeamAvatars",props:{members:{type:Array,default:()=>[]},responseLabel:{type:String,default:""}},computed:{visible(){return Array.isArray(this.members)&&this.members.length>0},stackWidth(){return Math.min(this.members.length,3)===1?20:16+Math.min(this.members.length,3)*13}},methods:{colorFor(t){return t.avatar_url?"transparent":oe(t.name||"")},initialsFor(t){return ae(t.name||"")}}},Xt={key:0,class:"wm-team"},Jt=["src","alt"],Qt={key:1},Zt={key:0,class:"wm-team__label"};function en(t,n,r,s,a,o){return o.visible?(e.openBlock(),e.createElementBlock("div",Xt,[e.createElementVNode("div",{class:"wm-team__stack",style:e.normalizeStyle({width:o.stackWidth+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.members.slice(0,3),(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-team__pill",style:e.normalizeStyle({left:l*13+"px",zIndex:3-l,background:o.colorFor(i)})},[i.avatar_url?(e.openBlock(),e.createElementBlock("img",{key:0,src:i.avatar_url,alt:i.name||""},null,8,Jt)):(e.openBlock(),e.createElementBlock("span",Qt,e.toDisplayString(o.initialsFor(i)),1))],4))),128))],4),r.responseLabel?(e.openBlock(),e.createElementBlock("span",Zt,e.toDisplayString(r.responseLabel),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}const Me=S(Yt,[["render",en],["__scopeId","data-v-e49a9063"]]),tn={name:"WmHeader",components:{AIAvatar:H,TeamAvatars:Me},inject:{t:{default:()=>T()}},props:{title:{type:String,default:"Nouvelle conversation"},showBack:{type:Boolean,default:!1},teamMembers:{type:Array,default:()=>[]},responseLabel:{type:String,default:""},showClose:{type:Boolean,default:!0},showMore:{type:Boolean,default:!0},moreActive:{type:Boolean,default:!1},showIdentity:{type:Boolean,default:!0},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["back","close","more"],computed:{hasTeam(){return Array.isArray(this.teamMembers)&&this.teamMembers.length>0},displayedTeamMembers(){const t=Array.isArray(this.teamMembers)?this.teamMembers:[];if(t.length<=3)return t;const n=new Date().getHours()%t.length,r=[];for(let s=0;s<3;s++)r.push(t[(n+s)%t.length]);return r}}},nn={class:"wm-header"},rn=["aria-label"],on={key:1,style:{width:"30px",height:"30px","flex-shrink":"0"}},an={class:"wm-header__avatar"},sn={class:"wm-header__main"},ln={class:"wm-header__title"},cn={key:3,class:"wm-header__fill"},dn={class:"wm-header__actions"},un=["aria-label","title"],mn=["aria-label","title"];function hn(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar"),l=e.resolveComponent("TeamAvatars");return e.openBlock(),e.createElementBlock("div",nn,[r.showBack?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-header__icon","aria-label":o.t("header.backToHome"),onClick:n[0]||(n[0]=f=>t.$emit("back"))},[...n[3]||(n[3]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M19 12H5M12 5l-7 7 7 7"})],-1)])],8,rn)):(e.openBlock(),e.createElementBlock("div",on)),r.showIdentity?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createElementVNode("div",an,[e.createVNode(i,{size:30,name:r.agentName,"image-url":r.agentAvatarUrl},null,8,["name","image-url"])]),e.createElementVNode("div",sn,[e.createElementVNode("div",ln,e.toDisplayString(r.title),1)]),o.hasTeam?(e.openBlock(),e.createBlock(l,{key:0,members:o.displayedTeamMembers,"response-label":""},null,8,["members"])):e.createCommentVNode("",!0)],64)):(e.openBlock(),e.createElementBlock("div",cn)),e.createElementVNode("div",dn,[r.showMore?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["wm-header__icon",{"wm-header__icon--active":r.moreActive}]),"aria-label":o.t("header.moreOptions"),title:o.t("header.moreOptions"),onClick:n[1]||(n[1]=f=>t.$emit("more"))},[...n[4]||(n[4]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true"},[e.createElementVNode("circle",{cx:"12",cy:"5",r:"1.6"}),e.createElementVNode("circle",{cx:"12",cy:"12",r:"1.6"}),e.createElementVNode("circle",{cx:"12",cy:"19",r:"1.6"})],-1)])],10,un)):e.createCommentVNode("",!0),r.showClose?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-header__icon","aria-label":o.t("header.closeWidget"),title:o.t("header.closeWidget"),onClick:n[2]||(n[2]=f=>t.$emit("close"))},[...n[5]||(n[5]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,mn)):e.createCommentVNode("",!0)])])}const Te=S(tn,[["render",hn],["__scopeId","data-v-7af4c118"]]),_e={book:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253",changelog:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2",status:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z",chat:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z",link:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"},fn={name:"WmOnboarding",components:{AIAvatar:H,HumanAvatar:Q},inject:{t:{default:()=>T()},wmLocale:{default:()=>()=>"fr"}},props:{welcomeMessage:{type:String,default:""},subtitle:{type:String,default:""},agentName:{type:String,default:""},defaultIconUrl:{type:String,default:null},quickLinks:{type:Array,default:()=>[]},openThreads:{type:Array,default:()=>[]},busy:{type:Boolean,default:!1}},emits:["start","select","resume","view-history"],computed:{heroTitle(){return this.welcomeMessage?this.welcomeMessage:this.agentName?this.t("onboarding.greetingNamed",{name:this.agentName}):this.t("onboarding.greeting")},heroSub(){return this.subtitle||this.t("onboarding.heroSub")},isOddQuickLinks(){return this.quickLinks.length%2===1},quickLinksLayout(){return this.isOddQuickLinks?"wm-onb__qlist":"wm-onb__grid"},unreadThreads(){return this.openThreads.filter(t=>t.unread)}},methods:{iconPath(t){return _e[t]||_e.link},isExternalLink(t){const n=t==null?void 0:t.url;return!!n&&!n.startsWith("#")},safeIconUrl(t){return lt(t==null?void 0:t.icon_url)},cardInlineStyle(t){const n={};t!=null&&t.color&&Ce(t.color)&&(n["--card-color"]=t.color);const r=this.safeIconUrl(t);return r&&(n["--icon-url"]=`url("${r}")`),Object.keys(n).length?n:null},renderPreview(t){return me(t)},avatarComponent(t){var n;return((n=t==null?void 0:t.author)==null?void 0:n.type)==="agent_human"?"HumanAvatar":"AIAvatar"},avatarProps(t){const n=t==null?void 0:t.author;return(n==null?void 0:n.type)==="agent_human"?{size:40,name:n.name||"",avatarUrl:n.avatar_url||null}:{size:40,name:(n==null?void 0:n.name)||"",imageUrl:(n==null?void 0:n.avatar_url)||null}},isDefaultAvatar(t){const n=t==null?void 0:t.author;return!(n!=null&&n.avatar_url||n!=null&&n.name)},avatarWrapperClass(t){return this.isDefaultAvatar(t)&&!(t!=null&&t.unread)?"wm-onb__avatar--muted":null},formatTs(t){if(!t)return"";const n=new Date(t);if(Number.isNaN(n.getTime()))return"";const r=P(this.wmLocale()),s=new Date;if(n.toDateString()===s.toDateString())return n.toLocaleTimeString(r,{hour:"2-digit",minute:"2-digit"});if(s.getTime()-n.getTime()<7*864e5){const i=n.toLocaleDateString(r,{weekday:"short"});return i.charAt(0).toUpperCase()+i.slice(1)}return n.toLocaleDateString(r,{day:"2-digit",month:"2-digit"})}}},pn={class:"wm-onb"},gn={class:"wm-onb__hero"},_n={class:"wm-onb__hero-text"},yn={class:"wm-onb__title"},vn={class:"wm-onb__sub"},kn={class:"wm-onb__cta"},wn=["disabled"],bn={class:"wm-onb__startLabel"},En=["onClick"],Cn={class:"wm-onb__card-icon"},Bn=["aria-label"],Nn={key:1,width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.9","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},Sn=["d"],An={class:"wm-onb__card-body"},Vn={class:"wm-onb__card-title"},Mn={key:0,class:"wm-onb__card-sub"},Tn={key:0,class:"wm-onb__card-ext",width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},xn={key:1,class:"wm-onb__sheet"},Ln={key:0,class:"wm-onb__alertList"},On=["onClick"],Dn={key:0,class:"wm-onb__defaultAvatar"},In=["aria-label"],Rn={class:"wm-onb__alert-body"},Fn={class:"wm-onb__alert-title"},Pn=["innerHTML"],Un={class:"wm-onb__alert-meta"},zn={key:0,class:"wm-onb__alert-time"},jn={class:"wm-onb__alert-resume"},Hn={class:"wm-onb__historyLabel"},qn={class:"wm-onb__historyCount"};function Kn(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",pn,[e.createElementVNode("div",gn,[n[2]||(n[2]=e.createElementVNode("svg",{class:"wm-onb__hero-deco",width:"180",height:"180",viewBox:"0 0 180 180",fill:"none","aria-hidden":"true"},[e.createElementVNode("circle",{cx:"170",cy:"10",r:"105",stroke:"#5B5FEF","stroke-width":"1","stroke-dasharray":"1 5",opacity:"0.35"}),e.createElementVNode("circle",{cx:"170",cy:"10",r:"72",stroke:"#5B5FEF","stroke-width":"1","stroke-dasharray":"1 5",opacity:"0.5"}),e.createElementVNode("circle",{cx:"152",cy:"34",r:"2.5",fill:"#5B5FEF",opacity:"0.65"})],-1)),e.createVNode(i,{size:52,"image-url":r.defaultIconUrl},null,8,["image-url"]),e.createElementVNode("div",_n,[e.createElementVNode("div",yn,e.toDisplayString(o.heroTitle),1),e.createElementVNode("div",vn,e.toDisplayString(o.heroSub),1)])]),e.createElementVNode("div",kn,[e.createElementVNode("button",{type:"button",class:"wm-onb__startBtn",disabled:r.busy,onClick:n[0]||(n[0]=l=>t.$emit("start"))},[n[3]||(n[3]=e.createElementVNode("span",{class:"wm-onb__startIcon"},[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.4","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M12 5v14M5 12h14"})])],-1)),e.createElementVNode("span",bn,e.toDisplayString(r.busy?"…":o.t("onboarding.start")),1),n[4]||(n[4]=e.createElementVNode("svg",{class:"wm-onb__startArrow",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M5 12h14M13 5l7 7-7 7"})],-1))],8,wn)]),r.quickLinks.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(o.quickLinksLayout)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.quickLinks,(l,f)=>(e.openBlock(),e.createElementBlock("button",{key:f,type:"button",class:e.normalizeClass(["wm-onb__card",{"wm-onb__card--row":o.isOddQuickLinks}]),style:e.normalizeStyle(o.cardInlineStyle(l)),onClick:y=>t.$emit("select",l)},[e.createElementVNode("span",Cn,[o.safeIconUrl(l)?(e.openBlock(),e.createElementBlock("span",{key:0,class:"wm-onb__card-iconImg",role:"img","aria-label":l.label||""},null,8,Bn)):(e.openBlock(),e.createElementBlock("svg",Nn,[e.createElementVNode("path",{d:o.iconPath(l.icon)},null,8,Sn)]))]),e.createElementVNode("span",An,[e.createElementVNode("span",Vn,e.toDisplayString(l.label),1),l.subtitle?(e.openBlock(),e.createElementBlock("span",Mn,e.toDisplayString(l.subtitle),1)):e.createCommentVNode("",!0)]),o.isExternalLink(l)?(e.openBlock(),e.createElementBlock("svg",Tn,[...n[5]||(n[5]=[e.createElementVNode("path",{d:"M7 17L17 7M9 7h8v8"},null,-1)])])):e.createCommentVNode("",!0)],14,En))),128))],2)):e.createCommentVNode("",!0),o.unreadThreads.length||r.openThreads.length?(e.openBlock(),e.createElementBlock("div",xn,[o.unreadThreads.length?(e.openBlock(),e.createElementBlock("div",Ln,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.unreadThreads,l=>(e.openBlock(),e.createElementBlock("button",{key:l.id,type:"button",class:"wm-onb__alert",onClick:f=>t.$emit("resume",l)},[e.createElementVNode("span",{class:e.normalizeClass(["wm-onb__alert-avatar",o.avatarWrapperClass(l)])},[o.isDefaultAvatar(l)?(e.openBlock(),e.createElementBlock("span",Dn,[...n[6]||(n[6]=[e.createElementVNode("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})],-1)])])):(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.avatarComponent(l)),e.mergeProps({key:1,ref_for:!0},o.avatarProps(l)),null,16)),e.createElementVNode("span",{class:"wm-onb__alert-dot","aria-label":o.t("onboarding.unread")},null,8,In)],2),e.createElementVNode("span",Rn,[e.createElementVNode("span",Fn,e.toDisplayString(l.title),1),e.createElementVNode("span",{class:"wm-onb__alert-preview",innerHTML:o.renderPreview(l.preview)},null,8,Pn)]),e.createElementVNode("span",Un,[o.formatTs(l._ts)?(e.openBlock(),e.createElementBlock("span",zn,e.toDisplayString(o.formatTs(l._ts)),1)):e.createCommentVNode("",!0),e.createElementVNode("span",jn,e.toDisplayString(o.t("onboarding.resume")),1)])],8,On))),128))])):e.createCommentVNode("",!0),r.openThreads.length?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-onb__historyLink",onClick:n[1]||(n[1]=l=>t.$emit("view-history"))},[n[7]||(n[7]=e.createElementVNode("span",{class:"wm-onb__historyIcon"},[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"})])],-1)),e.createElementVNode("span",Hn,e.toDisplayString(o.t("onboarding.allConversations")),1),e.createElementVNode("span",qn,e.toDisplayString(r.openThreads.length),1),n[8]||(n[8]=e.createElementVNode("svg",{class:"wm-onb__historyChev",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M9 18l6-6-6-6"})],-1))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])}const xe=S(fn,[["render",Kn],["__scopeId","data-v-f4df454a"]]),$n={name:"WmHistory",components:{AIAvatar:H,HumanAvatar:Q},inject:{t:{default:()=>T()},wmLocale:{default:()=>()=>"fr"}},props:{threads:{type:Array,default:()=>[]}},emits:["resume"],data(){return{query:""}},computed:{filteredThreads(){const t=this.query.trim().toLowerCase();return t?this.threads.filter(n=>(n.title||"").toLowerCase().includes(t)||(n.preview||"").toLowerCase().includes(t)):this.threads}},methods:{renderPreview(t){return me(t)},avatarComponent(t){var n;return((n=t==null?void 0:t.author)==null?void 0:n.type)==="agent_human"?"HumanAvatar":"AIAvatar"},avatarProps(t){const n=t==null?void 0:t.author;return(n==null?void 0:n.type)==="agent_human"?{size:40,name:n.name||"",avatarUrl:n.avatar_url||null}:{size:40,name:(n==null?void 0:n.name)||"",imageUrl:(n==null?void 0:n.avatar_url)||null}},isDefaultAvatar(t){const n=t==null?void 0:t.author;return!(n!=null&&n.avatar_url||n!=null&&n.name)},avatarWrapperClass(t){return this.isDefaultAvatar(t)&&!(t!=null&&t.unread)?"wm-hist__avatar--muted":null},formatTs(t){if(!t)return"";const n=new Date(t);if(Number.isNaN(n.getTime()))return"";const r=P(this.wmLocale()),s=new Date;if(n.toDateString()===s.toDateString())return n.toLocaleTimeString(r,{hour:"2-digit",minute:"2-digit"});if(s.getTime()-n.getTime()<7*864e5){const i=n.toLocaleDateString(r,{weekday:"short"});return i.charAt(0).toUpperCase()+i.slice(1)}return n.toLocaleDateString(r,{day:"2-digit",month:"2-digit"})}}},Wn={class:"wm-hist"},Gn={class:"wm-hist__search"},Yn=["placeholder","aria-label"],Xn={class:"wm-hist__list"},Jn=["onClick"],Qn={key:0,class:"wm-hist__defaultAvatar"},Zn=["aria-label"],er={class:"wm-hist__thread-body"},tr={class:"wm-hist__thread-title"},nr=["innerHTML"],rr={class:"wm-hist__thread-meta"},or={key:0,class:"wm-hist__thread-time"},ar={key:0,class:"wm-hist__empty"};function sr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",Wn,[e.createElementVNode("div",Gn,[n[1]||(n[1]=e.createElementVNode("span",{class:"wm-hist__searchIcon"},[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 21l-4.35-4.35M11 17a6 6 0 100-12 6 6 0 000 12z"})])],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":n[0]||(n[0]=i=>a.query=i),type:"text",placeholder:o.t("onboarding.search"),"aria-label":o.t("onboarding.search")},null,8,Yn),[[e.vModelText,a.query]])]),e.createElementVNode("div",Xn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.filteredThreads,i=>(e.openBlock(),e.createElementBlock("button",{key:i.id,type:"button",class:e.normalizeClass(["wm-hist__thread",{"wm-hist__thread--unread":i.unread}]),onClick:l=>t.$emit("resume",i)},[e.createElementVNode("span",{class:e.normalizeClass(["wm-hist__thread-avatar",o.avatarWrapperClass(i)])},[o.isDefaultAvatar(i)?(e.openBlock(),e.createElementBlock("span",Qn,[...n[2]||(n[2]=[e.createElementVNode("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})],-1)])])):(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.avatarComponent(i)),e.mergeProps({key:1,ref_for:!0},o.avatarProps(i)),null,16)),i.unread?(e.openBlock(),e.createElementBlock("span",{key:2,class:"wm-hist__thread-dot","aria-label":o.t("onboarding.unread")},null,8,Zn)):e.createCommentVNode("",!0)],2),e.createElementVNode("span",er,[e.createElementVNode("span",tr,e.toDisplayString(i.title),1),e.createElementVNode("span",{class:"wm-hist__thread-preview",innerHTML:o.renderPreview(i.preview)},null,8,nr)]),e.createElementVNode("span",rr,[o.formatTs(i._ts)?(e.openBlock(),e.createElementBlock("span",or,e.toDisplayString(o.formatTs(i._ts)),1)):e.createCommentVNode("",!0),n[3]||(n[3]=e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",class:"wm-hist__thread-chev","aria-hidden":"true"},[e.createElementVNode("path",{d:"M5 12h14M13 5l7 7-7 7"})],-1))])],10,Jn))),128)),o.filteredThreads.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",ar,e.toDisplayString(a.query?o.t("onboarding.noResults",{query:a.query}):o.t("onboarding.noConversations")),1))])])}const ir=S($n,[["render",sr],["__scopeId","data-v-60929fb5"]]);function lr(t){return typeof t!="string"?"":t.replace(/`([^`]+)`/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(new RegExp("(?<!\\*)\\*([^*]+)\\*(?!\\*)","g"),"$1").replace(/__([^_]+)__/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\s+/g," ").trim()}const cr={name:"WmActionResult",props:{state:{type:String,default:"success"},label:{type:String,required:!0},detail:{type:String,default:""}},computed:{detailText(){return lr(this.detail)}}},dr={class:"wm-result__icon","aria-hidden":"true"},ur={key:0,width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.8","stroke-linecap":"round","stroke-linejoin":"round"},mr={key:1,width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.6","stroke-linecap":"round","stroke-linejoin":"round"},hr={key:2,width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.4","stroke-linecap":"round","stroke-linejoin":"round"},fr={key:3,width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.2","stroke-linecap":"round","stroke-linejoin":"round"},pr={class:"wm-result__body"},gr={class:"wm-result__label"},_r={class:"wm-result__detail"};function yr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-result",`wm-result--${r.state}`])},[e.createElementVNode("span",dr,[r.state==="success"?(e.openBlock(),e.createElementBlock("svg",ur,[...n[0]||(n[0]=[e.createElementVNode("path",{d:"M20 6L9 17l-5-5"},null,-1)])])):r.state==="rejected"?(e.openBlock(),e.createElementBlock("svg",mr,[...n[1]||(n[1]=[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"},null,-1)])])):r.state==="awaiting"?(e.openBlock(),e.createElementBlock("svg",hr,[...n[2]||(n[2]=[e.createElementVNode("circle",{cx:"12",cy:"12",r:"10"},null,-1),e.createElementVNode("polyline",{points:"12 7 12 12 15 14"},null,-1)])])):(e.openBlock(),e.createElementBlock("svg",fr,[...n[3]||(n[3]=[e.createElementVNode("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"},null,-1),e.createElementVNode("line",{x1:"12",y1:"9",x2:"12",y2:"13"},null,-1),e.createElementVNode("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"},null,-1)])]))]),e.createElementVNode("span",pr,[e.createElementVNode("span",gr,e.toDisplayString(r.label),1),o.detailText?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[n[4]||(n[4]=e.createElementVNode("span",{class:"wm-result__sep","aria-hidden":"true"}," · ",-1)),e.createElementVNode("span",_r,e.toDisplayString(o.detailText),1)],64)):e.createCommentVNode("",!0)])],2)}const Le=S(cr,[["render",yr],["__scopeId","data-v-7284acd0"]]),vr={name:"WmArtifactFormResponse",inject:{t:{default:()=>T()}},props:{data:{type:Object,required:!0}},computed:{fields(){var t;return Array.isArray((t=this.data)==null?void 0:t.fields)?this.data.fields:[]}}},kr={class:"wm-art wm-art--formResponse"},wr={class:"wm-art__head"},br={class:"wm-art__title"},Er={class:"wm-art__badge wm-art__badge--success"},Cr={class:"wm-art__body"},Br={class:"wm-art__fieldLabel"};function Nr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",kr,[e.createElementVNode("div",wr,[e.createElementVNode("div",br,e.toDisplayString(r.data.title||o.t("form.title")),1),e.createElementVNode("span",Er,[n[0]||(n[0]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("polyline",{points:"20 6 9 17 4 12"})],-1)),e.createTextVNode(" "+e.toDisplayString(o.t("form.sent")),1)])]),e.createElementVNode("div",Cr,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.fields,(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",Br,e.toDisplayString(i.label),1),e.createElementVNode("div",{class:e.normalizeClass(["wm-art__fieldValue",{"wm-art__fieldValue--multi":i.multiline}])},e.toDisplayString(i.value),3)]))),128))])])}const Oe=S(vr,[["render",Nr],["__scopeId","data-v-713aecf1"]]),Sr={name:"WmArtifactInfoCard",props:{data:{type:Object,required:!0}},computed:{fields(){var t;return Array.isArray((t=this.data)==null?void 0:t.fields)?this.data.fields:[]},hasBody(){var t;return!!((t=this.data)!=null&&t.body)||this.fields.length>0}}},Ar={class:"wm-art wm-art--infoCard"},Vr={key:0,class:"wm-art__image"},Mr=["src","alt"],Tr={class:"wm-art__head"},xr={class:"wm-art__headMain"},Lr={class:"wm-art__title"},Or={key:0,class:"wm-art__subtitle"},Dr={key:1,class:"wm-art__body"},Ir={key:0,class:"wm-art__text"},Rr={class:"wm-art__fieldLabel"};function Fr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",Ar,[r.data.image_url?(e.openBlock(),e.createElementBlock("figure",Vr,[e.createElementVNode("img",{src:r.data.image_url,alt:r.data.title||"",loading:"lazy"},null,8,Mr)])):e.createCommentVNode("",!0),e.createElementVNode("div",Tr,[e.createElementVNode("div",xr,[e.createElementVNode("div",Lr,e.toDisplayString(r.data.title),1),r.data.subtitle?(e.openBlock(),e.createElementBlock("div",Or,e.toDisplayString(r.data.subtitle),1)):e.createCommentVNode("",!0)]),r.data.badge&&r.data.badge.label?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["wm-art__badge",`wm-art__badge--${r.data.badge.tone||"neutral"}`])},e.toDisplayString(r.data.badge.label),3)):e.createCommentVNode("",!0)]),o.hasBody?(e.openBlock(),e.createElementBlock("div",Dr,[r.data.body?(e.openBlock(),e.createElementBlock("div",Ir,e.toDisplayString(r.data.body),1)):e.createCommentVNode("",!0),o.fields.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(o.fields,(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",Rr,e.toDisplayString(i.label),1),e.createElementVNode("div",{class:e.normalizeClass(["wm-art__fieldValue",{"wm-art__fieldValue--multi":i.multiline}])},e.toDisplayString(i.value),3)]))),128)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])}const De=S(Sr,[["render",Fr],["__scopeId","data-v-7eae0e4a"]]);function Pr(t,n,r){if(!t)return"";const s=new Date(t);if(Number.isNaN(s.getTime()))return t;const a=s.toLocaleDateString(n,{day:"numeric",month:"long",year:"numeric"}),o=s.toLocaleTimeString(n,{hour:"2-digit",minute:"2-digit"});return`${a}${r}${o}`}const Ur={name:"WmArtifactTicket",inject:{t:{default:()=>T()},wmLocale:{default:()=>()=>"fr"}},props:{data:{type:Object,required:!0}},computed:{fields(){var t;return Array.isArray((t=this.data)==null?void 0:t.fields)?this.data.fields:[]},formattedDate(){var t;return Pr((t=this.data)==null?void 0:t.created_at,P(this.wmLocale()),this.t("ticket.dateAt"))}},methods:{isPriority(t){return/priorit|^prio$/i.test(String(t||"").trim())},isDate(t){return/date|échéanc|echeanc|deadline|due|créé|cree/i.test(String(t||"").trim())},priorityLevel(t){const n=String(t||"").toLowerCase();return/high|haute|élev|elev|critic|critiq|urgent/.test(n)?3:/low|basse|faible|minor/.test(n)?1:2}}},zr={class:"wm-art wm-art--ticket"},jr={class:"wm-art__head wm-tk__head"},Hr={class:"wm-art__title wm-tk__title"},qr={class:"wm-tk__sub"},Kr={class:"wm-tk__ref"},$r={key:0,class:"wm-tk__text"},Wr={key:0,class:"wm-art__body"},Gr={class:"wm-art__fieldLabel"},Yr=["data-level"],Xr={key:1,class:"wm-tk__date",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},Jr={key:1,class:"wm-art__footer wm-tk__footer"};function Qr(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",zr,[e.createElementVNode("div",jr,[e.createElementVNode("div",Hr,e.toDisplayString(r.data.title),1),e.createElementVNode("div",qr,[e.createElementVNode("div",Kr,[n[0]||(n[0]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M20 12a2 2 0 0 1 2-2V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v4a2 2 0 0 1 0 4v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 1-2-2z"}),e.createElementVNode("path",{d:"M13 5v2M13 17v2M13 11v2"})],-1)),e.createElementVNode("span",null,e.toDisplayString(r.data.reference),1)]),e.createElementVNode("span",{class:e.normalizeClass(["wm-art__badge","wm-tk__badge",`wm-art__badge--${r.data.status.tone||"neutral"}`])},[n[1]||(n[1]=e.createElementVNode("span",{class:"wm-tk__dot","aria-hidden":"true"},null,-1)),e.createTextVNode(" "+e.toDisplayString(r.data.status.label),1)],2)]),r.data.body?(e.openBlock(),e.createElementBlock("div",$r,e.toDisplayString(r.data.body),1)):e.createCommentVNode("",!0)]),o.fields.length?(e.openBlock(),e.createElementBlock("div",Wr,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.fields,(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",Gr,e.toDisplayString(i.label),1),e.createElementVNode("div",{class:e.normalizeClass(["wm-art__fieldValue",{"wm-art__fieldValue--multi":i.multiline}])},[o.isPriority(i.label)?(e.openBlock(),e.createElementBlock("svg",{key:0,class:"wm-tk__prio","data-level":o.priorityLevel(i.value),width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true"},[...n[2]||(n[2]=[e.createElementVNode("rect",{x:"1",y:"8",width:"2",height:"3",rx:"0.5"},null,-1),e.createElementVNode("rect",{x:"5",y:"5",width:"2",height:"6",rx:"0.5"},null,-1),e.createElementVNode("rect",{x:"9",y:"2",width:"2",height:"9",rx:"0.5"},null,-1)])],8,Yr)):o.isDate(i.label)?(e.openBlock(),e.createElementBlock("svg",Xr,[...n[3]||(n[3]=[e.createElementVNode("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"},null,-1),e.createElementVNode("path",{d:"M16 2v4M8 2v4M3 10h18"},null,-1)])])):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(i.value),1)],2)]))),128))])):e.createCommentVNode("",!0),r.data.created_at?(e.openBlock(),e.createElementBlock("div",Jr,[n[4]||(n[4]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),e.createElementVNode("path",{d:"M16 2v4M8 2v4M3 10h18"})],-1)),e.createElementVNode("span",null,e.toDisplayString(o.formattedDate),1)])):e.createCommentVNode("",!0)])}const Ie=S(Ur,[["render",Qr],["__scopeId","data-v-5f30c914"]]),Zr={form_response:Oe,info_card:De,ticket:Ie},eo={name:"WmArtifactRenderer",props:{artifact:{type:Object,required:!0}},computed:{component(){var n;const t=(n=this.artifact)==null?void 0:n.kind;return t&&Zr[t]||null}}};function to(t,n,r,s,a,o){return o.component?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.component),{key:0,data:r.artifact.data},null,8,["data"])):e.createCommentVNode("",!0)}const Re=S(eo,[["render",to]]),no={name:"WmAttachmentPreview",inject:{signAttachmentFn:{default:null},t:{default:()=>T()}},props:{attachment:{type:Object,required:!0}},data(){return{url:null,loading:!1}},computed:{kind(){var r,s;const t=(r=this.attachment)==null?void 0:r.type;if(t)return t;const n=(((s=this.attachment)==null?void 0:s.mime_type)||"").toLowerCase();return n.startsWith("image/")?"image":n.startsWith("audio/")?"audio":n.startsWith("video/")?"video":"file"},displayName(){var t,n,r;return((n=(t=this.attachment)==null?void 0:t.metadata)==null?void 0:n.name)||((r=this.attachment)==null?void 0:r.name)||this.guessNameFromPath()||this.t("attachment.fallbackName")},safeHref(){const t=String(this.url||"").trim();return/^(https?:\/\/|blob:|data:image\/)/i.test(t)?t:"#"},sizeLabel(){var n;const t=(n=this.attachment)==null?void 0:n.size_bytes;return t?t<1024?this.t("attachment.bytes",{size:t}):t<1024*1024?this.t("attachment.kilobytes",{size:(t/1024).toFixed(0)}):this.t("attachment.megabytes",{size:(t/(1024*1024)).toFixed(1)}):""}},watch:{"attachment.path":{handler(){this.refresh()},immediate:!0}},methods:{guessNameFromPath(){var r;return((((r=this.attachment)==null?void 0:r.path)||"").split("/").pop()||"").replace(/^[0-9a-f-]{8,}-/,"")},async refresh(){var t;if(!(!((t=this.attachment)!=null&&t.path)||!this.signAttachmentFn)){this.loading=!0;try{this.url=await this.signAttachmentFn(this.attachment.path)}finally{this.loading=!1}}},onFileClick(t){this.safeHref==="#"&&t.preventDefault()}}},ro=["href"],oo=["src","alt"],ao=["src"],so=["src"],io=["href","download"],lo={class:"wm-att__main"},co={class:"wm-att__name"},uo={key:0,class:"wm-att__meta"},mo={key:0,class:"wm-att__spin","aria-hidden":"true"};function ho(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-att",["wm-att--"+(o.kind||"file")]])},[o.kind==="image"&&a.url?(e.openBlock(),e.createElementBlock("a",{key:0,href:o.safeHref,target:"_blank",rel:"noopener",class:"wm-att__imgWrap"},[e.createElementVNode("img",{src:a.url,alt:o.displayName,loading:"lazy"},null,8,oo)],8,ro)):o.kind==="audio"&&a.url?(e.openBlock(),e.createElementBlock("audio",{key:1,src:a.url,controls:"",preload:"metadata"},null,8,ao)):o.kind==="video"&&a.url?(e.openBlock(),e.createElementBlock("video",{key:2,src:a.url,controls:"",preload:"metadata"},null,8,so)):(e.openBlock(),e.createElementBlock("a",{key:3,class:"wm-att__file",href:o.safeHref,download:o.displayName,target:"_blank",rel:"noopener",onClick:n[0]||(n[0]=(...i)=>o.onFileClick&&o.onFileClick(...i))},[n[1]||(n[1]=e.createElementVNode("span",{class:"wm-att__icon"},[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),e.createElementVNode("path",{d:"M14 2v6h6"})])],-1)),e.createElementVNode("span",lo,[e.createElementVNode("span",co,e.toDisplayString(o.displayName),1),o.sizeLabel?(e.openBlock(),e.createElementBlock("span",uo,e.toDisplayString(o.sizeLabel),1)):e.createCommentVNode("",!0)]),a.loading?(e.openBlock(),e.createElementBlock("span",mo)):e.createCommentVNode("",!0)],8,io))],2)}const Fe=S(no,[["render",ho],["__scopeId","data-v-0c877a62"]]),fo={name:"WmBubble",props:{role:{type:String,default:"ai"},text:{type:String,default:""}},computed:{rendered(){return Ae(this.text)}}},po=["innerHTML"];function go(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-bubble","wm-bubble--"+r.role])},[e.renderSlot(t.$slots,"default",{},()=>[e.createElementVNode("span",{innerHTML:o.rendered},null,8,po)],!0)],2)}const Pe=S(fo,[["render",go],["__scopeId","data-v-7ab13147"]]),_o={name:"WmTyping"},yo={class:"wm-typing"};function vo(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",yo,[...n[0]||(n[0]=[e.createElementVNode("span",{style:{"animation-delay":"0s"}},null,-1),e.createElementVNode("span",{style:{"animation-delay":"0.2s"}},null,-1),e.createElementVNode("span",{style:{"animation-delay":"0.4s"}},null,-1)])])}const Ue=S(_o,[["render",vo],["__scopeId","data-v-df2447fd"]]);function j(t){return t?t.client_msg_id||t.id:""}const ko={transferred_to_human:"system.transferredToHuman",assigned:"system.assigned",unassigned:"system.unassigned",resolved:"system.resolved",reopened:"system.reopened",idle:"system.idle"},wo=80,bo=200,Eo={name:"WmMessageList",components:{AIAvatar:H,HumanAvatar:Q,Bubble:Pe,Typing:Ue,ActionResult:Le,AttachmentPreview:Fe,ArtifactRenderer:Re},inject:{t:{default:()=>T()},wmLocale:{default:()=>()=>"fr"}},props:{messages:{type:Array,default:()=>[]},streamingActive:{type:Boolean,default:!1},dateLabel:{type:String,default:""},conversationId:{type:[String,Number],default:null},loadingMore:{type:Boolean,default:!1},hasMore:{type:Boolean,default:!1},unreadAnchorId:{type:Number,default:null},unreadBoundaryTs:{type:String,default:""},aiAgentName:{type:String,default:""},aiAgentAvatarUrl:{type:String,default:null}},emits:["load-more"],data(){return{silentFades:!1,widthByKey:Object.freeze({}),showScrollDown:!1,pressedItemKey:null}},computed:{historyExhausted(){return!this.hasMore&&!this.loadingMore&&this.messages.length>=20},groups(){var r,s,a,o;const t=[];for(const i of this.messages){const l=this.roleOf(i);if(l==="system"){if(((r=i==null?void 0:i.payload)==null?void 0:r.event)==="action_admin_pending"){const _=t[t.length-1];_&&_.role==="ai"?_.messages.push(i):t.push({key:`g-${j(i)}`,role:"ai",agentName:"",agentAvatarUrl:null,messages:[i],items:[]});continue}t.push({key:`sys-${j(i)}`,role:l,messages:[i],items:[],systemLabel:this.systemLabel(i)});continue}const f=t[t.length-1];f&&f.role===l&&(l==="ai"||f.agentName===(((s=i==null?void 0:i.author)==null?void 0:s.name)||""))?f.messages.push(i):t.push({key:`g-${j(i)}`,role:l,agentName:((a=i==null?void 0:i.author)==null?void 0:a.name)||"",agentAvatarUrl:((o=i==null?void 0:i.author)==null?void 0:o.avatar_url)||null,messages:[i],items:[]})}for(const i of t){if(i.role==="system")continue;const l=[];for(const f of i.messages)for(const y of this.itemsOf(f))l.push(y);i.items=l}const n=[];for(const i of t){if(i.role!=="system"&&!i.items.length)continue;const l=n[n.length-1];if(l&&l.role!=="system"&&l.role===i.role&&(i.role==="ai"||l.agentName===i.agentName)){l.messages.push(...i.messages),l.items.push(...i.items);continue}n.push(i)}for(const i of n)i.role!=="system"&&(i.key=this.stableGroupKey(i.messages));return n},unreadGroupKey(){if(this.unreadAnchorId==null)return null;const t=this.unreadAnchorId,n=this.unreadBoundaryTs;for(const r of this.groups){if(r.role==="user"||r.role==="system"||!r.items.length)continue;const s=r.messages[0];if(!s)continue;const a=R(s.id);if(a!=null&&!(a<=t)&&!(n&&s.created_at&&s.created_at>n))return r.key}return null}},watch:{messages:{handler:"snapshotAndRestore",deep:!0},conversationId(t,n){t!==n&&(this._groupIdByMsgKey=null,this.silentFades=!1)},loadingMore(t){t||(this._pendingLoadMore=!1),t&&(this.silentFades=!0),this.snapshotAndRestore()},streamingActive:"snapshotAndRestore"},mounted(){this._lastSeenConvId=this.conversationId,this.scrollToBottom(),this._measureFrame=null,this._ro=new ResizeObserver(()=>this.scheduleMeasure()),this.$refs.scrollEl&&this._ro.observe(this.$refs.scrollEl),this.$nextTick(()=>this.measureRows())},beforeUnmount(){var t;(t=this._ro)==null||t.disconnect(),this._measureFrame&&cancelAnimationFrame(this._measureFrame),this._pressTimer&&clearTimeout(this._pressTimer)},updated(){this.scheduleMeasure()},methods:{messageKey:j,stableGroupKey(t){this._groupIdByMsgKey||(this._groupIdByMsgKey=new Map,this._groupIdCounter=0);const n=this._groupIdByMsgKey;let r=null;for(const s of t){const a=j(s);if(a&&n.has(a)){r=n.get(a);break}}r==null&&(r=++this._groupIdCounter);for(const s of t){const a=j(s);a&&n.set(a,r)}return`g-${r}`},isAtBottom(t){return t.scrollHeight-t.scrollTop-t.clientHeight<=wo},onScroll(){const t=this.$refs.scrollEl;t&&(this.showScrollDown=!this.isAtBottom(t),!(this.loadingMore||!this.hasMore)&&(this._pendingLoadMore||t.scrollTop<=bo&&(this._pendingLoadMore=!0,this.$emit("load-more"))))},snapshotAndRestore(){const t=this.$refs.scrollEl;if(!t||this._scrollSnap)return;const n=this._lastSeenConvId!==this.conversationId;this._lastSeenConvId=this.conversationId;const r=this.isAtBottom(t);let s=null;if(!n&&!r){const o=this.pickAnchor(t);if(o!=null&&o.rowKey){const i=this.findRowByKey(t,o.rowKey);if(i){const l=t.getBoundingClientRect().top;s={rowKey:o.rowKey,relY:i.getBoundingClientRect().top-l}}}}const a={forceBottom:n,wasPinned:r,anchor:s};this._scrollSnap=a,this.$nextTick(()=>{if(this._scrollSnap=null,a.forceBottom||a.wasPinned){t.scrollTop=t.scrollHeight;return}if(!a.anchor)return;const o=()=>{const i=a.anchor,l=this.findRowByKey(t,i.rowKey);if(!l)return;const y=l.getBoundingClientRect().top-t.getBoundingClientRect().top-i.relY;Math.abs(y)>.5&&(t.scrollTop+=y)};o(),requestAnimationFrame(()=>{o(),requestAnimationFrame(o)})})},pickAnchor(t){const n=t.getBoundingClientRect().top,r=t.querySelectorAll(".wm-list__row[data-row-key]");let s=null;for(const a of r)if(s||(s=a),a.getBoundingClientRect().bottom>=n)return{rowKey:a.dataset.rowKey};return s?{rowKey:s.dataset.rowKey}:null},findRowByKey(t,n){if(!n)return null;const r=typeof CSS<"u"&&CSS.escape?CSS.escape(n):n.replace(/["\\]/g,"\\$&");return t.querySelector(`.wm-list__row[data-row-key="${r}"]`)},roleOf(t){var r,s;if((t==null?void 0:t.type)==="system"||((r=t==null?void 0:t.payload)==null?void 0:r.type)==="system")return"system";const n=(s=t==null?void 0:t.author)==null?void 0:s.type;return n==="user"?"user":n==="agent_human"?"human":"ai"},roleLabel(t){if(t.role==="human")return t.agentName||this.t("common.agent");const n=this.t("common.aiAssistant");return this.aiAgentName?`${this.aiAgentName} • ${n}`:n},itemsOf(t){var n;if(!t)return[];if(t.type==="system"&&((n=t==null?void 0:t.payload)==null?void 0:n.event)==="action_admin_pending")return[{message:t,partKey:"main",renderAs:"admin-pending",kind:{top:"bubble",bottom:"bubble"}}];if(t.type==="action"&&t.payload&&t.payload.state!=="pending"){const r=[{message:t,partKey:"main",renderAs:"action",kind:{top:"bubble",bottom:"bubble"}}];return this.actionArtifact(t)&&r.push({message:t,partKey:"artifact",renderAs:"artifact-of-action",kind:{top:"card",bottom:"card"}}),r}return this.artifactOf(t)?[{message:t,partKey:"main",renderAs:"artifact",kind:{top:"card",bottom:"card"}}]:t.text_md||this.attachmentsOf(t).length?[{message:t,partKey:"main",renderAs:"bubble",kind:{top:"bubble",bottom:"bubble"}}]:[]},cornersFor(t,n){var U,q,K;const r=t.items,s=(U=r[n])==null?void 0:U.kind,a=(q=r[n-1])==null?void 0:q.kind,o=(K=r[n+1])==null?void 0:K.kind,i=t.role==="user",l=14,f=4,y=a==null?void 0:a.bottom,_=o==null?void 0:o.top,C=this.widthByKey[this.rowKeyOf(t,n)],N=this.widthByKey[this.rowKeyOf(t,n-1)],k=this.widthByKey[this.rowKeyOf(t,n+1)],L=.5,b=(I,$,F)=>I!=null&&C!=null?I+L>=C:$===F||$==="card"&&F==="bubble";let V=l,M=l,A=l,D=l;return i?(y&&(M=f),(_||!o)&&(A=f),y&&b(N,y,s==null?void 0:s.top)&&(V=f),_&&b(k,_,s==null?void 0:s.bottom)&&(D=f)):(y&&(V=f),(_||!o)&&(D=f),y&&b(N,y,s==null?void 0:s.top)&&(M=f),_&&b(k,_,s==null?void 0:s.bottom)&&(A=f)),{tl:V,tr:M,br:A,bl:D}},cornersStyle(t,n){if(t.items.length<2)return null;const r=this.cornersFor(t,n);return{"--wm-r-tl":`${r.tl}px`,"--wm-r-tr":`${r.tr}px`,"--wm-r-br":`${r.br}px`,"--wm-r-bl":`${r.bl}px`}},rowKeyOf(t,n){var s;const r=(s=t==null?void 0:t.items)==null?void 0:s[n];return r?`${j(r.message)}-${r.partKey}`:""},scheduleMeasure(){this._measureFrame||(this._measureFrame=requestAnimationFrame(()=>{this._measureFrame=null,this.measureRows()}))},measureRows(){const t=this.$refs.scrollEl;if(!t)return;const n={};for(const o of t.querySelectorAll(".wm-list__row[data-row-key]")){const i=o.dataset.rowKey;if(!i)continue;const l=o.querySelector(".wm-bubble, .wm-result, .wm-art, .wm-list__body");if(!l)continue;const f=l.getBoundingClientRect().width;f>0&&(n[i]=f)}const r=this.widthByKey,s=Object.keys(r),a=Object.keys(n);if(s.length===a.length){let o=!0;for(const i of a)if(Math.abs((r[i]??0)-n[i])>.5){o=!1;break}if(o)return}this.widthByKey=Object.freeze(n)},onPressStart(t){this.onPressEnd(),this._pressTimer=setTimeout(()=>{this._pressTimer=null,this.pressedItemKey=t},400)},onPressEnd(){this._pressTimer&&(clearTimeout(this._pressTimer),this._pressTimer=null),this.pressedItemKey!==null&&(this.pressedItemKey=null)},timeOf(t){if(!(t!=null&&t.created_at))return"";try{return re(new Date(t.created_at),P(this.wmLocale()))}catch{return""}},lastTimeOf(t){const n=t.items[t.items.length-1],r=(n==null?void 0:n.message)||t.messages[t.messages.length-1];if(!(r!=null&&r.created_at))return"";try{return re(new Date(r.created_at),P(this.wmLocale()))}catch{return""}},hasTrailingOverlay(t){if(!t.messages.length)return!1;const n=t.messages[t.messages.length-1],r=t.items[t.items.length-1];return!!n&&(r==null?void 0:r.message)!==n},attachmentsOf(t){var r;const n=(r=t==null?void 0:t.payload)==null?void 0:r.attachments;return Array.isArray(n)?n:[]},artifactOf(t){var r;const n=(r=t==null?void 0:t.metadata)==null?void 0:r.artifact;return!n||typeof n!="object"||typeof n.kind!="string"?null:n},actionLabel(t){var n;return((n=t==null?void 0:t.payload)==null?void 0:n.name)||(t==null?void 0:t.text_md)||this.t("common.action")},actionDetail(t){var r,s,a,o,i,l;const n=t==null?void 0:t.payload;return n?n.state==="success"?((r=n.success)==null?void 0:r.summary)||((a=(s=n.success)==null?void 0:s.metadata)==null?void 0:a.description)||"":n.state==="rejected"?((o=n.rejected)==null?void 0:o.reason)||this.t("action.rejectedByUser"):n.state==="failure"&&(((i=n.failure)==null?void 0:i.summary)||((l=n.failure)==null?void 0:l.error))||"":""},actionArtifact(t){var r,s;const n=(s=(r=t==null?void 0:t.payload)==null?void 0:r.success)==null?void 0:s.artifact;return!n||typeof n!="object"||typeof n.kind!="string"?null:n},systemLabel(t){var a,o,i;const n=(a=t==null?void 0:t.payload)==null?void 0:a.event,r=ko[n],s=((o=t==null?void 0:t.metadata)==null?void 0:o.agent_name)||((i=t==null?void 0:t.author)==null?void 0:i.name)||this.t("messageList.anAgent");return r?this.t(r,{name:s}):(t==null?void 0:t.text_md)||this.t("messageList.conversationUpdate")},scrollToBottom(){const t=this.$refs.scrollEl;t&&(t.scrollTop=t.scrollHeight),this.showScrollDown=!1},scrollToBottomSmooth(){const t=this.$refs.scrollEl;t&&(typeof t.scrollTo=="function"?t.scrollTo({top:t.scrollHeight,behavior:"smooth"}):t.scrollTop=t.scrollHeight,this.showScrollDown=!1)}}},Co={class:"wm-list__wrap"},Bo={key:0,class:"wm-list__loadMore",role:"status","aria-live":"polite"},No={class:"wm-list__loadMore-lbl"},So={key:1,class:"wm-list__historyEnd"},Ao={key:2,class:"wm-list__sep"},Vo={class:"wm-list__sep-label"},Mo={key:0,class:"wm-list__sep wm-list__sep--unread"},To={class:"wm-list__sep-label wm-list__sep-label--unread"},xo={key:0,class:"wm-list__sysep"},Lo={class:"wm-list__sysep-label"},Oo=["data-row-key","onPointerdown"],Do={key:0,class:"wm-list__avatarSlot"},Io={key:5,class:"wm-list__body"},Ro={key:0},Fo={key:1,"aria-hidden":"true"},Po={key:2},Uo={key:0},zo={key:1,"aria-hidden":"true"},jo={key:2},Ho={key:3,class:"wm-list__row wm-list__row--ai fade-up"},qo={class:"wm-list__avatarSlot"},Ko=["aria-label","title"];function $o(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar"),l=e.resolveComponent("HumanAvatar"),f=e.resolveComponent("ActionResult"),y=e.resolveComponent("ArtifactRenderer"),_=e.resolveComponent("Bubble"),C=e.resolveComponent("AttachmentPreview"),N=e.resolveComponent("Typing");return e.openBlock(),e.createElementBlock("div",Co,[e.createElementVNode("div",{ref:"scrollEl",class:e.normalizeClass(["wm-list",{"wm-list--silent":a.silentFades}]),onScrollPassive:n[4]||(n[4]=(...k)=>o.onScroll&&o.onScroll(...k))},[r.loadingMore?(e.openBlock(),e.createElementBlock("div",Bo,[n[6]||(n[6]=e.createElementVNode("span",{class:"wm-list__loadMore-spinner","aria-hidden":"true"},null,-1)),e.createElementVNode("span",No,e.toDisplayString(o.t("messageList.loadingHistory")),1)])):o.historyExhausted?(e.openBlock(),e.createElementBlock("div",So,e.toDisplayString(o.t("messageList.conversationStart")),1)):e.createCommentVNode("",!0),r.dateLabel?(e.openBlock(),e.createElementBlock("div",Ao,[n[7]||(n[7]=e.createElementVNode("div",{class:"wm-list__line"},null,-1)),e.createElementVNode("span",Vo,e.toDisplayString(r.dateLabel),1),n[8]||(n[8]=e.createElementVNode("div",{class:"wm-list__line"},null,-1))])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.groups,(k,L)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:k.key},[k.key===o.unreadGroupKey?(e.openBlock(),e.createElementBlock("div",Mo,[n[9]||(n[9]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--unread"},null,-1)),e.createElementVNode("span",To,e.toDisplayString(o.t("messageList.unread")),1),n[10]||(n[10]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--unread"},null,-1))])):e.createCommentVNode("",!0),k.role==="system"||k.items.length?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["wm-list__group","wm-list__group--"+k.role])},[k.role==="system"?(e.openBlock(),e.createElementBlock("div",xo,[n[11]||(n[11]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--strong"},null,-1)),e.createElementVNode("span",Lo,e.toDisplayString(k.systemLabel),1),n[12]||(n[12]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--strong"},null,-1))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.items,(b,V)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${o.messageKey(b.message)}-${b.partKey}`},[e.createElementVNode("div",{"data-row-key":`${o.messageKey(b.message)}-${b.partKey}`,class:e.normalizeClass(["wm-list__row fade-up",["wm-list__row--"+k.role,{"is-pending":b.message._pending,"is-failed":b.message._failed}]]),style:e.normalizeStyle(o.cornersStyle(k,V)),onPointerdown:M=>o.onPressStart(`${o.messageKey(b.message)}-${b.partKey}`),onPointerup:n[0]||(n[0]=M=>o.onPressEnd()),onPointercancel:n[1]||(n[1]=M=>o.onPressEnd()),onPointerleave:n[2]||(n[2]=M=>o.onPressEnd()),onContextmenu:n[3]||(n[3]=e.withModifiers(()=>{},["prevent"]))},[k.role!=="user"?(e.openBlock(),e.createElementBlock("div",Do,[V===k.items.length-1?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[k.role==="ai"?(e.openBlock(),e.createBlock(i,{key:0,size:26,tail:!0,name:r.aiAgentName,"image-url":r.aiAgentAvatarUrl},null,8,["name","image-url"])):(e.openBlock(),e.createBlock(l,{key:1,name:k.agentName,"avatar-url":k.agentAvatarUrl,size:26,tail:!0},null,8,["name","avatar-url"]))],64)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),b.renderAs==="action"?(e.openBlock(),e.createBlock(f,{key:1,state:b.message.payload.state,label:o.actionLabel(b.message),detail:o.actionDetail(b.message)},null,8,["state","label","detail"])):b.renderAs==="admin-pending"?(e.openBlock(),e.createBlock(f,{key:2,state:"awaiting",label:o.t("messageList.approvalRequestSent"),detail:b.message.text_md||""},null,8,["label","detail"])):b.renderAs==="artifact-of-action"?(e.openBlock(),e.createBlock(y,{key:3,artifact:o.actionArtifact(b.message)},null,8,["artifact"])):b.renderAs==="artifact"?(e.openBlock(),e.createBlock(y,{key:4,artifact:o.artifactOf(b.message)},null,8,["artifact"])):(e.openBlock(),e.createElementBlock("div",Io,[b.message.text_md?(e.openBlock(),e.createBlock(_,{key:0,role:k.role,text:b.message.text_md},null,8,["role","text"])):e.createCommentVNode("",!0),o.attachmentsOf(b.message).length?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["wm-list__atts",{"wm-list__atts--align-end":k.role==="user"}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.attachmentsOf(b.message),(M,A)=>(e.openBlock(),e.createBlock(C,{key:`${o.messageKey(b.message)}-att-${A}`,attachment:M},null,8,["attachment"]))),128))],2)):e.createCommentVNode("",!0)]))],46,Oo),V<k.items.length-1&&a.pressedItemKey===`${o.messageKey(b.message)}-${b.partKey}`&&(k.role!=="user"||o.timeOf(b.message))?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["wm-list__meta wm-list__meta--press",{"wm-list__meta--right":k.role==="user"}])},[k.role!=="user"?(e.openBlock(),e.createElementBlock("span",Ro,e.toDisplayString(o.roleLabel(k)),1)):e.createCommentVNode("",!0),k.role!=="user"&&o.timeOf(b.message)?(e.openBlock(),e.createElementBlock("span",Fo,"•")):e.createCommentVNode("",!0),o.timeOf(b.message)?(e.openBlock(),e.createElementBlock("span",Po,e.toDisplayString(o.timeOf(b.message)),1)):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0)],64))),128)),(k.role!=="user"||o.lastTimeOf(k))&&!o.hasTrailingOverlay(k)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["wm-list__meta",{"wm-list__meta--right":k.role==="user"}])},[k.role!=="user"?(e.openBlock(),e.createElementBlock("span",Uo,e.toDisplayString(o.roleLabel(k)),1)):e.createCommentVNode("",!0),k.role!=="user"&&o.lastTimeOf(k)?(e.openBlock(),e.createElementBlock("span",zo,"•")):e.createCommentVNode("",!0),o.lastTimeOf(k)?(e.openBlock(),e.createElementBlock("span",jo,e.toDisplayString(o.lastTimeOf(k)),1)):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0)],64))],2)):e.createCommentVNode("",!0)],64))),128)),r.streamingActive?(e.openBlock(),e.createElementBlock("div",Ho,[e.createElementVNode("div",qo,[e.createVNode(i,{size:26,tail:!0,name:r.aiAgentName,"image-url":r.aiAgentAvatarUrl},null,8,["name","image-url"])]),e.createVNode(N)])):e.createCommentVNode("",!0)],34),e.createVNode(e.Transition,{name:"wm-scrollDown"},{default:e.withCtx(()=>[a.showScrollDown?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-list__scrollDown","aria-label":o.t("messageList.scrollToBottom"),title:o.t("messageList.scrollToBottom"),onClick:n[5]||(n[5]=(...k)=>o.scrollToBottomSmooth&&o.scrollToBottomSmooth(...k))},[...n[13]||(n[13]=[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M6 9l6 6 6-6"})],-1)])],8,Ko)):e.createCommentVNode("",!0)]),_:1})])}const ze=S(Eo,[["render",$o],["__scopeId","data-v-cf20685c"]]),J=typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function",ie=typeof window<"u"&&typeof window.MediaRecorder<"u";function je(){return ie&&["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"].find(n=>{var r,s;return(s=(r=window.MediaRecorder).isTypeSupported)==null?void 0:s.call(r,n)})||""}function He({audio:t}){return{video:!0,audio:!!t,selfBrowserSurface:"include",surfaceSwitching:"include",systemAudio:t?"include":"exclude"}}function Wo(t){return t?t.startsWith("image/")?"image":t.startsWith("video/")?"video":"file":"file"}async function qe(){if(!J)return null;let t;try{t=await navigator.mediaDevices.getDisplayMedia(He({audio:!1}))}catch(n){return(n==null?void 0:n.name)!=="NotAllowedError"&&console.error("[media] screenshot picker",n),null}try{return await Go(t)}catch(n){return console.error("[media] screenshot capture",n),null}finally{t.getTracks().forEach(n=>{n.stop()})}}async function Go(t){const n=document.createElement("video");n.muted=!0,n.playsInline=!0,n.srcObject=t,await n.play(),await new Promise(l=>requestAnimationFrame(l));const r=n.videoWidth||1280,s=n.videoHeight||720,a=document.createElement("canvas");a.width=r,a.height=s,a.getContext("2d").drawImage(n,0,0,r,s);const o=await new Promise((l,f)=>{a.toBlob(y=>y?l(y):f(new Error("toBlob failed")),"image/png")}),i=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19);return new File([o],`capture-${i}.png`,{type:"image/png"})}async function Ke(t={}){var y;if(!J||!ie)return null;let n;try{n=await navigator.mediaDevices.getDisplayMedia(He({audio:!0}))}catch(_){return(_==null?void 0:_.name)!=="NotAllowedError"&&console.error("[media] record picker",_),null}const r=je();let s;try{s=r?new window.MediaRecorder(n,{mimeType:r}):new window.MediaRecorder(n)}catch(_){return console.error("[media] recorder init",_),n.getTracks().forEach(C=>{C.stop()}),null}const a=[];let o=null,i=!1;s.addEventListener("dataavailable",_=>{_.data&&_.data.size>0&&a.push(_.data)}),s.addEventListener("stop",()=>{var _,C;if(o&&clearInterval(o),n.getTracks().forEach(N=>{N.stop()}),a.length){const N=s.mimeType||r||"video/webm",k=new Blob(a,{type:N}),L=/mp4/.test(N)?"mp4":"webm",b=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),V=new File([k],`ecran-${b}.${L}`,{type:N});(_=t.onfinalize)==null||_.call(t,V)}else(C=t.oncancel)==null||C.call(t)}),n.getVideoTracks().forEach(_=>{_.addEventListener("ended",()=>l(),{once:!0})});function l(){if(!i&&(i=!0,s.state!=="inactive"))try{s.stop()}catch(_){console.error("[media] recorder stop",_)}}try{s.start(1e3)}catch(_){return console.error("[media] recorder start",_),n.getTracks().forEach(C=>{C.stop()}),null}(y=t.onstart)==null||y.call(t);const f=Date.now();return o=setInterval(()=>{var _;(_=t.ontick)==null||_.call(t,Date.now()-f)},500),{stop:l,get state(){return s.state}}}const Yo=[{action:"file",labelKey:"composer.attachFile",path:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"},{action:"screenshot",labelKey:"composer.screenshot",path:"M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2z M12 17a4 4 0 100-8 4 4 0 000 8z"},{action:"record",labelKey:"composer.recordScreen",path:"M23 7l-7 5 7 5V7z M1 5a2 2 0 012-2h12a2 2 0 012 2v14a2 2 0 01-2 2H3a2 2 0 01-2-2V5z"}],Xo={name:"WmComposer",inject:{t:{default:()=>T()}},props:{modelValue:{type:String,default:""},placeholder:{type:String,default:"Écrivez votre message…"},disabled:{type:Boolean,default:!1},attachLabel:{type:String,default:"Joindre"},displayMode:{type:String,default:"floating"}},emits:["update:modelValue","send","attach"],data(){return{local:this.modelValue,attachOpen:!1,recording:!1,recordingElapsed:0,recorder:null,kbOffset:0}},computed:{canSend(){return!this.disabled&&!!this.local.trim()},attachItems(){return Yo.map(t=>({...t,label:this.t(t.labelKey),disabled:t.action==="screenshot"&&!J||t.action==="record"&&(!J||!ie)}))},recordingElapsedLabel(){const t=Math.floor(this.recordingElapsed/1e3),n=Math.floor(t/60),r=t%60;return`${n}:${r.toString().padStart(2,"0")}`}},watch:{modelValue(t){t!==this.local&&(this.local=t,this.$nextTick(()=>this.autosize()))},local(t){this.$emit("update:modelValue",t)}},mounted(){this.autosize(),this.displayMode==="sheet"&&this.setupKeyboardTracking()},beforeUnmount(){if(this.recorder)try{this.recorder.stop()}catch{}this.teardownKeyboardTracking()},methods:{focus(){const t=this.$refs.inputEl;if(!(!t||this.disabled))try{t.focus({preventScroll:!0})}catch{t.focus()}},onSubmit(){if(!this.canSend)return;const t=this.local.trim();this.local="",this.$emit("send",t),this.$nextTick(()=>this.autosize())},onKeydown(t){t.key==="Enter"&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey&&!t.isComposing&&(t.preventDefault(),this.onSubmit())},autosize(){const t=this.$refs.inputEl;t&&(t.clientWidth<80||(t.style.height="auto",t.style.height=`${t.scrollHeight}px`))},onFile(t){const n=Array.from(t.target.files||[]);for(const r of n)this.$emit("attach",r);t.target.value=""},onAttachAction(t){this.attachOpen=!1,t==="file"?this.pickFile():t==="screenshot"?this.captureScreenshot():t==="record"&&this.startRecording()},pickFile(){var t;(t=this.$refs.fileEl)==null||t.click()},async captureScreenshot(){if(this.disabled)return;const t=await qe();t&&this.$emit("attach",t)},async startRecording(){if(this.recording||this.disabled)return;this.recordingElapsed=0;const t=await Ke({onstart:()=>{this.recording=!0},ontick:n=>{this.recordingElapsed=n},onfinalize:n=>{this.$emit("attach",n),this.recording=!1,this.recordingElapsed=0,this.recorder=null},oncancel:()=>{this.recording=!1,this.recordingElapsed=0,this.recorder=null}});t&&(this.recorder=t)},stopRecording(){if(this.recorder)try{this.recorder.stop()}catch(t){console.error("[composer] stop recording",t)}},setupKeyboardTracking(){const t=window.visualViewport;t&&(this._vvHandler=()=>{const n=Math.max(0,window.innerHeight-t.height-t.offsetTop);this.kbOffset=n},t.addEventListener("resize",this._vvHandler),t.addEventListener("scroll",this._vvHandler))},teardownKeyboardTracking(){const t=window.visualViewport;!t||!this._vvHandler||(t.removeEventListener("resize",this._vvHandler),t.removeEventListener("scroll",this._vvHandler),this._vvHandler=null)}}},Jo={key:0,class:"wm-rec"},Qo={class:"wm-rec__lbl"},Zo={key:1,class:"wm-compose__menu",role:"menu"},ea=["disabled","onClick"],ta={class:"wm-compose__menuIcon"},na={viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true"},ra=["d"],oa=["placeholder","disabled"],aa={class:"wm-compose__actions"},sa=["title","aria-label","disabled"],ia=["disabled","aria-label"];function la(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-compose-wrap",{"wm-compose-wrap--sheet":r.displayMode==="sheet"}]),style:e.normalizeStyle(a.kbOffset?{transform:`translateY(-${a.kbOffset}px)`}:null)},[a.recording?(e.openBlock(),e.createElementBlock("div",Jo,[n[8]||(n[8]=e.createElementVNode("span",{class:"wm-rec__dot","aria-hidden":"true"},null,-1)),e.createElementVNode("span",Qo,e.toDisplayString(o.t("composer.recording",{time:o.recordingElapsedLabel})),1),e.createElementVNode("button",{type:"button",class:"wm-rec__stop",onClick:n[0]||(n[0]=(...i)=>o.stopRecording&&o.stopRecording(...i))},e.toDisplayString(o.t("composer.stop")),1)])):e.createCommentVNode("",!0),e.createElementVNode("form",{class:e.normalizeClass(["wm-compose",{"has-attach":a.attachOpen}]),onSubmit:n[7]||(n[7]=e.withModifiers((...i)=>o.onSubmit&&o.onSubmit(...i),["prevent"]))},[e.createElementVNode("input",{ref:"fileEl",type:"file",hidden:"",multiple:"",onChange:n[1]||(n[1]=(...i)=>o.onFile&&o.onFile(...i))},null,544),a.attachOpen?(e.openBlock(),e.createElementBlock("div",{key:0,class:"wm-compose__overlay",onClick:n[2]||(n[2]=i=>a.attachOpen=!1)})):e.createCommentVNode("",!0),a.attachOpen?(e.openBlock(),e.createElementBlock("div",Zo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.attachItems,i=>(e.openBlock(),e.createElementBlock("button",{key:i.action,type:"button",class:"wm-compose__menuItem",disabled:i.disabled,onClick:l=>o.onAttachAction(i.action)},[e.createElementVNode("span",ta,[(e.openBlock(),e.createElementBlock("svg",na,[e.createElementVNode("path",{d:i.path,stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",fill:"none"},null,8,ra)]))]),e.createElementVNode("span",null,e.toDisplayString(i.label),1)],8,ea))),128))])):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("textarea",{ref:"inputEl","onUpdate:modelValue":n[3]||(n[3]=i=>a.local=i),class:"wm-compose__input",rows:"3",placeholder:r.placeholder,disabled:r.disabled,onKeydown:n[4]||(n[4]=(...i)=>o.onKeydown&&o.onKeydown(...i)),onInput:n[5]||(n[5]=(...i)=>o.autosize&&o.autosize(...i))},null,40,oa),[[e.vModelText,a.local]]),e.createElementVNode("div",aa,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["wm-compose__icon",{"is-open":a.attachOpen}]),title:r.attachLabel,"aria-label":r.attachLabel,disabled:a.recording,onClick:n[6]||(n[6]=i=>a.attachOpen=!a.attachOpen)},[...n[9]||(n[9]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})],-1)])],10,sa),e.createElementVNode("button",{type:"submit",class:e.normalizeClass(["wm-compose__send",{"is-empty":!o.canSend}]),disabled:!o.canSend,"aria-label":o.t("composer.send")},[...n[10]||(n[10]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})],-1)])],10,ia)])],34)],6)}const $e=S(Xo,[["render",la],["__scopeId","data-v-01e81a27"]]),ca={name:"WmSuggestionChips",props:{items:{type:Array,default:()=>[]},baseDelay:{type:Number,default:360},stepDelay:{type:Number,default:90}},emits:["select"],computed:{batchKey(){return this.items.map(t=>(t==null?void 0:t.label)||(t==null?void 0:t.text)||"").join("§")}}},da=["onClick"];function ua(t,n,r,s,a,o){return r.items.length?(e.openBlock(),e.createElementBlock("div",{key:o.batchKey,class:"wm-chips"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,(i,l)=>(e.openBlock(),e.createElementBlock("button",{key:l,type:"button",class:"wm-chip",style:e.normalizeStyle({animationDelay:r.baseDelay+l*r.stepDelay+"ms"}),onClick:f=>t.$emit("select",i)},e.toDisplayString(i.label),13,da))),128))])):e.createCommentVNode("",!0)}const We=S(ca,[["render",ua],["__scopeId","data-v-47ad8085"]]),ma={name:"WmApprovalCard",components:{AIAvatar:H},inject:{t:{default:()=>T()}},props:{action:{type:String,required:!0},detail:{type:String,default:""},callbacks:{type:Array,default:()=>[]},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["callback"],computed:{approveCallback(){return this.callbacks.find(t=>t.id==="approve"||t.style==="primary")||this.callbacks[0]},rejectCallback(){return this.callbacks.find(t=>t.id==="reject"||t.style==="danger"||t.style==="neutral")||(this.callbacks.length>1?this.callbacks[1]:null)},approveId(){var t;return(t=this.approveCallback)==null?void 0:t.id},rejectId(){var t;return(t=this.rejectCallback)==null?void 0:t.id},approveLabel(){var t;return((t=this.approveCallback)==null?void 0:t.label)||this.t("approval.approve")},rejectLabel(){var t;return((t=this.rejectCallback)==null?void 0:t.label)||this.t("approval.reject")}}},ha={class:"wm-approval"},fa={class:"wm-approval__head"},pa={class:"wm-approval__icon"},ga={class:"wm-approval__main"},_a={class:"wm-approval__title"},ya={key:0,class:"wm-approval__detail"},va={class:"wm-approval__actions"};function ka(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",ha,[e.createElementVNode("div",fa,[e.createElementVNode("div",pa,[e.createVNode(i,{size:24,name:r.agentName,"image-url":r.agentAvatarUrl},null,8,["name","image-url"])]),e.createElementVNode("div",ga,[e.createElementVNode("div",_a,e.toDisplayString(r.action),1),r.detail?(e.openBlock(),e.createElementBlock("div",ya,e.toDisplayString(r.detail),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",va,[o.rejectId?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-approval__btn wm-approval__btn--neutral",onClick:n[0]||(n[0]=l=>t.$emit("callback",o.rejectId))},e.toDisplayString(o.rejectLabel),1)):e.createCommentVNode("",!0),o.approveId?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-approval__btn wm-approval__btn--primary",onClick:n[1]||(n[1]=l=>t.$emit("callback",o.approveId))},e.toDisplayString(o.approveLabel),1)):e.createCommentVNode("",!0)])])}const Ge=S(ma,[["render",ka],["__scopeId","data-v-a2bed37e"]]);let ye=0;const wa=new Set(["text","textarea","number","boolean","select","multiselect","date"]),ba={name:"WmFormCard",components:{AIAvatar:H},inject:{t:{default:()=>T()}},props:{form:{type:Object,required:!0},readOnly:{type:Boolean,default:!1},initialValues:{type:Object,default:null},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["submit"],data(){return ye+=1,{_uid:ye,values:{},busy:!1,error:""}},computed:{normalizedFields(){var n;return(Array.isArray((n=this.form)==null?void 0:n.fields)?this.form.fields:[]).filter(r=>!(!(r!=null&&r.key)||!(r!=null&&r.label)||!wa.has(r==null?void 0:r.type)||(r.type==="select"||r.type==="multiselect")&&(!Array.isArray(r.options)||r.options.length===0)))}},created(){this.resetValues()},methods:{resetValues(){const t=this.initialValues&&typeof this.initialValues=="object"?this.initialValues:{},n={};for(const r of this.normalizedFields){if(t[r.key]!==void 0){n[r.key]=t[r.key];continue}r.type==="boolean"?n[r.key]=!1:r.type==="multiselect"?n[r.key]=[]:n[r.key]=""}this.values=n,this.error=""},toggleMulti(t,n,r){const s=Array.isArray(this.values[t])?this.values[t].slice():[],a=s.indexOf(n);r&&a===-1?s.push(n):!r&&a!==-1&&s.splice(a,1),this.values={...this.values,[t]:s}},validate(){for(const t of this.normalizedFields){if(!t.required)continue;const n=this.values[t.key];if(t.type!=="boolean"){if(t.type==="multiselect"){if(!Array.isArray(n)||n.length===0)return this.t("form.fieldRequired",{label:t.label});continue}if(n==null||n==="")return this.t("form.fieldRequired",{label:t.label})}}return""},async onSubmit(){if(this.readOnly||this.busy)return;const t=this.validate();if(t){this.error=t;return}this.error="",this.busy=!0;try{await this.$emit("submit",{values:this.values})}finally{this.busy=!1}}}},Ea={class:"wm-form"},Ca={class:"wm-form__head"},Ba={class:"wm-form__icon"},Na={class:"wm-form__main"},Sa={class:"wm-form__title"},Aa={key:0,class:"wm-form__detail"},Va=["for"],Ma={key:0,class:"wm-form__req","aria-hidden":"true"},Ta=["id","onUpdate:modelValue","placeholder","required","disabled"],xa=["id","onUpdate:modelValue","placeholder","required","disabled"],La=["id","onUpdate:modelValue","placeholder","required","disabled"],Oa=["id","onUpdate:modelValue","required","disabled"],Da={key:4,class:"wm-form__bool"},Ia=["id","onUpdate:modelValue","disabled"],Ra=["id","onUpdate:modelValue","required","disabled"],Fa={value:"",disabled:""},Pa=["value"],Ua={key:6,class:"wm-form__multi"},za=["value","checked","disabled","onChange"],ja={key:0,class:"wm-form__err"},Ha=["disabled"],qa={key:0,class:"wm-form__spinner","aria-hidden":"true"},Ka={key:2,class:"wm-form__doneLbl"};function $a(t,n,r,s,a,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",Ea,[e.createElementVNode("div",Ca,[e.createElementVNode("div",Ba,[e.createVNode(i,{size:24,name:r.agentName,"image-url":r.agentAvatarUrl},null,8,["name","image-url"])]),e.createElementVNode("div",Na,[e.createElementVNode("div",Sa,e.toDisplayString(r.form.title||o.t("form.title")),1),r.form.description?(e.openBlock(),e.createElementBlock("div",Aa,e.toDisplayString(r.form.description),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("form",{class:"wm-form__body",onSubmit:n[0]||(n[0]=e.withModifiers((...l)=>o.onSubmit&&o.onSubmit(...l),["prevent"]))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.normalizedFields,l=>(e.openBlock(),e.createElementBlock("div",{key:l.key,class:"wm-form__field"},[e.createElementVNode("label",{for:`wm-f-${a._uid}-${l.key}`,class:"wm-form__label"},[e.createTextVNode(e.toDisplayString(l.label),1),l.required?(e.openBlock(),e.createElementBlock("span",Ma,"*")):e.createCommentVNode("",!0)],8,Va),l.type==="text"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,type:"text",class:"wm-form__input",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||a.busy},null,8,Ta)),[[e.vModelText,a.values[l.key]]]):l.type==="textarea"?e.withDirectives((e.openBlock(),e.createElementBlock("textarea",{key:1,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,class:"wm-form__textarea",rows:"3",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||a.busy},null,8,xa)),[[e.vModelText,a.values[l.key]]]):l.type==="number"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:2,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,type:"number",class:"wm-form__input",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||a.busy},null,8,La)),[[e.vModelText,a.values[l.key],void 0,{number:!0}]]):l.type==="date"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:3,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,type:"date",class:"wm-form__input",required:l.required,disabled:r.readOnly||a.busy},null,8,Oa)),[[e.vModelText,a.values[l.key]]]):l.type==="boolean"?(e.openBlock(),e.createElementBlock("label",Da,[e.withDirectives(e.createElementVNode("input",{id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,type:"checkbox",disabled:r.readOnly||a.busy},null,8,Ia),[[e.vModelCheckbox,a.values[l.key]]]),e.createElementVNode("span",null,e.toDisplayString(l.placeholder||o.t("common.yes")),1)])):l.type==="select"?e.withDirectives((e.openBlock(),e.createElementBlock("select",{key:5,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":f=>a.values[l.key]=f,class:"wm-form__select",required:l.required,disabled:r.readOnly||a.busy},[e.createElementVNode("option",Fa,e.toDisplayString(l.placeholder||o.t("form.choose")),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,f=>(e.openBlock(),e.createElementBlock("option",{key:f.value,value:f.value},e.toDisplayString(f.label),9,Pa))),128))],8,Ra)),[[e.vModelSelect,a.values[l.key]]]):l.type==="multiselect"?(e.openBlock(),e.createElementBlock("div",Ua,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,f=>(e.openBlock(),e.createElementBlock("label",{key:f.value,class:"wm-form__multiItem"},[e.createElementVNode("input",{type:"checkbox",value:f.value,checked:Array.isArray(a.values[l.key])&&a.values[l.key].includes(f.value),disabled:r.readOnly||a.busy,onChange:y=>o.toggleMulti(l.key,f.value,y.target.checked)},null,40,za),e.createElementVNode("span",null,e.toDisplayString(f.label),1)]))),128))])):e.createCommentVNode("",!0)]))),128)),a.error?(e.openBlock(),e.createElementBlock("div",ja,e.toDisplayString(a.error),1)):e.createCommentVNode("",!0),r.readOnly?(e.openBlock(),e.createElementBlock("div",Ka,e.toDisplayString(o.t("form.responseSent")),1)):(e.openBlock(),e.createElementBlock("button",{key:1,type:"submit",class:"wm-form__submit",disabled:a.busy},[a.busy?(e.openBlock(),e.createElementBlock("span",qa)):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(a.busy?o.t("common.sending"):r.form.submit_label||o.t("common.send")),1)],8,Ha))],32)])}const Ye=S(ba,[["render",$a],["__scopeId","data-v-fe65cc56"]]),Wa={name:"WmFeedback",inject:{t:{default:()=>T()}},props:{busy:{type:Boolean,default:!1},done:{type:Boolean,default:!1}},emits:["submit"],data(){return{sel:null}},computed:{options(){return[{v:1,e:"😞",l:this.t("feedback.rating1")},{v:2,e:"😐",l:this.t("feedback.rating2")},{v:3,e:"🙂",l:this.t("feedback.rating3")},{v:4,e:"😄",l:this.t("feedback.rating4")},{v:5,e:"🤩",l:this.t("feedback.rating5")}]}},methods:{onSend(){!this.sel||this.busy||this.$emit("submit",{rating:this.sel})}}},Ga={class:"wm-fb"},Ya={class:"wm-fb__title"},Xa={class:"wm-fb__sub"},Ja={class:"wm-fb__row"},Qa=["onClick"],Za={class:"wm-fb__emoji"},es={class:"wm-fb__label"},ts=["disabled"],ns={key:1,class:"wm-fb__done"},rs={class:"wm-fb__doneTitle"},os={class:"wm-fb__doneSub"};function as(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",Ga,[r.done?(e.openBlock(),e.createElementBlock("div",ns,[n[1]||(n[1]=e.createElementVNode("div",{class:"wm-fb__check"},[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#fff","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M20 6L9 17l-5-5"})])],-1)),e.createElementVNode("div",rs,e.toDisplayString(o.t("feedback.doneTitle")),1),e.createElementVNode("div",os,e.toDisplayString(o.t("feedback.doneSubtitle")),1)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("div",Ya,e.toDisplayString(o.t("feedback.question")),1),e.createElementVNode("div",Xa,e.toDisplayString(o.t("feedback.subtitle")),1),e.createElementVNode("div",Ja,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.options,i=>(e.openBlock(),e.createElementBlock("button",{key:i.v,type:"button",class:e.normalizeClass(["wm-fb__opt",{"is-selected":a.sel===i.v}]),onClick:l=>a.sel=i.v},[e.createElementVNode("span",Za,e.toDisplayString(i.e),1),e.createElementVNode("span",es,e.toDisplayString(i.l),1)],10,Qa))),128))]),e.createElementVNode("button",{type:"button",class:"wm-fb__send",disabled:!a.sel||r.busy,onClick:n[0]||(n[0]=(...i)=>o.onSend&&o.onSend(...i))},e.toDisplayString(r.busy?o.t("common.sending"):o.t("feedback.submit")),9,ts)],64))])}const Xe=S(Wa,[["render",as],["__scopeId","data-v-9b630564"]]),ss={name:"WmMoreMenu",inject:{t:{default:()=>T()}},props:{canRename:{type:Boolean,default:!0},canExport:{type:Boolean,default:!0},soundEnabled:{type:Boolean,default:!0},browserNotifEnabled:{type:Boolean,default:!1},statusUrl:{type:String,default:""},helpUrl:{type:String,default:""}},emits:["close","action","sound-toggle","browser-notif-toggle"],data(){return{soundOn:this.soundEnabled,browserNotifOn:this.browserNotifEnabled}},watch:{soundEnabled(t){this.soundOn=!!t},browserNotifEnabled(t){this.browserNotifOn=!!t}},methods:{emit(t){this.$emit("action",t)},toggleSound(){this.soundOn=!this.soundOn,this.$emit("sound-toggle",this.soundOn)},toggleBrowserNotif(){this.browserNotifOn=!this.browserNotifOn,this.$emit("browser-notif-toggle",this.browserNotifOn)}}},is={class:"wm-mm"},ls={class:"wm-mm__pop",role:"menu"},cs={key:0,class:"wm-mm__section"},ds={class:"wm-mm__label"},us={class:"wm-mm__label"},ms={key:1,class:"wm-mm__sep"},hs={class:"wm-mm__section"},fs={class:"wm-mm__label"},ps={class:"wm-mm__label"},gs={class:"wm-mm__section"},_s={class:"wm-mm__label"},ys={class:"wm-mm__label"};function vs(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",is,[e.createElementVNode("div",{class:"wm-mm__scrim",onClick:n[0]||(n[0]=i=>t.$emit("close"))}),e.createElementVNode("div",ls,[r.canRename||r.canExport?(e.openBlock(),e.createElementBlock("div",cs,[r.canRename?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-mm__item",onClick:n[1]||(n[1]=i=>o.emit("rename"))},[n[7]||(n[7]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M12 20h9"}),e.createElementVNode("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})])],-1)),e.createElementVNode("span",ds,e.toDisplayString(o.t("moreMenu.editTitle")),1)])):e.createCommentVNode("",!0),r.canExport?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-mm__item",onClick:n[2]||(n[2]=i=>o.emit("export"))},[n[8]||(n[8]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M4 12v8a2 2 0 002 2h12a2 2 0 002-2v-8M16 6l-4-4-4 4M12 2v13"})])],-1)),e.createElementVNode("span",us,e.toDisplayString(o.t("moreMenu.exportTranscript")),1),n[9]||(n[9]=e.createElementVNode("span",{class:"wm-mm__hint"},".txt",-1))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),r.canRename||r.canExport?(e.openBlock(),e.createElementBlock("div",ms)):e.createCommentVNode("",!0),e.createElementVNode("div",hs,[e.createElementVNode("button",{type:"button",class:"wm-mm__item",onClick:n[3]||(n[3]=(...i)=>o.toggleSound&&o.toggleSound(...i))},[n[11]||(n[11]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),e.createElementVNode("path",{d:"M15.54 8.46a5 5 0 010 7.07M19.07 4.93a10 10 0 010 14.14"})])],-1)),e.createElementVNode("span",fs,e.toDisplayString(o.t("moreMenu.sound")),1),e.createElementVNode("span",{class:e.normalizeClass(["wm-mm__toggle",{"wm-mm__toggle--on":a.soundOn}])},[...n[10]||(n[10]=[e.createElementVNode("span",{class:"wm-mm__knob"},null,-1)])],2)]),e.createElementVNode("button",{type:"button",class:"wm-mm__item",onClick:n[4]||(n[4]=(...i)=>o.toggleBrowserNotif&&o.toggleBrowserNotif(...i))},[n[13]||(n[13]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M15 17h5l-1.4-1.4A2 2 0 0118 14.2V11a6 6 0 10-12 0v3.2c0 .5-.2 1-.6 1.4L4 17h5m6 0a3 3 0 11-6 0"})])],-1)),e.createElementVNode("span",ps,e.toDisplayString(o.t("moreMenu.browserNotifications")),1),e.createElementVNode("span",{class:e.normalizeClass(["wm-mm__toggle",{"wm-mm__toggle--on":a.browserNotifOn}])},[...n[12]||(n[12]=[e.createElementVNode("span",{class:"wm-mm__knob"},null,-1)])],2)])]),n[16]||(n[16]=e.createElementVNode("div",{class:"wm-mm__sep"},null,-1)),e.createElementVNode("div",gs,[r.statusUrl?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-mm__item",onClick:n[5]||(n[5]=i=>o.emit("status"))},[n[14]||(n[14]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zM10 6v4l3 2"})])],-1)),e.createElementVNode("span",_s,e.toDisplayString(o.t("moreMenu.serviceStatus")),1)])):e.createCommentVNode("",!0),r.helpUrl?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-mm__item",onClick:n[6]||(n[6]=i=>o.emit("help"))},[n[15]||(n[15]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M9 11a3 3 0 116 0c0 2-3 2-3 5M12 19h.01M12 22a10 10 0 110-20 10 10 0 010 20z"})])],-1)),e.createElementVNode("span",ys,e.toDisplayString(o.t("moreMenu.helpCenter")),1)])):e.createCommentVNode("",!0)])])])}const Je=S(ss,[["render",vs],["__scopeId","data-v-76281e95"]]),ks={name:"WmRenameDialog",inject:{t:{default:()=>T()}},props:{title:{type:String,default:""},initialValue:{type:String,default:""},placeholder:{type:String,default:""}},emits:["close","submit"],data(){return{value:this.initialValue||""}},computed:{canSubmit(){const t=(this.value||"").trim();return!!t&&t!==(this.initialValue||"").trim()}},mounted(){this.$nextTick(()=>{const t=this.$refs.input;if(t){t.focus();try{t.select()}catch{}}})},methods:{onSubmit(){this.canSubmit&&this.$emit("submit",this.value.trim())}}},ws={class:"wm-dialog"},bs={class:"wm-dialog__card",role:"dialog","aria-modal":"true"},Es={class:"wm-dialog__head"},Cs={class:"wm-dialog__title"},Bs=["aria-label"],Ns={class:"wm-dialog__body"},Ss=["placeholder"],As={class:"wm-dialog__actions"},Vs=["disabled"];function Ms(t,n,r,s,a,o){return e.openBlock(),e.createElementBlock("div",ws,[e.createElementVNode("div",{class:"wm-dialog__scrim",onClick:n[0]||(n[0]=i=>t.$emit("close"))}),e.createElementVNode("div",bs,[e.createElementVNode("div",Es,[e.createElementVNode("div",Cs,e.toDisplayString(r.title||o.t("rename.title")),1),e.createElementVNode("button",{type:"button",class:"wm-dialog__close","aria-label":o.t("common.close"),onClick:n[1]||(n[1]=i=>t.$emit("close"))},[...n[7]||(n[7]=[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,Bs)]),e.createElementVNode("div",Ns,[e.withDirectives(e.createElementVNode("input",{ref:"input","onUpdate:modelValue":n[2]||(n[2]=i=>a.value=i),type:"text",class:"wm-dialog__input",placeholder:r.placeholder||o.t("rename.placeholder"),maxlength:120,onKeydown:[n[3]||(n[3]=e.withKeys(e.withModifiers((...i)=>o.onSubmit&&o.onSubmit(...i),["prevent"]),["enter"])),n[4]||(n[4]=e.withKeys(e.withModifiers(i=>t.$emit("close"),["prevent"]),["esc"]))]},null,40,Ss),[[e.vModelText,a.value]])]),e.createElementVNode("div",As,[e.createElementVNode("button",{type:"button",class:"wm-dialog__btn",onClick:n[5]||(n[5]=i=>t.$emit("close"))},e.toDisplayString(o.t("common.cancel")),1),e.createElementVNode("button",{type:"button",class:"wm-dialog__btn wm-dialog__btn--primary",disabled:!o.canSubmit,onClick:n[6]||(n[6]=(...i)=>o.onSubmit&&o.onSubmit(...i))},e.toDisplayString(o.t("common.save")),9,Vs)])])])}const Ts=S(ks,[["render",Ms],["__scopeId","data-v-6d5f94a8"]]),ve="ww-messenger-tokens",xs={name:"Messenger",components:{Launcher:Ve,Header:Te,Onboarding:xe,History:ir,MessageList:ze,Composer:$e,SuggestionChips:We,ApprovalCard:Ge,FormCard:Ye,Feedback:Xe,MoreMenu:Je,RenameDialog:Ts},mixins:[pt,wt,bt,Ct],provide(){return{signAttachmentFn:t=>{var n,r;return((r=(n=this.store)==null?void 0:n.signAttachment)==null?void 0:r.call(n,t))||null},t:(t,n)=>this.t(t,n),wmLocale:()=>this.locale}},props:{baseUrl:{type:String,default:Ee},widgetId:{type:String,default:""},context:{type:Object,default:null},displayMode:{type:String,default:"floating"},devtools:{type:Boolean,default:!1},language:{type:String,default:""}},data(){return{transport:null,store:null,isOpen:!1,launcherHovered:!1,draft:"",busy:!1,bootError:null,pendingAttachments:[],feedbackBusy:!1,feedbackDone:!1,convOpenedAt:0,moreOpen:!1,renameDialogOpen:!1,draftConv:null,activeConvId:null,showOnboarding:!1,showHistory:!1,dismissedPeeks:{},floatHeight:0,floatRO:null,parentOrigin:"",parentToken:"",parentVariables:null,parentAllowUnauthenticated:!1,parentInitReceived:!1,parentInitDeferred:null}},computed:{isEditor(){return!!this.devtools},isEmbedded(){return this.displayMode==="embedded"},customerLanguage(){var r,s,a,o;const t=(r=this.s)==null?void 0:r.customer,n=t&&(t.language||((s=t.values)==null?void 0:s.language));return n||((o=(a=this.context)==null?void 0:a.customer)==null?void 0:o.language)||""},locale(){var t;return se(this.language||this.customerLanguage||((t=this.widget)==null?void 0:t.default_language)||"")},translator(){return T(this.locale)},error(){var t;return this.bootError||((t=this.s)==null?void 0:t.error)||null},canBoot(){return!!(this.baseUrl&&this.widgetId)},s(){var t;return((t=this.store)==null?void 0:t.state)||null},ready(){var t;return!!((t=this.s)!=null&&t.ready)},allConversations(){var n;const t=(n=this.s)==null?void 0:n.conversations;return Array.isArray(t)?t:[]},drawerConversations(){var r;const t=((r=this.s)==null?void 0:r.messagesByConv)||{},n=this.revealedAt;return this.allConversations.map(s=>{var y;const a=t[s.id]||[],o=R(s.last_read_message_id);let i=0,l=null;for(let _=a.length-1;_>=0;_--){const C=a[_];if(!C)continue;if(((y=C.author)==null?void 0:y.type)==="user")break;const N=R(C.id);if(N!=null){if(o!=null&&N<=o)break;n[C.id]!==0&&(!l&&C.author&&(l=C.author),i++)}}if(!a.length){const _=R(s.last_message_id);_!=null&&(o==null||_>o)&&(i=1,l=s.last_message_author||null)}const f=a.filter(_=>!((_==null?void 0:_.id)!=null&&n[_.id]===0));return{...s,_preview:ut(s,f),_unread:i>0,_unreadCount:i,_lastAuthor:l}})},unreadCount(){return this.drawerConversations.filter(t=>t._unread).length},openThreads(){var n;const t=((n=this.s)==null?void 0:n.messagesByConv)||{};return this.drawerConversations.filter(r=>r.status!=="resolved").map(r=>({id:r.id,title:r.name||this.t("common.newConversation"),preview:r._preview||this.t("onboarding.newMessage"),unread:!!r._unread,author:r._lastAuthor||null,_ts:ge(r,t[r.id]||[])})).sort((r,s)=>r._ts<s._ts?1:r._ts>s._ts?-1:0)},latestUnreads(){var r;const t=((r=this.s)==null?void 0:r.messagesByConv)||{},n=[];for(const s of this.drawerConversations){if(!s._unread)continue;const a=ge(s,t[s.id]||[]),o=s._lastAuthor,i=!o||o.type==="agent_ia",l=(o==null?void 0:o.name)||(i?this.agentName:"")||"",f=(o==null?void 0:o.avatar_url)||(i?this.agentAvatarUrl:null);n.push({convId:s.id,preview:s._preview||this.t("notification.youHaveNewMessage"),ts:a,count:s._unreadCount||1,senderName:l,senderAvatarUrl:f})}return n.sort((s,a)=>s.ts<a.ts?1:s.ts>a.ts?-1:0),n},launcherPeeks(){if(this.isOpen||this.isEmbedded)return[];const t=this.dismissedPeeks||{};return this.latestUnreads.filter(n=>t[n.convId]!==n.ts)},isViewingThread(){return(this.isOpen||this.isEmbedded)&&!!this.currentConv},currentConv(){if(this.draftConv)return this.draftConv;if(this.showOnboarding)return null;const t=this.allConversations;if(!t.length)return null;if(this.activeConvId!=null){const n=t.find(r=>r.id===this.activeConvId);if(n)return n}return t[0]||null},canBack(){return!!this.currentConv||this.showHistory},statusUrl(){var r;const t=(r=this.widget)==null?void 0:r.quick_links;if(!Array.isArray(t))return"";const n=t.find(s=>s.icon==="status"&&s.url);return(n==null?void 0:n.url)||""},helpUrl(){var r;const t=(r=this.widget)==null?void 0:r.quick_links;if(!Array.isArray(t))return"";const n=t.find(s=>(s.icon==="chat"||s.icon==="help")&&s.url);return(n==null?void 0:n.url)||""},widget(){var t,n;return((n=(t=this.s)==null?void 0:t.config)==null?void 0:n.widget)||null},rootStyle(){var n;const t=(n=this.widget)==null?void 0:n.primary_color;return t&&Ce(t)?{"--wm-primary":t}:null},widgetWelcomeMessage(){var t;return((t=this.widget)==null?void 0:t.welcome_message)||""},widgetSubtitle(){var t;return((t=this.widget)==null?void 0:t.subtitle)||""},defaultIconUrl(){var t;return((t=this.widget)==null?void 0:t.default_icon_url)||null},agentName(){var t,n,r;return((r=(n=(t=this.s)==null?void 0:t.config)==null?void 0:n.agent)==null?void 0:r.name)||""},agentAvatarUrl(){var t,n,r;return((r=(n=(t=this.s)==null?void 0:t.config)==null?void 0:n.agent)==null?void 0:r.avatar_url)||null},quickLinks(){var n;const t=(n=this.widget)==null?void 0:n.quick_links;return Array.isArray(t)?t:[]},teamMembers(){var n;const t=(n=this.widget)==null?void 0:n.team_members;return Array.isArray(t)?t:[]},responseLabel(){var t;return((t=this.widget)==null?void 0:t.response_time_label)||""},humanMessageAuthor(){var n,r,s;if(!this.currentConv)return null;const t=((n=this.s.messagesByConv)==null?void 0:n[this.currentConv.id])||[];for(let a=t.length-1;a>=0;a--)if(((s=(r=t[a])==null?void 0:r.author)==null?void 0:s.type)==="agent_human")return t[a].author;return null},humanAgentName(){var t;return((t=this.humanMessageAuthor)==null?void 0:t.name)||""},humanAgentAvatarUrl(){var t;return((t=this.humanMessageAuthor)==null?void 0:t.avatar_url)||null},isEscalated(){return!!this.humanMessageAuthor},isWaitingHuman(){var n;const t=(n=this.currentConv)==null?void 0:n.status;return t==="waiting"||t==="handled"},headerTitle(){var t,n;return((t=this.currentConv)==null?void 0:t.name)||((n=this.widget)==null?void 0:n.name)||this.t("common.newConversation")},composerPlaceholder(){return this.isEscalated&&this.humanAgentName?this.t("composer.replyTo",{name:this.humanAgentName.split(" ")[0]}):this.isWaitingHuman?this.t("composer.agentTakingOver"):this.t("composer.placeholder")},displayedMessages(){var r,s;const t=this.currentConv;if(!t)return[];if(!t._draft){const a=(s=(r=this.s)==null?void 0:r.paginationByConv)==null?void 0:s[t.id];if(!(a!=null&&a.loaded))return[]}const n=this.revealedAt;return(this.s.messagesByConv[t.id]||[]).filter(a=>{var o,i,l,f,y;return(a==null?void 0:a.type)==="action"&&((o=a==null?void 0:a.payload)==null?void 0:o.state)==="pending"||X(a)&&!(n[a.id]>0)?!1:(a==null?void 0:a.type)==="action"||(a==null?void 0:a.type)==="system"||((i=a==null?void 0:a.payload)==null?void 0:i.type)==="system"||Array.isArray((l=a==null?void 0:a.payload)==null?void 0:l.attachments)&&a.payload.attachments.length||(f=a==null?void 0:a.metadata)!=null&&f.artifact||(y=a==null?void 0:a.metadata)!=null&&y.form?!0:typeof(a==null?void 0:a.text_md)=="string"&&a.text_md.trim().length>0})},streamingActive(){var r,s,a;const t=this.currentConv;return t?Object.keys(((r=this.s)==null?void 0:r.streamingByMsgId)||{}).length>0?!0:this.actionInFlight?!1:(((a=(s=this.s)==null?void 0:s.messagesByConv)==null?void 0:a[t.id])||[]).some(o=>X(o)&&!(this.revealedAt[o.id]>0)):!1},currentConvMessages(){var n,r,s;const t=(n=this.currentConv)==null?void 0:n.id;return t?((s=(r=this.s)==null?void 0:r.messagesByConv)==null?void 0:s[t])||[]:[]},pendingApproval(){return!this.currentConv||!this.store||this.actionInFlight?null:this.store.getPendingApproval(this.currentConv.id)},approvalReady(){return this.pendingApproval?this.pendingApproval.id===this.approvalLatchId?!0:!(this.streamingActive||!this.approvalSettled):!1},approvalTitle(){var t,n,r;return((n=(t=this.pendingApproval)==null?void 0:t.payload)==null?void 0:n.name)||((r=this.pendingApproval)==null?void 0:r.text_md)||this.t("action.title")},approvalDetail(){var s,a,o,i,l,f;const t=(o=(a=(s=this.pendingApproval)==null?void 0:s.payload)==null?void 0:a.pending)==null?void 0:o.user_explanation;if(typeof t=="string"&&t.trim())return t.trim();const n=(f=(l=(i=this.pendingApproval)==null?void 0:i.payload)==null?void 0:l.pending)==null?void 0:f.prepared_params;if(!n||typeof n!="object")return"";const r=Object.entries(n);return r.length?r.slice(0,2).map(([y,_])=>`${y}: ${_}`).join(" · "):""},actionInFlight(){var t,n;return!this.currentConv||!this.store?null:((n=(t=this.store).getActionInFlight)==null?void 0:n.call(t,this.currentConv.id))||null},actionInFlightName(){var n;const t=this.actionInFlight;return t?((n=t.payload)==null?void 0:n.name)||t.text_md||this.t("common.action"):""},suggestions(){return!this.currentConv||!this.store?[]:this.streamingActive?[]:this.pendingForm?[]:this.store.getLatestSuggestions(this.currentConv.id)},pendingForm(){var t,n;return!this.currentConv||!this.store||this.pendingApproval||this.actionInFlight||this.streamingActive||!this.approvalSettled?null:((n=(t=this.store).getLatestForm)==null?void 0:n.call(t,this.currentConv.id))||null},showFeedback(){var n;const t=this.currentConv;return t?this.feedbackDone?!0:t.status!=="resolved"?!1:!((n=t.metadata)!=null&&n.feedback):!1},floatVisible(){return this.approvalReady||!!this.pendingForm||this.showFeedback||this.suggestions.length>0},dateLabel(){var r,s,a;const t=this.currentConv;let n=new Date;if(t){const i=((a=(((s=(r=this.s)==null?void 0:r.messagesByConv)==null?void 0:s[t.id])||[]).find(l=>l==null?void 0:l.created_at))==null?void 0:a.created_at)||t.created_at;if(i){const l=new Date(i);Number.isNaN(l.getTime())||(n=l)}}return this.t("messageList.today",{time:re(n,P(this.locale))})},paginationState(){var r,s,a;const t=(r=this.currentConv)==null?void 0:r.id,n=t?(a=(s=this.s)==null?void 0:s.paginationByConv)==null?void 0:a[t]:null;return{loading:!!(n!=null&&n.loading),hasMore:!!(n!=null&&n.nextCursor)}}},watch:{latestUnreads:{handler(t){const n=new Set(t.map(i=>i.convId)),r=this.dismissedPeeks||{},s=Object.keys(r);if(!s.length)return;const a={};let o=!1;for(const i of s)n.has(i)?a[i]=r[i]:o=!0;o&&(this.dismissedPeeks=a)},deep:!0},"currentConv.id":{handler(t){var n;this.resetRevealQueue(),this.convOpenedAt=Date.now(),this.moreOpen=!1,this.renameDialogOpen=!1,this.resetApprovalPacing(),this.isViewingThread&&(this.unreadAnchorId=R((n=this.currentConv)==null?void 0:n.last_read_message_id),this.unreadBoundaryTs=t?new Date().toISOString():"")},immediate:!0},isViewingThread(t,n){var r;t&&!n?(this.unreadAnchorId=R((r=this.currentConv)==null?void 0:r.last_read_message_id),this.unreadBoundaryTs=new Date().toISOString()):t||(this.unreadAnchorId=null,this.unreadBoundaryTs="")},pendingApproval:{handler(t,n){if(t&&!n){const r=t!=null&&t.created_at?Date.parse(t.created_at):NaN;if(!(Number.isFinite(r)&&r>=this.convOpenedAt)){this.resetApprovalPacing();return}this.bumpApprovalSettle(2600)}else!t&&n&&this.resetApprovalPacing()},immediate:!1},streamingActive(t,n){t!==n&&this.pendingApproval&&this.pendingApproval.id!==this.approvalLatchId&&this.bumpApprovalSettle()},approvalReady(t){t&&this.pendingApproval&&(this.approvalLatchId=this.pendingApproval.id)},floatVisible:{handler(t){this.$nextTick(()=>this.syncFloatObserver(t))},immediate:!0},currentConvMessages(t){var n;this.paceMessages(t,(n=this.currentConv)==null?void 0:n.id),(this.isOpen||this.isEmbedded)&&this.currentConv&&this.markConvRead(this.currentConv)}},async mounted(){if(typeof document<"u"&&!document.getElementById(ve)){const t=document.createElement("style");t.id=ve,t.textContent=be,document.head.appendChild(t)}this._parentMessageHandler=this.onParentMessage.bind(this),window.addEventListener("message",this._parentMessageHandler),window.parent&&window.parent!==window&&window.parent.postMessage({type:"READY"},"*"),this.isEmbedded?(await this.boot(),this.store&&await this.open()):(await this.$nextTick(),this.sendCurrentLauncherSize(),this.observeLauncherSize())},beforeUnmount(){this._parentMessageHandler&&(window.removeEventListener("message",this._parentMessageHandler),this._parentMessageHandler=null),this._launcherRo&&(this._launcherRo.disconnect(),this._launcherRo=null),this.cancelReveals(),this.teardownLiveReveal(),this.disconnectFloatRO(),this.resetApprovalPacing(),this.teardownNotifications(),this.store&&this.store.destroy()},methods:{t(t,n){return this.translator(t,n)},waitForParentInit(){if(this.parentInitReceived)return Promise.resolve();if(!this.parentInitDeferred){let t;this.parentInitDeferred=new Promise(n=>{t=n}),this.parentInitDeferred._resolve=t}return this.parentInitDeferred},onParentMessage(t){var r;const n=t==null?void 0:t.data;if(!(!n||typeof n!="object")){if(n.type==="UPDATE"){this.transport&&n.payload&&this.transport.update(n.payload).catch(s=>{console.warn("[messenger] update failed",s)});return}if(n.type==="CONTEXT"){this.transport&&n.payload&&this.transport.context(n.payload);return}n.type==="INIT"&&(this.parentOrigin=t.origin,this.parentToken=typeof n.token=="string"?n.token:"",this.parentVariables=n.variables&&typeof n.variables=="object"?n.variables:n.context&&typeof n.context=="object"?n.context:null,this.parentAllowUnauthenticated=n.allowUnauthenticated===!0,this.parentInitReceived=!0,(r=this.parentInitDeferred)!=null&&r._resolve&&this.parentInitDeferred._resolve(),!this.isEmbedded&&!this.isOpen&&!this.parentAllowUnauthenticated&&this.parentToken&&this.hasValidSessionMarker()&&this.boot().catch(s=>{console.warn("[messenger] eager boot failed",s)}))}},hasValidSessionMarker(){if(typeof document>"u")return!1;const n=(document.cookie||"").match(/(?:^|; )messenger_session_marker=([^;]+)/);if(!n)return!1;const r=parseInt(n[1],10);return Number.isFinite(r)?r>Date.now():!1},async boot(){if(!this.canBoot){console.warn("[messenger] boot skipped — missing creds");return}try{await this.waitForParentInit(),this.transport=e.markRaw(ke({baseUrl:this.baseUrl,widgetId:this.widgetId})),this.store=e.markRaw(we(this.transport)),this.hydrateNotifPref();const t=this.parentVariables||this.context||null;if(await this.store.start({origin:this.parentOrigin,token:this.parentToken||void 0,allowUnauthenticated:this.parentAllowUnauthenticated,variables:t&&typeof t=="object"?t:void 0}),t&&typeof t=="object"){const n={};for(const[r,s]of Object.entries(t))r!=="customer"&&s&&typeof s=="object"&&!Array.isArray(s)&&(n[r]=s);Object.keys(n).length>0&&this.transport.context(n)}this.setupLiveReveal()}catch(t){console.error("[ww-messenger] bootstrap failed",t),this.bootError=(t==null?void 0:t.message)||String(t)}},async refresh(){this.store&&this.store.destroy(),this.cancelReveals(),this.teardownLiveReveal(),this.teardownNotifications(),this.convOpenedAt=0,this.transport=null,this.store=null,this.isOpen=!1,this.draft="",this.busy=!1,this.bootError=null,this.pendingAttachments=[],this.feedbackBusy=!1,this.feedbackDone=!1,this.moreOpen=!1,this.renameDialogOpen=!1,this.draftConv=null,this.activeConvId=null,this.showOnboarding=!1,this.showHistory=!1,await this.boot(),this.isEmbedded&&this.store&&await this.open()},syncFloatObserver(t){if(this.disconnectFloatRO(),!t){this.floatHeight=0;return}const n=this.$refs.floatEl;if(n){if(typeof ResizeObserver>"u"){this.floatHeight=Math.ceil(n.getBoundingClientRect().height+8);return}this.floatRO=new ResizeObserver(r=>{const s=r[0];if(!s)return;const a=Math.ceil(s.contentRect.height+8);a!==this.floatHeight&&(this.floatHeight=a,this.$nextTick(()=>{var o,i;(i=(o=this.$refs.messageList)==null?void 0:o.scrollToBottom)==null||i.call(o)}))}),this.floatRO.observe(n)}},disconnectFloatRO(){if(this.floatRO){try{this.floatRO.disconnect()}catch{}this.floatRO=null}},async open(){this.isOpen=!0,this.notifyParentResize("open"),this._launcherRo&&this._launcherRo.disconnect(),this.store||await this.boot(),this.store&&this.store.setPanelOpen(!0);const t=this.currentConv;if(t&&!t._draft){this.activeConvId==null&&(this.activeConvId=t.id);try{await this.store.openConversation(t.id)}catch(n){console.error("[ww-messenger] load messages failed",n)}this.markConvRead(t)}},async close(){this.isOpen=!1,await this.$nextTick(),this.sendCurrentLauncherSize(),this.observeLauncherSize(),this.store&&this.store.setPanelOpen(!1)},notifyParentResize(t,n){if(window.parent&&window.parent!==window)try{window.parent.postMessage({type:"RESIZE",state:t,displayMode:this.displayMode,...n||{}},"*")}catch(r){console.warn("[ww-messenger] notifyParentResize failed",r)}},onLauncherHover(t){this.launcherHovered=t,this.sendCurrentLauncherSize()},sendCurrentLauncherSize(){var _,C,N,k,L,b,V;if(this.isOpen)return;const t=(C=(_=this.$el)==null?void 0:_.querySelector)==null?void 0:C.call(_,".wm-launcherWrap");if(!t)return;const n=t.getBoundingClientRect();if(!n.width||!n.height)return;const r=(((N=this.launcherPeeks)==null?void 0:N.length)??0)>0,s=16,a=Math.ceil(n.width),o=Math.ceil(n.height),i=(L=(k=this.$el)==null?void 0:k.querySelector)==null?void 0:L.call(k,".wm-launcher"),l=(V=(b=this.$el)==null?void 0:b.querySelectorAll)==null?void 0:V.call(b,".wm-peek"),f=l&&l.length?l[l.length-1]:null;let y=null;if(f){const M=f.getBoundingClientRect();y={width:Math.ceil(M.width),height:Math.ceil(M.height),rightOffset:Math.max(0,Math.ceil(n.right-M.right)),bottomOffset:Math.max(0,Math.ceil(n.bottom-M.bottom))}}this.notifyParentResize("closed",{width:a+s,height:o+s,launcherWidth:(i==null?void 0:i.offsetWidth)||null,launcherHeight:(i==null?void 0:i.offsetHeight)||null,launcherHovered:this.launcherHovered,peek:y,peekHovered:this.launcherHovered&&r})},observeLauncherSize(){var r,s;if(typeof ResizeObserver>"u")return;const t=(s=(r=this.$el)==null?void 0:r.querySelector)==null?void 0:s.call(r,".wm-launcherWrap");if(!t)return;this._launcherRo&&this._launcherRo.disconnect();const n=new ResizeObserver(()=>{this.isOpen||this.sendCurrentLauncherSize()});n.observe(t),this._launcherRo=n},async openFromPeek(t){var r,s;const n=t||((r=this.latestUnreads[0])==null?void 0:r.convId);n&&n!==((s=this.currentConv)==null?void 0:s.id)&&(this.draftConv=null,this.activeConvId=n,this.showOnboarding=!1,this.showHistory=!1),await this.open()},dismissPeek(t){const n=this.latestUnreads.find(r=>r.convId===t);n&&(this.dismissedPeeks={...this.dismissedPeeks,[t]:n.ts})},startConv(){this.draftConv={id:"__draft__",_draft:!0,name:"",created_at:new Date().toISOString()},this.activeConvId=null,this.showOnboarding=!1,this.showHistory=!1,this.focusComposer()},async ensureRealConv(){const t=this.currentConv;if(!t)return null;if(!t._draft)return t;if(this.busy)return null;this.busy=!0;try{const n=await this.store.createConversation({});return this.draftConv=null,this.activeConvId=n.id,await this.store.openConversation(n.id),this.markConvRead(n),n}catch(n){return console.error("[ww-messenger] create conv failed",n),this.bootError=(n==null?void 0:n.message)||String(n),null}finally{this.busy=!1}},focusComposer(){this.$nextTick(()=>{var t;return(t=this.$refs.composer)==null?void 0:t.focus()})},toggleMore(){this.moreOpen=!this.moreOpen},goHome(){this.moreOpen=!1,this.draftConv=null,this.activeConvId=null,this.showOnboarding=!0,this.showHistory=!1},async onDrawerPick(t){if(!(t!=null&&t.id)||!this.store)return;this.draftConv=null,this.activeConvId=t.id,this.showOnboarding=!1,this.showHistory=!1;try{await this.store.openConversation(t.id)}catch(r){console.error("[ww-messenger] open conv failed",r)}const n=this.allConversations.find(r=>r.id===t.id);n&&this.markConvRead(n)},async onMoreAction(t){var n,r;switch(this.moreOpen=!1,t){case"rename":this.openRenameDialog();break;case"export":ft(this.currentConv,this.currentConv?(r=(n=this.s)==null?void 0:n.messagesByConv)==null?void 0:r[this.currentConv.id]:[],this.translator,this.locale);break;case"status":if(ne(this.statusUrl))try{window.open(this.statusUrl,"_blank","noopener")}catch{}break;case"help":if(ne(this.helpUrl))try{window.open(this.helpUrl,"_blank","noopener")}catch{}break}},openRenameDialog(){const t=this.currentConv;!t||t._draft||(this.renameDialogOpen=!0)},async onRenameSubmit(t){const n=this.currentConv;if(this.renameDialogOpen=!1,!n||n._draft||!this.store)return;const r=(t||"").trim();if(!(!r||r===n.name))try{await this.store.patchConversation(n.id,{name:r})}catch(s){console.error("[ww-messenger] rename failed",s)}},async onSend(t){let n=this.currentConv;if(!n&&(this.startConv(),n=this.currentConv,!n)||n._draft&&(n=await this.ensureRealConv(),!n))return;const r=n.id,s=this.pendingAttachments.slice();this.pendingAttachments=[],this.unreadAnchorId=null,this.unreadBoundaryTs="",await this.store.send(r,t,{attachments:s.length?s:void 0})},async onSuggestion(t){const n=t==null?void 0:t.label;n&&await this.onSend(n)},async onLoadMore(){var n;const t=(n=this.currentConv)==null?void 0:n.id;!t||!this.store||await this.store.loadMore(t)},async onApprovalCallback(t){const n=this.pendingApproval;n&&await this.store.clickCallback(n.id,t)},async onFormSubmit({values:t}){const n=this.pendingForm;if(!(n!=null&&n.form))return;const r=ct(n.form,t,this.translator);if(!r)return;let s=this.currentConv;s&&(s._draft&&(s=await this.ensureRealConv(),!s)||await this.store.send(s.id,r,{metadata:{artifact:dt(n.form,t,this.translator)}}))},async onAttach(t){if(!(!t||!this.transport))try{const n=await this.transport.uploadAttachment(t);this.pendingAttachments.push({type:n.type||"file",path:n.path,name:t.name||this.t("attachment.fileFallbackName"),mime_type:t.type,size_bytes:t.size})}catch(n){console.error("[ww-messenger] attachment upload failed",n)}},onPanelClick(t){const n=t.target&&t.target.closest?t.target.closest('a[href^="#"]'):null;n&&(t.preventDefault(),this.openInternalUrl(n.getAttribute("href")))},async openInternalUrl(t){if(typeof t!="string"||!t.startsWith("#"))return!1;const n=t.slice(1);if(n==="new"||n==="new-conversation")return this.isOpen||await this.open(),this.startConv(),!0;if(n.startsWith("conversation/")){const r=n.slice(13);return r&&await this.openFromPeek(r),!0}return console.warn("[messenger] unknown internal url",t),!0},async onQuickLink(t){if(t){if(t.url){if(await this.openInternalUrl(t.url))return;if(!ne(t.url)){console.warn("[messenger] refusing unsafe quick-link url",t.url);return}try{window.open(t.url,"_blank","noopener")}catch{}return}this.currentConv||this.startConv(),await this.onSend(t.label)}},async onFeedback({rating:t,comment:n}){if(this.currentConv){this.feedbackBusy=!0;try{await this.store.submitFeedback(this.currentConv.id,{rating:t,comment:n}),this.feedbackDone=!0}catch(r){console.error("[ww-messenger] feedback failed",r)}finally{this.feedbackBusy=!1}}}}},Ls={key:0,class:"wm-loading","aria-busy":"true","aria-live":"polite"},Os=["aria-label"],Ds={key:0,class:"wm-state"},Is={class:"wm-state__err"},Rs={class:"wm-state__errTitle"},Fs={class:"wm-state__errSub"},Ps={class:"wm-bottom"},Us={key:0,ref:"floatEl",class:"wm-float"},zs={key:1,class:"wm-actionWait",role:"status","aria-live":"polite"},js={class:"wm-actionWait__lbl"},Hs={key:2,class:"wm-attached"},qs=["aria-label","onClick"];function Ks(t,n,r,s,a,o){const i=e.resolveComponent("Launcher"),l=e.resolveComponent("Header"),f=e.resolveComponent("History"),y=e.resolveComponent("Onboarding"),_=e.resolveComponent("MessageList"),C=e.resolveComponent("ApprovalCard"),N=e.resolveComponent("FormCard"),k=e.resolveComponent("Feedback"),L=e.resolveComponent("SuggestionChips"),b=e.resolveComponent("Composer"),V=e.resolveComponent("MoreMenu"),M=e.resolveComponent("RenameDialog");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-root",`wm-root--${r.displayMode}`]),style:e.normalizeStyle(o.rootStyle)},[!a.isOpen&&!o.isEmbedded?(e.openBlock(),e.createBlock(i,{key:0,"unread-count":o.unreadCount,peeks:o.launcherPeeks,onOpen:o.openFromPeek,onDismiss:o.dismissPeek,onHover:o.onLauncherHover},null,8,["unread-count","peeks","onOpen","onDismiss","onHover"])):e.createCommentVNode("",!0),a.isOpen||o.isEmbedded?(e.openBlock(),e.createElementBlock("section",{key:1,class:e.normalizeClass(["wm-panel",`wm-panel--${r.displayMode}`,{"wm-panel--welcome":o.ready&&!o.error&&!o.currentConv}]),style:e.normalizeStyle(a.floatHeight?{"--wm-float-h":a.floatHeight+"px"}:null),role:"dialog","aria-label":"Messenger",onClick:n[6]||(n[6]=(...A)=>o.onPanelClick&&o.onPanelClick(...A))},[!o.ready&&!o.error?(e.openBlock(),e.createElementBlock("div",Ls,[o.isEmbedded?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-loading__close","aria-label":o.t("loading.minimize"),onClick:n[0]||(n[0]=(...A)=>o.close&&o.close(...A))},[...n[7]||(n[7]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,Os)),n[8]||(n[8]=e.createElementVNode("div",{class:"wm-loading__spinner","aria-hidden":"true"},null,-1))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(l,{title:o.headerTitle,"team-members":o.teamMembers,"response-label":o.responseLabel,"show-identity":!!o.currentConv,"show-back":o.canBack,"show-close":!o.isEmbedded,"more-active":a.moreOpen,"agent-name":o.agentName,"agent-avatar-url":o.agentAvatarUrl,onBack:o.goHome,onMore:o.toggleMore,onClose:o.close},null,8,["title","team-members","response-label","show-identity","show-back","show-close","more-active","agent-name","agent-avatar-url","onBack","onMore","onClose"]),o.error?(e.openBlock(),e.createElementBlock("div",Ds,[e.createElementVNode("div",Is,[n[9]||(n[9]=e.createElementVNode("div",{class:"wm-state__errIcon"},[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})])],-1)),e.createElementVNode("div",null,[e.createElementVNode("div",Rs,e.toDisplayString(o.t("error.connectionFailed")),1),e.createElementVNode("div",Fs,e.toDisplayString(o.error),1)])])])):!o.currentConv&&a.showHistory?(e.openBlock(),e.createBlock(f,{key:1,threads:o.openThreads,onResume:o.onDrawerPick},null,8,["threads","onResume"])):o.currentConv?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createVNode(_,{ref:"messageList",messages:o.displayedMessages,"streaming-active":o.streamingActive,"date-label":o.dateLabel,"conversation-id":o.currentConv?o.currentConv.id:null,"loading-more":o.paginationState.loading,"has-more":o.paginationState.hasMore,"unread-anchor-id":t.unreadAnchorId,"unread-boundary-ts":t.unreadBoundaryTs,"ai-agent-name":o.agentName,"ai-agent-avatar-url":o.agentAvatarUrl,onLoadMore:o.onLoadMore},null,8,["messages","streaming-active","date-label","conversation-id","loading-more","has-more","unread-anchor-id","unread-boundary-ts","ai-agent-name","ai-agent-avatar-url","onLoadMore"]),e.createElementVNode("div",Ps,[o.floatVisible?(e.openBlock(),e.createElementBlock("div",Us,[o.approvalReady?(e.openBlock(),e.createBlock(C,{key:0,action:o.approvalTitle,detail:o.approvalDetail,callbacks:o.pendingApproval.callbacks,"agent-name":o.agentName,"agent-avatar-url":o.agentAvatarUrl,onCallback:o.onApprovalCallback},null,8,["action","detail","callbacks","agent-name","agent-avatar-url","onCallback"])):o.pendingForm?(e.openBlock(),e.createBlock(N,{key:o.pendingForm.message&&o.pendingForm.message.id,form:o.pendingForm.form,"agent-name":o.agentName,"agent-avatar-url":o.agentAvatarUrl,onSubmit:o.onFormSubmit},null,8,["form","agent-name","agent-avatar-url","onSubmit"])):o.showFeedback?(e.openBlock(),e.createBlock(k,{key:2,busy:a.feedbackBusy,done:a.feedbackDone,onSubmit:o.onFeedback},null,8,["busy","done","onSubmit"])):(e.openBlock(),e.createBlock(L,{key:3,items:o.suggestions,onSelect:o.onSuggestion},null,8,["items","onSelect"]))],512)):e.createCommentVNode("",!0),o.actionInFlight?(e.openBlock(),e.createElementBlock("div",zs,[n[10]||(n[10]=e.createElementVNode("span",{class:"wm-actionWait__spinner","aria-hidden":"true"},null,-1)),e.createElementVNode("span",js,e.toDisplayString(o.t("action.inProgress",{name:o.actionInFlightName})),1)])):(e.openBlock(),e.createBlock(b,{key:2,ref:"composer",modelValue:a.draft,"onUpdate:modelValue":n[2]||(n[2]=A=>a.draft=A),placeholder:o.composerPlaceholder,disabled:!!o.pendingApproval,"attach-label":o.t("composer.attachFile"),"display-mode":r.displayMode,onSend:o.onSend,onAttach:o.onAttach},null,8,["modelValue","placeholder","disabled","attach-label","display-mode","onSend","onAttach"]))]),a.moreOpen?(e.openBlock(),e.createBlock(V,{key:0,"can-rename":!!o.currentConv&&!o.currentConv._draft,"can-export":!!o.currentConv&&!o.currentConv._draft,"sound-enabled":t.soundEnabled,"browser-notif-enabled":t.browserNotifEnabled,"status-url":o.statusUrl,"help-url":o.helpUrl,onClose:n[3]||(n[3]=A=>a.moreOpen=!1),onSoundToggle:t.onSoundToggle,onBrowserNotifToggle:t.onBrowserNotifToggle,onAction:o.onMoreAction},null,8,["can-rename","can-export","sound-enabled","browser-notif-enabled","status-url","help-url","onSoundToggle","onBrowserNotifToggle","onAction"])):e.createCommentVNode("",!0),a.renameDialogOpen&&o.currentConv&&!o.currentConv._draft?(e.openBlock(),e.createBlock(M,{key:1,"initial-value":o.currentConv.name||"",title:o.t("rename.dialogTitle"),onClose:n[4]||(n[4]=A=>a.renameDialogOpen=!1),onSubmit:o.onRenameSubmit},null,8,["initial-value","title","onSubmit"])):e.createCommentVNode("",!0),a.pendingAttachments.length?(e.openBlock(),e.createElementBlock("div",Hs,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.pendingAttachments,(A,D)=>(e.openBlock(),e.createElementBlock("div",{key:D,class:"wm-attached__chip"},[n[12]||(n[12]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})],-1)),e.createElementVNode("span",null,e.toDisplayString(A.name),1),e.createElementVNode("button",{type:"button","aria-label":o.t("attachment.remove"),onClick:U=>a.pendingAttachments.splice(D,1)},[...n[11]||(n[11]=[e.createElementVNode("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,qs)]))),128))])):e.createCommentVNode("",!0)],64)):(e.openBlock(),e.createBlock(y,{key:2,"welcome-message":o.widgetWelcomeMessage,subtitle:o.widgetSubtitle,"agent-name":o.agentName,"default-icon-url":o.defaultIconUrl,"quick-links":o.quickLinks,"open-threads":o.openThreads,busy:a.busy,onStart:o.startConv,onSelect:o.onQuickLink,onResume:o.onDrawerPick,onViewHistory:n[1]||(n[1]=A=>a.showHistory=!0)},null,8,["welcome-message","subtitle","agent-name","default-icon-url","quick-links","open-threads","busy","onStart","onSelect","onResume"])),a.moreOpen&&!o.currentConv?(e.openBlock(),e.createBlock(V,{key:4,"can-rename":!1,"can-export":!1,"sound-enabled":t.soundEnabled,"browser-notif-enabled":t.browserNotifEnabled,"status-url":o.statusUrl,"help-url":o.helpUrl,onClose:n[5]||(n[5]=A=>a.moreOpen=!1),onSoundToggle:t.onSoundToggle,onBrowserNotifToggle:t.onBrowserNotifToggle,onAction:o.onMoreAction},null,8,["sound-enabled","browser-notif-enabled","status-url","help-url","onSoundToggle","onBrowserNotifToggle","onAction"])):e.createCommentVNode("",!0)],64))],6)):e.createCommentVNode("",!0)],6)}const Qe=S(xs,[["render",Ks],["__scopeId","data-v-543e7817"]]),$s="0.5.47";exports.AIAvatar=H;exports.AVATAR_COLORS=te;exports.ActionResult=Le;exports.ApprovalCard=Ge;exports.ArtifactFormResponse=Oe;exports.ArtifactInfoCard=De;exports.ArtifactRenderer=Re;exports.ArtifactTicket=Ie;exports.AttachmentPreview=Fe;exports.Bubble=Pe;exports.Composer=$e;exports.DEFAULT_BASE_URL=Ee;exports.DEFAULT_LANGUAGE=G;exports.Feedback=Xe;exports.FormCard=Ye;exports.Header=Te;exports.HumanAvatar=Q;exports.Launcher=Ve;exports.MEDIA_RECORDER_SUPPORTED=ie;exports.MessageList=ze;exports.Messenger=Qe;exports.MoreMenu=Je;exports.Onboarding=xe;exports.SCREEN_CAPTURE_SUPPORTED=J;exports.SUPPORTED_LANGUAGES=Be;exports.SuggestionChips=We;exports.TeamAvatars=Me;exports.Typing=Ue;exports.VERSION=$s;exports.avatarColor=oe;exports.avatarInitials=ae;exports.captureScreenshotFile=qe;exports.colors=x;exports.createStore=we;exports.createTranslator=T;exports.createTransport=ke;exports.dateLocale=P;exports.default=Qe;exports.formatTime=re;exports.guessAttachmentKind=Wo;exports.pickRecorderMime=je;exports.renderInlineMarkdown=me;exports.renderMarkdown=Ae;exports.resolveLanguage=se;exports.startScreenRecording=Ke;exports.tokensCss=be;exports.uuid=ue;exports.v4=ue;
53
+ `)}function dt(t,n,r=T()){const a=[],s=Array.isArray(t==null?void 0:t.fields)?t.fields:[];for(const o of s){if(!(o!=null&&o.key)||!(o!=null&&o.label))continue;const i=n==null?void 0:n[o.key];if(i==null||i==="")continue;const l=Ce(o,i,r);if(!l)continue;const f=o.type==="textarea"||typeof l=="string"&&(l.length>60||l.includes(`
54
+ `));a.push({label:o.label,value:l,multiline:f})}return{kind:"form_response",data:{title:(t==null?void 0:t.title)||r("form.title"),fields:a}}}function Be(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function te(t){return/^(https?:\/\/|mailto:|tel:)/i.test(String(t).trim())}const fe="";function Y(t){let n=t;const r=[];return n=n.replace(/`([^`\n]+)`/g,(a,s)=>{const o=r.length;return r.push(s),`${fe}CODE${o}${fe}`}),n=n.replace(/\[([^\]\n]+)\]\(([^)\s]+)\)/g,(a,s,o)=>te(o)?`<a href="${o}" target="_blank" rel="noopener noreferrer">${s}</a>`:s),n=n.replace(/\*\*([^\n*][^\n]*?)\*\*/g,"<strong>$1</strong>"),n=n.replace(/__([^\n_][^\n]*?)__/g,"<u>$1</u>"),n=n.replace(/~~([^\n~][^\n]*?)~~/g,"<s>$1</s>"),n=n.replace(/(^|[^\w*])\*([^\n*]+?)\*(?!\w)/g,"$1<em>$2</em>"),n=n.replace(/(^|[^\w_])_([^\n_]+?)_(?!\w)/g,"$1<em>$2</em>"),n=n.replace(/CODE(\d+)/g,(a,s)=>`<code class="wm-md-code">${r[+s]}</code>`),n}function Ne(t){if(!t)return"";const n=String(t).replace(/\[([^\]\n]+)\]\([^)\s]+\)/g,"$1");return Y(Be(n))}function Se(t){if(!t)return"";const n=Be(t).split(`
55
+ `),r=[];let a=0;for(;a<n.length;){const o=n[a];if(/^\s*```([\w-]*)\s*$/.exec(o)){a++;const y=[];for(;a<n.length&&!/^\s*```\s*$/.test(n[a]);)y.push(n[a]),a++;a<n.length&&a++,r.push({type:"block",html:`<pre class="wm-md-pre"><code>${y.join(`
56
+ `)}</code></pre>`});continue}if(/^\s*[-*]\s+/.test(o)){const y=[];for(;a<n.length;){const C=/^\s*[-*]\s+(.*)$/.exec(n[a]);if(!C)break;y.push(C[1]),a++}const _=y.map(C=>`<li>${Y(C)}</li>`).join("");r.push({type:"block",html:`<ul class="wm-md-ul">${_}</ul>`});continue}const l=/^\s*(\d+)\.\s+(.*)$/.exec(o);if(l){const y=parseInt(l[1],10),_=[l[2]];for(a++;a<n.length;){const k=/^\s*\d+\.\s+(.*)$/.exec(n[a]);if(!k)break;_.push(k[1]),a++}const C=_.map(k=>`<li>${Y(k)}</li>`).join(""),N=y!==1?` start="${y}"`:"";r.push({type:"block",html:`<ol class="wm-md-ol"${N}>${C}</ol>`});continue}const f=/^(#{1,6})\s+(.*)$/.exec(o);if(f){const y=f[1].length;r.push({type:"block",html:`<h${y} class="wm-md-h wm-md-h${y}">${Y(f[2])}</h${y}>`}),a++;continue}r.push({type:"text",html:Y(o)}),a++}let s="";for(let o=0;o<r.length;o++){const i=r[o];s+=i.html;const l=r[o+1];l&&i.type!=="block"&&l.type!=="block"&&(s+=`
57
+ `)}return s}function X(t){var r;const n=(r=t==null?void 0:t.author)==null?void 0:r.type;return n==="agent_ia"||n==="agent_human"}function R(t){if(t==null)return null;const n=typeof t=="number"?t:Number(t);return Number.isFinite(n)?n:null}function pe(t,n){let r=(t==null?void 0:t.last_message_at)||(t==null?void 0:t.updated_at)||(t==null?void 0:t.created_at)||"";for(const a of n)a!=null&&a.created_at&&a.created_at>r&&(r=a.created_at);return r}function ut(t,n){var r,a,s;for(let o=n.length-1;o>=0;o--){const i=n[o];if(!i)continue;const l=typeof i.text_md=="string"?i.text_md.trim():"";if(l)return(((r=i.author)==null?void 0:r.type)==="user"?"Vous : ":"")+l.replace(/\s+/g," ");const f=(a=i.payload)==null?void 0:a.attachments;if(Array.isArray(f)&&f.length)return"📎 Pièce jointe"}return(t==null?void 0:t.last_message_preview)||(t==null?void 0:t.preview)||((s=t==null?void 0:t.metadata)==null?void 0:s.last_preview)||""}function mt(t,n){return(t==null?void 0:t.name)||((t==null?void 0:t.type)==="user"?n("common.you"):(t==null?void 0:t.type)==="agent_human"?n("common.agent"):(t==null?void 0:t.type)==="agent_ia"?n("common.aiAssistant"):n("common.system"))}function ht(t,n,r,a){const s=[`# ${t.name||r("common.conversation")}`,t.created_at?r("export.createdOn",{date:new Date(t.created_at).toLocaleString(a)}):"",""];for(const o of n){if(!o)continue;const i=(o.text_md||"").trim();if(!i)continue;const l=mt(o.author,r),f=o.created_at?new Date(o.created_at).toLocaleString(a):"";s.push(`[${f}] ${l} :`),s.push(i),s.push("")}return s.join(`
58
+ `)}function ft(t,n,r=T(),a){if(!t)return;const s=ht(t,n||[],r,z(a)),o=new Blob([s],{type:"text/plain;charset=utf-8"});try{const i=URL.createObjectURL(o),l=document.createElement("a");l.href=i,l.download=`${(t.name||"conversation").replace(/[^a-z0-9-_]+/gi,"_")}.txt`,document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(i),1e3)}catch(i){console.error("[ww-messenger] export failed",i)}}const pt={data(){const t=typeof Notification<"u";return{notifPermission:t?Notification.permission:"denied",soundEnabled:!0,browserNotifEnabled:t&&Notification.permission==="granted",_audioCtx:null}},methods:{teardownNotifications(){var t,n;if(this._audioCtx){try{(n=(t=this._audioCtx).close)==null||n.call(t)}catch{}this._audioCtx=null}},soundStorageKey(){return`wm:notif:sound:${this.widgetId||""}`},browserNotifStorageKey(){return`wm:notif:browser:${this.widgetId||""}`},hydrateNotifPref(){try{if(typeof localStorage>"u")return;const t=localStorage.getItem(this.soundStorageKey());t==="0"?this.soundEnabled=!1:t==="1"&&(this.soundEnabled=!0);const n=localStorage.getItem(this.browserNotifStorageKey());n==="0"?this.browserNotifEnabled=!1:n==="1"&&(this.browserNotifEnabled=typeof Notification<"u"&&Notification.permission==="granted")}catch{}},persistSoundPref(){try{if(typeof localStorage>"u")return;localStorage.setItem(this.soundStorageKey(),this.soundEnabled?"1":"0")}catch{}},persistBrowserNotifPref(){try{if(typeof localStorage>"u")return;localStorage.setItem(this.browserNotifStorageKey(),this.browserNotifEnabled?"1":"0")}catch{}},onSoundToggle(t){this.soundEnabled=!!t,this.persistSoundPref()},async onBrowserNotifToggle(t){if(typeof Notification>"u"){this.browserNotifEnabled=!1,this.persistBrowserNotifPref();return}if(!t){this.browserNotifEnabled=!1,this.persistBrowserNotifPref();return}let n=Notification.permission;if(n==="default"){try{n=await Notification.requestPermission()}catch(r){console.warn("[ww-messenger] notif permission request failed",r),n="denied"}this.notifPermission=n}this.browserNotifEnabled=n==="granted",this.persistBrowserNotifPref()},onMessageRevealed(t,n){var s;if(!this.soundEnabled&&!this.browserNotifEnabled||!n||!t||!X(t))return;const r=typeof document<"u"&&document.hidden;this.isOpen&&!r&&((s=this.currentConv)==null?void 0:s.id)===n||(this.soundEnabled&&this.playNotificationSound(),this.browserNotifEnabled&&this.showBrowserNotification(n,t))},playNotificationSound(){if(typeof window>"u")return;const t=window.AudioContext||window.webkitAudioContext;if(t)try{this._audioCtx||(this._audioCtx=new t);const n=this._audioCtx;if(n.state==="suspended")try{n.resume()}catch{}const r=n.currentTime,a=n.createOscillator(),s=n.createGain();a.connect(s),s.connect(n.destination),a.type="sine",a.frequency.setValueAtTime(880,r),a.frequency.exponentialRampToValueAtTime(1320,r+.08),s.gain.setValueAtTime(0,r),s.gain.linearRampToValueAtTime(.12,r+.02),s.gain.exponentialRampToValueAtTime(1e-4,r+.28),a.start(r),a.stop(r+.32)}catch{}},showBrowserNotification(t,n){if(typeof Notification>"u"||Notification.permission!=="granted")return;const r=n==null?void 0:n.author,a=!r||r.type==="agent_ia",o=((r==null?void 0:r.name)||(a?this.agentName:"")||this.t("launcher.theAgent"))+this.t("launcher.repliedToYou"),i=typeof(n==null?void 0:n.text_md)=="string"?n.text_md.trim():"",l=i?i.slice(0,140):this.t("notification.youHaveNewMessage");try{const f=new Notification(o,{body:l,tag:`wm-${t}`,renotify:!1,silent:!0});f.onclick=()=>{try{window.focus()}catch{}this.draftConv=null,this.showOnboarding=!1,this.activeConvId=t,this.isOpen=!0,this.store&&this.store.setPanelOpen(!0);try{f.close()}catch{}}}catch(f){console.warn("[ww-messenger] notification failed",f)}}}},gt=450,_t=50,yt=900,vt=12e3,kt=300,wt={data(){return{revealedAt:{},nextRevealAt:0,revealTimers:[],_liveRevealOff:null,_liveRevealConvSnapshot:null}},methods:{cancelReveals(){for(const t of this.revealTimers)clearTimeout(t);this.revealTimers=[]},resetRevealQueue(){this.cancelReveals(),this.revealedAt={},this.nextRevealAt=0},setupLiveReveal(){var r;if(!this.transport)return;this.teardownLiveReveal();const t=this.transport.on("message",a=>{const s=a==null?void 0:a.conversation_id,o=a==null?void 0:a.message;s&&o&&this.paceLiveMessage(o,s)});this._liveRevealConvSnapshot=new Map((((r=this.s)==null?void 0:r.conversations)||[]).map(a=>[a.id,(a==null?void 0:a.last_message_at)||""]));const n=this.transport.on("activity",a=>{this.handleLiveActivity(a)});this._liveRevealOff=()=>{try{t()}catch{}try{n()}catch{}}},teardownLiveReveal(){if(this._liveRevealOff){try{this._liveRevealOff()}catch{}this._liveRevealOff=null}this._liveRevealConvSnapshot=null},async handleLiveActivity(t){var s,o;const n=t==null?void 0:t.conversations;if(!Array.isArray(n)||!this.store)return;const r=this._liveRevealConvSnapshot||new Map,a=[];for(const i of n){if(!(i!=null&&i.id))continue;const l=i.last_message_at||"";if(!l)continue;const f=r.get(i.id)||"";l>f&&a.push(i.id)}this._liveRevealConvSnapshot=new Map(n.map(i=>[i.id,(i==null?void 0:i.last_message_at)||""]));for(const i of a)try{const l=await((o=(s=this.store).fetchSinceLast)==null?void 0:o.call(s,i));if(!Array.isArray(l))continue;for(const f of l)this.paceLiveMessage(f,i)}catch(l){console.error("[ww-messenger] activity delta fetch failed",l)}},scheduleReveal(t,n){const r=Date.now(),a=((t==null?void 0:t.text_md)||"").length,s=Math.min(vt,Math.max(yt,a*_t)),i=Math.max(r+gt,this.nextRevealAt+kt)+s;this.nextRevealAt=i;const l=Math.max(0,i-r),f=t.id,y=setTimeout(()=>{this.revealedAt={...this.revealedAt,[f]:Date.now()},this.revealTimers=this.revealTimers.filter(_=>_!==y),typeof this.onMessageRevealed=="function"&&this.onMessageRevealed(t,n)},l);this.revealTimers.push(y)},paceMessages(t,n){var s;if(!Array.isArray(t)||!t.length)return;const r=Date.now(),a={...this.revealedAt};for(const o of t){if((o==null?void 0:o.id)==null||a[o.id]!==void 0)continue;if(!X(o)){a[o.id]=r;continue}const i=o!=null&&o.created_at?Date.parse(o.created_at):NaN;if(!Number.isFinite(i)||i<this.convOpenedAt){a[o.id]=r;continue}const l=typeof(o==null?void 0:o.text_md)=="string"&&o.text_md.trim().length>0,f=Array.isArray((s=o==null?void 0:o.payload)==null?void 0:s.attachments)&&o.payload.attachments.length>0;if(!l&&!f){a[o.id]=r;continue}a[o.id]=0,this.scheduleReveal(o,n)}this.revealedAt=a},paceLiveMessage(t,n){var s;if(!(t!=null&&t.id)||this.revealedAt[t.id]!==void 0)return;if(!X(t)){this.revealedAt={...this.revealedAt,[t.id]:Date.now()};return}const r=typeof(t==null?void 0:t.text_md)=="string"&&t.text_md.trim().length>0,a=Array.isArray((s=t==null?void 0:t.payload)==null?void 0:s.attachments)&&t.payload.attachments.length>0;if(!r&&!a){this.revealedAt={...this.revealedAt,[t.id]:Date.now()};return}this.revealedAt={...this.revealedAt,[t.id]:0},this.scheduleReveal(t,n)}}},bt={data(){return{approvalSettled:!0,approvalSettleTimer:null,approvalLatchId:null}},methods:{resetApprovalPacing(){this.approvalSettleTimer&&(clearTimeout(this.approvalSettleTimer),this.approvalSettleTimer=null),this.approvalSettled=!0,this.approvalLatchId=null},bumpApprovalSettle(t=800){this.approvalSettled=!1,this.approvalSettleTimer&&clearTimeout(this.approvalSettleTimer),this.approvalSettleTimer=setTimeout(()=>{this.approvalSettled=!0,this.approvalSettleTimer=null},t)}}},Et=300,Ct={data(){return{unreadAnchorId:null,unreadBoundaryTs:""}},created(){this._readMarkerTimer=null,this._readMarkerPending=null},beforeUnmount(){this._readMarkerTimer&&(clearTimeout(this._readMarkerTimer),this._readMarkerTimer=null),this._readMarkerPending=null},methods:{markConvRead(t){var o,i;if(!(t!=null&&t.id)||t._draft||!this.store)return;const n=((i=(o=this.s)==null?void 0:o.messagesByConv)==null?void 0:i[t.id])||[],r=Bt(n);if(r==null)return;const a=R(t.last_read_message_id),s=R(r);s!=null&&(a!=null&&s<=a||(this._readMarkerPending={convId:t.id,messageId:r},!this._readMarkerTimer&&(this._readMarkerTimer=setTimeout(()=>{const l=this._readMarkerPending;this._readMarkerPending=null,this._readMarkerTimer=null,l&&this.store&&this.store.markConversationRead(l.convId,l.messageId)},Et))))}}};function Bt(t){for(let n=t.length-1;n>=0;n--){const r=t[n];if(!(!r||r._pending)&&R(r.id)!=null)return r.id}return null}const S=(t,n)=>{const r=t.__vccOpts||t;for(const[a,s]of n)r[a]=s;return r},Nt={name:"WmHumanAvatar",props:{name:{type:String,default:""},avatarUrl:{type:String,default:null},size:{type:Number,default:26},tail:{type:Boolean,default:!1}},computed:{bg(){return this.avatarUrl?"transparent":re(this.name)},initials(){return oe(this.name)}}},St=["src","alt"];function At(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-huav",{"wm-huav--tail":r.tail}]),style:e.normalizeStyle({width:r.size+"px",height:r.size+"px","--wm-avr":Math.round(r.size*.32)+"px",background:o.bg})},[r.avatarUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.avatarUrl,alt:r.name||""},null,8,St)):(e.openBlock(),e.createElementBlock("span",{key:1,style:e.normalizeStyle({fontSize:r.size*.36+"px"})},e.toDisplayString(o.initials),5))],6)}const ae=S(Nt,[["render",At],["__scopeId","data-v-14e10c0d"]]),Vt=3,Mt={name:"WmLauncher",components:{HumanAvatar:ae},inject:{t:{default:()=>T()}},props:{unreadCount:{type:Number,default:0},peeks:{type:Array,default:()=>[]}},emits:["open","dismiss"],computed:{visiblePeeks(){return this.peeks.slice(0,Vt).reverse()}}},Tt=["aria-label","onClick","onKeydown"],xt=["aria-label","onClick"],Ot={class:"wm-peek__avatar"},Lt=["aria-label"],Dt={class:"wm-peek__body"},It={class:"wm-peek__head"},Rt={class:"wm-peek__name"},Ft={class:"wm-peek__action"},Pt={class:"wm-peek__text"},Ut=["onClick"],jt=["aria-label"],zt=["aria-label"];function Ht(t,n,r,a,s,o){const i=e.resolveComponent("HumanAvatar");return e.openBlock(),e.createElementBlock("div",{class:"wm-launcherWrap",onMouseenter:n[1]||(n[1]=l=>t.$emit("hover",!0)),onMouseleave:n[2]||(n[2]=l=>t.$emit("hover",!1)),onFocusin:n[3]||(n[3]=l=>t.$emit("hover",!0)),onFocusout:n[4]||(n[4]=l=>t.$emit("hover",!1))},[e.createVNode(e.Transition,{name:"wm-peek"},{default:e.withCtx(()=>[o.visiblePeeks.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["wm-peekStack",{"wm-peekStack--multi":o.visiblePeeks.length>1}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.visiblePeeks,(l,f)=>(e.openBlock(),e.createElementBlock("div",{key:l.convId,class:"wm-peek",style:e.normalizeStyle({"--depth":o.visiblePeeks.length-1-f,zIndex:f+1}),role:"button",tabindex:"0","aria-label":o.t("launcher.openConversationWith",{name:l.senderName||o.t("launcher.theAgent")}),onClick:y=>t.$emit("open",l.convId),onKeydown:[e.withKeys(e.withModifiers(y=>t.$emit("open",l.convId),["prevent"]),["enter"]),e.withKeys(e.withModifiers(y=>t.$emit("open",l.convId),["prevent"]),["space"])]},[e.createElementVNode("button",{type:"button",class:"wm-peek__close","aria-label":o.t("launcher.dismiss"),onClick:e.withModifiers(y=>t.$emit("dismiss",l.convId),["stop"])},[...n[5]||(n[5]=[e.createElementVNode("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,xt),e.createElementVNode("div",Ot,[e.createVNode(i,{name:l.senderName,"avatar-url":l.senderAvatarUrl,size:34},null,8,["name","avatar-url"]),l.count>1?(e.openBlock(),e.createElementBlock("span",{key:0,class:"wm-peek__avatarBadge","aria-label":o.t("launcher.unreadMessages",{count:l.count})},e.toDisplayString(l.count>9?"9+":l.count),9,Lt)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Dt,[e.createElementVNode("div",It,[e.createElementVNode("span",Rt,e.toDisplayString(l.senderName||o.t("common.agent")),1),e.createElementVNode("span",Ft,e.toDisplayString(o.t("launcher.repliedToYou")),1)]),e.createElementVNode("p",Pt,e.toDisplayString(l.preview),1)]),e.createElementVNode("button",{type:"button",class:"wm-peek__open",onClick:e.withModifiers(y=>t.$emit("open",l.convId),["stop"])},e.toDisplayString(o.t("common.open")),9,Ut)],44,Tt))),128))],2)):e.createCommentVNode("",!0)]),_:1}),e.createElementVNode("button",{type:"button",class:"wm-launcher","aria-label":o.t("launcher.open"),onClick:n[0]||(n[0]=l=>t.$emit("open"))},[n[6]||(n[6]=e.createElementVNode("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})],-1)),r.unreadCount>0?(e.openBlock(),e.createElementBlock("span",{key:0,class:"wm-launcher__badge","aria-label":r.unreadCount>1?o.t("launcher.unreadConversationsMany",{count:r.unreadCount}):o.t("launcher.unreadConversationsOne",{count:r.unreadCount})},e.toDisplayString(r.unreadCount>9?"9+":r.unreadCount),9,zt)):e.createCommentVNode("",!0)],8,jt)],32)}const Ae=S(Mt,[["render",Ht],["__scopeId","data-v-44ddf1a1"]]),$t={name:"WmAIAvatar",props:{size:{type:Number,default:26},pulse:{type:Boolean,default:!1},tail:{type:Boolean,default:!1},name:{type:String,default:""},imageUrl:{type:String,default:null}},computed:{initials(){return oe(this.name)},bgColor(){return re(this.name)}}},qt={key:0,class:"wm-aiav__pulse"},Kt=["src","alt"],Wt=["width","height"];function Gt(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-aiav",{"wm-aiav--tail":r.tail}]),style:e.normalizeStyle({width:r.size+"px",height:r.size+"px","--wm-avr":r.size*.32+"px"})},[r.pulse?(e.openBlock(),e.createElementBlock("div",qt)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["wm-aiav__inner",{"wm-aiav__inner--glow":r.pulse,"wm-aiav__inner--img":!!r.imageUrl,"wm-aiav__inner--initials":!r.imageUrl&&!!o.initials}]),style:e.normalizeStyle(!r.imageUrl&&o.initials?{background:o.bgColor}:null)},[r.imageUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.imageUrl,alt:r.name||""},null,8,Kt)):o.initials?(e.openBlock(),e.createElementBlock("span",{key:1,style:e.normalizeStyle({fontSize:r.size*.36+"px"})},e.toDisplayString(o.initials),5)):(e.openBlock(),e.createElementBlock("svg",{key:2,width:r.size*.5,height:r.size*.5,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[...n[0]||(n[0]=[e.createElementVNode("path",{d:"M12 2 L13.5 9 L20 10.5 L13.5 12 L12 19 L10.5 12 L4 10.5 L10.5 9 Z",fill:"white",opacity:"0.92"},null,-1),e.createElementVNode("circle",{cx:"19",cy:"5",r:"1.5",fill:"white",opacity:"0.55"},null,-1),e.createElementVNode("circle",{cx:"5",cy:"18",r:"1",fill:"white",opacity:"0.38"},null,-1)])],8,Wt))],6)],6)}const H=S($t,[["render",Gt],["__scopeId","data-v-6f7f685d"]]),Yt={name:"WmTeamAvatars",props:{members:{type:Array,default:()=>[]},responseLabel:{type:String,default:""}},computed:{visible(){return Array.isArray(this.members)&&this.members.length>0},stackWidth(){return Math.min(this.members.length,3)===1?20:16+Math.min(this.members.length,3)*13}},methods:{colorFor(t){return t.avatar_url?"transparent":re(t.name||"")},initialsFor(t){return oe(t.name||"")}}},Xt={key:0,class:"wm-team"},Jt=["src","alt"],Qt={key:1},Zt={key:0,class:"wm-team__label"};function en(t,n,r,a,s,o){return o.visible?(e.openBlock(),e.createElementBlock("div",Xt,[e.createElementVNode("div",{class:"wm-team__stack",style:e.normalizeStyle({width:o.stackWidth+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.members.slice(0,3),(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-team__pill",style:e.normalizeStyle({left:l*13+"px",zIndex:3-l,background:o.colorFor(i)})},[i.avatar_url?(e.openBlock(),e.createElementBlock("img",{key:0,src:i.avatar_url,alt:i.name||""},null,8,Jt)):(e.openBlock(),e.createElementBlock("span",Qt,e.toDisplayString(o.initialsFor(i)),1))],4))),128))],4),r.responseLabel?(e.openBlock(),e.createElementBlock("span",Zt,e.toDisplayString(r.responseLabel),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}const Ve=S(Yt,[["render",en],["__scopeId","data-v-e49a9063"]]),tn={name:"WmHeader",components:{AIAvatar:H,TeamAvatars:Ve},inject:{t:{default:()=>T()}},props:{title:{type:String,default:"Nouvelle conversation"},showBack:{type:Boolean,default:!1},teamMembers:{type:Array,default:()=>[]},responseLabel:{type:String,default:""},showClose:{type:Boolean,default:!0},showMore:{type:Boolean,default:!0},moreActive:{type:Boolean,default:!1},showIdentity:{type:Boolean,default:!0},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["back","close","more"],computed:{hasTeam(){return Array.isArray(this.teamMembers)&&this.teamMembers.length>0},displayedTeamMembers(){const t=Array.isArray(this.teamMembers)?this.teamMembers:[];if(t.length<=3)return t;const n=new Date().getHours()%t.length,r=[];for(let a=0;a<3;a++)r.push(t[(n+a)%t.length]);return r}}},nn={class:"wm-header"},rn=["aria-label"],on={key:1,style:{width:"30px",height:"30px","flex-shrink":"0"}},sn={class:"wm-header__avatar"},an={class:"wm-header__main"},ln={class:"wm-header__title"},cn={key:3,class:"wm-header__fill"},dn={class:"wm-header__actions"},un=["aria-label","title"],mn=["aria-label","title"];function hn(t,n,r,a,s,o){const i=e.resolveComponent("AIAvatar"),l=e.resolveComponent("TeamAvatars");return e.openBlock(),e.createElementBlock("div",nn,[r.showBack?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-header__icon","aria-label":o.t("header.backToHome"),onClick:n[0]||(n[0]=f=>t.$emit("back"))},[...n[3]||(n[3]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M19 12H5M12 5l-7 7 7 7"})],-1)])],8,rn)):(e.openBlock(),e.createElementBlock("div",on)),r.showIdentity?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createElementVNode("div",sn,[e.createVNode(i,{size:30,name:r.agentName,"image-url":r.agentAvatarUrl},null,8,["name","image-url"])]),e.createElementVNode("div",an,[e.createElementVNode("div",ln,e.toDisplayString(r.title),1)]),o.hasTeam?(e.openBlock(),e.createBlock(l,{key:0,members:o.displayedTeamMembers,"response-label":""},null,8,["members"])):e.createCommentVNode("",!0)],64)):(e.openBlock(),e.createElementBlock("div",cn)),e.createElementVNode("div",dn,[r.showMore?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["wm-header__icon",{"wm-header__icon--active":r.moreActive}]),"aria-label":o.t("header.moreOptions"),title:o.t("header.moreOptions"),onClick:n[1]||(n[1]=f=>t.$emit("more"))},[...n[4]||(n[4]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true"},[e.createElementVNode("circle",{cx:"12",cy:"5",r:"1.6"}),e.createElementVNode("circle",{cx:"12",cy:"12",r:"1.6"}),e.createElementVNode("circle",{cx:"12",cy:"19",r:"1.6"})],-1)])],10,un)):e.createCommentVNode("",!0),r.showClose?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-header__icon","aria-label":o.t("header.closeWidget"),title:o.t("header.closeWidget"),onClick:n[2]||(n[2]=f=>t.$emit("close"))},[...n[5]||(n[5]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,mn)):e.createCommentVNode("",!0)])])}const Me=S(tn,[["render",hn],["__scopeId","data-v-7af4c118"]]),ge={book:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253",changelog:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2",status:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z",chat:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z",link:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"},fn={name:"WmOnboarding",components:{AIAvatar:H},inject:{t:{default:()=>T()}},props:{welcomeMessage:{type:String,default:""},subtitle:{type:String,default:""},agentName:{type:String,default:""},defaultIconUrl:{type:String,default:null},quickLinks:{type:Array,default:()=>[]},openThreads:{type:Array,default:()=>[]},busy:{type:Boolean,default:!1}},emits:["start","select","resume","view-history"],computed:{heroTitle(){return this.welcomeMessage?this.welcomeMessage:this.agentName?this.t("onboarding.greetingNamed",{name:this.agentName}):this.t("onboarding.greeting")},heroSub(){return this.subtitle||this.t("onboarding.heroSub")},unreadThreads(){return this.openThreads.filter(t=>t.unread)}},methods:{iconPath(t){return ge[t]||ge.link},isExternalLink(t){const n=t==null?void 0:t.url;return!!n&&!n.startsWith("#")},safeIconUrl(t){return lt(t==null?void 0:t.icon_url)},iconUrlStyle(t){const n=this.safeIconUrl(t);return n?{"--icon-url":`url("${n}")`}:null}}},pn={class:"wm-onb"},gn={class:"wm-onb__hero"},_n={class:"wm-onb__hero-text"},yn={class:"wm-onb__title"},vn={class:"wm-onb__sub"},kn={class:"wm-onb__actions"},wn=["disabled"],bn={class:"wm-onb__btn-label"},En=["onClick"],Cn={class:"wm-onb__btn-icon"},Bn=["aria-label"],Nn={key:1,width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.9","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},Sn=["d"],An={class:"wm-onb__btn-label"},Vn={key:0,class:"wm-onb__btn-trail",width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},Mn=["onClick"],Tn={class:"wm-onb__btn-label"},xn=["aria-label"],On={class:"wm-onb__btn-icon"},Ln={width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},Dn=["d"],In={class:"wm-onb__btn-label"},Rn={class:"wm-onb__btn-count"};function Fn(t,n,r,a,s,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",pn,[e.createElementVNode("div",gn,[n[2]||(n[2]=e.createElementVNode("svg",{class:"wm-onb__hero-deco",width:"180",height:"180",viewBox:"0 0 180 180",fill:"none","aria-hidden":"true"},[e.createElementVNode("circle",{cx:"170",cy:"10",r:"105",stroke:"#5B5FEF","stroke-width":"1","stroke-dasharray":"1 5",opacity:"0.35"}),e.createElementVNode("circle",{cx:"170",cy:"10",r:"72",stroke:"#5B5FEF","stroke-width":"1","stroke-dasharray":"1 5",opacity:"0.5"}),e.createElementVNode("circle",{cx:"152",cy:"34",r:"2.5",fill:"#5B5FEF",opacity:"0.65"})],-1)),e.createVNode(i,{size:52,"image-url":r.defaultIconUrl},null,8,["image-url"]),e.createElementVNode("div",_n,[e.createElementVNode("div",yn,e.toDisplayString(o.heroTitle),1),e.createElementVNode("div",vn,e.toDisplayString(o.heroSub),1)])]),e.createElementVNode("div",kn,[e.createElementVNode("button",{type:"button",class:"wm-onb__btn wm-onb__btn--start",disabled:r.busy,onClick:n[0]||(n[0]=l=>t.$emit("start"))},[n[3]||(n[3]=e.createElementVNode("span",{class:"wm-onb__btn-icon"},[e.createElementVNode("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M12 5v14M5 12h14"})])],-1)),e.createElementVNode("span",bn,e.toDisplayString(r.busy?"…":o.t("onboarding.start")),1)],8,wn),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.quickLinks,(l,f)=>(e.openBlock(),e.createElementBlock("button",{key:"ql-"+f,type:"button",class:"wm-onb__btn",onClick:y=>t.$emit("select",l)},[e.createElementVNode("span",Cn,[o.safeIconUrl(l)?(e.openBlock(),e.createElementBlock("span",{key:0,class:"wm-onb__btn-iconImg",style:e.normalizeStyle(o.iconUrlStyle(l)),role:"img","aria-label":l.label||""},null,12,Bn)):(e.openBlock(),e.createElementBlock("svg",Nn,[e.createElementVNode("path",{d:o.iconPath(l.icon)},null,8,Sn)]))]),e.createElementVNode("span",An,e.toDisplayString(l.label),1),o.isExternalLink(l)?(e.openBlock(),e.createElementBlock("svg",Vn,[...n[4]||(n[4]=[e.createElementVNode("path",{d:"M7 17L17 7M9 7h8v8"},null,-1)])])):e.createCommentVNode("",!0)],8,En))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.unreadThreads,l=>(e.openBlock(),e.createElementBlock("button",{key:"un-"+l.id,type:"button",class:"wm-onb__btn wm-onb__btn--unread",onClick:f=>t.$emit("resume",l)},[n[5]||(n[5]=e.createElementVNode("span",{class:"wm-onb__btn-icon"},[e.createElementVNode("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})])],-1)),e.createElementVNode("span",Tn,e.toDisplayString(l.title),1),e.createElementVNode("span",{class:"wm-onb__btn-dot","aria-label":o.t("onboarding.unread")},null,8,xn)],8,Mn))),128)),r.openThreads.length?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-onb__btn",onClick:n[1]||(n[1]=l=>t.$emit("view-history"))},[e.createElementVNode("span",On,[(e.openBlock(),e.createElementBlock("svg",Ln,[e.createElementVNode("path",{d:o.iconPath("chat")},null,8,Dn)]))]),e.createElementVNode("span",In,e.toDisplayString(o.t("onboarding.allConversations")),1),e.createElementVNode("span",Rn,e.toDisplayString(r.openThreads.length),1),n[6]||(n[6]=e.createElementVNode("svg",{class:"wm-onb__btn-trail",width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M9 18l6-6-6-6"})],-1))])):e.createCommentVNode("",!0)])])}const Te=S(fn,[["render",Fn],["__scopeId","data-v-8b4ef2e1"]]),Pn={name:"WmHistory",components:{AIAvatar:H,HumanAvatar:ae},inject:{t:{default:()=>T()},wmLocale:{default:()=>()=>"fr"}},props:{threads:{type:Array,default:()=>[]}},emits:["resume"],data(){return{query:""}},computed:{filteredThreads(){const t=this.query.trim().toLowerCase();return t?this.threads.filter(n=>(n.title||"").toLowerCase().includes(t)||(n.preview||"").toLowerCase().includes(t)):this.threads}},methods:{renderPreview(t){return Ne(t)},avatarComponent(t){var n;return((n=t==null?void 0:t.author)==null?void 0:n.type)==="agent_human"?"HumanAvatar":"AIAvatar"},avatarProps(t){const n=t==null?void 0:t.author;return(n==null?void 0:n.type)==="agent_human"?{size:40,name:n.name||"",avatarUrl:n.avatar_url||null}:{size:40,name:(n==null?void 0:n.name)||"",imageUrl:(n==null?void 0:n.avatar_url)||null}},isDefaultAvatar(t){const n=t==null?void 0:t.author;return!(n!=null&&n.avatar_url||n!=null&&n.name)},avatarWrapperClass(t){return this.isDefaultAvatar(t)&&!(t!=null&&t.unread)?"wm-hist__avatar--muted":null},formatTs(t){if(!t)return"";const n=new Date(t);if(Number.isNaN(n.getTime()))return"";const r=z(this.wmLocale()),a=new Date;if(n.toDateString()===a.toDateString())return n.toLocaleTimeString(r,{hour:"2-digit",minute:"2-digit"});if(a.getTime()-n.getTime()<7*864e5){const i=n.toLocaleDateString(r,{weekday:"short"});return i.charAt(0).toUpperCase()+i.slice(1)}return n.toLocaleDateString(r,{day:"2-digit",month:"2-digit"})}}},Un={class:"wm-hist"},jn={class:"wm-hist__search"},zn=["placeholder","aria-label"],Hn={class:"wm-hist__list"},$n=["onClick"],qn={key:0,class:"wm-hist__defaultAvatar"},Kn=["aria-label"],Wn={class:"wm-hist__thread-body"},Gn={class:"wm-hist__thread-title"},Yn=["innerHTML"],Xn={class:"wm-hist__thread-meta"},Jn={key:0,class:"wm-hist__thread-time"},Qn={key:0,class:"wm-hist__empty"};function Zn(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",Un,[e.createElementVNode("div",jn,[n[1]||(n[1]=e.createElementVNode("span",{class:"wm-hist__searchIcon"},[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 21l-4.35-4.35M11 17a6 6 0 100-12 6 6 0 000 12z"})])],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":n[0]||(n[0]=i=>s.query=i),type:"text",placeholder:o.t("onboarding.search"),"aria-label":o.t("onboarding.search")},null,8,zn),[[e.vModelText,s.query]])]),e.createElementVNode("div",Hn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.filteredThreads,i=>(e.openBlock(),e.createElementBlock("button",{key:i.id,type:"button",class:e.normalizeClass(["wm-hist__thread",{"wm-hist__thread--unread":i.unread}]),onClick:l=>t.$emit("resume",i)},[e.createElementVNode("span",{class:e.normalizeClass(["wm-hist__thread-avatar",o.avatarWrapperClass(i)])},[o.isDefaultAvatar(i)?(e.openBlock(),e.createElementBlock("span",qn,[...n[2]||(n[2]=[e.createElementVNode("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"})],-1)])])):(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.avatarComponent(i)),e.mergeProps({key:1,ref_for:!0},o.avatarProps(i)),null,16)),i.unread?(e.openBlock(),e.createElementBlock("span",{key:2,class:"wm-hist__thread-dot","aria-label":o.t("onboarding.unread")},null,8,Kn)):e.createCommentVNode("",!0)],2),e.createElementVNode("span",Wn,[e.createElementVNode("span",Gn,e.toDisplayString(i.title),1),e.createElementVNode("span",{class:"wm-hist__thread-preview",innerHTML:o.renderPreview(i.preview)},null,8,Yn)]),e.createElementVNode("span",Xn,[o.formatTs(i._ts)?(e.openBlock(),e.createElementBlock("span",Jn,e.toDisplayString(o.formatTs(i._ts)),1)):e.createCommentVNode("",!0),n[3]||(n[3]=e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",class:"wm-hist__thread-chev","aria-hidden":"true"},[e.createElementVNode("path",{d:"M5 12h14M13 5l7 7-7 7"})],-1))])],10,$n))),128)),o.filteredThreads.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Qn,e.toDisplayString(s.query?o.t("onboarding.noResults",{query:s.query}):o.t("onboarding.noConversations")),1))])])}const er=S(Pn,[["render",Zn],["__scopeId","data-v-0d31869d"]]);function tr(t){return typeof t!="string"?"":t.replace(/`([^`]+)`/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(new RegExp("(?<!\\*)\\*([^*]+)\\*(?!\\*)","g"),"$1").replace(/__([^_]+)__/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\s+/g," ").trim()}const nr={name:"WmActionResult",props:{state:{type:String,default:"success"},label:{type:String,required:!0},detail:{type:String,default:""}},computed:{detailText(){return tr(this.detail)}}},rr={class:"wm-result__icon","aria-hidden":"true"},or={key:0,width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.8","stroke-linecap":"round","stroke-linejoin":"round"},sr={key:1,width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.6","stroke-linecap":"round","stroke-linejoin":"round"},ar={key:2,width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.4","stroke-linecap":"round","stroke-linejoin":"round"},ir={key:3,width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.2","stroke-linecap":"round","stroke-linejoin":"round"},lr={class:"wm-result__body"},cr={class:"wm-result__label"},dr={class:"wm-result__detail"};function ur(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-result",`wm-result--${r.state}`])},[e.createElementVNode("span",rr,[r.state==="success"?(e.openBlock(),e.createElementBlock("svg",or,[...n[0]||(n[0]=[e.createElementVNode("path",{d:"M20 6L9 17l-5-5"},null,-1)])])):r.state==="rejected"?(e.openBlock(),e.createElementBlock("svg",sr,[...n[1]||(n[1]=[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"},null,-1)])])):r.state==="awaiting"?(e.openBlock(),e.createElementBlock("svg",ar,[...n[2]||(n[2]=[e.createElementVNode("circle",{cx:"12",cy:"12",r:"10"},null,-1),e.createElementVNode("polyline",{points:"12 7 12 12 15 14"},null,-1)])])):(e.openBlock(),e.createElementBlock("svg",ir,[...n[3]||(n[3]=[e.createElementVNode("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"},null,-1),e.createElementVNode("line",{x1:"12",y1:"9",x2:"12",y2:"13"},null,-1),e.createElementVNode("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"},null,-1)])]))]),e.createElementVNode("span",lr,[e.createElementVNode("span",cr,e.toDisplayString(r.label),1),o.detailText?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[n[4]||(n[4]=e.createElementVNode("span",{class:"wm-result__sep","aria-hidden":"true"}," · ",-1)),e.createElementVNode("span",dr,e.toDisplayString(o.detailText),1)],64)):e.createCommentVNode("",!0)])],2)}const xe=S(nr,[["render",ur],["__scopeId","data-v-7284acd0"]]),mr={name:"WmArtifactFormResponse",inject:{t:{default:()=>T()}},props:{data:{type:Object,required:!0}},computed:{fields(){var t;return Array.isArray((t=this.data)==null?void 0:t.fields)?this.data.fields:[]}}},hr={class:"wm-art wm-art--formResponse"},fr={class:"wm-art__head"},pr={class:"wm-art__title"},gr={class:"wm-art__badge wm-art__badge--success"},_r={class:"wm-art__body"},yr={class:"wm-art__fieldLabel"};function vr(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",hr,[e.createElementVNode("div",fr,[e.createElementVNode("div",pr,e.toDisplayString(r.data.title||o.t("form.title")),1),e.createElementVNode("span",gr,[n[0]||(n[0]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("polyline",{points:"20 6 9 17 4 12"})],-1)),e.createTextVNode(" "+e.toDisplayString(o.t("form.sent")),1)])]),e.createElementVNode("div",_r,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.fields,(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",yr,e.toDisplayString(i.label),1),e.createElementVNode("div",{class:e.normalizeClass(["wm-art__fieldValue",{"wm-art__fieldValue--multi":i.multiline}])},e.toDisplayString(i.value),3)]))),128))])])}const Oe=S(mr,[["render",vr],["__scopeId","data-v-713aecf1"]]),kr={name:"WmArtifactInfoCard",props:{data:{type:Object,required:!0}},computed:{fields(){var t;return Array.isArray((t=this.data)==null?void 0:t.fields)?this.data.fields:[]},hasBody(){var t;return!!((t=this.data)!=null&&t.body)||this.fields.length>0}}},wr={class:"wm-art wm-art--infoCard"},br={key:0,class:"wm-art__image"},Er=["src","alt"],Cr={class:"wm-art__head"},Br={class:"wm-art__headMain"},Nr={class:"wm-art__title"},Sr={key:0,class:"wm-art__subtitle"},Ar={key:1,class:"wm-art__body"},Vr={key:0,class:"wm-art__text"},Mr={class:"wm-art__fieldLabel"};function Tr(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",wr,[r.data.image_url?(e.openBlock(),e.createElementBlock("figure",br,[e.createElementVNode("img",{src:r.data.image_url,alt:r.data.title||"",loading:"lazy"},null,8,Er)])):e.createCommentVNode("",!0),e.createElementVNode("div",Cr,[e.createElementVNode("div",Br,[e.createElementVNode("div",Nr,e.toDisplayString(r.data.title),1),r.data.subtitle?(e.openBlock(),e.createElementBlock("div",Sr,e.toDisplayString(r.data.subtitle),1)):e.createCommentVNode("",!0)]),r.data.badge&&r.data.badge.label?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["wm-art__badge",`wm-art__badge--${r.data.badge.tone||"neutral"}`])},e.toDisplayString(r.data.badge.label),3)):e.createCommentVNode("",!0)]),o.hasBody?(e.openBlock(),e.createElementBlock("div",Ar,[r.data.body?(e.openBlock(),e.createElementBlock("div",Vr,e.toDisplayString(r.data.body),1)):e.createCommentVNode("",!0),o.fields.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(o.fields,(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",Mr,e.toDisplayString(i.label),1),e.createElementVNode("div",{class:e.normalizeClass(["wm-art__fieldValue",{"wm-art__fieldValue--multi":i.multiline}])},e.toDisplayString(i.value),3)]))),128)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])}const Le=S(kr,[["render",Tr],["__scopeId","data-v-7eae0e4a"]]);function xr(t,n,r){if(!t)return"";const a=new Date(t);if(Number.isNaN(a.getTime()))return t;const s=a.toLocaleDateString(n,{day:"numeric",month:"long",year:"numeric"}),o=a.toLocaleTimeString(n,{hour:"2-digit",minute:"2-digit"});return`${s}${r}${o}`}const Or={name:"WmArtifactTicket",inject:{t:{default:()=>T()},wmLocale:{default:()=>()=>"fr"}},props:{data:{type:Object,required:!0}},computed:{fields(){var t;return Array.isArray((t=this.data)==null?void 0:t.fields)?this.data.fields:[]},formattedDate(){var t;return xr((t=this.data)==null?void 0:t.created_at,z(this.wmLocale()),this.t("ticket.dateAt"))}},methods:{isPriority(t){return/priorit|^prio$/i.test(String(t||"").trim())},isDate(t){return/date|échéanc|echeanc|deadline|due|créé|cree/i.test(String(t||"").trim())},priorityLevel(t){const n=String(t||"").toLowerCase();return/high|haute|élev|elev|critic|critiq|urgent/.test(n)?3:/low|basse|faible|minor/.test(n)?1:2}}},Lr={class:"wm-art wm-art--ticket"},Dr={class:"wm-art__head wm-tk__head"},Ir={class:"wm-art__title wm-tk__title"},Rr={class:"wm-tk__sub"},Fr={class:"wm-tk__ref"},Pr={key:0,class:"wm-tk__text"},Ur={key:0,class:"wm-art__body"},jr={class:"wm-art__fieldLabel"},zr=["data-level"],Hr={key:1,class:"wm-tk__date",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},$r={key:1,class:"wm-art__footer wm-tk__footer"};function qr(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",Lr,[e.createElementVNode("div",Dr,[e.createElementVNode("div",Ir,e.toDisplayString(r.data.title),1),e.createElementVNode("div",Rr,[e.createElementVNode("div",Fr,[n[0]||(n[0]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M20 12a2 2 0 0 1 2-2V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v4a2 2 0 0 1 0 4v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 1-2-2z"}),e.createElementVNode("path",{d:"M13 5v2M13 17v2M13 11v2"})],-1)),e.createElementVNode("span",null,e.toDisplayString(r.data.reference),1)]),e.createElementVNode("span",{class:e.normalizeClass(["wm-art__badge","wm-tk__badge",`wm-art__badge--${r.data.status.tone||"neutral"}`])},[n[1]||(n[1]=e.createElementVNode("span",{class:"wm-tk__dot","aria-hidden":"true"},null,-1)),e.createTextVNode(" "+e.toDisplayString(r.data.status.label),1)],2)]),r.data.body?(e.openBlock(),e.createElementBlock("div",Pr,e.toDisplayString(r.data.body),1)):e.createCommentVNode("",!0)]),o.fields.length?(e.openBlock(),e.createElementBlock("div",Ur,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.fields,(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",jr,e.toDisplayString(i.label),1),e.createElementVNode("div",{class:e.normalizeClass(["wm-art__fieldValue",{"wm-art__fieldValue--multi":i.multiline}])},[o.isPriority(i.label)?(e.openBlock(),e.createElementBlock("svg",{key:0,class:"wm-tk__prio","data-level":o.priorityLevel(i.value),width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true"},[...n[2]||(n[2]=[e.createElementVNode("rect",{x:"1",y:"8",width:"2",height:"3",rx:"0.5"},null,-1),e.createElementVNode("rect",{x:"5",y:"5",width:"2",height:"6",rx:"0.5"},null,-1),e.createElementVNode("rect",{x:"9",y:"2",width:"2",height:"9",rx:"0.5"},null,-1)])],8,zr)):o.isDate(i.label)?(e.openBlock(),e.createElementBlock("svg",Hr,[...n[3]||(n[3]=[e.createElementVNode("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"},null,-1),e.createElementVNode("path",{d:"M16 2v4M8 2v4M3 10h18"},null,-1)])])):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(i.value),1)],2)]))),128))])):e.createCommentVNode("",!0),r.data.created_at?(e.openBlock(),e.createElementBlock("div",$r,[n[4]||(n[4]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),e.createElementVNode("path",{d:"M16 2v4M8 2v4M3 10h18"})],-1)),e.createElementVNode("span",null,e.toDisplayString(o.formattedDate),1)])):e.createCommentVNode("",!0)])}const De=S(Or,[["render",qr],["__scopeId","data-v-5f30c914"]]),Kr={form_response:Oe,info_card:Le,ticket:De},Wr={name:"WmArtifactRenderer",props:{artifact:{type:Object,required:!0}},computed:{component(){var n;const t=(n=this.artifact)==null?void 0:n.kind;return t&&Kr[t]||null}}};function Gr(t,n,r,a,s,o){return o.component?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.component),{key:0,data:r.artifact.data},null,8,["data"])):e.createCommentVNode("",!0)}const Ie=S(Wr,[["render",Gr]]),Yr={name:"WmAttachmentPreview",inject:{signAttachmentFn:{default:null},t:{default:()=>T()}},props:{attachment:{type:Object,required:!0}},data(){return{url:null,loading:!1}},computed:{kind(){var r,a;const t=(r=this.attachment)==null?void 0:r.type;if(t)return t;const n=(((a=this.attachment)==null?void 0:a.mime_type)||"").toLowerCase();return n.startsWith("image/")?"image":n.startsWith("audio/")?"audio":n.startsWith("video/")?"video":"file"},displayName(){var t,n,r;return((n=(t=this.attachment)==null?void 0:t.metadata)==null?void 0:n.name)||((r=this.attachment)==null?void 0:r.name)||this.guessNameFromPath()||this.t("attachment.fallbackName")},safeHref(){const t=String(this.url||"").trim();return/^(https?:\/\/|blob:|data:image\/)/i.test(t)?t:"#"},sizeLabel(){var n;const t=(n=this.attachment)==null?void 0:n.size_bytes;return t?t<1024?this.t("attachment.bytes",{size:t}):t<1024*1024?this.t("attachment.kilobytes",{size:(t/1024).toFixed(0)}):this.t("attachment.megabytes",{size:(t/(1024*1024)).toFixed(1)}):""}},watch:{"attachment.path":{handler(){this.refresh()},immediate:!0}},methods:{guessNameFromPath(){var r;return((((r=this.attachment)==null?void 0:r.path)||"").split("/").pop()||"").replace(/^[0-9a-f-]{8,}-/,"")},async refresh(){var t;if(!(!((t=this.attachment)!=null&&t.path)||!this.signAttachmentFn)){this.loading=!0;try{this.url=await this.signAttachmentFn(this.attachment.path)}finally{this.loading=!1}}},onFileClick(t){this.safeHref==="#"&&t.preventDefault()}}},Xr=["href"],Jr=["src","alt"],Qr=["src"],Zr=["src"],eo=["href","download"],to={class:"wm-att__main"},no={class:"wm-att__name"},ro={key:0,class:"wm-att__meta"},oo={key:0,class:"wm-att__spin","aria-hidden":"true"};function so(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-att",["wm-att--"+(o.kind||"file")]])},[o.kind==="image"&&s.url?(e.openBlock(),e.createElementBlock("a",{key:0,href:o.safeHref,target:"_blank",rel:"noopener",class:"wm-att__imgWrap"},[e.createElementVNode("img",{src:s.url,alt:o.displayName,loading:"lazy"},null,8,Jr)],8,Xr)):o.kind==="audio"&&s.url?(e.openBlock(),e.createElementBlock("audio",{key:1,src:s.url,controls:"",preload:"metadata"},null,8,Qr)):o.kind==="video"&&s.url?(e.openBlock(),e.createElementBlock("video",{key:2,src:s.url,controls:"",preload:"metadata"},null,8,Zr)):(e.openBlock(),e.createElementBlock("a",{key:3,class:"wm-att__file",href:o.safeHref,download:o.displayName,target:"_blank",rel:"noopener",onClick:n[0]||(n[0]=(...i)=>o.onFileClick&&o.onFileClick(...i))},[n[1]||(n[1]=e.createElementVNode("span",{class:"wm-att__icon"},[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),e.createElementVNode("path",{d:"M14 2v6h6"})])],-1)),e.createElementVNode("span",to,[e.createElementVNode("span",no,e.toDisplayString(o.displayName),1),o.sizeLabel?(e.openBlock(),e.createElementBlock("span",ro,e.toDisplayString(o.sizeLabel),1)):e.createCommentVNode("",!0)]),s.loading?(e.openBlock(),e.createElementBlock("span",oo)):e.createCommentVNode("",!0)],8,eo))],2)}const Re=S(Yr,[["render",so],["__scopeId","data-v-0c877a62"]]),ao={name:"WmBubble",props:{role:{type:String,default:"ai"},text:{type:String,default:""}},computed:{rendered(){return Se(this.text)}}},io=["innerHTML"];function lo(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-bubble","wm-bubble--"+r.role])},[e.renderSlot(t.$slots,"default",{},()=>[e.createElementVNode("span",{innerHTML:o.rendered},null,8,io)],!0)],2)}const Fe=S(ao,[["render",lo],["__scopeId","data-v-7ab13147"]]),co={name:"WmTyping"},uo={class:"wm-typing"};function mo(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",uo,[...n[0]||(n[0]=[e.createElementVNode("span",{style:{"animation-delay":"0s"}},null,-1),e.createElementVNode("span",{style:{"animation-delay":"0.2s"}},null,-1),e.createElementVNode("span",{style:{"animation-delay":"0.4s"}},null,-1)])])}const Pe=S(co,[["render",mo],["__scopeId","data-v-df2447fd"]]);function j(t){return t?t.client_msg_id||t.id:""}const ho={transferred_to_human:"system.transferredToHuman",assigned:"system.assigned",unassigned:"system.unassigned",resolved:"system.resolved",reopened:"system.reopened",idle:"system.idle"},fo=80,po=200,go={name:"WmMessageList",components:{AIAvatar:H,HumanAvatar:ae,Bubble:Fe,Typing:Pe,ActionResult:xe,AttachmentPreview:Re,ArtifactRenderer:Ie},inject:{t:{default:()=>T()},wmLocale:{default:()=>()=>"fr"}},props:{messages:{type:Array,default:()=>[]},streamingActive:{type:Boolean,default:!1},dateLabel:{type:String,default:""},conversationId:{type:[String,Number],default:null},loadingMore:{type:Boolean,default:!1},hasMore:{type:Boolean,default:!1},unreadAnchorId:{type:Number,default:null},unreadBoundaryTs:{type:String,default:""},aiAgentName:{type:String,default:""},aiAgentAvatarUrl:{type:String,default:null}},emits:["load-more"],data(){return{silentFades:!1,widthByKey:Object.freeze({}),showScrollDown:!1,pressedItemKey:null}},computed:{historyExhausted(){return!this.hasMore&&!this.loadingMore&&this.messages.length>=20},groups(){var r,a,s,o;const t=[];for(const i of this.messages){const l=this.roleOf(i);if(l==="system"){if(((r=i==null?void 0:i.payload)==null?void 0:r.event)==="action_admin_pending"){const _=t[t.length-1];_&&_.role==="ai"?_.messages.push(i):t.push({key:`g-${j(i)}`,role:"ai",agentName:"",agentAvatarUrl:null,messages:[i],items:[]});continue}t.push({key:`sys-${j(i)}`,role:l,messages:[i],items:[],systemLabel:this.systemLabel(i)});continue}const f=t[t.length-1];f&&f.role===l&&(l==="ai"||f.agentName===(((a=i==null?void 0:i.author)==null?void 0:a.name)||""))?f.messages.push(i):t.push({key:`g-${j(i)}`,role:l,agentName:((s=i==null?void 0:i.author)==null?void 0:s.name)||"",agentAvatarUrl:((o=i==null?void 0:i.author)==null?void 0:o.avatar_url)||null,messages:[i],items:[]})}for(const i of t){if(i.role==="system")continue;const l=[];for(const f of i.messages)for(const y of this.itemsOf(f))l.push(y);i.items=l}const n=[];for(const i of t){if(i.role!=="system"&&!i.items.length)continue;const l=n[n.length-1];if(l&&l.role!=="system"&&l.role===i.role&&(i.role==="ai"||l.agentName===i.agentName)){l.messages.push(...i.messages),l.items.push(...i.items);continue}n.push(i)}for(const i of n)i.role!=="system"&&(i.key=this.stableGroupKey(i.messages));return n},unreadGroupKey(){if(this.unreadAnchorId==null)return null;const t=this.unreadAnchorId,n=this.unreadBoundaryTs;for(const r of this.groups){if(r.role==="user"||r.role==="system"||!r.items.length)continue;const a=r.messages[0];if(!a)continue;const s=R(a.id);if(s!=null&&!(s<=t)&&!(n&&a.created_at&&a.created_at>n))return r.key}return null}},watch:{messages:{handler:"snapshotAndRestore",deep:!0},conversationId(t,n){t!==n&&(this._groupIdByMsgKey=null,this.silentFades=!1)},loadingMore(t){t||(this._pendingLoadMore=!1),t&&(this.silentFades=!0),this.snapshotAndRestore()},streamingActive:"snapshotAndRestore"},mounted(){this._lastSeenConvId=this.conversationId,this.scrollToBottom(),this._measureFrame=null,this._ro=new ResizeObserver(()=>this.scheduleMeasure()),this.$refs.scrollEl&&this._ro.observe(this.$refs.scrollEl),this.$nextTick(()=>this.measureRows())},beforeUnmount(){var t;(t=this._ro)==null||t.disconnect(),this._measureFrame&&cancelAnimationFrame(this._measureFrame),this._pressTimer&&clearTimeout(this._pressTimer)},updated(){this.scheduleMeasure()},methods:{messageKey:j,stableGroupKey(t){this._groupIdByMsgKey||(this._groupIdByMsgKey=new Map,this._groupIdCounter=0);const n=this._groupIdByMsgKey;let r=null;for(const a of t){const s=j(a);if(s&&n.has(s)){r=n.get(s);break}}r==null&&(r=++this._groupIdCounter);for(const a of t){const s=j(a);s&&n.set(s,r)}return`g-${r}`},isAtBottom(t){return t.scrollHeight-t.scrollTop-t.clientHeight<=fo},onScroll(){const t=this.$refs.scrollEl;t&&(this.showScrollDown=!this.isAtBottom(t),!(this.loadingMore||!this.hasMore)&&(this._pendingLoadMore||t.scrollTop<=po&&(this._pendingLoadMore=!0,this.$emit("load-more"))))},snapshotAndRestore(){const t=this.$refs.scrollEl;if(!t||this._scrollSnap)return;const n=this._lastSeenConvId!==this.conversationId;this._lastSeenConvId=this.conversationId;const r=this.isAtBottom(t);let a=null;if(!n&&!r){const o=this.pickAnchor(t);if(o!=null&&o.rowKey){const i=this.findRowByKey(t,o.rowKey);if(i){const l=t.getBoundingClientRect().top;a={rowKey:o.rowKey,relY:i.getBoundingClientRect().top-l}}}}const s={forceBottom:n,wasPinned:r,anchor:a};this._scrollSnap=s,this.$nextTick(()=>{if(this._scrollSnap=null,s.forceBottom||s.wasPinned){t.scrollTop=t.scrollHeight;return}if(!s.anchor)return;const o=()=>{const i=s.anchor,l=this.findRowByKey(t,i.rowKey);if(!l)return;const y=l.getBoundingClientRect().top-t.getBoundingClientRect().top-i.relY;Math.abs(y)>.5&&(t.scrollTop+=y)};o(),requestAnimationFrame(()=>{o(),requestAnimationFrame(o)})})},pickAnchor(t){const n=t.getBoundingClientRect().top,r=t.querySelectorAll(".wm-list__row[data-row-key]");let a=null;for(const s of r)if(a||(a=s),s.getBoundingClientRect().bottom>=n)return{rowKey:s.dataset.rowKey};return a?{rowKey:a.dataset.rowKey}:null},findRowByKey(t,n){if(!n)return null;const r=typeof CSS<"u"&&CSS.escape?CSS.escape(n):n.replace(/["\\]/g,"\\$&");return t.querySelector(`.wm-list__row[data-row-key="${r}"]`)},roleOf(t){var r,a;if((t==null?void 0:t.type)==="system"||((r=t==null?void 0:t.payload)==null?void 0:r.type)==="system")return"system";const n=(a=t==null?void 0:t.author)==null?void 0:a.type;return n==="user"?"user":n==="agent_human"?"human":"ai"},roleLabel(t){if(t.role==="human")return t.agentName||this.t("common.agent");const n=this.t("common.aiAssistant");return this.aiAgentName?`${this.aiAgentName} • ${n}`:n},itemsOf(t){var n;if(!t)return[];if(t.type==="system"&&((n=t==null?void 0:t.payload)==null?void 0:n.event)==="action_admin_pending")return[{message:t,partKey:"main",renderAs:"admin-pending",kind:{top:"bubble",bottom:"bubble"}}];if(t.type==="action"&&t.payload&&t.payload.state!=="pending"){const r=[{message:t,partKey:"main",renderAs:"action",kind:{top:"bubble",bottom:"bubble"}}];return this.actionArtifact(t)&&r.push({message:t,partKey:"artifact",renderAs:"artifact-of-action",kind:{top:"card",bottom:"card"}}),r}return this.artifactOf(t)?[{message:t,partKey:"main",renderAs:"artifact",kind:{top:"card",bottom:"card"}}]:t.text_md||this.attachmentsOf(t).length?[{message:t,partKey:"main",renderAs:"bubble",kind:{top:"bubble",bottom:"bubble"}}]:[]},cornersFor(t,n){var P,$,q;const r=t.items,a=(P=r[n])==null?void 0:P.kind,s=($=r[n-1])==null?void 0:$.kind,o=(q=r[n+1])==null?void 0:q.kind,i=t.role==="user",l=14,f=4,y=s==null?void 0:s.bottom,_=o==null?void 0:o.top,C=this.widthByKey[this.rowKeyOf(t,n)],N=this.widthByKey[this.rowKeyOf(t,n-1)],k=this.widthByKey[this.rowKeyOf(t,n+1)],O=.5,b=(I,K,F)=>I!=null&&C!=null?I+O>=C:K===F||K==="card"&&F==="bubble";let V=l,M=l,A=l,D=l;return i?(y&&(M=f),(_||!o)&&(A=f),y&&b(N,y,a==null?void 0:a.top)&&(V=f),_&&b(k,_,a==null?void 0:a.bottom)&&(D=f)):(y&&(V=f),(_||!o)&&(D=f),y&&b(N,y,a==null?void 0:a.top)&&(M=f),_&&b(k,_,a==null?void 0:a.bottom)&&(A=f)),{tl:V,tr:M,br:A,bl:D}},cornersStyle(t,n){if(t.items.length<2)return null;const r=this.cornersFor(t,n);return{"--wm-r-tl":`${r.tl}px`,"--wm-r-tr":`${r.tr}px`,"--wm-r-br":`${r.br}px`,"--wm-r-bl":`${r.bl}px`}},rowKeyOf(t,n){var a;const r=(a=t==null?void 0:t.items)==null?void 0:a[n];return r?`${j(r.message)}-${r.partKey}`:""},scheduleMeasure(){this._measureFrame||(this._measureFrame=requestAnimationFrame(()=>{this._measureFrame=null,this.measureRows()}))},measureRows(){const t=this.$refs.scrollEl;if(!t)return;const n={};for(const o of t.querySelectorAll(".wm-list__row[data-row-key]")){const i=o.dataset.rowKey;if(!i)continue;const l=o.querySelector(".wm-bubble, .wm-result, .wm-art, .wm-list__body");if(!l)continue;const f=l.getBoundingClientRect().width;f>0&&(n[i]=f)}const r=this.widthByKey,a=Object.keys(r),s=Object.keys(n);if(a.length===s.length){let o=!0;for(const i of s)if(Math.abs((r[i]??0)-n[i])>.5){o=!1;break}if(o)return}this.widthByKey=Object.freeze(n)},onPressStart(t){this.onPressEnd(),this._pressTimer=setTimeout(()=>{this._pressTimer=null,this.pressedItemKey=t},400)},onPressEnd(){this._pressTimer&&(clearTimeout(this._pressTimer),this._pressTimer=null),this.pressedItemKey!==null&&(this.pressedItemKey=null)},timeOf(t){if(!(t!=null&&t.created_at))return"";try{return ne(new Date(t.created_at),z(this.wmLocale()))}catch{return""}},lastTimeOf(t){const n=t.items[t.items.length-1],r=(n==null?void 0:n.message)||t.messages[t.messages.length-1];if(!(r!=null&&r.created_at))return"";try{return ne(new Date(r.created_at),z(this.wmLocale()))}catch{return""}},hasTrailingOverlay(t){if(!t.messages.length)return!1;const n=t.messages[t.messages.length-1],r=t.items[t.items.length-1];return!!n&&(r==null?void 0:r.message)!==n},attachmentsOf(t){var r;const n=(r=t==null?void 0:t.payload)==null?void 0:r.attachments;return Array.isArray(n)?n:[]},artifactOf(t){var r;const n=(r=t==null?void 0:t.metadata)==null?void 0:r.artifact;return!n||typeof n!="object"||typeof n.kind!="string"?null:n},actionLabel(t){var n;return((n=t==null?void 0:t.payload)==null?void 0:n.name)||(t==null?void 0:t.text_md)||this.t("common.action")},actionDetail(t){var r,a,s,o,i,l;const n=t==null?void 0:t.payload;return n?n.state==="success"?((r=n.success)==null?void 0:r.summary)||((s=(a=n.success)==null?void 0:a.metadata)==null?void 0:s.description)||"":n.state==="rejected"?((o=n.rejected)==null?void 0:o.reason)||this.t("action.rejectedByUser"):n.state==="failure"&&(((i=n.failure)==null?void 0:i.summary)||((l=n.failure)==null?void 0:l.error))||"":""},actionArtifact(t){var r,a;const n=(a=(r=t==null?void 0:t.payload)==null?void 0:r.success)==null?void 0:a.artifact;return!n||typeof n!="object"||typeof n.kind!="string"?null:n},systemLabel(t){var s,o,i;const n=(s=t==null?void 0:t.payload)==null?void 0:s.event,r=ho[n],a=((o=t==null?void 0:t.metadata)==null?void 0:o.agent_name)||((i=t==null?void 0:t.author)==null?void 0:i.name)||this.t("messageList.anAgent");return r?this.t(r,{name:a}):(t==null?void 0:t.text_md)||this.t("messageList.conversationUpdate")},scrollToBottom(){const t=this.$refs.scrollEl;t&&(t.scrollTop=t.scrollHeight),this.showScrollDown=!1},scrollToBottomSmooth(){const t=this.$refs.scrollEl;t&&(typeof t.scrollTo=="function"?t.scrollTo({top:t.scrollHeight,behavior:"smooth"}):t.scrollTop=t.scrollHeight,this.showScrollDown=!1)}}},_o={class:"wm-list__wrap"},yo={key:0,class:"wm-list__loadMore",role:"status","aria-live":"polite"},vo={class:"wm-list__loadMore-lbl"},ko={key:1,class:"wm-list__historyEnd"},wo={key:2,class:"wm-list__sep"},bo={class:"wm-list__sep-label"},Eo={key:0,class:"wm-list__sep wm-list__sep--unread"},Co={class:"wm-list__sep-label wm-list__sep-label--unread"},Bo={key:0,class:"wm-list__sysep"},No={class:"wm-list__sysep-label"},So=["data-row-key","onPointerdown"],Ao={key:0,class:"wm-list__avatarSlot"},Vo={key:5,class:"wm-list__body"},Mo={key:0},To={key:1,"aria-hidden":"true"},xo={key:2},Oo={key:0},Lo={key:1,"aria-hidden":"true"},Do={key:2},Io={key:3,class:"wm-list__row wm-list__row--ai fade-up"},Ro={class:"wm-list__avatarSlot"},Fo=["aria-label","title"];function Po(t,n,r,a,s,o){const i=e.resolveComponent("AIAvatar"),l=e.resolveComponent("HumanAvatar"),f=e.resolveComponent("ActionResult"),y=e.resolveComponent("ArtifactRenderer"),_=e.resolveComponent("Bubble"),C=e.resolveComponent("AttachmentPreview"),N=e.resolveComponent("Typing");return e.openBlock(),e.createElementBlock("div",_o,[e.createElementVNode("div",{ref:"scrollEl",class:e.normalizeClass(["wm-list",{"wm-list--silent":s.silentFades}]),onScrollPassive:n[4]||(n[4]=(...k)=>o.onScroll&&o.onScroll(...k))},[r.loadingMore?(e.openBlock(),e.createElementBlock("div",yo,[n[6]||(n[6]=e.createElementVNode("span",{class:"wm-list__loadMore-spinner","aria-hidden":"true"},null,-1)),e.createElementVNode("span",vo,e.toDisplayString(o.t("messageList.loadingHistory")),1)])):o.historyExhausted?(e.openBlock(),e.createElementBlock("div",ko,e.toDisplayString(o.t("messageList.conversationStart")),1)):e.createCommentVNode("",!0),r.dateLabel?(e.openBlock(),e.createElementBlock("div",wo,[n[7]||(n[7]=e.createElementVNode("div",{class:"wm-list__line"},null,-1)),e.createElementVNode("span",bo,e.toDisplayString(r.dateLabel),1),n[8]||(n[8]=e.createElementVNode("div",{class:"wm-list__line"},null,-1))])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.groups,(k,O)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:k.key},[k.key===o.unreadGroupKey?(e.openBlock(),e.createElementBlock("div",Eo,[n[9]||(n[9]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--unread"},null,-1)),e.createElementVNode("span",Co,e.toDisplayString(o.t("messageList.unread")),1),n[10]||(n[10]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--unread"},null,-1))])):e.createCommentVNode("",!0),k.role==="system"||k.items.length?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["wm-list__group","wm-list__group--"+k.role])},[k.role==="system"?(e.openBlock(),e.createElementBlock("div",Bo,[n[11]||(n[11]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--strong"},null,-1)),e.createElementVNode("span",No,e.toDisplayString(k.systemLabel),1),n[12]||(n[12]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--strong"},null,-1))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.items,(b,V)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${o.messageKey(b.message)}-${b.partKey}`},[e.createElementVNode("div",{"data-row-key":`${o.messageKey(b.message)}-${b.partKey}`,class:e.normalizeClass(["wm-list__row fade-up",["wm-list__row--"+k.role,{"is-pending":b.message._pending,"is-failed":b.message._failed}]]),style:e.normalizeStyle(o.cornersStyle(k,V)),onPointerdown:M=>o.onPressStart(`${o.messageKey(b.message)}-${b.partKey}`),onPointerup:n[0]||(n[0]=M=>o.onPressEnd()),onPointercancel:n[1]||(n[1]=M=>o.onPressEnd()),onPointerleave:n[2]||(n[2]=M=>o.onPressEnd()),onContextmenu:n[3]||(n[3]=e.withModifiers(()=>{},["prevent"]))},[k.role!=="user"?(e.openBlock(),e.createElementBlock("div",Ao,[V===k.items.length-1?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[k.role==="ai"?(e.openBlock(),e.createBlock(i,{key:0,size:26,tail:!0,name:r.aiAgentName,"image-url":r.aiAgentAvatarUrl},null,8,["name","image-url"])):(e.openBlock(),e.createBlock(l,{key:1,name:k.agentName,"avatar-url":k.agentAvatarUrl,size:26,tail:!0},null,8,["name","avatar-url"]))],64)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),b.renderAs==="action"?(e.openBlock(),e.createBlock(f,{key:1,state:b.message.payload.state,label:o.actionLabel(b.message),detail:o.actionDetail(b.message)},null,8,["state","label","detail"])):b.renderAs==="admin-pending"?(e.openBlock(),e.createBlock(f,{key:2,state:"awaiting",label:o.t("messageList.approvalRequestSent"),detail:b.message.text_md||""},null,8,["label","detail"])):b.renderAs==="artifact-of-action"?(e.openBlock(),e.createBlock(y,{key:3,artifact:o.actionArtifact(b.message)},null,8,["artifact"])):b.renderAs==="artifact"?(e.openBlock(),e.createBlock(y,{key:4,artifact:o.artifactOf(b.message)},null,8,["artifact"])):(e.openBlock(),e.createElementBlock("div",Vo,[b.message.text_md?(e.openBlock(),e.createBlock(_,{key:0,role:k.role,text:b.message.text_md},null,8,["role","text"])):e.createCommentVNode("",!0),o.attachmentsOf(b.message).length?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["wm-list__atts",{"wm-list__atts--align-end":k.role==="user"}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.attachmentsOf(b.message),(M,A)=>(e.openBlock(),e.createBlock(C,{key:`${o.messageKey(b.message)}-att-${A}`,attachment:M},null,8,["attachment"]))),128))],2)):e.createCommentVNode("",!0)]))],46,So),V<k.items.length-1&&s.pressedItemKey===`${o.messageKey(b.message)}-${b.partKey}`&&(k.role!=="user"||o.timeOf(b.message))?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["wm-list__meta wm-list__meta--press",{"wm-list__meta--right":k.role==="user"}])},[k.role!=="user"?(e.openBlock(),e.createElementBlock("span",Mo,e.toDisplayString(o.roleLabel(k)),1)):e.createCommentVNode("",!0),k.role!=="user"&&o.timeOf(b.message)?(e.openBlock(),e.createElementBlock("span",To,"•")):e.createCommentVNode("",!0),o.timeOf(b.message)?(e.openBlock(),e.createElementBlock("span",xo,e.toDisplayString(o.timeOf(b.message)),1)):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0)],64))),128)),(k.role!=="user"||o.lastTimeOf(k))&&!o.hasTrailingOverlay(k)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["wm-list__meta",{"wm-list__meta--right":k.role==="user"}])},[k.role!=="user"?(e.openBlock(),e.createElementBlock("span",Oo,e.toDisplayString(o.roleLabel(k)),1)):e.createCommentVNode("",!0),k.role!=="user"&&o.lastTimeOf(k)?(e.openBlock(),e.createElementBlock("span",Lo,"•")):e.createCommentVNode("",!0),o.lastTimeOf(k)?(e.openBlock(),e.createElementBlock("span",Do,e.toDisplayString(o.lastTimeOf(k)),1)):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0)],64))],2)):e.createCommentVNode("",!0)],64))),128)),r.streamingActive?(e.openBlock(),e.createElementBlock("div",Io,[e.createElementVNode("div",Ro,[e.createVNode(i,{size:26,tail:!0,name:r.aiAgentName,"image-url":r.aiAgentAvatarUrl},null,8,["name","image-url"])]),e.createVNode(N)])):e.createCommentVNode("",!0)],34),e.createVNode(e.Transition,{name:"wm-scrollDown"},{default:e.withCtx(()=>[s.showScrollDown?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-list__scrollDown","aria-label":o.t("messageList.scrollToBottom"),title:o.t("messageList.scrollToBottom"),onClick:n[5]||(n[5]=(...k)=>o.scrollToBottomSmooth&&o.scrollToBottomSmooth(...k))},[...n[13]||(n[13]=[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M6 9l6 6 6-6"})],-1)])],8,Fo)):e.createCommentVNode("",!0)]),_:1})])}const Ue=S(go,[["render",Po],["__scopeId","data-v-cf20685c"]]),J=typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function",ie=typeof window<"u"&&typeof window.MediaRecorder<"u";function je(){return ie&&["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"].find(n=>{var r,a;return(a=(r=window.MediaRecorder).isTypeSupported)==null?void 0:a.call(r,n)})||""}function ze({audio:t}){return{video:!0,audio:!!t,selfBrowserSurface:"include",surfaceSwitching:"include",systemAudio:t?"include":"exclude"}}function Uo(t){return t?t.startsWith("image/")?"image":t.startsWith("video/")?"video":"file":"file"}async function He(){if(!J)return null;let t;try{t=await navigator.mediaDevices.getDisplayMedia(ze({audio:!1}))}catch(n){return(n==null?void 0:n.name)!=="NotAllowedError"&&console.error("[media] screenshot picker",n),null}try{return await jo(t)}catch(n){return console.error("[media] screenshot capture",n),null}finally{t.getTracks().forEach(n=>{n.stop()})}}async function jo(t){const n=document.createElement("video");n.muted=!0,n.playsInline=!0,n.srcObject=t,await n.play(),await new Promise(l=>requestAnimationFrame(l));const r=n.videoWidth||1280,a=n.videoHeight||720,s=document.createElement("canvas");s.width=r,s.height=a,s.getContext("2d").drawImage(n,0,0,r,a);const o=await new Promise((l,f)=>{s.toBlob(y=>y?l(y):f(new Error("toBlob failed")),"image/png")}),i=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19);return new File([o],`capture-${i}.png`,{type:"image/png"})}async function $e(t={}){var y;if(!J||!ie)return null;let n;try{n=await navigator.mediaDevices.getDisplayMedia(ze({audio:!0}))}catch(_){return(_==null?void 0:_.name)!=="NotAllowedError"&&console.error("[media] record picker",_),null}const r=je();let a;try{a=r?new window.MediaRecorder(n,{mimeType:r}):new window.MediaRecorder(n)}catch(_){return console.error("[media] recorder init",_),n.getTracks().forEach(C=>{C.stop()}),null}const s=[];let o=null,i=!1;a.addEventListener("dataavailable",_=>{_.data&&_.data.size>0&&s.push(_.data)}),a.addEventListener("stop",()=>{var _,C;if(o&&clearInterval(o),n.getTracks().forEach(N=>{N.stop()}),s.length){const N=a.mimeType||r||"video/webm",k=new Blob(s,{type:N}),O=/mp4/.test(N)?"mp4":"webm",b=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),V=new File([k],`ecran-${b}.${O}`,{type:N});(_=t.onfinalize)==null||_.call(t,V)}else(C=t.oncancel)==null||C.call(t)}),n.getVideoTracks().forEach(_=>{_.addEventListener("ended",()=>l(),{once:!0})});function l(){if(!i&&(i=!0,a.state!=="inactive"))try{a.stop()}catch(_){console.error("[media] recorder stop",_)}}try{a.start(1e3)}catch(_){return console.error("[media] recorder start",_),n.getTracks().forEach(C=>{C.stop()}),null}(y=t.onstart)==null||y.call(t);const f=Date.now();return o=setInterval(()=>{var _;(_=t.ontick)==null||_.call(t,Date.now()-f)},500),{stop:l,get state(){return a.state}}}const zo=[{action:"file",labelKey:"composer.attachFile",path:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"},{action:"screenshot",labelKey:"composer.screenshot",path:"M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2z M12 17a4 4 0 100-8 4 4 0 000 8z"},{action:"record",labelKey:"composer.recordScreen",path:"M23 7l-7 5 7 5V7z M1 5a2 2 0 012-2h12a2 2 0 012 2v14a2 2 0 01-2 2H3a2 2 0 01-2-2V5z"}],Ho={name:"WmComposer",inject:{t:{default:()=>T()}},props:{modelValue:{type:String,default:""},placeholder:{type:String,default:"Écrivez votre message…"},disabled:{type:Boolean,default:!1},attachLabel:{type:String,default:"Joindre"},displayMode:{type:String,default:"floating"}},emits:["update:modelValue","send","attach"],data(){return{local:this.modelValue,attachOpen:!1,recording:!1,recordingElapsed:0,recorder:null,kbOffset:0}},computed:{canSend(){return!this.disabled&&!!this.local.trim()},attachItems(){return zo.map(t=>({...t,label:this.t(t.labelKey),disabled:t.action==="screenshot"&&!J||t.action==="record"&&(!J||!ie)}))},recordingElapsedLabel(){const t=Math.floor(this.recordingElapsed/1e3),n=Math.floor(t/60),r=t%60;return`${n}:${r.toString().padStart(2,"0")}`}},watch:{modelValue(t){t!==this.local&&(this.local=t,this.$nextTick(()=>this.autosize()))},local(t){this.$emit("update:modelValue",t)}},mounted(){this.autosize(),this.displayMode==="sheet"&&this.setupKeyboardTracking()},beforeUnmount(){if(this.recorder)try{this.recorder.stop()}catch{}this.teardownKeyboardTracking()},methods:{focus(){const t=this.$refs.inputEl;if(!(!t||this.disabled))try{t.focus({preventScroll:!0})}catch{t.focus()}},onSubmit(){if(!this.canSend)return;const t=this.local.trim();this.local="",this.$emit("send",t),this.$nextTick(()=>this.autosize())},onKeydown(t){t.key==="Enter"&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey&&!t.isComposing&&(t.preventDefault(),this.onSubmit())},autosize(){const t=this.$refs.inputEl;t&&(t.clientWidth<80||(t.style.height="auto",t.style.height=`${t.scrollHeight}px`))},onFile(t){const n=Array.from(t.target.files||[]);for(const r of n)this.$emit("attach",r);t.target.value=""},onAttachAction(t){this.attachOpen=!1,t==="file"?this.pickFile():t==="screenshot"?this.captureScreenshot():t==="record"&&this.startRecording()},pickFile(){var t;(t=this.$refs.fileEl)==null||t.click()},async captureScreenshot(){if(this.disabled)return;const t=await He();t&&this.$emit("attach",t)},async startRecording(){if(this.recording||this.disabled)return;this.recordingElapsed=0;const t=await $e({onstart:()=>{this.recording=!0},ontick:n=>{this.recordingElapsed=n},onfinalize:n=>{this.$emit("attach",n),this.recording=!1,this.recordingElapsed=0,this.recorder=null},oncancel:()=>{this.recording=!1,this.recordingElapsed=0,this.recorder=null}});t&&(this.recorder=t)},stopRecording(){if(this.recorder)try{this.recorder.stop()}catch(t){console.error("[composer] stop recording",t)}},setupKeyboardTracking(){const t=window.visualViewport;t&&(this._vvHandler=()=>{const n=Math.max(0,window.innerHeight-t.height-t.offsetTop);this.kbOffset=n},t.addEventListener("resize",this._vvHandler),t.addEventListener("scroll",this._vvHandler))},teardownKeyboardTracking(){const t=window.visualViewport;!t||!this._vvHandler||(t.removeEventListener("resize",this._vvHandler),t.removeEventListener("scroll",this._vvHandler),this._vvHandler=null)}}},$o={key:0,class:"wm-rec"},qo={class:"wm-rec__lbl"},Ko={key:1,class:"wm-compose__menu",role:"menu"},Wo=["disabled","onClick"],Go={class:"wm-compose__menuIcon"},Yo={viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true"},Xo=["d"],Jo=["placeholder","disabled"],Qo={class:"wm-compose__actions"},Zo=["title","aria-label","disabled"],es=["disabled","aria-label"];function ts(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-compose-wrap",{"wm-compose-wrap--sheet":r.displayMode==="sheet"}]),style:e.normalizeStyle(s.kbOffset?{transform:`translateY(-${s.kbOffset}px)`}:null)},[s.recording?(e.openBlock(),e.createElementBlock("div",$o,[n[8]||(n[8]=e.createElementVNode("span",{class:"wm-rec__dot","aria-hidden":"true"},null,-1)),e.createElementVNode("span",qo,e.toDisplayString(o.t("composer.recording",{time:o.recordingElapsedLabel})),1),e.createElementVNode("button",{type:"button",class:"wm-rec__stop",onClick:n[0]||(n[0]=(...i)=>o.stopRecording&&o.stopRecording(...i))},e.toDisplayString(o.t("composer.stop")),1)])):e.createCommentVNode("",!0),e.createElementVNode("form",{class:e.normalizeClass(["wm-compose",{"has-attach":s.attachOpen}]),onSubmit:n[7]||(n[7]=e.withModifiers((...i)=>o.onSubmit&&o.onSubmit(...i),["prevent"]))},[e.createElementVNode("input",{ref:"fileEl",type:"file",hidden:"",multiple:"",onChange:n[1]||(n[1]=(...i)=>o.onFile&&o.onFile(...i))},null,544),s.attachOpen?(e.openBlock(),e.createElementBlock("div",{key:0,class:"wm-compose__overlay",onClick:n[2]||(n[2]=i=>s.attachOpen=!1)})):e.createCommentVNode("",!0),s.attachOpen?(e.openBlock(),e.createElementBlock("div",Ko,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.attachItems,i=>(e.openBlock(),e.createElementBlock("button",{key:i.action,type:"button",class:"wm-compose__menuItem",disabled:i.disabled,onClick:l=>o.onAttachAction(i.action)},[e.createElementVNode("span",Go,[(e.openBlock(),e.createElementBlock("svg",Yo,[e.createElementVNode("path",{d:i.path,stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",fill:"none"},null,8,Xo)]))]),e.createElementVNode("span",null,e.toDisplayString(i.label),1)],8,Wo))),128))])):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("textarea",{ref:"inputEl","onUpdate:modelValue":n[3]||(n[3]=i=>s.local=i),class:"wm-compose__input",rows:"3",placeholder:r.placeholder,disabled:r.disabled,onKeydown:n[4]||(n[4]=(...i)=>o.onKeydown&&o.onKeydown(...i)),onInput:n[5]||(n[5]=(...i)=>o.autosize&&o.autosize(...i))},null,40,Jo),[[e.vModelText,s.local]]),e.createElementVNode("div",Qo,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["wm-compose__icon",{"is-open":s.attachOpen}]),title:r.attachLabel,"aria-label":r.attachLabel,disabled:s.recording,onClick:n[6]||(n[6]=i=>s.attachOpen=!s.attachOpen)},[...n[9]||(n[9]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})],-1)])],10,Zo),e.createElementVNode("button",{type:"submit",class:e.normalizeClass(["wm-compose__send",{"is-empty":!o.canSend}]),disabled:!o.canSend,"aria-label":o.t("composer.send")},[...n[10]||(n[10]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})],-1)])],10,es)])],34)],6)}const qe=S(Ho,[["render",ts],["__scopeId","data-v-01e81a27"]]),ns={name:"WmSuggestionChips",props:{items:{type:Array,default:()=>[]},baseDelay:{type:Number,default:360},stepDelay:{type:Number,default:90}},emits:["select"],computed:{batchKey(){return this.items.map(t=>(t==null?void 0:t.label)||(t==null?void 0:t.text)||"").join("§")}}},rs=["onClick"];function os(t,n,r,a,s,o){return r.items.length?(e.openBlock(),e.createElementBlock("div",{key:o.batchKey,class:"wm-chips"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.items,(i,l)=>(e.openBlock(),e.createElementBlock("button",{key:l,type:"button",class:"wm-chip",style:e.normalizeStyle({animationDelay:r.baseDelay+l*r.stepDelay+"ms"}),onClick:f=>t.$emit("select",i)},e.toDisplayString(i.label),13,rs))),128))])):e.createCommentVNode("",!0)}const Ke=S(ns,[["render",os],["__scopeId","data-v-47ad8085"]]),ss={name:"WmApprovalCard",components:{AIAvatar:H},inject:{t:{default:()=>T()}},props:{action:{type:String,required:!0},detail:{type:String,default:""},callbacks:{type:Array,default:()=>[]},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["callback"],computed:{approveCallback(){return this.callbacks.find(t=>t.id==="approve"||t.style==="primary")||this.callbacks[0]},rejectCallback(){return this.callbacks.find(t=>t.id==="reject"||t.style==="danger"||t.style==="neutral")||(this.callbacks.length>1?this.callbacks[1]:null)},approveId(){var t;return(t=this.approveCallback)==null?void 0:t.id},rejectId(){var t;return(t=this.rejectCallback)==null?void 0:t.id},approveLabel(){var t;return((t=this.approveCallback)==null?void 0:t.label)||this.t("approval.approve")},rejectLabel(){var t;return((t=this.rejectCallback)==null?void 0:t.label)||this.t("approval.reject")}}},as={class:"wm-approval"},is={class:"wm-approval__head"},ls={class:"wm-approval__icon"},cs={class:"wm-approval__main"},ds={class:"wm-approval__title"},us={key:0,class:"wm-approval__detail"},ms={class:"wm-approval__actions"};function hs(t,n,r,a,s,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",as,[e.createElementVNode("div",is,[e.createElementVNode("div",ls,[e.createVNode(i,{size:24,name:r.agentName,"image-url":r.agentAvatarUrl},null,8,["name","image-url"])]),e.createElementVNode("div",cs,[e.createElementVNode("div",ds,e.toDisplayString(r.action),1),r.detail?(e.openBlock(),e.createElementBlock("div",us,e.toDisplayString(r.detail),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",ms,[o.rejectId?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-approval__btn wm-approval__btn--neutral",onClick:n[0]||(n[0]=l=>t.$emit("callback",o.rejectId))},e.toDisplayString(o.rejectLabel),1)):e.createCommentVNode("",!0),o.approveId?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-approval__btn wm-approval__btn--primary",onClick:n[1]||(n[1]=l=>t.$emit("callback",o.approveId))},e.toDisplayString(o.approveLabel),1)):e.createCommentVNode("",!0)])])}const We=S(ss,[["render",hs],["__scopeId","data-v-a2bed37e"]]);let _e=0;const fs=new Set(["text","textarea","number","boolean","select","multiselect","date"]),ps={name:"WmFormCard",components:{AIAvatar:H},inject:{t:{default:()=>T()}},props:{form:{type:Object,required:!0},readOnly:{type:Boolean,default:!1},initialValues:{type:Object,default:null},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["submit"],data(){return _e+=1,{_uid:_e,values:{},busy:!1,error:""}},computed:{normalizedFields(){var n;return(Array.isArray((n=this.form)==null?void 0:n.fields)?this.form.fields:[]).filter(r=>!(!(r!=null&&r.key)||!(r!=null&&r.label)||!fs.has(r==null?void 0:r.type)||(r.type==="select"||r.type==="multiselect")&&(!Array.isArray(r.options)||r.options.length===0)))}},created(){this.resetValues()},methods:{resetValues(){const t=this.initialValues&&typeof this.initialValues=="object"?this.initialValues:{},n={};for(const r of this.normalizedFields){if(t[r.key]!==void 0){n[r.key]=t[r.key];continue}r.type==="boolean"?n[r.key]=!1:r.type==="multiselect"?n[r.key]=[]:n[r.key]=""}this.values=n,this.error=""},toggleMulti(t,n,r){const a=Array.isArray(this.values[t])?this.values[t].slice():[],s=a.indexOf(n);r&&s===-1?a.push(n):!r&&s!==-1&&a.splice(s,1),this.values={...this.values,[t]:a}},validate(){for(const t of this.normalizedFields){if(!t.required)continue;const n=this.values[t.key];if(t.type!=="boolean"){if(t.type==="multiselect"){if(!Array.isArray(n)||n.length===0)return this.t("form.fieldRequired",{label:t.label});continue}if(n==null||n==="")return this.t("form.fieldRequired",{label:t.label})}}return""},async onSubmit(){if(this.readOnly||this.busy)return;const t=this.validate();if(t){this.error=t;return}this.error="",this.busy=!0;try{await this.$emit("submit",{values:this.values})}finally{this.busy=!1}}}},gs={class:"wm-form"},_s={class:"wm-form__head"},ys={class:"wm-form__icon"},vs={class:"wm-form__main"},ks={class:"wm-form__title"},ws={key:0,class:"wm-form__detail"},bs=["for"],Es={key:0,class:"wm-form__req","aria-hidden":"true"},Cs=["id","onUpdate:modelValue","placeholder","required","disabled"],Bs=["id","onUpdate:modelValue","placeholder","required","disabled"],Ns=["id","onUpdate:modelValue","placeholder","required","disabled"],Ss=["id","onUpdate:modelValue","required","disabled"],As={key:4,class:"wm-form__bool"},Vs=["id","onUpdate:modelValue","disabled"],Ms=["id","onUpdate:modelValue","required","disabled"],Ts={value:"",disabled:""},xs=["value"],Os={key:6,class:"wm-form__multi"},Ls=["value","checked","disabled","onChange"],Ds={key:0,class:"wm-form__err"},Is=["disabled"],Rs={key:0,class:"wm-form__spinner","aria-hidden":"true"},Fs={key:2,class:"wm-form__doneLbl"};function Ps(t,n,r,a,s,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",gs,[e.createElementVNode("div",_s,[e.createElementVNode("div",ys,[e.createVNode(i,{size:24,name:r.agentName,"image-url":r.agentAvatarUrl},null,8,["name","image-url"])]),e.createElementVNode("div",vs,[e.createElementVNode("div",ks,e.toDisplayString(r.form.title||o.t("form.title")),1),r.form.description?(e.openBlock(),e.createElementBlock("div",ws,e.toDisplayString(r.form.description),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("form",{class:"wm-form__body",onSubmit:n[0]||(n[0]=e.withModifiers((...l)=>o.onSubmit&&o.onSubmit(...l),["prevent"]))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.normalizedFields,l=>(e.openBlock(),e.createElementBlock("div",{key:l.key,class:"wm-form__field"},[e.createElementVNode("label",{for:`wm-f-${s._uid}-${l.key}`,class:"wm-form__label"},[e.createTextVNode(e.toDisplayString(l.label),1),l.required?(e.openBlock(),e.createElementBlock("span",Es,"*")):e.createCommentVNode("",!0)],8,bs),l.type==="text"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,id:`wm-f-${s._uid}-${l.key}`,"onUpdate:modelValue":f=>s.values[l.key]=f,type:"text",class:"wm-form__input",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||s.busy},null,8,Cs)),[[e.vModelText,s.values[l.key]]]):l.type==="textarea"?e.withDirectives((e.openBlock(),e.createElementBlock("textarea",{key:1,id:`wm-f-${s._uid}-${l.key}`,"onUpdate:modelValue":f=>s.values[l.key]=f,class:"wm-form__textarea",rows:"3",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||s.busy},null,8,Bs)),[[e.vModelText,s.values[l.key]]]):l.type==="number"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:2,id:`wm-f-${s._uid}-${l.key}`,"onUpdate:modelValue":f=>s.values[l.key]=f,type:"number",class:"wm-form__input",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||s.busy},null,8,Ns)),[[e.vModelText,s.values[l.key],void 0,{number:!0}]]):l.type==="date"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:3,id:`wm-f-${s._uid}-${l.key}`,"onUpdate:modelValue":f=>s.values[l.key]=f,type:"date",class:"wm-form__input",required:l.required,disabled:r.readOnly||s.busy},null,8,Ss)),[[e.vModelText,s.values[l.key]]]):l.type==="boolean"?(e.openBlock(),e.createElementBlock("label",As,[e.withDirectives(e.createElementVNode("input",{id:`wm-f-${s._uid}-${l.key}`,"onUpdate:modelValue":f=>s.values[l.key]=f,type:"checkbox",disabled:r.readOnly||s.busy},null,8,Vs),[[e.vModelCheckbox,s.values[l.key]]]),e.createElementVNode("span",null,e.toDisplayString(l.placeholder||o.t("common.yes")),1)])):l.type==="select"?e.withDirectives((e.openBlock(),e.createElementBlock("select",{key:5,id:`wm-f-${s._uid}-${l.key}`,"onUpdate:modelValue":f=>s.values[l.key]=f,class:"wm-form__select",required:l.required,disabled:r.readOnly||s.busy},[e.createElementVNode("option",Ts,e.toDisplayString(l.placeholder||o.t("form.choose")),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,f=>(e.openBlock(),e.createElementBlock("option",{key:f.value,value:f.value},e.toDisplayString(f.label),9,xs))),128))],8,Ms)),[[e.vModelSelect,s.values[l.key]]]):l.type==="multiselect"?(e.openBlock(),e.createElementBlock("div",Os,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,f=>(e.openBlock(),e.createElementBlock("label",{key:f.value,class:"wm-form__multiItem"},[e.createElementVNode("input",{type:"checkbox",value:f.value,checked:Array.isArray(s.values[l.key])&&s.values[l.key].includes(f.value),disabled:r.readOnly||s.busy,onChange:y=>o.toggleMulti(l.key,f.value,y.target.checked)},null,40,Ls),e.createElementVNode("span",null,e.toDisplayString(f.label),1)]))),128))])):e.createCommentVNode("",!0)]))),128)),s.error?(e.openBlock(),e.createElementBlock("div",Ds,e.toDisplayString(s.error),1)):e.createCommentVNode("",!0),r.readOnly?(e.openBlock(),e.createElementBlock("div",Fs,e.toDisplayString(o.t("form.responseSent")),1)):(e.openBlock(),e.createElementBlock("button",{key:1,type:"submit",class:"wm-form__submit",disabled:s.busy},[s.busy?(e.openBlock(),e.createElementBlock("span",Rs)):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(s.busy?o.t("common.sending"):r.form.submit_label||o.t("common.send")),1)],8,Is))],32)])}const Ge=S(ps,[["render",Ps],["__scopeId","data-v-fe65cc56"]]),Us={name:"WmFeedback",inject:{t:{default:()=>T()}},props:{busy:{type:Boolean,default:!1},done:{type:Boolean,default:!1}},emits:["submit"],data(){return{sel:null}},computed:{options(){return[{v:1,e:"😞",l:this.t("feedback.rating1")},{v:2,e:"😐",l:this.t("feedback.rating2")},{v:3,e:"🙂",l:this.t("feedback.rating3")},{v:4,e:"😄",l:this.t("feedback.rating4")},{v:5,e:"🤩",l:this.t("feedback.rating5")}]}},methods:{onSend(){!this.sel||this.busy||this.$emit("submit",{rating:this.sel})}}},js={class:"wm-fb"},zs={class:"wm-fb__title"},Hs={class:"wm-fb__sub"},$s={class:"wm-fb__row"},qs=["onClick"],Ks={class:"wm-fb__emoji"},Ws={class:"wm-fb__label"},Gs=["disabled"],Ys={key:1,class:"wm-fb__done"},Xs={class:"wm-fb__doneTitle"},Js={class:"wm-fb__doneSub"};function Qs(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",js,[r.done?(e.openBlock(),e.createElementBlock("div",Ys,[n[1]||(n[1]=e.createElementVNode("div",{class:"wm-fb__check"},[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#fff","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M20 6L9 17l-5-5"})])],-1)),e.createElementVNode("div",Xs,e.toDisplayString(o.t("feedback.doneTitle")),1),e.createElementVNode("div",Js,e.toDisplayString(o.t("feedback.doneSubtitle")),1)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("div",zs,e.toDisplayString(o.t("feedback.question")),1),e.createElementVNode("div",Hs,e.toDisplayString(o.t("feedback.subtitle")),1),e.createElementVNode("div",$s,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.options,i=>(e.openBlock(),e.createElementBlock("button",{key:i.v,type:"button",class:e.normalizeClass(["wm-fb__opt",{"is-selected":s.sel===i.v}]),onClick:l=>s.sel=i.v},[e.createElementVNode("span",Ks,e.toDisplayString(i.e),1),e.createElementVNode("span",Ws,e.toDisplayString(i.l),1)],10,qs))),128))]),e.createElementVNode("button",{type:"button",class:"wm-fb__send",disabled:!s.sel||r.busy,onClick:n[0]||(n[0]=(...i)=>o.onSend&&o.onSend(...i))},e.toDisplayString(r.busy?o.t("common.sending"):o.t("feedback.submit")),9,Gs)],64))])}const Ye=S(Us,[["render",Qs],["__scopeId","data-v-9b630564"]]),Zs={name:"WmMoreMenu",inject:{t:{default:()=>T()}},props:{canRename:{type:Boolean,default:!0},canExport:{type:Boolean,default:!0},soundEnabled:{type:Boolean,default:!0},browserNotifEnabled:{type:Boolean,default:!1},statusUrl:{type:String,default:""},helpUrl:{type:String,default:""}},emits:["close","action","sound-toggle","browser-notif-toggle"],data(){return{soundOn:this.soundEnabled,browserNotifOn:this.browserNotifEnabled}},watch:{soundEnabled(t){this.soundOn=!!t},browserNotifEnabled(t){this.browserNotifOn=!!t}},methods:{emit(t){this.$emit("action",t)},toggleSound(){this.soundOn=!this.soundOn,this.$emit("sound-toggle",this.soundOn)},toggleBrowserNotif(){this.browserNotifOn=!this.browserNotifOn,this.$emit("browser-notif-toggle",this.browserNotifOn)}}},ea={class:"wm-mm"},ta={class:"wm-mm__pop",role:"menu"},na={key:0,class:"wm-mm__section"},ra={class:"wm-mm__label"},oa={class:"wm-mm__label"},sa={key:1,class:"wm-mm__sep"},aa={class:"wm-mm__section"},ia={class:"wm-mm__label"},la={class:"wm-mm__label"},ca={class:"wm-mm__section"},da={class:"wm-mm__label"},ua={class:"wm-mm__label"};function ma(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",ea,[e.createElementVNode("div",{class:"wm-mm__scrim",onClick:n[0]||(n[0]=i=>t.$emit("close"))}),e.createElementVNode("div",ta,[r.canRename||r.canExport?(e.openBlock(),e.createElementBlock("div",na,[r.canRename?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-mm__item",onClick:n[1]||(n[1]=i=>o.emit("rename"))},[n[7]||(n[7]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M12 20h9"}),e.createElementVNode("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})])],-1)),e.createElementVNode("span",ra,e.toDisplayString(o.t("moreMenu.editTitle")),1)])):e.createCommentVNode("",!0),r.canExport?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-mm__item",onClick:n[2]||(n[2]=i=>o.emit("export"))},[n[8]||(n[8]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M4 12v8a2 2 0 002 2h12a2 2 0 002-2v-8M16 6l-4-4-4 4M12 2v13"})])],-1)),e.createElementVNode("span",oa,e.toDisplayString(o.t("moreMenu.exportTranscript")),1),n[9]||(n[9]=e.createElementVNode("span",{class:"wm-mm__hint"},".txt",-1))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),r.canRename||r.canExport?(e.openBlock(),e.createElementBlock("div",sa)):e.createCommentVNode("",!0),e.createElementVNode("div",aa,[e.createElementVNode("button",{type:"button",class:"wm-mm__item",onClick:n[3]||(n[3]=(...i)=>o.toggleSound&&o.toggleSound(...i))},[n[11]||(n[11]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),e.createElementVNode("path",{d:"M15.54 8.46a5 5 0 010 7.07M19.07 4.93a10 10 0 010 14.14"})])],-1)),e.createElementVNode("span",ia,e.toDisplayString(o.t("moreMenu.sound")),1),e.createElementVNode("span",{class:e.normalizeClass(["wm-mm__toggle",{"wm-mm__toggle--on":s.soundOn}])},[...n[10]||(n[10]=[e.createElementVNode("span",{class:"wm-mm__knob"},null,-1)])],2)]),e.createElementVNode("button",{type:"button",class:"wm-mm__item",onClick:n[4]||(n[4]=(...i)=>o.toggleBrowserNotif&&o.toggleBrowserNotif(...i))},[n[13]||(n[13]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M15 17h5l-1.4-1.4A2 2 0 0118 14.2V11a6 6 0 10-12 0v3.2c0 .5-.2 1-.6 1.4L4 17h5m6 0a3 3 0 11-6 0"})])],-1)),e.createElementVNode("span",la,e.toDisplayString(o.t("moreMenu.browserNotifications")),1),e.createElementVNode("span",{class:e.normalizeClass(["wm-mm__toggle",{"wm-mm__toggle--on":s.browserNotifOn}])},[...n[12]||(n[12]=[e.createElementVNode("span",{class:"wm-mm__knob"},null,-1)])],2)])]),n[16]||(n[16]=e.createElementVNode("div",{class:"wm-mm__sep"},null,-1)),e.createElementVNode("div",ca,[r.statusUrl?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-mm__item",onClick:n[5]||(n[5]=i=>o.emit("status"))},[n[14]||(n[14]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zM10 6v4l3 2"})])],-1)),e.createElementVNode("span",da,e.toDisplayString(o.t("moreMenu.serviceStatus")),1)])):e.createCommentVNode("",!0),r.helpUrl?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-mm__item",onClick:n[6]||(n[6]=i=>o.emit("help"))},[n[15]||(n[15]=e.createElementVNode("span",{class:"wm-mm__icon"},[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M9 11a3 3 0 116 0c0 2-3 2-3 5M12 19h.01M12 22a10 10 0 110-20 10 10 0 010 20z"})])],-1)),e.createElementVNode("span",ua,e.toDisplayString(o.t("moreMenu.helpCenter")),1)])):e.createCommentVNode("",!0)])])])}const Xe=S(Zs,[["render",ma],["__scopeId","data-v-76281e95"]]),ha={name:"WmRenameDialog",inject:{t:{default:()=>T()}},props:{title:{type:String,default:""},initialValue:{type:String,default:""},placeholder:{type:String,default:""}},emits:["close","submit"],data(){return{value:this.initialValue||""}},computed:{canSubmit(){const t=(this.value||"").trim();return!!t&&t!==(this.initialValue||"").trim()}},mounted(){this.$nextTick(()=>{const t=this.$refs.input;if(t){t.focus();try{t.select()}catch{}}})},methods:{onSubmit(){this.canSubmit&&this.$emit("submit",this.value.trim())}}},fa={class:"wm-dialog"},pa={class:"wm-dialog__card",role:"dialog","aria-modal":"true"},ga={class:"wm-dialog__head"},_a={class:"wm-dialog__title"},ya=["aria-label"],va={class:"wm-dialog__body"},ka=["placeholder"],wa={class:"wm-dialog__actions"},ba=["disabled"];function Ea(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",fa,[e.createElementVNode("div",{class:"wm-dialog__scrim",onClick:n[0]||(n[0]=i=>t.$emit("close"))}),e.createElementVNode("div",pa,[e.createElementVNode("div",ga,[e.createElementVNode("div",_a,e.toDisplayString(r.title||o.t("rename.title")),1),e.createElementVNode("button",{type:"button",class:"wm-dialog__close","aria-label":o.t("common.close"),onClick:n[1]||(n[1]=i=>t.$emit("close"))},[...n[7]||(n[7]=[e.createElementVNode("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,ya)]),e.createElementVNode("div",va,[e.withDirectives(e.createElementVNode("input",{ref:"input","onUpdate:modelValue":n[2]||(n[2]=i=>s.value=i),type:"text",class:"wm-dialog__input",placeholder:r.placeholder||o.t("rename.placeholder"),maxlength:120,onKeydown:[n[3]||(n[3]=e.withKeys(e.withModifiers((...i)=>o.onSubmit&&o.onSubmit(...i),["prevent"]),["enter"])),n[4]||(n[4]=e.withKeys(e.withModifiers(i=>t.$emit("close"),["prevent"]),["esc"]))]},null,40,ka),[[e.vModelText,s.value]])]),e.createElementVNode("div",wa,[e.createElementVNode("button",{type:"button",class:"wm-dialog__btn",onClick:n[5]||(n[5]=i=>t.$emit("close"))},e.toDisplayString(o.t("common.cancel")),1),e.createElementVNode("button",{type:"button",class:"wm-dialog__btn wm-dialog__btn--primary",disabled:!o.canSubmit,onClick:n[6]||(n[6]=(...i)=>o.onSubmit&&o.onSubmit(...i))},e.toDisplayString(o.t("common.save")),9,ba)])])])}const Ca=S(ha,[["render",Ea],["__scopeId","data-v-6d5f94a8"]]),ye="ww-messenger-tokens",Ba={name:"Messenger",components:{Launcher:Ae,Header:Me,Onboarding:Te,History:er,MessageList:Ue,Composer:qe,SuggestionChips:Ke,ApprovalCard:We,FormCard:Ge,Feedback:Ye,MoreMenu:Xe,RenameDialog:Ca},mixins:[pt,wt,bt,Ct],provide(){return{signAttachmentFn:t=>{var n,r;return((r=(n=this.store)==null?void 0:n.signAttachment)==null?void 0:r.call(n,t))||null},t:(t,n)=>this.t(t,n),wmLocale:()=>this.locale}},props:{baseUrl:{type:String,default:be},widgetId:{type:String,default:""},context:{type:Object,default:null},displayMode:{type:String,default:"floating"},devtools:{type:Boolean,default:!1},language:{type:String,default:""}},data(){return{transport:null,store:null,isOpen:!1,launcherHovered:!1,draft:"",busy:!1,bootError:null,pendingAttachments:[],feedbackBusy:!1,feedbackDone:!1,convOpenedAt:0,moreOpen:!1,renameDialogOpen:!1,draftConv:null,activeConvId:null,showOnboarding:!1,showHistory:!1,dismissedPeeks:{},floatHeight:0,floatRO:null,parentOrigin:"",parentToken:"",parentVariables:null,parentAllowUnauthenticated:!1,parentInitReceived:!1,parentInitDeferred:null}},computed:{isEditor(){return!!this.devtools},isEmbedded(){return this.displayMode==="embedded"},customerLanguage(){var r,a,s,o;const t=(r=this.s)==null?void 0:r.customer,n=t&&(t.language||((a=t.values)==null?void 0:a.language));return n||((o=(s=this.context)==null?void 0:s.customer)==null?void 0:o.language)||""},locale(){var t;return se(this.language||this.customerLanguage||((t=this.widget)==null?void 0:t.default_language)||"")},translator(){return T(this.locale)},error(){var t;return this.bootError||((t=this.s)==null?void 0:t.error)||null},canBoot(){return!!(this.baseUrl&&this.widgetId)},s(){var t;return((t=this.store)==null?void 0:t.state)||null},ready(){var t;return!!((t=this.s)!=null&&t.ready)},allConversations(){var n;const t=(n=this.s)==null?void 0:n.conversations;return Array.isArray(t)?t:[]},drawerConversations(){var r;const t=((r=this.s)==null?void 0:r.messagesByConv)||{},n=this.revealedAt;return this.allConversations.map(a=>{var y;const s=t[a.id]||[],o=R(a.last_read_message_id);let i=0,l=null;for(let _=s.length-1;_>=0;_--){const C=s[_];if(!C)continue;if(((y=C.author)==null?void 0:y.type)==="user")break;const N=R(C.id);if(N!=null){if(o!=null&&N<=o)break;n[C.id]!==0&&(!l&&C.author&&(l=C.author),i++)}}if(!s.length){const _=R(a.last_message_id);_!=null&&(o==null||_>o)&&(i=1,l=a.last_message_author||null)}const f=s.filter(_=>!((_==null?void 0:_.id)!=null&&n[_.id]===0));return{...a,_preview:ut(a,f),_unread:i>0,_unreadCount:i,_lastAuthor:l}})},unreadCount(){return this.drawerConversations.filter(t=>t._unread).length},openThreads(){var n;const t=((n=this.s)==null?void 0:n.messagesByConv)||{};return this.drawerConversations.filter(r=>r.status!=="resolved").map(r=>({id:r.id,title:r.name||this.t("common.newConversation"),preview:r._preview||this.t("onboarding.newMessage"),unread:!!r._unread,author:r._lastAuthor||null,_ts:pe(r,t[r.id]||[])})).sort((r,a)=>r._ts<a._ts?1:r._ts>a._ts?-1:0)},latestUnreads(){var r;const t=((r=this.s)==null?void 0:r.messagesByConv)||{},n=[];for(const a of this.drawerConversations){if(!a._unread)continue;const s=pe(a,t[a.id]||[]),o=a._lastAuthor,i=!o||o.type==="agent_ia",l=(o==null?void 0:o.name)||(i?this.agentName:"")||"",f=(o==null?void 0:o.avatar_url)||(i?this.agentAvatarUrl:null);n.push({convId:a.id,preview:a._preview||this.t("notification.youHaveNewMessage"),ts:s,count:a._unreadCount||1,senderName:l,senderAvatarUrl:f})}return n.sort((a,s)=>a.ts<s.ts?1:a.ts>s.ts?-1:0),n},launcherPeeks(){if(this.isOpen||this.isEmbedded)return[];const t=this.dismissedPeeks||{};return this.latestUnreads.filter(n=>t[n.convId]!==n.ts)},isViewingThread(){return(this.isOpen||this.isEmbedded)&&!!this.currentConv},currentConv(){if(this.draftConv)return this.draftConv;if(this.showOnboarding)return null;const t=this.allConversations;if(!t.length)return null;if(this.activeConvId!=null){const n=t.find(r=>r.id===this.activeConvId);if(n)return n}return t[0]||null},canBack(){return!!this.currentConv||this.showHistory},statusUrl(){var r;const t=(r=this.widget)==null?void 0:r.quick_links;if(!Array.isArray(t))return"";const n=t.find(a=>a.icon==="status"&&a.url);return(n==null?void 0:n.url)||""},helpUrl(){var r;const t=(r=this.widget)==null?void 0:r.quick_links;if(!Array.isArray(t))return"";const n=t.find(a=>(a.icon==="chat"||a.icon==="help")&&a.url);return(n==null?void 0:n.url)||""},widget(){var t,n;return((n=(t=this.s)==null?void 0:t.config)==null?void 0:n.widget)||null},rootStyle(){var n;const t=(n=this.widget)==null?void 0:n.primary_color;return t&&it(t)?{"--wm-primary":t}:null},widgetWelcomeMessage(){var t;return((t=this.widget)==null?void 0:t.welcome_message)||""},widgetSubtitle(){var t;return((t=this.widget)==null?void 0:t.subtitle)||""},defaultIconUrl(){var t;return((t=this.widget)==null?void 0:t.default_icon_url)||null},agentName(){var t,n,r;return((r=(n=(t=this.s)==null?void 0:t.config)==null?void 0:n.agent)==null?void 0:r.name)||""},agentAvatarUrl(){var t,n,r;return((r=(n=(t=this.s)==null?void 0:t.config)==null?void 0:n.agent)==null?void 0:r.avatar_url)||null},quickLinks(){var n;const t=(n=this.widget)==null?void 0:n.quick_links;return Array.isArray(t)?t:[]},teamMembers(){var n;const t=(n=this.widget)==null?void 0:n.team_members;return Array.isArray(t)?t:[]},responseLabel(){var t;return((t=this.widget)==null?void 0:t.response_time_label)||""},humanMessageAuthor(){var n,r,a;if(!this.currentConv)return null;const t=((n=this.s.messagesByConv)==null?void 0:n[this.currentConv.id])||[];for(let s=t.length-1;s>=0;s--)if(((a=(r=t[s])==null?void 0:r.author)==null?void 0:a.type)==="agent_human")return t[s].author;return null},humanAgentName(){var t;return((t=this.humanMessageAuthor)==null?void 0:t.name)||""},humanAgentAvatarUrl(){var t;return((t=this.humanMessageAuthor)==null?void 0:t.avatar_url)||null},isEscalated(){return!!this.humanMessageAuthor},isWaitingHuman(){var n;const t=(n=this.currentConv)==null?void 0:n.status;return t==="waiting"||t==="handled"},headerTitle(){var t,n;return((t=this.currentConv)==null?void 0:t.name)||((n=this.widget)==null?void 0:n.name)||this.t("common.newConversation")},composerPlaceholder(){return this.isEscalated&&this.humanAgentName?this.t("composer.replyTo",{name:this.humanAgentName.split(" ")[0]}):this.isWaitingHuman?this.t("composer.agentTakingOver"):this.t("composer.placeholder")},displayedMessages(){var r,a;const t=this.currentConv;if(!t)return[];if(!t._draft){const s=(a=(r=this.s)==null?void 0:r.paginationByConv)==null?void 0:a[t.id];if(!(s!=null&&s.loaded))return[]}const n=this.revealedAt;return(this.s.messagesByConv[t.id]||[]).filter(s=>{var o,i,l,f,y;return(s==null?void 0:s.type)==="action"&&((o=s==null?void 0:s.payload)==null?void 0:o.state)==="pending"||X(s)&&!(n[s.id]>0)?!1:(s==null?void 0:s.type)==="action"||(s==null?void 0:s.type)==="system"||((i=s==null?void 0:s.payload)==null?void 0:i.type)==="system"||Array.isArray((l=s==null?void 0:s.payload)==null?void 0:l.attachments)&&s.payload.attachments.length||(f=s==null?void 0:s.metadata)!=null&&f.artifact||(y=s==null?void 0:s.metadata)!=null&&y.form?!0:typeof(s==null?void 0:s.text_md)=="string"&&s.text_md.trim().length>0})},streamingActive(){var r,a,s;const t=this.currentConv;return t?Object.keys(((r=this.s)==null?void 0:r.streamingByMsgId)||{}).length>0?!0:this.actionInFlight?!1:(((s=(a=this.s)==null?void 0:a.messagesByConv)==null?void 0:s[t.id])||[]).some(o=>X(o)&&!(this.revealedAt[o.id]>0)):!1},currentConvMessages(){var n,r,a;const t=(n=this.currentConv)==null?void 0:n.id;return t?((a=(r=this.s)==null?void 0:r.messagesByConv)==null?void 0:a[t])||[]:[]},pendingApproval(){return!this.currentConv||!this.store||this.actionInFlight?null:this.store.getPendingApproval(this.currentConv.id)},approvalReady(){return this.pendingApproval?this.pendingApproval.id===this.approvalLatchId?!0:!(this.streamingActive||!this.approvalSettled):!1},approvalTitle(){var t,n,r;return((n=(t=this.pendingApproval)==null?void 0:t.payload)==null?void 0:n.name)||((r=this.pendingApproval)==null?void 0:r.text_md)||this.t("action.title")},approvalDetail(){var a,s,o,i,l,f;const t=(o=(s=(a=this.pendingApproval)==null?void 0:a.payload)==null?void 0:s.pending)==null?void 0:o.user_explanation;if(typeof t=="string"&&t.trim())return t.trim();const n=(f=(l=(i=this.pendingApproval)==null?void 0:i.payload)==null?void 0:l.pending)==null?void 0:f.prepared_params;if(!n||typeof n!="object")return"";const r=Object.entries(n);return r.length?r.slice(0,2).map(([y,_])=>`${y}: ${_}`).join(" · "):""},actionInFlight(){var t,n;return!this.currentConv||!this.store?null:((n=(t=this.store).getActionInFlight)==null?void 0:n.call(t,this.currentConv.id))||null},actionInFlightName(){var n;const t=this.actionInFlight;return t?((n=t.payload)==null?void 0:n.name)||t.text_md||this.t("common.action"):""},suggestions(){return!this.currentConv||!this.store?[]:this.streamingActive?[]:this.pendingForm?[]:this.store.getLatestSuggestions(this.currentConv.id)},pendingForm(){var t,n;return!this.currentConv||!this.store||this.pendingApproval||this.actionInFlight||this.streamingActive||!this.approvalSettled?null:((n=(t=this.store).getLatestForm)==null?void 0:n.call(t,this.currentConv.id))||null},showFeedback(){var n;const t=this.currentConv;return t?this.feedbackDone?!0:t.status!=="resolved"?!1:!((n=t.metadata)!=null&&n.feedback):!1},floatVisible(){return this.approvalReady||!!this.pendingForm||this.showFeedback||this.suggestions.length>0},dateLabel(){var r,a,s;const t=this.currentConv;let n=new Date;if(t){const i=((s=(((a=(r=this.s)==null?void 0:r.messagesByConv)==null?void 0:a[t.id])||[]).find(l=>l==null?void 0:l.created_at))==null?void 0:s.created_at)||t.created_at;if(i){const l=new Date(i);Number.isNaN(l.getTime())||(n=l)}}return this.t("messageList.today",{time:ne(n,z(this.locale))})},paginationState(){var r,a,s;const t=(r=this.currentConv)==null?void 0:r.id,n=t?(s=(a=this.s)==null?void 0:a.paginationByConv)==null?void 0:s[t]:null;return{loading:!!(n!=null&&n.loading),hasMore:!!(n!=null&&n.nextCursor)}}},watch:{latestUnreads:{handler(t){const n=new Set(t.map(i=>i.convId)),r=this.dismissedPeeks||{},a=Object.keys(r);if(!a.length)return;const s={};let o=!1;for(const i of a)n.has(i)?s[i]=r[i]:o=!0;o&&(this.dismissedPeeks=s)},deep:!0},"currentConv.id":{handler(t){var n;this.resetRevealQueue(),this.convOpenedAt=Date.now(),this.moreOpen=!1,this.renameDialogOpen=!1,this.resetApprovalPacing(),this.isViewingThread&&(this.unreadAnchorId=R((n=this.currentConv)==null?void 0:n.last_read_message_id),this.unreadBoundaryTs=t?new Date().toISOString():"")},immediate:!0},isViewingThread(t,n){var r;t&&!n?(this.unreadAnchorId=R((r=this.currentConv)==null?void 0:r.last_read_message_id),this.unreadBoundaryTs=new Date().toISOString()):t||(this.unreadAnchorId=null,this.unreadBoundaryTs="")},pendingApproval:{handler(t,n){if(t&&!n){const r=t!=null&&t.created_at?Date.parse(t.created_at):NaN;if(!(Number.isFinite(r)&&r>=this.convOpenedAt)){this.resetApprovalPacing();return}this.bumpApprovalSettle(2600)}else!t&&n&&this.resetApprovalPacing()},immediate:!1},streamingActive(t,n){t!==n&&this.pendingApproval&&this.pendingApproval.id!==this.approvalLatchId&&this.bumpApprovalSettle()},approvalReady(t){t&&this.pendingApproval&&(this.approvalLatchId=this.pendingApproval.id)},floatVisible:{handler(t){this.$nextTick(()=>this.syncFloatObserver(t))},immediate:!0},currentConvMessages(t){var n;this.paceMessages(t,(n=this.currentConv)==null?void 0:n.id),(this.isOpen||this.isEmbedded)&&this.currentConv&&this.markConvRead(this.currentConv)}},async mounted(){if(typeof document<"u"&&!document.getElementById(ye)){const t=document.createElement("style");t.id=ye,t.textContent=we,document.head.appendChild(t)}this._parentMessageHandler=this.onParentMessage.bind(this),window.addEventListener("message",this._parentMessageHandler),window.parent&&window.parent!==window&&window.parent.postMessage({type:"READY"},"*"),this.isEmbedded?(await this.boot(),this.store&&await this.open()):(await this.$nextTick(),this.sendCurrentLauncherSize(),this.observeLauncherSize())},beforeUnmount(){this._parentMessageHandler&&(window.removeEventListener("message",this._parentMessageHandler),this._parentMessageHandler=null),this._launcherRo&&(this._launcherRo.disconnect(),this._launcherRo=null),this.cancelReveals(),this.teardownLiveReveal(),this.disconnectFloatRO(),this.resetApprovalPacing(),this.teardownNotifications(),this.store&&this.store.destroy()},methods:{t(t,n){return this.translator(t,n)},waitForParentInit(){if(this.parentInitReceived)return Promise.resolve();if(!this.parentInitDeferred){let t;this.parentInitDeferred=new Promise(n=>{t=n}),this.parentInitDeferred._resolve=t}return this.parentInitDeferred},onParentMessage(t){var r;const n=t==null?void 0:t.data;if(!(!n||typeof n!="object")){if(n.type==="UPDATE"){this.transport&&n.payload&&this.transport.update(n.payload).catch(a=>{console.warn("[messenger] update failed",a)});return}if(n.type==="CONTEXT"){this.transport&&n.payload&&this.transport.context(n.payload);return}n.type==="INIT"&&(this.parentOrigin=t.origin,this.parentToken=typeof n.token=="string"?n.token:"",this.parentVariables=n.variables&&typeof n.variables=="object"?n.variables:n.context&&typeof n.context=="object"?n.context:null,this.parentAllowUnauthenticated=n.allowUnauthenticated===!0,this.parentInitReceived=!0,(r=this.parentInitDeferred)!=null&&r._resolve&&this.parentInitDeferred._resolve(),!this.isEmbedded&&!this.isOpen&&!this.parentAllowUnauthenticated&&this.parentToken&&this.hasValidSessionMarker()&&this.boot().catch(a=>{console.warn("[messenger] eager boot failed",a)}))}},hasValidSessionMarker(){if(typeof document>"u")return!1;const n=(document.cookie||"").match(/(?:^|; )messenger_session_marker=([^;]+)/);if(!n)return!1;const r=parseInt(n[1],10);return Number.isFinite(r)?r>Date.now():!1},async boot(){if(!this.canBoot){console.warn("[messenger] boot skipped — missing creds");return}try{await this.waitForParentInit(),this.transport=e.markRaw(ve({baseUrl:this.baseUrl,widgetId:this.widgetId})),this.store=e.markRaw(ke(this.transport)),this.hydrateNotifPref();const t=this.parentVariables||this.context||null;if(await this.store.start({origin:this.parentOrigin,token:this.parentToken||void 0,allowUnauthenticated:this.parentAllowUnauthenticated,variables:t&&typeof t=="object"?t:void 0}),t&&typeof t=="object"){const n={};for(const[r,a]of Object.entries(t))r!=="customer"&&a&&typeof a=="object"&&!Array.isArray(a)&&(n[r]=a);Object.keys(n).length>0&&this.transport.context(n)}this.setupLiveReveal()}catch(t){console.error("[ww-messenger] bootstrap failed",t),this.bootError=(t==null?void 0:t.message)||String(t)}},async refresh(){this.store&&this.store.destroy(),this.cancelReveals(),this.teardownLiveReveal(),this.teardownNotifications(),this.convOpenedAt=0,this.transport=null,this.store=null,this.isOpen=!1,this.draft="",this.busy=!1,this.bootError=null,this.pendingAttachments=[],this.feedbackBusy=!1,this.feedbackDone=!1,this.moreOpen=!1,this.renameDialogOpen=!1,this.draftConv=null,this.activeConvId=null,this.showOnboarding=!1,this.showHistory=!1,await this.boot(),this.isEmbedded&&this.store&&await this.open()},syncFloatObserver(t){if(this.disconnectFloatRO(),!t){this.floatHeight=0;return}const n=this.$refs.floatEl;if(n){if(typeof ResizeObserver>"u"){this.floatHeight=Math.ceil(n.getBoundingClientRect().height+8);return}this.floatRO=new ResizeObserver(r=>{const a=r[0];if(!a)return;const s=Math.ceil(a.contentRect.height+8);s!==this.floatHeight&&(this.floatHeight=s,this.$nextTick(()=>{var o,i;(i=(o=this.$refs.messageList)==null?void 0:o.scrollToBottom)==null||i.call(o)}))}),this.floatRO.observe(n)}},disconnectFloatRO(){if(this.floatRO){try{this.floatRO.disconnect()}catch{}this.floatRO=null}},async open(){this.isOpen=!0,this.notifyParentResize("open"),this._launcherRo&&this._launcherRo.disconnect(),this.store||await this.boot(),this.store&&this.store.setPanelOpen(!0);const t=this.currentConv;if(t&&!t._draft){this.activeConvId==null&&(this.activeConvId=t.id);try{await this.store.openConversation(t.id)}catch(n){console.error("[ww-messenger] load messages failed",n)}this.markConvRead(t)}},async close(){this.isOpen=!1,await this.$nextTick(),this.sendCurrentLauncherSize(),this.observeLauncherSize(),this.store&&this.store.setPanelOpen(!1)},notifyParentResize(t,n){if(window.parent&&window.parent!==window)try{window.parent.postMessage({type:"RESIZE",state:t,displayMode:this.displayMode,...n||{}},"*")}catch(r){console.warn("[ww-messenger] notifyParentResize failed",r)}},onLauncherHover(t){this.launcherHovered=t,this.sendCurrentLauncherSize()},sendCurrentLauncherSize(){var _,C,N,k,O,b,V;if(this.isOpen)return;const t=(C=(_=this.$el)==null?void 0:_.querySelector)==null?void 0:C.call(_,".wm-launcherWrap");if(!t)return;const n=t.getBoundingClientRect();if(!n.width||!n.height)return;const r=(((N=this.launcherPeeks)==null?void 0:N.length)??0)>0,a=16,s=Math.ceil(n.width),o=Math.ceil(n.height),i=(O=(k=this.$el)==null?void 0:k.querySelector)==null?void 0:O.call(k,".wm-launcher"),l=(V=(b=this.$el)==null?void 0:b.querySelectorAll)==null?void 0:V.call(b,".wm-peek"),f=l&&l.length?l[l.length-1]:null;let y=null;if(f){const M=f.getBoundingClientRect();y={width:Math.ceil(M.width),height:Math.ceil(M.height),rightOffset:Math.max(0,Math.ceil(n.right-M.right)),bottomOffset:Math.max(0,Math.ceil(n.bottom-M.bottom))}}this.notifyParentResize("closed",{width:s+a,height:o+a,launcherWidth:(i==null?void 0:i.offsetWidth)||null,launcherHeight:(i==null?void 0:i.offsetHeight)||null,launcherHovered:this.launcherHovered,peek:y,peekHovered:this.launcherHovered&&r})},observeLauncherSize(){var r,a;if(typeof ResizeObserver>"u")return;const t=(a=(r=this.$el)==null?void 0:r.querySelector)==null?void 0:a.call(r,".wm-launcherWrap");if(!t)return;this._launcherRo&&this._launcherRo.disconnect();const n=new ResizeObserver(()=>{this.isOpen||this.sendCurrentLauncherSize()});n.observe(t),this._launcherRo=n},async openFromPeek(t){var r,a;const n=t||((r=this.latestUnreads[0])==null?void 0:r.convId);n&&n!==((a=this.currentConv)==null?void 0:a.id)&&(this.draftConv=null,this.activeConvId=n,this.showOnboarding=!1,this.showHistory=!1),await this.open()},dismissPeek(t){const n=this.latestUnreads.find(r=>r.convId===t);n&&(this.dismissedPeeks={...this.dismissedPeeks,[t]:n.ts})},startConv(){this.draftConv={id:"__draft__",_draft:!0,name:"",created_at:new Date().toISOString()},this.activeConvId=null,this.showOnboarding=!1,this.showHistory=!1,this.focusComposer()},async ensureRealConv(){const t=this.currentConv;if(!t)return null;if(!t._draft)return t;if(this.busy)return null;this.busy=!0;try{const n=await this.store.createConversation({});return this.draftConv=null,this.activeConvId=n.id,await this.store.openConversation(n.id),this.markConvRead(n),n}catch(n){return console.error("[ww-messenger] create conv failed",n),this.bootError=(n==null?void 0:n.message)||String(n),null}finally{this.busy=!1}},focusComposer(){this.$nextTick(()=>{var t;return(t=this.$refs.composer)==null?void 0:t.focus()})},toggleMore(){this.moreOpen=!this.moreOpen},goHome(){this.moreOpen=!1,this.draftConv=null,this.activeConvId=null,this.showOnboarding=!0,this.showHistory=!1},async onDrawerPick(t){if(!(t!=null&&t.id)||!this.store)return;this.draftConv=null,this.activeConvId=t.id,this.showOnboarding=!1,this.showHistory=!1;try{await this.store.openConversation(t.id)}catch(r){console.error("[ww-messenger] open conv failed",r)}const n=this.allConversations.find(r=>r.id===t.id);n&&this.markConvRead(n)},async onMoreAction(t){var n,r;switch(this.moreOpen=!1,t){case"rename":this.openRenameDialog();break;case"export":ft(this.currentConv,this.currentConv?(r=(n=this.s)==null?void 0:n.messagesByConv)==null?void 0:r[this.currentConv.id]:[],this.translator,this.locale);break;case"status":if(te(this.statusUrl))try{window.open(this.statusUrl,"_blank","noopener")}catch{}break;case"help":if(te(this.helpUrl))try{window.open(this.helpUrl,"_blank","noopener")}catch{}break}},openRenameDialog(){const t=this.currentConv;!t||t._draft||(this.renameDialogOpen=!0)},async onRenameSubmit(t){const n=this.currentConv;if(this.renameDialogOpen=!1,!n||n._draft||!this.store)return;const r=(t||"").trim();if(!(!r||r===n.name))try{await this.store.patchConversation(n.id,{name:r})}catch(a){console.error("[ww-messenger] rename failed",a)}},async onSend(t){let n=this.currentConv;if(!n&&(this.startConv(),n=this.currentConv,!n)||n._draft&&(n=await this.ensureRealConv(),!n))return;const r=n.id,a=this.pendingAttachments.slice();this.pendingAttachments=[],this.unreadAnchorId=null,this.unreadBoundaryTs="",await this.store.send(r,t,{attachments:a.length?a:void 0})},async onSuggestion(t){const n=t==null?void 0:t.label;n&&await this.onSend(n)},async onLoadMore(){var n;const t=(n=this.currentConv)==null?void 0:n.id;!t||!this.store||await this.store.loadMore(t)},async onApprovalCallback(t){const n=this.pendingApproval;n&&await this.store.clickCallback(n.id,t)},async onFormSubmit({values:t}){const n=this.pendingForm;if(!(n!=null&&n.form))return;const r=ct(n.form,t,this.translator);if(!r)return;let a=this.currentConv;a&&(a._draft&&(a=await this.ensureRealConv(),!a)||await this.store.send(a.id,r,{metadata:{artifact:dt(n.form,t,this.translator)}}))},async onAttach(t){if(!(!t||!this.transport))try{const n=await this.transport.uploadAttachment(t);this.pendingAttachments.push({type:n.type||"file",path:n.path,name:t.name||this.t("attachment.fileFallbackName"),mime_type:t.type,size_bytes:t.size})}catch(n){console.error("[ww-messenger] attachment upload failed",n)}},onPanelClick(t){const n=t.target&&t.target.closest?t.target.closest('a[href^="#"]'):null;n&&(t.preventDefault(),this.openInternalUrl(n.getAttribute("href")))},async openInternalUrl(t){if(typeof t!="string"||!t.startsWith("#"))return!1;const n=t.slice(1);if(n==="new"||n==="new-conversation")return this.isOpen||await this.open(),this.startConv(),!0;if(n.startsWith("conversation/")){const r=n.slice(13);return r&&await this.openFromPeek(r),!0}return console.warn("[messenger] unknown internal url",t),!0},async onQuickLink(t){if(t){if(t.url){if(await this.openInternalUrl(t.url))return;if(!te(t.url)){console.warn("[messenger] refusing unsafe quick-link url",t.url);return}try{window.open(t.url,"_blank","noopener")}catch{}return}this.currentConv||this.startConv(),await this.onSend(t.label)}},async onFeedback({rating:t,comment:n}){if(this.currentConv){this.feedbackBusy=!0;try{await this.store.submitFeedback(this.currentConv.id,{rating:t,comment:n}),this.feedbackDone=!0}catch(r){console.error("[ww-messenger] feedback failed",r)}finally{this.feedbackBusy=!1}}}}},Na={key:0,class:"wm-loading","aria-busy":"true","aria-live":"polite"},Sa=["aria-label"],Aa={key:0,class:"wm-state"},Va={class:"wm-state__err"},Ma={class:"wm-state__errTitle"},Ta={class:"wm-state__errSub"},xa={class:"wm-bottom"},Oa={key:0,ref:"floatEl",class:"wm-float"},La={key:1,class:"wm-actionWait",role:"status","aria-live":"polite"},Da={class:"wm-actionWait__lbl"},Ia={key:2,class:"wm-attached"},Ra=["aria-label","onClick"];function Fa(t,n,r,a,s,o){const i=e.resolveComponent("Launcher"),l=e.resolveComponent("Header"),f=e.resolveComponent("History"),y=e.resolveComponent("Onboarding"),_=e.resolveComponent("MessageList"),C=e.resolveComponent("ApprovalCard"),N=e.resolveComponent("FormCard"),k=e.resolveComponent("Feedback"),O=e.resolveComponent("SuggestionChips"),b=e.resolveComponent("Composer"),V=e.resolveComponent("MoreMenu"),M=e.resolveComponent("RenameDialog");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-root",`wm-root--${r.displayMode}`]),style:e.normalizeStyle(o.rootStyle)},[!s.isOpen&&!o.isEmbedded?(e.openBlock(),e.createBlock(i,{key:0,"unread-count":o.unreadCount,peeks:o.launcherPeeks,onOpen:o.openFromPeek,onDismiss:o.dismissPeek,onHover:o.onLauncherHover},null,8,["unread-count","peeks","onOpen","onDismiss","onHover"])):e.createCommentVNode("",!0),s.isOpen||o.isEmbedded?(e.openBlock(),e.createElementBlock("section",{key:1,class:e.normalizeClass(["wm-panel",`wm-panel--${r.displayMode}`,{"wm-panel--welcome":o.ready&&!o.error&&!o.currentConv}]),style:e.normalizeStyle(s.floatHeight?{"--wm-float-h":s.floatHeight+"px"}:null),role:"dialog","aria-label":"Messenger",onClick:n[6]||(n[6]=(...A)=>o.onPanelClick&&o.onPanelClick(...A))},[!o.ready&&!o.error?(e.openBlock(),e.createElementBlock("div",Na,[o.isEmbedded?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-loading__close","aria-label":o.t("loading.minimize"),onClick:n[0]||(n[0]=(...A)=>o.close&&o.close(...A))},[...n[7]||(n[7]=[e.createElementVNode("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,Sa)),n[8]||(n[8]=e.createElementVNode("div",{class:"wm-loading__spinner","aria-hidden":"true"},null,-1))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(l,{title:o.headerTitle,"team-members":o.teamMembers,"response-label":o.responseLabel,"show-identity":!!o.currentConv,"show-back":o.canBack,"show-close":!o.isEmbedded,"more-active":s.moreOpen,"agent-name":o.agentName,"agent-avatar-url":o.agentAvatarUrl,onBack:o.goHome,onMore:o.toggleMore,onClose:o.close},null,8,["title","team-members","response-label","show-identity","show-back","show-close","more-active","agent-name","agent-avatar-url","onBack","onMore","onClose"]),o.error?(e.openBlock(),e.createElementBlock("div",Aa,[e.createElementVNode("div",Va,[n[9]||(n[9]=e.createElementVNode("div",{class:"wm-state__errIcon"},[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})])],-1)),e.createElementVNode("div",null,[e.createElementVNode("div",Ma,e.toDisplayString(o.t("error.connectionFailed")),1),e.createElementVNode("div",Ta,e.toDisplayString(o.error),1)])])])):!o.currentConv&&s.showHistory?(e.openBlock(),e.createBlock(f,{key:1,threads:o.openThreads,onResume:o.onDrawerPick},null,8,["threads","onResume"])):o.currentConv?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createVNode(_,{ref:"messageList",messages:o.displayedMessages,"streaming-active":o.streamingActive,"date-label":o.dateLabel,"conversation-id":o.currentConv?o.currentConv.id:null,"loading-more":o.paginationState.loading,"has-more":o.paginationState.hasMore,"unread-anchor-id":t.unreadAnchorId,"unread-boundary-ts":t.unreadBoundaryTs,"ai-agent-name":o.agentName,"ai-agent-avatar-url":o.agentAvatarUrl,onLoadMore:o.onLoadMore},null,8,["messages","streaming-active","date-label","conversation-id","loading-more","has-more","unread-anchor-id","unread-boundary-ts","ai-agent-name","ai-agent-avatar-url","onLoadMore"]),e.createElementVNode("div",xa,[o.floatVisible?(e.openBlock(),e.createElementBlock("div",Oa,[o.approvalReady?(e.openBlock(),e.createBlock(C,{key:0,action:o.approvalTitle,detail:o.approvalDetail,callbacks:o.pendingApproval.callbacks,"agent-name":o.agentName,"agent-avatar-url":o.agentAvatarUrl,onCallback:o.onApprovalCallback},null,8,["action","detail","callbacks","agent-name","agent-avatar-url","onCallback"])):o.pendingForm?(e.openBlock(),e.createBlock(N,{key:o.pendingForm.message&&o.pendingForm.message.id,form:o.pendingForm.form,"agent-name":o.agentName,"agent-avatar-url":o.agentAvatarUrl,onSubmit:o.onFormSubmit},null,8,["form","agent-name","agent-avatar-url","onSubmit"])):o.showFeedback?(e.openBlock(),e.createBlock(k,{key:2,busy:s.feedbackBusy,done:s.feedbackDone,onSubmit:o.onFeedback},null,8,["busy","done","onSubmit"])):(e.openBlock(),e.createBlock(O,{key:3,items:o.suggestions,onSelect:o.onSuggestion},null,8,["items","onSelect"]))],512)):e.createCommentVNode("",!0),o.actionInFlight?(e.openBlock(),e.createElementBlock("div",La,[n[10]||(n[10]=e.createElementVNode("span",{class:"wm-actionWait__spinner","aria-hidden":"true"},null,-1)),e.createElementVNode("span",Da,e.toDisplayString(o.t("action.inProgress",{name:o.actionInFlightName})),1)])):(e.openBlock(),e.createBlock(b,{key:2,ref:"composer",modelValue:s.draft,"onUpdate:modelValue":n[2]||(n[2]=A=>s.draft=A),placeholder:o.composerPlaceholder,disabled:!!o.pendingApproval,"attach-label":o.t("composer.attachFile"),"display-mode":r.displayMode,onSend:o.onSend,onAttach:o.onAttach},null,8,["modelValue","placeholder","disabled","attach-label","display-mode","onSend","onAttach"]))]),s.moreOpen?(e.openBlock(),e.createBlock(V,{key:0,"can-rename":!!o.currentConv&&!o.currentConv._draft,"can-export":!!o.currentConv&&!o.currentConv._draft,"sound-enabled":t.soundEnabled,"browser-notif-enabled":t.browserNotifEnabled,"status-url":o.statusUrl,"help-url":o.helpUrl,onClose:n[3]||(n[3]=A=>s.moreOpen=!1),onSoundToggle:t.onSoundToggle,onBrowserNotifToggle:t.onBrowserNotifToggle,onAction:o.onMoreAction},null,8,["can-rename","can-export","sound-enabled","browser-notif-enabled","status-url","help-url","onSoundToggle","onBrowserNotifToggle","onAction"])):e.createCommentVNode("",!0),s.renameDialogOpen&&o.currentConv&&!o.currentConv._draft?(e.openBlock(),e.createBlock(M,{key:1,"initial-value":o.currentConv.name||"",title:o.t("rename.dialogTitle"),onClose:n[4]||(n[4]=A=>s.renameDialogOpen=!1),onSubmit:o.onRenameSubmit},null,8,["initial-value","title","onSubmit"])):e.createCommentVNode("",!0),s.pendingAttachments.length?(e.openBlock(),e.createElementBlock("div",Ia,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.pendingAttachments,(A,D)=>(e.openBlock(),e.createElementBlock("div",{key:D,class:"wm-attached__chip"},[n[12]||(n[12]=e.createElementVNode("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})],-1)),e.createElementVNode("span",null,e.toDisplayString(A.name),1),e.createElementVNode("button",{type:"button","aria-label":o.t("attachment.remove"),onClick:P=>s.pendingAttachments.splice(D,1)},[...n[11]||(n[11]=[e.createElementVNode("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,Ra)]))),128))])):e.createCommentVNode("",!0)],64)):(e.openBlock(),e.createBlock(y,{key:2,"welcome-message":o.widgetWelcomeMessage,subtitle:o.widgetSubtitle,"agent-name":o.agentName,"default-icon-url":o.defaultIconUrl,"quick-links":o.quickLinks,"open-threads":o.openThreads,busy:s.busy,onStart:o.startConv,onSelect:o.onQuickLink,onResume:o.onDrawerPick,onViewHistory:n[1]||(n[1]=A=>s.showHistory=!0)},null,8,["welcome-message","subtitle","agent-name","default-icon-url","quick-links","open-threads","busy","onStart","onSelect","onResume"])),s.moreOpen&&!o.currentConv?(e.openBlock(),e.createBlock(V,{key:4,"can-rename":!1,"can-export":!1,"sound-enabled":t.soundEnabled,"browser-notif-enabled":t.browserNotifEnabled,"status-url":o.statusUrl,"help-url":o.helpUrl,onClose:n[5]||(n[5]=A=>s.moreOpen=!1),onSoundToggle:t.onSoundToggle,onBrowserNotifToggle:t.onBrowserNotifToggle,onAction:o.onMoreAction},null,8,["sound-enabled","browser-notif-enabled","status-url","help-url","onSoundToggle","onBrowserNotifToggle","onAction"])):e.createCommentVNode("",!0)],64))],6)):e.createCommentVNode("",!0)],6)}const Je=S(Ba,[["render",Fa],["__scopeId","data-v-543e7817"]]),Pa="0.5.49";exports.AIAvatar=H;exports.AVATAR_COLORS=ee;exports.ActionResult=xe;exports.ApprovalCard=We;exports.ArtifactFormResponse=Oe;exports.ArtifactInfoCard=Le;exports.ArtifactRenderer=Ie;exports.ArtifactTicket=De;exports.AttachmentPreview=Re;exports.Bubble=Fe;exports.Composer=qe;exports.DEFAULT_BASE_URL=be;exports.DEFAULT_LANGUAGE=G;exports.Feedback=Ye;exports.FormCard=Ge;exports.Header=Me;exports.HumanAvatar=ae;exports.Launcher=Ae;exports.MEDIA_RECORDER_SUPPORTED=ie;exports.MessageList=Ue;exports.Messenger=Je;exports.MoreMenu=Xe;exports.Onboarding=Te;exports.SCREEN_CAPTURE_SUPPORTED=J;exports.SUPPORTED_LANGUAGES=Ee;exports.SuggestionChips=Ke;exports.TeamAvatars=Ve;exports.Typing=Pe;exports.VERSION=Pa;exports.avatarColor=re;exports.avatarInitials=oe;exports.captureScreenshotFile=He;exports.colors=x;exports.createStore=ke;exports.createTranslator=T;exports.createTransport=ve;exports.dateLocale=z;exports.default=Je;exports.formatTime=ne;exports.guessAttachmentKind=Uo;exports.pickRecorderMime=je;exports.renderInlineMarkdown=Ne;exports.renderMarkdown=Se;exports.resolveLanguage=se;exports.startScreenRecording=$e;exports.tokensCss=we;exports.uuid=ue;exports.v4=ue;