authscape 1.0.708 → 1.0.710

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -42,64 +42,48 @@ function AuthScapeApp(_ref) {
42
42
  _ref$enforceLoggedIn = _ref.enforceLoggedIn,
43
43
  enforceLoggedIn = _ref$enforceLoggedIn === void 0 ? false : _ref$enforceLoggedIn,
44
44
  _ref$enableAuth = _ref.enableAuth,
45
- enableAuth = _ref$enableAuth === void 0 ? true : _ref$enableAuth,
46
- _ref$enableConsentDia = _ref.enableConsentDialog,
47
- enableConsentDialog = _ref$enableConsentDia === void 0 ? false : _ref$enableConsentDia;
45
+ enableAuth = _ref$enableAuth === void 0 ? true : _ref$enableAuth;
48
46
  var _useState = (0, _react.useState)(false),
49
47
  _useState2 = _slicedToArray(_useState, 2),
50
48
  frontEndLoadedState = _useState2[0],
51
49
  setFrontEndLoadedState = _useState2[1];
52
50
  var _useState3 = (0, _react.useState)(false),
53
51
  _useState4 = _slicedToArray(_useState3, 2),
54
- concentState = _useState4[0],
55
- setConcentState = _useState4[1];
56
- var _useState5 = (0, _react.useState)(false),
52
+ isLoadingShow = _useState4[0],
53
+ setIsLoadingShow = _useState4[1];
54
+ var _useState5 = (0, _react.useState)(null),
57
55
  _useState6 = _slicedToArray(_useState5, 2),
58
- isLoadingShow = _useState6[0],
59
- setIsLoadingShow = _useState6[1];
60
- var _useState7 = (0, _react.useState)(null),
61
- _useState8 = _slicedToArray(_useState7, 2),
62
- signedInUserState = _useState8[0],
63
- setSignedInUserState = _useState8[1];
56
+ signedInUserState = _useState6[0],
57
+ setSignedInUserState = _useState6[1];
64
58
  var loadingAuth = (0, _react.useRef)(false);
65
- var frontEndLoaded = (0, _react.useRef)(false);
66
59
  var signedInUser = (0, _react.useRef)(null);
67
60
  var queryCodeUsed = (0, _react.useRef)(null);
68
61
  var ga4React = (0, _react.useRef)(null);
69
62
  var searchParams = (0, _navigation.useSearchParams)();
70
- var queryRef = searchParams.get('ref');
71
63
  var queryCode = searchParams.get('code');
72
64
  var pathname = (0, _navigation.usePathname)();
73
- var handleConsentAccepted = function handleConsentAccepted(prefs) {
74
- console.log("Consent accepted:", prefs);
75
- setConcentState(prefs);
76
- };
77
- var handleConsentRejected = function handleConsentRejected() {
78
- console.log("Consent rejected");
79
- setConcentState(null);
80
- // disable analytics scripts, etc.
81
- };
65
+
66
+ // ---------- PKCE Sign-in ----------
82
67
  var signInValidator = /*#__PURE__*/function () {
83
68
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(queryCode) {
84
69
  var codeVerifier, headers, queryString, response, domainHost, redirectUri;
85
70
  return _regeneratorRuntime().wrap(function _callee$(_context) {
86
71
  while (1) switch (_context.prev = _context.next) {
87
72
  case 0:
88
- if (!(queryCodeUsed.current != queryCode)) {
89
- _context.next = 4;
73
+ if (!(queryCodeUsed.current === queryCode)) {
74
+ _context.next = 2;
90
75
  break;
91
76
  }
92
- queryCodeUsed.current = queryCode;
93
- _context.next = 5;
94
- break;
95
- case 4:
96
77
  return _context.abrupt("return");
97
- case 5:
78
+ case 2:
79
+ queryCodeUsed.current = queryCode;
98
80
  codeVerifier = window.localStorage.getItem("verifier");
99
- if (!(queryCode != null && codeVerifier != null)) {
100
- _context.next = 28;
81
+ if (!(!queryCode || !codeVerifier)) {
82
+ _context.next = 6;
101
83
  break;
102
84
  }
85
+ return _context.abrupt("return");
86
+ case 6:
103
87
  headers = {
104
88
  'Content-Type': 'application/x-www-form-urlencoded'
105
89
  };
@@ -111,417 +95,194 @@ function AuthScapeApp(_ref) {
111
95
  client_secret: process.env.client_secret,
112
96
  code_verifier: codeVerifier
113
97
  });
114
- _context.prev = 9;
115
- _context.next = 12;
98
+ _context.prev = 8;
99
+ _context.next = 11;
116
100
  return _axios["default"].post(process.env.authorityUri + '/connect/token', queryString, {
117
101
  headers: headers
118
102
  });
119
- case 12:
103
+ case 11:
120
104
  response = _context.sent;
121
105
  domainHost = window.location.hostname.split('.').slice(-2).join('.');
122
106
  window.localStorage.removeItem("verifier");
123
- _context.next = 17;
107
+ _context.next = 16;
124
108
  return setCookie('access_token', response.data.access_token, {
125
109
  maxAge: 60 * 60 * 24 * 365,
126
- // 1 year,
127
110
  path: '/',
128
111
  domain: domainHost,
129
112
  secure: true
130
113
  });
131
- case 17:
132
- _context.next = 19;
114
+ case 16:
115
+ _context.next = 18;
133
116
  return setCookie('expires_in', response.data.expires_in, {
134
117
  maxAge: 60 * 60 * 24 * 365,
135
- // 1 year,
136
118
  path: '/',
137
119
  domain: domainHost,
138
120
  secure: true
139
121
  });
140
- case 19:
141
- _context.next = 21;
122
+ case 18:
123
+ _context.next = 20;
142
124
  return setCookie('refresh_token', response.data.refresh_token, {
143
125
  maxAge: 60 * 60 * 24 * 365,
144
- // 1 year,
145
126
  path: '/',
146
127
  domain: domainHost,
147
128
  secure: true
148
129
  });
149
- case 21:
150
- // await setCookie(null, "access_token", response.data.access_token,
151
- // {
152
- // maxAge: 2147483647,
153
- // path: '/',
154
- // domain: domainHost,
155
- // secure: true
156
- // });
157
- // await setCookie(null, "expires_in", response.data.expires_in,
158
- // {
159
- // maxAge: 2147483647,
160
- // path: '/',
161
- // domain: domainHost,
162
- // secure: true
163
- // });
164
- // await setCookie(null, "refresh_token", response.data.refresh_token,
165
- // {
166
- // maxAge: 2147483647,
167
- // path: '/',
168
- // domain: domainHost,
169
- // secure: true
170
- // });
130
+ case 20:
171
131
  redirectUri = localStorage.getItem("redirectUri");
172
132
  localStorage.clear();
173
- if (redirectUri != null) {
174
- window.location.href = redirectUri;
175
- } else {
176
- window.location.href = "/";
177
- }
133
+ window.location.href = redirectUri || "/";
178
134
  _context.next = 28;
179
135
  break;
180
- case 26:
181
- _context.prev = 26;
182
- _context.t0 = _context["catch"](9);
136
+ case 25:
137
+ _context.prev = 25;
138
+ _context.t0 = _context["catch"](8);
139
+ console.error("PKCE sign-in failed", _context.t0);
183
140
  case 28:
184
141
  case "end":
185
142
  return _context.stop();
186
143
  }
187
- }, _callee, null, [[9, 26]]);
144
+ }, _callee, null, [[8, 25]]);
188
145
  }));
