@itwin/core-i18n 5.14.4 → 5.14.6

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.
@@ -2032,7 +2032,7 @@ cov_ogldeftyv().s[3]++;
2032
2032
  exports.ITwinLocalization = void 0;
2033
2033
  const i18next_1 = (cov_ogldeftyv().s[4]++, __importDefault(__webpack_require__(/*! i18next */ "../../common/temp/node_modules/.pnpm/i18next@21.10.0/node_modules/i18next/dist/cjs/i18next.js")));
2034
2034
  const i18next_browser_languagedetector_1 = (cov_ogldeftyv().s[5]++, __importDefault(__webpack_require__(/*! i18next-browser-languagedetector */ "../../common/temp/node_modules/.pnpm/i18next-browser-languagedetector@6.1.8/node_modules/i18next-browser-languagedetector/dist/cjs/i18nextBrowserLanguageDetector.js")));
2035
- const i18next_http_backend_1 = (cov_ogldeftyv().s[6]++, __importDefault(__webpack_require__(/*! i18next-http-backend */ "../../common/temp/node_modules/.pnpm/i18next-http-backend@3.0.6/node_modules/i18next-http-backend/esm/index.js")));
2035
+ const i18next_http_backend_1 = (cov_ogldeftyv().s[6]++, __importDefault(__webpack_require__(/*! i18next-http-backend */ "../../common/temp/node_modules/.pnpm/i18next-http-backend@4.0.6/node_modules/i18next-http-backend/esm/index.js")));
2036
2036
  const core_bentley_1 = (cov_ogldeftyv().s[7]++, __webpack_require__(/*! @itwin/core-bentley */ "../bentley/lib/esm/core-bentley.js"));
2037
2037
  const DEFAULT_MAX_RETRIES = (cov_ogldeftyv().s[8]++, 1); // a low number prevents wasted time and potential timeouts when requesting localization files throws an error
2038
2038
  /** Supplies localizations for iTwin.js
@@ -24924,534 +24924,382 @@ module.exports = _unsupportedIterableToArray, module.exports.__esModule = true,
24924
24924
 
24925
24925
  /***/ },
24926
24926
 
24927
- /***/ "../../common/temp/node_modules/.pnpm/i18next-http-backend@3.0.6/node_modules/i18next-http-backend/esm/index.js"
24927
+ /***/ "../../common/temp/node_modules/.pnpm/i18next-http-backend@4.0.6/node_modules/i18next-http-backend/esm/index.js"
24928
24928
  /*!**********************************************************************************************************************!*\
24929
- !*** ../../common/temp/node_modules/.pnpm/i18next-http-backend@3.0.6/node_modules/i18next-http-backend/esm/index.js ***!
24929
+ !*** ../../common/temp/node_modules/.pnpm/i18next-http-backend@4.0.6/node_modules/i18next-http-backend/esm/index.js ***!
24930
24930
  \**********************************************************************************************************************/
24931
24931
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
24932
24932
 
24933
24933
  "use strict";
24934
24934
  __webpack_require__.r(__webpack_exports__);
24935
24935
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
24936
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
24936
+ /* harmony export */ "default": () => (/* binding */ Backend)
24937
24937
  /* harmony export */ });
