@aikaara/chat-sdk 0.9.4 → 0.9.5
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/{MountTenant-B-CCyWWA.mjs → MountTenant-BFBaHtZU.mjs} +152 -131
- package/dist/{MountTenant-CLSvsaX7.cjs → MountTenant-Cz8W90_R.cjs} +10 -10
- package/dist/cdn/aikaara-chat.iife.js +15 -15
- package/dist/headless.cjs +1 -1
- package/dist/headless.d.ts +7 -4
- package/dist/headless.mjs +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +10 -5
- package/dist/index.mjs +2 -2
- package/dist/ui.cjs +1 -1
- package/dist/ui.d.ts +4 -2
- package/dist/ui.mjs +1 -1
- package/package.json +1 -1
|
@@ -12454,7 +12454,18 @@ function ll(c) {
|
|
|
12454
12454
|
ll(t);
|
|
12455
12455
|
}
|
|
12456
12456
|
}
|
|
12457
|
-
|
|
12457
|
+
function lh(c) {
|
|
12458
|
+
const e = Date.now() - c.getTime(), t = Math.round(e / 1e3);
|
|
12459
|
+
if (t < 5) return "just now";
|
|
12460
|
+
if (t < 60) return `${t}s ago`;
|
|
12461
|
+
const r = Math.round(t / 60);
|
|
12462
|
+
if (r < 60) return `${r} min ago`;
|
|
12463
|
+
const a = Math.round(r / 60);
|
|
12464
|
+
if (a < 24) return `${a} hr ago`;
|
|
12465
|
+
const n = Math.round(a / 24);
|
|
12466
|
+
return n === 1 ? "Yesterday" : n < 7 ? `${n} d ago` : c.toLocaleDateString(void 0, { month: "short", day: "2-digit" });
|
|
12467
|
+
}
|
|
12468
|
+
class ch extends HTMLElement {
|
|
12458
12469
|
shadow;
|
|
12459
12470
|
container;
|
|
12460
12471
|
welcomeMessage = "";
|
|
@@ -12781,12 +12792,22 @@ class lh extends HTMLElement {
|
|
|
12781
12792
|
}
|
|
12782
12793
|
formatTime(e) {
|
|
12783
12794
|
try {
|
|
12784
|
-
const t = new Date(e);
|
|
12795
|
+
const t = new Date(e), r = t.toLocaleDateString(void 0, { month: "short", day: "2-digit" });
|
|
12785
12796
|
switch (this.timestampFormat) {
|
|
12786
12797
|
case "datetime":
|
|
12787
|
-
return `${
|
|
12798
|
+
return `${r}, ${t.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit" })}`;
|
|
12799
|
+
case "datetime-seconds":
|
|
12800
|
+
return `${r}, ${t.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit", second: "2-digit" })}`;
|
|
12801
|
+
case "datetime-24":
|
|
12802
|
+
return `${r}, ${t.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit", hour12: !1 })}`;
|
|
12788
12803
|
case "date":
|
|
12789
|
-
return
|
|
12804
|
+
return r;
|
|
12805
|
+
case "relative":
|
|
12806
|
+
return lh(t);
|
|
12807
|
+
case "time-24":
|
|
12808
|
+
return t.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit", hour12: !1 });
|
|
12809
|
+
case "time-seconds":
|
|
12810
|
+
return t.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit", second: "2-digit" });
|
|
12790
12811
|
case "none":
|
|
12791
12812
|
return "";
|
|
12792
12813
|
default:
|
|
@@ -12802,7 +12823,7 @@ class lh extends HTMLElement {
|
|
|
12802
12823
|
* data, or opens in a new tab depending on the matched handler.
|
|
12803
12824
|
*/
|
|
12804
12825
|
async handleLinkClick(e, t) {
|
|
12805
|
-
const r = this.linkHandlers.find((y) =>
|
|
12826
|
+
const r = this.linkHandlers.find((y) => uh(e, y.match)), a = r?.target ?? "iframe";
|
|
12806
12827
|
if (a === "tab") {
|
|
12807
12828
|
window.open(e, "_blank", "noopener,noreferrer");
|
|
12808
12829
|
return;
|
|
@@ -12812,7 +12833,7 @@ class lh extends HTMLElement {
|
|
|
12812
12833
|
requestAnimationFrame(() => n.show?.(e, i));
|
|
12813
12834
|
return;
|
|
12814
12835
|
}
|
|
12815
|
-
const s =
|
|
12836
|
+
const s = hh(e), o = cl(r.fetch.url, s), l = {
|
|
12816
12837
|
accept: "application/json",
|
|
12817
12838
|
...r.fetch.headers ?? {}
|
|
12818
12839
|
}, u = r.fetch.authHeader ?? "session";
|
|
@@ -12858,11 +12879,11 @@ class lh extends HTMLElement {
|
|
|
12858
12879
|
return e || (e = document.createElement("aikaara-link-modal"), document.body.appendChild(e)), e;
|
|
12859
12880
|
}
|
|
12860
12881
|
}
|
|
12861
|
-
function
|
|
12882
|
+
function uh(c, e) {
|
|
12862
12883
|
const t = e.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
12863
12884
|
return new RegExp("^" + t.replace(/\*/g, ".*").replace(/\?/g, ".") + "$", "i").test(c);
|
|
12864
12885
|
}
|
|
12865
|
-
function
|
|
12886
|
+
function hh(c) {
|
|
12866
12887
|
try {
|
|
12867
12888
|
const e = new URL(c), t = {};
|
|
12868
12889
|
return e.searchParams.forEach((r, a) => {
|
|
@@ -12885,7 +12906,7 @@ function zi(c, e) {
|
|
|
12885
12906
|
}
|
|
12886
12907
|
return c;
|
|
12887
12908
|
}
|
|
12888
|
-
class
|
|
12909
|
+
class fh extends HTMLElement {
|
|
12889
12910
|
shadow;
|
|
12890
12911
|
templatePayload = null;
|
|
12891
12912
|
attachments = [];
|
|
@@ -13001,7 +13022,7 @@ class hh extends HTMLElement {
|
|
|
13001
13022
|
renderAttachments() {
|
|
13002
13023
|
return this.attachments.length ? `<div class="attachments">${this.attachments.map(
|
|
13003
13024
|
(t) => `<a class="attachment" href="${xs(t.fileUrl)}" target="_blank" rel="noopener noreferrer">
|
|
13004
|
-
📎 ${
|
|
13025
|
+
📎 ${dh(t.fileName)}
|
|
13005
13026
|
</a>`
|
|
13006
13027
|
).join("")}</div>` : "";
|
|
13007
13028
|
}
|
|
@@ -13009,10 +13030,10 @@ class hh extends HTMLElement {
|
|
|
13009
13030
|
function xs(c) {
|
|
13010
13031
|
return String(c).replace(/[&<>"']/g, (e) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[e]);
|
|
13011
13032
|
}
|
|
13012
|
-
function
|
|
13033
|
+
function dh(c) {
|
|
13013
13034
|
return String(c).replace(/[&<>]/g, (e) => ({ "&": "&", "<": "<", ">": ">" })[e]);
|
|
13014
13035
|
}
|
|
13015
|
-
class
|
|
13036
|
+
class ph extends HTMLElement {
|
|
13016
13037
|
shadow;
|
|
13017
13038
|
textarea;
|
|
13018
13039
|
sendBtn;
|
|
@@ -13163,7 +13184,7 @@ class dh extends HTMLElement {
|
|
|
13163
13184
|
this.textarea.style.height = "auto", this.textarea.style.height = Math.min(this.textarea.scrollHeight, 120) + "px";
|
|
13164
13185
|
}
|
|
13165
13186
|
}
|
|
13166
|
-
class
|
|
13187
|
+
class gh extends HTMLElement {
|
|
13167
13188
|
shadow;
|
|
13168
13189
|
constructor() {
|
|
13169
13190
|
super(), this.shadow = this.attachShadow({ mode: "open" });
|
|
@@ -13212,7 +13233,7 @@ class ph extends HTMLElement {
|
|
|
13212
13233
|
this.removeAttribute("visible");
|
|
13213
13234
|
}
|
|
13214
13235
|
}
|
|
13215
|
-
class
|
|
13236
|
+
class mh extends HTMLElement {
|
|
13216
13237
|
shadow;
|
|
13217
13238
|
bubble;
|
|
13218
13239
|
constructor() {
|
|
@@ -13277,7 +13298,7 @@ class gh extends HTMLElement {
|
|
|
13277
13298
|
this.bubble?.classList.remove("cursor");
|
|
13278
13299
|
}
|
|
13279
13300
|
}
|
|
13280
|
-
class
|
|
13301
|
+
class bh extends HTMLElement {
|
|
13281
13302
|
shadow;
|
|
13282
13303
|
container;
|
|
13283
13304
|
dismissTimer = null;
|
|
@@ -13350,7 +13371,7 @@ function ul(c) {
|
|
|
13350
13371
|
});
|
|
13351
13372
|
return qr.set(c, t), t;
|
|
13352
13373
|
}
|
|
13353
|
-
function
|
|
13374
|
+
function yh(c, e = 5e3) {
|
|
13354
13375
|
return new Promise((t, r) => {
|
|
13355
13376
|
const a = setTimeout(() => r(new Error(`Custom element <${c}> not registered within ${e}ms`)), e);
|
|
13356
13377
|
customElements.whenDefined(c).then(() => {
|
|
@@ -13358,11 +13379,11 @@ function bh(c, e = 5e3) {
|
|
|
13358
13379
|
});
|
|
13359
13380
|
});
|
|
13360
13381
|
}
|
|
13361
|
-
function
|
|
13382
|
+
function vh(c) {
|
|
13362
13383
|
const e = `template:${c}`, t = window.__aikaara_descriptor__?.components?.[e];
|
|
13363
13384
|
return t && t.kind === "iife-element" ? { render: t.tag, scriptUrl: t.scriptUrl, props: t.props } : window.__aikaara_descriptor__?.templates?.[c];
|
|
13364
13385
|
}
|
|
13365
|
-
class
|
|
13386
|
+
class wh extends HTMLElement {
|
|
13366
13387
|
shadow;
|
|
13367
13388
|
payloadData = null;
|
|
13368
13389
|
innerMessage = "";
|
|
@@ -13401,8 +13422,8 @@ class vh extends HTMLElement {
|
|
|
13401
13422
|
<slot></slot>
|
|
13402
13423
|
`; this.firstChild; ) this.removeChild(this.firstChild);
|
|
13403
13424
|
if (!e) return;
|
|
13404
|
-
const r = t ?
|
|
13405
|
-
if (r?.scriptUrl && !customElements.get(a) && ul(r.scriptUrl).then(() =>
|
|
13425
|
+
const r = t ? vh(t) : void 0, a = r?.render ?? (t ? `aikaara-template-${t}` : `aikaara-template-${e}`);
|
|
13426
|
+
if (r?.scriptUrl && !customElements.get(a) && ul(r.scriptUrl).then(() => yh(a)).then(() => this.render()).catch((n) => console.warn(`[aikaara-template-renderer] failed to lazy-load ${r.scriptUrl}`, n)), customElements.get(a)) {
|
|
13406
13427
|
const n = document.createElement(a);
|
|
13407
13428
|
if (r?.props) {
|
|
13408
13429
|
for (const [i, s] of Object.entries(r.props))
|
|
@@ -13492,7 +13513,7 @@ class vh extends HTMLElement {
|
|
|
13492
13513
|
url: e.url ?? "",
|
|
13493
13514
|
openLinkInNewTab: e.openLinkInNewTab,
|
|
13494
13515
|
orderId: e.orderId,
|
|
13495
|
-
extra:
|
|
13516
|
+
extra: kh(e),
|
|
13496
13517
|
messageId: this.getAttribute("message-id") ?? void 0
|
|
13497
13518
|
}), this.appendChild(n);
|
|
13498
13519
|
});
|
|
@@ -13502,20 +13523,20 @@ class vh extends HTMLElement {
|
|
|
13502
13523
|
t.setPayload(e), this.appendChild(t);
|
|
13503
13524
|
}
|
|
13504
13525
|
}
|
|
13505
|
-
const
|
|
13526
|
+
const _h = /* @__PURE__ */ new Set([
|
|
13506
13527
|
"type",
|
|
13507
13528
|
"url",
|
|
13508
13529
|
"name",
|
|
13509
13530
|
"openLinkInNewTab",
|
|
13510
13531
|
"orderId"
|
|
13511
13532
|
]);
|
|
13512
|
-
function
|
|
13533
|
+
function kh(c) {
|
|
13513
13534
|
const e = {};
|
|
13514
13535
|
for (const [t, r] of Object.entries(c))
|
|
13515
|
-
|
|
13536
|
+
_h.has(t) || (e[t] = r);
|
|
13516
13537
|
return e;
|
|
13517
13538
|
}
|
|
13518
|
-
class
|
|
13539
|
+
class Sh extends HTMLElement {
|
|
13519
13540
|
shadow;
|
|
13520
13541
|
static get observedAttributes() {
|
|
13521
13542
|
return ["text", "subtext"];
|
|
@@ -13564,7 +13585,7 @@ class kh extends HTMLElement {
|
|
|
13564
13585
|
function As(c) {
|
|
13565
13586
|
return String(c).replace(/[&<>]/g, (e) => ({ "&": "&", "<": "<", ">": ">" })[e]);
|
|
13566
13587
|
}
|
|
13567
|
-
class
|
|
13588
|
+
class Eh extends HTMLElement {
|
|
13568
13589
|
shadow;
|
|
13569
13590
|
data = null;
|
|
13570
13591
|
selected = /* @__PURE__ */ new Set();
|
|
@@ -13715,7 +13736,7 @@ function rr(c) {
|
|
|
13715
13736
|
function Is(c) {
|
|
13716
13737
|
return String(c).replace(/[&<>"']/g, (e) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[e]);
|
|
13717
13738
|
}
|
|
13718
|
-
class
|
|
13739
|
+
class xh extends HTMLElement {
|
|
13719
13740
|
shadow;
|
|
13720
13741
|
data = null;
|
|
13721
13742
|
constructor() {
|
|
@@ -13775,14 +13796,14 @@ class Eh extends HTMLElement {
|
|
|
13775
13796
|
button:hover { background: var(--aikaara-submit-hover-bg, var(--aikaara-primary-hover, #4f46e5)); }
|
|
13776
13797
|
button:disabled { opacity: var(--aikaara-submit-disabled-opacity, 0.5); cursor: not-allowed; }
|
|
13777
13798
|
</style>
|
|
13778
|
-
<button type="button">${
|
|
13799
|
+
<button type="button">${Ah(e)}</button>
|
|
13779
13800
|
`, this.shadow.querySelector("button").addEventListener("click", () => this.handleClick());
|
|
13780
13801
|
}
|
|
13781
13802
|
}
|
|
13782
|
-
function
|
|
13803
|
+
function Ah(c) {
|
|
13783
13804
|
return String(c).replace(/[&<>]/g, (e) => ({ "&": "&", "<": "<", ">": ">" })[e]);
|
|
13784
13805
|
}
|
|
13785
|
-
class
|
|
13806
|
+
class Ih extends HTMLElement {
|
|
13786
13807
|
shadow;
|
|
13787
13808
|
data = null;
|
|
13788
13809
|
dismissed = !1;
|
|
@@ -13874,7 +13895,7 @@ class Ah extends HTMLElement {
|
|
|
13874
13895
|
function Hr(c) {
|
|
13875
13896
|
return String(c).replace(/[&<>]/g, (e) => ({ "&": "&", "<": "<", ">": ">" })[e]);
|
|
13876
13897
|
}
|
|
13877
|
-
class
|
|
13898
|
+
class Th extends HTMLElement {
|
|
13878
13899
|
static get observedAttributes() {
|
|
13879
13900
|
return ["slug", "user-id", "user-name", "user-token", "department-id", "config-base", "api-key"];
|
|
13880
13901
|
}
|
|
@@ -13928,7 +13949,7 @@ class Ih extends HTMLElement {
|
|
|
13928
13949
|
const o = Object.keys(n).length > 0 ? n : void 0;
|
|
13929
13950
|
return this.mountInflight = (async () => {
|
|
13930
13951
|
try {
|
|
13931
|
-
this.mounted = await
|
|
13952
|
+
this.mounted = await uf({
|
|
13932
13953
|
container: this,
|
|
13933
13954
|
slug: e,
|
|
13934
13955
|
configBase: this.getAttribute("config-base") ?? void 0,
|
|
@@ -13957,7 +13978,7 @@ class Ih extends HTMLElement {
|
|
|
13957
13978
|
})(), this.mountInflight;
|
|
13958
13979
|
}
|
|
13959
13980
|
}
|
|
13960
|
-
class
|
|
13981
|
+
class Ch extends HTMLElement {
|
|
13961
13982
|
shadow;
|
|
13962
13983
|
root = null;
|
|
13963
13984
|
iframe = null;
|
|
@@ -14074,7 +14095,7 @@ class Th extends HTMLElement {
|
|
|
14074
14095
|
});
|
|
14075
14096
|
}
|
|
14076
14097
|
}
|
|
14077
|
-
const
|
|
14098
|
+
const Oh = [
|
|
14078
14099
|
{ label: "Self-filing guidance" },
|
|
14079
14100
|
{ label: "Smart tax suggestions" },
|
|
14080
14101
|
{ label: "Auto-fetch 26AS / AIS" },
|
|
@@ -14082,7 +14103,7 @@ const Ch = [
|
|
|
14082
14103
|
{ label: "Dedicated tax expert" },
|
|
14083
14104
|
{ label: "End-to-end filing" },
|
|
14084
14105
|
{ label: "Document handling" }
|
|
14085
|
-
],
|
|
14106
|
+
], Ph = [
|
|
14086
14107
|
{
|
|
14087
14108
|
label: "DIY",
|
|
14088
14109
|
match: ["DIY", "DIY_SALARY"],
|
|
@@ -14105,11 +14126,11 @@ const Ch = [
|
|
|
14105
14126
|
features: [!0, !0, !0, !0, !0, !0, !0]
|
|
14106
14127
|
}
|
|
14107
14128
|
];
|
|
14108
|
-
class
|
|
14129
|
+
class Mh extends HTMLElement {
|
|
14109
14130
|
shadow;
|
|
14110
14131
|
data = null;
|
|
14111
|
-
columns =
|
|
14112
|
-
features =
|
|
14132
|
+
columns = Ph;
|
|
14133
|
+
features = Oh;
|
|
14113
14134
|
constructor() {
|
|
14114
14135
|
super(), this.shadow = this.attachShadow({ mode: "open" });
|
|
14115
14136
|
}
|
|
@@ -14242,30 +14263,30 @@ function zr(c) {
|
|
|
14242
14263
|
(e) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[e]
|
|
14243
14264
|
);
|
|
14244
14265
|
}
|
|
14245
|
-
function
|
|
14266
|
+
function Rh() {
|
|
14246
14267
|
const c = [
|
|
14247
14268
|
["aikaara-chat-widget", th],
|
|
14248
14269
|
["aikaara-chat-bubble", rh],
|
|
14249
14270
|
["aikaara-chat-header", nh],
|
|
14250
|
-
["aikaara-message-list",
|
|
14251
|
-
["aikaara-message-bubble",
|
|
14252
|
-
["aikaara-chat-input",
|
|
14253
|
-
["aikaara-typing-indicator",
|
|
14254
|
-
["aikaara-streaming-message",
|
|
14255
|
-
["aikaara-error-banner",
|
|
14256
|
-
["aikaara-template-renderer",
|
|
14257
|
-
["aikaara-system-pill",
|
|
14258
|
-
["aikaara-option-list",
|
|
14259
|
-
["aikaara-submit-action",
|
|
14260
|
-
["aikaara-modal-action",
|
|
14261
|
-
["aikaara-chat",
|
|
14262
|
-
["aikaara-link-modal",
|
|
14263
|
-
["aikaara-compare-plans",
|
|
14271
|
+
["aikaara-message-list", ch],
|
|
14272
|
+
["aikaara-message-bubble", fh],
|
|
14273
|
+
["aikaara-chat-input", ph],
|
|
14274
|
+
["aikaara-typing-indicator", gh],
|
|
14275
|
+
["aikaara-streaming-message", mh],
|
|
14276
|
+
["aikaara-error-banner", bh],
|
|
14277
|
+
["aikaara-template-renderer", wh],
|
|
14278
|
+
["aikaara-system-pill", Sh],
|
|
14279
|
+
["aikaara-option-list", Eh],
|
|
14280
|
+
["aikaara-submit-action", xh],
|
|
14281
|
+
["aikaara-modal-action", Ih],
|
|
14282
|
+
["aikaara-chat", Th],
|
|
14283
|
+
["aikaara-link-modal", Ch],
|
|
14284
|
+
["aikaara-compare-plans", Mh]
|
|
14264
14285
|
];
|
|
14265
14286
|
for (const [e, t] of c)
|
|
14266
14287
|
customElements.get(e) || customElements.define(e, t);
|
|
14267
14288
|
}
|
|
14268
|
-
|
|
14289
|
+
Rh();
|
|
14269
14290
|
function Kr(c, e, t = "") {
|
|
14270
14291
|
if (!e) return t;
|
|
14271
14292
|
const r = e.split(".");
|
|
@@ -14276,7 +14297,7 @@ function Kr(c, e, t = "") {
|
|
|
14276
14297
|
else return t;
|
|
14277
14298
|
return typeof a == "string" ? a : t;
|
|
14278
14299
|
}
|
|
14279
|
-
function
|
|
14300
|
+
function jh(c) {
|
|
14280
14301
|
try {
|
|
14281
14302
|
const e = c.split(".")[1];
|
|
14282
14303
|
if (!e) return 0;
|
|
@@ -14291,7 +14312,7 @@ function Rh(c) {
|
|
|
14291
14312
|
async function Pr(c) {
|
|
14292
14313
|
return typeof c == "function" ? await c() : c;
|
|
14293
14314
|
}
|
|
14294
|
-
class
|
|
14315
|
+
class Lh {
|
|
14295
14316
|
constructor(e, t) {
|
|
14296
14317
|
this.descriptor = e, this.sessionToken = t;
|
|
14297
14318
|
}
|
|
@@ -14323,14 +14344,14 @@ class jh {
|
|
|
14323
14344
|
if (!d) throw new Error("Session auth response missing token");
|
|
14324
14345
|
const p = Kr(o, this.descriptor.requestIdPath ?? "data.requestId"), y = this.cache?.requestId || p;
|
|
14325
14346
|
if (!y) throw new Error("Session auth response missing requestId");
|
|
14326
|
-
const f = Kr(o, this.descriptor.fullNamePath ?? "data.fullName"), g =
|
|
14347
|
+
const f = Kr(o, this.descriptor.fullNamePath ?? "data.fullName"), g = jh(d) || Date.now() + 3600 * 1e3;
|
|
14327
14348
|
return this.cache = { token: d, requestId: y, fullName: f, expiresAt: g }, this.cache;
|
|
14328
14349
|
}
|
|
14329
14350
|
}
|
|
14330
|
-
async function
|
|
14351
|
+
async function Nh(c) {
|
|
14331
14352
|
const e = {};
|
|
14332
14353
|
for (const t of c.spec) {
|
|
14333
|
-
const r = await
|
|
14354
|
+
const r = await Uh(t, c.providers);
|
|
14334
14355
|
if (r !== void 0 && r !== "")
|
|
14335
14356
|
e[t.name] = r;
|
|
14336
14357
|
else {
|
|
@@ -14343,11 +14364,11 @@ async function Lh(c) {
|
|
|
14343
14364
|
}
|
|
14344
14365
|
return e;
|
|
14345
14366
|
}
|
|
14346
|
-
async function
|
|
14367
|
+
async function Uh(c, e) {
|
|
14347
14368
|
const t = c.key ?? c.name;
|
|
14348
14369
|
switch (c.source) {
|
|
14349
14370
|
case "cookie":
|
|
14350
|
-
return
|
|
14371
|
+
return Bh(t);
|
|
14351
14372
|
case "localStorage":
|
|
14352
14373
|
return nr(() => window.localStorage.getItem(t) ?? void 0);
|
|
14353
14374
|
case "sessionStorage":
|
|
@@ -14355,7 +14376,7 @@ async function Nh(c, e) {
|
|
|
14355
14376
|
case "url_param":
|
|
14356
14377
|
return nr(() => new URL(window.location.href).searchParams.get(t) ?? void 0);
|
|
14357
14378
|
case "header_meta":
|
|
14358
|
-
return nr(() => document.querySelector(`meta[name="${
|
|
14379
|
+
return nr(() => document.querySelector(`meta[name="${Fh(t)}"]`)?.content ?? void 0);
|
|
14359
14380
|
case "callback": {
|
|
14360
14381
|
const r = e?.[c.name];
|
|
14361
14382
|
if (!r) return;
|
|
@@ -14366,7 +14387,7 @@ async function Nh(c, e) {
|
|
|
14366
14387
|
return;
|
|
14367
14388
|
}
|
|
14368
14389
|
}
|
|
14369
|
-
function
|
|
14390
|
+
function Bh(c) {
|
|
14370
14391
|
if (typeof document > "u") return;
|
|
14371
14392
|
const e = encodeURIComponent(c), t = document.cookie ? document.cookie.split("; ") : [];
|
|
14372
14393
|
for (const r of t) {
|
|
@@ -14388,11 +14409,11 @@ function nr(c) {
|
|
|
14388
14409
|
return;
|
|
14389
14410
|
}
|
|
14390
14411
|
}
|
|
14391
|
-
function
|
|
14412
|
+
function Fh(c) {
|
|
14392
14413
|
return c.replace(/["\\]/g, "\\$&");
|
|
14393
14414
|
}
|
|
14394
|
-
const
|
|
14395
|
-
class
|
|
14415
|
+
const Dh = 1800;
|
|
14416
|
+
class $h {
|
|
14396
14417
|
constructor(e) {
|
|
14397
14418
|
this.opts = e, this.cache = this.loadCache();
|
|
14398
14419
|
}
|
|
@@ -14421,7 +14442,7 @@ class Dh {
|
|
|
14421
14442
|
throw new Error(
|
|
14422
14443
|
"[aikaara-chat-sdk] SsoExchangeAdapter.exchange() requires descriptor.sso.collect; v2 partner-token flow should be handled by TokenDiscoveryReader instead."
|
|
14423
14444
|
);
|
|
14424
|
-
const e = await
|
|
14445
|
+
const e = await Nh({
|
|
14425
14446
|
spec: this.opts.descriptor.collect,
|
|
14426
14447
|
providers: this.opts.providers
|
|
14427
14448
|
}), t = JSON.stringify({ credentials: e }), r = {
|
|
@@ -14459,7 +14480,7 @@ class Dh {
|
|
|
14459
14480
|
return this.cache = u, this.persistCache(u), u;
|
|
14460
14481
|
}
|
|
14461
14482
|
computeExpiry() {
|
|
14462
|
-
const e = this.opts.descriptor.cacheTtlSec ??
|
|
14483
|
+
const e = this.opts.descriptor.cacheTtlSec ?? Dh;
|
|
14463
14484
|
if (!(!this.opts.descriptor.cacheKey || e <= 0))
|
|
14464
14485
|
return Date.now() + e * 1e3;
|
|
14465
14486
|
}
|
|
@@ -14492,8 +14513,8 @@ class Dh {
|
|
|
14492
14513
|
}
|
|
14493
14514
|
}
|
|
14494
14515
|
}
|
|
14495
|
-
const
|
|
14496
|
-
async function
|
|
14516
|
+
const Wh = 3e4, qh = 2e3, Hh = 100;
|
|
14517
|
+
async function zh(c) {
|
|
14497
14518
|
const { descriptor: e } = c, t = e.tokenSourceConfig ?? {};
|
|
14498
14519
|
switch (e.tokenSource) {
|
|
14499
14520
|
case "init": {
|
|
@@ -14502,37 +14523,37 @@ async function Hh(c) {
|
|
|
14502
14523
|
return { token: c.initToken, source: "init" };
|
|
14503
14524
|
}
|
|
14504
14525
|
case "query": {
|
|
14505
|
-
const r = typeof t.key == "string" && t.key ? t.key : "token", a =
|
|
14526
|
+
const r = typeof t.key == "string" && t.key ? t.key : "token", a = Vh(r);
|
|
14506
14527
|
if (!a) throw new Ke("query", `?${r}= not present`);
|
|
14507
14528
|
return { token: a, source: "query" };
|
|
14508
14529
|
}
|
|
14509
14530
|
case "hash": {
|
|
14510
|
-
const r = typeof t.key == "string" && t.key ? t.key : "token", a =
|
|
14531
|
+
const r = typeof t.key == "string" && t.key ? t.key : "token", a = Gh(r);
|
|
14511
14532
|
if (!a) throw new Ke("hash", `#${r}= not present`);
|
|
14512
14533
|
return { token: a, source: "hash" };
|
|
14513
14534
|
}
|
|
14514
14535
|
case "postmsg": {
|
|
14515
|
-
const r = typeof t.type == "string" ? t.type : "", a = typeof t.key == "string" && t.key ? t.key : "token", n =
|
|
14516
|
-
return { token: await
|
|
14536
|
+
const r = typeof t.type == "string" ? t.type : "", a = typeof t.key == "string" && t.key ? t.key : "token", n = Zh(typeof t.origins == "string" ? t.origins : ""), i = typeof t.timeoutMs == "number" && t.timeoutMs > 0 ? t.timeoutMs : Wh;
|
|
14537
|
+
return { token: await Xh({ type: r, key: a, origins: n, timeoutMs: i }), source: "postmsg" };
|
|
14517
14538
|
}
|
|
14518
14539
|
case "cookie": {
|
|
14519
14540
|
const r = typeof t.name == "string" && t.name ? t.name : "";
|
|
14520
14541
|
if (!r) throw new Ke("cookie", "cookie.name not configured");
|
|
14521
|
-
const a =
|
|
14542
|
+
const a = Yh(r);
|
|
14522
14543
|
if (!a) throw new Ke("cookie", `cookie "${r}" not set`);
|
|
14523
14544
|
return { token: a, source: "cookie" };
|
|
14524
14545
|
}
|
|
14525
14546
|
case "storage": {
|
|
14526
14547
|
const r = t.store === "session" ? "session" : "local", a = typeof t.key == "string" && t.key ? t.key : "", n = typeof t.path == "string" ? t.path : "";
|
|
14527
14548
|
if (!a) throw new Ke("storage", "storage.key not configured");
|
|
14528
|
-
const i =
|
|
14549
|
+
const i = Qh(r, a, n);
|
|
14529
14550
|
if (!i) throw new Ke("storage", `${r}Storage["${a}"] not set`);
|
|
14530
14551
|
return { token: i, source: "storage" };
|
|
14531
14552
|
}
|
|
14532
14553
|
case "global": {
|
|
14533
14554
|
const r = typeof t.path == "string" ? t.path : "";
|
|
14534
14555
|
if (!r) throw new Ke("global", "global.path not configured");
|
|
14535
|
-
const a = typeof t.timeoutMs == "number" && t.timeoutMs > 0 ? t.timeoutMs :
|
|
14556
|
+
const a = typeof t.timeoutMs == "number" && t.timeoutMs > 0 ? t.timeoutMs : qh, n = typeof t.intervalMs == "number" && t.intervalMs > 0 ? t.intervalMs : Hh, i = await Jh(r, a, n);
|
|
14536
14557
|
if (!i) throw new Ke("global", `window.${r} not present`);
|
|
14537
14558
|
return { token: i, source: "global" };
|
|
14538
14559
|
}
|
|
@@ -14545,7 +14566,7 @@ async function Hh(c) {
|
|
|
14545
14566
|
}
|
|
14546
14567
|
}
|
|
14547
14568
|
}
|
|
14548
|
-
class
|
|
14569
|
+
class Kh {
|
|
14549
14570
|
constructor(e) {
|
|
14550
14571
|
this.opts = e;
|
|
14551
14572
|
}
|
|
@@ -14556,7 +14577,7 @@ class zh {
|
|
|
14556
14577
|
/** Resolve the token. Returns cache if present. */
|
|
14557
14578
|
async get() {
|
|
14558
14579
|
if (this.cached) return this.cached;
|
|
14559
|
-
const e = await
|
|
14580
|
+
const e = await zh(this.opts);
|
|
14560
14581
|
return this.cached = e, e;
|
|
14561
14582
|
}
|
|
14562
14583
|
/**
|
|
@@ -14573,7 +14594,7 @@ class Ke extends Error {
|
|
|
14573
14594
|
super(`[aikaara-chat-sdk] token-discovery (${e}): ${t}`), this.source = e, this.name = "TokenDiscoveryError";
|
|
14574
14595
|
}
|
|
14575
14596
|
}
|
|
14576
|
-
function
|
|
14597
|
+
function Vh(c) {
|
|
14577
14598
|
if (!(typeof window > "u"))
|
|
14578
14599
|
try {
|
|
14579
14600
|
return new URL(window.location.href).searchParams.get(c) ?? void 0;
|
|
@@ -14581,7 +14602,7 @@ function Kh(c) {
|
|
|
14581
14602
|
return;
|
|
14582
14603
|
}
|
|
14583
14604
|
}
|
|
14584
|
-
function
|
|
14605
|
+
function Gh(c) {
|
|
14585
14606
|
if (!(typeof window > "u"))
|
|
14586
14607
|
try {
|
|
14587
14608
|
const e = window.location.hash.replace(/^#/, "");
|
|
@@ -14590,7 +14611,7 @@ function Vh(c) {
|
|
|
14590
14611
|
return;
|
|
14591
14612
|
}
|
|
14592
14613
|
}
|
|
14593
|
-
function
|
|
14614
|
+
function Yh(c) {
|
|
14594
14615
|
if (typeof document > "u") return;
|
|
14595
14616
|
const e = encodeURIComponent(c), t = document.cookie ? document.cookie.split("; ") : [];
|
|
14596
14617
|
for (const r of t) {
|
|
@@ -14605,7 +14626,7 @@ function Gh(c) {
|
|
|
14605
14626
|
}
|
|
14606
14627
|
}
|
|
14607
14628
|
}
|
|
14608
|
-
function
|
|
14629
|
+
function Qh(c, e, t) {
|
|
14609
14630
|
if (!(typeof window > "u"))
|
|
14610
14631
|
try {
|
|
14611
14632
|
const a = (c === "session" ? window.sessionStorage : window.localStorage).getItem(e);
|
|
@@ -14623,7 +14644,7 @@ function Yh(c, e, t) {
|
|
|
14623
14644
|
return;
|
|
14624
14645
|
}
|
|
14625
14646
|
}
|
|
14626
|
-
async function
|
|
14647
|
+
async function Jh(c, e, t) {
|
|
14627
14648
|
if (typeof window > "u") return;
|
|
14628
14649
|
const r = Date.now() + e;
|
|
14629
14650
|
for (; Date.now() < r; ) {
|
|
@@ -14638,7 +14659,7 @@ async function Qh(c, e, t) {
|
|
|
14638
14659
|
await new Promise((n) => setTimeout(n, t));
|
|
14639
14660
|
}
|
|
14640
14661
|
}
|
|
14641
|
-
function
|
|
14662
|
+
function Xh(c) {
|
|
14642
14663
|
return new Promise((e, t) => {
|
|
14643
14664
|
if (typeof window > "u") {
|
|
14644
14665
|
t(new Ke("postmsg", "no window"));
|
|
@@ -14660,7 +14681,7 @@ function Jh(c) {
|
|
|
14660
14681
|
window.addEventListener("message", n);
|
|
14661
14682
|
});
|
|
14662
14683
|
}
|
|
14663
|
-
function
|
|
14684
|
+
function Zh(c) {
|
|
14664
14685
|
return c ? c.split(/[,\s]+/).map((e) => e.trim()).filter(Boolean) : [];
|
|
14665
14686
|
}
|
|
14666
14687
|
function hl(c, e) {
|
|
@@ -14674,7 +14695,7 @@ function hl(c, e) {
|
|
|
14674
14695
|
return;
|
|
14675
14696
|
return r;
|
|
14676
14697
|
}
|
|
14677
|
-
function
|
|
14698
|
+
function ef() {
|
|
14678
14699
|
const c = typeof crypto < "u" ? crypto : null;
|
|
14679
14700
|
if (c?.randomUUID) return c.randomUUID();
|
|
14680
14701
|
if (c?.getRandomValues) {
|
|
@@ -14688,30 +14709,30 @@ function Zh() {
|
|
|
14688
14709
|
return (e === "x" ? t : t & 3 | 8).toString(16);
|
|
14689
14710
|
});
|
|
14690
14711
|
}
|
|
14691
|
-
const
|
|
14712
|
+
const tf = "aikaara_chat:requestId";
|
|
14692
14713
|
function so(c, e) {
|
|
14693
|
-
return `${
|
|
14714
|
+
return `${tf}:${c}:${e}`;
|
|
14694
14715
|
}
|
|
14695
|
-
function
|
|
14716
|
+
function rf(c, e) {
|
|
14696
14717
|
try {
|
|
14697
14718
|
return localStorage.getItem(so(c, e));
|
|
14698
14719
|
} catch {
|
|
14699
14720
|
return null;
|
|
14700
14721
|
}
|
|
14701
14722
|
}
|
|
14702
|
-
function
|
|
14723
|
+
function nf(c, e, t) {
|
|
14703
14724
|
try {
|
|
14704
14725
|
localStorage.setItem(so(c, e), t);
|
|
14705
14726
|
} catch {
|
|
14706
14727
|
}
|
|
14707
14728
|
}
|
|
14708
|
-
function
|
|
14729
|
+
function hf(c, e) {
|
|
14709
14730
|
try {
|
|
14710
14731
|
localStorage.removeItem(so(c, e));
|
|
14711
14732
|
} catch {
|
|
14712
14733
|
}
|
|
14713
14734
|
}
|
|
14714
|
-
async function
|
|
14735
|
+
async function of(c, e) {
|
|
14715
14736
|
console.log("[aikaara-chat-sdk] preflight running", c.length, "steps");
|
|
14716
14737
|
const t = {
|
|
14717
14738
|
userId: e.userId,
|
|
@@ -14744,7 +14765,7 @@ async function nf(c, e) {
|
|
|
14744
14765
|
try {
|
|
14745
14766
|
const b = await fetch(l, p);
|
|
14746
14767
|
if (b.ok) break;
|
|
14747
|
-
if (y = b.status, f = await b.text().catch(() => ""), g < i.length &&
|
|
14768
|
+
if (y = b.status, f = await b.text().catch(() => ""), g < i.length && sf(y, f)) {
|
|
14748
14769
|
const m = i[g++];
|
|
14749
14770
|
console.warn(
|
|
14750
14771
|
`[aikaara-chat-sdk] preflight #${s} ${u} ${l} → ${y} (transient). Retry #${g} in ${m}ms.`
|
|
@@ -14774,7 +14795,7 @@ async function nf(c, e) {
|
|
|
14774
14795
|
}
|
|
14775
14796
|
}
|
|
14776
14797
|
}
|
|
14777
|
-
function
|
|
14798
|
+
function sf(c, e) {
|
|
14778
14799
|
if (c === 503 || c === 504 || c === 502) return !0;
|
|
14779
14800
|
if (c === 401 || c === 403) return e.trim().length === 0;
|
|
14780
14801
|
if (c === 500) {
|
|
@@ -14799,8 +14820,8 @@ async function fl(c, e) {
|
|
|
14799
14820
|
}
|
|
14800
14821
|
return r;
|
|
14801
14822
|
}
|
|
14802
|
-
function
|
|
14803
|
-
return c.replace("{projectId}", e).replace("{uuid}",
|
|
14823
|
+
function af(c, e) {
|
|
14824
|
+
return c.replace("{projectId}", e).replace("{uuid}", ef().replace(/-/g, ""));
|
|
14804
14825
|
}
|
|
14805
14826
|
function dl(c) {
|
|
14806
14827
|
const e = c._preload;
|
|
@@ -14812,7 +14833,7 @@ function dl(c) {
|
|
|
14812
14833
|
);
|
|
14813
14834
|
t.length !== 0 && Promise.allSettled(t.map((r) => ul(r)));
|
|
14814
14835
|
}
|
|
14815
|
-
async function
|
|
14836
|
+
async function lf(c) {
|
|
14816
14837
|
const e = {
|
|
14817
14838
|
...c.config ?? (c.configUrl ? await fl(c.configUrl, c.configHeaders) : {}),
|
|
14818
14839
|
...c.overrides ?? {}
|
|
@@ -14821,8 +14842,8 @@ async function af(c) {
|
|
|
14821
14842
|
const t = e.transport ?? "tiledesk", r = e.tiledesk;
|
|
14822
14843
|
if ((t === "tiledesk" || t === "dual") && !r)
|
|
14823
14844
|
throw new Error("mount: descriptor.tiledesk is required for tiledesk/dual transport");
|
|
14824
|
-
const a = r?.projectId ?? "", n = c.identity.userId, i = c.forceNewConversation ? null :
|
|
14825
|
-
(!i || c.forceNewConversation) && a &&
|
|
14845
|
+
const a = r?.projectId ?? "", n = c.identity.userId, i = c.forceNewConversation ? null : rf(n, a), s = r?.requestIdTemplate ?? "support-group-{projectId}-{uuid}", o = c.conversationId ?? i ?? af(s, a);
|
|
14846
|
+
(!i || c.forceNewConversation) && a && nf(n, a, o);
|
|
14826
14847
|
const l = await c.tokenProvider(), u = c.tokenProvider, d = c.historyTokenProvider ?? u, p = r ? {
|
|
14827
14848
|
mqttEndpoint: r.mqttEndpoint,
|
|
14828
14849
|
jwtToken: l,
|
|
@@ -14909,13 +14930,13 @@ async function af(c) {
|
|
|
14909
14930
|
}
|
|
14910
14931
|
};
|
|
14911
14932
|
}
|
|
14912
|
-
function
|
|
14933
|
+
function cf(c) {
|
|
14913
14934
|
if (typeof c != "string") return c;
|
|
14914
14935
|
const e = document.querySelector(c);
|
|
14915
14936
|
if (!e) throw new Error(`mountFromSlug: container "${c}" not found`);
|
|
14916
14937
|
return e;
|
|
14917
14938
|
}
|
|
14918
|
-
async function
|
|
14939
|
+
async function uf(c) {
|
|
14919
14940
|
const e = (c.configBase ?? "https://api.aikaara.com").replace(/\/$/, ""), t = `${e}/api/v1/widget_configs/${encodeURIComponent(c.slug)}`;
|
|
14920
14941
|
let r = null;
|
|
14921
14942
|
try {
|
|
@@ -14955,7 +14976,7 @@ async function cf(c) {
|
|
|
14955
14976
|
);
|
|
14956
14977
|
let n = null, i = c.user.id, s = c.user.name, o = "", l = c.user.token, u = null;
|
|
14957
14978
|
if (a.sso?.tokenSource) {
|
|
14958
|
-
u = new
|
|
14979
|
+
u = new Kh({
|
|
14959
14980
|
descriptor: {
|
|
14960
14981
|
provider: a.sso.provider,
|
|
14961
14982
|
flow: a.sso.flow,
|
|
@@ -14972,20 +14993,20 @@ async function cf(c) {
|
|
|
14972
14993
|
l = async () => (await u.get()).token, c.user.identity && !c.user.identity.partnerToken && (c.user.identity.partnerToken = w.token);
|
|
14973
14994
|
} else if (a.sso && a.sso.collect && a.sso.collect.length > 0) {
|
|
14974
14995
|
const w = `${e}/api/v1/projects/by-slug/${encodeURIComponent(c.slug)}/sso_exchange`;
|
|
14975
|
-
n = await new
|
|
14996
|
+
n = await new $h({
|
|
14976
14997
|
descriptor: a.sso,
|
|
14977
14998
|
providers: c.user.credentialProviders,
|
|
14978
14999
|
exchangeUrl: w
|
|
14979
15000
|
}).get(), i = n.extUid || i, s = s ?? n.displayName, o = n.userToken;
|
|
14980
15001
|
}
|
|
14981
|
-
a.preflight && a.preflight.length && await
|
|
15002
|
+
a.preflight && a.preflight.length && await of(a.preflight, {
|
|
14982
15003
|
sessionToken: l,
|
|
14983
15004
|
userId: i,
|
|
14984
15005
|
projectId: a.tiledesk?.projectId ?? "",
|
|
14985
15006
|
slug: c.slug,
|
|
14986
15007
|
identity: c.user.identity
|
|
14987
15008
|
});
|
|
14988
|
-
const d = new
|
|
15009
|
+
const d = new Lh(a.auth, l), p = await d.get(), y = p.fullName || s || i;
|
|
14989
15010
|
window.__aikaara_runtime__ = {
|
|
14990
15011
|
getChatJwt: async () => (await d.get()).token,
|
|
14991
15012
|
identity: c.user.identity,
|
|
@@ -15005,8 +15026,8 @@ async function cf(c) {
|
|
|
15005
15026
|
fieldName: g.fieldName,
|
|
15006
15027
|
extraFields: g.extraFields,
|
|
15007
15028
|
headers: async () => ({ authorization: await b() })
|
|
15008
|
-
}) : void 0), m = await
|
|
15009
|
-
container:
|
|
15029
|
+
}) : void 0), m = await lf({
|
|
15030
|
+
container: cf(c.container),
|
|
15010
15031
|
config: a,
|
|
15011
15032
|
// SSO-issued Aikaara user token, used by the ActionCable transport.
|
|
15012
15033
|
// Tiledesk-only widgets ignore this; falls back to `userId` inside `mount`.
|
|
@@ -15040,45 +15061,45 @@ async function cf(c) {
|
|
|
15040
15061
|
}
|
|
15041
15062
|
export {
|
|
15042
15063
|
ao as A,
|
|
15043
|
-
|
|
15064
|
+
uf as B,
|
|
15044
15065
|
pl as C,
|
|
15045
|
-
|
|
15066
|
+
lf as D,
|
|
15046
15067
|
Ts as E,
|
|
15047
15068
|
sl as F,
|
|
15048
|
-
|
|
15049
|
-
|
|
15050
|
-
|
|
15051
|
-
|
|
15052
|
-
|
|
15053
|
-
|
|
15069
|
+
Th as G,
|
|
15070
|
+
Mh as H,
|
|
15071
|
+
Ch as I,
|
|
15072
|
+
Ih as J,
|
|
15073
|
+
Eh as K,
|
|
15074
|
+
xh as L,
|
|
15054
15075
|
Al as M,
|
|
15055
|
-
|
|
15056
|
-
|
|
15057
|
-
|
|
15076
|
+
Sh as N,
|
|
15077
|
+
wh as O,
|
|
15078
|
+
Lh as S,
|
|
15058
15079
|
$u as T,
|
|
15059
15080
|
rh as a,
|
|
15060
15081
|
Vu as b,
|
|
15061
15082
|
nh as c,
|
|
15062
|
-
|
|
15083
|
+
ph as d,
|
|
15063
15084
|
th as e,
|
|
15064
|
-
|
|
15065
|
-
|
|
15066
|
-
|
|
15067
|
-
|
|
15068
|
-
|
|
15085
|
+
bh as f,
|
|
15086
|
+
fh as g,
|
|
15087
|
+
ch as h,
|
|
15088
|
+
mh as i,
|
|
15089
|
+
gh as j,
|
|
15069
15090
|
xl as k,
|
|
15070
15091
|
El as l,
|
|
15071
15092
|
Tl as m,
|
|
15072
|
-
|
|
15093
|
+
$h as n,
|
|
15073
15094
|
Ke as o,
|
|
15074
|
-
|
|
15075
|
-
|
|
15076
|
-
|
|
15077
|
-
|
|
15095
|
+
Kh as p,
|
|
15096
|
+
hf as q,
|
|
15097
|
+
Rh as r,
|
|
15098
|
+
Nh as s,
|
|
15078
15099
|
al as t,
|
|
15079
15100
|
Ju as u,
|
|
15080
15101
|
Zu as v,
|
|
15081
|
-
|
|
15102
|
+
zh as w,
|
|
15082
15103
|
zu as x,
|
|
15083
15104
|
Hu as y,
|
|
15084
15105
|
qu as z
|