@spiffcommerce/core 21.9.0-alpha.5 → 21.9.0-alpha.7

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,27 +1,27 @@
1
1
  import { createHttpLink as EA, InMemoryCache as uA, ApolloClient as CA, from as QA, gql as D } from "@apollo/client/core";
2
- import { fetch as Ue, AssetType as dt, fetchAsArrayBuffer as Yt, StepType as y, getFrameData as _e, frameDataCache as mA, GroupCommand as G, UpdateFramePattern as St, UpdateFrameThresholdSettingsCommand as pA, calculateOffsets as et, LayoutElementType as k, generate as J, CreateElementCommand as T, generateSVGWithUnknownColors as Pt, svgObjectURL as ye, fetchAsString as Z, DeleteElementCommand as $, generateDefaultRectangleFrameSvg as wt, GetSVGDimensions as IA, patternImageDataCache as ht, getAttributesFromArrayBuffer as fA, findElement as Me, modifySVGWithElementProperties as DA, IllustrationColorCommand as Ve, IllustrationCacheCommand as FA, getFontMetrics as yA, getPatternImageData as We, FontAlignmentCommand as MA, FontColorCommand as YA, FontImageFillCommand as Le, applyTextTransformations as Xe, determineCorrectFontSizeAndLines as fe, FontSourceCommand as Et, loadFont as tt, TextChangeCommand as SA, FontSizeCommand as PA, createElementNS as xA, createElement as he, _loadFontExternalDataURL as At, UpdateWorkflowStateCommand as ut, CommandContext as NA, createCanvas as Ye, getSvgElement as xt, LayoutRenderingPurpose as Nt, renderPapyrusComponentAsString as Ht, loadImage as Rt, getDomParser as Ut, toBase64 as Ct, getVariant as HA, generateFrameSVG as RA, getDefaultVariant as Ge, domParser as Gt, sanitizeSvgTree as vt, traverse as UA, xmlSerializer as kt, CreateLayoutCommand as GA, AspectType as ce, rehydrateSerializedLayout as ee } from "@spiffcommerce/papyrus";
3
- import { AspectType as Wi, AssetType as Xi, BringForwardCommand as qi, BringToBackCommand as Zi, BringToFrontCommand as $i, CanvasCommand as _i, CommandContext as es, CreateElementCommand as ts, CreateLayoutCommand as As, DeleteElementCommand as as, FontAlignmentCommand as ns, FontColorCommand as is, FontSizeCommand as ss, FontSourceCommand as os, GroupCommand as rs, LayoutElementFactory as cs, LayoutElementType as gs, MoveCommand as ls, ResizeCommand as Bs, RotateCommand as ds, SendBackwardsCommand as ws, StepAspectType as hs, StepType as Es, TextChangeCommand as us, UnitOfMeasurement as Cs, dataUrlFromExternalUrl as Qs, determineCorrectFontSizeAndLines as ms, findElement as ps, frameDataCache as Is, generate as fs, generateSVGWithUnknownColors as Ds, getAttributesFromArrayBuffer as Fs, getAxisAlignedBoundingBox as ys, getFrameData as Ms, getSvgElement as Ys, loadFont as Ss, patternImageDataCache as Ps, registerFetchImplementation as xs, registerWindowImplementation as Ns, rehydrateSerializedLayout as Hs, setCanvasModule as Rs } from "@spiffcommerce/papyrus";
2
+ import { fetch as Ue, AssetType as dt, fetchAsArrayBuffer as St, StepType as y, getFrameData as _e, frameDataCache as mA, GroupCommand as G, UpdateFramePattern as Yt, UpdateFrameThresholdSettingsCommand as pA, calculateOffsets as et, LayoutElementType as k, generate as J, CreateElementCommand as O, generateSVGWithUnknownColors as Pt, svgObjectURL as ye, fetchAsString as Z, DeleteElementCommand as $, generateDefaultRectangleFrameSvg as wt, GetSVGDimensions as IA, patternImageDataCache as ht, getAttributesFromArrayBuffer as fA, findElement as Me, modifySVGWithElementProperties as DA, IllustrationColorCommand as Ve, IllustrationCacheCommand as FA, getFontMetrics as yA, getPatternImageData as We, FontAlignmentCommand as MA, FontColorCommand as SA, FontImageFillCommand as Le, applyTextTransformations as Xe, determineCorrectFontSizeAndLines as fe, FontSourceCommand as Et, loadFont as tt, TextChangeCommand as YA, FontSizeCommand as PA, createElementNS as xA, createElement as he, _loadFontExternalDataURL as At, UpdateWorkflowStateCommand as ut, CommandContext as NA, createCanvas as Se, getSvgElement as xt, LayoutRenderingPurpose as Nt, renderPapyrusComponentAsString as Ht, loadImage as Rt, getDomParser as Ut, toBase64 as Ct, getVariant as HA, generateFrameSVG as RA, getDefaultVariant as Ge, domParser as Gt, sanitizeSvgTree as vt, traverse as UA, xmlSerializer as kt, CreateLayoutCommand as GA, AspectType as ce, rehydrateSerializedLayout as ee } from "@spiffcommerce/papyrus";
3
+ import { AspectType as Wi, AssetType as Xi, BringForwardCommand as qi, BringToBackCommand as Zi, BringToFrontCommand as $i, CanvasCommand as _i, CommandContext as es, CreateElementCommand as ts, CreateLayoutCommand as As, DeleteElementCommand as as, FontAlignmentCommand as ns, FontColorCommand as is, FontSizeCommand as ss, FontSourceCommand as os, GroupCommand as rs, LayoutElementFactory as cs, LayoutElementType as gs, MoveCommand as ls, ResizeCommand as Bs, RotateCommand as ds, SendBackwardsCommand as ws, StepAspectType as hs, StepType as Es, TextChangeCommand as us, UnitOfMeasurement as Cs, dataUrlFromExternalUrl as Qs, determineCorrectFontSizeAndLines as ms, findElement as ps, frameDataCache as Is, generate as fs, generateSVGWithUnknownColors as Ds, getAttributesFromArrayBuffer as Fs, getAxisAlignedBoundingBox as ys, getFrameData as Ms, getSvgElement as Ss, loadFont as Ys, patternImageDataCache as Ps, registerFetchImplementation as xs, registerWindowImplementation as Ns, rehydrateSerializedLayout as Hs, setCanvasModule as Rs } from "@spiffcommerce/papyrus";
4
4
  import { setContext as vA } from "@apollo/client/link/context";
5
5
  import { onError as kA } from "@apollo/client/link/error";
6
6
  import { Pith as bt } from "pith";
7
7
  import Jt from "lodash.debounce";
8
8
  import Lt from "lodash.isequal";
9
9
  import le from "lodash.clonedeep";
10
- import { toString as Tt } from "qrcode";
10
+ import { toString as Ot } from "qrcode";
11
11
  import { split as qe } from "unicode-default-word-boundary";
12
12
  import at from "svg-path-bbox";
13
13
  import Qt from "lodash.chunk";
