@copart/ops-tool-kit 1.13.0-beta.3 → 1.13.0-beta.4

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.
@@ -47,7 +47,7 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
47
47
  var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
48
48
 
49
49
  const name$1 = "@copart/ops-tool-kit";
50
- const version$3 = "1.13.0-beta.3";
50
+ const version$3 = "1.13.0-beta.4";
51
51
  const main$1 = "dist/ops-tool-kit.js";
52
52
  const style = "dist/ops-tool-kit.css";
53
53
  const files = [
@@ -68250,6 +68250,324 @@ function getInitialUri() {
68250
68250
  });
68251
68251
  }
68252
68252
 
68253
+ function getAppName() {
68254
+ var _window$toolkitEnv;
68255
+ return (_window$toolkitEnv = window.toolkitEnv) !== null && _window$toolkitEnv !== void 0 && _window$toolkitEnv.APP_NAME ? window.toolkitEnv.APP_NAME : typeof process !== 'undefined' && process.env && process.env.APP_NAME || 'test-app';
68256
+ }
68257
+ function getByPath(obj, path) {
68258
+ if (obj == null) return undefined;
68259
+ var parts = path.split('.');
68260
+ var value = obj;
68261
+ for (var i = 0; i < parts.length && value != null; i++) {
68262
+ value = value[parts[i]];
68263
+ }
68264
+ return value;
68265
+ }
68266
+ function setByPath(obj, path, value) {
68267
+ if (obj == null) obj = {};
68268
+ var parts = path.split('.');
68269
+ var current = obj;
68270
+ for (var i = 0; i < parts.length - 1; i++) {
68271
+ if (current[parts[i]] == null) current[parts[i]] = {};
68272
+ current = current[parts[i]];
68273
+ }
68274
+ current[parts[parts.length - 1]] = value;
68275
+ return obj;
68276
+ }
68277
+ var cache = {
68278
+ local: {},
68279
+ session: {}
68280
+ };
68281
+ function setInitCache(initData) {
68282
+ if (!initData) return;
68283
+ cache = _objectSpread2({
68284
+ local: {},
68285
+ session: {}
68286
+ }, initData);
68287
+ if (initData.login != null) cache.local.login = initData.login;
68288
+ if (initData.settings != null) cache.local.settings = initData.settings;
68289
+ if (initData.dashboard != null) cache.session.dashboard = initData.dashboard;
68290
+ }
68291
+ function setExtraLocal(key, value) {
68292
+ cache.local[key] = value;
68293
+ }
68294
+ function getInitDataForBootstrap() {
68295
+ return getInitData();
68296
+ }
68297
+ function getLocalItem(key, path) {
68298
+ var value = cache.local[key] ?? cache[key];
68299
+ var out = path ? getByPath(value, path) : value;
68300
+ if (out !== undefined) return out;
68301
+ if (key === 'login') return cache.login;
68302
+ if (key === 'settings') return cache.settings;
68303
+ return undefined;
68304
+ }
68305
+ function setLocalItem(key, value, path) {
68306
+ sendStorageSet({
68307
+ op: 'setLocalItem',
68308
+ key: key,
68309
+ value: value,
68310
+ path: path
68311
+ });
68312
+ if (path) {
68313
+ var existing = cache.local[key] ?? cache[key] ?? {};
68314
+ cache.local[key] = setByPath(_objectSpread2({}, existing), path, value);
68315
+ } else {
68316
+ cache.local[key] = value;
68317
+ if (key === 'login') cache.login = value;
68318
+ if (key === 'settings') cache.settings = value;
68319
+ }
68320
+ }
68321
+ function getSessionItem(key, path) {
68322
+ var value = cache.session[key] ?? cache[key];
68323
+ var out = path ? getByPath(value, path) : value;
68324
+ if (out !== undefined) return out;
68325
+ if (key === 'dashboard') return cache.dashboard;
68326
+ return undefined;
68327
+ }
68328
+ function setSessionItem(key, value, path) {
68329
+ sendStorageSet({
68330
+ op: 'setSessionItem',
68331
+ key: key,
68332
+ value: value,
68333
+ path: path
68334
+ });
68335
+ if (path) {
68336
+ var existing = cache.session[key] ?? cache[key] ?? {};
68337
+ cache.session[key] = setByPath(_objectSpread2({}, existing), path, value);
68338
+ } else {
68339
+ cache.session[key] = value;
68340
+ if (key === 'dashboard') cache.dashboard = value;
68341
+ }
68342
+ }
68343
+ function getItem$1(key) {
68344
+ var APP_NAME = getAppName();
68345
+ var namespaced = "".concat(APP_NAME, ":").concat(key);
68346
+ return cache.local[namespaced] ?? cache[key];
68347
+ }
68348
+ function setItem(key, value) {
68349
+ var APP_NAME = getAppName();
68350
+ var namespaced = "".concat(APP_NAME, ":").concat(key);
68351
+ sendStorageSet({
68352
+ op: 'setLocalItem',
68353
+ key: namespaced,
68354
+ value: value
68355
+ });
68356
+ cache.local[namespaced] = value;
68357
+ cache[key] = value;
68358
+ return value;
68359
+ }
68360
+ function setAppContext() {
68361
+ var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
68362
+ try {
68363
+ var _window$toolkitEnv2, _storage$getLocalItem, _window$toolkitEnv3;
68364
+ if (_typeof$1(context) !== 'object' || context === null || Array.isArray(context)) {
68365
+ context = {};
68366
+ }
68367
+ var isCoreApp = (_window$toolkitEnv2 = window.toolkitEnv) !== null && _window$toolkitEnv2 !== void 0 && _window$toolkitEnv2.IS_CORE_APP ? window.toolkitEnv.IS_CORE_APP : process.env.IS_CORE_APP;
68368
+ if (isCoreApp) {
68369
+ setSessionItem('opsportal-core:miHelpBotContext', context);
68370
+ return;
68371
+ }
68372
+ var appTiles = ((_storage$getLocalItem = storage$1.getLocalItem('opsportal-core:config')) === null || _storage$getLocalItem === void 0 ? void 0 : _storage$getLocalItem.tiles) || [];
68373
+ var appName = getAppName();
68374
+ var appData = appTiles.find(function (tile) {
68375
+ return tile.appName ? tile.appName === appName : tile.path === "/".concat(appName);
68376
+ });
68377
+ var appAuthName = appData ? appData.appAuthName : (_window$toolkitEnv3 = window.toolkitEnv) !== null && _window$toolkitEnv3 !== void 0 && _window$toolkitEnv3.APP_AUTH_NAME ? window.toolkitEnv.APP_AUTH_NAME : process.env.APP_AUTH_NAME;
68378
+ if (!appAuthName) throw new Error('appAuthName not found');
68379
+ setSessionItem("".concat(appAuthName, ":miHelpBotContext"), context);
68380
+ } catch (e) {
68381
+ console.log('Error while setting context ', e);
68382
+ }
68383
+ }
68384
+ function clearStorage() {
68385
+ sendStorageSet({
68386
+ op: 'clear'
68387
+ });
68388
+ }
68389
+ var storage$1 = {
68390
+ getLocalItem: getLocalItem,
68391
+ setLocalItem: setLocalItem,
68392
+ getSessionItem: getSessionItem,
68393
+ setSessionItem: setSessionItem,
68394
+ getItem: getItem$1,
68395
+ setItem: setItem,
68396
+ setAppContext: setAppContext,
68397
+ get appContext() {
68398
+ try {
68399
+ var _window$toolkitEnv4, _storage$getLocalItem2, _window$toolkitEnv5;
68400
+ var isCoreApp = (_window$toolkitEnv4 = window.toolkitEnv) !== null && _window$toolkitEnv4 !== void 0 && _window$toolkitEnv4.IS_CORE_APP ? window.toolkitEnv.IS_CORE_APP : process.env.IS_CORE_APP;
68401
+ if (isCoreApp) {
68402
+ return getSessionItem('opsportal-core:miHelpBotContext');
68403
+ }
68404
+ var appTiles = ((_storage$getLocalItem2 = storage$1.getLocalItem('opsportal-core:config')) === null || _storage$getLocalItem2 === void 0 ? void 0 : _storage$getLocalItem2.tiles) || [];
68405
+ var appName = getAppName();
68406
+ var appData = appTiles.find(function (tile) {
68407
+ return tile.appName ? tile.appName === appName : tile.path === "/".concat(appName);
68408
+ });
68409
+ var appAuthName = appData ? appData.appAuthName : (_window$toolkitEnv5 = window.toolkitEnv) !== null && _window$toolkitEnv5 !== void 0 && _window$toolkitEnv5.APP_AUTH_NAME ? window.toolkitEnv.APP_AUTH_NAME : process.env.APP_AUTH_NAME;
68410
+ return appAuthName ? getSessionItem("".concat(appAuthName, ":miHelpBotContext")) : {};
68411
+ } catch (e) {
68412
+ console.log('App context error, ', e);
68413
+ return '';
68414
+ }
68415
+ },
68416
+ get config() {
68417
+ return getItem$1('config');
68418
+ },
68419
+ get coreConfig() {
68420
+ return getLocalItem('opsportal-core:config');
68421
+ },
68422
+ get permissions() {
68423
+ return getLocalItem('settings', 'permissions') || [];
68424
+ },
68425
+ get permissionIds() {
68426
+ return getLocalItem('settings', 'permissionIds') || [];
68427
+ },
68428
+ get allPermissionIds() {
68429
+ return getLocalItem('settings', 'allPermissionIds') || [];
68430
+ },
68431
+ get coreAppPermissions() {
68432
+ return getLocalItem('ops_portal:permissions') || [];
68433
+ },
68434
+ get currentAppPermissions() {
68435
+ var _storage$getLocalItem3, _window$toolkitEnv6;
68436
+ var appTiles = ((_storage$getLocalItem3 = storage$1.getLocalItem('opsportal-core:config')) === null || _storage$getLocalItem3 === void 0 ? void 0 : _storage$getLocalItem3.tiles) || [];
68437
+ var appName = getAppName();
68438
+ var appData = appTiles.find(function (tile) {
68439
+ return tile.appName ? tile.appName === appName : tile.path === "/".concat(appName);
68440
+ });
68441
+ var appAuthName = appData ? appData.appAuthName : (_window$toolkitEnv6 = window.toolkitEnv) !== null && _window$toolkitEnv6 !== void 0 && _window$toolkitEnv6.APP_AUTH_NAME ? window.toolkitEnv.APP_AUTH_NAME : process.env.APP_AUTH_NAME;
68442
+ return appAuthName ? storage$1.getLocalItem("".concat(appAuthName, ":permissions")) : [];
68443
+ },
68444
+ get appScopesAndFunctions() {
68445
+ return getLocalItem('appScopesAndFunctions') || [];
68446
+ },
68447
+ get userAppScopes() {
68448
+ return getLocalItem('login', 'userAppScopes') || [];
68449
+ },
68450
+ get userName() {
68451
+ return getLocalItem('login', 'userData.entity_name');
68452
+ },
68453
+ get userAvailability() {
68454
+ return getLocalItem('dashboard', 'userAvailability');
68455
+ },
68456
+ get userEmail() {
68457
+ return getLocalItem('login', 'userData.entity_mail');
68458
+ },
68459
+ get userCopartId() {
68460
+ return getLocalItem('login', 'userData.entity_employee_copart_id');
68461
+ },
68462
+ get userSamAccount() {
68463
+ return getLocalItem('login', 'userData.entity_sam_id');
68464
+ },
68465
+ get userCountry() {
68466
+ return getLocalItem('login', 'userData.entity_country');
68467
+ },
68468
+ get accessToken() {
68469
+ return getLocalItem('login', 'userData.access_token');
68470
+ },
68471
+ get refreshToken() {
68472
+ return getLocalItem('login', 'userData.refresh_token');
68473
+ },
68474
+ get isAuthenticated() {
68475
+ return getLocalItem('login', 'isAuthenticated');
68476
+ },
68477
+ get activeCountry() {
68478
+ var _getSessionItem;
68479
+ return (_getSessionItem = getSessionItem('dashboard')) === null || _getSessionItem === void 0 ? void 0 : _getSessionItem.selectedCountry;
68480
+ },
68481
+ get activeLanguage() {
68482
+ var _getSessionItem2;
68483
+ return ((_getSessionItem2 = getSessionItem('dashboard')) === null || _getSessionItem2 === void 0 ? void 0 : _getSessionItem2.language) || 'en';
68484
+ },
68485
+ get userSecurityLevel() {
68486
+ return Number(getSessionItem('securityLevel')) || 0;
68487
+ },
68488
+ get phoneNumber() {
68489
+ var _getLocalItem;
68490
+ return (_getLocalItem = getLocalItem('dashboard')) === null || _getLocalItem === void 0 ? void 0 : _getLocalItem.phoneNumber;
68491
+ },
68492
+ get userRole() {
68493
+ var _getLocalItem2;
68494
+ return ((_getLocalItem2 = getLocalItem('settings')) === null || _getLocalItem2 === void 0 ? void 0 : _getLocalItem2.selectedRole) || '';
68495
+ },
68496
+ get hasCasAccess() {
68497
+ var _getLocalItem3, _getLocalItem3$userDa;
68498
+ return (_getLocalItem3 = getLocalItem('login')) === null || _getLocalItem3 === void 0 ? void 0 : (_getLocalItem3$userDa = _getLocalItem3.userData) === null || _getLocalItem3$userDa === void 0 ? void 0 : _getLocalItem3$userDa.hasCasAccess;
68499
+ },
68500
+ get activeYardNumber() {
68501
+ var _getSessionItem3;
68502
+ return (_getSessionItem3 = getSessionItem('dashboard')) === null || _getSessionItem3 === void 0 ? void 0 : _getSessionItem3.selectedYard;
68503
+ },
68504
+ get lastSelectedYard() {
68505
+ var data = getLocalItem('lastSelectedYard');
68506
+ if (data && Object.entries(data).length) {
68507
+ return data;
68508
+ }
68509
+ },
68510
+ get homeYard() {
68511
+ var _getLocalItem4;
68512
+ var yardList = ((_getLocalItem4 = getLocalItem('login')) === null || _getLocalItem4 === void 0 ? void 0 : _getLocalItem4.yardList) || [];
68513
+ return yardList.find(function (yard) {
68514
+ return yard.isHomeYard === 'Y';
68515
+ });
68516
+ },
68517
+ get selectedHierarchy() {
68518
+ return storage$1.getLocalItem('settings', 'selectedHierarchy') || {};
68519
+ },
68520
+ get selectedHierarchyOption() {
68521
+ return storage$1.getLocalItem('settings', 'selectedHierarchyOption') || {};
68522
+ },
68523
+ get chromePluginData() {
68524
+ return storage$1.getLocalItem('chromePluginData') || {};
68525
+ },
68526
+ get twilioVoiceTask() {
68527
+ return getLocalItem('twilio', 'voiceTask') || {};
68528
+ },
68529
+ get twilioCallAnswered() {
68530
+ return getLocalItem('twilio', 'callAccepted') || false;
68531
+ },
68532
+ get twilioWrapup() {
68533
+ return getLocalItem('twilio', 'wrapUpCall') || false;
68534
+ },
68535
+ get twilioEnabledStatus() {
68536
+ return getLocalItem('dashboard', 'twilioEnabled') || false;
68537
+ },
68538
+ get clickToDialEnabledStatus() {
68539
+ return cache.local.c2dEnabled ? JSON.parse(cache.local.c2dEnabled) : false;
68540
+ },
68541
+ get callCapsuleEnabledStatus() {
68542
+ return getLocalItem('dashboard', 'isCallCapsuleEnabled') || false;
68543
+ },
68544
+ get flexLoaded() {
68545
+ return getLocalItem('twilio', 'flexLoaded') || false;
68546
+ },
68547
+ get workerProfileData() {
68548
+ return getLocalItem('twilio', 'workerProfileData') || {};
68549
+ },
68550
+ get twilioStatus() {
68551
+ return getLocalItem('twilio', 'status') || 'Offline';
68552
+ },
68553
+ get twilioUserStatus() {
68554
+ return getLocalItem('twilio', 'userStatus') || 'Offline';
68555
+ },
68556
+ get twilioCallSid() {
68557
+ return getLocalItem('twilio', 'callSid') || false;
68558
+ },
68559
+ get twilioWarning() {
68560
+ return getLocalItem('twilio', 'warning') || 'false';
68561
+ },
68562
+ clear: function clear() {
68563
+ return clearStorage();
68564
+ },
68565
+ logout: function logout() {
68566
+ clearStorage();
68567
+ window.location.assign('/logout');
68568
+ }
68569
+ };
68570
+
68253
68571
  var requestInterceptors = [];
