@kavchat/widget 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -226,7 +226,7 @@ function randomId(length = 22) {
226
226
  // src/styles.ts
227
227
  var CSS = `
228
228
  :host{all:initial}
229
- .kc{font-family:system-ui,-apple-system,"Segoe UI",Roboto,"Noto Sans Hebrew","Noto Sans Arabic",Arial,sans-serif;font-size:15px;line-height:1.45;color:#1f2328;-webkit-font-smoothing:antialiased}
229
+ .kc{font-family:system-ui,-apple-system,"Segoe UI",Roboto,"Noto Sans Hebrew","Noto Sans Arabic","Noto Sans Thai",Arial,sans-serif;font-size:15px;line-height:1.45;color:#1f2328;-webkit-font-smoothing:antialiased}
230
230
  .kc *,.kc *::before,.kc *::after{box-sizing:border-box}
231
231
  .kc [hidden]{display:none!important}
232
232
  .kc button,.kc input,.kc select,.kc textarea{font:inherit;color:inherit;margin:0}
@@ -241,8 +241,8 @@ var CSS = `
241
241
  .avatar{width:38px;height:38px;border-radius:50%;flex:none;display:flex;align-items:center;justify-content:center;overflow:hidden;background:rgba(255,255,255,.22);font-weight:600;font-size:15px}
242
242
  .avatar img{width:100%;height:100%;object-fit:cover}
243
243
  .titles{min-width:0;flex:1}
244
- .name{font-weight:600;font-size:16px;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
245
- .subtitle{font-size:13px;opacity:.85;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
244
+ .name{font-weight:600;font-size:16px;line-height:1.6;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
245
+ .subtitle{font-size:13px;line-height:1.6;opacity:.85;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
246
246
  .close{flex:none;width:36px;height:36px;border:0;border-radius:50%;background:transparent;color:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0}
247
247
  .close:hover{background:rgba(127,127,127,.2)}
248
248
  .close svg{width:22px;height:22px}
@@ -259,7 +259,7 @@ var CSS = `
259
259
  @keyframes kc-dot{50%{opacity:.3}}
260
260
  .msg img{display:block;max-width:100%;height:auto;border-radius:10px;margin-block-end:6px}
261
261
  .chips{flex:none;display:flex;flex-wrap:wrap;gap:6px;padding:4px 14px 10px;max-height:40%;overflow-y:auto}
262
- .chip{border:1px solid var(--kc-accent);background:#fff;color:var(--kc-accent);border-radius:999px;padding:6px 13px;cursor:pointer;font-size:14px;line-height:1.3;text-align:start}
262
+ .chip{border:1px solid var(--kc-accent);background:#fff;color:var(--kc-accent);border-radius:999px;padding:6px 13px;cursor:pointer;font-size:14px;line-height:1.4;text-align:start}
263
263
  .chip:hover{background:var(--kc-primary);color:var(--kc-on-primary);border-color:var(--kc-primary)}
264
264
  .chip-home,.chip-back{border-color:#cfd4da;color:#4b5563}
265
265
  .composer{flex:none;display:flex;align-items:center;gap:8px;padding:8px 10px;border-block-start:1px solid #e3e6ea;background:#fff}
package/dist/kavchat.js CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";(()=>{var $e=["he","en","ar","ru","es","fr","de","pt","it","tr"],Qe={ך:"כ",ם:"מ",ן:"נ",ף:"פ",ץ:"צ",أ:"ا",إ:"ا",آ:"ا",ٱ:"ا",ة:"ه",ى:"ي",ؤ:"و",ئ:"ي",ё:"е",ß:"ss",ı:"i"};function Ve(n){return n>=768&&n<=879||n>=1425&&n<=1479||n>=1552&&n<=1562||n>=1611&&n<=1631||n===1648||n>=1750&&n<=1773}function Ge(n){let e=n.charCodeAt(0);return e>=48&&e<=57||e>=1632&&e<=1641||e>=1488&&e<=1514||e>=1568&&e<=1610||e>=1649&&e<=1747||e>=19968&&e<=40959?!0:n.toLowerCase()!==n.toUpperCase()}var Ye=n=>{try{return n.normalize("NFD")}catch(e){return n}};function ne(n){var e;let t=Ye(String(n!=null?n:"").toLowerCase()),u="";for(let o of t){let r=o.charCodeAt(0);if(Ve(r))continue;let a=(e=Qe[o])!=null?e:o;u+=a.length===1&&!Ge(a)?" ":a}let i=u.replace(/\s+/g," ").trim();return i?i.split(" "):[]}var We={he:["איך","מה","אני","של","עם","את","זה","יש","אפשר","לי","על","או","גם","רוצה","צריך","האם","למה","מתי","איפה","כמה","אתם","שלי","לכם","אין","לא"],en:["how","what","i","my","me","the","a","an","is","are","do","does","can","to","of","in","on","for","with","and","or","it","you","your","want","need","please","when","where","why","which","there","this","that","be","get","not","no"],ar:["كيف","ماذا","ما","انا","في","على","من","الى","عن","هل","هذا","هذه","او","و","لي","متى","اين","لماذا","كم","اريد","ممكن","لا"],ru:["как","что","я","мне","мой","моя","в","на","с","и","или","не","это","где","когда","почему","сколько","можно","хочу","нужно","у","по","для","ли","есть"],es:["como","que","yo","mi","me","el","la","los","las","un","una","de","del","en","con","por","para","y","o","es","se","puedo","quiero","cuando","donde","cual","hay","no"],fr:["comment","que","quoi","je","mon","ma","mes","le","la","les","un","une","de","des","du","en","avec","pour","et","ou","est","il","elle","puis","veux","quand","ou","pourquoi","combien","ne","pas","j","l","d","qu"],de:["wie","was","ich","mein","meine","mir","der","die","das","ein","eine","und","oder","in","mit","fur","von","zu","ist","kann","mochte","wann","wo","warum","nicht","es","den","dem"],pt:["como","que","eu","meu","minha","o","a","os","as","um","uma","de","do","da","em","no","na","com","para","por","e","ou","posso","quero","quando","onde","porque","nao"],it:["come","che","cosa","io","mio","mia","il","lo","la","i","gli","le","un","una","di","del","della","in","con","per","e","o","posso","voglio","quando","dove","perche","non","l"],tr:["nasil","ne","ben","benim","bir","ve","veya","ile","icin","bu","su","mi","mu","nerede","ne zaman","neden","kac","istiyorum","var","yok","de","da"]},q={};for(let n of $e)q[n]=new Set(We[n].flatMap(e=>ne(e)));var Je=["ו","ה","ב","ל","מ","ש","כ"],Xe=["وال","بال","لل","كال","فال","ال","و","ب","ل","ف"],Ze=n=>n>=97&&n<=122||n>=224&&n<=591;function et(n){let e=n,t=e.charCodeAt(0);if(Ze(t))return e.length>3&&e.endsWith("s")&&!/(ss|us|is)$/.test(e)?e.slice(0,-1):e;if(t>=1488&&t<=1514){for(let u=0;u<2&&(e.length>3&&Je.includes(e[0]));u++)e=e.slice(1);return e}if(t>=1568&&t<=1610){for(let u of Xe)if(e.startsWith(u)&&e.length-u.length>=3)return e.slice(u.length)}return e}function ue(n,e="en"){var t;let u=(t=q[e])!=null?t:q.en,i=q.en;return ne(n).filter(o=>o.length>1&&!u.has(o)&&!i.has(o)).map(et)}function tt(n,e){if(n===e)return!0;if(Math.abs(n.length-e.length)>1||Math.min(n.length,e.length)<4)return!1;if(n.length===e.length){let o=[];for(let r=0;r<n.length&&o.length<=2;r++)n[r]!==e[r]&&o.push(r);if(o.length===2&&o[1]===o[0]+1&&n[o[0]]===e[o[1]]&&n[o[1]]===e[o[0]])return!0}let t=0,u=0,i=0;for(;t<n.length&&u<e.length;){if(n[t]===e[u]){t++,u++;continue}if(++i>1)return!1;n.length>e.length?t++:(e.length>n.length||t++,u++)}return i+(n.length-t)+(e.length-u)<=1}var ut=n=>String(n!=null?n:"").split(/\n\s*\n/).map(e=>e.trim()).filter(Boolean);function ie(n,e,t="en"){var u,i;let o=Array.from(new Set(ue(e,t)));if(o.length===0)return{kind:"none",matches:[]};let r=l=>l.flatMap(h=>ue(h,t)),a=[];for(let l of n){if(l.kind==="opening")continue;let h=l.content,w=new Map;for(let f of h.steps)for(let x of f.buttons){let g=x.action;g&&(g.type==="step"||g.type==="goto"&&!g.scriptId)&&w.set(g.stepId,[...(u=w.get(g.stepId))!=null?u:[],x.label])}for(let f of h.steps){let x=f.id===h.rootStepId,g=r([...f.keywords,...x?h.keywords:[]]),m=r([...x?[h.name]:[],...(i=w.get(f.id))!=null?i:[]]),d=0,v=[];for(let p of o)g.includes(p)?(d+=3,v.push({kind:"keyword",term:p})):m.includes(p)?(d+=2,v.push({kind:"title",term:p})):[...g,...m].some(k=>tt(p,k))&&(d+=.5,v.push({kind:"typo",term:p}));d>0&&a.push({scriptId:l.id,stepId:f.id,score:d,reasons:v})}}if(a.sort((l,h)=>h.score-l.score),a.length===0)return{kind:"none",matches:[]};let[c,b]=a;return!b||c.score>=b.score*2?{kind:"single",matches:[c]}:{kind:"multi",matches:a.filter(l=>l.score>=c.score/2).slice(0,3)}}var H={"chat.askAnswered":"Did that answer your question?","chat.yes":"Yes, thanks","chat.no":"No, I need help","chat.thanks":"Glad I could help!","chat.newQuestion":"New question","chat.back":"Back","chat.home":"Main menu","chat.didYouMean":"What did you mean?","chat.notFound":"I could not find an answer to that. Pick a topic from the menu, or talk to our team.","chat.notFoundTwice":"I could not find an answer. Our team will be happy to help, and your question is already in the form.","chat.contactChip":"Talk to our team","chat.openingContact":"Opening the contact form. This conversation will be attached to your request.","chat.chooseTopic":"How can I help?","chat.aiLabel":"AI answer","widget.open":"Open chat","widget.close":"Close chat","widget.placeholder":"Type your question...","widget.send":"Send","widget.poweredBy":"Powered by Kavchat","widget.offline":"You are offline. Showing saved answers.","widget.loading":"Loading...","widget.unavailable":"The assistant is not available right now.","form.title":"Contact us","form.name":"Name","form.email":"Email","form.phone":"Phone","form.topic":"Topic","form.message":"Message","form.submit":"Send","form.cancel":"Cancel","form.sending":"Sending...","form.sent":"Thanks! Your request #{number} was received. We will get back to you soon.","form.error":"Something went wrong. Please try again.","form.required":"Required","form.contactRequired":"Leave an email or a phone number so we can get back to you","form.emailInvalid":"Invalid email address","form.backToChat":"Back to chat"},nt={"chat.askAnswered":"קיבלת מענה?","chat.yes":"כן, תודה","chat.no":"לא, אני צריך עזרה","chat.thanks":"שמחתי לעזור!","chat.newQuestion":"שאלה חדשה","chat.back":"חזרה","chat.home":"תפריט ראשי","chat.didYouMean":"למה התכוונת?","chat.notFound":"לא מצאתי תשובה לשאלה הזו. אפשר לבחור נושא מהתפריט, או לפנות לצוות.","chat.notFoundTwice":"לא הצלחתי למצוא תשובה. הצוות ישמח לעזור, והשאלה שלך כבר תהיה כתובה בטופס.","chat.contactChip":"פנייה לצוות","chat.openingContact":"פותח את טופס הפנייה. מסלול השיחה יצורף לפנייה.","chat.chooseTopic":"במה אפשר לעזור?","chat.aiLabel":"תשובת AI","widget.open":"פתיחת הצ'אט","widget.close":"סגירת הצ'אט","widget.placeholder":"כתבו את השאלה...","widget.send":"שליחה","widget.poweredBy":"מופעל על ידי Kavchat","widget.offline":"אין חיבור לאינטרנט. מוצגות תשובות שמורות.","widget.loading":"טוען...","widget.unavailable":"העוזר לא זמין כרגע.","form.title":"פנייה לצוות","form.name":"שם","form.email":"אימייל","form.phone":"טלפון","form.topic":"נושא","form.message":"הודעה","form.submit":"שליחה","form.cancel":"ביטול","form.sending":"שולח...","form.sent":"תודה! פנייה מספר {number} התקבלה. נחזור אליכם בקרוב.","form.error":"משהו השתבש. נסו שוב.","form.required":"שדה חובה","form.contactRequired":"השאירו אימייל או טלפון כדי שנוכל לחזור אליכם","form.emailInvalid":"כתובת אימייל לא תקינה","form.backToChat":"חזרה לצ'אט"},it={"chat.askAnswered":"هل أجبت عن سؤالك؟","chat.yes":"نعم، شكرًا","chat.no":"لا، أحتاج مساعدة","chat.thanks":"سعدت بمساعدتك!","chat.newQuestion":"سؤال جديد","chat.back":"رجوع","chat.home":"القائمة الرئيسية","chat.didYouMean":"ماذا تقصد؟","chat.notFound":"لم أجد إجابة عن هذا السؤال. اختر موضوعًا من القائمة، أو تواصل مع فريقنا.","chat.notFoundTwice":"لم أتمكن من العثور على إجابة. يسعد فريقنا مساعدتك، وسؤالك مكتوب بالفعل في النموذج.","chat.contactChip":"تواصل مع الفريق","chat.openingContact":"جارٍ فتح نموذج التواصل. ستُرفق هذه المحادثة بطلبك.","chat.chooseTopic":"كيف يمكنني مساعدتك؟","chat.aiLabel":"إجابة من الذكاء الاصطناعي","widget.open":"فتح المحادثة","widget.close":"إغلاق المحادثة","widget.placeholder":"اكتب سؤالك...","widget.send":"إرسال","widget.poweredBy":"بدعم من Kavchat","widget.offline":"أنت غير متصل بالإنترنت. نعرض الإجابات المحفوظة.","widget.loading":"جارٍ التحميل...","widget.unavailable":"المساعد غير متاح حاليًا.","form.title":"تواصل معنا","form.name":"الاسم","form.email":"البريد الإلكتروني","form.phone":"الهاتف","form.topic":"الموضوع","form.message":"الرسالة","form.submit":"إرسال","form.cancel":"إلغاء","form.sending":"جارٍ الإرسال...","form.sent":"شكرًا! تم استلام طلبك رقم {number}. سنعود إليك قريبًا.","form.error":"حدث خطأ ما. يرجى المحاولة مرة أخرى.","form.required":"مطلوب","form.contactRequired":"اترك بريدًا إلكترونيًا أو رقم هاتف لنتمكن من الرد عليك","form.emailInvalid":"عنوان البريد الإلكتروني غير صالح","form.backToChat":"العودة إلى المحادثة"},ot={"chat.askAnswered":"Это ответило на ваш вопрос?","chat.yes":"Да, спасибо","chat.no":"Нет, нужна помощь","chat.thanks":"Рад помочь!","chat.newQuestion":"Новый вопрос","chat.back":"Назад","chat.home":"Главное меню","chat.didYouMean":"Что вы имели в виду?","chat.notFound":"Я не нашёл ответа на этот вопрос. Выберите тему в меню или напишите нашей команде.","chat.notFoundTwice":"Не удалось найти ответ. Наша команда с радостью поможет, а ваш вопрос уже добавлен в форму.","chat.contactChip":"Связаться с нами","chat.openingContact":"Открываю форму обращения. Этот диалог будет приложен к вашему запросу.","chat.chooseTopic":"Чем могу помочь?","chat.aiLabel":"Ответ ИИ","widget.open":"Открыть чат","widget.close":"Закрыть чат","widget.placeholder":"Введите ваш вопрос...","widget.send":"Отправить","widget.poweredBy":"Работает на Kavchat","widget.offline":"Нет подключения к интернету. Показываем сохранённые ответы.","widget.loading":"Загрузка...","widget.unavailable":"Ассистент сейчас недоступен.","form.title":"Связаться с нами","form.name":"Имя","form.email":"Email","form.phone":"Телефон","form.topic":"Тема","form.message":"Сообщение","form.submit":"Отправить","form.cancel":"Отмена","form.sending":"Отправка...","form.sent":"Спасибо! Ваше обращение №{number} получено. Мы скоро с вами свяжемся.","form.error":"Что-то пошло не так. Попробуйте ещё раз.","form.required":"Обязательное поле","form.contactRequired":"Укажите email или номер телефона, чтобы мы могли с вами связаться","form.emailInvalid":"Неверный адрес email","form.backToChat":"Вернуться в чат"},rt={"chat.askAnswered":"¿Resolvimos tu duda?","chat.yes":"Sí, gracias","chat.no":"No, necesito ayuda","chat.thanks":"¡Me alegra haberte ayudado!","chat.newQuestion":"Nueva pregunta","chat.back":"Atrás","chat.home":"Menú principal","chat.didYouMean":"¿Qué quisiste decir?","chat.notFound":"No encontré una respuesta para eso. Elige un tema del menú o habla con nuestro equipo.","chat.notFoundTwice":"No pude encontrar una respuesta. Nuestro equipo te ayudará con gusto, y tu pregunta ya está en el formulario.","chat.contactChip":"Hablar con el equipo","chat.openingContact":"Abriendo el formulario de contacto. Esta conversación se adjuntará a tu solicitud.","chat.chooseTopic":"¿En qué te puedo ayudar?","chat.aiLabel":"Respuesta de IA","widget.open":"Abrir chat","widget.close":"Cerrar chat","widget.placeholder":"Escribe tu pregunta...","widget.send":"Enviar","widget.poweredBy":"Con la tecnología de Kavchat","widget.offline":"Estás sin conexión. Mostrando respuestas guardadas.","widget.loading":"Cargando...","widget.unavailable":"El asistente no está disponible en este momento.","form.title":"Contáctanos","form.name":"Nombre","form.email":"Correo electrónico","form.phone":"Teléfono","form.topic":"Tema","form.message":"Mensaje","form.submit":"Enviar","form.cancel":"Cancelar","form.sending":"Enviando...","form.sent":"¡Gracias! Recibimos tu solicitud n.º {number}. Te responderemos pronto.","form.error":"Algo salió mal. Inténtalo de nuevo.","form.required":"Obligatorio","form.contactRequired":"Deja un correo o un teléfono para que podamos responderte","form.emailInvalid":"Correo electrónico no válido","form.backToChat":"Volver al chat"},at={"chat.askAnswered":"Avez-vous trouvé votre réponse ?","chat.yes":"Oui, merci","chat.no":"Non, aidez-moi","chat.thanks":"Ravi d'avoir pu vous aider !","chat.newQuestion":"Nouvelle question","chat.back":"Retour","chat.home":"Menu principal","chat.didYouMean":"Que vouliez-vous dire ?","chat.notFound":"Je n'ai pas trouvé de réponse à cette question. Choisissez un sujet dans le menu ou contactez notre équipe.","chat.notFoundTwice":"Je n'ai pas trouvé de réponse. Notre équipe se fera un plaisir de vous aider, et votre question figure déjà dans le formulaire.","chat.contactChip":"Contacter l'équipe","chat.openingContact":"Ouverture du formulaire de contact. Cette conversation sera jointe à votre demande.","chat.chooseTopic":"Comment puis-je vous aider ?","chat.aiLabel":"Réponse de l'IA","widget.open":"Ouvrir le chat","widget.close":"Fermer le chat","widget.placeholder":"Écrivez votre question...","widget.send":"Envoyer","widget.poweredBy":"Propulsé par Kavchat","widget.offline":"Vous êtes hors ligne. Affichage des réponses enregistrées.","widget.loading":"Chargement...","widget.unavailable":"L'assistant n'est pas disponible pour le moment.","form.title":"Nous contacter","form.name":"Nom","form.email":"E-mail","form.phone":"Téléphone","form.topic":"Sujet","form.message":"Message","form.submit":"Envoyer","form.cancel":"Annuler","form.sending":"Envoi en cours...","form.sent":"Merci ! Votre demande n° {number} a bien été reçue. Nous vous répondrons rapidement.","form.error":"Une erreur s'est produite. Veuillez réessayer.","form.required":"Obligatoire","form.contactRequired":"Indiquez un e-mail ou un numéro de téléphone pour que nous puissions vous répondre","form.emailInvalid":"Adresse e-mail invalide","form.backToChat":"Retour au chat"},st={"chat.askAnswered":"Hat Ihnen das weitergeholfen?","chat.yes":"Ja, danke","chat.no":"Nein, Hilfe bitte","chat.thanks":"Freut mich, dass ich helfen konnte!","chat.newQuestion":"Neue Frage","chat.back":"Zurück","chat.home":"Hauptmenü","chat.didYouMean":"Was meinten Sie?","chat.notFound":"Dazu habe ich leider keine Antwort gefunden. Wählen Sie ein Thema aus dem Menü oder wenden Sie sich an unser Team.","chat.notFoundTwice":"Ich konnte keine Antwort finden. Unser Team hilft Ihnen gerne weiter, und Ihre Frage steht bereits im Formular.","chat.contactChip":"Team kontaktieren","chat.openingContact":"Das Kontaktformular wird geöffnet. Dieser Chatverlauf wird Ihrer Anfrage beigefügt.","chat.chooseTopic":"Wie kann ich helfen?","chat.aiLabel":"KI-Antwort","widget.open":"Chat öffnen","widget.close":"Chat schließen","widget.placeholder":"Ihre Frage eingeben...","widget.send":"Senden","widget.poweredBy":"Bereitgestellt von Kavchat","widget.offline":"Sie sind offline. Gespeicherte Antworten werden angezeigt.","widget.loading":"Wird geladen...","widget.unavailable":"Der Assistent ist gerade nicht verfügbar.","form.title":"Kontakt","form.name":"Name","form.email":"E-Mail","form.phone":"Telefon","form.topic":"Thema","form.message":"Nachricht","form.submit":"Senden","form.cancel":"Abbrechen","form.sending":"Wird gesendet...","form.sent":"Vielen Dank! Ihre Anfrage Nr. {number} ist eingegangen. Wir melden uns in Kürze bei Ihnen.","form.error":"Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut.","form.required":"Pflichtfeld","form.contactRequired":"Bitte geben Sie eine E-Mail-Adresse oder Telefonnummer an, damit wir uns melden können","form.emailInvalid":"Ungültige E-Mail-Adresse","form.backToChat":"Zurück zum Chat"},ct={"chat.askAnswered":"Isso respondeu à sua pergunta?","chat.yes":"Sim, obrigado","chat.no":"Não, preciso de ajuda","chat.thanks":"Que bom que pude ajudar!","chat.newQuestion":"Nova pergunta","chat.back":"Voltar","chat.home":"Menu principal","chat.didYouMean":"O que você quis dizer?","chat.notFound":"Não encontrei uma resposta para isso. Escolha um assunto no menu ou fale com a nossa equipe.","chat.notFoundTwice":"Não consegui encontrar uma resposta. Nossa equipe vai ajudar com prazer, e sua pergunta já está no formulário.","chat.contactChip":"Falar com a equipe","chat.openingContact":"Abrindo o formulário de contato. Esta conversa será anexada à sua solicitação.","chat.chooseTopic":"Como posso ajudar?","chat.aiLabel":"Resposta de IA","widget.open":"Abrir chat","widget.close":"Fechar chat","widget.placeholder":"Digite sua pergunta...","widget.send":"Enviar","widget.poweredBy":"Desenvolvido por Kavchat","widget.offline":"Você está offline. Mostrando respostas salvas.","widget.loading":"Carregando...","widget.unavailable":"O assistente não está disponível no momento.","form.title":"Fale conosco","form.name":"Nome","form.email":"E-mail","form.phone":"Telefone","form.topic":"Assunto","form.message":"Mensagem","form.submit":"Enviar","form.cancel":"Cancelar","form.sending":"Enviando...","form.sent":"Obrigado! Sua solicitação nº {number} foi recebida. Retornaremos em breve.","form.error":"Algo deu errado. Tente novamente.","form.required":"Obrigatório","form.contactRequired":"Informe um e-mail ou telefone para que possamos retornar","form.emailInvalid":"Endereço de e-mail inválido","form.backToChat":"Voltar ao chat"},lt={"chat.askAnswered":"Hai trovato la risposta?","chat.yes":"Sì, grazie","chat.no":"No, mi serve aiuto","chat.thanks":"Felice di esserti stato utile!","chat.newQuestion":"Nuova domanda","chat.back":"Indietro","chat.home":"Menu principale","chat.didYouMean":"Cosa intendevi?","chat.notFound":"Non ho trovato una risposta. Scegli un argomento dal menu o parla con il nostro team.","chat.notFoundTwice":"Non sono riuscito a trovare una risposta. Il nostro team sarà felice di aiutarti, e la tua domanda è già nel modulo.","chat.contactChip":"Parla con il team","chat.openingContact":"Apro il modulo di contatto. Questa conversazione sarà allegata alla tua richiesta.","chat.chooseTopic":"Come posso aiutarti?","chat.aiLabel":"Risposta dell'IA","widget.open":"Apri la chat","widget.close":"Chiudi la chat","widget.placeholder":"Scrivi la tua domanda...","widget.send":"Invia","widget.poweredBy":"Powered by Kavchat","widget.offline":"Sei offline. Mostro le risposte salvate.","widget.loading":"Caricamento...","widget.unavailable":"L'assistente non è disponibile al momento.","form.title":"Contattaci","form.name":"Nome","form.email":"Email","form.phone":"Telefono","form.topic":"Argomento","form.message":"Messaggio","form.submit":"Invia","form.cancel":"Annulla","form.sending":"Invio in corso...","form.sent":"Grazie! La tua richiesta n. {number} è stata ricevuta. Ti risponderemo presto.","form.error":"Qualcosa è andato storto. Riprova.","form.required":"Obbligatorio","form.contactRequired":"Lascia un'email o un numero di telefono per poterti ricontattare","form.emailInvalid":"Indirizzo email non valido","form.backToChat":"Torna alla chat"},dt={"chat.askAnswered":"Sorunuza yanıt bulabildiniz mi?","chat.yes":"Evet, teşekkürler","chat.no":"Hayır, yardım lazım","chat.thanks":"Yardımcı olabildiğime sevindim!","chat.newQuestion":"Yeni soru","chat.back":"Geri","chat.home":"Ana menü","chat.didYouMean":"Ne demek istediniz?","chat.notFound":"Bununla ilgili bir yanıt bulamadım. Menüden bir konu seçin veya ekibimizle görüşün.","chat.notFoundTwice":"Bir yanıt bulamadım. Ekibimiz size memnuniyetle yardımcı olur, sorunuz forma zaten eklendi.","chat.contactChip":"Ekibe ulaşın","chat.openingContact":"İletişim formu açılıyor. Bu konuşma talebinize eklenecek.","chat.chooseTopic":"Size nasıl yardımcı olabilirim?","chat.aiLabel":"Yapay zekâ yanıtı","widget.open":"Sohbeti aç","widget.close":"Sohbeti kapat","widget.placeholder":"Sorunuzu yazın...","widget.send":"Gönder","widget.poweredBy":"Kavchat ile desteklenmektedir","widget.offline":"Çevrimdışısınız. Kayıtlı yanıtlar gösteriliyor.","widget.loading":"Yükleniyor...","widget.unavailable":"Asistan şu anda kullanılamıyor.","form.title":"Bize ulaşın","form.name":"Ad","form.email":"E-posta","form.phone":"Telefon","form.topic":"Konu","form.message":"Mesaj","form.submit":"Gönder","form.cancel":"İptal","form.sending":"Gönderiliyor...","form.sent":"Teşekkürler! {number} numaralı talebiniz alındı. En kısa sürede size dönüş yapacağız.","form.error":"Bir sorun oluştu. Lütfen tekrar deneyin.","form.required":"Zorunlu","form.contactRequired":"Size dönüş yapabilmemiz için bir e-posta veya telefon numarası bırakın","form.emailInvalid":"Geçersiz e-posta adresi","form.backToChat":"Sohbete dön"},N={en:H,he:nt,ar:it,ru:ot,es:rt,fr:at,de:st,pt:ct,it:lt,tr:dt},pt=["he","ar"],oe=n=>pt.includes(re(n)),re=n=>String(n||"en").toLowerCase().split(/[-_]/)[0].replace(/^iw$/,"he");function O(n,e){var t;let u=(t=N[re(n)])!=null?t:H;return{...H,...u,...e!=null?e:{}}}var ae=(n,e)=>n.replace(/\{(\w+)\}/g,(t,u)=>e[u]!==void 0?String(e[u]):t),A={now:()=>Date.now()};function j(n){A={...A,...n}}var D=n=>O(n.locale,A.texts),$=()=>new Date(A.now()).toISOString();function se(n,e,t){let u=n.scripts[e],i=u==null?void 0:u.content.steps.find(o=>o.id===t);return u&&i?{script:u,step:i}:null}var Q=n=>Object.values(n.scripts).filter(e=>e.kind!=="opening").sort((e,t)=>e.sortOrder-t.sortOrder),ce=n=>Q(n).map(e=>({id:`script:${e.id}`,label:e.content.name,kind:"button",action:{type:"script",scriptId:e.id}})),I=n=>({id:"home",label:D(n)["chat.home"],kind:"home"}),U=n=>{let e=[];return n.history.length>0&&e.push({id:"back",label:D(n)["chat.back"],kind:"back"}),e.push(I(n)),e},L=(n,e)=>({id:"contact",label:D(n)["chat.contactChip"],kind:"contact",...e?{prefill:e}:{}});function E(n,e,t,u={}){return(e==="bot"?ut(t):[t]).reduce((o,r)=>({...o,seq:o.seq+1,messages:[...o.messages,{id:`m${o.seq+1}`,from:e,text:r,at:A.now(),...u}]}),n)}var le=(n,e,t,u)=>({...n,path:[...n.path,{scriptId:e,stepId:t,via:u,at:$()}]});function y(n,e){let t=n.scripts[n.openingId],u=t==null?void 0:t.content.steps.find(r=>r.id===t.content.rootStepId),i=n.userName?`, ${n.userName}`:"",o={...n,position:null,history:[],outcome:"open"};if(e==="start"){let r=((u==null?void 0:u.text)||D(n)["chat.chooseTopic"]).replace(/\{name\}/g,i);o=E(o,"bot",r,u!=null&&u.imageUrl?{imageUrl:u.imageUrl}:{})}else o=E(o,"bot",D(n)["chat.chooseTopic"]);return o=le(o,n.openingId,(u==null?void 0:u.id)||"welcome",e),{...o,chips:[...ce(o),L(o)]}}function C(n,e,t,u,i=!0){let o=se(n,e,t);if(!o)return y(n,"home");let{step:r}=o,a={...n,history:i&&n.position?[...n.history,n.position]:n.history,position:{scriptId:e,stepId:t},lastScriptId:e};if(a=E(a,"bot",r.text,{stepId:t,scriptId:e,...r.imageUrl?{imageUrl:r.imageUrl}:{}}),a=le(a,e,t,u),r.buttons.length>0){let c=r.buttons.map(b=>({id:`btn:${b.id}`,label:b.label,kind:"button",action:b.action}));return{...a,chips:[...c,...U(a)]}}return a=E(a,"bot",D(a)["chat.askAnswered"]),{...a,chips:[{id:"yes",label:D(a)["chat.yes"],kind:"yes"},{id:"no",label:D(a)["chat.no"],kind:"no"},...U(a)]}}function ht(n){return n.messages.map(e=>({from:e.from,text:e.text,...e.stepId?{stepId:e.stepId}:{},at:new Date(e.at).toISOString()}))}function de(n,e){let t=n.lastScriptId?n.scripts[n.lastScriptId]:null,u={type:"contact",contactTopicId:(t==null?void 0:t.content.contactTopicId)||null,scriptId:n.lastScriptId,prefill:e||"",transcript:ht(n)},i=E({...n,outcome:"contact"},"bot",D(n)["chat.openingContact"]);return{state:{...i,chips:[I(i)]},effect:u}}function pe(n){let e={scripts:Object.fromEntries(n.scripts.map(t=>[t.id,t])),openingId:n.openingScriptId,locale:n.locale||"en",userName:n.userName||"",messages:[],chips:[],position:null,history:[],path:[],unmatched:[],misses:0,outcome:"open",lastScriptId:null,lastMatch:null,seq:0};return y(e,"start")}function ft(n,e,t){var u;let i=(u=n.position)==null?void 0:u.scriptId;if(!e)return{state:y(n,"home")};switch(e.type){case"script":{let o=n.scripts[e.scriptId];return o?{state:C(n,o.id,o.content.rootStepId,"button")}:{state:y(n,"home")}}case"step":return{state:C(n,i||"",e.stepId,"button")};case"goto":return{state:C(n,e.scriptId||i||"",e.stepId,"button")};case"contact":return de(n);case"screen":case"link":return{state:{...n,chips:t.length?t:U(n)},effect:e};default:return{state:y(n,"home")}}}function he(n,e){let t={...E(n,"user",e.label),chips:[],lastMatch:null};switch(e.kind){case"home":return{state:y(t,"home")};case"back":{let u=t.history[t.history.length-1];return u?(t={...t,history:t.history.slice(0,-1),position:null},{state:C(t,u.scriptId,u.stepId,"back",!1)}):{state:y(t,"home")}}case"yes":return t=E({...t,outcome:"answered"},"bot",D(t)["chat.thanks"]),{state:{...t,chips:[{id:"new",label:D(t)["chat.newQuestion"],kind:"home"}]}};case"no":case"contact":return de(t,e.prefill);case"pick":return e.target?{state:C(t,e.target.scriptId,e.target.stepId,"text")}:{state:y(t,"home")};default:return ft(t,e.action,n.chips)}}function mt(n,e){let t=se(n,e.scriptId,e.stepId);if(!t)return"";let{script:u,step:i}=t;if(i.id===u.content.rootStepId)return u.content.name;for(let o of u.content.steps){let r=o.buttons.find(a=>a.action&&"stepId"in a.action&&a.action.stepId===i.id);if(r)return r.label}return i.text.slice(0,25)}function V(n,e){let t=String(e!=null?e:"").trim().slice(0,500);if(!t)return{state:n};let u={...E(n,"user",t),chips:[]},i=ie(Q(u),t,u.locale);if(u={...u,lastMatch:i},i.kind==="single"){let o=i.matches[0];return{state:{...C(u,o.scriptId,o.stepId,"text"),misses:0,lastMatch:i}}}if(i.kind==="multi"){u=E({...u,misses:0},"bot",D(u)["chat.didYouMean"]);let o=i.matches.map(r=>({id:`pick:${r.scriptId}:${r.stepId}`,label:mt(u,r),kind:"pick",target:{scriptId:r.scriptId,stepId:r.stepId}}));return{state:{...u,chips:[...o,I(u)]}}}return u={...u,misses:u.misses+1,unmatched:[...u.unmatched,{text:t,at:$()}]},u.misses>=2?(u=E(u,"bot",D(u)["chat.notFoundTwice"]),{state:{...u,chips:[L(u,t),I(u)]}}):(u=E(u,"bot",D(u)["chat.notFound"]),{state:{...u,chips:[...ce(u),L(u,t)]}})}var gt=300,Dt=600;function fe(n,e){let t=String(e!=null?e:"").trim().slice(0,500);return!t||ie(Q(n),t,n.locale).kind!=="none"?null:t.slice(0,gt)}function me(n,e){let t=String(e!=null?e:"").trim().slice(0,500);return t?{...E(n,"user",t),chips:[]}:n}function ge(n,e,t,u){let i=String(e!=null?e:"").trim().slice(0,500),o=String(t!=null?t:"").trim().slice(0,Dt);if(!i||!o)return V(n,e);let r={...E(n,"user",i),chips:[],lastMatch:{kind:"none",matches:[]},misses:0,unmatched:[...n.unmatched,{text:i,at:$()}]};r={...r,seq:r.seq+1,messages:[...r.messages,{id:`m${r.seq+1}`,from:"bot",text:o,at:A.now(),ai:!0}]};let a=u?r.scripts[u]:void 0,c=[];return a&&a.kind!=="opening"&&c.push({id:`script:${a.id}`,label:a.content.name,kind:"button",action:{type:"script",scriptId:a.id}}),{state:{...r,chips:[...c,L(r,i),I(r)]}}}function De(n,e,t,u){return{sessionId:e,releaseVersion:t,startedAt:u,outcome:n.outcome,path:n.path.slice(-200),unmatched:n.unmatched.slice(-20)}}var Ee=(n,e)=>`${n.apiBase.replace(/\/+$/,"")}/v1/client/${encodeURIComponent(n.publicKey)}/${e}`;function be(n,e={}){let t=n.getToken();return t?{...e,Authorization:`Bearer ${t}`}:e}async function ve(n,e){let t;try{t=await fetch(Ee(n,"release"),{method:"GET",cache:"no-store",credentials:"omit",headers:be(n,e?{"If-None-Match":e}:{})})}catch(i){return{kind:"offline"}}if(t.status===304)return{kind:"not-modified"};if(t.status>=500||t.status===429)return{kind:"offline"};if(!t.ok)return{kind:"denied",status:t.status};let u=await t.json().catch(()=>null);return!u||u.success!==!0||!u.data||typeof u.data.enabled!="boolean"?{kind:"offline"}:{kind:"ok",release:u.data,etag:t.headers.get("ETag")||""}}function z(n,e,t,u=!1,i){return fetch(Ee(n,e),{method:"POST",cache:"no-store",credentials:"omit",keepalive:u,signal:i,headers:be(n,{"Content-Type":"application/json"}),body:JSON.stringify(t)})}var Et=2e4;async function xe(n,e,t){let u=new AbortController,i=setTimeout(()=>u.abort(),Et);try{let o=await z(n,"ai/answer",{sessionId:e,question:t},!1,u.signal),r=o.ok&&(await o.json()).data;return r&&typeof r.answer=="string"&&r.answer.trim()?{answer:r.answer,scriptId:r.scriptId||null}:null}catch(o){return null}finally{clearTimeout(i)}}async function we(n,e,t=!1){try{return(await z(n,"events",e,t)).ok}catch(u){return!1}}async function ye(n,e){try{return(await z(n,"screens",{platform:"web",screens:e})).ok}catch(t){return!1}}async function ke(n,e){try{let t=await z(n,"tickets",e),u=await t.json().catch(()=>null);return t.ok&&u&&u.success&&u.data?{ok:!0,id:String(u.data.id),number:Number(u.data.number)}:{ok:!1,code:String((u==null?void 0:u.code)||`http_${t.status}`),message:String((u==null?void 0:u.message)||"")}}catch(t){return{ok:!1,code:"network",message:""}}}var bt="#2563eb",G="#111827",Y="#ffffff";function J(n){let e=/^#([0-9a-f]{6})$/i.exec(String(n||"").trim());if(!e)return null;let t=parseInt(e[1],16);return[t>>16&255,t>>8&255,t&255]}function Ce(n){let[e,t,u]=n.map(i=>{let o=i/255;return o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4)});return .2126*e+.7152*t+.0722*u}function W(n,e){var i,o;let t=Ce((i=J(n))!=null?i:[0,0,0]),u=Ce((o=J(e))!=null?o:[0,0,0]);return(Math.max(t,u)+.05)/(Math.min(t,u)+.05)}function Ae(n){let e=J(n)?n.toLowerCase():bt,t=W(e,Y)>=W(e,G)?Y:G,u=W(e,Y)>=3?e:G;return{primary:e,onPrimary:t,accent:u}}function s(n,e,...t){let u=document.createElement(n);if(e)for(let[i,o]of Object.entries(e))o==null||o===!1||u.setAttribute(i,o===!0?"":o);return K(u,t),u}function K(n,e){for(let t of e)t==null||t===!1||n.appendChild(typeof t=="string"?document.createTextNode(t):t)}var Fe="http://www.w3.org/2000/svg";function F(n){let e=document.createElementNS(Fe,"svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("width","24"),e.setAttribute("height","24"),e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false");let t=document.createElementNS(Fe,"path");return t.setAttribute("d",n),t.setAttribute("fill","currentColor"),e.appendChild(t),e}var S={chat:"M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z",close:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z",send:"M2.01 21 23 12 2.01 3 2 10l15 2-15 2z"};function B(n,e){try{let t=new URL(String(n||"").trim());return e.includes(t.protocol)?t.href:null}catch(t){return null}}var X=/https:\/\/[^\s<>"'`]+/g,vt=/[.,;:!?)\]}'"»]+$/;function Se(n){let e=document.createDocumentFragment(),t=0;X.lastIndex=0;let u;for(;u=X.exec(n);){let i=u[0].replace(vt,""),o=B(i,["https:"]);if(!o||!i)continue;u.index>t&&e.appendChild(document.createTextNode(n.slice(t,u.index)));let r=s("a",{href:o,target:"_blank",rel:"noopener noreferrer"},i);e.appendChild(r),t=u.index+i.length,X.lastIndex=t}return t<n.length&&e.appendChild(document.createTextNode(n.slice(t))),e}var Te=n=>`kavchat:release:${n}`,Ie=n=>`kavchat:session:${n}`,Be=n=>`kavchat:screens:${n}`;function Z(n,e){try{let t=n().getItem(e);return t?JSON.parse(t):null}catch(t){return null}}function ee(n,e,t){try{n().setItem(e,JSON.stringify(t))}catch(u){}}var _=()=>window.localStorage,Re=()=>window.sessionStorage,Me=n=>Z(_,Te(n)),qe=(n,e)=>ee(_,Te(n),e),Le=n=>Z(_,Be(n)),Ne=(n,e)=>ee(_,Be(n),e),Oe=n=>Z(Re,Ie(n)),ze=(n,e)=>ee(Re,Ie(n),e),xt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";function Ke(n=22){let e=new Uint8Array(n);if(typeof crypto!="undefined"&&crypto.getRandomValues)crypto.getRandomValues(e);else for(let u=0;u<n;u++)e[u]=Math.floor(Math.random()*256);let t="";for(let u=0;u<n;u++)t+=xt[e[u]&63];return t}var _e=`
1
+ "use strict";(()=>{var Yu=["he","en","ar","ru","es","fr","de","pt","it","tr","th"],Wu={ך:"כ",ם:"מ",ן:"נ",ף:"פ",ץ:"צ",أ:"ا",إ:"ا",آ:"ا",ٱ:"ا",ة:"ه",ى:"ي",ؤ:"و",ئ:"ي",ё:"е",ß:"ss",ı:"i"};function Ju(e){return e>=768&&e<=879||e>=1425&&e<=1479||e>=1552&&e<=1562||e>=1611&&e<=1631||e===1648||e>=1750&&e<=1773}function au(e){return e>=3585&&e<=3630||e>=3632&&e<=3642||e>=3648&&e<=3653||e>=3655&&e<=3662||e>=3713&&e<=3758||e>=3760&&e<=3781||e>=3784&&e<=3790||e>=3804&&e<=3807||e>=4096&&e<=4169||e>=4176&&e<=4253||e>=6016&&e<=6099||e===6108||e===6109||e===12293||e>=12353&&e<=12438||e>=12441&&e<=12442||e>=12445&&e<=12447||e>=12449&&e<=12538||e>=12540&&e<=12543||e>=13312&&e<=19903||e>=19968&&e<=40959}function U(e){for(let u=0;u<e.length;u++)if(au(e.charCodeAt(u)))return!0;return!1}function Xu(e){let u=e.charCodeAt(0);return u>=48&&u<=57||u>=1632&&u<=1641||u>=1488&&u<=1514||u>=1568&&u<=1610||u>=1649&&u<=1747||au(u)?!0:e.toLowerCase()!==e.toUpperCase()}var Zu=e=>e>=8203&&e<=8205||e===8288||e===65279,ue=[3664,3792,4160,6112];function ee(e){for(let u of ue)if(e>=u&&e<=u+9)return String.fromCharCode(48+e-u)}var q={3640:103,3641:103,3642:9,3656:107,3657:107,3658:107,3659:107,3768:118,3769:118,3770:9,3784:122,3785:122,3786:122,3787:122,4151:7,4153:9,4154:9,4237:220,6098:9,6109:230,12441:8,12442:8},ou=e=>e>=3656&&e<=3659;function te(e){if(!/[\u0e33\u0e38-\u0e3a\u0e48-\u0e4b\u0e4d\u0eb8-\u0eba\u0ec8-\u0ecb\u1037\u1039\u103a\u108d\u17d2\u17dd\u3099\u309a]/.test(e))return e;let u=[];for(let t=0;t<e.length;t++)u.push(e.charCodeAt(t));for(let t=0;t<u.length;t++){if(!q[u[t]])continue;let i=t;for(;i<u.length&&q[u[i]];)i++;for(let o=t+1;o<i;o++){let r=u[o],a=o-1;for(;a>=t&&q[u[a]]>q[r];)u[a+1]=u[a],a--;u[a+1]=r}t=i-1}let n="";for(let t=0;t<u.length;t++){let i=u[t];i===3661&&u[t+1]===3634?(n+="ำ",t++):i===3661&&ou(u[t+1])&&u[t+2]===3634?(n+=String.fromCharCode(u[t+1],3635),t+=2):i===3635&&ou(u[t+1])?(n+=String.fromCharCode(u[t+1],3635),t++):n+=String.fromCharCode(i)}return n}var ne=e=>{try{return e.normalize("NFD")}catch(u){return e}};function $(e){var u,n;let t=ne(String(e!=null?e:"").toLowerCase()),i="";for(let r of t){let a=r.charCodeAt(0);if(Ju(a)||Zu(a))continue;let c=(n=(u=Wu[r])!=null?u:ee(a))!=null?n:r;i+=c.length===1&&!Xu(c)?" ":c}let o=te(i).replace(/\s+/g," ").trim();return o?o.split(" "):[]}var ie={he:["איך","מה","אני","של","עם","את","זה","יש","אפשר","לי","על","או","גם","רוצה","צריך","האם","למה","מתי","איפה","כמה","אתם","שלי","לכם","אין","לא"],en:["how","what","i","my","me","the","a","an","is","are","do","does","can","to","of","in","on","for","with","and","or","it","you","your","want","need","please","when","where","why","which","there","this","that","be","get","not","no"],ar:["كيف","ماذا","ما","انا","في","على","من","الى","عن","هل","هذا","هذه","او","و","لي","متى","اين","لماذا","كم","اريد","ممكن","لا"],ru:["как","что","я","мне","мой","моя","в","на","с","и","или","не","это","где","когда","почему","сколько","можно","хочу","нужно","у","по","для","ли","есть"],es:["como","que","yo","mi","me","el","la","los","las","un","una","de","del","en","con","por","para","y","o","es","se","puedo","quiero","cuando","donde","cual","hay","no"],fr:["comment","que","quoi","je","mon","ma","mes","le","la","les","un","une","de","des","du","en","avec","pour","et","ou","est","il","elle","puis","veux","quand","ou","pourquoi","combien","ne","pas","j","l","d","qu"],de:["wie","was","ich","mein","meine","mir","der","die","das","ein","eine","und","oder","in","mit","fur","von","zu","ist","kann","mochte","wann","wo","warum","nicht","es","den","dem"],pt:["como","que","eu","meu","minha","o","a","os","as","um","uma","de","do","da","em","no","na","com","para","por","e","ou","posso","quero","quando","onde","porque","nao"],it:["come","che","cosa","io","mio","mia","il","lo","la","i","gli","le","un","una","di","del","della","in","con","per","e","o","posso","voglio","quando","dove","perche","non","l"],tr:["nasil","ne","ben","benim","bir","ve","veya","ile","icin","bu","su","mi","mu","nerede","ne zaman","neden","kac","istiyorum","var","yok","de","da"],th:["ฉัน","ผม","ดิฉัน","คุณ","ครับ","ค่ะ","คะ","นะ","ไหม","มั้ย","อะไร","อย่างไร","ยังไง","ที่","และ","หรือ","ของ","ได้","จะ","ใน","กับ","เป็น","มี","ไม่","ให้","ว่า","อยาก","ต้องการ","เมื่อไหร่","ที่ไหน","ทำไม","เท่าไหร่"]},L={};for(let e of Yu)L[e]=new Set(ie[e].flatMap(u=>$(u)));var oe=["ו","ה","ב","ל","מ","ש","כ"],re=["وال","بال","لل","كال","فال","ال","و","ب","ل","ف"],ae=e=>e>=97&&e<=122||e>=224&&e<=591;function se(e){let u=e,n=u.charCodeAt(0);if(ae(n))return u.length>3&&u.endsWith("s")&&!/(ss|us|is)$/.test(u)?u.slice(0,-1):u;if(n>=1488&&n<=1514){for(let t=0;t<2&&(u.length>3&&oe.includes(u[0]));t++)u=u.slice(1);return u}if(n>=1568&&n<=1610){for(let t of re)if(u.startsWith(t)&&u.length-t.length>=3)return u.slice(t.length)}return u}function ru(e,u="en"){var n;let t=(n=L[u])!=null?n:L.en,i=L.en;return $(e).filter(o=>o.length>1&&!t.has(o)&&!i.has(o)).map(se)}function ce(e,u){if(e===u)return!0;if(Math.abs(e.length-u.length)>1||Math.min(e.length,u.length)<4)return!1;if(e.length===u.length){let o=[];for(let r=0;r<e.length&&o.length<=2;r++)e[r]!==u[r]&&o.push(r);if(o.length===2&&o[1]===o[0]+1&&e[o[0]]===u[o[1]]&&e[o[1]]===u[o[0]])return!0}let n=0,t=0,i=0;for(;n<e.length&&t<u.length;){if(e[n]===u[t]){n++,t++;continue}if(++i>1)return!1;e.length>u.length?n++:(u.length>e.length||n++,t++)}return i+(e.length-n)+(u.length-t)<=1}var le=e=>String(e!=null?e:"").split(/\n\s*\n/).map(u=>u.trim()).filter(Boolean);function su(e,u,n="en"){var t,i;let o=Array.from(new Set(ru(u,n)));if(o.length===0)return{kind:"none",matches:[]};let r=p=>p.flatMap(E=>ru(E,n)),a=o.filter(p=>!U(p)),c=$(u).join(""),f=[];for(let p of e){if(p.kind==="opening")continue;let E=p.content,A=new Map;for(let b of E.steps)for(let d of b.buttons){let l=d.action;l&&(l.type==="step"||l.type==="goto"&&!l.scriptId)&&A.set(l.stepId,[...(t=A.get(l.stepId))!=null?t:[],d.label])}for(let b of E.steps){let d=b.id===E.rootStepId,l=r([...b.keywords,...d?E.keywords:[]]),w=r([...d?[E.name]:[],...(i=A.get(b.id))!=null?i:[]]),v=[...l,...w].filter(h=>!U(h)),x=0,y=[];for(let h of a)l.includes(h)?(x+=3,y.push({kind:"keyword",term:h})):w.includes(h)?(x+=2,y.push({kind:"title",term:h})):v.some(F=>ce(h,F))&&(x+=.5,y.push({kind:"typo",term:h}));for(let h of Ee(l,w,c))x+=h.weight,y.push({kind:h.weight===3?"keyword":"title",term:h.term});x>0&&f.push({scriptId:p.id,stepId:b.id,score:x,reasons:y})}}if(f.sort((p,E)=>E.score-p.score),f.length===0)return{kind:"none",matches:[]};let[m,k]=f;return!k||m.score>=k.score*2?{kind:"single",matches:[m]}:{kind:"multi",matches:f.filter(p=>p.score>=m.score/2).slice(0,3)}}function Ee(e,u,n){let t=[],i=new Set;for(let[o,r]of[[e,3],[u,2]])for(let a of o)i.has(a)||!U(a)||(i.add(a),n.includes(a)&&t.push({term:a,weight:r}));return t.filter(o=>!t.some(r=>r.term!==o.term&&r.weight>=o.weight&&r.term.includes(o.term)))}var j={"chat.askAnswered":"Did that answer your question?","chat.yes":"Yes, thanks","chat.no":"No, I need help","chat.thanks":"Glad I could help!","chat.newQuestion":"New question","chat.back":"Back","chat.home":"Main menu","chat.didYouMean":"What did you mean?","chat.notFound":"I could not find an answer to that. Pick a topic from the menu, or talk to our team.","chat.notFoundTwice":"I could not find an answer. Our team will be happy to help, and your question is already in the form.","chat.contactChip":"Talk to our team","chat.openingContact":"Opening the contact form. This conversation will be attached to your request.","chat.chooseTopic":"How can I help?","chat.aiLabel":"AI answer","widget.open":"Open chat","widget.close":"Close chat","widget.placeholder":"Type your question...","widget.send":"Send","widget.poweredBy":"Powered by Kavchat","widget.offline":"You are offline. Showing saved answers.","widget.loading":"Loading...","widget.unavailable":"The assistant is not available right now.","form.title":"Contact us","form.name":"Name","form.email":"Email","form.phone":"Phone","form.topic":"Topic","form.message":"Message","form.submit":"Send","form.cancel":"Cancel","form.sending":"Sending...","form.sent":"Thanks! Your request #{number} was received. We will get back to you soon.","form.error":"Something went wrong. Please try again.","form.required":"Required","form.contactRequired":"Leave an email or a phone number so we can get back to you","form.emailInvalid":"Invalid email address","form.backToChat":"Back to chat"},de={"chat.askAnswered":"קיבלת מענה?","chat.yes":"כן, תודה","chat.no":"לא, אני צריך עזרה","chat.thanks":"שמחתי לעזור!","chat.newQuestion":"שאלה חדשה","chat.back":"חזרה","chat.home":"תפריט ראשי","chat.didYouMean":"למה התכוונת?","chat.notFound":"לא מצאתי תשובה לשאלה הזו. אפשר לבחור נושא מהתפריט, או לפנות לצוות.","chat.notFoundTwice":"לא הצלחתי למצוא תשובה. הצוות ישמח לעזור, והשאלה שלך כבר תהיה כתובה בטופס.","chat.contactChip":"פנייה לצוות","chat.openingContact":"פותח את טופס הפנייה. מסלול השיחה יצורף לפנייה.","chat.chooseTopic":"במה אפשר לעזור?","chat.aiLabel":"תשובת AI","widget.open":"פתיחת הצ'אט","widget.close":"סגירת הצ'אט","widget.placeholder":"כתבו את השאלה...","widget.send":"שליחה","widget.poweredBy":"מופעל על ידי Kavchat","widget.offline":"אין חיבור לאינטרנט. מוצגות תשובות שמורות.","widget.loading":"טוען...","widget.unavailable":"העוזר לא זמין כרגע.","form.title":"פנייה לצוות","form.name":"שם","form.email":"אימייל","form.phone":"טלפון","form.topic":"נושא","form.message":"הודעה","form.submit":"שליחה","form.cancel":"ביטול","form.sending":"שולח...","form.sent":"תודה! פנייה מספר {number} התקבלה. נחזור אליכם בקרוב.","form.error":"משהו השתבש. נסו שוב.","form.required":"שדה חובה","form.contactRequired":"השאירו אימייל או טלפון כדי שנוכל לחזור אליכם","form.emailInvalid":"כתובת אימייל לא תקינה","form.backToChat":"חזרה לצ'אט"},pe={"chat.askAnswered":"هل أجبت عن سؤالك؟","chat.yes":"نعم، شكرًا","chat.no":"لا، أحتاج مساعدة","chat.thanks":"سعدت بمساعدتك!","chat.newQuestion":"سؤال جديد","chat.back":"رجوع","chat.home":"القائمة الرئيسية","chat.didYouMean":"ماذا تقصد؟","chat.notFound":"لم أجد إجابة عن هذا السؤال. اختر موضوعًا من القائمة، أو تواصل مع فريقنا.","chat.notFoundTwice":"لم أتمكن من العثور على إجابة. يسعد فريقنا مساعدتك، وسؤالك مكتوب بالفعل في النموذج.","chat.contactChip":"تواصل مع الفريق","chat.openingContact":"جارٍ فتح نموذج التواصل. ستُرفق هذه المحادثة بطلبك.","chat.chooseTopic":"كيف يمكنني مساعدتك؟","chat.aiLabel":"إجابة من الذكاء الاصطناعي","widget.open":"فتح المحادثة","widget.close":"إغلاق المحادثة","widget.placeholder":"اكتب سؤالك...","widget.send":"إرسال","widget.poweredBy":"بدعم من Kavchat","widget.offline":"أنت غير متصل بالإنترنت. نعرض الإجابات المحفوظة.","widget.loading":"جارٍ التحميل...","widget.unavailable":"المساعد غير متاح حاليًا.","form.title":"تواصل معنا","form.name":"الاسم","form.email":"البريد الإلكتروني","form.phone":"الهاتف","form.topic":"الموضوع","form.message":"الرسالة","form.submit":"إرسال","form.cancel":"إلغاء","form.sending":"جارٍ الإرسال...","form.sent":"شكرًا! تم استلام طلبك رقم {number}. سنعود إليك قريبًا.","form.error":"حدث خطأ ما. يرجى المحاولة مرة أخرى.","form.required":"مطلوب","form.contactRequired":"اترك بريدًا إلكترونيًا أو رقم هاتف لنتمكن من الرد عليك","form.emailInvalid":"عنوان البريد الإلكتروني غير صالح","form.backToChat":"العودة إلى المحادثة"},he={"chat.askAnswered":"Это ответило на ваш вопрос?","chat.yes":"Да, спасибо","chat.no":"Нет, нужна помощь","chat.thanks":"Рад помочь!","chat.newQuestion":"Новый вопрос","chat.back":"Назад","chat.home":"Главное меню","chat.didYouMean":"Что вы имели в виду?","chat.notFound":"Я не нашёл ответа на этот вопрос. Выберите тему в меню или напишите нашей команде.","chat.notFoundTwice":"Не удалось найти ответ. Наша команда с радостью поможет, а ваш вопрос уже добавлен в форму.","chat.contactChip":"Связаться с нами","chat.openingContact":"Открываю форму обращения. Этот диалог будет приложен к вашему запросу.","chat.chooseTopic":"Чем могу помочь?","chat.aiLabel":"Ответ ИИ","widget.open":"Открыть чат","widget.close":"Закрыть чат","widget.placeholder":"Введите ваш вопрос...","widget.send":"Отправить","widget.poweredBy":"Работает на Kavchat","widget.offline":"Нет подключения к интернету. Показываем сохранённые ответы.","widget.loading":"Загрузка...","widget.unavailable":"Ассистент сейчас недоступен.","form.title":"Связаться с нами","form.name":"Имя","form.email":"Email","form.phone":"Телефон","form.topic":"Тема","form.message":"Сообщение","form.submit":"Отправить","form.cancel":"Отмена","form.sending":"Отправка...","form.sent":"Спасибо! Ваше обращение №{number} получено. Мы скоро с вами свяжемся.","form.error":"Что-то пошло не так. Попробуйте ещё раз.","form.required":"Обязательное поле","form.contactRequired":"Укажите email или номер телефона, чтобы мы могли с вами связаться","form.emailInvalid":"Неверный адрес email","form.backToChat":"Вернуться в чат"},fe={"chat.askAnswered":"¿Resolvimos tu duda?","chat.yes":"Sí, gracias","chat.no":"No, necesito ayuda","chat.thanks":"¡Me alegra haberte ayudado!","chat.newQuestion":"Nueva pregunta","chat.back":"Atrás","chat.home":"Menú principal","chat.didYouMean":"¿Qué quisiste decir?","chat.notFound":"No encontré una respuesta para eso. Elige un tema del menú o habla con nuestro equipo.","chat.notFoundTwice":"No pude encontrar una respuesta. Nuestro equipo te ayudará con gusto, y tu pregunta ya está en el formulario.","chat.contactChip":"Hablar con el equipo","chat.openingContact":"Abriendo el formulario de contacto. Esta conversación se adjuntará a tu solicitud.","chat.chooseTopic":"¿En qué te puedo ayudar?","chat.aiLabel":"Respuesta de IA","widget.open":"Abrir chat","widget.close":"Cerrar chat","widget.placeholder":"Escribe tu pregunta...","widget.send":"Enviar","widget.poweredBy":"Con la tecnología de Kavchat","widget.offline":"Estás sin conexión. Mostrando respuestas guardadas.","widget.loading":"Cargando...","widget.unavailable":"El asistente no está disponible en este momento.","form.title":"Contáctanos","form.name":"Nombre","form.email":"Correo electrónico","form.phone":"Teléfono","form.topic":"Tema","form.message":"Mensaje","form.submit":"Enviar","form.cancel":"Cancelar","form.sending":"Enviando...","form.sent":"¡Gracias! Recibimos tu solicitud n.º {number}. Te responderemos pronto.","form.error":"Algo salió mal. Inténtalo de nuevo.","form.required":"Obligatorio","form.contactRequired":"Deja un correo o un teléfono para que podamos responderte","form.emailInvalid":"Correo electrónico no válido","form.backToChat":"Volver al chat"},me={"chat.askAnswered":"Avez-vous trouvé votre réponse ?","chat.yes":"Oui, merci","chat.no":"Non, aidez-moi","chat.thanks":"Ravi d'avoir pu vous aider !","chat.newQuestion":"Nouvelle question","chat.back":"Retour","chat.home":"Menu principal","chat.didYouMean":"Que vouliez-vous dire ?","chat.notFound":"Je n'ai pas trouvé de réponse à cette question. Choisissez un sujet dans le menu ou contactez notre équipe.","chat.notFoundTwice":"Je n'ai pas trouvé de réponse. Notre équipe se fera un plaisir de vous aider, et votre question figure déjà dans le formulaire.","chat.contactChip":"Contacter l'équipe","chat.openingContact":"Ouverture du formulaire de contact. Cette conversation sera jointe à votre demande.","chat.chooseTopic":"Comment puis-je vous aider ?","chat.aiLabel":"Réponse de l'IA","widget.open":"Ouvrir le chat","widget.close":"Fermer le chat","widget.placeholder":"Écrivez votre question...","widget.send":"Envoyer","widget.poweredBy":"Propulsé par Kavchat","widget.offline":"Vous êtes hors ligne. Affichage des réponses enregistrées.","widget.loading":"Chargement...","widget.unavailable":"L'assistant n'est pas disponible pour le moment.","form.title":"Nous contacter","form.name":"Nom","form.email":"E-mail","form.phone":"Téléphone","form.topic":"Sujet","form.message":"Message","form.submit":"Envoyer","form.cancel":"Annuler","form.sending":"Envoi en cours...","form.sent":"Merci ! Votre demande n° {number} a bien été reçue. Nous vous répondrons rapidement.","form.error":"Une erreur s'est produite. Veuillez réessayer.","form.required":"Obligatoire","form.contactRequired":"Indiquez un e-mail ou un numéro de téléphone pour que nous puissions vous répondre","form.emailInvalid":"Adresse e-mail invalide","form.backToChat":"Retour au chat"},ge={"chat.askAnswered":"Hat Ihnen das weitergeholfen?","chat.yes":"Ja, danke","chat.no":"Nein, Hilfe bitte","chat.thanks":"Freut mich, dass ich helfen konnte!","chat.newQuestion":"Neue Frage","chat.back":"Zurück","chat.home":"Hauptmenü","chat.didYouMean":"Was meinten Sie?","chat.notFound":"Dazu habe ich leider keine Antwort gefunden. Wählen Sie ein Thema aus dem Menü oder wenden Sie sich an unser Team.","chat.notFoundTwice":"Ich konnte keine Antwort finden. Unser Team hilft Ihnen gerne weiter, und Ihre Frage steht bereits im Formular.","chat.contactChip":"Team kontaktieren","chat.openingContact":"Das Kontaktformular wird geöffnet. Dieser Chatverlauf wird Ihrer Anfrage beigefügt.","chat.chooseTopic":"Wie kann ich helfen?","chat.aiLabel":"KI-Antwort","widget.open":"Chat öffnen","widget.close":"Chat schließen","widget.placeholder":"Ihre Frage eingeben...","widget.send":"Senden","widget.poweredBy":"Bereitgestellt von Kavchat","widget.offline":"Sie sind offline. Gespeicherte Antworten werden angezeigt.","widget.loading":"Wird geladen...","widget.unavailable":"Der Assistent ist gerade nicht verfügbar.","form.title":"Kontakt","form.name":"Name","form.email":"E-Mail","form.phone":"Telefon","form.topic":"Thema","form.message":"Nachricht","form.submit":"Senden","form.cancel":"Abbrechen","form.sending":"Wird gesendet...","form.sent":"Vielen Dank! Ihre Anfrage Nr. {number} ist eingegangen. Wir melden uns in Kürze bei Ihnen.","form.error":"Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut.","form.required":"Pflichtfeld","form.contactRequired":"Bitte geben Sie eine E-Mail-Adresse oder Telefonnummer an, damit wir uns melden können","form.emailInvalid":"Ungültige E-Mail-Adresse","form.backToChat":"Zurück zum Chat"},De={"chat.askAnswered":"Isso respondeu à sua pergunta?","chat.yes":"Sim, obrigado","chat.no":"Não, preciso de ajuda","chat.thanks":"Que bom que pude ajudar!","chat.newQuestion":"Nova pergunta","chat.back":"Voltar","chat.home":"Menu principal","chat.didYouMean":"O que você quis dizer?","chat.notFound":"Não encontrei uma resposta para isso. Escolha um assunto no menu ou fale com a nossa equipe.","chat.notFoundTwice":"Não consegui encontrar uma resposta. Nossa equipe vai ajudar com prazer, e sua pergunta já está no formulário.","chat.contactChip":"Falar com a equipe","chat.openingContact":"Abrindo o formulário de contato. Esta conversa será anexada à sua solicitação.","chat.chooseTopic":"Como posso ajudar?","chat.aiLabel":"Resposta de IA","widget.open":"Abrir chat","widget.close":"Fechar chat","widget.placeholder":"Digite sua pergunta...","widget.send":"Enviar","widget.poweredBy":"Desenvolvido por Kavchat","widget.offline":"Você está offline. Mostrando respostas salvas.","widget.loading":"Carregando...","widget.unavailable":"O assistente não está disponível no momento.","form.title":"Fale conosco","form.name":"Nome","form.email":"E-mail","form.phone":"Telefone","form.topic":"Assunto","form.message":"Mensagem","form.submit":"Enviar","form.cancel":"Cancelar","form.sending":"Enviando...","form.sent":"Obrigado! Sua solicitação nº {number} foi recebida. Retornaremos em breve.","form.error":"Algo deu errado. Tente novamente.","form.required":"Obrigatório","form.contactRequired":"Informe um e-mail ou telefone para que possamos retornar","form.emailInvalid":"Endereço de e-mail inválido","form.backToChat":"Voltar ao chat"},be={"chat.askAnswered":"Hai trovato la risposta?","chat.yes":"Sì, grazie","chat.no":"No, mi serve aiuto","chat.thanks":"Felice di esserti stato utile!","chat.newQuestion":"Nuova domanda","chat.back":"Indietro","chat.home":"Menu principale","chat.didYouMean":"Cosa intendevi?","chat.notFound":"Non ho trovato una risposta. Scegli un argomento dal menu o parla con il nostro team.","chat.notFoundTwice":"Non sono riuscito a trovare una risposta. Il nostro team sarà felice di aiutarti, e la tua domanda è già nel modulo.","chat.contactChip":"Parla con il team","chat.openingContact":"Apro il modulo di contatto. Questa conversazione sarà allegata alla tua richiesta.","chat.chooseTopic":"Come posso aiutarti?","chat.aiLabel":"Risposta dell'IA","widget.open":"Apri la chat","widget.close":"Chiudi la chat","widget.placeholder":"Scrivi la tua domanda...","widget.send":"Invia","widget.poweredBy":"Powered by Kavchat","widget.offline":"Sei offline. Mostro le risposte salvate.","widget.loading":"Caricamento...","widget.unavailable":"L'assistente non è disponibile al momento.","form.title":"Contattaci","form.name":"Nome","form.email":"Email","form.phone":"Telefono","form.topic":"Argomento","form.message":"Messaggio","form.submit":"Invia","form.cancel":"Annulla","form.sending":"Invio in corso...","form.sent":"Grazie! La tua richiesta n. {number} è stata ricevuta. Ti risponderemo presto.","form.error":"Qualcosa è andato storto. Riprova.","form.required":"Obbligatorio","form.contactRequired":"Lascia un'email o un numero di telefono per poterti ricontattare","form.emailInvalid":"Indirizzo email non valido","form.backToChat":"Torna alla chat"},ve={"chat.askAnswered":"Sorunuza yanıt bulabildiniz mi?","chat.yes":"Evet, teşekkürler","chat.no":"Hayır, yardım lazım","chat.thanks":"Yardımcı olabildiğime sevindim!","chat.newQuestion":"Yeni soru","chat.back":"Geri","chat.home":"Ana menü","chat.didYouMean":"Ne demek istediniz?","chat.notFound":"Bununla ilgili bir yanıt bulamadım. Menüden bir konu seçin veya ekibimizle görüşün.","chat.notFoundTwice":"Bir yanıt bulamadım. Ekibimiz size memnuniyetle yardımcı olur, sorunuz forma zaten eklendi.","chat.contactChip":"Ekibe ulaşın","chat.openingContact":"İletişim formu açılıyor. Bu konuşma talebinize eklenecek.","chat.chooseTopic":"Size nasıl yardımcı olabilirim?","chat.aiLabel":"Yapay zekâ yanıtı","widget.open":"Sohbeti aç","widget.close":"Sohbeti kapat","widget.placeholder":"Sorunuzu yazın...","widget.send":"Gönder","widget.poweredBy":"Kavchat ile desteklenmektedir","widget.offline":"Çevrimdışısınız. Kayıtlı yanıtlar gösteriliyor.","widget.loading":"Yükleniyor...","widget.unavailable":"Asistan şu anda kullanılamıyor.","form.title":"Bize ulaşın","form.name":"Ad","form.email":"E-posta","form.phone":"Telefon","form.topic":"Konu","form.message":"Mesaj","form.submit":"Gönder","form.cancel":"İptal","form.sending":"Gönderiliyor...","form.sent":"Teşekkürler! {number} numaralı talebiniz alındı. En kısa sürede size dönüş yapacağız.","form.error":"Bir sorun oluştu. Lütfen tekrar deneyin.","form.required":"Zorunlu","form.contactRequired":"Size dönüş yapabilmemiz için bir e-posta veya telefon numarası bırakın","form.emailInvalid":"Geçersiz e-posta adresi","form.backToChat":"Sohbete dön"},xe={"chat.askAnswered":"คำตอบนี้ช่วยตอบคำถามของคุณหรือไม่","chat.yes":"ใช่ ขอบคุณ","chat.no":"ไม่ใช่ ต้องการความช่วยเหลือ","chat.thanks":"ยินดีที่ได้ช่วยเหลือ","chat.newQuestion":"ถามคำถามใหม่","chat.back":"ย้อนกลับ","chat.home":"เมนูหลัก","chat.didYouMean":"คุณหมายถึงข้อใด","chat.notFound":"ขออภัย ไม่พบคำตอบสำหรับคำถามนี้ กรุณาเลือกหัวข้อจากเมนู หรือติดต่อทีมงานของเรา","chat.notFoundTwice":"ขออภัย ไม่พบคำตอบ ทีมงานของเรายินดีช่วยเหลือ และได้ใส่คำถามของคุณไว้ในแบบฟอร์มแล้ว","chat.contactChip":"ติดต่อทีมงาน","chat.openingContact":"กำลังเปิดแบบฟอร์มติดต่อ บทสนทนานี้จะแนบไปกับคำขอของคุณ","chat.chooseTopic":"มีอะไรให้ช่วยไหม","chat.aiLabel":"คำตอบจาก AI","widget.open":"เปิดแชต","widget.close":"ปิดแชต","widget.placeholder":"พิมพ์คำถามของคุณ...","widget.send":"ส่ง","widget.poweredBy":"ขับเคลื่อนโดย Kavchat","widget.offline":"คุณออฟไลน์อยู่ กำลังแสดงคำตอบที่บันทึกไว้","widget.loading":"กำลังโหลด...","widget.unavailable":"ผู้ช่วยไม่พร้อมให้บริการในขณะนี้","form.title":"ติดต่อเรา","form.name":"ชื่อ","form.email":"อีเมล","form.phone":"โทรศัพท์","form.topic":"หัวข้อ","form.message":"ข้อความ","form.submit":"ส่ง","form.cancel":"ยกเลิก","form.sending":"กำลังส่ง...","form.sent":"ขอบคุณ เราได้รับคำขอหมายเลข {number} ของคุณแล้ว และจะติดต่อกลับโดยเร็ว","form.error":"เกิดข้อผิดพลาด กรุณาลองอีกครั้ง","form.required":"จำเป็นต้องกรอก","form.contactRequired":"กรุณาระบุอีเมลหรือหมายเลขโทรศัพท์ เพื่อให้เราติดต่อกลับได้","form.emailInvalid":"อีเมลไม่ถูกต้อง","form.backToChat":"กลับไปที่แชต"},O={en:j,he:de,ar:pe,ru:he,es:fe,fr:me,de:ge,pt:De,it:be,tr:ve,th:xe},we=["he","ar"],cu=e=>we.includes(lu(e)),lu=e=>String(e||"en").toLowerCase().split(/[-_]/)[0].replace(/^iw$/,"he");function z(e,u){var n;let t=(n=O[lu(e)])!=null?n:j;return{...j,...t,...u!=null?u:{}}}var Eu=(e,u)=>e.replace(/\{(\w+)\}/g,(n,t)=>u[t]!==void 0?String(u[t]):n),T={now:()=>Date.now()};function V(e){T={...T,...e}}var g=e=>z(e.locale,T.texts),G=()=>new Date(T.now()).toISOString();function du(e,u,n){let t=e.scripts[u],i=t==null?void 0:t.content.steps.find(o=>o.id===n);return t&&i?{script:t,step:i}:null}var Y=e=>Object.values(e.scripts).filter(u=>u.kind!=="opening").sort((u,n)=>u.sortOrder-n.sortOrder),pu=e=>Y(e).map(u=>({id:`script:${u.id}`,label:u.content.name,kind:"button",action:{type:"script",scriptId:u.id}})),R=e=>({id:"home",label:g(e)["chat.home"],kind:"home"}),Q=e=>{let u=[];return e.history.length>0&&u.push({id:"back",label:g(e)["chat.back"],kind:"back"}),u.push(R(e)),u},N=(e,u)=>({id:"contact",label:g(e)["chat.contactChip"],kind:"contact",...u?{prefill:u}:{}});function D(e,u,n,t={}){return(u==="bot"?le(n):[n]).reduce((o,r)=>({...o,seq:o.seq+1,messages:[...o.messages,{id:`m${o.seq+1}`,from:u,text:r,at:T.now(),...t}]}),e)}var hu=(e,u,n,t)=>({...e,path:[...e.path,{scriptId:u,stepId:n,via:t,at:G()}]});function C(e,u){let n=e.scripts[e.openingId],t=n==null?void 0:n.content.steps.find(r=>r.id===n.content.rootStepId),i=e.userName?`, ${e.userName}`:"",o={...e,position:null,history:[],outcome:"open"};if(u==="start"){let r=((t==null?void 0:t.text)||g(e)["chat.chooseTopic"]).replace(/\{name\}/g,i);o=D(o,"bot",r,t!=null&&t.imageUrl?{imageUrl:t.imageUrl}:{})}else o=D(o,"bot",g(e)["chat.chooseTopic"]);return o=hu(o,e.openingId,(t==null?void 0:t.id)||"welcome",u),{...o,chips:[...pu(o),N(o)]}}function S(e,u,n,t,i=!0){let o=du(e,u,n);if(!o)return C(e,"home");let{step:r}=o,a={...e,history:i&&e.position?[...e.history,e.position]:e.history,position:{scriptId:u,stepId:n},lastScriptId:u};if(a=D(a,"bot",r.text,{stepId:n,scriptId:u,...r.imageUrl?{imageUrl:r.imageUrl}:{}}),a=hu(a,u,n,t),r.buttons.length>0){let c=r.buttons.map(f=>({id:`btn:${f.id}`,label:f.label,kind:"button",action:f.action}));return{...a,chips:[...c,...Q(a)]}}return a=D(a,"bot",g(a)["chat.askAnswered"]),{...a,chips:[{id:"yes",label:g(a)["chat.yes"],kind:"yes"},{id:"no",label:g(a)["chat.no"],kind:"no"},...Q(a)]}}function ye(e){return e.messages.map(u=>({from:u.from,text:u.text,...u.stepId?{stepId:u.stepId}:{},at:new Date(u.at).toISOString()}))}function fu(e,u){let n=e.lastScriptId?e.scripts[e.lastScriptId]:null,t={type:"contact",contactTopicId:(n==null?void 0:n.content.contactTopicId)||null,scriptId:e.lastScriptId,prefill:u||"",transcript:ye(e)},i=D({...e,outcome:"contact"},"bot",g(e)["chat.openingContact"]);return{state:{...i,chips:[R(i)]},effect:t}}function mu(e){let u={scripts:Object.fromEntries(e.scripts.map(n=>[n.id,n])),openingId:e.openingScriptId,locale:e.locale||"en",userName:e.userName||"",messages:[],chips:[],position:null,history:[],path:[],unmatched:[],misses:0,outcome:"open",lastScriptId:null,lastMatch:null,seq:0};return C(u,"start")}function ke(e,u,n){var t;let i=(t=e.position)==null?void 0:t.scriptId;if(!u)return{state:C(e,"home")};switch(u.type){case"script":{let o=e.scripts[u.scriptId];return o?{state:S(e,o.id,o.content.rootStepId,"button")}:{state:C(e,"home")}}case"step":return{state:S(e,i||"",u.stepId,"button")};case"goto":return{state:S(e,u.scriptId||i||"",u.stepId,"button")};case"contact":return fu(e);case"screen":case"link":return{state:{...e,chips:n.length?n:Q(e)},effect:u};default:return{state:C(e,"home")}}}function gu(e,u){let n={...D(e,"user",u.label),chips:[],lastMatch:null};switch(u.kind){case"home":return{state:C(n,"home")};case"back":{let t=n.history[n.history.length-1];return t?(n={...n,history:n.history.slice(0,-1),position:null},{state:S(n,t.scriptId,t.stepId,"back",!1)}):{state:C(n,"home")}}case"yes":return n=D({...n,outcome:"answered"},"bot",g(n)["chat.thanks"]),{state:{...n,chips:[{id:"new",label:g(n)["chat.newQuestion"],kind:"home"}]}};case"no":case"contact":return fu(n,u.prefill);case"pick":return u.target?{state:S(n,u.target.scriptId,u.target.stepId,"text")}:{state:C(n,"home")};default:return ke(n,u.action,e.chips)}}function Ae(e,u){let n=du(e,u.scriptId,u.stepId);if(!n)return"";let{script:t,step:i}=n;if(i.id===t.content.rootStepId)return t.content.name;for(let o of t.content.steps){let r=o.buttons.find(a=>a.action&&"stepId"in a.action&&a.action.stepId===i.id);if(r)return r.label}return i.text.slice(0,25)}function W(e,u){let n=String(u!=null?u:"").trim().slice(0,500);if(!n)return{state:e};let t={...D(e,"user",n),chips:[]},i=su(Y(t),n,t.locale);if(t={...t,lastMatch:i},i.kind==="single"){let o=i.matches[0];return{state:{...S(t,o.scriptId,o.stepId,"text"),misses:0,lastMatch:i}}}if(i.kind==="multi"){t=D({...t,misses:0},"bot",g(t)["chat.didYouMean"]);let o=i.matches.map(r=>({id:`pick:${r.scriptId}:${r.stepId}`,label:Ae(t,r),kind:"pick",target:{scriptId:r.scriptId,stepId:r.stepId}}));return{state:{...t,chips:[...o,R(t)]}}}return t={...t,misses:t.misses+1,unmatched:[...t.unmatched,{text:n,at:G()}]},t.misses>=2?(t=D(t,"bot",g(t)["chat.notFoundTwice"]),{state:{...t,chips:[N(t,n),R(t)]}}):(t=D(t,"bot",g(t)["chat.notFound"]),{state:{...t,chips:[...pu(t),N(t,n)]}})}var Ce=300,Fe=600;function Du(e,u){let n=String(u!=null?u:"").trim().slice(0,500);return!n||su(Y(e),n,e.locale).kind!=="none"?null:n.slice(0,Ce)}function bu(e,u){let n=String(u!=null?u:"").trim().slice(0,500);return n?{...D(e,"user",n),chips:[]}:e}function vu(e,u,n,t){let i=String(u!=null?u:"").trim().slice(0,500),o=String(n!=null?n:"").trim().slice(0,Fe);if(!i||!o)return W(e,u);let r={...D(e,"user",i),chips:[],lastMatch:{kind:"none",matches:[]},misses:0,unmatched:[...e.unmatched,{text:i,at:G()}]};r={...r,seq:r.seq+1,messages:[...r.messages,{id:`m${r.seq+1}`,from:"bot",text:o,at:T.now(),ai:!0}]};let a=t?r.scripts[t]:void 0,c=[];return a&&a.kind!=="opening"&&c.push({id:`script:${a.id}`,label:a.content.name,kind:"button",action:{type:"script",scriptId:a.id}}),{state:{...r,chips:[...c,N(r,i),R(r)]}}}function xu(e,u,n,t){return{sessionId:u,releaseVersion:n,startedAt:t,outcome:e.outcome,path:e.path.slice(-200),unmatched:e.unmatched.slice(-20)}}var wu=(e,u)=>`${e.apiBase.replace(/\/+$/,"")}/v1/client/${encodeURIComponent(e.publicKey)}/${u}`;function yu(e,u={}){let n=e.getToken();return n?{...u,Authorization:`Bearer ${n}`}:u}async function ku(e,u){let n;try{n=await fetch(wu(e,"release"),{method:"GET",cache:"no-store",credentials:"omit",headers:yu(e,u?{"If-None-Match":u}:{})})}catch(i){return{kind:"offline"}}if(n.status===304)return{kind:"not-modified"};if(n.status>=500||n.status===429)return{kind:"offline"};if(!n.ok)return{kind:"denied",status:n.status};let t=await n.json().catch(()=>null);return!t||t.success!==!0||!t.data||typeof t.data.enabled!="boolean"?{kind:"offline"}:{kind:"ok",release:t.data,etag:n.headers.get("ETag")||""}}function K(e,u,n,t=!1,i){return fetch(wu(e,u),{method:"POST",cache:"no-store",credentials:"omit",keepalive:t,signal:i,headers:yu(e,{"Content-Type":"application/json"}),body:JSON.stringify(n)})}var Se=2e4;async function Au(e,u,n){let t=new AbortController,i=setTimeout(()=>t.abort(),Se);try{let o=await K(e,"ai/answer",{sessionId:u,question:n},!1,t.signal),r=o.ok&&(await o.json()).data;return r&&typeof r.answer=="string"&&r.answer.trim()?{answer:r.answer,scriptId:r.scriptId||null}:null}catch(o){return null}finally{clearTimeout(i)}}async function Cu(e,u,n=!1){try{return(await K(e,"events",u,n)).ok}catch(t){return!1}}async function Fu(e,u){try{return(await K(e,"screens",{platform:"web",screens:u})).ok}catch(n){return!1}}async function Su(e,u){try{let n=await K(e,"tickets",u),t=await n.json().catch(()=>null);return n.ok&&t&&t.success&&t.data?{ok:!0,id:String(t.data.id),number:Number(t.data.number)}:{ok:!1,code:String((t==null?void 0:t.code)||`http_${n.status}`),message:String((t==null?void 0:t.message)||"")}}catch(n){return{ok:!1,code:"network",message:""}}}var Te="#2563eb",J="#111827",X="#ffffff";function uu(e){let u=/^#([0-9a-f]{6})$/i.exec(String(e||"").trim());if(!u)return null;let n=parseInt(u[1],16);return[n>>16&255,n>>8&255,n&255]}function Tu(e){let[u,n,t]=e.map(i=>{let o=i/255;return o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4)});return .2126*u+.7152*n+.0722*t}function Z(e,u){var i,o;let n=Tu((i=uu(e))!=null?i:[0,0,0]),t=Tu((o=uu(u))!=null?o:[0,0,0]);return(Math.max(n,t)+.05)/(Math.min(n,t)+.05)}function Bu(e){let u=uu(e)?e.toLowerCase():Te,n=Z(u,X)>=Z(u,J)?X:J,t=Z(u,X)>=3?u:J;return{primary:u,onPrimary:n,accent:t}}function s(e,u,...n){let t=document.createElement(e);if(u)for(let[i,o]of Object.entries(u))o==null||o===!1||t.setAttribute(i,o===!0?"":o);return _(t,n),t}function _(e,u){for(let n of u)n==null||n===!1||e.appendChild(typeof n=="string"?document.createTextNode(n):n)}var Iu="http://www.w3.org/2000/svg";function B(e){let u=document.createElementNS(Iu,"svg");u.setAttribute("viewBox","0 0 24 24"),u.setAttribute("width","24"),u.setAttribute("height","24"),u.setAttribute("aria-hidden","true"),u.setAttribute("focusable","false");let n=document.createElementNS(Iu,"path");return n.setAttribute("d",e),n.setAttribute("fill","currentColor"),u.appendChild(n),u}var I={chat:"M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z",close:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z",send:"M2.01 21 23 12 2.01 3 2 10l15 2-15 2z"};function M(e,u){try{let n=new URL(String(e||"").trim());return u.includes(n.protocol)?n.href:null}catch(n){return null}}var eu=/https:\/\/[^\s<>"'`]+/g,Be=/[.,;:!?)\]}'"»]+$/;function Ru(e){let u=document.createDocumentFragment(),n=0;eu.lastIndex=0;let t;for(;t=eu.exec(e);){let i=t[0].replace(Be,""),o=M(i,["https:"]);if(!o||!i)continue;t.index>n&&u.appendChild(document.createTextNode(e.slice(n,t.index)));let r=s("a",{href:o,target:"_blank",rel:"noopener noreferrer"},i);u.appendChild(r),n=t.index+i.length,eu.lastIndex=n}return n<e.length&&u.appendChild(document.createTextNode(e.slice(n))),u}var Mu=e=>`kavchat:release:${e}`,qu=e=>`kavchat:session:${e}`,Lu=e=>`kavchat:screens:${e}`;function tu(e,u){try{let n=e().getItem(u);return n?JSON.parse(n):null}catch(n){return null}}function nu(e,u,n){try{e().setItem(u,JSON.stringify(n))}catch(t){}}var P=()=>window.localStorage,Nu=()=>window.sessionStorage,Ou=e=>tu(P,Mu(e)),zu=(e,u)=>nu(P,Mu(e),u),Ku=e=>tu(P,Lu(e)),_u=(e,u)=>nu(P,Lu(e),u),Pu=e=>tu(Nu,qu(e)),Hu=(e,u)=>nu(Nu,qu(e),u),Ie="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";function Uu(e=22){let u=new Uint8Array(e);if(typeof crypto!="undefined"&&crypto.getRandomValues)crypto.getRandomValues(u);else for(let t=0;t<e;t++)u[t]=Math.floor(Math.random()*256);let n="";for(let t=0;t<e;t++)n+=Ie[u[t]&63];return n}var ju=`
2
2
  :host{all:initial}
3
- .kc{font-family:system-ui,-apple-system,"Segoe UI",Roboto,"Noto Sans Hebrew","Noto Sans Arabic",Arial,sans-serif;font-size:15px;line-height:1.45;color:#1f2328;-webkit-font-smoothing:antialiased}
3
+ .kc{font-family:system-ui,-apple-system,"Segoe UI",Roboto,"Noto Sans Hebrew","Noto Sans Arabic","Noto Sans Thai",Arial,sans-serif;font-size:15px;line-height:1.45;color:#1f2328;-webkit-font-smoothing:antialiased}
4
4
  .kc *,.kc *::before,.kc *::after{box-sizing:border-box}
5
5
  .kc [hidden]{display:none!important}
6
6
  .kc button,.kc input,.kc select,.kc textarea{font:inherit;color:inherit;margin:0}
@@ -15,8 +15,8 @@
15
15
  .avatar{width:38px;height:38px;border-radius:50%;flex:none;display:flex;align-items:center;justify-content:center;overflow:hidden;background:rgba(255,255,255,.22);font-weight:600;font-size:15px}
16
16
  .avatar img{width:100%;height:100%;object-fit:cover}
17
17
  .titles{min-width:0;flex:1}
18
- .name{font-weight:600;font-size:16px;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
19
- .subtitle{font-size:13px;opacity:.85;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
18
+ .name{font-weight:600;font-size:16px;line-height:1.6;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
19
+ .subtitle{font-size:13px;line-height:1.6;opacity:.85;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
20
20
  .close{flex:none;width:36px;height:36px;border:0;border-radius:50%;background:transparent;color:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0}
21
21
  .close:hover{background:rgba(127,127,127,.2)}
22
22
  .close svg{width:22px;height:22px}
@@ -33,7 +33,7 @@
33
33
  @keyframes kc-dot{50%{opacity:.3}}
34
34
  .msg img{display:block;max-width:100%;height:auto;border-radius:10px;margin-block-end:6px}
35
35
  .chips{flex:none;display:flex;flex-wrap:wrap;gap:6px;padding:4px 14px 10px;max-height:40%;overflow-y:auto}
36
- .chip{border:1px solid var(--kc-accent);background:#fff;color:var(--kc-accent);border-radius:999px;padding:6px 13px;cursor:pointer;font-size:14px;line-height:1.3;text-align:start}
36
+ .chip{border:1px solid var(--kc-accent);background:#fff;color:var(--kc-accent);border-radius:999px;padding:6px 13px;cursor:pointer;font-size:14px;line-height:1.4;text-align:start}
37
37
  .chip:hover{background:var(--kc-primary);color:var(--kc-on-primary);border-color:var(--kc-primary)}
38
38
  .chip-home,.chip-back{border-color:#cfd4da;color:#4b5563}
39
39
  .composer{flex:none;display:flex;align-items:center;gap:8px;padding:8px 10px;border-block-start:1px solid #e3e6ea;background:#fff}
@@ -60,6 +60,6 @@
60
60
  .sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
61
61
  @media (max-width:480px){.panel,.kc[data-pos=start] .panel{inset:0;width:100%;max-width:none;height:100%;max-height:none;border-radius:0}}
62
62
  @media (prefers-reduced-motion:reduce){.kc *{animation:none!important;transition:none!important}}
63
- `;var wt="https://api.kavchat.com",yt="https://kavchat.com",kt=2e3,Ct=/^[A-Za-z0-9_.-]{1,40}$/,At=10080*60*1e3;function Ft(n){let e=new Set,t=[];for(let u of n!=null?n:[]){let i=typeof(u==null?void 0:u.id)=="string"?u.id:"",o=typeof(u==null?void 0:u.label)=="string"?u.label.trim().slice(0,60):"";if(!(!Ct.test(i)||!o||e.has(i))&&(e.add(i),t.push({id:i,label:o,needsTarget:u.needsTarget===!0}),t.length===100))break}return t}function St(n){let e=[...n].sort((u,i)=>u.id<i.id?-1:u.id>i.id?1:0).map(u=>`${u.id}|${u.label}|${u.needsTarget?1:0}`).join(`
64
- `),t=2166136261;for(let u=0;u<e.length;u++)t^=e.charCodeAt(u),t=Math.imul(t,16777619)>>>0;return t.toString(16)}var Pe=n=>String(n||"").toLowerCase().split(/[-_]/)[0].replace(/^iw$/,"he");function Tt(n,e){let t=Pe(n||(typeof navigator!="undefined"?navigator.language:"")||"");if(N[t])return t;let u=Pe(e);return N[u]?u:"en"}var It=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,P=class{constructor(e){this.release=null;this.offline=!1;this.ui=null;this.state=null;this.session=null;this.t=O("en");this.locale="en";this.isOpen=!1;this.prevFocus=null;this.reportTimer=null;this.dirty=!1;this.destroyed=!1;this.waiting=!1;this.onPageHide=()=>this.flush(!0);this.onVisibility=()=>{document.visibilityState==="hidden"&&this.flush(!0)};if(!e||!e.publicKey)throw new Error("Kavchat: publicKey is required");this.opts={...e},this.wantOpen=!!e.open,this.api={apiBase:e.apiBase||wt,publicKey:e.publicKey,getToken:()=>this.opts.userToken||void 0},window.addEventListener("pagehide",this.onPageHide),document.addEventListener("visibilitychange",this.onVisibility),this.ready=this.load()}get shadowRoot(){return this.ui?this.ui.root:null}get opened(){return this.isOpen}open(){this.wantOpen=!0;let e=this.ui;!e||this.isOpen||(this.isOpen=!0,this.prevFocus=document.activeElement,this.state||this.startFresh(),e.panel.hidden=!1,e.launcher.setAttribute("aria-expanded","true"),e.launcher.setAttribute("aria-label",this.t["widget.close"]),e.launcher.replaceChildren(F(S.close)),this.render(),this.focusInside(),this.emit({type:"open"}))}close(){this.wantOpen=!1;let e=this.ui;if(!e||!this.isOpen)return;this.isOpen=!1,e.panel.hidden=!0,e.launcher.setAttribute("aria-expanded","false"),e.launcher.setAttribute("aria-label",this.t["widget.open"]),e.launcher.replaceChildren(F(S.chat));let t=this.prevFocus;t&&t!==e.host&&t.isConnected&&typeof t.focus=="function"?t.focus():e.launcher.focus(),this.emit({type:"close"})}toggle(){this.isOpen?this.close():this.open()}setUser(e){return this.opts.userToken=(e==null?void 0:e.token)||void 0,this.opts.userName=(e==null?void 0:e.name)||void 0,this.ready=this.load(),this.ready}destroy(){this.destroyed||(this.flush(!0),this.destroyed=!0,this.reportTimer&&clearTimeout(this.reportTimer),window.removeEventListener("pagehide",this.onPageHide),document.removeEventListener("visibilitychange",this.onVisibility),this.unmount())}async load(){var r,a;let e=this.opts.publicKey,t=Me(e),u=await ve(this.api,(t==null?void 0:t.etag)||void 0);if(this.destroyed)return;let i=null,o=!1;u.kind==="ok"?(qe(e,{etag:u.etag,release:u.release}),i=u.release):u.kind==="not-modified"?i=(r=t==null?void 0:t.release)!=null?r:null:u.kind==="offline"&&(i=(a=t==null?void 0:t.release)!=null?a:null,o=!!i),this.apply(i,o),this.registerScreens()}async registerScreens(){let e=Ft(this.opts.screens);if(e.length===0)return;let t=this.opts.publicKey,u=St(e),i=Le(t);i&&i.fp===u&&Date.now()-i.at<At||await ye(this.api,e)&&Ne(t,{fp:u,at:Date.now()})}apply(e,t){if(!e||!e.enabled){this.release=null,this.state=null,this.isOpen=!1,this.unmount(),this.emit({type:"unavailable",reason:e&&"reason"in e?e.reason:void 0});return}this.offline=t;let u=!this.release||this.release.version!==e.version;this.release=e,this.locale=Tt(this.opts.locale,e.locale),this.t=O(this.locale),(u||!this.ui)&&(this.state=null,this.restoreSession(),this.mount()),this.ui&&(this.ui.banner.hidden=!this.offline),this.emit({type:"ready",version:e.version,offline:t}),this.wantOpen&&this.open()}restoreSession(){let e=this.release;if(!e)return;let t=Oe(this.opts.publicKey);if(t&&t.version===e.version&&t.state){let u={};for(let i of e.scripts)u[i.id]=i;this.session=t,this.state={...t.state,scripts:u}}else this.session=null}run(e){return j({texts:this.t}),e()}startFresh(){let e=this.release;e&&(j({texts:this.t}),this.session={id:Ke(),startedAt:new Date().toISOString(),version:e.version,state:null},this.setState(pe({scripts:e.scripts,openingScriptId:e.openingScriptId,locale:e.locale,userName:this.opts.userName})))}setState(e){if(this.state=e,this.session){let{scripts:t,...u}=e;this.session.state=u,ze(this.opts.publicKey,this.session)}this.render()}onChip(e){if(!this.state||this.waiting)return;let t=this.state,u=this.run(()=>he(t,e));this.afterAction(u)}async onSend(e){var a;if(!this.state||!e.trim()||this.waiting)return;let t=this.state,u=this.session,i=(a=this.release)!=null&&a.settings.aiAnswers&&u?fe(t,e):null;if(!i||!u)return this.afterAction(this.run(()=>V(t,e)));let o=me(t,e);this.state=o,this.waiting=!0,this.render();let r=await xe(this.api,u.id,i);if(this.waiting=!1,this.destroyed||this.state!==o)return this.render();this.afterAction(this.run(()=>ge(t,e,r&&r.answer,r&&r.scriptId)))}afterAction(e){this.setState(e.state),this.scheduleReport(),e.effect&&this.handleEffect(e.effect)}handleEffect(e){var t,u,i;if(this.emit({type:"effect",effect:e}),e.type==="contact")this.showForm(e);else if(e.type==="link")Mt(e.url,(t=this.ui)==null?void 0:t.root);else if(e.type==="screen")try{(i=(u=this.opts).onScreen)==null||i.call(u,e.screen,e.targetId)}catch(o){console.error("Kavchat: onScreen failed",o)}}scheduleReport(){this.dirty=!0,this.reportTimer&&clearTimeout(this.reportTimer),this.reportTimer=setTimeout(()=>this.flush(!1),kt)}flush(e){if(this.reportTimer&&(clearTimeout(this.reportTimer),this.reportTimer=null),!this.dirty||!this.state||!this.release||!this.session||this.destroyed)return;this.dirty=!1;let t=De(this.state,this.session.id,this.release.version,this.session.startedAt);we(this.api,t,e).then(u=>{u||(this.dirty=!0)})}emit(e){var t,u;try{(u=(t=this.opts).onEvent)==null||u.call(t,e)}catch(i){console.error("Kavchat: onEvent failed",i)}}unmount(){this.ui&&this.ui.host.remove(),this.ui=null,this.isOpen=!1}mount(){let e=this.release;if(!e)return;this.unmount();let t=this.t,u=e.settings,i=Ae(u.primaryColor),o=s("div",{"data-kavchat":""}),r=o.attachShadow({mode:"open"}),a=s("div",{class:"kc",dir:oe(this.locale)?"rtl":"ltr",lang:this.locale,"data-pos":u.position==="start"?"start":"end"});a.style.setProperty("--kc-primary",i.primary),a.style.setProperty("--kc-on-primary",i.onPrimary),a.style.setProperty("--kc-accent",i.accent);let c=s("button",{type:"button",class:"launcher","aria-label":t["widget.open"],"aria-expanded":"false","aria-controls":"kc-panel"},F(S.chat));c.addEventListener("click",()=>this.toggle());let b=u.avatarImageUrl?B(u.avatarImageUrl,["https:"]):null,l=s("div",{class:"avatar","aria-hidden":"true"},b?s("img",{src:b,alt:""}):(u.avatarText||u.botName||"").slice(0,2)),h=s("button",{type:"button",class:"close","aria-label":t["widget.close"]},F(S.close));h.addEventListener("click",()=>this.close());let w=s("div",{class:"header"},l,s("div",{class:"titles"},s("h2",{class:"name",id:"kc-title"},u.botName||""),u.subtitle?s("div",{class:"subtitle"},u.subtitle):null),h),f=s("div",{class:"banner",role:"status"},t["widget.offline"]);f.hidden=!this.offline;let x=s("div",{class:"messages"}),g=s("div",{class:"chips",role:"group"}),m=s("input",{type:"text",dir:"auto",maxlength:"500",autocomplete:"off",placeholder:t["widget.placeholder"],"aria-label":t["widget.placeholder"],enterkeyhint:"send"}),d=s("form",{class:"composer"},m,s("button",{type:"submit",class:"send","aria-label":t["widget.send"]},F(S.send)));d.addEventListener("submit",M=>{M.preventDefault();let je=m.value;m.value="",this.onSend(je)});let v=s("div",{class:"view"},x,g,d),p=s("div",{class:"view"});p.hidden=!0;let k=s("div",{class:"sr-only","aria-live":"polite","aria-atomic":"false"}),R=s("div",{class:"msg msg-bot typing","aria-hidden":"true"},"..."),T=s("div",{class:"panel",id:"kc-panel",role:"dialog","aria-labelledby":"kc-title",tabindex:"-1"},w,f,v,p,k);u.removeBranding||T.appendChild(s("a",{class:"badge",href:yt,target:"_blank",rel:"noopener noreferrer"},t["widget.poweredBy"])),T.hidden=!0,T.addEventListener("keydown",M=>{M.key==="Escape"&&(M.stopPropagation(),this.close())}),K(a,[c,T]),K(r,[s("style",null,_e),a]),(this.opts.container||document.body).appendChild(o),this.ui={host:o,root:r,wrap:a,launcher:c,panel:T,banner:f,chatView:v,messages:x,chips:g,input:m,formView:p,live:k,typing:R,rendered:0},this.state&&this.renderMessages(!1)}focusInside(){let e=this.ui;if(!e)return;let t=typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches;e.formView.hidden?t?e.panel.focus():e.input.focus():(e.formView.querySelector("input,select,textarea")||e.panel).focus()}render(){!this.ui||!this.state||(this.renderMessages(!0),this.renderChips())}renderMessages(e){let t=this.ui,u=this.state;if(!t||!u)return;t.rendered>u.messages.length&&(t.messages.textContent="",t.rendered=0);let i=[];for(let o=t.rendered;o<u.messages.length;o++){let r=u.messages[o];t.messages.appendChild(Rt(r,this.t)),r.from==="bot"&&i.push(r.ai?`${this.t["chat.aiLabel"]}: ${r.text}`:r.text)}t.rendered=u.messages.length,this.waiting?t.messages.appendChild(t.typing):t.typing.remove(),e&&i.length&&(t.live.textContent=i.join(`
65
- `)),t.messages.scrollTop=t.messages.scrollHeight}renderChips(){let e=this.ui,t=this.state;if(!(!e||!t)){e.chips.textContent="";for(let u of t.chips){let i=s("button",{type:"button",class:`chip chip-${u.kind}`},u.label);i.addEventListener("click",()=>this.onChip(u)),e.chips.appendChild(i)}e.chips.hidden=t.chips.length===0}}showChat(){let e=this.ui;e&&(e.formView.hidden=!0,e.formView.textContent="",e.chatView.hidden=!1,this.render(),this.isOpen&&this.focusInside())}showForm(e){let t=this.ui,u=this.release;if(!t||!u)return;let i=this.t,o=u.settings.contactTopics||[],r=(m,d,v)=>s("div",{class:"field"},s("label",{for:m},d),v),a=s("input",{id:"kc-name",type:"text",autocomplete:"name",maxlength:"100",dir:"auto"});a.value=this.opts.userName||"";let c=s("input",{id:"kc-email",type:"email",autocomplete:"email",dir:"auto"}),b=s("input",{id:"kc-phone",type:"tel",autocomplete:"tel",dir:"auto"}),l=null;if(o.length){l=s("select",{id:"kc-topic"},s("option",{value:""},""));for(let m of o)l.appendChild(s("option",{value:m.id},m.name));e.contactTopicId&&o.some(m=>m.id===e.contactTopicId)&&(l.value=e.contactTopicId)}let h=s("textarea",{id:"kc-message",required:!0,maxlength:"2000",dir:"auto"});h.value=e.prefill||"";let w=s("div",{class:"error",role:"alert"}),f=s("button",{type:"submit",class:"btn btn-primary"},i["form.submit"]),x=s("button",{type:"button",class:"btn"},i["form.cancel"]);x.addEventListener("click",()=>this.showChat());let g=s("form",{class:"form",novalidate:!0},s("h2",null,i["form.title"]),r("kc-name",i["form.name"],a),r("kc-email",i["form.email"],c),r("kc-phone",i["form.phone"],b),l?r("kc-topic",i["form.topic"],l):null,r("kc-message",i["form.message"],h),w,s("div",{class:"actions"},f,x));g.addEventListener("submit",async m=>{var k;m.preventDefault();let d={message:h.value.trim(),name:a.value.trim()||void 0,email:c.value.trim()||void 0,phone:b.value.trim()||void 0,topicId:(l==null?void 0:l.value)||void 0,scriptId:e.scriptId||void 0,sessionId:(k=this.session)==null?void 0:k.id,transcript:e.transcript.slice(-200).map(R=>({...R,text:R.text.slice(0,1e3)}))},v=d.message?!d.email&&!d.phone&&!this.opts.userToken?i["form.contactRequired"]:d.email&&!It.test(d.email)?i["form.emailInvalid"]:"":i["form.required"];if(v){w.textContent=v;return}w.textContent="",f.disabled=!0,f.textContent=i["form.sending"];let p=await ke(this.api,d);this.destroyed||(f.disabled=!1,f.textContent=i["form.submit"],p.ok?(this.flush(!1),this.emit({type:"ticket",id:p.id,number:p.number}),this.showSent(p.number)):w.textContent=Bt(p.code,p.message,i))}),t.formView.replaceChildren(g),t.chatView.hidden=!0,t.formView.hidden=!1,this.isOpen&&this.focusInside()}showSent(e){let t=this.ui;if(!t)return;let u=this.t,i=s("button",{type:"button",class:"btn btn-primary"},u["form.backToChat"]);i.addEventListener("click",()=>this.showChat());let o=s("p",{role:"status"},ae(u["form.sent"],{number:e}));t.formView.replaceChildren(s("div",{class:"sent"},o,i)),i.focus()}};function Bt(n,e,t){return n==="ticket_contact_required"?t["form.contactRequired"]:n==="email_invalid"?t["form.emailInvalid"]:n==="network"?t["form.error"]:e||t["form.error"]}function Rt(n,e){let t=s("div",{class:`msg msg-${n.from}`,dir:"auto"});n.ai&&t.appendChild(s("span",{class:"ai"},e["chat.aiLabel"]));let u=n.from==="bot"&&n.imageUrl?B(n.imageUrl,["https:"]):null;return u&&t.appendChild(s("img",{src:u,alt:"",loading:"lazy"})),t.appendChild(n.from==="bot"&&!n.ai?Se(n.text):document.createTextNode(n.text)),t}function Mt(n,e){let t=B(n,["https:","tel:"]);if(!t)return!1;let u=s("a",{href:t,target:"_blank",rel:"noopener noreferrer"});return u.style.display="none",(e||document.body).appendChild(u),u.click(),u.remove(),!0}var qt=["init","open","close","toggle","setUser","destroy"];function He(n=window){let e=n.Kavchat;if(e&&e.loaded)return{api:e,queue:[]};let t=Array.isArray(e==null?void 0:e.q)?e.q.filter(Array.isArray):[],u=null,i,o,r={loaded:!0,init(a){u&&u.destroy();let c={...a};return o!==void 0&&(c.open=o),i!==void 0&&(c.userToken=(i==null?void 0:i.token)||void 0,c.userName=(i==null?void 0:i.name)||void 0),o=i=void 0,u=new P(c),u.ready},open(){u?u.open():o=!0},close(){u?u.close():o=!1},toggle(){u?u.toggle():o=!o},setUser(a){u?u.setUser(a):i=a},destroy(){u&&u.destroy(),u=null},q:{push:(...a)=>(a.forEach(c=>te(r,c)),0)},get widget(){return u}};return n.Kavchat=r,{api:r,queue:t}}function te(n,e){let[t,...u]=e;if(!qt.includes(t)){console.warn(`Kavchat: unknown method ${t}`);return}try{let i=n[t](...u);i&&typeof i.catch=="function"&&i.catch(o=>console.error("Kavchat:",o))}catch(i){console.error("Kavchat:",i)}}function Lt(n){if(!n)return null;let e=i=>n.getAttribute(i)||void 0,t=e("data-key");if(!t)return null;let u={publicKey:t};return e("data-api")&&(u.apiBase=e("data-api")),e("data-locale")&&(u.locale=e("data-locale")),e("data-user-token")&&(u.userToken=e("data-user-token")),e("data-user-name")&&(u.userName=e("data-user-name")),e("data-open")==="true"&&(u.open=!0),u}function Nt(){return document.currentScript||document.querySelector('script[data-key][src*="kavchat"]')||document.querySelector("script[data-key]")}function Ue(n=Nt()){let{api:e,queue:t}=He(),u=Lt(n),i=t.findIndex(r=>r[0]==="init"),o=t.filter((r,a)=>a!==i);return i>=0?o.unshift(["init",{...u,...t[i][1]}]):u&&o.unshift(["init",u]),o.forEach(r=>te(e,r)),e}try{Ue()}catch(n){console.error("Kavchat:",n)}})();
63
+ `;var Re="https://api.kavchat.com",Me="https://kavchat.com",qe=2e3,Le=/^[A-Za-z0-9_.-]{1,40}$/,Ne=10080*60*1e3;function Oe(e){let u=new Set,n=[];for(let t of e!=null?e:[]){let i=typeof(t==null?void 0:t.id)=="string"?t.id:"",o=typeof(t==null?void 0:t.label)=="string"?t.label.trim().slice(0,60):"";if(!(!Le.test(i)||!o||u.has(i))&&(u.add(i),n.push({id:i,label:o,needsTarget:t.needsTarget===!0}),n.length===100))break}return n}function ze(e){let u=[...e].sort((t,i)=>t.id<i.id?-1:t.id>i.id?1:0).map(t=>`${t.id}|${t.label}|${t.needsTarget?1:0}`).join(`
64
+ `),n=2166136261;for(let t=0;t<u.length;t++)n^=u.charCodeAt(t),n=Math.imul(n,16777619)>>>0;return n.toString(16)}var Qu=e=>String(e||"").toLowerCase().split(/[-_]/)[0].replace(/^iw$/,"he");function Ke(e,u){let n=Qu(e||(typeof navigator!="undefined"?navigator.language:"")||"");if(O[n])return n;let t=Qu(u);return O[t]?t:"en"}var _e=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,H=class{constructor(u){this.release=null;this.offline=!1;this.ui=null;this.state=null;this.session=null;this.t=z("en");this.locale="en";this.isOpen=!1;this.prevFocus=null;this.reportTimer=null;this.dirty=!1;this.destroyed=!1;this.waiting=!1;this.onPageHide=()=>this.flush(!0);this.onVisibility=()=>{document.visibilityState==="hidden"&&this.flush(!0)};if(!u||!u.publicKey)throw new Error("Kavchat: publicKey is required");this.opts={...u},this.wantOpen=!!u.open,this.api={apiBase:u.apiBase||Re,publicKey:u.publicKey,getToken:()=>this.opts.userToken||void 0},window.addEventListener("pagehide",this.onPageHide),document.addEventListener("visibilitychange",this.onVisibility),this.ready=this.load()}get shadowRoot(){return this.ui?this.ui.root:null}get opened(){return this.isOpen}open(){this.wantOpen=!0;let u=this.ui;!u||this.isOpen||(this.isOpen=!0,this.prevFocus=document.activeElement,this.state||this.startFresh(),u.panel.hidden=!1,u.launcher.setAttribute("aria-expanded","true"),u.launcher.setAttribute("aria-label",this.t["widget.close"]),u.launcher.replaceChildren(B(I.close)),this.render(),this.focusInside(),this.emit({type:"open"}))}close(){this.wantOpen=!1;let u=this.ui;if(!u||!this.isOpen)return;this.isOpen=!1,u.panel.hidden=!0,u.launcher.setAttribute("aria-expanded","false"),u.launcher.setAttribute("aria-label",this.t["widget.open"]),u.launcher.replaceChildren(B(I.chat));let n=this.prevFocus;n&&n!==u.host&&n.isConnected&&typeof n.focus=="function"?n.focus():u.launcher.focus(),this.emit({type:"close"})}toggle(){this.isOpen?this.close():this.open()}setUser(u){return this.opts.userToken=(u==null?void 0:u.token)||void 0,this.opts.userName=(u==null?void 0:u.name)||void 0,this.ready=this.load(),this.ready}destroy(){this.destroyed||(this.flush(!0),this.destroyed=!0,this.reportTimer&&clearTimeout(this.reportTimer),window.removeEventListener("pagehide",this.onPageHide),document.removeEventListener("visibilitychange",this.onVisibility),this.unmount())}async load(){var r,a;let u=this.opts.publicKey,n=Ou(u),t=await ku(this.api,(n==null?void 0:n.etag)||void 0);if(this.destroyed)return;let i=null,o=!1;t.kind==="ok"?(zu(u,{etag:t.etag,release:t.release}),i=t.release):t.kind==="not-modified"?i=(r=n==null?void 0:n.release)!=null?r:null:t.kind==="offline"&&(i=(a=n==null?void 0:n.release)!=null?a:null,o=!!i),this.apply(i,o),this.registerScreens()}async registerScreens(){let u=Oe(this.opts.screens);if(u.length===0)return;let n=this.opts.publicKey,t=ze(u),i=Ku(n);i&&i.fp===t&&Date.now()-i.at<Ne||await Fu(this.api,u)&&_u(n,{fp:t,at:Date.now()})}apply(u,n){if(!u||!u.enabled){this.release=null,this.state=null,this.isOpen=!1,this.unmount(),this.emit({type:"unavailable",reason:u&&"reason"in u?u.reason:void 0});return}this.offline=n;let t=!this.release||this.release.version!==u.version;this.release=u,this.locale=Ke(this.opts.locale,u.locale),this.t=z(this.locale),(t||!this.ui)&&(this.state=null,this.restoreSession(),this.mount()),this.ui&&(this.ui.banner.hidden=!this.offline),this.emit({type:"ready",version:u.version,offline:n}),this.wantOpen&&this.open()}restoreSession(){let u=this.release;if(!u)return;let n=Pu(this.opts.publicKey);if(n&&n.version===u.version&&n.state){let t={};for(let i of u.scripts)t[i.id]=i;this.session=n,this.state={...n.state,scripts:t}}else this.session=null}run(u){return V({texts:this.t}),u()}startFresh(){let u=this.release;u&&(V({texts:this.t}),this.session={id:Uu(),startedAt:new Date().toISOString(),version:u.version,state:null},this.setState(mu({scripts:u.scripts,openingScriptId:u.openingScriptId,locale:u.locale,userName:this.opts.userName})))}setState(u){if(this.state=u,this.session){let{scripts:n,...t}=u;this.session.state=t,Hu(this.opts.publicKey,this.session)}this.render()}onChip(u){if(!this.state||this.waiting)return;let n=this.state,t=this.run(()=>gu(n,u));this.afterAction(t)}async onSend(u){var a;if(!this.state||!u.trim()||this.waiting)return;let n=this.state,t=this.session,i=(a=this.release)!=null&&a.settings.aiAnswers&&t?Du(n,u):null;if(!i||!t)return this.afterAction(this.run(()=>W(n,u)));let o=bu(n,u);this.state=o,this.waiting=!0,this.render();let r=await Au(this.api,t.id,i);if(this.waiting=!1,this.destroyed||this.state!==o)return this.render();this.afterAction(this.run(()=>vu(n,u,r&&r.answer,r&&r.scriptId)))}afterAction(u){this.setState(u.state),this.scheduleReport(),u.effect&&this.handleEffect(u.effect)}handleEffect(u){var n,t,i;if(this.emit({type:"effect",effect:u}),u.type==="contact")this.showForm(u);else if(u.type==="link")Ue(u.url,(n=this.ui)==null?void 0:n.root);else if(u.type==="screen")try{(i=(t=this.opts).onScreen)==null||i.call(t,u.screen,u.targetId)}catch(o){console.error("Kavchat: onScreen failed",o)}}scheduleReport(){this.dirty=!0,this.reportTimer&&clearTimeout(this.reportTimer),this.reportTimer=setTimeout(()=>this.flush(!1),qe)}flush(u){if(this.reportTimer&&(clearTimeout(this.reportTimer),this.reportTimer=null),!this.dirty||!this.state||!this.release||!this.session||this.destroyed)return;this.dirty=!1;let n=xu(this.state,this.session.id,this.release.version,this.session.startedAt);Cu(this.api,n,u).then(t=>{t||(this.dirty=!0)})}emit(u){var n,t;try{(t=(n=this.opts).onEvent)==null||t.call(n,u)}catch(i){console.error("Kavchat: onEvent failed",i)}}unmount(){this.ui&&this.ui.host.remove(),this.ui=null,this.isOpen=!1}mount(){let u=this.release;if(!u)return;this.unmount();let n=this.t,t=u.settings,i=Bu(t.primaryColor),o=s("div",{"data-kavchat":""}),r=o.attachShadow({mode:"open"}),a=s("div",{class:"kc",dir:cu(this.locale)?"rtl":"ltr",lang:this.locale,"data-pos":t.position==="start"?"start":"end"});a.style.setProperty("--kc-primary",i.primary),a.style.setProperty("--kc-on-primary",i.onPrimary),a.style.setProperty("--kc-accent",i.accent);let c=s("button",{type:"button",class:"launcher","aria-label":n["widget.open"],"aria-expanded":"false","aria-controls":"kc-panel"},B(I.chat));c.addEventListener("click",()=>this.toggle());let f=t.avatarImageUrl?M(t.avatarImageUrl,["https:"]):null,m=s("div",{class:"avatar","aria-hidden":"true"},f?s("img",{src:f,alt:""}):(t.avatarText||t.botName||"").slice(0,2)),k=s("button",{type:"button",class:"close","aria-label":n["widget.close"]},B(I.close));k.addEventListener("click",()=>this.close());let p=s("div",{class:"header"},m,s("div",{class:"titles"},s("h2",{class:"name",id:"kc-title"},t.botName||""),t.subtitle?s("div",{class:"subtitle"},t.subtitle):null),k),E=s("div",{class:"banner",role:"status"},n["widget.offline"]);E.hidden=!this.offline;let A=s("div",{class:"messages"}),b=s("div",{class:"chips",role:"group"}),d=s("input",{type:"text",dir:"auto",maxlength:"500",autocomplete:"off",placeholder:n["widget.placeholder"],"aria-label":n["widget.placeholder"],enterkeyhint:"send"}),l=s("form",{class:"composer"},d,s("button",{type:"submit",class:"send","aria-label":n["widget.send"]},B(I.send)));l.addEventListener("submit",F=>{F.preventDefault();let Gu=d.value;d.value="",this.onSend(Gu)});let w=s("div",{class:"view"},A,b,l),v=s("div",{class:"view"});v.hidden=!0;let x=s("div",{class:"sr-only","aria-live":"polite","aria-atomic":"false"}),y=s("div",{class:"msg msg-bot typing","aria-hidden":"true"},"..."),h=s("div",{class:"panel",id:"kc-panel",role:"dialog","aria-labelledby":"kc-title",tabindex:"-1"},p,E,w,v,x);t.removeBranding||h.appendChild(s("a",{class:"badge",href:Me,target:"_blank",rel:"noopener noreferrer"},n["widget.poweredBy"])),h.hidden=!0,h.addEventListener("keydown",F=>{F.key==="Escape"&&(F.stopPropagation(),this.close())}),_(a,[c,h]),_(r,[s("style",null,ju),a]),(this.opts.container||document.body).appendChild(o),this.ui={host:o,root:r,wrap:a,launcher:c,panel:h,banner:E,chatView:w,messages:A,chips:b,input:d,formView:v,live:x,typing:y,rendered:0},this.state&&this.renderMessages(!1)}focusInside(){let u=this.ui;if(!u)return;let n=typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches;u.formView.hidden?n?u.panel.focus():u.input.focus():(u.formView.querySelector("input,select,textarea")||u.panel).focus()}render(){!this.ui||!this.state||(this.renderMessages(!0),this.renderChips())}renderMessages(u){let n=this.ui,t=this.state;if(!n||!t)return;n.rendered>t.messages.length&&(n.messages.textContent="",n.rendered=0);let i=[];for(let o=n.rendered;o<t.messages.length;o++){let r=t.messages[o];n.messages.appendChild(He(r,this.t)),r.from==="bot"&&i.push(r.ai?`${this.t["chat.aiLabel"]}: ${r.text}`:r.text)}n.rendered=t.messages.length,this.waiting?n.messages.appendChild(n.typing):n.typing.remove(),u&&i.length&&(n.live.textContent=i.join(`
65
+ `)),n.messages.scrollTop=n.messages.scrollHeight}renderChips(){let u=this.ui,n=this.state;if(!(!u||!n)){u.chips.textContent="";for(let t of n.chips){let i=s("button",{type:"button",class:`chip chip-${t.kind}`},t.label);i.addEventListener("click",()=>this.onChip(t)),u.chips.appendChild(i)}u.chips.hidden=n.chips.length===0}}showChat(){let u=this.ui;u&&(u.formView.hidden=!0,u.formView.textContent="",u.chatView.hidden=!1,this.render(),this.isOpen&&this.focusInside())}showForm(u){let n=this.ui,t=this.release;if(!n||!t)return;let i=this.t,o=t.settings.contactTopics||[],r=(d,l,w)=>s("div",{class:"field"},s("label",{for:d},l),w),a=s("input",{id:"kc-name",type:"text",autocomplete:"name",maxlength:"100",dir:"auto"});a.value=this.opts.userName||"";let c=s("input",{id:"kc-email",type:"email",autocomplete:"email",dir:"auto"}),f=s("input",{id:"kc-phone",type:"tel",autocomplete:"tel",dir:"auto"}),m=null;if(o.length){m=s("select",{id:"kc-topic"},s("option",{value:""},""));for(let d of o)m.appendChild(s("option",{value:d.id},d.name));u.contactTopicId&&o.some(d=>d.id===u.contactTopicId)&&(m.value=u.contactTopicId)}let k=s("textarea",{id:"kc-message",required:!0,maxlength:"2000",dir:"auto"});k.value=u.prefill||"";let p=s("div",{class:"error",role:"alert"}),E=s("button",{type:"submit",class:"btn btn-primary"},i["form.submit"]),A=s("button",{type:"button",class:"btn"},i["form.cancel"]);A.addEventListener("click",()=>this.showChat());let b=s("form",{class:"form",novalidate:!0},s("h2",null,i["form.title"]),r("kc-name",i["form.name"],a),r("kc-email",i["form.email"],c),r("kc-phone",i["form.phone"],f),m?r("kc-topic",i["form.topic"],m):null,r("kc-message",i["form.message"],k),p,s("div",{class:"actions"},E,A));b.addEventListener("submit",async d=>{var x;d.preventDefault();let l={message:k.value.trim(),name:a.value.trim()||void 0,email:c.value.trim()||void 0,phone:f.value.trim()||void 0,topicId:(m==null?void 0:m.value)||void 0,scriptId:u.scriptId||void 0,sessionId:(x=this.session)==null?void 0:x.id,transcript:u.transcript.slice(-200).map(y=>({...y,text:y.text.slice(0,1e3)}))},w=l.message?!l.email&&!l.phone&&!this.opts.userToken?i["form.contactRequired"]:l.email&&!_e.test(l.email)?i["form.emailInvalid"]:"":i["form.required"];if(w){p.textContent=w;return}p.textContent="",E.disabled=!0,E.textContent=i["form.sending"];let v=await Su(this.api,l);this.destroyed||(E.disabled=!1,E.textContent=i["form.submit"],v.ok?(this.flush(!1),this.emit({type:"ticket",id:v.id,number:v.number}),this.showSent(v.number)):p.textContent=Pe(v.code,v.message,i))}),n.formView.replaceChildren(b),n.chatView.hidden=!0,n.formView.hidden=!1,this.isOpen&&this.focusInside()}showSent(u){let n=this.ui;if(!n)return;let t=this.t,i=s("button",{type:"button",class:"btn btn-primary"},t["form.backToChat"]);i.addEventListener("click",()=>this.showChat());let o=s("p",{role:"status"},Eu(t["form.sent"],{number:u}));n.formView.replaceChildren(s("div",{class:"sent"},o,i)),i.focus()}};function Pe(e,u,n){return e==="ticket_contact_required"?n["form.contactRequired"]:e==="email_invalid"?n["form.emailInvalid"]:e==="network"?n["form.error"]:u||n["form.error"]}function He(e,u){let n=s("div",{class:`msg msg-${e.from}`,dir:"auto"});e.ai&&n.appendChild(s("span",{class:"ai"},u["chat.aiLabel"]));let t=e.from==="bot"&&e.imageUrl?M(e.imageUrl,["https:"]):null;return t&&n.appendChild(s("img",{src:t,alt:"",loading:"lazy"})),n.appendChild(e.from==="bot"&&!e.ai?Ru(e.text):document.createTextNode(e.text)),n}function Ue(e,u){let n=M(e,["https:","tel:"]);if(!n)return!1;let t=s("a",{href:n,target:"_blank",rel:"noopener noreferrer"});return t.style.display="none",(u||document.body).appendChild(t),t.click(),t.remove(),!0}var je=["init","open","close","toggle","setUser","destroy"];function $u(e=window){let u=e.Kavchat;if(u&&u.loaded)return{api:u,queue:[]};let n=Array.isArray(u==null?void 0:u.q)?u.q.filter(Array.isArray):[],t=null,i,o,r={loaded:!0,init(a){t&&t.destroy();let c={...a};return o!==void 0&&(c.open=o),i!==void 0&&(c.userToken=(i==null?void 0:i.token)||void 0,c.userName=(i==null?void 0:i.name)||void 0),o=i=void 0,t=new H(c),t.ready},open(){t?t.open():o=!0},close(){t?t.close():o=!1},toggle(){t?t.toggle():o=!o},setUser(a){t?t.setUser(a):i=a},destroy(){t&&t.destroy(),t=null},q:{push:(...a)=>(a.forEach(c=>iu(r,c)),0)},get widget(){return t}};return e.Kavchat=r,{api:r,queue:n}}function iu(e,u){let[n,...t]=u;if(!je.includes(n)){console.warn(`Kavchat: unknown method ${n}`);return}try{let i=e[n](...t);i&&typeof i.catch=="function"&&i.catch(o=>console.error("Kavchat:",o))}catch(i){console.error("Kavchat:",i)}}function Qe(e){if(!e)return null;let u=i=>e.getAttribute(i)||void 0,n=u("data-key");if(!n)return null;let t={publicKey:n};return u("data-api")&&(t.apiBase=u("data-api")),u("data-locale")&&(t.locale=u("data-locale")),u("data-user-token")&&(t.userToken=u("data-user-token")),u("data-user-name")&&(t.userName=u("data-user-name")),u("data-open")==="true"&&(t.open=!0),t}function $e(){return document.currentScript||document.querySelector('script[data-key][src*="kavchat"]')||document.querySelector("script[data-key]")}function Vu(e=$e()){let{api:u,queue:n}=$u(),t=Qe(e),i=n.findIndex(r=>r[0]==="init"),o=n.filter((r,a)=>a!==i);return i>=0?o.unshift(["init",{...t,...n[i][1]}]):t&&o.unshift(["init",t]),o.forEach(r=>iu(u,r)),u}try{Vu()}catch(e){console.error("Kavchat:",e)}})();
@@ -1,5 +1,7 @@
1
1
  /**
2
2
  * העיצוב כולו בתוך ה-Shadow DOM. all: initial על ה-host עוצר ירושה של גופן, צבע וכיוון מהאתר.
3
- * רק תכונות לוגיות (inline-start/end), כדי ש-dir="rtl" יהפוך את הכל בלי עקיפות ידניות
3
+ * רק תכונות לוגיות (inline-start/end), כדי ש-dir="rtl" יהפוך את הכל בלי עקיפות ידניות.
4
+ * שורות עם overflow:hidden (שם וכותרת משנה) מקבלות line-height נדיב, כדי שתנועות וטונים בתאית,
5
+ * שיושבים מעל ומתחת לשורה, לא ייחתכו. אין לבועות גובה קבוע ואין בהן overflow:hidden
4
6
  */
5
- export declare const CSS = "\n:host{all:initial}\n.kc{font-family:system-ui,-apple-system,\"Segoe UI\",Roboto,\"Noto Sans Hebrew\",\"Noto Sans Arabic\",Arial,sans-serif;font-size:15px;line-height:1.45;color:#1f2328;-webkit-font-smoothing:antialiased}\n.kc *,.kc *::before,.kc *::after{box-sizing:border-box}\n.kc [hidden]{display:none!important}\n.kc button,.kc input,.kc select,.kc textarea{font:inherit;color:inherit;margin:0}\n.kc :focus-visible{outline:2px solid var(--kc-accent);outline-offset:2px}\n.launcher{position:fixed;z-index:2147483000;inset-block-end:20px;inset-inline-end:20px;width:56px;height:56px;border-radius:50%;border:0;padding:0;background:var(--kc-primary);color:var(--kc-on-primary);cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:0 6px 20px rgba(0,0,0,.22);transition:transform .15s ease}\n.launcher:hover{transform:scale(1.05)}\n.launcher svg{width:28px;height:28px}\n.kc[data-pos=start] .launcher,.kc[data-pos=start] .panel{inset-inline-end:auto;inset-inline-start:20px}\n.panel{position:fixed;z-index:2147483001;inset-block-end:88px;inset-inline-end:20px;width:380px;max-width:calc(100vw - 40px);height:620px;max-height:calc(100vh - 108px);display:flex;flex-direction:column;background:#fff;border-radius:16px;box-shadow:0 12px 40px rgba(0,0,0,.24);overflow:hidden;animation:kc-in .18s ease-out}\n@keyframes kc-in{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:none}}\n.header{display:flex;align-items:center;gap:10px;padding:12px 14px;background:var(--kc-primary);color:var(--kc-on-primary);flex:none}\n.avatar{width:38px;height:38px;border-radius:50%;flex:none;display:flex;align-items:center;justify-content:center;overflow:hidden;background:rgba(255,255,255,.22);font-weight:600;font-size:15px}\n.avatar img{width:100%;height:100%;object-fit:cover}\n.titles{min-width:0;flex:1}\n.name{font-weight:600;font-size:16px;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.subtitle{font-size:13px;opacity:.85;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.close{flex:none;width:36px;height:36px;border:0;border-radius:50%;background:transparent;color:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0}\n.close:hover{background:rgba(127,127,127,.2)}\n.close svg{width:22px;height:22px}\n.banner{flex:none;background:#fff4e5;color:#7a4100;font-size:13px;padding:6px 14px}\n.view{flex:1;min-height:0;display:flex;flex-direction:column;background:#f6f7f9}\n.messages{flex:1;min-height:0;overflow-y:auto;padding:16px 14px 8px;display:flex;flex-direction:column;gap:6px;overscroll-behavior:contain}\n.msg{max-width:85%;padding:9px 13px;border-radius:16px;white-space:pre-wrap;overflow-wrap:anywhere}\n.msg-bot{align-self:flex-start;background:#fff;border:1px solid #e3e6ea;border-end-start-radius:4px}\n.msg-user{align-self:flex-end;background:var(--kc-primary);color:var(--kc-on-primary);border-end-end-radius:4px}\n.msg-user+.msg-bot,.msg-bot+.msg-user{margin-block-start:6px}\n.msg a{color:inherit;text-decoration:underline}\n.ai{display:block;font-size:11px;font-weight:600;color:#6b7280}\n.typing{color:#9ca3af;font-weight:700;animation:kc-dot 1s infinite}\n@keyframes kc-dot{50%{opacity:.3}}\n.msg img{display:block;max-width:100%;height:auto;border-radius:10px;margin-block-end:6px}\n.chips{flex:none;display:flex;flex-wrap:wrap;gap:6px;padding:4px 14px 10px;max-height:40%;overflow-y:auto}\n.chip{border:1px solid var(--kc-accent);background:#fff;color:var(--kc-accent);border-radius:999px;padding:6px 13px;cursor:pointer;font-size:14px;line-height:1.3;text-align:start}\n.chip:hover{background:var(--kc-primary);color:var(--kc-on-primary);border-color:var(--kc-primary)}\n.chip-home,.chip-back{border-color:#cfd4da;color:#4b5563}\n.composer{flex:none;display:flex;align-items:center;gap:8px;padding:8px 10px;border-block-start:1px solid #e3e6ea;background:#fff}\n.composer input{flex:1;min-width:0;border:0;outline:0;background:transparent;padding:8px 6px;font-size:16px}\n.kc .composer input:focus-visible{outline:0}\n.composer:focus-within{box-shadow:inset 0 2px 0 var(--kc-accent)}\n.send{flex:none;width:40px;height:40px;border:0;border-radius:50%;background:var(--kc-primary);color:var(--kc-on-primary);cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0}\n.send svg{width:20px;height:20px}\n.kc[dir=rtl] .send svg{transform:scaleX(-1)}\n.form{flex:1;min-height:0;overflow-y:auto;padding:16px 16px 12px;background:#fff;display:flex;flex-direction:column;gap:10px}\n.form h2{margin:0 0 4px;font-size:17px;font-weight:600}\n.field label{display:block;font-size:13px;color:#4b5563;margin-block-end:3px}\n.field input,.field select,.field textarea{display:block;width:100%;border:1px solid #cfd4da;border-radius:8px;padding:8px 10px;background:#fff;font-size:16px}\n.field textarea{min-height:96px;resize:vertical}\n.field input:focus,.field select:focus,.field textarea:focus{border-color:var(--kc-accent);outline:0;box-shadow:0 0 0 2px color-mix(in srgb,var(--kc-accent) 25%,transparent)}\n.error{color:#b42318;font-size:14px}\n.actions{display:flex;gap:8px;flex-wrap:wrap;margin-block-start:4px}\n.btn{border-radius:8px;padding:9px 16px;cursor:pointer;border:1px solid #cfd4da;background:#fff}\n.btn-primary{background:var(--kc-primary);color:var(--kc-on-primary);border-color:var(--kc-primary)}\n.btn:disabled{opacity:.6;cursor:default}\n.sent{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px;padding:24px;text-align:center;background:#fff}\n.badge{flex:none;display:block;text-align:center;font-size:12px;color:#6b7280;padding:6px;background:#fff;border-block-start:1px solid #eef0f2;text-decoration:none}\n.badge:hover{color:#1f2328}\n.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}\n@media (max-width:480px){.panel,.kc[data-pos=start] .panel{inset:0;width:100%;max-width:none;height:100%;max-height:none;border-radius:0}}\n@media (prefers-reduced-motion:reduce){.kc *{animation:none!important;transition:none!important}}\n";
7
+ export declare const CSS = "\n:host{all:initial}\n.kc{font-family:system-ui,-apple-system,\"Segoe UI\",Roboto,\"Noto Sans Hebrew\",\"Noto Sans Arabic\",\"Noto Sans Thai\",Arial,sans-serif;font-size:15px;line-height:1.45;color:#1f2328;-webkit-font-smoothing:antialiased}\n.kc *,.kc *::before,.kc *::after{box-sizing:border-box}\n.kc [hidden]{display:none!important}\n.kc button,.kc input,.kc select,.kc textarea{font:inherit;color:inherit;margin:0}\n.kc :focus-visible{outline:2px solid var(--kc-accent);outline-offset:2px}\n.launcher{position:fixed;z-index:2147483000;inset-block-end:20px;inset-inline-end:20px;width:56px;height:56px;border-radius:50%;border:0;padding:0;background:var(--kc-primary);color:var(--kc-on-primary);cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:0 6px 20px rgba(0,0,0,.22);transition:transform .15s ease}\n.launcher:hover{transform:scale(1.05)}\n.launcher svg{width:28px;height:28px}\n.kc[data-pos=start] .launcher,.kc[data-pos=start] .panel{inset-inline-end:auto;inset-inline-start:20px}\n.panel{position:fixed;z-index:2147483001;inset-block-end:88px;inset-inline-end:20px;width:380px;max-width:calc(100vw - 40px);height:620px;max-height:calc(100vh - 108px);display:flex;flex-direction:column;background:#fff;border-radius:16px;box-shadow:0 12px 40px rgba(0,0,0,.24);overflow:hidden;animation:kc-in .18s ease-out}\n@keyframes kc-in{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:none}}\n.header{display:flex;align-items:center;gap:10px;padding:12px 14px;background:var(--kc-primary);color:var(--kc-on-primary);flex:none}\n.avatar{width:38px;height:38px;border-radius:50%;flex:none;display:flex;align-items:center;justify-content:center;overflow:hidden;background:rgba(255,255,255,.22);font-weight:600;font-size:15px}\n.avatar img{width:100%;height:100%;object-fit:cover}\n.titles{min-width:0;flex:1}\n.name{font-weight:600;font-size:16px;line-height:1.6;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.subtitle{font-size:13px;line-height:1.6;opacity:.85;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.close{flex:none;width:36px;height:36px;border:0;border-radius:50%;background:transparent;color:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0}\n.close:hover{background:rgba(127,127,127,.2)}\n.close svg{width:22px;height:22px}\n.banner{flex:none;background:#fff4e5;color:#7a4100;font-size:13px;padding:6px 14px}\n.view{flex:1;min-height:0;display:flex;flex-direction:column;background:#f6f7f9}\n.messages{flex:1;min-height:0;overflow-y:auto;padding:16px 14px 8px;display:flex;flex-direction:column;gap:6px;overscroll-behavior:contain}\n.msg{max-width:85%;padding:9px 13px;border-radius:16px;white-space:pre-wrap;overflow-wrap:anywhere}\n.msg-bot{align-self:flex-start;background:#fff;border:1px solid #e3e6ea;border-end-start-radius:4px}\n.msg-user{align-self:flex-end;background:var(--kc-primary);color:var(--kc-on-primary);border-end-end-radius:4px}\n.msg-user+.msg-bot,.msg-bot+.msg-user{margin-block-start:6px}\n.msg a{color:inherit;text-decoration:underline}\n.ai{display:block;font-size:11px;font-weight:600;color:#6b7280}\n.typing{color:#9ca3af;font-weight:700;animation:kc-dot 1s infinite}\n@keyframes kc-dot{50%{opacity:.3}}\n.msg img{display:block;max-width:100%;height:auto;border-radius:10px;margin-block-end:6px}\n.chips{flex:none;display:flex;flex-wrap:wrap;gap:6px;padding:4px 14px 10px;max-height:40%;overflow-y:auto}\n.chip{border:1px solid var(--kc-accent);background:#fff;color:var(--kc-accent);border-radius:999px;padding:6px 13px;cursor:pointer;font-size:14px;line-height:1.4;text-align:start}\n.chip:hover{background:var(--kc-primary);color:var(--kc-on-primary);border-color:var(--kc-primary)}\n.chip-home,.chip-back{border-color:#cfd4da;color:#4b5563}\n.composer{flex:none;display:flex;align-items:center;gap:8px;padding:8px 10px;border-block-start:1px solid #e3e6ea;background:#fff}\n.composer input{flex:1;min-width:0;border:0;outline:0;background:transparent;padding:8px 6px;font-size:16px}\n.kc .composer input:focus-visible{outline:0}\n.composer:focus-within{box-shadow:inset 0 2px 0 var(--kc-accent)}\n.send{flex:none;width:40px;height:40px;border:0;border-radius:50%;background:var(--kc-primary);color:var(--kc-on-primary);cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0}\n.send svg{width:20px;height:20px}\n.kc[dir=rtl] .send svg{transform:scaleX(-1)}\n.form{flex:1;min-height:0;overflow-y:auto;padding:16px 16px 12px;background:#fff;display:flex;flex-direction:column;gap:10px}\n.form h2{margin:0 0 4px;font-size:17px;font-weight:600}\n.field label{display:block;font-size:13px;color:#4b5563;margin-block-end:3px}\n.field input,.field select,.field textarea{display:block;width:100%;border:1px solid #cfd4da;border-radius:8px;padding:8px 10px;background:#fff;font-size:16px}\n.field textarea{min-height:96px;resize:vertical}\n.field input:focus,.field select:focus,.field textarea:focus{border-color:var(--kc-accent);outline:0;box-shadow:0 0 0 2px color-mix(in srgb,var(--kc-accent) 25%,transparent)}\n.error{color:#b42318;font-size:14px}\n.actions{display:flex;gap:8px;flex-wrap:wrap;margin-block-start:4px}\n.btn{border-radius:8px;padding:9px 16px;cursor:pointer;border:1px solid #cfd4da;background:#fff}\n.btn-primary{background:var(--kc-primary);color:var(--kc-on-primary);border-color:var(--kc-primary)}\n.btn:disabled{opacity:.6;cursor:default}\n.sent{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px;padding:24px;text-align:center;background:#fff}\n.badge{flex:none;display:block;text-align:center;font-size:12px;color:#6b7280;padding:6px;background:#fff;border-block-start:1px solid #eef0f2;text-decoration:none}\n.badge:hover{color:#1f2328}\n.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}\n@media (max-width:480px){.panel,.kc[data-pos=start] .panel{inset:0;width:100%;max-width:none;height:100%;max-height:none;border-radius:0}}\n@media (prefers-reduced-motion:reduce){.kc *{animation:none!important;transition:none!important}}\n";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kavchat/widget",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Kavchat web widget: the embeddable scripted support chat for websites.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -25,7 +25,7 @@
25
25
  "prepublishOnly": "yarn build"
26
26
  },
27
27
  "dependencies": {
28
- "@kavchat/core": "0.0.1"
28
+ "@kavchat/core": "0.0.2"
29
29
  },
30
30
  "devDependencies": {
31
31
  "esbuild": "^0.28.2",