authscape 1.0.706 → 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,414 +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
- if (pageProps.googleAnalytics4Code != null) {
286
- initGA(pageProps.googleAnalytics4Code);
287
- } else if (process.env.googleAnalytics4 != "") {
288
- initGA(process.env.googleAnalytics4);
289
- }
290
- if (pageProps.microsoftClarityCode != null) {
291
- _reactMicrosoftClarity.clarity.init(pageProps.microsoftClarityCode);
292
- if (signedInUser.current != null && _reactMicrosoftClarity.clarity.hasStarted()) {
293
- _reactMicrosoftClarity.clarity.identify('USER_ID', {
294
- userProperty: signedInUser.current.id.toString()
295
- });
296
- }
297
- } else if (process.env.microsoftClarityTrackingCode != "")
298
- // if there isn't a private label tracking code use the one built in the app
299
- {
300
- _reactMicrosoftClarity.clarity.init(process.env.microsoftClarityTrackingCode);
301
- if (signedInUser.current != null && _reactMicrosoftClarity.clarity.hasStarted()) {
302
- _reactMicrosoftClarity.clarity.identify('USER_ID', {
303
- userProperty: signedInUser.current.id.toString()
304
- });
305
- }
306
- }
307
- databaseDrivenPageView(window.location.pathname);
308
- _router["default"].events.on('routeChangeComplete', function () {
309
- if (ga4React != null && ga4React != "") {
310
- try {
311
- ga4React.current.pageview(window.location.pathname);
312
- } catch (exp) {}
313
- }
314
- databaseDrivenPageView(window.location.pathname);
315
- });
316
- if (pageProps.hubspotTrackingCode != null && pageProps.hubspotTrackingCode != "") {
317
- var script = document.createElement("script");
318
- script.src = pageProps.hubspotTrackingCode;
319
- script.async = true;
320
- script.defer = true;
321
- script.id = "hs-script-loader";
322
- 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);
323
218
  }
324
219
  }
325
- }, [frontEndLoadedState, concentState]);
326
- var validateUserSignedIn = /*#__PURE__*/function () {
327
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
328
- var usr;
329
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
330
- while (1) switch (_context2.prev = _context2.next) {
331
- case 0:
332
- loadingAuth.current = true;
333
- if (!enableAuth) {
334
- _context2.next = 6;
335
- break;
336
- }
337
- _context2.next = 4;
338
- return apiService().GetCurrentUser();
339
- case 4:
340
- usr = _context2.sent;
341
- if (usr != null) {
342
- signedInUser.current = usr;
343
- }
344
- case 6:
345
- setFrontEndLoadedState(true);
346
- frontEndLoaded.current = true;
347
- setSignedInUserState(signedInUser.current);
348
- case 9:
349
- case "end":
350
- return _context2.stop();
351
- }
352
- }, _callee2);
353
- }));
354
- return function validateUserSignedIn() {
355
- return _ref3.apply(this, arguments);
356
- };
357
- }();
358
- if (queryCode != null) {
359
- signInValidator(queryCode);
360
- } else {
361
- if (!loadingAuth.current) {
362
- validateUserSignedIn();
363
- }
364
- }
220
+ }, [queryCode, enableAuth]);
221
+
222
+ // ---------- Analytics Init ----------
365
223
  (0, _react.useEffect)(function () {
366
- 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) {
367
246
  (0, _authscape.authService)().login();
368
247
  }
369
- }, [signedInUserState, enforceLoggedIn, frontEndLoadedState]);
370
- var setIsLoading = function setIsLoading(isLoading) {
371
- setIsLoadingShow(isLoading);
372
- };
373
- var logPurchase = function logPurchase(transactionId, amount, tax, items) {
374
- if (ga4React != null && ga4React != "") {
375
- ga4React.current.gtag("event", "purchase", {
376
- transaction_id: transactionId,
377
- value: amount,
378
- tax: tax,
379
- currency: "USD",
380
- items: items
381
- });
382
- }
383
- };
384
- var setToastMessage = function setToastMessage(message) {
385
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
386
- if (options != null) {
387
- (0, _reactToastify.toast)(message, options);
388
- } else {
389
- (0, _reactToastify.toast)(message);
390
- }
391
- };
392
- var setInfoToastMessage = function setInfoToastMessage(message) {
393
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
394
- if (options != null) {
395
- _reactToastify.toast.info(message, options);
396
- } else {
397
- _reactToastify.toast.info(message);
398
- }
399
- };
400
- var setSuccessToastMessage = function setSuccessToastMessage(message) {
401
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
402
- if (options != null) {
403
- _reactToastify.toast.success(message, options);
404
- } else {
405
- _reactToastify.toast.success(message);
406
- }
407
- };
408
- var setWarnToastMessage = function setWarnToastMessage(message) {
409
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
410
- if (options != null) {
411
- _reactToastify.toast.warn(message, options);
412
- } else {
413
- _reactToastify.toast.warn(message);
414
- }
415
- };
416
- var setErrorToastMessage = function setErrorToastMessage(message) {
417
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
418
- if (options != null) {
419
- _reactToastify.toast.error(message, options);
420
- } else {
421
- _reactToastify.toast.error(message);
422
- }
423
- };
248
+ }, [signedInUserState, enforceLoggedIn, frontEndLoadedState, pathname]);
424
249
  var GetSignedInUser = function GetSignedInUser() {
425
- if (signedInUser != null) {
426
- var _signedInUser = signedInUser.current;
427
- if (_signedInUser != null) {
428
- _signedInUser.hasRole = function (name) {
429
- if (_signedInUser.roles != null) {
430
- if (_signedInUser.roles.find(function (r) {
431
- return r.name === name;
432
- }) != null) {
433
- return true;
434
- } else {
435
- return false;
436
- }
437
- }
438
- };
439
- _signedInUser.hasRoleId = function (id) {
440
- if (_signedInUser.roles != null) {
441
- if (_signedInUser.roles.find(function (r) {
442
- return r.id === id;
443
- }) != null) {
444
- return true;
445
- } else {
446
- return false;
447
- }
448
- }
449
- };
450
- _signedInUser.hasPermission = function (name) {
451
- if (_signedInUser.permissions != null) {
452
- if (_signedInUser.permissions.find(function (r) {
453
- return r === name;
454
- }) != null) {
455
- return true;
456
- } else {
457
- return false;
458
- }
459
- }
460
- };
461
- }
462
- return _signedInUser;
463
- } else {
464
- return null;
465
- }
250
+ return signedInUser.current;
466
251
  };
