@thefittingroom/shop-ui 0.1.13 → 1.1.0

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/esm/index.js CHANGED
@@ -1,11 +1,56 @@
1
1
  /*!
2
- * thefittingroom v0.1.13 (2024-01-10T20:35:01.451Z)
2
+ * thefittingroom v1.1.0 (2024-02-27T19:18:33.918Z)
3
3
  * Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
4
4
  */
5
+ function loadImageRecursive(imageURL, imageURLs) {
6
+ let next = function () {
7
+ if (imageURLs.length === 0) {
8
+ return;
9
+ }
10
+ loadImageRecursive(imageURLs.slice(-1), imageURLs.slice(0, -1));
11
+ };
12
+ var img = new Image();
13
+ img.onload = next;
14
+ img.onerror = next;
15
+ img.src = imageURL;
16
+ }
17
+ function loadImages(imageURLs) {
18
+ loadImageRecursive(imageURLs.slice(-1), imageURLs.slice(0, -1));
19
+ }
20
+ const InitImageSlider = (sliderID, onChange) => {
21
+ const slider = document.getElementById(sliderID);
22
+ if (!slider) {
23
+ throw new Error(`Slider with id ${sliderID} not found`);
24
+ }
25
+ return {
26
+ Load(imageURLs) {
27
+ if (!Array.isArray(imageURLs) || !imageURLs.length) {
28
+ console.debug('slider has no images to load');
29
+ return new Error('slider has no images to load');
30
+ }
31
+ loadImages(imageURLs);
32
+ const defaultScrollValue = (imageURLs === null || imageURLs === void 0 ? void 0 : imageURLs.length) - 2;
33
+ slider.value = defaultScrollValue.toString();
34
+ slider.max = (imageURLs.length - 1).toString();
35
+ const handleSliderChange = () => {
36
+ const currentValue = parseInt(slider.value);
37
+ onChange(slider, imageURLs[currentValue]);
38
+ };
39
+ onChange(slider, imageURLs[defaultScrollValue]);
40
+ slider.removeEventListener('input', handleSliderChange);
41
+ slider.addEventListener('input', handleSliderChange);
42
+ return () => {
43
+ slider.removeEventListener('input', handleSliderChange);
44
+ };
45
+ },
46
+ };
47
+ };
48
+
5
49
  /*!
6
- * thefittingroom v0.0.11 (2023-09-04T22:52:56.755Z)
50
+ * thefittingroom v1.1.0 (2024-02-16T20:34:26.286Z)
7
51
  * Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
8
52
  */
