@_solaris/messenger-widget 0.4.9 → 0.4.10

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.
@@ -74,4 +74,4 @@ ${a}`)}return i.join(`
74
74
  `)}function Ec(e,t,n=Me(),s){if(!e)return;const i=Mc(e,t||[],n,vn(s)),r=new Blob([i],{type:"text/plain;charset=utf-8"});try{const o=URL.createObjectURL(r),a=document.createElement("a");a.href=o,a.download=`${(e.name||"conversation").replace(/[^a-z0-9-_]+/gi,"_")}.txt`,document.body.appendChild(a),a.click(),document.body.removeChild(a),setTimeout(()=>URL.revokeObjectURL(o),1e3)}catch(o){console.error("[ww-messenger] export failed",o)}}const Oc={data(){const e=typeof Notification<"u";return{notifPermission:e?Notification.permission:"denied",soundEnabled:!0,browserNotifEnabled:e&&Notification.permission==="granted",_audioCtx:null}},methods:{teardownNotifications(){var e,t;if(this._audioCtx){try{(t=(e=this._audioCtx).close)==null||t.call(e)}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 e=localStorage.getItem(this.soundStorageKey());e==="0"?this.soundEnabled=!1:e==="1"&&(this.soundEnabled=!0);const t=localStorage.getItem(this.browserNotifStorageKey());t==="0"?this.browserNotifEnabled=!1:t==="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(e){this.soundEnabled=!!e,this.persistSoundPref()},async onBrowserNotifToggle(e){if(typeof Notification>"u"){this.browserNotifEnabled=!1,this.persistBrowserNotifPref();return}if(!e){this.browserNotifEnabled=!1,this.persistBrowserNotifPref();return}let t=Notification.permission;if(t==="default"){try{t=await Notification.requestPermission()}catch(n){console.warn("[ww-messenger] notif permission request failed",n),t="denied"}this.notifPermission=t}this.browserNotifEnabled=t==="granted",this.persistBrowserNotifPref()},onMessageRevealed(e,t){var i;if(!this.soundEnabled&&!this.browserNotifEnabled||!t||!e||!bn(e))return;const n=typeof document<"u"&&document.hidden;this.isOpen&&!n&&((i=this.currentConv)==null?void 0:i.id)===t||(this.soundEnabled&&this.playNotificationSound(),this.browserNotifEnabled&&this.showBrowserNotification(t,e))},playNotificationSound(){if(typeof window>"u")return;const e=window.AudioContext||window.webkitAudioContext;if(e)try{this._audioCtx||(this._audioCtx=new e);const t=this._audioCtx;if(t.state==="suspended")try{t.resume()}catch{}const n=t.currentTime,s=t.createOscillator(),i=t.createGain();s.connect(i),i.connect(t.destination),s.type="sine",s.frequency.setValueAtTime(880,n),s.frequency.exponentialRampToValueAtTime(1320,n+.08),i.gain.setValueAtTime(0,n),i.gain.linearRampToValueAtTime(.12,n+.02),i.gain.exponentialRampToValueAtTime(1e-4,n+.28),s.start(n),s.stop(n+.32)}catch{}},showBrowserNotification(e,t){if(typeof Notification>"u"||Notification.permission!=="granted")return;const n=t==null?void 0:t.author,s=!n||n.type==="agent_ia",r=((n==null?void 0:n.name)||(s?this.agentName:"")||this.t("launcher.theAgent"))+this.t("launcher.repliedToYou"),o=typeof(t==null?void 0:t.text_md)=="string"?t.text_md.trim():"",a=o?o.slice(0,140):this.t("notification.youHaveNewMessage");try{const l=new Notification(r,{body:a,tag:`wm-${e}`,renotify:!1,silent:!0});l.onclick=()=>{try{window.focus()}catch{}this.draftConv=null,this.showOnboarding=!1,this.activeConvId=e,this.isOpen=!0,this.store&&this.store.setPanelOpen(!0);try{l.close()}catch{}}}catch(l){console.warn("[ww-messenger] notification failed",l)}}}},Ic=450,Lc=50,Rc=900,Nc=12e3,Bc=300,Pc={data(){return{revealedAt:{},nextRevealAt:0,revealTimers:[],_liveRevealOff:null,_liveRevealConvSnapshot:null}},methods:{cancelReveals(){for(const e of this.revealTimers)clearTimeout(e);this.revealTimers=[]},resetRevealQueue(){this.cancelReveals(),this.revealedAt={},this.nextRevealAt=0},setupLiveReveal(){var n;if(!this.transport)return;this.teardownLiveReveal();const e=this.transport.on("message",s=>{const i=s==null?void 0:s.conversation_id,r=s==null?void 0:s.message;i&&r&&this.paceLiveMessage(r,i)});this._liveRevealConvSnapshot=new Map((((n=this.s)==null?void 0:n.conversations)||[]).map(s=>[s.id,(s==null?void 0:s.last_message_at)||""]));const t=this.transport.on("activity",s=>{this.handleLiveActivity(s)});this._liveRevealOff=()=>{try{e()}catch{}try{t()}catch{}}},teardownLiveReveal(){if(this._liveRevealOff){try{this._liveRevealOff()}catch{}this._liveRevealOff=null}this._liveRevealConvSnapshot=null},async handleLiveActivity(e){var i,r;const t=e==null?void 0:e.conversations;if(!Array.isArray(t)||!this.store)return;const n=this._liveRevealConvSnapshot||new Map,s=[];for(const o of t){if(!(o!=null&&o.id))continue;const a=o.last_message_at||"";if(!a)continue;const l=n.get(o.id)||"";a>l&&s.push(o.id)}this._liveRevealConvSnapshot=new Map(t.map(o=>[o.id,(o==null?void 0:o.last_message_at)||""]));for(const o of s)try{const a=await((r=(i=this.store).fetchSinceLast)==null?void 0:r.call(i,o));if(!Array.isArray(a))continue;for(const l of a)this.paceLiveMessage(l,o)}catch(a){console.error("[ww-messenger] activity delta fetch failed",a)}},scheduleReveal(e,t){const n=Date.now(),s=((e==null?void 0:e.text_md)||"").length,i=Math.min(Nc,Math.max(Rc,s*Lc)),o=Math.max(n+Ic,this.nextRevealAt+Bc)+i;this.nextRevealAt=o;const a=Math.max(0,o-n),l=e.id,f=setTimeout(()=>{this.revealedAt={...this.revealedAt,[l]:Date.now()},this.revealTimers=this.revealTimers.filter(c=>c!==f),typeof this.onMessageRevealed=="function"&&this.onMessageRevealed(e,t)},a);this.revealTimers.push(f)},paceMessages(e,t){var i;if(!Array.isArray(e)||!e.length)return;const n=Date.now(),s={...this.revealedAt};for(const r of e){if((r==null?void 0:r.id)==null||s[r.id]!==void 0)continue;if(!bn(r)){s[r.id]=n;continue}const o=r!=null&&r.created_at?Date.parse(r.created_at):NaN;if(!Number.isFinite(o)||o<this.convOpenedAt){s[r.id]=n;continue}const a=typeof(r==null?void 0:r.text_md)=="string"&&r.text_md.trim().length>0,l=Array.isArray((i=r==null?void 0:r.payload)==null?void 0:i.attachments)&&r.payload.attachments.length>0;if(!a&&!l){s[r.id]=n;continue}s[r.id]=0,this.scheduleReveal(r,t)}this.revealedAt=s},paceLiveMessage(e,t){var i;if(!(e!=null&&e.id)||this.revealedAt[e.id]!==void 0)return;if(!bn(e)){this.revealedAt={...this.revealedAt,[e.id]:Date.now()};return}const n=typeof(e==null?void 0:e.text_md)=="string"&&e.text_md.trim().length>0,s=Array.isArray((i=e==null?void 0:e.payload)==null?void 0:i.attachments)&&e.payload.attachments.length>0;if(!n&&!s){this.revealedAt={...this.revealedAt,[e.id]:Date.now()};return}this.revealedAt={...this.revealedAt,[e.id]:0},this.scheduleReveal(e,t)}}},Fc={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(e=800){this.approvalSettled=!1,this.approvalSettleTimer&&clearTimeout(this.approvalSettleTimer),this.approvalSettleTimer=setTimeout(()=>{this.approvalSettled=!0,this.approvalSettleTimer=null},e)}}},Dc=300,jc={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(e){var r,o;if(!(e!=null&&e.id)||e._draft||!this.store)return;const t=((o=(r=this.s)==null?void 0:r.messagesByConv)==null?void 0:o[e.id])||[],n=Uc(t);if(n==null)return;const s=kt(e.last_read_message_id),i=kt(n);i!=null&&(s!=null&&i<=s||(this._readMarkerPending={convId:e.id,messageId:n},!this._readMarkerTimer&&(this._readMarkerTimer=setTimeout(()=>{const a=this._readMarkerPending;this._readMarkerPending=null,this._readMarkerTimer=null,a&&this.store&&this.store.markConversationRead(a.convId,a.messageId)},Dc))))}}};function Uc(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if(!(!n||n._pending)&&kt(n.id)!=null)return n.id}return null}const be=(e,t)=>{const n=e.__vccOpts||e;for(const[s,i]of t)n[s]=i;return n},Hc={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":qs(this.name)},initials(){return Ws(this.name)}}},$c=["src","alt"];function Vc(e,t,n,s,i,r){return p(),y("div",{class:te(["wm-huav",{"wm-huav--tail":n.tail}]),style:De({width:n.size+"px",height:n.size+"px","--wm-avr":Math.round(n.size*.32)+"px",background:r.bg})},[n.avatarUrl?(p(),y("img",{key:0,src:n.avatarUrl,alt:n.name||""},null,8,$c)):(p(),y("span",{key:1,style:De({fontSize:n.size*.36+"px"})},O(r.initials),5))],6)}const vo=be(Hc,[["render",Vc],["__scopeId","data-v-14e10c0d"]]),Kc=3,qc={name:"WmLauncher",components:{HumanAvatar:vo},inject:{t:{default:()=>Me()}},props:{unreadCount:{type:Number,default:0},peeks:{type:Array,default:()=>[]}},emits:["open","dismiss"],computed:{visiblePeeks(){return this.peeks.slice(0,Kc).reverse()}}},Wc={class:"wm-launcherWrap"},zc=["aria-label","onClick","onKeydown"],Gc=["aria-label","onClick"],Yc={class:"wm-peek__avatar"},Jc=["aria-label"],Xc={class:"wm-peek__body"},Qc={class:"wm-peek__head"},Zc={class:"wm-peek__name"},eu={class:"wm-peek__action"},tu={class:"wm-peek__text"},nu=["onClick"],su=["aria-label"],ru=["aria-label"];function iu(e,t,n,s,i,r){const o=ge("HumanAvatar");return p(),y("div",Wc,[_e(Nl,{name:"wm-peek"},{default:Dr(()=>[r.visiblePeeks.length?(p(),y("div",{key:0,class:te(["wm-peekStack",{"wm-peekStack--multi":r.visiblePeeks.length>1}])},[(p(!0),y(Z,null,Te(r.visiblePeeks,(a,l)=>(p(),y("div",{key:a.convId,class:"wm-peek",style:De({"--depth":r.visiblePeeks.length-1-l,zIndex:l+1}),role:"button",tabindex:"0","aria-label":r.t("launcher.openConversationWith",{name:a.senderName||r.t("launcher.theAgent")}),onClick:f=>e.$emit("open",a.convId),onKeydown:[ns(wt(f=>e.$emit("open",a.convId),["prevent"]),["enter"]),ns(wt(f=>e.$emit("open",a.convId),["prevent"]),["space"])]},[u("button",{type:"button",class:"wm-peek__close","aria-label":r.t("launcher.dismiss"),onClick:wt(f=>e.$emit("dismiss",a.convId),["stop"])},[...t[1]||(t[1]=[u("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"},[u("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,Gc),u("div",Yc,[_e(o,{name:a.senderName,"avatar-url":a.senderAvatarUrl,size:34},null,8,["name","avatar-url"]),a.count>1?(p(),y("span",{key:0,class:"wm-peek__avatarBadge","aria-label":r.t("launcher.unreadMessages",{count:a.count})},O(a.count>9?"9+":a.count),9,Jc)):F("",!0)]),u("div",Xc,[u("div",Qc,[u("span",Zc,O(a.senderName||r.t("common.agent")),1),u("span",eu,O(r.t("launcher.repliedToYou")),1)]),u("p",tu,O(a.preview),1)]),u("button",{type:"button",class:"wm-peek__open",onClick:wt(f=>e.$emit("open",a.convId),["stop"])},O(r.t("common.open")),9,nu)],44,zc))),128))],2)):F("",!0)]),_:1}),u("button",{type:"button",class:"wm-launcher","aria-label":r.t("launcher.open"),onClick:t[0]||(t[0]=a=>e.$emit("open"))},[t[2]||(t[2]=u("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"},[u("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)),n.unreadCount>0?(p(),y("span",{key:0,class:"wm-launcher__badge","aria-label":n.unreadCount>1?r.t("launcher.unreadConversationsMany",{count:n.unreadCount}):r.t("launcher.unreadConversationsOne",{count:n.unreadCount})},O(n.unreadCount>9?"9+":n.unreadCount),9,ru)):F("",!0)],8,su)])}const ou=be(qc,[["render",iu],["__scopeId","data-v-5193a529"]]),au={name:"WmAIAvatar",props:{size:{type:Number,default:26},pulse:{type:Boolean,default:!1},tail:{type:Boolean,default:!1},name:{type:String,default:""},imageUrl:{type:String,default:null}},computed:{initials(){return Ws(this.name)},bgColor(){return qs(this.name)}}},lu={key:0,class:"wm-aiav__pulse"},cu=["src","alt"],uu=["width","height"];function du(e,t,n,s,i,r){return p(),y("div",{class:te(["wm-aiav",{"wm-aiav--tail":n.tail}]),style:De({width:n.size+"px",height:n.size+"px","--wm-avr":n.size*.32+"px"})},[n.pulse?(p(),y("div",lu)):F("",!0),u("div",{class:te(["wm-aiav__inner",{"wm-aiav__inner--glow":n.pulse,"wm-aiav__inner--img":!!n.imageUrl,"wm-aiav__inner--initials":!n.imageUrl&&!!r.initials}]),style:De(!n.imageUrl&&r.initials?{background:r.bgColor}:null)},[n.imageUrl?(p(),y("img",{key:0,src:n.imageUrl,alt:n.name||""},null,8,cu)):r.initials?(p(),y("span",{key:1,style:De({fontSize:n.size*.36+"px"})},O(r.initials),5)):(p(),y("svg",{key:2,width:n.size*.5,height:n.size*.5,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[...t[0]||(t[0]=[u("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),u("circle",{cx:"19",cy:"5",r:"1.5",fill:"white",opacity:"0.55"},null,-1),u("circle",{cx:"5",cy:"18",r:"1",fill:"white",opacity:"0.38"},null,-1)])],8,uu))],6)],6)}const wn=be(au,[["render",du],["__scopeId","data-v-6f7f685d"]]),fu={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(e){return e.avatar_url?"transparent":qs(e.name||"")},initialsFor(e){return Ws(e.name||"")}}},hu={key:0,class:"wm-team"},mu=["src","alt"],pu={key:1},gu={key:0,class:"wm-team__label"};function _u(e,t,n,s,i,r){return r.visible?(p(),y("div",hu,[u("div",{class:"wm-team__stack",style:De({width:r.stackWidth+"px"})},[(p(!0),y(Z,null,Te(n.members.slice(0,3),(o,a)=>(p(),y("div",{key:a,class:"wm-team__pill",style:De({left:a*13+"px",zIndex:3-a,background:r.colorFor(o)})},[o.avatar_url?(p(),y("img",{key:0,src:o.avatar_url,alt:o.name||""},null,8,mu)):(p(),y("span",pu,O(r.initialsFor(o)),1))],4))),128))],4),n.responseLabel?(p(),y("span",gu,O(n.responseLabel),1)):F("",!0)])):F("",!0)}const yu={name:"WmHeader",components:{AIAvatar:wn,TeamAvatars:be(fu,[["render",_u],["__scopeId","data-v-e49a9063"]])},inject:{t:{default:()=>Me()}},props:{title:{type:String,default:"Nouvelle conversation"},showBack:{type:Boolean,default:!1},teamMembers:{type:Array,default:()=>[]},responseLabel:{type:String,default:""},showClose:{type:Boolean,default:!0},showMore:{type:Boolean,default:!0},moreActive:{type:Boolean,default:!1},showIdentity:{type:Boolean,default:!0},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["back","close","more"],computed:{hasTeam(){return Array.isArray(this.teamMembers)&&this.teamMembers.length>0},displayedTeamMembers(){const e=Array.isArray(this.teamMembers)?this.teamMembers:[];if(e.length<=3)return e;const t=new Date().getHours()%e.length,n=[];for(let s=0;s<3;s++)n.push(e[(t+s)%e.length]);return n}}},vu={class:"wm-header"},bu=["aria-label"],wu={key:1,style:{width:"30px",height:"30px","flex-shrink":"0"}},ku={class:"wm-header__avatar"},Cu={class:"wm-header__main"},Su={class:"wm-header__title"},Au={key:3,class:"wm-header__fill"},xu={class:"wm-header__actions"},Tu=["aria-label","title"],Mu=["aria-label","title"];function Eu(e,t,n,s,i,r){const o=ge("AIAvatar"),a=ge("TeamAvatars");return p(),y("div",vu,[n.showBack?(p(),y("button",{key:0,type:"button",class:"wm-header__icon","aria-label":r.t("header.backToHome"),onClick:t[0]||(t[0]=l=>e.$emit("back"))},[...t[3]||(t[3]=[u("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"},[u("path",{d:"M19 12H5M12 5l-7 7 7 7"})],-1)])],8,bu)):(p(),y("div",wu)),n.showIdentity?(p(),y(Z,{key:2},[u("div",ku,[_e(o,{size:30,name:n.agentName,"image-url":n.agentAvatarUrl},null,8,["name","image-url"])]),u("div",Cu,[u("div",Su,O(n.title),1)]),r.hasTeam?(p(),ve(a,{key:0,members:r.displayedTeamMembers,"response-label":""},null,8,["members"])):F("",!0)],64)):(p(),y("div",Au)),u("div",xu,[n.showMore?(p(),y("button",{key:0,type:"button",class:te(["wm-header__icon",{"wm-header__icon--active":n.moreActive}]),"aria-label":r.t("header.moreOptions"),title:r.t("header.moreOptions"),onClick:t[1]||(t[1]=l=>e.$emit("more"))},[...t[4]||(t[4]=[u("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true"},[u("circle",{cx:"12",cy:"5",r:"1.6"}),u("circle",{cx:"12",cy:"12",r:"1.6"}),u("circle",{cx:"12",cy:"19",r:"1.6"})],-1)])],10,Tu)):F("",!0),n.showClose?(p(),y("button",{key:1,type:"button",class:"wm-header__icon","aria-label":r.t("header.closeWidget"),title:r.t("header.closeWidget"),onClick:t[2]||(t[2]=l=>e.$emit("close"))},[...t[5]||(t[5]=[u("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"},[u("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,Mu)):F("",!0)])])}const Ou=be(yu,[["render",Eu],["__scopeId","data-v-925c9e94"]]);function bo(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Iu(e){return/^(https?:\/\/|mailto:|tel:)/i.test(String(e).trim())}const wo="";function kn(e){let t=e;const n=[];return t=t.replace(/`([^`\n]+)`/g,(s,i)=>{const r=n.length;return n.push(i),`${wo}CODE${r}${wo}`}),t=t.replace(/\[([^\]\n]+)\]\(([^)\s]+)\)/g,(s,i,r)=>Iu(r)?`<a href="${r}" target="_blank" rel="noopener noreferrer">${i}</a>`:i),t=t.replace(/\*\*([^\n*][^\n]*?)\*\*/g,"<strong>$1</strong>"),t=t.replace(/__([^\n_][^\n]*?)__/g,"<u>$1</u>"),t=t.replace(/~~([^\n~][^\n]*?)~~/g,"<s>$1</s>"),t=t.replace(/(^|[^\w*])\*([^\n*]+?)\*(?!\w)/g,"$1<em>$2</em>"),t=t.replace(/(^|[^\w_])_([^\n_]+?)_(?!\w)/g,"$1<em>$2</em>"),t=t.replace(/CODE(\d+)/g,(s,i)=>`<code class="wm-md-code">${n[+i]}</code>`),t}function Lu(e){if(!e)return"";const t=String(e).replace(/\[([^\]\n]+)\]\([^)\s]+\)/g,"$1");return kn(bo(t))}function Ru(e){if(!e)return"";const t=bo(e).split(`
75
75
  `),n=[];let s=0;for(;s<t.length;){const r=t[s];if(/^\s*```([\w-]*)\s*$/.exec(r)){s++;const f=[];for(;s<t.length&&!/^\s*```\s*$/.test(t[s]);)f.push(t[s]),s++;s<t.length&&s++,n.push({type:"block",html:`<pre class="wm-md-pre"><code>${f.join(`
76
76
  `)}</code></pre>`});continue}if(/^\s*[-*]\s+/.test(r)){const f=[];for(;s<t.length;){const g=/^\s*[-*]\s+(.*)$/.exec(t[s]);if(!g)break;f.push(g[1]),s++}const c=f.map(g=>`<li>${kn(g)}</li>`).join("");n.push({type:"block",html:`<ul class="wm-md-ul">${c}</ul>`});continue}const a=/^\s*(\d+)\.\s+(.*)$/.exec(r);if(a){const f=parseInt(a[1],10),c=[a[2]];for(s++;s<t.length;){const S=/^\s*\d+\.\s+(.*)$/.exec(t[s]);if(!S)break;c.push(S[1]),s++}const g=c.map(S=>`<li>${kn(S)}</li>`).join(""),A=f!==1?` start="${f}"`:"";n.push({type:"block",html:`<ol class="wm-md-ol"${A}>${g}</ol>`});continue}const l=/^(#{1,6})\s+(.*)$/.exec(r);if(l){const f=l[1].length;n.push({type:"block",html:`<h${f} class="wm-md-h wm-md-h${f}">${kn(l[2])}</h${f}>`}),s++;continue}n.push({type:"text",html:kn(r)}),s++}let i="";for(let r=0;r<n.length;r++){const o=n[r];i+=o.html;const a=n[r+1];a&&o.type!=="block"&&a.type!=="block"&&(i+=`
77
- `)}return i}const ko={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"},Nu={name:"WmOnboarding",components:{AIAvatar:wn},inject:{t:{default:()=>Me()},wmLocale:{default:()=>()=>"fr"}},props:{welcomeMessage:{type:String,default:""},subtitle:{type:String,default:""},agentName:{type:String,default:""},defaultIconUrl:{type:String,default:null},quickLinks:{type:Array,default:()=>[]},openThreads:{type:Array,default:()=>[]},busy:{type:Boolean,default:!1}},emits:["start","select","resume"],data(){return{query:""}},computed:{heroTitle(){return this.welcomeMessage?this.welcomeMessage:this.agentName?this.t("onboarding.greetingNamed",{name:this.agentName}):this.t("onboarding.greeting")},heroSub(){return this.subtitle||this.t("onboarding.heroSub")},isOddQuickLinks(){return this.quickLinks.length%2===1},quickLinksLayout(){return this.isOddQuickLinks?"wm-onb__qlist":"wm-onb__grid"},filteredThreads(){const e=this.query.trim().toLowerCase();return e?this.openThreads.filter(t=>(t.title||"").toLowerCase().includes(e)||(t.preview||"").toLowerCase().includes(e)):this.openThreads}},methods:{iconPath(e){return ko[e]||ko.link},renderPreview(e){return Lu(e)},formatTs(e){if(!e)return"";const t=new Date(e);if(Number.isNaN(t.getTime()))return"";const n=vn(this.wmLocale()),s=new Date;if(t.toDateString()===s.toDateString())return t.toLocaleTimeString(n,{hour:"2-digit",minute:"2-digit"});if(s.getTime()-t.getTime()<7*864e5){const o=t.toLocaleDateString(n,{weekday:"short"});return o.charAt(0).toUpperCase()+o.slice(1)}return t.toLocaleDateString(n,{day:"2-digit",month:"2-digit"})}}},Bu={class:"wm-onb"},Pu={class:"wm-onb__hero"},Fu={class:"wm-onb__title"},Du={class:"wm-onb__sub"},ju={class:"wm-onb__cta"},Uu=["disabled"],Hu={key:0,class:"wm-onb__section"},$u={class:"wm-onb__section-title"},Vu=["onClick"],Ku={class:"wm-onb__card-icon"},qu={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"},Wu=["d"],zu={class:"wm-onb__card-body"},Gu={class:"wm-onb__card-title"},Yu={key:0,class:"wm-onb__card-sub"},Ju={key:1,class:"wm-onb__section"},Xu={class:"wm-onb__section-title"},Qu={class:"wm-onb__search"},Zu=["placeholder","aria-label"],ed={class:"wm-onb__list"},td=["onClick"],nd=["aria-label"],sd={class:"wm-onb__thread-body"},rd={class:"wm-onb__thread-title"},id=["innerHTML"],od={class:"wm-onb__thread-meta"},ad={key:0,class:"wm-onb__thread-time"},ld={key:0,class:"wm-onb__empty"};function cd(e,t,n,s,i,r){const o=ge("AIAvatar");return p(),y("div",Bu,[u("div",Pu,[_e(o,{size:56,pulse:!0,"image-url":n.defaultIconUrl},null,8,["image-url"]),u("div",Fu,O(r.heroTitle),1),u("div",Du,O(r.heroSub),1)]),u("div",ju,[u("button",{type:"button",class:"wm-onb__startBtn",disabled:n.busy,onClick:t[0]||(t[0]=a=>e.$emit("start"))},[t[2]||(t[2]=u("span",{class:"wm-onb__startIcon"},[u("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"},[u("path",{d:"M12 5v14M5 12h14"})])],-1)),u("span",null,O(n.busy?"…":r.t("onboarding.start")),1)],8,Uu)]),n.quickLinks.length?(p(),y("div",Hu,[u("div",$u,O(r.t("onboarding.quickAccess")),1),u("div",{class:te(r.quickLinksLayout)},[(p(!0),y(Z,null,Te(n.quickLinks,(a,l)=>(p(),y("button",{key:l,type:"button",class:te(["wm-onb__card",{"wm-onb__card--row":r.isOddQuickLinks}]),onClick:f=>e.$emit("select",a)},[u("span",Ku,[(p(),y("svg",qu,[u("path",{d:r.iconPath(a.icon)},null,8,Wu)]))]),u("span",zu,[u("span",Gu,O(a.label),1),a.description?(p(),y("span",Yu,O(a.description),1)):F("",!0)])],10,Vu))),128))],2)])):F("",!0),n.openThreads.length?(p(),y("div",Ju,[u("div",Xu,O(r.t("onboarding.recentConversations")),1),u("div",Qu,[t[3]||(t[3]=u("span",{class:"wm-onb__searchIcon"},[u("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"},[u("path",{d:"M21 21l-4.35-4.35M11 17a6 6 0 100-12 6 6 0 000 12z"})])],-1)),ct(u("input",{"onUpdate:modelValue":t[1]||(t[1]=a=>i.query=a),type:"text",placeholder:r.t("onboarding.search"),"aria-label":r.t("onboarding.search")},null,8,Zu),[[Lt,i.query]])]),u("div",ed,[(p(!0),y(Z,null,Te(r.filteredThreads,a=>(p(),y("button",{key:a.id,type:"button",class:"wm-onb__thread",onClick:l=>e.$emit("resume",a)},[u("span",{class:te(["wm-onb__thread-icon",{"wm-onb__thread-icon--inverted":!a.unread}])},[t[4]||(t[4]=u("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[u("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)),a.unread?(p(),y("span",{key:0,class:"wm-onb__thread-dot","aria-label":r.t("onboarding.unread")},null,8,nd)):F("",!0)],2),u("span",sd,[u("span",rd,O(a.title),1),u("span",{class:"wm-onb__thread-preview",innerHTML:r.renderPreview(a.preview)},null,8,id)]),u("span",od,[r.formatTs(a._ts)?(p(),y("span",ad,O(r.formatTs(a._ts)),1)):F("",!0),t[5]||(t[5]=u("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"},[u("path",{d:"M5 12h14M13 5l7 7-7 7"})],-1))])],8,td))),128)),r.filteredThreads.length?F("",!0):(p(),y("div",ld,O(r.t("onboarding.noResults",{query:i.query})),1))])])):F("",!0)])}const ud=be(Nu,[["render",cd],["__scopeId","data-v-900e5f91"]]);function dd(e){return typeof e!="string"?"":e.replace(/`([^`]+)`/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(new RegExp("(?<!\\*)\\*([^*]+)\\*(?!\\*)","g"),"$1").replace(/__([^_]+)__/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\s+/g," ").trim()}const fd={name:"WmActionResult",props:{state:{type:String,default:"success"},label:{type:String,required:!0},detail:{type:String,default:""}},computed:{detailText(){return dd(this.detail)}}},hd={class:"wm-result__icon","aria-hidden":"true"},md={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"},pd={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"},gd={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"},_d={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"},yd={class:"wm-result__body"},vd={class:"wm-result__label"},bd={class:"wm-result__detail"};function wd(e,t,n,s,i,r){return p(),y("div",{class:te(["wm-result",`wm-result--${n.state}`])},[u("span",hd,[n.state==="success"?(p(),y("svg",md,[...t[0]||(t[0]=[u("path",{d:"M20 6L9 17l-5-5"},null,-1)])])):n.state==="rejected"?(p(),y("svg",pd,[...t[1]||(t[1]=[u("path",{d:"M18 6L6 18M6 6l12 12"},null,-1)])])):n.state==="awaiting"?(p(),y("svg",gd,[...t[2]||(t[2]=[u("circle",{cx:"12",cy:"12",r:"10"},null,-1),u("polyline",{points:"12 7 12 12 15 14"},null,-1)])])):(p(),y("svg",_d,[...t[3]||(t[3]=[u("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),u("line",{x1:"12",y1:"9",x2:"12",y2:"13"},null,-1),u("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"},null,-1)])]))]),u("span",yd,[u("span",vd,O(n.label),1),r.detailText?(p(),y(Z,{key:0},[t[4]||(t[4]=u("span",{class:"wm-result__sep","aria-hidden":"true"}," · ",-1)),u("span",bd,O(r.detailText),1)],64)):F("",!0)])],2)}const kd=be(fd,[["render",wd],["__scopeId","data-v-7284acd0"]]),Cd={name:"WmArtifactFormResponse",inject:{t:{default:()=>Me()}},props:{data:{type:Object,required:!0}},computed:{fields(){var e;return Array.isArray((e=this.data)==null?void 0:e.fields)?this.data.fields:[]}}},Sd={class:"wm-art wm-art--formResponse"},Ad={class:"wm-art__head"},xd={class:"wm-art__title"},Td={class:"wm-art__badge wm-art__badge--success"},Md={class:"wm-art__body"},Ed={class:"wm-art__fieldLabel"};function Od(e,t,n,s,i,r){return p(),y("div",Sd,[u("div",Ad,[u("div",xd,O(n.data.title||r.t("form.title")),1),u("span",Td,[t[0]||(t[0]=u("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"},[u("polyline",{points:"20 6 9 17 4 12"})],-1)),Zn(" "+O(r.t("form.sent")),1)])]),u("div",Md,[(p(!0),y(Z,null,Te(r.fields,(o,a)=>(p(),y("div",{key:a,class:"wm-art__field"},[u("div",Ed,O(o.label),1),u("div",{class:te(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},O(o.value),3)]))),128))])])}const Id=be(Cd,[["render",Od],["__scopeId","data-v-713aecf1"]]),Ld={name:"WmArtifactInfoCard",props:{data:{type:Object,required:!0}},computed:{fields(){var e;return Array.isArray((e=this.data)==null?void 0:e.fields)?this.data.fields:[]},hasBody(){var e;return!!((e=this.data)!=null&&e.body)||this.fields.length>0}}},Rd={class:"wm-art wm-art--infoCard"},Nd={key:0,class:"wm-art__image"},Bd=["src","alt"],Pd={class:"wm-art__head"},Fd={class:"wm-art__headMain"},Dd={class:"wm-art__title"},jd={key:0,class:"wm-art__subtitle"},Ud={key:1,class:"wm-art__body"},Hd={key:0,class:"wm-art__text"},$d={class:"wm-art__fieldLabel"};function Vd(e,t,n,s,i,r){return p(),y("div",Rd,[n.data.image_url?(p(),y("figure",Nd,[u("img",{src:n.data.image_url,alt:n.data.title||"",loading:"lazy"},null,8,Bd)])):F("",!0),u("div",Pd,[u("div",Fd,[u("div",Dd,O(n.data.title),1),n.data.subtitle?(p(),y("div",jd,O(n.data.subtitle),1)):F("",!0)]),n.data.badge&&n.data.badge.label?(p(),y("span",{key:0,class:te(["wm-art__badge",`wm-art__badge--${n.data.badge.tone||"neutral"}`])},O(n.data.badge.label),3)):F("",!0)]),r.hasBody?(p(),y("div",Ud,[n.data.body?(p(),y("div",Hd,O(n.data.body),1)):F("",!0),r.fields.length?(p(!0),y(Z,{key:1},Te(r.fields,(o,a)=>(p(),y("div",{key:a,class:"wm-art__field"},[u("div",$d,O(o.label),1),u("div",{class:te(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},O(o.value),3)]))),128)):F("",!0)])):F("",!0)])}const Kd=be(Ld,[["render",Vd],["__scopeId","data-v-7eae0e4a"]]);function qd(e,t,n){if(!e)return"";const s=new Date(e);if(Number.isNaN(s.getTime()))return e;const i=s.toLocaleDateString(t,{day:"numeric",month:"long",year:"numeric"}),r=s.toLocaleTimeString(t,{hour:"2-digit",minute:"2-digit"});return`${i}${n}${r}`}const Wd={name:"WmArtifactTicket",inject:{t:{default:()=>Me()},wmLocale:{default:()=>()=>"fr"}},props:{data:{type:Object,required:!0}},computed:{fields(){var e;return Array.isArray((e=this.data)==null?void 0:e.fields)?this.data.fields:[]},formattedDate(){var e;return qd((e=this.data)==null?void 0:e.created_at,vn(this.wmLocale()),this.t("ticket.dateAt"))}},methods:{isPriority(e){return/priorit|^prio$/i.test(String(e||"").trim())},isDate(e){return/date|échéanc|echeanc|deadline|due|créé|cree/i.test(String(e||"").trim())},priorityLevel(e){const t=String(e||"").toLowerCase();return/high|haute|élev|elev|critic|critiq|urgent/.test(t)?3:/low|basse|faible|minor/.test(t)?1:2}}},zd={class:"wm-art wm-art--ticket"},Gd={class:"wm-art__head wm-tk__head"},Yd={class:"wm-art__title wm-tk__title"},Jd={class:"wm-tk__sub"},Xd={class:"wm-tk__ref"},Qd={key:0,class:"wm-tk__text"},Zd={key:0,class:"wm-art__body"},ef={class:"wm-art__fieldLabel"},tf=["data-level"],nf={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"},sf={key:1,class:"wm-art__footer wm-tk__footer"};function rf(e,t,n,s,i,r){return p(),y("div",zd,[u("div",Gd,[u("div",Yd,O(n.data.title),1),u("div",Jd,[u("div",Xd,[t[0]||(t[0]=u("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"},[u("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"}),u("path",{d:"M13 5v2M13 17v2M13 11v2"})],-1)),u("span",null,O(n.data.reference),1)]),u("span",{class:te(["wm-art__badge","wm-tk__badge",`wm-art__badge--${n.data.status.tone||"neutral"}`])},[t[1]||(t[1]=u("span",{class:"wm-tk__dot","aria-hidden":"true"},null,-1)),Zn(" "+O(n.data.status.label),1)],2)]),n.data.body?(p(),y("div",Qd,O(n.data.body),1)):F("",!0)]),r.fields.length?(p(),y("div",Zd,[(p(!0),y(Z,null,Te(r.fields,(o,a)=>(p(),y("div",{key:a,class:"wm-art__field"},[u("div",ef,O(o.label),1),u("div",{class:te(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},[r.isPriority(o.label)?(p(),y("svg",{key:0,class:"wm-tk__prio","data-level":r.priorityLevel(o.value),width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true"},[...t[2]||(t[2]=[u("rect",{x:"1",y:"8",width:"2",height:"3",rx:"0.5"},null,-1),u("rect",{x:"5",y:"5",width:"2",height:"6",rx:"0.5"},null,-1),u("rect",{x:"9",y:"2",width:"2",height:"9",rx:"0.5"},null,-1)])],8,tf)):r.isDate(o.label)?(p(),y("svg",nf,[...t[3]||(t[3]=[u("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"},null,-1),u("path",{d:"M16 2v4M8 2v4M3 10h18"},null,-1)])])):F("",!0),u("span",null,O(o.value),1)],2)]))),128))])):F("",!0),n.data.created_at?(p(),y("div",sf,[t[4]||(t[4]=u("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"},[u("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),u("path",{d:"M16 2v4M8 2v4M3 10h18"})],-1)),u("span",null,O(r.formattedDate),1)])):F("",!0)])}const of={form_response:Id,info_card:Kd,ticket:be(Wd,[["render",rf],["__scopeId","data-v-5f30c914"]])},af={name:"WmArtifactRenderer",props:{artifact:{type:Object,required:!0}},computed:{component(){var t;const e=(t=this.artifact)==null?void 0:t.kind;return e&&of[e]||null}}};function lf(e,t,n,s,i,r){return r.component?(p(),ve(ja(r.component),{key:0,data:n.artifact.data},null,8,["data"])):F("",!0)}const cf=be(af,[["render",lf]]),uf={name:"WmAttachmentPreview",inject:{signAttachmentFn:{default:null},t:{default:()=>Me()}},props:{attachment:{type:Object,required:!0}},data(){return{url:null,loading:!1}},computed:{kind(){var n,s;const e=(n=this.attachment)==null?void 0:n.type;if(e)return e;const t=(((s=this.attachment)==null?void 0:s.mime_type)||"").toLowerCase();return t.startsWith("image/")?"image":t.startsWith("audio/")?"audio":t.startsWith("video/")?"video":"file"},displayName(){var e,t,n;return((t=(e=this.attachment)==null?void 0:e.metadata)==null?void 0:t.name)||((n=this.attachment)==null?void 0:n.name)||this.guessNameFromPath()||this.t("attachment.fallbackName")},sizeLabel(){var t;const e=(t=this.attachment)==null?void 0:t.size_bytes;return e?e<1024?this.t("attachment.bytes",{size:e}):e<1024*1024?this.t("attachment.kilobytes",{size:(e/1024).toFixed(0)}):this.t("attachment.megabytes",{size:(e/(1024*1024)).toFixed(1)}):""}},watch:{"attachment.path":{handler(){this.refresh()},immediate:!0}},methods:{guessNameFromPath(){var n;return((((n=this.attachment)==null?void 0:n.path)||"").split("/").pop()||"").replace(/^[0-9a-f-]{8,}-/,"")},async refresh(){var e;if(!(!((e=this.attachment)!=null&&e.path)||!this.signAttachmentFn)){this.loading=!0;try{this.url=await this.signAttachmentFn(this.attachment.path)}finally{this.loading=!1}}},onFileClick(e){this.url||e.preventDefault()}}},df=["href"],ff=["src","alt"],hf=["src"],mf=["src"],pf=["href","download"],gf={class:"wm-att__main"},_f={class:"wm-att__name"},yf={key:0,class:"wm-att__meta"},vf={key:0,class:"wm-att__spin","aria-hidden":"true"};function bf(e,t,n,s,i,r){return p(),y("div",{class:te(["wm-att",["wm-att--"+(r.kind||"file")]])},[r.kind==="image"&&i.url?(p(),y("a",{key:0,href:i.url,target:"_blank",rel:"noopener",class:"wm-att__imgWrap"},[u("img",{src:i.url,alt:r.displayName,loading:"lazy"},null,8,ff)],8,df)):r.kind==="audio"&&i.url?(p(),y("audio",{key:1,src:i.url,controls:"",preload:"metadata"},null,8,hf)):r.kind==="video"&&i.url?(p(),y("video",{key:2,src:i.url,controls:"",preload:"metadata"},null,8,mf)):(p(),y("a",{key:3,class:"wm-att__file",href:i.url||"#",download:r.displayName,target:"_blank",rel:"noopener",onClick:t[0]||(t[0]=(...o)=>r.onFileClick&&r.onFileClick(...o))},[t[1]||(t[1]=u("span",{class:"wm-att__icon"},[u("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"},[u("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),u("path",{d:"M14 2v6h6"})])],-1)),u("span",gf,[u("span",_f,O(r.displayName),1),r.sizeLabel?(p(),y("span",yf,O(r.sizeLabel),1)):F("",!0)]),i.loading?(p(),y("span",vf)):F("",!0)],8,pf))],2)}const wf=be(uf,[["render",bf],["__scopeId","data-v-afc7b0d3"]]),kf={name:"WmBubble",props:{role:{type:String,default:"ai"},text:{type:String,default:""}},computed:{rendered(){return Ru(this.text)}}},Cf=["innerHTML"];function Sf(e,t,n,s,i,r){return p(),y("div",{class:te(["wm-bubble","wm-bubble--"+n.role])},[Ua(e.$slots,"default",{},()=>[u("span",{innerHTML:r.rendered},null,8,Cf)])],2)}const Af=be(kf,[["render",Sf],["__scopeId","data-v-7ab13147"]]),xf={name:"WmTyping"},Tf={class:"wm-typing"};function Mf(e,t,n,s,i,r){return p(),y("div",Tf,[...t[0]||(t[0]=[u("span",{style:{"animation-delay":"0s"}},null,-1),u("span",{style:{"animation-delay":"0.2s"}},null,-1),u("span",{style:{"animation-delay":"0.4s"}},null,-1)])])}const Ef=be(xf,[["render",Mf],["__scopeId","data-v-df2447fd"]]);function Rt(e){return e?e.client_msg_id||e.id:""}const Of={transferred_to_human:"system.transferredToHuman",assigned:"system.assigned",unassigned:"system.unassigned",resolved:"system.resolved",reopened:"system.reopened",idle:"system.idle"},If=80,Lf=200,Rf={name:"WmMessageList",components:{AIAvatar:wn,HumanAvatar:vo,Bubble:Af,Typing:Ef,ActionResult:kd,AttachmentPreview:wf,ArtifactRenderer:cf},inject:{t:{default:()=>Me()},wmLocale:{default:()=>()=>"fr"}},props:{messages:{type:Array,default:()=>[]},streamingActive:{type:Boolean,default:!1},dateLabel:{type:String,default:""},conversationId:{type:[String,Number],default:null},loadingMore:{type:Boolean,default:!1},hasMore:{type:Boolean,default:!1},unreadAnchorId:{type:Number,default:null},unreadBoundaryTs:{type:String,default:""},aiAgentName:{type:String,default:""},aiAgentAvatarUrl:{type:String,default:null}},emits:["load-more"],data(){return{silentFades:!1,widthByKey:Object.freeze({})}},computed:{historyExhausted(){return!this.hasMore&&!this.loadingMore&&this.messages.length>=20},groups(){var n,s,i,r;const e=[];for(const o of this.messages){const a=this.roleOf(o);if(a==="system"){if(((n=o==null?void 0:o.payload)==null?void 0:n.event)==="action_admin_pending"){const c=e[e.length-1];c&&c.role==="ai"?c.messages.push(o):e.push({key:`g-${Rt(o)}`,role:"ai",agentName:"",agentAvatarUrl:null,messages:[o],items:[]});continue}e.push({key:`sys-${Rt(o)}`,role:a,messages:[o],items:[],systemLabel:this.systemLabel(o)});continue}const l=e[e.length-1];l&&l.role===a&&(a==="ai"||l.agentName===(((s=o==null?void 0:o.author)==null?void 0:s.name)||""))?l.messages.push(o):e.push({key:`g-${Rt(o)}`,role:a,agentName:((i=o==null?void 0:o.author)==null?void 0:i.name)||"",agentAvatarUrl:((r=o==null?void 0:o.author)==null?void 0:r.avatar_url)||null,messages:[o],items:[]})}for(const o of e){if(o.role==="system")continue;const a=[];for(const l of o.messages)for(const f of this.itemsOf(l))a.push(f);o.items=a}const t=[];for(const o of e){if(o.role!=="system"&&!o.items.length)continue;const a=t[t.length-1];if(a&&a.role!=="system"&&a.role===o.role&&(o.role==="ai"||a.agentName===o.agentName)){a.messages.push(...o.messages),a.items.push(...o.items);continue}t.push(o)}for(const o of t)o.role!=="system"&&(o.key=this.stableGroupKey(o.messages));return t},unreadGroupKey(){if(this.unreadAnchorId==null)return null;const e=this.unreadAnchorId,t=this.unreadBoundaryTs;for(const n of this.groups){if(n.role==="user"||n.role==="system"||!n.items.length)continue;const s=n.messages[0];if(!s)continue;const i=kt(s.id);if(i!=null&&!(i<=e)&&!(t&&s.created_at&&s.created_at>t))return n.key}return null}},watch:{messages:{handler:"snapshotAndRestore",deep:!0},conversationId(e,t){e!==t&&(this._groupIdByMsgKey=null,this.silentFades=!1)},loadingMore(e){e||(this._pendingLoadMore=!1),e&&(this.silentFades=!0),this.snapshotAndRestore()},streamingActive:"snapshotAndRestore"},mounted(){this._lastSeenConvId=this.conversationId,this.scrollToBottom(),this._measureFrame=null,this._ro=new ResizeObserver(()=>this.scheduleMeasure()),this.$refs.scrollEl&&this._ro.observe(this.$refs.scrollEl),this.$nextTick(()=>this.measureRows())},beforeUnmount(){var e;(e=this._ro)==null||e.disconnect(),this._measureFrame&&cancelAnimationFrame(this._measureFrame)},updated(){this.scheduleMeasure()},methods:{messageKey:Rt,stableGroupKey(e){this._groupIdByMsgKey||(this._groupIdByMsgKey=new Map,this._groupIdCounter=0);const t=this._groupIdByMsgKey;let n=null;for(const s of e){const i=Rt(s);if(i&&t.has(i)){n=t.get(i);break}}n==null&&(n=++this._groupIdCounter);for(const s of e){const i=Rt(s);i&&t.set(i,n)}return`g-${n}`},isAtBottom(e){return e.scrollHeight-e.scrollTop-e.clientHeight<=If},onScroll(){const e=this.$refs.scrollEl;e&&(this.loadingMore||!this.hasMore||this._pendingLoadMore||e.scrollTop<=Lf&&(this._pendingLoadMore=!0,this.$emit("load-more")))},snapshotAndRestore(){const e=this.$refs.scrollEl;if(!e||this._scrollSnap)return;const t=this._lastSeenConvId!==this.conversationId;this._lastSeenConvId=this.conversationId;const n=this.isAtBottom(e);let s=null;if(!t&&!n){const r=this.pickAnchor(e);if(r!=null&&r.rowKey){const o=this.findRowByKey(e,r.rowKey);if(o){const a=e.getBoundingClientRect().top;s={rowKey:r.rowKey,relY:o.getBoundingClientRect().top-a}}}}const i={forceBottom:t,wasPinned:n,anchor:s};this._scrollSnap=i,this.$nextTick(()=>{if(this._scrollSnap=null,i.forceBottom||i.wasPinned){e.scrollTop=e.scrollHeight;return}if(!i.anchor)return;const r=()=>{const o=i.anchor,a=this.findRowByKey(e,o.rowKey);if(!a)return;const f=a.getBoundingClientRect().top-e.getBoundingClientRect().top-o.relY;Math.abs(f)>.5&&(e.scrollTop+=f)};r(),requestAnimationFrame(()=>{r(),requestAnimationFrame(r)})})},pickAnchor(e){const t=e.getBoundingClientRect().top,n=e.querySelectorAll(".wm-list__row[data-row-key]");let s=null;for(const i of n)if(s||(s=i),i.getBoundingClientRect().bottom>=t)return{rowKey:i.dataset.rowKey};return s?{rowKey:s.dataset.rowKey}:null},findRowByKey(e,t){if(!t)return null;const n=typeof CSS<"u"&&CSS.escape?CSS.escape(t):t.replace(/["\\]/g,"\\$&");return e.querySelector(`.wm-list__row[data-row-key="${n}"]`)},roleOf(e){var n,s;if((e==null?void 0:e.type)==="system"||((n=e==null?void 0:e.payload)==null?void 0:n.type)==="system")return"system";const t=(s=e==null?void 0:e.author)==null?void 0:s.type;return t==="user"?"user":t==="agent_human"?"human":"ai"},roleLabel(e){if(e.role==="human")return e.agentName||this.t("common.agent");const t=this.t("common.aiAssistant");return this.aiAgentName?`${this.aiAgentName} • ${t}`:t},itemsOf(e){var t;if(!e)return[];if(e.type==="system"&&((t=e==null?void 0:e.payload)==null?void 0:t.event)==="action_admin_pending")return[{message:e,partKey:"main",renderAs:"admin-pending",kind:{top:"bubble",bottom:"bubble"}}];if(e.type==="action"&&e.payload&&e.payload.state!=="pending"){const n=[{message:e,partKey:"main",renderAs:"action",kind:{top:"bubble",bottom:"bubble"}}];return this.actionArtifact(e)&&n.push({message:e,partKey:"artifact",renderAs:"artifact-of-action",kind:{top:"card",bottom:"card"}}),n}return this.artifactOf(e)?[{message:e,partKey:"main",renderAs:"artifact",kind:{top:"card",bottom:"card"}}]:e.text_md||this.attachmentsOf(e).length?[{message:e,partKey:"main",renderAs:"bubble",kind:{top:"bubble",bottom:"bubble"}}]:[]},cornersFor(e,t){var U,ee,ue;const n=e.items,s=(U=n[t])==null?void 0:U.kind,i=(ee=n[t-1])==null?void 0:ee.kind,r=(ue=n[t+1])==null?void 0:ue.kind,o=e.role==="user",a=14,l=4,f=i==null?void 0:i.bottom,c=r==null?void 0:r.top,g=this.widthByKey[this.rowKeyOf(e,t)],A=this.widthByKey[this.rowKeyOf(e,t-1)],S=this.widthByKey[this.rowKeyOf(e,t+1)],K=.5,I=(ye,we,z)=>ye!=null&&g!=null?ye+K>=g:we===z||we==="card"&&z==="bubble";let X=a,G=a,q=a,Q=a;return o?(f&&(G=l),(c||!r)&&(q=l),f&&I(A,f,s==null?void 0:s.top)&&(X=l),c&&I(S,c,s==null?void 0:s.bottom)&&(Q=l)):(f&&(X=l),(c||!r)&&(Q=l),f&&I(A,f,s==null?void 0:s.top)&&(G=l),c&&I(S,c,s==null?void 0:s.bottom)&&(q=l)),{tl:X,tr:G,br:q,bl:Q}},cornersStyle(e,t){if(e.items.length<2)return null;const n=this.cornersFor(e,t);return{"--wm-r-tl":`${n.tl}px`,"--wm-r-tr":`${n.tr}px`,"--wm-r-br":`${n.br}px`,"--wm-r-bl":`${n.bl}px`}},rowKeyOf(e,t){var s;const n=(s=e==null?void 0:e.items)==null?void 0:s[t];return n?`${Rt(n.message)}-${n.partKey}`:""},scheduleMeasure(){this._measureFrame||(this._measureFrame=requestAnimationFrame(()=>{this._measureFrame=null,this.measureRows()}))},measureRows(){const e=this.$refs.scrollEl;if(!e)return;const t={};for(const r of e.querySelectorAll(".wm-list__row[data-row-key]")){const o=r.dataset.rowKey;if(!o)continue;const a=r.querySelector(".wm-bubble, .wm-result, .wm-art, .wm-list__body");if(!a)continue;const l=a.getBoundingClientRect().width;l>0&&(t[o]=l)}const n=this.widthByKey,s=Object.keys(n),i=Object.keys(t);if(s.length===i.length){let r=!0;for(const o of i)if(Math.abs((n[o]??0)-t[o])>.5){r=!1;break}if(r)return}this.widthByKey=Object.freeze(t)},lastTimeOf(e){const t=e.items[e.items.length-1],n=(t==null?void 0:t.message)||e.messages[e.messages.length-1];if(!(n!=null&&n.created_at))return"";try{return ho(new Date(n.created_at),vn(this.wmLocale()))}catch{return""}},hasTrailingOverlay(e){if(!e.messages.length)return!1;const t=e.messages[e.messages.length-1],n=e.items[e.items.length-1];return!!t&&(n==null?void 0:n.message)!==t},attachmentsOf(e){var n;const t=(n=e==null?void 0:e.payload)==null?void 0:n.attachments;return Array.isArray(t)?t:[]},artifactOf(e){var n;const t=(n=e==null?void 0:e.metadata)==null?void 0:n.artifact;return!t||typeof t!="object"||typeof t.kind!="string"?null:t},actionLabel(e){var t;return((t=e==null?void 0:e.payload)==null?void 0:t.name)||(e==null?void 0:e.text_md)||this.t("common.action")},actionDetail(e){var n,s,i,r,o,a;const t=e==null?void 0:e.payload;return t?t.state==="success"?((n=t.success)==null?void 0:n.summary)||((i=(s=t.success)==null?void 0:s.metadata)==null?void 0:i.description)||"":t.state==="rejected"?((r=t.rejected)==null?void 0:r.reason)||this.t("action.rejectedByUser"):t.state==="failure"&&(((o=t.failure)==null?void 0:o.summary)||((a=t.failure)==null?void 0:a.error))||"":""},actionArtifact(e){var n,s;const t=(s=(n=e==null?void 0:e.payload)==null?void 0:n.success)==null?void 0:s.artifact;return!t||typeof t!="object"||typeof t.kind!="string"?null:t},systemLabel(e){var i,r,o;const t=(i=e==null?void 0:e.payload)==null?void 0:i.event,n=Of[t],s=((r=e==null?void 0:e.metadata)==null?void 0:r.agent_name)||((o=e==null?void 0:e.author)==null?void 0:o.name)||this.t("messageList.anAgent");return n?this.t(n,{name:s}):(e==null?void 0:e.text_md)||this.t("messageList.conversationUpdate")},scrollToBottom(){const e=this.$refs.scrollEl;e&&(e.scrollTop=e.scrollHeight)}}},Nf={key:0,class:"wm-list__loadMore",role:"status","aria-live":"polite"},Bf={class:"wm-list__loadMore-lbl"},Pf={key:1,class:"wm-list__historyEnd"},Ff={key:2,class:"wm-list__sep"},Df={class:"wm-list__sep-label"},jf={key:0,class:"wm-list__sep wm-list__sep--unread"},Uf={class:"wm-list__sep-label wm-list__sep-label--unread"},Hf={key:0,class:"wm-list__sysep"},$f={class:"wm-list__sysep-label"},Vf=["data-row-key"],Kf={key:0,class:"wm-list__avatarSlot"},qf={key:5,class:"wm-list__body"},Wf={key:0},zf={key:1,"aria-hidden":"true"},Gf={key:2},Yf={key:3,class:"wm-list__row wm-list__row--ai fade-up"},Jf={class:"wm-list__avatarSlot"};function Xf(e,t,n,s,i,r){const o=ge("AIAvatar"),a=ge("HumanAvatar"),l=ge("ActionResult"),f=ge("ArtifactRenderer"),c=ge("Bubble"),g=ge("AttachmentPreview"),A=ge("Typing");return p(),y("div",{ref:"scrollEl",class:te(["wm-list",{"wm-list--silent":i.silentFades}]),onScrollPassive:t[0]||(t[0]=(...S)=>r.onScroll&&r.onScroll(...S))},[n.loadingMore?(p(),y("div",Nf,[t[1]||(t[1]=u("span",{class:"wm-list__loadMore-spinner","aria-hidden":"true"},null,-1)),u("span",Bf,O(r.t("messageList.loadingHistory")),1)])):r.historyExhausted?(p(),y("div",Pf,O(r.t("messageList.conversationStart")),1)):F("",!0),n.dateLabel?(p(),y("div",Ff,[t[2]||(t[2]=u("div",{class:"wm-list__line"},null,-1)),u("span",Df,O(n.dateLabel),1),t[3]||(t[3]=u("div",{class:"wm-list__line"},null,-1))])):F("",!0),(p(!0),y(Z,null,Te(r.groups,(S,K)=>(p(),y(Z,{key:S.key},[S.key===r.unreadGroupKey?(p(),y("div",jf,[t[4]||(t[4]=u("div",{class:"wm-list__line wm-list__line--unread"},null,-1)),u("span",Uf,O(r.t("messageList.unread")),1),t[5]||(t[5]=u("div",{class:"wm-list__line wm-list__line--unread"},null,-1))])):F("",!0),S.role==="system"||S.items.length?(p(),y("div",{key:1,class:te(["wm-list__group","wm-list__group--"+S.role])},[S.role==="system"?(p(),y("div",Hf,[t[6]||(t[6]=u("div",{class:"wm-list__line wm-list__line--strong"},null,-1)),u("span",$f,O(S.systemLabel),1),t[7]||(t[7]=u("div",{class:"wm-list__line wm-list__line--strong"},null,-1))])):(p(),y(Z,{key:1},[(p(!0),y(Z,null,Te(S.items,(I,X)=>(p(),y("div",{key:`${r.messageKey(I.message)}-${I.partKey}`,"data-row-key":`${r.messageKey(I.message)}-${I.partKey}`,class:te(["wm-list__row fade-up",["wm-list__row--"+S.role,{"is-pending":I.message._pending,"is-failed":I.message._failed}]]),style:De(r.cornersStyle(S,X))},[S.role!=="user"?(p(),y("div",Kf,[X===S.items.length-1?(p(),y(Z,{key:0},[S.role==="ai"?(p(),ve(o,{key:0,size:26,tail:!0,name:n.aiAgentName,"image-url":n.aiAgentAvatarUrl},null,8,["name","image-url"])):(p(),ve(a,{key:1,name:S.agentName,"avatar-url":S.agentAvatarUrl,size:26,tail:!0},null,8,["name","avatar-url"]))],64)):F("",!0)])):F("",!0),I.renderAs==="action"?(p(),ve(l,{key:1,state:I.message.payload.state,label:r.actionLabel(I.message),detail:r.actionDetail(I.message)},null,8,["state","label","detail"])):I.renderAs==="admin-pending"?(p(),ve(l,{key:2,state:"awaiting",label:r.t("messageList.approvalRequestSent"),detail:I.message.text_md||""},null,8,["label","detail"])):I.renderAs==="artifact-of-action"?(p(),ve(f,{key:3,artifact:r.actionArtifact(I.message)},null,8,["artifact"])):I.renderAs==="artifact"?(p(),ve(f,{key:4,artifact:r.artifactOf(I.message)},null,8,["artifact"])):(p(),y("div",qf,[I.message.text_md?(p(),ve(c,{key:0,role:S.role,text:I.message.text_md},null,8,["role","text"])):F("",!0),r.attachmentsOf(I.message).length?(p(),y("div",{key:1,class:te(["wm-list__atts",{"wm-list__atts--align-end":S.role==="user"}])},[(p(!0),y(Z,null,Te(r.attachmentsOf(I.message),(G,q)=>(p(),ve(g,{key:`${r.messageKey(I.message)}-att-${q}`,attachment:G},null,8,["attachment"]))),128))],2)):F("",!0)]))],14,Vf))),128)),(S.role!=="user"||r.lastTimeOf(S))&&!r.hasTrailingOverlay(S)?(p(),y("div",{key:0,class:te(["wm-list__meta",{"wm-list__meta--right":S.role==="user"}])},[S.role!=="user"?(p(),y("span",Wf,O(r.roleLabel(S)),1)):F("",!0),S.role!=="user"&&r.lastTimeOf(S)?(p(),y("span",zf,"·")):F("",!0),r.lastTimeOf(S)?(p(),y("span",Gf,O(r.lastTimeOf(S)),1)):F("",!0)],2)):F("",!0)],64))],2)):F("",!0)],64))),128)),n.streamingActive?(p(),y("div",Yf,[u("div",Jf,[_e(o,{size:26,tail:!0,name:n.aiAgentName,"image-url":n.aiAgentAvatarUrl},null,8,["name","image-url"])]),_e(A)])):F("",!0)],34)}const Qf=be(Rf,[["render",Xf],["__scopeId","data-v-d769b193"]]),ss=typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function",Ys=typeof window<"u"&&typeof window.MediaRecorder<"u";function Zf(){return Ys&&["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"].find(t=>{var n,s;return(s=(n=window.MediaRecorder).isTypeSupported)==null?void 0:s.call(n,t)})||""}function Co({audio:e}){return{video:!0,audio:!!e,selfBrowserSurface:"include",surfaceSwitching:"include",systemAudio:e?"include":"exclude"}}async function eh(){if(!ss)return null;let e;try{e=await navigator.mediaDevices.getDisplayMedia(Co({audio:!1}))}catch(t){return(t==null?void 0:t.name)!=="NotAllowedError"&&console.error("[media] screenshot picker",t),null}try{return await th(e)}catch(t){return console.error("[media] screenshot capture",t),null}finally{e.getTracks().forEach(t=>{t.stop()})}}async function th(e){const t=document.createElement("video");t.muted=!0,t.playsInline=!0,t.srcObject=e,await t.play(),await new Promise(a=>requestAnimationFrame(a));const n=t.videoWidth||1280,s=t.videoHeight||720,i=document.createElement("canvas");i.width=n,i.height=s,i.getContext("2d").drawImage(t,0,0,n,s);const r=await new Promise((a,l)=>{i.toBlob(f=>f?a(f):l(new Error("toBlob failed")),"image/png")}),o=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19);return new File([r],`capture-${o}.png`,{type:"image/png"})}async function nh(e={}){var f;if(!ss||!Ys)return null;let t;try{t=await navigator.mediaDevices.getDisplayMedia(Co({audio:!0}))}catch(c){return(c==null?void 0:c.name)!=="NotAllowedError"&&console.error("[media] record picker",c),null}const n=Zf();let s;try{s=n?new window.MediaRecorder(t,{mimeType:n}):new window.MediaRecorder(t)}catch(c){return console.error("[media] recorder init",c),t.getTracks().forEach(g=>{g.stop()}),null}const i=[];let r=null,o=!1;s.addEventListener("dataavailable",c=>{c.data&&c.data.size>0&&i.push(c.data)}),s.addEventListener("stop",()=>{var c,g;if(r&&clearInterval(r),t.getTracks().forEach(A=>{A.stop()}),i.length){const A=s.mimeType||n||"video/webm",S=new Blob(i,{type:A}),K=/mp4/.test(A)?"mp4":"webm",I=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),X=new File([S],`ecran-${I}.${K}`,{type:A});(c=e.onfinalize)==null||c.call(e,X)}else(g=e.oncancel)==null||g.call(e)}),t.getVideoTracks().forEach(c=>{c.addEventListener("ended",()=>a(),{once:!0})});function a(){if(!o&&(o=!0,s.state!=="inactive"))try{s.stop()}catch(c){console.error("[media] recorder stop",c)}}try{s.start(1e3)}catch(c){return console.error("[media] recorder start",c),t.getTracks().forEach(g=>{g.stop()}),null}(f=e.onstart)==null||f.call(e);const l=Date.now();return r=setInterval(()=>{var c;(c=e.ontick)==null||c.call(e,Date.now()-l)},500),{stop:a,get state(){return s.state}}}const sh=[{action:"file",labelKey:"composer.attachFile",path:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"},{action:"screenshot",labelKey:"composer.screenshot",path:"M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2z M12 17a4 4 0 100-8 4 4 0 000 8z"},{action:"record",labelKey:"composer.recordScreen",path:"M23 7l-7 5 7 5V7z M1 5a2 2 0 012-2h12a2 2 0 012 2v14a2 2 0 01-2 2H3a2 2 0 01-2-2V5z"}],rh={name:"WmComposer",inject:{t:{default:()=>Me()}},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 sh.map(e=>({...e,label:this.t(e.labelKey),disabled:e.action==="screenshot"&&!ss||e.action==="record"&&(!ss||!Ys)}))},recordingElapsedLabel(){const e=Math.floor(this.recordingElapsed/1e3),t=Math.floor(e/60),n=e%60;return`${t}:${n.toString().padStart(2,"0")}`}},watch:{modelValue(e){e!==this.local&&(this.local=e,this.$nextTick(()=>this.autosize()))},local(e){this.$emit("update:modelValue",e)}},mounted(){this.autosize()},beforeUnmount(){if(this.recorder)try{this.recorder.stop()}catch{}},methods:{focus(){const e=this.$refs.inputEl;if(!(!e||this.disabled))try{e.focus({preventScroll:!0})}catch{e.focus()}},onSubmit(){if(!this.canSend)return;const e=this.local.trim();this.local="",this.$emit("send",e),this.$nextTick(()=>this.autosize())},onKeydown(e){e.key==="Enter"&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.isComposing&&(e.preventDefault(),this.onSubmit())},autosize(){const e=this.$refs.inputEl;e&&(e.style.height="auto",e.style.height=`${e.scrollHeight}px`)},onFile(e){const t=Array.from(e.target.files||[]);for(const n of t)this.$emit("attach",n);e.target.value=""},onAttachAction(e){this.attachOpen=!1,e==="file"?this.pickFile():e==="screenshot"?this.captureScreenshot():e==="record"&&this.startRecording()},pickFile(){var e;(e=this.$refs.fileEl)==null||e.click()},async captureScreenshot(){if(this.disabled)return;const e=await eh();e&&this.$emit("attach",e)},async startRecording(){if(this.recording||this.disabled)return;this.recordingElapsed=0;const e=await nh({onstart:()=>{this.recording=!0},ontick:t=>{this.recordingElapsed=t},onfinalize:t=>{this.$emit("attach",t),this.recording=!1,this.recordingElapsed=0,this.recorder=null},oncancel:()=>{this.recording=!1,this.recordingElapsed=0,this.recorder=null}});e&&(this.recorder=e)},stopRecording(){if(this.recorder)try{this.recorder.stop()}catch(e){console.error("[composer] stop recording",e)}}}},ih={class:"wm-compose-wrap"},oh={key:0,class:"wm-rec"},ah={class:"wm-rec__lbl"},lh={key:1,class:"wm-compose__menu",role:"menu"},ch=["disabled","onClick"],uh={class:"wm-compose__menuIcon"},dh={viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true"},fh=["d"],hh=["placeholder","disabled"],mh={class:"wm-compose__actions"},ph=["title","aria-label","disabled"],gh=["disabled","aria-label"];function _h(e,t,n,s,i,r){return p(),y("div",ih,[i.recording?(p(),y("div",oh,[t[8]||(t[8]=u("span",{class:"wm-rec__dot","aria-hidden":"true"},null,-1)),u("span",ah,O(r.t("composer.recording",{time:r.recordingElapsedLabel})),1),u("button",{type:"button",class:"wm-rec__stop",onClick:t[0]||(t[0]=(...o)=>r.stopRecording&&r.stopRecording(...o))},O(r.t("composer.stop")),1)])):F("",!0),u("form",{class:te(["wm-compose",{"has-attach":i.attachOpen}]),onSubmit:t[7]||(t[7]=wt((...o)=>r.onSubmit&&r.onSubmit(...o),["prevent"]))},[u("input",{ref:"fileEl",type:"file",hidden:"",multiple:"",onChange:t[1]||(t[1]=(...o)=>r.onFile&&r.onFile(...o))},null,544),i.attachOpen?(p(),y("div",{key:0,class:"wm-compose__overlay",onClick:t[2]||(t[2]=o=>i.attachOpen=!1)})):F("",!0),i.attachOpen?(p(),y("div",lh,[(p(!0),y(Z,null,Te(r.attachItems,o=>(p(),y("button",{key:o.action,type:"button",class:"wm-compose__menuItem",disabled:o.disabled,onClick:a=>r.onAttachAction(o.action)},[u("span",uh,[(p(),y("svg",dh,[u("path",{d:o.path,stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",fill:"none"},null,8,fh)]))]),u("span",null,O(o.label),1)],8,ch))),128))])):F("",!0),ct(u("textarea",{ref:"inputEl","onUpdate:modelValue":t[3]||(t[3]=o=>i.local=o),class:"wm-compose__input",rows:"3",placeholder:n.placeholder,disabled:n.disabled,onKeydown:t[4]||(t[4]=(...o)=>r.onKeydown&&r.onKeydown(...o)),onInput:t[5]||(t[5]=(...o)=>r.autosize&&r.autosize(...o))},null,40,hh),[[Lt,i.local]]),u("div",mh,[u("button",{type:"button",class:te(["wm-compose__icon",{"is-open":i.attachOpen}]),title:n.attachLabel,"aria-label":n.attachLabel,disabled:i.recording,onClick:t[6]||(t[6]=o=>i.attachOpen=!i.attachOpen)},[...t[9]||(t[9]=[u("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"},[u("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,ph),u("button",{type:"submit",class:te(["wm-compose__send",{"is-empty":!r.canSend}]),disabled:!r.canSend,"aria-label":r.t("composer.send")},[...t[10]||(t[10]=[u("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"},[u("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})],-1)])],10,gh)])],34)])}const yh=be(rh,[["render",_h],["__scopeId","data-v-aa81dbb8"]]),vh={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(e=>(e==null?void 0:e.label)||(e==null?void 0:e.text)||"").join("§")}}},bh=["onClick"];function wh(e,t,n,s,i,r){return n.items.length?(p(),y("div",{key:r.batchKey,class:"wm-chips"},[(p(!0),y(Z,null,Te(n.items,(o,a)=>(p(),y("button",{key:a,type:"button",class:"wm-chip",style:De({animationDelay:n.baseDelay+a*n.stepDelay+"ms"}),onClick:l=>e.$emit("select",o)},O(o.label),13,bh))),128))])):F("",!0)}const kh=be(vh,[["render",wh],["__scopeId","data-v-47ad8085"]]),Ch={name:"WmApprovalCard",components:{AIAvatar:wn},inject:{t:{default:()=>Me()}},props:{action:{type:String,required:!0},detail:{type:String,default:""},callbacks:{type:Array,default:()=>[]},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["callback"],computed:{approveCallback(){return this.callbacks.find(e=>e.id==="approve"||e.style==="primary")||this.callbacks[0]},rejectCallback(){return this.callbacks.find(e=>e.id==="reject"||e.style==="danger"||e.style==="neutral")||(this.callbacks.length>1?this.callbacks[1]:null)},approveId(){var e;return(e=this.approveCallback)==null?void 0:e.id},rejectId(){var e;return(e=this.rejectCallback)==null?void 0:e.id},approveLabel(){var e;return((e=this.approveCallback)==null?void 0:e.label)||this.t("approval.approve")},rejectLabel(){var e;return((e=this.rejectCallback)==null?void 0:e.label)||this.t("approval.reject")}}},Sh={class:"wm-approval"},Ah={class:"wm-approval__head"},xh={class:"wm-approval__icon"},Th={class:"wm-approval__main"},Mh={class:"wm-approval__title"},Eh={key:0,class:"wm-approval__detail"},Oh={class:"wm-approval__actions"};function Ih(e,t,n,s,i,r){const o=ge("AIAvatar");return p(),y("div",Sh,[u("div",Ah,[u("div",xh,[_e(o,{size:24,name:n.agentName,"image-url":n.agentAvatarUrl},null,8,["name","image-url"])]),u("div",Th,[u("div",Mh,O(n.action),1),n.detail?(p(),y("div",Eh,O(n.detail),1)):F("",!0)])]),u("div",Oh,[r.rejectId?(p(),y("button",{key:0,type:"button",class:"wm-approval__btn wm-approval__btn--neutral",onClick:t[0]||(t[0]=a=>e.$emit("callback",r.rejectId))},O(r.rejectLabel),1)):F("",!0),r.approveId?(p(),y("button",{key:1,type:"button",class:"wm-approval__btn wm-approval__btn--primary",onClick:t[1]||(t[1]=a=>e.$emit("callback",r.approveId))},O(r.approveLabel),1)):F("",!0)])])}const Lh=be(Ch,[["render",Ih],["__scopeId","data-v-a2bed37e"]]);let So=0;const Rh=new Set(["text","textarea","number","boolean","select","multiselect","date"]),Nh={name:"WmFormCard",components:{AIAvatar:wn},inject:{t:{default:()=>Me()}},props:{form:{type:Object,required:!0},readOnly:{type:Boolean,default:!1},initialValues:{type:Object,default:null},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["submit"],data(){return So+=1,{_uid:So,values:{},busy:!1,error:""}},computed:{normalizedFields(){var t;return(Array.isArray((t=this.form)==null?void 0:t.fields)?this.form.fields:[]).filter(n=>!(!(n!=null&&n.key)||!(n!=null&&n.label)||!Rh.has(n==null?void 0:n.type)||(n.type==="select"||n.type==="multiselect")&&(!Array.isArray(n.options)||n.options.length===0)))}},created(){this.resetValues()},methods:{resetValues(){const e=this.initialValues&&typeof this.initialValues=="object"?this.initialValues:{},t={};for(const n of this.normalizedFields){if(e[n.key]!==void 0){t[n.key]=e[n.key];continue}n.type==="boolean"?t[n.key]=!1:n.type==="multiselect"?t[n.key]=[]:t[n.key]=""}this.values=t,this.error=""},toggleMulti(e,t,n){const s=Array.isArray(this.values[e])?this.values[e].slice():[],i=s.indexOf(t);n&&i===-1?s.push(t):!n&&i!==-1&&s.splice(i,1),this.values={...this.values,[e]:s}},validate(){for(const e of this.normalizedFields){if(!e.required)continue;const t=this.values[e.key];if(e.type!=="boolean"){if(e.type==="multiselect"){if(!Array.isArray(t)||t.length===0)return this.t("form.fieldRequired",{label:e.label});continue}if(t==null||t==="")return this.t("form.fieldRequired",{label:e.label})}}return""},async onSubmit(){if(this.readOnly||this.busy)return;const e=this.validate();if(e){this.error=e;return}this.error="",this.busy=!0;try{await this.$emit("submit",{values:this.values})}finally{this.busy=!1}}}},Bh={class:"wm-form"},Ph={class:"wm-form__head"},Fh={class:"wm-form__icon"},Dh={class:"wm-form__main"},jh={class:"wm-form__title"},Uh={key:0,class:"wm-form__detail"},Hh=["for"],$h={key:0,class:"wm-form__req","aria-hidden":"true"},Vh=["id","onUpdate:modelValue","placeholder","required","disabled"],Kh=["id","onUpdate:modelValue","placeholder","required","disabled"],qh=["id","onUpdate:modelValue","placeholder","required","disabled"],Wh=["id","onUpdate:modelValue","required","disabled"],zh={key:4,class:"wm-form__bool"},Gh=["id","onUpdate:modelValue","disabled"],Yh=["id","onUpdate:modelValue","required","disabled"],Jh={value:"",disabled:""},Xh=["value"],Qh={key:6,class:"wm-form__multi"},Zh=["value","checked","disabled","onChange"],em={key:0,class:"wm-form__err"},tm=["disabled"],nm={key:0,class:"wm-form__spinner","aria-hidden":"true"},sm={key:2,class:"wm-form__doneLbl"};function rm(e,t,n,s,i,r){const o=ge("AIAvatar");return p(),y("div",Bh,[u("div",Ph,[u("div",Fh,[_e(o,{size:24,name:n.agentName,"image-url":n.agentAvatarUrl},null,8,["name","image-url"])]),u("div",Dh,[u("div",jh,O(n.form.title||r.t("form.title")),1),n.form.description?(p(),y("div",Uh,O(n.form.description),1)):F("",!0)])]),u("form",{class:"wm-form__body",onSubmit:t[0]||(t[0]=wt((...a)=>r.onSubmit&&r.onSubmit(...a),["prevent"]))},[(p(!0),y(Z,null,Te(r.normalizedFields,a=>(p(),y("div",{key:a.key,class:"wm-form__field"},[u("label",{for:`wm-f-${i._uid}-${a.key}`,class:"wm-form__label"},[Zn(O(a.label),1),a.required?(p(),y("span",$h,"*")):F("",!0)],8,Hh),a.type==="text"?ct((p(),y("input",{key:0,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,type:"text",class:"wm-form__input",placeholder:a.placeholder||"",required:a.required,disabled:n.readOnly||i.busy},null,8,Vh)),[[Lt,i.values[a.key]]]):a.type==="textarea"?ct((p(),y("textarea",{key:1,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,class:"wm-form__textarea",rows:"3",placeholder:a.placeholder||"",required:a.required,disabled:n.readOnly||i.busy},null,8,Kh)),[[Lt,i.values[a.key]]]):a.type==="number"?ct((p(),y("input",{key:2,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,type:"number",class:"wm-form__input",placeholder:a.placeholder||"",required:a.required,disabled:n.readOnly||i.busy},null,8,qh)),[[Lt,i.values[a.key],void 0,{number:!0}]]):a.type==="date"?ct((p(),y("input",{key:3,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,type:"date",class:"wm-form__input",required:a.required,disabled:n.readOnly||i.busy},null,8,Wh)),[[Lt,i.values[a.key]]]):a.type==="boolean"?(p(),y("label",zh,[ct(u("input",{id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,type:"checkbox",disabled:n.readOnly||i.busy},null,8,Gh),[[sc,i.values[a.key]]]),u("span",null,O(a.placeholder||r.t("common.yes")),1)])):a.type==="select"?ct((p(),y("select",{key:5,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,class:"wm-form__select",required:a.required,disabled:n.readOnly||i.busy},[u("option",Jh,O(a.placeholder||r.t("form.choose")),1),(p(!0),y(Z,null,Te(a.options,l=>(p(),y("option",{key:l.value,value:l.value},O(l.label),9,Xh))),128))],8,Yh)),[[rc,i.values[a.key]]]):a.type==="multiselect"?(p(),y("div",Qh,[(p(!0),y(Z,null,Te(a.options,l=>(p(),y("label",{key:l.value,class:"wm-form__multiItem"},[u("input",{type:"checkbox",value:l.value,checked:Array.isArray(i.values[a.key])&&i.values[a.key].includes(l.value),disabled:n.readOnly||i.busy,onChange:f=>r.toggleMulti(a.key,l.value,f.target.checked)},null,40,Zh),u("span",null,O(l.label),1)]))),128))])):F("",!0)]))),128)),i.error?(p(),y("div",em,O(i.error),1)):F("",!0),n.readOnly?(p(),y("div",sm,O(r.t("form.responseSent")),1)):(p(),y("button",{key:1,type:"submit",class:"wm-form__submit",disabled:i.busy},[i.busy?(p(),y("span",nm)):F("",!0),u("span",null,O(i.busy?r.t("common.sending"):n.form.submit_label||r.t("common.send")),1)],8,tm))],32)])}const im=be(Nh,[["render",rm],["__scopeId","data-v-fe65cc56"]]),om={name:"WmFeedback",inject:{t:{default:()=>Me()}},props:{busy:{type:Boolean,default:!1},done:{type:Boolean,default:!1}},emits:["submit"],data(){return{sel:null}},computed:{options(){return[{v:1,e:"😞",l:this.t("feedback.rating1")},{v:2,e:"😐",l:this.t("feedback.rating2")},{v:3,e:"🙂",l:this.t("feedback.rating3")},{v:4,e:"😄",l:this.t("feedback.rating4")},{v:5,e:"🤩",l:this.t("feedback.rating5")}]}},methods:{onSend(){!this.sel||this.busy||this.$emit("submit",{rating:this.sel})}}},am={class:"wm-fb"},lm={class:"wm-fb__title"},cm={class:"wm-fb__sub"},um={class:"wm-fb__row"},dm=["onClick"],fm={class:"wm-fb__emoji"},hm={class:"wm-fb__label"},mm=["disabled"],pm={key:1,class:"wm-fb__done"},gm={class:"wm-fb__doneTitle"},_m={class:"wm-fb__doneSub"};function ym(e,t,n,s,i,r){return p(),y("div",am,[n.done?(p(),y("div",pm,[t[1]||(t[1]=u("div",{class:"wm-fb__check"},[u("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"},[u("path",{d:"M20 6L9 17l-5-5"})])],-1)),u("div",gm,O(r.t("feedback.doneTitle")),1),u("div",_m,O(r.t("feedback.doneSubtitle")),1)])):(p(),y(Z,{key:0},[u("div",lm,O(r.t("feedback.question")),1),u("div",cm,O(r.t("feedback.subtitle")),1),u("div",um,[(p(!0),y(Z,null,Te(r.options,o=>(p(),y("button",{key:o.v,type:"button",class:te(["wm-fb__opt",{"is-selected":i.sel===o.v}]),onClick:a=>i.sel=o.v},[u("span",fm,O(o.e),1),u("span",hm,O(o.l),1)],10,dm))),128))]),u("button",{type:"button",class:"wm-fb__send",disabled:!i.sel||n.busy,onClick:t[0]||(t[0]=(...o)=>r.onSend&&r.onSend(...o))},O(n.busy?r.t("common.sending"):r.t("feedback.submit")),9,mm)],64))])}const vm=be(om,[["render",ym],["__scopeId","data-v-9b630564"]]),bm={name:"WmMoreMenu",inject:{t:{default:()=>Me()}},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(e){this.soundOn=!!e},browserNotifEnabled(e){this.browserNotifOn=!!e}},methods:{emit(e){this.$emit("action",e)},toggleSound(){this.soundOn=!this.soundOn,this.$emit("sound-toggle",this.soundOn)},toggleBrowserNotif(){this.browserNotifOn=!this.browserNotifOn,this.$emit("browser-notif-toggle",this.browserNotifOn)}}},wm={class:"wm-mm"},km={class:"wm-mm__pop",role:"menu"},Cm={key:0,class:"wm-mm__section"},Sm={class:"wm-mm__label"},Am={class:"wm-mm__label"},xm={key:1,class:"wm-mm__sep"},Tm={class:"wm-mm__section"},Mm={class:"wm-mm__label"},Em={class:"wm-mm__label"},Om={class:"wm-mm__section"},Im={class:"wm-mm__label"},Lm={class:"wm-mm__label"};function Rm(e,t,n,s,i,r){return p(),y("div",wm,[u("div",{class:"wm-mm__scrim",onClick:t[0]||(t[0]=o=>e.$emit("close"))}),u("div",km,[n.canRename||n.canExport?(p(),y("div",Cm,[n.canRename?(p(),y("button",{key:0,type:"button",class:"wm-mm__item",onClick:t[1]||(t[1]=o=>r.emit("rename"))},[t[7]||(t[7]=u("span",{class:"wm-mm__icon"},[u("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"},[u("path",{d:"M12 20h9"}),u("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})])],-1)),u("span",Sm,O(r.t("moreMenu.editTitle")),1)])):F("",!0),n.canExport?(p(),y("button",{key:1,type:"button",class:"wm-mm__item",onClick:t[2]||(t[2]=o=>r.emit("export"))},[t[8]||(t[8]=u("span",{class:"wm-mm__icon"},[u("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"},[u("path",{d:"M4 12v8a2 2 0 002 2h12a2 2 0 002-2v-8M16 6l-4-4-4 4M12 2v13"})])],-1)),u("span",Am,O(r.t("moreMenu.exportTranscript")),1),t[9]||(t[9]=u("span",{class:"wm-mm__hint"},".txt",-1))])):F("",!0)])):F("",!0),n.canRename||n.canExport?(p(),y("div",xm)):F("",!0),u("div",Tm,[u("button",{type:"button",class:"wm-mm__item",onClick:t[3]||(t[3]=(...o)=>r.toggleSound&&r.toggleSound(...o))},[t[11]||(t[11]=u("span",{class:"wm-mm__icon"},[u("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"},[u("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),u("path",{d:"M15.54 8.46a5 5 0 010 7.07M19.07 4.93a10 10 0 010 14.14"})])],-1)),u("span",Mm,O(r.t("moreMenu.sound")),1),u("span",{class:te(["wm-mm__toggle",{"wm-mm__toggle--on":i.soundOn}])},[...t[10]||(t[10]=[u("span",{class:"wm-mm__knob"},null,-1)])],2)]),u("button",{type:"button",class:"wm-mm__item",onClick:t[4]||(t[4]=(...o)=>r.toggleBrowserNotif&&r.toggleBrowserNotif(...o))},[t[13]||(t[13]=u("span",{class:"wm-mm__icon"},[u("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"},[u("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)),u("span",Em,O(r.t("moreMenu.browserNotifications")),1),u("span",{class:te(["wm-mm__toggle",{"wm-mm__toggle--on":i.browserNotifOn}])},[...t[12]||(t[12]=[u("span",{class:"wm-mm__knob"},null,-1)])],2)])]),t[16]||(t[16]=u("div",{class:"wm-mm__sep"},null,-1)),u("div",Om,[n.statusUrl?(p(),y("button",{key:0,type:"button",class:"wm-mm__item",onClick:t[5]||(t[5]=o=>r.emit("status"))},[t[14]||(t[14]=u("span",{class:"wm-mm__icon"},[u("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"},[u("path",{d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zM10 6v4l3 2"})])],-1)),u("span",Im,O(r.t("moreMenu.serviceStatus")),1)])):F("",!0),n.helpUrl?(p(),y("button",{key:1,type:"button",class:"wm-mm__item",onClick:t[6]||(t[6]=o=>r.emit("help"))},[t[15]||(t[15]=u("span",{class:"wm-mm__icon"},[u("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"},[u("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)),u("span",Lm,O(r.t("moreMenu.helpCenter")),1)])):F("",!0)])])])}const Nm=be(bm,[["render",Rm],["__scopeId","data-v-76281e95"]]),Bm={name:"WmRenameDialog",inject:{t:{default:()=>Me()}},props:{title:{type:String,default:""},initialValue:{type:String,default:""},placeholder:{type:String,default:""}},emits:["close","submit"],data(){return{value:this.initialValue||""}},computed:{canSubmit(){const e=(this.value||"").trim();return!!e&&e!==(this.initialValue||"").trim()}},mounted(){this.$nextTick(()=>{const e=this.$refs.input;if(e){e.focus();try{e.select()}catch{}}})},methods:{onSubmit(){this.canSubmit&&this.$emit("submit",this.value.trim())}}},Pm={class:"wm-dialog"},Fm={class:"wm-dialog__card",role:"dialog","aria-modal":"true"},Dm={class:"wm-dialog__head"},jm={class:"wm-dialog__title"},Um=["aria-label"],Hm={class:"wm-dialog__body"},$m=["placeholder"],Vm={class:"wm-dialog__actions"},Km=["disabled"];function qm(e,t,n,s,i,r){return p(),y("div",Pm,[u("div",{class:"wm-dialog__scrim",onClick:t[0]||(t[0]=o=>e.$emit("close"))}),u("div",Fm,[u("div",Dm,[u("div",jm,O(n.title||r.t("rename.title")),1),u("button",{type:"button",class:"wm-dialog__close","aria-label":r.t("common.close"),onClick:t[1]||(t[1]=o=>e.$emit("close"))},[...t[7]||(t[7]=[u("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"},[u("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,Um)]),u("div",Hm,[ct(u("input",{ref:"input","onUpdate:modelValue":t[2]||(t[2]=o=>i.value=o),type:"text",class:"wm-dialog__input",placeholder:n.placeholder||r.t("rename.placeholder"),maxlength:120,onKeydown:[t[3]||(t[3]=ns(wt((...o)=>r.onSubmit&&r.onSubmit(...o),["prevent"]),["enter"])),t[4]||(t[4]=ns(wt(o=>e.$emit("close"),["prevent"]),["esc"]))]},null,40,$m),[[Lt,i.value]])]),u("div",Vm,[u("button",{type:"button",class:"wm-dialog__btn",onClick:t[5]||(t[5]=o=>e.$emit("close"))},O(r.t("common.cancel")),1),u("button",{type:"button",class:"wm-dialog__btn wm-dialog__btn--primary",disabled:!r.canSubmit,onClick:t[6]||(t[6]=(...o)=>r.onSubmit&&r.onSubmit(...o))},O(r.t("common.save")),9,Km)])])])}const Wm=be(Bm,[["render",qm],["__scopeId","data-v-6d5f94a8"]]),Ao="ww-messenger-tokens",zm={name:"Messenger",components:{Launcher:ou,Header:Ou,Onboarding:ud,MessageList:Qf,Composer:yh,SuggestionChips:kh,ApprovalCard:Lh,FormCard:im,Feedback:vm,MoreMenu:Nm,RenameDialog:Wm},mixins:[Oc,Pc,Fc,jc],provide(){return{signAttachmentFn:e=>{var t,n;return((n=(t=this.store)==null?void 0:t.signAttachment)==null?void 0:n.call(t,e))||null},t:(e,t)=>this.t(e,t),wmLocale:()=>this.locale}},props:{baseUrl:{type:String,default:mo},widgetId:{type:String,default:""},userId:{type:String,default:""},userHash:{type:String,default:""},context:{type:Object,default:null},displayMode:{type:String,default:"floating"},devtools:{type:Boolean,default:!1},language:{type:String,default:""}},data(){return{transport:null,store:null,isOpen:!1,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"},customerLanguage(){var n,s,i,r;const e=(n=this.s)==null?void 0:n.customer,t=e&&(e.language||((s=e.values)==null?void 0:s.language));return t||((r=(i=this.context)==null?void 0:i.customer)==null?void 0:r.language)||""},locale(){var e;return Gs(this.language||this.customerLanguage||((e=this.widget)==null?void 0:e.default_language)||"")},translator(){return Me(this.locale)},error(){var e;return this.bootError||((e=this.s)==null?void 0:e.error)||null},canBoot(){return!!(this.baseUrl&&this.widgetId&&this.userId&&this.userHash)},s(){var e;return((e=this.store)==null?void 0:e.state)||null},ready(){var e;return!!((e=this.s)!=null&&e.ready)},allConversations(){var t;const e=(t=this.s)==null?void 0:t.conversations;return Array.isArray(e)?e:[]},drawerConversations(){var n;const e=((n=this.s)==null?void 0:n.messagesByConv)||{},t=this.revealedAt;return this.allConversations.map(s=>{var f;const i=e[s.id]||[],r=kt(s.last_read_message_id);let o=0,a=null;for(let c=i.length-1;c>=0;c--){const g=i[c];if(!g)continue;if(((f=g.author)==null?void 0:f.type)==="user")break;const A=kt(g.id);if(A!=null){if(r!=null&&A<=r)break;t[g.id]!==0&&(!a&&g.author&&(a=g.author),o++)}}const l=i.filter(c=>!((c==null?void 0:c.id)!=null&&t[c.id]===0));return{...s,_preview:xc(s,l),_unread:o>0,_unreadCount:o,_lastAuthor:a}})},unreadCount(){return this.drawerConversations.filter(e=>e._unread).length},openThreads(){var t;const e=((t=this.s)==null?void 0:t.messagesByConv)||{};return this.drawerConversations.filter(n=>n.status!=="resolved").map(n=>({id:n.id,title:n.name||this.t("common.newConversation"),preview:n._preview||this.t("onboarding.newMessage"),unread:!!n._unread,_ts:yo(n,e[n.id]||[])})).sort((n,s)=>n._ts<s._ts?1:n._ts>s._ts?-1:0)},latestUnreads(){var n;const e=((n=this.s)==null?void 0:n.messagesByConv)||{},t=[];for(const s of this.drawerConversations){if(!s._unread)continue;const i=yo(s,e[s.id]||[]),r=s._lastAuthor,o=!r||r.type==="agent_ia",a=(r==null?void 0:r.name)||(o?this.agentName:"")||"",l=(r==null?void 0:r.avatar_url)||(o?this.agentAvatarUrl:null);t.push({convId:s.id,preview:s._preview||this.t("notification.youHaveNewMessage"),ts:i,count:s._unreadCount||1,senderName:a,senderAvatarUrl:l})}return t.sort((s,i)=>s.ts<i.ts?1:s.ts>i.ts?-1:0),t},launcherPeeks(){if(this.isOpen||this.isEmbedded)return[];const e=this.dismissedPeeks||{};return this.latestUnreads.filter(t=>e[t.convId]!==t.ts)},isViewingThread(){return(this.isOpen||this.isEmbedded)&&!!this.currentConv},currentConv(){if(this.draftConv)return this.draftConv;if(this.showOnboarding)return null;const e=this.allConversations;if(!e.length)return null;if(this.activeConvId!=null){const t=e.find(n=>n.id===this.activeConvId);if(t)return t}return e[0]||null},canBack(){return!!this.currentConv},statusUrl(){var n;const e=(n=this.widget)==null?void 0:n.quick_links;if(!Array.isArray(e))return"";const t=e.find(s=>s.icon==="status"&&s.url);return(t==null?void 0:t.url)||""},helpUrl(){var n;const e=(n=this.widget)==null?void 0:n.quick_links;if(!Array.isArray(e))return"";const t=e.find(s=>(s.icon==="chat"||s.icon==="help")&&s.url);return(t==null?void 0:t.url)||""},widget(){var e,t;return((t=(e=this.s)==null?void 0:e.config)==null?void 0:t.widget)||null},widgetWelcomeMessage(){var e;return((e=this.widget)==null?void 0:e.welcome_message)||""},widgetSubtitle(){var e;return((e=this.widget)==null?void 0:e.subtitle)||""},defaultIconUrl(){var e;return((e=this.widget)==null?void 0:e.default_icon_url)||null},agentName(){var e,t,n;return((n=(t=(e=this.s)==null?void 0:e.config)==null?void 0:t.agent)==null?void 0:n.name)||""},agentAvatarUrl(){var e,t,n;return((n=(t=(e=this.s)==null?void 0:e.config)==null?void 0:t.agent)==null?void 0:n.avatar_url)||null},quickLinks(){var t;const e=(t=this.widget)==null?void 0:t.quick_links;return Array.isArray(e)?e:[]},teamMembers(){var t;const e=(t=this.widget)==null?void 0:t.team_members;return Array.isArray(e)?e:[]},responseLabel(){var e;return((e=this.widget)==null?void 0:e.response_time_label)||""},humanMessageAuthor(){var t,n,s;if(!this.currentConv)return null;const e=((t=this.s.messagesByConv)==null?void 0:t[this.currentConv.id])||[];for(let i=e.length-1;i>=0;i--)if(((s=(n=e[i])==null?void 0:n.author)==null?void 0:s.type)==="agent_human")return e[i].author;return null},humanAgentName(){var e;return((e=this.humanMessageAuthor)==null?void 0:e.name)||""},humanAgentAvatarUrl(){var e;return((e=this.humanMessageAuthor)==null?void 0:e.avatar_url)||null},isEscalated(){return!!this.humanMessageAuthor},isWaitingHuman(){var t;const e=(t=this.currentConv)==null?void 0:t.status;return e==="waiting"||e==="handled"},headerTitle(){var e,t;return((e=this.currentConv)==null?void 0:e.name)||((t=this.widget)==null?void 0:t.name)||this.t("common.newConversation")},composerPlaceholder(){return this.isEscalated&&this.humanAgentName?this.t("composer.replyTo",{name:this.humanAgentName.split(" ")[0]}):this.isWaitingHuman?this.t("composer.agentTakingOver"):this.t("composer.placeholder")},displayedMessages(){var n,s;const e=this.currentConv;if(!e)return[];if(!e._draft){const i=(s=(n=this.s)==null?void 0:n.paginationByConv)==null?void 0:s[e.id];if(!(i!=null&&i.loaded))return[]}const t=this.revealedAt;return(this.s.messagesByConv[e.id]||[]).filter(i=>{var r,o,a,l,f;return(i==null?void 0:i.type)==="action"&&((r=i==null?void 0:i.payload)==null?void 0:r.state)==="pending"||bn(i)&&!(t[i.id]>0)?!1:(i==null?void 0:i.type)==="action"||(i==null?void 0:i.type)==="system"||((o=i==null?void 0:i.payload)==null?void 0:o.type)==="system"||Array.isArray((a=i==null?void 0:i.payload)==null?void 0:a.attachments)&&i.payload.attachments.length||(l=i==null?void 0:i.metadata)!=null&&l.artifact||(f=i==null?void 0:i.metadata)!=null&&f.form?!0:typeof(i==null?void 0:i.text_md)=="string"&&i.text_md.trim().length>0})},streamingActive(){var n,s,i;const e=this.currentConv;return e?Object.keys(((n=this.s)==null?void 0:n.streamingByMsgId)||{}).length>0?!0:this.actionInFlight?!1:(((i=(s=this.s)==null?void 0:s.messagesByConv)==null?void 0:i[e.id])||[]).some(r=>bn(r)&&!(this.revealedAt[r.id]>0)):!1},currentConvMessages(){var t,n,s;const e=(t=this.currentConv)==null?void 0:t.id;return e?((s=(n=this.s)==null?void 0:n.messagesByConv)==null?void 0:s[e])||[]:[]},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 e,t,n;return((t=(e=this.pendingApproval)==null?void 0:e.payload)==null?void 0:t.name)||((n=this.pendingApproval)==null?void 0:n.text_md)||this.t("action.title")},approvalDetail(){var s,i,r,o,a,l;const e=(r=(i=(s=this.pendingApproval)==null?void 0:s.payload)==null?void 0:i.pending)==null?void 0:r.user_explanation;if(typeof e=="string"&&e.trim())return e.trim();const t=(l=(a=(o=this.pendingApproval)==null?void 0:o.payload)==null?void 0:a.pending)==null?void 0:l.prepared_params;if(!t||typeof t!="object")return"";const n=Object.entries(t);return n.length?n.slice(0,2).map(([f,c])=>`${f}: ${c}`).join(" · "):""},actionInFlight(){var e,t;return!this.currentConv||!this.store?null:((t=(e=this.store).getActionInFlight)==null?void 0:t.call(e,this.currentConv.id))||null},actionInFlightName(){var t;const e=this.actionInFlight;return e?((t=e.payload)==null?void 0:t.name)||e.text_md||this.t("common.action"):""},suggestions(){return!this.currentConv||!this.store?[]:this.streamingActive?[]:this.pendingForm?[]:this.store.getLatestSuggestions(this.currentConv.id)},pendingForm(){var e,t;return!this.currentConv||!this.store||this.pendingApproval||this.actionInFlight||this.streamingActive||!this.approvalSettled?null:((t=(e=this.store).getLatestForm)==null?void 0:t.call(e,this.currentConv.id))||null},showFeedback(){var t;const e=this.currentConv;return e?this.feedbackDone?!0:e.status!=="resolved"?!1:!((t=e.metadata)!=null&&t.feedback):!1},floatVisible(){return this.approvalReady||!!this.pendingForm||this.showFeedback||this.suggestions.length>0},dateLabel(){var n,s,i;const e=this.currentConv;let t=new Date;if(e){const o=((i=(((s=(n=this.s)==null?void 0:n.messagesByConv)==null?void 0:s[e.id])||[]).find(a=>a==null?void 0:a.created_at))==null?void 0:i.created_at)||e.created_at;if(o){const a=new Date(o);Number.isNaN(a.getTime())||(t=a)}}return this.t("messageList.today",{time:ho(t,vn(this.locale))})},paginationState(){var n,s,i;const e=(n=this.currentConv)==null?void 0:n.id,t=e?(i=(s=this.s)==null?void 0:s.paginationByConv)==null?void 0:i[e]:null;return{loading:!!(t!=null&&t.loading),hasMore:!!(t!=null&&t.nextCursor)}}},watch:{latestUnreads:{handler(e){const t=new Set(e.map(o=>o.convId)),n=this.dismissedPeeks||{},s=Object.keys(n);if(!s.length)return;const i={};let r=!1;for(const o of s)t.has(o)?i[o]=n[o]:r=!0;r&&(this.dismissedPeeks=i)},deep:!0},"currentConv.id":{handler(e){var t;this.resetRevealQueue(),this.convOpenedAt=Date.now(),this.moreOpen=!1,this.renameDialogOpen=!1,this.resetApprovalPacing(),this.isViewingThread&&(this.unreadAnchorId=kt((t=this.currentConv)==null?void 0:t.last_read_message_id),this.unreadBoundaryTs=e?new Date().toISOString():"")},immediate:!0},isViewingThread(e,t){var n;e&&!t?(this.unreadAnchorId=kt((n=this.currentConv)==null?void 0:n.last_read_message_id),this.unreadBoundaryTs=new Date().toISOString()):e||(this.unreadAnchorId=null,this.unreadBoundaryTs="")},pendingApproval:{handler(e,t){if(e&&!t){const n=e!=null&&e.created_at?Date.parse(e.created_at):NaN;if(!(Number.isFinite(n)&&n>=this.convOpenedAt)){this.resetApprovalPacing();return}this.bumpApprovalSettle(2600)}else!e&&t&&this.resetApprovalPacing()},immediate:!1},streamingActive(e,t){e!==t&&this.pendingApproval&&this.pendingApproval.id!==this.approvalLatchId&&this.bumpApprovalSettle()},approvalReady(e){e&&this.pendingApproval&&(this.approvalLatchId=this.pendingApproval.id)},floatVisible:{handler(e){this.$nextTick(()=>this.syncFloatObserver(e))},immediate:!0},currentConvMessages(e){var t;this.paceMessages(e,(t=this.currentConv)==null?void 0:t.id),(this.isOpen||this.isEmbedded)&&this.currentConv&&this.markConvRead(this.currentConv)}},async mounted(){if(typeof document<"u"&&!document.getElementById(Ao)){const e=document.createElement("style");e.id=Ao,e.textContent=kc,document.head.appendChild(e)}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:{t(e,t){return this.translator(e,t)},async boot(){var e;if(!this.canBoot){console.warn("[messenger] boot skipped — missing creds");return}try{this.transport=Cs(_c({baseUrl:this.baseUrl,widgetId:this.widgetId,userId:this.userId,userHash:this.userHash})),this.store=Cs(wc(this.transport)),this.hydrateNotifPref(),await this.store.start(),this.setupLiveReveal();const t=(e=this.context)==null?void 0:e.customer;t&&typeof t=="object"&&await this.store.applyCustomer(t)}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(e){if(this.disconnectFloatRO(),!e){this.floatHeight=0;return}const t=this.$refs.floatEl;if(t){if(typeof ResizeObserver>"u"){this.floatHeight=Math.ceil(t.getBoundingClientRect().height+8);return}this.floatRO=new ResizeObserver(n=>{const s=n[0];if(!s)return;const i=Math.ceil(s.contentRect.height+8);i!==this.floatHeight&&(this.floatHeight=i,this.$nextTick(()=>{var r,o;(o=(r=this.$refs.messageList)==null?void 0:r.scrollToBottom)==null||o.call(r)}))}),this.floatRO.observe(t)}},disconnectFloatRO(){if(this.floatRO){try{this.floatRO.disconnect()}catch{}this.floatRO=null}},async open(){this.isOpen=!0,this.store&&this.store.setPanelOpen(!0);const e=this.currentConv;if(e&&!e._draft){this.activeConvId==null&&(this.activeConvId=e.id);try{await this.store.openConversation(e.id)}catch(t){console.error("[ww-messenger] load messages failed",t)}this.markConvRead(e)}},close(){this.isOpen=!1,this.store&&this.store.setPanelOpen(!1)},async openFromPeek(e){var n,s;const t=e||((n=this.latestUnreads[0])==null?void 0:n.convId);t&&t!==((s=this.currentConv)==null?void 0:s.id)&&(this.draftConv=null,this.activeConvId=t,this.showOnboarding=!1),await this.open()},dismissPeek(e){const t=this.latestUnreads.find(n=>n.convId===e);t&&(this.dismissedPeeks={...this.dismissedPeeks,[e]:t.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 e=this.currentConv;if(!e)return null;if(!e._draft)return e;if(this.busy)return null;this.busy=!0;try{const t=await this.store.createConversation({});return this.draftConv=null,this.activeConvId=t.id,await this.store.openConversation(t.id),this.markConvRead(t),t}catch(t){return console.error("[ww-messenger] create conv failed",t),this.bootError=(t==null?void 0:t.message)||String(t),null}finally{this.busy=!1}},focusComposer(){this.$nextTick(()=>{var e;return(e=this.$refs.composer)==null?void 0:e.focus()})},toggleMore(){this.moreOpen=!this.moreOpen},goHome(){this.moreOpen=!1,this.draftConv=null,this.activeConvId=null,this.showOnboarding=!0},async onDrawerPick(e){if(!(e!=null&&e.id)||!this.store)return;this.draftConv=null,this.activeConvId=e.id,this.showOnboarding=!1;try{await this.store.openConversation(e.id)}catch(n){console.error("[ww-messenger] open conv failed",n)}const t=this.allConversations.find(n=>n.id===e.id);t&&this.markConvRead(t)},async onMoreAction(e){var t,n;switch(this.moreOpen=!1,e){case"rename":this.openRenameDialog();break;case"export":Ec(this.currentConv,this.currentConv?(n=(t=this.s)==null?void 0:t.messagesByConv)==null?void 0:n[this.currentConv.id]:[],this.translator,this.locale);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 e=this.currentConv;!e||e._draft||(this.renameDialogOpen=!0)},async onRenameSubmit(e){const t=this.currentConv;if(this.renameDialogOpen=!1,!t||t._draft||!this.store)return;const n=(e||"").trim();if(!(!n||n===t.name))try{await this.store.patchConversation(t.id,{name:n})}catch(s){console.error("[ww-messenger] rename failed",s)}},async onSend(e){let t=this.currentConv;if(!t&&(this.startConv(),t=this.currentConv,!t)||t._draft&&(t=await this.ensureRealConv(),!t))return;const n=t.id,s=this.pendingAttachments.slice();this.pendingAttachments=[],this.unreadAnchorId=null,this.unreadBoundaryTs="",await this.store.send(n,e,{attachments:s.length?s:void 0})},async onSuggestion(e){const t=e==null?void 0:e.label;t&&await this.onSend(t)},async onLoadMore(){var t;const e=(t=this.currentConv)==null?void 0:t.id;!e||!this.store||await this.store.loadMore(e)},async onApprovalCallback(e){const t=this.pendingApproval;t&&await this.store.clickCallback(t.id,e)},async onFormSubmit({values:e}){const t=this.pendingForm;if(!(t!=null&&t.form))return;const n=Sc(t.form,e,this.translator);if(!n)return;let s=this.currentConv;s&&(s._draft&&(s=await this.ensureRealConv(),!s)||await this.store.send(s.id,n,{metadata:{artifact:Ac(t.form,e,this.translator)}}))},async onAttach(e){if(!(!e||!this.transport))try{const t=await this.transport.uploadAttachment(e);this.pendingAttachments.push({type:t.type||"file",path:t.path,name:e.name||this.t("attachment.fileFallbackName"),mime_type:e.type,size_bytes:e.size})}catch(t){console.error("[ww-messenger] attachment upload failed",t)}},async onQuickLink(e){if(e){if(e.url){try{window.open(e.url,"_blank","noopener")}catch{}return}this.currentConv||this.startConv(),await this.onSend(e.label)}},async onFeedback({rating:e,comment:t}){if(this.currentConv){this.feedbackBusy=!0;try{await this.store.submitFeedback(this.currentConv.id,{rating:e,comment:t}),this.feedbackDone=!0}catch(n){console.error("[ww-messenger] feedback failed",n)}finally{this.feedbackBusy=!1}}}}},Gm={key:0,class:"wm-loading","aria-busy":"true","aria-live":"polite"},Ym=["aria-label"],Jm={key:0,class:"wm-state"},Xm={class:"wm-state__err"},Qm={class:"wm-state__errTitle"},Zm={class:"wm-state__errSub"},ep={class:"wm-bottom"},tp={key:0,ref:"floatEl",class:"wm-float"},np={key:1,class:"wm-actionWait",role:"status","aria-live":"polite"},sp={class:"wm-actionWait__lbl"},rp={key:2,class:"wm-attached"},ip=["aria-label","onClick"];function op(e,t,n,s,i,r){const o=ge("Launcher"),a=ge("Header"),l=ge("Onboarding"),f=ge("MessageList"),c=ge("ApprovalCard"),g=ge("FormCard"),A=ge("Feedback"),S=ge("SuggestionChips"),K=ge("Composer"),I=ge("MoreMenu"),X=ge("RenameDialog");return p(),y("div",{class:te(["wm-root",`wm-root--${n.displayMode}`])},[!i.isOpen&&!r.isEmbedded?(p(),ve(o,{key:0,"unread-count":r.unreadCount,peeks:r.launcherPeeks,onOpen:r.openFromPeek,onDismiss:r.dismissPeek},null,8,["unread-count","peeks","onOpen","onDismiss"])):F("",!0),i.isOpen||r.isEmbedded?(p(),y("section",{key:1,class:te(["wm-panel",`wm-panel--${n.displayMode}`]),style:De(i.floatHeight?{"--wm-float-h":i.floatHeight+"px"}:null),role:"dialog","aria-label":"Messenger"},[!r.ready&&!r.error?(p(),y("div",Gm,[r.isEmbedded?F("",!0):(p(),y("button",{key:0,type:"button",class:"wm-loading__close","aria-label":r.t("loading.minimize"),onClick:t[0]||(t[0]=(...G)=>r.close&&r.close(...G))},[...t[5]||(t[5]=[u("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"},[u("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,Ym)),t[6]||(t[6]=u("div",{class:"wm-loading__spinner","aria-hidden":"true"},null,-1))])):(p(),y(Z,{key:1},[_e(a,{title:r.headerTitle,"team-members":r.teamMembers,"response-label":r.responseLabel,"show-identity":!!r.currentConv,"show-back":r.canBack,"show-close":!r.isEmbedded,"more-active":i.moreOpen,"agent-name":r.agentName,"agent-avatar-url":r.agentAvatarUrl,onBack:r.goHome,onMore:r.toggleMore,onClose:r.close},null,8,["title","team-members","response-label","show-identity","show-back","show-close","more-active","agent-name","agent-avatar-url","onBack","onMore","onClose"]),r.error?(p(),y("div",Jm,[u("div",Xm,[t[7]||(t[7]=u("div",{class:"wm-state__errIcon"},[u("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"},[u("path",{d:"M18 6L6 18M6 6l12 12"})])],-1)),u("div",null,[u("div",Qm,O(r.t("error.connectionFailed")),1),u("div",Zm,O(r.error),1)])])])):r.currentConv?(p(),y(Z,{key:2},[_e(f,{ref:"messageList",messages:r.displayedMessages,"streaming-active":r.streamingActive,"date-label":r.dateLabel,"conversation-id":r.currentConv?r.currentConv.id:null,"loading-more":r.paginationState.loading,"has-more":r.paginationState.hasMore,"unread-anchor-id":e.unreadAnchorId,"unread-boundary-ts":e.unreadBoundaryTs,"ai-agent-name":r.agentName,"ai-agent-avatar-url":r.agentAvatarUrl,onLoadMore:r.onLoadMore},null,8,["messages","streaming-active","date-label","conversation-id","loading-more","has-more","unread-anchor-id","unread-boundary-ts","ai-agent-name","ai-agent-avatar-url","onLoadMore"]),u("div",ep,[r.floatVisible?(p(),y("div",tp,[r.approvalReady?(p(),ve(c,{key:0,action:r.approvalTitle,detail:r.approvalDetail,callbacks:r.pendingApproval.callbacks,"agent-name":r.agentName,"agent-avatar-url":r.agentAvatarUrl,onCallback:r.onApprovalCallback},null,8,["action","detail","callbacks","agent-name","agent-avatar-url","onCallback"])):r.pendingForm?(p(),ve(g,{key:r.pendingForm.message&&r.pendingForm.message.id,form:r.pendingForm.form,"agent-name":r.agentName,"agent-avatar-url":r.agentAvatarUrl,onSubmit:r.onFormSubmit},null,8,["form","agent-name","agent-avatar-url","onSubmit"])):r.showFeedback?(p(),ve(A,{key:2,busy:i.feedbackBusy,done:i.feedbackDone,onSubmit:r.onFeedback},null,8,["busy","done","onSubmit"])):(p(),ve(S,{key:3,items:r.suggestions,onSelect:r.onSuggestion},null,8,["items","onSelect"]))],512)):F("",!0),r.actionInFlight?(p(),y("div",np,[t[8]||(t[8]=u("span",{class:"wm-actionWait__spinner","aria-hidden":"true"},null,-1)),u("span",sp,O(r.t("action.inProgress",{name:r.actionInFlightName})),1)])):(p(),ve(K,{key:2,ref:"composer",modelValue:i.draft,"onUpdate:modelValue":t[1]||(t[1]=G=>i.draft=G),placeholder:r.composerPlaceholder,disabled:!!r.pendingApproval,"attach-label":r.t("composer.attachFile"),onSend:r.onSend,onAttach:r.onAttach},null,8,["modelValue","placeholder","disabled","attach-label","onSend","onAttach"]))]),i.moreOpen?(p(),ve(I,{key:0,"can-rename":!!r.currentConv&&!r.currentConv._draft,"can-export":!!r.currentConv&&!r.currentConv._draft,"sound-enabled":e.soundEnabled,"browser-notif-enabled":e.browserNotifEnabled,"status-url":r.statusUrl,"help-url":r.helpUrl,onClose:t[2]||(t[2]=G=>i.moreOpen=!1),onSoundToggle:e.onSoundToggle,onBrowserNotifToggle:e.onBrowserNotifToggle,onAction:r.onMoreAction},null,8,["can-rename","can-export","sound-enabled","browser-notif-enabled","status-url","help-url","onSoundToggle","onBrowserNotifToggle","onAction"])):F("",!0),i.renameDialogOpen&&r.currentConv&&!r.currentConv._draft?(p(),ve(X,{key:1,"initial-value":r.currentConv.name||"",title:r.t("rename.dialogTitle"),onClose:t[3]||(t[3]=G=>i.renameDialogOpen=!1),onSubmit:r.onRenameSubmit},null,8,["initial-value","title","onSubmit"])):F("",!0),i.pendingAttachments.length?(p(),y("div",rp,[(p(!0),y(Z,null,Te(i.pendingAttachments,(G,q)=>(p(),y("div",{key:q,class:"wm-attached__chip"},[t[10]||(t[10]=u("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"},[u("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)),u("span",null,O(G.name),1),u("button",{type:"button","aria-label":r.t("attachment.remove"),onClick:Q=>i.pendingAttachments.splice(q,1)},[...t[9]||(t[9]=[u("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"},[u("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,ip)]))),128))])):F("",!0)],64)):(p(),ve(l,{key:1,"welcome-message":r.widgetWelcomeMessage,subtitle:r.widgetSubtitle,"agent-name":r.agentName,"default-icon-url":r.defaultIconUrl,"quick-links":r.quickLinks,"open-threads":r.openThreads,busy:i.busy,onStart:r.startConv,onSelect:r.onQuickLink,onResume:r.onDrawerPick},null,8,["welcome-message","subtitle","agent-name","default-icon-url","quick-links","open-threads","busy","onStart","onSelect","onResume"])),i.moreOpen&&!r.currentConv?(p(),ve(I,{key:3,"can-rename":!1,"can-export":!1,"sound-enabled":e.soundEnabled,"browser-notif-enabled":e.browserNotifEnabled,"status-url":r.statusUrl,"help-url":r.helpUrl,onClose:t[4]||(t[4]=G=>i.moreOpen=!1),onSoundToggle:e.onSoundToggle,onBrowserNotifToggle:e.onBrowserNotifToggle,onAction:r.onMoreAction},null,8,["sound-enabled","browser-notif-enabled","status-url","help-url","onSoundToggle","onBrowserNotifToggle","onAction"])):F("",!0)],64))],6)):F("",!0)],2)}const ap=be(zm,[["render",op],["__scopeId","data-v-0bf94dbd"]]),lp="0.4.9";let Ct=null,Nt=null,Js="";function cp(e){if(e instanceof Element)return e;if(typeof e=="string"){const n=document.querySelector(e);if(n)return n}const t=document.createElement("div");return t.setAttribute("data-messenger-root",""),document.body.appendChild(t),t}function up(e){return{baseUrl:String(e.baseUrl||mo).trim(),widgetId:String(e.widgetId||"").trim(),userId:String(e.userId||"").trim(),userHash:String(e.userHash||"").trim(),displayMode:e.displayMode||"floating",devtools:!!e.devtools,language:String(e.language||"").trim(),target:e.target||null,context:e.context&&typeof e.context=="object"?e.context:null}}function dp(e={}){const t=up(e);if(!t.baseUrl||!t.widgetId||!t.userId||!t.userHash)return Xs(),null;const n=JSON.stringify({...t,target:typeof t.target=="string"?t.target:!!t.target});return Ct&&n===Js||(Xs(),Nt=cp(t.target),Ct=uc(ap,{baseUrl:t.baseUrl,widgetId:t.widgetId,userId:t.userId,userHash:t.userHash,displayMode:t.displayMode,devtools:t.devtools,language:t.language,context:t.context}),Ct.mount(Nt),Js=n),Ct}function Xs(){if(Ct){try{Ct.unmount()}catch{}Ct=null}Nt&&Nt.hasAttribute&&Nt.hasAttribute("data-messenger-root")&&Nt.remove(),Nt=null,Js=""}return zt.destroy=Xs,zt.init=dp,zt.version=lp,Object.defineProperty(zt,Symbol.toStringTag,{value:"Module"}),zt}({});
77
+ `)}return i}const ko={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"},Nu={name:"WmOnboarding",components:{AIAvatar:wn},inject:{t:{default:()=>Me()},wmLocale:{default:()=>()=>"fr"}},props:{welcomeMessage:{type:String,default:""},subtitle:{type:String,default:""},agentName:{type:String,default:""},defaultIconUrl:{type:String,default:null},quickLinks:{type:Array,default:()=>[]},openThreads:{type:Array,default:()=>[]},busy:{type:Boolean,default:!1}},emits:["start","select","resume"],data(){return{query:""}},computed:{heroTitle(){return this.welcomeMessage?this.welcomeMessage:this.agentName?this.t("onboarding.greetingNamed",{name:this.agentName}):this.t("onboarding.greeting")},heroSub(){return this.subtitle||this.t("onboarding.heroSub")},isOddQuickLinks(){return this.quickLinks.length%2===1},quickLinksLayout(){return this.isOddQuickLinks?"wm-onb__qlist":"wm-onb__grid"},filteredThreads(){const e=this.query.trim().toLowerCase();return e?this.openThreads.filter(t=>(t.title||"").toLowerCase().includes(e)||(t.preview||"").toLowerCase().includes(e)):this.openThreads}},methods:{iconPath(e){return ko[e]||ko.link},renderPreview(e){return Lu(e)},formatTs(e){if(!e)return"";const t=new Date(e);if(Number.isNaN(t.getTime()))return"";const n=vn(this.wmLocale()),s=new Date;if(t.toDateString()===s.toDateString())return t.toLocaleTimeString(n,{hour:"2-digit",minute:"2-digit"});if(s.getTime()-t.getTime()<7*864e5){const o=t.toLocaleDateString(n,{weekday:"short"});return o.charAt(0).toUpperCase()+o.slice(1)}return t.toLocaleDateString(n,{day:"2-digit",month:"2-digit"})}}},Bu={class:"wm-onb"},Pu={class:"wm-onb__hero"},Fu={class:"wm-onb__title"},Du={class:"wm-onb__sub"},ju={class:"wm-onb__cta"},Uu=["disabled"],Hu={key:0,class:"wm-onb__section"},$u={class:"wm-onb__section-title"},Vu=["onClick"],Ku={class:"wm-onb__card-icon"},qu={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"},Wu=["d"],zu={class:"wm-onb__card-body"},Gu={class:"wm-onb__card-title"},Yu={key:0,class:"wm-onb__card-sub"},Ju={key:1,class:"wm-onb__section"},Xu={class:"wm-onb__section-title"},Qu={class:"wm-onb__search"},Zu=["placeholder","aria-label"],ed={class:"wm-onb__list"},td=["onClick"],nd=["aria-label"],sd={class:"wm-onb__thread-body"},rd={class:"wm-onb__thread-title"},id=["innerHTML"],od={class:"wm-onb__thread-meta"},ad={key:0,class:"wm-onb__thread-time"},ld={key:0,class:"wm-onb__empty"};function cd(e,t,n,s,i,r){const o=ge("AIAvatar");return p(),y("div",Bu,[u("div",Pu,[_e(o,{size:56,pulse:!0,"image-url":n.defaultIconUrl},null,8,["image-url"]),u("div",Fu,O(r.heroTitle),1),u("div",Du,O(r.heroSub),1)]),u("div",ju,[u("button",{type:"button",class:"wm-onb__startBtn",disabled:n.busy,onClick:t[0]||(t[0]=a=>e.$emit("start"))},[t[2]||(t[2]=u("span",{class:"wm-onb__startIcon"},[u("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"},[u("path",{d:"M12 5v14M5 12h14"})])],-1)),u("span",null,O(n.busy?"…":r.t("onboarding.start")),1)],8,Uu)]),n.quickLinks.length?(p(),y("div",Hu,[u("div",$u,O(r.t("onboarding.quickAccess")),1),u("div",{class:te(r.quickLinksLayout)},[(p(!0),y(Z,null,Te(n.quickLinks,(a,l)=>(p(),y("button",{key:l,type:"button",class:te(["wm-onb__card",{"wm-onb__card--row":r.isOddQuickLinks}]),onClick:f=>e.$emit("select",a)},[u("span",Ku,[(p(),y("svg",qu,[u("path",{d:r.iconPath(a.icon)},null,8,Wu)]))]),u("span",zu,[u("span",Gu,O(a.label),1),a.description?(p(),y("span",Yu,O(a.description),1)):F("",!0)])],10,Vu))),128))],2)])):F("",!0),n.openThreads.length?(p(),y("div",Ju,[u("div",Xu,O(r.t("onboarding.recentConversations")),1),u("div",Qu,[t[3]||(t[3]=u("span",{class:"wm-onb__searchIcon"},[u("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"},[u("path",{d:"M21 21l-4.35-4.35M11 17a6 6 0 100-12 6 6 0 000 12z"})])],-1)),ct(u("input",{"onUpdate:modelValue":t[1]||(t[1]=a=>i.query=a),type:"text",placeholder:r.t("onboarding.search"),"aria-label":r.t("onboarding.search")},null,8,Zu),[[Lt,i.query]])]),u("div",ed,[(p(!0),y(Z,null,Te(r.filteredThreads,a=>(p(),y("button",{key:a.id,type:"button",class:"wm-onb__thread",onClick:l=>e.$emit("resume",a)},[u("span",{class:te(["wm-onb__thread-icon",{"wm-onb__thread-icon--inverted":!a.unread}])},[t[4]||(t[4]=u("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[u("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)),a.unread?(p(),y("span",{key:0,class:"wm-onb__thread-dot","aria-label":r.t("onboarding.unread")},null,8,nd)):F("",!0)],2),u("span",sd,[u("span",rd,O(a.title),1),u("span",{class:"wm-onb__thread-preview",innerHTML:r.renderPreview(a.preview)},null,8,id)]),u("span",od,[r.formatTs(a._ts)?(p(),y("span",ad,O(r.formatTs(a._ts)),1)):F("",!0),t[5]||(t[5]=u("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"},[u("path",{d:"M5 12h14M13 5l7 7-7 7"})],-1))])],8,td))),128)),r.filteredThreads.length?F("",!0):(p(),y("div",ld,O(r.t("onboarding.noResults",{query:i.query})),1))])])):F("",!0)])}const ud=be(Nu,[["render",cd],["__scopeId","data-v-900e5f91"]]);function dd(e){return typeof e!="string"?"":e.replace(/`([^`]+)`/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(new RegExp("(?<!\\*)\\*([^*]+)\\*(?!\\*)","g"),"$1").replace(/__([^_]+)__/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\s+/g," ").trim()}const fd={name:"WmActionResult",props:{state:{type:String,default:"success"},label:{type:String,required:!0},detail:{type:String,default:""}},computed:{detailText(){return dd(this.detail)}}},hd={class:"wm-result__icon","aria-hidden":"true"},md={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"},pd={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"},gd={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"},_d={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"},yd={class:"wm-result__body"},vd={class:"wm-result__label"},bd={class:"wm-result__detail"};function wd(e,t,n,s,i,r){return p(),y("div",{class:te(["wm-result",`wm-result--${n.state}`])},[u("span",hd,[n.state==="success"?(p(),y("svg",md,[...t[0]||(t[0]=[u("path",{d:"M20 6L9 17l-5-5"},null,-1)])])):n.state==="rejected"?(p(),y("svg",pd,[...t[1]||(t[1]=[u("path",{d:"M18 6L6 18M6 6l12 12"},null,-1)])])):n.state==="awaiting"?(p(),y("svg",gd,[...t[2]||(t[2]=[u("circle",{cx:"12",cy:"12",r:"10"},null,-1),u("polyline",{points:"12 7 12 12 15 14"},null,-1)])])):(p(),y("svg",_d,[...t[3]||(t[3]=[u("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),u("line",{x1:"12",y1:"9",x2:"12",y2:"13"},null,-1),u("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"},null,-1)])]))]),u("span",yd,[u("span",vd,O(n.label),1),r.detailText?(p(),y(Z,{key:0},[t[4]||(t[4]=u("span",{class:"wm-result__sep","aria-hidden":"true"}," · ",-1)),u("span",bd,O(r.detailText),1)],64)):F("",!0)])],2)}const kd=be(fd,[["render",wd],["__scopeId","data-v-7284acd0"]]),Cd={name:"WmArtifactFormResponse",inject:{t:{default:()=>Me()}},props:{data:{type:Object,required:!0}},computed:{fields(){var e;return Array.isArray((e=this.data)==null?void 0:e.fields)?this.data.fields:[]}}},Sd={class:"wm-art wm-art--formResponse"},Ad={class:"wm-art__head"},xd={class:"wm-art__title"},Td={class:"wm-art__badge wm-art__badge--success"},Md={class:"wm-art__body"},Ed={class:"wm-art__fieldLabel"};function Od(e,t,n,s,i,r){return p(),y("div",Sd,[u("div",Ad,[u("div",xd,O(n.data.title||r.t("form.title")),1),u("span",Td,[t[0]||(t[0]=u("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"},[u("polyline",{points:"20 6 9 17 4 12"})],-1)),Zn(" "+O(r.t("form.sent")),1)])]),u("div",Md,[(p(!0),y(Z,null,Te(r.fields,(o,a)=>(p(),y("div",{key:a,class:"wm-art__field"},[u("div",Ed,O(o.label),1),u("div",{class:te(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},O(o.value),3)]))),128))])])}const Id=be(Cd,[["render",Od],["__scopeId","data-v-713aecf1"]]),Ld={name:"WmArtifactInfoCard",props:{data:{type:Object,required:!0}},computed:{fields(){var e;return Array.isArray((e=this.data)==null?void 0:e.fields)?this.data.fields:[]},hasBody(){var e;return!!((e=this.data)!=null&&e.body)||this.fields.length>0}}},Rd={class:"wm-art wm-art--infoCard"},Nd={key:0,class:"wm-art__image"},Bd=["src","alt"],Pd={class:"wm-art__head"},Fd={class:"wm-art__headMain"},Dd={class:"wm-art__title"},jd={key:0,class:"wm-art__subtitle"},Ud={key:1,class:"wm-art__body"},Hd={key:0,class:"wm-art__text"},$d={class:"wm-art__fieldLabel"};function Vd(e,t,n,s,i,r){return p(),y("div",Rd,[n.data.image_url?(p(),y("figure",Nd,[u("img",{src:n.data.image_url,alt:n.data.title||"",loading:"lazy"},null,8,Bd)])):F("",!0),u("div",Pd,[u("div",Fd,[u("div",Dd,O(n.data.title),1),n.data.subtitle?(p(),y("div",jd,O(n.data.subtitle),1)):F("",!0)]),n.data.badge&&n.data.badge.label?(p(),y("span",{key:0,class:te(["wm-art__badge",`wm-art__badge--${n.data.badge.tone||"neutral"}`])},O(n.data.badge.label),3)):F("",!0)]),r.hasBody?(p(),y("div",Ud,[n.data.body?(p(),y("div",Hd,O(n.data.body),1)):F("",!0),r.fields.length?(p(!0),y(Z,{key:1},Te(r.fields,(o,a)=>(p(),y("div",{key:a,class:"wm-art__field"},[u("div",$d,O(o.label),1),u("div",{class:te(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},O(o.value),3)]))),128)):F("",!0)])):F("",!0)])}const Kd=be(Ld,[["render",Vd],["__scopeId","data-v-7eae0e4a"]]);function qd(e,t,n){if(!e)return"";const s=new Date(e);if(Number.isNaN(s.getTime()))return e;const i=s.toLocaleDateString(t,{day:"numeric",month:"long",year:"numeric"}),r=s.toLocaleTimeString(t,{hour:"2-digit",minute:"2-digit"});return`${i}${n}${r}`}const Wd={name:"WmArtifactTicket",inject:{t:{default:()=>Me()},wmLocale:{default:()=>()=>"fr"}},props:{data:{type:Object,required:!0}},computed:{fields(){var e;return Array.isArray((e=this.data)==null?void 0:e.fields)?this.data.fields:[]},formattedDate(){var e;return qd((e=this.data)==null?void 0:e.created_at,vn(this.wmLocale()),this.t("ticket.dateAt"))}},methods:{isPriority(e){return/priorit|^prio$/i.test(String(e||"").trim())},isDate(e){return/date|échéanc|echeanc|deadline|due|créé|cree/i.test(String(e||"").trim())},priorityLevel(e){const t=String(e||"").toLowerCase();return/high|haute|élev|elev|critic|critiq|urgent/.test(t)?3:/low|basse|faible|minor/.test(t)?1:2}}},zd={class:"wm-art wm-art--ticket"},Gd={class:"wm-art__head wm-tk__head"},Yd={class:"wm-art__title wm-tk__title"},Jd={class:"wm-tk__sub"},Xd={class:"wm-tk__ref"},Qd={key:0,class:"wm-tk__text"},Zd={key:0,class:"wm-art__body"},ef={class:"wm-art__fieldLabel"},tf=["data-level"],nf={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"},sf={key:1,class:"wm-art__footer wm-tk__footer"};function rf(e,t,n,s,i,r){return p(),y("div",zd,[u("div",Gd,[u("div",Yd,O(n.data.title),1),u("div",Jd,[u("div",Xd,[t[0]||(t[0]=u("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"},[u("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"}),u("path",{d:"M13 5v2M13 17v2M13 11v2"})],-1)),u("span",null,O(n.data.reference),1)]),u("span",{class:te(["wm-art__badge","wm-tk__badge",`wm-art__badge--${n.data.status.tone||"neutral"}`])},[t[1]||(t[1]=u("span",{class:"wm-tk__dot","aria-hidden":"true"},null,-1)),Zn(" "+O(n.data.status.label),1)],2)]),n.data.body?(p(),y("div",Qd,O(n.data.body),1)):F("",!0)]),r.fields.length?(p(),y("div",Zd,[(p(!0),y(Z,null,Te(r.fields,(o,a)=>(p(),y("div",{key:a,class:"wm-art__field"},[u("div",ef,O(o.label),1),u("div",{class:te(["wm-art__fieldValue",{"wm-art__fieldValue--multi":o.multiline}])},[r.isPriority(o.label)?(p(),y("svg",{key:0,class:"wm-tk__prio","data-level":r.priorityLevel(o.value),width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true"},[...t[2]||(t[2]=[u("rect",{x:"1",y:"8",width:"2",height:"3",rx:"0.5"},null,-1),u("rect",{x:"5",y:"5",width:"2",height:"6",rx:"0.5"},null,-1),u("rect",{x:"9",y:"2",width:"2",height:"9",rx:"0.5"},null,-1)])],8,tf)):r.isDate(o.label)?(p(),y("svg",nf,[...t[3]||(t[3]=[u("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"},null,-1),u("path",{d:"M16 2v4M8 2v4M3 10h18"},null,-1)])])):F("",!0),u("span",null,O(o.value),1)],2)]))),128))])):F("",!0),n.data.created_at?(p(),y("div",sf,[t[4]||(t[4]=u("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"},[u("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),u("path",{d:"M16 2v4M8 2v4M3 10h18"})],-1)),u("span",null,O(r.formattedDate),1)])):F("",!0)])}const of={form_response:Id,info_card:Kd,ticket:be(Wd,[["render",rf],["__scopeId","data-v-5f30c914"]])},af={name:"WmArtifactRenderer",props:{artifact:{type:Object,required:!0}},computed:{component(){var t;const e=(t=this.artifact)==null?void 0:t.kind;return e&&of[e]||null}}};function lf(e,t,n,s,i,r){return r.component?(p(),ve(ja(r.component),{key:0,data:n.artifact.data},null,8,["data"])):F("",!0)}const cf=be(af,[["render",lf]]),uf={name:"WmAttachmentPreview",inject:{signAttachmentFn:{default:null},t:{default:()=>Me()}},props:{attachment:{type:Object,required:!0}},data(){return{url:null,loading:!1}},computed:{kind(){var n,s;const e=(n=this.attachment)==null?void 0:n.type;if(e)return e;const t=(((s=this.attachment)==null?void 0:s.mime_type)||"").toLowerCase();return t.startsWith("image/")?"image":t.startsWith("audio/")?"audio":t.startsWith("video/")?"video":"file"},displayName(){var e,t,n;return((t=(e=this.attachment)==null?void 0:e.metadata)==null?void 0:t.name)||((n=this.attachment)==null?void 0:n.name)||this.guessNameFromPath()||this.t("attachment.fallbackName")},sizeLabel(){var t;const e=(t=this.attachment)==null?void 0:t.size_bytes;return e?e<1024?this.t("attachment.bytes",{size:e}):e<1024*1024?this.t("attachment.kilobytes",{size:(e/1024).toFixed(0)}):this.t("attachment.megabytes",{size:(e/(1024*1024)).toFixed(1)}):""}},watch:{"attachment.path":{handler(){this.refresh()},immediate:!0}},methods:{guessNameFromPath(){var n;return((((n=this.attachment)==null?void 0:n.path)||"").split("/").pop()||"").replace(/^[0-9a-f-]{8,}-/,"")},async refresh(){var e;if(!(!((e=this.attachment)!=null&&e.path)||!this.signAttachmentFn)){this.loading=!0;try{this.url=await this.signAttachmentFn(this.attachment.path)}finally{this.loading=!1}}},onFileClick(e){this.url||e.preventDefault()}}},df=["href"],ff=["src","alt"],hf=["src"],mf=["src"],pf=["href","download"],gf={class:"wm-att__main"},_f={class:"wm-att__name"},yf={key:0,class:"wm-att__meta"},vf={key:0,class:"wm-att__spin","aria-hidden":"true"};function bf(e,t,n,s,i,r){return p(),y("div",{class:te(["wm-att",["wm-att--"+(r.kind||"file")]])},[r.kind==="image"&&i.url?(p(),y("a",{key:0,href:i.url,target:"_blank",rel:"noopener",class:"wm-att__imgWrap"},[u("img",{src:i.url,alt:r.displayName,loading:"lazy"},null,8,ff)],8,df)):r.kind==="audio"&&i.url?(p(),y("audio",{key:1,src:i.url,controls:"",preload:"metadata"},null,8,hf)):r.kind==="video"&&i.url?(p(),y("video",{key:2,src:i.url,controls:"",preload:"metadata"},null,8,mf)):(p(),y("a",{key:3,class:"wm-att__file",href:i.url||"#",download:r.displayName,target:"_blank",rel:"noopener",onClick:t[0]||(t[0]=(...o)=>r.onFileClick&&r.onFileClick(...o))},[t[1]||(t[1]=u("span",{class:"wm-att__icon"},[u("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"},[u("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),u("path",{d:"M14 2v6h6"})])],-1)),u("span",gf,[u("span",_f,O(r.displayName),1),r.sizeLabel?(p(),y("span",yf,O(r.sizeLabel),1)):F("",!0)]),i.loading?(p(),y("span",vf)):F("",!0)],8,pf))],2)}const wf=be(uf,[["render",bf],["__scopeId","data-v-afc7b0d3"]]),kf={name:"WmBubble",props:{role:{type:String,default:"ai"},text:{type:String,default:""}},computed:{rendered(){return Ru(this.text)}}},Cf=["innerHTML"];function Sf(e,t,n,s,i,r){return p(),y("div",{class:te(["wm-bubble","wm-bubble--"+n.role])},[Ua(e.$slots,"default",{},()=>[u("span",{innerHTML:r.rendered},null,8,Cf)])],2)}const Af=be(kf,[["render",Sf],["__scopeId","data-v-7ab13147"]]),xf={name:"WmTyping"},Tf={class:"wm-typing"};function Mf(e,t,n,s,i,r){return p(),y("div",Tf,[...t[0]||(t[0]=[u("span",{style:{"animation-delay":"0s"}},null,-1),u("span",{style:{"animation-delay":"0.2s"}},null,-1),u("span",{style:{"animation-delay":"0.4s"}},null,-1)])])}const Ef=be(xf,[["render",Mf],["__scopeId","data-v-df2447fd"]]);function Rt(e){return e?e.client_msg_id||e.id:""}const Of={transferred_to_human:"system.transferredToHuman",assigned:"system.assigned",unassigned:"system.unassigned",resolved:"system.resolved",reopened:"system.reopened",idle:"system.idle"},If=80,Lf=200,Rf={name:"WmMessageList",components:{AIAvatar:wn,HumanAvatar:vo,Bubble:Af,Typing:Ef,ActionResult:kd,AttachmentPreview:wf,ArtifactRenderer:cf},inject:{t:{default:()=>Me()},wmLocale:{default:()=>()=>"fr"}},props:{messages:{type:Array,default:()=>[]},streamingActive:{type:Boolean,default:!1},dateLabel:{type:String,default:""},conversationId:{type:[String,Number],default:null},loadingMore:{type:Boolean,default:!1},hasMore:{type:Boolean,default:!1},unreadAnchorId:{type:Number,default:null},unreadBoundaryTs:{type:String,default:""},aiAgentName:{type:String,default:""},aiAgentAvatarUrl:{type:String,default:null}},emits:["load-more"],data(){return{silentFades:!1,widthByKey:Object.freeze({})}},computed:{historyExhausted(){return!this.hasMore&&!this.loadingMore&&this.messages.length>=20},groups(){var n,s,i,r;const e=[];for(const o of this.messages){const a=this.roleOf(o);if(a==="system"){if(((n=o==null?void 0:o.payload)==null?void 0:n.event)==="action_admin_pending"){const c=e[e.length-1];c&&c.role==="ai"?c.messages.push(o):e.push({key:`g-${Rt(o)}`,role:"ai",agentName:"",agentAvatarUrl:null,messages:[o],items:[]});continue}e.push({key:`sys-${Rt(o)}`,role:a,messages:[o],items:[],systemLabel:this.systemLabel(o)});continue}const l=e[e.length-1];l&&l.role===a&&(a==="ai"||l.agentName===(((s=o==null?void 0:o.author)==null?void 0:s.name)||""))?l.messages.push(o):e.push({key:`g-${Rt(o)}`,role:a,agentName:((i=o==null?void 0:o.author)==null?void 0:i.name)||"",agentAvatarUrl:((r=o==null?void 0:o.author)==null?void 0:r.avatar_url)||null,messages:[o],items:[]})}for(const o of e){if(o.role==="system")continue;const a=[];for(const l of o.messages)for(const f of this.itemsOf(l))a.push(f);o.items=a}const t=[];for(const o of e){if(o.role!=="system"&&!o.items.length)continue;const a=t[t.length-1];if(a&&a.role!=="system"&&a.role===o.role&&(o.role==="ai"||a.agentName===o.agentName)){a.messages.push(...o.messages),a.items.push(...o.items);continue}t.push(o)}for(const o of t)o.role!=="system"&&(o.key=this.stableGroupKey(o.messages));return t},unreadGroupKey(){if(this.unreadAnchorId==null)return null;const e=this.unreadAnchorId,t=this.unreadBoundaryTs;for(const n of this.groups){if(n.role==="user"||n.role==="system"||!n.items.length)continue;const s=n.messages[0];if(!s)continue;const i=kt(s.id);if(i!=null&&!(i<=e)&&!(t&&s.created_at&&s.created_at>t))return n.key}return null}},watch:{messages:{handler:"snapshotAndRestore",deep:!0},conversationId(e,t){e!==t&&(this._groupIdByMsgKey=null,this.silentFades=!1)},loadingMore(e){e||(this._pendingLoadMore=!1),e&&(this.silentFades=!0),this.snapshotAndRestore()},streamingActive:"snapshotAndRestore"},mounted(){this._lastSeenConvId=this.conversationId,this.scrollToBottom(),this._measureFrame=null,this._ro=new ResizeObserver(()=>this.scheduleMeasure()),this.$refs.scrollEl&&this._ro.observe(this.$refs.scrollEl),this.$nextTick(()=>this.measureRows())},beforeUnmount(){var e;(e=this._ro)==null||e.disconnect(),this._measureFrame&&cancelAnimationFrame(this._measureFrame)},updated(){this.scheduleMeasure()},methods:{messageKey:Rt,stableGroupKey(e){this._groupIdByMsgKey||(this._groupIdByMsgKey=new Map,this._groupIdCounter=0);const t=this._groupIdByMsgKey;let n=null;for(const s of e){const i=Rt(s);if(i&&t.has(i)){n=t.get(i);break}}n==null&&(n=++this._groupIdCounter);for(const s of e){const i=Rt(s);i&&t.set(i,n)}return`g-${n}`},isAtBottom(e){return e.scrollHeight-e.scrollTop-e.clientHeight<=If},onScroll(){const e=this.$refs.scrollEl;e&&(this.loadingMore||!this.hasMore||this._pendingLoadMore||e.scrollTop<=Lf&&(this._pendingLoadMore=!0,this.$emit("load-more")))},snapshotAndRestore(){const e=this.$refs.scrollEl;if(!e||this._scrollSnap)return;const t=this._lastSeenConvId!==this.conversationId;this._lastSeenConvId=this.conversationId;const n=this.isAtBottom(e);let s=null;if(!t&&!n){const r=this.pickAnchor(e);if(r!=null&&r.rowKey){const o=this.findRowByKey(e,r.rowKey);if(o){const a=e.getBoundingClientRect().top;s={rowKey:r.rowKey,relY:o.getBoundingClientRect().top-a}}}}const i={forceBottom:t,wasPinned:n,anchor:s};this._scrollSnap=i,this.$nextTick(()=>{if(this._scrollSnap=null,i.forceBottom||i.wasPinned){e.scrollTop=e.scrollHeight;return}if(!i.anchor)return;const r=()=>{const o=i.anchor,a=this.findRowByKey(e,o.rowKey);if(!a)return;const f=a.getBoundingClientRect().top-e.getBoundingClientRect().top-o.relY;Math.abs(f)>.5&&(e.scrollTop+=f)};r(),requestAnimationFrame(()=>{r(),requestAnimationFrame(r)})})},pickAnchor(e){const t=e.getBoundingClientRect().top,n=e.querySelectorAll(".wm-list__row[data-row-key]");let s=null;for(const i of n)if(s||(s=i),i.getBoundingClientRect().bottom>=t)return{rowKey:i.dataset.rowKey};return s?{rowKey:s.dataset.rowKey}:null},findRowByKey(e,t){if(!t)return null;const n=typeof CSS<"u"&&CSS.escape?CSS.escape(t):t.replace(/["\\]/g,"\\$&");return e.querySelector(`.wm-list__row[data-row-key="${n}"]`)},roleOf(e){var n,s;if((e==null?void 0:e.type)==="system"||((n=e==null?void 0:e.payload)==null?void 0:n.type)==="system")return"system";const t=(s=e==null?void 0:e.author)==null?void 0:s.type;return t==="user"?"user":t==="agent_human"?"human":"ai"},roleLabel(e){if(e.role==="human")return e.agentName||this.t("common.agent");const t=this.t("common.aiAssistant");return this.aiAgentName?`${this.aiAgentName} • ${t}`:t},itemsOf(e){var t;if(!e)return[];if(e.type==="system"&&((t=e==null?void 0:e.payload)==null?void 0:t.event)==="action_admin_pending")return[{message:e,partKey:"main",renderAs:"admin-pending",kind:{top:"bubble",bottom:"bubble"}}];if(e.type==="action"&&e.payload&&e.payload.state!=="pending"){const n=[{message:e,partKey:"main",renderAs:"action",kind:{top:"bubble",bottom:"bubble"}}];return this.actionArtifact(e)&&n.push({message:e,partKey:"artifact",renderAs:"artifact-of-action",kind:{top:"card",bottom:"card"}}),n}return this.artifactOf(e)?[{message:e,partKey:"main",renderAs:"artifact",kind:{top:"card",bottom:"card"}}]:e.text_md||this.attachmentsOf(e).length?[{message:e,partKey:"main",renderAs:"bubble",kind:{top:"bubble",bottom:"bubble"}}]:[]},cornersFor(e,t){var U,ee,ue;const n=e.items,s=(U=n[t])==null?void 0:U.kind,i=(ee=n[t-1])==null?void 0:ee.kind,r=(ue=n[t+1])==null?void 0:ue.kind,o=e.role==="user",a=14,l=4,f=i==null?void 0:i.bottom,c=r==null?void 0:r.top,g=this.widthByKey[this.rowKeyOf(e,t)],A=this.widthByKey[this.rowKeyOf(e,t-1)],S=this.widthByKey[this.rowKeyOf(e,t+1)],K=.5,I=(ye,we,z)=>ye!=null&&g!=null?ye+K>=g:we===z||we==="card"&&z==="bubble";let X=a,G=a,q=a,Q=a;return o?(f&&(G=l),(c||!r)&&(q=l),f&&I(A,f,s==null?void 0:s.top)&&(X=l),c&&I(S,c,s==null?void 0:s.bottom)&&(Q=l)):(f&&(X=l),(c||!r)&&(Q=l),f&&I(A,f,s==null?void 0:s.top)&&(G=l),c&&I(S,c,s==null?void 0:s.bottom)&&(q=l)),{tl:X,tr:G,br:q,bl:Q}},cornersStyle(e,t){if(e.items.length<2)return null;const n=this.cornersFor(e,t);return{"--wm-r-tl":`${n.tl}px`,"--wm-r-tr":`${n.tr}px`,"--wm-r-br":`${n.br}px`,"--wm-r-bl":`${n.bl}px`}},rowKeyOf(e,t){var s;const n=(s=e==null?void 0:e.items)==null?void 0:s[t];return n?`${Rt(n.message)}-${n.partKey}`:""},scheduleMeasure(){this._measureFrame||(this._measureFrame=requestAnimationFrame(()=>{this._measureFrame=null,this.measureRows()}))},measureRows(){const e=this.$refs.scrollEl;if(!e)return;const t={};for(const r of e.querySelectorAll(".wm-list__row[data-row-key]")){const o=r.dataset.rowKey;if(!o)continue;const a=r.querySelector(".wm-bubble, .wm-result, .wm-art, .wm-list__body");if(!a)continue;const l=a.getBoundingClientRect().width;l>0&&(t[o]=l)}const n=this.widthByKey,s=Object.keys(n),i=Object.keys(t);if(s.length===i.length){let r=!0;for(const o of i)if(Math.abs((n[o]??0)-t[o])>.5){r=!1;break}if(r)return}this.widthByKey=Object.freeze(t)},lastTimeOf(e){const t=e.items[e.items.length-1],n=(t==null?void 0:t.message)||e.messages[e.messages.length-1];if(!(n!=null&&n.created_at))return"";try{return ho(new Date(n.created_at),vn(this.wmLocale()))}catch{return""}},hasTrailingOverlay(e){if(!e.messages.length)return!1;const t=e.messages[e.messages.length-1],n=e.items[e.items.length-1];return!!t&&(n==null?void 0:n.message)!==t},attachmentsOf(e){var n;const t=(n=e==null?void 0:e.payload)==null?void 0:n.attachments;return Array.isArray(t)?t:[]},artifactOf(e){var n;const t=(n=e==null?void 0:e.metadata)==null?void 0:n.artifact;return!t||typeof t!="object"||typeof t.kind!="string"?null:t},actionLabel(e){var t;return((t=e==null?void 0:e.payload)==null?void 0:t.name)||(e==null?void 0:e.text_md)||this.t("common.action")},actionDetail(e){var n,s,i,r,o,a;const t=e==null?void 0:e.payload;return t?t.state==="success"?((n=t.success)==null?void 0:n.summary)||((i=(s=t.success)==null?void 0:s.metadata)==null?void 0:i.description)||"":t.state==="rejected"?((r=t.rejected)==null?void 0:r.reason)||this.t("action.rejectedByUser"):t.state==="failure"&&(((o=t.failure)==null?void 0:o.summary)||((a=t.failure)==null?void 0:a.error))||"":""},actionArtifact(e){var n,s;const t=(s=(n=e==null?void 0:e.payload)==null?void 0:n.success)==null?void 0:s.artifact;return!t||typeof t!="object"||typeof t.kind!="string"?null:t},systemLabel(e){var i,r,o;const t=(i=e==null?void 0:e.payload)==null?void 0:i.event,n=Of[t],s=((r=e==null?void 0:e.metadata)==null?void 0:r.agent_name)||((o=e==null?void 0:e.author)==null?void 0:o.name)||this.t("messageList.anAgent");return n?this.t(n,{name:s}):(e==null?void 0:e.text_md)||this.t("messageList.conversationUpdate")},scrollToBottom(){const e=this.$refs.scrollEl;e&&(e.scrollTop=e.scrollHeight)}}},Nf={key:0,class:"wm-list__loadMore",role:"status","aria-live":"polite"},Bf={class:"wm-list__loadMore-lbl"},Pf={key:1,class:"wm-list__historyEnd"},Ff={key:2,class:"wm-list__sep"},Df={class:"wm-list__sep-label"},jf={key:0,class:"wm-list__sep wm-list__sep--unread"},Uf={class:"wm-list__sep-label wm-list__sep-label--unread"},Hf={key:0,class:"wm-list__sysep"},$f={class:"wm-list__sysep-label"},Vf=["data-row-key"],Kf={key:0,class:"wm-list__avatarSlot"},qf={key:5,class:"wm-list__body"},Wf={key:0},zf={key:1,"aria-hidden":"true"},Gf={key:2},Yf={key:3,class:"wm-list__row wm-list__row--ai fade-up"},Jf={class:"wm-list__avatarSlot"};function Xf(e,t,n,s,i,r){const o=ge("AIAvatar"),a=ge("HumanAvatar"),l=ge("ActionResult"),f=ge("ArtifactRenderer"),c=ge("Bubble"),g=ge("AttachmentPreview"),A=ge("Typing");return p(),y("div",{ref:"scrollEl",class:te(["wm-list",{"wm-list--silent":i.silentFades}]),onScrollPassive:t[0]||(t[0]=(...S)=>r.onScroll&&r.onScroll(...S))},[n.loadingMore?(p(),y("div",Nf,[t[1]||(t[1]=u("span",{class:"wm-list__loadMore-spinner","aria-hidden":"true"},null,-1)),u("span",Bf,O(r.t("messageList.loadingHistory")),1)])):r.historyExhausted?(p(),y("div",Pf,O(r.t("messageList.conversationStart")),1)):F("",!0),n.dateLabel?(p(),y("div",Ff,[t[2]||(t[2]=u("div",{class:"wm-list__line"},null,-1)),u("span",Df,O(n.dateLabel),1),t[3]||(t[3]=u("div",{class:"wm-list__line"},null,-1))])):F("",!0),(p(!0),y(Z,null,Te(r.groups,(S,K)=>(p(),y(Z,{key:S.key},[S.key===r.unreadGroupKey?(p(),y("div",jf,[t[4]||(t[4]=u("div",{class:"wm-list__line wm-list__line--unread"},null,-1)),u("span",Uf,O(r.t("messageList.unread")),1),t[5]||(t[5]=u("div",{class:"wm-list__line wm-list__line--unread"},null,-1))])):F("",!0),S.role==="system"||S.items.length?(p(),y("div",{key:1,class:te(["wm-list__group","wm-list__group--"+S.role])},[S.role==="system"?(p(),y("div",Hf,[t[6]||(t[6]=u("div",{class:"wm-list__line wm-list__line--strong"},null,-1)),u("span",$f,O(S.systemLabel),1),t[7]||(t[7]=u("div",{class:"wm-list__line wm-list__line--strong"},null,-1))])):(p(),y(Z,{key:1},[(p(!0),y(Z,null,Te(S.items,(I,X)=>(p(),y("div",{key:`${r.messageKey(I.message)}-${I.partKey}`,"data-row-key":`${r.messageKey(I.message)}-${I.partKey}`,class:te(["wm-list__row fade-up",["wm-list__row--"+S.role,{"is-pending":I.message._pending,"is-failed":I.message._failed}]]),style:De(r.cornersStyle(S,X))},[S.role!=="user"?(p(),y("div",Kf,[X===S.items.length-1?(p(),y(Z,{key:0},[S.role==="ai"?(p(),ve(o,{key:0,size:26,tail:!0,name:n.aiAgentName,"image-url":n.aiAgentAvatarUrl},null,8,["name","image-url"])):(p(),ve(a,{key:1,name:S.agentName,"avatar-url":S.agentAvatarUrl,size:26,tail:!0},null,8,["name","avatar-url"]))],64)):F("",!0)])):F("",!0),I.renderAs==="action"?(p(),ve(l,{key:1,state:I.message.payload.state,label:r.actionLabel(I.message),detail:r.actionDetail(I.message)},null,8,["state","label","detail"])):I.renderAs==="admin-pending"?(p(),ve(l,{key:2,state:"awaiting",label:r.t("messageList.approvalRequestSent"),detail:I.message.text_md||""},null,8,["label","detail"])):I.renderAs==="artifact-of-action"?(p(),ve(f,{key:3,artifact:r.actionArtifact(I.message)},null,8,["artifact"])):I.renderAs==="artifact"?(p(),ve(f,{key:4,artifact:r.artifactOf(I.message)},null,8,["artifact"])):(p(),y("div",qf,[I.message.text_md?(p(),ve(c,{key:0,role:S.role,text:I.message.text_md},null,8,["role","text"])):F("",!0),r.attachmentsOf(I.message).length?(p(),y("div",{key:1,class:te(["wm-list__atts",{"wm-list__atts--align-end":S.role==="user"}])},[(p(!0),y(Z,null,Te(r.attachmentsOf(I.message),(G,q)=>(p(),ve(g,{key:`${r.messageKey(I.message)}-att-${q}`,attachment:G},null,8,["attachment"]))),128))],2)):F("",!0)]))],14,Vf))),128)),(S.role!=="user"||r.lastTimeOf(S))&&!r.hasTrailingOverlay(S)?(p(),y("div",{key:0,class:te(["wm-list__meta",{"wm-list__meta--right":S.role==="user"}])},[S.role!=="user"?(p(),y("span",Wf,O(r.roleLabel(S)),1)):F("",!0),S.role!=="user"&&r.lastTimeOf(S)?(p(),y("span",zf,"·")):F("",!0),r.lastTimeOf(S)?(p(),y("span",Gf,O(r.lastTimeOf(S)),1)):F("",!0)],2)):F("",!0)],64))],2)):F("",!0)],64))),128)),n.streamingActive?(p(),y("div",Yf,[u("div",Jf,[_e(o,{size:26,tail:!0,name:n.aiAgentName,"image-url":n.aiAgentAvatarUrl},null,8,["name","image-url"])]),_e(A)])):F("",!0)],34)}const Qf=be(Rf,[["render",Xf],["__scopeId","data-v-d769b193"]]),ss=typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function",Ys=typeof window<"u"&&typeof window.MediaRecorder<"u";function Zf(){return Ys&&["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"].find(t=>{var n,s;return(s=(n=window.MediaRecorder).isTypeSupported)==null?void 0:s.call(n,t)})||""}function Co({audio:e}){return{video:!0,audio:!!e,selfBrowserSurface:"include",surfaceSwitching:"include",systemAudio:e?"include":"exclude"}}async function eh(){if(!ss)return null;let e;try{e=await navigator.mediaDevices.getDisplayMedia(Co({audio:!1}))}catch(t){return(t==null?void 0:t.name)!=="NotAllowedError"&&console.error("[media] screenshot picker",t),null}try{return await th(e)}catch(t){return console.error("[media] screenshot capture",t),null}finally{e.getTracks().forEach(t=>{t.stop()})}}async function th(e){const t=document.createElement("video");t.muted=!0,t.playsInline=!0,t.srcObject=e,await t.play(),await new Promise(a=>requestAnimationFrame(a));const n=t.videoWidth||1280,s=t.videoHeight||720,i=document.createElement("canvas");i.width=n,i.height=s,i.getContext("2d").drawImage(t,0,0,n,s);const r=await new Promise((a,l)=>{i.toBlob(f=>f?a(f):l(new Error("toBlob failed")),"image/png")}),o=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19);return new File([r],`capture-${o}.png`,{type:"image/png"})}async function nh(e={}){var f;if(!ss||!Ys)return null;let t;try{t=await navigator.mediaDevices.getDisplayMedia(Co({audio:!0}))}catch(c){return(c==null?void 0:c.name)!=="NotAllowedError"&&console.error("[media] record picker",c),null}const n=Zf();let s;try{s=n?new window.MediaRecorder(t,{mimeType:n}):new window.MediaRecorder(t)}catch(c){return console.error("[media] recorder init",c),t.getTracks().forEach(g=>{g.stop()}),null}const i=[];let r=null,o=!1;s.addEventListener("dataavailable",c=>{c.data&&c.data.size>0&&i.push(c.data)}),s.addEventListener("stop",()=>{var c,g;if(r&&clearInterval(r),t.getTracks().forEach(A=>{A.stop()}),i.length){const A=s.mimeType||n||"video/webm",S=new Blob(i,{type:A}),K=/mp4/.test(A)?"mp4":"webm",I=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),X=new File([S],`ecran-${I}.${K}`,{type:A});(c=e.onfinalize)==null||c.call(e,X)}else(g=e.oncancel)==null||g.call(e)}),t.getVideoTracks().forEach(c=>{c.addEventListener("ended",()=>a(),{once:!0})});function a(){if(!o&&(o=!0,s.state!=="inactive"))try{s.stop()}catch(c){console.error("[media] recorder stop",c)}}try{s.start(1e3)}catch(c){return console.error("[media] recorder start",c),t.getTracks().forEach(g=>{g.stop()}),null}(f=e.onstart)==null||f.call(e);const l=Date.now();return r=setInterval(()=>{var c;(c=e.ontick)==null||c.call(e,Date.now()-l)},500),{stop:a,get state(){return s.state}}}const sh=[{action:"file",labelKey:"composer.attachFile",path:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"},{action:"screenshot",labelKey:"composer.screenshot",path:"M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2z M12 17a4 4 0 100-8 4 4 0 000 8z"},{action:"record",labelKey:"composer.recordScreen",path:"M23 7l-7 5 7 5V7z M1 5a2 2 0 012-2h12a2 2 0 012 2v14a2 2 0 01-2 2H3a2 2 0 01-2-2V5z"}],rh={name:"WmComposer",inject:{t:{default:()=>Me()}},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 sh.map(e=>({...e,label:this.t(e.labelKey),disabled:e.action==="screenshot"&&!ss||e.action==="record"&&(!ss||!Ys)}))},recordingElapsedLabel(){const e=Math.floor(this.recordingElapsed/1e3),t=Math.floor(e/60),n=e%60;return`${t}:${n.toString().padStart(2,"0")}`}},watch:{modelValue(e){e!==this.local&&(this.local=e,this.$nextTick(()=>this.autosize()))},local(e){this.$emit("update:modelValue",e)}},mounted(){this.autosize()},beforeUnmount(){if(this.recorder)try{this.recorder.stop()}catch{}},methods:{focus(){const e=this.$refs.inputEl;if(!(!e||this.disabled))try{e.focus({preventScroll:!0})}catch{e.focus()}},onSubmit(){if(!this.canSend)return;const e=this.local.trim();this.local="",this.$emit("send",e),this.$nextTick(()=>this.autosize())},onKeydown(e){e.key==="Enter"&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.isComposing&&(e.preventDefault(),this.onSubmit())},autosize(){const e=this.$refs.inputEl;e&&(e.style.height="auto",e.style.height=`${e.scrollHeight}px`)},onFile(e){const t=Array.from(e.target.files||[]);for(const n of t)this.$emit("attach",n);e.target.value=""},onAttachAction(e){this.attachOpen=!1,e==="file"?this.pickFile():e==="screenshot"?this.captureScreenshot():e==="record"&&this.startRecording()},pickFile(){var e;(e=this.$refs.fileEl)==null||e.click()},async captureScreenshot(){if(this.disabled)return;const e=await eh();e&&this.$emit("attach",e)},async startRecording(){if(this.recording||this.disabled)return;this.recordingElapsed=0;const e=await nh({onstart:()=>{this.recording=!0},ontick:t=>{this.recordingElapsed=t},onfinalize:t=>{this.$emit("attach",t),this.recording=!1,this.recordingElapsed=0,this.recorder=null},oncancel:()=>{this.recording=!1,this.recordingElapsed=0,this.recorder=null}});e&&(this.recorder=e)},stopRecording(){if(this.recorder)try{this.recorder.stop()}catch(e){console.error("[composer] stop recording",e)}}}},ih={class:"wm-compose-wrap"},oh={key:0,class:"wm-rec"},ah={class:"wm-rec__lbl"},lh={key:1,class:"wm-compose__menu",role:"menu"},ch=["disabled","onClick"],uh={class:"wm-compose__menuIcon"},dh={viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true"},fh=["d"],hh=["placeholder","disabled"],mh={class:"wm-compose__actions"},ph=["title","aria-label","disabled"],gh=["disabled","aria-label"];function _h(e,t,n,s,i,r){return p(),y("div",ih,[i.recording?(p(),y("div",oh,[t[8]||(t[8]=u("span",{class:"wm-rec__dot","aria-hidden":"true"},null,-1)),u("span",ah,O(r.t("composer.recording",{time:r.recordingElapsedLabel})),1),u("button",{type:"button",class:"wm-rec__stop",onClick:t[0]||(t[0]=(...o)=>r.stopRecording&&r.stopRecording(...o))},O(r.t("composer.stop")),1)])):F("",!0),u("form",{class:te(["wm-compose",{"has-attach":i.attachOpen}]),onSubmit:t[7]||(t[7]=wt((...o)=>r.onSubmit&&r.onSubmit(...o),["prevent"]))},[u("input",{ref:"fileEl",type:"file",hidden:"",multiple:"",onChange:t[1]||(t[1]=(...o)=>r.onFile&&r.onFile(...o))},null,544),i.attachOpen?(p(),y("div",{key:0,class:"wm-compose__overlay",onClick:t[2]||(t[2]=o=>i.attachOpen=!1)})):F("",!0),i.attachOpen?(p(),y("div",lh,[(p(!0),y(Z,null,Te(r.attachItems,o=>(p(),y("button",{key:o.action,type:"button",class:"wm-compose__menuItem",disabled:o.disabled,onClick:a=>r.onAttachAction(o.action)},[u("span",uh,[(p(),y("svg",dh,[u("path",{d:o.path,stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",fill:"none"},null,8,fh)]))]),u("span",null,O(o.label),1)],8,ch))),128))])):F("",!0),ct(u("textarea",{ref:"inputEl","onUpdate:modelValue":t[3]||(t[3]=o=>i.local=o),class:"wm-compose__input",rows:"3",placeholder:n.placeholder,disabled:n.disabled,onKeydown:t[4]||(t[4]=(...o)=>r.onKeydown&&r.onKeydown(...o)),onInput:t[5]||(t[5]=(...o)=>r.autosize&&r.autosize(...o))},null,40,hh),[[Lt,i.local]]),u("div",mh,[u("button",{type:"button",class:te(["wm-compose__icon",{"is-open":i.attachOpen}]),title:n.attachLabel,"aria-label":n.attachLabel,disabled:i.recording,onClick:t[6]||(t[6]=o=>i.attachOpen=!i.attachOpen)},[...t[9]||(t[9]=[u("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"},[u("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,ph),u("button",{type:"submit",class:te(["wm-compose__send",{"is-empty":!r.canSend}]),disabled:!r.canSend,"aria-label":r.t("composer.send")},[...t[10]||(t[10]=[u("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"},[u("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})],-1)])],10,gh)])],34)])}const yh=be(rh,[["render",_h],["__scopeId","data-v-aa81dbb8"]]),vh={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(e=>(e==null?void 0:e.label)||(e==null?void 0:e.text)||"").join("§")}}},bh=["onClick"];function wh(e,t,n,s,i,r){return n.items.length?(p(),y("div",{key:r.batchKey,class:"wm-chips"},[(p(!0),y(Z,null,Te(n.items,(o,a)=>(p(),y("button",{key:a,type:"button",class:"wm-chip",style:De({animationDelay:n.baseDelay+a*n.stepDelay+"ms"}),onClick:l=>e.$emit("select",o)},O(o.label),13,bh))),128))])):F("",!0)}const kh=be(vh,[["render",wh],["__scopeId","data-v-47ad8085"]]),Ch={name:"WmApprovalCard",components:{AIAvatar:wn},inject:{t:{default:()=>Me()}},props:{action:{type:String,required:!0},detail:{type:String,default:""},callbacks:{type:Array,default:()=>[]},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["callback"],computed:{approveCallback(){return this.callbacks.find(e=>e.id==="approve"||e.style==="primary")||this.callbacks[0]},rejectCallback(){return this.callbacks.find(e=>e.id==="reject"||e.style==="danger"||e.style==="neutral")||(this.callbacks.length>1?this.callbacks[1]:null)},approveId(){var e;return(e=this.approveCallback)==null?void 0:e.id},rejectId(){var e;return(e=this.rejectCallback)==null?void 0:e.id},approveLabel(){var e;return((e=this.approveCallback)==null?void 0:e.label)||this.t("approval.approve")},rejectLabel(){var e;return((e=this.rejectCallback)==null?void 0:e.label)||this.t("approval.reject")}}},Sh={class:"wm-approval"},Ah={class:"wm-approval__head"},xh={class:"wm-approval__icon"},Th={class:"wm-approval__main"},Mh={class:"wm-approval__title"},Eh={key:0,class:"wm-approval__detail"},Oh={class:"wm-approval__actions"};function Ih(e,t,n,s,i,r){const o=ge("AIAvatar");return p(),y("div",Sh,[u("div",Ah,[u("div",xh,[_e(o,{size:24,name:n.agentName,"image-url":n.agentAvatarUrl},null,8,["name","image-url"])]),u("div",Th,[u("div",Mh,O(n.action),1),n.detail?(p(),y("div",Eh,O(n.detail),1)):F("",!0)])]),u("div",Oh,[r.rejectId?(p(),y("button",{key:0,type:"button",class:"wm-approval__btn wm-approval__btn--neutral",onClick:t[0]||(t[0]=a=>e.$emit("callback",r.rejectId))},O(r.rejectLabel),1)):F("",!0),r.approveId?(p(),y("button",{key:1,type:"button",class:"wm-approval__btn wm-approval__btn--primary",onClick:t[1]||(t[1]=a=>e.$emit("callback",r.approveId))},O(r.approveLabel),1)):F("",!0)])])}const Lh=be(Ch,[["render",Ih],["__scopeId","data-v-a2bed37e"]]);let So=0;const Rh=new Set(["text","textarea","number","boolean","select","multiselect","date"]),Nh={name:"WmFormCard",components:{AIAvatar:wn},inject:{t:{default:()=>Me()}},props:{form:{type:Object,required:!0},readOnly:{type:Boolean,default:!1},initialValues:{type:Object,default:null},agentName:{type:String,default:""},agentAvatarUrl:{type:String,default:null}},emits:["submit"],data(){return So+=1,{_uid:So,values:{},busy:!1,error:""}},computed:{normalizedFields(){var t;return(Array.isArray((t=this.form)==null?void 0:t.fields)?this.form.fields:[]).filter(n=>!(!(n!=null&&n.key)||!(n!=null&&n.label)||!Rh.has(n==null?void 0:n.type)||(n.type==="select"||n.type==="multiselect")&&(!Array.isArray(n.options)||n.options.length===0)))}},created(){this.resetValues()},methods:{resetValues(){const e=this.initialValues&&typeof this.initialValues=="object"?this.initialValues:{},t={};for(const n of this.normalizedFields){if(e[n.key]!==void 0){t[n.key]=e[n.key];continue}n.type==="boolean"?t[n.key]=!1:n.type==="multiselect"?t[n.key]=[]:t[n.key]=""}this.values=t,this.error=""},toggleMulti(e,t,n){const s=Array.isArray(this.values[e])?this.values[e].slice():[],i=s.indexOf(t);n&&i===-1?s.push(t):!n&&i!==-1&&s.splice(i,1),this.values={...this.values,[e]:s}},validate(){for(const e of this.normalizedFields){if(!e.required)continue;const t=this.values[e.key];if(e.type!=="boolean"){if(e.type==="multiselect"){if(!Array.isArray(t)||t.length===0)return this.t("form.fieldRequired",{label:e.label});continue}if(t==null||t==="")return this.t("form.fieldRequired",{label:e.label})}}return""},async onSubmit(){if(this.readOnly||this.busy)return;const e=this.validate();if(e){this.error=e;return}this.error="",this.busy=!0;try{await this.$emit("submit",{values:this.values})}finally{this.busy=!1}}}},Bh={class:"wm-form"},Ph={class:"wm-form__head"},Fh={class:"wm-form__icon"},Dh={class:"wm-form__main"},jh={class:"wm-form__title"},Uh={key:0,class:"wm-form__detail"},Hh=["for"],$h={key:0,class:"wm-form__req","aria-hidden":"true"},Vh=["id","onUpdate:modelValue","placeholder","required","disabled"],Kh=["id","onUpdate:modelValue","placeholder","required","disabled"],qh=["id","onUpdate:modelValue","placeholder","required","disabled"],Wh=["id","onUpdate:modelValue","required","disabled"],zh={key:4,class:"wm-form__bool"},Gh=["id","onUpdate:modelValue","disabled"],Yh=["id","onUpdate:modelValue","required","disabled"],Jh={value:"",disabled:""},Xh=["value"],Qh={key:6,class:"wm-form__multi"},Zh=["value","checked","disabled","onChange"],em={key:0,class:"wm-form__err"},tm=["disabled"],nm={key:0,class:"wm-form__spinner","aria-hidden":"true"},sm={key:2,class:"wm-form__doneLbl"};function rm(e,t,n,s,i,r){const o=ge("AIAvatar");return p(),y("div",Bh,[u("div",Ph,[u("div",Fh,[_e(o,{size:24,name:n.agentName,"image-url":n.agentAvatarUrl},null,8,["name","image-url"])]),u("div",Dh,[u("div",jh,O(n.form.title||r.t("form.title")),1),n.form.description?(p(),y("div",Uh,O(n.form.description),1)):F("",!0)])]),u("form",{class:"wm-form__body",onSubmit:t[0]||(t[0]=wt((...a)=>r.onSubmit&&r.onSubmit(...a),["prevent"]))},[(p(!0),y(Z,null,Te(r.normalizedFields,a=>(p(),y("div",{key:a.key,class:"wm-form__field"},[u("label",{for:`wm-f-${i._uid}-${a.key}`,class:"wm-form__label"},[Zn(O(a.label),1),a.required?(p(),y("span",$h,"*")):F("",!0)],8,Hh),a.type==="text"?ct((p(),y("input",{key:0,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,type:"text",class:"wm-form__input",placeholder:a.placeholder||"",required:a.required,disabled:n.readOnly||i.busy},null,8,Vh)),[[Lt,i.values[a.key]]]):a.type==="textarea"?ct((p(),y("textarea",{key:1,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,class:"wm-form__textarea",rows:"3",placeholder:a.placeholder||"",required:a.required,disabled:n.readOnly||i.busy},null,8,Kh)),[[Lt,i.values[a.key]]]):a.type==="number"?ct((p(),y("input",{key:2,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,type:"number",class:"wm-form__input",placeholder:a.placeholder||"",required:a.required,disabled:n.readOnly||i.busy},null,8,qh)),[[Lt,i.values[a.key],void 0,{number:!0}]]):a.type==="date"?ct((p(),y("input",{key:3,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,type:"date",class:"wm-form__input",required:a.required,disabled:n.readOnly||i.busy},null,8,Wh)),[[Lt,i.values[a.key]]]):a.type==="boolean"?(p(),y("label",zh,[ct(u("input",{id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,type:"checkbox",disabled:n.readOnly||i.busy},null,8,Gh),[[sc,i.values[a.key]]]),u("span",null,O(a.placeholder||r.t("common.yes")),1)])):a.type==="select"?ct((p(),y("select",{key:5,id:`wm-f-${i._uid}-${a.key}`,"onUpdate:modelValue":l=>i.values[a.key]=l,class:"wm-form__select",required:a.required,disabled:n.readOnly||i.busy},[u("option",Jh,O(a.placeholder||r.t("form.choose")),1),(p(!0),y(Z,null,Te(a.options,l=>(p(),y("option",{key:l.value,value:l.value},O(l.label),9,Xh))),128))],8,Yh)),[[rc,i.values[a.key]]]):a.type==="multiselect"?(p(),y("div",Qh,[(p(!0),y(Z,null,Te(a.options,l=>(p(),y("label",{key:l.value,class:"wm-form__multiItem"},[u("input",{type:"checkbox",value:l.value,checked:Array.isArray(i.values[a.key])&&i.values[a.key].includes(l.value),disabled:n.readOnly||i.busy,onChange:f=>r.toggleMulti(a.key,l.value,f.target.checked)},null,40,Zh),u("span",null,O(l.label),1)]))),128))])):F("",!0)]))),128)),i.error?(p(),y("div",em,O(i.error),1)):F("",!0),n.readOnly?(p(),y("div",sm,O(r.t("form.responseSent")),1)):(p(),y("button",{key:1,type:"submit",class:"wm-form__submit",disabled:i.busy},[i.busy?(p(),y("span",nm)):F("",!0),u("span",null,O(i.busy?r.t("common.sending"):n.form.submit_label||r.t("common.send")),1)],8,tm))],32)])}const im=be(Nh,[["render",rm],["__scopeId","data-v-fe65cc56"]]),om={name:"WmFeedback",inject:{t:{default:()=>Me()}},props:{busy:{type:Boolean,default:!1},done:{type:Boolean,default:!1}},emits:["submit"],data(){return{sel:null}},computed:{options(){return[{v:1,e:"😞",l:this.t("feedback.rating1")},{v:2,e:"😐",l:this.t("feedback.rating2")},{v:3,e:"🙂",l:this.t("feedback.rating3")},{v:4,e:"😄",l:this.t("feedback.rating4")},{v:5,e:"🤩",l:this.t("feedback.rating5")}]}},methods:{onSend(){!this.sel||this.busy||this.$emit("submit",{rating:this.sel})}}},am={class:"wm-fb"},lm={class:"wm-fb__title"},cm={class:"wm-fb__sub"},um={class:"wm-fb__row"},dm=["onClick"],fm={class:"wm-fb__emoji"},hm={class:"wm-fb__label"},mm=["disabled"],pm={key:1,class:"wm-fb__done"},gm={class:"wm-fb__doneTitle"},_m={class:"wm-fb__doneSub"};function ym(e,t,n,s,i,r){return p(),y("div",am,[n.done?(p(),y("div",pm,[t[1]||(t[1]=u("div",{class:"wm-fb__check"},[u("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"},[u("path",{d:"M20 6L9 17l-5-5"})])],-1)),u("div",gm,O(r.t("feedback.doneTitle")),1),u("div",_m,O(r.t("feedback.doneSubtitle")),1)])):(p(),y(Z,{key:0},[u("div",lm,O(r.t("feedback.question")),1),u("div",cm,O(r.t("feedback.subtitle")),1),u("div",um,[(p(!0),y(Z,null,Te(r.options,o=>(p(),y("button",{key:o.v,type:"button",class:te(["wm-fb__opt",{"is-selected":i.sel===o.v}]),onClick:a=>i.sel=o.v},[u("span",fm,O(o.e),1),u("span",hm,O(o.l),1)],10,dm))),128))]),u("button",{type:"button",class:"wm-fb__send",disabled:!i.sel||n.busy,onClick:t[0]||(t[0]=(...o)=>r.onSend&&r.onSend(...o))},O(n.busy?r.t("common.sending"):r.t("feedback.submit")),9,mm)],64))])}const vm=be(om,[["render",ym],["__scopeId","data-v-9b630564"]]),bm={name:"WmMoreMenu",inject:{t:{default:()=>Me()}},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(e){this.soundOn=!!e},browserNotifEnabled(e){this.browserNotifOn=!!e}},methods:{emit(e){this.$emit("action",e)},toggleSound(){this.soundOn=!this.soundOn,this.$emit("sound-toggle",this.soundOn)},toggleBrowserNotif(){this.browserNotifOn=!this.browserNotifOn,this.$emit("browser-notif-toggle",this.browserNotifOn)}}},wm={class:"wm-mm"},km={class:"wm-mm__pop",role:"menu"},Cm={key:0,class:"wm-mm__section"},Sm={class:"wm-mm__label"},Am={class:"wm-mm__label"},xm={key:1,class:"wm-mm__sep"},Tm={class:"wm-mm__section"},Mm={class:"wm-mm__label"},Em={class:"wm-mm__label"},Om={class:"wm-mm__section"},Im={class:"wm-mm__label"},Lm={class:"wm-mm__label"};function Rm(e,t,n,s,i,r){return p(),y("div",wm,[u("div",{class:"wm-mm__scrim",onClick:t[0]||(t[0]=o=>e.$emit("close"))}),u("div",km,[n.canRename||n.canExport?(p(),y("div",Cm,[n.canRename?(p(),y("button",{key:0,type:"button",class:"wm-mm__item",onClick:t[1]||(t[1]=o=>r.emit("rename"))},[t[7]||(t[7]=u("span",{class:"wm-mm__icon"},[u("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"},[u("path",{d:"M12 20h9"}),u("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})])],-1)),u("span",Sm,O(r.t("moreMenu.editTitle")),1)])):F("",!0),n.canExport?(p(),y("button",{key:1,type:"button",class:"wm-mm__item",onClick:t[2]||(t[2]=o=>r.emit("export"))},[t[8]||(t[8]=u("span",{class:"wm-mm__icon"},[u("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"},[u("path",{d:"M4 12v8a2 2 0 002 2h12a2 2 0 002-2v-8M16 6l-4-4-4 4M12 2v13"})])],-1)),u("span",Am,O(r.t("moreMenu.exportTranscript")),1),t[9]||(t[9]=u("span",{class:"wm-mm__hint"},".txt",-1))])):F("",!0)])):F("",!0),n.canRename||n.canExport?(p(),y("div",xm)):F("",!0),u("div",Tm,[u("button",{type:"button",class:"wm-mm__item",onClick:t[3]||(t[3]=(...o)=>r.toggleSound&&r.toggleSound(...o))},[t[11]||(t[11]=u("span",{class:"wm-mm__icon"},[u("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"},[u("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),u("path",{d:"M15.54 8.46a5 5 0 010 7.07M19.07 4.93a10 10 0 010 14.14"})])],-1)),u("span",Mm,O(r.t("moreMenu.sound")),1),u("span",{class:te(["wm-mm__toggle",{"wm-mm__toggle--on":i.soundOn}])},[...t[10]||(t[10]=[u("span",{class:"wm-mm__knob"},null,-1)])],2)]),u("button",{type:"button",class:"wm-mm__item",onClick:t[4]||(t[4]=(...o)=>r.toggleBrowserNotif&&r.toggleBrowserNotif(...o))},[t[13]||(t[13]=u("span",{class:"wm-mm__icon"},[u("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"},[u("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)),u("span",Em,O(r.t("moreMenu.browserNotifications")),1),u("span",{class:te(["wm-mm__toggle",{"wm-mm__toggle--on":i.browserNotifOn}])},[...t[12]||(t[12]=[u("span",{class:"wm-mm__knob"},null,-1)])],2)])]),t[16]||(t[16]=u("div",{class:"wm-mm__sep"},null,-1)),u("div",Om,[n.statusUrl?(p(),y("button",{key:0,type:"button",class:"wm-mm__item",onClick:t[5]||(t[5]=o=>r.emit("status"))},[t[14]||(t[14]=u("span",{class:"wm-mm__icon"},[u("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"},[u("path",{d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zM10 6v4l3 2"})])],-1)),u("span",Im,O(r.t("moreMenu.serviceStatus")),1)])):F("",!0),n.helpUrl?(p(),y("button",{key:1,type:"button",class:"wm-mm__item",onClick:t[6]||(t[6]=o=>r.emit("help"))},[t[15]||(t[15]=u("span",{class:"wm-mm__icon"},[u("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"},[u("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)),u("span",Lm,O(r.t("moreMenu.helpCenter")),1)])):F("",!0)])])])}const Nm=be(bm,[["render",Rm],["__scopeId","data-v-76281e95"]]),Bm={name:"WmRenameDialog",inject:{t:{default:()=>Me()}},props:{title:{type:String,default:""},initialValue:{type:String,default:""},placeholder:{type:String,default:""}},emits:["close","submit"],data(){return{value:this.initialValue||""}},computed:{canSubmit(){const e=(this.value||"").trim();return!!e&&e!==(this.initialValue||"").trim()}},mounted(){this.$nextTick(()=>{const e=this.$refs.input;if(e){e.focus();try{e.select()}catch{}}})},methods:{onSubmit(){this.canSubmit&&this.$emit("submit",this.value.trim())}}},Pm={class:"wm-dialog"},Fm={class:"wm-dialog__card",role:"dialog","aria-modal":"true"},Dm={class:"wm-dialog__head"},jm={class:"wm-dialog__title"},Um=["aria-label"],Hm={class:"wm-dialog__body"},$m=["placeholder"],Vm={class:"wm-dialog__actions"},Km=["disabled"];function qm(e,t,n,s,i,r){return p(),y("div",Pm,[u("div",{class:"wm-dialog__scrim",onClick:t[0]||(t[0]=o=>e.$emit("close"))}),u("div",Fm,[u("div",Dm,[u("div",jm,O(n.title||r.t("rename.title")),1),u("button",{type:"button",class:"wm-dialog__close","aria-label":r.t("common.close"),onClick:t[1]||(t[1]=o=>e.$emit("close"))},[...t[7]||(t[7]=[u("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"},[u("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,Um)]),u("div",Hm,[ct(u("input",{ref:"input","onUpdate:modelValue":t[2]||(t[2]=o=>i.value=o),type:"text",class:"wm-dialog__input",placeholder:n.placeholder||r.t("rename.placeholder"),maxlength:120,onKeydown:[t[3]||(t[3]=ns(wt((...o)=>r.onSubmit&&r.onSubmit(...o),["prevent"]),["enter"])),t[4]||(t[4]=ns(wt(o=>e.$emit("close"),["prevent"]),["esc"]))]},null,40,$m),[[Lt,i.value]])]),u("div",Vm,[u("button",{type:"button",class:"wm-dialog__btn",onClick:t[5]||(t[5]=o=>e.$emit("close"))},O(r.t("common.cancel")),1),u("button",{type:"button",class:"wm-dialog__btn wm-dialog__btn--primary",disabled:!r.canSubmit,onClick:t[6]||(t[6]=(...o)=>r.onSubmit&&r.onSubmit(...o))},O(r.t("common.save")),9,Km)])])])}const Wm=be(Bm,[["render",qm],["__scopeId","data-v-6d5f94a8"]]),Ao="ww-messenger-tokens",zm={name:"Messenger",components:{Launcher:ou,Header:Ou,Onboarding:ud,MessageList:Qf,Composer:yh,SuggestionChips:kh,ApprovalCard:Lh,FormCard:im,Feedback:vm,MoreMenu:Nm,RenameDialog:Wm},mixins:[Oc,Pc,Fc,jc],provide(){return{signAttachmentFn:e=>{var t,n;return((n=(t=this.store)==null?void 0:t.signAttachment)==null?void 0:n.call(t,e))||null},t:(e,t)=>this.t(e,t),wmLocale:()=>this.locale}},props:{baseUrl:{type:String,default:mo},widgetId:{type:String,default:""},userId:{type:String,default:""},userHash:{type:String,default:""},context:{type:Object,default:null},displayMode:{type:String,default:"floating"},devtools:{type:Boolean,default:!1},language:{type:String,default:""}},data(){return{transport:null,store:null,isOpen:!1,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"},customerLanguage(){var n,s,i,r;const e=(n=this.s)==null?void 0:n.customer,t=e&&(e.language||((s=e.values)==null?void 0:s.language));return t||((r=(i=this.context)==null?void 0:i.customer)==null?void 0:r.language)||""},locale(){var e;return Gs(this.language||this.customerLanguage||((e=this.widget)==null?void 0:e.default_language)||"")},translator(){return Me(this.locale)},error(){var e;return this.bootError||((e=this.s)==null?void 0:e.error)||null},canBoot(){return!!(this.baseUrl&&this.widgetId&&this.userId&&this.userHash)},s(){var e;return((e=this.store)==null?void 0:e.state)||null},ready(){var e;return!!((e=this.s)!=null&&e.ready)},allConversations(){var t;const e=(t=this.s)==null?void 0:t.conversations;return Array.isArray(e)?e:[]},drawerConversations(){var n;const e=((n=this.s)==null?void 0:n.messagesByConv)||{},t=this.revealedAt;return this.allConversations.map(s=>{var f;const i=e[s.id]||[],r=kt(s.last_read_message_id);let o=0,a=null;for(let c=i.length-1;c>=0;c--){const g=i[c];if(!g)continue;if(((f=g.author)==null?void 0:f.type)==="user")break;const A=kt(g.id);if(A!=null){if(r!=null&&A<=r)break;t[g.id]!==0&&(!a&&g.author&&(a=g.author),o++)}}const l=i.filter(c=>!((c==null?void 0:c.id)!=null&&t[c.id]===0));return{...s,_preview:xc(s,l),_unread:o>0,_unreadCount:o,_lastAuthor:a}})},unreadCount(){return this.drawerConversations.filter(e=>e._unread).length},openThreads(){var t;const e=((t=this.s)==null?void 0:t.messagesByConv)||{};return this.drawerConversations.filter(n=>n.status!=="resolved").map(n=>({id:n.id,title:n.name||this.t("common.newConversation"),preview:n._preview||this.t("onboarding.newMessage"),unread:!!n._unread,_ts:yo(n,e[n.id]||[])})).sort((n,s)=>n._ts<s._ts?1:n._ts>s._ts?-1:0)},latestUnreads(){var n;const e=((n=this.s)==null?void 0:n.messagesByConv)||{},t=[];for(const s of this.drawerConversations){if(!s._unread)continue;const i=yo(s,e[s.id]||[]),r=s._lastAuthor,o=!r||r.type==="agent_ia",a=(r==null?void 0:r.name)||(o?this.agentName:"")||"",l=(r==null?void 0:r.avatar_url)||(o?this.agentAvatarUrl:null);t.push({convId:s.id,preview:s._preview||this.t("notification.youHaveNewMessage"),ts:i,count:s._unreadCount||1,senderName:a,senderAvatarUrl:l})}return t.sort((s,i)=>s.ts<i.ts?1:s.ts>i.ts?-1:0),t},launcherPeeks(){if(this.isOpen||this.isEmbedded)return[];const e=this.dismissedPeeks||{};return this.latestUnreads.filter(t=>e[t.convId]!==t.ts)},isViewingThread(){return(this.isOpen||this.isEmbedded)&&!!this.currentConv},currentConv(){if(this.draftConv)return this.draftConv;if(this.showOnboarding)return null;const e=this.allConversations;if(!e.length)return null;if(this.activeConvId!=null){const t=e.find(n=>n.id===this.activeConvId);if(t)return t}return e[0]||null},canBack(){return!!this.currentConv},statusUrl(){var n;const e=(n=this.widget)==null?void 0:n.quick_links;if(!Array.isArray(e))return"";const t=e.find(s=>s.icon==="status"&&s.url);return(t==null?void 0:t.url)||""},helpUrl(){var n;const e=(n=this.widget)==null?void 0:n.quick_links;if(!Array.isArray(e))return"";const t=e.find(s=>(s.icon==="chat"||s.icon==="help")&&s.url);return(t==null?void 0:t.url)||""},widget(){var e,t;return((t=(e=this.s)==null?void 0:e.config)==null?void 0:t.widget)||null},widgetWelcomeMessage(){var e;return((e=this.widget)==null?void 0:e.welcome_message)||""},widgetSubtitle(){var e;return((e=this.widget)==null?void 0:e.subtitle)||""},defaultIconUrl(){var e;return((e=this.widget)==null?void 0:e.default_icon_url)||null},agentName(){var e,t,n;return((n=(t=(e=this.s)==null?void 0:e.config)==null?void 0:t.agent)==null?void 0:n.name)||""},agentAvatarUrl(){var e,t,n;return((n=(t=(e=this.s)==null?void 0:e.config)==null?void 0:t.agent)==null?void 0:n.avatar_url)||null},quickLinks(){var t;const e=(t=this.widget)==null?void 0:t.quick_links;return Array.isArray(e)?e:[]},teamMembers(){var t;const e=(t=this.widget)==null?void 0:t.team_members;return Array.isArray(e)?e:[]},responseLabel(){var e;return((e=this.widget)==null?void 0:e.response_time_label)||""},humanMessageAuthor(){var t,n,s;if(!this.currentConv)return null;const e=((t=this.s.messagesByConv)==null?void 0:t[this.currentConv.id])||[];for(let i=e.length-1;i>=0;i--)if(((s=(n=e[i])==null?void 0:n.author)==null?void 0:s.type)==="agent_human")return e[i].author;return null},humanAgentName(){var e;return((e=this.humanMessageAuthor)==null?void 0:e.name)||""},humanAgentAvatarUrl(){var e;return((e=this.humanMessageAuthor)==null?void 0:e.avatar_url)||null},isEscalated(){return!!this.humanMessageAuthor},isWaitingHuman(){var t;const e=(t=this.currentConv)==null?void 0:t.status;return e==="waiting"||e==="handled"},headerTitle(){var e,t;return((e=this.currentConv)==null?void 0:e.name)||((t=this.widget)==null?void 0:t.name)||this.t("common.newConversation")},composerPlaceholder(){return this.isEscalated&&this.humanAgentName?this.t("composer.replyTo",{name:this.humanAgentName.split(" ")[0]}):this.isWaitingHuman?this.t("composer.agentTakingOver"):this.t("composer.placeholder")},displayedMessages(){var n,s;const e=this.currentConv;if(!e)return[];if(!e._draft){const i=(s=(n=this.s)==null?void 0:n.paginationByConv)==null?void 0:s[e.id];if(!(i!=null&&i.loaded))return[]}const t=this.revealedAt;return(this.s.messagesByConv[e.id]||[]).filter(i=>{var r,o,a,l,f;return(i==null?void 0:i.type)==="action"&&((r=i==null?void 0:i.payload)==null?void 0:r.state)==="pending"||bn(i)&&!(t[i.id]>0)?!1:(i==null?void 0:i.type)==="action"||(i==null?void 0:i.type)==="system"||((o=i==null?void 0:i.payload)==null?void 0:o.type)==="system"||Array.isArray((a=i==null?void 0:i.payload)==null?void 0:a.attachments)&&i.payload.attachments.length||(l=i==null?void 0:i.metadata)!=null&&l.artifact||(f=i==null?void 0:i.metadata)!=null&&f.form?!0:typeof(i==null?void 0:i.text_md)=="string"&&i.text_md.trim().length>0})},streamingActive(){var n,s,i;const e=this.currentConv;return e?Object.keys(((n=this.s)==null?void 0:n.streamingByMsgId)||{}).length>0?!0:this.actionInFlight?!1:(((i=(s=this.s)==null?void 0:s.messagesByConv)==null?void 0:i[e.id])||[]).some(r=>bn(r)&&!(this.revealedAt[r.id]>0)):!1},currentConvMessages(){var t,n,s;const e=(t=this.currentConv)==null?void 0:t.id;return e?((s=(n=this.s)==null?void 0:n.messagesByConv)==null?void 0:s[e])||[]:[]},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 e,t,n;return((t=(e=this.pendingApproval)==null?void 0:e.payload)==null?void 0:t.name)||((n=this.pendingApproval)==null?void 0:n.text_md)||this.t("action.title")},approvalDetail(){var s,i,r,o,a,l;const e=(r=(i=(s=this.pendingApproval)==null?void 0:s.payload)==null?void 0:i.pending)==null?void 0:r.user_explanation;if(typeof e=="string"&&e.trim())return e.trim();const t=(l=(a=(o=this.pendingApproval)==null?void 0:o.payload)==null?void 0:a.pending)==null?void 0:l.prepared_params;if(!t||typeof t!="object")return"";const n=Object.entries(t);return n.length?n.slice(0,2).map(([f,c])=>`${f}: ${c}`).join(" · "):""},actionInFlight(){var e,t;return!this.currentConv||!this.store?null:((t=(e=this.store).getActionInFlight)==null?void 0:t.call(e,this.currentConv.id))||null},actionInFlightName(){var t;const e=this.actionInFlight;return e?((t=e.payload)==null?void 0:t.name)||e.text_md||this.t("common.action"):""},suggestions(){return!this.currentConv||!this.store?[]:this.streamingActive?[]:this.pendingForm?[]:this.store.getLatestSuggestions(this.currentConv.id)},pendingForm(){var e,t;return!this.currentConv||!this.store||this.pendingApproval||this.actionInFlight||this.streamingActive||!this.approvalSettled?null:((t=(e=this.store).getLatestForm)==null?void 0:t.call(e,this.currentConv.id))||null},showFeedback(){var t;const e=this.currentConv;return e?this.feedbackDone?!0:e.status!=="resolved"?!1:!((t=e.metadata)!=null&&t.feedback):!1},floatVisible(){return this.approvalReady||!!this.pendingForm||this.showFeedback||this.suggestions.length>0},dateLabel(){var n,s,i;const e=this.currentConv;let t=new Date;if(e){const o=((i=(((s=(n=this.s)==null?void 0:n.messagesByConv)==null?void 0:s[e.id])||[]).find(a=>a==null?void 0:a.created_at))==null?void 0:i.created_at)||e.created_at;if(o){const a=new Date(o);Number.isNaN(a.getTime())||(t=a)}}return this.t("messageList.today",{time:ho(t,vn(this.locale))})},paginationState(){var n,s,i;const e=(n=this.currentConv)==null?void 0:n.id,t=e?(i=(s=this.s)==null?void 0:s.paginationByConv)==null?void 0:i[e]:null;return{loading:!!(t!=null&&t.loading),hasMore:!!(t!=null&&t.nextCursor)}}},watch:{latestUnreads:{handler(e){const t=new Set(e.map(o=>o.convId)),n=this.dismissedPeeks||{},s=Object.keys(n);if(!s.length)return;const i={};let r=!1;for(const o of s)t.has(o)?i[o]=n[o]:r=!0;r&&(this.dismissedPeeks=i)},deep:!0},"currentConv.id":{handler(e){var t;this.resetRevealQueue(),this.convOpenedAt=Date.now(),this.moreOpen=!1,this.renameDialogOpen=!1,this.resetApprovalPacing(),this.isViewingThread&&(this.unreadAnchorId=kt((t=this.currentConv)==null?void 0:t.last_read_message_id),this.unreadBoundaryTs=e?new Date().toISOString():"")},immediate:!0},isViewingThread(e,t){var n;e&&!t?(this.unreadAnchorId=kt((n=this.currentConv)==null?void 0:n.last_read_message_id),this.unreadBoundaryTs=new Date().toISOString()):e||(this.unreadAnchorId=null,this.unreadBoundaryTs="")},pendingApproval:{handler(e,t){if(e&&!t){const n=e!=null&&e.created_at?Date.parse(e.created_at):NaN;if(!(Number.isFinite(n)&&n>=this.convOpenedAt)){this.resetApprovalPacing();return}this.bumpApprovalSettle(2600)}else!e&&t&&this.resetApprovalPacing()},immediate:!1},streamingActive(e,t){e!==t&&this.pendingApproval&&this.pendingApproval.id!==this.approvalLatchId&&this.bumpApprovalSettle()},approvalReady(e){e&&this.pendingApproval&&(this.approvalLatchId=this.pendingApproval.id)},floatVisible:{handler(e){this.$nextTick(()=>this.syncFloatObserver(e))},immediate:!0},currentConvMessages(e){var t;this.paceMessages(e,(t=this.currentConv)==null?void 0:t.id),(this.isOpen||this.isEmbedded)&&this.currentConv&&this.markConvRead(this.currentConv)}},async mounted(){if(typeof document<"u"&&!document.getElementById(Ao)){const e=document.createElement("style");e.id=Ao,e.textContent=kc,document.head.appendChild(e)}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:{t(e,t){return this.translator(e,t)},async boot(){var e;if(!this.canBoot){console.warn("[messenger] boot skipped — missing creds");return}try{this.transport=Cs(_c({baseUrl:this.baseUrl,widgetId:this.widgetId,userId:this.userId,userHash:this.userHash})),this.store=Cs(wc(this.transport)),this.hydrateNotifPref(),await this.store.start(),this.setupLiveReveal();const t=(e=this.context)==null?void 0:e.customer;t&&typeof t=="object"&&await this.store.applyCustomer(t)}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(e){if(this.disconnectFloatRO(),!e){this.floatHeight=0;return}const t=this.$refs.floatEl;if(t){if(typeof ResizeObserver>"u"){this.floatHeight=Math.ceil(t.getBoundingClientRect().height+8);return}this.floatRO=new ResizeObserver(n=>{const s=n[0];if(!s)return;const i=Math.ceil(s.contentRect.height+8);i!==this.floatHeight&&(this.floatHeight=i,this.$nextTick(()=>{var r,o;(o=(r=this.$refs.messageList)==null?void 0:r.scrollToBottom)==null||o.call(r)}))}),this.floatRO.observe(t)}},disconnectFloatRO(){if(this.floatRO){try{this.floatRO.disconnect()}catch{}this.floatRO=null}},async open(){this.isOpen=!0,this.store&&this.store.setPanelOpen(!0);const e=this.currentConv;if(e&&!e._draft){this.activeConvId==null&&(this.activeConvId=e.id);try{await this.store.openConversation(e.id)}catch(t){console.error("[ww-messenger] load messages failed",t)}this.markConvRead(e)}},close(){this.isOpen=!1,this.store&&this.store.setPanelOpen(!1)},async openFromPeek(e){var n,s;const t=e||((n=this.latestUnreads[0])==null?void 0:n.convId);t&&t!==((s=this.currentConv)==null?void 0:s.id)&&(this.draftConv=null,this.activeConvId=t,this.showOnboarding=!1),await this.open()},dismissPeek(e){const t=this.latestUnreads.find(n=>n.convId===e);t&&(this.dismissedPeeks={...this.dismissedPeeks,[e]:t.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 e=this.currentConv;if(!e)return null;if(!e._draft)return e;if(this.busy)return null;this.busy=!0;try{const t=await this.store.createConversation({});return this.draftConv=null,this.activeConvId=t.id,await this.store.openConversation(t.id),this.markConvRead(t),t}catch(t){return console.error("[ww-messenger] create conv failed",t),this.bootError=(t==null?void 0:t.message)||String(t),null}finally{this.busy=!1}},focusComposer(){this.$nextTick(()=>{var e;return(e=this.$refs.composer)==null?void 0:e.focus()})},toggleMore(){this.moreOpen=!this.moreOpen},goHome(){this.moreOpen=!1,this.draftConv=null,this.activeConvId=null,this.showOnboarding=!0},async onDrawerPick(e){if(!(e!=null&&e.id)||!this.store)return;this.draftConv=null,this.activeConvId=e.id,this.showOnboarding=!1;try{await this.store.openConversation(e.id)}catch(n){console.error("[ww-messenger] open conv failed",n)}const t=this.allConversations.find(n=>n.id===e.id);t&&this.markConvRead(t)},async onMoreAction(e){var t,n;switch(this.moreOpen=!1,e){case"rename":this.openRenameDialog();break;case"export":Ec(this.currentConv,this.currentConv?(n=(t=this.s)==null?void 0:t.messagesByConv)==null?void 0:n[this.currentConv.id]:[],this.translator,this.locale);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 e=this.currentConv;!e||e._draft||(this.renameDialogOpen=!0)},async onRenameSubmit(e){const t=this.currentConv;if(this.renameDialogOpen=!1,!t||t._draft||!this.store)return;const n=(e||"").trim();if(!(!n||n===t.name))try{await this.store.patchConversation(t.id,{name:n})}catch(s){console.error("[ww-messenger] rename failed",s)}},async onSend(e){let t=this.currentConv;if(!t&&(this.startConv(),t=this.currentConv,!t)||t._draft&&(t=await this.ensureRealConv(),!t))return;const n=t.id,s=this.pendingAttachments.slice();this.pendingAttachments=[],this.unreadAnchorId=null,this.unreadBoundaryTs="",await this.store.send(n,e,{attachments:s.length?s:void 0})},async onSuggestion(e){const t=e==null?void 0:e.label;t&&await this.onSend(t)},async onLoadMore(){var t;const e=(t=this.currentConv)==null?void 0:t.id;!e||!this.store||await this.store.loadMore(e)},async onApprovalCallback(e){const t=this.pendingApproval;t&&await this.store.clickCallback(t.id,e)},async onFormSubmit({values:e}){const t=this.pendingForm;if(!(t!=null&&t.form))return;const n=Sc(t.form,e,this.translator);if(!n)return;let s=this.currentConv;s&&(s._draft&&(s=await this.ensureRealConv(),!s)||await this.store.send(s.id,n,{metadata:{artifact:Ac(t.form,e,this.translator)}}))},async onAttach(e){if(!(!e||!this.transport))try{const t=await this.transport.uploadAttachment(e);this.pendingAttachments.push({type:t.type||"file",path:t.path,name:e.name||this.t("attachment.fileFallbackName"),mime_type:e.type,size_bytes:e.size})}catch(t){console.error("[ww-messenger] attachment upload failed",t)}},async onQuickLink(e){if(e){if(e.url){try{window.open(e.url,"_blank","noopener")}catch{}return}this.currentConv||this.startConv(),await this.onSend(e.label)}},async onFeedback({rating:e,comment:t}){if(this.currentConv){this.feedbackBusy=!0;try{await this.store.submitFeedback(this.currentConv.id,{rating:e,comment:t}),this.feedbackDone=!0}catch(n){console.error("[ww-messenger] feedback failed",n)}finally{this.feedbackBusy=!1}}}}},Gm={key:0,class:"wm-loading","aria-busy":"true","aria-live":"polite"},Ym=["aria-label"],Jm={key:0,class:"wm-state"},Xm={class:"wm-state__err"},Qm={class:"wm-state__errTitle"},Zm={class:"wm-state__errSub"},ep={class:"wm-bottom"},tp={key:0,ref:"floatEl",class:"wm-float"},np={key:1,class:"wm-actionWait",role:"status","aria-live":"polite"},sp={class:"wm-actionWait__lbl"},rp={key:2,class:"wm-attached"},ip=["aria-label","onClick"];function op(e,t,n,s,i,r){const o=ge("Launcher"),a=ge("Header"),l=ge("Onboarding"),f=ge("MessageList"),c=ge("ApprovalCard"),g=ge("FormCard"),A=ge("Feedback"),S=ge("SuggestionChips"),K=ge("Composer"),I=ge("MoreMenu"),X=ge("RenameDialog");return p(),y("div",{class:te(["wm-root",`wm-root--${n.displayMode}`])},[!i.isOpen&&!r.isEmbedded?(p(),ve(o,{key:0,"unread-count":r.unreadCount,peeks:r.launcherPeeks,onOpen:r.openFromPeek,onDismiss:r.dismissPeek},null,8,["unread-count","peeks","onOpen","onDismiss"])):F("",!0),i.isOpen||r.isEmbedded?(p(),y("section",{key:1,class:te(["wm-panel",`wm-panel--${n.displayMode}`]),style:De(i.floatHeight?{"--wm-float-h":i.floatHeight+"px"}:null),role:"dialog","aria-label":"Messenger"},[!r.ready&&!r.error?(p(),y("div",Gm,[r.isEmbedded?F("",!0):(p(),y("button",{key:0,type:"button",class:"wm-loading__close","aria-label":r.t("loading.minimize"),onClick:t[0]||(t[0]=(...G)=>r.close&&r.close(...G))},[...t[5]||(t[5]=[u("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"},[u("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,Ym)),t[6]||(t[6]=u("div",{class:"wm-loading__spinner","aria-hidden":"true"},null,-1))])):(p(),y(Z,{key:1},[_e(a,{title:r.headerTitle,"team-members":r.teamMembers,"response-label":r.responseLabel,"show-identity":!!r.currentConv,"show-back":r.canBack,"show-close":!r.isEmbedded,"more-active":i.moreOpen,"agent-name":r.agentName,"agent-avatar-url":r.agentAvatarUrl,onBack:r.goHome,onMore:r.toggleMore,onClose:r.close},null,8,["title","team-members","response-label","show-identity","show-back","show-close","more-active","agent-name","agent-avatar-url","onBack","onMore","onClose"]),r.error?(p(),y("div",Jm,[u("div",Xm,[t[7]||(t[7]=u("div",{class:"wm-state__errIcon"},[u("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"},[u("path",{d:"M18 6L6 18M6 6l12 12"})])],-1)),u("div",null,[u("div",Qm,O(r.t("error.connectionFailed")),1),u("div",Zm,O(r.error),1)])])])):r.currentConv?(p(),y(Z,{key:2},[_e(f,{ref:"messageList",messages:r.displayedMessages,"streaming-active":r.streamingActive,"date-label":r.dateLabel,"conversation-id":r.currentConv?r.currentConv.id:null,"loading-more":r.paginationState.loading,"has-more":r.paginationState.hasMore,"unread-anchor-id":e.unreadAnchorId,"unread-boundary-ts":e.unreadBoundaryTs,"ai-agent-name":r.agentName,"ai-agent-avatar-url":r.agentAvatarUrl,onLoadMore:r.onLoadMore},null,8,["messages","streaming-active","date-label","conversation-id","loading-more","has-more","unread-anchor-id","unread-boundary-ts","ai-agent-name","ai-agent-avatar-url","onLoadMore"]),u("div",ep,[r.floatVisible?(p(),y("div",tp,[r.approvalReady?(p(),ve(c,{key:0,action:r.approvalTitle,detail:r.approvalDetail,callbacks:r.pendingApproval.callbacks,"agent-name":r.agentName,"agent-avatar-url":r.agentAvatarUrl,onCallback:r.onApprovalCallback},null,8,["action","detail","callbacks","agent-name","agent-avatar-url","onCallback"])):r.pendingForm?(p(),ve(g,{key:r.pendingForm.message&&r.pendingForm.message.id,form:r.pendingForm.form,"agent-name":r.agentName,"agent-avatar-url":r.agentAvatarUrl,onSubmit:r.onFormSubmit},null,8,["form","agent-name","agent-avatar-url","onSubmit"])):r.showFeedback?(p(),ve(A,{key:2,busy:i.feedbackBusy,done:i.feedbackDone,onSubmit:r.onFeedback},null,8,["busy","done","onSubmit"])):(p(),ve(S,{key:3,items:r.suggestions,onSelect:r.onSuggestion},null,8,["items","onSelect"]))],512)):F("",!0),r.actionInFlight?(p(),y("div",np,[t[8]||(t[8]=u("span",{class:"wm-actionWait__spinner","aria-hidden":"true"},null,-1)),u("span",sp,O(r.t("action.inProgress",{name:r.actionInFlightName})),1)])):(p(),ve(K,{key:2,ref:"composer",modelValue:i.draft,"onUpdate:modelValue":t[1]||(t[1]=G=>i.draft=G),placeholder:r.composerPlaceholder,disabled:!!r.pendingApproval,"attach-label":r.t("composer.attachFile"),onSend:r.onSend,onAttach:r.onAttach},null,8,["modelValue","placeholder","disabled","attach-label","onSend","onAttach"]))]),i.moreOpen?(p(),ve(I,{key:0,"can-rename":!!r.currentConv&&!r.currentConv._draft,"can-export":!!r.currentConv&&!r.currentConv._draft,"sound-enabled":e.soundEnabled,"browser-notif-enabled":e.browserNotifEnabled,"status-url":r.statusUrl,"help-url":r.helpUrl,onClose:t[2]||(t[2]=G=>i.moreOpen=!1),onSoundToggle:e.onSoundToggle,onBrowserNotifToggle:e.onBrowserNotifToggle,onAction:r.onMoreAction},null,8,["can-rename","can-export","sound-enabled","browser-notif-enabled","status-url","help-url","onSoundToggle","onBrowserNotifToggle","onAction"])):F("",!0),i.renameDialogOpen&&r.currentConv&&!r.currentConv._draft?(p(),ve(X,{key:1,"initial-value":r.currentConv.name||"",title:r.t("rename.dialogTitle"),onClose:t[3]||(t[3]=G=>i.renameDialogOpen=!1),onSubmit:r.onRenameSubmit},null,8,["initial-value","title","onSubmit"])):F("",!0),i.pendingAttachments.length?(p(),y("div",rp,[(p(!0),y(Z,null,Te(i.pendingAttachments,(G,q)=>(p(),y("div",{key:q,class:"wm-attached__chip"},[t[10]||(t[10]=u("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"},[u("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)),u("span",null,O(G.name),1),u("button",{type:"button","aria-label":r.t("attachment.remove"),onClick:Q=>i.pendingAttachments.splice(q,1)},[...t[9]||(t[9]=[u("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"},[u("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,ip)]))),128))])):F("",!0)],64)):(p(),ve(l,{key:1,"welcome-message":r.widgetWelcomeMessage,subtitle:r.widgetSubtitle,"agent-name":r.agentName,"default-icon-url":r.defaultIconUrl,"quick-links":r.quickLinks,"open-threads":r.openThreads,busy:i.busy,onStart:r.startConv,onSelect:r.onQuickLink,onResume:r.onDrawerPick},null,8,["welcome-message","subtitle","agent-name","default-icon-url","quick-links","open-threads","busy","onStart","onSelect","onResume"])),i.moreOpen&&!r.currentConv?(p(),ve(I,{key:3,"can-rename":!1,"can-export":!1,"sound-enabled":e.soundEnabled,"browser-notif-enabled":e.browserNotifEnabled,"status-url":r.statusUrl,"help-url":r.helpUrl,onClose:t[4]||(t[4]=G=>i.moreOpen=!1),onSoundToggle:e.onSoundToggle,onBrowserNotifToggle:e.onBrowserNotifToggle,onAction:r.onMoreAction},null,8,["sound-enabled","browser-notif-enabled","status-url","help-url","onSoundToggle","onBrowserNotifToggle","onAction"])):F("",!0)],64))],6)):F("",!0)],2)}const ap=be(zm,[["render",op],["__scopeId","data-v-0bf94dbd"]]),lp="0.4.10";let Ct=null,Nt=null,Js="";function cp(e){if(e instanceof Element)return e;if(typeof e=="string"){const n=document.querySelector(e);if(n)return n}const t=document.createElement("div");return t.setAttribute("data-messenger-root",""),document.body.appendChild(t),t}function up(e){return{baseUrl:String(e.baseUrl||mo).trim(),widgetId:String(e.widgetId||"").trim(),userId:String(e.userId||"").trim(),userHash:String(e.userHash||"").trim(),displayMode:e.displayMode||"floating",devtools:!!e.devtools,language:String(e.language||"").trim(),target:e.target||null,context:e.context&&typeof e.context=="object"?e.context:null}}function dp(e={}){const t=up(e);if(!t.baseUrl||!t.widgetId||!t.userId||!t.userHash)return Xs(),null;const n=JSON.stringify({...t,target:typeof t.target=="string"?t.target:!!t.target});return Ct&&n===Js||(Xs(),Nt=cp(t.target),Ct=uc(ap,{baseUrl:t.baseUrl,widgetId:t.widgetId,userId:t.userId,userHash:t.userHash,displayMode:t.displayMode,devtools:t.devtools,language:t.language,context:t.context}),Ct.mount(Nt),Js=n),Ct}function Xs(){if(Ct){try{Ct.unmount()}catch{}Ct=null}Nt&&Nt.hasAttribute&&Nt.hasAttribute("data-messenger-root")&&Nt.remove(),Nt=null,Js=""}return zt.destroy=Xs,zt.init=dp,zt.version=lp,Object.defineProperty(zt,Symbol.toStringTag,{value:"Module"}),zt}({});
package/dist/messenger.js CHANGED
@@ -6005,7 +6005,7 @@ function Pa(e, t, n, i, r, s) {
6005
6005
  ], 6)) : b("", !0)
6006
6006
  ], 2);
6007
6007
  }
6008
- const za = /* @__PURE__ */ B(Ma, [["render", Pa], ["__scopeId", "data-v-0bf94dbd"]]), qa = "0.4.9";
6008
+ const za = /* @__PURE__ */ B(Ma, [["render", Pa], ["__scopeId", "data-v-0bf94dbd"]]), qa = "0.4.10";
6009
6009
  export {
6010
6010
  le as AIAvatar,
6011
6011
  fe as AVATAR_COLORS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@_solaris/messenger-widget",
3
- "version": "0.4.9",
3
+ "version": "0.4.10",
4
4
  "description": "Embeddable chat messenger widget — Vue 3 library + standalone embed build. Wired to the messenger-server (HMAC + widgetId).",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",