467
252
  var useStore = (0, _zustand.create)(function (set) {
468
253
  return store;
469
254
  });
470
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_head["default"], null, /*#__PURE__*/_react["default"].createElement("meta", {
471
- name: "viewport",
472
- content: "width=device-width, initial-scale=0.86, maximum-scale=5.0, minimum-scale=0.86"
473
- })), enableConsentDialog && /*#__PURE__*/_react["default"].createElement(GDPRConsentDialog, {
474
- onAccept: handleConsentAccepted,
475
- onReject: handleConsentRejected,
476
- enableAnalytics: true,
477
- enableMarketing: false
478
- // additionalPrivacyFeatures={[
479
- // {id: "danceParty", title: "Dance Party", description: "Hello world this is about the feature", checked: true },
480
- // {id: "frog", title: "Able to see Frogs", description: "Frogs will appear on your screen", checked: true }
481
- // ]}
482
- }), /*#__PURE__*/_react["default"].createElement(_styles.ThemeProvider, {
483
- theme: muiTheme
484
- }, 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({
485
258
  children: /*#__PURE__*/_react["default"].createElement(Component, _extends({}, pageProps, {
486
259
  currentUser: GetSignedInUser(),
487
260
  loadedUser: frontEndLoadedState,
488
- setIsLoading: setIsLoading,
261
+ setIsLoading: setIsLoadingShow,
489
262
  logEvent: logEvent,
490
- logPurchase: logPurchase,
491
263
  store: useStore,
492
- setToastMessage: setToastMessage,
493
- setInfoToastMessage: setInfoToastMessage,
494
- setSuccessToastMessage: setSuccessToastMessage,
495
- setWarnToastMessage: setWarnToastMessage,
496
- setErrorToastMessage: setErrorToastMessage
264
+ toast: _reactToastify.toast
497
265
  })),
498
266
  currentUser: GetSignedInUser(),
267
+ setIsLoading: setIsLoadingShow,
499
268
  logEvent: logEvent,
500
- setIsLoading: setIsLoading,
501
269
  toast: _reactToastify.toast,
502
270
  store: useStore,
503
- setToastMessage: setToastMessage,
504
- pageProps: pageProps,
505
- setInfoToastMessage: setInfoToastMessage,
506
- setSuccessToastMessage: setSuccessToastMessage,
507
- setWarnToastMessage: setWarnToastMessage,
508
- setErrorToastMessage: setErrorToastMessage
509
- }), layout == null && /*#__PURE__*/_react["default"].createElement(Component, _extends({}, pageProps, {
271
+ pageProps: pageProps
272
+ }) : /*#__PURE__*/_react["default"].createElement(Component, _extends({}, pageProps, {
510
273
  currentUser: GetSignedInUser(),
511
274
  loadedUser: frontEndLoadedState,
512
- setIsLoading: setIsLoading,
275
+ setIsLoading: setIsLoadingShow,
513
276
  logEvent: logEvent,
514
- logPurchase: logPurchase,
515
277
  store: useStore,
516
- setToastMessage: setToastMessage,
517
- setInfoToastMessage: setInfoToastMessage,
518
- setSuccessToastMessage: setSuccessToastMessage,
519
- setWarnToastMessage: setWarnToastMessage,
520
- setErrorToastMessage: setErrorToastMessage
521
- }))), /*#__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));
522
286
  }
523
287
  "use strict";
524
288
 
@@ -2363,214 +2127,6 @@ var FileUploader = exports.FileUploader = function FileUploader(_ref) {
2363
2127
  };
2364
2128
  "use strict";
2365
2129
 
2366
- Object.defineProperty(exports, "__esModule", {
2367
- value: true
2368
- });
2369
- exports.GDPRConsentDialog = void 0;
2370
- var _react = _interopRequireWildcard(require("react"));
2371
- var _material = require("@mui/material");
2372
- 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); }
2373
- 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; }
2374
- 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); }
2375
- function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2376
- 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."); }
2377
- 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; } }
2378
- 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; }
2379
- 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; } }
2380
- function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
2381
- 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; }
2382
- 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; }
2383
- 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; }
2384
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
2385
- 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); }
2386
- var GDPRConsentDialog = exports.GDPRConsentDialog = function GDPRConsentDialog(_ref) {
2387
- var onAccept = _ref.onAccept,
2388
- onReject = _ref.onReject,
2389
- _ref$enableAnalytics = _ref.enableAnalytics,
2390
- enableAnalytics = _ref$enableAnalytics === void 0 ? true : _ref$enableAnalytics,
2391
- _ref$enableMarketing = _ref.enableMarketing,
2392
- enableMarketing = _ref$enableMarketing === void 0 ? true : _ref$enableMarketing,
2393
- _ref$additionalPrivac = _ref.additionalPrivacyFeatures,
2394
- additionalPrivacyFeatures = _ref$additionalPrivac === void 0 ? [] : _ref$additionalPrivac;
2395
- var initialPreferences = _objectSpread({
2396
- necessary: true,
2397
- analytics: enableAnalytics,
2398
- marketing: enableMarketing
2399
- }, Object.fromEntries(additionalPrivacyFeatures.map(function (item) {
2400
- var _item$checked;
2401
- return [item.id, (_item$checked = item.checked) !== null && _item$checked !== void 0 ? _item$checked : false];
2402
- })));
2403
- var _useState = (0, _react.useState)(false),
2404
- _useState2 = _slicedToArray(_useState, 2),
2405
- open = _useState2[0],
2406
- setOpen = _useState2[1];
2407
- var _useState3 = (0, _react.useState)(false),
2408
- _useState4 = _slicedToArray(_useState3, 2),
2409
- customize = _useState4[0],
2410
- setCustomize = _useState4[1];
2411
- var _useState5 = (0, _react.useState)(initialPreferences),
2412
- _useState6 = _slicedToArray(_useState5, 2),
2413
- preferences = _useState6[0],
2414
- setPreferences = _useState6[1];
2415
- (0, _react.useEffect)(function () {
2416
- var savedConsent = localStorage.getItem("gdpr-consent");
2417
- if (!savedConsent) {
2418
- setOpen(true);
2419
- }
2420
- }, []);
2421
- var saveConsentAndClose = function saveConsentAndClose(prefs) {
2422
- localStorage.setItem("gdpr-consent", JSON.stringify(prefs));
2423
- if (onAccept) onAccept(prefs);
2424
- setOpen(false);
2425
- };
2426
- var handleAcceptAll = function handleAcceptAll() {
2427
- var allPrefs = _objectSpread({
2428
- necessary: true,
2429
- analytics: enableAnalytics,
2430
- marketing: enableMarketing
2431
- }, Object.fromEntries(additionalPrivacyFeatures.map(function (item) {
2432
- return [item.id, true];
2433
- })));
2434
- saveConsentAndClose(allPrefs);
2435
- };
2436
- var handleRejectAll = function handleRejectAll() {
2437
- var rejectedPrefs = _objectSpread({
2438
- necessary: true,
2439
- analytics: false,
2440
- marketing: false
2441
- }, Object.fromEntries(additionalPrivacyFeatures.map(function (item) {
2442
- return [item.id, false];
2443
- })));
2444
- localStorage.setItem("gdpr-consent", JSON.stringify(rejectedPrefs));
2445
- if (onReject) onReject();
2446
- setOpen(false);
2447
- };
2448
- var handleAcceptSelected = function handleAcceptSelected() {
2449
- saveConsentAndClose(preferences);
2450
- };
2451
- var handleCheckboxChange = function handleCheckboxChange(key) {
2452
- return function (event) {
2453
- setPreferences(function (prev) {
2454
- return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, key, event.target.checked));
2455
- });
2456
- };
2457
- };
2458
- if (!open) return null;
2459
- return /*#__PURE__*/_react["default"].createElement(_material.Paper, {
2460
- elevation: 4,
2461
- sx: {
2462
- position: "fixed",
2463
- bottom: 0,
2464
- left: 0,
2465
- right: 0,
2466
- p: 2,
2467
- zIndex: 1300,
2468
- backgroundColor: "#fff",
2469
- borderTop: "1px solid #ccc"
2470
- }
2471
- }, /*#__PURE__*/_react["default"].createElement(_material.Box, {
2472
- display: "flex",
2473
- flexDirection: "column",
2474
- alignItems: "flex-start",
2475
- gap: 2
2476
- }, /*#__PURE__*/_react["default"].createElement(_material.Box, null, /*#__PURE__*/_react["default"].createElement(_material.Typography, {
2477
- variant: "subtitle1",
2478
- fontWeight: "bold"
2479
- }, "We value your privacy"), /*#__PURE__*/_react["default"].createElement(_material.Typography, {
2480
- variant: "body2"
2481
- }, "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, {
2482
- "in": customize
2483
- }, /*#__PURE__*/_react["default"].createElement(_material.Box, {
2484
- mb: 2
2485
- }, /*#__PURE__*/_react["default"].createElement(_material.Box, {
2486
- mb: 1
2487
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
2488
- control: /*#__PURE__*/_react["default"].createElement(_material.Checkbox, {
2489
- checked: true,
2490
- disabled: true
2491
- }),
2492
- label: "Necessary (always required)"
2493
- }), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_material.Typography, {
2494
- variant: "caption",
2495
- color: "textSecondary",
2496
- sx: {
2497
- ml: 4
2498
- }
2499
- }, "Required to enable core site functionality such as security, authentication, and accessibility.")), enableAnalytics && /*#__PURE__*/_react["default"].createElement(_material.Box, {
2500
- mb: 1
2501
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
2502
- control: /*#__PURE__*/_react["default"].createElement(_material.Checkbox, {
2503
- checked: preferences.analytics,
2504
- onChange: handleCheckboxChange("analytics")
2505
- }),
2506
- label: "Analytics"
2507
- }), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_material.Typography, {
2508
- variant: "caption",
2509
- color: "textSecondary",
2510
- sx: {
2511
- ml: 4
2512
- }
2513
- }, "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, {
2514
- mb: 1
2515
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
2516
- control: /*#__PURE__*/_react["default"].createElement(_material.Checkbox, {
2517
- checked: preferences.marketing,
2518
- onChange: handleCheckboxChange("marketing")
2519
- }),
2520
- label: "Marketing"
2521
- }), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_material.Typography, {
2522
- variant: "caption",
2523
- color: "textSecondary",
2524
- sx: {
2525
- ml: 4
2526
- }
2527
- }, "Allows us to show personalized ads and promotions based on your behavior and interactions.")), additionalPrivacyFeatures.map(function (feature) {
2528
- return /*#__PURE__*/_react["default"].createElement(_material.Box, {
2529
- key: feature.id,
2530
- mb: 1
2531
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
2532
- control: /*#__PURE__*/_react["default"].createElement(_material.Checkbox, {
2533
- checked: preferences[feature.id] || false,
2534
- onChange: handleCheckboxChange(feature.id)
2535
- }),
2536
- label: feature.title
2537
- }), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_material.Typography, {
2538
- variant: "caption",
2539
- color: "textSecondary",
2540
- sx: {
2541
- ml: 4
2542
- }
2543
- }, feature.description));
2544
- }))), /*#__PURE__*/_react["default"].createElement(_material.Box, {
2545
- display: "flex",
2546
- gap: 1,
2547
- flexWrap: "wrap"
2548
- }, !customize ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_material.Button, {
2549
- variant: "contained",
2550
- color: "primary",
2551
- onClick: handleAcceptAll
2552
- }, "Accept All"), /*#__PURE__*/_react["default"].createElement(_material.Button, {
2553
- variant: "outlined",
2554
- color: "error",
2555
- onClick: handleRejectAll
2556
- }, "Reject All"), /*#__PURE__*/_react["default"].createElement(_material.Button, {
2557
- variant: "text",
2558
- onClick: function onClick() {
2559
- return setCustomize(true);
2560
- }
2561
- }, "Customize Preferences")) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_material.Button, {
2562
- variant: "contained",
2563
- color: "primary",
2564
- onClick: handleAcceptSelected
2565
- }, "Save Preferences"), /*#__PURE__*/_react["default"].createElement(_material.Button, {
2566
- variant: "text",
2567
- onClick: function onClick() {
2568
- return setCustomize(false);
2569
- }
2570
- }, "Cancel")))));
2571
- };
2572
- "use strict";
2573
-
2574
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); }
2575
2131
  Object.defineProperty(exports, "__esModule", {
2576
2132
  value: true