@aiden-voice/widget 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/widget.js CHANGED
@@ -9,6 +9,7 @@ var e = {
9
9
  message: "Message",
10
10
  messagePlaceholder: "Type a message…",
11
11
  send: "Send",
12
+ messageSent: "Message sent. {name} is preparing a response.",
12
13
  lookingItUp: "Looking that up for you…",
13
14
  goodResponse: "Good response",
14
15
  badResponse: "Bad response",
@@ -24,7 +25,7 @@ var e = {
24
25
  cancel: "Cancel",
25
26
  feedbackThanks: "Thanks for the feedback",
26
27
  feedbackFailed: "Couldn't send feedback",
27
- conversationCleared: "Conversation cleared",
28
+ conversationCleared: "New conversation started. Previous messages were cleared.",
28
29
  genericError: "Something went wrong, please try again.",
29
30
  sessionExpired: "This chat session has expired. Reload the page to continue.",
30
31
  opensInNewTab: "(opens in new tab)",
@@ -819,6 +820,7 @@ var Tt = {
819
820
  message: "Message",
820
821
  messagePlaceholder: "Écrivez un message…",
821
822
  send: "Envoyer",
823
+ messageSent: "Message envoyé. {name} prépare une réponse.",
822
824
  lookingItUp: "Je recherche l’information pour vous…",
823
825
  goodResponse: "Réponse utile",
824
826
  badResponse: "Réponse peu utile",
@@ -834,7 +836,7 @@ var Tt = {
834
836
  cancel: "Annuler",
835
837
  feedbackThanks: "Merci pour votre commentaire",
836
838
  feedbackFailed: "Impossible d’envoyer votre commentaire",
837
- conversationCleared: "Conversation effacée",
839
+ conversationCleared: "Nouvelle conversation démarrée. Les messages précédents ont été effacés.",
838
840
  genericError: "Une erreur s’est produite. Veuillez réessayer.",
839
841
  sessionExpired: "Cette session de chat a expiré. Rechargez la page pour continuer.",
840
842
  opensInNewTab: "(s’ouvre dans un nouvel onglet)",
@@ -850,6 +852,7 @@ var Tt = {
850
852
  message: "Mensaje",
851
853
  messagePlaceholder: "Escriba un mensaje…",
852
854
  send: "Enviar",
855
+ messageSent: "Mensaje enviado. {name} está preparando una respuesta.",
853
856
  lookingItUp: "Estoy buscando esa información…",
854
857
  goodResponse: "Buena respuesta",
855
858
  badResponse: "Mala respuesta",
@@ -865,7 +868,7 @@ var Tt = {
865
868
  cancel: "Cancelar",
866
869
  feedbackThanks: "Gracias por sus comentarios",
867
870
  feedbackFailed: "No se pudieron enviar sus comentarios",
868
- conversationCleared: "Se inició una nueva conversación",
871
+ conversationCleared: "Se inició una nueva conversación. Se borraron los mensajes anteriores.",
869
872
  genericError: "Algo salió mal. Inténtelo de nuevo.",
870
873
  sessionExpired: "Esta sesión de chat expiró. Vuelva a cargar la página para continuar.",
871
874
  opensInNewTab: "(se abre en una pestaña nueva)",
@@ -881,6 +884,7 @@ var Tt = {
881
884
  message: "Mensagem",
882
885
  messagePlaceholder: "Digite uma mensagem…",
883
886
  send: "Enviar",
887
+ messageSent: "Mensagem enviada. {name} está preparando uma resposta.",
884
888
  lookingItUp: "Estou buscando essa informação…",
885
889
  goodResponse: "Boa resposta",
886
890
  badResponse: "Resposta ruim",
@@ -896,7 +900,7 @@ var Tt = {
896
900
  cancel: "Cancelar",
897
901
  feedbackThanks: "Agradecemos seu feedback",
898
902
  feedbackFailed: "Não foi possível enviar o feedback",
899
- conversationCleared: "Nova conversa iniciada",
903
+ conversationCleared: "Nova conversa iniciada. As mensagens anteriores foram apagadas.",
900
904
  genericError: "Algo deu errado. Tente novamente.",
901
905
  sessionExpired: "Esta sessão de chat expirou. Recarregue a página para continuar.",
902
906
  opensInNewTab: "(abre em uma nova aba)",
@@ -912,6 +916,7 @@ var Tt = {
912
916
  message: "Nachricht",
913
917
  messagePlaceholder: "Nachricht eingeben…",
914
918
  send: "Senden",
919
+ messageSent: "Nachricht gesendet. {name} bereitet eine Antwort vor.",
915
920
  lookingItUp: "Ich suche die Informationen für Sie heraus…",
916
921
  goodResponse: "Gute Antwort",
917
922
  badResponse: "Schlechte Antwort",
@@ -927,7 +932,7 @@ var Tt = {
927
932
  cancel: "Abbrechen",
928
933
  feedbackThanks: "Danke für Ihr Feedback",
929
934
  feedbackFailed: "Feedback konnte nicht gesendet werden",
930
- conversationCleared: "Neue Unterhaltung gestartet",
935
+ conversationCleared: "Neue Unterhaltung gestartet. Die bisherigen Nachrichten wurden gelöscht.",
931
936
  genericError: "Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut.",
932
937
  sessionExpired: "Diese Chat-Sitzung ist abgelaufen. Laden Sie die Seite neu, um fortzufahren.",
933
938
  opensInNewTab: "(öffnet sich in neuem Tab)",
@@ -943,6 +948,7 @@ var Tt = {
943
948
  message: "Messaggio",
944
949
  messagePlaceholder: "Scrivi un messaggio…",
945
950
  send: "Invia",
951
+ messageSent: "Messaggio inviato. {name} sta preparando una risposta.",
946
952
  lookingItUp: "Sto cercando le informazioni richieste…",
947
953
  goodResponse: "Risposta utile",
948
954
  badResponse: "Risposta non utile",
@@ -958,7 +964,7 @@ var Tt = {
958
964
  cancel: "Annulla",
959
965
  feedbackThanks: "Grazie per il feedback",
960
966
  feedbackFailed: "Impossibile inviare il feedback",
961
- conversationCleared: "Nuova conversazione avviata",
967
+ conversationCleared: "Nuova conversazione avviata. I messaggi precedenti sono stati cancellati.",
962
968
  genericError: "Si è verificato un errore. Riprovi.",
963
969
  sessionExpired: "Questa sessione di chat è scaduta. Ricarichi la pagina per continuare.",
964
970
  opensInNewTab: "(si apre in una nuova scheda)",
@@ -974,6 +980,7 @@ var Tt = {
974
980
  message: "メッセージ",
975
981
  messagePlaceholder: "メッセージを入力…",
976
982
  send: "送信",
983
+ messageSent: "メッセージを送信しました。{name}が回答を準備しています。",
977
984
  lookingItUp: "確認しています…",
978
985
  goodResponse: "良い回答",
979
986
  badResponse: "良くない回答",
@@ -989,7 +996,7 @@ var Tt = {
989
996
  cancel: "キャンセル",
990
997
  feedbackThanks: "フィードバックありがとうございます",
991
998
  feedbackFailed: "フィードバックを送信できませんでした",
992
- conversationCleared: "会話を消去しました",
999
+ conversationCleared: "新しい会話を開始しました。以前のメッセージは消去されました。",
993
1000
  genericError: "エラーが発生しました。もう一度お試しください。",
994
1001
  sessionExpired: "このチャットセッションの有効期限が切れました。続けるにはページを再読み込みしてください。",
995
1002
  opensInNewTab: "(新しいタブで開きます)",
@@ -1005,6 +1012,7 @@ var Tt = {
1005
1012
  message: "消息",
1006
1013
  messagePlaceholder: "输入消息…",
1007
1014
  send: "发送",
1015
+ messageSent: "消息已发送。{name}正在准备回复。",
1008
1016
  lookingItUp: "正在为您查找……",
1009
1017
  goodResponse: "回答很好",
1010
1018
  badResponse: "回答不好",
@@ -1020,7 +1028,7 @@ var Tt = {
1020
1028
  cancel: "取消",
1021
1029
  feedbackThanks: "感谢您的反馈",
1022
1030
  feedbackFailed: "反馈提交失败",
1023
- conversationCleared: "对话已清除",
1031
+ conversationCleared: "已开始新对话。之前的消息已清除。",
1024
1032
  genericError: "出了点问题,请重试。",
1025
1033
  sessionExpired: "此聊天会话已过期。请刷新页面后继续。",
1026
1034
  opensInNewTab: "(将在新标签页中打开)",
@@ -1036,6 +1044,7 @@ var Tt = {
1036
1044
  message: "Сообщение",
1037
1045
  messagePlaceholder: "Введите сообщение…",
1038
1046
  send: "Отправить",
1047
+ messageSent: "Сообщение отправлено. {name} готовит ответ.",
1039
1048
  lookingItUp: "Ищу информацию…",
1040
1049
  goodResponse: "Хороший ответ",
1041
1050
  badResponse: "Плохой ответ",
@@ -1051,7 +1060,7 @@ var Tt = {
1051
1060
  cancel: "Отмена",
1052
1061
  feedbackThanks: "Спасибо за отзыв",
1053
1062
  feedbackFailed: "Не удалось отправить отзыв",
1054
- conversationCleared: "Диалог очищен",
1063
+ conversationCleared: "Начат новый диалог. Предыдущие сообщения удалены.",
1055
1064
  genericError: "Что-то пошло не так. Попробуйте ещё раз.",
1056
1065
  sessionExpired: "Срок действия сеанса чата истёк. Перезагрузите страницу, чтобы продолжить.",
1057
1066
  opensInNewTab: "(откроется в новой вкладке)",
@@ -1067,6 +1076,7 @@ var Tt = {
1067
1076
  message: "संदेश",
1068
1077
  messagePlaceholder: "संदेश लिखें…",
1069
1078
  send: "भेजें",
1079
+ messageSent: "संदेश भेज दिया गया। {name} द्वारा जवाब तैयार किया जा रहा है।",
1070
1080
  lookingItUp: "आपके लिए जानकारी खोजी जा रही है…",
1071
1081
  goodResponse: "अच्छा जवाब",
1072
1082
  badResponse: "ख़राब जवाब",
@@ -1082,7 +1092,7 @@ var Tt = {
1082
1092
  cancel: "रद्द करें",
1083
1093
  feedbackThanks: "आपके फ़ीडबैक के लिए धन्यवाद",
1084
1094
  feedbackFailed: "फ़ीडबैक नहीं भेजा जा सका",
1085
- conversationCleared: "बातचीत मिटा दी गई",
1095
+ conversationCleared: "नई बातचीत शुरू हुई। पिछले संदेश मिटा दिए गए।",
1086
1096
  genericError: "कुछ ग़लत हो गया। कृपया फिर से कोशिश करें।",
1087
1097
  sessionExpired: "यह चैट सत्र समाप्त हो गया है। जारी रखने के लिए पेज को फिर से लोड करें।",
1088
1098
  opensInNewTab: "(नए टैब में खुलता है)",
@@ -1098,6 +1108,7 @@ var Tt = {
1098
1108
  message: "الرسالة",
1099
1109
  messagePlaceholder: "كتابة رسالة…",
1100
1110
  send: "إرسال",
1111
+ messageSent: "تم إرسال الرسالة. جارٍ إعداد الرد من قِبل {name}.",
1101
1112
  lookingItUp: "جارٍ البحث عن المعلومات…",
1102
1113
  goodResponse: "إجابة جيدة",
1103
1114
  badResponse: "إجابة سيئة",
@@ -1113,7 +1124,7 @@ var Tt = {
1113
1124
  cancel: "إلغاء",
1114
1125
  feedbackThanks: "شكرًا على ملاحظاتك",
1115
1126
  feedbackFailed: "تعذّر إرسال الملاحظات",
1116
- conversationCleared: "تم مسح المحادثة",
1127
+ conversationCleared: "بدأت محادثة جديدة. تم مسح الرسائل السابقة.",
1117
1128
  genericError: "حدث خطأ ما. يُرجى المحاولة مرة أخرى.",
1118
1129
  sessionExpired: "انتهت صلاحية جلسة الدردشة هذه. يُرجى إعادة تحميل الصفحة للمتابعة.",
1119
1130
  opensInNewTab: "(يُفتح في علامة تبويب جديدة)",
@@ -1169,21 +1180,24 @@ function Lt(e) {
1169
1180
  hasName: !0
1170
1181
  };
1171
1182
  }
1183
+ function Rt(e, t) {
1184
+ return e.split("{name}").join(t.name);
1185
+ }
1172
1186
  //#endregion
1173
1187
  //#region src/viewport.ts
1174
- var Rt = "(max-width: 400px), (max-height: 420px)", zt = "data-fit-visible", Bt = 40;
1175
- function Vt(e) {
1188
+ var zt = "(max-width: 400px), (max-height: 420px)", Bt = "data-fit-visible", Vt = 40;
1189
+ function Ht(e) {
1176
1190
  let t = typeof window < "u" ? window.visualViewport : null;
1177
1191
  if (!t) return () => {};
1178
1192
  let n = () => {
1179
- e.removeAttribute(zt), e.style.removeProperty("--whoo-widget-visible-top"), e.style.removeProperty("--whoo-widget-visible-height");
1193
+ e.removeAttribute(Bt), e.style.removeProperty("--whoo-widget-visible-top"), e.style.removeProperty("--whoo-widget-visible-height");
1180
1194
  }, r = () => {
1181
1195
  let r = document.documentElement.clientHeight, i = Math.abs(t.scale - 1) > .01, a = r - t.height;
1182
- if (i || r === 0 || a < Bt) {
1196
+ if (i || r === 0 || a < Vt) {
1183
1197
  n();
1184
1198
  return;
1185
1199
  }
1186
- e.setAttribute(zt, ""), e.style.setProperty("--whoo-widget-visible-top", `${Math.max(0, t.offsetTop)}px`), e.style.setProperty("--whoo-widget-visible-height", `${t.height}px`);
1200
+ e.setAttribute(Bt, ""), e.style.setProperty("--whoo-widget-visible-top", `${Math.max(0, t.offsetTop)}px`), e.style.setProperty("--whoo-widget-visible-height", `${t.height}px`);
1187
1201
  let o = e.getRootNode().activeElement;
1188
1202
  o && e.contains(o) && typeof o.scrollIntoView == "function" && o.scrollIntoView({ block: "nearest" });
1189
1203
  };
@@ -1191,43 +1205,43 @@ function Vt(e) {
1191
1205
  t.removeEventListener("resize", r), t.removeEventListener("scroll", r), n();
1192
1206
  };
1193
1207
  }
1194
- function Ht(e, t) {
1208
+ function Ut(e, t) {
1195
1209
  return typeof e.addEventListener == "function" ? (e.addEventListener("change", t), () => e.removeEventListener("change", t)) : typeof e.addListener == "function" ? (e.addListener(t), () => e.removeListener(t)) : () => {};
1196
1210
  }
1197
- var Ut = 0, Wt = "";
1198
- function Gt() {
1199
- Ut++ === 0 && (Wt = document.documentElement.style.overflow, document.documentElement.style.overflow = "hidden");
1200
- }
1211
+ var Wt = 0, Gt = "";
1201
1212
  function Kt() {
1202
- --Ut === 0 && (document.documentElement.style.overflow = Wt);
1213
+ Wt++ === 0 && (Gt = document.documentElement.style.overflow, document.documentElement.style.overflow = "hidden");
1203
1214
  }
1204
1215
  function qt() {
1216
+ --Wt === 0 && (document.documentElement.style.overflow = Gt);
1217
+ }
1218
+ function Jt() {
1205
1219
  if (typeof window > "u" || typeof window.matchMedia != "function") return () => {};
1206
- let e = window.matchMedia(Rt), t = !1, n = () => {
1207
- e.matches && !t ? (t = !0, Gt()) : !e.matches && t && (t = !1, Kt());
1220
+ let e = window.matchMedia(zt), t = !1, n = () => {
1221
+ e.matches && !t ? (t = !0, Kt()) : !e.matches && t && (t = !1, qt());
1208
1222
  };
1209
1223
  n();
1210
- let r = Ht(e, n);
1224
+ let r = Ut(e, n);
1211
1225
  return () => {
1212
- r(), t && (t = !1, Kt());
1226
+ r(), t && (t = !1, qt());
1213
1227
  };
1214
1228
  }
1215
- function Jt(e) {
1229
+ function Yt(e) {
1216
1230
  if (typeof window > "u" || typeof window.matchMedia != "function" || typeof e.showModal != "function") return () => {};
1217
- let t = window.matchMedia(Rt), n = !1, r = () => {
1231
+ let t = window.matchMedia(zt), n = !1, r = () => {
1218
1232
  if (t.matches === n || !e.isConnected) return;
1219
1233
  n = t.matches;
1220
1234
  let r = e.getRootNode().activeElement;
1221
1235
  e.close(), n ? e.showModal() : e.show(), r && e.contains(r) && r.focus({ preventScroll: !0 });
1222
1236
  };
1223
- return r(), Ht(t, r);
1237
+ return r(), Ut(t, r);
1224
1238
  }
1225
1239
  //#endregion
1226
1240
  //#region src/components/Composer.tsx
1227
- function Yt(e) {
1241
+ function Xt(e) {
1228
1242
  return e.isComposing || e.keyCode === 229;
1229
1243
  }
1230
- function Xt({ value: t, onChange: n, onSend: r, disabled: i, inputRef: a, text: o = e, contentLanguage: s }) {
1244
+ function Zt({ value: t, onChange: n, onSend: r, disabled: i, inputRef: a, text: o = e, contentLanguage: s }) {
1231
1245
  return /* @__PURE__ */ W("div", {
1232
1246
  class: "whoo-widget-composer",
1233
1247
  children: [
@@ -1248,7 +1262,7 @@ function Xt({ value: t, onChange: n, onSend: r, disabled: i, inputRef: a, text:
1248
1262
  ref: a,
1249
1263
  onInput: (e) => n(e.target.value),
1250
1264
  onKeyDown: (e) => {
1251
- e.key === "Enter" && !Yt(e) && r();
1265
+ e.key === "Enter" && !Xt(e) && r();
1252
1266
  }
1253
1267
  }),
1254
1268
  /* @__PURE__ */ W("button", {
@@ -1265,7 +1279,7 @@ function Xt({ value: t, onChange: n, onSend: r, disabled: i, inputRef: a, text:
1265
1279
  }
1266
1280
  //#endregion
1267
1281
  //#region src/components/ErrorBanner.tsx
1268
- function Zt({ message: e }) {
1282
+ function Qt({ message: e }) {
1269
1283
  return /* @__PURE__ */ W("div", {
1270
1284
  class: "whoo-widget-error-banner",
1271
1285
  role: "alert",
@@ -1274,8 +1288,8 @@ function Zt({ message: e }) {
1274
1288
  }
1275
1289
  //#endregion
1276
1290
  //#region src/markdown/tokenizer.ts
1277
- var Qt = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, K = /\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y, $t = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, en = /\*([^*\s](?:[^*]*[^*\s])?)\*/y, tn = /[ \t]*[*+-][ \t]+/y, nn = /https?:\/\/\S+/y, rn = /[.,;:!?)\]}>]+$/;
1278
- function an(e) {
1291
+ var K = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, $t = /\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y, en = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, tn = /\*([^*\s](?:[^*]*[^*\s])?)\*/y, nn = /[ \t]*[*+-][ \t]+/y, rn = /https?:\/\/\S+/y, an = /[.,;:!?)\]}>]+$/;
1292
+ function on(e) {
1279
1293
  let t = [], n = 0, r = 0, i = (n) => {
1280
1294
  n > r && t.push({
1281
1295
  type: "text",
@@ -1285,13 +1299,13 @@ function an(e) {
1285
1299
  });
1286
1300
  };
1287
1301
  for (; n < e.length;) {
1288
- if ((n === 0 || e[n - 1] === "\n") && (tn.lastIndex = n, tn.exec(e))) {
1302
+ if ((n === 0 || e[n - 1] === "\n") && (nn.lastIndex = n, nn.exec(e))) {
1289
1303
  i(n), t.push({
1290
1304
  type: "text",
1291
1305
  value: "• ",
1292
1306
  start: n,
1293
- end: tn.lastIndex
1294
- }), n = tn.lastIndex, r = n;
1307
+ end: nn.lastIndex
1308
+ }), n = nn.lastIndex, r = n;
1295
1309
  continue;
1296
1310
  }
1297
1311
  if (e[n] === "!" && n + 1 < e.length && e[n + 1] === "[") {
@@ -1304,56 +1318,56 @@ function an(e) {
1304
1318
  }
1305
1319
  }
1306
1320
  if (e[n - 1] !== "!") {
1307
- Qt.lastIndex = n;
1308
- let a = Qt.exec(e);
1321
+ K.lastIndex = n;
1322
+ let a = K.exec(e);
1309
1323
  if (a) {
1310
1324
  i(n), t.push({
1311
1325
  type: "link",
1312
1326
  text: a[1],
1313
1327
  url: a[2],
1314
1328
  start: n,
1315
- end: Qt.lastIndex
1316
- }), n = Qt.lastIndex, r = n;
1329
+ end: K.lastIndex
1330
+ }), n = K.lastIndex, r = n;
1317
1331
  continue;
1318
1332
  }
1319
1333
  }
1320
- K.lastIndex = n;
1321
- let a = K.exec(e);
1334
+ $t.lastIndex = n;
1335
+ let a = $t.exec(e);
1322
1336
  if (a) {
1323
1337
  i(n), t.push({
1324
1338
  type: "bold",
1325
1339
  value: a[1],
1326
1340
  start: n,
1327
- end: K.lastIndex
1328
- }), n = K.lastIndex, r = n;
1341
+ end: $t.lastIndex
1342
+ }), n = $t.lastIndex, r = n;
1329
1343
  continue;
1330
1344
  }
1331
- $t.lastIndex = n;
1332
- let o = $t.exec(e);
1345
+ en.lastIndex = n;
1346
+ let o = en.exec(e);
1333
1347
  if (o) {
1334
1348
  i(n), t.push({
1335
1349
  type: "italic",
1336
1350
  value: o[1],
1337
1351
  start: n,
1338
- end: $t.lastIndex
1339
- }), n = $t.lastIndex, r = n;
1352
+ end: en.lastIndex
1353
+ }), n = en.lastIndex, r = n;
1340
1354
  continue;
1341
1355
  }
1342
- en.lastIndex = n;
1343
- let s = en.exec(e);
1356
+ tn.lastIndex = n;
1357
+ let s = tn.exec(e);
1344
1358
  if (s) {
1345
1359
  i(n), t.push({
1346
1360
  type: "italic",
1347
1361
  value: s[1],
1348
1362
  start: n,
1349
- end: en.lastIndex
1350
- }), n = en.lastIndex, r = n;
1363
+ end: tn.lastIndex
1364
+ }), n = tn.lastIndex, r = n;
1351
1365
  continue;
1352
1366
  }
1353
- nn.lastIndex = n;
1354
- let c = nn.exec(e);
1367
+ rn.lastIndex = n;
1368
+ let c = rn.exec(e);
1355
1369
  if (c) {
1356
- let e = c[0].match(rn), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
1370
+ let e = c[0].match(an), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
1357
1371
  if (a.length > 0) {
1358
1372
  i(n), t.push({
1359
1373
  type: "link",
@@ -1371,12 +1385,12 @@ function an(e) {
1371
1385
  }
1372
1386
  //#endregion
1373
1387
  //#region src/markdown/render.tsx
1374
- var on = /^[ \t]*[*+-][ \t]+(.*)$/, sn = /[\p{Script=Arabic}\p{Script=Hebrew}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Nko}\p{Script=Adlam}\p{Script=Samaritan}\p{Script=Mandaic}\p{Script=Hanifi_Rohingya}\p{Script=Mende_Kikakui}]/u;
1375
- function cn(e) {
1388
+ var sn = /^[ \t]*[*+-][ \t]+(.*)$/, cn = /[\p{Script=Arabic}\p{Script=Hebrew}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Nko}\p{Script=Adlam}\p{Script=Samaritan}\p{Script=Mandaic}\p{Script=Hanifi_Rohingya}\p{Script=Mende_Kikakui}]/u;
1389
+ function ln(e) {
1376
1390
  let t = e.match(/\p{L}/u)?.[0];
1377
- if (t) return sn.test(t) ? "rtl" : "ltr";
1391
+ if (t) return cn.test(t) ? "rtl" : "ltr";
1378
1392
  }
1379
- function ln(e) {
1393
+ function un(e) {
1380
1394
  let t = [], n = [], r = [], i = () => {
1381
1395
  n.length > 0 && t.push({
1382
1396
  type: "text",
@@ -1389,7 +1403,7 @@ function ln(e) {
1389
1403
  }), r = [];
1390
1404
  };
1391
1405
  for (let t of e.split("\n")) {
1392
- let e = t.match(on);
1406
+ let e = t.match(sn);
1393
1407
  e ? (i(), r.push(e[1])) : (a(), n.push(t));
1394
1408
  }
1395
1409
  return i(), a(), t.some((e) => e.type === "list") ? t.flatMap((e, n) => {
@@ -1402,7 +1416,7 @@ function ln(e) {
1402
1416
  }) : null;
1403
1417
  }
1404
1418
  function q(e, t = {}) {
1405
- return an(e).map((e, n) => {
1419
+ return on(e).map((e, n) => {
1406
1420
  switch (e.type) {
1407
1421
  case "bold": return /* @__PURE__ */ W("strong", { children: q(e.value, t) }, n);
1408
1422
  case "italic": return /* @__PURE__ */ W("em", { children: q(e.value, t) }, n);
@@ -1420,20 +1434,20 @@ function q(e, t = {}) {
1420
1434
  }
1421
1435
  });
1422
1436
  }
1423
- function un(e, t = {}) {
1424
- let n = e.replace(/\r\n?/g, "\n"), r = ln(n);
1437
+ function dn(e, t = {}) {
1438
+ let n = e.replace(/\r\n?/g, "\n"), r = un(n);
1425
1439
  return r ? r.map((e, n) => e.type === "list" ? /* @__PURE__ */ W("ul", {
1426
1440
  class: "whoo-widget-list",
1427
- dir: cn(e.items.find((e) => cn(e)) ?? ""),
1441
+ dir: ln(e.items.find((e) => ln(e)) ?? ""),
1428
1442
  children: e.items.map((e, n) => /* @__PURE__ */ W("li", {
1429
- dir: cn(e),
1443
+ dir: ln(e),
1430
1444
  children: q(e, t)
1431
1445
  }, n))
1432
1446
  }, n) : /* @__PURE__ */ W("span", { children: q(e.text, t) }, n)) : q(n, t);
1433
1447
  }
1434
1448
  //#endregion
1435
1449
  //#region src/components/MessageFeedback.tsx
1436
- function dn(e) {
1450
+ function fn(e) {
1437
1451
  return [
1438
1452
  {
1439
1453
  value: "",
@@ -1457,7 +1471,7 @@ function dn(e) {
1457
1471
  }
1458
1472
  ];
1459
1473
  }
1460
- function fn({ state: t, containerRef: n, onThumbsUp: r, onThumbsDown: i, onDraftChange: a, onSubmitDetailed: o, onCancel: s, text: c = e, contentLanguage: l }) {
1474
+ function pn({ state: t, containerRef: n, onThumbsUp: r, onThumbsDown: i, onDraftChange: a, onSubmitDetailed: o, onCancel: s, text: c = e, contentLanguage: l }) {
1461
1475
  let u = t.correction ?? "", d = t.category ?? "", f = H(t.status), p = H(null), m = H(null);
1462
1476
  if (V(() => {
1463
1477
  let e = f.current;
@@ -1493,7 +1507,7 @@ function fn({ state: t, containerRef: n, onThumbsUp: r, onThumbsDown: i, onDraft
1493
1507
  "aria-label": c.feedbackCategory,
1494
1508
  value: d,
1495
1509
  onChange: (e) => a(u, e.target.value),
1496
- children: dn(c).map((e) => /* @__PURE__ */ W("option", {
1510
+ children: fn(c).map((e) => /* @__PURE__ */ W("option", {
1497
1511
  value: e.value,
1498
1512
  children: e.label
1499
1513
  }, e.value))
@@ -1546,10 +1560,9 @@ function fn({ state: t, containerRef: n, onThumbsUp: r, onThumbsDown: i, onDraft
1546
1560
  }
1547
1561
  //#endregion
1548
1562
  //#region src/components/MessageList.tsx
1549
- function pn({ isSlowResponse: e, text: t }) {
1563
+ function mn({ isSlowResponse: e, text: t }) {
1550
1564
  return /* @__PURE__ */ W("div", {
1551
1565
  class: "whoo-widget-pending",
1552
- role: "status",
1553
1566
  children: [/* @__PURE__ */ W("span", {
1554
1567
  class: "whoo-widget-typing",
1555
1568
  "aria-hidden": "true",
@@ -1564,7 +1577,7 @@ function pn({ isSlowResponse: e, text: t }) {
1564
1577
  }) : null]
1565
1578
  });
1566
1579
  }
1567
- function mn({ url: e, alt: t, lang: n }) {
1580
+ function hn({ url: e, alt: t, lang: n }) {
1568
1581
  let [r, i] = nt(!1);
1569
1582
  return r ? null : /* @__PURE__ */ W("img", {
1570
1583
  class: "whoo-widget-empty-state-image",
@@ -1575,10 +1588,10 @@ function mn({ url: e, alt: t, lang: n }) {
1575
1588
  onError: () => i(!0)
1576
1589
  });
1577
1590
  }
1578
- var hn = "whoo-widget-notice";
1579
- function gn({ notice: e, placement: t = "top", text: n, contentLanguage: r, languageTag: i }) {
1591
+ var gn = "whoo-widget-notice";
1592
+ function _n({ notice: e, placement: t = "top", text: n, contentLanguage: r, languageTag: i }) {
1580
1593
  return t === "footer" ? /* @__PURE__ */ W("div", {
1581
- id: hn,
1594
+ id: gn,
1582
1595
  class: "whoo-widget-notice-footer",
1583
1596
  role: "note",
1584
1597
  tabIndex: 0,
@@ -1586,27 +1599,27 @@ function gn({ notice: e, placement: t = "top", text: n, contentLanguage: r, lang
1586
1599
  class: "whoo-widget-message-text",
1587
1600
  dir: "auto",
1588
1601
  lang: r,
1589
- children: un(e, {
1602
+ children: dn(e, {
1590
1603
  linkCue: n.opensInNewTab,
1591
1604
  linkCueLang: i
1592
1605
  })
1593
1606
  })
1594
1607
  }) : /* @__PURE__ */ W("div", {
1595
- id: hn,
1608
+ id: gn,
1596
1609
  class: "whoo-widget-notice",
1597
1610
  role: "note",
1598
1611
  children: /* @__PURE__ */ W("div", {
1599
1612
  class: "whoo-widget-message-text",
1600
1613
  dir: "auto",
1601
1614
  lang: r,
1602
- children: un(e, {
1615
+ children: dn(e, {
1603
1616
  linkCue: n.opensInNewTab,
1604
1617
  linkCueLang: i
1605
1618
  })
1606
1619
  })
1607
1620
  });
1608
1621
  }
1609
- function _n({ message: e, speaker: t, feedbackState: n, showFeedback: r, pending: i, isSlowResponse: a, onThumbsUp: o, onThumbsDown: s, onDraftChange: c, onSubmitDetailed: l, onCancelFeedback: u, text: d, contentLanguage: f, languageTag: p }) {
1622
+ function vn({ message: e, speaker: t, feedbackState: n, showFeedback: r, pending: i, isSlowResponse: a, onThumbsUp: o, onThumbsDown: s, onDraftChange: c, onSubmitDetailed: l, onCancelFeedback: u, text: d, contentLanguage: f, languageTag: p }) {
1610
1623
  let m = H(null), h = e.id;
1611
1624
  return /* @__PURE__ */ W("div", {
1612
1625
  ref: m,
@@ -1624,19 +1637,19 @@ function _n({ message: e, speaker: t, feedbackState: n, showFeedback: r, pending
1624
1637
  " "
1625
1638
  ]
1626
1639
  }),
1627
- i ? /* @__PURE__ */ W(pn, {
1640
+ i ? /* @__PURE__ */ W(mn, {
1628
1641
  isSlowResponse: a,
1629
1642
  text: d
1630
1643
  }) : /* @__PURE__ */ W("div", {
1631
1644
  class: "whoo-widget-message-text",
1632
1645
  dir: "auto",
1633
1646
  lang: f,
1634
- children: un(e.content, {
1647
+ children: dn(e.content, {
1635
1648
  linkCue: d.opensInNewTab,
1636
1649
  linkCueLang: p
1637
1650
  })
1638
1651
  }),
1639
- r && e.role === "assistant" && h ? /* @__PURE__ */ W(fn, {
1652
+ r && e.role === "assistant" && h ? /* @__PURE__ */ W(pn, {
1640
1653
  state: n,
1641
1654
  containerRef: m,
1642
1655
  onThumbsUp: () => o(h),
@@ -1650,7 +1663,7 @@ function _n({ message: e, speaker: t, feedbackState: n, showFeedback: r, pending
1650
1663
  ]
1651
1664
  });
1652
1665
  }
1653
- function vn({ messages: t, messageFeedback: n, announcement: r, emptyStateImage: i, centerEmptyState: a = !1, centeredGreeting: o, notice: s, agentName: c = l, showFeedback: u = !1, isStreaming: d = !1, isSlowResponse: f = !1, onThumbsUp: p, onThumbsDown: m, onDraftChange: h = () => {}, onSubmitDetailed: g, onCancelFeedback: _, text: v = e, contentLanguage: y, languageTag: b, announcementIsContent: x = !1 }) {
1666
+ function yn({ messages: t, messageFeedback: n, announcement: r, emptyStateImage: i, centerEmptyState: a = !1, centeredGreeting: o, notice: s, agentName: c = l, showFeedback: u = !1, isStreaming: d = !1, isSlowResponse: f = !1, onThumbsUp: p, onThumbsDown: m, onDraftChange: h = () => {}, onSubmitDetailed: g, onCancelFeedback: _, text: v = e, contentLanguage: y, languageTag: b, announcementIsContent: x = !1 }) {
1654
1667
  let S = H(null), C = !!s && !t.some((e) => e.role === "user");
1655
1668
  it(() => {
1656
1669
  let e = S.current;
@@ -1660,7 +1673,7 @@ function vn({ messages: t, messageFeedback: n, announcement: r, emptyStateImage:
1660
1673
  f,
1661
1674
  C
1662
1675
  ]);
1663
- let w = i ? /* @__PURE__ */ W(mn, {
1676
+ let w = i ? /* @__PURE__ */ W(hn, {
1664
1677
  ...i,
1665
1678
  lang: y
1666
1679
  }) : null, T = a && t.length === 0 && (i || o);
@@ -1671,7 +1684,7 @@ function vn({ messages: t, messageFeedback: n, announcement: r, emptyStateImage:
1671
1684
  tabIndex: 0,
1672
1685
  children: [
1673
1686
  a ? null : w,
1674
- s ? /* @__PURE__ */ W(gn, {
1687
+ s ? /* @__PURE__ */ W(_n, {
1675
1688
  notice: s,
1676
1689
  text: v,
1677
1690
  contentLanguage: y,
@@ -1683,13 +1696,13 @@ function vn({ messages: t, messageFeedback: n, announcement: r, emptyStateImage:
1683
1696
  class: "whoo-widget-empty-state-greeting whoo-widget-message-text",
1684
1697
  dir: "auto",
1685
1698
  lang: y,
1686
- children: un(o, {
1699
+ children: dn(o, {
1687
1700
  linkCue: v.opensInNewTab,
1688
1701
  linkCueLang: b
1689
1702
  })
1690
1703
  }) : null]
1691
1704
  }) : null,
1692
- t.map((e, r) => /* @__PURE__ */ W(_n, {
1705
+ t.map((e, r) => /* @__PURE__ */ W(vn, {
1693
1706
  message: e,
1694
1707
  speaker: e.role === "user" ? v.you : c,
1695
1708
  showFeedback: u,
@@ -1708,6 +1721,7 @@ function vn({ messages: t, messageFeedback: n, announcement: r, emptyStateImage:
1708
1721
  ]
1709
1722
  }), /* @__PURE__ */ W("div", {
1710
1723
  class: "whoo-widget-sr-only",
1724
+ role: "status",
1711
1725
  "aria-live": "polite",
1712
1726
  "aria-atomic": "true",
1713
1727
  lang: x ? y : b,
@@ -1716,38 +1730,38 @@ function vn({ messages: t, messageFeedback: n, announcement: r, emptyStateImage:
1716
1730
  }
1717
1731
  //#endregion
1718
1732
  //#region src/components/Panel.tsx
1719
- var yn = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
1720
- function bn(e) {
1721
- return Array.from(e.querySelectorAll(yn)).filter((e) => {
1733
+ var bn = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
1734
+ function xn(e) {
1735
+ return Array.from(e.querySelectorAll(bn)).filter((e) => {
1722
1736
  let t = getComputedStyle(e);
1723
1737
  return t.display !== "none" && t.visibility !== "hidden";
1724
1738
  });
1725
1739
  }
1726
- function xn({ state: e, controller: t, greeting: n }) {
1740
+ function Sn({ state: e, controller: t, greeting: n }) {
1727
1741
  let r = H(null), i = H(null), a = H(null), o = H(!1);
1728
1742
  V(() => {
1729
1743
  (a.current ?? i.current)?.focus();
1730
1744
  }, []), V(() => {
1731
1745
  e.noticeAgreed && o.current && (o.current = !1, i.current?.focus());
1732
1746
  }, [e.noticeAgreed]), V(() => {
1733
- let e = r.current, n = e ? Vt(e) : () => {}, i = e ? Jt(e) : () => {}, a = () => {
1747
+ let e = r.current, n = e ? Ht(e) : () => {}, i = e ? Yt(e) : () => {}, a = () => {
1734
1748
  e && !e.open && t.close();
1735
1749
  };
1736
1750
  e?.addEventListener("close", a);
1737
- let o = qt();
1751
+ let o = Jt();
1738
1752
  return () => {
1739
1753
  n(), i(), e?.removeEventListener("close", a), o();
1740
1754
  };
1741
1755
  }, []);
1742
1756
  let s = (e) => {
1743
- if (e.key === "Escape" && !Yt(e)) {
1757
+ if (e.key === "Escape" && !Xt(e)) {
1744
1758
  e.preventDefault(), t.close();
1745
1759
  return;
1746
1760
  }
1747
1761
  if (e.key !== "Tab") return;
1748
1762
  let n = r.current;
1749
1763
  if (!n) return;
1750
- let i = bn(n);
1764
+ let i = xn(n);
1751
1765
  if (i.length === 0) return;
1752
1766
  let a = n.getRootNode().activeElement;
1753
1767
  e.preventDefault();
@@ -1761,7 +1775,7 @@ function xn({ state: e, controller: t, greeting: n }) {
1761
1775
  }, c = () => {
1762
1776
  let n = e.draft.trim();
1763
1777
  n && !e.isStreaming && (t.setDraft(""), t.sendMessage(n));
1764
- }, l = u(t.config.name) || e.agentName || "Aiden", d = u(t.config.title), { before: f, after: p, hasName: m } = Lt(t.text.chatWith), h = t.greetingStyle === "centered", g = e.messages.length === 0 && n && !h ? [{
1778
+ }, l = t.resolvedAgentName, d = u(t.config.title), { before: f, after: p, hasName: m } = Lt(t.text.chatWith), h = t.greetingStyle === "centered", g = e.messages.length === 0 && n && !h ? [{
1765
1779
  role: "assistant",
1766
1780
  content: n,
1767
1781
  id: null
@@ -1774,7 +1788,7 @@ function xn({ state: e, controller: t, greeting: n }) {
1774
1788
  class: "whoo-widget-panel",
1775
1789
  "aria-modal": "true",
1776
1790
  "aria-labelledby": "whoo-widget-title",
1777
- "aria-describedby": t.notice && e.noticeAgreed && e.messages.length === 0 ? hn : void 0,
1791
+ "aria-describedby": t.notice && e.noticeAgreed && e.messages.length === 0 ? gn : void 0,
1778
1792
  ref: r,
1779
1793
  onKeyDown: s,
1780
1794
  onCancel: (e) => {
@@ -1826,7 +1840,7 @@ function xn({ state: e, controller: t, greeting: n }) {
1826
1840
  })]
1827
1841
  })]
1828
1842
  }),
1829
- /* @__PURE__ */ W(vn, {
1843
+ /* @__PURE__ */ W(yn, {
1830
1844
  messages: g,
1831
1845
  messageFeedback: e.messageFeedback,
1832
1846
  announcement: e.announcement,
@@ -1848,8 +1862,8 @@ function xn({ state: e, controller: t, greeting: n }) {
1848
1862
  languageTag: t.languageTag,
1849
1863
  announcementIsContent: e.announcementIsContent
1850
1864
  }),
1851
- e.runtimeError && /* @__PURE__ */ W(Zt, { message: e.runtimeError }),
1852
- e.noticeAgreed ? /* @__PURE__ */ W(Xt, {
1865
+ e.runtimeError && /* @__PURE__ */ W(Qt, { message: e.runtimeError }),
1866
+ e.noticeAgreed ? /* @__PURE__ */ W(Zt, {
1853
1867
  value: e.draft,
1854
1868
  onChange: (e) => t.setDraft(e),
1855
1869
  onSend: c,
@@ -1863,7 +1877,7 @@ function xn({ state: e, controller: t, greeting: n }) {
1863
1877
  type: "button",
1864
1878
  class: "whoo-widget-agreement-button",
1865
1879
  ref: a,
1866
- "aria-describedby": hn,
1880
+ "aria-describedby": gn,
1867
1881
  autoFocus: !0,
1868
1882
  onClick: () => {
1869
1883
  o.current = !0, t.agreeToNotice();
@@ -1871,7 +1885,7 @@ function xn({ state: e, controller: t, greeting: n }) {
1871
1885
  children: t.text.agreeToNotice
1872
1886
  })
1873
1887
  }),
1874
- v ? /* @__PURE__ */ W(gn, {
1888
+ v ? /* @__PURE__ */ W(_n, {
1875
1889
  notice: t.notice,
1876
1890
  placement: "footer",
1877
1891
  text: t.text,
@@ -1883,7 +1897,7 @@ function xn({ state: e, controller: t, greeting: n }) {
1883
1897
  }
1884
1898
  //#endregion
1885
1899
  //#region src/components/App.tsx
1886
- function Sn({ controller: e }) {
1900
+ function Cn({ controller: e }) {
1887
1901
  let [t, n] = nt(e.getState()), r = H(null), i = H(t.isOpen);
1888
1902
  return it(() => (n(e.getState()), e.subscribe(n)), [e]), V(() => {
1889
1903
  i.current && !t.isOpen && r.current?.focus(), i.current = t.isOpen;
@@ -1896,7 +1910,7 @@ function Sn({ controller: e }) {
1896
1910
  openIcon: e.launcher.openIcon,
1897
1911
  buttonRef: r,
1898
1912
  text: e.text
1899
- }), t.isOpen && /* @__PURE__ */ W(xn, {
1913
+ }), t.isOpen && /* @__PURE__ */ W(Sn, {
1900
1914
  state: t,
1901
1915
  controller: e,
1902
1916
  greeting: e.config.greeting
@@ -1904,44 +1918,44 @@ function Sn({ controller: e }) {
1904
1918
  }
1905
1919
  //#endregion
1906
1920
  //#region src/api/client.ts
1907
- var Cn = class extends Error {
1921
+ var wn = class extends Error {
1908
1922
  status;
1909
1923
  constructor(e, t) {
1910
1924
  super(e), this.name = "WidgetApiError", this.status = t;
1911
1925
  }
1912
1926
  };
1913
- function wn(e) {
1927
+ function Tn(e) {
1914
1928
  if (typeof e != "string") return null;
1915
1929
  let t = e.trim();
1916
1930
  return t === "" ? null : t;
1917
1931
  }
1918
- async function Tn(e, t) {
1932
+ async function En(e, t) {
1919
1933
  let n = await fetch(`${e}/api/v1/widget/session`, {
1920
1934
  method: "POST",
1921
1935
  headers: { "Content-Type": "application/json" },
1922
1936
  body: JSON.stringify({ publishable_key: t })
1923
1937
  });
1924
- if (!n.ok) throw new Cn(`Failed to create widget session (${n.status})`, n.status);
1938
+ if (!n.ok) throw new wn(`Failed to create widget session (${n.status})`, n.status);
1925
1939
  let r = await n.json();
1926
1940
  return {
1927
1941
  token: r.token,
1928
- ...En(r)
1942
+ ...Dn(r)
1929
1943
  };
1930
1944
  }
1931
- function En(e) {
1945
+ function Dn(e) {
1932
1946
  return {
1933
- primaryColor: wn(e.primary_color),
1934
- name: wn(e.name),
1935
- accentColor: wn(e.accent_color),
1936
- inkColor: wn(e.ink_color)
1947
+ primaryColor: Tn(e.primary_color),
1948
+ name: Tn(e.name),
1949
+ accentColor: Tn(e.accent_color),
1950
+ inkColor: Tn(e.ink_color)
1937
1951
  };
1938
1952
  }
1939
- async function Dn(e, t) {
1953
+ async function On(e, t) {
1940
1954
  let n = await fetch(`${e}/api/v1/widget/branding`, { headers: { Authorization: `Bearer ${t}` } });
1941
- if (!n.ok) throw new Cn(`Failed to load widget branding (${n.status})`, n.status);
1942
- return En(await n.json());
1955
+ if (!n.ok) throw new wn(`Failed to load widget branding (${n.status})`, n.status);
1956
+ return Dn(await n.json());
1943
1957
  }
1944
- async function On(e, t, n) {
1958
+ async function kn(e, t, n) {
1945
1959
  let r = await fetch(`${e}/api/v1/widget/feedback`, {
1946
1960
  method: "POST",
1947
1961
  headers: {
@@ -1955,11 +1969,11 @@ async function On(e, t, n) {
1955
1969
  category: n.category ?? null
1956
1970
  })
1957
1971
  });
1958
- if (!r.ok) throw new Cn(`Feedback submission failed (${r.status})`, r.status);
1972
+ if (!r.ok) throw new wn(`Feedback submission failed (${r.status})`, r.status);
1959
1973
  }
1960
1974
  //#endregion
1961
1975
  //#region src/api/sse.ts
1962
- async function* kn(e, t, n, r, i) {
1976
+ async function* An(e, t, n, r, i) {
1963
1977
  let a = await fetch(`${e}/api/v1/widget/chat`, {
1964
1978
  method: "POST",
1965
1979
  headers: {
@@ -1972,7 +1986,7 @@ async function* kn(e, t, n, r, i) {
1972
1986
  }),
1973
1987
  signal: i
1974
1988
  });
1975
- if (!a.ok || !a.body) throw new Cn(`Chat request failed (${a.status})`, a.status);
1989
+ if (!a.ok || !a.body) throw new wn(`Chat request failed (${a.status})`, a.status);
1976
1990
  let o = a.body.getReader(), s = new TextDecoder(), c = "";
1977
1991
  for (;;) {
1978
1992
  let { done: e, value: t } = await o.read();
@@ -1984,11 +1998,11 @@ async function* kn(e, t, n, r, i) {
1984
1998
  c = c.slice(n + 2);
1985
1999
  let t = e.split("\n").find((e) => e.startsWith("data: "));
1986
2000
  if (i?.aborted) return;
1987
- t && (yield An(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
2001
+ t && (yield jn(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
1988
2002
  }
1989
2003
  }
1990
2004
  }
1991
- function An(e) {
2005
+ function jn(e) {
1992
2006
  return typeof e.error == "string" ? {
1993
2007
  type: "error",
1994
2008
  error: e.error,
@@ -2011,11 +2025,11 @@ function An(e) {
2011
2025
  }
2012
2026
  //#endregion
2013
2027
  //#region src/markdown/plainText.ts
2014
- function jn(e) {
2015
- return an(e.replace(/\r\n?/g, "\n")).map((e) => {
2028
+ function Mn(e) {
2029
+ return on(e.replace(/\r\n?/g, "\n")).map((e) => {
2016
2030
  switch (e.type) {
2017
2031
  case "bold":
2018
- case "italic": return jn(e.value);
2032
+ case "italic": return Mn(e.value);
2019
2033
  case "link": return e.text;
2020
2034
  default: return e.value;
2021
2035
  }
@@ -2023,16 +2037,16 @@ function jn(e) {
2023
2037
  }
2024
2038
  //#endregion
2025
2039
  //#region src/markdown/reveal.ts
2026
- var Mn = 40, Nn = 120;
2027
- function Pn(e) {
2040
+ var Nn = 40, Pn = 120;
2041
+ function Fn(e) {
2028
2042
  let t = [];
2029
- for (let n of an(e)) if (n.type === "text") {
2043
+ for (let n of on(e)) if (n.type === "text") {
2030
2044
  let e = n.value.split(/(\s+)/), r = n.start;
2031
2045
  for (let n of e) r += n.length, n.trim().length > 0 && t.push(r);
2032
2046
  } else t.push(n.end);
2033
2047
  return t;
2034
2048
  }
2035
- function Fn(e) {
2049
+ function In(e) {
2036
2050
  let t = null;
2037
2051
  return e?.addEventListener("abort", () => {
2038
2052
  t?.();
@@ -2047,14 +2061,14 @@ function Fn(e) {
2047
2061
  });
2048
2062
  };
2049
2063
  }
2050
- async function In(e, t, n) {
2051
- let r = n?.wordIntervalMs ?? Mn, i = n?.tokenIntervalMs ?? Nn, a = n?.signal, o = an(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = Fn(a), l = "";
2052
- for (let n of Pn(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
2064
+ async function Ln(e, t, n) {
2065
+ let r = n?.wordIntervalMs ?? Nn, i = n?.tokenIntervalMs ?? Pn, a = n?.signal, o = on(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = In(a), l = "";
2066
+ for (let n of Fn(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
2053
2067
  l !== e && t(e);
2054
2068
  }
2055
2069
  //#endregion
2056
2070
  //#region src/sessionToken.ts
2057
- function Ln(e) {
2071
+ function Rn(e) {
2058
2072
  let t = e.split(".");
2059
2073
  if (t.length !== 3 || t.some((e) => e === "")) return null;
2060
2074
  let n = t[1];
@@ -2068,60 +2082,60 @@ function Ln(e) {
2068
2082
  return null;
2069
2083
  }
2070
2084
  }
2071
- function Rn(e) {
2072
- let t = Ln(e)?.exp;
2085
+ function zn(e) {
2086
+ let t = Rn(e)?.exp;
2073
2087
  return typeof t == "number" ? t * 1e3 : null;
2074
2088
  }
2075
- function zn(e, t = Date.now()) {
2076
- let n = Rn(e);
2089
+ function Bn(e, t = Date.now()) {
2090
+ let n = zn(e);
2077
2091
  return n !== null && n <= t;
2078
2092
  }
2079
- function Bn(e, t = Date.now()) {
2080
- let n = Ln(e);
2093
+ function Vn(e, t = Date.now()) {
2094
+ let n = Rn(e);
2081
2095
  return n?.exp == null ? null : n.iat != null && n.exp > n.iat ? t + (n.exp - n.iat) * 1e3 : n.exp * 1e3;
2082
2096
  }
2083
2097
  //#endregion
2084
2098
  //#region src/storage.ts
2085
- function Vn(e) {
2099
+ function Hn(e) {
2086
2100
  return `whoo-aiden-widget:conversation:${e}`;
2087
2101
  }
2088
- function Hn(e) {
2102
+ function Un(e) {
2089
2103
  try {
2090
- return window.sessionStorage.getItem(Vn(e));
2104
+ return window.sessionStorage.getItem(Hn(e));
2091
2105
  } catch {
2092
2106
  return null;
2093
2107
  }
2094
2108
  }
2095
- function Un(e, t) {
2109
+ function Wn(e, t) {
2096
2110
  try {
2097
- window.sessionStorage.setItem(Vn(e), t);
2111
+ window.sessionStorage.setItem(Hn(e), t);
2098
2112
  } catch {}
2099
2113
  }
2100
- function Wn(e) {
2114
+ function Gn(e) {
2101
2115
  return `whoo-aiden-widget:notice-agreed:${e}`;
2102
2116
  }
2103
- function Gn(e, t) {
2117
+ function Kn(e, t) {
2104
2118
  try {
2105
- return window.sessionStorage.getItem(Wn(e)) === t;
2119
+ return window.sessionStorage.getItem(Gn(e)) === t;
2106
2120
  } catch {
2107
2121
  return !1;
2108
2122
  }
2109
2123
  }
2110
- function Kn(e, t) {
2124
+ function qn(e, t) {
2111
2125
  try {
2112
- window.sessionStorage.setItem(Wn(e), t);
2126
+ window.sessionStorage.setItem(Gn(e), t);
2113
2127
  } catch {}
2114
2128
  }
2115
- function qn(e) {
2129
+ function Jn(e) {
2116
2130
  try {
2117
- window.sessionStorage.removeItem(Vn(e));
2131
+ window.sessionStorage.removeItem(Hn(e));
2118
2132
  } catch {}
2119
2133
  }
2120
2134
  //#endregion
2121
2135
  //#region src/theme.ts
2122
- var Jn = /^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;
2123
- function Yn(e) {
2124
- if (Jn.test(e.trim())) return null;
2136
+ var Yn = /^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;
2137
+ function Xn(e) {
2138
+ if (Yn.test(e.trim())) return null;
2125
2139
  let t = document.createElement("div");
2126
2140
  if (t.style.color = e, t.style.color === "") return null;
2127
2141
  let n = document.createElement("div");
@@ -2141,7 +2155,7 @@ function Yn(e) {
2141
2155
  };
2142
2156
  }
2143
2157
  function J(e) {
2144
- return Yn(e)?.rgb ?? null;
2158
+ return Xn(e)?.rgb ?? null;
2145
2159
  }
2146
2160
  function Y([e, t, n]) {
2147
2161
  let r = (e) => {
@@ -2150,59 +2164,59 @@ function Y([e, t, n]) {
2150
2164
  };
2151
2165
  return .2126 * r(e) + .7152 * r(t) + .0722 * r(n);
2152
2166
  }
2153
- function Xn(e, t) {
2167
+ function Zn(e, t) {
2154
2168
  let n = Math.max(e, t), r = Math.min(e, t);
2155
2169
  return (n + .05) / (r + .05);
2156
2170
  }
2157
- function Zn(e) {
2171
+ function Qn(e) {
2158
2172
  let t = J(e);
2159
2173
  if (!t) return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`), "#ffffff";
2160
2174
  let n = Y(t);
2161
- return Xn(n, Y([
2175
+ return Zn(n, Y([
2162
2176
  0,
2163
2177
  0,
2164
2178
  0
2165
- ])) >= Xn(n, Y([
2179
+ ])) >= Zn(n, Y([
2166
2180
  255,
2167
2181
  255,
2168
2182
  255
2169
2183
  ])) ? "#000000" : "#ffffff";
2170
2184
  }
2171
- function Qn(e, t) {
2185
+ function $n(e, t) {
2172
2186
  let n = J(e), r = J(t);
2173
- return !n || !r ? NaN : Xn(Y(n), Y(r));
2187
+ return !n || !r ? NaN : Zn(Y(n), Y(r));
2174
2188
  }
2175
- var $n = i.primary, er = i.panel, tr = i.assistantBubble, nr = i.headerHover, rr = 4.5;
2176
- function ir([e, t, n]) {
2189
+ var er = i.primary, tr = i.panel, nr = i.assistantBubble, rr = i.headerHover, ir = 4.5;
2190
+ function ar([e, t, n]) {
2177
2191
  return `#${[
2178
2192
  e,
2179
2193
  t,
2180
2194
  n
2181
2195
  ].map((e) => e.toString(16).padStart(2, "0")).join("")}`;
2182
2196
  }
2183
- function ar(e, t = er) {
2197
+ function or(e, t = tr) {
2184
2198
  let n = J(e), r = J(t);
2185
- if (!n || !r) return $n;
2186
- let i = Y(r), a = (e) => Xn(Y(e), i) >= rr;
2187
- if (a(n)) return ir(n);
2199
+ if (!n || !r) return er;
2200
+ let i = Y(r), a = (e) => Zn(Y(e), i) >= ir;
2201
+ if (a(n)) return ar(n);
2188
2202
  for (let e = .99; e > 0; e -= .01) {
2189
2203
  let t = n.map((t) => Math.round(t * e));
2190
- if (a(t)) return ir(t);
2204
+ if (a(t)) return ar(t);
2191
2205
  }
2192
2206
  return "#000000";
2193
2207
  }
2194
- var or = i.ink, sr = i.link;
2208
+ var sr = i.ink, cr = i.link;
2195
2209
  function X(e) {
2196
2210
  if (typeof e != "string" || !e) return null;
2197
- let t = Yn(e);
2198
- return t ? ir(t.rgb) : null;
2211
+ let t = Xn(e);
2212
+ return t ? ar(t.rgb) : null;
2199
2213
  }
2200
- function cr(e) {
2214
+ function lr(e) {
2201
2215
  if (typeof e != "string" || !e) return null;
2202
- let t = Yn(e);
2203
- return t ? t.translucent ? e.trim() : ir(t.rgb) : null;
2216
+ let t = Xn(e);
2217
+ return t ? t.translucent ? e.trim() : ar(t.rgb) : null;
2204
2218
  }
2205
- var lr = [
2219
+ var ur = [
2206
2220
  {
2207
2221
  role: "onPrimary",
2208
2222
  against: ["primary"],
@@ -2255,7 +2269,7 @@ var lr = [
2255
2269
  }
2256
2270
  ];
2257
2271
  function Z({ color: e, inkColor: t, accentColor: n, overrides: a }) {
2258
- let o = typeof a == "object" && a && !Array.isArray(a) ? a : {}, s = (e) => cr(o[e]), c = X(e), l = s("primary"), u = l ?? c ?? $n, d = s("primaryText"), f = d ?? ar(u, nr), p = s("onPrimary") ?? Zn(u), m = X(t), h = s("ink") ?? (m ? ar(m, tr) : or), g = X(n), _ = s("link") ?? (g ? ar(g, tr) : sr), v = (e) => s(e) ?? i[e], y = {
2272
+ let o = typeof a == "object" && a && !Array.isArray(a) ? a : {}, s = (e) => lr(o[e]), c = X(e), l = s("primary"), u = l ?? c ?? er, d = s("primaryText"), f = d ?? or(u, rr), p = s("onPrimary") ?? Qn(u), m = X(t), h = s("ink") ?? (m ? or(m, nr) : sr), g = X(n), _ = s("link") ?? (g ? or(g, nr) : cr), v = (e) => s(e) ?? i[e], y = {
2259
2273
  primary: u,
2260
2274
  onPrimary: p,
2261
2275
  primaryText: f,
@@ -2273,9 +2287,9 @@ function Z({ color: e, inkColor: t, accentColor: n, overrides: a }) {
2273
2287
  inputBorder: v("inputBorder"),
2274
2288
  focusRing: v("focusRing")
2275
2289
  }, b = Object.fromEntries(r.map((e) => [e, s(e) !== null])), x = [];
2276
- for (let { role: e, against: t, required: n } of lr) for (let r of t) {
2290
+ for (let { role: e, against: t, required: n } of ur) for (let r of t) {
2277
2291
  if (!b[e] && !b[r]) continue;
2278
- let t = Qn(y[e], y[r]);
2292
+ let t = $n(y[e], y[r]);
2279
2293
  Number.isFinite(t) && t < n && x.push({
2280
2294
  role: e,
2281
2295
  against: r,
@@ -2304,62 +2318,62 @@ function Z({ color: e, inkColor: t, accentColor: n, overrides: a }) {
2304
2318
  function Q(e) {
2305
2319
  return typeof e == "string" ? `"${e}"` : `a ${typeof e} value`;
2306
2320
  }
2307
- function ur(e, t, n = $n) {
2321
+ function dr(e, t, n = er) {
2308
2322
  let r = t;
2309
2323
  X(t) === null && (console.warn(`[whoo-aiden-widget] Could not use ${Q(t)} as the theme color; falling back to ${Q(n)}.`), r = n);
2310
2324
  let i = Z({ color: r });
2311
2325
  e.style.setProperty("--whoo-widget-color", i.primary), e.style.setProperty("--whoo-widget-text-on-color", i.textOnPrimary), e.style.setProperty("--whoo-widget-color-text", i.primaryAsText);
2312
2326
  }
2313
- function dr(e, { inkColor: t, accentColor: n }) {
2327
+ function fr(e, { inkColor: t, accentColor: n }) {
2314
2328
  let r = Z({
2315
2329
  inkColor: t,
2316
2330
  accentColor: n
2317
2331
  });
2318
2332
  e.style.setProperty("--whoo-widget-ink", r.ink), e.style.setProperty("--whoo-widget-link-color", r.link);
2319
2333
  }
2320
- function fr(e, t) {
2334
+ function pr(e, t) {
2321
2335
  let n = Z({ overrides: t });
2322
2336
  for (let t of r) {
2323
2337
  let r = n.overridden.primary && (t === "onPrimary" || t === "primaryText");
2324
2338
  (n.overridden[t] || r) && e.style.setProperty(a[t], n.roles[t]);
2325
2339
  }
2326
2340
  }
2327
- function pr(e, t) {
2341
+ function mr(e, t) {
2328
2342
  e && X(e) === null && console.warn(`[whoo-aiden-widget] Could not use ${Q(e)} as the ${t}; using the default.`);
2329
2343
  }
2330
- function mr(e, t, n) {
2344
+ function hr(e, t, n) {
2331
2345
  for (let e of r) {
2332
2346
  let n = t[e];
2333
2347
  n && X(n) === null && console.warn(`[whoo-aiden-widget] Could not use ${Q(n)} as theme.colors.${e}; using the calculated color.`);
2334
2348
  }
2335
2349
  let i = t.primary;
2336
- typeof i == "string" && Yn(i)?.translucent && console.warn(`[whoo-aiden-widget] theme.colors.primary ${Q(i)} is translucent. The launcher shows your page through it, so its icon may be unreadable over dark content; pass a solid color.`), hr({
2350
+ typeof i == "string" && Xn(i)?.translucent && console.warn(`[whoo-aiden-widget] theme.colors.primary ${Q(i)} is translucent. The launcher shows your page through it, so its icon may be unreadable over dark content; pass a solid color.`), gr({
2337
2351
  color: e.color,
2338
2352
  inkColor: e.inkColor,
2339
2353
  accentColor: e.accentColor,
2340
2354
  overrides: t
2341
2355
  }, n);
2342
2356
  }
2343
- function hr(e, t) {
2357
+ function gr(e, t) {
2344
2358
  for (let n of Z(e).contrastWarnings) {
2345
2359
  let { role: e, against: r, value: i, ratio: a, required: o, overridden: s } = n, c = `${e}|${r}|${i}`;
2346
2360
  t.has(c) || (t.add(c), console.warn(s ? `[whoo-aiden-widget] theme.colors.${e} (${i}) has ${a.toFixed(2)}:1 contrast against the ${r} color; ${o}:1 is recommended. Using it as given.` : `[whoo-aiden-widget] the ${e} color (${i}) has ${a.toFixed(2)}:1 contrast against your theme.colors.${r}; ${o}:1 is recommended. Override theme.colors.${e} too.`));
2347
2361
  }
2348
2362
  }
2349
- function gr(e, t, n = /* @__PURE__ */ new Set()) {
2350
- ur(e, t.color ?? $n), pr(t.inkColor, "ink color"), pr(t.accentColor, "accent color"), dr(e, {
2363
+ function _r(e, t, n = /* @__PURE__ */ new Set()) {
2364
+ dr(e, t.color ?? er), mr(t.inkColor, "ink color"), mr(t.accentColor, "accent color"), fr(e, {
2351
2365
  inkColor: t.inkColor,
2352
2366
  accentColor: t.accentColor
2353
2367
  });
2354
2368
  let r = ae(t.theme);
2355
- mr(t, r.colors, n), fr(e, r.colors), r.fontFamily && e.style.setProperty("--whoo-widget-font", r.fontFamily);
2369
+ hr(t, r.colors, n), pr(e, r.colors), r.fontFamily && e.style.setProperty("--whoo-widget-font", r.fontFamily);
2356
2370
  }
2357
2371
  //#endregion
2358
2372
  //#region src/controller.ts
2359
- var _r = 8e3, vr = 3e3, yr = 15e3, br = class extends Error {
2373
+ var vr = 8e3, yr = 3e3, br = 15e3, xr = class extends Error {
2360
2374
  name = "SessionUnavailableError";
2361
2375
  };
2362
- function xr(e, t) {
2376
+ function Sr(e, t) {
2363
2377
  return t ? new Promise((n, r) => {
2364
2378
  let i = () => r(new DOMException("Aborted", "AbortError"));
2365
2379
  if (t.aborted) return i();
@@ -2370,23 +2384,23 @@ function xr(e, t) {
2370
2384
  });
2371
2385
  }) : e;
2372
2386
  }
2373
- function Sr(e, t) {
2374
- return e === "refused" ? new wr(t) : new br();
2387
+ function Cr(e, t) {
2388
+ return e === "refused" ? new Tr(t) : new xr();
2375
2389
  }
2376
- function Cr(e) {
2390
+ function wr(e) {
2377
2391
  let t = e?.status;
2378
2392
  return t === 401 || t === 403 || t === 404;
2379
2393
  }
2380
- var wr = class extends Error {
2394
+ var Tr = class extends Error {
2381
2395
  name = "SessionExpiredError";
2382
2396
  constructor(e) {
2383
2397
  super(e instanceof Error ? e.message : "The session has expired.");
2384
2398
  }
2385
2399
  };
2386
- function Tr(e) {
2400
+ function Er(e) {
2387
2401
  return e?.status === 401;
2388
2402
  }
2389
- function Er(e, t) {
2403
+ function Dr(e, t) {
2390
2404
  return new Promise((n) => {
2391
2405
  let r = setTimeout(n, t);
2392
2406
  e.then(() => {
@@ -2394,7 +2408,7 @@ function Er(e, t) {
2394
2408
  });
2395
2409
  });
2396
2410
  }
2397
- var Dr = class {
2411
+ var Or = class {
2398
2412
  config;
2399
2413
  state;
2400
2414
  listeners = /* @__PURE__ */ new Set();
@@ -2408,6 +2422,7 @@ var Dr = class {
2408
2422
  storageIdentifier;
2409
2423
  activeRequestController = null;
2410
2424
  slowResponseTimer = null;
2425
+ announcementTimer = null;
2411
2426
  prefersReducedMotion;
2412
2427
  launcher;
2413
2428
  launcherIconUrl;
@@ -2450,7 +2465,7 @@ var Dr = class {
2450
2465
  announcement: null,
2451
2466
  announcementIsContent: !1,
2452
2467
  isSlowResponse: !1,
2453
- noticeAgreed: !this.requireNoticeAgreement || Gn(this.storageIdentifier, this.notice),
2468
+ noticeAgreed: !this.requireNoticeAgreement || Kn(this.storageIdentifier, this.notice),
2454
2469
  draft: ""
2455
2470
  };
2456
2471
  }
@@ -2460,6 +2475,20 @@ var Dr = class {
2460
2475
  subscribe(e) {
2461
2476
  return this.listeners.add(e), () => this.listeners.delete(e);
2462
2477
  }
2478
+ get resolvedAgentName() {
2479
+ return u(this.config.name) || this.state.agentName || "Aiden";
2480
+ }
2481
+ announce(e, t = !1, n = !1) {
2482
+ this.announcementTimer !== null && (clearTimeout(this.announcementTimer), this.announcementTimer = null), n && e !== null && this.state.announcement !== e ? this.setState({
2483
+ announcement: e,
2484
+ announcementIsContent: t
2485
+ }) : (this.state.announcement !== null && this.setState({ announcement: null }), e !== null && (this.announcementTimer = setTimeout(() => {
2486
+ this.announcementTimer = null, this.setState({
2487
+ announcement: e,
2488
+ announcementIsContent: t
2489
+ });
2490
+ }, 250)));
2491
+ }
2463
2492
  clearSlowResponse() {
2464
2493
  this.slowResponseTimer !== null && (clearTimeout(this.slowResponseTimer), this.slowResponseTimer = null), this.state.isSlowResponse && this.setState({ isSlowResponse: !1 });
2465
2494
  }
@@ -2482,12 +2511,12 @@ var Dr = class {
2482
2511
  let e = this.config.apiBaseUrl ?? "https://api.aidenvoice.com";
2483
2512
  try {
2484
2513
  if (this.config.sessionToken) {
2485
- if (zn(this.config.sessionToken)) {
2514
+ if (Bn(this.config.sessionToken)) {
2486
2515
  if (!("token" in await this.renewToken())) throw Error("The sessionToken has expired.");
2487
- } else this.sessionToken = this.config.sessionToken, this.sessionTokenExpiresAt = Rn(this.config.sessionToken);
2516
+ } else this.sessionToken = this.config.sessionToken, this.sessionTokenExpiresAt = zn(this.config.sessionToken);
2488
2517
  } else if (this.config.publishableKey) {
2489
- let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await Tn(e, this.config.publishableKey);
2490
- this.sessionToken = t, this.sessionTokenExpiresAt = Bn(t), this.setState({
2518
+ let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await En(e, this.config.publishableKey);
2519
+ this.sessionToken = t, this.sessionTokenExpiresAt = Vn(t), this.setState({
2491
2520
  primaryColor: n,
2492
2521
  agentName: r,
2493
2522
  accentColor: i,
@@ -2498,13 +2527,13 @@ var Dr = class {
2498
2527
  console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) });
2499
2528
  return;
2500
2529
  }
2501
- this.conversationId = Hn(this.storageIdentifier), this.config.sessionToken && await Er(this.loadBranding(e), vr);
2530
+ this.conversationId = Un(this.storageIdentifier), this.config.sessionToken && await Dr(this.loadBranding(e), yr);
2502
2531
  }
2503
2532
  async loadBranding(e) {
2504
2533
  try {
2505
2534
  let t = this.config;
2506
2535
  if (X(t.color) && X(t.inkColor) && X(t.accentColor) && u(t.name)) return;
2507
- let { primaryColor: n, name: r, accentColor: i, inkColor: a } = await this.withSession((t) => Dn(e, t));
2536
+ let { primaryColor: n, name: r, accentColor: i, inkColor: a } = await this.withSession((t) => On(e, t));
2508
2537
  this.setState({
2509
2538
  primaryColor: n,
2510
2539
  agentName: r,
@@ -2513,30 +2542,28 @@ var Dr = class {
2513
2542
  });
2514
2543
  } catch (e) {
2515
2544
  let t = e?.status;
2516
- (e instanceof wr || t === 401 || t === 403) && (this.state.isInitializing ? (console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) })) : (console.error("[whoo-aiden-widget] the session was refused after start-up:", e), this.setState({ runtimeError: this.text.sessionExpired })));
2545
+ (e instanceof Tr || t === 401 || t === 403) && (this.state.isInitializing ? (console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) })) : (console.error("[whoo-aiden-widget] the session was refused after start-up:", e), this.setState({ runtimeError: this.text.sessionExpired })));
2517
2546
  }
2518
2547
  }
2519
2548
  open() {
2520
2549
  this.setState({ isOpen: !0 });
2521
2550
  }
2522
2551
  resetConversation() {
2523
- this.sendEpoch += 1, this.activeRequestController?.abort("reset"), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null, qn(this.storageIdentifier), this.setState({
2552
+ this.sendEpoch += 1, this.activeRequestController?.abort("reset"), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null, Jn(this.storageIdentifier), this.setState({
2524
2553
  messages: [],
2525
2554
  messageFeedback: {},
2526
2555
  runtimeError: null,
2527
- isStreaming: !1,
2528
- announcement: this.text.conversationCleared,
2529
- announcementIsContent: !1
2530
- });
2556
+ isStreaming: !1
2557
+ }), this.announce(this.text.conversationCleared);
2531
2558
  }
2532
2559
  agreeToNotice() {
2533
- this.state.noticeAgreed || (Kn(this.storageIdentifier, this.notice), this.setState({ noticeAgreed: !0 }));
2560
+ this.state.noticeAgreed || (qn(this.storageIdentifier, this.notice), this.setState({ noticeAgreed: !0 }));
2534
2561
  }
2535
2562
  setDraft(e) {
2536
2563
  this.setState({ draft: e });
2537
2564
  }
2538
2565
  close() {
2539
- this.activeRequestController?.abort("close"), this.activeRequestController = null, this.clearSlowResponse(), this.setState({ isOpen: !1 });
2566
+ this.activeRequestController?.abort("close"), this.activeRequestController = null, this.clearSlowResponse(), this.announce(null), this.setState({ isOpen: !1 });
2540
2567
  }
2541
2568
  async sendMessage(e) {
2542
2569
  if (!this.sessionToken || !this.state.noticeAgreed) return;
@@ -2558,9 +2585,8 @@ var Dr = class {
2558
2585
  a
2559
2586
  ],
2560
2587
  isStreaming: !0,
2561
- runtimeError: null,
2562
- announcement: null
2563
- });
2588
+ runtimeError: null
2589
+ }), this.announce(Rt(this.text.messageSent, { name: this.resolvedAgentName }), !1, !0);
2564
2590
  let o = a, s = (e) => {
2565
2591
  let t = o;
2566
2592
  o = {
@@ -2571,17 +2597,19 @@ var Dr = class {
2571
2597
  this.activeRequestController = l;
2572
2598
  let { signal: u } = l, d = !1;
2573
2599
  this.slowResponseTimer = setTimeout(() => {
2574
- this.slowResponseTimer = null, this.setState({ isSlowResponse: !0 });
2575
- }, _r);
2600
+ this.slowResponseTimer = null, this.setState({ isSlowResponse: !0 }), r() && this.announce(this.text.lookingItUp);
2601
+ }, vr);
2576
2602
  let f = !1, p = () => {
2577
2603
  this.state.draft === "" && (f = !0, this.setState({ draft: e }));
2578
- }, m = (e = this.text.genericError) => {
2579
- r() && (this.setState({ runtimeError: e }), p());
2580
- }, h = "";
2604
+ }, m = !1, h = (e) => {
2605
+ m = !0, this.announce(Mn(e), !0);
2606
+ }, g = (e = this.text.genericError) => {
2607
+ r() && (m || (m = !0, this.announce(null)), this.setState({ runtimeError: e }), p());
2608
+ }, _ = "";
2581
2609
  try {
2582
2610
  let { stream: n, first: i } = await this.withSession(async (n) => {
2583
2611
  d = !0;
2584
- let r = kn(t, n, this.conversationId, e, u);
2612
+ let r = An(t, n, this.conversationId, e, u);
2585
2613
  return {
2586
2614
  stream: r,
2587
2615
  first: await r.next()
@@ -2589,25 +2617,19 @@ var Dr = class {
2589
2617
  }, u);
2590
2618
  for (let e = i; !e.done && !u.aborted && r(); e = await n.next()) {
2591
2619
  let t = e.value;
2592
- if (t.type === "conversation_id") this.conversationId = t.conversationId, Un(this.storageIdentifier, t.conversationId);
2593
- else if (t.type === "delta") this.clearSlowResponse(), t.verbatim && !this.prefersReducedMotion ? (await In(t.delta, (e) => c(e), { signal: u }), h = t.delta) : t.verbatim ? (h = t.delta, c(h)) : (h += t.delta, c(h));
2594
- else if (t.type === "done") t.conversationId && (this.conversationId = t.conversationId, Un(this.storageIdentifier, t.conversationId)), t.messageId && s({ id: t.messageId }), r() && this.setState({
2595
- announcement: jn(h),
2596
- announcementIsContent: !0
2597
- });
2620
+ if (t.type === "conversation_id") this.conversationId = t.conversationId, Wn(this.storageIdentifier, t.conversationId);
2621
+ else if (t.type === "delta") this.clearSlowResponse(), t.verbatim && !this.prefersReducedMotion ? (await Ln(t.delta, (e) => c(e), { signal: u }), _ = t.delta) : t.verbatim ? (_ = t.delta, c(_)) : (_ += t.delta, c(_));
2622
+ else if (t.type === "done") t.conversationId && (this.conversationId = t.conversationId, Wn(this.storageIdentifier, t.conversationId)), t.messageId && s({ id: t.messageId }), r() && h(_);
2598
2623
  else if (t.type === "error") {
2599
- console.error("[whoo-aiden-widget] chat error:", t.error), h.trim() !== "" && r() && this.setState({
2600
- announcement: jn(h),
2601
- announcementIsContent: !0
2602
- }), m(), l.abort();
2624
+ console.error("[whoo-aiden-widget] chat error:", t.error), _.trim() !== "" && r() && h(_), g(), l.abort();
2603
2625
  break;
2604
2626
  }
2605
2627
  }
2606
2628
  } catch (e) {
2607
- u.aborted ? u.reason === "close" && r() && !d && p() : e instanceof wr ? (console.error("[whoo-aiden-widget] chat request failed: the session has expired.", e), m(this.text.sessionExpired)) : e instanceof br ? (console.error("[whoo-aiden-widget] chat request failed: no session could be had."), m()) : (console.error("[whoo-aiden-widget] chat request failed:", e), m());
2629
+ u.aborted ? u.reason === "close" && r() && !d && p() : e instanceof Tr ? (console.error("[whoo-aiden-widget] chat request failed: the session has expired.", e), g(this.text.sessionExpired)) : e instanceof xr ? (console.error("[whoo-aiden-widget] chat request failed: no session could be had."), g()) : (console.error("[whoo-aiden-widget] chat request failed:", e), g());
2608
2630
  } finally {
2609
2631
  let e = o.id === null && o.content.trim() === "", t = this.state.messages.filter((t) => !(e && t === o) && !(e && f && t === i)), n = t.length !== this.state.messages.length;
2610
- r() ? (this.activeRequestController = null, this.clearSlowResponse(), this.setState({
2632
+ r() ? (this.activeRequestController = null, this.clearSlowResponse(), m || (!u.aborted && _.trim() !== "" ? h(_) : this.announce(null)), this.setState({
2611
2633
  isStreaming: !1,
2612
2634
  ...n ? { messages: t } : {}
2613
2635
  })) : n && this.setState({ messages: t });
@@ -2651,7 +2673,7 @@ var Dr = class {
2651
2673
  }
2652
2674
  } });
2653
2675
  try {
2654
- await this.withSession((a) => On(i, a, {
2676
+ await this.withSession((a) => kn(i, a, {
2655
2677
  messageId: e,
2656
2678
  rating: t,
2657
2679
  correction: n,
@@ -2677,7 +2699,7 @@ var Dr = class {
2677
2699
  }
2678
2700
  async currentToken(e) {
2679
2701
  let t = this.sessionToken, n = this.sessionTokenExpiresAt;
2680
- return t && (n === null || n - Date.now() > 6e4) ? { token: t } : xr(this.renewToken(), e);
2702
+ return t && (n === null || n - Date.now() > 6e4) ? { token: t } : Sr(this.renewToken(), e);
2681
2703
  }
2682
2704
  renewToken() {
2683
2705
  return this.tokenRenewal ??= this.fetchNewToken().finally(() => {
@@ -2688,7 +2710,7 @@ var Dr = class {
2688
2710
  let e = ++this.renewalGeneration, t, n = new Promise((e) => {
2689
2711
  t = setTimeout(() => {
2690
2712
  console.error("[whoo-aiden-widget] could not renew the session: it took too long."), e({ failure: "unavailable" });
2691
- }, yr);
2713
+ }, br);
2692
2714
  });
2693
2715
  try {
2694
2716
  return await Promise.race([this.obtainToken(e), n]);
@@ -2699,64 +2721,64 @@ var Dr = class {
2699
2721
  async obtainToken(e) {
2700
2722
  let t = this.config.apiBaseUrl ?? "https://api.aidenvoice.com", n;
2701
2723
  try {
2702
- if (this.config.publishableKey) n = (await Tn(t, this.config.publishableKey)).token;
2724
+ if (this.config.publishableKey) n = (await En(t, this.config.publishableKey)).token;
2703
2725
  else if (this.getSessionToken) n = await this.getSessionToken();
2704
2726
  else return { failure: "refused" };
2705
2727
  } catch (e) {
2706
- return console.error("[whoo-aiden-widget] could not renew the session:", e), { failure: this.config.publishableKey && Cr(e) ? "refused" : "unavailable" };
2728
+ return console.error("[whoo-aiden-widget] could not renew the session:", e), { failure: this.config.publishableKey && wr(e) ? "refused" : "unavailable" };
2707
2729
  }
2708
- let r = typeof n == "string" ? Bn(n) : null;
2730
+ let r = typeof n == "string" ? Vn(n) : null;
2709
2731
  return typeof n != "string" || n === "" || r !== null && r <= Date.now() ? (console.error("[whoo-aiden-widget] could not renew the session: no usable token was returned."), { failure: "refused" }) : (e === this.renewalGeneration && (this.sessionToken = n, this.sessionTokenExpiresAt = r), { token: n });
2710
2732
  }
2711
2733
  async withSession(e, t) {
2712
2734
  let n = await this.currentToken(t);
2713
- if (!("token" in n)) throw Sr(n.failure);
2735
+ if (!("token" in n)) throw Cr(n.failure);
2714
2736
  let { token: r } = n;
2715
2737
  try {
2716
2738
  return await e(r);
2717
2739
  } catch (n) {
2718
- if (!Tr(n)) throw n;
2719
- let i = this.sessionToken && this.sessionToken !== r ? { token: this.sessionToken } : await xr(this.renewToken(), t);
2720
- if (!("token" in i)) throw Sr(i.failure, n);
2740
+ if (!Er(n)) throw n;
2741
+ let i = this.sessionToken && this.sessionToken !== r ? { token: this.sessionToken } : await Sr(this.renewToken(), t);
2742
+ if (!("token" in i)) throw Cr(i.failure, n);
2721
2743
  try {
2722
2744
  return await e(i.token);
2723
2745
  } catch (e) {
2724
- throw Tr(e) ? new wr(e) : e;
2746
+ throw Er(e) ? new Tr(e) : e;
2725
2747
  }
2726
2748
  }
2727
2749
  }
2728
- }, $ = 20, Or = 12, kr = 300, Ar = 352;
2729
- function jr() {
2750
+ }, $ = 20, kr = 12, Ar = 300, jr = 352;
2751
+ function Mr() {
2730
2752
  try {
2731
2753
  return typeof CSS < "u" && CSS.supports?.("height", "100dvh") ? "dvh" : "vh";
2732
2754
  } catch {
2733
2755
  return "vh";
2734
2756
  }
2735
2757
  }
2736
- function Mr(e, t) {
2758
+ function Nr(e, t) {
2737
2759
  let { offsetX: n, offsetY: r, launcherSize: i, panelWidth: a, panelHeight: o, cornerRadius: s } = ce(t.layout), c = (e) => typeof t.layout?.offset?.[e] == "number";
2738
2760
  if (typeof window < "u" && window.innerWidth > 0 && window.innerHeight > 0) {
2739
- let e = Math.max($, window.innerWidth - kr), t = Math.max($, window.innerHeight - i - Ar);
2761
+ let e = Math.max($, window.innerWidth - Ar), t = Math.max($, window.innerHeight - i - jr);
2740
2762
  c("x") && (n > e || n > window.innerWidth - i) && console.warn(`whoo-aiden-widget: \`layout.offset.x\` ${n} leaves no room for the launcher and panel in this viewport; it is held back.`), c("y") && (r > t || r > window.innerHeight - i) && console.warn(`whoo-aiden-widget: \`layout.offset.y\` ${r} leaves no room for the launcher and panel in this viewport; it is held back.`);
2741
2763
  }
2742
- let l = `100${jr()}`, u = `min(${n}px, max(${$}px, calc(100vw - ${kr}px)), calc(100vw - ${i}px))`, d = `min(${r}px, max(${$}px, calc(${l} - ${i + Ar}px)), calc(${l} - ${i}px))`, f = `calc(${d} + ${i}px + ${Or}px)`, p = t.position === "bottom-left", m = (t, n) => e.style.setProperty(t, n);
2764
+ let l = `100${Mr()}`, u = `min(${n}px, max(${$}px, calc(100vw - ${Ar}px)), calc(100vw - ${i}px))`, d = `min(${r}px, max(${$}px, calc(${l} - ${i + jr}px)), calc(${l} - ${i}px))`, f = `calc(${d} + ${i}px + ${kr}px)`, p = t.position === "bottom-left", m = (t, n) => e.style.setProperty(t, n);
2743
2765
  m("--whoo-widget-inset-left", p ? u : "auto"), m("--whoo-widget-inset-right", p ? "auto" : u), m("--whoo-widget-inset-bottom", d), m("--whoo-widget-launcher-size", `${i}px`), m("--whoo-widget-panel-bottom", f), m("--whoo-widget-panel-width", `${a}px`), m("--whoo-widget-panel-height", `${o}px`), m("--whoo-widget-panel-max-width", `calc(100vw - ${u} - ${$}px)`), m("--whoo-widget-panel-max-height", `calc(${l} - ${f} - ${$}px)`), s === void 0 ? e.style.removeProperty("--whoo-widget-corner-radius") : m("--whoo-widget-corner-radius", `${s}px`);
2744
2766
  }
2745
2767
  //#endregion
2746
2768
  //#region src/styles.css?inline
2747
- var Nr = ":host,.whoo-widget-root{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.whoo-widget-launcher{bottom:var(--whoo-widget-inset-bottom,20px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-launcher-size,56px);height:var(--whoo-widget-launcher-size,56px);background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:50%;justify-content:center;align-items:center;padding:0;font-size:24px;display:flex;position:fixed;box-shadow:0 2px 8px #0003}.whoo-widget-launcher:focus-visible{box-shadow:0 2px 8px #0003,0 0 0 4px #fff}.whoo-widget-launcher svg{width:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);height:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);display:block}.whoo-widget-launcher-icon-image{width:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);height:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);object-fit:cover;border-radius:50%}.whoo-widget-launcher-icon-image[hidden]{display:none}.whoo-widget-panel{bottom:var(--whoo-widget-panel-bottom,88px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-panel-width,360px);height:var(--whoo-widget-panel-height,480px);max-width:var(--whoo-widget-panel-max-width,calc(100vw - 40px));max-height:var(--whoo-widget-panel-max-height,calc(100vh - 108px));background:var(--whoo-widget-panel,#fff);border-radius:var(--whoo-widget-corner-radius,12px);font-family:var(--whoo-widget-font,-apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif);color:inherit;border:none;flex-direction:column;margin:0;padding:0;display:flex;position:fixed;overflow:hidden;box-shadow:0 4px 16px #0003}button,input,textarea,select{font-family:inherit}.whoo-widget-panel:not([open]){display:none}.whoo-widget-panel::backdrop{background:0 0}@media (width<=400px),(height<=420px){.whoo-widget-panel{width:auto;max-width:none;height:auto;max-height:none;inset:8px}}.whoo-widget-panel[data-fit-visible]{top:calc(var(--whoo-widget-visible-top,0px) + max(8px, var(--whoo-widget-visible-height,100%) - 8px - var(--whoo-widget-panel-height,480px)));height:min(var(--whoo-widget-panel-height,480px), calc(var(--whoo-widget-visible-height,100%) - 16px));max-height:none;bottom:auto}@media (width<=400px),(height<=420px){.whoo-widget-panel[data-fit-visible]{top:calc(var(--whoo-widget-visible-top,0px) + 8px);height:calc(var(--whoo-widget-visible-height,100%) - 16px)}}.whoo-widget-header{border-bottom:1px solid var(--whoo-widget-border,#e5e5e5);flex-wrap:wrap;flex-shrink:0;justify-content:space-between;align-items:center;gap:8px;max-height:50%;padding-block:8px;padding-inline:16px 8px;display:flex;overflow-y:auto}.whoo-widget-header-titles{flex:10em;min-width:0}.whoo-widget-header-title{color:var(--whoo-widget-ink,#111);overflow-wrap:anywhere;margin:0;font-size:15px;font-weight:600}.whoo-widget-header-subtitle{color:var(--whoo-widget-muted,#4b5563);overflow-wrap:anywhere;margin:2px 0 0;font-size:13px}.whoo-widget-header-actions{background:var(--whoo-widget-panel,#fff);flex-shrink:0;align-items:center;gap:4px;margin-inline-start:auto;display:flex;position:sticky;bottom:0}.whoo-widget-header-close,.whoo-widget-header-reset{color:var(--whoo-widget-color-text,#4f46e5);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px 8px;font-size:13px;display:inline-flex}.whoo-widget-header-close{width:32px;height:32px;padding:0}.whoo-widget-header-close:hover,.whoo-widget-header-reset:hover{background:var(--whoo-widget-header-hover,#f3f4f6)}.whoo-widget-message-list{overscroll-behavior:contain;flex:1;min-height:0;padding:12px;overflow-y:auto}.whoo-widget-message-list:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:-2px;box-shadow:inset 0 0 0 4px var(--whoo-widget-panel,#fff)}.whoo-widget-empty-state-image{object-fit:contain;max-width:min(160px,100%);height:auto;max-height:160px;margin:8px auto 16px;display:block}.whoo-widget-message-list--centered{flex-direction:column;display:flex}.whoo-widget-empty-state{margin-block:auto}.whoo-widget-empty-state-greeting{color:var(--whoo-widget-ink,#111);text-align:center;overflow-wrap:anywhere;white-space:pre-line}.whoo-widget-empty-state-greeting a{color:var(--whoo-widget-link-color,#00e)}@media (width<=400px),(height<=420px){.whoo-widget-empty-state-image{max-height:64px;margin:0 auto 8px}}.whoo-widget-notice{border:1px solid var(--whoo-widget-border,#e5e5e5);color:var(--whoo-widget-ink,#111);overflow-wrap:anywhere;white-space:pre-line;border-radius:8px;margin-bottom:12px;padding:8px 12px}.whoo-widget-notice a,.whoo-widget-notice-footer a{color:var(--whoo-widget-link-color,#00e)}.whoo-widget-message{overflow-wrap:anywhere;white-space:pre-line;border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-message-text,.whoo-widget-message-text li{unicode-bidi:plaintext}.whoo-widget-list{margin:4px 0;padding-inline-start:0}.whoo-widget-list li{margin-inline-start:20px}.whoo-widget-message--user{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);margin-inline-start:auto}.whoo-widget-message--user a{color:inherit}.whoo-widget-message--assistant{background:var(--whoo-widget-assistant-bubble,#f0f0f0);color:var(--whoo-widget-ink,#111)}.whoo-widget-message--assistant a{color:var(--whoo-widget-link-color,#00e)}.whoo-widget-pending{flex-wrap:wrap;align-items:center;gap:8px;min-height:1.2em;display:flex}.whoo-widget-typing{align-items:center;gap:4px;display:inline-flex}.whoo-widget-typing span{background:var(--whoo-widget-typing-dots,#6b7280);border-radius:50%;width:6px;height:6px;animation:1.2s ease-in-out infinite whoo-widget-typing-bounce}.whoo-widget-typing span:nth-child(2){animation-delay:.2s}.whoo-widget-typing span:nth-child(3){animation-delay:.4s}@keyframes whoo-widget-typing-bounce{0%,80%,to{transform:translateY(0)}40%{transform:translateY(-4px)}}@media (prefers-reduced-motion:reduce){.whoo-widget-typing span{animation:none}}.whoo-widget-error-banner{background:var(--whoo-widget-error-bg,#fee2e2);color:var(--whoo-widget-error-text,#991b1b);padding:8px 12px;font-size:13px}.whoo-widget-composer{border-top:1px solid var(--whoo-widget-border,#e5e5e5);gap:8px;padding:12px;display:flex}.whoo-widget-composer-input{border:1px solid var(--whoo-widget-input-border,#6b7280);border-radius:var(--whoo-widget-corner-radius,6px);unicode-bidi:plaintext;flex:1;min-width:0;padding:8px;font-size:16px}.whoo-widget-agreement{border-top:1px solid var(--whoo-widget-border,#e5e5e5);padding:12px}.whoo-widget-agreement-button{border-radius:var(--whoo-widget-corner-radius,6px);background:var(--whoo-widget-color,#4f46e5);width:100%;min-height:44px;color:var(--whoo-widget-text-on-color,#fff);overflow-wrap:anywhere;cursor:pointer;border:none;padding:8px 16px;font-weight:600;display:block}.whoo-widget-composer-send{border-radius:var(--whoo-widget-corner-radius,6px);background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;padding:8px 16px}.whoo-widget-composer-input::placeholder{color:var(--whoo-widget-muted,#4b5563);opacity:1}.whoo-widget-notice-footer{overscroll-behavior:contain;border-top:1px solid var(--whoo-widget-border,#e5e5e5);min-height:0;max-height:25%;color:var(--whoo-widget-muted,#4b5563);text-align:center;overflow-wrap:anywhere;white-space:pre-line;flex:0 auto;padding:8px 16px;font-size:12px;line-height:1.4;overflow-y:auto}.whoo-widget-notice-footer:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:-2px;box-shadow:inset 0 0 0 4px var(--whoo-widget-panel,#fff)}.whoo-widget-composer-send[aria-disabled=true],.whoo-widget-composer-input[aria-disabled=true]{opacity:.6;cursor:not-allowed}.whoo-widget-feedback{align-items:center;gap:6px;margin-top:4px;display:flex}.whoo-widget-feedback-buttons{gap:6px;display:flex}.whoo-widget-feedback-buttons button{cursor:pointer;color:var(--whoo-widget-muted,#4b5563);background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px;display:inline-flex}.whoo-widget-feedback-buttons button:hover:not(:disabled){color:var(--whoo-widget-text,#111);background:#0000000f}.whoo-widget-feedback-buttons button[aria-disabled=true]{opacity:.3;cursor:not-allowed}.whoo-widget-feedback-form{flex-direction:column;gap:6px;margin-top:6px;display:flex}.whoo-widget-feedback-textarea{box-sizing:border-box;border:1px solid var(--whoo-widget-input-border,#6b7280);resize:vertical;unicode-bidi:plaintext;border-radius:6px;width:100%;padding:6px;font-size:16px}.whoo-widget-feedback-select{border:1px solid var(--whoo-widget-input-border,#6b7280);border-radius:6px;height:2em;min-height:24px;padding:4px;font-size:16px}.whoo-widget-feedback-form-buttons{gap:6px;display:flex}.whoo-widget-feedback-submit{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-cancel{border:1px solid var(--whoo-widget-input-border,#6b7280);background:var(--whoo-widget-panel,#fff);color:var(--whoo-widget-text,#111);cursor:pointer;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-submitted{color:var(--whoo-widget-muted,#4b5563);margin-top:4px;font-size:12px}.whoo-widget-feedback-error{color:var(--whoo-widget-error-text,#991b1b);font-size:12px}.whoo-widget-sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,a:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:2px;box-shadow:0 0 0 4px var(--whoo-widget-panel,#fff)}@media (forced-colors:active){.whoo-widget-message{border:1px solid canvastext}.whoo-widget-launcher,.whoo-widget-header-close,.whoo-widget-header-reset,.whoo-widget-composer-send,.whoo-widget-agreement-button,.whoo-widget-feedback-submit,.whoo-widget-feedback-buttons button{border:1px solid buttontext}.whoo-widget-panel{box-sizing:border-box;border:1px solid canvastext}}";
2769
+ var Pr = ":host,.whoo-widget-root{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.whoo-widget-launcher{bottom:var(--whoo-widget-inset-bottom,20px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-launcher-size,56px);height:var(--whoo-widget-launcher-size,56px);background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:50%;justify-content:center;align-items:center;padding:0;font-size:24px;display:flex;position:fixed;box-shadow:0 2px 8px #0003}.whoo-widget-launcher:focus-visible{box-shadow:0 2px 8px #0003,0 0 0 4px #fff}.whoo-widget-launcher svg{width:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);height:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);display:block}.whoo-widget-launcher-icon-image{width:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);height:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);object-fit:cover;border-radius:50%}.whoo-widget-launcher-icon-image[hidden]{display:none}.whoo-widget-panel{bottom:var(--whoo-widget-panel-bottom,88px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-panel-width,360px);height:var(--whoo-widget-panel-height,480px);max-width:var(--whoo-widget-panel-max-width,calc(100vw - 40px));max-height:var(--whoo-widget-panel-max-height,calc(100vh - 108px));background:var(--whoo-widget-panel,#fff);border-radius:var(--whoo-widget-corner-radius,12px);font-family:var(--whoo-widget-font,-apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif);color:inherit;border:none;flex-direction:column;margin:0;padding:0;display:flex;position:fixed;overflow:hidden;box-shadow:0 4px 16px #0003}button,input,textarea,select{font-family:inherit}.whoo-widget-panel:not([open]){display:none}.whoo-widget-panel::backdrop{background:0 0}@media (width<=400px),(height<=420px){.whoo-widget-panel{width:auto;max-width:none;height:auto;max-height:none;inset:8px}}.whoo-widget-panel[data-fit-visible]{top:calc(var(--whoo-widget-visible-top,0px) + max(8px, var(--whoo-widget-visible-height,100%) - 8px - var(--whoo-widget-panel-height,480px)));height:min(var(--whoo-widget-panel-height,480px), calc(var(--whoo-widget-visible-height,100%) - 16px));max-height:none;bottom:auto}@media (width<=400px),(height<=420px){.whoo-widget-panel[data-fit-visible]{top:calc(var(--whoo-widget-visible-top,0px) + 8px);height:calc(var(--whoo-widget-visible-height,100%) - 16px)}}.whoo-widget-header{border-bottom:1px solid var(--whoo-widget-border,#e5e5e5);flex-wrap:wrap;flex-shrink:0;justify-content:space-between;align-items:center;gap:8px;max-height:50%;padding-block:8px;padding-inline:16px 8px;display:flex;overflow-y:auto}.whoo-widget-header-titles{flex:10em;min-width:0}.whoo-widget-header-title{color:var(--whoo-widget-ink,#111);overflow-wrap:anywhere;margin:0;font-size:15px;font-weight:600}.whoo-widget-header-subtitle{color:var(--whoo-widget-muted,#4b5563);overflow-wrap:anywhere;margin:2px 0 0;font-size:13px}.whoo-widget-header-actions{background:var(--whoo-widget-panel,#fff);flex-shrink:0;align-items:center;gap:4px;margin-inline-start:auto;display:flex;position:sticky;bottom:0}.whoo-widget-header-close,.whoo-widget-header-reset{color:var(--whoo-widget-color-text,#4f46e5);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px 8px;font-size:13px;display:inline-flex}.whoo-widget-header-close{width:32px;height:32px;padding:0}.whoo-widget-header-close:hover,.whoo-widget-header-reset:hover{background:var(--whoo-widget-header-hover,#f3f4f6)}.whoo-widget-message-list{overscroll-behavior:contain;flex:1;min-height:0;padding:12px;overflow-y:auto}.whoo-widget-message-list:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:-2px;box-shadow:inset 0 0 0 4px var(--whoo-widget-panel,#fff)}.whoo-widget-empty-state-image{object-fit:contain;max-width:min(160px,100%);height:auto;max-height:160px;margin:8px auto 16px;display:block}.whoo-widget-message-list--centered{flex-direction:column;display:flex}.whoo-widget-empty-state{margin-block:auto}.whoo-widget-empty-state-greeting{color:var(--whoo-widget-ink,#111);text-align:center;overflow-wrap:anywhere;white-space:pre-line}.whoo-widget-empty-state-greeting a{color:var(--whoo-widget-link-color,#00e)}@media (width<=400px),(height<=420px){.whoo-widget-empty-state-image{max-height:64px;margin:0 auto 8px}}.whoo-widget-notice{border:1px solid var(--whoo-widget-border,#e5e5e5);color:var(--whoo-widget-ink,#111);overflow-wrap:anywhere;white-space:pre-line;border-radius:8px;margin-bottom:12px;padding:8px 12px}.whoo-widget-notice a,.whoo-widget-notice-footer a{color:var(--whoo-widget-link-color,#00e)}.whoo-widget-message{overflow-wrap:anywhere;white-space:pre-line;border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-message-text,.whoo-widget-message-text li{unicode-bidi:plaintext}.whoo-widget-list{margin:4px 0;padding-inline-start:0}.whoo-widget-list li{margin-inline-start:20px}.whoo-widget-message--user{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);margin-inline-start:auto}.whoo-widget-message--user a{color:inherit}.whoo-widget-message--assistant{background:var(--whoo-widget-assistant-bubble,#f0f0f0);color:var(--whoo-widget-ink,#111)}.whoo-widget-message--assistant a{color:var(--whoo-widget-link-color,#00e)}.whoo-widget-pending{flex-wrap:wrap;align-items:center;gap:8px;min-height:1.2em;display:flex}.whoo-widget-typing{align-items:center;gap:4px;display:inline-flex}.whoo-widget-typing span{background:var(--whoo-widget-typing-dots,#6b7280);border-radius:50%;width:6px;height:6px;animation:1.2s ease-in-out infinite whoo-widget-typing-bounce}.whoo-widget-typing span:nth-child(2){animation-delay:.2s}.whoo-widget-typing span:nth-child(3){animation-delay:.4s}@keyframes whoo-widget-typing-bounce{0%,80%,to{transform:translateY(0)}40%{transform:translateY(-4px)}}@media (prefers-reduced-motion:reduce){.whoo-widget-typing span{animation:none}}.whoo-widget-error-banner{background:var(--whoo-widget-error-bg,#fee2e2);color:var(--whoo-widget-error-text,#991b1b);padding:8px 12px;font-size:13px}.whoo-widget-composer{border-top:1px solid var(--whoo-widget-border,#e5e5e5);gap:8px;padding:12px;display:flex}.whoo-widget-composer-input{border:1px solid var(--whoo-widget-input-border,#6b7280);border-radius:var(--whoo-widget-corner-radius,6px);unicode-bidi:plaintext;flex:1;min-width:0;padding:8px;font-size:16px}.whoo-widget-agreement{border-top:1px solid var(--whoo-widget-border,#e5e5e5);padding:12px}.whoo-widget-agreement-button{border-radius:var(--whoo-widget-corner-radius,6px);background:var(--whoo-widget-color,#4f46e5);width:100%;min-height:44px;color:var(--whoo-widget-text-on-color,#fff);overflow-wrap:anywhere;cursor:pointer;border:none;padding:8px 16px;font-weight:600;display:block}.whoo-widget-composer-send{border-radius:var(--whoo-widget-corner-radius,6px);background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;padding:8px 16px}.whoo-widget-composer-input::placeholder{color:var(--whoo-widget-muted,#4b5563);opacity:1}.whoo-widget-notice-footer{overscroll-behavior:contain;border-top:1px solid var(--whoo-widget-border,#e5e5e5);min-height:0;max-height:25%;color:var(--whoo-widget-muted,#4b5563);text-align:center;overflow-wrap:anywhere;white-space:pre-line;flex:0 auto;padding:8px 16px;font-size:12px;line-height:1.4;overflow-y:auto}.whoo-widget-notice-footer:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:-2px;box-shadow:inset 0 0 0 4px var(--whoo-widget-panel,#fff)}.whoo-widget-composer-send[aria-disabled=true],.whoo-widget-composer-input[aria-disabled=true]{opacity:.6;cursor:not-allowed}.whoo-widget-feedback{align-items:center;gap:6px;margin-top:4px;display:flex}.whoo-widget-feedback-buttons{gap:6px;display:flex}.whoo-widget-feedback-buttons button{cursor:pointer;color:var(--whoo-widget-muted,#4b5563);background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px;display:inline-flex}.whoo-widget-feedback-buttons button:hover:not(:disabled){color:var(--whoo-widget-text,#111);background:#0000000f}.whoo-widget-feedback-buttons button[aria-disabled=true]{opacity:.3;cursor:not-allowed}.whoo-widget-feedback-form{flex-direction:column;gap:6px;margin-top:6px;display:flex}.whoo-widget-feedback-textarea{box-sizing:border-box;border:1px solid var(--whoo-widget-input-border,#6b7280);resize:vertical;unicode-bidi:plaintext;border-radius:6px;width:100%;padding:6px;font-size:16px}.whoo-widget-feedback-select{border:1px solid var(--whoo-widget-input-border,#6b7280);border-radius:6px;height:2em;min-height:24px;padding:4px;font-size:16px}.whoo-widget-feedback-form-buttons{gap:6px;display:flex}.whoo-widget-feedback-submit{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-cancel{border:1px solid var(--whoo-widget-input-border,#6b7280);background:var(--whoo-widget-panel,#fff);color:var(--whoo-widget-text,#111);cursor:pointer;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-submitted{color:var(--whoo-widget-muted,#4b5563);margin-top:4px;font-size:12px}.whoo-widget-feedback-error{color:var(--whoo-widget-error-text,#991b1b);font-size:12px}.whoo-widget-sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,a:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:2px;box-shadow:0 0 0 4px var(--whoo-widget-panel,#fff)}@media (forced-colors:active){.whoo-widget-message{border:1px solid canvastext}.whoo-widget-launcher,.whoo-widget-header-close,.whoo-widget-header-reset,.whoo-widget-composer-send,.whoo-widget-agreement-button,.whoo-widget-feedback-submit,.whoo-widget-feedback-buttons button{border:1px solid buttontext}.whoo-widget-panel{box-sizing:border-box;border:1px solid canvastext}}";
2748
2770
  //#endregion
2749
2771
  //#region src/mount.tsx
2750
- function Pr(e) {
2772
+ function Fr(e) {
2751
2773
  let t = document.createElement("div");
2752
2774
  t.id = "whoo-aiden-widget-host", t.style.position = "relative", t.style.zIndex = String(c(e.zIndex));
2753
2775
  let n = t.attachShadow({ mode: "open" }), r = document.createElement("style");
2754
- r.textContent = Nr, n.appendChild(r);
2776
+ r.textContent = Pr, n.appendChild(r);
2755
2777
  let i = document.createElement("div");
2756
2778
  n.appendChild(i);
2757
2779
  let a = /* @__PURE__ */ new Set();
2758
- gr(i, e, a), Mr(i, e);
2759
- let o = new Dr(e);
2780
+ _r(i, e, a), Nr(i, e);
2781
+ let o = new Or(e);
2760
2782
  i.setAttribute("lang", o.languageTag), i.setAttribute("dir", o.dir);
2761
2783
  let s = X(e.color) !== null, l = null, u = "", d = ae(e.theme).colors, f = Object.keys(d).length > 0, p = {
2762
2784
  color: e.color,
@@ -2765,7 +2787,7 @@ function Pr(e) {
2765
2787
  };
2766
2788
  return o.subscribe((t) => {
2767
2789
  let n = !1;
2768
- !s && t.primaryColor && t.primaryColor !== l && (l = t.primaryColor, ur(i, t.primaryColor, e.color), X(t.primaryColor) && (p = {
2790
+ !s && t.primaryColor && t.primaryColor !== l && (l = t.primaryColor, dr(i, t.primaryColor, e.color), X(t.primaryColor) && (p = {
2769
2791
  ...p,
2770
2792
  color: t.primaryColor
2771
2793
  }), n = !0);
@@ -2773,7 +2795,7 @@ function Pr(e) {
2773
2795
  if ((t.inkColor || t.accentColor) && r !== u) {
2774
2796
  u = r;
2775
2797
  let a = X(e.inkColor) ? e.inkColor : t.inkColor, o = X(e.accentColor) ? e.accentColor : t.accentColor;
2776
- dr(i, {
2798
+ fr(i, {
2777
2799
  inkColor: a,
2778
2800
  accentColor: o
2779
2801
  }), p = {
@@ -2782,18 +2804,18 @@ function Pr(e) {
2782
2804
  accentColor: o
2783
2805
  }, n = !0;
2784
2806
  }
2785
- n && (fr(i, d), f && hr({
2807
+ n && (pr(i, d), f && gr({
2786
2808
  ...p,
2787
2809
  overrides: d
2788
2810
  }, a));
2789
- }), o.init(), He(/* @__PURE__ */ W(Sn, { controller: o }), i), document.body.appendChild(t), { unmount() {
2811
+ }), o.init(), He(/* @__PURE__ */ W(Cn, { controller: o }), i), document.body.appendChild(t), { unmount() {
2790
2812
  He(null, i), t.remove();
2791
2813
  } };
2792
2814
  }
2793
2815
  //#endregion
2794
2816
  //#region src/index.ts
2795
- function Fr(e) {
2796
- return f(e), Pr(e);
2817
+ function Ir(e) {
2818
+ return f(e), Fr(e);
2797
2819
  }
2798
2820
  //#endregion
2799
- export { Et as SUPPORTED_LANGUAGES, Fr as init, Z as resolveTheme };
2821
+ export { Et as SUPPORTED_LANGUAGES, Ir as init, Z as resolveTheme };