@_solaris/messenger-widget 0.3.12 → 0.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/messenger.cjs +25 -25
- package/dist/messenger.embed.js +32 -32
- package/dist/messenger.js +1506 -1382
- package/dist/style.css +1 -1
- package/dist/types/core/store.d.ts +1 -0
- package/dist/types/mixins/notifications.d.ts +1 -3
- package/dist/types/mixins/revealPacing.d.ts +8 -2
- package/package.json +1 -1
package/dist/messenger.cjs
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),Pe=["connected","message","message_stream","conversation_updated","config_updated","action_status"],ne="/client",je=5*60*1e3,Ue=10*60*1e3,ze=5*60*1e3;function ce(t){const n={baseUrl:He(t.baseUrl||""),widgetId:t.widgetId||"",userId:t.userId||"",userHash:t.userHash||"",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||!n.userId||!n.userHash)throw new Error("[transport] baseUrl, widgetId, userId, userHash are all required");function r(d,u){return n.listeners.has(d)||n.listeners.set(d,new Set),n.listeners.get(d).add(u),()=>n.listeners.get(d).delete(u)}function a(d,u){const f=n.listeners.get(d);f&&f.forEach(g=>{try{g(u)}catch(b){console.error("[transport] listener",d,b)}})}function s(d){n.connection!==d&&(n.connection=d,a("connection",d))}function o(){return{"X-User-Id":n.userId,"X-User-Hash":n.userHash,"X-Widget-Id":n.widgetId}}async function i(d,u,f){const g=await fetch(`${n.baseUrl}${ne}${u}`,{method:d,headers:{"Content-Type":"application/json",...o()},body:f!==void 0?JSON.stringify(f):void 0});if(!g.ok){const b=await l(g),C=new Error(`HTTP ${g.status} ${d} ${u} :: ${(b==null?void 0:b.error)||g.statusText}`);throw C.status=g.status,C.body=b,C}return g.status===204?null:g.json()}async function l(d){try{return await d.json()}catch{return null}}async function p(){const[d,u]=await Promise.all([fetch(`${n.baseUrl}/widgets/${encodeURIComponent(n.widgetId)}/config`).then(async f=>{if(!f.ok){const g=await l(f);throw new Error(`HTTP ${f.status} GET /widgets/:id/config :: ${(g==null?void 0:g.error)||f.statusText}`)}return f.json()}),i("GET","/customers/me")]);return{config:d,customer:(u==null?void 0:u.customer)??null}}async function v(){const d=await i("GET","/customers/me");return(d==null?void 0:d.customer)??null}async function y(d){const u=await i("PATCH","/customers/me",d);return(u==null?void 0:u.customer)??null}async function E(){const d=await i("GET","/conversations");return(d==null?void 0:d.conversations)??[]}async function S(d={}){return(await i("POST","/conversations",d)).conversation}async function k(d){return(await i("GET",`/conversations/${encodeURIComponent(d)}`)).conversation}async function x(d,u){return(await i("PATCH",`/conversations/${encodeURIComponent(d)}`,u)).conversation}async function w(d,u){return i("PATCH",`/conversations/${encodeURIComponent(d)}/read`,{message_id:u})}async function M(d,u={}){const f=new URLSearchParams;u.before&&f.set("before",u.before),u.since&&f.set("since",u.since),u.limit&&f.set("limit",String(u.limit));const g=f.toString()?`?${f.toString()}`:"";return i("GET",`/conversations/${encodeURIComponent(d)}/messages${g}`)}async function V(d,u){I();const f={client_msg_id:u.client_msg_id,type:"content",text_md:u.text_md,author:{id:n.userId,type:"user"},created_at:u.created_at||new Date().toISOString()};return Array.isArray(u.attachments)&&u.attachments.length&&(f.payload={type:"content",attachments:u.attachments}),u.metadata&&typeof u.metadata=="object"&&(f.metadata=u.metadata),i("POST",`/conversations/${encodeURIComponent(d)}/messages`,f)}async function T(d,u,f){return I(),i("POST",`/messages/${encodeURIComponent(d)}/callbacks/${encodeURIComponent(u)}`,f?{inputs:f}:{})}async function D(d){const u=d.name||"attachment",f=d.type||"application/octet-stream",g=d.size||0,b=await i("POST","/attachments",{mime_type:f,size_bytes:g,name:u}),C=await fetch(b.upload_url,{method:"PUT",headers:{"Content-Type":f},body:d});if(!C.ok)throw new Error(`HTTP ${C.status} PUT signed upload`);return{type:qe(f),path:b.path,mime_type:f,size_bytes:g}}async function $(d){return i("GET",`/attachments/sign?path=${encodeURIComponent(d)}`)}function F(){const d=new URLSearchParams({userId:n.userId,userHash:n.userHash,widgetId:n.widgetId}).toString();return`${n.baseUrl}${ne}/stream?${d}`}function O(){if(!n.eventSource&&!(typeof document<"u"&&document.hidden))try{const d=new EventSource(F());for(const u of Pe)d.addEventListener(u,f=>P(u,f.data));d.addEventListener("error",()=>a("error",new Error("SSE error"))),n.eventSource=d,s("open")}catch(d){console.error("[transport] SSE open failed",d),a("error",d)}}function P(d,u){try{const f=JSON.parse(u),g=f&&typeof f=="object"&&"data"in f?f.data:f;a(d,g)}catch(f){console.error("[transport] bad SSE payload",d,f)}}function L(){n.eventSource&&(n.eventSource.close(),n.eventSource=null),n.connection!=="paused"&&s("idle")}function I(){clearTimeout(n.burstTimer),O(),n.panelOpen||(n.burstTimer=setTimeout(()=>{n.panelOpen||L()},Ue))}function H(d){n.panelOpen=!!d,n.panelOpen?(clearTimeout(n.burstTimer),O()):I()}async function X(){try{const d=await E(),u=d.reduce((g,b)=>{const C=b==null?void 0:b.last_message_at;return C&&(!g||C>g)?C:g},null);u&&(!n.lastActivityAt||u>n.lastActivityAt)&&(n.lastActivityAt=u,a("activity",{conversations:d,latestAt:u}),I())}catch(d){console.error("[transport] poll failed",d)}}function q(){c(),!(typeof document<"u"&&document.hidden)&&(n.pollTimer=setInterval(X,je))}function c(){n.pollTimer&&(clearInterval(n.pollTimer),n.pollTimer=null)}function m(){if(document.hidden)clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=setTimeout(()=>{n.hiddenGraceTimer=null,document.hidden&&(c(),L(),s("paused"))},ze);else{if(n.hiddenGraceTimer){clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=null;return}s("idle"),q(),n.panelOpen&&O()}}async function h(){if(n.started)return n.lastBootstrap;n.started=!0;const d=await p();n.lastBootstrap=d;try{const u=await E();n.lastActivityAt=u.reduce((f,g)=>{const b=g==null?void 0:g.last_message_at;return b&&(!f||b>f)?b:f},null)}catch(u){console.error("[transport] initial /conversations failed",u)}return typeof document<"u"&&(n.visibilityHandler=m,document.addEventListener("visibilitychange",n.visibilityHandler)),q(),d}function _(){c(),clearTimeout(n.burstTimer),clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=null,L(),n.visibilityHandler&&(document.removeEventListener("visibilitychange",n.visibilityHandler),n.visibilityHandler=null),n.started=!1}return{on:r,start:h,stop:_,setPanelOpen:H,bootstrap:p,getCustomer:v,patchCustomer:y,listConversations:E,createConversation:S,getConversation:k,patchConversation:x,markConversationRead:w,listMessages:M,postMessage:V,postCallback:T,uploadAttachment:D,signAttachment:$,get connection(){return n.connection}}}function He(t){return t.endsWith("/")?t.slice(0,-1):t}function qe(t){return t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":"file"}function J(){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 de(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",c=>{n.connection=c})),r.push(t.on("message",c=>{const m=c==null?void 0:c.conversation_id,h=c==null?void 0:c.message;!m||!(h!=null&&h.id)||(O(m,h),h.client_msg_id&&delete n.streamingByMsgId[h.client_msg_id],I(m,h.created_at))})),r.push(t.on("message_stream",c=>{const m=c==null?void 0:c.message_id,h=c==null?void 0:c.token;!m||typeof h!="string"||(n.streamingByMsgId[m]=(n.streamingByMsgId[m]||"")+h)})),r.push(t.on("conversation_updated",c=>{const m=c==null?void 0:c.conversation_id,h=c==null?void 0:c.changes;if(!m||!h)return;const _=n.conversations.findIndex(d=>d.id===m);_!==-1&&(n.conversations[_]={...n.conversations[_],...h})})),r.push(t.on("config_updated",c=>{c!=null&&c.config&&(n.config=c.config)})),r.push(t.on("action_status",c=>{const m=c==null?void 0:c.conversation_id,h=c==null?void 0:c.action_id,_=c==null?void 0:c.action_name;if(!m||!h)return;const d=n.runningActionsByConv[m]||{};c.state==="running"?(d[h]=_||h,n.runningActionsByConv[m]={...d}):c.state==="done"&&(delete d[h],n.runningActionsByConv[m]={...d})})),r.push(t.on("activity",c=>{Array.isArray(c==null?void 0:c.conversations)&&(n.conversations=c.conversations)}));async function a(){try{const c=new Promise((h,_)=>setTimeout(()=>_(new Error("bootstrap timeout (15s) — check baseUrl, CORS, and network")),15e3)),m=await Promise.race([t.start(),c]);n.config=m.config,n.customer=m.customer,n.conversations=await Promise.race([t.listConversations(),c]),n.ready=!0}catch(c){console.error("[store] start failed",c),n.error=(c==null?void 0:c.message)||String(c)}}function s(){for(const c of r)try{c()}catch{}t.stop()}async function o(c){const m=X(c);if(!m)return n.customer;try{const h=await t.patchCustomer(m);h&&(n.customer=h)}catch(h){console.error("[store] applyCustomer failed",h)}return n.customer}async function i(c={}){const m=await t.createConversation(c),h=n.conversations.findIndex(_=>_.id===m.id);return h===-1?n.conversations=[m,...n.conversations]:n.conversations[h]=m,m}const l=50;async function p(c){const m=n.paginationByConv[c];if(!(m!=null&&m.loaded||m!=null&&m.loading)){y(c,{nextCursor:null,loading:!0,loaded:!1});try{const h=await t.listMessages(c,{limit:l}),_=(h==null?void 0:h.messages)??[],d=n.messagesByConv[c]||[],u=new Set;for(const g of _)(g==null?void 0:g.id)!=null&&u.add(`id:${String(g.id)}`),g!=null&&g.client_msg_id&&u.add(`c:${g.client_msg_id}`);const f=d.filter(g=>!((g==null?void 0:g.id)!=null&&u.has(`id:${String(g.id)}`)||g!=null&&g.client_msg_id&&u.has(`c:${g.client_msg_id}`)));n.messagesByConv[c]=[..._,...f].sort(H),y(c,{nextCursor:(h==null?void 0:h.next_cursor)??null,loading:!1,loaded:!0})}catch(h){console.error("[store] openConversation failed",h),y(c,{nextCursor:null,loading:!1,loaded:!1})}}}async function v(c){var d;const m=n.paginationByConv[c];if(!m||m.loading||!m.nextCursor)return;const _=(d=(n.messagesByConv[c]||[]).find(u=>u==null?void 0:u.created_at))==null?void 0:d.created_at;if(_){y(c,{...m,loading:!0});try{const u=await t.listMessages(c,{before:_,limit:l}),f=(u==null?void 0:u.messages)??[],g=n.messagesByConv[c]||[],b=new Set;for(const B of g)(B==null?void 0:B.id)!=null&&b.add(`id:${String(B.id)}`),B!=null&&B.client_msg_id&&b.add(`c:${B.client_msg_id}`);const C=f.filter(B=>!((B==null?void 0:B.id)!=null&&b.has(`id:${String(B.id)}`)||B!=null&&B.client_msg_id&&b.has(`c:${B.client_msg_id}`)));n.messagesByConv[c]=[...C,...g],y(c,{nextCursor:(u==null?void 0:u.next_cursor)??null,loading:!1,loaded:!0})}catch(u){console.error("[store] loadMore failed",u),y(c,{...m,loading:!1})}}}function y(c,m){n.paginationByConv={...n.paginationByConv,[c]:m}}async function E(c,m){const h=await t.patchConversation(c,m),_=n.conversations.findIndex(d=>d.id===c);_!==-1&&(n.conversations[_]=h)}async function S(c,m){if(!(!c||m==null))try{const h=await t.markConversationRead(c,m),_=(h==null?void 0:h.last_read_message_id)??m,d=n.conversations.findIndex(u=>(u==null?void 0:u.id)===c);d!==-1&&(n.conversations[d]={...n.conversations[d],last_read_message_id:_})}catch(h){console.error("[store] markConversationRead failed",h)}}async function k(c,m,{attachments:h,metadata:_}={}){var C;const d=(m||"").trim(),u=Array.isArray(h)&&h.length>0;if(!c||!d&&!u)return;const f=J(),g=q(c),b={id:f,client_msg_id:f,conversation_id:c,type:"content",text_md:d,author:{type:"user",id:((C=n.customer)==null?void 0:C.external_id)||null},created_at:g,_pending:!0,...u?{payload:{type:"content",attachments:h}}:{},..._&&typeof _=="object"?{metadata:_}:{}};O(c,b);try{await t.postMessage(c,{client_msg_id:f,text_md:d,created_at:g,...u?{attachments:h}:{},..._&&typeof _=="object"?{metadata:_}:{}})}catch(B){console.error("[store] send failed",B),L(c,f,{_failed:!0,_pending:!1})}}async function x(c,m,h){c!=null&&(n.awaitingCallback[c]=!0);try{await t.postCallback(c,m,h)}catch(_){console.error("[store] callback failed",_),c!=null&&delete n.awaitingCallback[c]}}const w=new Map;async function M(c){if(!c)return null;const m=w.get(c);if(m!=null&&m.url){const h=m.expires_at?Date.parse(m.expires_at):0;if(!h||h-Date.now()>6e4)return m.url}try{const h=await t.signAttachment(c);if(h!=null&&h.signed_url)return w.set(c,{url:h.signed_url,expires_at:h.expires_at}),h.signed_url}catch(h){console.error("[store] sign attachment failed",h)}return null}async function V(c,{rating:m,comment:h}={}){const _=n.conversations.find(f=>f.id===c),u={...(_==null?void 0:_.metadata)||{},feedback:{rating:m,comment:h||null,submitted_at:new Date().toISOString()}};await E(c,{metadata:u})}function T(c){var h,_;const m=n.messagesByConv[c]||[];for(let d=m.length-1;d>=0;d--){const u=m[d];if((u==null?void 0:u.type)==="action"&&((h=u==null?void 0:u.payload)==null?void 0:h.type)==="action"&&((_=u==null?void 0:u.payload)==null?void 0:_.state)==="pending"&&Array.isArray(u==null?void 0:u.callbacks)&&u.callbacks.length>0&&!n.awaitingCallback[u.id])return u}return null}function D(c){var h,_,d;const m=n.messagesByConv[c]||[];for(let u=m.length-1;u>=0;u--){const f=m[u];if(((h=f==null?void 0:f.author)==null?void 0:h.type)==="user"||(f==null?void 0:f.type)==="action"&&((_=f==null?void 0:f.payload)==null?void 0:_.state)==="pending")return null;const g=(d=f==null?void 0:f.metadata)==null?void 0:d.form;if(g&&Array.isArray(g.fields)&&g.fields.length>0)return{message:f,form:g}}return null}function $(c){const m=n.runningActionsByConv[c];if(!m)return null;const h=Object.keys(m);if(h.length===0)return null;const _=h[0];return{id:_,payload:{name:m[_]}}}function F(c){var h,_,d,u;const m=n.messagesByConv[c]||[];for(let f=m.length-1;f>=0;f--){const g=m[f];if(((h=g==null?void 0:g.author)==null?void 0:h.type)==="user")return[];if((g==null?void 0:g.type)==="action"&&((_=g==null?void 0:g.payload)==null?void 0:_.state)==="pending")return[];if(((d=g==null?void 0:g.author)==null?void 0:d.type)!=="agent_ia")continue;const b=(u=g==null?void 0:g.metadata)==null?void 0:u.suggested_replies;return Array.isArray(b)&&b.length?b.map(C=>{if(typeof C=="string"){const B=C.trim();return B?{label:B,kind:null}:null}if(C&&typeof C=="object"&&typeof C.label=="string"){const B=C.label.trim();if(!B)return null;const Fe=C.kind==="cta"||C.kind==="choice"||C.kind==="followup"?C.kind:null;return{label:B,kind:Fe}}return null}).filter(Boolean).slice(0,4):[]}return[]}function O(c,m){var u;const h=n.messagesByConv[c]||[];let _=-1;m!=null&&m.client_msg_id&&(_=h.findIndex(f=>(f==null?void 0:f.client_msg_id)&&f.client_msg_id===m.client_msg_id)),_===-1&&(m==null?void 0:m.id)!==void 0&&(m==null?void 0:m.id)!==null&&(_=h.findIndex(f=>P(f==null?void 0:f.id,m.id)));let d;_===-1?d=[...h,m].sort(H):(d=h.slice(),d[_]={...h[_],...m,_pending:!1,_failed:!1}),n.messagesByConv[c]=d,(m==null?void 0:m.type)==="action"&&((u=m==null?void 0:m.payload)!=null&&u.state)&&m.payload.state!=="pending"&&(m==null?void 0:m.id)!=null&&n.awaitingCallback[m.id]&&delete n.awaitingCallback[m.id]}function P(c,m){return c===m?!0:c==null||m==null?!1:String(c)===String(m)}function L(c,m,h){const _=n.messagesByConv[c];if(!_)return;const d=_.findIndex(f=>f.id===m);if(d===-1)return;const u=_.slice();u[d]={..._[d],...h},n.messagesByConv[c]=u}function I(c,m){const h=n.conversations.findIndex(d=>d.id===c);if(h===-1)return;const _=n.conversations[h];if(m&&(!_.last_message_at||m>_.last_message_at)){const d=n.conversations.slice();d[h]={..._,last_message_at:m},d.sort((u,f)=>(f.last_message_at||"").localeCompare(u.last_message_at||"")),n.conversations=d}}function H(c,m){return(c.created_at||"").localeCompare(m.created_at||"")}function X(c){if(!c||typeof c!="object")return null;const m={},h={};for(const[_,d]of Object.entries(c))d!==void 0&&(_==="name"||_==="email"?d!=null&&String(d).trim()!==""&&(m[_]=d):(_==="values"||_==="metadata")&&d&&typeof d=="object"?Object.assign(h,d):h[_]=d);return Object.keys(h).length&&(m.values=h),Object.keys(m).length?m:null}function q(c){const m=n.messagesByConv[c]||[];let h="";for(const u of m)u!=null&&u.created_at&&u.created_at>h&&(h=u.created_at);const _=new Date().toISOString();return!h||_>h?_:new Date(Date.parse(h)+1).toISOString()}return{state:n,start:a,destroy:s,applyCustomer:o,createConversation:i,openConversation:p,loadMore:v,patchConversation:E,markConversationRead:S,send:k,clickCallback:x,signAttachment:M,submitFeedback:V,getPendingApproval:T,getActionInFlight:$,getLatestSuggestions:F,getLatestForm:D,setPanelOpen:t.setPanelOpen}}const A={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"},W=["#5B5FEF","#7C3AED","#DB2777","#0891B2","#D97706","#059669"];function Q(t=""){return t?W[t.charCodeAt(0)%W.length]:W[0]}function Z(t=""){return t.split(" ").map(n=>n[0]||"").join("").toUpperCase().slice(0,2)}function ee(t=new Date){return t.toLocaleTimeString("fr-FR",{hour:"2-digit",minute:"2-digit"})}const ue=`
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),je=["connected","message","message_stream","conversation_updated","config_updated","action_status"],re="/client",ze=5*60*1e3,Ue=10*60*1e3,He=5*60*1e3;function de(t){const n={baseUrl:qe(t.baseUrl||""),widgetId:t.widgetId||"",userId:t.userId||"",userHash:t.userHash||"",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||!n.userId||!n.userHash)throw new Error("[transport] baseUrl, widgetId, userId, userHash are all required");function r(c,m){return n.listeners.has(c)||n.listeners.set(c,new Set),n.listeners.get(c).add(m),()=>n.listeners.get(c).delete(m)}function o(c,m){const h=n.listeners.get(c);h&&h.forEach(_=>{try{_(m)}catch(g){console.error("[transport] listener",c,g)}})}function a(c){n.connection!==c&&(n.connection=c,o("connection",c))}function s(){return{"X-User-Id":n.userId,"X-User-Hash":n.userHash,"X-Widget-Id":n.widgetId}}async function i(c,m,h){const _=await fetch(`${n.baseUrl}${re}${m}`,{method:c,headers:{"Content-Type":"application/json",...s()},body:h!==void 0?JSON.stringify(h):void 0});if(!_.ok){const g=await l(_),w=new Error(`HTTP ${_.status} ${c} ${m} :: ${(g==null?void 0:g.error)||_.statusText}`);throw w.status=_.status,w.body=g,w}return _.status===204?null:_.json()}async function l(c){try{return await c.json()}catch{return null}}async function p(){const[c,m]=await Promise.all([fetch(`${n.baseUrl}/widgets/${encodeURIComponent(n.widgetId)}/config`).then(async h=>{if(!h.ok){const _=await l(h);throw new Error(`HTTP ${h.status} GET /widgets/:id/config :: ${(_==null?void 0:_.error)||h.statusText}`)}return h.json()}),i("GET","/customers/me")]);return{config:c,customer:(m==null?void 0:m.customer)??null}}async function y(){const c=await i("GET","/customers/me");return(c==null?void 0:c.customer)??null}async function v(c){const m=await i("PATCH","/customers/me",c);return(m==null?void 0:m.customer)??null}async function E(){const c=await i("GET","/conversations");return(c==null?void 0:c.conversations)??[]}async function N(c={}){return(await i("POST","/conversations",c)).conversation}async function k(c){return(await i("GET",`/conversations/${encodeURIComponent(c)}`)).conversation}async function x(c,m){return(await i("PATCH",`/conversations/${encodeURIComponent(c)}`,m)).conversation}async function b(c,m){return i("PATCH",`/conversations/${encodeURIComponent(c)}/read`,{message_id:m})}async function M(c,m={}){const h=new URLSearchParams;m.before&&h.set("before",m.before),m.since&&h.set("since",m.since),m.limit&&h.set("limit",String(m.limit));const _=h.toString()?`?${h.toString()}`:"";return i("GET",`/conversations/${encodeURIComponent(c)}/messages${_}`)}async function S(c,m){O();const h={client_msg_id:m.client_msg_id,type:"content",text_md:m.text_md,author:{id:n.userId,type:"user"},created_at:m.created_at||new Date().toISOString()};return Array.isArray(m.attachments)&&m.attachments.length&&(h.payload={type:"content",attachments:m.attachments}),m.metadata&&typeof m.metadata=="object"&&(h.metadata=m.metadata),i("POST",`/conversations/${encodeURIComponent(c)}/messages`,h)}async function T(c,m,h){return O(),i("POST",`/messages/${encodeURIComponent(c)}/callbacks/${encodeURIComponent(m)}`,h?{inputs:h}:{})}async function I(c){const m=c.name||"attachment",h=c.type||"application/octet-stream",_=c.size||0,g=await i("POST","/attachments",{mime_type:h,size_bytes:_,name:m}),w=await fetch(g.upload_url,{method:"PUT",headers:{"Content-Type":h},body:c});if(!w.ok)throw new Error(`HTTP ${w.status} PUT signed upload`);return{type:Ke(h),path:g.path,mime_type:h,size_bytes:_}}async function F(c){return i("GET",`/attachments/sign?path=${encodeURIComponent(c)}`)}function P(){const c=new URLSearchParams({userId:n.userId,userHash:n.userHash,widgetId:n.widgetId}).toString();return`${n.baseUrl}${re}/stream?${c}`}function L(){if(!n.eventSource&&!(typeof document<"u"&&document.hidden))try{const c=new EventSource(P());for(const m of je)c.addEventListener(m,h=>R(m,h.data));c.addEventListener("error",()=>o("error",new Error("SSE error"))),n.eventSource=c,a("open")}catch(c){console.error("[transport] SSE open failed",c),o("error",c)}}function R(c,m){try{const h=JSON.parse(m),_=h&&typeof h=="object"&&"data"in h?h.data:h;o(c,_)}catch(h){console.error("[transport] bad SSE payload",c,h)}}function D(){n.eventSource&&(n.eventSource.close(),n.eventSource=null),n.connection!=="paused"&&a("idle")}function O(){clearTimeout(n.burstTimer),L(),n.panelOpen||(n.burstTimer=setTimeout(()=>{n.panelOpen||D()},Ue))}function J(c){n.panelOpen=!!c,n.panelOpen?(clearTimeout(n.burstTimer),L()):O()}async function K(){try{const c=await E(),m=c.reduce((_,g)=>{const w=g==null?void 0:g.last_message_at;return w&&(!_||w>_)?w:_},null);m&&(!n.lastActivityAt||m>n.lastActivityAt)&&(n.lastActivityAt=m,o("activity",{conversations:c,latestAt:m}),O())}catch(c){console.error("[transport] poll failed",c)}}function W(){z(),!(typeof document<"u"&&document.hidden)&&(n.pollTimer=setInterval(K,ze))}function z(){n.pollTimer&&(clearInterval(n.pollTimer),n.pollTimer=null)}function d(){if(document.hidden)clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=setTimeout(()=>{n.hiddenGraceTimer=null,document.hidden&&(z(),D(),a("paused"))},He);else{if(n.hiddenGraceTimer){clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=null;return}a("idle"),W(),n.panelOpen&&L()}}async function u(){if(n.started)return n.lastBootstrap;n.started=!0;const c=await p();n.lastBootstrap=c;try{const m=await E();n.lastActivityAt=m.reduce((h,_)=>{const g=_==null?void 0:_.last_message_at;return g&&(!h||g>h)?g:h},null)}catch(m){console.error("[transport] initial /conversations failed",m)}return typeof document<"u"&&(n.visibilityHandler=d,document.addEventListener("visibilitychange",n.visibilityHandler)),W(),c}function f(){z(),clearTimeout(n.burstTimer),clearTimeout(n.hiddenGraceTimer),n.hiddenGraceTimer=null,D(),n.visibilityHandler&&(document.removeEventListener("visibilitychange",n.visibilityHandler),n.visibilityHandler=null),n.started=!1}return{on:r,start:u,stop:f,setPanelOpen:J,bootstrap:p,getCustomer:y,patchCustomer:v,listConversations:E,createConversation:N,getConversation:k,patchConversation:x,markConversationRead:b,listMessages:M,postMessage:S,postCallback:T,uploadAttachment:I,signAttachment:F,get connection(){return n.connection}}}function qe(t){return t.endsWith("/")?t.slice(0,-1):t}function Ke(t){return t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":"file"}function Q(){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 ue(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,f=d==null?void 0:d.message;!u||!(f!=null&&f.id)||(R(u,f),f.client_msg_id&&delete n.streamingByMsgId[f.client_msg_id],J(u,f.created_at))})),r.push(t.on("message_stream",d=>{const u=d==null?void 0:d.message_id,f=d==null?void 0:d.token;!u||typeof f!="string"||(n.streamingByMsgId[u]=(n.streamingByMsgId[u]||"")+f)})),r.push(t.on("conversation_updated",d=>{const u=d==null?void 0:d.conversation_id,f=d==null?void 0:d.changes;if(!u||!f)return;const c=n.conversations.findIndex(m=>m.id===u);c!==-1&&(n.conversations[c]={...n.conversations[c],...f})})),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,f=d==null?void 0:d.action_id,c=d==null?void 0:d.action_name;if(!u||!f)return;const m=n.runningActionsByConv[u]||{};d.state==="running"?(m[f]=c||f,n.runningActionsByConv[u]={...m}):d.state==="done"&&(delete m[f],n.runningActionsByConv[u]={...m})})),r.push(t.on("activity",d=>{Array.isArray(d==null?void 0:d.conversations)&&(n.conversations=d.conversations)}));async function o(){try{const d=new Promise((f,c)=>setTimeout(()=>c(new Error("bootstrap timeout (15s) — check baseUrl, CORS, and network")),15e3)),u=await Promise.race([t.start(),d]);n.config=u.config,n.customer=u.customer,n.conversations=await Promise.race([t.listConversations(),d]),n.ready=!0}catch(d){console.error("[store] start failed",d),n.error=(d==null?void 0:d.message)||String(d)}}function a(){for(const d of r)try{d()}catch{}t.stop()}async function s(d){const u=W(d);if(!u)return n.customer;try{const f=await t.patchCustomer(u);f&&(n.customer=f)}catch(f){console.error("[store] applyCustomer failed",f)}return n.customer}async function i(d={}){const u=await t.createConversation(d),f=n.conversations.findIndex(c=>c.id===u.id);return f===-1?n.conversations=[u,...n.conversations]:n.conversations[f]=u,u}const l=50;async function p(d){const u=n.paginationByConv[d];if(!(u!=null&&u.loaded||u!=null&&u.loading)){v(d,{nextCursor:null,loading:!0,loaded:!1});try{const f=await t.listMessages(d,{limit:l}),c=(f==null?void 0:f.messages)??[],m=n.messagesByConv[d]||[],h=new Set;for(const g of c)(g==null?void 0:g.id)!=null&&h.add(`id:${String(g.id)}`),g!=null&&g.client_msg_id&&h.add(`c:${g.client_msg_id}`);const _=m.filter(g=>!((g==null?void 0:g.id)!=null&&h.has(`id:${String(g.id)}`)||g!=null&&g.client_msg_id&&h.has(`c:${g.client_msg_id}`)));n.messagesByConv[d]=[...c,..._].sort(K),v(d,{nextCursor:(f==null?void 0:f.next_cursor)??null,loading:!1,loaded:!0})}catch(f){console.error("[store] openConversation failed",f),v(d,{nextCursor:null,loading:!1,loaded:!1})}}}async function y(d){var m;const u=n.paginationByConv[d];if(!u||u.loading||!u.nextCursor)return;const c=(m=(n.messagesByConv[d]||[]).find(h=>h==null?void 0:h.created_at))==null?void 0:m.created_at;if(c){v(d,{...u,loading:!0});try{const h=await t.listMessages(d,{before:c,limit:l}),_=(h==null?void 0:h.messages)??[],g=n.messagesByConv[d]||[],w=new Set;for(const C of g)(C==null?void 0:C.id)!=null&&w.add(`id:${String(C.id)}`),C!=null&&C.client_msg_id&&w.add(`c:${C.client_msg_id}`);const A=_.filter(C=>!((C==null?void 0:C.id)!=null&&w.has(`id:${String(C.id)}`)||C!=null&&C.client_msg_id&&w.has(`c:${C.client_msg_id}`)));n.messagesByConv[d]=[...A,...g],v(d,{nextCursor:(h==null?void 0:h.next_cursor)??null,loading:!1,loaded:!0})}catch(h){console.error("[store] loadMore failed",h),v(d,{...u,loading:!1})}}}function v(d,u){n.paginationByConv={...n.paginationByConv,[d]:u}}async function E(d,u){const f=await t.patchConversation(d,u),c=n.conversations.findIndex(m=>m.id===d);c!==-1&&(n.conversations[c]=f)}async function N(d){if(!d)return[];const u=n.messagesByConv[d]||[];let f="";for(const c of u)c!=null&&c.created_at&&c.created_at>f&&(f=c.created_at);try{const c=await t.listMessages(d,f?{since:f}:{}),m=(c==null?void 0:c.messages)||[];if(!m.length)return[];const h=new Set,_=new Set;for(const w of u)(w==null?void 0:w.id)!=null&&h.add(String(w.id)),w!=null&&w.client_msg_id&&_.add(w.client_msg_id);const g=[];for(const w of m){const A=(w==null?void 0:w.id)!=null&&h.has(String(w.id))||(w==null?void 0:w.client_msg_id)&&_.has(w.client_msg_id);R(d,w),A||g.push(w)}return g}catch(c){return console.error("[store] fetchSinceLast failed",c),[]}}async function k(d,u){if(!(!d||u==null))try{const f=await t.markConversationRead(d,u),c=(f==null?void 0:f.last_read_message_id)??u,m=n.conversations.findIndex(h=>(h==null?void 0:h.id)===d);m!==-1&&(n.conversations[m]={...n.conversations[m],last_read_message_id:c})}catch(f){console.error("[store] markConversationRead failed",f)}}async function x(d,u,{attachments:f,metadata:c}={}){var A;const m=(u||"").trim(),h=Array.isArray(f)&&f.length>0;if(!d||!m&&!h)return;const _=Q(),g=z(d),w={id:_,client_msg_id:_,conversation_id:d,type:"content",text_md:m,author:{type:"user",id:((A=n.customer)==null?void 0:A.external_id)||null},created_at:g,_pending:!0,...h?{payload:{type:"content",attachments:f}}:{},...c&&typeof c=="object"?{metadata:c}:{}};R(d,w);try{await t.postMessage(d,{client_msg_id:_,text_md:m,created_at:g,...h?{attachments:f}:{},...c&&typeof c=="object"?{metadata:c}:{}})}catch(C){console.error("[store] send failed",C),O(d,_,{_failed:!0,_pending:!1})}}async function b(d,u,f){d!=null&&(n.awaitingCallback[d]=!0);try{await t.postCallback(d,u,f)}catch(c){console.error("[store] callback failed",c),d!=null&&delete n.awaitingCallback[d]}}const M=new Map;async function S(d){if(!d)return null;const u=M.get(d);if(u!=null&&u.url){const f=u.expires_at?Date.parse(u.expires_at):0;if(!f||f-Date.now()>6e4)return u.url}try{const f=await t.signAttachment(d);if(f!=null&&f.signed_url)return M.set(d,{url:f.signed_url,expires_at:f.expires_at}),f.signed_url}catch(f){console.error("[store] sign attachment failed",f)}return null}async function T(d,{rating:u,comment:f}={}){const c=n.conversations.find(_=>_.id===d),h={...(c==null?void 0:c.metadata)||{},feedback:{rating:u,comment:f||null,submitted_at:new Date().toISOString()}};await E(d,{metadata:h})}function I(d){var f,c;const u=n.messagesByConv[d]||[];for(let m=u.length-1;m>=0;m--){const h=u[m];if((h==null?void 0:h.type)==="action"&&((f=h==null?void 0:h.payload)==null?void 0:f.type)==="action"&&((c=h==null?void 0:h.payload)==null?void 0:c.state)==="pending"&&Array.isArray(h==null?void 0:h.callbacks)&&h.callbacks.length>0&&!n.awaitingCallback[h.id])return h}return null}function F(d){var f,c,m;const u=n.messagesByConv[d]||[];for(let h=u.length-1;h>=0;h--){const _=u[h];if(((f=_==null?void 0:_.author)==null?void 0:f.type)==="user"||(_==null?void 0:_.type)==="action"&&((c=_==null?void 0:_.payload)==null?void 0:c.state)==="pending")return null;const g=(m=_==null?void 0:_.metadata)==null?void 0:m.form;if(g&&Array.isArray(g.fields)&&g.fields.length>0)return{message:_,form:g}}return null}function P(d){const u=n.runningActionsByConv[d];if(!u)return null;const f=Object.keys(u);if(f.length===0)return null;const c=f[0];return{id:c,payload:{name:u[c]}}}function L(d){var f,c,m,h;const u=n.messagesByConv[d]||[];for(let _=u.length-1;_>=0;_--){const g=u[_];if(((f=g==null?void 0:g.author)==null?void 0:f.type)==="user")return[];if((g==null?void 0:g.type)==="action"&&((c=g==null?void 0:g.payload)==null?void 0:c.state)==="pending")return[];if(((m=g==null?void 0:g.author)==null?void 0:m.type)!=="agent_ia")continue;const w=(h=g==null?void 0:g.metadata)==null?void 0:h.suggested_replies;return Array.isArray(w)&&w.length?w.map(A=>{if(typeof A=="string"){const C=A.trim();return C?{label:C,kind:null}:null}if(A&&typeof A=="object"&&typeof A.label=="string"){const C=A.label.trim();if(!C)return null;const Pe=A.kind==="cta"||A.kind==="choice"||A.kind==="followup"?A.kind:null;return{label:C,kind:Pe}}return null}).filter(Boolean).slice(0,4):[]}return[]}function R(d,u){var h;const f=n.messagesByConv[d]||[];let c=-1;u!=null&&u.client_msg_id&&(c=f.findIndex(_=>(_==null?void 0:_.client_msg_id)&&_.client_msg_id===u.client_msg_id)),c===-1&&(u==null?void 0:u.id)!==void 0&&(u==null?void 0:u.id)!==null&&(c=f.findIndex(_=>D(_==null?void 0:_.id,u.id)));let m;c===-1?m=[...f,u].sort(K):(m=f.slice(),m[c]={...f[c],...u,_pending:!1,_failed:!1}),n.messagesByConv[d]=m,(u==null?void 0:u.type)==="action"&&((h=u==null?void 0:u.payload)!=null&&h.state)&&u.payload.state!=="pending"&&(u==null?void 0:u.id)!=null&&n.awaitingCallback[u.id]&&delete n.awaitingCallback[u.id]}function D(d,u){return d===u?!0:d==null||u==null?!1:String(d)===String(u)}function O(d,u,f){const c=n.messagesByConv[d];if(!c)return;const m=c.findIndex(_=>_.id===u);if(m===-1)return;const h=c.slice();h[m]={...c[m],...f},n.messagesByConv[d]=h}function J(d,u){const f=n.conversations.findIndex(m=>m.id===d);if(f===-1)return;const c=n.conversations[f];if(u&&(!c.last_message_at||u>c.last_message_at)){const m=n.conversations.slice();m[f]={...c,last_message_at:u},m.sort((h,_)=>(_.last_message_at||"").localeCompare(h.last_message_at||"")),n.conversations=m}}function K(d,u){return(d.created_at||"").localeCompare(u.created_at||"")}function W(d){if(!d||typeof d!="object")return null;const u={},f={};for(const[c,m]of Object.entries(d))m!==void 0&&(c==="name"||c==="email"?m!=null&&String(m).trim()!==""&&(u[c]=m):(c==="values"||c==="metadata")&&m&&typeof m=="object"?Object.assign(f,m):f[c]=m);return Object.keys(f).length&&(u.values=f),Object.keys(u).length?u:null}function z(d){const u=n.messagesByConv[d]||[];let f="";for(const h of u)h!=null&&h.created_at&&h.created_at>f&&(f=h.created_at);const c=new Date().toISOString();return!f||c>f?c:new Date(Date.parse(f)+1).toISOString()}return{state:n,start:o,destroy:a,applyCustomer:s,createConversation:i,openConversation:p,loadMore:y,fetchSinceLast:N,patchConversation:E,markConversationRead:k,send:x,clickCallback:b,signAttachment:S,submitFeedback:T,getPendingApproval:I,getActionInFlight:P,getLatestSuggestions:L,getLatestForm:F,setPanelOpen:t.setPanelOpen}}const V={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"},Y=["#5B5FEF","#7C3AED","#DB2777","#0891B2","#D97706","#059669"];function Z(t=""){return t?Y[t.charCodeAt(0)%Y.length]:Y[0]}function ee(t=""){return t.split(" ").map(n=>n[0]||"").join("").toUpperCase().slice(0,2)}function te(t=new Date){return t.toLocaleTimeString("fr-FR",{hour:"2-digit",minute:"2-digit"})}const me=`
|
|
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 {
|
|
5
5
|
--wm-f: 'Geist', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
6
6
|
--wm-fm: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
7
|
-
--wm-w: ${
|
|
8
|
-
--wm-g50: ${
|
|
9
|
-
--wm-g100: ${
|
|
10
|
-
--wm-g150: ${
|
|
11
|
-
--wm-g200: ${
|
|
12
|
-
--wm-g300: ${
|
|
13
|
-
--wm-g400: ${
|
|
14
|
-
--wm-g500: ${
|
|
15
|
-
--wm-g700: ${
|
|
16
|
-
--wm-g900: ${
|
|
17
|
-
--wm-a: ${
|
|
18
|
-
--wm-al: ${
|
|
19
|
-
--wm-green: ${
|
|
20
|
-
--wm-red: ${
|
|
21
|
-
--wm-redBg: ${
|
|
7
|
+
--wm-w: ${V.w};
|
|
8
|
+
--wm-g50: ${V.g50};
|
|
9
|
+
--wm-g100: ${V.g100};
|
|
10
|
+
--wm-g150: ${V.g150};
|
|
11
|
+
--wm-g200: ${V.g200};
|
|
12
|
+
--wm-g300: ${V.g300};
|
|
13
|
+
--wm-g400: ${V.g400};
|
|
14
|
+
--wm-g500: ${V.g500};
|
|
15
|
+
--wm-g700: ${V.g700};
|
|
16
|
+
--wm-g900: ${V.g900};
|
|
17
|
+
--wm-a: ${V.accent};
|
|
18
|
+
--wm-al: ${V.accentLight};
|
|
19
|
+
--wm-green: ${V.green};
|
|
20
|
+
--wm-red: ${V.red};
|
|
21
|
+
--wm-redBg: ${V.redBg};
|
|
22
22
|
--wm-sh1: 0 1px 3px rgba(0,0,0,.06);
|
|
23
23
|
--wm-sh2: 0 4px 24px rgba(0,0,0,.09), 0 1px 4px rgba(0,0,0,.05);
|
|
24
24
|
--wm-shPanel: 0 12px 40px rgba(0,0,0,.13), 0 2px 8px rgba(0,0,0,.06);
|
|
@@ -44,13 +44,13 @@
|
|
|
44
44
|
0% { transform: translateX(110%); opacity: 0; }
|
|
45
45
|
100% { transform: translateX(0); opacity: 1; }
|
|
46
46
|
}
|
|
47
|
-
`,
|
|
48
|
-
${i}`)}return
|
|
47
|
+
`,he="https://api.messenger.victorc.fr";function se(t,n){if(!Array.isArray(t==null?void 0:t.options))return n;const r=t.options.find(o=>(o==null?void 0:o.value)===n);return(r==null?void 0:r.label)||n}function fe(t,n){return Array.isArray(n)?n.map(r=>se(t,String(r))).join(", "):typeof n=="boolean"?n?"Oui":"Non":se(t,String(n))}function We(t,n){if(!t||!n)return"";const r=Array.isArray(t.fields)?t.fields:[],o=[];for(const a of r){if(!(a!=null&&a.key)||!(a!=null&&a.label))continue;const s=n[a.key];if(s==null||s==="")continue;const i=fe(a,s);i&&o.push(`${a.label} :
|
|
48
|
+
${i}`)}return o.join(`
|
|
49
49
|
|
|
50
|
-
`)}function
|
|
51
|
-
`));r.push({label:
|
|
52
|
-
`)}function Je(t,n){if(!t)return;const r=Xe(t,n||[]),a=new Blob([r],{type:"text/plain;charset=utf-8"});try{const s=URL.createObjectURL(a),o=document.createElement("a");o.href=s,o.download=`${(t.name||"conversation").replace(/[^a-z0-9-_]+/gi,"_")}.txt`,document.body.appendChild(o),o.click(),document.body.removeChild(o),setTimeout(()=>URL.revokeObjectURL(s),1e3)}catch(s){console.error("[ww-messenger] export failed",s)}}const Qe={data(){const t=typeof Notification<"u";return{notifPermission:t?Notification.permission:"denied",soundEnabled:!0,browserNotifEnabled:t&&Notification.permission==="granted",_notifUnsub:null,_audioCtx:null}},methods:{setupNotifications(){this.transport&&(this.teardownNotifications(),this._notifUnsub=this.transport.on("message",this.onIncomingNotification))},teardownNotifications(){var t,n;if(this._notifUnsub){try{this._notifUnsub()}catch{}this._notifUnsub=null}if(this._audioCtx){try{(n=(t=this._audioCtx).close)==null||n.call(t)}catch{}this._audioCtx=null}},soundStorageKey(){return`wm:notif:sound:${this.widgetId||""}:${this.userId||""}`},browserNotifStorageKey(){return`wm:notif:browser:${this.widgetId||""}:${this.userId||""}`},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()},onIncomingNotification(t){var i;if(!this.soundEnabled&&!this.browserNotifEnabled)return;const n=t==null?void 0:t.conversation_id,r=t==null?void 0:t.message;if(!n||!r||!G(r))return;const a=r!=null&&r.created_at?Date.parse(r.created_at):NaN;if(Number.isFinite(a)&&a<this.convOpenedAt-1e3)return;const s=typeof document<"u"&&document.hidden;this.isOpen&&!s&&((i=this.currentConv)==null?void 0:i.id)===n||(this.soundEnabled&&this.playNotificationSound(),this.browserNotifEnabled&&this.showBrowserNotification(n,r))},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){var i;if(typeof Notification>"u"||Notification.permission!=="granted")return;const r=this.allConversations.find(l=>l.id===t),a=(r==null?void 0:r.name)||((i=this.widget)==null?void 0:i.name)||"Nouveau message",s=typeof(n==null?void 0:n.text_md)=="string"?n.text_md.trim():"",o=s?s.slice(0,140):"Vous avez un nouveau message";try{const l=new Notification(a,{body:o,tag:`wm-${t}`,renotify:!1,silent:!0});l.onclick=()=>{try{window.focus()}catch{}this.draftConv=null,this.showOnboarding=!1,this.activeConvId=t,this.isOpen=!0,this.store&&this.store.setPanelOpen(!0);try{l.close()}catch{}}}catch(l){console.warn("[ww-messenger] notification failed",l)}}}},Ze=450,et=50,tt=900,nt=12e3,rt=300,ot={data(){return{revealedAt:{},nextRevealAt:0,revealTimers:[]}},methods:{cancelReveals(){for(const t of this.revealTimers)clearTimeout(t);this.revealTimers=[]},resetRevealQueue(){this.cancelReveals(),this.revealedAt={},this.nextRevealAt=0},scheduleReveal(t){const n=Date.now(),r=((t==null?void 0:t.text_md)||"").length,a=Math.min(nt,Math.max(tt,r*et)),o=Math.max(n+Ze,this.nextRevealAt+rt)+a;this.nextRevealAt=o;const i=Math.max(0,o-n),l=t.id,p=setTimeout(()=>{this.revealedAt={...this.revealedAt,[l]:Date.now()},this.revealTimers=this.revealTimers.filter(v=>v!==p)},i);this.revealTimers.push(p)},paceMessages(t){var a;if(!Array.isArray(t)||!t.length)return;const n=Date.now(),r={...this.revealedAt};for(const s of t){if((s==null?void 0:s.id)==null||r[s.id]!==void 0)continue;if(!G(s)){r[s.id]=n;continue}const o=s!=null&&s.created_at?Date.parse(s.created_at):NaN;if(!Number.isFinite(o)||o<this.convOpenedAt){r[s.id]=n;continue}const i=typeof(s==null?void 0:s.text_md)=="string"&&s.text_md.trim().length>0,l=Array.isArray((a=s==null?void 0:s.payload)==null?void 0:a.attachments)&&s.payload.attachments.length>0;if(!i&&!l){r[s.id]=n;continue}r[s.id]=0,this.scheduleReveal(s)}this.revealedAt=r}}},st={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)}}},at=300,it={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=lt(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)},at))))}}};function lt(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 N=(t,n)=>{const r=t.__vccOpts||t;for(const[a,s]of n)r[a]=s;return r},ct={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":Q(this.name)},initials(){return Z(this.name)}}},dt=["src","alt"];function ut(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,dt)):(e.openBlock(),e.createElementBlock("span",{key:1,style:e.normalizeStyle({fontSize:r.size*.36+"px"})},e.toDisplayString(o.initials),5))],6)}const te=N(ct,[["render",ut],["__scopeId","data-v-07246775"]]),mt=3,ht={name:"WmLauncher",components:{HumanAvatar:te},props:{unreadCount:{type:Number,default:0},peeks:{type:Array,default:()=>[]}},emits:["open","dismiss"],computed:{visiblePeeks(){return this.peeks.slice(0,mt).reverse()}}},ft={class:"wm-launcherWrap"},pt=["aria-label","onClick","onKeydown"],_t=["onClick"],gt={class:"wm-peek__avatar"},vt=["aria-label"],yt={class:"wm-peek__body"},kt={class:"wm-peek__head"},wt={class:"wm-peek__name"},bt={class:"wm-peek__text"},Et=["onClick"],Ct=["aria-label"];function Bt(t,n,r,a,s,o){const i=e.resolveComponent("HumanAvatar");return e.openBlock(),e.createElementBlock("div",ft,[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,p)=>(e.openBlock(),e.createElementBlock("div",{key:l.convId,class:"wm-peek",style:e.normalizeStyle({"--depth":o.visiblePeeks.length-1-p,zIndex:p+1}),role:"button",tabindex:"0","aria-label":`Ouvrir la conversation avec ${l.senderName||"l'agent"}`,onClick:v=>t.$emit("open",l.convId),onKeydown:[e.withKeys(e.withModifiers(v=>t.$emit("open",l.convId),["prevent"]),["enter"]),e.withKeys(e.withModifiers(v=>t.$emit("open",l.convId),["prevent"]),["space"])]},[e.createElementVNode("button",{type:"button",class:"wm-peek__close","aria-label":"Ignorer",onClick:e.withModifiers(v=>t.$emit("dismiss",l.convId),["stop"])},[...n[1]||(n[1]=[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,_t),e.createElementVNode("div",gt,[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":`${l.count} messages non lus`},e.toDisplayString(l.count>9?"9+":l.count),9,vt)):e.createCommentVNode("",!0)]),e.createElementVNode("div",yt,[e.createElementVNode("div",kt,[e.createElementVNode("span",wt,e.toDisplayString(l.senderName||"Agent"),1),n[2]||(n[2]=e.createElementVNode("span",{class:"wm-peek__action"}," vous a répondu",-1))]),e.createElementVNode("p",bt,e.toDisplayString(l.preview),1)]),e.createElementVNode("button",{type:"button",class:"wm-peek__open",onClick:e.withModifiers(v=>t.$emit("open",l.convId),["stop"])},"Ouvrir",8,Et)],44,pt))),128))],2)):e.createCommentVNode("",!0)]),_:1}),e.createElementVNode("button",{type:"button",class:"wm-launcher","aria-label":"Ouvrir le messenger",onClick:n[0]||(n[0]=l=>t.$emit("open"))},[n[3]||(n[3]=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} conversation${r.unreadCount>1?"s":""} non lue${r.unreadCount>1?"s":""}`},e.toDisplayString(r.unreadCount>9?"9+":r.unreadCount),9,Ct)):e.createCommentVNode("",!0)])])}const fe=N(ht,[["render",Bt],["__scopeId","data-v-525fd423"]]),Nt={name:"WmAIAvatar",props:{size:{type:Number,default:26},pulse:{type:Boolean,default:!1},tail:{type:Boolean,default:!1}}},St={key:0,class:"wm-aiav__pulse"},Vt=["width","height"];function At(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",St)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["wm-aiav__inner",{"wm-aiav__inner--glow":r.pulse}])},[(e.openBlock(),e.createElementBlock("svg",{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,Vt))],2)],6)}const j=N(Nt,[["render",At],["__scopeId","data-v-8c924688"]]),Mt={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":Q(t.name||"")},initialsFor(t){return Z(t.name||"")}}},Tt={key:0,class:"wm-team"},xt=["src","alt"],Ot={key:1},It={key:0,class:"wm-team__label"};function Dt(t,n,r,a,s,o){return o.visible?(e.openBlock(),e.createElementBlock("div",Tt,[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,xt)):(e.openBlock(),e.createElementBlock("span",Ot,e.toDisplayString(o.initialsFor(i)),1))],4))),128))],4),r.responseLabel?(e.openBlock(),e.createElementBlock("span",It,e.toDisplayString(r.responseLabel),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}const pe=N(Mt,[["render",Dt],["__scopeId","data-v-3659b9c1"]]),Lt={name:"WmHeader",components:{AIAvatar:j,TeamAvatars:pe},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}},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}}},Rt={class:"wm-header"},$t={key:1,style:{width:"30px",height:"30px","flex-shrink":"0"}},Ft={class:"wm-header__avatar"},Pt={class:"wm-header__main"},jt={class:"wm-header__title"},Ut={key:3,class:"wm-header__fill"},zt={class:"wm-header__actions"};function Ht(t,n,r,a,s,o){const i=e.resolveComponent("AIAvatar"),l=e.resolveComponent("TeamAvatars");return e.openBlock(),e.createElementBlock("div",Rt,[r.showBack?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-header__icon","aria-label":"Retour à l'accueil",onClick:n[0]||(n[0]=p=>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)])])):(e.openBlock(),e.createElementBlock("div",$t)),r.showIdentity?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createElementVNode("div",Ft,[e.createVNode(i,{size:30})]),e.createElementVNode("div",Pt,[e.createElementVNode("div",jt,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",Ut)),e.createElementVNode("div",zt,[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":"Plus d'options",title:"Plus d'options",onClick:n[1]||(n[1]=p=>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)])],2)):e.createCommentVNode("",!0),r.showClose?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-header__icon","aria-label":"Fermer le widget",title:"Fermer le widget",onClick:n[2]||(n[2]=p=>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)])])):e.createCommentVNode("",!0)])])}const _e=N(Lt,[["render",Ht],["__scopeId","data-v-ef4b443e"]]),se={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"},qt={name:"WmOnboarding",components:{AIAvatar:j},props:{welcomeMessage:{type:String,default:""},agentName:{type:String,default:""},quickLinks:{type:Array,default:()=>[]},openThreads:{type:Array,default:()=>[]},busy:{type:Boolean,default:!1}},emits:["start","select","resume"],data(){return{query:""}},computed:{heroTitle(){return this.welcomeMessage?this.welcomeMessage:this.agentName?`Bonjour, je suis ${this.agentName}`:"Bonjour, je suis votre assistant"},heroSub(){return`Posez-moi n'importe quelle question.
|
|
53
|
-
Je réponds en quelques secondes.`},isOddQuickLinks(){return this.quickLinks.length%2===1},quickLinksLayout(){return this.isOddQuickLinks?"wm-onb__qlist":"wm-onb__grid"},filteredThreads(){const t=this.query.trim().toLowerCase();return t?this.openThreads.filter(n=>(n.title||"").toLowerCase().includes(t)||(n.preview||"").toLowerCase().includes(t)):this.openThreads}},methods:{iconPath(t){return se[t]||se.link},formatTs(t){if(!t)return"";const n=new Date(t);if(Number.isNaN(n.getTime()))return"";const r=new Date;if(n.toDateString()===r.toDateString()){const o=String(n.getHours()).padStart(2,"0"),i=String(n.getMinutes()).padStart(2,"0");return`${o}h${i}`}if(r.getTime()-n.getTime()<7*864e5){const o=n.toLocaleDateString("fr-FR",{weekday:"short"});return o.charAt(0).toUpperCase()+o.slice(1)}return n.toLocaleDateString("fr-FR",{day:"2-digit",month:"2-digit"})}}},Kt={class:"wm-onb"},Wt={class:"wm-onb__hero"},Gt={class:"wm-onb__title"},Yt={class:"wm-onb__sub"},Xt={class:"wm-onb__cta"},Jt=["disabled"],Qt={key:0,class:"wm-onb__section"},Zt=["onClick"],en={class:"wm-onb__card-icon"},tn={width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},nn=["d"],rn={class:"wm-onb__card-body"},on={class:"wm-onb__card-title"},sn={key:0,class:"wm-onb__card-sub"},an={key:1,class:"wm-onb__section"},ln={class:"wm-onb__search"},cn={class:"wm-onb__list"},dn=["onClick"],un={key:0,class:"wm-onb__thread-dot","aria-label":"Non lu"},mn={class:"wm-onb__thread-body"},hn={class:"wm-onb__thread-title"},fn={class:"wm-onb__thread-preview"},pn={class:"wm-onb__thread-meta"},_n={key:0,class:"wm-onb__thread-time"},gn={key:0,class:"wm-onb__empty"};function vn(t,n,r,a,s,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",Kt,[e.createElementVNode("div",Wt,[e.createVNode(i,{size:56,pulse:!0}),e.createElementVNode("div",Gt,e.toDisplayString(o.heroTitle),1),e.createElementVNode("div",Yt,e.toDisplayString(o.heroSub),1)]),e.createElementVNode("div",Xt,[e.createElementVNode("button",{type:"button",class:"wm-onb__startBtn",disabled:r.busy,onClick:n[0]||(n[0]=l=>t.$emit("start"))},[n[2]||(n[2]=e.createElementVNode("span",{class:"wm-onb__startIcon"},[e.createElementVNode("svg",{width:"12",height:"12",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:"M12 5v14M5 12h14"})])],-1)),e.createElementVNode("span",null,e.toDisplayString(r.busy?"…":"Commencer une conversation"),1)],8,Jt)]),r.quickLinks.length?(e.openBlock(),e.createElementBlock("div",Qt,[n[3]||(n[3]=e.createElementVNode("div",{class:"wm-onb__section-title"},"Accès rapide",-1)),e.createElementVNode("div",{class:e.normalizeClass(o.quickLinksLayout)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.quickLinks,(l,p)=>(e.openBlock(),e.createElementBlock("button",{key:p,type:"button",class:e.normalizeClass(["wm-onb__card",{"wm-onb__card--row":o.isOddQuickLinks}]),onClick:v=>t.$emit("select",l)},[e.createElementVNode("span",en,[(e.openBlock(),e.createElementBlock("svg",tn,[e.createElementVNode("path",{d:o.iconPath(l.icon)},null,8,nn)]))]),e.createElementVNode("span",rn,[e.createElementVNode("span",on,e.toDisplayString(l.label),1),l.description?(e.openBlock(),e.createElementBlock("span",sn,e.toDisplayString(l.description),1)):e.createCommentVNode("",!0)])],10,Zt))),128))],2)])):e.createCommentVNode("",!0),r.openThreads.length?(e.openBlock(),e.createElementBlock("div",an,[n[7]||(n[7]=e.createElementVNode("div",{class:"wm-onb__section-title"},"Conversations récentes",-1)),e.createElementVNode("div",ln,[n[4]||(n[4]=e.createElementVNode("span",{class:"wm-onb__searchIcon"},[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:"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[1]||(n[1]=l=>s.query=l),type:"text",placeholder:"Rechercher dans vos messages","aria-label":"Rechercher dans vos messages"},null,512),[[e.vModelText,s.query]])]),e.createElementVNode("div",cn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.filteredThreads,l=>(e.openBlock(),e.createElementBlock("button",{key:l.id,type:"button",class:"wm-onb__thread",onClick:p=>t.$emit("resume",l)},[e.createElementVNode("span",{class:e.normalizeClass(["wm-onb__thread-icon",{"wm-onb__thread-icon--inverted":!l.unread}])},[n[5]||(n[5]=e.createElementVNode("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[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:"currentColor",opacity:"0.92"})],-1)),l.unread?(e.openBlock(),e.createElementBlock("span",un)):e.createCommentVNode("",!0)],2),e.createElementVNode("span",mn,[e.createElementVNode("span",hn,e.toDisplayString(l.title),1),e.createElementVNode("span",fn,e.toDisplayString(l.preview),1)]),e.createElementVNode("span",pn,[o.formatTs(l._ts)?(e.openBlock(),e.createElementBlock("span",_n,e.toDisplayString(o.formatTs(l._ts)),1)):e.createCommentVNode("",!0),n[6]||(n[6]=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-onb__thread-chev","aria-hidden":"true"},[e.createElementVNode("path",{d:"M5 12h14M13 5l7 7-7 7"})],-1))])],8,dn))),128)),o.filteredThreads.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",gn," Aucun résultat pour « "+e.toDisplayString(s.query)+" ». ",1))])])):e.createCommentVNode("",!0)])}const ge=N(qt,[["render",vn],["__scopeId","data-v-c85f6958"]]);function yn(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 kn={name:"WmActionResult",props:{state:{type:String,default:"success"},label:{type:String,required:!0},detail:{type:String,default:""}},computed:{detailText(){return yn(this.detail)}}},wn={class:"wm-result__icon","aria-hidden":"true"},bn={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"},En={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"},Cn={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"},Bn={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"},Nn={class:"wm-result__body"},Sn={class:"wm-result__label"},Vn={class:"wm-result__detail"};function An(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-result",`wm-result--${r.state}`])},[e.createElementVNode("span",wn,[r.state==="success"?(e.openBlock(),e.createElementBlock("svg",bn,[...n[0]||(n[0]=[e.createElementVNode("path",{d:"M20 6L9 17l-5-5"},null,-1)])])):r.state==="rejected"?(e.openBlock(),e.createElementBlock("svg",En,[...n[1]||(n[1]=[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"},null,-1)])])):r.state==="awaiting"?(e.openBlock(),e.createElementBlock("svg",Cn,[...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",Bn,[...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",Nn,[e.createElementVNode("span",Sn,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",Vn,e.toDisplayString(o.detailText),1)],64)):e.createCommentVNode("",!0)])],2)}const ve=N(kn,[["render",An],["__scopeId","data-v-64a83fb8"]]),Mn={name:"WmArtifactFormResponse",props:{data:{type:Object,required:!0}},computed:{fields(){var t;return Array.isArray((t=this.data)==null?void 0:t.fields)?this.data.fields:[]}}},Tn={class:"wm-art wm-art--formResponse"},xn={class:"wm-art__head"},On={class:"wm-art__title"},In={class:"wm-art__body"},Dn={class:"wm-art__fieldLabel"};function Ln(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",Tn,[e.createElementVNode("div",xn,[e.createElementVNode("div",On,e.toDisplayString(r.data.title||"Formulaire"),1),n[0]||(n[0]=e.createElementVNode("span",{class:"wm-art__badge wm-art__badge--success"},[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"})]),e.createTextVNode(" Envoyé ")],-1))]),e.createElementVNode("div",In,[(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",Dn,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 ye=N(Mn,[["render",Ln],["__scopeId","data-v-ca24a9c9"]]),Rn={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}}},$n={class:"wm-art wm-art--infoCard"},Fn={key:0,class:"wm-art__image"},Pn=["src","alt"],jn={class:"wm-art__head"},Un={class:"wm-art__headMain"},zn={class:"wm-art__title"},Hn={key:0,class:"wm-art__subtitle"},qn={key:1,class:"wm-art__body"},Kn={key:0,class:"wm-art__text"},Wn={class:"wm-art__fieldLabel"};function Gn(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",$n,[r.data.image_url?(e.openBlock(),e.createElementBlock("figure",Fn,[e.createElementVNode("img",{src:r.data.image_url,alt:r.data.title||"",loading:"lazy"},null,8,Pn)])):e.createCommentVNode("",!0),e.createElementVNode("div",jn,[e.createElementVNode("div",Un,[e.createElementVNode("div",zn,e.toDisplayString(r.data.title),1),r.data.subtitle?(e.openBlock(),e.createElementBlock("div",Hn,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",qn,[r.data.body?(e.openBlock(),e.createElementBlock("div",Kn,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",Wn,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 ke=N(Rn,[["render",Gn],["__scopeId","data-v-d7369333"]]);function Yn(t){if(!t)return"";const n=new Date(t);if(Number.isNaN(n.getTime()))return t;const r=n.toLocaleDateString("fr-FR",{day:"numeric",month:"long",year:"numeric"}),a=n.toLocaleTimeString("fr-FR",{hour:"2-digit",minute:"2-digit"});return`${r} à ${a}`}const Xn={name:"WmArtifactTicket",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 Yn((t=this.data)==null?void 0:t.created_at)}},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}}},Jn={class:"wm-art wm-art--ticket"},Qn={class:"wm-art__head wm-tk__head"},Zn={class:"wm-art__title wm-tk__title"},er={class:"wm-tk__sub"},tr={class:"wm-tk__ref"},nr={key:0,class:"wm-tk__text"},rr={key:0,class:"wm-art__body"},or={class:"wm-art__fieldLabel"},sr=["data-level"],ar={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"},ir={key:1,class:"wm-art__footer wm-tk__footer"};function lr(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",Jn,[e.createElementVNode("div",Qn,[e.createElementVNode("div",Zn,e.toDisplayString(r.data.title),1),e.createElementVNode("div",er,[e.createElementVNode("div",tr,[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",nr,e.toDisplayString(r.data.body),1)):e.createCommentVNode("",!0)]),o.fields.length?(e.openBlock(),e.createElementBlock("div",rr,[(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",or,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,sr)):o.isDate(i.label)?(e.openBlock(),e.createElementBlock("svg",ar,[...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",ir,[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 we=N(Xn,[["render",lr],["__scopeId","data-v-8b274eb7"]]),cr={form_response:ye,info_card:ke,ticket:we},dr={name:"WmArtifactRenderer",props:{artifact:{type:Object,required:!0}},computed:{component(){var n;const t=(n=this.artifact)==null?void 0:n.kind;return t&&cr[t]||null}}};function ur(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 be=N(dr,[["render",ur]]),mr={name:"WmAttachmentPreview",inject:{signAttachmentFn:{default:null}},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()||"Pièce jointe"},sizeLabel(){var n;const t=(n=this.attachment)==null?void 0:n.size_bytes;return t?t<1024?`${t} o`:t<1024*1024?`${(t/1024).toFixed(0)} ko`:`${(t/(1024*1024)).toFixed(1)} Mo`:""}},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.url||t.preventDefault()}}},hr=["href"],fr=["src","alt"],pr=["src"],_r=["src"],gr=["href","download"],vr={class:"wm-att__main"},yr={class:"wm-att__name"},kr={key:0,class:"wm-att__meta"},wr={key:0,class:"wm-att__spin","aria-hidden":"true"};function br(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:s.url,target:"_blank",rel:"noopener",class:"wm-att__imgWrap"},[e.createElementVNode("img",{src:s.url,alt:o.displayName,loading:"lazy"},null,8,fr)],8,hr)):o.kind==="audio"&&s.url?(e.openBlock(),e.createElementBlock("audio",{key:1,src:s.url,controls:"",preload:"metadata"},null,8,pr)):o.kind==="video"&&s.url?(e.openBlock(),e.createElementBlock("video",{key:2,src:s.url,controls:"",preload:"metadata"},null,8,_r)):(e.openBlock(),e.createElementBlock("a",{key:3,class:"wm-att__file",href:s.url||"#",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",vr,[e.createElementVNode("span",yr,e.toDisplayString(o.displayName),1),o.sizeLabel?(e.openBlock(),e.createElementBlock("span",kr,e.toDisplayString(o.sizeLabel),1)):e.createCommentVNode("",!0)]),s.loading?(e.openBlock(),e.createElementBlock("span",wr)):e.createCommentVNode("",!0)],8,gr))],2)}const Ee=N(mr,[["render",br],["__scopeId","data-v-1cd1267b"]]);function Er(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Cr(t){return/^(https?:\/\/|mailto:|tel:)/i.test(String(t).trim())}const ae="";function K(t){let n=t;const r=[];return n=n.replace(/`([^`\n]+)`/g,(a,s)=>{const o=r.length;return r.push(s),`${ae}CODE${o}${ae}`}),n=n.replace(/\[([^\]\n]+)\]\(([^)\s]+)\)/g,(a,s,o)=>Cr(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 Ce(t){if(!t)return"";const n=Er(t).split(`
|
|
54
|
-
`),r=[];let
|
|
55
|
-
`)}</code></pre>`});continue}if(/^\s*[-*]\s+/.test(
|
|
56
|
-
`)}return s}const Br={name:"WmBubble",props:{role:{type:String,default:"ai"},text:{type:String,default:""}},computed:{rendered(){return Ce(this.text)}}},Nr=["innerHTML"];function Sr(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,Nr)],!0)],2)}const Be=N(Br,[["render",Sr],["__scopeId","data-v-5c9e9f2b"]]),Vr={name:"WmTyping"},Ar={class:"wm-typing"};function Mr(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",Ar,[...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 Ne=N(Vr,[["render",Mr],["__scopeId","data-v-df2447fd"]]);function U(t){return t?t.client_msg_id||t.id:""}const Tr={transferred_to_human:"Conversation transférée à un humain",assigned:"{name} a rejoint la conversation",unassigned:"L'agent a quitté la conversation",resolved:"Conversation résolue",reopened:"Conversation rouverte",idle:"Conversation en pause"},xr=80,Or=200,Ir={name:"WmMessageList",components:{AIAvatar:j,HumanAvatar:te,Bubble:Be,Typing:Ne,ActionResult:ve,AttachmentPreview:Ee,ArtifactRenderer:be},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:""}},emits:["load-more"],data(){return{silentFades:!1,widthByKey:Object.freeze({})}},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 y=t[t.length-1];y&&y.role==="ai"?y.messages.push(i):t.push({key:`g-${U(i)}`,role:"ai",agentName:"",agentAvatarUrl:null,messages:[i],items:[]});continue}t.push({key:`sys-${U(i)}`,role:l,messages:[i],items:[],systemLabel:this.systemLabel(i)});continue}const p=t[t.length-1];p&&p.role===l&&(l==="ai"||p.agentName===(((a=i==null?void 0:i.author)==null?void 0:a.name)||""))?p.messages.push(i):t.push({key:`g-${U(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 p of i.messages)for(const v of this.itemsOf(p))l.push(v);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)}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},loadingMore(t){t||(this._pendingLoadMore=!1),this.silentFades=!0,clearTimeout(this._silenceTimer),t||(this._silenceTimer=setTimeout(()=>{this.silentFades=!1},250)),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),clearTimeout(this._silenceTimer)},updated(){this.scheduleMeasure()},methods:{messageKey:U,isAtBottom(t){return t.scrollHeight-t.scrollTop-t.clientHeight<=xr},onScroll(){const t=this.$refs.scrollEl;t&&(this.loadingMore||!this.hasMore||this._pendingLoadMore||t.scrollTop<=Or&&(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.el){const i=t.getBoundingClientRect().top;a={el:o.el,relY:o.el.getBoundingClientRect().top-i}}}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=()=>{var v;const i=s.anchor;if(!((v=i.el)!=null&&v.isConnected))return;const p=i.el.getBoundingClientRect().top-t.getBoundingClientRect().top-i.relY;Math.abs(p)>.5&&(t.scrollTop+=p)};o(),requestAnimationFrame(()=>{o(),requestAnimationFrame(o)})})},pickAnchor(t){const n=t.scrollTop;let r=null;for(const a of t.children)if(a.classList.contains("wm-list__group")&&(r||(r=a),a.offsetTop+a.offsetHeight>=n))return{el:a,offsetTop:a.offsetTop};return r?{el:r,offsetTop:r.offsetTop}:null},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){return t.role==="human"?t.agentName||"Agent":"Assistant IA"},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 $,F,O;const r=t.items,a=($=r[n])==null?void 0:$.kind,s=(F=r[n-1])==null?void 0:F.kind,o=(O=r[n+1])==null?void 0:O.kind,i=t.role==="user",l=14,p=4,v=s==null?void 0:s.bottom,y=o==null?void 0:o.top,E=this.widthByKey[this.rowKeyOf(t,n)],S=this.widthByKey[this.rowKeyOf(t,n-1)],k=this.widthByKey[this.rowKeyOf(t,n+1)],x=.5,w=(P,L,I)=>P!=null&&E!=null?P+x>=E:L===I||L==="card"&&I==="bubble";let M=l,V=l,T=l,D=l;return i?(v&&(V=p),(y||!o)&&(T=p),v&&w(S,v,a==null?void 0:a.top)&&(M=p),y&&w(k,y,a==null?void 0:a.bottom)&&(D=p)):(v&&(M=p),(y||!o)&&(D=p),v&&w(S,v,a==null?void 0:a.top)&&(V=p),y&&w(k,y,a==null?void 0:a.bottom)&&(T=p)),{tl:M,tr:V,br:T,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?`${U(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 p=l.getBoundingClientRect().width;p>0&&(n[i]=p)}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)},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 ee(new Date(r.created_at))}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)||"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)||"Action annulée par l'utilisateur.":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=Tr[n]||(t==null?void 0:t.text_md)||"Mise à jour de la conversation",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)||"";return r.replace("{name}",a||"Un agent")},scrollToBottom(){const t=this.$refs.scrollEl;t&&(t.scrollTop=t.scrollHeight)}}},Dr={key:0,class:"wm-list__loadMore",role:"status","aria-live":"polite"},Lr={key:1,class:"wm-list__historyEnd"},Rr={key:2,class:"wm-list__sep"},$r={class:"wm-list__sep-label"},Fr={key:0,class:"wm-list__sep wm-list__sep--unread"},Pr={key:0,class:"wm-list__sysep"},jr={class:"wm-list__sysep-label"},Ur=["data-row-key"],zr={key:0,class:"wm-list__avatarSlot"},Hr={key:5,class:"wm-list__body"},qr={key:0},Kr={key:1,"aria-hidden":"true"},Wr={key:2},Gr={key:3,class:"wm-list__row wm-list__row--ai fade-up"},Yr={class:"wm-list__avatarSlot"};function Xr(t,n,r,a,s,o){const i=e.resolveComponent("AIAvatar"),l=e.resolveComponent("HumanAvatar"),p=e.resolveComponent("ActionResult"),v=e.resolveComponent("ArtifactRenderer"),y=e.resolveComponent("Bubble"),E=e.resolveComponent("AttachmentPreview"),S=e.resolveComponent("Typing");return e.openBlock(),e.createElementBlock("div",{ref:"scrollEl",class:e.normalizeClass(["wm-list",{"wm-list--silent":s.silentFades}]),onScrollPassive:n[0]||(n[0]=(...k)=>o.onScroll&&o.onScroll(...k))},[r.loadingMore?(e.openBlock(),e.createElementBlock("div",Dr,[...n[1]||(n[1]=[e.createElementVNode("span",{class:"wm-list__loadMore-spinner","aria-hidden":"true"},null,-1),e.createElementVNode("span",{class:"wm-list__loadMore-lbl"},"Chargement de l'historique…",-1)])])):o.historyExhausted?(e.openBlock(),e.createElementBlock("div",Lr,"Début de la conversation")):e.createCommentVNode("",!0),r.dateLabel?(e.openBlock(),e.createElementBlock("div",Rr,[n[2]||(n[2]=e.createElementVNode("div",{class:"wm-list__line"},null,-1)),e.createElementVNode("span",$r,e.toDisplayString(r.dateLabel),1),n[3]||(n[3]=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,x)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:k.key},[k.key===o.unreadGroupKey?(e.openBlock(),e.createElementBlock("div",Fr,[...n[4]||(n[4]=[e.createElementVNode("div",{class:"wm-list__line wm-list__line--unread"},null,-1),e.createElementVNode("span",{class:"wm-list__sep-label wm-list__sep-label--unread"},"Non lus",-1),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",Pr,[n[5]||(n[5]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--strong"},null,-1)),e.createElementVNode("span",jr,e.toDisplayString(k.systemLabel),1),n[6]||(n[6]=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,(w,M)=>(e.openBlock(),e.createElementBlock("div",{key:`${o.messageKey(w.message)}-${w.partKey}`,"data-row-key":`${o.messageKey(w.message)}-${w.partKey}`,class:e.normalizeClass(["wm-list__row fade-up",["wm-list__row--"+k.role,{"is-pending":w.message._pending,"is-failed":w.message._failed}]]),style:e.normalizeStyle(o.cornersStyle(k,M))},[k.role!=="user"?(e.openBlock(),e.createElementBlock("div",zr,[M===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})):(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),w.renderAs==="action"?(e.openBlock(),e.createBlock(p,{key:1,state:w.message.payload.state,label:o.actionLabel(w.message),detail:o.actionDetail(w.message)},null,8,["state","label","detail"])):w.renderAs==="admin-pending"?(e.openBlock(),e.createBlock(p,{key:2,state:"awaiting",label:"Demande d'approbation envoyée",detail:w.message.text_md||""},null,8,["detail"])):w.renderAs==="artifact-of-action"?(e.openBlock(),e.createBlock(v,{key:3,artifact:o.actionArtifact(w.message)},null,8,["artifact"])):w.renderAs==="artifact"?(e.openBlock(),e.createBlock(v,{key:4,artifact:o.artifactOf(w.message)},null,8,["artifact"])):(e.openBlock(),e.createElementBlock("div",Hr,[w.message.text_md?(e.openBlock(),e.createBlock(y,{key:0,role:k.role,text:w.message.text_md},null,8,["role","text"])):e.createCommentVNode("",!0),o.attachmentsOf(w.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(w.message),(V,T)=>(e.openBlock(),e.createBlock(E,{key:`${o.messageKey(w.message)}-att-${T}`,attachment:V},null,8,["attachment"]))),128))],2)):e.createCommentVNode("",!0)]))],14,Ur))),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",qr,e.toDisplayString(o.roleLabel(k)),1)):e.createCommentVNode("",!0),k.role!=="user"&&o.lastTimeOf(k)?(e.openBlock(),e.createElementBlock("span",Kr,"·")):e.createCommentVNode("",!0),o.lastTimeOf(k)?(e.openBlock(),e.createElementBlock("span",Wr,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",Gr,[e.createElementVNode("div",Yr,[e.createVNode(i,{size:26,tail:!0})]),e.createVNode(S)])):e.createCommentVNode("",!0)],34)}const Se=N(Ir,[["render",Xr],["__scopeId","data-v-946babe3"]]),z=typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function",Y=typeof window<"u"&&typeof window.MediaRecorder<"u";function Ve(){return Y&&["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 Ae({audio:t}){return{video:!0,audio:!!t,selfBrowserSurface:"include",surfaceSwitching:"include",systemAudio:t?"include":"exclude"}}function Jr(t){return t?t.startsWith("image/")?"image":t.startsWith("video/")?"video":"file":"file"}async function Me(){if(!z)return null;let t;try{t=await navigator.mediaDevices.getDisplayMedia(Ae({audio:!1}))}catch(n){return(n==null?void 0:n.name)!=="NotAllowedError"&&console.error("[media] screenshot picker",n),null}try{return await Qr(t)}catch(n){return console.error("[media] screenshot capture",n),null}finally{t.getTracks().forEach(n=>{n.stop()})}}async function Qr(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,p)=>{s.toBlob(v=>v?l(v):p(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 Te(t={}){var v;if(!z||!Y)return null;let n;try{n=await navigator.mediaDevices.getDisplayMedia(Ae({audio:!0}))}catch(y){return(y==null?void 0:y.name)!=="NotAllowedError"&&console.error("[media] record picker",y),null}const r=Ve();let a;try{a=r?new window.MediaRecorder(n,{mimeType:r}):new window.MediaRecorder(n)}catch(y){return console.error("[media] recorder init",y),n.getTracks().forEach(E=>{E.stop()}),null}const s=[];let o=null,i=!1;a.addEventListener("dataavailable",y=>{y.data&&y.data.size>0&&s.push(y.data)}),a.addEventListener("stop",()=>{var y,E;if(o&&clearInterval(o),n.getTracks().forEach(S=>{S.stop()}),s.length){const S=a.mimeType||r||"video/webm",k=new Blob(s,{type:S}),x=/mp4/.test(S)?"mp4":"webm",w=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),M=new File([k],`ecran-${w}.${x}`,{type:S});(y=t.onfinalize)==null||y.call(t,M)}else(E=t.oncancel)==null||E.call(t)}),n.getVideoTracks().forEach(y=>{y.addEventListener("ended",()=>l(),{once:!0})});function l(){if(!i&&(i=!0,a.state!=="inactive"))try{a.stop()}catch(y){console.error("[media] recorder stop",y)}}try{a.start(1e3)}catch(y){return console.error("[media] recorder start",y),n.getTracks().forEach(E=>{E.stop()}),null}(v=t.onstart)==null||v.call(t);const p=Date.now();return o=setInterval(()=>{var y;(y=t.ontick)==null||y.call(t,Date.now()-p)},500),{stop:l,get state(){return a.state}}}const Zr=[{action:"file",label:"Joindre un fichier",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",label:"Capture d'écran",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",label:"Enregistrer l'écran",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"}],eo={name:"WmComposer",props:{modelValue:{type:String,default:""},placeholder:{type:String,default:"Écrivez votre message…"},disabled:{type:Boolean,default:!1},attachLabel:{type:String,default:"Joindre"}},emits:["update:modelValue","send","attach"],data(){return{local:this.modelValue,attachOpen:!1,recording:!1,recordingElapsed:0,recorder:null}},computed:{canSend(){return!this.disabled&&!!this.local.trim()},attachItems(){return Zr.map(t=>({...t,disabled:t.action==="screenshot"&&!z||t.action==="record"&&(!z||!Y)}))},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()},beforeUnmount(){if(this.recorder)try{this.recorder.stop()}catch{}},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.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 Me();t&&this.$emit("attach",t)},async startRecording(){if(this.recording||this.disabled)return;this.recordingElapsed=0;const t=await Te({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)}}}},to={class:"wm-compose-wrap"},no={key:0,class:"wm-rec"},ro={class:"wm-rec__lbl"},oo={key:1,class:"wm-compose__menu",role:"menu"},so=["disabled","onClick"],ao={class:"wm-compose__menuIcon"},io={viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true"},lo=["d"],co=["placeholder","disabled"],uo={class:"wm-compose__actions"},mo=["title","aria-label","disabled"],ho=["disabled"];function fo(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",to,[s.recording?(e.openBlock(),e.createElementBlock("div",no,[n[8]||(n[8]=e.createElementVNode("span",{class:"wm-rec__dot","aria-hidden":"true"},null,-1)),e.createElementVNode("span",ro,"Enregistrement · "+e.toDisplayString(o.recordingElapsedLabel),1),e.createElementVNode("button",{type:"button",class:"wm-rec__stop",onClick:n[0]||(n[0]=(...i)=>o.stopRecording&&o.stopRecording(...i))},"Arrêter")])):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",oo,[(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",ao,[(e.openBlock(),e.createElementBlock("svg",io,[e.createElementVNode("path",{d:i.path,stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",fill:"none"},null,8,lo)]))]),e.createElementVNode("span",null,e.toDisplayString(i.label),1)],8,so))),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,co),[[e.vModelText,s.local]]),e.createElementVNode("div",uo,[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,mo),e.createElementVNode("button",{type:"submit",class:e.normalizeClass(["wm-compose__send",{"is-empty":!o.canSend}]),disabled:!o.canSend,"aria-label":"Envoyer"},[...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,ho)])],34)])}const xe=N(eo,[["render",fo],["__scopeId","data-v-14fa9ec0"]]),po={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("§")}}},_o=["onClick"];function go(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:p=>t.$emit("select",i)},e.toDisplayString(i.label),13,_o))),128))])):e.createCommentVNode("",!0)}const Oe=N(po,[["render",go],["__scopeId","data-v-55aa529d"]]),vo={name:"WmApprovalCard",components:{AIAvatar:j},props:{action:{type:String,required:!0},detail:{type:String,default:""},callbacks:{type:Array,default:()=>[]}},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)||"Autoriser"},rejectLabel(){var t;return((t=this.rejectCallback)==null?void 0:t.label)||"Refuser"}}},yo={class:"wm-approval"},ko={class:"wm-approval__head"},wo={class:"wm-approval__icon"},bo={class:"wm-approval__main"},Eo={class:"wm-approval__title"},Co={key:0,class:"wm-approval__detail"},Bo={class:"wm-approval__actions"};function No(t,n,r,a,s,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",yo,[e.createElementVNode("div",ko,[e.createElementVNode("div",wo,[e.createVNode(i,{size:24})]),e.createElementVNode("div",bo,[e.createElementVNode("div",Eo,e.toDisplayString(r.action),1),r.detail?(e.openBlock(),e.createElementBlock("div",Co,e.toDisplayString(r.detail),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",Bo,[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 Ie=N(vo,[["render",No],["__scopeId","data-v-b1be139c"]]);let ie=0;const So=new Set(["text","textarea","number","boolean","select","multiselect","date"]),Vo={name:"WmFormCard",components:{AIAvatar:j},props:{form:{type:Object,required:!0},readOnly:{type:Boolean,default:!1},initialValues:{type:Object,default:null}},emits:["submit"],data(){return ie+=1,{_uid:ie,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)||!So.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`« ${t.label} » est requis.`;continue}if(n==null||n==="")return`« ${t.label} » est requis.`}}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}}}},Ao={class:"wm-form"},Mo={class:"wm-form__head"},To={class:"wm-form__icon"},xo={class:"wm-form__main"},Oo={class:"wm-form__title"},Io={key:0,class:"wm-form__detail"},Do=["for"],Lo={key:0,class:"wm-form__req","aria-hidden":"true"},Ro=["id","onUpdate:modelValue","placeholder","required","disabled"],$o=["id","onUpdate:modelValue","placeholder","required","disabled"],Fo=["id","onUpdate:modelValue","placeholder","required","disabled"],Po=["id","onUpdate:modelValue","required","disabled"],jo={key:4,class:"wm-form__bool"},Uo=["id","onUpdate:modelValue","disabled"],zo=["id","onUpdate:modelValue","required","disabled"],Ho={value:"",disabled:""},qo=["value"],Ko={key:6,class:"wm-form__multi"},Wo=["value","checked","disabled","onChange"],Go={key:0,class:"wm-form__err"},Yo=["disabled"],Xo={key:0,class:"wm-form__spinner","aria-hidden":"true"},Jo={key:2,class:"wm-form__doneLbl"};function Qo(t,n,r,a,s,o){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",Ao,[e.createElementVNode("div",Mo,[e.createElementVNode("div",To,[e.createVNode(i,{size:24})]),e.createElementVNode("div",xo,[e.createElementVNode("div",Oo,e.toDisplayString(r.form.title||"Formulaire"),1),r.form.description?(e.openBlock(),e.createElementBlock("div",Io,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",Lo,"*")):e.createCommentVNode("",!0)],8,Do),l.type==="text"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,id:`wm-f-${s._uid}-${l.key}`,"onUpdate:modelValue":p=>s.values[l.key]=p,type:"text",class:"wm-form__input",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||s.busy},null,8,Ro)),[[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":p=>s.values[l.key]=p,class:"wm-form__textarea",rows:"3",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||s.busy},null,8,$o)),[[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":p=>s.values[l.key]=p,type:"number",class:"wm-form__input",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||s.busy},null,8,Fo)),[[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":p=>s.values[l.key]=p,type:"date",class:"wm-form__input",required:l.required,disabled:r.readOnly||s.busy},null,8,Po)),[[e.vModelText,s.values[l.key]]]):l.type==="boolean"?(e.openBlock(),e.createElementBlock("label",jo,[e.withDirectives(e.createElementVNode("input",{id:`wm-f-${s._uid}-${l.key}`,"onUpdate:modelValue":p=>s.values[l.key]=p,type:"checkbox",disabled:r.readOnly||s.busy},null,8,Uo),[[e.vModelCheckbox,s.values[l.key]]]),e.createElementVNode("span",null,e.toDisplayString(l.placeholder||"Oui"),1)])):l.type==="select"?e.withDirectives((e.openBlock(),e.createElementBlock("select",{key:5,id:`wm-f-${s._uid}-${l.key}`,"onUpdate:modelValue":p=>s.values[l.key]=p,class:"wm-form__select",required:l.required,disabled:r.readOnly||s.busy},[e.createElementVNode("option",Ho,e.toDisplayString(l.placeholder||"Choisir…"),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,p=>(e.openBlock(),e.createElementBlock("option",{key:p.value,value:p.value},e.toDisplayString(p.label),9,qo))),128))],8,zo)),[[e.vModelSelect,s.values[l.key]]]):l.type==="multiselect"?(e.openBlock(),e.createElementBlock("div",Ko,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,p=>(e.openBlock(),e.createElementBlock("label",{key:p.value,class:"wm-form__multiItem"},[e.createElementVNode("input",{type:"checkbox",value:p.value,checked:Array.isArray(s.values[l.key])&&s.values[l.key].includes(p.value),disabled:r.readOnly||s.busy,onChange:v=>o.toggleMulti(l.key,p.value,v.target.checked)},null,40,Wo),e.createElementVNode("span",null,e.toDisplayString(p.label),1)]))),128))])):e.createCommentVNode("",!0)]))),128)),s.error?(e.openBlock(),e.createElementBlock("div",Go,e.toDisplayString(s.error),1)):e.createCommentVNode("",!0),r.readOnly?(e.openBlock(),e.createElementBlock("div",Jo,"Réponse envoyée")):(e.openBlock(),e.createElementBlock("button",{key:1,type:"submit",class:"wm-form__submit",disabled:s.busy},[s.busy?(e.openBlock(),e.createElementBlock("span",Xo)):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(s.busy?"Envoi…":r.form.submit_label||"Envoyer"),1)],8,Yo))],32)])}const De=N(Vo,[["render",Qo],["__scopeId","data-v-64b40f76"]]),Zo={name:"WmFeedback",props:{busy:{type:Boolean,default:!1},done:{type:Boolean,default:!1}},emits:["submit"],data(){return{sel:null,options:[{v:1,e:"😞",l:"Pas bien"},{v:2,e:"😐",l:"Moyen"},{v:3,e:"🙂",l:"Bien"},{v:4,e:"😄",l:"Super"},{v:5,e:"🤩",l:"Excellent"}]}},methods:{onSend(){!this.sel||this.busy||this.$emit("submit",{rating:this.sel})}}},es={class:"wm-fb"},ts={class:"wm-fb__row"},ns=["onClick"],rs={class:"wm-fb__emoji"},os={class:"wm-fb__label"},ss=["disabled"],as={key:1,class:"wm-fb__done"};function is(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",es,[r.done?(e.openBlock(),e.createElementBlock("div",as,[...n[3]||(n[3]=[e.createStaticVNode('<div class="wm-fb__check" data-v-6f45ff3b><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" data-v-6f45ff3b><path d="M20 6L9 17l-5-5" data-v-6f45ff3b></path></svg></div><div class="wm-fb__doneTitle" data-v-6f45ff3b>Merci pour votre retour !</div><div class="wm-fb__doneSub" data-v-6f45ff3b>Votre avis a bien été pris en compte.</div>',3)])])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[n[1]||(n[1]=e.createElementVNode("div",{class:"wm-fb__title"},"Comment s'est passée cette conversation ?",-1)),n[2]||(n[2]=e.createElementVNode("div",{class:"wm-fb__sub"},"Votre avis nous aide à améliorer l'assistant.",-1)),e.createElementVNode("div",ts,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.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",rs,e.toDisplayString(i.e),1),e.createElementVNode("span",os,e.toDisplayString(i.l),1)],10,ns))),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?"Envoi…":"Envoyer mon avis"),9,ss)],64))])}const Le=N(Zo,[["render",is],["__scopeId","data-v-6f45ff3b"]]),ls={name:"WmMoreMenu",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)}}},cs={class:"wm-mm"},ds={class:"wm-mm__pop",role:"menu"},us={key:0,class:"wm-mm__section"},ms={key:1,class:"wm-mm__sep"},hs={class:"wm-mm__section"},fs={class:"wm-mm__section"};function ps(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",cs,[e.createElementVNode("div",{class:"wm-mm__scrim",onClick:n[0]||(n[0]=i=>t.$emit("close"))}),e.createElementVNode("div",ds,[r.canRename||r.canExport?(e.openBlock(),e.createElementBlock("div",us,[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.createStaticVNode('<span class="wm-mm__icon" data-v-3a73911b><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" data-v-3a73911b><path d="M12 20h9" data-v-3a73911b></path><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z" data-v-3a73911b></path></svg></span><span class="wm-mm__label" data-v-3a73911b>Modifier le titre</span>',2)])])):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.createStaticVNode('<span class="wm-mm__icon" data-v-3a73911b><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" data-v-3a73911b><path d="M4 12v8a2 2 0 002 2h12a2 2 0 002-2v-8M16 6l-4-4-4 4M12 2v13" data-v-3a73911b></path></svg></span><span class="wm-mm__label" data-v-3a73911b>Exporter la transcription</span><span class="wm-mm__hint" data-v-3a73911b>.txt</span>',3)])])):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[10]||(n[10]=e.createStaticVNode('<span class="wm-mm__icon" data-v-3a73911b><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" data-v-3a73911b><path d="M11 5L6 9H2v6h4l5 4V5z" data-v-3a73911b></path><path d="M15.54 8.46a5 5 0 010 7.07M19.07 4.93a10 10 0 010 14.14" data-v-3a73911b></path></svg></span><span class="wm-mm__label" data-v-3a73911b>Son</span>',2)),e.createElementVNode("span",{class:e.normalizeClass(["wm-mm__toggle",{"wm-mm__toggle--on":s.soundOn}])},[...n[9]||(n[9]=[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[12]||(n[12]=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)),n[13]||(n[13]=e.createElementVNode("span",{class:"wm-mm__label"},"Notifications navigateur",-1)),e.createElementVNode("span",{class:e.normalizeClass(["wm-mm__toggle",{"wm-mm__toggle--on":s.browserNotifOn}])},[...n[11]||(n[11]=[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",fs,[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",{class:"wm-mm__label"},"Statut des services",-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",{class:"wm-mm__label"},"Centre d'aide",-1)])])):e.createCommentVNode("",!0)])])])}const Re=N(ls,[["render",ps],["__scopeId","data-v-3a73911b"]]),_s={name:"WmRenameDialog",props:{title:{type:String,default:"Modifier le titre"},initialValue:{type:String,default:""},placeholder:{type:String,default:"Titre de la conversation"}},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())}}},gs={class:"wm-dialog"},vs={class:"wm-dialog__card",role:"dialog","aria-modal":"true"},ys={class:"wm-dialog__head"},ks={class:"wm-dialog__title"},ws={class:"wm-dialog__body"},bs=["placeholder"],Es={class:"wm-dialog__actions"},Cs=["disabled"];function Bs(t,n,r,a,s,o){return e.openBlock(),e.createElementBlock("div",gs,[e.createElementVNode("div",{class:"wm-dialog__scrim",onClick:n[0]||(n[0]=i=>t.$emit("close"))}),e.createElementVNode("div",vs,[e.createElementVNode("div",ys,[e.createElementVNode("div",ks,e.toDisplayString(r.title),1),e.createElementVNode("button",{type:"button",class:"wm-dialog__close","aria-label":"Fermer",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)])])]),e.createElementVNode("div",ws,[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,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,bs),[[e.vModelText,s.value]])]),e.createElementVNode("div",Es,[e.createElementVNode("button",{type:"button",class:"wm-dialog__btn",onClick:n[5]||(n[5]=i=>t.$emit("close"))},"Annuler"),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))},"Enregistrer",8,Cs)])])])}const Ns=N(_s,[["render",Bs],["__scopeId","data-v-4f4b37c9"]]),le="ww-messenger-tokens",Ss={name:"Messenger",components:{Launcher:fe,Header:_e,Onboarding:ge,MessageList:Se,Composer:xe,SuggestionChips:Oe,ApprovalCard:Ie,FormCard:De,Feedback:Le,MoreMenu:Re,RenameDialog:Ns},mixins:[Qe,ot,st,it],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}}},props:{baseUrl:{type:String,default:me},widgetId:{type:String,default:""},userId:{type:String,default:""},userHash:{type:String,default:""},customer:{type:Object,default:null},displayMode:{type:String,default:"floating"},devtools:{type:Boolean,default:!1}},data(){return{transport:null,store:null,isOpen:!1,draft:"",busy:!1,bootError:null,pendingAttachments:[],feedbackBusy:!1,feedbackDone:!1,convOpenedAt:0,moreOpen:!1,renameDialogOpen:!1,draftConv:null,activeConvId:null,showOnboarding:!1,dismissedPeeks:{},floatHeight:0,floatRO:null}},computed:{isEditor(){return!!this.devtools},isEmbedded(){return this.displayMode==="embedded"},error(){var t;return this.bootError||((t=this.s)==null?void 0:t.error)||null},canBoot(){return!!(this.baseUrl&&this.widgetId&&this.userId&&this.userHash)},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 n;const t=((n=this.s)==null?void 0:n.messagesByConv)||{};return this.allConversations.map(r=>{var l;const a=t[r.id]||[],s=R(r.last_read_message_id);let o=0,i=null;for(let p=a.length-1;p>=0;p--){const v=a[p];if(!v)continue;if(((l=v.author)==null?void 0:l.type)==="user")break;const y=R(v.id);if(y!=null){if(s!=null&&y<=s)break;!i&&v.author&&(i=v.author),o++}}return{...r,_preview:Ge(r,a),_unread:o>0,_unreadCount:o,_lastAuthor:i}})},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||"Nouvelle conversation",preview:r._preview||"Nouveau message",unread:!!r._unread,_ts:oe(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=oe(a,t[a.id]||[]),o=a._lastAuthor,i=!o||o.type==="agent_ia",l=(o==null?void 0:o.name)||(i?this.agentName:"")||"",p=(o==null?void 0:o.avatar_url)||(i?this.agentAvatarUrl:null);n.push({convId:a.id,preview:a._preview||"Vous avez un nouveau message",ts:s,count:a._unreadCount||1,senderName:l,senderAvatarUrl:p})}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},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},widgetWelcomeMessage(){var t;return((t=this.widget)==null?void 0:t.welcome_message)||""},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)||"Nouvelle conversation"},composerPlaceholder(){return this.isEscalated&&this.humanAgentName?`Répondre à ${this.humanAgentName.split(" ")[0]}…`:this.isWaitingHuman?"Un agent prend le relais…":"Écrivez votre message…"},displayedMessages(){const t=this.currentConv;if(!t)return[];const n=this.revealedAt;return(this.s.messagesByConv[t.id]||[]).filter(r=>{var a,s,o,i,l;return(r==null?void 0:r.type)==="action"&&((a=r==null?void 0:r.payload)==null?void 0:a.state)==="pending"||G(r)&&!(n[r.id]>0)?!1:(r==null?void 0:r.type)==="action"||(r==null?void 0:r.type)==="system"||((s=r==null?void 0:r.payload)==null?void 0:s.type)==="system"||Array.isArray((o=r==null?void 0:r.payload)==null?void 0:o.attachments)&&r.payload.attachments.length||(i=r==null?void 0:r.metadata)!=null&&i.artifact||(l=r==null?void 0:r.metadata)!=null&&l.form?!0:typeof(r==null?void 0:r.text_md)=="string"&&r.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=>G(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)||"Confirmer l'action"},approvalDetail(){var a,s,o,i,l,p;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=(p=(l=(i=this.pendingApproval)==null?void 0:i.payload)==null?void 0:l.pending)==null?void 0:p.prepared_params;if(!n||typeof n!="object")return"";const r=Object.entries(n);return r.length?r.slice(0,2).map(([v,y])=>`${v}: ${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||"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`Aujourd'hui · ${ee(n)}`},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){this.paceMessages(t),(this.isOpen||this.isEmbedded)&&this.currentConv&&this.markConvRead(this.currentConv)}},async mounted(){if(typeof document<"u"&&!document.getElementById(le)){const t=document.createElement("style");t.id=le,t.textContent=ue,document.head.appendChild(t)}await this.boot(),this.isEmbedded&&this.store&&await this.open()},beforeUnmount(){this.cancelReveals(),this.disconnectFloatRO(),this.resetApprovalPacing(),this.teardownNotifications(),this.store&&this.store.destroy()},methods:{async boot(){if(!this.canBoot){console.warn("[messenger] boot skipped — missing creds");return}try{this.transport=e.markRaw(ce({baseUrl:this.baseUrl,widgetId:this.widgetId,userId:this.userId,userHash:this.userHash})),this.store=e.markRaw(de(this.transport)),this.hydrateNotifPref(),this.setupNotifications(),await this.store.start(),this.customer&&typeof this.customer=="object"&&await this.store.applyCustomer(this.customer)}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.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,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.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)}},close(){this.isOpen=!1,this.store&&this.store.setPanelOpen(!1)},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),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.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},async onDrawerPick(t){if(!(t!=null&&t.id)||!this.store)return;this.draftConv=null,this.activeConvId=t.id,this.showOnboarding=!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":Je(this.currentConv,this.currentConv?(r=(n=this.s)==null?void 0:n.messagesByConv)==null?void 0:r[this.currentConv.id]:[]);break;case"status":if(this.statusUrl)try{window.open(this.statusUrl,"_blank","noopener")}catch{}break;case"help":if(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=Ke(n.form,t);if(!r)return;let a=this.currentConv;a&&(a._draft&&(a=await this.ensureRealConv(),!a)||await this.store.send(a.id,r,{metadata:{artifact:We(n.form,t)}}))},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||"fichier",mime_type:t.type,size_bytes:t.size})}catch(n){console.error("[ww-messenger] attachment upload failed",n)}},async onQuickLink(t){if(t){if(t.url){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}}}}},Vs={key:0,class:"wm-loading","aria-busy":"true","aria-live":"polite"},As={key:0,class:"wm-state"},Ms={class:"wm-state__err"},Ts={class:"wm-state__errSub"},xs={class:"wm-bottom"},Os={key:0,ref:"floatEl",class:"wm-float"},Is={key:1,class:"wm-actionWait",role:"status","aria-live":"polite"},Ds={class:"wm-actionWait__lbl"},Ls={key:2,class:"wm-attached"},Rs=["onClick"];function $s(t,n,r,a,s,o){const i=e.resolveComponent("Launcher"),l=e.resolveComponent("Header"),p=e.resolveComponent("Onboarding"),v=e.resolveComponent("MessageList"),y=e.resolveComponent("ApprovalCard"),E=e.resolveComponent("FormCard"),S=e.resolveComponent("Feedback"),k=e.resolveComponent("SuggestionChips"),x=e.resolveComponent("Composer"),w=e.resolveComponent("MoreMenu"),M=e.resolveComponent("RenameDialog");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-root",`wm-root--${r.displayMode}`])},[!s.isOpen&&!o.isEmbedded?(e.openBlock(),e.createBlock(i,{key:0,"unread-count":o.unreadCount,peeks:o.launcherPeeks,onOpen:o.openFromPeek,onDismiss:o.dismissPeek},null,8,["unread-count","peeks","onOpen","onDismiss"])):e.createCommentVNode("",!0),s.isOpen||o.isEmbedded?(e.openBlock(),e.createElementBlock("section",{key:1,class:e.normalizeClass(["wm-panel",`wm-panel--${r.displayMode}`]),style:e.normalizeStyle(s.floatHeight?{"--wm-float-h":s.floatHeight+"px"}:null),role:"dialog","aria-label":"Messenger"},[!o.ready&&!o.error?(e.openBlock(),e.createElementBlock("div",Vs,[o.isEmbedded?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-loading__close","aria-label":"Réduire",onClick:n[0]||(n[0]=(...V)=>o.close&&o.close(...V))},[...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)])])),n[6]||(n[6]=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,onBack:o.goHome,onMore:o.toggleMore,onClose:o.close},null,8,["title","team-members","response-label","show-identity","show-back","show-close","more-active","onBack","onMore","onClose"]),o.error?(e.openBlock(),e.createElementBlock("div",As,[e.createElementVNode("div",Ms,[n[8]||(n[8]=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,[n[7]||(n[7]=e.createElementVNode("div",{class:"wm-state__errTitle"},"Connexion impossible",-1)),e.createElementVNode("div",Ts,e.toDisplayString(o.error),1)])])])):o.currentConv?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createVNode(v,{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,onLoadMore:o.onLoadMore},null,8,["messages","streaming-active","date-label","conversation-id","loading-more","has-more","unread-anchor-id","unread-boundary-ts","onLoadMore"]),e.createElementVNode("div",xs,[o.floatVisible?(e.openBlock(),e.createElementBlock("div",Os,[o.approvalReady?(e.openBlock(),e.createBlock(y,{key:0,action:o.approvalTitle,detail:o.approvalDetail,callbacks:o.pendingApproval.callbacks,onCallback:o.onApprovalCallback},null,8,["action","detail","callbacks","onCallback"])):o.pendingForm?(e.openBlock(),e.createBlock(E,{key:o.pendingForm.message&&o.pendingForm.message.id,form:o.pendingForm.form,onSubmit:o.onFormSubmit},null,8,["form","onSubmit"])):o.showFeedback?(e.openBlock(),e.createBlock(S,{key:2,busy:s.feedbackBusy,done:s.feedbackDone,onSubmit:o.onFeedback},null,8,["busy","done","onSubmit"])):(e.openBlock(),e.createBlock(k,{key:3,items:o.suggestions,onSelect:o.onSuggestion},null,8,["items","onSelect"]))],512)):e.createCommentVNode("",!0),o.actionInFlight?(e.openBlock(),e.createElementBlock("div",Is,[n[9]||(n[9]=e.createElementVNode("span",{class:"wm-actionWait__spinner","aria-hidden":"true"},null,-1)),e.createElementVNode("span",Ds,e.toDisplayString(o.actionInFlightName)+" en cours, veuillez patienter…",1)])):(e.openBlock(),e.createBlock(x,{key:2,ref:"composer",modelValue:s.draft,"onUpdate:modelValue":n[1]||(n[1]=V=>s.draft=V),placeholder:o.composerPlaceholder,disabled:!!o.pendingApproval,"attach-label":"Joindre un fichier",onSend:o.onSend,onAttach:o.onAttach},null,8,["modelValue","placeholder","disabled","onSend","onAttach"]))]),s.moreOpen?(e.openBlock(),e.createBlock(w,{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[2]||(n[2]=V=>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:"Modifier le titre de la conversation",onClose:n[3]||(n[3]=V=>s.renameDialogOpen=!1),onSubmit:o.onRenameSubmit},null,8,["initial-value","onSubmit"])):e.createCommentVNode("",!0),s.pendingAttachments.length?(e.openBlock(),e.createElementBlock("div",Ls,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.pendingAttachments,(V,T)=>(e.openBlock(),e.createElementBlock("div",{key:T,class:"wm-attached__chip"},[n[11]||(n[11]=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(V.name),1),e.createElementVNode("button",{type:"button","aria-label":"Retirer",onClick:D=>s.pendingAttachments.splice(T,1)},[...n[10]||(n[10]=[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,Rs)]))),128))])):e.createCommentVNode("",!0)],64)):(e.openBlock(),e.createBlock(p,{key:1,"welcome-message":o.widgetWelcomeMessage,"agent-name":o.agentName,"quick-links":o.quickLinks,"open-threads":o.openThreads,busy:s.busy,onStart:o.startConv,onSelect:o.onQuickLink,onResume:o.onDrawerPick},null,8,["welcome-message","agent-name","quick-links","open-threads","busy","onStart","onSelect","onResume"])),s.moreOpen&&!o.currentConv?(e.openBlock(),e.createBlock(w,{key:3,"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[4]||(n[4]=V=>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)],2)}const $e=N(Ss,[["render",$s],["__scopeId","data-v-4500d0e5"]]),Fs="0.3.12";exports.AIAvatar=j;exports.AVATAR_COLORS=W;exports.ActionResult=ve;exports.ApprovalCard=Ie;exports.ArtifactFormResponse=ye;exports.ArtifactInfoCard=ke;exports.ArtifactRenderer=be;exports.ArtifactTicket=we;exports.AttachmentPreview=Ee;exports.Bubble=Be;exports.Composer=xe;exports.DEFAULT_BASE_URL=me;exports.Feedback=Le;exports.FormCard=De;exports.Header=_e;exports.HumanAvatar=te;exports.Launcher=fe;exports.MEDIA_RECORDER_SUPPORTED=Y;exports.MessageList=Se;exports.Messenger=$e;exports.MoreMenu=Re;exports.Onboarding=ge;exports.SCREEN_CAPTURE_SUPPORTED=z;exports.SuggestionChips=Oe;exports.TeamAvatars=pe;exports.Typing=Ne;exports.VERSION=Fs;exports.avatarColor=Q;exports.avatarInitials=Z;exports.captureScreenshotFile=Me;exports.colors=A;exports.createStore=de;exports.createTransport=ce;exports.default=$e;exports.formatTime=ee;exports.guessAttachmentKind=Jr;exports.pickRecorderMime=Ve;exports.renderMarkdown=Ce;exports.startScreenRecording=Te;exports.tokensCss=ue;exports.uuid=J;exports.v4=J;
|
|
50
|
+
`)}function Ge(t,n){const r=[],o=Array.isArray(t==null?void 0:t.fields)?t.fields:[];for(const a of o){if(!(a!=null&&a.key)||!(a!=null&&a.label))continue;const s=n==null?void 0:n[a.key];if(s==null||s==="")continue;const i=fe(a,s);if(!i)continue;const l=a.type==="textarea"||typeof i=="string"&&(i.length>60||i.includes(`
|
|
51
|
+
`));r.push({label:a.label,value:i,multiline:l})}return{kind:"form_response",data:{title:(t==null?void 0:t.title)||"Formulaire",fields:r}}}function H(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 $(t){if(t==null)return null;const n=typeof t=="number"?t:Number(t);return Number.isFinite(n)?n:null}function oe(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 o of n)o!=null&&o.created_at&&o.created_at>r&&(r=o.created_at);return r}function Ye(t,n){var r,o,a;for(let s=n.length-1;s>=0;s--){const i=n[s];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 p=(o=i.payload)==null?void 0:o.attachments;if(Array.isArray(p)&&p.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 Xe(t){return(t==null?void 0:t.name)||((t==null?void 0:t.type)==="user"?"Vous":(t==null?void 0:t.type)==="agent_human"?"Agent":(t==null?void 0:t.type)==="agent_ia"?"Assistant IA":"Système")}function Je(t,n){const r=[`# ${t.name||"Conversation"}`,t.created_at?`Créée le : ${t.created_at}`:"",""];for(const o of n){if(!o)continue;const a=(o.text_md||"").trim();if(!a)continue;const s=Xe(o.author),i=o.created_at?new Date(o.created_at).toLocaleString("fr-FR"):"";r.push(`[${i}] ${s} :`),r.push(a),r.push("")}return r.join(`
|
|
52
|
+
`)}function Qe(t,n){if(!t)return;const r=Je(t,n||[]),o=new Blob([r],{type:"text/plain;charset=utf-8"});try{const a=URL.createObjectURL(o),s=document.createElement("a");s.href=a,s.download=`${(t.name||"conversation").replace(/[^a-z0-9-_]+/gi,"_")}.txt`,document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>URL.revokeObjectURL(a),1e3)}catch(a){console.error("[ww-messenger] export failed",a)}}const Ze={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||""}:${this.userId||""}`},browserNotifStorageKey(){return`wm:notif:browser:${this.widgetId||""}:${this.userId||""}`},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||!H(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,o=n.createOscillator(),a=n.createGain();o.connect(a),a.connect(n.destination),o.type="sine",o.frequency.setValueAtTime(880,r),o.frequency.exponentialRampToValueAtTime(1320,r+.08),a.gain.setValueAtTime(0,r),a.gain.linearRampToValueAtTime(.12,r+.02),a.gain.exponentialRampToValueAtTime(1e-4,r+.28),o.start(r),o.stop(r+.32)}catch{}},showBrowserNotification(t,n){var i;if(typeof Notification>"u"||Notification.permission!=="granted")return;const r=this.allConversations.find(l=>(l==null?void 0:l.id)===t),o=(r==null?void 0:r.name)||((i=this.widget)==null?void 0:i.name)||"Nouveau message",a=typeof(n==null?void 0:n.text_md)=="string"?n.text_md.trim():"",s=a?a.slice(0,140):"Vous avez un nouveau message";try{const l=new Notification(o,{body:s,tag:`wm-${t}`,renotify:!1,silent:!0});l.onclick=()=>{try{window.focus()}catch{}this.draftConv=null,this.showOnboarding=!1,this.activeConvId=t,this.isOpen=!0,this.store&&this.store.setPanelOpen(!0);try{l.close()}catch{}}}catch(l){console.warn("[ww-messenger] notification failed",l)}}}},et=450,tt=50,nt=900,rt=12e3,st=300,ot={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",o=>{const a=o==null?void 0:o.conversation_id,s=o==null?void 0:o.message;a&&s&&this.paceLiveMessage(s,a)});this._liveRevealConvSnapshot=new Map((((r=this.s)==null?void 0:r.conversations)||[]).map(o=>[o.id,(o==null?void 0:o.last_message_at)||""]));const n=this.transport.on("activity",o=>{this.handleLiveActivity(o)});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,s;const n=t==null?void 0:t.conversations;if(!Array.isArray(n)||!this.store)return;const r=this._liveRevealConvSnapshot||new Map,o=[];for(const i of n){if(!(i!=null&&i.id))continue;const l=i.last_message_at||"";if(!l)continue;const p=r.get(i.id)||"";l>p&&o.push(i.id)}this._liveRevealConvSnapshot=new Map(n.map(i=>[i.id,(i==null?void 0:i.last_message_at)||""]));for(const i of o)try{const l=await((s=(a=this.store).fetchSinceLast)==null?void 0:s.call(a,i));if(!Array.isArray(l))continue;for(const p of l)this.paceLiveMessage(p,i)}catch(l){console.error("[ww-messenger] activity delta fetch failed",l)}},scheduleReveal(t,n){const r=Date.now(),o=((t==null?void 0:t.text_md)||"").length,a=Math.min(rt,Math.max(nt,o*tt)),i=Math.max(r+et,this.nextRevealAt+st)+a;this.nextRevealAt=i;const l=Math.max(0,i-r),p=t.id,y=setTimeout(()=>{this.revealedAt={...this.revealedAt,[p]:Date.now()},this.revealTimers=this.revealTimers.filter(v=>v!==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(),o={...this.revealedAt};for(const s of t){if((s==null?void 0:s.id)==null||o[s.id]!==void 0)continue;if(!H(s)){o[s.id]=r;continue}const i=s!=null&&s.created_at?Date.parse(s.created_at):NaN;if(!Number.isFinite(i)||i<this.convOpenedAt){o[s.id]=r;continue}const l=typeof(s==null?void 0:s.text_md)=="string"&&s.text_md.trim().length>0,p=Array.isArray((a=s==null?void 0:s.payload)==null?void 0:a.attachments)&&s.payload.attachments.length>0;if(!l&&!p){o[s.id]=r;continue}o[s.id]=0,this.scheduleReveal(s,n)}this.revealedAt=o},paceLiveMessage(t,n){var a;if(!(t!=null&&t.id)||this.revealedAt[t.id]!==void 0)return;if(!H(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,o=Array.isArray((a=t==null?void 0:t.payload)==null?void 0:a.attachments)&&t.payload.attachments.length>0;if(!r&&!o){this.revealedAt={...this.revealedAt,[t.id]:Date.now()};return}this.revealedAt={...this.revealedAt,[t.id]:0},this.scheduleReveal(t,n)}}},at={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)}}},it=300,lt={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 s,i;if(!(t!=null&&t.id)||t._draft||!this.store)return;const n=((i=(s=this.s)==null?void 0:s.messagesByConv)==null?void 0:i[t.id])||[],r=ct(n);if(r==null)return;const o=$(t.last_read_message_id),a=$(r);a!=null&&(o!=null&&a<=o||(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)},it))))}}};function ct(t){for(let n=t.length-1;n>=0;n--){const r=t[n];if(!(!r||r._pending)&&$(r.id)!=null)return r.id}return null}const B=(t,n)=>{const r=t.__vccOpts||t;for(const[o,a]of n)r[o]=a;return r},dt={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":Z(this.name)},initials(){return ee(this.name)}}},ut=["src","alt"];function mt(t,n,r,o,a,s){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:s.bg})},[r.avatarUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.avatarUrl,alt:r.name||""},null,8,ut)):(e.openBlock(),e.createElementBlock("span",{key:1,style:e.normalizeStyle({fontSize:r.size*.36+"px"})},e.toDisplayString(s.initials),5))],6)}const ne=B(dt,[["render",mt],["__scopeId","data-v-07246775"]]),ht=3,ft={name:"WmLauncher",components:{HumanAvatar:ne},props:{unreadCount:{type:Number,default:0},peeks:{type:Array,default:()=>[]}},emits:["open","dismiss"],computed:{visiblePeeks(){return this.peeks.slice(0,ht).reverse()}}},pt={class:"wm-launcherWrap"},_t=["aria-label","onClick","onKeydown"],gt=["onClick"],vt={class:"wm-peek__avatar"},yt=["aria-label"],kt={class:"wm-peek__body"},wt={class:"wm-peek__head"},bt={class:"wm-peek__name"},Et={class:"wm-peek__text"},Ct=["onClick"],Bt=["aria-label"];function Nt(t,n,r,o,a,s){const i=e.resolveComponent("HumanAvatar");return e.openBlock(),e.createElementBlock("div",pt,[e.createVNode(e.Transition,{name:"wm-peek"},{default:e.withCtx(()=>[s.visiblePeeks.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["wm-peekStack",{"wm-peekStack--multi":s.visiblePeeks.length>1}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.visiblePeeks,(l,p)=>(e.openBlock(),e.createElementBlock("div",{key:l.convId,class:"wm-peek",style:e.normalizeStyle({"--depth":s.visiblePeeks.length-1-p,zIndex:p+1}),role:"button",tabindex:"0","aria-label":`Ouvrir la conversation avec ${l.senderName||"l'agent"}`,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":"Ignorer",onClick:e.withModifiers(y=>t.$emit("dismiss",l.convId),["stop"])},[...n[1]||(n[1]=[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,gt),e.createElementVNode("div",vt,[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":`${l.count} messages non lus`},e.toDisplayString(l.count>9?"9+":l.count),9,yt)):e.createCommentVNode("",!0)]),e.createElementVNode("div",kt,[e.createElementVNode("div",wt,[e.createElementVNode("span",bt,e.toDisplayString(l.senderName||"Agent"),1),n[2]||(n[2]=e.createElementVNode("span",{class:"wm-peek__action"}," vous a répondu",-1))]),e.createElementVNode("p",Et,e.toDisplayString(l.preview),1)]),e.createElementVNode("button",{type:"button",class:"wm-peek__open",onClick:e.withModifiers(y=>t.$emit("open",l.convId),["stop"])},"Ouvrir",8,Ct)],44,_t))),128))],2)):e.createCommentVNode("",!0)]),_:1}),e.createElementVNode("button",{type:"button",class:"wm-launcher","aria-label":"Ouvrir le messenger",onClick:n[0]||(n[0]=l=>t.$emit("open"))},[n[3]||(n[3]=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} conversation${r.unreadCount>1?"s":""} non lue${r.unreadCount>1?"s":""}`},e.toDisplayString(r.unreadCount>9?"9+":r.unreadCount),9,Bt)):e.createCommentVNode("",!0)])])}const pe=B(ft,[["render",Nt],["__scopeId","data-v-525fd423"]]),St={name:"WmAIAvatar",props:{size:{type:Number,default:26},pulse:{type:Boolean,default:!1},tail:{type:Boolean,default:!1}}},At={key:0,class:"wm-aiav__pulse"},Vt=["width","height"];function Mt(t,n,r,o,a,s){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",At)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["wm-aiav__inner",{"wm-aiav__inner--glow":r.pulse}])},[(e.openBlock(),e.createElementBlock("svg",{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,Vt))],2)],6)}const j=B(St,[["render",Mt],["__scopeId","data-v-8c924688"]]),Tt={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":Z(t.name||"")},initialsFor(t){return ee(t.name||"")}}},xt={key:0,class:"wm-team"},Ot=["src","alt"],It={key:1},Lt={key:0,class:"wm-team__label"};function Rt(t,n,r,o,a,s){return s.visible?(e.openBlock(),e.createElementBlock("div",xt,[e.createElementVNode("div",{class:"wm-team__stack",style:e.normalizeStyle({width:s.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:s.colorFor(i)})},[i.avatar_url?(e.openBlock(),e.createElementBlock("img",{key:0,src:i.avatar_url,alt:i.name||""},null,8,Ot)):(e.openBlock(),e.createElementBlock("span",It,e.toDisplayString(s.initialsFor(i)),1))],4))),128))],4),r.responseLabel?(e.openBlock(),e.createElementBlock("span",Lt,e.toDisplayString(r.responseLabel),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}const _e=B(Tt,[["render",Rt],["__scopeId","data-v-3659b9c1"]]),Dt={name:"WmHeader",components:{AIAvatar:j,TeamAvatars:_e},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}},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 o=0;o<3;o++)r.push(t[(n+o)%t.length]);return r}}},$t={class:"wm-header"},Ft={key:1,style:{width:"30px",height:"30px","flex-shrink":"0"}},Pt={class:"wm-header__avatar"},jt={class:"wm-header__main"},zt={class:"wm-header__title"},Ut={key:3,class:"wm-header__fill"},Ht={class:"wm-header__actions"};function qt(t,n,r,o,a,s){const i=e.resolveComponent("AIAvatar"),l=e.resolveComponent("TeamAvatars");return e.openBlock(),e.createElementBlock("div",$t,[r.showBack?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-header__icon","aria-label":"Retour à l'accueil",onClick:n[0]||(n[0]=p=>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)])])):(e.openBlock(),e.createElementBlock("div",Ft)),r.showIdentity?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createElementVNode("div",Pt,[e.createVNode(i,{size:30})]),e.createElementVNode("div",jt,[e.createElementVNode("div",zt,e.toDisplayString(r.title),1)]),s.hasTeam?(e.openBlock(),e.createBlock(l,{key:0,members:s.displayedTeamMembers,"response-label":""},null,8,["members"])):e.createCommentVNode("",!0)],64)):(e.openBlock(),e.createElementBlock("div",Ut)),e.createElementVNode("div",Ht,[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":"Plus d'options",title:"Plus d'options",onClick:n[1]||(n[1]=p=>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)])],2)):e.createCommentVNode("",!0),r.showClose?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-header__icon","aria-label":"Fermer le widget",title:"Fermer le widget",onClick:n[2]||(n[2]=p=>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)])])):e.createCommentVNode("",!0)])])}const ge=B(Dt,[["render",qt],["__scopeId","data-v-ef4b443e"]]),ae={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"},Kt={name:"WmOnboarding",components:{AIAvatar:j},props:{welcomeMessage:{type:String,default:""},agentName:{type:String,default:""},quickLinks:{type:Array,default:()=>[]},openThreads:{type:Array,default:()=>[]},busy:{type:Boolean,default:!1}},emits:["start","select","resume"],data(){return{query:""}},computed:{heroTitle(){return this.welcomeMessage?this.welcomeMessage:this.agentName?`Bonjour, je suis ${this.agentName}`:"Bonjour, je suis votre assistant"},heroSub(){return`Posez-moi n'importe quelle question.
|
|
53
|
+
Je réponds en quelques secondes.`},isOddQuickLinks(){return this.quickLinks.length%2===1},quickLinksLayout(){return this.isOddQuickLinks?"wm-onb__qlist":"wm-onb__grid"},filteredThreads(){const t=this.query.trim().toLowerCase();return t?this.openThreads.filter(n=>(n.title||"").toLowerCase().includes(t)||(n.preview||"").toLowerCase().includes(t)):this.openThreads}},methods:{iconPath(t){return ae[t]||ae.link},formatTs(t){if(!t)return"";const n=new Date(t);if(Number.isNaN(n.getTime()))return"";const r=new Date;if(n.toDateString()===r.toDateString()){const s=String(n.getHours()).padStart(2,"0"),i=String(n.getMinutes()).padStart(2,"0");return`${s}h${i}`}if(r.getTime()-n.getTime()<7*864e5){const s=n.toLocaleDateString("fr-FR",{weekday:"short"});return s.charAt(0).toUpperCase()+s.slice(1)}return n.toLocaleDateString("fr-FR",{day:"2-digit",month:"2-digit"})}}},Wt={class:"wm-onb"},Gt={class:"wm-onb__hero"},Yt={class:"wm-onb__title"},Xt={class:"wm-onb__sub"},Jt={class:"wm-onb__cta"},Qt=["disabled"],Zt={key:0,class:"wm-onb__section"},en=["onClick"],tn={class:"wm-onb__card-icon"},nn={width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.7","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},rn=["d"],sn={class:"wm-onb__card-body"},on={class:"wm-onb__card-title"},an={key:0,class:"wm-onb__card-sub"},ln={key:1,class:"wm-onb__section"},cn={class:"wm-onb__search"},dn={class:"wm-onb__list"},un=["onClick"],mn={key:0,class:"wm-onb__thread-dot","aria-label":"Non lu"},hn={class:"wm-onb__thread-body"},fn={class:"wm-onb__thread-title"},pn={class:"wm-onb__thread-preview"},_n={class:"wm-onb__thread-meta"},gn={key:0,class:"wm-onb__thread-time"},vn={key:0,class:"wm-onb__empty"};function yn(t,n,r,o,a,s){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",Wt,[e.createElementVNode("div",Gt,[e.createVNode(i,{size:56,pulse:!0}),e.createElementVNode("div",Yt,e.toDisplayString(s.heroTitle),1),e.createElementVNode("div",Xt,e.toDisplayString(s.heroSub),1)]),e.createElementVNode("div",Jt,[e.createElementVNode("button",{type:"button",class:"wm-onb__startBtn",disabled:r.busy,onClick:n[0]||(n[0]=l=>t.$emit("start"))},[n[2]||(n[2]=e.createElementVNode("span",{class:"wm-onb__startIcon"},[e.createElementVNode("svg",{width:"12",height:"12",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:"M12 5v14M5 12h14"})])],-1)),e.createElementVNode("span",null,e.toDisplayString(r.busy?"…":"Commencer une conversation"),1)],8,Qt)]),r.quickLinks.length?(e.openBlock(),e.createElementBlock("div",Zt,[n[3]||(n[3]=e.createElementVNode("div",{class:"wm-onb__section-title"},"Accès rapide",-1)),e.createElementVNode("div",{class:e.normalizeClass(s.quickLinksLayout)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.quickLinks,(l,p)=>(e.openBlock(),e.createElementBlock("button",{key:p,type:"button",class:e.normalizeClass(["wm-onb__card",{"wm-onb__card--row":s.isOddQuickLinks}]),onClick:y=>t.$emit("select",l)},[e.createElementVNode("span",tn,[(e.openBlock(),e.createElementBlock("svg",nn,[e.createElementVNode("path",{d:s.iconPath(l.icon)},null,8,rn)]))]),e.createElementVNode("span",sn,[e.createElementVNode("span",on,e.toDisplayString(l.label),1),l.description?(e.openBlock(),e.createElementBlock("span",an,e.toDisplayString(l.description),1)):e.createCommentVNode("",!0)])],10,en))),128))],2)])):e.createCommentVNode("",!0),r.openThreads.length?(e.openBlock(),e.createElementBlock("div",ln,[n[7]||(n[7]=e.createElementVNode("div",{class:"wm-onb__section-title"},"Conversations récentes",-1)),e.createElementVNode("div",cn,[n[4]||(n[4]=e.createElementVNode("span",{class:"wm-onb__searchIcon"},[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:"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[1]||(n[1]=l=>a.query=l),type:"text",placeholder:"Rechercher dans vos messages","aria-label":"Rechercher dans vos messages"},null,512),[[e.vModelText,a.query]])]),e.createElementVNode("div",dn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.filteredThreads,l=>(e.openBlock(),e.createElementBlock("button",{key:l.id,type:"button",class:"wm-onb__thread",onClick:p=>t.$emit("resume",l)},[e.createElementVNode("span",{class:e.normalizeClass(["wm-onb__thread-icon",{"wm-onb__thread-icon--inverted":!l.unread}])},[n[5]||(n[5]=e.createElementVNode("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[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:"currentColor",opacity:"0.92"})],-1)),l.unread?(e.openBlock(),e.createElementBlock("span",mn)):e.createCommentVNode("",!0)],2),e.createElementVNode("span",hn,[e.createElementVNode("span",fn,e.toDisplayString(l.title),1),e.createElementVNode("span",pn,e.toDisplayString(l.preview),1)]),e.createElementVNode("span",_n,[s.formatTs(l._ts)?(e.openBlock(),e.createElementBlock("span",gn,e.toDisplayString(s.formatTs(l._ts)),1)):e.createCommentVNode("",!0),n[6]||(n[6]=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-onb__thread-chev","aria-hidden":"true"},[e.createElementVNode("path",{d:"M5 12h14M13 5l7 7-7 7"})],-1))])],8,un))),128)),s.filteredThreads.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",vn," Aucun résultat pour « "+e.toDisplayString(a.query)+" ». ",1))])])):e.createCommentVNode("",!0)])}const ve=B(Kt,[["render",yn],["__scopeId","data-v-c85f6958"]]);function kn(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 wn={name:"WmActionResult",props:{state:{type:String,default:"success"},label:{type:String,required:!0},detail:{type:String,default:""}},computed:{detailText(){return kn(this.detail)}}},bn={class:"wm-result__icon","aria-hidden":"true"},En={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"},Cn={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"},Bn={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"},Nn={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"},Sn={class:"wm-result__body"},An={class:"wm-result__label"},Vn={class:"wm-result__detail"};function Mn(t,n,r,o,a,s){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-result",`wm-result--${r.state}`])},[e.createElementVNode("span",bn,[r.state==="success"?(e.openBlock(),e.createElementBlock("svg",En,[...n[0]||(n[0]=[e.createElementVNode("path",{d:"M20 6L9 17l-5-5"},null,-1)])])):r.state==="rejected"?(e.openBlock(),e.createElementBlock("svg",Cn,[...n[1]||(n[1]=[e.createElementVNode("path",{d:"M18 6L6 18M6 6l12 12"},null,-1)])])):r.state==="awaiting"?(e.openBlock(),e.createElementBlock("svg",Bn,[...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",Nn,[...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",Sn,[e.createElementVNode("span",An,e.toDisplayString(r.label),1),s.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",Vn,e.toDisplayString(s.detailText),1)],64)):e.createCommentVNode("",!0)])],2)}const ye=B(wn,[["render",Mn],["__scopeId","data-v-64a83fb8"]]),Tn={name:"WmArtifactFormResponse",props:{data:{type:Object,required:!0}},computed:{fields(){var t;return Array.isArray((t=this.data)==null?void 0:t.fields)?this.data.fields:[]}}},xn={class:"wm-art wm-art--formResponse"},On={class:"wm-art__head"},In={class:"wm-art__title"},Ln={class:"wm-art__body"},Rn={class:"wm-art__fieldLabel"};function Dn(t,n,r,o,a,s){return e.openBlock(),e.createElementBlock("div",xn,[e.createElementVNode("div",On,[e.createElementVNode("div",In,e.toDisplayString(r.data.title||"Formulaire"),1),n[0]||(n[0]=e.createElementVNode("span",{class:"wm-art__badge wm-art__badge--success"},[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"})]),e.createTextVNode(" Envoyé ")],-1))]),e.createElementVNode("div",Ln,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.fields,(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",Rn,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 ke=B(Tn,[["render",Dn],["__scopeId","data-v-ca24a9c9"]]),$n={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}}},Fn={class:"wm-art wm-art--infoCard"},Pn={key:0,class:"wm-art__image"},jn=["src","alt"],zn={class:"wm-art__head"},Un={class:"wm-art__headMain"},Hn={class:"wm-art__title"},qn={key:0,class:"wm-art__subtitle"},Kn={key:1,class:"wm-art__body"},Wn={key:0,class:"wm-art__text"},Gn={class:"wm-art__fieldLabel"};function Yn(t,n,r,o,a,s){return e.openBlock(),e.createElementBlock("div",Fn,[r.data.image_url?(e.openBlock(),e.createElementBlock("figure",Pn,[e.createElementVNode("img",{src:r.data.image_url,alt:r.data.title||"",loading:"lazy"},null,8,jn)])):e.createCommentVNode("",!0),e.createElementVNode("div",zn,[e.createElementVNode("div",Un,[e.createElementVNode("div",Hn,e.toDisplayString(r.data.title),1),r.data.subtitle?(e.openBlock(),e.createElementBlock("div",qn,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)]),s.hasBody?(e.openBlock(),e.createElementBlock("div",Kn,[r.data.body?(e.openBlock(),e.createElementBlock("div",Wn,e.toDisplayString(r.data.body),1)):e.createCommentVNode("",!0),s.fields.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(s.fields,(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",Gn,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 we=B($n,[["render",Yn],["__scopeId","data-v-d7369333"]]);function Xn(t){if(!t)return"";const n=new Date(t);if(Number.isNaN(n.getTime()))return t;const r=n.toLocaleDateString("fr-FR",{day:"numeric",month:"long",year:"numeric"}),o=n.toLocaleTimeString("fr-FR",{hour:"2-digit",minute:"2-digit"});return`${r} à ${o}`}const Jn={name:"WmArtifactTicket",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 Xn((t=this.data)==null?void 0:t.created_at)}},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}}},Qn={class:"wm-art wm-art--ticket"},Zn={class:"wm-art__head wm-tk__head"},er={class:"wm-art__title wm-tk__title"},tr={class:"wm-tk__sub"},nr={class:"wm-tk__ref"},rr={key:0,class:"wm-tk__text"},sr={key:0,class:"wm-art__body"},or={class:"wm-art__fieldLabel"},ar=["data-level"],ir={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"},lr={key:1,class:"wm-art__footer wm-tk__footer"};function cr(t,n,r,o,a,s){return e.openBlock(),e.createElementBlock("div",Qn,[e.createElementVNode("div",Zn,[e.createElementVNode("div",er,e.toDisplayString(r.data.title),1),e.createElementVNode("div",tr,[e.createElementVNode("div",nr,[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",rr,e.toDisplayString(r.data.body),1)):e.createCommentVNode("",!0)]),s.fields.length?(e.openBlock(),e.createElementBlock("div",sr,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.fields,(i,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,class:"wm-art__field"},[e.createElementVNode("div",or,e.toDisplayString(i.label),1),e.createElementVNode("div",{class:e.normalizeClass(["wm-art__fieldValue",{"wm-art__fieldValue--multi":i.multiline}])},[s.isPriority(i.label)?(e.openBlock(),e.createElementBlock("svg",{key:0,class:"wm-tk__prio","data-level":s.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,ar)):s.isDate(i.label)?(e.openBlock(),e.createElementBlock("svg",ir,[...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",lr,[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(s.formattedDate),1)])):e.createCommentVNode("",!0)])}const be=B(Jn,[["render",cr],["__scopeId","data-v-8b274eb7"]]),dr={form_response:ke,info_card:we,ticket:be},ur={name:"WmArtifactRenderer",props:{artifact:{type:Object,required:!0}},computed:{component(){var n;const t=(n=this.artifact)==null?void 0:n.kind;return t&&dr[t]||null}}};function mr(t,n,r,o,a,s){return s.component?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(s.component),{key:0,data:r.artifact.data},null,8,["data"])):e.createCommentVNode("",!0)}const Ee=B(ur,[["render",mr]]),hr={name:"WmAttachmentPreview",inject:{signAttachmentFn:{default:null}},props:{attachment:{type:Object,required:!0}},data(){return{url:null,loading:!1}},computed:{kind(){var r,o;const t=(r=this.attachment)==null?void 0:r.type;if(t)return t;const n=(((o=this.attachment)==null?void 0:o.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()||"Pièce jointe"},sizeLabel(){var n;const t=(n=this.attachment)==null?void 0:n.size_bytes;return t?t<1024?`${t} o`:t<1024*1024?`${(t/1024).toFixed(0)} ko`:`${(t/(1024*1024)).toFixed(1)} Mo`:""}},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.url||t.preventDefault()}}},fr=["href"],pr=["src","alt"],_r=["src"],gr=["src"],vr=["href","download"],yr={class:"wm-att__main"},kr={class:"wm-att__name"},wr={key:0,class:"wm-att__meta"},br={key:0,class:"wm-att__spin","aria-hidden":"true"};function Er(t,n,r,o,a,s){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-att",["wm-att--"+(s.kind||"file")]])},[s.kind==="image"&&a.url?(e.openBlock(),e.createElementBlock("a",{key:0,href:a.url,target:"_blank",rel:"noopener",class:"wm-att__imgWrap"},[e.createElementVNode("img",{src:a.url,alt:s.displayName,loading:"lazy"},null,8,pr)],8,fr)):s.kind==="audio"&&a.url?(e.openBlock(),e.createElementBlock("audio",{key:1,src:a.url,controls:"",preload:"metadata"},null,8,_r)):s.kind==="video"&&a.url?(e.openBlock(),e.createElementBlock("video",{key:2,src:a.url,controls:"",preload:"metadata"},null,8,gr)):(e.openBlock(),e.createElementBlock("a",{key:3,class:"wm-att__file",href:a.url||"#",download:s.displayName,target:"_blank",rel:"noopener",onClick:n[0]||(n[0]=(...i)=>s.onFileClick&&s.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",yr,[e.createElementVNode("span",kr,e.toDisplayString(s.displayName),1),s.sizeLabel?(e.openBlock(),e.createElementBlock("span",wr,e.toDisplayString(s.sizeLabel),1)):e.createCommentVNode("",!0)]),a.loading?(e.openBlock(),e.createElementBlock("span",br)):e.createCommentVNode("",!0)],8,vr))],2)}const Ce=B(hr,[["render",Er],["__scopeId","data-v-1cd1267b"]]);function Cr(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Br(t){return/^(https?:\/\/|mailto:|tel:)/i.test(String(t).trim())}const ie="";function G(t){let n=t;const r=[];return n=n.replace(/`([^`\n]+)`/g,(o,a)=>{const s=r.length;return r.push(a),`${ie}CODE${s}${ie}`}),n=n.replace(/\[([^\]\n]+)\]\(([^)\s]+)\)/g,(o,a,s)=>Br(s)?`<a href="${s}" 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,(o,a)=>`<code class="wm-md-code">${r[+a]}</code>`),n}function Be(t){if(!t)return"";const n=Cr(t).split(`
|
|
54
|
+
`),r=[];let o=0;for(;o<n.length;){const s=n[o];if(/^\s*```([\w-]*)\s*$/.exec(s)){o++;const y=[];for(;o<n.length&&!/^\s*```\s*$/.test(n[o]);)y.push(n[o]),o++;o<n.length&&o++,r.push({type:"block",html:`<pre class="wm-md-pre"><code>${y.join(`
|
|
55
|
+
`)}</code></pre>`});continue}if(/^\s*[-*]\s+/.test(s)){const y=[];for(;o<n.length;){const E=/^\s*[-*]\s+(.*)$/.exec(n[o]);if(!E)break;y.push(E[1]),o++}const v=y.map(E=>`<li>${G(E)}</li>`).join("");r.push({type:"block",html:`<ul class="wm-md-ul">${v}</ul>`});continue}const l=/^\s*(\d+)\.\s+(.*)$/.exec(s);if(l){const y=parseInt(l[1],10),v=[l[2]];for(o++;o<n.length;){const k=/^\s*\d+\.\s+(.*)$/.exec(n[o]);if(!k)break;v.push(k[1]),o++}const E=v.map(k=>`<li>${G(k)}</li>`).join(""),N=y!==1?` start="${y}"`:"";r.push({type:"block",html:`<ol class="wm-md-ol"${N}>${E}</ol>`});continue}const p=/^(#{1,6})\s+(.*)$/.exec(s);if(p){const y=p[1].length;r.push({type:"block",html:`<h${y} class="wm-md-h wm-md-h${y}">${G(p[2])}</h${y}>`}),o++;continue}r.push({type:"text",html:G(s)}),o++}let a="";for(let s=0;s<r.length;s++){const i=r[s];a+=i.html;const l=r[s+1];l&&i.type!=="block"&&l.type!=="block"&&(a+=`
|
|
56
|
+
`)}return a}const Nr={name:"WmBubble",props:{role:{type:String,default:"ai"},text:{type:String,default:""}},computed:{rendered(){return Be(this.text)}}},Sr=["innerHTML"];function Ar(t,n,r,o,a,s){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-bubble","wm-bubble--"+r.role])},[e.renderSlot(t.$slots,"default",{},()=>[e.createElementVNode("span",{innerHTML:s.rendered},null,8,Sr)],!0)],2)}const Ne=B(Nr,[["render",Ar],["__scopeId","data-v-5c9e9f2b"]]),Vr={name:"WmTyping"},Mr={class:"wm-typing"};function Tr(t,n,r,o,a,s){return e.openBlock(),e.createElementBlock("div",Mr,[...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 Se=B(Vr,[["render",Tr],["__scopeId","data-v-df2447fd"]]);function U(t){return t?t.client_msg_id||t.id:""}const xr={transferred_to_human:"Conversation transférée à un humain",assigned:"{name} a rejoint la conversation",unassigned:"L'agent a quitté la conversation",resolved:"Conversation résolue",reopened:"Conversation rouverte",idle:"Conversation en pause"},Or=80,Ir=200,Lr={name:"WmMessageList",components:{AIAvatar:j,HumanAvatar:ne,Bubble:Ne,Typing:Se,ActionResult:ye,AttachmentPreview:Ce,ArtifactRenderer:Ee},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:""}},emits:["load-more"],data(){return{silentFades:!1,widthByKey:Object.freeze({})}},computed:{historyExhausted(){return!this.hasMore&&!this.loadingMore&&this.messages.length>=20},groups(){var r,o,a,s;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 v=t[t.length-1];v&&v.role==="ai"?v.messages.push(i):t.push({key:`g-${U(i)}`,role:"ai",agentName:"",agentAvatarUrl:null,messages:[i],items:[]});continue}t.push({key:`sys-${U(i)}`,role:l,messages:[i],items:[],systemLabel:this.systemLabel(i)});continue}const p=t[t.length-1];p&&p.role===l&&(l==="ai"||p.agentName===(((o=i==null?void 0:i.author)==null?void 0:o.name)||""))?p.messages.push(i):t.push({key:`g-${U(i)}`,role:l,agentName:((a=i==null?void 0:i.author)==null?void 0:a.name)||"",agentAvatarUrl:((s=i==null?void 0:i.author)==null?void 0:s.avatar_url)||null,messages:[i],items:[]})}for(const i of t){if(i.role==="system")continue;const l=[];for(const p of i.messages)for(const y of this.itemsOf(p))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)}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 o=r.messages[0];if(!o)continue;const a=$(o.id);if(a!=null&&!(a<=t)&&!(n&&o.created_at&&o.created_at>n))return r.key}return null}},watch:{messages:{handler:"snapshotAndRestore",deep:!0},loadingMore(t){t||(this._pendingLoadMore=!1),this.silentFades=!0,clearTimeout(this._silenceTimer),t||(this._silenceTimer=setTimeout(()=>{this.silentFades=!1},250)),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),clearTimeout(this._silenceTimer)},updated(){this.scheduleMeasure()},methods:{messageKey:U,isAtBottom(t){return t.scrollHeight-t.scrollTop-t.clientHeight<=Or},onScroll(){const t=this.$refs.scrollEl;t&&(this.loadingMore||!this.hasMore||this._pendingLoadMore||t.scrollTop<=Ir&&(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 o=null;if(!n&&!r){const s=this.pickAnchor(t);if(s!=null&&s.el){const i=t.getBoundingClientRect().top;o={el:s.el,relY:s.el.getBoundingClientRect().top-i}}}const a={forceBottom:n,wasPinned:r,anchor:o};this._scrollSnap=a,this.$nextTick(()=>{if(this._scrollSnap=null,a.forceBottom||a.wasPinned){t.scrollTop=t.scrollHeight;return}if(!a.anchor)return;const s=()=>{var y;const i=a.anchor;if(!((y=i.el)!=null&&y.isConnected))return;const p=i.el.getBoundingClientRect().top-t.getBoundingClientRect().top-i.relY;Math.abs(p)>.5&&(t.scrollTop+=p)};s(),requestAnimationFrame(()=>{s(),requestAnimationFrame(s)})})},pickAnchor(t){const n=t.scrollTop;let r=null;for(const o of t.children)if(o.classList.contains("wm-list__group")&&(r||(r=o),o.offsetTop+o.offsetHeight>=n))return{el:o,offsetTop:o.offsetTop};return r?{el:r,offsetTop:r.offsetTop}:null},roleOf(t){var r,o;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=(o=t==null?void 0:t.author)==null?void 0:o.type;return n==="user"?"user":n==="agent_human"?"human":"ai"},roleLabel(t){return t.role==="human"?t.agentName||"Agent":"Assistant IA"},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 F,P,L;const r=t.items,o=(F=r[n])==null?void 0:F.kind,a=(P=r[n-1])==null?void 0:P.kind,s=(L=r[n+1])==null?void 0:L.kind,i=t.role==="user",l=14,p=4,y=a==null?void 0:a.bottom,v=s==null?void 0:s.top,E=this.widthByKey[this.rowKeyOf(t,n)],N=this.widthByKey[this.rowKeyOf(t,n-1)],k=this.widthByKey[this.rowKeyOf(t,n+1)],x=.5,b=(R,D,O)=>R!=null&&E!=null?R+x>=E:D===O||D==="card"&&O==="bubble";let M=l,S=l,T=l,I=l;return i?(y&&(S=p),(v||!s)&&(T=p),y&&b(N,y,o==null?void 0:o.top)&&(M=p),v&&b(k,v,o==null?void 0:o.bottom)&&(I=p)):(y&&(M=p),(v||!s)&&(I=p),y&&b(N,y,o==null?void 0:o.top)&&(S=p),v&&b(k,v,o==null?void 0:o.bottom)&&(T=p)),{tl:M,tr:S,br:T,bl:I}},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 o;const r=(o=t==null?void 0:t.items)==null?void 0:o[n];return r?`${U(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 s of t.querySelectorAll(".wm-list__row[data-row-key]")){const i=s.dataset.rowKey;if(!i)continue;const l=s.querySelector(".wm-bubble, .wm-result, .wm-art, .wm-list__body");if(!l)continue;const p=l.getBoundingClientRect().width;p>0&&(n[i]=p)}const r=this.widthByKey,o=Object.keys(r),a=Object.keys(n);if(o.length===a.length){let s=!0;for(const i of a)if(Math.abs((r[i]??0)-n[i])>.5){s=!1;break}if(s)return}this.widthByKey=Object.freeze(n)},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 te(new Date(r.created_at))}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)||"Action"},actionDetail(t){var r,o,a,s,i,l;const n=t==null?void 0:t.payload;return n?n.state==="success"?((r=n.success)==null?void 0:r.summary)||((a=(o=n.success)==null?void 0:o.metadata)==null?void 0:a.description)||"":n.state==="rejected"?((s=n.rejected)==null?void 0:s.reason)||"Action annulée par l'utilisateur.":n.state==="failure"&&(((i=n.failure)==null?void 0:i.summary)||((l=n.failure)==null?void 0:l.error))||"":""},actionArtifact(t){var r,o;const n=(o=(r=t==null?void 0:t.payload)==null?void 0:r.success)==null?void 0:o.artifact;return!n||typeof n!="object"||typeof n.kind!="string"?null:n},systemLabel(t){var a,s,i;const n=(a=t==null?void 0:t.payload)==null?void 0:a.event,r=xr[n]||(t==null?void 0:t.text_md)||"Mise à jour de la conversation",o=((s=t==null?void 0:t.metadata)==null?void 0:s.agent_name)||((i=t==null?void 0:t.author)==null?void 0:i.name)||"";return r.replace("{name}",o||"Un agent")},scrollToBottom(){const t=this.$refs.scrollEl;t&&(t.scrollTop=t.scrollHeight)}}},Rr={key:0,class:"wm-list__loadMore",role:"status","aria-live":"polite"},Dr={key:1,class:"wm-list__historyEnd"},$r={key:2,class:"wm-list__sep"},Fr={class:"wm-list__sep-label"},Pr={key:0,class:"wm-list__sep wm-list__sep--unread"},jr={key:0,class:"wm-list__sysep"},zr={class:"wm-list__sysep-label"},Ur=["data-row-key"],Hr={key:0,class:"wm-list__avatarSlot"},qr={key:5,class:"wm-list__body"},Kr={key:0},Wr={key:1,"aria-hidden":"true"},Gr={key:2},Yr={key:3,class:"wm-list__row wm-list__row--ai fade-up"},Xr={class:"wm-list__avatarSlot"};function Jr(t,n,r,o,a,s){const i=e.resolveComponent("AIAvatar"),l=e.resolveComponent("HumanAvatar"),p=e.resolveComponent("ActionResult"),y=e.resolveComponent("ArtifactRenderer"),v=e.resolveComponent("Bubble"),E=e.resolveComponent("AttachmentPreview"),N=e.resolveComponent("Typing");return e.openBlock(),e.createElementBlock("div",{ref:"scrollEl",class:e.normalizeClass(["wm-list",{"wm-list--silent":a.silentFades}]),onScrollPassive:n[0]||(n[0]=(...k)=>s.onScroll&&s.onScroll(...k))},[r.loadingMore?(e.openBlock(),e.createElementBlock("div",Rr,[...n[1]||(n[1]=[e.createElementVNode("span",{class:"wm-list__loadMore-spinner","aria-hidden":"true"},null,-1),e.createElementVNode("span",{class:"wm-list__loadMore-lbl"},"Chargement de l'historique…",-1)])])):s.historyExhausted?(e.openBlock(),e.createElementBlock("div",Dr,"Début de la conversation")):e.createCommentVNode("",!0),r.dateLabel?(e.openBlock(),e.createElementBlock("div",$r,[n[2]||(n[2]=e.createElementVNode("div",{class:"wm-list__line"},null,-1)),e.createElementVNode("span",Fr,e.toDisplayString(r.dateLabel),1),n[3]||(n[3]=e.createElementVNode("div",{class:"wm-list__line"},null,-1))])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.groups,(k,x)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:k.key},[k.key===s.unreadGroupKey?(e.openBlock(),e.createElementBlock("div",Pr,[...n[4]||(n[4]=[e.createElementVNode("div",{class:"wm-list__line wm-list__line--unread"},null,-1),e.createElementVNode("span",{class:"wm-list__sep-label wm-list__sep-label--unread"},"Non lus",-1),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",jr,[n[5]||(n[5]=e.createElementVNode("div",{class:"wm-list__line wm-list__line--strong"},null,-1)),e.createElementVNode("span",zr,e.toDisplayString(k.systemLabel),1),n[6]||(n[6]=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,M)=>(e.openBlock(),e.createElementBlock("div",{key:`${s.messageKey(b.message)}-${b.partKey}`,"data-row-key":`${s.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(s.cornersStyle(k,M))},[k.role!=="user"?(e.openBlock(),e.createElementBlock("div",Hr,[M===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})):(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(p,{key:1,state:b.message.payload.state,label:s.actionLabel(b.message),detail:s.actionDetail(b.message)},null,8,["state","label","detail"])):b.renderAs==="admin-pending"?(e.openBlock(),e.createBlock(p,{key:2,state:"awaiting",label:"Demande d'approbation envoyée",detail:b.message.text_md||""},null,8,["detail"])):b.renderAs==="artifact-of-action"?(e.openBlock(),e.createBlock(y,{key:3,artifact:s.actionArtifact(b.message)},null,8,["artifact"])):b.renderAs==="artifact"?(e.openBlock(),e.createBlock(y,{key:4,artifact:s.artifactOf(b.message)},null,8,["artifact"])):(e.openBlock(),e.createElementBlock("div",qr,[b.message.text_md?(e.openBlock(),e.createBlock(v,{key:0,role:k.role,text:b.message.text_md},null,8,["role","text"])):e.createCommentVNode("",!0),s.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(s.attachmentsOf(b.message),(S,T)=>(e.openBlock(),e.createBlock(E,{key:`${s.messageKey(b.message)}-att-${T}`,attachment:S},null,8,["attachment"]))),128))],2)):e.createCommentVNode("",!0)]))],14,Ur))),128)),(k.role!=="user"||s.lastTimeOf(k))&&!s.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",Kr,e.toDisplayString(s.roleLabel(k)),1)):e.createCommentVNode("",!0),k.role!=="user"&&s.lastTimeOf(k)?(e.openBlock(),e.createElementBlock("span",Wr,"·")):e.createCommentVNode("",!0),s.lastTimeOf(k)?(e.openBlock(),e.createElementBlock("span",Gr,e.toDisplayString(s.lastTimeOf(k)),1)):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0)],64))],2)):e.createCommentVNode("",!0)],64))),128)),r.streamingActive?(e.openBlock(),e.createElementBlock("div",Yr,[e.createElementVNode("div",Xr,[e.createVNode(i,{size:26,tail:!0})]),e.createVNode(N)])):e.createCommentVNode("",!0)],34)}const Ae=B(Lr,[["render",Jr],["__scopeId","data-v-946babe3"]]),q=typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function",X=typeof window<"u"&&typeof window.MediaRecorder<"u";function Ve(){return X&&["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"].find(n=>{var r,o;return(o=(r=window.MediaRecorder).isTypeSupported)==null?void 0:o.call(r,n)})||""}function Me({audio:t}){return{video:!0,audio:!!t,selfBrowserSurface:"include",surfaceSwitching:"include",systemAudio:t?"include":"exclude"}}function Qr(t){return t?t.startsWith("image/")?"image":t.startsWith("video/")?"video":"file":"file"}async function Te(){if(!q)return null;let t;try{t=await navigator.mediaDevices.getDisplayMedia(Me({audio:!1}))}catch(n){return(n==null?void 0:n.name)!=="NotAllowedError"&&console.error("[media] screenshot picker",n),null}try{return await Zr(t)}catch(n){return console.error("[media] screenshot capture",n),null}finally{t.getTracks().forEach(n=>{n.stop()})}}async function Zr(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,o=n.videoHeight||720,a=document.createElement("canvas");a.width=r,a.height=o,a.getContext("2d").drawImage(n,0,0,r,o);const s=await new Promise((l,p)=>{a.toBlob(y=>y?l(y):p(new Error("toBlob failed")),"image/png")}),i=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19);return new File([s],`capture-${i}.png`,{type:"image/png"})}async function xe(t={}){var y;if(!q||!X)return null;let n;try{n=await navigator.mediaDevices.getDisplayMedia(Me({audio:!0}))}catch(v){return(v==null?void 0:v.name)!=="NotAllowedError"&&console.error("[media] record picker",v),null}const r=Ve();let o;try{o=r?new window.MediaRecorder(n,{mimeType:r}):new window.MediaRecorder(n)}catch(v){return console.error("[media] recorder init",v),n.getTracks().forEach(E=>{E.stop()}),null}const a=[];let s=null,i=!1;o.addEventListener("dataavailable",v=>{v.data&&v.data.size>0&&a.push(v.data)}),o.addEventListener("stop",()=>{var v,E;if(s&&clearInterval(s),n.getTracks().forEach(N=>{N.stop()}),a.length){const N=o.mimeType||r||"video/webm",k=new Blob(a,{type:N}),x=/mp4/.test(N)?"mp4":"webm",b=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),M=new File([k],`ecran-${b}.${x}`,{type:N});(v=t.onfinalize)==null||v.call(t,M)}else(E=t.oncancel)==null||E.call(t)}),n.getVideoTracks().forEach(v=>{v.addEventListener("ended",()=>l(),{once:!0})});function l(){if(!i&&(i=!0,o.state!=="inactive"))try{o.stop()}catch(v){console.error("[media] recorder stop",v)}}try{o.start(1e3)}catch(v){return console.error("[media] recorder start",v),n.getTracks().forEach(E=>{E.stop()}),null}(y=t.onstart)==null||y.call(t);const p=Date.now();return s=setInterval(()=>{var v;(v=t.ontick)==null||v.call(t,Date.now()-p)},500),{stop:l,get state(){return o.state}}}const es=[{action:"file",label:"Joindre un fichier",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",label:"Capture d'écran",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",label:"Enregistrer l'écran",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"}],ts={name:"WmComposer",props:{modelValue:{type:String,default:""},placeholder:{type:String,default:"Écrivez votre message…"},disabled:{type:Boolean,default:!1},attachLabel:{type:String,default:"Joindre"}},emits:["update:modelValue","send","attach"],data(){return{local:this.modelValue,attachOpen:!1,recording:!1,recordingElapsed:0,recorder:null}},computed:{canSend(){return!this.disabled&&!!this.local.trim()},attachItems(){return es.map(t=>({...t,disabled:t.action==="screenshot"&&!q||t.action==="record"&&(!q||!X)}))},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()},beforeUnmount(){if(this.recorder)try{this.recorder.stop()}catch{}},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.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 Te();t&&this.$emit("attach",t)},async startRecording(){if(this.recording||this.disabled)return;this.recordingElapsed=0;const t=await xe({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)}}}},ns={class:"wm-compose-wrap"},rs={key:0,class:"wm-rec"},ss={class:"wm-rec__lbl"},os={key:1,class:"wm-compose__menu",role:"menu"},as=["disabled","onClick"],is={class:"wm-compose__menuIcon"},ls={viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true"},cs=["d"],ds=["placeholder","disabled"],us={class:"wm-compose__actions"},ms=["title","aria-label","disabled"],hs=["disabled"];function fs(t,n,r,o,a,s){return e.openBlock(),e.createElementBlock("div",ns,[a.recording?(e.openBlock(),e.createElementBlock("div",rs,[n[8]||(n[8]=e.createElementVNode("span",{class:"wm-rec__dot","aria-hidden":"true"},null,-1)),e.createElementVNode("span",ss,"Enregistrement · "+e.toDisplayString(s.recordingElapsedLabel),1),e.createElementVNode("button",{type:"button",class:"wm-rec__stop",onClick:n[0]||(n[0]=(...i)=>s.stopRecording&&s.stopRecording(...i))},"Arrêter")])):e.createCommentVNode("",!0),e.createElementVNode("form",{class:e.normalizeClass(["wm-compose",{"has-attach":a.attachOpen}]),onSubmit:n[7]||(n[7]=e.withModifiers((...i)=>s.onSubmit&&s.onSubmit(...i),["prevent"]))},[e.createElementVNode("input",{ref:"fileEl",type:"file",hidden:"",multiple:"",onChange:n[1]||(n[1]=(...i)=>s.onFile&&s.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",os,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.attachItems,i=>(e.openBlock(),e.createElementBlock("button",{key:i.action,type:"button",class:"wm-compose__menuItem",disabled:i.disabled,onClick:l=>s.onAttachAction(i.action)},[e.createElementVNode("span",is,[(e.openBlock(),e.createElementBlock("svg",ls,[e.createElementVNode("path",{d:i.path,stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",fill:"none"},null,8,cs)]))]),e.createElementVNode("span",null,e.toDisplayString(i.label),1)],8,as))),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)=>s.onKeydown&&s.onKeydown(...i)),onInput:n[5]||(n[5]=(...i)=>s.autosize&&s.autosize(...i))},null,40,ds),[[e.vModelText,a.local]]),e.createElementVNode("div",us,[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,ms),e.createElementVNode("button",{type:"submit",class:e.normalizeClass(["wm-compose__send",{"is-empty":!s.canSend}]),disabled:!s.canSend,"aria-label":"Envoyer"},[...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,hs)])],34)])}const Oe=B(ts,[["render",fs],["__scopeId","data-v-14fa9ec0"]]),ps={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("§")}}},_s=["onClick"];function gs(t,n,r,o,a,s){return r.items.length?(e.openBlock(),e.createElementBlock("div",{key:s.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:p=>t.$emit("select",i)},e.toDisplayString(i.label),13,_s))),128))])):e.createCommentVNode("",!0)}const Ie=B(ps,[["render",gs],["__scopeId","data-v-55aa529d"]]),vs={name:"WmApprovalCard",components:{AIAvatar:j},props:{action:{type:String,required:!0},detail:{type:String,default:""},callbacks:{type:Array,default:()=>[]}},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)||"Autoriser"},rejectLabel(){var t;return((t=this.rejectCallback)==null?void 0:t.label)||"Refuser"}}},ys={class:"wm-approval"},ks={class:"wm-approval__head"},ws={class:"wm-approval__icon"},bs={class:"wm-approval__main"},Es={class:"wm-approval__title"},Cs={key:0,class:"wm-approval__detail"},Bs={class:"wm-approval__actions"};function Ns(t,n,r,o,a,s){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",ys,[e.createElementVNode("div",ks,[e.createElementVNode("div",ws,[e.createVNode(i,{size:24})]),e.createElementVNode("div",bs,[e.createElementVNode("div",Es,e.toDisplayString(r.action),1),r.detail?(e.openBlock(),e.createElementBlock("div",Cs,e.toDisplayString(r.detail),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",Bs,[s.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",s.rejectId))},e.toDisplayString(s.rejectLabel),1)):e.createCommentVNode("",!0),s.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",s.approveId))},e.toDisplayString(s.approveLabel),1)):e.createCommentVNode("",!0)])])}const Le=B(vs,[["render",Ns],["__scopeId","data-v-b1be139c"]]);let le=0;const Ss=new Set(["text","textarea","number","boolean","select","multiselect","date"]),As={name:"WmFormCard",components:{AIAvatar:j},props:{form:{type:Object,required:!0},readOnly:{type:Boolean,default:!1},initialValues:{type:Object,default:null}},emits:["submit"],data(){return le+=1,{_uid:le,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)||!Ss.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 o=Array.isArray(this.values[t])?this.values[t].slice():[],a=o.indexOf(n);r&&a===-1?o.push(n):!r&&a!==-1&&o.splice(a,1),this.values={...this.values,[t]:o}},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`« ${t.label} » est requis.`;continue}if(n==null||n==="")return`« ${t.label} » est requis.`}}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}}}},Vs={class:"wm-form"},Ms={class:"wm-form__head"},Ts={class:"wm-form__icon"},xs={class:"wm-form__main"},Os={class:"wm-form__title"},Is={key:0,class:"wm-form__detail"},Ls=["for"],Rs={key:0,class:"wm-form__req","aria-hidden":"true"},Ds=["id","onUpdate:modelValue","placeholder","required","disabled"],$s=["id","onUpdate:modelValue","placeholder","required","disabled"],Fs=["id","onUpdate:modelValue","placeholder","required","disabled"],Ps=["id","onUpdate:modelValue","required","disabled"],js={key:4,class:"wm-form__bool"},zs=["id","onUpdate:modelValue","disabled"],Us=["id","onUpdate:modelValue","required","disabled"],Hs={value:"",disabled:""},qs=["value"],Ks={key:6,class:"wm-form__multi"},Ws=["value","checked","disabled","onChange"],Gs={key:0,class:"wm-form__err"},Ys=["disabled"],Xs={key:0,class:"wm-form__spinner","aria-hidden":"true"},Js={key:2,class:"wm-form__doneLbl"};function Qs(t,n,r,o,a,s){const i=e.resolveComponent("AIAvatar");return e.openBlock(),e.createElementBlock("div",Vs,[e.createElementVNode("div",Ms,[e.createElementVNode("div",Ts,[e.createVNode(i,{size:24})]),e.createElementVNode("div",xs,[e.createElementVNode("div",Os,e.toDisplayString(r.form.title||"Formulaire"),1),r.form.description?(e.openBlock(),e.createElementBlock("div",Is,e.toDisplayString(r.form.description),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("form",{class:"wm-form__body",onSubmit:n[0]||(n[0]=e.withModifiers((...l)=>s.onSubmit&&s.onSubmit(...l),["prevent"]))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.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",Rs,"*")):e.createCommentVNode("",!0)],8,Ls),l.type==="text"?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":p=>a.values[l.key]=p,type:"text",class:"wm-form__input",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||a.busy},null,8,Ds)),[[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":p=>a.values[l.key]=p,class:"wm-form__textarea",rows:"3",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||a.busy},null,8,$s)),[[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":p=>a.values[l.key]=p,type:"number",class:"wm-form__input",placeholder:l.placeholder||"",required:l.required,disabled:r.readOnly||a.busy},null,8,Fs)),[[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":p=>a.values[l.key]=p,type:"date",class:"wm-form__input",required:l.required,disabled:r.readOnly||a.busy},null,8,Ps)),[[e.vModelText,a.values[l.key]]]):l.type==="boolean"?(e.openBlock(),e.createElementBlock("label",js,[e.withDirectives(e.createElementVNode("input",{id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":p=>a.values[l.key]=p,type:"checkbox",disabled:r.readOnly||a.busy},null,8,zs),[[e.vModelCheckbox,a.values[l.key]]]),e.createElementVNode("span",null,e.toDisplayString(l.placeholder||"Oui"),1)])):l.type==="select"?e.withDirectives((e.openBlock(),e.createElementBlock("select",{key:5,id:`wm-f-${a._uid}-${l.key}`,"onUpdate:modelValue":p=>a.values[l.key]=p,class:"wm-form__select",required:l.required,disabled:r.readOnly||a.busy},[e.createElementVNode("option",Hs,e.toDisplayString(l.placeholder||"Choisir…"),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,p=>(e.openBlock(),e.createElementBlock("option",{key:p.value,value:p.value},e.toDisplayString(p.label),9,qs))),128))],8,Us)),[[e.vModelSelect,a.values[l.key]]]):l.type==="multiselect"?(e.openBlock(),e.createElementBlock("div",Ks,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,p=>(e.openBlock(),e.createElementBlock("label",{key:p.value,class:"wm-form__multiItem"},[e.createElementVNode("input",{type:"checkbox",value:p.value,checked:Array.isArray(a.values[l.key])&&a.values[l.key].includes(p.value),disabled:r.readOnly||a.busy,onChange:y=>s.toggleMulti(l.key,p.value,y.target.checked)},null,40,Ws),e.createElementVNode("span",null,e.toDisplayString(p.label),1)]))),128))])):e.createCommentVNode("",!0)]))),128)),a.error?(e.openBlock(),e.createElementBlock("div",Gs,e.toDisplayString(a.error),1)):e.createCommentVNode("",!0),r.readOnly?(e.openBlock(),e.createElementBlock("div",Js,"Réponse envoyée")):(e.openBlock(),e.createElementBlock("button",{key:1,type:"submit",class:"wm-form__submit",disabled:a.busy},[a.busy?(e.openBlock(),e.createElementBlock("span",Xs)):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(a.busy?"Envoi…":r.form.submit_label||"Envoyer"),1)],8,Ys))],32)])}const Re=B(As,[["render",Qs],["__scopeId","data-v-64b40f76"]]),Zs={name:"WmFeedback",props:{busy:{type:Boolean,default:!1},done:{type:Boolean,default:!1}},emits:["submit"],data(){return{sel:null,options:[{v:1,e:"😞",l:"Pas bien"},{v:2,e:"😐",l:"Moyen"},{v:3,e:"🙂",l:"Bien"},{v:4,e:"😄",l:"Super"},{v:5,e:"🤩",l:"Excellent"}]}},methods:{onSend(){!this.sel||this.busy||this.$emit("submit",{rating:this.sel})}}},eo={class:"wm-fb"},to={class:"wm-fb__row"},no=["onClick"],ro={class:"wm-fb__emoji"},so={class:"wm-fb__label"},oo=["disabled"],ao={key:1,class:"wm-fb__done"};function io(t,n,r,o,a,s){return e.openBlock(),e.createElementBlock("div",eo,[r.done?(e.openBlock(),e.createElementBlock("div",ao,[...n[3]||(n[3]=[e.createStaticVNode('<div class="wm-fb__check" data-v-6f45ff3b><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" data-v-6f45ff3b><path d="M20 6L9 17l-5-5" data-v-6f45ff3b></path></svg></div><div class="wm-fb__doneTitle" data-v-6f45ff3b>Merci pour votre retour !</div><div class="wm-fb__doneSub" data-v-6f45ff3b>Votre avis a bien été pris en compte.</div>',3)])])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[n[1]||(n[1]=e.createElementVNode("div",{class:"wm-fb__title"},"Comment s'est passée cette conversation ?",-1)),n[2]||(n[2]=e.createElementVNode("div",{class:"wm-fb__sub"},"Votre avis nous aide à améliorer l'assistant.",-1)),e.createElementVNode("div",to,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.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",ro,e.toDisplayString(i.e),1),e.createElementVNode("span",so,e.toDisplayString(i.l),1)],10,no))),128))]),e.createElementVNode("button",{type:"button",class:"wm-fb__send",disabled:!a.sel||r.busy,onClick:n[0]||(n[0]=(...i)=>s.onSend&&s.onSend(...i))},e.toDisplayString(r.busy?"Envoi…":"Envoyer mon avis"),9,oo)],64))])}const De=B(Zs,[["render",io],["__scopeId","data-v-6f45ff3b"]]),lo={name:"WmMoreMenu",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)}}},co={class:"wm-mm"},uo={class:"wm-mm__pop",role:"menu"},mo={key:0,class:"wm-mm__section"},ho={key:1,class:"wm-mm__sep"},fo={class:"wm-mm__section"},po={class:"wm-mm__section"};function _o(t,n,r,o,a,s){return e.openBlock(),e.createElementBlock("div",co,[e.createElementVNode("div",{class:"wm-mm__scrim",onClick:n[0]||(n[0]=i=>t.$emit("close"))}),e.createElementVNode("div",uo,[r.canRename||r.canExport?(e.openBlock(),e.createElementBlock("div",mo,[r.canRename?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-mm__item",onClick:n[1]||(n[1]=i=>s.emit("rename"))},[...n[7]||(n[7]=[e.createStaticVNode('<span class="wm-mm__icon" data-v-3a73911b><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" data-v-3a73911b><path d="M12 20h9" data-v-3a73911b></path><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z" data-v-3a73911b></path></svg></span><span class="wm-mm__label" data-v-3a73911b>Modifier le titre</span>',2)])])):e.createCommentVNode("",!0),r.canExport?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"wm-mm__item",onClick:n[2]||(n[2]=i=>s.emit("export"))},[...n[8]||(n[8]=[e.createStaticVNode('<span class="wm-mm__icon" data-v-3a73911b><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" data-v-3a73911b><path d="M4 12v8a2 2 0 002 2h12a2 2 0 002-2v-8M16 6l-4-4-4 4M12 2v13" data-v-3a73911b></path></svg></span><span class="wm-mm__label" data-v-3a73911b>Exporter la transcription</span><span class="wm-mm__hint" data-v-3a73911b>.txt</span>',3)])])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),r.canRename||r.canExport?(e.openBlock(),e.createElementBlock("div",ho)):e.createCommentVNode("",!0),e.createElementVNode("div",fo,[e.createElementVNode("button",{type:"button",class:"wm-mm__item",onClick:n[3]||(n[3]=(...i)=>s.toggleSound&&s.toggleSound(...i))},[n[10]||(n[10]=e.createStaticVNode('<span class="wm-mm__icon" data-v-3a73911b><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" data-v-3a73911b><path d="M11 5L6 9H2v6h4l5 4V5z" data-v-3a73911b></path><path d="M15.54 8.46a5 5 0 010 7.07M19.07 4.93a10 10 0 010 14.14" data-v-3a73911b></path></svg></span><span class="wm-mm__label" data-v-3a73911b>Son</span>',2)),e.createElementVNode("span",{class:e.normalizeClass(["wm-mm__toggle",{"wm-mm__toggle--on":a.soundOn}])},[...n[9]||(n[9]=[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)=>s.toggleBrowserNotif&&s.toggleBrowserNotif(...i))},[n[12]||(n[12]=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)),n[13]||(n[13]=e.createElementVNode("span",{class:"wm-mm__label"},"Notifications navigateur",-1)),e.createElementVNode("span",{class:e.normalizeClass(["wm-mm__toggle",{"wm-mm__toggle--on":a.browserNotifOn}])},[...n[11]||(n[11]=[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",po,[r.statusUrl?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-mm__item",onClick:n[5]||(n[5]=i=>s.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",{class:"wm-mm__label"},"Statut des services",-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=>s.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",{class:"wm-mm__label"},"Centre d'aide",-1)])])):e.createCommentVNode("",!0)])])])}const $e=B(lo,[["render",_o],["__scopeId","data-v-3a73911b"]]),go={name:"WmRenameDialog",props:{title:{type:String,default:"Modifier le titre"},initialValue:{type:String,default:""},placeholder:{type:String,default:"Titre de la conversation"}},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())}}},vo={class:"wm-dialog"},yo={class:"wm-dialog__card",role:"dialog","aria-modal":"true"},ko={class:"wm-dialog__head"},wo={class:"wm-dialog__title"},bo={class:"wm-dialog__body"},Eo=["placeholder"],Co={class:"wm-dialog__actions"},Bo=["disabled"];function No(t,n,r,o,a,s){return e.openBlock(),e.createElementBlock("div",vo,[e.createElementVNode("div",{class:"wm-dialog__scrim",onClick:n[0]||(n[0]=i=>t.$emit("close"))}),e.createElementVNode("div",yo,[e.createElementVNode("div",ko,[e.createElementVNode("div",wo,e.toDisplayString(r.title),1),e.createElementVNode("button",{type:"button",class:"wm-dialog__close","aria-label":"Fermer",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)])])]),e.createElementVNode("div",bo,[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,maxlength:120,onKeydown:[n[3]||(n[3]=e.withKeys(e.withModifiers((...i)=>s.onSubmit&&s.onSubmit(...i),["prevent"]),["enter"])),n[4]||(n[4]=e.withKeys(e.withModifiers(i=>t.$emit("close"),["prevent"]),["esc"]))]},null,40,Eo),[[e.vModelText,a.value]])]),e.createElementVNode("div",Co,[e.createElementVNode("button",{type:"button",class:"wm-dialog__btn",onClick:n[5]||(n[5]=i=>t.$emit("close"))},"Annuler"),e.createElementVNode("button",{type:"button",class:"wm-dialog__btn wm-dialog__btn--primary",disabled:!s.canSubmit,onClick:n[6]||(n[6]=(...i)=>s.onSubmit&&s.onSubmit(...i))},"Enregistrer",8,Bo)])])])}const So=B(go,[["render",No],["__scopeId","data-v-4f4b37c9"]]),ce="ww-messenger-tokens",Ao={name:"Messenger",components:{Launcher:pe,Header:ge,Onboarding:ve,MessageList:Ae,Composer:Oe,SuggestionChips:Ie,ApprovalCard:Le,FormCard:Re,Feedback:De,MoreMenu:$e,RenameDialog:So},mixins:[Ze,ot,at,lt],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}}},props:{baseUrl:{type:String,default:he},widgetId:{type:String,default:""},userId:{type:String,default:""},userHash:{type:String,default:""},customer:{type:Object,default:null},displayMode:{type:String,default:"floating"},devtools:{type:Boolean,default:!1}},data(){return{transport:null,store:null,isOpen:!1,draft:"",busy:!1,bootError:null,pendingAttachments:[],feedbackBusy:!1,feedbackDone:!1,convOpenedAt:0,moreOpen:!1,renameDialogOpen:!1,draftConv:null,activeConvId:null,showOnboarding:!1,dismissedPeeks:{},floatHeight:0,floatRO:null}},computed:{isEditor(){return!!this.devtools},isEmbedded(){return this.displayMode==="embedded"},error(){var t;return this.bootError||((t=this.s)==null?void 0:t.error)||null},canBoot(){return!!(this.baseUrl&&this.widgetId&&this.userId&&this.userHash)},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(o=>{var y;const a=t[o.id]||[],s=$(o.last_read_message_id);let i=0,l=null;for(let v=a.length-1;v>=0;v--){const E=a[v];if(!E)continue;if(((y=E.author)==null?void 0:y.type)==="user")break;const N=$(E.id);if(N!=null){if(s!=null&&N<=s)break;n[E.id]!==0&&(!l&&E.author&&(l=E.author),i++)}}const p=a.filter(v=>!((v==null?void 0:v.id)!=null&&n[v.id]===0));return{...o,_preview:Ye(o,p),_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||"Nouvelle conversation",preview:r._preview||"Nouveau message",unread:!!r._unread,_ts:oe(r,t[r.id]||[])})).sort((r,o)=>r._ts<o._ts?1:r._ts>o._ts?-1:0)},latestUnreads(){var r;const t=((r=this.s)==null?void 0:r.messagesByConv)||{},n=[];for(const o of this.drawerConversations){if(!o._unread)continue;const a=oe(o,t[o.id]||[]),s=o._lastAuthor,i=!s||s.type==="agent_ia",l=(s==null?void 0:s.name)||(i?this.agentName:"")||"",p=(s==null?void 0:s.avatar_url)||(i?this.agentAvatarUrl:null);n.push({convId:o.id,preview:o._preview||"Vous avez un nouveau message",ts:a,count:o._unreadCount||1,senderName:l,senderAvatarUrl:p})}return n.sort((o,a)=>o.ts<a.ts?1:o.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},statusUrl(){var r;const t=(r=this.widget)==null?void 0:r.quick_links;if(!Array.isArray(t))return"";const n=t.find(o=>o.icon==="status"&&o.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(o=>(o.icon==="chat"||o.icon==="help")&&o.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},widgetWelcomeMessage(){var t;return((t=this.widget)==null?void 0:t.welcome_message)||""},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,o;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(((o=(r=t[a])==null?void 0:r.author)==null?void 0:o.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)||"Nouvelle conversation"},composerPlaceholder(){return this.isEscalated&&this.humanAgentName?`Répondre à ${this.humanAgentName.split(" ")[0]}…`:this.isWaitingHuman?"Un agent prend le relais…":"Écrivez votre message…"},displayedMessages(){const t=this.currentConv;if(!t)return[];const n=this.revealedAt;return(this.s.messagesByConv[t.id]||[]).filter(r=>{var o,a,s,i,l;return(r==null?void 0:r.type)==="action"&&((o=r==null?void 0:r.payload)==null?void 0:o.state)==="pending"||H(r)&&!(n[r.id]>0)?!1:(r==null?void 0:r.type)==="action"||(r==null?void 0:r.type)==="system"||((a=r==null?void 0:r.payload)==null?void 0:a.type)==="system"||Array.isArray((s=r==null?void 0:r.payload)==null?void 0:s.attachments)&&r.payload.attachments.length||(i=r==null?void 0:r.metadata)!=null&&i.artifact||(l=r==null?void 0:r.metadata)!=null&&l.form?!0:typeof(r==null?void 0:r.text_md)=="string"&&r.text_md.trim().length>0})},streamingActive(){var r,o,a;const t=this.currentConv;return t?Object.keys(((r=this.s)==null?void 0:r.streamingByMsgId)||{}).length>0?!0:this.actionInFlight?!1:(((a=(o=this.s)==null?void 0:o.messagesByConv)==null?void 0:a[t.id])||[]).some(s=>H(s)&&!(this.revealedAt[s.id]>0)):!1},currentConvMessages(){var n,r,o;const t=(n=this.currentConv)==null?void 0:n.id;return t?((o=(r=this.s)==null?void 0:r.messagesByConv)==null?void 0:o[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)||"Confirmer l'action"},approvalDetail(){var o,a,s,i,l,p;const t=(s=(a=(o=this.pendingApproval)==null?void 0:o.payload)==null?void 0:a.pending)==null?void 0:s.user_explanation;if(typeof t=="string"&&t.trim())return t.trim();const n=(p=(l=(i=this.pendingApproval)==null?void 0:i.payload)==null?void 0:l.pending)==null?void 0:p.prepared_params;if(!n||typeof n!="object")return"";const r=Object.entries(n);return r.length?r.slice(0,2).map(([y,v])=>`${y}: ${v}`).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||"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,o,a;const t=this.currentConv;let n=new Date;if(t){const i=((a=(((o=(r=this.s)==null?void 0:r.messagesByConv)==null?void 0:o[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`Aujourd'hui · ${te(n)}`},paginationState(){var r,o,a;const t=(r=this.currentConv)==null?void 0:r.id,n=t?(a=(o=this.s)==null?void 0:o.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||{},o=Object.keys(r);if(!o.length)return;const a={};let s=!1;for(const i of o)n.has(i)?a[i]=r[i]:s=!0;s&&(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=$((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=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(ce)){const t=document.createElement("style");t.id=ce,t.textContent=me,document.head.appendChild(t)}await this.boot(),this.isEmbedded&&this.store&&await this.open()},beforeUnmount(){this.cancelReveals(),this.teardownLiveReveal(),this.disconnectFloatRO(),this.resetApprovalPacing(),this.teardownNotifications(),this.store&&this.store.destroy()},methods:{async boot(){if(!this.canBoot){console.warn("[messenger] boot skipped — missing creds");return}try{this.transport=e.markRaw(de({baseUrl:this.baseUrl,widgetId:this.widgetId,userId:this.userId,userHash:this.userHash})),this.store=e.markRaw(ue(this.transport)),this.hydrateNotifPref(),await this.store.start(),this.setupLiveReveal(),this.customer&&typeof this.customer=="object"&&await this.store.applyCustomer(this.customer)}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,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 o=r[0];if(!o)return;const a=Math.ceil(o.contentRect.height+8);a!==this.floatHeight&&(this.floatHeight=a,this.$nextTick(()=>{var s,i;(i=(s=this.$refs.messageList)==null?void 0:s.scrollToBottom)==null||i.call(s)}))}),this.floatRO.observe(n)}},disconnectFloatRO(){if(this.floatRO){try{this.floatRO.disconnect()}catch{}this.floatRO=null}},async open(){this.isOpen=!0,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)}},close(){this.isOpen=!1,this.store&&this.store.setPanelOpen(!1)},async openFromPeek(t){var r,o;const n=t||((r=this.latestUnreads[0])==null?void 0:r.convId);n&&n!==((o=this.currentConv)==null?void 0:o.id)&&(this.draftConv=null,this.activeConvId=n,this.showOnboarding=!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.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},async onDrawerPick(t){if(!(t!=null&&t.id)||!this.store)return;this.draftConv=null,this.activeConvId=t.id,this.showOnboarding=!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":Qe(this.currentConv,this.currentConv?(r=(n=this.s)==null?void 0:n.messagesByConv)==null?void 0:r[this.currentConv.id]:[]);break;case"status":if(this.statusUrl)try{window.open(this.statusUrl,"_blank","noopener")}catch{}break;case"help":if(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(o){console.error("[ww-messenger] rename failed",o)}},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,o=this.pendingAttachments.slice();this.pendingAttachments=[],this.unreadAnchorId=null,this.unreadBoundaryTs="",await this.store.send(r,t,{attachments:o.length?o: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=We(n.form,t);if(!r)return;let o=this.currentConv;o&&(o._draft&&(o=await this.ensureRealConv(),!o)||await this.store.send(o.id,r,{metadata:{artifact:Ge(n.form,t)}}))},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||"fichier",mime_type:t.type,size_bytes:t.size})}catch(n){console.error("[ww-messenger] attachment upload failed",n)}},async onQuickLink(t){if(t){if(t.url){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}}}}},Vo={key:0,class:"wm-loading","aria-busy":"true","aria-live":"polite"},Mo={key:0,class:"wm-state"},To={class:"wm-state__err"},xo={class:"wm-state__errSub"},Oo={class:"wm-bottom"},Io={key:0,ref:"floatEl",class:"wm-float"},Lo={key:1,class:"wm-actionWait",role:"status","aria-live":"polite"},Ro={class:"wm-actionWait__lbl"},Do={key:2,class:"wm-attached"},$o=["onClick"];function Fo(t,n,r,o,a,s){const i=e.resolveComponent("Launcher"),l=e.resolveComponent("Header"),p=e.resolveComponent("Onboarding"),y=e.resolveComponent("MessageList"),v=e.resolveComponent("ApprovalCard"),E=e.resolveComponent("FormCard"),N=e.resolveComponent("Feedback"),k=e.resolveComponent("SuggestionChips"),x=e.resolveComponent("Composer"),b=e.resolveComponent("MoreMenu"),M=e.resolveComponent("RenameDialog");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["wm-root",`wm-root--${r.displayMode}`])},[!a.isOpen&&!s.isEmbedded?(e.openBlock(),e.createBlock(i,{key:0,"unread-count":s.unreadCount,peeks:s.launcherPeeks,onOpen:s.openFromPeek,onDismiss:s.dismissPeek},null,8,["unread-count","peeks","onOpen","onDismiss"])):e.createCommentVNode("",!0),a.isOpen||s.isEmbedded?(e.openBlock(),e.createElementBlock("section",{key:1,class:e.normalizeClass(["wm-panel",`wm-panel--${r.displayMode}`]),style:e.normalizeStyle(a.floatHeight?{"--wm-float-h":a.floatHeight+"px"}:null),role:"dialog","aria-label":"Messenger"},[!s.ready&&!s.error?(e.openBlock(),e.createElementBlock("div",Vo,[s.isEmbedded?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"wm-loading__close","aria-label":"Réduire",onClick:n[0]||(n[0]=(...S)=>s.close&&s.close(...S))},[...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)])])),n[6]||(n[6]=e.createElementVNode("div",{class:"wm-loading__spinner","aria-hidden":"true"},null,-1))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(l,{title:s.headerTitle,"team-members":s.teamMembers,"response-label":s.responseLabel,"show-identity":!!s.currentConv,"show-back":s.canBack,"show-close":!s.isEmbedded,"more-active":a.moreOpen,onBack:s.goHome,onMore:s.toggleMore,onClose:s.close},null,8,["title","team-members","response-label","show-identity","show-back","show-close","more-active","onBack","onMore","onClose"]),s.error?(e.openBlock(),e.createElementBlock("div",Mo,[e.createElementVNode("div",To,[n[8]||(n[8]=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,[n[7]||(n[7]=e.createElementVNode("div",{class:"wm-state__errTitle"},"Connexion impossible",-1)),e.createElementVNode("div",xo,e.toDisplayString(s.error),1)])])])):s.currentConv?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createVNode(y,{ref:"messageList",messages:s.displayedMessages,"streaming-active":s.streamingActive,"date-label":s.dateLabel,"conversation-id":s.currentConv?s.currentConv.id:null,"loading-more":s.paginationState.loading,"has-more":s.paginationState.hasMore,"unread-anchor-id":t.unreadAnchorId,"unread-boundary-ts":t.unreadBoundaryTs,onLoadMore:s.onLoadMore},null,8,["messages","streaming-active","date-label","conversation-id","loading-more","has-more","unread-anchor-id","unread-boundary-ts","onLoadMore"]),e.createElementVNode("div",Oo,[s.floatVisible?(e.openBlock(),e.createElementBlock("div",Io,[s.approvalReady?(e.openBlock(),e.createBlock(v,{key:0,action:s.approvalTitle,detail:s.approvalDetail,callbacks:s.pendingApproval.callbacks,onCallback:s.onApprovalCallback},null,8,["action","detail","callbacks","onCallback"])):s.pendingForm?(e.openBlock(),e.createBlock(E,{key:s.pendingForm.message&&s.pendingForm.message.id,form:s.pendingForm.form,onSubmit:s.onFormSubmit},null,8,["form","onSubmit"])):s.showFeedback?(e.openBlock(),e.createBlock(N,{key:2,busy:a.feedbackBusy,done:a.feedbackDone,onSubmit:s.onFeedback},null,8,["busy","done","onSubmit"])):(e.openBlock(),e.createBlock(k,{key:3,items:s.suggestions,onSelect:s.onSuggestion},null,8,["items","onSelect"]))],512)):e.createCommentVNode("",!0),s.actionInFlight?(e.openBlock(),e.createElementBlock("div",Lo,[n[9]||(n[9]=e.createElementVNode("span",{class:"wm-actionWait__spinner","aria-hidden":"true"},null,-1)),e.createElementVNode("span",Ro,e.toDisplayString(s.actionInFlightName)+" en cours, veuillez patienter…",1)])):(e.openBlock(),e.createBlock(x,{key:2,ref:"composer",modelValue:a.draft,"onUpdate:modelValue":n[1]||(n[1]=S=>a.draft=S),placeholder:s.composerPlaceholder,disabled:!!s.pendingApproval,"attach-label":"Joindre un fichier",onSend:s.onSend,onAttach:s.onAttach},null,8,["modelValue","placeholder","disabled","onSend","onAttach"]))]),a.moreOpen?(e.openBlock(),e.createBlock(b,{key:0,"can-rename":!!s.currentConv&&!s.currentConv._draft,"can-export":!!s.currentConv&&!s.currentConv._draft,"sound-enabled":t.soundEnabled,"browser-notif-enabled":t.browserNotifEnabled,"status-url":s.statusUrl,"help-url":s.helpUrl,onClose:n[2]||(n[2]=S=>a.moreOpen=!1),onSoundToggle:t.onSoundToggle,onBrowserNotifToggle:t.onBrowserNotifToggle,onAction:s.onMoreAction},null,8,["can-rename","can-export","sound-enabled","browser-notif-enabled","status-url","help-url","onSoundToggle","onBrowserNotifToggle","onAction"])):e.createCommentVNode("",!0),a.renameDialogOpen&&s.currentConv&&!s.currentConv._draft?(e.openBlock(),e.createBlock(M,{key:1,"initial-value":s.currentConv.name||"",title:"Modifier le titre de la conversation",onClose:n[3]||(n[3]=S=>a.renameDialogOpen=!1),onSubmit:s.onRenameSubmit},null,8,["initial-value","onSubmit"])):e.createCommentVNode("",!0),a.pendingAttachments.length?(e.openBlock(),e.createElementBlock("div",Do,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.pendingAttachments,(S,T)=>(e.openBlock(),e.createElementBlock("div",{key:T,class:"wm-attached__chip"},[n[11]||(n[11]=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(S.name),1),e.createElementVNode("button",{type:"button","aria-label":"Retirer",onClick:I=>a.pendingAttachments.splice(T,1)},[...n[10]||(n[10]=[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,$o)]))),128))])):e.createCommentVNode("",!0)],64)):(e.openBlock(),e.createBlock(p,{key:1,"welcome-message":s.widgetWelcomeMessage,"agent-name":s.agentName,"quick-links":s.quickLinks,"open-threads":s.openThreads,busy:a.busy,onStart:s.startConv,onSelect:s.onQuickLink,onResume:s.onDrawerPick},null,8,["welcome-message","agent-name","quick-links","open-threads","busy","onStart","onSelect","onResume"])),a.moreOpen&&!s.currentConv?(e.openBlock(),e.createBlock(b,{key:3,"can-rename":!1,"can-export":!1,"sound-enabled":t.soundEnabled,"browser-notif-enabled":t.browserNotifEnabled,"status-url":s.statusUrl,"help-url":s.helpUrl,onClose:n[4]||(n[4]=S=>a.moreOpen=!1),onSoundToggle:t.onSoundToggle,onBrowserNotifToggle:t.onBrowserNotifToggle,onAction:s.onMoreAction},null,8,["sound-enabled","browser-notif-enabled","status-url","help-url","onSoundToggle","onBrowserNotifToggle","onAction"])):e.createCommentVNode("",!0)],64))],6)):e.createCommentVNode("",!0)],2)}const Fe=B(Ao,[["render",Fo],["__scopeId","data-v-2ea39c44"]]),Po="0.3.13";exports.AIAvatar=j;exports.AVATAR_COLORS=Y;exports.ActionResult=ye;exports.ApprovalCard=Le;exports.ArtifactFormResponse=ke;exports.ArtifactInfoCard=we;exports.ArtifactRenderer=Ee;exports.ArtifactTicket=be;exports.AttachmentPreview=Ce;exports.Bubble=Ne;exports.Composer=Oe;exports.DEFAULT_BASE_URL=he;exports.Feedback=De;exports.FormCard=Re;exports.Header=ge;exports.HumanAvatar=ne;exports.Launcher=pe;exports.MEDIA_RECORDER_SUPPORTED=X;exports.MessageList=Ae;exports.Messenger=Fe;exports.MoreMenu=$e;exports.Onboarding=ve;exports.SCREEN_CAPTURE_SUPPORTED=q;exports.SuggestionChips=Ie;exports.TeamAvatars=_e;exports.Typing=Se;exports.VERSION=Po;exports.avatarColor=Z;exports.avatarInitials=ee;exports.captureScreenshotFile=Te;exports.colors=V;exports.createStore=ue;exports.createTransport=de;exports.default=Fe;exports.formatTime=te;exports.guessAttachmentKind=Qr;exports.pickRecorderMime=Ve;exports.renderMarkdown=Be;exports.startScreenRecording=xe;exports.tokensCss=me;exports.uuid=Q;exports.v4=Q;
|