189
146
  return function signInValidator(_x) {
190
147
  return _ref2.apply(this, arguments);
191
148
  };
192
149
  }();
150
+
151
+ // ---------- GA + Clarity ----------
193
152
  function initGA(_x2) {
194
153
  return _initGA.apply(this, arguments);
195
154
  }
196
155
  function _initGA() {
197
- _initGA = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(G) {
198
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
199
- while (1) switch (_context3.prev = _context3.next) {
156
+ _initGA = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(G) {
157
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
158
+ while (1) switch (_context2.prev = _context2.next) {
200
159
  case 0:
201
- if (!(!_ga4React["default"].isInitialized() && G && process.browser)) {
202
- _context3.next = 10;
160
+ if (!(!_ga4React["default"].isInitialized() && G && typeof window !== "undefined")) {
161
+ _context2.next = 10;
203
162
  break;
204
163
  }
205
164
  ga4React.current = new _ga4React["default"](G, {
206
165
  debug_mode: !process.env.production
207
166
  });
208
- _context3.prev = 2;
209
- _context3.next = 5;
167
+ _context2.prev = 2;
168
+ _context2.next = 5;
210
169
  return ga4React.current.initialize();
211
170
  case 5:
212
- _context3.next = 10;
171
+ _context2.next = 10;
213
172
  break;
214
173
  case 7:
215
- _context3.prev = 7;
216
- _context3.t0 = _context3["catch"](2);
217
- console.error(_context3.t0);
174
+ _context2.prev = 7;
175
+ _context2.t0 = _context2["catch"](2);
176
+ console.error(_context2.t0);
218
177
  case 10:
219
178
  case "end":
220
- return _context3.stop();
179
+ return _context2.stop();
221
180
  }
222
- }, _callee3, null, [[2, 7]]);
181
+ }, _callee2, null, [[2, 7]]);
223
182
  }));