24938
- /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "../../common/temp/node_modules/.pnpm/i18next-http-backend@3.0.6/node_modules/i18next-http-backend/esm/utils.js");
24939
- /* harmony import */ var _request_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./request.js */ "../../common/temp/node_modules/.pnpm/i18next-http-backend@3.0.6/node_modules/i18next-http-backend/esm/request.js");
24940
- 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); }
24941
- 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; }
24942
- 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; }
24943
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
24944
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
24945
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
24946
- 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; }
24947
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
24948
- 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); }
24949
- ;
24950
-
24951
- var getDefaults = function getDefaults() {
24952
- return {
24953
- loadPath: '/locales/{{lng}}/{{ns}}.json',
24954
- addPath: '/locales/add/{{lng}}/{{ns}}',
24955
- parse: function parse(data) {
24956
- return JSON.parse(data);
24957
- },
24958
- stringify: JSON.stringify,
24959
- parsePayload: function parsePayload(namespace, key, fallbackValue) {
24960
- return _defineProperty({}, key, fallbackValue || '');
24961
- },
24962
- parseLoadPayload: function parseLoadPayload(languages, namespaces) {
24963
- return undefined;
24964
- },
24965
- request: _request_js__WEBPACK_IMPORTED_MODULE_1__["default"],
24966
- reloadInterval: typeof window !== 'undefined' ? false : 60 * 60 * 1000,
24967
- customHeaders: {},
24968
- queryStringParams: {},
24969
- crossDomain: false,
24970
- withCredentials: false,
24971
- overrideMimeType: false,
24972
- requestOptions: {
24973
- mode: 'cors',
24974
- credentials: 'same-origin',
24975
- cache: 'default'
24976
- }
24977
- };
24978
- };
24979
- var Backend = function () {
24980
- function Backend(services) {
24981
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
24982
- var allOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
24983
- _classCallCheck(this, Backend);
24984
- this.services = services;
24985
- this.options = options;
24986
- this.allOptions = allOptions;
24987
- this.type = 'backend';
24988
- this.init(services, options, allOptions);
24989
- }
24990
- return _createClass(Backend, [{
24991
- key: "init",
24992
- value: function init(services) {
24993
- var _this = this;
24994
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
24995
- var allOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
24996
- this.services = services;
24997
- this.options = _objectSpread(_objectSpread(_objectSpread({}, getDefaults()), this.options || {}), options);
24998
- this.allOptions = allOptions;
24999
- if (this.services && this.options.reloadInterval) {
25000
- var timer = setInterval(function () {
25001
- return _this.reload();
25002
- }, this.options.reloadInterval);
25003
- if (_typeof(timer) === 'object' && typeof timer.unref === 'function') timer.unref();
25004
- }
25005
- }
25006
- }, {
25007
- key: "readMulti",
25008
- value: function readMulti(languages, namespaces, callback) {
25009
- this._readAny(languages, languages, namespaces, namespaces, callback);
25010
- }
25011
- }, {
25012
- key: "read",
25013
- value: function read(language, namespace, callback) {
25014
- this._readAny([language], language, [namespace], namespace, callback);
25015
- }
25016
- }, {
25017
- key: "_readAny",
25018
- value: function _readAny(languages, loadUrlLanguages, namespaces, loadUrlNamespaces, callback) {
25019
- var _this2 = this;
25020
- var loadPath = this.options.loadPath;
25021
- if (typeof this.options.loadPath === 'function') {
25022
- loadPath = this.options.loadPath(languages, namespaces);
25023
- }
25024
- loadPath = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.makePromise)(loadPath);
25025
- loadPath.then(function (resolvedLoadPath) {
25026
- if (!resolvedLoadPath) return callback(null, {});
25027
- var url = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.interpolateUrl)(resolvedLoadPath, {
25028
- lng: languages.join('+'),
25029
- ns: namespaces.join('+')
25030
- });
25031
- if (url == null) {
25032
- var safeLngs = languages.map(_utils_js__WEBPACK_IMPORTED_MODULE_0__.sanitizeLogValue).join(', ');
25033
- var safeNss = namespaces.map(_utils_js__WEBPACK_IMPORTED_MODULE_0__.sanitizeLogValue).join(', ');
25034
- return callback(new Error('i18next-http-backend: unsafe lng/ns value — refusing to build request URL for languages=[' + safeLngs + '] namespaces=[' + safeNss + ']'), false);
25035
- }
25036
- _this2.loadUrl(url, callback, loadUrlLanguages, loadUrlNamespaces);
25037
- });
25038
- }
25039
- }, {
25040
- key: "loadUrl",
25041
- value: function loadUrl(url, callback, languages, namespaces) {
25042
- var _this3 = this;
25043
- var lng = typeof languages === 'string' ? [languages] : languages;
25044
- var ns = typeof namespaces === 'string' ? [namespaces] : namespaces;
25045
- var payload = this.options.parseLoadPayload(lng, ns);
25046
- var safeUrl = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.sanitizeLogValue)((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.redactUrlCredentials)(url));
25047
- this.options.request(this.options, url, payload, function (err, res) {
25048
- if (res && (res.status >= 500 && res.status < 600 || !res.status)) return callback('failed loading ' + safeUrl + '; status code: ' + res.status, true);
25049
- if (res && res.status >= 400 && res.status < 500) return callback('failed loading ' + safeUrl + '; status code: ' + res.status, false);
25050
- if (!res && err && err.message) {
25051
- var errorMessage = err.message.toLowerCase();
25052
- var isNetworkError = ['failed', 'fetch', 'network', 'load'].find(function (term) {
25053
- return errorMessage.indexOf(term) > -1;
25054
- });
25055
- if (isNetworkError) {
25056
- return callback('failed loading ' + safeUrl + ': ' + (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.sanitizeLogValue)(err.message), true);
25057
- }
25058
- }
25059
- if (err) return callback(err, false);
25060
- var ret, parseErr;
25061
- try {
25062
- if (typeof res.data === 'string') {
25063
- ret = _this3.options.parse(res.data, languages, namespaces);
25064
- } else {
25065
- ret = res.data;
25066
- }
25067
- } catch (e) {
25068
- parseErr = 'failed parsing ' + safeUrl + ' to json';
25069
- }
25070
- if (parseErr) return callback(parseErr, false);
25071
- callback(null, ret);
25072
- });
25073
- }
25074
- }, {
25075
- key: "create",
25076
- value: function create(languages, namespace, key, fallbackValue, callback) {
25077
- var _this4 = this;
25078
- if (!this.options.addPath) return;
25079
- if (typeof languages === 'string') languages = [languages];
25080
- var payload = this.options.parsePayload(namespace, key, fallbackValue);
25081
- var finished = 0;
25082
- var dataArray = [];
25083
- var resArray = [];
25084
- languages.forEach(function (lng) {
25085
- var addPath = _this4.options.addPath;
25086
- if (typeof _this4.options.addPath === 'function') {
25087
- addPath = _this4.options.addPath(lng, namespace);
25088
- }
25089
- var url = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.interpolateUrl)(addPath, {
25090
- lng: lng,
25091
- ns: namespace
25092
- });
25093
- if (url == null) {
25094
- finished += 1;
25095
- if (callback && finished === languages.length) callback(dataArray, resArray);
25096
- return;
25097
- }
25098
- _this4.options.request(_this4.options, url, payload, function (data, res) {
25099
- finished += 1;
25100
- dataArray.push(data);
25101
- resArray.push(res);
25102
- if (finished === languages.length) {
25103
- if (typeof callback === 'function') callback(dataArray, resArray);
25104
- }
25105
- });
25106
- });
25107
- }
25108
- }, {
25109
- key: "reload",
25110
- value: function reload() {
25111
- var _this5 = this;
25112
- var _this$services = this.services,
25113
- backendConnector = _this$services.backendConnector,
25114
- languageUtils = _this$services.languageUtils,
25115
- logger = _this$services.logger;
25116
- var currentLanguage = backendConnector.language;
25117
- if (currentLanguage && currentLanguage.toLowerCase() === 'cimode') return;
25118
- var toLoad = [];
25119
- var append = function append(lng) {
25120
- var lngs = languageUtils.toResolveHierarchy(lng);
25121
- lngs.forEach(function (l) {
25122
- if (toLoad.indexOf(l) < 0) toLoad.push(l);
25123
- });
25124
- };
25125
- append(currentLanguage);
25126
- if (this.allOptions.preload) this.allOptions.preload.forEach(function (l) {
25127
- return append(l);
25128
- });
25129
- toLoad.forEach(function (lng) {
25130
- _this5.allOptions.ns.forEach(function (ns) {
25131
- backendConnector.read(lng, ns, 'read', null, null, function (err, data) {
25132
- if (err) logger.warn("loading namespace ".concat(ns, " for language ").concat(lng, " failed"), err);
25133
- if (!err && data) logger.log("loaded namespace ".concat(ns, " for language ").concat(lng), data);
25134
- backendConnector.loaded("".concat(lng, "|").concat(ns), err, data);
25135
- });
25136
- });
25137
- });
25138
- }
25139
- }]);
25140
- }();
25141
- Backend.type = 'backend';
25142
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Backend);
25143
-
25144
- /***/ },
25145
-
25146
- /***/ "../../common/temp/node_modules/.pnpm/i18next-http-backend@3.0.6/node_modules/i18next-http-backend/esm/request.js"
25147
- /*!************************************************************************************************************************!*\
25148
- !*** ../../common/temp/node_modules/.pnpm/i18next-http-backend@3.0.6/node_modules/i18next-http-backend/esm/request.js ***!
25149
- \************************************************************************************************************************/
25150
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
25151
-
25152
- "use strict";
25153
- __webpack_require__.r(__webpack_exports__);
25154
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
25155
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
25156
- /* harmony export */ });
25157
- /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "../../common/temp/node_modules/.pnpm/i18next-http-backend@3.0.6/node_modules/i18next-http-backend/esm/utils.js");
25158
- 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; }
25159
- 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; }
25160
- 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; }
25161
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
25162
- 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); }
25163
- 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); }
25164
- ;
25165
- var fetchApi = typeof fetch === 'function' ? fetch : undefined;
25166
- if (typeof __webpack_require__.g !== 'undefined' && __webpack_require__.g.fetch) {
25167
- fetchApi = __webpack_require__.g.fetch;
25168
- } else if (typeof window !== 'undefined' && window.fetch) {
25169
- fetchApi = window.fetch;
25170
- }
25171
- var XmlHttpRequestApi;
25172
- if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.hasXMLHttpRequest)()) {
25173
- if (typeof __webpack_require__.g !== 'undefined' && __webpack_require__.g.XMLHttpRequest) {
25174
- XmlHttpRequestApi = __webpack_require__.g.XMLHttpRequest;
25175
- } else if (typeof window !== 'undefined' && window.XMLHttpRequest) {
25176
- XmlHttpRequestApi = window.XMLHttpRequest;
25177
- }
25178
- }
25179
- var ActiveXObjectApi;
25180
- if (typeof ActiveXObject === 'function') {
25181
- if (typeof __webpack_require__.g !== 'undefined' && __webpack_require__.g.ActiveXObject) {
25182
- ActiveXObjectApi = __webpack_require__.g.ActiveXObject;
25183
- } else if (typeof window !== 'undefined' && window.ActiveXObject) {
25184
- ActiveXObjectApi = window.ActiveXObject;
25185
- }
25186
- }
25187
- if (typeof fetchApi !== 'function') fetchApi = undefined;
25188
- if (!fetchApi && !XmlHttpRequestApi && !ActiveXObjectApi) {
25189
- try {
25190
- __webpack_require__.e(/*! import() */ "vendors-common_temp_node_modules_pnpm_cross-fetch_4_1_0_node_modules_cross-fetch_dist_browser-44272f").then(() => (__webpack_require__.t(/*! cross-fetch */ "../../common/temp/node_modules/.pnpm/cross-fetch@4.1.0/node_modules/cross-fetch/dist/browser-ponyfill.js", 19))).then(function (mod) {
25191
- fetchApi = mod.default;
25192
- }).catch(function () {});
25193
- } catch (e) {}
25194
- }
25195
- var UNSAFE_KEYS = ['__proto__', 'constructor', 'prototype'];
25196
- var addQueryString = function addQueryString(url, params) {
25197
- if (params && _typeof(params) === 'object') {
25198
- var queryString = '';
25199
- for (var _i = 0, _Object$keys = Object.keys(params); _i < _Object$keys.length; _i++) {
25200
- var paramName = _Object$keys[_i];
25201
- if (UNSAFE_KEYS.indexOf(paramName) > -1) continue;
25202
- queryString += '&' + encodeURIComponent(paramName) + '=' + encodeURIComponent(params[paramName]);
25203
- }
25204
- if (!queryString) return url;
25205
- url = url + (url.indexOf('?') !== -1 ? '&' : '?') + queryString.slice(1);
25206
- }
25207
- return url;
25208
- };
25209
- var fetchIt = function fetchIt(url, fetchOptions, callback, altFetch) {
25210
- var resolver = function resolver(response) {
25211
- if (!response.ok) return callback(response.statusText || 'Error', {
25212
- status: response.status
25213
- });
25214
- response.text().then(function (data) {
25215
- callback(null, {
25216
- status: response.status,
25217
- data: data
25218
- });
25219
- }).catch(callback);
25220
- };
25221
- if (altFetch) {
25222
- var altResponse = altFetch(url, fetchOptions);
25223
- if (altResponse instanceof Promise) {
25224
- altResponse.then(resolver).catch(callback);
25225
- return;
25226
- }
25227
- }
25228
- if (typeof fetch === 'function') {
25229
- fetch(url, fetchOptions).then(resolver).catch(callback);
25230
- } else {
25231
- fetchApi(url, fetchOptions).then(resolver).catch(callback);
25232
- }
25233
- };
25234
- var requestWithFetch = function requestWithFetch(options, url, payload, callback) {
25235
- if (options.queryStringParams) {
25236
- url = addQueryString(url, options.queryStringParams);
25237
- }
25238
- var headers = _objectSpread({}, typeof options.customHeaders === 'function' ? options.customHeaders() : options.customHeaders);
25239
- if (typeof window === 'undefined' && typeof __webpack_require__.g !== 'undefined' && typeof __webpack_require__.g.process !== 'undefined' && __webpack_require__.g.process.versions && __webpack_require__.g.process.versions.node) {
25240
- headers['User-Agent'] = "i18next-http-backend (node/".concat(__webpack_require__.g.process.version, "; ").concat(__webpack_require__.g.process.platform, " ").concat(__webpack_require__.g.process.arch, ")");
25241
- }
25242
- if (payload) headers['Content-Type'] = 'application/json';
25243
- var reqOptions = typeof options.requestOptions === 'function' ? options.requestOptions(payload) : options.requestOptions;
25244
- var fetchOptions = _objectSpread({
25245
- method: payload ? 'POST' : 'GET',
25246
- body: payload ? options.stringify(payload) : undefined,
25247
- headers: headers
25248
- }, options._omitFetchOptions ? {} : reqOptions);
25249
- var altFetch = typeof options.alternateFetch === 'function' && options.alternateFetch.length >= 1 ? options.alternateFetch : undefined;
25250
- try {
25251
- fetchIt(url, fetchOptions, callback, altFetch);
25252
- } catch (e) {
25253
- if (!reqOptions || Object.keys(reqOptions).length === 0 || !e.message || e.message.indexOf('not implemented') < 0) {
25254
- return callback(e);
25255
- }
25256
- try {
25257
- Object.keys(reqOptions).forEach(function (opt) {
25258
- delete fetchOptions[opt];
25259
- });
25260
- fetchIt(url, fetchOptions, callback, altFetch);
25261
- options._omitFetchOptions = true;
25262
- } catch (err) {
25263
- callback(err);
25264
- }
25265
- }
25266
- };
25267
- var requestWithXmlHttpRequest = function requestWithXmlHttpRequest(options, url, payload, callback) {
25268
- if (payload && _typeof(payload) === 'object') {
25269
- payload = addQueryString('', payload).slice(1);
25270
- }
25271
- if (options.queryStringParams) {
25272
- url = addQueryString(url, options.queryStringParams);
25273
- }
25274
- try {
25275
- var x = XmlHttpRequestApi ? new XmlHttpRequestApi() : new ActiveXObjectApi('MSXML2.XMLHTTP.3.0');
25276
- x.open(payload ? 'POST' : 'GET', url, 1);
25277
- if (!options.crossDomain) {
25278
- x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
25279
- }
25280
- x.withCredentials = !!options.withCredentials;
25281
- if (payload) {
25282
- x.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
25283
- }
25284
- if (x.overrideMimeType) {
25285
- x.overrideMimeType('application/json');
25286
- }
25287
- var h = options.customHeaders;
25288
- h = typeof h === 'function' ? h() : h;
25289
- if (h) {
25290
- for (var _i2 = 0, _Object$keys2 = Object.keys(h); _i2 < _Object$keys2.length; _i2++) {
25291
- var i = _Object$keys2[_i2];
25292
- if (UNSAFE_KEYS.indexOf(i) > -1) continue;
25293
- x.setRequestHeader(i, h[i]);
25294
- }
25295
- }
25296
- x.onreadystatechange = function () {
25297
- x.readyState > 3 && callback(x.status >= 400 ? x.statusText : null, {
25298
- status: x.status,
25299
- data: x.responseText
25300
- });
25301
- };
25302
- x.send(payload);
25303
- } catch (e) {
25304
- console && console.log(e);
25305
- }
25306
- };
25307
- var request = function request(options, url, payload, callback) {
25308
- if (typeof payload === 'function') {
25309
- callback = payload;
25310
- payload = undefined;
25311
- }
25312
- callback = callback || function () {};
25313
- if (fetchApi && url.indexOf('file:') !== 0) {
25314
- return requestWithFetch(options, url, payload, callback);
25315
- }
25316
- if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.hasXMLHttpRequest)() || typeof ActiveXObject === 'function') {
25317
- return requestWithXmlHttpRequest(options, url, payload, callback);
25318
- }
25319
- callback(new Error('No fetch and no xhr implementation found!'));
25320
- };
25321
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (request);
25322
-
25323
- /***/ },
25324
-
25325
- /***/ "../../common/temp/node_modules/.pnpm/i18next-http-backend@3.0.6/node_modules/i18next-http-backend/esm/utils.js"
25326
- /*!**********************************************************************************************************************!*\
25327
- !*** ../../common/temp/node_modules/.pnpm/i18next-http-backend@3.0.6/node_modules/i18next-http-backend/esm/utils.js ***!
25328
- \**********************************************************************************************************************/
25329
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
25330
-
25331
- "use strict";
25332
- __webpack_require__.r(__webpack_exports__);
25333
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
25334
- /* harmony export */ defaults: () => (/* binding */ defaults),
25335
- /* harmony export */ hasXMLHttpRequest: () => (/* binding */ hasXMLHttpRequest),
25336
- /* harmony export */ interpolate: () => (/* binding */ interpolate),
25337
- /* harmony export */ interpolateUrl: () => (/* binding */ interpolateUrl),
25338
- /* harmony export */ isSafeLangUrlSegment: () => (/* binding */ isSafeLangUrlSegment),
25339
- /* harmony export */ isSafeNsUrlSegment: () => (/* binding */ isSafeNsUrlSegment),
25340
- /* harmony export */ isSafeUrlSegment: () => (/* binding */ isSafeUrlSegment),
25341
- /* harmony export */ makePromise: () => (/* binding */ makePromise),
25342
- /* harmony export */ redactUrlCredentials: () => (/* binding */ redactUrlCredentials),
25343
- /* harmony export */ sanitizeLogValue: () => (/* binding */ sanitizeLogValue)
25344
- /* harmony export */ });
25345
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
25346
- 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; } }
25347
- 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; }
25348
- 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); }
25349
- var arr = [];
25350
- var each = arr.forEach;
25351
- var slice = arr.slice;
25352
- var UNSAFE_KEYS = ['__proto__', 'constructor', 'prototype'];
25353
- function defaults(obj) {
25354
- each.call(slice.call(arguments, 1), function (source) {
25355
- if (source) {
25356
- for (var _i = 0, _Object$keys = Object.keys(source); _i < _Object$keys.length; _i++) {
25357
- var prop = _Object$keys[_i];
25358
- if (UNSAFE_KEYS.indexOf(prop) > -1) continue;
25359
- if (obj[prop] === undefined) obj[prop] = source[prop];
25360
- }
25361
- }
25362
- });
25363
- return obj;
25364
- }
24938
+ //#region lib/utils.js
24939
+ const arr = [];
24940
+ arr.forEach;
24941
+ arr.slice;
24942
+ const UNSAFE_KEYS$1 = [
24943
+ "__proto__",
24944
+ "constructor",
24945
+ "prototype"
24946
+ ];
25365
24947
  function isSafeUrlSegmentBase(v) {
25366
- if (typeof v !== 'string') return false;
25367
- if (v.length === 0 || v.length > 128) return false;
25368
- if (UNSAFE_KEYS.indexOf(v) > -1) return false;
25369
- if (v.indexOf('..') > -1) return false;
25370
- if (v.indexOf('\\') > -1) return false;
25371
- if (/[?#%\s@]/.test(v)) return false;
25372
- if (/[\x00-\x1F\x7F]/.test(v)) return false;
25373
- return true;
24948
+ if (typeof v !== "string") return false;
24949
+ if (v.length === 0 || v.length > 128) return false;
24950
+ if (UNSAFE_KEYS$1.indexOf(v) > -1) return false;
24951
+ if (v.indexOf("..") > -1) return false;
24952
+ if (v.indexOf("\\") > -1) return false;
24953
+ if (/[?#%:&=;\s]/.test(v)) return false;
24954
+ if (/[\x00-\x1F\x7F]/.test(v)) return false;
24955
+ return true;
25374
24956
  }
25375
24957
  function isSafeLangUrlSegment(v) {
25376
- if (!isSafeUrlSegmentBase(v)) return false;
25377
- if (v.indexOf('/') > -1) return false;
25378
- return true;
24958
+ if (!isSafeUrlSegmentBase(v)) return false;
24959
+ if (v.indexOf("/") > -1 || v.indexOf("@") > -1) return false;
24960
+ return true;
25379
24961
  }
25380
24962
  function isSafeNsUrlSegment(v) {
25381
- return isSafeUrlSegmentBase(v);
24963
+ if (!isSafeUrlSegmentBase(v)) return false;
24964
+ if (v.indexOf("//") > -1) return false;
24965
+ return true;
25382
24966
  }
25383
- var isSafeUrlSegment = isSafeLangUrlSegment;
25384
- var SAFETY_CHECK_BY_KEY = {
25385
- lng: isSafeLangUrlSegment,
25386
- ns: isSafeNsUrlSegment
24967
+ const SAFETY_CHECK_BY_KEY = {
24968
+ lng: isSafeLangUrlSegment,
24969
+ ns: isSafeNsUrlSegment
25387
24970
  };
25388
24971
  function sanitizeLogValue(v) {
25389
- if (typeof v !== 'string') return v;
25390
- return v.replace(/[\r\n\x00-\x1F\x7F]/g, ' ');
24972
+ if (typeof v !== "string") return v;
24973
+ return v.replace(/[\r\n\x00-\x1F\x7F]/g, " ");
25391
24974
  }
25392
24975
  function redactUrlCredentials(u) {
25393
- if (typeof u !== 'string' || u.length === 0) return u;
25394
- try {
25395
- var parsed = new URL(u);
25396
- if (parsed.username || parsed.password) {
25397
- parsed.username = '';
25398
- parsed.password = '';
25399
- return parsed.toString();
25400
- }
25401
- return u;
25402
- } catch (e) {
25403
- return u.replace(/(\/\/)[^/@\s]+@/g, '$1');
25404
- }
24976
+ if (typeof u !== "string" || u.length === 0) return u;
24977
+ try {
24978
+ const parsed = new URL(u);
24979
+ if (parsed.username || parsed.password) {
24980
+ parsed.username = "";
24981
+ parsed.password = "";
24982
+ return parsed.toString();
24983
+ }
24984
+ return u;
24985
+ } catch (e) {
24986
+ return u.replace(/(\/\/)[^/@\s]+@/g, "$1");
24987
+ }
25405
24988
  }
25406
24989
  function hasXMLHttpRequest() {
25407
- return typeof XMLHttpRequest === 'function' || (typeof XMLHttpRequest === "undefined" ? "undefined" : _typeof(XMLHttpRequest)) === 'object';
24990
+ return typeof XMLHttpRequest === "function" || typeof XMLHttpRequest === "object";
25408
24991
  }
24992
+ /**
24993
+ * Determine whether the given `maybePromise` is a Promise.
24994
+ *
24995
+ * @param {*} maybePromise
24996
+ *
24997
+ * @returns {Boolean}
24998
+ */
25409
24999
  function isPromise(maybePromise) {
25410
- return !!maybePromise && typeof maybePromise.then === 'function';
25000
+ return !!maybePromise && typeof maybePromise.then === "function";
25411
25001
  }
25002
+ /**
25003
+ * Convert any value to a Promise than will resolve to this value.
25004
+ *
25005
+ * @param {*} maybePromise
25006
+ *
25007
+ * @returns {Promise}
25008
+ */
25412
25009
  function makePromise(maybePromise) {
25413
- if (isPromise(maybePromise)) {
25414
- return maybePromise;
25415
- }
25416
- return Promise.resolve(maybePromise);
25417
- }
25418
- var interpolationRegexp = /\{\{(.+?)\}\}/g;
25419
- function interpolate(str, data) {
25420
- return str.replace(interpolationRegexp, function (match, key) {
25421
- var k = key.trim();
25422
- if (UNSAFE_KEYS.indexOf(k) > -1) return match;
25423
- var value = data[k];
25424
- return value != null ? value : match;
25425
- });
25010
+ if (isPromise(maybePromise)) return maybePromise;
25011
+ return Promise.resolve(maybePromise);
25426
25012
  }
25013
+ const interpolationRegexp = /\{\{(.+?)\}\}/g;
25014
+ const LEADING_DOUBLE_SLASH = /^[/\\]{2}/;
25427
25015
  function interpolateUrl(str, data) {
25428
- var unsafe = false;
25429
- var result = str.replace(interpolationRegexp, function (match, key) {
25430
- var k = key.trim();
25431
- if (UNSAFE_KEYS.indexOf(k) > -1) return match;
25432
- var value = data[k];
25433
- if (value == null) return match;
25434
- var check = SAFETY_CHECK_BY_KEY[k] || isSafeLangUrlSegment;
25435
- var segments = String(value).split('+');
25436
- var _iterator = _createForOfIteratorHelper(segments),
25437
- _step;
25438
- try {
25439
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
25440
- var seg = _step.value;
25441
- if (!check(seg)) {
25442
- unsafe = true;
25443
- return match;
25444
- }
25445
- }
25446
- } catch (err) {
25447
- _iterator.e(err);
25448
- } finally {
25449
- _iterator.f();
25450
- }
25451
- return segments.join('+');
25452
- });
25453
- return unsafe ? null : result;
25016
+ let unsafe = false;
25017
+ const result = str.replace(interpolationRegexp, (match, key) => {
25018
+ const k = key.trim();
25019
+ if (UNSAFE_KEYS$1.indexOf(k) > -1) return match;
25020
+ const value = data[k];
25021
+ if (value == null) return match;
25022
+ const check = SAFETY_CHECK_BY_KEY[k] || isSafeLangUrlSegment;
25023
+ const segments = String(value).split("+");
25024
+ for (const seg of segments) if (!check(seg)) {
25025
+ unsafe = true;
25026
+ return match;
25027
+ }
25028
+ return segments.join("+");
25029
+ });
25030
+ if (unsafe) return null;
25031
+ if (LEADING_DOUBLE_SLASH.test(result) && !LEADING_DOUBLE_SLASH.test(str)) return null;
25032
+ return result;
25454
25033
  }
25034
+ //#endregion
25035
+ //#region lib/request.js
25036
+ const g = typeof globalThis !== "undefined" ? globalThis : typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : void 0;
25037
+ let fetchApi;
25038
+ if (typeof fetch === "function") fetchApi = fetch;
25039
+ else if (g && typeof g.fetch === "function") fetchApi = g.fetch;
25040
+ const XmlHttpRequestApi = hasXMLHttpRequest() && g ? g.XMLHttpRequest : void 0;
25041
+ const ActiveXObjectApi = typeof ActiveXObject === "function" && g ? g.ActiveXObject : void 0;
25042
+ const UNSAFE_KEYS = [
25043
+ "__proto__",
25044
+ "constructor",
25045
+ "prototype"
25046
+ ];
25047
+ const addQueryString = (url, params) => {
25048
+ if (params && typeof params === "object") {
25049
+ let queryString = "";
25050
+ for (const paramName of Object.keys(params)) {
25051
+ if (UNSAFE_KEYS.indexOf(paramName) > -1) continue;
25052
+ queryString += "&" + encodeURIComponent(paramName) + "=" + encodeURIComponent(params[paramName]);
25053
+ }
25054
+ if (!queryString) return url;
25055
+ url = url + (url.indexOf("?") !== -1 ? "&" : "?") + queryString.slice(1);
25056
+ }
25057
+ return url;
25058
+ };
25059
+ const fetchIt = (url, fetchOptions, callback, altFetch) => {
25060
+ const resolver = (response) => {
25061
+ if (!response.ok) return callback(response.statusText || "Error", { status: response.status });
25062
+ response.text().then((data) => {
25063
+ callback(null, {
25064
+ status: response.status,
25065
+ data
25066
+ });
25067
+ }).catch(callback);
25068
+ };
25069
+ if (altFetch) {
25070
+ const altResponse = altFetch(url, fetchOptions);
25071
+ if (altResponse instanceof Promise) {
25072
+ altResponse.then(resolver).catch(callback);
25073
+ return;
25074
+ }
25075
+ }
25076
+ if (typeof fetch === "function") fetch(url, fetchOptions).then(resolver).catch(callback);
25077
+ else fetchApi(url, fetchOptions).then(resolver).catch(callback);
25078
+ };
25079
+ const requestWithFetch = (options, url, payload, callback) => {
25080
+ if (options.queryStringParams) url = addQueryString(url, options.queryStringParams);
25081
+ const headers = { ...typeof options.customHeaders === "function" ? options.customHeaders() : options.customHeaders };
25082
+ if (typeof window === "undefined" && typeof __webpack_require__.g !== "undefined" && typeof __webpack_require__.g.process !== "undefined" && __webpack_require__.g.process.versions && __webpack_require__.g.process.versions.node) headers["User-Agent"] = `i18next-http-backend (node/${__webpack_require__.g.process.version}; ${__webpack_require__.g.process.platform} ${__webpack_require__.g.process.arch})`;
25083
+ if (payload) headers["Content-Type"] = "application/json";
25084
+ const reqOptions = typeof options.requestOptions === "function" ? options.requestOptions(payload) : options.requestOptions;
25085
+ const fetchOptions = {
25086
+ method: payload ? "POST" : "GET",
25087
+ body: payload ? options.stringify(payload) : void 0,
25088
+ headers,
25089
+ ...options._omitFetchOptions ? {} : reqOptions
25090
+ };
25091
+ const altFetch = typeof options.alternateFetch === "function" && options.alternateFetch.length >= 1 ? options.alternateFetch : void 0;
25092
+ try {
25093
+ fetchIt(url, fetchOptions, callback, altFetch);
25094
+ } catch (e) {
25095
+ if (!reqOptions || Object.keys(reqOptions).length === 0 || !e.message || e.message.indexOf("not implemented") < 0) return callback(e);
25096
+ try {
25097
+ Object.keys(reqOptions).forEach((opt) => {
25098
+ delete fetchOptions[opt];
25099
+ });
25100
+ fetchIt(url, fetchOptions, callback, altFetch);
25101
+ options._omitFetchOptions = true;
25102
+ } catch (err) {
25103
+ callback(err);
25104
+ }
25105
+ }
25106
+ };
25107
+ const requestWithXmlHttpRequest = (options, url, payload, callback) => {
25108
+ if (payload && typeof payload === "object") payload = addQueryString("", payload).slice(1);
25109
+ if (options.queryStringParams) url = addQueryString(url, options.queryStringParams);
25110
+ let completed = false;
25111
+ try {
25112
+ const x = XmlHttpRequestApi ? new XmlHttpRequestApi() : new ActiveXObjectApi("MSXML2.XMLHTTP.3.0");
25113
+ x.open(payload ? "POST" : "GET", url, 1);
25114
+ if (!options.crossDomain) x.setRequestHeader("X-Requested-With", "XMLHttpRequest");
25115
+ x.withCredentials = !!options.withCredentials;
25116
+ if (payload) x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
25117
+ if (x.overrideMimeType) x.overrideMimeType("application/json");
25118
+ let h = options.customHeaders;
25119
+ h = typeof h === "function" ? h() : h;
25120
+ if (h) for (const i of Object.keys(h)) {
25121
+ if (UNSAFE_KEYS.indexOf(i) > -1) continue;
25122
+ x.setRequestHeader(i, h[i]);
25123
+ }
25124
+ x.onreadystatechange = () => {
25125
+ if (x.readyState > 3) {
25126
+ completed = true;
25127
+ callback(x.status >= 400 ? x.statusText : null, {
25128
+ status: x.status,
25129
+ data: x.responseText
25130
+ });
25131
+ }
25132
+ };
25133
+ x.send(payload);
25134
+ } catch (e) {
25135
+ if (completed) throw e;
25136
+ callback(e);
25137
+ }
25138
+ };
25139
+ const request = (options, url, payload, callback) => {
25140
+ if (typeof payload === "function") {
25141
+ callback = payload;
25142
+ payload = void 0;
25143
+ }
25144
+ callback = callback || (() => {});
25145
+ if (fetchApi && url.indexOf("file:") !== 0) return requestWithFetch(options, url, payload, callback);
25146
+ if (hasXMLHttpRequest() || typeof ActiveXObject === "function") return requestWithXmlHttpRequest(options, url, payload, callback);
25147
+ callback(/* @__PURE__ */ new Error("No fetch and no xhr implementation found!"));
25148
+ };
25149
+ //#endregion
25150
+ //#region lib/index.js
25151
+ const getDefaults = () => {
25152
+ return {
25153
+ loadPath: "/locales/{{lng}}/{{ns}}.json",
25154
+ addPath: "/locales/add/{{lng}}/{{ns}}",
25155
+ parse: (data) => JSON.parse(data),
25156
+ stringify: JSON.stringify,
25157
+ parsePayload: (namespace, key, fallbackValue) => ({ [key]: fallbackValue || "" }),
25158
+ parseLoadPayload: (languages, namespaces) => void 0,
25159
+ request,
25160
+ reloadInterval: typeof window !== "undefined" ? false : 3600 * 1e3,
25161
+ customHeaders: {},
25162
+ queryStringParams: {},
25163
+ crossDomain: false,
25164
+ withCredentials: false,
25165
+ overrideMimeType: false,
25166
+ requestOptions: {
25167
+ mode: "cors",
25168
+ credentials: "same-origin",
25169
+ cache: "default"
25170
+ }
25171
+ };
25172
+ };
25173
+ var Backend = class {
25174
+ constructor(services, options = {}, allOptions = {}) {
25175
+ this.services = services;
25176
+ this.options = options;
25177
+ this.allOptions = allOptions;
25178
+ this.type = "backend";
25179
+ this.init(services, options, allOptions);
25180
+ }
25181
+ init(services, options = {}, allOptions = {}) {
25182
+ this.services = services;
25183
+ this.options = {
25184
+ ...getDefaults(),
25185
+ ...this.options || {},
25186
+ ...options
25187
+ };
25188
+ this.allOptions = allOptions;
25189
+ if (this.services && this.options.reloadInterval) {
25190
+ const timer = setInterval(() => this.reload(), this.options.reloadInterval);
25191
+ if (typeof timer === "object" && typeof timer.unref === "function") timer.unref();
25192
+ }
25193
+ }
25194
+ readMulti(languages, namespaces, callback) {
25195
+ this._readAny(languages, languages, namespaces, namespaces, callback);
25196
+ }
25197
+ read(language, namespace, callback) {
25198
+ this._readAny([language], language, [namespace], namespace, callback);
25199
+ }
25200
+ _readAny(languages, loadUrlLanguages, namespaces, loadUrlNamespaces, callback) {
25201
+ let loadPath = this.options.loadPath;
25202
+ if (typeof this.options.loadPath === "function") loadPath = this.options.loadPath(languages, namespaces);
25203
+ loadPath = makePromise(loadPath);
25204
+ loadPath.then((resolvedLoadPath) => {
25205
+ if (!resolvedLoadPath) return callback(null, {});
25206
+ const url = interpolateUrl(resolvedLoadPath, {
25207
+ lng: languages.join("+"),
25208
+ ns: namespaces.join("+")
25209
+ });
25210
+ if (url == null) {
25211
+ const safeLngs = languages.map(sanitizeLogValue).join(", ");
25212
+ const safeNss = namespaces.map(sanitizeLogValue).join(", ");
25213
+ return callback(/* @__PURE__ */ new Error("i18next-http-backend: unsafe lng/ns value — refusing to build request URL for languages=[" + safeLngs + "] namespaces=[" + safeNss + "]"), false);
25214
+ }
25215
+ this.loadUrl(url, callback, loadUrlLanguages, loadUrlNamespaces);
25216
+ }, (err) => callback(err, false));
25217
+ }
25218
+ loadUrl(url, callback, languages, namespaces) {
25219
+ const lng = typeof languages === "string" ? [languages] : languages;
25220
+ const ns = typeof namespaces === "string" ? [namespaces] : namespaces;
25221
+ const payload = this.options.parseLoadPayload(lng, ns);
25222
+ const safeUrl = sanitizeLogValue(redactUrlCredentials(url));
25223
+ this.options.request(this.options, url, payload, (err, res) => {
25224
+ if (res && (res.status >= 500 && res.status < 600 || !res.status)) return callback("failed loading " + safeUrl + "; status code: " + res.status, true);
25225
+ if (res && res.status >= 400 && res.status < 500) return callback("failed loading " + safeUrl + "; status code: " + res.status, false);
25226
+ if (!res && err && err.message) {
25227
+ const errorMessage = err.message.toLowerCase();
25228
+ if ([
25229
+ "failed",
25230
+ "fetch",
25231
+ "network",
25232
+ "load"
25233
+ ].find((term) => errorMessage.indexOf(term) > -1)) return callback("failed loading " + safeUrl + ": " + sanitizeLogValue(err.message), true);
25234
+ }
25235
+ if (err) return callback(err, false);
25236
+ let ret, parseErr;
25237
+ try {
25238
+ if (typeof res.data === "string") ret = this.options.parse(res.data, languages, namespaces);
25239
+ else ret = res.data;
25240
+ } catch (e) {
25241
+ parseErr = "failed parsing " + safeUrl + " to json";
25242
+ }
25243
+ if (parseErr) return callback(parseErr, false);
25244
+ callback(null, ret);
25245
+ });
25246
+ }
25247
+ create(languages, namespace, key, fallbackValue, callback) {
25248
+ if (!this.options.addPath) return;
25249
+ if (typeof languages === "string") languages = [languages];
25250
+ const payload = this.options.parsePayload(namespace, key, fallbackValue);
25251
+ let finished = 0;
25252
+ const dataArray = [];
25253
+ const resArray = [];
25254
+ languages.forEach((lng) => {
25255
+ let addPath = this.options.addPath;
25256
+ if (typeof this.options.addPath === "function") addPath = this.options.addPath(lng, namespace);
25257
+ const url = interpolateUrl(addPath, {
25258
+ lng,
25259
+ ns: namespace
25260
+ });
25261
+ if (url == null) {
25262
+ finished += 1;
25263
+ if (callback && finished === languages.length) callback(dataArray, resArray);
25264
+ return;
25265
+ }
25266
+ this.options.request(this.options, url, payload, (data, res) => {
25267
+ finished += 1;
25268
+ dataArray.push(data);
25269
+ resArray.push(res);
25270
+ if (finished === languages.length) {
25271
+ if (typeof callback === "function") callback(dataArray, resArray);
25272
+ }
25273
+ });
25274
+ });
25275
+ }
25276
+ reload() {
25277
+ const { backendConnector, languageUtils, logger } = this.services;
25278
+ const currentLanguage = backendConnector.language;
25279
+ if (currentLanguage && currentLanguage.toLowerCase() === "cimode") return;
25280
+ const toLoad = [];
25281
+ const append = (lng) => {
25282
+ languageUtils.toResolveHierarchy(lng).forEach((l) => {
25283
+ if (toLoad.indexOf(l) < 0) toLoad.push(l);
25284
+ });
25285
+ };
25286
+ append(currentLanguage);
25287
+ if (this.allOptions.preload) this.allOptions.preload.forEach((l) => append(l));
25288
+ toLoad.forEach((lng) => {
25289
+ this.allOptions.ns.forEach((ns) => {
25290
+ backendConnector.read(lng, ns, "read", null, null, (err, data) => {
25291
+ if (err) logger.warn(`loading namespace ${ns} for language ${lng} failed`, err);
25292
+ if (!err && data) logger.log(`loaded namespace ${ns} for language ${lng}`, data);
25293
+ backendConnector.loaded(`${lng}|${ns}`, err, data);
25294
+ });
25295
+ });
25296
+ });
25297
+ }
25298
+ };
25299
+ Backend.type = "backend";
25300
+ //#endregion
25301
+
25302
+
25455
25303
 
25456
25304
  /***/ }
25457
25305
 
@@ -25487,40 +25335,7 @@ function interpolateUrl(str, data) {
25487
25335
  /******/ return module.exports;
25488
25336
  /******/ }
25489
25337
  /******/
25490
- /******/ // expose the modules object (__webpack_modules__)
25491
- /******/ __webpack_require__.m = __webpack_modules__;
25492
- /******/
25493
25338
  /************************************************************************/
25494
- /******/ /* webpack/runtime/create fake namespace object */
25495
- /******/ (() => {
25496
- /******/ const getProto = Object.getPrototypeOf;
25497
- /******/ let leafPrototypes;
25498
- /******/ // create a fake namespace object
25499
- /******/ // mode & 1: value is a module id, require it
25500
- /******/ // mode & 2: merge all properties of value into the ns
25501
- /******/ // mode & 4: return value when already ns object
25502
- /******/ // mode & 16: return value when it's Promise-like
25503
- /******/ // mode & 8|1: behave like require
25504
- /******/ __webpack_require__.t = function(value, mode) {
25505
- /******/ if(mode & 1) value = this(value);
25506
- /******/ if(mode & 8) return value;
25507
- /******/ if(typeof value === 'object' && value) {
25508
- /******/ if((mode & 4) && value.__esModule) return value;
25509
- /******/ if((mode & 16) && typeof value.then === 'function') return value;
25510
- /******/ }
25511
- /******/ const ns = Object.create(null);
25512
- /******/ __webpack_require__.r(ns);
25513
- /******/ const def = {};
25514
- /******/ leafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)];
25515
- /******/ for(var current = mode & 2 && value; (typeof current == 'object' || typeof current == 'function') && !~leafPrototypes.indexOf(current); current = getProto(current)) {
25516
- /******/ Object.getOwnPropertyNames(current).forEach((key) => (def[key] = () => (value[key])));
25517
- /******/ }
25518
- /******/ def['default'] = () => (value);
25519
- /******/ __webpack_require__.d(ns, def);
25520
- /******/ return ns;
25521
- /******/ };
25522
- /******/ })();
25523
- /******/
25524
25339
  /******/ /* webpack/runtime/define property getters */
25525
25340
  /******/ // define getter/value functions for harmony exports
25526
25341
  /******/ __webpack_require__.d = (exports, definition) => {
@@ -25531,20 +25346,6 @@ function interpolateUrl(str, data) {
25531
25346
  /******/ }
25532
25347
  /******/ };
25533
25348
  /******/
25534
- /******/ /* webpack/runtime/ensure chunk */
25535
- /******/ __webpack_require__.f = {};
25536
- /******/ // This file contains only the entry chunk.
25537
- /******/ // The chunk loading function for additional chunks
25538
- /******/ __webpack_require__.e = (chunkId) => {
25539
- /******/ const promises = [];
25540
- /******/ __webpack_require__.f.j(chunkId, promises);
25541
- /******/ return Promise.all(promises);
25542
- /******/ };
25543
- /******/
25544
- /******/ /* webpack/runtime/get javascript chunk filename */
25545
- /******/ // This function allow to reference async chunks
25546
- /******/ __webpack_require__.u = (chunkId) => (chunkId + ".bundled-tests.instrumented.js");
25547
- /******/
25548
25349
  /******/ /* webpack/runtime/global */
25549
25350
  /******/ __webpack_require__.g = (function() {
25550
25351
  /******/ if (typeof globalThis === 'object') return globalThis;
@@ -25558,51 +25359,6 @@ function interpolateUrl(str, data) {
25558
25359
  /******/ /* webpack/runtime/hasOwnProperty shorthand */
25559
25360
  /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop));
25560
25361
  /******/
25561
- /******/ /* webpack/runtime/load script */
25562
- /******/ (() => {
25563
- /******/ const inProgress = {};
25564
- /******/ const dataWebpackPrefix = "@itwin/core-i18n:";
25565
- /******/ // loadScript function to load a script via script tag
25566
- /******/ __webpack_require__.l = (url, done, key, chunkId) => {
25567
- /******/ if(inProgress[url]) { inProgress[url].push(done); return; }
25568
- /******/ let script, needAttach;
25569
- /******/ if(key !== undefined) {
25570
- /******/ const scripts = document.getElementsByTagName("script");
25571
- /******/ for(var i = 0; i < scripts.length; i++) {
25572
- /******/ const s = scripts[i];
25573
- /******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; }
25574
- /******/ }
25575
- /******/ }
25576
- /******/ if(!script) {
25577
- /******/ needAttach = true;
25578
- /******/ script = document.createElement('script');
25579
- /******/
25580
- /******/ script.charset = 'utf-8';
25581
- /******/ if (__webpack_require__.nc) {
25582
- /******/ script.setAttribute("nonce", __webpack_require__.nc);
25583
- /******/ }
25584
- /******/ script.setAttribute("data-webpack", dataWebpackPrefix + key);
25585
- /******/
25586
- /******/ script.src = url;
25587
- /******/ }
25588
- /******/ inProgress[url] = [done];
25589
- /******/ const onScriptComplete = (prev, event) => {
25590
- /******/ // avoid mem leaks in IE.
25591
- /******/ script.onerror = script.onload = null;
25592
- /******/ clearTimeout(timeout);
25593
- /******/ const doneFns = inProgress[url];
25594
- /******/ delete inProgress[url];
25595
- /******/ script.parentNode?.removeChild(script);
25596
- /******/ doneFns?.forEach((fn) => (fn(event)));
25597
- /******/ if(prev) return prev(event);
25598
- /******/ }
25599
- /******/ const timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
25600
- /******/ script.onerror = onScriptComplete.bind(null, script.onerror);
25601
- /******/ script.onload = onScriptComplete.bind(null, script.onload);
25602
- /******/ needAttach && document.head.appendChild(script);
25603
- /******/ };
25604
- /******/ })();
25605
- /******/
25606
25362
  /******/ /* webpack/runtime/make namespace object */
25607
25363
  /******/ // define __esModule on exports
25608
25364
  /******/ __webpack_require__.r = (exports) => {
@@ -25610,118 +25366,6 @@ function interpolateUrl(str, data) {
25610
25366
  /******/ Object.defineProperty(exports, '__esModule', { value: true });
25611
25367
  /******/ };
25612
25368
  /******/
25613
- /******/ /* webpack/runtime/publicPath */
25614
- /******/ (() => {
25615
- /******/ let scriptUrl;
25616
- /******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
25617
- /******/ const document = __webpack_require__.g.document;
25618
- /******/ if (!scriptUrl && document) {
25619
- /******/ if (document.currentScript?.tagName.toUpperCase() === 'SCRIPT')
25620
- /******/ scriptUrl = document.currentScript.src;
25621
- /******/ if (!scriptUrl) {
25622
- /******/ const scripts = document.getElementsByTagName("script");
25623
- /******/ if(scripts.length) {
25624
- /******/ let i = scripts.length - 1;
25625
- /******/ while (i > -1 && (!scriptUrl || !/^https?:/.test(scriptUrl))) scriptUrl = scripts[i--].src;
25626
- /******/ }
25627
- /******/ }
25628
- /******/ }
25629
- /******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
25630
- /******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
25631
- /******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
25632
- /******/ scriptUrl = scriptUrl.replace(/^blob:|[?#].*$/g, "").replace(/\/[^/]+$/, "/");
25633
- /******/ __webpack_require__.p = scriptUrl;
25634
- /******/ })();
25635
- /******/
25636
- /******/ /* webpack/runtime/jsonp chunk loading */
25637
- /******/ (() => {
25638
- /******/ // no baseURI
25639
- /******/
25640
- /******/ // object to store loaded and loading chunks
25641
- /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
25642
- /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
25643
- /******/ const installedChunks = {
25644
- /******/ "main": 0
25645
- /******/ };
25646
- /******/
25647
- /******/ __webpack_require__.f.j = (chunkId, promises) => {
25648
- /******/ // JSONP chunk loading for javascript
25649
- /******/ let installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;
25650
- /******/ if(installedChunkData !== 0) { // 0 means "already installed".
25651
- /******/
25652
- /******/ // a Promise means "currently loading".
25653
- /******/ if(installedChunkData) {
25654
- /******/ promises.push(installedChunkData[2]);
25655
- /******/ } else {
25656
- /******/ if(true) { // all chunks have JS
25657
- /******/ // setup Promise in chunk cache
25658
- /******/ const promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));
25659
- /******/ promises.push(installedChunkData[2] = promise);
25660
- /******/
25661
- /******/ // create error before stack unwound to get useful stacktrace later
25662
- /******/ const error = new Error();
25663
- /******/ const loadingEnded = (event) => {
25664
- /******/ if(__webpack_require__.o(installedChunks, chunkId)) {
25665
- /******/ installedChunkData = installedChunks[chunkId];
25666
- /******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
25667
- /******/ if(installedChunkData) {
25668
- /******/ const errorType = event && (event.type === 'load' ? 'missing' : event.type);
25669
- /******/ const realSrc = event && event.target && event.target.src;
25670
- /******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
25671
- /******/ error.name = 'ChunkLoadError';
25672
- /******/ error.type = errorType;
25673
- /******/ error.request = realSrc;
25674
- /******/ error.event = event;
25675
- /******/ installedChunkData[1](error);
25676
- /******/ }
25677
- /******/ }
25678
- /******/ };
25679
- /******/ __webpack_require__.l(__webpack_require__.p + __webpack_require__.u(chunkId), loadingEnded, "chunk-" + chunkId, chunkId);
25680
- /******/ }
25681
- /******/ }
25682
- /******/ }
25683
- /******/ };
25684
- /******/
25685
- /******/ // no prefetching
25686
- /******/
25687
- /******/ // no preloaded
25688
- /******/
25689
- /******/ // no HMR
25690
- /******/
25691
- /******/ // no HMR manifest
25692
- /******/
25693
- /******/ // no on chunks loaded
25694
- /******/
25695
- /******/ // install a JSONP callback for chunk loading
25696
- /******/ const webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
25697
- /******/ let [chunkIds, moreModules, runtime] = data;
25698
- /******/ // add "moreModules" to the modules object,
25699
- /******/ // then flag all "chunkIds" as loaded and fire callback
25700
- /******/ var moduleId, chunkId, i = 0;
25701
- /******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
25702
- /******/ for(moduleId in moreModules) {
25703
- /******/ if(__webpack_require__.o(moreModules, moduleId)) {
25704
- /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
25705
- /******/ }
25706
- /******/ }
25707
- /******/ if(runtime) var result = runtime(__webpack_require__);
25708
- /******/ }
25709
- /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
25710
- /******/ for(;i < chunkIds.length; i++) {
25711
- /******/ chunkId = chunkIds[i];
25712
- /******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
25713
- /******/ installedChunks[chunkId][0]();
25714
- /******/ }
25715
- /******/ installedChunks[chunkId] = 0;
25716
- /******/ }
25717
- /******/
25718
- /******/ }
25719
- /******/
25720
- /******/ const chunkLoadingGlobal = self["webpackChunk_itwin_core_i18n"] = self["webpackChunk_itwin_core_i18n"] || [];
25721
- /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
25722
- /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
25723
- /******/ })();
25724
- /******/
25725
25369
  /************************************************************************/
25726
25370
  let __webpack_exports__ = {};
25727
25371
  // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.