68254
68572
  var responseInterceptors = [];
68255
68573
  function applyRequestInterceptors(config) {
@@ -68474,7 +68792,6 @@ var fetcher = {
68474
68792
  var _getUserPreferences = _asyncToGenerator$1(/*#__PURE__*/_regenerator().m(function _callee5() {
68475
68793
  var appName,
68476
68794
  _config$endpoints,
68477
- storage,
68478
68795
  config,
68479
68796
  urlTemplate,
68480
68797
  url,
@@ -68487,8 +68804,7 @@ var fetcher = {
68487
68804
  case 0:
68488
68805
  appName = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : '';
68489
68806
  _context5.p = 1;
68490
- storage = require("./storage").default;
68491
- config = storage.getLocalItem('opsportal-core:config');
68807
+ config = storage$1.getLocalItem('opsportal-core:config');
68492
68808
  urlTemplate = config === null || config === void 0 ? void 0 : (_config$endpoints = config.endpoints) === null || _config$endpoints === void 0 ? void 0 : _config$endpoints.userPreferences;
68493
68809
  if (urlTemplate) {
68494
68810
  _context5.n = 2;
@@ -68497,7 +68813,7 @@ var fetcher = {
68497
68813
  return _context5.a(2, {});
68498
68814
  case 2:
68499
68815
  url = urlTemplate.replace(/\{appName\}/g, appName);
68500
- country = storage.getSessionItem('dashboard', 'selectedCountryA3code');
68816
+ country = storage$1.getSessionItem('dashboard', 'selectedCountryA3code');
68501
68817
  _context5.n = 3;
68502
68818
  return fetcher.get(url, {
68503
68819
  headers: {
@@ -68525,7 +68841,6 @@ var fetcher = {
68525
68841
  var appName,
68526
68842
  data,
68527
68843
  _config$endpoints2,
68528
- storage,
68529
68844
  config,
68530
68845
  urlTemplate,
68531
68846
  url,
@@ -68539,8 +68854,7 @@ var fetcher = {
68539
68854
  appName = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : '';
68540
68855
  data = _args6.length > 1 ? _args6[1] : undefined;
68541
68856
  _context6.p = 1;
68542
- storage = require("./storage").default;
68543
- config = storage.getLocalItem('opsportal-core:config');
68857
+ config = storage$1.getLocalItem('opsportal-core:config');
68544
68858
  urlTemplate = config === null || config === void 0 ? void 0 : (_config$endpoints2 = config.endpoints) === null || _config$endpoints2 === void 0 ? void 0 : _config$endpoints2.userPreferences;
68545
68859
  if (urlTemplate) {
68546
68860
  _context6.n = 2;
@@ -68549,7 +68863,7 @@ var fetcher = {
68549
68863
  return _context6.a(2, '');
68550
68864
  case 2:
68551
68865
  url = urlTemplate.replace(/\{appName\}/g, appName);
68552
- country = storage.getSessionItem('dashboard', 'selectedCountryA3code');
68866
+ country = storage$1.getSessionItem('dashboard', 'selectedCountryA3code');
68553
68867
  _context6.n = 3;
68554
68868
  return fetcher.put(url, data, {
68555
68869
  headers: {
@@ -68574,13 +68888,12 @@ var fetcher = {
68574
68888
  }(),
68575
68889
  getPrintersForYard: function () {
68576
68890
  var _getPrintersForYard = _asyncToGenerator$1(/*#__PURE__*/_regenerator().m(function _callee7(yardNumber) {
68577
- var _config$endpoints3, storage, config, url, response;
68891
+ var _config$endpoints3, config, url, response;
68578
68892
  return _regenerator().w(function (_context7) {
68579
68893
  while (1) switch (_context7.p = _context7.n) {
68580
68894
  case 0:
68581
68895
  _context7.p = 0;
68582
- storage = require("./storage").default;
68583
- config = storage.getLocalItem('opsportal-core:config');
68896
+ config = storage$1.getLocalItem('opsportal-core:config');
68584
68897
  url = config === null || config === void 0 ? void 0 : (_config$endpoints3 = config.endpoints) === null || _config$endpoints3 === void 0 ? void 0 : _config$endpoints3.printersByYard;
68585
68898
  if (url) {
68586
68899
  _context7.n = 1;
@@ -68761,324 +69074,6 @@ var fetcher = {
68761
69074
  }()
68762
69075
  };
68763
69076
 
68764
- function getAppName() {
68765
- var _window$toolkitEnv;
68766
- return (_window$toolkitEnv = window.toolkitEnv) !== null && _window$toolkitEnv !== void 0 && _window$toolkitEnv.APP_NAME ? window.toolkitEnv.APP_NAME : typeof process !== 'undefined' && process.env && process.env.APP_NAME || 'test-app';
68767
- }
68768
- function getByPath(obj, path) {
68769
- if (obj == null) return undefined;
68770
- var parts = path.split('.');
68771
- var value = obj;
68772
- for (var i = 0; i < parts.length && value != null; i++) {
68773
- value = value[parts[i]];
68774
- }
68775
- return value;
68776
- }
68777
- function setByPath(obj, path, value) {
68778
- if (obj == null) obj = {};
68779
- var parts = path.split('.');
68780
- var current = obj;
68781
- for (var i = 0; i < parts.length - 1; i++) {
68782
- if (current[parts[i]] == null) current[parts[i]] = {};
68783
- current = current[parts[i]];
68784
- }
68785
- current[parts[parts.length - 1]] = value;
68786
- return obj;
68787
- }
68788
- var cache = {
68789
- local: {},
68790
- session: {}
68791
- };
68792
- function setInitCache(initData) {
68793
- if (!initData) return;
68794
- cache = _objectSpread2({
68795
- local: {},
68796
- session: {}
68797
- }, initData);
68798
- if (initData.login != null) cache.local.login = initData.login;
68799
- if (initData.settings != null) cache.local.settings = initData.settings;
68800
- if (initData.dashboard != null) cache.session.dashboard = initData.dashboard;
68801
- }
68802
- function setExtraLocal(key, value) {
68803
- cache.local[key] = value;
68804
- }
68805
- function getInitDataForBootstrap() {
68806
- return getInitData();
68807
- }
68808
- function getLocalItem(key, path) {
68809
- var value = cache.local[key] ?? cache[key];
68810
- var out = path ? getByPath(value, path) : value;
68811
- if (out !== undefined) return out;
68812
- if (key === 'login') return cache.login;
68813
- if (key === 'settings') return cache.settings;
68814
- return undefined;
68815
- }
68816
- function setLocalItem(key, value, path) {
68817
- sendStorageSet({
68818
- op: 'setLocalItem',
68819
- key: key,
68820
- value: value,
68821
- path: path
68822
- });
68823
- if (path) {
68824
- var existing = cache.local[key] ?? cache[key] ?? {};
68825
- cache.local[key] = setByPath(_objectSpread2({}, existing), path, value);
68826
- } else {
68827
- cache.local[key] = value;
68828
- if (key === 'login') cache.login = value;
68829
- if (key === 'settings') cache.settings = value;
68830
- }
68831
- }
68832
- function getSessionItem(key, path) {
68833
- var value = cache.session[key] ?? cache[key];
68834
- var out = path ? getByPath(value, path) : value;
68835
- if (out !== undefined) return out;
68836
- if (key === 'dashboard') return cache.dashboard;
68837
- return undefined;
68838
- }
68839
- function setSessionItem(key, value, path) {
68840
- sendStorageSet({
68841
- op: 'setSessionItem',
68842
- key: key,
68843
- value: value,
68844
- path: path
68845
- });
68846
- if (path) {
68847
- var existing = cache.session[key] ?? cache[key] ?? {};
68848
- cache.session[key] = setByPath(_objectSpread2({}, existing), path, value);
68849
- } else {
68850
- cache.session[key] = value;
68851
- if (key === 'dashboard') cache.dashboard = value;
68852
- }
68853
- }
68854
- function getItem$1(key) {
68855
- var APP_NAME = getAppName();
68856
- var namespaced = "".concat(APP_NAME, ":").concat(key);
68857
- return cache.local[namespaced] ?? cache[key];
68858
- }
68859
- function setItem(key, value) {
68860
- var APP_NAME = getAppName();
68861
- var namespaced = "".concat(APP_NAME, ":").concat(key);
68862
- sendStorageSet({
68863
- op: 'setLocalItem',
68864
- key: namespaced,
68865
- value: value
68866
- });
68867
- cache.local[namespaced] = value;
68868
- cache[key] = value;
68869
- return value;
68870
- }
68871
- function setAppContext() {
68872
- var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
68873
- try {
68874
- var _window$toolkitEnv2, _storage$getLocalItem, _window$toolkitEnv3;
68875
- if (_typeof$1(context) !== 'object' || context === null || Array.isArray(context)) {
68876
- context = {};
68877
- }
68878
- var isCoreApp = (_window$toolkitEnv2 = window.toolkitEnv) !== null && _window$toolkitEnv2 !== void 0 && _window$toolkitEnv2.IS_CORE_APP ? window.toolkitEnv.IS_CORE_APP : process.env.IS_CORE_APP;
68879
- if (isCoreApp) {
68880
- setSessionItem('opsportal-core:miHelpBotContext', context);
68881
- return;
68882
- }
68883
- var appTiles = ((_storage$getLocalItem = storage$1.getLocalItem('opsportal-core:config')) === null || _storage$getLocalItem === void 0 ? void 0 : _storage$getLocalItem.tiles) || [];
68884
- var appName = getAppName();
68885
- var appData = appTiles.find(function (tile) {
68886
- return tile.appName ? tile.appName === appName : tile.path === "/".concat(appName);
68887
- });
68888
- var appAuthName = appData ? appData.appAuthName : (_window$toolkitEnv3 = window.toolkitEnv) !== null && _window$toolkitEnv3 !== void 0 && _window$toolkitEnv3.APP_AUTH_NAME ? window.toolkitEnv.APP_AUTH_NAME : process.env.APP_AUTH_NAME;
68889
- if (!appAuthName) throw new Error('appAuthName not found');
68890
- setSessionItem("".concat(appAuthName, ":miHelpBotContext"), context);
68891
- } catch (e) {
68892
- console.log('Error while setting context ', e);
68893
- }
68894
- }
68895
- function clearStorage() {
68896
- sendStorageSet({
68897
- op: 'clear'
68898
- });
68899
- }
68900
- var storage$1 = {
68901
- getLocalItem: getLocalItem,
68902
- setLocalItem: setLocalItem,
68903
- getSessionItem: getSessionItem,
68904
- setSessionItem: setSessionItem,
68905
- getItem: getItem$1,
68906
- setItem: setItem,
68907
- setAppContext: setAppContext,
68908
- get appContext() {
68909
- try {
68910
- var _window$toolkitEnv4, _storage$getLocalItem2, _window$toolkitEnv5;
68911
- var isCoreApp = (_window$toolkitEnv4 = window.toolkitEnv) !== null && _window$toolkitEnv4 !== void 0 && _window$toolkitEnv4.IS_CORE_APP ? window.toolkitEnv.IS_CORE_APP : process.env.IS_CORE_APP;
68912
- if (isCoreApp) {
68913
- return getSessionItem('opsportal-core:miHelpBotContext');
68914
- }
68915
- var appTiles = ((_storage$getLocalItem2 = storage$1.getLocalItem('opsportal-core:config')) === null || _storage$getLocalItem2 === void 0 ? void 0 : _storage$getLocalItem2.tiles) || [];
68916
- var appName = getAppName();
68917
- var appData = appTiles.find(function (tile) {
68918
- return tile.appName ? tile.appName === appName : tile.path === "/".concat(appName);
68919
- });
68920
- var appAuthName = appData ? appData.appAuthName : (_window$toolkitEnv5 = window.toolkitEnv) !== null && _window$toolkitEnv5 !== void 0 && _window$toolkitEnv5.APP_AUTH_NAME ? window.toolkitEnv.APP_AUTH_NAME : process.env.APP_AUTH_NAME;
68921
- return appAuthName ? getSessionItem("".concat(appAuthName, ":miHelpBotContext")) : {};
68922
- } catch (e) {
68923
- console.log('App context error, ', e);
68924
- return '';
68925
- }
68926
- },
68927
- get config() {
68928
- return getItem$1('config');
68929
- },
68930
- get coreConfig() {
68931
- return getLocalItem('opsportal-core:config');
68932
- },
68933
- get permissions() {
68934
- return getLocalItem('settings', 'permissions') || [];
68935
- },
68936
- get permissionIds() {
68937
- return getLocalItem('settings', 'permissionIds') || [];
68938
- },
68939
- get allPermissionIds() {
68940
- return getLocalItem('settings', 'allPermissionIds') || [];
68941
- },
68942
- get coreAppPermissions() {
68943
- return getLocalItem('ops_portal:permissions') || [];
68944
- },
68945
- get currentAppPermissions() {
68946
- var _storage$getLocalItem3, _window$toolkitEnv6;
68947
- var appTiles = ((_storage$getLocalItem3 = storage$1.getLocalItem('opsportal-core:config')) === null || _storage$getLocalItem3 === void 0 ? void 0 : _storage$getLocalItem3.tiles) || [];
68948
- var appName = getAppName();
68949
- var appData = appTiles.find(function (tile) {
68950
- return tile.appName ? tile.appName === appName : tile.path === "/".concat(appName);
68951
- });
68952
- var appAuthName = appData ? appData.appAuthName : (_window$toolkitEnv6 = window.toolkitEnv) !== null && _window$toolkitEnv6 !== void 0 && _window$toolkitEnv6.APP_AUTH_NAME ? window.toolkitEnv.APP_AUTH_NAME : process.env.APP_AUTH_NAME;
68953
- return appAuthName ? storage$1.getLocalItem("".concat(appAuthName, ":permissions")) : [];
68954
- },
68955
- get appScopesAndFunctions() {
68956
- return getLocalItem('appScopesAndFunctions') || [];
68957
- },
68958
- get userAppScopes() {
68959
- return getLocalItem('login', 'userAppScopes') || [];
68960
- },
68961
- get userName() {
68962
- return getLocalItem('login', 'userData.entity_name');
68963
- },
68964
- get userAvailability() {
68965
- return getLocalItem('dashboard', 'userAvailability');
68966
- },
68967
- get userEmail() {
68968
- return getLocalItem('login', 'userData.entity_mail');
68969
- },
68970
- get userCopartId() {
68971
- return getLocalItem('login', 'userData.entity_employee_copart_id');
68972
- },
68973
- get userSamAccount() {
68974
- return getLocalItem('login', 'userData.entity_sam_id');
68975
- },
68976
- get userCountry() {
68977
- return getLocalItem('login', 'userData.entity_country');
68978
- },
68979
- get accessToken() {
68980
- return getLocalItem('login', 'userData.access_token');
68981
- },
68982
- get refreshToken() {
68983
- return getLocalItem('login', 'userData.refresh_token');
68984
- },
68985
- get isAuthenticated() {
68986
- return getLocalItem('login', 'isAuthenticated');
68987
- },
68988
- get activeCountry() {
68989
- var _getSessionItem;
68990
- return (_getSessionItem = getSessionItem('dashboard')) === null || _getSessionItem === void 0 ? void 0 : _getSessionItem.selectedCountry;
68991
- },
68992
- get activeLanguage() {
68993
- var _getSessionItem2;
68994
- return ((_getSessionItem2 = getSessionItem('dashboard')) === null || _getSessionItem2 === void 0 ? void 0 : _getSessionItem2.language) || 'en';
68995
- },
68996
- get userSecurityLevel() {
68997
- return Number(getSessionItem('securityLevel')) || 0;
68998
- },
68999
- get phoneNumber() {
69000
- var _getLocalItem;
69001
- return (_getLocalItem = getLocalItem('dashboard')) === null || _getLocalItem === void 0 ? void 0 : _getLocalItem.phoneNumber;
69002
- },
69003
- get userRole() {
69004
- var _getLocalItem2;
69005
- return ((_getLocalItem2 = getLocalItem('settings')) === null || _getLocalItem2 === void 0 ? void 0 : _getLocalItem2.selectedRole) || '';
69006
- },
69007
- get hasCasAccess() {
69008
- var _getLocalItem3, _getLocalItem3$userDa;
69009
- return (_getLocalItem3 = getLocalItem('login')) === null || _getLocalItem3 === void 0 ? void 0 : (_getLocalItem3$userDa = _getLocalItem3.userData) === null || _getLocalItem3$userDa === void 0 ? void 0 : _getLocalItem3$userDa.hasCasAccess;
69010
- },
69011
- get activeYardNumber() {
69012
- var _getSessionItem3;
69013
- return (_getSessionItem3 = getSessionItem('dashboard')) === null || _getSessionItem3 === void 0 ? void 0 : _getSessionItem3.selectedYard;
69014
- },
69015
- get lastSelectedYard() {
69016
- var data = getLocalItem('lastSelectedYard');
69017
- if (data && Object.entries(data).length) {
69018
- return data;
69019
- }
69020
- },
69021
- get homeYard() {
69022
- var _getLocalItem4;
69023
- var yardList = ((_getLocalItem4 = getLocalItem('login')) === null || _getLocalItem4 === void 0 ? void 0 : _getLocalItem4.yardList) || [];
69024
- return yardList.find(function (yard) {
69025
- return yard.isHomeYard === 'Y';
69026
- });
69027
- },
69028
- get selectedHierarchy() {
69029
- return storage$1.getLocalItem('settings', 'selectedHierarchy') || {};
69030
- },
69031
- get selectedHierarchyOption() {
69032
- return storage$1.getLocalItem('settings', 'selectedHierarchyOption') || {};
69033
- },
69034
- get chromePluginData() {
69035
- return storage$1.getLocalItem('chromePluginData') || {};
69036
- },
69037
- get twilioVoiceTask() {
69038
- return getLocalItem('twilio', 'voiceTask') || {};
69039
- },
69040
- get twilioCallAnswered() {
69041
- return getLocalItem('twilio', 'callAccepted') || false;
69042
- },
69043
- get twilioWrapup() {
69044
- return getLocalItem('twilio', 'wrapUpCall') || false;
69045
- },
69046
- get twilioEnabledStatus() {
69047
- return getLocalItem('dashboard', 'twilioEnabled') || false;
69048
- },
69049
- get clickToDialEnabledStatus() {
69050
- return cache.local.c2dEnabled ? JSON.parse(cache.local.c2dEnabled) : false;
69051
- },
69052
- get callCapsuleEnabledStatus() {
69053
- return getLocalItem('dashboard', 'isCallCapsuleEnabled') || false;
69054
- },
69055
- get flexLoaded() {
69056
- return getLocalItem('twilio', 'flexLoaded') || false;
69057
- },
69058
- get workerProfileData() {
69059
- return getLocalItem('twilio', 'workerProfileData') || {};
69060
- },
69061
- get twilioStatus() {
69062
- return getLocalItem('twilio', 'status') || 'Offline';
69063
- },
69064
- get twilioUserStatus() {
69065
- return getLocalItem('twilio', 'userStatus') || 'Offline';
69066
- },
69067
- get twilioCallSid() {
69068
- return getLocalItem('twilio', 'callSid') || false;
69069
- },
69070
- get twilioWarning() {
69071
- return getLocalItem('twilio', 'warning') || 'false';
69072
- },
69073
- clear: function clear() {
69074
- return clearStorage();
69075
- },
69076
- logout: function logout() {
69077
- clearStorage();
69078
- window.location.assign('/logout');
69079
- }
69080
- };
69081
-
69082
69077
  var isEmpty = function isEmpty(arr) {
69083
69078
  return !arr || arr.length === 0;
69084
69079
  };