@salesforce/platform-sdk 9.11.0 → 9.12.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/index.js CHANGED
@@ -1,19 +1,19 @@
1
- import { buildServiceDescriptor as z, setHeader as _ } from "@conduit-client/service-fetch-network/v1";
2
- import { resolvedPromiseLike as w, ok as D, err as P, stableJSONStringify as ee, DataNotFoundError as te, UserVisibleError as se, deepFreeze as E, isUserVisibleError as re } from "@conduit-client/utils";
3
- import { print as R, parse as ne } from "@conduit-client/onestore-graphql-parser/v1";
4
- import { RetryPolicy as ie, buildServiceDescriptor as oe } from "@conduit-client/service-retry/v1";
5
- import { buildServiceDescriptor as ae } from "@conduit-client/service-cache/v1";
6
- import { buildServiceDescriptor as ce } from "@conduit-client/service-cache-control/v1";
7
- import { buildInMemoryCacheInclusionPolicyService as le } from "@conduit-client/service-cache-inclusion-policy/v1";
8
- import { buildServiceDescriptor as ue } from "@conduit-client/service-pubsub/v1";
9
- import { HttpCacheControlCommand as de } from "@conduit-client/command-http-cache-control/v1";
10
- import { encodeCoreEnvelopeContentsRaw as he } from "o11y/collectors";
11
- import { SimpleCollector as fe } from "o11y/simple_collector";
12
- import { registerInstrumentedApp as pe } from "o11y/client";
13
- import { analyticsContextSchema as ge, sessionSchema as me, pageViewSchema as ye, errorContextSchema as we, interactionSchema as be, customEventSchema as ve } from "o11y_schema/sf_mcpanalytics";
14
- var c = /* @__PURE__ */ ((s) => (s.WebApp = "WebApp", s.MicroFrontend = "Micro-Frontend", s.OpenAI = "OpenAI", s.SalesforceACC = "Salesforce-ACC", s.MCPApps = "MCP-Apps", s.Mosaic = "Mosaic", s))(c || {});
15
- const Ce = Se();
16
- function Se() {
1
+ import { buildServiceDescriptor as G, setHeader as E } from "@conduit-client/service-fetch-network/v1";
2
+ import { resolvedPromiseLike as b, ok as P, err as L, stableJSONStringify as ne, DataNotFoundError as ie, UserVisibleError as oe, deepFreeze as I, isUserVisibleError as ae } from "@conduit-client/utils";
3
+ import { print as O, parse as ce } from "@conduit-client/onestore-graphql-parser/v1";
4
+ import { RetryPolicy as le, buildServiceDescriptor as ue } from "@conduit-client/service-retry/v1";
5
+ import { buildServiceDescriptor as de } from "@conduit-client/service-cache/v1";
6
+ import { buildServiceDescriptor as he } from "@conduit-client/service-cache-control/v1";
7
+ import { buildInMemoryCacheInclusionPolicyService as fe } from "@conduit-client/service-cache-inclusion-policy/v1";
8
+ import { buildServiceDescriptor as pe } from "@conduit-client/service-pubsub/v1";
9
+ import { HttpCacheControlCommand as ge } from "@conduit-client/command-http-cache-control/v1";
10
+ import { encodeCoreEnvelopeContentsRaw as me } from "o11y/collectors";
11
+ import { SimpleCollector as ye } from "o11y/simple_collector";
12
+ import { registerInstrumentedApp as we } from "o11y/client";
13
+ import { analyticsContextSchema as be, sessionSchema as ve, pageViewSchema as Ce, errorContextSchema as Se, interactionSchema as Te, customEventSchema as _e } from "o11y_schema/sf_mcpanalytics";
14
+ var a = /* @__PURE__ */ ((s) => (s.WebApp = "WebApp", s.MicroFrontend = "Micro-Frontend", s.OpenAI = "OpenAI", s.SalesforceACC = "Salesforce-ACC", s.MCPApps = "MCP-Apps", s.Mosaic = "Mosaic", s))(a || {});
15
+ const Ee = Ie();
16
+ function Ie() {
17
17
  if (typeof window > "u")
18
18
  return "Mosaic";
19
19
  if (window.openai)
@@ -27,28 +27,28 @@ function Se() {
27
27
  const s = window;
28
28
  return s.$A || s.Aura ? "Salesforce-ACC" : "WebApp";
29
29
  }
30
- function C(s) {
31
- return s ?? Ce;
30
+ function S(s) {
31
+ return s ?? Ee;
32
32
  }
33
33
  function A(s) {
34
34
  return typeof s == "object" && s !== null && "jsonrpc" in s && s.jsonrpc === "2.0";
35
35
  }
36
- function Te(s) {
36
+ function Me(s) {
37
37
  return A(s) && "id" in s && typeof s.id == "number" && "result" in s;
38
38
  }
39
- function j(s) {
39
+ function X(s) {
40
40
  return A(s) && "id" in s && typeof s.id == "number" && "error" in s;
41
41
  }
42
- function _e(s) {
43
- return Te(s) || j(s);
42
+ function Ae(s) {
43
+ return Me(s) || X(s);
44
44
  }
45
- function Ee(s) {
45
+ function ke(s) {
46
46
  return A(s) && "method" in s && typeof s.method == "string" && !("id" in s);
47
47
  }
48
- function ns(s) {
48
+ function us(s) {
49
49
  return A(s) && "id" in s && typeof s.id == "number" && "method" in s && typeof s.method == "string";
50
50
  }
51
- class Me {
51
+ class De {
52
52
  targetOrigin;
53
53
  /**
54
54
  * @param targetOrigin - origin passed as the second argument to
@@ -69,7 +69,7 @@ class Me {
69
69
  return window.addEventListener("message", t), () => window.removeEventListener("message", t);
70
70
  }
71
71
  }
72
- class Ae {
72
+ class Pe {
73
73
  nextRequestId = 1;
74
74
  pending = /* @__PURE__ */ new Map();
75
75
  notificationHandlers = /* @__PURE__ */ new Map();
@@ -81,7 +81,7 @@ class Ae {
81
81
  * `WindowPostMessageTransport`, which preserves the original
82
82
  * `window.parent.postMessage` behaviour.
83
83
  */
84
- constructor(e = new Me()) {
84
+ constructor(e = new De()) {
85
85
  this.transport = e, this.transport.onMessage(this.onMessage);
86
86
  }
87
87
  /**
@@ -110,14 +110,14 @@ class Ae {
110
110
  * multiple protocols without cross-talk.
111
111
  */
112
112
  onMessage = (e) => {
113
- if (_e(e)) {
113
+ if (Ae(e)) {
114
114
  const t = this.pending.get(e.id);
115
115
  if (!t)
116
116
  return;
117
- this.pending.delete(e.id), j(e) ? t.reject(new Error(e.error.message || "Request failed")) : t.resolve(e.result);
117
+ this.pending.delete(e.id), X(e) ? t.reject(new Error(e.error.message || "Request failed")) : t.resolve(e.result);
118
118
  return;
119
119
  }
120
- if (Ee(e)) {
120
+ if (ke(e)) {
121
121
  const t = this.notificationHandlers.get(e.method);
122
122
  t && t.forEach((r) => r(e.params));
123
123
  }
@@ -181,9 +181,9 @@ class Ae {
181
181
  this.transport.post(r);
182
182
  }
183
183
  }
184
- function Ie() {
184
+ function Le() {
185
185
  }
186
- class is {
186
+ class ds {
187
187
  #e;
188
188
  #s = /* @__PURE__ */ new Set();
189
189
  #n = !1;
@@ -225,7 +225,7 @@ class is {
225
225
  */
226
226
  onMessage(e) {
227
227
  if (this.#r)
228
- return Ie;
228
+ return Le;
229
229
  this.#s.add(e), this.#n || this.#o();
230
230
  let t = !1;
231
231
  return () => {
@@ -279,8 +279,8 @@ class is {
279
279
  }
280
280
  };
281
281
  }
282
- const ke = 500, De = "2026-01-26";
283
- class y extends Ae {
282
+ const xe = 500, Re = "2026-01-26";
283
+ class w extends Pe {
284
284
  static initPromise = null;
285
285
  hostCtx = {};
286
286
  _handshakeSucceeded = !1;
@@ -291,17 +291,17 @@ class y extends Ae {
291
291
  * calls reuse the same session and handshake result.
292
292
  */
293
293
  static async getInstance(e) {
294
- return y.initPromise || (y.initPromise = (async () => {
295
- const t = new y();
294
+ return w.initPromise || (w.initPromise = (async () => {
295
+ const t = new w();
296
296
  return await t.handshake(e), t;
297
- })()), y.initPromise;
297
+ })()), w.initPromise;
298
298
  }
299
299
  /**
300
300
  * Reset the singleton (for testing only).
301
301
  * @internal
302
302
  */
303
303
  static resetInstance() {
304
- y.initPromise = null;
304
+ w.initPromise = null;
305
305
  }
306
306
  /**
307
307
  * Perform the ui/initialize → hostContext → ui/notifications/initialized handshake.
@@ -311,11 +311,11 @@ class y extends Ae {
311
311
  * still render (graceful degradation for non-SEP-1865 hosts).
312
312
  */
313
313
  async handshake(e) {
314
- const t = e?.handshakeTimeoutMs ?? ke, r = e?.appInfo ?? { name: "mcp-app", version: "1.0.0" };
314
+ const t = e?.handshakeTimeoutMs ?? xe, r = e?.appInfo ?? { name: "mcp-app", version: "1.0.0" };
315
315
  try {
316
316
  const n = /* @__PURE__ */ Symbol("timeout"), i = await Promise.race([
317
317
  this.request("ui/initialize", {
318
- protocolVersion: De,
318
+ protocolVersion: Re,
319
319
  appInfo: r,
320
320
  appCapabilities: {}
321
321
  }),
@@ -351,7 +351,7 @@ class y extends Ae {
351
351
  super.registerNotificationHandler(e, t);
352
352
  }
353
353
  }
354
- const Pe = {
354
+ const Oe = {
355
355
  callTool: !0,
356
356
  sendMessageToHost: !0,
357
357
  readResource: !0,
@@ -372,7 +372,7 @@ const Pe = {
372
372
  // TODO
373
373
  getTheme: !0,
374
374
  resize: !0
375
- }, Le = {
375
+ }, He = {
376
376
  callTool: !0,
377
377
  sendMessageToHost: !0,
378
378
  readResource: !1,
@@ -392,7 +392,7 @@ const Pe = {
392
392
  displayModal: !0,
393
393
  getTheme: !0,
394
394
  resize: !1
395
- }, xe = {
395
+ }, qe = {
396
396
  callTool: !1,
397
397
  sendMessageToHost: !0,
398
398
  readResource: !1,
@@ -412,7 +412,7 @@ const Pe = {
412
412
  displayModal: !1,
413
413
  getTheme: !0,
414
414
  resize: !1
415
- }, Re = {
415
+ }, Ne = {
416
416
  callTool: !1,
417
417
  sendMessageToHost: !1,
418
418
  readResource: !1,
@@ -433,26 +433,26 @@ const Pe = {
433
433
  getTheme: !1,
434
434
  resize: !1
435
435
  };
436
- function os(s) {
436
+ function hs(s) {
437
437
  switch (s) {
438
- case c.MCPApps:
439
- return { ...Pe };
440
- case c.OpenAI:
441
- return { ...Le };
442
- case c.SalesforceACC:
443
- return { ...xe };
444
- case c.Mosaic:
445
- case c.WebApp:
446
- case c.MicroFrontend:
438
+ case a.MCPApps:
439
+ return { ...Oe };
440
+ case a.OpenAI:
441
+ return { ...He };
442
+ case a.SalesforceACC:
443
+ return { ...qe };
444
+ case a.Mosaic:
445
+ case a.WebApp:
446
+ case a.MicroFrontend:
447
447
  default:
448
- return { ...Re };
448
+ return { ...Ne };
449
449
  }
450
450
  }
451
- const Oe = /* @__PURE__ */ new Set(["then", "catch", "finally"]);
452
- function I(s, e) {
451
+ const Fe = /* @__PURE__ */ new Set(["then", "catch", "finally"]);
452
+ function k(s, e) {
453
453
  return new Proxy(s, {
454
454
  get(t, r, n) {
455
- if (typeof r == "symbol" || Oe.has(r)) {
455
+ if (typeof r == "symbol" || Fe.has(r)) {
456
456
  const i = Reflect.get(t, r, n);
457
457
  return typeof i == "function" ? i.bind(t) : i;
458
458
  }
@@ -463,7 +463,7 @@ Use \`const sdk = await ${e}();\` before accessing SDK methods.`
463
463
  }
464
464
  });
465
465
  }
466
- class He {
466
+ class Ue {
467
467
  constructor(e) {
468
468
  this.session = e;
469
469
  const t = e.getHostContext();
@@ -599,8 +599,8 @@ class He {
599
599
  this.subscriptions.forEach((e) => e());
600
600
  }
601
601
  }
602
- const F = "openai:set_globals";
603
- class qe {
602
+ const U = "openai:set_globals";
603
+ class Ve {
604
604
  sendMessageToHost(e) {
605
605
  return window.openai.sendFollowUpMessage({ prompt: e.content });
606
606
  }
@@ -635,12 +635,12 @@ class qe {
635
635
  }
636
636
  subscribe(e) {
637
637
  const t = () => e();
638
- return window.addEventListener(F, t), () => {
639
- window.removeEventListener(F, t);
638
+ return window.addEventListener(U, t), () => {
639
+ window.removeEventListener(U, t);
640
640
  };
641
641
  }
642
642
  }
643
- class Ne {
643
+ class $e {
644
644
  async sendMessageToHost(e) {
645
645
  throw console.warn("SalesforceACCChatSDK.sendMessageToHost: stub implementation", e), new Error("SalesforceACCChatSDK.sendMessageToHost not yet implemented");
646
646
  }
@@ -648,31 +648,31 @@ class Ne {
648
648
  return console.warn("SalesforceACCChatSDK.followUpActions: stub implementation"), [];
649
649
  }
650
650
  }
651
- let S = null, O = null;
652
- function Fe(s) {
653
- return S || (S = Ue(s).then((e) => (O = e, e))), S;
651
+ let T = null, H = null;
652
+ function We(s) {
653
+ return T || (T = Ke(s).then((e) => (H = e, e))), T;
654
654
  }
655
- function as() {
656
- return O;
655
+ function fs() {
656
+ return H;
657
657
  }
658
- function cs() {
659
- S = null, O = null;
658
+ function ps() {
659
+ T = null, H = null;
660
660
  }
661
- function Ue(s) {
662
- return I(
661
+ function Ke(s) {
662
+ return k(
663
663
  (async () => {
664
- switch (C(s?.surface)) {
665
- case c.OpenAI:
666
- return new qe();
667
- case c.WebApp:
668
- case c.Mosaic:
664
+ switch (S(s?.surface)) {
665
+ case a.OpenAI:
666
+ return new Ve();
667
+ case a.WebApp:
668
+ case a.Mosaic:
669
669
  return {};
670
- case c.SalesforceACC:
671
- return new Ne();
672
- case c.MicroFrontend:
673
- case c.MCPApps: {
674
- const t = await y.getInstance(s?.mcpApps);
675
- return t.handshakeSucceeded ? new He(t) : {};
670
+ case a.SalesforceACC:
671
+ return new $e();
672
+ case a.MicroFrontend:
673
+ case a.MCPApps: {
674
+ const t = await w.getInstance(s?.mcpApps);
675
+ return t.handshakeSucceeded ? new Ue(t) : {};
676
676
  }
677
677
  default:
678
678
  return {};
@@ -681,7 +681,7 @@ function Ue(s) {
681
681
  "createChatSDK"
682
682
  );
683
683
  }
684
- function Ve(s) {
684
+ function ze(s) {
685
685
  switch (s) {
686
686
  case "info":
687
687
  return "ℹ️";
@@ -695,10 +695,10 @@ function Ve(s) {
695
695
  return "ℹ️";
696
696
  }
697
697
  }
698
- function L(s, e) {
699
- return `${Ve(e)} ${s}`;
698
+ function x(s, e) {
699
+ return `${ze(e)} ${s}`;
700
700
  }
701
- function U(s, e) {
701
+ function V(s, e) {
702
702
  const t = s.trim();
703
703
  if (t === "")
704
704
  return { success: !0, value: void 0 };
@@ -714,7 +714,7 @@ function U(s, e) {
714
714
  error: `Invalid ${e}: "${s}". Value must be a positive number.`
715
715
  } : { success: !0, value: n };
716
716
  }
717
- class We {
717
+ class Be {
718
718
  constructor(e) {
719
719
  this.session = e;
720
720
  }
@@ -724,7 +724,7 @@ class We {
724
724
  * @param level - The message severity level (defaults to "info")
725
725
  */
726
726
  async sendMessage(e, t = "info") {
727
- const r = L(e, t);
727
+ const r = x(e, t);
728
728
  await this.session.request("ui/message", {
729
729
  role: "user",
730
730
  content: [
@@ -749,23 +749,23 @@ class We {
749
749
  return e ? { mode: e } : null;
750
750
  }
751
751
  async resize(e, t) {
752
- const r = U(e, "width");
752
+ const r = V(e, "width");
753
753
  if (!r.success)
754
754
  return Promise.reject(new Error(r.error));
755
- const n = U(t, "height");
755
+ const n = V(t, "height");
756
756
  if (!n.success)
757
757
  return Promise.reject(new Error(n.error));
758
758
  const i = {};
759
759
  return r.value !== void 0 && (i.width = r.value), n.value !== void 0 && (i.height = n.value), this.session.sendNotification("ui/notifications/size-changed", i), Promise.resolve();
760
760
  }
761
761
  }
762
- class $e {
762
+ class je {
763
763
  async displayAlert(e) {
764
- const t = e.level || "info", r = L(e.message, t);
764
+ const t = e.level || "info", r = x(e.message, t);
765
765
  await window.openai.sendFollowUpMessage({ prompt: r });
766
766
  }
767
767
  async displayToast(e) {
768
- const t = e.level || "info", r = L(e.message, t);
768
+ const t = e.level || "info", r = x(e.message, t);
769
769
  await window.openai.sendFollowUpMessage({ prompt: r });
770
770
  }
771
771
  async displayModal(e) {
@@ -779,31 +779,31 @@ class $e {
779
779
  return e ? { mode: e } : null;
780
780
  }
781
781
  }
782
- let T = null, H = null;
783
- function ls(s) {
784
- return T || (T = Ke(s).then((e) => (H = e, e))), T;
782
+ let _ = null, q = null;
783
+ function gs(s) {
784
+ return _ || (_ = Je(s).then((e) => (q = e, e))), _;
785
785
  }
786
- function us() {
787
- return H;
786
+ function ms() {
787
+ return q;
788
788
  }
789
- function ds() {
790
- T = null, H = null;
789
+ function ys() {
790
+ _ = null, q = null;
791
791
  }
792
- function Ke(s) {
793
- return I(
792
+ function Je(s) {
793
+ return k(
794
794
  (async () => {
795
- switch (C(s?.surface)) {
796
- case c.OpenAI:
797
- return new $e();
798
- case c.WebApp:
799
- case c.Mosaic:
795
+ switch (S(s?.surface)) {
796
+ case a.OpenAI:
797
+ return new je();
798
+ case a.WebApp:
799
+ case a.Mosaic:
800
800
  return {};
801
- case c.SalesforceACC:
801
+ case a.SalesforceACC:
802
802
  return {};
803
- case c.MicroFrontend:
804
- case c.MCPApps: {
805
- const t = await y.getInstance(s?.mcpApps);
806
- return t.handshakeSucceeded ? new We(t) : {};
803
+ case a.MicroFrontend:
804
+ case a.MCPApps: {
805
+ const t = await w.getInstance(s?.mcpApps);
806
+ return t.handshakeSucceeded ? new Be(t) : {};
807
807
  }
808
808
  default:
809
809
  return {};
@@ -812,42 +812,42 @@ function Ke(s) {
812
812
  "createViewSDK"
813
813
  );
814
814
  }
815
- function Be(s) {
815
+ function Qe(s) {
816
816
  return (e) => {
817
817
  const [t, r] = e;
818
818
  if (typeof t == "string" && !t.startsWith("http")) {
819
819
  const n = t.startsWith("/") ? t : `/${t}`;
820
- return w([`${s}${n}`, r]);
820
+ return b([`${s}${n}`, r]);
821
821
  }
822
- return w(e);
822
+ return b(e);
823
823
  };
824
824
  }
825
- function ze(s) {
826
- return (e) => w(_("Authorization", `Bearer ${s}`, e));
825
+ function Ge(s) {
826
+ return (e) => b(E("Authorization", `Bearer ${s}`, e));
827
827
  }
828
- function je(s, e) {
828
+ function Xe(s, e) {
829
829
  const t = [];
830
- return s && t.push(Be(s)), e && t.push(ze(e)), z({
830
+ return s && t.push(Qe(s)), e && t.push(Ge(e)), G({
831
831
  request: t
832
832
  }).service;
833
833
  }
834
834
  const M = () => {
835
- }, x = async () => {
835
+ }, R = async () => {
836
836
  };
837
- function q(s) {
837
+ function N(s) {
838
838
  try {
839
- return D(ne(s));
839
+ return P(ce(s));
840
840
  } catch (e) {
841
- return P(b(e));
841
+ return L(v(e));
842
842
  }
843
843
  }
844
- function N(s, e) {
844
+ function F(s, e) {
845
845
  const t = s.definitions.filter(
846
846
  (r) => r.kind === "OperationDefinition"
847
847
  );
848
848
  return t.length === 0 ? "unknown" : t.length === 1 ? e === void 0 || t[0].name?.value === e ? t[0].operation : "unknown" : e === void 0 ? "unknown" : t.find((r) => r.name?.value === e)?.operation ?? "unknown";
849
849
  }
850
- function b(s) {
850
+ function v(s) {
851
851
  if (s && typeof s == "object" && "data" in s) {
852
852
  const e = s.data;
853
853
  if (e && typeof e == "object" && "errors" in e && Array.isArray(e.errors))
@@ -855,10 +855,10 @@ function b(s) {
855
855
  }
856
856
  return s instanceof Error ? [{ message: s.message }] : typeof s == "string" ? [{ message: s }] : [{ message: "Unknown error" }];
857
857
  }
858
- async function Q(s, { mutation: e, variables: t, operationName: r }) {
859
- const n = q(e);
858
+ async function Y(s, { mutation: e, variables: t, operationName: r }) {
859
+ const n = N(e);
860
860
  if (n.isErr()) return { data: void 0, errors: n.error };
861
- const i = n.value, o = N(i, r);
861
+ const i = n.value, o = F(i, r);
862
862
  if (o !== "mutation")
863
863
  return {
864
864
  data: void 0,
@@ -869,23 +869,23 @@ async function Q(s, { mutation: e, variables: t, operationName: r }) {
869
869
  ]
870
870
  };
871
871
  try {
872
- const a = await s({
873
- query: R(i),
872
+ const c = await s({
873
+ query: O(i),
874
874
  variables: t,
875
875
  operationName: r
876
876
  });
877
877
  return {
878
- data: a.data ?? void 0,
879
- errors: a.errors
878
+ data: c.data ?? void 0,
879
+ errors: c.errors
880
880
  };
881
- } catch (a) {
882
- return { data: void 0, errors: b(a) };
881
+ } catch (c) {
882
+ return { data: void 0, errors: v(c) };
883
883
  }
884
884
  }
885
- function G(s) {
885
+ function Z(s) {
886
886
  function e(r, n, i) {
887
887
  return s({
888
- query: R(r),
888
+ query: O(r),
889
889
  variables: n,
890
890
  operationName: i
891
891
  }).then(
@@ -893,7 +893,7 @@ function G(s) {
893
893
  data: o.data ?? void 0,
894
894
  errors: o.errors
895
895
  }),
896
- (o) => ({ data: void 0, errors: b(o) })
896
+ (o) => ({ data: void 0, errors: v(o) })
897
897
  );
898
898
  }
899
899
  async function t({
@@ -901,57 +901,57 @@ function G(s) {
901
901
  variables: n,
902
902
  operationName: i
903
903
  }) {
904
- const o = q(r);
904
+ const o = N(r);
905
905
  if (o.isErr())
906
906
  return {
907
907
  data: void 0,
908
908
  errors: o.error,
909
909
  subscribe: () => M,
910
- refresh: x
910
+ refresh: R
911
911
  };
912
- const a = o.value, h = N(a, i);
913
- if (h !== "query")
912
+ const c = o.value, l = F(c, i);
913
+ if (l !== "query")
914
914
  return {
915
915
  data: void 0,
916
916
  errors: [
917
917
  {
918
- message: `DataSDK.graphql.query() requires a GraphQL query, received ${h}.`
918
+ message: `DataSDK.graphql.query() requires a GraphQL query, received ${l}.`
919
919
  }
920
920
  ],
921
921
  subscribe: () => M,
922
- refresh: x
922
+ refresh: R
923
923
  };
924
- const d = /* @__PURE__ */ new Set(), p = n, f = await e(a, p, i);
924
+ const d = /* @__PURE__ */ new Set(), g = n, f = await e(c, g, i);
925
925
  return {
926
926
  data: f.data,
927
927
  errors: f.errors,
928
- subscribe(l) {
929
- return d.add(l), () => {
930
- d.delete(l);
928
+ subscribe(h) {
929
+ return d.add(h), () => {
930
+ d.delete(h);
931
931
  };
932
932
  },
933
933
  async refresh() {
934
- const l = await e(a, p, i);
935
- for (const u of d) u(l);
934
+ const h = await e(c, g, i);
935
+ for (const p of d) p(h);
936
936
  }
937
937
  };
938
938
  }
939
939
  return {
940
940
  query: t,
941
- mutate: (r) => Q(s, r)
941
+ mutate: (r) => Y(s, r)
942
942
  };
943
943
  }
944
- const Qe = typeof __SF_API_VERSION__ < "u" ? __SF_API_VERSION__ : "65.0";
945
- function J(s = Qe) {
944
+ const Ye = typeof __SF_API_VERSION__ < "u" ? __SF_API_VERSION__ : "65.0";
945
+ function ee(s = Ye) {
946
946
  return `/services/data/v${s}`;
947
947
  }
948
- class Ge {
948
+ class Ze {
949
949
  clientFetch;
950
950
  pathData;
951
951
  graphql;
952
952
  constructor(e) {
953
- const t = Je(), r = Xe(e?.instanceUrl ?? t.instanceUrl), n = e?.accessToken ?? t.accessToken;
954
- this.pathData = J(e?.apiVersion ?? t.apiVersion), this.clientFetch = je(r || void 0, n), this.graphql = G(this.executeRawGraphQL.bind(this));
953
+ const t = et(), r = tt(e?.instanceUrl ?? t.instanceUrl), n = e?.accessToken ?? t.accessToken;
954
+ this.pathData = ee(e?.apiVersion ?? t.apiVersion), this.clientFetch = Xe(r || void 0, n), this.graphql = Z(this.executeRawGraphQL.bind(this));
955
955
  }
956
956
  async executeRawGraphQL({
957
957
  query: e,
@@ -968,7 +968,7 @@ class Ge {
968
968
  })).json();
969
969
  }
970
970
  }
971
- function Je() {
971
+ function et() {
972
972
  const s = globalThis.MOSAIC_ENV;
973
973
  return {
974
974
  instanceUrl: s?.instanceUrl,
@@ -976,62 +976,62 @@ function Je() {
976
976
  apiVersion: s?.apiVersion
977
977
  };
978
978
  }
979
- function Xe(s) {
979
+ function tt(s) {
980
980
  if (!s || s === "/") return "";
981
981
  let e = s;
982
982
  return !e.startsWith("/") && !e.startsWith("http") && (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
983
983
  }
984
- const Ye = "graphqlQuery";
985
- class Ze {
984
+ const st = "graphqlQuery";
985
+ class rt {
986
986
  graphql;
987
987
  constructor() {
988
- this.graphql = G(this.executeRawGraphQL.bind(this));
988
+ this.graphql = Z(this.executeRawGraphQL.bind(this));
989
989
  }
990
990
  async executeRawGraphQL({
991
991
  query: e,
992
992
  variables: t,
993
993
  operationName: r
994
994
  }) {
995
- return (await window.openai.callTool(Ye, {
995
+ return (await window.openai.callTool(st, {
996
996
  query: e,
997
997
  ...t != null ? { variables: t } : {},
998
998
  ...r != null ? { operationName: r } : {}
999
999
  })).structuredContent;
1000
1000
  }
1001
1001
  }
1002
- const et = "X-SFDC-Client-Name", tt = "X-SFDC-Client-Version", st = "@salesforce/platform-sdk", rt = "9.11.0", nt = (s) => {
1003
- let e = _(et, st, s);
1004
- return e = _(tt, rt, e), w(e);
1005
- }, it = "X-CSRF-Token";
1006
- function ot(s, e = {}) {
1002
+ const nt = "X-SFDC-Client-Name", it = "X-SFDC-Client-Version", ot = "@salesforce/platform-sdk", at = "9.12.1", ct = (s) => {
1003
+ let e = E(nt, ot, s);
1004
+ return e = E(it, at, e), b(e);
1005
+ }, lt = "X-CSRF-Token";
1006
+ function ut(s, e = {}) {
1007
1007
  const { protectedUrls: t = [], alwaysProtectedUrls: r = [] } = e;
1008
1008
  return async (n) => {
1009
- const [i, o] = n, a = new Request(i, o);
1010
- if (V(r, a.url) || at(a.method) && V(t, a.url)) {
1009
+ const [i, o] = n, c = new Request(i, o);
1010
+ if ($(r, c.url) || dt(c.method) && $(t, c.url)) {
1011
1011
  const d = await s.getToken();
1012
- n = _(it, d, n);
1012
+ n = E(lt, d, n);
1013
1013
  }
1014
- return w(n);
1014
+ return b(n);
1015
1015
  };
1016
1016
  }
1017
- function at(s) {
1017
+ function dt(s) {
1018
1018
  const e = s.toLowerCase();
1019
1019
  return e === "post" || e === "put" || e === "patch" || e === "delete";
1020
1020
  }
1021
- function V(s, e) {
1021
+ function $(s, e) {
1022
1022
  const t = new URL(e);
1023
1023
  return s.some((r) => t.pathname.includes(r));
1024
1024
  }
1025
- function ct(s, e = {}) {
1026
- const t = ot(s, e);
1025
+ function ht(s, e = {}) {
1026
+ const t = ut(s, e);
1027
1027
  async function r(n) {
1028
1028
  const i = await t(n);
1029
1029
  return fetch(i[0], i[1]);
1030
1030
  }
1031
1031
  return (n, i) => i ? i.applyRetry(async () => r(n)) : r(n);
1032
1032
  }
1033
- const lt = [400, 401, 403];
1034
- class ut extends ie {
1033
+ const ft = [400, 401, 403];
1034
+ class pt extends le {
1035
1035
  constructor(e) {
1036
1036
  super(e), this.csrfTokenManager = e;
1037
1037
  }
@@ -1039,7 +1039,7 @@ class ut extends ie {
1039
1039
  * Determines if a failed request should be retried due to CSRF token issues.
1040
1040
  */
1041
1041
  async shouldRetry(e, t) {
1042
- return t.attempt >= 1 ? !1 : lt.includes(e.status);
1042
+ return t.attempt >= 1 ? !1 : ft.includes(e.status);
1043
1043
  }
1044
1044
  /**
1045
1045
  * CSRF token refresh should happen immediately with no delay.
@@ -1057,7 +1057,7 @@ class ut extends ie {
1057
1057
  await this.csrfTokenManager.refreshToken();
1058
1058
  }
1059
1059
  }
1060
- class dt {
1060
+ class gt {
1061
1061
  constructor(e, t) {
1062
1062
  this.endpoint = e, this.cacheName = t, this.tokenPromise = this.obtainToken();
1063
1063
  }
@@ -1106,28 +1106,28 @@ class dt {
1106
1106
  }
1107
1107
  }
1108
1108
  const W = /* @__PURE__ */ new Map();
1109
- function ht(s) {
1109
+ function mt(s) {
1110
1110
  const { endpoint: e, cacheName: t, ...r } = s.csrf;
1111
1111
  let n = W.get(e);
1112
- return n || (n = new dt(e, t), W.set(e, n)), z(
1112
+ return n || (n = new gt(e, t), W.set(e, n)), G(
1113
1113
  {
1114
- retry: ct(n, r),
1115
- request: [nt]
1114
+ retry: ht(n, r),
1115
+ request: [ct]
1116
1116
  },
1117
- oe(new ut(n)).service
1117
+ ue(new pt(n)).service
1118
1118
  ).service;
1119
1119
  }
1120
- const $ = /* @__PURE__ */ new Map();
1121
- function ft(s) {
1122
- let e = $.get(s);
1120
+ const K = /* @__PURE__ */ new Map();
1121
+ function yt(s) {
1122
+ let e = K.get(s);
1123
1123
  if (!e) {
1124
- const t = ae().service, r = le(t).service, n = ce(t, r).service, i = ue().service;
1125
- e = { cache: t, cacheController: n, pubSub: i }, $.set(s, e);
1124
+ const t = de().service, r = fe(t).service, n = he(t, r).service, i = pe().service;
1125
+ e = { cache: t, cacheController: n, pubSub: i }, K.set(s, e);
1126
1126
  }
1127
1127
  return e;
1128
1128
  }
1129
- function pt(s, e) {
1130
- const t = ft(s);
1129
+ function wt(s, e) {
1130
+ const t = yt(s);
1131
1131
  return {
1132
1132
  shared: t,
1133
1133
  services: {
@@ -1137,15 +1137,15 @@ function pt(s, e) {
1137
1137
  }
1138
1138
  };
1139
1139
  }
1140
- function X() {
1140
+ function te() {
1141
1141
  return {
1142
1142
  "Content-Type": "application/json",
1143
1143
  Accept: "application/json",
1144
1144
  "X-Chatter-Entity-Encoding": "false"
1145
1145
  };
1146
1146
  }
1147
- const K = 300;
1148
- function gt(s, e) {
1147
+ const z = 300;
1148
+ function bt(s, e) {
1149
1149
  try {
1150
1150
  return JSON.parse(JSON.stringify(s));
1151
1151
  } catch (t) {
@@ -1155,19 +1155,19 @@ function gt(s, e) {
1155
1155
  throw n.cause = t, n;
1156
1156
  }
1157
1157
  }
1158
- function mt(s) {
1158
+ function vt(s) {
1159
1159
  if (typeof s == "object" && s.type === "max-age") {
1160
1160
  const e = s.maxAge;
1161
- return Number.isFinite(e) && e >= 0 ? e : K;
1161
+ return Number.isFinite(e) && e >= 0 ? e : z;
1162
1162
  }
1163
- return K;
1163
+ return z;
1164
1164
  }
1165
- class yt extends de {
1165
+ class Ct extends ge {
1166
1166
  constructor(e, t, r) {
1167
- super(t), this.url = r, this.query = e.query, this.normalizedOperationName = e.operationName ?? "", this.normalizedVariables = gt(
1167
+ super(t), this.url = r, this.query = e.query, this.normalizedOperationName = e.operationName ?? "", this.normalizedVariables = bt(
1168
1168
  e.variables ?? {},
1169
1169
  this.normalizedOperationName
1170
- ), this.cacheControl = e.cacheControl, this.resolvedMaxAge = mt(e.cacheControl);
1170
+ ), this.cacheControl = e.cacheControl, this.resolvedMaxAge = vt(e.cacheControl);
1171
1171
  }
1172
1172
  query;
1173
1173
  normalizedVariables;
@@ -1179,7 +1179,7 @@ class yt extends de {
1179
1179
  this.url,
1180
1180
  {
1181
1181
  method: "POST",
1182
- headers: X(),
1182
+ headers: te(),
1183
1183
  body: JSON.stringify({
1184
1184
  query: this.query,
1185
1185
  variables: this.normalizedVariables,
@@ -1189,7 +1189,7 @@ class yt extends de {
1189
1189
  ];
1190
1190
  }
1191
1191
  buildKey() {
1192
- return ee({
1192
+ return ne({
1193
1193
  query: this.query,
1194
1194
  variables: this.normalizedVariables,
1195
1195
  operationName: this.normalizedOperationName
@@ -1210,7 +1210,7 @@ class yt extends de {
1210
1210
  */
1211
1211
  readFromCache(e) {
1212
1212
  const t = this.buildKey(), r = e.get(t)?.value;
1213
- return r === void 0 ? w(P(new te())) : w(D(r));
1213
+ return r === void 0 ? b(L(new ie())) : b(P(r));
1214
1214
  }
1215
1215
  writeToCache(e, t) {
1216
1216
  if (t.isOk() && t.value.data != null && Object.keys(t.value.data).length > 0) {
@@ -1226,7 +1226,7 @@ class yt extends de {
1226
1226
  }
1227
1227
  });
1228
1228
  }
1229
- return w(void 0);
1229
+ return b(void 0);
1230
1230
  }
1231
1231
  get cacheControlStrategyConfig() {
1232
1232
  const e = Math.floor(Date.now() / 1e3);
@@ -1240,55 +1240,55 @@ class yt extends de {
1240
1240
  return e.errors && e.errors.length > 0;
1241
1241
  }
1242
1242
  processFetchReturnValue(e) {
1243
- return this.responseHasErrors(e) ? P(new se(e)) : D(e);
1243
+ return this.responseHasErrors(e) ? L(new oe(e)) : P(e);
1244
1244
  }
1245
1245
  }
1246
- function Y(s) {
1247
- if (re(s) && s.data && typeof s.data == "object") {
1246
+ function se(s) {
1247
+ if (ae(s) && s.data && typeof s.data == "object") {
1248
1248
  const e = s.data;
1249
1249
  if (e.data != null)
1250
1250
  return e.data;
1251
1251
  }
1252
1252
  }
1253
- function wt(s) {
1253
+ function St(s) {
1254
1254
  return (e) => {
1255
1255
  if (e.isOk()) {
1256
1256
  const t = e.value;
1257
- E(t), s({ data: t, errors: void 0 });
1257
+ I(t), s({ data: t, errors: void 0 });
1258
1258
  } else {
1259
- const t = Y(e.error);
1260
- t && E(t), s({ data: t, errors: b(e.error) });
1259
+ const t = se(e.error);
1260
+ t && I(t), s({ data: t, errors: v(e.error) });
1261
1261
  }
1262
1262
  };
1263
1263
  }
1264
- async function bt(s) {
1264
+ async function Tt(s) {
1265
1265
  let e, t, r;
1266
1266
  try {
1267
1267
  const n = await s.execute();
1268
- n.isOk() ? (e = n.value.data, E(e), r = (i) => n.value.subscribe(i)) : (e = Y(n.error.failure), e && E(e), t = b(n.error.failure), r = (i) => n.error.subscribe(i));
1268
+ n.isOk() ? (e = n.value.data, I(e), r = (i) => n.value.subscribe(i)) : (e = se(n.error.failure), e && I(e), t = v(n.error.failure), r = (i) => n.error.subscribe(i));
1269
1269
  } catch (n) {
1270
- t = b(n);
1270
+ t = v(n);
1271
1271
  }
1272
1272
  return {
1273
1273
  data: e,
1274
1274
  errors: t,
1275
1275
  subscribe(n) {
1276
- return r ? r(wt(n)) : M;
1276
+ return r ? r(St(n)) : M;
1277
1277
  },
1278
1278
  async refresh() {
1279
1279
  await s.refresh();
1280
1280
  }
1281
1281
  };
1282
1282
  }
1283
- function k(s) {
1283
+ function D(s) {
1284
1284
  return {
1285
1285
  data: void 0,
1286
1286
  errors: s,
1287
1287
  subscribe: () => M,
1288
- refresh: x
1288
+ refresh: R
1289
1289
  };
1290
1290
  }
1291
- function vt({
1291
+ function _t({
1292
1292
  bundle: s,
1293
1293
  url: e,
1294
1294
  executeRaw: t
@@ -1297,58 +1297,58 @@ function vt({
1297
1297
  async function n({
1298
1298
  query: i,
1299
1299
  variables: o,
1300
- operationName: a,
1301
- cacheControl: h
1300
+ operationName: c,
1301
+ cacheControl: l
1302
1302
  }) {
1303
- const d = q(i);
1304
- if (d.isErr()) return k(d.error);
1305
- const p = d.value, f = N(p, a);
1303
+ const d = N(i);
1304
+ if (d.isErr()) return D(d.error);
1305
+ const g = d.value, f = F(g, c);
1306
1306
  if (f !== "query")
1307
- return k([
1307
+ return D([
1308
1308
  {
1309
1309
  message: `DataSDK.graphql.query() requires a GraphQL query, received ${f}.`
1310
1310
  }
1311
1311
  ]);
1312
- let l;
1312
+ let h;
1313
1313
  try {
1314
- l = new yt(
1314
+ h = new Ct(
1315
1315
  {
1316
- query: R(p),
1316
+ query: O(g),
1317
1317
  variables: o,
1318
- operationName: a,
1319
- cacheControl: h
1318
+ operationName: c,
1319
+ cacheControl: l
1320
1320
  },
1321
1321
  r,
1322
1322
  e
1323
1323
  );
1324
- } catch (u) {
1325
- return k(b(u));
1324
+ } catch (p) {
1325
+ return D(v(p));
1326
1326
  }
1327
- return bt(l);
1327
+ return Tt(h);
1328
1328
  }
1329
1329
  return {
1330
1330
  query: n,
1331
- mutate: (i) => Q(t, i)
1331
+ mutate: (i) => Y(t, i)
1332
1332
  };
1333
1333
  }
1334
- const Ct = 1, St = `@salesforce/platform-sdk-data_v${Ct}`, Z = J(), Tt = `${Z}/ui-api`, B = `${Z}/graphql`;
1335
- class _t {
1334
+ const Et = 1, It = `@salesforce/platform-sdk-data_v${Et}`, re = ee(), Mt = `${re}/ui-api`, B = `${re}/graphql`;
1335
+ class At {
1336
1336
  baseUrl;
1337
1337
  clientFetch;
1338
1338
  onStatus;
1339
1339
  graphql;
1340
1340
  constructor(e) {
1341
- const t = Et();
1342
- this.baseUrl = Mt(e?.basePath ?? t.apiPath), this.onStatus = e?.onStatus ?? {}, this.clientFetch = ht({
1341
+ const t = kt();
1342
+ this.baseUrl = Dt(e?.basePath ?? t.apiPath), this.onStatus = e?.onStatus ?? {}, this.clientFetch = mt({
1343
1343
  csrf: {
1344
- endpoint: `${this.baseUrl}${Tt}/session/csrf`,
1345
- cacheName: St,
1344
+ endpoint: `${this.baseUrl}${Mt}/session/csrf`,
1345
+ cacheName: It,
1346
1346
  protectedUrls: ["services/data/v", "services/apexrest"],
1347
1347
  alwaysProtectedUrls: ["services/apexrest"]
1348
1348
  }
1349
1349
  });
1350
- const r = (i, o) => this.fetch(i, o), n = pt(this.baseUrl, r);
1351
- this.graphql = vt({
1350
+ const r = (i, o) => this.fetch(i, o), n = wt(this.baseUrl, r);
1351
+ this.graphql = _t({
1352
1352
  bundle: n,
1353
1353
  url: B,
1354
1354
  executeRaw: this.executeRawGraphQL.bind(this)
@@ -1372,7 +1372,7 @@ class _t {
1372
1372
  return (await this.fetch(B, {
1373
1373
  method: "POST",
1374
1374
  body: JSON.stringify({ query: e, variables: t, operationName: r }),
1375
- headers: X()
1375
+ headers: te()
1376
1376
  })).json();
1377
1377
  }
1378
1378
  /**
@@ -1389,35 +1389,35 @@ class _t {
1389
1389
  return e;
1390
1390
  }
1391
1391
  }
1392
- function Et() {
1392
+ function kt() {
1393
1393
  return {
1394
1394
  apiPath: globalThis.SFDC_ENV?.apiPath
1395
1395
  };
1396
1396
  }
1397
- function Mt(s) {
1397
+ function Dt(s) {
1398
1398
  if (!s || s === "/") return "";
1399
1399
  let e = s;
1400
1400
  return e.startsWith("/") || (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
1401
1401
  }
1402
- function hs(s, ...e) {
1402
+ function ws(s, ...e) {
1403
1403
  let t = s[0] ?? "";
1404
1404
  for (let r = 0; r < e.length; r += 1)
1405
1405
  t += String(e[r]) + (s[r + 1] ?? "");
1406
1406
  return t;
1407
1407
  }
1408
- function fs(s) {
1409
- return I(
1408
+ function bs(s) {
1409
+ return k(
1410
1410
  (async () => {
1411
- switch (C(s?.surface)) {
1412
- case c.OpenAI:
1413
- return new Ze();
1414
- case c.WebApp:
1415
- case c.MicroFrontend:
1416
- return new _t(s?.webapp);
1417
- case c.Mosaic:
1418
- return new Ge(s?.mosaic);
1419
- case c.SalesforceACC:
1420
- case c.MCPApps:
1411
+ switch (S(s?.surface)) {
1412
+ case a.OpenAI:
1413
+ return new rt();
1414
+ case a.WebApp:
1415
+ case a.MicroFrontend:
1416
+ return new At(s?.webapp);
1417
+ case a.Mosaic:
1418
+ return new Ze(s?.mosaic);
1419
+ case a.SalesforceACC:
1420
+ case a.MCPApps:
1421
1421
  return {};
1422
1422
  default:
1423
1423
  return {};
@@ -1426,21 +1426,21 @@ function fs(s) {
1426
1426
  "createDataSDK"
1427
1427
  );
1428
1428
  }
1429
- function ps(s) {
1430
- return I(
1429
+ function vs(s) {
1430
+ return k(
1431
1431
  (async () => {
1432
- switch (C(s?.surface)) {
1433
- case c.OpenAI:
1432
+ switch (S(s?.surface)) {
1433
+ case a.OpenAI:
1434
1434
  return {};
1435
- case c.WebApp:
1435
+ case a.WebApp:
1436
1436
  return {};
1437
- case c.MicroFrontend:
1437
+ case a.MicroFrontend:
1438
1438
  return {};
1439
- case c.SalesforceACC:
1439
+ case a.SalesforceACC:
1440
1440
  return {};
1441
- case c.MCPApps:
1441
+ case a.MCPApps:
1442
1442
  return {};
1443
- case c.Mosaic:
1443
+ case a.Mosaic:
1444
1444
  return {};
1445
1445
  default:
1446
1446
  return {};
@@ -1449,13 +1449,13 @@ function ps(s) {
1449
1449
  "createLightningSDK"
1450
1450
  );
1451
1451
  }
1452
- function At(s) {
1452
+ function Pt(s) {
1453
1453
  let e = "";
1454
1454
  for (let r = 0; r < s.length; r += 8192)
1455
1455
  e += String.fromCharCode.apply(null, Array.from(s.subarray(r, r + 8192)));
1456
1456
  return btoa(e);
1457
1457
  }
1458
- class It {
1458
+ class Lt {
1459
1459
  entries = [];
1460
1460
  totalBytes = 0;
1461
1461
  maxBufferSize;
@@ -1470,7 +1470,7 @@ class It {
1470
1470
  return this.entries.length === 0;
1471
1471
  }
1472
1472
  enqueue(e, t) {
1473
- const r = At(e), n = {
1473
+ const r = Pt(e), n = {
1474
1474
  data: r,
1475
1475
  traceId: t?.traceId,
1476
1476
  instanceId: t?.instanceId,
@@ -1492,8 +1492,8 @@ class It {
1492
1492
  e > 0 && this.onError?.({ reason: "buffer_overflow", droppedCount: e });
1493
1493
  }
1494
1494
  }
1495
- const kt = "telemetry/upload";
1496
- class Dt {
1495
+ const xt = "telemetry/upload";
1496
+ class Rt {
1497
1497
  buffer;
1498
1498
  sdk;
1499
1499
  onError;
@@ -1511,8 +1511,8 @@ class Dt {
1511
1511
  flush() {
1512
1512
  if (this.buffer.isEmpty || !this.sdk.callTool)
1513
1513
  return;
1514
- const t = this.buffer.drain().map(Pt);
1515
- this.sdk.callTool({ toolName: kt, params: { inputs: [{ envelopes: t }] } }).catch((r) => {
1514
+ const t = this.buffer.drain().map(Ot);
1515
+ this.sdk.callTool({ toolName: xt, params: { inputs: [{ envelopes: t }] } }).catch((r) => {
1516
1516
  this.onError?.({ reason: "tool_call_failed", error: r });
1517
1517
  });
1518
1518
  }
@@ -1520,37 +1520,37 @@ class Dt {
1520
1520
  this.disposed || (this.disposed = !0, this.timerId !== null && (clearInterval(this.timerId), this.timerId = null), document.removeEventListener("visibilitychange", this.handleVisibilityChange), window.removeEventListener("pagehide", this.handlePageHide), this.flush());
1521
1521
  }
1522
1522
  }
1523
- function Pt(s) {
1523
+ function Ot(s) {
1524
1524
  const e = { base64Env: s.data };
1525
1525
  return s.traceId !== void 0 && (e.traceId = s.traceId), e;
1526
1526
  }
1527
- const Lt = 65536, xt = 3e4;
1528
- function gs(s) {
1527
+ const Ht = 65536, qt = 3e4;
1528
+ function Cs(s) {
1529
1529
  const {
1530
1530
  sdk: e,
1531
- maxBufferSize: t = Lt,
1532
- flushInterval: r = xt,
1531
+ maxBufferSize: t = Ht,
1532
+ flushInterval: r = qt,
1533
1533
  onError: n
1534
- } = s, i = new It({ maxBufferSize: t, onError: n }), o = new Dt(i, e, { flushInterval: r, onError: n });
1534
+ } = s, i = new Lt({ maxBufferSize: t, onError: n }), o = new Rt(i, e, { flushInterval: r, onError: n });
1535
1535
  return {
1536
- enqueue(a, h) {
1537
- i.enqueue(a, h);
1536
+ enqueue(c, l) {
1537
+ i.enqueue(c, l);
1538
1538
  },
1539
1539
  dispose() {
1540
1540
  o.dispose();
1541
1541
  }
1542
1542
  };
1543
1543
  }
1544
- const Rt = 1e4, Ot = 10, Ht = 10, qt = 250, Nt = 1e3;
1545
- function v(s, e) {
1544
+ const Nt = 1e4, Ft = 10, Ut = 10, Vt = 250, $t = 1e3;
1545
+ function C(s, e) {
1546
1546
  if (s !== void 0 && (typeof s != "number" || !Number.isFinite(s) || s <= 0))
1547
1547
  throw new Error(`${e}, if defined, must be a finite number greater than 0`);
1548
1548
  }
1549
- function Ft(s, e) {
1549
+ function Wt(s, e) {
1550
1550
  if (typeof s != "function")
1551
1551
  throw new Error(`${e} must be a function`);
1552
1552
  }
1553
- class Ut {
1553
+ class Kt {
1554
1554
  _collector;
1555
1555
  _onEnvelope;
1556
1556
  _onError;
@@ -1571,7 +1571,7 @@ class Ut {
1571
1571
  _lastClickTriggeredAt = 0;
1572
1572
  _isDisposed = !1;
1573
1573
  constructor(e) {
1574
- Ft(e?.onEnvelope, "options.onEnvelope"), v(e.uploadInterval, "options.uploadInterval"), v(e.messagesLimit, "options.messagesLimit"), v(e.metricsLimit, "options.metricsLimit"), v(e.maxUniqueSchemas, "options.maxUniqueSchemas"), v(e.clickUploadDelay, "options.clickUploadDelay"), v(e.clickTriggerCooldown, "options.clickTriggerCooldown"), this._onEnvelope = e.onEnvelope, this._onError = e.onError, this._messagesLimit = e.messagesLimit ?? Ot, this._metricsLimit = e.metricsLimit ?? Ht, this._uploadInterval = e.uploadInterval ?? Rt, this._clickUploadDelay = e.clickUploadDelay ?? qt, this._clickTriggerCooldown = e.clickTriggerCooldown ?? Nt, this._enableClickTrigger = e.enableClickTrigger !== !1, this._enableVisibilityTrigger = e.enableVisibilityTrigger !== !1, this._collector = new fe({
1574
+ Wt(e?.onEnvelope, "options.onEnvelope"), C(e.uploadInterval, "options.uploadInterval"), C(e.messagesLimit, "options.messagesLimit"), C(e.metricsLimit, "options.metricsLimit"), C(e.maxUniqueSchemas, "options.maxUniqueSchemas"), C(e.clickUploadDelay, "options.clickUploadDelay"), C(e.clickTriggerCooldown, "options.clickTriggerCooldown"), this._onEnvelope = e.onEnvelope, this._onError = e.onError, this._messagesLimit = e.messagesLimit ?? Ft, this._metricsLimit = e.metricsLimit ?? Ut, this._uploadInterval = e.uploadInterval ?? Nt, this._clickUploadDelay = e.clickUploadDelay ?? Vt, this._clickTriggerCooldown = e.clickTriggerCooldown ?? $t, this._enableClickTrigger = e.enableClickTrigger !== !1, this._enableVisibilityTrigger = e.enableVisibilityTrigger !== !1, this._collector = new ye({
1575
1575
  environment: e.environment,
1576
1576
  maxUniqueSchemas: e.maxUniqueSchemas
1577
1577
  }), this._restartInterval(), this._attachWindowListeners();
@@ -1651,7 +1651,7 @@ class Ut {
1651
1651
  metricsCount: this.metricsCount,
1652
1652
  estimatedByteSize: this.estimatedByteSize,
1653
1653
  triggeredAt: Date.now()
1654
- }, r = this._collector.getRawContentsOfCoreEnvelope(), n = he(r);
1654
+ }, r = this._collector.getRawContentsOfCoreEnvelope(), n = me(r);
1655
1655
  this._restartInterval();
1656
1656
  try {
1657
1657
  await this._onEnvelope(n, t);
@@ -1664,15 +1664,15 @@ class Ut {
1664
1664
  }
1665
1665
  }
1666
1666
  }
1667
- function Vt(s, e) {
1667
+ function zt(s, e) {
1668
1668
  if (!s)
1669
1669
  throw new Error("instrumentedApp is required");
1670
- const t = new Ut(e);
1670
+ const t = new Kt(e);
1671
1671
  return s.registerLogCollector(t), s.registerMetricsCollector(t), e.enableClickTrigger !== !1 && s.activateClickTracker?.(), t;
1672
1672
  }
1673
- function Wt(s) {
1674
- const e = (r, n, i, o, a) => {
1675
- s.error(a ?? r);
1673
+ function Bt(s) {
1674
+ const e = (r, n, i, o, c) => {
1675
+ s.error(c ?? r);
1676
1676
  }, t = (r) => {
1677
1677
  s.error(r.reason);
1678
1678
  };
@@ -1680,33 +1680,40 @@ function Wt(s) {
1680
1680
  window.removeEventListener("error", e), window.removeEventListener("unhandledrejection", t);
1681
1681
  };
1682
1682
  }
1683
- function m(s, e) {
1683
+ const jt = "aJC", Ss = "sfdc.pftId", j = /* @__PURE__ */ new Set(), Jt = /^aJC[0-9A-Za-z]{12}(?:[0-9A-Za-z]{3})?$/;
1684
+ function J(s) {
1685
+ return typeof s != "string" || s.length === 0 ? !1 : s.length !== 15 && s.length !== 18 ? (Q(s, "Expected a 15- or 18-character Salesforce ID"), !1) : Jt.test(s) ? !0 : (Q(s, `Expected a Product Feature Id (prefix "${jt}", base62).`), !1);
1686
+ }
1687
+ function Q(s, e) {
1688
+ j.has(s) || (j.add(s), console.debug(`[platform-sdk:analytics] Ignoring invalid PFT Id "${s}". ${e}`));
1689
+ }
1690
+ function y(s, e) {
1684
1691
  return { surface: e };
1685
1692
  }
1686
- const $t = {
1693
+ const Qt = {
1687
1694
  callTool: {
1688
1695
  isAsync: !0,
1689
1696
  extractTags: (s, e) => ({ toolName: s[0]?.toolName ?? "unknown", surface: e })
1690
1697
  },
1691
1698
  setWidgetState: {
1692
1699
  isAsync: !1,
1693
- extractTags: m
1700
+ extractTags: y
1694
1701
  },
1695
1702
  getWidgetState: {
1696
1703
  isAsync: !1,
1697
- extractTags: m
1704
+ extractTags: y
1698
1705
  },
1699
1706
  sendMessageToHost: {
1700
1707
  isAsync: !0,
1701
- extractTags: m
1708
+ extractTags: y
1702
1709
  },
1703
1710
  openLink: {
1704
1711
  isAsync: !0,
1705
- extractTags: m
1712
+ extractTags: y
1706
1713
  },
1707
1714
  subscribe: {
1708
1715
  isAsync: !1,
1709
- extractTags: m,
1716
+ extractTags: y,
1710
1717
  wrapArgs: (s, e) => {
1711
1718
  const t = s[0];
1712
1719
  return [
@@ -1726,116 +1733,128 @@ const $t = {
1726
1733
  },
1727
1734
  accessToolOutput: {
1728
1735
  isAsync: !1,
1729
- extractTags: m
1736
+ extractTags: y
1730
1737
  },
1731
1738
  accessToolInput: {
1732
1739
  isAsync: !1,
1733
- extractTags: m
1740
+ extractTags: y
1734
1741
  },
1735
1742
  accessToolMetadata: {
1736
1743
  isAsync: !1,
1737
- extractTags: m
1744
+ extractTags: y
1738
1745
  }
1739
1746
  };
1740
- function Kt(s, e, t) {
1747
+ function Gt(s, e, t) {
1741
1748
  return new Proxy(s, {
1742
1749
  get(r, n, i) {
1743
- const o = Reflect.get(r, n, i), a = $t[n];
1744
- return !a || typeof o != "function" ? o : (...h) => {
1745
- const d = a.extractTags(h, t), p = a.wrapArgs ? a.wrapArgs(h, e) : h, f = `sdk.${String(n)}`;
1746
- return a.isAsync ? e.activityAsync(f, async () => {
1750
+ const o = Reflect.get(r, n, i), c = Qt[n];
1751
+ return !c || typeof o != "function" ? o : (...l) => {
1752
+ const d = c.extractTags(l, t), g = c.wrapArgs ? c.wrapArgs(l, e) : l, f = `sdk.${String(n)}`;
1753
+ return c.isAsync ? e.activityAsync(f, async () => {
1747
1754
  try {
1748
- const l = await o.apply(
1755
+ const h = await o.apply(
1749
1756
  r,
1750
- p
1757
+ g
1751
1758
  );
1752
- return e.incrementCounter(f, 1, !1, d), l;
1753
- } catch (l) {
1754
- throw e.incrementCounter(f, 1, !0, d), l;
1759
+ return e.incrementCounter(f, 1, !1, d), h;
1760
+ } catch (h) {
1761
+ throw e.incrementCounter(f, 1, !0, d), h;
1755
1762
  }
1756
- }) : (e.incrementCounter(f, 1, !1, d), o.apply(r, p));
1763
+ }) : (e.incrementCounter(f, 1, !1, d), o.apply(r, g));
1757
1764
  };
1758
1765
  }
1759
1766
  });
1760
1767
  }
1761
- async function ms(s) {
1762
- const { appId: e, clientSessionId: t } = s, r = C(), n = Date.now(), i = s.sdk ?? await Fe(), o = pe("mcp-widget", {
1768
+ async function Ts(s) {
1769
+ const { appId: e, clientSessionId: t } = s, r = S(), n = Date.now(), i = s.sdk ?? await We();
1770
+ let o = null;
1771
+ s.pftId !== void 0 && J(s.pftId) && (o = s.pftId);
1772
+ const c = we("mcp-widget", {
1763
1773
  appPayloadProvider: {
1764
1774
  getPayload: () => ({
1765
- schema: ge,
1766
- payload: { appId: e, surface: r }
1775
+ schema: be,
1776
+ payload: {
1777
+ appId: e,
1778
+ surface: r,
1779
+ ...o !== null ? { pftId: o } : {}
1780
+ }
1767
1781
  })
1768
1782
  },
1769
1783
  clientSessionId: t
1770
- }), a = o, h = Kt(i, a, r), d = Wt(a);
1771
- let p;
1772
- s.transport && (p = Vt(o, {
1784
+ }), l = c, d = Gt(i, l, r), g = Bt(l);
1785
+ let f;
1786
+ s.transport && (f = zt(c, {
1773
1787
  onEnvelope: (u) => {
1774
1788
  s.transport.enqueue(u);
1775
1789
  }
1776
1790
  }));
1777
- let f, l = !1;
1791
+ let h, p = !1;
1778
1792
  return {
1779
- instrumentedSDK: h,
1780
- app: o,
1781
- trackEvent(u, g) {
1782
- l || a.log(ve, {
1793
+ instrumentedSDK: d,
1794
+ app: c,
1795
+ trackEvent(u, m) {
1796
+ p || l.log(_e, {
1783
1797
  eventName: u,
1784
- properties: g ? JSON.stringify(g) : ""
1798
+ properties: m ? JSON.stringify(m) : ""
1785
1799
  });
1786
1800
  },
1787
- trackInteraction(u, g) {
1788
- l || a.log(be, {
1801
+ trackInteraction(u, m) {
1802
+ p || l.log(Te, {
1789
1803
  elementId: u,
1790
- properties: g ? JSON.stringify(g) : ""
1804
+ properties: m ? JSON.stringify(m) : ""
1791
1805
  });
1792
1806
  },
1793
- trackError(u, g) {
1794
- l || a.error(u, we, {
1795
- properties: g ? JSON.stringify(g) : ""
1807
+ trackError(u, m) {
1808
+ p || l.error(u, Se, {
1809
+ properties: m ? JSON.stringify(m) : ""
1796
1810
  });
1797
1811
  },
1798
1812
  trackPageView(u) {
1799
- l || u !== f && (f = u, a.log(ye, { componentRef: u }));
1813
+ p || u !== h && (h = u, l.log(Ce, { componentRef: u }));
1814
+ },
1815
+ setPftId(u) {
1816
+ p || J(u) && (o = u);
1800
1817
  },
1801
1818
  dispose() {
1802
- if (l) return;
1803
- l = !0, d();
1819
+ if (p) return;
1820
+ p = !0, g();
1804
1821
  const u = Date.now() - n;
1805
- a.log(me, { durationMs: u }), p?.dispose();
1822
+ l.log(ve, { durationMs: u }), f?.dispose();
1806
1823
  }
1807
1824
  };
1808
1825
  }
1809
1826
  export {
1810
- Ae as JsonRpcClient,
1811
- He as MCPAppsChatSDK,
1812
- We as MCPAppsViewSDK,
1813
- y as McpAppsSession,
1814
- is as MessageChannelTransport,
1815
- c as Surface,
1816
- Ut as TelemetryUploader,
1817
- Me as WindowPostMessageTransport,
1818
- ms as createAnalytics,
1819
- Ue as createChatSDK,
1820
- fs as createDataSDK,
1821
- ps as createLightningSDK,
1822
- gs as createTelemetryTransport,
1823
- Ke as createViewSDK,
1824
- Fe as getChatSDK,
1825
- as as getChatSDKSync,
1826
- C as getSurface,
1827
- os as getSurfaceCapabilities,
1828
- ls as getViewSDK,
1829
- us as getViewSDKSync,
1830
- hs as gql,
1827
+ Pe as JsonRpcClient,
1828
+ Ue as MCPAppsChatSDK,
1829
+ Be as MCPAppsViewSDK,
1830
+ w as McpAppsSession,
1831
+ ds as MessageChannelTransport,
1832
+ Ss as PFT_META_KEY,
1833
+ a as Surface,
1834
+ Kt as TelemetryUploader,
1835
+ De as WindowPostMessageTransport,
1836
+ Ts as createAnalytics,
1837
+ Ke as createChatSDK,
1838
+ bs as createDataSDK,
1839
+ vs as createLightningSDK,
1840
+ Cs as createTelemetryTransport,
1841
+ Je as createViewSDK,
1842
+ We as getChatSDK,
1843
+ fs as getChatSDKSync,
1844
+ S as getSurface,
1845
+ hs as getSurfaceCapabilities,
1846
+ gs as getViewSDK,
1847
+ ms as getViewSDKSync,
1848
+ ws as gql,
1831
1849
  A as isJsonRpcBase,
1832
- j as isJsonRpcErrorResponse,
1833
- Ee as isJsonRpcNotification,
1834
- ns as isJsonRpcRequest,
1835
- _e as isJsonRpcResponse,
1836
- Te as isJsonRpcSuccessResponse,
1837
- Vt as registerTelemetryUploader,
1838
- cs as resetChatSDK,
1839
- ds as resetViewSDK,
1840
- I as wrapSDKPromise
1850
+ X as isJsonRpcErrorResponse,
1851
+ ke as isJsonRpcNotification,
1852
+ us as isJsonRpcRequest,
1853
+ Ae as isJsonRpcResponse,
1854
+ Me as isJsonRpcSuccessResponse,
1855
+ zt as registerTelemetryUploader,
1856
+ ps as resetChatSDK,
1857
+ ys as resetViewSDK,
1858
+ J as validatePftId,
1859
+ k as wrapSDKPromise
1841
1860
  };