224
183
  return _initGA.apply(this, arguments);
225
184
  }
226
185
  var logEvent = function logEvent(category, action, label) {
227
- if (ga4React != null && ga4React.current != null && ga4React != "") {
186
+ if (ga4React.current) {
228
187
  ga4React.current.event(action, label, category);
229
188
  }
230
- if (process.env.enableDatabaseAnalytics == "true") {
231
- var userId = null;
232
- var locationId = null;
233
- var companyId = null;
234
- var host = window.location.protocol + "//" + window.location.host;
235
- if (signedInUser.current != null) {
236
- userId = signedInUser.current.id;
237
- locationId = signedInUser.current.locationId;
238
- companyId = signedInUser.current.companyId;
239
- }
240
- apiService().post("/Analytics/Event", {
241
- userId: userId,
242
- locationId: locationId,
243
- companyId: companyId,
244
- uri: window.location.pathname,
245
- category: category,
246
- action: action,
247
- label: label,
248
- host: host
249
- });
250
- }
251
189
  };
252
190
  var databaseDrivenPageView = function databaseDrivenPageView(pathName) {
253
- if (process.env.enableDatabaseAnalytics == "true") {
254
- var userId = null;
255
- var locationId = null;
256
- var companyId = null;
257
- var host = window.location.protocol + "//" + window.location.host;
258
- if (signedInUser.current != null) {
259
- userId = signedInUser.current.id;
260
- locationId = signedInUser.current.locationId;
261
- companyId = signedInUser.current.companyId;
262
- }
263
- if (pathName == "/signin-oidc") {
264
- return;
265
- }
266
- apiService().post("/Analytics/PageView", {
267
- userId: userId,
268
- locationId: locationId,
269
- companyId: companyId,
270
- uri: pathName,
271
- host: host
272
- });
273
- }
191
+ var _signedInUser$current, _signedInUser$current2, _signedInUser$current3;
192
+ if (process.env.enableDatabaseAnalytics !== "true") return;
193
+ if (pathName === "/signin-oidc") return;
194
+ var host = window.location.protocol + "//" + window.location.host;
195
+ apiService().post("/Analytics/PageView", {
196
+ userId: (_signedInUser$current = signedInUser.current) === null || _signedInUser$current === void 0 ? void 0 : _signedInUser$current.id,
197
+ locationId: (_signedInUser$current2 = signedInUser.current) === null || _signedInUser$current2 === void 0 ? void 0 : _signedInUser$current2.locationId,
198
+ companyId: (_signedInUser$current3 = signedInUser.current) === null || _signedInUser$current3 === void 0 ? void 0 : _signedInUser$current3.companyId,
199
+ uri: pathName,
200
+ host: host
201
+ });
274
202
  };
203
+
204
+ // ---------- Auth + Tracking Init ----------
275
205
  (0, _react.useEffect)(function () {
276
- var enableAnalytics = false;
277
- var stored = localStorage.getItem("gdpr-consent");
278
- if (stored) {
279
- var prefs = JSON.parse(stored);
280
- if (prefs.analytics) {
281
- enableAnalytics = true;
282
- }
283
- }
284
- if (frontEndLoadedState && !enableConsentDialog || frontEndLoadedState && enableConsentDialog && enableAnalytics) {
285
- console.log("Analytics are working now!");
286
- if (pageProps.googleAnalytics4Code != null) {
287
- initGA(pageProps.googleAnalytics4Code);
288
- } else if (process.env.googleAnalytics4 != "") {
289
- initGA(process.env.googleAnalytics4);
290
- }
291
- if (pageProps.microsoftClarityCode != null) {
292
- _reactMicrosoftClarity.clarity.init(pageProps.microsoftClarityCode);
293
- if (signedInUser.current != null && _reactMicrosoftClarity.clarity.hasStarted()) {
294
- _reactMicrosoftClarity.clarity.identify('USER_ID', {
295
- userProperty: signedInUser.current.id.toString()
296
- });
297
- }
298
- } else if (process.env.microsoftClarityTrackingCode != "")
299
- // if there isn't a private label tracking code use the one built in the app
300
- {
301
- _reactMicrosoftClarity.clarity.init(process.env.microsoftClarityTrackingCode);
302
- if (signedInUser.current != null && _reactMicrosoftClarity.clarity.hasStarted()) {
303
- _reactMicrosoftClarity.clarity.identify('USER_ID', {
304
- userProperty: signedInUser.current.id.toString()
305
- });
306
- }
307
- }
308
- databaseDrivenPageView(window.location.pathname);
309
- _router["default"].events.on('routeChangeComplete', function () {
310
- if (ga4React != null && ga4React != "") {
311
- try {
312
- ga4React.current.pageview(window.location.pathname);
313
- } catch (exp) {}
314
- }
315
- databaseDrivenPageView(window.location.pathname);
316
- });
317
- if (pageProps.hubspotTrackingCode != null && pageProps.hubspotTrackingCode != "") {
318
- var script = document.createElement("script");
319
- script.src = pageProps.hubspotTrackingCode;
320
- script.async = true;
321
- script.defer = true;
322
- script.id = "hs-script-loader";
323
- document.body.appendChild(script);
206
+ if (queryCode) {
207
+ signInValidator(queryCode);
208
+ } else if (!loadingAuth.current) {
209
+ loadingAuth.current = true;
210
+ if (enableAuth) {
211
+ apiService().GetCurrentUser().then(function (usr) {
212
+ signedInUser.current = usr;
213
+ setSignedInUserState(usr);
214
+ setFrontEndLoadedState(true);
215
+ });
216
+ } else {
217
+ setFrontEndLoadedState(true);
324
218
  }
325
- } else {
326
- console.log("No Analytics for you!");
327
219
  }
328
- }, [frontEndLoadedState, concentState]);
329
- var validateUserSignedIn = /*#__PURE__*/function () {
330
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
331
- var usr;
332
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
333
- while (1) switch (_context2.prev = _context2.next) {
334
- case 0:
335
- loadingAuth.current = true;
336
- if (!enableAuth) {
337
- _context2.next = 6;
338
- break;
339
- }
340
- _context2.next = 4;
341
- return apiService().GetCurrentUser();
342
- case 4:
343
- usr = _context2.sent;
344
- if (usr != null) {
345
- signedInUser.current = usr;
346
- }
347
- case 6:
348
- setFrontEndLoadedState(true);
349
- frontEndLoaded.current = true;
350
- setSignedInUserState(signedInUser.current);
351
- case 9:
352
- case "end":
353
- return _context2.stop();
354
- }
355
- }, _callee2);
356
- }));
357
- return function validateUserSignedIn() {
358
- return _ref3.apply(this, arguments);
359
- };
360
- }();
361
- if (queryCode != null) {
362
- signInValidator(queryCode);
363
- } else {
364
- if (!loadingAuth.current) {
365
- validateUserSignedIn();
366
- }
367
- }
220
+ }, [queryCode, enableAuth]);
221
+
222
+ // ---------- Analytics Init ----------
368
223
  (0, _react.useEffect)(function () {
369
- if (signedInUserState == null && enforceLoggedIn && pathname != "/signin-oidc" && frontEndLoadedState == true) {
224
+ if (!frontEndLoadedState) return;
225
+ if (pageProps.googleAnalytics4Code) {
226
+ initGA(pageProps.googleAnalytics4Code);
227
+ } else if (process.env.googleAnalytics4) {
228
+ initGA(process.env.googleAnalytics4);
229
+ }
230
+ if (pageProps.microsoftClarityCode) {
231
+ _reactMicrosoftClarity.clarity.init(pageProps.microsoftClarityCode);
232
+ } else if (process.env.microsoftClarityTrackingCode) {
233
+ _reactMicrosoftClarity.clarity.init(process.env.microsoftClarityTrackingCode);
234
+ }
235
+ databaseDrivenPageView(window.location.pathname);
236
+ _router["default"].events.on('routeChangeComplete', function (url) {
237
+ var _ga4React$current;
238
+ (_ga4React$current = ga4React.current) === null || _ga4React$current === void 0 || _ga4React$current.pageview(url);
239
+ databaseDrivenPageView(url);
240
+ });
241
+ }, [frontEndLoadedState]);
242
+
243
+ // ---------- Enforce Login ----------
244
+ (0, _react.useEffect)(function () {
245
+ if (enforceLoggedIn && pathname !== "/signin-oidc" && frontEndLoadedState && !signedInUserState) {
370
246
  (0, _authscape.authService)().login();
371
247
  }
372
- }, [signedInUserState, enforceLoggedIn, frontEndLoadedState]);
373
- var setIsLoading = function setIsLoading(isLoading) {
374
- setIsLoadingShow(isLoading);
375
- };
376
- var logPurchase = function logPurchase(transactionId, amount, tax, items) {
377
- if (ga4React != null && ga4React != "") {
378
- ga4React.current.gtag("event", "purchase", {
379
- transaction_id: transactionId,
380
- value: amount,
381
- tax: tax,
382
- currency: "USD",
383
- items: items
384
- });
385
- }
386
- };
387
- var setToastMessage = function setToastMessage(message) {
388
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
389
- if (options != null) {
390
- (0, _reactToastify.toast)(message, options);
391
- } else {
392
- (0, _reactToastify.toast)(message);
393
- }
394
- };
395
- var setInfoToastMessage = function setInfoToastMessage(message) {
396
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
397
- if (options != null) {
398
- _reactToastify.toast.info(message, options);
399
- } else {
400
- _reactToastify.toast.info(message);
401
- }
402
- };
403
- var setSuccessToastMessage = function setSuccessToastMessage(message) {
404
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
405
- if (options != null) {
406
- _reactToastify.toast.success(message, options);
407
- } else {
408
- _reactToastify.toast.success(message);
409
- }
410
- };
411
- var setWarnToastMessage = function setWarnToastMessage(message) {
412
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
413
- if (options != null) {
414
- _reactToastify.toast.warn(message, options);
415
- } else {
416
- _reactToastify.toast.warn(message);
417
- }
418
- };
419
- var setErrorToastMessage = function setErrorToastMessage(message) {
420
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
421
- if (options != null) {
422
- _reactToastify.toast.error(message, options);
423
- } else {
424
- _reactToastify.toast.error(message);
425
- }
426
- };
248
+ }, [signedInUserState, enforceLoggedIn, frontEndLoadedState, pathname]);
427
249
  var GetSignedInUser = function GetSignedInUser() {
428
- if (signedInUser != null) {
429
- var _signedInUser = signedInUser.current;
430
- if (_signedInUser != null) {
431
- _signedInUser.hasRole = function (name) {
432
- if (_signedInUser.roles != null) {
433
- if (_signedInUser.roles.find(function (r) {
434
- return r.name === name;
435
- }) != null) {
436
- return true;
437
- } else {
438
- return false;
439
- }
440
- }
441
- };
442
- _signedInUser.hasRoleId = function (id) {
443
- if (_signedInUser.roles != null) {
444
- if (_signedInUser.roles.find(function (r) {
445
- return r.id === id;
446
- }) != null) {
447
- return true;
448
- } else {
449
- return false;
450
- }
451
- }
452
- };
453
- _signedInUser.hasPermission = function (name) {
454
- if (_signedInUser.permissions != null) {
455
- if (_signedInUser.permissions.find(function (r) {
456
- return r === name;
457
- }) != null) {
458
- return true;
459
- } else {
460
- return false;
461
- }
462
- }
463
- };
464
- }
465
- return _signedInUser;
466
- } else {
467
- return null;
468
- }
250
+ return signedInUser.current;
469
251
  };
