· 5 years ago · Aug 15, 2020, 04:06 PM
1"use strict";
2var app = angular.module("app", ["ionic", "ionic-native-transitions", "ngAnimate", "ngCordova", "pascalprecht.translate", "templates"]);
3app.config([
4 "$provide",
5 "$compileProvider",
6 "$httpProvider",
7 "$ionicConfigProvider",
8 "$ionicNativeTransitionsProvider",
9 "$stateProvider",
10 "$translateProvider",
11 function ($provide, $compileProvider, $httpProvider, $ionicConfigProvider, $ionicNativeTransitionsProvider, $stateProvider, $translateProvider) {
12 $provide.decorator("$exceptionHandler", [
13 "$delegate",
14 function ($delegate) {
15 return function (exception, cause) {
16 $delegate(exception, cause), Raven.captureException(exception);
17 };
18 },
19 ]),
20 $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|mailto|copdate):/),
21 $httpProvider.interceptors.push("httpApiInterceptor"),
22 $ionicConfigProvider.scrolling.jsScrolling(!1),
23 $ionicConfigProvider.views.swipeBackEnabled(!1),
24 $ionicNativeTransitionsProvider.setDefaultTransition({ type: "slide", direction: "left" }),
25 $ionicNativeTransitionsProvider.setDefaultBackTransition({ type: "slide", direction: "right" }),
26 $stateProvider
27 .state("splash", { url: "/splash", templateUrl: "templates/views/splash.html", controller: "SplashController", cache: !1 })
28 .state("onboarding", { url: "/onboarding", templateUrl: "templates/views/onboarding.html", controller: "OnboardingController", cache: !1 })
29 .state("signUp", { url: "/sign-up", templateUrl: "templates/views/sign-up.html", controller: "SignUpController", cache: !1 })
30 .state("signIn", { url: "/sign-in", templateUrl: "templates/views/sign-in.html", controller: "SignInController", cache: !1 })
31 .state("forgotPassword", { url: "/forgot-password", templateUrl: "templates/views/forgot-password.html", controller: "ForgotPasswordController", cache: !1 })
32 .state("latestEvents", { url: "/latest-events", templateUrl: "templates/views/latest-events.html", controller: "LatestEventsController", cache: !1 })
33 .state("upcomingEvents", { url: "/upcoming-events", templateUrl: "templates/views/upcoming-events.html", controller: "UpcomingEventsController", cache: !1 })
34 .state("event", { url: "/event/:id", templateUrl: "templates/views/event.html", controller: "EventController", params: { id: { value: null, squash: !0 } }, cache: !1 })
35 .state("eventRules", { url: "/event-rules/:id", templateUrl: "templates/views/event-rules.html", controller: "EventRulesController", params: { id: { value: null, squash: !0 } }, cache: !1 })
36 .state("eventEnteringConfirmed", {
37 url: "/event-entering-confirmed/:id",
38 templateUrl: "templates/views/event-entering-confirmed.html",
39 controller: "EventEnteringConfirmedController",
40 params: { id: { value: null, squash: !0 } },
41 cache: !1,
42 })
43 .state("eventReservation", { url: "/event-reservation/:id", templateUrl: "templates/views/event-reservation.html", controller: "EventReservationController", params: { id: { value: null, squash: !0 } }, cache: !1 })
44 .state("eventReservationConfirmed", {
45 url: "/event-reservation-confirmed/:id",
46 templateUrl: "templates/views/event-reservation-confirmed.html",
47 controller: "EventReservationConfirmedController",
48 params: { id: { value: null, squash: !0 } },
49 cache: !1,
50 })
51 .state("eventReservationCancelled", {
52 url: "/event-reservation-cancelled/:id",
53 templateUrl: "templates/views/event-reservation-cancelled.html",
54 controller: "EventReservationCancelledController",
55 params: { id: { value: null, squash: !0 } },
56 cache: !1,
57 })
58 .state("eventReservationTimedOut", {
59 url: "/event-reservation-timed-out/:id",
60 templateUrl: "templates/views/event-reservation-timed-out.html",
61 controller: "EventReservationTimedOutController",
62 params: { id: { value: null, squash: !0 } },
63 cache: !1,
64 })
65 .state("eventWaitingList", { url: "/event-waiting-list/:id", templateUrl: "templates/views/event-waiting-list.html", controller: "EventWaitingListController", params: { id: { value: null, squash: !0 } }, cache: !1 })
66 .state("coppedEvents", { url: "/copped-events", templateUrl: "templates/views/copped-events.html", controller: "CoppedEventsController", cache: !1 })
67 .state("coppedEventsTicket", { url: "/copped-events/:id", templateUrl: "templates/views/copped-events-ticket.html", controller: "CoppedEventsTicketController", params: { id: { value: null, squash: !0 } }, cache: !1 })
68 .state("listedEvents", { url: "/listed-events", templateUrl: "templates/views/listed-events.html", controller: "ListedEventsController", cache: !1 })
69 .state("messages", { url: "/messages", templateUrl: "templates/views/messages.html", controller: "MessagesController", cache: !1 })
70 .state("message", { url: "/message/:id", templateUrl: "templates/views/message.html", controller: "MessageController", params: { id: { value: null, squash: !0 } }, cache: !1 })
71 .state("account", { url: "/account", templateUrl: "templates/views/account.html", controller: "AccountController", cache: !1 })
72 .state("editProfile", { url: "/edit-profile", templateUrl: "templates/views/edit-profile.html", controller: "EditProfileController", cache: !1 })
73 .state("changePassword", { url: "/change-password", templateUrl: "templates/views/change-password.html", controller: "ChangePasswordController", cache: !1 })
74 .state("accountHistory", { url: "/account-history", templateUrl: "templates/views/account-history.html", controller: "AccountHistoryController", cache: !1 })
75 .state("insiders", { url: "/insiders", templateUrl: "templates/views/insiders.html", controller: "InsidersController" })
76 .state("settings", { url: "/settings", templateUrl: "templates/views/settings.html", controller: "SettingsController" })
77 .state("becomePartner", { url: "/become-partner", templateUrl: "templates/views/become-partner.html", controller: "BecomePartnerController" })
78 .state("faq", { url: "/faq", templateUrl: "templates/views/faq.html", controller: "FaqController" })
79 .state("termsOfUse", { url: "/terms-of-use", templateUrl: "templates/views/terms-of-use.html", controller: "TermsOfUseController" })
80 .state("privacyPolicy", { url: "/privacy-policy", templateUrl: "templates/views/privacy-policy.html", controller: "PrivacyPolicyController" })
81 .state("selectStores", { url: "/select-stores", templateUrl: "templates/views/select-stores.html", controller: "SelectStoresController", cache: !1 })
82 .state("selectFootwearSize", { url: "/select-footwear-size", templateUrl: "templates/views/select-footwear-size.html", controller: "SelectFootwearSizeController", cache: !1 })
83 .state("selectApparelSize", { url: "/select-apparel-size", templateUrl: "templates/views/select-apparel-size.html", controller: "SelectApparelSizeController", cache: !1 })
84 .state("selectSizes", { url: "/select-sizes/:id", templateUrl: "templates/views/select-sizes.html", controller: "SelectSizesController", params: { id: { value: null, squash: !0 } }, cache: !1 })
85 .state("enableNotifications", { url: "/enable-notifications", templateUrl: "templates/views/enable-notifications.html", controller: "EnableNotificationsController" })
86 .state("shareLocation", { url: "/share-location", templateUrl: "templates/views/share-location.html", controller: "ShareLocationController" })
87 .state("paymentMethod", { url: "/payment-method/:id", templateUrl: "templates/views/payment-method.html", controller: "PaymentMethodController", params: { id: { value: null, squash: !0 } }, cache: !1 }),
88 $translateProvider.useStaticFilesLoader({ prefix: "assets/locales/", suffix: ".json" }),
89 $translateProvider.addInterpolation("$translateMessageFormatInterpolation"),
90 $translateProvider.useSanitizeValueStrategy("sanitize"),
91 $translateProvider.preferredLanguage("en_US");
92 },
93]),
94 app.run([
95 "$window",
96 "$rootScope",
97 "$state",
98 "$location",
99 "$timeout",
100 "$translate",
101 "$ionicPlatform",
102 "$ionicNativeTransitions",
103 "$ionicHistory",
104 "$cordovaSplashscreen",
105 "Config",
106 "Storage",
107 "User",
108 "UserService",
109 "Utils",
110 "Operator",
111 "Diagnostic",
112 "GA",
113 "Codepush",
114 function ($window, $rootScope, $state, $location, $timeout, $translate, $ionicPlatform, $ionicNativeTransitions, $ionicHistory, $cordovaSplashscreen, Config, Storage, User, UserService, Utils, Operator, Diagnostic, GA, Codepush) {
115 var ravenOptions = {
116 release: "3.3.3",
117 environment: "production",
118 debug: !1,
119 ignoreErrors: [
120 "callback.success.apply is not a function",
121 "Cannot read property 'call' of undefined",
122 "callback.success.apply is not a function. (In 'callback.success.apply(null, args)', 'callback.success.apply' is undefined)",
123 "[$rootScope:inprog] $digest already in progress",
124 "[$rootScope:inprog] $digest already in progress http://errors.angularjs.org/1.5.3/$rootScope/inprog?p0=%24digest",
125 ],
126 ignoreUrls: [],
127 };
128 Raven.config("https://8ce44f92cdff432ab356cad9d4ef7154@sentry.io/1396674", ravenOptions).install(),
129 Raven.context(function () {
130 $ionicPlatform.ready(function () {
131 Diagnostic.isNotificationsEnabled(function (enabled) {
132 enabled && (User.enableNotifications(!0), Operator.send("oneSignal.init"));
133 }),
134 Diagnostic.isLocationAuthorized(function (authorized) {
135 authorized && User.shareLocation(!0);
136 });
137 var deviceDensity,
138 device = ionic.Platform.device();
139 if (
140 (("Android" !== device.platform && "iOS" !== device.platform) || hockeyapp.start(null, null, Config.hockeyApp[device.platform].appId),
141 $window.Keyboard && $window.Keyboard.hideFormAccessoryBar(!1),
142 $translate.use("en_US"),
143 Storage.set("deviceOs", device.platform),
144 Storage.set("deviceUuid", device.uuid),
145 Storage.set("deviceWidth", $window.screen.width),
146 Storage.set("deviceHeight", $window.screen.height),
147 "Android" === device.platform)
148 )
149 switch (($ionicNativeTransitions.enable(!1), $window.devicePixelRatio)) {
150 case 2:
151 deviceDensity = "@xdpi";
152 break;
153 case 3:
154 deviceDensity = "@xxdpi";
155 break;
156 case 4:
157 deviceDensity = "@xxxdpi";
158 break;
159 default:
160 deviceDensity = "@hdpi";
161 }
162 else deviceDensity = "@3x";
163 Storage.set("deviceDensity", deviceDensity),
164 $window.ga &&
165 "" !== Config.googleAnalytics.trackingId &&
166 $window.ga.startTrackerWithId(
167 Config.googleAnalytics.trackingId,
168 Config.googleAnalytics.dispatchPeriod,
169 function (response) {
170 $window.ga.setAllowIDFACollection(!1),
171 $window.ga.enableUncaughtExceptionReporting(
172 !1,
173 function (response) {},
174 function (response) {}
175 );
176 },
177 function (response) {}
178 ),
179 localforage.config({ driver: [localforage.WEBSQL, localforage.INDEXEDDB, localforage.LOCALSTORAGE], name: "copdateDB", storeName: "copdateStore" }),
180 $ionicPlatform.on("pause", function () {
181 User.stopNotificationsUpdateInterval(), Operator.send($state.current.name + ".pause");
182 }),
183 $ionicPlatform.on("resume", function () {
184 Codepush.sync(function () {
185 Codepush.getCurrentPackage(function (metadata) {
186 metadata.isFirstRun && Storage.set("codePushRelease", metadata.label, !0);
187 });
188 });
189 var schemeUrl = window.localStorage.getItem("schemeUrl") || null;
190 if (schemeUrl) {
191 var redirect,
192 split = schemeUrl.split("/"),
193 schemeUrlState = null;
194 switch (split[0]) {
195 case "events":
196 split[1] && (schemeUrlState = { stateName: "event", stateParams: { id: split[1] } });
197 }
198 switch ((schemeUrlState && Storage.set("schemeRedirection", schemeUrlState), User.isConnected)) {
199 case !0:
200 Storage.get("schemeRedirection") && (redirect = angular.copy(Storage.get("schemeRedirection"))), Storage.unset("schemeRedirection");
201 break;
202 case !1:
203 (redirect = Config.redirects.login), Operator.send("notification.show", { type: "error", message: { translate: "notification.error.invalidAccessToken", translateValues: {} } });
204 }
205 Utils.switchState(redirect.stateName, "fade", redirect.stateParams);
206 }
207 User.startNotificationsUpdateInterval(), Operator.send($state.current.name + ".resume");
208 }),
209 Operator.send("secureStorage.uuid", {
210 uuid: device.uuid,
211 callback: function () {
212 User.init(function () {
213 Codepush.sync(function () {
214 Codepush.getCurrentPackage(function (metadata) {
215 metadata.isFirstRun && Storage.set("codePushRelease", metadata.label, !0);
216 });
217 }),
218 Storage.set("isAppReady", !0),
219 User.startNotificationsUpdateInterval(),
220 Utils.switchState("splash", "no-transition");
221 });
222 },
223 });
224 });
225 }),
226 $rootScope.$on("$stateChangeStart", function (e, toState, toParams, fromState, fromParams) {
227 Storage.get("isAppReady") || e.preventDefault();
228 }),
229 $rootScope.$on("$stateChangeSuccess", function (e, toState, toParams, fromState, fromParams) {
230 GA.trackView($location.url());
231 }),
232 $rootScope.$on("secureStorage.uuid", function (e, data) {
233 var timeout = $timeout(function () {
234 if ("iOS" === Storage.get("deviceOs")) {
235 if (window.cordova)
236 var ss = new cordova.plugins.SecureStorage(
237 function () {
238 ss.get(
239 function (value) {
240 Storage.set("deviceUuid", value), "function" == typeof data.callback && data.callback();
241 },
242 function (error) {
243 ss.set(
244 function (key) {},
245 function (error) {},
246 "uuid",
247 data.uuid
248 ),
249 "function" == typeof data.callback && data.callback();
250 },
251 "uuid"
252 );
253 },
254 function (error) {},
255 "undefined"
256 );
257 $timeout.cancel(timeout);
258 } else "function" == typeof data.callback && data.callback();
259 });
260 }),
261 $rootScope.$on("splashscreen.hide", function () {
262 $window.cordova && $cordovaSplashscreen.hide();
263 }),
264 $rootScope.$on("statusbar.update", function (e, data) {
265 var timeout;
266 (data = data || {}),
267 $window.StatusBar &&
268 ("iOS" === Storage.get("deviceOs")
269 ? (timeout = $timeout(function () {
270 switch (data.theme) {
271 case "black":
272 StatusBar.styleBlackOpaque();
273 break;
274 default:
275 StatusBar.styleDefault();
276 }
277 $timeout.cancel(timeout);
278 }, Config.transitions.defaultDuration - 100))
279 : StatusBar.styleBlackOpaque());
280 }),
281 $rootScope.$on("osSettings.open", function (e, data) {
282 $window.cordova &&
283 $window.cordova.plugins.settings &&
284 $window.cordova.plugins.settings.open(
285 data.setting,
286 function () {},
287 function () {}
288 );
289 }),
290 $rootScope.$on("dialog", function (e, data) {
291 switch (data.type) {
292 case "confirm":
293 $window.cordova
294 ? navigator.notification.confirm(
295 data.text,
296 function (index) {
297 "function" == typeof data.callback && data.callback(index);
298 },
299 data.title,
300 data.action
301 )
302 : $window.confirm(data.text) && "function" == typeof data.callback && data.callback(2);
303 break;
304 case "prompt":
305 $window.cordova &&
306 navigator.notification.prompt(
307 data.text,
308 function (index) {
309 "function" == typeof data.callback && data.callback(index);
310 },
311 data.title,
312 data.action,
313 data.placeholder
314 );
315 break;
316 default:
317 $window.cordova &&
318 navigator.notification.alert(
319 data.text,
320 function () {
321 "function" == typeof data.callback && data.callback();
322 },
323 data.title,
324 data.action
325 );
326 }
327 }),
328 $rootScope.$on("network.none", function () {
329 Operator.send("dialog", { type: "alert", title: $translate.instant("dialog.connectionLost.title"), text: $translate.instant("dialog.connectionLost.text"), action: $translate.instant("dialog.connectionLost.action") });
330 }),
331 $rootScope.$on("api.timeout", function (e, data) {
332 Operator.send("dialog", {
333 type: "confirm",
334 title: $translate.instant("dialog.apiTimeout.title"),
335 text: $translate.instant("dialog.apiTimeout.text"),
336 action: [$translate.instant("dialog.apiTimeout.action.confirm")],
337 callback: function (index) {
338 2 === index && "function" == typeof data.callback && data.callback();
339 },
340 });
341 }),
342 $rootScope.$on("app.signOut", function (e, data) {
343 (data = data || {}),
344 UserService.signOut().then(function (response) {
345 var redirect = Config.redirects.onboarding;
346 User.disconnect(),
347 $ionicHistory.nextViewOptions({ historyRoot: !0, disableBack: !0 }),
348 data.forced && ((redirect = Config.redirects.login), Operator.send("notification.show", { type: "error", message: { translate: "notification.error.invalidAccessToken", translateValues: {} } })),
349 Utils.switchState(redirect.stateName, "fade", redirect.stateParams);
350 });
351 }),
352 $rootScope.$on("app.update", function () {
353 Operator.send("dialog", {
354 type: "alert",
355 title: $translate.instant("dialog.updateApp.title"),
356 text: $translate.instant("dialog.updateApp.text"),
357 action: $translate.instant("dialog.updateApp.action"),
358 callback: function () {
359 var external = "iOS" === Storage.get("deviceOs") ? Config.external.appStore : Config.external.googlePlay,
360 scheme = external.scheme[Storage.get("deviceOs")];
361 scheme
362 ? appAvailability.check(
363 scheme,
364 function () {
365 cordova.InAppBrowser.open(external.url.app, "_system");
366 },
367 function () {
368 cordova.InAppBrowser.open(external.url.browser, "_system");
369 }
370 )
371 : cordova.InAppBrowser.open(external.url.browser, "_system");
372 },
373 });
374 }),
375 $rootScope.$on("app.backdoor", function (e, data) {
376 Operator.send("dialog", { type: "alert", title: $translate.instant("dialog.backdoor.title"), text: data.message || $translate.instant("dialog.backdoor.text"), action: $translate.instant("dialog.backdoor.action") });
377 }),
378 $rootScope.$on("app.exit", function (e, data) {
379 Operator.send("dialog", {
380 type: "confirm",
381 title: $translate.instant("dialog.exitApp.title"),
382 text: $translate.instant("dialog.exitApp.text"),
383 action: [$translate.instant("dialog.exitApp.action.confirm")],
384 callback: function (index) {
385 2 === index && "function" == typeof data.callback && data.callback();
386 },
387 });
388 }),
389 $rootScope.$on("oneSignal.init", function (e, data) {
390 (data = data || {}),
391 $window.plugins &&
392 $window.plugins.OneSignal &&
393 ($window.plugins.OneSignal.startInit(Config.oneSignal.appId, Config.oneSignal.googleProjectNumber),
394 $window.plugins.OneSignal.addPermissionObserver(function (state) {
395 $window.plugins.OneSignal.getPermissionSubscriptionState(function (status) {
396 switch (Storage.get("deviceOs")) {
397 case "Android":
398 1 === status.permissionStatus.state ? User.enableNotifications(!0) : User.enableNotifications(!1), "function" == typeof data.callback && data.callback();
399 break;
400 case "iOS":
401 0 < status.permissionStatus.status && (2 === status.permissionStatus.status ? User.enableNotifications(!0) : User.enableNotifications(!1), "function" == typeof data.callback && data.callback());
402 }
403 });
404 }),
405 $window.plugins.OneSignal.handleNotificationOpened(function (response) {
406 var redirect;
407 response.notification.payload.additionalData.event_id
408 ? (redirect = { stateName: "event", stateParams: { id: response.notification.payload.additionalData.event_id } })
409 : response.notification.payload.additionalData.message_id && (redirect = { stateName: "message", stateParams: { id: response.notification.payload.additionalData.message_id } }),
410 redirect && (User.isConnected ? Utils.switchState(redirect.stateName, "no-transition", redirect.stateParams) : Storage.set("oneSignalRedirection", redirect));
411 }),
412 $window.plugins.OneSignal.inFocusDisplaying($window.plugins.OneSignal.OSInFocusDisplayOption.Notification),
413 $window.plugins.OneSignal.endInit(),
414 $window.plugins.OneSignal.getIds(function (ids) {
415 Storage.set("oneSignalUserId", ids.userId);
416 }));
417 }),
418 $rootScope.$on("oneSignal.validateTags", function () {
419 $window.plugins &&
420 $window.plugins.OneSignal &&
421 User.isNotificationsEnabled &&
422 $window.plugins.OneSignal.getTags(function (tags) {
423 (tags.copdate_id = parseInt(tags.copdate_id) || 0), tags.copdate_id !== User.profile.id && $window.plugins.OneSignal.sendTag("copdate_id", User.profile.id);
424 });
425 });
426 },
427 ]),
428 angular.module("app").constant("Config", {
429 app: { version: "3.3.3" },
430 timeoutDelay: { invalidEvent: 1e3, invalidMessage: 1e3, geofenceDetection: 2e3, geofenceFirstTimeDetection: 5e3, beaconDetection: 2e3, splashFallback: 5e3 },
431 intervalDelay: { copStatus: 15 },
432 default: { phoneCountryCode: "us", dateFormat: "MMMM Do YYYY", dateTimeFormat: "MMM Do YYYY, h:mm A", notificationsUpdateInterval: 3e4, invalidEventBackDelay: 1e3, appLogoutCodes: [102], dismissNotificationDelay: 3e3 },
433 copdate: {
434 apiUrl: "https://admin.copdate.com/application/services",
435 apiSecret: "N5NURTumYMKKi4gNoRSUjcvrr6GrCt",
436 apiTimeoutDelay: 1e4,
437 email: "partners@copdate.com",
438 websiteUrl: "https://copdate.com/",
439 faqUrl: "https://admin.app.copdate.com/privacy/faq.html",
440 termsUrl: "https://admin.app.copdate.com/privacy/terms.html",
441 privacyUrl: "https://admin.app.copdate.com/privacy/privacy.html",
442 },
443 hockeyApp: { Android: { appId: "e0720daac6234179912d746a0f54c29c" }, iOS: { appId: "37df20253d6449709f123c11fcbc2e22" } },
444 oneSignal: { appId: "eb8f53e2-05b4-4a72-b319-52822dc2d432", googleProjectNumber: "113954202281" },
445 googleAnalytics: { trackingId: "UA-80829761-3", dispatchPeriod: 10 },
446 stripe: { appUrl: "https://api.stripe.com/v1" },
447 validatorPatterns: {
448 email: /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/,
449 password: /^(?=.*[0-9])[0-9a-zA-Z]{6,}$/,
450 cardNumber: /^\d{13,16}$/,
451 visa: /^4/,
452 mastercard: /^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[01]|2720)/,
453 amex: /^3[47]/,
454 cardSecurityCode: /^\d{3,4}$/,
455 },
456 parserPatterns: { cardNumber: /[^0-9]+/g, cardSecurityCode: /[^0-9]+/g },
457 drawer: {
458 navigation: [
459 { icon: "icon-drawer-latest", translate: "latestEvents.header.title", indicator: "latest", stateName: "latestEvents" },
460 { icon: "icon-drawer-upcoming", translate: "upcomingEvents.header.title", indicator: "upcoming", stateName: "upcomingEvents" },
461 { icon: "icon-drawer-messages", translate: "messages.header.title", indicator: "messages", stateName: "messages" },
462 { icon: "icon-drawer-copped", translate: "coppedEvents.header.title", badge: "copped", stateName: "coppedEvents" },
463 { icon: "icon-drawer-listed", translate: "listedEvents.header.title", badge: "listed", stateName: "listedEvents" },
464 { icon: "icon-drawer-insiders", translate: "insiders.header.title", stateName: "insiders" },
465 { icon: "icon-drawer-settings", translate: "settings.header.title", stateName: "settings" },
466 ],
467 backdropDelay: 200,
468 },
469 modelOptions: { default: { updateOn: "default", allowInvalid: "true" } },
470 locales: { en: "en_US" },
471 countries: [
472 { code: "af", name: "Afghanistan" },
473 { code: "ax", name: "Åland Islands" },
474 { code: "al", name: "Albania" },
475 { code: "dz", name: "Algeria" },
476 { code: "as", name: "American Samoa" },
477 { code: "ad", name: "Andorra" },
478 { code: "ao", name: "Angola" },
479 { code: "ai", name: "Anguilla" },
480 { code: "aq", name: "Antarctica" },
481 { code: "ag", name: "Antigua and Barbuda" },
482 { code: "ar", name: "Argentina" },
483 { code: "am", name: "Armenia" },
484 { code: "aw", name: "Aruba" },
485 { code: "au", name: "Australia" },
486 { code: "at", name: "Austria" },
487 { code: "az", name: "Azerbaijan" },
488 { code: "bs", name: "Bahamas" },
489 { code: "bh", name: "Bahrain" },
490 { code: "bd", name: "Bangladesh" },
491 { code: "bb", name: "Barbados" },
492 { code: "by", name: "Belarus" },
493 { code: "be", name: "Belgium" },
494 { code: "bz", name: "Belize" },
495 { code: "bj", name: "Benin" },
496 { code: "bm", name: "Bermuda" },
497 { code: "bt", name: "Bhutan" },
498 { code: "bo", name: "Bolivia" },
499 { code: "ba", name: "Bosnia and Herzegovina" },
500 { code: "bw", name: "Botswana" },
501 { code: "bv", name: "Bouvet Island" },
502 { code: "br", name: "Brazil" },
503 { code: "io", name: "British Indian Ocean Territory" },
504 { code: "bn", name: "Brunei Darussalam" },
505 { code: "bg", name: "Bulgaria" },
506 { code: "bf", name: "Burkina Faso" },
507 { code: "bi", name: "Burundi" },
508 { code: "kh", name: "Cambodia" },
509 { code: "cm", name: "Cameroon" },
510 { code: "ca", name: "Canada" },
511 { code: "cv", name: "Cape Verde" },
512 { code: "ky", name: "Cayman Islands" },
513 { code: "cf", name: "Central African Republic" },
514 { code: "td", name: "Chad" },
515 { code: "cl", name: "Chile" },
516 { code: "cn", name: "China" },
517 { code: "cx", name: "Christmas Island" },
518 { code: "cc", name: "Cocos (Keeling) Islands" },
519 { code: "co", name: "Colombia" },
520 { code: "km", name: "Comoros" },
521 { code: "cg", name: "Congo" },
522 { code: "cd", name: "Congo, The Democratic Republic of the" },
523 { code: "ck", name: "Cook Islands" },
524 { code: "cr", name: "Costa Rica" },
525 { code: "ci", name: "Cote D'Ivoire" },
526 { code: "hr", name: "Croatia" },
527 { code: "cu", name: "Cuba" },
528 { code: "cy", name: "Cyprus" },
529 { code: "cz", name: "Czech Republic" },
530 { code: "dk", name: "Denmark" },
531 { code: "dj", name: "Djibouti" },
532 { code: "dm", name: "Dominica" },
533 { code: "do", name: "Dominican Republic" },
534 { code: "ec", name: "Ecuador" },
535 { code: "eg", name: "Egypt" },
536 { code: "sv", name: "El Salvador" },
537 { code: "gq", name: "Equatorial Guinea" },
538 { code: "er", name: "Eritrea" },
539 { code: "ee", name: "Estonia" },
540 { code: "et", name: "Ethiopia" },
541 { code: "fk", name: "Falkland Islands (Malvinas)" },
542 { code: "fo", name: "Faroe Islands" },
543 { code: "fj", name: "Fiji" },
544 { code: "fi", name: "Finland" },
545 { code: "fr", name: "France" },
546 { code: "gf", name: "French Guiana" },
547 { code: "pf", name: "French Polynesia" },
548 { code: "tf", name: "French Southern Territories" },
549 { code: "ga", name: "Gabon" },
550 { code: "gm", name: "Gambia" },
551 { code: "ge", name: "Georgia" },
552 { code: "de", name: "Germany" },
553 { code: "gh", name: "Ghana" },
554 { code: "gi", name: "Gibraltar" },
555 { code: "gr", name: "Greece" },
556 { code: "gl", name: "Greenland" },
557 { code: "gd", name: "Grenada" },
558 { code: "gp", name: "Guadeloupe" },
559 { code: "gu", name: "Guam" },
560 { code: "gt", name: "Guatemala" },
561 { code: "gg", name: "Guernsey" },
562 { code: "gn", name: "Guinea" },
563 { code: "gw", name: "Guinea-Bissau" },
564 { code: "gy", name: "Guyana" },
565 { code: "ht", name: "Haiti" },
566 { code: "hm", name: "Heard Island and Mcdonald Islands" },
567 { code: "va", name: "Holy See (Vatican City State)" },
568 { code: "hn", name: "Honduras" },
569 { code: "hk", name: "Hong Kong" },
570 { code: "hu", name: "Hungary" },
571 { code: "is", name: "Iceland" },
572 { code: "in", name: "India" },
573 { code: "id", name: "Indonesia" },
574 { code: "ir", name: "Iran, Islamic Republic Of" },
575 { code: "iq", name: "Iraq" },
576 { code: "ie", name: "Ireland" },
577 { code: "im", name: "Isle of Man" },
578 { code: "il", name: "Israel" },
579 { code: "it", name: "Italy" },
580 { code: "jm", name: "Jamaica" },
581 { code: "jp", name: "Japan" },
582 { code: "je", name: "Jersey" },
583 { code: "jo", name: "Jordan" },
584 { code: "kz", name: "Kazakhstan" },
585 { code: "ke", name: "Kenya" },
586 { code: "ki", name: "Kiribati" },
587 { code: "kp", name: "Democratic People's Republic of Korea" },
588 { code: "kr", name: "Korea, Republic of" },
589 { code: "xk", name: "Kosovo" },
590 { code: "kw", name: "Kuwait" },
591 { code: "kg", name: "Kyrgyzstan" },
592 { code: "la", name: "Lao People's Democratic Republic" },
593 { code: "lv", name: "Latvia" },
594 { code: "lb", name: "Lebanon" },
595 { code: "ls", name: "Lesotho" },
596 { code: "lr", name: "Liberia" },
597 { code: "ly", name: "Libyan Arab Jamahiriya" },
598 { code: "li", name: "Liechtenstein" },
599 { code: "lt", name: "Lithuania" },
600 { code: "lu", name: "Luxembourg" },
601 { code: "mo", name: "Macao" },
602 { code: "mk", name: "Macedonia, The Former Yugoslav Republic of" },
603 { code: "mg", name: "Madagascar" },
604 { code: "mw", name: "Malawi" },
605 { code: "my", name: "Malaysia" },
606 { code: "mv", name: "Maldives" },
607 { code: "ml", name: "Mali" },
608 { code: "mt", name: "Malta" },
609 { code: "mh", name: "Marshall Islands" },
610 { code: "mq", name: "Martinique" },
611 { code: "mr", name: "Mauritania" },
612 { code: "mu", name: "Mauritius" },
613 { code: "yt", name: "Mayotte" },
614 { code: "mx", name: "Mexico" },
615 { code: "fm", name: "Micronesia, Federated States of" },
616 { code: "md", name: "Moldova, Republic of" },
617 { code: "mc", name: "Monaco" },
618 { code: "mn", name: "Mongolia" },
619 { code: "me", name: "Montenegro" },
620 { code: "ms", name: "Montserrat" },
621 { code: "ma", name: "Morocco" },
622 { code: "mz", name: "Mozambique" },
623 { code: "mm", name: "Myanmar" },
624 { code: "na", name: "Namibia" },
625 { code: "nr", name: "Nauru" },
626 { code: "np", name: "Nepal" },
627 { code: "nl", name: "Netherlands" },
628 { code: "an", name: "Netherlands Antilles" },
629 { code: "nc", name: "New Caledonia" },
630 { code: "nz", name: "New Zealand" },
631 { code: "ni", name: "Nicaragua" },
632 { code: "ne", name: "Niger" },
633 { code: "ng", name: "Nigeria" },
634 { code: "nu", name: "Niue" },
635 { code: "nf", name: "Norfolk Island" },
636 { code: "mp", name: "Northern Mariana Islands" },
637 { code: "no", name: "Norway" },
638 { code: "om", name: "Oman" },
639 { code: "pk", name: "Pakistan" },
640 { code: "pw", name: "Palau" },
641 { code: "ps", name: "Palestinian Territory, Occupied" },
642 { code: "pa", name: "Panama" },
643 { code: "pg", name: "Papua New Guinea" },
644 { code: "py", name: "Paraguay" },
645 { code: "pe", name: "Peru" },
646 { code: "ph", name: "Philippines" },
647 { code: "pn", name: "Pitcairn" },
648 { code: "pl", name: "Poland" },
649 { code: "pt", name: "Portugal" },
650 { code: "pr", name: "Puerto Rico" },
651 { code: "qa", name: "Qatar" },
652 { code: "re", name: "Reunion" },
653 { code: "ro", name: "Romania" },
654 { code: "ru", name: "Russian Federation" },
655 { code: "rw", name: "Rwanda" },
656 { code: "sh", name: "Saint Helena" },
657 { code: "kn", name: "Saint Kitts and Nevis" },
658 { code: "lc", name: "Saint Lucia" },
659 { code: "pm", name: "Saint Pierre and Miquelon" },
660 { code: "vc", name: "Saint Vincent and the Grenadines" },
661 { code: "ws", name: "Samoa" },
662 { code: "sm", name: "San Marino" },
663 { code: "st", name: "Sao Tome and Principe" },
664 { code: "sa", name: "Saudi Arabia" },
665 { code: "sn", name: "Senegal" },
666 { code: "rs", name: "Serbia" },
667 { code: "sc", name: "Seychelles" },
668 { code: "sl", name: "Sierra Leone" },
669 { code: "sg", name: "Singapore" },
670 { code: "sk", name: "Slovakia" },
671 { code: "si", name: "Slovenia" },
672 { code: "sb", name: "Solomon Islands" },
673 { code: "so", name: "Somalia" },
674 { code: "za", name: "South Africa" },
675 { code: "gs", name: "South Georgia and the South Sandwich Islands" },
676 { code: "es", name: "Spain" },
677 { code: "lk", name: "Sri Lanka" },
678 { code: "sd", name: "Sudan" },
679 { code: "sr", name: "Suriname" },
680 { code: "sj", name: "Svalbard and Jan Mayen" },
681 { code: "sz", name: "Swaziland" },
682 { code: "se", name: "Sweden" },
683 { code: "ch", name: "Switzerland" },
684 { code: "sy", name: "Syrian Arab Republic" },
685 { code: "tw", name: "Taiwan" },
686 { code: "tj", name: "Tajikistan" },
687 { code: "tz", name: "Tanzania, United Republic of" },
688 { code: "th", name: "Thailand" },
689 { code: "tl", name: "Timor-Leste" },
690 { code: "tg", name: "Togo" },
691 { code: "tk", name: "Tokelau" },
692 { code: "to", name: "Tonga" },
693 { code: "tt", name: "Trinidad and Tobago" },
694 { code: "tn", name: "Tunisia" },
695 { code: "tr", name: "Turkey" },
696 { code: "tm", name: "Turkmenistan" },
697 { code: "tc", name: "Turks and Caicos Islands" },
698 { code: "tv", name: "Tuvalu" },
699 { code: "ug", name: "Uganda" },
700 { code: "ua", name: "Ukraine" },
701 { code: "ae", name: "United Arab Emirates" },
702 { code: "gb", name: "United Kingdom" },
703 { code: "us", name: "United States" },
704 { code: "um", name: "United States Minor Outlying Islands" },
705 { code: "uy", name: "Uruguay" },
706 { code: "uz", name: "Uzbekistan" },
707 { code: "vu", name: "Vanuatu" },
708 { code: "ve", name: "Venezuela" },
709 { code: "vn", name: "Viet Nam" },
710 { code: "vg", name: "Virgin Islands, British" },
711 { code: "vi", name: "Virgin Islands, U.S." },
712 { code: "wf", name: "Wallis and Futuna" },
713 { code: "eh", name: "Western Sahara" },
714 { code: "ye", name: "Yemen" },
715 { code: "zm", name: "Zambia" },
716 { code: "zw", name: "Zimbabwe" },
717 ],
718 external: {
719 twitter: { name: "Twitter", scheme: { iOS: "twitter://", Android: "com.twitter.android" }, url: { app: "twitter://user?screen_name=copdate", browser: "https://twitter.com/copdate" } },
720 facebook: { name: "Facebook", scheme: { iOS: "fb://", Android: "com.facebook.katana" }, url: { app: "fb://user?screen_name=copdate", browser: "https://www.facebook.com/CopDate-463168860477593" } },
721 instagram: { name: "Instagram", scheme: { iOS: "instagram://", Android: "com.instagram.android" }, url: { app: "instagram://user?username=copdate", browser: "https://instagram.com/copdate" } },
722 appStore: { name: "App Store", scheme: { iOS: "itms-apps://" }, url: { app: "itms-apps://itunes.apple.com/app/copdate/id981606099", browser: "https://itunes.apple.com/app/copdate/id981606099" } },
723 googlePlay: { name: "Google Play", scheme: { Android: "com.android.vending" }, url: { app: "market://details?id=com.copdate.copdate", browser: "https://play.google.com/store/apps/details?id=com.copdate.copdate" } },
724 },
725 redirects: { onboarding: { stateName: "onboarding", stateParams: {} }, latest: { stateName: "latestEvents", stateParams: {} }, login: { stateName: "signIn", stateParams: {} } },
726 infiniteScroll: { distance: "25%" },
727 slider: { defaultTransitionDuration: "0.3s", intervalDelay: 50 },
728 date: { format: "MMM Do YYYY, h:mm A", noTime: "MMMM Do YYYY" },
729 transitions: { defaultDuration: 400, fadeDuration: 800 },
730 logoAnimation: { redirectionDelay: 1e3 },
731 splashscreen: { delay: { iOS: 0, Android: 300 } },
732 timeout: { delay: 1e4 },
733 geofencing: { geofencePromiseDelay: 5e3, geofenceIntervalDelay: 15e3 },
734 onboarding: { startIntroAnimationDelay: 1e3 },
735 alert: { showDuration: 3e3, hideDelay: 500 },
736 historyCategories: ["all", "in", "out"],
737 }),
738 angular.module("app").controller("AccountHistoryController", [
739 "$scope",
740 "Config",
741 "User",
742 "UserService",
743 "Utils",
744 "Operator",
745 function ($scope, Config, User, UserService, Utils, Operator) {
746 ($scope.parseApiError = function (error) {
747 (error = error || {}).code || (error.code = 201), Operator.send("notification.show", { type: "error", message: { translate: "notification.error.unexpectedError", translateValues: { code: error.code } } });
748 }),
749 ($scope.getTransactions = function (page, callback) {
750 var params = { page: page || 1 };
751 UserService.getTransactions(params).then(function (response) {
752 if (response.timeout)
753 Operator.send("api.timeout", {
754 callback: function () {
755 $scope.getTransactions(page, callback);
756 },
757 });
758 else if (((response.data = response.data || {}), response.data.success)) {
759 var nextPage,
760 transactions = [];
761 for (var key in response.data.payload.transactions) {
762 var transaction = {
763 date: moment.utc(response.data.payload.transactions[key].date).utcOffset(moment.parseZone(response.data.payload.transactions[key].date).utcOffset()).format(Config.default.dateTimeFormat),
764 id: response.data.payload.transactions[key].transaction_id,
765 card: { type: response.data.payload.transactions[key].card_type, last4: response.data.payload.transactions[key].card_last4 },
766 amount: response.data.payload.transactions[key].amount,
767 };
768 transactions.push(transaction);
769 }
770 (nextPage = response.data.payload.next_page || null), "function" == typeof callback && callback(transactions, nextPage);
771 } else $scope.parseApiError(response.data.error);
772 });
773 }),
774 ($scope.loadTransactions = function (callback) {
775 $scope.getTransactions($scope.data.nextPage, function (transactions, nextPage) {
776 ($scope.data.list = $scope.data.list.concat(transactions)),
777 ($scope.data.nextPage = nextPage),
778 Operator.send("scroll.infiniteScrollComplete"),
779 ($scope.isTransactions = !!$scope.data.list.length),
780 ($scope.isMoreTransactions = !!nextPage),
781 "function" == typeof callback && callback();
782 });
783 }),
784 ($scope.refreshList = function () {
785 ($scope.data.list = []),
786 ($scope.data.nextPage = 1),
787 $scope.loadTransactions(function () {
788 Operator.send("scroll.refreshComplete");
789 });
790 }),
791 ($scope.getMoreTransactions = function () {
792 $scope.loadTransactions();
793 }),
794 $scope.$on("$ionicView.loaded", function () {
795 ($scope.header = { theme: "black", title: { translate: "accountHistory.header.title", translateValues: {} }, buttons: { back: !0 } }),
796 ($scope.data = { infiniteScrollDistance: Config.infiniteScroll.distance }),
797 Operator.send("statusbar.update", { theme: $scope.header.theme });
798 }),
799 $scope.$on("$ionicView.beforeEnter", function () {
800 ($scope.isLoading = !1),
801 ($scope.isTransactions = !1),
802 ($scope.isMoreTransactions = !1),
803 ($scope.data.list = []),
804 ($scope.data.nextPage = 1),
805 $scope.loadTransactions(function () {
806 $scope.isLoading = !1;
807 });
808 }),
809 $scope.$on("accountHistory.pause", function () {}),
810 $scope.$on("accountHistory.resume", function () {});
811 },
812 ]),
813 angular.module("app").controller("AccountController", [
814 "$scope",
815 "$translate",
816 "$ionicActionSheet",
817 "Config",
818 "User",
819 "UserService",
820 "Utils",
821 "Operator",
822 function ($scope, $translate, $ionicActionSheet, Config, User, UserService, Utils, Operator) {
823 ($scope.signOut = function () {
824 $ionicActionSheet.show({
825 destructiveText: $translate.instant("account.content.actionSheet.signOut"),
826 cancelText: $translate.instant("account.content.actionSheet.cancel"),
827 cancelOnStateChange: !0,
828 destructiveButtonClicked: function () {
829 Operator.send("app.signOut");
830 },
831 });
832 }),
833 ($scope.goTo = function ($event, stateName, transition, stateParams) {
834 Utils.goTo($event, stateName, transition, stateParams);
835 }),
836 $scope.$on("$ionicView.loaded", function () {
837 ($scope.header = {
838 theme: "white",
839 title: { translate: "account.header.title", translateValues: {} },
840 buttons: { drawer: !0, edit: !0 },
841 callback: {
842 edit: function () {
843 Utils.switchState("editProfile");
844 },
845 },
846 }),
847 ($scope.data = {
848 user: {
849 name: User.profile.name.first + " " + User.profile.name.last,
850 email: User.profile.email,
851 phone: intlTelInputUtils.formatNumber(User.profile.phone, User.profile.phoneCountryCode, 1),
852 shoeSize: User.sizes.shoe,
853 },
854 }),
855 Operator.send("statusbar.update", { theme: $scope.header.theme });
856 }),
857 $scope.$on("$ionicView.beforeEnter", function () {}),
858 $scope.$on("account.pause", function () {}),
859 $scope.$on("account.resume", function () {});
860 },
861 ]),
862 angular.module("app").controller("BecomePartnerController", [
863 "$window",
864 "$scope",
865 "Config",
866 "Operator",
867 "GA",
868 function ($window, $scope, Config, Operator, GA) {
869 ($scope.mailTo = function () {
870 GA.trackEvent("Send email"), $window.open("mailto:" + Config.copdate.email, "_self");
871 }),
872 $scope.$on("$ionicView.loaded", function () {
873 ($scope.header = { theme: "white", title: { translate: "becomePartner.header.title", translateValues: {} }, buttons: { back: !0 } }), Operator.send("statusbar.update", { theme: $scope.header.theme });
874 }),
875 $scope.$on("$ionicView.beforeEnter", function () {}),
876 $scope.$on("becomePartner.pause", function () {}),
877 $scope.$on("becomePartner.resume", function () {});
878 },
879 ]),
880 angular.module("app").controller("ChangePasswordController", [
881 "$scope",
882 "$timeout",
883 "Config",
884 "User",
885 "UserService",
886 "Utils",
887 "FormService",
888 "Operator",
889 function ($scope, $timeout, Config, User, UserService, Utils, FormService, Operator) {
890 ($scope.setForm = function () {
891 $scope.data.form = FormService.setForm({
892 value: { current_password: "", new_password: "", confirm_new_password: "" },
893 error: { current_password: "", new_password: "", confirm_new_password: "" },
894 errorMessages: {
895 current_password: { required: "field.error.currentPassword.required", invalid: "field.error.currentPassword.invalid" },
896 new_password: { required: "field.error.newPassword.required", pattern: "field.error.newPassword.pattern", notMatch: "field.error.newPassword.notMatch" },
897 confirm_new_password: { required: "field.error.confirmNewPassword.required", match: "field.error.confirmNewPassword.match" },
898 },
899 });
900 }),
901 ($scope.validateField = function (field) {
902 FormService.validateField($scope.form, field);
903 }),
904 ($scope.validateForm = function () {
905 return FormService.validateForm($scope.form);
906 }),
907 ($scope.parseApiError = function (error) {
908 var message = { translate: "notification.error.invalidData", translateValues: {} };
909 switch (((error = error || {}).code || (error.code = 201), error.code)) {
910 case 111:
911 FormService.newScheme.error.password = FormService.errorMessages.password.pattern;
912 break;
913 case 112:
914 FormService.newScheme.error.password = FormService.errorMessages.password.invalid;
915 break;
916 default:
917 message = { translate: "notification.error.unexpectedError", translateValues: { code: error.code } };
918 }
919 Operator.send("notification.show", { type: "error", message: message });
920 }),
921 ($scope.onSubmit = function () {
922 if (!$scope.isSaving && $scope.validateForm())
923 if (angular.equals(FormService.newScheme.value.new_password, FormService.newScheme.value.confirm_new_password)) {
924 $scope.isSaving = !0;
925 var params = angular.copy(FormService.newScheme.value);
926 delete params.confirm_new_password,
927 UserService.changePassword(params).then(function (response) {
928 response.timeout
929 ? Operator.send("api.timeout", {
930 callback: function () {
931 ($scope.isSaving = !1), $scope.onSubmit();
932 },
933 })
934 : ((response.data = response.data || {}),
935 response.data.success
936 ? ($scope.setForm(), Operator.send("notification.show", { type: "success", message: { translate: "notification.success.passwordChanged" } }))
937 : $scope.parseApiError(response.data.error),
938 ($scope.isSaving = !1));
939 });
940 } else FormService.newScheme.error.confirm_new_password = FormService.errorMessages.confirm_new_password.match;
941 }),
942 ($scope.keyboardOpened = function () {
943 ($scope.isFieldFocus = !0), $scope.data.keyboardCloseTimeout && $timeout.cancel($scope.data.keyboardCloseTimeout);
944 }),
945 ($scope.keyboardClosed = function (field) {
946 $scope.validateField(field),
947 ($scope.data.keyboardCloseTimeout = $timeout(function () {
948 ($scope.isFieldFocus = !1), $timeout.cancel($scope.data.keyboardCloseTimeout);
949 }, 300));
950 }),
951 $scope.$on("$ionicView.loaded", function () {
952 ($scope.header = { theme: "white", title: { translate: "changePassword.header.title", translateValues: {} }, buttons: { back: !0 } }),
953 ($scope.data = { form: {}, keyboardCloseTimeout: null, modelOptions: Config.modelOptions }),
954 Operator.send("statusbar.update", { theme: $scope.header.theme });
955 }),
956 $scope.$on("$ionicView.beforeEnter", function () {
957 ($scope.isFieldFocus = !1), ($scope.isSaving = !1), $scope.setForm();
958 }),
959 $scope.$on("changePassword.pause", function () {}),
960 $scope.$on("changePassword.resume", function () {});
961 },
962 ]),
963 angular.module("app").controller("CoppedEventsTicketController", [
964 "$scope",
965 "Storage",
966 "Operator",
967 function ($scope, Storage, Operator) {
968 $scope.$on("$ionicView.loaded", function () {
969 ($scope.header = { theme: "white", title: { translate: "coppedEventsTicket.header.title", translateValues: {} }, buttons: { back: !0 } }),
970 ($scope.data = { event: Storage.get("eventTicket") }),
971 Operator.send("statusbar.update", { theme: $scope.header.theme });
972 }),
973 $scope.$on("$ionicView.beforeEnter", function () {}),
974 $scope.$on("coppedEventsTicket.pause", function () {}),
975 $scope.$on("coppedEventsTicket.resume", function () {});
976 },
977 ]),
978 angular.module("app").controller("CoppedEventsController", [
979 "$scope",
980 "Config",
981 "Storage",
982 "User",
983 "UserService",
984 "Utils",
985 "Operator",
986 function ($scope, Config, Storage, User, UserService, Utils, Operator) {
987 ($scope.parseApiError = function (error) {
988 (error = error || {}).code || (error.code = 201), Operator.send("notification.show", { type: "error", message: { translate: "notification.error.unexpectedError", translateValues: { code: error.code } } });
989 }),
990 ($scope.getCoppedEvents = function (callback) {
991 UserService.getCoppedEvents().then(function (response) {
992 if (response.timeout)
993 Operator.send("api.timeout", {
994 callback: function () {
995 $scope.getCoppedEvents(callback);
996 },
997 });
998 else if (((response.data = response.data || {}), response.data.success)) {
999 var item,
1000 event,
1001 activedList = [],
1002 archivedList = [];
1003 for (var key in response.data.payload.cops)
1004 (event = {
1005 id: (item = response.data.payload.cops[key]).event.id,
1006 date: moment.utc(item.event.date).utcOffset(moment.parseZone(item.event.date).utcOffset()).format(Config.default.dateFormat),
1007 type: "rsvp" === item.event.type ? "rsvp" : "list",
1008 confirmationCode: item.event.confirmation_code,
1009 reservationId: item.event.reservation_id,
1010 userName: item.event.user_name,
1011 pickupStatus: item.event.pickup_status || null,
1012 product: { name: item.event.product.name, images: item.event.product.images || [], sizeType: null },
1013 store: { logo: item.store.logo, name: item.store.name, city: item.store.city, address: item.store.address, postalCode: item.store.postal_code },
1014 payment: { fee: item.event.payment.fee, retailPrice: item.event.payment.retail_price },
1015 }),
1016 item.event.product.size &&
1017 ((event.product.sizeType = item.event.product.size.type || null),
1018 "shoe" === event.product.sizeType && (event.product.sizeType = "footwear"),
1019 "time" === event.product.sizeType
1020 ? (event.product.timeSlot = item.event.product.size.slot || null)
1021 : ((event.product.size = item.event.product.size.size || null), (event.product.gender = item.event.product.size.gender || null))),
1022 event.pickupStatus ? archivedList.push(event) : activedList.push(event);
1023 "function" == typeof callback && callback(activedList, archivedList);
1024 } else $scope.parseApiError(response.data.error);
1025 });
1026 }),
1027 ($scope.loadEvents = function (callback) {
1028 ($scope.isEvents = !1),
1029 $scope.getCoppedEvents(function (activedList, archivedList) {
1030 ($scope.data.activedList = activedList), ($scope.data.archivedList = archivedList), ($scope.isEvents = !!$scope.data[$scope.currentTab + "List"].length), "function" == typeof callback && callback();
1031 });
1032 }),
1033 ($scope.selectNavigationTab = function (tab) {
1034 ($scope.currentTab = tab),
1035 ($scope.isLoading = !0),
1036 $scope.loadEvents(function () {
1037 $scope.isLoading = !1;
1038 });
1039 }),
1040 ($scope.goTo = function ($event, stateName, transition, stateParams) {
1041 Utils.goTo($event, stateName, transition, stateParams);
1042 }),
1043 ($scope.goToTicket = function (event) {
1044 (event.product.image = event.product.images[0]), delete event.product.images, delete event.store.address, delete event.store.logo, delete event.store.postalCode;
1045 var eventTicket = {
1046 id: event.id,
1047 userName: event.userName,
1048 product: event.product,
1049 payment: event.payment,
1050 store: event.store,
1051 confirmationCode: event.confirmationCode,
1052 qrcode: event.reservationId + "." + event.id + "." + event.confirmationCode,
1053 };
1054 Storage.set("eventTicket", eventTicket), Utils.switchState("coppedEventsTicket", "slide-left", { id: event.id });
1055 }),
1056 $scope.$on("$ionicView.loaded", function () {
1057 ($scope.currentTab = ""),
1058 ($scope.header = { theme: "black", title: { translate: "coppedEvents.header.title", translateValues: {} }, buttons: { drawer: !0 } }),
1059 ($scope.data = {
1060 tabs: [
1061 { name: "actived", translate: "coppedEvents.header.tabs.actived" },
1062 { name: "archived", translate: "coppedEvents.header.tabs.archived" },
1063 ],
1064 activedList: [],
1065 archivedList: [],
1066 user: { name: User.profile.name.first + " " + User.profile.name.last },
1067 }),
1068 Operator.send("splashscreen.hide"),
1069 Operator.send("statusbar.update", { theme: $scope.header.theme });
1070 }),
1071 $scope.$on("$ionicView.beforeEnter", function () {
1072 ($scope.isLoading = !0), ($scope.isEvents = !1), Storage.unset("eventTicket"), $scope.selectNavigationTab("actived");
1073 }),
1074 $scope.$on("coppedEvents.pause", function () {}),
1075 $scope.$on("coppedEvents.resume", function () {});
1076 },
1077 ]),
1078 angular.module("app").controller("EditProfileController", [
1079 "$scope",
1080 "$timeout",
1081 "Config",
1082 "User",
1083 "UserService",
1084 "Utils",
1085 "FormService",
1086 "Operator",
1087 function ($scope, $timeout, Config, User, UserService, Utils, FormService, Operator) {
1088 ($scope.setForm = function () {
1089 var data = {
1090 value: {
1091 first_name: angular.copy(User.profile.name.first),
1092 last_name: angular.copy(User.profile.name.last),
1093 email: angular.copy(User.profile.email),
1094 phone: angular.copy(User.profile.phone),
1095 phone_country_code: angular.copy(User.profile.phoneCountryCode),
1096 },
1097 error: { first_name: "", last_name: "", email: "", phone: "", phone_country_code: "" },
1098 errorMessages: {
1099 first_name: { required: "field.error.firstName.required", maxlength: "field.error.firstName.maxlength" },
1100 last_name: { required: "field.error.lastName.required", maxlength: "field.error.lastName.maxlength" },
1101 email: { required: "field.error.email.required", pattern: "field.error.email.pattern", alreadyExist: "field.error.email.alreadyExist" },
1102 phone: { required: "field.error.phone.required", pattern: "field.error.phone.pattern", countryCode: "field.error.phone.countryCode" },
1103 },
1104 };
1105 $scope.data.form = FormService.setForm(data);
1106 }),
1107 ($scope.validateField = function (field) {
1108 FormService.validateField($scope.form, field);
1109 }),
1110 ($scope.validateForm = function () {
1111 return FormService.validateForm($scope.form);
1112 }),
1113 ($scope.parseApiError = function (error) {
1114 var message = { translate: "notification.error.invalidData", translateValues: {} };
1115 switch (((error = error || {}).code || (error.code = 201), error.code)) {
1116 case 109:
1117 FormService.newScheme.error.email = FormService.errorMessages.email.pattern;
1118 break;
1119 case 110:
1120 FormService.newScheme.error.email = FormService.errorMessages.email.alreadyExist;
1121 break;
1122 case 113:
1123 FormService.newScheme.error.first_name = FormService.errorMessages.first_name.required;
1124 break;
1125 case 114:
1126 FormService.newScheme.error.last_name = FormService.errorMessages.last_name.required;
1127 break;
1128 case 122:
1129 FormService.newScheme.error.phone = FormService.errorMessages.phone.pattern;
1130 break;
1131 case 126:
1132 FormService.newScheme.error.phone = FormService.errorMessages.phone.countryCode;
1133 break;
1134 default:
1135 message = { translate: "notification.error.unexpectedError", translateValues: { code: error.code } };
1136 }
1137 Operator.send("notification.show", { type: "error", message: message });
1138 }),
1139 ($scope.onSubmit = function () {
1140 if (!$scope.isSaving && $scope.validateForm())
1141 if (angular.equals(FormService.newScheme.value, FormService.oldScheme.value)) Operator.send("notification.show", { type: "success", message: { translate: "notification.success.profileUpdated" } });
1142 else {
1143 $scope.isSaving = !0;
1144 var params = angular.copy(FormService.newScheme.value);
1145 (params.phone = Utils.getPhoneNumberRaw(params.phone, params.phone_country_code)),
1146 UserService.updateProfile(params).then(function (response) {
1147 response.timeout
1148 ? Operator.send("api.timeout", {
1149 callback: function () {
1150 ($scope.isSaving = !1), $scope.onSubmit();
1151 },
1152 })
1153 : ((response.data = response.data || {}),
1154 response.data.success
1155 ? (User.setProfile({
1156 user_id: User.profile.id,
1157 first_name: params.first_name,
1158 last_name: params.last_name,
1159 email: params.email,
1160 phone: params.phone,
1161 phone_country_code: params.phone_country_code,
1162 }),
1163 Operator.send("notification.show", { type: "success", message: { translate: "notification.success.profileUpdated" } }))
1164 : $scope.parseApiError(response.data.error),
1165 ($scope.isSaving = !1));
1166 });
1167 }
1168 }),
1169 ($scope.keyboardOpened = function () {
1170 ($scope.isFieldFocus = !0), $scope.data.keyboardCloseTimeout && $timeout.cancel($scope.data.keyboardCloseTimeout);
1171 }),
1172 ($scope.keyboardClosed = function (field) {
1173 $scope.validateField(field),
1174 ($scope.data.keyboardCloseTimeout = $timeout(function () {
1175 ($scope.isFieldFocus = !1), $timeout.cancel($scope.data.keyboardCloseTimeout);
1176 }, 300));
1177 }),
1178 $scope.$on("$ionicView.loaded", function () {
1179 ($scope.header = { theme: "white", title: { translate: "editProfile.header.title", translateValues: {} }, buttons: { back: !0 } }),
1180 ($scope.data = { form: {}, keyboardCloseTimeout: null, modelOptions: Config.modelOptions }),
1181 Operator.send("statusbar.update", { theme: $scope.header.theme });
1182 }),
1183 $scope.$on("$ionicView.beforeEnter", function () {
1184 ($scope.isFieldFocus = !1), ($scope.isSaving = !1), $scope.setForm();
1185 }),
1186 $scope.$on("editProfile.pause", function () {}),
1187 $scope.$on("editProfile.resume", function () {});
1188 },
1189 ]),
1190 angular.module("app").controller("EnableNotificationsController", [
1191 "$scope",
1192 "$ionicHistory",
1193 "Config",
1194 "Storage",
1195 "User",
1196 "Utils",
1197 "Operator",
1198 "Diagnostic",
1199 function ($scope, $ionicHistory, Config, Storage, User, Utils, Operator, Diagnostic) {
1200 ($scope.enableNotifications = function () {
1201 switch (User.isNotificationsEnabled) {
1202 case !0:
1203 $scope.goNext();
1204 break;
1205 case !1:
1206 Operator.send("osSettings.open", { setting: "iOS" === Storage.get("deviceOs") ? "application_details" : "application" });
1207 break;
1208 default:
1209 Operator.send("oneSignal.init", {
1210 callback: function () {
1211 Operator.send("oneSignal.validateTags"), $scope.goNext();
1212 },
1213 });
1214 }
1215 }),
1216 ($scope.goNext = function () {
1217 var next,
1218 transition = "slide-left";
1219 User.isLocationShared ? ((next = Storage.get("schemeRedirection") ? angular.copy(Storage.get("schemeRedirection")) : Config.redirects.latest), (transition = "fade")) : (next = { stateName: "shareLocation" }),
1220 Utils.switchState(next.stateName, transition);
1221 }),
1222 $scope.$on("$ionicView.loaded", function () {
1223 ($scope.header = { theme: "white", title: {}, buttons: {} }),
1224 ($scope.data = { referrer: $ionicHistory.backView() || {}, density: Storage.get("deviceDensity") }),
1225 "selectSizes" !== $scope.data.referrer.stateName && ($scope.header.buttons.back = !0),
1226 Operator.send("statusbar.update", { theme: $scope.header.theme });
1227 }),
1228 $scope.$on("$ionicView.beforeEnter", function () {}),
1229 $scope.$on("enableNotifications.pause", function () {}),
1230 $scope.$on("enableNotifications.resume", function () {
1231 Diagnostic.isNotificationsEnabled(function (enabled) {
1232 enabled && (User.enableNotifications(!0), $scope.goNext());
1233 });
1234 });
1235 },
1236 ]),
1237 angular.module("app").controller("EventEnteringConfirmedController", [
1238 "$scope",
1239 "$stateParams",
1240 "EventService",
1241 "Utils",
1242 "Operator",
1243 function ($scope, $stateParams, EventService, Utils, Operator) {
1244 ($scope.getEvent = function (eventId, callback) {
1245 var params = { event_id: eventId };
1246 EventService.getEvent(params).then(function (response) {
1247 if (response.timeout)
1248 Operator.send("api.timeout", {
1249 callback: function () {
1250 $scope.getEvent(eventId, callback);
1251 },
1252 });
1253 else if (((response.data = response.data || {}), response.data.success)) {
1254 var event = { id: response.data.payload.event.id, type: "rsvp" === response.data.payload.event.type ? "rsvp" : "list", product: { images: response.data.payload.event.product.images || [] } };
1255 "function" == typeof callback && callback(event);
1256 } else $scope.parseApiError(response.data.error);
1257 });
1258 }),
1259 $scope.$on("$ionicView.loaded", function () {
1260 ($scope.header = {
1261 theme: "black",
1262 title: { translate: "eventEnteringConfirmed.header.title", translateValues: {} },
1263 buttons: { close: !0 },
1264 callback: {
1265 close: function () {
1266 Utils.switchState("latestEvents", "slide-down");
1267 },
1268 },
1269 }),
1270 ($scope.data = {}),
1271 Operator.send("statusbar.update", { theme: $scope.header.theme });
1272 }),
1273 $scope.$on("$ionicView.beforeEnter", function () {
1274 ($scope.isLoading = !0),
1275 $scope.getEvent($stateParams.id, function (event) {
1276 ($scope.data.event = event), ($scope.isLoading = !1);
1277 });
1278 }),
1279 $scope.$on("eventEnteringConfirmed.pause", function () {}),
1280 $scope.$on("eventEnteringConfirmed.resume", function () {});
1281 },
1282 ]),
1283 angular.module("app").controller("EventReservationCancelledController", [
1284 "$scope",
1285 "Utils",
1286 "Operator",
1287 function ($scope, Utils, Operator) {
1288 ($scope.goTo = function ($event, stateName, transition, stateParams) {
1289 Utils.goTo($event, stateName, transition, stateParams);
1290 }),
1291 $scope.$on("$ionicView.loaded", function () {
1292 ($scope.header = {
1293 theme: "white",
1294 title: { translate: "eventReservationCancelled.header.title", translateValues: {} },
1295 buttons: { close: !0 },
1296 callback: {
1297 close: function () {
1298 Utils.switchState("latestEvents", "slide-down");
1299 },
1300 },
1301 }),
1302 ($scope.data = {}),
1303 Operator.send("statusbar.update", { theme: $scope.header.theme });
1304 }),
1305 $scope.$on("$ionicView.beforeEnter", function () {}),
1306 $scope.$on("eventReservationCancelled.pause", function () {}),
1307 $scope.$on("eventReservationCancelled.resume", function () {});
1308 },
1309 ]),
1310 angular.module("app").controller("EventReservationConfirmedController", [
1311 "$scope",
1312 "$stateParams",
1313 "EventService",
1314 "Utils",
1315 "Operator",
1316 function ($scope, $stateParams, EventService, Utils, Operator) {
1317 ($scope.getEvent = function (eventId, callback) {
1318 var params = { event_id: eventId };
1319 EventService.getEvent(params).then(function (response) {
1320 if (response.timeout)
1321 Operator.send("api.timeout", {
1322 callback: function () {
1323 $scope.getEvent(eventId, callback);
1324 },
1325 });
1326 else if (((response.data = response.data || {}), response.data.success)) {
1327 var event = {
1328 id: response.data.payload.event.id,
1329 type: "rsvp" === response.data.payload.event.type ? "rsvp" : "list",
1330 product: { name: response.data.payload.event.product.name, images: response.data.payload.event.product.images || [] },
1331 store: { name: response.data.payload.store.name, city: response.data.payload.store.city },
1332 payment: { fee: 0 },
1333 };
1334 "function" == typeof callback && callback(event);
1335 } else $scope.parseApiError(response.data.error);
1336 });
1337 }),
1338 $scope.$on("$ionicView.loaded", function () {
1339 ($scope.header = {
1340 theme: "black",
1341 title: { translate: "eventReservationConfirmed.header.title", translateValues: {} },
1342 buttons: { close: !0 },
1343 callback: {
1344 close: function () {
1345 Utils.switchState("latestEvents", "slide-down");
1346 },
1347 },
1348 }),
1349 ($scope.data = {}),
1350 Operator.send("statusbar.update", { theme: $scope.header.theme });
1351 }),
1352 $scope.$on("$ionicView.beforeEnter", function () {
1353 ($scope.isLoading = !0),
1354 $scope.getEvent($stateParams.id, function (event) {
1355 ($scope.data.event = event), ($scope.isLoading = !1);
1356 });
1357 }),
1358 $scope.$on("eventReservationConfirmed.pause", function () {}),
1359 $scope.$on("eventReservationConfirmed.resume", function () {});
1360 },
1361 ]),
1362 angular.module("app").controller("EventReservationTimedOutController", [
1363 "$scope",
1364 "$stateParams",
1365 "EventService",
1366 "Utils",
1367 "Operator",
1368 function ($scope, $stateParams, EventService, Utils, Operator) {
1369 ($scope.parseApiError = function (error) {
1370 var message;
1371 switch (((error = error || {}).code || (error.code = 201), error.code)) {
1372 case 108:
1373 case 128:
1374 case 131:
1375 return void Utils.switchState("latestEvents", "no-transition");
1376 case 136:
1377 return void Utils.switchState("eventWaitingList", "no-transition", { id: $scope.data.event.id });
1378 default:
1379 message = { translate: "notification.error.unexpectedError", translateValues: { code: error.code } };
1380 }
1381 message && Operator.send("notification.show", { type: "error", message: message });
1382 }),
1383 ($scope.getEvent = function (eventId, callback) {
1384 var params = { event_id: eventId };
1385 EventService.getEvent(params).then(function (response) {
1386 if (response.timeout)
1387 Operator.send("api.timeout", {
1388 callback: function () {
1389 $scope.getEvent(eventId, callback);
1390 },
1391 });
1392 else if (((response.data = response.data || {}), response.data.success)) {
1393 var event = { id: response.data.payload.event.id, type: "rsvp" === response.data.payload.event.type ? "rsvp" : "list" };
1394 "function" == typeof callback && callback(event);
1395 } else $scope.parseApiError(response.data.error);
1396 });
1397 }),
1398 ($scope.clearReservation = function (eventId) {
1399 var params = { event_id: eventId };
1400 EventService.clearReservation(params).then(function (response) {
1401 response.timeout
1402 ? Operator.send("api.timeout", {
1403 callback: function () {
1404 $scope.clearReservation(eventId);
1405 },
1406 })
1407 : ((response.data = response.data || {}), response.data.success ? Utils.switchState("event", "slide-down", { id: $stateParams.id }) : $scope.parseApiError(response.data.error));
1408 });
1409 }),
1410 $scope.$on("$ionicView.loaded", function () {
1411 ($scope.header = {
1412 theme: "white",
1413 title: { translate: "eventReservationTimedOut.header.title", translateValues: {} },
1414 buttons: { close: !0 },
1415 callback: {
1416 close: function () {
1417 "rsvp" === $scope.data.event.type && $scope.clearReservation($stateParams.id);
1418 },
1419 },
1420 }),
1421 ($scope.data = {}),
1422 Operator.send("statusbar.update", { theme: $scope.header.theme });
1423 }),
1424 $scope.$on("$ionicView.beforeEnter", function () {
1425 ($scope.isLoading = !0),
1426 ($scope.isSaving = !1),
1427 $scope.getEvent($stateParams.id, function (event) {
1428 ($scope.data.event = event), ($scope.isLoading = !1);
1429 });
1430 }),
1431 $scope.$on("eventReservationTimedOut.pause", function () {}),
1432 $scope.$on("eventReservationTimedOut.resume", function () {});
1433 },
1434 ]),
1435 angular.module("app").controller("EventReservationController", [
1436 "$scope",
1437 "$stateParams",
1438 "$interval",
1439 "$translate",
1440 "EventService",
1441 "Utils",
1442 "Operator",
1443 function ($scope, $stateParams, $interval, $translate, EventService, Utils, Operator) {
1444 ($scope.parseApiError = function (error) {
1445 var message;
1446 switch (((error = error || {}).code || (error.code = 201), error.code)) {
1447 case 108:
1448 case 128:
1449 case 131:
1450 return void Utils.switchState("latestEvents", "no-transition");
1451 case 129:
1452 return void Utils.switchState("eventReservationTimedOut", "no-transition", { id: $scope.data.event.id });
1453 case 135:
1454 return void Utils.switchState("coppedEvents", "no-transition");
1455 case 136:
1456 return void Utils.switchState("eventWaitingList", "no-transition", { id: $scope.data.event.id });
1457 default:
1458 message = { translate: "notification.error.unexpectedError", translateValues: { code: error.code } };
1459 }
1460 message && Operator.send("notification.show", { type: "error", message: message });
1461 }),
1462 ($scope.getEvent = function (eventId, callback) {
1463 var params = { event_id: eventId };
1464 EventService.getEvent(params).then(function (response) {
1465 if (response.timeout)
1466 Operator.send("api.timeout", {
1467 callback: function () {
1468 $scope.getEvent(eventId, callback);
1469 },
1470 });
1471 else if (((response.data = response.data || {}), response.data.success)) {
1472 var event = {
1473 id: response.data.payload.event.id,
1474 type: "rsvp" === response.data.payload.event.type ? "rsvp" : "list",
1475 product: { name: response.data.payload.event.product.name, images: response.data.payload.event.product.images || [] },
1476 store: { name: response.data.payload.store.name, city: response.data.payload.store.city },
1477 payment: {
1478 timestamp: response.data.payload.event.payment.timestamp,
1479 timeout: response.data.payload.event.payment.timeout,
1480 retailPrice: response.data.payload.event.payment.retail_price,
1481 fee: response.data.payload.event.payment.fee,
1482 sizeType: null,
1483 },
1484 };
1485 if (response.data.payload.event.payment.size)
1486 if (((event.payment.sizeType = response.data.payload.event.payment.size.type || null), "shoe" === event.payment.sizeType && (event.payment.sizeType = "footwear"), "time" === event.payment.sizeType)) {
1487 var slot = Utils.findItemByKey("slot", String(response.data.payload.event.payment.size.slot), response.data.payload.event.product.sizes.enabled_slots);
1488 (event.payment.slot = response.data.payload.event.payment.size.slot), (event.payment.slotLabel = slot.label);
1489 } else (event.payment.size = response.data.payload.event.payment.size.size || null), (event.payment.gender = response.data.payload.event.payment.size.gender || null);
1490 else event.payment.sizeType = "other";
1491 "function" == typeof callback && callback(event);
1492 } else $scope.parseApiError(response.data.error);
1493 });
1494 }),
1495 ($scope.getEventTimeout = function (eventId, callback) {
1496 var params = { event_id: eventId };
1497 EventService.getEventTimeout(params).then(function (response) {
1498 var timeout;
1499 response.timeout
1500 ? Operator.send("api.timeout", {
1501 callback: function () {
1502 $scope.getEventTimeout(eventId, callback);
1503 },
1504 })
1505 : ((response.data = response.data || {}), response.data.success ? (timeout = response.data.payload.timeout) : $scope.parseApiError(response.data.error), "function" == typeof callback && callback(timeout));
1506 });
1507 }),
1508 ($scope.confirmReservation = function () {
1509 if (!$scope.isSaving)
1510 if (0 < $scope.data.event.payment.fee) Utils.switchState("paymentMethod", "slide-left", { id: $scope.data.event.id });
1511 else {
1512 $scope.isSaving = !0;
1513 var params = { event_id: $scope.data.event.id };
1514 EventService.confirmFreeReservation(params).then(function (response) {
1515 if (response.timeout)
1516 Operator.send("api.timeout", {
1517 callback: function () {
1518 ($scope.isSaving = !1), $scope.confirmReservation();
1519 },
1520 });
1521 else {
1522 if (((response.data = response.data || {}), response.data.success)) return Utils.switchState("eventReservationConfirmed", "slide-up", { id: $scope.data.event.id }), void ($scope.isSaving = !1);
1523 $scope.parseApiError(response.data.error);
1524 }
1525 });
1526 }
1527 }),
1528 ($scope.cancelReservation = function () {
1529 $scope.isCancelling ||
1530 Operator.send("dialog", {
1531 type: "confirm",
1532 title: $translate.instant("dialog.cancelReservation.title"),
1533 text: $translate.instant("dialog.cancelReservation.text"),
1534 action: [$translate.instant("dialog.cancelReservation.action.cancel"), $translate.instant("dialog.cancelReservation.action.confirm")],
1535 callback: function (index) {
1536 if (2 === index) {
1537 $scope.isCancelling = !0;
1538 var params = { event_id: $scope.data.event.id };
1539 EventService.cancelReservation(params).then(function (response) {
1540 response.timeout
1541 ? Operator.send("api.timeout", {
1542 callback: function () {
1543 ($scope.isCancelling = !1), $scope.cancelReservation();
1544 },
1545 })
1546 : ((response.data = response.data || {}),
1547 response.data.success ? Utils.switchState("eventReservationCancelled", "slide-up", { id: $scope.data.event.id }) : $scope.parseApiError(response.data.error));
1548 });
1549 }
1550 },
1551 });
1552 }),
1553 ($scope.updateCountdown = function (time) {
1554 var seconds,
1555 duration = moment.duration(time, "seconds");
1556 if ((seconds = duration.asSeconds()) < 1) Utils.switchState("eventReservationTimedOut", "slide-up", { id: $scope.data.event.id });
1557 else {
1558 var hh = duration.hours() < 10 ? "0" + duration.hours() : duration.hours(),
1559 mm = duration.minutes() < 10 ? "0" + duration.minutes() : duration.minutes(),
1560 ss = duration.seconds() < 10 ? "0" + duration.seconds() : duration.seconds();
1561 $scope.data.countdown = seconds < 3600 ? mm + ":" + ss : hh + ":" + mm + ":" + ss;
1562 }
1563 }),
1564 ($scope.startCountdownInterval = function (time) {
1565 var duration = moment.duration(time, "seconds");
1566 $scope.stopCountdownInterval(),
1567 ($scope.data.countdownInterval = $interval(function () {
1568 (duration = moment.duration(duration.asSeconds() - 1, "seconds")), $scope.updateCountdown(duration.asSeconds());
1569 }, 1e3));
1570 }),
1571 ($scope.stopCountdownInterval = function () {
1572 $scope.data.countdownInterval && ($interval.cancel($scope.data.countdownInterval), ($scope.data.countdownInterval = null));
1573 }),
1574 $scope.$on("$ionicView.loaded", function () {
1575 ($scope.header = { theme: "white", title: {}, buttons: { back: !0 } }), ($scope.data = {}), Operator.send("splashscreen.hide"), Operator.send("statusbar.update", { theme: $scope.header.theme });
1576 }),
1577 $scope.$on("$ionicView.beforeEnter", function () {
1578 ($scope.isLoading = !0),
1579 ($scope.isSaving = !1),
1580 ($scope.isCancelling = !1),
1581 $scope.getEvent($stateParams.id, function (event) {
1582 ($scope.header.title = { translate: "eventReservation.header.title." + event.type, translateValues: {} }), ($scope.data.event = event), ($scope.data.countdown = 0), ($scope.data.countdownInterval = null);
1583 var time = moment.duration(event.payment.timeout, "seconds").asSeconds();
1584 $scope.updateCountdown(time), $scope.startCountdownInterval(event.payment.timeout), ($scope.isLoading = !1);
1585 });
1586 }),
1587 $scope.$on("$ionicView.beforeLeave", function () {
1588 $scope.stopCountdownInterval();
1589 }),
1590 $scope.$on("eventReservation.pause", function () {
1591 ($scope.isLoading = !0), $scope.stopCountdownInterval();
1592 }),
1593 $scope.$on("eventReservation.resume", function () {
1594 ($scope.isLoading = !0),
1595 $scope.getEventTimeout($stateParams.id, function (timeout) {
1596 timeout && ($scope.data.event.payment.timeout = timeout);
1597 var time = moment.duration($scope.data.event.payment.timeout, "seconds").asSeconds();
1598 $scope.updateCountdown(time), $scope.startCountdownInterval($scope.data.event.payment.timeout), ($scope.isLoading = !1);
1599 });
1600 });
1601 },
1602 ]),
1603 angular.module("app").controller("EventRulesController", [
1604 "$scope",
1605 "$stateParams",
1606 "$timeout",
1607 "$ionicHistory",
1608 "Config",
1609 "EventService",
1610 "Utils",
1611 "Operator",
1612 function ($scope, $stateParams, $timeout, $ionicHistory, Config, EventService, Utils, Operator) {
1613 ($scope.parseApiError = function (error) {
1614 var message;
1615 switch (((error = error || {}).code || (error.code = 201), error.code)) {
1616 case 108:
1617 var timeout = $timeout(function () {
1618 Utils.switchState($scope.data.referrer.stateName, "slide-right"), $timeout.cancel(timeout);
1619 }, Config.timeoutDelay.invalidEvent);
1620 return;
1621 default:
1622 message = { translate: "notification.error.unexpectedError", translateValues: { code: error.code } };
1623 }
1624 message && Operator.send("notification.show", { type: "error", message: message });
1625 }),
1626 ($scope.getEventRules = function (callback) {
1627 var params = { event_id: $stateParams.id };
1628 EventService.getEventRules(params).then(function (response) {
1629 if (response.timeout)
1630 Operator.send("api.timeout", {
1631 callback: function () {
1632 $scope.getEvent($stateParams.id, callback);
1633 },
1634 });
1635 else if (((response.data = response.data || {}), response.data.success)) {
1636 var event = {
1637 store: {
1638 logo: response.data.payload.store.logo,
1639 name: response.data.payload.store.name,
1640 city: response.data.payload.store.city,
1641 address: response.data.payload.store.address,
1642 postalCode: response.data.payload.store.postal_code,
1643 },
1644 rules: response.data.payload.rules,
1645 };
1646 "function" == typeof callback && callback(event);
1647 } else $scope.parseApiError(response.data.error);
1648 });
1649 }),
1650 $scope.$on("$ionicView.loaded", function () {
1651 ($scope.header = { theme: "white", title: { translate: "eventRules.header.title", translateValues: {} }, buttons: { back: !0 } }),
1652 ($scope.data = { referrer: $ionicHistory.backView() || {} }),
1653 Operator.send("statusbar.update", { theme: $scope.header.theme });
1654 }),
1655 $scope.$on("$ionicView.beforeEnter", function () {
1656 ($scope.isLoading = !0),
1657 $scope.getEventRules(function (event) {
1658 ($scope.data.event = event), ($scope.isLoading = !1);
1659 });
1660 }),
1661 $scope.$on("event.pause", function () {}),
1662 $scope.$on("event.resume", function () {});
1663 },
1664 ]),
1665 angular.module("app").controller("EventWaitingListController", [
1666 "$scope",
1667 "$stateParams",
1668 "$timeout",
1669 "$interval",
1670 "$translate",
1671 "Config",
1672 "Storage",
1673 "User",
1674 "EventService",
1675 "Utils",
1676 "Operator",
1677 function ($scope, $stateParams, $timeout, $interval, $translate, Config, Storage, User, EventService, Utils, Operator) {
1678 ($scope.parseApiError = function (error) {
1679 var message;
1680 switch (((error = error || {}).code || (error.code = 201), error.code)) {
1681 case 108:
1682 return void Utils.switchState("latestEvents", "slide-right");
1683 case 116:
1684 case 124:
1685 return void Utils.switchState("event", "slide-right", { id: $stateParams.id, status: "noSize" });
1686 case 117:
1687 return void Utils.switchState("event", "slide-right", { id: $stateParams.id });
1688 default:
1689 message = { translate: "notification.error.unexpectedError", translateValues: { code: error.code } };
1690 }
1691 message && Operator.send("notification.show", { type: "error", message: message });
1692 }),
1693 ($scope.getEvent = function (callback) {
1694 var params = { event_id: $stateParams.id };
1695 EventService.getEvent(params).then(function (response) {
1696 if (response.timeout)
1697 Operator.send("api.timeout", {
1698 callback: function () {
1699 $scope.getEvent($stateParams.id, callback);
1700 },
1701 });
1702 else if (((response.data = response.data || {}), response.data.success)) {
1703 if ("rsvp" !== response.data.payload.event.type) return void Utils.switchState("event", "slide-right", { id: $stateParams.id });
1704 var event = {
1705 type: "rsvp",
1706 product: { name: response.data.payload.event.product.name, images: response.data.payload.event.product.images || [], sizeType: null },
1707 store: { name: response.data.payload.store.name, city: response.data.payload.store.city },
1708 };
1709 response.data.payload.event.product.sizes
1710 ? ((event.product.sizeType = response.data.payload.event.product.sizes.type || null), "shoe" === event.product.sizeType && (event.product.sizeType = "footwear"))
1711 : (event.product.sizeType = "other"),
1712 "function" == typeof callback && callback(event);
1713 } else $scope.parseApiError(response.data.error);
1714 });
1715 }),
1716 ($scope.getEventCopStatus = function (callback) {
1717 var params = { event_id: $stateParams.id };
1718 EventService.getEventCopStatus(params).then(function (response) {
1719 if (response.timeout)
1720 Operator.send("api.timeout", {
1721 callback: function () {
1722 $scope.getEventCopStatus($stateParams.id, callback);
1723 },
1724 });
1725 else {
1726 if (((response.data = response.data || {}), response.data.success)) {
1727 if (!0 === response.data.payload.is_sold_out) return void Utils.switchState("event", "slide-right", { id: $stateParams.id });
1728 var key,
1729 shoeSize,
1730 sizeFound = !1;
1731 switch (response.data.payload.sizes.type) {
1732 case "time":
1733 for (key in response.data.payload.sizes.slots) {
1734 var timeSlot = response.data.payload.sizes.slots[key];
1735 if (timeSlot.size === $scope.data.user.timeSlot.value) {
1736 if (((sizeFound = !0), timeSlot.available)) return void $scope.copEvent();
1737 if (!timeSlot.available && !timeSlot.pending) return void Utils.switchState("event", "slide-right", { id: $stateParams.id });
1738 }
1739 }
1740 break;
1741 case "shoe":
1742 for (key in response.data.payload.sizes[$scope.data.user.footwearSize.gender])
1743 if (((shoeSize = response.data.payload.sizes[$scope.data.user.footwearSize.gender][key]), parseFloat(shoeSize.size) === parseFloat($scope.data.user.footwearSize.size))) {
1744 if (((sizeFound = !0), shoeSize.available)) return void $scope.copEvent();
1745 if (!shoeSize.available && !shoeSize.pending) return void Utils.switchState("event", "slide-right", { id: $stateParams.id });
1746 }
1747 break;
1748 case "apparel":
1749 for (key in response.data.payload.sizes[$scope.data.user.apparelSize.gender])
1750 if ((shoeSize = response.data.payload.sizes[$scope.data.user.apparelSize.gender][key]).size === $scope.data.user.apparelSize.size) {
1751 if (((sizeFound = !0), shoeSize.available)) return void $scope.copEvent();
1752 if (!shoeSize.available && !shoeSize.pending) return void Utils.switchState("event", "slide-right", { id: $stateParams.id });
1753 }
1754 break;
1755 case "other":
1756 var any = response.data.payload.sizes.any[0];
1757 if (((sizeFound = !(!any.available && !any.pending)), any.available)) return void $scope.copEvent();
1758 if (!any.available && !any.pending) return void Utils.switchState("event", "slide-right", { id: $stateParams.id });
1759 }
1760 if (!sizeFound) return void Utils.switchState("event", "slide-right", { id: $stateParams.id });
1761 } else $scope.parseApiError(response.data.error);
1762 "function" == typeof callback && callback();
1763 }
1764 });
1765 }),
1766 ($scope.copEvent = function () {
1767 var params = { event_id: $stateParams.id };
1768 switch ($scope.data.event.product.sizeType) {
1769 case "time":
1770 (params.size_type = "time"), (params.time_slot = $scope.data.user.timeSlot.value);
1771 break;
1772 case "footwear":
1773 (params.size_type = "shoe"), (params.size_value = $scope.data.user.footwearSize.size), (params.size_gender = $scope.data.user.footwearSize.gender);
1774 break;
1775 case "apparel":
1776 (params.size_type = "apparel"), (params.size_value = $scope.data.user.apparelSize.size), (params.size_gender = $scope.data.user.apparelSize.gender);
1777 break;
1778 case "other":
1779 params.size_type = "other";
1780 }
1781 EventService.copEvent(params).then(function (response) {
1782 response.timeout
1783 ? Operator.send("api.timeout", {
1784 callback: function () {
1785 ($scope.isSaving = !1), $scope.copEvent();
1786 },
1787 })
1788 : ((response.data = response.data || {}), response.data.success ? Utils.switchState("eventReservation", "slide-left", { id: $stateParams.id }) : $scope.parseApiError(response.data.error));
1789 });
1790 }),
1791 ($scope.exitWaitinglist = function () {
1792 Operator.send("dialog", {
1793 type: "confirm",
1794 title: $translate.instant("dialog.exitWaitingList.title"),
1795 text: $translate.instant("dialog.exitWaitingList.text"),
1796 action: [$translate.instant("dialog.exitWaitingList.action.cancel"), $translate.instant("dialog.exitWaitingList.action.confirm")],
1797 callback: function (index) {
1798 2 === index && Utils.switchState("event", "slide-right", { id: $stateParams.id });
1799 },
1800 });
1801 }),
1802 ($scope.updateCountdown = function (time) {
1803 var seconds,
1804 duration = moment.duration(time, "seconds");
1805 seconds = duration.asSeconds();
1806 var mm = duration.minutes() < 10 ? "0" + duration.minutes() : duration.minutes(),
1807 ss = duration.seconds() < 10 ? "0" + duration.seconds() : duration.seconds();
1808 if ((($scope.data.countdown = mm + ":" + ss), seconds < 1)) {
1809 $scope.stopCountdownInterval(), ($scope.isChecking = !0);
1810 var timeout = $timeout(function () {
1811 $scope.getEventCopStatus(function () {
1812 ($scope.isChecking = !1), $scope.updateCountdown(Config.intervalDelay.copStatus), $scope.startCountdownInterval(Config.intervalDelay.copStatus);
1813 }),
1814 $timeout.cancel(timeout);
1815 }, 1e3);
1816 } else;
1817 }),
1818 ($scope.startCountdownInterval = function (time) {
1819 var duration = moment.duration(time, "seconds");
1820 $scope.stopCountdownInterval(),
1821 ($scope.data.countdownInterval = $interval(function () {
1822 (duration = moment.duration(duration.asSeconds() - 1, "seconds")), $scope.updateCountdown(duration.asSeconds());
1823 }, 1e3));
1824 }),
1825 ($scope.stopCountdownInterval = function () {
1826 $scope.data.countdownInterval && ($interval.cancel($scope.data.countdownInterval), ($scope.data.countdownInterval = null));
1827 }),
1828 $scope.$on("$ionicView.loaded", function () {
1829 ($scope.header = { theme: "white", title: { translate: "eventWaitingList.header.title", translateValues: {} }, buttons: { back: !0 } }),
1830 ($scope.data = { user: { footwearSize: Storage.get("eventCustomSize") || User.sizes.footwear, apparelSize: Storage.get("eventCustomSize") || User.sizes.apparel, timeSlot: Storage.get("eventCustomSlot") || {} } }),
1831 Operator.send("statusbar.update", { theme: $scope.header.theme });
1832 }),
1833 $scope.$on("$ionicView.beforeEnter", function () {
1834 ($scope.isLoading = !0),
1835 ($scope.isChecking = !1),
1836 $scope.getEvent(function (event) {
1837 ($scope.data.event = event),
1838 ($scope.data.countdown = 0),
1839 ($scope.data.countdownInterval = null),
1840 $scope.updateCountdown(Config.intervalDelay.copStatus),
1841 $scope.startCountdownInterval(Config.intervalDelay.copStatus),
1842 ($scope.isLoading = !1);
1843 });
1844 }),
1845 $scope.$on("$ionicView.beforeLeave", function () {
1846 $scope.stopCountdownInterval();
1847 }),
1848 $scope.$on("eventReservation.pause", function () {
1849 $scope.stopCountdownInterval();
1850 }),
1851 $scope.$on("eventReservation.resume", function () {
1852 $scope.updateCountdown(Config.intervalDelay.copStatus), $scope.startCountdownInterval(Config.intervalDelay.copStatus);
1853 });
1854 },
1855 ]),
1856 angular.module("app").controller("EventController", [
1857 "$scope",
1858 "$stateParams",
1859 "$timeout",
1860 "$ionicHistory",
1861 "Config",
1862 "Storage",
1863 "User",
1864 "EventService",
1865 "Utils",
1866 "Geolocation",
1867 "Beacon",
1868 "Map",
1869 "Diagnostic",
1870 "Operator",
1871 function ($scope, $stateParams, $timeout, $ionicHistory, Config, Storage, User, EventService, Utils, Geolocation, Beacon, Map, Diagnostic, Operator) {
1872 ($scope.parseApiError = function (error) {
1873 var message;
1874 switch (((error = error || {}).code || (error.code = 201), error.code)) {
1875 case 108:
1876 var timeout = $timeout(function () {
1877 Utils.switchState($scope.data.referrer.stateName, "slide-right", $scope.data.referrer.stateParams || {}), $timeout.cancel(timeout);
1878 }, Config.timeoutDelay.invalidEvent);
1879 return;
1880 case 116:
1881 case 124:
1882 ($scope.data.event.isSizeNotAvailable = !0), ($scope.data.event.status = "noSize"), $scope.updateView();
1883 break;
1884 case 117:
1885 ($scope.data.event.isSoldOut = !0), ($scope.data.event.status = "soldOut"), $scope.updateView();
1886 break;
1887 case 120:
1888 case 137:
1889 message = { translate: "notification.error.noSizeSelection", translateValues: {} };
1890 break;
1891 case 136:
1892 return void Utils.switchState("eventWaitingList", "slide-left", { id: $stateParams.id });
1893 case 139:
1894 message = { translate: "notification.error.noTimeslotSelection", translateValues: {} };
1895 break;
1896 case 140:
1897 message = { translate: "notification.error.deviceAlreadyUse", translateValues: {} };
1898 break;
1899 default:
1900 message = { translate: "notification.error.unexpectedError", translateValues: { code: error.code } };
1901 }
1902 message && Operator.send("notification.show", { type: "error", message: message });
1903 }),
1904 ($scope.getEvent = function (eventId, callback) {
1905 var params = { event_id: eventId };
1906 EventService.getEvent(params).then(function (response) {
1907 if (response.timeout)
1908 Operator.send("api.timeout", {
1909 callback: function () {
1910 $scope.getEvent(eventId, callback);
1911 },
1912 });
1913 else if (((response.data = response.data || {}), response.data.success)) {
1914 var event = {
1915 id: response.data.payload.event.id,
1916 type: "rsvp" === response.data.payload.event.type ? "rsvp" : "list",
1917 product: { name: response.data.payload.event.product.name, images: response.data.payload.event.product.images || [], sizeType: null },
1918 store: { logo: response.data.payload.store.logo, name: response.data.payload.store.name, city: response.data.payload.store.city },
1919 hasInventory: !1 !== response.data.payload.event.inventory_set,
1920 isLocalOnly: response.data.payload.event.is_local_only || !1,
1921 isInStoreOnly: response.data.payload.event.is_instore_only || !1,
1922 isSoldOut: response.data.payload.event.is_sold_out || !1,
1923 isSizeNotAvailable: !1,
1924 isUnlocked: !0,
1925 status: !0 !== response.data.payload.event.is_active ? "upcoming" : "active",
1926 },
1927 offset = moment().utcOffset(),
1928 date = moment(response.data.payload.event.date).utcOffset(offset);
1929 "upcoming" === event.status
1930 ? ((event.date = date.format(Config.default.dateFormat)),
1931 (event.isLocalOnly || event.isInStoreOnly) &&
1932 ((event.isUnlocked = !1), (event.geofence = response.data.payload.event.geofence || {}), event.isInStoreOnly && ((event.geofence.radius = 0), (event.isInStoreOnly = !1), (event.isLocalOnly = !0))))
1933 : ((event.date = date.format(Config.default.dateTimeFormat)),
1934 event.isSoldOut
1935 ? (event.status = "soldOut")
1936 : (response.data.payload.event.product.sizes
1937 ? ((event.hasInventory = !0), (event.product.sizeType = response.data.payload.event.product.sizes.type || null), "shoe" === event.product.sizeType && (event.product.sizeType = "footwear"))
1938 : (event.product.sizeType = "other"),
1939 (event.isLocalOnly || event.isInStoreOnly) &&
1940 ((event.isUnlocked = !1),
1941 event.isLocalOnly ? (event.geofence = response.data.payload.event.geofence || {}) : (event.beacon = response.data.payload.event.beacon || {}),
1942 Geolocation.setConfig({
1943 desiredAccuracy: 0,
1944 stopOnTerminate: !0,
1945 useSignificantChangesOnly: !0,
1946 locationAuthorizationRequest: "WhenInUse",
1947 disableMotionActivityUpdates: !0,
1948 maxRecordsToPersist: 0,
1949 }),
1950 (Geolocation.providerChangeCallback = function () {
1951 var timeout = $timeout(function () {
1952 switch (Geolocation.providerStatus) {
1953 case Geolocation.instance.AUTHORIZATION_STATUS_ALWAYS:
1954 case Geolocation.instance.AUTHORIZATION_STATUS_WHEN_IN_USE:
1955 User.isLocationShared || ($scope.data.event.isLocalOnly ? $scope.startGeofencing() : $scope.data.event.isInStoreOnly && $scope.startBeacon()), User.shareLocation(!0);
1956 break;
1957 default:
1958 User.isLocationShared && ($scope.data.event.isLocalOnly ? $scope.stopGeofencing() : $scope.data.event.isInStoreOnly && $scope.stopBeacon()), User.shareLocation(!1);
1959 }
1960 $timeout.cancel(timeout);
1961 });
1962 })))),
1963 "function" == typeof callback && callback(event);
1964 } else $scope.parseApiError(response.data.error);
1965 });
1966 }),
1967 ($scope.dropEvent = function () {
1968 var params = { event_id: $scope.data.event.id };
1969 EventService.dropEvent(params), Utils.switchState("latestEvents", "slide-right");
1970 }),
1971 ($scope.copEvent = function () {
1972 if (!$scope.isSaving) {
1973 var params = { event_id: $scope.data.event.id };
1974 switch ($scope.data.event.product.sizeType) {
1975 case "time":
1976 if (!$scope.data.user.timeSlot.value) return void $scope.parseApiError({ code: 139 });
1977 (params.size_type = "time"), (params.time_slot = $scope.data.user.timeSlot.value);
1978 break;
1979 case "footwear":
1980 if (!$scope.data.user.footwearSize.size || !$scope.data.user.footwearSize.gender) return void $scope.parseApiError({ code: 120 });
1981 (params.size_type = "shoe"), (params.size_value = $scope.data.user.footwearSize.size || ""), (params.size_gender = $scope.data.user.footwearSize.gender || "");
1982 break;
1983 case "apparel":
1984 if (!$scope.data.user.footwearSize.size || !$scope.data.user.footwearSize.gender) return void $scope.parseApiError({ code: 137 });
1985 (params.size_type = "apparel"), (params.size_value = $scope.data.user.apparelSize.size || ""), (params.size_gender = $scope.data.user.apparelSize.gender || "");
1986 break;
1987 default:
1988 params.size_type = "other";
1989 }
1990 ($scope.isSaving = !0),
1991 EventService.copEvent(params).then(function (response) {
1992 response.timeout
1993 ? Operator.send("api.timeout", {
1994 callback: function () {
1995 ($scope.isSaving = !1), $scope.copEvent();
1996 },
1997 })
1998 : ((response.data = response.data || {}),
1999 response.data.success
2000 ? "rsvp" === $scope.data.event.type
2001 ? Utils.switchState("eventReservation", "slide-left", { id: $scope.data.event.id })
2002 : Utils.switchState("eventEnteringConfirmed", "slide-up", { id: $scope.data.event.id })
2003 : ($scope.parseApiError(response.data.error), ($scope.isSaving = !1)));
2004 });
2005 }
2006 }),
2007 ($scope.shareLocation = function () {
2008 switch (User.isLocationShared) {
2009 case !0:
2010 case !1:
2011 Operator.send("osSettings.open", { setting: "iOS" === Storage.get("deviceOs") ? "application_details" : "location" });
2012 break;
2013 default:
2014 Geolocation.init(function () {
2015 Geolocation.start();
2016 });
2017 }
2018 }),
2019 ($scope.startGeofencing = function (callback) {
2020 Geolocation.setGeofence({
2021 identifier: "eid" + $scope.data.event.id,
2022 latitude: $scope.data.event.geofence.lat,
2023 longitude: $scope.data.event.geofence.lon,
2024 radius: 1e3,
2025 notifyOnEntry: !0,
2026 notifyOnExit: !0,
2027 notifyOnDwell: !0,
2028 loiteringDelay: 3e4,
2029 extras: {},
2030 }),
2031 (Geolocation.geofencesChangeCallback = function (event) {
2032 var on = !1;
2033 for (var key in event.on) event.on[key].identifier === Geolocation.geofence.identifier && (on = !0);
2034 var timeout = $timeout(function () {
2035 $scope.hasBeenUnlocked
2036 ? $scope.data.event.isSoldOut
2037 ? ($scope.data.event.status = "soldOut")
2038 : $scope.data.event.isSizeNotAvailable
2039 ? ($scope.data.event.status = "noSize")
2040 : ($scope.data.event.status = "active")
2041 : on
2042 ? $scope.data.event.isSoldOut
2043 ? ($scope.data.event.status = "soldOut")
2044 : $scope.data.event.isSizeNotAvailable
2045 ? ($scope.data.event.status = "noSize")
2046 : ($scope.data.event.status = "active")
2047 : ($scope.data.event.status = "localOutOfRange"),
2048 $scope.updateView(),
2049 $scope.data.geofenceDetectionTimeout && "function" == typeof callback && callback(),
2050 $timeout.cancel(timeout);
2051 });
2052 }),
2053 (Geolocation.positionCallback = function (position) {
2054 var isBlocked = !1;
2055 position.mock && (isBlocked = !0);
2056 var altitude = position.coords.altitude || 0,
2057 altitudeAccuracy = position.coords.altitude_accuracy || 0,
2058 speed = position.coords.speed || 0;
2059 if ((altitude || -1 !== altitudeAccuracy || -1 !== speed || (isBlocked = !0), isBlocked)) return ($scope.data.event.status = "localOutOfRange"), $scope.updateView(), void Map.clearUser();
2060 Map.setUser(position.coords.latitude, position.coords.longitude);
2061 }),
2062 Geolocation.init(function () {
2063 Geolocation.startGeofences(),
2064 Geolocation.addGeofence(),
2065 Geolocation.setGeofenceProximityRadius($scope.data.event.geofence.radius),
2066 Geolocation.instance
2067 ? ($scope.data.geofenceDetectionTimeout = $timeout(function () {
2068 switch (Geolocation.providerStatus) {
2069 case Geolocation.instance.AUTHORIZATION_STATUS_ALWAYS:
2070 case Geolocation.instance.AUTHORIZATION_STATUS_WHEN_IN_USE:
2071 $scope.data.event.status = "localOutOfRange";
2072 break;
2073 default:
2074 $scope.data.event.status = "localUnauthorized";
2075 }
2076 $scope.updateView(), "function" == typeof callback && callback();
2077 }, Config.timeoutDelay.geofenceFirstTimeDetection))
2078 : ($scope.data.event.status = "localUnauthorized");
2079 });
2080 }),
2081 ($scope.stopGeofencing = function () {
2082 Geolocation.removeGeofences(), Geolocation.stop();
2083 }),
2084 ($scope.resetGeofencing = function () {
2085 $scope.stopGeofencing(),
2086 ($scope.isSaving = !0),
2087 $scope.startGeofencing(function () {
2088 $scope.data.geofenceDetectionTimeout && ($timeout.cancel($scope.data.geofenceDetectionTimeout), ($scope.data.geofenceDetectionTimeout = null)), ($scope.isSaving = !1);
2089 }),
2090 ($scope.data.geofenceDetectionTimeout = $timeout(function () {
2091 ($scope.isSaving = !1), $scope.updateView(), $timeout.cancel($scope.data.geofenceDetectionTimeout), ($scope.data.geofenceDetectionTimeout = null);
2092 }, Config.timeoutDelay.geofenceDetection));
2093 }),
2094 ($scope.startBeacon = function (callback) {
2095 ($scope.data.event.status = User.isLocationShared ? "inStoreOutOfRange" : "inStoreUnauthorized"),
2096 Beacon.setRegion($scope.data.event.store.name, $scope.data.event.beacon.uuid, $scope.data.event.beacon.major, $scope.data.event.beacon.minor),
2097 Beacon.startRanging(
2098 function (result) {
2099 if ($scope.hasBeenUnlocked)
2100 $scope.data.event.isSoldOut ? ($scope.data.event.status = "soldOut") : $scope.data.event.isSizeNotAvailable ? ($scope.data.event.status = "noSize") : ($scope.data.event.status = "active");
2101 else if (0 < result.beacons.length) {
2102 var beaconRegion,
2103 distance,
2104 beacon = result.beacons[0];
2105 (distance =
2106 "iOS" === Storage.get("deviceOs")
2107 ? ((beaconRegion = beacon.proximityUUID + ":" + beacon.major + ":" + beacon.minor), beacon.distance)
2108 : ((beaconRegion = beacon.uuid.toUpperCase() + ":" + beacon.major + ":" + beacon.minor), beacon.accuracy)),
2109 beaconRegion != Beacon.getRegion()
2110 ? ($scope.data.event.status = "inStoreOutOfRange")
2111 : 0 <= distance &&
2112 (distance <= $scope.data.event.beacon.nearRadius
2113 ? $scope.data.event.isSoldOut
2114 ? ($scope.data.event.status = "soldOut")
2115 : $scope.data.event.isSizeNotAvailable
2116 ? ($scope.data.event.status = "noSize")
2117 : ($scope.data.event.status = "active")
2118 : distance <= $scope.data.event.beacon.farRadius
2119 ? ($scope.data.event.status = "inStoreTooFar")
2120 : ($scope.data.event.status = "inStoreOutOfRange"));
2121 } else $scope.data.event.status = "inStoreOutOfRange";
2122 $scope.updateView(), "function" == typeof callback && callback();
2123 },
2124 function (error) {
2125 ($scope.data.event.status = "inStoreUnauthorized"), $scope.updateView(), "function" == typeof callback && callback();
2126 }
2127 );
2128 }),
2129 ($scope.stopBeacon = function () {
2130 Beacon.stopRanging();
2131 }),
2132 ($scope.updateView = function () {
2133 var timeout = $timeout(function () {
2134 switch ($scope.data.event.status) {
2135 case "rooted":
2136 ($scope.hasFooter = !1),
2137 ($scope.header.title = { translate: "event.header.title.rooted", translateValues: {} }),
2138 ($scope.data.event.isUnlocked = !1),
2139 ($scope.data.event.isLocalOnly || $scope.data.event.isInStoreOnly) &&
2140 ($scope.isMapReady ||
2141 Map.init($scope.data.event.geofence.lat, $scope.data.event.geofence.lon, $scope.data.event.geofence.radius, function () {
2142 $scope.isMapReady = !0;
2143 }));
2144 break;
2145 case "localUnauthorized":
2146 case "localOutOfRange":
2147 ($scope.hasFooter = !0),
2148 ($scope.header.title = { translate: "event.header.title.notLocal", translateValues: {} }),
2149 ($scope.data.event.isUnlocked = !1),
2150 $scope.isMapReady ||
2151 Map.init($scope.data.event.geofence.lat, $scope.data.event.geofence.lon, $scope.data.event.geofence.radius, function () {
2152 $scope.isMapReady = !0;
2153 });
2154 break;
2155 case "inStoreUnauthorized":
2156 case "inStoreTooFar":
2157 case "inStoreOutOfRange":
2158 ($scope.hasFooter = "inStoreUnauthorized" === $scope.data.event.status), ($scope.header.title = { translate: "event.header.title.notInStore", translateValues: {} }), ($scope.data.event.isUnlocked = !1);
2159 break;
2160 case "upcoming":
2161 ($scope.hasFooter = !0),
2162 ($scope.header.title = { translate: "event.header.title.upcoming", translateValues: {} }),
2163 ($scope.data.event.isLocalOnly || $scope.data.event.isInStoreOnly) &&
2164 ($scope.isMapReady ||
2165 Map.init($scope.data.event.geofence.lat, $scope.data.event.geofence.lon, $scope.data.event.geofence.radius, function () {
2166 $scope.isMapReady = !0;
2167 }));
2168 break;
2169 case "active":
2170 ($scope.hasBeenUnlocked = !0),
2171 ($scope.hasFooter = !0),
2172 ($scope.header.title = { translate: "event.header.title." + $scope.data.event.type, translateValues: {} }),
2173 ($scope.data.event.isSoldOut = !1),
2174 ($scope.data.event.isSizeNotAvailable = !1),
2175 ($scope.data.event.isUnlocked = !0);
2176 break;
2177 case "soldOut":
2178 case "noSize":
2179 ($scope.hasBeenUnlocked = !0),
2180 ($scope.hasFooter = !0),
2181 ($scope.header.title = { translate: "event.header.title." + $scope.data.event.status, translateValues: {} }),
2182 ($scope.data.event.isSoldOut = "soldOut" === $scope.data.event.status),
2183 ($scope.data.event.isSizeNotAvailable = "noSize" === $scope.data.event.status),
2184 ($scope.data.event.isUnlocked = !0);
2185 }
2186 $timeout.cancel(timeout);
2187 });
2188 }),
2189 ($scope.goTo = function ($event, stateName, transition, stateParams) {
2190 Utils.goTo($event, stateName, transition, stateParams);
2191 }),
2192 $scope.$on("$ionicView.loaded", function () {
2193 ($scope.header = { theme: "black", title: {}, buttons: { back: !0 } }),
2194 ($scope.data = {
2195 referrer: $ionicHistory.backView() || {},
2196 user: { footwearSize: Storage.get("eventCustomSize") || User.sizes.footwear, apparelSize: Storage.get("eventCustomSize") || User.sizes.apparel, timeSlot: Storage.get("eventCustomSlot") || {} },
2197 }),
2198 Operator.send("splashscreen.hide"),
2199 Operator.send("statusbar.update", { theme: $scope.header.theme });
2200 }),
2201 $scope.$on("$ionicView.beforeEnter", function () {
2202 ($scope.isLoading = !0),
2203 ($scope.isSaving = !1),
2204 ($scope.isMapReady = !1),
2205 ($scope.hasBeenUnlocked = !1),
2206 ($scope.hasFooter = !1),
2207 (window.localStorage.getItem("schemeUrl") || null) && (window.localStorage.removeItem("schemeUrl"), Storage.unset("schemeRedirection")),
2208 Diagnostic.isLocationAuthorized(function (authorized) {
2209 authorized && User.shareLocation(!0);
2210 }),
2211 $scope.getEvent($stateParams.id, function (event) {
2212 ($scope.data.event = event),
2213 Diagnostic.isDeviceRooted()
2214 ? (($scope.data.event.status = "rooted"), ($scope.isLoading = !1), $scope.updateView())
2215 : "active" === $scope.data.event.status && $scope.data.event.isLocalOnly
2216 ? User.isLocationShared
2217 ? $scope.startGeofencing(function () {
2218 $scope.data.geofenceDetectionTimeout && ($timeout.cancel($scope.data.geofenceDetectionTimeout), ($scope.data.geofenceDetectionTimeout = null)), ($scope.isLoading = !1);
2219 })
2220 : (($scope.data.event.status = "localUnauthorized"), ($scope.isLoading = !1), $scope.updateView())
2221 : "active" === $scope.data.event.status && $scope.data.event.isInStoreOnly
2222 ? User.isLocationShared
2223 ? ($scope.startBeacon(function () {
2224 $scope.data.beaconDetectionTimeout && ($timeout.cancel($scope.data.beaconDetectionTimeout), ($scope.data.beaconDetectionTimeout = null)), ($scope.isLoading = !1);
2225 }),
2226 ($scope.data.beaconDetectionTimeout = $timeout(function () {
2227 ($scope.isLoading = !1), $scope.updateView(), $timeout.cancel($scope.data.beaconDetectionTimeout), ($scope.data.beaconDetectionTimeout = null);
2228 }, Config.timeoutDelay.beaconDetection)))
2229 : (($scope.data.event.status = "inStoreUnauthorized"), ($scope.isLoading = !1), $scope.updateView())
2230 : (($scope.isLoading = !1), $scope.updateView()),
2231 User.getNotifications();
2232 });
2233 }),
2234 $scope.$on("$ionicView.beforeLeave", function () {
2235 User.isLocationShared && (($scope.data.event = $scope.data.event || {}), $scope.data.event.isLocalOnly ? ($scope.stopGeofencing(), Map.clear()) : $scope.data.event.isInStoreOnly && $scope.stopBeacon());
2236 }),
2237 $scope.$on("event.pause", function () {}),
2238 $scope.$on("event.resume", function () {});
2239 },
2240 ]),
2241 angular.module("app").controller("FaqController", [
2242 "$scope",
2243 "Config",
2244 "ContentService",
2245 "Operator",
2246 function ($scope, Config, ContentService, Operator) {
2247 ($scope.loadContent = function (callback) {
2248 ContentService.loadContent(Config.copdate.faqUrl).then(
2249 function (response) {
2250 response.timeout
2251 ? Operator.send("api.timeout", {
2252 callback: function () {
2253 $scope.loadContent(callback);
2254 },
2255 })
2256 : response.data && "function" == typeof callback && callback(response.data);
2257 },
2258 function (response) {}
2259 );
2260 }),
2261 $scope.$on("$ionicView.loaded", function () {
2262 ($scope.header = { theme: "white", title: { translate: "faq.header.title", translateValues: {} }, buttons: { back: !0 } }), ($scope.data = {}), Operator.send("statusbar.update", { theme: $scope.header.theme });
2263 }),
2264 $scope.$on("$ionicView.beforeEnter", function () {
2265 ($scope.isLoading = !0),
2266 $scope.loadContent(function (content) {
2267 ($scope.data.content = content), ($scope.isLoading = !1);
2268 });
2269 }),
2270 $scope.$on("faq.pause", function () {}),
2271 $scope.$on("faq.resume", function () {});
2272 },
2273 ]),
2274 angular.module("app").controller("ForgotPasswordController", [
2275 "$scope",
2276 "$timeout",
2277 "Config",
2278 "Storage",
2279 "User",
2280 "UserService",
2281 "Utils",
2282 "FormService",
2283 "Operator",
2284 function ($scope, $timeout, Config, Storage, User, UserService, Utils, FormService, Operator) {
2285 ($scope.setForm = function () {
2286 $scope.data.form = FormService.setForm({
2287 value: { email: "" },
2288 error: { email: "" },
2289 errorMessages: { email: { required: "field.error.email.required", pattern: "field.error.email.pattern", notFound: "field.error.email.notFound" } },
2290 });
2291 }),
2292 ($scope.validateField = function (field) {
2293 FormService.validateField($scope.form, field);
2294 }),
2295 ($scope.validateForm = function () {
2296 return FormService.validateForm($scope.form);
2297 }),
2298 ($scope.parseApiError = function (error) {
2299 var message = { translate: "notification.error.invalidData", translateValues: {} };
2300 switch (((error = error || {}).code || (error.code = 201), error.code)) {
2301 case 119:
2302 FormService.newScheme.error.email = FormService.errorMessages.email.notFound;
2303 break;
2304 default:
2305 message = { translate: "notification.error.unexpectedError", translateValues: { code: error.code } };
2306 }
2307 Operator.send("notification.show", { type: "error", message: message });
2308 }),
2309 ($scope.onSubmit = function () {
2310 if (!$scope.isSaving && $scope.validateForm()) {
2311 $scope.isSaving = !0;
2312 var params = angular.copy(FormService.newScheme.value);
2313 UserService.resetPassword(params).then(function (response) {
2314 response.timeout
2315 ? Operator.send("api.timeout", {
2316 callback: function () {
2317 ($scope.isSaving = !1), $scope.onSubmit();
2318 },
2319 })
2320 : ((response.data = response.data || {}),
2321 response.data.success
2322 ? (Operator.send("notification.show", { type: "success", message: { translate: "notification.success.resetPassword" } }), Utils.switchState("signIn", "slide-right"))
2323 : $scope.parseApiError(response.data.error),
2324 ($scope.isSaving = !1));
2325 });
2326 }
2327 }),
2328 ($scope.keyboardOpened = function () {
2329 ($scope.isFieldFocus = !0), $scope.data.keyboardCloseTimeout && $timeout.cancel($scope.data.keyboardCloseTimeout);
2330 }),
2331 ($scope.keyboardClosed = function (field) {
2332 $scope.validateField(field),
2333 ($scope.data.keyboardCloseTimeout = $timeout(function () {
2334 ($scope.isFieldFocus = !1), $timeout.cancel($scope.data.keyboardCloseTimeout);
2335 }, 300));
2336 }),
2337 $scope.$on("$ionicView.loaded", function () {
2338 ($scope.header = { theme: "white", title: { translate: "forgotPassword.header.title", translateValues: {} }, buttons: { back: !0 } }),
2339 ($scope.data = { form: {}, keyboardCloseTimeout: null, modelOptions: Config.modelOptions }),
2340 Operator.send("statusbar.update", { theme: $scope.header.theme });
2341 }),
2342 $scope.$on("$ionicView.beforeEnter", function () {
2343 ($scope.isFieldFocus = !1), ($scope.isSaving = !1), $scope.setForm();
2344 }),
2345 $scope.$on("forgotPassword.pause", function () {}),
2346 $scope.$on("forgotPassword.resume", function () {});
2347 },
2348 ]),
2349 angular.module("app").controller("InsidersController", [
2350 "$scope",
2351 "$timeout",
2352 "Config",
2353 "Storage",
2354 "User",
2355 "Utils",
2356 "FormService",
2357 "Operator",
2358 function ($scope, $timeout, Config, Storage, User, Utils, FormService, Operator) {
2359 ($scope.setForm = function () {
2360 $scope.data.form = FormService.setForm({ value: { code: "" }, error: { code: "" }, errorMessages: { code: { required: "field.error.insiderCode.required" } } });
2361 }),
2362 ($scope.validateField = function (field) {
2363 FormService.validateField($scope.form, field);
2364 }),
2365 ($scope.validateForm = function () {
2366 return FormService.validateForm($scope.form);
2367 }),
2368 ($scope.onSubmit = function () {
2369 if (!$scope.isSaving && $scope.validateForm()) {
2370 $scope.isSaving = !0;
2371 var timeout = $timeout(function () {
2372 Operator.send("notification.show", { type: "error", message: { translate: "notification.error.invalidInsidersCode" } }), $scope.setForm(), ($scope.isSaving = !1), $timeout.cancel(timeout);
2373 }, 2e3);
2374 }
2375 }),
2376 ($scope.keyboardOpened = function () {
2377 ($scope.isFieldFocus = !0), $scope.data.keyboardCloseTimeout && $timeout.cancel($scope.data.keyboardCloseTimeout);
2378 }),
2379 ($scope.keyboardClosed = function (field) {
2380 $scope.validateField(field),
2381 ($scope.data.keyboardCloseTimeout = $timeout(function () {
2382 ($scope.isFieldFocus = !1), $timeout.cancel($scope.data.keyboardCloseTimeout);
2383 }, 300));
2384 }),
2385 $scope.$on("$ionicView.loaded", function () {
2386 ($scope.header = { theme: "white", title: { translate: "insiders.header.title", translateValues: {} }, buttons: { drawer: !0 } }),
2387 ($scope.data = { form: {}, keyboardCloseTimeout: null, modelOptions: Config.modelOptions, density: Storage.get("deviceDensity") }),
2388 Operator.send("statusbar.update", { theme: $scope.header.theme });
2389 }),
2390 $scope.$on("$ionicView.beforeEnter", function () {
2391 ($scope.isFieldFocus = !1), ($scope.isSaving = !1), $scope.setForm();
2392 }),
2393 $scope.$on("insiders.pause", function () {}),
2394 $scope.$on("insiders.resume", function () {});
2395 },
2396 ]),
2397 angular.module("app").controller("LatestEventsController", [
2398 "$scope",
2399 "Config",
2400 "Storage",
2401 "EventService",
2402 "Utils",
2403 "Operator",
2404 function ($scope, Config, Storage, EventService, Utils, Operator) {
2405 ($scope.parseApiError = function (error) {
2406 (error = error || {}).code || (error.code = 201), Operator.send("notification.show", { type: "error", message: { translate: "notification.error.unexpectedError", translateValues: { code: error.code } } });
2407 }),
2408 ($scope.getLatestEvents = function (page, callback) {
2409 var params = { page: page || 1 };
2410 EventService.getLatestEvents(params).then(function (response) {
2411 if (response.timeout)
2412 Operator.send("api.timeout", {
2413 callback: function () {
2414 $scope.getLatestEvents(callback);
2415 },
2416 });
2417 else if (((response.data = response.data || {}), response.data.success)) {
2418 var nextPage,
2419 events = [];
2420 for (var key in response.data.payload.events) {
2421 var event = {
2422 id: response.data.payload.events[key].event.id,
2423 type: "rsvp" === response.data.payload.events[key].event.type ? "rsvp" : "list",
2424 product: {
2425 name: response.data.payload.events[key].event.product.name,
2426 images: response.data.payload.events[key].event.product.images || [],
2427 url: response.data.payload.events[key].event.product.url || null,
2428 },
2429 store: { logo: response.data.payload.events[key].store.logo, name: response.data.payload.events[key].store.name, city: response.data.payload.events[key].store.city },
2430 isLocalOnly: response.data.payload.events[key].event.is_local_only || !1,
2431 isInStoreOnly: response.data.payload.events[key].event.is_instore_only || !1,
2432 unseen: response.data.payload.events[key].event.unseen || !1,
2433 status: "active",
2434 payment: response.data.payload.events[key].event.payment || null,
2435 },
2436 offset = moment().utcOffset(),
2437 date = moment(response.data.payload.events[key].event.date).utcOffset(offset);
2438 (event.date = date.format(Config.default.dateTimeFormat)),
2439 "rsvp" === event.type && !0 === response.data.payload.events[key].event.is_sold_out
2440 ? (event.status = "soldOut")
2441 : "list" === event.type && !0 === response.data.payload.events[key].event.is_closed && (event.status = "closed"),
2442 events.push(event);
2443 }
2444 (nextPage = response.data.payload.next_page || null), "function" == typeof callback && callback(events, nextPage);
2445 } else $scope.parseApiError(response.data.error);
2446 });
2447 }),
2448 ($scope.loadEvents = function (callback) {
2449 $scope.getLatestEvents($scope.data.nextPage, function (events, nextPage) {
2450 ($scope.data.list = $scope.data.list.concat(events)),
2451 ($scope.data.nextPage = nextPage),
2452 Operator.send("scroll.infiniteScrollComplete"),
2453 ($scope.isEvents = !!$scope.data.list.length),
2454 ($scope.isMoreEvents = !!nextPage),
2455 ($scope.isLoading = !1),
2456 "function" == typeof callback && callback();
2457 });
2458 }),
2459 ($scope.refreshList = function () {
2460 ($scope.data.list = []),
2461 ($scope.data.nextPage = 1),
2462 $scope.loadEvents(function () {
2463 Operator.send("scroll.refreshComplete");
2464 });
2465 }),
2466 ($scope.getMoreEvents = function () {
2467 $scope.loadEvents();
2468 }),
2469 ($scope.goTo = function ($event, stateName, transition, stateParams) {
2470 Utils.goTo($event, stateName, transition, stateParams);
2471 }),
2472 ($scope.goToEvent = function ($event, event) {
2473 if ("soldOut" !== event.status && "closed" !== event.status) {
2474 var stateName = "event",
2475 stateParams = { id: event.id };
2476 event.payment && (stateName = 5 < event.payment.timeout ? "eventReservation" : "eventReservationTimedOut"), Utils.goTo($event, stateName, "slide-left", stateParams);
2477 }
2478 }),
2479 $scope.$on("$ionicView.loaded", function () {
2480 ($scope.header = { theme: "black", title: { translate: "latestEvents.header.title", translateValues: {} }, buttons: { drawer: !0, upcoming: !0 } }),
2481 ($scope.data = { infiniteScrollDistance: Config.infiniteScroll.distance }),
2482 Operator.send("splashscreen.hide"),
2483 Operator.send("statusbar.update", { theme: $scope.header.theme });
2484 }),
2485 $scope.$on("$ionicView.beforeEnter", function () {
2486 ($scope.isLoading = !0),
2487 ($scope.isEvents = !1),
2488 ($scope.isMoreEvents = !1),
2489 Storage.unset("event"),
2490 Storage.unset("eventCustomSize"),
2491 Storage.unset("eventCustomSlot"),
2492 ($scope.data.list = []),
2493 ($scope.data.nextPage = 1),
2494 $scope.loadEvents();
2495 }),
2496 $scope.$on("latestEvents.pause", function () {}),
2497 $scope.$on("latestEvents.resume", function () {});
2498 },
2499 ]),
2500 angular.module("app").controller("ListedEventsController", [
2501 "$scope",
2502 "Config",
2503 "Storage",
2504 "User",
2505 "UserService",
2506 "Utils",
2507 "Operator",
2508 function ($scope, Config, Storage, User, UserService, Utils, Operator) {
2509 ($scope.parseApiError = function (error) {
2510 (error = error || {}).code || (error.code = 201), Operator.send("notification.show", { type: "error", message: { translate: "notification.error.unexpectedError", translateValues: { code: error.code } } });
2511 }),
2512 ($scope.getListedEvents = function (callback) {
2513 UserService.getListedEvents().then(function (response) {
2514 if (response.timeout)
2515 Operator.send("api.timeout", {
2516 callback: function () {
2517 $scope.getListedEvents(callback);
2518 },
2519 });
2520 else if (((response.data = response.data || {}), response.data.success)) {
2521 var item,
2522 event,
2523 activedList = [],
2524 endedList = [];
2525 for (var key in response.data.payload.listed)
2526 (event = {
2527 id: (item = response.data.payload.listed[key]).event.id,
2528 date: moment.utc(item.event.date).utcOffset(moment.parseZone(item.event.date).utcOffset()).format(Config.default.dateFormat),
2529 confirmationCode: item.event.confirmation_code,
2530 userName: item.event.user_name,
2531 product: { name: item.event.product.name, images: item.event.product.images || [], sizeType: null },
2532 store: { logo: item.store.logo, name: item.store.name, city: item.store.city, address: item.store.address, postalCode: item.store.postal_code },
2533 payment: { fee: item.event.payment.fee, retailPrice: item.event.payment.retail_price },
2534 isCancelled: item.event.is_cancelled || !1,
2535 }),
2536 item.event.product.size &&
2537 ((event.product.sizeType = item.event.product.size.type || null),
2538 "shoe" === event.product.sizeType && (event.product.sizeType = "footwear"),
2539 "time" === event.product.sizeType
2540 ? (event.product.timeSlot = item.event.product.size.slot || null)
2541 : ((event.product.size = item.event.product.size.size || null), (event.product.gender = item.event.product.size.gender || null))),
2542 2 < moment().diff(moment(item.event.date), "days") ? endedList.push(event) : activedList.push(event);
2543 "function" == typeof callback && callback(activedList, endedList);
2544 } else $scope.parseApiError(response.data.error);
2545 });
2546 }),
2547 ($scope.loadEvents = function (callback) {
2548 ($scope.isEvents = !1),
2549 $scope.getListedEvents(function (activedList, endedList) {
2550 ($scope.data.activedList = activedList), ($scope.data.endedList = endedList), ($scope.isEvents = !!$scope.data[$scope.currentTab + "List"].length), "function" == typeof callback && callback();
2551 });
2552 }),
2553 ($scope.selectNavigationTab = function (tab) {
2554 ($scope.currentTab = tab),
2555 ($scope.isLoading = !0),
2556 $scope.loadEvents(function () {
2557 $scope.isLoading = !1;
2558 });
2559 }),
2560 ($scope.goTo = function ($event, stateName, transition, stateParams) {
2561 Utils.goTo($event, stateName, transition, stateParams);
2562 }),
2563 $scope.$on("$ionicView.loaded", function () {
2564 ($scope.currentTab = ""),
2565 ($scope.header = { theme: "black", title: { translate: "listedEvents.header.title", translateValues: {} }, buttons: { drawer: !0 } }),
2566 ($scope.data = {
2567 tabs: [
2568 { name: "actived", translate: "listedEvents.header.tabs.actived" },
2569 { name: "ended", translate: "listedEvents.header.tabs.ended" },
2570 ],
2571 activedList: [],
2572 endedList: [],
2573 user: { name: User.profile.name.first + " " + User.profile.name.last },
2574 }),
2575 Operator.send("splashscreen.hide"),
2576 Operator.send("statusbar.update", { theme: $scope.header.theme });
2577 }),
2578 $scope.$on("$ionicView.beforeEnter", function () {
2579 ($scope.isLoading = !1), ($scope.isEvents = !1), $scope.selectNavigationTab("actived");
2580 }),
2581 $scope.$on("listedEvents.pause", function () {}),
2582 $scope.$on("listedEvents.resume", function () {});
2583 },
2584 ]),
2585 angular.module("app").controller("MessageController", [
2586 "$scope",
2587 "$stateParams",
2588 "$timeout",
2589 "$translate",
2590 "$ionicHistory",
2591 "Config",
2592 "User",
2593 "UserService",
2594 "Utils",
2595 "Operator",
2596 function ($scope, $stateParams, $timeout, $translate, $ionicHistory, Config, User, UserService, Utils, Operator) {
2597 ($scope.parseApiError = function (error) {
2598 var message;
2599 switch (((error = error || {}).code || (error.code = 201), error.code)) {
2600 case 134:
2601 var timeout = $timeout(function () {
2602 Utils.switchState($scope.data.referrer.stateName, "slide-right"), $timeout.cancel(timeout);
2603 }, Config.timeoutDelay.invalidMessage);
2604 return;
2605 default:
2606 message = { translate: "notification.error.unexpectedError", translateValues: { code: error.code } };
2607 }
2608 message && Operator.send("notification.show", { type: "error", message: message });
2609 }),
2610 ($scope.getMessage = function (callback) {
2611 var params = { message_id: $stateParams.id };
2612 UserService.getMessage(params).then(function (response) {
2613 if (response.timeout)
2614 Operator.send("api.timeout", {
2615 callback: function () {
2616 $scope.getMessage(callback);
2617 },
2618 });
2619 else if (((response.data = response.data || {}), response.data.success)) {
2620 var message = {
2621 id: response.data.payload.message.id,
2622 date: moment.utc(response.data.payload.message.date).utcOffset(moment.parseZone(response.data.payload.message.date).utcOffset()).format(Config.default.dateTimeFormat),
2623 title: response.data.payload.message.title,
2624 text: response.data.payload.message.text,
2625 image: response.data.payload.message.image || null,
2626 };
2627 if (response.data.payload.message.link)
2628 switch (
2629 ((message.button = {
2630 type: response.data.payload.message.link.type,
2631 url: response.data.payload.message.link.url,
2632 label: response.data.payload.message.link.button_label || $translate.instant("message.footer.default"),
2633 }),
2634 response.data.payload.message.event_status)
2635 ) {
2636 case "expired":
2637 (message.button.type = "disabled"), (message.button.label = $translate.instant("message.footer.expired"));
2638 break;
2639 case "confirmed":
2640 (message.button.type = "disabled"), (message.button.label = $translate.instant("message.footer.confirmed"));
2641 break;
2642 case "refused":
2643 (message.button.type = "disabled"), (message.button.label = $translate.instant("message.footer.refused"));
2644 }
2645 "function" == typeof callback && callback(message);
2646 } else $scope.parseApiError(response.data.error);
2647 });
2648 }),
2649 $scope.$on("$ionicView.loaded", function () {
2650 ($scope.header = { theme: "white", title: {}, buttons: { back: !0 } }), ($scope.data = { referrer: $ionicHistory.backView() || {} }), Operator.send("statusbar.update", { theme: $scope.header.theme });
2651 }),
2652 $scope.$on("$ionicView.beforeEnter", function () {
2653 ($scope.isLoading = !0),
2654 ($scope.hasFooter = !1),
2655 $scope.getMessage(function (message) {
2656 ($scope.data.message = message),
2657 ($scope.header.title = { translate: "message.header.title", translateValues: { title: $scope.data.message.title } }),
2658 message.button && ($scope.hasFooter = !0),
2659 ($scope.isLoading = !1),
2660 User.getNotifications();
2661 });
2662 }),
2663 $scope.$on("message.pause", function () {}),
2664 $scope.$on("message.resume", function () {});
2665 },
2666 ]),
2667 angular.module("app").controller("MessagesController", [
2668 "$scope",
2669 "Config",
2670 "UserService",
2671 "Utils",
2672 "Operator",
2673 function ($scope, Config, UserService, Utils, Operator) {
2674 ($scope.parseApiError = function (error) {
2675 (error = error || {}).code || (error.code = 201), Operator.send("notification.show", { type: "error", message: { translate: "notification.error.unexpectedError", translateValues: { code: error.code } } });
2676 }),
2677 ($scope.getMessages = function (page, callback) {
2678 var params = { page: page || 1 };
2679 UserService.getMessages(params).then(function (response) {
2680 if (response.timeout)
2681 Operator.send("api.timeout", {
2682 callback: function () {
2683 $scope.getMessages(page, callback);
2684 },
2685 });
2686 else if (((response.data = response.data || {}), response.data.success)) {
2687 var nextPage,
2688 messages = [];
2689 for (var key in response.data.payload.messages) {
2690 var message = {
2691 id: response.data.payload.messages[key].id,
2692 title: response.data.payload.messages[key].title,
2693 date: moment.utc(response.data.payload.messages[key].date).utcOffset(moment.parseZone(response.data.payload.messages[key].date).utcOffset()).format(Config.default.dateTimeFormat),
2694 unread: response.data.payload.messages[key].unread || !1,
2695 };
2696 messages.push(message);
2697 }
2698 (nextPage = response.data.payload.next_page || null), "function" == typeof callback && callback(messages, nextPage);
2699 } else $scope.parseApiError(response.data.error);
2700 });
2701 }),
2702 ($scope.loadMessages = function (callback) {
2703 $scope.getMessages($scope.data.nextPage, function (messages, nextPage) {
2704 ($scope.data.list = $scope.data.list.concat(messages)),
2705 ($scope.data.nextPage = nextPage),
2706 Operator.send("scroll.infiniteScrollComplete"),
2707 ($scope.isMessages = !!$scope.data.list.length),
2708 ($scope.isMoreMessages = !!nextPage),
2709 "function" == typeof callback && callback();
2710 });
2711 }),
2712 ($scope.refreshList = function () {
2713 ($scope.data.list = []),
2714 ($scope.data.nextPage = 1),
2715 $scope.loadMessages(function () {
2716 Operator.send("scroll.refreshComplete");
2717 });
2718 }),
2719 ($scope.getMoreMessages = function () {
2720 $scope.loadMessages();
2721 }),
2722 ($scope.goTo = function ($event, stateName, transition, stateParams) {
2723 Utils.goTo($event, stateName, transition, stateParams);
2724 }),
2725 $scope.$on("$ionicView.loaded", function () {
2726 ($scope.header = { theme: "black", title: { translate: "messages.header.title", translateValues: {} }, buttons: { drawer: !0 } }),
2727 ($scope.data = { infiniteScrollDistance: Config.infiniteScroll.distance }),
2728 Operator.send("splashscreen.hide"),
2729 Operator.send("statusbar.update", { theme: $scope.header.theme });
2730 }),
2731 $scope.$on("$ionicView.beforeEnter", function () {
2732 ($scope.isLoading = !0),
2733 ($scope.isMessages = !1),
2734 ($scope.isMoreMessages = !1),
2735 ($scope.data.list = []),
2736 ($scope.data.nextPage = 1),
2737 $scope.loadMessages(function () {
2738 $scope.isLoading = !1;
2739 });
2740 }),
2741 $scope.$on("messages.pause", function () {}),
2742 $scope.$on("messages.resume", function () {});
2743 },
2744 ]),
2745 angular.module("app").controller("OnboardingController", [
2746 "$scope",
2747 "$ionicHistory",
2748 "Storage",
2749 "Utils",
2750 "Operator",
2751 function ($scope, $ionicHistory, Storage, Utils, Operator) {
2752 ($scope.goTo = function ($event, stateName, transition, stateParams) {
2753 Utils.goTo($event, stateName, transition, stateParams);
2754 }),
2755 $scope.$on("$ionicView.loaded", function () {
2756 ($scope.currentTheme = "grey"), ($scope.data = { density: Storage.get("deviceDensity") });
2757 }),
2758 $scope.$on("$ionicView.beforeEnter", function () {
2759 ($scope.isAnimate = !0), ($scope.isTutorialMode = !1), Operator.send("statusbar.update");
2760 var referrer = $ionicHistory.forwardView() || null;
2761 referrer ? ($scope.isAnimate = !1) : ((referrer = $ionicHistory.backView() || null), ($scope.isTutorialMode = !!referrer && "settings" === referrer.stateName));
2762 }),
2763 $scope.$on("$ionicView.beforeLeave", function () {}),
2764 $scope.$on("onboarding.pause", function () {}),
2765 $scope.$on("onboarding.resume", function () {});
2766 },
2767 ]),
2768 angular.module("app").controller("PaymentMethodController", [
2769 "$scope",
2770 "$stateParams",
2771 "$timeout",
2772 "$filter",
2773 "$ionicHistory",
2774 "Config",
2775 "Storage",
2776 "User",
2777 "UserService",
2778 "EventService",
2779 "StripeApi",
2780 "Utils",
2781 "FormService",
2782 "Operator",
2783 function ($scope, $stateParams, $timeout, $filter, $ionicHistory, Config, Storage, User, UserService, EventService, StripeApi, Utils, FormService, Operator) {
2784 ($scope.setForm = function () {
2785 $scope.data.form = FormService.setForm({
2786 value: { cardNumber: "", cardBrand: "", cardExpiration: "", cardSecurityCode: "" },
2787 error: { cardNumber: "", cardBrand: "", cardExpiration: "", cardSecurityCode: "" },
2788 errorMessages: {
2789 cardNumber: { required: "field.error.cardNumber.required", pattern: "field.error.cardNumber.pattern" },
2790 cardExpiration: { required: "field.error.cardExpiration.required", pattern: "field.error.cardExpiration.pattern" },
2791 cardSecurityCode: { required: "field.error.cardSecurityCode.required", pattern: "field.error.cardSecurityCode.pattern" },
2792 },
2793 });
2794 }),
2795 ($scope.formatCardNumber = function () {
2796 FormService.newScheme.value.cardBrand = Utils.getCardBrand($scope.data.form.value.cardNumber);
2797 var brand = FormService.newScheme.value.cardBrand || "visa";
2798 return ($scope.data.cardSecurityCodeMessage = "field.info.cardSecurityCode." + brand), $filter("cardNumber")($scope.data.form.value.cardNumber, $scope.data.form.value.cardBrand);
2799 }),
2800 ($scope.formatCardExpiration = function () {
2801 return $filter("cardExpiration")($scope.data.form.value.cardExpiration);
2802 }),
2803 ($scope.formatCardSecurityCode = function () {
2804 return $filter("cardSecurityCode")($scope.data.form.value.cardSecurityCode);
2805 }),
2806 ($scope.validateField = function (field) {
2807 FormService.validateField($scope.form, field);
2808 }),
2809 ($scope.validateForm = function () {
2810 return FormService.validateForm($scope.form);
2811 }),
2812 ($scope.parseApiError = function (error) {
2813 var message = { translate: "notification.error.invalidData", translateValues: {} };
2814 switch (((error = error || {}).code || (error.code = 201), error.code)) {
2815 case "invalid_number":
2816 case "incorrect_number":
2817 FormService.newScheme.error.cardNumber = FormService.errorMessages.cardNumber.pattern;
2818 break;
2819 case "invalid_expiry_month":
2820 case "invalid_expiry_year":
2821 FormService.newScheme.error.cardExpiration = FormService.errorMessages.cardExpiration.pattern;
2822 break;
2823 case "invalid_cvc":
2824 case "incorrect_cvc":
2825 FormService.newScheme.error.cardSecurityCode = FormService.errorMessages.cardSecurityCode.pattern;
2826 break;
2827 case "api_connection_error":
2828 case "api_error":
2829 case "authentication_error":
2830 case "idempotency_error":
2831 case "invalid_request_error":
2832 case "rate_limit_error":
2833 case 130:
2834 case 132:
2835 case 133:
2836 message = { translate: "notification.error.paymentError", translateValues: { code: error.code } };
2837 break;
2838 case 127:
2839 message = { translate: "notification.error.paymentError", translateValues: { code: error.stripe_error.message } };
2840 break;
2841 case 129:
2842 Utils.switchState("eventReservationTimedOut", "no-transition", { id: $scope.data.event.id });
2843 break;
2844 default:
2845 message = { translate: "notification.error.unexpectedError", translateValues: { code: error.code } };
2846 }
2847 Operator.send("notification.show", { type: "error", message: message });
2848 }),
2849 ($scope.onSubmit = function () {
2850 var params;
2851 if (!$scope.isSaving)
2852 if ($scope.isSavedCard) "account" !== $scope.data.referrer.stateName && (($scope.isSaving = !0), $scope.payFee());
2853 else {
2854 if (!$scope.validateForm()) return;
2855 $scope.isSaving = !0;
2856 var expiration = moment(FormService.newScheme.value.cardExpiration),
2857 data = { number: FormService.newScheme.value.cardNumber, exp_month: expiration.format("M"), exp_year: expiration.format("YYYY"), cvc: FormService.newScheme.value.cardSecurityCode };
2858 (data = Object.keys(data)
2859 .map(function (key) {
2860 return "card[" + encodeURIComponent(key) + "]=" + encodeURIComponent(data[key]);
2861 })
2862 .join("&")),
2863 StripeApi.getCardToken(Storage.get("stripeKey"), data).then(
2864 function (response) {
2865 (params = { stripe_token: response.data.id, type: response.data.card.brand, last4: response.data.card.last4 }),
2866 $scope.saveCard(params, function () {
2867 "account" !== $scope.data.referrer.stateName
2868 ? $scope.payFee()
2869 : (($scope.data.savedCard = User.card), ($scope.data.removeButton = { translate: "paymentMethod.footer.remove", translateValue: {} }), ($scope.isSavedCard = !0), ($scope.isSaving = !1));
2870 });
2871 },
2872 function (response) {
2873 $scope.parseApiError({ code: "card_error" === response.data.error.type ? response.data.error.code : response.data.error.type }), ($scope.isSaving = !1);
2874 }
2875 );
2876 }
2877 }),
2878 ($scope.keyboardOpened = function () {
2879 ($scope.isFieldFocus = !0), $scope.data.keyboardCloseTimeout && $timeout.cancel($scope.data.keyboardCloseTimeout);
2880 }),
2881 ($scope.keyboardClosed = function (field) {
2882 $scope.validateField(field),
2883 ($scope.data.keyboardCloseTimeout = $timeout(function () {
2884 ($scope.isFieldFocus = !1), $timeout.cancel($scope.data.keyboardCloseTimeout);
2885 }, 300));
2886 }),
2887 ($scope.getEvent = function (eventId, callback) {
2888 var params = { event_id: eventId };
2889 EventService.getEvent(params).then(function (response) {
2890 if (response.timeout)
2891 Operator.send("api.timeout", {
2892 callback: function () {
2893 $scope.getEvent(eventId, callback);
2894 },
2895 });
2896 else if (((response.data = response.data || {}), response.data.success)) {
2897 var event = { id: response.data.payload.event.id, payment: { timeout: response.data.payload.event.payment.timeout, fee: response.data.payload.event.payment.fee } };
2898 "function" == typeof callback && callback(event);
2899 } else $scope.parseApiError(response.data.error);
2900 });
2901 }),
2902 ($scope.onRemove = function () {
2903 "account" !== $scope.data.referrer.stateName
2904 ? $scope.onSubmit()
2905 : (($scope.isSaving = !0),
2906 UserService.deleteCard().then(function (response) {
2907 response.timeout
2908 ? Operator.send("api.timeout", {
2909 callback: function () {
2910 ($scope.isSaving = !1), $scope.onRemove();
2911 },
2912 })
2913 : ((response.data = response.data || {}),
2914 response.data.success
2915 ? (User.resetCard(), $scope.setForm(), ($scope.data.submitButton = { translate: "paymentMethod.footer.save", translateValue: {} }), ($scope.isSavedCard = !1))
2916 : $scope.parseApiError(response.data.error),
2917 ($scope.isSaving = !1));
2918 }));
2919 }),
2920 ($scope.saveCard = function (params, callback) {
2921 (params = params || {}),
2922 UserService.saveCard(params).then(function (response) {
2923 response.timeout
2924 ? Operator.send("api.timeout", {
2925 callback: function () {
2926 $scope.saveCardToken(params, callback);
2927 },
2928 })
2929 : ((response.data = response.data || {}),
2930 response.data.success ? (User.setCard({ type: params.type, last4: params.last4 }), "function" == typeof callback && callback()) : ($scope.parseApiError(response.data.error), ($scope.isSaving = !1)));
2931 });
2932 }),
2933 ($scope.payFee = function () {
2934 var params = { event_id: $scope.data.event.id };
2935 EventService.confirmPaidReservation(params).then(function (response) {
2936 (response.data = response.data || {}),
2937 response.data.success ? Utils.switchState("eventReservationConfirmed", "slide-up", { id: $scope.data.event.id }) : ($scope.parseApiError(response.data.error), ($scope.isSaving = !1));
2938 });
2939 }),
2940 ($scope.useAnotherCard = function () {
2941 $scope.setForm(), ($scope.data.submitButton = { translate: "paymentMethod.footer.pay", translateValue: { fee: $filter("currency")($scope.data.event.payment.fee) } }), ($scope.isSavedCard = !1);
2942 }),
2943 ($scope.goTo = function ($event, stateName, transition, stateParams) {
2944 Utils.goTo($event, stateName, transition, stateParams);
2945 }),
2946 $scope.$on("$ionicView.loaded", function () {
2947 ($scope.header = { theme: "white", title: { translate: "paymentMethod.header.title", translateValues: {} }, buttons: { back: !0 } }),
2948 ($scope.data = {
2949 referrer: $ionicHistory.backView() || {},
2950 form: {},
2951 keyboardCloseTimeout: null,
2952 modelOptions: Config.modelOptions,
2953 savedCard: User.card || null,
2954 cardSecurityCodeMessage: "field.info.cardSecurityCode.visa",
2955 }),
2956 Operator.send("statusbar.update", { theme: $scope.header.theme });
2957 }),
2958 $scope.$on("$ionicView.beforeEnter", function () {
2959 ($scope.isFieldFocus = !1),
2960 ($scope.isLoading = !1),
2961 ($scope.isSaving = !1),
2962 ($scope.isCancelling = !1),
2963 ($scope.isSavedCard = !1),
2964 "account" !== $scope.data.referrer.stateName
2965 ? (($scope.isLoading = !0),
2966 $scope.getEvent($stateParams.id, function (event) {
2967 ($scope.data.event = event),
2968 $scope.data.savedCard
2969 ? (($scope.data.removeButton = { translate: "paymentMethod.footer.pay", translateValue: { fee: $filter("currency")($scope.data.event.payment.fee) } }), ($scope.isSavedCard = !0))
2970 : ($scope.setForm(), ($scope.data.submitButton = { translate: "paymentMethod.footer.pay", translateValue: { fee: $filter("currency")($scope.data.event.payment.fee) } })),
2971 ($scope.isLoading = !1);
2972 }))
2973 : $scope.data.savedCard
2974 ? (($scope.isSavedCard = !0), ($scope.data.removeButton = { translate: "paymentMethod.footer.remove", translateValue: {} }))
2975 : ($scope.setForm(), ($scope.data.submitButton = { translate: "paymentMethod.footer.save", translateValue: {} }));
2976 }),
2977 $scope.$on("paymentMethod.pause", function () {}),
2978 $scope.$on("paymentMethod.resume", function () {});
2979 },
2980 ]),
2981 angular.module("app").controller("PrivacyPolicyController", [
2982 "$scope",
2983 "Config",
2984 "ContentService",
2985 "Operator",
2986 function ($scope, Config, ContentService, Operator) {
2987 ($scope.loadContent = function (callback) {
2988 ContentService.loadContent(Config.copdate.privacyUrl).then(
2989 function (response) {
2990 response.timeout
2991 ? Operator.send("api.timeout", {
2992 callback: function () {
2993 $scope.loadContent(callback);
2994 },
2995 })
2996 : response.data && "function" == typeof callback && callback(response.data);
2997 },
2998 function (response) {}
2999 );
3000 }),
3001 $scope.$on("$ionicView.loaded", function () {
3002 ($scope.header = { theme: "white", title: { translate: "privacyPolicy.header.title", translateValues: {} }, buttons: { back: !0 } }), ($scope.data = {}), Operator.send("statusbar.update", { theme: $scope.header.theme });
3003 }),
3004 $scope.$on("$ionicView.beforeEnter", function () {
3005 ($scope.isLoading = !0),
3006 $scope.loadContent(function (content) {
3007 ($scope.data.content = content), ($scope.isLoading = !1);
3008 });
3009 }),
3010 $scope.$on("privacyPolicy.pause", function () {}),
3011 $scope.$on("privacyPolicy.resume", function () {});
3012 },
3013 ]),
3014 angular.module("app").controller("SelectApparelSizeController", [
3015 "$scope",
3016 "$timeout",
3017 "$ionicHistory",
3018 "Config",
3019 "Storage",
3020 "User",
3021 "UserService",
3022 "SizesService",
3023 "Utils",
3024 "Operator",
3025 function ($scope, $timeout, $ionicHistory, Config, Storage, User, UserService, SizesService, Utils, Operator) {
3026 ($scope.resetForm = function () {
3027 $scope.data.form = {
3028 value: {
3029 gender: $scope.data.user.gender || "male",
3030 apparel_size: {
3031 male: "male" === $scope.data.user.gender && $scope.data.user.apparelSize.size ? $scope.data.user.apparelSize.size : "",
3032 female: "female" === $scope.data.user.gender && $scope.data.user.apparelSize.size ? $scope.data.user.apparelSize.size : "",
3033 },
3034 },
3035 };
3036 }),
3037 ($scope.validateForm = function () {
3038 if ($scope.form.$invalid) {
3039 for (var key in $scope.data.form.error) $scope.form[key] && ($scope.form[key].$setTouched(), $scope.form[key].$setDirty());
3040 return !1;
3041 }
3042 return !0;
3043 }),
3044 ($scope.parseApiError = function (error) {
3045 var message;
3046 switch (((error = error || {}).code || (error.code = 201), error.code)) {
3047 case 120:
3048 case 121:
3049 message = { translate: "notification.error.invalidFootwearSize", translateValues: {} };
3050 break;
3051 case 137:
3052 case 138:
3053 message = { translate: "notification.error.invalidApparelSize", translateValues: {} };
3054 break;
3055 case 139:
3056 message = { translate: "notification.error.invalidTimeSlot", translateValues: {} };
3057 break;
3058 default:
3059 message = { translate: "notification.error.unexpectedError", translateValues: { code: error.code } };
3060 }
3061 Operator.send("notification.show", { type: "error", message: message });
3062 }),
3063 ($scope.onSubmit = function () {
3064 var params;
3065 $scope.isSaving ||
3066 ($scope.validateForm()
3067 ? (($scope.isSaving = !0),
3068 (params = { apparel_size: angular.copy($scope.data.form.value.apparel_size[$scope.data.form.value.gender]), apparel_size_gender: $scope.data.form.value.gender }),
3069 UserService.updateSizes(params).then(function (response) {
3070 response.timeout
3071 ? Operator.send("api.timeout", {
3072 callback: function () {
3073 ($scope.isSaving = !1), $scope.onSubmit();
3074 },
3075 })
3076 : ((response.data = response.data || {}),
3077 response.data.success
3078 ? (User.setSizes("apparel", { gender: params.apparel_size_gender, size: params.apparel_size }),
3079 "selectFootwearSize" === $scope.data.referrer.stateName
3080 ? $scope.goNext()
3081 : Operator.send("notification.show", { type: "success", message: { translate: "notification.success.sizeUpdated", translateValues: {} } }))
3082 : $scope.parseApiError(response.data.error),
3083 ($scope.isSaving = !1));
3084 }))
3085 : Operator.send("notification.show", { type: "error", message: { translate: "notification.error.noSizeSelection", translateValues: {} } }));
3086 }),
3087 ($scope.selectGender = function (tab) {
3088 ($scope.data.form.value.gender = tab), ($scope.hasSizeSelected = !!$scope.data.form.value.apparel_size[$scope.data.form.value.gender]);
3089 }),
3090 ($scope.selectSize = function (size) {
3091 var timeout = $timeout(function () {
3092 $scope.data.form.value.apparel_size[$scope.data.form.value.gender] !== size && ($scope.hasSizeSelected = !0), ($scope.data.form.value.apparel_size[$scope.data.form.value.gender] = size), $timeout.cancel(timeout);
3093 });
3094 }),
3095 ($scope.getSizeMatrix = function (callback) {
3096 Storage.get("apparelSizeMatrix")
3097 ? (($scope.data.apparelSizes = Storage.get("apparelSizeMatrix")), "function" == typeof callback && callback())
3098 : SizesService.getSizeMatrix().then(function (response) {
3099 if (response.timeout)
3100 Operator.send("api.timeout", {
3101 callback: function () {
3102 $scope.getSizeMatrix(callback);
3103 },
3104 });
3105 else if (((response.data = response.data || {}), response.data.success)) {
3106 var key,
3107 apparelSizes = { male: [], female: [] };
3108 for (key in response.data.payload.sizes.apparel.male) apparelSizes.male.push({ value: String(response.data.payload.sizes.apparel.male[key]) });
3109 for (key in response.data.payload.sizes.apparel.female) apparelSizes.female.push({ value: String(response.data.payload.sizes.apparel.female[key]) });
3110 Storage.set("apparelSizeMatrix", apparelSizes), ($scope.data.apparelSizes = Storage.get("apparelSizeMatrix")), "function" == typeof callback && callback();
3111 } else $scope.parseApiError(response.data.error);
3112 });
3113 }),
3114 ($scope.goNext = function () {
3115 var next,
3116 transition = "slide-left";
3117 User.isNotificationsEnabled
3118 ? User.isLocationShared
3119 ? ((next = Storage.get("schemeRedirection") ? angular.copy(Storage.get("schemeRedirection")) : Config.redirects.latest), Storage.unset("schemeRedirection"), (transition = "fade"))
3120 : (next = { stateName: "shareLocation" })
3121 : (next = { stateName: "enableNotifications" }),
3122 Utils.switchState(next.stateName, transition);
3123 }),
3124 $scope.$on("$ionicView.loaded", function () {
3125 switch (
3126 (($scope.header = { theme: "black", title: { translate: "selectSizes.header.title.default", translateValues: {} }, buttons: {} }),
3127 ($scope.data = {
3128 tabs: [
3129 { name: "male", translate: "selectApparelSize.header.tabs.male" },
3130 { name: "female", translate: "selectApparelSize.header.tabs.female" },
3131 ],
3132 referrer: $ionicHistory.backView() || {},
3133 form: {},
3134 modelOptions: Config.modelOptions,
3135 submitButtonTranslate: "selectApparelSize.footer.save",
3136 }),
3137 $scope.data.referrer.stateName)
3138 ) {
3139 case "selectFootwearSize":
3140 ($scope.header.buttons.back = !0), ($scope.data.submitButtonTranslate = "selectApparelSize.footer.next");
3141 break;
3142 default:
3143 $scope.header.buttons.back = !0;
3144 }
3145 Operator.send("statusbar.update", { theme: $scope.header.theme });
3146 }),
3147 $scope.$on("$ionicView.beforeEnter", function () {
3148 ($scope.isLoading = !0),
3149 ($scope.isSaving = !1),
3150 $scope.getSizeMatrix(function () {
3151 ($scope.isLoading = !1),
3152 ($scope.data.user = { gender: null, apparelSize: User.sizes.apparel || { size: "M", gender: "male" } }),
3153 ($scope.data.user.gender = $scope.data.user.apparelSize.gender),
3154 "selectFootwearSize" === $scope.data.referrer.stateName && ($scope.hasSizeSelected = !0),
3155 $scope.resetForm();
3156 });
3157 }),
3158 $scope.$on("$ionicView.beforeLeave", function () {}),
3159 $scope.$on("selectApparelSize.pause", function () {}),
3160 $scope.$on("selectApparelSize.resume", function () {});
3161 },
3162 ]),
3163 angular.module("app").controller("SelectFootwearSizeController", [
3164 "$scope",
3165 "$timeout",
3166 "$ionicHistory",
3167 "Config",
3168 "Storage",
3169 "User",
3170 "UserService",
3171 "SizesService",
3172 "Utils",
3173 "Operator",
3174 function ($scope, $timeout, $ionicHistory, Config, Storage, User, UserService, SizesService, Utils, Operator) {
3175 ($scope.resetForm = function () {
3176 $scope.data.form = {
3177 value: {
3178 gender: $scope.data.user.gender || "male",
3179 footwear_size: {
3180 male: "male" === $scope.data.user.gender && $scope.data.user.footwearSize.size ? $scope.data.user.footwearSize.size : "",
3181 female: "female" === $scope.data.user.gender && $scope.data.user.footwearSize.size ? $scope.data.user.footwearSize.size : "",
3182 },
3183 },
3184 };
3185 }),
3186 ($scope.validateForm = function () {
3187 if ($scope.form.$invalid) {
3188 for (var key in $scope.data.form.error) $scope.form[key] && ($scope.form[key].$setTouched(), $scope.form[key].$setDirty());
3189 return !1;
3190 }
3191 return !0;
3192 }),
3193 ($scope.parseApiError = function (error) {
3194 var message;
3195 switch (((error = error || {}).code || (error.code = 201), error.code)) {
3196 case 120:
3197 case 121:
3198 message = { translate: "notification.error.invalidFootwearSize", translateValues: {} };
3199 break;
3200 case 137:
3201 case 138:
3202 message = { translate: "notification.error.invalidApparelSize", translateValues: {} };
3203 break;
3204 case 139:
3205 message = { translate: "notification.error.invalidTimeSlot", translateValues: {} };
3206 break;
3207 default:
3208 message = { translate: "notification.error.unexpectedError", translateValues: { code: error.code } };
3209 }
3210 Operator.send("notification.show", { type: "error", message: message });
3211 }),
3212 ($scope.onSubmit = function () {
3213 var params;
3214 $scope.isSaving ||
3215 ($scope.validateForm()
3216 ? (($scope.isSaving = !0),
3217 (params = { shoe_size: angular.copy(parseFloat($scope.data.form.value.footwear_size[$scope.data.form.value.gender])), shoe_size_gender: $scope.data.form.value.gender }),
3218 UserService.updateSizes(params).then(function (response) {
3219 response.timeout
3220 ? Operator.send("api.timeout", {
3221 callback: function () {
3222 ($scope.isSaving = !1), $scope.onSubmit();
3223 },
3224 })
3225 : ((response.data = response.data || {}),
3226 response.data.success
3227 ? (User.setSizes("footwear", { gender: params.shoe_size_gender, size: params.shoe_size }),
3228 "selectStores" === $scope.data.referrer.stateName
3229 ? $scope.goNext()
3230 : Operator.send("notification.show", { type: "success", message: { translate: "notification.success.sizeUpdated", translateValues: {} } }))
3231 : $scope.parseApiError(response.data.error),
3232 ($scope.isSaving = !1));
3233 }))
3234 : Operator.send("notification.show", { type: "error", message: { translate: "notification.error.noSizeSelection", translateValues: {} } }));
3235 }),
3236 ($scope.selectGender = function (tab) {
3237 ($scope.data.form.value.gender = tab), ($scope.hasSizeSelected = !!$scope.data.form.value.footwear_size[$scope.data.form.value.gender]);
3238 }),
3239 ($scope.selectSize = function (size) {
3240 var timeout = $timeout(function () {
3241 $scope.data.form.value.footwear_size[$scope.data.form.value.gender] !== size && ($scope.hasSizeSelected = !0), ($scope.data.form.value.footwear_size[$scope.data.form.value.gender] = size), $timeout.cancel(timeout);
3242 });
3243 }),
3244 ($scope.getSizeMatrix = function (callback) {
3245 Storage.get("footwearSizeMatrix")
3246 ? (($scope.data.footwearSizes = Storage.get("footwearSizeMatrix")), "function" == typeof callback && callback())
3247 : SizesService.getSizeMatrix().then(function (response) {
3248 if (response.timeout)
3249 Operator.send("api.timeout", {
3250 callback: function () {
3251 $scope.getSizeMatrix(callback);
3252 },
3253 });
3254 else if (((response.data = response.data || {}), response.data.success)) {
3255 var key,
3256 footwearSizes = { male: [], female: [] };
3257 for (key in response.data.payload.sizes.shoe.male) footwearSizes.male.push({ value: String(response.data.payload.sizes.shoe.male[key]) });
3258 for (key in response.data.payload.sizes.shoe.female) footwearSizes.female.push({ value: String(response.data.payload.sizes.shoe.female[key]) });
3259 Storage.set("footwearSizeMatrix", footwearSizes), ($scope.data.footwearSizes = Storage.get("footwearSizeMatrix")), "function" == typeof callback && callback();
3260 } else $scope.parseApiError(response.data.error);
3261 });
3262 }),
3263 ($scope.goNext = function () {
3264 Utils.switchState("selectApparelSize", "slide-left");
3265 }),
3266 $scope.$on("$ionicView.loaded", function () {
3267 switch (
3268 (($scope.header = { theme: "black", title: { translate: "selectSizes.header.title.default", translateValues: {} }, buttons: {} }),
3269 ($scope.data = {
3270 tabs: [
3271 { name: "male", translate: "selectFootwearSize.header.tabs.male" },
3272 { name: "female", translate: "selectFootwearSize.header.tabs.female" },
3273 ],
3274 referrer: $ionicHistory.backView() || {},
3275 form: {},
3276 modelOptions: Config.modelOptions,
3277 submitButtonTranslate: "selectFootwearSize.footer.save",
3278 }),
3279 $scope.data.referrer.stateName)
3280 ) {
3281 case "selectStores":
3282 ($scope.header.buttons.back = !0), ($scope.data.submitButtonTranslate = "selectFootwearSize.footer.next");
3283 break;
3284 default:
3285 $scope.header.buttons.back = !0;
3286 }
3287 Operator.send("statusbar.update", { theme: $scope.header.theme });
3288 }),
3289 $scope.$on("$ionicView.beforeEnter", function () {
3290 ($scope.isLoading = !0),
3291 ($scope.isSaving = !1),
3292 $scope.getSizeMatrix(function () {
3293 ($scope.isLoading = !1),
3294 ($scope.data.user = { gender: null, footwearSize: User.sizes.footwear || { size: "9", gender: "male" } }),
3295 ($scope.data.user.gender = $scope.data.user.footwearSize.gender),
3296 "selectStores" === $scope.data.referrer.stateName && ($scope.hasSizeSelected = !0),
3297 $scope.resetForm();
3298 });
3299 }),
3300 $scope.$on("$ionicView.beforeLeave", function () {}),
3301 $scope.$on("selectFootwearSize.pause", function () {}),
3302 $scope.$on("selectFootwearSize.resume", function () {});
3303 },
3304 ]),
3305 angular.module("app").controller("SelectSizesController", [
3306 "$scope",
3307 "$stateParams",
3308 "$timeout",
3309 "$ionicHistory",
3310 "Config",
3311 "Storage",
3312 "User",
3313 "UserService",
3314 "EventService",
3315 "SizesService",
3316 "Utils",
3317 "Operator",
3318 function ($scope, $stateParams, $timeout, $ionicHistory, Config, Storage, User, UserService, EventService, SizesService, Utils, Operator) {
3319 ($scope.resetForm = function () {
3320 switch ((($scope.data.form = { value: {} }), $scope.data.event.product.sizes.type)) {
3321 case "time":
3322 $scope.data.form.value = { time_slot: $scope.data.user.timeSlot ? $scope.data.user.timeSlot : "" };
3323 break;
3324 case "footwear":
3325 $scope.data.form.value = {
3326 gender: $scope.data.user.gender || "male",
3327 footwear_size: {
3328 male: "male" === $scope.data.user.gender && $scope.data.user.footwearSize.size ? $scope.data.user.footwearSize.size : "",
3329 female: "female" === $scope.data.user.gender && $scope.data.user.footwearSize.size ? $scope.data.user.footwearSize.size : "",
3330 },
3331 };
3332 break;
3333 case "apparel":
3334 $scope.data.form.value = {
3335 gender: $scope.data.user.gender || "male",
3336 apparel_size: {
3337 male: "male" === $scope.data.user.gender && $scope.data.user.apparelSize.size ? $scope.data.user.apparelSize.size : "",
3338 female: "female" === $scope.data.user.gender && $scope.data.user.apparelSize.size ? $scope.data.user.apparelSize.size : "",
3339 },
3340 };
3341 }
3342 }),
3343 ($scope.validateForm = function () {
3344 if ($scope.form.$invalid) {
3345 for (var key in $scope.data.form.error) $scope.form[key] && ($scope.form[key].$setTouched(), $scope.form[key].$setDirty());
3346 return !1;
3347 }
3348 return !0;
3349 }),
3350 ($scope.parseApiError = function (error) {
3351 var message;
3352 switch (((error = error || {}).code || (error.code = 201), error.code)) {
3353 case 120:
3354 case 121:
3355 message = { translate: "notification.error.invalidFootwearSize", translateValues: {} };
3356 break;
3357 case 137:
3358 case 138:
3359 message = { translate: "notification.error.invalidApparelSize", translateValues: {} };
3360 break;
3361 case 139:
3362 message = { translate: "notification.error.invalidTimeSlot", translateValues: {} };
3363 break;
3364 default:
3365 message = { translate: "notification.error.unexpectedError", translateValues: { code: error.code } };
3366 }
3367 Operator.send("notification.show", { type: "error", message: message });
3368 }),
3369 ($scope.onSubmit = function () {
3370 if (!$scope.isSaving)
3371 if ($scope.validateForm()) {
3372 switch ($scope.data.event.product.sizes.type) {
3373 case "time":
3374 Storage.set("eventCustomSlot", $scope.data.form.value.time_slot);
3375 break;
3376 case "footwear":
3377 Storage.set("eventCustomSize", { gender: $scope.data.form.value.gender, size: $scope.data.form.value.footwear_size[$scope.data.form.value.gender] });
3378 break;
3379 case "apparel":
3380 Storage.set("eventCustomSize", { gender: $scope.data.form.value.gender, size: $scope.data.form.value.apparel_size[$scope.data.form.value.gender] });
3381 }
3382 Utils.switchState($scope.data.referrer.stateName, "slide-down", $scope.data.referrer.stateParams);
3383 } else Operator.send("notification.show", { type: "error", message: { translate: "notification.error.noSizeSelection", translateValues: {} } });
3384 }),
3385 ($scope.getEvent = function (eventId, callback) {
3386 var params = { event_id: eventId };
3387 EventService.getEvent(params).then(function (response) {
3388 if (response.timeout)
3389 Operator.send("api.timeout", {
3390 callback: function () {
3391 $scope.getEvent(eventId, callback);
3392 },
3393 });
3394 else if (((response.data = response.data || {}), response.data.success)) {
3395 var event = { product: { sizes: { type: response.data.payload.event.product.sizes.type } } };
3396 "shoe" === event.product.sizes.type && (event.product.sizes.type = "footwear"),
3397 "time" === event.product.sizes.type
3398 ? ((event.product.sizes.enabledSlots = response.data.payload.event.product.sizes.enabled_slots || []), (event.product.sizes.slots = response.data.payload.event.product.sizes.slots || []))
3399 : ((event.product.sizes.male = response.data.payload.event.product.sizes.male || []), (event.product.sizes.female = response.data.payload.event.product.sizes.female || [])),
3400 "function" == typeof callback && callback(event);
3401 } else $scope.parseApiError(response.data.error);
3402 });
3403 }),
3404 ($scope.selectGender = function (tab) {
3405 switch ((($scope.data.form.value.gender = tab), $scope.data.event.product.sizes.type)) {
3406 case "footwear":
3407 $scope.hasSizeSelected = !(!$scope.data.form.value.gender || !$scope.data.form.value.footwear_size[$scope.data.form.value.gender]);
3408 break;
3409 case "apparel":
3410 $scope.hasSizeSelected = !(!$scope.data.form.value.gender || !$scope.data.form.value.apparel_size[$scope.data.form.value.gender]);
3411 }
3412 }),
3413 ($scope.selectSize = function (type, size) {
3414 var timeout, selectedSize;
3415 timeout = $timeout(function () {
3416 switch (type) {
3417 case "time":
3418 !1 === (selectedSize = Utils.findItemByKey("value", String(size), $scope.data.timeSlots)).available
3419 ? ($scope.hasSizeSelected = !1)
3420 : $scope.data.form.value.time_slot !== size && ($scope.hasSizeSelected = !0),
3421 ($scope.data.form.value.time_slot = selectedSize);
3422 break;
3423 case "footwear":
3424 !1 === (selectedSize = Utils.findItemByKey("value", String(size), $scope.data.footwearSizes[$scope.data.form.value.gender])).available
3425 ? ($scope.hasSizeSelected = !1)
3426 : $scope.data.form.value.footwear_size[$scope.data.form.value.gender] !== size && ($scope.hasSizeSelected = !0),
3427 ($scope.data.form.value.footwear_size[$scope.data.form.value.gender] = size);
3428 break;
3429 case "apparel":
3430 !1 === (selectedSize = Utils.findItemByKey("value", String(size), $scope.data.apparelSizes[$scope.data.form.value.gender])).available
3431 ? ($scope.hasSizeSelected = !1)
3432 : $scope.data.form.value.apparel_size[$scope.data.form.value.gender] !== size && ($scope.hasSizeSelected = !0),
3433 ($scope.data.form.value.apparel_size[$scope.data.form.value.gender] = size);
3434 }
3435 $timeout.cancel(timeout);
3436 });
3437 }),
3438 ($scope.getSizeMatrix = function (callback) {
3439 Storage.get("footwearSizeMatrix") && Storage.get("apparelSizeMatrix")
3440 ? (($scope.data.footwearSizes = angular.copy(Storage.get("footwearSizeMatrix"))), ($scope.data.apparelSizes = angular.copy(Storage.get("apparelSizeMatrix"))), "function" == typeof callback && callback())
3441 : SizesService.getSizeMatrix().then(function (response) {
3442 if (response.timeout)
3443 Operator.send("api.timeout", {
3444 callback: function () {
3445 $scope.getSizeMatrix(callback);
3446 },
3447 });
3448 else if (((response.data = response.data || {}), response.data.success)) {
3449 var key,
3450 footwearSizes = { male: [], female: [] },
3451 apparelSizes = { male: [], female: [] };
3452 for (key in response.data.payload.sizes.shoe.male) footwearSizes.male.push({ value: String(response.data.payload.sizes.shoe.male[key]) });
3453 for (key in response.data.payload.sizes.shoe.female) footwearSizes.female.push({ value: String(response.data.payload.sizes.shoe.female[key]) });
3454 for (key in response.data.payload.sizes.apparel.male) apparelSizes.male.push({ value: response.data.payload.sizes.apparel.male[key] });
3455 for (key in response.data.payload.sizes.apparel.female) apparelSizes.female.push({ value: response.data.payload.sizes.apparel.female[key] });
3456 Storage.set("footwearSizeMatrix", footwearSizes),
3457 Storage.set("apparelSizeMatrix", apparelSizes),
3458 ($scope.data.footwearSizes = angular.copy(Storage.get("footwearSizeMatrix"))),
3459 ($scope.data.apparelSizes = angular.copy(Storage.get("apparelSizeMatrix"))),
3460 "function" == typeof callback && callback();
3461 } else $scope.parseApiError(response.data.error);
3462 });
3463 }),
3464 $scope.$on("$ionicView.loaded", function () {
3465 ($scope.header = {
3466 theme: "black",
3467 title: { translate: null, translateValues: {} },
3468 buttons: { close: !0 },
3469 callback: {
3470 close: function () {
3471 Utils.switchState($scope.data.referrer.stateName, "slide-down", $scope.data.referrer.stateParams);
3472 },
3473 },
3474 }),
3475 ($scope.data = {
3476 tabs: [
3477 { name: "male", translate: "selectSizes.header.tabs.male" },
3478 { name: "female", translate: "selectSizes.header.tabs.female" },
3479 ],
3480 referrer: $ionicHistory.backView() || {},
3481 form: {},
3482 modelOptions: Config.modelOptions,
3483 submitButtonTranslate: "selectSizes.footer.save",
3484 }),
3485 Operator.send("statusbar.update", { theme: $scope.header.theme });
3486 }),
3487 $scope.$on("$ionicView.beforeEnter", function () {
3488 ($scope.isLoading = !0),
3489 ($scope.isSaving = !1),
3490 ($scope.hasNavigationTabs = !1),
3491 ($scope.hasFootwearSizeSelected = !1),
3492 ($scope.hasApparelSizeSelected = !1),
3493 ($scope.hasTimeSlotSelected = !1),
3494 ($scope.isFootwearSizeVisible = !1),
3495 ($scope.isApparelSizeVisible = !1),
3496 ($scope.isTimeSlotVisible = !1),
3497 $scope.getSizeMatrix(function () {
3498 $scope.getEvent($stateParams.id, function (event) {
3499 var item;
3500 switch (
3501 (($scope.data.event = event),
3502 ($scope.data.user = {
3503 gender: null,
3504 footwearSize: Storage.get("eventCustomSize") || User.sizes.footwear,
3505 apparelSize: Storage.get("eventCustomSize") || User.sizes.apparel,
3506 timeSlot: Storage.get("eventCustomSlot") || {},
3507 }),
3508 "time" === $scope.data.event.product.sizes.type ? ($scope.header.title.translate = "selectSizes.header.title.time") : ($scope.header.title.translate = "selectSizes.header.title.default"),
3509 $scope.data.event.product.sizes.type)
3510 ) {
3511 case "footwear":
3512 for (item in (($scope.hasNavigationTabs = !0),
3513 ($scope.isFootwearSizeVisible = !0),
3514 ($scope.data.user.gender = $scope.data.user.footwearSize.gender),
3515 $scope.resetForm(),
3516 $scope.data.footwearSizes.male))
3517 $scope.data.event.product.sizes.male.indexOf($scope.data.footwearSizes.male[item].value) < 0 && ($scope.data.footwearSizes.male[item].available = !1);
3518 for (item in $scope.data.footwearSizes.female)
3519 $scope.data.event.product.sizes.female.indexOf($scope.data.footwearSizes.female[item].value) < 0 && ($scope.data.footwearSizes.female[item].available = !1);
3520 $scope.hasFootwearSizeSelected = !(!$scope.data.form.value.size_gender || !$scope.data.form.value.footwear_size[$scope.data.form.value.size_gender]);
3521 break;
3522 case "apparel":
3523 for (item in (($scope.hasNavigationTabs = !0), ($scope.isApparelSizeVisible = !0), ($scope.data.user.gender = $scope.data.user.apparelSize.gender), $scope.resetForm(), $scope.data.apparelSizes.male))
3524 $scope.data.event.product.sizes.male.indexOf($scope.data.apparelSizes.male[item].value) < 0 && ($scope.data.apparelSizes.male[item].available = !1);
3525 for (item in $scope.data.apparelSizes.female) $scope.data.event.product.sizes.female.indexOf($scope.data.apparelSizes.female[item].value) < 0 && ($scope.data.apparelSizes.female[item].available = !1);
3526 $scope.hasApparelSelected = !(!$scope.data.form.value.size_gender || !$scope.data.form.value.apparel_size[$scope.data.form.value.size_gender]);
3527 break;
3528 case "time":
3529 for (var key in (($scope.isTimeSlotVisible = !0), $scope.resetForm(), ($scope.data.timeSlots = []), event.product.sizes.enabledSlots))
3530 $scope.data.timeSlots.push({ value: event.product.sizes.enabledSlots[key].slot, label: event.product.sizes.enabledSlots[key].label });
3531 for (item in $scope.data.timeSlots) $scope.data.event.product.sizes.slots.indexOf($scope.data.timeSlots[item].value) < 0 && ($scope.data.timeSlots[item].available = !1);
3532 $scope.hasTimeSlotSelected = !!$scope.data.form.value.time_slot;
3533 }
3534 $scope.isLoading = !1;
3535 });
3536 });
3537 }),
3538 $scope.$on("$ionicView.beforeLeave", function () {}),
3539 $scope.$on("selectSizes.pause", function () {}),
3540 $scope.$on("selectSizes.resume", function () {});
3541 },
3542 ]),
3543 angular.module("app").controller("SelectStoresController", [
3544 "$window",
3545 "$scope",
3546 "$ionicHistory",
3547 "Config",
3548 "User",
3549 "UserService",
3550 "StoreService",
3551 "Utils",
3552 "Operator",
3553 function ($window, $scope, $ionicHistory, Config, User, UserService, StoreService, Utils, Operator) {
3554 ($scope.resetForm = function () {
3555 $scope.data.form = { value: { selection: [] } };
3556 }),
3557 ($scope.parseApiError = function (error) {
3558 var message;
3559 switch (((error = error || {}).code || (error.code = 201), error.code)) {
3560 case 107:
3561 message = { translate: "notification.error.invalidStores", translateValues: {} };
3562 break;
3563 default:
3564 message = { translate: "notification.error.unexpectedError", translateValues: { code: error.code } };
3565 }
3566 Operator.send("notification.show", { type: "error", message: message });
3567 }),
3568 ($scope.onSubmit = function () {
3569 if (!$scope.isSaving)
3570 if ($scope.hasStoreSelected) {
3571 $scope.isSaving = !0;
3572 var params = { stores: angular.copy($scope.data.form.value.selection.join(",")) };
3573 UserService.updateStores(params).then(function (response) {
3574 response.timeout
3575 ? Operator.send("api.timeout", {
3576 callback: function () {
3577 ($scope.isSaving = !1), $scope.onSubmit("stores");
3578 },
3579 })
3580 : ((response.data = response.data || {}),
3581 response.data.success
3582 ? "latestEvents" === $scope.data.referrer.stateName || "upcomingEvents" === $scope.data.referrer.stateName
3583 ? Utils.switchState($scope.data.referrer.stateName, "slide-down")
3584 : void 0 === $scope.data.referrer.stateName
3585 ? $scope.goNext()
3586 : Operator.send("notification.show", { type: "success", message: { translate: "notification.success.storesUpdated", translateValues: {} } })
3587 : $scope.parseApiError(response.data.error),
3588 ($scope.isSaving = !1));
3589 });
3590 } else Operator.send("notification.show", { type: "error", message: { translate: "notification.error.noStoreSelection", translateValues: {} } });
3591 }),
3592 ($scope.getStores = function (callback) {
3593 StoreService.getList().then(function (response) {
3594 response.timeout
3595 ? Operator.send("api.timeout", {
3596 callback: function () {
3597 $scope.getStores(callback);
3598 },
3599 })
3600 : ((response.data = response.data || {}), response.data.success ? "function" == typeof callback && callback(response.data.payload.countries) : $scope.parseApiError(response.data.error));
3601 });
3602 }),
3603 ($scope.getUserStores = function (callback) {
3604 UserService.getStores().then(function (response) {
3605 response.timeout
3606 ? Operator.send("api.timeout", {
3607 callback: function () {
3608 $scope.getUserStores(callback);
3609 },
3610 })
3611 : ((response.data = response.data || {}), response.data.success ? "function" == typeof callback && callback(response.data.payload.stores) : $scope.parseApiError(response.data.error));
3612 });
3613 }),
3614 ($scope.toggleStore = function (storeId) {
3615 if (storeId) {
3616 $scope.data.form.value["store_" + storeId] = !$scope.data.form.value["store_" + storeId];
3617 var index = $scope.data.form.value.selection.indexOf(storeId);
3618 -1 < index ? $scope.data.form.value.selection.splice(index, 1) : $scope.data.form.value.selection.push(storeId), ($scope.hasStoreSelected = !!$scope.data.form.value.selection.length);
3619 }
3620 }),
3621 ($scope.goNext = function () {
3622 Utils.switchState("selectFootwearSize", "slide-left");
3623 }),
3624 $scope.$on("$ionicView.loaded", function () {
3625 switch (
3626 (($scope.header = { theme: "white", title: { translate: "selectStores.header.title", translateValues: {} }, buttons: {} }),
3627 ($scope.data = { referrer: $ionicHistory.backView() || {}, form: {}, modelOptions: Config.modelOptions, submitButtonTranslate: "selectStores.footer.save" }),
3628 $scope.data.referrer.stateName)
3629 ) {
3630 case void 0:
3631 $scope.data.submitButtonTranslate = "selectStores.footer.next";
3632 break;
3633 case "latestEvents":
3634 case "upcomingEvents":
3635 ($scope.header.buttons.close = !0),
3636 ($scope.header.callback = {
3637 close: function () {
3638 Utils.switchState($scope.data.referrer.stateName, "slide-down");
3639 },
3640 });
3641 break;
3642 default:
3643 $scope.header.buttons.back = !0;
3644 }
3645 Operator.send("statusbar.update", { theme: $scope.header.theme });
3646 }),
3647 $scope.$on("$ionicView.beforeEnter", function () {
3648 ($scope.isLoading = !0),
3649 ($scope.isSaving = !1),
3650 ($scope.hasStoreSelected = !1),
3651 $scope.resetForm(),
3652 $scope.getStores(function (stores) {
3653 var city, country;
3654 (($scope.data.stores = stores), User.location.countryCode) ? ((city = User.location.city), (country = User.location.countryCode)) : (country = $window.navigator.language.split("-")[1]);
3655 if (country) {
3656 var countryIndex = $scope.data.stores.indexOf(Utils.findItemByKey("id", country, $scope.data.stores));
3657 if (-1 < countryIndex) {
3658 if (city) {
3659 var cityIndex = $scope.data.stores[countryIndex].cities.indexOf(Utils.findItemByKey("name", city, $scope.data.stores[countryIndex].cities));
3660 if (0 < cityIndex) {
3661 var citySpliced = $scope.data.stores[countryIndex].cities.splice(cityIndex, 1);
3662 $scope.data.stores[countryIndex].cities.unshift(citySpliced[0]);
3663 }
3664 }
3665 if (0 < countryIndex) {
3666 var countrySpliced = $scope.data.stores.splice(countryIndex, 1);
3667 $scope.data.stores.unshift(countrySpliced[0]);
3668 }
3669 }
3670 }
3671 $scope.getUserStores(function (stores) {
3672 for (var key in stores) $scope.toggleStore(stores[key]);
3673 $scope.isLoading = !1;
3674 });
3675 });
3676 }),
3677 $scope.$on("selectStores.pause", function () {}),
3678 $scope.$on("selectStores.resume", function () {});
3679 },
3680 ]),
3681 angular.module("app").controller("SettingsController", [
3682 "$window",
3683 "$scope",
3684 "Config",
3685 "Storage",
3686 "GA",
3687 "Operator",
3688 function ($window, $scope, Config, Storage, GA, Operator) {
3689 ($scope.launchApp = function (app) {
3690 var scheme = Config.external[app].scheme[Storage.get("deviceOs")];
3691 GA.trackEvent("Launch app", Config.external[app].name),
3692 void 0 !== scheme
3693 ? appAvailability.check(
3694 scheme,
3695 function () {
3696 cordova.InAppBrowser.open(Config.external[app].url.app, "_system");
3697 },
3698 function () {
3699 cordova.InAppBrowser.open(Config.external[app].url.browser, "_system");
3700 }
3701 )
3702 : $window.open(Config.external[app].url.browser, "_blank");
3703 }),
3704 $scope.$on("$ionicView.loaded", function () {
3705 ($scope.header = { theme: "grey", title: { translate: "settings.header.title", translateValues: {} }, buttons: { drawer: !0 } }),
3706 ($scope.data = { app: Config.app, codePushRelease: Storage.get("codePushRelease"), deviceOs: Storage.get("deviceOs") }),
3707 Operator.send("statusbar.update", { theme: "white" });
3708 }),
3709 $scope.$on("$ionicView.beforeEnter", function () {}),
3710 $scope.$on("settings.pause", function () {}),
3711 $scope.$on("settings.resume", function () {});
3712 },
3713 ]),
3714 angular.module("app").controller("ShareLocationController", [
3715 "$scope",
3716 "$ionicHistory",
3717 "Config",
3718 "Storage",
3719 "User",
3720 "Utils",
3721 "Geolocation",
3722 "Operator",
3723 function ($scope, $ionicHistory, Config, Storage, User, Utils, Geolocation, Operator) {
3724 ($scope.shareLocation = function () {
3725 switch (User.isLocationShared) {
3726 case !0:
3727 $scope.goNext();
3728 break;
3729 case !1:
3730 Operator.send("osSettings.open", { setting: "iOS" === Storage.get("deviceOs") ? "application_details" : "location" });
3731 break;
3732 default:
3733 Geolocation.init(function () {
3734 Geolocation.start();
3735 });
3736 }
3737 }),
3738 ($scope.goNext = function () {
3739 var next;
3740 (next = Storage.get("schemeRedirection") ? angular.copy(Storage.get("schemeRedirection")) : Config.redirects.latest), Storage.unset("schemeRedirection"), Utils.switchState(next.stateName, "fade");
3741 }),
3742 $scope.$on("$ionicView.loaded", function () {
3743 ($scope.header = { theme: "white", title: {}, buttons: {} }),
3744 ($scope.data = { referrer: $ionicHistory.backView() || {}, density: Storage.get("deviceDensity") }),
3745 "enableNotifications" !== $scope.data.referrer.stateName && ($scope.header.buttons.back = !0),
3746 Geolocation.setConfig({ stopOnTerminate: !0, useSignificantChangesOnly: !0, locationAuthorizationRequest: "WhenInUse", disableMotionActivityUpdates: !0, maxRecordsToPersist: 0 }),
3747 (Geolocation.providerChangeCallback = function () {
3748 switch (Geolocation.providerStatus) {
3749 case Geolocation.instance.AUTHORIZATION_STATUS_ALWAYS:
3750 case Geolocation.instance.AUTHORIZATION_STATUS_WHEN_IN_USE:
3751 User.shareLocation(!0), $scope.goNext();
3752 break;
3753 default:
3754 User.shareLocation(!1);
3755 }
3756 }),
3757 Operator.send("statusbar.update", { theme: $scope.header.theme });
3758 }),
3759 $scope.$on("$ionicView.beforeEnter", function () {}),
3760 $scope.$on("shareLocation.pause", function () {}),
3761 $scope.$on("shareLocation.resume", function () {});
3762 },
3763 ]),
3764 angular.module("app").controller("SignInController", [
3765 "$scope",
3766 "$timeout",
3767 "$ionicHistory",
3768 "Config",
3769 "Storage",
3770 "User",
3771 "UserService",
3772 "Utils",
3773 "FormService",
3774 "Operator",
3775 function ($scope, $timeout, $ionicHistory, Config, Storage, User, UserService, Utils, FormService, Operator) {
3776 ($scope.setForm = function () {
3777 $scope.data.form = FormService.setForm({
3778 value: { email: "", password: "" },
3779 error: { email: "", password: "" },
3780 errorMessages: { email: { required: "field.error.email.required", pattern: "field.error.email.pattern", alreadyExist: "field.error.email.alreadyExist" }, password: { required: "field.error.password.required" } },
3781 });
3782 }),
3783 ($scope.validateField = function (field) {
3784 FormService.validateField($scope.form, field);
3785 }),
3786 ($scope.validateForm = function () {
3787 return FormService.validateForm($scope.form);
3788 }),
3789 ($scope.parseApiError = function (error) {
3790 var message, code;
3791 switch (((code = (error = error || {}).code || 201), error.code || (error.code = 999), code)) {
3792 case 118:
3793 message = { translate: "notification.error.invalidCredentials", translateValues: {} };
3794 break;
3795 default:
3796 message = { translate: "notification.error.unexpectedError", translateValues: { code: error.code } };
3797 }
3798 Operator.send("notification.show", { type: "error", message: message });
3799 }),
3800 ($scope.onSubmit = function () {
3801 if (!$scope.isSaving && $scope.validateForm()) {
3802 $scope.isSaving = !0;
3803 var params = FormService.newScheme.value;
3804 UserService.signIn(params).then(function (response) {
3805 if (response.timeout)
3806 Operator.send("api.timeout", {
3807 callback: function () {
3808 ($scope.isSaving = !1), $scope.onSubmit();
3809 },
3810 });
3811 else {
3812 var redirect;
3813 if (((response.data = response.data || {}), response.data.success))
3814 (response.data.payload.sizes = response.data.payload.sizes || {}),
3815 User.connect(),
3816 User.setProfile({
3817 user_id: response.data.payload.user_id,
3818 first_name: response.data.payload.first_name,
3819 last_name: response.data.payload.last_name,
3820 email: response.data.payload.email,
3821 phone: response.data.payload.phone,
3822 phone_country_code: response.data.payload.phone_country_code,
3823 }),
3824 User.setCard(response.data.payload.saved_card),
3825 User.initSizes(response.data.payload.sizes),
3826 User.setNotifications(response.data.payload.notifications),
3827 Storage.set("accessToken", response.data.payload.access_token, !0),
3828 Storage.set("stripeKey", response.data.payload.stripe_key),
3829 Storage.get("oneSignalUserId")
3830 ? response.data.payload.one_signal_user_id !== Storage.get("oneSignalUserId") && UserService.updateOneSignalId()
3831 : null === User.isNotificationsEnabled && Operator.send("oneSignal.init"),
3832 User.startNotificationsUpdateInterval(),
3833 $ionicHistory.nextViewOptions({ historyRoot: !0, disableBack: !0 }),
3834 (redirect = Storage.get("oneSignalRedirection")
3835 ? angular.copy(Storage.get("oneSignalRedirection"))
3836 : Storage.get("schemeRedirection")
3837 ? angular.copy(Storage.get("schemeRedirection"))
3838 : Config.redirects.latest),
3839 Storage.unset("oneSignalRedirection"),
3840 Storage.unset("schemeRedirection"),
3841 Operator.send("oneSignal.validateTags"),
3842 Utils.switchState(redirect.stateName, "fade", redirect.stateParams);
3843 else $scope.parseApiError(response.data.error);
3844 $scope.isSaving = !1;
3845 }
3846 });
3847 }
3848 }),
3849 ($scope.keyboardOpened = function () {
3850 ($scope.isFieldFocus = !0), $scope.data.keyboardCloseTimeout && $timeout.cancel($scope.data.keyboardCloseTimeout);
3851 }),
3852 ($scope.keyboardClosed = function (field) {
3853 $scope.validateField(field),
3854 ($scope.data.keyboardCloseTimeout = $timeout(function () {
3855 ($scope.isFieldFocus = !1), $timeout.cancel($scope.data.keyboardCloseTimeout);
3856 }, 300));
3857 }),
3858 ($scope.goTo = function ($event, stateName, transition, stateParams) {
3859 Utils.goTo($event, stateName, transition, stateParams);
3860 }),
3861 $scope.$on("$ionicView.loaded", function () {
3862 ($scope.header = { theme: "white", title: { translate: "signIn.header.title", translateValues: {} }, buttons: { back: !0 } }),
3863 ($scope.data = { form: {}, keyboardCloseTimeout: null, modelOptions: Config.modelOptions }),
3864 Operator.send("splashscreen.hide"),
3865 Operator.send("onboarding.close"),
3866 Operator.send("drawer.close"),
3867 Operator.send("statusbar.update", { theme: $scope.header.theme });
3868 }),
3869 $scope.$on("$ionicView.beforeEnter", function () {
3870 ($scope.isFieldFocus = !1), ($scope.isSaving = !1), $scope.setForm();
3871 }),
3872 $scope.$on("signIn.pause", function () {}),
3873 $scope.$on("signIn.resume", function () {});
3874 },
3875 ]),
3876 angular.module("app").controller("SignUpController", [
3877 "$window",
3878 "$scope",
3879 "$timeout",
3880 "$ionicHistory",
3881 "Config",
3882 "Storage",
3883 "User",
3884 "UserService",
3885 "Utils",
3886 "FormService",
3887 "Operator",
3888 function ($window, $scope, $timeout, $ionicHistory, Config, Storage, User, UserService, Utils, FormService, Operator) {
3889 ($scope.setForm = function () {
3890 $scope.data.form = FormService.setForm({
3891 value: { first_name: "", last_name: "", email: "", password: "", phone: "", phone_country_code: "" },
3892 error: { first_name: "", last_name: "", email: "", password: "", phone: "", phone_country_code: "" },
3893 errorMessages: {
3894 first_name: { required: "field.error.firstName.required", maxlength: "field.error.firstName.maxlength" },
3895 last_name: { required: "field.error.lastName.required", maxlength: "field.error.lastName.maxlength" },
3896 email: { required: "field.error.email.required", pattern: "field.error.email.pattern", alreadyExist: "field.error.email.alreadyExist" },
3897 password: { required: "field.error.password.required", pattern: "field.error.password.pattern" },
3898 phone: { required: "field.error.phone.required", pattern: "field.error.phone.pattern", countryCode: "field.error.phone.countryCode" },
3899 },
3900 });
3901 }),
3902 ($scope.validateField = function (field) {
3903 FormService.validateField($scope.form, field);
3904 }),
3905 ($scope.validateForm = function () {
3906 return FormService.validateForm($scope.form);
3907 }),
3908 ($scope.parseApiError = function (error) {
3909 var message = { translate: "notification.error.invalidData", translateValues: {} };
3910 switch (((error = error || {}).code || (error.code = 201), error.code)) {
3911 case 109:
3912 FormService.newScheme.error.email = FormService.errorMessages.email.pattern;
3913 break;
3914 case 110:
3915 FormService.newScheme.error.email = FormService.errorMessages.email.alreadyExist;
3916 break;
3917 case 111:
3918 FormService.newScheme.error.password = FormService.errorMessages.password.pattern;
3919 break;
3920 case 113:
3921 FormService.newScheme.error.first_name = FormService.errorMessages.first_name.required;
3922 break;
3923 case 114:
3924 FormService.newScheme.error.last_name = FormService.errorMessages.last_name.required;
3925 break;
3926 case 122:
3927 FormService.newScheme.error.phone = FormService.errorMessages.phone.pattern;
3928 break;
3929 case 126:
3930 FormService.newScheme.error.phone = FormService.errorMessages.phone.countryCode;
3931 break;
3932 default:
3933 message = { translate: "notification.error.unexpectedError", translateValues: { code: error.code } };
3934 }
3935 Operator.send("notification.show", { type: "error", message: message });
3936 }),
3937 ($scope.onSubmit = function () {
3938 if (!$scope.isSaving && $scope.validateForm()) {
3939 $scope.isSaving = !0;
3940 var params = angular.copy(FormService.newScheme.value);
3941 (params.phone = Utils.getPhoneNumberRaw(params.phone, params.phone_country_code)),
3942 UserService.signUp(params).then(function (response) {
3943 response.timeout
3944 ? Operator.send("api.timeout", {
3945 callback: function () {
3946 ($scope.isSaving = !1), $scope.onSubmit();
3947 },
3948 })
3949 : ((response.data = response.data || {}),
3950 response.data.success
3951 ? (User.connect(),
3952 User.setProfile({
3953 user_id: response.data.payload.user_id,
3954 first_name: params.first_name,
3955 last_name: params.last_name,
3956 email: params.email,
3957 phone: params.phone,
3958 phone_country_code: params.phone_country_code,
3959 }),
3960 User.resetNotifications(),
3961 Storage.set("accessToken", response.data.payload.access_token, !0),
3962 Storage.set("stripeKey", response.data.payload.stripe_key),
3963 User.startNotificationsUpdateInterval(),
3964 $ionicHistory.nextViewOptions({ historyRoot: !0, disableBack: !0 }),
3965 Utils.switchState("selectStores", "slide-left"))
3966 : $scope.parseApiError(response.data.error),
3967 ($scope.isSaving = !1));
3968 });
3969 }
3970 }),
3971 ($scope.keyboardOpened = function () {
3972 ($scope.isFieldFocus = !0), $scope.data.keyboardCloseTimeout && $timeout.cancel($scope.data.keyboardCloseTimeout);
3973 }),
3974 ($scope.keyboardClosed = function (field) {
3975 $scope.validateField(field),
3976 ($scope.data.keyboardCloseTimeout = $timeout(function () {
3977 ($scope.isFieldFocus = !1), $timeout.cancel($scope.data.keyboardCloseTimeout);
3978 }, 300));
3979 }),
3980 ($scope.goTo = function ($event, stateName, transition, stateParams) {
3981 Utils.goTo($event, stateName, transition, stateParams);
3982 }),
3983 $scope.$on("$ionicView.loaded", function () {
3984 ($scope.header = { theme: "white", title: { translate: "signUp.header.title", translateValues: {} }, buttons: { back: !0 } }),
3985 ($scope.data = { form: {}, keyboardCloseTimeout: null, modelOptions: Config.modelOptions }),
3986 Operator.send("onboarding.close"),
3987 Operator.send("statusbar.update", { theme: $scope.header.theme });
3988 }),
3989 $scope.$on("$ionicView.beforeEnter", function () {
3990 if ((($scope.isFieldFocus = !1), ($scope.isSaving = !1), $scope.setForm(), User.location.countryCode)) FormService.newScheme.value.phone_country_code = angular.copy(User.location.countryCode.toLowerCase());
3991 else {
3992 var code = $window.navigator.language.split("-")[1] || "";
3993 FormService.newScheme.value.phone_country_code = code.toLowerCase() || Config.default.phoneCountryCode;
3994 }
3995 }),
3996 $scope.$on("signUp.pause", function () {}),
3997 $scope.$on("signUp.resume", function () {});
3998 },
3999 ]),
4000 angular.module("app").controller("SplashController", [
4001 "$scope",
4002 "$timeout",
4003 "$ionicHistory",
4004 "Config",
4005 "Storage",
4006 "User",
4007 "Utils",
4008 "Operator",
4009 function ($scope, $timeout, $ionicHistory, Config, Storage, User, Utils, Operator) {
4010 $scope.$on("splash.redirection", function () {
4011 var redirect;
4012 $scope.data.timeout && ($timeout.cancel($scope.data.timeout), ($scope.data.timeout = null)), $ionicHistory.nextViewOptions({ historyRoot: !0, disableBack: !0 });
4013 var schemeUrl = angular.copy(window.localStorage.getItem("schemeUrl")) || null;
4014 if (schemeUrl) {
4015 var split = schemeUrl.split("/"),
4016 schemeUrlState = null;
4017 switch (split[0]) {
4018 case "events":
4019 split[1] && (schemeUrlState = { stateName: "event", stateParams: { id: split[1] } });
4020 }
4021 schemeUrlState && Storage.set("schemeRedirection", schemeUrlState);
4022 }
4023 switch (User.isConnected) {
4024 case !0:
4025 (redirect = Storage.get("oneSignalRedirection") ? angular.copy(Storage.get("oneSignalRedirection")) : Storage.get("schemeRedirection") ? angular.copy(Storage.get("schemeRedirection")) : Config.redirects.latest),
4026 Storage.unset("oneSignalRedirection"),
4027 Storage.unset("schemeRedirection"),
4028 Operator.send("oneSignal.validateTags");
4029 break;
4030 case !1:
4031 (redirect = Config.redirects.login), Operator.send("notification.show", { type: "error", message: { translate: "notification.error.invalidAccessToken", translateValues: {} } });
4032 break;
4033 default:
4034 redirect = Config.redirects.onboarding;
4035 }
4036 Utils.switchState(redirect.stateName, "fade", redirect.stateParams);
4037 }),
4038 $scope.$on("$ionicView.loaded", function () {
4039 ($scope.data = { timeout: null }), Operator.send("splashscreen.hide"), Operator.send("statusbar.update", { theme: "white" });
4040 }),
4041 $scope.$on("$ionicView.beforeEnter", function () {
4042 $scope.data.timeout = $timeout(function () {
4043 Operator.send("splash.redirection"), $timeout.cancel($scope.data.timeout);
4044 }, Config.timeoutDelay.splashFallback);
4045 }),
4046 $scope.$on("splash.pause", function () {}),
4047 $scope.$on("splash.resume", function () {});
4048 },
4049 ]),
4050 angular.module("app").controller("TermsOfUseController", [
4051 "$scope",
4052 "Config",
4053 "ContentService",
4054 "Operator",
4055 function ($scope, Config, ContentService, Operator) {
4056 ($scope.loadContent = function (callback) {
4057 ContentService.loadContent(Config.copdate.termsUrl).then(
4058 function (response) {
4059 response.timeout
4060 ? Operator.send("api.timeout", {
4061 callback: function () {
4062 $scope.loadContent(callback);
4063 },
4064 })
4065 : response.data && "function" == typeof callback && callback(response.data);
4066 },
4067 function (response) {}
4068 );
4069 }),
4070 $scope.$on("$ionicView.loaded", function () {
4071 ($scope.header = { theme: "white", title: { translate: "termsOfUse.header.title", translateValues: {} }, buttons: { back: !0 } }), ($scope.data = {}), Operator.send("statusbar.update", { theme: $scope.header.theme });
4072 }),
4073 $scope.$on("$ionicView.beforeEnter", function () {
4074 ($scope.isLoading = !0),
4075 $scope.loadContent(function (content) {
4076 ($scope.data.content = content), ($scope.isLoading = !1);
4077 });
4078 }),
4079 $scope.$on("termsOfUse.pause", function () {}),
4080 $scope.$on("termsOfUse.resume", function () {});
4081 },
4082 ]),
4083 angular.module("app").controller("UpcomingEventsController", [
4084 "$scope",
4085 "Config",
4086 "Storage",
4087 "EventService",
4088 "Utils",
4089 "Operator",
4090 function ($scope, Config, Storage, EventService, Utils, Operator) {
4091 ($scope.parseApiError = function (error) {
4092 (error = error || {}).code || (error.code = 201), Operator.send("notification.show", { type: "error", message: { translate: "notification.error.unexpectedError", translateValues: { code: error.code } } });
4093 }),
4094 ($scope.getUpcomingEvents = function (page, callback) {
4095 var params = { page: page || 1 };
4096 EventService.getUpcomingEvents(params).then(
4097 function (response) {
4098 if (response.timeout)
4099 Operator.send("api.timeout", {
4100 callback: function () {
4101 $scope.getUpcomingEvents(callback);
4102 },
4103 });
4104 else if (((response.data = response.data || {}), response.data.success)) {
4105 var nextPage,
4106 events = [];
4107 for (var key in response.data.payload.events) {
4108 var event = {
4109 id: response.data.payload.events[key].event.id,
4110 type: "rsvp" === response.data.payload.events[key].event.type ? "rsvp" : "list",
4111 product: {
4112 name: response.data.payload.events[key].event.product.name,
4113 images: response.data.payload.events[key].event.product.images || [],
4114 url: response.data.payload.events[key].event.product.url,
4115 },
4116 store: { logo: response.data.payload.events[key].store.logo, name: response.data.payload.events[key].store.name, city: response.data.payload.events[key].store.city },
4117 isLocalOnly: response.data.payload.events[key].event.is_local_only || !1,
4118 isInStoreOnly: response.data.payload.events[key].event.is_instore_only || !1,
4119 unseen: response.data.payload.events[key].event.unseen || !1,
4120 status: "upcoming",
4121 },
4122 offset = moment().utcOffset(),
4123 date = moment(response.data.payload.events[key].event.date).utcOffset(offset);
4124 (event.date = date.format(Config.default.dateFormat)), events.push(event);
4125 }
4126 (nextPage = response.data.payload.next_page || null), "function" == typeof callback && callback(events, nextPage);
4127 } else $scope.parseApiError(response.data.error);
4128 },
4129 function (response) {
4130 $scope.parseApiError(response.data.error);
4131 }
4132 );
4133 }),
4134 ($scope.loadEvents = function (callback) {
4135 $scope.getUpcomingEvents($scope.data.nextPage, function (events, nextPage) {
4136 ($scope.data.list = $scope.data.list.concat(events)),
4137 ($scope.data.nextPage = nextPage),
4138 Operator.send("scroll.infiniteScrollComplete"),
4139 ($scope.isEvents = !!$scope.data.list.length),
4140 ($scope.isMoreEvents = !!nextPage),
4141 ($scope.isLoading = !1),
4142 "function" == typeof callback && callback();
4143 });
4144 }),
4145 ($scope.refreshList = function () {
4146 ($scope.data.list = []),
4147 ($scope.data.nextPage = 1),
4148 $scope.loadEvents(function () {
4149 Operator.send("scroll.refreshComplete");
4150 });
4151 }),
4152 ($scope.getMoreEvents = function () {
4153 $scope.loadEvents();
4154 }),
4155 ($scope.goTo = function ($event, stateName, transition, stateParams) {
4156 Utils.goTo($event, stateName, transition, stateParams);
4157 }),
4158 ($scope.goToEvent = function ($event, event) {
4159 var stateParams = { id: event.id };
4160 Utils.goTo($event, "event", "slide-left", stateParams);
4161 }),
4162 $scope.$on("$ionicView.loaded", function () {
4163 ($scope.header = { theme: "black", title: { translate: "upcomingEvents.header.title", translateValues: {} }, buttons: { drawer: !0, latest: !0 } }),
4164 ($scope.data = { infiniteScrollDistance: Config.infiniteScroll.distance }),
4165 Operator.send("statusbar.update", { theme: $scope.header.theme });
4166 }),
4167 $scope.$on("$ionicView.beforeEnter", function () {
4168 ($scope.isLoading = !0), ($scope.isEvents = !1), ($scope.isMoreEvents = !1), Storage.unset("event"), ($scope.data.list = []), ($scope.data.nextPage = 1), $scope.loadEvents();
4169 }),
4170 $scope.$on("upcomingEvents.pause", function () {}),
4171 $scope.$on("upcomingEvents.resume", function () {});
4172 },
4173 ]),
4174 angular.module("app").directive("cardExpirationField", function () {
4175 return {
4176 restrict: "E",
4177 require: "ngModel",
4178 replace: !0,
4179 templateUrl: "templates/components/card-expiration-field.html",
4180 scope: {
4181 min: "=uiMin",
4182 max: "=uiMax",
4183 label: "@uiLabel",
4184 placeholder: "@uiPlaceholder",
4185 iconBefore: "@uiIconBefore",
4186 iconBeforeClick: "&?uiIconBeforeClick",
4187 iconAfter: "@uiIconAfter",
4188 iconAfterClick: "&?uiIconAfterClick",
4189 info: "@uiInfo",
4190 error: "@uiError",
4191 onRenderCallback: "&?uiRenderCallback",
4192 onInitCallback: "&?uiInitCallback",
4193 onFocusCallback: "&?uiFocusCallback",
4194 onChangeCallback: "&?uiChangeCallback",
4195 onBlurCallback: "&?uiBlurCallback",
4196 },
4197 link: function (scope, element, attrs, ngModel) {
4198 (scope.value = null),
4199 (scope.selection = null),
4200 (scope.model = ngModel).$setPristine(),
4201 ngModel.$setUntouched(),
4202 ngModel.$formatters.push(function (modelValue) {
4203 return (scope.value = modelValue);
4204 }),
4205 "function" == typeof scope.onInitCallback && scope.onInitCallback(),
4206 (ngModel.$render = function () {
4207 if (!scope.selection && scope.placeholder) return (scope.selection = scope.placeholder), void angular.element(element).addClass("has-placeholder");
4208 angular.element(element).removeClass("has-placeholder"),
4209 angular.isDate(scope.value) && ("function" == typeof scope.onRenderCallback ? (scope.selection = scope.onRenderCallback({ value: ngModel.$modelValue })) : (scope.selection = scope.value));
4210 }),
4211 (scope.onFocus = function () {
4212 scope.disabled || (angular.element(element).addClass("has-focus"), "function" == typeof scope.onFocusCallback && scope.onFocusCallback());
4213 }),
4214 (scope.onChange = function () {
4215 scope.disabled || (ngModel.$setViewValue(scope.value), ngModel.$render(), "function" == typeof scope.onChangeCallback && scope.onChangeCallback());
4216 }),
4217 (scope.onBlur = function () {
4218 scope.disabled || (ngModel.$setDirty(), ngModel.$setTouched(), angular.element(element).removeClass("has-focus"), "function" == typeof scope.onBlurCallback && scope.onBlurCallback());
4219 });
4220 },
4221 };
4222 }),
4223 angular.module("app").directive("drawer", [
4224 "$state",
4225 "$timeout",
4226 "$ionicBackdrop",
4227 "Config",
4228 "User",
4229 "Utils",
4230 "Operator",
4231 function ($state, $timeout, $ionicBackdrop, Config, User, Utils, Operator) {
4232 return {
4233 restrict: "E",
4234 replace: !0,
4235 templateUrl: "templates/components/drawer.html",
4236 controller: [
4237 "$scope",
4238 function ($scope) {
4239 ($scope.data = { navigation: Config.drawer.navigation }),
4240 ($scope.updateData = function () {
4241 ($scope.currentView = $state.current.name), ($scope.data.user = { name: User.profile.name.first + " " + User.profile.name.last, notifications: User.notifications });
4242 }),
4243 ($scope.goTo = function ($event, stateName, transition, stateParams) {
4244 Utils.goTo($event, stateName, transition, stateParams), $scope.closeDrawer();
4245 }),
4246 ($scope.closeDrawer = function () {
4247 Operator.send("drawer.close");
4248 });
4249 },
4250 ],
4251 link: function (scope, element, attrs) {
4252 scope.$on("drawer.open", function () {
4253 scope.updateData();
4254 var timeout = $timeout(function () {
4255 $ionicBackdrop.retain(), $timeout.cancel(timeout);
4256 }, Config.drawer.backdropDelay);
4257 angular.element(element).addClass("open");
4258 }),
4259 scope.$on("drawer.close", function () {
4260 var timeout = $timeout(function () {
4261 $ionicBackdrop.release(), $timeout.cancel(timeout);
4262 }, Config.drawer.backdropDelay);
4263 angular.element(element).removeClass("open");
4264 });
4265 },
4266 };
4267 },
4268 ]),
4269 angular.module("app").directive("header", [
4270 "$state",
4271 "$ionicPlatform",
4272 "$ionicHistory",
4273 "Config",
4274 "Storage",
4275 "User",
4276 "Utils",
4277 "Operator",
4278 function ($state, $ionicPlatform, $ionicHistory, Config, Storage, User, Utils, Operator) {
4279 return {
4280 restrict: "E",
4281 replace: !0,
4282 templateUrl: "templates/components/header.html",
4283 scope: { model: "=" },
4284 controller: [
4285 "$scope",
4286 function ($scope) {
4287 ($scope.data = {}),
4288 "Android" === Storage.get("deviceOs") &&
4289 (($scope.registerBackButtonAction = function () {
4290 $scope.deregister = $ionicPlatform.registerBackButtonAction(function () {
4291 $scope.goBack();
4292 }, 999);
4293 }),
4294 ($scope.deregisterBackButtonAction = function () {
4295 $scope.$on("$destroy", $scope.deregister);
4296 }),
4297 $scope.registerBackButtonAction()),
4298 ($scope.goTo = function ($event, stateName, transition, stateParams, stateOptions) {
4299 Utils.goTo($event, stateName, transition, stateParams, stateOptions);
4300 }),
4301 ($scope.goBack = function () {
4302 var previous = $ionicHistory.backView(),
4303 transition = "slide-right",
4304 deviceOs = Storage.get("deviceOs");
4305 if (
4306 ("event" === $state.current.name && null === previous && (previous = Config.redirects.latest),
4307 "message" === $state.current.name && null === previous && (previous = { stateName: "messages", stateParams: {} }),
4308 null !== previous || "Android" !== deviceOs)
4309 ) {
4310 switch ($state.current.name) {
4311 case "signUp":
4312 case "signIn":
4313 previous = { stateName: "onboarding", stateParams: {} };
4314 break;
4315 case "eventReservation":
4316 previous = { stateName: "latestEvents", stateParams: {} };
4317 break;
4318 case "eventReservationConfirmed":
4319 case "eventReservationCancelled":
4320 case "eventReservationTimedOut":
4321 (previous = { stateName: "latestEvents", stateParams: {} }), (transition = "slide-down");
4322 }
4323 Utils.switchState(previous.stateName, transition, previous.stateParams), "Android" === deviceOs && ($scope.deregisterBackButtonAction(), $scope.registerBackButtonAction());
4324 } else Operator.send("app.exit");
4325 }),
4326 ($scope.openDrawer = function () {
4327 Operator.send("drawer.open");
4328 }),
4329 ($scope.editView = function () {
4330 "function" == typeof $scope.model.callback.edit && $scope.model.callback.edit();
4331 }),
4332 ($scope.closeView = function () {
4333 "function" == typeof $scope.model.callback.close && $scope.model.callback.close();
4334 }),
4335 ($scope.updateData = function () {
4336 $scope.data = { user: { notifications: User.notifications.latest + User.notifications.upcoming + User.notifications.messages } };
4337 }),
4338 $scope.$on("header.notificationsUpdate", function () {
4339 $scope.updateData();
4340 });
4341 },
4342 ],
4343 link: function (scope, element, attrs) {
4344 scope.updateData();
4345 },
4346 };
4347 },
4348 ]),
4349 angular.module("app").directive("imagePreload", function () {
4350 return {
4351 restrict: "A",
4352 link: function (scope, element, attrs) {
4353 var img = angular.element(element);
4354 img.addClass("preload");
4355 var imgLoad = imagesLoaded(img);
4356 imgLoad.once("done", function (instance) {
4357 img.addClass("loaded");
4358 }),
4359 imgLoad.once("fail", function (instance) {
4360 img.addClass("loaded placeholder");
4361 });
4362 },
4363 };
4364 }),
4365 angular.module("app").directive("imageSlider", [
4366 "$window",
4367 "$interval",
4368 "Config",
4369 function ($window, $interval, Config) {
4370 return {
4371 restrict: "E",
4372 replace: !0,
4373 templateUrl: "templates/components/image-slider.html",
4374 scope: { images: "=", theme: "@", lockSlides: "=" },
4375 controller: [
4376 "$scope",
4377 function ($scope) {
4378 var interval = null;
4379 ($scope.isSwiping = !1),
4380 ($scope.hasLockSlides = $scope.lockSlides || !1),
4381 !$scope.hasLockSlides && $scope.images.length < 2 && ($scope.hasLockSlides = !0),
4382 ($scope.data = {}),
4383 ($scope.cue = null),
4384 ($scope.options = {
4385 loop: !1,
4386 pagination: !1,
4387 onInit: function (swiper) {
4388 $scope.hasLockSlides ? swiper.lockSwipes(!0) : (($scope.data.swiper = swiper), $scope.setCue());
4389 },
4390 onTouchStart: function (swiper) {
4391 if (!$scope.hasLockSlides) {
4392 ($scope.isSwiping = !0), interval && $scope.cancelInterval();
4393 var total = swiper.slides.length;
4394 interval = $interval(function () {
4395 var duration = $scope.isSwiping ? "0ms" : Config.slider.defaultTransitionDuration,
4396 x = 24 * total * (Math.abs(swiper.translate) / (total * $window.screen.width));
4397 0 < swiper.translate ? (x = 0) : Math.abs(swiper.translate) > (total - 1) * $window.screen.width && (x = 24 * (total - 1)),
4398 $scope.cue && angular.element($scope.cue).css({ "transition-duration": duration, transform: "translate3d(" + x + "px, 0, 0)" }),
4399 $scope.isSwiping || $scope.cancelInterval();
4400 }, Config.slider.intervalDelay);
4401 }
4402 },
4403 onTouchEnd: function () {
4404 $scope.isSwiping = !1;
4405 },
4406 }),
4407 ($scope.cancelInterval = function () {
4408 $interval.cancel(interval), (interval = null);
4409 });
4410 },
4411 ],
4412 link: function (scope, element, attrs) {
4413 scope.setCue = function () {
4414 scope.cue = element[0].querySelector(".event-slides-pager-cue");
4415 };
4416 },
4417 };
4418 },
4419 ]),
4420 angular.module("app").directive("logoAnimation", [
4421 "$timeout",
4422 "Config",
4423 "Operator",
4424 function ($timeout, Config, Operator) {
4425 return {
4426 restrict: "A",
4427 controller: [
4428 "$scope",
4429 function ($scope) {
4430 $scope.animationCompleted = function () {
4431 Operator.send("splash.redirection");
4432 };
4433 },
4434 ],
4435 link: function (scope, element, attrs) {
4436 (element[0].onerror = function (e) {
4437 scope.animationCompleted();
4438 }),
4439 angular
4440 .element(element)
4441 .on("loadstart", function (e) {
4442 element[0].play();
4443 })
4444 .on("ended", function (e) {
4445 var promise = $timeout(function () {
4446 scope.animationCompleted(), $timeout.cancel(promise);
4447 }, Config.logoAnimation.redirectionDelay);
4448 }),
4449 (element[0].src = "assets/videos/logo-animation.mp4");
4450 },
4451 };
4452 },
4453 ]),
4454 angular.module("app").directive("navigationTabs", function () {
4455 return {
4456 restrict: "E",
4457 replace: !0,
4458 templateUrl: "templates/components/navigation-tabs.html",
4459 scope: { theme: "=theme", tabs: "=tabs", activeTab: "=activeTab", onClickCallback: "&?onClickCallback" },
4460 controller: [
4461 "$scope",
4462 function ($scope) {
4463 $scope.onClick = function (tab) {
4464 tab.name && "function" == typeof $scope.onClickCallback && $scope.onClickCallback({ tab: tab.name });
4465 };
4466 },
4467 ],
4468 };
4469 }),
4470 angular.module("app").directive("notification", [
4471 "$timeout",
4472 "Config",
4473 "Operator",
4474 function ($timeout, Config, Operator) {
4475 return {
4476 restrict: "E",
4477 replace: !0,
4478 templateUrl: "templates/components/notification.html",
4479 scope: {},
4480 link: function (scope, element, attrs) {
4481 var notification = angular.element(element);
4482 (scope.message = null),
4483 (scope.showPromise = null),
4484 (scope.hidePromise = null),
4485 scope.$on("notification.show", function (e, data) {
4486 (scope.message = { translate: data.message.translate, translateValues: data.message.translateValues || {} }),
4487 notification.removeClass("notification-hide"),
4488 notification.addClass("notification-" + data.type).addClass("notification-show"),
4489 scope.showPromise && $timeout.cancel(scope.showPromise),
4490 scope.hidePromise && $timeout.cancel(scope.hidePromise),
4491 (scope.showPromise = $timeout(function () {
4492 Operator.send("notification.hide"), $timeout.cancel(scope.showPromise);
4493 }, Config.default.dismissNotificationDelay));
4494 }),
4495 scope.$on("notification.hide", function () {
4496 notification.addClass("notification-hide"),
4497 scope.hidePromise && $timeout.cancel(scope.hidePromise),
4498 (scope.hidePromise = $timeout(function () {
4499 (scope.message = null), notification.removeClass("notification-show notification-success notification-error"), $timeout.cancel(scope.hidePromise);
4500 }, 400));
4501 });
4502 },
4503 };
4504 },
4505 ]),
4506 angular.module("app").directive("onboardingAnimation", [
4507 "$window",
4508 "$timeout",
4509 "$interval",
4510 "Config",
4511 function ($window, $timeout, $interval, Config) {
4512 return {
4513 restrict: "A",
4514 controller: [
4515 "$scope",
4516 function ($scope) {
4517 ($scope.isSwiping = !1),
4518 ($scope.slider = null),
4519 ($scope.sliderInterval = null),
4520 ($scope.options = {
4521 loop: !1,
4522 pagination: !1,
4523 onInit: function (swiper) {
4524 $scope.slider = swiper;
4525 },
4526 onTouchStart: function (swiper, event) {
4527 ($scope.isSwiping = !0),
4528 $scope.cancelSliderInterval(),
4529 ($scope.sliderInterval = $interval(function () {
4530 var duration = $scope.isSwiping ? "0ms" : "300ms",
4531 percentage = Math.abs(Math.abs(swiper.translate) - swiper.activeIndex * $window.screen.width) / $window.screen.width,
4532 x = { pagerCue: (Math.abs(swiper.translate) / (5 * $window.screen.width)) * 120 },
4533 y = { notifications: 0, reserve: 0, confirm: 0, outro: 0 },
4534 scale = { reserve: 1 };
4535 switch ((0 < swiper.translate && (x.pagerCue = -x.pagerCue), swiper.activeIndex)) {
4536 case 0:
4537 y.notifications = 20 * percentage;
4538 break;
4539 case 1:
4540 (y.notifications = 20 - 20 * percentage), (y.reserve = 20 * percentage), "next" === swiper.swipeDirection && (scale.reserve = 1 + 0.1 * percentage);
4541 break;
4542 case 2:
4543 (y.notifications = 20 * percentage),
4544 (y.reserve = 20 - 20 * percentage),
4545 (y.confirm = 20 * percentage),
4546 ("prev" !== swiper.swipeDirection && "next" !== swiper.swipeDirection && void 0 !== swiper.swipeDirection) || (scale.reserve = 1.1 - 0.1 * percentage);
4547 break;
4548 case 3:
4549 (y.confirm = 20 - 20 * percentage), (y.outro = 20 * percentage), "prev" === swiper.swipeDirection && (scale.reserve = 1 + 0.1 * percentage);
4550 break;
4551 case 4:
4552 (y.confirm = 20 * percentage), "prev" === swiper.swipeDirection ? (y.outro = 20 * percentage) : (y.outro = 20);
4553 }
4554 angular.element($scope.animation.notificationsTop).css({ "transition-duration": duration, transform: "translate3d(0, " + y.notifications + "px, 0)" }),
4555 angular.element($scope.animation.notificationsBottom).css({ "transition-duration": duration, transform: "translate3d(0, -" + y.notifications + "px, 0)" }),
4556 angular.element($scope.animation.reserveTop).css({ "transition-duration": duration, transform: "translate3d(0, " + y.reserve + "px, 0)" }),
4557 angular.element($scope.animation.reserveBg).css({ "transition-duration": duration, transform: "scale(" + scale.reserve + ", " + scale.reserve + ")" }),
4558 angular.element($scope.animation.confirmTop).css({ "transition-duration": duration, transform: "translate3d(0, " + y.confirm + "px, 0)" }),
4559 angular.element($scope.animation.confirmBottom).css({ "transition-duration": duration, transform: "translate3d(0, -" + y.confirm + "px, 0)" }),
4560 angular.element($scope.animation.outroTop).css({ "transition-duration": duration, transform: "translate3d(0, " + y.outro + "px, 0)" }),
4561 angular.element($scope.animation.pagerCue).css({ "transition-duration": duration, "transition-delay": "0s", transform: "translate3d(" + x.pagerCue + "px, 0, 0)" }),
4562 $scope.isSwiping || $scope.cancelSliderInterval();
4563 }, 50));
4564 },
4565 onTouchMove: function (swiper, event) {
4566 var display = { introBg: "block", outroBg: "block", defaultBg: "block" };
4567 0 !== swiper.activeIndex || ("prev" !== swiper.swipeDirection && void 0 !== swiper.swipeDirection)
4568 ? 4 !== swiper.activeIndex || ("next" !== swiper.swipeDirection && void 0 !== swiper.swipeDirection) || (display.outroBg = "none")
4569 : (display.introBg = "none"),
4570 0 < swiper.activeIndex && (display.defaultBg = "none"),
4571 angular.element($scope.animation.introBg).css({ display: display.introBg }),
4572 angular.element($scope.animation.outroBg).css({ display: display.outroBg }),
4573 angular.element($scope.animation.defaultBg).css({ display: display.defaultBg });
4574 },
4575 onTouchEnd: function (swiper, event) {
4576 $scope.isSwiping = !1;
4577 },
4578 }),
4579 ($scope.cancelSliderInterval = function () {
4580 $scope.sliderInterval && ($interval.cancel($scope.sliderInterval), ($scope.sliderInterval = null));
4581 });
4582 },
4583 ],
4584 link: function (scope, element, attrs) {
4585 angular.element(element).removeClass("init-intro-animation start-intro-animation no-intro-animation"),
4586 (scope.animation = {
4587 introBg: element[0].querySelector("#intro-bg"),
4588 notificationsTop: element[0].querySelector("#notifications-top"),
4589 notificationsBottom: element[0].querySelector("#notifications-bottom"),
4590 reserveTop: element[0].querySelector("#reserve-top"),
4591 reserveBg: element[0].querySelector("#reserve-bg"),
4592 confirmTop: element[0].querySelector("#confirm-top"),
4593 confirmBottom: element[0].querySelector("#confirm-bottom"),
4594 outroTop: element[0].querySelector("#outro-top"),
4595 outroBg: element[0].querySelector("#outro-bg"),
4596 pagerCue: element[0].querySelector("#pager-cue"),
4597 defaultBg: element[0].querySelector("#default-bg"),
4598 }),
4599 attrs.$observe("onboardingAnimate", function () {
4600 if ("true" === attrs.onboardingAnimate) {
4601 angular.element(element).addClass("init-intro-animation");
4602 var promise = $timeout(function () {
4603 angular.element(element).addClass("start-intro-animation"), $timeout.cancel(promise);
4604 }, Config.onboarding.startIntroAnimationDelay);
4605 } else angular.element(element).addClass("no-intro-animation");
4606 });
4607 },
4608 };
4609 },
4610 ]),
4611 angular.module("app").directive("parsePattern", [
4612 "Config",
4613 function (Config) {
4614 return {
4615 restrict: "A",
4616 require: "ngModel",
4617 link: function (scope, element, attrs, ngModel) {
4618 ngModel.$parsers.push(function (value) {
4619 var formattedValue;
4620 switch (attrs.parsePattern) {
4621 case "cardNumber":
4622 (formattedValue = String(value.replace(Config.parserPatterns.cardNumber, "")).substring(0, 16)), (formattedValue = parseInt(formattedValue));
4623 break;
4624 case "cardSecurityCode":
4625 formattedValue = String(value.replace(Config.parserPatterns.cardSecurityCode, "")).substring(0, 4);
4626 break;
4627 default:
4628 formattedValue = value;
4629 }
4630 return formattedValue;
4631 });
4632 },
4633 };
4634 },
4635 ]),
4636 angular.module("app").directive("phonefield", function () {
4637 return {
4638 restrict: "E",
4639 require: "ngModel",
4640 replace: !0,
4641 templateUrl: "templates/components/phonefield.html",
4642 scope: {
4643 label: "@uiLabel",
4644 countryValue: "=uiCountry",
4645 info: "@uiInfo",
4646 error: "@uiError",
4647 onRenderCallback: "&?uiRenderCallback",
4648 onInitCallback: "&?uiInitCallback",
4649 onFocusCallback: "&?uiFocusCallback",
4650 onChangeCallback: "&?uiChangeCallback",
4651 onBlurCallback: "&?uiBlurCallback",
4652 },
4653 controller: [
4654 "$scope",
4655 "$ionicModal",
4656 "Config",
4657 function ($scope, $ionicModal, Config) {
4658 ($scope.data = { countries: Config.countries }),
4659 ($scope.modalHeader = {
4660 theme: "white",
4661 title: { translate: "modal.title.chooseCountry", translateValues: {} },
4662 buttons: { close: !0 },
4663 callback: {
4664 close: function () {
4665 $scope.closeCountryModal();
4666 },
4667 },
4668 }),
4669 ($scope.openCountryModal = function () {
4670 $ionicModal.fromTemplateUrl("templates/modals/phone-country.html", { scope: $scope, animation: "animation-slide-up" }).then(function (modal) {
4671 ($scope.modal = modal), $scope.modal.show();
4672 });
4673 }),
4674 ($scope.closeCountryModal = function () {
4675 $scope.modal &&
4676 $scope.modal.hide().then(function (modal) {
4677 $scope.modal.remove();
4678 });
4679 }),
4680 $scope.$watch(
4681 function () {
4682 return $scope.countryValue;
4683 },
4684 function (newValue, oldValue) {
4685 (newValue === oldValue && $scope.value) ||
4686 (($scope.value = null), ($scope.placeholder = intlTelInputUtils.getExampleNumber($scope.countryValue, !1, 0)), $scope.model.$setPristine(), $scope.model.$setUntouched(), $scope.onChange());
4687 }
4688 );
4689 },
4690 ],
4691 link: function (scope, element, attrs, ngModel) {
4692 (scope.value = null),
4693 (scope.placeholder = null),
4694 (scope.model = ngModel),
4695 scope.model.$setPristine(),
4696 scope.model.$setUntouched(),
4697 ngModel.$formatters.push(function (modelValue) {
4698 return (scope.value = intlTelInputUtils.formatNumber(modelValue, scope.countryValue, 1)), modelValue;
4699 }),
4700 "function" == typeof scope.onInitCallback && scope.onInitCallback(),
4701 (ngModel.$render = function () {
4702 "function" == typeof scope.onRenderCallback && (scope.value = scope.onRenderCallback({ value: ngModel.$viewValue }));
4703 }),
4704 (scope.onFocus = function () {
4705 scope.disabled || (angular.element(element).addClass("has-focus"), "function" == typeof scope.onFocusCallback && scope.onFocusCallback());
4706 }),
4707 (scope.onChange = function () {
4708 scope.disabled ||
4709 (scope.value && (scope.value = intlTelInputUtils.formatNumber(scope.value, scope.countryValue, 1)),
4710 ngModel.$setViewValue(scope.value),
4711 ngModel.$render(),
4712 "function" == typeof scope.onChangeCallback && scope.onChangeCallback());
4713 }),
4714 (scope.onBlur = function () {
4715 scope.disabled || (ngModel.$setDirty(), ngModel.$setTouched(), angular.element(element).removeClass("has-focus"), "function" == typeof scope.onBlurCallback && scope.onBlurCallback());
4716 }),
4717 (scope.onSelectCountry = function (country) {
4718 (scope.countryValue = country), scope.closeCountryModal();
4719 });
4720 },
4721 };
4722 }),
4723 angular.module("app").directive("qrcode", function () {
4724 return {
4725 restrict: "E",
4726 replace: !0,
4727 templateUrl: "templates/components/qrcode.html",
4728 scope: { data: "=uiData" },
4729 link: function (scope, element, attrs) {
4730 new QRious({ element: document.getElementById("qrious"), value: scope.data, size: 128 });
4731 },
4732 };
4733 }),
4734 angular.module("app").directive("sizeSelector", function () {
4735 return {
4736 restrict: "E",
4737 replace: !0,
4738 templateUrl: "templates/components/size-selector.html",
4739 scope: { size: "=size", selected: "=selected", onClickCallback: "&?onClickCallback" },
4740 controller: [
4741 "$scope",
4742 function ($scope) {
4743 $scope.onClick = function () {
4744 "function" == typeof $scope.onClickCallback && $scope.onClickCallback({ size: $scope.size.value });
4745 };
4746 },
4747 ],
4748 };
4749 }),
4750 angular.module("app").directive("storeSelector", function () {
4751 return {
4752 restrict: "E",
4753 replace: !0,
4754 templateUrl: "templates/components/store-selector.html",
4755 scope: { store: "=store", selected: "=selected", onClickCallback: "&?onClickCallback" },
4756 controller: [
4757 "$scope",
4758 function ($scope) {
4759 $scope.onClick = function () {
4760 "function" == typeof $scope.onClickCallback && $scope.onClickCallback({ storeId: $scope.store.id });
4761 };
4762 },
4763 ],
4764 };
4765 }),
4766 angular.module("app").directive("textfield", function () {
4767 return {
4768 restrict: "E",
4769 require: "ngModel",
4770 replace: !0,
4771 templateUrl: "templates/components/textfield.html",
4772 scope: {
4773 type: "@uiType",
4774 pattern: "@uiPattern",
4775 label: "@uiLabel",
4776 placeholder: "@uiPlaceholder",
4777 iconBefore: "@uiIconBefore",
4778 iconBeforeClick: "&?uiIconBeforeClick",
4779 iconAfter: "@uiIconAfter",
4780 iconAfterClick: "&?uiIconAfterClick",
4781 info: "@uiInfo",
4782 error: "@uiError",
4783 onRenderCallback: "&?uiRenderCallback",
4784 onInitCallback: "&?uiInitCallback",
4785 onFocusCallback: "&?uiFocusCallback",
4786 onChangeCallback: "&?uiChangeCallback",
4787 onBlurCallback: "&?uiBlurCallback",
4788 },
4789 link: function (scope, element, attrs, ngModel) {
4790 (scope.value = null),
4791 (scope.model = ngModel),
4792 "hidden" === scope.type && angular.element(element).addClass("is-hidden"),
4793 ngModel.$setPristine(),
4794 ngModel.$setUntouched(),
4795 ngModel.$formatters.push(function (modelValue) {
4796 return (scope.value = modelValue);
4797 }),
4798 "function" == typeof scope.onInitCallback && scope.onInitCallback(),
4799 (ngModel.$render = function () {
4800 "function" == typeof scope.onRenderCallback && (scope.value = scope.onRenderCallback({ value: ngModel.$modelValue }));
4801 }),
4802 (scope.onFocus = function () {
4803 scope.disabled || (angular.element(element).addClass("has-focus"), "function" == typeof scope.onFocusCallback && scope.onFocusCallback());
4804 }),
4805 (scope.onChange = function () {
4806 scope.disabled || (ngModel.$setViewValue(scope.value), ngModel.$render(), "function" == typeof scope.onChangeCallback && scope.onChangeCallback());
4807 }),
4808 (scope.onBlur = function () {
4809 scope.disabled || (ngModel.$setDirty(), ngModel.$setTouched(), angular.element(element).removeClass("has-focus"), "function" == typeof scope.onBlurCallback && scope.onBlurCallback());
4810 });
4811 },
4812 };
4813 }),
4814 angular.module("app").directive("validateMatch", [
4815 "$parse",
4816 function ($parse) {
4817 return {
4818 restrict: "A",
4819 require: "ngModel",
4820 link: function (scope, element, attrs, ngModel) {
4821 ngModel.$validators.match = function (modelValue, viewValue) {
4822 return modelValue === $parse(attrs.validateMatch)(scope);
4823 };
4824 },
4825 };
4826 },
4827 ]),
4828 angular.module("app").directive("validateNotMatch", [
4829 "$parse",
4830 function ($parse) {
4831 return {
4832 restrict: "A",
4833 require: "ngModel",
4834 link: function (scope, element, attrs, ngModel) {
4835 ngModel.$validators.notMatch = function (modelValue, viewValue) {
4836 return modelValue != $parse(attrs.validateNotMatch)(scope);
4837 };
4838 },
4839 };
4840 },
4841 ]),
4842 angular.module("app").directive("validatePattern", [
4843 "Config",
4844 function (Config) {
4845 return {
4846 restrict: "A",
4847 require: "ngModel",
4848 link: function (scope, element, attrs, ngModel) {
4849 ngModel.$validators.pattern = function (modelValue, viewValue) {
4850 return !modelValue || Config.validatorPatterns[attrs.validatePattern].test(modelValue);
4851 };
4852 },
4853 };
4854 },
4855 ]),
4856 angular.module("app").directive("validatePhone", [
4857 "$parse",
4858 function ($parse) {
4859 return {
4860 restrict: "A",
4861 require: "ngModel",
4862 link: function (scope, element, attrs, ngModel) {
4863 ngModel.$validators.phone = function (modelValue, viewValue) {
4864 var country = $parse(attrs.validatePhone);
4865 return intlTelInputUtils.isValidNumber(modelValue, country(scope));
4866 };
4867 },
4868 };
4869 },
4870 ]),
4871 angular.module("app").factory("Cache", function () {
4872 var cache = {
4873 views: {},
4874 resetAll: function () {
4875 cache.views = { "events.latest": !1, "events.upcoming": !1, "events.event.info": !1 };
4876 },
4877 };
4878 return cache.resetAll(), cache;
4879 }),
4880 angular.module("app").factory("httpApiInterceptor", [
4881 "$window",
4882 "$translate",
4883 "$cordovaNetwork",
4884 "Config",
4885 "Operator",
4886 function ($window, $translate, $cordovaNetwork, Config, Operator) {
4887 return {
4888 request: function (obj) {
4889 return 0 === obj.url.indexOf(Config.copdate.apiUrl) && $window.cordova && $cordovaNetwork.getNetwork() === Connection.NONE && Operator.send("network.none"), obj;
4890 },
4891 response: function (obj) {
4892 if (0 === obj.config.url.indexOf(Config.copdate.apiUrl) && ((obj.data = obj.data || {}), obj.data.error))
4893 switch (obj.data.error.code) {
4894 case 102:
4895 "me" !== obj.config.params.service && Operator.send("app.signOut", { forced: !0 });
4896 break;
4897 case 202:
4898 Operator.send("app.update");
4899 break;
4900 case 299:
4901 Operator.send("app.backdoor", obj.data.error);
4902 }
4903 return obj;
4904 },
4905 };
4906 },
4907 ]),
4908 angular.module("app").factory("$translateStaticFilesLoader", [
4909 "$q",
4910 "$http",
4911 function ($q, $http) {
4912 return function (options) {
4913 if (!(options && (angular.isArray(options.files) || (angular.isString(options.prefix) && angular.isString(options.suffix))))) throw new Error("Couldn't load static files, no files and prefix or suffix specified!");
4914 options.files || (options.files = [{ prefix: options.prefix, suffix: options.suffix }]);
4915 for (
4916 var load = function (file) {
4917 if (!file || !angular.isString(file.prefix) || !angular.isString(file.suffix)) throw new Error("Couldn't load static file, no prefix or suffix specified!");
4918 var deferred = $q.defer();
4919 return (
4920 $http(angular.extend({ url: [file.prefix, options.key, file.suffix].join(""), method: "GET", params: "" }, options.$http))
4921 .success(function (data) {
4922 deferred.resolve(data);
4923 })
4924 .error(function (data) {
4925 deferred.reject(options.key);
4926 }),
4927 deferred.promise
4928 );
4929 },
4930 deferred = $q.defer(),
4931 promises = [],
4932 length = options.files.length,
4933 i = 0;
4934 i < length;
4935 i++
4936 )
4937 promises.push(load({ prefix: options.files[i].prefix, key: options.key, suffix: options.files[i].suffix }));
4938 return (
4939 $q.all(promises).then(
4940 function (data) {
4941 for (var length = data.length, mergedData = {}, i = 0; i < length; i++) for (var key in data[i]) mergedData[key] = data[i][key];
4942 deferred.resolve(mergedData);
4943 },
4944 function (data) {
4945 deferred.reject(data);
4946 }
4947 ),
4948 deferred.promise
4949 );
4950 };
4951 },
4952 ]),
4953 angular.module("app").factory("Map", function () {
4954 var map = {
4955 instance: null,
4956 eventMarker: [],
4957 userMarker: [],
4958 eventCircle: [],
4959 init: function (latitude, longitude, radius, callback) {
4960 if (plugin) {
4961 var position = new plugin.google.maps.LatLng(latitude, longitude);
4962 map.instance
4963 ? (map.clear(), map.instance.setDiv(document.getElementById("map")), map.setEvent(latitude, longitude, radius), "function" == typeof callback && callback())
4964 : ((map.instance = plugin.google.maps.Map.getMap(document.getElementById("map"), {
4965 mapType: plugin.google.maps.MapTypeId.ROADMAP,
4966 controls: { compass: !1, myLocationButton: !1, indoorPicker: !1, zoom: !1 },
4967 gestures: { scroll: !0, tilt: !1, rotate: !1, zoom: !0 },
4968 camera: { latLng: position, zoom: 14 },
4969 styles: [
4970 { elementType: "geometry", stylers: [{ color: "#f5f5f5" }] },
4971 { elementType: "geometry.stroke", stylers: [{ visibility: "simplified" }] },
4972 { elementType: "labels.icon", stylers: [{ visibility: "off" }] },
4973 { elementType: "labels.text.fill", stylers: [{ color: "#616161" }] },
4974 { elementType: "labels.text.stroke", stylers: [{ color: "#f5f5f5" }] },
4975 { featureType: "administrative.land_parcel", elementType: "labels.text.fill", stylers: [{ color: "#bdbdbd" }] },
4976 { featureType: "poi", elementType: "geometry", stylers: [{ color: "#eeeeee" }] },
4977 { featureType: "poi", elementType: "labels.text.fill", stylers: [{ color: "#757575" }] },
4978 { featureType: "poi.park", elementType: "geometry", stylers: [{ color: "#e5e5e5" }] },
4979 { featureType: "poi.park", elementType: "labels.text.fill", stylers: [{ color: "#9e9e9e" }] },
4980 { featureType: "road", elementType: "geometry", stylers: [{ color: "#ffffff" }] },
4981 { featureType: "road.arterial", elementType: "labels.text.fill", stylers: [{ color: "#757575" }] },
4982 { featureType: "road.highway", elementType: "geometry", stylers: [{ color: "#dadada" }] },
4983 { featureType: "road.highway", elementType: "labels.text.fill", stylers: [{ color: "#616161" }] },
4984 { featureType: "road.local", elementType: "labels.text.fill", stylers: [{ color: "#9e9e9e" }] },
4985 { featureType: "transit.line", elementType: "geometry", stylers: [{ color: "#e5e5e5" }] },
4986 { featureType: "transit.station", elementType: "geometry", stylers: [{ color: "#eeeeee" }] },
4987 { featureType: "water", elementType: "geometry", stylers: [{ color: "#c9c9c9" }] },
4988 { featureType: "water", elementType: "labels.text.fill", stylers: [{ color: "#9e9e9e" }] },
4989 ],
4990 })),
4991 map.instance.addEventListenerOnce(plugin.google.maps.event.MAP_READY, function () {
4992 map.instance.setCameraTarget(position), map.setEvent(latitude, longitude, radius), "function" == typeof callback && callback();
4993 }));
4994 }
4995 },
4996 clear: function () {
4997 map.instance && (map.instance.setDiv(null), map.instance.clear(), (map.eventMarker = []), (map.userMarker = []), (map.eventCircle = []));
4998 },
4999 clearUser: function () {
5000 map.instance && (map.userMarker.length && map.userMarker[0].remove(), (map.userMarker = []));
5001 },
5002 setEvent: function (latitude, longitude, radius) {
5003 if (map.instance) {
5004 var position = new plugin.google.maps.LatLng(latitude, longitude);
5005 map.instance.addMarker({ position: position, flat: !0, icon: "#268BEF", zIndex: 201 }, function (marker) {
5006 map.eventMarker[0] = marker;
5007 }),
5008 radius &&
5009 map.instance.addCircle({ center: position, radius: radius, fillColor: "#268BEF40", strokeColor: "#268BEF00", strokeWeight: 2, zIndex: 200 }, function (circle) {
5010 map.eventCircle[0] = circle;
5011 }),
5012 map.instance.moveCamera({ target: position }, function () {});
5013 }
5014 },
5015 setUser: function (latitude, longitude) {
5016 if (map.instance) {
5017 var position = new plugin.google.maps.LatLng(latitude, longitude);
5018 map.userMarker.length
5019 ? map.userMarker[0].setPosition(position)
5020 : map.instance.addMarker({ position: position, flat: !0, icon: "#FF0000", zIndex: 202 }, function (marker) {
5021 map.userMarker[0] = marker;
5022 });
5023 }
5024 },
5025 };
5026 return map;
5027 }),
5028 angular.module("app").factory("Operator", [
5029 "$rootScope",
5030 function ($rootScope) {
5031 var operator = {
5032 send: function (key, data) {
5033 data ? $rootScope.$broadcast(key, data) : $rootScope.$broadcast(key);
5034 },
5035 };
5036 return operator;
5037 },
5038 ]),
5039 angular.module("app").factory("Storage", function () {
5040 var storage = {
5041 data: {
5042 accessToken: null,
5043 apparelSizeMatrix: null,
5044 codePushRelease: null,
5045 deviceOs: null,
5046 deviceUuid: null,
5047 deviceWidth: null,
5048 deviceHeight: null,
5049 deviceDensity: "@3x",
5050 eventCustomSize: null,
5051 eventCustomSlot: null,
5052 eventTicket: null,
5053 footwearSizeMatrix: null,
5054 isAppReady: !1,
5055 oneSignalUserId: null,
5056 oneSignalRedirection: null,
5057 schemeRedirection: null,
5058 stripeKey: null,
5059 },
5060 get: function (key) {
5061 return storage.data[key];
5062 },
5063 getFromLocalStorage: function (key) {
5064 return localforage.getItem(key);
5065 },
5066 set: function (key, value, localStorage) {
5067 (storage.data[key] = value), localStorage && localforage.setItem(key, value);
5068 },
5069 unset: function (key) {
5070 (storage.data[key] = null), localforage.removeItem(key);
5071 },
5072 };
5073 return storage;
5074 }),
5075 angular.module("app").factory("User", [
5076 "$q",
5077 "$timeout",
5078 "$interval",
5079 "$ionicHistory",
5080 "Config",
5081 "Storage",
5082 "UserService",
5083 "Utils",
5084 "Operator",
5085 function ($q, $timeout, $interval, $ionicHistory, Config, Storage, UserService, Utils, Operator) {
5086 var user = {
5087 isConnected: null,
5088 isNotificationsEnabled: null,
5089 isLocationShared: null,
5090 profile: {},
5091 location: {},
5092 card: null,
5093 sizes: {},
5094 notifications: {},
5095 notificationsInterval: null,
5096 init: function (callback) {
5097 $q.all([Storage.getFromLocalStorage("accessToken"), Storage.getFromLocalStorage("oneSignalUserId")])
5098 .then(function (values) {
5099 Storage.set("accessToken", values[0]), Storage.set("oneSignalUserId", values[1]);
5100 })
5101 .catch(function (errors) {})
5102 .finally(function () {
5103 Storage.get("accessToken")
5104 ? UserService.me().then(function (response) {
5105 (response.data = response.data || {}),
5106 response.data.success
5107 ? ((response.data.payload.sizes = response.data.payload.sizes || {}),
5108 user.connect(),
5109 user.setProfile({
5110 user_id: response.data.payload.user_id,
5111 first_name: response.data.payload.first_name,
5112 last_name: response.data.payload.last_name,
5113 email: response.data.payload.email,
5114 phone: response.data.payload.phone,
5115 phone_country_code: response.data.payload.phone_country_code,
5116 }),
5117 user.setCard(response.data.payload.saved_card),
5118 user.initSizes(response.data.payload.sizes),
5119 user.setNotifications(response.data.payload.notifications),
5120 Storage.set("stripeKey", response.data.payload.stripe_key),
5121 Storage.get("oneSignalUserId") && response.data.payload.one_signal_user_id !== Storage.get("oneSignalUserId") && UserService.updateOneSignalId())
5122 : (user.disconnect(), user.resetProfile(), user.resetNotifications()),
5123 "function" == typeof callback && callback();
5124 })
5125 : "function" == typeof callback && callback();
5126 });
5127 },
5128 connect: function () {
5129 user.isConnected = !0;
5130 },
5131 disconnect: function () {
5132 (user.isConnected = !1),
5133 user.resetProfile(),
5134 user.resetLocation(),
5135 user.resetCard(),
5136 user.resetSizes(),
5137 user.resetNotifications(),
5138 user.stopNotificationsUpdateInterval(),
5139 Storage.unset("accessToken"),
5140 Storage.unset("oneSignalUserId"),
5141 Storage.unset("stripeKey");
5142 },
5143 enableNotifications: function (enabled) {
5144 user.isNotificationsEnabled = enabled;
5145 },
5146 shareLocation: function (shared) {
5147 user.isLocationShared = shared;
5148 },
5149 setProfile: function (profile) {
5150 user.profile = { id: profile.user_id, name: { first: profile.first_name, last: profile.last_name }, email: profile.email, phone: profile.phone, phoneCountryCode: profile.phone_country_code };
5151 },
5152 resetProfile: function () {
5153 user.profile = {};
5154 },
5155 setLocation: function (location) {
5156 (location = location || {}),
5157 (user.location = { latitude: location.latitude || null, longitude: location.longitude || null, city: location.city || null, country: location.country || null, countryCode: location.country_code || null });
5158 },
5159 resetLocation: function () {
5160 user.location = {};
5161 },
5162 setCard: function (card) {
5163 card && "American Express" === card.type && (card.type = "amex"), (user.card = card || null);
5164 },
5165 resetCard: function () {
5166 user.card = null;
5167 },
5168 initSizes: function (sizes) {
5169 sizes.shoe && user.setSizes("footwear", { gender: sizes.shoe.gender, size: sizes.shoe.size }), sizes.apparel && user.setSizes("apparel", { gender: sizes.apparel.gender, size: sizes.apparel.size });
5170 },
5171 setSizes: function (type, size) {
5172 type && (user.sizes[type] = size || {});
5173 },
5174 resetSizes: function () {
5175 user.sizes = {};
5176 },
5177 getNotifications: function () {
5178 UserService.getNotifications().then(function (response) {
5179 (response.data = response.data || {}), response.data.success && (user.setNotifications(response.data.payload.notifications), Operator.send("header.notificationsUpdate"));
5180 });
5181 },
5182 setNotifications: function (notifications) {
5183 (notifications = notifications || {}),
5184 (user.notifications = {
5185 latest: notifications.latest_events || 0,
5186 upcoming: notifications.upcoming_events || 0,
5187 messages: notifications.messages || 0,
5188 copped: notifications.total_copped || 0,
5189 listed: notifications.total_listed || 0,
5190 });
5191 },
5192 resetNotifications: function () {
5193 user.notifications = { latest: 0, upcoming: 0, messages: 0, copped: 0, listed: 0 };
5194 },
5195 startNotificationsUpdateInterval: function () {
5196 user.stopNotificationsUpdateInterval(),
5197 user.isConnected &&
5198 (user.notificationsInterval = $interval(function () {
5199 user.getNotifications();
5200 }, Config.default.notificationsUpdateInterval));
5201 },
5202 stopNotificationsUpdateInterval: function () {
5203 user.notificationsInterval && ($interval.cancel(user.notificationsInterval), (user.notificationsInterval = null));
5204 },
5205 };
5206 return user;
5207 },
5208 ]),
5209 angular.module("app").filter("cardExpiration", function () {
5210 return function (date) {
5211 if (angular.isDate(date)) return (date.getMonth() < 9 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + "/" + date.getFullYear().toString().substr(2, 2);
5212 };
5213 }),
5214 angular.module("app").filter("cardNumber", function () {
5215 return function (number, type) {
5216 if (number) {
5217 var formattedValue = (number = String(number)),
5218 block1 = number.substring(0, 4),
5219 block2 = number.substring(4, 8),
5220 block3 = number.substring(8, 12),
5221 block4 = number.substring(12, 16);
5222 switch (type) {
5223 case "amex":
5224 (block2 = number.substring(4, 10)), (block3 = number.substring(10, 15)), (block4 = "");
5225 }
5226 return (formattedValue = block1), block2 && (formattedValue += " " + block2), block3 && (formattedValue += " " + block3), block4 && (formattedValue += " " + block4), formattedValue;
5227 }
5228 };
5229 }),
5230 angular.module("app").filter("cardSecurityCode", function () {
5231 return function (code) {
5232 if (code) return code.substring(0, 4);
5233 };
5234 }),
5235 angular.module("app").filter("phone", function () {
5236 return function (number) {
5237 if (number) {
5238 var formattedNumber = (number = "1" == (number = String(number))[0] ? number.slice(1) : number),
5239 c = "1" == number[0] ? "1 " : "",
5240 area = number.substring(0, 3),
5241 front = number.substring(3, 6),
5242 end = number.substring(6, 10);
5243 return front && (formattedNumber = c + "(" + area + ") " + front), end && (formattedNumber += "-" + end), formattedNumber;
5244 }
5245 };
5246 }),
5247 angular.module("app").service("Api", [
5248 "$q",
5249 "$http",
5250 "$cacheFactory",
5251 "$timeout",
5252 "Config",
5253 function ($q, $http, $cacheFactory, $timeout, Config) {
5254 (this.generateSig = function (data) {
5255 data.sig && delete data.sig;
5256 var keys = Object.keys(data).sort(),
5257 output = "";
5258 for (var key in keys) output += keys[key] + "=" + data[keys[key]];
5259 return CryptoJS.SHA1(output + Config.copdate.apiSecret).toString();
5260 }),
5261 (this.call = function (params, cacheType) {
5262 var promise,
5263 canceller = $q.defer(),
5264 deferred = $q.defer(),
5265 data = { params: params, timeout: canceller.promise },
5266 isCancelled = !1,
5267 sig = this.generateSig(params);
5268 return (
5269 (data.params.sig = sig),
5270 cacheType && (data.cache = $cacheFactory.get(cacheType)),
5271 (promise = $timeout(function () {
5272 canceller.resolve(), (isCancelled = !0), $timeout.cancel(promise);
5273 }, Config.copdate.apiTimeoutDelay)),
5274 $http.get(Config.copdate.apiUrl, data).then(
5275 function (response) {
5276 $timeout.cancel(promise), deferred.resolve(response);
5277 },
5278 function (response) {
5279 isCancelled ? deferred.resolve({ timeout: !0 }) : ($timeout.cancel(promise), deferred.resolve(response));
5280 }
5281 ),
5282 deferred.promise
5283 );
5284 }),
5285 (this.load = function (url) {
5286 return $http.get(url);
5287 });
5288 },
5289 ]),
5290 angular.module("app").service("Beacon", [
5291 "$window",
5292 "Storage",
5293 function ($window, Storage) {
5294 (this.region = {}),
5295 (this.androidRegion = {}),
5296 (this.setRegion = function (identifier, uuid, major, minor) {
5297 identifier && uuid && (this.region = { identifier: identifier, uuid: uuid, major: major || 0, minor: minor || 0 });
5298 }),
5299 (this.getRegion = function () {
5300 return this.region.uuid + ":" + this.region.major + ":" + this.region.minor;
5301 }),
5302 (this.startRanging = function (successCallback, errorCallback) {
5303 if ("iOS" === Storage.get("deviceOs")) {
5304 if (!$window.EstimoteBeacons) return;
5305 $window.EstimoteBeacons.startRangingBeaconsInRegion(
5306 this.region,
5307 function (result) {
5308 "function" == typeof successCallback && successCallback(result);
5309 },
5310 function (error) {
5311 "function" == typeof errorCallback && errorCallback(error);
5312 }
5313 );
5314 } else {
5315 var delegate = new cordova.plugins.locationManager.Delegate();
5316 (delegate.didDetermineStateForRegion = function (pluginResult) {}),
5317 (delegate.didStartMonitoringForRegion = function (pluginResult) {}),
5318 (delegate.didRangeBeaconsInRegion = function (pluginResult) {
5319 "function" == typeof successCallback && successCallback(pluginResult);
5320 }),
5321 (this.androidRegion = new cordova.plugins.locationManager.BeaconRegion(this.region.identifier, this.region.uuid, this.region.major, this.region.minor)),
5322 cordova.plugins.locationManager.setDelegate(delegate),
5323 cordova.plugins.locationManager
5324 .startRangingBeaconsInRegion(this.androidRegion)
5325 .fail(function (error) {
5326 "function" == typeof errorCallback && errorCallback(error);
5327 })
5328 .done();
5329 }
5330 }),
5331 (this.stopRanging = function () {
5332 var self = this;
5333 "iOS" === Storage.get("deviceOs")
5334 ? $window.EstimoteBeacons.stopRangingBeaconsInRegion(
5335 this.region,
5336 function (result) {
5337 self.region = {};
5338 },
5339 function (error) {
5340 self.region = {};
5341 }
5342 )
5343 : (cordova.plugins.locationManager
5344 .stopRangingBeaconsInRegion(this.androidRegion)
5345 .fail(function (e) {
5346 self.androidRegion = {};
5347 })
5348 .done(),
5349 (this.androidRegion = {}));
5350 });
5351 },
5352 ]),
5353 angular.module("app").service("Codepush", [
5354 "$window",
5355 "Storage",
5356 function ($window, Storage) {
5357 (this.sync = function (callback) {
5358 $window.codePush &&
5359 $window.codePush.sync(
5360 function (status) {
5361 "function" == typeof callback && callback();
5362 },
5363 null,
5364 null,
5365 function (error) {}
5366 );
5367 }),
5368 (this.getCurrentPackage = function (callback) {
5369 $window.codePush &&
5370 $window.codePush.getCurrentPackage(
5371 function (update) {
5372 update && "function" == typeof callback && callback(update);
5373 },
5374 function (error) {}
5375 );
5376 });
5377 },
5378 ]),
5379 angular.module("app").service("ContentService", [
5380 "Api",
5381 function (Api) {
5382 this.loadContent = function (url) {
5383 return Api.load(url);
5384 };
5385 },
5386 ]),
5387 angular.module("app").service("Diagnostic", [
5388 "$window",
5389 function ($window) {
5390 (this.isNotificationsEnabled = function (callback) {
5391 $window.cordova &&
5392 cordova.plugins.diagnostic.isRemoteNotificationsEnabled(
5393 function (enabled) {
5394 "function" == typeof callback && callback(enabled);
5395 },
5396 function (error) {}
5397 );
5398 }),
5399 (this.isLocationAuthorized = function (callback) {
5400 $window.cordova &&
5401 cordova.plugins.diagnostic.isLocationAuthorized(
5402 function (authorized) {
5403 "function" == typeof callback && callback(authorized);
5404 },
5405 function (error) {}
5406 );
5407 }),
5408 (this.isDeviceRooted = function (callback) {
5409 $window.cordova &&
5410 IRoot.isRooted(
5411 function (result) {
5412 "function" == typeof callback && callback(result);
5413 },
5414 function (error) {}
5415 );
5416 });
5417 },
5418 ]),
5419 angular.module("app").service("EventService", [
5420 "Storage",
5421 "Api",
5422 function (Storage, Api) {
5423 (this.getLatestEvents = function (params) {
5424 return ((params = params || {}).service = "getLatestEvents"), (params.access_token = Storage.data.accessToken), Api.call(params);
5425 }),
5426 (this.getUpcomingEvents = function (params) {
5427 return ((params = params || {}).service = "getUpcomingEvents"), (params.access_token = Storage.data.accessToken), Api.call(params);
5428 }),
5429 (this.getEvent = function (params) {
5430 return ((params = params || {}).service = "getEvent"), (params.access_token = Storage.data.accessToken), Api.call(params);
5431 }),
5432 (this.getEventRules = function (params) {
5433 return ((params = params || {}).service = "getEventRules"), (params.access_token = Storage.data.accessToken), Api.call(params);
5434 }),
5435 (this.getEventTimeout = function (params) {
5436 return ((params = params || {}).service = "getEventTimeout"), (params.access_token = Storage.data.accessToken), Api.call(params);
5437 }),
5438 (this.getEventCopStatus = function (params) {
5439 return ((params = params || {}).service = "getEventCopStatus"), (params.access_token = Storage.data.accessToken), Api.call(params);
5440 }),
5441 (this.copEvent = function (params) {
5442 return ((params = params || {}).service = "eventCop"), (params.access_token = Storage.data.accessToken), (params.device_id = Storage.get("deviceUuid") || "na"), Api.call(params);
5443 }),
5444 (this.confirmFreeReservation = function (params) {
5445 return ((params = params || {}).service = "eventCopFreeConfirmation"), (params.access_token = Storage.data.accessToken), Api.call(params);
5446 }),
5447 (this.confirmPaidReservation = function (params) {
5448 return ((params = params || {}).service = "eventCopPaidConfirmation"), (params.access_token = Storage.data.accessToken), (params.device_id = Storage.get("deviceUuid") || "na"), Api.call(params);
5449 }),
5450 (this.dropEvent = function (params) {
5451 return ((params = params || {}).service = "eventDrop"), (params.access_token = Storage.data.accessToken), Api.call(params);
5452 }),
5453 (this.cancelReservation = function (params) {
5454 return ((params = params || {}).service = "eventReservationCancelled"), (params.access_token = Storage.data.accessToken), Api.call(params);
5455 }),
5456 (this.clearReservation = function (params) {
5457 return ((params = params || {}).service = "eventReservationReset"), (params.access_token = Storage.data.accessToken), Api.call(params);
5458 });
5459 },
5460 ]),
5461 angular.module("app").service("FormService", [
5462 "Config",
5463 function (Config) {
5464 (this.oldScheme = null),
5465 (this.newScheme = null),
5466 (this.errorMessages = null),
5467 (this.setForm = function (data) {
5468 return (this.oldScheme = { value: data.value, error: data.error }), (this.newScheme = angular.copy(this.oldScheme)), (this.errorMessages = data.errorMessages), this.newScheme;
5469 }),
5470 (this.validateField = function (formInstance, field) {
5471 if ((formInstance = formInstance || {})[field])
5472 if (formInstance[field].$touched) {
5473 var error = this.parseErrors(formInstance[field].$error);
5474 this.newScheme.error[field] = this.errorMessages[field][error] || "";
5475 } else this.newScheme.error[field] = "";
5476 }),
5477 (this.validateForm = function (formInstance) {
5478 if (formInstance.$invalid) {
5479 for (var key in this.newScheme.error) formInstance[key] && (formInstance[key].$setTouched(), formInstance[key].$setDirty(), this.validateField(key));
5480 return !1;
5481 }
5482 return !0;
5483 }),
5484 (this.parseErrors = function (errors) {
5485 var error;
5486 return errors.required ? (error = "required") : errors.maxlength ? (error = "maxlength") : errors.pattern ? (error = "pattern") : errors.match ? (error = "match") : errors.notMatch && (error = "notMatch"), error;
5487 });
5488 },
5489 ]),
5490 angular.module("app").service("GA", [
5491 "$window",
5492 "Config",
5493 function ($window, Config) {
5494 (this.trackView = function (stateName) {
5495 var view;
5496 if (Config.googleAnalytics.trackingId && $window.ga) {
5497 switch (stateName) {
5498 case "landing":
5499 view = "Landing";
5500 break;
5501 case "connect.signup":
5502 view = "Signup";
5503 break;
5504 case "connect.chooseStores":
5505 view = "Signup - Choose store";
5506 break;
5507 case "connect.chooseSize":
5508 view = "Signup - Choose size";
5509 break;
5510 case "connect.notifications":
5511 view = "Signup - Notifications";
5512 break;
5513 case "connect.login":
5514 view = "Login";
5515 break;
5516 case "connect.forgot":
5517 view = "Forgot password";
5518 }
5519 view && $window.ga.trackView(view);
5520 }
5521 }),
5522 (this.trackUser = function (id) {
5523 Config.googleAnalytics.trackingId && $window.ga && $window.ga("set", "&uid", id);
5524 }),
5525 (this.trackEvent = function (category, action, label, value) {
5526 Config.googleAnalytics.trackingId && ((label = label || null), (value = value || null), $window.ga && $window.ga.trackEvent(category, action, label, value));
5527 });
5528 },
5529 ]),
5530 angular.module("app").service("Geolocation", [
5531 "$window",
5532 "Config",
5533 function ($window, Config) {
5534 (this.instance = null),
5535 (this.config = {}),
5536 (this.geofence = {}),
5537 (this.geofencesChangeCallback = null),
5538 (this.providerStatus = 0),
5539 (this.providerChangeCallback = null),
5540 (this.positionCallback = null),
5541 (this.setConfig = function (config) {
5542 config && (this.config = config);
5543 }),
5544 (this.setGeofenceProximityRadius = function (radius) {
5545 radius && this.instance && this.instance.setConfig({ geofenceProximityRadius: radius });
5546 }),
5547 (this.setGeofence = function (geofence) {
5548 geofence && (this.geofence = geofence);
5549 }),
5550 (this.init = function (callback) {
5551 if ($window.BackgroundGeolocation && !this.instance) {
5552 var self = this;
5553 (this.instance = $window.BackgroundGeolocation),
5554 this.instance.on("providerchange", function (provider) {
5555 (self.provider = provider), (self.providerStatus = provider.status), "function" == typeof self.providerChangeCallback && self.providerChangeCallback();
5556 }),
5557 this.instance.configure(
5558 this.config,
5559 function (state) {
5560 "function" == typeof callback && callback();
5561 },
5562 function (error) {}
5563 );
5564 } else "function" == typeof callback && callback();
5565 }),
5566 (this.start = function () {
5567 if (this.instance) {
5568 var self = this;
5569 this.instance.start(function () {
5570 self.instance.getCurrentPosition(function (location, taskId) {
5571 self.instance.finish(taskId), "function" == typeof self.positionCallback && self.positionCallback(location);
5572 });
5573 });
5574 }
5575 }),
5576 (this.startGeofences = function () {
5577 if (this.instance) {
5578 var self = this;
5579 this.instance.on("geofenceschange", function (event) {
5580 "function" == typeof self.geofencesChangeCallback && self.geofencesChangeCallback(event);
5581 }),
5582 this.instance.startGeofences(function () {
5583 self.instance.getCurrentPosition(function (location, taskId) {
5584 self.instance.finish(taskId), "function" == typeof self.positionCallback && self.positionCallback(location);
5585 }),
5586 self.instance.watchPosition(function (location) {
5587 "function" == typeof self.positionCallback && self.positionCallback(location);
5588 });
5589 });
5590 }
5591 }),
5592 (this.addGeofence = function () {
5593 this.instance &&
5594 this.geofence.identifier &&
5595 this.instance.addGeofence(
5596 this.geofence,
5597 function () {},
5598 function (error) {}
5599 );
5600 }),
5601 (this.removeGeofences = function () {
5602 this.instance &&
5603 this.instance.removeGeofences(
5604 function () {},
5605 function (error) {}
5606 );
5607 }),
5608 (this.stop = function () {
5609 this.instance && (this.instance.stop(), (this.config = {}), (this.geofence = {}));
5610 });
5611 },
5612 ]),
5613 angular.module("app").service("SizesService", [
5614 "Api",
5615 function (Api) {
5616 this.getSizeMatrix = function () {
5617 return Api.call({ service: "sizeMatrix" });
5618 };
5619 },
5620 ]),
5621 angular.module("app").service("StoreService", [
5622 "Storage",
5623 "Api",
5624 function (Storage, Api) {
5625 this.getList = function () {
5626 var params = { service: "getStores", access_token: Storage.data.accessToken };
5627 return Api.call(params);
5628 };
5629 },
5630 ]),
5631 angular.module("app").service("StripeApi", [
5632 "$http",
5633 "Config",
5634 function ($http, Config) {
5635 this.getCardToken = function (key, data) {
5636 data = data || {};
5637 var config = { headers: { Authorization: "Bearer " + key, "Content-Type": "application/x-www-form-urlencoded" } };
5638 return $http.post(Config.stripe.appUrl + "/tokens", data, config);
5639 };
5640 },
5641 ]),
5642 angular.module("app").service("UserService", [
5643 "Config",
5644 "Storage",
5645 "Api",
5646 function (Config, Storage, Api) {
5647 (this.signUp = function (params) {
5648 return (
5649 ((params = params || {}).service = "signup"),
5650 (params.app_version = Config.app.version),
5651 (params.device_os = Storage.get("deviceOs") || "na"),
5652 (params.device_id = Storage.get("deviceUuid") || "na"),
5653 (params.one_signal_user_id = Storage.get("oneSignalUserId") || "na"),
5654 Api.call(params)
5655 );
5656 }),
5657 (this.signIn = function (params) {
5658 return (
5659 ((params = params || {}).service = "login"),
5660 (params.app_version = Config.app.version),
5661 (params.device_os = Storage.get("deviceOs") || "na"),
5662 (params.device_id = Storage.get("deviceUuid") || "na"),
5663 (params.one_signal_user_id = Storage.get("oneSignalUserId") || "na"),
5664 Api.call(params)
5665 );
5666 }),
5667 (this.signOut = function () {
5668 var params = { service: "logout", access_token: Storage.get("accessToken"), device_id: Storage.get("deviceUuid") || "na" };
5669 return Api.call(params);
5670 }),
5671 (this.resetPassword = function (params) {
5672 return ((params = params || {}).service = "forgotPassword"), Api.call(params);
5673 }),
5674 (this.me = function () {
5675 var params = { service: "me", app_version: Config.app.version, access_token: Storage.get("accessToken"), device_id: Storage.get("deviceUuid") || "na", one_signal_user_id: Storage.get("oneSignalUserId") || "na" };
5676 return Api.call(params);
5677 }),
5678 (this.getCoppedEvents = function () {
5679 var params = { service: "getUserCops", access_token: Storage.get("accessToken") };
5680 return Api.call(params);
5681 }),
5682 (this.getListedEvents = function () {
5683 var params = { service: "getUserListed", access_token: Storage.get("accessToken") };
5684 return Api.call(params);
5685 }),
5686 (this.getNotifications = function () {
5687 var params = { service: "getUserNotifications", access_token: Storage.get("accessToken") };
5688 return Api.call(params);
5689 }),
5690 (this.getMessages = function (params) {
5691 return ((params = params || {}).service = "getMessages"), (params.access_token = Storage.get("accessToken")), Api.call(params);
5692 }),
5693 (this.getMessage = function (params) {
5694 return ((params = params || {}).service = "getMessage"), (params.access_token = Storage.data.accessToken), Api.call(params);
5695 }),
5696 (this.updateProfile = function (params) {
5697 return ((params = params || {}).service = "updateUserProfile"), (params.access_token = Storage.get("accessToken")), Api.call(params);
5698 }),
5699 (this.changePassword = function (params) {
5700 return ((params = params || {}).service = "changePassword"), (params.access_token = Storage.get("accessToken")), Api.call(params);
5701 }),
5702 (this.getStores = function () {
5703 var params = { service: "getUserStores", access_token: Storage.get("accessToken") };
5704 return Api.call(params);
5705 }),
5706 (this.updateStores = function (params) {
5707 return ((params = params || {}).service = "updateUserStores"), (params.access_token = Storage.get("accessToken")), Api.call(params);
5708 }),
5709 (this.updateSizes = function (params) {
5710 return ((params = params || {}).service = "updateUserSizes"), (params.access_token = Storage.get("accessToken")), Api.call(params);
5711 }),
5712 (this.saveCard = function (params) {
5713 return ((params = params || {}).service = "savePaymentInfo"), (params.access_token = Storage.get("accessToken")), Api.call(params);
5714 }),
5715 (this.deleteCard = function () {
5716 var params = { service: "deletePaymentInfo", access_token: Storage.get("accessToken") };
5717 return Api.call(params);
5718 }),
5719 (this.updateOneSignalId = function () {
5720 var params = { service: "updateOneSignalId", access_token: Storage.get("accessToken"), one_signal_user_id: Storage.get("oneSignalUserId") };
5721 return Api.call(params);
5722 }),
5723 (this.getTransactions = function (params) {
5724 return ((params = params || {}).service = "getUserTransactions"), (params.access_token = Storage.get("accessToken")), Api.call(params);
5725 });
5726 },
5727 ]),
5728 angular.module("app").service("Utils", [
5729 "$window",
5730 "$filter",
5731 "$ionicHistory",
5732 "$ionicNativeTransitions",
5733 "Config",
5734 function ($window, $filter, $ionicHistory, $ionicNativeTransitions, Config) {
5735 (this.goTo = function ($event, stateName, transition, stateParams) {
5736 if ($event) {
5737 if (($event.preventDefault(), $event.target.href)) return void ($window.cordova ? cordova.InAppBrowser.open($event.target.href, "_system") : $window.open($event.target.href, "_blank"));
5738 if ($event.target.pathname) return void ($window.cordova ? cordova.InAppBrowser.open($event.target.pathname, "_system") : $window.open($event.target.pathname, "_self"));
5739 }
5740 stateName && ((transition = transition || null), (stateParams = stateParams || {}), this.switchState(stateName, transition, stateParams));
5741 }),
5742 (this.switchState = function (stateName, transition, stateParams) {
5743 stateParams = stateParams || {};
5744 var transitionOptions = {};
5745 switch (transition) {
5746 case "fade":
5747 transitionOptions = { type: "fade", duration: Config.transitions.fadeDuration };
5748 break;
5749 case "slide-left":
5750 case "slide-right":
5751 case "slide-up":
5752 case "slide-down":
5753 transitionOptions = { type: "slide", direction: transition.split("-")[1] };
5754 break;
5755 case "no-transition":
5756 transitionOptions = { type: "fade", duration: 0 };
5757 break;
5758 default:
5759 transitionOptions = { type: "slide", direction: "left" };
5760 }
5761 void 0 === transitionOptions.duration && (transitionOptions.duration = Config.transitions.defaultDuration), $ionicNativeTransitions.stateGo(stateName, stateParams, {}, transitionOptions);
5762 }),
5763 (this.getPhoneNumberRaw = function (number, country) {
5764 return intlTelInputUtils.formatNumber(number, country, 2).replace(/[^0-9]+/g, "");
5765 }),
5766 (this.getCardBrand = function (number) {
5767 var brand;
5768 return Config.validatorPatterns.visa.test(number) ? (brand = "visa") : Config.validatorPatterns.mastercard.test(number) ? (brand = "mastercard") : Config.validatorPatterns.amex.test(number) && (brand = "amex"), brand;
5769 }),
5770 (this.switchView = function (view, transition, params) {
5771 var options = {};
5772 switch (((params = params || {}), transition)) {
5773 case "fade":
5774 options = { type: "fade", duration: Config.transitions.fade.duration };
5775 break;
5776 case "slide-reverse":
5777 options = { type: "slide", direction: "right", duration: Config.transitions.slide.duration };
5778 break;
5779 case "no-transition":
5780 options = { type: "fade", duration: 0 };
5781 break;
5782 default:
5783 options = { type: "slide", direction: "left", duration: Config.transitions.slide.duration };
5784 }
5785 $ionicNativeTransitions.stateGo(view, params, options);
5786 }),
5787 (this.findItemByKey = function (key, value, array) {
5788 return $filter("filter")(array, function (item) {
5789 return item[key] === value;
5790 })[0];
5791 });
5792 },
5793 ]);
5794//# sourceMappingURL=app.min.js.map
5795