@spiffcommerce/core 19.2.0 → 19.2.1-alpha.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.d.ts CHANGED
@@ -21,10 +21,17 @@ declare class OptionService {
21
21
  }
22
22
  declare const optionService: OptionService;
23
23
 
24
+ declare enum GraphQLAuthenticationMode {
25
+ Default = 0,
26
+ Application = 1,
27
+ User = 2
28
+ }
24
29
  declare class GraphQlManager {
25
30
  private shadowGraphqlClient;
31
+ private authenticationMode;
26
32
  constructor();
27
33
  getShadowGraphqlClient(): ApolloClient<any>;
34
+ setAuthenticationMode(mode: GraphQLAuthenticationMode): void;
28
35
  private constructShadowGraphqlClient;
29
36
  }
30
37
  declare const graphQlManager: GraphQlManager;
package/dist/index.js CHANGED
@@ -169,32 +169,51 @@ const kt = (c) => {
169
169
  };
170
170
  class Lt {
171
171
  constructor() {
172
- this.shadowGraphqlClient = this.constructShadowGraphqlClient(), yA.addServerUrlCallback(() => {
172
+ this.authenticationMode = 0, this.shadowGraphqlClient = this.constructShadowGraphqlClient(), yA.addServerUrlCallback(() => {
173
173
  this.shadowGraphqlClient = this.constructShadowGraphqlClient();
174
174
  });
175
175
  }
176
176
  getShadowGraphqlClient() {
177
177
  return this.shadowGraphqlClient;
178
178
  }
179
+ setAuthenticationMode(A) {
180
+ this.authenticationMode = A;
181
+ }
179
182
  constructShadowGraphqlClient() {
180
183
  const A = Bt({
181
184
  uri: `${yA.getServerUrl()}/graphql`,
182
185
  fetch: ZA
183
186
  }), e = Ht(async (i, s) => {
184
- const { headers: o } = s, r = o || {}, g = await bt(), B = s.bearer ?? g.bearer, l = s.partnerId ?? g.partnerId, d = s.activeIntegration ?? g.activeIntegration, w = s.transactionOwnerId, h = s.customerToken ?? g.customerToken, E = s.applicationKey ?? g.applicationKey, Q = s.bundleOwnerId;
187
+ const { headers: o } = s, r = o || {}, g = await bt(), B = () => {
188
+ switch (this.authenticationMode) {
189
+ case 2:
190
+ case 0:
191
+ return s.bearer ?? g.bearer;
192
+ default:
193
+ return;
194
+ }
195
+ }, l = () => {
196
+ switch (this.authenticationMode) {
197
+ case 1:
198
+ case 0:
199
+ return s.applicationKey ?? g.applicationKey;
200
+ default:
201
+ return;
202
+ }
203
+ }, d = B(), w = l(), h = s.partnerId ?? g.partnerId, E = s.activeIntegration ?? g.activeIntegration, Q = s.transactionOwnerId, C = s.customerToken ?? g.customerToken, f = s.bundleOwnerId;
185
204
  try {
186
205
  if (window && window.__SENTRY__) {
187
- const C = window.__SENTRY__.hub;
188
- if (C) {
189
- const f = C.traceHeaders();
190
- Object.entries(f).forEach(([u, m]) => {
191
- r[u] = m;
206
+ const u = window.__SENTRY__.hub;
207
+ if (u) {
208
+ const I = u.traceHeaders();
209
+ Object.entries(I).forEach(([m, p]) => {
210
+ r[m] = p;
192
211
  });
193
212
  }
194
213
  }
195
214
  } catch {
196
215
  }
197
- return B && (r.Authorization = `Bearer ${B}`), l && (r.partnerId = l), d && (r.activeIntegration = d), w && (r.transactionOwnerId = w), h && (r.customerToken = h), E && (r["X-Application-Key"] = E), Q && (r.bundleOwnerId = Q), {
216
+ return d && (r.Authorization = `Bearer ${d}`), h && (r.partnerId = h), E && (r.activeIntegration = E), Q && (r.transactionOwnerId = Q), C && (r.customerToken = C), w && (r["X-Application-Key"] = w), f && (r.bundleOwnerId = f), {
198
217
  headers: r
199
218
  };
200
219
  }), t = Rt(({ operation: i, graphQLErrors: s, networkError: o }) => {
@@ -1671,8 +1690,8 @@ class un {
1671
1690
  async regenerateQRCode(A, e, t, n, a, i, s, o, r) {
1672
1691
  if (!e && t !== "" && n === "") {
1673
1692
  const g = async () => {
1674
- var u, m;
1675
- const C = (await Te([t]))[0], f = (m = (u = C == null ? void 0 : C.versions) == null ? void 0 : u.find((I) => I.name === "mpeg4")) == null ? void 0 : m.link;
1693
+ var u, I;
1694
+ const C = (await Te([t]))[0], f = (I = (u = C == null ? void 0 : C.versions) == null ? void 0 : u.find((m) => m.name === "mpeg4")) == null ? void 0 : I.link;
1676
1695
  return { asset: C, link: f };
1677
1696
  }, B = await new Promise((C, f) => {
1678
1697
  new We(
@@ -1936,11 +1955,11 @@ class In {
1936
1955
  scaleX: (C == null ? void 0 : C.zoom) || 1,
1937
1956
  scaleY: (C == null ? void 0 : C.zoom) || 1,
1938
1957
  rotation: 0
1939
- } : void 0, u = J(), I = n.getLayouts().find((p) => p.panelId === d.panelId);
1940
- if (!I)
1958
+ } : void 0, u = J(), m = n.getLayouts().find((p) => p.panelId === d.panelId);
1959
+ if (!m)
1941
1960
  throw new z(d);
1942
1961
  return {
1943
- command: this.getCreateElementCommand(u, d, I, {
1962
+ command: this.getCreateElementCommand(u, d, m, {
1944
1963
  frameData: h,
1945
1964
  pattern: f,
1946
1965
  disablePlaceholder: A.data.disablePlaceholder,
@@ -2168,7 +2187,7 @@ class pn {
2168
2187
  if (!o)
2169
2188
  throw new rA(s);
2170
2189
  const r = await Me(await this.getIllustrationBody(o)), g = await pA(r.svg), B = (C) => {
2171
- const f = a.getLayouts().find((m) => m.panelId === C.panelId);
2190
+ const f = a.getLayouts().find((I) => I.panelId === C.panelId);
2172
2191
  if (!f)
2173
2192
  throw new z(C);
2174
2193
  const u = J();
@@ -2202,13 +2221,13 @@ class pn {
2202
2221
  );
2203
2222
  const C = await this.availableColors(A, a) || [], f = Object.keys(r.colors);
2204
2223
  if (A.data.colorPickerEnabled && C.length === 1 && f.length === 1) {
2205
- const u = C[0], m = f[0];
2224
+ const u = C[0], I = f[0];
2206
2225
  await this.changeColors(
2207
2226
  A,
2208
- l.map((I) => I.regionElement),
2227
+ l.map((m) => m.regionElement),
2209
2228
  a,
2210
2229
  () => a.getCommandContext().getAllLayouts(),
2211
- /* @__PURE__ */ new Map([[m, u.variant.color]])
2230
+ /* @__PURE__ */ new Map([[I, u.variant.color]])
2212
2231
  );
2213
2232
  }
2214
2233
  }
@@ -3090,7 +3109,7 @@ class Hn {
3090
3109
  h,
3091
3110
  async () => {
3092
3111
  e.updateMetadata(A.stepName, { color: E, text: Q }), e.updateStorage(A.stepName, { text: Q, inputText: Q });
3093
- const f = s.map((m) => new Be(m.id, w)), u = new G(f);
3112
+ const f = s.map((I) => new Be(I.id, w)), u = new G(f);
3094
3113
  e.getCommandDispatcher()(u), e.setMandatoryFulfilled(A.stepName, !0);
3095
3114
  }
3096
3115
  );
@@ -3246,7 +3265,7 @@ class Hn {
3246
3265
  curved: t.curved,
3247
3266
  paths: t.paths,
3248
3267
  fillSpotColorDefinition: Q
3249
- }, m = [], I = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map();
3268
+ }, I = [], m = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map();
3250
3269
  if (!u.fontData)
3251
3270
  throw new k("Failed to resolve font data for text.");
3252
3271
  const [M, y] = uA(
@@ -3263,16 +3282,16 @@ class Hn {
3263
3282
  [o],
3264
3283
  { size: t.size, minSize: t.minSize, maxSize: t.maxSize }
3265
3284
  );
3266
- I.set(u.id, M), p.set(u.id, y);
3285
+ m.set(u.id, M), p.set(u.id, y);
3267
3286
  const S = t.curved || t.vertical ? o : (y || []).join(`
3268
3287
  `);
3269
- m.push(
3288
+ I.push(
3270
3289
  this.generateTextChangeCommandsForRegion(M, t, u.id, S)
3271
3290
  );
3272
3291
  const Y = new L(u, d);
3273
3292
  return {
3274
3293
  regionElement: { id: w, region: B },
3275
- commands: [Y, ...m],
3294
+ commands: [Y, ...I],
3276
3295
  newElement: u,
3277
3296
  fontData: n
3278
3297
  };
@@ -3310,23 +3329,23 @@ class Hn {
3310
3329
  const B = (n || "").replace(/^(?![\u000A\u000D])[\u0000-\u001F\u007F-\u009F]/g, ""), l = this.getProcessedInput(B, A.data, s), d = i.getRegionElements(A.stepName), w = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
3311
3330
  for (const u of d)
3312
3331
  if (u.region) {
3313
- const [m, I] = uA(
3332
+ const [I, m] = uA(
3314
3333
  e,
3315
3334
  t,
3316
3335
  u.region,
3317
3336
  [l],
3318
3337
  { size: A.data.size, minSize: A.data.minSize, maxSize: A.data.maxSize }
3319
3338
  );
3320
- w.set(u.id, m), h.set(u.id, I);
3339
+ w.set(u.id, I), h.set(u.id, m);
3321
3340
  }
3322
3341
  const Q = (() => {
3323
3342
  if (A.data && A.data.maxLength && l.length > A.data.maxLength)
3324
3343
  return g && g(!0), { info: "0" };
3325
- const u = i.getProfanities(), m = jA(l.toLowerCase());
3326
- for (const I of m)
3344
+ const u = i.getProfanities(), I = jA(l.toLowerCase());
3345
+ for (const m of I)
3327
3346
  for (const p in u) {
3328
3347
  const M = u[p].toLowerCase().replace(/\s/g, "");
3329
- if (I === M)
3348
+ if (m === M)
3330
3349
  return o(!0), { error: "Blocked profanity." };
3331
3350
  }
3332
3351
  return !A.data.vertical && !A.data.allowNewlines && (l.includes(`
@@ -3343,14 +3362,14 @@ class Hn {
3343
3362
  }), a.defaultCleared && i.setMandatoryFulfilled(A.stepName, !0);
3344
3363
  const C = [];
3345
3364
  for (const u of d) {
3346
- const m = A.data.curved ? l : (h.get(u.id) || []).join(`
3365
+ const I = A.data.curved ? l : (h.get(u.id) || []).join(`
3347
3366
  `);
3348
3367
  C.push(
3349
3368
  this.generateTextChangeCommandsForRegion(
3350
3369
  w.get(u.id) || 1,
3351
3370
  A.data,
3352
3371
  u.id,
3353
- m
3372
+ I
3354
3373
  )
3355
3374
  );
3356
3375
  }
@@ -4798,16 +4817,16 @@ class bn extends ae {
4798
4817
  }
4799
4818
  brandSvg(A, e) {
4800
4819
  const t = A.toSVG(2), n = A.getBoundingBox(), a = n.x2 - n.x1, i = A.toPathData(3), s = () => {
4801
- const m = R("g"), I = R("defs");
4802
- m.appendChild(I), I.appendChild(et(3, 7, 4, "shadow"));
4820
+ const I = R("g"), m = R("defs");
4821
+ I.appendChild(m), m.appendChild(et(3, 7, 4, "shadow"));
4803
4822
  const p = R("g");
4804
- m.appendChild(p), p.setAttribute("filter", "url(#shadow)"), p.innerHTML = t;
4823
+ I.appendChild(p), p.setAttribute("filter", "url(#shadow)"), p.innerHTML = t;
4805
4824
  const M = R("g");
4806
- m.appendChild(M), M.setAttribute("fill", "red"), M.setAttribute("stroke", "red"), M.setAttribute("stroke-width", "9"), M.innerHTML = t;
4825
+ I.appendChild(M), M.setAttribute("fill", "red"), M.setAttribute("stroke", "red"), M.setAttribute("stroke-width", "9"), M.innerHTML = t;
4807
4826
  const y = R("g");
4808
- m.appendChild(y), y.setAttribute("fill", "#9d2621"), y.setAttribute("transform", "translate(1,1)"), y.innerHTML = t;
4827
+ I.appendChild(y), y.setAttribute("fill", "#9d2621"), y.setAttribute("transform", "translate(1,1)"), y.innerHTML = t;
4809
4828
  const S = R("g");
4810
- return m.appendChild(S), S.setAttribute("fill", "yellow"), S.innerHTML = t, new oe(m).transform(([N, H]) => [N, H + (a / 2 - N) ** 2 / (a * 2.9)]), m;
4829
+ return I.appendChild(S), S.setAttribute("fill", "yellow"), S.innerHTML = t, new oe(I).transform(([N, H]) => [N, H + (a / 2 - N) ** 2 / (a * 2.9)]), I;
4811
4830
  }, [o, r, g] = _e(e);
4812
4831
  if (!o)
4813
4832
  return "";
@@ -4866,10 +4885,10 @@ class Tn extends ae {
4866
4885
  f.setAttribute("opacity", "0"), C.appendChild(f);
4867
4886
  const u = R("g");
4868
4887
  C.appendChild(u);
4869
- const m = r();
4870
- u.appendChild(m);
4871
- const I = te(o);
4872
- return se(u, I, w, h), g.outerHTML;
4888
+ const I = r();
4889
+ u.appendChild(I);
4890
+ const m = te(o);
4891
+ return se(u, m, w, h), g.outerHTML;
4873
4892
  }
4874
4893
  // 1 if true, 0 if false.
4875
4894
  }
@@ -4890,10 +4909,10 @@ class zn extends ae {
4890
4909
  f.classList.add("module-text-group");
4891
4910
  const u = R("defs");
4892
4911
  f.appendChild(u), u.appendChild(et(0, 2, 2, "shadow"));
4893
- const m = R("path");
4894
- m.setAttribute("d", g), m.setAttribute("stroke", "black"), m.setAttribute("stroke-width", "3"), u.appendChild(m);
4895
- const I = R("g");
4896
- I.classList.add("module-layer0"), f.appendChild(I), I.setAttribute("filter", "url(#shadow)"), I.innerHTML = m.outerHTML;
4912
+ const I = R("path");
4913
+ I.setAttribute("d", g), I.setAttribute("stroke", "black"), I.setAttribute("stroke-width", "3"), u.appendChild(I);
4914
+ const m = R("g");
4915
+ m.classList.add("module-layer0"), f.appendChild(m), m.setAttribute("filter", "url(#shadow)"), m.innerHTML = I.outerHTML;
4897
4916
  const p = R("g");
4898
4917
  p.classList.add("module-layer1"), f.appendChild(p), p.setAttribute("stroke-width", "3"), p.setAttribute("stroke", "rgb(45,41,38)"), p.setAttribute("fill", "rgb(45,41,38)"), p.setAttribute("transform", "translate(0.5,0)"), p.innerHTML = s;
4899
4918
  const M = R("g");
@@ -5341,19 +5360,19 @@ class jn {
5341
5360
  ), this.stepElements = {}, this.stepInitialised = {}, this.stepMetadata = {}, this.stepSelections = {}, this.storage = {}, await this.ensureStepsAreLoaded();
5342
5361
  }
5343
5362
  async setSelectionsAndElements(A, e, t, n) {
5344
- var m;
5363
+ var I;
5345
5364
  const a = this.stepSelections;
5346
5365
  this.stepSelections = {
5347
5366
  ...this.stepSelections,
5348
5367
  [A]: { selectedVariants: e }
5349
- }, this.selectionCost = Object.values(this.stepSelections).reduce((I, p) => I + p.selectedVariants.map((M) => M.priceModifier || 0).reduce((M, y) => M + y, 0), 0), this.workflow.steps.forEach((I) => {
5350
- tA(I, this.stepSelections) || (this.stepInitialised[I.stepName] = !1, delete this.stepMetadata[I.stepName], delete this.stepSelections[I.stepName], delete this.storage[I.stepName]);
5368
+ }, this.selectionCost = Object.values(this.stepSelections).reduce((m, p) => m + p.selectedVariants.map((M) => M.priceModifier || 0).reduce((M, y) => M + y, 0), 0), this.workflow.steps.forEach((m) => {
5369
+ tA(m, this.stepSelections) || (this.stepInitialised[m.stepName] = !1, delete this.stepMetadata[m.stepName], delete this.stepSelections[m.stepName], delete this.storage[m.stepName]);
5351
5370
  });
5352
- const i = this.allScenes, s = eA(i, a), o = eA(i, this.stepSelections), r = s.map((I) => I.silentSteps).flat(), B = o.map((I) => I.silentSteps).flat().filter(
5353
- (I) => !r.some((p) => p.stepName === I.stepName)
5371
+ const i = this.allScenes, s = eA(i, a), o = eA(i, this.stepSelections), r = s.map((m) => m.silentSteps).flat(), B = o.map((m) => m.silentSteps).flat().filter(
5372
+ (m) => !r.some((p) => p.stepName === m.stepName)
5354
5373
  );
5355
- r.forEach((I) => {
5356
- tA(I, this.stepSelections) || (this.stepInitialised[I.stepName] = !1);
5374
+ r.forEach((m) => {
5375
+ tA(m, this.stepSelections) || (this.stepInitialised[m.stepName] = !1);
5357
5376
  });
5358
5377
  const l = this.getInvalidCanvasRegions(), { stepElements: d, commands: w } = await this.stepElementsForIntroducedSilentSteps(B, !1);
5359
5378
  this.stepElements = {
@@ -5361,16 +5380,16 @@ class jn {
5361
5380
  ...d,
5362
5381
  [A]: t
5363
5382
  }, this.removeElements(l);
5364
- const h = this.workflow.steps.find((I) => I.stepName === A);
5383
+ const h = this.workflow.steps.find((m) => m.stepName === A);
5365
5384
  if ((h == null ? void 0 : h.type) === D.Frame) {
5366
- const I = this.getStepSpecificServices(A);
5367
- (m = I == null ? void 0 : I.frameService) == null || m.setTargetElements(t.map((p) => p.id));
5385
+ const m = this.getStepSpecificServices(A);
5386
+ (I = m == null ? void 0 : m.frameService) == null || I.setTargetElements(t.map((p) => p.id));
5368
5387
  }
5369
- const E = l.map((I) => new Z(I.id)), Q = new de(this.constructSerializableWorkflow()), C = [...w, ...E, Q];
5388
+ const E = l.map((m) => new Z(m.id)), Q = new de(this.constructSerializableWorkflow()), C = [...w, ...E, Q];
5370
5389
  C.length > 0 && this.commandContext.apply(new G(C), !0), await this.ensureStepsAreLoaded(), this.onElementsChange();
5371
5390
  const f = this.getInvalidModelVariants(), u = this.modelContainer;
5372
5391
  if (u) {
5373
- const I = f.map(
5392
+ const m = f.map(
5374
5393
  (p) => u.applyModelVariant(
5375
5394
  p,
5376
5395
  {
@@ -5379,7 +5398,7 @@ class jn {
5379
5398
  !1
5380
5399
  )
5381
5400
  );
5382
- await Promise.all(I);
5401
+ await Promise.all(m);
5383
5402
  }
5384
5403
  await this.onSelectionChange(), n && await n();
5385
5404
  }
@@ -6311,12 +6330,12 @@ const it = F`
6311
6330
  return [S, Y];
6312
6331
  }, [C] = await Q(!0), f = Object.fromEntries(
6313
6332
  Object.keys(C).map((y) => [y, C[y].map((S) => S.id)])
6314
- ), [u] = await Q(!1), m = Object.fromEntries(
6333
+ ), [u] = await Q(!1), I = Object.fromEntries(
6315
6334
  Object.keys(u).map((y) => [
6316
6335
  y,
6317
6336
  u[y].map((S) => S.id)
6318
6337
  ])
6319
- ), I = await s(w, n.id);
6338
+ ), m = await s(w, n.id);
6320
6339
  return {
6321
6340
  designDetails: (() => {
6322
6341
  const y = {
@@ -6328,7 +6347,7 @@ const it = F`
6328
6347
  workflowId: A.id,
6329
6348
  transactionId: n.id,
6330
6349
  useThreeDimPreview: !!w,
6331
- previewImage: I
6350
+ previewImage: m
6332
6351
  };
6333
6352
  if (E) {
6334
6353
  const S = [];
@@ -6338,7 +6357,7 @@ const it = F`
6338
6357
  }
6339
6358
  if (f) {
6340
6359
  const S = [];
6341
- for (const [Y, N] of Object.entries(m))
6360
+ for (const [Y, N] of Object.entries(I))
6342
6361
  S.push({ key: Y, ids: N });
6343
6362
  y.selectedVariants = S;
6344
6363
  }
@@ -6592,8 +6611,8 @@ class EA {
6592
6611
  let a = 2048;
6593
6612
  e && e <= 2048 && (a = e);
6594
6613
  const i = DA(a, a), s = this.commandContext.getAllLayouts(), o = t.defaultPreviewPanelIndex || 0, r = t.panels[o], g = s.find((u) => {
6595
- var m;
6596
- return ((m = u.layoutState) == null ? void 0 : m.layout.panelId) === (r == null ? void 0 : r.name);
6614
+ var I;
6615
+ return ((I = u.layoutState) == null ? void 0 : I.layout.panelId) === (r == null ? void 0 : r.name);
6597
6616
  }) || s[0], B = g.layoutState.layout.previewRegion ? {
6598
6617
  x: g.layoutState.layout.previewRegion.left,
6599
6618
  y: g.layoutState.layout.previewRegion.top,
@@ -6900,17 +6919,17 @@ const ga = [
6900
6919
  return console.error(s), [];
6901
6920
  }
6902
6921
  }, da = async (c, A, e, t) => {
6903
- var m, I;
6922
+ var I, m;
6904
6923
  const n = e.data, a = t.option;
6905
6924
  if (!a)
6906
6925
  return console.error(`No option for step ${t.stepName}.`), [];
6907
- const i = ((m = a.variants) == null ? void 0 : m.find((p) => p.id === n.illustrationVariantId)) || NA(a);
6926
+ const i = ((I = a.variants) == null ? void 0 : I.find((p) => p.id === n.illustrationVariantId)) || NA(a);
6908
6927
  if (!i)
6909
6928
  return console.error(`No variant with ID: ${n.illustrationVariantId}`), [];
6910
6929
  if (!i.asset)
6911
6930
  return console.error(`No asset for variant with ID: ${n.illustrationVariantId}`), [];
6912
6931
  A[t.stepName] = { selectedVariants: [i] };
6913
- const s = (I = i.asset) == null ? void 0 : I.fileLink;
6932
+ const s = (m = i.asset) == null ? void 0 : m.fileLink;
6914
6933
  if (!s)
6915
6934
  return console.error(`No asset link for variant with ID: ${n.illustrationVariantId}`), [];
6916
6935
  const o = await q(s, !0), r = /<svg.*?<\/svg>/s, g = o.match(r) || [], B = (g == null ? void 0 : g.length) > 0 ? g[0] : "", w = Ne().parseFromString(B, "image/svg+xml").firstElementChild;
@@ -9838,8 +9857,8 @@ class ui {
9838
9857
  if (E && await this.authenticateCustomerId(E)) {
9839
9858
  const C = ((d = (l = this.customer) == null ? void 0 : l.bundleStakeholders) == null ? void 0 : d.find(
9840
9859
  (f) => {
9841
- var u, m;
9842
- return (m = (u = f.bundle) == null ? void 0 : u.transactions) == null ? void 0 : m.some((I) => I.id === A);
9860
+ var u, I;
9861
+ return (I = (u = f.bundle) == null ? void 0 : u.transactions) == null ? void 0 : I.some((m) => m.id === A);
9843
9862
  }
9844
9863
  )) || ((h = (w = this.customer) == null ? void 0 : w.stakeholders) == null ? void 0 : h.find(
9845
9864
  (f) => {
@@ -10067,7 +10086,7 @@ class ui {
10067
10086
  var Q, C;
10068
10087
  const E = P.getShadowGraphqlClient();
10069
10088
  if (n.type === "transaction") {
10070
- const { transactionId: f, readOnly: u } = n, m = await E.query({
10089
+ const { transactionId: f, readOnly: u } = n, I = await E.query({
10071
10090
  query: BA,
10072
10091
  variables: {
10073
10092
  ids: [f]
@@ -10075,15 +10094,15 @@ class ui {
10075
10094
  errorPolicy: "all",
10076
10095
  fetchPolicy: "no-cache"
10077
10096
  });
10078
- if (!((Q = m.data) != null && Q.transactions) || m.data.transactions.length === 0)
10097
+ if (!((Q = I.data) != null && Q.transactions) || I.data.transactions.length === 0)
10079
10098
  throw new U("Existing transaction not found.");
10080
- const I = (C = m.data) == null ? void 0 : C.transactions[0];
10081
- if (!I.workflowId)
10099
+ const m = (C = I.data) == null ? void 0 : C.transactions[0];
10100
+ if (!m.workflowId)
10082
10101
  throw new U("Existing transaction has no workflow ID.");
10083
- const p = await QA(I.workflowId);
10084
- if (!I.product)
10102
+ const p = await QA(m.workflowId);
10103
+ if (!m.product)
10085
10104
  throw new U("Failed to load transaction, product not available.");
10086
- return { transaction: I, workflow: p, readOnly: u };
10105
+ return { transaction: m, workflow: p, readOnly: u };
10087
10106
  }
10088
10107
  if (n.type === "integration" || n.type === "external") {
10089
10108
  const f = async () => {
@@ -10108,8 +10127,8 @@ class ui {
10108
10127
  if (!y.product)
10109
10128
  throw new U("Failed to create transaction, product not available.");
10110
10129
  return y;
10111
- }, u = QA(n.workflowId, n == null ? void 0 : n.graphql), [m, I] = await Promise.all([f(), u]);
10112
- return { transaction: m, workflow: I };
10130
+ }, u = QA(n.workflowId, n == null ? void 0 : n.graphql), [I, m] = await Promise.all([f(), u]);
10131
+ return { transaction: I, workflow: m };
10113
10132
  }
10114
10133
  throw new U("No workflow ID provided.");
10115
10134
  }, { transaction: i, workflow: s, readOnly: o } = await a();
@@ -10166,19 +10185,19 @@ class ui {
10166
10185
  async getWorkflowExperiences(A, e) {
10167
10186
  if (A.length === 0)
10168
10187
  throw new U("No options provided!");
10169
- const t = P.getShadowGraphqlClient(), n = async (m) => {
10188
+ const t = P.getShadowGraphqlClient(), n = async (I) => {
10170
10189
  var y, S;
10171
- if (m.length === 0)
10190
+ if (I.length === 0)
10172
10191
  return [];
10173
- const I = m.map((Y) => Y.option.transactionId), p = await t.query({
10192
+ const m = I.map((Y) => Y.option.transactionId), p = await t.query({
10174
10193
  query: BA,
10175
10194
  variables: {
10176
- ids: I
10195
+ ids: m
10177
10196
  },
10178
10197
  errorPolicy: "all",
10179
10198
  fetchPolicy: "no-cache"
10180
10199
  }), M = p.data.transactions;
10181
- if (M.length !== m.length) {
10200
+ if (M.length !== I.length) {
10182
10201
  const Y = ((S = (y = p.errors) == null ? void 0 : y[0]) == null ? void 0 : S.message) || "Unknown error";
10183
10202
  throw new U(`Not all transactions were found: ${Y}`);
10184
10203
  }
@@ -10187,18 +10206,18 @@ class ui {
10187
10206
  return {
10188
10207
  transaction: Y,
10189
10208
  workflowId: Y.workflowId,
10190
- readOnly: ((H = m.find((T) => T.option.transactionId === Y.id)) == null ? void 0 : H.option.readOnly) ?? !1,
10191
- index: m[N].index
10209
+ readOnly: ((H = I.find((T) => T.option.transactionId === Y.id)) == null ? void 0 : H.option.readOnly) ?? !1,
10210
+ index: I[N].index
10192
10211
  };
10193
10212
  });
10194
- }, a = async (m) => {
10213
+ }, a = async (I) => {
10195
10214
  var M, y, S;
10196
- if (m.length === 0)
10215
+ if (I.length === 0)
10197
10216
  return [];
10198
- const I = await t.mutate({
10217
+ const m = await t.mutate({
10199
10218
  mutation: sn,
10200
10219
  variables: {
10201
- inputs: m.map((Y) => ({
10220
+ inputs: I.map((Y) => ({
10202
10221
  integrationProductId: Y.option.type === "integration" ? Y.option.integrationProductId : void 0,
10203
10222
  externalIntegrationId: Y.option.type === "external" ? Y.option.externalIntegrationId : void 0,
10204
10223
  externalProductId: Y.option.type === "external" ? Y.option.externalProductId : void 0,
@@ -10208,29 +10227,29 @@ class ui {
10208
10227
  },
10209
10228
  errorPolicy: "all",
10210
10229
  fetchPolicy: "no-cache"
10211
- }), p = (M = I.data) == null ? void 0 : M.transactionCreateMany;
10230
+ }), p = (M = m.data) == null ? void 0 : M.transactionCreateMany;
10212
10231
  if (!p || p.length === 0) {
10213
- const Y = ((S = (y = I.errors) == null ? void 0 : y[0]) == null ? void 0 : S.message) || "Unknown error";
10232
+ const Y = ((S = (y = m.errors) == null ? void 0 : y[0]) == null ? void 0 : S.message) || "Unknown error";
10214
10233
  throw new U(`Failed to create transactions: ${Y}`);
10215
10234
  }
10216
10235
  return p.map((Y, N) => ({
10217
10236
  transaction: Y,
10218
10237
  workflowId: Y.workflowId,
10219
10238
  readOnly: !1,
10220
- index: m[N].index
10239
+ index: I[N].index
10221
10240
  }));
10222
- }, i = A.map((m, I) => ({ option: m, index: I })), s = i.filter((m) => m.option.type === "transaction"), o = i.filter(
10223
- (m) => m.option.type === "integration" || m.option.type === "external"
10241
+ }, i = A.map((I, m) => ({ option: I, index: m })), s = i.filter((I) => I.option.type === "transaction"), o = i.filter(
10242
+ (I) => I.option.type === "integration" || I.option.type === "external"
10224
10243
  ), r = Ee(s, 10), g = Ee(o, 10), B = (await Promise.all([
10225
10244
  ...r.map(n),
10226
10245
  ...g.map(a)
10227
- ])).flat(), l = [...new Set(B.map((m) => m.workflowId))], d = await lt(l, e), w = new Map(d.map((m) => [m.id, m])), h = x.getMap("transactionOwnerIds") || /* @__PURE__ */ new Map(), E = B.map(async (m) => {
10246
+ ])).flat(), l = [...new Set(B.map((I) => I.workflowId))], d = await lt(l, e), w = new Map(d.map((I) => [I.id, I])), h = x.getMap("transactionOwnerIds") || /* @__PURE__ */ new Map(), E = B.map(async (I) => {
10228
10247
  var T;
10229
- const { transaction: I, workflowId: p, readOnly: M, index: y } = m, S = w.get(p), Y = A[y];
10230
- !h.get(I.id) && I.transactionOwnerId && h.set(I.id, I.transactionOwnerId);
10231
- const N = h.get(I.id) || void 0, H = {
10232
- product: I.product,
10233
- transaction: I,
10248
+ const { transaction: m, workflowId: p, readOnly: M, index: y } = I, S = w.get(p), Y = A[y];
10249
+ !h.get(m.id) && m.transactionOwnerId && h.set(m.id, m.transactionOwnerId);
10250
+ const N = h.get(m.id) || void 0, H = {
10251
+ product: m.product,
10252
+ transaction: m,
10234
10253
  layouts: [],
10235
10254
  singleVariantsRenderable: (T = Y == null ? void 0 : Y.workflowConfiguration) == null ? void 0 : T.singleVariantsRenderable,
10236
10255
  stateMutationFunc: M ? async () => {
@@ -10240,8 +10259,8 @@ class ui {
10240
10259
  workflow: S,
10241
10260
  isReloadedTransaction: Y.type === "transaction"
10242
10261
  };
10243
- if (Y.type === "transaction" && I.workflowState) {
10244
- const b = JSON.parse(I.workflowState);
10262
+ if (Y.type === "transaction" && m.workflowState) {
10263
+ const b = JSON.parse(m.workflowState);
10245
10264
  H.layouts = Object.values(b.layouts).map((V) => V.layout), await _(b), await AA(b), H.reloadedState = b;
10246
10265
  } else if (!M && Y.workflowState) {
10247
10266
  const b = JSON.parse(Y.workflowState);
@@ -10256,11 +10275,11 @@ class ui {
10256
10275
  ), H.delayWorkflowStateSync = !0, this.initialized = !0, this.experienceOptions = H, { experienceOptions: H, index: y, options: Y };
10257
10276
  });
10258
10277
  x.setMap("transactionOwnerIds", h);
10259
- const f = (await Promise.all(E)).sort((m, I) => m.index - I.index).map(async (m) => {
10260
- const { experienceOptions: I, options: p } = m, M = new EA(this, I);
10278
+ const f = (await Promise.all(E)).sort((I, m) => I.index - m.index).map(async (I) => {
10279
+ const { experienceOptions: m, options: p } = I, M = new EA(this, m);
10261
10280
  return await M.getWorkflowManager().getInitializationPromise(), p.type !== "transaction" && this.customer && await M.attachCustomerDetails({ email: this.customer.emailAddress }), M;
10262
10281
  }), u = await Promise.all(f);
10263
- return u.forEach((m) => m.getWorkflowManager().setWorkflowStateSyncEnabled(!0)), u;
10282
+ return u.forEach((I) => I.getWorkflowManager().setWorkflowStateSyncEnabled(!0)), u;
10264
10283
  }
10265
10284
  /**
10266
10285
  * Initialize the client from an integration product.