470
252
  var useStore = (0, _zustand.create)(function (set) {
471
253
  return store;
472
254
  });
473
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_head["default"], null, /*#__PURE__*/_react["default"].createElement("meta", {
474
- name: "viewport",
475
- content: "width=device-width, initial-scale=0.86, maximum-scale=5.0, minimum-scale=0.86"
476
- })), enableConsentDialog && /*#__PURE__*/_react["default"].createElement(GDPRConsentDialog, {
477
- onAccept: handleConsentAccepted,
478
- onReject: handleConsentRejected,
479
- enableAnalytics: true,
480
- enableMarketing: false
481
- // additionalPrivacyFeatures={[
482
- // {id: "danceParty", title: "Dance Party", description: "Hello world this is about the feature", checked: true },
483
- // {id: "frog", title: "Able to see Frogs", description: "Frogs will appear on your screen", checked: true }
484
- // ]}
485
- }), /*#__PURE__*/_react["default"].createElement(_styles.ThemeProvider, {
486
- theme: muiTheme
487
- }, frontEndLoadedState != null && frontEndLoadedState && pathname != "/signin-oidc" && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, layout != null && layout({
255
+
256
+ // ---------- Render ----------
257
+ var pageContent = layout ? layout({
488
258
  children: /*#__PURE__*/_react["default"].createElement(Component, _extends({}, pageProps, {
489
259
  currentUser: GetSignedInUser(),
490
260
  loadedUser: frontEndLoadedState,
491
- setIsLoading: setIsLoading,
261
+ setIsLoading: setIsLoadingShow,
492
262
  logEvent: logEvent,
493
- logPurchase: logPurchase,
494
263
  store: useStore,
495
- setToastMessage: setToastMessage,
496
- setInfoToastMessage: setInfoToastMessage,
497
- setSuccessToastMessage: setSuccessToastMessage,
498
- setWarnToastMessage: setWarnToastMessage,
499
- setErrorToastMessage: setErrorToastMessage
264
+ toast: _reactToastify.toast
500
265
  })),
501
266
  currentUser: GetSignedInUser(),
267
+ setIsLoading: setIsLoadingShow,
502
268
  logEvent: logEvent,
503
- setIsLoading: setIsLoading,
504
269
  toast: _reactToastify.toast,
505
270
  store: useStore,
506
- setToastMessage: setToastMessage,
507
- pageProps: pageProps,
508
- setInfoToastMessage: setInfoToastMessage,
509
- setSuccessToastMessage: setSuccessToastMessage,
510
- setWarnToastMessage: setWarnToastMessage,
511
- setErrorToastMessage: setErrorToastMessage
512
- }), layout == null && /*#__PURE__*/_react["default"].createElement(Component, _extends({}, pageProps, {
271
+ pageProps: pageProps
272
+ }) : /*#__PURE__*/_react["default"].createElement(Component, _extends({}, pageProps, {
513
273
  currentUser: GetSignedInUser(),
514
274
  loadedUser: frontEndLoadedState,
515
- setIsLoading: setIsLoading,
275
+ setIsLoading: setIsLoadingShow,
516
276
  logEvent: logEvent,
517
- logPurchase: logPurchase,
518
277
  store: useStore,
519
- setToastMessage: setToastMessage,
520
- setInfoToastMessage: setInfoToastMessage,
521
- setSuccessToastMessage: setSuccessToastMessage,
522
- setWarnToastMessage: setWarnToastMessage,
523
- setErrorToastMessage: setErrorToastMessage
524
- }))), /*#__PURE__*/_react["default"].createElement(_reactToastify.ToastContainer, null)), loadingLayout && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, loadingLayout(isLoadingShow)));
278
+ toast: _reactToastify.toast
279
+ }));
280
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_head["default"], null, /*#__PURE__*/_react["default"].createElement("meta", {
281
+ name: "viewport",
282
+ content: "width=device-width, initial-scale=0.86, maximum-scale=5.0, minimum-scale=0.86"
283
+ })), /*#__PURE__*/_react["default"].createElement(_styles.ThemeProvider, {
284
+ theme: muiTheme
285
+ }, pageContent, /*#__PURE__*/_react["default"].createElement(_reactToastify.ToastContainer, null)), loadingLayout && loadingLayout(isLoadingShow));
525
286
  }
