@helpai/elements 1.14.1 → 1.14.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/elements-web-component.esm.js +11 -11
- package/elements-web-component.esm.js.map +2 -2
- package/elements.cjs.js +4 -4
- package/elements.cjs.js.map +2 -2
- package/elements.esm.js +4 -4
- package/elements.esm.js.map +2 -2
- package/elements.js +29 -29
- package/elements.js.map +2 -2
- package/index.d.ts +1 -1
- package/index.mjs +4 -4
- package/llms-full.txt +142 -142
- package/llms.txt +19 -19
- package/package.json +1 -1
- package/react.d.ts +1 -1
- package/react.mjs +4 -4
- package/style.css +1 -1
- package/web-component.d.ts +1 -1
- package/web-component.mjs +4 -4
package/web-component.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{Component as e,h as t,render as n}from"preact";import{batch as r,computed as i,effect as a,signal as o,useComputed as s,useSignal as c}from"@preact/signals";import{useCallback as l,useEffect as u,useId as d,useLayoutEffect as f,useMemo as p,useRef as m,useState as h}from"preact/hooks";import{Fragment as g,jsx as _,jsxs as v}from"preact/jsx-runtime";import*as y from"streaming-markdown";import{memo as b}from"preact/compat";function x(e,t){if(e?.length&&t)return e.find(e=>e.locale===t)}function S(e,t){let{translations:n,defaultLocale:r,...i}=e,a=x(n,t);return a?{...i,title:a.title??i.title,description:a.description??i.description,content:a.content??i.content}:i}function C(e,t){let{translations:n,defaultLocale:r,...i}=e,a=x(n,t);return a?{...i,title:a.title??i.title,description:a.description??i.description}:i}function w(e,t){let{translations:n,defaultLocale:r,...i}=e,a=x(n,t);if(!a)return i;let o=new Map((a.fields??[]).map(e=>[e.name,e])),s=i.fields.map(e=>{let t=o.get(e.name);if(!t)return e;let n=new Map((t.options??[]).map(e=>[e.value,e]));return{...e,label:t.label??e.label,placeholder:t.placeholder??e.placeholder,validationHint:t.validationHint??e.validationHint,options:e.options?.map(e=>{let t=n.get(e.value);return t?{...e,label:t.label??e.label,description:t.description??e.description}:e})}});return{...i,title:a.title??i.title,description:a.description??i.description,submitLabel:a.submitLabel??i.submitLabel,fields:s}}const T={attach:`Attach files`,file:`File`,attachmentMimeRejected:`File type not supported`,attachmentTooLarge:`File is too large`,attachmentTooMany:`Attachment limit reached`,conversationClosed:`This chat is closed`,conversationLoading:`Loading chat…`,loadPreviousMessages:`Load previous messages`,close:`Close`,collapse:`Collapse`,collapseSidebar:`Collapse sidebar`,composerPlaceholder:`Type a message…`,dateLastWeek:`Last 7 days`,dateOlder:`Older`,dateToday:`Today`,dateYesterday:`Yesterday`,dropZone:`Drop files to attach`,errorGeneric:`Something went wrong`,errorRateLimited:`Too many requests — please try again in a moment.`,errorRateLimitedIn:`Too many requests — please try again in {seconds} s.`,errorOffline:`Can't reach the server. Check your connection and try again.`,errorServer:`Something went wrong on our side. Please try again.`,errorReconnecting:`Connection lost. Reconnecting…`,errorRetry:`Retry`,expand:`Expand`,expandSidebar:`Expand sidebar`,exitFullscreen:`Exit fullscreen`,fullscreen:`Fullscreen`,history:`History`,historyBack:`Back to chat`,historyEmpty:`No previous chats yet`,historyLoading:`Loading your chats…`,historyContinue:`Continue the chat`,historyTitle:`Chat history`,loadMoreConversations:`Load more conversations`,language:`Language`,launcherOpen:`Open chat`,launcherLabel:`Chat with us`,micStart:`Start voice input`,micStop:`Stop voice input`,micUnsupported:`Voice input is not supported in this browser`,moreActions:`More actions`,newConversation:`New chat`,panelTitle:`Chat`,popOut:`Open in new tab`,resizeHandle:`Drag to resize`,scrollToBottom:`Scroll to latest`,send:`Send`,queueMessage:`Queue message`,removeQueuedMessage:`Remove queued message`,compactingContext:`Optimizing conversation context…`,soundOff:`Sound off`,soundOn:`Sound on`,startNewConversation:`Start a new chat`,talkToOperator:`Talk to a person`,connectingOperator:`Connecting you to a person…`,noOperatorAvailable:`No one's available right now — leave your details and we'll follow up.`,chattingWithOperator:`You're chatting with {operator}`,cancelOperatorRequest:`Keep chatting with the AI`,stop:`Stop`,theme:`Theme`,themeAuto:`Auto`,themeDark:`Dark`,themeLight:`Light`,textSize:`Text size`,textSizeSmall:`Small`,textSizeNormal:`Normal`,textSizeLarge:`Large`,loading:`Loading…`,visualPreparing:`Preparing visual…`,visualError:`This visual could not be displayed.`,visualPartial:`Some parts of this visual could not be displayed.`,thinking:`Thinking…`,thought:`Thought`,thoughtFor:`Thought for {time}`,toolResult:`Result`,sources:`Sources`,feedbackUp:`Good response`,feedbackDown:`Bad response`,feedbackThanks:`Thanks for your feedback`,copy:`Copy`,copied:`Copied`,tabHome:`Home`,tabConversations:`Chats`,tabHelp:`Help`,tabNews:`News`,modulesEmpty:`Nothing here yet`,moduleBack:`Back`,contentLoading:`Loading…`,contentHelpful:`Was this helpful?`,homeGreeting:`How can we help?`,homeGreetingNamed:`Hi {name} 👋`,homeGreetingLead:`How can we help?`,homeSearchPlaceholder:`Search for help`,homeAskPlaceholder:`Ask a question…`,homeWhatsNew:`What's new`,homeContentTitle:`Popular articles`,homeStatus:`Status`,helpTitle:`Help`,helpSearchPlaceholder:`Search for help`,helpEmpty:`No help articles yet`,helpLoading:`Loading help…`,helpSearchEmpty:`No results for “{query}”`,helpShowMore:`Show more`,newsTitle:`News`,newsEmpty:`No news yet`,newsLoading:`Loading news…`,newsBack:`Back to news`,newsPublishedAt:`Published {date}`,newsShowMore:`Show more`,newsUnseen:`New post`,formSubmit:`Submit`,formSkip:`Maybe later`,formSubmitted:`Completed`,formSkipped:`Maybe later`,formFillOut:`Fill out`,formRequired:`This field is required`,formInvalidEmail:`Enter a valid email address`,formInvalidTel:`Enter a valid phone number`,formInvalidUrl:`Enter a valid URL`,formInvalidNumber:`Enter a valid number`,formTooShort:`Too short (min {min} characters)`,formTooLong:`Too long (max {max} characters)`,formNumberTooSmall:`Must be at least {min}`,formNumberTooLarge:`Must be at most {max}`,formPatternMismatch:`Please match the requested format`,formChooseAtLeast:`Choose at least {min}`,formChooseAtMost:`Choose at most {max}`,formOther:`Other`,formOtherPlaceholder:`Type your answer…`,inputRequired:`Questions for you`,inputBadge:`Questions`,inputAnswered:`Answered`,inputSkipped:`Skipped`,showOptions:`Show options`,hideOptions:`Hide options`,qtypeText:`Your answer`,qtypeEmail:`Email address`,qtypePhone:`Phone number`,qtypeNumber:`Number`,qtypeDate:`Date`,qtypeChooseOne:`Pick one`,qtypeChooseAny:`Pick any`,qtypeBoolean:`Yes / No`,inputSubmit:`Submit answers`,inputSubmitHint:`Enter to send · Shift+Enter = new line`,inputSkip:`Skip`,confirmYes:`Yes`,confirmNo:`No`,approve:`Approve`,reject:`Reject`,approvalPrompt:`{tool} requires your approval to execute.`,approvalBody:`Review the tool input above and decide whether to allow this action.`,approvalYourResponse:`Your response: {decision}`,approvalEditHint:`You can edit this response until this step continues.`,approvalSubmitting:`Response submitted. Request in progress…`,edit:`Edit`,toolParameters:`Parameters`,statusAwaiting:`Awaiting Approval`,statusResponded:`Submitted`,statusRunning:`Running`,statusCompleted:`Completed`,statusDenied:`Denied`,statusError:`Error`,statusSuperseded:`Skipped`,statusIncomplete:`Not completed`,toolStepsFailed:`{count} failed`,statusStopped:`Stopped`,toolStepsStopped:`Stopped after {count} steps`,toolStepsStoppedOne:`Stopped after 1 step`,thoughtsShowMore:`Show more`,thoughtsShowLess:`Show less`},E={en:T,fr:{attach:`Joindre des fichiers`,file:`Fichier`,attachmentMimeRejected:`Type de fichier non pris en charge`,attachmentTooLarge:`Le fichier est trop volumineux`,attachmentTooMany:`Limite de pièces jointes atteinte`,conversationClosed:`Ce chat est fermé`,conversationLoading:`Chargement du chat…`,loadPreviousMessages:`Charger les messages précédents`,close:`Fermer`,collapse:`Réduire`,collapseSidebar:`Réduire la barre latérale`,composerPlaceholder:`Écrivez un message…`,dateLastWeek:`7 derniers jours`,dateOlder:`Plus ancien`,dateToday:`Aujourd'hui`,dateYesterday:`Hier`,dropZone:`Déposez les fichiers à joindre`,errorGeneric:`Une erreur s'est produite`,errorRateLimited:`Trop de requêtes — veuillez réessayer dans un instant.`,errorRateLimitedIn:`Trop de requêtes — veuillez réessayer dans {seconds} s.`,errorOffline:`Impossible de joindre le serveur. Vérifiez votre connexion et réessayez.`,errorServer:`Un problème est survenu de notre côté. Veuillez réessayer.`,errorReconnecting:`Connexion perdue. Reconnexion…`,errorRetry:`Réessayer`,expand:`Agrandir`,expandSidebar:`Développer la barre latérale`,exitFullscreen:`Quitter le plein écran`,fullscreen:`Plein écran`,history:`Historique`,historyBack:`Retour au chat`,historyEmpty:`Aucun chat pour le moment`,historyContinue:`Poursuivre le chat`,historyLoading:`Chargement de vos chats…`,historyTitle:`Historique des chats`,loadMoreConversations:`Charger plus de conversations`,language:`Langue`,launcherOpen:`Ouvrir le chat`,launcherLabel:`Discuter avec nous`,micStart:`Démarrer la saisie vocale`,micStop:`Arrêter la saisie vocale`,micUnsupported:`La saisie vocale n'est pas prise en charge par ce navigateur`,moreActions:`Plus d'actions`,newConversation:`Nouveau chat`,panelTitle:`Chat`,popOut:`Ouvrir dans un nouvel onglet`,resizeHandle:`Glisser pour redimensionner`,scrollToBottom:`Aller au plus récent`,send:`Envoyer`,queueMessage:`Mettre le message en attente`,removeQueuedMessage:`Retirer le message en attente`,compactingContext:`Optimisation du contexte de la conversation…`,soundOff:`Son désactivé`,soundOn:`Son activé`,startNewConversation:`Démarrer un nouveau chat`,talkToOperator:`Parler à une personne`,connectingOperator:`Mise en relation avec une personne…`,noOperatorAvailable:`Personne n'est disponible pour le moment — laissez vos coordonnées et nous reviendrons vers vous.`,chattingWithOperator:`Vous discutez avec {operator}`,cancelOperatorRequest:`Continuer avec l'IA`,stop:`Arrêter`,theme:`Thème`,themeAuto:`Auto`,themeDark:`Sombre`,themeLight:`Clair`,textSize:`Taille du texte`,textSizeSmall:`Petite`,textSizeNormal:`Normale`,textSizeLarge:`Grande`,loading:`Chargement…`,visualPreparing:`Préparation du visuel…`,visualError:`Ce visuel n’a pas pu être affiché.`,visualPartial:`Certaines parties de ce visuel n’ont pas pu être affichées.`,thinking:`Réflexion…`,thought:`Réflexion`,thoughtFor:`Réflexion : {time}`,toolResult:`Résultat`,sources:`Sources`,feedbackUp:`Bonne réponse`,feedbackDown:`Mauvaise réponse`,feedbackThanks:`Merci pour votre retour`,copy:`Copier`,copied:`Copié`,tabHome:`Accueil`,tabConversations:`Chats`,tabHelp:`Aide`,tabNews:`Actualités`,modulesEmpty:`Rien pour le moment`,moduleBack:`Retour`,contentLoading:`Chargement…`,contentHelpful:`Cela vous a-t-il aidé ?`,homeGreeting:`Comment pouvons-nous vous aider ?`,homeGreetingNamed:`Bonjour {name} 👋`,homeGreetingLead:`Comment pouvons-nous vous aider ?`,homeSearchPlaceholder:`Rechercher de l'aide`,homeAskPlaceholder:`Posez une question…`,homeWhatsNew:`Nouveautés`,homeContentTitle:`Articles populaires`,homeStatus:`Statut`,helpTitle:`Aide`,helpSearchPlaceholder:`Rechercher de l'aide`,helpEmpty:`Aucun article d'aide pour le moment`,helpLoading:`Chargement de l'aide…`,helpSearchEmpty:`Aucun résultat pour «\xA0{query}\xA0»`,helpShowMore:`Afficher plus`,newsTitle:`Actualités`,newsEmpty:`Aucune actualité pour le moment`,newsLoading:`Chargement des actualités…`,newsBack:`Retour aux actualités`,newsPublishedAt:`Publié le {date}`,newsShowMore:`Afficher plus`,newsUnseen:`Nouvelle publication`,formSubmit:`Envoyer`,formSkip:`Plus tard`,formSubmitted:`Terminé`,formSkipped:`Plus tard`,formFillOut:`Remplir`,formRequired:`Ce champ est obligatoire`,formInvalidEmail:`Saisissez une adresse e-mail valide`,formInvalidTel:`Saisissez un numéro de téléphone valide`,formInvalidUrl:`Saisissez une URL valide`,formInvalidNumber:`Saisissez un nombre valide`,formTooShort:`Trop court (min. {min} caractères)`,formTooLong:`Trop long (max. {max} caractères)`,formNumberTooSmall:`Doit être au moins {min}`,formNumberTooLarge:`Doit être au plus {max}`,formPatternMismatch:`Veuillez respecter le format demandé`,formChooseAtLeast:`Choisissez au moins {min}`,formChooseAtMost:`Choisissez au plus {max}`,formOther:`Autre`,formOtherPlaceholder:`Saisissez votre réponse…`,inputRequired:`Questions pour vous`,inputBadge:`Questions`,inputAnswered:`Répondu`,inputSkipped:`Ignoré`,showOptions:`Afficher les options`,hideOptions:`Masquer les options`,qtypeText:`Votre réponse`,qtypeEmail:`Adresse e-mail`,qtypePhone:`Numéro de téléphone`,qtypeNumber:`Nombre`,qtypeDate:`Date`,qtypeChooseOne:`Choisir une`,qtypeChooseAny:`Choisir plusieurs`,qtypeBoolean:`Oui / Non`,inputSubmit:`Envoyer les réponses`,inputSubmitHint:`Entrée pour envoyer · Maj+Entrée = saut de ligne`,inputSkip:`Ignorer`,confirmYes:`Oui`,confirmNo:`Non`,approve:`Approuver`,reject:`Refuser`,approvalPrompt:`{tool} nécessite votre approbation pour s'exécuter.`,approvalBody:`Vérifiez les paramètres ci-dessus et décidez d'autoriser ou non cette action.`,approvalYourResponse:`Votre réponse : {decision}`,approvalEditHint:`Vous pouvez modifier votre réponse jusqu'à la reprise de cette étape.`,approvalSubmitting:`Réponse envoyée. Traitement en cours…`,edit:`Modifier`,toolParameters:`Paramètres`,statusAwaiting:`En attente d'approbation`,statusResponded:`Envoyé`,statusRunning:`En cours`,statusCompleted:`Terminé`,statusDenied:`Refusé`,statusError:`Erreur`,statusSuperseded:`Ignoré`,statusIncomplete:`Non terminé`,toolStepsFailed:`{count} en échec`,statusStopped:`Arrêté`,toolStepsStopped:`Arrêté après {count} étapes`,toolStepsStoppedOne:`Arrêté après 1 étape`,thoughtsShowMore:`Afficher plus`,thoughtsShowLess:`Afficher moins`},ar:{attach:`إرفاق ملفات`,file:`ملف`,attachmentMimeRejected:`نوع الملف غير مدعوم`,attachmentTooLarge:`حجم الملف كبير جدًا`,attachmentTooMany:`تم بلوغ الحد الأقصى للمرفقات`,conversationClosed:`تم إغلاق هذه الدردشة`,conversationLoading:`جارٍ تحميل الدردشة…`,loadPreviousMessages:`تحميل الرسائل السابقة`,close:`إغلاق`,collapse:`طيّ`,collapseSidebar:`طيّ الشريط الجانبي`,composerPlaceholder:`اكتب رسالة…`,dateLastWeek:`آخر ٧ أيام`,dateOlder:`أقدم`,dateToday:`اليوم`,dateYesterday:`أمس`,dropZone:`أفلت الملفات لإرفاقها`,errorGeneric:`حدث خطأ ما`,errorRateLimited:`طلبات كثيرة جدًا — يرجى المحاولة بعد لحظة.`,errorRateLimitedIn:`طلبات كثيرة جدًا — يرجى المحاولة بعد {seconds} ث.`,errorOffline:`تعذّر الوصول إلى الخادم. تحقّق من اتصالك وحاول مرة أخرى.`,errorServer:`حدث خطأ من جهتنا. يرجى المحاولة مرة أخرى.`,errorReconnecting:`انقطع الاتصال. جارٍ إعادة الاتصال…`,errorRetry:`إعادة المحاولة`,expand:`توسيع`,expandSidebar:`توسيع الشريط الجانبي`,exitFullscreen:`إنهاء ملء الشاشة`,fullscreen:`ملء الشاشة`,history:`السجل`,historyBack:`العودة إلى الدردشة`,historyEmpty:`لا توجد دردشات سابقة بعد`,historyContinue:`متابعة الدردشة`,historyLoading:`جارٍ تحميل دردشاتك…`,historyTitle:`سجل الدردشات`,loadMoreConversations:`تحميل المزيد من المحادثات`,language:`اللغة`,launcherOpen:`فتح الدردشة`,launcherLabel:`تحدث معنا`,micStart:`بدء الإدخال الصوتي`,micStop:`إيقاف الإدخال الصوتي`,micUnsupported:`الإدخال الصوتي غير مدعوم في هذا المتصفح`,moreActions:`إجراءات إضافية`,newConversation:`دردشة جديدة`,panelTitle:`الدردشة`,popOut:`فتح في علامة تبويب جديدة`,resizeHandle:`اسحب لتغيير الحجم`,scrollToBottom:`الانتقال إلى الأحدث`,send:`إرسال`,queueMessage:`إضافة الرسالة إلى قائمة الانتظار`,removeQueuedMessage:`إزالة الرسالة من قائمة الانتظار`,compactingContext:`جارٍ تحسين سياق المحادثة…`,soundOff:`كتم الصوت`,soundOn:`تشغيل الصوت`,startNewConversation:`بدء دردشة جديدة`,talkToOperator:`التحدث إلى شخص`,connectingOperator:`جارٍ توصيلك بشخص…`,noOperatorAvailable:`لا يوجد موظفون متاحون الآن — اترك بياناتك وسنتواصل معك.`,chattingWithOperator:`أنت تتحدث مع {operator}`,cancelOperatorRequest:`متابعة المحادثة مع الذكاء الاصطناعي`,stop:`إيقاف`,theme:`المظهر`,themeAuto:`تلقائي`,themeDark:`داكن`,themeLight:`فاتح`,textSize:`حجم النص`,textSizeSmall:`صغير`,textSizeNormal:`عادي`,textSizeLarge:`كبير`,loading:`جارٍ التحميل…`,visualPreparing:`جارٍ إعداد المحتوى المرئي…`,visualError:`تعذر عرض هذا المحتوى المرئي.`,visualPartial:`تعذر عرض بعض أجزاء هذا المحتوى المرئي.`,thinking:`يفكّر…`,thought:`تفكير`,thoughtFor:`فكّر لمدة {time}`,toolResult:`النتيجة`,sources:`المصادر`,feedbackUp:`رد جيد`,feedbackDown:`رد سيئ`,feedbackThanks:`شكرًا على ملاحظاتك`,copy:`نسخ`,copied:`تم النسخ`,tabHome:`الرئيسية`,tabConversations:`الدردشات`,tabHelp:`المساعدة`,tabNews:`الأخبار`,modulesEmpty:`لا شيء هنا بعد`,moduleBack:`رجوع`,contentLoading:`جارٍ التحميل…`,contentHelpful:`هل كان هذا مفيدًا؟`,homeGreeting:`كيف يمكننا مساعدتك؟`,homeGreetingNamed:`مرحبًا {name} 👋`,homeGreetingLead:`كيف يمكننا مساعدتك؟`,homeSearchPlaceholder:`ابحث عن مساعدة`,homeAskPlaceholder:`اطرح سؤالاً…`,homeWhatsNew:`ما الجديد`,homeContentTitle:`مقالات شائعة`,homeStatus:`الحالة`,helpTitle:`المساعدة`,helpSearchPlaceholder:`ابحث عن مساعدة`,helpEmpty:`لا توجد مقالات مساعدة بعد`,helpLoading:`جارٍ تحميل المساعدة…`,helpSearchEmpty:`لا نتائج لـ «{query}»`,helpShowMore:`عرض المزيد`,newsTitle:`الأخبار`,newsEmpty:`لا توجد أخبار بعد`,newsLoading:`جارٍ تحميل الأخبار…`,newsBack:`العودة إلى الأخبار`,newsPublishedAt:`نُشر في {date}`,newsShowMore:`عرض المزيد`,newsUnseen:`منشور جديد`,formSubmit:`إرسال`,formSkip:`لاحقًا`,formSubmitted:`تم`,formSkipped:`لاحقًا`,formFillOut:`تعبئة`,formRequired:`هذا الحقل مطلوب`,formInvalidEmail:`أدخل بريدًا إلكترونيًا صحيحًا`,formInvalidTel:`أدخل رقم هاتف صحيحًا`,formInvalidUrl:`أدخل رابطًا صحيحًا`,formInvalidNumber:`أدخل رقمًا صحيحًا`,formTooShort:`قصير جدًا (الحد الأدنى {min} حرفًا)`,formTooLong:`طويل جدًا (الحد الأقصى {max} حرفًا)`,formNumberTooSmall:`يجب ألا يقل عن {min}`,formNumberTooLarge:`يجب ألا يزيد عن {max}`,formPatternMismatch:`يرجى مطابقة الصيغة المطلوبة`,formChooseAtLeast:`اختر {min} على الأقل`,formChooseAtMost:`اختر {max} على الأكثر`,formOther:`أخرى`,formOtherPlaceholder:`اكتب إجابتك…`,inputRequired:`أسئلة لك`,inputBadge:`أسئلة`,inputAnswered:`تمت الإجابة`,inputSkipped:`تم التخطي`,showOptions:`إظهار الخيارات`,hideOptions:`إخفاء الخيارات`,qtypeText:`إجابتك`,qtypeEmail:`عنوان البريد الإلكتروني`,qtypePhone:`رقم الهاتف`,qtypeNumber:`رقم`,qtypeDate:`تاريخ`,qtypeChooseOne:`اختر واحدًا`,qtypeChooseAny:`اختر أيًا`,qtypeBoolean:`نعم / لا`,inputSubmit:`إرسال الإجابات`,inputSubmitHint:`Enter للإرسال · Shift+Enter = سطر جديد`,inputSkip:`تخطٍّ`,confirmYes:`نعم`,confirmNo:`لا`,approve:`موافقة`,reject:`رفض`,approvalPrompt:`تتطلب {tool} موافقتك للتنفيذ.`,approvalBody:`راجع مُعطيات الأداة أعلاه وقرّر السماح بهذا الإجراء أو رفضه.`,approvalYourResponse:`ردّك: {decision}`,approvalEditHint:`يمكنك تعديل ردّك حتى تستأنف هذه الخطوة.`,approvalSubmitting:`تم إرسال الرد. جارٍ التنفيذ…`,edit:`تعديل`,toolParameters:`المعطيات`,statusAwaiting:`بانتظار الموافقة`,statusResponded:`تم الإرسال`,statusRunning:`قيد التنفيذ`,statusCompleted:`مكتمل`,statusDenied:`مرفوض`,statusError:`خطأ`,statusSuperseded:`تم التخطي`,statusIncomplete:`لم يكتمل`,toolStepsFailed:`فشل {count}`,statusStopped:`أُوقف`,toolStepsStopped:`أُوقف بعد {count} خطوات`,toolStepsStoppedOne:`أُوقف بعد خطوة واحدة`,thoughtsShowMore:`عرض المزيد`,thoughtsShowLess:`عرض أقل`},es:{attach:`Adjuntar archivos`,file:`Archivo`,attachmentMimeRejected:`Tipo de archivo no admitido`,attachmentTooLarge:`El archivo es demasiado grande`,attachmentTooMany:`Se alcanzó el límite de adjuntos`,conversationClosed:`Este chat está cerrado`,conversationLoading:`Cargando chat…`,loadPreviousMessages:`Cargar mensajes anteriores`,close:`Cerrar`,collapse:`Contraer`,collapseSidebar:`Contraer la barra lateral`,composerPlaceholder:`Escribe un mensaje…`,dateLastWeek:`Últimos 7 días`,dateOlder:`Anteriores`,dateToday:`Hoy`,dateYesterday:`Ayer`,dropZone:`Suelta los archivos para adjuntarlos`,errorGeneric:`Algo salió mal`,errorRateLimited:`Demasiadas solicitudes: inténtalo de nuevo en un momento.`,errorRateLimitedIn:`Demasiadas solicitudes: inténtalo de nuevo en {seconds} s.`,errorOffline:`No se puede conectar con el servidor. Revisa tu conexión e inténtalo de nuevo.`,errorServer:`Algo salió mal por nuestra parte. Inténtalo de nuevo.`,errorReconnecting:`Se perdió la conexión. Reconectando…`,errorRetry:`Reintentar`,expand:`Ampliar`,expandSidebar:`Expandir la barra lateral`,exitFullscreen:`Salir de pantalla completa`,fullscreen:`Pantalla completa`,history:`Historial`,historyBack:`Volver al chat`,historyEmpty:`Aún no tienes chats`,historyContinue:`Continuar el chat`,historyLoading:`Cargando tus chats…`,historyTitle:`Historial de chats`,loadMoreConversations:`Cargar más conversaciones`,language:`Idioma`,launcherOpen:`Abrir el chat`,launcherLabel:`Chatea con nosotros`,micStart:`Iniciar entrada de voz`,micStop:`Detener entrada de voz`,micUnsupported:`Este navegador no admite la entrada de voz`,moreActions:`Más acciones`,newConversation:`Nuevo chat`,panelTitle:`Chat`,popOut:`Abrir en una pestaña nueva`,resizeHandle:`Arrastra para cambiar el tamaño`,scrollToBottom:`Ir a lo más reciente`,send:`Enviar`,queueMessage:`Poner mensaje en cola`,removeQueuedMessage:`Quitar mensaje de la cola`,compactingContext:`Optimizando el contexto de la conversación…`,soundOff:`Sonido desactivado`,soundOn:`Sonido activado`,startNewConversation:`Iniciar un chat nuevo`,talkToOperator:`Hablar con una persona`,connectingOperator:`Conectándote con una persona…`,noOperatorAvailable:`Nadie está disponible ahora — deja tus datos y te contactaremos.`,chattingWithOperator:`Estás chateando con {operator}`,cancelOperatorRequest:`Seguir con la IA`,stop:`Detener`,theme:`Tema`,themeAuto:`Automático`,themeDark:`Oscuro`,themeLight:`Claro`,textSize:`Tamaño del texto`,textSizeSmall:`Pequeño`,textSizeNormal:`Normal`,textSizeLarge:`Grande`,loading:`Cargando…`,visualPreparing:`Preparando visualización…`,visualError:`No se pudo mostrar esta visualización.`,visualPartial:`No se pudieron mostrar algunas partes de esta visualización.`,thinking:`Pensando…`,thought:`Razonamiento`,thoughtFor:`Razonó durante {time}`,toolResult:`Resultado`,sources:`Fuentes`,feedbackUp:`Buena respuesta`,feedbackDown:`Mala respuesta`,feedbackThanks:`Gracias por tu opinión`,copy:`Copiar`,copied:`Copiado`,tabHome:`Inicio`,tabConversations:`Chats`,tabHelp:`Ayuda`,tabNews:`Novedades`,modulesEmpty:`Aún no hay nada aquí`,moduleBack:`Atrás`,contentLoading:`Cargando…`,contentHelpful:`¿Te resultó útil?`,homeGreeting:`¿Cómo podemos ayudarte?`,homeGreetingNamed:`Hola, {name} 👋`,homeGreetingLead:`¿Cómo podemos ayudarte?`,homeSearchPlaceholder:`Buscar ayuda`,homeAskPlaceholder:`Haz una pregunta…`,homeWhatsNew:`Lo nuevo`,homeContentTitle:`Artículos populares`,homeStatus:`Estado`,helpTitle:`Ayuda`,helpSearchPlaceholder:`Buscar ayuda`,helpEmpty:`Aún no hay artículos de ayuda`,helpLoading:`Cargando la ayuda…`,helpSearchEmpty:`Sin resultados para «{query}»`,helpShowMore:`Mostrar más`,newsTitle:`Novedades`,newsEmpty:`Aún no hay novedades`,newsLoading:`Cargando novedades…`,newsBack:`Volver a novedades`,newsPublishedAt:`Publicado el {date}`,newsShowMore:`Mostrar más`,newsUnseen:`Publicación nueva`,formSubmit:`Enviar`,formSkip:`Quizá más tarde`,formSubmitted:`Completado`,formSkipped:`Quizá más tarde`,formFillOut:`Completar`,formRequired:`Este campo es obligatorio`,formInvalidEmail:`Introduce un correo electrónico válido`,formInvalidTel:`Introduce un número de teléfono válido`,formInvalidUrl:`Introduce una URL válida`,formInvalidNumber:`Introduce un número válido`,formTooShort:`Demasiado corto (mín. {min} caracteres)`,formTooLong:`Demasiado largo (máx. {max} caracteres)`,formNumberTooSmall:`Debe ser al menos {min}`,formNumberTooLarge:`Debe ser como máximo {max}`,formPatternMismatch:`Respeta el formato solicitado`,formChooseAtLeast:`Elige al menos {min}`,formChooseAtMost:`Elige como máximo {max}`,formOther:`Otro`,formOtherPlaceholder:`Escribe tu respuesta…`,inputRequired:`Preguntas para ti`,inputBadge:`Preguntas`,inputAnswered:`Respondido`,inputSkipped:`Omitido`,showOptions:`Mostrar opciones`,hideOptions:`Ocultar opciones`,qtypeText:`Tu respuesta`,qtypeEmail:`Correo electrónico`,qtypePhone:`Número de teléfono`,qtypeNumber:`Número`,qtypeDate:`Fecha`,qtypeChooseOne:`Elige una`,qtypeChooseAny:`Elige varias`,qtypeBoolean:`Sí / No`,inputSubmit:`Enviar respuestas`,inputSubmitHint:`Enter para enviar · Mayús+Enter = nueva línea`,inputSkip:`Omitir`,confirmYes:`Sí`,confirmNo:`No`,approve:`Aprobar`,reject:`Rechazar`,approvalPrompt:`{tool} requiere tu aprobación para ejecutarse.`,approvalBody:`Revisa los parámetros de arriba y decide si permites esta acción.`,approvalYourResponse:`Tu respuesta: {decision}`,approvalEditHint:`Puedes cambiar tu respuesta hasta que este paso continúe.`,approvalSubmitting:`Respuesta enviada. Procesando…`,edit:`Editar`,toolParameters:`Parámetros`,statusAwaiting:`Esperando aprobación`,statusResponded:`Enviado`,statusRunning:`En curso`,statusCompleted:`Completado`,statusDenied:`Denegado`,statusError:`Error`,statusSuperseded:`Omitido`,statusIncomplete:`No completado`,toolStepsFailed:`{count} con error`,statusStopped:`Detenido`,toolStepsStopped:`Detenido tras {count} pasos`,toolStepsStoppedOne:`Detenido tras 1 paso`,thoughtsShowMore:`Mostrar más`,thoughtsShowLess:`Mostrar menos`},he:{attach:`צירוף קבצים`,file:`קובץ`,attachmentMimeRejected:`סוג הקובץ אינו נתמך`,attachmentTooLarge:`הקובץ גדול מדי`,attachmentTooMany:`הגעת למספר המרבי של קבצים מצורפים`,conversationClosed:`הצ׳אט הזה נסגר`,conversationLoading:`טוען צ׳אט…`,loadPreviousMessages:`טעינת הודעות קודמות`,close:`סגירה`,collapse:`כיווץ`,collapseSidebar:`כיווץ סרגל הצד`,composerPlaceholder:`כתוב הודעה…`,dateLastWeek:`7 הימים האחרונים`,dateOlder:`ישן יותר`,dateToday:`היום`,dateYesterday:`אתמול`,dropZone:`שחרר קבצים כדי לצרף`,errorGeneric:`משהו השתבש`,errorRateLimited:`יותר מדי בקשות — נסה שוב בעוד רגע.`,errorRateLimitedIn:`יותר מדי בקשות — נסה שוב בעוד {seconds} שנ׳.`,errorOffline:`אין חיבור לשרת. בדוק את החיבור ונסה שוב.`,errorServer:`משהו השתבש אצלנו. נסה שוב.`,errorReconnecting:`החיבור אבד. מתחבר מחדש…`,errorRetry:`נסה שוב`,expand:`הרחבה`,expandSidebar:`הרחבת סרגל הצד`,exitFullscreen:`יציאה ממסך מלא`,fullscreen:`מסך מלא`,history:`היסטוריה`,historyBack:`חזרה לצ׳אט`,historyEmpty:`אין עדיין צ׳אטים קודמים`,historyContinue:`המשך צ׳אט`,historyLoading:`טוען את הצ׳אטים שלך…`,historyTitle:`היסטוריית צ׳אטים`,loadMoreConversations:`טעינת שיחות נוספות`,language:`שפה`,launcherOpen:`פתיחת צ׳אט`,launcherLabel:`דברו איתנו`,micStart:`התחלת קלט קולי`,micStop:`עצירת קלט קולי`,micUnsupported:`קלט קולי אינו נתמך בדפדפן זה`,moreActions:`פעולות נוספות`,newConversation:`צ׳אט חדש`,panelTitle:`צ׳אט`,popOut:`פתיחה בכרטיסייה חדשה`,resizeHandle:`גרור לשינוי הגודל`,scrollToBottom:`מעבר לחדש ביותר`,send:`שליחה`,queueMessage:`הוספת ההודעה לתור`,removeQueuedMessage:`הסרת ההודעה מהתור`,compactingContext:`מבצע אופטימיזציה להקשר השיחה…`,soundOff:`השתקת הצליל`,soundOn:`הפעלת הצליל`,startNewConversation:`התחלת צ׳אט חדש`,talkToOperator:`דברו עם אדם`,connectingOperator:`מחברים אותך לאדם…`,noOperatorAvailable:`אין נציגים זמינים כעת — השאר את הפרטים שלך ונחזור אליך.`,chattingWithOperator:`אתה מצ׳וטט עם {operator}`,cancelOperatorRequest:`המשך לשוחח עם ה-AI`,stop:`עצירה`,theme:`ערכת נושא`,themeAuto:`אוטומטי`,themeDark:`כהה`,themeLight:`בהיר`,textSize:`גודל טקסט`,textSizeSmall:`קטן`,textSizeNormal:`רגיל`,textSizeLarge:`גדול`,loading:`טוען…`,visualPreparing:`מכין תצוגה…`,visualError:`לא ניתן היה להציג תצוגה זו.`,visualPartial:`לא ניתן היה להציג חלקים מתצוגה זו.`,thinking:`חושב…`,thought:`מחשבה`,thoughtFor:`חשב במשך {time}`,toolResult:`תוצאה`,sources:`מקורות`,feedbackUp:`תשובה טובה`,feedbackDown:`תשובה גרועה`,feedbackThanks:`תודה על המשוב`,copy:`העתק`,copied:`הועתק`,tabHome:`בית`,tabConversations:`צ׳אטים`,tabHelp:`עזרה`,tabNews:`חדשות`,modulesEmpty:`אין כאן עדיין כלום`,moduleBack:`חזרה`,contentLoading:`טוען…`,contentHelpful:`האם זה עזר?`,homeGreeting:`כיצד נוכל לעזור?`,homeGreetingNamed:`שלום {name} 👋`,homeGreetingLead:`כיצד נוכל לעזור?`,homeSearchPlaceholder:`חיפוש עזרה`,homeAskPlaceholder:`שאלו שאלה…`,homeWhatsNew:`מה חדש`,homeContentTitle:`מאמרים פופולריים`,homeStatus:`סטטוס`,helpTitle:`עזרה`,helpSearchPlaceholder:`חיפוש עזרה`,helpEmpty:`אין עדיין מאמרי עזרה`,helpLoading:`טוען עזרה…`,helpSearchEmpty:`אין תוצאות עבור „{query}”`,helpShowMore:`הצגת עוד`,newsTitle:`חדשות`,newsEmpty:`אין עדיין חדשות`,newsLoading:`טוען חדשות…`,newsBack:`חזרה לחדשות`,newsPublishedAt:`פורסם ב-{date}`,newsShowMore:`הצגת עוד`,newsUnseen:`פוסט חדש`,formSubmit:`שליחה`,formSkip:`אחר כך`,formSubmitted:`נשלח`,formSkipped:`דולג`,formFillOut:`מילוי`,formRequired:`שדה חובה`,formInvalidEmail:`הזן כתובת אימייל תקינה`,formInvalidTel:`הזן מספר טלפון תקין`,formInvalidUrl:`הזן כתובת URL תקינה`,formInvalidNumber:`הזן מספר תקין`,formTooShort:`קצר מדי (לפחות {min} תווים)`,formTooLong:`ארוך מדי (לכל היותר {max} תווים)`,formNumberTooSmall:`חייב להיות לפחות {min}`,formNumberTooLarge:`חייב להיות לכל היותר {max}`,formPatternMismatch:`התאם לתבנית הנדרשת`,formChooseAtLeast:`בחר לפחות {min}`,formChooseAtMost:`בחר לכל היותר {max}`,formOther:`אחר`,formOtherPlaceholder:`כתוב את תשובתך…`,inputRequired:`שאלות עבורך`,inputBadge:`שאלות`,inputAnswered:`נענה`,inputSkipped:`דולג`,showOptions:`הצג אפשרויות`,hideOptions:`הסתר אפשרויות`,qtypeText:`התשובה שלך`,qtypeEmail:`כתובת אימייל`,qtypePhone:`מספר טלפון`,qtypeNumber:`מספר`,qtypeDate:`תאריך`,qtypeChooseOne:`בחר אחת`,qtypeChooseAny:`בחר כמה`,qtypeBoolean:`כן / לא`,inputSubmit:`שליחת תשובות`,inputSubmitHint:`Enter לשליחה · Shift+Enter = שורה חדשה`,inputSkip:`דילוג`,confirmYes:`כן`,confirmNo:`לא`,approve:`אישור`,reject:`דחייה`,approvalPrompt:`הכלי {tool} דורש את אישורך כדי לפעול.`,approvalBody:`בדוק את פרמטרי הכלי שלמעלה והחלט אם לאשר פעולה זו.`,approvalYourResponse:`התגובה שלך: {decision}`,approvalEditHint:`ניתן לערוך את תגובתך עד שהשלב הזה יתחדש.`,approvalSubmitting:`התגובה נשלחה. מבצע…`,edit:`עריכה`,toolParameters:`פרמטרים`,statusAwaiting:`ממתין לאישור`,statusResponded:`נשלח`,statusRunning:`פועל`,statusCompleted:`הושלם`,statusDenied:`נדחה`,statusError:`שגיאה`,statusSuperseded:`דולג`,statusIncomplete:`לא הושלם`,toolStepsFailed:`{count} נכשלו`,statusStopped:`נעצר`,toolStepsStopped:`נעצר אחרי {count} שלבים`,toolStepsStoppedOne:`נעצר אחרי שלב אחד`,thoughtsShowMore:`הצגת עוד`,thoughtsShowLess:`הצגת פחות`}};function D(e,t){let n=O(e),r=M(t),i=n===`en`?{}:E[n]??{},a=r?t[n]??{}:t??{},o=r?t.en??{}:{};return{...T,...i,...o,...a}}function O(e){return(e.split(`-`)[0]??`en`).toLowerCase()}const k=/* @__PURE__ */ new Set([`ar`,`he`,`iw`,`fa`,`ur`,`ps`,`sd`,`ug`,`yi`,`dv`,`ckb`,`ks`,`nqo`,`prs`,`syr`]);function A(e){return k.has(O(e))}function j(e,t){return e[t]??t}function M(e){if(!e)return!1;for(let t of Object.values(e))if(t&&typeof t==`object`)return!0;return!1}const N={id:`help-ai`,name:`@helpai/elements`,global:`HelpAI`,tagName:`web-ai-chat`,cssPrefix:`helpai`,defaultBaseUrl:`https://help.ai`,displayName:`Help AI`,domain:`help.ai`,siteUrl:`https://help.ai`},ee=new class{get(e){try{return localStorage.getItem(e)}catch{return null}}set(e,t){try{localStorage.setItem(e,t)}catch{}}remove(e){try{localStorage.removeItem(e)}catch{}}},te={maxBytes:10485760,maxCount:10,accept:`*/*`},P={voice:`local`},ne={list:[],byTrigger:{}},re={enabled:!0,sampleRate:1},F={upload:`/pai/upload-file`,transcribe:`/pai/transcribe-audio`,submitForm:`/pai/submit-form`},I={variant:`circle`,size:`md`,label:void 0,icon:`chat`,hidden:!1},ie={floating:[`theme`,`textSize`,`history`,`close`,`clear`,`expand`,`fullscreen`,`popOut`,`sound`,`language`],inline:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`],standalone:[`theme`,`textSize`,`history`,`clear`,`sound`,`language`],page:[`theme`,`textSize`,`history`,`clear`,`sound`,`language`],modal:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`],drawer:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`]},ae={enabled:!0,volume:.3,events:void 0},L={enabled:!0,events:void 0},oe=[{label:`tabConversations`,layout:`chat`}],se=[`off`,`error`,`warn`,`info`,`debug`,`trace`],ce=N.cssPrefix,R=`${ce}.debug`,le=`__${N.global}_DEBUG__`,ue=`${ce}-debug`;let de=2;function fe(){if(typeof window>`u`)return 2;try{let e=new URLSearchParams(window.location.search).get(ue);if(e!==null){let t=pe(e);if(t>=0)return t}}catch{}try{let e=window.localStorage?.getItem(R);if(e){let t=pe(e);if(t>=0)return t}}catch{}return Reflect.get(window,le)?4:2}function pe(e){if(e===!0||e===`1`||e===`true`)return 4;if(e===!1||e===`0`||e===`false`||e===`off`)return 0;if(typeof e==`number`)return Math.max(0,Math.min(5,Math.floor(e)));if(typeof e==`string`){let t=se.findIndex(t=>t===e);if(t>=0)return t}return-1}de=fe();function me(e){let t=`[${ce}:${e}]`;function n(e,n,r){return(r,i)=>{de<e||(i===void 0?console[n](t,r):console[n](t,r,i))}}return{error:n(1,`error`,`error`),warn:n(2,`warn`,`warn`),info:n(3,`info`,`info`),debug:n(4,`debug`,`debug`),trace:n(5,`debug`,`trace`),scope:t=>me(`${e}:${t}`)}}const z=me(`core`),he=z.scope(`context`),ge=/* @__PURE__ */ new Set([`visitorId`,`conversationId`,`jwt`,`token`,`authorization`,`password`]),_e=1024,ve=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function ye(e){return xe(e,`userContext`,!0)}function be(e){return xe(e,`pageContext`,!1)}function xe(e,t,n){if(e==null)return;if(typeof e!=`object`||Array.isArray(e)){he.warn(`ignored ${t} — expected an object`,{type:Array.isArray(e)?`array`:typeof e});return}let r={},i=0;for(let[n,a]of Object.entries(e)){if(ge.has(n)){he.warn(`dropped reserved ${t} key "${n}" — managed by the widget, not host-settable`);continue}if(a==null)continue;if(i>=50){he.warn(`${t} truncated at 50 keys — dropped "${n}"`);continue}let e=Se(t,n,a);e!==void 0&&(r[n]=e,i++)}return n&&typeof r.email==`string`&&!ve.test(r.email)&&(he.warn(`dropped malformed context field`,{field:`${t}.email`,reason:`invalid format`}),delete r.email),Object.keys(r).length>0?r:void 0}function Se(e,t,n){if(typeof n==`boolean`)return n;if(typeof n==`number`){if(!Number.isFinite(n)){he.warn(`dropped non-finite ${e}.${t}`);return}return n}if(typeof n==`string`){let r=n.trim();return r===``?void 0:r.length>_e?(he.warn(`truncated ${e}.${t} to ${_e} chars`),r.slice(0,_e)):r}he.warn(`dropped ${e}.${t} — only string/number/boolean values are allowed`,{type:typeof n})}function Ce(e){let t=typeof e==`object`&&e?e:{},n=t.presentation??{},r=t.behavior??{},i=t.i18n??{},a=t.feedback??{},o=t.footer??{},s=t.header??{},c={enabled:t.history?.enabled??!0},{themeMode:l,themeOverrides:u}=we(t.theme),d=n.mode??`floating`,f=Te(i.defaultLocale),p=i.availableLocales??[i.locale??f],m=Ee(i.locale??f,p,f),h=(t.baseUrl??N.defaultBaseUrl).replace(/\/$/,``),g=(t.agentApiBaseUrl??`${h}/api/agent`).replace(/\/$/,``),_=(t.dataApiBaseUrl??`${h}/api/data`).replace(/\/$/,``);return{widgetId:t.widgetId??`default`,publicKey:t.publicKey,aiAgentDeploymentId:t.aiAgentDeploymentId,baseUrl:h,agentApiBaseUrl:g,dataApiBaseUrl:_,userContext:ye(t.userContext),pageContext:be(t.pageContext),position:n.position??`bottom-right`,themeMode:l,textSize:`normal`,themeOverrides:u,mode:d,iframe:n.iframe??!1,responseMode:r.responseMode??`streaming`,showReasoning:r.showReasoning??!1,showToolCalls:r.showToolCalls??!1,showSources:r.showSources??!1,enableMessageFeedback:!(r.disableMessageFeedback??!1),autoSendSuggestions:r.autoSendSuggestions??!1,popOutUrl:r.popOutUrl,features:{voice:t.features?.voice??P.voice,fileUpload:!(t.features?.disableFileUpload??!1),humanInLoop:!(t.features?.disableHumanInLoop??!1),operatorRequest:t.features?.enableOperatorRequest===!0},forms:Pe(t.forms,m),endpoints:{upload:t.endpoints?.upload??F.upload,transcribe:t.endpoints?.transcribe??F.transcribe,submitForm:t.endpoints?.submitForm??F.submitForm},attachments:{accept:t.composer?.attachments?.accept??te.accept,maxBytes:t.composer?.attachments?.maxBytes??te.maxBytes,maxCount:t.composer?.attachments?.maxCount??te.maxCount},locale:m,defaultLocale:f,availableLocales:p,startMinimized:r.startMinimized??!0,actions:De(d,s.actions,c.enabled),size:n.size??{},launcher:Ie(t.launcher),sound:Oe(a.sound),haptics:ke(a.haptics),strings:D(m,i.strings),stringsOverride:i.strings,composerDisclaimer:o.composerDisclaimer??``,poweredBy:je(o.poweredBy),composer:Me(t.composer),modules:Ne(t.modules,c.enabled),tracking:Ae(t.tracking,_),history:c,storage:t.storage??ee,userToken:t.userToken,tools:t.tools,onMessage:t.onMessage,onOpen:t.onOpen,onClose:t.onClose,onError:t.onError}}function we(e){if(typeof e==`string`)return{themeMode:e,themeOverrides:{}};if(!e||typeof e!=`object`)return{themeMode:`auto`,themeOverrides:{}};let{mode:t,...n}=e;return{themeMode:t??`auto`,themeOverrides:n}}function Te(e){return e&&e!==`auto`?e:globalThis.navigator?.language||`en`}function Ee(e,t,n){return t.length<=1||t.includes(e)?e:t.includes(n)?n:t[0]??e}function De(e,t,n){let r=t??ie[e];return n?r:r.filter(e=>e!==`history`)}function Oe(e){return{enabled:e?.enabled??ae.enabled,volume:e?.volume??ae.volume,events:e?.events}}function ke(e){return{enabled:e?.enabled??L.enabled,events:e?.events}}function Ae(e,t){let n=e?.sampleRate??re.sampleRate;return{enabled:e?.enabled??re.enabled,endpoint:e?.endpoint??`${t}/pai/elements-px.gif`,sampleRate:Math.min(1,Math.max(0,Number.isFinite(n)?n:1)),token:e?.token}}function je(e){let t={text:`Powered by ${N.displayName}`,href:N.siteUrl,...e};return t.text||t.logoUrl?t:null}function Me(e){let t=e?.sendButton;return{sendButton:{shape:t?.shape??`circle`,icon:t?.icon??`arrowUp`,variant:t?.variant??`filled`}}}function Ne(e,t){let n=e??oe,r=/* @__PURE__ */ new Set,i=[];for(let e of n.slice(0,4)){if(!e?.label||!e?.layout)continue;let n=e.contentCollectionIds?.filter(Boolean),a=e.id??n?.[0]??e.layout;for(;r.has(a);)a=`${a}-${i.length}`;r.add(a);let o={id:a,label:e.label,layout:e.layout};n?.length&&(o.contentCollectionIds=n),e.layout===`home`&&(o.brandName=e.brandName,o.greetingText=e.greetingText,o.showGreeting=!(e.hideGreeting??!1),o.showSearchBar=!(e.hideSearchBar??!1),o.showRecentConversations=t&&!(e.hideRecentConversations??!1),e.userAvatars?.length&&(o.userAvatars=e.userAvatars),e.status&&(o.status=e.status),o.contentBlockTitle=e.contentBlockTitle),i.push(o)}return{list:i,byId:Object.fromEntries(i.map(e=>[e.id,e]))}}function Pe(e,t){if(!e?.length)return ne;let n=[],r=/* @__PURE__ */ new Set;for(let i of e){if(!i?.id||r.has(i.id))continue;let e=w(i,t),a=(e.fields??[]).filter(e=>!!(e?.name&&e.label&&e.type)),o=(Array.isArray(e.on)?e.on:[e.on]).map(Fe).filter(e=>e!==null);a.length!==0&&o.length!==0&&(r.add(e.id),n.push({id:e.id,triggers:o,when:e.when,fields:a,title:e.title,description:e.description,submitLabel:e.submitLabel,skippable:e.skippable??!1,blocking:e.blocking??!1,frequency:e.frequency??`once`,mirrorToContext:e.mirrorToContext??!0,reopenable:e.reopenable??!0,reviewable:e.reviewable??!0}))}let i={};for(let e of n){var a;for(let t of e.triggers)(i[a=t.kind]??(i[a]=[])).push(e)}return{list:n,byTrigger:i}}function Fe(e){if(typeof e!=`string`)return null;if(e===`pre-chat`||e===`conversation-closed`||e===`panel-close`||e===`manual`)return{kind:e};let[t,n]=e.split(`:`,2);if(t===`after-messages`){let e=Number(n);return Number.isFinite(e)&&e>0?{kind:`after-messages`,param:e}:null}if(t===`idle`){let e=Number(n);return Number.isFinite(e)&&e>0?{kind:`idle`,param:e}:null}return t===`page-area`&&n?{kind:`page-area`,param:n}:null}function Ie(e){let t=e?.callout?.text?{shape:`pill`,position:`auto`,delayMs:1200,autoDismissMs:0,animated:!0,persistent:!0,...e.callout}:null;return{variant:e?.variant??I.variant,size:e?.size??I.size,label:e?.label??I.label,icon:e?.icon??I.icon,hidden:e?.hidden??I.hidden,callout:t}}function Le(e,t,n,r){let i=Ee(t,e.availableLocales,e.defaultLocale);if(i===e.locale&&n===e.themeMode&&r===e.textSize)return e;let a={...e};return i!==e.locale&&(a.locale=i,a.strings=D(i,e.stringsOverride)),n!==e.themeMode&&(a.themeMode=n),r!==e.textSize&&(a.textSize=r),a}const Re=[`presentation`,`behavior`,`theme`,`launcher`,`header`,`composer`,`feedback`,`i18n`,`footer`,`features`,`tracking`,`endpoints`,`history`];function ze(e,t){if(!t)return e;let n={...e};for(let r of Re){let i=t[r];if(i===void 0)continue;let a=e[r];r===`theme`?a===void 0?n[r]=i:typeof a==`string`&&typeof i==`object`&&i&&(n[r]={...i,mode:a}):r!==`i18n`&&(n[r]=Be(i,a))}t.modules!==void 0&&e.modules===void 0&&(n.modules=t.modules),t.dataApiBaseUrl!==void 0&&e.dataApiBaseUrl===void 0&&(n.dataApiBaseUrl=t.dataApiBaseUrl);let r=e.i18n,i=t.i18n;if(r||i){let e=Be(i??{},r);i?.availableLocales!==void 0&&(e.availableLocales=i.availableLocales),i?.defaultLocale!==void 0&&(e.defaultLocale=i.defaultLocale);let t=r?.strings,a=i?.strings;(t||a)&&(e.strings=Ve(a,t)),n.i18n=e}return n}function Be(e,t){if(!t)return e;let n={...e};for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);return n}function Ve(e,t){if(!e)return t;if(!t)return e;let n=M(e),r=M(t);if(!n&&!r)return{...e,...t};let i={},a=n?e:{en:e},o=r?t:{en:t};for(let[e,t]of Object.entries(a))i[e]={...t};for(let[e,t]of Object.entries(o))i[e]={...i[e],...t};return i}const He=[`clear`,`expand`,`fullscreen`,`popOut`,`sound`,`history`,`language`,`theme`,`textSize`,`close`];function Ue(e){return e!==`false`}function We(e){return e.split(`,`).map(e=>e.trim()).filter(Boolean)}const Ge=[[`public-key`,`publicKey`],[`ai-agent-deployment-id`,`aiAgentDeploymentId`],[`base-url`,`baseUrl`],[`agent-api-base-url`,`agentApiBaseUrl`],[`data-api-base-url`,`dataApiBaseUrl`],[`theme`,`theme`,e=>e]],Ke=[[`mode`,`mode`,e=>e],[`position`,`position`,e=>e],[`iframe`,`iframe`,Ue]],qe=[[`width`,`width`],[`height`,`height`]],Je=[[`response-mode`,`responseMode`,e=>e],[`start-minimized`,`startMinimized`,Ue],[`show-reasoning`,`showReasoning`,Ue],[`show-tool-calls`,`showToolCalls`,Ue],[`show-sources`,`showSources`,Ue],[`disable-message-feedback`,`disableMessageFeedback`,Ue],[`auto-send-suggestions`,`autoSendSuggestions`,Ue],[`pop-out-url`,`popOutUrl`]],Ye=[[`locale`,`locale`]],Xe=new Set(He);function Ze(e){return We(e).filter(e=>Xe.has(e))}const Qe=[[`launcher-variant`,`variant`,e=>e],[`launcher-size`,`size`,e=>e],[`launcher-icon`,`icon`],[`launcher-hidden`,`hidden`,Ue]],B=[[`features-disable-file-upload`,`disableFileUpload`,Ue],[`features-voice`,`voice`,e=>e]],$e=[[`endpoint-upload`,`upload`],[`endpoint-transcribe`,`transcribe`]],et=[[`user-id`,`id`],[`user-email`,`email`],[`user-name`,`name`]],tt=[[`page-area`,`area`],[`page-url`,`url`],[`page-path`,`path`],[`page-title`,`title`]],nt=[`launcher-label`,`callout-text`,`callout-delay`,`actions`,`user-context`,`page-context`],rt=[Ge,Ke,qe,Je,Ye,Qe,B,$e,et,tt],it=/* @__PURE__ */ new Set([`iframe`,`start-minimized`]),at=[...rt.flatMap(e=>e.map(([e])=>e).filter(e=>!it.has(e))),...nt];function ot(e){let t={};function n(t){let n=e(t);return n===null||n===``?void 0:n}for(let[e,r,i]of Ge){let a=n(e);a!==void 0&&(t[r]=i?i(a):a)}let r=st(n,Ke),i=st(n,qe);(r||i)&&(t.presentation={...r,...i?{size:i}:{}});let a=st(n,Je);a&&(t.behavior=a);let o=st(n,Ye);o&&(t.i18n=o);let s=lt(e,n);s&&(t.launcher=s);let c=st(n,B);c&&(t.features=c);let l=st(n,$e);l&&(t.endpoints=l);let u=ct(n,et,`user-context`);u&&(t.userContext=u);let d=ct(n,tt,`page-context`);d&&(t.pageContext=d);let f=n(`actions`);return f!==void 0&&(t.header={actions:Ze(f)}),t}function st(e,t){let n={};for(let[r,i,a]of t){let t=e(r);t!==void 0&&(n[i]=a?a(t):t)}return Object.keys(n).length>0?n:null}function ct(e,t,n){let r={};for(let[n,i]of t){let t=e(n);t!==void 0&&(r[i]=t)}let i={},a=e(n);if(a)try{let e=JSON.parse(a);e&&typeof e==`object`&&!Array.isArray(e)&&(i=e)}catch{}let o={...i,...r};return Object.keys(o).length>0?o:null}function lt(e,t){let n=st(t,Qe)??{},r=e(`launcher-label`);r!==null&&(n.label=r);let i=t(`callout-text`);if(i){let e=Number.parseInt(t(`callout-delay`)??``,10);n.callout={text:i,...Number.isFinite(e)?{delayMs:e}:{}}}return Object.keys(n).length>0?n:null}const ut=z.scope(`track`);function dt(e,t){let n=typeof e==`string`?e.trim():``;if(!n||n.length>64){ut.warn(`track: ignored an event without a name of 1–64 characters`,{name:e});return}let r=Object.fromEntries(Object.entries(typeof t==`object`&&t?t:{}).filter(e=>typeof e[1]==`string`||typeof e[1]==`boolean`||Number.isFinite(e[1])));return JSON.stringify(r).length>256?(ut.warn(`track: sent the event without its data, which is over 256 characters`,{name:n}),{name:n}):Object.keys(r).length>0?{name:n,data:r}:{name:n}}function ft(e){let t=[];return e.on(`hostEvent`,e=>{t.push({...e,at:Date.now()}),t.length>10&&t.shift()}),t}function pt(){let e=Date.now(),t=/* @__PURE__ */ new Uint8Array(16);t[0]=Math.floor(e/2**40)&255,t[1]=Math.floor(e/2**32)&255,t[2]=e>>>24&255,t[3]=e>>>16&255,t[4]=e>>>8&255,t[5]=e&255,mt(t.subarray(6)),t[6]=t[6]&15|112,t[8]=t[8]&63|128;let n=Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``);return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function mt(e){if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256)}const ht=z.scope(`persistence`);function gt(e,t=ee,n){let r=n?`${e}.${n}`:e,i=`${N.cssPrefix}.storageVersion`,a=t.get(i)??void 0,o=a?`.v${a}`:``,s=`${N.cssPrefix}.${r}${o}`,c=`${N.cssPrefix}${o}.visitorId`,l=`${s}.conversationId`,u=`${s}.userPrefs`,d=`${s}.panelOpen`,f=`${s}.panelSize`,p=`${s}.calloutDismissed`,m=`${s}.sidebarCollapsed`,h=`${s}.activeModule`,g=`${s}.seenNewsId`,_=`${s}.historyCount`,v=`${s}.formsDone`,y={getVisitorId(){let e=t.get(c);if(e)return e;let n=pt();return t.set(c,n),n},loadConversationId(){return t.get(l)??void 0},saveConversationId(e){ht.trace(`saveConversationId`,{id:e,scope:r}),e?t.set(l,e):t.remove(l)},loadDraft(e){return t.get(`${s}.draft.${e}`)??``},saveDraft(e,n){let r=`${s}.draft.${e}`;n?t.set(r,n):t.remove(r)},loadMessageQueue(e){let n=t.get(`${s}.messageQueue.${e}`);if(!n)return[];try{let e=JSON.parse(n);return!Array.isArray(e)||!e.every(vt)?[]:e}catch(e){return ht.warn(`loadMessageQueue parse failed`,{error:e}),[]}},saveMessageQueue(e,n){let r=`${s}.messageQueue.${e}`;if(n.length===0)t.remove(r);else try{t.set(r,JSON.stringify(n))}catch(e){ht.warn(`saveMessageQueue serialise failed`,{error:e})}},loadUserPrefs(){let e=t.get(u);if(!e)return{};try{return yt(JSON.parse(e))}catch(e){return ht.warn(`loadUserPrefs parse failed`,{error:e}),{}}},saveUserPrefs(e){try{t.set(u,JSON.stringify(e))}catch(e){ht.warn(`saveUserPrefs serialise failed`,{error:e})}},patchUserPrefs(e){let t=y.loadUserPrefs();y.saveUserPrefs({...t,...e})},loadPanelOpen(){let e=t.get(d);return e===`1`||e!==`0`&&null},savePanelOpen(e){t.set(d,e?`1`:`0`)},loadPanelSize(){let e=t.get(f);return e===`normal`||e===`expanded`||e===`fullscreen`?e:null},savePanelSize(e){t.set(f,e)},loadCalloutDismissed(e){if(!e)return!1;let n=t.get(p);return!!n&&n===e},saveCalloutDismissed(e){e?t.set(p,e):t.remove(p)},loadSidebarCollapsed(){let e=t.get(m);return e===`1`||e!==`0`&&null},saveSidebarCollapsed(e){t.set(m,e?`1`:`0`)},loadActiveModule(){return t.get(h)||null},saveActiveModule(e){t.set(h,e)},loadSeenNewsId(){return t.get(g)||null},saveSeenNewsId(e){t.set(g,e)},loadHistoryCount(){let e=t.get(_);if(!e)return null;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>=0?n:null},saveHistoryCount(e){t.set(_,String(e))},loadFormsDone(){let e=t.get(v);if(!e)return{};try{let t=JSON.parse(e);return _t(t)?Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]==`number`)):{}}catch(e){return ht.warn(`loadFormsDone parse failed`,{error:e}),{}}},saveFormDone(e){try{let n=y.loadFormsDone();n[e]=Date.now(),t.set(v,JSON.stringify(n))}catch(e){ht.warn(`saveFormDone serialise failed`,{error:e})}},rememberStorageVersion(e){e&&e!==t.get(i)&&(ht.debug(`rememberStorageVersion (force-reset on next load)`,{version:e}),t.set(i,e))},clearConversation(){t.remove(l)},reset(){let e=t.get(l);e&&(t.remove(`${s}.draft.${e}`),t.remove(`${s}.messageQueue.${e}`));for(let e of[c,l,u,d,f,p,m,h,g,_,v])t.remove(e);ht.info(`reset: forgot the visitor`,{scope:r})}};return y}function _t(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function vt(e){return _t(e)&&typeof e.id==`string`&&e.id.length>0&&typeof e.text==`string`}function yt(e){if(!_t(e))return{};let t={};return typeof e.locale==`string`&&(t.locale=e.locale),typeof e.soundMuted==`boolean`&&(t.soundMuted=e.soundMuted),(e.themeMode===`auto`||e.themeMode===`light`||e.themeMode===`dark`)&&(t.themeMode=e.themeMode),(e.textSize===`small`||e.textSize===`normal`||e.textSize===`large`)&&(t.textSize=e.textSize),_t(e.widgetSize)&&typeof e.widgetSize.width==`number`&&typeof e.widgetSize.height==`number`&&(t.widgetSize={width:e.widgetSize.width,height:e.widgetSize.height}),t}const bt=`1.14.1`,xt={open:()=>void 0,close:()=>void 0,expand:e=>({on:e}),fullscreen:e=>({on:e}),send:e=>({attachments:e.attachmentCount}),message:e=>({role:e.role}),stop:()=>void 0,clear:()=>void 0,suggestion:()=>void 0,toggleHistory:e=>({view:e.view}),handshake:()=>void 0,formSubmit:e=>({formId:e.formId,skipped:e.skipped}),toolResult:()=>void 0,toolDecision:e=>({approved:e.approved}),hostEvent:e=>({name:e.name,data:e.data&&JSON.stringify(e.data)}),messageFeedback:e=>({value:e.value??`none`}),contentView:e=>({section:e.section,count:e.count}),contentOpen:e=>({contentId:e.contentId,contentCollectionId:e.contentCollectionId}),contentSearch:e=>({qlen:e.queryLength,hits:e.hitCount}),contentRead:e=>({contentId:e.contentId}),contentLinkClick:e=>({contentId:e.contentId}),attach:e=>({count:e.count,bytes:e.totalBytes}),voiceStart:()=>void 0,voiceStop:e=>({ms:e.durationMs}),voiceCancel:()=>void 0,localeChange:e=>({locale:e}),themeChange:e=>({theme:e}),textSizeChange:e=>({size:e}),soundToggle:e=>({muted:e.muted}),sidebarToggle:e=>({collapsed:e.collapsed}),calloutDismiss:()=>void 0,error:()=>void 0};function St(){let e=navigator;return e.globalPrivacyControl===!0||e.doNotTrack===`1`}function Ct(){return location.origin+location.pathname}function wt(){try{return document.referrer?new URL(document.referrer).origin:``}catch{return``}}function Tt(e,t){let n=Math.random(),r=0,i=0,a=/* @__PURE__ */ new Set;function o(e,o){let{tracking:s,publicKey:c,aiAgentDeploymentId:l,mode:u,themeMode:d}=t.getOptions();if(!s.enabled||St()||n>=s.sampleRate)return;let f=performance.now();if(f-r>6e4&&(r=f,i=0),++i>60)return;let p=new URLSearchParams;p.set(`v`,`1`),p.set(`_ev`,bt),p.set(`e`,e),s.token&&p.set(`tk`,s.token),c&&p.set(`pk`,c),l&&p.set(`dep`,l),p.set(`vid`,t.getVisitorId());let m=t.getConversationId();m&&p.set(`cid`,m),p.set(`url`,Ct());let h=wt();h&&p.set(`ref`,h),p.set(`sw`,String(screen.width)),p.set(`sh`,String(screen.height)),p.set(`vw`,String(innerWidth)),p.set(`vh`,String(innerHeight)),p.set(`dpr`,String(devicePixelRatio)),p.set(`lang`,navigator.language);try{p.set(`tz`,Intl.DateTimeFormat().resolvedOptions().timeZone)}catch{}if(p.set(`m`,u),p.set(`th`,d),o)for(let[e,t]of Object.entries(o))t!==void 0&&p.set(e,String(t));p.set(`ts`,String(Date.now()));let g=`${s.endpoint}?${p}`;if(g.length>2e3)return;let _=new Image(1,1);a.add(_);function v(){return a.delete(_)}_.addEventListener(`load`,v,{once:!0}),_.addEventListener(`error`,v,{once:!0}),_.src=g}let s=[];function c(e,t){if(s&&e!==`handshake`){s.length<60&&s.push([e,t]);return}let n=s??[];s=void 0;for(let[e,t]of n)o(e,t);o(e,t)}let l=Object.keys(xt).map(t=>e.on(t,e=>c(t,xt[t]?.(e))));return()=>{for(let e of l)e();a.clear()}}const Et=`:host{--__P__-accent-user: __BRAND_ACCENT__;--__P__-accent: var(--__P__-accent-user);--__P__-accent-text-user: __BRAND_ACCENT_TEXT__;--__P__-accent-text: var(--__P__-accent-text-user);--__P__-accent-fg: var(--__P__-accent);--__P__-radius: __BRAND_RADIUS__;--__P__-radius-sm: 8px;--__P__-radius-md: 10px;--__P__-radius-lg: 16px;--__P__-font: __BRAND_FONT__;--__P__-font-display: var(--__P__-font);--__P__-font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;--__P__-bg: oklch(1 0 0);--__P__-bg-elevated: oklch(.9789 .0029 278.3);--__P__-surface: var(--__P__-bg-elevated);--__P__-muted: var(--__P__-fg-muted);--__P__-hover: oklch(.1686 .011 278.3 / .06);--__P__-fg: oklch(.1686 .011 278.3);--__P__-fg-muted: oklch(.4932 .0301 278.3);--__P__-border: oklch(.9312 .0084 278.3);--__P__-border-strong: oklch(.8757 .0131 278.3);--__P__-bubble-user: var(--__P__-accent);--__P__-bubble-user-text: var(--__P__-accent-text);--__P__-bubble-assistant: oklch(.9638 .0058 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-on-accent: var(--__P__-accent-text);--__P__-success: oklch(.6456 .1654 151.53);--__P__-warning: oklch(.7135 .1494 74.05);--__P__-danger: oklch(.5966 .1818 24.51);--__P__-danger-text: oklch(.5054 .1905 27.52);--__P__-danger-bg: oklch(.5966 .1818 24.51 / .1);--__P__-neutral: oklch(.7137 .0192 278.3);--__P__-pill-l-min: .3;--__P__-pill-l-max: .46;--__P__-focus: var(--__P__-accent);--__P__-shadow-panel: 0 8px 24px -8px rgba(13, 15, 20, .18), 0 24px 64px -24px rgba(13, 15, 20, .24);--__P__-shadow-card: 0 1px 2px rgba(13, 15, 20, .06), 0 4px 12px -6px rgba(13, 15, 20, .12);--__P__-backdrop: oklch(.1686 .011 278.3 / .55);--__P__-shadow-fab: 0 6px 16px -4px color-mix(in oklch, var(--__P__-accent) 45%, transparent), 0 12px 32px -12px rgba(13, 15, 20, .25);--__P__-z-fab: 2147483600;--__P__-z-panel: 2147483601;--__P__-panel-w: 380px;--__P__-panel-h: 600px;--__P__-fab-size: 56px;--__P__-conversation-max: 768px;--__P__-space-1: 4px;--__P__-space-2: 8px;--__P__-space-3: 12px;--__P__-space-4: 16px;--__P__-space-5: 20px;--__P__-space-6: 24px;--__P__-space-8: 32px;--__P__-text-scale: 1;--__P__-text-xs: calc(12px * var(--__P__-text-scale));--__P__-text-sm: calc(13px * var(--__P__-text-scale));--__P__-text-base: calc(15px * var(--__P__-text-scale));--__P__-text-md: calc(16px * var(--__P__-text-scale));--__P__-text-lg: calc(18px * var(--__P__-text-scale));--__P__-text-xl: calc(22px * var(--__P__-text-scale));--__P__-text-2xl: calc(30px * var(--__P__-text-scale))}:host([data-mode="modal"]),:host([data-mode="drawer"]){--__P__-conversation-max: 100%}:host([data-text-size="small"]){--__P__-text-scale: .9}:host([data-text-size="large"]){--__P__-text-scale: 1.15}:host{--__P__-ease: cubic-bezier(.2, .7, .2, 1);--__P__-ease-out: cubic-bezier(.2, .7, .2, 1);--__P__-ease-in: cubic-bezier(.4, 0, 1, 1);--__P__-ease-in-out: cubic-bezier(.65, 0, .35, 1);--__P__-dur-quick: .12s;--__P__-dur-base: .22s;--__P__-dur-slow: .32s;font-family:var(--__P__-font);color:var(--__P__-fg);color-scheme:light;--__P__-color-scheme: light}:host([data-theme="dark"]){--__P__-bg: oklch(.1783 .0128 278.3);--__P__-bg-elevated: oklch(.2232 .0182 278.3);--__P__-fg: oklch(.9368 .01 278.3);--__P__-fg-muted: oklch(.7048 .0296 278.3);--__P__-border: oklch(.2752 .0266 278.3);--__P__-border-strong: oklch(.335 .0291 278.3);--__P__-hover: oklch(.9368 .01 278.3 / .08);--__P__-bubble-assistant: oklch(.2474 .0311 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-danger-text: oklch(.8077 .1035 19.57);--__P__-danger-bg: oklch(.5966 .1818 24.51 / .18);--__P__-shadow-panel: 0 8px 24px -8px rgba(0, 0, 0, .6), 0 24px 64px -24px rgba(0, 0, 0, .7);--__P__-shadow-card: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 12px -6px rgba(0, 0, 0, .5);--__P__-backdrop: rgba(0, 0, 0, .65);--__P__-pill-l-min: .75;--__P__-pill-l-max: .92;color-scheme:dark;--__P__-color-scheme: dark}@media(prefers-color-scheme:dark){:host([data-theme="auto"]){--__P__-bg: oklch(.1783 .0128 278.3);--__P__-bg-elevated: oklch(.2232 .0182 278.3);--__P__-fg: oklch(.9368 .01 278.3);--__P__-fg-muted: oklch(.7048 .0296 278.3);--__P__-border: oklch(.2752 .0266 278.3);--__P__-border-strong: oklch(.335 .0291 278.3);--__P__-hover: oklch(.9368 .01 278.3 / .08);--__P__-bubble-assistant: oklch(.2474 .0311 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-pill-l-min: .75;--__P__-pill-l-max: .92;--__P__-shadow-panel: 0 8px 24px -8px rgba(0, 0, 0, .6), 0 24px 64px -24px rgba(0, 0, 0, .7);color-scheme:dark;--__P__-color-scheme: dark}}@supports (color: oklch(from red l c h)){:host{--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.3, l, .62) c h);--__P__-accent-text: oklch(from var(--__P__-accent) clamp(0, (l / .623 - 1) * -infinity, 1) 0 h);--__P__-accent-fg: oklch(from var(--__P__-accent-user) clamp(.3, l, .46) c h)}:host([data-theme="dark"]){--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.65, l, .85) c h);--__P__-accent-fg: var(--__P__-accent)}@media(prefers-color-scheme:dark){:host([data-theme="auto"]){--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.65, l, .85) c h);--__P__-accent-fg: var(--__P__-accent)}}}@media(prefers-reduced-motion:reduce){:host{--__P__-dur-quick: 1ms;--__P__-dur-base: 1ms;--__P__-dur-slow: 1ms}}
|
|
1
|
+
import{Component as e,h as t,render as n}from"preact";import{batch as r,computed as i,effect as a,signal as o,useComputed as s,useSignal as c}from"@preact/signals";import{useCallback as l,useEffect as u,useId as d,useLayoutEffect as f,useMemo as p,useRef as m,useState as h}from"preact/hooks";import{Fragment as g,jsx as _,jsxs as v}from"preact/jsx-runtime";import*as y from"streaming-markdown";import{memo as b}from"preact/compat";function x(e,t){if(e?.length&&t)return e.find(e=>e.locale===t)}function S(e,t){let{translations:n,defaultLocale:r,...i}=e,a=x(n,t);return a?{...i,title:a.title??i.title,description:a.description??i.description,content:a.content??i.content}:i}function C(e,t){let{translations:n,defaultLocale:r,...i}=e,a=x(n,t);return a?{...i,title:a.title??i.title,description:a.description??i.description}:i}function w(e,t){let{translations:n,defaultLocale:r,...i}=e,a=x(n,t);if(!a)return i;let o=new Map((a.fields??[]).map(e=>[e.name,e])),s=i.fields.map(e=>{let t=o.get(e.name);if(!t)return e;let n=new Map((t.options??[]).map(e=>[e.value,e]));return{...e,label:t.label??e.label,placeholder:t.placeholder??e.placeholder,validationHint:t.validationHint??e.validationHint,options:e.options?.map(e=>{let t=n.get(e.value);return t?{...e,label:t.label??e.label,description:t.description??e.description}:e})}});return{...i,title:a.title??i.title,description:a.description??i.description,submitLabel:a.submitLabel??i.submitLabel,fields:s}}const T={attach:`Attach files`,file:`File`,attachmentMimeRejected:`File type not supported`,attachmentTooLarge:`File is too large`,attachmentTooMany:`Attachment limit reached`,conversationClosed:`This chat is closed`,conversationLoading:`Loading chat…`,loadPreviousMessages:`Load previous messages`,close:`Close`,collapse:`Collapse`,collapseSidebar:`Collapse sidebar`,composerPlaceholder:`Type a message…`,dateLastWeek:`Last 7 days`,dateOlder:`Older`,dateToday:`Today`,dateYesterday:`Yesterday`,dropZone:`Drop files to attach`,errorGeneric:`Something went wrong`,errorRateLimited:`Too many requests — please try again in a moment.`,errorRateLimitedIn:`Too many requests — please try again in {seconds} s.`,errorOffline:`Can't reach the server. Check your connection and try again.`,errorServer:`Something went wrong on our side. Please try again.`,errorOriginNotAllowed:`This chat isn't set up for this website yet.`,errorReconnecting:`Connection lost. Reconnecting…`,errorRetry:`Retry`,expand:`Expand`,expandSidebar:`Expand sidebar`,exitFullscreen:`Exit fullscreen`,fullscreen:`Fullscreen`,history:`History`,historyBack:`Back to chat`,historyEmpty:`No previous chats yet`,historyLoading:`Loading your chats…`,historyContinue:`Continue the chat`,historyTitle:`Chat history`,loadMoreConversations:`Load more conversations`,language:`Language`,launcherOpen:`Open chat`,launcherLabel:`Chat with us`,micStart:`Start voice input`,micStop:`Stop voice input`,micUnsupported:`Voice input is not supported in this browser`,moreActions:`More actions`,newConversation:`New chat`,panelTitle:`Chat`,popOut:`Open in new tab`,resizeHandle:`Drag to resize`,scrollToBottom:`Scroll to latest`,send:`Send`,queueMessage:`Queue message`,removeQueuedMessage:`Remove queued message`,compactingContext:`Optimizing conversation context…`,soundOff:`Sound off`,soundOn:`Sound on`,startNewConversation:`Start a new chat`,talkToOperator:`Talk to a person`,connectingOperator:`Connecting you to a person…`,noOperatorAvailable:`No one's available right now — leave your details and we'll follow up.`,chattingWithOperator:`You're chatting with {operator}`,cancelOperatorRequest:`Keep chatting with the AI`,stop:`Stop`,theme:`Theme`,themeAuto:`Auto`,themeDark:`Dark`,themeLight:`Light`,textSize:`Text size`,textSizeSmall:`Small`,textSizeNormal:`Normal`,textSizeLarge:`Large`,loading:`Loading…`,visualPreparing:`Preparing visual…`,visualError:`This visual could not be displayed.`,visualPartial:`Some parts of this visual could not be displayed.`,thinking:`Thinking…`,thought:`Thought`,thoughtFor:`Thought for {time}`,toolResult:`Result`,sources:`Sources`,feedbackUp:`Good response`,feedbackDown:`Bad response`,feedbackThanks:`Thanks for your feedback`,copy:`Copy`,copied:`Copied`,tabHome:`Home`,tabConversations:`Chats`,tabHelp:`Help`,tabNews:`News`,modulesEmpty:`Nothing here yet`,moduleBack:`Back`,contentLoading:`Loading…`,contentHelpful:`Was this helpful?`,homeGreeting:`How can we help?`,homeGreetingNamed:`Hi {name} 👋`,homeGreetingLead:`How can we help?`,homeSearchPlaceholder:`Search for help`,homeAskPlaceholder:`Ask a question…`,homeWhatsNew:`What's new`,homeContentTitle:`Popular articles`,homeStatus:`Status`,helpTitle:`Help`,helpSearchPlaceholder:`Search for help`,helpEmpty:`No help articles yet`,helpLoading:`Loading help…`,helpSearchEmpty:`No results for “{query}”`,helpShowMore:`Show more`,newsTitle:`News`,newsEmpty:`No news yet`,newsLoading:`Loading news…`,newsBack:`Back to news`,newsPublishedAt:`Published {date}`,newsShowMore:`Show more`,newsUnseen:`New post`,formSubmit:`Submit`,formSkip:`Maybe later`,formSubmitted:`Completed`,formSkipped:`Maybe later`,formFillOut:`Fill out`,formRequired:`This field is required`,formInvalidEmail:`Enter a valid email address`,formInvalidTel:`Enter a valid phone number`,formInvalidUrl:`Enter a valid URL`,formInvalidNumber:`Enter a valid number`,formTooShort:`Too short (min {min} characters)`,formTooLong:`Too long (max {max} characters)`,formNumberTooSmall:`Must be at least {min}`,formNumberTooLarge:`Must be at most {max}`,formPatternMismatch:`Please match the requested format`,formChooseAtLeast:`Choose at least {min}`,formChooseAtMost:`Choose at most {max}`,formOther:`Other`,formOtherPlaceholder:`Type your answer…`,inputRequired:`Questions for you`,inputBadge:`Questions`,inputAnswered:`Answered`,inputSkipped:`Skipped`,showOptions:`Show options`,hideOptions:`Hide options`,qtypeText:`Your answer`,qtypeEmail:`Email address`,qtypePhone:`Phone number`,qtypeNumber:`Number`,qtypeDate:`Date`,qtypeChooseOne:`Pick one`,qtypeChooseAny:`Pick any`,qtypeBoolean:`Yes / No`,inputSubmit:`Submit answers`,inputSubmitHint:`Enter to send · Shift+Enter = new line`,inputSkip:`Skip`,confirmYes:`Yes`,confirmNo:`No`,approve:`Approve`,reject:`Reject`,approvalPrompt:`{tool} requires your approval to execute.`,approvalBody:`Review the tool input above and decide whether to allow this action.`,approvalYourResponse:`Your response: {decision}`,approvalEditHint:`You can edit this response until this step continues.`,approvalSubmitting:`Response submitted. Request in progress…`,edit:`Edit`,toolParameters:`Parameters`,statusAwaiting:`Awaiting Approval`,statusResponded:`Submitted`,statusRunning:`Running`,statusCompleted:`Completed`,statusDenied:`Denied`,statusError:`Error`,statusSuperseded:`Skipped`,statusIncomplete:`Not completed`,toolStepsFailed:`{count} failed`,statusStopped:`Stopped`,toolStepsStopped:`Stopped after {count} steps`,toolStepsStoppedOne:`Stopped after 1 step`,thoughtsShowMore:`Show more`,thoughtsShowLess:`Show less`},E={en:T,fr:{attach:`Joindre des fichiers`,file:`Fichier`,attachmentMimeRejected:`Type de fichier non pris en charge`,attachmentTooLarge:`Le fichier est trop volumineux`,attachmentTooMany:`Limite de pièces jointes atteinte`,conversationClosed:`Ce chat est fermé`,conversationLoading:`Chargement du chat…`,loadPreviousMessages:`Charger les messages précédents`,close:`Fermer`,collapse:`Réduire`,collapseSidebar:`Réduire la barre latérale`,composerPlaceholder:`Écrivez un message…`,dateLastWeek:`7 derniers jours`,dateOlder:`Plus ancien`,dateToday:`Aujourd'hui`,dateYesterday:`Hier`,dropZone:`Déposez les fichiers à joindre`,errorGeneric:`Une erreur s'est produite`,errorRateLimited:`Trop de requêtes — veuillez réessayer dans un instant.`,errorRateLimitedIn:`Trop de requêtes — veuillez réessayer dans {seconds} s.`,errorOffline:`Impossible de joindre le serveur. Vérifiez votre connexion et réessayez.`,errorServer:`Un problème est survenu de notre côté. Veuillez réessayer.`,errorOriginNotAllowed:`Ce chat n'est pas encore configuré pour ce site.`,errorReconnecting:`Connexion perdue. Reconnexion…`,errorRetry:`Réessayer`,expand:`Agrandir`,expandSidebar:`Développer la barre latérale`,exitFullscreen:`Quitter le plein écran`,fullscreen:`Plein écran`,history:`Historique`,historyBack:`Retour au chat`,historyEmpty:`Aucun chat pour le moment`,historyContinue:`Poursuivre le chat`,historyLoading:`Chargement de vos chats…`,historyTitle:`Historique des chats`,loadMoreConversations:`Charger plus de conversations`,language:`Langue`,launcherOpen:`Ouvrir le chat`,launcherLabel:`Discuter avec nous`,micStart:`Démarrer la saisie vocale`,micStop:`Arrêter la saisie vocale`,micUnsupported:`La saisie vocale n'est pas prise en charge par ce navigateur`,moreActions:`Plus d'actions`,newConversation:`Nouveau chat`,panelTitle:`Chat`,popOut:`Ouvrir dans un nouvel onglet`,resizeHandle:`Glisser pour redimensionner`,scrollToBottom:`Aller au plus récent`,send:`Envoyer`,queueMessage:`Mettre le message en attente`,removeQueuedMessage:`Retirer le message en attente`,compactingContext:`Optimisation du contexte de la conversation…`,soundOff:`Son désactivé`,soundOn:`Son activé`,startNewConversation:`Démarrer un nouveau chat`,talkToOperator:`Parler à une personne`,connectingOperator:`Mise en relation avec une personne…`,noOperatorAvailable:`Personne n'est disponible pour le moment — laissez vos coordonnées et nous reviendrons vers vous.`,chattingWithOperator:`Vous discutez avec {operator}`,cancelOperatorRequest:`Continuer avec l'IA`,stop:`Arrêter`,theme:`Thème`,themeAuto:`Auto`,themeDark:`Sombre`,themeLight:`Clair`,textSize:`Taille du texte`,textSizeSmall:`Petite`,textSizeNormal:`Normale`,textSizeLarge:`Grande`,loading:`Chargement…`,visualPreparing:`Préparation du visuel…`,visualError:`Ce visuel n’a pas pu être affiché.`,visualPartial:`Certaines parties de ce visuel n’ont pas pu être affichées.`,thinking:`Réflexion…`,thought:`Réflexion`,thoughtFor:`Réflexion : {time}`,toolResult:`Résultat`,sources:`Sources`,feedbackUp:`Bonne réponse`,feedbackDown:`Mauvaise réponse`,feedbackThanks:`Merci pour votre retour`,copy:`Copier`,copied:`Copié`,tabHome:`Accueil`,tabConversations:`Chats`,tabHelp:`Aide`,tabNews:`Actualités`,modulesEmpty:`Rien pour le moment`,moduleBack:`Retour`,contentLoading:`Chargement…`,contentHelpful:`Cela vous a-t-il aidé ?`,homeGreeting:`Comment pouvons-nous vous aider ?`,homeGreetingNamed:`Bonjour {name} 👋`,homeGreetingLead:`Comment pouvons-nous vous aider ?`,homeSearchPlaceholder:`Rechercher de l'aide`,homeAskPlaceholder:`Posez une question…`,homeWhatsNew:`Nouveautés`,homeContentTitle:`Articles populaires`,homeStatus:`Statut`,helpTitle:`Aide`,helpSearchPlaceholder:`Rechercher de l'aide`,helpEmpty:`Aucun article d'aide pour le moment`,helpLoading:`Chargement de l'aide…`,helpSearchEmpty:`Aucun résultat pour «\xA0{query}\xA0»`,helpShowMore:`Afficher plus`,newsTitle:`Actualités`,newsEmpty:`Aucune actualité pour le moment`,newsLoading:`Chargement des actualités…`,newsBack:`Retour aux actualités`,newsPublishedAt:`Publié le {date}`,newsShowMore:`Afficher plus`,newsUnseen:`Nouvelle publication`,formSubmit:`Envoyer`,formSkip:`Plus tard`,formSubmitted:`Terminé`,formSkipped:`Plus tard`,formFillOut:`Remplir`,formRequired:`Ce champ est obligatoire`,formInvalidEmail:`Saisissez une adresse e-mail valide`,formInvalidTel:`Saisissez un numéro de téléphone valide`,formInvalidUrl:`Saisissez une URL valide`,formInvalidNumber:`Saisissez un nombre valide`,formTooShort:`Trop court (min. {min} caractères)`,formTooLong:`Trop long (max. {max} caractères)`,formNumberTooSmall:`Doit être au moins {min}`,formNumberTooLarge:`Doit être au plus {max}`,formPatternMismatch:`Veuillez respecter le format demandé`,formChooseAtLeast:`Choisissez au moins {min}`,formChooseAtMost:`Choisissez au plus {max}`,formOther:`Autre`,formOtherPlaceholder:`Saisissez votre réponse…`,inputRequired:`Questions pour vous`,inputBadge:`Questions`,inputAnswered:`Répondu`,inputSkipped:`Ignoré`,showOptions:`Afficher les options`,hideOptions:`Masquer les options`,qtypeText:`Votre réponse`,qtypeEmail:`Adresse e-mail`,qtypePhone:`Numéro de téléphone`,qtypeNumber:`Nombre`,qtypeDate:`Date`,qtypeChooseOne:`Choisir une`,qtypeChooseAny:`Choisir plusieurs`,qtypeBoolean:`Oui / Non`,inputSubmit:`Envoyer les réponses`,inputSubmitHint:`Entrée pour envoyer · Maj+Entrée = saut de ligne`,inputSkip:`Ignorer`,confirmYes:`Oui`,confirmNo:`Non`,approve:`Approuver`,reject:`Refuser`,approvalPrompt:`{tool} nécessite votre approbation pour s'exécuter.`,approvalBody:`Vérifiez les paramètres ci-dessus et décidez d'autoriser ou non cette action.`,approvalYourResponse:`Votre réponse : {decision}`,approvalEditHint:`Vous pouvez modifier votre réponse jusqu'à la reprise de cette étape.`,approvalSubmitting:`Réponse envoyée. Traitement en cours…`,edit:`Modifier`,toolParameters:`Paramètres`,statusAwaiting:`En attente d'approbation`,statusResponded:`Envoyé`,statusRunning:`En cours`,statusCompleted:`Terminé`,statusDenied:`Refusé`,statusError:`Erreur`,statusSuperseded:`Ignoré`,statusIncomplete:`Non terminé`,toolStepsFailed:`{count} en échec`,statusStopped:`Arrêté`,toolStepsStopped:`Arrêté après {count} étapes`,toolStepsStoppedOne:`Arrêté après 1 étape`,thoughtsShowMore:`Afficher plus`,thoughtsShowLess:`Afficher moins`},ar:{attach:`إرفاق ملفات`,file:`ملف`,attachmentMimeRejected:`نوع الملف غير مدعوم`,attachmentTooLarge:`حجم الملف كبير جدًا`,attachmentTooMany:`تم بلوغ الحد الأقصى للمرفقات`,conversationClosed:`تم إغلاق هذه الدردشة`,conversationLoading:`جارٍ تحميل الدردشة…`,loadPreviousMessages:`تحميل الرسائل السابقة`,close:`إغلاق`,collapse:`طيّ`,collapseSidebar:`طيّ الشريط الجانبي`,composerPlaceholder:`اكتب رسالة…`,dateLastWeek:`آخر ٧ أيام`,dateOlder:`أقدم`,dateToday:`اليوم`,dateYesterday:`أمس`,dropZone:`أفلت الملفات لإرفاقها`,errorGeneric:`حدث خطأ ما`,errorRateLimited:`طلبات كثيرة جدًا — يرجى المحاولة بعد لحظة.`,errorRateLimitedIn:`طلبات كثيرة جدًا — يرجى المحاولة بعد {seconds} ث.`,errorOffline:`تعذّر الوصول إلى الخادم. تحقّق من اتصالك وحاول مرة أخرى.`,errorServer:`حدث خطأ من جهتنا. يرجى المحاولة مرة أخرى.`,errorOriginNotAllowed:`هذه المحادثة غير مُعدّة لهذا الموقع بعد.`,errorReconnecting:`انقطع الاتصال. جارٍ إعادة الاتصال…`,errorRetry:`إعادة المحاولة`,expand:`توسيع`,expandSidebar:`توسيع الشريط الجانبي`,exitFullscreen:`إنهاء ملء الشاشة`,fullscreen:`ملء الشاشة`,history:`السجل`,historyBack:`العودة إلى الدردشة`,historyEmpty:`لا توجد دردشات سابقة بعد`,historyContinue:`متابعة الدردشة`,historyLoading:`جارٍ تحميل دردشاتك…`,historyTitle:`سجل الدردشات`,loadMoreConversations:`تحميل المزيد من المحادثات`,language:`اللغة`,launcherOpen:`فتح الدردشة`,launcherLabel:`تحدث معنا`,micStart:`بدء الإدخال الصوتي`,micStop:`إيقاف الإدخال الصوتي`,micUnsupported:`الإدخال الصوتي غير مدعوم في هذا المتصفح`,moreActions:`إجراءات إضافية`,newConversation:`دردشة جديدة`,panelTitle:`الدردشة`,popOut:`فتح في علامة تبويب جديدة`,resizeHandle:`اسحب لتغيير الحجم`,scrollToBottom:`الانتقال إلى الأحدث`,send:`إرسال`,queueMessage:`إضافة الرسالة إلى قائمة الانتظار`,removeQueuedMessage:`إزالة الرسالة من قائمة الانتظار`,compactingContext:`جارٍ تحسين سياق المحادثة…`,soundOff:`كتم الصوت`,soundOn:`تشغيل الصوت`,startNewConversation:`بدء دردشة جديدة`,talkToOperator:`التحدث إلى شخص`,connectingOperator:`جارٍ توصيلك بشخص…`,noOperatorAvailable:`لا يوجد موظفون متاحون الآن — اترك بياناتك وسنتواصل معك.`,chattingWithOperator:`أنت تتحدث مع {operator}`,cancelOperatorRequest:`متابعة المحادثة مع الذكاء الاصطناعي`,stop:`إيقاف`,theme:`المظهر`,themeAuto:`تلقائي`,themeDark:`داكن`,themeLight:`فاتح`,textSize:`حجم النص`,textSizeSmall:`صغير`,textSizeNormal:`عادي`,textSizeLarge:`كبير`,loading:`جارٍ التحميل…`,visualPreparing:`جارٍ إعداد المحتوى المرئي…`,visualError:`تعذر عرض هذا المحتوى المرئي.`,visualPartial:`تعذر عرض بعض أجزاء هذا المحتوى المرئي.`,thinking:`يفكّر…`,thought:`تفكير`,thoughtFor:`فكّر لمدة {time}`,toolResult:`النتيجة`,sources:`المصادر`,feedbackUp:`رد جيد`,feedbackDown:`رد سيئ`,feedbackThanks:`شكرًا على ملاحظاتك`,copy:`نسخ`,copied:`تم النسخ`,tabHome:`الرئيسية`,tabConversations:`الدردشات`,tabHelp:`المساعدة`,tabNews:`الأخبار`,modulesEmpty:`لا شيء هنا بعد`,moduleBack:`رجوع`,contentLoading:`جارٍ التحميل…`,contentHelpful:`هل كان هذا مفيدًا؟`,homeGreeting:`كيف يمكننا مساعدتك؟`,homeGreetingNamed:`مرحبًا {name} 👋`,homeGreetingLead:`كيف يمكننا مساعدتك؟`,homeSearchPlaceholder:`ابحث عن مساعدة`,homeAskPlaceholder:`اطرح سؤالاً…`,homeWhatsNew:`ما الجديد`,homeContentTitle:`مقالات شائعة`,homeStatus:`الحالة`,helpTitle:`المساعدة`,helpSearchPlaceholder:`ابحث عن مساعدة`,helpEmpty:`لا توجد مقالات مساعدة بعد`,helpLoading:`جارٍ تحميل المساعدة…`,helpSearchEmpty:`لا نتائج لـ «{query}»`,helpShowMore:`عرض المزيد`,newsTitle:`الأخبار`,newsEmpty:`لا توجد أخبار بعد`,newsLoading:`جارٍ تحميل الأخبار…`,newsBack:`العودة إلى الأخبار`,newsPublishedAt:`نُشر في {date}`,newsShowMore:`عرض المزيد`,newsUnseen:`منشور جديد`,formSubmit:`إرسال`,formSkip:`لاحقًا`,formSubmitted:`تم`,formSkipped:`لاحقًا`,formFillOut:`تعبئة`,formRequired:`هذا الحقل مطلوب`,formInvalidEmail:`أدخل بريدًا إلكترونيًا صحيحًا`,formInvalidTel:`أدخل رقم هاتف صحيحًا`,formInvalidUrl:`أدخل رابطًا صحيحًا`,formInvalidNumber:`أدخل رقمًا صحيحًا`,formTooShort:`قصير جدًا (الحد الأدنى {min} حرفًا)`,formTooLong:`طويل جدًا (الحد الأقصى {max} حرفًا)`,formNumberTooSmall:`يجب ألا يقل عن {min}`,formNumberTooLarge:`يجب ألا يزيد عن {max}`,formPatternMismatch:`يرجى مطابقة الصيغة المطلوبة`,formChooseAtLeast:`اختر {min} على الأقل`,formChooseAtMost:`اختر {max} على الأكثر`,formOther:`أخرى`,formOtherPlaceholder:`اكتب إجابتك…`,inputRequired:`أسئلة لك`,inputBadge:`أسئلة`,inputAnswered:`تمت الإجابة`,inputSkipped:`تم التخطي`,showOptions:`إظهار الخيارات`,hideOptions:`إخفاء الخيارات`,qtypeText:`إجابتك`,qtypeEmail:`عنوان البريد الإلكتروني`,qtypePhone:`رقم الهاتف`,qtypeNumber:`رقم`,qtypeDate:`تاريخ`,qtypeChooseOne:`اختر واحدًا`,qtypeChooseAny:`اختر أيًا`,qtypeBoolean:`نعم / لا`,inputSubmit:`إرسال الإجابات`,inputSubmitHint:`Enter للإرسال · Shift+Enter = سطر جديد`,inputSkip:`تخطٍّ`,confirmYes:`نعم`,confirmNo:`لا`,approve:`موافقة`,reject:`رفض`,approvalPrompt:`تتطلب {tool} موافقتك للتنفيذ.`,approvalBody:`راجع مُعطيات الأداة أعلاه وقرّر السماح بهذا الإجراء أو رفضه.`,approvalYourResponse:`ردّك: {decision}`,approvalEditHint:`يمكنك تعديل ردّك حتى تستأنف هذه الخطوة.`,approvalSubmitting:`تم إرسال الرد. جارٍ التنفيذ…`,edit:`تعديل`,toolParameters:`المعطيات`,statusAwaiting:`بانتظار الموافقة`,statusResponded:`تم الإرسال`,statusRunning:`قيد التنفيذ`,statusCompleted:`مكتمل`,statusDenied:`مرفوض`,statusError:`خطأ`,statusSuperseded:`تم التخطي`,statusIncomplete:`لم يكتمل`,toolStepsFailed:`فشل {count}`,statusStopped:`أُوقف`,toolStepsStopped:`أُوقف بعد {count} خطوات`,toolStepsStoppedOne:`أُوقف بعد خطوة واحدة`,thoughtsShowMore:`عرض المزيد`,thoughtsShowLess:`عرض أقل`},es:{attach:`Adjuntar archivos`,file:`Archivo`,attachmentMimeRejected:`Tipo de archivo no admitido`,attachmentTooLarge:`El archivo es demasiado grande`,attachmentTooMany:`Se alcanzó el límite de adjuntos`,conversationClosed:`Este chat está cerrado`,conversationLoading:`Cargando chat…`,loadPreviousMessages:`Cargar mensajes anteriores`,close:`Cerrar`,collapse:`Contraer`,collapseSidebar:`Contraer la barra lateral`,composerPlaceholder:`Escribe un mensaje…`,dateLastWeek:`Últimos 7 días`,dateOlder:`Anteriores`,dateToday:`Hoy`,dateYesterday:`Ayer`,dropZone:`Suelta los archivos para adjuntarlos`,errorGeneric:`Algo salió mal`,errorRateLimited:`Demasiadas solicitudes: inténtalo de nuevo en un momento.`,errorRateLimitedIn:`Demasiadas solicitudes: inténtalo de nuevo en {seconds} s.`,errorOffline:`No se puede conectar con el servidor. Revisa tu conexión e inténtalo de nuevo.`,errorServer:`Algo salió mal por nuestra parte. Inténtalo de nuevo.`,errorOriginNotAllowed:`Este chat aún no está configurado para este sitio web.`,errorReconnecting:`Se perdió la conexión. Reconectando…`,errorRetry:`Reintentar`,expand:`Ampliar`,expandSidebar:`Expandir la barra lateral`,exitFullscreen:`Salir de pantalla completa`,fullscreen:`Pantalla completa`,history:`Historial`,historyBack:`Volver al chat`,historyEmpty:`Aún no tienes chats`,historyContinue:`Continuar el chat`,historyLoading:`Cargando tus chats…`,historyTitle:`Historial de chats`,loadMoreConversations:`Cargar más conversaciones`,language:`Idioma`,launcherOpen:`Abrir el chat`,launcherLabel:`Chatea con nosotros`,micStart:`Iniciar entrada de voz`,micStop:`Detener entrada de voz`,micUnsupported:`Este navegador no admite la entrada de voz`,moreActions:`Más acciones`,newConversation:`Nuevo chat`,panelTitle:`Chat`,popOut:`Abrir en una pestaña nueva`,resizeHandle:`Arrastra para cambiar el tamaño`,scrollToBottom:`Ir a lo más reciente`,send:`Enviar`,queueMessage:`Poner mensaje en cola`,removeQueuedMessage:`Quitar mensaje de la cola`,compactingContext:`Optimizando el contexto de la conversación…`,soundOff:`Sonido desactivado`,soundOn:`Sonido activado`,startNewConversation:`Iniciar un chat nuevo`,talkToOperator:`Hablar con una persona`,connectingOperator:`Conectándote con una persona…`,noOperatorAvailable:`Nadie está disponible ahora — deja tus datos y te contactaremos.`,chattingWithOperator:`Estás chateando con {operator}`,cancelOperatorRequest:`Seguir con la IA`,stop:`Detener`,theme:`Tema`,themeAuto:`Automático`,themeDark:`Oscuro`,themeLight:`Claro`,textSize:`Tamaño del texto`,textSizeSmall:`Pequeño`,textSizeNormal:`Normal`,textSizeLarge:`Grande`,loading:`Cargando…`,visualPreparing:`Preparando visualización…`,visualError:`No se pudo mostrar esta visualización.`,visualPartial:`No se pudieron mostrar algunas partes de esta visualización.`,thinking:`Pensando…`,thought:`Razonamiento`,thoughtFor:`Razonó durante {time}`,toolResult:`Resultado`,sources:`Fuentes`,feedbackUp:`Buena respuesta`,feedbackDown:`Mala respuesta`,feedbackThanks:`Gracias por tu opinión`,copy:`Copiar`,copied:`Copiado`,tabHome:`Inicio`,tabConversations:`Chats`,tabHelp:`Ayuda`,tabNews:`Novedades`,modulesEmpty:`Aún no hay nada aquí`,moduleBack:`Atrás`,contentLoading:`Cargando…`,contentHelpful:`¿Te resultó útil?`,homeGreeting:`¿Cómo podemos ayudarte?`,homeGreetingNamed:`Hola, {name} 👋`,homeGreetingLead:`¿Cómo podemos ayudarte?`,homeSearchPlaceholder:`Buscar ayuda`,homeAskPlaceholder:`Haz una pregunta…`,homeWhatsNew:`Lo nuevo`,homeContentTitle:`Artículos populares`,homeStatus:`Estado`,helpTitle:`Ayuda`,helpSearchPlaceholder:`Buscar ayuda`,helpEmpty:`Aún no hay artículos de ayuda`,helpLoading:`Cargando la ayuda…`,helpSearchEmpty:`Sin resultados para «{query}»`,helpShowMore:`Mostrar más`,newsTitle:`Novedades`,newsEmpty:`Aún no hay novedades`,newsLoading:`Cargando novedades…`,newsBack:`Volver a novedades`,newsPublishedAt:`Publicado el {date}`,newsShowMore:`Mostrar más`,newsUnseen:`Publicación nueva`,formSubmit:`Enviar`,formSkip:`Quizá más tarde`,formSubmitted:`Completado`,formSkipped:`Quizá más tarde`,formFillOut:`Completar`,formRequired:`Este campo es obligatorio`,formInvalidEmail:`Introduce un correo electrónico válido`,formInvalidTel:`Introduce un número de teléfono válido`,formInvalidUrl:`Introduce una URL válida`,formInvalidNumber:`Introduce un número válido`,formTooShort:`Demasiado corto (mín. {min} caracteres)`,formTooLong:`Demasiado largo (máx. {max} caracteres)`,formNumberTooSmall:`Debe ser al menos {min}`,formNumberTooLarge:`Debe ser como máximo {max}`,formPatternMismatch:`Respeta el formato solicitado`,formChooseAtLeast:`Elige al menos {min}`,formChooseAtMost:`Elige como máximo {max}`,formOther:`Otro`,formOtherPlaceholder:`Escribe tu respuesta…`,inputRequired:`Preguntas para ti`,inputBadge:`Preguntas`,inputAnswered:`Respondido`,inputSkipped:`Omitido`,showOptions:`Mostrar opciones`,hideOptions:`Ocultar opciones`,qtypeText:`Tu respuesta`,qtypeEmail:`Correo electrónico`,qtypePhone:`Número de teléfono`,qtypeNumber:`Número`,qtypeDate:`Fecha`,qtypeChooseOne:`Elige una`,qtypeChooseAny:`Elige varias`,qtypeBoolean:`Sí / No`,inputSubmit:`Enviar respuestas`,inputSubmitHint:`Enter para enviar · Mayús+Enter = nueva línea`,inputSkip:`Omitir`,confirmYes:`Sí`,confirmNo:`No`,approve:`Aprobar`,reject:`Rechazar`,approvalPrompt:`{tool} requiere tu aprobación para ejecutarse.`,approvalBody:`Revisa los parámetros de arriba y decide si permites esta acción.`,approvalYourResponse:`Tu respuesta: {decision}`,approvalEditHint:`Puedes cambiar tu respuesta hasta que este paso continúe.`,approvalSubmitting:`Respuesta enviada. Procesando…`,edit:`Editar`,toolParameters:`Parámetros`,statusAwaiting:`Esperando aprobación`,statusResponded:`Enviado`,statusRunning:`En curso`,statusCompleted:`Completado`,statusDenied:`Denegado`,statusError:`Error`,statusSuperseded:`Omitido`,statusIncomplete:`No completado`,toolStepsFailed:`{count} con error`,statusStopped:`Detenido`,toolStepsStopped:`Detenido tras {count} pasos`,toolStepsStoppedOne:`Detenido tras 1 paso`,thoughtsShowMore:`Mostrar más`,thoughtsShowLess:`Mostrar menos`},he:{attach:`צירוף קבצים`,file:`קובץ`,attachmentMimeRejected:`סוג הקובץ אינו נתמך`,attachmentTooLarge:`הקובץ גדול מדי`,attachmentTooMany:`הגעת למספר המרבי של קבצים מצורפים`,conversationClosed:`הצ׳אט הזה נסגר`,conversationLoading:`טוען צ׳אט…`,loadPreviousMessages:`טעינת הודעות קודמות`,close:`סגירה`,collapse:`כיווץ`,collapseSidebar:`כיווץ סרגל הצד`,composerPlaceholder:`כתוב הודעה…`,dateLastWeek:`7 הימים האחרונים`,dateOlder:`ישן יותר`,dateToday:`היום`,dateYesterday:`אתמול`,dropZone:`שחרר קבצים כדי לצרף`,errorGeneric:`משהו השתבש`,errorRateLimited:`יותר מדי בקשות — נסה שוב בעוד רגע.`,errorRateLimitedIn:`יותר מדי בקשות — נסה שוב בעוד {seconds} שנ׳.`,errorOffline:`אין חיבור לשרת. בדוק את החיבור ונסה שוב.`,errorServer:`משהו השתבש אצלנו. נסה שוב.`,errorOriginNotAllowed:`הצ'אט הזה עדיין לא מוגדר לאתר הזה.`,errorReconnecting:`החיבור אבד. מתחבר מחדש…`,errorRetry:`נסה שוב`,expand:`הרחבה`,expandSidebar:`הרחבת סרגל הצד`,exitFullscreen:`יציאה ממסך מלא`,fullscreen:`מסך מלא`,history:`היסטוריה`,historyBack:`חזרה לצ׳אט`,historyEmpty:`אין עדיין צ׳אטים קודמים`,historyContinue:`המשך צ׳אט`,historyLoading:`טוען את הצ׳אטים שלך…`,historyTitle:`היסטוריית צ׳אטים`,loadMoreConversations:`טעינת שיחות נוספות`,language:`שפה`,launcherOpen:`פתיחת צ׳אט`,launcherLabel:`דברו איתנו`,micStart:`התחלת קלט קולי`,micStop:`עצירת קלט קולי`,micUnsupported:`קלט קולי אינו נתמך בדפדפן זה`,moreActions:`פעולות נוספות`,newConversation:`צ׳אט חדש`,panelTitle:`צ׳אט`,popOut:`פתיחה בכרטיסייה חדשה`,resizeHandle:`גרור לשינוי הגודל`,scrollToBottom:`מעבר לחדש ביותר`,send:`שליחה`,queueMessage:`הוספת ההודעה לתור`,removeQueuedMessage:`הסרת ההודעה מהתור`,compactingContext:`מבצע אופטימיזציה להקשר השיחה…`,soundOff:`השתקת הצליל`,soundOn:`הפעלת הצליל`,startNewConversation:`התחלת צ׳אט חדש`,talkToOperator:`דברו עם אדם`,connectingOperator:`מחברים אותך לאדם…`,noOperatorAvailable:`אין נציגים זמינים כעת — השאר את הפרטים שלך ונחזור אליך.`,chattingWithOperator:`אתה מצ׳וטט עם {operator}`,cancelOperatorRequest:`המשך לשוחח עם ה-AI`,stop:`עצירה`,theme:`ערכת נושא`,themeAuto:`אוטומטי`,themeDark:`כהה`,themeLight:`בהיר`,textSize:`גודל טקסט`,textSizeSmall:`קטן`,textSizeNormal:`רגיל`,textSizeLarge:`גדול`,loading:`טוען…`,visualPreparing:`מכין תצוגה…`,visualError:`לא ניתן היה להציג תצוגה זו.`,visualPartial:`לא ניתן היה להציג חלקים מתצוגה זו.`,thinking:`חושב…`,thought:`מחשבה`,thoughtFor:`חשב במשך {time}`,toolResult:`תוצאה`,sources:`מקורות`,feedbackUp:`תשובה טובה`,feedbackDown:`תשובה גרועה`,feedbackThanks:`תודה על המשוב`,copy:`העתק`,copied:`הועתק`,tabHome:`בית`,tabConversations:`צ׳אטים`,tabHelp:`עזרה`,tabNews:`חדשות`,modulesEmpty:`אין כאן עדיין כלום`,moduleBack:`חזרה`,contentLoading:`טוען…`,contentHelpful:`האם זה עזר?`,homeGreeting:`כיצד נוכל לעזור?`,homeGreetingNamed:`שלום {name} 👋`,homeGreetingLead:`כיצד נוכל לעזור?`,homeSearchPlaceholder:`חיפוש עזרה`,homeAskPlaceholder:`שאלו שאלה…`,homeWhatsNew:`מה חדש`,homeContentTitle:`מאמרים פופולריים`,homeStatus:`סטטוס`,helpTitle:`עזרה`,helpSearchPlaceholder:`חיפוש עזרה`,helpEmpty:`אין עדיין מאמרי עזרה`,helpLoading:`טוען עזרה…`,helpSearchEmpty:`אין תוצאות עבור „{query}”`,helpShowMore:`הצגת עוד`,newsTitle:`חדשות`,newsEmpty:`אין עדיין חדשות`,newsLoading:`טוען חדשות…`,newsBack:`חזרה לחדשות`,newsPublishedAt:`פורסם ב-{date}`,newsShowMore:`הצגת עוד`,newsUnseen:`פוסט חדש`,formSubmit:`שליחה`,formSkip:`אחר כך`,formSubmitted:`נשלח`,formSkipped:`דולג`,formFillOut:`מילוי`,formRequired:`שדה חובה`,formInvalidEmail:`הזן כתובת אימייל תקינה`,formInvalidTel:`הזן מספר טלפון תקין`,formInvalidUrl:`הזן כתובת URL תקינה`,formInvalidNumber:`הזן מספר תקין`,formTooShort:`קצר מדי (לפחות {min} תווים)`,formTooLong:`ארוך מדי (לכל היותר {max} תווים)`,formNumberTooSmall:`חייב להיות לפחות {min}`,formNumberTooLarge:`חייב להיות לכל היותר {max}`,formPatternMismatch:`התאם לתבנית הנדרשת`,formChooseAtLeast:`בחר לפחות {min}`,formChooseAtMost:`בחר לכל היותר {max}`,formOther:`אחר`,formOtherPlaceholder:`כתוב את תשובתך…`,inputRequired:`שאלות עבורך`,inputBadge:`שאלות`,inputAnswered:`נענה`,inputSkipped:`דולג`,showOptions:`הצג אפשרויות`,hideOptions:`הסתר אפשרויות`,qtypeText:`התשובה שלך`,qtypeEmail:`כתובת אימייל`,qtypePhone:`מספר טלפון`,qtypeNumber:`מספר`,qtypeDate:`תאריך`,qtypeChooseOne:`בחר אחת`,qtypeChooseAny:`בחר כמה`,qtypeBoolean:`כן / לא`,inputSubmit:`שליחת תשובות`,inputSubmitHint:`Enter לשליחה · Shift+Enter = שורה חדשה`,inputSkip:`דילוג`,confirmYes:`כן`,confirmNo:`לא`,approve:`אישור`,reject:`דחייה`,approvalPrompt:`הכלי {tool} דורש את אישורך כדי לפעול.`,approvalBody:`בדוק את פרמטרי הכלי שלמעלה והחלט אם לאשר פעולה זו.`,approvalYourResponse:`התגובה שלך: {decision}`,approvalEditHint:`ניתן לערוך את תגובתך עד שהשלב הזה יתחדש.`,approvalSubmitting:`התגובה נשלחה. מבצע…`,edit:`עריכה`,toolParameters:`פרמטרים`,statusAwaiting:`ממתין לאישור`,statusResponded:`נשלח`,statusRunning:`פועל`,statusCompleted:`הושלם`,statusDenied:`נדחה`,statusError:`שגיאה`,statusSuperseded:`דולג`,statusIncomplete:`לא הושלם`,toolStepsFailed:`{count} נכשלו`,statusStopped:`נעצר`,toolStepsStopped:`נעצר אחרי {count} שלבים`,toolStepsStoppedOne:`נעצר אחרי שלב אחד`,thoughtsShowMore:`הצגת עוד`,thoughtsShowLess:`הצגת פחות`}};function D(e,t){let n=O(e),r=M(t),i=n===`en`?{}:E[n]??{},a=r?t[n]??{}:t??{},o=r?t.en??{}:{};return{...T,...i,...o,...a}}function O(e){return(e.split(`-`)[0]??`en`).toLowerCase()}const k=/* @__PURE__ */ new Set([`ar`,`he`,`iw`,`fa`,`ur`,`ps`,`sd`,`ug`,`yi`,`dv`,`ckb`,`ks`,`nqo`,`prs`,`syr`]);function A(e){return k.has(O(e))}function j(e,t){return e[t]??t}function M(e){if(!e)return!1;for(let t of Object.values(e))if(t&&typeof t==`object`)return!0;return!1}const N={id:`help-ai`,name:`@helpai/elements`,global:`HelpAI`,tagName:`web-ai-chat`,cssPrefix:`helpai`,defaultBaseUrl:`https://help.ai`,displayName:`Help AI`,domain:`help.ai`,siteUrl:`https://help.ai`},ee=new class{get(e){try{return localStorage.getItem(e)}catch{return null}}set(e,t){try{localStorage.setItem(e,t)}catch{}}remove(e){try{localStorage.removeItem(e)}catch{}}},te={maxBytes:10485760,maxCount:10,accept:`*/*`},P={voice:`local`},ne={list:[],byTrigger:{}},re={enabled:!0,sampleRate:1},F={upload:`/pai/upload-file`,transcribe:`/pai/transcribe-audio`,submitForm:`/pai/submit-form`},I={variant:`circle`,size:`md`,label:void 0,icon:`chat`,hidden:!1},ie={floating:[`theme`,`textSize`,`history`,`close`,`clear`,`expand`,`fullscreen`,`popOut`,`sound`,`language`],inline:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`],standalone:[`theme`,`textSize`,`history`,`clear`,`sound`,`language`],page:[`theme`,`textSize`,`history`,`clear`,`sound`,`language`],modal:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`],drawer:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`]},ae={enabled:!0,volume:.3,events:void 0},L={enabled:!0,events:void 0},oe=[{label:`tabConversations`,layout:`chat`}],se=[`off`,`error`,`warn`,`info`,`debug`,`trace`],ce=N.cssPrefix,R=`${ce}.debug`,le=`__${N.global}_DEBUG__`,ue=`${ce}-debug`;let de=2;function fe(){if(typeof window>`u`)return 2;try{let e=new URLSearchParams(window.location.search).get(ue);if(e!==null){let t=pe(e);if(t>=0)return t}}catch{}try{let e=window.localStorage?.getItem(R);if(e){let t=pe(e);if(t>=0)return t}}catch{}return Reflect.get(window,le)?4:2}function pe(e){if(e===!0||e===`1`||e===`true`)return 4;if(e===!1||e===`0`||e===`false`||e===`off`)return 0;if(typeof e==`number`)return Math.max(0,Math.min(5,Math.floor(e)));if(typeof e==`string`){let t=se.findIndex(t=>t===e);if(t>=0)return t}return-1}de=fe();function me(e){let t=`[${ce}:${e}]`;function n(e,n,r){return(r,i)=>{de<e||(i===void 0?console[n](t,r):console[n](t,r,i))}}return{error:n(1,`error`,`error`),warn:n(2,`warn`,`warn`),info:n(3,`info`,`info`),debug:n(4,`debug`,`debug`),trace:n(5,`debug`,`trace`),scope:t=>me(`${e}:${t}`)}}const z=me(`core`),he=z.scope(`context`),ge=/* @__PURE__ */ new Set([`visitorId`,`conversationId`,`jwt`,`token`,`authorization`,`password`]),_e=1024,ve=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function ye(e){return xe(e,`userContext`,!0)}function be(e){return xe(e,`pageContext`,!1)}function xe(e,t,n){if(e==null)return;if(typeof e!=`object`||Array.isArray(e)){he.warn(`ignored ${t} — expected an object`,{type:Array.isArray(e)?`array`:typeof e});return}let r={},i=0;for(let[n,a]of Object.entries(e)){if(ge.has(n)){he.warn(`dropped reserved ${t} key "${n}" — managed by the widget, not host-settable`);continue}if(a==null)continue;if(i>=50){he.warn(`${t} truncated at 50 keys — dropped "${n}"`);continue}let e=Se(t,n,a);e!==void 0&&(r[n]=e,i++)}return n&&typeof r.email==`string`&&!ve.test(r.email)&&(he.warn(`dropped malformed context field`,{field:`${t}.email`,reason:`invalid format`}),delete r.email),Object.keys(r).length>0?r:void 0}function Se(e,t,n){if(typeof n==`boolean`)return n;if(typeof n==`number`){if(!Number.isFinite(n)){he.warn(`dropped non-finite ${e}.${t}`);return}return n}if(typeof n==`string`){let r=n.trim();return r===``?void 0:r.length>_e?(he.warn(`truncated ${e}.${t} to ${_e} chars`),r.slice(0,_e)):r}he.warn(`dropped ${e}.${t} — only string/number/boolean values are allowed`,{type:typeof n})}function Ce(e){let t=typeof e==`object`&&e?e:{},n=t.presentation??{},r=t.behavior??{},i=t.i18n??{},a=t.feedback??{},o=t.footer??{},s=t.header??{},c={enabled:t.history?.enabled??!0},{themeMode:l,themeOverrides:u}=we(t.theme),d=n.mode??`floating`,f=Te(i.defaultLocale),p=i.availableLocales??[i.locale??f],m=Ee(i.locale??f,p,f),h=(t.baseUrl??N.defaultBaseUrl).replace(/\/$/,``),g=(t.agentApiBaseUrl??`${h}/api/agent`).replace(/\/$/,``),_=(t.dataApiBaseUrl??`${h}/api/data`).replace(/\/$/,``);return{widgetId:t.widgetId??`default`,publicKey:t.publicKey,aiAgentDeploymentId:t.aiAgentDeploymentId,baseUrl:h,agentApiBaseUrl:g,dataApiBaseUrl:_,userContext:ye(t.userContext),pageContext:be(t.pageContext),position:n.position??`bottom-right`,themeMode:l,textSize:`normal`,themeOverrides:u,mode:d,iframe:n.iframe??!1,responseMode:r.responseMode??`streaming`,showReasoning:r.showReasoning??!1,showToolCalls:r.showToolCalls??!1,showSources:r.showSources??!1,enableMessageFeedback:!(r.disableMessageFeedback??!1),autoSendSuggestions:r.autoSendSuggestions??!1,popOutUrl:r.popOutUrl,features:{voice:t.features?.voice??P.voice,fileUpload:!(t.features?.disableFileUpload??!1),humanInLoop:!(t.features?.disableHumanInLoop??!1),operatorRequest:t.features?.enableOperatorRequest===!0},forms:Pe(t.forms,m),endpoints:{upload:t.endpoints?.upload??F.upload,transcribe:t.endpoints?.transcribe??F.transcribe,submitForm:t.endpoints?.submitForm??F.submitForm},attachments:{accept:t.composer?.attachments?.accept??te.accept,maxBytes:t.composer?.attachments?.maxBytes??te.maxBytes,maxCount:t.composer?.attachments?.maxCount??te.maxCount},locale:m,defaultLocale:f,availableLocales:p,startMinimized:r.startMinimized??!0,actions:De(d,s.actions,c.enabled),size:n.size??{},launcher:Ie(t.launcher),sound:Oe(a.sound),haptics:ke(a.haptics),strings:D(m,i.strings),stringsOverride:i.strings,composerDisclaimer:o.composerDisclaimer??``,poweredBy:je(o.poweredBy),composer:Me(t.composer),modules:Ne(t.modules,c.enabled),tracking:Ae(t.tracking,_),history:c,storage:t.storage??ee,userToken:t.userToken,tools:t.tools,onMessage:t.onMessage,onOpen:t.onOpen,onClose:t.onClose,onError:t.onError}}function we(e){if(typeof e==`string`)return{themeMode:e,themeOverrides:{}};if(!e||typeof e!=`object`)return{themeMode:`auto`,themeOverrides:{}};let{mode:t,...n}=e;return{themeMode:t??`auto`,themeOverrides:n}}function Te(e){return e&&e!==`auto`?e:globalThis.navigator?.language||`en`}function Ee(e,t,n){return t.length<=1||t.includes(e)?e:t.includes(n)?n:t[0]??e}function De(e,t,n){let r=t??ie[e];return n?r:r.filter(e=>e!==`history`)}function Oe(e){return{enabled:e?.enabled??ae.enabled,volume:e?.volume??ae.volume,events:e?.events}}function ke(e){return{enabled:e?.enabled??L.enabled,events:e?.events}}function Ae(e,t){let n=e?.sampleRate??re.sampleRate;return{enabled:e?.enabled??re.enabled,endpoint:e?.endpoint??`${t}/pai/elements-px.gif`,sampleRate:Math.min(1,Math.max(0,Number.isFinite(n)?n:1)),token:e?.token}}function je(e){let t={text:`Powered by ${N.displayName}`,href:N.siteUrl,...e};return t.text||t.logoUrl?t:null}function Me(e){let t=e?.sendButton;return{sendButton:{shape:t?.shape??`circle`,icon:t?.icon??`arrowUp`,variant:t?.variant??`filled`}}}function Ne(e,t){let n=e??oe,r=/* @__PURE__ */ new Set,i=[];for(let e of n.slice(0,4)){if(!e?.label||!e?.layout)continue;let n=e.contentCollectionIds?.filter(Boolean),a=e.id??n?.[0]??e.layout;for(;r.has(a);)a=`${a}-${i.length}`;r.add(a);let o={id:a,label:e.label,layout:e.layout};n?.length&&(o.contentCollectionIds=n),e.layout===`home`&&(o.brandName=e.brandName,o.greetingText=e.greetingText,o.showGreeting=!(e.hideGreeting??!1),o.showSearchBar=!(e.hideSearchBar??!1),o.showRecentConversations=t&&!(e.hideRecentConversations??!1),e.userAvatars?.length&&(o.userAvatars=e.userAvatars),e.status&&(o.status=e.status),o.contentBlockTitle=e.contentBlockTitle),i.push(o)}return{list:i,byId:Object.fromEntries(i.map(e=>[e.id,e]))}}function Pe(e,t){if(!e?.length)return ne;let n=[],r=/* @__PURE__ */ new Set;for(let i of e){if(!i?.id||r.has(i.id))continue;let e=w(i,t),a=(e.fields??[]).filter(e=>!!(e?.name&&e.label&&e.type)),o=(Array.isArray(e.on)?e.on:[e.on]).map(Fe).filter(e=>e!==null);a.length!==0&&o.length!==0&&(r.add(e.id),n.push({id:e.id,triggers:o,when:e.when,fields:a,title:e.title,description:e.description,submitLabel:e.submitLabel,skippable:e.skippable??!1,blocking:e.blocking??!1,frequency:e.frequency??`once`,mirrorToContext:e.mirrorToContext??!0,reopenable:e.reopenable??!0,reviewable:e.reviewable??!0}))}let i={};for(let e of n){var a;for(let t of e.triggers)(i[a=t.kind]??(i[a]=[])).push(e)}return{list:n,byTrigger:i}}function Fe(e){if(typeof e!=`string`)return null;if(e===`pre-chat`||e===`conversation-closed`||e===`panel-close`||e===`manual`)return{kind:e};let[t,n]=e.split(`:`,2);if(t===`after-messages`){let e=Number(n);return Number.isFinite(e)&&e>0?{kind:`after-messages`,param:e}:null}if(t===`idle`){let e=Number(n);return Number.isFinite(e)&&e>0?{kind:`idle`,param:e}:null}return t===`page-area`&&n?{kind:`page-area`,param:n}:null}function Ie(e){let t=e?.callout?.text?{shape:`pill`,position:`auto`,delayMs:1200,autoDismissMs:0,animated:!0,persistent:!0,...e.callout}:null;return{variant:e?.variant??I.variant,size:e?.size??I.size,label:e?.label??I.label,icon:e?.icon??I.icon,hidden:e?.hidden??I.hidden,callout:t}}function Le(e,t,n,r){let i=Ee(t,e.availableLocales,e.defaultLocale);if(i===e.locale&&n===e.themeMode&&r===e.textSize)return e;let a={...e};return i!==e.locale&&(a.locale=i,a.strings=D(i,e.stringsOverride)),n!==e.themeMode&&(a.themeMode=n),r!==e.textSize&&(a.textSize=r),a}const Re=[`presentation`,`behavior`,`theme`,`launcher`,`header`,`composer`,`feedback`,`i18n`,`footer`,`features`,`tracking`,`endpoints`,`history`];function ze(e,t){if(!t)return e;let n={...e};for(let r of Re){let i=t[r];if(i===void 0)continue;let a=e[r];r===`theme`?a===void 0?n[r]=i:typeof a==`string`&&typeof i==`object`&&i&&(n[r]={...i,mode:a}):r!==`i18n`&&(n[r]=Be(i,a))}t.modules!==void 0&&e.modules===void 0&&(n.modules=t.modules),t.dataApiBaseUrl!==void 0&&e.dataApiBaseUrl===void 0&&(n.dataApiBaseUrl=t.dataApiBaseUrl);let r=e.i18n,i=t.i18n;if(r||i){let e=Be(i??{},r);i?.availableLocales!==void 0&&(e.availableLocales=i.availableLocales),i?.defaultLocale!==void 0&&(e.defaultLocale=i.defaultLocale);let t=r?.strings,a=i?.strings;(t||a)&&(e.strings=Ve(a,t)),n.i18n=e}return n}function Be(e,t){if(!t)return e;let n={...e};for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);return n}function Ve(e,t){if(!e)return t;if(!t)return e;let n=M(e),r=M(t);if(!n&&!r)return{...e,...t};let i={},a=n?e:{en:e},o=r?t:{en:t};for(let[e,t]of Object.entries(a))i[e]={...t};for(let[e,t]of Object.entries(o))i[e]={...i[e],...t};return i}const He=[`clear`,`expand`,`fullscreen`,`popOut`,`sound`,`history`,`language`,`theme`,`textSize`,`close`];function Ue(e){return e!==`false`}function We(e){return e.split(`,`).map(e=>e.trim()).filter(Boolean)}const Ge=[[`public-key`,`publicKey`],[`ai-agent-deployment-id`,`aiAgentDeploymentId`],[`base-url`,`baseUrl`],[`agent-api-base-url`,`agentApiBaseUrl`],[`data-api-base-url`,`dataApiBaseUrl`],[`theme`,`theme`,e=>e]],Ke=[[`mode`,`mode`,e=>e],[`position`,`position`,e=>e],[`iframe`,`iframe`,Ue]],qe=[[`width`,`width`],[`height`,`height`]],Je=[[`response-mode`,`responseMode`,e=>e],[`start-minimized`,`startMinimized`,Ue],[`show-reasoning`,`showReasoning`,Ue],[`show-tool-calls`,`showToolCalls`,Ue],[`show-sources`,`showSources`,Ue],[`disable-message-feedback`,`disableMessageFeedback`,Ue],[`auto-send-suggestions`,`autoSendSuggestions`,Ue],[`pop-out-url`,`popOutUrl`]],Ye=[[`locale`,`locale`]],Xe=new Set(He);function Ze(e){return We(e).filter(e=>Xe.has(e))}const Qe=[[`launcher-variant`,`variant`,e=>e],[`launcher-size`,`size`,e=>e],[`launcher-icon`,`icon`],[`launcher-hidden`,`hidden`,Ue]],B=[[`features-disable-file-upload`,`disableFileUpload`,Ue],[`features-voice`,`voice`,e=>e]],$e=[[`endpoint-upload`,`upload`],[`endpoint-transcribe`,`transcribe`]],et=[[`user-id`,`id`],[`user-email`,`email`],[`user-name`,`name`]],tt=[[`page-area`,`area`],[`page-url`,`url`],[`page-path`,`path`],[`page-title`,`title`]],nt=[`launcher-label`,`callout-text`,`callout-delay`,`actions`,`user-context`,`page-context`],rt=[Ge,Ke,qe,Je,Ye,Qe,B,$e,et,tt],it=/* @__PURE__ */ new Set([`iframe`,`start-minimized`]),at=[...rt.flatMap(e=>e.map(([e])=>e).filter(e=>!it.has(e))),...nt];function ot(e){let t={};function n(t){let n=e(t);return n===null||n===``?void 0:n}for(let[e,r,i]of Ge){let a=n(e);a!==void 0&&(t[r]=i?i(a):a)}let r=st(n,Ke),i=st(n,qe);(r||i)&&(t.presentation={...r,...i?{size:i}:{}});let a=st(n,Je);a&&(t.behavior=a);let o=st(n,Ye);o&&(t.i18n=o);let s=lt(e,n);s&&(t.launcher=s);let c=st(n,B);c&&(t.features=c);let l=st(n,$e);l&&(t.endpoints=l);let u=ct(n,et,`user-context`);u&&(t.userContext=u);let d=ct(n,tt,`page-context`);d&&(t.pageContext=d);let f=n(`actions`);return f!==void 0&&(t.header={actions:Ze(f)}),t}function st(e,t){let n={};for(let[r,i,a]of t){let t=e(r);t!==void 0&&(n[i]=a?a(t):t)}return Object.keys(n).length>0?n:null}function ct(e,t,n){let r={};for(let[n,i]of t){let t=e(n);t!==void 0&&(r[i]=t)}let i={},a=e(n);if(a)try{let e=JSON.parse(a);e&&typeof e==`object`&&!Array.isArray(e)&&(i=e)}catch{}let o={...i,...r};return Object.keys(o).length>0?o:null}function lt(e,t){let n=st(t,Qe)??{},r=e(`launcher-label`);r!==null&&(n.label=r);let i=t(`callout-text`);if(i){let e=Number.parseInt(t(`callout-delay`)??``,10);n.callout={text:i,...Number.isFinite(e)?{delayMs:e}:{}}}return Object.keys(n).length>0?n:null}const ut=z.scope(`track`);function dt(e,t){let n=typeof e==`string`?e.trim():``;if(!n||n.length>64){ut.warn(`track: ignored an event without a name of 1–64 characters`,{name:e});return}let r=Object.fromEntries(Object.entries(typeof t==`object`&&t?t:{}).filter(e=>typeof e[1]==`string`||typeof e[1]==`boolean`||Number.isFinite(e[1])));return JSON.stringify(r).length>256?(ut.warn(`track: sent the event without its data, which is over 256 characters`,{name:n}),{name:n}):Object.keys(r).length>0?{name:n,data:r}:{name:n}}function ft(e){let t=[];return e.on(`hostEvent`,e=>{t.push({...e,at:Date.now()}),t.length>10&&t.shift()}),t}function pt(){let e=Date.now(),t=/* @__PURE__ */ new Uint8Array(16);t[0]=Math.floor(e/2**40)&255,t[1]=Math.floor(e/2**32)&255,t[2]=e>>>24&255,t[3]=e>>>16&255,t[4]=e>>>8&255,t[5]=e&255,mt(t.subarray(6)),t[6]=t[6]&15|112,t[8]=t[8]&63|128;let n=Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``);return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function mt(e){if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256)}const ht=z.scope(`persistence`);function gt(e,t=ee,n){let r=n?`${e}.${n}`:e,i=`${N.cssPrefix}.storageVersion`,a=t.get(i)??void 0,o=a?`.v${a}`:``,s=`${N.cssPrefix}.${r}${o}`,c=`${N.cssPrefix}${o}.visitorId`,l=`${s}.conversationId`,u=`${s}.userPrefs`,d=`${s}.panelOpen`,f=`${s}.panelSize`,p=`${s}.calloutDismissed`,m=`${s}.sidebarCollapsed`,h=`${s}.activeModule`,g=`${s}.seenNewsId`,_=`${s}.historyCount`,v=`${s}.formsDone`,y={getVisitorId(){let e=t.get(c);if(e)return e;let n=pt();return t.set(c,n),n},loadConversationId(){return t.get(l)??void 0},saveConversationId(e){ht.trace(`saveConversationId`,{id:e,scope:r}),e?t.set(l,e):t.remove(l)},loadDraft(e){return t.get(`${s}.draft.${e}`)??``},saveDraft(e,n){let r=`${s}.draft.${e}`;n?t.set(r,n):t.remove(r)},loadMessageQueue(e){let n=t.get(`${s}.messageQueue.${e}`);if(!n)return[];try{let e=JSON.parse(n);return!Array.isArray(e)||!e.every(vt)?[]:e}catch(e){return ht.warn(`loadMessageQueue parse failed`,{error:e}),[]}},saveMessageQueue(e,n){let r=`${s}.messageQueue.${e}`;if(n.length===0)t.remove(r);else try{t.set(r,JSON.stringify(n))}catch(e){ht.warn(`saveMessageQueue serialise failed`,{error:e})}},loadUserPrefs(){let e=t.get(u);if(!e)return{};try{return yt(JSON.parse(e))}catch(e){return ht.warn(`loadUserPrefs parse failed`,{error:e}),{}}},saveUserPrefs(e){try{t.set(u,JSON.stringify(e))}catch(e){ht.warn(`saveUserPrefs serialise failed`,{error:e})}},patchUserPrefs(e){let t=y.loadUserPrefs();y.saveUserPrefs({...t,...e})},loadPanelOpen(){let e=t.get(d);return e===`1`||e!==`0`&&null},savePanelOpen(e){t.set(d,e?`1`:`0`)},loadPanelSize(){let e=t.get(f);return e===`normal`||e===`expanded`||e===`fullscreen`?e:null},savePanelSize(e){t.set(f,e)},loadCalloutDismissed(e){if(!e)return!1;let n=t.get(p);return!!n&&n===e},saveCalloutDismissed(e){e?t.set(p,e):t.remove(p)},loadSidebarCollapsed(){let e=t.get(m);return e===`1`||e!==`0`&&null},saveSidebarCollapsed(e){t.set(m,e?`1`:`0`)},loadActiveModule(){return t.get(h)||null},saveActiveModule(e){t.set(h,e)},loadSeenNewsId(){return t.get(g)||null},saveSeenNewsId(e){t.set(g,e)},loadHistoryCount(){let e=t.get(_);if(!e)return null;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>=0?n:null},saveHistoryCount(e){t.set(_,String(e))},loadFormsDone(){let e=t.get(v);if(!e)return{};try{let t=JSON.parse(e);return _t(t)?Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]==`number`)):{}}catch(e){return ht.warn(`loadFormsDone parse failed`,{error:e}),{}}},saveFormDone(e){try{let n=y.loadFormsDone();n[e]=Date.now(),t.set(v,JSON.stringify(n))}catch(e){ht.warn(`saveFormDone serialise failed`,{error:e})}},rememberStorageVersion(e){e&&e!==t.get(i)&&(ht.debug(`rememberStorageVersion (force-reset on next load)`,{version:e}),t.set(i,e))},clearConversation(){t.remove(l)},reset(){let e=t.get(l);e&&(t.remove(`${s}.draft.${e}`),t.remove(`${s}.messageQueue.${e}`));for(let e of[c,l,u,d,f,p,m,h,g,_,v])t.remove(e);ht.info(`reset: forgot the visitor`,{scope:r})}};return y}function _t(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function vt(e){return _t(e)&&typeof e.id==`string`&&e.id.length>0&&typeof e.text==`string`}function yt(e){if(!_t(e))return{};let t={};return typeof e.locale==`string`&&(t.locale=e.locale),typeof e.soundMuted==`boolean`&&(t.soundMuted=e.soundMuted),(e.themeMode===`auto`||e.themeMode===`light`||e.themeMode===`dark`)&&(t.themeMode=e.themeMode),(e.textSize===`small`||e.textSize===`normal`||e.textSize===`large`)&&(t.textSize=e.textSize),_t(e.widgetSize)&&typeof e.widgetSize.width==`number`&&typeof e.widgetSize.height==`number`&&(t.widgetSize={width:e.widgetSize.width,height:e.widgetSize.height}),t}const bt=`1.14.2`,xt={open:()=>void 0,close:()=>void 0,expand:e=>({on:e}),fullscreen:e=>({on:e}),send:e=>({attachments:e.attachmentCount}),message:e=>({role:e.role}),stop:()=>void 0,clear:()=>void 0,suggestion:()=>void 0,toggleHistory:e=>({view:e.view}),handshake:()=>void 0,formSubmit:e=>({formId:e.formId,skipped:e.skipped}),toolResult:()=>void 0,toolDecision:e=>({approved:e.approved}),hostEvent:e=>({name:e.name,data:e.data&&JSON.stringify(e.data)}),messageFeedback:e=>({value:e.value??`none`}),contentView:e=>({section:e.section,count:e.count}),contentOpen:e=>({contentId:e.contentId,contentCollectionId:e.contentCollectionId}),contentSearch:e=>({qlen:e.queryLength,hits:e.hitCount}),contentRead:e=>({contentId:e.contentId}),contentLinkClick:e=>({contentId:e.contentId}),attach:e=>({count:e.count,bytes:e.totalBytes}),voiceStart:()=>void 0,voiceStop:e=>({ms:e.durationMs}),voiceCancel:()=>void 0,localeChange:e=>({locale:e}),themeChange:e=>({theme:e}),textSizeChange:e=>({size:e}),soundToggle:e=>({muted:e.muted}),sidebarToggle:e=>({collapsed:e.collapsed}),calloutDismiss:()=>void 0,error:()=>void 0};function St(){let e=navigator;return e.globalPrivacyControl===!0||e.doNotTrack===`1`}function Ct(){return location.origin+location.pathname}function wt(){try{return document.referrer?new URL(document.referrer).origin:``}catch{return``}}function Tt(e,t){let n=Math.random(),r=0,i=0,a=/* @__PURE__ */ new Set;function o(e,o){let{tracking:s,publicKey:c,aiAgentDeploymentId:l,mode:u,themeMode:d}=t.getOptions();if(!s.enabled||St()||n>=s.sampleRate)return;let f=performance.now();if(f-r>6e4&&(r=f,i=0),++i>60)return;let p=new URLSearchParams;p.set(`v`,`1`),p.set(`_ev`,bt),p.set(`e`,e),s.token&&p.set(`tk`,s.token),c&&p.set(`pk`,c),l&&p.set(`dep`,l),p.set(`vid`,t.getVisitorId());let m=t.getConversationId();m&&p.set(`cid`,m),p.set(`url`,Ct());let h=wt();h&&p.set(`ref`,h),p.set(`sw`,String(screen.width)),p.set(`sh`,String(screen.height)),p.set(`vw`,String(innerWidth)),p.set(`vh`,String(innerHeight)),p.set(`dpr`,String(devicePixelRatio)),p.set(`lang`,navigator.language);try{p.set(`tz`,Intl.DateTimeFormat().resolvedOptions().timeZone)}catch{}if(p.set(`m`,u),p.set(`th`,d),o)for(let[e,t]of Object.entries(o))t!==void 0&&p.set(e,String(t));p.set(`ts`,String(Date.now()));let g=`${s.endpoint}?${p}`;if(g.length>2e3)return;let _=new Image(1,1);a.add(_);function v(){return a.delete(_)}_.addEventListener(`load`,v,{once:!0}),_.addEventListener(`error`,v,{once:!0}),_.src=g}let s=[];function c(e,t){if(s&&e!==`handshake`){s.length<60&&s.push([e,t]);return}let n=s??[];s=void 0;for(let[e,t]of n)o(e,t);o(e,t)}let l=Object.keys(xt).map(t=>e.on(t,e=>c(t,xt[t]?.(e))));return()=>{for(let e of l)e();a.clear()}}const Et=`:host{--__P__-accent-user: __BRAND_ACCENT__;--__P__-accent: var(--__P__-accent-user);--__P__-accent-text-user: __BRAND_ACCENT_TEXT__;--__P__-accent-text: var(--__P__-accent-text-user);--__P__-accent-fg: var(--__P__-accent);--__P__-radius: __BRAND_RADIUS__;--__P__-radius-sm: 8px;--__P__-radius-md: 10px;--__P__-radius-lg: 16px;--__P__-font: __BRAND_FONT__;--__P__-font-display: var(--__P__-font);--__P__-font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;--__P__-bg: oklch(1 0 0);--__P__-bg-elevated: oklch(.9789 .0029 278.3);--__P__-surface: var(--__P__-bg-elevated);--__P__-muted: var(--__P__-fg-muted);--__P__-hover: oklch(.1686 .011 278.3 / .06);--__P__-fg: oklch(.1686 .011 278.3);--__P__-fg-muted: oklch(.4932 .0301 278.3);--__P__-border: oklch(.9312 .0084 278.3);--__P__-border-strong: oklch(.8757 .0131 278.3);--__P__-bubble-user: var(--__P__-accent);--__P__-bubble-user-text: var(--__P__-accent-text);--__P__-bubble-assistant: oklch(.9638 .0058 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-on-accent: var(--__P__-accent-text);--__P__-success: oklch(.6456 .1654 151.53);--__P__-warning: oklch(.7135 .1494 74.05);--__P__-danger: oklch(.5966 .1818 24.51);--__P__-danger-text: oklch(.5054 .1905 27.52);--__P__-danger-bg: oklch(.5966 .1818 24.51 / .1);--__P__-neutral: oklch(.7137 .0192 278.3);--__P__-pill-l-min: .3;--__P__-pill-l-max: .46;--__P__-focus: var(--__P__-accent);--__P__-shadow-panel: 0 8px 24px -8px rgba(13, 15, 20, .18), 0 24px 64px -24px rgba(13, 15, 20, .24);--__P__-shadow-card: 0 1px 2px rgba(13, 15, 20, .06), 0 4px 12px -6px rgba(13, 15, 20, .12);--__P__-backdrop: oklch(.1686 .011 278.3 / .55);--__P__-shadow-fab: 0 6px 16px -4px color-mix(in oklch, var(--__P__-accent) 45%, transparent), 0 12px 32px -12px rgba(13, 15, 20, .25);--__P__-z-fab: 2147483600;--__P__-z-panel: 2147483601;--__P__-panel-w: 380px;--__P__-panel-h: 600px;--__P__-fab-size: 56px;--__P__-conversation-max: 768px;--__P__-space-1: 4px;--__P__-space-2: 8px;--__P__-space-3: 12px;--__P__-space-4: 16px;--__P__-space-5: 20px;--__P__-space-6: 24px;--__P__-space-8: 32px;--__P__-text-scale: 1;--__P__-text-xs: calc(12px * var(--__P__-text-scale));--__P__-text-sm: calc(13px * var(--__P__-text-scale));--__P__-text-base: calc(15px * var(--__P__-text-scale));--__P__-text-md: calc(16px * var(--__P__-text-scale));--__P__-text-lg: calc(18px * var(--__P__-text-scale));--__P__-text-xl: calc(22px * var(--__P__-text-scale));--__P__-text-2xl: calc(30px * var(--__P__-text-scale))}:host([data-mode="modal"]),:host([data-mode="drawer"]){--__P__-conversation-max: 100%}:host([data-text-size="small"]){--__P__-text-scale: .9}:host([data-text-size="large"]){--__P__-text-scale: 1.15}:host{--__P__-ease: cubic-bezier(.2, .7, .2, 1);--__P__-ease-out: cubic-bezier(.2, .7, .2, 1);--__P__-ease-in: cubic-bezier(.4, 0, 1, 1);--__P__-ease-in-out: cubic-bezier(.65, 0, .35, 1);--__P__-dur-quick: .12s;--__P__-dur-base: .22s;--__P__-dur-slow: .32s;font-family:var(--__P__-font);color:var(--__P__-fg);color-scheme:light;--__P__-color-scheme: light}:host([data-theme="dark"]){--__P__-bg: oklch(.1783 .0128 278.3);--__P__-bg-elevated: oklch(.2232 .0182 278.3);--__P__-fg: oklch(.9368 .01 278.3);--__P__-fg-muted: oklch(.7048 .0296 278.3);--__P__-border: oklch(.2752 .0266 278.3);--__P__-border-strong: oklch(.335 .0291 278.3);--__P__-hover: oklch(.9368 .01 278.3 / .08);--__P__-bubble-assistant: oklch(.2474 .0311 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-danger-text: oklch(.8077 .1035 19.57);--__P__-danger-bg: oklch(.5966 .1818 24.51 / .18);--__P__-shadow-panel: 0 8px 24px -8px rgba(0, 0, 0, .6), 0 24px 64px -24px rgba(0, 0, 0, .7);--__P__-shadow-card: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 12px -6px rgba(0, 0, 0, .5);--__P__-backdrop: rgba(0, 0, 0, .65);--__P__-pill-l-min: .75;--__P__-pill-l-max: .92;color-scheme:dark;--__P__-color-scheme: dark}@media(prefers-color-scheme:dark){:host([data-theme="auto"]){--__P__-bg: oklch(.1783 .0128 278.3);--__P__-bg-elevated: oklch(.2232 .0182 278.3);--__P__-fg: oklch(.9368 .01 278.3);--__P__-fg-muted: oklch(.7048 .0296 278.3);--__P__-border: oklch(.2752 .0266 278.3);--__P__-border-strong: oklch(.335 .0291 278.3);--__P__-hover: oklch(.9368 .01 278.3 / .08);--__P__-bubble-assistant: oklch(.2474 .0311 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-pill-l-min: .75;--__P__-pill-l-max: .92;--__P__-shadow-panel: 0 8px 24px -8px rgba(0, 0, 0, .6), 0 24px 64px -24px rgba(0, 0, 0, .7);color-scheme:dark;--__P__-color-scheme: dark}}@supports (color: oklch(from red l c h)){:host{--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.3, l, .62) c h);--__P__-accent-text: oklch(from var(--__P__-accent) clamp(0, (l / .623 - 1) * -infinity, 1) 0 h);--__P__-accent-fg: oklch(from var(--__P__-accent-user) clamp(.3, l, .46) c h)}:host([data-theme="dark"]){--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.65, l, .85) c h);--__P__-accent-fg: var(--__P__-accent)}@media(prefers-color-scheme:dark){:host([data-theme="auto"]){--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.65, l, .85) c h);--__P__-accent-fg: var(--__P__-accent)}}}@media(prefers-reduced-motion:reduce){:host{--__P__-dur-quick: 1ms;--__P__-dur-base: 1ms;--__P__-dur-slow: 1ms}}
|
|
2
2
|
|
|
3
3
|
*,*:before,*:after{box-sizing:border-box;margin:0;padding:0;border:0}button{font:inherit;color:inherit;background:none;cursor:pointer;-webkit-appearance:none;appearance:none;line-height:1}button:focus-visible,[tabindex]:focus-visible,textarea:focus-visible,input:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px}textarea,input{font:inherit;color:inherit;background:none;border:0;outline:0;resize:none}a{color:var(--__P__-accent-fg);text-decoration:underline;text-underline-offset:2px}img,svg{display:block;max-width:100%}ul,ol{list-style:none}.__P__-app{display:block;width:100%;height:100%;font-family:var(--__P__-font);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-feature-settings:"cv11","ss01","ss03"}.__P__-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}
|
|
4
4
|
|
|
5
|
-
.__P__-anchor{color-scheme:var(--__P__-color-scheme, light);right:16px;bottom:16px}.__P__-surface{display:contents}.__P__-surface[hidden]{display:none}:host([data-position="bottom-left"]) .__P__-anchor,:host([data-position="top-left"]) .__P__-anchor{right:auto;left:16px}:host([data-position="top-right"]) .__P__-anchor,:host([data-position="top-left"]) .__P__-anchor{bottom:auto;top:16px}.__P__-anchor{position:fixed;display:flex;flex-direction:column;align-items:flex-end;gap:var(--__P__-space-3);pointer-events:none}.__P__-anchor{--__P__-fab-size: 56px}.__P__-anchor[data-launcher-size=sm]{--__P__-fab-size: 44px}.__P__-anchor[data-launcher-size=md]{--__P__-fab-size: 56px}.__P__-anchor[data-launcher-size=lg]{--__P__-fab-size: 68px}.__P__-anchor>*{pointer-events:auto}.__P__-fab[data-size=sm]{--__P__-fab-size: 44px;font-size:var(--__P__-text-sm)}.__P__-fab[data-size=md]{--__P__-fab-size: 56px;font-size:calc(14px * var(--__P__-text-scale))}.__P__-fab[data-size=lg]{--__P__-fab-size: 68px;font-size:var(--__P__-text-base)}.__P__-fab{display:inline-flex;align-items:center;justify-content:center;gap:var(--__P__-space-2);color:var(--__P__-accent-text);background:var(--__P__-accent);box-shadow:var(--__P__-shadow-fab);font-weight:600;line-height:1;transform-origin:bottom right;animation:__P__-fab-in var(--__P__-dur-base) var(--__P__-ease) both;transition:transform var(--__P__-dur-base) var(--__P__-ease),opacity var(--__P__-dur-base) var(--__P__-ease),box-shadow var(--__P__-dur-base) var(--__P__-ease)}.__P__-fab:hover{transform:translateY(-2px)}.__P__-fab:active{transform:translateY(0)}.__P__-fab:focus-visible{outline:2px solid var(--__P__-on-accent);outline-offset:3px}.__P__-fab svg{width:24px;height:24px;flex-shrink:0}@keyframes __P__-fab-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:none}}.__P__-fab[data-leaving]{position:absolute;right:0;bottom:0;animation:__P__-fab-out var(--__P__-dur-quick) var(--__P__-ease) forwards;pointer-events:none}:host([data-position^="top-"]) .__P__-fab[data-leaving]{bottom:auto;top:0}:host([data-position$="-left"]) .__P__-fab[data-leaving]{right:auto;left:0}@keyframes __P__-fab-out{0%{opacity:1;transform:none}to{opacity:0;transform:scale(.85)}}.__P__-fab[data-variant=circle]{width:var(--__P__-fab-size);height:var(--__P__-fab-size);border-radius:999px}.__P__-fab[data-variant=circle] .__P__-fab-label{display:none}.__P__-fab[data-variant=pill]{height:var(--__P__-fab-size);padding:0 18px 0 16px;border-radius:999px}.__P__-fab[data-variant=bar]{height:var(--__P__-fab-size);padding:0 22px;border-radius:var(--__P__-radius)}.__P__-fab[data-variant=minimal]{height:var(--__P__-fab-size);padding:0 var(--__P__-space-4);border-radius:999px;background:transparent;color:var(--__P__-accent-fg);box-shadow:none;border:1px solid currentColor}.__P__-fab[data-variant=minimal]:hover{background:color-mix(in srgb,var(--__P__-accent) 12%,transparent)}.__P__-callout{--__P__-callout-fab-h: var(--__P__-fab-size, 56px);--__P__-callout-gap: clamp(12px, calc(var(--__P__-callout-fab-h) * .25), 22px);--__P__-callout-nudge-direction: -1;position:absolute;display:inline-flex;align-items:center;gap:var(--__P__-space-2);padding:10px 14px;background:var(--__P__-fg);color:var(--__P__-bg);border-radius:999px;font-size:var(--__P__-text-sm);font-weight:600;line-height:1.2;box-shadow:0 10px 30px -8px #00000059;pointer-events:auto;animation:__P__-callout-in var(--__P__-dur-slow) var(--__P__-ease);z-index:1;max-width:240px;white-space:nowrap}.__P__-callout[data-position=left]{right:calc(100% + var(--__P__-callout-gap));bottom:calc(var(--__P__-callout-fab-h) / 2);transform:translateY(50%)}.__P__-callout[data-position=right]{left:calc(100% + var(--__P__-callout-gap));bottom:calc(var(--__P__-callout-fab-h) / 2);transform:translateY(50%);--__P__-callout-nudge-direction: 1}.__P__-callout[data-position=top]{bottom:calc(100% + var(--__P__-callout-gap));right:0;max-width:min(280px,calc(100vw - 32px))}.__P__-callout[data-position=bottom]{top:calc(100% + var(--__P__-callout-gap));right:0;max-width:min(280px,calc(100vw - 32px))}:host([data-position$="-left"]) .__P__-callout[data-position=top],:host([data-position$="-left"]) .__P__-callout[data-position=bottom]{right:auto;left:0}.__P__-callout[data-shape=bubble]{border-radius:var(--__P__-radius-md);white-space:normal;width:max-content;max-width:min(280px,calc(100vw - 32px))}.__P__-callout[data-shape=callout]{padding:12px 18px;font-size:calc(14px * var(--__P__-text-scale));background:var(--__P__-accent);color:var(--__P__-accent-text)}.__P__-callout:after{content:"";position:absolute;width:12px;height:12px;background:inherit;border-radius:2px;transform:rotate(45deg)}.__P__-callout[data-position=left]:after{right:-5px;top:50%;margin-top:-6px}.__P__-callout[data-position=right]:after{left:-5px;top:50%;margin-top:-6px}.__P__-callout[data-position=top]:after{bottom:-5px;right:calc(var(--__P__-fab-size, 56px) / 2 - 6px)}.__P__-callout[data-position=bottom]:after{top:-5px;right:calc(var(--__P__-fab-size, 56px) / 2 - 6px)}:host([data-position$="-left"]) .__P__-callout[data-position=top]:after,:host([data-position$="-left"]) .__P__-callout[data-position=bottom]:after{right:auto;left:calc(var(--__P__-fab-size, 56px) / 2 - 6px)}.__P__-callout[data-animated]{animation:__P__-callout-in var(--__P__-dur-slow) var(--__P__-ease),__P__-callout-nudge 1.6s var(--__P__-ease-in-out) var(--__P__-dur-slow) infinite}@keyframes __P__-callout-in{0%{opacity:0}to{opacity:1}}@keyframes __P__-callout-nudge{0%,to{margin-left:0;margin-right:0}50%{margin-left:calc(6px * var(--__P__-callout-nudge-direction));margin-right:calc(-6px * var(--__P__-callout-nudge-direction))}}@media(prefers-reduced-motion:reduce){.__P__-callout[data-animated]{animation:__P__-callout-in 1ms var(--__P__-ease)}.__P__-icon-btn[data-recording=true],.__P__-typing span{animation:none}}.__P__-callout-close{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;border-radius:999px;color:inherit;opacity:.7;cursor:pointer}.__P__-callout-close:hover{opacity:1;background:color-mix(in srgb,currentColor 15%,transparent)}.__P__-callout-close:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-callout-close svg{width:12px;height:12px}.__P__-panel{width:var(--__P__-panel-w);height:var(--__P__-panel-h);max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);background:var(--__P__-bg);color:var(--__P__-fg);border-radius:var(--__P__-radius-lg);box-shadow:var(--__P__-shadow-panel);display:flex;flex-direction:column;overflow:hidden;overflow:clip;overscroll-behavior:none;transform-origin:bottom right;animation:__P__-panel-in var(--__P__-dur-slow) var(--__P__-ease);border:1px solid var(--__P__-border)}@media(prefers-reduced-motion:no-preference){.__P__-panel{transition:width var(--__P__-dur-base) var(--__P__-ease),height var(--__P__-dur-base) var(--__P__-ease),max-width var(--__P__-dur-base) var(--__P__-ease),max-height var(--__P__-dur-base) var(--__P__-ease)}.__P__-panel[data-resizing]{transition:none}}:host([data-mode="open"]) .__P__-panel{width:var(--__P__-widget-w, var(--__P__-panel-w));height:var(--__P__-widget-h, var(--__P__-panel-h));min-width:var(--__P__-resize-min-w, auto);min-height:var(--__P__-resize-min-h, auto);max-width:var(--__P__-resize-max-w, calc(100vw - 32px) );max-height:var(--__P__-resize-max-h, calc(100dvh - 32px) )}@keyframes __P__-panel-in{0%{opacity:0;transform:translateY(8px) scale(.98)}to{opacity:1;transform:none}}:host([data-mode="expanded"]) .__P__-panel{width:var(--__P__-expanded-w, 640px);height:var(--__P__-expanded-h, 820px);max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px)}:host([data-mode="fullscreen"]){z-index:var(--__P__-z-panel)!important}:host([data-mode="fullscreen"]) .__P__-anchor{inset:var(--__P__-visual-viewport-top, 0px) 0 auto;height:var(--__P__-visual-viewport-height, 100dvh);padding:0;justify-content:flex-end;align-items:flex-end}:host([data-mode="fullscreen"][data-position*="top"]) .__P__-anchor{justify-content:flex-start}:host([data-mode="fullscreen"][data-position*="left"]) .__P__-anchor{align-items:flex-start}:host([data-mode="fullscreen"]) .__P__-panel{width:100vw;height:100%;max-width:none;max-height:none;border-radius:0;border:0}:host([data-mode="fullscreen"]) .__P__-fab{display:none}@media(max-width:640px){:host([data-mode="open"]) .__P__-anchor,:host([data-mode="expanded"]) .__P__-anchor{inset:var(--__P__-visual-viewport-top, 0px) 0 auto;align-items:stretch;height:var(--__P__-visual-viewport-height, 100dvh);padding:0}:host([data-mode="open"]) .__P__-panel,:host([data-mode="expanded"]) .__P__-panel{width:100vw;height:100%;max-width:none;max-height:none;border-radius:0;border:0}}:host([data-mode="inline"]) .__P__-anchor,:host([data-mode="standalone"]) .__P__-anchor{position:static;inset:auto;padding:0;align-items:stretch;width:100%;height:100%;min-height:0}:host([data-mode="inline"]) .__P__-panel,:host([data-mode="standalone"]) .__P__-panel{width:100%;height:100%;min-width:0;min-height:0;max-width:none;max-height:none;animation:none}:host([data-mode="inline"]) .__P__-fab,:host([data-mode="standalone"]) .__P__-fab{display:none}:host([data-mode="inline"]){min-height:320px}:host([data-mode="inline"]) .__P__-panel{border-radius:var(--__P__-radius)}:host([data-mode="standalone"]) .__P__-panel{border-radius:0;border:0;box-shadow:none}:host([data-mode="modal"]){position:fixed!important;inset:0!important;z-index:var(--__P__-z-panel)!important;display:block!important;width:100vw;height:100dvh;background:var(--__P__-modal-backdrop, var(--__P__-backdrop));animation:__P__-backdrop-in var(--__P__-dur-base) var(--__P__-ease) both;--__P__-panel-w: min(960px, 92vw);--__P__-panel-h: min(720px, 88dvh)}:host([data-mode="modal"]) .__P__-anchor{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:var(--__P__-space-6);pointer-events:none}:host([data-mode="modal"]) .__P__-panel{pointer-events:auto;width:var(--__P__-widget-w, var(--__P__-panel-w));height:var(--__P__-widget-h, var(--__P__-panel-h));max-width:calc(100vw - 48px);max-height:calc(100dvh - 48px);min-width:0;min-height:0;border-radius:var(--__P__-radius);box-shadow:var(--__P__-shadow-panel);animation:__P__-modal-in var(--__P__-dur-base) var(--__P__-ease);translate:var(--__P__-modal-dx, 0px) var(--__P__-modal-dy, 0px)}:host([data-mode="modal"]) .__P__-header,:host([data-mode="modal"]) .__P__-back-header,:host([data-mode="modal"]) .__P__-home-hero{cursor:grab;touch-action:none}:host([data-mode="modal"]) .__P__-panel[data-dragging]{cursor:grabbing;user-select:none}:host([data-mode="modal"]) .__P__-panel[data-dragging] *{cursor:grabbing}:host([data-mode="modal"]) .__P__-fab{display:none}@keyframes __P__-backdrop-in{0%{background:#0000}to{background:var(--__P__-modal-backdrop, var(--__P__-backdrop))}}@keyframes __P__-modal-in{0%{opacity:0;transform:translateY(8px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}:host([data-mode="drawer"]){--__P__-panel-w: min(440px, calc(100vw - 32px) );--__P__-panel-h: 100dvh}:host([data-mode="drawer"]) .__P__-anchor{position:fixed;--__P__-inset-x: var(--__P__-panel-inset, 12px);--__P__-inset-y: var(--__P__-panel-inset, 3dvh);top:var(--__P__-inset-y);bottom:auto;right:var(--__P__-inset-x);left:auto;width:min(var(--__P__-widget-w, var(--__P__-panel-w)),calc(100vw - var(--__P__-inset-x) * 2));height:min(var(--__P__-widget-h, var(--__P__-panel-h)),calc(100dvh - var(--__P__-inset-y) * 2));padding:0;display:block;pointer-events:auto}:host([data-mode="drawer"][data-position$="-left"]) .__P__-anchor{right:auto;left:var(--__P__-inset-x)}:host([data-mode="drawer"][data-position^="bottom-"]) .__P__-anchor{top:auto;bottom:var(--__P__-inset-y)}:host([data-mode="drawer"]) .__P__-panel{width:100%;height:100%;max-width:none;max-height:none;min-width:0;min-height:0;border-radius:var(--__P__-radius, 12px);border:1px solid var(--__P__-border);box-shadow:-8px 16px 32px -12px #00000038;animation:__P__-drawer-in var(--__P__-dur-base) var(--__P__-ease)}:host([data-mode="drawer"][data-position$="-left"]) .__P__-panel{box-shadow:8px 16px 32px -12px #00000038;animation:__P__-drawer-in-left var(--__P__-dur-base) var(--__P__-ease)}.__P__-fab[data-edge-tab]{display:inline-flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--__P__-space-2);position:fixed;top:50%;height:140px;width:auto;min-width:0;padding:10px 8px;writing-mode:vertical-rl;text-orientation:mixed;transform:translateY(-50%);transform-origin:center;animation:__P__-edge-tab-in var(--__P__-dur-base) var(--__P__-ease) both}.__P__-fab[data-edge-tab] svg{writing-mode:horizontal-tb}.__P__-fab[data-edge-tab]:hover{transform:translateY(-50%) scale(1.03)}.__P__-fab[data-edge-tab]:active{transform:translateY(-50%) scale(.97)}:host([data-position$="-right"]) .__P__-fab[data-edge-tab]{right:0;left:auto;border-radius:12px 0 0 12px;box-shadow:-6px 0 18px -8px #0000004d}:host([data-position$="-left"]) .__P__-fab[data-edge-tab]{left:0;right:auto;border-radius:0 12px 12px 0;box-shadow:6px 0 18px -8px #0000004d}.__P__-fab[data-edge-tab][data-leaving]{position:fixed;top:50%;bottom:auto;animation:__P__-edge-tab-out var(--__P__-dur-quick) var(--__P__-ease) forwards}@keyframes __P__-edge-tab-in{0%{opacity:0;transform:translateY(-50%) scale(.9)}to{opacity:1;transform:translateY(-50%) scale(1)}}@keyframes __P__-edge-tab-out{0%{opacity:1;transform:translateY(-50%) scale(1)}to{opacity:0;transform:translateY(-50%) scale(.85)}}@keyframes __P__-drawer-in{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes __P__-drawer-in-left{0%{transform:translate(-100%)}to{transform:translate(0)}}@media(prefers-reduced-motion:reduce){:host([data-mode="drawer"]) .__P__-panel,.__P__-fab[data-edge-tab]{animation:none}}.__P__-header{display:flex;align-items:center;gap:var(--__P__-space-2);padding:10px 12px;border-bottom:1px solid var(--__P__-border);background:var(--__P__-bg)}.__P__-header h1{font-size:calc(14px * var(--__P__-text-scale));font-weight:600;flex:1;letter-spacing:-.01em}.__P__-header-actions{margin-inline-start:auto;display:flex;align-items:center;gap:var(--__P__-space-1);flex-shrink:0}.__P__-agent{flex:1;display:inline-flex;align-items:center;gap:10px;min-width:0}.__P__-agent-avatar{position:relative;width:32px;height:32px;border-radius:var(--__P__-radius-md);background:var(--__P__-bg-elevated);color:var(--__P__-fg-muted);display:inline-flex;align-items:center;justify-content:center;font-weight:700;font-size:var(--__P__-text-xs);flex-shrink:0}.__P__-agent-avatar img{width:100%;height:100%;border-radius:inherit;object-fit:cover}.__P__-agent-avatar:after{content:"";position:absolute;right:-1px;bottom:-1px;width:10px;height:10px;border-radius:999px;border:2px solid var(--__P__-bg);background:var(--__P__-neutral)}.__P__-agent-avatar[data-status=online]:after{background:var(--__P__-success)}.__P__-agent-avatar[data-status=away]:after{background:var(--__P__-warning)}.__P__-agent-avatar[data-status=offline]:after{background:var(--__P__-neutral)}.__P__-agent-meta{display:flex;flex-direction:column;line-height:1.15;min-width:0}.__P__-agent-meta strong{font-size:calc(14px * var(--__P__-text-scale));font-weight:600;letter-spacing:-.01em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-agent-meta span{font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-suggestions{display:flex;flex-wrap:nowrap;gap:var(--__P__-space-2);padding:6px 14px 10px;overflow-x:auto;overflow-y:hidden;scroll-behavior:smooth;scroll-snap-type:x proximity;scrollbar-width:none;-ms-overflow-style:none;min-width:0}.__P__-suggestions::-webkit-scrollbar{display:none}.__P__-suggestions[data-cut-end=true]{mask-image:linear-gradient(to right,#000 calc(100% - 32px),transparent)}.__P__-suggestions[data-cut-start=true]{mask-image:linear-gradient(to right,transparent,#000 32px)}.__P__-suggestions[data-cut-start=true][data-cut-end=true]{mask-image:linear-gradient(to right,transparent,#000 32px,#000 calc(100% - 32px),transparent)}:host([dir="rtl"]) .__P__-suggestions[data-cut-end=true]{mask-image:linear-gradient(to left,#000 calc(100% - 32px),transparent)}:host([dir="rtl"]) .__P__-suggestions[data-cut-start=true]{mask-image:linear-gradient(to left,transparent,#000 32px)}:host([dir="rtl"]) .__P__-suggestions[data-cut-start=true][data-cut-end=true]{mask-image:linear-gradient(to left,transparent,#000 32px,#000 calc(100% - 32px),transparent)}.__P__-suggestions:before,.__P__-suggestions:after{content:"";flex:1 1 0;min-width:0}.__P__-suggestion{flex:0 0 auto;scroll-snap-align:center;padding:7px 14px;border-radius:999px;background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);color:var(--__P__-fg);font-size:var(--__P__-text-sm);font-weight:500;white-space:nowrap;transition:background var(--__P__-dur-quick) var(--__P__-ease),border-color var(--__P__-dur-quick) var(--__P__-ease),transform var(--__P__-dur-quick) var(--__P__-ease)}.__P__-suggestion:hover{border-color:var(--__P__-accent);color:var(--__P__-accent-fg);transform:translateY(-1px)}.__P__-suggestion:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px;border-color:var(--__P__-accent)}.__P__-suggestion:active{transform:translateY(0)}.__P__-icon-btn{width:32px;height:32px;border-radius:999px;position:relative;display:inline-flex;align-items:center;justify-content:center;color:var(--__P__-fg-muted);transition:background var(--__P__-dur-quick) var(--__P__-ease),color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-icon-btn:hover{background:var(--__P__-bg-elevated);color:var(--__P__-fg)}.__P__-icon-btn:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-icon-btn:active{background:var(--__P__-border)}.__P__-icon-btn:disabled{opacity:.45;cursor:not-allowed}.__P__-icon-btn:before{content:"";position:absolute;inset:-6px}.__P__-icon-btn svg{width:18px;height:18px}.__P__-icon-btn[data-recording=true]{color:var(--__P__-accent-fg);background:color-mix(in srgb,var(--__P__-accent) 12%,transparent);animation:__P__-pulse 1.2s var(--__P__-ease) infinite}@keyframes __P__-pulse{0%,to{box-shadow:0 0 color-mix(in srgb,var(--__P__-accent) 40%,transparent)}50%{box-shadow:0 0 0 6px color-mix(in srgb,var(--__P__-accent) 0%,transparent)}}.__P__-list,.__P__-history,.__P__-module-scroll,.__P__-home-scroll,.__P__-help-list,.__P__-toolui-code,.__P__-sidebar-conversations{scrollbar-width:thin;scrollbar-color:var(--__P__-border-strong) transparent;overscroll-behavior:contain;scrollbar-gutter:stable}.__P__-list::-webkit-scrollbar,.__P__-history::-webkit-scrollbar,.__P__-module-scroll::-webkit-scrollbar,.__P__-home-scroll::-webkit-scrollbar,.__P__-help-list::-webkit-scrollbar,.__P__-toolui-code::-webkit-scrollbar,.__P__-sidebar-conversations::-webkit-scrollbar{width:8px}.__P__-list::-webkit-scrollbar-thumb,.__P__-history::-webkit-scrollbar-thumb,.__P__-module-scroll::-webkit-scrollbar-thumb,.__P__-home-scroll::-webkit-scrollbar-thumb,.__P__-help-list::-webkit-scrollbar-thumb,.__P__-toolui-code::-webkit-scrollbar-thumb,.__P__-sidebar-conversations::-webkit-scrollbar-thumb{background:var(--__P__-border-strong);border-radius:8px}.__P__-list-wrap{position:relative;flex:1;min-height:0;display:flex;flex-direction:column}.__P__-jump{position:absolute;inset-inline:0;bottom:14px;z-index:2;margin-inline:auto;display:flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:999px;border:1px solid var(--__P__-border);background:var(--__P__-bg-elevated);color:var(--__P__-fg);box-shadow:var(--__P__-shadow-panel);cursor:pointer;opacity:.85;transition:opacity var(--__P__-dur-quick) var(--__P__-ease),transform var(--__P__-dur-quick) var(--__P__-ease);animation:__P__-bubble-in var(--__P__-dur-base) var(--__P__-ease)}.__P__-jump:hover{opacity:1}.__P__-jump:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;opacity:1}.__P__-jump:active{transform:translateY(1px)}.__P__-jump svg{width:18px;height:18px}.__P__-list{flex:1;min-height:0;overflow-y:auto;padding:var(--__P__-space-4);padding-bottom:var(--__P__-space-8);display:flex;flex-direction:column;gap:14px}.__P__-list--fade{--__P__-fade-size: 20px;--__P__-fade-top: 0px;--__P__-fade-bottom: 0px;-webkit-mask-image:linear-gradient(to bottom,transparent 0,#000 var(--__P__-fade-top),#000 calc(100% - var(--__P__-fade-bottom)),transparent 100%);mask-image:linear-gradient(to bottom,transparent 0,#000 var(--__P__-fade-top),#000 calc(100% - var(--__P__-fade-bottom)),transparent 100%)}.__P__-list--fade[data-fade-top=true]{--__P__-fade-top: var(--__P__-fade-size)}.__P__-list--fade[data-fade-bottom=true]{--__P__-fade-bottom: var(--__P__-fade-size)}.__P__-list>*{width:100%;max-width:var(--__P__-conversation-max, 768px);margin-inline:auto}.__P__-load-previous,.__P__-history-more{display:flex;justify-content:center}.__P__-load-previous button,.__P__-history-more button{border:0;padding:4px 8px;background:transparent;color:var(--__P__-accent);font:inherit;font-size:var(--__P__-text-sm);font-weight:600;cursor:pointer}.__P__-load-previous button:hover,.__P__-history-more button:hover{text-decoration:underline}.__P__-load-previous button:focus-visible,.__P__-history-more button:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;border-radius:var(--__P__-radius-sm)}.__P__-load-previous button:disabled,.__P__-history-more button:disabled{cursor:wait;opacity:.6}.__P__-date-divider{display:flex;justify-content:center;margin-block:var(--__P__-space-3)}.__P__-date-pill{padding:3px 10px;border-radius:999px;font-size:calc(11px * var(--__P__-text-scale));font-weight:600;color:var(--__P__-fg-muted);background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);box-shadow:var(--__P__-shadow-card)}.__P__-bubble-row{display:flex}.__P__-bubble-row[data-role=user]{justify-content:flex-end}.__P__-bubble-row[data-role=assistant]{justify-content:flex-start}.__P__-bubble{max-width:100%;min-width:0;padding:var(--__P__-space-3) var(--__P__-space-4);border-radius:var(--__P__-radius);line-height:1.6;font-size:calc(14px * var(--__P__-text-scale));word-wrap:break-word;overflow-wrap:break-word;box-shadow:0 1px 2px #0000000a,0 1px 8px -4px #0000000f;animation:__P__-bubble-in var(--__P__-dur-base) var(--__P__-ease)}.__P__-bubble ::selection{background:color-mix(in srgb,var(--__P__-accent) 30%,transparent)}.__P__-bubble-row[data-role=user] .__P__-bubble ::selection{background:#fff6;color:var(--__P__-bubble-user-text)}@keyframes __P__-bubble-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}.__P__-bubble-row[data-role=user] .__P__-bubble{background:var(--__P__-bubble-user);color:var(--__P__-bubble-user-text);border-end-end-radius:5px}.__P__-bubble-row[data-role=assistant] .__P__-bubble{background:var(--__P__-bubble-assistant);color:var(--__P__-bubble-assistant-text);border:1px solid var(--__P__-border);border-end-start-radius:5px}.__P__-bubble-row[data-role=operator] .__P__-bubble{display:flex;align-items:stretch;padding:0;overflow:hidden;background:var(--__P__-bubble-assistant);color:var(--__P__-bubble-assistant-text);border-end-start-radius:5px}.__P__-bubble-row[data-role=operator] .__P__-bubble-col{align-items:flex-start}.__P__-bubble-author{display:flex;flex:0 0 auto;align-items:center;padding:0 .875rem;border-inline-end:1px solid color-mix(in oklab,var(--__P__-accent),transparent 60%);color:var(--__P__-accent);font-size:calc(13px * var(--__P__-text-scale));font-weight:600;letter-spacing:.025em;user-select:none}.__P__-bubble-body{display:flex;flex-wrap:wrap;align-items:flex-start;gap:var(--__P__-space-3) 6px;min-width:0}.__P__-bubble-body>*{flex:1 0 100%;min-width:0}.__P__-bubble-body>.__P__-source,.__P__-bubble-body>.__P__-typing{flex:0 1 auto}.__P__-bubble-row[data-role=operator] .__P__-bubble-body{flex:1 1 auto;min-width:0;padding:var(--__P__-space-3) var(--__P__-space-4)}.__P__-bubble-col{display:flex;flex-direction:column;max-width:85%;min-width:0}.__P__-bubble-row[data-role=user] .__P__-bubble-col{align-items:flex-end}.__P__-bubble-row[data-role=assistant] .__P__-bubble-col{align-items:flex-start}.__P__-bubble-row[data-role=assistant] .__P__-bubble-col:has(.__P__-toolui,.__P__-steps){width:100%}.__P__-bubble-row[data-role=assistant] .__P__-bubble-col:has(.__P__-toolui,.__P__-steps) .__P__-bubble{width:100%}@media(max-width:640px){.__P__-bubble-col{max-width:92%}.__P__-toolui:not(.__P__-toolui-collapsible){padding:var(--__P__-space-3);gap:var(--__P__-space-2)}details.__P__-toolui-collapsible>summary{padding:var(--__P__-space-2) var(--__P__-space-3)}details.__P__-toolui-collapsible>.__P__-toolui-section{margin:var(--__P__-space-3)}.__P__-toolui-section,.__P__-toolui-desc{padding:var(--__P__-space-2) var(--__P__-space-3)}}.__P__-bubble-meta{display:flex;align-items:center;gap:8px;margin-top:2px;padding:0 2px;min-height:24px}.__P__-bubble-actions{display:flex;align-items:center;gap:2px}.__P__-bubble-time{font-size:calc(11px * var(--__P__-text-scale));line-height:1;color:var(--__P__-fg-muted);user-select:none}.__P__-feedback{display:flex;align-items:center;gap:2px}.__P__-msg-action{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;border:0;border-radius:var(--__P__-radius-sm);background:transparent;color:var(--__P__-fg-muted);cursor:pointer;opacity:.65;transition:opacity var(--__P__-dur-quick) var(--__P__-ease),background var(--__P__-dur-quick) var(--__P__-ease),color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-msg-action:hover{opacity:1;background:var(--__P__-bg-elevated);color:var(--__P__-fg)}.__P__-msg-action:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;opacity:1}.__P__-msg-action[data-active=true]{opacity:1;color:var(--__P__-accent-fg)}.__P__-msg-action svg{width:15px;height:15px}.__P__-md>*:first-child{margin-top:0}.__P__-md>*:last-child{margin-bottom:0}.__P__-md p{margin:10px 0}.__P__-md h1,.__P__-md h2,.__P__-md h3,.__P__-md h4,.__P__-md h5,.__P__-md h6{margin:18px 0 8px;line-height:1.3;letter-spacing:-.01em;font-weight:700}.__P__-md h1{font-size:1.4em}.__P__-md h2{font-size:1.22em}.__P__-md h3{font-size:1.08em}.__P__-md h4,.__P__-md h5,.__P__-md h6{font-size:1em}.__P__-md>h1:first-child,.__P__-md>h2:first-child,.__P__-md>h3:first-child,.__P__-md>h4:first-child,.__P__-md>h5:first-child,.__P__-md>h6:first-child{margin-top:0}.__P__-md ul,.__P__-md ol{padding-inline-start:1.5em;margin:10px 0}.__P__-md ul{list-style:disc}.__P__-md ol{list-style:decimal}.__P__-md li{margin:6px 0;padding-inline-start:2px}.__P__-md li::marker{color:var(--__P__-fg-muted)}.__P__-md li>p{margin:6px 0}.__P__-md li>ul,.__P__-md li>ol{margin:6px 0}.__P__-md strong,.__P__-md b{font-weight:650;letter-spacing:-.005em}.__P__-md em,.__P__-md i{font-style:italic}.__P__-md code{font-family:var(--__P__-font-mono);font-size:.86em;padding:1px 6px;border-radius:5px;background:color-mix(in srgb,var(--__P__-accent) 10%,transparent);color:var(--__P__-fg);border:1px solid color-mix(in srgb,var(--__P__-accent) 16%,transparent)}.__P__-md pre{font-family:var(--__P__-font-mono);font-size:calc(12.5px * var(--__P__-text-scale));padding:12px 14px;border-radius:var(--__P__-radius-sm);background:#7f7f7f1f;overflow-x:auto;margin:var(--__P__-space-3) 0;line-height:1.5}.__P__-md pre code{padding:0;background:none}.__P__-file-image,.__P__-file-chip{border-radius:var(--__P__-radius-sm);color:inherit;text-decoration:none}.__P__-file-image{display:block;width:fit-content;max-width:min(100%,240px);overflow:hidden}.__P__-file-image img{max-height:240px;object-fit:cover}.__P__-file-chip{display:flex;align-items:center;gap:var(--__P__-space-2);max-width:min(100%,280px);padding:var(--__P__-space-2);border:1px solid color-mix(in srgb,currentColor 18%,transparent);background:color-mix(in srgb,currentColor 5%,transparent);transition:background var(--__P__-dur-base) var(--__P__-ease)}.__P__-file-chip:hover{background:color-mix(in srgb,currentColor 10%,transparent)}.__P__-file-image:focus-visible,.__P__-file-chip:focus-visible{outline:2px solid currentColor;outline-offset:2px}.__P__-file-chip-icon{flex:none;display:grid;place-items:center;width:32px;height:32px;border-radius:var(--__P__-radius-sm);background:color-mix(in srgb,currentColor 10%,transparent)}.__P__-file-chip-text{display:grid;min-width:0;line-height:1.35}.__P__-file-chip-name{font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.__P__-file-chip-meta{font-size:var(--__P__-text-xs);opacity:.75}.__P__-md a{color:inherit;text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:2px}.__P__-md a:hover{text-decoration-thickness:2px}.__P__-md blockquote{margin:14px 0;padding:6px 14px;border-inline-start:3px solid color-mix(in srgb,var(--__P__-accent) 50%,transparent);background:color-mix(in srgb,var(--__P__-accent) 5%,transparent);border-start-end-radius:var(--__P__-radius-sm);border-end-end-radius:var(--__P__-radius-sm);color:var(--__P__-fg-muted)}.__P__-md blockquote>:first-child{margin-top:0}.__P__-md blockquote>:last-child{margin-bottom:0}.__P__-md hr{border:0;height:1px;background:color-mix(in srgb,currentColor 18%,transparent);margin:var(--__P__-space-4) 0}.__P__-md table{border-collapse:collapse;margin:var(--__P__-space-3) 0;font-size:.95em;display:block;overflow-x:auto;max-width:100%;font-variant-numeric:tabular-nums}.__P__-md th,.__P__-md td{padding:6px 10px;border-bottom:1px solid color-mix(in srgb,currentColor 12%,transparent);text-align:start}.__P__-md th{font-weight:700;background:color-mix(in srgb,currentColor 6%,transparent)}.__P__-md h1+ul,.__P__-md h1+ol,.__P__-md h2+ul,.__P__-md h2+ol,.__P__-md h3+ul,.__P__-md h3+ol,.__P__-md h4+ul,.__P__-md h4+ol{margin-top:var(--__P__-space-1)}.__P__-loading{display:inline-flex;align-items:center;gap:var(--__P__-space-2);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm)}.__P__-loading-spinner{width:14px;height:14px;border-radius:999px;border:2px solid currentColor;border-top-color:transparent;animation:__P__-spin .8s linear infinite}@keyframes __P__-spin{to{transform:rotate(1turn)}}.__P__-typing{display:inline-flex;gap:var(--__P__-space-1);padding:var(--__P__-space-1) 0}.__P__-typing span{width:5px;height:5px;border-radius:999px;background:currentColor;opacity:.4;animation:__P__-blink 1.2s var(--__P__-ease) infinite}.__P__-typing span:nth-child(2){animation-delay:.2s}.__P__-typing span:nth-child(3){animation-delay:.4s}@keyframes __P__-blink{0%,80%,to{opacity:.3;transform:translateY(0)}40%{opacity:1;transform:translateY(-2px)}}.__P__-steps{min-width:0;font-size:var(--__P__-text-sm)}.__P__-steps-head,.__P__-steps-row-head,.__P__-steps-thought-more{display:inline-flex;align-items:center;gap:var(--__P__-space-2);max-width:100%;min-width:0;min-height:28px;padding:0;border:0;background:none;color:var(--__P__-fg-muted);font:inherit;text-align:start;cursor:pointer;-webkit-tap-highlight-color:transparent}.__P__-steps-head:hover,.__P__-steps-row-head:hover,.__P__-steps-thought-more:hover{color:var(--__P__-fg)}.__P__-steps-head:focus-visible,.__P__-steps-row-head:focus-visible,.__P__-steps-thought-toggle:focus-visible,.__P__-steps-thought-more:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;border-radius:var(--__P__-radius-sm)}.__P__-steps-icon,.__P__-steps-row-icon{display:inline-flex;flex:none;align-items:center;justify-content:center;width:16px;height:16px}.__P__-steps-icon svg,.__P__-steps-row-icon svg{width:14px;height:14px}.__P__-steps-label,.__P__-steps-row-label{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-steps-sep{margin-inline:var(--__P__-space-1)}.__P__-steps-name .__P__-steps-count{margin-inline-start:var(--__P__-space-1)}.__P__-steps-count,.__P__-steps-failed,.__P__-steps-denied,.__P__-steps-time{flex:none;font-variant-numeric:tabular-nums}.__P__-steps-failed{color:var(--__P__-danger-text)}.__P__-steps-denied{color:var(--__P__-fg-muted)}.__P__-steps-chevron{display:inline-flex;flex:none;width:16px;height:16px;transition:transform var(--__P__-dur-quick) var(--__P__-ease)}.__P__-steps-chevron svg{width:16px;height:16px}.__P__-steps-chevron[data-open=true]{transform:rotate(180deg)}.__P__-steps-list{position:relative;display:flex;flex-direction:column;gap:var(--__P__-space-1);margin:var(--__P__-space-1) 0 0;padding:0;list-style:none}.__P__-steps-list:before{content:"";position:absolute;inset-block:0;inset-inline-start:7px;width:2px;border-radius:1px;background:var(--__P__-border)}.__P__-steps-row{position:relative;display:grid;grid-template-columns:16px minmax(0,1fr);column-gap:var(--__P__-space-2);align-items:start}.__P__-steps-row .__P__-steps-row-icon{margin-block:6px;border-radius:999px;background:var(--__P__-bubble-assistant);color:var(--__P__-fg-muted)}.__P__-steps-row[data-status=error] .__P__-steps-row-icon{color:var(--__P__-danger-text)}.__P__-steps-row-main{display:flex;flex-direction:column;align-items:flex-start;min-width:0}.__P__-steps-row-name{color:var(--__P__-fg);font-weight:500}.__P__-steps-row-summary{margin-inline-start:var(--__P__-space-2);color:var(--__P__-fg-muted)}.__P__-steps-row-body{display:flex;flex-direction:column;gap:var(--__P__-space-2);width:100%;margin:var(--__P__-space-1) 0 var(--__P__-space-2)}.__P__-steps-body{display:grid;grid-template-rows:0fr;transition:grid-template-rows .2s ease-out}.__P__-steps-body[data-open=true]{grid-template-rows:1fr}.__P__-steps-body-inner{min-height:0;overflow:hidden}.__P__-steps-live{min-width:0;overflow:hidden;text-overflow:ellipsis;background:linear-gradient(90deg,var(--__P__-fg-muted) 0%,var(--__P__-fg) 50%,var(--__P__-fg-muted) 100%) 0 0 / 200% 100%;background-clip:text;-webkit-background-clip:text;color:transparent;animation:__P__-steps-shimmer 2s linear infinite}@keyframes __P__-steps-shimmer{to{background-position:-200% 0}}@media(prefers-reduced-motion:reduce){.__P__-steps-body,.__P__-steps-chevron{transition:none}.__P__-steps-live{background:none;color:var(--__P__-fg-muted);animation:none}}.__P__-steps-thought-label,.__P__-steps-stopped-label{display:inline-flex;align-items:center;min-height:28px;color:var(--__P__-fg-muted)}.__P__-steps-thought-text{width:100%;color:var(--__P__-fg-muted)}.__P__-steps-thought-text[data-clamped=true]{max-height:calc(3 * 1.6em);overflow:hidden;mask-image:linear-gradient(to bottom,#000 60%,transparent);cursor:pointer}.__P__-steps-thought-toggle{padding:0;border:0;background:none;font:inherit;text-align:start;cursor:pointer}.__P__-steps-thought-toggle:hover{color:var(--__P__-fg)}.__P__-steps-thought-more{min-height:24px;font-size:var(--__P__-text-xs)}.__P__-reasoning-body{color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm)}.__P__-reasoning-body>:first-child{margin-top:0}.__P__-reasoning-body>:last-child{margin-bottom:0}.__P__-source{display:inline-flex;align-items:center;gap:6px;max-width:100%;padding:var(--__P__-space-1) var(--__P__-space-2);border-radius:999px;background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);text-decoration:none}a.__P__-source:hover{color:var(--__P__-fg);border-color:var(--__P__-accent)}.__P__-source-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-composer{border-top:1px solid var(--__P__-border);padding:10px 12px;background:var(--__P__-bg);display:flex;flex-direction:column;gap:var(--__P__-space-2)}.__P__-composer>*{width:100%;max-width:var(--__P__-conversation-max, 768px);margin-inline:auto}.__P__-compaction-status{width:100%;padding:10px 14px;justify-content:center;font-size:var(--__P__-text-xs)}.__P__-message-queue{display:flex;max-height:112px;flex-direction:column;gap:var(--__P__-space-1);overflow-y:auto}.__P__-attachment-chip.__P__-queued-message{width:100%;max-width:none}.__P__-queued-text{min-width:0;flex:1}.__P__-composer-row{display:flex;align-items:flex-end;gap:6px}.__P__-textarea{flex:1;--__P__-textarea-base-height: 40px;height:var(--__P__-textarea-base-height);max-height:160px;padding:10px 12px;border-radius:var(--__P__-radius);background:var(--__P__-bg-elevated);border:1px solid transparent;font-size:calc(14px * var(--__P__-text-scale));line-height:1.4;transition:height var(--__P__-dur-quick) var(--__P__-ease),border-color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-textarea:focus-visible{outline:none;border-color:var(--__P__-focus)}@media(pointer:coarse){.__P__-textarea{--__P__-textarea-base-height: 44px}}.__P__-send{width:40px;height:40px;display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;transition:opacity var(--__P__-dur-quick) var(--__P__-ease),transform var(--__P__-dur-quick) var(--__P__-ease),background var(--__P__-dur-quick) var(--__P__-ease)}.__P__-send[data-shape=circle]{border-radius:999px}.__P__-send[data-shape=square]{border-radius:var(--__P__-radius-sm)}.__P__-send[data-shape=pill]{width:auto;padding:0 18px;border-radius:999px}.__P__-send[data-variant=filled]{background:var(--__P__-accent);color:var(--__P__-accent-text)}.__P__-send[data-variant=outline]{background:transparent;color:var(--__P__-accent-fg);border-color:var(--__P__-accent)}.__P__-send[data-variant=outline]:not(:disabled):hover{background:color-mix(in srgb,var(--__P__-accent) 10%,transparent)}.__P__-send[data-variant=ghost]{background:transparent;color:var(--__P__-accent-fg)}.__P__-send[data-variant=ghost]:not(:disabled):hover{background:color-mix(in srgb,var(--__P__-accent) 8%,transparent)}.__P__-send:disabled{opacity:.4;cursor:not-allowed}.__P__-send:not(:disabled):hover{transform:translateY(-1px)}.__P__-send:not(:disabled):active{transform:translateY(0)}.__P__-send:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-send svg{width:18px;height:18px}.__P__-composer-actions{display:flex;gap:var(--__P__-space-1);flex-wrap:wrap}.__P__-attachments{display:flex;flex-wrap:wrap;gap:6px}.__P__-attachment-chip{display:inline-flex;align-items:center;gap:6px;padding:var(--__P__-space-1) var(--__P__-space-2) var(--__P__-space-1) var(--__P__-space-1);border-radius:999px;background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);font-size:var(--__P__-text-xs);max-width:200px}.__P__-attachment-thumb{width:24px;height:24px;border-radius:999px;object-fit:cover;background:var(--__P__-border)}.__P__-attachment-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.__P__-attachment-remove{width:18px;height:18px;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;color:var(--__P__-fg-muted)}.__P__-attachment-remove:hover{background:var(--__P__-border);color:var(--__P__-fg)}.__P__-dropzone{position:absolute;inset:8px;border:2px dashed var(--__P__-accent);border-radius:var(--__P__-radius);background:color-mix(in srgb,var(--__P__-accent) 8%,transparent);display:flex;align-items:center;justify-content:center;font-weight:600;color:var(--__P__-accent-fg);pointer-events:none;z-index:10;animation:__P__-fade-in var(--__P__-dur-quick) var(--__P__-ease)}@keyframes __P__-fade-in{0%{opacity:0}to{opacity:1}}.__P__-error{display:flex;align-items:center;gap:var(--__P__-space-2);padding:8px 12px;border-radius:var(--__P__-radius-sm);background:color-mix(in oklab,var(--__P__-danger) 8%,var(--__P__-bg-elevated));border:1px solid color-mix(in oklab,var(--__P__-danger) 20%,transparent);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm)}.__P__-error-icon{display:inline-flex;flex:none;width:16px;height:16px;color:var(--__P__-danger-text)}.__P__-error-icon svg{width:16px;height:16px}.__P__-error-text{min-width:0}.__P__-error-retry{flex:none;margin-inline-start:auto;min-height:28px;border:0;background:none;padding:0;color:var(--__P__-accent-fg);font:inherit;font-size:var(--__P__-text-sm);font-weight:600;text-decoration:underline;white-space:nowrap;cursor:pointer}.__P__-error-retry:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;border-radius:var(--__P__-radius-sm)}.__P__-history{flex:1;overflow-y:auto;padding:var(--__P__-space-2) var(--__P__-space-1) var(--__P__-space-3)}.__P__-history-footer{flex:none;padding:var(--__P__-space-2) var(--__P__-space-3) var(--__P__-space-3);border-top:1px solid var(--__P__-border);background:var(--__P__-surface)}.__P__-history-new{width:100%;display:flex;align-items:center;justify-content:center;gap:var(--__P__-space-2);padding:var(--__P__-space-2) var(--__P__-space-3);border:none;border-radius:var(--__P__-radius-md);background:var(--__P__-accent);color:var(--__P__-on-accent);cursor:pointer;font-size:var(--__P__-text-sm);font-weight:600;transition:filter var(--__P__-dur-quick) var(--__P__-ease-out),transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-history-new svg{width:16px;height:16px}.__P__-history-new:hover{filter:brightness(1.08)}.__P__-history-new:active{transform:translateY(1px)}.__P__-history-new:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-history-empty{flex:1;display:flex;align-items:center;justify-content:center;padding:40px 16px;color:var(--__P__-fg-muted);font-size:calc(14px * var(--__P__-text-scale));text-align:center}.__P__-history-group{display:flex;flex-direction:column;padding:0 var(--__P__-space-3)}.__P__-history-heading{font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted);padding:14px 4px 8px;text-transform:uppercase;letter-spacing:.04em}.__P__-history-card{display:flex;flex-direction:column;background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-lg, 14px);overflow:hidden}.__P__-history-card>[role=listitem]{display:flex;flex-direction:column}.__P__-history-item{all:unset;display:flex;align-items:center;gap:var(--__P__-space-3);padding:12px var(--__P__-space-3);cursor:pointer;transition:background var(--__P__-dur-base) var(--__P__-ease)}.__P__-history-card>*+*{border-top:1px solid var(--__P__-border)}.__P__-history-item:hover{background:var(--__P__-bg-elevated)}.__P__-history-item:focus-visible{background:var(--__P__-bg-elevated);outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-history-avatar{flex:none;display:grid;place-items:center;width:36px;height:36px;border-radius:var(--__P__-radius-md);background:color-mix(in oklab,var(--__P__-accent) 12%,transparent);color:var(--__P__-accent-fg)}.__P__-history-avatar svg{width:18px;height:18px}.__P__-history-body{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.__P__-history-row{display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-2)}.__P__-history-title{flex:1;min-width:0;font-size:calc(14px * var(--__P__-text-scale));font-weight:500;color:var(--__P__-fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-history-time{flex:none;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted)}.__P__-history-preview{flex:1;min-width:0;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-history-dot{flex:none;width:8px;height:8px;border-radius:50%;background:var(--__P__-accent)}.__P__-history-item[data-unread=true] .__P__-history-title{font-weight:600}.__P__-history-item[data-closed=true] .__P__-history-title{color:var(--__P__-fg-muted)}.__P__-history-item-skeleton{cursor:default;pointer-events:none}.__P__-skeleton{display:block;border-radius:4px;background:linear-gradient(90deg,color-mix(in oklab,var(--__P__-fg) 9%,transparent) 30%,color-mix(in oklab,var(--__P__-fg) 17%,transparent),color-mix(in oklab,var(--__P__-fg) 9%,transparent) 70%);background-size:200% 100%;animation:__P__-skeleton-shimmer 1.8s ease-in-out infinite}.__P__-history-avatar.__P__-skeleton{border-radius:var(--__P__-radius-md)}.__P__-skeleton-heading{width:52px;height:8px}.__P__-skeleton-title{width:55%;height:12px}.__P__-skeleton-time{width:34px;height:10px}.__P__-skeleton-preview{width:80%;height:10px}@keyframes __P__-skeleton-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@media(prefers-reduced-motion:reduce){.__P__-skeleton{animation:none}}.__P__-list-loading{margin:auto;padding:var(--__P__-space-6) var(--__P__-space-4);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);text-align:center}.__P__-readonly-banner{display:flex;flex-direction:column;align-items:center;gap:10px;padding:14px 12px;margin:0 var(--__P__-space-3) var(--__P__-space-3);border-radius:var(--__P__-radius-md);background:var(--__P__-bg-elevated);color:var(--__P__-fg-muted);text-align:center;font-size:var(--__P__-text-sm)}.__P__-readonly-label{line-height:1.4}.__P__-readonly-cta{appearance:none;border:0;cursor:pointer;padding:var(--__P__-space-2) var(--__P__-space-4);border-radius:999px;background:var(--__P__-accent);color:var(--__P__-accent-text, #fff);font:inherit;font-weight:600;font-size:var(--__P__-text-sm);transition:filter var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-readonly-cta:hover,.__P__-readonly-cta:focus-visible{filter:brightness(1.1)}.__P__-operator-banner{display:flex;align-items:center;justify-content:center;gap:8px;margin:0 var(--__P__-space-3) var(--__P__-space-1);padding:8px 12px;border-radius:var(--__P__-radius-md);background:color-mix(in oklab,var(--__P__-bg-elevated),var(--__P__-accent) 6%);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);line-height:1.3;text-align:center}.__P__-operator-pulse{flex:0 0 auto;width:8px;height:8px;border-radius:50%;background:var(--__P__-accent)}.__P__-operator-banner[data-mode=awaiting-operator] .__P__-operator-pulse{animation:__P__-operator-pulse 1.4s var(--__P__-ease-out) infinite}.__P__-cancel-operator-request{flex:0 0 auto;padding:0;border:0;background:none;color:var(--__P__-accent);font:inherit;font-weight:600;text-decoration:underline;text-underline-offset:2px;cursor:pointer}.__P__-cancel-operator-request:hover{opacity:.8}.__P__-cancel-operator-request:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px;border-radius:var(--__P__-radius-sm)}@keyframes __P__-operator-pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.4;transform:scale(.7)}}.__P__-readonly-cta:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px}.__P__-composer-footer{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;padding:10px 16px;margin:0 var(--__P__-space-3);border-top:1px solid var(--__P__-border);text-align:center;font-size:calc(11px * var(--__P__-text-scale));line-height:1.4;color:var(--__P__-fg-muted)}.__P__-disclaimer{max-width:320px;margin:0 auto;opacity:.9;letter-spacing:.01em}.__P__-poweredby{display:inline-flex;align-items:center;justify-content:center;gap:6px;color:inherit;text-decoration:none;opacity:.7;transition:opacity var(--__P__-dur-base) var(--__P__-ease);font-size:calc(11px * var(--__P__-text-scale));letter-spacing:.02em}.__P__-poweredby:hover{opacity:1}.__P__-poweredby-logo{height:12px;width:auto;display:inline-block;vertical-align:middle}.__P__-poweredby-bar{flex:none;display:flex;align-items:center;justify-content:center;padding:6px 16px;border-top:1px solid var(--__P__-border);background:var(--__P__-bg-elevated)}.__P__-menu-wrap{position:relative;display:inline-flex}.__P__-menu{position:absolute;top:100%;inset-inline-end:0;margin-top:6px;min-width:200px;padding:6px;background:var(--__P__-bg);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);box-shadow:var(--__P__-shadow-panel);z-index:10;display:flex;flex-direction:column;gap:2px;animation:__P__-menu-in var(--__P__-dur-base) var(--__P__-ease)}@media(prefers-reduced-motion:reduce){.__P__-menu{animation:none}}@keyframes __P__-menu-in{0%{opacity:0;transform:translateY(-4px) scale(.98);transform-origin:top right}to{opacity:1;transform:none}}.__P__-menu-item{all:unset;display:flex;align-items:center;gap:10px;padding:8px 10px;font-size:var(--__P__-text-sm);color:var(--__P__-fg);border-radius:var(--__P__-radius-sm);cursor:pointer;user-select:none}.__P__-menu-item:hover{background:var(--__P__-bg-elevated)}.__P__-menu-item:focus-visible{background:var(--__P__-bg-elevated);outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-menu-item[disabled]{opacity:.45;cursor:not-allowed}.__P__-menu-icon{display:inline-flex;width:16px;height:16px;color:var(--__P__-fg-muted)}.__P__-menu-icon svg{width:16px;height:16px}.__P__-menu-label{flex:1}.__P__-menu-check{display:inline-flex;color:var(--__P__-accent-fg)}.__P__-menu-check svg{width:14px;height:14px}.__P__-menu-item-segmented{cursor:default}.__P__-menu-item-segmented:hover{background:transparent}.__P__-segmented{display:inline-flex;gap:2px;padding:2px;background:var(--__P__-bg-elevated);border-radius:var(--__P__-radius-sm)}.__P__-segment{all:unset;min-width:26px;padding:3px 8px;font-size:var(--__P__-text-xs);font-weight:600;letter-spacing:.02em;text-align:center;color:var(--__P__-fg-muted);border-radius:calc(var(--__P__-radius-sm) - 2px);cursor:pointer;transition:color .12s ease,background .12s ease}.__P__-segment:hover{color:var(--__P__-fg)}.__P__-segment[data-on=true]{background:var(--__P__-bg);color:var(--__P__-accent-fg);box-shadow:var(--__P__-shadow-card)}.__P__-segment:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-resize-grip{position:absolute;width:18px;height:18px;display:flex;align-items:center;justify-content:center;color:var(--__P__-fg-muted);opacity:.45;transition:opacity var(--__P__-dur-base) var(--__P__-ease);z-index:2;touch-action:none;user-select:none}.__P__-resize-grip:hover,.__P__-resize-grip:focus-visible{opacity:1}.__P__-resize-grip svg{width:10px;height:10px}.__P__-resize-grip--bottom-left{bottom:2px;left:2px;cursor:nesw-resize;transform:scaleX(-1)}.__P__-resize-grip--bottom-right{bottom:2px;right:2px;cursor:nwse-resize}.__P__-resize-grip--top-left{top:2px;left:2px;cursor:nwse-resize;transform:rotate(180deg)}.__P__-resize-grip--top-right{top:2px;right:2px;cursor:nesw-resize;transform:scaleY(-1)}:host(:not([data-mode="open"])) .__P__-resize-grip{display:none}.__P__-messenger{display:flex;flex-direction:column;overflow:hidden}.__P__-messenger-body,.__P__-messenger-pane{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}.__P__-messenger-pane[hidden]{display:none}@keyframes __P__-view-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}.__P__-module{display:flex;flex-direction:column;height:100%;min-height:0}@media(prefers-reduced-motion:no-preference){.__P__-module,.__P__-history{animation:__P__-view-in .18s var(--__P__-ease-out)}}.__P__-module-scroll{flex:1;min-height:0;overflow-y:auto;padding:var(--__P__-space-3);display:flex;flex-direction:column;gap:var(--__P__-space-3)}.__P__-home{container-type:inline-size;background:radial-gradient(125% 65% at 88% 0%,color-mix(in srgb,#fff 16%,transparent),transparent 55%),linear-gradient(180deg,var(--__P__-accent) 0%,var(--__P__-accent) 22%,color-mix(in srgb,var(--__P__-accent) 28%,var(--__P__-surface)) 44%,var(--__P__-surface) 70%);border-radius:var(--__P__-radius-lg) var(--__P__-radius-lg) 0 0}.__P__-home-scroll{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;background:transparent}.__P__-home-cards{display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:4px 14px 16px}.__P__-module-pad{padding:var(--__P__-space-3) var(--__P__-space-3) 0}.__P__-module-empty{display:flex;flex-direction:column;align-items:center;gap:var(--__P__-space-3);padding:var(--__P__-space-8) var(--__P__-space-4);text-align:center;color:var(--__P__-fg-muted);font-size:var(--__P__-text-base)}.__P__-module-retry{padding:var(--__P__-space-2) var(--__P__-space-4);border:1px solid var(--__P__-border-strong);border-radius:var(--__P__-radius-sm);color:var(--__P__-fg);font-weight:600;cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease-out),border-color var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-module-retry:hover{background:var(--__P__-hover);border-color:var(--__P__-accent)}.__P__-module-retry:active{background:var(--__P__-border)}.__P__-module-retry:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-help-list{flex:1;min-height:0;overflow-y:auto;padding-bottom:var(--__P__-space-3)}.__P__-help-group{display:flex;flex-direction:column}.__P__-help-section-title{position:sticky;top:0;z-index:1;margin:0;padding:var(--__P__-space-3) var(--__P__-space-5) var(--__P__-space-2);font-size:var(--__P__-text-xs);font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--__P__-fg-muted);background:var(--__P__-bg)}.__P__-help-card{margin:0 var(--__P__-space-3) var(--__P__-space-3);background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);overflow:hidden}.__P__-help-card .__P__-list-row{border-bottom:0;border-radius:0}.__P__-help-card .__P__-list-row+.__P__-list-row{border-top:1px solid var(--__P__-border)}.__P__-help-more{justify-content:center;color:var(--__P__-accent-fg);font-weight:600}.__P__-tabbar{display:flex;border-top:1px solid var(--__P__-border);background:var(--__P__-bg-elevated);flex-shrink:0}.__P__-tab{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--__P__-space-1);min-height:48px;padding:var(--__P__-space-2) var(--__P__-space-1);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600;transition:color var(--__P__-dur-quick) var(--__P__-ease-out)}@media(hover:hover){.__P__-tab:hover{background:var(--__P__-hover)}}.__P__-tab[aria-selected=true]{color:var(--__P__-accent-fg)}.__P__-tab:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-tab:active{background:var(--__P__-hover)}.__P__-tab-icon{position:relative;display:inline-flex}.__P__-tab-icon svg{width:22px;height:22px}.__P__-tab-badge{position:absolute;top:-2px;left:calc(50% + 6px);width:8px;height:8px;border-radius:50%;background:var(--__P__-accent);box-shadow:0 0 0 2px var(--__P__-bg-elevated)}.__P__-home-hero{flex-shrink:0;padding:var(--__P__-space-5) var(--__P__-space-5) var(--__P__-space-3);color:var(--__P__-on-accent);--__P__-focus: var(--__P__-on-accent)}.__P__-home-hero-top{display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-3);min-height:32px}.__P__-home-brand{font-size:clamp(calc(12px * var(--__P__-text-scale)),calc(3.2cqi * var(--__P__-text-scale)),calc(14px * var(--__P__-text-scale)));font-weight:600;letter-spacing:.01em;color:color-mix(in srgb,#fff 82%,transparent);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.__P__-home-brand-spacer{flex:1}.__P__-home-hero-actions{display:flex;align-items:center;gap:var(--__P__-space-2);flex-shrink:0}.__P__-home-hero-actions .__P__-icon-btn{color:#fff}.__P__-home-hero-actions .__P__-icon-btn:hover{background:color-mix(in srgb,#fff 18%,transparent);color:#fff}.__P__-home-hero-actions .__P__-icon-btn:active{background:color-mix(in srgb,#fff 26%,transparent)}.__P__-home-greeting{margin:28px 0 0;font-family:var(--__P__-font-display);font-size:clamp(calc(19px * var(--__P__-text-scale)),calc(5.5cqi * var(--__P__-text-scale)),var(--__P__-text-2xl));font-weight:800;line-height:1.18;letter-spacing:-.01em;overflow-wrap:anywhere}.__P__-home-lead{margin:10px 0 0;font-family:var(--__P__-font-display);font-size:clamp(calc(15px * var(--__P__-text-scale)),calc(4.2cqi * var(--__P__-text-scale)),var(--__P__-text-xl));font-weight:600;line-height:1.25;letter-spacing:-.005em;color:color-mix(in srgb,var(--__P__-on-accent) 78%,transparent);overflow-wrap:anywhere}.__P__-home-avatars{display:flex}.__P__-home-avatar{width:30px;height:30px;border-radius:var(--__P__-radius-md);overflow:hidden;margin-inline-start:-10px;border:2px solid color-mix(in srgb,#fff 92%,transparent);box-shadow:0 1px 3px #0000002e;background:var(--__P__-surface);display:inline-flex;align-items:center;justify-content:center;font-size:var(--__P__-text-xs);font-weight:700;color:var(--__P__-fg)}.__P__-home-avatar:first-child{margin-inline-start:0}.__P__-home-avatar img{width:100%;height:100%;object-fit:cover}.__P__-home-content{background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);box-shadow:var(--__P__-shadow-card);overflow:hidden}.__P__-home-content-title{padding:var(--__P__-space-4) var(--__P__-space-4) var(--__P__-space-3);font-size:var(--__P__-text-sm);font-weight:700}.__P__-home-content-list{display:flex;flex-direction:column;padding:0 var(--__P__-space-2) var(--__P__-space-2)}.__P__-home-content-list .__P__-list-row+.__P__-list-row{border-top:1px solid var(--__P__-border)}.__P__-home-card{display:block;width:100%;text-align:start;background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);padding:var(--__P__-space-4);box-shadow:var(--__P__-shadow-card)}.__P__-home-card[data-interactive=true]{cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease-out),transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-home-card[data-interactive=true]:hover{background:var(--__P__-bg-elevated)}.__P__-home-card[data-interactive=true]:active{transform:translateY(1px)}.__P__-home-card[data-interactive=true]:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-home-recent-row{display:flex;align-items:center;gap:var(--__P__-space-3)}.__P__-home-recent-avatar{display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;flex-shrink:0;border-radius:var(--__P__-radius-md);background:color-mix(in oklch,var(--__P__-accent) 14%,transparent);color:var(--__P__-accent-fg)}.__P__-home-recent-avatar svg{width:20px;height:20px}.__P__-home-recent-body{display:flex;flex-direction:column;gap:3px;min-width:0;flex:1;line-height:1.45}.__P__-home-recent-title{font-weight:600;font-size:calc(14px * var(--__P__-text-scale))}.__P__-home-recent-preview{color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.__P__-home-recent-dot{width:8px;height:8px;border-radius:999px;background:var(--__P__-accent);flex-shrink:0}.__P__-home-recent-row[data-unread=true] .__P__-home-recent-title{font-weight:700}.__P__-home-status{display:flex;align-items:center;gap:var(--__P__-space-3)}.__P__-home-status-icon svg{width:22px;height:22px;color:var(--__P__-success)}.__P__-home-status[data-level=degraded] .__P__-home-status-icon svg{color:var(--__P__-warning)}.__P__-home-status[data-level=down] .__P__-home-status-icon svg{color:var(--__P__-danger)}.__P__-home-status-text{font-weight:600;font-size:calc(14px * var(--__P__-text-scale))}.__P__-home-search{display:flex;align-items:center;gap:var(--__P__-space-2);width:100%;padding:var(--__P__-space-3) var(--__P__-space-4);border-radius:var(--__P__-radius);border:1px solid var(--__P__-border);background:var(--__P__-surface);text-align:start}.__P__-home-search[data-input=true]{background:var(--__P__-bg-elevated)}.__P__-home-search:hover{border-color:var(--__P__-border-strong)}.__P__-home-search:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-home-search[data-input=true]:focus-within{outline:none;border-color:var(--__P__-focus)}.__P__-home-search-text{flex:1;color:var(--__P__-fg-muted);font-size:calc(14px * var(--__P__-text-scale))}.__P__-home-search-input{flex:1;border:0;background:transparent;font-size:calc(14px * var(--__P__-text-scale));color:var(--__P__-fg);outline:none}.__P__-home-search-input:focus-visible{outline:none}.__P__-home-search-icon svg{width:18px;height:18px;color:var(--__P__-accent-fg)}.__P__-home-ask{padding-block:6px;padding-inline-end:6px}.__P__-home-ask .__P__-send{width:32px;height:32px;flex-shrink:0}.__P__-home-ask .__P__-send[data-shape=pill]{width:auto;padding:0 14px}.__P__-home-ask .__P__-send svg{width:16px;height:16px}.__P__-list-row{display:flex;align-items:center;gap:var(--__P__-space-3);width:100%;min-height:44px;text-align:start;padding:var(--__P__-space-3) var(--__P__-space-2);border-radius:var(--__P__-radius-sm)}.__P__-list-row:hover{background:var(--__P__-hover)}.__P__-list-row:active{background:var(--__P__-border)}.__P__-list-row:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-list-row-body{display:flex;flex-direction:column;min-width:0;flex:1}.__P__-list-row-title{font-weight:600;font-size:var(--__P__-text-md);line-height:1.35}.__P__-list-row-sub{color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);margin-top:var(--__P__-space-1);line-height:1.45;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.__P__-list-row-chevron svg{width:18px;height:18px;color:var(--__P__-accent-fg);flex-shrink:0}.__P__-back-header{display:flex;align-items:center;gap:var(--__P__-space-2);padding:10px 12px;border-bottom:1px solid var(--__P__-border);flex-shrink:0}.__P__-back-title{flex:1;text-align:center;font-size:var(--__P__-text-md);font-weight:700;margin:0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-back-spacer{width:32px;height:1px}.__P__-history>*,.__P__-home-scroll>*,.__P__-module-scroll>*,.__P__-help-list>*,.__P__-history-footer>*,.__P__-module-pad{width:100%;max-width:var(--__P__-conversation-max, 768px);margin-inline:auto}.__P__-header,.__P__-back-header{padding-inline:max(12px,calc((100% - var(--__P__-conversation-max, 768px)) / 2))}.__P__-tabbar{padding-inline:max(0px,calc((100% - var(--__P__-conversation-max, 768px)) / 2))}.__P__-content{display:flex;flex-direction:column;gap:14px;width:100%;max-width:68ch;margin:0 auto}.__P__-content-hero{width:100%;border-radius:var(--__P__-radius)}.__P__-content-subtitle{color:var(--__P__-fg-muted);margin:0}.__P__-content-vote{display:flex;align-items:center;flex-wrap:wrap;gap:var(--__P__-space-2);padding-top:var(--__P__-space-3);border-top:1px solid var(--__P__-border)}.__P__-content-frame{flex:1;min-height:0;width:100%;border:0;background:#fff}.__P__-news-list{display:flex;flex-direction:column;gap:var(--__P__-space-3)}.__P__-news-card{display:block;width:100%;text-align:start;line-height:1.45;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);overflow:hidden;background:var(--__P__-surface);transition:background var(--__P__-dur-quick) var(--__P__-ease-out),transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-news-card:hover{background:var(--__P__-bg-elevated)}.__P__-news-card:active{transform:translateY(1px)}.__P__-news-card:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-news-hero{width:100%;display:block}.__P__-news-body{display:flex;flex-direction:column;gap:6px;padding:14px 16px}.__P__-news-title{font-weight:700;font-size:var(--__P__-text-md)}.__P__-news-meta{display:flex;flex-wrap:wrap;align-items:center;gap:6px;color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm)}.__P__-news-tag{padding:1px 8px;border-radius:6px;background:var(--__P__-hover);color:var(--__P__-fg);font-size:calc(12px * var(--__P__-text-scale));white-space:nowrap}.__P__-news-more{display:flex;align-items:center;justify-content:center;gap:var(--__P__-space-2);width:100%;min-height:44px;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);background:var(--__P__-surface);color:var(--__P__-accent-fg);font-weight:600}.__P__-news-more:hover{background:var(--__P__-bg-elevated)}.__P__-news-more:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-news-summary{color:var(--__P__-fg-muted);font-size:calc(14px * var(--__P__-text-scale));display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.__P__-modules-empty{display:flex;align-items:center;justify-content:center;position:relative}.__P__-modules-empty-close{position:absolute;top:12px;inset-inline-end:12px}.__P__-modules-empty-text{color:var(--__P__-fg-muted);font-size:var(--__P__-text-base)}.__P__-form{display:flex;flex-direction:column;gap:var(--__P__-space-4)}.__P__-field{display:flex;flex-direction:column;gap:6px}.__P__-field-head{display:flex;flex-wrap:wrap;align-items:baseline;gap:var(--__P__-space-2)}.__P__-field-label{font-size:var(--__P__-text-sm);font-weight:600;color:var(--__P__-fg)}.__P__-field-req{color:var(--__P__-danger)}.__P__-field-type{flex-shrink:0;align-self:center;margin-inline-start:auto;border:1px solid var(--__P__-border);border-radius:5px;background:color-mix(in oklab,var(--__P__-fg-muted) 9%,transparent);padding:1px 7px;font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted);white-space:nowrap}.__P__-field-input{width:100%;min-width:0;max-width:100%;box-sizing:border-box;padding:10px var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);color:var(--__P__-fg);font:inherit;font-size:var(--__P__-text-sm);resize:vertical;transition:border-color var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-field-input:focus-visible{outline:none;border-color:var(--__P__-accent)}.__P__-field[data-invalid=true] .__P__-field-input{border-color:var(--__P__-danger)}.__P__-field-input[type=date],.__P__-field-input[type=time]{appearance:none;-webkit-appearance:none}@media(pointer:coarse){.__P__-textarea,.__P__-home-search-input,.__P__-field-input{font-size:max(16px,calc(16px * var(--__P__-text-scale)))}}.__P__-field-hint{font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted)}.__P__-field-error{font-size:var(--__P__-text-xs);color:var(--__P__-danger)}.__P__-field-choices{display:flex;flex-direction:column;gap:10px;padding-top:2px}.__P__-choice{display:flex;align-items:flex-start;gap:10px;font-size:var(--__P__-text-sm);color:var(--__P__-fg);cursor:pointer}.__P__-choice input{margin-top:2px;accent-color:var(--__P__-accent)}.__P__-form-actions{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:var(--__P__-space-2);margin-top:var(--__P__-space-2)}.__P__-form-hint{flex:1 1 auto;min-width:6rem;margin-inline-end:auto;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted)}.__P__-form-submit{padding:var(--__P__-space-2) var(--__P__-space-4);border:none;border-radius:var(--__P__-radius-md);background:var(--__P__-accent);color:var(--__P__-accent-text, #fff);font:inherit;font-weight:600;font-size:var(--__P__-text-sm);white-space:nowrap;flex-shrink:0;cursor:pointer;transition:filter var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-form-submit:hover:not(:disabled){filter:brightness(1.06)}.__P__-form-submit:disabled{opacity:.6;cursor:default}.__P__-form-skip{padding:var(--__P__-space-2) var(--__P__-space-4);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:transparent;color:var(--__P__-fg-muted);font:inherit;font-size:var(--__P__-text-sm);white-space:nowrap;flex-shrink:0;cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-form-skip:hover:not(:disabled){background:var(--__P__-bg-elevated)}@media(max-width:640px){.__P__-form-hint{flex-basis:100%;margin-inline-end:0;font-size:var(--__P__-text-xs)}.__P__-form-submit,.__P__-form-skip{flex:1 1 0;text-align:center}}.__P__-form-gate{display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:var(--__P__-space-4);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:var(--__P__-bg-elevated)}.__P__-form-gate-title{margin:0;font-size:var(--__P__-text-base);font-weight:700;color:var(--__P__-fg)}.__P__-form-gate-desc{margin:0 0 var(--__P__-space-1);font-size:var(--__P__-text-sm);color:var(--__P__-fg-muted)}.__P__-form-done{display:flex;align-items:center;justify-content:center;gap:6px;padding:6px 12px;border:1px dashed var(--__P__-border);border-radius:999px;align-self:center;font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted)}.__P__-form-done svg{width:14px;height:14px;color:var(--__P__-success, #22c55e)}.__P__-form-done[data-outcome=skipped] svg{color:var(--__P__-fg-muted)}.__P__-form-done-fill{border:0;background:none;padding:0 2px;cursor:pointer;font:inherit;font-weight:600;color:var(--__P__-accent-fg)}.__P__-form-done-fill:hover{text-decoration:underline}details.__P__-form-done{display:block;padding:0;border-radius:var(--__P__-radius-md)}details[open].__P__-form-done{width:min(100%,420px);background:var(--__P__-surface)}.__P__-form-done-summary{display:flex;align-items:center;justify-content:center;gap:6px;padding:8px 12px;cursor:pointer;list-style:none}.__P__-form-done-summary::-webkit-details-marker{display:none}.__P__-form-done-summary>svg:last-child{color:var(--__P__-fg-muted);transition:transform .15s var(--__P__-ease)}details[open]>.__P__-form-done-summary>svg:last-child{transform:rotate(90deg)}.__P__-form-answers{margin:0;padding:var(--__P__-space-2) var(--__P__-space-3) var(--__P__-space-3);display:grid;gap:var(--__P__-space-3);text-align:start}.__P__-form-answer{display:grid;gap:6px}.__P__-form-answer dt{font-size:var(--__P__-text-sm);font-weight:600;color:var(--__P__-fg)}.__P__-form-answer dd{margin:0;padding:10px var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);font-size:var(--__P__-text-sm);font-weight:400;color:var(--__P__-fg);overflow-wrap:anywhere}.__P__-toolui{border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-lg, 14px);background:var(--__P__-bg-elevated);font-size:var(--__P__-text-sm)}.__P__-toolui:not(.__P__-toolui-collapsible){display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:var(--__P__-space-4)}.__P__-toolui-group{display:flex;flex-direction:column;gap:var(--__P__-space-3)}.__P__-toolui-stale{opacity:.7}details.__P__-toolui-collapsible>summary{display:flex;align-items:center;gap:var(--__P__-space-2);padding:var(--__P__-space-3) var(--__P__-space-4);cursor:pointer;list-style:none;-webkit-tap-highlight-color:transparent;user-select:none}details.__P__-toolui-collapsible>summary::-webkit-details-marker{display:none}details.__P__-toolui-collapsible[open]>summary{border-bottom:1px solid var(--__P__-border)}details.__P__-toolui-collapsible>.__P__-toolui-section{margin:var(--__P__-space-4)}details.__P__-toolui-collapsible>.__P__-toolui-section~.__P__-toolui-section{margin-top:calc(-1 * var(--__P__-space-2))}.__P__-toolui-name-text{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-toolui-chevron{display:inline-flex;color:var(--__P__-fg-muted);transition:transform var(--__P__-dur-quick) var(--__P__-ease-out)}details.__P__-toolui-collapsible>summary .__P__-toolui-status{margin-inline-start:auto}.__P__-toolui-chevron svg{width:16px;height:16px}details.__P__-toolui-collapsible[open]>summary .__P__-toolui-chevron{transform:rotate(180deg)}.__P__-toolui-badge,.__P__-toolui-name-pill,.__P__-toolui-q-pill{--__P__-pill: var(--__P__-fg-muted);display:inline-flex;min-width:0;align-items:center;gap:5px;padding:3px 7px;border-radius:5px;border:1px solid var(--__P__-border);background:color-mix(in oklab,var(--__P__-fg-muted) 9%,transparent);color:var(--__P__-pill);font-size:var(--__P__-text-xs);font-weight:600;white-space:nowrap}.__P__-toolui-badge svg,.__P__-toolui-name-pill svg,.__P__-toolui-q-pill svg{flex-shrink:0;width:14px;height:14px}.__P__-toolui-status-icon{display:inline-flex}.__P__-toolui-name-pill{--__P__-pill: oklch(.68 .13 233)}.__P__-toolui-q-pill{--__P__-pill: oklch(.66 .12 195)}.__P__-toolui-status[data-status=completed]{--__P__-pill: var(--__P__-success, #16a34a)}.__P__-toolui-status[data-status=responded]{--__P__-pill: oklch(.62 .15 255)}.__P__-toolui-status[data-status=awaiting]{--__P__-pill: var(--__P__-warning, #f59e0b)}.__P__-toolui-status[data-status=denied]{--__P__-pill: oklch(.66 .16 45)}.__P__-toolui-status[data-status=error]{--__P__-pill: var(--__P__-danger, #dc2626)}.__P__-toolui-status[data-status=superseded],.__P__-toolui-status[data-status=incomplete],.__P__-toolui-status[data-status=stopped]{--__P__-pill: var(--__P__-fg-muted)}@supports (color: oklch(from red l c h)){.__P__-toolui-badge,.__P__-toolui-name-pill,.__P__-toolui-q-pill{color:oklch(from var(--__P__-pill) clamp(var(--__P__-pill-l-min),l,var(--__P__-pill-l-max)) c h)}}.__P__-toolui-head{display:flex;align-items:center;flex-wrap:wrap;gap:var(--__P__-space-2)}.__P__-toolui-head-end{display:inline-flex;align-items:center;gap:var(--__P__-space-2);margin-inline-start:auto}.__P__-toolui-collapse-body{display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:var(--__P__-space-4)}.__P__-toolui-summary{display:flex;flex-direction:column;gap:var(--__P__-space-3)}.__P__-toolui-collapse-body>.__P__-form{gap:var(--__P__-space-3)}.__P__-toolui-collapse-body>.__P__-form>.__P__-field,.__P__-toolui-summary>.__P__-field{padding:10px var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:color-mix(in oklab,var(--__P__-bg) 80%,transparent);line-height:1.5}.__P__-toolui-collapse-body>.__P__-form>.__P__-field{gap:var(--__P__-space-2)}.__P__-toolui-summary>.__P__-field{gap:var(--__P__-space-1)}.__P__-toolui-summary .__P__-field-label{color:var(--__P__-fg-muted)}.__P__-toolui-answer{margin:0;font-size:var(--__P__-text-sm);color:var(--__P__-fg-muted);overflow-wrap:anywhere;white-space:pre-wrap}.__P__-toolui-footer{display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-3);margin-inline:calc(-1 * var(--__P__-space-4));padding:var(--__P__-space-3) var(--__P__-space-4) 0;border-top:1px solid var(--__P__-border)}.__P__-toolui-options-toggle{display:inline-flex;align-items:center;gap:4px;border:0;background:transparent;padding:0;cursor:pointer;font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted);transition:color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-toolui-options-toggle:hover{color:var(--__P__-fg)}.__P__-toolui-options-chevron{display:inline-flex;transition:transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-toolui-options-chevron svg{width:14px;height:14px}.__P__-toolui-options-chevron.__P__-open{transform:rotate(180deg)}.__P__-toolui-desc{margin:0;padding:var(--__P__-space-3);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);border:1px solid var(--__P__-border);color:var(--__P__-fg-muted);line-height:1.5}.__P__-toolui-section{display:flex;flex-direction:column;gap:8px;padding:var(--__P__-space-3);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);border:1px solid var(--__P__-border)}.__P__-toolui:not(.__P__-toolui-collapsible) .__P__-toolui-section,.__P__-toolui:not(.__P__-toolui-collapsible) .__P__-toolui-desc{padding:0;background:none;border:0;border-radius:0}.__P__-toolui-label{font-size:var(--__P__-text-xs);font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--__P__-fg-muted)}.__P__-toolui-code{margin:0;max-height:240px;overflow:auto;color:var(--__P__-fg);font-family:var(--__P__-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);font-size:var(--__P__-text-xs);line-height:1.5;white-space:pre-wrap;word-break:break-word}.__P__-toolui-code[data-error=true]{color:var(--__P__-danger, #dc2626)}.__P__-toolui-body{gap:6px}.__P__-toolui-prompt{margin:0;font-weight:600;color:var(--__P__-fg);overflow-wrap:anywhere}.__P__-toolui-subtle{margin:0;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted);line-height:1.5}.__P__-toolui-fields{display:grid;grid-template-columns:auto minmax(0,1fr);gap:2px var(--__P__-space-2);margin:0;font-size:var(--__P__-text-xs);line-height:1.5}.__P__-toolui-fields>div{display:contents}.__P__-toolui-fields dt{color:var(--__P__-fg-muted)}.__P__-toolui-fields dd{margin:0;min-width:0;overflow:hidden;color:var(--__P__-fg);font-family:var(--__P__-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);text-overflow:ellipsis;white-space:nowrap}.__P__-toolui-actions{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:var(--__P__-space-2);margin-top:var(--__P__-space-2)}:host([dir="rtl"]) .__P__-icon-dir{transform:scaleX(-1)}:host([dir="rtl"]) .__P__-field-input[type=date],:host([dir="rtl"]) .__P__-field-input[type=time]{position:relative;text-align:right;padding-left:34px}:host([dir="rtl"]) .__P__-field-input[type=date]::-webkit-datetime-edit,:host([dir="rtl"]) .__P__-field-input[type=time]::-webkit-datetime-edit{text-align:right}:host([dir="rtl"]) .__P__-field-input[type=date]::-webkit-calendar-picker-indicator,:host([dir="rtl"]) .__P__-field-input[type=time]::-webkit-calendar-picker-indicator{position:absolute;left:var(--__P__-space-3);margin:0}
|
|
5
|
+
.__P__-anchor{color-scheme:var(--__P__-color-scheme, light);right:16px;bottom:16px}.__P__-surface{display:contents}.__P__-surface[hidden]{display:none}:host([data-position="bottom-left"]) .__P__-anchor,:host([data-position="top-left"]) .__P__-anchor{right:auto;left:16px}:host([data-position="top-right"]) .__P__-anchor,:host([data-position="top-left"]) .__P__-anchor{bottom:auto;top:16px}.__P__-anchor{position:fixed;display:flex;flex-direction:column;align-items:flex-end;gap:var(--__P__-space-3);pointer-events:none}.__P__-anchor{--__P__-fab-size: 56px}.__P__-anchor[data-launcher-size=sm]{--__P__-fab-size: 44px}.__P__-anchor[data-launcher-size=md]{--__P__-fab-size: 56px}.__P__-anchor[data-launcher-size=lg]{--__P__-fab-size: 68px}.__P__-anchor>*{pointer-events:auto}.__P__-fab[data-size=sm]{--__P__-fab-size: 44px;font-size:var(--__P__-text-sm)}.__P__-fab[data-size=md]{--__P__-fab-size: 56px;font-size:calc(14px * var(--__P__-text-scale))}.__P__-fab[data-size=lg]{--__P__-fab-size: 68px;font-size:var(--__P__-text-base)}.__P__-fab{display:inline-flex;align-items:center;justify-content:center;gap:var(--__P__-space-2);color:var(--__P__-accent-text);background:var(--__P__-accent);box-shadow:var(--__P__-shadow-fab);font-weight:600;line-height:1;transform-origin:bottom right;animation:__P__-fab-in var(--__P__-dur-base) var(--__P__-ease) both;transition:transform var(--__P__-dur-base) var(--__P__-ease),opacity var(--__P__-dur-base) var(--__P__-ease),box-shadow var(--__P__-dur-base) var(--__P__-ease)}.__P__-fab:hover{transform:translateY(-2px)}.__P__-fab:active{transform:translateY(0)}.__P__-fab:focus-visible{outline:2px solid var(--__P__-on-accent);outline-offset:3px}.__P__-fab svg{width:24px;height:24px;flex-shrink:0}@keyframes __P__-fab-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:none}}.__P__-fab[data-leaving]{position:absolute;right:0;bottom:0;animation:__P__-fab-out var(--__P__-dur-quick) var(--__P__-ease) forwards;pointer-events:none}:host([data-position^="top-"]) .__P__-fab[data-leaving]{bottom:auto;top:0}:host([data-position$="-left"]) .__P__-fab[data-leaving]{right:auto;left:0}@keyframes __P__-fab-out{0%{opacity:1;transform:none}to{opacity:0;transform:scale(.85)}}.__P__-fab[data-variant=circle]{width:var(--__P__-fab-size);height:var(--__P__-fab-size);border-radius:999px}.__P__-fab[data-variant=circle] .__P__-fab-label{display:none}.__P__-fab[data-variant=pill]{height:var(--__P__-fab-size);padding:0 18px 0 16px;border-radius:999px}.__P__-fab[data-variant=bar]{height:var(--__P__-fab-size);padding:0 22px;border-radius:var(--__P__-radius)}.__P__-fab[data-variant=minimal]{height:var(--__P__-fab-size);padding:0 var(--__P__-space-4);border-radius:999px;background:transparent;color:var(--__P__-accent-fg);box-shadow:none;border:1px solid currentColor}.__P__-fab[data-variant=minimal]:hover{background:color-mix(in srgb,var(--__P__-accent) 12%,transparent)}.__P__-callout{--__P__-callout-fab-h: var(--__P__-fab-size, 56px);--__P__-callout-gap: clamp(12px, calc(var(--__P__-callout-fab-h) * .25), 22px);--__P__-callout-nudge-direction: -1;position:absolute;display:inline-flex;align-items:center;gap:var(--__P__-space-2);padding:10px 14px;background:var(--__P__-fg);color:var(--__P__-bg);border-radius:999px;font-size:var(--__P__-text-sm);font-weight:600;line-height:1.2;box-shadow:0 10px 30px -8px #00000059;pointer-events:auto;animation:__P__-callout-in var(--__P__-dur-slow) var(--__P__-ease);z-index:1;max-width:240px;white-space:nowrap}.__P__-callout[data-position=left]{right:calc(100% + var(--__P__-callout-gap));bottom:calc(var(--__P__-callout-fab-h) / 2);transform:translateY(50%)}.__P__-callout[data-position=right]{left:calc(100% + var(--__P__-callout-gap));bottom:calc(var(--__P__-callout-fab-h) / 2);transform:translateY(50%);--__P__-callout-nudge-direction: 1}.__P__-callout[data-position=top]{bottom:calc(100% + var(--__P__-callout-gap));right:0;max-width:min(280px,calc(100vw - 32px))}.__P__-callout[data-position=bottom]{top:calc(100% + var(--__P__-callout-gap));right:0;max-width:min(280px,calc(100vw - 32px))}:host([data-position$="-left"]) .__P__-callout[data-position=top],:host([data-position$="-left"]) .__P__-callout[data-position=bottom]{right:auto;left:0}.__P__-callout[data-shape=bubble]{border-radius:var(--__P__-radius-md);white-space:normal;width:max-content;max-width:min(280px,calc(100vw - 32px))}.__P__-callout[data-shape=callout]{padding:12px 18px;font-size:calc(14px * var(--__P__-text-scale));background:var(--__P__-accent);color:var(--__P__-accent-text)}.__P__-callout:after{content:"";position:absolute;width:12px;height:12px;background:inherit;border-radius:2px;transform:rotate(45deg)}.__P__-callout[data-position=left]:after{right:-5px;top:50%;margin-top:-6px}.__P__-callout[data-position=right]:after{left:-5px;top:50%;margin-top:-6px}.__P__-callout[data-position=top]:after{bottom:-5px;right:calc(var(--__P__-fab-size, 56px) / 2 - 6px)}.__P__-callout[data-position=bottom]:after{top:-5px;right:calc(var(--__P__-fab-size, 56px) / 2 - 6px)}:host([data-position$="-left"]) .__P__-callout[data-position=top]:after,:host([data-position$="-left"]) .__P__-callout[data-position=bottom]:after{right:auto;left:calc(var(--__P__-fab-size, 56px) / 2 - 6px)}.__P__-callout[data-animated]{animation:__P__-callout-in var(--__P__-dur-slow) var(--__P__-ease),__P__-callout-nudge 1.6s var(--__P__-ease-in-out) var(--__P__-dur-slow) infinite}@keyframes __P__-callout-in{0%{opacity:0}to{opacity:1}}@keyframes __P__-callout-nudge{0%,to{margin-left:0;margin-right:0}50%{margin-left:calc(6px * var(--__P__-callout-nudge-direction));margin-right:calc(-6px * var(--__P__-callout-nudge-direction))}}@media(prefers-reduced-motion:reduce){.__P__-callout[data-animated]{animation:__P__-callout-in 1ms var(--__P__-ease)}.__P__-icon-btn[data-recording=true],.__P__-typing span{animation:none}}.__P__-callout-close{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;border-radius:999px;color:inherit;opacity:.7;cursor:pointer}.__P__-callout-close:hover{opacity:1;background:color-mix(in srgb,currentColor 15%,transparent)}.__P__-callout-close:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-callout-close svg{width:12px;height:12px}.__P__-panel{width:var(--__P__-panel-w);height:var(--__P__-panel-h);max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);background:var(--__P__-bg);color:var(--__P__-fg);border-radius:var(--__P__-radius-lg);box-shadow:var(--__P__-shadow-panel);display:flex;flex-direction:column;overflow:hidden;overflow:clip;overscroll-behavior:none;transform-origin:bottom right;animation:__P__-panel-in var(--__P__-dur-slow) var(--__P__-ease);border:1px solid var(--__P__-border)}@media(prefers-reduced-motion:no-preference){.__P__-panel{transition:width var(--__P__-dur-base) var(--__P__-ease),height var(--__P__-dur-base) var(--__P__-ease),max-width var(--__P__-dur-base) var(--__P__-ease),max-height var(--__P__-dur-base) var(--__P__-ease)}.__P__-panel[data-resizing]{transition:none}}:host([data-mode="open"]) .__P__-panel{width:var(--__P__-widget-w, var(--__P__-panel-w));height:var(--__P__-widget-h, var(--__P__-panel-h));min-width:var(--__P__-resize-min-w, auto);min-height:var(--__P__-resize-min-h, auto);max-width:var(--__P__-resize-max-w, calc(100vw - 32px) );max-height:var(--__P__-resize-max-h, calc(100dvh - 32px) )}@keyframes __P__-panel-in{0%{opacity:0;transform:translateY(8px) scale(.98)}to{opacity:1;transform:none}}:host([data-mode="expanded"]) .__P__-panel{width:var(--__P__-expanded-w, 640px);height:var(--__P__-expanded-h, 820px);max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px)}:host([data-mode="fullscreen"]){z-index:var(--__P__-z-panel)!important}:host([data-mode="fullscreen"]) .__P__-anchor{inset:var(--__P__-visual-viewport-top, 0px) 0 auto;height:var(--__P__-visual-viewport-height, 100dvh);padding:0;justify-content:flex-end;align-items:flex-end}:host([data-mode="fullscreen"][data-position*="top"]) .__P__-anchor{justify-content:flex-start}:host([data-mode="fullscreen"][data-position*="left"]) .__P__-anchor{align-items:flex-start}:host([data-mode="fullscreen"]) .__P__-panel{width:100vw;height:100%;max-width:none;max-height:none;border-radius:0;border:0}:host([data-mode="fullscreen"]) .__P__-fab{display:none}:host([data-mode="inline"]) .__P__-anchor,:host([data-mode="standalone"]) .__P__-anchor{position:static;inset:auto;padding:0;align-items:stretch;width:100%;height:100%;min-height:0}:host([data-mode="inline"]) .__P__-panel,:host([data-mode="standalone"]) .__P__-panel{width:100%;height:100%;min-width:0;min-height:0;max-width:none;max-height:none;animation:none}:host([data-mode="inline"]) .__P__-fab,:host([data-mode="standalone"]) .__P__-fab{display:none}:host([data-mode="inline"]){min-height:320px}:host([data-mode="inline"]) .__P__-panel{border-radius:var(--__P__-radius)}:host([data-mode="standalone"]) .__P__-panel{border-radius:0;border:0;box-shadow:none}:host([data-mode="modal"]){position:fixed!important;inset:0!important;z-index:var(--__P__-z-panel)!important;display:block!important;width:100vw;height:100dvh;background:var(--__P__-modal-backdrop, var(--__P__-backdrop));animation:__P__-backdrop-in var(--__P__-dur-base) var(--__P__-ease) both;--__P__-panel-w: min(960px, 92vw);--__P__-panel-h: min(720px, 88dvh)}:host([data-mode="modal"]) .__P__-anchor{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:var(--__P__-space-6);pointer-events:none}:host([data-mode="modal"]) .__P__-panel{pointer-events:auto;width:var(--__P__-widget-w, var(--__P__-panel-w));height:var(--__P__-widget-h, var(--__P__-panel-h));max-width:calc(100vw - 48px);max-height:calc(100dvh - 48px);min-width:0;min-height:0;border-radius:var(--__P__-radius);box-shadow:var(--__P__-shadow-panel);animation:__P__-modal-in var(--__P__-dur-base) var(--__P__-ease);translate:var(--__P__-modal-dx, 0px) var(--__P__-modal-dy, 0px)}:host([data-mode="modal"]) .__P__-header,:host([data-mode="modal"]) .__P__-back-header,:host([data-mode="modal"]) .__P__-home-hero{cursor:grab;touch-action:none}:host([data-mode="modal"]) .__P__-panel[data-dragging]{cursor:grabbing;user-select:none}:host([data-mode="modal"]) .__P__-panel[data-dragging] *{cursor:grabbing}:host([data-mode="modal"]) .__P__-fab{display:none}@keyframes __P__-backdrop-in{0%{background:#0000}to{background:var(--__P__-modal-backdrop, var(--__P__-backdrop))}}@keyframes __P__-modal-in{0%{opacity:0;transform:translateY(8px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}:host([data-mode="drawer"]){--__P__-panel-w: min(440px, calc(100vw - 32px) );--__P__-panel-h: 100dvh}:host([data-mode="drawer"]) .__P__-anchor{position:fixed;--__P__-inset-x: var(--__P__-panel-inset, 12px);--__P__-inset-y: var(--__P__-panel-inset, 3dvh);top:var(--__P__-inset-y);bottom:auto;right:var(--__P__-inset-x);left:auto;width:min(var(--__P__-widget-w, var(--__P__-panel-w)),calc(100vw - var(--__P__-inset-x) * 2));height:min(var(--__P__-widget-h, var(--__P__-panel-h)),calc(100dvh - var(--__P__-inset-y) * 2));padding:0;display:block;pointer-events:auto}:host([data-mode="drawer"][data-position$="-left"]) .__P__-anchor{right:auto;left:var(--__P__-inset-x)}:host([data-mode="drawer"][data-position^="bottom-"]) .__P__-anchor{top:auto;bottom:var(--__P__-inset-y)}:host([data-mode="drawer"]) .__P__-panel{width:100%;height:100%;max-width:none;max-height:none;min-width:0;min-height:0;border-radius:var(--__P__-radius, 12px);border:1px solid var(--__P__-border);box-shadow:-8px 16px 32px -12px #00000038;animation:__P__-drawer-in var(--__P__-dur-base) var(--__P__-ease)}:host([data-mode="drawer"][data-position$="-left"]) .__P__-panel{box-shadow:8px 16px 32px -12px #00000038;animation:__P__-drawer-in-left var(--__P__-dur-base) var(--__P__-ease)}.__P__-fab[data-edge-tab]{display:inline-flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--__P__-space-2);position:fixed;top:50%;height:140px;width:auto;min-width:0;padding:10px 8px;writing-mode:vertical-rl;text-orientation:mixed;transform:translateY(-50%);transform-origin:center;animation:__P__-edge-tab-in var(--__P__-dur-base) var(--__P__-ease) both}.__P__-fab[data-edge-tab] svg{writing-mode:horizontal-tb}.__P__-fab[data-edge-tab]:hover{transform:translateY(-50%) scale(1.03)}.__P__-fab[data-edge-tab]:active{transform:translateY(-50%) scale(.97)}:host([data-position$="-right"]) .__P__-fab[data-edge-tab]{right:0;left:auto;border-radius:12px 0 0 12px;box-shadow:-6px 0 18px -8px #0000004d}:host([data-position$="-left"]) .__P__-fab[data-edge-tab]{left:0;right:auto;border-radius:0 12px 12px 0;box-shadow:6px 0 18px -8px #0000004d}.__P__-fab[data-edge-tab][data-leaving]{position:fixed;top:50%;bottom:auto;animation:__P__-edge-tab-out var(--__P__-dur-quick) var(--__P__-ease) forwards}@keyframes __P__-edge-tab-in{0%{opacity:0;transform:translateY(-50%) scale(.9)}to{opacity:1;transform:translateY(-50%) scale(1)}}@keyframes __P__-edge-tab-out{0%{opacity:1;transform:translateY(-50%) scale(1)}to{opacity:0;transform:translateY(-50%) scale(.85)}}@keyframes __P__-drawer-in{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes __P__-drawer-in-left{0%{transform:translate(-100%)}to{transform:translate(0)}}@media(prefers-reduced-motion:reduce){:host([data-mode="drawer"]) .__P__-panel,.__P__-fab[data-edge-tab]{animation:none}}@media(max-width:640px){:host([data-mode="open"][data-position]) .__P__-anchor,:host([data-mode="expanded"][data-position]) .__P__-anchor,:host([data-mode="drawer"][data-position]) .__P__-anchor,:host([data-mode="modal"][data-position]) .__P__-anchor{inset:var(--__P__-visual-viewport-top, 0px) 0 auto;align-items:stretch;width:auto;height:var(--__P__-visual-viewport-height, 100dvh);padding:0}:host([data-mode="open"][data-position]) .__P__-panel,:host([data-mode="expanded"][data-position]) .__P__-panel,:host([data-mode="drawer"][data-position]) .__P__-panel,:host([data-mode="modal"][data-position]) .__P__-panel{width:100vw;height:100%;max-width:none;max-height:none;border-radius:0;border:0;box-shadow:none;translate:none}:host([data-mode="modal"]){background:none;animation:none}}.__P__-header{display:flex;align-items:center;gap:var(--__P__-space-2);padding:10px 12px;border-bottom:1px solid var(--__P__-border);background:var(--__P__-bg)}.__P__-header h1{font-size:calc(14px * var(--__P__-text-scale));font-weight:600;flex:1;letter-spacing:-.01em}.__P__-header-actions{margin-inline-start:auto;display:flex;align-items:center;gap:var(--__P__-space-1);flex-shrink:0}.__P__-agent{flex:1;display:inline-flex;align-items:center;gap:10px;min-width:0}.__P__-agent-avatar{position:relative;width:32px;height:32px;border-radius:var(--__P__-radius-md);background:var(--__P__-bg-elevated);color:var(--__P__-fg-muted);display:inline-flex;align-items:center;justify-content:center;font-weight:700;font-size:var(--__P__-text-xs);flex-shrink:0}.__P__-agent-avatar img{width:100%;height:100%;border-radius:inherit;object-fit:cover}.__P__-agent-avatar:after{content:"";position:absolute;right:-1px;bottom:-1px;width:10px;height:10px;border-radius:999px;border:2px solid var(--__P__-bg);background:var(--__P__-neutral)}.__P__-agent-avatar[data-status=online]:after{background:var(--__P__-success)}.__P__-agent-avatar[data-status=away]:after{background:var(--__P__-warning)}.__P__-agent-avatar[data-status=offline]:after{background:var(--__P__-neutral)}.__P__-agent-meta{display:flex;flex-direction:column;line-height:1.15;min-width:0}.__P__-agent-meta strong{font-size:calc(14px * var(--__P__-text-scale));font-weight:600;letter-spacing:-.01em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-agent-meta span{font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-suggestions{display:flex;flex-wrap:nowrap;gap:var(--__P__-space-2);padding:6px 14px 10px;overflow-x:auto;overflow-y:hidden;scroll-behavior:smooth;scroll-snap-type:x proximity;scrollbar-width:none;-ms-overflow-style:none;min-width:0}.__P__-suggestions::-webkit-scrollbar{display:none}.__P__-suggestions[data-cut-end=true]{mask-image:linear-gradient(to right,#000 calc(100% - 32px),transparent)}.__P__-suggestions[data-cut-start=true]{mask-image:linear-gradient(to right,transparent,#000 32px)}.__P__-suggestions[data-cut-start=true][data-cut-end=true]{mask-image:linear-gradient(to right,transparent,#000 32px,#000 calc(100% - 32px),transparent)}:host([dir="rtl"]) .__P__-suggestions[data-cut-end=true]{mask-image:linear-gradient(to left,#000 calc(100% - 32px),transparent)}:host([dir="rtl"]) .__P__-suggestions[data-cut-start=true]{mask-image:linear-gradient(to left,transparent,#000 32px)}:host([dir="rtl"]) .__P__-suggestions[data-cut-start=true][data-cut-end=true]{mask-image:linear-gradient(to left,transparent,#000 32px,#000 calc(100% - 32px),transparent)}.__P__-suggestions:before,.__P__-suggestions:after{content:"";flex:1 1 0;min-width:0}.__P__-suggestion{flex:0 0 auto;scroll-snap-align:center;padding:7px 14px;border-radius:999px;background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);color:var(--__P__-fg);font-size:var(--__P__-text-sm);font-weight:500;white-space:nowrap;transition:background var(--__P__-dur-quick) var(--__P__-ease),border-color var(--__P__-dur-quick) var(--__P__-ease),transform var(--__P__-dur-quick) var(--__P__-ease)}.__P__-suggestion:hover{border-color:var(--__P__-accent);color:var(--__P__-accent-fg);transform:translateY(-1px)}.__P__-suggestion:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px;border-color:var(--__P__-accent)}.__P__-suggestion:active{transform:translateY(0)}.__P__-icon-btn{width:32px;height:32px;border-radius:999px;position:relative;display:inline-flex;align-items:center;justify-content:center;color:var(--__P__-fg-muted);transition:background var(--__P__-dur-quick) var(--__P__-ease),color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-icon-btn:hover{background:var(--__P__-bg-elevated);color:var(--__P__-fg)}.__P__-icon-btn:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-icon-btn:active{background:var(--__P__-border)}.__P__-icon-btn:disabled{opacity:.45;cursor:not-allowed}.__P__-icon-btn:before{content:"";position:absolute;inset:-6px}.__P__-icon-btn svg{width:18px;height:18px}.__P__-icon-btn[data-recording=true]{color:var(--__P__-accent-fg);background:color-mix(in srgb,var(--__P__-accent) 12%,transparent);animation:__P__-pulse 1.2s var(--__P__-ease) infinite}@keyframes __P__-pulse{0%,to{box-shadow:0 0 color-mix(in srgb,var(--__P__-accent) 40%,transparent)}50%{box-shadow:0 0 0 6px color-mix(in srgb,var(--__P__-accent) 0%,transparent)}}.__P__-list,.__P__-history,.__P__-module-scroll,.__P__-home-scroll,.__P__-help-list,.__P__-toolui-code,.__P__-sidebar-conversations{scrollbar-width:thin;scrollbar-color:var(--__P__-border-strong) transparent;overscroll-behavior:contain;scrollbar-gutter:stable}.__P__-list::-webkit-scrollbar,.__P__-history::-webkit-scrollbar,.__P__-module-scroll::-webkit-scrollbar,.__P__-home-scroll::-webkit-scrollbar,.__P__-help-list::-webkit-scrollbar,.__P__-toolui-code::-webkit-scrollbar,.__P__-sidebar-conversations::-webkit-scrollbar{width:8px}.__P__-list::-webkit-scrollbar-thumb,.__P__-history::-webkit-scrollbar-thumb,.__P__-module-scroll::-webkit-scrollbar-thumb,.__P__-home-scroll::-webkit-scrollbar-thumb,.__P__-help-list::-webkit-scrollbar-thumb,.__P__-toolui-code::-webkit-scrollbar-thumb,.__P__-sidebar-conversations::-webkit-scrollbar-thumb{background:var(--__P__-border-strong);border-radius:8px}.__P__-list-wrap{position:relative;flex:1;min-height:0;display:flex;flex-direction:column}.__P__-jump{position:absolute;inset-inline:0;bottom:14px;z-index:2;margin-inline:auto;display:flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:999px;border:1px solid var(--__P__-border);background:var(--__P__-bg-elevated);color:var(--__P__-fg);box-shadow:var(--__P__-shadow-panel);cursor:pointer;opacity:.85;transition:opacity var(--__P__-dur-quick) var(--__P__-ease),transform var(--__P__-dur-quick) var(--__P__-ease);animation:__P__-bubble-in var(--__P__-dur-base) var(--__P__-ease)}.__P__-jump:hover{opacity:1}.__P__-jump:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;opacity:1}.__P__-jump:active{transform:translateY(1px)}.__P__-jump svg{width:18px;height:18px}.__P__-list{flex:1;min-height:0;overflow-y:auto;padding:var(--__P__-space-4);padding-bottom:var(--__P__-space-8);display:flex;flex-direction:column;gap:14px}.__P__-list--fade{--__P__-fade-size: 20px;--__P__-fade-top: 0px;--__P__-fade-bottom: 0px;-webkit-mask-image:linear-gradient(to bottom,transparent 0,#000 var(--__P__-fade-top),#000 calc(100% - var(--__P__-fade-bottom)),transparent 100%);mask-image:linear-gradient(to bottom,transparent 0,#000 var(--__P__-fade-top),#000 calc(100% - var(--__P__-fade-bottom)),transparent 100%)}.__P__-list--fade[data-fade-top=true]{--__P__-fade-top: var(--__P__-fade-size)}.__P__-list--fade[data-fade-bottom=true]{--__P__-fade-bottom: var(--__P__-fade-size)}.__P__-list>*{width:100%;max-width:var(--__P__-conversation-max, 768px);margin-inline:auto}.__P__-load-previous,.__P__-history-more{display:flex;justify-content:center}.__P__-load-previous button,.__P__-history-more button{border:0;padding:4px 8px;background:transparent;color:var(--__P__-accent);font:inherit;font-size:var(--__P__-text-sm);font-weight:600;cursor:pointer}.__P__-load-previous button:hover,.__P__-history-more button:hover{text-decoration:underline}.__P__-load-previous button:focus-visible,.__P__-history-more button:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;border-radius:var(--__P__-radius-sm)}.__P__-load-previous button:disabled,.__P__-history-more button:disabled{cursor:wait;opacity:.6}.__P__-date-divider{display:flex;justify-content:center;margin-block:var(--__P__-space-3)}.__P__-date-pill{padding:3px 10px;border-radius:999px;font-size:calc(11px * var(--__P__-text-scale));font-weight:600;color:var(--__P__-fg-muted);background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);box-shadow:var(--__P__-shadow-card)}.__P__-bubble-row{display:flex}.__P__-bubble-row[data-role=user]{justify-content:flex-end}.__P__-bubble-row[data-role=assistant]{justify-content:flex-start}.__P__-bubble{max-width:100%;min-width:0;padding:var(--__P__-space-3) var(--__P__-space-4);border-radius:var(--__P__-radius);line-height:1.6;font-size:calc(14px * var(--__P__-text-scale));word-wrap:break-word;overflow-wrap:break-word;box-shadow:0 1px 2px #0000000a,0 1px 8px -4px #0000000f;animation:__P__-bubble-in var(--__P__-dur-base) var(--__P__-ease)}.__P__-bubble ::selection{background:color-mix(in srgb,var(--__P__-accent) 30%,transparent)}.__P__-bubble-row[data-role=user] .__P__-bubble ::selection{background:#fff6;color:var(--__P__-bubble-user-text)}@keyframes __P__-bubble-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}.__P__-bubble-row[data-role=user] .__P__-bubble{background:var(--__P__-bubble-user);color:var(--__P__-bubble-user-text);border-end-end-radius:5px}.__P__-bubble-row[data-role=assistant] .__P__-bubble{background:var(--__P__-bubble-assistant);color:var(--__P__-bubble-assistant-text);border:1px solid var(--__P__-border);border-end-start-radius:5px}.__P__-bubble-row[data-role=operator] .__P__-bubble{display:flex;align-items:stretch;padding:0;overflow:hidden;background:var(--__P__-bubble-assistant);color:var(--__P__-bubble-assistant-text);border-end-start-radius:5px}.__P__-bubble-row[data-role=operator] .__P__-bubble-col{align-items:flex-start}.__P__-bubble-author{display:flex;flex:0 0 auto;align-items:center;padding:0 .875rem;border-inline-end:1px solid color-mix(in oklab,var(--__P__-accent),transparent 60%);color:var(--__P__-accent);font-size:calc(13px * var(--__P__-text-scale));font-weight:600;letter-spacing:.025em;user-select:none}.__P__-bubble-body{display:flex;flex-wrap:wrap;align-items:flex-start;gap:var(--__P__-space-3) 6px;min-width:0}.__P__-bubble-body>*{flex:1 0 100%;min-width:0}.__P__-bubble-body>.__P__-source,.__P__-bubble-body>.__P__-typing{flex:0 1 auto}.__P__-bubble-row[data-role=operator] .__P__-bubble-body{flex:1 1 auto;min-width:0;padding:var(--__P__-space-3) var(--__P__-space-4)}.__P__-bubble-col{display:flex;flex-direction:column;max-width:85%;min-width:0}.__P__-bubble-row[data-role=user] .__P__-bubble-col{align-items:flex-end}.__P__-bubble-row[data-role=assistant] .__P__-bubble-col{align-items:flex-start}.__P__-bubble-row[data-role=assistant] .__P__-bubble-col:has(.__P__-toolui,.__P__-steps){width:100%}.__P__-bubble-row[data-role=assistant] .__P__-bubble-col:has(.__P__-toolui,.__P__-steps) .__P__-bubble{width:100%}@media(max-width:640px){.__P__-bubble-col{max-width:92%}.__P__-toolui:not(.__P__-toolui-collapsible){padding:var(--__P__-space-3);gap:var(--__P__-space-2)}details.__P__-toolui-collapsible>summary{padding:var(--__P__-space-2) var(--__P__-space-3)}details.__P__-toolui-collapsible>.__P__-toolui-section{margin:var(--__P__-space-3)}.__P__-toolui-section,.__P__-toolui-desc{padding:var(--__P__-space-2) var(--__P__-space-3)}}.__P__-bubble-meta{display:flex;align-items:center;gap:8px;margin-top:2px;padding:0 2px;min-height:24px}.__P__-bubble-actions{display:flex;align-items:center;gap:2px}.__P__-bubble-time{font-size:calc(11px * var(--__P__-text-scale));line-height:1;color:var(--__P__-fg-muted);user-select:none}.__P__-feedback{display:flex;align-items:center;gap:2px}.__P__-msg-action{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;border:0;border-radius:var(--__P__-radius-sm);background:transparent;color:var(--__P__-fg-muted);cursor:pointer;opacity:.65;transition:opacity var(--__P__-dur-quick) var(--__P__-ease),background var(--__P__-dur-quick) var(--__P__-ease),color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-msg-action:hover{opacity:1;background:var(--__P__-bg-elevated);color:var(--__P__-fg)}.__P__-msg-action:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;opacity:1}.__P__-msg-action[data-active=true]{opacity:1;color:var(--__P__-accent-fg)}.__P__-msg-action svg{width:15px;height:15px}.__P__-md>*:first-child{margin-top:0}.__P__-md>*:last-child{margin-bottom:0}.__P__-md p{margin:10px 0}.__P__-md h1,.__P__-md h2,.__P__-md h3,.__P__-md h4,.__P__-md h5,.__P__-md h6{margin:18px 0 8px;line-height:1.3;letter-spacing:-.01em;font-weight:700}.__P__-md h1{font-size:1.4em}.__P__-md h2{font-size:1.22em}.__P__-md h3{font-size:1.08em}.__P__-md h4,.__P__-md h5,.__P__-md h6{font-size:1em}.__P__-md>h1:first-child,.__P__-md>h2:first-child,.__P__-md>h3:first-child,.__P__-md>h4:first-child,.__P__-md>h5:first-child,.__P__-md>h6:first-child{margin-top:0}.__P__-md ul,.__P__-md ol{padding-inline-start:1.5em;margin:10px 0}.__P__-md ul{list-style:disc}.__P__-md ol{list-style:decimal}.__P__-md li{margin:6px 0;padding-inline-start:2px}.__P__-md li::marker{color:var(--__P__-fg-muted)}.__P__-md li>p{margin:6px 0}.__P__-md li>ul,.__P__-md li>ol{margin:6px 0}.__P__-md strong,.__P__-md b{font-weight:650;letter-spacing:-.005em}.__P__-md em,.__P__-md i{font-style:italic}.__P__-md code{font-family:var(--__P__-font-mono);font-size:.86em;padding:1px 6px;border-radius:5px;background:color-mix(in srgb,var(--__P__-accent) 10%,transparent);color:var(--__P__-fg);border:1px solid color-mix(in srgb,var(--__P__-accent) 16%,transparent)}.__P__-md pre{font-family:var(--__P__-font-mono);font-size:calc(12.5px * var(--__P__-text-scale));padding:12px 14px;border-radius:var(--__P__-radius-sm);background:#7f7f7f1f;overflow-x:auto;margin:var(--__P__-space-3) 0;line-height:1.5}.__P__-md pre code{padding:0;background:none}.__P__-file-image,.__P__-file-chip{border-radius:var(--__P__-radius-sm);color:inherit;text-decoration:none}.__P__-file-image{display:block;width:fit-content;max-width:min(100%,240px);overflow:hidden}.__P__-file-image img{max-height:240px;object-fit:cover}.__P__-file-chip{display:flex;align-items:center;gap:var(--__P__-space-2);max-width:min(100%,280px);padding:var(--__P__-space-2);border:1px solid color-mix(in srgb,currentColor 18%,transparent);background:color-mix(in srgb,currentColor 5%,transparent);transition:background var(--__P__-dur-base) var(--__P__-ease)}.__P__-file-chip:hover{background:color-mix(in srgb,currentColor 10%,transparent)}.__P__-file-image:focus-visible,.__P__-file-chip:focus-visible{outline:2px solid currentColor;outline-offset:2px}.__P__-file-chip-icon{flex:none;display:grid;place-items:center;width:32px;height:32px;border-radius:var(--__P__-radius-sm);background:color-mix(in srgb,currentColor 10%,transparent)}.__P__-file-chip-text{display:grid;min-width:0;line-height:1.35}.__P__-file-chip-name{font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.__P__-file-chip-meta{font-size:var(--__P__-text-xs);opacity:.75}.__P__-md a{color:inherit;text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:2px}.__P__-md a:hover{text-decoration-thickness:2px}.__P__-md blockquote{margin:14px 0;padding:6px 14px;border-inline-start:3px solid color-mix(in srgb,var(--__P__-accent) 50%,transparent);background:color-mix(in srgb,var(--__P__-accent) 5%,transparent);border-start-end-radius:var(--__P__-radius-sm);border-end-end-radius:var(--__P__-radius-sm);color:var(--__P__-fg-muted)}.__P__-md blockquote>:first-child{margin-top:0}.__P__-md blockquote>:last-child{margin-bottom:0}.__P__-md hr{border:0;height:1px;background:color-mix(in srgb,currentColor 18%,transparent);margin:var(--__P__-space-4) 0}.__P__-md table{border-collapse:collapse;margin:var(--__P__-space-3) 0;font-size:.95em;display:block;overflow-x:auto;max-width:100%;font-variant-numeric:tabular-nums}.__P__-md th,.__P__-md td{padding:6px 10px;border-bottom:1px solid color-mix(in srgb,currentColor 12%,transparent);text-align:start}.__P__-md th{font-weight:700;background:color-mix(in srgb,currentColor 6%,transparent)}.__P__-md h1+ul,.__P__-md h1+ol,.__P__-md h2+ul,.__P__-md h2+ol,.__P__-md h3+ul,.__P__-md h3+ol,.__P__-md h4+ul,.__P__-md h4+ol{margin-top:var(--__P__-space-1)}.__P__-loading{display:inline-flex;align-items:center;gap:var(--__P__-space-2);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm)}.__P__-loading-spinner{width:14px;height:14px;border-radius:999px;border:2px solid currentColor;border-top-color:transparent;animation:__P__-spin .8s linear infinite}@keyframes __P__-spin{to{transform:rotate(1turn)}}.__P__-typing{display:inline-flex;gap:var(--__P__-space-1);padding:var(--__P__-space-1) 0}.__P__-typing span{width:5px;height:5px;border-radius:999px;background:currentColor;opacity:.4;animation:__P__-blink 1.2s var(--__P__-ease) infinite}.__P__-typing span:nth-child(2){animation-delay:.2s}.__P__-typing span:nth-child(3){animation-delay:.4s}@keyframes __P__-blink{0%,80%,to{opacity:.3;transform:translateY(0)}40%{opacity:1;transform:translateY(-2px)}}.__P__-steps{min-width:0;font-size:var(--__P__-text-sm)}.__P__-steps-head,.__P__-steps-row-head,.__P__-steps-thought-more{display:inline-flex;align-items:center;gap:var(--__P__-space-2);max-width:100%;min-width:0;min-height:28px;padding:0;border:0;background:none;color:var(--__P__-fg-muted);font:inherit;text-align:start;cursor:pointer;-webkit-tap-highlight-color:transparent}.__P__-steps-head:hover,.__P__-steps-row-head:hover,.__P__-steps-thought-more:hover{color:var(--__P__-fg)}.__P__-steps-head:focus-visible,.__P__-steps-row-head:focus-visible,.__P__-steps-thought-toggle:focus-visible,.__P__-steps-thought-more:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;border-radius:var(--__P__-radius-sm)}.__P__-steps-icon,.__P__-steps-row-icon{display:inline-flex;flex:none;align-items:center;justify-content:center;width:16px;height:16px}.__P__-steps-icon svg,.__P__-steps-row-icon svg{width:14px;height:14px}.__P__-steps-label,.__P__-steps-row-label{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-steps-sep{margin-inline:var(--__P__-space-1)}.__P__-steps-name .__P__-steps-count{margin-inline-start:var(--__P__-space-1)}.__P__-steps-count,.__P__-steps-failed,.__P__-steps-denied,.__P__-steps-time{flex:none;font-variant-numeric:tabular-nums}.__P__-steps-failed{color:var(--__P__-danger-text)}.__P__-steps-denied{color:var(--__P__-fg-muted)}.__P__-steps-chevron{display:inline-flex;flex:none;width:16px;height:16px;transition:transform var(--__P__-dur-quick) var(--__P__-ease)}.__P__-steps-chevron svg{width:16px;height:16px}.__P__-steps-chevron[data-open=true]{transform:rotate(180deg)}.__P__-steps-list{position:relative;display:flex;flex-direction:column;gap:var(--__P__-space-1);margin:var(--__P__-space-1) 0 0;padding:0;list-style:none}.__P__-steps-list:before{content:"";position:absolute;inset-block:0;inset-inline-start:7px;width:2px;border-radius:1px;background:var(--__P__-border)}.__P__-steps-row{position:relative;display:grid;grid-template-columns:16px minmax(0,1fr);column-gap:var(--__P__-space-2);align-items:start}.__P__-steps-row .__P__-steps-row-icon{margin-block:6px;border-radius:999px;background:var(--__P__-bubble-assistant);color:var(--__P__-fg-muted)}.__P__-steps-row[data-status=error] .__P__-steps-row-icon{color:var(--__P__-danger-text)}.__P__-steps-row-main{display:flex;flex-direction:column;align-items:flex-start;min-width:0}.__P__-steps-row-name{color:var(--__P__-fg);font-weight:500}.__P__-steps-row-summary{margin-inline-start:var(--__P__-space-2);color:var(--__P__-fg-muted)}.__P__-steps-row-body{display:flex;flex-direction:column;gap:var(--__P__-space-2);width:100%;margin:var(--__P__-space-1) 0 var(--__P__-space-2)}.__P__-steps-body{display:grid;grid-template-rows:0fr;transition:grid-template-rows .2s ease-out}.__P__-steps-body[data-open=true]{grid-template-rows:1fr}.__P__-steps-body-inner{min-height:0;overflow:hidden}.__P__-steps-live{min-width:0;overflow:hidden;text-overflow:ellipsis;background:linear-gradient(90deg,var(--__P__-fg-muted) 0%,var(--__P__-fg) 50%,var(--__P__-fg-muted) 100%) 0 0 / 200% 100%;background-clip:text;-webkit-background-clip:text;color:transparent;animation:__P__-steps-shimmer 2s linear infinite}@keyframes __P__-steps-shimmer{to{background-position:-200% 0}}@media(prefers-reduced-motion:reduce){.__P__-steps-body,.__P__-steps-chevron{transition:none}.__P__-steps-live{background:none;color:var(--__P__-fg-muted);animation:none}}.__P__-steps-thought-label,.__P__-steps-stopped-label{display:inline-flex;align-items:center;min-height:28px;color:var(--__P__-fg-muted)}.__P__-steps-thought-text{width:100%;color:var(--__P__-fg-muted)}.__P__-steps-thought-text[data-clamped=true]{max-height:calc(3 * 1.6em);overflow:hidden;mask-image:linear-gradient(to bottom,#000 60%,transparent);cursor:pointer}.__P__-steps-thought-toggle{padding:0;border:0;background:none;font:inherit;text-align:start;cursor:pointer}.__P__-steps-thought-toggle:hover{color:var(--__P__-fg)}.__P__-steps-thought-more{min-height:24px;font-size:var(--__P__-text-xs)}.__P__-reasoning-body{color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm)}.__P__-reasoning-body>:first-child{margin-top:0}.__P__-reasoning-body>:last-child{margin-bottom:0}.__P__-source{display:inline-flex;align-items:center;gap:6px;max-width:100%;padding:var(--__P__-space-1) var(--__P__-space-2);border-radius:999px;background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);text-decoration:none}a.__P__-source:hover{color:var(--__P__-fg);border-color:var(--__P__-accent)}.__P__-source-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-composer{border-top:1px solid var(--__P__-border);padding:10px 12px;background:var(--__P__-bg);display:flex;flex-direction:column;gap:var(--__P__-space-2)}.__P__-composer>*{width:100%;max-width:var(--__P__-conversation-max, 768px);margin-inline:auto}.__P__-compaction-status{width:100%;padding:10px 14px;justify-content:center;font-size:var(--__P__-text-xs)}.__P__-message-queue{display:flex;max-height:112px;flex-direction:column;gap:var(--__P__-space-1);overflow-y:auto}.__P__-attachment-chip.__P__-queued-message{width:100%;max-width:none}.__P__-queued-text{min-width:0;flex:1}.__P__-composer-row{display:flex;align-items:flex-end;gap:6px}.__P__-textarea{flex:1;--__P__-textarea-base-height: 40px;height:var(--__P__-textarea-base-height);max-height:160px;padding:10px 12px;border-radius:var(--__P__-radius);background:var(--__P__-bg-elevated);border:1px solid transparent;font-size:calc(14px * var(--__P__-text-scale));line-height:1.4;transition:height var(--__P__-dur-quick) var(--__P__-ease),border-color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-textarea:focus-visible{outline:none;border-color:var(--__P__-focus)}@media(pointer:coarse){.__P__-textarea{--__P__-textarea-base-height: 44px}}.__P__-send{width:40px;height:40px;display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;transition:opacity var(--__P__-dur-quick) var(--__P__-ease),transform var(--__P__-dur-quick) var(--__P__-ease),background var(--__P__-dur-quick) var(--__P__-ease)}.__P__-send[data-shape=circle]{border-radius:999px}.__P__-send[data-shape=square]{border-radius:var(--__P__-radius-sm)}.__P__-send[data-shape=pill]{width:auto;padding:0 18px;border-radius:999px}.__P__-send[data-variant=filled]{background:var(--__P__-accent);color:var(--__P__-accent-text)}.__P__-send[data-variant=outline]{background:transparent;color:var(--__P__-accent-fg);border-color:var(--__P__-accent)}.__P__-send[data-variant=outline]:not(:disabled):hover{background:color-mix(in srgb,var(--__P__-accent) 10%,transparent)}.__P__-send[data-variant=ghost]{background:transparent;color:var(--__P__-accent-fg)}.__P__-send[data-variant=ghost]:not(:disabled):hover{background:color-mix(in srgb,var(--__P__-accent) 8%,transparent)}.__P__-send:disabled{opacity:.4;cursor:not-allowed}.__P__-send:not(:disabled):hover{transform:translateY(-1px)}.__P__-send:not(:disabled):active{transform:translateY(0)}.__P__-send:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-send svg{width:18px;height:18px}.__P__-composer-actions{display:flex;gap:var(--__P__-space-1);flex-wrap:wrap}.__P__-attachments{display:flex;flex-wrap:wrap;gap:6px}.__P__-attachment-chip{display:inline-flex;align-items:center;gap:6px;padding:var(--__P__-space-1) var(--__P__-space-2) var(--__P__-space-1) var(--__P__-space-1);border-radius:999px;background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);font-size:var(--__P__-text-xs);max-width:200px}.__P__-attachment-thumb{width:24px;height:24px;border-radius:999px;object-fit:cover;background:var(--__P__-border)}.__P__-attachment-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.__P__-attachment-remove{width:18px;height:18px;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;color:var(--__P__-fg-muted)}.__P__-attachment-remove:hover{background:var(--__P__-border);color:var(--__P__-fg)}.__P__-dropzone{position:absolute;inset:8px;border:2px dashed var(--__P__-accent);border-radius:var(--__P__-radius);background:color-mix(in srgb,var(--__P__-accent) 8%,transparent);display:flex;align-items:center;justify-content:center;font-weight:600;color:var(--__P__-accent-fg);pointer-events:none;z-index:10;animation:__P__-fade-in var(--__P__-dur-quick) var(--__P__-ease)}@keyframes __P__-fade-in{0%{opacity:0}to{opacity:1}}.__P__-error{display:flex;align-items:center;gap:var(--__P__-space-2);padding:8px 12px;border-radius:var(--__P__-radius-sm);background:color-mix(in oklab,var(--__P__-danger) 8%,var(--__P__-bg-elevated));border:1px solid color-mix(in oklab,var(--__P__-danger) 20%,transparent);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm)}.__P__-error-icon{display:inline-flex;flex:none;width:16px;height:16px;color:var(--__P__-danger-text)}.__P__-error-icon svg{width:16px;height:16px}.__P__-error-text{min-width:0}.__P__-error-retry{flex:none;margin-inline-start:auto;min-height:28px;border:0;background:none;padding:0;color:var(--__P__-accent-fg);font:inherit;font-size:var(--__P__-text-sm);font-weight:600;text-decoration:underline;white-space:nowrap;cursor:pointer}.__P__-error-retry:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;border-radius:var(--__P__-radius-sm)}.__P__-history{flex:1;overflow-y:auto;padding:var(--__P__-space-2) var(--__P__-space-1) var(--__P__-space-3)}.__P__-history-footer{flex:none;padding:var(--__P__-space-2) var(--__P__-space-3) var(--__P__-space-3);border-top:1px solid var(--__P__-border);background:var(--__P__-surface)}.__P__-history-new{width:100%;display:flex;align-items:center;justify-content:center;gap:var(--__P__-space-2);padding:var(--__P__-space-2) var(--__P__-space-3);border:none;border-radius:var(--__P__-radius-md);background:var(--__P__-accent);color:var(--__P__-on-accent);cursor:pointer;font-size:var(--__P__-text-sm);font-weight:600;transition:filter var(--__P__-dur-quick) var(--__P__-ease-out),transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-history-new svg{width:16px;height:16px}.__P__-history-new:hover{filter:brightness(1.08)}.__P__-history-new:active{transform:translateY(1px)}.__P__-history-new:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-history-empty{flex:1;display:flex;align-items:center;justify-content:center;padding:40px 16px;color:var(--__P__-fg-muted);font-size:calc(14px * var(--__P__-text-scale));text-align:center}.__P__-history-group{display:flex;flex-direction:column;padding:0 var(--__P__-space-3)}.__P__-history-heading{font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted);padding:14px 4px 8px;text-transform:uppercase;letter-spacing:.04em}.__P__-history-card{display:flex;flex-direction:column;background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-lg, 14px);overflow:hidden}.__P__-history-card>[role=listitem]{display:flex;flex-direction:column}.__P__-history-item{all:unset;display:flex;align-items:center;gap:var(--__P__-space-3);padding:12px var(--__P__-space-3);cursor:pointer;transition:background var(--__P__-dur-base) var(--__P__-ease)}.__P__-history-card>*+*{border-top:1px solid var(--__P__-border)}.__P__-history-item:hover{background:var(--__P__-bg-elevated)}.__P__-history-item:focus-visible{background:var(--__P__-bg-elevated);outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-history-avatar{flex:none;display:grid;place-items:center;width:36px;height:36px;border-radius:var(--__P__-radius-md);background:color-mix(in oklab,var(--__P__-accent) 12%,transparent);color:var(--__P__-accent-fg)}.__P__-history-avatar svg{width:18px;height:18px}.__P__-history-body{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.__P__-history-row{display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-2)}.__P__-history-title{flex:1;min-width:0;font-size:calc(14px * var(--__P__-text-scale));font-weight:500;color:var(--__P__-fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-history-time{flex:none;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted)}.__P__-history-preview{flex:1;min-width:0;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-history-dot{flex:none;width:8px;height:8px;border-radius:50%;background:var(--__P__-accent)}.__P__-history-item[data-unread=true] .__P__-history-title{font-weight:600}.__P__-history-item[data-closed=true] .__P__-history-title{color:var(--__P__-fg-muted)}.__P__-history-item-skeleton{cursor:default;pointer-events:none}.__P__-skeleton{display:block;border-radius:4px;background:linear-gradient(90deg,color-mix(in oklab,var(--__P__-fg) 9%,transparent) 30%,color-mix(in oklab,var(--__P__-fg) 17%,transparent),color-mix(in oklab,var(--__P__-fg) 9%,transparent) 70%);background-size:200% 100%;animation:__P__-skeleton-shimmer 1.8s ease-in-out infinite}.__P__-history-avatar.__P__-skeleton{border-radius:var(--__P__-radius-md)}.__P__-skeleton-heading{width:52px;height:8px}.__P__-skeleton-title{width:55%;height:12px}.__P__-skeleton-time{width:34px;height:10px}.__P__-skeleton-preview{width:80%;height:10px}@keyframes __P__-skeleton-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@media(prefers-reduced-motion:reduce){.__P__-skeleton{animation:none}}.__P__-list-loading{margin:auto;padding:var(--__P__-space-6) var(--__P__-space-4);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);text-align:center}.__P__-readonly-banner{display:flex;flex-direction:column;align-items:center;gap:10px;padding:14px 12px;margin:0 var(--__P__-space-3) var(--__P__-space-3);border-radius:var(--__P__-radius-md);background:var(--__P__-bg-elevated);color:var(--__P__-fg-muted);text-align:center;font-size:var(--__P__-text-sm)}.__P__-readonly-label{line-height:1.4}.__P__-readonly-cta{appearance:none;border:0;cursor:pointer;padding:var(--__P__-space-2) var(--__P__-space-4);border-radius:999px;background:var(--__P__-accent);color:var(--__P__-accent-text, #fff);font:inherit;font-weight:600;font-size:var(--__P__-text-sm);transition:filter var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-readonly-cta:hover,.__P__-readonly-cta:focus-visible{filter:brightness(1.1)}.__P__-operator-banner{display:flex;align-items:center;justify-content:center;gap:8px;margin:0 var(--__P__-space-3) var(--__P__-space-1);padding:8px 12px;border-radius:var(--__P__-radius-md);background:color-mix(in oklab,var(--__P__-bg-elevated),var(--__P__-accent) 6%);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);line-height:1.3;text-align:center}.__P__-operator-pulse{flex:0 0 auto;width:8px;height:8px;border-radius:50%;background:var(--__P__-accent)}.__P__-operator-banner[data-mode=awaiting-operator] .__P__-operator-pulse{animation:__P__-operator-pulse 1.4s var(--__P__-ease-out) infinite}.__P__-cancel-operator-request{flex:0 0 auto;padding:0;border:0;background:none;color:var(--__P__-accent);font:inherit;font-weight:600;text-decoration:underline;text-underline-offset:2px;cursor:pointer}.__P__-cancel-operator-request:hover{opacity:.8}.__P__-cancel-operator-request:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px;border-radius:var(--__P__-radius-sm)}@keyframes __P__-operator-pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.4;transform:scale(.7)}}.__P__-readonly-cta:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px}.__P__-composer-footer{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;padding:10px 16px;margin:0 var(--__P__-space-3);border-top:1px solid var(--__P__-border);text-align:center;font-size:calc(11px * var(--__P__-text-scale));line-height:1.4;color:var(--__P__-fg-muted)}.__P__-disclaimer{max-width:320px;margin:0 auto;opacity:.9;letter-spacing:.01em}.__P__-poweredby{display:inline-flex;align-items:center;justify-content:center;gap:6px;color:inherit;text-decoration:none;opacity:.7;transition:opacity var(--__P__-dur-base) var(--__P__-ease);font-size:calc(11px * var(--__P__-text-scale));letter-spacing:.02em}.__P__-poweredby:hover{opacity:1}.__P__-poweredby-logo{height:12px;width:auto;display:inline-block;vertical-align:middle}.__P__-poweredby-bar{flex:none;display:flex;align-items:center;justify-content:center;padding:6px 16px;border-top:1px solid var(--__P__-border);background:var(--__P__-bg-elevated)}.__P__-menu-wrap{position:relative;display:inline-flex}.__P__-menu{position:absolute;top:100%;inset-inline-end:0;margin-top:6px;min-width:200px;padding:6px;background:var(--__P__-bg);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);box-shadow:var(--__P__-shadow-panel);z-index:10;display:flex;flex-direction:column;gap:2px;animation:__P__-menu-in var(--__P__-dur-base) var(--__P__-ease)}@media(prefers-reduced-motion:reduce){.__P__-menu{animation:none}}@keyframes __P__-menu-in{0%{opacity:0;transform:translateY(-4px) scale(.98);transform-origin:top right}to{opacity:1;transform:none}}.__P__-menu-item{all:unset;display:flex;align-items:center;gap:10px;padding:8px 10px;font-size:var(--__P__-text-sm);color:var(--__P__-fg);border-radius:var(--__P__-radius-sm);cursor:pointer;user-select:none}.__P__-menu-item:hover{background:var(--__P__-bg-elevated)}.__P__-menu-item:focus-visible{background:var(--__P__-bg-elevated);outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-menu-item[disabled]{opacity:.45;cursor:not-allowed}.__P__-menu-icon{display:inline-flex;width:16px;height:16px;color:var(--__P__-fg-muted)}.__P__-menu-icon svg{width:16px;height:16px}.__P__-menu-label{flex:1}.__P__-menu-check{display:inline-flex;color:var(--__P__-accent-fg)}.__P__-menu-check svg{width:14px;height:14px}.__P__-menu-item-segmented{cursor:default}.__P__-menu-item-segmented:hover{background:transparent}.__P__-segmented{display:inline-flex;gap:2px;padding:2px;background:var(--__P__-bg-elevated);border-radius:var(--__P__-radius-sm)}.__P__-segment{all:unset;min-width:26px;padding:3px 8px;font-size:var(--__P__-text-xs);font-weight:600;letter-spacing:.02em;text-align:center;color:var(--__P__-fg-muted);border-radius:calc(var(--__P__-radius-sm) - 2px);cursor:pointer;transition:color .12s ease,background .12s ease}.__P__-segment:hover{color:var(--__P__-fg)}.__P__-segment[data-on=true]{background:var(--__P__-bg);color:var(--__P__-accent-fg);box-shadow:var(--__P__-shadow-card)}.__P__-segment:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-resize-grip{position:absolute;width:18px;height:18px;display:flex;align-items:center;justify-content:center;color:var(--__P__-fg-muted);opacity:.45;transition:opacity var(--__P__-dur-base) var(--__P__-ease);z-index:2;touch-action:none;user-select:none}.__P__-resize-grip:hover,.__P__-resize-grip:focus-visible{opacity:1}.__P__-resize-grip svg{width:10px;height:10px}.__P__-resize-grip--bottom-left{bottom:2px;left:2px;cursor:nesw-resize;transform:scaleX(-1)}.__P__-resize-grip--bottom-right{bottom:2px;right:2px;cursor:nwse-resize}.__P__-resize-grip--top-left{top:2px;left:2px;cursor:nwse-resize;transform:rotate(180deg)}.__P__-resize-grip--top-right{top:2px;right:2px;cursor:nesw-resize;transform:scaleY(-1)}:host(:not([data-mode="open"])) .__P__-resize-grip{display:none}.__P__-messenger{display:flex;flex-direction:column;overflow:hidden}.__P__-messenger-body,.__P__-messenger-pane{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}.__P__-messenger-pane[hidden]{display:none}@keyframes __P__-view-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}.__P__-module{display:flex;flex-direction:column;height:100%;min-height:0}@media(prefers-reduced-motion:no-preference){.__P__-module,.__P__-history{animation:__P__-view-in .18s var(--__P__-ease-out)}}.__P__-module-scroll{flex:1;min-height:0;overflow-y:auto;padding:var(--__P__-space-3);display:flex;flex-direction:column;gap:var(--__P__-space-3)}.__P__-home{container-type:inline-size;background:radial-gradient(125% 65% at 88% 0%,color-mix(in srgb,#fff 16%,transparent),transparent 55%),linear-gradient(180deg,var(--__P__-accent) 0%,var(--__P__-accent) 22%,color-mix(in srgb,var(--__P__-accent) 28%,var(--__P__-surface)) 44%,var(--__P__-surface) 70%);border-radius:var(--__P__-radius-lg) var(--__P__-radius-lg) 0 0}.__P__-home-scroll{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;background:transparent}.__P__-home-cards{display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:4px 14px 16px}.__P__-module-pad{padding:var(--__P__-space-3) var(--__P__-space-3) 0}.__P__-module-empty{display:flex;flex-direction:column;align-items:center;gap:var(--__P__-space-3);padding:var(--__P__-space-8) var(--__P__-space-4);text-align:center;color:var(--__P__-fg-muted);font-size:var(--__P__-text-base)}.__P__-module-retry{padding:var(--__P__-space-2) var(--__P__-space-4);border:1px solid var(--__P__-border-strong);border-radius:var(--__P__-radius-sm);color:var(--__P__-fg);font-weight:600;cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease-out),border-color var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-module-retry:hover{background:var(--__P__-hover);border-color:var(--__P__-accent)}.__P__-module-retry:active{background:var(--__P__-border)}.__P__-module-retry:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-help-list{flex:1;min-height:0;overflow-y:auto;padding-bottom:var(--__P__-space-3)}.__P__-help-group{display:flex;flex-direction:column}.__P__-help-section-title{position:sticky;top:0;z-index:1;margin:0;padding:var(--__P__-space-3) var(--__P__-space-5) var(--__P__-space-2);font-size:var(--__P__-text-xs);font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--__P__-fg-muted);background:var(--__P__-bg)}.__P__-help-card{margin:0 var(--__P__-space-3) var(--__P__-space-3);background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);overflow:hidden}.__P__-help-card .__P__-list-row{border-bottom:0;border-radius:0}.__P__-help-card .__P__-list-row+.__P__-list-row{border-top:1px solid var(--__P__-border)}.__P__-help-more{justify-content:center;color:var(--__P__-accent-fg);font-weight:600}.__P__-tabbar{display:flex;border-top:1px solid var(--__P__-border);background:var(--__P__-bg-elevated);flex-shrink:0}.__P__-tab{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--__P__-space-1);min-height:48px;padding:var(--__P__-space-2) var(--__P__-space-1);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600;transition:color var(--__P__-dur-quick) var(--__P__-ease-out)}@media(hover:hover){.__P__-tab:hover{background:var(--__P__-hover)}}.__P__-tab[aria-selected=true]{color:var(--__P__-accent-fg)}.__P__-tab:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-tab:active{background:var(--__P__-hover)}.__P__-tab-icon{position:relative;display:inline-flex}.__P__-tab-icon svg{width:22px;height:22px}.__P__-tab-badge{position:absolute;top:-2px;left:calc(50% + 6px);width:8px;height:8px;border-radius:50%;background:var(--__P__-accent);box-shadow:0 0 0 2px var(--__P__-bg-elevated)}.__P__-home-hero{flex-shrink:0;padding:var(--__P__-space-5) var(--__P__-space-5) var(--__P__-space-3);color:var(--__P__-on-accent);--__P__-focus: var(--__P__-on-accent)}.__P__-home-hero-top{display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-3);min-height:32px}.__P__-home-brand{font-size:clamp(calc(12px * var(--__P__-text-scale)),calc(3.2cqi * var(--__P__-text-scale)),calc(14px * var(--__P__-text-scale)));font-weight:600;letter-spacing:.01em;color:color-mix(in srgb,#fff 82%,transparent);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.__P__-home-brand-spacer{flex:1}.__P__-home-hero-actions{display:flex;align-items:center;gap:var(--__P__-space-2);flex-shrink:0}.__P__-home-hero-actions .__P__-icon-btn{color:#fff}.__P__-home-hero-actions .__P__-icon-btn:hover{background:color-mix(in srgb,#fff 18%,transparent);color:#fff}.__P__-home-hero-actions .__P__-icon-btn:active{background:color-mix(in srgb,#fff 26%,transparent)}.__P__-home-greeting{margin:28px 0 0;font-family:var(--__P__-font-display);font-size:clamp(calc(19px * var(--__P__-text-scale)),calc(5.5cqi * var(--__P__-text-scale)),var(--__P__-text-2xl));font-weight:800;line-height:1.18;letter-spacing:-.01em;overflow-wrap:anywhere}.__P__-home-lead{margin:10px 0 0;font-family:var(--__P__-font-display);font-size:clamp(calc(15px * var(--__P__-text-scale)),calc(4.2cqi * var(--__P__-text-scale)),var(--__P__-text-xl));font-weight:600;line-height:1.25;letter-spacing:-.005em;color:color-mix(in srgb,var(--__P__-on-accent) 78%,transparent);overflow-wrap:anywhere}.__P__-home-avatars{display:flex}.__P__-home-avatar{width:30px;height:30px;border-radius:var(--__P__-radius-md);overflow:hidden;margin-inline-start:-10px;border:2px solid color-mix(in srgb,#fff 92%,transparent);box-shadow:0 1px 3px #0000002e;background:var(--__P__-surface);display:inline-flex;align-items:center;justify-content:center;font-size:var(--__P__-text-xs);font-weight:700;color:var(--__P__-fg)}.__P__-home-avatar:first-child{margin-inline-start:0}.__P__-home-avatar img{width:100%;height:100%;object-fit:cover}.__P__-home-content{background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);box-shadow:var(--__P__-shadow-card);overflow:hidden}.__P__-home-content-title{padding:var(--__P__-space-4) var(--__P__-space-4) var(--__P__-space-3);font-size:var(--__P__-text-sm);font-weight:700}.__P__-home-content-list{display:flex;flex-direction:column;padding:0 var(--__P__-space-2) var(--__P__-space-2)}.__P__-home-content-list .__P__-list-row+.__P__-list-row{border-top:1px solid var(--__P__-border)}.__P__-home-card{display:block;width:100%;text-align:start;background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);padding:var(--__P__-space-4);box-shadow:var(--__P__-shadow-card)}.__P__-home-card[data-interactive=true]{cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease-out),transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-home-card[data-interactive=true]:hover{background:var(--__P__-bg-elevated)}.__P__-home-card[data-interactive=true]:active{transform:translateY(1px)}.__P__-home-card[data-interactive=true]:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-home-recent-row{display:flex;align-items:center;gap:var(--__P__-space-3)}.__P__-home-recent-avatar{display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;flex-shrink:0;border-radius:var(--__P__-radius-md);background:color-mix(in oklch,var(--__P__-accent) 14%,transparent);color:var(--__P__-accent-fg)}.__P__-home-recent-avatar svg{width:20px;height:20px}.__P__-home-recent-body{display:flex;flex-direction:column;gap:3px;min-width:0;flex:1;line-height:1.45}.__P__-home-recent-title{font-weight:600;font-size:calc(14px * var(--__P__-text-scale))}.__P__-home-recent-preview{color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.__P__-home-recent-dot{width:8px;height:8px;border-radius:999px;background:var(--__P__-accent);flex-shrink:0}.__P__-home-recent-row[data-unread=true] .__P__-home-recent-title{font-weight:700}.__P__-home-status{display:flex;align-items:center;gap:var(--__P__-space-3)}.__P__-home-status-icon svg{width:22px;height:22px;color:var(--__P__-success)}.__P__-home-status[data-level=degraded] .__P__-home-status-icon svg{color:var(--__P__-warning)}.__P__-home-status[data-level=down] .__P__-home-status-icon svg{color:var(--__P__-danger)}.__P__-home-status-text{font-weight:600;font-size:calc(14px * var(--__P__-text-scale))}.__P__-home-search{display:flex;align-items:center;gap:var(--__P__-space-2);width:100%;padding:var(--__P__-space-3) var(--__P__-space-4);border-radius:var(--__P__-radius);border:1px solid var(--__P__-border);background:var(--__P__-surface);text-align:start}.__P__-home-search[data-input=true]{background:var(--__P__-bg-elevated)}.__P__-home-search:hover{border-color:var(--__P__-border-strong)}.__P__-home-search:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-home-search[data-input=true]:focus-within{outline:none;border-color:var(--__P__-focus)}.__P__-home-search-text{flex:1;color:var(--__P__-fg-muted);font-size:calc(14px * var(--__P__-text-scale))}.__P__-home-search-input{flex:1;border:0;background:transparent;font-size:calc(14px * var(--__P__-text-scale));color:var(--__P__-fg);outline:none}.__P__-home-search-input:focus-visible{outline:none}.__P__-home-search-icon svg{width:18px;height:18px;color:var(--__P__-accent-fg)}.__P__-home-ask{padding-block:6px;padding-inline-end:6px}.__P__-home-ask .__P__-send{width:32px;height:32px;flex-shrink:0}.__P__-home-ask .__P__-send[data-shape=pill]{width:auto;padding:0 14px}.__P__-home-ask .__P__-send svg{width:16px;height:16px}.__P__-list-row{display:flex;align-items:center;gap:var(--__P__-space-3);width:100%;min-height:44px;text-align:start;padding:var(--__P__-space-3) var(--__P__-space-2);border-radius:var(--__P__-radius-sm)}.__P__-list-row:hover{background:var(--__P__-hover)}.__P__-list-row:active{background:var(--__P__-border)}.__P__-list-row:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-list-row-body{display:flex;flex-direction:column;min-width:0;flex:1}.__P__-list-row-title{font-weight:600;font-size:var(--__P__-text-md);line-height:1.35}.__P__-list-row-sub{color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);margin-top:var(--__P__-space-1);line-height:1.45;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.__P__-list-row-chevron svg{width:18px;height:18px;color:var(--__P__-accent-fg);flex-shrink:0}.__P__-back-header{display:flex;align-items:center;gap:var(--__P__-space-2);padding:10px 12px;border-bottom:1px solid var(--__P__-border);flex-shrink:0}.__P__-back-title{flex:1;text-align:center;font-size:var(--__P__-text-md);font-weight:700;margin:0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-back-spacer{width:32px;height:1px}.__P__-history>*,.__P__-home-scroll>*,.__P__-module-scroll>*,.__P__-help-list>*,.__P__-history-footer>*,.__P__-module-pad{width:100%;max-width:var(--__P__-conversation-max, 768px);margin-inline:auto}.__P__-header,.__P__-back-header{padding-inline:max(12px,calc((100% - var(--__P__-conversation-max, 768px)) / 2))}.__P__-tabbar{padding-inline:max(0px,calc((100% - var(--__P__-conversation-max, 768px)) / 2))}.__P__-content{display:flex;flex-direction:column;gap:14px;width:100%;max-width:68ch;margin:0 auto}.__P__-content-hero{width:100%;border-radius:var(--__P__-radius)}.__P__-content-subtitle{color:var(--__P__-fg-muted);margin:0}.__P__-content-vote{display:flex;align-items:center;flex-wrap:wrap;gap:var(--__P__-space-2);padding-top:var(--__P__-space-3);border-top:1px solid var(--__P__-border)}.__P__-content-frame{flex:1;min-height:0;width:100%;border:0;background:#fff}.__P__-news-list{display:flex;flex-direction:column;gap:var(--__P__-space-3)}.__P__-news-card{display:block;width:100%;text-align:start;line-height:1.45;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);overflow:hidden;background:var(--__P__-surface);transition:background var(--__P__-dur-quick) var(--__P__-ease-out),transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-news-card:hover{background:var(--__P__-bg-elevated)}.__P__-news-card:active{transform:translateY(1px)}.__P__-news-card:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-news-hero{width:100%;display:block}.__P__-news-body{display:flex;flex-direction:column;gap:6px;padding:14px 16px}.__P__-news-title{font-weight:700;font-size:var(--__P__-text-md)}.__P__-news-meta{display:flex;flex-wrap:wrap;align-items:center;gap:6px;color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm)}.__P__-news-tag{padding:1px 8px;border-radius:6px;background:var(--__P__-hover);color:var(--__P__-fg);font-size:calc(12px * var(--__P__-text-scale));white-space:nowrap}.__P__-news-more{display:flex;align-items:center;justify-content:center;gap:var(--__P__-space-2);width:100%;min-height:44px;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);background:var(--__P__-surface);color:var(--__P__-accent-fg);font-weight:600}.__P__-news-more:hover{background:var(--__P__-bg-elevated)}.__P__-news-more:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-news-summary{color:var(--__P__-fg-muted);font-size:calc(14px * var(--__P__-text-scale));display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.__P__-modules-empty{display:flex;align-items:center;justify-content:center;position:relative}.__P__-modules-empty-close{position:absolute;top:12px;inset-inline-end:12px}.__P__-modules-empty-text{color:var(--__P__-fg-muted);font-size:var(--__P__-text-base)}.__P__-form{display:flex;flex-direction:column;gap:var(--__P__-space-4)}.__P__-field{display:flex;flex-direction:column;gap:6px}.__P__-field-head{display:flex;flex-wrap:wrap;align-items:baseline;gap:var(--__P__-space-2)}.__P__-field-label{font-size:var(--__P__-text-sm);font-weight:600;color:var(--__P__-fg)}.__P__-field-req{color:var(--__P__-danger)}.__P__-field-type{flex-shrink:0;align-self:center;margin-inline-start:auto;border:1px solid var(--__P__-border);border-radius:5px;background:color-mix(in oklab,var(--__P__-fg-muted) 9%,transparent);padding:1px 7px;font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted);white-space:nowrap}.__P__-field-input{width:100%;min-width:0;max-width:100%;box-sizing:border-box;padding:10px var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);color:var(--__P__-fg);font:inherit;font-size:var(--__P__-text-sm);resize:vertical;transition:border-color var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-field-input:focus-visible{outline:none;border-color:var(--__P__-accent)}.__P__-field[data-invalid=true] .__P__-field-input{border-color:var(--__P__-danger)}.__P__-field-input[type=date],.__P__-field-input[type=time]{appearance:none;-webkit-appearance:none}@media(pointer:coarse){.__P__-textarea,.__P__-home-search-input,.__P__-field-input{font-size:max(16px,calc(16px * var(--__P__-text-scale)))}}.__P__-field-hint{font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted)}.__P__-field-error{font-size:var(--__P__-text-xs);color:var(--__P__-danger)}.__P__-field-choices{display:flex;flex-direction:column;gap:10px;padding-top:2px}.__P__-choice{display:flex;align-items:flex-start;gap:10px;font-size:var(--__P__-text-sm);color:var(--__P__-fg);cursor:pointer}.__P__-choice input{margin-top:2px;accent-color:var(--__P__-accent)}.__P__-form-actions{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:var(--__P__-space-2);margin-top:var(--__P__-space-2)}.__P__-form-hint{flex:1 1 auto;min-width:6rem;margin-inline-end:auto;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted)}.__P__-form-submit{padding:var(--__P__-space-2) var(--__P__-space-4);border:none;border-radius:var(--__P__-radius-md);background:var(--__P__-accent);color:var(--__P__-accent-text, #fff);font:inherit;font-weight:600;font-size:var(--__P__-text-sm);white-space:nowrap;flex-shrink:0;cursor:pointer;transition:filter var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-form-submit:hover:not(:disabled){filter:brightness(1.06)}.__P__-form-submit:disabled{opacity:.6;cursor:default}.__P__-form-skip{padding:var(--__P__-space-2) var(--__P__-space-4);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:transparent;color:var(--__P__-fg-muted);font:inherit;font-size:var(--__P__-text-sm);white-space:nowrap;flex-shrink:0;cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-form-skip:hover:not(:disabled){background:var(--__P__-bg-elevated)}@media(max-width:640px){.__P__-form-hint{flex-basis:100%;margin-inline-end:0;font-size:var(--__P__-text-xs)}.__P__-form-submit,.__P__-form-skip{flex:1 1 0;text-align:center}}.__P__-form-gate{display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:var(--__P__-space-4);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:var(--__P__-bg-elevated)}.__P__-form-gate-title{margin:0;font-size:var(--__P__-text-base);font-weight:700;color:var(--__P__-fg)}.__P__-form-gate-desc{margin:0 0 var(--__P__-space-1);font-size:var(--__P__-text-sm);color:var(--__P__-fg-muted)}.__P__-form-done{display:flex;align-items:center;justify-content:center;gap:6px;padding:6px 12px;border:1px dashed var(--__P__-border);border-radius:999px;align-self:center;font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted)}.__P__-form-done svg{width:14px;height:14px;color:var(--__P__-success, #22c55e)}.__P__-form-done[data-outcome=skipped] svg{color:var(--__P__-fg-muted)}.__P__-form-done-fill{border:0;background:none;padding:0 2px;cursor:pointer;font:inherit;font-weight:600;color:var(--__P__-accent-fg)}.__P__-form-done-fill:hover{text-decoration:underline}details.__P__-form-done{display:block;padding:0;border-radius:var(--__P__-radius-md)}details[open].__P__-form-done{width:min(100%,420px);background:var(--__P__-surface)}.__P__-form-done-summary{display:flex;align-items:center;justify-content:center;gap:6px;padding:8px 12px;cursor:pointer;list-style:none}.__P__-form-done-summary::-webkit-details-marker{display:none}.__P__-form-done-summary>svg:last-child{color:var(--__P__-fg-muted);transition:transform .15s var(--__P__-ease)}details[open]>.__P__-form-done-summary>svg:last-child{transform:rotate(90deg)}.__P__-form-answers{margin:0;padding:var(--__P__-space-2) var(--__P__-space-3) var(--__P__-space-3);display:grid;gap:var(--__P__-space-3);text-align:start}.__P__-form-answer{display:grid;gap:6px}.__P__-form-answer dt{font-size:var(--__P__-text-sm);font-weight:600;color:var(--__P__-fg)}.__P__-form-answer dd{margin:0;padding:10px var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);font-size:var(--__P__-text-sm);font-weight:400;color:var(--__P__-fg);overflow-wrap:anywhere}.__P__-toolui{border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-lg, 14px);background:var(--__P__-bg-elevated);font-size:var(--__P__-text-sm)}.__P__-toolui:not(.__P__-toolui-collapsible){display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:var(--__P__-space-4)}.__P__-toolui-group{display:flex;flex-direction:column;gap:var(--__P__-space-3)}.__P__-toolui-stale{opacity:.7}details.__P__-toolui-collapsible>summary{display:flex;align-items:center;gap:var(--__P__-space-2);padding:var(--__P__-space-3) var(--__P__-space-4);cursor:pointer;list-style:none;-webkit-tap-highlight-color:transparent;user-select:none}details.__P__-toolui-collapsible>summary::-webkit-details-marker{display:none}details.__P__-toolui-collapsible[open]>summary{border-bottom:1px solid var(--__P__-border)}details.__P__-toolui-collapsible>.__P__-toolui-section{margin:var(--__P__-space-4)}details.__P__-toolui-collapsible>.__P__-toolui-section~.__P__-toolui-section{margin-top:calc(-1 * var(--__P__-space-2))}.__P__-toolui-name-text{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-toolui-chevron{display:inline-flex;color:var(--__P__-fg-muted);transition:transform var(--__P__-dur-quick) var(--__P__-ease-out)}details.__P__-toolui-collapsible>summary .__P__-toolui-status{margin-inline-start:auto}.__P__-toolui-chevron svg{width:16px;height:16px}details.__P__-toolui-collapsible[open]>summary .__P__-toolui-chevron{transform:rotate(180deg)}.__P__-toolui-badge,.__P__-toolui-name-pill,.__P__-toolui-q-pill{--__P__-pill: var(--__P__-fg-muted);display:inline-flex;min-width:0;align-items:center;gap:5px;padding:3px 7px;border-radius:5px;border:1px solid var(--__P__-border);background:color-mix(in oklab,var(--__P__-fg-muted) 9%,transparent);color:var(--__P__-pill);font-size:var(--__P__-text-xs);font-weight:600;white-space:nowrap}.__P__-toolui-badge svg,.__P__-toolui-name-pill svg,.__P__-toolui-q-pill svg{flex-shrink:0;width:14px;height:14px}.__P__-toolui-status-icon{display:inline-flex}.__P__-toolui-name-pill{--__P__-pill: oklch(.68 .13 233)}.__P__-toolui-q-pill{--__P__-pill: oklch(.66 .12 195)}.__P__-toolui-status[data-status=completed]{--__P__-pill: var(--__P__-success, #16a34a)}.__P__-toolui-status[data-status=responded]{--__P__-pill: oklch(.62 .15 255)}.__P__-toolui-status[data-status=awaiting]{--__P__-pill: var(--__P__-warning, #f59e0b)}.__P__-toolui-status[data-status=denied]{--__P__-pill: oklch(.66 .16 45)}.__P__-toolui-status[data-status=error]{--__P__-pill: var(--__P__-danger, #dc2626)}.__P__-toolui-status[data-status=superseded],.__P__-toolui-status[data-status=incomplete],.__P__-toolui-status[data-status=stopped]{--__P__-pill: var(--__P__-fg-muted)}@supports (color: oklch(from red l c h)){.__P__-toolui-badge,.__P__-toolui-name-pill,.__P__-toolui-q-pill{color:oklch(from var(--__P__-pill) clamp(var(--__P__-pill-l-min),l,var(--__P__-pill-l-max)) c h)}}.__P__-toolui-head{display:flex;align-items:center;flex-wrap:wrap;gap:var(--__P__-space-2)}.__P__-toolui-head-end{display:inline-flex;align-items:center;gap:var(--__P__-space-2);margin-inline-start:auto}.__P__-toolui-collapse-body{display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:var(--__P__-space-4)}.__P__-toolui-summary{display:flex;flex-direction:column;gap:var(--__P__-space-3)}.__P__-toolui-collapse-body>.__P__-form{gap:var(--__P__-space-3)}.__P__-toolui-collapse-body>.__P__-form>.__P__-field,.__P__-toolui-summary>.__P__-field{padding:10px var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:color-mix(in oklab,var(--__P__-bg) 80%,transparent);line-height:1.5}.__P__-toolui-collapse-body>.__P__-form>.__P__-field{gap:var(--__P__-space-2)}.__P__-toolui-summary>.__P__-field{gap:var(--__P__-space-1)}.__P__-toolui-summary .__P__-field-label{color:var(--__P__-fg-muted)}.__P__-toolui-answer{margin:0;font-size:var(--__P__-text-sm);color:var(--__P__-fg-muted);overflow-wrap:anywhere;white-space:pre-wrap}.__P__-toolui-footer{display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-3);margin-inline:calc(-1 * var(--__P__-space-4));padding:var(--__P__-space-3) var(--__P__-space-4) 0;border-top:1px solid var(--__P__-border)}.__P__-toolui-options-toggle{display:inline-flex;align-items:center;gap:4px;border:0;background:transparent;padding:0;cursor:pointer;font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted);transition:color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-toolui-options-toggle:hover{color:var(--__P__-fg)}.__P__-toolui-options-chevron{display:inline-flex;transition:transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-toolui-options-chevron svg{width:14px;height:14px}.__P__-toolui-options-chevron.__P__-open{transform:rotate(180deg)}.__P__-toolui-desc{margin:0;padding:var(--__P__-space-3);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);border:1px solid var(--__P__-border);color:var(--__P__-fg-muted);line-height:1.5}.__P__-toolui-section{display:flex;flex-direction:column;gap:8px;padding:var(--__P__-space-3);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);border:1px solid var(--__P__-border)}.__P__-toolui:not(.__P__-toolui-collapsible) .__P__-toolui-section,.__P__-toolui:not(.__P__-toolui-collapsible) .__P__-toolui-desc{padding:0;background:none;border:0;border-radius:0}.__P__-toolui-label{font-size:var(--__P__-text-xs);font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--__P__-fg-muted)}.__P__-toolui-code{margin:0;max-height:240px;overflow:auto;color:var(--__P__-fg);font-family:var(--__P__-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);font-size:var(--__P__-text-xs);line-height:1.5;white-space:pre-wrap;word-break:break-word}.__P__-toolui-code[data-error=true]{color:var(--__P__-danger, #dc2626)}.__P__-toolui-body{gap:6px}.__P__-toolui-prompt{margin:0;font-weight:600;color:var(--__P__-fg);overflow-wrap:anywhere}.__P__-toolui-subtle{margin:0;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted);line-height:1.5}.__P__-toolui-fields{display:grid;grid-template-columns:auto minmax(0,1fr);gap:2px var(--__P__-space-2);margin:0;font-size:var(--__P__-text-xs);line-height:1.5}.__P__-toolui-fields>div{display:contents}.__P__-toolui-fields dt{color:var(--__P__-fg-muted)}.__P__-toolui-fields dd{margin:0;min-width:0;overflow:hidden;color:var(--__P__-fg);font-family:var(--__P__-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);text-overflow:ellipsis;white-space:nowrap}.__P__-toolui-actions{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:var(--__P__-space-2);margin-top:var(--__P__-space-2)}:host([dir="rtl"]) .__P__-icon-dir{transform:scaleX(-1)}:host([dir="rtl"]) .__P__-field-input[type=date],:host([dir="rtl"]) .__P__-field-input[type=time]{position:relative;text-align:right;padding-left:34px}:host([dir="rtl"]) .__P__-field-input[type=date]::-webkit-datetime-edit,:host([dir="rtl"]) .__P__-field-input[type=time]::-webkit-datetime-edit{text-align:right}:host([dir="rtl"]) .__P__-field-input[type=date]::-webkit-calendar-picker-indicator,:host([dir="rtl"]) .__P__-field-input[type=time]::-webkit-calendar-picker-indicator{position:absolute;left:var(--__P__-space-3);margin:0}
|
|
6
6
|
|
|
7
7
|
.__P__-generative-ui{display:grid;gap:var(--__P__-space-3);overflow-wrap:anywhere;white-space:pre-wrap}.__P__-generative-ui p{margin:0}.__P__-generative-ui-grid-container{container:__P__-generative-ui-grid / inline-size;min-width:0}.__P__-generative-ui-grid{display:grid;grid-template-columns:minmax(0,1fr);align-items:start;gap:16px}.__P__-generative-ui-cell{display:grid;align-content:start;min-width:0;gap:16px}@container __P__-generative-ui-grid (min-width: 496px){.__P__-generative-ui-grid:is([data-columns="2"],[data-columns="3"],[data-columns="4"]){grid-template-columns:repeat(2,minmax(0,1fr))}.__P__-generative-ui-grid:is([data-columns="2"],[data-columns="3"],[data-columns="4"])>.__P__-generative-ui-cell:is([data-span="2"],[data-span="3"],[data-span="4"]){grid-column:span 2}}@container __P__-generative-ui-grid (min-width: 752px){.__P__-generative-ui-grid:is([data-columns="3"],[data-columns="4"]){grid-template-columns:repeat(3,minmax(0,1fr))}.__P__-generative-ui-grid:is([data-columns="3"],[data-columns="4"])>.__P__-generative-ui-cell:is([data-span="3"],[data-span="4"]){grid-column:span 3}}@container __P__-generative-ui-grid (min-width: 1008px){.__P__-generative-ui-grid[data-columns="4"]{grid-template-columns:repeat(4,minmax(0,1fr))}.__P__-generative-ui-grid[data-columns="4"]>.__P__-generative-ui-cell[data-span="4"]{grid-column:span 4}}.__P__-generative-ui section{display:grid;gap:var(--__P__-space-2);padding:var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);min-width:0}.__P__-generative-ui-metric{font-size:1.6em;font-weight:700}.__P__-generative-ui-table{overflow-x:auto}.__P__-generative-ui table{width:100%;border-collapse:collapse;white-space:normal}.__P__-generative-ui caption{text-align:start;font-weight:600;padding-bottom:var(--__P__-space-2)}.__P__-generative-ui th,.__P__-generative-ui td{text-align:start;padding:var(--__P__-space-2);border-bottom:1px solid var(--__P__-border)}.__P__-generative-ui-chart{display:block;width:100%;color:var(--__P__-accent)}.__P__-generative-ui-axis{stroke:var(--__P__-border)}.__P__-generative-ui-data{display:flex;flex-wrap:wrap;gap:var(--__P__-space-2);font-size:.85em}
|
|
8
8
|
|
|
@@ -28,8 +28,8 @@ import{Component as e,h as t,render as n}from"preact";import{batch as r,computed
|
|
|
28
28
|
|
|
29
29
|
`))!==-1;){let e=r.slice(0,a);r=r.slice(a+2),yield e}}}finally{n.releaseLock()}}function ga(e,t){let n=``,r;for(let i of e.split(`
|
|
30
30
|
`))if(i!==``){if(i.startsWith(`:`))t?.(i.slice(1).trim());else if(i.startsWith(`data:`)){let e=i.slice(5).replace(/^ /,``);n=n?`${n}\n${e}`:e}else i.startsWith(`id:`)&&(r=i.slice(3).trim())}if(n===`[DONE]`)return`done`;if(!n)return null;try{let e=JSON.parse(n);return pa.trace(`chunk`,{type:e.type,eventId:r}),{chunk:e,eventId:r}}catch(e){throw pa.trace(`frame parse failed`,{errorType:e instanceof Error?e.name:typeof e,payloadLength:n.length}),new fa(`invalid SSE frame`,`network`,void 0,e)}}const G=z.scope(`transport`),_a=6e4,va=/* @__PURE__ */ new WeakMap;function ya(e){return va.get(e)}function ba(e,t){return va.set(e,t),e}function xa(e){return Math.max(e?.upsertRevision??0,e?.read?.revision??0)}function Sa(e,t){return e.conversationId===t.conversationId&&e.title===t.title&&e.lastMessageAt===t.lastMessageAt&&e.preview===t.preview&&e.canContinue===t.canContinue&&e.hasUnread===t.hasUnread&&e.controlState===t.controlState}function Ca(e,t,n=!0){switch(t.type){case`snapshot`:{let n=new Map(e.map(e=>[e.conversationId,e])),r=e.filter(e=>(ya(e)?.activityRevision??0)>t.requestedRevision).toSorted((e,t)=>ya(t).activityRevision-ya(e).activityRevision),i=new Set(r.map(e=>e.conversationId));return[...r,...t.result.conversations.filter(e=>!i.has(e.conversationId)).map(e=>{let r=n.get(e.conversationId);if(!r)return e;let i=ya(r);return(i?.upsertRevision??0)>t.requestedRevision?r:i?.read&&!r.hasUnread&&i.read.lastMessageAt===e.lastMessageAt?ba({...e,hasUnread:!1},{upsertRevision:0,read:i.read}):e})]}case`read`:{let n=e.findIndex(e=>e.conversationId===t.conversationId&&(t.lastMessageAt===void 0||e.lastMessageAt===t.lastMessageAt));if(n<0)return e;let r=e[n],i=ya(r);if(xa(i)>t.revision)return e;let a=t.lastMessageAt??r.lastMessageAt,o={upsertRevision:i?.upsertRevision??0,...i?.activityRevision===void 0?{}:{activityRevision:i.activityRevision},read:{revision:t.revision,...a?{lastMessageAt:a}:{}}};return r.hasUnread?e.map((e,t)=>t===n?ba({...e,hasUnread:!1},o):e):(ba(r,o),e)}case`upsert`:{let r=e.findIndex(e=>e.conversationId===t.conversation.conversationId);if(r<0&&!n)return e;let i=r<0?void 0:e[r],a=i?ya(i):void 0;if(xa(a)>t.revision)return e;let o=t.activity?t.revision:a?.activityRevision,s={upsertRevision:t.revision,...o===void 0?{}:{activityRevision:o},...!t.conversation.hasUnread&&a?.read?{read:a.read}:{}},c=i?{...i,...t.conversation,title:i.title}:{...t.conversation};return i&&Sa(i,c)?(ba(i,s),e):(ba(c,s),t.activity?[c,...e.filter(e=>e.conversationId!==c.conversationId)]:i?e.map((e,t)=>t===r?c:e):[...e,c])}default:return t}}const wa=/* @__PURE__ */ new Set([408,425,429,500,502,503,504]);function Ta(e){return 400*2**e+Math.floor(Math.random()*250)}function Ea(e){return 6e4+Math.ceil(e/1048576)*15e3}function Da(e){let t=e.get(`retry-after`);if(!t)return null;let n=Number(t),r=Number.isFinite(n)?n*1e3:Date.parse(t)-Date.now();return Number.isFinite(r)&&r>=0?Math.min(r,3e4):null}var Oa=class{constructor(e){this.ttlMs=e,V(this,`map`,/* @__PURE__ */ new Map)}getOrFetch(e,t){let n=this.map.get(e);if(n&&performance.now()-n.at<this.ttlMs)return n.result;let r={at:performance.now(),result:t().then(e=>(r.value=e,e)).catch(t=>{throw this.map.get(e)===r&&this.map.delete(e),t})};return this.map.set(e,r),r.result}peek(e){let t=this.map.get(e);if(t?.value!==void 0&&performance.now()-t.at<this.ttlMs)return t.value}update(e){for(let t of this.map.values())if(t.value!==void 0){let n=e(t.value);t.value=n,t.result=Promise.resolve(n)}else t.result=t.result.then(n=>{let r=e(n);return t.value=r,r})}delete(e){this.map.delete(e)}},ka=class{constructor(e){this.opts=e,V(this,`conversationListeners`,/* @__PURE__ */ new Set),V(this,`conversationRevision`,0),V(this,`visitorId`,void 0),V(this,`conversationId`,void 0),V(this,`userContext`,void 0),V(this,`pageContext`,void 0),V(this,`locale`,void 0),V(this,`userTokenSource`,void 0),V(this,`userToken`,void 0),V(this,`userTokenRequest`,void 0),V(this,`conversationsCache`,new Oa(1e4)),V(this,`contentCache`,new Oa(_a)),V(this,`contentCollectionsCache`,new Oa(_a))}setUserToken(e){this.userTokenSource=e,this.userToken=typeof e==`string`&&e||void 0,this.userTokenRequest=typeof e==`function`?this.fetchUserToken():void 0}setContext(e,t){this.userContext=e,this.pageContext=t}setLocale(e){this.locale=e}primeIdentity(e,t){e&&(this.visitorId=e),t&&(this.conversationId=t)}envelope(){let e={_ev:bt};this.visitorId&&(e.visitorId=this.visitorId),this.conversationId&&(e.conversationId=this.conversationId),this.locale&&(e.locale=this.locale);let t=da(this.userContext,this.pageContext);return t&&(e[ui]=t),e}withEnvelope(e){return{...this.envelope(),...e}}appendEnvelope(e){for(let[t,n]of Object.entries(this.envelope()))e.append(t,n);return e}withEnvelopeQuery(e){let t=new URL(this.url(e));for(let[e,n]of Object.entries(this.envelope()))t.searchParams.has(e)||t.searchParams.set(e,n);return t.toString()}async handshake(e){G.debug(`handshake →`,{visitorId:e.visitorId,conversationId:e.conversationId,locale:e.locale}),this.userTokenRequest&&await this.userTokenRequest;let t=await this.postJson(li.handshake,e,`handshake`);return G.debug(`handshake ←`,{visitorId:t.visitorId,conversationId:t.conversationId,hasWelcome:!!t.welcome,hasConfig:!!t.config,rebind:t.rebind}),this.visitorId=e.visitorId,this.conversationId=t.conversationId,t}async uploadFile(e,t){G.debug(`uploadFile →`,{name:e.name,size:e.size,type:e.type});let n=new FormData;n.append(`file`,e,e.name);let r=await this.postForm(this.uploadPath,n,`upload`,t,Ea(e.size));return G.debug(`uploadFile ←`,{id:r.id,url:r.url}),r}async transcribe(e,t=`audio/webm`){G.debug(`transcribe →`,{size:e.size,mimeType:t});let n=new FormData;n.append(`audio`,e,`voice.${Aa(t)}`),n.append(`mimeType`,t);let r=await this.postForm(this.transcribePath,n,`transcribe`);return G.debug(`transcribe ←`,{textLen:r.text.length}),r}subscribeConversationChanges(e){return this.conversationListeners.add(e),()=>this.conversationListeners.delete(e)}publishConversation(e,t=!1){let n={type:`upsert`,conversation:e,revision:++this.conversationRevision,...t?{activity:!0}:{}};this.conversationsCache.update(r=>{let i=r.pagination.page===1,a=r.conversations.some(t=>t.conversationId===e.conversationId),o=Ca(r.conversations,n,i&&t),s=i&&o.length>r.pagination.limit?o.slice(0,r.pagination.limit):o;if(!i||!t||a||r.pagination.hasNext)return s===r.conversations?r:{...r,conversations:s};let c=Math.max(r.pagination.total,r.conversations.length)+1,l=Math.ceil(c/r.pagination.limit);return{...r,conversations:s,pagination:{...r.pagination,total:c,totalPages:l,hasNext:r.pagination.page<l}}});for(let e of this.conversationListeners)e(n)}localeCacheKey(e){return`${this.locale??``}|${JSON.stringify(e,Object.keys(e).toSorted())}`}peekConversations(e={}){return this.conversationsCache.peek(this.localeCacheKey(e))}listConversations(e={},t=!1){if((e.page??1)>1)return this.fetchConversations(e);let n=this.localeCacheKey(e),r=this.conversationRevision;t&&this.conversationsCache.delete(n);let i=this.conversationsCache.getOrFetch(n,()=>this.fetchConversations(e));return t?i.then(e=>{let t={type:`snapshot`,result:e,requestedRevision:r};for(let e of this.conversationListeners)e(t);return e}):i}async fetchConversations(e){let t=new URL(this.url(li.listConversations));return e.visitorId&&t.searchParams.set(`visitorId`,e.visitorId),e.page&&t.searchParams.set(`page`,String(e.page)),e.limit&&t.searchParams.set(`limit`,String(e.limit)),e.ids?.length&&t.searchParams.set(`ids`,e.ids.join(`,`)),this.getJson(t.toString(),`listConversations`)}async loadConversation(e,{ids:t=[],beforeId:n,beforeCreatedAt:r}={}){let i=new URL(this.url(li.listMessages));i.searchParams.set(`conversationId`,e),i.searchParams.set(`limit`,`50`),t.length>0&&i.searchParams.set(`ids`,t.join(`,`)),n&&i.searchParams.set(`beforeId`,n),r&&i.searchParams.set(`beforeCreatedAt`,r);let a=await this.getJson(i.toString(),`loadConversation`);return{...a,messages:a.messages.toReversed()}}async markRead(e,t){if(!this.visitorId||!e)return;let n={type:`read`,conversationId:e,...t===void 0?{}:{lastMessageAt:t},revision:++this.conversationRevision};this.conversationsCache.update(e=>{let t=Ca(e.conversations,n);return t===e.conversations?e:{...e,conversations:t}});for(let e of this.conversationListeners)e(n);try{await this.postJson(li.markRead,{conversationId:e},`markRead`,!0)}catch(e){G.debug(`markRead failed (non-fatal)`,{err:e})}}async requestOperator(){if(this.visitorId&&this.conversationId)try{return(await this.postJson(li.requestOperator,{},`requestOperator`)).controlState}catch(e){G.debug(`requestOperator failed (non-fatal)`,{err:e});return}}async cancelOperatorRequest(){if(this.visitorId&&this.conversationId)try{return(await this.postJson(li.cancelOperatorRequest,{},`cancelOperatorRequest`)).controlState}catch(e){G.debug(`cancelOperatorRequest failed (non-fatal)`,{err:e});return}}listContent(e={}){return this.contentCache.getOrFetch(this.localeCacheKey(e),()=>this.fetchContent(e))}async fetchContent(e){let t=new URL(this.dataUrl(li.content));for(let[n,r]of Object.entries(e))r!==void 0&&t.searchParams.set(n,Array.isArray(r)?r.join(`,`):String(r));let n=await this.getJson(t.toString(),`listContent`),r=n.items?.map(e=>S(e,this.locale))??[];return{...n,items:r}}async setContentVote(e){try{await this.postJson(this.dataUrl(li.contentVoteSet),e,`setContentVote`)}catch{}}listContentCollections(e){return this.contentCollectionsCache.getOrFetch(this.localeCacheKey({ids:e}),()=>this.fetchContentCollections(e))}async fetchContentCollections(e){let t=new URL(this.dataUrl(li.contentCollections));return e.length&&t.searchParams.set(`ids`,e.join(`,`)),{items:(await this.getJson(t.toString(),`listContentCollections`)).items?.map(e=>C(e,this.locale))??[]}}async bootstrap(e){let t=new URL(this.dataUrl(li.bootstrap));e&&t.searchParams.set(`conversationId`,e);let n=await this.getJson(t.toString(),`bootstrap`);return{forms:n.forms??[],formSubmissions:n.formSubmissions??[]}}async saveUserPrefs(e){return this.postJson(li.updateSettings,{userPrefs:e},`saveUserPrefs`)}get uploadPath(){return this.opts.endpoints?.upload??`/pai/upload-file`}get transcribePath(){return this.opts.endpoints?.transcribe??`/pai/transcribe-audio`}get submitFormPath(){return this.opts.endpoints?.submitForm??li.submitForm}async submitForm(e){G.debug(`submitForm →`,{formId:e.formId,trigger:e.trigger,fields:Object.keys(e.values).length});try{await this.postJson(this.dataUrl(this.submitFormPath),e,`submitForm`)}catch(e){G.debug(`submitForm failed (non-fatal)`,{err:e})}}async submitFeedback(e){G.debug(`submitFeedback →`,{messageId:e.messageId,value:e.value});try{await this.postJson(li.messageFeedback,{messageId:e.messageId,set:{feedback:e.value}},`submitFeedback`)}catch(e){G.debug(`submitFeedback failed (non-fatal)`,{err:e})}}async sendTurn(e,t={}){G.debug(`message →`,{conversationId:e.conversationId,visitorId:e.visitorId,messageCount:e.messages.length});let n=JSON.stringify({...this.withEnvelope(e),[ui]:da(this.userContext,this.pageContext,this.opts.recentHostEvents)}),r=t.keepalive===!0&&new Blob([n]).size<6e4;try{return await this.runWithAbort(async e=>{let t=await this.withFreshUserToken(()=>this.fetchImpl(this.url(li.streamMessage),{method:`POST`,credentials:`omit`,headers:{accept:`application/json`,"content-type":`application/json`,...this.headersFor(this.url(li.streamMessage))},body:n,keepalive:r,signal:e}));if(t.status!==202)throw new fa(`sendTurn failed: expected 202, received ${t.status}`,`server`,t.status,void 0,Ma(t));let i;try{i=await t.json()}catch(n){throw e?.aborted?n:new fa(`sendTurn failed: invalid acknowledgement`,`server`,t.status,n)}if(!ja(i))throw new fa(`sendTurn failed: invalid acknowledgement`,`server`,t.status);return i},void 0,3e4)}catch(e){throw e instanceof fa?e:new fa(`sendTurn failed: network error`,`network`,void 0,e)}}cancelTurn(e,t){this.visitorId&&e&&t&&(G.debug(`cancel stream`,{conversationId:e,runId:t,visitorId:this.visitorId}),this.fetchImpl(this.url(li.cancelStream),{method:`POST`,credentials:`omit`,headers:{"content-type":`application/json`,...this.headersFor(this.url(li.cancelStream))},body:JSON.stringify(this.withEnvelope({conversationId:e,runId:t})),keepalive:!0}).catch(e=>G.debug(`cancel POST failed (non-fatal)`,{err:e})))}async connectResumeStream(e){let t=new AbortController;function n(){return t.abort(e.signal.reason)}e.signal.aborted?n():e.signal.addEventListener(`abort`,n,{once:!0});let r=setTimeout(()=>t.abort(),1e4);function i(){clearTimeout(r),e.signal.removeEventListener(`abort`,n)}let a;try{this.userTokenRequest&&await this.userTokenRequest,a=await this.fetchImpl(this.resumeUrl(),{method:`GET`,credentials:`omit`,headers:{accept:`text/event-stream`,...this.headersFor(this.resumeUrl())},signal:t.signal})}catch(t){return i(),e.signal.aborted||G.debug(`resume-stream fetch failed — reconnecting`,{err:t}),`held`}if(!a.ok)return i(),a.status===401&&typeof this.userTokenSource==`function`?(await this.fetchUserToken(),`held`):a.status===409||wa.has(a.status)?(G.debug(`resume-stream → transient response; reconnecting`,{status:a.status}),`held`):(G.debug(`resume-stream → endpoint unavailable`,{status:a.status}),`unavailable`);if(!a.body)return i(),G.debug(`resume-stream → bodyless response; stopping`,{status:a.status}),`unavailable`;if(!(a.headers.get(`content-type`)??``).includes(`text/event-stream`))return i(),G.debug(`resume-stream → non-SSE response; stopping`),`unavailable`;let o=!1;try{for await(let{chunk:n}of ma(a,t.signal,t=>{o||t!==`connected`||(o=!0,clearTimeout(r),e.onConnected())})){if(e.signal.aborted)return`held`;e.onChunk(n)}}catch(t){if(e.signal.aborted)return`held`;G.debug(`resume-stream segment dropped — reconnecting`,{err:t})}finally{i()}return`held`}resumeUrl(){return this.withEnvelopeQuery(li.streamResume)}async postJson(e,t,n,r=!1){let i=await this.fetchWithRetry(()=>[this.url(e),{method:`POST`,credentials:`omit`,headers:{"content-type":`application/json`,...this.headersFor(this.url(e))},body:JSON.stringify(this.withEnvelope(t)),...r?{keepalive:!0}:{}}],n);return this.assertOk(i,n)}async postForm(e,t,n,r,i){return this.runWithAbort(async r=>{let i=await this.withFreshUserToken(()=>this.fetchImpl(this.url(e),{method:`POST`,credentials:`omit`,headers:this.headersFor(this.url(e)),body:this.appendEnvelope(t),signal:r}));return this.assertOk(i,n)},r,i)}async runWithAbort(e,t,n){if(!t&&n===void 0)return e();let r=new AbortController;function i(){return r.abort(t?.reason)}t?.aborted?i():t?.addEventListener(`abort`,i,{once:!0});let a=n===void 0?void 0:setTimeout(()=>r.abort(),n);try{return await e(r.signal)}finally{a!==void 0&&clearTimeout(a),t?.removeEventListener(`abort`,i)}}async getJson(e,t){let n=await this.fetchWithRetry(()=>[this.withEnvelopeQuery(e),{method:`GET`,credentials:`omit`,headers:{accept:`application/json`,...this.headersFor(this.url(e))}}],t);return this.assertOk(n,t)}async fetchWithRetry(e,t){for(let n=0;;n++){let r;try{r=await this.withFreshUserToken(()=>this.fetchImpl(...e()))}catch(e){if(n>=3)throw new fa(`${t} failed: network error`,`network`,void 0,e);G.debug(`request network error — retrying`,{label:t,attempt:n}),await ca(Ta(n));continue}if(r.ok||!wa.has(r.status)||n>=3)return r;let i=Da(r.headers)??Ta(n);G.debug(`request retryable status — retrying`,{label:t,status:r.status,attempt:n,wait:i}),await ca(i)}}async assertOk(e,t){if(!e.ok)throw new fa(`${t} failed: ${e.status}`,`server`,e.status);return await e.json()}fetchUserToken(){let e=this.userTokenSource;if(typeof e!=`function`)return Promise.resolve();let t=Promise.resolve().then(e).then(t=>{this.userTokenSource===e&&(this.userToken=t||void 0)},e=>{G.warn(`userToken function failed; continuing as an anonymous visitor`,{err:e})});return this.userTokenRequest=t,t}headersFor(e){let t=!/^https?:\/\//i.test(e)||e.startsWith(`${this.opts.agentApiBaseUrl}/`);return{...this.opts.auth.headers(),...t&&this.userToken?{"x-user-token":this.userToken}:{}}}async withFreshUserToken(e){let t=await e();return t.status!==401||!this.userTokenSource?t:typeof this.userTokenSource==`function`?(await this.fetchUserToken(),e()):(G.warn(`userToken rejected as invalid or expired; pass a function so the widget can fetch a fresh one`),t)}url(e){return/^https?:\/\//i.test(e)?e:`${this.opts.agentApiBaseUrl}${e}`}dataUrl(e){return/^https?:\/\//i.test(e)?e:`${this.opts.dataApiBaseUrl}${e}`}get fetchImpl(){return this.opts.fetchImpl??globalThis.fetch.bind(globalThis)}};function Aa(e){return e.includes(`webm`)?`webm`:e.includes(`ogg`)?`ogg`:e.includes(`mp4`)||e.includes(`m4a`)?`m4a`:e.includes(`mpeg`)?`mp3`:e.includes(`wav`)?`wav`:`bin`}function ja(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`status`),n=Reflect.get(e,`conversationId`),r=Reflect.get(e,`runId`);return t===`accepted`&&typeof n==`string`&&n.length>0&&(r===void 0||typeof r==`string`&&r.length>0)}function Ma(e){let t=Number(e.headers.get(`retry-after`));return Number.isInteger(t)&&t>0?t:void 0}function Na(e,t,n){switch(e){case`clear`:case`sound`:case`history`:case`language`:case`theme`:case`textSize`:return!0;case`popOut`:return t!==`standalone`&&t!==`page`;case`expand`:return t===`floating`;case`fullscreen`:return t!==`standalone`;case`close`:return t===`standalone`||t===`page`?!1:t!==`inline`||n===`fullscreen`}}function Pa(e,t,n){return Na(`close`,e,t)?n.includes(`close`):!1}function Fa(e,t){return e===`inline`&&t===`fullscreen`?`exit-fullscreen`:`close`}function Ia(e,t,n,r){let i={role:n,text:r};e.emit(`message`,i),t.onMessage?.(i)}function La(e){let t=m(e);t.current=e;let n=m(null);return n.current??(n.current=Ra(t)),n.current}function Ra(e){let t=o(null),n=/* @__PURE__ */ new Set;function r(t){return`${e.current.conversationId()??``}:${t}`}function i(t){return t.frequency===`always`?!1:t.frequency===`conversation`?n.has(r(t.id)):t.id in e.current.persistence.loadFormsDone()}function a(n,r){if(t.value)return;let a=e.current;if(n===`manual`){let e=a.forms.list.find(e=>e.id===r);e&&(t.value={form:e,trigger:`manual`})}else for(let e of a.forms.byTrigger[n]??[]){let r=e.triggers.find(e=>e.kind===n);if(r&&za(r,a)&&!i(e)&&Ba(e,a)){t.value={form:e,trigger:n};return}}}function s(i,a){let o=t.value;if(!o)return;t.value=null;let{form:s,trigger:c}=o;s.frequency===`conversation`?n.add(r(s.id)):s.frequency!==`always`&&e.current.persistence.saveFormDone(s.id),e.current.onComplete(s,c,i,a)}function c(){let n=t.value;if(!n)return;let r=e.current.forms.list.find(e=>e.id===n.form.id);r&&r!==n.form&&(t.value={form:r,trigger:n.trigger})}return{activeForm:t,fire:a,refresh:c,complete:e=>s(e,!1),skip:()=>s({},!0)}}function za(e,t){return e.kind===`after-messages`?t.messageCount()>=Number(e.param??0):e.kind!==`page-area`||t.pageArea()===e.param}function Ba(e,t){let n=e.when;if(!n)return!0;if(n.missingContext?.length){let e=t.userContext()??{};if(n.missingContext.some(t=>e[t]!==void 0&&e[t]!==``))return!1}if(n.pageArea&&!(Array.isArray(n.pageArea)?n.pageArea:[n.pageArea]).includes(t.pageArea()??``))return!1;let r=t.messageCount();return!(n.minMessages!=null&&r<n.minMessages||n.maxMessages!=null&&r>n.maxMessages)}function Va(e){return Object.fromEntries(e.map(e=>[e,[]]))}function Ha(e,t,n){return e.includes(t)?t:e.includes(n)?n:e[0]??``}function Ua(e,t,n){let r=[...new Set(t)],i=Ha(r,e,``),a=o({activeTab:i,stacks:Va(r)});return{sig:a,reconcile(e,t){let i=[...new Set(e)],o=a.value,s=Ha(i,o.activeTab,t),c=Object.fromEntries(i.map(e=>[e,o.stacks[e]??[]])),l=s===o.activeTab&&i.length===Object.keys(o.stacks).length&&i.every(e=>o.stacks[e]===c[e]);r=i,!l&&(a.value={activeTab:s,stacks:c},s!==o.activeTab&&s&&n?.(s))},switchTab(e){e in a.value.stacks&&a.value.activeTab!==e&&(a.value={...a.value,activeTab:e},n?.(e))},open(e,t){let r=a.value;e in r.stacks&&(a.value={activeTab:e,stacks:{...r.stacks,[e]:t?[t]:[]}},r.activeTab!==e&&n?.(e))},push(e){let t=a.value,n=t.stacks[t.activeTab]??[];a.value={...t,stacks:{...t.stacks,[t.activeTab]:[...n,e]}}},pop(){let e=a.value,t=e.stacks[e.activeTab]??[];t.length!==0&&(a.value={...e,stacks:{...e.stacks,[e.activeTab]:t.slice(0,-1)}})},reset(e){a.value={activeTab:Ha(r,e,``),stacks:Va(r)}}}}function Wa(e){return e.stacks[e.activeTab]??[]}function Ga(e){return Wa(e).at(-1)}function Ka(e){return Wa(e).length===0}function qa(e,t,n){return e===`page`?`page`:e===`standalone`?`standalone`:e===`inline`?t===`fullscreen`?`fullscreen`:`inline`:e===`modal`||e===`drawer`?n?t===`fullscreen`?`fullscreen`:e:`closed`:n?t===`fullscreen`?`fullscreen`:t===`expanded`?`expanded`:`open`:`closed`}function Ja(e,t,n){if(e===`standalone`||e===`page`)return`fullscreen`;let r=t.initialSize;return r===`expanded`||r===`fullscreen`||r===`normal`?r:n>0&&n<640?`fullscreen`:n>=(t.autoSizeBreakpoint??900)?`expanded`:`normal`}function Ya(e,t,n,r=null){return{panelOpen:e.mode===`inline`||e.mode===`standalone`||e.mode===`page`||(n??!e.startMinimized),panelSize:e.mode!==`standalone`&&e.mode!==`page`&&e.mode!==`inline`&&r?r:Ja(e.mode,e.size,t)}}function Xa(){return typeof window>`u`?0:window.innerWidth}const K={fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 24 24`},Za=`${N.cssPrefix}-icon-dir`;function Qa(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M21 12a8 8 0 0 1-12 6.93L3 21l1.65-5.16A8 8 0 1 1 21 12Z`})})}function $a(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M18 6 6 18M6 6l12 12`})})}function eo(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M12 5v14M5 12h14`})})}function to(){return/* @__PURE__ */ v(`svg`,{...K,class:Za,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`m22 2-7 20-4-9-9-4Z`}),/* @__PURE__ */ _(`path`,{d:`M22 2 11 13`})]})}function no(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M12 19V5M5 12l7-7 7 7`})})}function ro(){return/* @__PURE__ */ _(`svg`,{...K,class:Za,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M3 20V4l18 8-18 8Z`})})}function io(){return/* @__PURE__ */ _(`svg`,{...K,class:Za,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`m9 18 6-6-6-6`})})}function ao(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}function oo(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`m21 11-9 9a5.5 5.5 0 0 1-7.78-7.78l8.49-8.49a3.67 3.67 0 0 1 5.19 5.19l-8.49 8.49a1.83 1.83 0 0 1-2.6-2.6l7.78-7.78`})})}function so(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`rect`,{x:`9`,y:`2`,width:`6`,height:`12`,rx:`3`}),/* @__PURE__ */ _(`path`,{d:`M5 10a7 7 0 0 0 14 0M12 19v3`})]})}function co(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M3 8V3h5M21 8V3h-5M3 16v5h5M21 16v5h-5`})})}function lo(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M8 3v5H3M16 3v5h5M8 21v-5H3M16 21v-5h5`})})}function uo(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M3 3h7v2H5v5H3zM21 3h-7v2h5v5h2zM3 21h7v-2H5v-5H3zM21 21h-7v-2h5v-5h2z`})})}function fo(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M10 3v5H3M14 3v5h7M10 21v-5H3M14 21v-5h7`})})}function po(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M14 3h7v7M21 3l-9 9`}),/* @__PURE__ */ _(`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`})]})}function mo(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,viewBox:`0 0 10 10`,children:/* @__PURE__ */ _(`path`,{d:`M9 1L1 9M9 5L5 9M9 9H9`,strokeWidth:`1.5`})})}function ho(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`5`,r:`1.5`,fill:`currentColor`,stroke:`none`}),/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`1.5`,fill:`currentColor`,stroke:`none`}),/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`19`,r:`1.5`,fill:`currentColor`,stroke:`none`})]})}function go(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M11 5 6 9H2v6h4l5 4zM15 9a5 5 0 0 1 0 6M18 7a9 9 0 0 1 0 10`})})}function _o(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M11 5 6 9H2v6h4l5 4zM22 9l-6 6M16 9l6 6`})})}function vo(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M3 18 8 6l5 12M4.7 14h6.6`}),/* @__PURE__ */ _(`path`,{d:`M14.5 18l3.2-7 3.2 7M15.6 15.8h4.2`})]})}function yo(){return/* @__PURE__ */ _(`svg`,{...K,class:Za,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`m5 6 6 6-6 6M13 6l6 6-6 6`})})}function bo(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M20 6 9 17l-5-5`})})}function xo(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M3 3v6h6`}),/* @__PURE__ */ _(`path`,{d:`M3.05 13A9 9 0 1 0 6 5.3L3 9`}),/* @__PURE__ */ _(`path`,{d:`M12 7v5l3 2`})]})}function So(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ _(`path`,{d:`M2 12h20`}),/* @__PURE__ */ _(`path`,{d:`M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z`})]})}function Co(){return/* @__PURE__ */ _(`svg`,{...K,class:Za,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M19 12H5M12 19l-7-7 7-7`})})}function wo(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M12 20h9`}),/* @__PURE__ */ _(`path`,{d:`M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z`})]})}function To(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`m6 9 6 6 6-6`})})}function Eo(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z`}),/* @__PURE__ */ _(`path`,{d:`M14 2v6h6`})]})}function Do(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`m12 3-1.5 4.5L6 9l4.5 1.5L12 15l1.5-4.5L18 9l-4.5-1.5Z`}),/* @__PURE__ */ _(`path`,{d:`M19 15v4M17 17h4M5 3v2M4 4h2`})]})}function Oo(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2Z`})})}function ko(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ _(`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`}),/* @__PURE__ */ _(`path`,{d:`M12 17h.01`})]})}function Ao(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`m15 4 3 3-9 9-3-3z`}),/* @__PURE__ */ _(`path`,{d:`M18 2v2M20 4h2M3 20l3-3M3 16h2M5 14v2`})]})}function jo(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`rect`,{x:`4`,y:`8`,width:`16`,height:`12`,rx:`2`}),/* @__PURE__ */ _(`path`,{d:`M12 8V4`}),/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`3`,r:`1`}),/* @__PURE__ */ _(`path`,{d:`M2 14h2M20 14h2M9 13h.01M15 13h.01M9.5 17h5`})]})}function Mo(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M4 14v-2a8 8 0 0 1 16 0v2`}),/* @__PURE__ */ _(`rect`,{x:`2`,y:`14`,width:`4`,height:`6`,rx:`1.5`}),/* @__PURE__ */ _(`rect`,{x:`18`,y:`14`,width:`4`,height:`6`,rx:`1.5`}),/* @__PURE__ */ _(`path`,{d:`M20 20v1a3 3 0 0 1-3 3h-5`})]})}function No(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`4`}),/* @__PURE__ */ _(`path`,{d:`m4.93 4.93 4.24 4.24M14.83 14.83l4.24 4.24M14.83 9.17l4.24-4.24M4.93 19.07l4.24-4.24`})]})}function Po(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`11`,cy:`11`,r:`7`}),/* @__PURE__ */ _(`path`,{d:`m21 21-4.3-4.3`})]})}function Fo(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ _(`path`,{d:`m8.5 12 2.5 2.5 4.5-5`})]})}function Io(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M3 9.5 12 3l9 6.5`}),/* @__PURE__ */ _(`path`,{d:`M5 9v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9`})]})}function Lo(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`m3 11 15-5v12L3 13z`}),/* @__PURE__ */ _(`path`,{d:`M3 11v2a2 2 0 0 0 2 2h1V9H5a2 2 0 0 0-2 2z`}),/* @__PURE__ */ _(`path`,{d:`M7 15v3a2 2 0 0 0 4 0v-2`}),/* @__PURE__ */ _(`path`,{d:`M21 10a3 3 0 0 1 0 4`})]})}function Ro(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z`}),/* @__PURE__ */ _(`path`,{d:`M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1`})]})}function zo(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`4`}),/* @__PURE__ */ _(`path`,{d:`M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41`})]})}function Bo(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`})})}function Vo(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ _(`path`,{d:`M12 3v18`}),/* @__PURE__ */ _(`path`,{d:`M12 3a9 9 0 0 1 0 18z`,fill:`currentColor`,stroke:`none`})]})}function Ho(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`10.5`,cy:`10.5`,r:`6.5`}),/* @__PURE__ */ _(`path`,{d:`M8 11a2.5 2.5 0 0 0 5 0`}),/* @__PURE__ */ _(`path`,{d:`m20 20-4.4-4.4`})]})}function Uo(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M12 3.5 13.6 9 19 10.5 13.6 12 12 17.5 10.4 12 5 10.5 10.4 9z`}),/* @__PURE__ */ _(`path`,{d:`M18.5 4v3M20 5.5h-3M5.5 16v2.5M6.75 17.25h-2.5`})]})}function Wo(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M4 18h16`}),/* @__PURE__ */ _(`path`,{d:`M5 18a7 7 0 0 1 14 0`}),/* @__PURE__ */ _(`path`,{d:`M12 8V6`}),/* @__PURE__ */ _(`path`,{d:`M10 6h4`})]})}function Go(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M7 11V6.5a1.5 1.5 0 0 1 3 0V10`}),/* @__PURE__ */ _(`path`,{d:`M10 10V5.5a1.5 1.5 0 0 1 3 0V10`}),/* @__PURE__ */ _(`path`,{d:`M13 10V6.5a1.5 1.5 0 0 1 3 0V12`}),/* @__PURE__ */ _(`path`,{d:`M16 9.5a1.5 1.5 0 0 1 3 0v2.5a7 7 0 0 1-7 7 7 7 0 0 1-6.4-4.2L4 12.5a1.5 1.5 0 0 1 2.6-1.5L7 11`})]})}function Ko(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`rect`,{x:`9`,y:`9`,width:`11`,height:`11`,rx:`2`}),/* @__PURE__ */ _(`path`,{d:`M5 15a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2`})]})}function qo(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M7 10v11H4a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1z`}),/* @__PURE__ */ _(`path`,{d:`M7 10l4-7a2.5 2.5 0 0 1 2.5 2.5V8h5a2 2 0 0 1 2 2.3l-1.2 8A2 2 0 0 1 17.3 20H7`})]})}function Jo(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`path`,{d:`M17 14V3h3a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1z`}),/* @__PURE__ */ _(`path`,{d:`M17 14l-4 7a2.5 2.5 0 0 1-2.5-2.5V16h-5a2 2 0 0 1-2-2.3l1.2-8A2 2 0 0 1 6.7 4H17`})]})}function Yo(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`3.5`}),/* @__PURE__ */ _(`path`,{d:`M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M19.1 4.9l-2.1 2.1M7 17l-2.1 2.1`})]})}function Xo(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ _(`path`,{d:`M12 7v5l3 2`})]})}function Zo(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ _(`path`,{d:`m8.5 12 2.5 2.5 4.5-5`})]})}function Qo(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ _(`path`,{d:`m15 9-6 6M9 9l6 6`})]})}function $o(){return/* @__PURE__ */ _(`svg`,{...K,"aria-hidden":`true`,children:/* @__PURE__ */ _(`path`,{d:`M12 18V5M15 13a4.17 4.17 0 01-3-4 4.17 4.17 0 01-3 4M17.707 6.294A3 3 0 1012 5a3 3 0 10-5.707 1.294M17.996 5.125a4 4 0 012.526 5.77M18 18a4 4 0 002-7.465M19.967 17.482a4 4 0 11-7.967.517 4 4 0 11-7.967-.517M6 18a4 4 0 01-2-7.465M6.004 5.125a4 4 0 00-2.526 5.77`})})}function es(){return/* @__PURE__ */ v(`svg`,{...K,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ _(`path`,{d:`M12 8v4M12 16h.01`})]})}const ts={chat:Qa,message:Oo,bubbles:Ro,spark:Do,wand:Ao,bot:jo,help:ko,lifebuoy:No,headset:Mo,search:Ho,sparkles:Uo,concierge:Wo,wave:Go},q=N.cssPrefix,J={launcher:`${q}-launcher`,callout:`${q}-callout`,calloutDismiss:`${q}-callout-dismiss`,panel:`${q}-panel`,panelHeader:`${q}-panel-header`,resizeGrip:`${q}-resize-grip`,scrollToBottom:`${q}-scroll-to-bottom`,loadPreviousMessages:`${q}-load-previous-messages`,actionHistory:`${q}-action-history`,actionClose:`${q}-action-close`,langSegment:`${q}-lang-segment`,composer:`${q}-composer`,composerInput:`${q}-composer-input`,composerSend:`${q}-composer-send`,composerStop:`${q}-composer-stop`,compactionStatus:`${q}-compaction-status`,messageQueue:`${q}-message-queue`,queuedMessage:`${q}-queued-message`,queuedMessageRemove:`${q}-queued-message-remove`,composerAttach:`${q}-composer-attach`,composerFileInput:`${q}-composer-file-input`,composerVoice:`${q}-composer-voice`,attachmentChip:`${q}-attachment-chip`,attachmentRemove:`${q}-attachment-remove`,suggestion:`${q}-suggestion`,messageBubble:`${q}-message`,messageRetry:`${q}-message-retry`,messageFile:`${q}-message-file`,messageFeedback:`${q}-message-feedback`,feedbackUp:`${q}-feedback-up`,feedbackDown:`${q}-feedback-down`,messageCopy:`${q}-message-copy`,historyPane:`${q}-history-pane`,historyBack:`${q}-history-back`,historyItem:`${q}-history-item`,historyLoadMore:`${q}-history-load-more`,sidebar:`${q}-sidebar`,sidebarToggle:`${q}-sidebar-toggle`,sidebarNewConversation:`${q}-sidebar-new-conversation`,sidebarItem:`${q}-sidebar-item`,messengerHome:`${q}-messenger-home`,modulesEmpty:`${q}-modules-empty`,tab:`${q}-tab`,tabBadge:`${q}-tab-badge`,homeView:`${q}-home-view`,homeGreeting:`${q}-home-greeting`,homeBrand:`${q}-home-brand`,backHeader:`${q}-back-header`,contentView:`${q}-content-view`,contentScroll:`${q}-content-scroll`,homeSearch:`${q}-home-search`,helpSearch:`${q}-help-search`,homeRecent:`${q}-home-recent`,homeAsk:`${q}-home-ask`,homeWhatsNew:`${q}-home-whats-new`,homeContentRow:`${q}-home-content-row`,helpArticle:`${q}-help-article`,newsItem:`${q}-news-item`,newsMore:`${q}-news-more`,formGate:`${q}-form-gate`,formDone:`${q}-form-done`,formDoneToggle:`${q}-form-done-toggle`,formAnswers:`${q}-form-answers`,formFill:`${q}-form-fill`,formSubmit:`${q}-form-submit`,formSkip:`${q}-form-skip`,formField:`${q}-form-field`,toolAskQuestions:`${q}-tool-ask-questions`,toolInputSubmit:`${q}-tool-input-submit`,toolInputSkip:`${q}-tool-input-skip`,toolApproval:`${q}-tool-approval`,toolApprovalFields:`${q}-tool-approval-fields`,toolApprove:`${q}-tool-approve`,toolReject:`${q}-tool-reject`,toolEdit:`${q}-tool-edit`,toolDecision:`${q}-tool-decision`,typingDots:`${q}-typing-dots`,reasoning:`${q}-reasoning`,replyStopped:`${q}-reply-stopped`,toolAskSummary:`${q}-ask-questions-summary`,toolAskOptions:`${q}-ask-questions-options-toggle`,toolCall:`${q}-tool-call`,toolSteps:`${q}-tool-steps`,toolStep:`${q}-tool-step`,source:`${q}-source`,operatorRequest:`${q}-operator-request`,operatorBanner:`${q}-operator-banner`,cancelOperatorRequest:`${q}-cancel-operator-request`};function ns(e,t){return`${e}-${t}`}const rs=N.cssPrefix;function is({onToggle:e,launcher:t,strings:n,leaving:r,edgeTab:i}){let a=t.variant!==`circle`&&!!t.label;return/* @__PURE__ */ v(`button`,{type:`button`,class:`${rs}-fab`,part:`launcher`,"data-variant":t.variant,"data-size":t.size,"data-edge-tab":i?`true`:void 0,"data-leaving":r?`true`:void 0,"data-testid":J.launcher,onClick:e,"aria-label":n.launcherOpen,children:[as(t.icon),a?/* @__PURE__ */ _(`span`,{class:`${rs}-fab-label`,children:j(n,t.label??``)}):null]})}function as(e){let t=ts[e];return t?/* @__PURE__ */ _(t,{}):/* @__PURE__ */ _(os,{source:e})}function os({source:e}){return/* @__PURE__ */ _(`span`,{ref:t=>{t&&ss(t,e)},"aria-hidden":`true`})}function ss(e,t){if(e.dataset.svgMounted!==t)try{let n=new DOMParser().parseFromString(t,`image/svg+xml`).documentElement;n.tagName.toLowerCase()===`svg`&&(e.replaceChildren(document.importNode(n,!0)),e.dataset.svgMounted=t)}catch{}}function cs({callout:e,launcherPosition:t,strings:n,closeLabel:r,onDismiss:i}){let[a,o]=h(!1);return u(()=>{let t=setTimeout(()=>o(!0),e.delayMs);return()=>clearTimeout(t)},[e.delayMs]),u(()=>{if(!a||e.autoDismissMs<=0)return;let t=setTimeout(i,e.autoDismissMs);return()=>clearTimeout(t)},[a,e.autoDismissMs,i]),a?/* @__PURE__ */ v(`div`,{class:`${rs}-callout`,role:`status`,"data-shape":e.shape,"data-position":ls(e.position,t),"data-animated":e.animated?`true`:void 0,"data-testid":J.callout,children:[/* @__PURE__ */ _(`span`,{children:j(n,e.text)}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${rs}-callout-close`,onClick:i,"aria-label":r,title:r,"data-testid":J.calloutDismiss,children:/* @__PURE__ */ _($a,{})})]}):null}function ls(e,t){let n=t.endsWith(`-right`),r=t.startsWith(`bottom-`);return e===`vertical`?r?`top`:`bottom`:n?`left`:`right`}function us(e){function t(t){if(t.key!==`Tab`)return;let n=[...e.querySelectorAll(`a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),[tabindex]:not([tabindex="-1"])`)].filter(e=>e.offsetParent!==null||e===document.activeElement);if(n.length===0){t.preventDefault();return}let r=n[0],i=n[n.length-1];if(!r||!i)return;let a=e.getRootNode().activeElement;t.shiftKey&&a===r?(t.preventDefault(),i.focus()):!t.shiftKey&&a===i&&(t.preventDefault(),r.focus())}return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)}const ds=N.cssPrefix;function fs({title:e,actions:t}){return/* @__PURE__ */ v(`header`,{class:`${ds}-back-header`,part:`header`,"data-variant":`title`,children:[/* @__PURE__ */ _(`span`,{class:`${ds}-back-spacer`,"aria-hidden":`true`}),/* @__PURE__ */ _(`h1`,{class:`${ds}-back-title`,children:e}),t??/* @__PURE__ */ _(`span`,{class:`${ds}-back-spacer`,"aria-hidden":`true`})]})}function ps({title:e,backLabel:t,onBack:n,actions:r,testid:i}){return/* @__PURE__ */ v(`header`,{class:`${ds}-back-header`,part:`header`,"data-testid":i,children:[/* @__PURE__ */ _(`button`,{type:`button`,class:`${ds}-icon-btn`,onClick:n,"aria-label":t,title:t,children:/* @__PURE__ */ _(Co,{})}),/* @__PURE__ */ _(`h1`,{class:`${ds}-back-title`,children:e}),r??/* @__PURE__ */ _(`span`,{class:`${ds}-back-spacer`,"aria-hidden":`true`})]})}function ms({textSig:e,doneSig:t,generativeUi:n=!1,strings:r=T}){let i=m(null);return f(()=>{let o=i.current;if(!o)return;o.classList.add(`${N.cssPrefix}-md`),o.replaceChildren();let s=n?ti(o,{cssPrefix:N.cssPrefix,strings:r}):void 0,c=y.parser(s??y.default_renderer(o)),l=0,u=a(()=>{let i=e.value,a=t.value;i.length<l&&(s?.dispose(),o.replaceChildren(),s=n?ti(o,{cssPrefix:N.cssPrefix,strings:r}):void 0,c=y.parser(s??y.default_renderer(o)),l=0);let u=i.slice(l);u&&y.parser_write(c,u),l=i.length,a&&(y.parser_end(c),s?.finish())}),d=new MutationObserver(()=>vs(o));d.observe(o,{childList:!0,subtree:!0}),vs(o);function f(e){let t=e.target?.closest?.(`a`);if(!t||!(t instanceof HTMLAnchorElement))return;let n=t.getAttribute(`href`)??``;n&&!n.startsWith(`#`)&&(e.preventDefault(),window.open(n,`_blank`,`noopener,noreferrer`))}return o.addEventListener(`click`,f),()=>{u(),s?.dispose(),d.disconnect(),o.removeEventListener(`click`,f)}},[e,t,n,r]),/* @__PURE__ */ _(`div`,{ref:i})}function hs({text:e}){let t=p(()=>o(e),[e]),n=p(()=>o(!0),[]);return/* @__PURE__ */ _(ms,{textSig:t,doneSig:n})}const gs=/<(\/?)(?:(Note|Info|Tip|Warning|Danger|Check|Callout)|Tabs?|Steps?|AccordionGroup|Accordion|Expandable|Columns|CardGroup|Card|Frame|CodeGroup|Badge|Icon|Video|Embed|ParamField|ResponseField)\b((?:"[^"]*"|'[^']*'|[^>"'])*?)(\/?)>|(^|\n)([ \t]*)(```[^]*?(?:\n[ \t]*```|$))?/g;function _s(e){let t=0,n=``;return e.replace(gs,(e,r,i,a,o,s,c,l)=>{if(r===void 0)return t?s+(l?.split(`\n${c}`).join(`
|
|
31
|
-
`)??n):e;if(r)return t--,i&&(n=n.slice(2)),i?`\n${n}`:``;o||(t++,i&&(n+=`> `));let u={};a.replace(/(\w+)=(["'])(.*?)\2/g,(e,t,n,r)=>u[t]=r);let d=u.href??u.src,f=u.title??u.path??u.query??u.body??u.header??u.name??d;return(i?`> `:``)+(f?`**${d?`[${f}](${d})`:f}**${u.type?` \`${u.type}\``:``}\n${n}`:``)})}function vs(e){for(let t of e.querySelectorAll(`a`)){let e=t.getAttribute(`href`)??``;e&&!e.startsWith(`#`)&&(t.target=`_blank`,t.rel=`noopener noreferrer`)}}const ys=/* @__PURE__ */ new Set([y.CODE_INLINE,y.ITALIC_AST,y.ITALIC_UND,y.STRONG_AST,y.STRONG_UND,y.STRIKE,y.LINK,y.RAW_URL,y.IMAGE,y.EQUATION_INLINE]);function bs(e){let t=``,n=[],r=y.parser({data:void 0,add_token:(e,r)=>{n.push(r),ys.has(r)||(t+=` `)},end_token:()=>{let e=n.pop();e!==void 0&&!ys.has(e)&&(t+=` `)},add_text:(e,n)=>void(t+=n),set_attr:()=>void 0});return y.parser_write(r,e),y.parser_end(r),t.replace(/\s+/g,` `).trim()}const xs=N.cssPrefix;function Ss({tone:e=`info`,message:t,onRetry:n,strings:r}){return/* @__PURE__ */ v(`div`,{class:`${xs}-module-empty`,role:e===`error`?`alert`:`status`,"aria-live":`polite`,children:[/* @__PURE__ */ _(`span`,{children:t}),n?/* @__PURE__ */ _(`button`,{type:`button`,class:`${xs}-module-retry`,onClick:n,children:r.errorRetry}):null]})}const Cs=N.cssPrefix,ws=z.scope(`content`);function Ts({id:e,title:t,transport:n,strings:r,bus:i,onBack:a,actions:o}){let[s,c]=h(null),[d,f]=h(!1),[p,m]=h(!1),[y,b]=h(0),[x,S]=h(null),C=l(()=>{m(!1),c(null),b(e=>e+1)},[]);u(()=>{let t=!1,r=n.listContentCollections([]).catch(()=>void 0);return Promise.all([n.listContent({ids:[e],limit:1}),r]).then(([n,r])=>{if(t)return;let a=n.items[0];a?(c(a),f(r?.items.find(e=>e.id===a.contentCollectionId)?.settings?.voteAccess===`portal`),i.emit(`contentOpen`,{contentId:e,contentCollectionId:a.contentCollectionId})):m(!0)}).catch(e=>{t||(ws.warn(`listContent (reader) failed`,{err:e}),m(!0))}),()=>{t=!0}},[n,e,y,i]),u(()=>{if(!s)return;let t=setTimeout(()=>i.emit(`contentRead`,{contentId:e}),5e3);return()=>clearTimeout(t)},[s,e,i]);let w=l(t=>{let n=(t.target?.closest?.(`a`))?.getAttribute(`href`)??``;n&&!n.startsWith(`#`)&&i.emit(`contentLinkClick`,{contentId:e})},[i,e]);function T(t){S(e),n.setContentVote({contentId:e,value:t})}function E(){return p?/* @__PURE__ */ _(Ss,{tone:`error`,message:r.errorGeneric,onRetry:C,strings:r}):s===null?/* @__PURE__ */ _(Ss,{message:r.contentLoading,strings:r}):/* @__PURE__ */ v(`article`,{class:`${Cs}-content`,"data-testid":J.contentView,onClick:w,children:[s.image?/* @__PURE__ */ _(`img`,{class:`${Cs}-content-hero`,src:s.image,alt:``,loading:`lazy`}):null,s.description?/* @__PURE__ */ _(`p`,{class:`${Cs}-content-subtitle`,children:s.description}):null,/* @__PURE__ */ _(hs,{text:_s(s.content??``)}),d?/* @__PURE__ */ _(`div`,{class:`${Cs}-content-vote`,"aria-live":`polite`,children:x===e?r.feedbackThanks:/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`span`,{children:r.contentHelpful}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${Cs}-module-retry`,onClick:()=>T(1),children:r.confirmYes}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${Cs}-module-retry`,onClick:()=>T(0),children:r.confirmNo})]})}):null]})}return/* @__PURE__ */ v(`div`,{class:`${Cs}-module`,children:[/* @__PURE__ */ _(ps,{title:s?.title||t||r.moduleBack,backLabel:r.moduleBack,onBack:a,actions:o,testid:J.backHeader}),/* @__PURE__ */ _(`div`,{class:`${Cs}-module-scroll`,"data-testid":J.contentScroll,children:E()})]})}function Es({itemCount:e,initialFocusIndex:t}){let[n,r]=h(!1),i=m(null),a=m(null),[o,s]=h(-1),c=l(()=>{r(!1),s(-1),i.current?.focus()},[]),d=l(()=>r(e=>!e),[]);return u(()=>{if(!n)return;function e(e){let t=a.current,n=i.current;if(!t||!n)return;let o=e.composedPath();o.includes(t)||o.includes(n)||(r(!1),s(-1))}return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)},[n]),u(()=>{if(!n||e===0)return;let r=t?.()??0;s(r<0||r>=e?0:r)},[n,e,t]),u(()=>{!n||o<0||(a.current?.querySelectorAll(`[role='menuitem']`))?.[o]?.focus()},[n,o]),{open:n,focusIndex:o,triggerRef:i,menuRef:a,toggle:d,close:c,onTriggerKey:l(e=>{(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r(!0))},[]),onMenuKey:l(t=>{if(e!==0)switch(t.key){case`Escape`:t.preventDefault(),c();return;case`ArrowDown`:t.preventDefault(),s(t=>(t+1)%e);return;case`ArrowUp`:t.preventDefault(),s(t=>(t-1+e)%e);return;case`Home`:t.preventDefault(),s(0);return;case`End`:t.preventDefault(),s(e-1)}},[e,c])}}function Ds({items:e,triggerLabel:t}){let n=N.cssPrefix,r=Es({itemCount:e.length});function i(e){e.disabled||(e.onSelect?.(),e.keepOpen||r.close())}function a(e,t){return e.onSelectValue?.(t)}function o(e,t){let n=t.segments;if(!n?.length)return;let r=Math.max(0,n.findIndex(e=>e.value===t.value)),i=-1;if(e.key===`ArrowRight`||e.key===`Enter`||e.key===` `)i=(r+1)%n.length;else if(e.key===`ArrowLeft`)i=(r-1+n.length)%n.length;else return;e.preventDefault(),e.stopPropagation(),a(t,n[i].value)}return/* @__PURE__ */ v(`div`,{class:`${n}-menu-wrap`,children:[/* @__PURE__ */ _(`button`,{ref:r.triggerRef,type:`button`,class:`${n}-icon-btn`,"aria-label":t,"aria-haspopup":`menu`,"aria-expanded":r.open,title:t,onClick:r.toggle,onKeyDown:r.onTriggerKey,children:/* @__PURE__ */ _(ho,{})}),r.open?/* @__PURE__ */ _(`div`,{ref:r.menuRef,class:`${n}-menu`,role:`menu`,"aria-label":t,onKeyDown:r.onMenuKey,tabIndex:-1,children:e.map(e=>e.segments?/* @__PURE__ */ v(`div`,{role:`menuitem`,class:`${n}-menu-item ${n}-menu-item-segmented`,"aria-label":e.label,tabIndex:-1,onKeyDown:t=>o(t,e),children:[e.icon?/* @__PURE__ */ _(`span`,{class:`${n}-menu-icon`,children:e.icon}):null,/* @__PURE__ */ _(`span`,{class:`${n}-menu-label`,children:e.label}),/* @__PURE__ */ _(`span`,{class:`${n}-segmented`,role:`group`,"aria-label":e.label,children:e.segments.map(t=>{let r=t.value===e.value;return/* @__PURE__ */ _(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":r,class:`${n}-segment`,"data-on":r?`true`:void 0,lang:t.lang,title:t.value,tabIndex:-1,"data-testid":`${J.langSegment}-${t.value}`,onClick:()=>a(e,t.value),children:t.label},t.value)})})]},e.id):/* @__PURE__ */ v(`button`,{type:`button`,role:`menuitem`,class:`${n}-menu-item`,"aria-pressed":e.type===`switch`?e.on:void 0,disabled:e.disabled,onClick:()=>i(e),children:[e.icon?/* @__PURE__ */ _(`span`,{class:`${n}-menu-icon`,children:e.icon}):null,/* @__PURE__ */ _(`span`,{class:`${n}-menu-label`,children:e.label}),e.type===`switch`&&e.on?/* @__PURE__ */ _(`span`,{class:`${n}-menu-check`,"aria-hidden":`true`,children:/* @__PURE__ */ _(bo,{})}):null]},e.id))}):null]})}const Os=N.cssPrefix;function ks(e){let t=typeof matchMedia!=`function`||matchMedia(`(prefers-color-scheme: dark)`).matches;return e===`host`?kt()===`dark`?`light`:`dark`:e===`auto`?t?`light`:`dark`:t?e===`light`?`dark`:`auto`:e===`dark`?`light`:`auto`}const As={normal:`large`,large:`small`,small:`normal`};function js(e){return _(e===`light`?zo:e===`dark`?Bo:Vo,{})}function Ms(e){return(e.split(`-`)[0]??e).toUpperCase()}function Ns(e,t){let n;try{n=new URL(e,window.location.href)}catch{return}if(n.protocol===`http:`||n.protocol===`https:`)return t.conversationId&&n.searchParams.set(`chat`,t.conversationId),n.searchParams.set(`widgetId`,t.widgetId),t.publicKey&&n.searchParams.set(`public_key`,t.publicKey),n.searchParams.set(`ai_agent_deployment_id`,t.aiAgentDeploymentId),n.href}function Ps({panelProps:e,variant:t}){let{options:n,panelSize:r,feedback:i,onClose:a,onClear:o,onExpand:c,onFullscreen:l,onSoundToggle:u}=e,{onToggleHistory:d,onLocaleChange:f,onThemeChange:p,onTextSizeChange:m}=e,h=n.strings,g=n.mode,y=t===`chat`,b=s(()=>i.mutedSig.value).value,x=new Set(n.actions);function S(e){return x.has(e)}let C=typeof matchMedia==`function`&&matchMedia(`(max-width: 640px)`).matches;function w(e){return!C&&Na(e,g,r)}let T=n.themeMode,E={auto:h.themeAuto,light:h.themeLight,dark:h.themeDark,host:h.themeAuto},D=n.textSize,O={small:h.textSizeSmall,normal:h.textSizeNormal,large:h.textSizeLarge},k=[];if(y&&S(`clear`)&&k.push({id:`clear`,icon:/* @__PURE__ */ _(wo,{}),label:h.newConversation,onSelect:o}),S(`expand`)&&w(`expand`)){let e=r===`expanded`;k.push({id:`expand`,icon:_(e?lo:co,{}),label:e?h.collapse:h.expand,type:`switch`,on:e,onSelect:c})}if(S(`fullscreen`)&&w(`fullscreen`)){let e=r===`fullscreen`;k.push({id:`fullscreen`,icon:_(e?fo:uo,{}),label:e?h.exitFullscreen:h.fullscreen,type:`switch`,on:e,onSelect:l})}let A=n.popOutUrl,j=n.aiAgentDeploymentId;S(`popOut`)&&A&&j&&Na(`popOut`,g,r)&&k.push({id:`popOut`,icon:/* @__PURE__ */ _(po,{}),label:h.popOut,onSelect:()=>{let t=Ns(A,{conversationId:e.conversationId,widgetId:n.widgetId,publicKey:n.publicKey,aiAgentDeploymentId:j});t&&window.open(t,`_blank`,`noopener,noreferrer`)}}),y&&S(`sound`)&&k.push({id:`sound`,icon:_(b?_o:go,{}),label:b?h.soundOff:h.soundOn,type:`switch`,on:!b,onSelect:u}),S(`theme`)&&k.push({id:`theme`,icon:js(T),label:`${h.theme}: ${E[T]}`,onSelect:()=>p(ks(T)),keepOpen:!0}),S(`textSize`)&&k.push({id:`textSize`,icon:/* @__PURE__ */ _(vo,{}),label:`${h.textSize}: ${O[D]}`,onSelect:()=>m(As[D]),keepOpen:!0}),S(`language`)&&n.availableLocales.length>1&&k.push({id:`language`,icon:/* @__PURE__ */ _(So,{}),label:h.language,segments:n.availableLocales.map(e=>({value:e,label:Ms(e),lang:e})),value:n.locale,onSelectValue:f});let M=!!a&&Pa(g,r,n.actions),N=y&&S(`history`);return/* @__PURE__ */ v(`div`,{class:`${Os}-header-actions`,children:[N?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Os}-icon-btn`,onClick:d,"aria-label":h.history,title:h.history,"data-testid":J.actionHistory,children:/* @__PURE__ */ _(xo,{})}):null,k.length>0?/* @__PURE__ */ _(Ds,{items:k,triggerLabel:h.moreActions}):null,M?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Os}-icon-btn`,onClick:a,"aria-label":h.close,title:h.close,"data-testid":J.actionClose,children:/* @__PURE__ */ _($a,{})}):null]})}const Fs={Icon:Ro};function Is(e,t){return e instanceof fa?e.status===429?e.retryAfterSeconds?t.errorRateLimitedIn.replace(`{seconds}`,String(e.retryAfterSeconds)):t.errorRateLimited:e.code===`network`?t.errorOffline:e.status!==void 0&&e.status>=500?t.errorServer:t.errorGeneric:t.errorGeneric}const Ls=N.cssPrefix;function Rs({placeholder:e,onActivate:t}){return/* @__PURE__ */ v(`button`,{type:`button`,class:`${Ls}-home-search`,onClick:t,"data-testid":J.homeSearch,children:[/* @__PURE__ */ _(`span`,{class:`${Ls}-home-search-text`,children:e}),/* @__PURE__ */ _(`span`,{class:`${Ls}-home-search-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Po,{})})]})}function zs({placeholder:e,value:t,onInput:n}){return/* @__PURE__ */ v(`div`,{class:`${Ls}-home-search`,"data-input":`true`,children:[/* @__PURE__ */ _(`input`,{type:`search`,class:`${Ls}-home-search-input`,placeholder:e,value:t,maxLength:200,onInput:e=>n(e.currentTarget.value),"data-testid":J.helpSearch}),/* @__PURE__ */ _(`span`,{class:`${Ls}-home-search-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Po,{})})]})}const Bs=N.cssPrefix;function Vs({title:e,subtitle:t,onClick:n,testid:r}){return/* @__PURE__ */ v(`button`,{type:`button`,class:`${Bs}-list-row`,onClick:n,"data-testid":r,children:[/* @__PURE__ */ v(`span`,{class:`${Bs}-list-row-body`,children:[/* @__PURE__ */ _(`span`,{class:`${Bs}-list-row-title`,children:e}),t?/* @__PURE__ */ _(`span`,{class:`${Bs}-list-row-sub`,children:t}):null]}),/* @__PURE__ */ _(`span`,{class:`${Bs}-list-row-chevron`,"aria-hidden":`true`,children:/* @__PURE__ */ _(io,{})})]})}const Hs=N.cssPrefix,Us=z.scope(`help`);function Ws(e,t,n){let r=new Map(n.map(e=>[e.id,e.title]));return t.map(t=>({id:t,title:r.get(t),rows:e.filter(e=>e.contentCollectionId===t)})).filter(e=>e.rows.length>0)}function Gs({transport:e,strings:t,bus:n},r,i){let[a,o]=h(),s=m(void 0);function c(a){if(!r?.length)return;let c={};s.current=c,o(e=>({search:i,items:[],collections:[],...e,pagination:a>1?e?.pagination:void 0,loading:!0,error:void 0})),Promise.all([e.listContent({contentCollectionIds:r,sortBy:`order`,page:a,limit:20,search:i}),a>1?void 0:e.listContentCollections(r)]).then(([e,t])=>{s.current===c&&(o(n=>({search:i,items:[...a>1?n?.items??[]:[],...e.items],collections:t?.items??n?.collections??[],pagination:e.pagination,loading:!1})),!(a>1)&&(i?n.emit(`contentSearch`,{queryLength:i.length,hitCount:e.pagination.total}):n.emit(`contentView`,{section:`help`,count:e.items.length})))}).catch(e=>{s.current===c&&(Us.warn(`listContent (help) failed`,{err:e,page:a}),o(n=>n&&{...n,loading:!1,error:Is(e,t)}))})}return u(()=>{if(!r?.length)o(void 0);else return c(1),()=>{s.current=void 0}},[e,r,i]),[a,()=>!a?.loading&&c((a?.pagination?.page??0)+1)]}function Ks(e){let{strings:t,config:n,nav:r,panelProps:i}=e,a=n.contentCollectionIds,[o,s]=h(``),[c,l]=h(``),d=Gs(e,a),f=Gs(e,c?a:void 0,c),[p,m]=o.trim()?f:d;u(()=>{let e=setTimeout(()=>l(o.trim()),300);return()=>clearTimeout(e)},[o]);function y(){if(!a?.length)return/* @__PURE__ */ _(Ss,{message:t.helpEmpty,strings:t});let e=p?.error?/* @__PURE__ */ _(Ss,{tone:`error`,message:p.error,onRetry:m,strings:t}):null;return e&&!p?.pagination?e:!p||!p.pagination&&!p.items.length?/* @__PURE__ */ _(Ss,{message:t.helpLoading,strings:t}):p.items.length?/* @__PURE__ */ v(g,{children:[Ws(p.items,a,p.collections).map(e=>/* @__PURE__ */ v(`section`,{class:`${Hs}-help-group`,children:[e.title?/* @__PURE__ */ _(`h2`,{class:`${Hs}-help-section-title`,children:e.title}):null,/* @__PURE__ */ _(`div`,{class:`${Hs}-help-card`,children:e.rows.map(e=>/* @__PURE__ */ _(Vs,{title:e.title,subtitle:e.description,onClick:()=>r.push(e.url?{kind:`iframe`,url:e.url,title:e.title}:{kind:`content`,id:e.id,title:e.title}),testid:ns(J.helpArticle,e.id)},e.id))})]},e.id)),e,p.pagination?.hasNext&&!e?/* @__PURE__ */ _(`div`,{children:/* @__PURE__ */ _(`div`,{class:`${Hs}-help-card`,children:/* @__PURE__ */ v(`button`,{type:`button`,class:`${Hs}-list-row ${Hs}-help-more`,onClick:m,"aria-busy":p.loading,children:[p.loading?/* @__PURE__ */ _(`span`,{class:`${Hs}-loading-spinner`,"aria-hidden":`true`}):null,t.helpShowMore]})})}):null]}):/* @__PURE__ */ _(Ss,{message:p.search?t.helpSearchEmpty.replace(`{query}`,p.search):t.helpEmpty,strings:t})}return/* @__PURE__ */ v(`div`,{class:`${Hs}-module`,children:[/* @__PURE__ */ _(fs,{title:t.helpTitle,actions:/* @__PURE__ */ _(Ps,{panelProps:i,variant:`plain`})}),/* @__PURE__ */ _(`div`,{class:`${Hs}-module-pad`,children:/* @__PURE__ */ _(zs,{placeholder:t.helpSearchPlaceholder,value:o,onInput:s})}),/* @__PURE__ */ _(`div`,{class:`${Hs}-help-list`,children:y()})]})}const qs={Icon:ko,Root:e=>/* @__PURE__ */ _(Ks,{...e})},Js=z.scope(`attachments`);function Ys(e,t,n){let r=Qs(e),i=[],a=[],o=tc(n.accept),s=t.reduce((e,t)=>e+t.size,0),c=t.length;for(let e of r){let t=Zs(e,c,s,n,o);t?a.push({file:e,reason:t}):(i.push(ec(e)),s+=e.size,c+=1)}return(i.length||a.length)&&Js.debug(`ingest`,{accepted:i.length,rejected:a.map(e=>({name:e.file.name,reason:e.reason}))}),{accepted:i,rejected:a}}function Xs(e){try{URL.revokeObjectURL(e.previewUrl)}catch(e){Js.debug(`revokeObjectURL failed`,{error:e})}}function Zs(e,t,n,r,i){return t>=r.maxCount?`count`:n+e.size>r.maxBytes?`bytes`:nc(e,i)?null:`mime`}function Qs(e){return e?Array.isArray(e)?e.filter(e=>e instanceof File):[...e].map(e=>e instanceof File?e:$s(e)).filter(e=>e!==null):[]}function $s(e){let t=e;return!t?.getAsFile||t.kind!==`file`?null:t.getAsFile()}function ec(e){return{file:e,id:pt(),mediaType:e.type||`application/octet-stream`,name:e.name||`pasted-file`,previewUrl:URL.createObjectURL(e),size:e.size}}function tc(e){return e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean).map(e=>{if(e.startsWith(`.`))return{kind:`ext`,ext:e};let[t=`*`,n=`*`]=e.split(`/`);return{kind:`mime`,type:t,subtype:n}})}function nc(e,t){if(t.length===0)return!0;let[n=`*`,r=`*`]=(e.type||``).toLowerCase().split(`/`),i=(e.name||``).toLowerCase();return t.some(e=>e.kind===`ext`?i.endsWith(e.ext):e.type===`image`&&e.subtype===`*`&&/\.(heic|heif|avif|bmp|tif|tiff)$/.test(i)?!0:(e.type===`*`||e.type===n)&&(e.subtype===`*`||e.subtype===r))}const rc=N.cssPrefix;function ic({attachment:e,onRemove:t,disabled:n=!1}){let r=/^image\/(jpeg|png|gif|webp|avif|bmp|x-ms-bmp|svg\+xml)$/i.test(e.mediaType);return/* @__PURE__ */ v(`span`,{class:`${rc}-attachment-chip`,title:e.name,"data-testid":ns(J.attachmentChip,e.id),children:[r?/* @__PURE__ */ _(`img`,{class:`${rc}-attachment-thumb`,src:e.previewUrl,alt:``}):/* @__PURE__ */ _(`span`,{class:`${rc}-attachment-thumb`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Eo,{})}),/* @__PURE__ */ _(`span`,{class:`${rc}-attachment-name`,children:e.name}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${rc}-attachment-remove`,onClick:t,disabled:n,"aria-label":`Remove ${e.name}`,"data-testid":ns(J.attachmentRemove,e.id),children:/* @__PURE__ */ _($a,{})})]})}const ac={isSupported:!1,start:()=>void 0,stop:()=>void 0,cancel:()=>void 0};function oc(e,t,n){return e===`disabled`?ac:e===`server`?uc(n):sc(t)}function sc(e){let t=cc();if(!t)return ac;let n=null,r=0;return{isSupported:!0,start(i,a){let o=n,s=++r;n=null,o?.abort();let c=new t;n=c,c.continuous=!0,c.interimResults=!0,c.lang=e;let l=!1;c.addEventListener(`result`,e=>{if(r!==s||n!==c)return;let t=e,a=``,o=!1;for(let e=t.resultIndex;e<t.results.length;e++){let n=t.results[e];n&&(a+=n[0].transcript,n.isFinal&&(o=!0))}i(a,o)});function u(){l||r!==s||n!==c||(l=!0,n=null,a())}c.addEventListener(`end`,u),c.addEventListener(`error`,u);try{c.start()}catch{u()}},stop(){n?.stop()},cancel(){r++;let e=n;n=null,e?.abort()}}}function cc(){return window.SpeechRecognition??window.webkitSpeechRecognition}const lc=[`audio/webm;codecs=opus`,`audio/webm`,`audio/ogg;codecs=opus`,`audio/mp4`];function uc(e){if(typeof MediaRecorder>`u`||!navigator?.mediaDevices?.getUserMedia)return ac;let t=0,n=null;function r(e){for(let t of e.stream?.getTracks()??[])t.stop();e.stream=null}function i(){t++;let e=n;n=null,e&&(r(e),e.recorder?.state!==`inactive`&&e.recorder?.stop())}async function a(i){if(i.finishing)return;i.finishing=!0;let a=i.recorder?.mimeType??`audio/webm`;r(i);let o=new Blob(i.chunks,{type:a});i.chunks=[];try{let{text:r}=await e(o,a);n===i&&t===i.generation&&r&&i.onText(r,!0)}catch{}finally{n===i&&t===i.generation&&(n=null,i.onEnd())}}return{isSupported:!0,async start(e,o){i();let s={generation:t,recorder:null,stream:null,chunks:[],onText:e,onEnd:o,finishing:!1};n=s;try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});if(n!==s||t!==s.generation){for(let t of e.getTracks())t.stop();return}s.stream=e;let r=dc(),i=new MediaRecorder(e,r?{mimeType:r}:void 0);s.recorder=i,i.addEventListener(`dataavailable`,e=>{n===s&&t===s.generation&&e.data.size>0&&s.chunks.push(e.data)}),i.addEventListener(`stop`,()=>{n===s&&t===s.generation&&a(s)}),i.start()}catch{r(s),n===s&&t===s.generation&&(n=null,o())}},stop(){let e=n;e&&(e.recorder?e.recorder.state!==`inactive`&&e.recorder.stop():i())},cancel(){i()}}}function dc(){for(let e of lc)if(MediaRecorder.isTypeSupported(e))return e}const fc=N.cssPrefix,pc=z.scope(`composer`);function mc(e){return e.reduce((e,t)=>e+t.size,0)}const hc={arrowUp:no,paperPlane:to,send:ro,chevron:io};function gc(e){return`activeElement`in e}function _c(e){return`host`in e&&`activeElement`in e}function vc({options:e,transport:t,feedback:n,bus:r,persistence:i,conversationId:a,isStreaming:o,pageToolRunning:s=!1,isMemoryCompacting:c=!1,canReleaseQueuedMessages:d=!0,queueManualMessages:p=!1,active:g=!0,isPreparing:y=!1,operatorRequestEnabled:b,canRequestOperator:x=!1,controlMode:S=`ai-agent`,onRequestOperator:C,onSend:w,onStop:T,apiRef:E}){let D=e.strings,[O,k]=h(()=>i.loadDraft(a)),[A,j]=h([]),[M,N]=h(()=>i.loadMessageQueue(a).map(e=>({id:e.id,text:e.text,attachments:[]}))),ee=m(M),te=m(!1),[P,ne]=h(!1),[re,F]=h(!1),I=m(!1),ie=m(null),ae=m(null),L=m(null),oe=m(0),se=m(a);se.current=a;let ce=m(g);ce.current=g;let R=m(y);R.current=y;let le=re||y||!g,ue=o&&S===`ai-agent`,de=ue||c&&S===`ai-agent`,fe=S===`ai-agent`&&(de||p||M.length>0),pe=l(e=>{N(t=>{let n=e(t);return i.saveMessageQueue(se.current,n.filter(e=>e.attachments.length===0).map(({id:e,text:t})=>({id:e,text:t}))),ee.current=n,n})},[i]),me=l(e=>{pe(t=>(t.find(t=>t.id===e)?.attachments.forEach(Xs),t.filter(t=>t.id!==e)))},[pe]),z=l(e=>{k(t=>{let n=typeof e==`function`?e(t):e;return n===t?t:(i.saveDraft(se.current,n),n)})},[i]),he=e.features.fileUpload,ge=e.features.voice,[_e,ve]=h(()=>oc(ge,e.locale,(e,n)=>t.transcribe(e,n))),ye=m(_e);ye.current=_e;let be=m({mode:ge,locale:e.locale,transport:t});u(()=>{let n=be.current;(n.mode!==ge||n.locale!==e.locale||n.transport!==t)&&(be.current={mode:ge,locale:e.locale,transport:t},oe.current++,ye.current.cancel(),L.current=null,ne(!1),ve(oc(ge,e.locale,(e,n)=>t.transcribe(e,n))))},[e.locale,ge,t]),f(()=>()=>{oe.current++,_e.cancel()},[_e]);let xe=l(e=>{let t=L.current;if(t===null)return!1;let n=Math.round(performance.now()-t);return pc[e](`voiceStop`,{durationMs:n}),r.emit(`voiceStop`,{durationMs:n}),L.current=null,!0},[r]),Se=l(()=>{L.current!==null&&(_e.stop(),ne(!1),xe(`info`)&&n.play(`voiceStop`))},[xe,n,_e]),Ce=l(()=>{oe.current++,_e.cancel(),ne(!1),xe(`info`)&&n.play(`voiceStop`)},[xe,n,_e]);u(()=>{(y||!g)&&Ce()},[g,Ce,y]),u(()=>{let e=ie.current;if(!e)return;let t=e.getRootNode(),n=gc(t)?t.activeElement:null;n&&e.closest(`.${fc}-panel`)?.contains(n)||e.focus({preventScroll:!0})},[]),u(()=>{let e=ie.current;if(!e)return;if(O.length===0){e.style.height=``;return}e.style.height=`auto`;let t=getComputedStyle(e),n=Number.parseFloat(t.getPropertyValue(`--${fc}-textarea-base-height`)),r=Number.parseFloat(t.borderTopWidth)+Number.parseFloat(t.borderBottomWidth),i=Math.min(e.scrollHeight+r,Number.parseFloat(t.maxHeight)),a=Number.parseFloat(t.fontSize)*.7;e.style.height=`${i<n+a?n:i}px`},[O]);let we=m(A);we.current=A,u(()=>()=>{we.current.forEach(Xs);for(let e of ee.current)e.attachments.forEach(Xs)},[]),f(()=>{if(E)return E.current={attachFromDrop:t=>{if(!he||!ce.current||I.current||R.current)return;let n=Ys(t,we.current,e.attachments);n.accepted.length!==0&&(pc.info(`attach (drop)`,{count:n.accepted.length,totalBytes:mc(n.accepted)}),r.emit(`attach`,{count:n.accepted.length,totalBytes:mc(n.accepted)}),j(e=>[...e,...n.accepted]))},fill:e=>{if(!ce.current||I.current||R.current)return;z(e);let t=ie.current;t&&(t.focus({preventScroll:!0}),requestAnimationFrame(()=>t.setSelectionRange(t.value.length,t.value.length)))},acceptQueuedMessage:me},()=>{E.current&&(E.current=null)}},[E,he,y,e.attachments,me,z]),u(()=>{let t=ie.current;if(!t)return;let n=t.closest(`.${fc}-panel`);if(!n)return;let i=n=>{if(!ce.current||I.current||R.current)return;let i=n.clipboardData;if(!i)return;let a=n.target?.closest?.(`input, textarea, [contenteditable]:not([contenteditable='false'])`);if(a&&a!==t)return;if(he){let t=Ys(i.items,we.current,e.attachments);if(t.accepted.length>0){n.preventDefault(),pc.info(`attach (paste)`,{count:t.accepted.length,totalBytes:mc(t.accepted)}),r.emit(`attach`,{count:t.accepted.length,totalBytes:mc(t.accepted)}),j(e=>[...e,...t.accepted]);return}}if(a===t)return;let o=i.getData(`text/plain`);o&&(n.preventDefault(),z(e=>e+o),t.focus())};return n.addEventListener(`paste`,i),()=>n.removeEventListener(`paste`,i)},[he,e.attachments,z]);async function Te(){let e=O.trim();if(!e&&A.length===0||!g||ue||I.current||y)return;Ce(),I.current=!0,F(!0);let t=O,n=A;try{await w(e,n)&&(z(e=>e===t?``:e),j(e=>e===n?(n.forEach(Xs),we.current=[],[]):e))}finally{I.current=!1,F(!1),requestAnimationFrame(()=>{let e=ie.current;if(!e||e.disabled||!ce.current)return;let t=e.getRootNode(),n=gc(t)?t.activeElement:null,r=n?.getAttribute(`data-testid`);if(!(n&&n!==e&&r!==J.composerSend&&r!==J.composerStop)){if(_c(t)){let e=t.host.ownerDocument;if(!e.hasFocus())return;let n=e.activeElement;if(n&&n!==t.host&&n!==e.body)return}e.focus({preventScroll:!0})}})}}function Ee(){let e=O.trim();if(!e&&A.length===0||!g||!fe||I.current||y)return;Ce();let t=A;pe(n=>[...n,{id:pt(),text:e,attachments:t}]),z(``),j(e=>e===t?(we.current=[],[]):e),ie.current?.focus({preventScroll:!0})}u(()=>{de&&(te.current=!1)},[de]),u(()=>{let e=M[0];if(!e||!d||de||te.current||re||y||!g)return;let t=setTimeout(()=>{te.current=!0,w(e.text,e.attachments,e.id).then(t=>{t?me(e.id):te.current=!1})},300);return()=>clearTimeout(t)},[g,d,y,w,de,M,me,re]);function De(e){e.key!==`Enter`||e.shiftKey||e.isComposing||(e.preventDefault(),fe&&(O.trim()||A.length>0)?Ee():ue?T():Te())}function Oe(t){let n=t.target;if(!g||I.current||y){n.value=``;return}let i=Ys(n.files,A,e.attachments);i.accepted.length>0&&(pc.info(`attach (file picker)`,{count:i.accepted.length,totalBytes:mc(i.accepted)}),r.emit(`attach`,{count:i.accepted.length,totalBytes:mc(i.accepted)}),j(e=>[...e,...i.accepted])),n.value=``}function ke(e){!g||I.current||y||(pc.info(`removeAttachment`,{id:e}),r.emit(`removeAttachment`,{id:e}),j(t=>{let n=t.find(t=>t.id===e);return n&&Xs(n),t.filter(t=>t.id!==e)}))}function Ae(){if(P){Se();return}if(!g||!_e.isSupported||I.current||y)return;let e=++oe.current;L.current=performance.now(),pc.info(`voiceStart`),r.emit(`voiceStart`,void 0),ne(!0),n.play(`voiceStart`),_e.start((t,n)=>{oe.current===e&&ce.current&&!R.current&&!I.current&&n&&z(e=>`${e}${t} `)},()=>{oe.current===e&&ce.current&&(ne(!1),xe(`debug`))})}let je=hc[e.composer.sendButton.icon],Me=!!(O.trim()||A.length>0),Ne=ue||s&&!Me;return/* @__PURE__ */ v(`div`,{class:`${fc}-composer`,part:`composer`,"data-testid":J.composer,children:[M.length>0?/* @__PURE__ */ _(`div`,{class:`${fc}-message-queue`,"aria-label":D.queueMessage,"data-testid":J.messageQueue,children:M.map(e=>/* @__PURE__ */ v(`div`,{class:`${fc}-attachment-chip ${fc}-queued-message`,"data-testid":`${J.queuedMessage}-${e.id}`,children:[/* @__PURE__ */ _(`span`,{class:`${fc}-attachment-name ${fc}-queued-text`,children:e.text||e.attachments.map(e=>e.name).join(`, `)}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${fc}-attachment-remove`,onClick:()=>me(e.id),"aria-label":D.removeQueuedMessage,title:D.removeQueuedMessage,"data-testid":`${J.queuedMessageRemove}-${e.id}`,children:/* @__PURE__ */ _($a,{})})]},e.id))}):null,A.length>0?/* @__PURE__ */ _(`div`,{class:`${fc}-attachments`,children:A.map(e=>/* @__PURE__ */ _(ic,{attachment:e,onRemove:()=>ke(e.id),disabled:le},e.id))}):null,/* @__PURE__ */ v(`div`,{class:`${fc}-composer-row`,children:[/* @__PURE__ */ v(`div`,{class:`${fc}-composer-actions`,children:[he?/* @__PURE__ */ _(`button`,{type:`button`,class:`${fc}-icon-btn`,onClick:()=>ae.current?.click(),disabled:le,"aria-label":D.attach,"data-testid":J.composerAttach,children:/* @__PURE__ */ _(oo,{})}):null,_e.isSupported?/* @__PURE__ */ _(`button`,{type:`button`,class:`${fc}-icon-btn`,onClick:Ae,disabled:le,"aria-label":P?D.micStop:D.micStart,"aria-pressed":P,"data-recording":P?`true`:void 0,"data-testid":J.composerVoice,children:/* @__PURE__ */ _(so,{})}):null]}),/* @__PURE__ */ _(`textarea`,{ref:ie,name:`message`,class:`${fc}-textarea`,rows:1,value:O,placeholder:D.composerPlaceholder,onInput:e=>z(e.currentTarget.value),onKeyDown:De,disabled:le,"aria-label":D.composerPlaceholder,"data-testid":J.composerInput}),fe&&Me?/* @__PURE__ */ _(`button`,{type:`button`,class:`${fc}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:Ee,disabled:le,"aria-label":D.queueMessage,title:D.queueMessage,"data-testid":J.composerSend,children:/* @__PURE__ */ _(je,{})}):null,Ne?/* @__PURE__ */ _(`button`,{type:`button`,class:`${fc}-send`,onClick:T,disabled:le,"aria-label":D.stop,"data-testid":J.composerStop,children:/* @__PURE__ */ _(ao,{})}):null,!Ne&&(!fe||!Me)?/* @__PURE__ */ _(`button`,{type:`button`,class:`${fc}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:()=>void Te(),disabled:le||!O.trim()&&A.length===0,"aria-label":D.send,"data-testid":J.composerSend,children:/* @__PURE__ */ _(je,{})}):null,b&&S===`ai-agent`&&C?/* @__PURE__ */ _(`button`,{type:`button`,class:`${fc}-icon-btn`,onClick:C,disabled:le||!x,"aria-label":D.talkToOperator,title:D.talkToOperator,"data-testid":J.operatorRequest,children:/* @__PURE__ */ _(Mo,{})}):null]}),/* @__PURE__ */ _(`input`,{ref:ae,name:`attachments`,type:`file`,multiple:!0,accept:e.attachments.accept,onChange:Oe,disabled:le,class:`${fc}-sr-only`,"data-testid":J.composerFileInput})]})}const yc=N.cssPrefix;function bc({onClick:e,children:t,testid:n}){return e?/* @__PURE__ */ _(`button`,{type:`button`,class:`${yc}-home-card`,"data-interactive":`true`,onClick:e,"data-testid":n,children:t}):/* @__PURE__ */ _(`div`,{class:`${yc}-home-card`,"data-testid":n,children:t})}function xc(e){return e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(``)}const Sc=N.cssPrefix,Cc=z.scope(`news`);function wc(e,t){let n=e?new Date(e):void 0;if(n&&!Number.isNaN(n.getTime()))return new Intl.DateTimeFormat(t,{dateStyle:`medium`}).format(n)}function Tc({options:e,transport:t,strings:n,config:r,nav:i,bus:a,panelProps:o,latestNews:s}){let c=r.contentCollectionIds,[l,d]=h({items:[],loading:!0}),f=m(void 0);function p(e){if(!c?.length)return;let r={};f.current=r,d(e=>({...e,loading:!0,error:void 0})),t.listContent({contentCollectionIds:c,sortBy:`publishedAt`,sortOrder:`desc`,page:e,limit:10}).then(t=>{if(f.current!==r||(d(n=>({items:e>1?[...n.items,...t.items]:t.items,pagination:t.pagination,loading:!1})),e>1))return;a.emit(`contentView`,{section:`news`,count:t.items.length});let n=t.items[0];n&&s.markSeen(n.id)}).catch(t=>{f.current===r&&(Cc.warn(`listContent (news) failed`,{err:t,page:e}),d(e=>({...e,loading:!1,error:Is(t,n)})))})}function g(){l.loading||p((l.pagination?.page??0)+1)}u(()=>(d({items:[],loading:!0}),p(1),()=>{f.current=void 0}),[t,c]);function y(t){let n=wc(t.publishedAt,e.locale);return/* @__PURE__ */ v(`button`,{type:`button`,class:`${Sc}-news-card`,onClick:()=>i.push({kind:`content`,id:t.id,title:t.title}),"data-testid":ns(J.newsItem,t.id),children:[t.image?/* @__PURE__ */ _(`img`,{class:`${Sc}-news-hero`,src:t.image,alt:``,loading:`lazy`}):null,/* @__PURE__ */ v(`span`,{class:`${Sc}-news-body`,children:[/* @__PURE__ */ _(`span`,{class:`${Sc}-news-title`,children:t.title}),n||t.tags?.length?/* @__PURE__ */ v(`span`,{class:`${Sc}-news-meta`,children:[n?/* @__PURE__ */ _(`time`,{dateTime:t.publishedAt,children:n}):null,t.tags?.map(e=>/* @__PURE__ */ _(`span`,{class:`${Sc}-news-tag`,children:e},e))]}):null,t.description?/* @__PURE__ */ _(`span`,{class:`${Sc}-news-summary`,children:t.description}):null]})]},t.id)}function b(){if(!c?.length)return/* @__PURE__ */ _(Ss,{message:n.newsEmpty,strings:n});let e=l.error?/* @__PURE__ */ _(Ss,{tone:`error`,message:l.error,onRetry:g,strings:n}):null;return e&&!l.pagination?e:l.pagination?l.items.length?/* @__PURE__ */ v(`div`,{class:`${Sc}-news-list`,children:[l.items.map(y),e,l.pagination.hasNext&&!e?/* @__PURE__ */ v(`button`,{type:`button`,class:`${Sc}-news-more`,onClick:g,"aria-busy":l.loading,"data-testid":J.newsMore,children:[l.loading?/* @__PURE__ */ _(`span`,{class:`${Sc}-loading-spinner`,"aria-hidden":`true`}):null,n.newsShowMore]}):null]}):/* @__PURE__ */ _(Ss,{message:n.newsEmpty,strings:n}):/* @__PURE__ */ _(Ss,{message:n.newsLoading,strings:n})}return/* @__PURE__ */ v(`div`,{class:`${Sc}-module`,children:[/* @__PURE__ */ _(fs,{title:n.newsTitle,actions:/* @__PURE__ */ _(Ps,{panelProps:o,variant:`plain`})}),/* @__PURE__ */ _(`div`,{class:`${Sc}-module-scroll`,children:b()})]})}const Ec={Icon:Lo,Root:e=>/* @__PURE__ */ _(Tc,{...e})},Y=N.cssPrefix,Dc=z.scope(`home`);function Oc(e){let t=e.options.userContext?.name,n=e.config.greetingText?j(e.strings,e.config.greetingText):void 0;if(n){let r=t?n.replace(`{name}`,t):n.replace(/\s*\{name\}\s*/,` `).trim(),i=e.strings.homeGreetingLead;return{title:r,subtitle:r.toLowerCase()===i.toLowerCase()?void 0:i}}return t?{title:e.strings.homeGreetingNamed.replace(`{name}`,t),subtitle:e.strings.homeGreetingLead}:{title:e.strings.homeGreeting}}function kc(e,t){return t.url?e.push({kind:`iframe`,url:t.url,title:t.title}):e.push({kind:`content`,id:t.id,title:t.title})}function Ac({options:e,onAsk:t}){let[n,r]=h(``),{sendButton:i}=e.composer,a=hc[i.icon];function o(e){e.preventDefault();let i=n.trim();i&&(r(``),t(i))}return/* @__PURE__ */ v(`form`,{class:`${Y}-home-search ${Y}-home-ask`,"data-input":`true`,onSubmit:o,"data-testid":J.homeAsk,children:[/* @__PURE__ */ _(`input`,{type:`text`,class:`${Y}-home-search-input`,placeholder:e.strings.homeAskPlaceholder,"aria-label":e.strings.homeAskPlaceholder,value:n,enterKeyHint:`send`,onInput:e=>r(e.currentTarget.value)}),/* @__PURE__ */ _(`button`,{type:`submit`,class:`${Y}-send`,"data-shape":i.shape,"data-variant":i.variant,disabled:!n.trim(),"aria-label":e.strings.send,children:/* @__PURE__ */ _(a,{})})]})}function jc(e,t){return Ca(e,t,t.type!==`upsert`||t.activity===!0)}function Mc(e){let{transport:t,strings:n,config:r,nav:i,bus:a,panelProps:o,latestNews:s}=e,[c,l]=h(null),[d,f]=h([]),p=r.contentCollectionIds?.join(`,`),m=e.options.modules.list.some(e=>e.layout===`chat`);u(()=>{if(r.showRecentConversations===!1)return;let e=!1,n=!0,i=[],a=t.subscribeConversationChanges(e=>{n&&i.push(e),l(t=>jc(t?[t]:[],e)[0]??null)});return t.listConversations({limit:m?50:1}).then(t=>{if(e)return;let r=i.reduce(jc,t.conversations);i=[],n=!1,l(r[0]??null)}).catch(t=>{e||(i=[],n=!1,Dc.warn(`listConversations (home) failed`,{err:t}))}),()=>{e=!0,a()}},[t,r.showRecentConversations,m]),u(()=>{if(!r.contentCollectionIds?.length)return;let e=!1;return t.listContent({contentCollectionIds:r.contentCollectionIds,pinned:!0,limit:6}).then(t=>{e||(f(t.items),a.emit(`contentView`,{section:`home`,count:t.items.length}))}).catch(t=>!e&&Dc.warn(`listContent (home) failed`,{err:t})),()=>{e=!0}},[t,p,a]);let y=Oc(e),b=r.userAvatars??[],x=r.status,S=x?.text?j(n,x.text):n.homeStatus,C=r.contentBlockTitle?j(n,r.contentBlockTitle):n.homeContentTitle,w=s.item,T=wc(w?.publishedAt,e.options.locale);return/* @__PURE__ */ _(`div`,{class:`${Y}-module ${Y}-home`,"data-testid":J.homeView,children:/* @__PURE__ */ v(`div`,{class:`${Y}-home-scroll`,children:[/* @__PURE__ */ v(`div`,{class:`${Y}-home-hero`,children:[/* @__PURE__ */ v(`div`,{class:`${Y}-home-hero-top`,children:[r.brandName?/* @__PURE__ */ _(`span`,{class:`${Y}-home-brand`,"data-testid":J.homeBrand,children:r.brandName}):/* @__PURE__ */ _(`span`,{class:`${Y}-home-brand-spacer`,"aria-hidden":`true`}),/* @__PURE__ */ v(`div`,{class:`${Y}-home-hero-actions`,children:[b.length>0?/* @__PURE__ */ _(`div`,{class:`${Y}-home-avatars`,children:b.map(e=>/* @__PURE__ */ _(`span`,{class:`${Y}-home-avatar`,title:e.role?`${e.name} · ${e.role}`:e.name,children:e.avatar?/* @__PURE__ */ _(`img`,{src:e.avatar,alt:``,loading:`lazy`}):/* @__PURE__ */ _(`span`,{children:xc(e.name)})},e.name))}):null,/* @__PURE__ */ _(Ps,{panelProps:o,variant:`plain`})]})]}),r.showGreeting===!1?null:/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`h1`,{class:`${Y}-home-greeting`,"data-testid":J.homeGreeting,children:y.title}),y.subtitle?/* @__PURE__ */ _(`p`,{class:`${Y}-home-lead`,children:y.subtitle}):null]})]}),/* @__PURE__ */ v(`div`,{class:`${Y}-home-cards`,children:[m?/* @__PURE__ */ _(Ac,{options:e.options,onAsk:e=>i.startNewConversation(e)}):null,r.showSearchBar===!1?null:/* @__PURE__ */ _(Rs,{placeholder:n.homeSearchPlaceholder,onActivate:()=>i.switchToLayout(`help`)}),w?/* @__PURE__ */ _(bc,{onClick:()=>{s.markSeen(w.id),i.push({kind:`content`,id:w.id,title:w.title})},testid:J.homeWhatsNew,children:/* @__PURE__ */ v(`div`,{class:`${Y}-home-recent-row`,"data-unread":s.unseen?`true`:void 0,children:[/* @__PURE__ */ _(`span`,{class:`${Y}-home-recent-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Lo,{})}),/* @__PURE__ */ v(`span`,{class:`${Y}-home-recent-body`,children:[/* @__PURE__ */ _(`span`,{class:`${Y}-home-recent-title`,children:n.homeWhatsNew}),/* @__PURE__ */ _(`span`,{class:`${Y}-home-recent-preview`,children:T?`${w.title} · ${T}`:w.title})]}),s.unseen?/* @__PURE__ */ _(`span`,{class:`${Y}-home-recent-dot`,role:`img`,"aria-label":n.newsUnseen}):null]})}):null,c?/* @__PURE__ */ _(bc,{onClick:()=>i.selectConversation(c),testid:J.homeRecent,children:/* @__PURE__ */ v(`div`,{class:`${Y}-home-recent-row`,"data-unread":c.hasUnread?`true`:void 0,children:[/* @__PURE__ */ _(`span`,{class:`${Y}-home-recent-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Ro,{})}),/* @__PURE__ */ v(`span`,{class:`${Y}-home-recent-body`,children:[/* @__PURE__ */ _(`span`,{class:`${Y}-home-recent-title`,children:c.title}),c.preview?/* @__PURE__ */ _(`span`,{class:`${Y}-home-recent-preview`,children:bs(c.preview)}):null]}),c.hasUnread?/* @__PURE__ */ _(`span`,{class:`${Y}-home-recent-dot`,"aria-label":`Unread`}):null]})}):null,x?/* @__PURE__ */ _(bc,{onClick:x.url?()=>i.push({kind:`iframe`,url:x.url,title:S}):void 0,children:/* @__PURE__ */ v(`div`,{class:`${Y}-home-status`,"data-level":x.level??`operational`,children:[/* @__PURE__ */ _(`span`,{class:`${Y}-home-status-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Fo,{})}),/* @__PURE__ */ _(`span`,{class:`${Y}-home-status-text`,children:S})]})}):null,d.length>0?/* @__PURE__ */ v(`section`,{class:`${Y}-home-content`,children:[/* @__PURE__ */ _(`div`,{class:`${Y}-home-content-title`,children:C}),/* @__PURE__ */ _(`div`,{class:`${Y}-home-content-list`,children:d.map(e=>/* @__PURE__ */ _(Vs,{title:e.title,subtitle:e.description,onClick:()=>kc(i,e),testid:ns(J.homeContentRow,e.id)},e.id))})]}):null]})]})})}const Nc={chat:Fs,home:{Icon:Io,Root:e=>/* @__PURE__ */ _(Mc,{...e})},help:qs,news:Ec},Pc=N.cssPrefix;function Fc({modules:e,activeTab:t,strings:n,hasUnread:r,onSelect:i}){return/* @__PURE__ */ _(`nav`,{class:`${Pc}-tabbar`,role:`tablist`,"aria-label":n.panelTitle,children:e.map(e=>{let a=Nc[e.layout].Icon,o=e.id===t,s=e.layout===`chat`&&r;return/* @__PURE__ */ v(`button`,{type:`button`,role:`tab`,"aria-selected":o,class:`${Pc}-tab`,onClick:()=>i(e.id),"data-testid":ns(J.tab,e.id),children:[/* @__PURE__ */ v(`span`,{class:`${Pc}-tab-icon`,"aria-hidden":`true`,children:[/* @__PURE__ */ _(a,{}),s?/* @__PURE__ */ _(`span`,{class:`${Pc}-tab-badge`,"data-testid":J.tabBadge,"aria-label":`Unread`}):null]}),/* @__PURE__ */ _(`span`,{class:`${Pc}-tab-label`,children:j(n,e.label)})]},e.id)})})}const Ic=N.cssPrefix;function Lc({url:e,title:t,strings:n,onBack:r,actions:i}){return/* @__PURE__ */ v(`div`,{class:`${Ic}-module`,children:[/* @__PURE__ */ _(ps,{title:t||n.moduleBack,backLabel:n.moduleBack,onBack:r,actions:i}),/* @__PURE__ */ _(`iframe`,{class:`${Ic}-content-frame`,src:e,title:t||`content`,sandbox:`allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-downloads`,referrerpolicy:`no-referrer`,loading:`lazy`,allow:`fullscreen`})]})}const Rc=N.cssPrefix;function zc({agent:e,strings:t}){let n=e.status??`online`,r=j(t,e.name),i=e.title?j(t,e.title):null;return/* @__PURE__ */ v(`div`,{class:`${Rc}-agent`,children:[/* @__PURE__ */ _(`div`,{class:`${Rc}-agent-avatar`,"data-status":n,children:e.avatar?/* @__PURE__ */ _(`img`,{src:e.avatar,alt:``}):/* @__PURE__ */ _(`span`,{children:xc(r)})}),/* @__PURE__ */ v(`div`,{class:`${Rc}-agent-meta`,children:[/* @__PURE__ */ _(`strong`,{children:r}),i?/* @__PURE__ */ _(`span`,{children:i}):null]})]})}const Bc=[`today`,`yesterday`,`lastWeek`,`older`];function Vc(e,t){let n=Date.parse(t);if(!Number.isFinite(n))return`older`;let r=Math.floor((Uc(e)-Uc(n))/864e5);return r<=0?`today`:r===1?`yesterday`:r<7?`lastWeek`:`older`}function Hc(e,t){let n=/* @__PURE__ */ new Map;for(let r of t){let t=Vc(e,r.lastMessageAt),i=n.get(t);i?i.push(r):n.set(t,[r])}return Bc.filter(e=>n.has(e)).map(e=>({bucket:e,conversations:n.get(e)}))}function Uc(e){let t=new Date(e);return t.setUTCHours(0,0,0,0),t.getTime()}const Wc=z.scope(`history`),Gc={today:`dateToday`,yesterday:`dateYesterday`,lastWeek:`dateLastWeek`,older:`dateOlder`};function Kc(e,t){let n=t.type!==`upsert`||t.activity===!0;if(t.type===`snapshot`&&t.result.pagination.page===1&&e.pagination.page>1){let r=Ca(e.conversations.slice(0,t.result.pagination.limit),t,n);if(t.result.conversations.length===0){if(r.length===0)return t.result;let e=Math.max(t.result.pagination.total,r.length);return{...t.result,conversations:r,pagination:{...t.result.pagination,total:e,totalPages:Math.ceil(e/t.result.pagination.limit)}}}let i=new Set(r.map(e=>e.conversationId)),a=e.conversations.slice(t.result.pagination.limit).filter(e=>!i.has(e.conversationId)),o=e.pagination.page,s={...t.result.pagination,page:o,hasPrev:o>1,hasNext:o<t.result.pagination.totalPages};return{conversations:[...r,...a],pagination:s}}let r=Ca(e.conversations,t,n);return r===e.conversations?e:{...t.type===`snapshot`?t.result:e,conversations:r}}function qc(e,t,n){let r=Date.parse(e);return Number.isFinite(r)?new Date(r).toDateString()===new Date(t).toDateString()?new Intl.DateTimeFormat(n,{hour:`numeric`,minute:`2-digit`}).format(r):t-r<6048e5?new Intl.DateTimeFormat(n,{weekday:`short`}).format(r):new Intl.DateTimeFormat(n,{month:`short`,day:`numeric`}).format(r):``}function Jc({transport:e,strings:t,locale:n,persistence:r,onSelect:i,onNewConversation:a}){let o=N.cssPrefix,s=e.peekConversations({limit:50}),[c,l]=h(s?`loaded`:`loading`),[d,f]=h(s),[p,y]=h(!1),b=m(void 0),x=d?.conversations??[],S=d?.pagination;u(()=>{let t=!1,n=!0,i=[],a=e.subscribeConversationChanges(e=>{n&&i.push(e),f(t=>t&&Kc(t,e))});b.current=void 0,y(!1);let o=e.peekConversations({limit:50});return f(o),l(o?`loaded`:`loading`),e.listConversations({limit:50}).then(e=>{if(t)return;let a=e;for(let e of i)a=Kc(a,e);i=[],n=!1,f(a),l(`loaded`),r.saveHistoryCount(a.conversations.length)}).catch(e=>{t||(i=[],n=!1,Wc.warn(`listConversations failed`,{err:e}),l(`error`))}),()=>{t=!0,a(),b.current=void 0}},[e,r,n]);async function C(){if(b.current||!S?.hasNext)return;let t={};b.current=t,y(!0);try{let n=await e.listConversations({page:S.page+1,limit:S.limit});if(b.current!==t)return;f(e=>{if(!e)return e;let t=new Set(e.conversations.map(e=>e.conversationId)),i=n.conversations.filter(e=>!t.has(e.conversationId)&&(t.add(e.conversationId),!0)),a={conversations:[...e.conversations,...i],pagination:n.pagination};return r.saveHistoryCount(a.conversations.length),a})}catch(e){if(b.current!==t)return;Wc.warn(`listConversations page failed`,{err:e,page:S.page+1})}finally{b.current===t&&(b.current=void 0,y(!1))}}let w=a?/* @__PURE__ */ _(`div`,{class:`${o}-history-footer`,children:/* @__PURE__ */ v(`button`,{type:`button`,class:`${o}-history-new`,onClick:a,"data-testid":J.sidebarNewConversation,children:[/* @__PURE__ */ _(eo,{}),t.newConversation]})}):null;if(c===`loading`){let e=Math.min(r.loadHistoryCount()??3,6);return/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`div`,{class:`${o}-history`,"aria-busy":`true`,"aria-label":t.historyLoading,children:/* @__PURE__ */ v(`div`,{class:`${o}-history-group`,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`div`,{class:`${o}-history-heading`,children:/* @__PURE__ */ _(`span`,{class:`${o}-skeleton ${o}-skeleton-heading`})}),/* @__PURE__ */ _(`div`,{class:`${o}-history-card`,children:Array.from({length:Math.max(1,e)},(e,t)=>/* @__PURE__ */ v(`div`,{class:`${o}-history-item ${o}-history-item-skeleton`,children:[/* @__PURE__ */ _(`span`,{class:`${o}-history-avatar ${o}-skeleton`}),/* @__PURE__ */ v(`span`,{class:`${o}-history-body`,children:[/* @__PURE__ */ v(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ _(`span`,{class:`${o}-history-title`,children:/* @__PURE__ */ _(`span`,{class:`${o}-skeleton ${o}-skeleton-title`})}),/* @__PURE__ */ _(`span`,{class:`${o}-history-time`,children:/* @__PURE__ */ _(`span`,{class:`${o}-skeleton ${o}-skeleton-time`})})]}),/* @__PURE__ */ _(`span`,{class:`${o}-history-row`,children:/* @__PURE__ */ _(`span`,{class:`${o}-history-preview`,children:/* @__PURE__ */ _(`span`,{class:`${o}-skeleton ${o}-skeleton-preview`})})})]})]},t))})]})}),w]})}if(c===`error`||x.length===0)return/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`div`,{class:`${o}-history-empty`,children:t.historyEmpty}),w]});let T=Date.now(),E=Hc(T,x);return/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ v(`div`,{class:`${o}-history`,role:`list`,children:[E.map(e=>/* @__PURE__ */ v(`div`,{class:`${o}-history-group`,children:[/* @__PURE__ */ _(`div`,{class:`${o}-history-heading`,children:t[Gc[e.bucket]]}),/* @__PURE__ */ _(`div`,{class:`${o}-history-card`,children:e.conversations.map(e=>/* @__PURE__ */ _(`div`,{role:`listitem`,children:/* @__PURE__ */ v(`button`,{type:`button`,class:`${o}-history-item`,onClick:()=>i(e),"data-closed":e.canContinue?void 0:`true`,"data-unread":e.hasUnread?`true`:void 0,"data-testid":ns(J.historyItem,e.conversationId),children:[/* @__PURE__ */ _(`span`,{class:`${o}-history-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Oo,{})}),/* @__PURE__ */ v(`span`,{class:`${o}-history-body`,children:[/* @__PURE__ */ v(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ _(`span`,{class:`${o}-history-title`,children:e.title}),/* @__PURE__ */ _(`span`,{class:`${o}-history-time`,children:qc(e.lastMessageAt,T,n)})]}),/* @__PURE__ */ v(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ _(`span`,{class:`${o}-history-preview`,children:e.preview&&bs(e.preview)||(e.canContinue?t.historyContinue:t.conversationClosed)}),e.hasUnread?/* @__PURE__ */ _(`span`,{class:`${o}-history-dot`}):null]})]})]})},e.conversationId))})]},e.bucket)),S?.hasNext?/* @__PURE__ */ _(`div`,{class:`${o}-history-more`,children:/* @__PURE__ */ _(`button`,{type:`button`,onClick:C,disabled:p,"aria-busy":p,"data-testid":J.historyLoadMore,children:t.loadMoreConversations})}):null]}),w]})}const Yc=N.cssPrefix;function Xc({visible:e,strings:t}){return e?/* @__PURE__ */ _(`div`,{class:`${Yc}-dropzone`,role:`status`,"aria-live":`polite`,children:t.dropZone}):null}const Zc=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Qc=/^https?:\/\/[^\s.]+\.[^\s]+$/i,$c=/^[+]?[\d\s().-]{6,}$/;function el(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>String(t[n]??`{${n}}`))}function tl(e){return Array.isArray(e)?e.length:+!!e?.trim()}function nl(e,t,n){let r=e.required??!0,i=e.validation;if(e.type===`multiselect`){let e=tl(t);return r&&e===0?n.formRequired:e===0?void 0:i?.minSelections!=null&&e<i.minSelections?el(n.formChooseAtLeast,{min:i.minSelections}):i?.maxSelections!=null&&e>i.maxSelections?el(n.formChooseAtMost,{max:i.maxSelections}):void 0}let a=typeof t==`string`?t.trim():``;if(!a)return r?n.formRequired:void 0;switch(e.type){case`email`:if(!Zc.test(a))return n.formInvalidEmail;break;case`url`:if(!Qc.test(a))return n.formInvalidUrl;break;case`tel`:if(!$c.test(a))return n.formInvalidTel;break;case`number`:{let e=Number(a);if(!Number.isFinite(e))return n.formInvalidNumber;if(i?.min!=null&&e<i.min)return el(n.formNumberTooSmall,{min:i.min});if(i?.max!=null&&e>i.max)return el(n.formNumberTooLarge,{max:i.max});break}}if(i?.minLength!=null&&a.length<i.minLength)return el(n.formTooShort,{min:i.minLength});if(i?.maxLength!=null&&a.length>i.maxLength)return el(n.formTooLong,{max:i.maxLength});if(i?.pattern)try{if(!new RegExp(i.pattern).test(a))return n.formPatternMismatch}catch{}}function rl(e,t,n){let r={};for(let i of e){let e=nl(i,t[i.name],n);e&&(r[i.name]=e)}return r}function il(e){let t={};for(let[n,r]of Object.entries(e)){let e=Array.isArray(r)?r.join(`, `):r;e.trim()&&(t[n]=e.trim())}return t}const X=N.cssPrefix,al=`__other__`;function ol({fields:e,strings:t,submitLabel:n,onSubmit:r,skipLabel:i,onSkip:a,footerHint:o,submitOnEnter:s,disabled:c,initialValues:l,hideActions:u,fieldTypeLabels:d,rootTestId:f,submitTestId:p,skipTestId:m}){let[g,y]=h(()=>({...ul(e),...l})),[b,x]=h({}),[S,C]=h({});function w(e){S[e]&&C(t=>({...t,[e]:``}))}function T(e,t){y(n=>({...n,[e]:t})),w(e)}function E(e,t){x(n=>({...n,[e]:t})),w(e)}function D(n){if(n.preventDefault(),c)return;let i=dl(e,g,b),a=rl(e,i,t);Object.keys(a).length>0?C(a):r(il(i))}function O(e){!s||e.key!==`Enter`||e.shiftKey||e.isComposing||e.target&&`tagName`in e.target&&e.target.tagName===`TEXTAREA`&&D(e)}return/* @__PURE__ */ v(`form`,{class:`${X}-form`,onSubmit:D,onKeyDown:O,"data-testid":f,noValidate:!0,children:[e.map(e=>/* @__PURE__ */ _(sl,{field:e,value:g[e.name],otherText:b[e.name]??``,error:S[e.name],disabled:c,typeLabel:d?.[e.name],strings:t,onChange:t=>T(e.name,t),onOtherChange:t=>E(e.name,t)},e.name)),u?null:/* @__PURE__ */ v(`div`,{class:`${X}-form-actions`,children:[o?/* @__PURE__ */ _(`span`,{class:`${X}-form-hint`,children:o}):null,i&&a?/* @__PURE__ */ _(`button`,{type:`button`,class:`${X}-form-skip`,onClick:a,disabled:c,"data-testid":m,children:i}):null,/* @__PURE__ */ _(`button`,{type:`submit`,class:`${X}-form-submit`,disabled:c,"data-testid":p,children:n})]})]})}function sl({field:e,value:t,otherText:n,error:r,disabled:i,typeLabel:a,strings:o,onChange:s,onOtherChange:c}){let l=cl({field:e,value:t,otherText:n,disabled:i,strings:o,onChange:s,onOtherChange:c,fieldTid:ns(J.formField,e.name)});return/* @__PURE__ */ v(`label`,{class:`${X}-field`,"data-field":e.name,"data-invalid":r?`true`:void 0,children:[/* @__PURE__ */ v(`span`,{class:`${X}-field-head`,children:[/* @__PURE__ */ v(`span`,{class:`${X}-field-label`,children:[e.label,e.required??!0?/* @__PURE__ */ _(`span`,{class:`${X}-field-req`,"aria-hidden":`true`,children:` *`}):null]}),a?/* @__PURE__ */ _(`span`,{class:`${X}-field-type`,children:a}):null]}),l,e.validationHint&&!r?/* @__PURE__ */ _(`span`,{class:`${X}-field-hint`,children:e.validationHint}):null,r?/* @__PURE__ */ _(`span`,{class:`${X}-field-error`,role:`alert`,children:r}):null]})}function cl(e){let{field:t,value:n,otherText:r,disabled:i,strings:a,onChange:o,onOtherChange:s,fieldTid:c}=e,l=typeof n==`string`?n:``,u=t.type===`select`?a.formOtherPlaceholder:t.placeholder??a.formOtherPlaceholder,d=t.allowOther&&l===al?/* @__PURE__ */ _(`input`,{class:`${X}-field-input`,value:r,placeholder:u,disabled:i,onInput:e=>s(e.currentTarget.value)}):null;switch(t.type){case`textarea`:return/* @__PURE__ */ _(`textarea`,{class:`${X}-field-input`,rows:3,value:l,placeholder:t.placeholder,disabled:i,onInput:e=>o(e.currentTarget.value),"data-testid":c});case`select`:return/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ v(`select`,{class:`${X}-field-input`,value:l,disabled:i,onChange:e=>o(e.currentTarget.value),"data-testid":c,children:[/* @__PURE__ */ _(`option`,{value:``,children:t.placeholder??`—`}),(t.options??[]).map(e=>/* @__PURE__ */ _(`option`,{value:e.value,children:e.label??e.value},e.value)),t.allowOther?/* @__PURE__ */ _(`option`,{value:al,children:a.formOther}):null]}),d]});case`radio`:return/* @__PURE__ */ v(`div`,{class:`${X}-field-choices`,role:`radiogroup`,"data-testid":c,children:[(t.options??[]).map(e=>/* @__PURE__ */ v(`label`,{class:`${X}-choice`,children:[/* @__PURE__ */ _(`input`,{type:`radio`,name:`${X}-${t.name}`,checked:l===e.value,disabled:i,onChange:()=>o(e.value)}),/* @__PURE__ */ _(`span`,{children:e.label??e.value})]},e.value)),t.allowOther?/* @__PURE__ */ v(`label`,{class:`${X}-choice`,children:[/* @__PURE__ */ _(`input`,{type:`radio`,name:`${X}-${t.name}`,checked:l===al,disabled:i,onChange:()=>o(al)}),/* @__PURE__ */ _(`span`,{children:a.formOther})]}):null,d]});case`checkbox`:return/* @__PURE__ */ v(`label`,{class:`${X}-choice`,children:[/* @__PURE__ */ _(`input`,{type:`checkbox`,checked:l===`true`,disabled:i,onChange:e=>o(e.currentTarget.checked?`true`:``),"data-testid":c}),/* @__PURE__ */ _(`span`,{children:t.placeholder??t.label})]});case`multiselect`:{let e=Array.isArray(n)?n:[];function l(t,n){return o(n?[...e,t]:e.filter(e=>e!==t))}return/* @__PURE__ */ v(`div`,{class:`${X}-field-choices`,"data-testid":c,children:[(t.options??[]).map(t=>/* @__PURE__ */ v(`label`,{class:`${X}-choice`,children:[/* @__PURE__ */ _(`input`,{type:`checkbox`,checked:e.includes(t.value),disabled:i,onChange:e=>l(t.value,e.currentTarget.checked)}),/* @__PURE__ */ _(`span`,{children:t.label??t.value})]},t.value)),t.allowOther||(t.options??[]).length===0?/* @__PURE__ */ _(`textarea`,{class:`${X}-field-input`,rows:2,value:r,placeholder:t.placeholder??a.formOtherPlaceholder,disabled:i,onInput:e=>s(e.currentTarget.value)}):null]})}default:return/* @__PURE__ */ _(`input`,{...ll(t.type),class:`${X}-field-input`,value:l,placeholder:t.placeholder,disabled:i,onInput:e=>o(e.currentTarget.value),"data-testid":c})}}function ll(e){switch(e){case`number`:return{type:e};case`email`:return{type:e};case`tel`:return{type:e};case`url`:return{type:e};case`date`:case`time`:return{type:e};default:return{type:`text`}}}function ul(e){let t={};for(let n of e)n.defaultValue!=null&&(t[n.name]=n.type===`multiselect`?n.defaultValue.split(`,`).map(e=>e.trim()).filter(Boolean):n.defaultValue);return t}function dl(e,t,n){let r={...t};for(let i of e){let e=n[i.name]?.trim();if((i.type===`radio`||i.type===`select`)&&i.allowOther&&t[i.name]===al)r[i.name]=e??``;else if(i.type===`multiselect`&&e){let n=e.split(/[,\n;]+/).map(e=>e.trim()).filter(Boolean),a=t[i.name];r[i.name]=[...Array.isArray(a)?a:[],...n]}}return r}const fl=N.cssPrefix;function pl({form:e,strings:t,onSubmit:n,onSkip:r}){return/* @__PURE__ */ v(`div`,{class:`${fl}-form-gate`,"data-testid":J.formGate,children:[e.title?/* @__PURE__ */ _(`h3`,{class:`${fl}-form-gate-title`,children:e.title}):null,e.description?/* @__PURE__ */ _(`p`,{class:`${fl}-form-gate-desc`,children:e.description}):null,/* @__PURE__ */ _(ol,{fields:e.fields,strings:t,submitLabel:e.submitLabel??t.formSubmit,onSubmit:n,skipLabel:e.skippable?t.formSkip:void 0,onSkip:e.skippable?r:void 0,submitTestId:J.formSubmit,skipTestId:J.formSkip})]})}function ml({marker:e,strings:t,onFill:n}){let r=e.outcome===`skipped`,i=r?t.formSkipped:t.formSubmitted,a=e.title?/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`span`,{children:e.title}),/* @__PURE__ */ _(`span`,{class:`${fl}-sr-only`,children:i})]}):/* @__PURE__ */ _(`span`,{children:i}),o=e.form?.reviewable??!1,s=!r&&o&&e.values&&Object.keys(e.values).length>0?e.values:null;if(s){function t(t){return e.form?.fields.find(e=>e.name===t)?.label??t}return/* @__PURE__ */ v(`details`,{class:`${fl}-form-done`,"data-outcome":e.outcome,"data-testid":J.formDone,children:[/* @__PURE__ */ v(`summary`,{class:`${fl}-form-done-summary`,"data-testid":J.formDoneToggle,children:[/* @__PURE__ */ _(bo,{}),a,/* @__PURE__ */ _(io,{})]}),/* @__PURE__ */ _(`dl`,{class:`${fl}-form-answers`,"data-testid":J.formAnswers,children:Object.entries(s).map(([e,n])=>/* @__PURE__ */ v(`div`,{class:`${fl}-form-answer`,children:[/* @__PURE__ */ _(`dt`,{children:t(e)}),/* @__PURE__ */ _(`dd`,{children:n})]},e))})]})}return/* @__PURE__ */ v(`div`,{class:`${fl}-form-done`,"data-outcome":e.outcome,"data-testid":J.formDone,role:`status`,children:[_(r?yo:bo,{}),a,r&&e.form?.reopenable&&n?/* @__PURE__ */ _(`button`,{type:`button`,class:`${fl}-form-done-fill`,"data-testid":J.formFill,onClick:n,children:t.formFillOut}):null]})}const hl=N.cssPrefix;function gl({messageId:e,initial:t,strings:n,onFeedback:r}){let[i,a]=h(t);u(()=>a(t),[e,t]);function o(t){let n=i===t?null:t;a(n),r(e,n)}return/* @__PURE__ */ v(`div`,{class:`${hl}-feedback`,role:`group`,"data-testid":J.messageFeedback,children:[/* @__PURE__ */ _(`button`,{type:`button`,class:`${hl}-msg-action`,"data-active":i===`up`?`true`:void 0,"aria-pressed":i===`up`,"aria-label":n.feedbackUp,title:n.feedbackUp,onClick:()=>o(`up`),"data-testid":J.feedbackUp,children:/* @__PURE__ */ _(qo,{})}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${hl}-msg-action`,"data-active":i===`down`?`true`:void 0,"aria-pressed":i===`down`,"aria-label":n.feedbackDown,title:n.feedbackDown,onClick:()=>o(`down`),"data-testid":J.feedbackDown,children:/* @__PURE__ */ _(Jo,{})}),/* @__PURE__ */ _(`span`,{class:`${hl}-sr-only`,role:`status`,"aria-live":`polite`,children:i?n.feedbackThanks:``})]})}const _l=/* @__PURE__ */ new Set([`hidden`,`submit`,`button`,`reset`,`image`,`file`,`password`]);function vl(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function yl(e){return!vl(e)||e.name===``||e.disabled?!1:!(e instanceof HTMLInputElement&&_l.has(e.type))}function bl(e){let t=e.labels?.[0]?.textContent?.trim();return e.getAttribute(`toolparamdescription`)??(t||e.getAttribute(`aria-description`))??void 0}function xl(e,t){let n=bl(e),r=n?{description:n}:{};return e instanceof HTMLSelectElement?{...r,type:`string`,enum:[...e.options].map(e=>e.value)}:e instanceof HTMLTextAreaElement?{...r,type:`string`}:e.type===`checkbox`?{...r,type:`boolean`}:e.type===`radio`?{...r,type:`string`,enum:t}:e.type===`number`||e.type===`range`?{...r,type:`number`}:{...r,type:`string`}}function Sl(e,t){Object.getOwnPropertyDescriptor(Reflect.getPrototypeOf(e)??e,`value`)?.set?.call(e,t),e.dispatchEvent(new Event(`input`,{bubbles:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}function Cl(e){return e==null?``:typeof e==`string`?e:JSON.stringify(e)}function wl(e,t){e instanceof HTMLInputElement&&e.type===`checkbox`?e.checked!==(t===!0||t===`true`)&&e.click():e instanceof HTMLInputElement&&e.type===`radio`?e.value===Cl(t)&&!e.checked&&e.click():Sl(e,Cl(t))}function Tl(e,t,n){let r=[...e.elements].filter(yl),i={},a=/* @__PURE__ */ new Set;for(let e of r){var o;let t=r.flatMap(t=>t instanceof HTMLInputElement&&t.type===`radio`&&t.name===e.name?[t.value]:[]);i[o=e.name]??(i[o]=xl(e,t)),e.required&&a.add(e.name)}return{name:t,description:n,inputSchema:{type:`object`,properties:i,...a.size>0?{required:[...a]}:{}},execute(t){let n=typeof t==`object`&&t?Object.entries(t):[];for(let[e,t]of n)for(let n of r)n.name===e&&wl(n,t);if(!e.hasAttribute(`toolautosubmit`))return`Filled in the form. The visitor still needs to check it and press its submit button.`;let i=[...new Set([...e.elements].flatMap(e=>vl(e)&&e.name&&!e.checkValidity()?[e.name]:[]))];return i.length>0?`Filled in the form, but it can't be submitted yet: ${i.join(`, `)} still needs the visitor. Ask them to complete it and press the submit button.`:(setTimeout(()=>e.requestSubmit(),0),`Filled in the form and submitted it.`)}}}function El(){return[...document.querySelectorAll(`form[toolname][tooldescription]`)].flatMap(e=>{let t=e.getAttribute(`toolname`)?.trim()??``,n=e.getAttribute(`tooldescription`)?.trim()??``;return t&&n?[Tl(e,t,n)]:[]})}const Dl=`${N.cssPrefix}.page-tools`;function Ol(e){return typeof e==`object`&&!!e}function kl(e){return Ol(e)&&(e.state===`running`||e.state===`stopped`||e.state===`finished`&&Ol(e.outcome))}function Al(e){let t=e?JSON.parse(e):void 0;return Ol(t)?{sent:Array.isArray(t.sent)?t.sent.filter(e=>typeof e==`string`):[],calls:Object.fromEntries(Object.entries(Ol(t.calls)?t.calls:{}).filter(e=>kl(e[1])))}:{sent:[],calls:{}}}let jl={sent:[],calls:{}};function Ml(){try{jl=Al(sessionStorage.getItem(Dl))}catch{}return jl}function Nl(e){jl=e;try{sessionStorage.setItem(Dl,JSON.stringify(e))}catch{}}const Pl={markSent(e){let t=Ml();Nl({...t,sent:[...t.sent.filter(t=>t!==e),e].slice(-20)})},sentHere(e){return Ml().sent.includes(e)},get(e){return Ml().calls[e]},set(e,t){let n=Ml(),r=Object.entries(n.calls).filter(([t])=>t!==e);Nl({...n,calls:Object.fromEntries([...r,[e,t]].slice(-50))})},clear(e){let t=Ml();e.some(e=>e in t.calls)&&Nl({...t,calls:Object.fromEntries(Object.entries(t.calls).filter(([t])=>!e.includes(t)))})}},Fl=z.scope(`page-tools`),Il=3e4,Ll=Symbol.for(`${N.cssPrefix}.page-tools`),Rl={state:`output-error`,errorText:`The page reloaded before this finished, so it may or may not have taken effect. Check with the visitor before trying it again.`},zl=`The visitor stopped this before it finished.`;function Bl(e){return typeof e==`object`&&!!e}function Vl(e){return Bl(e)&&Array.isArray(e.registered)&&e.runs instanceof Map}function Hl(){let e=Reflect.get(globalThis,Ll);if(Vl(e))return e;let t={registered:[],runs:/* @__PURE__ */ new Map};return Reflect.set(globalThis,Ll,t),t}function Ul(e,t){let n=Bl(t)&&t.signal instanceof AbortSignal?t.signal:void 0;if(n?.aborted)return;let r=Hl().registered;r.push(e);function i(){let t=r.indexOf(e);t>=0&&r.splice(t,1)}n?.addEventListener(`abort`,i,{once:!0})}function Wl(e){return e.replace(/[^A-Za-z0-9_-]/g,`_`).slice(0,58)}function Gl(e){if(!Bl(e)||typeof e.name!=`string`||!Wl(e.name))return;let t=[e.description,e.title].find(e=>typeof e==`string`&&e.trim()!==``)??e.name;return{name:Wl(e.name),description:t.trim().slice(0,1024),inputSchema:{properties:{},...Bl(e.inputSchema)?e.inputSchema:{},type:`object`},consequential:Bl(e.annotations)&&e.annotations.consequentialHint===!0}}function Kl(e){return e.flatMap(e=>{let t=Gl(e),n=Bl(e)?e.execute:void 0;return!t||typeof n!=`function`?(Fl.warn(`skipped a tool without a name or an execute function`,e),[]):[{...t,run:(t,r)=>Reflect.apply(n,e,[t,{signal:r}])}]})}async function ql(){let e=Reflect.get(document,`modelContext`)??Reflect.get(navigator,`modelContext`);if(!Bl(e)||typeof e.getTools!=`function`||typeof e.executeTool!=`function`)return[];let t=e.getTools,n=e.executeTool,r=await Promise.race([Promise.resolve().then(()=>Reflect.apply(t,e,[])),ca(1e3).then(()=>[])]).catch(()=>[]);return(Array.isArray(r)?r:[]).flatMap(t=>{let r=Gl(t);return r?[{...r,run:(r,i)=>Reflect.apply(n,e,[t,r,{signal:i}])}]:[]})}async function Jl(e=[]){let t=Kl(El()),n=new Set(t.map(e=>e.name)),r=[...(await ql()).filter(e=>!n.has(e.name)),...t,...Kl(e),...Kl(Hl().registered)];return new Map(r.map(e=>[e.name,e]))}function Yl(e){return[...e.values()].map(({name:e,description:t,inputSchema:n,consequential:r})=>r?{name:e,description:t,inputSchema:n,annotations:{consequentialHint:!0}}:{name:e,description:t,inputSchema:n})}function Xl(e){return e?.execution===`client`}function Zl(e){return e.startsWith(`site__`)?e.slice(6):e}function Ql(e){if(e===void 0||typeof e==`function`||typeof e==`symbol`)return null;let t=/* @__PURE__ */ new WeakSet,n=JSON.stringify(e,(e,n)=>{if(typeof n==`bigint`)return n.toString();if(typeof n!=`function`&&typeof n!=`symbol`)return n instanceof Node?`[${n.nodeName.toLowerCase()}]`:Bl(n)?t.has(n)?`[circular]`:(t.add(n),n):n});return n.length>Il?{truncated:!0,preview:n.slice(0,Il)}:JSON.parse(n)}async function $l(e){let t=Zl(e.toolName),n=(await Jl(e.optionTools)).get(t);return n?Promise.resolve().then(()=>n.run(e.input,e.signal)).then(e=>({state:`output-available`,output:Ql(e)})).catch(e=>(Fl.warn(`a page tool failed`,{name:t,error:e}),{state:`output-error`,errorText:(e instanceof Error?e.message:String(e)).slice(0,1e3)||`The page tool failed.`})):{state:`output-error`,errorText:`This page doesn't offer "${t}" right now; the visitor may have moved on. Tell them, or continue without it.`}}function eu(e){let{toolCallId:t}=e,n=Pl.get(t);if(n?.state===`finished`)return Promise.resolve(n.outcome);let{runs:r}=Hl(),i=r.get(t);if(i)return i.outcome;if(n?.state===`running`)return Pl.set(t,{state:`finished`,outcome:Rl}),e.onSettled(`interrupted`,0),Promise.resolve(Rl);let a=new AbortController,o=performance.now();Pl.set(t,{state:`running`});let s=$l({...e,signal:a.signal}).then(n=>(r.delete(t),Pl.get(t)?.state===`running`&&(Pl.set(t,{state:`finished`,outcome:n}),e.onSettled(n.state===`output-available`?`completed`:`failed`,Math.round(performance.now()-o))),n));return r.set(t,{outcome:s,controller:a}),s}function tu(e){return e===Rl.errorText||e===zl}function nu(e){return Pl.set(e,{state:`stopped`}),Hl().runs.get(e)?.controller.abort(),zl}function ru(e){Pl.clear([e]),Hl().runs.get(e)?.controller.abort()}const iu=N.cssPrefix;function au(e){let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function ou(e){if(e.startsWith(`tool:`)||e.startsWith(`tool-`))return e.slice(5);let t=e.indexOf(`__`),n=e.slice(t+2);return t>0&&n?`${au(e.slice(0,t))} · ${au(n)}`:e}function su(e){let t=e.indexOf(`__`),n=e.slice(t+2);return t>0&&n?au(n):ou(e)}function cu(e,t){let n=e===`output-available`||e===`output-error`||e===`output-denied`,r=e===`approval-responded`||t?.approved!==void 0;return{terminal:n,responded:r,decided:n||r}}function lu({status:e,icon:t,label:n}){return/* @__PURE__ */ v(`span`,{class:`${iu}-toolui-badge ${iu}-toolui-status`,"data-status":e,children:[/* @__PURE__ */ _(`span`,{class:`${iu}-toolui-status-icon`,children:t}),n]})}function uu(e,t){return e===`output-error`?`error`:e===`output-denied`||t?.approved===!1?`denied`:e===`output-available`?`completed`:e===`approval-responded`||t?.approved===!0?`responded`:e===`approval-requested`?`awaiting`:`running`}function du(e,t,n={}){return n.submitted?`responded`:n.incomplete?`incomplete`:mu(uu(e,t),n.superseded,n.live??!0,n.stopped??!1)}function fu({status:e}){return _(e===`stopped`?ao:e===`denied`||e===`error`||e===`superseded`||e===`incomplete`?Qo:e===`completed`||e===`responded`?Zo:Xo,{})}function pu(e,t){switch(e){case`awaiting`:return t.statusAwaiting;case`responded`:return t.statusResponded;case`completed`:return t.statusCompleted;case`denied`:return t.statusDenied;case`error`:return t.statusError;case`superseded`:return t.statusSuperseded;case`incomplete`:return t.statusIncomplete;case`stopped`:return t.statusStopped;default:return t.statusRunning}}function mu(e,t,n,r){return t&&(e===`awaiting`||e===`running`)?`superseded`:r&&(e===`running`||e===`responded`)?`stopped`:!n&&e===`running`?`error`:e}function hu({state:e,approval:t,strings:n,superseded:r,live:i=!0,submitted:a=!1,incomplete:o=!1,stopped:s=!1}){let c=du(e,t,{superseded:r,live:i,submitted:a,incomplete:o,stopped:s});return/* @__PURE__ */ _(lu,{status:c,icon:/* @__PURE__ */ _(fu,{status:c}),label:pu(c,n)})}function gu({name:e,state:t,approval:n,strings:r,superseded:i,live:a,submitted:o,incomplete:s,stopped:c}){return/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ v(`span`,{class:`${iu}-toolui-name-pill`,children:[/* @__PURE__ */ _(Yo,{}),/* @__PURE__ */ _(`span`,{class:`${iu}-toolui-name-text`,children:e})]}),/* @__PURE__ */ _(hu,{state:t,approval:n,strings:r,superseded:i,live:a,submitted:o,incomplete:s,stopped:c}),/* @__PURE__ */ _(`span`,{class:`${iu}-toolui-chevron`,children:/* @__PURE__ */ _(To,{})})]})}function _u({part:e,strings:t,testid:n,superseded:r,live:a,submitted:o,incomplete:s,stopped:c,open:l}){let u=p(()=>i(()=>e.inputSig.value),[e]),d=p(()=>i(()=>e.outputSig.value),[e]),f=p(()=>i(()=>e.errorSig.value),[e]),m=p(()=>i(()=>e.stateSig.value),[e]),h=p(()=>i(()=>e.approvalSig.value),[e]),g=p(()=>i(()=>Xl(e.toolMetadata)&&tu(e.errorSig.value)),[e]),y=s===!0||g.value;return/* @__PURE__ */ v(`details`,{class:`${iu}-toolui ${iu}-toolui-collapsible`,"data-testid":n,open:l||void 0,children:[/* @__PURE__ */ _(`summary`,{class:`${iu}-toolui-head`,children:/* @__PURE__ */ _(gu,{name:ou(e.toolName),state:m.value,approval:h.value,strings:t,superseded:r,live:a,submitted:o,incomplete:y,stopped:c})}),/* @__PURE__ */ _(vu,{label:t.toolParameters,value:u.value}),d.value===void 0?null:/* @__PURE__ */ _(vu,{label:t.toolResult,value:d.value}),f.value&&!y?/* @__PURE__ */ _(vu,{label:t.statusError,value:f.value,error:!0}):null]})}function vu({label:e,value:t,error:n}){let r=n?typeof t==`string`?t:``:xu(bu(t));return r?/* @__PURE__ */ v(`div`,{class:`${iu}-toolui-section`,children:[/* @__PURE__ */ _(`span`,{class:`${iu}-toolui-label`,children:e}),/* @__PURE__ */ _(`pre`,{class:`${iu}-toolui-code`,"data-error":n?`true`:void 0,children:r})]}):null}function yu(e){return!!xu(e.inputSig.value)||!!e.errorSig.value||!!xu(bu(e.outputSig.value))}function bu(e){if(e&&typeof e==`object`){let t=e;if(t.storage===`tool-result-ref`&&`summary`in t)return t.summary}return e}function xu(e){if(e==null)return``;try{let t=typeof e==`string`?e:JSON.stringify(e,null,2);return!t||t===`{}`||t===`[]`||t===`""`?``:t.length>800?`${t.slice(0,800)}…`:t}catch{return``}}function Su(e){return e.partsSig.value.some(e=>e.kind===`text`&&e.textSig.value.length>0)}function Cu(e){return e.partsSig.value.some(e=>e.kind===`reasoning`)}function wu(e){return e.streaming&&!e.bufferedHold&&!(e.reasoningVisible&&e.working)}function Tu(e){let{streaming:t,reasoningVisible:n,emptyReply:r,hidden:i}=e,a=e.responseMode===`buffered`&&t,o=t&&!e.hasAnswerText;return{streaming:t,bufferedHold:a,reasoningVisible:n,working:o,showStreamDots:wu({streaming:t,bufferedHold:a,reasoningVisible:n,working:o}),emptyReply:r,hidden:i}}function Eu(e,t){let n=e.stateSig.value,r=e.approvalSig.value,{terminal:i,responded:a,decided:o}=cu(n,r),s=t.continuationStreaming===!0&&!o,c=t.superseded&&!o&&!s;return{pill:du(n,r,{superseded:c,live:t.live,submitted:s,incomplete:Xl(e.toolMetadata)&&tu(e.errorSig.value),stopped:t.stopped}),state:n,terminal:i,decided:o||s,showApproveReject:!o&&!t.superseded&&!s,showAnswered:a&&!i&&!c,showSubmitted:s,showEdit:a&&t.active&&!i,skipped:c,answeredApproved:r?.approved}}const Du=N.cssPrefix;function Ou({part:e,strings:t}){let n=e.title||e.filename||e.url||t.sources;return e.url?/* @__PURE__ */ v(`a`,{class:`${Du}-source`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,"data-testid":J.source,children:[/* @__PURE__ */ _(`span`,{class:`${Du}-source-icon`,"aria-hidden":`true`,children:`🔗`}),/* @__PURE__ */ _(`span`,{class:`${Du}-source-label`,children:n})]}):/* @__PURE__ */ v(`span`,{class:`${Du}-source`,"data-testid":J.source,children:[/* @__PURE__ */ _(`span`,{class:`${Du}-source-icon`,"aria-hidden":`true`,children:`📄`}),/* @__PURE__ */ _(`span`,{class:`${Du}-source-label`,children:n})]})}const ku=N.cssPrefix;function Au(e){return!e||typeof e!=`object`||Array.isArray(e)?[]:Object.entries(e).flatMap(([e,t])=>typeof t==`string`?t.trim()?[{key:e,value:t.trim()}]:[]:typeof t==`number`||typeof t==`boolean`?[{key:e,value:String(t)}]:[]).slice(0,4)}function ju({part:e,strings:t,active:n,superseded:r=!1,continuationStreaming:a=!1,stopped:o=!1,onDecision:s,onEdit:c}){let l=p(()=>i(()=>e.approvalSig.value),[e]),u=p(()=>i(()=>Eu(e,{active:n,superseded:r,continuationStreaming:a,stopped:o})),[e,n,r,a,o]).value,{terminal:d,showApproveReject:f,showAnswered:m,showSubmitted:h,showEdit:y,skipped:b}=u,x=ou(e.toolName),S=u.answeredApproved,C=e.toolCallId,w=Au(e.inputSig.value),T=/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`p`,{class:`${ku}-toolui-prompt`,children:t.approvalPrompt.replace(`{tool}`,x)}),w.length>0?/* @__PURE__ */ _(`dl`,{class:`${ku}-toolui-fields`,"data-testid":J.toolApprovalFields,children:w.map(({key:e,value:t})=>/* @__PURE__ */ v(`div`,{children:[/* @__PURE__ */ _(`dt`,{children:e}),/* @__PURE__ */ _(`dd`,{title:t,children:t})]},e))}):null,/* @__PURE__ */ _(`p`,{class:`${ku}-toolui-subtle`,children:t.approvalBody})]});h?T=/* @__PURE__ */ _(`p`,{class:`${ku}-toolui-subtle`,children:t.approvalSubmitting}):m&&S!==!1?T=/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ v(`p`,{class:`${ku}-toolui-prompt`,children:[t.approvalYourResponse.replace(`{decision}`,S?t.approve:t.reject),l.value?.reason?` — ${l.value.reason}`:``]}),y?/* @__PURE__ */ _(`p`,{class:`${ku}-toolui-subtle`,children:t.approvalEditHint}):null,y?null:/* @__PURE__ */ _(`p`,{class:`${ku}-toolui-subtle`,children:t.approvalSubmitting})]}):m&&(T=/* @__PURE__ */ _(g,{}));let E=f||h||y||m&&S!==!1;return/* @__PURE__ */ v(`div`,{class:`${ku}-toolui-group`,"data-testid":u.decided?J.toolDecision:J.toolApproval,children:[/* @__PURE__ */ _(_u,{part:e,strings:t,superseded:b,submitted:h,stopped:o,open:f}),b||d||!E?null:/* @__PURE__ */ v(`div`,{class:`${ku}-toolui ${ku}-toolui-body`,children:[T,f?/* @__PURE__ */ v(`div`,{class:`${ku}-toolui-actions`,children:[/* @__PURE__ */ _(`button`,{type:`button`,class:`${ku}-form-skip`,disabled:!n,onClick:()=>s(C,!1),"data-testid":J.toolReject,children:t.reject}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${ku}-form-submit`,disabled:!n,onClick:()=>s(C,!0),"data-testid":J.toolApprove,children:t.approve})]}):null,y?/* @__PURE__ */ _(`div`,{class:`${ku}-toolui-actions`,children:/* @__PURE__ */ _(`button`,{type:`button`,class:`${ku}-form-skip`,onClick:()=>c(C),"data-testid":J.toolEdit,children:t.edit})}):null]})]})}const Mu=[`text`,`email`,`phone`,`number`,`date`,`single-select`,`multi-select`,`boolean`];function Nu(e){return typeof e==`object`&&!!e}function Pu(e){let t=Nu(e)?e:{},n=(Array.isArray(t.questions)?t.questions:[]).map(Fu).filter(e=>e!==null);return{intro:Ru(t.intro),questions:n}}function Fu(e,t){if(!Nu(e))return null;let n=Mu.find(t=>t===e.type)??`text`;return{key:Ru(e.key)??`q${t+1}`,question:Ru(e.question)??`Please provide the missing information.`,type:n,options:Array.isArray(e.options)?e.options.filter(e=>typeof e==`string`&&e.trim().length>0):void 0,required:typeof e.required==`boolean`?e.required:void 0,helpText:Ru(e.helpText)}}function Iu(e){switch(e){case`text`:return`textarea`;case`phone`:return`tel`;case`single-select`:case`boolean`:return`radio`;case`multi-select`:return`multiselect`;default:return e}}function Lu(e,t,n){return e.questions.map(e=>{let r=Iu(e.type),i=e.type===`boolean`?[{value:`yes`,label:t},{value:`no`,label:n}]:(e.options??[]).map(e=>({value:e,label:e}));return{name:e.key,label:e.question,type:r,required:e.required??!1,options:i.length>0?i:void 0,validationHint:e.helpText}})}function Ru(e){return typeof e==`string`&&e.trim()?e.trim():void 0}const zu=N.cssPrefix;function Bu({skipped:e,submitted:t,strings:n}){return e?{status:`superseded`,statusLabel:n.inputSkipped}:t?{status:`responded`,statusLabel:n.statusResponded}:{status:`completed`,statusLabel:n.inputAnswered}}const Vu={text:`qtypeText`,email:`qtypeEmail`,phone:`qtypePhone`,number:`qtypeNumber`,date:`qtypeDate`,"single-select":`qtypeChooseOne`,"multi-select":`qtypeChooseAny`,boolean:`qtypeBoolean`};function Hu(e,t){let n={};for(let r of e)n[r.key]=t[Vu[r.type]];return n}function Uu({part:e,strings:t,active:n,superseded:r=!1,continuationStreaming:a=!1,onDecision:o,onEdit:s}){let c=p(()=>i(()=>e.stateSig.value),[e]).value,l=p(()=>i(()=>e.approvalSig.value),[e]).value,u=p(()=>i(()=>Pu(e.inputSig.value)),[e]).value,{terminal:d,decided:f}=cu(c,l),m=f&&l?.approved===!0,g=a&&!f,y=!f&&!r&&!g,b=!y&&!m&&!g,x=m&&n&&!d,S=u.questions,[C,w]=h(null),T=C??(y||m||g),[E,D]=h(!1),O=S.length>1?Qa:ko,k=y?t.inputRequired:t.inputBadge,A=g?/* @__PURE__ */ _(`p`,{class:`${zu}-toolui-subtle`,children:t.approvalSubmitting}):y?/* @__PURE__ */ _(Wu,{req:u,strings:t,active:n,resolve:(t,n)=>o(e.toolCallId,n,t)}):E?/* @__PURE__ */ _(ol,{fields:Lu(u,t.confirmYes,t.confirmNo),strings:t,submitLabel:t.inputSubmit,onSubmit:()=>{},disabled:!0,hideActions:!0,fieldTypeLabels:Hu(S,t),initialValues:m?Xu(S,l?.reason):void 0}):/* @__PURE__ */ _(Gu,{questions:S,answers:m?Yu(l?.reason):{},strings:t}),{status:j,statusLabel:M}=Bu({skipped:b,submitted:g,strings:t});return/* @__PURE__ */ v(`details`,{class:`${zu}-toolui ${zu}-toolui-collapsible${r?` ${zu}-toolui-stale`:``}`,open:T,onToggle:e=>{let t=e.currentTarget.open;t!==T&&w(t)},"data-testid":y?J.toolAskQuestions:J.toolDecision,children:[/* @__PURE__ */ v(`summary`,{class:`${zu}-toolui-head`,children:[/* @__PURE__ */ v(`span`,{class:`${zu}-toolui-q-pill`,children:[/* @__PURE__ */ _(O,{}),k]}),/* @__PURE__ */ v(`span`,{class:`${zu}-toolui-head-end`,children:[y?null:/* @__PURE__ */ _(lu,{status:j,icon:_(b?Qo:Zo,{}),label:M}),/* @__PURE__ */ _(`span`,{class:`${zu}-toolui-chevron`,children:/* @__PURE__ */ _(To,{})})]})]}),/* @__PURE__ */ v(`div`,{class:`${zu}-toolui-collapse-body`,children:[u.intro?/* @__PURE__ */ _(`div`,{class:`${zu}-toolui-desc`,children:u.intro}):null,A,y||g?null:/* @__PURE__ */ v(`div`,{class:`${zu}-toolui-footer`,children:[/* @__PURE__ */ v(`button`,{type:`button`,class:`${zu}-toolui-options-toggle`,onClick:()=>D(e=>!e),"data-testid":J.toolAskOptions,children:[/* @__PURE__ */ _(`span`,{class:`${zu}-toolui-options-chevron${E?` ${zu}-open`:``}`,children:/* @__PURE__ */ _(To,{})}),E?t.hideOptions:t.showOptions]}),x?/* @__PURE__ */ _(`button`,{type:`button`,class:`${zu}-form-skip`,onClick:()=>s(e.toolCallId),"data-testid":J.toolEdit,children:t.edit}):null]})]})]})}function Wu({req:e,strings:t,active:n,resolve:r}){let i=Lu(e,t.confirmYes,t.confirmNo),a=e.questions.length===1&&e.questions[0]?.type===`text`;return/* @__PURE__ */ _(ol,{fields:i,strings:t,disabled:!n,submitLabel:t.inputSubmit,footerHint:a?t.inputSubmitHint:void 0,onSubmit:t=>r(qu(e.questions,t),!0),skipLabel:t.inputSkip,onSkip:()=>r(void 0,!1),submitOnEnter:a,fieldTypeLabels:Hu(e.questions,t),submitTestId:J.toolInputSubmit,skipTestId:J.toolInputSkip})}function Gu({questions:e,answers:t,strings:n}){return/* @__PURE__ */ _(`div`,{class:`${zu}-toolui-summary`,"data-testid":J.toolAskSummary,children:e.map(e=>/* @__PURE__ */ v(`div`,{class:`${zu}-field`,children:[/* @__PURE__ */ _(`span`,{class:`${zu}-field-head`,children:/* @__PURE__ */ v(`span`,{class:`${zu}-field-label`,children:[e.question,e.required?/* @__PURE__ */ _(`span`,{class:`${zu}-field-req`,"aria-hidden":`true`,children:` *`}):null]})}),/* @__PURE__ */ _(`p`,{class:`${zu}-toolui-answer`,children:Ku(e,t[e.key],n)||`—`})]},e.key))})}function Ku(e,t,n){return e.type===`boolean`?t===`yes`?n.confirmYes:t===`no`?n.confirmNo:t??``:t??``}function qu(e,t){let n=e.flatMap(e=>{let n=t[e.key];if(n==null||n.trim()===``)return[];let r=e.type===`multi-select`?n.split(`,`).map(e=>e.trim()).filter(Boolean):n;return[{key:e.key,value:r}]});return JSON.stringify({answers:n})}function Ju(e){if(!e)return{};let t=(()=>{try{return JSON.parse(e)}catch{return}})()?.answers;if(!Array.isArray(t))return{};let n={};for(let e of t)if(e&&typeof e==`object`&&`key`in e){let{key:t,value:r}=e;if(typeof t!=`string`)continue;typeof r==`string`?n[t]=r:Array.isArray(r)&&(n[t]=r.filter(e=>typeof e==`string`))}return n}function Yu(e){let t=Ju(e),n={};for(let[e,r]of Object.entries(t))n[e]=Array.isArray(r)?r.join(`, `):r;return n}function Xu(e,t){let n=Ju(t),r={};for(let t of e){let e=n[t.key];e!==void 0&&(t.type===`multi-select`?r[t.key]=Array.isArray(e)?e:[e]:r[t.key]=Array.isArray(e)?e[0]??``:e)}return r}function Zu({part:e,strings:t,live:n,superseded:r,stopped:a=!1}){let o=Xl(e.toolMetadata);if(!p(()=>i(()=>yu(e)),[e]).value&&!o)return null;let s=e.outputSig.value===void 0&&!e.errorSig.value;return/* @__PURE__ */ _(_u,{part:e,strings:t,testid:J.toolCall,live:n||o&&!r,incomplete:o&&r&&s,stopped:a})}const Z=N.cssPrefix;function Qu(e){if(e.kind!==`tool`)return!1;let t=e.stateSig.value;return t!==`approval-requested`&&t!==`approval-responded`&&!e.toolMetadata?.card&&!Xl(e.toolMetadata)}function $u(e,t){let n=[];for(let[r,i]of e.entries()){let e=n.at(-1);i.kind===`reasoning`&&t.showReasoning||Qu(i)&&yu(i)?e?.kind===`steps`?(e.parts.push(i),e.indices.push(r)):n.push({kind:`steps`,parts:[i],indices:[r]}):i.kind===`step-start`||i.kind===`reasoning`||i.kind===`source`&&!t.showSources||Qu(i)||n.push({kind:`part`,part:i,index:r})}return n}function ed(e){if(e&&typeof e==`object`)return Object.values(e).find(e=>typeof e==`string`&&e.trim().length>0)?.trim()}function td(e,t){let n=[...new Set(t)];if(e&&n.length!==0&&!n.some(t=>t<0||t>=e.length))return n.reduce((t,n)=>t+(e[n]?.durationMs??0),0)}function nd(e){let t=[];for(let n of e)t.push((t.at(-1)??-1)+ +(n.kind===`step-start`));return t}function rd(e,t){return e.streaming?t.thinking:e.reasoningMs===void 0?t.thought:t.thoughtFor.replace(`{time}`,id(e.reasoningMs))}function id(e){if(e<1e4)return`${Number((e/1e3).toFixed(1))} s`;let t=Math.round(e/1e3);return t<60?`${t} s`:`${Math.floor(t/60)} m ${t%60} s`}function ad(e){return e.split(`
|
|
31
|
+
`)??n):e;if(r)return t--,i&&(n=n.slice(2)),i?`\n${n}`:``;o||(t++,i&&(n+=`> `));let u={};a.replace(/(\w+)=(["'])(.*?)\2/g,(e,t,n,r)=>u[t]=r);let d=u.href??u.src,f=u.title??u.path??u.query??u.body??u.header??u.name??d;return(i?`> `:``)+(f?`**${d?`[${f}](${d})`:f}**${u.type?` \`${u.type}\``:``}\n${n}`:``)})}function vs(e){for(let t of e.querySelectorAll(`a`)){let e=t.getAttribute(`href`)??``;e&&!e.startsWith(`#`)&&(t.target=`_blank`,t.rel=`noopener noreferrer`)}}const ys=/* @__PURE__ */ new Set([y.CODE_INLINE,y.ITALIC_AST,y.ITALIC_UND,y.STRONG_AST,y.STRONG_UND,y.STRIKE,y.LINK,y.RAW_URL,y.IMAGE,y.EQUATION_INLINE]);function bs(e){let t=``,n=[],r=y.parser({data:void 0,add_token:(e,r)=>{n.push(r),ys.has(r)||(t+=` `)},end_token:()=>{let e=n.pop();e!==void 0&&!ys.has(e)&&(t+=` `)},add_text:(e,n)=>void(t+=n),set_attr:()=>void 0});return y.parser_write(r,e),y.parser_end(r),t.replace(/\s+/g,` `).trim()}const xs=N.cssPrefix;function Ss({tone:e=`info`,message:t,onRetry:n,strings:r}){return/* @__PURE__ */ v(`div`,{class:`${xs}-module-empty`,role:e===`error`?`alert`:`status`,"aria-live":`polite`,children:[/* @__PURE__ */ _(`span`,{children:t}),n?/* @__PURE__ */ _(`button`,{type:`button`,class:`${xs}-module-retry`,onClick:n,children:r.errorRetry}):null]})}const Cs=N.cssPrefix,ws=z.scope(`content`);function Ts({id:e,title:t,transport:n,strings:r,bus:i,onBack:a,actions:o}){let[s,c]=h(null),[d,f]=h(!1),[p,m]=h(!1),[y,b]=h(0),[x,S]=h(null),C=l(()=>{m(!1),c(null),b(e=>e+1)},[]);u(()=>{let t=!1,r=n.listContentCollections([]).catch(()=>void 0);return Promise.all([n.listContent({ids:[e],limit:1}),r]).then(([n,r])=>{if(t)return;let a=n.items[0];a?(c(a),f(r?.items.find(e=>e.id===a.contentCollectionId)?.settings?.voteAccess===`portal`),i.emit(`contentOpen`,{contentId:e,contentCollectionId:a.contentCollectionId})):m(!0)}).catch(e=>{t||(ws.warn(`listContent (reader) failed`,{err:e}),m(!0))}),()=>{t=!0}},[n,e,y,i]),u(()=>{if(!s)return;let t=setTimeout(()=>i.emit(`contentRead`,{contentId:e}),5e3);return()=>clearTimeout(t)},[s,e,i]);let w=l(t=>{let n=(t.target?.closest?.(`a`))?.getAttribute(`href`)??``;n&&!n.startsWith(`#`)&&i.emit(`contentLinkClick`,{contentId:e})},[i,e]);function T(t){S(e),n.setContentVote({contentId:e,value:t})}function E(){return p?/* @__PURE__ */ _(Ss,{tone:`error`,message:r.errorGeneric,onRetry:C,strings:r}):s===null?/* @__PURE__ */ _(Ss,{message:r.contentLoading,strings:r}):/* @__PURE__ */ v(`article`,{class:`${Cs}-content`,"data-testid":J.contentView,onClick:w,children:[s.image?/* @__PURE__ */ _(`img`,{class:`${Cs}-content-hero`,src:s.image,alt:``,loading:`lazy`}):null,s.description?/* @__PURE__ */ _(`p`,{class:`${Cs}-content-subtitle`,children:s.description}):null,/* @__PURE__ */ _(hs,{text:_s(s.content??``)}),d?/* @__PURE__ */ _(`div`,{class:`${Cs}-content-vote`,"aria-live":`polite`,children:x===e?r.feedbackThanks:/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`span`,{children:r.contentHelpful}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${Cs}-module-retry`,onClick:()=>T(1),children:r.confirmYes}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${Cs}-module-retry`,onClick:()=>T(0),children:r.confirmNo})]})}):null]})}return/* @__PURE__ */ v(`div`,{class:`${Cs}-module`,children:[/* @__PURE__ */ _(ps,{title:s?.title||t||r.moduleBack,backLabel:r.moduleBack,onBack:a,actions:o,testid:J.backHeader}),/* @__PURE__ */ _(`div`,{class:`${Cs}-module-scroll`,"data-testid":J.contentScroll,children:E()})]})}function Es({itemCount:e,initialFocusIndex:t}){let[n,r]=h(!1),i=m(null),a=m(null),[o,s]=h(-1),c=l(()=>{r(!1),s(-1),i.current?.focus()},[]),d=l(()=>r(e=>!e),[]);return u(()=>{if(!n)return;function e(e){let t=a.current,n=i.current;if(!t||!n)return;let o=e.composedPath();o.includes(t)||o.includes(n)||(r(!1),s(-1))}return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)},[n]),u(()=>{if(!n||e===0)return;let r=t?.()??0;s(r<0||r>=e?0:r)},[n,e,t]),u(()=>{!n||o<0||(a.current?.querySelectorAll(`[role='menuitem']`))?.[o]?.focus()},[n,o]),{open:n,focusIndex:o,triggerRef:i,menuRef:a,toggle:d,close:c,onTriggerKey:l(e=>{(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r(!0))},[]),onMenuKey:l(t=>{if(e!==0)switch(t.key){case`Escape`:t.preventDefault(),c();return;case`ArrowDown`:t.preventDefault(),s(t=>(t+1)%e);return;case`ArrowUp`:t.preventDefault(),s(t=>(t-1+e)%e);return;case`Home`:t.preventDefault(),s(0);return;case`End`:t.preventDefault(),s(e-1)}},[e,c])}}function Ds({items:e,triggerLabel:t}){let n=N.cssPrefix,r=Es({itemCount:e.length});function i(e){e.disabled||(e.onSelect?.(),e.keepOpen||r.close())}function a(e,t){return e.onSelectValue?.(t)}function o(e,t){let n=t.segments;if(!n?.length)return;let r=Math.max(0,n.findIndex(e=>e.value===t.value)),i=-1;if(e.key===`ArrowRight`||e.key===`Enter`||e.key===` `)i=(r+1)%n.length;else if(e.key===`ArrowLeft`)i=(r-1+n.length)%n.length;else return;e.preventDefault(),e.stopPropagation(),a(t,n[i].value)}return/* @__PURE__ */ v(`div`,{class:`${n}-menu-wrap`,children:[/* @__PURE__ */ _(`button`,{ref:r.triggerRef,type:`button`,class:`${n}-icon-btn`,"aria-label":t,"aria-haspopup":`menu`,"aria-expanded":r.open,title:t,onClick:r.toggle,onKeyDown:r.onTriggerKey,children:/* @__PURE__ */ _(ho,{})}),r.open?/* @__PURE__ */ _(`div`,{ref:r.menuRef,class:`${n}-menu`,role:`menu`,"aria-label":t,onKeyDown:r.onMenuKey,tabIndex:-1,children:e.map(e=>e.segments?/* @__PURE__ */ v(`div`,{role:`menuitem`,class:`${n}-menu-item ${n}-menu-item-segmented`,"aria-label":e.label,tabIndex:-1,onKeyDown:t=>o(t,e),children:[e.icon?/* @__PURE__ */ _(`span`,{class:`${n}-menu-icon`,children:e.icon}):null,/* @__PURE__ */ _(`span`,{class:`${n}-menu-label`,children:e.label}),/* @__PURE__ */ _(`span`,{class:`${n}-segmented`,role:`group`,"aria-label":e.label,children:e.segments.map(t=>{let r=t.value===e.value;return/* @__PURE__ */ _(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":r,class:`${n}-segment`,"data-on":r?`true`:void 0,lang:t.lang,title:t.value,tabIndex:-1,"data-testid":`${J.langSegment}-${t.value}`,onClick:()=>a(e,t.value),children:t.label},t.value)})})]},e.id):/* @__PURE__ */ v(`button`,{type:`button`,role:`menuitem`,class:`${n}-menu-item`,"aria-pressed":e.type===`switch`?e.on:void 0,disabled:e.disabled,onClick:()=>i(e),children:[e.icon?/* @__PURE__ */ _(`span`,{class:`${n}-menu-icon`,children:e.icon}):null,/* @__PURE__ */ _(`span`,{class:`${n}-menu-label`,children:e.label}),e.type===`switch`&&e.on?/* @__PURE__ */ _(`span`,{class:`${n}-menu-check`,"aria-hidden":`true`,children:/* @__PURE__ */ _(bo,{})}):null]},e.id))}):null]})}const Os=N.cssPrefix;function ks(e){let t=typeof matchMedia!=`function`||matchMedia(`(prefers-color-scheme: dark)`).matches;return e===`host`?kt()===`dark`?`light`:`dark`:e===`auto`?t?`light`:`dark`:t?e===`light`?`dark`:`auto`:e===`dark`?`light`:`auto`}const As={normal:`large`,large:`small`,small:`normal`};function js(e){return _(e===`light`?zo:e===`dark`?Bo:Vo,{})}function Ms(e){return(e.split(`-`)[0]??e).toUpperCase()}function Ns(e,t){let n;try{n=new URL(e,window.location.href)}catch{return}if(n.protocol===`http:`||n.protocol===`https:`)return t.conversationId&&n.searchParams.set(`chat`,t.conversationId),n.searchParams.set(`widgetId`,t.widgetId),t.publicKey&&n.searchParams.set(`public_key`,t.publicKey),n.searchParams.set(`ai_agent_deployment_id`,t.aiAgentDeploymentId),n.href}function Ps({panelProps:e,variant:t}){let{options:n,panelSize:r,feedback:i,onClose:a,onClear:o,onExpand:c,onFullscreen:l,onSoundToggle:u}=e,{onToggleHistory:d,onLocaleChange:f,onThemeChange:p,onTextSizeChange:m}=e,h=n.strings,g=n.mode,y=t===`chat`,b=s(()=>i.mutedSig.value).value,x=new Set(n.actions);function S(e){return x.has(e)}let C=typeof matchMedia==`function`&&matchMedia(`(max-width: 640px)`).matches;function w(e){return!C&&Na(e,g,r)}let T=n.themeMode,E={auto:h.themeAuto,light:h.themeLight,dark:h.themeDark,host:h.themeAuto},D=n.textSize,O={small:h.textSizeSmall,normal:h.textSizeNormal,large:h.textSizeLarge},k=[];if(y&&S(`clear`)&&k.push({id:`clear`,icon:/* @__PURE__ */ _(wo,{}),label:h.newConversation,onSelect:o}),S(`expand`)&&w(`expand`)){let e=r===`expanded`;k.push({id:`expand`,icon:_(e?lo:co,{}),label:e?h.collapse:h.expand,type:`switch`,on:e,onSelect:c})}if(S(`fullscreen`)&&w(`fullscreen`)){let e=r===`fullscreen`;k.push({id:`fullscreen`,icon:_(e?fo:uo,{}),label:e?h.exitFullscreen:h.fullscreen,type:`switch`,on:e,onSelect:l})}let A=n.popOutUrl,j=n.aiAgentDeploymentId;S(`popOut`)&&A&&j&&Na(`popOut`,g,r)&&k.push({id:`popOut`,icon:/* @__PURE__ */ _(po,{}),label:h.popOut,onSelect:()=>{let t=Ns(A,{conversationId:e.conversationId,widgetId:n.widgetId,publicKey:n.publicKey,aiAgentDeploymentId:j});t&&window.open(t,`_blank`,`noopener,noreferrer`)}}),y&&S(`sound`)&&k.push({id:`sound`,icon:_(b?_o:go,{}),label:b?h.soundOff:h.soundOn,type:`switch`,on:!b,onSelect:u}),S(`theme`)&&k.push({id:`theme`,icon:js(T),label:`${h.theme}: ${E[T]}`,onSelect:()=>p(ks(T)),keepOpen:!0}),S(`textSize`)&&k.push({id:`textSize`,icon:/* @__PURE__ */ _(vo,{}),label:`${h.textSize}: ${O[D]}`,onSelect:()=>m(As[D]),keepOpen:!0}),S(`language`)&&n.availableLocales.length>1&&k.push({id:`language`,icon:/* @__PURE__ */ _(So,{}),label:h.language,segments:n.availableLocales.map(e=>({value:e,label:Ms(e),lang:e})),value:n.locale,onSelectValue:f});let M=!!a&&Pa(g,r,n.actions),N=y&&S(`history`);return/* @__PURE__ */ v(`div`,{class:`${Os}-header-actions`,children:[N?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Os}-icon-btn`,onClick:d,"aria-label":h.history,title:h.history,"data-testid":J.actionHistory,children:/* @__PURE__ */ _(xo,{})}):null,k.length>0?/* @__PURE__ */ _(Ds,{items:k,triggerLabel:h.moreActions}):null,M?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Os}-icon-btn`,onClick:a,"aria-label":h.close,title:h.close,"data-testid":J.actionClose,children:/* @__PURE__ */ _($a,{})}):null]})}const Fs={Icon:Ro};function Is(e,t){return e instanceof fa?e.status===429?e.retryAfterSeconds?t.errorRateLimitedIn.replace(`{seconds}`,String(e.retryAfterSeconds)):t.errorRateLimited:e.code===`network`?t.errorOffline:e.status===403?t.errorOriginNotAllowed:e.status!==void 0&&e.status>=500?t.errorServer:t.errorGeneric:t.errorGeneric}const Ls=N.cssPrefix;function Rs({placeholder:e,onActivate:t}){return/* @__PURE__ */ v(`button`,{type:`button`,class:`${Ls}-home-search`,onClick:t,"data-testid":J.homeSearch,children:[/* @__PURE__ */ _(`span`,{class:`${Ls}-home-search-text`,children:e}),/* @__PURE__ */ _(`span`,{class:`${Ls}-home-search-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Po,{})})]})}function zs({placeholder:e,value:t,onInput:n}){return/* @__PURE__ */ v(`div`,{class:`${Ls}-home-search`,"data-input":`true`,children:[/* @__PURE__ */ _(`input`,{type:`search`,class:`${Ls}-home-search-input`,placeholder:e,value:t,maxLength:200,onInput:e=>n(e.currentTarget.value),"data-testid":J.helpSearch}),/* @__PURE__ */ _(`span`,{class:`${Ls}-home-search-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Po,{})})]})}const Bs=N.cssPrefix;function Vs({title:e,subtitle:t,onClick:n,testid:r}){return/* @__PURE__ */ v(`button`,{type:`button`,class:`${Bs}-list-row`,onClick:n,"data-testid":r,children:[/* @__PURE__ */ v(`span`,{class:`${Bs}-list-row-body`,children:[/* @__PURE__ */ _(`span`,{class:`${Bs}-list-row-title`,children:e}),t?/* @__PURE__ */ _(`span`,{class:`${Bs}-list-row-sub`,children:t}):null]}),/* @__PURE__ */ _(`span`,{class:`${Bs}-list-row-chevron`,"aria-hidden":`true`,children:/* @__PURE__ */ _(io,{})})]})}const Hs=N.cssPrefix,Us=z.scope(`help`);function Ws(e,t,n){let r=new Map(n.map(e=>[e.id,e.title]));return t.map(t=>({id:t,title:r.get(t),rows:e.filter(e=>e.contentCollectionId===t)})).filter(e=>e.rows.length>0)}function Gs({transport:e,strings:t,bus:n},r,i){let[a,o]=h(),s=m(void 0);function c(a){if(!r?.length)return;let c={};s.current=c,o(e=>({search:i,items:[],collections:[],...e,pagination:a>1?e?.pagination:void 0,loading:!0,error:void 0})),Promise.all([e.listContent({contentCollectionIds:r,sortBy:`order`,page:a,limit:20,search:i}),a>1?void 0:e.listContentCollections(r)]).then(([e,t])=>{s.current===c&&(o(n=>({search:i,items:[...a>1?n?.items??[]:[],...e.items],collections:t?.items??n?.collections??[],pagination:e.pagination,loading:!1})),!(a>1)&&(i?n.emit(`contentSearch`,{queryLength:i.length,hitCount:e.pagination.total}):n.emit(`contentView`,{section:`help`,count:e.items.length})))}).catch(e=>{s.current===c&&(Us.warn(`listContent (help) failed`,{err:e,page:a}),o(n=>n&&{...n,loading:!1,error:Is(e,t)}))})}return u(()=>{if(!r?.length)o(void 0);else return c(1),()=>{s.current=void 0}},[e,r,i]),[a,()=>!a?.loading&&c((a?.pagination?.page??0)+1)]}function Ks(e){let{strings:t,config:n,nav:r,panelProps:i}=e,a=n.contentCollectionIds,[o,s]=h(``),[c,l]=h(``),d=Gs(e,a),f=Gs(e,c?a:void 0,c),[p,m]=o.trim()?f:d;u(()=>{let e=setTimeout(()=>l(o.trim()),300);return()=>clearTimeout(e)},[o]);function y(){if(!a?.length)return/* @__PURE__ */ _(Ss,{message:t.helpEmpty,strings:t});let e=p?.error?/* @__PURE__ */ _(Ss,{tone:`error`,message:p.error,onRetry:m,strings:t}):null;return e&&!p?.pagination?e:!p||!p.pagination&&!p.items.length?/* @__PURE__ */ _(Ss,{message:t.helpLoading,strings:t}):p.items.length?/* @__PURE__ */ v(g,{children:[Ws(p.items,a,p.collections).map(e=>/* @__PURE__ */ v(`section`,{class:`${Hs}-help-group`,children:[e.title?/* @__PURE__ */ _(`h2`,{class:`${Hs}-help-section-title`,children:e.title}):null,/* @__PURE__ */ _(`div`,{class:`${Hs}-help-card`,children:e.rows.map(e=>/* @__PURE__ */ _(Vs,{title:e.title,subtitle:e.description,onClick:()=>r.push(e.url?{kind:`iframe`,url:e.url,title:e.title}:{kind:`content`,id:e.id,title:e.title}),testid:ns(J.helpArticle,e.id)},e.id))})]},e.id)),e,p.pagination?.hasNext&&!e?/* @__PURE__ */ _(`div`,{children:/* @__PURE__ */ _(`div`,{class:`${Hs}-help-card`,children:/* @__PURE__ */ v(`button`,{type:`button`,class:`${Hs}-list-row ${Hs}-help-more`,onClick:m,"aria-busy":p.loading,children:[p.loading?/* @__PURE__ */ _(`span`,{class:`${Hs}-loading-spinner`,"aria-hidden":`true`}):null,t.helpShowMore]})})}):null]}):/* @__PURE__ */ _(Ss,{message:p.search?t.helpSearchEmpty.replace(`{query}`,p.search):t.helpEmpty,strings:t})}return/* @__PURE__ */ v(`div`,{class:`${Hs}-module`,children:[/* @__PURE__ */ _(fs,{title:t.helpTitle,actions:/* @__PURE__ */ _(Ps,{panelProps:i,variant:`plain`})}),/* @__PURE__ */ _(`div`,{class:`${Hs}-module-pad`,children:/* @__PURE__ */ _(zs,{placeholder:t.helpSearchPlaceholder,value:o,onInput:s})}),/* @__PURE__ */ _(`div`,{class:`${Hs}-help-list`,children:y()})]})}const qs={Icon:ko,Root:e=>/* @__PURE__ */ _(Ks,{...e})},Js=z.scope(`attachments`);function Ys(e,t,n){let r=Qs(e),i=[],a=[],o=tc(n.accept),s=t.reduce((e,t)=>e+t.size,0),c=t.length;for(let e of r){let t=Zs(e,c,s,n,o);t?a.push({file:e,reason:t}):(i.push(ec(e)),s+=e.size,c+=1)}return(i.length||a.length)&&Js.debug(`ingest`,{accepted:i.length,rejected:a.map(e=>({name:e.file.name,reason:e.reason}))}),{accepted:i,rejected:a}}function Xs(e){try{URL.revokeObjectURL(e.previewUrl)}catch(e){Js.debug(`revokeObjectURL failed`,{error:e})}}function Zs(e,t,n,r,i){return t>=r.maxCount?`count`:n+e.size>r.maxBytes?`bytes`:nc(e,i)?null:`mime`}function Qs(e){return e?Array.isArray(e)?e.filter(e=>e instanceof File):[...e].map(e=>e instanceof File?e:$s(e)).filter(e=>e!==null):[]}function $s(e){let t=e;return!t?.getAsFile||t.kind!==`file`?null:t.getAsFile()}function ec(e){return{file:e,id:pt(),mediaType:e.type||`application/octet-stream`,name:e.name||`pasted-file`,previewUrl:URL.createObjectURL(e),size:e.size}}function tc(e){return e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean).map(e=>{if(e.startsWith(`.`))return{kind:`ext`,ext:e};let[t=`*`,n=`*`]=e.split(`/`);return{kind:`mime`,type:t,subtype:n}})}function nc(e,t){if(t.length===0)return!0;let[n=`*`,r=`*`]=(e.type||``).toLowerCase().split(`/`),i=(e.name||``).toLowerCase();return t.some(e=>e.kind===`ext`?i.endsWith(e.ext):e.type===`image`&&e.subtype===`*`&&/\.(heic|heif|avif|bmp|tif|tiff)$/.test(i)?!0:(e.type===`*`||e.type===n)&&(e.subtype===`*`||e.subtype===r))}const rc=N.cssPrefix;function ic({attachment:e,onRemove:t,disabled:n=!1}){let r=/^image\/(jpeg|png|gif|webp|avif|bmp|x-ms-bmp|svg\+xml)$/i.test(e.mediaType);return/* @__PURE__ */ v(`span`,{class:`${rc}-attachment-chip`,title:e.name,"data-testid":ns(J.attachmentChip,e.id),children:[r?/* @__PURE__ */ _(`img`,{class:`${rc}-attachment-thumb`,src:e.previewUrl,alt:``}):/* @__PURE__ */ _(`span`,{class:`${rc}-attachment-thumb`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Eo,{})}),/* @__PURE__ */ _(`span`,{class:`${rc}-attachment-name`,children:e.name}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${rc}-attachment-remove`,onClick:t,disabled:n,"aria-label":`Remove ${e.name}`,"data-testid":ns(J.attachmentRemove,e.id),children:/* @__PURE__ */ _($a,{})})]})}const ac={isSupported:!1,start:()=>void 0,stop:()=>void 0,cancel:()=>void 0};function oc(e,t,n){return e===`disabled`?ac:e===`server`?uc(n):sc(t)}function sc(e){let t=cc();if(!t)return ac;let n=null,r=0;return{isSupported:!0,start(i,a){let o=n,s=++r;n=null,o?.abort();let c=new t;n=c,c.continuous=!0,c.interimResults=!0,c.lang=e;let l=!1;c.addEventListener(`result`,e=>{if(r!==s||n!==c)return;let t=e,a=``,o=!1;for(let e=t.resultIndex;e<t.results.length;e++){let n=t.results[e];n&&(a+=n[0].transcript,n.isFinal&&(o=!0))}i(a,o)});function u(){l||r!==s||n!==c||(l=!0,n=null,a())}c.addEventListener(`end`,u),c.addEventListener(`error`,u);try{c.start()}catch{u()}},stop(){n?.stop()},cancel(){r++;let e=n;n=null,e?.abort()}}}function cc(){return window.SpeechRecognition??window.webkitSpeechRecognition}const lc=[`audio/webm;codecs=opus`,`audio/webm`,`audio/ogg;codecs=opus`,`audio/mp4`];function uc(e){if(typeof MediaRecorder>`u`||!navigator?.mediaDevices?.getUserMedia)return ac;let t=0,n=null;function r(e){for(let t of e.stream?.getTracks()??[])t.stop();e.stream=null}function i(){t++;let e=n;n=null,e&&(r(e),e.recorder?.state!==`inactive`&&e.recorder?.stop())}async function a(i){if(i.finishing)return;i.finishing=!0;let a=i.recorder?.mimeType??`audio/webm`;r(i);let o=new Blob(i.chunks,{type:a});i.chunks=[];try{let{text:r}=await e(o,a);n===i&&t===i.generation&&r&&i.onText(r,!0)}catch{}finally{n===i&&t===i.generation&&(n=null,i.onEnd())}}return{isSupported:!0,async start(e,o){i();let s={generation:t,recorder:null,stream:null,chunks:[],onText:e,onEnd:o,finishing:!1};n=s;try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});if(n!==s||t!==s.generation){for(let t of e.getTracks())t.stop();return}s.stream=e;let r=dc(),i=new MediaRecorder(e,r?{mimeType:r}:void 0);s.recorder=i,i.addEventListener(`dataavailable`,e=>{n===s&&t===s.generation&&e.data.size>0&&s.chunks.push(e.data)}),i.addEventListener(`stop`,()=>{n===s&&t===s.generation&&a(s)}),i.start()}catch{r(s),n===s&&t===s.generation&&(n=null,o())}},stop(){let e=n;e&&(e.recorder?e.recorder.state!==`inactive`&&e.recorder.stop():i())},cancel(){i()}}}function dc(){for(let e of lc)if(MediaRecorder.isTypeSupported(e))return e}const fc=N.cssPrefix,pc=z.scope(`composer`);function mc(e){return e.reduce((e,t)=>e+t.size,0)}const hc={arrowUp:no,paperPlane:to,send:ro,chevron:io};function gc(e){return`activeElement`in e}function _c(e){return`host`in e&&`activeElement`in e}function vc({options:e,transport:t,feedback:n,bus:r,persistence:i,conversationId:a,isStreaming:o,pageToolRunning:s=!1,isMemoryCompacting:c=!1,canReleaseQueuedMessages:d=!0,queueManualMessages:p=!1,active:g=!0,isPreparing:y=!1,operatorRequestEnabled:b,canRequestOperator:x=!1,controlMode:S=`ai-agent`,onRequestOperator:C,onSend:w,onStop:T,apiRef:E}){let D=e.strings,[O,k]=h(()=>i.loadDraft(a)),[A,j]=h([]),[M,N]=h(()=>i.loadMessageQueue(a).map(e=>({id:e.id,text:e.text,attachments:[]}))),ee=m(M),te=m(!1),[P,ne]=h(!1),[re,F]=h(!1),I=m(!1),ie=m(null),ae=m(null),L=m(null),oe=m(0),se=m(a);se.current=a;let ce=m(g);ce.current=g;let R=m(y);R.current=y;let le=re||y||!g,ue=o&&S===`ai-agent`,de=ue||c&&S===`ai-agent`,fe=S===`ai-agent`&&(de||p||M.length>0),pe=l(e=>{N(t=>{let n=e(t);return i.saveMessageQueue(se.current,n.filter(e=>e.attachments.length===0).map(({id:e,text:t})=>({id:e,text:t}))),ee.current=n,n})},[i]),me=l(e=>{pe(t=>(t.find(t=>t.id===e)?.attachments.forEach(Xs),t.filter(t=>t.id!==e)))},[pe]),z=l(e=>{k(t=>{let n=typeof e==`function`?e(t):e;return n===t?t:(i.saveDraft(se.current,n),n)})},[i]),he=e.features.fileUpload,ge=e.features.voice,[_e,ve]=h(()=>oc(ge,e.locale,(e,n)=>t.transcribe(e,n))),ye=m(_e);ye.current=_e;let be=m({mode:ge,locale:e.locale,transport:t});u(()=>{let n=be.current;(n.mode!==ge||n.locale!==e.locale||n.transport!==t)&&(be.current={mode:ge,locale:e.locale,transport:t},oe.current++,ye.current.cancel(),L.current=null,ne(!1),ve(oc(ge,e.locale,(e,n)=>t.transcribe(e,n))))},[e.locale,ge,t]),f(()=>()=>{oe.current++,_e.cancel()},[_e]);let xe=l(e=>{let t=L.current;if(t===null)return!1;let n=Math.round(performance.now()-t);return pc[e](`voiceStop`,{durationMs:n}),r.emit(`voiceStop`,{durationMs:n}),L.current=null,!0},[r]),Se=l(()=>{L.current!==null&&(_e.stop(),ne(!1),xe(`info`)&&n.play(`voiceStop`))},[xe,n,_e]),Ce=l(()=>{oe.current++,_e.cancel(),ne(!1),xe(`info`)&&n.play(`voiceStop`)},[xe,n,_e]);u(()=>{(y||!g)&&Ce()},[g,Ce,y]),u(()=>{let e=ie.current;if(!e)return;let t=e.getRootNode(),n=gc(t)?t.activeElement:null;n&&e.closest(`.${fc}-panel`)?.contains(n)||e.focus({preventScroll:!0})},[]),u(()=>{let e=ie.current;if(!e)return;if(O.length===0){e.style.height=``;return}e.style.height=`auto`;let t=getComputedStyle(e),n=Number.parseFloat(t.getPropertyValue(`--${fc}-textarea-base-height`)),r=Number.parseFloat(t.borderTopWidth)+Number.parseFloat(t.borderBottomWidth),i=Math.min(e.scrollHeight+r,Number.parseFloat(t.maxHeight)),a=Number.parseFloat(t.fontSize)*.7;e.style.height=`${i<n+a?n:i}px`},[O]);let we=m(A);we.current=A,u(()=>()=>{we.current.forEach(Xs);for(let e of ee.current)e.attachments.forEach(Xs)},[]),f(()=>{if(E)return E.current={attachFromDrop:t=>{if(!he||!ce.current||I.current||R.current)return;let n=Ys(t,we.current,e.attachments);n.accepted.length!==0&&(pc.info(`attach (drop)`,{count:n.accepted.length,totalBytes:mc(n.accepted)}),r.emit(`attach`,{count:n.accepted.length,totalBytes:mc(n.accepted)}),j(e=>[...e,...n.accepted]))},fill:e=>{if(!ce.current||I.current||R.current)return;z(e);let t=ie.current;t&&(t.focus({preventScroll:!0}),requestAnimationFrame(()=>t.setSelectionRange(t.value.length,t.value.length)))},acceptQueuedMessage:me},()=>{E.current&&(E.current=null)}},[E,he,y,e.attachments,me,z]),u(()=>{let t=ie.current;if(!t)return;let n=t.closest(`.${fc}-panel`);if(!n)return;let i=n=>{if(!ce.current||I.current||R.current)return;let i=n.clipboardData;if(!i)return;let a=n.target?.closest?.(`input, textarea, [contenteditable]:not([contenteditable='false'])`);if(a&&a!==t)return;if(he){let t=Ys(i.items,we.current,e.attachments);if(t.accepted.length>0){n.preventDefault(),pc.info(`attach (paste)`,{count:t.accepted.length,totalBytes:mc(t.accepted)}),r.emit(`attach`,{count:t.accepted.length,totalBytes:mc(t.accepted)}),j(e=>[...e,...t.accepted]);return}}if(a===t)return;let o=i.getData(`text/plain`);o&&(n.preventDefault(),z(e=>e+o),t.focus())};return n.addEventListener(`paste`,i),()=>n.removeEventListener(`paste`,i)},[he,e.attachments,z]);async function Te(){let e=O.trim();if(!e&&A.length===0||!g||ue||I.current||y)return;Ce(),I.current=!0,F(!0);let t=O,n=A;try{await w(e,n)&&(z(e=>e===t?``:e),j(e=>e===n?(n.forEach(Xs),we.current=[],[]):e))}finally{I.current=!1,F(!1),requestAnimationFrame(()=>{let e=ie.current;if(!e||e.disabled||!ce.current)return;let t=e.getRootNode(),n=gc(t)?t.activeElement:null,r=n?.getAttribute(`data-testid`);if(!(n&&n!==e&&r!==J.composerSend&&r!==J.composerStop)){if(_c(t)){let e=t.host.ownerDocument;if(!e.hasFocus())return;let n=e.activeElement;if(n&&n!==t.host&&n!==e.body)return}e.focus({preventScroll:!0})}})}}function Ee(){let e=O.trim();if(!e&&A.length===0||!g||!fe||I.current||y)return;Ce();let t=A;pe(n=>[...n,{id:pt(),text:e,attachments:t}]),z(``),j(e=>e===t?(we.current=[],[]):e),ie.current?.focus({preventScroll:!0})}u(()=>{de&&(te.current=!1)},[de]),u(()=>{let e=M[0];if(!e||!d||de||te.current||re||y||!g)return;let t=setTimeout(()=>{te.current=!0,w(e.text,e.attachments,e.id).then(t=>{t?me(e.id):te.current=!1})},300);return()=>clearTimeout(t)},[g,d,y,w,de,M,me,re]);function De(e){e.key!==`Enter`||e.shiftKey||e.isComposing||(e.preventDefault(),fe&&(O.trim()||A.length>0)?Ee():ue?T():Te())}function Oe(t){let n=t.target;if(!g||I.current||y){n.value=``;return}let i=Ys(n.files,A,e.attachments);i.accepted.length>0&&(pc.info(`attach (file picker)`,{count:i.accepted.length,totalBytes:mc(i.accepted)}),r.emit(`attach`,{count:i.accepted.length,totalBytes:mc(i.accepted)}),j(e=>[...e,...i.accepted])),n.value=``}function ke(e){!g||I.current||y||(pc.info(`removeAttachment`,{id:e}),r.emit(`removeAttachment`,{id:e}),j(t=>{let n=t.find(t=>t.id===e);return n&&Xs(n),t.filter(t=>t.id!==e)}))}function Ae(){if(P){Se();return}if(!g||!_e.isSupported||I.current||y)return;let e=++oe.current;L.current=performance.now(),pc.info(`voiceStart`),r.emit(`voiceStart`,void 0),ne(!0),n.play(`voiceStart`),_e.start((t,n)=>{oe.current===e&&ce.current&&!R.current&&!I.current&&n&&z(e=>`${e}${t} `)},()=>{oe.current===e&&ce.current&&(ne(!1),xe(`debug`))})}let je=hc[e.composer.sendButton.icon],Me=!!(O.trim()||A.length>0),Ne=ue||s&&!Me;return/* @__PURE__ */ v(`div`,{class:`${fc}-composer`,part:`composer`,"data-testid":J.composer,children:[M.length>0?/* @__PURE__ */ _(`div`,{class:`${fc}-message-queue`,"aria-label":D.queueMessage,"data-testid":J.messageQueue,children:M.map(e=>/* @__PURE__ */ v(`div`,{class:`${fc}-attachment-chip ${fc}-queued-message`,"data-testid":`${J.queuedMessage}-${e.id}`,children:[/* @__PURE__ */ _(`span`,{class:`${fc}-attachment-name ${fc}-queued-text`,children:e.text||e.attachments.map(e=>e.name).join(`, `)}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${fc}-attachment-remove`,onClick:()=>me(e.id),"aria-label":D.removeQueuedMessage,title:D.removeQueuedMessage,"data-testid":`${J.queuedMessageRemove}-${e.id}`,children:/* @__PURE__ */ _($a,{})})]},e.id))}):null,A.length>0?/* @__PURE__ */ _(`div`,{class:`${fc}-attachments`,children:A.map(e=>/* @__PURE__ */ _(ic,{attachment:e,onRemove:()=>ke(e.id),disabled:le},e.id))}):null,/* @__PURE__ */ v(`div`,{class:`${fc}-composer-row`,children:[/* @__PURE__ */ v(`div`,{class:`${fc}-composer-actions`,children:[he?/* @__PURE__ */ _(`button`,{type:`button`,class:`${fc}-icon-btn`,onClick:()=>ae.current?.click(),disabled:le,"aria-label":D.attach,"data-testid":J.composerAttach,children:/* @__PURE__ */ _(oo,{})}):null,_e.isSupported?/* @__PURE__ */ _(`button`,{type:`button`,class:`${fc}-icon-btn`,onClick:Ae,disabled:le,"aria-label":P?D.micStop:D.micStart,"aria-pressed":P,"data-recording":P?`true`:void 0,"data-testid":J.composerVoice,children:/* @__PURE__ */ _(so,{})}):null]}),/* @__PURE__ */ _(`textarea`,{ref:ie,name:`message`,class:`${fc}-textarea`,rows:1,value:O,placeholder:D.composerPlaceholder,onInput:e=>z(e.currentTarget.value),onKeyDown:De,disabled:le,"aria-label":D.composerPlaceholder,"data-testid":J.composerInput}),fe&&Me?/* @__PURE__ */ _(`button`,{type:`button`,class:`${fc}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:Ee,disabled:le,"aria-label":D.queueMessage,title:D.queueMessage,"data-testid":J.composerSend,children:/* @__PURE__ */ _(je,{})}):null,Ne?/* @__PURE__ */ _(`button`,{type:`button`,class:`${fc}-send`,onClick:T,disabled:le,"aria-label":D.stop,"data-testid":J.composerStop,children:/* @__PURE__ */ _(ao,{})}):null,!Ne&&(!fe||!Me)?/* @__PURE__ */ _(`button`,{type:`button`,class:`${fc}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:()=>void Te(),disabled:le||!O.trim()&&A.length===0,"aria-label":D.send,"data-testid":J.composerSend,children:/* @__PURE__ */ _(je,{})}):null,b&&S===`ai-agent`&&C?/* @__PURE__ */ _(`button`,{type:`button`,class:`${fc}-icon-btn`,onClick:C,disabled:le||!x,"aria-label":D.talkToOperator,title:D.talkToOperator,"data-testid":J.operatorRequest,children:/* @__PURE__ */ _(Mo,{})}):null]}),/* @__PURE__ */ _(`input`,{ref:ae,name:`attachments`,type:`file`,multiple:!0,accept:e.attachments.accept,onChange:Oe,disabled:le,class:`${fc}-sr-only`,"data-testid":J.composerFileInput})]})}const yc=N.cssPrefix;function bc({onClick:e,children:t,testid:n}){return e?/* @__PURE__ */ _(`button`,{type:`button`,class:`${yc}-home-card`,"data-interactive":`true`,onClick:e,"data-testid":n,children:t}):/* @__PURE__ */ _(`div`,{class:`${yc}-home-card`,"data-testid":n,children:t})}function xc(e){return e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(``)}const Sc=N.cssPrefix,Cc=z.scope(`news`);function wc(e,t){let n=e?new Date(e):void 0;if(n&&!Number.isNaN(n.getTime()))return new Intl.DateTimeFormat(t,{dateStyle:`medium`}).format(n)}function Tc({options:e,transport:t,strings:n,config:r,nav:i,bus:a,panelProps:o,latestNews:s}){let c=r.contentCollectionIds,[l,d]=h({items:[],loading:!0}),f=m(void 0);function p(e){if(!c?.length)return;let r={};f.current=r,d(e=>({...e,loading:!0,error:void 0})),t.listContent({contentCollectionIds:c,sortBy:`publishedAt`,sortOrder:`desc`,page:e,limit:10}).then(t=>{if(f.current!==r||(d(n=>({items:e>1?[...n.items,...t.items]:t.items,pagination:t.pagination,loading:!1})),e>1))return;a.emit(`contentView`,{section:`news`,count:t.items.length});let n=t.items[0];n&&s.markSeen(n.id)}).catch(t=>{f.current===r&&(Cc.warn(`listContent (news) failed`,{err:t,page:e}),d(e=>({...e,loading:!1,error:Is(t,n)})))})}function g(){l.loading||p((l.pagination?.page??0)+1)}u(()=>(d({items:[],loading:!0}),p(1),()=>{f.current=void 0}),[t,c]);function y(t){let n=wc(t.publishedAt,e.locale);return/* @__PURE__ */ v(`button`,{type:`button`,class:`${Sc}-news-card`,onClick:()=>i.push({kind:`content`,id:t.id,title:t.title}),"data-testid":ns(J.newsItem,t.id),children:[t.image?/* @__PURE__ */ _(`img`,{class:`${Sc}-news-hero`,src:t.image,alt:``,loading:`lazy`}):null,/* @__PURE__ */ v(`span`,{class:`${Sc}-news-body`,children:[/* @__PURE__ */ _(`span`,{class:`${Sc}-news-title`,children:t.title}),n||t.tags?.length?/* @__PURE__ */ v(`span`,{class:`${Sc}-news-meta`,children:[n?/* @__PURE__ */ _(`time`,{dateTime:t.publishedAt,children:n}):null,t.tags?.map(e=>/* @__PURE__ */ _(`span`,{class:`${Sc}-news-tag`,children:e},e))]}):null,t.description?/* @__PURE__ */ _(`span`,{class:`${Sc}-news-summary`,children:t.description}):null]})]},t.id)}function b(){if(!c?.length)return/* @__PURE__ */ _(Ss,{message:n.newsEmpty,strings:n});let e=l.error?/* @__PURE__ */ _(Ss,{tone:`error`,message:l.error,onRetry:g,strings:n}):null;return e&&!l.pagination?e:l.pagination?l.items.length?/* @__PURE__ */ v(`div`,{class:`${Sc}-news-list`,children:[l.items.map(y),e,l.pagination.hasNext&&!e?/* @__PURE__ */ v(`button`,{type:`button`,class:`${Sc}-news-more`,onClick:g,"aria-busy":l.loading,"data-testid":J.newsMore,children:[l.loading?/* @__PURE__ */ _(`span`,{class:`${Sc}-loading-spinner`,"aria-hidden":`true`}):null,n.newsShowMore]}):null]}):/* @__PURE__ */ _(Ss,{message:n.newsEmpty,strings:n}):/* @__PURE__ */ _(Ss,{message:n.newsLoading,strings:n})}return/* @__PURE__ */ v(`div`,{class:`${Sc}-module`,children:[/* @__PURE__ */ _(fs,{title:n.newsTitle,actions:/* @__PURE__ */ _(Ps,{panelProps:o,variant:`plain`})}),/* @__PURE__ */ _(`div`,{class:`${Sc}-module-scroll`,children:b()})]})}const Ec={Icon:Lo,Root:e=>/* @__PURE__ */ _(Tc,{...e})},Y=N.cssPrefix,Dc=z.scope(`home`);function Oc(e){let t=e.options.userContext?.name,n=e.config.greetingText?j(e.strings,e.config.greetingText):void 0;if(n){let r=t?n.replace(`{name}`,t):n.replace(/\s*\{name\}\s*/,` `).trim(),i=e.strings.homeGreetingLead;return{title:r,subtitle:r.toLowerCase()===i.toLowerCase()?void 0:i}}return t?{title:e.strings.homeGreetingNamed.replace(`{name}`,t),subtitle:e.strings.homeGreetingLead}:{title:e.strings.homeGreeting}}function kc(e,t){return t.url?e.push({kind:`iframe`,url:t.url,title:t.title}):e.push({kind:`content`,id:t.id,title:t.title})}function Ac({options:e,onAsk:t}){let[n,r]=h(``),{sendButton:i}=e.composer,a=hc[i.icon];function o(e){e.preventDefault();let i=n.trim();i&&(r(``),t(i))}return/* @__PURE__ */ v(`form`,{class:`${Y}-home-search ${Y}-home-ask`,"data-input":`true`,onSubmit:o,"data-testid":J.homeAsk,children:[/* @__PURE__ */ _(`input`,{type:`text`,class:`${Y}-home-search-input`,placeholder:e.strings.homeAskPlaceholder,"aria-label":e.strings.homeAskPlaceholder,value:n,enterKeyHint:`send`,onInput:e=>r(e.currentTarget.value)}),/* @__PURE__ */ _(`button`,{type:`submit`,class:`${Y}-send`,"data-shape":i.shape,"data-variant":i.variant,disabled:!n.trim(),"aria-label":e.strings.send,children:/* @__PURE__ */ _(a,{})})]})}function jc(e,t){return Ca(e,t,t.type!==`upsert`||t.activity===!0)}function Mc(e){let{transport:t,strings:n,config:r,nav:i,bus:a,panelProps:o,latestNews:s}=e,[c,l]=h(null),[d,f]=h([]),p=r.contentCollectionIds?.join(`,`),m=e.options.modules.list.some(e=>e.layout===`chat`);u(()=>{if(r.showRecentConversations===!1)return;let e=!1,n=!0,i=[],a=t.subscribeConversationChanges(e=>{n&&i.push(e),l(t=>jc(t?[t]:[],e)[0]??null)});return t.listConversations({limit:m?50:1}).then(t=>{if(e)return;let r=i.reduce(jc,t.conversations);i=[],n=!1,l(r[0]??null)}).catch(t=>{e||(i=[],n=!1,Dc.warn(`listConversations (home) failed`,{err:t}))}),()=>{e=!0,a()}},[t,r.showRecentConversations,m]),u(()=>{if(!r.contentCollectionIds?.length)return;let e=!1;return t.listContent({contentCollectionIds:r.contentCollectionIds,pinned:!0,limit:6}).then(t=>{e||(f(t.items),a.emit(`contentView`,{section:`home`,count:t.items.length}))}).catch(t=>!e&&Dc.warn(`listContent (home) failed`,{err:t})),()=>{e=!0}},[t,p,a]);let y=Oc(e),b=r.userAvatars??[],x=r.status,S=x?.text?j(n,x.text):n.homeStatus,C=r.contentBlockTitle?j(n,r.contentBlockTitle):n.homeContentTitle,w=s.item,T=wc(w?.publishedAt,e.options.locale);return/* @__PURE__ */ _(`div`,{class:`${Y}-module ${Y}-home`,"data-testid":J.homeView,children:/* @__PURE__ */ v(`div`,{class:`${Y}-home-scroll`,children:[/* @__PURE__ */ v(`div`,{class:`${Y}-home-hero`,children:[/* @__PURE__ */ v(`div`,{class:`${Y}-home-hero-top`,children:[r.brandName?/* @__PURE__ */ _(`span`,{class:`${Y}-home-brand`,"data-testid":J.homeBrand,children:r.brandName}):/* @__PURE__ */ _(`span`,{class:`${Y}-home-brand-spacer`,"aria-hidden":`true`}),/* @__PURE__ */ v(`div`,{class:`${Y}-home-hero-actions`,children:[b.length>0?/* @__PURE__ */ _(`div`,{class:`${Y}-home-avatars`,children:b.map(e=>/* @__PURE__ */ _(`span`,{class:`${Y}-home-avatar`,title:e.role?`${e.name} · ${e.role}`:e.name,children:e.avatar?/* @__PURE__ */ _(`img`,{src:e.avatar,alt:``,loading:`lazy`}):/* @__PURE__ */ _(`span`,{children:xc(e.name)})},e.name))}):null,/* @__PURE__ */ _(Ps,{panelProps:o,variant:`plain`})]})]}),r.showGreeting===!1?null:/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`h1`,{class:`${Y}-home-greeting`,"data-testid":J.homeGreeting,children:y.title}),y.subtitle?/* @__PURE__ */ _(`p`,{class:`${Y}-home-lead`,children:y.subtitle}):null]})]}),/* @__PURE__ */ v(`div`,{class:`${Y}-home-cards`,children:[m?/* @__PURE__ */ _(Ac,{options:e.options,onAsk:e=>i.startNewConversation(e)}):null,r.showSearchBar===!1?null:/* @__PURE__ */ _(Rs,{placeholder:n.homeSearchPlaceholder,onActivate:()=>i.switchToLayout(`help`)}),w?/* @__PURE__ */ _(bc,{onClick:()=>{s.markSeen(w.id),i.push({kind:`content`,id:w.id,title:w.title})},testid:J.homeWhatsNew,children:/* @__PURE__ */ v(`div`,{class:`${Y}-home-recent-row`,"data-unread":s.unseen?`true`:void 0,children:[/* @__PURE__ */ _(`span`,{class:`${Y}-home-recent-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Lo,{})}),/* @__PURE__ */ v(`span`,{class:`${Y}-home-recent-body`,children:[/* @__PURE__ */ _(`span`,{class:`${Y}-home-recent-title`,children:n.homeWhatsNew}),/* @__PURE__ */ _(`span`,{class:`${Y}-home-recent-preview`,children:T?`${w.title} · ${T}`:w.title})]}),s.unseen?/* @__PURE__ */ _(`span`,{class:`${Y}-home-recent-dot`,role:`img`,"aria-label":n.newsUnseen}):null]})}):null,c?/* @__PURE__ */ _(bc,{onClick:()=>i.selectConversation(c),testid:J.homeRecent,children:/* @__PURE__ */ v(`div`,{class:`${Y}-home-recent-row`,"data-unread":c.hasUnread?`true`:void 0,children:[/* @__PURE__ */ _(`span`,{class:`${Y}-home-recent-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Ro,{})}),/* @__PURE__ */ v(`span`,{class:`${Y}-home-recent-body`,children:[/* @__PURE__ */ _(`span`,{class:`${Y}-home-recent-title`,children:c.title}),c.preview?/* @__PURE__ */ _(`span`,{class:`${Y}-home-recent-preview`,children:bs(c.preview)}):null]}),c.hasUnread?/* @__PURE__ */ _(`span`,{class:`${Y}-home-recent-dot`,"aria-label":`Unread`}):null]})}):null,x?/* @__PURE__ */ _(bc,{onClick:x.url?()=>i.push({kind:`iframe`,url:x.url,title:S}):void 0,children:/* @__PURE__ */ v(`div`,{class:`${Y}-home-status`,"data-level":x.level??`operational`,children:[/* @__PURE__ */ _(`span`,{class:`${Y}-home-status-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Fo,{})}),/* @__PURE__ */ _(`span`,{class:`${Y}-home-status-text`,children:S})]})}):null,d.length>0?/* @__PURE__ */ v(`section`,{class:`${Y}-home-content`,children:[/* @__PURE__ */ _(`div`,{class:`${Y}-home-content-title`,children:C}),/* @__PURE__ */ _(`div`,{class:`${Y}-home-content-list`,children:d.map(e=>/* @__PURE__ */ _(Vs,{title:e.title,subtitle:e.description,onClick:()=>kc(i,e),testid:ns(J.homeContentRow,e.id)},e.id))})]}):null]})]})})}const Nc={chat:Fs,home:{Icon:Io,Root:e=>/* @__PURE__ */ _(Mc,{...e})},help:qs,news:Ec},Pc=N.cssPrefix;function Fc({modules:e,activeTab:t,strings:n,hasUnread:r,onSelect:i}){return/* @__PURE__ */ _(`nav`,{class:`${Pc}-tabbar`,role:`tablist`,"aria-label":n.panelTitle,children:e.map(e=>{let a=Nc[e.layout].Icon,o=e.id===t,s=e.layout===`chat`&&r;return/* @__PURE__ */ v(`button`,{type:`button`,role:`tab`,"aria-selected":o,class:`${Pc}-tab`,onClick:()=>i(e.id),"data-testid":ns(J.tab,e.id),children:[/* @__PURE__ */ v(`span`,{class:`${Pc}-tab-icon`,"aria-hidden":`true`,children:[/* @__PURE__ */ _(a,{}),s?/* @__PURE__ */ _(`span`,{class:`${Pc}-tab-badge`,"data-testid":J.tabBadge,"aria-label":`Unread`}):null]}),/* @__PURE__ */ _(`span`,{class:`${Pc}-tab-label`,children:j(n,e.label)})]},e.id)})})}const Ic=N.cssPrefix;function Lc({url:e,title:t,strings:n,onBack:r,actions:i}){return/* @__PURE__ */ v(`div`,{class:`${Ic}-module`,children:[/* @__PURE__ */ _(ps,{title:t||n.moduleBack,backLabel:n.moduleBack,onBack:r,actions:i}),/* @__PURE__ */ _(`iframe`,{class:`${Ic}-content-frame`,src:e,title:t||`content`,sandbox:`allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-downloads`,referrerpolicy:`no-referrer`,loading:`lazy`,allow:`fullscreen`})]})}const Rc=N.cssPrefix;function zc({agent:e,strings:t}){let n=e.status??`online`,r=j(t,e.name),i=e.title?j(t,e.title):null;return/* @__PURE__ */ v(`div`,{class:`${Rc}-agent`,children:[/* @__PURE__ */ _(`div`,{class:`${Rc}-agent-avatar`,"data-status":n,children:e.avatar?/* @__PURE__ */ _(`img`,{src:e.avatar,alt:``}):/* @__PURE__ */ _(`span`,{children:xc(r)})}),/* @__PURE__ */ v(`div`,{class:`${Rc}-agent-meta`,children:[/* @__PURE__ */ _(`strong`,{children:r}),i?/* @__PURE__ */ _(`span`,{children:i}):null]})]})}const Bc=[`today`,`yesterday`,`lastWeek`,`older`];function Vc(e,t){let n=Date.parse(t);if(!Number.isFinite(n))return`older`;let r=Math.floor((Uc(e)-Uc(n))/864e5);return r<=0?`today`:r===1?`yesterday`:r<7?`lastWeek`:`older`}function Hc(e,t){let n=/* @__PURE__ */ new Map;for(let r of t){let t=Vc(e,r.lastMessageAt),i=n.get(t);i?i.push(r):n.set(t,[r])}return Bc.filter(e=>n.has(e)).map(e=>({bucket:e,conversations:n.get(e)}))}function Uc(e){let t=new Date(e);return t.setUTCHours(0,0,0,0),t.getTime()}const Wc=z.scope(`history`),Gc={today:`dateToday`,yesterday:`dateYesterday`,lastWeek:`dateLastWeek`,older:`dateOlder`};function Kc(e,t){let n=t.type!==`upsert`||t.activity===!0;if(t.type===`snapshot`&&t.result.pagination.page===1&&e.pagination.page>1){let r=Ca(e.conversations.slice(0,t.result.pagination.limit),t,n);if(t.result.conversations.length===0){if(r.length===0)return t.result;let e=Math.max(t.result.pagination.total,r.length);return{...t.result,conversations:r,pagination:{...t.result.pagination,total:e,totalPages:Math.ceil(e/t.result.pagination.limit)}}}let i=new Set(r.map(e=>e.conversationId)),a=e.conversations.slice(t.result.pagination.limit).filter(e=>!i.has(e.conversationId)),o=e.pagination.page,s={...t.result.pagination,page:o,hasPrev:o>1,hasNext:o<t.result.pagination.totalPages};return{conversations:[...r,...a],pagination:s}}let r=Ca(e.conversations,t,n);return r===e.conversations?e:{...t.type===`snapshot`?t.result:e,conversations:r}}function qc(e,t,n){let r=Date.parse(e);return Number.isFinite(r)?new Date(r).toDateString()===new Date(t).toDateString()?new Intl.DateTimeFormat(n,{hour:`numeric`,minute:`2-digit`}).format(r):t-r<6048e5?new Intl.DateTimeFormat(n,{weekday:`short`}).format(r):new Intl.DateTimeFormat(n,{month:`short`,day:`numeric`}).format(r):``}function Jc({transport:e,strings:t,locale:n,persistence:r,onSelect:i,onNewConversation:a}){let o=N.cssPrefix,s=e.peekConversations({limit:50}),[c,l]=h(s?`loaded`:`loading`),[d,f]=h(s),[p,y]=h(!1),b=m(void 0),x=d?.conversations??[],S=d?.pagination;u(()=>{let t=!1,n=!0,i=[],a=e.subscribeConversationChanges(e=>{n&&i.push(e),f(t=>t&&Kc(t,e))});b.current=void 0,y(!1);let o=e.peekConversations({limit:50});return f(o),l(o?`loaded`:`loading`),e.listConversations({limit:50}).then(e=>{if(t)return;let a=e;for(let e of i)a=Kc(a,e);i=[],n=!1,f(a),l(`loaded`),r.saveHistoryCount(a.conversations.length)}).catch(e=>{t||(i=[],n=!1,Wc.warn(`listConversations failed`,{err:e}),l(`error`))}),()=>{t=!0,a(),b.current=void 0}},[e,r,n]);async function C(){if(b.current||!S?.hasNext)return;let t={};b.current=t,y(!0);try{let n=await e.listConversations({page:S.page+1,limit:S.limit});if(b.current!==t)return;f(e=>{if(!e)return e;let t=new Set(e.conversations.map(e=>e.conversationId)),i=n.conversations.filter(e=>!t.has(e.conversationId)&&(t.add(e.conversationId),!0)),a={conversations:[...e.conversations,...i],pagination:n.pagination};return r.saveHistoryCount(a.conversations.length),a})}catch(e){if(b.current!==t)return;Wc.warn(`listConversations page failed`,{err:e,page:S.page+1})}finally{b.current===t&&(b.current=void 0,y(!1))}}let w=a?/* @__PURE__ */ _(`div`,{class:`${o}-history-footer`,children:/* @__PURE__ */ v(`button`,{type:`button`,class:`${o}-history-new`,onClick:a,"data-testid":J.sidebarNewConversation,children:[/* @__PURE__ */ _(eo,{}),t.newConversation]})}):null;if(c===`loading`){let e=Math.min(r.loadHistoryCount()??3,6);return/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`div`,{class:`${o}-history`,"aria-busy":`true`,"aria-label":t.historyLoading,children:/* @__PURE__ */ v(`div`,{class:`${o}-history-group`,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`div`,{class:`${o}-history-heading`,children:/* @__PURE__ */ _(`span`,{class:`${o}-skeleton ${o}-skeleton-heading`})}),/* @__PURE__ */ _(`div`,{class:`${o}-history-card`,children:Array.from({length:Math.max(1,e)},(e,t)=>/* @__PURE__ */ v(`div`,{class:`${o}-history-item ${o}-history-item-skeleton`,children:[/* @__PURE__ */ _(`span`,{class:`${o}-history-avatar ${o}-skeleton`}),/* @__PURE__ */ v(`span`,{class:`${o}-history-body`,children:[/* @__PURE__ */ v(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ _(`span`,{class:`${o}-history-title`,children:/* @__PURE__ */ _(`span`,{class:`${o}-skeleton ${o}-skeleton-title`})}),/* @__PURE__ */ _(`span`,{class:`${o}-history-time`,children:/* @__PURE__ */ _(`span`,{class:`${o}-skeleton ${o}-skeleton-time`})})]}),/* @__PURE__ */ _(`span`,{class:`${o}-history-row`,children:/* @__PURE__ */ _(`span`,{class:`${o}-history-preview`,children:/* @__PURE__ */ _(`span`,{class:`${o}-skeleton ${o}-skeleton-preview`})})})]})]},t))})]})}),w]})}if(c===`error`||x.length===0)return/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`div`,{class:`${o}-history-empty`,children:t.historyEmpty}),w]});let T=Date.now(),E=Hc(T,x);return/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ v(`div`,{class:`${o}-history`,role:`list`,children:[E.map(e=>/* @__PURE__ */ v(`div`,{class:`${o}-history-group`,children:[/* @__PURE__ */ _(`div`,{class:`${o}-history-heading`,children:t[Gc[e.bucket]]}),/* @__PURE__ */ _(`div`,{class:`${o}-history-card`,children:e.conversations.map(e=>/* @__PURE__ */ _(`div`,{role:`listitem`,children:/* @__PURE__ */ v(`button`,{type:`button`,class:`${o}-history-item`,onClick:()=>i(e),"data-closed":e.canContinue?void 0:`true`,"data-unread":e.hasUnread?`true`:void 0,"data-testid":ns(J.historyItem,e.conversationId),children:[/* @__PURE__ */ _(`span`,{class:`${o}-history-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Oo,{})}),/* @__PURE__ */ v(`span`,{class:`${o}-history-body`,children:[/* @__PURE__ */ v(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ _(`span`,{class:`${o}-history-title`,children:e.title}),/* @__PURE__ */ _(`span`,{class:`${o}-history-time`,children:qc(e.lastMessageAt,T,n)})]}),/* @__PURE__ */ v(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ _(`span`,{class:`${o}-history-preview`,children:e.preview&&bs(e.preview)||(e.canContinue?t.historyContinue:t.conversationClosed)}),e.hasUnread?/* @__PURE__ */ _(`span`,{class:`${o}-history-dot`}):null]})]})]})},e.conversationId))})]},e.bucket)),S?.hasNext?/* @__PURE__ */ _(`div`,{class:`${o}-history-more`,children:/* @__PURE__ */ _(`button`,{type:`button`,onClick:C,disabled:p,"aria-busy":p,"data-testid":J.historyLoadMore,children:t.loadMoreConversations})}):null]}),w]})}const Yc=N.cssPrefix;function Xc({visible:e,strings:t}){return e?/* @__PURE__ */ _(`div`,{class:`${Yc}-dropzone`,role:`status`,"aria-live":`polite`,children:t.dropZone}):null}const Zc=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Qc=/^https?:\/\/[^\s.]+\.[^\s]+$/i,$c=/^[+]?[\d\s().-]{6,}$/;function el(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>String(t[n]??`{${n}}`))}function tl(e){return Array.isArray(e)?e.length:+!!e?.trim()}function nl(e,t,n){let r=e.required??!0,i=e.validation;if(e.type===`multiselect`){let e=tl(t);return r&&e===0?n.formRequired:e===0?void 0:i?.minSelections!=null&&e<i.minSelections?el(n.formChooseAtLeast,{min:i.minSelections}):i?.maxSelections!=null&&e>i.maxSelections?el(n.formChooseAtMost,{max:i.maxSelections}):void 0}let a=typeof t==`string`?t.trim():``;if(!a)return r?n.formRequired:void 0;switch(e.type){case`email`:if(!Zc.test(a))return n.formInvalidEmail;break;case`url`:if(!Qc.test(a))return n.formInvalidUrl;break;case`tel`:if(!$c.test(a))return n.formInvalidTel;break;case`number`:{let e=Number(a);if(!Number.isFinite(e))return n.formInvalidNumber;if(i?.min!=null&&e<i.min)return el(n.formNumberTooSmall,{min:i.min});if(i?.max!=null&&e>i.max)return el(n.formNumberTooLarge,{max:i.max});break}}if(i?.minLength!=null&&a.length<i.minLength)return el(n.formTooShort,{min:i.minLength});if(i?.maxLength!=null&&a.length>i.maxLength)return el(n.formTooLong,{max:i.maxLength});if(i?.pattern)try{if(!new RegExp(i.pattern).test(a))return n.formPatternMismatch}catch{}}function rl(e,t,n){let r={};for(let i of e){let e=nl(i,t[i.name],n);e&&(r[i.name]=e)}return r}function il(e){let t={};for(let[n,r]of Object.entries(e)){let e=Array.isArray(r)?r.join(`, `):r;e.trim()&&(t[n]=e.trim())}return t}const X=N.cssPrefix,al=`__other__`;function ol({fields:e,strings:t,submitLabel:n,onSubmit:r,skipLabel:i,onSkip:a,footerHint:o,submitOnEnter:s,disabled:c,initialValues:l,hideActions:u,fieldTypeLabels:d,rootTestId:f,submitTestId:p,skipTestId:m}){let[g,y]=h(()=>({...ul(e),...l})),[b,x]=h({}),[S,C]=h({});function w(e){S[e]&&C(t=>({...t,[e]:``}))}function T(e,t){y(n=>({...n,[e]:t})),w(e)}function E(e,t){x(n=>({...n,[e]:t})),w(e)}function D(n){if(n.preventDefault(),c)return;let i=dl(e,g,b),a=rl(e,i,t);Object.keys(a).length>0?C(a):r(il(i))}function O(e){!s||e.key!==`Enter`||e.shiftKey||e.isComposing||e.target&&`tagName`in e.target&&e.target.tagName===`TEXTAREA`&&D(e)}return/* @__PURE__ */ v(`form`,{class:`${X}-form`,onSubmit:D,onKeyDown:O,"data-testid":f,noValidate:!0,children:[e.map(e=>/* @__PURE__ */ _(sl,{field:e,value:g[e.name],otherText:b[e.name]??``,error:S[e.name],disabled:c,typeLabel:d?.[e.name],strings:t,onChange:t=>T(e.name,t),onOtherChange:t=>E(e.name,t)},e.name)),u?null:/* @__PURE__ */ v(`div`,{class:`${X}-form-actions`,children:[o?/* @__PURE__ */ _(`span`,{class:`${X}-form-hint`,children:o}):null,i&&a?/* @__PURE__ */ _(`button`,{type:`button`,class:`${X}-form-skip`,onClick:a,disabled:c,"data-testid":m,children:i}):null,/* @__PURE__ */ _(`button`,{type:`submit`,class:`${X}-form-submit`,disabled:c,"data-testid":p,children:n})]})]})}function sl({field:e,value:t,otherText:n,error:r,disabled:i,typeLabel:a,strings:o,onChange:s,onOtherChange:c}){let l=cl({field:e,value:t,otherText:n,disabled:i,strings:o,onChange:s,onOtherChange:c,fieldTid:ns(J.formField,e.name)});return/* @__PURE__ */ v(`label`,{class:`${X}-field`,"data-field":e.name,"data-invalid":r?`true`:void 0,children:[/* @__PURE__ */ v(`span`,{class:`${X}-field-head`,children:[/* @__PURE__ */ v(`span`,{class:`${X}-field-label`,children:[e.label,e.required??!0?/* @__PURE__ */ _(`span`,{class:`${X}-field-req`,"aria-hidden":`true`,children:` *`}):null]}),a?/* @__PURE__ */ _(`span`,{class:`${X}-field-type`,children:a}):null]}),l,e.validationHint&&!r?/* @__PURE__ */ _(`span`,{class:`${X}-field-hint`,children:e.validationHint}):null,r?/* @__PURE__ */ _(`span`,{class:`${X}-field-error`,role:`alert`,children:r}):null]})}function cl(e){let{field:t,value:n,otherText:r,disabled:i,strings:a,onChange:o,onOtherChange:s,fieldTid:c}=e,l=typeof n==`string`?n:``,u=t.type===`select`?a.formOtherPlaceholder:t.placeholder??a.formOtherPlaceholder,d=t.allowOther&&l===al?/* @__PURE__ */ _(`input`,{class:`${X}-field-input`,value:r,placeholder:u,disabled:i,onInput:e=>s(e.currentTarget.value)}):null;switch(t.type){case`textarea`:return/* @__PURE__ */ _(`textarea`,{class:`${X}-field-input`,rows:3,value:l,placeholder:t.placeholder,disabled:i,onInput:e=>o(e.currentTarget.value),"data-testid":c});case`select`:return/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ v(`select`,{class:`${X}-field-input`,value:l,disabled:i,onChange:e=>o(e.currentTarget.value),"data-testid":c,children:[/* @__PURE__ */ _(`option`,{value:``,children:t.placeholder??`—`}),(t.options??[]).map(e=>/* @__PURE__ */ _(`option`,{value:e.value,children:e.label??e.value},e.value)),t.allowOther?/* @__PURE__ */ _(`option`,{value:al,children:a.formOther}):null]}),d]});case`radio`:return/* @__PURE__ */ v(`div`,{class:`${X}-field-choices`,role:`radiogroup`,"data-testid":c,children:[(t.options??[]).map(e=>/* @__PURE__ */ v(`label`,{class:`${X}-choice`,children:[/* @__PURE__ */ _(`input`,{type:`radio`,name:`${X}-${t.name}`,checked:l===e.value,disabled:i,onChange:()=>o(e.value)}),/* @__PURE__ */ _(`span`,{children:e.label??e.value})]},e.value)),t.allowOther?/* @__PURE__ */ v(`label`,{class:`${X}-choice`,children:[/* @__PURE__ */ _(`input`,{type:`radio`,name:`${X}-${t.name}`,checked:l===al,disabled:i,onChange:()=>o(al)}),/* @__PURE__ */ _(`span`,{children:a.formOther})]}):null,d]});case`checkbox`:return/* @__PURE__ */ v(`label`,{class:`${X}-choice`,children:[/* @__PURE__ */ _(`input`,{type:`checkbox`,checked:l===`true`,disabled:i,onChange:e=>o(e.currentTarget.checked?`true`:``),"data-testid":c}),/* @__PURE__ */ _(`span`,{children:t.placeholder??t.label})]});case`multiselect`:{let e=Array.isArray(n)?n:[];function l(t,n){return o(n?[...e,t]:e.filter(e=>e!==t))}return/* @__PURE__ */ v(`div`,{class:`${X}-field-choices`,"data-testid":c,children:[(t.options??[]).map(t=>/* @__PURE__ */ v(`label`,{class:`${X}-choice`,children:[/* @__PURE__ */ _(`input`,{type:`checkbox`,checked:e.includes(t.value),disabled:i,onChange:e=>l(t.value,e.currentTarget.checked)}),/* @__PURE__ */ _(`span`,{children:t.label??t.value})]},t.value)),t.allowOther||(t.options??[]).length===0?/* @__PURE__ */ _(`textarea`,{class:`${X}-field-input`,rows:2,value:r,placeholder:t.placeholder??a.formOtherPlaceholder,disabled:i,onInput:e=>s(e.currentTarget.value)}):null]})}default:return/* @__PURE__ */ _(`input`,{...ll(t.type),class:`${X}-field-input`,value:l,placeholder:t.placeholder,disabled:i,onInput:e=>o(e.currentTarget.value),"data-testid":c})}}function ll(e){switch(e){case`number`:return{type:e};case`email`:return{type:e};case`tel`:return{type:e};case`url`:return{type:e};case`date`:case`time`:return{type:e};default:return{type:`text`}}}function ul(e){let t={};for(let n of e)n.defaultValue!=null&&(t[n.name]=n.type===`multiselect`?n.defaultValue.split(`,`).map(e=>e.trim()).filter(Boolean):n.defaultValue);return t}function dl(e,t,n){let r={...t};for(let i of e){let e=n[i.name]?.trim();if((i.type===`radio`||i.type===`select`)&&i.allowOther&&t[i.name]===al)r[i.name]=e??``;else if(i.type===`multiselect`&&e){let n=e.split(/[,\n;]+/).map(e=>e.trim()).filter(Boolean),a=t[i.name];r[i.name]=[...Array.isArray(a)?a:[],...n]}}return r}const fl=N.cssPrefix;function pl({form:e,strings:t,onSubmit:n,onSkip:r}){return/* @__PURE__ */ v(`div`,{class:`${fl}-form-gate`,"data-testid":J.formGate,children:[e.title?/* @__PURE__ */ _(`h3`,{class:`${fl}-form-gate-title`,children:e.title}):null,e.description?/* @__PURE__ */ _(`p`,{class:`${fl}-form-gate-desc`,children:e.description}):null,/* @__PURE__ */ _(ol,{fields:e.fields,strings:t,submitLabel:e.submitLabel??t.formSubmit,onSubmit:n,skipLabel:e.skippable?t.formSkip:void 0,onSkip:e.skippable?r:void 0,submitTestId:J.formSubmit,skipTestId:J.formSkip})]})}function ml({marker:e,strings:t,onFill:n}){let r=e.outcome===`skipped`,i=r?t.formSkipped:t.formSubmitted,a=e.title?/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`span`,{children:e.title}),/* @__PURE__ */ _(`span`,{class:`${fl}-sr-only`,children:i})]}):/* @__PURE__ */ _(`span`,{children:i}),o=e.form?.reviewable??!1,s=!r&&o&&e.values&&Object.keys(e.values).length>0?e.values:null;if(s){function t(t){return e.form?.fields.find(e=>e.name===t)?.label??t}return/* @__PURE__ */ v(`details`,{class:`${fl}-form-done`,"data-outcome":e.outcome,"data-testid":J.formDone,children:[/* @__PURE__ */ v(`summary`,{class:`${fl}-form-done-summary`,"data-testid":J.formDoneToggle,children:[/* @__PURE__ */ _(bo,{}),a,/* @__PURE__ */ _(io,{})]}),/* @__PURE__ */ _(`dl`,{class:`${fl}-form-answers`,"data-testid":J.formAnswers,children:Object.entries(s).map(([e,n])=>/* @__PURE__ */ v(`div`,{class:`${fl}-form-answer`,children:[/* @__PURE__ */ _(`dt`,{children:t(e)}),/* @__PURE__ */ _(`dd`,{children:n})]},e))})]})}return/* @__PURE__ */ v(`div`,{class:`${fl}-form-done`,"data-outcome":e.outcome,"data-testid":J.formDone,role:`status`,children:[_(r?yo:bo,{}),a,r&&e.form?.reopenable&&n?/* @__PURE__ */ _(`button`,{type:`button`,class:`${fl}-form-done-fill`,"data-testid":J.formFill,onClick:n,children:t.formFillOut}):null]})}const hl=N.cssPrefix;function gl({messageId:e,initial:t,strings:n,onFeedback:r}){let[i,a]=h(t);u(()=>a(t),[e,t]);function o(t){let n=i===t?null:t;a(n),r(e,n)}return/* @__PURE__ */ v(`div`,{class:`${hl}-feedback`,role:`group`,"data-testid":J.messageFeedback,children:[/* @__PURE__ */ _(`button`,{type:`button`,class:`${hl}-msg-action`,"data-active":i===`up`?`true`:void 0,"aria-pressed":i===`up`,"aria-label":n.feedbackUp,title:n.feedbackUp,onClick:()=>o(`up`),"data-testid":J.feedbackUp,children:/* @__PURE__ */ _(qo,{})}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${hl}-msg-action`,"data-active":i===`down`?`true`:void 0,"aria-pressed":i===`down`,"aria-label":n.feedbackDown,title:n.feedbackDown,onClick:()=>o(`down`),"data-testid":J.feedbackDown,children:/* @__PURE__ */ _(Jo,{})}),/* @__PURE__ */ _(`span`,{class:`${hl}-sr-only`,role:`status`,"aria-live":`polite`,children:i?n.feedbackThanks:``})]})}const _l=/* @__PURE__ */ new Set([`hidden`,`submit`,`button`,`reset`,`image`,`file`,`password`]);function vl(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function yl(e){return!vl(e)||e.name===``||e.disabled?!1:!(e instanceof HTMLInputElement&&_l.has(e.type))}function bl(e){let t=e.labels?.[0]?.textContent?.trim();return e.getAttribute(`toolparamdescription`)??(t||e.getAttribute(`aria-description`))??void 0}function xl(e,t){let n=bl(e),r=n?{description:n}:{};return e instanceof HTMLSelectElement?{...r,type:`string`,enum:[...e.options].map(e=>e.value)}:e instanceof HTMLTextAreaElement?{...r,type:`string`}:e.type===`checkbox`?{...r,type:`boolean`}:e.type===`radio`?{...r,type:`string`,enum:t}:e.type===`number`||e.type===`range`?{...r,type:`number`}:{...r,type:`string`}}function Sl(e,t){Object.getOwnPropertyDescriptor(Reflect.getPrototypeOf(e)??e,`value`)?.set?.call(e,t),e.dispatchEvent(new Event(`input`,{bubbles:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}function Cl(e){return e==null?``:typeof e==`string`?e:JSON.stringify(e)}function wl(e,t){e instanceof HTMLInputElement&&e.type===`checkbox`?e.checked!==(t===!0||t===`true`)&&e.click():e instanceof HTMLInputElement&&e.type===`radio`?e.value===Cl(t)&&!e.checked&&e.click():Sl(e,Cl(t))}function Tl(e,t,n){let r=[...e.elements].filter(yl),i={},a=/* @__PURE__ */ new Set;for(let e of r){var o;let t=r.flatMap(t=>t instanceof HTMLInputElement&&t.type===`radio`&&t.name===e.name?[t.value]:[]);i[o=e.name]??(i[o]=xl(e,t)),e.required&&a.add(e.name)}return{name:t,description:n,inputSchema:{type:`object`,properties:i,...a.size>0?{required:[...a]}:{}},execute(t){let n=typeof t==`object`&&t?Object.entries(t):[];for(let[e,t]of n)for(let n of r)n.name===e&&wl(n,t);if(!e.hasAttribute(`toolautosubmit`))return`Filled in the form. The visitor still needs to check it and press its submit button.`;let i=[...new Set([...e.elements].flatMap(e=>vl(e)&&e.name&&!e.checkValidity()?[e.name]:[]))];return i.length>0?`Filled in the form, but it can't be submitted yet: ${i.join(`, `)} still needs the visitor. Ask them to complete it and press the submit button.`:(setTimeout(()=>e.requestSubmit(),0),`Filled in the form and submitted it.`)}}}function El(){return[...document.querySelectorAll(`form[toolname][tooldescription]`)].flatMap(e=>{let t=e.getAttribute(`toolname`)?.trim()??``,n=e.getAttribute(`tooldescription`)?.trim()??``;return t&&n?[Tl(e,t,n)]:[]})}const Dl=`${N.cssPrefix}.page-tools`;function Ol(e){return typeof e==`object`&&!!e}function kl(e){return Ol(e)&&(e.state===`running`||e.state===`stopped`||e.state===`finished`&&Ol(e.outcome))}function Al(e){let t=e?JSON.parse(e):void 0;return Ol(t)?{sent:Array.isArray(t.sent)?t.sent.filter(e=>typeof e==`string`):[],calls:Object.fromEntries(Object.entries(Ol(t.calls)?t.calls:{}).filter(e=>kl(e[1])))}:{sent:[],calls:{}}}let jl={sent:[],calls:{}};function Ml(){try{jl=Al(sessionStorage.getItem(Dl))}catch{}return jl}function Nl(e){jl=e;try{sessionStorage.setItem(Dl,JSON.stringify(e))}catch{}}const Pl={markSent(e){let t=Ml();Nl({...t,sent:[...t.sent.filter(t=>t!==e),e].slice(-20)})},sentHere(e){return Ml().sent.includes(e)},get(e){return Ml().calls[e]},set(e,t){let n=Ml(),r=Object.entries(n.calls).filter(([t])=>t!==e);Nl({...n,calls:Object.fromEntries([...r,[e,t]].slice(-50))})},clear(e){let t=Ml();e.some(e=>e in t.calls)&&Nl({...t,calls:Object.fromEntries(Object.entries(t.calls).filter(([t])=>!e.includes(t)))})}},Fl=z.scope(`page-tools`),Il=3e4,Ll=Symbol.for(`${N.cssPrefix}.page-tools`),Rl={state:`output-error`,errorText:`The page reloaded before this finished, so it may or may not have taken effect. Check with the visitor before trying it again.`},zl=`The visitor stopped this before it finished.`;function Bl(e){return typeof e==`object`&&!!e}function Vl(e){return Bl(e)&&Array.isArray(e.registered)&&e.runs instanceof Map}function Hl(){let e=Reflect.get(globalThis,Ll);if(Vl(e))return e;let t={registered:[],runs:/* @__PURE__ */ new Map};return Reflect.set(globalThis,Ll,t),t}function Ul(e,t){let n=Bl(t)&&t.signal instanceof AbortSignal?t.signal:void 0;if(n?.aborted)return;let r=Hl().registered;r.push(e);function i(){let t=r.indexOf(e);t>=0&&r.splice(t,1)}n?.addEventListener(`abort`,i,{once:!0})}function Wl(e){return e.replace(/[^A-Za-z0-9_-]/g,`_`).slice(0,58)}function Gl(e){if(!Bl(e)||typeof e.name!=`string`||!Wl(e.name))return;let t=[e.description,e.title].find(e=>typeof e==`string`&&e.trim()!==``)??e.name;return{name:Wl(e.name),description:t.trim().slice(0,1024),inputSchema:{properties:{},...Bl(e.inputSchema)?e.inputSchema:{},type:`object`},consequential:Bl(e.annotations)&&e.annotations.consequentialHint===!0}}function Kl(e){return e.flatMap(e=>{let t=Gl(e),n=Bl(e)?e.execute:void 0;return!t||typeof n!=`function`?(Fl.warn(`skipped a tool without a name or an execute function`,e),[]):[{...t,run:(t,r)=>Reflect.apply(n,e,[t,{signal:r}])}]})}async function ql(){let e=Reflect.get(document,`modelContext`)??Reflect.get(navigator,`modelContext`);if(!Bl(e)||typeof e.getTools!=`function`||typeof e.executeTool!=`function`)return[];let t=e.getTools,n=e.executeTool,r=await Promise.race([Promise.resolve().then(()=>Reflect.apply(t,e,[])),ca(1e3).then(()=>[])]).catch(()=>[]);return(Array.isArray(r)?r:[]).flatMap(t=>{let r=Gl(t);return r?[{...r,run:(r,i)=>Reflect.apply(n,e,[t,r,{signal:i}])}]:[]})}async function Jl(e=[]){let t=Kl(El()),n=new Set(t.map(e=>e.name)),r=[...(await ql()).filter(e=>!n.has(e.name)),...t,...Kl(e),...Kl(Hl().registered)];return new Map(r.map(e=>[e.name,e]))}function Yl(e){return[...e.values()].map(({name:e,description:t,inputSchema:n,consequential:r})=>r?{name:e,description:t,inputSchema:n,annotations:{consequentialHint:!0}}:{name:e,description:t,inputSchema:n})}function Xl(e){return e?.execution===`client`}function Zl(e){return e.startsWith(`site__`)?e.slice(6):e}function Ql(e){if(e===void 0||typeof e==`function`||typeof e==`symbol`)return null;let t=/* @__PURE__ */ new WeakSet,n=JSON.stringify(e,(e,n)=>{if(typeof n==`bigint`)return n.toString();if(typeof n!=`function`&&typeof n!=`symbol`)return n instanceof Node?`[${n.nodeName.toLowerCase()}]`:Bl(n)?t.has(n)?`[circular]`:(t.add(n),n):n});return n.length>Il?{truncated:!0,preview:n.slice(0,Il)}:JSON.parse(n)}async function $l(e){let t=Zl(e.toolName),n=(await Jl(e.optionTools)).get(t);return n?Promise.resolve().then(()=>n.run(e.input,e.signal)).then(e=>({state:`output-available`,output:Ql(e)})).catch(e=>(Fl.warn(`a page tool failed`,{name:t,error:e}),{state:`output-error`,errorText:(e instanceof Error?e.message:String(e)).slice(0,1e3)||`The page tool failed.`})):{state:`output-error`,errorText:`This page doesn't offer "${t}" right now; the visitor may have moved on. Tell them, or continue without it.`}}function eu(e){let{toolCallId:t}=e,n=Pl.get(t);if(n?.state===`finished`)return Promise.resolve(n.outcome);let{runs:r}=Hl(),i=r.get(t);if(i)return i.outcome;if(n?.state===`running`)return Pl.set(t,{state:`finished`,outcome:Rl}),e.onSettled(`interrupted`,0),Promise.resolve(Rl);let a=new AbortController,o=performance.now();Pl.set(t,{state:`running`});let s=$l({...e,signal:a.signal}).then(n=>(r.delete(t),Pl.get(t)?.state===`running`&&(Pl.set(t,{state:`finished`,outcome:n}),e.onSettled(n.state===`output-available`?`completed`:`failed`,Math.round(performance.now()-o))),n));return r.set(t,{outcome:s,controller:a}),s}function tu(e){return e===Rl.errorText||e===zl}function nu(e){return Pl.set(e,{state:`stopped`}),Hl().runs.get(e)?.controller.abort(),zl}function ru(e){Pl.clear([e]),Hl().runs.get(e)?.controller.abort()}const iu=N.cssPrefix;function au(e){let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function ou(e){if(e.startsWith(`tool:`)||e.startsWith(`tool-`))return e.slice(5);let t=e.indexOf(`__`),n=e.slice(t+2);return t>0&&n?`${au(e.slice(0,t))} · ${au(n)}`:e}function su(e){let t=e.indexOf(`__`),n=e.slice(t+2);return t>0&&n?au(n):ou(e)}function cu(e,t){let n=e===`output-available`||e===`output-error`||e===`output-denied`,r=e===`approval-responded`||t?.approved!==void 0;return{terminal:n,responded:r,decided:n||r}}function lu({status:e,icon:t,label:n}){return/* @__PURE__ */ v(`span`,{class:`${iu}-toolui-badge ${iu}-toolui-status`,"data-status":e,children:[/* @__PURE__ */ _(`span`,{class:`${iu}-toolui-status-icon`,children:t}),n]})}function uu(e,t){return e===`output-error`?`error`:e===`output-denied`||t?.approved===!1?`denied`:e===`output-available`?`completed`:e===`approval-responded`||t?.approved===!0?`responded`:e===`approval-requested`?`awaiting`:`running`}function du(e,t,n={}){return n.submitted?`responded`:n.incomplete?`incomplete`:mu(uu(e,t),n.superseded,n.live??!0,n.stopped??!1)}function fu({status:e}){return _(e===`stopped`?ao:e===`denied`||e===`error`||e===`superseded`||e===`incomplete`?Qo:e===`completed`||e===`responded`?Zo:Xo,{})}function pu(e,t){switch(e){case`awaiting`:return t.statusAwaiting;case`responded`:return t.statusResponded;case`completed`:return t.statusCompleted;case`denied`:return t.statusDenied;case`error`:return t.statusError;case`superseded`:return t.statusSuperseded;case`incomplete`:return t.statusIncomplete;case`stopped`:return t.statusStopped;default:return t.statusRunning}}function mu(e,t,n,r){return t&&(e===`awaiting`||e===`running`)?`superseded`:r&&(e===`running`||e===`responded`)?`stopped`:!n&&e===`running`?`error`:e}function hu({state:e,approval:t,strings:n,superseded:r,live:i=!0,submitted:a=!1,incomplete:o=!1,stopped:s=!1}){let c=du(e,t,{superseded:r,live:i,submitted:a,incomplete:o,stopped:s});return/* @__PURE__ */ _(lu,{status:c,icon:/* @__PURE__ */ _(fu,{status:c}),label:pu(c,n)})}function gu({name:e,state:t,approval:n,strings:r,superseded:i,live:a,submitted:o,incomplete:s,stopped:c}){return/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ v(`span`,{class:`${iu}-toolui-name-pill`,children:[/* @__PURE__ */ _(Yo,{}),/* @__PURE__ */ _(`span`,{class:`${iu}-toolui-name-text`,children:e})]}),/* @__PURE__ */ _(hu,{state:t,approval:n,strings:r,superseded:i,live:a,submitted:o,incomplete:s,stopped:c}),/* @__PURE__ */ _(`span`,{class:`${iu}-toolui-chevron`,children:/* @__PURE__ */ _(To,{})})]})}function _u({part:e,strings:t,testid:n,superseded:r,live:a,submitted:o,incomplete:s,stopped:c,open:l}){let u=p(()=>i(()=>e.inputSig.value),[e]),d=p(()=>i(()=>e.outputSig.value),[e]),f=p(()=>i(()=>e.errorSig.value),[e]),m=p(()=>i(()=>e.stateSig.value),[e]),h=p(()=>i(()=>e.approvalSig.value),[e]),g=p(()=>i(()=>Xl(e.toolMetadata)&&tu(e.errorSig.value)),[e]),y=s===!0||g.value;return/* @__PURE__ */ v(`details`,{class:`${iu}-toolui ${iu}-toolui-collapsible`,"data-testid":n,open:l||void 0,children:[/* @__PURE__ */ _(`summary`,{class:`${iu}-toolui-head`,children:/* @__PURE__ */ _(gu,{name:ou(e.toolName),state:m.value,approval:h.value,strings:t,superseded:r,live:a,submitted:o,incomplete:y,stopped:c})}),/* @__PURE__ */ _(vu,{label:t.toolParameters,value:u.value}),d.value===void 0?null:/* @__PURE__ */ _(vu,{label:t.toolResult,value:d.value}),f.value&&!y?/* @__PURE__ */ _(vu,{label:t.statusError,value:f.value,error:!0}):null]})}function vu({label:e,value:t,error:n}){let r=n?typeof t==`string`?t:``:xu(bu(t));return r?/* @__PURE__ */ v(`div`,{class:`${iu}-toolui-section`,children:[/* @__PURE__ */ _(`span`,{class:`${iu}-toolui-label`,children:e}),/* @__PURE__ */ _(`pre`,{class:`${iu}-toolui-code`,"data-error":n?`true`:void 0,children:r})]}):null}function yu(e){return!!xu(e.inputSig.value)||!!e.errorSig.value||!!xu(bu(e.outputSig.value))}function bu(e){if(e&&typeof e==`object`){let t=e;if(t.storage===`tool-result-ref`&&`summary`in t)return t.summary}return e}function xu(e){if(e==null)return``;try{let t=typeof e==`string`?e:JSON.stringify(e,null,2);return!t||t===`{}`||t===`[]`||t===`""`?``:t.length>800?`${t.slice(0,800)}…`:t}catch{return``}}function Su(e){return e.partsSig.value.some(e=>e.kind===`text`&&e.textSig.value.length>0)}function Cu(e){return e.partsSig.value.some(e=>e.kind===`reasoning`)}function wu(e){return e.streaming&&!e.bufferedHold&&!(e.reasoningVisible&&e.working)}function Tu(e){let{streaming:t,reasoningVisible:n,emptyReply:r,hidden:i}=e,a=e.responseMode===`buffered`&&t,o=t&&!e.hasAnswerText;return{streaming:t,bufferedHold:a,reasoningVisible:n,working:o,showStreamDots:wu({streaming:t,bufferedHold:a,reasoningVisible:n,working:o}),emptyReply:r,hidden:i}}function Eu(e,t){let n=e.stateSig.value,r=e.approvalSig.value,{terminal:i,responded:a,decided:o}=cu(n,r),s=t.continuationStreaming===!0&&!o,c=t.superseded&&!o&&!s;return{pill:du(n,r,{superseded:c,live:t.live,submitted:s,incomplete:Xl(e.toolMetadata)&&tu(e.errorSig.value),stopped:t.stopped}),state:n,terminal:i,decided:o||s,showApproveReject:!o&&!t.superseded&&!s,showAnswered:a&&!i&&!c,showSubmitted:s,showEdit:a&&t.active&&!i,skipped:c,answeredApproved:r?.approved}}const Du=N.cssPrefix;function Ou({part:e,strings:t}){let n=e.title||e.filename||e.url||t.sources;return e.url?/* @__PURE__ */ v(`a`,{class:`${Du}-source`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,"data-testid":J.source,children:[/* @__PURE__ */ _(`span`,{class:`${Du}-source-icon`,"aria-hidden":`true`,children:`🔗`}),/* @__PURE__ */ _(`span`,{class:`${Du}-source-label`,children:n})]}):/* @__PURE__ */ v(`span`,{class:`${Du}-source`,"data-testid":J.source,children:[/* @__PURE__ */ _(`span`,{class:`${Du}-source-icon`,"aria-hidden":`true`,children:`📄`}),/* @__PURE__ */ _(`span`,{class:`${Du}-source-label`,children:n})]})}const ku=N.cssPrefix;function Au(e){return!e||typeof e!=`object`||Array.isArray(e)?[]:Object.entries(e).flatMap(([e,t])=>typeof t==`string`?t.trim()?[{key:e,value:t.trim()}]:[]:typeof t==`number`||typeof t==`boolean`?[{key:e,value:String(t)}]:[]).slice(0,4)}function ju({part:e,strings:t,active:n,superseded:r=!1,continuationStreaming:a=!1,stopped:o=!1,onDecision:s,onEdit:c}){let l=p(()=>i(()=>e.approvalSig.value),[e]),u=p(()=>i(()=>Eu(e,{active:n,superseded:r,continuationStreaming:a,stopped:o})),[e,n,r,a,o]).value,{terminal:d,showApproveReject:f,showAnswered:m,showSubmitted:h,showEdit:y,skipped:b}=u,x=ou(e.toolName),S=u.answeredApproved,C=e.toolCallId,w=Au(e.inputSig.value),T=/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`p`,{class:`${ku}-toolui-prompt`,children:t.approvalPrompt.replace(`{tool}`,x)}),w.length>0?/* @__PURE__ */ _(`dl`,{class:`${ku}-toolui-fields`,"data-testid":J.toolApprovalFields,children:w.map(({key:e,value:t})=>/* @__PURE__ */ v(`div`,{children:[/* @__PURE__ */ _(`dt`,{children:e}),/* @__PURE__ */ _(`dd`,{title:t,children:t})]},e))}):null,/* @__PURE__ */ _(`p`,{class:`${ku}-toolui-subtle`,children:t.approvalBody})]});h?T=/* @__PURE__ */ _(`p`,{class:`${ku}-toolui-subtle`,children:t.approvalSubmitting}):m&&S!==!1?T=/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ v(`p`,{class:`${ku}-toolui-prompt`,children:[t.approvalYourResponse.replace(`{decision}`,S?t.approve:t.reject),l.value?.reason?` — ${l.value.reason}`:``]}),y?/* @__PURE__ */ _(`p`,{class:`${ku}-toolui-subtle`,children:t.approvalEditHint}):null,y?null:/* @__PURE__ */ _(`p`,{class:`${ku}-toolui-subtle`,children:t.approvalSubmitting})]}):m&&(T=/* @__PURE__ */ _(g,{}));let E=f||h||y||m&&S!==!1;return/* @__PURE__ */ v(`div`,{class:`${ku}-toolui-group`,"data-testid":u.decided?J.toolDecision:J.toolApproval,children:[/* @__PURE__ */ _(_u,{part:e,strings:t,superseded:b,submitted:h,stopped:o,open:f}),b||d||!E?null:/* @__PURE__ */ v(`div`,{class:`${ku}-toolui ${ku}-toolui-body`,children:[T,f?/* @__PURE__ */ v(`div`,{class:`${ku}-toolui-actions`,children:[/* @__PURE__ */ _(`button`,{type:`button`,class:`${ku}-form-skip`,disabled:!n,onClick:()=>s(C,!1),"data-testid":J.toolReject,children:t.reject}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${ku}-form-submit`,disabled:!n,onClick:()=>s(C,!0),"data-testid":J.toolApprove,children:t.approve})]}):null,y?/* @__PURE__ */ _(`div`,{class:`${ku}-toolui-actions`,children:/* @__PURE__ */ _(`button`,{type:`button`,class:`${ku}-form-skip`,onClick:()=>c(C),"data-testid":J.toolEdit,children:t.edit})}):null]})]})}const Mu=[`text`,`email`,`phone`,`number`,`date`,`single-select`,`multi-select`,`boolean`];function Nu(e){return typeof e==`object`&&!!e}function Pu(e){let t=Nu(e)?e:{},n=(Array.isArray(t.questions)?t.questions:[]).map(Fu).filter(e=>e!==null);return{intro:Ru(t.intro),questions:n}}function Fu(e,t){if(!Nu(e))return null;let n=Mu.find(t=>t===e.type)??`text`;return{key:Ru(e.key)??`q${t+1}`,question:Ru(e.question)??`Please provide the missing information.`,type:n,options:Array.isArray(e.options)?e.options.filter(e=>typeof e==`string`&&e.trim().length>0):void 0,required:typeof e.required==`boolean`?e.required:void 0,helpText:Ru(e.helpText)}}function Iu(e){switch(e){case`text`:return`textarea`;case`phone`:return`tel`;case`single-select`:case`boolean`:return`radio`;case`multi-select`:return`multiselect`;default:return e}}function Lu(e,t,n){return e.questions.map(e=>{let r=Iu(e.type),i=e.type===`boolean`?[{value:`yes`,label:t},{value:`no`,label:n}]:(e.options??[]).map(e=>({value:e,label:e}));return{name:e.key,label:e.question,type:r,required:e.required??!1,options:i.length>0?i:void 0,validationHint:e.helpText}})}function Ru(e){return typeof e==`string`&&e.trim()?e.trim():void 0}const zu=N.cssPrefix;function Bu({skipped:e,submitted:t,strings:n}){return e?{status:`superseded`,statusLabel:n.inputSkipped}:t?{status:`responded`,statusLabel:n.statusResponded}:{status:`completed`,statusLabel:n.inputAnswered}}const Vu={text:`qtypeText`,email:`qtypeEmail`,phone:`qtypePhone`,number:`qtypeNumber`,date:`qtypeDate`,"single-select":`qtypeChooseOne`,"multi-select":`qtypeChooseAny`,boolean:`qtypeBoolean`};function Hu(e,t){let n={};for(let r of e)n[r.key]=t[Vu[r.type]];return n}function Uu({part:e,strings:t,active:n,superseded:r=!1,continuationStreaming:a=!1,onDecision:o,onEdit:s}){let c=p(()=>i(()=>e.stateSig.value),[e]).value,l=p(()=>i(()=>e.approvalSig.value),[e]).value,u=p(()=>i(()=>Pu(e.inputSig.value)),[e]).value,{terminal:d,decided:f}=cu(c,l),m=f&&l?.approved===!0,g=a&&!f,y=!f&&!r&&!g,b=!y&&!m&&!g,x=m&&n&&!d,S=u.questions,[C,w]=h(null),T=C??(y||m||g),[E,D]=h(!1),O=S.length>1?Qa:ko,k=y?t.inputRequired:t.inputBadge,A=g?/* @__PURE__ */ _(`p`,{class:`${zu}-toolui-subtle`,children:t.approvalSubmitting}):y?/* @__PURE__ */ _(Wu,{req:u,strings:t,active:n,resolve:(t,n)=>o(e.toolCallId,n,t)}):E?/* @__PURE__ */ _(ol,{fields:Lu(u,t.confirmYes,t.confirmNo),strings:t,submitLabel:t.inputSubmit,onSubmit:()=>{},disabled:!0,hideActions:!0,fieldTypeLabels:Hu(S,t),initialValues:m?Xu(S,l?.reason):void 0}):/* @__PURE__ */ _(Gu,{questions:S,answers:m?Yu(l?.reason):{},strings:t}),{status:j,statusLabel:M}=Bu({skipped:b,submitted:g,strings:t});return/* @__PURE__ */ v(`details`,{class:`${zu}-toolui ${zu}-toolui-collapsible${r?` ${zu}-toolui-stale`:``}`,open:T,onToggle:e=>{let t=e.currentTarget.open;t!==T&&w(t)},"data-testid":y?J.toolAskQuestions:J.toolDecision,children:[/* @__PURE__ */ v(`summary`,{class:`${zu}-toolui-head`,children:[/* @__PURE__ */ v(`span`,{class:`${zu}-toolui-q-pill`,children:[/* @__PURE__ */ _(O,{}),k]}),/* @__PURE__ */ v(`span`,{class:`${zu}-toolui-head-end`,children:[y?null:/* @__PURE__ */ _(lu,{status:j,icon:_(b?Qo:Zo,{}),label:M}),/* @__PURE__ */ _(`span`,{class:`${zu}-toolui-chevron`,children:/* @__PURE__ */ _(To,{})})]})]}),/* @__PURE__ */ v(`div`,{class:`${zu}-toolui-collapse-body`,children:[u.intro?/* @__PURE__ */ _(`div`,{class:`${zu}-toolui-desc`,children:u.intro}):null,A,y||g?null:/* @__PURE__ */ v(`div`,{class:`${zu}-toolui-footer`,children:[/* @__PURE__ */ v(`button`,{type:`button`,class:`${zu}-toolui-options-toggle`,onClick:()=>D(e=>!e),"data-testid":J.toolAskOptions,children:[/* @__PURE__ */ _(`span`,{class:`${zu}-toolui-options-chevron${E?` ${zu}-open`:``}`,children:/* @__PURE__ */ _(To,{})}),E?t.hideOptions:t.showOptions]}),x?/* @__PURE__ */ _(`button`,{type:`button`,class:`${zu}-form-skip`,onClick:()=>s(e.toolCallId),"data-testid":J.toolEdit,children:t.edit}):null]})]})]})}function Wu({req:e,strings:t,active:n,resolve:r}){let i=Lu(e,t.confirmYes,t.confirmNo),a=e.questions.length===1&&e.questions[0]?.type===`text`;return/* @__PURE__ */ _(ol,{fields:i,strings:t,disabled:!n,submitLabel:t.inputSubmit,footerHint:a?t.inputSubmitHint:void 0,onSubmit:t=>r(qu(e.questions,t),!0),skipLabel:t.inputSkip,onSkip:()=>r(void 0,!1),submitOnEnter:a,fieldTypeLabels:Hu(e.questions,t),submitTestId:J.toolInputSubmit,skipTestId:J.toolInputSkip})}function Gu({questions:e,answers:t,strings:n}){return/* @__PURE__ */ _(`div`,{class:`${zu}-toolui-summary`,"data-testid":J.toolAskSummary,children:e.map(e=>/* @__PURE__ */ v(`div`,{class:`${zu}-field`,children:[/* @__PURE__ */ _(`span`,{class:`${zu}-field-head`,children:/* @__PURE__ */ v(`span`,{class:`${zu}-field-label`,children:[e.question,e.required?/* @__PURE__ */ _(`span`,{class:`${zu}-field-req`,"aria-hidden":`true`,children:` *`}):null]})}),/* @__PURE__ */ _(`p`,{class:`${zu}-toolui-answer`,children:Ku(e,t[e.key],n)||`—`})]},e.key))})}function Ku(e,t,n){return e.type===`boolean`?t===`yes`?n.confirmYes:t===`no`?n.confirmNo:t??``:t??``}function qu(e,t){let n=e.flatMap(e=>{let n=t[e.key];if(n==null||n.trim()===``)return[];let r=e.type===`multi-select`?n.split(`,`).map(e=>e.trim()).filter(Boolean):n;return[{key:e.key,value:r}]});return JSON.stringify({answers:n})}function Ju(e){if(!e)return{};let t=(()=>{try{return JSON.parse(e)}catch{return}})()?.answers;if(!Array.isArray(t))return{};let n={};for(let e of t)if(e&&typeof e==`object`&&`key`in e){let{key:t,value:r}=e;if(typeof t!=`string`)continue;typeof r==`string`?n[t]=r:Array.isArray(r)&&(n[t]=r.filter(e=>typeof e==`string`))}return n}function Yu(e){let t=Ju(e),n={};for(let[e,r]of Object.entries(t))n[e]=Array.isArray(r)?r.join(`, `):r;return n}function Xu(e,t){let n=Ju(t),r={};for(let t of e){let e=n[t.key];e!==void 0&&(t.type===`multi-select`?r[t.key]=Array.isArray(e)?e:[e]:r[t.key]=Array.isArray(e)?e[0]??``:e)}return r}function Zu({part:e,strings:t,live:n,superseded:r,stopped:a=!1}){let o=Xl(e.toolMetadata);if(!p(()=>i(()=>yu(e)),[e]).value&&!o)return null;let s=e.outputSig.value===void 0&&!e.errorSig.value;return/* @__PURE__ */ _(_u,{part:e,strings:t,testid:J.toolCall,live:n||o&&!r,incomplete:o&&r&&s,stopped:a})}const Z=N.cssPrefix;function Qu(e){if(e.kind!==`tool`)return!1;let t=e.stateSig.value;return t!==`approval-requested`&&t!==`approval-responded`&&!e.toolMetadata?.card&&!Xl(e.toolMetadata)}function $u(e,t){let n=[];for(let[r,i]of e.entries()){let e=n.at(-1);i.kind===`reasoning`&&t.showReasoning||Qu(i)&&yu(i)?e?.kind===`steps`?(e.parts.push(i),e.indices.push(r)):n.push({kind:`steps`,parts:[i],indices:[r]}):i.kind===`step-start`||i.kind===`reasoning`||i.kind===`source`&&!t.showSources||Qu(i)||n.push({kind:`part`,part:i,index:r})}return n}function ed(e){if(e&&typeof e==`object`)return Object.values(e).find(e=>typeof e==`string`&&e.trim().length>0)?.trim()}function td(e,t){let n=[...new Set(t)];if(e&&n.length!==0&&!n.some(t=>t<0||t>=e.length))return n.reduce((t,n)=>t+(e[n]?.durationMs??0),0)}function nd(e){let t=[];for(let n of e)t.push((t.at(-1)??-1)+ +(n.kind===`step-start`));return t}function rd(e,t){return e.streaming?t.thinking:e.reasoningMs===void 0?t.thought:t.thoughtFor.replace(`{time}`,id(e.reasoningMs))}function id(e){if(e<1e4)return`${Number((e/1e3).toFixed(1))} s`;let t=Math.round(e/1e3);return t<60?`${t} s`:`${Math.floor(t/60)} m ${t%60} s`}function ad(e){return e.split(`
|
|
32
32
|
`).map(e=>e.trim()).findLast(e=>/^\*\*[^*].*\*\*$/.test(e))?.slice(2,-2).trim()}function od(e,t){return e?.kind===`tool`?`${su(e.toolName)}…`:(e&&ad(e.textSig.value))??t.thinking}function sd(e,t){let n=e.map(e=>e.kind===`tool`?{kind:`tool`,part:e,name:ou(e.toolName),summary:ed(e.inputSig.value),status:du(e.stateSig.value,e.approvalSig.value,{live:t.live,stopped:t.stopped})}:{kind:`thought`,part:e}),r=n.flatMap(e=>e.kind===`tool`?[e]:[]),i=/* @__PURE__ */ new Map;for(let e of r)i.set(su(e.part.toolName),(i.get(su(e.part.toolName))??0)+1);let a=r.some(e=>e.status===`stopped`),[o]=r;return{tools:[...i].map(([e,t])=>({name:e,count:t})),...r.length===1&&o?{single:{name:su(o.part.toolName),...o.summary?{summary:o.summary}:{}}}:{},failed:r.filter(e=>e.status===`error`).length,...t.stopped&&a?{stopped:{finished:r.filter(e=>e.status!==`stopped`).length}}:{},rows:n}}function cd({parts:e,steps:t=[],stepTimings:n,timed:r=!0,strings:a,live:o,running:s,stopped:c=!1,runStartedAt:l}){let[u,d]=h(!1),[f,m]=h(!1),g=sd(e,{live:o,stopped:c}),y=e.at(-1),b=p(()=>i(()=>od(y,a)),[y,a]).value,x=r?td(n,t):void 0;function S(){d(!u),m(!0)}return/* @__PURE__ */ v(`div`,{class:`${Z}-steps`,"data-testid":J.toolSteps,"data-running":s?`true`:void 0,"data-stopped":g.stopped?`true`:void 0,children:[/* @__PURE__ */ v(`button`,{type:`button`,class:`${Z}-steps-head`,"aria-expanded":u,onClick:S,children:[/* @__PURE__ */ _(`span`,{class:`${Z}-steps-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(ud,{running:s,stopped:g.stopped!==void 0})}),/* @__PURE__ */ _(`span`,{class:`${Z}-steps-label`,children:s?/* @__PURE__ */ _(`span`,{class:`${Z}-steps-live`,children:b}):/* @__PURE__ */ _(fd,{view:g,strings:a})}),!s&&g.failed>0?/* @__PURE__ */ _(`span`,{class:`${Z}-steps-failed`,children:a.toolStepsFailed.replace(`{count}`,String(g.failed))}):null,s&&l?/* @__PURE__ */ _(ld,{since:l}):null,!s&&x!==void 0?/* @__PURE__ */ _(`span`,{class:`${Z}-steps-time`,children:id(x)}):null,/* @__PURE__ */ _(`span`,{class:`${Z}-steps-chevron`,"data-open":u?`true`:void 0,children:/* @__PURE__ */ _(To,{})})]}),/* @__PURE__ */ _(`span`,{class:`${Z}-sr-only`,role:`status`,children:s?b:``}),/* @__PURE__ */ _(`div`,{class:`${Z}-steps-body`,"data-open":u?`true`:void 0,inert:!u,children:/* @__PURE__ */ _(`div`,{class:`${Z}-steps-body-inner`,children:f?/* @__PURE__ */ _(`ol`,{class:`${Z}-steps-list`,children:g.rows.map((e,r)=>e.kind===`tool`?/* @__PURE__ */ _(pd,{row:e,strings:a},e.part.toolCallId):/* @__PURE__ */ _(hd,{part:e.part,current:s&&r===g.rows.length-1,reasoningMs:n?.[t[r]??-1]?.reasoningMs,strings:a},`${e.part.id}#${r}`))}):null})})]})}function ld({since:e}){let[t,n]=h(()=>Date.now());u(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]);let r=Math.max(0,Math.floor((t-Date.parse(e))/1e3));return/* @__PURE__ */ _(`span`,{class:`${Z}-steps-time`,children:r<60?`${r} s`:`${Math.floor(r/60)} m ${r%60} s`})}function ud({running:e,stopped:t}){return e?/* @__PURE__ */ _(`span`,{class:`${Z}-loading-spinner`}):_(t?ao:Yo,{})}function dd(e,t){return e===0?t.statusStopped:e===1?t.toolStepsStoppedOne:t.toolStepsStopped.replace(`{count}`,String(e))}function fd({view:e,strings:t}){return e.stopped?/* @__PURE__ */ _(g,{children:dd(e.stopped.finished,t)}):e.single?/* @__PURE__ */ v(g,{children:[e.single.name,e.single.summary?/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(`span`,{class:`${Z}-steps-sep`,"aria-hidden":`true`,children:`·`}),/* @__PURE__ */ _(`span`,{class:`${Z}-steps-summary`,children:e.single.summary})]}):null]}):/* @__PURE__ */ _(g,{children:e.tools.map(({name:e,count:t},n)=>/* @__PURE__ */ v(`span`,{class:`${Z}-steps-name`,children:[n>0?/* @__PURE__ */ _(`span`,{class:`${Z}-steps-sep`,"aria-hidden":`true`,children:`·`}):null,e,t>1?/* @__PURE__ */ v(`span`,{class:`${Z}-steps-count`,children:[`×`,t]}):null]},e))})}function pd({row:e,strings:t}){let[n,r]=h(!1),{part:i,name:a,summary:o,status:s}=e;return/* @__PURE__ */ v(`li`,{class:`${Z}-steps-row`,"data-testid":J.toolStep,"data-status":s,children:[/* @__PURE__ */ _(`span`,{class:`${Z}-steps-row-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(md,{status:s})}),/* @__PURE__ */ v(`div`,{class:`${Z}-steps-row-main`,children:[/* @__PURE__ */ v(`button`,{type:`button`,class:`${Z}-steps-row-head`,"aria-expanded":n,onClick:()=>r(!n),children:[/* @__PURE__ */ v(`span`,{class:`${Z}-steps-row-label`,children:[/* @__PURE__ */ _(`span`,{class:`${Z}-steps-row-name`,children:a}),o?/* @__PURE__ */ _(`span`,{class:`${Z}-steps-row-summary`,children:o}):null]}),s===`error`?/* @__PURE__ */ _(`span`,{class:`${Z}-steps-failed`,children:t.statusError}):null,s===`denied`?/* @__PURE__ */ _(`span`,{class:`${Z}-steps-denied`,children:t.statusDenied}):null,s===`stopped`?/* @__PURE__ */ _(`span`,{class:`${Z}-steps-denied`,children:t.statusStopped}):null,/* @__PURE__ */ _(`span`,{class:`${Z}-steps-chevron`,"data-open":n?`true`:void 0,children:/* @__PURE__ */ _(To,{})})]}),n?/* @__PURE__ */ v(`div`,{class:`${Z}-steps-row-body`,children:[/* @__PURE__ */ _(vu,{label:t.toolParameters,value:i.inputSig.value}),i.outputSig.value===void 0?null:/* @__PURE__ */ _(vu,{label:t.toolResult,value:i.outputSig.value}),i.errorSig.value?/* @__PURE__ */ _(vu,{label:t.statusError,value:i.errorSig.value,error:!0}):null]}):null]})]})}function md({status:e}){return e===`running`?/* @__PURE__ */ _(`span`,{class:`${Z}-loading-spinner`}):_(e===`stopped`?ao:e===`error`||e===`denied`?Qo:Zo,{})}function hd({part:e,current:t,reasoningMs:n,strings:r,standalone:a=!1}){let[o,s]=h(!1),c=p(()=>i(()=>e.textSig.value.trim()===``),[e]).value,l=p(()=>i(()=>e.textSig.value.length>200),[e]).value,u=rd({streaming:t,reasoningMs:n},r),f=d(),m=l&&!c,g=m&&!o,y=t?`${Z}-steps-thought-label ${Z}-steps-live`:`${Z}-steps-thought-label`;return/* @__PURE__ */ v(a?`div`:`li`,{class:`${Z}-steps-row ${Z}-steps-thought`,"data-status":`thought`,"data-testid":a?J.reasoning:void 0,children:[/* @__PURE__ */ _(`span`,{class:`${Z}-steps-row-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _($o,{})}),/* @__PURE__ */ v(`div`,{class:`${Z}-steps-row-main`,children:[m?/* @__PURE__ */ _(`button`,{type:`button`,class:`${y} ${Z}-steps-thought-toggle`,"aria-expanded":o,"aria-controls":f,onClick:()=>s(!o),children:u}):/* @__PURE__ */ _(`span`,{class:y,children:u}),c?null:/* @__PURE__ */ _(`div`,{id:f,class:`${Z}-steps-thought-text ${Z}-reasoning-body`,"data-clamped":g?`true`:void 0,onClick:g?()=>s(!0):void 0,children:/* @__PURE__ */ _(ms,{textSig:e.textSig,doneSig:e.doneSig})}),m?/* @__PURE__ */ v(`button`,{type:`button`,class:`${Z}-steps-thought-more`,"aria-expanded":o,"aria-controls":f,onClick:()=>s(!o),children:[o?r.thoughtsShowLess:r.thoughtsShowMore,/* @__PURE__ */ _(`span`,{class:`${Z}-steps-chevron`,"data-open":o?`true`:void 0,children:/* @__PURE__ */ _(To,{})})]}):null]})]})}const Q=N.cssPrefix,gd=b(_d);function _d({message:e,status:t,strings:n,responseMode:r,showReasoning:a,showToolCalls:o,showSources:s,interactive:c=!1,superseded:l=!1,tool:u,onRetry:d,enableMessageFeedback:f=!1,onFeedback:m,reconnecting:h=!1}){let g=[...p(()=>i(()=>e.partsSig.value),[e]).value];for(let t of e.attachments??[])t.url&&!g.some(e=>e.kind===`file`&&e.url===t.url)&&g.push({kind:`file`,url:t.url,mediaType:t.mediaType,filename:t.name,fileId:t.id,fileSize:t.size});let y=p(()=>i(()=>na(e)),[e,t,e.canceled]),b=p(()=>i(()=>Su(e)),[e]),x=p(()=>i(()=>a&&Cu(e)),[e,a]),S=p(()=>i(()=>ia(e,x.value)),[e,x,t,e.canceled]),C=p(()=>i(()=>!Pi(e)),[e]),w=t===`streaming`,T=e.role===`assistant`&&w,E=Tu({streaming:T,responseMode:r,reasoningVisible:x.value,hasAnswerText:b.value,emptyReply:y.value,hidden:S.value}),{bufferedHold:D,showStreamDots:O}=E;if(E.hidden)return null;let k=yd(e.createdAt),A=e.role===`assistant`||e.role===`operator`,j=f&&!!m&&!!e.serverMessageId&&A&&!w&&t!==`error`&&!y.value,M=w?``:g.filter(e=>e.kind===`text`).map(t=>e.role===`assistant`?ai(t.textSig.peek()):t.textSig.peek()).join(`
|
|
33
33
|
|
|
34
|
-
`).trim(),N=!w&&t!==`error`&&!y.value&&M.length>0,ee=o?$u(g,{showReasoning:a,showSources:s}):g.map((e,t)=>({kind:`part`,part:e,index:t})),te=nd(g),P=e.canceled===!0||t===`error`,ne=e.canceled===!0&&!w&&C.value&&x.value,re=ee.at(-1),F=re?.kind===`steps`?re.indices.at(-1):re?.index;function I(r,i){return/* @__PURE__ */ _(bd,{part:r,generativeUi:e.role===`assistant`,live:T,current:T&&i===F,reasoningMs:e.stepTimings?.[te[i]??-1]?.reasoningMs,strings:n,showReasoning:a,showToolCalls:o,showSources:s,interactive:c&&t===`complete`&&(r.kind!==`tool`||Vi(e,i)),superseded:l,continuationStreaming:e.continuationStreaming===!0,stopped:P,tool:u},`${Ed(r)}#${i}`)}let ie=j||N;return/* @__PURE__ */ _(`div`,{class:`${Q}-bubble-row`,"data-role":e.role,"data-testid":ns(J.messageBubble,e.serverMessageId??e.id),children:/* @__PURE__ */ v(`div`,{class:`${Q}-bubble-col`,children:[/* @__PURE__ */ v(`div`,{class:`${Q}-bubble`,children:[e.role===`operator`&&e.operatorInitials?/* @__PURE__ */ _(`span`,{class:`${Q}-bubble-author`,children:e.operatorInitials}):null,/* @__PURE__ */ v(`div`,{class:`${Q}-bubble-body`,children:[D?/* @__PURE__ */ _(Od,{label:n.loading}):ee.flatMap((t,r)=>t.kind===`part`?[I(t.part,t.index)]:t.parts.some(e=>e.kind===`tool`)?[/* @__PURE__ */ _(cd,{parts:t.parts,steps:t.indices.map(e=>te[e]??-1),stepTimings:e.stepTimings,timed:!P,strings:n,live:T,running:T&&r===ee.length-1,stopped:P&&r===ee.length-1,runStartedAt:e.runStartedAt},`steps#${t.indices[0]}`)]:t.parts.map((e,n)=>I(e,t.indices[n]??n))),ne?/* @__PURE__ */ v(`div`,{class:`${Q}-steps-row`,"data-status":`stopped`,"data-testid":J.replyStopped,children:[/* @__PURE__ */ _(`span`,{class:`${Q}-steps-row-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(ao,{})}),/* @__PURE__ */ _(`div`,{class:`${Q}-steps-row-main`,children:/* @__PURE__ */ _(`span`,{class:`${Q}-steps-stopped-label`,children:n.statusStopped})})]}):null,O&&!h&&/* @__PURE__ */ _(Dd,{}),t===`error`||y.value?/* @__PURE__ */ _(Td,{text:wd(e,t,n),retryLabel:n.errorRetry,onRetry:d?()=>d(e):void 0}):null,h&&T?/* @__PURE__ */ _(Td,{text:n.errorReconnecting}):null]})]}),k||ie?/* @__PURE__ */ v(`div`,{class:`${Q}-bubble-meta`,children:[k?/* @__PURE__ */ _(`time`,{class:`${Q}-bubble-time`,dateTime:k.iso,title:k.full,children:k.short}):null,ie?/* @__PURE__ */ v(`div`,{class:`${Q}-bubble-actions`,children:[j&&e.serverMessageId?/* @__PURE__ */ _(gl,{messageId:e.serverMessageId,initial:e.feedback??null,strings:n,onFeedback:m}):null,N?/* @__PURE__ */ _(vd,{text:M,strings:n}):null]}):null]}):null]})})}function vd({text:e,strings:t}){let[n,r]=h(!1);function i(){navigator.clipboard?.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)}).catch(()=>{})}let a=n?t.copied:t.copy;return/* @__PURE__ */ _(`button`,{type:`button`,class:`${Q}-msg-action`,"data-active":n?`true`:void 0,"aria-label":a,title:a,onClick:i,"data-testid":J.messageCopy,children:_(n?bo:Ko,{})})}function yd(e){if(typeof e!=`number`||!Number.isFinite(e))return null;try{let t=new Date(e);return{short:t.toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`}),full:t.toLocaleString(void 0,{dateStyle:`full`,timeStyle:`short`}),iso:t.toISOString()}}catch{return null}}function bd({part:e,generativeUi:t,live:n,current:r,reasoningMs:i,strings:a,showReasoning:o,showToolCalls:s,showSources:c,interactive:l,superseded:u,continuationStreaming:d,stopped:f,tool:p}){switch(e.kind){case`step-start`:return null;case`text`:return/* @__PURE__ */ _(ms,{textSig:e.textSig,doneSig:e.doneSig,generativeUi:t,strings:a});case`reasoning`:return o?/* @__PURE__ */ _(hd,{part:e,current:r,reasoningMs:i,strings:a,standalone:!0}):null;case`tool`:return/* @__PURE__ */ _(Cd,{part:e,strings:a,showToolCalls:s,interactive:l,superseded:u,continuationStreaming:d,live:n,stopped:f,tool:p});case`file`:return/* @__PURE__ */ _(xd,{part:e,strings:a});case`source`:return c?/* @__PURE__ */ _(Ou,{part:e,strings:a}):null}}function xd({part:e,strings:t}){let n=e.filename??t.file;if(e.mediaType.startsWith(`image/`))return/* @__PURE__ */ _(`a`,{class:`${Q}-file-image`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,title:n,"data-testid":J.messageFile,children:/* @__PURE__ */ _(`img`,{src:e.url,alt:n,loading:`lazy`})});let r=(n.includes(`.`)?n.split(`.`).pop():e.mediaType.split(`/`).pop())?.toUpperCase(),i=e.fileSize===void 0?void 0:Sd(e.fileSize);return/* @__PURE__ */ v(`a`,{class:`${Q}-file-chip`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,title:n,"data-testid":J.messageFile,children:[/* @__PURE__ */ _(`span`,{class:`${Q}-file-chip-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Eo,{})}),/* @__PURE__ */ v(`span`,{class:`${Q}-file-chip-text`,children:[/* @__PURE__ */ _(`span`,{class:`${Q}-file-chip-name`,children:n}),/* @__PURE__ */ _(`span`,{class:`${Q}-file-chip-meta`,children:[r,i].filter(Boolean).join(` · `)})]})]})}function Sd(e){let t=Math.min(Math.floor(Math.log10(Math.max(e,1))/3),2);return new Intl.NumberFormat(void 0,{style:`unit`,unit:[`byte`,`kilobyte`,`megabyte`][t],unitDisplay:`narrow`,maximumFractionDigits:1}).format(e/1e3**t)}function Cd({part:e,strings:t,showToolCalls:n,interactive:r,superseded:a,continuationStreaming:o,live:s,stopped:c,tool:l}){let u=p(()=>i(()=>e.approvalSig.value!==void 0),[e]),d=p(()=>i(()=>!Qu(e)),[e]);return!n&&!d.value?null:l?.humanInLoop&&u.value?e.toolMetadata?.card===`questions`?/* @__PURE__ */ _(Uu,{part:e,strings:t,active:r,superseded:a,continuationStreaming:o,onDecision:l.onDecision,onEdit:l.onEdit}):/* @__PURE__ */ _(ju,{part:e,strings:t,active:r,superseded:a,continuationStreaming:o,stopped:c,onDecision:l.onDecision,onEdit:l.onEdit}):n?/* @__PURE__ */ _(Zu,{part:e,strings:t,live:s,superseded:a,stopped:c}):null}function wd(e,t,n){return e.errorText?e.errorText:t===`error`&&e.role===`assistant`?n.errorServer:n.errorGeneric}function Td({text:e,retryLabel:t,onRetry:n}){return/* @__PURE__ */ v(`div`,{class:`${Q}-error`,role:`alert`,children:[/* @__PURE__ */ _(`span`,{class:`${Q}-error-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(es,{})}),/* @__PURE__ */ _(`span`,{class:`${Q}-error-text`,children:e}),n&&t?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Q}-error-retry`,onClick:n,"data-testid":J.messageRetry,children:t}):null]})}function Ed(e){switch(e.kind){case`text`:case`reasoning`:case`step-start`:return`${e.kind}:${e.id}`;case`tool`:return`tool:${e.toolCallId}`;case`file`:return`file:${e.url}`;case`source`:return`source:${e.sourceId}`}}function Dd(){return/* @__PURE__ */ v(`span`,{class:`${Q}-typing`,"data-testid":J.typingDots,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`span`,{}),/* @__PURE__ */ _(`span`,{}),/* @__PURE__ */ _(`span`,{})]})}function Od({label:e}){return/* @__PURE__ */ v(`span`,{class:`${Q}-loading`,role:`status`,children:[/* @__PURE__ */ _(`span`,{class:`${Q}-loading-spinner`,"aria-hidden":`true`}),/* @__PURE__ */ _(`span`,{class:`${Q}-loading-label`,children:e})]})}const kd=N.cssPrefix;function Ad({messagesSig:e,reconnectingSig:t,strings:n,responseMode:r,showReasoning:i,showToolCalls:a,showSources:o,enableMessageFeedback:c,onFeedback:l,loading:d,onLoadPreviousMessages:p,idle:g,controlMode:y=`ai-agent`,tool:b,onRetry:x,form:S,formMarkers:C,onFillForm:w}){let T=m(null),E=s(()=>e.value),[D,O]=h(!1),[k,A]=h(!1),j=m(!1),M=m(!1),[N,ee]=h(),te=m(!1),P=m(!1),ne=m(!1),re=m(0);function F(){return ne.current||performance.now()-re.current<350}let I=m(0);function ie(e){let t=e.scrollHeight-e.clientHeight>1;e.dataset.fadeTop=t&&e.scrollTop>1?`true`:`false`,e.dataset.fadeBottom=t&&e.scrollHeight-e.scrollTop-e.clientHeight>1?`true`:`false`}function ae(e){return O(e.scrollHeight-e.scrollTop-e.clientHeight>240)}function L(e){I.current=performance.now(),e.scrollTop=e.scrollHeight,ie(e)}function oe(e,t){L(e);let n=t,r=0;function i(){P.current||F()||(L(e),--n>0&&(r=requestAnimationFrame(i)))}return t>0&&(r=requestAnimationFrame(i)),()=>cancelAnimationFrame(r)}function se(e,t){let n,r,i,a=-1;function o(){n.disconnect(),r.disconnect(),clearTimeout(i)}function s(){if(P.current||F()||a>=0&&e.scrollTop<a-4)return o();L(e),a=e.scrollTop}return n=new ResizeObserver(s),r=new MutationObserver(s),s(),n.observe(e),r.observe(e,{childList:!0,subtree:!0,characterData:!0}),i=setTimeout(o,t),o}let ce=E.value[0]?.id;f(()=>{let e=T.current;if(e&&E.value.length!==0&&!M.current&&(te.current=!0,E.value.some(e=>e.role===`user`)))return se(e,300)},[ce]);let R=m(0);u(()=>{let e=T.current,t=E.value,n=R.current;if(R.current=t.length,e&&te.current&&!M.current){if(t.slice(n).some(e=>e.role===`user`))return P.current=!1,oe(e,3);t.some(e=>e.role===`user`)&&(P.current||F()||e.scrollHeight-e.scrollTop-e.clientHeight<120&&L(e))}},[E.value.length]);let le=m(null);u(()=>{let e=T.current,t=E.value.at(-1),n=le.current;if(le.current=t?{id:t.id,streaming:t.status===`streaming`}:null,e&&te.current&&t&&t.id===n?.id&&!n.streaming&&t.status===`streaming`)return P.current=!1,oe(e,3)},[E.value]),u(()=>{let e=T.current;if(!e)return;let t=E.value.at(-1);if(!t||t.status!==`streaming`&&!E.value.some(e=>e.role===`user`))return;let n=()=>{P.current||F()||e.scrollHeight-e.scrollTop-e.clientHeight<240&&L(e)};if(t.status!==`streaming`)return se(e,300);n();let r=new MutationObserver(n);return r.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>r.disconnect()},[E.value]);let ue=S?.form.id,de=!!S&&(C??[]).some(e=>e.formId===S.form.id);f(()=>{let e=T.current;e&&ue&&!P.current&&E.value.some(e=>e.role===`user`)&&(de?e.querySelector(`[data-testid="${J.formGate}"]`)?.scrollIntoView({block:`nearest`}):L(e))},[ue,de]),u(()=>{let e=T.current;if(!e)return;let t=()=>{ae(e),ie(e),performance.now()-I.current>150&&(P.current=e.scrollHeight-e.scrollTop-e.clientHeight>8)};function n(){P.current=!0}function r(e){e.deltaY<0&&n()}let i=0;function a(e){i=e.touches[0]?.clientY??0,ne.current=!0}function o(e){(e.touches[0]?.clientY??0)>i+4&&n()}function s(){ne.current=!1,re.current=performance.now()}function c(){ne.current=!0}return e.addEventListener(`scroll`,t,{passive:!0}),e.addEventListener(`wheel`,r,{passive:!0}),e.addEventListener(`touchstart`,a,{passive:!0}),e.addEventListener(`touchmove`,o,{passive:!0}),e.addEventListener(`touchend`,s,{passive:!0}),e.addEventListener(`touchcancel`,s,{passive:!0}),e.addEventListener(`pointerdown`,c,{passive:!0}),window.addEventListener(`pointerup`,s,{passive:!0}),window.addEventListener(`pointercancel`,s,{passive:!0}),ae(e),()=>{e.removeEventListener(`scroll`,t),e.removeEventListener(`wheel`,r),e.removeEventListener(`touchstart`,a),e.removeEventListener(`touchmove`,o),e.removeEventListener(`touchend`,s),e.removeEventListener(`touchcancel`,s),e.removeEventListener(`pointerdown`,c),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)}},[]);function fe(){let e=T.current;e&&(P.current=!1,L(e))}let pe=E.value.filter(e=>!e.ephemeral),me=pe[0],z=me?.serverMessageId??me?.id,he=!!(p&&pe.length>=50&&z!==N);async function ge(){if(!p||j.current)return;let e=T.current,t=e?.scrollHeight??0,n=e?.scrollTop??0;j.current=!0,M.current=!0,A(!0);try{let r=await p();r===!1&&z&&ee(z),r&&e&&(await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e()))),e.scrollTop=n+e.scrollHeight-t,ie(e),ae(e))}finally{M.current=!1,j.current=!1,A(!1)}}let _e=[],ve=``,ye=E.value.at(-1)?.id,be=t?.value===!0,xe=[...C??[]].toSorted((e,t)=>(e.createdAt??1/0)-(t.createdAt??1/0));function Se(e){return S&&e.formId===S.form.id?/* @__PURE__ */ _(pl,{form:S.form,strings:n,onSubmit:S.onSubmit,onSkip:S.onSkip},`gate:${e.formId}`):/* @__PURE__ */ _(ml,{marker:e,strings:n,onFill:!S&&w?()=>w(e.formId):void 0},e.key)}function Ce(e){for(let t=xe[0];t?.createdAt!==void 0&&!(e!==void 0&&t.createdAt>e);t=xe[0])xe.shift(),_e.push(Se(t))}for(let e of E.value){if(e.role===`assistant`&&e.id!==ye&&na(e))continue;Ce(e.createdAt);let t=jd(e.createdAt);t&&t!==ve&&(_e.push(/* @__PURE__ */ _(`div`,{class:`${kd}-date-divider`,children:/* @__PURE__ */ _(`span`,{class:`${kd}-date-pill`,title:Md(e.createdAt),children:Nd(e.createdAt,n)})},`day:${t}`)),ve=t);let s=e.retryAction!==void 0||e.role===`assistant`&&e.id===ye?ra(E.value,e):void 0,u=s!==void 0&&(s.kind!==`continue-assistant`||y===`ai-agent`);_e.push(/* @__PURE__ */ _(gd,{message:e,status:e.status,strings:n,responseMode:r,showReasoning:i,showToolCalls:a,showSources:o,interactive:!!g&&y===`ai-agent`&&e.id===ye,superseded:e.id!==ye,tool:b,onRetry:g&&u&&(e.role===`user`||e.id===ye)?x:void 0,enableMessageFeedback:c,onFeedback:l,reconnecting:be&&e.id===ye},e.id))}for(let e of xe)_e.push(Se(e));return/* @__PURE__ */ v(`div`,{class:`${kd}-list-wrap`,children:[/* @__PURE__ */ v(`div`,{ref:T,class:`${kd}-list ${kd}-list--fade`,part:`messages`,role:`log`,"aria-live":`polite`,"aria-relevant":`additions text`,children:[d&&E.value.length===0?/* @__PURE__ */ _(`div`,{class:`${kd}-list-loading`,role:`status`,children:n.conversationLoading}):null,he?/* @__PURE__ */ _(`div`,{class:`${kd}-load-previous`,children:/* @__PURE__ */ _(`button`,{type:`button`,onClick:ge,disabled:k,"aria-busy":k,"data-testid":J.loadPreviousMessages,children:n.loadPreviousMessages})}):null,_e,S&&!de?/* @__PURE__ */ _(pl,{form:S.form,strings:n,onSubmit:S.onSubmit,onSkip:S.onSkip}):null]}),D?/* @__PURE__ */ _(`button`,{type:`button`,class:`${kd}-jump`,onClick:fe,"aria-label":n.scrollToBottom,title:n.scrollToBottom,"data-testid":J.scrollToBottom,children:/* @__PURE__ */ _(To,{})}):null]})}function jd(e){if(typeof e!=`number`||!Number.isFinite(e))return``;let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function Md(e){if(typeof e!=`number`||!Number.isFinite(e))return``;try{return new Date(e).toLocaleDateString(void 0,{dateStyle:`full`})}catch{return``}}function Nd(e,t){let n=new Date(e);function r(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}let i=Math.round((r(/* @__PURE__ */ new Date)-r(n))/864e5);return i<=0?t.dateToday:i===1?t.dateYesterday:i<7?n.toLocaleDateString(void 0,{weekday:`long`}):n.toLocaleDateString(void 0,{month:`long`,day:`numeric`,year:`numeric`})}function Pd({panelEl:e,resize:t,position:n,initialSize:r,onSizeChange:i,strings:a}){let o=N.cssPrefix,s=m(null);if(u(()=>{if(!e)return;let n=e.style;t.minWidth&&n.setProperty(`--${o}-resize-min-w`,t.minWidth),t.maxWidth&&n.setProperty(`--${o}-resize-max-w`,t.maxWidth),t.minHeight&&n.setProperty(`--${o}-resize-min-h`,t.minHeight),t.maxHeight&&n.setProperty(`--${o}-resize-max-h`,t.maxHeight),r&&(n.setProperty(`--${o}-widget-w`,`${r.width}px`),n.setProperty(`--${o}-widget-h`,`${r.height}px`))},[e,t.minWidth,t.maxWidth,t.minHeight,t.maxHeight,o,r]),!e)return null;let c=n.startsWith(`top-`),l=n.endsWith(`-right`),d=`${o}-resize-grip ${o}-resize-grip--${c?`bottom`:`top`}-${l?`left`:`right`}`;function f(t){if(!e)return;let n=t.currentTarget,r=e.getBoundingClientRect();s.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startW:r.width,startH:r.height,dirX:l?-1:1,dirY:c?1:-1},n.setPointerCapture(t.pointerId),e.setAttribute(`data-resizing`,``),t.preventDefault()}function p(t){let n=s.current;if(!n||t.pointerId!==n.pointerId||!e)return;let r=(t.clientX-n.startX)*n.dirX,i=(t.clientY-n.startY)*n.dirY;e.style.setProperty(`--${o}-widget-w`,`${n.startW+r}px`),e.style.setProperty(`--${o}-widget-h`,`${n.startH+i}px`)}function h(t){let n=s.current;if(!n||t.pointerId!==n.pointerId||!e)return;t.currentTarget.releasePointerCapture(t.pointerId),e.removeAttribute(`data-resizing`);let r=e.getBoundingClientRect();i({width:Math.round(r.width),height:Math.round(r.height)}),s.current=null}return/* @__PURE__ */ _(`div`,{class:d,role:`separator`,"aria-orientation":`vertical`,"aria-label":a.resizeHandle,title:a.resizeHandle,onPointerDown:f,onPointerMove:p,onPointerUp:h,onPointerCancel:h,"data-testid":J.resizeGrip,children:/* @__PURE__ */ _(mo,{})})}const Fd=N.cssPrefix;function Id({suggestions:e,onPick:t,disabled:n=!1}){let r=m(null),[i,a]=h({start:!1,end:!1});return u(()=>{let e=r.current;if(!e)return;function t(){if(!e)return;let t=Math.abs(e.scrollLeft),n=t>1,r=t<e.scrollWidth-e.clientWidth-1;a(e=>e.start===n&&e.end===r?e:{start:n,end:r})}t(),e.addEventListener(`scroll`,t,{passive:!0});let n=typeof ResizeObserver>`u`?void 0:new ResizeObserver(t);return n?.observe(e),()=>{e.removeEventListener(`scroll`,t),n?.disconnect()}},[e]),e.length===0?null:/* @__PURE__ */ _(`div`,{ref:r,class:`${Fd}-suggestions`,role:`group`,"aria-label":`Suggested replies`,"data-cut-start":i.start?`true`:void 0,"data-cut-end":i.end?`true`:void 0,children:e.map((e,r)=>/* @__PURE__ */ _(`button`,{type:`button`,class:`${Fd}-suggestion`,onClick:()=>t(e),disabled:n,"data-testid":ns(J.suggestion,r),children:e.label},e.id))})}const Ld=N.cssPrefix,Rd=`.${Ld}-header, .${Ld}-back-header, .${Ld}-home-hero`;function zd(e,t){u(()=>{if(!t||!e)return;function n(e){return Number.parseFloat(e)||0}function r(e,t){return Math.min(t,Math.max(-t,e))}let i=null,a=t=>{let r=t.target;if(!(r instanceof Element)||!r.closest(Rd)||r.closest(`button, a, input, textarea, select, [role="tab"], [contenteditable]`))return;let a=e.getBoundingClientRect();i={id:t.pointerId,x:t.clientX,y:t.clientY,dx:n(e.style.getPropertyValue(`--${Ld}-modal-dx`)),dy:n(e.style.getPropertyValue(`--${Ld}-modal-dy`)),maxX:(window.innerWidth+a.width)/2-56,maxY:(window.innerHeight+a.height)/2-56},e.dataset.dragging=`true`,t.preventDefault()},o=t=>{if(!i||t.pointerId!==i.id)return;let n=r(i.dx+t.clientX-i.x,i.maxX),a=r(i.dy+t.clientY-i.y,i.maxY);e.style.setProperty(`--${Ld}-modal-dx`,`${n}px`),e.style.setProperty(`--${Ld}-modal-dy`,`${a}px`)},s=t=>{i&&t.pointerId===i.id&&(i=null,delete e.dataset.dragging)};return e.addEventListener(`pointerdown`,a),window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s),()=>{e.removeEventListener(`pointerdown`,a),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)}},[e,t])}function Bd({containerRef:e,onDrop:t,disabled:n=!1}){let[r,i]=h(!1);return u(()=>{if(n){i(!1);return}let r=e.current;if(!r)return;let a=0;function o(e){a+=1,e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),i(!0))}function s(){--a,!(a>0)&&(a=0,i(!1))}function c(e){e.dataTransfer?.types.includes(`Files`)&&e.preventDefault()}function l(e){a=0,i(!1),e.dataTransfer&&(e.preventDefault(),t(e.dataTransfer.items))}return r.addEventListener(`dragenter`,o),r.addEventListener(`dragleave`,s),r.addEventListener(`dragover`,c),r.addEventListener(`drop`,l),()=>{r.removeEventListener(`dragenter`,o),r.removeEventListener(`dragleave`,s),r.removeEventListener(`dragover`,c),r.removeEventListener(`drop`,l)}},[e,n,t]),{visible:!n&&r}}const Vd=N.cssPrefix;function Hd(e){let{options:t,onClose:n}=e,r=t.strings,i=m(null);u(()=>{let e=i.current;if(!e)return;let t=us(e);function r(e){e.key===`Escape`&&n?.()}return e.addEventListener(`keydown`,r),()=>{t(),e.removeEventListener(`keydown`,r)}},[n]);let a=e.composerApiRef,o=e.composerActive&&e.view===`chat`&&e.canSend&&!e.activeForm?.blocking&&!e.sendPreparing&&e.options.features.fileUpload,{visible:s}=Bd({containerRef:i,onDrop:l(e=>{o&&a.current?.attachFromDrop(e)},[a,o]),disabled:!o});return zd(i.current,t.mode===`modal`),/* @__PURE__ */ v(`div`,{ref:i,class:`${Vd}-panel`,part:`panel`,role:`dialog`,"aria-modal":`false`,"aria-label":r.panelTitle,style:{position:`relative`},"data-testid":J.panel,children:[/* @__PURE__ */ _(Ud,{...e,containerEl:i.current,dragOver:s}),/* @__PURE__ */ _(Yd,{poweredBy:e.options.poweredBy})]})}function Ud(e){let{options:t,transport:n,feedback:r,bus:i,persistence:a,conversationId:o,composerKey:c,panelSize:l,view:u,canSend:d,isStreaming:f,isMemoryCompacting:p,canReleaseQueuedMessages:m,queueManualMessages:h,sendPreparing:y,controlMode:b,assignedOperatorInitials:x,operatorAvailable:S,operatorRequestEnabled:C,onRequestOperator:w,onCancelOperatorRequest:T,loadingMessages:E,onLoadPreviousMessages:D,messagesSig:O,reconnectingSig:k,agent:A,suggestions:j,initialWidgetSize:M,onClose:N,onBack:ee,onClear:te,onToggleHistory:P,onSelectHistoryConversation:ne,onNewConversation:re,onWidgetSizeChange:F,onSend:I,onStop:ie,onSuggestion:ae,activeForm:L,formMarkers:oe,onFormSubmit:se,onFormSkip:ce,onFormFill:R,tool:le,onRetry:ue,onMessageFeedback:de,containerEl:fe,dragOver:pe,composerApiRef:me}=e,z=t.strings,he=s(()=>O.value.some(e=>!e.ephemeral&&e.role!==`system`)).value,ge;return ge=L?.blocking?null:d?/* @__PURE__ */ v(g,{children:[b&&b!==`ai-agent`?/* @__PURE__ */ _(Kd,{controlMode:b,operatorInitials:x,operatorAvailable:S,onCancelOperatorRequest:T,strings:z}):null,p&&b===`ai-agent`?/* @__PURE__ */ v(`div`,{class:`${Vd}-loading ${Vd}-compaction-status`,role:`status`,"data-testid":J.compactionStatus,children:[/* @__PURE__ */ _(`span`,{class:`${Vd}-loading-spinner`,"aria-hidden":`true`}),z.compactingContext]}):null,!f&&!p&&b===`ai-agent`&&/* @__PURE__ */ _(Id,{suggestions:j,onPick:ae,disabled:y}),/* @__PURE__ */ _(vc,{options:t,transport:n,feedback:r,bus:i,persistence:a,conversationId:o,isStreaming:f,pageToolRunning:e.pageToolRunning,isMemoryCompacting:p,canReleaseQueuedMessages:m,queueManualMessages:h,active:e.composerActive&&u===`chat`,isPreparing:y,operatorRequestEnabled:C,canRequestOperator:he,controlMode:b,onRequestOperator:w,onSend:I,onStop:ie,apiRef:me},c)]}):/* @__PURE__ */ _(Gd,{label:z.conversationClosed,ctaLabel:z.startNewConversation,onNewConversation:te}),/* @__PURE__ */ v(g,{children:[u===`history`?/* @__PURE__ */ _(Wd,{strings:z,onBack:P,onClose:N,showClose:Pa(t.mode,l,t.actions)}):/* @__PURE__ */ v(`header`,{class:`${Vd}-header`,part:`header`,"data-testid":J.panelHeader,children:[ee?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Vd}-icon-btn`,onClick:ee,"aria-label":z.moduleBack,title:z.moduleBack,children:/* @__PURE__ */ _(Co,{})}):null,A?/* @__PURE__ */ _(zc,{agent:A,strings:z}):/* @__PURE__ */ _(`h1`,{children:z.panelTitle}),/* @__PURE__ */ _(Ps,{panelProps:e,variant:`chat`})]}),u===`history`?/* @__PURE__ */ _(Jc,{transport:n,strings:z,locale:t.locale,persistence:a,onSelect:ne,onNewConversation:re}):/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(Xc,{visible:pe,strings:z}),/* @__PURE__ */ _(Ad,{messagesSig:O,reconnectingSig:k,strings:z,responseMode:t.responseMode,showReasoning:t.showReasoning,showToolCalls:t.showToolCalls,showSources:t.showSources,enableMessageFeedback:t.enableMessageFeedback,onFeedback:de,loading:E,onLoadPreviousMessages:D,idle:!f&&!y&&d&&!L?.blocking,controlMode:b,tool:le,onRetry:ue,form:L?{form:L,onSubmit:se,onSkip:ce}:null,formMarkers:oe,onFillForm:R}),ge,/* @__PURE__ */ _(Jd,{disclaimer:t.composerDisclaimer})]}),t.size.resize?.enabled?/* @__PURE__ */ _(Pd,{panelEl:fe,resize:t.size.resize,position:t.position,initialSize:M,onSizeChange:F,strings:z}):null]})}function Wd({strings:e,onBack:t,onClose:n,showClose:r}){return/* @__PURE__ */ v(`header`,{class:`${Vd}-header`,part:`header`,children:[/* @__PURE__ */ _(`button`,{type:`button`,class:`${Vd}-icon-btn`,onClick:t,"aria-label":e.historyBack,title:e.historyBack,children:/* @__PURE__ */ _(Co,{})}),/* @__PURE__ */ _(`h1`,{children:e.historyTitle}),r?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Vd}-icon-btn`,onClick:n,"aria-label":e.close,title:e.close,children:/* @__PURE__ */ _($a,{})}):null]})}function Gd({label:e,ctaLabel:t,onNewConversation:n}){return/* @__PURE__ */ v(`div`,{class:`${Vd}-readonly-banner`,role:`note`,children:[/* @__PURE__ */ _(`span`,{class:`${Vd}-readonly-label`,children:e}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${Vd}-readonly-cta`,onClick:n,children:t})]})}function Kd({controlMode:e,operatorInitials:t,operatorAvailable:n,onCancelOperatorRequest:r,strings:i}){let a=qd(e,t,n,i);return/* @__PURE__ */ v(`div`,{class:`${Vd}-operator-banner`,role:`status`,"data-mode":e,"data-testid":J.operatorBanner,children:[/* @__PURE__ */ _(`span`,{class:`${Vd}-operator-pulse`,"aria-hidden":`true`}),/* @__PURE__ */ _(`span`,{class:`${Vd}-operator-label`,children:a}),e===`awaiting-operator`&&r?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Vd}-cancel-operator-request`,"data-testid":J.cancelOperatorRequest,onClick:r,children:i.cancelOperatorRequest}):null]})}function qd(e,t,n,r){return e===`operator`?r.chattingWithOperator.replace(`{operator}`,t??``):n===!1?r.noOperatorAvailable:r.connectingOperator}function Jd({disclaimer:e}){return e?/* @__PURE__ */ _(`div`,{class:`${Vd}-composer-footer`,children:/* @__PURE__ */ _(`div`,{class:`${Vd}-disclaimer`,children:e})}):null}function Yd({poweredBy:e}){return e?/* @__PURE__ */ _(`div`,{class:`${Vd}-poweredby-bar`,children:/* @__PURE__ */ _(Xd,{logoUrl:e.logoUrl,text:e.text,href:e.href})}):null}function Xd({logoUrl:e,text:t,href:n}){let r=/* @__PURE__ */ v(g,{children:[e?/* @__PURE__ */ _(`img`,{class:`${Vd}-poweredby-logo`,src:e,alt:``,loading:`lazy`}):null,t?/* @__PURE__ */ _(`span`,{children:t}):null]});return n?/* @__PURE__ */ _(`a`,{class:`${Vd}-poweredby`,href:n,target:`_blank`,rel:`noopener noreferrer`,children:r}):/* @__PURE__ */ _(`span`,{class:`${Vd}-poweredby`,children:r})}const Zd=N.cssPrefix;function Qd({panelProps:e,enabledModules:t,nav:n,bus:r,hasUnread:i,latestNews:a,onSelectConversation:o,onStartNewConversation:c,onSetPanelSize:d}){let f=e.options,p=f.strings,h=m(null),g=m(/* @__PURE__ */ new Set);u(()=>{let t=h.current;if(!t)return;let n=us(t);function r(t){t.key===`Escape`&&e.onClose?.()}return t.addEventListener(`keydown`,r),()=>{n(),t.removeEventListener(`keydown`,r)}},[e.onClose]);let y=s(()=>n.sig.value).value,b=Ga(y),x=f.modules.byId[y.activeTab],S=e.composerActive&&x?.layout===`chat`&&b===void 0,C=e.composerApiRef,w=S&&e.view===`chat`&&e.canSend&&!e.activeForm?.blocking&&!e.sendPreparing&&e.options.features.fileUpload,{visible:T}=Bd({containerRef:h,onDrop:l(e=>{w&&C.current?.attachFromDrop(e)},[C,w]),disabled:!w});zd(h.current,f.mode===`modal`);let E=b?.kind===`iframe`||b?.kind===`content`,D=t.length>1&&(Ka(y)||!E),O=m(null);u(()=>{if(E&&O.current===null)O.current=e.panelSize,e.panelSize===`normal`&&d(`expanded`);else if(!E&&O.current!==null){let e=O.current;O.current=null,d(e)}},[E]);let k={push:e=>n.push(e),pop:()=>n.pop(),switchTab:e=>n.switchTab(e),switchToLayout:e=>{let r=t.find(t=>t.layout===e);r&&n.switchTab(r.id)},selectConversation:o,startNewConversation:c};function A(t){return{options:f,transport:e.transport,strings:p,config:t,nav:k,bus:r,panelProps:e,latestNews:a}}let j=/* @__PURE__ */ _(Ps,{panelProps:e,variant:`plain`});x&&g.current.add(x.id);let M=t.filter(e=>g.current.has(e.id));function N(t){if(t.layout===`chat`)return/* @__PURE__ */ _(Ud,{...e,composerActive:S,containerEl:h.current,dragOver:T});let n=Nc[t.layout].Root;return n?/* @__PURE__ */ _(n,{...A(t)}):null}function ee(){return b?.kind===`iframe`?/* @__PURE__ */ _(Lc,{url:b.url,title:b.title,strings:p,onBack:()=>n.pop(),actions:j}):b?.kind===`content`?/* @__PURE__ */ _(Ts,{id:b.id,title:b.title,transport:e.transport,strings:p,bus:r,onBack:()=>n.pop(),actions:j}):null}return/* @__PURE__ */ v(`div`,{ref:h,class:`${Zd}-panel ${Zd}-messenger`,part:`panel`,role:`dialog`,"aria-modal":`false`,"aria-label":p.panelTitle,style:{position:`relative`},"data-testid":J.messengerHome,children:[/* @__PURE__ */ v(`div`,{class:`${Zd}-messenger-body`,children:[M.map(e=>/* @__PURE__ */ _(`div`,{class:`${Zd}-messenger-pane`,hidden:E||e.id!==x?.id,children:N(e)},e.id)),ee()]}),D?/* @__PURE__ */ _(Fc,{modules:t,activeTab:y.activeTab,strings:p,hasUnread:i,onSelect:e=>n.switchTab(e)}):null,/* @__PURE__ */ _(Yd,{poweredBy:f.poweredBy}),f.size.resize?.enabled&&(x?.layout!==`chat`||b)?/* @__PURE__ */ _(Pd,{panelEl:h.current,resize:f.size.resize,position:f.position,initialSize:e.initialWidgetSize,onSizeChange:e.onWidgetSizeChange,strings:p}):null]})}const $d=N.cssPrefix;function ef({strings:e,onClose:t}){return/* @__PURE__ */ v(`div`,{class:`${$d}-panel ${$d}-modules-empty`,part:`panel`,role:`dialog`,"aria-label":e.panelTitle,"data-testid":J.modulesEmpty,children:[t?/* @__PURE__ */ _(`button`,{type:`button`,class:`${$d}-icon-btn ${$d}-modules-empty-close`,onClick:t,"aria-label":e.close,title:e.close,children:/* @__PURE__ */ _($a,{})}):null,/* @__PURE__ */ _(`p`,{class:`${$d}-modules-empty-text`,children:e.modulesEmpty})]})}function tf(e){let t=N.cssPrefix,{site:n,blocks:r,strings:i,collapsed:a}=e,o=r?.navigation??[],s=r?.linkCards??[],c=a?i.expandSidebar:i.collapseSidebar;return/* @__PURE__ */ v(`aside`,{class:`${t}-sidebar`,"data-collapsed":a?`true`:`false`,"data-testid":J.sidebar,children:[/* @__PURE__ */ v(`div`,{class:`${t}-sidebar-header`,children:[/* @__PURE__ */ _(nf,{site:n}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${t}-sidebar-toggle`,"aria-label":c,"aria-expanded":a?`false`:`true`,title:c,onClick:e.onToggleCollapsed,"data-testid":J.sidebarToggle,children:/* @__PURE__ */ _(rf,{collapsed:a})})]}),a?null:/* @__PURE__ */ v(g,{children:[o.length>0?/* @__PURE__ */ _(`nav`,{class:`${t}-sidebar-section`,"data-section":`navigation`,children:/* @__PURE__ */ _(af,{items:o})}):null,s.length>0?/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-section`,"data-section":`link-cards`,children:/* @__PURE__ */ _(of,{items:s})}):null,e.showConversations?/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-conversations`,children:/* @__PURE__ */ _(Jc,{transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,onSelect:e.onSelectConversation,onNewConversation:e.onNewConversation})}):null]})]})}function nf({site:e}){let t=N.cssPrefix;if(e?.logo?.url){let n=e.logo.alt??e.title??`Logo`;return/* @__PURE__ */ v(`picture`,{children:[e.logoDark?.url?/* @__PURE__ */ _(`source`,{srcset:e.logoDark.url,media:`(prefers-color-scheme: dark)`}):null,/* @__PURE__ */ _(`img`,{class:`${t}-sidebar-logo`,src:e.logo.url,alt:n})]})}return/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-title`,children:e?.title??N.name})}function rf({collapsed:e}){return/* @__PURE__ */ _(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"aria-hidden":`true`,children:e?/* @__PURE__ */ _(`polyline`,{points:`9 6 15 12 9 18`}):/* @__PURE__ */ _(`polyline`,{points:`15 6 9 12 15 18`})})}function af({items:e}){let t=N.cssPrefix;return/* @__PURE__ */ _(`ul`,{class:`${t}-sidebar-nav`,children:e.map(e=>/* @__PURE__ */ _(`li`,{children:/* @__PURE__ */ v(`a`,{class:`${t}-sidebar-nav-item`,href:e.href,target:e.href?`_blank`:void 0,rel:e.href?`noreferrer`:void 0,children:[e.icon?/* @__PURE__ */ _(`span`,{class:`${t}-sidebar-nav-icon`,"data-icon":e.icon}):null,/* @__PURE__ */ _(`span`,{class:`${t}-sidebar-nav-label`,children:e.label})]})},e.id??e.label))})}function of({items:e}){let t=N.cssPrefix;return/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-cards`,children:e.map(e=>/* @__PURE__ */ v(`a`,{class:`${t}-sidebar-card`,href:e.href,target:e.href?`_blank`:void 0,rel:e.href?`noreferrer`:void 0,children:[/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-card-label`,children:e.label}),e.description?/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-card-desc`,children:e.description}):null]},e.id??e.label))})}const sf=N.cssPrefix;function cf(e){return/* @__PURE__ */ v(`main`,{class:`${sf}-page-shell`,"data-sidebar-collapsed":e.sidebarCollapsed?`true`:`false`,children:[/* @__PURE__ */ _(tf,{site:e.site,blocks:e.blocks,transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,showConversations:e.showConversations,onSelectConversation:e.onSelectConversation,onNewConversation:e.onNewConversation,collapsed:e.sidebarCollapsed,onToggleCollapsed:e.onToggleSidebarCollapsed}),/* @__PURE__ */ _(`section`,{class:`${sf}-page-chat`,"aria-label":e.strings.panelTitle,children:e.children})]})}const lf=z.scope(`hitl`);function uf(e){return e.kind===`tool`&&Xl(e.toolMetadata)&&(e.stateSig.value===`input-available`||e.stateSig.value===`approval-responded`&&e.approvalSig.value?.approved===!0)}function df(e,t){t.errorSig.value=nu(t.toolCallId),t.stateSig.value=`output-error`,e.partsSig.value=[...e.partsSig.value]}function ff(e,t){let n=e.slice(0,e.indexOf(t)).findLast(e=>e.role===`user`);return n!==void 0&&Pl.sentHere(n.id)}function pf(e){let{streaming:t,controlModeSig:n,messagesSig:r,sendAiTurn:i,bus:a,humanInLoop:o,tools:s}=e,c=m(t);c.current=t;let d=m(s);d.current=s;let f=m(/* @__PURE__ */ new Map),[g,_]=h(!1),v=l((e,t,a)=>{if(c.current||n.value!==`ai-agent`)return!1;let o=r.value.at(-1),s=o?.partsSig.value.findIndex(t=>t.kind===`tool`&&t.toolCallId===e)??-1,l=o?.partsSig.value[s];if(!o||l?.kind!==`tool`)return lf.warn(`decideTool: tool part not found`,{toolCallId:e}),!1;if(o.status!==`complete`||!Vi(o,s)||!t(l))return!1;if(a(l),o.partsSig.value=[...o.partsSig.value],!zi(o)||o.partsSig.value.some(uf))return!0;o.status=`streaming`,o.retryAction={kind:`continue-assistant`,messageId:o.serverMessageId??o.id},o.awaitingContinuation=!0,r.value=[...r.value];let u=o.partsSig.value.flatMap(e=>e.kind===`tool`?[e.toolCallId]:[]);return i({continueExisting:!0}).then(e=>e&&Pl.clear(u)),!0},[n,r,i]),y=l((e,t)=>{let{toolCallId:n,toolName:r}=t;f.current.has(n)||(f.current.set(n,e),_(!0),eu({toolCallId:n,toolName:r,input:t.inputSig.value,optionTools:d.current??[],onSettled:(e,t)=>{lf.info(`toolResult`,{toolCallId:n,status:e}),a.emit(`toolResult`,{toolCallId:n,name:Zl(r),status:e,durationMs:t})}}).then(e=>{f.current.delete(n)&&(_(f.current.size>0),v(n,uf,t=>{e.state===`output-available`?t.outputSig.value=e.output:t.errorSig.value=e.errorText,t.stateSig.value=e.state}))}))},[a,v]),b=l(()=>{let e=r.value;for(let[t,n]of f.current){let r=e.findIndex(e=>e.id===n);r<0||r===e.length-1||(f.current.delete(t),ru(t),_(f.current.size>0))}let t=e.at(-1);if(c.current||t?.role!==`assistant`||t.status!==`complete`)return;let n=t.partsSig.value.filter(e=>uf(e)&&e.stateSig.value===`input-available`);if(n.length!==0&&ff(e,t))for(let e of n)Pl.get(e.toolCallId)?.state===`stopped`?df(t,e):y(t.id,e)},[r,y]);u(()=>b(),[t,b]),u(()=>r.subscribe(()=>b()),[r,b]);let x=l((e,t,n)=>{let i=!1,o;if(!v(e,e=>e.stateSig.value===`approval-requested`,r=>{Xl(r.toolMetadata)&&(o=r),i=r.toolMetadata?.card===`questions`;let a=r.approvalSig.value?.id??e;r.approvalSig.value={id:a,approved:t,reason:n},r.stateSig.value=`approval-responded`}))return;let s=r.value.at(-1);o&&t&&s&&y(s.id,o),o&&!t&&a.emit(`toolResult`,{toolCallId:e,name:Zl(o.toolName),status:`declined`,durationMs:0}),i?(lf.info(`toolResult`,{toolCallId:e}),a.emit(`toolResult`,{toolCallId:e})):(lf.info(`toolDecision`,{toolCallId:e,approved:t}),a.emit(`toolDecision`,{toolCallId:e,approved:t}))},[a,v,r,y]),S=l(e=>{v(e,e=>e.stateSig.value===`approval-responded`&&e.approvalSig.value?.approved!==void 0&&!uf(e),t=>{let n=t.approvalSig.value?.id??e;t.approvalSig.value={id:n},t.stateSig.value=`approval-requested`})},[v]);return{toolInteraction:p(()=>({humanInLoop:o,onDecision:x,onEdit:S}),[o,x,S]),pageToolsRunning:g,stopPageTools:l(()=>{let e=r.value.at(-1);for(let t of f.current.keys()){let n=e?.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t);e&&n?df(e,n):nu(t),lf.info(`toolResult`,{toolCallId:t,status:`stopped`}),a.emit(`toolResult`,{toolCallId:t,name:n?Zl(n.toolName):void 0,status:`stopped`,durationMs:0})}f.current.clear(),_(!1)},[a,r])}}const mf=z.scope(`latest-news`);function hf({transport:e,options:t,persistence:n,enabled:r}){let i=t.modules.list.find(e=>e.layout===`news`)?.contentCollectionIds,a=i?.join(`,`),[o,s]=h(),[c,d]=h(()=>n.loadSeenNewsId());u(()=>{if(!r||!i?.length)return;let t=!1;return e.listContent({contentCollectionIds:i,sortBy:`publishedAt`,sortOrder:`desc`,limit:1}).then(e=>{t||s(e.items[0])}).catch(e=>mf.debug(`listContent (latest news) failed (non-fatal)`,{err:e})),()=>{t=!0}},[e,r,a]);let f=l(e=>{n.saveSeenNewsId(e),d(e)},[n]);return{item:o,unseen:o!==void 0&&o.id!==c,markSeen:f}}function gf({callout:e,persistence:t}){let n=e?.text??``,r=e?.persistent??!0,[i,a]=h(()=>!r&&t.loadCalloutDismissed(n));return u(()=>{a(!r&&t.loadCalloutDismissed(n))},[n,r,t]),{dismissed:i,dismissCallout:l(()=>{a(!0),r||t.saveCalloutDismissed(n)},[t,n,r])}}function _f(e){let{transport:t,conversationIdSig:n}=e,r=c(`ai-agent`),i=c(void 0),a=c(void 0),o=m(void 0),s=l(e=>{let t=e.controlRevision,s=o.current;s&&s.conversationId===n.value&&t<s.revision||(o.current={conversationId:n.value,revision:t},r.value=e.controlMode,i.value=e.assignedOperatorInitials,e.controlMode===`awaiting-operator`?e.operatorAvailable!==void 0&&(a.value=e.operatorAvailable):a.value=void 0)},[n,r,i,a]);return{controlModeSig:r,assignedOperatorInitialsSig:i,operatorAvailableSig:a,applyControlState:s,adoptControlStateChunk:l(e=>{if(e.type!==`data-control-state`)return;let t=fi(e.data);t&&s(t)},[s]),requestOperator:l(async()=>{let e=n.value,r=await t.requestOperator();r&&n.value===e&&s(r)},[t,n,s]),cancelOperatorRequest:l(async()=>{let e=n.value,r=await t.cancelOperatorRequest();r&&n.value===e&&s(r)},[t,n,s])}}const vf=N.cssPrefix,yf=`--${vf}-visual-viewport-height`,bf=`--${vf}-visual-viewport-top`;function xf(e){let{hostElement:t,mode:n,panelSize:r,isOpen:i,surfaceReady:a,setIsOpen:o}=e;f(()=>{Ut(t,qa(n,r,i))},[t,i,r,n]),f(()=>{if(!i||!a)return;let e=t.ownerDocument.defaultView,n=e?.visualViewport,r=t.shadowRoot?.querySelector(`.${vf}-anchor`);if(!e||!n||!r)return;let o=()=>{r.style.setProperty(yf,`${n.height}px`),r.style.setProperty(bf,`${n.offsetTop}px`)},s=0,c=()=>{e.cancelAnimationFrame(s),s=e.requestAnimationFrame(()=>{s=e.requestAnimationFrame(o)})};return o(),n.addEventListener(`resize`,c),n.addEventListener(`scroll`,c),()=>{e.cancelAnimationFrame(s),n.removeEventListener(`resize`,c),n.removeEventListener(`scroll`,c),r.style.removeProperty(yf),r.style.removeProperty(bf)}},[t,i,a]),u(()=>{if(n!==`modal`||!i)return;function e(e){e.composedPath().some(e=>e instanceof HTMLElement&&e.classList.contains(`${vf}-panel`))||o(!1)}return t.addEventListener(`click`,e),()=>t.removeEventListener(`click`,e)},[t,i,n,o]),u(()=>{if(n!==`drawer`||!i)return;function e(e){e.key===`Escape`&&o(!1)}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,n,o])}const Sf=z.scope(`reducer`);var Cf=class{constructor(e,t){this.messagesSig=e,this.onReconcileNeeded=t,V(this,`active`,null),V(this,`openTextParts`,/* @__PURE__ */ new Map),V(this,`partSeq`,0),V(this,`replay`,null)}attach(e){this.active=e,this.openTextParts.clear()}detach(){this.active=null,this.replay=null,this.openTextParts.clear()}beginReplay(e,t){let n=yi();n.id=e.id;let r=Tf(e)||Bi(e)&&(e.status!==`streaming`||zi(e)),i=e.status===`streaming`&&zi(e)&&Ri(e);this.replay={baseline:e,shadow:n,chunks:[t],probeContinuation:r,continuationTailReplay:i,liveCatchUp:e.status===`streaming`&&!r},this.attach(n),this.apply(t)}refreshReplayBaseline(){let e=this.replay;if(!e)return null;let t=e.shadow.serverMessageId??e.baseline.serverMessageId,n=this.messagesSig.value,r=n.at(-1),i=r===e.baseline||r?.id===e.baseline.id||t!==void 0&&r?.serverMessageId===t?r:n.find(t=>t===e.baseline)??n.find(n=>n.id===e.baseline.id||t!==void 0&&n.serverMessageId===t);if(!i)return this.detach(),null;if(i===e.baseline)return e;let a=e.baseline;return e.baseline=i,Ef(a,i),e.liveCatchUp&&Tf(e.shadow)&&(i.status===`streaming`||Bi(i))?(e.probeContinuation=!1,e.continuationTailReplay=!1,e):(e.probeContinuation=Tf(i)||Bi(i)&&(i.status!==`streaming`||zi(i)),e.continuationTailReplay=i.status===`streaming`&&zi(i)&&Ri(i),e.liveCatchUp=i.status===`streaming`&&!e.probeContinuation,e)}refreshActive(){let e=this.active;if(!e)return null;let t=e.serverMessageId,n=this.messagesSig.value,r=n.at(-1),i=r===e||r?.id===e.id||t!==void 0&&r?.serverMessageId===t?r:n.find(t=>t===e)??n.find(n=>n.id===e.id||t!==void 0&&n.serverMessageId===t);if(!i)return this.detach(),null;if(i===e)return e;Ef(e,i);let a=Tf(e)&&Bi(i);return i.status!==`streaming`&&!a?(this.detach(),null):(this.replay={baseline:i,shadow:e,chunks:[],probeContinuation:!1,continuationTailReplay:!1,liveCatchUp:!0},e)}promoteReplay(){let{baseline:e,shadow:t}=this.replay;return r(()=>{e.role=t.role,e.serverMessageId=t.serverMessageId,e.operatorInitials=t.operatorInitials,e.status=t.status,t.canceled&&(e.canceled=!0),e.finishReason=t.finishReason,e.errorText=t.errorText,e.suggestions=t.suggestions??e.suggestions,e.runStartedAt=t.runStartedAt??e.runStartedAt,e.stepTimings=t.stepTimings??e.stepTimings,e.partsSig.value=t.partsSig.value,this.messagesSig.value=[...this.messagesSig.value]}),this.replay=null,this.active=e,e}promoteContinuation(){let{baseline:e,chunks:t}=this.replay,n=Hi(e);return this.replay=null,r(()=>{e.partsSig.value=e.partsSig.value.slice(0,Df(e,t)+1),e.awaitingContinuation=!1,e.status=`streaming`,e.finishReason=void 0,e.errorText=void 0,e.suggestions=void 0,this.attach(e);for(let e of t)this.apply(e);e.continuationStreaming=n||void 0,this.messagesSig.value=[...this.messagesSig.value]}),e}settleOwnedContinuation(e){let{baseline:t}=this.replay,n=Hi(t);return this.replay=null,r(()=>{t.awaitingContinuation=!1,t.status=`streaming`,t.finishReason=void 0,t.errorText=void 0,t.suggestions=void 0,this.attach(t),this.apply(e),t.continuationStreaming=n||void 0,this.messagesSig.value=[...this.messagesSig.value]}),t}applyResume(e){if(e.type===`start`){let t=(this.replay?.baseline??this.active)?.serverMessageId;t!==void 0&&e.messageId!==void 0&&t!==e.messageId&&this.onReconcileNeeded?.({messageId:t}),this.detach();let n=e.messageId,r=n===void 0?void 0:this.messagesSig.value.find(e=>e.serverMessageId===n||e.id===n);if(r!==void 0)return e.messageMetadata?.senderRole===`visitor`&&r.role===`user`&&(r.status===`pending`||r.status===`error`)&&(r.serverMessageId=n,r.status=`complete`,r.errorText=void 0,r.retryAction=void 0,this.messagesSig.value=[...this.messagesSig.value]),this.beginReplay(r,e),null;let i=e.messageMetadata?.senderRole,a=this.messagesSig.value.at(-1);if(i===void 0&&a?.role===`assistant`&&a.status===`streaming`&&a.serverMessageId===void 0&&!Ni(a))return this.attach(a),this.apply(e),null;let o=yi();return this.attach(o),this.messagesSig.value=[...this.messagesSig.value,o],this.apply(e),null}if(this.replay){let t=this.refreshReplayBaseline();if(!t)return null;t.chunks.push(e),e.type===`data-control-state`&&(t.baseline.operatorRoutedTurn=e.data.controlMode!==`ai-agent`),this.apply(e);let{baseline:n,shadow:r,probeContinuation:i,continuationTailReplay:a,liveCatchUp:o}=t,s=e.type===`finish`||e.type===`error`||e.type===`abort`;if(i){if(!jf(n,r,e)){if(s){if(n.status===`streaming`&&n.awaitingContinuation!==!0){let t=this.settleOwnedContinuation(e);return this.detach(),t}Ff(n,r)&&(n.continuationStreaming=!0,this.messagesSig.value=[...this.messagesSig.value],this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id})),this.detach()}return null}let t=Tf(n)&&s?this.settleOwnedContinuation(e):this.promoteContinuation();return s?(t.continuationStreaming&&(e.type===`finish`?this.onReconcileNeeded?.({messageId:t.serverMessageId??t.id}):t.continuationStreaming=!1),this.detach(),t):null}if(a&&kf(n,r)){let e=this.promoteContinuation();return s?(this.detach(),e):null}if(!o)return s&&this.detach(),null;if(s&&!Ni(n)&&Ni(r)){let e=this.promoteReplay();return this.detach(),e}if(!Of(n,r))return s&&(this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id}),this.detach()),null;let c=this.promoteReplay();return s?(this.detach(),c):null}let t=this.refreshActive();if(!t)return null;if(this.replay)return this.applyResume(e);if(this.apply(e),e.type===`finish`||e.type===`error`||e.type===`abort`){let n=t;return n.continuationStreaming&&(e.type===`finish`?this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id}):n.continuationStreaming=!1),this.detach(),n}return null}ensureTextPart(e,t,n){let r=`${t}:${n}`,i=this.openTextParts.get(r);if(i)return i;let a={kind:t,id:`${n}#${this.partSeq++}`,textSig:o(``),doneSig:o(!1)};return this.openTextParts.set(r,a),Lf(e,a),a}apply(e){let t=this.active;if(t)switch(e.type){case`start`:{e.messageId&&(t.serverMessageId=e.messageId);let n=e.messageMetadata;n?.runStartedAt&&(t.runStartedAt=n.runStartedAt),n?.senderRole===`operator`?(t.role=`operator`,n.operatorInitials&&(t.operatorInitials=n.operatorInitials)):n?.senderRole===`visitor`&&(t.role=`user`);return}case`finish-step`:this.openTextParts.clear();return;case`start-step`:Lf(t,{kind:`step-start`,id:`ss-${this.partSeq++}`});return;case`message-metadata`:t.stepTimings=wi(e.messageMetadata?.steps)??t.stepTimings;return;case`finish`:Sf.debug(`finish`,{reason:e.finishReason,canContinue:e.canContinue}),t.stepTimings=wi(e.messageMetadata?.steps)??t.stepTimings,t.status=`complete`,t.retryAction=void 0,e.finishReason&&(t.finishReason=e.finishReason),this.bumpDone(t);return;case`error`:Sf.warn(`stream error chunk`,{errorText:e.errorText}),t.status=`error`,t.errorText=void 0,this.bumpDone(t);return;case`abort`:Sf.debug(`stream abort chunk (canceled)`),t.status=`complete`,t.canceled=!0,t.retryAction=void 0,this.bumpDone(t);return;case`text-start`:this.ensureTextPart(t,`text`,e.id);return;case`text-delta`:{let n=this.ensureTextPart(t,`text`,e.id);n.textSig.value+=e.delta;return}case`text-end`:this.ensureTextPart(t,`text`,e.id).doneSig.value=!0;return;case`reasoning-start`:this.ensureTextPart(t,`reasoning`,e.id).doneSig.value=!1;return;case`reasoning-delta`:{let n=this.ensureTextPart(t,`reasoning`,e.id);n.textSig.value+=e.delta;return}case`reasoning-end`:this.ensureTextPart(t,`reasoning`,e.id).doneSig.value=!0;return;case`tool-input-start`:case`tool-input-delta`:case`tool-input-available`:case`tool-input-error`:case`tool-output-available`:case`tool-output-error`:case`tool-output-denied`:case`tool-approval-request`:zf(t,e);return;case`file`:Lf(t,{kind:`file`,url:e.url,mediaType:e.mediaType});return;case`source-url`:Rf(t,{kind:`source`,sourceId:e.sourceId,url:e.url,title:e.title});return;case`source-document`:Rf(t,{kind:`source`,sourceId:e.sourceId,title:e.title,filename:e.filename,mediaType:e.mediaType});return;case`data-suggestions`:t.suggestions=mi(e.data);return;case`data-control-state`:t.operatorRoutedTurn=e.data.controlMode!==`ai-agent`;return;case`data-memory-compaction-state`:return}}bumpDone(e){r(()=>{e.partsSig.value=[...e.partsSig.value],this.messagesSig.value.includes(e)&&(this.messagesSig.value=[...this.messagesSig.value])})}};const wf={"input-streaming":0,"input-available":1,"approval-requested":2,"approval-responded":3,"output-available":4,"output-denied":4,"output-error":4};function Tf(e){return e.awaitingContinuation===!0||e.continuationStreaming===!0||e.retryAction?.kind===`continue-assistant`}function Ef(e,t){e.canceled&&(t.canceled=!0),Tf(e)&&(t.status===`streaming`||Bi(t))&&(t.awaitingContinuation??(t.awaitingContinuation=e.awaitingContinuation),t.continuationStreaming??(t.continuationStreaming=e.continuationStreaming),t.retryAction===void 0&&(t.retryAction=e.retryAction))}function Df(e,t){let n=e.partsSig.value,r=t.findIndex(e=>e.type===`start-step`),i=new Set(t.slice(0,r<0?t.length:r).flatMap(e=>`toolCallId`in e&&e.type.startsWith(`tool-output`)?[e.toolCallId]:[])),a=n.findLastIndex(e=>e.kind===`tool`&&(e.stateSig.value===`approval-requested`||e.stateSig.value===`approval-responded`||i.has(e.toolCallId)));if(a>=0)return a;let o=new Set(t.flatMap(e=>e.type===`tool-input-start`||e.type===`tool-input-available`?[e.toolCallId]:[]));return n.some(e=>e.kind===`tool`&&o.has(e.toolCallId))?-1:n.findLastIndex(e=>e.kind===`tool`)}function Of(e,t){let n=e.partsSig.value,r=t.partsSig.value;return e.role!==t.role||r.length<n.length?!1:n.every((e,t)=>Af(e,r[t]))}function kf(e,t){let n=e.partsSig.value,r=n.findLastIndex(e=>e.kind===`tool`),i=new Set(n.slice(0,r+1).flatMap(e=>e.kind===`tool`?[e.toolCallId]:[])),a=t.partsSig.value.filter(e=>e.kind!==`tool`||!i.has(e.toolCallId)),o=n.slice(r+1);return a.length<o.length?!1:o.every((e,t)=>Af(e,a[t]))}function Af(e,t){switch(e.kind){case`text`:case`reasoning`:return t?.kind===e.kind&&t.textSig.value.startsWith(e.textSig.value);case`step-start`:return t?.kind===`step-start`;case`tool`:{if(t?.kind!==`tool`||t.toolCallId!==e.toolCallId||!$i(t.toolName,e.toolName)||wf[t.stateSig.value]<wf[e.stateSig.value])return!1;let n=e.approvalSig.value?.approved;return n===void 0||t.approvalSig.value?.approved===n}case`file`:return t?.kind===`file`&&t.url===e.url&&t.mediaType===e.mediaType;case`source`:return t?.kind===`source`&&t.sourceId===e.sourceId&&t.url===e.url&&t.title===e.title&&t.filename===e.filename&&t.mediaType===e.mediaType;default:return e}}function jf(e,t,n){return Mf(e,n)||!Nf(e,t)?!0:n.type!==`finish`&&n.type!==`error`&&n.type!==`abort`?!1:Ri(t)||e.awaitingContinuation===!0&&n.type!==`finish`?!0:e.awaitingContinuation===!0&&t.partsSig.value.every(e=>e.kind===`step-start`)}function Mf(e,t){if(t.type!==`tool-output-available`&&t.type!==`tool-output-error`&&t.type!==`tool-output-denied`)return!1;let n=e.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t.toolCallId);return n!==void 0&&wf[n.stateSig.value]<4}function Nf(e,t){let n=t.partsSig.value;if(n.length===0)return!0;let r=e.partsSig.value;return r.some((e,t)=>n.every((e,n)=>Pf(r[t+n],e)))}function Pf(e,t){switch(t.kind){case`text`:case`reasoning`:return e?.kind===t.kind&&e.textSig.value.startsWith(t.textSig.value);case`step-start`:return e?.kind===`step-start`;case`tool`:return e?.kind===`tool`&&e.toolCallId===t.toolCallId&&(t.toolName===`tool`||$i(e.toolName,t.toolName));case`file`:return e?.kind===`file`&&e.url===t.url&&e.mediaType===t.mediaType;case`source`:return e?.kind===`source`&&e.sourceId===t.sourceId&&e.url===t.url&&e.title===t.title&&e.filename===t.filename&&e.mediaType===t.mediaType;default:return t}}function Ff(e,t){if(Tf(e)||!Bi(e))return!1;let n=new Set(e.partsSig.value.filter(e=>e.kind===`tool`).map(e=>e.toolCallId));return!t.partsSig.value.some(e=>e.kind===`tool`&&n.has(e.toolCallId))}function If(e,t,n,r,i){let a=e.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t);if(a)return r&&(a.dynamic=!0),a.toolMetadata??(a.toolMetadata=i),a;let s={kind:`tool`,toolCallId:t,toolName:n??`tool`,dynamic:r?!0:void 0,toolMetadata:i,inputPartialSig:o(``),inputSig:o(void 0),outputSig:o(void 0),errorSig:o(void 0),stateSig:o(`input-streaming`),approvalSig:o(void 0)};return Lf(e,s),s}function Lf(e,t){e.partsSig.value=[...e.partsSig.value,t]}function Rf(e,t){e.partsSig.value.some(e=>e.kind===`source`&&e.sourceId===t.sourceId)||Lf(e,t)}function zf(e,t){switch(t.type){case`tool-input-start`:If(e,t.toolCallId,t.toolName,t.dynamic,t.toolMetadata);return;case`tool-input-delta`:{let n=If(e,t.toolCallId);n.inputPartialSig.value+=t.inputTextDelta;return}case`tool-input-available`:{let n=If(e,t.toolCallId,t.toolName,t.dynamic,t.toolMetadata);n.inputSig.value=t.input,n.stateSig.value=`input-available`;return}case`tool-input-error`:{let n=If(e,t.toolCallId,t.toolName,t.dynamic);n.inputSig.value=t.input,n.errorSig.value=t.errorText,n.stateSig.value=`output-error`;return}case`tool-approval-request`:{let n=If(e,t.toolCallId,t.toolName);n.approvalSig.value={id:t.approvalId},n.stateSig.value=`approval-requested`;return}case`tool-output-available`:{let n=If(e,t.toolCallId,void 0,t.dynamic);n.outputSig.value=t.output,n.stateSig.value=`output-available`;return}case`tool-output-error`:{let n=If(e,t.toolCallId,void 0,t.dynamic);n.errorSig.value=t.errorText,n.stateSig.value=`output-error`;return}case`tool-output-denied`:{let n=If(e,t.toolCallId);n.stateSig.value=`output-denied`;return}default:return}}const Bf=1e3;async function Vf(e){let t=Bf,n=!1,r=!1,i=!1;function a(){i||e.signal.aborted||(i=!0,e.onInitialBoundaryReady())}for(;!e.signal.aborted;){let o,s=`held`;try{s=await e.connect(()=>{if(e.signal.aborted)return;o=e.now();let t=n||r;n=!0,r=!1,i?t&&e.backfill():a()})}catch{}if(e.signal.aborted||(!n&&o===void 0&&(r=!0,a()),s===`unavailable`))return;e.onDropped?.(),o!==void 0&&e.now()-o>=1e3&&(t=Bf),await e.sleep(t),t=Math.min(t*2,15e3)}}function Hf(e){let{activated:t,conversationReady:n,conversationIdSig:r,messagesSig:i,optionsRef:a,transport:o,visitorId:s,adoptControlStateChunk:c,adoptMemoryCompactionStateChunk:l,settleSuggestions:d,recordConversationReply:f,transcriptRecoverySig:p,beginConversationTranscript:h,commitConversationTranscript:g,onReplyLanded:_,runCancellation:v,canContinueRef:y,setCanSend:b,feedback:x,bus:S,loadInitialThread:C,shouldReconcileOnConnect:w,reconnectingSig:T}=e,E=m(0);u(()=>{if(!t||!n||!r.value)return;let e=r.value,u=new AbortController,m=e=>{},D=new Cf(i,e=>m(e));o.primeIdentity(s,e);let O=!1,k=!1,A,j=!1,M,N=0,ee=y.current,te,P,ne=Date.now(),re,F=!1,I=!1,ie=!1;function ae(t,n,r){if(!Ni(t))return;let o=i.value.findLast(e=>!e.ephemeral),s=t.serverMessageId??t.id;if(!(o&&(o.serverMessageId??o.id)!==s))return Mi(i.value,t,e,a.current.strings.newConversation,n,r)}function L(e,t,n,r){let i=ae(e,t,r);if(!i)return;let a=`${e.serverMessageId??e.id}:${n}:${i.preview??``}`;a!==P&&(P=a,o.publishConversation({...i,hasUnread:!0},!0))}let oe;function se(){oe&&(clearTimeout(oe.timer),oe=void 0)}function ce(){let e=oe;if(!e)return;clearTimeout(e.timer),oe=void 0;let t=i.value.find(t=>(t.serverMessageId??t.id)===e.replyId);(t?.role===`assistant`||t?.role===`operator`)&&L(t,e.canContinue,e.generation,e.activityAt)}function R(e,t,n,r){se(),oe={replyId:e.serverMessageId??e.id,canContinue:t,generation:n,activityAt:r,timer:setTimeout(ce,120)}}function le(e,t,n,r=Date.now(),i=!0){se();let a=ae(e,t,r);if(!a)return;let o=`${e.serverMessageId??e.id}:${n}`;o!==te&&(te=o,f(a),i&&re&&!F&&(I=!0))}function ue(e,t){(e||!v.localSendRef.current)&&v.settle(t),e&&_()}function de(e,t=[],n=!1,r,o=ee,s=N,c=Date.now(),l=!0){let u=a.current;if(e.canceled){le(e,o,s,c,l),ue(n,r);return}let f=!0,p=e.status===`error`;switch(aa(e,p)){case`drop`:i.value=i.value.filter(t=>t!==e),f=!1;break;case`complete-operator-routed`:e.status=`complete`,n&&(x.play(`messageReceived`),Ia(S,u,`assistant`,ji(e)));break;case`error`:if(e.status=`error`,n){x.play(`error`);let e=/* @__PURE__ */ Error(p?`stream error chunk`:`empty reply`);S.emit(`error`,e),u.onError?.(e)}break;case`complete`:e.status=`complete`,n&&(x.play(`messageReceived`),Ia(S,u,`assistant`,ji(e))),d(e,t)}f&&le(e,o,s,c,l),ue(n,r)}function fe(t){if(u.signal.aborted||r.value!==e)return;if(c(t),l?.(t),t.type===`start`){ce();let n=t.messageId===void 0?void 0:i.value.find(e=>e.serverMessageId===t.messageId||e.id===t.messageId);j=n!==void 0&&n.status!==`streaming`;let r=M?.senderRole===`visitor`?M.messageId:void 0;if(M={messageId:t.messageId,senderRole:t.messageMetadata?.senderRole},N+=1,ne=Date.now(),P=void 0,O=t.messageMetadata?.senderRole===void 0,k=!1,A=O?t.messageMetadata?.runId:void 0,O){let n=t.messageId!==void 0&&i.value.some(e=>e.serverMessageId===t.messageId||e.id===t.messageId),a=i.value.at(-1),o=t.messageId!==void 0&&(a?.serverMessageId===t.messageId||a?.id===t.messageId),s=v.localSendRef.current&&(!n||o)&&a?.role===`assistant`&&a.status===`streaming`&&(o||a.serverMessageId===void 0&&a.partsSig.value.length===0);k=v.captureStart(e,t,s,r)}}let n=O&&(t.type===`finish`||t.type===`error`||t.type===`abort`),o=n?A:void 0,s=n&&(k||v.ownsLocalRun(o)),d=N,f=j;t.type===`finish`&&t.canContinue!==void 0&&(ee=t.canContinue);let p=ee;n&&(O=!1,k=!1,A=void 0);let m=D.applyResume(t),h=M?.messageId,g=h===void 0?void 0:i.value.find(e=>e.serverMessageId===h||e.id===h);j&&M?.senderRole!==`visitor`&&(m!==null||g?.status===`streaming`)&&(j=!1,f=!1);let _=!j&&(g?.role===`assistant`||g?.role===`operator`);t.type===`text-delta`&&_&&R(g,ee,N,ne),t.type===`text-end`&&(se(),_&&L(g,ee,N,ne)),t.type===`finish`&&t.canContinue===!1&&b(!1),m?m.role===`operator`?(f||(x.play(`messageReceived`),Ia(S,a.current,`operator`,ji(m))),le(m,p,d,ne),j=!1,n&&(s||!v.localSendRef.current)&&v.settle(o)):m.role===`assistant`&&(de(m,[],s,o,p,d,ne),j=!1):n&&(s||!v.localSendRef.current)&&v.settle(o)}async function pe(t){let n=N,a=await o.loadConversation(e,t?{ids:[t]}:void 0).catch(()=>null);if(u.signal.aborted||r.value!==e||!a)return!1;a.controlState&&c({type:`data-control-state`,data:a.controlState});let s=i.value.at(-1),l=n===N&&(t===void 0||s!==void 0&&(s.serverMessageId===t||s.id===t));if(a.messages.length===0)return!0;l&&(ee=a.canContinue,b(ee));let f=i.value,p=t===void 0?f.at(-1):f.find(e=>e.serverMessageId===t||e.id===t),{messages:m,changed:h}=Xi(f,Oi(a.messages));if(!h)return!0;i.value=m;let g=t===void 0?m.at(-1):m.find(e=>e.serverMessageId===t||e.id===t),_=p!==void 0&&g!==void 0&&(p.id===g.id||p.serverMessageId!==void 0&&p.serverMessageId===g.serverMessageId),y=g!==void 0&&g.status!==`streaming`&&(!_||p?.status===`streaming`),x=_&&p?.status===`streaming`?Date.now():g?.createdAt;return l&&y&&g.role===`assistant`?de(g,g.suggestions??[],v.localSendRef.current,void 0,a.canContinue,n,x,!1):l&&y&&g.role===`operator`?le(g,a.canContinue,n,x,!1):l&&g?.role===`assistant`&&g.status!==`streaming`&&d(g,g.suggestions??[]),!0}let me=/* @__PURE__ */ new Set;m=({messageId:e})=>{if(me.has(e)||!i.value.some(t=>t.serverMessageId===e||t.id===e))return;me.add(e);function t(){return me.delete(e)}pe(e).then(t,t)};function z(t=!1){if(u.signal.aborted||r.value!==e){I=!1;return}if(re){I=!0;return}let n=t?C(e):void 0,i=n??(!t||w()?pe():void 0);if(!i)return;h(e),re=i,F=n!==void 0;function a(t=!1){re===i&&(re=void 0,I?(I=!1,z()):t&&g(e))}i.then(a,()=>a(!1))}let he=p.subscribe(e=>{e<=E.current||(E.current=e,ie&&z())});return Vf({signal:u.signal,now:()=>performance.now(),sleep:e=>ca(e,u.signal),connect:e=>o.connectResumeStream({signal:u.signal,onChunk:fe,onConnected:()=>{T.value=!1,e()}}),onDropped:()=>{T.value=!0},onInitialBoundaryReady:()=>{ie=!0,z(!0)},backfill:()=>z()}),()=>{u.abort(),T.value=!1,se(),he(),D.detach()}},[t,n,r,r.value,s,o,c,l,d,f,p,h,g,_,v,y,b,i,S,x,C,w,T])}function Uf(e){let{transport:t,setStreaming:n}=e,r=m(void 0),i=m(void 0),a=m(!1),o=m(void 0),s=m(!1),c=m(/* @__PURE__ */ new Map),u=m(/* @__PURE__ */ new Set),d=l((e,n)=>{let r=`${e}:${n}`;o.current!==r&&(o.current=r,t.cancelTurn(e,n))},[t]),f=l(e=>{r.current=void 0,i.current=e,a.current=!1,o.current=void 0,s.current=!0,n(!0)},[n]),h=l((e,t)=>{c.current.set(e,{messageId:t})},[]),g=l(e=>{e!==void 0&&(u.current.add(e),u.current.size>32&&u.current.delete(u.current.values().next().value)),(e===void 0||r.current?.runId===e)&&(r.current=void 0,i.current=void 0,a.current=!1,s.current=!1,n(!1))},[n]),_=l((e,t)=>i.current===e?(i.current=void 0,t.runId?(r.current={conversationId:t.conversationId,runId:t.runId},n(!0),a.current&&d(t.conversationId,t.runId),!0):(g(),!0)):t.runId&&r.current?.runId===t.runId?(r.current={conversationId:t.conversationId,runId:t.runId},a.current&&d(t.conversationId,t.runId),!0):!1,[d,n,g]),v=l((e,t)=>{let l=c.current.get(e);return l?(c.current.delete(e),!t.runId||u.current.has(t.runId)?!0:l.runId===void 0?(s.current||i.current||(r.current={conversationId:t.conversationId,runId:t.runId},i.current=void 0,a.current=!1,o.current=void 0,s.current=!0,n(!0)),!0):(l.runId===t.runId&&r.current?.runId===t.runId&&(r.current={conversationId:t.conversationId,runId:t.runId},a.current&&d(t.conversationId,t.runId)),!0)):!1},[d,n]),y=l(e=>i.current===e&&(g(),!0),[g]),b=l(e=>{let t=c.current.get(e);return t?(c.current.delete(e),t.runId===void 0):!1},[]),x=l((e,t,l,f)=>{let p=t.messageMetadata?.runId;if(t.messageMetadata?.senderRole!==void 0||typeof p!=`string`||!p||u.current.has(p))return!1;if(r.current?.runId===p)return s.current;if(s.current)return r.current||!l?!1:(i.current=void 0,r.current={conversationId:e,runId:p},n(!0),a.current&&d(e,p),!0);let m=[...c.current.values()].filter(e=>e.runId===void 0).find(e=>e.messageId===f);return m?(m.runId=p,r.current={conversationId:e,runId:p},i.current=void 0,a.current=!1,o.current=void 0,s.current=!0,n(!0),!0):(i.current=void 0,r.current={conversationId:e,runId:p},n(!0),a.current&&d(e,p),s.current)},[d,n]),S=l(e=>typeof e==`string`&&r.current?.runId===e&&s.current,[]),C=l(()=>{let e=r.current;if(e)return a.current=!0,d(e.conversationId,e.runId),!0;let t=i.current;return t?(a.current=!0,t.then(e=>{e.runId&&d(e.conversationId,e.runId)}).catch(()=>void 0),!0):!1},[d]);return p(()=>({localSendRef:s,begin:f,beginRouted:h,acceptAck:_,acceptRoutedAck:v,reject:y,rejectRouted:b,captureStart:x,ownsLocalRun:S,settle:g,stop:C}),[_,v,f,h,x,S,y,b,g,C])}const Wf=z.scope(`send`);function Gf(e,t,n,r,i,a=!0){e.publishConversation({...Mi(t,n,r,i,a),hasUnread:!1},!0)}function Kf(e,t){return e.id===t.id||(e.serverMessageId??e.id)===(t.serverMessageId??t.id)}function qf(e){return e.findLast(e=>!e.ephemeral&&e.role!==`system`&&(e.role===`user`||e.status!==`streaming`||Ni(e)))}function Jf(e,t,n,r,i){let a=qf(t);a?.role===`user`&&Kf(a,n)&&Gf(e,t,a,r,i)}function Yf(e){return!(e instanceof fa)||e.code===`network`||e.status===void 0||e.status===202||e.status===408||e.status===425||e.status===429||e.status>=500&&e.status<600}function Xf(e){let{transport:t,messagesSig:n,conversationIdSig:r,options:i,bus:a,feedback:o,persistence:s,visitorId:c,adoptConversationId:u,applyControlState:d,setCanSend:f,settleSuggestions:p,runCancellation:m}=e,h=l(()=>{let e=r.value??pt();return r.value||(r.value=e,s.saveConversationId(e)),e},[r,s]);return{sendAiTurn:l(async({continueExisting:e,turn:l})=>{let g=h(),_=n.value.at(-1),v=l?[l]:ki(n.value,e),y=v[0];y?.role===`user`&&Pl.markSent(y.id);let b=v.map(Ai),x=s.loadUserPrefs(),S=Jl(i.tools).then(n=>t.sendTurn(hi({messages:b,conversationId:g,visitorId:c,userPrefs:x,clientTools:Yl(n)}),{keepalive:e}));m.begin(S);try{let a=await S;if(r.value!==g||!m.acceptAck(S,a))return!1;if(u(a.conversationId),a.runId&&y?.role===`user`&&Jf(t,n.value,y,a.conversationId,i.strings.newConversation),!a.runId){let o=await t.loadConversation(a.conversationId).catch(()=>null);if(r.value!==a.conversationId)return!0;if(o){o.controlState&&d(o.controlState),f(o.canContinue);let r=Oi(o.messages),{messages:s,changed:c}=Xi(n.value,r);c&&(n.value=s);let l=r.findLast(e=>!e.ephemeral&&e.role!==`system`),u=qf(n.value);u&&l&&Kf(u,l)&&Gf(t,n.value,u,a.conversationId,i.strings.newConversation,o.canContinue);let m=_?n.value.find(e=>e.id===_.id&&e.role===`assistant`&&e.status!==`streaming`):void 0;m&&p(m,m.suggestions??[]),!e&&_?.role===`assistant`&&n.value.includes(_)&&_.serverMessageId===void 0&&!Ni(_)&&(n.value=n.value.filter(e=>e!==_))}else _?.role===`assistant`&&n.value.includes(_)&&(_.status=`error`,_.errorText=i.strings.errorGeneric,_.retryAction=e?{kind:`continue-assistant`,messageId:_.serverMessageId??_.id}:y?.role===`user`?{kind:`resend-user`,messageId:y.id}:null,n.value=[...n.value])}return!0}catch(s){if(r.value!==g)return!1;if(!m.reject(S))return y?.role===`user`&&Jf(t,n.value,y,g,i.strings.newConversation),!0;let c=Is(s,i.strings),u=Yf(s),h=l?.role===`assistant`?l:n.value.at(-1);if(e&&h?.role===`assistant`&&s instanceof fa&&s.status===409){let e=h.serverMessageId??h.id,i=await t.loadConversation(g,{ids:[e]}).catch(()=>null);if(r.value!==g)return!1;if(i){i.controlState&&d(i.controlState),f(i.canContinue);let t=Oi(i.messages),r=t.find(t=>(t.serverMessageId??t.id)===e);if(r&&Zi(h,r)){let{messages:r,changed:i}=Xi(n.value,t),a=r.find(t=>(t.serverMessageId??t.id)===e);if(i&&a&&a!==h)return a.awaitingContinuation=!1,a.continuationStreaming=void 0,a.retryAction=null,n.value=r,a.status!==`streaming`&&p(a,a.suggestions??[]),!0}}if(!n.value.includes(h)||h.status!==`streaming`)return!1;h.continuationStreaming=!0}if(e&&h?.role===`assistant`)h.status=`error`,h.errorText=c,h.retryAction=u?{kind:`continue-assistant`,messageId:h.serverMessageId??h.id}:null,n.value=[...n.value];else if(_?.role===`assistant`&&n.value.includes(_)){_.status=`error`,_.errorText=c;let e=v[0];_.retryAction=u&&e?.role===`user`?{kind:`resend-user`,messageId:e.id}:null,n.value=[...n.value]}else{let e=yi();e.status=`error`,e.errorText=c;let t=v[0];e.retryAction=u&&t?.role===`user`?{kind:`resend-user`,messageId:t.id}:null,n.value=[...n.value,e]}return o.play(`error`),a.emit(`error`,s),i.onError?.(s),!1}},[t,n,i,a,o,s,c,u,d,f,p,h,m]),sendRoutedTurn:l(async e=>{let l=h();e.status=`pending`,e.errorText=void 0,e.retryAction=void 0,n.value.includes(e)&&(n.value=[...n.value]),Pl.markSent(e.id);let d=[Ai(e)],f=s.loadUserPrefs(),p=Jl(i.tools).then(e=>t.sendTurn(hi({messages:d,conversationId:l,visitorId:c,userPrefs:f,clientTools:Yl(e)})));m.beginRouted(p,e.id);try{let a=await p;return r.value===l?m.acceptRoutedAck(p,a)?(u(a.conversationId),Jf(t,n.value,e,a.conversationId,i.strings.newConversation),e.status===`pending`&&(e.status=`complete`,n.value.includes(e)&&(n.value=[...n.value])),!0):!1:(m.rejectRouted(p),!1)}catch(s){let c=m.rejectRouted(p);if(r.value!==l)return!1;if(!c)return Jf(t,n.value,e,l,i.strings.newConversation),e.status===`pending`&&(e.status=`complete`,n.value.includes(e)&&(n.value=[...n.value])),!0;if(e.status!==`pending`)return Jf(t,n.value,e,l,i.strings.newConversation),!0;Wf.debug(`operator-routed send failed`,{error:s});let u=s instanceof Error?s:Error(String(s));return e.status=`error`,e.errorText=Is(s,i.strings),e.retryAction=Yf(s)?{kind:`resend-user`,messageId:e.id}:null,n.value.includes(e)&&(n.value=[...n.value]),o.play(`error`),a.emit(`error`,u),i.onError?.(u),!1}},[t,n,i,a,o,s,c,u,h,m])}}const Zf=z.scope(`unread`);function Qf(e){let{transport:t,options:n,conversationIdSig:r,isConversationVisibleRef:i,activated:a,conversationReady:o}=e,s=c(!1),d=c(0),f=c(0),p=m([]),h=m(void 0),g=m(!1),_=l(()=>{let e=r.value,t=i.current()&&h.current===e?e:void 0,n=p.current.filter(e=>e.hasUnread&&e.conversationId!==t).length;d.value=n,s.value=n>0},[r,s,d,i]),v=l(e=>{let t=r.value,n=p.current.find(e=>e.conversationId===t),i=Ca(p.current,e),a=i.find(e=>e.conversationId===t),o=e.type===`snapshot`&&t!==void 0&&a?.hasUnread===!0&&h.current===t&&n!==void 0&&n.lastMessageAt!==a.lastMessageAt;o&&(h.current=void 0),p.current=i,_(),o&&(f.value+=1)},[r,_,f]),y=l(()=>{if(_(),!i.current())return;let e=r.value;if(!e||h.current!==e)return;let n=p.current.find(t=>t.conversationId===e);n?.hasUnread&&t.markRead(e,n.lastMessageAt)},[r,i,_,t]),b=l(e=>{r.value===e&&(h.current=void 0,_())},[r,_]),x=l(e=>{r.value===e&&(h.current=e,y())},[r,y]),S=l(e=>h.current===e,[]),C=l((e=!1)=>{n.history.enabled&&n.modules.list.some(e=>e.layout===`chat`)&&(g.current||(g.current=!0,t.listConversations({limit:50},e).then(t=>{e||v({type:`snapshot`,result:t,requestedRevision:0}),y()}).catch(e=>Zf.debug(`refreshUnread failed (non-fatal)`,{err:e})).finally(()=>{g.current=!1})))},[v,y,n.history.enabled,n.modules,t]),w=l(e=>{let n=e.conversationId,a=i.current()&&r.value===n&&h.current===n,o=p.current.find(e=>e.conversationId===n),s=a&&(o?.lastMessageAt!==e.lastMessageAt||o.hasUnread);t.publishConversation({...e,hasUnread:!a},!0),s&&t.markRead(n,e.lastMessageAt)},[r,i,t]);u(()=>t.subscribeConversationChanges(v),[v,t]);let T=m(!1);return u(()=>{a&&o&&!T.current&&(T.current=!0,C())},[a,o,C]),u(()=>{if(!a)return;function e(){document.visibilityState===`visible`&&(y(),C(!0))}return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[a,y,C]),{hasUnreadSig:s,unreadCountSig:d,transcriptRecoverySig:f,markVisibleConversationRead:y,beginConversationTranscript:b,commitConversationTranscript:x,isConversationTranscriptCommitted:S,recordConversationReply:w}}const $f=z.scope(`settings`);function ep(e){let{options:t,persistence:n,transport:r,feedback:i,hostElement:a,bus:o}=e,s=n.loadUserPrefs(),[c,d]=h(()=>s.locale??t.locale),[f,p]=h(s.themeMode),m=f??t.themeMode,[g,_]=h(()=>s.textSize??t.textSize),v=l(e=>{n.patchUserPrefs(e),r.saveUserPrefs(n.loadUserPrefs()).catch(e=>$f.warn(`saveUserPrefs failed`,{err:e}))},[n,r]);u(()=>{s.soundMuted!==void 0&&i.setMuted(s.soundMuted)},[]),u(()=>{if(m!==`host`)a.dataset.theme=m;else return At(e=>{a.dataset.theme=e})},[a,m,t]),u(()=>{a.dataset.textSize=g},[a,g,t]),u(()=>{let e=!0;return i.mutedSig.subscribe(t=>{e?e=!1:v({soundMuted:t})})},[i,v]);let y=Ee(c,t.availableLocales,t.defaultLocale);return u(()=>{r.setLocale(y)},[r,y]),u(()=>{a.dir=A(y)?`rtl`:`ltr`},[a,y]),u(()=>{y!==c&&d(y)},[y,c]),{activeLocale:c,activeThemeMode:m,activeTextSize:g,effectiveLocale:y,setActiveLocale:d,setActiveThemeMode:p,setActiveTextSize:_,patchAndSync:v,handleLocaleChange:l(e=>{$f.info(`localeChange`,{locale:e}),d(e),v({locale:e}),o.emit(`localeChange`,e)},[v,o]),handleThemeChange:l(e=>{$f.info(`themeChange`,{mode:e}),p(e),a.dataset.theme=e,v({themeMode:e}),o.emit(`themeChange`,e)},[a,v,o]),handleTextSizeChange:l(e=>{$f.info(`textSizeChange`,{size:e}),_(e),a.dataset.textSize=e,v({textSize:e}),o.emit(`textSizeChange`,e)},[a,v,o]),handleSoundToggle:l(()=>{i.toggleMuted();let e=i.mutedSig.value;$f.info(`soundToggle`,{muted:e}),o.emit(`soundToggle`,{muted:e})},[i,o])}}const $=z.scope(`app`),tp=N.cssPrefix,np={home:`home`,chats:`chat`,help:`help`,news:`news`};function rp(e,t){return bi({...e,text:j(t,e.text)})}function ip({options:e,hostElement:t,bus:n,recentHostEvents:i}){let o=e.aiAgentDeploymentId;if(!o)throw Error(`aiAgentDeploymentId is required`);let[d]=h(()=>gt(e.widgetId,e.storage,e.aiAgentDeploymentId)),[g]=h(()=>d.getVisitorId()),y=d.loadUserPrefs(),b=c(d.loadConversationId()),x=m(b.value!==void 0),S=c(b.value??``),C=c([]),w=c(!1),[T,E]=h(!1),D=m(void 0),[O,k]=h([]);function A(){let t=e.modules.list,n=new Set(t.map(e=>e.id)),r=d.loadActiveModule();return r&&n.has(r)?r:t[0]?.id??``}function M(){return e.modules.list.find(e=>e.layout===`chat`)?.id}function ee(){let t=M();return t?e.modules.list.length===1||P.sig.value.activeTab===t:!1}let te=m(void 0);if(!te.current){let t=e.modules.list.map(e=>e.id),n=d.loadActiveModule()??t[0]??``;te.current=Ua(n,n?[...t,n]:t,e=>d.saveActiveModule(e))}let P=te.current,ne=s(()=>P.sig.value.activeTab).value,re=s(()=>b.value).value,[F,I]=h(!1),[ie,ae]=h(null),[L,oe]=h(!1),se=e.mode===`standalone`||e.mode===`inline`,ce=m(Ya(e,Xa(),d.loadPanelOpen(),d.loadPanelSize())),[R,le]=h(ce.current.panelOpen),[ue,de]=h(ce.current.panelOpen),fe=m(void 0),pe=m(void 0),me=m(!1),z=m(void 0);u(()=>{R&&de(!0)},[R]);let he=m(!1),[ge,_e]=h(!1),{dismissed:ve,dismissCallout:ye}=gf({callout:e.launcher.callout,persistence:d}),be=e.launcher.callout?.persistent??!0,xe=l(()=>{$.info(`calloutDismiss`),n.emit(`calloutDismiss`,void 0),ye()},[n,ye]),[Se,Ce]=h(ce.current.panelSize),we=m(!1),[Te,Ee]=h(`chat`),De=m(()=>!1);De.current=()=>R&&Te===`chat`&&!document.hidden&&ee();let[Oe,ke]=h(!0),Ae=m(Oe);Ae.current=Oe;let[je,Me]=h(!1),Ne=m(je);Ne.current=je;let Fe=m(null),[Ie,Re]=h(!1),[ze,Be]=h(null),[Ve,He]=h([]),Ue=m(e.strings),We=m(e);We.current=e;let[Ge,Ke]=h(void 0),[qe,Je]=h(void 0),[Ye,Xe]=h(()=>d.loadSidebarCollapsed()??!1),[Ze,Qe]=h({}),[B]=h(()=>new ka({agentApiBaseUrl:e.agentApiBaseUrl,dataApiBaseUrl:e.dataApiBaseUrl,auth:Gt({publicKey:e.publicKey,aiAgentDeploymentId:o,publicKeyHeader:`x-public-key`}),endpoints:e.endpoints,recentHostEvents:i})),[$e]=h(()=>new yn(e.sound,e.haptics)),et=Uf({transport:B,setStreaming:Me}),{activeLocale:tt,activeThemeMode:nt,activeTextSize:rt,effectiveLocale:it,setActiveLocale:at,setActiveThemeMode:ot,setActiveTextSize:st,patchAndSync:ct,handleLocaleChange:lt,handleThemeChange:ut,handleTextSizeChange:dt,handleSoundToggle:ft}=ep({options:e,persistence:d,transport:B,feedback:$e,hostElement:t,bus:n}),{controlModeSig:mt,assignedOperatorInitialsSig:ht,operatorAvailableSig:_t,applyControlState:vt,adoptControlStateChunk:bt,requestOperator:xt,cancelOperatorRequest:St}=_f({transport:B,conversationIdSig:b}),Ct=c(/* @__PURE__ */ new Map),wt=l(e=>{if(e.type!==`data-memory-compaction-state`)return;let t=b.value;if(!t)return;let n=pi(e.data);if(!n)return;let r=Ct.value.get(t);if(r&&(n.postFinishSequence<r.postFinishSequence||n.postFinishSequence===r.postFinishSequence&&(r.status===`ready`||r.status===n.status)))return;let i=new Map(Ct.value);i.set(t,n),Ct.value=i},[b,Ct]),{hasUnreadSig:Tt,unreadCountSig:Et,transcriptRecoverySig:Dt,markVisibleConversationRead:Ot,beginConversationTranscript:kt,commitConversationTranscript:At,isConversationTranscriptCommitted:jt,recordConversationReply:Mt}=Qf({transport:B,options:e,conversationIdSig:b,isConversationVisibleRef:De,activated:ue,conversationReady:F}),Nt=R&&e.modules.byId[ne]?.layout===`home`,Pt=hf({transport:B,options:e,persistence:d,enabled:F&&Nt});u(()=>{Ot()},[ne,R,Te,re,Ot]),u(()=>{$e.update(e.sound,e.haptics)},[$e,e.sound,e.haptics]),u(()=>()=>$e.destroy(),[$e]),u(()=>{!we.current&&e.size.initialSize&&(we.current=!0,!d.loadPanelSize()&&Ce(Ja(e.mode,e.size,Xa())))},[e.mode,e.size,d]),u(()=>{if(!F||he.current)return;he.current=!0;let t=Ya(e,Xa(),d.loadPanelOpen(),d.loadPanelSize());le(t.panelOpen),Ce(t.panelSize)},[F,e,d]);let Ft=m(null);u(()=>{F&&P.reconcile(e.modules.list.map(e=>e.id),A())},[F,e.modules.list,P]);let It=l(e=>{e&&e.length!==0&&(C.value=e.map(e=>rp(e,Ue.current)))},[C]),Lt=m(null),Rt=l(async e=>{try{let{formSubmissions:t}=await(e?B.bootstrap(e):Lt.current??B.bootstrap()),n=/* @__PURE__ */ new Map;return t.forEach((e,t)=>n.set(e.formId,t)),t.filter((e,t)=>!e.skipped||n.get(e.formId)===t).map((e,t)=>({key:`wire:${e.formId}:${e.createdAt??t}`,formId:e.formId,outcome:e.skipped?`skipped`:`submitted`,createdAt:oi(e.createdAt),values:e.values}))}catch(e){return $.debug(`bootstrap failed — no form markers (non-fatal)`,{err:e}),[]}},[B]),zt=m(0),Bt=m(0),Vt=l(e=>{if(e===b.value)return;let t=b.value;Bt.current++,E(!1),t&&(d.saveDraft(e,d.loadDraft(t)),d.saveDraft(t,``),d.saveMessageQueue(e,d.loadMessageQueue(t)),d.saveMessageQueue(t,[])),b.value=e,d.saveConversationId(e),B.primeIdentity(void 0,e),$.info(`conversation rebound`,{previous:t,current:e}),t&&n.emit(`conversationRebound`,{previous:t,current:e})},[n,b,d,B]),Ht=l((e,t)=>{let n=[...e.map(e=>e.createdAt),...t.map(e=>e.createdAt)].filter(e=>e!==void 0),r=(n.length?Math.min(...n):Date.now())-1;return[...(z.current?.messages??[]).map(e=>{let t=rp(e,Ue.current);return t.createdAt=r,t}),...e]},[]),Ut=l(async e=>{let t=Bt.current;function r(){return t!==Bt.current||b.value!==e}pe.current===e&&(pe.current=void 0),E(!0);try{let[t,n]=await Promise.all([B.loadConversation(e),Rt()]);if(r())return!1;let i=Oi(t.messages);k(n);let a=Ht(Yi(i,C.value),n);if(C.value=a,pe.current=a.some(e=>e.role===`user`)?void 0:e,i.length>0||t.controlState!==void 0){ke(t.canContinue),t.controlState&&vt(t.controlState);let e=i.findLast(e=>e.role===`assistant`&&!e.ephemeral);He(e?.suggestions??[])}return!0}catch(t){return r()||($.warn(`loadThread failed; keeping conversation active`,{err:t,conversationId:e}),n.emit(`error`,t),We.current.onError?.(t)),!1}finally{r()||E(!1)}},[B,Rt,C,b,Ht,n]),Wt=l(e=>{if(fe.current===e)return fe.current=void 0,Ut(e)},[Ut]),Kt=l(()=>{if(D.current)return Promise.resolve(void 0);let t=b.value,r=C.value.find(e=>e.serverMessageId!==void 0),i=r?.serverMessageId,a=r?new Date(r.createdAt).toISOString():void 0;if(!t||!i||!a)return Promise.resolve(void 0);let o=Bt.current,s={};return D.current=s,(async()=>{try{let e=await B.loadConversation(t,{beforeId:i,beforeCreatedAt:a});if(D.current!==s||Bt.current!==o||b.value!==t)return;if(e.messages.length===0)return!1;let n=e.messages.map(Ci),r=C.value,c=Ui(r,n);if(c!==r){let e=Math.min(...n.map(e=>e.createdAt??1/0),...O.map(e=>e.createdAt??1/0));if(Number.isFinite(e))for(let t of r){if(!t.ephemeral)break;(t.createdAt??1/0)>=e&&(t.createdAt=e-1)}C.value=c}return!0}catch(r){if(D.current!==s||Bt.current!==o||b.value!==t)return;$.warn(`load previous messages failed`,{err:r,conversationId:t,beforeId:i}),n.emit(`error`,r),e.onError?.(r);return}finally{D.current===s&&(D.current=void 0)}})()},[n,b,O,C,e,B]),Zt=l(async({newConversation:t})=>{let i=++zt.current;function a(){return i!==zt.current}let o=b.value,s=t||!o?pt():o;s!==o&&(Bt.current++,E(!1),r(()=>{b.value=s,S.value=s}),d.saveConversationId(s)),B.primeIdentity(g,s);let c;try{c=await B.handshake({visitorId:g,conversationId:s,userPrefs:d.loadUserPrefs(),locale:tt})}catch(r){if(a())return;n.emit(`error`,r),e.onError?.(r),t||I(!0);return}if(a())return;c.conversationId!==s&&Vt(c.conversationId),Be(c.agent),c.site&&xn(c.site)?Ke(c.site):c.site&&$.warn(`invalid site config, using fallback`,{site:c.site}),c.blocks&&Sn(c.blocks)?Je(c.blocks):c.blocks&&$.warn(`invalid blocks config, using fallback`,{blocks:c.blocks});let l=yt(c.userPrefs);if(Object.keys(l).length>0&&!t&&(d.saveUserPrefs(l),l.locale&&at(l.locale),l.soundMuted!==void 0&&$e.setMuted(l.soundMuted),l.themeMode&&ot(l.themeMode),l.textSize&&st(l.textSize)),z.current=c.welcome,t||n.emit(`handshake`,c),c.welcome?.suggestions){let e=Ue.current;He(c.welcome.suggestions.map(t=>({...t,label:j(e,t.label),...t.text===void 0?{}:{text:j(e,t.text)}})))}let u=!t&&o&&c.conversationId===o;x.current=!!u,u?me.current||(fe.current=c.conversationId):(pe.current=c.conversationId,It(c.welcome?.messages),At(c.conversationId)),t||I(!0)},[B,g,d,e,n,b,S,$e,It,tt,Vt,At]),en=JSON.stringify(e.userContext??null),nn=JSON.stringify(e.pageContext??null),rn=JSON.stringify(Ze);u(()=>{let t=Object.keys(Ze).length?{...Ze,...e.userContext}:e.userContext;B.setContext(t,ap(e.pageContext))},[B,en,nn,rn]),u(()=>B.setUserToken(e.userToken),[B,e.userToken]);let an=l((e,t=[])=>He(e.suggestions??t),[]);u(()=>(B.primeIdentity(g,b.value),Zt({newConversation:!1}),()=>{zt.current++,Bt.current++}),[]),u(()=>{ue&&F&&!me.current&&(me.current=!0,Lt.current=B.bootstrap(),(async()=>{try{let e=await Lt.current;ae(Pe((e??{forms:[]}).forms,it))}catch(e){$.debug(`bootstrap failed — treating as no forms`,{err:e})}finally{oe(!0)}})(),fe.current===b.value&&E(!0))},[ue,F]);let V=m(null);u(()=>{if(!ue||!F||(V.current??(V.current=it),V.current===it))return;V.current=it;let e=!1;return B.bootstrap().then(t=>{e||ae(Pe((t??{forms:[]}).forms,it))}).catch(e=>$.debug(`forms re-localize failed — keeping current copy`,{err:e})),()=>{e=!0}},[ue,F,it,B]);let sn=m(en);u(()=>{F&&sn.current!==en&&(sn.current=en,Zt({newConversation:!1}))},[en,F,Zt]),xf({hostElement:t,mode:e.mode,panelSize:Se,isOpen:R,surfaceReady:F,setIsOpen:le});let{sendAiTurn:cn,sendRoutedTurn:ln}=Xf({transport:B,messagesSig:C,conversationIdSig:b,options:e,bus:n,feedback:$e,persistence:d,visitorId:g,adoptConversationId:Vt,applyControlState:vt,setCanSend:ke,settleSuggestions:an,runCancellation:et}),{toolInteraction:un,pageToolsRunning:dn,stopPageTools:fn}=pf({streaming:je,controlModeSig:mt,messagesSig:C,sendAiTurn:cn,bus:n,humanInLoop:e.features.humanInLoop,tools:e.tools}),pn=l((e,t)=>{let r=C.value.find(t=>t.serverMessageId===e);r&&(r.feedback=t),$.info(`messageFeedback`,{messageId:e,value:t}),n.emit(`messageFeedback`,{messageId:e,value:t}),B.submitFeedback({messageId:e,value:t})},[n,C,B]);function mn(){return C.value.reduce((e,t)=>e+ +(t.role===`user`),0)}let hn=e.forms.list.length>0?e.forms:ie??e.forms,gn=La({forms:hn,persistence:d,userContext:()=>e.userContext,messageCount:mn,pageArea:()=>e.pageContext?.area?String(e.pageContext.area):void 0,conversationId:()=>b.value,onComplete:(e,t,r,i)=>{$.info(`formSubmit`,{formId:e.id,trigger:t,skipped:i}),n.emit(`formSubmit`,{formId:e.id,values:r,skipped:i}),k(t=>{let n=t.find(t=>t.formId===e.id&&t.outcome===`skipped`)?.createdAt??Date.now();return[...t.filter(t=>t.formId!==e.id||t.outcome!==`skipped`),{key:`local:${e.id}:${n}`,formId:e.id,outcome:i?`skipped`:`submitted`,createdAt:n,...i?{}:{values:r}}]});let a=b.value??pt();b.value||(b.value=a,d.saveConversationId(a),B.primeIdentity(void 0,a)),!i&&e.mirrorToContext&&Qe(e=>({...e,...r})),B.submitForm({formId:e.id,conversationId:a,trigger:t,values:r,skipped:i})}}),_n=s(()=>gn.activeForm.value),vn=_n.value?.form.blocking??!1;Hf({activated:ue,conversationReady:F,conversationIdSig:b,messagesSig:C,optionsRef:We,transport:B,visitorId:g,adoptControlStateChunk:bt,adoptMemoryCompactionStateChunk:wt,settleSuggestions:an,recordConversationReply:Mt,transcriptRecoverySig:Dt,beginConversationTranscript:kt,commitConversationTranscript:At,onReplyLanded:l(()=>gn.fire(`after-messages`),[gn]),runCancellation:et,canContinueRef:Ae,setCanSend:ke,feedback:$e,bus:n,loadInitialThread:Wt,shouldReconcileOnConnect:l(()=>x.current||C.value.some(e=>!e.ephemeral&&e.role===`user`),[C]),reconnectingSig:w}),u(()=>{gn.refresh()},[hn,gn]);let bn=e.pageContext?.area?String(e.pageContext.area):void 0,Cn=s(()=>C.value.length),wn=m(null);u(()=>{L&&wn.current&&(gn.fire(`manual`,wn.current),wn.current=null)},[L,gn]),u(()=>{F&&L&&gn.fire(`pre-chat`)},[F,L,gn]),u(()=>{L&&!Oe&&gn.fire(`conversation-closed`)},[L,Oe,gn]),u(()=>{F&&L&&bn&&gn.fire(`page-area`)},[F,L,bn,gn]);let Tn=p(()=>{let e=hn.list.flatMap(e=>e.triggers).filter(e=>e.kind===`idle`).map(e=>Number(e.param));return e.length?Math.min(...e)*1e3:0},[hn]);u(()=>{if(!Tn||!R)return;let e=setTimeout(()=>gn.fire(`idle`),Tn);return()=>clearTimeout(e)},[Tn,R,gn,Cn.value]);let En=l(async(t,r,i)=>{if(Fe.current)return!1;let a=b.value,o=a?Ct.value.get(a):void 0,s=mt.value!==`ai-agent`;if(!s&&o?.status===`compacting`||($.info(`send`,{textLen:t.length,attachments:r.length,streaming:Ne.current,routedToOperator:s}),Ne.current&&!s))return!1;let c=new AbortController,l={conversationId:a,controller:c};Fe.current=l,Re(!0);try{$e.unlock();let o=await sp(B,r,c.signal,t=>{c.signal.aborted||($.warn(`upload failed`,{err:t}),n.emit(`error`,t),e.onError?.(t))});if(c.signal.aborted||b.value!==a||!Ae.current||gn.activeForm.value?.form.blocking)return!1;let s=a?Ct.value.get(a):void 0,l=mt.value!==`ai-agent`;if(!l&&s?.status===`compacting`||Ne.current&&!l||!t&&o.length===0)return!1;n.emit(`send`,{text:t,attachmentCount:r.length}),Ve.length>0&&He([]),$e.play(`messageSent`);let u=vi(t,o,i);return Ia(n,e,`user`,t),l?(C.value=[...C.value,u],i?await ln(u):(ln(u),!0)):(C.value=[...C.value,u,yi()],i?await cn({continueExisting:!1}):(cn({continueExisting:!1}),!0))}finally{Fe.current===l&&(Fe.current=null,Re(!1))}},[B,n,e,Ve.length,C,b,Ct,cn,ln,mt]),Dn=m(En);Dn.current=En;let On=b.value,kn=(On?Ct.value.get(On):void 0)?.status===`compacting`,H=mt.value===`ai-agent`,An=s(()=>{let e=C.value.at(-1);return e?.role===`assistant`&&e.partsSig.value.some(e=>e.kind===`tool`&&e.stateSig.value===`approval-requested`)}),U=s(()=>C.value.some(e=>e.retryAction?.kind===`resend-user`||e.retryAction?.kind===`continue-assistant`));f(()=>{let e=b.value;return()=>{let t=Fe.current;t&&t.conversationId===e&&(Fe.current=null,Re(!1),t.controller.abort())}},[b.value]),u(()=>{(!Oe||vn)&&Fe.current?.controller.abort()},[vn,Oe]);let jn=l(()=>{if(dn){$.info(`stop page tools`),n.emit(`stop`,void 0),fn();return}if(!et.stop())return;$.info(`stop`),n.emit(`stop`,void 0);let e=C.value.at(-1);e&&e.role!==`user`&&e.status===`streaming`&&(e.canceled=!0,C.value=[...C.value])},[et,n,C,dn,fn]),Mn=l(e=>{if(je)return;let t=C.value,n=ra(t,e);if(n)switch($.info(`retry`,{kind:n.kind,messageId:n.messageId}),n.kind){case`continue-assistant`:if(mt.value!==`ai-agent`||e.role!==`assistant`||(e.serverMessageId??e.id)!==n.messageId)return;e.status=`streaming`,e.errorText=void 0,e.retryAction=void 0,e.awaitingContinuation=!0,C.value=[...t],cn({continueExisting:!0,turn:e});return;case`resend-user`:{let r=t.find(e=>e.role===`user`&&e.id===n.messageId);if(!r)return;let i=e=>{e&&Ft.current?.acceptQueuedMessage(n.messageId)};if(r.status=`complete`,r.errorText=void 0,r.retryAction=void 0,mt.value!==`ai-agent`){C.value=e.role===`assistant`?t.filter(t=>t!==e):[...t],ln(r).then(i);return}let a=yi();C.value=e.role===`assistant`?t.map(t=>t===e?a:t):[...t,a],cn({continueExisting:!1,turn:r}).then(i);return}case`repeat-user`:{let e=t.find(e=>e.role===`user`&&e.id===n.messageId);if(!e)return;let r=vi(ji(e),e.attachments?.map(e=>({...e}))??[]),i=new Set(r.attachments?.flatMap(e=>e.url?[e.url]:[])??[]),a=e.partsSig.value.flatMap(e=>e.kind===`file`&&!i.has(e.url)?[{...e}]:[]);if(a.length>0&&(r.partsSig.value=[...r.partsSig.value,...a]),mt.value!==`ai-agent`){C.value=[...t,r],ln(r);return}C.value=[...t,r,yi()],cn({continueExisting:!1,turn:r});return}default:return n}},[je,C,mt,cn,ln]),Nn=l(()=>{Fa(e.mode,Se)===`exit-fullscreen`?($.info(`close → exit-fullscreen`,{mode:e.mode}),Ce(`normal`),n.emit(`fullscreen`,!1)):($.info(`close → panel closed`,{mode:e.mode}),gn.fire(`panel-close`),le(!1),d.savePanelOpen(!1),n.emit(`close`,void 0),e.onClose?.())},[n,e,d,Se,gn]),Pn=l(()=>{$.info(`open`,{mode:e.mode}),$e.unlock(),_e(!0),le(!0),d.savePanelOpen(!0),!ve&&!be&&xe(),setTimeout(()=>_e(!1),op),n.emit(`open`,void 0),e.onOpen?.()},[n,e,$e,d,ve,be,xe]),Fn=l(()=>{let e=C.value.some(e=>e.role===`user`);if(pe.current===b.value&&!e&&Oe&&b.value)$.info(`clear → reusing empty conversation`,{conversationId:b.value}),C.value.length===0&&It(z.current?.messages);else return $.info(`clear → new conversation`,{wasStreaming:je}),n.emit(`clear`,void 0),et.settle(),x.current=!1,fe.current=void 0,pe.current=void 0,r(()=>{C.value=[],b.value=void 0,vt({controlMode:`ai-agent`,controlRevision:0})}),d.clearConversation(),ke(!0),k([]),He([]),Zt({newConversation:!0})},[je,C,b,d,Zt,n,Oe,It,et,vt]),In=l(()=>{let t=Fn();Ee(`chat`);let n=e.modules.list.find(e=>e.layout===`chat`)?.id;return n&&P.switchTab(n),t},[Fn,P,e]),Ln=l(async e=>{await In(),await Dn.current(e,[])||Ft.current?.fill(e)},[In]),Rn=l(()=>{let e=Se===`expanded`?`normal`:`expanded`;$.info(`expand`,{from:Se,expanded:e===`expanded`}),Ce(e),d.savePanelSize(e),n.emit(`expand`,e===`expanded`)},[n,Se,d]),zn=l(()=>{let e=Se===`fullscreen`?`normal`:`fullscreen`;$.info(`fullscreen`,{from:Se,fullscreen:e===`fullscreen`}),Ce(e),d.savePanelSize(e),n.emit(`fullscreen`,e===`fullscreen`)},[n,Se,d]),Bn=l(()=>{Ee(e=>{let t=e===`history`?`chat`:`history`;return $.info(`toggleHistory`,{view:t}),n.emit(`toggleHistory`,{view:t}),t})},[n]),Vn=l(()=>{Xe(e=>{let t=!e;return $.info(`sidebarToggle`,{collapsed:t}),d.saveSidebarCollapsed(t),n.emit(`sidebarToggle`,{collapsed:t}),t})},[d,n]),Hn=l(e=>{$.info(`resize`,e),ct({widgetSize:e}),n.emit(`resize`,e)},[ct,n]),Un=l(async t=>{let i=t.conversationId;if(i===b.value&&jt(i)){$.info(`selectConversation`,{conversationId:i,cached:!0}),n.emit(`selectConversation`,{conversationId:i}),B.publishConversation(t),Ee(`chat`);let e=M();e&&P.switchTab(e),At(i);return}let a=++zt.current;Bt.current++,E(!1);function o(){return a!==zt.current}$.info(`selectConversation`,{conversationId:i,wasStreaming:je}),n.emit(`selectConversation`,{conversationId:i}),B.publishConversation(t);try{let[e,t]=await Promise.all([B.loadConversation(i),Rt(i)]);if(o())return;et.settle(),x.current=!0,fe.current=void 0;let n=Oi(e.messages),a=e.conversationId!==b.value,s=a?n:Yi(n,C.value);pe.current=s.some(e=>e.role===`user`)?void 0:e.conversationId,r(()=>{C.value=Ht(s,t),a&&(S.value=e.conversationId),b.value=e.conversationId}),k(t),d.saveConversationId(e.conversationId),B.primeIdentity(g,e.conversationId),ke(e.canContinue),e.controlState&&vt(e.controlState);let c=s.findLast(e=>e.role===`assistant`&&!e.ephemeral);He(c?.suggestions??[]),a?kt(e.conversationId):At(e.conversationId),Ee(`chat`);let l=M();l&&P.switchTab(l)}catch(t){if(o())return;n.emit(`error`,t),e.onError?.(t)}},[B,C,b,S,n,e,d,Rt,Ht,je,g,et,kt,At,jt,P]),Wn=l(e=>{if(typeof e!=`string`)return;R||Pn(),Ee(`chat`);let t=M();t&&P.switchTab(t),L?gn.fire(`manual`,e):wn.current=e},[R,Pn,e.modules,P,L,gn]),Gn=m(void 0),W=l(t=>{let n=e.modules.list.find(e=>e.layout===np[t.to]);if(!n){$.warn(`open: the widget has no such tab`,{to:t.to});return}let r=t.id&&(n.layout===`help`||n.layout===`news`)?{kind:`content`,id:t.id,title:``}:void 0;P.open(n.id,r)},[e.modules,P]),Kn=l(e=>{R||Pn(),e!==void 0&&(qt(e)?F?W(e):Gn.current=e:$.warn(`open: unknown target`,{detail:e}))},[R,Pn,F,W]);u(()=>{F&&Gn.current&&(W(Gn.current),Gn.current=void 0)},[F,W]);let qn=F&&!T&&!vn&&(!H||!An.value&&!U.value),[Jn,Yn]=h(),Xn=l(e=>{let t=Xt(e);t?(R||Pn(),Yn(t)):$.warn(`ask: expected { text, send? } with non-empty text`,{detail:e})},[R,Pn]),Zn=R&&L&&Oe&&F&&!T&&!vn,Qn=Zn&&qn&&!Ie&&!(H&&(je||kn));u(()=>{if(Jn===void 0||!(Jn.send?Qn:Zn))return;let e=M();e?Te!==`chat`||!ee()?(Ee(`chat`),P.switchTab(e)):(Yn(void 0),Jn.send?En(Jn.text,[]).then(e=>{e||Ft.current?.fill(Jn.text)}):Ft.current?.fill(Jn.text)):($.warn(`ask: the widget has no chat`),Yn(void 0))},[Jn,Zn,Qn,Te,ne,e.modules,P,En]),u(()=>{if(e.widgetId!=="default")return;let n=`data-${N.cssPrefix}-`,r=[`ask`,`open`,`close`,`form`].map(e=>n+e);function i(e){let i=e.composedPath().find(e=>e instanceof Element&&r.some(t=>e.hasAttribute(t)));if(!(i instanceof Element))return;e.preventDefault();let a=i.getAttribute(`${n}ask`),o=i.getAttribute(`${n}open`),s=i.getAttribute(`${n}form`);a===null?o===null?s===null?Qt(t,`close`):Qt(t,`openForm`,s):Qt(t,`open`,Jt(o)):Qt(t,`ask`,Yt(a||(i.textContent??``),{send:i.hasAttribute(`${n}send`)}))}return document.addEventListener(`click`,i),()=>document.removeEventListener(`click`,i)},[e.widgetId,t]),u(()=>{if(e.widgetId!=="default")return;let n=tn(location.href);n&&(history.replaceState(history.state,``,n.url),n.ask?Qt(t,`ask`,Yt(n.ask)):Qt(t,`open`,n.target))},[e.widgetId,t]);let $n=m(on),er=e.mode===`page`||e.mode===`inline`||e.mode===`standalone`;u(()=>a(()=>{let e=b.value,t={open:er||R,ready:F,unread:Et.value,...e?{conversationId:e}:{}},r=$n.current;(t.open!==r.open||t.ready!==r.ready||t.unread!==r.unread||t.conversationId!==r.conversationId)&&($n.current=t,n.emit(`state`,t),t.unread!==r.unread&&n.emit(`unread`,t.unread))}),[n,er,R,F,Et,b]);let tr=m({handleOpenCommand:Kn,handleClose:Nn,handleExpand:Rn,handleFullscreen:zn,openForm:Wn,handleAskCommand:Xn});tr.current={handleOpenCommand:Kn,handleClose:Nn,handleExpand:Rn,handleFullscreen:zn,openForm:Wn,handleAskCommand:Xn},f(()=>$t(t,{open:e=>tr.current.handleOpenCommand(e),close:()=>tr.current.handleClose(),expand:()=>tr.current.handleExpand(),fullscreen:()=>tr.current.handleFullscreen(),openForm:e=>tr.current.openForm(e),ask:e=>tr.current.handleAskCommand(e)}),[t]);let nr=p(()=>Le(e,tt,nt,rt),[e,tt,nt,rt]);Ue.current=nr.strings;let rr=p(()=>O.map(e=>{let t=hn.list.find(t=>t.id===e.formId);return{...e,title:t?.title,form:t}}),[O,hn]);function ir(e){Un(e)}let ar={options:nr,transport:B,feedback:$e,bus:n,persistence:d,conversationId:b.value??``,composerKey:S.value,composerApiRef:Ft,view:Te,canSend:Oe,isStreaming:je,pageToolRunning:dn,isMemoryCompacting:kn,canReleaseQueuedMessages:qn,queueManualMessages:H&&(An.value||U.value),sendPreparing:Ie,composerActive:nr.mode===`page`||nr.mode===`inline`||nr.mode===`standalone`||R,controlMode:mt.value,assignedOperatorInitials:ht.value,operatorAvailable:_t.value,operatorRequestEnabled:e.features.operatorRequest,onRequestOperator:xt,onCancelOperatorRequest:St,loadingMessages:T,onLoadPreviousMessages:Kt,messagesSig:C,reconnectingSig:w,agent:ze,suggestions:Ve,initialWidgetSize:y.widgetSize??null,onClose:Nn,onClear:Fn,onExpand:Rn,onFullscreen:zn,onSoundToggle:ft,onToggleHistory:Bn,onSelectHistoryConversation:ir,onNewConversation:In,onLocaleChange:lt,onThemeChange:ut,onTextSizeChange:dt,onWidgetSizeChange:Hn,onSend:En,onStop:jn,onSuggestion:t=>{if(Fe.current)return;let r=t.text??t.label;$.info(`suggestion`,{text:r,autoSend:e.autoSendSuggestions}),n.emit(`suggestion`,{text:r}),e.autoSendSuggestions?En(r,[]):Ft.current?.fill(r)},activeForm:_n.value?.form??null,formMarkers:rr,onFormSubmit:gn.complete,onFormSkip:gn.skip,onFormFill:e=>gn.fire(`manual`,e),tool:un,onRetry:Mn,onMessageFeedback:pn};if(!F)return null;let or=nr.modules.list;function sr(e){let t=Na(`close`,nr.mode,e);return or.length===0?/* @__PURE__ */ _(ef,{strings:nr.strings,onClose:t?Nn:void 0}):or.length===1&&or[0]?.layout===`chat`?/* @__PURE__ */ _(Hd,{...ar,panelSize:e}):/* @__PURE__ */ _(Qd,{panelProps:{...ar,panelSize:e,onClose:t?Nn:void 0},enabledModules:or,nav:P,bus:n,hasUnread:Tt.value,latestNews:Pt,onSelectConversation:ir,onStartNewConversation:Ln,onSetPanelSize:Ce})}if(e.mode===`page`){let t=e.history.enabled&&or.some(e=>e.layout===`chat`);return/* @__PURE__ */ _(`div`,{class:`${tp}-anchor`,children:/* @__PURE__ */ _(cf,{site:Ge,blocks:qe,transport:B,strings:nr.strings,locale:nr.locale,persistence:d,showConversations:t,onSelectConversation:ir,onNewConversation:In,sidebarCollapsed:Ye,onToggleSidebarCollapsed:Vn,children:sr(`fullscreen`)})})}if(se){let t=e.mode===`standalone`?`fullscreen`:Se;return/* @__PURE__ */ _(`div`,{class:`${tp}-anchor`,children:sr(t)})}let cr=e.mode===`drawer`,lr=e.mode!==`modal`&&!e.launcher.hidden&&(!R||ge),ur=lr&&!ge&&!ve&&!cr?nr.launcher.callout:null;return/* @__PURE__ */ v(`div`,{class:`${tp}-anchor`,"data-launcher-size":nr.launcher.size,children:[R||ue?/* @__PURE__ */ _(`div`,{class:`${tp}-surface`,hidden:!R,children:sr(Se)}):null,lr?/* @__PURE__ */ _(is,{onToggle:Pn,launcher:nr.launcher,strings:nr.strings,leaving:ge,edgeTab:cr}):null,ur?/* @__PURE__ */ _(cs,{callout:ur,launcherPosition:nr.position,strings:nr.strings,closeLabel:nr.strings.close,onDismiss:xe}):null]})}function ap(e){let t=e?.url??(typeof location<`u`?location.href:void 0);if(e||t)return{...e,...t?{url:t}:{}}}const op=120;async function sp(e,t,n,r){return(await Promise.all(t.map(async t=>{try{let{id:r,url:i,originalName:a,mimeType:o,fileSize:s}=await e.uploadFile(t.file,n);return{id:r,name:a,mediaType:o,size:s,url:i}}catch(e){r(e);return}}))).filter(e=>e!==void 0)}const cp=z.scope(`error-boundary`);var lp=class extends e{constructor(...e){super(...e),V(this,`state`,{crashed:!1})}componentDidCatch(e,t){cp.error(`widget render crashed`,{error:e,componentStack:t?.componentStack}),this.setState({crashed:!0}),this.props.onError(e,t?.componentStack)}render(){return this.state.crashed?this.props.fallback:this.props.children}};function up(e){let{bus:r,host:i,appRoot:a,persistence:o,reportError:s}=e,c=e.initialRaw,l,u=Ce(c),d=!0,f=0,p=ft(r);function m(){u=Ce(l?ze(c,l):c)}function h(){Pt(i,Ft(u.mode));let e=o.loadUserPrefs().themeMode;Wt(i,e?{...u,themeMode:e}:u),d&&(Ut(i,dp(u)),d=!1)}function g(){h(),n(t(lp,{onError:s},t(ip,{key:f,bus:r,hostElement:i,options:u,recentHostEvents:p})),a)}r.on(`handshake`,e=>{e.config&&(e.config.storageVersion&&o.rememberStorageVersion(e.config.storageVersion),l=e.config,m(),g())});let _=Tt(r,{getOptions:()=>u,getVisitorId:()=>o.getVisitorId(),getConversationId:()=>o.loadConversationId()});function v(e={}){o.reset(),c={...c,userContext:void 0,userToken:void 0,...e},p.length=0,f+=1,d=!0,m(),g()}return{getOptions:()=>u,getUserOptions:()=>c,render:g,setUserOptions:e=>{c=e,m(),g()},patchUserOptions:e=>{let t=`userToken`in e&&e.userToken!==c.userToken;t&&c.userToken?v(e):(t&&(f+=1),c={...c,...e},m(),g())},reset:()=>v(),destroy:()=>_()}}function dp(e){if(e.mode===`standalone`)return`standalone`;if(e.mode===`inline`)return`inline`;let t=gt(e.widgetId,e.storage,e.aiAgentDeploymentId),{panelOpen:n,panelSize:r}=Ya(e,Xa(),t.loadPanelOpen(),t.loadPanelSize());return qa(e.mode,r,n)}var fp=class extends HTMLElement{constructor(...e){super(...e),V(this,`bus`,new sn),V(this,`widgetState`,on),V(this,`userToken`,void 0),V(this,`pageTools`,[]),V(this,`markReady`,()=>{}),V(this,`ready`,new Promise(e=>{this.markReady=e})),V(this,`mountResult`,null),V(this,`runtime`,null)}static get observedAttributes(){return at}connectedCallback(){if(Object.hasOwn(this,`tools`)){let e=Reflect.get(this,`tools`);Reflect.deleteProperty(this,`tools`),this.pageTools=Array.isArray(e)?e:[]}this.boot()}disconnectedCallback(){this.mountResult&&(this.runtime?.destroy(),this.runtime=null,n(null,this.mountResult.appRoot),this.bus.clear(),this.widgetState=on)}attributeChangedCallback(){this.isConnected&&this.boot()}open(e){Qt(this,`open`,e)}close(){Qt(this,`close`)}expand(){Qt(this,`expand`)}openForm(e){Qt(this,`openForm`,e)}ask(e,t){Qt(this,`ask`,Yt(e,t))}get state(){return this.widgetState}reset(){this.userToken=void 0,this.runtime?.reset()}login(e){this.userToken=e,this.runtime?.patchUserOptions({userToken:e})}track(e,t){let n=dt(e,t);n&&this.bus.emit(`hostEvent`,n)}get tools(){return this.pageTools}set tools(e){this.pageTools=e,this.runtime?.patchUserOptions({tools:e})}registerTool(e,t){Ul(e,t)}on(e,t){return this.bus.on(e,t)}boot(){let e={...ot(e=>this.getAttribute(e)),...this.userToken?{userToken:this.userToken}:{},tools:this.pageTools};if(!e.aiAgentDeploymentId)throw Error(`ai-agent-deployment-id is required`);if(this.runtime){this.runtime.setUserOptions(e);return}let t=Ce(e);this.mountResult??(this.mountResult=It({existingHost:this,position:Ft(t.mode)}));let n=gt(t.widgetId,t.storage,t.aiAgentDeploymentId);this.bus.on(`state`,e=>{this.widgetState=e,e.ready&&this.markReady()}),this.runtime=up({bus:this.bus,host:this.mountResult.hostElement,appRoot:this.mountResult.appRoot,persistence:n,initialRaw:e,reportError:e=>this.bus.emit(`error`,e)}),this.runtime.render()}};let pp=!1;function mp(){if(pp||typeof customElements>`u`)return;let e=N.tagName;customElements.get(e)||customElements.define(e,fp),pp=!0}typeof customElements<`u`&&mp();export{mp as registerWebComponent};
|
|
34
|
+
`).trim(),N=!w&&t!==`error`&&!y.value&&M.length>0,ee=o?$u(g,{showReasoning:a,showSources:s}):g.map((e,t)=>({kind:`part`,part:e,index:t})),te=nd(g),P=e.canceled===!0||t===`error`,ne=e.canceled===!0&&!w&&C.value&&x.value,re=ee.at(-1),F=re?.kind===`steps`?re.indices.at(-1):re?.index;function I(r,i){return/* @__PURE__ */ _(bd,{part:r,generativeUi:e.role===`assistant`,live:T,current:T&&i===F,reasoningMs:e.stepTimings?.[te[i]??-1]?.reasoningMs,strings:n,showReasoning:a,showToolCalls:o,showSources:s,interactive:c&&t===`complete`&&(r.kind!==`tool`||Vi(e,i)),superseded:l,continuationStreaming:e.continuationStreaming===!0,stopped:P,tool:u},`${Ed(r)}#${i}`)}let ie=j||N;return/* @__PURE__ */ _(`div`,{class:`${Q}-bubble-row`,"data-role":e.role,"data-testid":ns(J.messageBubble,e.serverMessageId??e.id),children:/* @__PURE__ */ v(`div`,{class:`${Q}-bubble-col`,children:[/* @__PURE__ */ v(`div`,{class:`${Q}-bubble`,children:[e.role===`operator`&&e.operatorInitials?/* @__PURE__ */ _(`span`,{class:`${Q}-bubble-author`,children:e.operatorInitials}):null,/* @__PURE__ */ v(`div`,{class:`${Q}-bubble-body`,children:[D?/* @__PURE__ */ _(Od,{label:n.loading}):ee.flatMap((t,r)=>t.kind===`part`?[I(t.part,t.index)]:t.parts.some(e=>e.kind===`tool`)?[/* @__PURE__ */ _(cd,{parts:t.parts,steps:t.indices.map(e=>te[e]??-1),stepTimings:e.stepTimings,timed:!P,strings:n,live:T,running:T&&r===ee.length-1,stopped:P&&r===ee.length-1,runStartedAt:e.runStartedAt},`steps#${t.indices[0]}`)]:t.parts.map((e,n)=>I(e,t.indices[n]??n))),ne?/* @__PURE__ */ v(`div`,{class:`${Q}-steps-row`,"data-status":`stopped`,"data-testid":J.replyStopped,children:[/* @__PURE__ */ _(`span`,{class:`${Q}-steps-row-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(ao,{})}),/* @__PURE__ */ _(`div`,{class:`${Q}-steps-row-main`,children:/* @__PURE__ */ _(`span`,{class:`${Q}-steps-stopped-label`,children:n.statusStopped})})]}):null,O&&!h&&/* @__PURE__ */ _(Dd,{}),t===`error`||y.value?/* @__PURE__ */ _(Td,{text:wd(e,t,n),retryLabel:n.errorRetry,onRetry:d?()=>d(e):void 0}):null,h&&T?/* @__PURE__ */ _(Td,{text:n.errorReconnecting}):null]})]}),k||ie?/* @__PURE__ */ v(`div`,{class:`${Q}-bubble-meta`,children:[k?/* @__PURE__ */ _(`time`,{class:`${Q}-bubble-time`,dateTime:k.iso,title:k.full,children:k.short}):null,ie?/* @__PURE__ */ v(`div`,{class:`${Q}-bubble-actions`,children:[j&&e.serverMessageId?/* @__PURE__ */ _(gl,{messageId:e.serverMessageId,initial:e.feedback??null,strings:n,onFeedback:m}):null,N?/* @__PURE__ */ _(vd,{text:M,strings:n}):null]}):null]}):null]})})}function vd({text:e,strings:t}){let[n,r]=h(!1);function i(){navigator.clipboard?.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)}).catch(()=>{})}let a=n?t.copied:t.copy;return/* @__PURE__ */ _(`button`,{type:`button`,class:`${Q}-msg-action`,"data-active":n?`true`:void 0,"aria-label":a,title:a,onClick:i,"data-testid":J.messageCopy,children:_(n?bo:Ko,{})})}function yd(e){if(typeof e!=`number`||!Number.isFinite(e))return null;try{let t=new Date(e);return{short:t.toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`}),full:t.toLocaleString(void 0,{dateStyle:`full`,timeStyle:`short`}),iso:t.toISOString()}}catch{return null}}function bd({part:e,generativeUi:t,live:n,current:r,reasoningMs:i,strings:a,showReasoning:o,showToolCalls:s,showSources:c,interactive:l,superseded:u,continuationStreaming:d,stopped:f,tool:p}){switch(e.kind){case`step-start`:return null;case`text`:return/* @__PURE__ */ _(ms,{textSig:e.textSig,doneSig:e.doneSig,generativeUi:t,strings:a});case`reasoning`:return o?/* @__PURE__ */ _(hd,{part:e,current:r,reasoningMs:i,strings:a,standalone:!0}):null;case`tool`:return/* @__PURE__ */ _(Cd,{part:e,strings:a,showToolCalls:s,interactive:l,superseded:u,continuationStreaming:d,live:n,stopped:f,tool:p});case`file`:return/* @__PURE__ */ _(xd,{part:e,strings:a});case`source`:return c?/* @__PURE__ */ _(Ou,{part:e,strings:a}):null}}function xd({part:e,strings:t}){let n=e.filename??t.file;if(e.mediaType.startsWith(`image/`))return/* @__PURE__ */ _(`a`,{class:`${Q}-file-image`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,title:n,"data-testid":J.messageFile,children:/* @__PURE__ */ _(`img`,{src:e.url,alt:n,loading:`lazy`})});let r=(n.includes(`.`)?n.split(`.`).pop():e.mediaType.split(`/`).pop())?.toUpperCase(),i=e.fileSize===void 0?void 0:Sd(e.fileSize);return/* @__PURE__ */ v(`a`,{class:`${Q}-file-chip`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,title:n,"data-testid":J.messageFile,children:[/* @__PURE__ */ _(`span`,{class:`${Q}-file-chip-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(Eo,{})}),/* @__PURE__ */ v(`span`,{class:`${Q}-file-chip-text`,children:[/* @__PURE__ */ _(`span`,{class:`${Q}-file-chip-name`,children:n}),/* @__PURE__ */ _(`span`,{class:`${Q}-file-chip-meta`,children:[r,i].filter(Boolean).join(` · `)})]})]})}function Sd(e){let t=Math.min(Math.floor(Math.log10(Math.max(e,1))/3),2);return new Intl.NumberFormat(void 0,{style:`unit`,unit:[`byte`,`kilobyte`,`megabyte`][t],unitDisplay:`narrow`,maximumFractionDigits:1}).format(e/1e3**t)}function Cd({part:e,strings:t,showToolCalls:n,interactive:r,superseded:a,continuationStreaming:o,live:s,stopped:c,tool:l}){let u=p(()=>i(()=>e.approvalSig.value!==void 0),[e]),d=p(()=>i(()=>!Qu(e)),[e]);return!n&&!d.value?null:l?.humanInLoop&&u.value?e.toolMetadata?.card===`questions`?/* @__PURE__ */ _(Uu,{part:e,strings:t,active:r,superseded:a,continuationStreaming:o,onDecision:l.onDecision,onEdit:l.onEdit}):/* @__PURE__ */ _(ju,{part:e,strings:t,active:r,superseded:a,continuationStreaming:o,stopped:c,onDecision:l.onDecision,onEdit:l.onEdit}):n?/* @__PURE__ */ _(Zu,{part:e,strings:t,live:s,superseded:a,stopped:c}):null}function wd(e,t,n){return e.errorText?e.errorText:t===`error`&&e.role===`assistant`?n.errorServer:n.errorGeneric}function Td({text:e,retryLabel:t,onRetry:n}){return/* @__PURE__ */ v(`div`,{class:`${Q}-error`,role:`alert`,children:[/* @__PURE__ */ _(`span`,{class:`${Q}-error-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ _(es,{})}),/* @__PURE__ */ _(`span`,{class:`${Q}-error-text`,children:e}),n&&t?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Q}-error-retry`,onClick:n,"data-testid":J.messageRetry,children:t}):null]})}function Ed(e){switch(e.kind){case`text`:case`reasoning`:case`step-start`:return`${e.kind}:${e.id}`;case`tool`:return`tool:${e.toolCallId}`;case`file`:return`file:${e.url}`;case`source`:return`source:${e.sourceId}`}}function Dd(){return/* @__PURE__ */ v(`span`,{class:`${Q}-typing`,"data-testid":J.typingDots,"aria-hidden":`true`,children:[/* @__PURE__ */ _(`span`,{}),/* @__PURE__ */ _(`span`,{}),/* @__PURE__ */ _(`span`,{})]})}function Od({label:e}){return/* @__PURE__ */ v(`span`,{class:`${Q}-loading`,role:`status`,children:[/* @__PURE__ */ _(`span`,{class:`${Q}-loading-spinner`,"aria-hidden":`true`}),/* @__PURE__ */ _(`span`,{class:`${Q}-loading-label`,children:e})]})}const kd=N.cssPrefix;function Ad({messagesSig:e,reconnectingSig:t,strings:n,responseMode:r,showReasoning:i,showToolCalls:a,showSources:o,enableMessageFeedback:c,onFeedback:l,loading:d,onLoadPreviousMessages:p,idle:g,controlMode:y=`ai-agent`,tool:b,onRetry:x,form:S,formMarkers:C,onFillForm:w}){let T=m(null),E=s(()=>e.value),[D,O]=h(!1),[k,A]=h(!1),j=m(!1),M=m(!1),[N,ee]=h(),te=m(!1),P=m(!1),ne=m(!1),re=m(0);function F(){return ne.current||performance.now()-re.current<350}let I=m(0);function ie(e){let t=e.scrollHeight-e.clientHeight>1;e.dataset.fadeTop=t&&e.scrollTop>1?`true`:`false`,e.dataset.fadeBottom=t&&e.scrollHeight-e.scrollTop-e.clientHeight>1?`true`:`false`}function ae(e){return O(e.scrollHeight-e.scrollTop-e.clientHeight>240)}function L(e){I.current=performance.now(),e.scrollTop=e.scrollHeight,ie(e)}function oe(e,t){L(e);let n=t,r=0;function i(){P.current||F()||(L(e),--n>0&&(r=requestAnimationFrame(i)))}return t>0&&(r=requestAnimationFrame(i)),()=>cancelAnimationFrame(r)}function se(e,t){let n,r,i,a=-1;function o(){n.disconnect(),r.disconnect(),clearTimeout(i)}function s(){if(P.current||F()||a>=0&&e.scrollTop<a-4)return o();L(e),a=e.scrollTop}return n=new ResizeObserver(s),r=new MutationObserver(s),s(),n.observe(e),r.observe(e,{childList:!0,subtree:!0,characterData:!0}),i=setTimeout(o,t),o}let ce=E.value[0]?.id;f(()=>{let e=T.current;if(e&&E.value.length!==0&&!M.current&&(te.current=!0,E.value.some(e=>e.role===`user`)))return se(e,300)},[ce]);let R=m(0);u(()=>{let e=T.current,t=E.value,n=R.current;if(R.current=t.length,e&&te.current&&!M.current){if(t.slice(n).some(e=>e.role===`user`))return P.current=!1,oe(e,3);t.some(e=>e.role===`user`)&&(P.current||F()||e.scrollHeight-e.scrollTop-e.clientHeight<120&&L(e))}},[E.value.length]);let le=m(null);u(()=>{let e=T.current,t=E.value.at(-1),n=le.current;if(le.current=t?{id:t.id,streaming:t.status===`streaming`}:null,e&&te.current&&t&&t.id===n?.id&&!n.streaming&&t.status===`streaming`)return P.current=!1,oe(e,3)},[E.value]),u(()=>{let e=T.current;if(!e)return;let t=E.value.at(-1);if(!t||t.status!==`streaming`&&!E.value.some(e=>e.role===`user`))return;let n=()=>{P.current||F()||e.scrollHeight-e.scrollTop-e.clientHeight<240&&L(e)};if(t.status!==`streaming`)return se(e,300);n();let r=new MutationObserver(n);return r.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>r.disconnect()},[E.value]);let ue=S?.form.id,de=!!S&&(C??[]).some(e=>e.formId===S.form.id);f(()=>{let e=T.current;e&&ue&&!P.current&&E.value.some(e=>e.role===`user`)&&(de?e.querySelector(`[data-testid="${J.formGate}"]`)?.scrollIntoView({block:`nearest`}):L(e))},[ue,de]),u(()=>{let e=T.current;if(!e)return;let t=()=>{ae(e),ie(e),performance.now()-I.current>150&&(P.current=e.scrollHeight-e.scrollTop-e.clientHeight>8)};function n(){P.current=!0}function r(e){e.deltaY<0&&n()}let i=0;function a(e){i=e.touches[0]?.clientY??0,ne.current=!0}function o(e){(e.touches[0]?.clientY??0)>i+4&&n()}function s(){ne.current=!1,re.current=performance.now()}function c(){ne.current=!0}return e.addEventListener(`scroll`,t,{passive:!0}),e.addEventListener(`wheel`,r,{passive:!0}),e.addEventListener(`touchstart`,a,{passive:!0}),e.addEventListener(`touchmove`,o,{passive:!0}),e.addEventListener(`touchend`,s,{passive:!0}),e.addEventListener(`touchcancel`,s,{passive:!0}),e.addEventListener(`pointerdown`,c,{passive:!0}),window.addEventListener(`pointerup`,s,{passive:!0}),window.addEventListener(`pointercancel`,s,{passive:!0}),ae(e),()=>{e.removeEventListener(`scroll`,t),e.removeEventListener(`wheel`,r),e.removeEventListener(`touchstart`,a),e.removeEventListener(`touchmove`,o),e.removeEventListener(`touchend`,s),e.removeEventListener(`touchcancel`,s),e.removeEventListener(`pointerdown`,c),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)}},[]);function fe(){let e=T.current;e&&(P.current=!1,L(e))}let pe=E.value.filter(e=>!e.ephemeral),me=pe[0],z=me?.serverMessageId??me?.id,he=!!(p&&pe.length>=50&&z!==N);async function ge(){if(!p||j.current)return;let e=T.current,t=e?.scrollHeight??0,n=e?.scrollTop??0;j.current=!0,M.current=!0,A(!0);try{let r=await p();r===!1&&z&&ee(z),r&&e&&(await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e()))),e.scrollTop=n+e.scrollHeight-t,ie(e),ae(e))}finally{M.current=!1,j.current=!1,A(!1)}}let _e=[],ve=``,ye=E.value.at(-1)?.id,be=t?.value===!0,xe=[...C??[]].toSorted((e,t)=>(e.createdAt??1/0)-(t.createdAt??1/0));function Se(e){return S&&e.formId===S.form.id?/* @__PURE__ */ _(pl,{form:S.form,strings:n,onSubmit:S.onSubmit,onSkip:S.onSkip},`gate:${e.formId}`):/* @__PURE__ */ _(ml,{marker:e,strings:n,onFill:!S&&w?()=>w(e.formId):void 0},e.key)}function Ce(e){for(let t=xe[0];t?.createdAt!==void 0&&!(e!==void 0&&t.createdAt>e);t=xe[0])xe.shift(),_e.push(Se(t))}for(let e of E.value){if(e.role===`assistant`&&e.id!==ye&&na(e))continue;Ce(e.createdAt);let t=jd(e.createdAt);t&&t!==ve&&(_e.push(/* @__PURE__ */ _(`div`,{class:`${kd}-date-divider`,children:/* @__PURE__ */ _(`span`,{class:`${kd}-date-pill`,title:Md(e.createdAt),children:Nd(e.createdAt,n)})},`day:${t}`)),ve=t);let s=e.retryAction!==void 0||e.role===`assistant`&&e.id===ye?ra(E.value,e):void 0,u=s!==void 0&&(s.kind!==`continue-assistant`||y===`ai-agent`);_e.push(/* @__PURE__ */ _(gd,{message:e,status:e.status,strings:n,responseMode:r,showReasoning:i,showToolCalls:a,showSources:o,interactive:!!g&&y===`ai-agent`&&e.id===ye,superseded:e.id!==ye,tool:b,onRetry:g&&u&&(e.role===`user`||e.id===ye)?x:void 0,enableMessageFeedback:c,onFeedback:l,reconnecting:be&&e.id===ye},e.id))}for(let e of xe)_e.push(Se(e));return/* @__PURE__ */ v(`div`,{class:`${kd}-list-wrap`,children:[/* @__PURE__ */ v(`div`,{ref:T,class:`${kd}-list ${kd}-list--fade`,part:`messages`,role:`log`,"aria-live":`polite`,"aria-relevant":`additions text`,children:[d&&E.value.length===0?/* @__PURE__ */ _(`div`,{class:`${kd}-list-loading`,role:`status`,children:n.conversationLoading}):null,he?/* @__PURE__ */ _(`div`,{class:`${kd}-load-previous`,children:/* @__PURE__ */ _(`button`,{type:`button`,onClick:ge,disabled:k,"aria-busy":k,"data-testid":J.loadPreviousMessages,children:n.loadPreviousMessages})}):null,_e,S&&!de?/* @__PURE__ */ _(pl,{form:S.form,strings:n,onSubmit:S.onSubmit,onSkip:S.onSkip}):null]}),D?/* @__PURE__ */ _(`button`,{type:`button`,class:`${kd}-jump`,onClick:fe,"aria-label":n.scrollToBottom,title:n.scrollToBottom,"data-testid":J.scrollToBottom,children:/* @__PURE__ */ _(To,{})}):null]})}function jd(e){if(typeof e!=`number`||!Number.isFinite(e))return``;let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function Md(e){if(typeof e!=`number`||!Number.isFinite(e))return``;try{return new Date(e).toLocaleDateString(void 0,{dateStyle:`full`})}catch{return``}}function Nd(e,t){let n=new Date(e);function r(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}let i=Math.round((r(/* @__PURE__ */ new Date)-r(n))/864e5);return i<=0?t.dateToday:i===1?t.dateYesterday:i<7?n.toLocaleDateString(void 0,{weekday:`long`}):n.toLocaleDateString(void 0,{month:`long`,day:`numeric`,year:`numeric`})}function Pd({panelEl:e,resize:t,position:n,initialSize:r,onSizeChange:i,strings:a}){let o=N.cssPrefix,s=m(null);if(u(()=>{if(!e)return;let n=e.style;t.minWidth&&n.setProperty(`--${o}-resize-min-w`,t.minWidth),t.maxWidth&&n.setProperty(`--${o}-resize-max-w`,t.maxWidth),t.minHeight&&n.setProperty(`--${o}-resize-min-h`,t.minHeight),t.maxHeight&&n.setProperty(`--${o}-resize-max-h`,t.maxHeight),r&&(n.setProperty(`--${o}-widget-w`,`${r.width}px`),n.setProperty(`--${o}-widget-h`,`${r.height}px`))},[e,t.minWidth,t.maxWidth,t.minHeight,t.maxHeight,o,r]),!e)return null;let c=n.startsWith(`top-`),l=n.endsWith(`-right`),d=`${o}-resize-grip ${o}-resize-grip--${c?`bottom`:`top`}-${l?`left`:`right`}`;function f(t){if(!e)return;let n=t.currentTarget,r=e.getBoundingClientRect();s.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startW:r.width,startH:r.height,dirX:l?-1:1,dirY:c?1:-1},n.setPointerCapture(t.pointerId),e.setAttribute(`data-resizing`,``),t.preventDefault()}function p(t){let n=s.current;if(!n||t.pointerId!==n.pointerId||!e)return;let r=(t.clientX-n.startX)*n.dirX,i=(t.clientY-n.startY)*n.dirY;e.style.setProperty(`--${o}-widget-w`,`${n.startW+r}px`),e.style.setProperty(`--${o}-widget-h`,`${n.startH+i}px`)}function h(t){let n=s.current;if(!n||t.pointerId!==n.pointerId||!e)return;t.currentTarget.releasePointerCapture(t.pointerId),e.removeAttribute(`data-resizing`);let r=e.getBoundingClientRect();i({width:Math.round(r.width),height:Math.round(r.height)}),s.current=null}return/* @__PURE__ */ _(`div`,{class:d,role:`separator`,"aria-orientation":`vertical`,"aria-label":a.resizeHandle,title:a.resizeHandle,onPointerDown:f,onPointerMove:p,onPointerUp:h,onPointerCancel:h,"data-testid":J.resizeGrip,children:/* @__PURE__ */ _(mo,{})})}const Fd=N.cssPrefix;function Id({suggestions:e,onPick:t,disabled:n=!1}){let r=m(null),[i,a]=h({start:!1,end:!1});return u(()=>{let e=r.current;if(!e)return;function t(){if(!e)return;let t=Math.abs(e.scrollLeft),n=t>1,r=t<e.scrollWidth-e.clientWidth-1;a(e=>e.start===n&&e.end===r?e:{start:n,end:r})}t(),e.addEventListener(`scroll`,t,{passive:!0});let n=typeof ResizeObserver>`u`?void 0:new ResizeObserver(t);return n?.observe(e),()=>{e.removeEventListener(`scroll`,t),n?.disconnect()}},[e]),e.length===0?null:/* @__PURE__ */ _(`div`,{ref:r,class:`${Fd}-suggestions`,role:`group`,"aria-label":`Suggested replies`,"data-cut-start":i.start?`true`:void 0,"data-cut-end":i.end?`true`:void 0,children:e.map((e,r)=>/* @__PURE__ */ _(`button`,{type:`button`,class:`${Fd}-suggestion`,onClick:()=>t(e),disabled:n,"data-testid":ns(J.suggestion,r),children:e.label},e.id))})}const Ld=N.cssPrefix,Rd=`.${Ld}-header, .${Ld}-back-header, .${Ld}-home-hero`;function zd(e,t){u(()=>{if(!t||!e)return;function n(e){return Number.parseFloat(e)||0}function r(e,t){return Math.min(t,Math.max(-t,e))}let i=null,a=t=>{let r=t.target;if(!(r instanceof Element)||!r.closest(Rd)||r.closest(`button, a, input, textarea, select, [role="tab"], [contenteditable]`))return;let a=e.getBoundingClientRect();i={id:t.pointerId,x:t.clientX,y:t.clientY,dx:n(e.style.getPropertyValue(`--${Ld}-modal-dx`)),dy:n(e.style.getPropertyValue(`--${Ld}-modal-dy`)),maxX:(window.innerWidth+a.width)/2-56,maxY:(window.innerHeight+a.height)/2-56},e.dataset.dragging=`true`,t.preventDefault()},o=t=>{if(!i||t.pointerId!==i.id)return;let n=r(i.dx+t.clientX-i.x,i.maxX),a=r(i.dy+t.clientY-i.y,i.maxY);e.style.setProperty(`--${Ld}-modal-dx`,`${n}px`),e.style.setProperty(`--${Ld}-modal-dy`,`${a}px`)},s=t=>{i&&t.pointerId===i.id&&(i=null,delete e.dataset.dragging)};return e.addEventListener(`pointerdown`,a),window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s),()=>{e.removeEventListener(`pointerdown`,a),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)}},[e,t])}function Bd({containerRef:e,onDrop:t,disabled:n=!1}){let[r,i]=h(!1);return u(()=>{if(n){i(!1);return}let r=e.current;if(!r)return;let a=0;function o(e){a+=1,e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),i(!0))}function s(){--a,!(a>0)&&(a=0,i(!1))}function c(e){e.dataTransfer?.types.includes(`Files`)&&e.preventDefault()}function l(e){a=0,i(!1),e.dataTransfer&&(e.preventDefault(),t(e.dataTransfer.items))}return r.addEventListener(`dragenter`,o),r.addEventListener(`dragleave`,s),r.addEventListener(`dragover`,c),r.addEventListener(`drop`,l),()=>{r.removeEventListener(`dragenter`,o),r.removeEventListener(`dragleave`,s),r.removeEventListener(`dragover`,c),r.removeEventListener(`drop`,l)}},[e,n,t]),{visible:!n&&r}}const Vd=N.cssPrefix;function Hd(e){let{options:t,onClose:n}=e,r=t.strings,i=m(null);u(()=>{let e=i.current;if(!e)return;let t=us(e);function r(e){e.key===`Escape`&&n?.()}return e.addEventListener(`keydown`,r),()=>{t(),e.removeEventListener(`keydown`,r)}},[n]);let a=e.composerApiRef,o=e.composerActive&&e.view===`chat`&&e.canSend&&!e.activeForm?.blocking&&!e.sendPreparing&&e.options.features.fileUpload,{visible:s}=Bd({containerRef:i,onDrop:l(e=>{o&&a.current?.attachFromDrop(e)},[a,o]),disabled:!o});return zd(i.current,t.mode===`modal`),/* @__PURE__ */ v(`div`,{ref:i,class:`${Vd}-panel`,part:`panel`,role:`dialog`,"aria-modal":`false`,"aria-label":r.panelTitle,style:{position:`relative`},"data-testid":J.panel,children:[/* @__PURE__ */ _(Ud,{...e,containerEl:i.current,dragOver:s}),/* @__PURE__ */ _(Yd,{poweredBy:e.options.poweredBy})]})}function Ud(e){let{options:t,transport:n,feedback:r,bus:i,persistence:a,conversationId:o,composerKey:c,panelSize:l,view:u,canSend:d,isStreaming:f,isMemoryCompacting:p,canReleaseQueuedMessages:m,queueManualMessages:h,sendPreparing:y,controlMode:b,assignedOperatorInitials:x,operatorAvailable:S,operatorRequestEnabled:C,onRequestOperator:w,onCancelOperatorRequest:T,loadingMessages:E,onLoadPreviousMessages:D,messagesSig:O,reconnectingSig:k,agent:A,suggestions:j,initialWidgetSize:M,onClose:N,onBack:ee,onClear:te,onToggleHistory:P,onSelectHistoryConversation:ne,onNewConversation:re,onWidgetSizeChange:F,onSend:I,onStop:ie,onSuggestion:ae,activeForm:L,formMarkers:oe,onFormSubmit:se,onFormSkip:ce,onFormFill:R,tool:le,onRetry:ue,onMessageFeedback:de,containerEl:fe,dragOver:pe,composerApiRef:me}=e,z=t.strings,he=s(()=>O.value.some(e=>!e.ephemeral&&e.role!==`system`)).value,ge;return ge=L?.blocking?null:d?/* @__PURE__ */ v(g,{children:[b&&b!==`ai-agent`?/* @__PURE__ */ _(Kd,{controlMode:b,operatorInitials:x,operatorAvailable:S,onCancelOperatorRequest:T,strings:z}):null,p&&b===`ai-agent`?/* @__PURE__ */ v(`div`,{class:`${Vd}-loading ${Vd}-compaction-status`,role:`status`,"data-testid":J.compactionStatus,children:[/* @__PURE__ */ _(`span`,{class:`${Vd}-loading-spinner`,"aria-hidden":`true`}),z.compactingContext]}):null,!f&&!p&&b===`ai-agent`&&/* @__PURE__ */ _(Id,{suggestions:j,onPick:ae,disabled:y}),/* @__PURE__ */ _(vc,{options:t,transport:n,feedback:r,bus:i,persistence:a,conversationId:o,isStreaming:f,pageToolRunning:e.pageToolRunning,isMemoryCompacting:p,canReleaseQueuedMessages:m,queueManualMessages:h,active:e.composerActive&&u===`chat`,isPreparing:y,operatorRequestEnabled:C,canRequestOperator:he,controlMode:b,onRequestOperator:w,onSend:I,onStop:ie,apiRef:me},c)]}):/* @__PURE__ */ _(Gd,{label:z.conversationClosed,ctaLabel:z.startNewConversation,onNewConversation:te}),/* @__PURE__ */ v(g,{children:[u===`history`?/* @__PURE__ */ _(Wd,{strings:z,onBack:P,onClose:N,showClose:Pa(t.mode,l,t.actions)}):/* @__PURE__ */ v(`header`,{class:`${Vd}-header`,part:`header`,"data-testid":J.panelHeader,children:[ee?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Vd}-icon-btn`,onClick:ee,"aria-label":z.moduleBack,title:z.moduleBack,children:/* @__PURE__ */ _(Co,{})}):null,A?/* @__PURE__ */ _(zc,{agent:A,strings:z}):/* @__PURE__ */ _(`h1`,{children:z.panelTitle}),/* @__PURE__ */ _(Ps,{panelProps:e,variant:`chat`})]}),u===`history`?/* @__PURE__ */ _(Jc,{transport:n,strings:z,locale:t.locale,persistence:a,onSelect:ne,onNewConversation:re}):/* @__PURE__ */ v(g,{children:[/* @__PURE__ */ _(Xc,{visible:pe,strings:z}),/* @__PURE__ */ _(Ad,{messagesSig:O,reconnectingSig:k,strings:z,responseMode:t.responseMode,showReasoning:t.showReasoning,showToolCalls:t.showToolCalls,showSources:t.showSources,enableMessageFeedback:t.enableMessageFeedback,onFeedback:de,loading:E,onLoadPreviousMessages:D,idle:!f&&!y&&d&&!L?.blocking,controlMode:b,tool:le,onRetry:ue,form:L?{form:L,onSubmit:se,onSkip:ce}:null,formMarkers:oe,onFillForm:R}),ge,/* @__PURE__ */ _(Jd,{disclaimer:t.composerDisclaimer})]}),t.size.resize?.enabled?/* @__PURE__ */ _(Pd,{panelEl:fe,resize:t.size.resize,position:t.position,initialSize:M,onSizeChange:F,strings:z}):null]})}function Wd({strings:e,onBack:t,onClose:n,showClose:r}){return/* @__PURE__ */ v(`header`,{class:`${Vd}-header`,part:`header`,children:[/* @__PURE__ */ _(`button`,{type:`button`,class:`${Vd}-icon-btn`,onClick:t,"aria-label":e.historyBack,title:e.historyBack,children:/* @__PURE__ */ _(Co,{})}),/* @__PURE__ */ _(`h1`,{children:e.historyTitle}),r?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Vd}-icon-btn`,onClick:n,"aria-label":e.close,title:e.close,children:/* @__PURE__ */ _($a,{})}):null]})}function Gd({label:e,ctaLabel:t,onNewConversation:n}){return/* @__PURE__ */ v(`div`,{class:`${Vd}-readonly-banner`,role:`note`,children:[/* @__PURE__ */ _(`span`,{class:`${Vd}-readonly-label`,children:e}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${Vd}-readonly-cta`,onClick:n,children:t})]})}function Kd({controlMode:e,operatorInitials:t,operatorAvailable:n,onCancelOperatorRequest:r,strings:i}){let a=qd(e,t,n,i);return/* @__PURE__ */ v(`div`,{class:`${Vd}-operator-banner`,role:`status`,"data-mode":e,"data-testid":J.operatorBanner,children:[/* @__PURE__ */ _(`span`,{class:`${Vd}-operator-pulse`,"aria-hidden":`true`}),/* @__PURE__ */ _(`span`,{class:`${Vd}-operator-label`,children:a}),e===`awaiting-operator`&&r?/* @__PURE__ */ _(`button`,{type:`button`,class:`${Vd}-cancel-operator-request`,"data-testid":J.cancelOperatorRequest,onClick:r,children:i.cancelOperatorRequest}):null]})}function qd(e,t,n,r){return e===`operator`?r.chattingWithOperator.replace(`{operator}`,t??``):n===!1?r.noOperatorAvailable:r.connectingOperator}function Jd({disclaimer:e}){return e?/* @__PURE__ */ _(`div`,{class:`${Vd}-composer-footer`,children:/* @__PURE__ */ _(`div`,{class:`${Vd}-disclaimer`,children:e})}):null}function Yd({poweredBy:e}){return e?/* @__PURE__ */ _(`div`,{class:`${Vd}-poweredby-bar`,children:/* @__PURE__ */ _(Xd,{logoUrl:e.logoUrl,text:e.text,href:e.href})}):null}function Xd({logoUrl:e,text:t,href:n}){let r=/* @__PURE__ */ v(g,{children:[e?/* @__PURE__ */ _(`img`,{class:`${Vd}-poweredby-logo`,src:e,alt:``,loading:`lazy`}):null,t?/* @__PURE__ */ _(`span`,{children:t}):null]});return n?/* @__PURE__ */ _(`a`,{class:`${Vd}-poweredby`,href:n,target:`_blank`,rel:`noopener noreferrer`,children:r}):/* @__PURE__ */ _(`span`,{class:`${Vd}-poweredby`,children:r})}const Zd=N.cssPrefix;function Qd({panelProps:e,enabledModules:t,nav:n,bus:r,hasUnread:i,latestNews:a,onSelectConversation:o,onStartNewConversation:c,onSetPanelSize:d}){let f=e.options,p=f.strings,h=m(null),g=m(/* @__PURE__ */ new Set);u(()=>{let t=h.current;if(!t)return;let n=us(t);function r(t){t.key===`Escape`&&e.onClose?.()}return t.addEventListener(`keydown`,r),()=>{n(),t.removeEventListener(`keydown`,r)}},[e.onClose]);let y=s(()=>n.sig.value).value,b=Ga(y),x=f.modules.byId[y.activeTab],S=e.composerActive&&x?.layout===`chat`&&b===void 0,C=e.composerApiRef,w=S&&e.view===`chat`&&e.canSend&&!e.activeForm?.blocking&&!e.sendPreparing&&e.options.features.fileUpload,{visible:T}=Bd({containerRef:h,onDrop:l(e=>{w&&C.current?.attachFromDrop(e)},[C,w]),disabled:!w});zd(h.current,f.mode===`modal`);let E=b?.kind===`iframe`||b?.kind===`content`,D=t.length>1&&(Ka(y)||!E),O=m(null);u(()=>{if(E&&O.current===null)O.current=e.panelSize,e.panelSize===`normal`&&d(`expanded`);else if(!E&&O.current!==null){let e=O.current;O.current=null,d(e)}},[E]);let k={push:e=>n.push(e),pop:()=>n.pop(),switchTab:e=>n.switchTab(e),switchToLayout:e=>{let r=t.find(t=>t.layout===e);r&&n.switchTab(r.id)},selectConversation:o,startNewConversation:c};function A(t){return{options:f,transport:e.transport,strings:p,config:t,nav:k,bus:r,panelProps:e,latestNews:a}}let j=/* @__PURE__ */ _(Ps,{panelProps:e,variant:`plain`});x&&g.current.add(x.id);let M=t.filter(e=>g.current.has(e.id));function N(t){if(t.layout===`chat`)return/* @__PURE__ */ _(Ud,{...e,composerActive:S,containerEl:h.current,dragOver:T});let n=Nc[t.layout].Root;return n?/* @__PURE__ */ _(n,{...A(t)}):null}function ee(){return b?.kind===`iframe`?/* @__PURE__ */ _(Lc,{url:b.url,title:b.title,strings:p,onBack:()=>n.pop(),actions:j}):b?.kind===`content`?/* @__PURE__ */ _(Ts,{id:b.id,title:b.title,transport:e.transport,strings:p,bus:r,onBack:()=>n.pop(),actions:j}):null}return/* @__PURE__ */ v(`div`,{ref:h,class:`${Zd}-panel ${Zd}-messenger`,part:`panel`,role:`dialog`,"aria-modal":`false`,"aria-label":p.panelTitle,style:{position:`relative`},"data-testid":J.messengerHome,children:[/* @__PURE__ */ v(`div`,{class:`${Zd}-messenger-body`,children:[M.map(e=>/* @__PURE__ */ _(`div`,{class:`${Zd}-messenger-pane`,hidden:E||e.id!==x?.id,children:N(e)},e.id)),ee()]}),D?/* @__PURE__ */ _(Fc,{modules:t,activeTab:y.activeTab,strings:p,hasUnread:i,onSelect:e=>n.switchTab(e)}):null,/* @__PURE__ */ _(Yd,{poweredBy:f.poweredBy}),f.size.resize?.enabled&&(x?.layout!==`chat`||b)?/* @__PURE__ */ _(Pd,{panelEl:h.current,resize:f.size.resize,position:f.position,initialSize:e.initialWidgetSize,onSizeChange:e.onWidgetSizeChange,strings:p}):null]})}const $d=N.cssPrefix;function ef({strings:e,onClose:t}){return/* @__PURE__ */ v(`div`,{class:`${$d}-panel ${$d}-modules-empty`,part:`panel`,role:`dialog`,"aria-label":e.panelTitle,"data-testid":J.modulesEmpty,children:[t?/* @__PURE__ */ _(`button`,{type:`button`,class:`${$d}-icon-btn ${$d}-modules-empty-close`,onClick:t,"aria-label":e.close,title:e.close,children:/* @__PURE__ */ _($a,{})}):null,/* @__PURE__ */ _(`p`,{class:`${$d}-modules-empty-text`,children:e.modulesEmpty})]})}function tf(e){let t=N.cssPrefix,{site:n,blocks:r,strings:i,collapsed:a}=e,o=r?.navigation??[],s=r?.linkCards??[],c=a?i.expandSidebar:i.collapseSidebar;return/* @__PURE__ */ v(`aside`,{class:`${t}-sidebar`,"data-collapsed":a?`true`:`false`,"data-testid":J.sidebar,children:[/* @__PURE__ */ v(`div`,{class:`${t}-sidebar-header`,children:[/* @__PURE__ */ _(nf,{site:n}),/* @__PURE__ */ _(`button`,{type:`button`,class:`${t}-sidebar-toggle`,"aria-label":c,"aria-expanded":a?`false`:`true`,title:c,onClick:e.onToggleCollapsed,"data-testid":J.sidebarToggle,children:/* @__PURE__ */ _(rf,{collapsed:a})})]}),a?null:/* @__PURE__ */ v(g,{children:[o.length>0?/* @__PURE__ */ _(`nav`,{class:`${t}-sidebar-section`,"data-section":`navigation`,children:/* @__PURE__ */ _(af,{items:o})}):null,s.length>0?/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-section`,"data-section":`link-cards`,children:/* @__PURE__ */ _(of,{items:s})}):null,e.showConversations?/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-conversations`,children:/* @__PURE__ */ _(Jc,{transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,onSelect:e.onSelectConversation,onNewConversation:e.onNewConversation})}):null]})]})}function nf({site:e}){let t=N.cssPrefix;if(e?.logo?.url){let n=e.logo.alt??e.title??`Logo`;return/* @__PURE__ */ v(`picture`,{children:[e.logoDark?.url?/* @__PURE__ */ _(`source`,{srcset:e.logoDark.url,media:`(prefers-color-scheme: dark)`}):null,/* @__PURE__ */ _(`img`,{class:`${t}-sidebar-logo`,src:e.logo.url,alt:n})]})}return/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-title`,children:e?.title??N.name})}function rf({collapsed:e}){return/* @__PURE__ */ _(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"aria-hidden":`true`,children:e?/* @__PURE__ */ _(`polyline`,{points:`9 6 15 12 9 18`}):/* @__PURE__ */ _(`polyline`,{points:`15 6 9 12 15 18`})})}function af({items:e}){let t=N.cssPrefix;return/* @__PURE__ */ _(`ul`,{class:`${t}-sidebar-nav`,children:e.map(e=>/* @__PURE__ */ _(`li`,{children:/* @__PURE__ */ v(`a`,{class:`${t}-sidebar-nav-item`,href:e.href,target:e.href?`_blank`:void 0,rel:e.href?`noreferrer`:void 0,children:[e.icon?/* @__PURE__ */ _(`span`,{class:`${t}-sidebar-nav-icon`,"data-icon":e.icon}):null,/* @__PURE__ */ _(`span`,{class:`${t}-sidebar-nav-label`,children:e.label})]})},e.id??e.label))})}function of({items:e}){let t=N.cssPrefix;return/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-cards`,children:e.map(e=>/* @__PURE__ */ v(`a`,{class:`${t}-sidebar-card`,href:e.href,target:e.href?`_blank`:void 0,rel:e.href?`noreferrer`:void 0,children:[/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-card-label`,children:e.label}),e.description?/* @__PURE__ */ _(`div`,{class:`${t}-sidebar-card-desc`,children:e.description}):null]},e.id??e.label))})}const sf=N.cssPrefix;function cf(e){return/* @__PURE__ */ v(`main`,{class:`${sf}-page-shell`,"data-sidebar-collapsed":e.sidebarCollapsed?`true`:`false`,children:[/* @__PURE__ */ _(tf,{site:e.site,blocks:e.blocks,transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,showConversations:e.showConversations,onSelectConversation:e.onSelectConversation,onNewConversation:e.onNewConversation,collapsed:e.sidebarCollapsed,onToggleCollapsed:e.onToggleSidebarCollapsed}),/* @__PURE__ */ _(`section`,{class:`${sf}-page-chat`,"aria-label":e.strings.panelTitle,children:e.children})]})}const lf=z.scope(`hitl`);function uf(e){return e.kind===`tool`&&Xl(e.toolMetadata)&&(e.stateSig.value===`input-available`||e.stateSig.value===`approval-responded`&&e.approvalSig.value?.approved===!0)}function df(e,t){t.errorSig.value=nu(t.toolCallId),t.stateSig.value=`output-error`,e.partsSig.value=[...e.partsSig.value]}function ff(e,t){let n=e.slice(0,e.indexOf(t)).findLast(e=>e.role===`user`);return n!==void 0&&Pl.sentHere(n.id)}function pf(e){let{streaming:t,controlModeSig:n,messagesSig:r,sendAiTurn:i,bus:a,humanInLoop:o,tools:s}=e,c=m(t);c.current=t;let d=m(s);d.current=s;let f=m(/* @__PURE__ */ new Map),[g,_]=h(!1),v=l((e,t,a)=>{if(c.current||n.value!==`ai-agent`)return!1;let o=r.value.at(-1),s=o?.partsSig.value.findIndex(t=>t.kind===`tool`&&t.toolCallId===e)??-1,l=o?.partsSig.value[s];if(!o||l?.kind!==`tool`)return lf.warn(`decideTool: tool part not found`,{toolCallId:e}),!1;if(o.status!==`complete`||!Vi(o,s)||!t(l))return!1;if(a(l),o.partsSig.value=[...o.partsSig.value],!zi(o)||o.partsSig.value.some(uf))return!0;o.status=`streaming`,o.retryAction={kind:`continue-assistant`,messageId:o.serverMessageId??o.id},o.awaitingContinuation=!0,r.value=[...r.value];let u=o.partsSig.value.flatMap(e=>e.kind===`tool`?[e.toolCallId]:[]);return i({continueExisting:!0}).then(e=>e&&Pl.clear(u)),!0},[n,r,i]),y=l((e,t)=>{let{toolCallId:n,toolName:r}=t;f.current.has(n)||(f.current.set(n,e),_(!0),eu({toolCallId:n,toolName:r,input:t.inputSig.value,optionTools:d.current??[],onSettled:(e,t)=>{lf.info(`toolResult`,{toolCallId:n,status:e}),a.emit(`toolResult`,{toolCallId:n,name:Zl(r),status:e,durationMs:t})}}).then(e=>{f.current.delete(n)&&(_(f.current.size>0),v(n,uf,t=>{e.state===`output-available`?t.outputSig.value=e.output:t.errorSig.value=e.errorText,t.stateSig.value=e.state}))}))},[a,v]),b=l(()=>{let e=r.value;for(let[t,n]of f.current){let r=e.findIndex(e=>e.id===n);r<0||r===e.length-1||(f.current.delete(t),ru(t),_(f.current.size>0))}let t=e.at(-1);if(c.current||t?.role!==`assistant`||t.status!==`complete`)return;let n=t.partsSig.value.filter(e=>uf(e)&&e.stateSig.value===`input-available`);if(n.length!==0&&ff(e,t))for(let e of n)Pl.get(e.toolCallId)?.state===`stopped`?df(t,e):y(t.id,e)},[r,y]);u(()=>b(),[t,b]),u(()=>r.subscribe(()=>b()),[r,b]);let x=l((e,t,n)=>{let i=!1,o;if(!v(e,e=>e.stateSig.value===`approval-requested`,r=>{Xl(r.toolMetadata)&&(o=r),i=r.toolMetadata?.card===`questions`;let a=r.approvalSig.value?.id??e;r.approvalSig.value={id:a,approved:t,reason:n},r.stateSig.value=`approval-responded`}))return;let s=r.value.at(-1);o&&t&&s&&y(s.id,o),o&&!t&&a.emit(`toolResult`,{toolCallId:e,name:Zl(o.toolName),status:`declined`,durationMs:0}),i?(lf.info(`toolResult`,{toolCallId:e}),a.emit(`toolResult`,{toolCallId:e})):(lf.info(`toolDecision`,{toolCallId:e,approved:t}),a.emit(`toolDecision`,{toolCallId:e,approved:t}))},[a,v,r,y]),S=l(e=>{v(e,e=>e.stateSig.value===`approval-responded`&&e.approvalSig.value?.approved!==void 0&&!uf(e),t=>{let n=t.approvalSig.value?.id??e;t.approvalSig.value={id:n},t.stateSig.value=`approval-requested`})},[v]);return{toolInteraction:p(()=>({humanInLoop:o,onDecision:x,onEdit:S}),[o,x,S]),pageToolsRunning:g,stopPageTools:l(()=>{let e=r.value.at(-1);for(let t of f.current.keys()){let n=e?.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t);e&&n?df(e,n):nu(t),lf.info(`toolResult`,{toolCallId:t,status:`stopped`}),a.emit(`toolResult`,{toolCallId:t,name:n?Zl(n.toolName):void 0,status:`stopped`,durationMs:0})}f.current.clear(),_(!1)},[a,r])}}const mf=z.scope(`latest-news`);function hf({transport:e,options:t,persistence:n,enabled:r}){let i=t.modules.list.find(e=>e.layout===`news`)?.contentCollectionIds,a=i?.join(`,`),[o,s]=h(),[c,d]=h(()=>n.loadSeenNewsId());u(()=>{if(!r||!i?.length)return;let t=!1;return e.listContent({contentCollectionIds:i,sortBy:`publishedAt`,sortOrder:`desc`,limit:1}).then(e=>{t||s(e.items[0])}).catch(e=>mf.debug(`listContent (latest news) failed (non-fatal)`,{err:e})),()=>{t=!0}},[e,r,a]);let f=l(e=>{n.saveSeenNewsId(e),d(e)},[n]);return{item:o,unseen:o!==void 0&&o.id!==c,markSeen:f}}function gf({callout:e,persistence:t}){let n=e?.text??``,r=e?.persistent??!0,[i,a]=h(()=>!r&&t.loadCalloutDismissed(n));return u(()=>{a(!r&&t.loadCalloutDismissed(n))},[n,r,t]),{dismissed:i,dismissCallout:l(()=>{a(!0),r||t.saveCalloutDismissed(n)},[t,n,r])}}function _f(e){let{transport:t,conversationIdSig:n}=e,r=c(`ai-agent`),i=c(void 0),a=c(void 0),o=m(void 0),s=l(e=>{let t=e.controlRevision,s=o.current;s&&s.conversationId===n.value&&t<s.revision||(o.current={conversationId:n.value,revision:t},r.value=e.controlMode,i.value=e.assignedOperatorInitials,e.controlMode===`awaiting-operator`?e.operatorAvailable!==void 0&&(a.value=e.operatorAvailable):a.value=void 0)},[n,r,i,a]);return{controlModeSig:r,assignedOperatorInitialsSig:i,operatorAvailableSig:a,applyControlState:s,adoptControlStateChunk:l(e=>{if(e.type!==`data-control-state`)return;let t=fi(e.data);t&&s(t)},[s]),requestOperator:l(async()=>{let e=n.value,r=await t.requestOperator();r&&n.value===e&&s(r)},[t,n,s]),cancelOperatorRequest:l(async()=>{let e=n.value,r=await t.cancelOperatorRequest();r&&n.value===e&&s(r)},[t,n,s])}}const vf=N.cssPrefix,yf=`--${vf}-visual-viewport-height`,bf=`--${vf}-visual-viewport-top`;function xf(e){let{hostElement:t,mode:n,panelSize:r,isOpen:i,surfaceReady:a,setIsOpen:o}=e;f(()=>{Ut(t,qa(n,r,i))},[t,i,r,n]),f(()=>{if(!i||!a)return;let e=t.ownerDocument.defaultView,n=e?.visualViewport,r=t.shadowRoot?.querySelector(`.${vf}-anchor`);if(!e||!n||!r)return;let o=()=>{r.style.setProperty(yf,`${n.height}px`),r.style.setProperty(bf,`${n.offsetTop}px`)},s=0,c=()=>{e.cancelAnimationFrame(s),s=e.requestAnimationFrame(()=>{s=e.requestAnimationFrame(o)})};return o(),n.addEventListener(`resize`,c),n.addEventListener(`scroll`,c),()=>{e.cancelAnimationFrame(s),n.removeEventListener(`resize`,c),n.removeEventListener(`scroll`,c),r.style.removeProperty(yf),r.style.removeProperty(bf)}},[t,i,a]),u(()=>{if(n!==`modal`||!i)return;function e(e){e.composedPath().some(e=>e instanceof HTMLElement&&e.classList.contains(`${vf}-panel`))||o(!1)}return t.addEventListener(`click`,e),()=>t.removeEventListener(`click`,e)},[t,i,n,o]),u(()=>{if(n!==`drawer`||!i)return;function e(e){e.key===`Escape`&&o(!1)}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,n,o])}const Sf=z.scope(`reducer`);var Cf=class{constructor(e,t){this.messagesSig=e,this.onReconcileNeeded=t,V(this,`active`,null),V(this,`openTextParts`,/* @__PURE__ */ new Map),V(this,`partSeq`,0),V(this,`replay`,null)}attach(e){this.active=e,this.openTextParts.clear()}detach(){this.active=null,this.replay=null,this.openTextParts.clear()}beginReplay(e,t){let n=yi();n.id=e.id;let r=Tf(e)||Bi(e)&&(e.status!==`streaming`||zi(e)),i=e.status===`streaming`&&zi(e)&&Ri(e);this.replay={baseline:e,shadow:n,chunks:[t],probeContinuation:r,continuationTailReplay:i,liveCatchUp:e.status===`streaming`&&!r},this.attach(n),this.apply(t)}refreshReplayBaseline(){let e=this.replay;if(!e)return null;let t=e.shadow.serverMessageId??e.baseline.serverMessageId,n=this.messagesSig.value,r=n.at(-1),i=r===e.baseline||r?.id===e.baseline.id||t!==void 0&&r?.serverMessageId===t?r:n.find(t=>t===e.baseline)??n.find(n=>n.id===e.baseline.id||t!==void 0&&n.serverMessageId===t);if(!i)return this.detach(),null;if(i===e.baseline)return e;let a=e.baseline;return e.baseline=i,Ef(a,i),e.liveCatchUp&&Tf(e.shadow)&&(i.status===`streaming`||Bi(i))?(e.probeContinuation=!1,e.continuationTailReplay=!1,e):(e.probeContinuation=Tf(i)||Bi(i)&&(i.status!==`streaming`||zi(i)),e.continuationTailReplay=i.status===`streaming`&&zi(i)&&Ri(i),e.liveCatchUp=i.status===`streaming`&&!e.probeContinuation,e)}refreshActive(){let e=this.active;if(!e)return null;let t=e.serverMessageId,n=this.messagesSig.value,r=n.at(-1),i=r===e||r?.id===e.id||t!==void 0&&r?.serverMessageId===t?r:n.find(t=>t===e)??n.find(n=>n.id===e.id||t!==void 0&&n.serverMessageId===t);if(!i)return this.detach(),null;if(i===e)return e;Ef(e,i);let a=Tf(e)&&Bi(i);return i.status!==`streaming`&&!a?(this.detach(),null):(this.replay={baseline:i,shadow:e,chunks:[],probeContinuation:!1,continuationTailReplay:!1,liveCatchUp:!0},e)}promoteReplay(){let{baseline:e,shadow:t}=this.replay;return r(()=>{e.role=t.role,e.serverMessageId=t.serverMessageId,e.operatorInitials=t.operatorInitials,e.status=t.status,t.canceled&&(e.canceled=!0),e.finishReason=t.finishReason,e.errorText=t.errorText,e.suggestions=t.suggestions??e.suggestions,e.runStartedAt=t.runStartedAt??e.runStartedAt,e.stepTimings=t.stepTimings??e.stepTimings,e.partsSig.value=t.partsSig.value,this.messagesSig.value=[...this.messagesSig.value]}),this.replay=null,this.active=e,e}promoteContinuation(){let{baseline:e,chunks:t}=this.replay,n=Hi(e);return this.replay=null,r(()=>{e.partsSig.value=e.partsSig.value.slice(0,Df(e,t)+1),e.awaitingContinuation=!1,e.status=`streaming`,e.finishReason=void 0,e.errorText=void 0,e.suggestions=void 0,this.attach(e);for(let e of t)this.apply(e);e.continuationStreaming=n||void 0,this.messagesSig.value=[...this.messagesSig.value]}),e}settleOwnedContinuation(e){let{baseline:t}=this.replay,n=Hi(t);return this.replay=null,r(()=>{t.awaitingContinuation=!1,t.status=`streaming`,t.finishReason=void 0,t.errorText=void 0,t.suggestions=void 0,this.attach(t),this.apply(e),t.continuationStreaming=n||void 0,this.messagesSig.value=[...this.messagesSig.value]}),t}applyResume(e){if(e.type===`start`){let t=(this.replay?.baseline??this.active)?.serverMessageId;t!==void 0&&e.messageId!==void 0&&t!==e.messageId&&this.onReconcileNeeded?.({messageId:t}),this.detach();let n=e.messageId,r=n===void 0?void 0:this.messagesSig.value.find(e=>e.serverMessageId===n||e.id===n);if(r!==void 0)return e.messageMetadata?.senderRole===`visitor`&&r.role===`user`&&(r.status===`pending`||r.status===`error`)&&(r.serverMessageId=n,r.status=`complete`,r.errorText=void 0,r.retryAction=void 0,this.messagesSig.value=[...this.messagesSig.value]),this.beginReplay(r,e),null;let i=e.messageMetadata?.senderRole,a=this.messagesSig.value.at(-1);if(i===void 0&&a?.role===`assistant`&&a.status===`streaming`&&a.serverMessageId===void 0&&!Ni(a))return this.attach(a),this.apply(e),null;let o=yi();return this.attach(o),this.messagesSig.value=[...this.messagesSig.value,o],this.apply(e),null}if(this.replay){let t=this.refreshReplayBaseline();if(!t)return null;t.chunks.push(e),e.type===`data-control-state`&&(t.baseline.operatorRoutedTurn=e.data.controlMode!==`ai-agent`),this.apply(e);let{baseline:n,shadow:r,probeContinuation:i,continuationTailReplay:a,liveCatchUp:o}=t,s=e.type===`finish`||e.type===`error`||e.type===`abort`;if(i){if(!jf(n,r,e)){if(s){if(n.status===`streaming`&&n.awaitingContinuation!==!0){let t=this.settleOwnedContinuation(e);return this.detach(),t}Ff(n,r)&&(n.continuationStreaming=!0,this.messagesSig.value=[...this.messagesSig.value],this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id})),this.detach()}return null}let t=Tf(n)&&s?this.settleOwnedContinuation(e):this.promoteContinuation();return s?(t.continuationStreaming&&(e.type===`finish`?this.onReconcileNeeded?.({messageId:t.serverMessageId??t.id}):t.continuationStreaming=!1),this.detach(),t):null}if(a&&kf(n,r)){let e=this.promoteContinuation();return s?(this.detach(),e):null}if(!o)return s&&this.detach(),null;if(s&&!Ni(n)&&Ni(r)){let e=this.promoteReplay();return this.detach(),e}if(!Of(n,r))return s&&(this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id}),this.detach()),null;let c=this.promoteReplay();return s?(this.detach(),c):null}let t=this.refreshActive();if(!t)return null;if(this.replay)return this.applyResume(e);if(this.apply(e),e.type===`finish`||e.type===`error`||e.type===`abort`){let n=t;return n.continuationStreaming&&(e.type===`finish`?this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id}):n.continuationStreaming=!1),this.detach(),n}return null}ensureTextPart(e,t,n){let r=`${t}:${n}`,i=this.openTextParts.get(r);if(i)return i;let a={kind:t,id:`${n}#${this.partSeq++}`,textSig:o(``),doneSig:o(!1)};return this.openTextParts.set(r,a),Lf(e,a),a}apply(e){let t=this.active;if(t)switch(e.type){case`start`:{e.messageId&&(t.serverMessageId=e.messageId);let n=e.messageMetadata;n?.runStartedAt&&(t.runStartedAt=n.runStartedAt),n?.senderRole===`operator`?(t.role=`operator`,n.operatorInitials&&(t.operatorInitials=n.operatorInitials)):n?.senderRole===`visitor`&&(t.role=`user`);return}case`finish-step`:this.openTextParts.clear();return;case`start-step`:Lf(t,{kind:`step-start`,id:`ss-${this.partSeq++}`});return;case`message-metadata`:t.stepTimings=wi(e.messageMetadata?.steps)??t.stepTimings;return;case`finish`:Sf.debug(`finish`,{reason:e.finishReason,canContinue:e.canContinue}),t.stepTimings=wi(e.messageMetadata?.steps)??t.stepTimings,t.status=`complete`,t.retryAction=void 0,e.finishReason&&(t.finishReason=e.finishReason),this.bumpDone(t);return;case`error`:Sf.warn(`stream error chunk`,{errorText:e.errorText}),t.status=`error`,t.errorText=void 0,this.bumpDone(t);return;case`abort`:Sf.debug(`stream abort chunk (canceled)`),t.status=`complete`,t.canceled=!0,t.retryAction=void 0,this.bumpDone(t);return;case`text-start`:this.ensureTextPart(t,`text`,e.id);return;case`text-delta`:{let n=this.ensureTextPart(t,`text`,e.id);n.textSig.value+=e.delta;return}case`text-end`:this.ensureTextPart(t,`text`,e.id).doneSig.value=!0;return;case`reasoning-start`:this.ensureTextPart(t,`reasoning`,e.id).doneSig.value=!1;return;case`reasoning-delta`:{let n=this.ensureTextPart(t,`reasoning`,e.id);n.textSig.value+=e.delta;return}case`reasoning-end`:this.ensureTextPart(t,`reasoning`,e.id).doneSig.value=!0;return;case`tool-input-start`:case`tool-input-delta`:case`tool-input-available`:case`tool-input-error`:case`tool-output-available`:case`tool-output-error`:case`tool-output-denied`:case`tool-approval-request`:zf(t,e);return;case`file`:Lf(t,{kind:`file`,url:e.url,mediaType:e.mediaType});return;case`source-url`:Rf(t,{kind:`source`,sourceId:e.sourceId,url:e.url,title:e.title});return;case`source-document`:Rf(t,{kind:`source`,sourceId:e.sourceId,title:e.title,filename:e.filename,mediaType:e.mediaType});return;case`data-suggestions`:t.suggestions=mi(e.data);return;case`data-control-state`:t.operatorRoutedTurn=e.data.controlMode!==`ai-agent`;return;case`data-memory-compaction-state`:return}}bumpDone(e){r(()=>{e.partsSig.value=[...e.partsSig.value],this.messagesSig.value.includes(e)&&(this.messagesSig.value=[...this.messagesSig.value])})}};const wf={"input-streaming":0,"input-available":1,"approval-requested":2,"approval-responded":3,"output-available":4,"output-denied":4,"output-error":4};function Tf(e){return e.awaitingContinuation===!0||e.continuationStreaming===!0||e.retryAction?.kind===`continue-assistant`}function Ef(e,t){e.canceled&&(t.canceled=!0),Tf(e)&&(t.status===`streaming`||Bi(t))&&(t.awaitingContinuation??(t.awaitingContinuation=e.awaitingContinuation),t.continuationStreaming??(t.continuationStreaming=e.continuationStreaming),t.retryAction===void 0&&(t.retryAction=e.retryAction))}function Df(e,t){let n=e.partsSig.value,r=t.findIndex(e=>e.type===`start-step`),i=new Set(t.slice(0,r<0?t.length:r).flatMap(e=>`toolCallId`in e&&e.type.startsWith(`tool-output`)?[e.toolCallId]:[])),a=n.findLastIndex(e=>e.kind===`tool`&&(e.stateSig.value===`approval-requested`||e.stateSig.value===`approval-responded`||i.has(e.toolCallId)));if(a>=0)return a;let o=new Set(t.flatMap(e=>e.type===`tool-input-start`||e.type===`tool-input-available`?[e.toolCallId]:[]));return n.some(e=>e.kind===`tool`&&o.has(e.toolCallId))?-1:n.findLastIndex(e=>e.kind===`tool`)}function Of(e,t){let n=e.partsSig.value,r=t.partsSig.value;return e.role!==t.role||r.length<n.length?!1:n.every((e,t)=>Af(e,r[t]))}function kf(e,t){let n=e.partsSig.value,r=n.findLastIndex(e=>e.kind===`tool`),i=new Set(n.slice(0,r+1).flatMap(e=>e.kind===`tool`?[e.toolCallId]:[])),a=t.partsSig.value.filter(e=>e.kind!==`tool`||!i.has(e.toolCallId)),o=n.slice(r+1);return a.length<o.length?!1:o.every((e,t)=>Af(e,a[t]))}function Af(e,t){switch(e.kind){case`text`:case`reasoning`:return t?.kind===e.kind&&t.textSig.value.startsWith(e.textSig.value);case`step-start`:return t?.kind===`step-start`;case`tool`:{if(t?.kind!==`tool`||t.toolCallId!==e.toolCallId||!$i(t.toolName,e.toolName)||wf[t.stateSig.value]<wf[e.stateSig.value])return!1;let n=e.approvalSig.value?.approved;return n===void 0||t.approvalSig.value?.approved===n}case`file`:return t?.kind===`file`&&t.url===e.url&&t.mediaType===e.mediaType;case`source`:return t?.kind===`source`&&t.sourceId===e.sourceId&&t.url===e.url&&t.title===e.title&&t.filename===e.filename&&t.mediaType===e.mediaType;default:return e}}function jf(e,t,n){return Mf(e,n)||!Nf(e,t)?!0:n.type!==`finish`&&n.type!==`error`&&n.type!==`abort`?!1:Ri(t)||e.awaitingContinuation===!0&&n.type!==`finish`?!0:e.awaitingContinuation===!0&&t.partsSig.value.every(e=>e.kind===`step-start`)}function Mf(e,t){if(t.type!==`tool-output-available`&&t.type!==`tool-output-error`&&t.type!==`tool-output-denied`)return!1;let n=e.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t.toolCallId);return n!==void 0&&wf[n.stateSig.value]<4}function Nf(e,t){let n=t.partsSig.value;if(n.length===0)return!0;let r=e.partsSig.value;return r.some((e,t)=>n.every((e,n)=>Pf(r[t+n],e)))}function Pf(e,t){switch(t.kind){case`text`:case`reasoning`:return e?.kind===t.kind&&e.textSig.value.startsWith(t.textSig.value);case`step-start`:return e?.kind===`step-start`;case`tool`:return e?.kind===`tool`&&e.toolCallId===t.toolCallId&&(t.toolName===`tool`||$i(e.toolName,t.toolName));case`file`:return e?.kind===`file`&&e.url===t.url&&e.mediaType===t.mediaType;case`source`:return e?.kind===`source`&&e.sourceId===t.sourceId&&e.url===t.url&&e.title===t.title&&e.filename===t.filename&&e.mediaType===t.mediaType;default:return t}}function Ff(e,t){if(Tf(e)||!Bi(e))return!1;let n=new Set(e.partsSig.value.filter(e=>e.kind===`tool`).map(e=>e.toolCallId));return!t.partsSig.value.some(e=>e.kind===`tool`&&n.has(e.toolCallId))}function If(e,t,n,r,i){let a=e.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t);if(a)return r&&(a.dynamic=!0),a.toolMetadata??(a.toolMetadata=i),a;let s={kind:`tool`,toolCallId:t,toolName:n??`tool`,dynamic:r?!0:void 0,toolMetadata:i,inputPartialSig:o(``),inputSig:o(void 0),outputSig:o(void 0),errorSig:o(void 0),stateSig:o(`input-streaming`),approvalSig:o(void 0)};return Lf(e,s),s}function Lf(e,t){e.partsSig.value=[...e.partsSig.value,t]}function Rf(e,t){e.partsSig.value.some(e=>e.kind===`source`&&e.sourceId===t.sourceId)||Lf(e,t)}function zf(e,t){switch(t.type){case`tool-input-start`:If(e,t.toolCallId,t.toolName,t.dynamic,t.toolMetadata);return;case`tool-input-delta`:{let n=If(e,t.toolCallId);n.inputPartialSig.value+=t.inputTextDelta;return}case`tool-input-available`:{let n=If(e,t.toolCallId,t.toolName,t.dynamic,t.toolMetadata);n.inputSig.value=t.input,n.stateSig.value=`input-available`;return}case`tool-input-error`:{let n=If(e,t.toolCallId,t.toolName,t.dynamic);n.inputSig.value=t.input,n.errorSig.value=t.errorText,n.stateSig.value=`output-error`;return}case`tool-approval-request`:{let n=If(e,t.toolCallId,t.toolName);n.approvalSig.value={id:t.approvalId},n.stateSig.value=`approval-requested`;return}case`tool-output-available`:{let n=If(e,t.toolCallId,void 0,t.dynamic);n.outputSig.value=t.output,n.stateSig.value=`output-available`;return}case`tool-output-error`:{let n=If(e,t.toolCallId,void 0,t.dynamic);n.errorSig.value=t.errorText,n.stateSig.value=`output-error`;return}case`tool-output-denied`:{let n=If(e,t.toolCallId);n.stateSig.value=`output-denied`;return}default:return}}const Bf=1e3;async function Vf(e){let t=Bf,n=!1,r=!1,i=!1;function a(){i||e.signal.aborted||(i=!0,e.onInitialBoundaryReady())}for(;!e.signal.aborted;){let o,s=`held`;try{s=await e.connect(()=>{if(e.signal.aborted)return;o=e.now();let t=n||r;n=!0,r=!1,i?t&&e.backfill():a()})}catch{}if(e.signal.aborted||(!n&&o===void 0&&(r=!0,a()),s===`unavailable`))return;e.onDropped?.(),o!==void 0&&e.now()-o>=1e3&&(t=Bf),await e.sleep(t),t=Math.min(t*2,15e3)}}function Hf(e){let{activated:t,conversationReady:n,conversationIdSig:r,messagesSig:i,optionsRef:a,transport:o,visitorId:s,adoptControlStateChunk:c,adoptMemoryCompactionStateChunk:l,settleSuggestions:d,recordConversationReply:f,transcriptRecoverySig:p,beginConversationTranscript:h,commitConversationTranscript:g,onReplyLanded:_,runCancellation:v,canContinueRef:y,setCanSend:b,feedback:x,bus:S,loadInitialThread:C,shouldReconcileOnConnect:w,reconnectingSig:T}=e,E=m(0);u(()=>{if(!t||!n||!r.value)return;let e=r.value,u=new AbortController,m=e=>{},D=new Cf(i,e=>m(e));o.primeIdentity(s,e);let O=!1,k=!1,A,j=!1,M,N=0,ee=y.current,te,P,ne=Date.now(),re,F=!1,I=!1,ie=!1;function ae(t,n,r){if(!Ni(t))return;let o=i.value.findLast(e=>!e.ephemeral),s=t.serverMessageId??t.id;if(!(o&&(o.serverMessageId??o.id)!==s))return Mi(i.value,t,e,a.current.strings.newConversation,n,r)}function L(e,t,n,r){let i=ae(e,t,r);if(!i)return;let a=`${e.serverMessageId??e.id}:${n}:${i.preview??``}`;a!==P&&(P=a,o.publishConversation({...i,hasUnread:!0},!0))}let oe;function se(){oe&&(clearTimeout(oe.timer),oe=void 0)}function ce(){let e=oe;if(!e)return;clearTimeout(e.timer),oe=void 0;let t=i.value.find(t=>(t.serverMessageId??t.id)===e.replyId);(t?.role===`assistant`||t?.role===`operator`)&&L(t,e.canContinue,e.generation,e.activityAt)}function R(e,t,n,r){se(),oe={replyId:e.serverMessageId??e.id,canContinue:t,generation:n,activityAt:r,timer:setTimeout(ce,120)}}function le(e,t,n,r=Date.now(),i=!0){se();let a=ae(e,t,r);if(!a)return;let o=`${e.serverMessageId??e.id}:${n}`;o!==te&&(te=o,f(a),i&&re&&!F&&(I=!0))}function ue(e,t){(e||!v.localSendRef.current)&&v.settle(t),e&&_()}function de(e,t=[],n=!1,r,o=ee,s=N,c=Date.now(),l=!0){let u=a.current;if(e.canceled){le(e,o,s,c,l),ue(n,r);return}let f=!0,p=e.status===`error`;switch(aa(e,p)){case`drop`:i.value=i.value.filter(t=>t!==e),f=!1;break;case`complete-operator-routed`:e.status=`complete`,n&&(x.play(`messageReceived`),Ia(S,u,`assistant`,ji(e)));break;case`error`:if(e.status=`error`,n){x.play(`error`);let e=/* @__PURE__ */ Error(p?`stream error chunk`:`empty reply`);S.emit(`error`,e),u.onError?.(e)}break;case`complete`:e.status=`complete`,n&&(x.play(`messageReceived`),Ia(S,u,`assistant`,ji(e))),d(e,t)}f&&le(e,o,s,c,l),ue(n,r)}function fe(t){if(u.signal.aborted||r.value!==e)return;if(c(t),l?.(t),t.type===`start`){ce();let n=t.messageId===void 0?void 0:i.value.find(e=>e.serverMessageId===t.messageId||e.id===t.messageId);j=n!==void 0&&n.status!==`streaming`;let r=M?.senderRole===`visitor`?M.messageId:void 0;if(M={messageId:t.messageId,senderRole:t.messageMetadata?.senderRole},N+=1,ne=Date.now(),P=void 0,O=t.messageMetadata?.senderRole===void 0,k=!1,A=O?t.messageMetadata?.runId:void 0,O){let n=t.messageId!==void 0&&i.value.some(e=>e.serverMessageId===t.messageId||e.id===t.messageId),a=i.value.at(-1),o=t.messageId!==void 0&&(a?.serverMessageId===t.messageId||a?.id===t.messageId),s=v.localSendRef.current&&(!n||o)&&a?.role===`assistant`&&a.status===`streaming`&&(o||a.serverMessageId===void 0&&a.partsSig.value.length===0);k=v.captureStart(e,t,s,r)}}let n=O&&(t.type===`finish`||t.type===`error`||t.type===`abort`),o=n?A:void 0,s=n&&(k||v.ownsLocalRun(o)),d=N,f=j;t.type===`finish`&&t.canContinue!==void 0&&(ee=t.canContinue);let p=ee;n&&(O=!1,k=!1,A=void 0);let m=D.applyResume(t),h=M?.messageId,g=h===void 0?void 0:i.value.find(e=>e.serverMessageId===h||e.id===h);j&&M?.senderRole!==`visitor`&&(m!==null||g?.status===`streaming`)&&(j=!1,f=!1);let _=!j&&(g?.role===`assistant`||g?.role===`operator`);t.type===`text-delta`&&_&&R(g,ee,N,ne),t.type===`text-end`&&(se(),_&&L(g,ee,N,ne)),t.type===`finish`&&t.canContinue===!1&&b(!1),m?m.role===`operator`?(f||(x.play(`messageReceived`),Ia(S,a.current,`operator`,ji(m))),le(m,p,d,ne),j=!1,n&&(s||!v.localSendRef.current)&&v.settle(o)):m.role===`assistant`&&(de(m,[],s,o,p,d,ne),j=!1):n&&(s||!v.localSendRef.current)&&v.settle(o)}async function pe(t){let n=N,a=await o.loadConversation(e,t?{ids:[t]}:void 0).catch(()=>null);if(u.signal.aborted||r.value!==e||!a)return!1;a.controlState&&c({type:`data-control-state`,data:a.controlState});let s=i.value.at(-1),l=n===N&&(t===void 0||s!==void 0&&(s.serverMessageId===t||s.id===t));if(a.messages.length===0)return!0;l&&(ee=a.canContinue,b(ee));let f=i.value,p=t===void 0?f.at(-1):f.find(e=>e.serverMessageId===t||e.id===t),{messages:m,changed:h}=Xi(f,Oi(a.messages));if(!h)return!0;i.value=m;let g=t===void 0?m.at(-1):m.find(e=>e.serverMessageId===t||e.id===t),_=p!==void 0&&g!==void 0&&(p.id===g.id||p.serverMessageId!==void 0&&p.serverMessageId===g.serverMessageId),y=g!==void 0&&g.status!==`streaming`&&(!_||p?.status===`streaming`),x=_&&p?.status===`streaming`?Date.now():g?.createdAt;return l&&y&&g.role===`assistant`?de(g,g.suggestions??[],v.localSendRef.current,void 0,a.canContinue,n,x,!1):l&&y&&g.role===`operator`?le(g,a.canContinue,n,x,!1):l&&g?.role===`assistant`&&g.status!==`streaming`&&d(g,g.suggestions??[]),!0}let me=/* @__PURE__ */ new Set;m=({messageId:e})=>{if(me.has(e)||!i.value.some(t=>t.serverMessageId===e||t.id===e))return;me.add(e);function t(){return me.delete(e)}pe(e).then(t,t)};function z(t=!1){if(u.signal.aborted||r.value!==e){I=!1;return}if(re){I=!0;return}let n=t?C(e):void 0,i=n??(!t||w()?pe():void 0);if(!i)return;h(e),re=i,F=n!==void 0;function a(t=!1){re===i&&(re=void 0,I?(I=!1,z()):t&&g(e))}i.then(a,()=>a(!1))}let he=p.subscribe(e=>{e<=E.current||(E.current=e,ie&&z())});return Vf({signal:u.signal,now:()=>performance.now(),sleep:e=>ca(e,u.signal),connect:e=>o.connectResumeStream({signal:u.signal,onChunk:fe,onConnected:()=>{T.value=!1,e()}}),onDropped:()=>{T.value=!0},onInitialBoundaryReady:()=>{ie=!0,z(!0)},backfill:()=>z()}),()=>{u.abort(),T.value=!1,se(),he(),D.detach()}},[t,n,r,r.value,s,o,c,l,d,f,p,h,g,_,v,y,b,i,S,x,C,w,T])}function Uf(e){let{transport:t,setStreaming:n}=e,r=m(void 0),i=m(void 0),a=m(!1),o=m(void 0),s=m(!1),c=m(/* @__PURE__ */ new Map),u=m(/* @__PURE__ */ new Set),d=l((e,n)=>{let r=`${e}:${n}`;o.current!==r&&(o.current=r,t.cancelTurn(e,n))},[t]),f=l(e=>{r.current=void 0,i.current=e,a.current=!1,o.current=void 0,s.current=!0,n(!0)},[n]),h=l((e,t)=>{c.current.set(e,{messageId:t})},[]),g=l(e=>{e!==void 0&&(u.current.add(e),u.current.size>32&&u.current.delete(u.current.values().next().value)),(e===void 0||r.current?.runId===e)&&(r.current=void 0,i.current=void 0,a.current=!1,s.current=!1,n(!1))},[n]),_=l((e,t)=>i.current===e?(i.current=void 0,t.runId?(r.current={conversationId:t.conversationId,runId:t.runId},n(!0),a.current&&d(t.conversationId,t.runId),!0):(g(),!0)):t.runId&&r.current?.runId===t.runId?(r.current={conversationId:t.conversationId,runId:t.runId},a.current&&d(t.conversationId,t.runId),!0):!1,[d,n,g]),v=l((e,t)=>{let l=c.current.get(e);return l?(c.current.delete(e),!t.runId||u.current.has(t.runId)?!0:l.runId===void 0?(s.current||i.current||(r.current={conversationId:t.conversationId,runId:t.runId},i.current=void 0,a.current=!1,o.current=void 0,s.current=!0,n(!0)),!0):(l.runId===t.runId&&r.current?.runId===t.runId&&(r.current={conversationId:t.conversationId,runId:t.runId},a.current&&d(t.conversationId,t.runId)),!0)):!1},[d,n]),y=l(e=>i.current===e&&(g(),!0),[g]),b=l(e=>{let t=c.current.get(e);return t?(c.current.delete(e),t.runId===void 0):!1},[]),x=l((e,t,l,f)=>{let p=t.messageMetadata?.runId;if(t.messageMetadata?.senderRole!==void 0||typeof p!=`string`||!p||u.current.has(p))return!1;if(r.current?.runId===p)return s.current;if(s.current)return r.current||!l?!1:(i.current=void 0,r.current={conversationId:e,runId:p},n(!0),a.current&&d(e,p),!0);let m=[...c.current.values()].filter(e=>e.runId===void 0).find(e=>e.messageId===f);return m?(m.runId=p,r.current={conversationId:e,runId:p},i.current=void 0,a.current=!1,o.current=void 0,s.current=!0,n(!0),!0):(i.current=void 0,r.current={conversationId:e,runId:p},n(!0),a.current&&d(e,p),s.current)},[d,n]),S=l(e=>typeof e==`string`&&r.current?.runId===e&&s.current,[]),C=l(()=>{let e=r.current;if(e)return a.current=!0,d(e.conversationId,e.runId),!0;let t=i.current;return t?(a.current=!0,t.then(e=>{e.runId&&d(e.conversationId,e.runId)}).catch(()=>void 0),!0):!1},[d]);return p(()=>({localSendRef:s,begin:f,beginRouted:h,acceptAck:_,acceptRoutedAck:v,reject:y,rejectRouted:b,captureStart:x,ownsLocalRun:S,settle:g,stop:C}),[_,v,f,h,x,S,y,b,g,C])}const Wf=z.scope(`send`);function Gf(e,t,n,r,i,a=!0){e.publishConversation({...Mi(t,n,r,i,a),hasUnread:!1},!0)}function Kf(e,t){return e.id===t.id||(e.serverMessageId??e.id)===(t.serverMessageId??t.id)}function qf(e){return e.findLast(e=>!e.ephemeral&&e.role!==`system`&&(e.role===`user`||e.status!==`streaming`||Ni(e)))}function Jf(e,t,n,r,i){let a=qf(t);a?.role===`user`&&Kf(a,n)&&Gf(e,t,a,r,i)}function Yf(e){return!(e instanceof fa)||e.code===`network`||e.status===void 0||e.status===202||e.status===408||e.status===425||e.status===429||e.status>=500&&e.status<600}function Xf(e){let{transport:t,messagesSig:n,conversationIdSig:r,options:i,bus:a,feedback:o,persistence:s,visitorId:c,adoptConversationId:u,applyControlState:d,setCanSend:f,settleSuggestions:p,runCancellation:m}=e,h=l(()=>{let e=r.value??pt();return r.value||(r.value=e,s.saveConversationId(e)),e},[r,s]);return{sendAiTurn:l(async({continueExisting:e,turn:l})=>{let g=h(),_=n.value.at(-1),v=l?[l]:ki(n.value,e),y=v[0];y?.role===`user`&&Pl.markSent(y.id);let b=v.map(Ai),x=s.loadUserPrefs(),S=Jl(i.tools).then(n=>t.sendTurn(hi({messages:b,conversationId:g,visitorId:c,userPrefs:x,clientTools:Yl(n)}),{keepalive:e}));m.begin(S);try{let a=await S;if(r.value!==g||!m.acceptAck(S,a))return!1;if(u(a.conversationId),a.runId&&y?.role===`user`&&Jf(t,n.value,y,a.conversationId,i.strings.newConversation),!a.runId){let o=await t.loadConversation(a.conversationId).catch(()=>null);if(r.value!==a.conversationId)return!0;if(o){o.controlState&&d(o.controlState),f(o.canContinue);let r=Oi(o.messages),{messages:s,changed:c}=Xi(n.value,r);c&&(n.value=s);let l=r.findLast(e=>!e.ephemeral&&e.role!==`system`),u=qf(n.value);u&&l&&Kf(u,l)&&Gf(t,n.value,u,a.conversationId,i.strings.newConversation,o.canContinue);let m=_?n.value.find(e=>e.id===_.id&&e.role===`assistant`&&e.status!==`streaming`):void 0;m&&p(m,m.suggestions??[]),!e&&_?.role===`assistant`&&n.value.includes(_)&&_.serverMessageId===void 0&&!Ni(_)&&(n.value=n.value.filter(e=>e!==_))}else _?.role===`assistant`&&n.value.includes(_)&&(_.status=`error`,_.errorText=i.strings.errorGeneric,_.retryAction=e?{kind:`continue-assistant`,messageId:_.serverMessageId??_.id}:y?.role===`user`?{kind:`resend-user`,messageId:y.id}:null,n.value=[...n.value])}return!0}catch(s){if(r.value!==g)return!1;if(!m.reject(S))return y?.role===`user`&&Jf(t,n.value,y,g,i.strings.newConversation),!0;let c=Is(s,i.strings),u=Yf(s),h=l?.role===`assistant`?l:n.value.at(-1);if(e&&h?.role===`assistant`&&s instanceof fa&&s.status===409){let e=h.serverMessageId??h.id,i=await t.loadConversation(g,{ids:[e]}).catch(()=>null);if(r.value!==g)return!1;if(i){i.controlState&&d(i.controlState),f(i.canContinue);let t=Oi(i.messages),r=t.find(t=>(t.serverMessageId??t.id)===e);if(r&&Zi(h,r)){let{messages:r,changed:i}=Xi(n.value,t),a=r.find(t=>(t.serverMessageId??t.id)===e);if(i&&a&&a!==h)return a.awaitingContinuation=!1,a.continuationStreaming=void 0,a.retryAction=null,n.value=r,a.status!==`streaming`&&p(a,a.suggestions??[]),!0}}if(!n.value.includes(h)||h.status!==`streaming`)return!1;h.continuationStreaming=!0}if(e&&h?.role===`assistant`)h.status=`error`,h.errorText=c,h.retryAction=u?{kind:`continue-assistant`,messageId:h.serverMessageId??h.id}:null,n.value=[...n.value];else if(_?.role===`assistant`&&n.value.includes(_)){_.status=`error`,_.errorText=c;let e=v[0];_.retryAction=u&&e?.role===`user`?{kind:`resend-user`,messageId:e.id}:null,n.value=[...n.value]}else{let e=yi();e.status=`error`,e.errorText=c;let t=v[0];e.retryAction=u&&t?.role===`user`?{kind:`resend-user`,messageId:t.id}:null,n.value=[...n.value,e]}return o.play(`error`),a.emit(`error`,s),i.onError?.(s),!1}},[t,n,i,a,o,s,c,u,d,f,p,h,m]),sendRoutedTurn:l(async e=>{let l=h();e.status=`pending`,e.errorText=void 0,e.retryAction=void 0,n.value.includes(e)&&(n.value=[...n.value]),Pl.markSent(e.id);let d=[Ai(e)],f=s.loadUserPrefs(),p=Jl(i.tools).then(e=>t.sendTurn(hi({messages:d,conversationId:l,visitorId:c,userPrefs:f,clientTools:Yl(e)})));m.beginRouted(p,e.id);try{let a=await p;return r.value===l?m.acceptRoutedAck(p,a)?(u(a.conversationId),Jf(t,n.value,e,a.conversationId,i.strings.newConversation),e.status===`pending`&&(e.status=`complete`,n.value.includes(e)&&(n.value=[...n.value])),!0):!1:(m.rejectRouted(p),!1)}catch(s){let c=m.rejectRouted(p);if(r.value!==l)return!1;if(!c)return Jf(t,n.value,e,l,i.strings.newConversation),e.status===`pending`&&(e.status=`complete`,n.value.includes(e)&&(n.value=[...n.value])),!0;if(e.status!==`pending`)return Jf(t,n.value,e,l,i.strings.newConversation),!0;Wf.debug(`operator-routed send failed`,{error:s});let u=s instanceof Error?s:Error(String(s));return e.status=`error`,e.errorText=Is(s,i.strings),e.retryAction=Yf(s)?{kind:`resend-user`,messageId:e.id}:null,n.value.includes(e)&&(n.value=[...n.value]),o.play(`error`),a.emit(`error`,u),i.onError?.(u),!1}},[t,n,i,a,o,s,c,u,h,m])}}const Zf=z.scope(`unread`);function Qf(e){let{transport:t,options:n,conversationIdSig:r,isConversationVisibleRef:i,activated:a,conversationReady:o}=e,s=c(!1),d=c(0),f=c(0),p=m([]),h=m(void 0),g=m(!1),_=l(()=>{let e=r.value,t=i.current()&&h.current===e?e:void 0,n=p.current.filter(e=>e.hasUnread&&e.conversationId!==t).length;d.value=n,s.value=n>0},[r,s,d,i]),v=l(e=>{let t=r.value,n=p.current.find(e=>e.conversationId===t),i=Ca(p.current,e),a=i.find(e=>e.conversationId===t),o=e.type===`snapshot`&&t!==void 0&&a?.hasUnread===!0&&h.current===t&&n!==void 0&&n.lastMessageAt!==a.lastMessageAt;o&&(h.current=void 0),p.current=i,_(),o&&(f.value+=1)},[r,_,f]),y=l(()=>{if(_(),!i.current())return;let e=r.value;if(!e||h.current!==e)return;let n=p.current.find(t=>t.conversationId===e);n?.hasUnread&&t.markRead(e,n.lastMessageAt)},[r,i,_,t]),b=l(e=>{r.value===e&&(h.current=void 0,_())},[r,_]),x=l(e=>{r.value===e&&(h.current=e,y())},[r,y]),S=l(e=>h.current===e,[]),C=l((e=!1)=>{n.history.enabled&&n.modules.list.some(e=>e.layout===`chat`)&&(g.current||(g.current=!0,t.listConversations({limit:50},e).then(t=>{e||v({type:`snapshot`,result:t,requestedRevision:0}),y()}).catch(e=>Zf.debug(`refreshUnread failed (non-fatal)`,{err:e})).finally(()=>{g.current=!1})))},[v,y,n.history.enabled,n.modules,t]),w=l(e=>{let n=e.conversationId,a=i.current()&&r.value===n&&h.current===n,o=p.current.find(e=>e.conversationId===n),s=a&&(o?.lastMessageAt!==e.lastMessageAt||o.hasUnread);t.publishConversation({...e,hasUnread:!a},!0),s&&t.markRead(n,e.lastMessageAt)},[r,i,t]);u(()=>t.subscribeConversationChanges(v),[v,t]);let T=m(!1);return u(()=>{a&&o&&!T.current&&(T.current=!0,C())},[a,o,C]),u(()=>{if(!a)return;function e(){document.visibilityState===`visible`&&(y(),C(!0))}return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[a,y,C]),{hasUnreadSig:s,unreadCountSig:d,transcriptRecoverySig:f,markVisibleConversationRead:y,beginConversationTranscript:b,commitConversationTranscript:x,isConversationTranscriptCommitted:S,recordConversationReply:w}}const $f=z.scope(`settings`);function ep(e){let{options:t,persistence:n,transport:r,feedback:i,hostElement:a,bus:o}=e,s=n.loadUserPrefs(),[c,d]=h(()=>s.locale??t.locale),[f,p]=h(s.themeMode),m=f??t.themeMode,[g,_]=h(()=>s.textSize??t.textSize),v=l(e=>{n.patchUserPrefs(e),r.saveUserPrefs(n.loadUserPrefs()).catch(e=>$f.warn(`saveUserPrefs failed`,{err:e}))},[n,r]);u(()=>{s.soundMuted!==void 0&&i.setMuted(s.soundMuted)},[]),u(()=>{if(m!==`host`)a.dataset.theme=m;else return At(e=>{a.dataset.theme=e})},[a,m,t]),u(()=>{a.dataset.textSize=g},[a,g,t]),u(()=>{let e=!0;return i.mutedSig.subscribe(t=>{e?e=!1:v({soundMuted:t})})},[i,v]);let y=Ee(c,t.availableLocales,t.defaultLocale);return u(()=>{r.setLocale(y)},[r,y]),u(()=>{a.dir=A(y)?`rtl`:`ltr`},[a,y]),u(()=>{y!==c&&d(y)},[y,c]),{activeLocale:c,activeThemeMode:m,activeTextSize:g,effectiveLocale:y,setActiveLocale:d,setActiveThemeMode:p,setActiveTextSize:_,patchAndSync:v,handleLocaleChange:l(e=>{$f.info(`localeChange`,{locale:e}),d(e),v({locale:e}),o.emit(`localeChange`,e)},[v,o]),handleThemeChange:l(e=>{$f.info(`themeChange`,{mode:e}),p(e),a.dataset.theme=e,v({themeMode:e}),o.emit(`themeChange`,e)},[a,v,o]),handleTextSizeChange:l(e=>{$f.info(`textSizeChange`,{size:e}),_(e),a.dataset.textSize=e,v({textSize:e}),o.emit(`textSizeChange`,e)},[a,v,o]),handleSoundToggle:l(()=>{i.toggleMuted();let e=i.mutedSig.value;$f.info(`soundToggle`,{muted:e}),o.emit(`soundToggle`,{muted:e})},[i,o])}}const $=z.scope(`app`),tp=N.cssPrefix,np={home:`home`,chats:`chat`,help:`help`,news:`news`};function rp(e,t){return bi({...e,text:j(t,e.text)})}function ip({options:e,hostElement:t,bus:n,recentHostEvents:i}){let o=e.aiAgentDeploymentId;if(!o)throw Error(`aiAgentDeploymentId is required`);let[d]=h(()=>gt(e.widgetId,e.storage,e.aiAgentDeploymentId)),[g]=h(()=>d.getVisitorId()),y=d.loadUserPrefs(),b=c(d.loadConversationId()),x=m(b.value!==void 0),S=c(b.value??``),C=c([]),w=c(!1),[T,E]=h(!1),D=m(void 0),[O,k]=h([]);function A(){let t=e.modules.list,n=new Set(t.map(e=>e.id)),r=d.loadActiveModule();return r&&n.has(r)?r:t[0]?.id??``}function M(){return e.modules.list.find(e=>e.layout===`chat`)?.id}function ee(){let t=M();return t?e.modules.list.length===1||P.sig.value.activeTab===t:!1}let te=m(void 0);if(!te.current){let t=e.modules.list.map(e=>e.id),n=d.loadActiveModule()??t[0]??``;te.current=Ua(n,n?[...t,n]:t,e=>d.saveActiveModule(e))}let P=te.current,ne=s(()=>P.sig.value.activeTab).value,re=s(()=>b.value).value,[F,I]=h(!1),[ie,ae]=h(null),[L,oe]=h(!1),se=e.mode===`standalone`||e.mode===`inline`,ce=m(Ya(e,Xa(),d.loadPanelOpen(),d.loadPanelSize())),[R,le]=h(ce.current.panelOpen),[ue,de]=h(ce.current.panelOpen),fe=m(void 0),pe=m(void 0),me=m(!1),z=m(void 0);u(()=>{R&&de(!0)},[R]);let he=m(!1),[ge,_e]=h(!1),{dismissed:ve,dismissCallout:ye}=gf({callout:e.launcher.callout,persistence:d}),be=e.launcher.callout?.persistent??!0,xe=l(()=>{$.info(`calloutDismiss`),n.emit(`calloutDismiss`,void 0),ye()},[n,ye]),[Se,Ce]=h(ce.current.panelSize),we=m(!1),[Te,Ee]=h(`chat`),De=m(()=>!1);De.current=()=>R&&Te===`chat`&&!document.hidden&&ee();let[Oe,ke]=h(!0),Ae=m(Oe);Ae.current=Oe;let[je,Me]=h(!1),Ne=m(je);Ne.current=je;let Fe=m(null),[Ie,Re]=h(!1),[ze,Be]=h(null),[Ve,He]=h([]),Ue=m(e.strings),We=m(e);We.current=e;let[Ge,Ke]=h(void 0),[qe,Je]=h(void 0),[Ye,Xe]=h(()=>d.loadSidebarCollapsed()??!1),[Ze,Qe]=h({}),[B]=h(()=>new ka({agentApiBaseUrl:e.agentApiBaseUrl,dataApiBaseUrl:e.dataApiBaseUrl,auth:Gt({publicKey:e.publicKey,aiAgentDeploymentId:o,publicKeyHeader:`x-public-key`}),endpoints:e.endpoints,recentHostEvents:i})),[$e]=h(()=>new yn(e.sound,e.haptics)),et=Uf({transport:B,setStreaming:Me}),{activeLocale:tt,activeThemeMode:nt,activeTextSize:rt,effectiveLocale:it,setActiveLocale:at,setActiveThemeMode:ot,setActiveTextSize:st,patchAndSync:ct,handleLocaleChange:lt,handleThemeChange:ut,handleTextSizeChange:dt,handleSoundToggle:ft}=ep({options:e,persistence:d,transport:B,feedback:$e,hostElement:t,bus:n}),{controlModeSig:mt,assignedOperatorInitialsSig:ht,operatorAvailableSig:_t,applyControlState:vt,adoptControlStateChunk:bt,requestOperator:xt,cancelOperatorRequest:St}=_f({transport:B,conversationIdSig:b}),Ct=c(/* @__PURE__ */ new Map),wt=l(e=>{if(e.type!==`data-memory-compaction-state`)return;let t=b.value;if(!t)return;let n=pi(e.data);if(!n)return;let r=Ct.value.get(t);if(r&&(n.postFinishSequence<r.postFinishSequence||n.postFinishSequence===r.postFinishSequence&&(r.status===`ready`||r.status===n.status)))return;let i=new Map(Ct.value);i.set(t,n),Ct.value=i},[b,Ct]),{hasUnreadSig:Tt,unreadCountSig:Et,transcriptRecoverySig:Dt,markVisibleConversationRead:Ot,beginConversationTranscript:kt,commitConversationTranscript:At,isConversationTranscriptCommitted:jt,recordConversationReply:Mt}=Qf({transport:B,options:e,conversationIdSig:b,isConversationVisibleRef:De,activated:ue,conversationReady:F}),Nt=R&&e.modules.byId[ne]?.layout===`home`,Pt=hf({transport:B,options:e,persistence:d,enabled:F&&Nt});u(()=>{Ot()},[ne,R,Te,re,Ot]),u(()=>{$e.update(e.sound,e.haptics)},[$e,e.sound,e.haptics]),u(()=>()=>$e.destroy(),[$e]),u(()=>{!we.current&&e.size.initialSize&&(we.current=!0,!d.loadPanelSize()&&Ce(Ja(e.mode,e.size,Xa())))},[e.mode,e.size,d]),u(()=>{if(!F||he.current)return;he.current=!0;let t=Ya(e,Xa(),d.loadPanelOpen(),d.loadPanelSize());le(t.panelOpen),Ce(t.panelSize)},[F,e,d]);let Ft=m(null);u(()=>{F&&P.reconcile(e.modules.list.map(e=>e.id),A())},[F,e.modules.list,P]);let It=l(e=>{e&&e.length!==0&&(C.value=e.map(e=>rp(e,Ue.current)))},[C]),Lt=m(null),Rt=l(async e=>{try{let{formSubmissions:t}=await(e?B.bootstrap(e):Lt.current??B.bootstrap()),n=/* @__PURE__ */ new Map;return t.forEach((e,t)=>n.set(e.formId,t)),t.filter((e,t)=>!e.skipped||n.get(e.formId)===t).map((e,t)=>({key:`wire:${e.formId}:${e.createdAt??t}`,formId:e.formId,outcome:e.skipped?`skipped`:`submitted`,createdAt:oi(e.createdAt),values:e.values}))}catch(e){return $.debug(`bootstrap failed — no form markers (non-fatal)`,{err:e}),[]}},[B]),zt=m(0),Bt=m(0),Vt=l(e=>{if(e===b.value)return;let t=b.value;Bt.current++,E(!1),t&&(d.saveDraft(e,d.loadDraft(t)),d.saveDraft(t,``),d.saveMessageQueue(e,d.loadMessageQueue(t)),d.saveMessageQueue(t,[])),b.value=e,d.saveConversationId(e),B.primeIdentity(void 0,e),$.info(`conversation rebound`,{previous:t,current:e}),t&&n.emit(`conversationRebound`,{previous:t,current:e})},[n,b,d,B]),Ht=l((e,t)=>{let n=[...e.map(e=>e.createdAt),...t.map(e=>e.createdAt)].filter(e=>e!==void 0),r=(n.length?Math.min(...n):Date.now())-1;return[...(z.current?.messages??[]).map(e=>{let t=rp(e,Ue.current);return t.createdAt=r,t}),...e]},[]),Ut=l(async e=>{let t=Bt.current;function r(){return t!==Bt.current||b.value!==e}pe.current===e&&(pe.current=void 0),E(!0);try{let[t,n]=await Promise.all([B.loadConversation(e),Rt()]);if(r())return!1;let i=Oi(t.messages);k(n);let a=Ht(Yi(i,C.value),n);if(C.value=a,pe.current=a.some(e=>e.role===`user`)?void 0:e,i.length>0||t.controlState!==void 0){ke(t.canContinue),t.controlState&&vt(t.controlState);let e=i.findLast(e=>e.role===`assistant`&&!e.ephemeral);He(e?.suggestions??[])}return!0}catch(t){return r()||($.warn(`loadThread failed; keeping conversation active`,{err:t,conversationId:e}),n.emit(`error`,t),We.current.onError?.(t)),!1}finally{r()||E(!1)}},[B,Rt,C,b,Ht,n]),Wt=l(e=>{if(fe.current===e)return fe.current=void 0,Ut(e)},[Ut]),Kt=l(()=>{if(D.current)return Promise.resolve(void 0);let t=b.value,r=C.value.find(e=>e.serverMessageId!==void 0),i=r?.serverMessageId,a=r?new Date(r.createdAt).toISOString():void 0;if(!t||!i||!a)return Promise.resolve(void 0);let o=Bt.current,s={};return D.current=s,(async()=>{try{let e=await B.loadConversation(t,{beforeId:i,beforeCreatedAt:a});if(D.current!==s||Bt.current!==o||b.value!==t)return;if(e.messages.length===0)return!1;let n=e.messages.map(Ci),r=C.value,c=Ui(r,n);if(c!==r){let e=Math.min(...n.map(e=>e.createdAt??1/0),...O.map(e=>e.createdAt??1/0));if(Number.isFinite(e))for(let t of r){if(!t.ephemeral)break;(t.createdAt??1/0)>=e&&(t.createdAt=e-1)}C.value=c}return!0}catch(r){if(D.current!==s||Bt.current!==o||b.value!==t)return;$.warn(`load previous messages failed`,{err:r,conversationId:t,beforeId:i}),n.emit(`error`,r),e.onError?.(r);return}finally{D.current===s&&(D.current=void 0)}})()},[n,b,O,C,e,B]),Zt=l(async({newConversation:t})=>{let i=++zt.current;function a(){return i!==zt.current}let o=b.value,s=t||!o?pt():o;s!==o&&(Bt.current++,E(!1),r(()=>{b.value=s,S.value=s}),d.saveConversationId(s)),B.primeIdentity(g,s);let c;try{c=await B.handshake({visitorId:g,conversationId:s,userPrefs:d.loadUserPrefs(),locale:tt})}catch(r){if(a())return;n.emit(`error`,r),e.onError?.(r),t||I(!0);return}if(a())return;c.conversationId!==s&&Vt(c.conversationId),Be(c.agent),c.site&&xn(c.site)?Ke(c.site):c.site&&$.warn(`invalid site config, using fallback`,{site:c.site}),c.blocks&&Sn(c.blocks)?Je(c.blocks):c.blocks&&$.warn(`invalid blocks config, using fallback`,{blocks:c.blocks});let l=yt(c.userPrefs);if(Object.keys(l).length>0&&!t&&(d.saveUserPrefs(l),l.locale&&at(l.locale),l.soundMuted!==void 0&&$e.setMuted(l.soundMuted),l.themeMode&&ot(l.themeMode),l.textSize&&st(l.textSize)),z.current=c.welcome,t||n.emit(`handshake`,c),c.welcome?.suggestions){let e=Ue.current;He(c.welcome.suggestions.map(t=>({...t,label:j(e,t.label),...t.text===void 0?{}:{text:j(e,t.text)}})))}let u=!t&&o&&c.conversationId===o;x.current=!!u,u?me.current||(fe.current=c.conversationId):(pe.current=c.conversationId,It(c.welcome?.messages),At(c.conversationId)),t||I(!0)},[B,g,d,e,n,b,S,$e,It,tt,Vt,At]),en=JSON.stringify(e.userContext??null),nn=JSON.stringify(e.pageContext??null),rn=JSON.stringify(Ze);u(()=>{let t=Object.keys(Ze).length?{...Ze,...e.userContext}:e.userContext;B.setContext(t,ap(e.pageContext))},[B,en,nn,rn]),u(()=>B.setUserToken(e.userToken),[B,e.userToken]);let an=l((e,t=[])=>He(e.suggestions??t),[]);u(()=>(B.primeIdentity(g,b.value),Zt({newConversation:!1}),()=>{zt.current++,Bt.current++}),[]),u(()=>{ue&&F&&!me.current&&(me.current=!0,Lt.current=B.bootstrap(),(async()=>{try{let e=await Lt.current;ae(Pe((e??{forms:[]}).forms,it))}catch(e){$.debug(`bootstrap failed — treating as no forms`,{err:e})}finally{oe(!0)}})(),fe.current===b.value&&E(!0))},[ue,F]);let V=m(null);u(()=>{if(!ue||!F||(V.current??(V.current=it),V.current===it))return;V.current=it;let e=!1;return B.bootstrap().then(t=>{e||ae(Pe((t??{forms:[]}).forms,it))}).catch(e=>$.debug(`forms re-localize failed — keeping current copy`,{err:e})),()=>{e=!0}},[ue,F,it,B]);let sn=m(en);u(()=>{F&&sn.current!==en&&(sn.current=en,Zt({newConversation:!1}))},[en,F,Zt]),xf({hostElement:t,mode:e.mode,panelSize:Se,isOpen:R,surfaceReady:F,setIsOpen:le});let{sendAiTurn:cn,sendRoutedTurn:ln}=Xf({transport:B,messagesSig:C,conversationIdSig:b,options:e,bus:n,feedback:$e,persistence:d,visitorId:g,adoptConversationId:Vt,applyControlState:vt,setCanSend:ke,settleSuggestions:an,runCancellation:et}),{toolInteraction:un,pageToolsRunning:dn,stopPageTools:fn}=pf({streaming:je,controlModeSig:mt,messagesSig:C,sendAiTurn:cn,bus:n,humanInLoop:e.features.humanInLoop,tools:e.tools}),pn=l((e,t)=>{let r=C.value.find(t=>t.serverMessageId===e);r&&(r.feedback=t),$.info(`messageFeedback`,{messageId:e,value:t}),n.emit(`messageFeedback`,{messageId:e,value:t}),B.submitFeedback({messageId:e,value:t})},[n,C,B]);function mn(){return C.value.reduce((e,t)=>e+ +(t.role===`user`),0)}let hn=e.forms.list.length>0?e.forms:ie??e.forms,gn=La({forms:hn,persistence:d,userContext:()=>e.userContext,messageCount:mn,pageArea:()=>e.pageContext?.area?String(e.pageContext.area):void 0,conversationId:()=>b.value,onComplete:(e,t,r,i)=>{$.info(`formSubmit`,{formId:e.id,trigger:t,skipped:i}),n.emit(`formSubmit`,{formId:e.id,values:r,skipped:i}),k(t=>{let n=t.find(t=>t.formId===e.id&&t.outcome===`skipped`)?.createdAt??Date.now();return[...t.filter(t=>t.formId!==e.id||t.outcome!==`skipped`),{key:`local:${e.id}:${n}`,formId:e.id,outcome:i?`skipped`:`submitted`,createdAt:n,...i?{}:{values:r}}]});let a=b.value??pt();b.value||(b.value=a,d.saveConversationId(a),B.primeIdentity(void 0,a)),!i&&e.mirrorToContext&&Qe(e=>({...e,...r})),B.submitForm({formId:e.id,conversationId:a,trigger:t,values:r,skipped:i})}}),_n=s(()=>gn.activeForm.value),vn=_n.value?.form.blocking??!1;Hf({activated:ue,conversationReady:F,conversationIdSig:b,messagesSig:C,optionsRef:We,transport:B,visitorId:g,adoptControlStateChunk:bt,adoptMemoryCompactionStateChunk:wt,settleSuggestions:an,recordConversationReply:Mt,transcriptRecoverySig:Dt,beginConversationTranscript:kt,commitConversationTranscript:At,onReplyLanded:l(()=>gn.fire(`after-messages`),[gn]),runCancellation:et,canContinueRef:Ae,setCanSend:ke,feedback:$e,bus:n,loadInitialThread:Wt,shouldReconcileOnConnect:l(()=>x.current||C.value.some(e=>!e.ephemeral&&e.role===`user`),[C]),reconnectingSig:w}),u(()=>{gn.refresh()},[hn,gn]);let bn=e.pageContext?.area?String(e.pageContext.area):void 0,Cn=s(()=>C.value.length),wn=m(null);u(()=>{L&&wn.current&&(gn.fire(`manual`,wn.current),wn.current=null)},[L,gn]),u(()=>{F&&L&&gn.fire(`pre-chat`)},[F,L,gn]),u(()=>{L&&!Oe&&gn.fire(`conversation-closed`)},[L,Oe,gn]),u(()=>{F&&L&&bn&&gn.fire(`page-area`)},[F,L,bn,gn]);let Tn=p(()=>{let e=hn.list.flatMap(e=>e.triggers).filter(e=>e.kind===`idle`).map(e=>Number(e.param));return e.length?Math.min(...e)*1e3:0},[hn]);u(()=>{if(!Tn||!R)return;let e=setTimeout(()=>gn.fire(`idle`),Tn);return()=>clearTimeout(e)},[Tn,R,gn,Cn.value]);let En=l(async(t,r,i)=>{if(Fe.current)return!1;let a=b.value,o=a?Ct.value.get(a):void 0,s=mt.value!==`ai-agent`;if(!s&&o?.status===`compacting`||($.info(`send`,{textLen:t.length,attachments:r.length,streaming:Ne.current,routedToOperator:s}),Ne.current&&!s))return!1;let c=new AbortController,l={conversationId:a,controller:c};Fe.current=l,Re(!0);try{$e.unlock();let o=await sp(B,r,c.signal,t=>{c.signal.aborted||($.warn(`upload failed`,{err:t}),n.emit(`error`,t),e.onError?.(t))});if(c.signal.aborted||b.value!==a||!Ae.current||gn.activeForm.value?.form.blocking)return!1;let s=a?Ct.value.get(a):void 0,l=mt.value!==`ai-agent`;if(!l&&s?.status===`compacting`||Ne.current&&!l||!t&&o.length===0)return!1;n.emit(`send`,{text:t,attachmentCount:r.length}),Ve.length>0&&He([]),$e.play(`messageSent`);let u=vi(t,o,i);return Ia(n,e,`user`,t),l?(C.value=[...C.value,u],i?await ln(u):(ln(u),!0)):(C.value=[...C.value,u,yi()],i?await cn({continueExisting:!1}):(cn({continueExisting:!1}),!0))}finally{Fe.current===l&&(Fe.current=null,Re(!1))}},[B,n,e,Ve.length,C,b,Ct,cn,ln,mt]),Dn=m(En);Dn.current=En;let On=b.value,kn=(On?Ct.value.get(On):void 0)?.status===`compacting`,H=mt.value===`ai-agent`,An=s(()=>{let e=C.value.at(-1);return e?.role===`assistant`&&e.partsSig.value.some(e=>e.kind===`tool`&&e.stateSig.value===`approval-requested`)}),U=s(()=>C.value.some(e=>e.retryAction?.kind===`resend-user`||e.retryAction?.kind===`continue-assistant`));f(()=>{let e=b.value;return()=>{let t=Fe.current;t&&t.conversationId===e&&(Fe.current=null,Re(!1),t.controller.abort())}},[b.value]),u(()=>{(!Oe||vn)&&Fe.current?.controller.abort()},[vn,Oe]);let jn=l(()=>{if(dn){$.info(`stop page tools`),n.emit(`stop`,void 0),fn();return}if(!et.stop())return;$.info(`stop`),n.emit(`stop`,void 0);let e=C.value.at(-1);e&&e.role!==`user`&&e.status===`streaming`&&(e.canceled=!0,C.value=[...C.value])},[et,n,C,dn,fn]),Mn=l(e=>{if(je)return;let t=C.value,n=ra(t,e);if(n)switch($.info(`retry`,{kind:n.kind,messageId:n.messageId}),n.kind){case`continue-assistant`:if(mt.value!==`ai-agent`||e.role!==`assistant`||(e.serverMessageId??e.id)!==n.messageId)return;e.status=`streaming`,e.errorText=void 0,e.retryAction=void 0,e.awaitingContinuation=!0,C.value=[...t],cn({continueExisting:!0,turn:e});return;case`resend-user`:{let r=t.find(e=>e.role===`user`&&e.id===n.messageId);if(!r)return;let i=e=>{e&&Ft.current?.acceptQueuedMessage(n.messageId)};if(r.status=`complete`,r.errorText=void 0,r.retryAction=void 0,mt.value!==`ai-agent`){C.value=e.role===`assistant`?t.filter(t=>t!==e):[...t],ln(r).then(i);return}let a=yi();C.value=e.role===`assistant`?t.map(t=>t===e?a:t):[...t,a],cn({continueExisting:!1,turn:r}).then(i);return}case`repeat-user`:{let e=t.find(e=>e.role===`user`&&e.id===n.messageId);if(!e)return;let r=vi(ji(e),e.attachments?.map(e=>({...e}))??[]),i=new Set(r.attachments?.flatMap(e=>e.url?[e.url]:[])??[]),a=e.partsSig.value.flatMap(e=>e.kind===`file`&&!i.has(e.url)?[{...e}]:[]);if(a.length>0&&(r.partsSig.value=[...r.partsSig.value,...a]),mt.value!==`ai-agent`){C.value=[...t,r],ln(r);return}C.value=[...t,r,yi()],cn({continueExisting:!1,turn:r});return}default:return n}},[je,C,mt,cn,ln]),Nn=l(()=>{Fa(e.mode,Se)===`exit-fullscreen`?($.info(`close → exit-fullscreen`,{mode:e.mode}),Ce(`normal`),n.emit(`fullscreen`,!1)):($.info(`close → panel closed`,{mode:e.mode}),gn.fire(`panel-close`),le(!1),d.savePanelOpen(!1),n.emit(`close`,void 0),e.onClose?.())},[n,e,d,Se,gn]),Pn=l(()=>{$.info(`open`,{mode:e.mode}),$e.unlock(),_e(!0),le(!0),d.savePanelOpen(!0),!ve&&!be&&xe(),setTimeout(()=>_e(!1),op),n.emit(`open`,void 0),e.onOpen?.()},[n,e,$e,d,ve,be,xe]),Fn=l(()=>{let e=C.value.some(e=>e.role===`user`);if(pe.current===b.value&&!e&&Oe&&b.value)$.info(`clear → reusing empty conversation`,{conversationId:b.value}),C.value.length===0&&It(z.current?.messages);else return $.info(`clear → new conversation`,{wasStreaming:je}),n.emit(`clear`,void 0),et.settle(),x.current=!1,fe.current=void 0,pe.current=void 0,r(()=>{C.value=[],b.value=void 0,vt({controlMode:`ai-agent`,controlRevision:0})}),d.clearConversation(),ke(!0),k([]),He([]),Zt({newConversation:!0})},[je,C,b,d,Zt,n,Oe,It,et,vt]),In=l(()=>{let t=Fn();Ee(`chat`);let n=e.modules.list.find(e=>e.layout===`chat`)?.id;return n&&P.switchTab(n),t},[Fn,P,e]),Ln=l(async e=>{await In(),await Dn.current(e,[])||Ft.current?.fill(e)},[In]),Rn=l(()=>{let e=Se===`expanded`?`normal`:`expanded`;$.info(`expand`,{from:Se,expanded:e===`expanded`}),Ce(e),d.savePanelSize(e),n.emit(`expand`,e===`expanded`)},[n,Se,d]),zn=l(()=>{let e=Se===`fullscreen`?`normal`:`fullscreen`;$.info(`fullscreen`,{from:Se,fullscreen:e===`fullscreen`}),Ce(e),d.savePanelSize(e),n.emit(`fullscreen`,e===`fullscreen`)},[n,Se,d]),Bn=l(()=>{Ee(e=>{let t=e===`history`?`chat`:`history`;return $.info(`toggleHistory`,{view:t}),n.emit(`toggleHistory`,{view:t}),t})},[n]),Vn=l(()=>{Xe(e=>{let t=!e;return $.info(`sidebarToggle`,{collapsed:t}),d.saveSidebarCollapsed(t),n.emit(`sidebarToggle`,{collapsed:t}),t})},[d,n]),Hn=l(e=>{$.info(`resize`,e),ct({widgetSize:e}),n.emit(`resize`,e)},[ct,n]),Un=l(async t=>{let i=t.conversationId;if(i===b.value&&jt(i)){$.info(`selectConversation`,{conversationId:i,cached:!0}),n.emit(`selectConversation`,{conversationId:i}),B.publishConversation(t),Ee(`chat`);let e=M();e&&P.switchTab(e),At(i);return}let a=++zt.current;Bt.current++,E(!1);function o(){return a!==zt.current}$.info(`selectConversation`,{conversationId:i,wasStreaming:je}),n.emit(`selectConversation`,{conversationId:i}),B.publishConversation(t);try{let[e,t]=await Promise.all([B.loadConversation(i),Rt(i)]);if(o())return;et.settle(),x.current=!0,fe.current=void 0;let n=Oi(e.messages),a=e.conversationId!==b.value,s=a?n:Yi(n,C.value);pe.current=s.some(e=>e.role===`user`)?void 0:e.conversationId,r(()=>{C.value=Ht(s,t),a&&(S.value=e.conversationId),b.value=e.conversationId}),k(t),d.saveConversationId(e.conversationId),B.primeIdentity(g,e.conversationId),ke(e.canContinue),e.controlState&&vt(e.controlState);let c=s.findLast(e=>e.role===`assistant`&&!e.ephemeral);He(c?.suggestions??[]),a?kt(e.conversationId):At(e.conversationId),Ee(`chat`);let l=M();l&&P.switchTab(l)}catch(t){if(o())return;n.emit(`error`,t),e.onError?.(t)}},[B,C,b,S,n,e,d,Rt,Ht,je,g,et,kt,At,jt,P]),Wn=l(e=>{if(typeof e!=`string`)return;R||Pn(),Ee(`chat`);let t=M();t&&P.switchTab(t),L?gn.fire(`manual`,e):wn.current=e},[R,Pn,e.modules,P,L,gn]),Gn=m(void 0),W=l(t=>{let n=e.modules.list.find(e=>e.layout===np[t.to]);if(!n){$.warn(`open: the widget has no such tab`,{to:t.to});return}let r=t.id&&(n.layout===`help`||n.layout===`news`)?{kind:`content`,id:t.id,title:``}:void 0;P.open(n.id,r)},[e.modules,P]),Kn=l(e=>{R||Pn(),e!=null&&(qt(e)?F?W(e):Gn.current=e:$.warn(`open: unknown target`,{detail:e}))},[R,Pn,F,W]);u(()=>{F&&Gn.current&&(W(Gn.current),Gn.current=void 0)},[F,W]);let qn=F&&!T&&!vn&&(!H||!An.value&&!U.value),[Jn,Yn]=h(),Xn=l(e=>{let t=Xt(e);t?(R||Pn(),Yn(t)):$.warn(`ask: expected { text, send? } with non-empty text`,{detail:e})},[R,Pn]),Zn=R&&L&&Oe&&F&&!T&&!vn,Qn=Zn&&qn&&!Ie&&!(H&&(je||kn));u(()=>{if(Jn===void 0||!(Jn.send?Qn:Zn))return;let e=M();e?Te!==`chat`||!ee()?(Ee(`chat`),P.switchTab(e)):(Yn(void 0),Jn.send?En(Jn.text,[]).then(e=>{e||Ft.current?.fill(Jn.text)}):Ft.current?.fill(Jn.text)):($.warn(`ask: the widget has no chat`),Yn(void 0))},[Jn,Zn,Qn,Te,ne,e.modules,P,En]),u(()=>{if(e.widgetId!=="default")return;let n=`data-${N.cssPrefix}-`,r=[`ask`,`open`,`close`,`form`].map(e=>n+e);function i(e){let i=e.composedPath().find(e=>e instanceof Element&&r.some(t=>e.hasAttribute(t)));if(!(i instanceof Element))return;e.preventDefault();let a=i.getAttribute(`${n}ask`),o=i.getAttribute(`${n}open`),s=i.getAttribute(`${n}form`);a===null?o===null?s===null?Qt(t,`close`):Qt(t,`openForm`,s):Qt(t,`open`,Jt(o)):Qt(t,`ask`,Yt(a||(i.textContent??``),{send:i.hasAttribute(`${n}send`)}))}return document.addEventListener(`click`,i),()=>document.removeEventListener(`click`,i)},[e.widgetId,t]),u(()=>{if(e.widgetId!=="default")return;let n=tn(location.href);n&&(history.replaceState(history.state,``,n.url),n.ask?Qt(t,`ask`,Yt(n.ask)):Qt(t,`open`,n.target))},[e.widgetId,t]);let $n=m(on),er=e.mode===`page`||e.mode===`inline`||e.mode===`standalone`;u(()=>a(()=>{let e=b.value,t={open:er||R,ready:F,unread:Et.value,...e?{conversationId:e}:{}},r=$n.current;(t.open!==r.open||t.ready!==r.ready||t.unread!==r.unread||t.conversationId!==r.conversationId)&&($n.current=t,n.emit(`state`,t),t.unread!==r.unread&&n.emit(`unread`,t.unread))}),[n,er,R,F,Et,b]);let tr=m({handleOpenCommand:Kn,handleClose:Nn,handleExpand:Rn,handleFullscreen:zn,openForm:Wn,handleAskCommand:Xn});tr.current={handleOpenCommand:Kn,handleClose:Nn,handleExpand:Rn,handleFullscreen:zn,openForm:Wn,handleAskCommand:Xn},f(()=>$t(t,{open:e=>tr.current.handleOpenCommand(e),close:()=>tr.current.handleClose(),expand:()=>tr.current.handleExpand(),fullscreen:()=>tr.current.handleFullscreen(),openForm:e=>tr.current.openForm(e),ask:e=>tr.current.handleAskCommand(e)}),[t]);let nr=p(()=>Le(e,tt,nt,rt),[e,tt,nt,rt]);Ue.current=nr.strings;let rr=p(()=>O.map(e=>{let t=hn.list.find(t=>t.id===e.formId);return{...e,title:t?.title,form:t}}),[O,hn]);function ir(e){Un(e)}let ar={options:nr,transport:B,feedback:$e,bus:n,persistence:d,conversationId:b.value??``,composerKey:S.value,composerApiRef:Ft,view:Te,canSend:Oe,isStreaming:je,pageToolRunning:dn,isMemoryCompacting:kn,canReleaseQueuedMessages:qn,queueManualMessages:H&&(An.value||U.value),sendPreparing:Ie,composerActive:nr.mode===`page`||nr.mode===`inline`||nr.mode===`standalone`||R,controlMode:mt.value,assignedOperatorInitials:ht.value,operatorAvailable:_t.value,operatorRequestEnabled:e.features.operatorRequest,onRequestOperator:xt,onCancelOperatorRequest:St,loadingMessages:T,onLoadPreviousMessages:Kt,messagesSig:C,reconnectingSig:w,agent:ze,suggestions:Ve,initialWidgetSize:y.widgetSize??null,onClose:Nn,onClear:Fn,onExpand:Rn,onFullscreen:zn,onSoundToggle:ft,onToggleHistory:Bn,onSelectHistoryConversation:ir,onNewConversation:In,onLocaleChange:lt,onThemeChange:ut,onTextSizeChange:dt,onWidgetSizeChange:Hn,onSend:En,onStop:jn,onSuggestion:t=>{if(Fe.current)return;let r=t.text??t.label;$.info(`suggestion`,{text:r,autoSend:e.autoSendSuggestions}),n.emit(`suggestion`,{text:r}),e.autoSendSuggestions?En(r,[]):Ft.current?.fill(r)},activeForm:_n.value?.form??null,formMarkers:rr,onFormSubmit:gn.complete,onFormSkip:gn.skip,onFormFill:e=>gn.fire(`manual`,e),tool:un,onRetry:Mn,onMessageFeedback:pn};if(!F)return null;let or=nr.modules.list;function sr(e){let t=Na(`close`,nr.mode,e);return or.length===0?/* @__PURE__ */ _(ef,{strings:nr.strings,onClose:t?Nn:void 0}):or.length===1&&or[0]?.layout===`chat`?/* @__PURE__ */ _(Hd,{...ar,panelSize:e}):/* @__PURE__ */ _(Qd,{panelProps:{...ar,panelSize:e,onClose:t?Nn:void 0},enabledModules:or,nav:P,bus:n,hasUnread:Tt.value,latestNews:Pt,onSelectConversation:ir,onStartNewConversation:Ln,onSetPanelSize:Ce})}if(e.mode===`page`){let t=e.history.enabled&&or.some(e=>e.layout===`chat`);return/* @__PURE__ */ _(`div`,{class:`${tp}-anchor`,children:/* @__PURE__ */ _(cf,{site:Ge,blocks:qe,transport:B,strings:nr.strings,locale:nr.locale,persistence:d,showConversations:t,onSelectConversation:ir,onNewConversation:In,sidebarCollapsed:Ye,onToggleSidebarCollapsed:Vn,children:sr(`fullscreen`)})})}if(se){let t=e.mode===`standalone`?`fullscreen`:Se;return/* @__PURE__ */ _(`div`,{class:`${tp}-anchor`,children:sr(t)})}let cr=e.mode===`drawer`,lr=e.mode!==`modal`&&!e.launcher.hidden&&(!R||ge),ur=lr&&!ge&&!ve&&!cr?nr.launcher.callout:null;return/* @__PURE__ */ v(`div`,{class:`${tp}-anchor`,"data-launcher-size":nr.launcher.size,children:[R||ue?/* @__PURE__ */ _(`div`,{class:`${tp}-surface`,hidden:!R,children:sr(Se)}):null,lr?/* @__PURE__ */ _(is,{onToggle:Pn,launcher:nr.launcher,strings:nr.strings,leaving:ge,edgeTab:cr}):null,ur?/* @__PURE__ */ _(cs,{callout:ur,launcherPosition:nr.position,strings:nr.strings,closeLabel:nr.strings.close,onDismiss:xe}):null]})}function ap(e){let t=e?.url??(typeof location<`u`?location.href:void 0);if(e||t)return{...e,...t?{url:t}:{}}}const op=120;async function sp(e,t,n,r){return(await Promise.all(t.map(async t=>{try{let{id:r,url:i,originalName:a,mimeType:o,fileSize:s}=await e.uploadFile(t.file,n);return{id:r,name:a,mediaType:o,size:s,url:i}}catch(e){r(e);return}}))).filter(e=>e!==void 0)}const cp=z.scope(`error-boundary`);var lp=class extends e{constructor(...e){super(...e),V(this,`state`,{crashed:!1})}componentDidCatch(e,t){cp.error(`widget render crashed`,{error:e,componentStack:t?.componentStack}),this.setState({crashed:!0}),this.props.onError(e,t?.componentStack)}render(){return this.state.crashed?this.props.fallback:this.props.children}};function up(e){let{bus:r,host:i,appRoot:a,persistence:o,reportError:s}=e,c=e.initialRaw,l,u=Ce(c),d=!0,f=0,p=ft(r);function m(){u=Ce(l?ze(c,l):c)}function h(){Pt(i,Ft(u.mode));let e=o.loadUserPrefs().themeMode;Wt(i,e?{...u,themeMode:e}:u),d&&(Ut(i,dp(u)),d=!1)}function g(){h(),n(t(lp,{onError:s},t(ip,{key:f,bus:r,hostElement:i,options:u,recentHostEvents:p})),a)}r.on(`handshake`,e=>{e.config&&(e.config.storageVersion&&o.rememberStorageVersion(e.config.storageVersion),l=e.config,m(),g())});let _=Tt(r,{getOptions:()=>u,getVisitorId:()=>o.getVisitorId(),getConversationId:()=>o.loadConversationId()});function v(e={}){o.reset(),c={...c,userContext:void 0,userToken:void 0,...e},p.length=0,f+=1,d=!0,m(),g()}return{getOptions:()=>u,getUserOptions:()=>c,render:g,setUserOptions:e=>{c=e,m(),g()},patchUserOptions:e=>{let t=`userToken`in e&&e.userToken!==c.userToken;t&&c.userToken?v(e):(t&&(f+=1),c={...c,...e},m(),g())},reset:()=>v(),destroy:()=>_()}}function dp(e){if(e.mode===`standalone`)return`standalone`;if(e.mode===`inline`)return`inline`;let t=gt(e.widgetId,e.storage,e.aiAgentDeploymentId),{panelOpen:n,panelSize:r}=Ya(e,Xa(),t.loadPanelOpen(),t.loadPanelSize());return qa(e.mode,r,n)}var fp=class extends HTMLElement{constructor(...e){super(...e),V(this,`bus`,new sn),V(this,`widgetState`,on),V(this,`userToken`,void 0),V(this,`pageTools`,[]),V(this,`markReady`,()=>{}),V(this,`ready`,new Promise(e=>{this.markReady=e})),V(this,`mountResult`,null),V(this,`runtime`,null)}static get observedAttributes(){return at}connectedCallback(){if(Object.hasOwn(this,`tools`)){let e=Reflect.get(this,`tools`);Reflect.deleteProperty(this,`tools`),this.pageTools=Array.isArray(e)?e:[]}this.boot()}disconnectedCallback(){this.mountResult&&(this.runtime?.destroy(),this.runtime=null,n(null,this.mountResult.appRoot),this.bus.clear(),this.widgetState=on)}attributeChangedCallback(){this.isConnected&&this.boot()}open(e){Qt(this,`open`,e)}close(){Qt(this,`close`)}expand(){Qt(this,`expand`)}openForm(e){Qt(this,`openForm`,e)}ask(e,t){Qt(this,`ask`,Yt(e,t))}get state(){return this.widgetState}reset(){this.userToken=void 0,this.runtime?.reset()}login(e){this.userToken=e,this.runtime?.patchUserOptions({userToken:e})}track(e,t){let n=dt(e,t);n&&this.bus.emit(`hostEvent`,n)}get tools(){return this.pageTools}set tools(e){this.pageTools=e,this.runtime?.patchUserOptions({tools:e})}registerTool(e,t){Ul(e,t)}on(e,t){return this.bus.on(e,t)}boot(){let e={...ot(e=>this.getAttribute(e)),...this.userToken?{userToken:this.userToken}:{},tools:this.pageTools};if(!e.aiAgentDeploymentId)throw Error(`ai-agent-deployment-id is required`);if(this.runtime){this.runtime.setUserOptions(e);return}let t=Ce(e);this.mountResult??(this.mountResult=It({existingHost:this,position:Ft(t.mode)}));let n=gt(t.widgetId,t.storage,t.aiAgentDeploymentId);this.bus.on(`state`,e=>{this.widgetState=e,e.ready&&this.markReady()}),this.runtime=up({bus:this.bus,host:this.mountResult.hostElement,appRoot:this.mountResult.appRoot,persistence:n,initialRaw:e,reportError:e=>this.bus.emit(`error`,e)}),this.runtime.render()}};let pp=!1;function mp(){if(pp||typeof customElements>`u`)return;let e=N.tagName;customElements.get(e)||customElements.define(e,fp),pp=!0}typeof customElements<`u`&&mp();export{mp as registerWebComponent};
|
|
35
35
|
//# sourceMappingURL=web-component.mjs.map
|