bstp-agent-widget 0.2.101 → 0.2.102

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.
@@ -28149,13 +28149,9 @@ var xP = /* @__PURE__ */ function(e) {
28149
28149
  //#endregion
28150
28150
  //#region src/components/AgentChat/AgentChatPanel/AgentChatPanelContentBody.tsx
28151
28151
  function SP({ messages: e, isLoading: t, error: n, scrollViewportRef: r, onWidgetEvent: i }) {
28152
- return /* @__PURE__ */ E(Qv, {
28152
+ return /* @__PURE__ */ T(Qv, {
28153
28153
  className: TT.body,
28154
- children: [n && /* @__PURE__ */ T(ef, {
28155
- size: "xs",
28156
- c: "red",
28157
- children: n
28158
- }), /* @__PURE__ */ T(dc, {
28154
+ children: /* @__PURE__ */ T(dc, {
28159
28155
  h: "100%",
28160
28156
  type: "auto",
28161
28157
  offsetScrollbars: !0,
@@ -28163,28 +28159,36 @@ function SP({ messages: e, isLoading: t, error: n, scrollViewportRef: r, onWidge
28163
28159
  children: /* @__PURE__ */ E(Qv, {
28164
28160
  gap: "sm",
28165
28161
  className: TT.messageList,
28166
- children: [e.map((e) => /* @__PURE__ */ T(Y, {
28167
- className: `${TT.messageBubble} ${e.sentBy === xP.USER ? TT.messageBubbleUser : TT.messageBubbleAssistant}`,
28168
- children: e.sentBy === xP.ASSISTANT ? /* @__PURE__ */ T(bP, {
28169
- content: e.text,
28170
- onWidgetEvent: i
28171
- }) : /* @__PURE__ */ T(ef, {
28172
- className: TT.userText,
28173
- children: e.text
28162
+ children: [
28163
+ n && /* @__PURE__ */ T(Yd, {
28164
+ color: "red",
28165
+ variant: "light",
28166
+ children: n
28167
+ }),
28168
+ e.map((e) => /* @__PURE__ */ T(Y, {
28169
+ className: `${TT.messageBubble} ${e.sentBy === xP.USER ? TT.messageBubbleUser : TT.messageBubbleAssistant}`,
28170
+ children: e.sentBy === xP.ASSISTANT ? /* @__PURE__ */ T(bP, {
28171
+ content: e.text,
28172
+ onWidgetEvent: i
28173
+ }) : /* @__PURE__ */ T(ef, {
28174
+ className: TT.userText,
28175
+ children: e.text
28176
+ })
28177
+ }, e.id)),
28178
+ t && /* @__PURE__ */ T(Y, {
28179
+ className: `${TT.messageBubble} ${TT.messageBubbleAssistant}`,
28180
+ children: /* @__PURE__ */ T(PP, { messages: [
28181
+ "Thinking",
28182
+ "Analyzing your request",
28183
+ "Searching for information",
28184
+ "Processing data",
28185
+ "Preparing response",
28186
+ "Almost there"
28187
+ ] })
28174
28188
  })
28175
- }, e.id)), t && /* @__PURE__ */ T(Y, {
28176
- className: `${TT.messageBubble} ${TT.messageBubbleAssistant}`,
28177
- children: /* @__PURE__ */ T(PP, { messages: [
28178
- "Thinking",
28179
- "Analyzing your request",
28180
- "Searching for information",
28181
- "Processing data",
28182
- "Preparing response",
28183
- "Almost there"
28184
- ] })
28185
- })]
28189
+ ]
28186
28190
  })
28187
- })]
28191
+ })
28188
28192
  });
28189
28193
  }
28190
28194
  var CP = {
@@ -28833,7 +28837,12 @@ function WP({ items: e, title: t = "Details", advantages: n = [], price: r, pric
28833
28837
  }
28834
28838
  //#endregion
28835
28839
  //#region src/context/AgentChatRuntimeContext.tsx
28836
- var GP = o(null);
28840
+ var GP = o({
28841
+ customerId: "",
28842
+ customerToken: "",
28843
+ language: "en",
28844
+ forceReAuth: !1
28845
+ });
28837
28846
  //#endregion
28838
28847
  //#region src/hooks/useAgentChatRuntime.ts
28839
28848
  function KP() {
@@ -28854,13 +28863,13 @@ function JP() {
28854
28863
  //#endregion
28855
28864
  //#region src/mappers/agent-chat-runtime.mapper.ts
28856
28865
  function YP(e) {
28857
- return "customerId" in e ? e.customerId : e.getCustomerId();
28866
+ return e.customerId;
28858
28867
  }
28859
- async function XP(e) {
28860
- return "customerToken" in e ? e.customerToken : e.getCustomerToken();
28868
+ function XP(e) {
28869
+ return e.customerToken;
28861
28870
  }
28862
28871
  function ZP(e) {
28863
- return "language" in e ? e.language ?? null : "getLanguage" in e && e.getLanguage ? e.getLanguage() : null;
28872
+ return e.language ?? null;
28864
28873
  }
28865
28874
  //#endregion
28866
28875
  //#region src/mappers/agent-chat-config.mapper.ts
@@ -33833,13 +33842,16 @@ function IV() {
33833
33842
  var LV = EV({
33834
33843
  mutationKey: ["genai", "login"],
33835
33844
  mutationFn: async ({ serviceAccount: e, serviceKey: t }) => TV.loginToGenai(e, t)
33836
- }), RV = null, zV = null;
33837
- function BV(e = !1) {
33845
+ }), RV = new lV("useGenaiLogin"), zV = null, BV = null;
33846
+ function VV(e = !1) {
33838
33847
  let t = IV(), { mutateAsync: n } = LV(), [r, i] = y(!1), [a, o] = y(null), [s, c] = y(null), [l, u] = y(null);
33839
33848
  return f(() => {
33840
33849
  (async () => {
33841
33850
  let r = pF();
33842
- if (console.log("useGenaiLogin - forceReAuth:", e, "existingToken:", !!r), r && !e) {
33851
+ if (RV.debug("Checking existing token", {
33852
+ forceReAuth: e,
33853
+ hasExistingToken: !!r
33854
+ }), r && !e) {
33843
33855
  c(r);
33844
33856
  return;
33845
33857
  }
@@ -33847,21 +33859,24 @@ function BV(e = !1) {
33847
33859
  if (!a) return;
33848
33860
  u(a);
33849
33861
  let s = `${a.serviceAccount}::${a.serviceKey}`;
33850
- if (console.log("useGenaiLogin - currentKey:", s, "attemptedLoginKey:", RV), RV === s && !e) {
33851
- zV && c(await zV);
33862
+ if (RV.debug("Checking login key", {
33863
+ currentKey: s,
33864
+ attemptedLoginKey: zV
33865
+ }), zV === s && !e) {
33866
+ BV && c(await BV);
33852
33867
  return;
33853
33868
  }
33854
- e && (console.log("useGenaiLogin - Resetting module-level state for forceReAuth"), RV = null, zV = null), RV = s, i(!0), o(null), zV = (async () => (console.log("useGenaiLogin - Attempting login"), (await n({
33869
+ e && (RV.info("Resetting module-level state for forceReAuth"), zV = null, BV = null), zV = s, i(!0), o(null), BV = (async () => (RV.info("Attempting login"), (await n({
33855
33870
  serviceAccount: a.serviceAccount,
33856
33871
  serviceKey: a.serviceKey
33857
33872
  })).access_token ?? null))();
33858
33873
  try {
33859
- let e = await zV;
33860
- c(e), console.log("useGenaiLogin - Login successful, token:", !!e);
33874
+ let e = await BV;
33875
+ c(e), RV.info("Login successful", { hasToken: !!e });
33861
33876
  } catch (e) {
33862
- console.error("GenAI login failed at app startup:", e), o("Failed to authenticate with GenAI service");
33877
+ RV.error("GenAI login failed", { error: e instanceof Error ? e.message : String(e) }), o("Failed to authenticate with GenAI service");
33863
33878
  } finally {
33864
- zV = null, i(!1);
33879
+ BV = null, i(!1);
33865
33880
  }
33866
33881
  })();
33867
33882
  }, [
@@ -33877,12 +33892,12 @@ function BV(e = !1) {
33877
33892
  }
33878
33893
  //#endregion
33879
33894
  //#region src/queries/genai/useTenantSwitchMutation.ts
33880
- var VV = EV({
33895
+ var HV = EV({
33881
33896
  mutationKey: ["genai", "tenant-switch"],
33882
33897
  mutationFn: async ({ tenant_id: e, token: t }) => TV.switchTenant(e, t)
33883
- }), HV = null, UV = null;
33884
- function WV(e, t, n = !1) {
33885
- let { mutateAsync: r } = VV(), [i, a] = y(!1), [o, s] = y(null), [c, l] = y(!1);
33898
+ }), UV = null, WV = null;
33899
+ function GV(e, t, n = !1) {
33900
+ let { mutateAsync: r } = HV(), [i, a] = y(!1), [o, s] = y(null), [c, l] = y(!1);
33886
33901
  return f(() => {
33887
33902
  (async () => {
33888
33903
  if (!e || !t) {
@@ -33897,22 +33912,22 @@ function WV(e, t, n = !1) {
33897
33912
  l(!0);
33898
33913
  return;
33899
33914
  }
33900
- if (console.log("useGenaiTenantSwitch - switchedForToken:", UV, "loginToken:", e), UV === e && !n) {
33901
- HV && (await HV, l(!!pF()));
33915
+ if (console.log("useGenaiTenantSwitch - switchedForToken:", WV, "loginToken:", e), WV === e && !n) {
33916
+ UV && (await UV, l(!!pF()));
33902
33917
  return;
33903
33918
  }
33904
- n && (console.log("useGenaiTenantSwitch - Resetting module-level state for forceReAuth"), UV = null, HV = null), UV = e, a(!0), s(null), HV = (async () => {
33919
+ n && (console.log("useGenaiTenantSwitch - Resetting module-level state for forceReAuth"), WV = null, UV = null), WV = e, a(!0), s(null), UV = (async () => {
33905
33920
  console.log("useGenaiTenantSwitch - Attempting tenant switch for tenantId:", t), await r({
33906
33921
  tenant_id: t,
33907
33922
  token: e
33908
33923
  });
33909
33924
  })();
33910
33925
  try {
33911
- await HV, l(!0), console.log("useGenaiTenantSwitch - Tenant switch successful");
33926
+ await UV, l(!0), console.log("useGenaiTenantSwitch - Tenant switch successful");
33912
33927
  } catch (e) {
33913
33928
  console.error("GenAI tenant switch failed:", e), s("Failed to switch tenant");
33914
33929
  } finally {
33915
- HV = null, a(!1);
33930
+ UV = null, a(!1);
33916
33931
  }
33917
33932
  })();
33918
33933
  }, [
@@ -33928,8 +33943,8 @@ function WV(e, t, n = !1) {
33928
33943
  }
33929
33944
  //#endregion
33930
33945
  //#region src/hooks/useGenaiAuth.ts
33931
- function GV(e = !1) {
33932
- let { isLoggingIn: t, loginError: n, loginToken: r, genaiInit: i } = BV(e), { isSwitching: a, switchError: o, hasToken: s } = WV(r, i?.tenantId, e);
33946
+ function KV(e = !1) {
33947
+ let { isLoggingIn: t, loginError: n, loginToken: r, genaiInit: i } = VV(e), { isSwitching: a, switchError: o, hasToken: s } = GV(r, i?.tenantId, e);
33933
33948
  return {
33934
33949
  isAuthenticating: t || a,
33935
33950
  authError: n ?? o,
@@ -33938,7 +33953,7 @@ function GV(e = !1) {
33938
33953
  }
33939
33954
  //#endregion
33940
33955
  //#region src/hooks/usePanelState.ts
33941
- function KV(e = {}) {
33956
+ function qV(e = {}) {
33942
33957
  let { defaultOpen: t = !1, persist: n = !0 } = e, [r, i] = nt({
33943
33958
  key: n ? IN.PANEL_OPEN : `panel-state-${Date.now()}`,
33944
33959
  defaultValue: t,
@@ -33969,14 +33984,14 @@ function KV(e = {}) {
33969
33984
  }
33970
33985
  //#endregion
33971
33986
  //#region src/hooks/useAgentChatUiOptions.ts
33972
- var qV = {
33987
+ var JV = {
33973
33988
  bottom: 24,
33974
33989
  right: 24
33975
- }, JV = 1e4;
33976
- function YV(e) {
33977
- let t = e?.panelWidth ?? 420, n = e?.panelHeight ?? "100%", r = e?.panelHeaderHeight ?? 56, i = e?.panelTopOffset, a = e?.zIndex ?? JV, o = {
33978
- ...typeof e?.fabTopOffset == "number" ? { top: e.fabTopOffset } : { bottom: e?.fabBottomOffset ?? qV.bottom },
33979
- ...typeof e?.fabLeftOffset == "number" ? { left: e.fabLeftOffset } : { right: e?.fabRightOffset ?? qV.right }
33990
+ }, YV = 1e4;
33991
+ function XV(e) {
33992
+ let t = e?.panelWidth ?? 420, n = e?.panelHeight ?? "100%", r = e?.panelHeaderHeight ?? 56, i = e?.panelTopOffset, a = e?.zIndex ?? YV, o = {
33993
+ ...typeof e?.fabTopOffset == "number" ? { top: e.fabTopOffset } : { bottom: e?.fabBottomOffset ?? JV.bottom },
33994
+ ...typeof e?.fabLeftOffset == "number" ? { left: e.fabLeftOffset } : { right: e?.fabRightOffset ?? JV.right }
33980
33995
  }, s = e?.panelTitle ?? "Agent Chat";
33981
33996
  return {
33982
33997
  panelWidth: t,
@@ -33992,7 +34007,7 @@ function YV(e) {
33992
34007
  }
33993
34008
  //#endregion
33994
34009
  //#region src/hooks/useAgentChatActions.ts
33995
- function XV(e, t) {
34010
+ function ZV(e, t) {
33996
34011
  let n = v([]);
33997
34012
  return {
33998
34013
  actions: _(() => {
@@ -34008,7 +34023,7 @@ function XV(e, t) {
34008
34023
  }
34009
34024
  //#endregion
34010
34025
  //#region src/hooks/useResizable.ts
34011
- function ZV(e = {}) {
34026
+ function QV(e = {}) {
34012
34027
  let { axis: t = "y", direction: n = 1, onResizeChange: r } = e, [i, a] = y(0), o = v({
34013
34028
  startPos: 0,
34014
34029
  startOffset: 0
@@ -34046,7 +34061,7 @@ function ZV(e = {}) {
34046
34061
  }
34047
34062
  //#endregion
34048
34063
  //#region src/hooks/useAgentChatLayout.ts
34049
- var QV = [
34064
+ var $V = [
34050
34065
  "#root main",
34051
34066
  "#root",
34052
34067
  "main",
@@ -34054,9 +34069,9 @@ var QV = [
34054
34069
  "#app",
34055
34070
  "body"
34056
34071
  ];
34057
- function $V(e, t, n) {
34072
+ function eH(e, t, n) {
34058
34073
  let r = v(Math.max(280, t ?? 420)), i = v(n ?? !1), a = v(null), o = u(() => {
34059
- let t = e?.hostContainerSelector, n = [...t ? t.split(",").map((e) => e.trim()).filter(Boolean) : [], ...QV];
34074
+ let t = e?.hostContainerSelector, n = [...t ? t.split(",").map((e) => e.trim()).filter(Boolean) : [], ...$V];
34060
34075
  for (let e of n) {
34061
34076
  let t = document.querySelector(e);
34062
34077
  if (t) return t;
@@ -34082,7 +34097,7 @@ function $V(e, t, n) {
34082
34097
  }
34083
34098
  let { element: n, inlinePaddingBefore: r, widthApplied: i } = a.current;
34084
34099
  e !== i && (n.style.paddingRight = r, n.style.paddingRight = `calc(${r || "0px"} + ${e}px)`, a.current.widthApplied = e);
34085
- }, [o]), c = ZV({
34100
+ }, [o]), c = QV({
34086
34101
  axis: "x",
34087
34102
  direction: -1,
34088
34103
  onResizeChange: u((e) => {
@@ -34107,7 +34122,7 @@ function $V(e, t, n) {
34107
34122
  }
34108
34123
  //#endregion
34109
34124
  //#region src/hooks/useAgentChatVoiceHandlers.ts
34110
- function eH({ isListening: e, stopListening: t, reset: n, sendMessage: r, composerText: i, setComposerText: a, startListening: o, close: s }) {
34125
+ function tH({ isListening: e, stopListening: t, reset: n, sendMessage: r, composerText: i, setComposerText: a, startListening: o, close: s }) {
34111
34126
  return {
34112
34127
  handleSubmit: () => {
34113
34128
  e && t(), n(), r(i);
@@ -34122,7 +34137,7 @@ function eH({ isListening: e, stopListening: t, reset: n, sendMessage: r, compos
34122
34137
  }
34123
34138
  //#endregion
34124
34139
  //#region src/utils/color-utils.ts
34125
- function tH(e) {
34140
+ function nH(e) {
34126
34141
  let t = 0, n = 0, r = 0;
34127
34142
  if (e.startsWith("rgb")) {
34128
34143
  let i = e.match(/\d+/g);
@@ -34137,16 +34152,16 @@ function tH(e) {
34137
34152
  b: r
34138
34153
  };
34139
34154
  }
34140
- function nH(e, t) {
34141
- let { r: n, g: r, b: i } = tH(e), a = t / 100;
34155
+ function rH(e, t) {
34156
+ let { r: n, g: r, b: i } = nH(e), a = t / 100;
34142
34157
  return `rgb(${Math.min(255, n + (255 - n) * a)}, ${Math.min(255, r + (255 - r) * a)}, ${Math.min(255, i + (255 - i) * a)})`;
34143
34158
  }
34144
- function rH(e, t) {
34145
- let { r: n, g: r, b: i } = tH(e), a = t / 100;
34159
+ function iH(e, t) {
34160
+ let { r: n, g: r, b: i } = nH(e), a = t / 100;
34146
34161
  return `rgb(${Math.max(0, n - n * a)}, ${Math.max(0, r - r * a)}, ${Math.max(0, i - i * a)})`;
34147
34162
  }
34148
- function iH(e) {
34149
- let { r: t, g: n, b: r } = tH(e);
34163
+ function aH(e) {
34164
+ let { r: t, g: n, b: r } = nH(e);
34150
34165
  return [
34151
34166
  `rgb(${t + 50}, ${n + 50}, ${r + 50})`,
34152
34167
  `rgb(${t + 40}, ${n + 40}, ${r + 40})`,
@@ -34163,10 +34178,10 @@ function iH(e) {
34163
34178
  }
34164
34179
  //#endregion
34165
34180
  //#region src/hooks/useAccentColor.ts
34166
- function aH(e) {
34181
+ function oH(e) {
34167
34182
  let t = _(() => {
34168
34183
  if (e) try {
34169
- let t = iH(e);
34184
+ let t = aH(e);
34170
34185
  if (t && t.length === 11) return nT({
34171
34186
  colors: { accent: t },
34172
34187
  primaryColor: "accent"
@@ -34178,8 +34193,8 @@ function aH(e) {
34178
34193
  }, [e]);
34179
34194
  return f(() => {
34180
34195
  try {
34181
- let t = document.documentElement, n = e || "#414275", r = nH(n, 40), i = rH(n, 15);
34182
- t.style.setProperty("--agent-accent-color", n), t.style.setProperty("--agent-accent-color-light", nH(n, 40)), t.style.setProperty("--agent-accent-color-dark", i), t.style.setProperty("--agent-accent-bg", n), t.style.setProperty("--agent-accent-bg-light", r), t.style.setProperty("--agent-accent-border", n), t.style.setProperty("--agent-accent-text", "#ffffff"), t.style.setProperty("--agent-accent-text-muted", "rgba(255, 255, 255, 0.8)"), console.log("CSS variables set successfully");
34196
+ let t = document.documentElement, n = e || "#414275", r = rH(n, 40), i = iH(n, 15);
34197
+ t.style.setProperty("--agent-accent-color", n), t.style.setProperty("--agent-accent-color-light", rH(n, 40)), t.style.setProperty("--agent-accent-color-dark", i), t.style.setProperty("--agent-accent-bg", n), t.style.setProperty("--agent-accent-bg-light", r), t.style.setProperty("--agent-accent-border", n), t.style.setProperty("--agent-accent-text", "#ffffff"), t.style.setProperty("--agent-accent-text-muted", "rgba(255, 255, 255, 0.8)"), console.log("CSS variables set successfully");
34183
34198
  } catch (e) {
34184
34199
  console.error("Failed to set accent color CSS properties:", e);
34185
34200
  }
@@ -34187,72 +34202,81 @@ function aH(e) {
34187
34202
  }
34188
34203
  //#endregion
34189
34204
  //#region src/features/agent-chat/components/AgentChatLauncher/AgentChatLauncher.tsx
34190
- function oH(e) {
34191
- let t = d(GP), n = t && "forceReAuth" in t ? t.forceReAuth : !1;
34192
- console.log("AgentChatLauncher - forceReAuth:", n, "runtime:", t), GV(n);
34193
- let { panelWidth: r, panelHeight: i, panelHeaderHeight: a, panelTopOffset: o, zIndex: s, fabPosition: c, fabButtonLabel: l, panelTitle: u, accentColor: f } = YV(e);
34194
- aH(f);
34195
- let p = v(!1), { messages: m, composerText: h, setComposerText: g, isLoading: _, error: y, sendMessage: b, sendInitialMessage: x, canSend: S } = kV(), { actions: C, handleActionClick: D } = XV(m, b), { runtimeInfo: O, refreshRuntimeInfo: k } = AV(), { isOpen: A, open: j, close: M } = KV({
34205
+ function sH(e) {
34206
+ let t = d(GP).forceReAuth, { isAuthenticating: n, hasToken: r } = KV(t), { panelWidth: i, panelHeight: a, panelHeaderHeight: o, panelTopOffset: s, zIndex: c, fabPosition: l, fabButtonLabel: u, panelTitle: p, accentColor: m } = XV(e);
34207
+ oH(m);
34208
+ let h = v(!1), { messages: g, composerText: _, setComposerText: y, isLoading: b, error: x, sendMessage: S, sendInitialMessage: C, canSend: D } = kV(), { actions: O, handleActionClick: k } = ZV(g, S), { runtimeInfo: A, refreshRuntimeInfo: j } = AV(), { isOpen: M, open: N, close: P } = qV({
34196
34209
  defaultOpen: !1,
34197
34210
  persist: !0,
34198
34211
  onOpen: async () => {
34199
- p.current || (p.current = !0, await k(), await x());
34212
+ h.current || (h.current = !0, await j());
34200
34213
  }
34201
- }), N = MV([m.length, _]), { isListening: P, isSupported: F, startListening: ee, stopListening: te, reset: I } = NV({
34214
+ });
34215
+ f(() => {
34216
+ (async () => {
34217
+ h.current && M && !n && r && (await C(), h.current = !1);
34218
+ })();
34219
+ }, [
34220
+ M,
34221
+ n,
34222
+ r,
34223
+ C
34224
+ ]);
34225
+ let F = MV([g.length, b]), { isListening: ee, isSupported: te, startListening: I, stopListening: L, reset: R } = NV({
34202
34226
  lang: PV(),
34203
34227
  continuous: !0,
34204
34228
  pauseOnSubmit: !0,
34205
- onTextChange: g
34206
- }), { panelResizableWidth: L } = $V(e, r, A), { handleSubmit: R, handleToggleVoice: ne, handleClose: re } = eH({
34207
- isListening: P,
34208
- stopListening: te,
34209
- reset: I,
34210
- sendMessage: b,
34211
- composerText: h,
34212
- setComposerText: g,
34213
- startListening: ee,
34214
- close: M
34215
- });
34216
- return /* @__PURE__ */ E(w, { children: [!A && /* @__PURE__ */ T(MP, {
34217
- onClick: () => void j(),
34218
- zIndex: s,
34219
- position: c,
34220
- label: l
34221
- }), A && /* @__PURE__ */ T(EP, {
34229
+ onTextChange: y
34230
+ }), { panelResizableWidth: ne } = eH(e, i, M), { handleSubmit: re, handleToggleVoice: ie, handleClose: ae } = tH({
34231
+ isListening: ee,
34232
+ stopListening: L,
34233
+ reset: R,
34234
+ sendMessage: S,
34235
+ composerText: _,
34236
+ setComposerText: y,
34237
+ startListening: I,
34238
+ close: P
34239
+ });
34240
+ return /* @__PURE__ */ E(w, { children: [!M && /* @__PURE__ */ T(MP, {
34241
+ onClick: () => void N(),
34242
+ zIndex: c,
34243
+ position: l,
34244
+ label: u
34245
+ }), M && /* @__PURE__ */ T(EP, {
34222
34246
  visible: !0,
34223
- onClose: re,
34224
- messages: m,
34225
- composerText: h,
34226
- onComposerTextChange: g,
34227
- isLoading: _,
34228
- error: y,
34229
- canSend: S,
34230
- onSubmit: R,
34231
- actions: C,
34232
- onActionClick: D,
34233
- isListening: P,
34234
- isVoiceSupported: F,
34235
- onToggleVoice: ne,
34236
- panelTitle: u,
34237
- runtimeInfo: O,
34238
- scrollViewportRef: N,
34239
- panelWidth: r,
34240
- panelHeight: i,
34241
- panelHeaderHeight: a,
34242
- panelResizableWidth: L,
34243
- zIndex: s,
34244
- panelTopOffset: o
34247
+ onClose: ae,
34248
+ messages: g,
34249
+ composerText: _,
34250
+ onComposerTextChange: y,
34251
+ isLoading: b,
34252
+ error: x,
34253
+ canSend: D,
34254
+ onSubmit: re,
34255
+ actions: O,
34256
+ onActionClick: k,
34257
+ isListening: ee,
34258
+ isVoiceSupported: te,
34259
+ onToggleVoice: ie,
34260
+ panelTitle: p,
34261
+ runtimeInfo: A,
34262
+ scrollViewportRef: F,
34263
+ panelWidth: i,
34264
+ panelHeight: a,
34265
+ panelHeaderHeight: o,
34266
+ panelResizableWidth: ne,
34267
+ zIndex: c,
34268
+ panelTopOffset: s
34245
34269
  })] });
34246
34270
  }
34247
34271
  //#endregion
34248
34272
  //#region src/providers/AgentChatProviders.tsx
34249
- function sH({ runtime: e, children: t }) {
34273
+ function cH({ runtime: e, children: t }) {
34250
34274
  return /* @__PURE__ */ T(GP.Provider, {
34251
34275
  value: e,
34252
34276
  children: t
34253
34277
  });
34254
34278
  }
34255
- function cH({ config: e, children: t }) {
34279
+ function lH({ config: e, children: t }) {
34256
34280
  return /* @__PURE__ */ T(qP.Provider, {
34257
34281
  value: e,
34258
34282
  children: t
@@ -34260,10 +34284,10 @@ function cH({ config: e, children: t }) {
34260
34284
  }
34261
34285
  //#endregion
34262
34286
  //#region src/providers/ConfigProvider.tsx
34263
- var lH = ({ children: e, config: t }) => /* @__PURE__ */ T(FV.Provider, {
34287
+ var uH = ({ children: e, config: t }) => /* @__PURE__ */ T(FV.Provider, {
34264
34288
  value: t,
34265
34289
  children: e
34266
- }), uH = {
34290
+ }), dH = {
34267
34291
  url: {
34268
34292
  app: "http://localhost:4201",
34269
34293
  api: "https://cognitus-etiyacell.etiyacloud.com",
@@ -34309,12 +34333,12 @@ var lH = ({ children: e, config: t }) => /* @__PURE__ */ T(FV.Provider, {
34309
34333
  tenantId: 54
34310
34334
  }
34311
34335
  }
34312
- }, dH = null;
34313
- function fH() {
34314
- return dH;
34336
+ }, fH = null;
34337
+ function pH() {
34338
+ return fH;
34315
34339
  }
34316
- function pH(e) {
34317
- let t = uH.genai?.init;
34340
+ function mH(e) {
34341
+ let t = dH.genai?.init;
34318
34342
  return !t || e.genai?.init ? e : {
34319
34343
  ...e,
34320
34344
  genai: {
@@ -34323,22 +34347,22 @@ function pH(e) {
34323
34347
  }
34324
34348
  };
34325
34349
  }
34326
- async function mH(e) {
34350
+ async function hH(e) {
34327
34351
  let t = `${(globalThis.__BASE_URL__ ?? "").replace(/\/$/, "")}/environment.json`, n = e ?? t;
34328
34352
  try {
34329
34353
  let e = await fetch(n);
34330
- if (!e.ok) return dH = uH, uH;
34331
- let t = pH(await e.json());
34332
- return dH = t, t;
34354
+ if (!e.ok) return fH = dH, dH;
34355
+ let t = mH(await e.json());
34356
+ return fH = t, t;
34333
34357
  } catch {
34334
- return dH = uH, uH;
34358
+ return fH = dH, dH;
34335
34359
  }
34336
34360
  }
34337
34361
  //#endregion
34338
34362
  //#region src/lib/agent-widget.tsx
34339
- function hH({ config: e, runtime: t, theme: n }) {
34363
+ function gH({ config: e, runtime: t, theme: n }) {
34340
34364
  pI.locale || pI.activate("en");
34341
- let r = aH(n?.accentColor), i = fH();
34365
+ let r = oH(n?.accentColor), i = pH();
34342
34366
  return i ? /* @__PURE__ */ T(HO, {
34343
34367
  i18n: pI,
34344
34368
  children: /* @__PURE__ */ T(Gn, {
@@ -34346,13 +34370,13 @@ function hH({ config: e, runtime: t, theme: n }) {
34346
34370
  defaultColorScheme: "auto",
34347
34371
  children: /* @__PURE__ */ T(qL, {
34348
34372
  client: pV,
34349
- children: /* @__PURE__ */ T(lH, {
34373
+ children: /* @__PURE__ */ T(uH, {
34350
34374
  config: i,
34351
- children: /* @__PURE__ */ T(cH, {
34375
+ children: /* @__PURE__ */ T(lH, {
34352
34376
  config: e,
34353
- children: /* @__PURE__ */ T(sH, {
34377
+ children: /* @__PURE__ */ T(cH, {
34354
34378
  runtime: t,
34355
- children: /* @__PURE__ */ T(oH, { ...n ?? {} })
34379
+ children: /* @__PURE__ */ T(sH, { ...n ?? {} })
34356
34380
  })
34357
34381
  })
34358
34382
  })
@@ -34362,22 +34386,22 @@ function hH({ config: e, runtime: t, theme: n }) {
34362
34386
  }
34363
34387
  //#endregion
34364
34388
  //#region src/lib/mount-widget.tsx
34365
- var gH = /* @__PURE__ */ new WeakMap();
34366
- async function _H(e, t, n) {
34389
+ var _H = /* @__PURE__ */ new WeakMap();
34390
+ async function vH(e, t, n) {
34367
34391
  try {
34368
- bV(await mH(n?.environmentUrl));
34392
+ bV(await hH(n?.environmentUrl));
34369
34393
  } catch (e) {
34370
34394
  throw console.error("Failed to initialize agent widget rest services:", e), e;
34371
34395
  }
34372
- let r = gH.get(e);
34396
+ let r = _H.get(e);
34373
34397
  r && r.unmount();
34374
34398
  let i = D(e);
34375
- return i.render(/* @__PURE__ */ T(hH, { ...t })), gH.set(e, i), () => {
34376
- let t = gH.get(e);
34377
- t && (t.unmount(), gH.delete(e));
34399
+ return i.render(/* @__PURE__ */ T(gH, { ...t })), _H.set(e, i), () => {
34400
+ let t = _H.get(e);
34401
+ t && (t.unmount(), _H.delete(e));
34378
34402
  };
34379
34403
  }
34380
- function vH(e) {
34404
+ function yH(e) {
34381
34405
  let t = e.genai?.config;
34382
34406
  if (!t?.assistantId) throw Error("GenAI config is missing in environment.json.");
34383
34407
  return {
@@ -34385,24 +34409,24 @@ function vH(e) {
34385
34409
  agents: t.agents
34386
34410
  };
34387
34411
  }
34388
- function yH(e, t) {
34412
+ function bH(e, t) {
34389
34413
  return t ? {
34390
34414
  assistantId: t.assistantId ?? e.assistantId,
34391
34415
  agents: t.agents ?? e.agents
34392
34416
  } : e;
34393
34417
  }
34394
- function bH(e, t) {
34418
+ function xH(e, t) {
34395
34419
  return t ? (e.genai ||= {}, e.genai.config || (e.genai.config = {}), typeof t.assistantId == "number" && (e.genai.config.assistantId = t.assistantId), t.agents && (e.genai.config.agents = t.agents), e) : e;
34396
34420
  }
34397
- async function xH(e, t) {
34398
- let n = bH(await mH(t.environmentUrl), t.config);
34399
- return bV(n), _H(e, {
34400
- config: yH(vH(n), t.config),
34421
+ async function SH(e, t) {
34422
+ let n = xH(await hH(t.environmentUrl), t.config);
34423
+ return bV(n), vH(e, {
34424
+ config: bH(yH(n), t.config),
34401
34425
  runtime: t.runtime,
34402
34426
  theme: t.theme
34403
34427
  });
34404
34428
  }
34405
34429
  //#endregion
34406
- export { hH as AgentChatWidget, _H as mountAgentChatWidget, xH as mountAgentChatWidgetFromEnvironment };
34430
+ export { gH as AgentChatWidget, vH as mountAgentChatWidget, SH as mountAgentChatWidgetFromEnvironment };
34407
34431
 
34408
34432
  //# sourceMappingURL=agent-widget.js.map