526
287
  "use strict";
527
288
 
@@ -2366,214 +2127,6 @@ var FileUploader = exports.FileUploader = function FileUploader(_ref) {
2366
2127
  };
2367
2128
  "use strict";
2368
2129
 
2369
- Object.defineProperty(exports, "__esModule", {
2370
- value: true
2371
- });
2372
- exports.GDPRConsentDialog = void 0;
2373
- var _react = _interopRequireWildcard(require("react"));
2374
- var _material = require("@mui/material");
2375
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
2376
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
2377
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2378
- function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2379
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
2380
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
2381
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
2382
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
2383
- function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
2384
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2385
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2386
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2387
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
2388
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
2389
- var GDPRConsentDialog = exports.GDPRConsentDialog = function GDPRConsentDialog(_ref) {
2390
- var onAccept = _ref.onAccept,
2391
- onReject = _ref.onReject,
2392
- _ref$enableAnalytics = _ref.enableAnalytics,
2393
- enableAnalytics = _ref$enableAnalytics === void 0 ? true : _ref$enableAnalytics,
2394
- _ref$enableMarketing = _ref.enableMarketing,
2395
- enableMarketing = _ref$enableMarketing === void 0 ? true : _ref$enableMarketing,
2396
- _ref$additionalPrivac = _ref.additionalPrivacyFeatures,
2397
- additionalPrivacyFeatures = _ref$additionalPrivac === void 0 ? [] : _ref$additionalPrivac;
2398
- var initialPreferences = _objectSpread({
2399
- necessary: true,
2400
- analytics: enableAnalytics,
2401
- marketing: enableMarketing
2402
- }, Object.fromEntries(additionalPrivacyFeatures.map(function (item) {
2403
- var _item$checked;
2404
- return [item.id, (_item$checked = item.checked) !== null && _item$checked !== void 0 ? _item$checked : false];
2405
- })));
2406
- var _useState = (0, _react.useState)(false),
2407
- _useState2 = _slicedToArray(_useState, 2),
2408
- open = _useState2[0],
2409
- setOpen = _useState2[1];
2410
- var _useState3 = (0, _react.useState)(false),
2411
- _useState4 = _slicedToArray(_useState3, 2),
2412
- customize = _useState4[0],
2413
- setCustomize = _useState4[1];
2414
- var _useState5 = (0, _react.useState)(initialPreferences),
2415
- _useState6 = _slicedToArray(_useState5, 2),
2416
- preferences = _useState6[0],
2417
- setPreferences = _useState6[1];
2418
- (0, _react.useEffect)(function () {
2419
- var savedConsent = localStorage.getItem("gdpr-consent");
2420
- if (!savedConsent) {
2421
- setOpen(true);
2422
- }
2423
- }, []);
2424
- var saveConsentAndClose = function saveConsentAndClose(prefs) {
2425
- localStorage.setItem("gdpr-consent", JSON.stringify(prefs));
2426
- if (onAccept) onAccept(prefs);
2427
- setOpen(false);
2428
- };
2429
- var handleAcceptAll = function handleAcceptAll() {
2430
- var allPrefs = _objectSpread({
2431
- necessary: true,
2432
- analytics: enableAnalytics,
2433
- marketing: enableMarketing
2434
- }, Object.fromEntries(additionalPrivacyFeatures.map(function (item) {
2435
- return [item.id, true];
2436
- })));
2437
- saveConsentAndClose(allPrefs);
2438
- };
2439
- var handleRejectAll = function handleRejectAll() {
2440
- var rejectedPrefs = _objectSpread({
2441
- necessary: true,
2442
- analytics: false,
2443
- marketing: false
2444
- }, Object.fromEntries(additionalPrivacyFeatures.map(function (item) {
2445
- return [item.id, false];
2446
- })));
2447
- localStorage.setItem("gdpr-consent", JSON.stringify(rejectedPrefs));
2448
- if (onReject) onReject();
2449
- setOpen(false);
2450
- };
2451
- var handleAcceptSelected = function handleAcceptSelected() {
2452
- saveConsentAndClose(preferences);
2453
- };
2454
- var handleCheckboxChange = function handleCheckboxChange(key) {
2455
- return function (event) {
2456
- setPreferences(function (prev) {
2457
- return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, key, event.target.checked));
2458
- });
2459
- };
2460
- };
2461
- if (!open) return null;
2462
- return /*#__PURE__*/_react["default"].createElement(_material.Paper, {
2463
- elevation: 4,
2464
- sx: {
2465
- position: "fixed",
2466
- bottom: 0,
2467
- left: 0,
2468
- right: 0,
2469
- p: 2,
2470
- zIndex: 1300,
2471
- backgroundColor: "#fff",
2472
- borderTop: "1px solid #ccc"
2473
- }
2474
- }, /*#__PURE__*/_react["default"].createElement(_material.Box, {
2475
- display: "flex",
2476
- flexDirection: "column",
2477
- alignItems: "flex-start",
2478
- gap: 2
2479
- }, /*#__PURE__*/_react["default"].createElement(_material.Box, null, /*#__PURE__*/_react["default"].createElement(_material.Typography, {
2480
- variant: "subtitle1",
2481
- fontWeight: "bold"
2482
- }, "We value your privacy"), /*#__PURE__*/_react["default"].createElement(_material.Typography, {
2483
- variant: "body2"
2484
- }, "We use cookies to enhance your experience, for analytics and marketing. You can accept all, reject all, or customize your preferences.")), /*#__PURE__*/_react["default"].createElement(_material.Collapse, {
2485
- "in": customize
2486
- }, /*#__PURE__*/_react["default"].createElement(_material.Box, {
2487
- mb: 2
2488
- }, /*#__PURE__*/_react["default"].createElement(_material.Box, {
2489
- mb: 1
2490
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
2491
- control: /*#__PURE__*/_react["default"].createElement(_material.Checkbox, {
2492
- checked: true,
2493
- disabled: true
2494
- }),
2495
- label: "Necessary (always required)"
2496
- }), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_material.Typography, {
2497
- variant: "caption",
2498
- color: "textSecondary",
2499
- sx: {
2500
- ml: 4
2501
- }
2502
- }, "Required to enable core site functionality such as security, authentication, and accessibility.")), enableAnalytics && /*#__PURE__*/_react["default"].createElement(_material.Box, {
2503
- mb: 1
2504
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
2505
- control: /*#__PURE__*/_react["default"].createElement(_material.Checkbox, {
2506
- checked: preferences.analytics,
2507
- onChange: handleCheckboxChange("analytics")
2508
- }),
2509
- label: "Analytics"
2510
- }), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_material.Typography, {
2511
- variant: "caption",
2512
- color: "textSecondary",
2513
- sx: {
2514
- ml: 4
2515
- }
2516
- }, "Helps us understand how you use our site so we can improve it. For example, tracking page visits or feature usage.")), enableMarketing && /*#__PURE__*/_react["default"].createElement(_material.Box, {
2517
- mb: 1
2518
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
2519
- control: /*#__PURE__*/_react["default"].createElement(_material.Checkbox, {
2520
- checked: preferences.marketing,
2521
- onChange: handleCheckboxChange("marketing")
2522
- }),
2523
- label: "Marketing"
2524
- }), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_material.Typography, {
2525
- variant: "caption",
2526
- color: "textSecondary",
2527
- sx: {
2528
- ml: 4
2529
- }
2530
- }, "Allows us to show personalized ads and promotions based on your behavior and interactions.")), additionalPrivacyFeatures.map(function (feature) {
2531
- return /*#__PURE__*/_react["default"].createElement(_material.Box, {
2532
- key: feature.id,
2533
- mb: 1
2534
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
2535
- control: /*#__PURE__*/_react["default"].createElement(_material.Checkbox, {
2536
- checked: preferences[feature.id] || false,
2537
- onChange: handleCheckboxChange(feature.id)
2538
- }),
2539
- label: feature.title
2540
- }), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_material.Typography, {
2541
- variant: "caption",
2542
- color: "textSecondary",
2543
- sx: {
2544
- ml: 4
2545
- }
2546
- }, feature.description));
2547
- }))), /*#__PURE__*/_react["default"].createElement(_material.Box, {
2548
- display: "flex",
2549
- gap: 1,
2550
- flexWrap: "wrap"
2551
- }, !customize ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_material.Button, {
2552
- variant: "contained",
2553
- color: "primary",
2554
- onClick: handleAcceptAll
2555
- }, "Accept All"), /*#__PURE__*/_react["default"].createElement(_material.Button, {
2556
- variant: "outlined",
2557
- color: "error",
2558
- onClick: handleRejectAll
2559
- }, "Reject All"), /*#__PURE__*/_react["default"].createElement(_material.Button, {
2560
- variant: "text",
2561
- onClick: function onClick() {
2562
- return setCustomize(true);
2563
- }
2564
- }, "Customize Preferences")) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_material.Button, {
2565
- variant: "contained",
2566
- color: "primary",
2567
- onClick: handleAcceptSelected
2568
- }, "Save Preferences"), /*#__PURE__*/_react["default"].createElement(_material.Button, {
2569
- variant: "text",
2570
- onClick: function onClick() {
2571
- return setCustomize(false);
2572
- }
2573
- }, "Cancel")))));
2574
- };
2575
- "use strict";
2576
-
2577
2130
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2578
2131
  Object.defineProperty(exports, "__esModule", {
2579
2132
  value: true