53
+
9
54
  /**
10
55
  * @license
11
56
  * Copyright 2017 Google LLC
@@ -22734,18 +22779,6 @@ class AvatarNotCreatedError extends Error {
22734
22779
  this.name = 'AvatarNotCreatedError';
22735
22780
  }
22736
22781
  }
22737
- class NoFramesFoundError extends Error {
22738
- constructor() {
22739
- super('no frames found');
22740
- this.name = 'NoFramesFoundError';
22741
- }
22742
- }
22743
- class RequestTimeoutError extends Error {
22744
- constructor() {
22745
- super('request timeout');
22746
- this.name = 'RequestTimeoutError';
22747
- }
22748
- }
22749
22782
  class UserNotLoggedInError extends Error {
22750
22783
  constructor() {
22751
22784
  super('user not logged in');
@@ -22758,42 +22791,9 @@ class NoColorwaySizeAssetsFoundError extends Error {
22758
22791
  this.name = 'NoColorwaySizeAssetsFoundError';
22759
22792
  }
22760
22793
  }
22761
- class NoStylesFoundError extends Error {
22762
- constructor() {
22763
- super('no styles found');
22764
- this.name = 'NoStylesFoundError';
22765
- }
22766
- }
22767
- class RecommendedAvailableSizesError extends Error {
22768
- constructor(recommended_size, available_sizes) {
22769
- super('recommended available sizes error');
22770
- this.name = 'RecommendedAvailableSizesError';
22771
- this.recommended_size = recommended_size;
22772
- this.available_sizes = available_sizes;
22773
- }
22774
- }
22775
- class BrandUserIdNotSetError extends Error {
22776
- constructor() {
22777
- super('brand user id not set');
22778
- this.name = 'BrandUserIdNotSetError';
22779
- }
22780
- }
22781
22794
  // Backend responses
22782
22795
  const AvatarNotCreated = 'avatar not created';
22783
22796
 
22784
- var errors = /*#__PURE__*/Object.freeze({
22785
- __proto__: null,
22786
- AvatarNotCreatedError: AvatarNotCreatedError,
22787
- NoFramesFoundError: NoFramesFoundError,
22788
- RequestTimeoutError: RequestTimeoutError,
22789
- UserNotLoggedInError: UserNotLoggedInError,
22790
- NoColorwaySizeAssetsFoundError: NoColorwaySizeAssetsFoundError,
22791
- NoStylesFoundError: NoStylesFoundError,
22792
- RecommendedAvailableSizesError: RecommendedAvailableSizesError,
22793
- BrandUserIdNotSetError: BrandUserIdNotSetError,
22794
- AvatarNotCreated: AvatarNotCreated
22795
- });
22796
-
22797
22797
  class FirebaseUser {
22798
22798
  constructor(firestore, app) {
22799
22799
  this.firestore = firestore;
@@ -22834,19 +22834,11 @@ class FirebaseUser {
22834
22834
  const userProfile = await Ol(Aa(this.firestore, 'users', this.id));
22835
22835
  return userProfile.data();
22836
22836
  }
22837
- watchUserProfileForChanges(predicate, timeout) {
22837
+ watchUserProfileForChanges(callback) {
22838
22838
  let unsub;
22839
22839
  const q = sl(Ta(this.firestore, 'users'), rl(Eh(), '==', this.id));
22840
- const cancel = setTimeout(() => unsub(), timeout);
22841
- return new Promise((resolve) => {
22842
- unsub = jl(q, async (snapshot) => {
22843
- if (!(await predicate(snapshot)))
22844
- return;
22845
- clearTimeout(cancel);
22846
- unsub();
22847
- resolve(snapshot.docs[0].data());
22848
- });
22849
- });
22840
+ unsub = jl(q, (snapshot) => callback(snapshot.docs[0].data()));
22841
+ return () => unsub();
22850
22842
  }
22851
22843
  async login(username, password) {
22852
22844
  if (this.auth.currentUser)
@@ -22895,6 +22887,11 @@ class Firebase {
22895
22887
  const q = sl(Ta(this.firestore, collectionName), ...constraints);
22896
22888
  return Bl(q);
22897
22889
  }
22890
+ async getDoc(collectionName, id) {
22891
+ const docRef = Aa(this.firestore, collectionName, id);
22892
+ const docSnap = await Ol(docRef);
22893
+ return docSnap.exists() ? docSnap.data() : null;
22894
+ }
22898
22895
  }
22899
22896
 
22900
22897
  const getFirebaseError = (e) => {
@@ -22906,7 +22903,370 @@ const getFirebaseError = (e) => {
22906
22903
  }
22907
22904
  };
22908
22905
 
22909
- const asyncTry = (promise) => promise.then((data) => [null, data]).catch((error) => [error]);
22906
+ var MeasurementLocation;
22907
+ (function (MeasurementLocation) {
22908
+ MeasurementLocation["ACROSS_BACK"] = "across_back";
22909
+ MeasurementLocation["ACROSS_FRONT"] = "across_front";
22910
+ MeasurementLocation["ACROSS_SHOULDER"] = "across_shoulder";
22911
+ MeasurementLocation["ANKLE"] = "ankle";
22912
+ MeasurementLocation["ARMEYE"] = "arm_eye";
22913
+ MeasurementLocation["ARM_LENGTH_FROM_SHOULDER"] = "arm_length_from_shoulder";
22914
+ MeasurementLocation["BACK_CROTCH_LENGTH"] = "back_crotch_length";
22915
+ MeasurementLocation["BACK_NECK_TO_EBLOW"] = "back_neck_to_elbow";
22916
+ MeasurementLocation["BELOW_KNEE"] = "below_knee";
22917
+ MeasurementLocation["BICEP"] = "bicep";
22918
+ MeasurementLocation["BUST"] = "bust";
22919
+ MeasurementLocation["BUST_POINT_TO_BUST_POINT"] = "bust_point_to_bust_point";
22920
+ MeasurementLocation["CALF"] = "calf";
22921
+ MeasurementLocation["CB_NECK_TO_WAIST"] = "cb_neck_to_waist";
22922
+ MeasurementLocation["CB_NECK_TO_WRIST"] = "cb_neck_to_wrist";
22923
+ MeasurementLocation["CF_NECK_TO_WAIST"] = "cf_neck_to_waist";
22924
+ MeasurementLocation["ELBOW"] = "elbow";
22925
+ MeasurementLocation["FOREARM"] = "forearm";
22926
+ MeasurementLocation["FRONT_CROTCH_LENGTH"] = "front_crotch_length";
22927
+ MeasurementLocation["HIGH_HIP_PLACEMENT_FROM_WAIST"] = "high_hip_placement";
22928
+ MeasurementLocation["HIGH_HIP"] = "high_hip";
22929
+ MeasurementLocation["HSP_TO_ACROSS_BACK"] = "hsp_to_across_back";
22930
+ MeasurementLocation["HSP_TO_ACROSS_FRONT"] = "hsp_to_across_front";
22931
+ MeasurementLocation["HSP_TO_BUST_POINT"] = "hsp_to_bust_point";
22932
+ MeasurementLocation["HSP_TO_LOW_HIP_POSITION"] = "hsp_to_low_hip_position";
22933
+ MeasurementLocation["HSP_TO_WAIST_POSITION"] = "hsp_to_waist_position";
22934
+ MeasurementLocation["INSEAM"] = "inseam";
22935
+ MeasurementLocation["KNEE"] = "knee";
22936
+ MeasurementLocation["LOW_HIP"] = "low_hip";
22937
+ MeasurementLocation["LOW_HIP_PLACEMENT_FROM_WAIST"] = "low_hip_placement";
22938
+ MeasurementLocation["MID_NECK"] = "mid_neck";
22939
+ MeasurementLocation["NECK_AT_BASE"] = "neck_base";
22940
+ MeasurementLocation["SHOULDER_DROP"] = "shoulder_drop";
22941
+ MeasurementLocation["SHOULDER_TO_SHOULDER"] = "shoulder_to_shoulder";
22942
+ MeasurementLocation["SIDE_WAIST_TO_FLOOR"] = "side_waist_to_floor";
22943
+ MeasurementLocation["SIDE_WAIST_TO_KNEE"] = "side_waist_to_knee";
22944
+ MeasurementLocation["THIGH"] = "thigh";
22945
+ MeasurementLocation["TOTAL_RISE_LENGTH"] = "total_rise_length";
22946
+ MeasurementLocation["UNDER_BUST"] = "under_bust";
22947
+ MeasurementLocation["VERTICAL_TRUNK"] = "vertical_trunk";
22948
+ MeasurementLocation["WAIST"] = "waist";
22949
+ MeasurementLocation["WRIST"] = "wrist";
22950
+ })(MeasurementLocation || (MeasurementLocation = {}));
22951
+ const MeasurementLocationName = {
22952
+ [MeasurementLocation.ACROSS_BACK]: 'Across back',
22953
+ [MeasurementLocation.ACROSS_FRONT]: 'Across front',
22954
+ [MeasurementLocation.ACROSS_SHOULDER]: 'Across shoulder',
22955
+ [MeasurementLocation.ANKLE]: 'Ankle',
22956
+ [MeasurementLocation.ARMEYE]: 'Armeye',
22957
+ [MeasurementLocation.ARM_LENGTH_FROM_SHOULDER]: 'Arm length from shoulder',
22958
+ [MeasurementLocation.BACK_CROTCH_LENGTH]: 'Back crotch length',
22959
+ [MeasurementLocation.BACK_NECK_TO_EBLOW]: 'Back neck to eblow',
22960
+ [MeasurementLocation.BELOW_KNEE]: 'Below knee',
22961
+ [MeasurementLocation.BICEP]: 'Bicep',
22962
+ [MeasurementLocation.BUST]: 'Chest/Bust',
22963
+ [MeasurementLocation.BUST_POINT_TO_BUST_POINT]: 'Bust point to bust point',
22964
+ [MeasurementLocation.CALF]: 'Calf',
22965
+ [MeasurementLocation.CB_NECK_TO_WAIST]: 'Cb neck to waist',
22966
+ [MeasurementLocation.CB_NECK_TO_WRIST]: 'Cb neck to wrist',
22967
+ [MeasurementLocation.CF_NECK_TO_WAIST]: 'Cf neck to waist',
22968
+ [MeasurementLocation.ELBOW]: 'Elbow',
22969
+ [MeasurementLocation.FOREARM]: 'Forearm',
22970
+ [MeasurementLocation.FRONT_CROTCH_LENGTH]: 'Front crotch length',
22971
+ [MeasurementLocation.HIGH_HIP_PLACEMENT_FROM_WAIST]: 'High hip placement from waist',
22972
+ [MeasurementLocation.HIGH_HIP]: 'High hip',
22973
+ [MeasurementLocation.HSP_TO_ACROSS_BACK]: 'Hsp to across back',
22974
+ [MeasurementLocation.HSP_TO_ACROSS_FRONT]: 'Hsp to across front',
22975
+ [MeasurementLocation.HSP_TO_BUST_POINT]: 'Hsp to bust point',
22976
+ [MeasurementLocation.HSP_TO_LOW_HIP_POSITION]: 'Hsp to low hip position',
22977
+ [MeasurementLocation.HSP_TO_WAIST_POSITION]: 'Hsp to waist position',
22978
+ [MeasurementLocation.INSEAM]: 'Inseam',
22979
+ [MeasurementLocation.KNEE]: 'Knee',
22980
+ [MeasurementLocation.LOW_HIP]: 'Low hip',
22981
+ [MeasurementLocation.LOW_HIP_PLACEMENT_FROM_WAIST]: 'Low hip placement from waist',
22982
+ [MeasurementLocation.MID_NECK]: 'Mid neck',
22983
+ [MeasurementLocation.NECK_AT_BASE]: 'Neck at base',
22984
+ [MeasurementLocation.SHOULDER_DROP]: 'Shoulder drop',
22985
+ [MeasurementLocation.SHOULDER_TO_SHOULDER]: 'Shoulder to shoulder',
22986
+ [MeasurementLocation.SIDE_WAIST_TO_FLOOR]: 'Side waist to floor',
22987
+ [MeasurementLocation.SIDE_WAIST_TO_KNEE]: 'Side waist to knee',
22988
+ [MeasurementLocation.THIGH]: 'Thigh',
22989
+ [MeasurementLocation.TOTAL_RISE_LENGTH]: 'Total rise length',
22990
+ [MeasurementLocation.UNDER_BUST]: 'Under bust',
22991
+ [MeasurementLocation.VERTICAL_TRUNK]: 'Vertical trunk',
22992
+ [MeasurementLocation.WAIST]: 'Waist',
22993
+ [MeasurementLocation.WRIST]: 'Wrist',
22994
+ };
22995
+ var Classification;
22996
+ (function (Classification) {
22997
+ Classification["BLOUSES"] = "blouses";
22998
+ Classification["COATS"] = "coats";
22999
+ Classification["DRESSES"] = "dresses";
23000
+ Classification["JACKETS"] = "jackets";
23001
+ Classification["PANTS"] = "pants";
23002
+ Classification["PUFFERS_AND_PARKAS"] = "puffer_and_parkas";
23003
+ Classification["SHORTS"] = "shorts";
23004
+ Classification["SKIRTS"] = "skirts";
23005
+ Classification["SWEATERS"] = "sweaters";
23006
+ Classification["T_SHIRTS_AND_TANKS"] = "t_shirts_and_tanks";
23007
+ })(Classification || (Classification = {}));
23008
+ const ClassificationLocations = {
23009
+ [Classification.BLOUSES]: [
23010
+ MeasurementLocation.BUST,
23011
+ MeasurementLocation.ACROSS_SHOULDER,
23012
+ MeasurementLocation.WAIST,
23013
+ MeasurementLocation.LOW_HIP,
23014
+ MeasurementLocation.HIGH_HIP,
23015
+ ],
23016
+ // prettier-ignore
23017
+ [Classification.COATS]: [
23018
+ MeasurementLocation.BUST,
23019
+ MeasurementLocation.ACROSS_SHOULDER,
23020
+ MeasurementLocation.WAIST,
23021
+ MeasurementLocation.LOW_HIP,
23022
+ MeasurementLocation.HIGH_HIP
23023
+ ],
23024
+ [Classification.DRESSES]: [
23025
+ MeasurementLocation.LOW_HIP,
23026
+ MeasurementLocation.BUST,
23027
+ MeasurementLocation.ACROSS_SHOULDER,
23028
+ MeasurementLocation.WAIST,
23029
+ ],
23030
+ [Classification.JACKETS]: [
23031
+ MeasurementLocation.BUST,
23032
+ MeasurementLocation.ACROSS_SHOULDER,
23033
+ MeasurementLocation.WAIST,
23034
+ MeasurementLocation.LOW_HIP,
23035
+ MeasurementLocation.HIGH_HIP,
23036
+ ],
23037
+ [Classification.PANTS]: [
23038
+ MeasurementLocation.LOW_HIP,
23039
+ MeasurementLocation.WAIST,
23040
+ MeasurementLocation.THIGH,
23041
+ MeasurementLocation.INSEAM,
23042
+ ],
23043
+ [Classification.PUFFERS_AND_PARKAS]: [
23044
+ MeasurementLocation.BUST,
23045
+ MeasurementLocation.ACROSS_SHOULDER,
23046
+ MeasurementLocation.WAIST,
23047
+ MeasurementLocation.LOW_HIP,
23048
+ MeasurementLocation.HIGH_HIP,
23049
+ ],
23050
+ [Classification.SHORTS]: [
23051
+ MeasurementLocation.LOW_HIP,
23052
+ MeasurementLocation.WAIST,
23053
+ MeasurementLocation.THIGH,
23054
+ MeasurementLocation.INSEAM,
23055
+ ],
23056
+ // prettier-ignore
23057
+ [Classification.SKIRTS]: [
23058
+ MeasurementLocation.LOW_HIP,
23059
+ MeasurementLocation.WAIST
23060
+ ],
23061
+ // prettier-ignore
23062
+ [Classification.SWEATERS]: [
23063
+ MeasurementLocation.BUST,
23064
+ MeasurementLocation.ACROSS_SHOULDER,
23065
+ MeasurementLocation.WAIST,
23066
+ MeasurementLocation.LOW_HIP,
23067
+ MeasurementLocation.HIGH_HIP
23068
+ ],
23069
+ // prettier-ignore
23070
+ [Classification.T_SHIRTS_AND_TANKS]: [
23071
+ MeasurementLocation.BUST,
23072
+ MeasurementLocation.ACROSS_SHOULDER,
23073
+ MeasurementLocation.WAIST,
23074
+ MeasurementLocation.LOW_HIP,
23075
+ MeasurementLocation.HIGH_HIP
23076
+ ],
23077
+ };
23078
+ const CategoryNames = {
23079
+ ["activewear" /* Category.ACTIVEWEAR */]: 'Active Wear',
23080
+ ["dresses" /* Category.DRESSES */]: 'Dresses',
23081
+ ["jackets_and_coats" /* Category.JACKETS_AND_COATS */]: 'Jackets and Coats',
23082
+ ["jeans" /* Category.JEANS */]: 'Jeans',
23083
+ ["jumpsuits_and_rompers" /* Category.JUMPSUITS_AND_ROMPERS */]: 'Jumpsuits and Rompers',
23084
+ ["pants_and_shorts" /* Category.PANTS_AND_SHORTS */]: 'Pants and Shorts',
23085
+ ["skirts" /* Category.SKIRTS */]: 'Skirts',
23086
+ ["suits_and_tailoring" /* Category.SUITS_AND_TAILORING */]: 'Suits and Tailoring',
23087
+ ["sweaters" /* Category.SWEATERS */]: 'Sweaters',
23088
+ ["tops" /* Category.TOPS */]: 'Tops',
23089
+ };
23090
+ const Categories = [
23091
+ "activewear" /* Category.ACTIVEWEAR */,
23092
+ "dresses" /* Category.DRESSES */,
23093
+ "jackets_and_coats" /* Category.JACKETS_AND_COATS */,
23094
+ "jeans" /* Category.JEANS */,
23095
+ "jumpsuits_and_rompers" /* Category.JUMPSUITS_AND_ROMPERS */,
23096
+ "pants_and_shorts" /* Category.PANTS_AND_SHORTS */,
23097
+ "skirts" /* Category.SKIRTS */,
23098
+ "suits_and_tailoring" /* Category.SUITS_AND_TAILORING */,
23099
+ "sweaters" /* Category.SWEATERS */,
23100
+ "tops" /* Category.TOPS */,
23101
+ ];
23102
+ const SubcategoryNames = {
23103
+ ["a_line" /* Subcategory.A_LINE */]: 'A Line',
23104
+ ["a_line_flared" /* Subcategory.A_LINE_FLARED */]: 'A Line Flared',
23105
+ ["blazers" /* Subcategory.BLAZERS */]: 'Blazers',
23106
+ ["bodycon" /* Subcategory.BODYCON */]: 'Bodycon',
23107
+ ["bodysuits" /* Subcategory.BODYSUITS */]: 'Bodysuits',
23108
+ ["boiler_suits" /* Subcategory.BOILER_SUITS */]: 'Boiler Suits',
23109
+ ["bootcut" /* Subcategory.BOOTCUT */]: 'Bootcut',
23110
+ ["cardigans" /* Subcategory.CARDIGANS */]: 'Cardigans',
23111
+ ["cigarette" /* Subcategory.CIGARETTE */]: 'Cigarette',
23112
+ ["corsets_and_bustiers" /* Subcategory.CORSETS_AND_BUSTIERS */]: 'Corsets and Bustiers',
23113
+ ["crewnecks" /* Subcategory.CREWNECKS */]: 'Crewnecks',
23114
+ ["culottes" /* Subcategory.CULOTTES */]: 'Culottes',
23115
+ ["denim" /* Subcategory.DENIM */]: 'Denim',
23116
+ ["denim_jackets" /* Subcategory.DENIM_JACKETS */]: 'Denim Jackets',
23117
+ ["denim_shorts" /* Subcategory.DENIM_SHORTS */]: 'Denim Shorts',
23118
+ ["fit_and_flare" /* Subcategory.FIT_AND_FLARE */]: 'Fit and Flare',
23119
+ ["flared" /* Subcategory.FLARED */]: 'Flared',
23120
+ ["hoodies_and_zipups" /* Subcategory.HOODIES_AND_ZIPUPS */]: 'Hoodies and Zipups',
23121
+ ["joggers" /* Subcategory.JOGGERS */]: 'Joggers',
23122
+ ["jumpsuits" /* Subcategory.JUMPSUITS */]: 'Jumpsuits',
23123
+ ["knit" /* Subcategory.KNIT */]: 'Knit',
23124
+ ["leggings" /* Subcategory.LEGGINGS */]: 'Leggings',
23125
+ ["mom" /* Subcategory.MOM */]: 'Mom',
23126
+ ["overalls" /* Subcategory.OVERALLS */]: 'Overalls',
23127
+ ["parkas" /* Subcategory.PARKAS */]: 'Parkas',
23128
+ ["peacoats" /* Subcategory.PEACOATS */]: 'Peacoats',
23129
+ ["pencil" /* Subcategory.PENCIL */]: 'Pencil',
23130
+ ["pleated" /* Subcategory.PLEATED */]: 'Pleated',
23131
+ ["polos" /* Subcategory.POLOS */]: 'Polos',
23132
+ ["puffer_jackets" /* Subcategory.PUFFER_JACKETS */]: 'Puffer Jackets',
23133
+ ["raincoats" /* Subcategory.RAINCOATS */]: 'Raincoats',
23134
+ ["relaxed" /* Subcategory.RELAXED */]: 'Relaxed',
23135
+ ["rompers" /* Subcategory.ROMPERS */]: 'Rompers',
23136
+ ["shackets" /* Subcategory.SHACKETS */]: 'Shackets',
23137
+ ["shirt" /* Subcategory.SHIRT */]: 'Shirt',
23138
+ ["shirts_and_blouses" /* Subcategory.SHIRTS_AND_BLOUSES */]: 'Shirts and Blouses',
23139
+ ["skater" /* Subcategory.SKATER */]: 'Skater',
23140
+ ["skinny" /* Subcategory.SKINNY */]: 'Skinny',
23141
+ ["slim" /* Subcategory.SLIM */]: 'Slim',
23142
+ ["slip" /* Subcategory.SLIP */]: 'Slip',
23143
+ ["sports_bras" /* Subcategory.SPORTS_BRAS */]: 'Sports Bras',
23144
+ ["straight" /* Subcategory.STRAIGHT */]: 'Straight',
23145
+ ["suit_jackets" /* Subcategory.SUIT_JACKETS */]: 'Suit Jackets',
23146
+ ["suit_skirts" /* Subcategory.SUIT_SKIRTS */]: 'Suit Skirts',
23147
+ ["suit_trousers" /* Subcategory.SUIT_TROUSERS */]: 'Suit Trousers',
23148
+ ["suit_vests" /* Subcategory.SUIT_VESTS */]: 'Suit Vests',
23149
+ ["sweatshirts" /* Subcategory.SWEATSHIRTS */]: 'Sweatshirts',
23150
+ ["t_shirts" /* Subcategory.T_SHIRTS */]: 'T-Shirts',
23151
+ ["tank_tops_and_camisoles" /* Subcategory.TANK_TOPS_AND_CAMISOLES */]: 'Tank Tops and Camisoles',
23152
+ ["tapered" /* Subcategory.TAPERED */]: 'Tapered',
23153
+ ["trench_coats" /* Subcategory.TRENCH_COATS */]: 'Trench Coats',
23154
+ ["trousers" /* Subcategory.TROUSERS */]: 'Trousers',
23155
+ ["turtlenecks" /* Subcategory.TURTLENECKS */]: 'Turtleneck',
23156
+ ["unitards" /* Subcategory.UNITARDS */]: 'Unitards',
23157
+ ["v_necks" /* Subcategory.V_NECKS */]: 'V-Necks',
23158
+ ["wide_leg" /* Subcategory.WIDE_LEG */]: 'Wide Leg',
23159
+ ["wrap" /* Subcategory.WRAP */]: 'Wrap',
23160
+ };
23161
+ const Taxonomy = {
23162
+ ["activewear" /* Category.ACTIVEWEAR */]: {
23163
+ ["leggings" /* Subcategory.LEGGINGS */]: Classification.PANTS,
23164
+ ["joggers" /* Subcategory.JOGGERS */]: Classification.PANTS,
23165
+ ["sweatshirts" /* Subcategory.SWEATSHIRTS */]: Classification.SWEATERS,
23166
+ },
23167
+ ["dresses" /* Category.DRESSES */]: {
23168
+ ["a_line" /* Subcategory.A_LINE */]: Classification.DRESSES,
23169
+ ["bodycon" /* Subcategory.BODYCON */]: Classification.DRESSES,
23170
+ ["fit_and_flare" /* Subcategory.FIT_AND_FLARE */]: Classification.DRESSES,
23171
+ ["knit" /* Subcategory.KNIT */]: Classification.DRESSES,
23172
+ ["shirt" /* Subcategory.SHIRT */]: Classification.DRESSES,
23173
+ ["slip" /* Subcategory.SLIP */]: Classification.DRESSES,
23174
+ ["straight" /* Subcategory.STRAIGHT */]: Classification.DRESSES,
23175
+ ["wrap" /* Subcategory.WRAP */]: Classification.DRESSES,
23176
+ },
23177
+ ["jackets_and_coats" /* Category.JACKETS_AND_COATS */]: {
23178
+ ["denim_jackets" /* Subcategory.DENIM_JACKETS */]: Classification.JACKETS,
23179
+ ["parkas" /* Subcategory.PARKAS */]: Classification.PUFFERS_AND_PARKAS,
23180
+ ["peacoats" /* Subcategory.PEACOATS */]: Classification.COATS,
23181
+ ["puffer_jackets" /* Subcategory.PUFFER_JACKETS */]: Classification.PUFFERS_AND_PARKAS,
23182
+ ["raincoats" /* Subcategory.RAINCOATS */]: Classification.COATS,
23183
+ ["rompers" /* Subcategory.ROMPERS */]: Classification.COATS,
23184
+ ["shackets" /* Subcategory.SHACKETS */]: Classification.JACKETS,
23185
+ ["trench_coats" /* Subcategory.TRENCH_COATS */]: Classification.COATS,
23186
+ },
23187
+ ["jeans" /* Category.JEANS */]: {
23188
+ ["bootcut" /* Subcategory.BOOTCUT */]: Classification.PANTS,
23189
+ ["flared" /* Subcategory.FLARED */]: Classification.PANTS,
23190
+ ["mom" /* Subcategory.MOM */]: Classification.PANTS,
23191
+ ["relaxed" /* Subcategory.RELAXED */]: Classification.PANTS,
23192
+ ["skinny" /* Subcategory.SKINNY */]: Classification.PANTS,
23193
+ ["slim" /* Subcategory.SLIM */]: Classification.PANTS,
23194
+ ["straight" /* Subcategory.STRAIGHT */]: Classification.PANTS,
23195
+ ["tapered" /* Subcategory.TAPERED */]: Classification.PANTS,
23196
+ ["wide_leg" /* Subcategory.WIDE_LEG */]: Classification.PANTS,
23197
+ },
23198
+ ["jumpsuits_and_rompers" /* Category.JUMPSUITS_AND_ROMPERS */]: {
23199
+ ["boiler_suits" /* Subcategory.BOILER_SUITS */]: Classification.DRESSES,
23200
+ ["denim" /* Subcategory.DENIM */]: Classification.DRESSES,
23201
+ ["jumpsuits" /* Subcategory.JUMPSUITS */]: Classification.DRESSES,
23202
+ ["overalls" /* Subcategory.OVERALLS */]: Classification.DRESSES,
23203
+ ["rompers" /* Subcategory.ROMPERS */]: Classification.DRESSES,
23204
+ ["unitards" /* Subcategory.UNITARDS */]: Classification.DRESSES,
23205
+ },
23206
+ ["pants_and_shorts" /* Category.PANTS_AND_SHORTS */]: {
23207
+ ["cigarette" /* Subcategory.CIGARETTE */]: Classification.PANTS,
23208
+ ["culottes" /* Subcategory.CULOTTES */]: Classification.SHORTS,
23209
+ ["denim_shorts" /* Subcategory.DENIM_SHORTS */]: Classification.SHORTS,
23210
+ ["flared" /* Subcategory.FLARED */]: Classification.PANTS,
23211
+ ["joggers" /* Subcategory.JOGGERS */]: Classification.PANTS,
23212
+ ["leggings" /* Subcategory.LEGGINGS */]: Classification.PANTS,
23213
+ ["skinny" /* Subcategory.SKINNY */]: Classification.PANTS,
23214
+ ["wide_leg" /* Subcategory.WIDE_LEG */]: Classification.PANTS,
23215
+ },
23216
+ ["skirts" /* Category.SKIRTS */]: {
23217
+ ["a_line_flared" /* Subcategory.A_LINE_FLARED */]: Classification.SKIRTS,
23218
+ ["denim" /* Subcategory.DENIM */]: Classification.SKIRTS,
23219
+ ["knit" /* Subcategory.KNIT */]: Classification.SKIRTS,
23220
+ ["pencil" /* Subcategory.PENCIL */]: Classification.SKIRTS,
23221
+ ["pleated" /* Subcategory.PLEATED */]: Classification.SKIRTS,
23222
+ ["skater" /* Subcategory.SKATER */]: Classification.SKIRTS,
23223
+ ["slip" /* Subcategory.SLIP */]: Classification.SKIRTS,
23224
+ ["wrap" /* Subcategory.WRAP */]: Classification.SKIRTS,
23225
+ },
23226
+ ["suits_and_tailoring" /* Category.SUITS_AND_TAILORING */]: {
23227
+ ["blazers" /* Subcategory.BLAZERS */]: Classification.JACKETS,
23228
+ ["suit_jackets" /* Subcategory.SUIT_JACKETS */]: Classification.JACKETS,
23229
+ ["suit_skirts" /* Subcategory.SUIT_SKIRTS */]: Classification.SKIRTS,
23230
+ ["suit_trousers" /* Subcategory.SUIT_TROUSERS */]: Classification.PANTS,
23231
+ ["suit_vests" /* Subcategory.SUIT_VESTS */]: Classification.SWEATERS,
23232
+ ["trousers" /* Subcategory.TROUSERS */]: Classification.PANTS,
23233
+ },
23234
+ ["sweaters" /* Category.SWEATERS */]: {
23235
+ ["cardigans" /* Subcategory.CARDIGANS */]: Classification.SWEATERS,
23236
+ ["crewnecks" /* Subcategory.CREWNECKS */]: Classification.SWEATERS,
23237
+ ["hoodies_and_zipups" /* Subcategory.HOODIES_AND_ZIPUPS */]: Classification.SWEATERS,
23238
+ ["sweatshirts" /* Subcategory.SWEATSHIRTS */]: Classification.SWEATERS,
23239
+ ["turtlenecks" /* Subcategory.TURTLENECKS */]: Classification.SWEATERS,
23240
+ ["v_necks" /* Subcategory.V_NECKS */]: Classification.SWEATERS,
23241
+ },
23242
+ ["tops" /* Category.TOPS */]: {
23243
+ ["bodysuits" /* Subcategory.BODYSUITS */]: Classification.BLOUSES,
23244
+ ["corsets_and_bustiers" /* Subcategory.CORSETS_AND_BUSTIERS */]: Classification.BLOUSES,
23245
+ ["polos" /* Subcategory.POLOS */]: Classification.T_SHIRTS_AND_TANKS,
23246
+ ["shirts_and_blouses" /* Subcategory.SHIRTS_AND_BLOUSES */]: Classification.BLOUSES,
23247
+ ["t_shirts" /* Subcategory.T_SHIRTS */]: Classification.T_SHIRTS_AND_TANKS,
23248
+ ["tank_tops_and_camisoles" /* Subcategory.TANK_TOPS_AND_CAMISOLES */]: Classification.T_SHIRTS_AND_TANKS,
23249
+ },
23250
+ };
23251
+ var Fit;
23252
+ (function (Fit) {
23253
+ Fit["TOO_TIGHT"] = "too_tight";
23254
+ Fit["TIGHT"] = "tight";
23255
+ Fit["SLIGHTLY_TIGHT"] = "slightly_tight";
23256
+ Fit["PERFECT_FIT"] = "perfect_fit";
23257
+ Fit["SLIGHTLY_LOOSE"] = "slightly_loose";
23258
+ Fit["LOOSE"] = "loose";
23259
+ Fit["OVERSIZED"] = "oversized";
23260
+ })(Fit || (Fit = {}));
23261
+ const FitNames = {
23262
+ [Fit.TOO_TIGHT]: 'Too Tight',
23263
+ [Fit.TIGHT]: 'Tight',
23264
+ [Fit.SLIGHTLY_TIGHT]: 'Slightly Tight',
23265
+ [Fit.PERFECT_FIT]: 'Perfect Fit',
23266
+ [Fit.SLIGHTLY_LOOSE]: 'Slightly Loose',
23267
+ [Fit.LOOSE]: 'Loose',
23268
+ [Fit.OVERSIZED]: 'Oversized',
23269
+ };
22910
23270
 
22911
23271
  class Fetcher {
22912
23272
  static get endpoint() {
@@ -22956,22 +23316,10 @@ class Fetcher {
22956
23316
  }
22957
23317
  }
22958
23318
 
22959
- const testImage = (url) => {
22960
- const img = new Image();
22961
- img.src = url;
22962
- return new Promise((resolve) => {
22963
- img.onerror = () => resolve(false);
22964
- img.onload = () => resolve(true);
22965
- });
22966
- };
22967
-
22968
23319
  class TfrShop {
22969
23320
  constructor(brandId, firebase) {
22970
23321
  this.brandId = brandId;
22971
23322
  this.firebase = firebase;
22972
- const config = Config.getInstance().config;
22973
- TfrShop.avatarTimeout = config.avatarTimeout ? Number(config.avatarTimeout) : 120000;
22974
- TfrShop.vtoTimeout = config.vtoTimeout ? Number(config.vtoTimeout) : 120000;
22975
23323
  }
22976
23324
  get user() {
22977
23325
  return this.firebase.user;
@@ -22982,39 +23330,16 @@ class TfrShop {
22982
23330
  onInit() {
22983
23331
  return this.firebase.onInit();
22984
23332
  }
22985
- async tryOn(colorwaySizeAssetSku) {
22986
- if (!this.isLoggedIn)
22987
- throw new UserNotLoggedInError();
22988
- try {
22989
- const frames = await this.getColorwaySizeAssetFrames(colorwaySizeAssetSku);
22990
- return frames;
22991
- }
22992
- catch (error) {
22993
- if (!(error instanceof NoFramesFoundError))
22994
- throw error;
22995
- return this.requestThenGetColorwaySizeAssetFrames(colorwaySizeAssetSku);
22996
- }
22997
- }
22998
- async awaitAvatarCreated() {
22999
- if (!this.isLoggedIn)
23000
- throw new UserNotLoggedInError();
23001
- const { promise, unsubscribe } = this.firebase.query('users', rl(Eh(), '==', this.user.id));
23002
- const cancel = setTimeout(() => {
23003
- unsubscribe();
23004
- throw new RequestTimeoutError();
23005
- }, TfrShop.avatarTimeout);
23006
- const snapshot = await promise;
23007
- clearTimeout(cancel);
23008
- const userProfile = snapshot.docs[0].data();
23009
- return userProfile.avatar_status === 'CREATED';
23010
- }
23011
23333
  async getRecommendedSizes(styleId) {
23334
+ var _a, _b;
23012
23335
  if (!this.isLoggedIn)
23013
23336
  throw new UserNotLoggedInError();
23014
23337
  try {
23015
23338
  const res = await Fetcher.Get(this.user, `/styles/${styleId}/recommendation`);
23016
- const json = await res.json();
23017
- return json;
23339
+ const data = (await res.json());
23340
+ if (!((_a = data === null || data === void 0 ? void 0 : data.fits) === null || _a === void 0 ? void 0 : _a.length) || !((_b = data === null || data === void 0 ? void 0 : data.recommended_size) === null || _b === void 0 ? void 0 : _b.id))
23341
+ return null;
23342
+ return data;
23018
23343
  }
23019
23344
  catch (error) {
23020
23345
  if ((error === null || error === void 0 ? void 0 : error.error) === AvatarNotCreated)
@@ -23022,85 +23347,26 @@ class TfrShop {
23022
23347
  throw error;
23023
23348
  }
23024
23349
  }
23025
- async getRecommendedSizesLabels(styleId) {
23026
- const sizeRecommendation = await this.getRecommendedSizes(styleId);
23027
- const recommendedSizeLabel = sizeRecommendation.recommended_sizes.label || sizeRecommendation.recommended_sizes.size_value.size;
23028
- const availableSizeLabels = sizeRecommendation.available_sizes.map((size) => size.label || size.size_value.size);
23029
- return { recommendedSizeLabel, availableSizeLabels };
23030
- }
23031
- async getStyles(ids, skus) {
23032
- const constraints = [rl('brand_id', '==', this.brandId)];
23033
- if ((ids === null || ids === void 0 ? void 0 : ids.length) > 0)
23034
- constraints.push(rl('id', 'in', ids));
23035
- if ((skus === null || skus === void 0 ? void 0 : skus.length) > 0)
23036
- constraints.push(rl('brand_style_id', 'in', skus));
23037
- try {
23038
- const querySnapshot = await this.firebase.getDocs('styles', constraints);
23039
- const styles = new Map();
23040
- querySnapshot.forEach((doc) => {
23041
- const FirestoreStyle = doc.data();
23042
- styles.set(FirestoreStyle.id, FirestoreStyle);
23043
- });
23044
- return styles;
23045
- }
23046
- catch (error) {
23047
- return getFirebaseError(error);
23048
- }
23049
- }
23050
23350
  async submitTelephoneNumber(tel) {
23051
23351
  const sanitizedTel = tel.replace(/[^\+0-9]/g, '');
23052
23352
  const res = await Fetcher.Post(this.user, '/ios-app-link', { phone_number: sanitizedTel }, false);
23053
23353
  console.log(res);
23054
23354
  }
23055
- async awaitColorwaySizeAssetFrames(colorwaySizeAssetSKU) {
23056
- var _a, _b, _c, _d;
23057
- if (!this.isLoggedIn)
23058
- throw new UserNotLoggedInError();
23059
- const predicate = async (data) => {
23060
- var _a, _b, _c, _d;
23061
- const frames = (_d = (_c = (_b = (_a = data.docs[0].data()) === null || _a === void 0 ? void 0 : _a.vto) === null || _b === void 0 ? void 0 : _b[this.brandId]) === null || _c === void 0 ? void 0 : _c[colorwaySizeAssetSKU]) === null || _d === void 0 ? void 0 : _d.frames;
23062
- if (!(frames === null || frames === void 0 ? void 0 : frames.length))
23063
- return false;
23064
- return testImage(frames[0]);
23065
- };
23066
- const userProfile = (await this.user.watchUserProfileForChanges(predicate, TfrShop.vtoTimeout));
23067
- if (!((_d = (_c = (_b = (_a = userProfile === null || userProfile === void 0 ? void 0 : userProfile.vto) === null || _a === void 0 ? void 0 : _a[this.brandId]) === null || _b === void 0 ? void 0 : _b[colorwaySizeAssetSKU]) === null || _c === void 0 ? void 0 : _c.frames) === null || _d === void 0 ? void 0 : _d.length))
23068
- throw new NoFramesFoundError();
23069
- return userProfile.vto[this.brandId][colorwaySizeAssetSKU].frames;
23070
- }
23071
- async requestThenGetColorwaySizeAssetFrames(colorwaySizeAssetSku) {
23072
- var _a, _b;
23073
- const [error, colorwaySizeAsset] = await asyncTry(this.getColorwaySizeAssetFromSku(colorwaySizeAssetSku));
23074
- if (error)
23075
- throw error;
23076
- try {
23077
- await this.requestColorwaySizeAssetFrames(colorwaySizeAsset.id);
23078
- return this.awaitColorwaySizeAssetFrames(colorwaySizeAssetSku);
23079
- }
23080
- catch (error) {
23081
- if ((error === null || error === void 0 ? void 0 : error.error) === AvatarNotCreated)
23082
- throw new AvatarNotCreatedError();
23083
- if (!error.recommended_size_id)
23084
- throw new Error(error);
23085
- const errorOutsideRecommended = error;
23086
- const styles = await this.getStyles([colorwaySizeAsset.style_id], null);
23087
- const style = styles.get(colorwaySizeAsset.style_id);
23088
- if (!(style === null || style === void 0 ? void 0 : style.sizes))
23089
- throw new NoStylesFoundError();
23090
- const recommendedSize = ((_a = style.sizes[errorOutsideRecommended.recommended_size_id]) === null || _a === void 0 ? void 0 : _a.label) ||
23091
- ((_b = style.sizes[errorOutsideRecommended.recommended_size_id]) === null || _b === void 0 ? void 0 : _b.size);
23092
- const availableSizes = errorOutsideRecommended.available_size_ids
23093
- .filter((id) => { var _a; return ((_a = style.sizes[id]) === null || _a === void 0 ? void 0 : _a.size) !== recommendedSize; })
23094
- .map((id) => { var _a, _b; return ((_a = style.sizes[id]) === null || _a === void 0 ? void 0 : _a.label) || ((_b = style.sizes[id]) === null || _b === void 0 ? void 0 : _b.size); });
23095
- throw new RecommendedAvailableSizesError(recommendedSize, availableSizes);
23096
- }
23097
- }
23098
23355
  async getColorwaySizeAssetFromSku(colorwaySizeAssetSku) {
23099
23356
  const assets = await this.getColorwaySizeAssets(null, [colorwaySizeAssetSku]);
23100
23357
  if (!(assets === null || assets === void 0 ? void 0 : assets.size))
23101
23358
  throw new NoColorwaySizeAssetsFoundError();
23102
23359
  return Array.from(assets.values())[0];
23103
23360
  }
23361
+ async getMeasurementLocationsFromSku(sku) {
23362
+ var _a;
23363
+ const asset = await this.getColorwaySizeAssetFromSku(sku);
23364
+ const styleCategory = await this.getStyleCategory(asset.style_id);
23365
+ const classificationLocation = ((_a = Taxonomy[styleCategory.category]) === null || _a === void 0 ? void 0 : _a[styleCategory.sub_category]) || null;
23366
+ return classificationLocation
23367
+ ? ClassificationLocations[classificationLocation].map((location) => MeasurementLocationName[location])
23368
+ : null;
23369
+ }
23104
23370
  async getColorwaySizeAssets(styleId, skus) {
23105
23371
  const constraints = [rl('brand_id', '==', this.brandId)];
23106
23372
  if (styleId)
@@ -23120,29 +23386,16 @@ class TfrShop {
23120
23386
  return getFirebaseError(error);
23121
23387
  }
23122
23388
  }
23123
- async requestColorwaySizeAssetFrames(colorwaySizeAssetId) {
23124
- if (!this.isLoggedIn)
23125
- throw new UserNotLoggedInError();
23126
- if (!this.user.brandUserId)
23127
- throw new BrandUserIdNotSetError();
23128
- await Fetcher.Post(this.user, `/colorway-size-assets/${colorwaySizeAssetId}/frames`, {
23129
- brand_user_id: String(this.user.brandUserId),
23130
- });
23389
+ async getStyleCategory(styleId) {
23390
+ try {
23391
+ const doc = await this.firebase.getDoc('style_categories', String(styleId));
23392
+ return doc;
23393
+ }
23394
+ catch (error) {
23395
+ return getFirebaseError(error);
23396
+ }
23131
23397
  }
23132
- async getColorwaySizeAssetFrames(colorwaySizeAssetSKU) {
23133
- var _a, _b, _c;
23134
- const userProfile = await this.user.getUserProfile();
23135
- const frames = ((_c = (_b = (_a = userProfile === null || userProfile === void 0 ? void 0 : userProfile.vto) === null || _a === void 0 ? void 0 : _a[this.brandId]) === null || _b === void 0 ? void 0 : _b[colorwaySizeAssetSKU]) === null || _c === void 0 ? void 0 : _c.frames) || [];
23136
- if (!frames.length)
23137
- throw new NoFramesFoundError();
23138
- const testedImage = await testImage(frames[0]);
23139
- if (!testedImage)
23140
- throw new NoFramesFoundError();
23141
- return frames;
23142
- }
23143
- }
23144
- TfrShop.avatarTimeout = 120000;
23145
- TfrShop.vtoTimeout = 120000;
23398
+ }
23146
23399
  const initShop = (brandId, env = 'dev') => {
23147
23400
  if (env === 'dev' || env === 'development')
23148
23401
  console.warn('TfrShop is in development mode');
@@ -23157,51 +23410,20 @@ var AvatarState$1;
23157
23410
  AvatarState["PENDING"] = "PENDING";
23158
23411
  })(AvatarState$1 || (AvatarState$1 = {}));
23159
23412
 
23160
- const VTO_TIMEOUT_MS = TfrShop.vtoTimeout;
23161
-
23162
- function loadImageRecursive(imageURL, imageURLs) {
23163
- let next = function () {
23164
- if (imageURLs.length === 0) {
23165
- return;
23166
- }
23167
- loadImageRecursive(imageURLs.slice(-1), imageURLs.slice(0, -1));
23168
- };
23169
- var img = new Image();
23170
- img.onload = next;
23171
- img.onerror = next;
23172
- img.src = imageURL;
23173
- }
23174
- function loadImages(imageURLs) {
23175
- loadImageRecursive(imageURLs.slice(-1), imageURLs.slice(0, -1));
23176
- }
23177
- const InitImageSlider = (sliderID, onChange) => {
23178
- const slider = document.getElementById(sliderID);
23179
- if (!slider) {
23180
- throw new Error(`Slider with id ${sliderID} not found`);
23181
- }
23182
- return {
23183
- Load(imageURLs) {
23184
- if (!Array.isArray(imageURLs) || !imageURLs.length) {
23185
- console.debug('slider has no images to load');
23186
- return new Error('slider has no images to load');
23187
- }
23188
- loadImages(imageURLs);
23189
- const defaultScrollValue = (imageURLs === null || imageURLs === void 0 ? void 0 : imageURLs.length) - 2;
23190
- slider.value = defaultScrollValue.toString();
23191
- slider.max = (imageURLs.length - 1).toString();
23192
- const handleSliderChange = () => {
23193
- const currentValue = parseInt(slider.value);
23194
- onChange(slider, imageURLs[currentValue]);
23195
- };
23196
- onChange(slider, imageURLs[defaultScrollValue]);
23197
- slider.removeEventListener('input', handleSliderChange);
23198
- slider.addEventListener('input', handleSliderChange);
23199
- return () => {
23200
- slider.removeEventListener('input', handleSliderChange);
23201
- };
23202
- },
23203
- };
23204
- };
23413
+ var index = /*#__PURE__*/Object.freeze({
23414
+ __proto__: null,
23415
+ get AvatarState () { return AvatarState$1; },
23416
+ get MeasurementLocation () { return MeasurementLocation; },
23417
+ MeasurementLocationName: MeasurementLocationName,
23418
+ get Classification () { return Classification; },
23419
+ ClassificationLocations: ClassificationLocations,
23420
+ CategoryNames: CategoryNames,
23421
+ Categories: Categories,
23422
+ SubcategoryNames: SubcategoryNames,
23423
+ Taxonomy: Taxonomy,
23424
+ get Fit () { return Fit; },
23425
+ FitNames: FitNames
23426
+ });
23205
23427
 
23206
23428
  var L = {
23207
23429
  AssociatedEmail: 'If there is an account associated with that email, We have sent a link to reset your password.',
@@ -23257,16 +23479,22 @@ const validatePassword = (password) => {
23257
23479
 
23258
23480
  var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
23259
23481
 
23260
- var css$6 = ".tfr-bg-aquamarina-strong{background-color:#209da7}.tfr-c-white{color:#fff}.tfr-c-brand{color:#209da7}.tfr-c-dark{color:#000}.tfr-c-dark-o5{color:rgba(0,0,0,.5)}.tfr-c-red{color:red}";
23482
+ var css$8 = ".tfr-bg-aquamarina-strong{background-color:#209da7}.tfr-c-white{color:#fff}.tfr-c-brand{color:#209da7}.tfr-c-dark{color:#000}.tfr-c-dark-o5{color:rgba(0,0,0,.5)}.tfr-c-red{color:red}";
23483
+ n(css$8,{});
23484
+
23485
+ var css$7 = ".tfr-home-button-container{display:flex;flex-wrap:wrap;margin:20px}.tfr-home-button-container>button{border:0;cursor:pointer;height:60px;margin:20px;width:200px}.tfr-home-button-container>button:hover{background-color:#e6e6e6}[data-tfr=hidden]{display:none}.tfr-modal{background-color:rgba(0,0,0,.53);display:flex;height:100%;left:0;position:fixed;top:0;width:100%;z-index:10000}.tfr-modal-content{margin:auto;text-align:center;width:90%}.tfr-modal-content-flex{align-items:center;display:flex}.tfr-modal-content-container{background-color:#fff;border:1px solid #434343;border-radius:0;box-shadow:0 6px 6px #00000029;line-height:normal;margin:auto;max-height:100vh;max-width:709px;overflow:auto;width:100%}.tfr-close-container{text-align:end}.tfr-close{color:#aaa;font-size:28px;font-weight:700;height:50px;width:50px}.tfr-close:focus,.tfr-close:hover{color:#000;text-decoration:none}.tfr-cursor:hover{cursor:pointer}.tfr-underline{text-decoration:underline}.tfr-standard-button{border:0;border-radius:3px;color:#fff;height:43px;width:138px}.tfr-logo-container{align-items:center;display:flex}.tfr-modal-title-logo-container{align-items:center;display:flex;justify-content:center}.tfr-girl-clothes{display:inline-block;height:316px;width:253px}.tfr-t-a-center{text-align:center}.tfr-w-70-p{width:70%}.tfr-w-80-p{width:80%}.tfr-w-85-p{width:85%}.tfr-w-150{width:150px}.tfr-h-150{height:150px}.tfr-d-none{display:none}.tfr-d-block{display:block}.tfr-d-flex{display:flex}.tfr-how-it-works-item{align-items:center;display:flex;justify-items:center}.tfr-try-on-content{margin-left:60px}#tfr-tryon-image{max-width:30vw}.progress-bar{background-color:#fff;border:1px solid #bdbdbd;height:10px;margin:15px auto 0;width:55%}.progress-bar-fill{animation-duration:120s;animation-name:progress;background-color:#209da7;color:#fff;display:block;font-size:16px;height:100%;text-align:center;transition:width .6s linear}#tfr-video{height:100%;max-height:390px;max-width:390px}.tfr-logo-box{aspect-ratio:1;margin:auto;max-height:430px;max-width:430px;padding:20px}.tfr-flex,.tfr-logo-box{align-items:center;display:flex;justify-content:center}";
23486
+ n(css$7,{});
23487
+
23488
+ var css$6 = "input{border:none;box-shadow:none!important;width:100%}input:focus,select:focus,textarea:focus{border:none;outline:none}.tfr-fieldset{margin-left:auto;margin-right:auto;width:65%}.tfr-fieldset,.tfr-fieldset-inline{border-color:rgba(0,0,0,.5);border-radius:10px;border-width:1px;padding:5px 10px 10px;text-align:left}.tfr-fieldset-inline{margin-right:10px;width:250px}.tfr-fieldset-err{border-color:red}";
23261
23489
  n(css$6,{});
23262
23490
 
23263
- var css$5 = ".tfr-home-button-container{display:flex;flex-wrap:wrap;margin:20px}.tfr-home-button-container>button{border:0;cursor:pointer;height:60px;margin:20px;width:200px}.tfr-home-button-container>button:hover{background-color:#e6e6e6}[data-tfr=hidden]{display:none}.tfr-modal{background-color:rgba(0,0,0,.53);display:flex;height:100%;left:0;position:fixed;top:0;width:100%;z-index:10000}.tfr-modal-content{margin:auto;text-align:center;width:90%}.tfr-modal-content-flex{align-items:center;display:flex}.tfr-modal-content-container{background-color:#fff;border:1px solid #434343;border-radius:0;box-shadow:0 6px 6px #00000029;line-height:normal;margin:auto;max-height:100vh;max-width:709px;overflow:auto;width:100%}.tfr-close-container{text-align:end}.tfr-close{color:#aaa;font-size:28px;font-weight:700;height:50px;width:50px}.tfr-close:focus,.tfr-close:hover{color:#000;text-decoration:none}.tfr-cursor:hover{cursor:pointer}.tfr-underline{text-decoration:underline}.tfr-standard-button{border:0;border-radius:3px;color:#fff;height:43px;width:138px}.tfr-logo-container{align-items:center;display:flex}.tfr-modal-title-logo-container{align-items:center;display:flex;justify-content:center}.tfr-girl-clothes{display:inline-block;height:316px;width:253px}.tfr-t-a-center{text-align:center}.tfr-w-70-p{width:70%}.tfr-w-80-p{width:80%}.tfr-w-85-p{width:85%}.tfr-w-150{width:150px}.tfr-h-150{height:150px}.tfr-d-none{display:none}.tfr-d-block{display:block}.tfr-d-flex{display:flex}.tfr-how-it-works-item{align-items:center;display:flex;justify-items:center}.tfr-try-on-content{margin-left:60px}#tfr-tryon-image{max-width:30vw}.progress-bar{background-color:#fff;border:1px solid #bdbdbd;height:10px;margin:15px auto 0;width:55%}.progress-bar-fill{animation-duration:120s;animation-name:progress;background-color:#209da7;color:#fff;display:block;font-size:16px;height:100%;text-align:center;transition:width .6s linear}#tfr-video{height:100%;max-height:390px;max-width:390px}.tfr-logo-box{aspect-ratio:1;margin:auto;max-height:430px;max-width:430px;padding:20px}.tfr-flex,.tfr-logo-box{align-items:center;display:flex;justify-content:center}";
23491
+ var css$5 = ".lds-ellipsis{display:inline-block;height:80px;position:relative;width:80px}.lds-ellipsis div{animation-timing-function:cubic-bezier(0,1,1,0);background:#209da7;border-radius:50%;display:block;height:13px;position:absolute;top:33px;width:13px}.lds-ellipsis div:first-child{animation:lds-ellipsis1 .6s infinite;left:8px}.lds-ellipsis div:nth-child(2){animation:lds-ellipsis2 .6s infinite;left:8px}.lds-ellipsis div:nth-child(3){animation:lds-ellipsis2 .6s infinite;left:32px}.lds-ellipsis div:nth-child(4){animation:lds-ellipsis3 .6s infinite;left:56px}@keyframes lds-ellipsis1{0%{transform:scale(0)}to{transform:scale(1)}}@keyframes lds-ellipsis3{0%{transform:scale(1)}to{transform:scale(0)}}@keyframes lds-ellipsis2{0%{transform:translate(0)}to{transform:translate(24px)}}";
23264
23492
  n(css$5,{});
23265
23493
 
23266
- var css$4 = "input{border:none;box-shadow:none!important;width:100%}input:focus,select:focus,textarea:focus{border:none;outline:none}.tfr-fieldset{margin-left:auto;margin-right:auto;width:65%}.tfr-fieldset,.tfr-fieldset-inline{border-color:rgba(0,0,0,.5);border-radius:10px;border-width:1px;padding:5px 10px 10px;text-align:left}.tfr-fieldset-inline{margin-right:10px;width:250px}.tfr-fieldset-err{border-color:red}";
23494
+ var css$4 = "@media screen and (max-width:702px){.tfr-modal-title-logo-container{display:flex;flex-direction:column}}@media screen and (min-width:600px){.tfr-modal-content-container{border-radius:10px;height:auto}}@media screen and (max-width:599px){.tfr-mobile-hidden{display:none}.tfr-modal-content-container{min-height:100vh}.trf-logo-title{margin-bottom:10px}.tfr-modal-content-flex{height:calc(100vh - 76px)}}@media screen and (max-width:500px){.tfr-fieldset{width:90%}.tfr-how-it-works-item{flex-direction:column}.tfr-try-on-content{margin-left:0;margin-top:20px}}";
23267
23495
  n(css$4,{});
23268
23496
 
23269
- var css$3 = "@media screen and (max-width:702px){.tfr-modal-title-logo-container{display:flex;flex-direction:column}}@media screen and (min-width:600px){.tfr-modal-content-container{border-radius:10px;height:auto}}@media screen and (max-width:599px){.tfr-mobile-hidden{display:none}.tfr-modal-content-container{min-height:100vh}.trf-logo-title{margin-bottom:10px}.tfr-modal-content-flex{height:calc(100vh - 76px)}}@media screen and (max-width:500px){.tfr-fieldset{width:90%}.tfr-how-it-works-item{flex-direction:column}.tfr-try-on-content{margin-left:0;margin-top:20px}}";
23497
+ var css$3 = "#tfr-size-recommendations{border:1px solid hsla(0,0%,7%,.55);color:#121212;display:flex;padding:14px 20px;width:440px}#tfr-size-recommendations,#tfr-size-recommendations-container{align-items:center;flex-direction:column;justify-content:center}#tfr-size-recommendations-container{display:none;width:100%}#tfr-size-rec-login-svg{display:none}#tfr-size-rec-title{align-items:center;display:flex;margin-bottom:8px}#tfr-size-rec-subtitle{margin-bottom:6px}#tfr-size-rec-subtitle,#tfr-size-rec-title{font-size:16px;font-weight:700}#tfr-size-rec-table{display:flex;flex-direction:column;font-size:12px;width:100%}.tfr-size-rec-table-row:first-of-type{border-top-width:2px}.tfr-size-rec-table-row{align-items:center;border-top:1px solid hsla(0,0%,7%,.55);display:flex;height:40px;justify-content:center}.tfr-size-rec-table-cell-left,.tfr-size-rec-table-cell-right{flex:1 1 0px}.tfr-size-rec-table-cell-left{font-weight:700;margin-right:70px;text-align:right}.tfr-size-rec-table-cell-right{margin-left:16px}.tfr-size-rec-table-cell-right.perfect{color:#209da7}#tfr-size-rec-size>.tfr-size-rec-login-cta{font-weight:500;margin-left:10px}.tfr-size-rec-login-cta,.tfr-size-rec-table-cell-right{font-size:12px}.tfr-size-rec-login-cta{color:#a7a7a7;display:flex}#tfr-size-rec-action-login,#tfr-size-rec-action-logout{display:none}#tfr-size-rec-action{cursor:pointer;font-size:16px;margin-top:14px;text-decoration:underline}#tfr-size-rec-select{background-color:#878787;border-radius:8px;box-shadow:0 4px 4px 0 rgba(0,0,0,.3);color:#fff;display:none;font-size:14px;margin-bottom:20px;margin-top:10px}#tfr-size-rec-select,.tfr-size-rec-select-button{align-items:center;height:35px;justify-content:center}.tfr-size-rec-select-button{cursor:pointer;display:flex;transition:all .15s ease-in;width:80px}.tfr-size-rec-select-button:hover:not(.active){background-color:hsla(0,0%,100%,.3);opacity:.7}.tfr-size-rec-select-button.active{background-color:#212121;height:45px}.tfr-size-rec-select-button.active,.tfr-size-rec-select-button:first-of-type{border-bottom-left-radius:8px;border-top-left-radius:8px}.tfr-size-rec-select-button.active,.tfr-size-rec-select-button:last-of-type{border-bottom-right-radius:8px;border-top-right-radius:8px}";
23270
23498
  n(css$3,{});
23271
23499
 
23272
23500
  var css$2 = ".tfr-mt-10{margin-top:10px}.tfr-mt-20{margin-top:20px}.tfr-mt-15{margin-top:15px}.tfr-mt-30{margin-top:30px}.mt-40{margin-top:40px}.tfr-mb-40{margin-bottom:40px}.tfr-mb-20{margin-bottom:20px}.tfr-mr-10{margin-right:10px}.tfr-mr-15{margin-right:15px}.tfr-mt-50{margin-top:50px}.tfr-mt-60{margin-top:60px}.tfr-mb-60{margin-bottom:60px}.tfr-mr-20{margin-right:20px}.tfr-mt-15-p{margin-top:15%}.tfr-mb-13-p{margin-bottom:13%}.tfr-m-h-auto{margin-left:auto;margin-right:auto}.tfr-pt-20{padding-top:20px}.tfr-pb-50{padding-bottom:50px}.tfr-p-20{padding:20px}.tfr-pr-20{padding-right:20px}.tfr-pl-20{padding-left:20px}.tfr-pb-7-p{padding-bottom:7%}";
@@ -36119,19 +36347,13 @@ const TryOnModal = (props) => {
36119
36347
  };
36120
36348
  };
36121
36349
 
36122
- class FittingRoomNav {
36350
+ class TfrModal {
36123
36351
  constructor(modalDivId, signIn, forgotPassword, submitTel) {
36124
36352
  this.signIn = signIn;
36125
36353
  this.forgotPassword = forgotPassword;
36126
36354
  this.submitTel = submitTel;
36127
36355
  this.manager = InitModalManager(modalDivId);
36128
36356
  }
36129
- get sku() {
36130
- return this._sku;
36131
- }
36132
- setSku(sku) {
36133
- this._sku = sku;
36134
- }
36135
36357
  close() {
36136
36358
  this.manager.close();
36137
36359
  }
@@ -36195,6 +36417,241 @@ class FittingRoomNav {
36195
36417
  }
36196
36418
  }
36197
36419
 
36420
+ const svgSrc = '';
36421
+ class SizeRecComponent {
36422
+ constructor(sizeRecMainDivId, tfrShop, onSignInClick, onSignOutClick) {
36423
+ this.tfrShop = tfrShop;
36424
+ this.onSignInClick = onSignInClick;
36425
+ this.onSignOutClick = onSignOutClick;
36426
+ this._sku = '';
36427
+ this.redraw = null;
36428
+ this.init(sizeRecMainDivId);
36429
+ }
36430
+ get sku() {
36431
+ return this._sku;
36432
+ }
36433
+ setSku(sku) {
36434
+ this._sku = sku;
36435
+ }
36436
+ setIsLoggedIn(isLoggedIn) {
36437
+ if (isLoggedIn) {
36438
+ this.tfrSizeRecActionLogin.style.display = 'none';
36439
+ this.tfrSizeRecActionLogout.style.display = 'block';
36440
+ }
36441
+ else {
36442
+ this.tfrSizeRecActionLogin.style.display = 'block';
36443
+ this.tfrSizeRecActionLogout.style.display = 'none';
36444
+ }
36445
+ }
36446
+ setLoading(isLoading) {
36447
+ if (isLoading) {
36448
+ this.tfrSizeRecLoading.style.display = 'block';
36449
+ this.tfrSizeRecommendationsContainer.style.display = 'none';
36450
+ }
36451
+ else {
36452
+ this.tfrSizeRecLoading.style.display = 'none';
36453
+ this.tfrSizeRecommendationsContainer.style.display = 'flex';
36454
+ }
36455
+ }
36456
+ setGarmentLocations(locations) {
36457
+ this.renderGarmentLocations(locations);
36458
+ this.tfrSizeRecSelect.style.display = 'none';
36459
+ }
36460
+ setRecommendedSize({ recommended, sizes }) {
36461
+ this.renderSizeRec(recommended, sizes);
36462
+ this.tfrSizeRecSelect.style.display = 'flex';
36463
+ }
36464
+ setError(error) {
36465
+ this.tfrSizeRecommendationError.innerHTML = error;
36466
+ }
36467
+ init(sizeRecMainDivId) {
36468
+ const sizeRecMainDiv = document.getElementById(sizeRecMainDivId);
36469
+ if (!sizeRecMainDiv)
36470
+ throw new Error('Size rec main div not found');
36471
+ this.render(sizeRecMainDiv);
36472
+ this.setElements();
36473
+ this.bindEvents();
36474
+ }
36475
+ setElements() {
36476
+ this.tfrSizeRecActionLogin = document.getElementById('tfr-size-rec-action-login');
36477
+ this.tfrSizeRecActionLogout = document.getElementById('tfr-size-rec-action-logout');
36478
+ this.tfrSizeRecTable = document.getElementById('tfr-size-rec-table');
36479
+ this.tfrSizeRecommendationError = document.getElementById('tfr-size-recommendation-error');
36480
+ this.tfrSizeRecSize = document.getElementById('tfr-size-rec-size');
36481
+ this.tfrSizeRecSelect = document.getElementById('tfr-size-rec-select');
36482
+ this.tfrSizeRecLoading = document.getElementById('tfr-size-rec-loading');
36483
+ this.tfrSizeRecommendationsContainer = document.getElementById('tfr-size-recommendations-container');
36484
+ }
36485
+ bindEvents() {
36486
+ this.tfrSizeRecActionLogin.addEventListener('click', this.onSignInClick);
36487
+ this.tfrSizeRecActionLogout.addEventListener('click', this.onSignOutClick);
36488
+ this.tfrSizeRecSelect.addEventListener('click', this.onSizeRecSelectClick.bind(this));
36489
+ }
36490
+ onSizeRecSelectClick(e) {
36491
+ const target = e.target;
36492
+ if (!target.classList.contains('tfr-size-rec-select-button'))
36493
+ return;
36494
+ e.preventDefault();
36495
+ const selectedIndex = Number(target.getAttribute('data-index'));
36496
+ if (Number.isNaN(selectedIndex))
36497
+ return;
36498
+ const allButtons = document.querySelectorAll('.tfr-size-rec-select-button');
36499
+ allButtons.forEach((button) => button.classList.remove('active'));
36500
+ allButtons.item(selectedIndex).classList.add('active');
36501
+ this.redraw(selectedIndex);
36502
+ }
36503
+ renderSizeRec(recommended, sizes) {
36504
+ this.tfrSizeRecSize.innerHTML = `&nbsp;${recommended}`;
36505
+ const selectedSizeIndex = sizes.findIndex(({ size }) => size === recommended);
36506
+ this.redraw = (index) => this.renderSizeRecTable(sizes, index);
36507
+ this.redraw(selectedSizeIndex);
36508
+ this.renderSizeRecSelect(sizes, selectedSizeIndex);
36509
+ }
36510
+ renderSizeRecTable(sizes, index) {
36511
+ const { locations } = sizes[index];
36512
+ const html = locations
36513
+ .sort(({ location: a }, { location: b }) => (a < b ? -1 : 1))
36514
+ .map(({ location, fit }) => this.renderSizeRecTableRow(location, fit))
36515
+ .join('');
36516
+ this.tfrSizeRecTable.innerHTML = html;
36517
+ }
36518
+ renderSizeRecSelect(sizes, index) {
36519
+ const sizeNames = sizes.map(({ size }) => size);
36520
+ const html = sizeNames
36521
+ .map((name, i) => `<div class="tfr-size-rec-select-button ${i === index ? 'active' : ''}" data-index="${i}">${name}</div>`)
36522
+ .join('');
36523
+ this.tfrSizeRecSelect.innerHTML = html;
36524
+ }
36525
+ renderSizeRecTableRow(location, fit) {
36526
+ return `<div class="tfr-size-rec-table-row">
36527
+ <div class="tfr-size-rec-table-cell-left">${location}</div>
36528
+ <div class="tfr-size-rec-table-cell-right ${fit === 'Perfect Fit' ? 'perfect' : ''}">
36529
+ ${fit}
36530
+ </div>
36531
+ </div>`;
36532
+ }
36533
+ renderLoginCta() {
36534
+ return `<div class="tfr-size-rec-login-cta"><img src="${svgSrc}" /> Login to view</div>`;
36535
+ }
36536
+ renderGarmentLocations(locations) {
36537
+ const html = locations
36538
+ .sort()
36539
+ .map((location) => this.renderSizeRecTableRow(location, this.renderLoginCta()))
36540
+ .join('');
36541
+ this.tfrSizeRecTable.innerHTML = html;
36542
+ this.tfrSizeRecSize.innerHTML = this.renderLoginCta();
36543
+ }
36544
+ render(sizeRecMainDiv) {
36545
+ const body = `<div id="tfr-size-recommendations">
36546
+ <div id="tfr-size-rec-loading">
36547
+ <div class="lds-ellipsis">
36548
+ <div></div>
36549
+ <div></div>
36550
+ <div></div>
36551
+ <div></div>
36552
+ </div>
36553
+ </div>
36554
+ <div id="tfr-size-recommendations-container">
36555
+ <img id="tfr-size-rec-login-svg" src="{{ 'login-icon.svg' | asset_url }}" />
36556
+ <div id="tfr-size-rec-title">
36557
+ Recommend Size:
36558
+ <div id="tfr-size-rec-size">
36559
+ <div class="tfr-size-rec-login-cta">
36560
+ <img src="{{ 'login-icon.svg' | asset_url }}" /> Login to view
36561
+ </div>
36562
+ </div>
36563
+ </div>
36564
+
36565
+ <div id="tfr-size-rec-select"></div>
36566
+
36567
+ <div id="tfr-size-rec-subtitle">How it fits</div>
36568
+
36569
+ <div id="tfr-size-rec-table"></div>
36570
+
36571
+ <div id="tfr-size-rec-action">
36572
+ <div id="tfr-size-rec-action-login">Login to see your recommended size</div>
36573
+ <div id="tfr-size-rec-action-logout">Sign out of the Fitting Room</div>
36574
+ </div>
36575
+ </div>
36576
+ </div>`;
36577
+ sizeRecMainDiv.innerHTML = body;
36578
+ }
36579
+ }
36580
+
36581
+ class TfrSizeRec {
36582
+ constructor(sizeRecMainDivId, tfrShop, onSignInClick, onSignOutClick) {
36583
+ this.tfrShop = tfrShop;
36584
+ this.onSignInClick = onSignInClick;
36585
+ this.onSignOutClick = onSignOutClick;
36586
+ this.sizeRecComponent = new SizeRecComponent(sizeRecMainDivId, this.tfrShop, this.onSignInClick, this.onSignOutClick);
36587
+ }
36588
+ get sku() {
36589
+ return this.sizeRecComponent.sku;
36590
+ }
36591
+ setSku(sku) {
36592
+ this.sizeRecComponent.setSku(sku);
36593
+ }
36594
+ setIsLoggedIn(isLoggedIn) {
36595
+ this.sizeRecComponent.setIsLoggedIn(isLoggedIn);
36596
+ }
36597
+ async setGarmentLocations() {
36598
+ this.sizeRecComponent.setLoading(true);
36599
+ const locations = await this.getGarmentLocations();
36600
+ if (!locations)
36601
+ return;
36602
+ this.sizeRecComponent.setGarmentLocations(locations);
36603
+ this.sizeRecComponent.setLoading(false);
36604
+ }
36605
+ async setRecommendedSize() {
36606
+ this.sizeRecComponent.setLoading(true);
36607
+ const sizes = await this.getRecommenedSize();
36608
+ if (!sizes)
36609
+ return;
36610
+ this.sizeRecComponent.setRecommendedSize(sizes);
36611
+ this.sizeRecComponent.setLoading(false);
36612
+ }
36613
+ async getGarmentLocations() {
36614
+ try {
36615
+ const locations = await this.tfrShop.getMeasurementLocationsFromSku(this.sku);
36616
+ return locations;
36617
+ }
36618
+ catch (error) {
36619
+ this.sizeRecComponent.setError(error.message);
36620
+ return null;
36621
+ }
36622
+ }
36623
+ async getRecommenedSize() {
36624
+ try {
36625
+ const colorwaySizeAsset = await this.tfrShop.getColorwaySizeAssetFromSku(this.sku);
36626
+ const sizes = await this.getRecommendedSizes(String(colorwaySizeAsset.style_id));
36627
+ return sizes;
36628
+ }
36629
+ catch (error) {
36630
+ this.sizeRecComponent.setError(error.message);
36631
+ return null;
36632
+ }
36633
+ }
36634
+ async getRecommendedSizes(styleId) {
36635
+ const sizeRec = await this.tfrShop.getRecommendedSizes(styleId);
36636
+ if (!sizeRec)
36637
+ return null;
36638
+ return {
36639
+ recommended: sizeRec.recommended_size.size_value.size,
36640
+ sizes: sizeRec.fits.map((fit) => {
36641
+ return {
36642
+ size: sizeRec.available_sizes.find((size) => size.id === fit.size_id).size_value.size,
36643
+ locations: fit.measurement_location_fits.map((locationFit) => {
36644
+ return {
36645
+ fit: index.FitNames[locationFit.fit],
36646
+ location: index.MeasurementLocationName[locationFit.measurement_location],
36647
+ };
36648
+ }),
36649
+ };
36650
+ }),
36651
+ };
36652
+ }
36653
+ }
36654
+
36198
36655
  var AvatarState;
36199
36656
  (function (AvatarState) {
36200
36657
  AvatarState["NOT_CREATED"] = "NOT_CREATED";
@@ -36203,45 +36660,65 @@ var AvatarState;
36203
36660
  })(AvatarState || (AvatarState = {}));
36204
36661
 
36205
36662
  class FittingRoom {
36206
- constructor(shopId, modalDivId, hooks = {}, tryOnEnabled = false, _env) {
36663
+ constructor(shopId, modalDivId, sizeRecMainDivId, hooks = {}, _env) {
36207
36664
  this.shopId = shopId;
36208
36665
  this.hooks = hooks;
36209
- this.tryOnEnabled = tryOnEnabled;
36666
+ this.isLoggedIn = false;
36667
+ this.unsub = null;
36210
36668
  // prettier-ignore
36211
36669
  const env = _env
36212
36670
  ? _env
36213
36671
  : typeof process !== 'undefined'
36214
36672
  ? process.env.NODE_ENV
36215
36673
  : 'dev';
36216
- this.nav = new FittingRoomNav(modalDivId, this.signIn.bind(this), this.forgotPassword.bind(this), this.submitTel.bind(this));
36674
+ this.tfrModal = new TfrModal(modalDivId, this.signIn.bind(this), this.forgotPassword.bind(this), this.submitTel.bind(this));
36217
36675
  this.tfrShop = initShop(Number(this.shopId), env);
36218
- }
36219
- get sku() {
36220
- return this.nav.sku;
36676
+ this.tfrSizeRec = new TfrSizeRec(sizeRecMainDivId, this.tfrShop, this.onSignInClick.bind(this), this.signOut.bind(this));
36221
36677
  }
36222
36678
  get shop() {
36223
36679
  return this.tfrShop;
36224
36680
  }
36225
- async onInit() {
36226
- const loggedIn = await this.tfrShop.onInit();
36227
- if (loggedIn && this.hooks.onLogin)
36228
- this.hooks.onLogin();
36229
- if (!loggedIn && this.hooks.onLogout)
36230
- this.hooks.onLogout();
36231
- return loggedIn;
36681
+ get sku() {
36682
+ return this.tfrSizeRec.sku;
36232
36683
  }
36233
36684
  setSku(sku) {
36234
- this.nav.setSku(sku);
36685
+ this.tfrSizeRec.setSku(sku);
36686
+ if (this.isLoggedIn)
36687
+ this.tfrSizeRec.setRecommendedSize();
36688
+ else
36689
+ this.tfrSizeRec.setGarmentLocations();
36690
+ }
36691
+ async onInit() {
36692
+ var _a, _b;
36693
+ this.isLoggedIn = await this.tfrShop.onInit();
36694
+ this.tfrSizeRec.setIsLoggedIn(this.isLoggedIn);
36695
+ if (this.isLoggedIn) {
36696
+ if ((_a = this.hooks) === null || _a === void 0 ? void 0 : _a.onLogin)
36697
+ this.hooks.onLogin();
36698
+ this.subscribeToProfileChanges();
36699
+ }
36700
+ else {
36701
+ if ((_b = this.hooks) === null || _b === void 0 ? void 0 : _b.onLogout)
36702
+ this.hooks.onLogout();
36703
+ this.unsubscribeFromProfileChanges();
36704
+ }
36705
+ return this.isLoggedIn;
36235
36706
  }
36236
36707
  close() {
36237
- this.nav.close();
36708
+ this.tfrModal.close();
36238
36709
  }
36239
36710
  async signOut() {
36711
+ var _a;
36240
36712
  await this.tfrShop.user.logout();
36241
- if (this.hooks.onLogout)
36713
+ if ((_a = this.hooks) === null || _a === void 0 ? void 0 : _a.onLogout)
36242
36714
  this.hooks.onLogout();
36715
+ this.isLoggedIn = false;
36716
+ this.tfrSizeRec.setIsLoggedIn(false);
36717
+ this.tfrSizeRec.setGarmentLocations();
36718
+ this.unsubscribeFromProfileChanges();
36243
36719
  }
36244
36720
  async signIn(username, password, validationError) {
36721
+ var _a;
36245
36722
  if (username.length == 0 || password.length == 0)
36246
36723
  return validationError(L.UsernameOrPasswordEmpty);
36247
36724
  if (!validateEmail(username))
@@ -36250,36 +36727,17 @@ class FittingRoom {
36250
36727
  return validationError(L.PasswordError);
36251
36728
  try {
36252
36729
  await this.tfrShop.user.login(username, password);
36730
+ if ((_a = this.hooks) === null || _a === void 0 ? void 0 : _a.onLogin)
36731
+ this.hooks.onLogin();
36732
+ this.tfrModal.close();
36733
+ this.isLoggedIn = true;
36734
+ this.tfrSizeRec.setIsLoggedIn(true);
36735
+ this.tfrSizeRec.setRecommendedSize();
36736
+ this.subscribeToProfileChanges();
36253
36737
  }
36254
36738
  catch (e) {
36255
36739
  return validationError(L.UsernameOrPasswordIncorrect);
36256
36740
  }
36257
- if (this.hooks.onLogin)
36258
- this.hooks.onLogin();
36259
- this.nav.close();
36260
- try {
36261
- const userProfile = await this.tfrShop.user.getUserProfile();
36262
- switch (userProfile.avatar_status) {
36263
- case AvatarState.NOT_CREATED:
36264
- this.nav.onNotCreated();
36265
- break;
36266
- case AvatarState.PENDING:
36267
- if (this.hooks.onLoading)
36268
- this.hooks.onLoading();
36269
- break;
36270
- case AvatarState.CREATED:
36271
- console.debug('avatar_state: created');
36272
- if (this.tryOnEnabled)
36273
- this.tryOn();
36274
- break;
36275
- default:
36276
- this.nav.onError(L.SomethingWentWrong);
36277
- break;
36278
- }
36279
- }
36280
- catch (_a) {
36281
- this.nav.onError(L.SomethingWentWrong);
36282
- }
36283
36741
  }
36284
36742
  setBrandUserId(brandUserId) {
36285
36743
  this.tfrShop.user.setBrandUserId(brandUserId);
@@ -36287,68 +36745,67 @@ class FittingRoom {
36287
36745
  async submitTel(tel) {
36288
36746
  try {
36289
36747
  await this.tfrShop.submitTelephoneNumber(tel);
36290
- this.nav.toSignIn();
36748
+ this.tfrModal.toSignIn();
36291
36749
  }
36292
36750
  catch (_a) {
36293
- this.nav.onError(L.SomethingWentWrong);
36751
+ this.tfrModal.onError(L.SomethingWentWrong);
36294
36752
  }
36295
36753
  }
36296
36754
  async forgotPassword(email) {
36297
36755
  await this.tfrShop.user.sendPasswordResetEmail(email);
36298
- this.nav.toSignIn();
36756
+ this.tfrModal.toSignIn();
36299
36757
  }
36300
36758
  async passwordReset(code, newPassword) {
36301
36759
  await this.tfrShop.user.confirmPasswordReset(code, newPassword);
36302
- this.nav.toPasswordReset();
36760
+ this.tfrModal.toPasswordReset();
36303
36761
  }
36304
- async getRecommendedSizeString(styleId) {
36305
- const res = await this.tfrShop.getRecommendedSizesLabels(styleId);
36306
- const { recommendedSizeLabel, availableSizeLabels } = res;
36307
- return { recommendedSizeLabel, availableSizeLabels };
36762
+ async getMeasurementLocationsFromSku(sku) {
36763
+ return this.tfrShop.getMeasurementLocationsFromSku(sku);
36308
36764
  }
36309
36765
  onSignInClick() {
36310
- this.nav.toScan();
36766
+ this.tfrModal.toScan();
36311
36767
  }
36312
- async tryOn() {
36313
- if (!this.shop.isLoggedIn)
36314
- return this.nav.toScan();
36315
- if (!this.tryOnEnabled)
36316
- return;
36317
- try {
36318
- if (this.hooks.onLoading)
36319
- this.hooks.onLoading();
36320
- const frames = await this.tfrShop.tryOn(this.sku);
36321
- this.nav.close();
36322
- if (this.hooks.onVtoReady)
36323
- this.hooks.onVtoReady(frames);
36324
- }
36325
- catch (error) {
36326
- if (error instanceof errors.BrandUserIdNotSetError)
36327
- return this.nav.onError(L.BrandUserIdNotSet);
36328
- if (error instanceof errors.AvatarNotCreatedError)
36329
- return this.nav.onError(L.DontHaveAvatar);
36330
- if (error instanceof errors.RecommendedAvailableSizesError)
36331
- return this.nav.onSizeError(error.recommended_size, error.available_sizes);
36332
- if (error instanceof errors.UserNotLoggedInError) {
36333
- if (this.hooks.onLoadingComplete)
36768
+ onUserProfileChange(userProfile) {
36769
+ var _a, _b, _c, _d;
36770
+ switch (userProfile.avatar_status) {
36771
+ case AvatarState.NOT_CREATED:
36772
+ if ((_a = this.hooks) === null || _a === void 0 ? void 0 : _a.onError)
36773
+ this.hooks.onError(L.DontHaveAvatar);
36774
+ this.tfrModal.onNotCreated();
36775
+ break;
36776
+ case AvatarState.PENDING:
36777
+ if ((_b = this.hooks) === null || _b === void 0 ? void 0 : _b.onLoading)
36778
+ this.hooks.onLoading();
36779
+ break;
36780
+ case AvatarState.CREATED:
36781
+ if ((_c = this.hooks) === null || _c === void 0 ? void 0 : _c.onLoadingComplete)
36334
36782
  this.hooks.onLoadingComplete();
36335
- return this.nav.toScan();
36336
- }
36337
- console.error(error.message);
36338
- this.nav.onError(L.SomethingWentWrong);
36339
- }
36340
- finally {
36341
- if (this.hooks.onLoadingComplete)
36342
- this.hooks.onLoadingComplete();
36783
+ break;
36784
+ default:
36785
+ if ((_d = this.hooks) === null || _d === void 0 ? void 0 : _d.onError)
36786
+ this.hooks.onError(L.SomethingWentWrong);
36787
+ this.tfrModal.onError(L.SomethingWentWrong);
36788
+ break;
36343
36789
  }
36344
36790
  }
36791
+ subscribeToProfileChanges() {
36792
+ if (this.unsub)
36793
+ return;
36794
+ this.unsub = this.tfrShop.user.watchUserProfileForChanges((userProfile) => this.onUserProfileChange(userProfile));
36795
+ }
36796
+ unsubscribeFromProfileChanges() {
36797
+ if (!this.unsub)
36798
+ return;
36799
+ this.unsub();
36800
+ this.unsub = null;
36801
+ }
36345
36802
  }
36346
36803
 
36347
- const initFittingRoom = async (shopId, modalDivId, hooks, tryOnEnabled = false, env = 'dev') => {
36348
- const tfr = new FittingRoom(shopId, modalDivId, hooks, tryOnEnabled, env);
36804
+ const initFittingRoom = async (shopId, modalDivId, sizeRecMainDivId, hooks, env = 'dev') => {
36805
+ const tfr = new FittingRoom(shopId, modalDivId, sizeRecMainDivId, hooks, env);
36349
36806
  await tfr.onInit();
36350
36807
  return tfr;
36351
36808
  };
36352
36809
 
36353
- export { InitImageSlider, VTO_TIMEOUT_MS, initFittingRoom };
36810
+ export { InitImageSlider, initFittingRoom };
36354
36811
  //# sourceMappingURL=index.js.map