@ihoomanai/chat-widget 2.5.6 → 2.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- const e={serverUrl:"https://api.ihooman.ai",theme:"light",position:"bottom-right",title:"Chat Support",subtitle:"We typically reply within minutes",welcomeMessage:"Hi there! 👋 How can we help you today?",placeholder:"Type a message...",primaryColor:"#00aeff",gradientFrom:"#00aeff",gradientTo:"#0066ff",showTimestamps:!0,showTypingIndicator:!0,enableSounds:!0,enableFileUpload:!0,startOpen:!1,persistSession:!0,zIndex:9999,width:380,height:560,buttonSize:60,borderRadius:16,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',avatarUrl:"",poweredBy:!0},t='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>',o='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>',n='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="22" y1="2" x2="11" y2="13"></line><polygon points="22 2 15 22 11 13 2 9 22 2"></polygon></svg>',i='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"></path></svg>',a='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="5" y1="12" x2="19" y2="12"></line></svg>',s='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="11" width="18" height="10" rx="2"></rect><circle cx="12" cy="5" r="2"></circle><path d="M12 7v4"></path></svg>',r='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg>',d='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><line x1="10" y1="9" x2="8" y2="9"></line></svg>',l='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>',c='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>';let p={widgetId:"",...e},m={isOpen:!1,isConnected:!1,messages:[],sessionId:null,visitorId:null,unreadCount:0},h="chat",g=!1,u={};const b={};let f=null,x=null,y=0;let w=!1;function v(e=""){return e+Math.random().toString(36).slice(2,14)+Date.now().toString(36)}function V(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}function k(e,t){const o="ihooman_chat_"+e;try{if(void 0===t){const e=localStorage.getItem(o);return e?JSON.parse(e):null}return null===t?(localStorage.removeItem(o),null):(localStorage.setItem(o,JSON.stringify(t)),t)}catch{return null}}function A(e,t){(b[e]||[]).forEach(o=>{try{o(t)}catch(t){console.error(`Error in ${e} event handler:`,t)}});const o=`on${e.charAt(0).toUpperCase()}${e.slice(1)}`,n=p[o];if("function"==typeof n)try{n(t)}catch(e){console.error(`Error in ${o} callback:`,e)}}function $(){const e=document.createElement("style");e.id="ihooman-widget-styles",e.textContent=function(){const{primaryColor:e,gradientFrom:t,gradientTo:o,fontFamily:n,borderRadius:i,zIndex:a,width:s,height:r,buttonSize:d}=p,l="dark"===p.theme,c=l?"#1a1a2e":"#ffffff",m=l?"#e4e4e7":"#1f2937",h=l?"#71717a":"#6b7280",g=l?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.08)",u=l?"#16162a":"#f9fafb",b=`linear-gradient(135deg, ${t}, ${o})`,f=l?"#252542":"#f1f5f9",x=p.position?.includes("right")??!0,y=p.position?.includes("bottom")??!0;return`\n .ihooman-widget * { box-sizing: border-box; margin: 0; padding: 0; }\n .ihooman-widget { font-family: ${n}; font-size: 14px; line-height: 1.5; color: ${m}; -webkit-font-smoothing: antialiased; }\n .ihooman-widget button { border-radius: 8px; }\n .ihooman-toggle { position: fixed; ${x?"right: 20px":"left: 20px"}; ${y?"bottom: 20px":"top: 20px"}; width: ${d}px; height: ${d}px; border-radius: 50% !important; background: linear-gradient(135deg, ${t}, ${o}); border: none; cursor: pointer; z-index: ${a}; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 20px rgba(0, 174, 255, 0.35); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); overflow: hidden; }\n .ihooman-toggle:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(0, 174, 255, 0.45); }\n .ihooman-toggle:active { transform: scale(0.95); }\n .ihooman-toggle::before { content: ''; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(255,255,255,0.2), transparent); border-radius: 50%; }\n .ihooman-toggle svg { width: 26px; height: 26px; color: white; transition: transform 0.3s ease, opacity 0.2s ease; position: relative; z-index: 1; }\n .ihooman-toggle .chat-icon { display: flex; align-items: center; justify-content: center; transition: transform 0.3s ease, opacity 0.2s ease; }\n .ihooman-toggle .close-icon { position: absolute; display: flex; align-items: center; justify-content: center; transform: rotate(-90deg) scale(0); opacity: 0; transition: transform 0.3s ease, opacity 0.2s ease; }\n .ihooman-toggle.open .chat-icon { transform: rotate(90deg) scale(0); opacity: 0; }\n .ihooman-toggle.open .close-icon { transform: rotate(0) scale(1); opacity: 1; }\n .ihooman-pulse { position: absolute; inset: 0; border-radius: 50%; background: ${e}; animation: ihooman-pulse 2s ease-out infinite; }\n @keyframes ihooman-pulse { 0% { transform: scale(1); opacity: 0.5; } 100% { transform: scale(1.6); opacity: 0; } }\n .ihooman-toggle.open .ihooman-pulse { display: none; }\n .ihooman-badge { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 6px; background: #ef4444; color: white; font-size: 11px; font-weight: 600; border-radius: 10px; display: flex; align-items: center; justify-content: center; z-index: 2; }\n .ihooman-badge:empty { display: none; }\n .ihooman-window { position: fixed; ${x?"right: 20px":"left: 20px"}; ${y?"bottom: 90px":"top: 90px"}; width: ${s}px; height: ${r}px; max-height: calc(100vh - 120px); z-index: ${(a??9999)-1}; display: flex; flex-direction: column; opacity: 0; visibility: hidden; transform: translateY(20px) scale(0.95); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); overscroll-behavior: contain; }\n .ihooman-window.open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }\n .ihooman-container { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; border-radius: ${i}px; overflow: hidden; }\n .ihooman-container::before { content: ''; position: absolute; inset: 0; background: ${c}; opacity: 0.97; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-radius: ${i}px; border: 1px solid ${g}; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }\n .ihooman-container > * { position: relative; z-index: 1; }\n .ihooman-header { padding: 16px 20px; background: linear-gradient(135deg, ${t}, ${o}); color: white; display: flex; align-items: center; gap: 12px; flex-shrink: 0; }\n .ihooman-header-avatar { width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }\n .ihooman-header-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }\n .ihooman-header-avatar svg { width: 22px; height: 22px; }\n .ihooman-header-info { flex: 1; min-width: 0; }\n .ihooman-header-title { font-size: 16px; font-weight: 600; margin-bottom: 2px; }\n .ihooman-header-status { display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: 0.9; }\n .ihooman-status-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; }\n .ihooman-status-dot.offline { background: #f59e0b; }\n .ihooman-header-actions { display: flex; gap: 8px; }\n .ihooman-header-btn { width: 32px; height: 32px; border-radius: 8px !important; background: rgba(255,255,255,0.15); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; color: white; transition: background 0.2s; }\n .ihooman-header-btn:hover { background: rgba(255,255,255,0.25); }\n .ihooman-header-btn svg { width: 16px; height: 16px; }\n .ihooman-messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: ${c}; overscroll-behavior: contain; min-height: 0; }\n .ihooman-messages::-webkit-scrollbar { width: 6px; }\n .ihooman-messages::-webkit-scrollbar-track { background: transparent; }\n .ihooman-messages::-webkit-scrollbar-thumb { background: ${g}; border-radius: 3px; }\n .ihooman-message { display: flex; flex-direction: column; max-width: 85%; animation: ihooman-fadeIn 0.3s ease; }\n @keyframes ihooman-fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }\n .ihooman-message.user { align-self: flex-end; align-items: flex-end; }\n .ihooman-message.bot { align-self: flex-start; align-items: flex-start; }\n .ihooman-message-content { padding: 12px 16px; border-radius: 16px; word-wrap: break-word; }\n .ihooman-message.user .ihooman-message-content { background: ${b}; color: white; border-bottom-right-radius: 4px; }\n .ihooman-message.bot .ihooman-message-content { background: ${f}; color: ${m}; border-bottom-left-radius: 4px; }\n .ihooman-message-content code { background: rgba(0,0,0,0.1); padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: 13px; }\n .ihooman-message-time { font-size: 11px; color: ${h}; margin-top: 4px; padding: 0 4px; }\n .ihooman-typing { display: flex; align-items: center; gap: 8px; padding: 12px 16px; background: ${f}; border-radius: 16px; border-bottom-left-radius: 4px; max-width: 80px; align-self: flex-start; }\n .ihooman-typing-dots { display: flex; gap: 4px; }\n .ihooman-typing-dot { width: 8px; height: 8px; background: ${h}; border-radius: 50%; animation: ihooman-typing 1.4s infinite; }\n .ihooman-typing-dot:nth-child(2) { animation-delay: 0.2s; }\n .ihooman-typing-dot:nth-child(3) { animation-delay: 0.4s; }\n @keyframes ihooman-typing { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-4px); opacity: 1; } }\n .ihooman-input-area { padding: 12px 16px; background: ${c}; border-top: 1px solid ${g}; flex-shrink: 0; }\n .ihooman-input-wrapper { display: flex; align-items: flex-end; gap: 8px; background: ${u}; border: 1px solid ${g}; border-radius: 12px; padding: 8px 12px; transition: border-color 0.2s, box-shadow 0.2s; }\n .ihooman-input-wrapper:focus-within { border-color: ${e}; box-shadow: 0 0 0 3px rgba(0, 174, 255, 0.1); }\n .ihooman-input { flex: 1; border: none; background: transparent; font-family: inherit; font-size: 14px; color: ${m}; resize: none; max-height: 100px; outline: none; line-height: 1.4; }\n .ihooman-input::placeholder { color: ${h}; }\n .ihooman-input-btn { width: 36px; height: 36px; border-radius: 10px; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; background: transparent; color: ${h}; }\n .ihooman-input-btn:hover { background: ${g}; color: ${m}; }\n .ihooman-input-btn.send { background: linear-gradient(135deg, ${t}, ${o}); color: white; }\n .ihooman-input-btn.send:hover { transform: scale(1.05); box-shadow: 0 4px 12px rgba(0, 174, 255, 0.3); }\n .ihooman-input-btn.send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }\n .ihooman-input-btn svg { width: 18px; height: 18px; }\n .ihooman-file-input { display: none; }\n .ihooman-powered { text-align: center; padding: 8px; font-size: 11px; color: ${h}; background: ${c}; }\n .ihooman-powered a { color: ${e}; text-decoration: none; }\n .ihooman-error { padding: 16px; text-align: center; color: #ef4444; background: ${c}; }\n .ihooman-escalation-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }\n .ihooman-widget .ihooman-escalation-btn { display: inline-flex !important; align-items: center !important; gap: 8px !important; padding: 10px 18px !important; border-radius: 8px !important; border: none !important; cursor: pointer !important; font-family: inherit !important; font-size: 13px !important; font-weight: 500 !important; transition: all 0.2s ease !important; width: auto !important; height: auto !important; min-width: 120px !important; }\n .ihooman-widget .ihooman-escalation-btn svg { width: 16px !important; height: 16px !important; flex-shrink: 0 !important; }\n .ihooman-widget .ihooman-escalation-btn.primary { background: linear-gradient(135deg, ${t}, ${o}) !important; color: white !important; }\n .ihooman-widget .ihooman-escalation-btn.primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 174, 255, 0.3); }\n .ihooman-widget .ihooman-escalation-btn.secondary { background: ${l?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.05)"} !important; color: ${m} !important; border: 1px solid ${g} !important; }\n .ihooman-widget .ihooman-escalation-btn.secondary:hover { background: ${l?"rgba(255,255,255,0.15)":"rgba(0,0,0,0.08)"} !important; }\n .ihooman-widget .ihooman-escalation-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }\n .ihooman-status-bar { padding: 10px 16px; text-align: center; font-size: 13px; display: none; }\n .ihooman-status-bar.show { display: block; }\n .ihooman-status-bar.waiting { background: #fef3c7; color: #92400e; }\n .ihooman-status-bar.connected { background: #dcfce7; color: #166534; }\n .ihooman-chat-view { display: flex; flex-direction: column; flex: 1; overflow: hidden; min-height: 0; }\n .ihooman-chat-view.hidden { display: none; }\n .ihooman-ticket-view { display: none; flex-direction: column; padding: 20px; gap: 16px; background: ${c}; flex: 1; overflow-y: auto; min-height: 0; }\n .ihooman-ticket-view.show { display: flex; }\n .ihooman-ticket-title { font-size: 18px; font-weight: 600; color: ${m}; margin: 0; display: flex; align-items: center; gap: 8px; }\n .ihooman-ticket-subtitle { font-size: 13px; color: ${h}; margin: 0; }\n .ihooman-ticket-input { padding: 12px 14px; border: 1px solid ${g}; border-radius: 10px; font-size: 14px; font-family: inherit; background: ${u}; color: ${m}; outline: none; transition: border-color 0.2s; }\n .ihooman-ticket-input:focus { border-color: ${e}; }\n .ihooman-ticket-input::placeholder { color: ${h}; }\n .ihooman-ticket-textarea { min-height: 100px; resize: vertical; }\n .ihooman-ticket-submit { padding: 14px; background: linear-gradient(135deg, ${t}, ${o}); color: white; border: none; border-radius: 10px; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.2s; }\n .ihooman-ticket-submit:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 174, 255, 0.3); }\n .ihooman-ticket-submit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }\n .ihooman-ticket-back { padding: 10px; background: transparent; color: ${h}; border: 1px solid ${g}; border-radius: 10px; font-size: 13px; cursor: pointer; transition: all 0.2s; }\n .ihooman-ticket-back:hover { background: ${l?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.03)"}; }\n .ihooman-history-view { display: none; flex-direction: column; flex: 1; overflow: hidden; background: ${c}; }\n .ihooman-history-view.show { display: flex; }\n .ihooman-history-header { padding: 12px 16px; border-bottom: 1px solid ${g}; display: flex; justify-content: space-between; align-items: center; }\n .ihooman-history-title { font-size: 14px; font-weight: 600; color: ${m}; margin: 0; }\n .ihooman-history-new { display: inline-flex; align-items: center; gap: 4px; background: linear-gradient(135deg, ${t}, ${o}); color: white; border: none; padding: 8px 16px; border-radius: 8px !important; font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.2s; }\n .ihooman-history-new:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0, 174, 255, 0.3); }\n .ihooman-history-new svg { width: 14px; height: 14px; flex-shrink: 0; }\n .ihooman-history-list { flex: 1; overflow-y: auto; padding: 8px; overscroll-behavior: contain; }\n .ihooman-history-item { padding: 12px; border: 1px solid ${g}; border-radius: 8px; margin-bottom: 6px; cursor: pointer; transition: all 0.2s; background: ${c}; }\n .ihooman-history-item:hover { background: ${l?"rgba(255,255,255,0.05)":"#f8fafc"}; }\n .ihooman-history-item.active { background: ${l?"rgba(0, 174, 255, 0.1)":"#eff6ff"}; border-color: ${e}; }\n .ihooman-history-preview { font-size: 13px; color: ${m}; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n .ihooman-history-meta { font-size: 11px; color: ${h}; margin-top: 4px; display: flex; justify-content: space-between; }\n .ihooman-history-empty { padding: 40px; text-align: center; color: ${h}; font-size: 14px; }\n @media (max-width: 480px) { .ihooman-window { width: calc(100vw - 20px); height: calc(100vh - 100px); left: 10px; right: 10px; bottom: 80px; max-height: none; } .ihooman-toggle { ${x?"right: 16px":"left: 16px"}; bottom: 16px; } }\n `}(),document.head.appendChild(e);const r=document.createElement("div");r.className="ihooman-widget",r.innerHTML=`\n <button class="ihooman-toggle" aria-label="Open chat">\n <span class="ihooman-pulse"></span>\n <span class="ihooman-badge"></span>\n <span class="chat-icon">${t}</span>\n <span class="close-icon">${o}</span>\n </button>\n <div class="ihooman-window" role="dialog" aria-label="Chat window">\n <div class="ihooman-container">\n <div class="ihooman-header">\n <div class="ihooman-header-avatar">${p.avatarUrl?`<img src="${V(p.avatarUrl)}" alt="Support">`:s}</div>\n <div class="ihooman-header-info">\n <div class="ihooman-header-title">${V(p.title||"Chat Support")}</div>\n <div class="ihooman-header-status"><span class="ihooman-status-dot"></span><span class="ihooman-status-text">Online</span></div>\n </div>\n <div class="ihooman-header-actions">\n <button class="ihooman-header-btn" data-action="history" title="Chat history">${l}</button>\n <button class="ihooman-header-btn" data-action="refresh" title="New conversation">${c}</button>\n <button class="ihooman-header-btn" data-action="minimize" title="Minimize">${a}</button>\n </div>\n </div>\n \n \x3c!-- Chat View --\x3e\n <div class="ihooman-chat-view">\n <div class="ihooman-status-bar"></div>\n <div class="ihooman-messages" role="log" aria-live="polite"></div>\n <div class="ihooman-input-area">\n <div class="ihooman-input-wrapper">\n ${p.enableFileUpload?`<button class="ihooman-input-btn attach" title="Attach file">${i}</button><input type="file" class="ihooman-file-input">`:""}\n <textarea class="ihooman-input" placeholder="${V(p.placeholder||"Type a message...")}" rows="1" aria-label="Message input"></textarea>\n <button class="ihooman-input-btn send" title="Send message" disabled>${n}</button>\n </div>\n </div>\n </div>\n \n \x3c!-- Ticket Form View --\x3e\n <div class="ihooman-ticket-view">\n <h4 class="ihooman-ticket-title">📝 Submit a Ticket</h4>\n <p class="ihooman-ticket-subtitle">We'll get back to you via email</p>\n <input class="ihooman-ticket-input" id="ihooman-ticket-name" placeholder="Your name" required>\n <input class="ihooman-ticket-input" id="ihooman-ticket-email" type="email" placeholder="Your email" required>\n <textarea class="ihooman-ticket-input ihooman-ticket-textarea" id="ihooman-ticket-issue" placeholder="Describe your issue..."></textarea>\n <button class="ihooman-ticket-submit" id="ihooman-ticket-submit">Submit Ticket</button>\n <button class="ihooman-ticket-back" id="ihooman-ticket-back">← Back to Chat</button>\n </div>\n \n \x3c!-- History View --\x3e\n <div class="ihooman-history-view">\n <div class="ihooman-history-header">\n <span class="ihooman-history-title">Your Conversations</span>\n <button class="ihooman-history-new" style="all: revert; display: inline-flex !important; align-items: center !important; gap: 4px !important; background: linear-gradient(135deg, ${p.gradientFrom}, ${p.gradientTo}) !important; color: white !important; border: none !important; padding: 6px 10px !important; border-radius: 6px !important; font-size: 12px !important; font-weight: 500 !important; cursor: pointer !important; width: auto !important; height: auto !important; min-width: 0 !important; aspect-ratio: auto !important;">${c} New Chat</button>\n </div>\n <div class="ihooman-history-list"></div>\n </div>\n \n ${p.poweredBy?'<div class="ihooman-powered">Powered by <a href="https://ihooman.ai" target="_blank" rel="noopener">Ihooman AI</a></div>':""}\n </div>\n </div>\n `,document.body.appendChild(r),u={widget:r,toggle:r.querySelector(".ihooman-toggle"),badge:r.querySelector(".ihooman-badge"),window:r.querySelector(".ihooman-window"),chatView:r.querySelector(".ihooman-chat-view"),ticketView:r.querySelector(".ihooman-ticket-view"),historyView:r.querySelector(".ihooman-history-view"),historyList:r.querySelector(".ihooman-history-list"),historyNewBtn:r.querySelector(".ihooman-history-new"),messages:r.querySelector(".ihooman-messages"),input:r.querySelector(".ihooman-input"),sendBtn:r.querySelector(".ihooman-input-btn.send"),attachBtn:r.querySelector(".ihooman-input-btn.attach"),fileInput:r.querySelector(".ihooman-file-input"),statusDot:r.querySelector(".ihooman-status-dot"),statusText:r.querySelector(".ihooman-status-text"),statusBar:r.querySelector(".ihooman-status-bar"),ticketName:r.querySelector("#ihooman-ticket-name"),ticketEmail:r.querySelector("#ihooman-ticket-email"),ticketIssue:r.querySelector("#ihooman-ticket-issue"),ticketSubmitBtn:r.querySelector("#ihooman-ticket-submit"),ticketBackBtn:r.querySelector("#ihooman-ticket-back")},function(){if(!u.toggle||!u.sendBtn||!u.input)return;u.toggle.addEventListener("click",Y),u.sendBtn.addEventListener("click",U),u.input.addEventListener("input",()=>{u.sendBtn&&(u.sendBtn.disabled=!u.input?.value.trim()),u.input&&(u.input.style.height="auto",u.input.style.height=Math.min(u.input.scrollHeight,100)+"px")}),u.input.addEventListener("keydown",e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),u.sendBtn?.disabled||U())}),u.attachBtn&&u.fileInput&&(u.attachBtn.addEventListener("click",()=>u.fileInput?.click()),u.fileInput.addEventListener("change",O));u.widget?.querySelector('[data-action="refresh"]')?.addEventListener("click",R),u.widget?.querySelector('[data-action="minimize"]')?.addEventListener("click",D),u.widget?.querySelector('[data-action="history"]')?.addEventListener("click",C),u.ticketSubmitBtn&&u.ticketSubmitBtn.addEventListener("click",B);u.ticketBackBtn&&u.ticketBackBtn.addEventListener("click",()=>I("chat"));u.historyNewBtn&&u.historyNewBtn.addEventListener("click",()=>{R(),I("chat")})}()}function S(e,t="bot",o={}){const n={id:v("msg_"),content:e,sender:t,timestamp:new Date,metadata:o};if(m.messages.push(n),!u.messages)return n;const i=document.createElement("div");i.className=`ihooman-message ${t}`;const a="bot"===t&&!0===o?.escalation_offered;let s="";if(a){const e="all: revert; display: inline-flex !important; align-items: center !important; justify-content: center !important; gap: 6px !important; padding: 8px 12px !important; border-radius: 6px !important; border: none !important; cursor: pointer !important; font-size: 12px !important; font-weight: 500 !important; line-height: 1.2 !important; width: auto !important; height: auto !important; min-width: 0 !important; min-height: 0 !important; max-width: none !important; max-height: none !important; aspect-ratio: auto !important; box-sizing: border-box !important;";s=`\n <div class="ihooman-escalation-actions" style="display: flex !important; gap: 8px !important; margin-top: 10px !important; flex-wrap: wrap !important;">\n <button class="ihooman-escalation-btn primary" data-action="live-agent" style="${`${e} background: linear-gradient(135deg, ${p.gradientFrom}, ${p.gradientTo}) !important; color: white !important;`}">\n ${r}\n <span>Talk to Agent</span>\n </button>\n <button class="ihooman-escalation-btn secondary" data-action="create-ticket" style="${`${e} background: rgba(0,0,0,0.05) !important; color: inherit !important; border: 1px solid rgba(0,0,0,0.1) !important;`}">\n ${d}\n <span>Create Ticket</span>\n </button>\n </div>\n `}var l,c;if(i.innerHTML=`\n <div class="ihooman-message-content">${c=e,c?V(c).replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/`(.*?)`/g,"<code>$1</code>").replace(/\n/g,"<br>"):""}</div>\n ${s}\n ${p.showTimestamps?`<div class="ihooman-message-time">${l=n.timestamp,new Date(l).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}</div>`:""}\n `,a){const e=i.querySelector('[data-action="live-agent"]'),t=i.querySelector('[data-action="create-ticket"]');e&&e.addEventListener("click",()=>_("live-agent")),t&&t.addEventListener("click",()=>_("create-ticket"))}const h=u.messages.querySelector(".ihooman-typing");return h&&h.remove(),u.messages.appendChild(i),u.messages.scrollTop=u.messages.scrollHeight,"bot"!==t||m.isOpen||(m.unreadCount++,u.badge&&(u.badge.textContent=String(m.unreadCount)),p.enableSounds&&function(){try{const e=new Audio("data:audio/mp3;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4Ljc2LjEwMAAAAAAAAAAAAAAA//tQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWGluZwAAAA8AAAACAAABhgC7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7//////////////////////////////////////////////////////////////////8AAAAATGF2YzU4LjEzAAAAAAAAAAAAAAAAJAAAAAAAAAAAAYYNBrP/AAAAAAAAAAAAAAAAAAAAAP/7UMQAA8AAAaQAAAAgAAA0gAAABExBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tQxBKDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVU=");e.volume=.3,e.play().catch(()=>{})}catch{}}()),A("message",n),n}function _(e){document.querySelectorAll(".ihooman-escalation-btn").forEach(e=>e.disabled=!0),"live-agent"===e?async function(){if(!m.sessionId)return void S("Please send a message first to start a conversation.","bot",{is_system_message:!0});const e=u.widget?.querySelector('[data-action="live-agent"]');e&&(e.disabled=!0,e.innerHTML='<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg> Connecting...');try{const e=await fetch(`${p.serverUrl}/api/widget/live-agent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({widget_id:p.widgetId,session_id:m.sessionId,visitor_id:m.visitorId})}),t=await e.json();g=!0,t.position_in_queue&&t.position_in_queue>1?T("waiting",`⏳ Waiting for agent (Position: #${t.position_in_queue})`):T("waiting","⏳ Connecting to live support..."),E()}catch(e){console.error("Error requesting live agent:",e),S("❌ Unable to connect to live support. Please try again.","bot",{is_system_message:!0})}e&&(e.disabled=!1,e.innerHTML='<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg> Live Agent')}():"create-ticket"===e&&(I("ticket"),setTimeout(()=>u.ticketName?.focus(),100))}function I(e){h=e,u.chatView&&u.chatView.classList.toggle("hidden","chat"!==e),u.ticketView&&u.ticketView.classList.toggle("show","ticket"===e),u.historyView&&u.historyView.classList.toggle("show","history"===e),"history"===e&&async function(){if(!u.historyList||!m.visitorId)return;u.historyList.innerHTML='<div class="ihooman-history-empty">Loading...</div>';try{const e=await fetch(`${p.serverUrl}/api/widget/conversations?widget_id=${p.widgetId}&visitor_id=${m.visitorId}&limit=20`);if(!e.ok)throw new Error("Failed to load history");const t=await e.json();if(!t.length)return void(u.historyList.innerHTML='<div class="ihooman-history-empty">No conversations yet</div>');u.historyList.innerHTML=t.map(e=>`\n <div class="ihooman-history-item ${e.session_id===m.sessionId?"active":""}" data-session-id="${e.session_id}">\n <div class="ihooman-history-preview">${V(e.preview||"New conversation")}</div>\n <div class="ihooman-history-meta">\n <span>${e.message_count} msgs</span>\n <span>${"pending"===e.status?"🟡 Pending":"closed"===e.status?"✓ Closed":""} ${function(e){const t=Date.now()-new Date(e).getTime();return t<6e4?"now":t<36e5?Math.floor(t/6e4)+"m":t<864e5?Math.floor(t/36e5)+"h":Math.floor(t/864e5)+"d"}(e.updated_at)}</span>\n </div>\n </div>\n `).join(""),u.historyList.querySelectorAll(".ihooman-history-item").forEach(e=>{e.addEventListener("click",()=>{const t=e.dataset.sessionId;t&&async function(e){m.sessionId=e,p.persistSession&&k("session_id",e);u.messages&&(u.messages.innerHTML="");g=!1,z(),T("hidden"),w=!0,f&&(f.close(),f=null);j(),I("chat"),await async function(e){try{const t=await fetch(`${p.serverUrl}/api/widget/transcript/${e}?widget_id=${p.widgetId}`);if(!t.ok)throw new Error("Failed to load messages");const o=await t.json();u.messages&&(u.messages.innerHTML=""),o.messages&&o.messages.length>0?o.messages.forEach(e=>{const t="user"===e.sender_type?"user":"bot";S(e.content,t,e.extra_data||{})}):p.welcomeMessage&&S(p.welcomeMessage,"bot"),"pending"===o.status?(g=!0,E(),T("waiting","⏳ Waiting for agent...")):"closed"===o.status&&T("hidden")}catch(e){console.error("Error loading conversation messages:",e),p.welcomeMessage&&S(p.welcomeMessage,"bot")}}(e)}(t)})})}catch(e){console.error("Error loading conversation history:",e),u.historyList.innerHTML='<div class="ihooman-history-empty">Failed to load history</div>'}}()}function C(){I("history"===h?"chat":"history")}function T(e,t){u.statusBar&&("hidden"!==e?(u.statusBar.classList.add("show"),u.statusBar.classList.remove("waiting","connected"),u.statusBar.classList.add(e),t&&(u.statusBar.textContent=t)):u.statusBar.classList.remove("show"))}async function B(){const e=u.ticketName?.value.trim(),t=u.ticketEmail?.value.trim(),o=u.ticketIssue?.value.trim();if(e&&t){u.ticketSubmitBtn&&(u.ticketSubmitBtn.disabled=!0,u.ticketSubmitBtn.textContent="Submitting...");try{const n=await fetch(`${p.serverUrl}/api/widget/submit-ticket`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({widget_id:p.widgetId,session_id:m.sessionId,user_name:e,user_email:t,issue:o||"No description provided"})}),i=await n.json();u.ticketName&&(u.ticketName.value=""),u.ticketEmail&&(u.ticketEmail.value=""),u.ticketIssue&&(u.ticketIssue.value=""),I("chat");S(`✅ Ticket submitted! We'll contact you at ${t}. Reference: #${i.ticket_id?i.ticket_id.slice(0,8):"submitted"}`,"bot",{is_system_message:!0})}catch(e){console.error("Error submitting ticket:",e),S("❌ Error submitting ticket. Please try again.","bot",{is_system_message:!0})}u.ticketSubmitBtn&&(u.ticketSubmitBtn.disabled=!1,u.ticketSubmitBtn.textContent="Submit Ticket")}else alert("Please fill in your name and email")}let L=null;function E(){L||(L=setInterval(async()=>{if(m.sessionId&&g)try{try{const e=await fetch(`${p.serverUrl}/api/widget/escalation-status/${m.sessionId}?widget_id=${p.widgetId}`);if(e.ok){const t=await e.json();t.escalated&&("in_progress"===t.ticket_status?T("connected","🟢 Connected to live agent"):"open"===t.ticket_status?t.position_in_queue&&t.position_in_queue>1?T("waiting",`⏳ Waiting for agent (Position: #${t.position_in_queue})`):T("waiting","⏳ Waiting for agent..."):"closed"!==t.ticket_status&&"resolved"!==t.ticket_status||(g=!1,z(),T("hidden"),S("This conversation has been closed. Thank you for contacting us!","bot",{is_system_message:!0})))}}catch{}}catch(e){console.error("Error polling for messages:",e)}else z()},3e3))}function z(){L&&(clearInterval(L),L=null)}function M(){if(!p.showTypingIndicator||!u.messages)return;if(u.messages.querySelector(".ihooman-typing"))return;const e=document.createElement("div");e.className="ihooman-typing",e.innerHTML='<div class="ihooman-typing-dots"><span class="ihooman-typing-dot"></span><span class="ihooman-typing-dot"></span><span class="ihooman-typing-dot"></span></div>',u.messages.appendChild(e),u.messages.scrollTop=u.messages.scrollHeight}function q(){const e=u.messages?.querySelector(".ihooman-typing");e&&e.remove()}function U(){const e=u.input?.value.trim();e&&(u.input&&(u.input.value="",u.input.style.height="auto"),u.sendBtn&&(u.sendBtn.disabled=!0),S(e,"user"),M(),async function(e){if(f&&f.readyState===WebSocket.OPEN)return void f.send(JSON.stringify({type:"message",content:e}));try{const t=await fetch(`${p.serverUrl}/api/v1/public/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:e,session_id:m.sessionId,visitor_id:m.visitorId,widget_id:p.widgetId})}),o=await t.json();q(),o.session_id&&(m.sessionId=o.session_id,p.persistSession&&k("session_id",m.sessionId)),o.response&&S(o.response,"bot",{sources:o.sources,confidence:o.confidence})}catch(e){q(),S("Sorry, something went wrong. Please try again.","bot"),A("error",e)}}(e))}function O(e){const t=e.target,o=t.files?.[0];if(!o)return;S(`📎 Uploading: ${o.name}...`,"user"),M();const n=new FormData;n.append("file",o),n.append("session_id",m.sessionId||""),n.append("visitor_id",m.visitorId||""),n.append("widget_id",p.widgetId),fetch(`${p.serverUrl}/api/upload`,{method:"POST",body:n}).then(e=>e.json()).then(e=>{q(),e.message&&S(e.message,"bot")}).catch(()=>{q(),S("Failed to upload file.","bot")}),t.value=""}function j(e){if(!p.serverUrl&&!e)return;let t;if(p.widgetId){const e=p.serverUrl?.replace(/^http/,"ws"),o=new URLSearchParams({widget_id:p.widgetId});m.visitorId&&o.append("visitor_id",m.visitorId),m.sessionId&&o.append("session_id",m.sessionId),t=`${e}/public/ws?${o.toString()}`}else t=e||p.serverUrl?.replace(/^http/,"ws")+"/ws";try{N(),f=new WebSocket(t),f.onopen=()=>{m.isConnected=!0,y=0,P(!0),A("connected"),N(),F=setInterval(()=>{if(f&&f.readyState===WebSocket.OPEN)try{f.send(JSON.stringify({type:"ping"}))}catch(e){console.warn("Failed to send heartbeat ping:",e)}},25e3)},f.onclose=t=>{if(m.isConnected=!1,P(!1),N(),A("disconnected"),console.log(`WebSocket closed: code=${t.code}, reason=${t.reason||"none"}, wasClean=${t.wasClean}`),w)w=!1;else if(m.isOpen)if(y<5){y++;const t=Math.min(1e3*Math.pow(2,y),3e4);console.log(`WebSocket reconnecting in ${t}ms (attempt ${y}/5)`),setTimeout(()=>j(e),t)}else console.warn("WebSocket reconnection failed, falling back to polling"),H()},f.onerror=e=>{console.error("WebSocket error:",e)},f.onmessage=e=>{try{const t=JSON.parse(e.data);if("connected"===t.type)t.session_id&&(m.sessionId=t.session_id,p.persistSession&&k("session_id",m.sessionId)),t.visitor_id&&(m.visitorId=t.visitor_id,p.persistSession&&k("visitor_id",m.visitorId)),t.welcome_message&&0===m.messages.length&&S(t.welcome_message,"bot");else if("message"===t.type){q();const e="user"===t.sender?"user":"bot";S(t.content,e,{confidence:t.confidence,agent_name:t.agent_name,escalation_offered:t.escalation_offered,escalated:t.escalated})}else"typing"===t.type?t.is_typing?M():q():"pong"===t.type||"error"===t.type&&(console.error("WebSocket server error:",t.message),A("error",{message:t.message}))}catch{}}}catch{console.warn("WebSocket not supported, using polling"),H()}}let F=null;function N(){F&&(clearInterval(F),F=null)}function H(){x||(x=setInterval(async()=>{if(m.sessionId)try{const e=await fetch(`${p.serverUrl}/api/messages?session_id=${m.sessionId}&since=${Date.now()-5e3}&widget_id=${p.widgetId}`),t=await e.json();t.messages&&t.messages.forEach(e=>{m.messages.find(t=>t.id===e.id)||S(e.content,e.sender_type,e.metadata)})}catch{}},5e3))}function P(e){u.statusDot&&u.statusDot.classList.toggle("offline",!e),u.statusText&&(u.statusText.textContent=e?"Online":"Offline")}function W(){m.isOpen||(m.isOpen=!0,m.unreadCount=0,u.badge&&(u.badge.textContent=""),u.toggle&&u.toggle.classList.add("open"),u.window&&u.window.classList.add("open"),setTimeout(()=>u.input?.focus(),300),A("open"))}function D(){m.isOpen&&(m.isOpen=!1,u.toggle&&u.toggle.classList.remove("open"),u.window&&u.window.classList.remove("open"),A("close"))}function Y(){m.isOpen?D():W()}function R(){m.sessionId=null,m.visitorId=null,m.messages=[],g=!1,k("session_id",null),m.visitorId=v("v_"),k("visitor_id",m.visitorId),u.messages&&(u.messages.innerHTML=""),T("hidden"),z(),y=0,f&&(w=!0,f.close(),f=null),j(),p.welcomeMessage&&S(p.welcomeMessage,"bot"),A("newConversation")}async function J(t){if(!t.widgetId)return console.error("IhoomanChat: widgetId is required"),null;p={...e,...t},m.visitorId=k("visitor_id")||v("v_"),k("visitor_id",m.visitorId),p.persistSession&&(m.sessionId=k("session_id"));const o=p.serverUrl||"https://api.ihooman.ai",n=await async function(e,t){try{const o=await fetch(`${t}/api/widget/config?widget_id=${encodeURIComponent(e)}`);return o.ok?await o.json():{success:!1,error:(await o.json().catch(()=>({}))).error||`HTTP ${o.status}`}}catch(e){return{success:!1,error:"Unable to connect. Please check your internet connection."}}}(p.widgetId,o);let i;var a;return n.success&&n.config?(a=n.config,p.title=a.title||p.title,p.subtitle=a.subtitle||p.subtitle,p.welcomeMessage=a.welcomeMessage||p.welcomeMessage,p.placeholder=a.placeholder||p.placeholder,p.position=a.position||p.position,a.theme&&(p.primaryColor=a.theme.primaryColor||p.primaryColor,p.gradientFrom=a.theme.gradientFrom||p.gradientFrom,p.gradientTo=a.theme.gradientTo||p.gradientTo,p.fontFamily=a.theme.fontFamily||p.fontFamily,a.theme.borderRadius&&(p.borderRadius=parseInt(a.theme.borderRadius,10)||p.borderRadius)),a.behavior&&(p.startOpen=a.behavior.startOpen??p.startOpen,p.showTypingIndicator=a.behavior.showTypingIndicator??p.showTypingIndicator,p.showTimestamps=a.behavior.showTimestamps??p.showTimestamps,p.enableSounds=a.behavior.enableSounds??p.enableSounds,p.enableFileUpload=a.behavior.enableFileUpload??p.enableFileUpload,p.persistSession=a.behavior.persistSession??p.persistSession),a.branding&&(p.avatarUrl=a.branding.avatarUrl||p.avatarUrl,p.poweredBy=a.branding.poweredBy??p.poweredBy),i=n.chatEndpoint):n.error&&(console.warn("IhoomanChat: Could not fetch server config:",n.error),"Widget not authorized for this domain"===n.error&&console.error("IhoomanChat: Widget configuration error. Please contact support.")),$(),m.messages.forEach(e=>S(e.content,e.sender,e.metadata)),0===m.messages.length&&p.welcomeMessage&&S(p.welcomeMessage,"bot"),j(i),p.startOpen&&setTimeout(W,500),A("ready"),Q}const Q={init:J,open:W,close:D,toggle:Y,destroy:function(){N(),z(),w=!0,f&&(f.close(),f=null),x&&(clearInterval(x),x=null),u.widget&&u.widget.remove();const e=document.getElementById("ihooman-widget-styles");e&&e.remove(),m={isOpen:!1,isConnected:!1,messages:[],sessionId:null,visitorId:null,unreadCount:0},u={},y=0,w=!1},sendMessage:function(e){e.trim()&&(u.input&&(u.input.value=e),U())},setUser:function(e){e.name&&k("user_name",e.name),e.email&&k("user_email",e.email),e.metadata&&k("user_metadata",e.metadata)},clearHistory:function(){R()},on:function(e,t){b[e]||(b[e]=[]),b[e].push(t)},off:function(e,t){b[e]&&(b[e]=b[e].filter(e=>e!==t))},getState:function(){return{...m}},version:"2.0.0"},G=Q;function K(){return{...Q}}!function(){if("undefined"==typeof document)return;let e=document.currentScript;if(!e){const t=document.getElementsByTagName("script");for(let o=0;o<t.length;o++)if(t[o].src&&t[o].src.includes("ihooman")){e=t[o];break}}if(!e)return;const t=e.getAttribute("data-widget-id");if(t){const o={widgetId:t},n=e.getAttribute("data-server-url");n&&(o.serverUrl=n);const i=e.getAttribute("data-theme");"light"!==i&&"dark"!==i||(o.theme=i);const a=e.getAttribute("data-position");a&&(o.position=a);"true"===e.getAttribute("data-start-open")&&(o.startOpen=!0),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>J(o)):J(o)}}(),"undefined"!=typeof window&&(window.IhoomanChat=G);export{G as IhoomanChat,K as createWidgetInstance,G as default};
1
+ const e={serverUrl:"https://api.ihooman.ai",theme:"light",position:"bottom-right",title:"Chat Support",subtitle:"We typically reply within minutes",welcomeMessage:"Hi there! 👋 How can we help you today?",placeholder:"Type a message...",primaryColor:"#00aeff",gradientFrom:"#00aeff",gradientTo:"#0066ff",showTimestamps:!0,showTypingIndicator:!0,enableSounds:!0,enableFileUpload:!0,startOpen:!1,persistSession:!0,zIndex:9999,width:380,height:560,buttonSize:60,borderRadius:16,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',avatarUrl:"",poweredBy:!0},t='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>',n='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>',o='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="22" y1="2" x2="11" y2="13"></line><polygon points="22 2 15 22 11 13 2 9 22 2"></polygon></svg>',i='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"></path></svg>',a='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="5" y1="12" x2="19" y2="12"></line></svg>',s='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="11" width="18" height="10" rx="2"></rect><circle cx="12" cy="5" r="2"></circle><path d="M12 7v4"></path></svg>',r='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg>',d='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><line x1="10" y1="9" x2="8" y2="9"></line></svg>',l='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>',c='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>';let p={widgetId:"",...e},m={isOpen:!1,isConnected:!1,messages:[],sessionId:null,visitorId:null,unreadCount:0},h="chat",g=!1,u={};const b={};let f=null,x=null,y=0;let w=!1;function v(e=""){return e+Math.random().toString(36).slice(2,14)+Date.now().toString(36)}function V(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}function k(e,t){const n="ihooman_chat_"+e;try{if(void 0===t){const e=localStorage.getItem(n);return e?JSON.parse(e):null}return null===t?(localStorage.removeItem(n),null):(localStorage.setItem(n,JSON.stringify(t)),t)}catch{return null}}function A(e,t){(b[e]||[]).forEach(n=>{try{n(t)}catch(t){console.error(`Error in ${e} event handler:`,t)}});const n=`on${e.charAt(0).toUpperCase()}${e.slice(1)}`,o=p[n];if("function"==typeof o)try{o(t)}catch(e){console.error(`Error in ${n} callback:`,e)}}function $(){const e=document.createElement("style");e.id="ihooman-widget-styles",e.textContent=function(){const{primaryColor:e,gradientFrom:t,gradientTo:n,fontFamily:o,borderRadius:i,zIndex:a,width:s,height:r,buttonSize:d}=p,l="dark"===p.theme,c=l?"#1a1a2e":"#ffffff",m=l?"#e4e4e7":"#1f2937",h=l?"#71717a":"#6b7280",g=l?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.08)",u=l?"#16162a":"#f9fafb",b=`linear-gradient(135deg, ${t}, ${n})`,f=l?"#252542":"#f1f5f9",x=p.position?.includes("right")??!0,y=p.position?.includes("bottom")??!0;return`\n .ihooman-widget * { box-sizing: border-box; margin: 0; padding: 0; }\n .ihooman-widget { font-family: ${o}; font-size: 14px; line-height: 1.5; color: ${m}; -webkit-font-smoothing: antialiased; }\n .ihooman-widget button { border-radius: 8px; }\n .ihooman-toggle { position: fixed; ${x?"right: 20px":"left: 20px"}; ${y?"bottom: 20px":"top: 20px"}; width: ${d}px; height: ${d}px; border-radius: 50% !important; background: linear-gradient(135deg, ${t}, ${n}); border: none; cursor: pointer; z-index: ${a}; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 20px rgba(0, 174, 255, 0.35); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); overflow: hidden; }\n .ihooman-toggle:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(0, 174, 255, 0.45); }\n .ihooman-toggle:active { transform: scale(0.95); }\n .ihooman-toggle::before { content: ''; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(255,255,255,0.2), transparent); border-radius: 50%; }\n .ihooman-toggle svg { width: 26px; height: 26px; color: white; transition: transform 0.3s ease, opacity 0.2s ease; position: relative; z-index: 1; }\n .ihooman-toggle .chat-icon { display: flex; align-items: center; justify-content: center; transition: transform 0.3s ease, opacity 0.2s ease; }\n .ihooman-toggle .close-icon { position: absolute; display: flex; align-items: center; justify-content: center; transform: rotate(-90deg) scale(0); opacity: 0; transition: transform 0.3s ease, opacity 0.2s ease; }\n .ihooman-toggle.open .chat-icon { transform: rotate(90deg) scale(0); opacity: 0; }\n .ihooman-toggle.open .close-icon { transform: rotate(0) scale(1); opacity: 1; }\n .ihooman-pulse { position: absolute; inset: 0; border-radius: 50%; background: ${e}; animation: ihooman-pulse 2s ease-out infinite; }\n @keyframes ihooman-pulse { 0% { transform: scale(1); opacity: 0.5; } 100% { transform: scale(1.6); opacity: 0; } }\n .ihooman-toggle.open .ihooman-pulse { display: none; }\n .ihooman-badge { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 6px; background: #ef4444; color: white; font-size: 11px; font-weight: 600; border-radius: 10px; display: flex; align-items: center; justify-content: center; z-index: 2; }\n .ihooman-badge:empty { display: none; }\n .ihooman-window { position: fixed; ${x?"right: 20px":"left: 20px"}; ${y?"bottom: 90px":"top: 90px"}; width: ${s}px; height: ${r}px; max-height: calc(100vh - 120px); z-index: ${(a??9999)-1}; display: flex; flex-direction: column; opacity: 0; visibility: hidden; transform: translateY(20px) scale(0.95); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); overscroll-behavior: contain; }\n .ihooman-window.open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }\n .ihooman-container { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; border-radius: ${i}px; overflow: hidden; }\n .ihooman-container::before { content: ''; position: absolute; inset: 0; background: ${c}; opacity: 0.97; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-radius: ${i}px; border: 1px solid ${g}; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }\n .ihooman-container > * { position: relative; z-index: 1; }\n .ihooman-header { padding: 16px 20px; background: linear-gradient(135deg, ${t}, ${n}); color: white; display: flex; align-items: center; gap: 12px; flex-shrink: 0; }\n .ihooman-header-avatar { width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }\n .ihooman-header-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }\n .ihooman-header-avatar svg { width: 22px; height: 22px; }\n .ihooman-header-info { flex: 1; min-width: 0; }\n .ihooman-header-title { font-size: 16px; font-weight: 600; margin-bottom: 2px; }\n .ihooman-header-status { display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: 0.9; }\n .ihooman-status-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; }\n .ihooman-status-dot.offline { background: #f59e0b; }\n .ihooman-header-actions { display: flex; gap: 8px; }\n .ihooman-header-btn { width: 32px; height: 32px; border-radius: 8px !important; background: rgba(255,255,255,0.15); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; color: white; transition: background 0.2s; }\n .ihooman-header-btn:hover { background: rgba(255,255,255,0.25); }\n .ihooman-header-btn svg { width: 16px; height: 16px; }\n .ihooman-messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: ${c}; overscroll-behavior: contain; min-height: 0; }\n .ihooman-messages::-webkit-scrollbar { width: 6px; }\n .ihooman-messages::-webkit-scrollbar-track { background: transparent; }\n .ihooman-messages::-webkit-scrollbar-thumb { background: ${g}; border-radius: 3px; }\n .ihooman-message { display: flex; flex-direction: column; max-width: 85%; animation: ihooman-fadeIn 0.3s ease; }\n @keyframes ihooman-fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }\n .ihooman-message.user { align-self: flex-end; align-items: flex-end; }\n .ihooman-message.bot { align-self: flex-start; align-items: flex-start; }\n .ihooman-message-content { padding: 12px 16px; border-radius: 16px; word-wrap: break-word; }\n .ihooman-message.user .ihooman-message-content { background: ${b}; color: white; border-bottom-right-radius: 4px; }\n .ihooman-message.bot .ihooman-message-content { background: ${f}; color: ${m}; border-bottom-left-radius: 4px; }\n .ihooman-message-content code { background: rgba(0,0,0,0.1); padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: 13px; }\n .ihooman-message-time { font-size: 11px; color: ${h}; margin-top: 4px; padding: 0 4px; }\n .ihooman-typing { display: flex; align-items: center; gap: 8px; padding: 12px 16px; background: ${f}; border-radius: 16px; border-bottom-left-radius: 4px; max-width: 80px; align-self: flex-start; }\n .ihooman-typing-dots { display: flex; gap: 4px; }\n .ihooman-typing-dot { width: 8px; height: 8px; background: ${h}; border-radius: 50%; animation: ihooman-typing 1.4s infinite; }\n .ihooman-typing-dot:nth-child(2) { animation-delay: 0.2s; }\n .ihooman-typing-dot:nth-child(3) { animation-delay: 0.4s; }\n @keyframes ihooman-typing { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-4px); opacity: 1; } }\n .ihooman-input-area { padding: 12px 16px; background: ${c}; border-top: 1px solid ${g}; flex-shrink: 0; }\n .ihooman-input-wrapper { display: flex; align-items: flex-end; gap: 8px; background: ${u}; border: 1px solid ${g}; border-radius: 12px; padding: 8px 12px; transition: border-color 0.2s, box-shadow 0.2s; }\n .ihooman-input-wrapper:focus-within { border-color: ${e}; box-shadow: 0 0 0 3px rgba(0, 174, 255, 0.1); }\n .ihooman-input { flex: 1; border: none; background: transparent; font-family: inherit; font-size: 14px; color: ${m}; resize: none; max-height: 100px; outline: none; line-height: 1.4; }\n .ihooman-input::placeholder { color: ${h}; }\n .ihooman-input-btn { width: 36px; height: 36px; border-radius: 10px; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; background: transparent; color: ${h}; }\n .ihooman-input-btn:hover { background: ${g}; color: ${m}; }\n .ihooman-input-btn.send { background: linear-gradient(135deg, ${t}, ${n}); color: white; }\n .ihooman-input-btn.send:hover { transform: scale(1.05); box-shadow: 0 4px 12px rgba(0, 174, 255, 0.3); }\n .ihooman-input-btn.send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }\n .ihooman-input-btn svg { width: 18px; height: 18px; }\n .ihooman-file-input { display: none; }\n .ihooman-powered { text-align: center; padding: 8px; font-size: 11px; color: ${h}; background: ${c}; }\n .ihooman-powered a { color: ${e}; text-decoration: none; }\n .ihooman-error { padding: 16px; text-align: center; color: #ef4444; background: ${c}; }\n .ihooman-escalation-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }\n .ihooman-widget .ihooman-escalation-btn { display: inline-flex !important; align-items: center !important; gap: 8px !important; padding: 10px 18px !important; border-radius: 8px !important; border: none !important; cursor: pointer !important; font-family: inherit !important; font-size: 13px !important; font-weight: 500 !important; transition: all 0.2s ease !important; width: auto !important; height: auto !important; min-width: 120px !important; }\n .ihooman-widget .ihooman-escalation-btn svg { width: 16px !important; height: 16px !important; flex-shrink: 0 !important; }\n .ihooman-widget .ihooman-escalation-btn.primary { background: linear-gradient(135deg, ${t}, ${n}) !important; color: white !important; }\n .ihooman-widget .ihooman-escalation-btn.primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 174, 255, 0.3); }\n .ihooman-widget .ihooman-escalation-btn.secondary { background: ${l?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.05)"} !important; color: ${m} !important; border: 1px solid ${g} !important; }\n .ihooman-widget .ihooman-escalation-btn.secondary:hover { background: ${l?"rgba(255,255,255,0.15)":"rgba(0,0,0,0.08)"} !important; }\n .ihooman-widget .ihooman-escalation-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }\n .ihooman-status-bar { padding: 10px 16px; text-align: center; font-size: 13px; display: none; }\n .ihooman-status-bar.show { display: block; }\n .ihooman-status-bar.waiting { background: #fef3c7; color: #92400e; }\n .ihooman-status-bar.connected { background: #dcfce7; color: #166534; }\n .ihooman-chat-view { display: flex; flex-direction: column; flex: 1; overflow: hidden; min-height: 0; }\n .ihooman-chat-view.hidden { display: none; }\n .ihooman-ticket-view { display: none; flex-direction: column; padding: 20px; gap: 16px; background: ${c}; flex: 1; overflow-y: auto; min-height: 0; }\n .ihooman-ticket-view.show { display: flex; }\n .ihooman-ticket-title { font-size: 18px; font-weight: 600; color: ${m}; margin: 0; display: flex; align-items: center; gap: 8px; }\n .ihooman-ticket-subtitle { font-size: 13px; color: ${h}; margin: 0; }\n .ihooman-ticket-input { padding: 12px 14px; border: 1px solid ${g}; border-radius: 10px; font-size: 14px; font-family: inherit; background: ${u}; color: ${m}; outline: none; transition: border-color 0.2s; }\n .ihooman-ticket-input:focus { border-color: ${e}; }\n .ihooman-ticket-input::placeholder { color: ${h}; }\n .ihooman-ticket-textarea { min-height: 100px; resize: vertical; }\n .ihooman-ticket-submit { padding: 14px; background: linear-gradient(135deg, ${t}, ${n}); color: white; border: none; border-radius: 10px; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.2s; }\n .ihooman-ticket-submit:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 174, 255, 0.3); }\n .ihooman-ticket-submit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }\n .ihooman-ticket-back { padding: 10px; background: transparent; color: ${h}; border: 1px solid ${g}; border-radius: 10px; font-size: 13px; cursor: pointer; transition: all 0.2s; }\n .ihooman-ticket-back:hover { background: ${l?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.03)"}; }\n .ihooman-history-view { display: none; flex-direction: column; flex: 1; overflow: hidden; background: ${c}; }\n .ihooman-history-view.show { display: flex; }\n .ihooman-history-header { padding: 12px 16px; border-bottom: 1px solid ${g}; display: flex; justify-content: space-between; align-items: center; }\n .ihooman-history-title { font-size: 14px; font-weight: 600; color: ${m}; margin: 0; }\n .ihooman-history-new { display: inline-flex; align-items: center; gap: 4px; background: linear-gradient(135deg, ${t}, ${n}); color: white; border: none; padding: 8px 16px; border-radius: 8px !important; font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.2s; }\n .ihooman-history-new:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0, 174, 255, 0.3); }\n .ihooman-history-new svg { width: 14px; height: 14px; flex-shrink: 0; }\n .ihooman-history-list { flex: 1; overflow-y: auto; padding: 8px; overscroll-behavior: contain; }\n .ihooman-history-item { padding: 12px; border: 1px solid ${g}; border-radius: 8px; margin-bottom: 6px; cursor: pointer; transition: all 0.2s; background: ${c}; }\n .ihooman-history-item:hover { background: ${l?"rgba(255,255,255,0.05)":"#f8fafc"}; }\n .ihooman-history-item.active { background: ${l?"rgba(0, 174, 255, 0.1)":"#eff6ff"}; border-color: ${e}; }\n .ihooman-history-preview { font-size: 13px; color: ${m}; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n .ihooman-history-meta { font-size: 11px; color: ${h}; margin-top: 4px; display: flex; justify-content: space-between; }\n .ihooman-history-empty { padding: 40px; text-align: center; color: ${h}; font-size: 14px; }\n .ihooman-preset-questions { padding: 8px 16px; display: flex; flex-wrap: wrap; gap: 6px; background: ${c}; border-top: 1px solid ${g}; }\n .ihooman-preset-questions:empty { display: none; }\n .ihooman-preset-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9999px; border: 1px solid ${e}33; background: ${e}1a; color: ${e}; font-size: 12px; font-weight: 500; cursor: pointer; transition: all 0.2s; white-space: nowrap; }\n .ihooman-preset-btn:hover { background: ${e}33; border-color: ${e}4d; }\n .ihooman-preset-btn .icon { font-size: 14px; }\n @media (max-width: 480px) { .ihooman-window { width: calc(100vw - 20px); height: calc(100vh - 100px); left: 10px; right: 10px; bottom: 80px; max-height: none; } .ihooman-toggle { ${x?"right: 16px":"left: 16px"}; bottom: 16px; } }\n `}(),document.head.appendChild(e);const r=document.createElement("div");r.className="ihooman-widget",r.innerHTML=`\n <button class="ihooman-toggle" aria-label="Open chat">\n <span class="ihooman-pulse"></span>\n <span class="ihooman-badge"></span>\n <span class="chat-icon">${t}</span>\n <span class="close-icon">${n}</span>\n </button>\n <div class="ihooman-window" role="dialog" aria-label="Chat window">\n <div class="ihooman-container">\n <div class="ihooman-header">\n <div class="ihooman-header-avatar">${p.avatarUrl?`<img src="${V(p.avatarUrl)}" alt="Support">`:s}</div>\n <div class="ihooman-header-info">\n <div class="ihooman-header-title">${V(p.title||"Chat Support")}</div>\n <div class="ihooman-header-status"><span class="ihooman-status-dot"></span><span class="ihooman-status-text">Online</span></div>\n </div>\n <div class="ihooman-header-actions">\n <button class="ihooman-header-btn" data-action="history" title="Chat history">${l}</button>\n <button class="ihooman-header-btn" data-action="refresh" title="New conversation">${c}</button>\n <button class="ihooman-header-btn" data-action="minimize" title="Minimize">${a}</button>\n </div>\n </div>\n \n \x3c!-- Chat View --\x3e\n <div class="ihooman-chat-view">\n <div class="ihooman-status-bar"></div>\n <div class="ihooman-messages" role="log" aria-live="polite"></div>\n <div class="ihooman-preset-questions"></div>\n <div class="ihooman-input-area">\n <div class="ihooman-input-wrapper">\n ${p.enableFileUpload?`<button class="ihooman-input-btn attach" title="Attach file">${i}</button><input type="file" class="ihooman-file-input">`:""}\n <textarea class="ihooman-input" placeholder="${V(p.placeholder||"Type a message...")}" rows="1" aria-label="Message input"></textarea>\n <button class="ihooman-input-btn send" title="Send message" disabled>${o}</button>\n </div>\n </div>\n </div>\n \n \x3c!-- Ticket Form View --\x3e\n <div class="ihooman-ticket-view">\n <h4 class="ihooman-ticket-title">📝 Submit a Ticket</h4>\n <p class="ihooman-ticket-subtitle">We'll get back to you via email</p>\n <input class="ihooman-ticket-input" id="ihooman-ticket-name" placeholder="Your name" required>\n <input class="ihooman-ticket-input" id="ihooman-ticket-email" type="email" placeholder="Your email" required>\n <textarea class="ihooman-ticket-input ihooman-ticket-textarea" id="ihooman-ticket-issue" placeholder="Describe your issue..."></textarea>\n <button class="ihooman-ticket-submit" id="ihooman-ticket-submit">Submit Ticket</button>\n <button class="ihooman-ticket-back" id="ihooman-ticket-back">← Back to Chat</button>\n </div>\n \n \x3c!-- History View --\x3e\n <div class="ihooman-history-view">\n <div class="ihooman-history-header">\n <span class="ihooman-history-title">Your Conversations</span>\n <button class="ihooman-history-new" style="all: revert; display: inline-flex !important; align-items: center !important; gap: 4px !important; background: linear-gradient(135deg, ${p.gradientFrom}, ${p.gradientTo}) !important; color: white !important; border: none !important; padding: 6px 10px !important; border-radius: 6px !important; font-size: 12px !important; font-weight: 500 !important; cursor: pointer !important; width: auto !important; height: auto !important; min-width: 0 !important; aspect-ratio: auto !important;">${c} New Chat</button>\n </div>\n <div class="ihooman-history-list"></div>\n </div>\n \n ${p.poweredBy?'<div class="ihooman-powered">Powered by <a href="https://ihooman.ai" target="_blank" rel="noopener">Ihooman AI</a></div>':""}\n </div>\n </div>\n `,document.body.appendChild(r),u={widget:r,toggle:r.querySelector(".ihooman-toggle"),badge:r.querySelector(".ihooman-badge"),window:r.querySelector(".ihooman-window"),chatView:r.querySelector(".ihooman-chat-view"),ticketView:r.querySelector(".ihooman-ticket-view"),historyView:r.querySelector(".ihooman-history-view"),historyList:r.querySelector(".ihooman-history-list"),historyNewBtn:r.querySelector(".ihooman-history-new"),messages:r.querySelector(".ihooman-messages"),presetQuestions:r.querySelector(".ihooman-preset-questions"),input:r.querySelector(".ihooman-input"),sendBtn:r.querySelector(".ihooman-input-btn.send"),attachBtn:r.querySelector(".ihooman-input-btn.attach"),fileInput:r.querySelector(".ihooman-file-input"),statusDot:r.querySelector(".ihooman-status-dot"),statusText:r.querySelector(".ihooman-status-text"),statusBar:r.querySelector(".ihooman-status-bar"),ticketName:r.querySelector("#ihooman-ticket-name"),ticketEmail:r.querySelector("#ihooman-ticket-email"),ticketIssue:r.querySelector("#ihooman-ticket-issue"),ticketSubmitBtn:r.querySelector("#ihooman-ticket-submit"),ticketBackBtn:r.querySelector("#ihooman-ticket-back")},function(){if(!u.toggle||!u.sendBtn||!u.input)return;u.toggle.addEventListener("click",Y),u.sendBtn.addEventListener("click",U),u.input.addEventListener("input",()=>{u.sendBtn&&(u.sendBtn.disabled=!u.input?.value.trim()),u.input&&(u.input.style.height="auto",u.input.style.height=Math.min(u.input.scrollHeight,100)+"px")}),u.input.addEventListener("keydown",e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),u.sendBtn?.disabled||U())}),u.attachBtn&&u.fileInput&&(u.attachBtn.addEventListener("click",()=>u.fileInput?.click()),u.fileInput.addEventListener("change",j));u.widget?.querySelector('[data-action="refresh"]')?.addEventListener("click",R),u.widget?.querySelector('[data-action="minimize"]')?.addEventListener("click",Q),u.widget?.querySelector('[data-action="history"]')?.addEventListener("click",T),u.ticketSubmitBtn&&u.ticketSubmitBtn.addEventListener("click",B);u.ticketBackBtn&&u.ticketBackBtn.addEventListener("click",()=>I("chat"));u.historyNewBtn&&u.historyNewBtn.addEventListener("click",()=>{R(),I("chat")})}(),function(){if(!u.presetQuestions||0===J.length)return void(u.presetQuestions&&(u.presetQuestions.innerHTML=""));u.presetQuestions.innerHTML=J.map(e=>`\n <button class="ihooman-preset-btn" data-question-id="${V(e.id)}" data-question-text="${V(e.text)}">\n ${e.icon?`<span class="icon">${V(e.icon)}</span>`:""}\n <span>${V(e.text)}</span>\n </button>\n `).join(""),u.presetQuestions.querySelectorAll(".ihooman-preset-btn").forEach(e=>{e.addEventListener("click",()=>{const t=e.dataset.questionText;t&&function(e){S(e,"user"),q(),O(e),u.presetQuestions&&(u.presetQuestions.style.display="none")}(t)})})}()}function S(e,t="bot",n={}){const o={id:v("msg_"),content:e,sender:t,timestamp:new Date,metadata:n};if(m.messages.push(o),!u.messages)return o;const i=document.createElement("div");i.className=`ihooman-message ${t}`;const a="bot"===t&&!0===n?.escalation_offered;let s="";if(a){const e="all: revert; display: inline-flex !important; align-items: center !important; justify-content: center !important; gap: 6px !important; padding: 8px 12px !important; border-radius: 6px !important; border: none !important; cursor: pointer !important; font-size: 12px !important; font-weight: 500 !important; line-height: 1.2 !important; width: auto !important; height: auto !important; min-width: 0 !important; min-height: 0 !important; max-width: none !important; max-height: none !important; aspect-ratio: auto !important; box-sizing: border-box !important;";s=`\n <div class="ihooman-escalation-actions" style="display: flex !important; gap: 8px !important; margin-top: 10px !important; flex-wrap: wrap !important;">\n <button class="ihooman-escalation-btn primary" data-action="live-agent" style="${`${e} background: linear-gradient(135deg, ${p.gradientFrom}, ${p.gradientTo}) !important; color: white !important;`}">\n ${r}\n <span>Talk to Agent</span>\n </button>\n <button class="ihooman-escalation-btn secondary" data-action="create-ticket" style="${`${e} background: rgba(0,0,0,0.05) !important; color: inherit !important; border: 1px solid rgba(0,0,0,0.1) !important;`}">\n ${d}\n <span>Create Ticket</span>\n </button>\n </div>\n `}var l,c;if(i.innerHTML=`\n <div class="ihooman-message-content">${c=e,c?V(c).replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/`(.*?)`/g,"<code>$1</code>").replace(/\n/g,"<br>"):""}</div>\n ${s}\n ${p.showTimestamps?`<div class="ihooman-message-time">${l=o.timestamp,new Date(l).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}</div>`:""}\n `,a){const e=i.querySelector('[data-action="live-agent"]'),t=i.querySelector('[data-action="create-ticket"]');e&&e.addEventListener("click",()=>_("live-agent")),t&&t.addEventListener("click",()=>_("create-ticket"))}const h=u.messages.querySelector(".ihooman-typing");return h&&h.remove(),u.messages.appendChild(i),u.messages.scrollTop=u.messages.scrollHeight,"bot"!==t||m.isOpen||(m.unreadCount++,u.badge&&(u.badge.textContent=String(m.unreadCount)),p.enableSounds&&function(){try{const e=new Audio("data:audio/mp3;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4Ljc2LjEwMAAAAAAAAAAAAAAA//tQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWGluZwAAAA8AAAACAAABhgC7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7//////////////////////////////////////////////////////////////////8AAAAATGF2YzU4LjEzAAAAAAAAAAAAAAAAJAAAAAAAAAAAAYYNBrP/AAAAAAAAAAAAAAAAAAAAAP/7UMQAA8AAAaQAAAAgAAA0gAAABExBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tQxBKDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVU=");e.volume=.3,e.play().catch(()=>{})}catch{}}()),A("message",o),o}function _(e){document.querySelectorAll(".ihooman-escalation-btn").forEach(e=>e.disabled=!0),"live-agent"===e?async function(){if(!m.sessionId)return void S("Please send a message first to start a conversation.","bot",{is_system_message:!0});const e=u.widget?.querySelector('[data-action="live-agent"]');e&&(e.disabled=!0,e.innerHTML='<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg> Connecting...');try{const e=await fetch(`${p.serverUrl}/api/widget/live-agent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({widget_id:p.widgetId,session_id:m.sessionId,visitor_id:m.visitorId})}),t=await e.json();g=!0,t.position_in_queue&&t.position_in_queue>1?C("waiting",`⏳ Waiting for agent (Position: #${t.position_in_queue})`):C("waiting","⏳ Connecting to live support..."),E()}catch(e){console.error("Error requesting live agent:",e),S("❌ Unable to connect to live support. Please try again.","bot",{is_system_message:!0})}e&&(e.disabled=!1,e.innerHTML='<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg> Live Agent')}():"create-ticket"===e&&(I("ticket"),setTimeout(()=>u.ticketName?.focus(),100))}function I(e){h=e,u.chatView&&u.chatView.classList.toggle("hidden","chat"!==e),u.ticketView&&u.ticketView.classList.toggle("show","ticket"===e),u.historyView&&u.historyView.classList.toggle("show","history"===e),"history"===e&&async function(){if(!u.historyList||!m.visitorId)return;u.historyList.innerHTML='<div class="ihooman-history-empty">Loading...</div>';try{const e=await fetch(`${p.serverUrl}/api/widget/conversations?widget_id=${p.widgetId}&visitor_id=${m.visitorId}&limit=20`);if(!e.ok)throw new Error("Failed to load history");const t=await e.json();if(!t.length)return void(u.historyList.innerHTML='<div class="ihooman-history-empty">No conversations yet</div>');u.historyList.innerHTML=t.map(e=>`\n <div class="ihooman-history-item ${e.session_id===m.sessionId?"active":""}" data-session-id="${e.session_id}">\n <div class="ihooman-history-preview">${V(e.preview||"New conversation")}</div>\n <div class="ihooman-history-meta">\n <span>${e.message_count} msgs</span>\n <span>${"pending"===e.status?"🟡 Pending":"closed"===e.status?"✓ Closed":""} ${function(e){const t=Date.now()-new Date(e).getTime();return t<6e4?"now":t<36e5?Math.floor(t/6e4)+"m":t<864e5?Math.floor(t/36e5)+"h":Math.floor(t/864e5)+"d"}(e.updated_at)}</span>\n </div>\n </div>\n `).join(""),u.historyList.querySelectorAll(".ihooman-history-item").forEach(e=>{e.addEventListener("click",()=>{const t=e.dataset.sessionId;t&&async function(e){m.sessionId=e,p.persistSession&&k("session_id",e);u.messages&&(u.messages.innerHTML="");g=!1,z(),C("hidden"),w=!0,f&&(f.close(),f=null);F(),I("chat"),await async function(e){try{const t=await fetch(`${p.serverUrl}/api/widget/transcript/${e}?widget_id=${p.widgetId}`);if(!t.ok)throw new Error("Failed to load messages");const n=await t.json();u.messages&&(u.messages.innerHTML=""),n.messages&&n.messages.length>0?n.messages.forEach(e=>{const t="user"===e.sender_type?"user":"bot";S(e.content,t,e.extra_data||{})}):p.welcomeMessage&&S(p.welcomeMessage,"bot"),"pending"===n.status?(g=!0,E(),C("waiting","⏳ Waiting for agent...")):"closed"===n.status&&C("hidden")}catch(e){console.error("Error loading conversation messages:",e),p.welcomeMessage&&S(p.welcomeMessage,"bot")}}(e)}(t)})})}catch(e){console.error("Error loading conversation history:",e),u.historyList.innerHTML='<div class="ihooman-history-empty">Failed to load history</div>'}}()}function T(){I("history"===h?"chat":"history")}function C(e,t){u.statusBar&&("hidden"!==e?(u.statusBar.classList.add("show"),u.statusBar.classList.remove("waiting","connected"),u.statusBar.classList.add(e),t&&(u.statusBar.textContent=t)):u.statusBar.classList.remove("show"))}async function B(){const e=u.ticketName?.value.trim(),t=u.ticketEmail?.value.trim(),n=u.ticketIssue?.value.trim();if(e&&t){u.ticketSubmitBtn&&(u.ticketSubmitBtn.disabled=!0,u.ticketSubmitBtn.textContent="Submitting...");try{const o=await fetch(`${p.serverUrl}/api/widget/submit-ticket`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({widget_id:p.widgetId,session_id:m.sessionId,user_name:e,user_email:t,issue:n||"No description provided"})}),i=await o.json();u.ticketName&&(u.ticketName.value=""),u.ticketEmail&&(u.ticketEmail.value=""),u.ticketIssue&&(u.ticketIssue.value=""),I("chat");S(`✅ Ticket submitted! We'll contact you at ${t}. Reference: #${i.ticket_id?i.ticket_id.slice(0,8):"submitted"}`,"bot",{is_system_message:!0})}catch(e){console.error("Error submitting ticket:",e),S("❌ Error submitting ticket. Please try again.","bot",{is_system_message:!0})}u.ticketSubmitBtn&&(u.ticketSubmitBtn.disabled=!1,u.ticketSubmitBtn.textContent="Submit Ticket")}else alert("Please fill in your name and email")}let L=null;function E(){L||(L=setInterval(async()=>{if(m.sessionId&&g)try{try{const e=await fetch(`${p.serverUrl}/api/widget/escalation-status/${m.sessionId}?widget_id=${p.widgetId}`);if(e.ok){const t=await e.json();t.escalated&&("in_progress"===t.ticket_status?C("connected","🟢 Connected to live agent"):"open"===t.ticket_status?t.position_in_queue&&t.position_in_queue>1?C("waiting",`⏳ Waiting for agent (Position: #${t.position_in_queue})`):C("waiting","⏳ Waiting for agent..."):"closed"!==t.ticket_status&&"resolved"!==t.ticket_status||(g=!1,z(),C("hidden"),S("This conversation has been closed. Thank you for contacting us!","bot",{is_system_message:!0})))}}catch{}}catch(e){console.error("Error polling for messages:",e)}else z()},3e3))}function z(){L&&(clearInterval(L),L=null)}function q(){if(!p.showTypingIndicator||!u.messages)return;if(u.messages.querySelector(".ihooman-typing"))return;const e=document.createElement("div");e.className="ihooman-typing",e.innerHTML='<div class="ihooman-typing-dots"><span class="ihooman-typing-dot"></span><span class="ihooman-typing-dot"></span><span class="ihooman-typing-dot"></span></div>',u.messages.appendChild(e),u.messages.scrollTop=u.messages.scrollHeight}function M(){const e=u.messages?.querySelector(".ihooman-typing");e&&e.remove()}function U(){const e=u.input?.value.trim();e&&(u.input&&(u.input.value="",u.input.style.height="auto"),u.sendBtn&&(u.sendBtn.disabled=!0),S(e,"user"),q(),O(e))}async function O(e){if(f&&f.readyState===WebSocket.OPEN)f.send(JSON.stringify({type:"message",content:e}));else try{const t=await fetch(`${p.serverUrl}/api/v1/public/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:e,session_id:m.sessionId,visitor_id:m.visitorId,widget_id:p.widgetId})}),n=await t.json();M(),n.session_id&&(m.sessionId=n.session_id,p.persistSession&&k("session_id",m.sessionId)),n.response&&S(n.response,"bot",{sources:n.sources,confidence:n.confidence})}catch(e){M(),S("Sorry, something went wrong. Please try again.","bot"),A("error",e)}}function j(e){const t=e.target,n=t.files?.[0];if(!n)return;S(`📎 Uploading: ${n.name}...`,"user"),q();const o=new FormData;o.append("file",n),o.append("session_id",m.sessionId||""),o.append("visitor_id",m.visitorId||""),o.append("widget_id",p.widgetId),fetch(`${p.serverUrl}/api/upload`,{method:"POST",body:o}).then(e=>e.json()).then(e=>{M(),e.message&&S(e.message,"bot")}).catch(()=>{M(),S("Failed to upload file.","bot")}),t.value=""}function F(e){if(!p.serverUrl&&!e)return;let t;if(p.widgetId){const e=p.serverUrl?.replace(/^http/,"ws"),n=new URLSearchParams({widget_id:p.widgetId});m.visitorId&&n.append("visitor_id",m.visitorId),m.sessionId&&n.append("session_id",m.sessionId),t=`${e}/public/ws?${n.toString()}`}else t=e||p.serverUrl?.replace(/^http/,"ws")+"/ws";try{H(),f=new WebSocket(t),f.onopen=()=>{m.isConnected=!0,y=0,W(!0),A("connected"),H(),N=setInterval(()=>{if(f&&f.readyState===WebSocket.OPEN)try{f.send(JSON.stringify({type:"ping"}))}catch(e){console.warn("Failed to send heartbeat ping:",e)}},25e3)},f.onclose=t=>{if(m.isConnected=!1,W(!1),H(),A("disconnected"),console.log(`WebSocket closed: code=${t.code}, reason=${t.reason||"none"}, wasClean=${t.wasClean}`),w)w=!1;else if(m.isOpen)if(y<5){y++;const t=Math.min(1e3*Math.pow(2,y),3e4);console.log(`WebSocket reconnecting in ${t}ms (attempt ${y}/5)`),setTimeout(()=>F(e),t)}else console.warn("WebSocket reconnection failed, falling back to polling"),P()},f.onerror=e=>{console.error("WebSocket error:",e)},f.onmessage=e=>{try{const t=JSON.parse(e.data);if("connected"===t.type)t.session_id&&(m.sessionId=t.session_id,p.persistSession&&k("session_id",m.sessionId)),t.visitor_id&&(m.visitorId=t.visitor_id,p.persistSession&&k("visitor_id",m.visitorId)),t.welcome_message&&0===m.messages.length&&S(t.welcome_message,"bot");else if("message"===t.type){M();const e="user"===t.sender?"user":"bot";S(t.content,e,{confidence:t.confidence,agent_name:t.agent_name,escalation_offered:t.escalation_offered,escalated:t.escalated})}else"typing"===t.type?t.is_typing?q():M():"pong"===t.type||"error"===t.type&&(console.error("WebSocket server error:",t.message),A("error",{message:t.message}))}catch{}}}catch{console.warn("WebSocket not supported, using polling"),P()}}let N=null;function H(){N&&(clearInterval(N),N=null)}function P(){x||(x=setInterval(async()=>{if(m.sessionId)try{const e=await fetch(`${p.serverUrl}/api/messages?session_id=${m.sessionId}&since=${Date.now()-5e3}&widget_id=${p.widgetId}`),t=await e.json();t.messages&&t.messages.forEach(e=>{m.messages.find(t=>t.id===e.id)||S(e.content,e.sender_type,e.metadata)})}catch{}},5e3))}function W(e){u.statusDot&&u.statusDot.classList.toggle("offline",!e),u.statusText&&(u.statusText.textContent=e?"Online":"Offline")}function D(){m.isOpen||(m.isOpen=!0,m.unreadCount=0,u.badge&&(u.badge.textContent=""),u.toggle&&u.toggle.classList.add("open"),u.window&&u.window.classList.add("open"),setTimeout(()=>u.input?.focus(),300),A("open"))}function Q(){m.isOpen&&(m.isOpen=!1,u.toggle&&u.toggle.classList.remove("open"),u.window&&u.window.classList.remove("open"),A("close"))}function Y(){m.isOpen?Q():D()}function R(){m.sessionId=null,m.visitorId=null,m.messages=[],g=!1,k("session_id",null),m.visitorId=v("v_"),k("visitor_id",m.visitorId),u.messages&&(u.messages.innerHTML=""),C("hidden"),z(),y=0,f&&(w=!0,f.close(),f=null),F(),p.welcomeMessage&&S(p.welcomeMessage,"bot"),A("newConversation")}let J=[];async function G(t){if(!t.widgetId)return console.error("IhoomanChat: widgetId is required"),null;p={...e,...t},m.visitorId=k("visitor_id")||v("v_"),k("visitor_id",m.visitorId),p.persistSession&&(m.sessionId=k("session_id"));const n=p.serverUrl||"https://api.ihooman.ai",o=await async function(e,t){try{const n=await fetch(`${t}/api/widget/config?widget_id=${encodeURIComponent(e)}`);return n.ok?await n.json():{success:!1,error:(await n.json().catch(()=>({}))).error||`HTTP ${n.status}`}}catch(e){return{success:!1,error:"Unable to connect. Please check your internet connection."}}}(p.widgetId,n);let i;var a;return o.success&&o.config?(a=o.config,p.title=a.title||p.title,p.subtitle=a.subtitle||p.subtitle,p.welcomeMessage=a.welcomeMessage||p.welcomeMessage,p.placeholder=a.placeholder||p.placeholder,p.position=a.position||p.position,a.theme&&(p.primaryColor=a.theme.primaryColor||p.primaryColor,p.gradientFrom=a.theme.gradientFrom||p.gradientFrom,p.gradientTo=a.theme.gradientTo||p.gradientTo,p.fontFamily=a.theme.fontFamily||p.fontFamily,a.theme.borderRadius&&(p.borderRadius=parseInt(a.theme.borderRadius,10)||p.borderRadius)),a.behavior&&(p.startOpen=a.behavior.startOpen??p.startOpen,p.showTypingIndicator=a.behavior.showTypingIndicator??p.showTypingIndicator,p.showTimestamps=a.behavior.showTimestamps??p.showTimestamps,p.enableSounds=a.behavior.enableSounds??p.enableSounds,p.enableFileUpload=a.behavior.enableFileUpload??p.enableFileUpload,p.persistSession=a.behavior.persistSession??p.persistSession),a.branding&&(p.avatarUrl=a.branding.avatarUrl||p.avatarUrl,p.poweredBy=a.branding.poweredBy??p.poweredBy),a.presetQuestions&&Array.isArray(a.presetQuestions)&&(J=a.presetQuestions),i=o.chatEndpoint):o.error&&(console.warn("IhoomanChat: Could not fetch server config:",o.error),"Widget not authorized for this domain"===o.error&&console.error("IhoomanChat: Widget configuration error. Please contact support.")),$(),m.messages.forEach(e=>S(e.content,e.sender,e.metadata)),0===m.messages.length&&p.welcomeMessage&&S(p.welcomeMessage,"bot"),F(i),p.startOpen&&setTimeout(D,500),A("ready"),K}const K={init:G,open:D,close:Q,toggle:Y,destroy:function(){H(),z(),w=!0,f&&(f.close(),f=null),x&&(clearInterval(x),x=null),u.widget&&u.widget.remove();const e=document.getElementById("ihooman-widget-styles");e&&e.remove(),m={isOpen:!1,isConnected:!1,messages:[],sessionId:null,visitorId:null,unreadCount:0},u={},y=0,w=!1},sendMessage:function(e){e.trim()&&(u.input&&(u.input.value=e),U())},setUser:function(e){e.name&&k("user_name",e.name),e.email&&k("user_email",e.email),e.metadata&&k("user_metadata",e.metadata)},clearHistory:function(){R()},on:function(e,t){b[e]||(b[e]=[]),b[e].push(t)},off:function(e,t){b[e]&&(b[e]=b[e].filter(e=>e!==t))},getState:function(){return{...m}},version:"2.0.0"},Z=K;function X(){return{...K}}!function(){if("undefined"==typeof document)return;let e=document.currentScript;if(!e){const t=document.getElementsByTagName("script");for(let n=0;n<t.length;n++)if(t[n].src&&t[n].src.includes("ihooman")){e=t[n];break}}if(!e)return;const t=e.getAttribute("data-widget-id");if(t){const n={widgetId:t},o=e.getAttribute("data-server-url");o&&(n.serverUrl=o);const i=e.getAttribute("data-theme");"light"!==i&&"dark"!==i||(n.theme=i);const a=e.getAttribute("data-position");a&&(n.position=a);"true"===e.getAttribute("data-start-open")&&(n.startOpen=!0),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>G(n)):G(n)}}(),"undefined"!=typeof window&&(window.IhoomanChat=Z);export{Z as IhoomanChat,X as createWidgetInstance,Z as default};
2
2
  //# sourceMappingURL=index.esm.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.min.js","sources":["../src/widget.ts"],"sourcesContent":[null],"names":["defaultConfig","serverUrl","theme","position","title","subtitle","welcomeMessage","placeholder","primaryColor","gradientFrom","gradientTo","showTimestamps","showTypingIndicator","enableSounds","enableFileUpload","startOpen","persistSession","zIndex","width","height","buttonSize","borderRadius","fontFamily","avatarUrl","poweredBy","icons","config","widgetId","state","isOpen","isConnected","messages","sessionId","visitorId","unreadCount","currentView","isLiveAgentMode","elements","eventListeners","ws","pollInterval","reconnectAttempts","intentionalDisconnect","generateId","prefix","Math","random","toString","slice","Date","now","escapeHtml","text","div","document","createElement","textContent","innerHTML","storage","key","value","fullKey","undefined","item","localStorage","getItem","JSON","parse","removeItem","setItem","stringify","emit","event","data","forEach","fn","e","console","error","callbackName","charAt","toUpperCase","callback","createWidget","styleEl","id","isDark","bgColor","textColor","mutedColor","borderColor","inputBg","messageBgUser","messageBgBot","positionRight","includes","positionBottom","generateStyles","head","appendChild","widget","className","body","toggle","querySelector","badge","window","chatView","ticketView","historyView","historyList","historyNewBtn","input","sendBtn","attachBtn","fileInput","statusDot","statusText","statusBar","ticketName","ticketEmail","ticketIssue","ticketSubmitBtn","ticketBackBtn","addEventListener","handleSendClick","disabled","trim","style","min","scrollHeight","shiftKey","preventDefault","click","handleFileSelect","startNewConversation","close","toggleHistoryView","handleSubmitTicket","showView","setupEventListeners","addMessage","content","sender","metadata","message","timestamp","push","el","showEscalationButtons","escalation_offered","escalationButtonsHtml","btnBaseStyle","date","replace","toLocaleTimeString","hour","minute","liveAgentBtn","ticketBtn","handleEscalationAction","typing","remove","scrollTop","String","audio","Audio","volume","play","catch","playSound","action","querySelectorAll","btn","async","is_system_message","liveBtn","response","fetch","method","headers","widget_id","session_id","visitor_id","json","position_in_queue","updateStatusBar","startLiveAgentPolling","handleRequestLiveAgent","setTimeout","focus","view","classList","ok","Error","conversations","length","map","conv","preview","message_count","status","diff","getTime","floor","timeAgo","updated_at","join","dataset","stopLiveAgentPolling","connectWebSocket","msg","sender_type","extra_data","loadConversationMessages","switchToConversation","loadConversationHistory","add","name","email","issue","user_name","user_email","ticket_id","alert","liveAgentPollInterval","setInterval","escResponse","escData","escalated","ticket_status","clearInterval","showTyping","hideTyping","readyState","WebSocket","OPEN","send","type","sources","confidence","sendMessageToServer","target","file","files","formData","FormData","append","then","r","chatEndpoint","wsUrl","baseWsUrl","params","URLSearchParams","stopHeartbeat","onopen","updateStatus","heartbeatInterval","warn","onclose","log","code","reason","wasClean","delay","pow","startPolling","onerror","onmessage","welcome_message","agent_name","is_typing","find","m","online","open","init","userConfig","configResponse","encodeURIComponent","success","fetchWidgetConfig","serverConfig","parseInt","behavior","branding","publicAPI","destroy","styles","getElementById","sendMessage","setUser","user","clearHistory","on","off","filter","getState","version","IhoomanChat","createWidgetInstance","script","currentScript","scripts","getElementsByTagName","i","src","getAttribute","autoConfig"],"mappings":"AA2BA,MAMMA,EAAuC,CAC3CC,UAAW,yBACXC,MAAO,QACPC,SAAU,eACVC,MAAO,eACPC,SAAU,oCACVC,eAAgB,0CAChBC,YAAa,oBACbC,aAAc,UACdC,aAAc,UACdC,WAAY,UACZC,gBAAgB,EAChBC,qBAAqB,EACrBC,cAAc,EACdC,kBAAkB,EAClBC,WAAW,EACXC,gBAAgB,EAChBC,OAAQ,KACRC,MAAO,IACPC,OAAQ,IACRC,WAAY,GACZC,aAAc,GACdC,WAAY,oEACZC,UAAW,GACXC,WAAW,GAOPC,EACE,oKADFA,EAEG,2KAFHA,EAGE,uLAHFA,EAII,wNAJJA,EAKM,iIALNA,EAOC,4MAPDA,EAQ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IAAUkT,EAAWlT,SAAWA,GAGlB,SADA2S,EAAOM,aAAa,qBACZC,EAAWtS,WAAY,GAGrB,YAAxBuC,SAASoL,WACXpL,SAASsE,iBAAiB,mBAAoB,IAAMyJ,EAAKgC,IAEzDhC,EAAKgC,EAET,CACD,CAzCD,GA4CsB,oBAAX3M,SACRA,OAA8CkM,YAAcA"}
1
+ {"version":3,"file":"index.esm.min.js","sources":["../src/widget.ts"],"sourcesContent":[null],"names":["defaultConfig","serverUrl","theme","position","title","subtitle","welcomeMessage","placeholder","primaryColor","gradientFrom","gradientTo","showTimestamps","showTypingIndicator","enableSounds","enableFileUpload","startOpen","persistSession","zIndex","width","height","buttonSize","borderRadius","fontFamily","avatarUrl","poweredBy","icons","config","widgetId","state","isOpen","isConnected","messages","sessionId","visitorId","unreadCount","currentView","isLiveAgentMode","elements","eventListeners","ws","pollInterval","reconnectAttempts","intentionalDisconnect","generateId","prefix","Math","random","toString","slice","Date","now","escapeHtml","text","div","document","createElement","textContent","innerHTML","storage","key","value","fullKey","undefined","item","localStorage","getItem","JSON","parse","removeItem","setItem","stringify","emit","event","data","forEach","fn","e","console","error","callbackName","charAt","toUpperCase","callback","createWidget","styleEl","id","isDark","bgColor","textColor","mutedColor","borderColor","inputBg","messageBgUser","messageBgBot","positionRight","includes","positionBottom","generateStyles","head","appendChild","widget","className","body","toggle","querySelector","badge","window","chatView","ticketView","historyView","historyList","historyNewBtn","presetQuestions","input","sendBtn","attachBtn","fileInput","statusDot","statusText","statusBar","ticketName","ticketEmail","ticketIssue","ticketSubmitBtn","ticketBackBtn","addEventListener","handleSendClick","disabled","trim","style","min","scrollHeight","shiftKey","preventDefault","click","handleFileSelect","startNewConversation","close","toggleHistoryView","handleSubmitTicket","showView","setupEventListeners","length","map","q","icon","join","querySelectorAll","btn","questionText","dataset","addMessage","showTyping","sendMessageToServer","display","handlePresetQuestionClick","renderPresetQuestions","content","sender","metadata","message","timestamp","push","el","showEscalationButtons","escalation_offered","escalationButtonsHtml","btnBaseStyle","date","replace","toLocaleTimeString","hour","minute","liveAgentBtn","ticketBtn","handleEscalationAction","typing","remove","scrollTop","String","audio","Audio","volume","play","catch","playSound","action","async","is_system_message","liveBtn","response","fetch","method","headers","widget_id","session_id","visitor_id","json","position_in_queue","updateStatusBar","startLiveAgentPolling","handleRequestLiveAgent","setTimeout","focus","view","classList","ok","Error","conversations","conv","preview","message_count","status","diff","getTime","floor","timeAgo","updated_at","stopLiveAgentPolling","connectWebSocket","msg","sender_type","extra_data","loadConversationMessages","switchToConversation","loadConversationHistory","add","name","email","issue","user_name","user_email","ticket_id","alert","liveAgentPollInterval","setInterval","escResponse","escData","escalated","ticket_status","clearInterval","hideTyping","readyState","WebSocket","OPEN","send","type","sources","confidence","target","file","files","formData","FormData","append","then","r","chatEndpoint","wsUrl","baseWsUrl","params","URLSearchParams","stopHeartbeat","onopen","updateStatus","heartbeatInterval","warn","onclose","log","code","reason","wasClean","delay","pow","startPolling","onerror","onmessage","welcome_message","agent_name","is_typing","find","m","online","open","init","userConfig","configResponse","encodeURIComponent","success","fetchWidgetConfig","serverConfig","parseInt","behavior","branding","Array","isArray","publicAPI","destroy","styles","getElementById","sendMessage","setUser","user","clearHistory","on","off","filter","getState","version","IhoomanChat","createWidgetInstance","script","currentScript","scripts","getElementsByTagName","i","src","getAttribute","autoConfig"],"mappings":"AA2BA,MAMMA,EAAuC,CAC3CC,UAAW,yBACXC,MAAO,QACPC,SAAU,eACVC,MAAO,eACPC,SAAU,oCACVC,eAAgB,0CAChBC,YAAa,oBACbC,aAAc,UACdC,aAAc,UACdC,WAAY,UACZC,gBAAgB,EAChBC,qBAAqB,EACrBC,cAAc,EACdC,kBAAkB,EAClBC,WAAW,EACXC,gBAAgB,EAChBC,OAAQ,KACRC,MAAO,IACPC,OAAQ,IACRC,WAAY,GACZC,aAAc,GACdC,WAAY,oEACZC,UAAW,GACXC,WAAW,GAOPC,EACE,oKADFA,EAEG,2KAFHA,EAGE,uLAHFA,EAII,wNAJJA,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C7B,EA0NE+N,IArNF,SAAazO,EAAoBU,GAC3B5C,EAAekC,KACjBlC,EAAekC,GAASlC,EAAekC,GAAO0O,OAAQvO,GAAOA,IAAOO,GAExE,EAkNEiO,SA7MF,WACE,MAAO,IAAKvR,EACd,EA4MEwR,QA/wDc,SAqxDHC,EAA8Bb,WAK3Bc,IACd,MAAO,IAAKd,EACd,EAUA,WACE,GAAwB,oBAAblP,SAA0B,OAErC,IAAIiQ,EAAmCjQ,SAASkQ,cAEhD,IAAKD,EAAQ,CACX,MAAME,EAAUnQ,SAASoQ,qBAAqB,UAC9C,IAAK,IAAIC,EAAI,EAAGA,EAAIF,EAAQ3K,OAAQ6K,IAClC,GAAIF,EAAQE,GAAGC,KAAOH,EAAQE,GAAGC,IAAI7N,SAAS,WAAY,CACxDwN,EAASE,EAAQE,GACjB,KACF,CAEJ,CAEA,IAAKJ,EAAQ,OAEb,MAAM5R,EAAW4R,EAAOM,aAAa,kBACrC,GAAIlS,EAAU,CACZ,MAAMmS,EAA2D,CAAEnS,YAG7D1B,EAAYsT,EAAOM,aAAa,mBAClC5T,IAAW6T,EAAW7T,UAAYA,GAEtC,MAAMC,EAAQqT,EAAOM,aAAa,cACpB,UAAV3T,GAA+B,SAAVA,IAAkB4T,EAAW5T,MAAQA,GAE9D,MAAMC,EAAWoT,EAAOM,aAAa,iBACjC1T,IAAU2T,EAAW3T,SAAWA,GAGlB,SADAoT,EAAOM,aAAa,qBACZC,EAAW/S,WAAY,GAGrB,YAAxBuC,SAAS4L,WACX5L,SAASuE,iBAAiB,mBAAoB,IAAM+J,EAAKkC,IAEzDlC,EAAKkC,EAET,CACD,CAzCD,GA4CsB,oBAAXpN,SACRA,OAA8C2M,YAAcA"}
package/dist/index.umd.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @ihoomanai/chat-widget v2.5.6
2
+ * @ihoomanai/chat-widget v2.5.8
3
3
  * Universal chat support widget for any website - secure Widget ID based initialization
4
4
  *
5
5
  * @license MIT
@@ -309,6 +309,11 @@
309
309
  .ihooman-history-preview { font-size: 13px; color: ${textColor}; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
310
310
  .ihooman-history-meta { font-size: 11px; color: ${mutedColor}; margin-top: 4px; display: flex; justify-content: space-between; }
311
311
  .ihooman-history-empty { padding: 40px; text-align: center; color: ${mutedColor}; font-size: 14px; }
312
+ .ihooman-preset-questions { padding: 8px 16px; display: flex; flex-wrap: wrap; gap: 6px; background: ${bgColor}; border-top: 1px solid ${borderColor}; }
313
+ .ihooman-preset-questions:empty { display: none; }
314
+ .ihooman-preset-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9999px; border: 1px solid ${primaryColor}33; background: ${primaryColor}1a; color: ${primaryColor}; font-size: 12px; font-weight: 500; cursor: pointer; transition: all 0.2s; white-space: nowrap; }
315
+ .ihooman-preset-btn:hover { background: ${primaryColor}33; border-color: ${primaryColor}4d; }
316
+ .ihooman-preset-btn .icon { font-size: 14px; }
312
317
  @media (max-width: 480px) { .ihooman-window { width: calc(100vw - 20px); height: calc(100vh - 100px); left: 10px; right: 10px; bottom: 80px; max-height: none; } .ihooman-toggle { ${positionRight ? 'right: 16px' : 'left: 16px'}; bottom: 16px; } }
313
318
  `;
314
319
  }
@@ -353,6 +358,7 @@
353
358
  <div class="ihooman-chat-view">
354
359
  <div class="ihooman-status-bar"></div>
355
360
  <div class="ihooman-messages" role="log" aria-live="polite"></div>
361
+ <div class="ihooman-preset-questions"></div>
356
362
  <div class="ihooman-input-area">
357
363
  <div class="ihooman-input-wrapper">
358
364
  ${config.enableFileUpload ? `<button class="ihooman-input-btn attach" title="Attach file">${icons.attach}</button><input type="file" class="ihooman-file-input">` : ''}
@@ -399,6 +405,7 @@
399
405
  historyList: widget.querySelector('.ihooman-history-list'),
400
406
  historyNewBtn: widget.querySelector('.ihooman-history-new'),
401
407
  messages: widget.querySelector('.ihooman-messages'),
408
+ presetQuestions: widget.querySelector('.ihooman-preset-questions'),
402
409
  input: widget.querySelector('.ihooman-input'),
403
410
  sendBtn: widget.querySelector('.ihooman-input-btn.send'),
404
411
  attachBtn: widget.querySelector('.ihooman-input-btn.attach'),
@@ -414,6 +421,8 @@
414
421
  };
415
422
  // Set up event listeners
416
423
  setupEventListeners();
424
+ // Render preset questions
425
+ renderPresetQuestions();
417
426
  }
418
427
  /**
419
428
  * Set up DOM event listeners
@@ -535,6 +544,47 @@
535
544
  emit('message', message);
536
545
  return message;
537
546
  }
547
+ /**
548
+ * Render preset questions in the widget
549
+ */
550
+ function renderPresetQuestions() {
551
+ if (!elements.presetQuestions || presetQuestions.length === 0) {
552
+ if (elements.presetQuestions) {
553
+ elements.presetQuestions.innerHTML = '';
554
+ }
555
+ return;
556
+ }
557
+ elements.presetQuestions.innerHTML = presetQuestions.map(q => `
558
+ <button class="ihooman-preset-btn" data-question-id="${escapeHtml(q.id)}" data-question-text="${escapeHtml(q.text)}">
559
+ ${q.icon ? `<span class="icon">${escapeHtml(q.icon)}</span>` : ''}
560
+ <span>${escapeHtml(q.text)}</span>
561
+ </button>
562
+ `).join('');
563
+ // Add click handlers
564
+ elements.presetQuestions.querySelectorAll('.ihooman-preset-btn').forEach(btn => {
565
+ btn.addEventListener('click', () => {
566
+ const questionText = btn.dataset.questionText;
567
+ if (questionText) {
568
+ handlePresetQuestionClick(questionText);
569
+ }
570
+ });
571
+ });
572
+ }
573
+ /**
574
+ * Handle preset question click - send the question as a message
575
+ */
576
+ function handlePresetQuestionClick(questionText) {
577
+ // Add the question as a user message
578
+ addMessage(questionText, 'user');
579
+ // Show typing indicator
580
+ showTyping();
581
+ // Send to server
582
+ sendMessageToServer(questionText);
583
+ // Hide preset questions after first use (optional - can be removed if you want them to persist)
584
+ if (elements.presetQuestions) {
585
+ elements.presetQuestions.style.display = 'none';
586
+ }
587
+ }
538
588
  /**
539
589
  * Handle escalation action button clicks
540
590
  */
@@ -1411,6 +1461,10 @@
1411
1461
  };
1412
1462
  }
1413
1463
  }
1464
+ /**
1465
+ * Preset questions from server config
1466
+ */
1467
+ let presetQuestions = [];
1414
1468
  /**
1415
1469
  * Apply server configuration to local config
1416
1470
  */
@@ -1445,6 +1499,10 @@
1445
1499
  config.avatarUrl = serverConfig.branding.avatarUrl || config.avatarUrl;
1446
1500
  config.poweredBy = serverConfig.branding.poweredBy ?? config.poweredBy;
1447
1501
  }
1502
+ // Store preset questions
1503
+ if (serverConfig.presetQuestions && Array.isArray(serverConfig.presetQuestions)) {
1504
+ presetQuestions = serverConfig.presetQuestions;
1505
+ }
1448
1506
  }
1449
1507
  /**
1450
1508
  * Initialize the widget