@spiffcommerce/core 21.10.0-alpha.1 → 21.10.0-alpha.2
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 +76 -73
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHttpLink as CA, InMemoryCache as QA, ApolloClient as mA, from as pA, gql as D } from "@apollo/client/core";
|
|
2
|
-
import { fetch as $e, getAttributesFromArrayBuffer as Pt, AssetType as ht, StepType as y, getFrameData as _e, frameDataCache as IA, GroupCommand as
|
|
3
|
-
import { AspectType as qi, AssetType as Zi, BringForwardCommand as $i, BringToBackCommand as _i, BringToFrontCommand as eo, CanvasCommand as to, CommandContext as Ao, CreateElementCommand as ao, CreateLayoutCommand as no, DeleteElementCommand as io, FontAlignmentCommand as oo, FontColorCommand as so, FontSizeCommand as ro, FontSourceCommand as co, GroupCommand as go, LayoutElementFactory as lo, LayoutElementType as Bo, MoveCommand as wo, ResizeCommand as ho, RotateCommand as Eo, SendBackwardsCommand as uo, StepAspectType as Co, StepType as Qo, TextChangeCommand as mo, UnitOfMeasurement as po, dataUrlFromExternalUrl as Io, determineCorrectFontSizeAndLines as fo, findElement as Do, frameDataCache as Fo, generate as yo, generateSVGWithUnknownColors as Mo, getAttributesFromArrayBuffer as So, getAxisAlignedBoundingBox as Yo, getFrameData as Po, getSvgElement as xo, loadFont as No, patternImageDataCache as Ho, registerFetchImplementation as Ro, registerWindowImplementation as Uo, rehydrateSerializedLayout as
|
|
2
|
+
import { fetch as $e, getAttributesFromArrayBuffer as Pt, AssetType as ht, StepType as y, getFrameData as _e, frameDataCache as IA, GroupCommand as v, UpdateFramePattern as xt, UpdateFrameThresholdSettingsCommand as fA, calculateOffsets as et, LayoutElementType as k, generate as J, CreateElementCommand as L, generateSVGWithUnknownColors as Nt, svgObjectURL as Me, fetchAsString as Z, DeleteElementCommand as $, generateDefaultRectangleFrameSvg as Et, GetSVGDimensions as DA, patternImageDataCache as ut, fetchAsArrayBuffer as FA, findElement as Se, modifySVGWithElementProperties as yA, IllustrationColorCommand as je, IllustrationCacheCommand as MA, getFontMetrics as SA, getPatternImageData as Ve, FontAlignmentCommand as YA, FontColorCommand as PA, FontImageFillCommand as Je, applyTextTransformations as We, determineCorrectFontSizeAndLines as De, FontSourceCommand as Ct, loadFont as tt, TextChangeCommand as xA, FontSizeCommand as NA, createElementNS as HA, createElement as Ee, _loadFontExternalDataURL as At, UpdateWorkflowStateCommand as Qt, CommandContext as RA, createCanvas as Ye, getSvgElement as Ht, LayoutRenderingPurpose as Rt, renderPapyrusComponentAsString as Ut, loadImage as vt, getDomParser as Gt, toBase64 as mt, getVariant as UA, generateFrameSVG as vA, getDefaultVariant as ve, domParser as kt, sanitizeSvgTree as bt, traverse as GA, xmlSerializer as Jt, CreateLayoutCommand as kA, AspectType as ce, rehydrateSerializedLayout as ee } from "@spiffcommerce/papyrus";
|
|
3
|
+
import { AspectType as qi, AssetType as Zi, BringForwardCommand as $i, BringToBackCommand as _i, BringToFrontCommand as eo, CanvasCommand as to, CommandContext as Ao, CreateElementCommand as ao, CreateLayoutCommand as no, DeleteElementCommand as io, FontAlignmentCommand as oo, FontColorCommand as so, FontSizeCommand as ro, FontSourceCommand as co, GroupCommand as go, LayoutElementFactory as lo, LayoutElementType as Bo, MoveCommand as wo, ResizeCommand as ho, RotateCommand as Eo, SendBackwardsCommand as uo, StepAspectType as Co, StepType as Qo, TextChangeCommand as mo, UnitOfMeasurement as po, dataUrlFromExternalUrl as Io, determineCorrectFontSizeAndLines as fo, findElement as Do, frameDataCache as Fo, generate as yo, generateSVGWithUnknownColors as Mo, getAttributesFromArrayBuffer as So, getAxisAlignedBoundingBox as Yo, getFrameData as Po, getSvgElement as xo, loadFont as No, patternImageDataCache as Ho, registerFetchImplementation as Ro, registerWindowImplementation as Uo, rehydrateSerializedLayout as vo, setCanvasModule as Go } from "@spiffcommerce/papyrus";
|
|
4
4
|
import { setContext as bA } from "@apollo/client/link/context";
|
|
5
5
|
import { onError as JA } from "@apollo/client/link/error";
|
|
6
6
|
import { Pith as Ot } from "pith";
|
|
@@ -46,27 +46,27 @@ class xe extends we {
|
|
|
46
46
|
super(`Workflow Misconfiguration: ${e.stepName} - ${t}`), this.step = e;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
class
|
|
49
|
+
class Ge extends Kt {
|
|
50
50
|
constructor(e) {
|
|
51
51
|
super(`ImplementationError - ${e}`);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
class b extends
|
|
54
|
+
class b extends Ge {
|
|
55
55
|
constructor(e) {
|
|
56
56
|
super(`Unhandled Behavior Encountered: ${e}`);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
class se extends
|
|
59
|
+
class se extends Ge {
|
|
60
60
|
constructor(e) {
|
|
61
61
|
super(`Parsing Error: ${e}`);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
class U extends
|
|
64
|
+
class U extends Ge {
|
|
65
65
|
constructor(e) {
|
|
66
66
|
super(`Client Error: ${e}`);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
class ke extends
|
|
69
|
+
class ke extends Ge {
|
|
70
70
|
constructor(e) {
|
|
71
71
|
super(`Resource Generation Failed: ${e}`);
|
|
72
72
|
}
|
|
@@ -563,7 +563,7 @@ class Oe {
|
|
|
563
563
|
return e ? Array.from(e.entries()).map((t) => ({ assetKey: t[0], src: t[1] })) : [];
|
|
564
564
|
}
|
|
565
565
|
}
|
|
566
|
-
const
|
|
566
|
+
const G = new Aa();
|
|
567
567
|
class aa {
|
|
568
568
|
constructor() {
|
|
569
569
|
this.cache = {}, this.disabled = !1;
|
|
@@ -655,8 +655,8 @@ const de = new aa(), Wt = D`
|
|
|
655
655
|
});
|
|
656
656
|
return e.data.options.forEach((t) => {
|
|
657
657
|
var A, a;
|
|
658
|
-
(A = t.defaultVariant) != null && A.asset &&
|
|
659
|
-
n.asset &&
|
|
658
|
+
(A = t.defaultVariant) != null && A.asset && G.cacheAsset(t.defaultVariant.asset), t.colorProfile && G.cacheAsset(t.colorProfile), (a = t.variants) == null || a.forEach((n) => {
|
|
659
|
+
n.asset && G.cacheAsset(n.asset), n.displayImage && G.cacheAsset(n.displayImage), n.thumbnail && G.cacheAsset(n.thumbnail), n.material && G.cacheMaterial(n.material);
|
|
660
660
|
});
|
|
661
661
|
}), e.data.options;
|
|
662
662
|
}, oa = async (c, e) => (await e).find((A) => A.id === c), sa = async (c) => {
|
|
@@ -1560,7 +1560,7 @@ class Fa {
|
|
|
1560
1560
|
const o = this.workflowManager.getCommandDispatcher();
|
|
1561
1561
|
n.forEach((s, r) => {
|
|
1562
1562
|
o(
|
|
1563
|
-
new
|
|
1563
|
+
new v([
|
|
1564
1564
|
new xt(s, t, e[r]),
|
|
1565
1565
|
new fA(s, a.useThreshold, a.invertThreshold, a.threshold, a.thresholdSaturation)
|
|
1566
1566
|
])
|
|
@@ -1815,7 +1815,7 @@ class Ma {
|
|
|
1815
1815
|
B
|
|
1816
1816
|
);
|
|
1817
1817
|
});
|
|
1818
|
-
return { command: new
|
|
1818
|
+
return { command: new v(s), followup: async () => {
|
|
1819
1819
|
} };
|
|
1820
1820
|
}
|
|
1821
1821
|
}
|
|
@@ -1918,11 +1918,11 @@ class Ya {
|
|
|
1918
1918
|
new _t(
|
|
1919
1919
|
async () => {
|
|
1920
1920
|
var r;
|
|
1921
|
-
const o = (r = (await
|
|
1921
|
+
const o = (r = (await G.getLocalOrFromServer(t.key || "")).versions) == null ? void 0 : r.find((g) => g.name === "svg");
|
|
1922
1922
|
return o ? (await fetch(o.link)).status === 200 : !1;
|
|
1923
1923
|
},
|
|
1924
1924
|
() => {
|
|
1925
|
-
|
|
1925
|
+
G.getLocalOrFromServer(t.key || "").then((i) => {
|
|
1926
1926
|
this.loadPatternFromAsset(i, e, A).then(n);
|
|
1927
1927
|
});
|
|
1928
1928
|
},
|
|
@@ -2034,7 +2034,7 @@ class Ya {
|
|
|
2034
2034
|
})
|
|
2035
2035
|
), g = r.map((d) => d.command), B = r.map((d) => d.removeExistingCommands).flat();
|
|
2036
2036
|
return {
|
|
2037
|
-
command: new
|
|
2037
|
+
command: new v([...g, ...B]),
|
|
2038
2038
|
followup: async () => {
|
|
2039
2039
|
n && n(!1), await a.setSelectionsAndElements(
|
|
2040
2040
|
e.stepName,
|
|
@@ -2186,7 +2186,7 @@ class Pa {
|
|
|
2186
2186
|
r.push(new je(B, l, d));
|
|
2187
2187
|
r.push(new MA(B, o, s));
|
|
2188
2188
|
}
|
|
2189
|
-
return new
|
|
2189
|
+
return new v(r);
|
|
2190
2190
|
}
|
|
2191
2191
|
async changeColors(e, t, A, a, n) {
|
|
2192
2192
|
var d, w;
|
|
@@ -2266,7 +2266,7 @@ class Pa {
|
|
|
2266
2266
|
return f.toLowerCase() === ((Q = u.color) == null ? void 0 : Q.toLowerCase()) ? u.name : f;
|
|
2267
2267
|
});
|
|
2268
2268
|
})), n.updateMetadata(e.stepName, { colors: E }), {
|
|
2269
|
-
command: new
|
|
2269
|
+
command: new v(w),
|
|
2270
2270
|
followup: async () => {
|
|
2271
2271
|
await n.setSelectionsAndElements(
|
|
2272
2272
|
e.stepName,
|
|
@@ -2514,7 +2514,7 @@ class Ha {
|
|
|
2514
2514
|
), {
|
|
2515
2515
|
id: w,
|
|
2516
2516
|
region: l,
|
|
2517
|
-
command: new
|
|
2517
|
+
command: new v(C)
|
|
2518
2518
|
};
|
|
2519
2519
|
};
|
|
2520
2520
|
if (i.length > 0) {
|
|
@@ -2525,7 +2525,7 @@ class Ha {
|
|
|
2525
2525
|
return r(w, d.region, d.id);
|
|
2526
2526
|
}).filter((d) => !!d).filter((d) => !!d).map((d) => d && d.command);
|
|
2527
2527
|
return {
|
|
2528
|
-
command: new
|
|
2528
|
+
command: new v(l),
|
|
2529
2529
|
followup: async () => {
|
|
2530
2530
|
}
|
|
2531
2531
|
};
|
|
@@ -2534,7 +2534,7 @@ class Ha {
|
|
|
2534
2534
|
(d) => r(o.svgPrint(t, d), d)
|
|
2535
2535
|
), l = B.filter((d) => !!d).map((d) => d && d.command);
|
|
2536
2536
|
return {
|
|
2537
|
-
command: new
|
|
2537
|
+
command: new v(l),
|
|
2538
2538
|
followup: async () => {
|
|
2539
2539
|
const d = B.filter((w) => w).map((w) => w && { id: w.id, region: w.region });
|
|
2540
2540
|
await A.setSelectionsAndElements(
|
|
@@ -2642,7 +2642,7 @@ class Ua {
|
|
|
2642
2642
|
};
|
|
2643
2643
|
}, g = e.data.regions.map(r);
|
|
2644
2644
|
return {
|
|
2645
|
-
command: new
|
|
2645
|
+
command: new v([...s, ...g.map((B) => B.command)]),
|
|
2646
2646
|
followup: async () => {
|
|
2647
2647
|
await A.setSelectionsAndElements(
|
|
2648
2648
|
e.stepName,
|
|
@@ -2657,7 +2657,7 @@ class Ua {
|
|
|
2657
2657
|
}
|
|
2658
2658
|
}
|
|
2659
2659
|
const AA = new Ua();
|
|
2660
|
-
class
|
|
2660
|
+
class va {
|
|
2661
2661
|
async init(e, t, A) {
|
|
2662
2662
|
const a = e.option;
|
|
2663
2663
|
if (!a)
|
|
@@ -2715,8 +2715,8 @@ class Ga {
|
|
|
2715
2715
|
};
|
|
2716
2716
|
}
|
|
2717
2717
|
}
|
|
2718
|
-
const aA = new
|
|
2719
|
-
class
|
|
2718
|
+
const aA = new va();
|
|
2719
|
+
class Ga {
|
|
2720
2720
|
constructor() {
|
|
2721
2721
|
this.shapeFillId = "spiff-fill-shape";
|
|
2722
2722
|
}
|
|
@@ -2737,7 +2737,7 @@ class va {
|
|
|
2737
2737
|
throw new z(s);
|
|
2738
2738
|
return new je(o.id, this.shapeFillId, e);
|
|
2739
2739
|
}).filter((o) => !!o);
|
|
2740
|
-
A.getCommandDispatcher()(new
|
|
2740
|
+
A.getCommandDispatcher()(new v(i)), A.updateStorage(t.stepName, { colour: e });
|
|
2741
2741
|
}
|
|
2742
2742
|
async init(e, t, A) {
|
|
2743
2743
|
const a = e.option;
|
|
@@ -2810,7 +2810,7 @@ class va {
|
|
|
2810
2810
|
return new je(B.id, this.shapeFillId, w);
|
|
2811
2811
|
}, g = A.map(r).filter((B) => !!B);
|
|
2812
2812
|
return {
|
|
2813
|
-
command: new
|
|
2813
|
+
command: new v(g),
|
|
2814
2814
|
followup: async () => {
|
|
2815
2815
|
await a.setSelectionsAndElements(
|
|
2816
2816
|
e.stepName,
|
|
@@ -2873,7 +2873,7 @@ class va {
|
|
|
2873
2873
|
};
|
|
2874
2874
|
}, g = e.data.regions.map(r), B = g.filter((d) => !!d).map((d) => d == null ? void 0 : d.command), l = g.filter((d) => !!d).map((d) => ({ id: d.id, region: d.region }));
|
|
2875
2875
|
return {
|
|
2876
|
-
command: new
|
|
2876
|
+
command: new v(B),
|
|
2877
2877
|
followup: async () => {
|
|
2878
2878
|
await a.setSelectionsAndElements(
|
|
2879
2879
|
e.stepName,
|
|
@@ -2888,7 +2888,7 @@ class va {
|
|
|
2888
2888
|
}
|
|
2889
2889
|
}
|
|
2890
2890
|
}
|
|
2891
|
-
const re = new
|
|
2891
|
+
const re = new Ga();
|
|
2892
2892
|
class ka {
|
|
2893
2893
|
constructor() {
|
|
2894
2894
|
this.latestToast = null, this.toastType = null, this.toastCallbacks = [];
|
|
@@ -3122,7 +3122,7 @@ class Oa {
|
|
|
3122
3122
|
}
|
|
3123
3123
|
return !A.data.curved && t.length > 0 && !Array.from(B.values()).every((d) => d) ? (o.errors.push({ localizationKey: "workflow.steps.text.doesNotFit" }), o) : (a.updateStorage(A.stepName, { text: e }), a.updateMetadata(A.stepName, {
|
|
3124
3124
|
text: i
|
|
3125
|
-
}), n.defaultCleared && a.setMandatoryFulfilled(A.stepName, !0), o.command = new
|
|
3125
|
+
}), n.defaultCleared && a.setMandatoryFulfilled(A.stepName, !0), o.command = new v(r), o);
|
|
3126
3126
|
}
|
|
3127
3127
|
async selectVariant(e, t, A, a, n) {
|
|
3128
3128
|
const i = await this.selectVariantCommand(
|
|
@@ -3166,7 +3166,7 @@ class Oa {
|
|
|
3166
3166
|
E,
|
|
3167
3167
|
async () => {
|
|
3168
3168
|
t.updateMetadata(e.stepName, { color: h, text: C }), t.updateStorage(e.stepName, { text: C, inputText: C });
|
|
3169
|
-
const f = o.map((m) => new Ct(m.id, w)), Q = new
|
|
3169
|
+
const f = o.map((m) => new Ct(m.id, w)), Q = new v(f);
|
|
3170
3170
|
t.getCommandDispatcher()(Q), t.setMandatoryFulfilled(e.stepName, !0);
|
|
3171
3171
|
}
|
|
3172
3172
|
);
|
|
@@ -3232,7 +3232,7 @@ class Oa {
|
|
|
3232
3232
|
o
|
|
3233
3233
|
);
|
|
3234
3234
|
return d && l.push(d), {
|
|
3235
|
-
command: new
|
|
3235
|
+
command: new v(l),
|
|
3236
3236
|
followup: async () => {
|
|
3237
3237
|
n.markUpdateCompleted(r), await n.setSelectionsAndElements(e.stepName, [t], a);
|
|
3238
3238
|
}
|
|
@@ -3263,7 +3263,7 @@ class Oa {
|
|
|
3263
3263
|
w.push(...h);
|
|
3264
3264
|
}
|
|
3265
3265
|
return d && w.push(d), {
|
|
3266
|
-
command: new
|
|
3266
|
+
command: new v(w),
|
|
3267
3267
|
followup: async () => {
|
|
3268
3268
|
n.markUpdateCompleted(r);
|
|
3269
3269
|
}
|
|
@@ -3377,7 +3377,7 @@ class Oa {
|
|
|
3377
3377
|
const s = new NA(A, e);
|
|
3378
3378
|
n.push(s);
|
|
3379
3379
|
}
|
|
3380
|
-
return new
|
|
3380
|
+
return new v(n);
|
|
3381
3381
|
}
|
|
3382
3382
|
/**
|
|
3383
3383
|
* @deprecated
|
|
@@ -3430,7 +3430,7 @@ class Oa {
|
|
|
3430
3430
|
)
|
|
3431
3431
|
);
|
|
3432
3432
|
}
|
|
3433
|
-
return new
|
|
3433
|
+
return new v(u);
|
|
3434
3434
|
}
|
|
3435
3435
|
}
|
|
3436
3436
|
const K = new Oa();
|
|
@@ -5050,7 +5050,7 @@ class en {
|
|
|
5050
5050
|
this.storage[o.stepName] = o.storage || {};
|
|
5051
5051
|
}), this.allScenes = await ma(e);
|
|
5052
5052
|
const a = Ae(this.allScenes, this.stepSelections).map((o) => o.silentSteps).flat(), { stepElements: n, commands: i } = await this.stepElementsForIntroducedSilentSteps(a, !!this.reloadedState);
|
|
5053
|
-
this.commandContext.apply(new
|
|
5053
|
+
this.commandContext.apply(new v(i), !0), this.stepElements = { ...this.stepElements, ...n }, await this.ensureStepsAreLoaded(), !this.isReloadedTransaction && this.updateStateWithServer(), this.renderLayouts(), this.reloadedState && t();
|
|
5054
5054
|
}
|
|
5055
5055
|
getClient() {
|
|
5056
5056
|
return this.client;
|
|
@@ -5449,7 +5449,7 @@ class en {
|
|
|
5449
5449
|
(m = p == null ? void 0 : p.frameService) == null || m.setTargetElements(A.map((I) => I.id));
|
|
5450
5450
|
}
|
|
5451
5451
|
const h = l.map((p) => new $(p.id)), C = new Qt(this.constructSerializableWorkflow()), u = [...w, ...h, C];
|
|
5452
|
-
u.length > 0 && this.commandContext.apply(new
|
|
5452
|
+
u.length > 0 && this.commandContext.apply(new v(u), !0), await this.ensureStepsAreLoaded(), this.onElementsChange();
|
|
5453
5453
|
const f = this.getInvalidModelVariants(), Q = this.modelContainer;
|
|
5454
5454
|
if (Q) {
|
|
5455
5455
|
const p = f.map(
|
|
@@ -5532,7 +5532,7 @@ class en {
|
|
|
5532
5532
|
throw new Error(`Step initialization failed: ${s.reason}`);
|
|
5533
5533
|
return s.value;
|
|
5534
5534
|
}), i = n.filter((s) => !!s && !!s.command).map((s) => s.command), o = n.filter((s) => !!s && !!s.followup).map((s) => s.followup);
|
|
5535
|
-
i && i.length > 0 && this.commandContext.apply(new
|
|
5535
|
+
i && i.length > 0 && this.commandContext.apply(new v(i), !0);
|
|
5536
5536
|
for (const s of o)
|
|
5537
5537
|
await s();
|
|
5538
5538
|
o.length > 0 && await this.ensureStepsAreLoaded(), this.onInitChange();
|
|
@@ -6753,8 +6753,8 @@ class me {
|
|
|
6753
6753
|
anonymousCrossOrigin: !0,
|
|
6754
6754
|
ignoreDimensions: !1,
|
|
6755
6755
|
createCanvas: Ye,
|
|
6756
|
-
createImage:
|
|
6757
|
-
DOMParser:
|
|
6756
|
+
createImage: vt,
|
|
6757
|
+
DOMParser: Gt(),
|
|
6758
6758
|
fetch: $e
|
|
6759
6759
|
})).render();
|
|
6760
6760
|
const C = await this.getCanvasObjectURLAsync(i);
|
|
@@ -7068,7 +7068,7 @@ const mn = [
|
|
|
7068
7068
|
o && (e[A.stepName] = { selectedVariants: [o] });
|
|
7069
7069
|
const s = async (r) => {
|
|
7070
7070
|
var E;
|
|
7071
|
-
const g = await
|
|
7071
|
+
const g = await vA(
|
|
7072
7072
|
r || {
|
|
7073
7073
|
width: 1,
|
|
7074
7074
|
height: 1
|
|
@@ -7119,7 +7119,7 @@ const mn = [
|
|
|
7119
7119
|
const a = t.data, n = A.option;
|
|
7120
7120
|
if (!n)
|
|
7121
7121
|
return console.error(`No option for step ${A.stepName}.`), [];
|
|
7122
|
-
const i = ((m = n.variants) == null ? void 0 : m.find((I) => I.id === a.illustrationVariantId)) ||
|
|
7122
|
+
const i = ((m = n.variants) == null ? void 0 : m.find((I) => I.id === a.illustrationVariantId)) || ve(n);
|
|
7123
7123
|
if (!i)
|
|
7124
7124
|
return console.error(`No variant with ID: ${a.illustrationVariantId}`), [];
|
|
7125
7125
|
if (!i.asset)
|
|
@@ -7133,7 +7133,7 @@ const mn = [
|
|
|
7133
7133
|
return console.error("Failed to read SVG."), [];
|
|
7134
7134
|
bt(w);
|
|
7135
7135
|
const E = {};
|
|
7136
|
-
|
|
7136
|
+
GA(w, (I) => {
|
|
7137
7137
|
mn.includes(I.tagName) && !I.attributes.getNamedItem("fill") && I.setAttribute("fill", "#000000");
|
|
7138
7138
|
const F = I.attributes.getNamedItem("fill");
|
|
7139
7139
|
if (F && F.value !== "none") {
|
|
@@ -7218,7 +7218,7 @@ const mn = [
|
|
|
7218
7218
|
const a = t.data, n = A.option;
|
|
7219
7219
|
if (!n)
|
|
7220
7220
|
return console.error(`No option for step ${A.stepName}.`), [];
|
|
7221
|
-
const i = ((g = n.variants) == null ? void 0 : g.find((l) => l.id === a.pictureVariantId)) ||
|
|
7221
|
+
const i = ((g = n.variants) == null ? void 0 : g.find((l) => l.id === a.pictureVariantId)) || ve(n);
|
|
7222
7222
|
if (!i)
|
|
7223
7223
|
return console.error(`No variant with ID: ${a.pictureVariantId}`), [];
|
|
7224
7224
|
if (!i.asset)
|
|
@@ -7260,7 +7260,7 @@ const mn = [
|
|
|
7260
7260
|
const a = t.data, n = A.option;
|
|
7261
7261
|
if (!n)
|
|
7262
7262
|
return console.error(`No option for step ${A.stepName}.`), [];
|
|
7263
|
-
const i = ((r = n.variants) == null ? void 0 : r.find((g) => g.id === a.colorVariantId)) ||
|
|
7263
|
+
const i = ((r = n.variants) == null ? void 0 : r.find((g) => g.id === a.colorVariantId)) || ve(n);
|
|
7264
7264
|
if (!i)
|
|
7265
7265
|
return console.error(`No variant with ID: ${a.colorVariantId}`), [];
|
|
7266
7266
|
e[A.stepName] = { selectedVariants: [i] };
|
|
@@ -7385,7 +7385,7 @@ const mn = [
|
|
|
7385
7385
|
const h = A.option;
|
|
7386
7386
|
if (!h)
|
|
7387
7387
|
return;
|
|
7388
|
-
const C = ((f = h.variants) == null ? void 0 : f.find((Q) => Q.id === n.fontVariantId)) ||
|
|
7388
|
+
const C = ((f = h.variants) == null ? void 0 : f.find((Q) => Q.id === n.fontVariantId)) || ve(h);
|
|
7389
7389
|
if (!C || !C.asset)
|
|
7390
7390
|
return;
|
|
7391
7391
|
e[A.stepName] = { selectedVariants: [C] };
|
|
@@ -7686,8 +7686,8 @@ class Rn extends Zt {
|
|
|
7686
7686
|
ignoreMouse: !0,
|
|
7687
7687
|
enableRedraw: !1,
|
|
7688
7688
|
createCanvas: Ye,
|
|
7689
|
-
createImage:
|
|
7690
|
-
DOMParser:
|
|
7689
|
+
createImage: vt,
|
|
7690
|
+
DOMParser: Gt(),
|
|
7691
7691
|
fetch: $e
|
|
7692
7692
|
});
|
|
7693
7693
|
B.resize(o, s), await B.render(), this.onRender();
|
|
@@ -7709,9 +7709,9 @@ const Ti = (c, e) => {
|
|
|
7709
7709
|
serializableWorkflow: { steps: [] },
|
|
7710
7710
|
layouts: {}
|
|
7711
7711
|
};
|
|
7712
|
-
a = new
|
|
7712
|
+
a = new v(t.map((s) => new kA(s))).apply(a);
|
|
7713
7713
|
const i = await Pn(c, e, t, A);
|
|
7714
|
-
return new
|
|
7714
|
+
return new v(i).apply(a);
|
|
7715
7715
|
}, Un = D`
|
|
7716
7716
|
${ne}
|
|
7717
7717
|
fragment ProductFields on Product {
|
|
@@ -7810,7 +7810,7 @@ const Ti = (c, e) => {
|
|
|
7810
7810
|
}
|
|
7811
7811
|
}
|
|
7812
7812
|
}
|
|
7813
|
-
`,
|
|
7813
|
+
`, vn = (c) => D`
|
|
7814
7814
|
${wA(c)}
|
|
7815
7815
|
query GetBundle($id: String!) {
|
|
7816
7816
|
bundles(ids: [$id]) {
|
|
@@ -7832,7 +7832,7 @@ const Ti = (c, e) => {
|
|
|
7832
7832
|
}
|
|
7833
7833
|
}
|
|
7834
7834
|
}
|
|
7835
|
-
`,
|
|
7835
|
+
`, Gn = D`
|
|
7836
7836
|
query GetBundleStakeholders($id: String!) {
|
|
7837
7837
|
bundles(ids: [$id]) {
|
|
7838
7838
|
id
|
|
@@ -8149,7 +8149,7 @@ class Zn extends Bt {
|
|
|
8149
8149
|
const t = await this.getOriginalImage();
|
|
8150
8150
|
if (!t)
|
|
8151
8151
|
throw new Error("You must supply an image selection before attempting to remove the background.");
|
|
8152
|
-
const A = this.bundle.getGlobalPropertyStateManager(), a = await
|
|
8152
|
+
const A = this.bundle.getGlobalPropertyStateManager(), a = await G.removeBackgroundFromAsset(t), i = {
|
|
8153
8153
|
...A.getAspectStorage(this.property.name),
|
|
8154
8154
|
backgroundRemovedAssetKey: a.key,
|
|
8155
8155
|
useOriginalAsset: !e
|
|
@@ -8169,7 +8169,7 @@ class Zn extends Bt {
|
|
|
8169
8169
|
async getImage() {
|
|
8170
8170
|
const e = this.getStateValue();
|
|
8171
8171
|
if (e)
|
|
8172
|
-
return
|
|
8172
|
+
return G.getLocalOrFromServer(e);
|
|
8173
8173
|
}
|
|
8174
8174
|
/**
|
|
8175
8175
|
* Retrieves the original, unmodified image selection, if one exists.
|
|
@@ -8178,7 +8178,7 @@ class Zn extends Bt {
|
|
|
8178
8178
|
async getOriginalImage() {
|
|
8179
8179
|
const e = this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);
|
|
8180
8180
|
if (e != null && e.originalAssetKey)
|
|
8181
|
-
return
|
|
8181
|
+
return G.getLocalOrFromServer(e.originalAssetKey);
|
|
8182
8182
|
}
|
|
8183
8183
|
/**
|
|
8184
8184
|
* Retrieves the version of the image selection that has the background removed, if one exists.
|
|
@@ -8187,7 +8187,7 @@ class Zn extends Bt {
|
|
|
8187
8187
|
async getBackgroundRemovedImage() {
|
|
8188
8188
|
const e = this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);
|
|
8189
8189
|
if (e != null && e.backgroundRemovedAssetKey)
|
|
8190
|
-
return
|
|
8190
|
+
return G.getLocalOrFromServer(e.backgroundRemovedAssetKey);
|
|
8191
8191
|
}
|
|
8192
8192
|
getUseOriginalImage() {
|
|
8193
8193
|
var e;
|
|
@@ -8223,7 +8223,7 @@ class Zn extends Bt {
|
|
|
8223
8223
|
const t = this.getStateValue();
|
|
8224
8224
|
if (!t)
|
|
8225
8225
|
return;
|
|
8226
|
-
const A = await
|
|
8226
|
+
const A = await G.getLocalOrFromServer(t);
|
|
8227
8227
|
if (!A)
|
|
8228
8228
|
return;
|
|
8229
8229
|
await this.applyImageSelection(A, e, !1);
|
|
@@ -9159,7 +9159,7 @@ class St {
|
|
|
9159
9159
|
}
|
|
9160
9160
|
async getAllStakeholders() {
|
|
9161
9161
|
const e = await x.getShadowGraphqlClient().query({
|
|
9162
|
-
query:
|
|
9162
|
+
query: Gn,
|
|
9163
9163
|
errorPolicy: "all",
|
|
9164
9164
|
fetchPolicy: "no-cache",
|
|
9165
9165
|
variables: {
|
|
@@ -10207,8 +10207,8 @@ const Bi = D`
|
|
|
10207
10207
|
return A.forEach((n) => {
|
|
10208
10208
|
n.steps.forEach((i) => {
|
|
10209
10209
|
var o, s, r;
|
|
10210
|
-
delete i.data.__typename, (o = i.option) != null && o.id && ((s = i.option.defaultVariant) != null && s.asset &&
|
|
10211
|
-
g.asset &&
|
|
10210
|
+
delete i.data.__typename, (o = i.option) != null && o.id && ((s = i.option.defaultVariant) != null && s.asset && G.cacheAsset(i.option.defaultVariant.asset), i.option.colorProfile && G.cacheAsset(i.option.colorProfile), (r = i.option.variants) == null || r.forEach((g) => {
|
|
10211
|
+
g.asset && G.cacheAsset(g.asset), g.displayImage && G.cacheAsset(g.displayImage), g.thumbnail && G.cacheAsset(g.thumbnail), g.material && G.cacheMaterial(g.material);
|
|
10212
10212
|
}), de.set({ id: i.option.id }, Promise.resolve(i.option)));
|
|
10213
10213
|
});
|
|
10214
10214
|
}), A;
|
|
@@ -10244,7 +10244,7 @@ const Bi = D`
|
|
|
10244
10244
|
};
|
|
10245
10245
|
class Si {
|
|
10246
10246
|
constructor(e) {
|
|
10247
|
-
this.updateTransactionState = async (t) => {
|
|
10247
|
+
this.activeIntegration = void 0, this.updateTransactionState = async (t) => {
|
|
10248
10248
|
try {
|
|
10249
10249
|
return x.getShadowGraphqlClient().mutate({
|
|
10250
10250
|
...t,
|
|
@@ -10260,7 +10260,7 @@ class Si {
|
|
|
10260
10260
|
* and the Spiff Commerce platform.
|
|
10261
10261
|
*/
|
|
10262
10262
|
getAssetManager() {
|
|
10263
|
-
return
|
|
10263
|
+
return G;
|
|
10264
10264
|
}
|
|
10265
10265
|
getCurrencyCode() {
|
|
10266
10266
|
if (this.currencyCode === void 0)
|
|
@@ -10276,11 +10276,14 @@ class Si {
|
|
|
10276
10276
|
if (!this.options.applicationKey)
|
|
10277
10277
|
throw new Error("Cannot get current Integration without specifying an Application Key.");
|
|
10278
10278
|
if (this.activeIntegration)
|
|
10279
|
-
return this.activeIntegration;
|
|
10280
|
-
const e = async () =>
|
|
10281
|
-
query
|
|
10282
|
-
|
|
10283
|
-
|
|
10279
|
+
return console.log("returning current promise"), this.activeIntegration;
|
|
10280
|
+
const e = async () => {
|
|
10281
|
+
const A = await x.getShadowGraphqlClient().query({
|
|
10282
|
+
query: Ci,
|
|
10283
|
+
errorPolicy: "all"
|
|
10284
|
+
});
|
|
10285
|
+
return console.log("Get integration response", A), A.data.currentIntegration;
|
|
10286
|
+
};
|
|
10284
10287
|
return this.activeIntegration = e(), this.activeIntegration;
|
|
10285
10288
|
}
|
|
10286
10289
|
async canUseAddon(e) {
|
|
@@ -10537,7 +10540,7 @@ class Si {
|
|
|
10537
10540
|
...g,
|
|
10538
10541
|
...(C = a == null ? void 0 : a.graphql) == null ? void 0 : C.additionalHeaders
|
|
10539
10542
|
}, l = await x.getShadowGraphqlClient().query({
|
|
10540
|
-
query:
|
|
10543
|
+
query: vn(((f = (u = a == null ? void 0 : a.graphql) == null ? void 0 : u.productCollection) == null ? void 0 : f.eagerFetchProducts) || !1),
|
|
10541
10544
|
variables: {
|
|
10542
10545
|
id: e
|
|
10543
10546
|
},
|
|
@@ -11208,7 +11211,7 @@ class Pi extends W {
|
|
|
11208
11211
|
const t = await this.getOriginalImageSelection();
|
|
11209
11212
|
if (!t)
|
|
11210
11213
|
throw new Error("You must supply an image selection before attempting to remove the background.");
|
|
11211
|
-
const A = await
|
|
11214
|
+
const A = await G.removeBackgroundFromAsset(t);
|
|
11212
11215
|
e && await Fe.selectImage(this.step, A, this.manager);
|
|
11213
11216
|
const a = ((n = this.manager.getStepStorage(this.step.stepName)) == null ? void 0 : n.framePatternData) || {};
|
|
11214
11217
|
return this.manager.updateStorage(this.step.stepName, {
|
|
@@ -11239,13 +11242,13 @@ class Pi extends W {
|
|
|
11239
11242
|
var t, A;
|
|
11240
11243
|
const e = (A = (t = this.manager.getStepStorage(this.step.stepName)) == null ? void 0 : t.framePatternData) == null ? void 0 : A.originalAssetKey;
|
|
11241
11244
|
if (e)
|
|
11242
|
-
return
|
|
11245
|
+
return G.getLocalOrFromServer(e);
|
|
11243
11246
|
}
|
|
11244
11247
|
async getBackgroundRemovedImageSelection() {
|
|
11245
11248
|
var t, A;
|
|
11246
11249
|
const e = (A = (t = this.manager.getStepStorage(this.step.stepName)) == null ? void 0 : t.framePatternData) == null ? void 0 : A.backgroundRemovedAssetKey;
|
|
11247
11250
|
if (e)
|
|
11248
|
-
return
|
|
11251
|
+
return G.getLocalOrFromServer(e);
|
|
11249
11252
|
}
|
|
11250
11253
|
hasBackgroundRemovedImageSelection() {
|
|
11251
11254
|
var e, t;
|
|
@@ -11359,7 +11362,7 @@ export {
|
|
|
11359
11362
|
X as Variant,
|
|
11360
11363
|
Qn as WorkflowExperienceEventType,
|
|
11361
11364
|
me as WorkflowExperienceImpl,
|
|
11362
|
-
|
|
11365
|
+
G as assetService,
|
|
11363
11366
|
hn as createDesign,
|
|
11364
11367
|
Io as dataUrlFromExternalUrl,
|
|
11365
11368
|
Te as designService,
|
|
@@ -11392,8 +11395,8 @@ export {
|
|
|
11392
11395
|
aA as questionStepService,
|
|
11393
11396
|
Ro as registerFetchImplementation,
|
|
11394
11397
|
Uo as registerWindowImplementation,
|
|
11395
|
-
|
|
11396
|
-
|
|
11398
|
+
vo as rehydrateSerializedLayout,
|
|
11399
|
+
Go as setCanvasModule,
|
|
11397
11400
|
re as shapeStepService,
|
|
11398
11401
|
ya as shortenUrl,
|
|
11399
11402
|
q as spiffCoreConfiguration,
|
package/dist/index.umd.cjs
CHANGED
|
@@ -3031,4 +3031,4 @@ IfnI8vaNAAAAAElFTkSuQmCC" transform="matrix(0.13 0.0141 -0.0141 0.1301 104.926 1
|
|
|
3031
3031
|
}
|
|
3032
3032
|
}
|
|
3033
3033
|
}
|
|
3034
|
-
`,ne=async c=>{var e;for(const t in c.layouts){const A=c.layouts[t].elements.filter(a=>a.type===l.LayoutElementType.Illustration);for(let a=0;a<A.length;++a){const i=A[a];i.src&&i.svg&&(i.cachedObjectURL=await l.svgObjectURL(i.svg))}const n=c.layouts[t].elements.filter(a=>a.type===l.LayoutElementType.Textbox);for(let a=0;a<n.length;++a){const i=n[a];(e=i.fontData)!=null&&e.assetUrl&&await l.loadFont(i.fontData.assetUrl)}}},pa=async(c,e)=>{var n;const t=await N.getShadowGraphqlClient().query({query:ha(((n=e==null?void 0:e.assets)==null?void 0:n.metadata)||!1),errorPolicy:"all",fetchPolicy:"no-cache",variables:{ids:c}}),A=t.data.workflows;if(A===void 0||A.length!==c.length)throw new Error(`Unable to read workflows: ${t.errors??"Length mismatch in response"}`);return A.forEach(a=>{a.steps.forEach(i=>{var o,s,r;delete i.data.__typename,(o=i.option)!=null&&o.id&&((s=i.option.defaultVariant)!=null&&s.asset&&G.cacheAsset(i.option.defaultVariant.asset),i.option.colorProfile&&G.cacheAsset(i.option.colorProfile),(r=i.option.variants)==null||r.forEach(g=>{g.asset&&G.cacheAsset(g.asset),g.displayImage&&G.cacheAsset(g.displayImage),g.thumbnail&&G.cacheAsset(g.thumbnail),g.material&&G.cacheMaterial(g.material)}),Z.set({id:i.option.id},Promise.resolve(i.option)))})}),A},Fa=async(c,e)=>{const A=(await e).find(n=>n.id===c);if(!A)throw new Error(`Workflow not found: ${c}`);return A},_e=async(c,e)=>{const t=c.map(o=>Z.get({id:o,options:e})),A=c.filter((o,s)=>t[s]===void 0);if(A.length===0)return Promise.all(t);const n=pa(A,e),a=A.map(o=>Z.set({id:o,options:e},Fa(o,n))),i=t.filter(o=>o!==void 0);return await Promise.all(i.concat(a))},Ce=async(c,e)=>(await _e([c],e))[0],Ma=c=>c.sort((e,t)=>e.index-t.index).map(e=>({id:l.generate(),panelId:e.name,name:e.name,index:e.index,createdAt:new Date,updatedAt:new Date,transparentBackground:e.transparentBackground,height:e.height,width:e.width,previewRegion:e.previewRegion,useEditableArea:e.useEditableArea,editableArea:e.editableArea})),et=(c,e)=>{const t=c.workflowState,A=t?JSON.parse(t):void 0;return A?Object.values(A.layouts).map(n=>n.layout):Ma(e.panels)};class cA{constructor(e){this.updateTransactionState=async t=>{try{return N.getShadowGraphqlClient().mutate({...t,mutation:GA})}catch(A){throw console.error(A),new v("Critical - Unable to synchronize workflow state with server.")}},this.initialized=!1,this.options=e,this.options.applicationKey&&EA(this.options.applicationKey)}getAssetManager(){return G}getCurrencyCode(){if(this.currencyCode===void 0)throw new Error("No currency code set.");return this.currencyCode}getFlowService(){if(!CA())throw new Error("Application key required to use Flow Service.");return new oA}async getIntegration(){if(!this.options.applicationKey)throw new Error("Cannot get current Integration without specifying an Application Key.");if(this.activeIntegration)return this.activeIntegration;const e=async()=>(await N.getShadowGraphqlClient().query({query:Ca,errorPolicy:"all"})).data.currentIntegration;return this.activeIntegration=e(),this.activeIntegration}async canUseAddon(e){var t;try{return((t=(await this.getIntegration()).partner.activeAddons)==null?void 0:t.includes(e))??!1}catch(A){return console.error(A),!1}}async authenticateBundleFromLocalStorage(e){var n,a;const t=P.getMap("bundleOwnerIds");if(t!=null&&t.has(e))return Promise.resolve({success:!0,stakeholderType:ge.Owner});const A=P.getMap("bundlePartnerIds")||new Map;if(A.has(e)){const i=A.get(e),s=(P.getMap("partnerCustomerIds")||new Map).get(i);if(s&&await this.authenticateCustomerId(s)){const g=(a=(n=this.customer)==null?void 0:n.bundleStakeholders)==null?void 0:a.find(B=>{var d;return((d=B.bundle)==null?void 0:d.id)===e});if(g)return Promise.resolve({success:!0,stakeholderType:g.type})}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(e){var g,B,d,w,h,u;const t=N.getShadowGraphqlClient(),A=await t.query({query:Ea,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:e}});if(!A.data.transactions||A.data.transactions.length===0)throw new Error(`Transaction not found: ${e}`);const n=A.data.transactions[0];if(!((B=(g=n.product)==null?void 0:g.partner)==null?void 0:B.id))throw new Error(`Unable to read transaction: ${e}`);if(n.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const i=P.getMap("transactionOwnerIds");if(i!=null&&i.has(e))return Promise.resolve({success:!0,stakeholderType:ge.Owner});const o=P.getMap("transactionCustomerIds");if(o!=null&&o.has(e)){const E=o.get(e);if(E&&await this.authenticateCustomerId(E)){const Q=((w=(d=this.customer)==null?void 0:d.bundleStakeholders)==null?void 0:w.find(F=>{var I,f;return(f=(I=F.bundle)==null?void 0:I.transactions)==null?void 0:f.some(D=>D.id===e)}))||((u=(h=this.customer)==null?void 0:h.stakeholders)==null?void 0:u.find(F=>{var I;return((I=F.transaction)==null?void 0:I.id)===e}));if(Q)return Promise.resolve({success:!0,stakeholderType:Q.type})}}const r=(await t.query({query:ua,errorPolicy:"all",variables:{id:n.workflowId}})).data.workflow;if(!r)throw new Error(`Unable to read workflow: ${n.workflowId}`);return Promise.resolve({success:!1,theme:r.overrideTheme,customLogoLink:n.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(e){const t=P.getMap("transactionCustomerIds");t!=null&&t.has(e)&&(t.delete(e),P.setMap("transactionCustomerIds",t))}getStakeholderTypeForTransaction(e){var A,n;const t=(n=(A=this.customer)==null?void 0:A.stakeholders)==null?void 0:n.find(a=>{var i;return((i=a.transaction)==null?void 0:i.id)===e});if(t)return t.type}async getOrCreateCustomer(e){var i;this.customer=void 0;const t=N.getShadowGraphqlClient(),n=(await t.query({query:Qa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:e}})).data.customer;if(!n.id){const s=(i=(await t.mutate({mutation:ma,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:e}}})).data)==null?void 0:i.customerCreate;if(!s)throw new Error("Unable to create customer.");return this.storeCustomer(s),this.customer=s,{customer:s,isAuthenticated:!1}}this.storeCustomer(n);const a=await this.authenticateCustomerId(n.id);return{customer:this.customer||n,isAuthenticated:a}}async authenticateCustomerId(e){var o;const t=N.getShadowGraphqlClient(),A=P.getMap("customerTokens");if(!(A!=null&&A.has(e)))return!1;const n=A.get(e);if(!n)return!1;const i=(o=(await t.mutate({mutation:Ia,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:n}})).data)==null?void 0:o.customerAuthenticate;return i?(this.storeCustomer(i),lt(n),this.customer=i,!0):!1}async generateVerificationCode(e){await N.getShadowGraphqlClient().mutate({mutation:fa,variables:{emailAddress:e}})}async verifyCode(e,t){var a,i;const n=(a=(await N.getShadowGraphqlClient().mutate({mutation:Da,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:e,verificationCode:t}})).data)==null?void 0:a.customerVerifyCode;if(n!=null&&n.loginToken){if(!((i=n.partner)!=null&&i.id))throw new Error(`Unable to find customer: ${e}`);const o=P.getMap("customerTokens")||new Map;return o.set(n.id,n.loginToken),P.setMap("customerTokens",o),this.storeCustomer(n),lt(n.loginToken),this.customer={...n,loginToken:void 0},!0}return!1}async getNewBundle(e,t,A){var s,r,g;const a=(g=(await N.getShadowGraphqlClient().mutate({mutation:Kn(((r=(s=A==null?void 0:A.graphql)==null?void 0:s.productCollection)==null?void 0:r.eagerFetchProducts)||!1),variables:{collectionId:e,initialMetadata:t?Object.entries(t).map((B,d)=>({key:B[0],value:B[1]})):void 0},fetchPolicy:"no-cache"})).data)==null?void 0:g.bundleCreate;if(!(a!=null&&a.id))throw new Error("Unable to create bundle");const i=P.getMap("bundlePartnerIds")||new Map;i.set(a.id,a.partner.id),P.setMap("bundlePartnerIds",i);const o=P.getMap("bundleOwnerIds")||new Map;return o.set(a.id,a.bundleOwnerId),P.setMap("bundleOwnerIds",o),new iA(this,a,void 0,void 0,a.bundleOwnerId)}async getExistingBundle(e,t,A,n){var E,m,Q,F,I,f,D,p,y;const a=P.getMap("bundleOwnerIds"),i=a==null?void 0:a.get(e),s=((E=Object.entries(localStorage).find(([S,x])=>S.startsWith("CognitoIdentityServiceProvider")&&S.endsWith("idToken")))==null?void 0:E[0])||"",r=localStorage.getItem(s),g={};r&&!Ke(r)&&(g.Authorization=`Bearer ${r}`);const B={bundleOwnerId:i,...g,...(m=n==null?void 0:n.graphql)==null?void 0:m.additionalHeaders},d=await N.getShadowGraphqlClient().query({query:On(((F=(Q=n==null?void 0:n.graphql)==null?void 0:Q.productCollection)==null?void 0:F.eagerFetchProducts)||!1),variables:{id:e},fetchPolicy:"no-cache",context:{headers:B}});if(!((I=d.data)!=null&&I.bundles)||((f=d.data)==null?void 0:f.bundles.length)===0||!((D=d.data)!=null&&D.bundles[0]))throw new Error(`Unable to find bundle: ${e}`);const w=(p=d.data)==null?void 0:p.bundles[0],h=P.getMap("bundlePartnerIds")||new Map;h.set(w.id,w.partner.id),P.setMap("bundlePartnerIds",h);const u=new iA(this,w,t,A,i,{additionalHeaders:(y=n==null?void 0:n.graphql)==null?void 0:y.additionalHeaders});return await u.getInitializationPromise(),u}async getBundleStakeholders(){var a;if(!this.customer)throw new Error("Customer not authenticated.");const e=await N.getShadowGraphqlClient().query({query:zn,variables:{id:this.customer.id},fetchPolicy:"no-cache"});if(!((a=e.data)!=null&&a.customers)||e.data.customers.length===0)throw new Error("Unable to find customer.");const A=e.data.customers[0].bundleStakeholders||[],n=P.getMap("bundlePartnerIds")||new Map;return A.forEach(i=>{var o,s;(o=i.bundle)!=null&&o.id&&((s=i.bundle.partner)!=null&&s.id)&&n.set(i.bundle.id,i.bundle.partner.id)}),P.setMap("bundlePartnerIds",n),A}async getWorkflowExperience(e,t,A,n){var B,d,w,h,u;if(!n)return await this.getWorkflowExperienceDeprecated(e,t,A);const a=async()=>{var m,Q;const E=N.getShadowGraphqlClient();if(n.type==="transaction"){const{transactionId:F,readOnly:I}=n,f=await E.query({query:Ie,variables:{ids:[F]},errorPolicy:"all",fetchPolicy:"no-cache"});if(!((m=f.data)!=null&&m.transactions)||f.data.transactions.length===0)throw new v("Existing transaction not found.");const D=(Q=f.data)==null?void 0:Q.transactions[0];if(!D.workflowId)throw new v("Existing transaction has no workflow ID.");const p=await Ce(D.workflowId);if(!D.product)throw new v("Failed to load transaction, product not available.");return{transaction:D,workflow:p,readOnly:I}}if(n.type==="integration"||n.type==="external"){const F=async()=>{const p=n.type==="integration"?{integrationProductId:n.integrationProductId}:{externalIntegrationId:n.externalIntegrationId,externalProductId:n.externalProductId},y=await E.mutate({mutation:ut,variables:{...p,workflowId:n.workflowId,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!y.data||!y.data.transactionCreate)throw new v("Failed to create transaction!");const S=y.data.transactionCreate;if(!S.product)throw new v("Failed to create transaction, product not available.");return S},I=Ce(n.workflowId,n==null?void 0:n.graphql),[f,D]=await Promise.all([F(),I]);return{transaction:f,workflow:D}}throw new v("No workflow ID provided.")},{transaction:i,workflow:o,readOnly:s}=await a();this.currencyCode=(B=i.product.partner)==null?void 0:B.currencyCode;const r={product:i.product,transaction:i,layouts:[],singleVariantsRenderable:(d=n==null?void 0:n.workflowConfiguration)==null?void 0:d.singleVariantsRenderable,stateMutationFunc:s?async()=>{throw new k("State mutation is forbidden in read only mode!")}:async E=>{const Q=(P.getMap("transactionOwnerIds")||new Map).get(i.id)||void 0;return this.updateTransactionState({...E,context:{transactionOwnerId:Q}})},readOnly:s,workflow:o};if(n.type==="transaction"&&i.workflowState){const E=JSON.parse(i.workflowState);r.layouts=Object.values(E.layouts).map(m=>m.layout),await l.rehydrateSerializedLayout(E),await ne(E),r.reloadedState=E}else if(!s&&n.workflowState){const E=JSON.parse(n.workflowState);r.layouts=Object.values(E.layouts).map(m=>m.layout),await l.rehydrateSerializedLayout(E),await ne(E),r.reloadedState=E}else r.layouts=et(r.transaction,r.workflow);if(r.renderableContextService=new ye(r.layouts),n.previewService?(r.previewService=n.previewService,(w=r.product)!=null&&w.modelUrl&&(r.modelContainer=r.previewService.loadModel({model:r.product.modelUrl,contextService:r.renderableContextService}))):(r.previewService=A&&A(o),(h=r.product)!=null&&h.modelUrl&&(r.modelContainer=(u=r.previewService)==null?void 0:u.loadModel({model:r.product.modelUrl,contextService:r.renderableContextService}))),n.type!=="transaction"){const E=P.getMap("transactionOwnerIds")||new Map;E.set(i.id,i.transactionOwnerId),P.setMap("transactionOwnerIds",E)}else r.isReloadedTransaction=!0;this.initialized=!0,this.experienceOptions=r;const g=new he(this,r);return await g.getWorkflowManager().getInitializationPromise(),n.type!=="transaction"&&this.customer&&await g.attachCustomerDetails({email:this.customer.emailAddress}),g}async getWorkflowExperiences(e,t){if(e.length===0)throw new v("No options provided!");const A=N.getShadowGraphqlClient(),n=async f=>{var S,x;if(f.length===0)return[];const D=f.map(Y=>Y.option.transactionId),p=await A.query({query:Ie,variables:{ids:D},errorPolicy:"all",fetchPolicy:"no-cache"}),y=p.data.transactions;if(y.length!==f.length){const Y=((x=(S=p.errors)==null?void 0:S[0])==null?void 0:x.message)||"Unknown error";throw new v(`Not all transactions were found: ${Y}`)}return y.map((Y,H)=>{var R;return{transaction:Y,workflowId:Y.workflowId,readOnly:((R=f.find(T=>T.option.transactionId===Y.id))==null?void 0:R.option.readOnly)??!1,index:f[H].index}})},a=async f=>{var y,S,x;if(f.length===0)return[];const D=await A.mutate({mutation:UA,variables:{inputs:f.map(Y=>({integrationProductId:Y.option.type==="integration"?Y.option.integrationProductId:void 0,externalIntegrationId:Y.option.type==="external"?Y.option.externalIntegrationId:void 0,externalProductId:Y.option.type==="external"?Y.option.externalProductId:void 0,workflowId:Y.option.workflowId,claim:!0}))},errorPolicy:"all",fetchPolicy:"no-cache"}),p=(y=D.data)==null?void 0:y.transactionCreateMany;if(!p||p.length===0){const Y=((x=(S=D.errors)==null?void 0:S[0])==null?void 0:x.message)||"Unknown error";throw new v(`Failed to create transactions: ${Y}`)}return p.map((Y,H)=>({transaction:Y,workflowId:Y.workflowId,readOnly:!1,index:f[H].index}))},i=e.map((f,D)=>({option:f,index:D})),o=i.filter(f=>f.option.type==="transaction"),s=i.filter(f=>f.option.type==="integration"||f.option.type==="external"),r=st(o,10),g=st(s,10),B=(await Promise.all([...r.map(n),...g.map(a)])).flat(),d=[...new Set(B.map(f=>f.workflowId))],w=await _e(d,t),h=new Map(w.map(f=>[f.id,f])),u=P.getMap("transactionOwnerIds")||new Map,E=B.map(async f=>{var T;const{transaction:D,workflowId:p,readOnly:y,index:S}=f,x=h.get(p),Y=e[S];!u.get(D.id)&&D.transactionOwnerId&&u.set(D.id,D.transactionOwnerId);const H=u.get(D.id)||void 0,R={product:D.product,transaction:D,layouts:[],singleVariantsRenderable:(T=Y==null?void 0:Y.workflowConfiguration)==null?void 0:T.singleVariantsRenderable,stateMutationFunc:y?async()=>{throw new k("State mutation is forbidden in read only mode!")}:async b=>this.updateTransactionState({...b,context:{transactionOwnerId:H}}),readOnly:y,workflow:x,isReloadedTransaction:Y.type==="transaction"};if(Y.type==="transaction"&&D.workflowState){const b=JSON.parse(D.workflowState);R.layouts=Object.values(b.layouts||{}).map(z=>z.layout),await l.rehydrateSerializedLayout(b),await ne(b),R.reloadedState=b}else if(!y&&Y.workflowState){const b=JSON.parse(Y.workflowState);R.layouts=Object.values(b.layouts||{}).map(z=>z.layout),await l.rehydrateSerializedLayout(b),await ne(b),R.reloadedState=b}else R.layouts=et(R.transaction,R.workflow);return R.renderableContextService=new ye(R.layouts),R.delayWorkflowStateSync=!0,this.initialized=!0,this.experienceOptions=R,{experienceOptions:R,index:S,options:Y}});P.setMap("transactionOwnerIds",u);const F=(await Promise.all(E)).sort((f,D)=>f.index-D.index).map(async f=>{const{experienceOptions:D,options:p}=f,y=new he(this,D);return await y.getWorkflowManager().getInitializationPromise(),p.type!=="transaction"&&this.customer&&await y.attachCustomerDetails({email:this.customer.emailAddress}),y}),I=await Promise.all(F);return I.forEach(f=>f.getWorkflowManager().setWorkflowStateSyncEnabled(!0)),I}async initFromIntegrationProduct(e){var i;if(e==="")throw new v("No integration product ID provided.");const A=await N.getShadowGraphqlClient().mutate({mutation:ut,variables:{integrationProductId:e,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!A.data||!A.data.transactionCreate)throw new v("Failed to create transaction!");const n=A.data.transactionCreate;if(!n.product)throw new v("Failed to create transaction, product not available.");this.currencyCode=(i=n.product.partner)==null?void 0:i.currencyCode;const a=P.getMap("transactionOwnerIds")||new Map;a.set(n.id,n.transactionOwnerId),P.setMap("transactionOwnerIds",a),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:async o=>this.updateTransactionState({...o,context:{transactionOwnerId:n.transactionOwnerId}})},this.initialized=!0}async initFromTransaction(e,t=!1){var o,s,r,g;if(e==="")throw new v("No transaction ID provided.");const A=N.getShadowGraphqlClient(),n=async()=>{var w,h;const d=(w=(await A.query({query:Ie,variables:{ids:[e]},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:w.transactions[0];if(!d)throw new v("Failed to read transaction.");if(!d.product)throw new v("Failed to load transaction, product not available.");this.currencyCode=(h=d.product.partner)==null?void 0:h.currencyCode,this.experienceOptions={product:d.product,transaction:d,layouts:[],stateMutationFunc:async()=>{throw new k("State mutation is forbidden in read only mode!")},readOnly:t},this.initialized=!0};if(t)return await n();const a=P.getMap("transactionOwnerIds")||new Map,i=a.get(e);if(i){const d=(o=(await A.query({query:Ie,variables:{ids:[e]},errorPolicy:"all"})).data)==null?void 0:o.transactions[0];if(!d)throw new v("Failed to read transaction.");if(!d.product)throw new v("Failed to load transaction, product not available.");this.currencyCode=(s=d.product.partner)==null?void 0:s.currencyCode,this.experienceOptions={product:d.product,transaction:d,layouts:[],stateMutationFunc:async w=>this.updateTransactionState({...w,context:{transactionOwnerId:i}}),readOnly:t},this.initialized=!0;return}try{const d=(r=(await A.mutate({mutation:vA,variables:{id:e},errorPolicy:"all"})).data)==null?void 0:r.transactionClaim;if(!d)throw new v("Failed to read transaction.");if(!d.product)throw new v("Failed to load transaction, product not available.");this.currencyCode=(g=d.product.partner)==null?void 0:g.currencyCode,d.transactionOwnerId&&(a.set(d.id,d.transactionOwnerId),P.setMap("transactionOwnerIds",a)),this.experienceOptions={product:d.product,transaction:d,layouts:[],stateMutationFunc:async w=>this.updateTransactionState({...w,context:{transactionOwnerId:d.transactionOwnerId}}),readOnly:t},this.initialized=!0}catch{throw new v("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(e,t,A){var n,a,i,o;if(!this.initialized||!this.experienceOptions)throw new v("Cannot launch experience: Not initialized.");if(this.experienceOptions.transaction.workflowId){const s=await Ce(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=s,this.experienceOptions.transaction.workflowState){const g=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(g.layouts).map(B=>B.layout),await l.rehydrateSerializedLayout(g),await ne(g),this.experienceOptions.reloadedState=g}this.experienceOptions.previewService=A&&A(s),this.experienceOptions.renderableContextService=new ye(this.experienceOptions.layouts),(n=this.experienceOptions.product)!=null&&n.modelUrl&&(this.experienceOptions.modelContainer=(a=this.experienceOptions.previewService)==null?void 0:a.loadModel({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}));const r=new he(this,this.experienceOptions);return await r.getWorkflowManager().getInitializationPromise(),r}if(e){const r=(P.getMap("transactionOwnerIds")||new Map).get(this.experienceOptions.transaction.id),g=N.getShadowGraphqlClient().mutate({mutation:kA,variables:{workflowId:e,id:this.experienceOptions.transaction.id},context:{transactionOwnerId:r}}),B=Ce(e);if(await Promise.all([g,B]),this.experienceOptions.workflow=await B,t){const w=JSON.parse(t);this.experienceOptions.layouts=Object.values(w.layouts).map(h=>h.layout),await l.rehydrateSerializedLayout(w),await ne(w),this.experienceOptions.reloadedState=w}else this.experienceOptions.layouts=et(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=A&&A(await B),this.experienceOptions.renderableContextService=new ye(this.experienceOptions.layouts),(i=this.experienceOptions.product)!=null&&i.modelUrl&&(this.experienceOptions.modelContainer=(o=this.experienceOptions.previewService)==null?void 0:o.loadModel({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}));const d=new he(this,this.experienceOptions);return await d.getWorkflowManager().getInitializationPromise(),d}throw new v("No workflow ID provided.")}getPreviewService(){var e;return(e=this.experienceOptions)==null?void 0:e.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new v("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new v("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}configureUrls(e,t,A){W.setHubUrl(e),W.setServerUrl(t),W.setServicesApiUrl(A),this.getIntegration()}storeCustomer(e){const t=P.getMap("partnerCustomerIds")||new Map;t.set(e.partner.id,e.id),P.setMap("partnerCustomerIds",t)}async getIntegrationProductById(e){var a,i;const n=(a=(await N.getShadowGraphqlClient().query({query:JA,variables:{ids:[e]},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:a.integrationProducts;if(!n||n.length===0||!((i=n[0])!=null&&i.id))throw new Error("Integration product not found.");return new $e(n[0])}async getIntegrationProductFromExternalIds(e,t){var i;const a=(i=(await N.getShadowGraphqlClient().query({query:TA,variables:{externalProductId:t,externalIntegrationId:e},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:i.integrationProductFromExternalIds;if(!(a!=null&&a.id))throw new Error("Integration product not found.");return new $e(a)}async getIntegrationProduct(e){return e.type==="integration"?this.getIntegrationProductById(e.integrationProductId):this.getIntegrationProductFromExternalIds(e.externalIntegrationId,e.externalProductId)}}class ya{getClient(){return this.client??{}}setClient(e){this.client=e}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}async reset(){}updateStateWithServer(e){}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(e){}addPoller(e){}addConfirmCallback(e){}addEditedCallback(e){}addElementsCallback(e){}addInformationResultCallback(e){}addInitCallback(e){}addMakingAdjustmentsCallback(e){}addMandatoryCallback(e){}addMetadataCallback(e){}addSelectionCallback(e){}addStepSpecificStorageCallback(e,t){}addStorageCallback(e){}getCommandDispatcher(){return e=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(e){return[]}getSerializedStep(e,t){}getStepSpecificServices(e){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(e){}markUpdateCompleted(e){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}setCurrentAdjustingStepId(e){}setEditedStatus(e,t){}setInformationResults(e){}setMandatoryFulfilled(e,t){}async setSelectionsAndElements(e,t,A){}toggleDesignConfirmed(){}updateMetadata(e,t){}async updateStorage(e,t){}injectIntoPreviewService(e){return Promise.resolve()}ejectFromPreviewService(){}setWorkflowStateSyncEnabled(e){}}var gA=(c=>(c.SelectFrame="SelectFrame",c.SelectImage="SelectImage",c.Position="Position",c))(gA||{});class lA extends j{constructor(e,t){var A;super(e,t),this.frameService=(A=this.manager.getStepSpecificServices(this.getId()))==null?void 0:A.frameService}selectVariant(e){const t=this.manager.getRegionElements(this.step.stepName);return de.selectVariant(this.step,e.getResource(),t,this.manager,A=>this.setUpdateState(A))}onFrameDataChanged(e){this.frameService&&this.frameService.onFrameDataChanged(t=>{t&&e(t)})}async selectImage(e,t=!0){var A;if(await de.selectImage(this.step,e,this.manager),t){const n=((A=this.manager.getStepStorage(this.step.stepName))==null?void 0:A.framePatternData)||{};this.manager.updateStorage(this.step.stepName,{framePatternData:{...n,originalAssetKey:e.key,backgroundRemovedAssetKey:void 0,useOriginalAsset:void 0}})}}async canUseBackgroundRemover(){return this.manager.getClient().canUseAddon(me.BackgroundRemover)}async removeBackgroundFromImageSelection(e=!0){var a;if(!await this.canUseBackgroundRemover())throw new Error("The current Integration does not have access to the Background Remover. Please call canUseBackgroundRemover to ensure you disable this feature when appropriate.");const t=await this.getOriginalImageSelection();if(!t)throw new Error("You must supply an image selection before attempting to remove the background.");const A=await G.removeBackgroundFromAsset(t);e&&await de.selectImage(this.step,A,this.manager);const n=((a=this.manager.getStepStorage(this.step.stepName))==null?void 0:a.framePatternData)||{};return this.manager.updateStorage(this.step.stepName,{framePatternData:{...n,backgroundRemovedAssetKey:A.key,useOriginalAsset:!e}}),A}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(e,t,A,n){return n&&n.length>1&&e===void 0?"SelectFrame":t||A||this.getImageData()?"Position":"SelectImage"}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}async getOriginalImageSelection(){var t,A;const e=(A=(t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.framePatternData)==null?void 0:A.originalAssetKey;if(e)return G.getLocalOrFromServer(e)}async getBackgroundRemovedImageSelection(){var t,A;const e=(A=(t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.framePatternData)==null?void 0:A.backgroundRemovedAssetKey;if(e)return G.getLocalOrFromServer(e)}hasBackgroundRemovedImageSelection(){var e,t;return!!((t=(e=this.getFrameStepStorage())==null?void 0:e.framePatternData)!=null&&t.backgroundRemovedAssetKey)}getUseOriginalImageSelection(){var e,t;return((t=(e=this.getFrameStepStorage())==null?void 0:e.framePatternData)==null?void 0:t.useOriginalAsset)??!1}async setUseOriginalImageSelection(e){var n;const t=((n=this.getFrameStepStorage())==null?void 0:n.framePatternData)||{};if(t.useOriginalAsset===e)return;const A=await this.getOriginalImageSelection();if(!A)throw new Error("You must provide an image selection before calling setUseOriginalImageSelection");if(e)await this.selectImage(A,!1);else{const a=await this.getBackgroundRemovedImageSelection();if(!a)throw new Error("You must call removeBackgroundFromImageSelection before attempting to apply the image.");await this.selectImage(a,!1)}this.manager.updateStorage(this.step.stepName,{framePatternData:{...t,useOriginalAsset:e}})}getFrameStepStorage(){return this.manager.getStepStorage(this.step.stepName)}}Object.defineProperty(C,"AspectType",{enumerable:!0,get:()=>l.AspectType}),Object.defineProperty(C,"AssetType",{enumerable:!0,get:()=>l.AssetType}),Object.defineProperty(C,"BringForwardCommand",{enumerable:!0,get:()=>l.BringForwardCommand}),Object.defineProperty(C,"BringToBackCommand",{enumerable:!0,get:()=>l.BringToBackCommand}),Object.defineProperty(C,"BringToFrontCommand",{enumerable:!0,get:()=>l.BringToFrontCommand}),Object.defineProperty(C,"CanvasCommand",{enumerable:!0,get:()=>l.CanvasCommand}),Object.defineProperty(C,"CommandContext",{enumerable:!0,get:()=>l.CommandContext}),Object.defineProperty(C,"CreateElementCommand",{enumerable:!0,get:()=>l.CreateElementCommand}),Object.defineProperty(C,"CreateLayoutCommand",{enumerable:!0,get:()=>l.CreateLayoutCommand}),Object.defineProperty(C,"DeleteElementCommand",{enumerable:!0,get:()=>l.DeleteElementCommand}),Object.defineProperty(C,"FontAlignmentCommand",{enumerable:!0,get:()=>l.FontAlignmentCommand}),Object.defineProperty(C,"FontColorCommand",{enumerable:!0,get:()=>l.FontColorCommand}),Object.defineProperty(C,"FontSizeCommand",{enumerable:!0,get:()=>l.FontSizeCommand}),Object.defineProperty(C,"FontSourceCommand",{enumerable:!0,get:()=>l.FontSourceCommand}),Object.defineProperty(C,"GroupCommand",{enumerable:!0,get:()=>l.GroupCommand}),Object.defineProperty(C,"LayoutElementFactory",{enumerable:!0,get:()=>l.LayoutElementFactory}),Object.defineProperty(C,"LayoutElementType",{enumerable:!0,get:()=>l.LayoutElementType}),Object.defineProperty(C,"MoveCommand",{enumerable:!0,get:()=>l.MoveCommand}),Object.defineProperty(C,"ResizeCommand",{enumerable:!0,get:()=>l.ResizeCommand}),Object.defineProperty(C,"RotateCommand",{enumerable:!0,get:()=>l.RotateCommand}),Object.defineProperty(C,"SendBackwardsCommand",{enumerable:!0,get:()=>l.SendBackwardsCommand}),Object.defineProperty(C,"StepAspectType",{enumerable:!0,get:()=>l.StepAspectType}),Object.defineProperty(C,"StepType",{enumerable:!0,get:()=>l.StepType}),Object.defineProperty(C,"TextChangeCommand",{enumerable:!0,get:()=>l.TextChangeCommand}),Object.defineProperty(C,"UnitOfMeasurement",{enumerable:!0,get:()=>l.UnitOfMeasurement}),Object.defineProperty(C,"dataUrlFromExternalUrl",{enumerable:!0,get:()=>l.dataUrlFromExternalUrl}),Object.defineProperty(C,"determineCorrectFontSizeAndLines",{enumerable:!0,get:()=>l.determineCorrectFontSizeAndLines}),Object.defineProperty(C,"findElement",{enumerable:!0,get:()=>l.findElement}),Object.defineProperty(C,"frameDataCache",{enumerable:!0,get:()=>l.frameDataCache}),Object.defineProperty(C,"generate",{enumerable:!0,get:()=>l.generate}),Object.defineProperty(C,"generateSVGWithUnknownColors",{enumerable:!0,get:()=>l.generateSVGWithUnknownColors}),Object.defineProperty(C,"getAttributesFromArrayBuffer",{enumerable:!0,get:()=>l.getAttributesFromArrayBuffer}),Object.defineProperty(C,"getAxisAlignedBoundingBox",{enumerable:!0,get:()=>l.getAxisAlignedBoundingBox}),Object.defineProperty(C,"getFrameData",{enumerable:!0,get:()=>l.getFrameData}),Object.defineProperty(C,"getSvgElement",{enumerable:!0,get:()=>l.getSvgElement}),Object.defineProperty(C,"loadFont",{enumerable:!0,get:()=>l.loadFont}),Object.defineProperty(C,"patternImageDataCache",{enumerable:!0,get:()=>l.patternImageDataCache}),Object.defineProperty(C,"registerFetchImplementation",{enumerable:!0,get:()=>l.registerFetchImplementation}),Object.defineProperty(C,"registerWindowImplementation",{enumerable:!0,get:()=>l.registerWindowImplementation}),Object.defineProperty(C,"rehydrateSerializedLayout",{enumerable:!0,get:()=>l.rehydrateSerializedLayout}),Object.defineProperty(C,"setCanvasModule",{enumerable:!0,get:()=>l.setCanvasModule}),C.AddonHandle=me,C.ArrayInput=ga,C.AssetNotFoundError=V,C.CollectionProduct=Ye,C.ColorOptionGlobalPropertyHandle=tA,C.ConversionDataType=Ct,C.ConversionLocation=Et,C.FileUploadGlobalPropertyHandle=_t,C.FlowExecutionNodeResult=Ee,C.FlowExecutionResult=sA,C.FlowService=oA,C.FrameService=ft,C.FrameStep=gA,C.FrameStepHandle=lA,C.GlobalPropertyHandle=Se,C.IllustrationStepHandle=Gt,C.InformationMessageType=we,C.InformationStepHandle=zt,C.IntegrationProduct=$e,C.IntegrationType=wt,C.LayoutNotFoundError=J,C.MaterialStepHandle=kt,C.MisconfigurationError=se,C.MockWorkflowManager=ya,C.ModelStepHandle=bt,C.ObjectInput=Ze,C.ObjectInputType=rA,C.OptionGlobalPropertyHandle=We,C.OptionNotFoundError=oe,C.ParseError=q,C.PictureStepHandle=Jt,C.ProductCameraRig=ht,C.ProductCollection=AA,C.ProductWorkflow=Ae,C.PromiseCache=Z,C.PromiseQueue=ve,C.QuestionStepHandle=Tt,C.QueueablePromise=Ue,C.ResourceNotFoundError=X,C.ShapeStepHandle=Ot,C.SpiffCommerceClient=cA,C.StakeholderType=ge,C.StepHandle=j,C.TextGlobalPropertyHandle=eA,C.TextInput=ca,C.TextStepHandle=Lt,C.Transform=aA,C.TransformCollection=nA,C.UnhandledBehaviorError=k,C.Variant=K,C.WorkflowExperienceEventType=Xt,C.WorkflowExperienceImpl=he,C.assetService=G,C.createDesign=Wt,C.designService=Me,C.digitalContentStepService=Mt,C.frameStepService=de,C.generateCommands=qt,C.generateStateFromDesignInputSteps=Jn,C.getBoundedOffsets=It,C.getWorkflow=Ce,C.getWorkflows=_e,C.graphQlManager=N,C.illustrationStepService=Be,C.materialStepService=Ge,C.modelStepService=ke,C.moduleStepService=yt,C.optionService=O,C.persistenceService=P,C.pictureStepService=be,C.questionStepService=Je,C.shapeStepService=te,C.shortenUrl=pt,C.spiffCoreConfiguration=W,C.stepAspectValuesToDesignInputSteps=bn,C.textStepService=L,C.toast=St,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
|
|
3034
|
+
`,ne=async c=>{var e;for(const t in c.layouts){const A=c.layouts[t].elements.filter(a=>a.type===l.LayoutElementType.Illustration);for(let a=0;a<A.length;++a){const i=A[a];i.src&&i.svg&&(i.cachedObjectURL=await l.svgObjectURL(i.svg))}const n=c.layouts[t].elements.filter(a=>a.type===l.LayoutElementType.Textbox);for(let a=0;a<n.length;++a){const i=n[a];(e=i.fontData)!=null&&e.assetUrl&&await l.loadFont(i.fontData.assetUrl)}}},pa=async(c,e)=>{var n;const t=await N.getShadowGraphqlClient().query({query:ha(((n=e==null?void 0:e.assets)==null?void 0:n.metadata)||!1),errorPolicy:"all",fetchPolicy:"no-cache",variables:{ids:c}}),A=t.data.workflows;if(A===void 0||A.length!==c.length)throw new Error(`Unable to read workflows: ${t.errors??"Length mismatch in response"}`);return A.forEach(a=>{a.steps.forEach(i=>{var o,s,r;delete i.data.__typename,(o=i.option)!=null&&o.id&&((s=i.option.defaultVariant)!=null&&s.asset&&G.cacheAsset(i.option.defaultVariant.asset),i.option.colorProfile&&G.cacheAsset(i.option.colorProfile),(r=i.option.variants)==null||r.forEach(g=>{g.asset&&G.cacheAsset(g.asset),g.displayImage&&G.cacheAsset(g.displayImage),g.thumbnail&&G.cacheAsset(g.thumbnail),g.material&&G.cacheMaterial(g.material)}),Z.set({id:i.option.id},Promise.resolve(i.option)))})}),A},Fa=async(c,e)=>{const A=(await e).find(n=>n.id===c);if(!A)throw new Error(`Workflow not found: ${c}`);return A},_e=async(c,e)=>{const t=c.map(o=>Z.get({id:o,options:e})),A=c.filter((o,s)=>t[s]===void 0);if(A.length===0)return Promise.all(t);const n=pa(A,e),a=A.map(o=>Z.set({id:o,options:e},Fa(o,n))),i=t.filter(o=>o!==void 0);return await Promise.all(i.concat(a))},Ce=async(c,e)=>(await _e([c],e))[0],Ma=c=>c.sort((e,t)=>e.index-t.index).map(e=>({id:l.generate(),panelId:e.name,name:e.name,index:e.index,createdAt:new Date,updatedAt:new Date,transparentBackground:e.transparentBackground,height:e.height,width:e.width,previewRegion:e.previewRegion,useEditableArea:e.useEditableArea,editableArea:e.editableArea})),et=(c,e)=>{const t=c.workflowState,A=t?JSON.parse(t):void 0;return A?Object.values(A.layouts).map(n=>n.layout):Ma(e.panels)};class cA{constructor(e){this.activeIntegration=void 0,this.updateTransactionState=async t=>{try{return N.getShadowGraphqlClient().mutate({...t,mutation:GA})}catch(A){throw console.error(A),new v("Critical - Unable to synchronize workflow state with server.")}},this.initialized=!1,this.options=e,this.options.applicationKey&&EA(this.options.applicationKey)}getAssetManager(){return G}getCurrencyCode(){if(this.currencyCode===void 0)throw new Error("No currency code set.");return this.currencyCode}getFlowService(){if(!CA())throw new Error("Application key required to use Flow Service.");return new oA}async getIntegration(){if(!this.options.applicationKey)throw new Error("Cannot get current Integration without specifying an Application Key.");if(this.activeIntegration)return console.log("returning current promise"),this.activeIntegration;const e=async()=>{const A=await N.getShadowGraphqlClient().query({query:Ca,errorPolicy:"all"});return console.log("Get integration response",A),A.data.currentIntegration};return this.activeIntegration=e(),this.activeIntegration}async canUseAddon(e){var t;try{return((t=(await this.getIntegration()).partner.activeAddons)==null?void 0:t.includes(e))??!1}catch(A){return console.error(A),!1}}async authenticateBundleFromLocalStorage(e){var n,a;const t=P.getMap("bundleOwnerIds");if(t!=null&&t.has(e))return Promise.resolve({success:!0,stakeholderType:ge.Owner});const A=P.getMap("bundlePartnerIds")||new Map;if(A.has(e)){const i=A.get(e),s=(P.getMap("partnerCustomerIds")||new Map).get(i);if(s&&await this.authenticateCustomerId(s)){const g=(a=(n=this.customer)==null?void 0:n.bundleStakeholders)==null?void 0:a.find(B=>{var d;return((d=B.bundle)==null?void 0:d.id)===e});if(g)return Promise.resolve({success:!0,stakeholderType:g.type})}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(e){var g,B,d,w,h,u;const t=N.getShadowGraphqlClient(),A=await t.query({query:Ea,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:e}});if(!A.data.transactions||A.data.transactions.length===0)throw new Error(`Transaction not found: ${e}`);const n=A.data.transactions[0];if(!((B=(g=n.product)==null?void 0:g.partner)==null?void 0:B.id))throw new Error(`Unable to read transaction: ${e}`);if(n.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const i=P.getMap("transactionOwnerIds");if(i!=null&&i.has(e))return Promise.resolve({success:!0,stakeholderType:ge.Owner});const o=P.getMap("transactionCustomerIds");if(o!=null&&o.has(e)){const E=o.get(e);if(E&&await this.authenticateCustomerId(E)){const Q=((w=(d=this.customer)==null?void 0:d.bundleStakeholders)==null?void 0:w.find(F=>{var I,f;return(f=(I=F.bundle)==null?void 0:I.transactions)==null?void 0:f.some(D=>D.id===e)}))||((u=(h=this.customer)==null?void 0:h.stakeholders)==null?void 0:u.find(F=>{var I;return((I=F.transaction)==null?void 0:I.id)===e}));if(Q)return Promise.resolve({success:!0,stakeholderType:Q.type})}}const r=(await t.query({query:ua,errorPolicy:"all",variables:{id:n.workflowId}})).data.workflow;if(!r)throw new Error(`Unable to read workflow: ${n.workflowId}`);return Promise.resolve({success:!1,theme:r.overrideTheme,customLogoLink:n.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(e){const t=P.getMap("transactionCustomerIds");t!=null&&t.has(e)&&(t.delete(e),P.setMap("transactionCustomerIds",t))}getStakeholderTypeForTransaction(e){var A,n;const t=(n=(A=this.customer)==null?void 0:A.stakeholders)==null?void 0:n.find(a=>{var i;return((i=a.transaction)==null?void 0:i.id)===e});if(t)return t.type}async getOrCreateCustomer(e){var i;this.customer=void 0;const t=N.getShadowGraphqlClient(),n=(await t.query({query:Qa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:e}})).data.customer;if(!n.id){const s=(i=(await t.mutate({mutation:ma,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:e}}})).data)==null?void 0:i.customerCreate;if(!s)throw new Error("Unable to create customer.");return this.storeCustomer(s),this.customer=s,{customer:s,isAuthenticated:!1}}this.storeCustomer(n);const a=await this.authenticateCustomerId(n.id);return{customer:this.customer||n,isAuthenticated:a}}async authenticateCustomerId(e){var o;const t=N.getShadowGraphqlClient(),A=P.getMap("customerTokens");if(!(A!=null&&A.has(e)))return!1;const n=A.get(e);if(!n)return!1;const i=(o=(await t.mutate({mutation:Ia,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:n}})).data)==null?void 0:o.customerAuthenticate;return i?(this.storeCustomer(i),lt(n),this.customer=i,!0):!1}async generateVerificationCode(e){await N.getShadowGraphqlClient().mutate({mutation:fa,variables:{emailAddress:e}})}async verifyCode(e,t){var a,i;const n=(a=(await N.getShadowGraphqlClient().mutate({mutation:Da,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:e,verificationCode:t}})).data)==null?void 0:a.customerVerifyCode;if(n!=null&&n.loginToken){if(!((i=n.partner)!=null&&i.id))throw new Error(`Unable to find customer: ${e}`);const o=P.getMap("customerTokens")||new Map;return o.set(n.id,n.loginToken),P.setMap("customerTokens",o),this.storeCustomer(n),lt(n.loginToken),this.customer={...n,loginToken:void 0},!0}return!1}async getNewBundle(e,t,A){var s,r,g;const a=(g=(await N.getShadowGraphqlClient().mutate({mutation:Kn(((r=(s=A==null?void 0:A.graphql)==null?void 0:s.productCollection)==null?void 0:r.eagerFetchProducts)||!1),variables:{collectionId:e,initialMetadata:t?Object.entries(t).map((B,d)=>({key:B[0],value:B[1]})):void 0},fetchPolicy:"no-cache"})).data)==null?void 0:g.bundleCreate;if(!(a!=null&&a.id))throw new Error("Unable to create bundle");const i=P.getMap("bundlePartnerIds")||new Map;i.set(a.id,a.partner.id),P.setMap("bundlePartnerIds",i);const o=P.getMap("bundleOwnerIds")||new Map;return o.set(a.id,a.bundleOwnerId),P.setMap("bundleOwnerIds",o),new iA(this,a,void 0,void 0,a.bundleOwnerId)}async getExistingBundle(e,t,A,n){var E,m,Q,F,I,f,D,p,y;const a=P.getMap("bundleOwnerIds"),i=a==null?void 0:a.get(e),s=((E=Object.entries(localStorage).find(([S,x])=>S.startsWith("CognitoIdentityServiceProvider")&&S.endsWith("idToken")))==null?void 0:E[0])||"",r=localStorage.getItem(s),g={};r&&!Ke(r)&&(g.Authorization=`Bearer ${r}`);const B={bundleOwnerId:i,...g,...(m=n==null?void 0:n.graphql)==null?void 0:m.additionalHeaders},d=await N.getShadowGraphqlClient().query({query:On(((F=(Q=n==null?void 0:n.graphql)==null?void 0:Q.productCollection)==null?void 0:F.eagerFetchProducts)||!1),variables:{id:e},fetchPolicy:"no-cache",context:{headers:B}});if(!((I=d.data)!=null&&I.bundles)||((f=d.data)==null?void 0:f.bundles.length)===0||!((D=d.data)!=null&&D.bundles[0]))throw new Error(`Unable to find bundle: ${e}`);const w=(p=d.data)==null?void 0:p.bundles[0],h=P.getMap("bundlePartnerIds")||new Map;h.set(w.id,w.partner.id),P.setMap("bundlePartnerIds",h);const u=new iA(this,w,t,A,i,{additionalHeaders:(y=n==null?void 0:n.graphql)==null?void 0:y.additionalHeaders});return await u.getInitializationPromise(),u}async getBundleStakeholders(){var a;if(!this.customer)throw new Error("Customer not authenticated.");const e=await N.getShadowGraphqlClient().query({query:zn,variables:{id:this.customer.id},fetchPolicy:"no-cache"});if(!((a=e.data)!=null&&a.customers)||e.data.customers.length===0)throw new Error("Unable to find customer.");const A=e.data.customers[0].bundleStakeholders||[],n=P.getMap("bundlePartnerIds")||new Map;return A.forEach(i=>{var o,s;(o=i.bundle)!=null&&o.id&&((s=i.bundle.partner)!=null&&s.id)&&n.set(i.bundle.id,i.bundle.partner.id)}),P.setMap("bundlePartnerIds",n),A}async getWorkflowExperience(e,t,A,n){var B,d,w,h,u;if(!n)return await this.getWorkflowExperienceDeprecated(e,t,A);const a=async()=>{var m,Q;const E=N.getShadowGraphqlClient();if(n.type==="transaction"){const{transactionId:F,readOnly:I}=n,f=await E.query({query:Ie,variables:{ids:[F]},errorPolicy:"all",fetchPolicy:"no-cache"});if(!((m=f.data)!=null&&m.transactions)||f.data.transactions.length===0)throw new v("Existing transaction not found.");const D=(Q=f.data)==null?void 0:Q.transactions[0];if(!D.workflowId)throw new v("Existing transaction has no workflow ID.");const p=await Ce(D.workflowId);if(!D.product)throw new v("Failed to load transaction, product not available.");return{transaction:D,workflow:p,readOnly:I}}if(n.type==="integration"||n.type==="external"){const F=async()=>{const p=n.type==="integration"?{integrationProductId:n.integrationProductId}:{externalIntegrationId:n.externalIntegrationId,externalProductId:n.externalProductId},y=await E.mutate({mutation:ut,variables:{...p,workflowId:n.workflowId,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!y.data||!y.data.transactionCreate)throw new v("Failed to create transaction!");const S=y.data.transactionCreate;if(!S.product)throw new v("Failed to create transaction, product not available.");return S},I=Ce(n.workflowId,n==null?void 0:n.graphql),[f,D]=await Promise.all([F(),I]);return{transaction:f,workflow:D}}throw new v("No workflow ID provided.")},{transaction:i,workflow:o,readOnly:s}=await a();this.currencyCode=(B=i.product.partner)==null?void 0:B.currencyCode;const r={product:i.product,transaction:i,layouts:[],singleVariantsRenderable:(d=n==null?void 0:n.workflowConfiguration)==null?void 0:d.singleVariantsRenderable,stateMutationFunc:s?async()=>{throw new k("State mutation is forbidden in read only mode!")}:async E=>{const Q=(P.getMap("transactionOwnerIds")||new Map).get(i.id)||void 0;return this.updateTransactionState({...E,context:{transactionOwnerId:Q}})},readOnly:s,workflow:o};if(n.type==="transaction"&&i.workflowState){const E=JSON.parse(i.workflowState);r.layouts=Object.values(E.layouts).map(m=>m.layout),await l.rehydrateSerializedLayout(E),await ne(E),r.reloadedState=E}else if(!s&&n.workflowState){const E=JSON.parse(n.workflowState);r.layouts=Object.values(E.layouts).map(m=>m.layout),await l.rehydrateSerializedLayout(E),await ne(E),r.reloadedState=E}else r.layouts=et(r.transaction,r.workflow);if(r.renderableContextService=new ye(r.layouts),n.previewService?(r.previewService=n.previewService,(w=r.product)!=null&&w.modelUrl&&(r.modelContainer=r.previewService.loadModel({model:r.product.modelUrl,contextService:r.renderableContextService}))):(r.previewService=A&&A(o),(h=r.product)!=null&&h.modelUrl&&(r.modelContainer=(u=r.previewService)==null?void 0:u.loadModel({model:r.product.modelUrl,contextService:r.renderableContextService}))),n.type!=="transaction"){const E=P.getMap("transactionOwnerIds")||new Map;E.set(i.id,i.transactionOwnerId),P.setMap("transactionOwnerIds",E)}else r.isReloadedTransaction=!0;this.initialized=!0,this.experienceOptions=r;const g=new he(this,r);return await g.getWorkflowManager().getInitializationPromise(),n.type!=="transaction"&&this.customer&&await g.attachCustomerDetails({email:this.customer.emailAddress}),g}async getWorkflowExperiences(e,t){if(e.length===0)throw new v("No options provided!");const A=N.getShadowGraphqlClient(),n=async f=>{var S,x;if(f.length===0)return[];const D=f.map(Y=>Y.option.transactionId),p=await A.query({query:Ie,variables:{ids:D},errorPolicy:"all",fetchPolicy:"no-cache"}),y=p.data.transactions;if(y.length!==f.length){const Y=((x=(S=p.errors)==null?void 0:S[0])==null?void 0:x.message)||"Unknown error";throw new v(`Not all transactions were found: ${Y}`)}return y.map((Y,H)=>{var R;return{transaction:Y,workflowId:Y.workflowId,readOnly:((R=f.find(T=>T.option.transactionId===Y.id))==null?void 0:R.option.readOnly)??!1,index:f[H].index}})},a=async f=>{var y,S,x;if(f.length===0)return[];const D=await A.mutate({mutation:UA,variables:{inputs:f.map(Y=>({integrationProductId:Y.option.type==="integration"?Y.option.integrationProductId:void 0,externalIntegrationId:Y.option.type==="external"?Y.option.externalIntegrationId:void 0,externalProductId:Y.option.type==="external"?Y.option.externalProductId:void 0,workflowId:Y.option.workflowId,claim:!0}))},errorPolicy:"all",fetchPolicy:"no-cache"}),p=(y=D.data)==null?void 0:y.transactionCreateMany;if(!p||p.length===0){const Y=((x=(S=D.errors)==null?void 0:S[0])==null?void 0:x.message)||"Unknown error";throw new v(`Failed to create transactions: ${Y}`)}return p.map((Y,H)=>({transaction:Y,workflowId:Y.workflowId,readOnly:!1,index:f[H].index}))},i=e.map((f,D)=>({option:f,index:D})),o=i.filter(f=>f.option.type==="transaction"),s=i.filter(f=>f.option.type==="integration"||f.option.type==="external"),r=st(o,10),g=st(s,10),B=(await Promise.all([...r.map(n),...g.map(a)])).flat(),d=[...new Set(B.map(f=>f.workflowId))],w=await _e(d,t),h=new Map(w.map(f=>[f.id,f])),u=P.getMap("transactionOwnerIds")||new Map,E=B.map(async f=>{var T;const{transaction:D,workflowId:p,readOnly:y,index:S}=f,x=h.get(p),Y=e[S];!u.get(D.id)&&D.transactionOwnerId&&u.set(D.id,D.transactionOwnerId);const H=u.get(D.id)||void 0,R={product:D.product,transaction:D,layouts:[],singleVariantsRenderable:(T=Y==null?void 0:Y.workflowConfiguration)==null?void 0:T.singleVariantsRenderable,stateMutationFunc:y?async()=>{throw new k("State mutation is forbidden in read only mode!")}:async b=>this.updateTransactionState({...b,context:{transactionOwnerId:H}}),readOnly:y,workflow:x,isReloadedTransaction:Y.type==="transaction"};if(Y.type==="transaction"&&D.workflowState){const b=JSON.parse(D.workflowState);R.layouts=Object.values(b.layouts||{}).map(z=>z.layout),await l.rehydrateSerializedLayout(b),await ne(b),R.reloadedState=b}else if(!y&&Y.workflowState){const b=JSON.parse(Y.workflowState);R.layouts=Object.values(b.layouts||{}).map(z=>z.layout),await l.rehydrateSerializedLayout(b),await ne(b),R.reloadedState=b}else R.layouts=et(R.transaction,R.workflow);return R.renderableContextService=new ye(R.layouts),R.delayWorkflowStateSync=!0,this.initialized=!0,this.experienceOptions=R,{experienceOptions:R,index:S,options:Y}});P.setMap("transactionOwnerIds",u);const F=(await Promise.all(E)).sort((f,D)=>f.index-D.index).map(async f=>{const{experienceOptions:D,options:p}=f,y=new he(this,D);return await y.getWorkflowManager().getInitializationPromise(),p.type!=="transaction"&&this.customer&&await y.attachCustomerDetails({email:this.customer.emailAddress}),y}),I=await Promise.all(F);return I.forEach(f=>f.getWorkflowManager().setWorkflowStateSyncEnabled(!0)),I}async initFromIntegrationProduct(e){var i;if(e==="")throw new v("No integration product ID provided.");const A=await N.getShadowGraphqlClient().mutate({mutation:ut,variables:{integrationProductId:e,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!A.data||!A.data.transactionCreate)throw new v("Failed to create transaction!");const n=A.data.transactionCreate;if(!n.product)throw new v("Failed to create transaction, product not available.");this.currencyCode=(i=n.product.partner)==null?void 0:i.currencyCode;const a=P.getMap("transactionOwnerIds")||new Map;a.set(n.id,n.transactionOwnerId),P.setMap("transactionOwnerIds",a),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:async o=>this.updateTransactionState({...o,context:{transactionOwnerId:n.transactionOwnerId}})},this.initialized=!0}async initFromTransaction(e,t=!1){var o,s,r,g;if(e==="")throw new v("No transaction ID provided.");const A=N.getShadowGraphqlClient(),n=async()=>{var w,h;const d=(w=(await A.query({query:Ie,variables:{ids:[e]},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:w.transactions[0];if(!d)throw new v("Failed to read transaction.");if(!d.product)throw new v("Failed to load transaction, product not available.");this.currencyCode=(h=d.product.partner)==null?void 0:h.currencyCode,this.experienceOptions={product:d.product,transaction:d,layouts:[],stateMutationFunc:async()=>{throw new k("State mutation is forbidden in read only mode!")},readOnly:t},this.initialized=!0};if(t)return await n();const a=P.getMap("transactionOwnerIds")||new Map,i=a.get(e);if(i){const d=(o=(await A.query({query:Ie,variables:{ids:[e]},errorPolicy:"all"})).data)==null?void 0:o.transactions[0];if(!d)throw new v("Failed to read transaction.");if(!d.product)throw new v("Failed to load transaction, product not available.");this.currencyCode=(s=d.product.partner)==null?void 0:s.currencyCode,this.experienceOptions={product:d.product,transaction:d,layouts:[],stateMutationFunc:async w=>this.updateTransactionState({...w,context:{transactionOwnerId:i}}),readOnly:t},this.initialized=!0;return}try{const d=(r=(await A.mutate({mutation:vA,variables:{id:e},errorPolicy:"all"})).data)==null?void 0:r.transactionClaim;if(!d)throw new v("Failed to read transaction.");if(!d.product)throw new v("Failed to load transaction, product not available.");this.currencyCode=(g=d.product.partner)==null?void 0:g.currencyCode,d.transactionOwnerId&&(a.set(d.id,d.transactionOwnerId),P.setMap("transactionOwnerIds",a)),this.experienceOptions={product:d.product,transaction:d,layouts:[],stateMutationFunc:async w=>this.updateTransactionState({...w,context:{transactionOwnerId:d.transactionOwnerId}}),readOnly:t},this.initialized=!0}catch{throw new v("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(e,t,A){var n,a,i,o;if(!this.initialized||!this.experienceOptions)throw new v("Cannot launch experience: Not initialized.");if(this.experienceOptions.transaction.workflowId){const s=await Ce(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=s,this.experienceOptions.transaction.workflowState){const g=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(g.layouts).map(B=>B.layout),await l.rehydrateSerializedLayout(g),await ne(g),this.experienceOptions.reloadedState=g}this.experienceOptions.previewService=A&&A(s),this.experienceOptions.renderableContextService=new ye(this.experienceOptions.layouts),(n=this.experienceOptions.product)!=null&&n.modelUrl&&(this.experienceOptions.modelContainer=(a=this.experienceOptions.previewService)==null?void 0:a.loadModel({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}));const r=new he(this,this.experienceOptions);return await r.getWorkflowManager().getInitializationPromise(),r}if(e){const r=(P.getMap("transactionOwnerIds")||new Map).get(this.experienceOptions.transaction.id),g=N.getShadowGraphqlClient().mutate({mutation:kA,variables:{workflowId:e,id:this.experienceOptions.transaction.id},context:{transactionOwnerId:r}}),B=Ce(e);if(await Promise.all([g,B]),this.experienceOptions.workflow=await B,t){const w=JSON.parse(t);this.experienceOptions.layouts=Object.values(w.layouts).map(h=>h.layout),await l.rehydrateSerializedLayout(w),await ne(w),this.experienceOptions.reloadedState=w}else this.experienceOptions.layouts=et(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=A&&A(await B),this.experienceOptions.renderableContextService=new ye(this.experienceOptions.layouts),(i=this.experienceOptions.product)!=null&&i.modelUrl&&(this.experienceOptions.modelContainer=(o=this.experienceOptions.previewService)==null?void 0:o.loadModel({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}));const d=new he(this,this.experienceOptions);return await d.getWorkflowManager().getInitializationPromise(),d}throw new v("No workflow ID provided.")}getPreviewService(){var e;return(e=this.experienceOptions)==null?void 0:e.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new v("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new v("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}configureUrls(e,t,A){W.setHubUrl(e),W.setServerUrl(t),W.setServicesApiUrl(A),this.getIntegration()}storeCustomer(e){const t=P.getMap("partnerCustomerIds")||new Map;t.set(e.partner.id,e.id),P.setMap("partnerCustomerIds",t)}async getIntegrationProductById(e){var a,i;const n=(a=(await N.getShadowGraphqlClient().query({query:JA,variables:{ids:[e]},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:a.integrationProducts;if(!n||n.length===0||!((i=n[0])!=null&&i.id))throw new Error("Integration product not found.");return new $e(n[0])}async getIntegrationProductFromExternalIds(e,t){var i;const a=(i=(await N.getShadowGraphqlClient().query({query:TA,variables:{externalProductId:t,externalIntegrationId:e},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:i.integrationProductFromExternalIds;if(!(a!=null&&a.id))throw new Error("Integration product not found.");return new $e(a)}async getIntegrationProduct(e){return e.type==="integration"?this.getIntegrationProductById(e.integrationProductId):this.getIntegrationProductFromExternalIds(e.externalIntegrationId,e.externalProductId)}}class ya{getClient(){return this.client??{}}setClient(e){this.client=e}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}async reset(){}updateStateWithServer(e){}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(e){}addPoller(e){}addConfirmCallback(e){}addEditedCallback(e){}addElementsCallback(e){}addInformationResultCallback(e){}addInitCallback(e){}addMakingAdjustmentsCallback(e){}addMandatoryCallback(e){}addMetadataCallback(e){}addSelectionCallback(e){}addStepSpecificStorageCallback(e,t){}addStorageCallback(e){}getCommandDispatcher(){return e=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(e){return[]}getSerializedStep(e,t){}getStepSpecificServices(e){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(e){}markUpdateCompleted(e){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}setCurrentAdjustingStepId(e){}setEditedStatus(e,t){}setInformationResults(e){}setMandatoryFulfilled(e,t){}async setSelectionsAndElements(e,t,A){}toggleDesignConfirmed(){}updateMetadata(e,t){}async updateStorage(e,t){}injectIntoPreviewService(e){return Promise.resolve()}ejectFromPreviewService(){}setWorkflowStateSyncEnabled(e){}}var gA=(c=>(c.SelectFrame="SelectFrame",c.SelectImage="SelectImage",c.Position="Position",c))(gA||{});class lA extends j{constructor(e,t){var A;super(e,t),this.frameService=(A=this.manager.getStepSpecificServices(this.getId()))==null?void 0:A.frameService}selectVariant(e){const t=this.manager.getRegionElements(this.step.stepName);return de.selectVariant(this.step,e.getResource(),t,this.manager,A=>this.setUpdateState(A))}onFrameDataChanged(e){this.frameService&&this.frameService.onFrameDataChanged(t=>{t&&e(t)})}async selectImage(e,t=!0){var A;if(await de.selectImage(this.step,e,this.manager),t){const n=((A=this.manager.getStepStorage(this.step.stepName))==null?void 0:A.framePatternData)||{};this.manager.updateStorage(this.step.stepName,{framePatternData:{...n,originalAssetKey:e.key,backgroundRemovedAssetKey:void 0,useOriginalAsset:void 0}})}}async canUseBackgroundRemover(){return this.manager.getClient().canUseAddon(me.BackgroundRemover)}async removeBackgroundFromImageSelection(e=!0){var a;if(!await this.canUseBackgroundRemover())throw new Error("The current Integration does not have access to the Background Remover. Please call canUseBackgroundRemover to ensure you disable this feature when appropriate.");const t=await this.getOriginalImageSelection();if(!t)throw new Error("You must supply an image selection before attempting to remove the background.");const A=await G.removeBackgroundFromAsset(t);e&&await de.selectImage(this.step,A,this.manager);const n=((a=this.manager.getStepStorage(this.step.stepName))==null?void 0:a.framePatternData)||{};return this.manager.updateStorage(this.step.stepName,{framePatternData:{...n,backgroundRemovedAssetKey:A.key,useOriginalAsset:!e}}),A}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(e,t,A,n){return n&&n.length>1&&e===void 0?"SelectFrame":t||A||this.getImageData()?"Position":"SelectImage"}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}async getOriginalImageSelection(){var t,A;const e=(A=(t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.framePatternData)==null?void 0:A.originalAssetKey;if(e)return G.getLocalOrFromServer(e)}async getBackgroundRemovedImageSelection(){var t,A;const e=(A=(t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.framePatternData)==null?void 0:A.backgroundRemovedAssetKey;if(e)return G.getLocalOrFromServer(e)}hasBackgroundRemovedImageSelection(){var e,t;return!!((t=(e=this.getFrameStepStorage())==null?void 0:e.framePatternData)!=null&&t.backgroundRemovedAssetKey)}getUseOriginalImageSelection(){var e,t;return((t=(e=this.getFrameStepStorage())==null?void 0:e.framePatternData)==null?void 0:t.useOriginalAsset)??!1}async setUseOriginalImageSelection(e){var n;const t=((n=this.getFrameStepStorage())==null?void 0:n.framePatternData)||{};if(t.useOriginalAsset===e)return;const A=await this.getOriginalImageSelection();if(!A)throw new Error("You must provide an image selection before calling setUseOriginalImageSelection");if(e)await this.selectImage(A,!1);else{const a=await this.getBackgroundRemovedImageSelection();if(!a)throw new Error("You must call removeBackgroundFromImageSelection before attempting to apply the image.");await this.selectImage(a,!1)}this.manager.updateStorage(this.step.stepName,{framePatternData:{...t,useOriginalAsset:e}})}getFrameStepStorage(){return this.manager.getStepStorage(this.step.stepName)}}Object.defineProperty(C,"AspectType",{enumerable:!0,get:()=>l.AspectType}),Object.defineProperty(C,"AssetType",{enumerable:!0,get:()=>l.AssetType}),Object.defineProperty(C,"BringForwardCommand",{enumerable:!0,get:()=>l.BringForwardCommand}),Object.defineProperty(C,"BringToBackCommand",{enumerable:!0,get:()=>l.BringToBackCommand}),Object.defineProperty(C,"BringToFrontCommand",{enumerable:!0,get:()=>l.BringToFrontCommand}),Object.defineProperty(C,"CanvasCommand",{enumerable:!0,get:()=>l.CanvasCommand}),Object.defineProperty(C,"CommandContext",{enumerable:!0,get:()=>l.CommandContext}),Object.defineProperty(C,"CreateElementCommand",{enumerable:!0,get:()=>l.CreateElementCommand}),Object.defineProperty(C,"CreateLayoutCommand",{enumerable:!0,get:()=>l.CreateLayoutCommand}),Object.defineProperty(C,"DeleteElementCommand",{enumerable:!0,get:()=>l.DeleteElementCommand}),Object.defineProperty(C,"FontAlignmentCommand",{enumerable:!0,get:()=>l.FontAlignmentCommand}),Object.defineProperty(C,"FontColorCommand",{enumerable:!0,get:()=>l.FontColorCommand}),Object.defineProperty(C,"FontSizeCommand",{enumerable:!0,get:()=>l.FontSizeCommand}),Object.defineProperty(C,"FontSourceCommand",{enumerable:!0,get:()=>l.FontSourceCommand}),Object.defineProperty(C,"GroupCommand",{enumerable:!0,get:()=>l.GroupCommand}),Object.defineProperty(C,"LayoutElementFactory",{enumerable:!0,get:()=>l.LayoutElementFactory}),Object.defineProperty(C,"LayoutElementType",{enumerable:!0,get:()=>l.LayoutElementType}),Object.defineProperty(C,"MoveCommand",{enumerable:!0,get:()=>l.MoveCommand}),Object.defineProperty(C,"ResizeCommand",{enumerable:!0,get:()=>l.ResizeCommand}),Object.defineProperty(C,"RotateCommand",{enumerable:!0,get:()=>l.RotateCommand}),Object.defineProperty(C,"SendBackwardsCommand",{enumerable:!0,get:()=>l.SendBackwardsCommand}),Object.defineProperty(C,"StepAspectType",{enumerable:!0,get:()=>l.StepAspectType}),Object.defineProperty(C,"StepType",{enumerable:!0,get:()=>l.StepType}),Object.defineProperty(C,"TextChangeCommand",{enumerable:!0,get:()=>l.TextChangeCommand}),Object.defineProperty(C,"UnitOfMeasurement",{enumerable:!0,get:()=>l.UnitOfMeasurement}),Object.defineProperty(C,"dataUrlFromExternalUrl",{enumerable:!0,get:()=>l.dataUrlFromExternalUrl}),Object.defineProperty(C,"determineCorrectFontSizeAndLines",{enumerable:!0,get:()=>l.determineCorrectFontSizeAndLines}),Object.defineProperty(C,"findElement",{enumerable:!0,get:()=>l.findElement}),Object.defineProperty(C,"frameDataCache",{enumerable:!0,get:()=>l.frameDataCache}),Object.defineProperty(C,"generate",{enumerable:!0,get:()=>l.generate}),Object.defineProperty(C,"generateSVGWithUnknownColors",{enumerable:!0,get:()=>l.generateSVGWithUnknownColors}),Object.defineProperty(C,"getAttributesFromArrayBuffer",{enumerable:!0,get:()=>l.getAttributesFromArrayBuffer}),Object.defineProperty(C,"getAxisAlignedBoundingBox",{enumerable:!0,get:()=>l.getAxisAlignedBoundingBox}),Object.defineProperty(C,"getFrameData",{enumerable:!0,get:()=>l.getFrameData}),Object.defineProperty(C,"getSvgElement",{enumerable:!0,get:()=>l.getSvgElement}),Object.defineProperty(C,"loadFont",{enumerable:!0,get:()=>l.loadFont}),Object.defineProperty(C,"patternImageDataCache",{enumerable:!0,get:()=>l.patternImageDataCache}),Object.defineProperty(C,"registerFetchImplementation",{enumerable:!0,get:()=>l.registerFetchImplementation}),Object.defineProperty(C,"registerWindowImplementation",{enumerable:!0,get:()=>l.registerWindowImplementation}),Object.defineProperty(C,"rehydrateSerializedLayout",{enumerable:!0,get:()=>l.rehydrateSerializedLayout}),Object.defineProperty(C,"setCanvasModule",{enumerable:!0,get:()=>l.setCanvasModule}),C.AddonHandle=me,C.ArrayInput=ga,C.AssetNotFoundError=V,C.CollectionProduct=Ye,C.ColorOptionGlobalPropertyHandle=tA,C.ConversionDataType=Ct,C.ConversionLocation=Et,C.FileUploadGlobalPropertyHandle=_t,C.FlowExecutionNodeResult=Ee,C.FlowExecutionResult=sA,C.FlowService=oA,C.FrameService=ft,C.FrameStep=gA,C.FrameStepHandle=lA,C.GlobalPropertyHandle=Se,C.IllustrationStepHandle=Gt,C.InformationMessageType=we,C.InformationStepHandle=zt,C.IntegrationProduct=$e,C.IntegrationType=wt,C.LayoutNotFoundError=J,C.MaterialStepHandle=kt,C.MisconfigurationError=se,C.MockWorkflowManager=ya,C.ModelStepHandle=bt,C.ObjectInput=Ze,C.ObjectInputType=rA,C.OptionGlobalPropertyHandle=We,C.OptionNotFoundError=oe,C.ParseError=q,C.PictureStepHandle=Jt,C.ProductCameraRig=ht,C.ProductCollection=AA,C.ProductWorkflow=Ae,C.PromiseCache=Z,C.PromiseQueue=ve,C.QuestionStepHandle=Tt,C.QueueablePromise=Ue,C.ResourceNotFoundError=X,C.ShapeStepHandle=Ot,C.SpiffCommerceClient=cA,C.StakeholderType=ge,C.StepHandle=j,C.TextGlobalPropertyHandle=eA,C.TextInput=ca,C.TextStepHandle=Lt,C.Transform=aA,C.TransformCollection=nA,C.UnhandledBehaviorError=k,C.Variant=K,C.WorkflowExperienceEventType=Xt,C.WorkflowExperienceImpl=he,C.assetService=G,C.createDesign=Wt,C.designService=Me,C.digitalContentStepService=Mt,C.frameStepService=de,C.generateCommands=qt,C.generateStateFromDesignInputSteps=Jn,C.getBoundedOffsets=It,C.getWorkflow=Ce,C.getWorkflows=_e,C.graphQlManager=N,C.illustrationStepService=Be,C.materialStepService=Ge,C.modelStepService=ke,C.moduleStepService=yt,C.optionService=O,C.persistenceService=P,C.pictureStepService=be,C.questionStepService=Je,C.shapeStepService=te,C.shortenUrl=pt,C.spiffCoreConfiguration=W,C.stepAspectValuesToDesignInputSteps=bn,C.textStepService=L,C.toast=St,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED