@thefittingroom/shop-ui 0.1.13 → 1.0.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.0.0 (2024-02-16T17:02:27.996Z)
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.0.3 (2024-02-16T14:55:02.187Z)
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;
@@ -22895,6 +22895,11 @@ class Firebase {
22895
22895
  const q = sl(Ta(this.firestore, collectionName), ...constraints);
22896
22896
  return Bl(q);
22897
22897
  }
22898
+ async getDoc(collectionName, id) {
22899
+ const docRef = Aa(this.firestore, collectionName, id);
22900
+ const docSnap = await Ol(docRef);
22901
+ return docSnap.exists() ? docSnap.data() : null;
22902
+ }
22898
22903
  }
22899
22904
 
22900
22905
  const getFirebaseError = (e) => {
@@ -22906,7 +22911,370 @@ const getFirebaseError = (e) => {
22906
22911
  }
22907
22912
  };
22908
22913
 
22909
- const asyncTry = (promise) => promise.then((data) => [null, data]).catch((error) => [error]);
22914
+ var MeasurementLocation;
22915
+ (function (MeasurementLocation) {
22916
+ MeasurementLocation["ACROSS_BACK"] = "across_back";
22917
+ MeasurementLocation["ACROSS_FRONT"] = "across_front";
22918
+ MeasurementLocation["ACROSS_SHOULDER"] = "across_shoulder";
22919
+ MeasurementLocation["ANKLE"] = "ankle";
22920
+ MeasurementLocation["ARMEYE"] = "arm_eye";
22921
+ MeasurementLocation["ARM_LENGTH_FROM_SHOULDER"] = "arm_length_from_shoulder";
22922
+ MeasurementLocation["BACK_CROTCH_LENGTH"] = "back_crotch_length";
22923
+ MeasurementLocation["BACK_NECK_TO_EBLOW"] = "back_neck_to_elbow";
22924
+ MeasurementLocation["BELOW_KNEE"] = "below_knee";
22925
+ MeasurementLocation["BICEP"] = "bicep";
22926
+ MeasurementLocation["BUST"] = "bust";
22927
+ MeasurementLocation["BUST_POINT_TO_BUST_POINT"] = "bust_point_to_bust_point";
22928
+ MeasurementLocation["CALF"] = "calf";
22929
+ MeasurementLocation["CB_NECK_TO_WAIST"] = "cb_neck_to_waist";
22930
+ MeasurementLocation["CB_NECK_TO_WRIST"] = "cb_neck_to_wrist";
22931
+ MeasurementLocation["CF_NECK_TO_WAIST"] = "cf_neck_to_waist";
22932
+ MeasurementLocation["ELBOW"] = "elbow";
22933
+ MeasurementLocation["FOREARM"] = "forearm";
22934
+ MeasurementLocation["FRONT_CROTCH_LENGTH"] = "front_crotch_length";
22935
+ MeasurementLocation["HIGH_HIP_PLACEMENT_FROM_WAIST"] = "high_hip_placement";
22936
+ MeasurementLocation["HIGH_HIP"] = "high_hip";
22937
+ MeasurementLocation["HSP_TO_ACROSS_BACK"] = "hsp_to_across_back";
22938
+ MeasurementLocation["HSP_TO_ACROSS_FRONT"] = "hsp_to_across_front";
22939
+ MeasurementLocation["HSP_TO_BUST_POINT"] = "hsp_to_bust_point";
22940
+ MeasurementLocation["HSP_TO_LOW_HIP_POSITION"] = "hsp_to_low_hip_position";
22941
+ MeasurementLocation["HSP_TO_WAIST_POSITION"] = "hsp_to_waist_position";
22942
+ MeasurementLocation["INSEAM"] = "inseam";
22943
+ MeasurementLocation["KNEE"] = "knee";
22944
+ MeasurementLocation["LOW_HIP"] = "low_hip";
22945
+ MeasurementLocation["LOW_HIP_PLACEMENT_FROM_WAIST"] = "low_hip_placement";
22946
+ MeasurementLocation["MID_NECK"] = "mid_neck";
22947
+ MeasurementLocation["NECK_AT_BASE"] = "neck_base";
22948
+ MeasurementLocation["SHOULDER_DROP"] = "shoulder_drop";
22949
+ MeasurementLocation["SHOULDER_TO_SHOULDER"] = "shoulder_to_shoulder";
22950
+ MeasurementLocation["SIDE_WAIST_TO_FLOOR"] = "side_waist_to_floor";
22951
+ MeasurementLocation["SIDE_WAIST_TO_KNEE"] = "side_waist_to_knee";
22952
+ MeasurementLocation["THIGH"] = "thigh";
22953
+ MeasurementLocation["TOTAL_RISE_LENGTH"] = "total_rise_length";
22954
+ MeasurementLocation["UNDER_BUST"] = "under_bust";
22955
+ MeasurementLocation["VERTICAL_TRUNK"] = "vertical_trunk";
22956
+ MeasurementLocation["WAIST"] = "waist";
22957
+ MeasurementLocation["WRIST"] = "wrist";
22958
+ })(MeasurementLocation || (MeasurementLocation = {}));
22959
+ const MeasurementLocationName = {
22960
+ [MeasurementLocation.ACROSS_BACK]: 'Across back',
22961
+ [MeasurementLocation.ACROSS_FRONT]: 'Across front',
22962
+ [MeasurementLocation.ACROSS_SHOULDER]: 'Across shoulder',
22963
+ [MeasurementLocation.ANKLE]: 'Ankle',
22964
+ [MeasurementLocation.ARMEYE]: 'Armeye',
22965
+ [MeasurementLocation.ARM_LENGTH_FROM_SHOULDER]: 'Arm length from shoulder',
22966
+ [MeasurementLocation.BACK_CROTCH_LENGTH]: 'Back crotch length',
22967
+ [MeasurementLocation.BACK_NECK_TO_EBLOW]: 'Back neck to eblow',
22968
+ [MeasurementLocation.BELOW_KNEE]: 'Below knee',
22969
+ [MeasurementLocation.BICEP]: 'Bicep',
22970
+ [MeasurementLocation.BUST]: 'Chest/Bust',
22971
+ [MeasurementLocation.BUST_POINT_TO_BUST_POINT]: 'Bust point to bust point',
22972
+ [MeasurementLocation.CALF]: 'Calf',
22973
+ [MeasurementLocation.CB_NECK_TO_WAIST]: 'Cb neck to waist',
22974
+ [MeasurementLocation.CB_NECK_TO_WRIST]: 'Cb neck to wrist',
22975
+ [MeasurementLocation.CF_NECK_TO_WAIST]: 'Cf neck to waist',
22976
+ [MeasurementLocation.ELBOW]: 'Elbow',
22977
+ [MeasurementLocation.FOREARM]: 'Forearm',
22978
+ [MeasurementLocation.FRONT_CROTCH_LENGTH]: 'Front crotch length',
22979
+ [MeasurementLocation.HIGH_HIP_PLACEMENT_FROM_WAIST]: 'High hip placement from waist',
22980
+ [MeasurementLocation.HIGH_HIP]: 'High hip',
22981
+ [MeasurementLocation.HSP_TO_ACROSS_BACK]: 'Hsp to across back',
22982
+ [MeasurementLocation.HSP_TO_ACROSS_FRONT]: 'Hsp to across front',
22983
+ [MeasurementLocation.HSP_TO_BUST_POINT]: 'Hsp to bust point',
22984
+ [MeasurementLocation.HSP_TO_LOW_HIP_POSITION]: 'Hsp to low hip position',
22985
+ [MeasurementLocation.HSP_TO_WAIST_POSITION]: 'Hsp to waist position',
22986
+ [MeasurementLocation.INSEAM]: 'Inseam',
22987
+ [MeasurementLocation.KNEE]: 'Knee',
22988
+ [MeasurementLocation.LOW_HIP]: 'Low hip',
22989
+ [MeasurementLocation.LOW_HIP_PLACEMENT_FROM_WAIST]: 'Low hip placement from waist',
22990
+ [MeasurementLocation.MID_NECK]: 'Mid neck',
22991
+ [MeasurementLocation.NECK_AT_BASE]: 'Neck at base',
22992
+ [MeasurementLocation.SHOULDER_DROP]: 'Shoulder drop',
22993
+ [MeasurementLocation.SHOULDER_TO_SHOULDER]: 'Shoulder to shoulder',
22994
+ [MeasurementLocation.SIDE_WAIST_TO_FLOOR]: 'Side waist to floor',
22995
+ [MeasurementLocation.SIDE_WAIST_TO_KNEE]: 'Side waist to knee',
22996
+ [MeasurementLocation.THIGH]: 'Thigh',
22997
+ [MeasurementLocation.TOTAL_RISE_LENGTH]: 'Total rise length',
22998
+ [MeasurementLocation.UNDER_BUST]: 'Under bust',
22999
+ [MeasurementLocation.VERTICAL_TRUNK]: 'Vertical trunk',
23000
+ [MeasurementLocation.WAIST]: 'Waist',
23001
+ [MeasurementLocation.WRIST]: 'Wrist',
23002
+ };
23003
+ var Classification;
23004
+ (function (Classification) {
23005
+ Classification["BLOUSES"] = "blouses";
23006
+ Classification["COATS"] = "coats";
23007
+ Classification["DRESSES"] = "dresses";
23008
+ Classification["JACKETS"] = "jackets";
23009
+ Classification["PANTS"] = "pants";
23010
+ Classification["PUFFERS_AND_PARKAS"] = "puffer_and_parkas";
23011
+ Classification["SHORTS"] = "shorts";
23012
+ Classification["SKIRTS"] = "skirts";
23013
+ Classification["SWEATERS"] = "sweaters";
23014
+ Classification["T_SHIRTS_AND_TANKS"] = "t_shirts_and_tanks";
23015
+ })(Classification || (Classification = {}));
23016
+ const ClassificationLocations = {
23017
+ [Classification.BLOUSES]: [
23018
+ MeasurementLocation.BUST,
23019
+ MeasurementLocation.ACROSS_SHOULDER,
23020
+ MeasurementLocation.WAIST,
23021
+ MeasurementLocation.LOW_HIP,
23022
+ MeasurementLocation.HIGH_HIP,
23023
+ ],
23024
+ // prettier-ignore
23025
+ [Classification.COATS]: [
23026
+ MeasurementLocation.BUST,
23027
+ MeasurementLocation.ACROSS_SHOULDER,
23028
+ MeasurementLocation.WAIST,
23029
+ MeasurementLocation.LOW_HIP,
23030
+ MeasurementLocation.HIGH_HIP
23031
+ ],
23032
+ [Classification.DRESSES]: [
23033
+ MeasurementLocation.LOW_HIP,
23034
+ MeasurementLocation.BUST,
23035
+ MeasurementLocation.ACROSS_SHOULDER,
23036
+ MeasurementLocation.WAIST,
23037
+ ],
23038
+ [Classification.JACKETS]: [
23039
+ MeasurementLocation.BUST,
23040
+ MeasurementLocation.ACROSS_SHOULDER,
23041
+ MeasurementLocation.WAIST,
23042
+ MeasurementLocation.LOW_HIP,
23043
+ MeasurementLocation.HIGH_HIP,
23044
+ ],
23045
+ [Classification.PANTS]: [
23046
+ MeasurementLocation.LOW_HIP,
23047
+ MeasurementLocation.WAIST,
23048
+ MeasurementLocation.THIGH,
23049
+ MeasurementLocation.INSEAM,
23050
+ ],
23051
+ [Classification.PUFFERS_AND_PARKAS]: [
23052
+ MeasurementLocation.BUST,
23053
+ MeasurementLocation.ACROSS_SHOULDER,
23054
+ MeasurementLocation.WAIST,
23055
+ MeasurementLocation.LOW_HIP,
23056
+ MeasurementLocation.HIGH_HIP,
23057
+ ],
23058
+ [Classification.SHORTS]: [
23059
+ MeasurementLocation.LOW_HIP,
23060
+ MeasurementLocation.WAIST,
23061
+ MeasurementLocation.THIGH,
23062
+ MeasurementLocation.INSEAM,
23063
+ ],
23064
+ // prettier-ignore
23065
+ [Classification.SKIRTS]: [
23066
+ MeasurementLocation.LOW_HIP,
23067
+ MeasurementLocation.WAIST
23068
+ ],
23069
+ // prettier-ignore
23070
+ [Classification.SWEATERS]: [
23071
+ MeasurementLocation.BUST,
23072
+ MeasurementLocation.ACROSS_SHOULDER,
23073
+ MeasurementLocation.WAIST,
23074
+ MeasurementLocation.LOW_HIP,
23075
+ MeasurementLocation.HIGH_HIP
23076
+ ],
23077
+ // prettier-ignore
23078
+ [Classification.T_SHIRTS_AND_TANKS]: [
23079
+ MeasurementLocation.BUST,
23080
+ MeasurementLocation.ACROSS_SHOULDER,
23081
+ MeasurementLocation.WAIST,
23082
+ MeasurementLocation.LOW_HIP,
23083
+ MeasurementLocation.HIGH_HIP
23084
+ ],
23085
+ };
23086
+ const CategoryNames = {
23087
+ ["activewear" /* Category.ACTIVEWEAR */]: 'Active Wear',
23088
+ ["dresses" /* Category.DRESSES */]: 'Dresses',
23089
+ ["jackets_and_coats" /* Category.JACKETS_AND_COATS */]: 'Jackets and Coats',
23090
+ ["jeans" /* Category.JEANS */]: 'Jeans',
23091
+ ["jumpsuits_and_rompers" /* Category.JUMPSUITS_AND_ROMPERS */]: 'Jumpsuits and Rompers',
23092
+ ["pants_and_shorts" /* Category.PANTS_AND_SHORTS */]: 'Pants and Shorts',
23093
+ ["skirts" /* Category.SKIRTS */]: 'Skirts',
23094
+ ["suits_and_tailoring" /* Category.SUITS_AND_TAILORING */]: 'Suits and Tailoring',
23095
+ ["sweaters" /* Category.SWEATERS */]: 'Sweaters',
23096
+ ["tops" /* Category.TOPS */]: 'Tops',
23097
+ };
23098
+ const Categories = [
23099
+ "activewear" /* Category.ACTIVEWEAR */,
23100
+ "dresses" /* Category.DRESSES */,
23101
+ "jackets_and_coats" /* Category.JACKETS_AND_COATS */,
23102
+ "jeans" /* Category.JEANS */,
23103
+ "jumpsuits_and_rompers" /* Category.JUMPSUITS_AND_ROMPERS */,
23104
+ "pants_and_shorts" /* Category.PANTS_AND_SHORTS */,
23105
+ "skirts" /* Category.SKIRTS */,
23106
+ "suits_and_tailoring" /* Category.SUITS_AND_TAILORING */,
23107
+ "sweaters" /* Category.SWEATERS */,
23108
+ "tops" /* Category.TOPS */,
23109
+ ];
23110
+ const SubcategoryNames = {
23111
+ ["a_line" /* Subcategory.A_LINE */]: 'A Line',
23112
+ ["a_line_flared" /* Subcategory.A_LINE_FLARED */]: 'A Line Flared',
23113
+ ["blazers" /* Subcategory.BLAZERS */]: 'Blazers',
23114
+ ["bodycon" /* Subcategory.BODYCON */]: 'Bodycon',
23115
+ ["bodysuits" /* Subcategory.BODYSUITS */]: 'Bodysuits',
23116
+ ["boiler_suits" /* Subcategory.BOILER_SUITS */]: 'Boiler Suits',
23117
+ ["bootcut" /* Subcategory.BOOTCUT */]: 'Bootcut',
23118
+ ["cardigans" /* Subcategory.CARDIGANS */]: 'Cardigans',
23119
+ ["cigarette" /* Subcategory.CIGARETTE */]: 'Cigarette',
23120
+ ["corsets_and_bustiers" /* Subcategory.CORSETS_AND_BUSTIERS */]: 'Corsets and Bustiers',
23121
+ ["crewnecks" /* Subcategory.CREWNECKS */]: 'Crewnecks',
23122
+ ["culottes" /* Subcategory.CULOTTES */]: 'Culottes',
23123
+ ["denim" /* Subcategory.DENIM */]: 'Denim',
23124
+ ["denim_jackets" /* Subcategory.DENIM_JACKETS */]: 'Denim Jackets',
23125
+ ["denim_shorts" /* Subcategory.DENIM_SHORTS */]: 'Denim Shorts',
23126
+ ["fit_and_flare" /* Subcategory.FIT_AND_FLARE */]: 'Fit and Flare',
23127
+ ["flared" /* Subcategory.FLARED */]: 'Flared',
23128
+ ["hoodies_and_zipups" /* Subcategory.HOODIES_AND_ZIPUPS */]: 'Hoodies and Zipups',
23129
+ ["joggers" /* Subcategory.JOGGERS */]: 'Joggers',
23130
+ ["jumpsuits" /* Subcategory.JUMPSUITS */]: 'Jumpsuits',
23131
+ ["knit" /* Subcategory.KNIT */]: 'Knit',
23132
+ ["leggings" /* Subcategory.LEGGINGS */]: 'Leggings',
23133
+ ["mom" /* Subcategory.MOM */]: 'Mom',
23134
+ ["overalls" /* Subcategory.OVERALLS */]: 'Overalls',
23135
+ ["parkas" /* Subcategory.PARKAS */]: 'Parkas',
23136
+ ["peacoats" /* Subcategory.PEACOATS */]: 'Peacoats',
23137
+ ["pencil" /* Subcategory.PENCIL */]: 'Pencil',
23138
+ ["pleated" /* Subcategory.PLEATED */]: 'Pleated',
23139
+ ["polos" /* Subcategory.POLOS */]: 'Polos',
23140
+ ["puffer_jackets" /* Subcategory.PUFFER_JACKETS */]: 'Puffer Jackets',
23141
+ ["raincoats" /* Subcategory.RAINCOATS */]: 'Raincoats',
23142
+ ["relaxed" /* Subcategory.RELAXED */]: 'Relaxed',
23143
+ ["rompers" /* Subcategory.ROMPERS */]: 'Rompers',
23144
+ ["shackets" /* Subcategory.SHACKETS */]: 'Shackets',
23145
+ ["shirt" /* Subcategory.SHIRT */]: 'Shirt',
23146
+ ["shirts_and_blouses" /* Subcategory.SHIRTS_AND_BLOUSES */]: 'Shirts and Blouses',
23147
+ ["skater" /* Subcategory.SKATER */]: 'Skater',
23148
+ ["skinny" /* Subcategory.SKINNY */]: 'Skinny',
23149
+ ["slim" /* Subcategory.SLIM */]: 'Slim',
23150
+ ["slip" /* Subcategory.SLIP */]: 'Slip',
23151
+ ["sports_bras" /* Subcategory.SPORTS_BRAS */]: 'Sports Bras',
23152
+ ["straight" /* Subcategory.STRAIGHT */]: 'Straight',
23153
+ ["suit_jackets" /* Subcategory.SUIT_JACKETS */]: 'Suit Jackets',
23154
+ ["suit_skirts" /* Subcategory.SUIT_SKIRTS */]: 'Suit Skirts',
23155
+ ["suit_trousers" /* Subcategory.SUIT_TROUSERS */]: 'Suit Trousers',
23156
+ ["suit_vests" /* Subcategory.SUIT_VESTS */]: 'Suit Vests',
23157
+ ["sweatshirts" /* Subcategory.SWEATSHIRTS */]: 'Sweatshirts',
23158
+ ["t_shirts" /* Subcategory.T_SHIRTS */]: 'T-Shirts',
23159
+ ["tank_tops_and_camisoles" /* Subcategory.TANK_TOPS_AND_CAMISOLES */]: 'Tank Tops and Camisoles',
23160
+ ["tapered" /* Subcategory.TAPERED */]: 'Tapered',
23161
+ ["trench_coats" /* Subcategory.TRENCH_COATS */]: 'Trench Coats',
23162
+ ["trousers" /* Subcategory.TROUSERS */]: 'Trousers',
23163
+ ["turtlenecks" /* Subcategory.TURTLENECKS */]: 'Turtleneck',
23164
+ ["unitards" /* Subcategory.UNITARDS */]: 'Unitards',
23165
+ ["v_necks" /* Subcategory.V_NECKS */]: 'V-Necks',
23166
+ ["wide_leg" /* Subcategory.WIDE_LEG */]: 'Wide Leg',
23167
+ ["wrap" /* Subcategory.WRAP */]: 'Wrap',
23168
+ };
23169
+ const Taxonomy = {
23170
+ ["activewear" /* Category.ACTIVEWEAR */]: {
23171
+ ["leggings" /* Subcategory.LEGGINGS */]: Classification.PANTS,
23172
+ ["joggers" /* Subcategory.JOGGERS */]: Classification.PANTS,
23173
+ ["sweatshirts" /* Subcategory.SWEATSHIRTS */]: Classification.SWEATERS,
23174
+ },
23175
+ ["dresses" /* Category.DRESSES */]: {
23176
+ ["a_line" /* Subcategory.A_LINE */]: Classification.DRESSES,
23177
+ ["bodycon" /* Subcategory.BODYCON */]: Classification.DRESSES,
23178
+ ["fit_and_flare" /* Subcategory.FIT_AND_FLARE */]: Classification.DRESSES,
23179
+ ["knit" /* Subcategory.KNIT */]: Classification.DRESSES,
23180
+ ["shirt" /* Subcategory.SHIRT */]: Classification.DRESSES,
23181
+ ["slip" /* Subcategory.SLIP */]: Classification.DRESSES,
23182
+ ["straight" /* Subcategory.STRAIGHT */]: Classification.DRESSES,
23183
+ ["wrap" /* Subcategory.WRAP */]: Classification.DRESSES,
23184
+ },
23185
+ ["jackets_and_coats" /* Category.JACKETS_AND_COATS */]: {
23186
+ ["denim_jackets" /* Subcategory.DENIM_JACKETS */]: Classification.JACKETS,
23187
+ ["parkas" /* Subcategory.PARKAS */]: Classification.PUFFERS_AND_PARKAS,
23188
+ ["peacoats" /* Subcategory.PEACOATS */]: Classification.COATS,
23189
+ ["puffer_jackets" /* Subcategory.PUFFER_JACKETS */]: Classification.PUFFERS_AND_PARKAS,
23190
+ ["raincoats" /* Subcategory.RAINCOATS */]: Classification.COATS,
23191
+ ["rompers" /* Subcategory.ROMPERS */]: Classification.COATS,
23192
+ ["shackets" /* Subcategory.SHACKETS */]: Classification.JACKETS,
23193
+ ["trench_coats" /* Subcategory.TRENCH_COATS */]: Classification.COATS,
23194
+ },
23195
+ ["jeans" /* Category.JEANS */]: {
23196
+ ["bootcut" /* Subcategory.BOOTCUT */]: Classification.PANTS,
23197
+ ["flared" /* Subcategory.FLARED */]: Classification.PANTS,
23198
+ ["mom" /* Subcategory.MOM */]: Classification.PANTS,
23199
+ ["relaxed" /* Subcategory.RELAXED */]: Classification.PANTS,
23200
+ ["skinny" /* Subcategory.SKINNY */]: Classification.PANTS,
23201
+ ["slim" /* Subcategory.SLIM */]: Classification.PANTS,
23202
+ ["straight" /* Subcategory.STRAIGHT */]: Classification.PANTS,
23203
+ ["tapered" /* Subcategory.TAPERED */]: Classification.PANTS,
23204
+ ["wide_leg" /* Subcategory.WIDE_LEG */]: Classification.PANTS,
23205
+ },
23206
+ ["jumpsuits_and_rompers" /* Category.JUMPSUITS_AND_ROMPERS */]: {
23207
+ ["boiler_suits" /* Subcategory.BOILER_SUITS */]: Classification.DRESSES,
23208
+ ["denim" /* Subcategory.DENIM */]: Classification.DRESSES,
23209
+ ["jumpsuits" /* Subcategory.JUMPSUITS */]: Classification.DRESSES,
23210
+ ["overalls" /* Subcategory.OVERALLS */]: Classification.DRESSES,
23211
+ ["rompers" /* Subcategory.ROMPERS */]: Classification.DRESSES,
23212
+ ["unitards" /* Subcategory.UNITARDS */]: Classification.DRESSES,
23213
+ },
23214
+ ["pants_and_shorts" /* Category.PANTS_AND_SHORTS */]: {
23215
+ ["cigarette" /* Subcategory.CIGARETTE */]: Classification.PANTS,
23216
+ ["culottes" /* Subcategory.CULOTTES */]: Classification.SHORTS,
23217
+ ["denim_shorts" /* Subcategory.DENIM_SHORTS */]: Classification.SHORTS,
23218
+ ["flared" /* Subcategory.FLARED */]: Classification.PANTS,
23219
+ ["joggers" /* Subcategory.JOGGERS */]: Classification.PANTS,
23220
+ ["leggings" /* Subcategory.LEGGINGS */]: Classification.PANTS,
23221
+ ["skinny" /* Subcategory.SKINNY */]: Classification.PANTS,
23222
+ ["wide_leg" /* Subcategory.WIDE_LEG */]: Classification.PANTS,
23223
+ },
23224
+ ["skirts" /* Category.SKIRTS */]: {
23225
+ ["a_line_flared" /* Subcategory.A_LINE_FLARED */]: Classification.SKIRTS,
23226
+ ["denim" /* Subcategory.DENIM */]: Classification.SKIRTS,
23227
+ ["knit" /* Subcategory.KNIT */]: Classification.SKIRTS,
23228
+ ["pencil" /* Subcategory.PENCIL */]: Classification.SKIRTS,
23229
+ ["pleated" /* Subcategory.PLEATED */]: Classification.SKIRTS,
23230
+ ["skater" /* Subcategory.SKATER */]: Classification.SKIRTS,
23231
+ ["slip" /* Subcategory.SLIP */]: Classification.SKIRTS,
23232
+ ["wrap" /* Subcategory.WRAP */]: Classification.SKIRTS,
23233
+ },
23234
+ ["suits_and_tailoring" /* Category.SUITS_AND_TAILORING */]: {
23235
+ ["blazers" /* Subcategory.BLAZERS */]: Classification.JACKETS,
23236
+ ["suit_jackets" /* Subcategory.SUIT_JACKETS */]: Classification.JACKETS,
23237
+ ["suit_skirts" /* Subcategory.SUIT_SKIRTS */]: Classification.SKIRTS,
23238
+ ["suit_trousers" /* Subcategory.SUIT_TROUSERS */]: Classification.PANTS,
23239
+ ["suit_vests" /* Subcategory.SUIT_VESTS */]: Classification.SWEATERS,
23240
+ ["trousers" /* Subcategory.TROUSERS */]: Classification.PANTS,
23241
+ },
23242
+ ["sweaters" /* Category.SWEATERS */]: {
23243
+ ["cardigans" /* Subcategory.CARDIGANS */]: Classification.SWEATERS,
23244
+ ["crewnecks" /* Subcategory.CREWNECKS */]: Classification.SWEATERS,
23245
+ ["hoodies_and_zipups" /* Subcategory.HOODIES_AND_ZIPUPS */]: Classification.SWEATERS,
23246
+ ["sweatshirts" /* Subcategory.SWEATSHIRTS */]: Classification.SWEATERS,
23247
+ ["turtlenecks" /* Subcategory.TURTLENECKS */]: Classification.SWEATERS,
23248
+ ["v_necks" /* Subcategory.V_NECKS */]: Classification.SWEATERS,
23249
+ },
23250
+ ["tops" /* Category.TOPS */]: {
23251
+ ["bodysuits" /* Subcategory.BODYSUITS */]: Classification.BLOUSES,
23252
+ ["corsets_and_bustiers" /* Subcategory.CORSETS_AND_BUSTIERS */]: Classification.BLOUSES,
23253
+ ["polos" /* Subcategory.POLOS */]: Classification.T_SHIRTS_AND_TANKS,
23254
+ ["shirts_and_blouses" /* Subcategory.SHIRTS_AND_BLOUSES */]: Classification.BLOUSES,
23255
+ ["t_shirts" /* Subcategory.T_SHIRTS */]: Classification.T_SHIRTS_AND_TANKS,
23256
+ ["tank_tops_and_camisoles" /* Subcategory.TANK_TOPS_AND_CAMISOLES */]: Classification.T_SHIRTS_AND_TANKS,
23257
+ },
23258
+ };
23259
+ var Fit;
23260
+ (function (Fit) {
23261
+ Fit["TOO_TIGHT"] = "too_tight";
23262
+ Fit["TIGHT"] = "tight";
23263
+ Fit["SLIGHTLY_TIGHT"] = "slightly_tight";
23264
+ Fit["PERFECT_FIT"] = "perfect_fit";
23265
+ Fit["SLIGHTLY_LOOSE"] = "slightly_loose";
23266
+ Fit["LOOSE"] = "loose";
23267
+ Fit["OVERSIZED"] = "oversized";
23268
+ })(Fit || (Fit = {}));
23269
+ const FitNames = {
23270
+ [Fit.TOO_TIGHT]: 'Too Tight',
23271
+ [Fit.TIGHT]: 'Tight',
23272
+ [Fit.SLIGHTLY_TIGHT]: 'Slightly Tight',
23273
+ [Fit.PERFECT_FIT]: 'Perfect Fit',
23274
+ [Fit.SLIGHTLY_LOOSE]: 'Slightly Loose',
23275
+ [Fit.LOOSE]: 'Loose',
23276
+ [Fit.OVERSIZED]: 'Oversized',
23277
+ };
22910
23278
 
22911
23279
  class Fetcher {
22912
23280
  static get endpoint() {
@@ -22956,22 +23324,10 @@ class Fetcher {
22956
23324
  }
22957
23325
  }
22958
23326
 
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
23327
  class TfrShop {
22969
23328
  constructor(brandId, firebase) {
22970
23329
  this.brandId = brandId;
22971
23330
  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
23331
  }
22976
23332
  get user() {
22977
23333
  return this.firebase.user;
@@ -22982,39 +23338,16 @@ class TfrShop {
22982
23338
  onInit() {
22983
23339
  return this.firebase.onInit();
22984
23340
  }
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
23341
  async getRecommendedSizes(styleId) {
23342
+ var _a, _b;
23012
23343
  if (!this.isLoggedIn)
23013
23344
  throw new UserNotLoggedInError();
23014
23345
  try {
23015
23346
  const res = await Fetcher.Get(this.user, `/styles/${styleId}/recommendation`);
23016
- const json = await res.json();
23017
- return json;
23347
+ const data = (await res.json());
23348
+ 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))
23349
+ return null;
23350
+ return data;
23018
23351
  }
23019
23352
  catch (error) {
23020
23353
  if ((error === null || error === void 0 ? void 0 : error.error) === AvatarNotCreated)
@@ -23022,85 +23355,26 @@ class TfrShop {
23022
23355
  throw error;
23023
23356
  }
23024
23357
  }
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
23358
  async submitTelephoneNumber(tel) {
23051
23359
  const sanitizedTel = tel.replace(/[^\+0-9]/g, '');
23052
23360
  const res = await Fetcher.Post(this.user, '/ios-app-link', { phone_number: sanitizedTel }, false);
23053
23361
  console.log(res);
23054
23362
  }
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
23363
  async getColorwaySizeAssetFromSku(colorwaySizeAssetSku) {
23099
23364
  const assets = await this.getColorwaySizeAssets(null, [colorwaySizeAssetSku]);
23100
23365
  if (!(assets === null || assets === void 0 ? void 0 : assets.size))
23101
23366
  throw new NoColorwaySizeAssetsFoundError();
23102
23367
  return Array.from(assets.values())[0];
23103
23368
  }
23369
+ async getMeasurementLocationsFromSku(sku) {
23370
+ var _a;
23371
+ const asset = await this.getColorwaySizeAssetFromSku(sku);
23372
+ const styleCategory = await this.getStyleCategory(asset.style_id);
23373
+ const classificationLocation = ((_a = Taxonomy[styleCategory.category]) === null || _a === void 0 ? void 0 : _a[styleCategory.sub_category]) || null;
23374
+ return classificationLocation
23375
+ ? ClassificationLocations[classificationLocation].map((location) => MeasurementLocationName[location])
23376
+ : null;
23377
+ }
23104
23378
  async getColorwaySizeAssets(styleId, skus) {
23105
23379
  const constraints = [rl('brand_id', '==', this.brandId)];
23106
23380
  if (styleId)
@@ -23120,29 +23394,16 @@ class TfrShop {
23120
23394
  return getFirebaseError(error);
23121
23395
  }
23122
23396
  }
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
- });
23397
+ async getStyleCategory(styleId) {
23398
+ try {
23399
+ const doc = await this.firebase.getDoc('style_categories', String(styleId));
23400
+ return doc;
23401
+ }
23402
+ catch (error) {
23403
+ return getFirebaseError(error);
23404
+ }
23131
23405
  }
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;
23406
+ }
23146
23407
  const initShop = (brandId, env = 'dev') => {
23147
23408
  if (env === 'dev' || env === 'development')
23148
23409
  console.warn('TfrShop is in development mode');
@@ -23157,51 +23418,20 @@ var AvatarState$1;
23157
23418
  AvatarState["PENDING"] = "PENDING";
23158
23419
  })(AvatarState$1 || (AvatarState$1 = {}));
23159
23420
 
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
- };
23421
+ var index = /*#__PURE__*/Object.freeze({
23422
+ __proto__: null,
23423
+ get AvatarState () { return AvatarState$1; },
23424
+ get MeasurementLocation () { return MeasurementLocation; },
23425
+ MeasurementLocationName: MeasurementLocationName,
23426
+ get Classification () { return Classification; },
23427
+ ClassificationLocations: ClassificationLocations,
23428
+ CategoryNames: CategoryNames,
23429
+ Categories: Categories,
23430
+ SubcategoryNames: SubcategoryNames,
23431
+ Taxonomy: Taxonomy,
23432
+ get Fit () { return Fit; },
23433
+ FitNames: FitNames
23434
+ });
23205
23435
 
23206
23436
  var L = {
23207
23437
  AssociatedEmail: 'If there is an account associated with that email, We have sent a link to reset your password.',
@@ -36203,10 +36433,9 @@ var AvatarState;
36203
36433
  })(AvatarState || (AvatarState = {}));
36204
36434
 
36205
36435
  class FittingRoom {
36206
- constructor(shopId, modalDivId, hooks = {}, tryOnEnabled = false, _env) {
36436
+ constructor(shopId, modalDivId, hooks = {}, _env) {
36207
36437
  this.shopId = shopId;
36208
36438
  this.hooks = hooks;
36209
- this.tryOnEnabled = tryOnEnabled;
36210
36439
  // prettier-ignore
36211
36440
  const env = _env
36212
36441
  ? _env
@@ -36269,8 +36498,6 @@ class FittingRoom {
36269
36498
  break;
36270
36499
  case AvatarState.CREATED:
36271
36500
  console.debug('avatar_state: created');
36272
- if (this.tryOnEnabled)
36273
- this.tryOn();
36274
36501
  break;
36275
36502
  default:
36276
36503
  this.nav.onError(L.SomethingWentWrong);
@@ -36301,54 +36528,38 @@ class FittingRoom {
36301
36528
  await this.tfrShop.user.confirmPasswordReset(code, newPassword);
36302
36529
  this.nav.toPasswordReset();
36303
36530
  }
36304
- async getRecommendedSizeString(styleId) {
36305
- const res = await this.tfrShop.getRecommendedSizesLabels(styleId);
36306
- const { recommendedSizeLabel, availableSizeLabels } = res;
36307
- return { recommendedSizeLabel, availableSizeLabels };
36531
+ async getMeasurementLocationsFromSku(sku) {
36532
+ return this.tfrShop.getMeasurementLocationsFromSku(sku);
36308
36533
  }
36309
36534
  onSignInClick() {
36310
36535
  this.nav.toScan();
36311
36536
  }
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)
36334
- 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();
36343
- }
36537
+ async getRecommendedSizes(styleId) {
36538
+ const sizeRec = await this.tfrShop.getRecommendedSizes(styleId);
36539
+ if (!sizeRec)
36540
+ return null;
36541
+ return {
36542
+ recommended: sizeRec.recommended_size.size_value.size,
36543
+ sizes: sizeRec.fits.map((fit) => {
36544
+ return {
36545
+ size: sizeRec.available_sizes.find((size) => size.id === fit.size_id).size_value.size,
36546
+ locations: fit.measurement_location_fits.map((locationFit) => {
36547
+ return {
36548
+ fit: index.FitNames[locationFit.fit],
36549
+ location: index.MeasurementLocationName[locationFit.measurement_location],
36550
+ };
36551
+ }),
36552
+ };
36553
+ }),
36554
+ };
36344
36555
  }
36345
36556
  }
36346
36557
 
36347
- const initFittingRoom = async (shopId, modalDivId, hooks, tryOnEnabled = false, env = 'dev') => {
36348
- const tfr = new FittingRoom(shopId, modalDivId, hooks, tryOnEnabled, env);
36558
+ const initFittingRoom = async (shopId, modalDivId, hooks, env = 'dev') => {
36559
+ const tfr = new FittingRoom(shopId, modalDivId, hooks, env);
36349
36560
  await tfr.onInit();
36350
36561
  return tfr;
36351
36562
  };
36352
36563
 
36353
- export { InitImageSlider, VTO_TIMEOUT_MS, initFittingRoom };
36564
+ export { InitImageSlider, initFittingRoom };
36354
36565
  //# sourceMappingURL=index.js.map