14
- class Ot extends Error {
14
+ class Tt extends Error {
15
15
  constructor(e) {
16
16
  super(e), this.name = this.constructor.name;
17
17
  }
18
18
  }
19
- class we extends Ot {
19
+ class we extends Tt {
20
20
  constructor(e) {
21
21
  super(`ConfigurationError - ${e}`);
22
22
  }
23
23
  }
24
- class Se extends we {
24
+ class Ye extends we {
25
25
  constructor(e) {
26
26
  super(`Option not Configured: ${e.stepTitle}`), this.optionId = (e == null ? void 0 : e.optionId) || "N/A";
27
27
  }
@@ -46,7 +46,7 @@ class Pe extends we {
46
46
  super(`Workflow Misconfiguration: ${e.stepName} - ${t}`), this.step = e;
47
47
  }
48
48
  }
49
- class ve extends Ot {
49
+ class ve extends Tt {
50
50
  constructor(e) {
51
51
  super(`ImplementationError - ${e}`);
52
52
  }
@@ -153,9 +153,9 @@ const pt = (c) => {
153
153
  zt = c;
154
154
  };
155
155
  let nt;
156
- const TA = (c) => {
156
+ const OA = (c) => {
157
157
  nt = c;
158
- }, OA = () => nt, zA = () => new Promise((c) => {
158
+ }, TA = () => nt, zA = () => new Promise((c) => {
159
159
  const e = q.getHubUrl(), t = (A) => {
160
160
  A.origin === e && (window.removeEventListener("message", t), c(A.data));
161
161
  };
@@ -446,7 +446,7 @@ class ea {
446
446
  g.lengthComputable && A(g.loaded * 100 / g.total);
447
447
  }, r.onload = () => {
448
448
  const g = i.assetResponse.asset;
449
- Te.add(i.assetResponse.asset), s(g);
449
+ Oe.add(i.assetResponse.asset), s(g);
450
450
  }, r.onerror = o, r.send(e.blob);
451
451
  }), this.cacheAsset(i.assetResponse.asset), i.assetResponse.asset;
452
452
  }
@@ -471,7 +471,7 @@ class ea {
471
471
  if (this.bgrmCache.has(e.key))
472
472
  return this.bgrmCache.get(e.key);
473
473
  const A = (async () => {
474
- const a = await Yt(e.fileLink), n = await this.removeBackground(new Blob([a], { type: e.mimeType })), i = {
474
+ const a = await St(e.fileLink), n = await this.removeBackground(new Blob([a], { type: e.mimeType })), i = {
475
475
  name: e.key + "_removed_bg",
476
476
  blob: n
477
477
  };
@@ -480,10 +480,10 @@ class ea {
480
480
  return this.bgrmCache.set(e.key, A), A;
481
481
  }
482
482
  removePersistedAsset(e) {
483
- Te.remove(e);
483
+ Oe.remove(e);
484
484
  }
485
485
  getPersistedAssets() {
486
- return Te.list();
486
+ return Oe.list();
487
487
  }
488
488
  /**
489
489
  * Handles mimeType resolution & asset creation request
@@ -535,7 +535,7 @@ class ea {
535
535
  }
536
536
  }
537
537
  const ie = "persistentAssets";
538
- class Te {
538
+ class Oe {
539
539
  /**
540
540
  * Add a new asset to persistence
541
541
  * @param asset The asset to add.
@@ -1569,7 +1569,7 @@ class fa {
1569
1569
  n.forEach((o, r) => {
1570
1570
  s(
1571
1571
  new G([
1572
- new St(o, t, e[r]),
1572
+ new Yt(o, t, e[r]),
1573
1573
  new pA(o, a.useThreshold, a.invertThreshold, a.threshold, a.thresholdSaturation)
1574
1574
  ])
1575
1575
  );
@@ -1634,7 +1634,7 @@ class ft {
1634
1634
  id: d.id,
1635
1635
  region: a
1636
1636
  },
1637
- command: new T(d, n)
1637
+ command: new O(d, n)
1638
1638
  };
1639
1639
  } else {
1640
1640
  const l = this.configuration.type === y.SilentIllustration ? (B = this.configuration.data.asset) == null ? void 0 : B.fileLink : i, w = await Pt(await (async () => new Promise((h, C) => {
@@ -1669,7 +1669,7 @@ class ft {
1669
1669
  id: E.id,
1670
1670
  region: a
1671
1671
  },
1672
- command: new T(E, n)
1672
+ command: new O(E, n)
1673
1673
  };
1674
1674
  }
1675
1675
  }, this.configuration = e, this.layouts = t, this.product = A || void 0;
@@ -1799,7 +1799,7 @@ class Fa {
1799
1799
  return e.data.regions.map(t);
1800
1800
  }
1801
1801
  async command(e, t, A, a) {
1802
- const n = A.getLayouts(), s = `data:image/svg+xml;base64,${btoa(await Tt(e, { type: "svg" }))}`, o = t.map((r) => {
1802
+ const n = A.getLayouts(), s = `data:image/svg+xml;base64,${btoa(await Ot(e, { type: "svg" }))}`, o = t.map((r) => {
1803
1803
  const g = r.region, B = n.find((l) => l.panelId === (g == null ? void 0 : g.panelId));
1804
1804
  if (!B && g)
1805
1805
  throw new z(g);
@@ -1807,7 +1807,7 @@ class Fa {
1807
1807
  throw new Error("Region not found");
1808
1808
  if (!B || !g)
1809
1809
  throw new Error("Neither a region or layout found!");
1810
- return new T(
1810
+ return new O(
1811
1811
  {
1812
1812
  stepRegion: g,
1813
1813
  stepName: a,
@@ -1921,23 +1921,25 @@ class Ma {
1921
1921
  }
1922
1922
  }
1923
1923
  selectImage(e, t, A) {
1924
- A.setEditedStatus(e.stepName, !0), (t.fileLink || "").endsWith("pdf") ? A.addPoller(
1925
- new Zt(
1926
- async () => {
1927
- var o;
1928
- const i = (o = (await v.getLocalOrFromServer(t.key || "")).versions) == null ? void 0 : o.find((r) => r.name === "svg");
1929
- return i ? (await fetch(i.link)).status === 200 : !1;
1930
- },
1931
- () => {
1932
- v.getLocalOrFromServer(t.key || "").then((n) => {
1933
- this.loadPatternFromAsset(n, e, A);
1934
- });
1935
- },
1936
- () => {
1937
- throw new ke("Failed to resolve transcoded PDF");
1938
- }
1939
- )
1940
- ) : this.loadPatternFromAsset(t, e, A);
1924
+ return A.setEditedStatus(e.stepName, !0), (t.fileLink || "").endsWith("pdf") ? new Promise((n) => {
1925
+ A.addPoller(
1926
+ new Zt(
1927
+ async () => {
1928
+ var r;
1929
+ const s = (r = (await v.getLocalOrFromServer(t.key || "")).versions) == null ? void 0 : r.find((g) => g.name === "svg");
1930
+ return s ? (await fetch(s.link)).status === 200 : !1;
1931
+ },
1932
+ () => {
1933
+ v.getLocalOrFromServer(t.key || "").then((i) => {
1934
+ this.loadPatternFromAsset(i, e, A).then(n);
1935
+ });
1936
+ },
1937
+ () => {
1938
+ throw new ke("Failed to resolve transcoded PDF");
1939
+ }
1940
+ )
1941
+ );
1942
+ }) : this.loadPatternFromAsset(t, e, A);
1941
1943
  }
1942
1944
  async selectVariant(e, t, A, a, n) {
1943
1945
  const i = await this.selectVariantCommand(
@@ -1950,7 +1952,7 @@ class Ma {
1950
1952
  i && (i.command && a.getCommandDispatcher()(i.command), i.followup && await i.followup());
1951
1953
  }
1952
1954
  getCreateElementCommand(e, t, A, a) {
1953
- return new T(
1955
+ return new O(
1954
1956
  {
1955
1957
  id: e,
1956
1958
  type: k.Frame,
@@ -1988,7 +1990,7 @@ class Ma {
1988
1990
  };
1989
1991
  ht.set(e, i), t.setPatternData(i);
1990
1992
  } else {
1991
- const A = await Yt(e, !0), a = await fA(A), n = {
1993
+ const A = await St(e, !0), a = await fA(A), n = {
1992
1994
  src: e,
1993
1995
  width: a.width,
1994
1996
  height: a.height,
@@ -2085,7 +2087,7 @@ class Ma {
2085
2087
  }
2086
2088
  }
2087
2089
  const De = new Ma();
2088
- class Ya {
2090
+ class Sa {
2089
2091
  async getIllustrationBody(e) {
2090
2092
  return new Promise((t) => {
2091
2093
  Z(e, !0).then((A) => {
@@ -2094,7 +2096,7 @@ class Ya {
2094
2096
  });
2095
2097
  }
2096
2098
  getCreateElementCommand(e, t, A, a) {
2097
- return new T(
2099
+ return new O(
2098
2100
  {
2099
2101
  stepRegion: t,
2100
2102
  stepName: a.stepName,
@@ -2297,12 +2299,12 @@ class Ya {
2297
2299
  };
2298
2300
  }
2299
2301
  }
2300
- const Fe = new Ya();
2301
- class Sa {
2302
+ const Fe = new Sa();
2303
+ class Ya {
2302
2304
  async init(e, t, A) {
2303
2305
  const a = e.option;
2304
2306
  if (!a)
2305
- throw new Se(e);
2307
+ throw new Ye(e);
2306
2308
  if (A)
2307
2309
  await this.reload(e, t, A);
2308
2310
  else {
@@ -2320,7 +2322,7 @@ class Sa {
2320
2322
  A.serializableWorkflow.steps
2321
2323
  ), s = Object.values(A.layouts).map((g) => g.elements).flat().filter((g) => g.stepName === e.stepName), o = e.option;
2322
2324
  if (!o)
2323
- throw new Se(e);
2325
+ throw new Ye(e);
2324
2326
  if (a != null && a.selectedVariants) {
2325
2327
  const g = a.selectedVariants[0].id;
2326
2328
  if (g) {
@@ -2371,12 +2373,12 @@ class Sa {
2371
2373
  };
2372
2374
  }
2373
2375
  }
2374
- const $t = new Sa();
2376
+ const $t = new Ya();
2375
2377
  class Pa {
2376
2378
  async init(e, t, A) {
2377
2379
  const a = e.option;
2378
2380
  if (!a)
2379
- throw new Se(e);
2381
+ throw new Ye(e);
2380
2382
  if (A)
2381
2383
  await this.reload(e, t, A);
2382
2384
  else {
@@ -2498,7 +2500,7 @@ class xa {
2498
2500
  return console.error(`Can not find layout for region: ${l.panelId}`), null;
2499
2501
  const C = [];
2500
2502
  return d && C.push(new $(w)), C.push(
2501
- new T(
2503
+ new O(
2502
2504
  {
2503
2505
  stepRegion: l,
2504
2506
  stepName: e.stepName,
@@ -2626,7 +2628,7 @@ class Ha {
2626
2628
  const w = J();
2627
2629
  return {
2628
2630
  regionElement: { id: w, region: B },
2629
- command: new T(
2631
+ command: new O(
2630
2632
  {
2631
2633
  stepName: e.stepName,
2632
2634
  stepRegion: B,
@@ -2748,7 +2750,7 @@ class Ua {
2748
2750
  async init(e, t, A) {
2749
2751
  const a = e.option;
2750
2752
  if (!a)
2751
- throw new Se(e);
2753
+ throw new Ye(e);
2752
2754
  if (A)
2753
2755
  await this.reload(e, t, A);
2754
2756
  else {
@@ -2856,7 +2858,7 @@ class Ua {
2856
2858
  return {
2857
2859
  id: u,
2858
2860
  region: d,
2859
- command: new T(
2861
+ command: new O(
2860
2862
  {
2861
2863
  stepRegion: d,
2862
2864
  stepName: e.stepName,
@@ -2917,7 +2919,7 @@ class Ga {
2917
2919
  );
2918
2920
  }
2919
2921
  }
2920
- const va = new Ga(), Oe = 30;
2922
+ const va = new Ga(), Te = 30;
2921
2923
  class Ne extends Error {
2922
2924
  constructor(e) {
2923
2925
  super(e), Object.setPrototypeOf(this, new.target.prototype), this.name = Ne.name;
@@ -3051,7 +3053,7 @@ class ba {
3051
3053
  for (const r of A) {
3052
3054
  if (!t.fill)
3053
3055
  throw new Error("Fill not set on new color selection!");
3054
- const g = new YA(r.id, t.fill, s);
3056
+ const g = new SA(r.id, t.fill, s);
3055
3057
  n(g);
3056
3058
  }
3057
3059
  }
@@ -3228,7 +3230,7 @@ class ba {
3228
3230
  }
3229
3231
  const d = await this.changeInputTextWithRegion(
3230
3232
  e,
3231
- e.data.size || Oe,
3233
+ e.data.size || Te,
3232
3234
  g,
3233
3235
  A.text || "",
3234
3236
  A,
@@ -3253,7 +3255,7 @@ class ba {
3253
3255
  n
3254
3256
  ), d = await this.changeInputTextWithRegion(
3255
3257
  e,
3256
- e.data.size || Oe,
3258
+ e.data.size || Te,
3257
3259
  g,
3258
3260
  ((B = l[0]) == null ? void 0 : B.newElement.input) || A.text || e.data.defaultText || "",
3259
3261
  A,
@@ -3297,8 +3299,8 @@ class ba {
3297
3299
  let C;
3298
3300
  if (h && h.variants) {
3299
3301
  const N = h.variants.find((H) => {
3300
- var O;
3301
- return H.id === ((O = h.defaultVariant) == null ? void 0 : O.id);
3302
+ var T;
3303
+ return H.id === ((T = h.defaultVariant) == null ? void 0 : T.id);
3302
3304
  }) || h.variants[0];
3303
3305
  C = this.createTextFillSpotColor(h, N), i.updateStorage(e, {
3304
3306
  colorProfileAssetKey: (E = h.colorProfile) == null ? void 0 : E.key
@@ -3309,7 +3311,7 @@ class ba {
3309
3311
  stepName: e,
3310
3312
  align: this.textAlign(A),
3311
3313
  fill: n.color ? n.color : f,
3312
- fontSize: A.size || Oe,
3314
+ fontSize: A.size || Te,
3313
3315
  fontData: a,
3314
3316
  id: w,
3315
3317
  layer: B.layer,
@@ -3346,15 +3348,15 @@ class ba {
3346
3348
  { size: A.size, minSize: A.minSize, maxSize: A.maxSize }
3347
3349
  );
3348
3350
  p.set(Q.id, F), I.set(Q.id, M);
3349
- const S = A.curved || A.vertical ? o : (M || []).join(`
3351
+ const Y = A.curved || A.vertical ? o : (M || []).join(`
3350
3352
  `);
3351
3353
  m.push(
3352
- this.generateTextChangeCommandsForRegion(F, A, Q.id, S)
3354
+ this.generateTextChangeCommandsForRegion(F, A, Q.id, Y)
3353
3355
  );
3354
- const Y = new T(Q, d);
3356
+ const S = new O(Q, d);
3355
3357
  return {
3356
3358
  regionElement: { id: w, region: B },
3357
- commands: [Y, ...m],
3359
+ commands: [S, ...m],
3358
3360
  newElement: Q,
3359
3361
  fontData: a
3360
3362
  };
@@ -3378,7 +3380,7 @@ class ba {
3378
3380
  ), g;
3379
3381
  }
3380
3382
  generateTextChangeCommandsForRegion(e, t, A, a) {
3381
- const n = [], i = new SA(A, a);
3383
+ const n = [], i = new YA(A, a);
3382
3384
  if (n.push(i), !t.size) {
3383
3385
  const o = new PA(A, e);
3384
3386
  n.push(o);
@@ -4706,15 +4708,15 @@ IfnI8vaNAAAAAElFTkSuQmCC" transform="matrix(0.13 0.0141 -0.0141 0.1301 104.926 1
4706
4708
  `, R = (c) => xA("http://www.w3.org/2000/svg", c), ot = (c, e) => {
4707
4709
  const t = R("rect");
4708
4710
  return t.setAttribute("height", `${c}`), t.setAttribute("width", `${e}`), t;
4709
- }, Ta = () => {
4711
+ }, Oa = () => {
4710
4712
  const c = R("svg");
4711
4713
  return c.setAttribute("xmlns", "http://www.w3.org/2000/svg"), c.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink"), c.setAttribute("version", "1.1"), c;
4712
- }, Oa = (c) => {
4714
+ }, Ta = (c) => {
4713
4715
  const e = R("use");
4714
4716
  return e.setAttribute("xlink:href", c), e.setAttribute("href", c), e;
4715
4717
  };
4716
4718
  function AA(c) {
4717
- const e = Ta(), t = /viewBox="0 0 (.+?) (.+?)"/.exec(c) || ["0", "0"], A = parseFloat(t[1]), a = parseFloat(t[2]);
4719
+ const e = Oa(), t = /viewBox="0 0 (.+?) (.+?)"/.exec(c) || ["0", "0"], A = parseFloat(t[1]), a = parseFloat(t[2]);
4718
4720
  return e.setAttribute("height", `${a}`), e.setAttribute("width", `${A}`), [e, a, A];
4719
4721
  }
4720
4722
  const za = (c, e, t) => {
@@ -4723,7 +4725,7 @@ const za = (c, e, t) => {
4723
4725
  };
4724
4726
  function aA(c, e, t) {
4725
4727
  const A = J();
4726
- za(e, t, `bgdef-${A}`), c.appendChild(Oa(`#bgdef-${A}`));
4728
+ za(e, t, `bgdef-${A}`), c.appendChild(Ta(`#bgdef-${A}`));
4727
4729
  }
4728
4730
  const nA = (c, e, t, A) => {
4729
4731
  const a = he("filter");
@@ -4888,8 +4890,8 @@ class ja extends st {
4888
4890
  m.appendChild(F), F.setAttribute("fill", "red"), F.setAttribute("stroke", "red"), F.setAttribute("stroke-width", "9"), F.innerHTML = A;
4889
4891
  const M = R("g");
4890
4892
  m.appendChild(M), M.setAttribute("fill", "#9d2621"), M.setAttribute("transform", "translate(1,1)"), M.innerHTML = A;
4891
- const S = R("g");
4892
- return m.appendChild(S), S.setAttribute("fill", "yellow"), S.innerHTML = A, new ct(m).transform(([N, H]) => [N, H + (n / 2 - N) ** 2 / (n * 2.9)]), m;
4893
+ const Y = R("g");
4894
+ return m.appendChild(Y), Y.setAttribute("fill", "yellow"), Y.innerHTML = A, new ct(m).transform(([N, H]) => [N, H + (n / 2 - N) ** 2 / (n * 2.9)]), m;
4893
4895
  }, [o, r, g] = AA(t);
4894
4896
  if (!o)
4895
4897
  return "";
@@ -4928,13 +4930,13 @@ class Wa extends st {
4928
4930
  I.appendChild(F), F.setAttribute("stroke", "#5C1A0D"), F.setAttribute("stroke-width", "4"), F.setAttribute("transform", "translate(1,1)"), F.innerHTML = a;
4929
4931
  const M = R("g");
4930
4932
  I.appendChild(M), M.setAttribute("fill", "#FFE386"), M.setAttribute("transform", "translate(1,1)"), M.innerHTML = a;
4931
- const S = R("g");
4932
- I.appendChild(S), S.setAttribute("fill", "white"), S.innerHTML = a;
4933
- const Y = new ct(I);
4934
- return Y.transform(([N, H]) => [N, H + ((s - N) * H) ** 2 / (s * 5e4)]), Y.transform(([N, H]) => [
4933
+ const Y = R("g");
4934
+ I.appendChild(Y), Y.setAttribute("fill", "white"), Y.innerHTML = a;
4935
+ const S = new ct(I);
4936
+ return S.transform(([N, H]) => [N, H + ((s - N) * H) ** 2 / (s * 5e4)]), S.transform(([N, H]) => [
4935
4937
  N,
4936
4938
  H + (s / 3 - N) ** 2 / s * this.indicator(N < s / 3)
4937
- ]), Y.transform(([N, H]) => [N - (i - H) * (s - N) / 800, H]), I;
4939
+ ]), S.transform(([N, H]) => [N - (i - H) * (s - N) / 800, H]), I;
4938
4940
  }, [g, B, l] = AA(t);
4939
4941
  if (!g)
4940
4942
  return "";
@@ -4981,7 +4983,7 @@ class qa extends st {
4981
4983
  const F = R("g");
4982
4984
  F.classList.add("module-layer2"), f.appendChild(F), F.setAttribute("fill", "rgb(255,209,0)"), F.setAttribute("transform", "translate(1,-0.1)"), F.innerHTML = s;
4983
4985
  const M = R("g");
4984
- return M.classList.add("module-layer3"), f.appendChild(M), M.setAttribute("fill", "white"), M.innerHTML = s, new ct(f).transform(([Y, N]) => [Y, N + (r / 2 - Y) ** 2 / (r * 6)]), f;
4986
+ return M.classList.add("module-layer3"), f.appendChild(M), M.setAttribute("fill", "white"), M.innerHTML = s, new ct(f).transform(([S, N]) => [S, N + (r / 2 - S) ** 2 / (r * 6)]), f;
4985
4987
  }, l = R("g");
4986
4988
  l.classList.add("module-root");
4987
4989
  const d = R("defs");
@@ -6180,7 +6182,7 @@ class Ce {
6180
6182
  case y.Model:
6181
6183
  return new tn(e, t);
6182
6184
  case y.Frame:
6183
- return new Yi(e, t);
6185
+ return new Si(e, t);
6184
6186
  default:
6185
6187
  throw new b(`Step type ${t.type} not yet supported in Core SDK`);
6186
6188
  }
@@ -6383,38 +6385,38 @@ const rA = D`
6383
6385
  }, gA = async (c, e, t, A, a, n, i, s, o, r) => {
6384
6386
  var F;
6385
6387
  await (async () => {
6386
- var O;
6388
+ var T;
6387
6389
  if (r !== void 0)
6388
6390
  return r;
6389
6391
  await c.outstandingRequestsPromise();
6390
- const S = (P.getMap("transactionOwnerIds") || /* @__PURE__ */ new Map()).get(a.id), N = await x.getShadowGraphqlClient().query({
6392
+ const Y = (P.getMap("transactionOwnerIds") || /* @__PURE__ */ new Map()).get(a.id), N = await x.getShadowGraphqlClient().query({
6391
6393
  query: Vt,
6392
6394
  variables: { ids: [a.id] },
6393
6395
  fetchPolicy: "no-cache",
6394
6396
  errorPolicy: "all",
6395
6397
  context: {
6396
- transactionOwnerId: S
6398
+ transactionOwnerId: Y
6397
6399
  }
6398
- }), H = (O = N.data) == null ? void 0 : O.transactions[0].workflowState;
6400
+ }), H = (T = N.data) == null ? void 0 : T.transactions[0].workflowState;
6399
6401
  return N.errors ? (N.errors.forEach((L) => {
6400
6402
  N.errors && console.log("Server Error:", L.message);
6401
6403
  }), null) : H ?? null;
6402
6404
  })() || (console.warn("State mismatch detected. Uploading known state explicitly"), console.warn("State Object:", JSON.stringify(A())), await c.updateStateWithServerImmediate(A), console.log("Server state is undefined @ Workflow completion"));
6403
6405
  const l = c.getPreviewService(), d = (F = e == null ? void 0 : e.finalizeStepConfig) == null ? void 0 : F.lookAtAnimation, w = l && e.showModelOnFinishStep && !!d, E = o && $e(o, e, !0), h = o && $e(o, e, !1), C = async (M) => {
6404
- const S = {};
6405
- let Y = 0;
6406
+ const Y = {};
6407
+ let S = 0;
6406
6408
  if (Object.keys(n).length > 0)
6407
6409
  for (const N of Object.keys(n)) {
6408
- const H = n[N], O = e.steps.find((L) => L.stepName === N);
6410
+ const H = n[N], T = e.steps.find((L) => L.stepName === N);
6409
6411
  for (let L = 0; L < H.selections.length; ++L) {
6410
6412
  const V = H.selections[L];
6411
- if (O && (!M || O.option && (O.option.variants || []).length > 1 && !O.data.hideSelectionInCart && !O.data.hideSelectionsInCart)) {
6412
- const Je = O.stepTitle;
6413
- S[Je] ? S[Je].push({
6413
+ if (T && (!M || T.option && (T.option.variants || []).length > 1 && !T.data.hideSelectionInCart && !T.data.hideSelectionsInCart)) {
6414
+ const Je = T.stepTitle;
6415
+ Y[Je] ? Y[Je].push({
6414
6416
  id: V.id || "",
6415
6417
  name: V.name,
6416
6418
  priceModifier: V.priceModifier
6417
- }) : S[Je] = [
6419
+ }) : Y[Je] = [
6418
6420
  {
6419
6421
  id: V.id || "",
6420
6422
  name: V.name,
@@ -6422,25 +6424,25 @@ const rA = D`
6422
6424
  }
6423
6425
  ];
6424
6426
  }
6425
- Y += V.priceModifier;
6427
+ S += V.priceModifier;
6426
6428
  }
6427
6429
  }
6428
- return [S, Y];
6430
+ return [Y, S];
6429
6431
  }, [u] = await C(!0), f = Object.fromEntries(
6430
- Object.keys(u).map((M) => [M, u[M].map((S) => S.id)])
6432
+ Object.keys(u).map((M) => [M, u[M].map((Y) => Y.id)])
6431
6433
  ), [Q] = await C(!1), m = Object.fromEntries(
6432
6434
  Object.keys(Q).map((M) => [
6433
6435
  M,
6434
- Q[M].map((S) => S.id)
6436
+ Q[M].map((Y) => Y.id)
6435
6437
  ])
6436
6438
  ), p = await s(w, a.id);
6437
6439
  return {
6438
6440
  designDetails: (() => {
6439
6441
  const M = {
6440
6442
  name: i,
6441
- layouts: t.map((S) => ({
6442
- index: S.index,
6443
- panelId: S.panelId
6443
+ layouts: t.map((Y) => ({
6444
+ index: Y.index,
6445
+ panelId: Y.panelId
6444
6446
  })),
6445
6447
  workflowId: e.id,
6446
6448
  transactionId: a.id,
@@ -6448,16 +6450,16 @@ const rA = D`
6448
6450
  previewImage: p
6449
6451
  };
6450
6452
  if (h) {
6451
- const S = [];
6452
- for (const [Y, N] of Object.entries(h))
6453
- S.push({ key: Y, value: N });
6454
- M.metadata = S;
6453
+ const Y = [];
6454
+ for (const [S, N] of Object.entries(h))
6455
+ Y.push({ key: S, value: N });
6456
+ M.metadata = Y;
6455
6457
  }
6456
6458
  if (f) {
6457
- const S = [];
6458
- for (const [Y, N] of Object.entries(m))
6459
- S.push({ key: Y, ids: N });
6460
- M.selectedVariants = S;
6459
+ const Y = [];
6460
+ for (const [S, N] of Object.entries(m))
6461
+ Y.push({ key: S, ids: N });
6462
+ M.selectedVariants = Y;
6461
6463
  }
6462
6464
  return M;
6463
6465
  })(),
@@ -6714,7 +6716,7 @@ class Qe {
6714
6716
  }
6715
6717
  let n = 2048;
6716
6718
  t && t <= 2048 && (n = t);
6717
- const i = Ye(n, n), s = this.commandContext.getAllLayouts(), o = A.defaultPreviewPanelIndex || 0, r = A.panels[o], g = s.find((Q) => {
6719
+ const i = Se(n, n), s = this.commandContext.getAllLayouts(), o = A.defaultPreviewPanelIndex || 0, r = A.panels[o], g = s.find((Q) => {
6718
6720
  var m;
6719
6721
  return ((m = Q.layoutState) == null ? void 0 : m.layout.panelId) === (r == null ? void 0 : r.name);
6720
6722
  }) || s[0], B = g.layoutState.layout.previewRegion ? {
@@ -6739,7 +6741,7 @@ class Qe {
6739
6741
  await (await bt.from(d, E, {
6740
6742
  anonymousCrossOrigin: !0,
6741
6743
  ignoreDimensions: !1,
6742
- createCanvas: Ye,
6744
+ createCanvas: Se,
6743
6745
  createImage: Rt,
6744
6746
  DOMParser: Ut(),
6745
6747
  fetch: Ue
@@ -7024,12 +7026,12 @@ const Cn = [
7024
7026
  ], Qn = async (c, e, t) => {
7025
7027
  const A = e.data, a = t.data.baseUrl, n = A.assetUrl.replace("localhost", "localstack"), i = a.slice(0, 4) === "http" ? "" : "https://", s = new URL(i + a);
7026
7028
  s.searchParams.append("video", Ct(JSON.stringify([{ href: n }]))), s.pathname = s.pathname + (s.pathname.slice(-1) === "/" ? "" : "/");
7027
- const o = s.toString(), g = `data:image/svg+xml;base64,${Ct(await Tt(o, { type: "svg" }))}`, B = (d) => {
7029
+ const o = s.toString(), g = `data:image/svg+xml;base64,${Ct(await Ot(o, { type: "svg" }))}`, B = (d) => {
7028
7030
  const w = c.find((h) => h.panelId === d.panelId);
7029
7031
  if (!w)
7030
7032
  throw new z(d);
7031
7033
  const E = J();
7032
- return new T(
7034
+ return new O(
7033
7035
  {
7034
7036
  id: E,
7035
7037
  src: g,
@@ -7070,7 +7072,7 @@ const Cn = [
7070
7072
  top: a.y
7071
7073
  });
7072
7074
  return [
7073
- new T(
7075
+ new O(
7074
7076
  {
7075
7077
  id: l,
7076
7078
  path: B.path,
@@ -7094,7 +7096,7 @@ const Cn = [
7094
7096
  },
7095
7097
  d
7096
7098
  ),
7097
- new St(l, i, w)
7099
+ new Yt(l, i, w)
7098
7100
  ];
7099
7101
  };
7100
7102
  return (await Promise.all(A.data.regions.map((r) => o(r)))).flat();
@@ -7124,13 +7126,13 @@ const Cn = [
7124
7126
  Cn.includes(I.tagName) && !I.attributes.getNamedItem("fill") && I.setAttribute("fill", "#000000");
7125
7127
  const F = I.attributes.getNamedItem("fill");
7126
7128
  if (F && F.value !== "none") {
7127
- const S = F.value, N = `spiff-fill-${S.replace(/\W/g, "")}`;
7128
- I.classList.add(N), E[N] = { browserValue: S };
7129
+ const Y = F.value, N = `spiff-fill-${Y.replace(/\W/g, "")}`;
7130
+ I.classList.add(N), E[N] = { browserValue: Y };
7129
7131
  }
7130
7132
  const M = I.attributes.getNamedItem("stroke");
7131
7133
  if (M && M.value !== "none") {
7132
- const S = M.value, N = `spiff-stroke-${S.replace(/\W/g, "")}`;
7133
- I.classList.add(N), E[N] = { browserValue: S };
7134
+ const Y = M.value, N = `spiff-stroke-${Y.replace(/\W/g, "")}`;
7135
+ I.classList.add(N), E[N] = { browserValue: Y };
7134
7136
  }
7135
7137
  });
7136
7138
  const C = kt().serializeToString(w), u = a.colors;
@@ -7143,11 +7145,11 @@ const Cn = [
7143
7145
  }
7144
7146
  }
7145
7147
  const f = (I) => {
7146
- const F = c.find((S) => S.panelId === I.panelId);
7148
+ const F = c.find((Y) => Y.panelId === I.panelId);
7147
7149
  if (!F)
7148
7150
  throw new z(I);
7149
7151
  const M = J();
7150
- return new T(
7152
+ return new O(
7151
7153
  {
7152
7154
  colors: E,
7153
7155
  id: M,
@@ -7176,7 +7178,7 @@ const Cn = [
7176
7178
  if (!r)
7177
7179
  throw new z(o);
7178
7180
  const g = J();
7179
- return new T(
7181
+ return new O(
7180
7182
  {
7181
7183
  colors: {},
7182
7184
  id: g,
@@ -7219,7 +7221,7 @@ const Cn = [
7219
7221
  if (!d)
7220
7222
  throw new z(l);
7221
7223
  const w = J();
7222
- return new T(
7224
+ return new O(
7223
7225
  {
7224
7226
  id: w,
7225
7227
  src: s,
@@ -7276,7 +7278,7 @@ const Cn = [
7276
7278
  />
7277
7279
  </svg>
7278
7280
  `, w = { "spiff-fill-shape": { browserValue: i.color || "#000000" } }, E = J();
7279
- return new T(
7281
+ return new O(
7280
7282
  {
7281
7283
  colors: w,
7282
7284
  id: E,
@@ -7327,7 +7329,7 @@ const Cn = [
7327
7329
  excludeFromExport: e.data.excludeFromPrint,
7328
7330
  preserveAspectRatio: "none"
7329
7331
  };
7330
- A.push(new T(B, g));
7332
+ A.push(new O(B, g));
7331
7333
  });
7332
7334
  } catch (r) {
7333
7335
  console.error(r);
@@ -7362,7 +7364,7 @@ const Cn = [
7362
7364
  productOverlay: e.type === y.ProductOverlay ? !0 : void 0,
7363
7365
  excludeFromExport: e.data.excludeFromPrint
7364
7366
  };
7365
- A.push(new T(d, l));
7367
+ A.push(new O(d, l));
7366
7368
  });
7367
7369
  }
7368
7370
  return A;
@@ -7441,7 +7443,7 @@ const Cn = [
7441
7443
  }
7442
7444
  );
7443
7445
  a.push(
7444
- new T(
7446
+ new O(
7445
7447
  {
7446
7448
  ...u,
7447
7449
  fontSize: f,
@@ -7452,7 +7454,7 @@ const Cn = [
7452
7454
  )
7453
7455
  );
7454
7456
  } else
7455
- a.push(new T(u, C));
7457
+ a.push(new O(u, C));
7456
7458
  }
7457
7459
  return a;
7458
7460
  }, Mn = (c, e) => c.conditions ? c.conditions.every((t) => {
@@ -7464,7 +7466,7 @@ const Cn = [
7464
7466
  );
7465
7467
  }
7466
7468
  return !1;
7467
- }) : !0, Yn = async (c, e, t, A) => {
7469
+ }) : !0, Sn = async (c, e, t, A) => {
7468
7470
  const a = [], n = {};
7469
7471
  for (const i of c) {
7470
7472
  const s = e.steps.find((o) => o.stepName === i.name);
@@ -7533,10 +7535,10 @@ class me {
7533
7535
  return this.layouts;
7534
7536
  }
7535
7537
  }
7536
- const Sn = () => new Promise((c, e) => {
7537
- const A = Ye().getContext("webgl2");
7538
+ const Yn = () => new Promise((c, e) => {
7539
+ const A = Se().getContext("webgl2");
7538
7540
  c(!!A);
7539
- }), Pn = Sn();
7541
+ }), Pn = Yn();
7540
7542
  class xn {
7541
7543
  constructor(e, t, A) {
7542
7544
  this.hasSetStaticContext = !1, this.interactiveDirty = !1, this.staticCtxDirty = !1, this.lastRequestedRenderArguments = void 0, this.lastCompletedStaticRender = void 0, this.lastModificationID = void 0, this.renderQueue = new qt(2), this.id = e, this.name = t, this.service = A;
@@ -7672,7 +7674,7 @@ class Nn extends Xt {
7672
7674
  ignoreClear: !0,
7673
7675
  ignoreMouse: !0,
7674
7676
  enableRedraw: !1,
7675
- createCanvas: Ye,
7677
+ createCanvas: Se,
7676
7678
  createImage: Rt,
7677
7679
  DOMParser: Ut(),
7678
7680
  fetch: Ue
@@ -7691,13 +7693,13 @@ const Li = (c, e) => {
7691
7693
  }
7692
7694
  });
7693
7695
  }), t;
7694
- }, Ti = async (c, e, t, A) => {
7696
+ }, Oi = async (c, e, t, A) => {
7695
7697
  let a = {
7696
7698
  serializableWorkflow: { steps: [] },
7697
7699
  layouts: {}
7698
7700
  };
7699
7701
  a = new G(t.map((o) => new GA(o))).apply(a);
7700
- const i = await Yn(c, e, t, A);
7702
+ const i = await Sn(c, e, t, A);
7701
7703
  return new G(i).apply(a);
7702
7704
  }, Hn = D`
7703
7705
  ${ne}
@@ -7907,7 +7909,7 @@ const Li = (c, e) => {
7907
7909
  id
7908
7910
  }
7909
7911
  }
7910
- `, Tn = D`
7912
+ `, On = D`
7911
7913
  mutation BundleRemoveTransaction(
7912
7914
  $id: String!
7913
7915
  $transactionId: String!
@@ -7922,7 +7924,7 @@ const Li = (c, e) => {
7922
7924
  id
7923
7925
  }
7924
7926
  }
7925
- `, On = D`
7927
+ `, Tn = D`
7926
7928
  mutation BundleRemoveTransactions(
7927
7929
  $id: String!
7928
7930
  $transactionIds: [String!]!
@@ -8113,7 +8115,9 @@ class Xn extends gt {
8113
8115
  await Promise.all([
8114
8116
  t.setAspect(this.property.name, e.key, {
8115
8117
  ...t.getAspectStorage(this.property.name) || {},
8116
- originalAssetKey: e.key
8118
+ originalAssetKey: e.key,
8119
+ backgroundRemovedAssetKey: void 0,
8120
+ useOriginalAsset: void 0
8117
8121
  }),
8118
8122
  this.applyImageSelection(e)
8119
8123
  ]);
@@ -8130,9 +8134,9 @@ class Xn extends gt {
8130
8134
  const A = this.bundle.getGlobalPropertyStateManager(), a = await v.removeBackgroundFromAsset(t), i = {
8131
8135
  ...A.getAspectStorage(this.property.name),
8132
8136
  backgroundRemovedAssetKey: a.key,
8133
- useOriginalAsset: e
8137
+ useOriginalAsset: !e
8134
8138
  }, o = [e ? A.setAspect(this.property.name, a.key, i) : A.setAspectStorage(this.property.name, i)];
8135
- return e && o.push(this.applyImageSelection(a)), await Promise.all(o), a;
8139
+ return e && o.push(this.applyImageSelection(a, void 0, !1)), await Promise.all(o), this.updateSharedStepStorage(i), a;
8136
8140
  }
8137
8141
  /**
8138
8142
  * Returns `true` if the state has an image assigned, otherwise `false`.
@@ -8172,22 +8176,58 @@ class Xn extends gt {
8172
8176
  return ((e = this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name)) == null ? void 0 : e.useOriginalAsset) ?? !1;
8173
8177
  }
8174
8178
  async setUseOriginalImage(e) {
8175
- const t = this.bundle.getGlobalPropertyStateManager(), A = t.getAspectStorage(this.property.name);
8176
- await t.setAspectStorage(this.property.name, {
8177
- ...A,
8179
+ const t = await this.getOriginalImage();
8180
+ if (!t)
8181
+ throw new Error("You must select an image before calling setUseOriginalImage");
8182
+ const A = this.bundle.getGlobalPropertyStateManager(), a = A.getAspectStorage(this.property.name);
8183
+ if ((a == null ? void 0 : a.useOriginalAsset) === e)
8184
+ return;
8185
+ const n = {
8186
+ ...a,
8178
8187
  useOriginalAsset: e
8179
- });
8188
+ }, i = [A.setAspectStorage(this.property.name, n)];
8189
+ if (e)
8190
+ i.push(this.applyImageSelection(t, void 0, !1));
8191
+ else {
8192
+ const s = async () => {
8193
+ const o = await this.getBackgroundRemovedImage();
8194
+ if (!o)
8195
+ throw new Error(
8196
+ "You must call removeBackgroundFromImage before attempting to use that version of the image."
8197
+ );
8198
+ this.applyImageSelection(o, void 0, !1);
8199
+ };
8200
+ i.push(s());
8201
+ }
8202
+ this.updateSharedStepStorage(n);
8180
8203
  }
8181
8204
  async applyGlobalState(e) {
8182
8205
  const t = this.getStateValue();
8183
8206
  if (!t)
8184
8207
  return Promise.resolve();
8185
8208
  const A = await v.getLocalOrFromServer(t);
8186
- return A ? this.applyImageSelection(A, e) : Promise.resolve();
8209
+ if (!A)
8210
+ return Promise.resolve();
8211
+ await this.applyImageSelection(A, e);
8187
8212
  }
8188
- async applyImageSelection(e, t) {
8189
- const a = this.getSharedSteps(t).map((n) => n.selectImage(e));
8190
- await Promise.all(a);
8213
+ async applyImageSelection(e, t, A = !0) {
8214
+ const n = this.getSharedSteps(t).map((i) => i.selectImage(e, A));
8215
+ await Promise.all(n);
8216
+ }
8217
+ updateSharedStepStorage(e) {
8218
+ this.bundle.getWorkflowExperiences().forEach(
8219
+ (A) => A.getSteps().forEach((a) => {
8220
+ var i;
8221
+ if (a.getOverrideGlobalPropertyConfiguration(this.property.type))
8222
+ return;
8223
+ ((i = a.getRaw().globalPropertyAspectConfigurations) == null ? void 0 : i.some(
8224
+ (s) => {
8225
+ var o, r;
8226
+ return s.globalPropertyConfigurationId === ((r = (o = this.bundle.getProductCollection()) == null ? void 0 : o.getResource().globalPropertyConfiguration) == null ? void 0 : r.id) && s.aspectName === this.property.name;
8227
+ }
8228
+ )) && A.getWorkflowManager().updateStorage(a.getId(), { framePatternData: e });
8229
+ })
8230
+ );
8191
8231
  }
8192
8232
  }
8193
8233
  class qn extends gt {
@@ -8958,7 +8998,7 @@ class yt {
8958
8998
  (n) => n.getWorkflowManager().getTransaction().id === t.id
8959
8999
  );
8960
9000
  a.setBundle(void 0), this.previewService && a.getWorkflowManager().ejectFromPreviewService(), this.bundleStateManager.removeStateForTransaction(t.id), await x.getShadowGraphqlClient().mutate({
8961
- mutation: Tn,
9001
+ mutation: On,
8962
9002
  variables: {
8963
9003
  id: this.id,
8964
9004
  transactionId: t.id,
@@ -8990,7 +9030,7 @@ class yt {
8990
9030
  A.forEach((a) => a.setBundle(void 0)), [...this.workflowExperiences, ...A].forEach(
8991
9031
  (a) => a.checkForPriceBreakChanges()
8992
9032
  ), this.previewService && A.forEach((a) => a.getWorkflowManager().ejectFromPreviewService()), e.forEach((a) => this.bundleStateManager.removeStateForTransaction(a.id)), await x.getShadowGraphqlClient().mutate({
8993
- mutation: On,
9033
+ mutation: Tn,
8994
9034
  variables: {
8995
9035
  id: this.id,
8996
9036
  transactionIds: e.map((a) => a.id),
@@ -9412,7 +9452,7 @@ class Bt {
9412
9452
  }
9413
9453
  }
9414
9454
  var ci = /* @__PURE__ */ ((c) => (c.Transaction = "Transaction", c.Bundle = "Bundle", c.Product = "Product", c.Variant = "Variant", c.Option = "Option", c.LineItem = "LineItem", c.Asset = "Asset", c))(ci || {});
9415
- class Oi extends Bt {
9455
+ class Ti extends Bt {
9416
9456
  constructor(e) {
9417
9457
  super(`"${e}"`);
9418
9458
  }
@@ -10192,7 +10232,7 @@ class yi {
10192
10232
  } catch (A) {
10193
10233
  throw console.error(A), new U("Critical - Unable to synchronize workflow state with server.");
10194
10234
  }
10195
- }, this.initialized = !1, this.options = e, this.options.applicationKey && TA(this.options.applicationKey);
10235
+ }, this.initialized = !1, this.options = e, this.options.applicationKey && OA(this.options.applicationKey);
10196
10236
  }
10197
10237
  /**
10198
10238
  * @returns The asset manager allows for common operations related to assets
@@ -10207,7 +10247,7 @@ class yi {
10207
10247
  return this.currencyCode;
10208
10248
  }
10209
10249
  getFlowService() {
10210
- if (!OA())
10250
+ if (!TA())
10211
10251
  throw new Error("Application key required to use Flow Service.");
10212
10252
  return new oi();
10213
10253
  }
@@ -10456,7 +10496,7 @@ class yi {
10456
10496
  */
10457
10497
  async getExistingBundle(e, t, A, a) {
10458
10498
  var h, C, u, f, Q, m, p, I, F;
10459
- const n = P.getMap("bundleOwnerIds"), i = n == null ? void 0 : n.get(e), o = ((h = Object.entries(localStorage).find(([M, S]) => M.startsWith("CognitoIdentityServiceProvider") && M.endsWith("idToken"))) == null ? void 0 : h[0]) || "", r = localStorage.getItem(o), g = {};
10499
+ const n = P.getMap("bundleOwnerIds"), i = n == null ? void 0 : n.get(e), o = ((h = Object.entries(localStorage).find(([M, Y]) => M.startsWith("CognitoIdentityServiceProvider") && M.endsWith("idToken"))) == null ? void 0 : h[0]) || "", r = localStorage.getItem(o), g = {};
10460
10500
  r && (g.Authorization = `Bearer ${r}`);
10461
10501
  const B = {
10462
10502
  bundleOwnerId: i,
@@ -10618,10 +10658,10 @@ class yi {
10618
10658
  if (e.length === 0)
10619
10659
  throw new U("No options provided!");
10620
10660
  const A = x.getShadowGraphqlClient(), a = async (m) => {
10621
- var M, S;
10661
+ var M, Y;
10622
10662
  if (m.length === 0)
10623
10663
  return [];
10624
- const p = m.map((Y) => Y.option.transactionId), I = await A.query({
10664
+ const p = m.map((S) => S.option.transactionId), I = await A.query({
10625
10665
  query: Ee,
10626
10666
  variables: {
10627
10667
  ids: p
@@ -10630,30 +10670,30 @@ class yi {
10630
10670
  fetchPolicy: "no-cache"
10631
10671
  }), F = I.data.transactions;
10632
10672
  if (F.length !== m.length) {
10633
- const Y = ((S = (M = I.errors) == null ? void 0 : M[0]) == null ? void 0 : S.message) || "Unknown error";
10634
- throw new U(`Not all transactions were found: ${Y}`);
10673
+ const S = ((Y = (M = I.errors) == null ? void 0 : M[0]) == null ? void 0 : Y.message) || "Unknown error";
10674
+ throw new U(`Not all transactions were found: ${S}`);
10635
10675
  }
10636
- return F.map((Y, N) => {
10676
+ return F.map((S, N) => {
10637
10677
  var H;
10638
10678
  return {
10639
- transaction: Y,
10640
- workflowId: Y.workflowId,
10641
- readOnly: ((H = m.find((O) => O.option.transactionId === Y.id)) == null ? void 0 : H.option.readOnly) ?? !1,
10679
+ transaction: S,
10680
+ workflowId: S.workflowId,
10681
+ readOnly: ((H = m.find((T) => T.option.transactionId === S.id)) == null ? void 0 : H.option.readOnly) ?? !1,
10642
10682
  index: m[N].index
10643
10683
  };
10644
10684
  });
10645
10685
  }, n = async (m) => {
10646
- var F, M, S;
10686
+ var F, M, Y;
10647
10687
  if (m.length === 0)
10648
10688
  return [];
10649
10689
  const p = await A.mutate({
10650
10690
  mutation: la,
10651
10691
  variables: {
10652
- inputs: m.map((Y) => ({
10653
- integrationProductId: Y.option.type === "integration" ? Y.option.integrationProductId : void 0,
10654
- externalIntegrationId: Y.option.type === "external" ? Y.option.externalIntegrationId : void 0,
10655
- externalProductId: Y.option.type === "external" ? Y.option.externalProductId : void 0,
10656
- workflowId: Y.option.workflowId,
10692
+ inputs: m.map((S) => ({
10693
+ integrationProductId: S.option.type === "integration" ? S.option.integrationProductId : void 0,
10694
+ externalIntegrationId: S.option.type === "external" ? S.option.externalIntegrationId : void 0,
10695
+ externalProductId: S.option.type === "external" ? S.option.externalProductId : void 0,
10696
+ workflowId: S.option.workflowId,
10657
10697
  claim: !0
10658
10698
  }))
10659
10699
  },
@@ -10661,12 +10701,12 @@ class yi {
10661
10701
  fetchPolicy: "no-cache"
10662
10702
  }), I = (F = p.data) == null ? void 0 : F.transactionCreateMany;
10663
10703
  if (!I || I.length === 0) {
10664
- const Y = ((S = (M = p.errors) == null ? void 0 : M[0]) == null ? void 0 : S.message) || "Unknown error";
10665
- throw new U(`Failed to create transactions: ${Y}`);
10704
+ const S = ((Y = (M = p.errors) == null ? void 0 : M[0]) == null ? void 0 : Y.message) || "Unknown error";
10705
+ throw new U(`Failed to create transactions: ${S}`);
10666
10706
  }
10667
- return I.map((Y, N) => ({
10668
- transaction: Y,
10669
- workflowId: Y.workflowId,
10707
+ return I.map((S, N) => ({
10708
+ transaction: S,
10709
+ workflowId: S.workflowId,
10670
10710
  readOnly: !1,
10671
10711
  index: m[N].index
10672
10712
  }));
@@ -10676,26 +10716,26 @@ class yi {
10676
10716
  ...r.map(a),
10677
10717
  ...g.map(n)
10678
10718
  ])).flat(), l = [...new Set(B.map((m) => m.workflowId))], d = await hA(l, t), w = new Map(d.map((m) => [m.id, m])), E = P.getMap("transactionOwnerIds") || /* @__PURE__ */ new Map(), h = B.map(async (m) => {
10679
- var O;
10680
- const { transaction: p, workflowId: I, readOnly: F, index: M } = m, S = w.get(I), Y = e[M];
10719
+ var T;
10720
+ const { transaction: p, workflowId: I, readOnly: F, index: M } = m, Y = w.get(I), S = e[M];
10681
10721
  !E.get(p.id) && p.transactionOwnerId && E.set(p.id, p.transactionOwnerId);
10682
10722
  const N = E.get(p.id) || void 0, H = {
10683
10723
  product: p.product,
10684
10724
  transaction: p,
10685
10725
  layouts: [],
10686
- singleVariantsRenderable: (O = Y == null ? void 0 : Y.workflowConfiguration) == null ? void 0 : O.singleVariantsRenderable,
10726
+ singleVariantsRenderable: (T = S == null ? void 0 : S.workflowConfiguration) == null ? void 0 : T.singleVariantsRenderable,
10687
10727
  stateMutationFunc: F ? async () => {
10688
10728
  throw new b("State mutation is forbidden in read only mode!");
10689
10729
  } : async (L) => this.updateTransactionState({ ...L, context: { transactionOwnerId: N } }),
10690
10730
  readOnly: F,
10691
- workflow: S,
10692
- isReloadedTransaction: Y.type === "transaction"
10731
+ workflow: Y,
10732
+ isReloadedTransaction: S.type === "transaction"
10693
10733
  };
10694
- if (Y.type === "transaction" && p.workflowState) {
10734
+ if (S.type === "transaction" && p.workflowState) {
10695
10735
  const L = JSON.parse(p.workflowState);
10696
10736
  H.layouts = Object.values(L.layouts || {}).map((V) => V.layout), await ee(L), await te(L), H.reloadedState = L;
10697
- } else if (!F && Y.workflowState) {
10698
- const L = JSON.parse(Y.workflowState);
10737
+ } else if (!F && S.workflowState) {
10738
+ const L = JSON.parse(S.workflowState);
10699
10739
  H.layouts = Object.values(L.layouts || {}).map((V) => V.layout), await ee(L), await te(L), H.reloadedState = L;
10700
10740
  } else
10701
10741
  H.layouts = je(
@@ -10704,7 +10744,7 @@ class yi {
10704
10744
  );
10705
10745
  return H.renderableContextService = new me(
10706
10746
  H.layouts
10707
- ), H.delayWorkflowStateSync = !0, this.initialized = !0, this.experienceOptions = H, { experienceOptions: H, index: M, options: Y };
10747
+ ), H.delayWorkflowStateSync = !0, this.initialized = !0, this.experienceOptions = H, { experienceOptions: H, index: M, options: S };
10708
10748
  });
10709
10749
  P.setMap("transactionOwnerIds", E);
10710
10750
  const f = (await Promise.all(h)).sort((m, p) => m.index - p.index).map(async (m) => {
@@ -11070,7 +11110,7 @@ class Ki {
11070
11110
  }
11071
11111
  }
11072
11112
  var Mi = /* @__PURE__ */ ((c) => (c.SelectFrame = "SelectFrame", c.SelectImage = "SelectImage", c.Position = "Position", c))(Mi || {});
11073
- class Yi extends W {
11113
+ class Si extends W {
11074
11114
  constructor(e, t) {
11075
11115
  var A;
11076
11116
  super(e, t), this.frameService = (A = this.manager.getStepSpecificServices(this.getId())) == null ? void 0 : A.frameService;
@@ -11095,15 +11135,16 @@ class Yi extends W {
11095
11135
  * @param asset The asset to use.
11096
11136
  * @param storeAsOriginal Optional: Store this asset as the original, unmodified version of the image. Default: `true`.
11097
11137
  */
11098
- selectImage(e, t = !0) {
11138
+ async selectImage(e, t = !0) {
11099
11139
  var A;
11100
- if (De.selectImage(this.step, e, this.manager), t) {
11140
+ if (await De.selectImage(this.step, e, this.manager), t) {
11101
11141
  const a = ((A = this.manager.getStepStorage(this.step.stepName)) == null ? void 0 : A.framePatternData) || {};
11102
11142
  this.manager.updateStorage(this.step.stepName, {
11103
11143
  framePatternData: {
11104
11144
  ...a,
11105
11145
  originalAssetKey: e.key,
11106
- backgroundRemovedAssetKey: void 0
11146
+ backgroundRemovedAssetKey: void 0,
11147
+ useOriginalAsset: void 0
11107
11148
  }
11108
11149
  });
11109
11150
  }
@@ -11119,13 +11160,13 @@ class Yi extends W {
11119
11160
  if (!t)
11120
11161
  throw new Error("You must supply an image selection before attempting to remove the background.");
11121
11162
  const A = await v.removeBackgroundFromAsset(t);
11122
- e && De.selectImage(this.step, A, this.manager);
11163
+ e && await De.selectImage(this.step, A, this.manager);
11123
11164
  const a = ((n = this.manager.getStepStorage(this.step.stepName)) == null ? void 0 : n.framePatternData) || {};
11124
11165
  return this.manager.updateStorage(this.step.stepName, {
11125
11166
  framePatternData: {
11126
11167
  ...a,
11127
11168
  backgroundRemovedAssetKey: A.key,
11128
- useOriginalAsset: e
11169
+ useOriginalAsset: !e
11129
11170
  }
11130
11171
  }), A;
11131
11172
  }
@@ -11161,9 +11202,24 @@ class Yi extends W {
11161
11202
  var e, t;
11162
11203
  return ((t = (e = this.manager.getStepStorage(this.step.stepName)) == null ? void 0 : e.framePatternData) == null ? void 0 : t.useOriginalAsset) ?? !1;
11163
11204
  }
11164
- setUseOriginalImageSelection(e) {
11165
- var A;
11166
- const t = ((A = this.manager.getStepStorage(this.step.stepName)) == null ? void 0 : A.framePatternData) || {};
11205
+ async setUseOriginalImageSelection(e) {
11206
+ var a;
11207
+ const t = ((a = this.manager.getStepStorage(this.step.stepName)) == null ? void 0 : a.framePatternData) || {};
11208
+ if (t.useOriginalAsset === e)
11209
+ return;
11210
+ const A = await this.getOriginalImageSelection();
11211
+ if (!A)
11212
+ throw new Error("You must provide an image selection before calling setUseOriginalImageSelection");
11213
+ if (e)
11214
+ this.selectImage(A, !1);
11215
+ else {
11216
+ const n = await this.getBackgroundRemovedImageSelection();
11217
+ if (!n)
11218
+ throw new Error(
11219
+ "You must call removeBackgroundFromImageSelection before attempting to apply the image."
11220
+ );
11221
+ this.selectImage(n, !1);
11222
+ }
11167
11223
  this.manager.updateStorage(this.step.stepName, {
11168
11224
  framePatternData: { ...t, useOriginalAsset: e }
11169
11225
  });
@@ -11196,7 +11252,7 @@ export {
11196
11252
  os as FontSourceCommand,
11197
11253
  fa as FrameService,
11198
11254
  Mi as FrameStep,
11199
- Yi as FrameStepHandle,
11255
+ Si as FrameStepHandle,
11200
11256
  gt as GlobalPropertyHandle,
11201
11257
  rs as GroupCommand,
11202
11258
  _a as IllustrationStepHandle,
@@ -11215,7 +11271,7 @@ export {
11215
11271
  wA as ObjectInput,
11216
11272
  ci as ObjectInputType,
11217
11273
  dA as OptionGlobalPropertyHandle,
11218
- Se as OptionNotFoundError,
11274
+ Ye as OptionNotFoundError,
11219
11275
  oe as ParseError,
11220
11276
  An as PictureStepHandle,
11221
11277
  ra as ProductCameraRig,
@@ -11237,7 +11293,7 @@ export {
11237
11293
  Es as StepType,
11238
11294
  us as TextChangeCommand,
11239
11295
  qn as TextGlobalPropertyHandle,
11240
- Oi as TextInput,
11296
+ Ti as TextInput,
11241
11297
  sn as TextStepHandle,
11242
11298
  ii as Transform,
11243
11299
  ni as TransformCollection,
@@ -11256,19 +11312,19 @@ export {
11256
11312
  Is as frameDataCache,
11257
11313
  De as frameStepService,
11258
11314
  fs as generate,
11259
- Yn as generateCommands,
11315
+ Sn as generateCommands,
11260
11316
  Ds as generateSVGWithUnknownColors,
11261
- Ti as generateStateFromDesignInputSteps,
11317
+ Oi as generateStateFromDesignInputSteps,
11262
11318
  Fs as getAttributesFromArrayBuffer,
11263
11319
  ys as getAxisAlignedBoundingBox,
11264
11320
  Ia as getBoundedOffsets,
11265
11321
  Ms as getFrameData,
11266
- Ys as getSvgElement,
11322
+ Ss as getSvgElement,
11267
11323
  Ie as getWorkflow,
11268
11324
  hA as getWorkflows,
11269
11325
  x as graphQlManager,
11270
11326
  Fe as illustrationStepService,
11271
- Ss as loadFont,
11327
+ Ys as loadFont,
11272
11328
  $t as materialStepService,
11273
11329
  _t as modelStepService,
11274
11330
  Na as moduleStepService,