andoncloud-widget-preview 1.1.8 → 1.2.0
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/dist/index.css +1 -72
- package/dist/index.css.map +1 -1
- package/dist/index.js +1 -4152
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +3 -1
- package/dist/version.d.ts +1 -1
- package/package.json +18 -12
package/dist/index.js
CHANGED
|
@@ -1,4153 +1,2 @@
|
|
|
1
|
-
var React = require('react');
|
|
2
|
-
var andoncloudSdk = require('andoncloud-sdk');
|
|
3
|
-
var reactRouterDom = require('react-router-dom');
|
|
4
|
-
require('react-grid-layout/css/styles.css');
|
|
5
|
-
var RGL = require('react-grid-layout');
|
|
6
|
-
var andoncloudDashboardToolkit = require('andoncloud-dashboard-toolkit');
|
|
7
|
-
|
|
8
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
-
|
|
10
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
11
|
-
var RGL__default = /*#__PURE__*/_interopDefaultLegacy(RGL);
|
|
12
|
-
|
|
13
|
-
function _typeof(obj) {
|
|
14
|
-
"@babel/helpers - typeof";
|
|
15
|
-
|
|
16
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
17
|
-
return typeof obj;
|
|
18
|
-
} : function (obj) {
|
|
19
|
-
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
20
|
-
}, _typeof(obj);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function _toPrimitive(input, hint) {
|
|
24
|
-
if (_typeof(input) !== "object" || input === null) return input;
|
|
25
|
-
var prim = input[Symbol.toPrimitive];
|
|
26
|
-
if (prim !== undefined) {
|
|
27
|
-
var res = prim.call(input, hint || "default");
|
|
28
|
-
if (_typeof(res) !== "object") return res;
|
|
29
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
30
|
-
}
|
|
31
|
-
return (hint === "string" ? String : Number)(input);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function _toPropertyKey(arg) {
|
|
35
|
-
var key = _toPrimitive(arg, "string");
|
|
36
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function _defineProperty(obj, key, value) {
|
|
40
|
-
key = _toPropertyKey(key);
|
|
41
|
-
if (key in obj) {
|
|
42
|
-
Object.defineProperty(obj, key, {
|
|
43
|
-
value: value,
|
|
44
|
-
enumerable: true,
|
|
45
|
-
configurable: true,
|
|
46
|
-
writable: true
|
|
47
|
-
});
|
|
48
|
-
} else {
|
|
49
|
-
obj[key] = value;
|
|
50
|
-
}
|
|
51
|
-
return obj;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
|
|
55
|
-
var htmlEntities = {
|
|
56
|
-
'&': '&',
|
|
57
|
-
'&': '&',
|
|
58
|
-
'<': '<',
|
|
59
|
-
'<': '<',
|
|
60
|
-
'>': '>',
|
|
61
|
-
'>': '>',
|
|
62
|
-
''': "'",
|
|
63
|
-
''': "'",
|
|
64
|
-
'"': '"',
|
|
65
|
-
'"': '"',
|
|
66
|
-
' ': ' ',
|
|
67
|
-
' ': ' ',
|
|
68
|
-
'©': '©',
|
|
69
|
-
'©': '©',
|
|
70
|
-
'®': '®',
|
|
71
|
-
'®': '®',
|
|
72
|
-
'…': '…',
|
|
73
|
-
'…': '…',
|
|
74
|
-
'/': '/',
|
|
75
|
-
'/': '/'
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
var unescapeHtmlEntity = function unescapeHtmlEntity(m) {
|
|
79
|
-
return htmlEntities[m];
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
var unescape$1 = function unescape(text) {
|
|
83
|
-
return text.replace(matchHtmlEntity, unescapeHtmlEntity);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
87
|
-
|
|
88
|
-
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$7(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
89
|
-
var defaultOptions = {
|
|
90
|
-
bindI18n: 'languageChanged',
|
|
91
|
-
bindI18nStore: '',
|
|
92
|
-
transEmptyNodeValue: '',
|
|
93
|
-
transSupportBasicHtmlNodes: true,
|
|
94
|
-
transWrapTextNodes: '',
|
|
95
|
-
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
|
|
96
|
-
useSuspense: true,
|
|
97
|
-
unescape: unescape$1
|
|
98
|
-
};
|
|
99
|
-
function setDefaults() {
|
|
100
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
101
|
-
defaultOptions = _objectSpread$7(_objectSpread$7({}, defaultOptions), options);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function _classCallCheck(instance, Constructor) {
|
|
105
|
-
if (!(instance instanceof Constructor)) {
|
|
106
|
-
throw new TypeError("Cannot call a class as a function");
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function _defineProperties(target, props) {
|
|
111
|
-
for (var i = 0; i < props.length; i++) {
|
|
112
|
-
var descriptor = props[i];
|
|
113
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
114
|
-
descriptor.configurable = true;
|
|
115
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
116
|
-
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
120
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
121
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
122
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
123
|
-
writable: false
|
|
124
|
-
});
|
|
125
|
-
return Constructor;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
var initReactI18next = {
|
|
129
|
-
type: '3rdParty',
|
|
130
|
-
init: function init(instance) {
|
|
131
|
-
setDefaults(instance.options.react);
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
React.createContext();
|
|
136
|
-
(function () {
|
|
137
|
-
function ReportNamespaces() {
|
|
138
|
-
_classCallCheck(this, ReportNamespaces);
|
|
139
|
-
|
|
140
|
-
this.usedNamespaces = {};
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
_createClass(ReportNamespaces, [{
|
|
144
|
-
key: "addUsedNamespaces",
|
|
145
|
-
value: function addUsedNamespaces(namespaces) {
|
|
146
|
-
var _this = this;
|
|
147
|
-
|
|
148
|
-
namespaces.forEach(function (ns) {
|
|
149
|
-
if (!_this.usedNamespaces[ns]) _this.usedNamespaces[ns] = true;
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
}, {
|
|
153
|
-
key: "getUsedNamespaces",
|
|
154
|
-
value: function getUsedNamespaces() {
|
|
155
|
-
return Object.keys(this.usedNamespaces);
|
|
156
|
-
}
|
|
157
|
-
}]);
|
|
158
|
-
|
|
159
|
-
return ReportNamespaces;
|
|
160
|
-
})();
|
|
161
|
-
|
|
162
|
-
function _arrayWithHoles(arr) {
|
|
163
|
-
if (Array.isArray(arr)) return arr;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function _arrayLikeToArray(arr, len) {
|
|
167
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
168
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
169
|
-
return arr2;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
173
|
-
if (!o) return;
|
|
174
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
175
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
176
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
177
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
178
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function _nonIterableRest() {
|
|
182
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function _assertThisInitialized(self) {
|
|
186
|
-
if (self === void 0) {
|
|
187
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
188
|
-
}
|
|
189
|
-
return self;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function _setPrototypeOf(o, p) {
|
|
193
|
-
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
194
|
-
o.__proto__ = p;
|
|
195
|
-
return o;
|
|
196
|
-
};
|
|
197
|
-
return _setPrototypeOf(o, p);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function _inherits(subClass, superClass) {
|
|
201
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
202
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
203
|
-
}
|
|
204
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
205
|
-
constructor: {
|
|
206
|
-
value: subClass,
|
|
207
|
-
writable: true,
|
|
208
|
-
configurable: true
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
Object.defineProperty(subClass, "prototype", {
|
|
212
|
-
writable: false
|
|
213
|
-
});
|
|
214
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function _possibleConstructorReturn(self, call) {
|
|
218
|
-
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
219
|
-
return call;
|
|
220
|
-
} else if (call !== void 0) {
|
|
221
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
222
|
-
}
|
|
223
|
-
return _assertThisInitialized(self);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
function _getPrototypeOf(o) {
|
|
227
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
228
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
229
|
-
};
|
|
230
|
-
return _getPrototypeOf(o);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
function _iterableToArray(iter) {
|
|
234
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
function _toArray(arr) {
|
|
238
|
-
return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
242
|
-
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
243
|
-
var consoleLogger = {
|
|
244
|
-
type: 'logger',
|
|
245
|
-
log: function log(args) {
|
|
246
|
-
this.output('log', args);
|
|
247
|
-
},
|
|
248
|
-
warn: function warn(args) {
|
|
249
|
-
this.output('warn', args);
|
|
250
|
-
},
|
|
251
|
-
error: function error(args) {
|
|
252
|
-
this.output('error', args);
|
|
253
|
-
},
|
|
254
|
-
output: function output(type, args) {
|
|
255
|
-
if (console && console[type]) console[type].apply(console, args);
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
var Logger = function () {
|
|
259
|
-
function Logger(concreteLogger) {
|
|
260
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
261
|
-
_classCallCheck(this, Logger);
|
|
262
|
-
this.init(concreteLogger, options);
|
|
263
|
-
}
|
|
264
|
-
_createClass(Logger, [{
|
|
265
|
-
key: "init",
|
|
266
|
-
value: function init(concreteLogger) {
|
|
267
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
268
|
-
this.prefix = options.prefix || 'i18next:';
|
|
269
|
-
this.logger = concreteLogger || consoleLogger;
|
|
270
|
-
this.options = options;
|
|
271
|
-
this.debug = options.debug;
|
|
272
|
-
}
|
|
273
|
-
}, {
|
|
274
|
-
key: "setDebug",
|
|
275
|
-
value: function setDebug(bool) {
|
|
276
|
-
this.debug = bool;
|
|
277
|
-
}
|
|
278
|
-
}, {
|
|
279
|
-
key: "log",
|
|
280
|
-
value: function log() {
|
|
281
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
282
|
-
args[_key] = arguments[_key];
|
|
283
|
-
}
|
|
284
|
-
return this.forward(args, 'log', '', true);
|
|
285
|
-
}
|
|
286
|
-
}, {
|
|
287
|
-
key: "warn",
|
|
288
|
-
value: function warn() {
|
|
289
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
290
|
-
args[_key2] = arguments[_key2];
|
|
291
|
-
}
|
|
292
|
-
return this.forward(args, 'warn', '', true);
|
|
293
|
-
}
|
|
294
|
-
}, {
|
|
295
|
-
key: "error",
|
|
296
|
-
value: function error() {
|
|
297
|
-
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
298
|
-
args[_key3] = arguments[_key3];
|
|
299
|
-
}
|
|
300
|
-
return this.forward(args, 'error', '');
|
|
301
|
-
}
|
|
302
|
-
}, {
|
|
303
|
-
key: "deprecate",
|
|
304
|
-
value: function deprecate() {
|
|
305
|
-
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
306
|
-
args[_key4] = arguments[_key4];
|
|
307
|
-
}
|
|
308
|
-
return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
|
|
309
|
-
}
|
|
310
|
-
}, {
|
|
311
|
-
key: "forward",
|
|
312
|
-
value: function forward(args, lvl, prefix, debugOnly) {
|
|
313
|
-
if (debugOnly && !this.debug) return null;
|
|
314
|
-
if (typeof args[0] === 'string') args[0] = "".concat(prefix).concat(this.prefix, " ").concat(args[0]);
|
|
315
|
-
return this.logger[lvl](args);
|
|
316
|
-
}
|
|
317
|
-
}, {
|
|
318
|
-
key: "create",
|
|
319
|
-
value: function create(moduleName) {
|
|
320
|
-
return new Logger(this.logger, _objectSpread$6(_objectSpread$6({}, {
|
|
321
|
-
prefix: "".concat(this.prefix, ":").concat(moduleName, ":")
|
|
322
|
-
}), this.options));
|
|
323
|
-
}
|
|
324
|
-
}, {
|
|
325
|
-
key: "clone",
|
|
326
|
-
value: function clone(options) {
|
|
327
|
-
options = options || this.options;
|
|
328
|
-
options.prefix = options.prefix || this.prefix;
|
|
329
|
-
return new Logger(this.logger, options);
|
|
330
|
-
}
|
|
331
|
-
}]);
|
|
332
|
-
return Logger;
|
|
333
|
-
}();
|
|
334
|
-
var baseLogger = new Logger();
|
|
335
|
-
|
|
336
|
-
var EventEmitter = function () {
|
|
337
|
-
function EventEmitter() {
|
|
338
|
-
_classCallCheck(this, EventEmitter);
|
|
339
|
-
this.observers = {};
|
|
340
|
-
}
|
|
341
|
-
_createClass(EventEmitter, [{
|
|
342
|
-
key: "on",
|
|
343
|
-
value: function on(events, listener) {
|
|
344
|
-
var _this = this;
|
|
345
|
-
events.split(' ').forEach(function (event) {
|
|
346
|
-
_this.observers[event] = _this.observers[event] || [];
|
|
347
|
-
_this.observers[event].push(listener);
|
|
348
|
-
});
|
|
349
|
-
return this;
|
|
350
|
-
}
|
|
351
|
-
}, {
|
|
352
|
-
key: "off",
|
|
353
|
-
value: function off(event, listener) {
|
|
354
|
-
if (!this.observers[event]) return;
|
|
355
|
-
if (!listener) {
|
|
356
|
-
delete this.observers[event];
|
|
357
|
-
return;
|
|
358
|
-
}
|
|
359
|
-
this.observers[event] = this.observers[event].filter(function (l) {
|
|
360
|
-
return l !== listener;
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
}, {
|
|
364
|
-
key: "emit",
|
|
365
|
-
value: function emit(event) {
|
|
366
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
367
|
-
args[_key - 1] = arguments[_key];
|
|
368
|
-
}
|
|
369
|
-
if (this.observers[event]) {
|
|
370
|
-
var cloned = [].concat(this.observers[event]);
|
|
371
|
-
cloned.forEach(function (observer) {
|
|
372
|
-
observer.apply(void 0, args);
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
if (this.observers['*']) {
|
|
376
|
-
var _cloned = [].concat(this.observers['*']);
|
|
377
|
-
_cloned.forEach(function (observer) {
|
|
378
|
-
observer.apply(observer, [event].concat(args));
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
}]);
|
|
383
|
-
return EventEmitter;
|
|
384
|
-
}();
|
|
385
|
-
|
|
386
|
-
function defer() {
|
|
387
|
-
var res;
|
|
388
|
-
var rej;
|
|
389
|
-
var promise = new Promise(function (resolve, reject) {
|
|
390
|
-
res = resolve;
|
|
391
|
-
rej = reject;
|
|
392
|
-
});
|
|
393
|
-
promise.resolve = res;
|
|
394
|
-
promise.reject = rej;
|
|
395
|
-
return promise;
|
|
396
|
-
}
|
|
397
|
-
function makeString(object) {
|
|
398
|
-
if (object == null) return '';
|
|
399
|
-
return '' + object;
|
|
400
|
-
}
|
|
401
|
-
function copy(a, s, t) {
|
|
402
|
-
a.forEach(function (m) {
|
|
403
|
-
if (s[m]) t[m] = s[m];
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
function getLastOfPath(object, path, Empty) {
|
|
407
|
-
function cleanKey(key) {
|
|
408
|
-
return key && key.indexOf('###') > -1 ? key.replace(/###/g, '.') : key;
|
|
409
|
-
}
|
|
410
|
-
function canNotTraverseDeeper() {
|
|
411
|
-
return !object || typeof object === 'string';
|
|
412
|
-
}
|
|
413
|
-
var stack = typeof path !== 'string' ? [].concat(path) : path.split('.');
|
|
414
|
-
while (stack.length > 1) {
|
|
415
|
-
if (canNotTraverseDeeper()) return {};
|
|
416
|
-
var key = cleanKey(stack.shift());
|
|
417
|
-
if (!object[key] && Empty) object[key] = new Empty();
|
|
418
|
-
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
419
|
-
object = object[key];
|
|
420
|
-
} else {
|
|
421
|
-
object = {};
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
if (canNotTraverseDeeper()) return {};
|
|
425
|
-
return {
|
|
426
|
-
obj: object,
|
|
427
|
-
k: cleanKey(stack.shift())
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
function setPath(object, path, newValue) {
|
|
431
|
-
var _getLastOfPath = getLastOfPath(object, path, Object),
|
|
432
|
-
obj = _getLastOfPath.obj,
|
|
433
|
-
k = _getLastOfPath.k;
|
|
434
|
-
obj[k] = newValue;
|
|
435
|
-
}
|
|
436
|
-
function pushPath(object, path, newValue, concat) {
|
|
437
|
-
var _getLastOfPath2 = getLastOfPath(object, path, Object),
|
|
438
|
-
obj = _getLastOfPath2.obj,
|
|
439
|
-
k = _getLastOfPath2.k;
|
|
440
|
-
obj[k] = obj[k] || [];
|
|
441
|
-
if (concat) obj[k] = obj[k].concat(newValue);
|
|
442
|
-
if (!concat) obj[k].push(newValue);
|
|
443
|
-
}
|
|
444
|
-
function getPath(object, path) {
|
|
445
|
-
var _getLastOfPath3 = getLastOfPath(object, path),
|
|
446
|
-
obj = _getLastOfPath3.obj,
|
|
447
|
-
k = _getLastOfPath3.k;
|
|
448
|
-
if (!obj) return undefined;
|
|
449
|
-
return obj[k];
|
|
450
|
-
}
|
|
451
|
-
function getPathWithDefaults(data, defaultData, key) {
|
|
452
|
-
var value = getPath(data, key);
|
|
453
|
-
if (value !== undefined) {
|
|
454
|
-
return value;
|
|
455
|
-
}
|
|
456
|
-
return getPath(defaultData, key);
|
|
457
|
-
}
|
|
458
|
-
function deepExtend(target, source, overwrite) {
|
|
459
|
-
for (var prop in source) {
|
|
460
|
-
if (prop !== '__proto__' && prop !== 'constructor') {
|
|
461
|
-
if (prop in target) {
|
|
462
|
-
if (typeof target[prop] === 'string' || target[prop] instanceof String || typeof source[prop] === 'string' || source[prop] instanceof String) {
|
|
463
|
-
if (overwrite) target[prop] = source[prop];
|
|
464
|
-
} else {
|
|
465
|
-
deepExtend(target[prop], source[prop], overwrite);
|
|
466
|
-
}
|
|
467
|
-
} else {
|
|
468
|
-
target[prop] = source[prop];
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
return target;
|
|
473
|
-
}
|
|
474
|
-
function regexEscape(str) {
|
|
475
|
-
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
|
476
|
-
}
|
|
477
|
-
var _entityMap = {
|
|
478
|
-
'&': '&',
|
|
479
|
-
'<': '<',
|
|
480
|
-
'>': '>',
|
|
481
|
-
'"': '"',
|
|
482
|
-
"'": ''',
|
|
483
|
-
'/': '/'
|
|
484
|
-
};
|
|
485
|
-
function escape(data) {
|
|
486
|
-
if (typeof data === 'string') {
|
|
487
|
-
return data.replace(/[&<>"'\/]/g, function (s) {
|
|
488
|
-
return _entityMap[s];
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
|
-
return data;
|
|
492
|
-
}
|
|
493
|
-
var isIE10 = typeof window !== 'undefined' && window.navigator && typeof window.navigator.userAgentData === 'undefined' && window.navigator.userAgent && window.navigator.userAgent.indexOf('MSIE') > -1;
|
|
494
|
-
var chars = [' ', ',', '?', '!', ';'];
|
|
495
|
-
function looksLikeObjectPath(key, nsSeparator, keySeparator) {
|
|
496
|
-
nsSeparator = nsSeparator || '';
|
|
497
|
-
keySeparator = keySeparator || '';
|
|
498
|
-
var possibleChars = chars.filter(function (c) {
|
|
499
|
-
return nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0;
|
|
500
|
-
});
|
|
501
|
-
if (possibleChars.length === 0) return true;
|
|
502
|
-
var r = new RegExp("(".concat(possibleChars.map(function (c) {
|
|
503
|
-
return c === '?' ? '\\?' : c;
|
|
504
|
-
}).join('|'), ")"));
|
|
505
|
-
var matched = !r.test(key);
|
|
506
|
-
if (!matched) {
|
|
507
|
-
var ki = key.indexOf(keySeparator);
|
|
508
|
-
if (ki > 0 && !r.test(key.substring(0, ki))) {
|
|
509
|
-
matched = true;
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
return matched;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
516
|
-
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
517
|
-
function _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$3(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
518
|
-
function _isNativeReflectConstruct$3() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
519
|
-
function deepFind(obj, path) {
|
|
520
|
-
var keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
|
|
521
|
-
if (!obj) return undefined;
|
|
522
|
-
if (obj[path]) return obj[path];
|
|
523
|
-
var paths = path.split(keySeparator);
|
|
524
|
-
var current = obj;
|
|
525
|
-
for (var i = 0; i < paths.length; ++i) {
|
|
526
|
-
if (!current) return undefined;
|
|
527
|
-
if (typeof current[paths[i]] === 'string' && i + 1 < paths.length) {
|
|
528
|
-
return undefined;
|
|
529
|
-
}
|
|
530
|
-
if (current[paths[i]] === undefined) {
|
|
531
|
-
var j = 2;
|
|
532
|
-
var p = paths.slice(i, i + j).join(keySeparator);
|
|
533
|
-
var mix = current[p];
|
|
534
|
-
while (mix === undefined && paths.length > i + j) {
|
|
535
|
-
j++;
|
|
536
|
-
p = paths.slice(i, i + j).join(keySeparator);
|
|
537
|
-
mix = current[p];
|
|
538
|
-
}
|
|
539
|
-
if (mix === undefined) return undefined;
|
|
540
|
-
if (mix === null) return null;
|
|
541
|
-
if (path.endsWith(p)) {
|
|
542
|
-
if (typeof mix === 'string') return mix;
|
|
543
|
-
if (p && typeof mix[p] === 'string') return mix[p];
|
|
544
|
-
}
|
|
545
|
-
var joinedPath = paths.slice(i + j).join(keySeparator);
|
|
546
|
-
if (joinedPath) return deepFind(mix, joinedPath, keySeparator);
|
|
547
|
-
return undefined;
|
|
548
|
-
}
|
|
549
|
-
current = current[paths[i]];
|
|
550
|
-
}
|
|
551
|
-
return current;
|
|
552
|
-
}
|
|
553
|
-
var ResourceStore = function (_EventEmitter) {
|
|
554
|
-
_inherits(ResourceStore, _EventEmitter);
|
|
555
|
-
var _super = _createSuper$3(ResourceStore);
|
|
556
|
-
function ResourceStore(data) {
|
|
557
|
-
var _this;
|
|
558
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
559
|
-
ns: ['translation'],
|
|
560
|
-
defaultNS: 'translation'
|
|
561
|
-
};
|
|
562
|
-
_classCallCheck(this, ResourceStore);
|
|
563
|
-
_this = _super.call(this);
|
|
564
|
-
if (isIE10) {
|
|
565
|
-
EventEmitter.call(_assertThisInitialized(_this));
|
|
566
|
-
}
|
|
567
|
-
_this.data = data || {};
|
|
568
|
-
_this.options = options;
|
|
569
|
-
if (_this.options.keySeparator === undefined) {
|
|
570
|
-
_this.options.keySeparator = '.';
|
|
571
|
-
}
|
|
572
|
-
if (_this.options.ignoreJSONStructure === undefined) {
|
|
573
|
-
_this.options.ignoreJSONStructure = true;
|
|
574
|
-
}
|
|
575
|
-
return _this;
|
|
576
|
-
}
|
|
577
|
-
_createClass(ResourceStore, [{
|
|
578
|
-
key: "addNamespaces",
|
|
579
|
-
value: function addNamespaces(ns) {
|
|
580
|
-
if (this.options.ns.indexOf(ns) < 0) {
|
|
581
|
-
this.options.ns.push(ns);
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
}, {
|
|
585
|
-
key: "removeNamespaces",
|
|
586
|
-
value: function removeNamespaces(ns) {
|
|
587
|
-
var index = this.options.ns.indexOf(ns);
|
|
588
|
-
if (index > -1) {
|
|
589
|
-
this.options.ns.splice(index, 1);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
}, {
|
|
593
|
-
key: "getResource",
|
|
594
|
-
value: function getResource(lng, ns, key) {
|
|
595
|
-
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
596
|
-
var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
|
597
|
-
var ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
|
|
598
|
-
var path = [lng, ns];
|
|
599
|
-
if (key && typeof key !== 'string') path = path.concat(key);
|
|
600
|
-
if (key && typeof key === 'string') path = path.concat(keySeparator ? key.split(keySeparator) : key);
|
|
601
|
-
if (lng.indexOf('.') > -1) {
|
|
602
|
-
path = lng.split('.');
|
|
603
|
-
}
|
|
604
|
-
var result = getPath(this.data, path);
|
|
605
|
-
if (result || !ignoreJSONStructure || typeof key !== 'string') return result;
|
|
606
|
-
return deepFind(this.data && this.data[lng] && this.data[lng][ns], key, keySeparator);
|
|
607
|
-
}
|
|
608
|
-
}, {
|
|
609
|
-
key: "addResource",
|
|
610
|
-
value: function addResource(lng, ns, key, value) {
|
|
611
|
-
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
|
|
612
|
-
silent: false
|
|
613
|
-
};
|
|
614
|
-
var keySeparator = this.options.keySeparator;
|
|
615
|
-
if (keySeparator === undefined) keySeparator = '.';
|
|
616
|
-
var path = [lng, ns];
|
|
617
|
-
if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
|
|
618
|
-
if (lng.indexOf('.') > -1) {
|
|
619
|
-
path = lng.split('.');
|
|
620
|
-
value = ns;
|
|
621
|
-
ns = path[1];
|
|
622
|
-
}
|
|
623
|
-
this.addNamespaces(ns);
|
|
624
|
-
setPath(this.data, path, value);
|
|
625
|
-
if (!options.silent) this.emit('added', lng, ns, key, value);
|
|
626
|
-
}
|
|
627
|
-
}, {
|
|
628
|
-
key: "addResources",
|
|
629
|
-
value: function addResources(lng, ns, resources) {
|
|
630
|
-
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
|
|
631
|
-
silent: false
|
|
632
|
-
};
|
|
633
|
-
for (var m in resources) {
|
|
634
|
-
if (typeof resources[m] === 'string' || Object.prototype.toString.apply(resources[m]) === '[object Array]') this.addResource(lng, ns, m, resources[m], {
|
|
635
|
-
silent: true
|
|
636
|
-
});
|
|
637
|
-
}
|
|
638
|
-
if (!options.silent) this.emit('added', lng, ns, resources);
|
|
639
|
-
}
|
|
640
|
-
}, {
|
|
641
|
-
key: "addResourceBundle",
|
|
642
|
-
value: function addResourceBundle(lng, ns, resources, deep, overwrite) {
|
|
643
|
-
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
|
|
644
|
-
silent: false
|
|
645
|
-
};
|
|
646
|
-
var path = [lng, ns];
|
|
647
|
-
if (lng.indexOf('.') > -1) {
|
|
648
|
-
path = lng.split('.');
|
|
649
|
-
deep = resources;
|
|
650
|
-
resources = ns;
|
|
651
|
-
ns = path[1];
|
|
652
|
-
}
|
|
653
|
-
this.addNamespaces(ns);
|
|
654
|
-
var pack = getPath(this.data, path) || {};
|
|
655
|
-
if (deep) {
|
|
656
|
-
deepExtend(pack, resources, overwrite);
|
|
657
|
-
} else {
|
|
658
|
-
pack = _objectSpread$5(_objectSpread$5({}, pack), resources);
|
|
659
|
-
}
|
|
660
|
-
setPath(this.data, path, pack);
|
|
661
|
-
if (!options.silent) this.emit('added', lng, ns, resources);
|
|
662
|
-
}
|
|
663
|
-
}, {
|
|
664
|
-
key: "removeResourceBundle",
|
|
665
|
-
value: function removeResourceBundle(lng, ns) {
|
|
666
|
-
if (this.hasResourceBundle(lng, ns)) {
|
|
667
|
-
delete this.data[lng][ns];
|
|
668
|
-
}
|
|
669
|
-
this.removeNamespaces(ns);
|
|
670
|
-
this.emit('removed', lng, ns);
|
|
671
|
-
}
|
|
672
|
-
}, {
|
|
673
|
-
key: "hasResourceBundle",
|
|
674
|
-
value: function hasResourceBundle(lng, ns) {
|
|
675
|
-
return this.getResource(lng, ns) !== undefined;
|
|
676
|
-
}
|
|
677
|
-
}, {
|
|
678
|
-
key: "getResourceBundle",
|
|
679
|
-
value: function getResourceBundle(lng, ns) {
|
|
680
|
-
if (!ns) ns = this.options.defaultNS;
|
|
681
|
-
if (this.options.compatibilityAPI === 'v1') return _objectSpread$5(_objectSpread$5({}, {}), this.getResource(lng, ns));
|
|
682
|
-
return this.getResource(lng, ns);
|
|
683
|
-
}
|
|
684
|
-
}, {
|
|
685
|
-
key: "getDataByLanguage",
|
|
686
|
-
value: function getDataByLanguage(lng) {
|
|
687
|
-
return this.data[lng];
|
|
688
|
-
}
|
|
689
|
-
}, {
|
|
690
|
-
key: "hasLanguageSomeTranslations",
|
|
691
|
-
value: function hasLanguageSomeTranslations(lng) {
|
|
692
|
-
var data = this.getDataByLanguage(lng);
|
|
693
|
-
var n = data && Object.keys(data) || [];
|
|
694
|
-
return !!n.find(function (v) {
|
|
695
|
-
return data[v] && Object.keys(data[v]).length > 0;
|
|
696
|
-
});
|
|
697
|
-
}
|
|
698
|
-
}, {
|
|
699
|
-
key: "toJSON",
|
|
700
|
-
value: function toJSON() {
|
|
701
|
-
return this.data;
|
|
702
|
-
}
|
|
703
|
-
}]);
|
|
704
|
-
return ResourceStore;
|
|
705
|
-
}(EventEmitter);
|
|
706
|
-
|
|
707
|
-
var postProcessor = {
|
|
708
|
-
processors: {},
|
|
709
|
-
addPostProcessor: function addPostProcessor(module) {
|
|
710
|
-
this.processors[module.name] = module;
|
|
711
|
-
},
|
|
712
|
-
handle: function handle(processors, value, key, options, translator) {
|
|
713
|
-
var _this = this;
|
|
714
|
-
processors.forEach(function (processor) {
|
|
715
|
-
if (_this.processors[processor]) value = _this.processors[processor].process(value, key, options, translator);
|
|
716
|
-
});
|
|
717
|
-
return value;
|
|
718
|
-
}
|
|
719
|
-
};
|
|
720
|
-
|
|
721
|
-
function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
722
|
-
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
723
|
-
function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
724
|
-
function _isNativeReflectConstruct$2() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
725
|
-
var checkedLoadedFor = {};
|
|
726
|
-
var Translator = function (_EventEmitter) {
|
|
727
|
-
_inherits(Translator, _EventEmitter);
|
|
728
|
-
var _super = _createSuper$2(Translator);
|
|
729
|
-
function Translator(services) {
|
|
730
|
-
var _this;
|
|
731
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
732
|
-
_classCallCheck(this, Translator);
|
|
733
|
-
_this = _super.call(this);
|
|
734
|
-
if (isIE10) {
|
|
735
|
-
EventEmitter.call(_assertThisInitialized(_this));
|
|
736
|
-
}
|
|
737
|
-
copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, _assertThisInitialized(_this));
|
|
738
|
-
_this.options = options;
|
|
739
|
-
if (_this.options.keySeparator === undefined) {
|
|
740
|
-
_this.options.keySeparator = '.';
|
|
741
|
-
}
|
|
742
|
-
_this.logger = baseLogger.create('translator');
|
|
743
|
-
return _this;
|
|
744
|
-
}
|
|
745
|
-
_createClass(Translator, [{
|
|
746
|
-
key: "changeLanguage",
|
|
747
|
-
value: function changeLanguage(lng) {
|
|
748
|
-
if (lng) this.language = lng;
|
|
749
|
-
}
|
|
750
|
-
}, {
|
|
751
|
-
key: "exists",
|
|
752
|
-
value: function exists(key) {
|
|
753
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
754
|
-
interpolation: {}
|
|
755
|
-
};
|
|
756
|
-
if (key === undefined || key === null) {
|
|
757
|
-
return false;
|
|
758
|
-
}
|
|
759
|
-
var resolved = this.resolve(key, options);
|
|
760
|
-
return resolved && resolved.res !== undefined;
|
|
761
|
-
}
|
|
762
|
-
}, {
|
|
763
|
-
key: "extractFromKey",
|
|
764
|
-
value: function extractFromKey(key, options) {
|
|
765
|
-
var nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;
|
|
766
|
-
if (nsSeparator === undefined) nsSeparator = ':';
|
|
767
|
-
var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
|
768
|
-
var namespaces = options.ns || this.options.defaultNS || [];
|
|
769
|
-
var wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
|
|
770
|
-
var seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
|
|
771
|
-
if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
|
|
772
|
-
var m = key.match(this.interpolator.nestingRegexp);
|
|
773
|
-
if (m && m.length > 0) {
|
|
774
|
-
return {
|
|
775
|
-
key: key,
|
|
776
|
-
namespaces: namespaces
|
|
777
|
-
};
|
|
778
|
-
}
|
|
779
|
-
var parts = key.split(nsSeparator);
|
|
780
|
-
if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
|
|
781
|
-
key = parts.join(keySeparator);
|
|
782
|
-
}
|
|
783
|
-
if (typeof namespaces === 'string') namespaces = [namespaces];
|
|
784
|
-
return {
|
|
785
|
-
key: key,
|
|
786
|
-
namespaces: namespaces
|
|
787
|
-
};
|
|
788
|
-
}
|
|
789
|
-
}, {
|
|
790
|
-
key: "translate",
|
|
791
|
-
value: function translate(keys, options, lastKey) {
|
|
792
|
-
var _this2 = this;
|
|
793
|
-
if (_typeof(options) !== 'object' && this.options.overloadTranslationOptionHandler) {
|
|
794
|
-
options = this.options.overloadTranslationOptionHandler(arguments);
|
|
795
|
-
}
|
|
796
|
-
if (!options) options = {};
|
|
797
|
-
if (keys === undefined || keys === null) return '';
|
|
798
|
-
if (!Array.isArray(keys)) keys = [String(keys)];
|
|
799
|
-
var returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;
|
|
800
|
-
var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
|
801
|
-
var _this$extractFromKey = this.extractFromKey(keys[keys.length - 1], options),
|
|
802
|
-
key = _this$extractFromKey.key,
|
|
803
|
-
namespaces = _this$extractFromKey.namespaces;
|
|
804
|
-
var namespace = namespaces[namespaces.length - 1];
|
|
805
|
-
var lng = options.lng || this.language;
|
|
806
|
-
var appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
|
|
807
|
-
if (lng && lng.toLowerCase() === 'cimode') {
|
|
808
|
-
if (appendNamespaceToCIMode) {
|
|
809
|
-
var nsSeparator = options.nsSeparator || this.options.nsSeparator;
|
|
810
|
-
if (returnDetails) {
|
|
811
|
-
resolved.res = "".concat(namespace).concat(nsSeparator).concat(key);
|
|
812
|
-
return resolved;
|
|
813
|
-
}
|
|
814
|
-
return "".concat(namespace).concat(nsSeparator).concat(key);
|
|
815
|
-
}
|
|
816
|
-
if (returnDetails) {
|
|
817
|
-
resolved.res = key;
|
|
818
|
-
return resolved;
|
|
819
|
-
}
|
|
820
|
-
return key;
|
|
821
|
-
}
|
|
822
|
-
var resolved = this.resolve(keys, options);
|
|
823
|
-
var res = resolved && resolved.res;
|
|
824
|
-
var resUsedKey = resolved && resolved.usedKey || key;
|
|
825
|
-
var resExactUsedKey = resolved && resolved.exactUsedKey || key;
|
|
826
|
-
var resType = Object.prototype.toString.apply(res);
|
|
827
|
-
var noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
|
|
828
|
-
var joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
|
|
829
|
-
var handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
|
|
830
|
-
var handleAsObject = typeof res !== 'string' && typeof res !== 'boolean' && typeof res !== 'number';
|
|
831
|
-
if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(typeof joinArrays === 'string' && resType === '[object Array]')) {
|
|
832
|
-
if (!options.returnObjects && !this.options.returnObjects) {
|
|
833
|
-
if (!this.options.returnedObjectHandler) {
|
|
834
|
-
this.logger.warn('accessing an object - but returnObjects options is not enabled!');
|
|
835
|
-
}
|
|
836
|
-
var r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, _objectSpread$4(_objectSpread$4({}, options), {}, {
|
|
837
|
-
ns: namespaces
|
|
838
|
-
})) : "key '".concat(key, " (").concat(this.language, ")' returned an object instead of string.");
|
|
839
|
-
if (returnDetails) {
|
|
840
|
-
resolved.res = r;
|
|
841
|
-
return resolved;
|
|
842
|
-
}
|
|
843
|
-
return r;
|
|
844
|
-
}
|
|
845
|
-
if (keySeparator) {
|
|
846
|
-
var resTypeIsArray = resType === '[object Array]';
|
|
847
|
-
var copy = resTypeIsArray ? [] : {};
|
|
848
|
-
var newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
|
|
849
|
-
for (var m in res) {
|
|
850
|
-
if (Object.prototype.hasOwnProperty.call(res, m)) {
|
|
851
|
-
var deepKey = "".concat(newKeyToUse).concat(keySeparator).concat(m);
|
|
852
|
-
copy[m] = this.translate(deepKey, _objectSpread$4(_objectSpread$4({}, options), {
|
|
853
|
-
joinArrays: false,
|
|
854
|
-
ns: namespaces
|
|
855
|
-
}));
|
|
856
|
-
if (copy[m] === deepKey) copy[m] = res[m];
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
res = copy;
|
|
860
|
-
}
|
|
861
|
-
} else if (handleAsObjectInI18nFormat && typeof joinArrays === 'string' && resType === '[object Array]') {
|
|
862
|
-
res = res.join(joinArrays);
|
|
863
|
-
if (res) res = this.extendTranslation(res, keys, options, lastKey);
|
|
864
|
-
} else {
|
|
865
|
-
var usedDefault = false;
|
|
866
|
-
var usedKey = false;
|
|
867
|
-
var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
|
|
868
|
-
var hasDefaultValue = Translator.hasDefaultValue(options);
|
|
869
|
-
var defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
|
|
870
|
-
var defaultValue = options["defaultValue".concat(defaultValueSuffix)] || options.defaultValue;
|
|
871
|
-
if (!this.isValidLookup(res) && hasDefaultValue) {
|
|
872
|
-
usedDefault = true;
|
|
873
|
-
res = defaultValue;
|
|
874
|
-
}
|
|
875
|
-
if (!this.isValidLookup(res)) {
|
|
876
|
-
usedKey = true;
|
|
877
|
-
res = key;
|
|
878
|
-
}
|
|
879
|
-
var missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
|
|
880
|
-
var resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
|
|
881
|
-
var updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
|
|
882
|
-
if (usedKey || usedDefault || updateMissing) {
|
|
883
|
-
this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
|
|
884
|
-
if (keySeparator) {
|
|
885
|
-
var fk = this.resolve(key, _objectSpread$4(_objectSpread$4({}, options), {}, {
|
|
886
|
-
keySeparator: false
|
|
887
|
-
}));
|
|
888
|
-
if (fk && fk.res) this.logger.warn('Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.');
|
|
889
|
-
}
|
|
890
|
-
var lngs = [];
|
|
891
|
-
var fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
|
|
892
|
-
if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
|
|
893
|
-
for (var i = 0; i < fallbackLngs.length; i++) {
|
|
894
|
-
lngs.push(fallbackLngs[i]);
|
|
895
|
-
}
|
|
896
|
-
} else if (this.options.saveMissingTo === 'all') {
|
|
897
|
-
lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
|
|
898
|
-
} else {
|
|
899
|
-
lngs.push(options.lng || this.language);
|
|
900
|
-
}
|
|
901
|
-
var send = function send(l, k, specificDefaultValue) {
|
|
902
|
-
var defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
|
|
903
|
-
if (_this2.options.missingKeyHandler) {
|
|
904
|
-
_this2.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
|
|
905
|
-
} else if (_this2.backendConnector && _this2.backendConnector.saveMissing) {
|
|
906
|
-
_this2.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
|
|
907
|
-
}
|
|
908
|
-
_this2.emit('missingKey', l, namespace, k, res);
|
|
909
|
-
};
|
|
910
|
-
if (this.options.saveMissing) {
|
|
911
|
-
if (this.options.saveMissingPlurals && needsPluralHandling) {
|
|
912
|
-
lngs.forEach(function (language) {
|
|
913
|
-
_this2.pluralResolver.getSuffixes(language, options).forEach(function (suffix) {
|
|
914
|
-
send([language], key + suffix, options["defaultValue".concat(suffix)] || defaultValue);
|
|
915
|
-
});
|
|
916
|
-
});
|
|
917
|
-
} else {
|
|
918
|
-
send(lngs, key, defaultValue);
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
res = this.extendTranslation(res, keys, options, resolved, lastKey);
|
|
923
|
-
if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = "".concat(namespace, ":").concat(key);
|
|
924
|
-
if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
|
|
925
|
-
if (this.options.compatibilityAPI !== 'v1') {
|
|
926
|
-
res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? "".concat(namespace, ":").concat(key) : key, usedDefault ? res : undefined);
|
|
927
|
-
} else {
|
|
928
|
-
res = this.options.parseMissingKeyHandler(res);
|
|
929
|
-
}
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
if (returnDetails) {
|
|
933
|
-
resolved.res = res;
|
|
934
|
-
return resolved;
|
|
935
|
-
}
|
|
936
|
-
return res;
|
|
937
|
-
}
|
|
938
|
-
}, {
|
|
939
|
-
key: "extendTranslation",
|
|
940
|
-
value: function extendTranslation(res, key, options, resolved, lastKey) {
|
|
941
|
-
var _this3 = this;
|
|
942
|
-
if (this.i18nFormat && this.i18nFormat.parse) {
|
|
943
|
-
res = this.i18nFormat.parse(res, _objectSpread$4(_objectSpread$4({}, this.options.interpolation.defaultVariables), options), resolved.usedLng, resolved.usedNS, resolved.usedKey, {
|
|
944
|
-
resolved: resolved
|
|
945
|
-
});
|
|
946
|
-
} else if (!options.skipInterpolation) {
|
|
947
|
-
if (options.interpolation) this.interpolator.init(_objectSpread$4(_objectSpread$4({}, options), {
|
|
948
|
-
interpolation: _objectSpread$4(_objectSpread$4({}, this.options.interpolation), options.interpolation)
|
|
949
|
-
}));
|
|
950
|
-
var skipOnVariables = typeof res === 'string' && (options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
|
|
951
|
-
var nestBef;
|
|
952
|
-
if (skipOnVariables) {
|
|
953
|
-
var nb = res.match(this.interpolator.nestingRegexp);
|
|
954
|
-
nestBef = nb && nb.length;
|
|
955
|
-
}
|
|
956
|
-
var data = options.replace && typeof options.replace !== 'string' ? options.replace : options;
|
|
957
|
-
if (this.options.interpolation.defaultVariables) data = _objectSpread$4(_objectSpread$4({}, this.options.interpolation.defaultVariables), data);
|
|
958
|
-
res = this.interpolator.interpolate(res, data, options.lng || this.language, options);
|
|
959
|
-
if (skipOnVariables) {
|
|
960
|
-
var na = res.match(this.interpolator.nestingRegexp);
|
|
961
|
-
var nestAft = na && na.length;
|
|
962
|
-
if (nestBef < nestAft) options.nest = false;
|
|
963
|
-
}
|
|
964
|
-
if (options.nest !== false) res = this.interpolator.nest(res, function () {
|
|
965
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
966
|
-
args[_key] = arguments[_key];
|
|
967
|
-
}
|
|
968
|
-
if (lastKey && lastKey[0] === args[0] && !options.context) {
|
|
969
|
-
_this3.logger.warn("It seems you are nesting recursively key: ".concat(args[0], " in key: ").concat(key[0]));
|
|
970
|
-
return null;
|
|
971
|
-
}
|
|
972
|
-
return _this3.translate.apply(_this3, args.concat([key]));
|
|
973
|
-
}, options);
|
|
974
|
-
if (options.interpolation) this.interpolator.reset();
|
|
975
|
-
}
|
|
976
|
-
var postProcess = options.postProcess || this.options.postProcess;
|
|
977
|
-
var postProcessorNames = typeof postProcess === 'string' ? [postProcess] : postProcess;
|
|
978
|
-
if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
|
|
979
|
-
res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? _objectSpread$4({
|
|
980
|
-
i18nResolved: resolved
|
|
981
|
-
}, options) : options, this);
|
|
982
|
-
}
|
|
983
|
-
return res;
|
|
984
|
-
}
|
|
985
|
-
}, {
|
|
986
|
-
key: "resolve",
|
|
987
|
-
value: function resolve(keys) {
|
|
988
|
-
var _this4 = this;
|
|
989
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
990
|
-
var found;
|
|
991
|
-
var usedKey;
|
|
992
|
-
var exactUsedKey;
|
|
993
|
-
var usedLng;
|
|
994
|
-
var usedNS;
|
|
995
|
-
if (typeof keys === 'string') keys = [keys];
|
|
996
|
-
keys.forEach(function (k) {
|
|
997
|
-
if (_this4.isValidLookup(found)) return;
|
|
998
|
-
var extracted = _this4.extractFromKey(k, options);
|
|
999
|
-
var key = extracted.key;
|
|
1000
|
-
usedKey = key;
|
|
1001
|
-
var namespaces = extracted.namespaces;
|
|
1002
|
-
if (_this4.options.fallbackNS) namespaces = namespaces.concat(_this4.options.fallbackNS);
|
|
1003
|
-
var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
|
|
1004
|
-
var needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && _this4.pluralResolver.shouldUseIntlApi();
|
|
1005
|
-
var needsContextHandling = options.context !== undefined && (typeof options.context === 'string' || typeof options.context === 'number') && options.context !== '';
|
|
1006
|
-
var codes = options.lngs ? options.lngs : _this4.languageUtils.toResolveHierarchy(options.lng || _this4.language, options.fallbackLng);
|
|
1007
|
-
namespaces.forEach(function (ns) {
|
|
1008
|
-
if (_this4.isValidLookup(found)) return;
|
|
1009
|
-
usedNS = ns;
|
|
1010
|
-
if (!checkedLoadedFor["".concat(codes[0], "-").concat(ns)] && _this4.utils && _this4.utils.hasLoadedNamespace && !_this4.utils.hasLoadedNamespace(usedNS)) {
|
|
1011
|
-
checkedLoadedFor["".concat(codes[0], "-").concat(ns)] = true;
|
|
1012
|
-
_this4.logger.warn("key \"".concat(usedKey, "\" for languages \"").concat(codes.join(', '), "\" won't get resolved as namespace \"").concat(usedNS, "\" was not yet loaded"), 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');
|
|
1013
|
-
}
|
|
1014
|
-
codes.forEach(function (code) {
|
|
1015
|
-
if (_this4.isValidLookup(found)) return;
|
|
1016
|
-
usedLng = code;
|
|
1017
|
-
var finalKeys = [key];
|
|
1018
|
-
if (_this4.i18nFormat && _this4.i18nFormat.addLookupKeys) {
|
|
1019
|
-
_this4.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
|
|
1020
|
-
} else {
|
|
1021
|
-
var pluralSuffix;
|
|
1022
|
-
if (needsPluralHandling) pluralSuffix = _this4.pluralResolver.getSuffix(code, options.count, options);
|
|
1023
|
-
var zeroSuffix = "".concat(_this4.options.pluralSeparator, "zero");
|
|
1024
|
-
if (needsPluralHandling) {
|
|
1025
|
-
finalKeys.push(key + pluralSuffix);
|
|
1026
|
-
if (needsZeroSuffixLookup) {
|
|
1027
|
-
finalKeys.push(key + zeroSuffix);
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
if (needsContextHandling) {
|
|
1031
|
-
var contextKey = "".concat(key).concat(_this4.options.contextSeparator).concat(options.context);
|
|
1032
|
-
finalKeys.push(contextKey);
|
|
1033
|
-
if (needsPluralHandling) {
|
|
1034
|
-
finalKeys.push(contextKey + pluralSuffix);
|
|
1035
|
-
if (needsZeroSuffixLookup) {
|
|
1036
|
-
finalKeys.push(contextKey + zeroSuffix);
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
var possibleKey;
|
|
1042
|
-
while (possibleKey = finalKeys.pop()) {
|
|
1043
|
-
if (!_this4.isValidLookup(found)) {
|
|
1044
|
-
exactUsedKey = possibleKey;
|
|
1045
|
-
found = _this4.getResource(code, ns, possibleKey, options);
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
});
|
|
1049
|
-
});
|
|
1050
|
-
});
|
|
1051
|
-
return {
|
|
1052
|
-
res: found,
|
|
1053
|
-
usedKey: usedKey,
|
|
1054
|
-
exactUsedKey: exactUsedKey,
|
|
1055
|
-
usedLng: usedLng,
|
|
1056
|
-
usedNS: usedNS
|
|
1057
|
-
};
|
|
1058
|
-
}
|
|
1059
|
-
}, {
|
|
1060
|
-
key: "isValidLookup",
|
|
1061
|
-
value: function isValidLookup(res) {
|
|
1062
|
-
return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
|
|
1063
|
-
}
|
|
1064
|
-
}, {
|
|
1065
|
-
key: "getResource",
|
|
1066
|
-
value: function getResource(code, ns, key) {
|
|
1067
|
-
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1068
|
-
if (this.i18nFormat && this.i18nFormat.getResource) return this.i18nFormat.getResource(code, ns, key, options);
|
|
1069
|
-
return this.resourceStore.getResource(code, ns, key, options);
|
|
1070
|
-
}
|
|
1071
|
-
}], [{
|
|
1072
|
-
key: "hasDefaultValue",
|
|
1073
|
-
value: function hasDefaultValue(options) {
|
|
1074
|
-
var prefix = 'defaultValue';
|
|
1075
|
-
for (var option in options) {
|
|
1076
|
-
if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {
|
|
1077
|
-
return true;
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
return false;
|
|
1081
|
-
}
|
|
1082
|
-
}]);
|
|
1083
|
-
return Translator;
|
|
1084
|
-
}(EventEmitter);
|
|
1085
|
-
|
|
1086
|
-
function capitalize(string) {
|
|
1087
|
-
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
1088
|
-
}
|
|
1089
|
-
var LanguageUtil = function () {
|
|
1090
|
-
function LanguageUtil(options) {
|
|
1091
|
-
_classCallCheck(this, LanguageUtil);
|
|
1092
|
-
this.options = options;
|
|
1093
|
-
this.supportedLngs = this.options.supportedLngs || false;
|
|
1094
|
-
this.logger = baseLogger.create('languageUtils');
|
|
1095
|
-
}
|
|
1096
|
-
_createClass(LanguageUtil, [{
|
|
1097
|
-
key: "getScriptPartFromCode",
|
|
1098
|
-
value: function getScriptPartFromCode(code) {
|
|
1099
|
-
if (!code || code.indexOf('-') < 0) return null;
|
|
1100
|
-
var p = code.split('-');
|
|
1101
|
-
if (p.length === 2) return null;
|
|
1102
|
-
p.pop();
|
|
1103
|
-
if (p[p.length - 1].toLowerCase() === 'x') return null;
|
|
1104
|
-
return this.formatLanguageCode(p.join('-'));
|
|
1105
|
-
}
|
|
1106
|
-
}, {
|
|
1107
|
-
key: "getLanguagePartFromCode",
|
|
1108
|
-
value: function getLanguagePartFromCode(code) {
|
|
1109
|
-
if (!code || code.indexOf('-') < 0) return code;
|
|
1110
|
-
var p = code.split('-');
|
|
1111
|
-
return this.formatLanguageCode(p[0]);
|
|
1112
|
-
}
|
|
1113
|
-
}, {
|
|
1114
|
-
key: "formatLanguageCode",
|
|
1115
|
-
value: function formatLanguageCode(code) {
|
|
1116
|
-
if (typeof code === 'string' && code.indexOf('-') > -1) {
|
|
1117
|
-
var specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];
|
|
1118
|
-
var p = code.split('-');
|
|
1119
|
-
if (this.options.lowerCaseLng) {
|
|
1120
|
-
p = p.map(function (part) {
|
|
1121
|
-
return part.toLowerCase();
|
|
1122
|
-
});
|
|
1123
|
-
} else if (p.length === 2) {
|
|
1124
|
-
p[0] = p[0].toLowerCase();
|
|
1125
|
-
p[1] = p[1].toUpperCase();
|
|
1126
|
-
if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
|
|
1127
|
-
} else if (p.length === 3) {
|
|
1128
|
-
p[0] = p[0].toLowerCase();
|
|
1129
|
-
if (p[1].length === 2) p[1] = p[1].toUpperCase();
|
|
1130
|
-
if (p[0] !== 'sgn' && p[2].length === 2) p[2] = p[2].toUpperCase();
|
|
1131
|
-
if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
|
|
1132
|
-
if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());
|
|
1133
|
-
}
|
|
1134
|
-
return p.join('-');
|
|
1135
|
-
}
|
|
1136
|
-
return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
|
|
1137
|
-
}
|
|
1138
|
-
}, {
|
|
1139
|
-
key: "isSupportedCode",
|
|
1140
|
-
value: function isSupportedCode(code) {
|
|
1141
|
-
if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
|
|
1142
|
-
code = this.getLanguagePartFromCode(code);
|
|
1143
|
-
}
|
|
1144
|
-
return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
|
|
1145
|
-
}
|
|
1146
|
-
}, {
|
|
1147
|
-
key: "getBestMatchFromCodes",
|
|
1148
|
-
value: function getBestMatchFromCodes(codes) {
|
|
1149
|
-
var _this = this;
|
|
1150
|
-
if (!codes) return null;
|
|
1151
|
-
var found;
|
|
1152
|
-
codes.forEach(function (code) {
|
|
1153
|
-
if (found) return;
|
|
1154
|
-
var cleanedLng = _this.formatLanguageCode(code);
|
|
1155
|
-
if (!_this.options.supportedLngs || _this.isSupportedCode(cleanedLng)) found = cleanedLng;
|
|
1156
|
-
});
|
|
1157
|
-
if (!found && this.options.supportedLngs) {
|
|
1158
|
-
codes.forEach(function (code) {
|
|
1159
|
-
if (found) return;
|
|
1160
|
-
var lngOnly = _this.getLanguagePartFromCode(code);
|
|
1161
|
-
if (_this.isSupportedCode(lngOnly)) return found = lngOnly;
|
|
1162
|
-
found = _this.options.supportedLngs.find(function (supportedLng) {
|
|
1163
|
-
if (supportedLng.indexOf(lngOnly) === 0) return supportedLng;
|
|
1164
|
-
});
|
|
1165
|
-
});
|
|
1166
|
-
}
|
|
1167
|
-
if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
|
|
1168
|
-
return found;
|
|
1169
|
-
}
|
|
1170
|
-
}, {
|
|
1171
|
-
key: "getFallbackCodes",
|
|
1172
|
-
value: function getFallbackCodes(fallbacks, code) {
|
|
1173
|
-
if (!fallbacks) return [];
|
|
1174
|
-
if (typeof fallbacks === 'function') fallbacks = fallbacks(code);
|
|
1175
|
-
if (typeof fallbacks === 'string') fallbacks = [fallbacks];
|
|
1176
|
-
if (Object.prototype.toString.apply(fallbacks) === '[object Array]') return fallbacks;
|
|
1177
|
-
if (!code) return fallbacks["default"] || [];
|
|
1178
|
-
var found = fallbacks[code];
|
|
1179
|
-
if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
|
|
1180
|
-
if (!found) found = fallbacks[this.formatLanguageCode(code)];
|
|
1181
|
-
if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
|
|
1182
|
-
if (!found) found = fallbacks["default"];
|
|
1183
|
-
return found || [];
|
|
1184
|
-
}
|
|
1185
|
-
}, {
|
|
1186
|
-
key: "toResolveHierarchy",
|
|
1187
|
-
value: function toResolveHierarchy(code, fallbackCode) {
|
|
1188
|
-
var _this2 = this;
|
|
1189
|
-
var fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
|
|
1190
|
-
var codes = [];
|
|
1191
|
-
var addCode = function addCode(c) {
|
|
1192
|
-
if (!c) return;
|
|
1193
|
-
if (_this2.isSupportedCode(c)) {
|
|
1194
|
-
codes.push(c);
|
|
1195
|
-
} else {
|
|
1196
|
-
_this2.logger.warn("rejecting language code not found in supportedLngs: ".concat(c));
|
|
1197
|
-
}
|
|
1198
|
-
};
|
|
1199
|
-
if (typeof code === 'string' && code.indexOf('-') > -1) {
|
|
1200
|
-
if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
|
|
1201
|
-
if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
|
|
1202
|
-
if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
|
|
1203
|
-
} else if (typeof code === 'string') {
|
|
1204
|
-
addCode(this.formatLanguageCode(code));
|
|
1205
|
-
}
|
|
1206
|
-
fallbackCodes.forEach(function (fc) {
|
|
1207
|
-
if (codes.indexOf(fc) < 0) addCode(_this2.formatLanguageCode(fc));
|
|
1208
|
-
});
|
|
1209
|
-
return codes;
|
|
1210
|
-
}
|
|
1211
|
-
}]);
|
|
1212
|
-
return LanguageUtil;
|
|
1213
|
-
}();
|
|
1214
|
-
|
|
1215
|
-
var sets = [{
|
|
1216
|
-
lngs: ['ach', 'ak', 'am', 'arn', 'br', 'fil', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt', 'pt-BR', 'tg', 'tl', 'ti', 'tr', 'uz', 'wa'],
|
|
1217
|
-
nr: [1, 2],
|
|
1218
|
-
fc: 1
|
|
1219
|
-
}, {
|
|
1220
|
-
lngs: ['af', 'an', 'ast', 'az', 'bg', 'bn', 'ca', 'da', 'de', 'dev', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fi', 'fo', 'fur', 'fy', 'gl', 'gu', 'ha', 'hi', 'hu', 'hy', 'ia', 'it', 'kk', 'kn', 'ku', 'lb', 'mai', 'ml', 'mn', 'mr', 'nah', 'nap', 'nb', 'ne', 'nl', 'nn', 'no', 'nso', 'pa', 'pap', 'pms', 'ps', 'pt-PT', 'rm', 'sco', 'se', 'si', 'so', 'son', 'sq', 'sv', 'sw', 'ta', 'te', 'tk', 'ur', 'yo'],
|
|
1221
|
-
nr: [1, 2],
|
|
1222
|
-
fc: 2
|
|
1223
|
-
}, {
|
|
1224
|
-
lngs: ['ay', 'bo', 'cgg', 'fa', 'ht', 'id', 'ja', 'jbo', 'ka', 'km', 'ko', 'ky', 'lo', 'ms', 'sah', 'su', 'th', 'tt', 'ug', 'vi', 'wo', 'zh'],
|
|
1225
|
-
nr: [1],
|
|
1226
|
-
fc: 3
|
|
1227
|
-
}, {
|
|
1228
|
-
lngs: ['be', 'bs', 'cnr', 'dz', 'hr', 'ru', 'sr', 'uk'],
|
|
1229
|
-
nr: [1, 2, 5],
|
|
1230
|
-
fc: 4
|
|
1231
|
-
}, {
|
|
1232
|
-
lngs: ['ar'],
|
|
1233
|
-
nr: [0, 1, 2, 3, 11, 100],
|
|
1234
|
-
fc: 5
|
|
1235
|
-
}, {
|
|
1236
|
-
lngs: ['cs', 'sk'],
|
|
1237
|
-
nr: [1, 2, 5],
|
|
1238
|
-
fc: 6
|
|
1239
|
-
}, {
|
|
1240
|
-
lngs: ['csb', 'pl'],
|
|
1241
|
-
nr: [1, 2, 5],
|
|
1242
|
-
fc: 7
|
|
1243
|
-
}, {
|
|
1244
|
-
lngs: ['cy'],
|
|
1245
|
-
nr: [1, 2, 3, 8],
|
|
1246
|
-
fc: 8
|
|
1247
|
-
}, {
|
|
1248
|
-
lngs: ['fr'],
|
|
1249
|
-
nr: [1, 2],
|
|
1250
|
-
fc: 9
|
|
1251
|
-
}, {
|
|
1252
|
-
lngs: ['ga'],
|
|
1253
|
-
nr: [1, 2, 3, 7, 11],
|
|
1254
|
-
fc: 10
|
|
1255
|
-
}, {
|
|
1256
|
-
lngs: ['gd'],
|
|
1257
|
-
nr: [1, 2, 3, 20],
|
|
1258
|
-
fc: 11
|
|
1259
|
-
}, {
|
|
1260
|
-
lngs: ['is'],
|
|
1261
|
-
nr: [1, 2],
|
|
1262
|
-
fc: 12
|
|
1263
|
-
}, {
|
|
1264
|
-
lngs: ['jv'],
|
|
1265
|
-
nr: [0, 1],
|
|
1266
|
-
fc: 13
|
|
1267
|
-
}, {
|
|
1268
|
-
lngs: ['kw'],
|
|
1269
|
-
nr: [1, 2, 3, 4],
|
|
1270
|
-
fc: 14
|
|
1271
|
-
}, {
|
|
1272
|
-
lngs: ['lt'],
|
|
1273
|
-
nr: [1, 2, 10],
|
|
1274
|
-
fc: 15
|
|
1275
|
-
}, {
|
|
1276
|
-
lngs: ['lv'],
|
|
1277
|
-
nr: [1, 2, 0],
|
|
1278
|
-
fc: 16
|
|
1279
|
-
}, {
|
|
1280
|
-
lngs: ['mk'],
|
|
1281
|
-
nr: [1, 2],
|
|
1282
|
-
fc: 17
|
|
1283
|
-
}, {
|
|
1284
|
-
lngs: ['mnk'],
|
|
1285
|
-
nr: [0, 1, 2],
|
|
1286
|
-
fc: 18
|
|
1287
|
-
}, {
|
|
1288
|
-
lngs: ['mt'],
|
|
1289
|
-
nr: [1, 2, 11, 20],
|
|
1290
|
-
fc: 19
|
|
1291
|
-
}, {
|
|
1292
|
-
lngs: ['or'],
|
|
1293
|
-
nr: [2, 1],
|
|
1294
|
-
fc: 2
|
|
1295
|
-
}, {
|
|
1296
|
-
lngs: ['ro'],
|
|
1297
|
-
nr: [1, 2, 20],
|
|
1298
|
-
fc: 20
|
|
1299
|
-
}, {
|
|
1300
|
-
lngs: ['sl'],
|
|
1301
|
-
nr: [5, 1, 2, 3],
|
|
1302
|
-
fc: 21
|
|
1303
|
-
}, {
|
|
1304
|
-
lngs: ['he', 'iw'],
|
|
1305
|
-
nr: [1, 2, 20, 21],
|
|
1306
|
-
fc: 22
|
|
1307
|
-
}];
|
|
1308
|
-
var _rulesPluralsTypes = {
|
|
1309
|
-
1: function _(n) {
|
|
1310
|
-
return Number(n > 1);
|
|
1311
|
-
},
|
|
1312
|
-
2: function _(n) {
|
|
1313
|
-
return Number(n != 1);
|
|
1314
|
-
},
|
|
1315
|
-
3: function _(n) {
|
|
1316
|
-
return 0;
|
|
1317
|
-
},
|
|
1318
|
-
4: function _(n) {
|
|
1319
|
-
return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
|
|
1320
|
-
},
|
|
1321
|
-
5: function _(n) {
|
|
1322
|
-
return Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5);
|
|
1323
|
-
},
|
|
1324
|
-
6: function _(n) {
|
|
1325
|
-
return Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2);
|
|
1326
|
-
},
|
|
1327
|
-
7: function _(n) {
|
|
1328
|
-
return Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
|
|
1329
|
-
},
|
|
1330
|
-
8: function _(n) {
|
|
1331
|
-
return Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3);
|
|
1332
|
-
},
|
|
1333
|
-
9: function _(n) {
|
|
1334
|
-
return Number(n >= 2);
|
|
1335
|
-
},
|
|
1336
|
-
10: function _(n) {
|
|
1337
|
-
return Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4);
|
|
1338
|
-
},
|
|
1339
|
-
11: function _(n) {
|
|
1340
|
-
return Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3);
|
|
1341
|
-
},
|
|
1342
|
-
12: function _(n) {
|
|
1343
|
-
return Number(n % 10 != 1 || n % 100 == 11);
|
|
1344
|
-
},
|
|
1345
|
-
13: function _(n) {
|
|
1346
|
-
return Number(n !== 0);
|
|
1347
|
-
},
|
|
1348
|
-
14: function _(n) {
|
|
1349
|
-
return Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3);
|
|
1350
|
-
},
|
|
1351
|
-
15: function _(n) {
|
|
1352
|
-
return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
|
|
1353
|
-
},
|
|
1354
|
-
16: function _(n) {
|
|
1355
|
-
return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2);
|
|
1356
|
-
},
|
|
1357
|
-
17: function _(n) {
|
|
1358
|
-
return Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1);
|
|
1359
|
-
},
|
|
1360
|
-
18: function _(n) {
|
|
1361
|
-
return Number(n == 0 ? 0 : n == 1 ? 1 : 2);
|
|
1362
|
-
},
|
|
1363
|
-
19: function _(n) {
|
|
1364
|
-
return Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3);
|
|
1365
|
-
},
|
|
1366
|
-
20: function _(n) {
|
|
1367
|
-
return Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2);
|
|
1368
|
-
},
|
|
1369
|
-
21: function _(n) {
|
|
1370
|
-
return Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0);
|
|
1371
|
-
},
|
|
1372
|
-
22: function _(n) {
|
|
1373
|
-
return Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3);
|
|
1374
|
-
}
|
|
1375
|
-
};
|
|
1376
|
-
var deprecatedJsonVersions = ['v1', 'v2', 'v3'];
|
|
1377
|
-
var suffixesOrder = {
|
|
1378
|
-
zero: 0,
|
|
1379
|
-
one: 1,
|
|
1380
|
-
two: 2,
|
|
1381
|
-
few: 3,
|
|
1382
|
-
many: 4,
|
|
1383
|
-
other: 5
|
|
1384
|
-
};
|
|
1385
|
-
function createRules() {
|
|
1386
|
-
var rules = {};
|
|
1387
|
-
sets.forEach(function (set) {
|
|
1388
|
-
set.lngs.forEach(function (l) {
|
|
1389
|
-
rules[l] = {
|
|
1390
|
-
numbers: set.nr,
|
|
1391
|
-
plurals: _rulesPluralsTypes[set.fc]
|
|
1392
|
-
};
|
|
1393
|
-
});
|
|
1394
|
-
});
|
|
1395
|
-
return rules;
|
|
1396
|
-
}
|
|
1397
|
-
var PluralResolver = function () {
|
|
1398
|
-
function PluralResolver(languageUtils) {
|
|
1399
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1400
|
-
_classCallCheck(this, PluralResolver);
|
|
1401
|
-
this.languageUtils = languageUtils;
|
|
1402
|
-
this.options = options;
|
|
1403
|
-
this.logger = baseLogger.create('pluralResolver');
|
|
1404
|
-
if ((!this.options.compatibilityJSON || this.options.compatibilityJSON === 'v4') && (typeof Intl === 'undefined' || !Intl.PluralRules)) {
|
|
1405
|
-
this.options.compatibilityJSON = 'v3';
|
|
1406
|
-
this.logger.error('Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.');
|
|
1407
|
-
}
|
|
1408
|
-
this.rules = createRules();
|
|
1409
|
-
}
|
|
1410
|
-
_createClass(PluralResolver, [{
|
|
1411
|
-
key: "addRule",
|
|
1412
|
-
value: function addRule(lng, obj) {
|
|
1413
|
-
this.rules[lng] = obj;
|
|
1414
|
-
}
|
|
1415
|
-
}, {
|
|
1416
|
-
key: "getRule",
|
|
1417
|
-
value: function getRule(code) {
|
|
1418
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1419
|
-
if (this.shouldUseIntlApi()) {
|
|
1420
|
-
try {
|
|
1421
|
-
return new Intl.PluralRules(code, {
|
|
1422
|
-
type: options.ordinal ? 'ordinal' : 'cardinal'
|
|
1423
|
-
});
|
|
1424
|
-
} catch (_unused) {
|
|
1425
|
-
return;
|
|
1426
|
-
}
|
|
1427
|
-
}
|
|
1428
|
-
return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];
|
|
1429
|
-
}
|
|
1430
|
-
}, {
|
|
1431
|
-
key: "needsPlural",
|
|
1432
|
-
value: function needsPlural(code) {
|
|
1433
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1434
|
-
var rule = this.getRule(code, options);
|
|
1435
|
-
if (this.shouldUseIntlApi()) {
|
|
1436
|
-
return rule && rule.resolvedOptions().pluralCategories.length > 1;
|
|
1437
|
-
}
|
|
1438
|
-
return rule && rule.numbers.length > 1;
|
|
1439
|
-
}
|
|
1440
|
-
}, {
|
|
1441
|
-
key: "getPluralFormsOfKey",
|
|
1442
|
-
value: function getPluralFormsOfKey(code, key) {
|
|
1443
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1444
|
-
return this.getSuffixes(code, options).map(function (suffix) {
|
|
1445
|
-
return "".concat(key).concat(suffix);
|
|
1446
|
-
});
|
|
1447
|
-
}
|
|
1448
|
-
}, {
|
|
1449
|
-
key: "getSuffixes",
|
|
1450
|
-
value: function getSuffixes(code) {
|
|
1451
|
-
var _this = this;
|
|
1452
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1453
|
-
var rule = this.getRule(code, options);
|
|
1454
|
-
if (!rule) {
|
|
1455
|
-
return [];
|
|
1456
|
-
}
|
|
1457
|
-
if (this.shouldUseIntlApi()) {
|
|
1458
|
-
return rule.resolvedOptions().pluralCategories.sort(function (pluralCategory1, pluralCategory2) {
|
|
1459
|
-
return suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2];
|
|
1460
|
-
}).map(function (pluralCategory) {
|
|
1461
|
-
return "".concat(_this.options.prepend).concat(pluralCategory);
|
|
1462
|
-
});
|
|
1463
|
-
}
|
|
1464
|
-
return rule.numbers.map(function (number) {
|
|
1465
|
-
return _this.getSuffix(code, number, options);
|
|
1466
|
-
});
|
|
1467
|
-
}
|
|
1468
|
-
}, {
|
|
1469
|
-
key: "getSuffix",
|
|
1470
|
-
value: function getSuffix(code, count) {
|
|
1471
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1472
|
-
var rule = this.getRule(code, options);
|
|
1473
|
-
if (rule) {
|
|
1474
|
-
if (this.shouldUseIntlApi()) {
|
|
1475
|
-
return "".concat(this.options.prepend).concat(rule.select(count));
|
|
1476
|
-
}
|
|
1477
|
-
return this.getSuffixRetroCompatible(rule, count);
|
|
1478
|
-
}
|
|
1479
|
-
this.logger.warn("no plural rule found for: ".concat(code));
|
|
1480
|
-
return '';
|
|
1481
|
-
}
|
|
1482
|
-
}, {
|
|
1483
|
-
key: "getSuffixRetroCompatible",
|
|
1484
|
-
value: function getSuffixRetroCompatible(rule, count) {
|
|
1485
|
-
var _this2 = this;
|
|
1486
|
-
var idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
|
|
1487
|
-
var suffix = rule.numbers[idx];
|
|
1488
|
-
if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
|
|
1489
|
-
if (suffix === 2) {
|
|
1490
|
-
suffix = 'plural';
|
|
1491
|
-
} else if (suffix === 1) {
|
|
1492
|
-
suffix = '';
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
var returnSuffix = function returnSuffix() {
|
|
1496
|
-
return _this2.options.prepend && suffix.toString() ? _this2.options.prepend + suffix.toString() : suffix.toString();
|
|
1497
|
-
};
|
|
1498
|
-
if (this.options.compatibilityJSON === 'v1') {
|
|
1499
|
-
if (suffix === 1) return '';
|
|
1500
|
-
if (typeof suffix === 'number') return "_plural_".concat(suffix.toString());
|
|
1501
|
-
return returnSuffix();
|
|
1502
|
-
} else if (this.options.compatibilityJSON === 'v2') {
|
|
1503
|
-
return returnSuffix();
|
|
1504
|
-
} else if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
|
|
1505
|
-
return returnSuffix();
|
|
1506
|
-
}
|
|
1507
|
-
return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
|
|
1508
|
-
}
|
|
1509
|
-
}, {
|
|
1510
|
-
key: "shouldUseIntlApi",
|
|
1511
|
-
value: function shouldUseIntlApi() {
|
|
1512
|
-
return !deprecatedJsonVersions.includes(this.options.compatibilityJSON);
|
|
1513
|
-
}
|
|
1514
|
-
}]);
|
|
1515
|
-
return PluralResolver;
|
|
1516
|
-
}();
|
|
1517
|
-
|
|
1518
|
-
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1519
|
-
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1520
|
-
var Interpolator = function () {
|
|
1521
|
-
function Interpolator() {
|
|
1522
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1523
|
-
_classCallCheck(this, Interpolator);
|
|
1524
|
-
this.logger = baseLogger.create('interpolator');
|
|
1525
|
-
this.options = options;
|
|
1526
|
-
this.format = options.interpolation && options.interpolation.format || function (value) {
|
|
1527
|
-
return value;
|
|
1528
|
-
};
|
|
1529
|
-
this.init(options);
|
|
1530
|
-
}
|
|
1531
|
-
_createClass(Interpolator, [{
|
|
1532
|
-
key: "init",
|
|
1533
|
-
value: function init() {
|
|
1534
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1535
|
-
if (!options.interpolation) options.interpolation = {
|
|
1536
|
-
escapeValue: true
|
|
1537
|
-
};
|
|
1538
|
-
var iOpts = options.interpolation;
|
|
1539
|
-
this.escape = iOpts.escape !== undefined ? iOpts.escape : escape;
|
|
1540
|
-
this.escapeValue = iOpts.escapeValue !== undefined ? iOpts.escapeValue : true;
|
|
1541
|
-
this.useRawValueToEscape = iOpts.useRawValueToEscape !== undefined ? iOpts.useRawValueToEscape : false;
|
|
1542
|
-
this.prefix = iOpts.prefix ? regexEscape(iOpts.prefix) : iOpts.prefixEscaped || '{{';
|
|
1543
|
-
this.suffix = iOpts.suffix ? regexEscape(iOpts.suffix) : iOpts.suffixEscaped || '}}';
|
|
1544
|
-
this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
|
|
1545
|
-
this.unescapePrefix = iOpts.unescapeSuffix ? '' : iOpts.unescapePrefix || '-';
|
|
1546
|
-
this.unescapeSuffix = this.unescapePrefix ? '' : iOpts.unescapeSuffix || '';
|
|
1547
|
-
this.nestingPrefix = iOpts.nestingPrefix ? regexEscape(iOpts.nestingPrefix) : iOpts.nestingPrefixEscaped || regexEscape('$t(');
|
|
1548
|
-
this.nestingSuffix = iOpts.nestingSuffix ? regexEscape(iOpts.nestingSuffix) : iOpts.nestingSuffixEscaped || regexEscape(')');
|
|
1549
|
-
this.nestingOptionsSeparator = iOpts.nestingOptionsSeparator ? iOpts.nestingOptionsSeparator : iOpts.nestingOptionsSeparator || ',';
|
|
1550
|
-
this.maxReplaces = iOpts.maxReplaces ? iOpts.maxReplaces : 1000;
|
|
1551
|
-
this.alwaysFormat = iOpts.alwaysFormat !== undefined ? iOpts.alwaysFormat : false;
|
|
1552
|
-
this.resetRegExp();
|
|
1553
|
-
}
|
|
1554
|
-
}, {
|
|
1555
|
-
key: "reset",
|
|
1556
|
-
value: function reset() {
|
|
1557
|
-
if (this.options) this.init(this.options);
|
|
1558
|
-
}
|
|
1559
|
-
}, {
|
|
1560
|
-
key: "resetRegExp",
|
|
1561
|
-
value: function resetRegExp() {
|
|
1562
|
-
var regexpStr = "".concat(this.prefix, "(.+?)").concat(this.suffix);
|
|
1563
|
-
this.regexp = new RegExp(regexpStr, 'g');
|
|
1564
|
-
var regexpUnescapeStr = "".concat(this.prefix).concat(this.unescapePrefix, "(.+?)").concat(this.unescapeSuffix).concat(this.suffix);
|
|
1565
|
-
this.regexpUnescape = new RegExp(regexpUnescapeStr, 'g');
|
|
1566
|
-
var nestingRegexpStr = "".concat(this.nestingPrefix, "(.+?)").concat(this.nestingSuffix);
|
|
1567
|
-
this.nestingRegexp = new RegExp(nestingRegexpStr, 'g');
|
|
1568
|
-
}
|
|
1569
|
-
}, {
|
|
1570
|
-
key: "interpolate",
|
|
1571
|
-
value: function interpolate(str, data, lng, options) {
|
|
1572
|
-
var _this = this;
|
|
1573
|
-
var match;
|
|
1574
|
-
var value;
|
|
1575
|
-
var replaces;
|
|
1576
|
-
var defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
|
|
1577
|
-
function regexSafe(val) {
|
|
1578
|
-
return val.replace(/\$/g, '$$$$');
|
|
1579
|
-
}
|
|
1580
|
-
var handleFormat = function handleFormat(key) {
|
|
1581
|
-
if (key.indexOf(_this.formatSeparator) < 0) {
|
|
1582
|
-
var path = getPathWithDefaults(data, defaultData, key);
|
|
1583
|
-
return _this.alwaysFormat ? _this.format(path, undefined, lng, _objectSpread$3(_objectSpread$3(_objectSpread$3({}, options), data), {}, {
|
|
1584
|
-
interpolationkey: key
|
|
1585
|
-
})) : path;
|
|
1586
|
-
}
|
|
1587
|
-
var p = key.split(_this.formatSeparator);
|
|
1588
|
-
var k = p.shift().trim();
|
|
1589
|
-
var f = p.join(_this.formatSeparator).trim();
|
|
1590
|
-
return _this.format(getPathWithDefaults(data, defaultData, k), f, lng, _objectSpread$3(_objectSpread$3(_objectSpread$3({}, options), data), {}, {
|
|
1591
|
-
interpolationkey: k
|
|
1592
|
-
}));
|
|
1593
|
-
};
|
|
1594
|
-
this.resetRegExp();
|
|
1595
|
-
var missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;
|
|
1596
|
-
var skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
|
|
1597
|
-
var todos = [{
|
|
1598
|
-
regex: this.regexpUnescape,
|
|
1599
|
-
safeValue: function safeValue(val) {
|
|
1600
|
-
return regexSafe(val);
|
|
1601
|
-
}
|
|
1602
|
-
}, {
|
|
1603
|
-
regex: this.regexp,
|
|
1604
|
-
safeValue: function safeValue(val) {
|
|
1605
|
-
return _this.escapeValue ? regexSafe(_this.escape(val)) : regexSafe(val);
|
|
1606
|
-
}
|
|
1607
|
-
}];
|
|
1608
|
-
todos.forEach(function (todo) {
|
|
1609
|
-
replaces = 0;
|
|
1610
|
-
while (match = todo.regex.exec(str)) {
|
|
1611
|
-
var matchedVar = match[1].trim();
|
|
1612
|
-
value = handleFormat(matchedVar);
|
|
1613
|
-
if (value === undefined) {
|
|
1614
|
-
if (typeof missingInterpolationHandler === 'function') {
|
|
1615
|
-
var temp = missingInterpolationHandler(str, match, options);
|
|
1616
|
-
value = typeof temp === 'string' ? temp : '';
|
|
1617
|
-
} else if (options && options.hasOwnProperty(matchedVar)) {
|
|
1618
|
-
value = '';
|
|
1619
|
-
} else if (skipOnVariables) {
|
|
1620
|
-
value = match[0];
|
|
1621
|
-
continue;
|
|
1622
|
-
} else {
|
|
1623
|
-
_this.logger.warn("missed to pass in variable ".concat(matchedVar, " for interpolating ").concat(str));
|
|
1624
|
-
value = '';
|
|
1625
|
-
}
|
|
1626
|
-
} else if (typeof value !== 'string' && !_this.useRawValueToEscape) {
|
|
1627
|
-
value = makeString(value);
|
|
1628
|
-
}
|
|
1629
|
-
var safeValue = todo.safeValue(value);
|
|
1630
|
-
str = str.replace(match[0], safeValue);
|
|
1631
|
-
if (skipOnVariables) {
|
|
1632
|
-
todo.regex.lastIndex += value.length;
|
|
1633
|
-
todo.regex.lastIndex -= match[0].length;
|
|
1634
|
-
} else {
|
|
1635
|
-
todo.regex.lastIndex = 0;
|
|
1636
|
-
}
|
|
1637
|
-
replaces++;
|
|
1638
|
-
if (replaces >= _this.maxReplaces) {
|
|
1639
|
-
break;
|
|
1640
|
-
}
|
|
1641
|
-
}
|
|
1642
|
-
});
|
|
1643
|
-
return str;
|
|
1644
|
-
}
|
|
1645
|
-
}, {
|
|
1646
|
-
key: "nest",
|
|
1647
|
-
value: function nest(str, fc) {
|
|
1648
|
-
var _this2 = this;
|
|
1649
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1650
|
-
var match;
|
|
1651
|
-
var value;
|
|
1652
|
-
var clonedOptions;
|
|
1653
|
-
function handleHasOptions(key, inheritedOptions) {
|
|
1654
|
-
var sep = this.nestingOptionsSeparator;
|
|
1655
|
-
if (key.indexOf(sep) < 0) return key;
|
|
1656
|
-
var c = key.split(new RegExp("".concat(sep, "[ ]*{")));
|
|
1657
|
-
var optionsString = "{".concat(c[1]);
|
|
1658
|
-
key = c[0];
|
|
1659
|
-
optionsString = this.interpolate(optionsString, clonedOptions);
|
|
1660
|
-
var matchedSingleQuotes = optionsString.match(/'/g);
|
|
1661
|
-
var matchedDoubleQuotes = optionsString.match(/"/g);
|
|
1662
|
-
if (matchedSingleQuotes && matchedSingleQuotes.length % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
|
|
1663
|
-
optionsString = optionsString.replace(/'/g, '"');
|
|
1664
|
-
}
|
|
1665
|
-
try {
|
|
1666
|
-
clonedOptions = JSON.parse(optionsString);
|
|
1667
|
-
if (inheritedOptions) clonedOptions = _objectSpread$3(_objectSpread$3({}, inheritedOptions), clonedOptions);
|
|
1668
|
-
} catch (e) {
|
|
1669
|
-
this.logger.warn("failed parsing options string in nesting for key ".concat(key), e);
|
|
1670
|
-
return "".concat(key).concat(sep).concat(optionsString);
|
|
1671
|
-
}
|
|
1672
|
-
delete clonedOptions.defaultValue;
|
|
1673
|
-
return key;
|
|
1674
|
-
}
|
|
1675
|
-
while (match = this.nestingRegexp.exec(str)) {
|
|
1676
|
-
var formatters = [];
|
|
1677
|
-
clonedOptions = _objectSpread$3({}, options);
|
|
1678
|
-
clonedOptions.applyPostProcessor = false;
|
|
1679
|
-
delete clonedOptions.defaultValue;
|
|
1680
|
-
var doReduce = false;
|
|
1681
|
-
if (match[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match[1])) {
|
|
1682
|
-
var r = match[1].split(this.formatSeparator).map(function (elem) {
|
|
1683
|
-
return elem.trim();
|
|
1684
|
-
});
|
|
1685
|
-
match[1] = r.shift();
|
|
1686
|
-
formatters = r;
|
|
1687
|
-
doReduce = true;
|
|
1688
|
-
}
|
|
1689
|
-
value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
|
|
1690
|
-
if (value && match[0] === str && typeof value !== 'string') return value;
|
|
1691
|
-
if (typeof value !== 'string') value = makeString(value);
|
|
1692
|
-
if (!value) {
|
|
1693
|
-
this.logger.warn("missed to resolve ".concat(match[1], " for nesting ").concat(str));
|
|
1694
|
-
value = '';
|
|
1695
|
-
}
|
|
1696
|
-
if (doReduce) {
|
|
1697
|
-
value = formatters.reduce(function (v, f) {
|
|
1698
|
-
return _this2.format(v, f, options.lng, _objectSpread$3(_objectSpread$3({}, options), {}, {
|
|
1699
|
-
interpolationkey: match[1].trim()
|
|
1700
|
-
}));
|
|
1701
|
-
}, value.trim());
|
|
1702
|
-
}
|
|
1703
|
-
str = str.replace(match[0], value);
|
|
1704
|
-
this.regexp.lastIndex = 0;
|
|
1705
|
-
}
|
|
1706
|
-
return str;
|
|
1707
|
-
}
|
|
1708
|
-
}]);
|
|
1709
|
-
return Interpolator;
|
|
1710
|
-
}();
|
|
1711
|
-
|
|
1712
|
-
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1713
|
-
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1714
|
-
function parseFormatStr(formatStr) {
|
|
1715
|
-
var formatName = formatStr.toLowerCase().trim();
|
|
1716
|
-
var formatOptions = {};
|
|
1717
|
-
if (formatStr.indexOf('(') > -1) {
|
|
1718
|
-
var p = formatStr.split('(');
|
|
1719
|
-
formatName = p[0].toLowerCase().trim();
|
|
1720
|
-
var optStr = p[1].substring(0, p[1].length - 1);
|
|
1721
|
-
if (formatName === 'currency' && optStr.indexOf(':') < 0) {
|
|
1722
|
-
if (!formatOptions.currency) formatOptions.currency = optStr.trim();
|
|
1723
|
-
} else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {
|
|
1724
|
-
if (!formatOptions.range) formatOptions.range = optStr.trim();
|
|
1725
|
-
} else {
|
|
1726
|
-
var opts = optStr.split(';');
|
|
1727
|
-
opts.forEach(function (opt) {
|
|
1728
|
-
if (!opt) return;
|
|
1729
|
-
var _opt$split = opt.split(':'),
|
|
1730
|
-
_opt$split2 = _toArray(_opt$split),
|
|
1731
|
-
key = _opt$split2[0],
|
|
1732
|
-
rest = _opt$split2.slice(1);
|
|
1733
|
-
var val = rest.join(':').trim().replace(/^'+|'+$/g, '');
|
|
1734
|
-
if (!formatOptions[key.trim()]) formatOptions[key.trim()] = val;
|
|
1735
|
-
if (val === 'false') formatOptions[key.trim()] = false;
|
|
1736
|
-
if (val === 'true') formatOptions[key.trim()] = true;
|
|
1737
|
-
if (!isNaN(val)) formatOptions[key.trim()] = parseInt(val, 10);
|
|
1738
|
-
});
|
|
1739
|
-
}
|
|
1740
|
-
}
|
|
1741
|
-
return {
|
|
1742
|
-
formatName: formatName,
|
|
1743
|
-
formatOptions: formatOptions
|
|
1744
|
-
};
|
|
1745
|
-
}
|
|
1746
|
-
function createCachedFormatter(fn) {
|
|
1747
|
-
var cache = {};
|
|
1748
|
-
return function invokeFormatter(val, lng, options) {
|
|
1749
|
-
var key = lng + JSON.stringify(options);
|
|
1750
|
-
var formatter = cache[key];
|
|
1751
|
-
if (!formatter) {
|
|
1752
|
-
formatter = fn(lng, options);
|
|
1753
|
-
cache[key] = formatter;
|
|
1754
|
-
}
|
|
1755
|
-
return formatter(val);
|
|
1756
|
-
};
|
|
1757
|
-
}
|
|
1758
|
-
var Formatter = function () {
|
|
1759
|
-
function Formatter() {
|
|
1760
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1761
|
-
_classCallCheck(this, Formatter);
|
|
1762
|
-
this.logger = baseLogger.create('formatter');
|
|
1763
|
-
this.options = options;
|
|
1764
|
-
this.formats = {
|
|
1765
|
-
number: createCachedFormatter(function (lng, options) {
|
|
1766
|
-
var formatter = new Intl.NumberFormat(lng, options);
|
|
1767
|
-
return function (val) {
|
|
1768
|
-
return formatter.format(val);
|
|
1769
|
-
};
|
|
1770
|
-
}),
|
|
1771
|
-
currency: createCachedFormatter(function (lng, options) {
|
|
1772
|
-
var formatter = new Intl.NumberFormat(lng, _objectSpread$2(_objectSpread$2({}, options), {}, {
|
|
1773
|
-
style: 'currency'
|
|
1774
|
-
}));
|
|
1775
|
-
return function (val) {
|
|
1776
|
-
return formatter.format(val);
|
|
1777
|
-
};
|
|
1778
|
-
}),
|
|
1779
|
-
datetime: createCachedFormatter(function (lng, options) {
|
|
1780
|
-
var formatter = new Intl.DateTimeFormat(lng, _objectSpread$2({}, options));
|
|
1781
|
-
return function (val) {
|
|
1782
|
-
return formatter.format(val);
|
|
1783
|
-
};
|
|
1784
|
-
}),
|
|
1785
|
-
relativetime: createCachedFormatter(function (lng, options) {
|
|
1786
|
-
var formatter = new Intl.RelativeTimeFormat(lng, _objectSpread$2({}, options));
|
|
1787
|
-
return function (val) {
|
|
1788
|
-
return formatter.format(val, options.range || 'day');
|
|
1789
|
-
};
|
|
1790
|
-
}),
|
|
1791
|
-
list: createCachedFormatter(function (lng, options) {
|
|
1792
|
-
var formatter = new Intl.ListFormat(lng, _objectSpread$2({}, options));
|
|
1793
|
-
return function (val) {
|
|
1794
|
-
return formatter.format(val);
|
|
1795
|
-
};
|
|
1796
|
-
})
|
|
1797
|
-
};
|
|
1798
|
-
this.init(options);
|
|
1799
|
-
}
|
|
1800
|
-
_createClass(Formatter, [{
|
|
1801
|
-
key: "init",
|
|
1802
|
-
value: function init(services) {
|
|
1803
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
1804
|
-
interpolation: {}
|
|
1805
|
-
};
|
|
1806
|
-
var iOpts = options.interpolation;
|
|
1807
|
-
this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
|
|
1808
|
-
}
|
|
1809
|
-
}, {
|
|
1810
|
-
key: "add",
|
|
1811
|
-
value: function add(name, fc) {
|
|
1812
|
-
this.formats[name.toLowerCase().trim()] = fc;
|
|
1813
|
-
}
|
|
1814
|
-
}, {
|
|
1815
|
-
key: "addCached",
|
|
1816
|
-
value: function addCached(name, fc) {
|
|
1817
|
-
this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
|
|
1818
|
-
}
|
|
1819
|
-
}, {
|
|
1820
|
-
key: "format",
|
|
1821
|
-
value: function format(value, _format, lng, options) {
|
|
1822
|
-
var _this = this;
|
|
1823
|
-
var formats = _format.split(this.formatSeparator);
|
|
1824
|
-
var result = formats.reduce(function (mem, f) {
|
|
1825
|
-
var _parseFormatStr = parseFormatStr(f),
|
|
1826
|
-
formatName = _parseFormatStr.formatName,
|
|
1827
|
-
formatOptions = _parseFormatStr.formatOptions;
|
|
1828
|
-
if (_this.formats[formatName]) {
|
|
1829
|
-
var formatted = mem;
|
|
1830
|
-
try {
|
|
1831
|
-
var valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || {};
|
|
1832
|
-
var l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
|
|
1833
|
-
formatted = _this.formats[formatName](mem, l, _objectSpread$2(_objectSpread$2(_objectSpread$2({}, formatOptions), options), valOptions));
|
|
1834
|
-
} catch (error) {
|
|
1835
|
-
_this.logger.warn(error);
|
|
1836
|
-
}
|
|
1837
|
-
return formatted;
|
|
1838
|
-
} else {
|
|
1839
|
-
_this.logger.warn("there was no format function for ".concat(formatName));
|
|
1840
|
-
}
|
|
1841
|
-
return mem;
|
|
1842
|
-
}, value);
|
|
1843
|
-
return result;
|
|
1844
|
-
}
|
|
1845
|
-
}]);
|
|
1846
|
-
return Formatter;
|
|
1847
|
-
}();
|
|
1848
|
-
|
|
1849
|
-
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1850
|
-
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1851
|
-
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
1852
|
-
function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
1853
|
-
function removePending(q, name) {
|
|
1854
|
-
if (q.pending[name] !== undefined) {
|
|
1855
|
-
delete q.pending[name];
|
|
1856
|
-
q.pendingCount--;
|
|
1857
|
-
}
|
|
1858
|
-
}
|
|
1859
|
-
var Connector = function (_EventEmitter) {
|
|
1860
|
-
_inherits(Connector, _EventEmitter);
|
|
1861
|
-
var _super = _createSuper$1(Connector);
|
|
1862
|
-
function Connector(backend, store, services) {
|
|
1863
|
-
var _this;
|
|
1864
|
-
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1865
|
-
_classCallCheck(this, Connector);
|
|
1866
|
-
_this = _super.call(this);
|
|
1867
|
-
if (isIE10) {
|
|
1868
|
-
EventEmitter.call(_assertThisInitialized(_this));
|
|
1869
|
-
}
|
|
1870
|
-
_this.backend = backend;
|
|
1871
|
-
_this.store = store;
|
|
1872
|
-
_this.services = services;
|
|
1873
|
-
_this.languageUtils = services.languageUtils;
|
|
1874
|
-
_this.options = options;
|
|
1875
|
-
_this.logger = baseLogger.create('backendConnector');
|
|
1876
|
-
_this.waitingReads = [];
|
|
1877
|
-
_this.maxParallelReads = options.maxParallelReads || 10;
|
|
1878
|
-
_this.readingCalls = 0;
|
|
1879
|
-
_this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
|
|
1880
|
-
_this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
|
|
1881
|
-
_this.state = {};
|
|
1882
|
-
_this.queue = [];
|
|
1883
|
-
if (_this.backend && _this.backend.init) {
|
|
1884
|
-
_this.backend.init(services, options.backend, options);
|
|
1885
|
-
}
|
|
1886
|
-
return _this;
|
|
1887
|
-
}
|
|
1888
|
-
_createClass(Connector, [{
|
|
1889
|
-
key: "queueLoad",
|
|
1890
|
-
value: function queueLoad(languages, namespaces, options, callback) {
|
|
1891
|
-
var _this2 = this;
|
|
1892
|
-
var toLoad = {};
|
|
1893
|
-
var pending = {};
|
|
1894
|
-
var toLoadLanguages = {};
|
|
1895
|
-
var toLoadNamespaces = {};
|
|
1896
|
-
languages.forEach(function (lng) {
|
|
1897
|
-
var hasAllNamespaces = true;
|
|
1898
|
-
namespaces.forEach(function (ns) {
|
|
1899
|
-
var name = "".concat(lng, "|").concat(ns);
|
|
1900
|
-
if (!options.reload && _this2.store.hasResourceBundle(lng, ns)) {
|
|
1901
|
-
_this2.state[name] = 2;
|
|
1902
|
-
} else if (_this2.state[name] < 0) ; else if (_this2.state[name] === 1) {
|
|
1903
|
-
if (pending[name] === undefined) pending[name] = true;
|
|
1904
|
-
} else {
|
|
1905
|
-
_this2.state[name] = 1;
|
|
1906
|
-
hasAllNamespaces = false;
|
|
1907
|
-
if (pending[name] === undefined) pending[name] = true;
|
|
1908
|
-
if (toLoad[name] === undefined) toLoad[name] = true;
|
|
1909
|
-
if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;
|
|
1910
|
-
}
|
|
1911
|
-
});
|
|
1912
|
-
if (!hasAllNamespaces) toLoadLanguages[lng] = true;
|
|
1913
|
-
});
|
|
1914
|
-
if (Object.keys(toLoad).length || Object.keys(pending).length) {
|
|
1915
|
-
this.queue.push({
|
|
1916
|
-
pending: pending,
|
|
1917
|
-
pendingCount: Object.keys(pending).length,
|
|
1918
|
-
loaded: {},
|
|
1919
|
-
errors: [],
|
|
1920
|
-
callback: callback
|
|
1921
|
-
});
|
|
1922
|
-
}
|
|
1923
|
-
return {
|
|
1924
|
-
toLoad: Object.keys(toLoad),
|
|
1925
|
-
pending: Object.keys(pending),
|
|
1926
|
-
toLoadLanguages: Object.keys(toLoadLanguages),
|
|
1927
|
-
toLoadNamespaces: Object.keys(toLoadNamespaces)
|
|
1928
|
-
};
|
|
1929
|
-
}
|
|
1930
|
-
}, {
|
|
1931
|
-
key: "loaded",
|
|
1932
|
-
value: function loaded(name, err, data) {
|
|
1933
|
-
var s = name.split('|');
|
|
1934
|
-
var lng = s[0];
|
|
1935
|
-
var ns = s[1];
|
|
1936
|
-
if (err) this.emit('failedLoading', lng, ns, err);
|
|
1937
|
-
if (data) {
|
|
1938
|
-
this.store.addResourceBundle(lng, ns, data);
|
|
1939
|
-
}
|
|
1940
|
-
this.state[name] = err ? -1 : 2;
|
|
1941
|
-
var loaded = {};
|
|
1942
|
-
this.queue.forEach(function (q) {
|
|
1943
|
-
pushPath(q.loaded, [lng], ns);
|
|
1944
|
-
removePending(q, name);
|
|
1945
|
-
if (err) q.errors.push(err);
|
|
1946
|
-
if (q.pendingCount === 0 && !q.done) {
|
|
1947
|
-
Object.keys(q.loaded).forEach(function (l) {
|
|
1948
|
-
if (!loaded[l]) loaded[l] = {};
|
|
1949
|
-
var loadedKeys = q.loaded[l];
|
|
1950
|
-
if (loadedKeys.length) {
|
|
1951
|
-
loadedKeys.forEach(function (ns) {
|
|
1952
|
-
if (loaded[l][ns] === undefined) loaded[l][ns] = true;
|
|
1953
|
-
});
|
|
1954
|
-
}
|
|
1955
|
-
});
|
|
1956
|
-
q.done = true;
|
|
1957
|
-
if (q.errors.length) {
|
|
1958
|
-
q.callback(q.errors);
|
|
1959
|
-
} else {
|
|
1960
|
-
q.callback();
|
|
1961
|
-
}
|
|
1962
|
-
}
|
|
1963
|
-
});
|
|
1964
|
-
this.emit('loaded', loaded);
|
|
1965
|
-
this.queue = this.queue.filter(function (q) {
|
|
1966
|
-
return !q.done;
|
|
1967
|
-
});
|
|
1968
|
-
}
|
|
1969
|
-
}, {
|
|
1970
|
-
key: "read",
|
|
1971
|
-
value: function read(lng, ns, fcName) {
|
|
1972
|
-
var _this3 = this;
|
|
1973
|
-
var tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
1974
|
-
var wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
|
|
1975
|
-
var callback = arguments.length > 5 ? arguments[5] : undefined;
|
|
1976
|
-
if (!lng.length) return callback(null, {});
|
|
1977
|
-
if (this.readingCalls >= this.maxParallelReads) {
|
|
1978
|
-
this.waitingReads.push({
|
|
1979
|
-
lng: lng,
|
|
1980
|
-
ns: ns,
|
|
1981
|
-
fcName: fcName,
|
|
1982
|
-
tried: tried,
|
|
1983
|
-
wait: wait,
|
|
1984
|
-
callback: callback
|
|
1985
|
-
});
|
|
1986
|
-
return;
|
|
1987
|
-
}
|
|
1988
|
-
this.readingCalls++;
|
|
1989
|
-
var resolver = function resolver(err, data) {
|
|
1990
|
-
_this3.readingCalls--;
|
|
1991
|
-
if (_this3.waitingReads.length > 0) {
|
|
1992
|
-
var next = _this3.waitingReads.shift();
|
|
1993
|
-
_this3.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
|
|
1994
|
-
}
|
|
1995
|
-
if (err && data && tried < _this3.maxRetries) {
|
|
1996
|
-
setTimeout(function () {
|
|
1997
|
-
_this3.read.call(_this3, lng, ns, fcName, tried + 1, wait * 2, callback);
|
|
1998
|
-
}, wait);
|
|
1999
|
-
return;
|
|
2000
|
-
}
|
|
2001
|
-
callback(err, data);
|
|
2002
|
-
};
|
|
2003
|
-
var fc = this.backend[fcName].bind(this.backend);
|
|
2004
|
-
if (fc.length === 2) {
|
|
2005
|
-
try {
|
|
2006
|
-
var r = fc(lng, ns);
|
|
2007
|
-
if (r && typeof r.then === 'function') {
|
|
2008
|
-
r.then(function (data) {
|
|
2009
|
-
return resolver(null, data);
|
|
2010
|
-
})["catch"](resolver);
|
|
2011
|
-
} else {
|
|
2012
|
-
resolver(null, r);
|
|
2013
|
-
}
|
|
2014
|
-
} catch (err) {
|
|
2015
|
-
resolver(err);
|
|
2016
|
-
}
|
|
2017
|
-
return;
|
|
2018
|
-
}
|
|
2019
|
-
return fc(lng, ns, resolver);
|
|
2020
|
-
}
|
|
2021
|
-
}, {
|
|
2022
|
-
key: "prepareLoading",
|
|
2023
|
-
value: function prepareLoading(languages, namespaces) {
|
|
2024
|
-
var _this4 = this;
|
|
2025
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2026
|
-
var callback = arguments.length > 3 ? arguments[3] : undefined;
|
|
2027
|
-
if (!this.backend) {
|
|
2028
|
-
this.logger.warn('No backend was added via i18next.use. Will not load resources.');
|
|
2029
|
-
return callback && callback();
|
|
2030
|
-
}
|
|
2031
|
-
if (typeof languages === 'string') languages = this.languageUtils.toResolveHierarchy(languages);
|
|
2032
|
-
if (typeof namespaces === 'string') namespaces = [namespaces];
|
|
2033
|
-
var toLoad = this.queueLoad(languages, namespaces, options, callback);
|
|
2034
|
-
if (!toLoad.toLoad.length) {
|
|
2035
|
-
if (!toLoad.pending.length) callback();
|
|
2036
|
-
return null;
|
|
2037
|
-
}
|
|
2038
|
-
toLoad.toLoad.forEach(function (name) {
|
|
2039
|
-
_this4.loadOne(name);
|
|
2040
|
-
});
|
|
2041
|
-
}
|
|
2042
|
-
}, {
|
|
2043
|
-
key: "load",
|
|
2044
|
-
value: function load(languages, namespaces, callback) {
|
|
2045
|
-
this.prepareLoading(languages, namespaces, {}, callback);
|
|
2046
|
-
}
|
|
2047
|
-
}, {
|
|
2048
|
-
key: "reload",
|
|
2049
|
-
value: function reload(languages, namespaces, callback) {
|
|
2050
|
-
this.prepareLoading(languages, namespaces, {
|
|
2051
|
-
reload: true
|
|
2052
|
-
}, callback);
|
|
2053
|
-
}
|
|
2054
|
-
}, {
|
|
2055
|
-
key: "loadOne",
|
|
2056
|
-
value: function loadOne(name) {
|
|
2057
|
-
var _this5 = this;
|
|
2058
|
-
var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
2059
|
-
var s = name.split('|');
|
|
2060
|
-
var lng = s[0];
|
|
2061
|
-
var ns = s[1];
|
|
2062
|
-
this.read(lng, ns, 'read', undefined, undefined, function (err, data) {
|
|
2063
|
-
if (err) _this5.logger.warn("".concat(prefix, "loading namespace ").concat(ns, " for language ").concat(lng, " failed"), err);
|
|
2064
|
-
if (!err && data) _this5.logger.log("".concat(prefix, "loaded namespace ").concat(ns, " for language ").concat(lng), data);
|
|
2065
|
-
_this5.loaded(name, err, data);
|
|
2066
|
-
});
|
|
2067
|
-
}
|
|
2068
|
-
}, {
|
|
2069
|
-
key: "saveMissing",
|
|
2070
|
-
value: function saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
|
|
2071
|
-
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
2072
|
-
var clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : function () {};
|
|
2073
|
-
if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {
|
|
2074
|
-
this.logger.warn("did not save key \"".concat(key, "\" as the namespace \"").concat(namespace, "\" was not yet loaded"), 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');
|
|
2075
|
-
return;
|
|
2076
|
-
}
|
|
2077
|
-
if (key === undefined || key === null || key === '') return;
|
|
2078
|
-
if (this.backend && this.backend.create) {
|
|
2079
|
-
var opts = _objectSpread$1(_objectSpread$1({}, options), {}, {
|
|
2080
|
-
isUpdate: isUpdate
|
|
2081
|
-
});
|
|
2082
|
-
var fc = this.backend.create.bind(this.backend);
|
|
2083
|
-
if (fc.length < 6) {
|
|
2084
|
-
try {
|
|
2085
|
-
var r;
|
|
2086
|
-
if (fc.length === 5) {
|
|
2087
|
-
r = fc(languages, namespace, key, fallbackValue, opts);
|
|
2088
|
-
} else {
|
|
2089
|
-
r = fc(languages, namespace, key, fallbackValue);
|
|
2090
|
-
}
|
|
2091
|
-
if (r && typeof r.then === 'function') {
|
|
2092
|
-
r.then(function (data) {
|
|
2093
|
-
return clb(null, data);
|
|
2094
|
-
})["catch"](clb);
|
|
2095
|
-
} else {
|
|
2096
|
-
clb(null, r);
|
|
2097
|
-
}
|
|
2098
|
-
} catch (err) {
|
|
2099
|
-
clb(err);
|
|
2100
|
-
}
|
|
2101
|
-
} else {
|
|
2102
|
-
fc(languages, namespace, key, fallbackValue, clb, opts);
|
|
2103
|
-
}
|
|
2104
|
-
}
|
|
2105
|
-
if (!languages || !languages[0]) return;
|
|
2106
|
-
this.store.addResource(languages[0], namespace, key, fallbackValue);
|
|
2107
|
-
}
|
|
2108
|
-
}]);
|
|
2109
|
-
return Connector;
|
|
2110
|
-
}(EventEmitter);
|
|
2111
|
-
|
|
2112
|
-
function get() {
|
|
2113
|
-
return {
|
|
2114
|
-
debug: false,
|
|
2115
|
-
initImmediate: true,
|
|
2116
|
-
ns: ['translation'],
|
|
2117
|
-
defaultNS: ['translation'],
|
|
2118
|
-
fallbackLng: ['dev'],
|
|
2119
|
-
fallbackNS: false,
|
|
2120
|
-
supportedLngs: false,
|
|
2121
|
-
nonExplicitSupportedLngs: false,
|
|
2122
|
-
load: 'all',
|
|
2123
|
-
preload: false,
|
|
2124
|
-
simplifyPluralSuffix: true,
|
|
2125
|
-
keySeparator: '.',
|
|
2126
|
-
nsSeparator: ':',
|
|
2127
|
-
pluralSeparator: '_',
|
|
2128
|
-
contextSeparator: '_',
|
|
2129
|
-
partialBundledLanguages: false,
|
|
2130
|
-
saveMissing: false,
|
|
2131
|
-
updateMissing: false,
|
|
2132
|
-
saveMissingTo: 'fallback',
|
|
2133
|
-
saveMissingPlurals: true,
|
|
2134
|
-
missingKeyHandler: false,
|
|
2135
|
-
missingInterpolationHandler: false,
|
|
2136
|
-
postProcess: false,
|
|
2137
|
-
postProcessPassResolved: false,
|
|
2138
|
-
returnNull: true,
|
|
2139
|
-
returnEmptyString: true,
|
|
2140
|
-
returnObjects: false,
|
|
2141
|
-
joinArrays: false,
|
|
2142
|
-
returnedObjectHandler: false,
|
|
2143
|
-
parseMissingKeyHandler: false,
|
|
2144
|
-
appendNamespaceToMissingKey: false,
|
|
2145
|
-
appendNamespaceToCIMode: false,
|
|
2146
|
-
overloadTranslationOptionHandler: function handle(args) {
|
|
2147
|
-
var ret = {};
|
|
2148
|
-
if (_typeof(args[1]) === 'object') ret = args[1];
|
|
2149
|
-
if (typeof args[1] === 'string') ret.defaultValue = args[1];
|
|
2150
|
-
if (typeof args[2] === 'string') ret.tDescription = args[2];
|
|
2151
|
-
if (_typeof(args[2]) === 'object' || _typeof(args[3]) === 'object') {
|
|
2152
|
-
var options = args[3] || args[2];
|
|
2153
|
-
Object.keys(options).forEach(function (key) {
|
|
2154
|
-
ret[key] = options[key];
|
|
2155
|
-
});
|
|
2156
|
-
}
|
|
2157
|
-
return ret;
|
|
2158
|
-
},
|
|
2159
|
-
interpolation: {
|
|
2160
|
-
escapeValue: true,
|
|
2161
|
-
format: function format(value, _format, lng, options) {
|
|
2162
|
-
return value;
|
|
2163
|
-
},
|
|
2164
|
-
prefix: '{{',
|
|
2165
|
-
suffix: '}}',
|
|
2166
|
-
formatSeparator: ',',
|
|
2167
|
-
unescapePrefix: '-',
|
|
2168
|
-
nestingPrefix: '$t(',
|
|
2169
|
-
nestingSuffix: ')',
|
|
2170
|
-
nestingOptionsSeparator: ',',
|
|
2171
|
-
maxReplaces: 1000,
|
|
2172
|
-
skipOnVariables: true
|
|
2173
|
-
}
|
|
2174
|
-
};
|
|
2175
|
-
}
|
|
2176
|
-
function transformOptions(options) {
|
|
2177
|
-
if (typeof options.ns === 'string') options.ns = [options.ns];
|
|
2178
|
-
if (typeof options.fallbackLng === 'string') options.fallbackLng = [options.fallbackLng];
|
|
2179
|
-
if (typeof options.fallbackNS === 'string') options.fallbackNS = [options.fallbackNS];
|
|
2180
|
-
if (options.supportedLngs && options.supportedLngs.indexOf('cimode') < 0) {
|
|
2181
|
-
options.supportedLngs = options.supportedLngs.concat(['cimode']);
|
|
2182
|
-
}
|
|
2183
|
-
return options;
|
|
2184
|
-
}
|
|
2185
|
-
|
|
2186
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2187
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2188
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
2189
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
2190
|
-
function noop() {}
|
|
2191
|
-
function bindMemberFunctions(inst) {
|
|
2192
|
-
var mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
|
|
2193
|
-
mems.forEach(function (mem) {
|
|
2194
|
-
if (typeof inst[mem] === 'function') {
|
|
2195
|
-
inst[mem] = inst[mem].bind(inst);
|
|
2196
|
-
}
|
|
2197
|
-
});
|
|
2198
|
-
}
|
|
2199
|
-
var I18n = function (_EventEmitter) {
|
|
2200
|
-
_inherits(I18n, _EventEmitter);
|
|
2201
|
-
var _super = _createSuper(I18n);
|
|
2202
|
-
function I18n() {
|
|
2203
|
-
var _this;
|
|
2204
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2205
|
-
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
2206
|
-
_classCallCheck(this, I18n);
|
|
2207
|
-
_this = _super.call(this);
|
|
2208
|
-
if (isIE10) {
|
|
2209
|
-
EventEmitter.call(_assertThisInitialized(_this));
|
|
2210
|
-
}
|
|
2211
|
-
_this.options = transformOptions(options);
|
|
2212
|
-
_this.services = {};
|
|
2213
|
-
_this.logger = baseLogger;
|
|
2214
|
-
_this.modules = {
|
|
2215
|
-
external: []
|
|
2216
|
-
};
|
|
2217
|
-
bindMemberFunctions(_assertThisInitialized(_this));
|
|
2218
|
-
if (callback && !_this.isInitialized && !options.isClone) {
|
|
2219
|
-
if (!_this.options.initImmediate) {
|
|
2220
|
-
_this.init(options, callback);
|
|
2221
|
-
return _possibleConstructorReturn(_this, _assertThisInitialized(_this));
|
|
2222
|
-
}
|
|
2223
|
-
setTimeout(function () {
|
|
2224
|
-
_this.init(options, callback);
|
|
2225
|
-
}, 0);
|
|
2226
|
-
}
|
|
2227
|
-
return _this;
|
|
2228
|
-
}
|
|
2229
|
-
_createClass(I18n, [{
|
|
2230
|
-
key: "init",
|
|
2231
|
-
value: function init() {
|
|
2232
|
-
var _this2 = this;
|
|
2233
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2234
|
-
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
2235
|
-
if (typeof options === 'function') {
|
|
2236
|
-
callback = options;
|
|
2237
|
-
options = {};
|
|
2238
|
-
}
|
|
2239
|
-
if (!options.defaultNS && options.defaultNS !== false && options.ns) {
|
|
2240
|
-
if (typeof options.ns === 'string') {
|
|
2241
|
-
options.defaultNS = options.ns;
|
|
2242
|
-
} else if (options.ns.indexOf('translation') < 0) {
|
|
2243
|
-
options.defaultNS = options.ns[0];
|
|
2244
|
-
}
|
|
2245
|
-
}
|
|
2246
|
-
var defOpts = get();
|
|
2247
|
-
this.options = _objectSpread(_objectSpread(_objectSpread({}, defOpts), this.options), transformOptions(options));
|
|
2248
|
-
if (this.options.compatibilityAPI !== 'v1') {
|
|
2249
|
-
this.options.interpolation = _objectSpread(_objectSpread({}, defOpts.interpolation), this.options.interpolation);
|
|
2250
|
-
}
|
|
2251
|
-
if (options.keySeparator !== undefined) {
|
|
2252
|
-
this.options.userDefinedKeySeparator = options.keySeparator;
|
|
2253
|
-
}
|
|
2254
|
-
if (options.nsSeparator !== undefined) {
|
|
2255
|
-
this.options.userDefinedNsSeparator = options.nsSeparator;
|
|
2256
|
-
}
|
|
2257
|
-
function createClassOnDemand(ClassOrObject) {
|
|
2258
|
-
if (!ClassOrObject) return null;
|
|
2259
|
-
if (typeof ClassOrObject === 'function') return new ClassOrObject();
|
|
2260
|
-
return ClassOrObject;
|
|
2261
|
-
}
|
|
2262
|
-
if (!this.options.isClone) {
|
|
2263
|
-
if (this.modules.logger) {
|
|
2264
|
-
baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
|
|
2265
|
-
} else {
|
|
2266
|
-
baseLogger.init(null, this.options);
|
|
2267
|
-
}
|
|
2268
|
-
var formatter;
|
|
2269
|
-
if (this.modules.formatter) {
|
|
2270
|
-
formatter = this.modules.formatter;
|
|
2271
|
-
} else if (typeof Intl !== 'undefined') {
|
|
2272
|
-
formatter = Formatter;
|
|
2273
|
-
}
|
|
2274
|
-
var lu = new LanguageUtil(this.options);
|
|
2275
|
-
this.store = new ResourceStore(this.options.resources, this.options);
|
|
2276
|
-
var s = this.services;
|
|
2277
|
-
s.logger = baseLogger;
|
|
2278
|
-
s.resourceStore = this.store;
|
|
2279
|
-
s.languageUtils = lu;
|
|
2280
|
-
s.pluralResolver = new PluralResolver(lu, {
|
|
2281
|
-
prepend: this.options.pluralSeparator,
|
|
2282
|
-
compatibilityJSON: this.options.compatibilityJSON,
|
|
2283
|
-
simplifyPluralSuffix: this.options.simplifyPluralSuffix
|
|
2284
|
-
});
|
|
2285
|
-
if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
|
|
2286
|
-
s.formatter = createClassOnDemand(formatter);
|
|
2287
|
-
s.formatter.init(s, this.options);
|
|
2288
|
-
this.options.interpolation.format = s.formatter.format.bind(s.formatter);
|
|
2289
|
-
}
|
|
2290
|
-
s.interpolator = new Interpolator(this.options);
|
|
2291
|
-
s.utils = {
|
|
2292
|
-
hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
|
|
2293
|
-
};
|
|
2294
|
-
s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
|
|
2295
|
-
s.backendConnector.on('*', function (event) {
|
|
2296
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
2297
|
-
args[_key - 1] = arguments[_key];
|
|
2298
|
-
}
|
|
2299
|
-
_this2.emit.apply(_this2, [event].concat(args));
|
|
2300
|
-
});
|
|
2301
|
-
if (this.modules.languageDetector) {
|
|
2302
|
-
s.languageDetector = createClassOnDemand(this.modules.languageDetector);
|
|
2303
|
-
if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
|
|
2304
|
-
}
|
|
2305
|
-
if (this.modules.i18nFormat) {
|
|
2306
|
-
s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
|
|
2307
|
-
if (s.i18nFormat.init) s.i18nFormat.init(this);
|
|
2308
|
-
}
|
|
2309
|
-
this.translator = new Translator(this.services, this.options);
|
|
2310
|
-
this.translator.on('*', function (event) {
|
|
2311
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
2312
|
-
args[_key2 - 1] = arguments[_key2];
|
|
2313
|
-
}
|
|
2314
|
-
_this2.emit.apply(_this2, [event].concat(args));
|
|
2315
|
-
});
|
|
2316
|
-
this.modules.external.forEach(function (m) {
|
|
2317
|
-
if (m.init) m.init(_this2);
|
|
2318
|
-
});
|
|
2319
|
-
}
|
|
2320
|
-
this.format = this.options.interpolation.format;
|
|
2321
|
-
if (!callback) callback = noop;
|
|
2322
|
-
if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
|
|
2323
|
-
var codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
|
2324
|
-
if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
|
|
2325
|
-
}
|
|
2326
|
-
if (!this.services.languageDetector && !this.options.lng) {
|
|
2327
|
-
this.logger.warn('init: no languageDetector is used and no lng is defined');
|
|
2328
|
-
}
|
|
2329
|
-
var storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
|
|
2330
|
-
storeApi.forEach(function (fcName) {
|
|
2331
|
-
_this2[fcName] = function () {
|
|
2332
|
-
var _this2$store;
|
|
2333
|
-
return (_this2$store = _this2.store)[fcName].apply(_this2$store, arguments);
|
|
2334
|
-
};
|
|
2335
|
-
});
|
|
2336
|
-
var storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
|
|
2337
|
-
storeApiChained.forEach(function (fcName) {
|
|
2338
|
-
_this2[fcName] = function () {
|
|
2339
|
-
var _this2$store2;
|
|
2340
|
-
(_this2$store2 = _this2.store)[fcName].apply(_this2$store2, arguments);
|
|
2341
|
-
return _this2;
|
|
2342
|
-
};
|
|
2343
|
-
});
|
|
2344
|
-
var deferred = defer();
|
|
2345
|
-
var load = function load() {
|
|
2346
|
-
var finish = function finish(err, t) {
|
|
2347
|
-
if (_this2.isInitialized && !_this2.initializedStoreOnce) _this2.logger.warn('init: i18next is already initialized. You should call init just once!');
|
|
2348
|
-
_this2.isInitialized = true;
|
|
2349
|
-
if (!_this2.options.isClone) _this2.logger.log('initialized', _this2.options);
|
|
2350
|
-
_this2.emit('initialized', _this2.options);
|
|
2351
|
-
deferred.resolve(t);
|
|
2352
|
-
callback(err, t);
|
|
2353
|
-
};
|
|
2354
|
-
if (_this2.languages && _this2.options.compatibilityAPI !== 'v1' && !_this2.isInitialized) return finish(null, _this2.t.bind(_this2));
|
|
2355
|
-
_this2.changeLanguage(_this2.options.lng, finish);
|
|
2356
|
-
};
|
|
2357
|
-
if (this.options.resources || !this.options.initImmediate) {
|
|
2358
|
-
load();
|
|
2359
|
-
} else {
|
|
2360
|
-
setTimeout(load, 0);
|
|
2361
|
-
}
|
|
2362
|
-
return deferred;
|
|
2363
|
-
}
|
|
2364
|
-
}, {
|
|
2365
|
-
key: "loadResources",
|
|
2366
|
-
value: function loadResources(language) {
|
|
2367
|
-
var _this3 = this;
|
|
2368
|
-
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
|
|
2369
|
-
var usedCallback = callback;
|
|
2370
|
-
var usedLng = typeof language === 'string' ? language : this.language;
|
|
2371
|
-
if (typeof language === 'function') usedCallback = language;
|
|
2372
|
-
if (!this.options.resources || this.options.partialBundledLanguages) {
|
|
2373
|
-
if (usedLng && usedLng.toLowerCase() === 'cimode') return usedCallback();
|
|
2374
|
-
var toLoad = [];
|
|
2375
|
-
var append = function append(lng) {
|
|
2376
|
-
if (!lng) return;
|
|
2377
|
-
var lngs = _this3.services.languageUtils.toResolveHierarchy(lng);
|
|
2378
|
-
lngs.forEach(function (l) {
|
|
2379
|
-
if (toLoad.indexOf(l) < 0) toLoad.push(l);
|
|
2380
|
-
});
|
|
2381
|
-
};
|
|
2382
|
-
if (!usedLng) {
|
|
2383
|
-
var fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
|
2384
|
-
fallbacks.forEach(function (l) {
|
|
2385
|
-
return append(l);
|
|
2386
|
-
});
|
|
2387
|
-
} else {
|
|
2388
|
-
append(usedLng);
|
|
2389
|
-
}
|
|
2390
|
-
if (this.options.preload) {
|
|
2391
|
-
this.options.preload.forEach(function (l) {
|
|
2392
|
-
return append(l);
|
|
2393
|
-
});
|
|
2394
|
-
}
|
|
2395
|
-
this.services.backendConnector.load(toLoad, this.options.ns, function (e) {
|
|
2396
|
-
if (!e && !_this3.resolvedLanguage && _this3.language) _this3.setResolvedLanguage(_this3.language);
|
|
2397
|
-
usedCallback(e);
|
|
2398
|
-
});
|
|
2399
|
-
} else {
|
|
2400
|
-
usedCallback(null);
|
|
2401
|
-
}
|
|
2402
|
-
}
|
|
2403
|
-
}, {
|
|
2404
|
-
key: "reloadResources",
|
|
2405
|
-
value: function reloadResources(lngs, ns, callback) {
|
|
2406
|
-
var deferred = defer();
|
|
2407
|
-
if (!lngs) lngs = this.languages;
|
|
2408
|
-
if (!ns) ns = this.options.ns;
|
|
2409
|
-
if (!callback) callback = noop;
|
|
2410
|
-
this.services.backendConnector.reload(lngs, ns, function (err) {
|
|
2411
|
-
deferred.resolve();
|
|
2412
|
-
callback(err);
|
|
2413
|
-
});
|
|
2414
|
-
return deferred;
|
|
2415
|
-
}
|
|
2416
|
-
}, {
|
|
2417
|
-
key: "use",
|
|
2418
|
-
value: function use(module) {
|
|
2419
|
-
if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');
|
|
2420
|
-
if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');
|
|
2421
|
-
if (module.type === 'backend') {
|
|
2422
|
-
this.modules.backend = module;
|
|
2423
|
-
}
|
|
2424
|
-
if (module.type === 'logger' || module.log && module.warn && module.error) {
|
|
2425
|
-
this.modules.logger = module;
|
|
2426
|
-
}
|
|
2427
|
-
if (module.type === 'languageDetector') {
|
|
2428
|
-
this.modules.languageDetector = module;
|
|
2429
|
-
}
|
|
2430
|
-
if (module.type === 'i18nFormat') {
|
|
2431
|
-
this.modules.i18nFormat = module;
|
|
2432
|
-
}
|
|
2433
|
-
if (module.type === 'postProcessor') {
|
|
2434
|
-
postProcessor.addPostProcessor(module);
|
|
2435
|
-
}
|
|
2436
|
-
if (module.type === 'formatter') {
|
|
2437
|
-
this.modules.formatter = module;
|
|
2438
|
-
}
|
|
2439
|
-
if (module.type === '3rdParty') {
|
|
2440
|
-
this.modules.external.push(module);
|
|
2441
|
-
}
|
|
2442
|
-
return this;
|
|
2443
|
-
}
|
|
2444
|
-
}, {
|
|
2445
|
-
key: "setResolvedLanguage",
|
|
2446
|
-
value: function setResolvedLanguage(l) {
|
|
2447
|
-
if (!l || !this.languages) return;
|
|
2448
|
-
if (['cimode', 'dev'].indexOf(l) > -1) return;
|
|
2449
|
-
for (var li = 0; li < this.languages.length; li++) {
|
|
2450
|
-
var lngInLngs = this.languages[li];
|
|
2451
|
-
if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;
|
|
2452
|
-
if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
|
|
2453
|
-
this.resolvedLanguage = lngInLngs;
|
|
2454
|
-
break;
|
|
2455
|
-
}
|
|
2456
|
-
}
|
|
2457
|
-
}
|
|
2458
|
-
}, {
|
|
2459
|
-
key: "changeLanguage",
|
|
2460
|
-
value: function changeLanguage(lng, callback) {
|
|
2461
|
-
var _this4 = this;
|
|
2462
|
-
this.isLanguageChangingTo = lng;
|
|
2463
|
-
var deferred = defer();
|
|
2464
|
-
this.emit('languageChanging', lng);
|
|
2465
|
-
var setLngProps = function setLngProps(l) {
|
|
2466
|
-
_this4.language = l;
|
|
2467
|
-
_this4.languages = _this4.services.languageUtils.toResolveHierarchy(l);
|
|
2468
|
-
_this4.resolvedLanguage = undefined;
|
|
2469
|
-
_this4.setResolvedLanguage(l);
|
|
2470
|
-
};
|
|
2471
|
-
var done = function done(err, l) {
|
|
2472
|
-
if (l) {
|
|
2473
|
-
setLngProps(l);
|
|
2474
|
-
_this4.translator.changeLanguage(l);
|
|
2475
|
-
_this4.isLanguageChangingTo = undefined;
|
|
2476
|
-
_this4.emit('languageChanged', l);
|
|
2477
|
-
_this4.logger.log('languageChanged', l);
|
|
2478
|
-
} else {
|
|
2479
|
-
_this4.isLanguageChangingTo = undefined;
|
|
2480
|
-
}
|
|
2481
|
-
deferred.resolve(function () {
|
|
2482
|
-
return _this4.t.apply(_this4, arguments);
|
|
2483
|
-
});
|
|
2484
|
-
if (callback) callback(err, function () {
|
|
2485
|
-
return _this4.t.apply(_this4, arguments);
|
|
2486
|
-
});
|
|
2487
|
-
};
|
|
2488
|
-
var setLng = function setLng(lngs) {
|
|
2489
|
-
if (!lng && !lngs && _this4.services.languageDetector) lngs = [];
|
|
2490
|
-
var l = typeof lngs === 'string' ? lngs : _this4.services.languageUtils.getBestMatchFromCodes(lngs);
|
|
2491
|
-
if (l) {
|
|
2492
|
-
if (!_this4.language) {
|
|
2493
|
-
setLngProps(l);
|
|
2494
|
-
}
|
|
2495
|
-
if (!_this4.translator.language) _this4.translator.changeLanguage(l);
|
|
2496
|
-
if (_this4.services.languageDetector && _this4.services.languageDetector.cacheUserLanguage) _this4.services.languageDetector.cacheUserLanguage(l);
|
|
2497
|
-
}
|
|
2498
|
-
_this4.loadResources(l, function (err) {
|
|
2499
|
-
done(err, l);
|
|
2500
|
-
});
|
|
2501
|
-
};
|
|
2502
|
-
if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
|
|
2503
|
-
setLng(this.services.languageDetector.detect());
|
|
2504
|
-
} else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
|
|
2505
|
-
if (this.services.languageDetector.detect.length === 0) {
|
|
2506
|
-
this.services.languageDetector.detect().then(setLng);
|
|
2507
|
-
} else {
|
|
2508
|
-
this.services.languageDetector.detect(setLng);
|
|
2509
|
-
}
|
|
2510
|
-
} else {
|
|
2511
|
-
setLng(lng);
|
|
2512
|
-
}
|
|
2513
|
-
return deferred;
|
|
2514
|
-
}
|
|
2515
|
-
}, {
|
|
2516
|
-
key: "getFixedT",
|
|
2517
|
-
value: function getFixedT(lng, ns, keyPrefix) {
|
|
2518
|
-
var _this5 = this;
|
|
2519
|
-
var fixedT = function fixedT(key, opts) {
|
|
2520
|
-
var options;
|
|
2521
|
-
if (_typeof(opts) !== 'object') {
|
|
2522
|
-
for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
|
|
2523
|
-
rest[_key3 - 2] = arguments[_key3];
|
|
2524
|
-
}
|
|
2525
|
-
options = _this5.options.overloadTranslationOptionHandler([key, opts].concat(rest));
|
|
2526
|
-
} else {
|
|
2527
|
-
options = _objectSpread({}, opts);
|
|
2528
|
-
}
|
|
2529
|
-
options.lng = options.lng || fixedT.lng;
|
|
2530
|
-
options.lngs = options.lngs || fixedT.lngs;
|
|
2531
|
-
options.ns = options.ns || fixedT.ns;
|
|
2532
|
-
options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
|
|
2533
|
-
var keySeparator = _this5.options.keySeparator || '.';
|
|
2534
|
-
var resultKey = options.keyPrefix ? "".concat(options.keyPrefix).concat(keySeparator).concat(key) : key;
|
|
2535
|
-
return _this5.t(resultKey, options);
|
|
2536
|
-
};
|
|
2537
|
-
if (typeof lng === 'string') {
|
|
2538
|
-
fixedT.lng = lng;
|
|
2539
|
-
} else {
|
|
2540
|
-
fixedT.lngs = lng;
|
|
2541
|
-
}
|
|
2542
|
-
fixedT.ns = ns;
|
|
2543
|
-
fixedT.keyPrefix = keyPrefix;
|
|
2544
|
-
return fixedT;
|
|
2545
|
-
}
|
|
2546
|
-
}, {
|
|
2547
|
-
key: "t",
|
|
2548
|
-
value: function t() {
|
|
2549
|
-
var _this$translator;
|
|
2550
|
-
return this.translator && (_this$translator = this.translator).translate.apply(_this$translator, arguments);
|
|
2551
|
-
}
|
|
2552
|
-
}, {
|
|
2553
|
-
key: "exists",
|
|
2554
|
-
value: function exists() {
|
|
2555
|
-
var _this$translator2;
|
|
2556
|
-
return this.translator && (_this$translator2 = this.translator).exists.apply(_this$translator2, arguments);
|
|
2557
|
-
}
|
|
2558
|
-
}, {
|
|
2559
|
-
key: "setDefaultNamespace",
|
|
2560
|
-
value: function setDefaultNamespace(ns) {
|
|
2561
|
-
this.options.defaultNS = ns;
|
|
2562
|
-
}
|
|
2563
|
-
}, {
|
|
2564
|
-
key: "hasLoadedNamespace",
|
|
2565
|
-
value: function hasLoadedNamespace(ns) {
|
|
2566
|
-
var _this6 = this;
|
|
2567
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2568
|
-
if (!this.isInitialized) {
|
|
2569
|
-
this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
|
|
2570
|
-
return false;
|
|
2571
|
-
}
|
|
2572
|
-
if (!this.languages || !this.languages.length) {
|
|
2573
|
-
this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);
|
|
2574
|
-
return false;
|
|
2575
|
-
}
|
|
2576
|
-
var lng = this.resolvedLanguage || this.languages[0];
|
|
2577
|
-
var fallbackLng = this.options ? this.options.fallbackLng : false;
|
|
2578
|
-
var lastLng = this.languages[this.languages.length - 1];
|
|
2579
|
-
if (lng.toLowerCase() === 'cimode') return true;
|
|
2580
|
-
var loadNotPending = function loadNotPending(l, n) {
|
|
2581
|
-
var loadState = _this6.services.backendConnector.state["".concat(l, "|").concat(n)];
|
|
2582
|
-
return loadState === -1 || loadState === 2;
|
|
2583
|
-
};
|
|
2584
|
-
if (options.precheck) {
|
|
2585
|
-
var preResult = options.precheck(this, loadNotPending);
|
|
2586
|
-
if (preResult !== undefined) return preResult;
|
|
2587
|
-
}
|
|
2588
|
-
if (this.hasResourceBundle(lng, ns)) return true;
|
|
2589
|
-
if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
|
|
2590
|
-
if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
|
|
2591
|
-
return false;
|
|
2592
|
-
}
|
|
2593
|
-
}, {
|
|
2594
|
-
key: "loadNamespaces",
|
|
2595
|
-
value: function loadNamespaces(ns, callback) {
|
|
2596
|
-
var _this7 = this;
|
|
2597
|
-
var deferred = defer();
|
|
2598
|
-
if (!this.options.ns) {
|
|
2599
|
-
callback && callback();
|
|
2600
|
-
return Promise.resolve();
|
|
2601
|
-
}
|
|
2602
|
-
if (typeof ns === 'string') ns = [ns];
|
|
2603
|
-
ns.forEach(function (n) {
|
|
2604
|
-
if (_this7.options.ns.indexOf(n) < 0) _this7.options.ns.push(n);
|
|
2605
|
-
});
|
|
2606
|
-
this.loadResources(function (err) {
|
|
2607
|
-
deferred.resolve();
|
|
2608
|
-
if (callback) callback(err);
|
|
2609
|
-
});
|
|
2610
|
-
return deferred;
|
|
2611
|
-
}
|
|
2612
|
-
}, {
|
|
2613
|
-
key: "loadLanguages",
|
|
2614
|
-
value: function loadLanguages(lngs, callback) {
|
|
2615
|
-
var deferred = defer();
|
|
2616
|
-
if (typeof lngs === 'string') lngs = [lngs];
|
|
2617
|
-
var preloaded = this.options.preload || [];
|
|
2618
|
-
var newLngs = lngs.filter(function (lng) {
|
|
2619
|
-
return preloaded.indexOf(lng) < 0;
|
|
2620
|
-
});
|
|
2621
|
-
if (!newLngs.length) {
|
|
2622
|
-
if (callback) callback();
|
|
2623
|
-
return Promise.resolve();
|
|
2624
|
-
}
|
|
2625
|
-
this.options.preload = preloaded.concat(newLngs);
|
|
2626
|
-
this.loadResources(function (err) {
|
|
2627
|
-
deferred.resolve();
|
|
2628
|
-
if (callback) callback(err);
|
|
2629
|
-
});
|
|
2630
|
-
return deferred;
|
|
2631
|
-
}
|
|
2632
|
-
}, {
|
|
2633
|
-
key: "dir",
|
|
2634
|
-
value: function dir(lng) {
|
|
2635
|
-
if (!lng) lng = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language);
|
|
2636
|
-
if (!lng) return 'rtl';
|
|
2637
|
-
var rtlLngs = ['ar', 'shu', 'sqr', 'ssh', 'xaa', 'yhd', 'yud', 'aao', 'abh', 'abv', 'acm', 'acq', 'acw', 'acx', 'acy', 'adf', 'ads', 'aeb', 'aec', 'afb', 'ajp', 'apc', 'apd', 'arb', 'arq', 'ars', 'ary', 'arz', 'auz', 'avl', 'ayh', 'ayl', 'ayn', 'ayp', 'bbz', 'pga', 'he', 'iw', 'ps', 'pbt', 'pbu', 'pst', 'prp', 'prd', 'ug', 'ur', 'ydd', 'yds', 'yih', 'ji', 'yi', 'hbo', 'men', 'xmn', 'fa', 'jpr', 'peo', 'pes', 'prs', 'dv', 'sam', 'ckb'];
|
|
2638
|
-
var languageUtils = this.services && this.services.languageUtils || new LanguageUtil(get());
|
|
2639
|
-
return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
|
|
2640
|
-
}
|
|
2641
|
-
}, {
|
|
2642
|
-
key: "cloneInstance",
|
|
2643
|
-
value: function cloneInstance() {
|
|
2644
|
-
var _this8 = this;
|
|
2645
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2646
|
-
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
|
|
2647
|
-
var mergedOptions = _objectSpread(_objectSpread(_objectSpread({}, this.options), options), {
|
|
2648
|
-
isClone: true
|
|
2649
|
-
});
|
|
2650
|
-
var clone = new I18n(mergedOptions);
|
|
2651
|
-
if (options.debug !== undefined || options.prefix !== undefined) {
|
|
2652
|
-
clone.logger = clone.logger.clone(options);
|
|
2653
|
-
}
|
|
2654
|
-
var membersToCopy = ['store', 'services', 'language'];
|
|
2655
|
-
membersToCopy.forEach(function (m) {
|
|
2656
|
-
clone[m] = _this8[m];
|
|
2657
|
-
});
|
|
2658
|
-
clone.services = _objectSpread({}, this.services);
|
|
2659
|
-
clone.services.utils = {
|
|
2660
|
-
hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
|
|
2661
|
-
};
|
|
2662
|
-
clone.translator = new Translator(clone.services, clone.options);
|
|
2663
|
-
clone.translator.on('*', function (event) {
|
|
2664
|
-
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
2665
|
-
args[_key4 - 1] = arguments[_key4];
|
|
2666
|
-
}
|
|
2667
|
-
clone.emit.apply(clone, [event].concat(args));
|
|
2668
|
-
});
|
|
2669
|
-
clone.init(mergedOptions, callback);
|
|
2670
|
-
clone.translator.options = clone.options;
|
|
2671
|
-
clone.translator.backendConnector.services.utils = {
|
|
2672
|
-
hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
|
|
2673
|
-
};
|
|
2674
|
-
return clone;
|
|
2675
|
-
}
|
|
2676
|
-
}, {
|
|
2677
|
-
key: "toJSON",
|
|
2678
|
-
value: function toJSON() {
|
|
2679
|
-
return {
|
|
2680
|
-
options: this.options,
|
|
2681
|
-
store: this.store,
|
|
2682
|
-
language: this.language,
|
|
2683
|
-
languages: this.languages,
|
|
2684
|
-
resolvedLanguage: this.resolvedLanguage
|
|
2685
|
-
};
|
|
2686
|
-
}
|
|
2687
|
-
}]);
|
|
2688
|
-
return I18n;
|
|
2689
|
-
}(EventEmitter);
|
|
2690
|
-
_defineProperty(I18n, "createInstance", function () {
|
|
2691
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2692
|
-
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
2693
|
-
return new I18n(options, callback);
|
|
2694
|
-
});
|
|
2695
|
-
var instance = I18n.createInstance();
|
|
2696
|
-
instance.createInstance = I18n.createInstance;
|
|
2697
|
-
|
|
2698
|
-
var en = {
|
|
2699
|
-
|
|
2700
|
-
};
|
|
2701
|
-
|
|
2702
|
-
var pl = {
|
|
2703
|
-
|
|
2704
|
-
};
|
|
2705
|
-
|
|
2706
|
-
var resources = {
|
|
2707
|
-
en: {
|
|
2708
|
-
translation: en
|
|
2709
|
-
},
|
|
2710
|
-
pl: {
|
|
2711
|
-
translation: pl
|
|
2712
|
-
}
|
|
2713
|
-
}; // eslint-disable-next-line no-void
|
|
2714
|
-
|
|
2715
|
-
void instance.use(initReactI18next).init({
|
|
2716
|
-
resources: resources,
|
|
2717
|
-
lng: 'pl',
|
|
2718
|
-
interpolation: {
|
|
2719
|
-
escapeValue: false
|
|
2720
|
-
}
|
|
2721
|
-
});
|
|
2722
|
-
|
|
2723
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
2724
|
-
|
|
2725
|
-
function createCommonjsModule(fn) {
|
|
2726
|
-
var module = { exports: {} };
|
|
2727
|
-
return fn(module, module.exports), module.exports;
|
|
2728
|
-
}
|
|
2729
|
-
|
|
2730
|
-
/**
|
|
2731
|
-
* [js-md5]{@link https://github.com/emn178/js-md5}
|
|
2732
|
-
*
|
|
2733
|
-
* @namespace md5
|
|
2734
|
-
* @version 0.7.3
|
|
2735
|
-
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
2736
|
-
* @copyright Chen, Yi-Cyuan 2014-2017
|
|
2737
|
-
* @license MIT
|
|
2738
|
-
*/
|
|
2739
|
-
|
|
2740
|
-
var md5 = createCommonjsModule(function (module) {
|
|
2741
|
-
(function () {
|
|
2742
|
-
|
|
2743
|
-
var ERROR = 'input is invalid type';
|
|
2744
|
-
var WINDOW = typeof window === 'object';
|
|
2745
|
-
var root = WINDOW ? window : {};
|
|
2746
|
-
if (root.JS_MD5_NO_WINDOW) {
|
|
2747
|
-
WINDOW = false;
|
|
2748
|
-
}
|
|
2749
|
-
var WEB_WORKER = !WINDOW && typeof self === 'object';
|
|
2750
|
-
var NODE_JS = !root.JS_MD5_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;
|
|
2751
|
-
if (NODE_JS) {
|
|
2752
|
-
root = commonjsGlobal;
|
|
2753
|
-
} else if (WEB_WORKER) {
|
|
2754
|
-
root = self;
|
|
2755
|
-
}
|
|
2756
|
-
var COMMON_JS = !root.JS_MD5_NO_COMMON_JS && 'object' === 'object' && module.exports;
|
|
2757
|
-
var ARRAY_BUFFER = !root.JS_MD5_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined';
|
|
2758
|
-
var HEX_CHARS = '0123456789abcdef'.split('');
|
|
2759
|
-
var EXTRA = [128, 32768, 8388608, -2147483648];
|
|
2760
|
-
var SHIFT = [0, 8, 16, 24];
|
|
2761
|
-
var OUTPUT_TYPES = ['hex', 'array', 'digest', 'buffer', 'arrayBuffer', 'base64'];
|
|
2762
|
-
var BASE64_ENCODE_CHAR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
|
|
2763
|
-
|
|
2764
|
-
var blocks = [], buffer8;
|
|
2765
|
-
if (ARRAY_BUFFER) {
|
|
2766
|
-
var buffer = new ArrayBuffer(68);
|
|
2767
|
-
buffer8 = new Uint8Array(buffer);
|
|
2768
|
-
blocks = new Uint32Array(buffer);
|
|
2769
|
-
}
|
|
2770
|
-
|
|
2771
|
-
if (root.JS_MD5_NO_NODE_JS || !Array.isArray) {
|
|
2772
|
-
Array.isArray = function (obj) {
|
|
2773
|
-
return Object.prototype.toString.call(obj) === '[object Array]';
|
|
2774
|
-
};
|
|
2775
|
-
}
|
|
2776
|
-
|
|
2777
|
-
if (ARRAY_BUFFER && (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) {
|
|
2778
|
-
ArrayBuffer.isView = function (obj) {
|
|
2779
|
-
return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer;
|
|
2780
|
-
};
|
|
2781
|
-
}
|
|
2782
|
-
|
|
2783
|
-
/**
|
|
2784
|
-
* @method hex
|
|
2785
|
-
* @memberof md5
|
|
2786
|
-
* @description Output hash as hex string
|
|
2787
|
-
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
|
|
2788
|
-
* @returns {String} Hex string
|
|
2789
|
-
* @example
|
|
2790
|
-
* md5.hex('The quick brown fox jumps over the lazy dog');
|
|
2791
|
-
* // equal to
|
|
2792
|
-
* md5('The quick brown fox jumps over the lazy dog');
|
|
2793
|
-
*/
|
|
2794
|
-
/**
|
|
2795
|
-
* @method digest
|
|
2796
|
-
* @memberof md5
|
|
2797
|
-
* @description Output hash as bytes array
|
|
2798
|
-
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
|
|
2799
|
-
* @returns {Array} Bytes array
|
|
2800
|
-
* @example
|
|
2801
|
-
* md5.digest('The quick brown fox jumps over the lazy dog');
|
|
2802
|
-
*/
|
|
2803
|
-
/**
|
|
2804
|
-
* @method array
|
|
2805
|
-
* @memberof md5
|
|
2806
|
-
* @description Output hash as bytes array
|
|
2807
|
-
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
|
|
2808
|
-
* @returns {Array} Bytes array
|
|
2809
|
-
* @example
|
|
2810
|
-
* md5.array('The quick brown fox jumps over the lazy dog');
|
|
2811
|
-
*/
|
|
2812
|
-
/**
|
|
2813
|
-
* @method arrayBuffer
|
|
2814
|
-
* @memberof md5
|
|
2815
|
-
* @description Output hash as ArrayBuffer
|
|
2816
|
-
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
|
|
2817
|
-
* @returns {ArrayBuffer} ArrayBuffer
|
|
2818
|
-
* @example
|
|
2819
|
-
* md5.arrayBuffer('The quick brown fox jumps over the lazy dog');
|
|
2820
|
-
*/
|
|
2821
|
-
/**
|
|
2822
|
-
* @method buffer
|
|
2823
|
-
* @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.
|
|
2824
|
-
* @memberof md5
|
|
2825
|
-
* @description Output hash as ArrayBuffer
|
|
2826
|
-
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
|
|
2827
|
-
* @returns {ArrayBuffer} ArrayBuffer
|
|
2828
|
-
* @example
|
|
2829
|
-
* md5.buffer('The quick brown fox jumps over the lazy dog');
|
|
2830
|
-
*/
|
|
2831
|
-
/**
|
|
2832
|
-
* @method base64
|
|
2833
|
-
* @memberof md5
|
|
2834
|
-
* @description Output hash as base64 string
|
|
2835
|
-
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
|
|
2836
|
-
* @returns {String} base64 string
|
|
2837
|
-
* @example
|
|
2838
|
-
* md5.base64('The quick brown fox jumps over the lazy dog');
|
|
2839
|
-
*/
|
|
2840
|
-
var createOutputMethod = function (outputType) {
|
|
2841
|
-
return function (message) {
|
|
2842
|
-
return new Md5(true).update(message)[outputType]();
|
|
2843
|
-
};
|
|
2844
|
-
};
|
|
2845
|
-
|
|
2846
|
-
/**
|
|
2847
|
-
* @method create
|
|
2848
|
-
* @memberof md5
|
|
2849
|
-
* @description Create Md5 object
|
|
2850
|
-
* @returns {Md5} Md5 object.
|
|
2851
|
-
* @example
|
|
2852
|
-
* var hash = md5.create();
|
|
2853
|
-
*/
|
|
2854
|
-
/**
|
|
2855
|
-
* @method update
|
|
2856
|
-
* @memberof md5
|
|
2857
|
-
* @description Create and update Md5 object
|
|
2858
|
-
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
|
|
2859
|
-
* @returns {Md5} Md5 object.
|
|
2860
|
-
* @example
|
|
2861
|
-
* var hash = md5.update('The quick brown fox jumps over the lazy dog');
|
|
2862
|
-
* // equal to
|
|
2863
|
-
* var hash = md5.create();
|
|
2864
|
-
* hash.update('The quick brown fox jumps over the lazy dog');
|
|
2865
|
-
*/
|
|
2866
|
-
var createMethod = function () {
|
|
2867
|
-
var method = createOutputMethod('hex');
|
|
2868
|
-
if (NODE_JS) {
|
|
2869
|
-
method = nodeWrap(method);
|
|
2870
|
-
}
|
|
2871
|
-
method.create = function () {
|
|
2872
|
-
return new Md5();
|
|
2873
|
-
};
|
|
2874
|
-
method.update = function (message) {
|
|
2875
|
-
return method.create().update(message);
|
|
2876
|
-
};
|
|
2877
|
-
for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
|
|
2878
|
-
var type = OUTPUT_TYPES[i];
|
|
2879
|
-
method[type] = createOutputMethod(type);
|
|
2880
|
-
}
|
|
2881
|
-
return method;
|
|
2882
|
-
};
|
|
2883
|
-
|
|
2884
|
-
var nodeWrap = function (method) {
|
|
2885
|
-
var crypto = eval("require('crypto')");
|
|
2886
|
-
var Buffer = eval("require('buffer').Buffer");
|
|
2887
|
-
var nodeMethod = function (message) {
|
|
2888
|
-
if (typeof message === 'string') {
|
|
2889
|
-
return crypto.createHash('md5').update(message, 'utf8').digest('hex');
|
|
2890
|
-
} else {
|
|
2891
|
-
if (message === null || message === undefined) {
|
|
2892
|
-
throw ERROR;
|
|
2893
|
-
} else if (message.constructor === ArrayBuffer) {
|
|
2894
|
-
message = new Uint8Array(message);
|
|
2895
|
-
}
|
|
2896
|
-
}
|
|
2897
|
-
if (Array.isArray(message) || ArrayBuffer.isView(message) ||
|
|
2898
|
-
message.constructor === Buffer) {
|
|
2899
|
-
return crypto.createHash('md5').update(new Buffer(message)).digest('hex');
|
|
2900
|
-
} else {
|
|
2901
|
-
return method(message);
|
|
2902
|
-
}
|
|
2903
|
-
};
|
|
2904
|
-
return nodeMethod;
|
|
2905
|
-
};
|
|
2906
|
-
|
|
2907
|
-
/**
|
|
2908
|
-
* Md5 class
|
|
2909
|
-
* @class Md5
|
|
2910
|
-
* @description This is internal class.
|
|
2911
|
-
* @see {@link md5.create}
|
|
2912
|
-
*/
|
|
2913
|
-
function Md5(sharedMemory) {
|
|
2914
|
-
if (sharedMemory) {
|
|
2915
|
-
blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] =
|
|
2916
|
-
blocks[4] = blocks[5] = blocks[6] = blocks[7] =
|
|
2917
|
-
blocks[8] = blocks[9] = blocks[10] = blocks[11] =
|
|
2918
|
-
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
|
|
2919
|
-
this.blocks = blocks;
|
|
2920
|
-
this.buffer8 = buffer8;
|
|
2921
|
-
} else {
|
|
2922
|
-
if (ARRAY_BUFFER) {
|
|
2923
|
-
var buffer = new ArrayBuffer(68);
|
|
2924
|
-
this.buffer8 = new Uint8Array(buffer);
|
|
2925
|
-
this.blocks = new Uint32Array(buffer);
|
|
2926
|
-
} else {
|
|
2927
|
-
this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
2928
|
-
}
|
|
2929
|
-
}
|
|
2930
|
-
this.h0 = this.h1 = this.h2 = this.h3 = this.start = this.bytes = this.hBytes = 0;
|
|
2931
|
-
this.finalized = this.hashed = false;
|
|
2932
|
-
this.first = true;
|
|
2933
|
-
}
|
|
2934
|
-
|
|
2935
|
-
/**
|
|
2936
|
-
* @method update
|
|
2937
|
-
* @memberof Md5
|
|
2938
|
-
* @instance
|
|
2939
|
-
* @description Update hash
|
|
2940
|
-
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
|
|
2941
|
-
* @returns {Md5} Md5 object.
|
|
2942
|
-
* @see {@link md5.update}
|
|
2943
|
-
*/
|
|
2944
|
-
Md5.prototype.update = function (message) {
|
|
2945
|
-
if (this.finalized) {
|
|
2946
|
-
return;
|
|
2947
|
-
}
|
|
2948
|
-
|
|
2949
|
-
var notString, type = typeof message;
|
|
2950
|
-
if (type !== 'string') {
|
|
2951
|
-
if (type === 'object') {
|
|
2952
|
-
if (message === null) {
|
|
2953
|
-
throw ERROR;
|
|
2954
|
-
} else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
|
|
2955
|
-
message = new Uint8Array(message);
|
|
2956
|
-
} else if (!Array.isArray(message)) {
|
|
2957
|
-
if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) {
|
|
2958
|
-
throw ERROR;
|
|
2959
|
-
}
|
|
2960
|
-
}
|
|
2961
|
-
} else {
|
|
2962
|
-
throw ERROR;
|
|
2963
|
-
}
|
|
2964
|
-
notString = true;
|
|
2965
|
-
}
|
|
2966
|
-
var code, index = 0, i, length = message.length, blocks = this.blocks;
|
|
2967
|
-
var buffer8 = this.buffer8;
|
|
2968
|
-
|
|
2969
|
-
while (index < length) {
|
|
2970
|
-
if (this.hashed) {
|
|
2971
|
-
this.hashed = false;
|
|
2972
|
-
blocks[0] = blocks[16];
|
|
2973
|
-
blocks[16] = blocks[1] = blocks[2] = blocks[3] =
|
|
2974
|
-
blocks[4] = blocks[5] = blocks[6] = blocks[7] =
|
|
2975
|
-
blocks[8] = blocks[9] = blocks[10] = blocks[11] =
|
|
2976
|
-
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
|
|
2977
|
-
}
|
|
2978
|
-
|
|
2979
|
-
if (notString) {
|
|
2980
|
-
if (ARRAY_BUFFER) {
|
|
2981
|
-
for (i = this.start; index < length && i < 64; ++index) {
|
|
2982
|
-
buffer8[i++] = message[index];
|
|
2983
|
-
}
|
|
2984
|
-
} else {
|
|
2985
|
-
for (i = this.start; index < length && i < 64; ++index) {
|
|
2986
|
-
blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
|
|
2987
|
-
}
|
|
2988
|
-
}
|
|
2989
|
-
} else {
|
|
2990
|
-
if (ARRAY_BUFFER) {
|
|
2991
|
-
for (i = this.start; index < length && i < 64; ++index) {
|
|
2992
|
-
code = message.charCodeAt(index);
|
|
2993
|
-
if (code < 0x80) {
|
|
2994
|
-
buffer8[i++] = code;
|
|
2995
|
-
} else if (code < 0x800) {
|
|
2996
|
-
buffer8[i++] = 0xc0 | (code >> 6);
|
|
2997
|
-
buffer8[i++] = 0x80 | (code & 0x3f);
|
|
2998
|
-
} else if (code < 0xd800 || code >= 0xe000) {
|
|
2999
|
-
buffer8[i++] = 0xe0 | (code >> 12);
|
|
3000
|
-
buffer8[i++] = 0x80 | ((code >> 6) & 0x3f);
|
|
3001
|
-
buffer8[i++] = 0x80 | (code & 0x3f);
|
|
3002
|
-
} else {
|
|
3003
|
-
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
|
|
3004
|
-
buffer8[i++] = 0xf0 | (code >> 18);
|
|
3005
|
-
buffer8[i++] = 0x80 | ((code >> 12) & 0x3f);
|
|
3006
|
-
buffer8[i++] = 0x80 | ((code >> 6) & 0x3f);
|
|
3007
|
-
buffer8[i++] = 0x80 | (code & 0x3f);
|
|
3008
|
-
}
|
|
3009
|
-
}
|
|
3010
|
-
} else {
|
|
3011
|
-
for (i = this.start; index < length && i < 64; ++index) {
|
|
3012
|
-
code = message.charCodeAt(index);
|
|
3013
|
-
if (code < 0x80) {
|
|
3014
|
-
blocks[i >> 2] |= code << SHIFT[i++ & 3];
|
|
3015
|
-
} else if (code < 0x800) {
|
|
3016
|
-
blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];
|
|
3017
|
-
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
|
3018
|
-
} else if (code < 0xd800 || code >= 0xe000) {
|
|
3019
|
-
blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];
|
|
3020
|
-
blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
|
|
3021
|
-
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
|
3022
|
-
} else {
|
|
3023
|
-
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
|
|
3024
|
-
blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];
|
|
3025
|
-
blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];
|
|
3026
|
-
blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
|
|
3027
|
-
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
|
3028
|
-
}
|
|
3029
|
-
}
|
|
3030
|
-
}
|
|
3031
|
-
}
|
|
3032
|
-
this.lastByteIndex = i;
|
|
3033
|
-
this.bytes += i - this.start;
|
|
3034
|
-
if (i >= 64) {
|
|
3035
|
-
this.start = i - 64;
|
|
3036
|
-
this.hash();
|
|
3037
|
-
this.hashed = true;
|
|
3038
|
-
} else {
|
|
3039
|
-
this.start = i;
|
|
3040
|
-
}
|
|
3041
|
-
}
|
|
3042
|
-
if (this.bytes > 4294967295) {
|
|
3043
|
-
this.hBytes += this.bytes / 4294967296 << 0;
|
|
3044
|
-
this.bytes = this.bytes % 4294967296;
|
|
3045
|
-
}
|
|
3046
|
-
return this;
|
|
3047
|
-
};
|
|
3048
|
-
|
|
3049
|
-
Md5.prototype.finalize = function () {
|
|
3050
|
-
if (this.finalized) {
|
|
3051
|
-
return;
|
|
3052
|
-
}
|
|
3053
|
-
this.finalized = true;
|
|
3054
|
-
var blocks = this.blocks, i = this.lastByteIndex;
|
|
3055
|
-
blocks[i >> 2] |= EXTRA[i & 3];
|
|
3056
|
-
if (i >= 56) {
|
|
3057
|
-
if (!this.hashed) {
|
|
3058
|
-
this.hash();
|
|
3059
|
-
}
|
|
3060
|
-
blocks[0] = blocks[16];
|
|
3061
|
-
blocks[16] = blocks[1] = blocks[2] = blocks[3] =
|
|
3062
|
-
blocks[4] = blocks[5] = blocks[6] = blocks[7] =
|
|
3063
|
-
blocks[8] = blocks[9] = blocks[10] = blocks[11] =
|
|
3064
|
-
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
|
|
3065
|
-
}
|
|
3066
|
-
blocks[14] = this.bytes << 3;
|
|
3067
|
-
blocks[15] = this.hBytes << 3 | this.bytes >>> 29;
|
|
3068
|
-
this.hash();
|
|
3069
|
-
};
|
|
3070
|
-
|
|
3071
|
-
Md5.prototype.hash = function () {
|
|
3072
|
-
var a, b, c, d, bc, da, blocks = this.blocks;
|
|
3073
|
-
|
|
3074
|
-
if (this.first) {
|
|
3075
|
-
a = blocks[0] - 680876937;
|
|
3076
|
-
a = (a << 7 | a >>> 25) - 271733879 << 0;
|
|
3077
|
-
d = (-1732584194 ^ a & 2004318071) + blocks[1] - 117830708;
|
|
3078
|
-
d = (d << 12 | d >>> 20) + a << 0;
|
|
3079
|
-
c = (-271733879 ^ (d & (a ^ -271733879))) + blocks[2] - 1126478375;
|
|
3080
|
-
c = (c << 17 | c >>> 15) + d << 0;
|
|
3081
|
-
b = (a ^ (c & (d ^ a))) + blocks[3] - 1316259209;
|
|
3082
|
-
b = (b << 22 | b >>> 10) + c << 0;
|
|
3083
|
-
} else {
|
|
3084
|
-
a = this.h0;
|
|
3085
|
-
b = this.h1;
|
|
3086
|
-
c = this.h2;
|
|
3087
|
-
d = this.h3;
|
|
3088
|
-
a += (d ^ (b & (c ^ d))) + blocks[0] - 680876936;
|
|
3089
|
-
a = (a << 7 | a >>> 25) + b << 0;
|
|
3090
|
-
d += (c ^ (a & (b ^ c))) + blocks[1] - 389564586;
|
|
3091
|
-
d = (d << 12 | d >>> 20) + a << 0;
|
|
3092
|
-
c += (b ^ (d & (a ^ b))) + blocks[2] + 606105819;
|
|
3093
|
-
c = (c << 17 | c >>> 15) + d << 0;
|
|
3094
|
-
b += (a ^ (c & (d ^ a))) + blocks[3] - 1044525330;
|
|
3095
|
-
b = (b << 22 | b >>> 10) + c << 0;
|
|
3096
|
-
}
|
|
3097
|
-
|
|
3098
|
-
a += (d ^ (b & (c ^ d))) + blocks[4] - 176418897;
|
|
3099
|
-
a = (a << 7 | a >>> 25) + b << 0;
|
|
3100
|
-
d += (c ^ (a & (b ^ c))) + blocks[5] + 1200080426;
|
|
3101
|
-
d = (d << 12 | d >>> 20) + a << 0;
|
|
3102
|
-
c += (b ^ (d & (a ^ b))) + blocks[6] - 1473231341;
|
|
3103
|
-
c = (c << 17 | c >>> 15) + d << 0;
|
|
3104
|
-
b += (a ^ (c & (d ^ a))) + blocks[7] - 45705983;
|
|
3105
|
-
b = (b << 22 | b >>> 10) + c << 0;
|
|
3106
|
-
a += (d ^ (b & (c ^ d))) + blocks[8] + 1770035416;
|
|
3107
|
-
a = (a << 7 | a >>> 25) + b << 0;
|
|
3108
|
-
d += (c ^ (a & (b ^ c))) + blocks[9] - 1958414417;
|
|
3109
|
-
d = (d << 12 | d >>> 20) + a << 0;
|
|
3110
|
-
c += (b ^ (d & (a ^ b))) + blocks[10] - 42063;
|
|
3111
|
-
c = (c << 17 | c >>> 15) + d << 0;
|
|
3112
|
-
b += (a ^ (c & (d ^ a))) + blocks[11] - 1990404162;
|
|
3113
|
-
b = (b << 22 | b >>> 10) + c << 0;
|
|
3114
|
-
a += (d ^ (b & (c ^ d))) + blocks[12] + 1804603682;
|
|
3115
|
-
a = (a << 7 | a >>> 25) + b << 0;
|
|
3116
|
-
d += (c ^ (a & (b ^ c))) + blocks[13] - 40341101;
|
|
3117
|
-
d = (d << 12 | d >>> 20) + a << 0;
|
|
3118
|
-
c += (b ^ (d & (a ^ b))) + blocks[14] - 1502002290;
|
|
3119
|
-
c = (c << 17 | c >>> 15) + d << 0;
|
|
3120
|
-
b += (a ^ (c & (d ^ a))) + blocks[15] + 1236535329;
|
|
3121
|
-
b = (b << 22 | b >>> 10) + c << 0;
|
|
3122
|
-
a += (c ^ (d & (b ^ c))) + blocks[1] - 165796510;
|
|
3123
|
-
a = (a << 5 | a >>> 27) + b << 0;
|
|
3124
|
-
d += (b ^ (c & (a ^ b))) + blocks[6] - 1069501632;
|
|
3125
|
-
d = (d << 9 | d >>> 23) + a << 0;
|
|
3126
|
-
c += (a ^ (b & (d ^ a))) + blocks[11] + 643717713;
|
|
3127
|
-
c = (c << 14 | c >>> 18) + d << 0;
|
|
3128
|
-
b += (d ^ (a & (c ^ d))) + blocks[0] - 373897302;
|
|
3129
|
-
b = (b << 20 | b >>> 12) + c << 0;
|
|
3130
|
-
a += (c ^ (d & (b ^ c))) + blocks[5] - 701558691;
|
|
3131
|
-
a = (a << 5 | a >>> 27) + b << 0;
|
|
3132
|
-
d += (b ^ (c & (a ^ b))) + blocks[10] + 38016083;
|
|
3133
|
-
d = (d << 9 | d >>> 23) + a << 0;
|
|
3134
|
-
c += (a ^ (b & (d ^ a))) + blocks[15] - 660478335;
|
|
3135
|
-
c = (c << 14 | c >>> 18) + d << 0;
|
|
3136
|
-
b += (d ^ (a & (c ^ d))) + blocks[4] - 405537848;
|
|
3137
|
-
b = (b << 20 | b >>> 12) + c << 0;
|
|
3138
|
-
a += (c ^ (d & (b ^ c))) + blocks[9] + 568446438;
|
|
3139
|
-
a = (a << 5 | a >>> 27) + b << 0;
|
|
3140
|
-
d += (b ^ (c & (a ^ b))) + blocks[14] - 1019803690;
|
|
3141
|
-
d = (d << 9 | d >>> 23) + a << 0;
|
|
3142
|
-
c += (a ^ (b & (d ^ a))) + blocks[3] - 187363961;
|
|
3143
|
-
c = (c << 14 | c >>> 18) + d << 0;
|
|
3144
|
-
b += (d ^ (a & (c ^ d))) + blocks[8] + 1163531501;
|
|
3145
|
-
b = (b << 20 | b >>> 12) + c << 0;
|
|
3146
|
-
a += (c ^ (d & (b ^ c))) + blocks[13] - 1444681467;
|
|
3147
|
-
a = (a << 5 | a >>> 27) + b << 0;
|
|
3148
|
-
d += (b ^ (c & (a ^ b))) + blocks[2] - 51403784;
|
|
3149
|
-
d = (d << 9 | d >>> 23) + a << 0;
|
|
3150
|
-
c += (a ^ (b & (d ^ a))) + blocks[7] + 1735328473;
|
|
3151
|
-
c = (c << 14 | c >>> 18) + d << 0;
|
|
3152
|
-
b += (d ^ (a & (c ^ d))) + blocks[12] - 1926607734;
|
|
3153
|
-
b = (b << 20 | b >>> 12) + c << 0;
|
|
3154
|
-
bc = b ^ c;
|
|
3155
|
-
a += (bc ^ d) + blocks[5] - 378558;
|
|
3156
|
-
a = (a << 4 | a >>> 28) + b << 0;
|
|
3157
|
-
d += (bc ^ a) + blocks[8] - 2022574463;
|
|
3158
|
-
d = (d << 11 | d >>> 21) + a << 0;
|
|
3159
|
-
da = d ^ a;
|
|
3160
|
-
c += (da ^ b) + blocks[11] + 1839030562;
|
|
3161
|
-
c = (c << 16 | c >>> 16) + d << 0;
|
|
3162
|
-
b += (da ^ c) + blocks[14] - 35309556;
|
|
3163
|
-
b = (b << 23 | b >>> 9) + c << 0;
|
|
3164
|
-
bc = b ^ c;
|
|
3165
|
-
a += (bc ^ d) + blocks[1] - 1530992060;
|
|
3166
|
-
a = (a << 4 | a >>> 28) + b << 0;
|
|
3167
|
-
d += (bc ^ a) + blocks[4] + 1272893353;
|
|
3168
|
-
d = (d << 11 | d >>> 21) + a << 0;
|
|
3169
|
-
da = d ^ a;
|
|
3170
|
-
c += (da ^ b) + blocks[7] - 155497632;
|
|
3171
|
-
c = (c << 16 | c >>> 16) + d << 0;
|
|
3172
|
-
b += (da ^ c) + blocks[10] - 1094730640;
|
|
3173
|
-
b = (b << 23 | b >>> 9) + c << 0;
|
|
3174
|
-
bc = b ^ c;
|
|
3175
|
-
a += (bc ^ d) + blocks[13] + 681279174;
|
|
3176
|
-
a = (a << 4 | a >>> 28) + b << 0;
|
|
3177
|
-
d += (bc ^ a) + blocks[0] - 358537222;
|
|
3178
|
-
d = (d << 11 | d >>> 21) + a << 0;
|
|
3179
|
-
da = d ^ a;
|
|
3180
|
-
c += (da ^ b) + blocks[3] - 722521979;
|
|
3181
|
-
c = (c << 16 | c >>> 16) + d << 0;
|
|
3182
|
-
b += (da ^ c) + blocks[6] + 76029189;
|
|
3183
|
-
b = (b << 23 | b >>> 9) + c << 0;
|
|
3184
|
-
bc = b ^ c;
|
|
3185
|
-
a += (bc ^ d) + blocks[9] - 640364487;
|
|
3186
|
-
a = (a << 4 | a >>> 28) + b << 0;
|
|
3187
|
-
d += (bc ^ a) + blocks[12] - 421815835;
|
|
3188
|
-
d = (d << 11 | d >>> 21) + a << 0;
|
|
3189
|
-
da = d ^ a;
|
|
3190
|
-
c += (da ^ b) + blocks[15] + 530742520;
|
|
3191
|
-
c = (c << 16 | c >>> 16) + d << 0;
|
|
3192
|
-
b += (da ^ c) + blocks[2] - 995338651;
|
|
3193
|
-
b = (b << 23 | b >>> 9) + c << 0;
|
|
3194
|
-
a += (c ^ (b | ~d)) + blocks[0] - 198630844;
|
|
3195
|
-
a = (a << 6 | a >>> 26) + b << 0;
|
|
3196
|
-
d += (b ^ (a | ~c)) + blocks[7] + 1126891415;
|
|
3197
|
-
d = (d << 10 | d >>> 22) + a << 0;
|
|
3198
|
-
c += (a ^ (d | ~b)) + blocks[14] - 1416354905;
|
|
3199
|
-
c = (c << 15 | c >>> 17) + d << 0;
|
|
3200
|
-
b += (d ^ (c | ~a)) + blocks[5] - 57434055;
|
|
3201
|
-
b = (b << 21 | b >>> 11) + c << 0;
|
|
3202
|
-
a += (c ^ (b | ~d)) + blocks[12] + 1700485571;
|
|
3203
|
-
a = (a << 6 | a >>> 26) + b << 0;
|
|
3204
|
-
d += (b ^ (a | ~c)) + blocks[3] - 1894986606;
|
|
3205
|
-
d = (d << 10 | d >>> 22) + a << 0;
|
|
3206
|
-
c += (a ^ (d | ~b)) + blocks[10] - 1051523;
|
|
3207
|
-
c = (c << 15 | c >>> 17) + d << 0;
|
|
3208
|
-
b += (d ^ (c | ~a)) + blocks[1] - 2054922799;
|
|
3209
|
-
b = (b << 21 | b >>> 11) + c << 0;
|
|
3210
|
-
a += (c ^ (b | ~d)) + blocks[8] + 1873313359;
|
|
3211
|
-
a = (a << 6 | a >>> 26) + b << 0;
|
|
3212
|
-
d += (b ^ (a | ~c)) + blocks[15] - 30611744;
|
|
3213
|
-
d = (d << 10 | d >>> 22) + a << 0;
|
|
3214
|
-
c += (a ^ (d | ~b)) + blocks[6] - 1560198380;
|
|
3215
|
-
c = (c << 15 | c >>> 17) + d << 0;
|
|
3216
|
-
b += (d ^ (c | ~a)) + blocks[13] + 1309151649;
|
|
3217
|
-
b = (b << 21 | b >>> 11) + c << 0;
|
|
3218
|
-
a += (c ^ (b | ~d)) + blocks[4] - 145523070;
|
|
3219
|
-
a = (a << 6 | a >>> 26) + b << 0;
|
|
3220
|
-
d += (b ^ (a | ~c)) + blocks[11] - 1120210379;
|
|
3221
|
-
d = (d << 10 | d >>> 22) + a << 0;
|
|
3222
|
-
c += (a ^ (d | ~b)) + blocks[2] + 718787259;
|
|
3223
|
-
c = (c << 15 | c >>> 17) + d << 0;
|
|
3224
|
-
b += (d ^ (c | ~a)) + blocks[9] - 343485551;
|
|
3225
|
-
b = (b << 21 | b >>> 11) + c << 0;
|
|
3226
|
-
|
|
3227
|
-
if (this.first) {
|
|
3228
|
-
this.h0 = a + 1732584193 << 0;
|
|
3229
|
-
this.h1 = b - 271733879 << 0;
|
|
3230
|
-
this.h2 = c - 1732584194 << 0;
|
|
3231
|
-
this.h3 = d + 271733878 << 0;
|
|
3232
|
-
this.first = false;
|
|
3233
|
-
} else {
|
|
3234
|
-
this.h0 = this.h0 + a << 0;
|
|
3235
|
-
this.h1 = this.h1 + b << 0;
|
|
3236
|
-
this.h2 = this.h2 + c << 0;
|
|
3237
|
-
this.h3 = this.h3 + d << 0;
|
|
3238
|
-
}
|
|
3239
|
-
};
|
|
3240
|
-
|
|
3241
|
-
/**
|
|
3242
|
-
* @method hex
|
|
3243
|
-
* @memberof Md5
|
|
3244
|
-
* @instance
|
|
3245
|
-
* @description Output hash as hex string
|
|
3246
|
-
* @returns {String} Hex string
|
|
3247
|
-
* @see {@link md5.hex}
|
|
3248
|
-
* @example
|
|
3249
|
-
* hash.hex();
|
|
3250
|
-
*/
|
|
3251
|
-
Md5.prototype.hex = function () {
|
|
3252
|
-
this.finalize();
|
|
3253
|
-
|
|
3254
|
-
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3;
|
|
3255
|
-
|
|
3256
|
-
return HEX_CHARS[(h0 >> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] +
|
|
3257
|
-
HEX_CHARS[(h0 >> 12) & 0x0F] + HEX_CHARS[(h0 >> 8) & 0x0F] +
|
|
3258
|
-
HEX_CHARS[(h0 >> 20) & 0x0F] + HEX_CHARS[(h0 >> 16) & 0x0F] +
|
|
3259
|
-
HEX_CHARS[(h0 >> 28) & 0x0F] + HEX_CHARS[(h0 >> 24) & 0x0F] +
|
|
3260
|
-
HEX_CHARS[(h1 >> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] +
|
|
3261
|
-
HEX_CHARS[(h1 >> 12) & 0x0F] + HEX_CHARS[(h1 >> 8) & 0x0F] +
|
|
3262
|
-
HEX_CHARS[(h1 >> 20) & 0x0F] + HEX_CHARS[(h1 >> 16) & 0x0F] +
|
|
3263
|
-
HEX_CHARS[(h1 >> 28) & 0x0F] + HEX_CHARS[(h1 >> 24) & 0x0F] +
|
|
3264
|
-
HEX_CHARS[(h2 >> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] +
|
|
3265
|
-
HEX_CHARS[(h2 >> 12) & 0x0F] + HEX_CHARS[(h2 >> 8) & 0x0F] +
|
|
3266
|
-
HEX_CHARS[(h2 >> 20) & 0x0F] + HEX_CHARS[(h2 >> 16) & 0x0F] +
|
|
3267
|
-
HEX_CHARS[(h2 >> 28) & 0x0F] + HEX_CHARS[(h2 >> 24) & 0x0F] +
|
|
3268
|
-
HEX_CHARS[(h3 >> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] +
|
|
3269
|
-
HEX_CHARS[(h3 >> 12) & 0x0F] + HEX_CHARS[(h3 >> 8) & 0x0F] +
|
|
3270
|
-
HEX_CHARS[(h3 >> 20) & 0x0F] + HEX_CHARS[(h3 >> 16) & 0x0F] +
|
|
3271
|
-
HEX_CHARS[(h3 >> 28) & 0x0F] + HEX_CHARS[(h3 >> 24) & 0x0F];
|
|
3272
|
-
};
|
|
3273
|
-
|
|
3274
|
-
/**
|
|
3275
|
-
* @method toString
|
|
3276
|
-
* @memberof Md5
|
|
3277
|
-
* @instance
|
|
3278
|
-
* @description Output hash as hex string
|
|
3279
|
-
* @returns {String} Hex string
|
|
3280
|
-
* @see {@link md5.hex}
|
|
3281
|
-
* @example
|
|
3282
|
-
* hash.toString();
|
|
3283
|
-
*/
|
|
3284
|
-
Md5.prototype.toString = Md5.prototype.hex;
|
|
3285
|
-
|
|
3286
|
-
/**
|
|
3287
|
-
* @method digest
|
|
3288
|
-
* @memberof Md5
|
|
3289
|
-
* @instance
|
|
3290
|
-
* @description Output hash as bytes array
|
|
3291
|
-
* @returns {Array} Bytes array
|
|
3292
|
-
* @see {@link md5.digest}
|
|
3293
|
-
* @example
|
|
3294
|
-
* hash.digest();
|
|
3295
|
-
*/
|
|
3296
|
-
Md5.prototype.digest = function () {
|
|
3297
|
-
this.finalize();
|
|
3298
|
-
|
|
3299
|
-
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3;
|
|
3300
|
-
return [
|
|
3301
|
-
h0 & 0xFF, (h0 >> 8) & 0xFF, (h0 >> 16) & 0xFF, (h0 >> 24) & 0xFF,
|
|
3302
|
-
h1 & 0xFF, (h1 >> 8) & 0xFF, (h1 >> 16) & 0xFF, (h1 >> 24) & 0xFF,
|
|
3303
|
-
h2 & 0xFF, (h2 >> 8) & 0xFF, (h2 >> 16) & 0xFF, (h2 >> 24) & 0xFF,
|
|
3304
|
-
h3 & 0xFF, (h3 >> 8) & 0xFF, (h3 >> 16) & 0xFF, (h3 >> 24) & 0xFF
|
|
3305
|
-
];
|
|
3306
|
-
};
|
|
3307
|
-
|
|
3308
|
-
/**
|
|
3309
|
-
* @method array
|
|
3310
|
-
* @memberof Md5
|
|
3311
|
-
* @instance
|
|
3312
|
-
* @description Output hash as bytes array
|
|
3313
|
-
* @returns {Array} Bytes array
|
|
3314
|
-
* @see {@link md5.array}
|
|
3315
|
-
* @example
|
|
3316
|
-
* hash.array();
|
|
3317
|
-
*/
|
|
3318
|
-
Md5.prototype.array = Md5.prototype.digest;
|
|
3319
|
-
|
|
3320
|
-
/**
|
|
3321
|
-
* @method arrayBuffer
|
|
3322
|
-
* @memberof Md5
|
|
3323
|
-
* @instance
|
|
3324
|
-
* @description Output hash as ArrayBuffer
|
|
3325
|
-
* @returns {ArrayBuffer} ArrayBuffer
|
|
3326
|
-
* @see {@link md5.arrayBuffer}
|
|
3327
|
-
* @example
|
|
3328
|
-
* hash.arrayBuffer();
|
|
3329
|
-
*/
|
|
3330
|
-
Md5.prototype.arrayBuffer = function () {
|
|
3331
|
-
this.finalize();
|
|
3332
|
-
|
|
3333
|
-
var buffer = new ArrayBuffer(16);
|
|
3334
|
-
var blocks = new Uint32Array(buffer);
|
|
3335
|
-
blocks[0] = this.h0;
|
|
3336
|
-
blocks[1] = this.h1;
|
|
3337
|
-
blocks[2] = this.h2;
|
|
3338
|
-
blocks[3] = this.h3;
|
|
3339
|
-
return buffer;
|
|
3340
|
-
};
|
|
3341
|
-
|
|
3342
|
-
/**
|
|
3343
|
-
* @method buffer
|
|
3344
|
-
* @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.
|
|
3345
|
-
* @memberof Md5
|
|
3346
|
-
* @instance
|
|
3347
|
-
* @description Output hash as ArrayBuffer
|
|
3348
|
-
* @returns {ArrayBuffer} ArrayBuffer
|
|
3349
|
-
* @see {@link md5.buffer}
|
|
3350
|
-
* @example
|
|
3351
|
-
* hash.buffer();
|
|
3352
|
-
*/
|
|
3353
|
-
Md5.prototype.buffer = Md5.prototype.arrayBuffer;
|
|
3354
|
-
|
|
3355
|
-
/**
|
|
3356
|
-
* @method base64
|
|
3357
|
-
* @memberof Md5
|
|
3358
|
-
* @instance
|
|
3359
|
-
* @description Output hash as base64 string
|
|
3360
|
-
* @returns {String} base64 string
|
|
3361
|
-
* @see {@link md5.base64}
|
|
3362
|
-
* @example
|
|
3363
|
-
* hash.base64();
|
|
3364
|
-
*/
|
|
3365
|
-
Md5.prototype.base64 = function () {
|
|
3366
|
-
var v1, v2, v3, base64Str = '', bytes = this.array();
|
|
3367
|
-
for (var i = 0; i < 15;) {
|
|
3368
|
-
v1 = bytes[i++];
|
|
3369
|
-
v2 = bytes[i++];
|
|
3370
|
-
v3 = bytes[i++];
|
|
3371
|
-
base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] +
|
|
3372
|
-
BASE64_ENCODE_CHAR[(v1 << 4 | v2 >>> 4) & 63] +
|
|
3373
|
-
BASE64_ENCODE_CHAR[(v2 << 2 | v3 >>> 6) & 63] +
|
|
3374
|
-
BASE64_ENCODE_CHAR[v3 & 63];
|
|
3375
|
-
}
|
|
3376
|
-
v1 = bytes[i];
|
|
3377
|
-
base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] +
|
|
3378
|
-
BASE64_ENCODE_CHAR[(v1 << 4) & 63] +
|
|
3379
|
-
'==';
|
|
3380
|
-
return base64Str;
|
|
3381
|
-
};
|
|
3382
|
-
|
|
3383
|
-
var exports = createMethod();
|
|
3384
|
-
|
|
3385
|
-
if (COMMON_JS) {
|
|
3386
|
-
module.exports = exports;
|
|
3387
|
-
} else {
|
|
3388
|
-
/**
|
|
3389
|
-
* @method md5
|
|
3390
|
-
* @description Md5 hash function, export to global in browsers.
|
|
3391
|
-
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
|
|
3392
|
-
* @returns {String} md5 hashes
|
|
3393
|
-
* @example
|
|
3394
|
-
* md5(''); // d41d8cd98f00b204e9800998ecf8427e
|
|
3395
|
-
* md5('The quick brown fox jumps over the lazy dog'); // 9e107d9d372bb6826bd81d3542a419d6
|
|
3396
|
-
* md5('The quick brown fox jumps over the lazy dog.'); // e4d909c290d0fb1ca068ffaddf22cbd0
|
|
3397
|
-
*
|
|
3398
|
-
* // It also supports UTF-8 encoding
|
|
3399
|
-
* md5('中文'); // a7bac2239fcdcb3a067903d8077c4a07
|
|
3400
|
-
*
|
|
3401
|
-
* // It also supports byte `Array`, `Uint8Array`, `ArrayBuffer`
|
|
3402
|
-
* md5([]); // d41d8cd98f00b204e9800998ecf8427e
|
|
3403
|
-
* md5(new Uint8Array([])); // d41d8cd98f00b204e9800998ecf8427e
|
|
3404
|
-
*/
|
|
3405
|
-
root.md5 = exports;
|
|
3406
|
-
}
|
|
3407
|
-
})();
|
|
3408
|
-
});
|
|
3409
|
-
|
|
3410
|
-
/*
|
|
3411
|
-
* [js-sha1]{@link https://github.com/emn178/js-sha1}
|
|
3412
|
-
*
|
|
3413
|
-
* @version 0.6.0
|
|
3414
|
-
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
3415
|
-
* @copyright Chen, Yi-Cyuan 2014-2017
|
|
3416
|
-
* @license MIT
|
|
3417
|
-
*/
|
|
3418
|
-
|
|
3419
|
-
var sha1 = createCommonjsModule(function (module) {
|
|
3420
|
-
/*jslint bitwise: true */
|
|
3421
|
-
(function() {
|
|
3422
|
-
|
|
3423
|
-
var root = typeof window === 'object' ? window : {};
|
|
3424
|
-
var NODE_JS = !root.JS_SHA1_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;
|
|
3425
|
-
if (NODE_JS) {
|
|
3426
|
-
root = commonjsGlobal;
|
|
3427
|
-
}
|
|
3428
|
-
var COMMON_JS = !root.JS_SHA1_NO_COMMON_JS && 'object' === 'object' && module.exports;
|
|
3429
|
-
var HEX_CHARS = '0123456789abcdef'.split('');
|
|
3430
|
-
var EXTRA = [-2147483648, 8388608, 32768, 128];
|
|
3431
|
-
var SHIFT = [24, 16, 8, 0];
|
|
3432
|
-
var OUTPUT_TYPES = ['hex', 'array', 'digest', 'arrayBuffer'];
|
|
3433
|
-
|
|
3434
|
-
var blocks = [];
|
|
3435
|
-
|
|
3436
|
-
var createOutputMethod = function (outputType) {
|
|
3437
|
-
return function (message) {
|
|
3438
|
-
return new Sha1(true).update(message)[outputType]();
|
|
3439
|
-
};
|
|
3440
|
-
};
|
|
3441
|
-
|
|
3442
|
-
var createMethod = function () {
|
|
3443
|
-
var method = createOutputMethod('hex');
|
|
3444
|
-
if (NODE_JS) {
|
|
3445
|
-
method = nodeWrap(method);
|
|
3446
|
-
}
|
|
3447
|
-
method.create = function () {
|
|
3448
|
-
return new Sha1();
|
|
3449
|
-
};
|
|
3450
|
-
method.update = function (message) {
|
|
3451
|
-
return method.create().update(message);
|
|
3452
|
-
};
|
|
3453
|
-
for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
|
|
3454
|
-
var type = OUTPUT_TYPES[i];
|
|
3455
|
-
method[type] = createOutputMethod(type);
|
|
3456
|
-
}
|
|
3457
|
-
return method;
|
|
3458
|
-
};
|
|
3459
|
-
|
|
3460
|
-
var nodeWrap = function (method) {
|
|
3461
|
-
var crypto = eval("require('crypto')");
|
|
3462
|
-
var Buffer = eval("require('buffer').Buffer");
|
|
3463
|
-
var nodeMethod = function (message) {
|
|
3464
|
-
if (typeof message === 'string') {
|
|
3465
|
-
return crypto.createHash('sha1').update(message, 'utf8').digest('hex');
|
|
3466
|
-
} else if (message.constructor === ArrayBuffer) {
|
|
3467
|
-
message = new Uint8Array(message);
|
|
3468
|
-
} else if (message.length === undefined) {
|
|
3469
|
-
return method(message);
|
|
3470
|
-
}
|
|
3471
|
-
return crypto.createHash('sha1').update(new Buffer(message)).digest('hex');
|
|
3472
|
-
};
|
|
3473
|
-
return nodeMethod;
|
|
3474
|
-
};
|
|
3475
|
-
|
|
3476
|
-
function Sha1(sharedMemory) {
|
|
3477
|
-
if (sharedMemory) {
|
|
3478
|
-
blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] =
|
|
3479
|
-
blocks[4] = blocks[5] = blocks[6] = blocks[7] =
|
|
3480
|
-
blocks[8] = blocks[9] = blocks[10] = blocks[11] =
|
|
3481
|
-
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
|
|
3482
|
-
this.blocks = blocks;
|
|
3483
|
-
} else {
|
|
3484
|
-
this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
3485
|
-
}
|
|
3486
|
-
|
|
3487
|
-
this.h0 = 0x67452301;
|
|
3488
|
-
this.h1 = 0xEFCDAB89;
|
|
3489
|
-
this.h2 = 0x98BADCFE;
|
|
3490
|
-
this.h3 = 0x10325476;
|
|
3491
|
-
this.h4 = 0xC3D2E1F0;
|
|
3492
|
-
|
|
3493
|
-
this.block = this.start = this.bytes = this.hBytes = 0;
|
|
3494
|
-
this.finalized = this.hashed = false;
|
|
3495
|
-
this.first = true;
|
|
3496
|
-
}
|
|
3497
|
-
|
|
3498
|
-
Sha1.prototype.update = function (message) {
|
|
3499
|
-
if (this.finalized) {
|
|
3500
|
-
return;
|
|
3501
|
-
}
|
|
3502
|
-
var notString = typeof(message) !== 'string';
|
|
3503
|
-
if (notString && message.constructor === root.ArrayBuffer) {
|
|
3504
|
-
message = new Uint8Array(message);
|
|
3505
|
-
}
|
|
3506
|
-
var code, index = 0, i, length = message.length || 0, blocks = this.blocks;
|
|
3507
|
-
|
|
3508
|
-
while (index < length) {
|
|
3509
|
-
if (this.hashed) {
|
|
3510
|
-
this.hashed = false;
|
|
3511
|
-
blocks[0] = this.block;
|
|
3512
|
-
blocks[16] = blocks[1] = blocks[2] = blocks[3] =
|
|
3513
|
-
blocks[4] = blocks[5] = blocks[6] = blocks[7] =
|
|
3514
|
-
blocks[8] = blocks[9] = blocks[10] = blocks[11] =
|
|
3515
|
-
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
|
|
3516
|
-
}
|
|
3517
|
-
|
|
3518
|
-
if(notString) {
|
|
3519
|
-
for (i = this.start; index < length && i < 64; ++index) {
|
|
3520
|
-
blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
|
|
3521
|
-
}
|
|
3522
|
-
} else {
|
|
3523
|
-
for (i = this.start; index < length && i < 64; ++index) {
|
|
3524
|
-
code = message.charCodeAt(index);
|
|
3525
|
-
if (code < 0x80) {
|
|
3526
|
-
blocks[i >> 2] |= code << SHIFT[i++ & 3];
|
|
3527
|
-
} else if (code < 0x800) {
|
|
3528
|
-
blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];
|
|
3529
|
-
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
|
3530
|
-
} else if (code < 0xd800 || code >= 0xe000) {
|
|
3531
|
-
blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];
|
|
3532
|
-
blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
|
|
3533
|
-
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
|
3534
|
-
} else {
|
|
3535
|
-
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
|
|
3536
|
-
blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];
|
|
3537
|
-
blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];
|
|
3538
|
-
blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
|
|
3539
|
-
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
|
3540
|
-
}
|
|
3541
|
-
}
|
|
3542
|
-
}
|
|
3543
|
-
|
|
3544
|
-
this.lastByteIndex = i;
|
|
3545
|
-
this.bytes += i - this.start;
|
|
3546
|
-
if (i >= 64) {
|
|
3547
|
-
this.block = blocks[16];
|
|
3548
|
-
this.start = i - 64;
|
|
3549
|
-
this.hash();
|
|
3550
|
-
this.hashed = true;
|
|
3551
|
-
} else {
|
|
3552
|
-
this.start = i;
|
|
3553
|
-
}
|
|
3554
|
-
}
|
|
3555
|
-
if (this.bytes > 4294967295) {
|
|
3556
|
-
this.hBytes += this.bytes / 4294967296 << 0;
|
|
3557
|
-
this.bytes = this.bytes % 4294967296;
|
|
3558
|
-
}
|
|
3559
|
-
return this;
|
|
3560
|
-
};
|
|
3561
|
-
|
|
3562
|
-
Sha1.prototype.finalize = function () {
|
|
3563
|
-
if (this.finalized) {
|
|
3564
|
-
return;
|
|
3565
|
-
}
|
|
3566
|
-
this.finalized = true;
|
|
3567
|
-
var blocks = this.blocks, i = this.lastByteIndex;
|
|
3568
|
-
blocks[16] = this.block;
|
|
3569
|
-
blocks[i >> 2] |= EXTRA[i & 3];
|
|
3570
|
-
this.block = blocks[16];
|
|
3571
|
-
if (i >= 56) {
|
|
3572
|
-
if (!this.hashed) {
|
|
3573
|
-
this.hash();
|
|
3574
|
-
}
|
|
3575
|
-
blocks[0] = this.block;
|
|
3576
|
-
blocks[16] = blocks[1] = blocks[2] = blocks[3] =
|
|
3577
|
-
blocks[4] = blocks[5] = blocks[6] = blocks[7] =
|
|
3578
|
-
blocks[8] = blocks[9] = blocks[10] = blocks[11] =
|
|
3579
|
-
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
|
|
3580
|
-
}
|
|
3581
|
-
blocks[14] = this.hBytes << 3 | this.bytes >>> 29;
|
|
3582
|
-
blocks[15] = this.bytes << 3;
|
|
3583
|
-
this.hash();
|
|
3584
|
-
};
|
|
3585
|
-
|
|
3586
|
-
Sha1.prototype.hash = function () {
|
|
3587
|
-
var a = this.h0, b = this.h1, c = this.h2, d = this.h3, e = this.h4;
|
|
3588
|
-
var f, j, t, blocks = this.blocks;
|
|
3589
|
-
|
|
3590
|
-
for(j = 16; j < 80; ++j) {
|
|
3591
|
-
t = blocks[j - 3] ^ blocks[j - 8] ^ blocks[j - 14] ^ blocks[j - 16];
|
|
3592
|
-
blocks[j] = (t << 1) | (t >>> 31);
|
|
3593
|
-
}
|
|
3594
|
-
|
|
3595
|
-
for(j = 0; j < 20; j += 5) {
|
|
3596
|
-
f = (b & c) | ((~b) & d);
|
|
3597
|
-
t = (a << 5) | (a >>> 27);
|
|
3598
|
-
e = t + f + e + 1518500249 + blocks[j] << 0;
|
|
3599
|
-
b = (b << 30) | (b >>> 2);
|
|
3600
|
-
|
|
3601
|
-
f = (a & b) | ((~a) & c);
|
|
3602
|
-
t = (e << 5) | (e >>> 27);
|
|
3603
|
-
d = t + f + d + 1518500249 + blocks[j + 1] << 0;
|
|
3604
|
-
a = (a << 30) | (a >>> 2);
|
|
3605
|
-
|
|
3606
|
-
f = (e & a) | ((~e) & b);
|
|
3607
|
-
t = (d << 5) | (d >>> 27);
|
|
3608
|
-
c = t + f + c + 1518500249 + blocks[j + 2] << 0;
|
|
3609
|
-
e = (e << 30) | (e >>> 2);
|
|
3610
|
-
|
|
3611
|
-
f = (d & e) | ((~d) & a);
|
|
3612
|
-
t = (c << 5) | (c >>> 27);
|
|
3613
|
-
b = t + f + b + 1518500249 + blocks[j + 3] << 0;
|
|
3614
|
-
d = (d << 30) | (d >>> 2);
|
|
3615
|
-
|
|
3616
|
-
f = (c & d) | ((~c) & e);
|
|
3617
|
-
t = (b << 5) | (b >>> 27);
|
|
3618
|
-
a = t + f + a + 1518500249 + blocks[j + 4] << 0;
|
|
3619
|
-
c = (c << 30) | (c >>> 2);
|
|
3620
|
-
}
|
|
3621
|
-
|
|
3622
|
-
for(; j < 40; j += 5) {
|
|
3623
|
-
f = b ^ c ^ d;
|
|
3624
|
-
t = (a << 5) | (a >>> 27);
|
|
3625
|
-
e = t + f + e + 1859775393 + blocks[j] << 0;
|
|
3626
|
-
b = (b << 30) | (b >>> 2);
|
|
3627
|
-
|
|
3628
|
-
f = a ^ b ^ c;
|
|
3629
|
-
t = (e << 5) | (e >>> 27);
|
|
3630
|
-
d = t + f + d + 1859775393 + blocks[j + 1] << 0;
|
|
3631
|
-
a = (a << 30) | (a >>> 2);
|
|
3632
|
-
|
|
3633
|
-
f = e ^ a ^ b;
|
|
3634
|
-
t = (d << 5) | (d >>> 27);
|
|
3635
|
-
c = t + f + c + 1859775393 + blocks[j + 2] << 0;
|
|
3636
|
-
e = (e << 30) | (e >>> 2);
|
|
3637
|
-
|
|
3638
|
-
f = d ^ e ^ a;
|
|
3639
|
-
t = (c << 5) | (c >>> 27);
|
|
3640
|
-
b = t + f + b + 1859775393 + blocks[j + 3] << 0;
|
|
3641
|
-
d = (d << 30) | (d >>> 2);
|
|
3642
|
-
|
|
3643
|
-
f = c ^ d ^ e;
|
|
3644
|
-
t = (b << 5) | (b >>> 27);
|
|
3645
|
-
a = t + f + a + 1859775393 + blocks[j + 4] << 0;
|
|
3646
|
-
c = (c << 30) | (c >>> 2);
|
|
3647
|
-
}
|
|
3648
|
-
|
|
3649
|
-
for(; j < 60; j += 5) {
|
|
3650
|
-
f = (b & c) | (b & d) | (c & d);
|
|
3651
|
-
t = (a << 5) | (a >>> 27);
|
|
3652
|
-
e = t + f + e - 1894007588 + blocks[j] << 0;
|
|
3653
|
-
b = (b << 30) | (b >>> 2);
|
|
3654
|
-
|
|
3655
|
-
f = (a & b) | (a & c) | (b & c);
|
|
3656
|
-
t = (e << 5) | (e >>> 27);
|
|
3657
|
-
d = t + f + d - 1894007588 + blocks[j + 1] << 0;
|
|
3658
|
-
a = (a << 30) | (a >>> 2);
|
|
3659
|
-
|
|
3660
|
-
f = (e & a) | (e & b) | (a & b);
|
|
3661
|
-
t = (d << 5) | (d >>> 27);
|
|
3662
|
-
c = t + f + c - 1894007588 + blocks[j + 2] << 0;
|
|
3663
|
-
e = (e << 30) | (e >>> 2);
|
|
3664
|
-
|
|
3665
|
-
f = (d & e) | (d & a) | (e & a);
|
|
3666
|
-
t = (c << 5) | (c >>> 27);
|
|
3667
|
-
b = t + f + b - 1894007588 + blocks[j + 3] << 0;
|
|
3668
|
-
d = (d << 30) | (d >>> 2);
|
|
3669
|
-
|
|
3670
|
-
f = (c & d) | (c & e) | (d & e);
|
|
3671
|
-
t = (b << 5) | (b >>> 27);
|
|
3672
|
-
a = t + f + a - 1894007588 + blocks[j + 4] << 0;
|
|
3673
|
-
c = (c << 30) | (c >>> 2);
|
|
3674
|
-
}
|
|
3675
|
-
|
|
3676
|
-
for(; j < 80; j += 5) {
|
|
3677
|
-
f = b ^ c ^ d;
|
|
3678
|
-
t = (a << 5) | (a >>> 27);
|
|
3679
|
-
e = t + f + e - 899497514 + blocks[j] << 0;
|
|
3680
|
-
b = (b << 30) | (b >>> 2);
|
|
3681
|
-
|
|
3682
|
-
f = a ^ b ^ c;
|
|
3683
|
-
t = (e << 5) | (e >>> 27);
|
|
3684
|
-
d = t + f + d - 899497514 + blocks[j + 1] << 0;
|
|
3685
|
-
a = (a << 30) | (a >>> 2);
|
|
3686
|
-
|
|
3687
|
-
f = e ^ a ^ b;
|
|
3688
|
-
t = (d << 5) | (d >>> 27);
|
|
3689
|
-
c = t + f + c - 899497514 + blocks[j + 2] << 0;
|
|
3690
|
-
e = (e << 30) | (e >>> 2);
|
|
3691
|
-
|
|
3692
|
-
f = d ^ e ^ a;
|
|
3693
|
-
t = (c << 5) | (c >>> 27);
|
|
3694
|
-
b = t + f + b - 899497514 + blocks[j + 3] << 0;
|
|
3695
|
-
d = (d << 30) | (d >>> 2);
|
|
3696
|
-
|
|
3697
|
-
f = c ^ d ^ e;
|
|
3698
|
-
t = (b << 5) | (b >>> 27);
|
|
3699
|
-
a = t + f + a - 899497514 + blocks[j + 4] << 0;
|
|
3700
|
-
c = (c << 30) | (c >>> 2);
|
|
3701
|
-
}
|
|
3702
|
-
|
|
3703
|
-
this.h0 = this.h0 + a << 0;
|
|
3704
|
-
this.h1 = this.h1 + b << 0;
|
|
3705
|
-
this.h2 = this.h2 + c << 0;
|
|
3706
|
-
this.h3 = this.h3 + d << 0;
|
|
3707
|
-
this.h4 = this.h4 + e << 0;
|
|
3708
|
-
};
|
|
3709
|
-
|
|
3710
|
-
Sha1.prototype.hex = function () {
|
|
3711
|
-
this.finalize();
|
|
3712
|
-
|
|
3713
|
-
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4;
|
|
3714
|
-
|
|
3715
|
-
return HEX_CHARS[(h0 >> 28) & 0x0F] + HEX_CHARS[(h0 >> 24) & 0x0F] +
|
|
3716
|
-
HEX_CHARS[(h0 >> 20) & 0x0F] + HEX_CHARS[(h0 >> 16) & 0x0F] +
|
|
3717
|
-
HEX_CHARS[(h0 >> 12) & 0x0F] + HEX_CHARS[(h0 >> 8) & 0x0F] +
|
|
3718
|
-
HEX_CHARS[(h0 >> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] +
|
|
3719
|
-
HEX_CHARS[(h1 >> 28) & 0x0F] + HEX_CHARS[(h1 >> 24) & 0x0F] +
|
|
3720
|
-
HEX_CHARS[(h1 >> 20) & 0x0F] + HEX_CHARS[(h1 >> 16) & 0x0F] +
|
|
3721
|
-
HEX_CHARS[(h1 >> 12) & 0x0F] + HEX_CHARS[(h1 >> 8) & 0x0F] +
|
|
3722
|
-
HEX_CHARS[(h1 >> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] +
|
|
3723
|
-
HEX_CHARS[(h2 >> 28) & 0x0F] + HEX_CHARS[(h2 >> 24) & 0x0F] +
|
|
3724
|
-
HEX_CHARS[(h2 >> 20) & 0x0F] + HEX_CHARS[(h2 >> 16) & 0x0F] +
|
|
3725
|
-
HEX_CHARS[(h2 >> 12) & 0x0F] + HEX_CHARS[(h2 >> 8) & 0x0F] +
|
|
3726
|
-
HEX_CHARS[(h2 >> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] +
|
|
3727
|
-
HEX_CHARS[(h3 >> 28) & 0x0F] + HEX_CHARS[(h3 >> 24) & 0x0F] +
|
|
3728
|
-
HEX_CHARS[(h3 >> 20) & 0x0F] + HEX_CHARS[(h3 >> 16) & 0x0F] +
|
|
3729
|
-
HEX_CHARS[(h3 >> 12) & 0x0F] + HEX_CHARS[(h3 >> 8) & 0x0F] +
|
|
3730
|
-
HEX_CHARS[(h3 >> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] +
|
|
3731
|
-
HEX_CHARS[(h4 >> 28) & 0x0F] + HEX_CHARS[(h4 >> 24) & 0x0F] +
|
|
3732
|
-
HEX_CHARS[(h4 >> 20) & 0x0F] + HEX_CHARS[(h4 >> 16) & 0x0F] +
|
|
3733
|
-
HEX_CHARS[(h4 >> 12) & 0x0F] + HEX_CHARS[(h4 >> 8) & 0x0F] +
|
|
3734
|
-
HEX_CHARS[(h4 >> 4) & 0x0F] + HEX_CHARS[h4 & 0x0F];
|
|
3735
|
-
};
|
|
3736
|
-
|
|
3737
|
-
Sha1.prototype.toString = Sha1.prototype.hex;
|
|
3738
|
-
|
|
3739
|
-
Sha1.prototype.digest = function () {
|
|
3740
|
-
this.finalize();
|
|
3741
|
-
|
|
3742
|
-
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4;
|
|
3743
|
-
|
|
3744
|
-
return [
|
|
3745
|
-
(h0 >> 24) & 0xFF, (h0 >> 16) & 0xFF, (h0 >> 8) & 0xFF, h0 & 0xFF,
|
|
3746
|
-
(h1 >> 24) & 0xFF, (h1 >> 16) & 0xFF, (h1 >> 8) & 0xFF, h1 & 0xFF,
|
|
3747
|
-
(h2 >> 24) & 0xFF, (h2 >> 16) & 0xFF, (h2 >> 8) & 0xFF, h2 & 0xFF,
|
|
3748
|
-
(h3 >> 24) & 0xFF, (h3 >> 16) & 0xFF, (h3 >> 8) & 0xFF, h3 & 0xFF,
|
|
3749
|
-
(h4 >> 24) & 0xFF, (h4 >> 16) & 0xFF, (h4 >> 8) & 0xFF, h4 & 0xFF
|
|
3750
|
-
];
|
|
3751
|
-
};
|
|
3752
|
-
|
|
3753
|
-
Sha1.prototype.array = Sha1.prototype.digest;
|
|
3754
|
-
|
|
3755
|
-
Sha1.prototype.arrayBuffer = function () {
|
|
3756
|
-
this.finalize();
|
|
3757
|
-
|
|
3758
|
-
var buffer = new ArrayBuffer(20);
|
|
3759
|
-
var dataView = new DataView(buffer);
|
|
3760
|
-
dataView.setUint32(0, this.h0);
|
|
3761
|
-
dataView.setUint32(4, this.h1);
|
|
3762
|
-
dataView.setUint32(8, this.h2);
|
|
3763
|
-
dataView.setUint32(12, this.h3);
|
|
3764
|
-
dataView.setUint32(16, this.h4);
|
|
3765
|
-
return buffer;
|
|
3766
|
-
};
|
|
3767
|
-
|
|
3768
|
-
var exports = createMethod();
|
|
3769
|
-
|
|
3770
|
-
if (COMMON_JS) {
|
|
3771
|
-
module.exports = exports;
|
|
3772
|
-
} else {
|
|
3773
|
-
root.sha1 = exports;
|
|
3774
|
-
}
|
|
3775
|
-
})();
|
|
3776
|
-
});
|
|
3777
|
-
|
|
3778
|
-
/** List of hex digit for fast accessing by index */
|
|
3779
|
-
var HEX_DIGITS = '0123456789abcdef'.split('');
|
|
3780
|
-
|
|
3781
|
-
/** Length of string containing uuid */
|
|
3782
|
-
var UUID_LENGTH = 36;
|
|
3783
|
-
|
|
3784
|
-
/** Regular expression for uuid testing */
|
|
3785
|
-
var UUID_REGEXP = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
3786
|
-
|
|
3787
|
-
/** Map matching of hex number and corresponding byte */
|
|
3788
|
-
var HEX_TO_BYTE_MAP = (function () {
|
|
3789
|
-
var map = {};
|
|
3790
|
-
|
|
3791
|
-
for (var i = 0; i < 256; i++) {
|
|
3792
|
-
var hex = i.toString(16);
|
|
3793
|
-
|
|
3794
|
-
map[hex.length === 1 ? '0' + hex : hex] = i;
|
|
3795
|
-
}
|
|
3796
|
-
|
|
3797
|
-
return map;
|
|
3798
|
-
})();
|
|
3799
|
-
|
|
3800
|
-
/**
|
|
3801
|
-
* Converts unsigned byte to hex representation
|
|
3802
|
-
* @param {number} ubyte The unsigned byte to convert
|
|
3803
|
-
* @returns {string} The hex representation
|
|
3804
|
-
*/
|
|
3805
|
-
var uint8ToHex = function (ubyte) {
|
|
3806
|
-
var first = ubyte >> 4;
|
|
3807
|
-
var second = ubyte - (first << 4);
|
|
3808
|
-
|
|
3809
|
-
return HEX_DIGITS[first] + HEX_DIGITS[second];
|
|
3810
|
-
};
|
|
3811
|
-
|
|
3812
|
-
/**
|
|
3813
|
-
* Converts unsigned byte buffer to hex string
|
|
3814
|
-
* @param {Uint8Array} buf The unsigned bytes buffer
|
|
3815
|
-
* @returns {string} The hex string representation
|
|
3816
|
-
*/
|
|
3817
|
-
var uint8ArrayToHex = function (buf) {
|
|
3818
|
-
var out = '';
|
|
3819
|
-
|
|
3820
|
-
for (var i = 0; i < buf.length; i++) {
|
|
3821
|
-
out += uint8ToHex(buf[i]);
|
|
3822
|
-
}
|
|
3823
|
-
|
|
3824
|
-
return out;
|
|
3825
|
-
};
|
|
3826
|
-
|
|
3827
|
-
/**
|
|
3828
|
-
* Converts string to buffer of char codes
|
|
3829
|
-
* @param {string} str The string to parse
|
|
3830
|
-
* @returns {Uint8Array} Buffer of char codes
|
|
3831
|
-
*/
|
|
3832
|
-
var stringToCharBuffer = function (str) {
|
|
3833
|
-
var escapedStr = unescape(encodeURIComponent(str));
|
|
3834
|
-
var buffer = new Uint8Array(escapedStr.length);
|
|
3835
|
-
|
|
3836
|
-
for (var i = 0; i < escapedStr.length; i++) {
|
|
3837
|
-
buffer[i] = escapedStr[i].charCodeAt(0);
|
|
3838
|
-
}
|
|
3839
|
-
|
|
3840
|
-
return buffer;
|
|
3841
|
-
};
|
|
3842
|
-
|
|
3843
|
-
/**
|
|
3844
|
-
* Generates MD5 hash from buffer
|
|
3845
|
-
* @param {Uint8Array} buf Buffer of char codes
|
|
3846
|
-
* @returns {Uint8Array} MD5 hash buffer
|
|
3847
|
-
*/
|
|
3848
|
-
var md5Hash = function (buf) {
|
|
3849
|
-
return new Uint8Array(md5.arrayBuffer(buf));
|
|
3850
|
-
};
|
|
3851
|
-
|
|
3852
|
-
/**
|
|
3853
|
-
* Generates SHA-1 hash from buffer
|
|
3854
|
-
* @param {Uint8Array} buf Buffer of char codes
|
|
3855
|
-
* @returns {Uint8Array} SHA-1 hash buffer
|
|
3856
|
-
*/
|
|
3857
|
-
var sha1Hash = function (buf) {
|
|
3858
|
-
return new Uint8Array(sha1.arrayBuffer(buf));
|
|
3859
|
-
};
|
|
3860
|
-
|
|
3861
|
-
/**
|
|
3862
|
-
* Concatenates two uint8 buffers
|
|
3863
|
-
* @param {Uint8Array} buf1 The first buffer to concatenate
|
|
3864
|
-
* @param {Uint8Array} buf2 The second buffer to concatenate
|
|
3865
|
-
* @returns {Uint8Array} Concatenation result
|
|
3866
|
-
*/
|
|
3867
|
-
var concatBuffers = function (buf1, buf2) {
|
|
3868
|
-
var out = new Uint8Array(buf1.length + buf2.length);
|
|
3869
|
-
|
|
3870
|
-
out.set(new Uint8Array(buf1), 0);
|
|
3871
|
-
out.set(new Uint8Array(buf2), buf1.byteLength);
|
|
3872
|
-
|
|
3873
|
-
return out;
|
|
3874
|
-
};
|
|
3875
|
-
|
|
3876
|
-
/**
|
|
3877
|
-
* Validates UUID
|
|
3878
|
-
* @param {string} uuid UUID to validate
|
|
3879
|
-
* @return {boolean} Validation result
|
|
3880
|
-
*/
|
|
3881
|
-
var validateUuid = function (uuid) {
|
|
3882
|
-
return typeof uuid === 'string' && uuid.length === UUID_LENGTH && UUID_REGEXP.test(uuid);
|
|
3883
|
-
};
|
|
3884
|
-
|
|
3885
|
-
/**
|
|
3886
|
-
* Parses UUID into a buffer
|
|
3887
|
-
* @param {string} uuid UUID to parse
|
|
3888
|
-
* @returns {Uint8Array} Ready buffer
|
|
3889
|
-
*/
|
|
3890
|
-
var parseUuid = function (uuid) {
|
|
3891
|
-
if (!validateUuid(uuid)) {
|
|
3892
|
-
throw TypeError('Invalid UUID');
|
|
3893
|
-
}
|
|
3894
|
-
|
|
3895
|
-
var buf = new Uint8Array(16);
|
|
3896
|
-
var strIndex = 0;
|
|
3897
|
-
var bufIndex = 0;
|
|
3898
|
-
|
|
3899
|
-
while (strIndex < uuid.length) {
|
|
3900
|
-
if (uuid[strIndex] === '-') {
|
|
3901
|
-
strIndex++;
|
|
3902
|
-
continue;
|
|
3903
|
-
}
|
|
3904
|
-
|
|
3905
|
-
var oct = (uuid[strIndex] + uuid[strIndex + 1]).toLowerCase();
|
|
3906
|
-
buf[bufIndex] = HEX_TO_BYTE_MAP[oct];
|
|
3907
|
-
|
|
3908
|
-
bufIndex++;
|
|
3909
|
-
strIndex += 2;
|
|
3910
|
-
}
|
|
3911
|
-
|
|
3912
|
-
return buf;
|
|
3913
|
-
};
|
|
3914
|
-
|
|
3915
|
-
/**
|
|
3916
|
-
* Creates uuid from hash buffer
|
|
3917
|
-
* @param {Uint8Array} hashBuffer Hash buffer
|
|
3918
|
-
* @param {3|5} version Version of uuid
|
|
3919
|
-
* @returns {string} The uuid
|
|
3920
|
-
*/
|
|
3921
|
-
var hashToUuid = function (hashBuffer, version) {
|
|
3922
|
-
return (
|
|
3923
|
-
// The low field of the timestamp
|
|
3924
|
-
uint8ArrayToHex(hashBuffer.slice(0, 4)) +
|
|
3925
|
-
'-' +
|
|
3926
|
-
// The middle field of the timestamp
|
|
3927
|
-
uint8ArrayToHex(hashBuffer.slice(4, 6)) +
|
|
3928
|
-
'-' +
|
|
3929
|
-
// The high field of the timestamp multiplexed with the version number
|
|
3930
|
-
uint8ToHex((hashBuffer[6] & 0x0f) | parseInt(version * 10, 16)) +
|
|
3931
|
-
uint8ToHex(hashBuffer[7]) +
|
|
3932
|
-
'-' +
|
|
3933
|
-
// The high field of the clock sequence multiplexed with the variant
|
|
3934
|
-
uint8ToHex((hashBuffer[8] & 0x3f) | 0x80) +
|
|
3935
|
-
// The low field of the clock sequence
|
|
3936
|
-
uint8ToHex(hashBuffer[9]) +
|
|
3937
|
-
'-' +
|
|
3938
|
-
// The spatially unique node identifier
|
|
3939
|
-
uint8ArrayToHex(hashBuffer.slice(10, 16))
|
|
3940
|
-
);
|
|
3941
|
-
};
|
|
3942
|
-
|
|
3943
|
-
var lib = {
|
|
3944
|
-
uint8ToHex: uint8ToHex,
|
|
3945
|
-
uint8ArrayToHex: uint8ArrayToHex,
|
|
3946
|
-
stringToCharBuffer: stringToCharBuffer,
|
|
3947
|
-
md5Hash: md5Hash,
|
|
3948
|
-
sha1Hash: sha1Hash,
|
|
3949
|
-
concatBuffers: concatBuffers,
|
|
3950
|
-
validateUuid: validateUuid,
|
|
3951
|
-
parseUuid: parseUuid,
|
|
3952
|
-
hashToUuid: hashToUuid,
|
|
3953
|
-
};
|
|
3954
|
-
|
|
3955
|
-
/** Uin8Array with zero items */
|
|
3956
|
-
var EMPTY_UINT8_ARRAY = new Uint8Array(0);
|
|
3957
|
-
|
|
3958
|
-
/**
|
|
3959
|
-
* Generates the Name-Based UUID hashes v3 and v5 according to RFC-4122
|
|
3960
|
-
* https://tools.ietf.org/html/rfc4122#section-4.3
|
|
3961
|
-
* @param {string} target Hashing target
|
|
3962
|
-
* @param {string} [namespace] Some name space within which generation occurs
|
|
3963
|
-
* @param {3|5} [version=5] Version of UUID. Available versions is 3 and 5
|
|
3964
|
-
* according to RFC-4122. The version is responsible for the hashing algorithm:
|
|
3965
|
-
* version 3 uses MD5, and version 5 uses SHA-1. Default is 5.
|
|
3966
|
-
* @returns {string} UUID
|
|
3967
|
-
*/
|
|
3968
|
-
function generateUuid(target, namespace, version) {
|
|
3969
|
-
if (typeof target !== 'string') {
|
|
3970
|
-
throw TypeError('Value must be string');
|
|
3971
|
-
}
|
|
3972
|
-
|
|
3973
|
-
if (typeof namespace === 'number') {
|
|
3974
|
-
return generateUuid(target, undefined, namespace);
|
|
3975
|
-
}
|
|
3976
|
-
|
|
3977
|
-
if (version == null) {
|
|
3978
|
-
return generateUuid(target, namespace, 5);
|
|
3979
|
-
}
|
|
3980
|
-
|
|
3981
|
-
if (version !== 3 && version !== 5) {
|
|
3982
|
-
throw TypeError('Version of UUID can be only 3 or 5');
|
|
3983
|
-
}
|
|
3984
|
-
|
|
3985
|
-
// Parsing target chars
|
|
3986
|
-
var targetCharBuffer = lib.stringToCharBuffer(target);
|
|
3987
|
-
var namespaceCharBuffer = typeof namespace === 'string' ? lib.parseUuid(namespace) : EMPTY_UINT8_ARRAY;
|
|
3988
|
-
|
|
3989
|
-
// Concatenation two buffers of strings to one
|
|
3990
|
-
var buffer = lib.concatBuffers(namespaceCharBuffer, targetCharBuffer);
|
|
3991
|
-
|
|
3992
|
-
// Getting hash
|
|
3993
|
-
var hash = version === 3 ? lib.md5Hash(buffer) : lib.sha1Hash(buffer);
|
|
3994
|
-
|
|
3995
|
-
return lib.hashToUuid(hash, version);
|
|
3996
|
-
}
|
|
3997
|
-
|
|
3998
|
-
/**
|
|
3999
|
-
* Export module
|
|
4000
|
-
*/
|
|
4001
|
-
var src = generateUuid;
|
|
4002
|
-
|
|
4003
|
-
var ReactGridLayout = RGL.WidthProvider(RGL__default["default"]);
|
|
4004
|
-
var GRAPHQL_API_URL = process.env.REACT_APP_WIDGET_GRAPHQL_API_URL;
|
|
4005
|
-
|
|
4006
|
-
var Dashboard = function Dashboard(_ref) {
|
|
4007
|
-
var lang = _ref.lang,
|
|
4008
|
-
widgetName = _ref.widgetName,
|
|
4009
|
-
widgetDisplayName = _ref.widgetDisplayName,
|
|
4010
|
-
widgetWidth = _ref.widgetWidth,
|
|
4011
|
-
widgetHeight = _ref.widgetHeight,
|
|
4012
|
-
Widget = _ref.Widget,
|
|
4013
|
-
editMode = _ref.editMode;
|
|
4014
|
-
|
|
4015
|
-
var _useLoginStatus = andoncloudSdk.useLoginStatus(),
|
|
4016
|
-
authResponse = _useLoginStatus.authResponse;
|
|
4017
|
-
|
|
4018
|
-
var _useState = React.useState(false),
|
|
4019
|
-
settingsModalOpened = _useState[0],
|
|
4020
|
-
setSettingsModalOpened = _useState[1];
|
|
4021
|
-
|
|
4022
|
-
var widgetId = src(widgetName);
|
|
4023
|
-
return React__default["default"].createElement(ReactGridLayout, {
|
|
4024
|
-
className: "layout",
|
|
4025
|
-
layout: [{
|
|
4026
|
-
i: widgetId,
|
|
4027
|
-
x: 0,
|
|
4028
|
-
y: 0,
|
|
4029
|
-
w: widgetWidth || 3,
|
|
4030
|
-
h: widgetHeight || 4
|
|
4031
|
-
}],
|
|
4032
|
-
draggableHandle: ".draggable-handle"
|
|
4033
|
-
}, (authResponse == null ? void 0 : authResponse.accessToken) && React__default["default"].createElement(andoncloudDashboardToolkit.WidgetCard, {
|
|
4034
|
-
key: widgetId,
|
|
4035
|
-
Widget: Widget,
|
|
4036
|
-
title: widgetDisplayName(lang),
|
|
4037
|
-
id: widgetId,
|
|
4038
|
-
url: GRAPHQL_API_URL,
|
|
4039
|
-
token: authResponse.accessToken,
|
|
4040
|
-
lang: lang,
|
|
4041
|
-
openSettingsModal: settingsModalOpened,
|
|
4042
|
-
onSettingsModalOpened: function onSettingsModalOpened() {
|
|
4043
|
-
return setSettingsModalOpened(true);
|
|
4044
|
-
},
|
|
4045
|
-
onSettingsModalClosed: function onSettingsModalClosed() {
|
|
4046
|
-
return setSettingsModalOpened(false);
|
|
4047
|
-
},
|
|
4048
|
-
editMode: editMode
|
|
4049
|
-
}));
|
|
4050
|
-
};
|
|
4051
|
-
|
|
4052
|
-
var routes = function routes(isLoggedIn, _ref) {
|
|
4053
|
-
var lang = _ref.lang,
|
|
4054
|
-
widgetName = _ref.widgetName,
|
|
4055
|
-
widgetDisplayName = _ref.widgetDisplayName,
|
|
4056
|
-
widgetWidth = _ref.widgetWidth,
|
|
4057
|
-
widgetHeight = _ref.widgetHeight,
|
|
4058
|
-
Widget = _ref.Widget,
|
|
4059
|
-
editMode = _ref.editMode;
|
|
4060
|
-
return [{
|
|
4061
|
-
path: '/',
|
|
4062
|
-
element: isLoggedIn ? React__default["default"].createElement(Dashboard, {
|
|
4063
|
-
lang: lang,
|
|
4064
|
-
widgetName: widgetName,
|
|
4065
|
-
widgetDisplayName: widgetDisplayName,
|
|
4066
|
-
widgetWidth: widgetWidth,
|
|
4067
|
-
widgetHeight: widgetHeight,
|
|
4068
|
-
Widget: Widget,
|
|
4069
|
-
editMode: editMode
|
|
4070
|
-
}) : React__default["default"].createElement(reactRouterDom.Navigate, {
|
|
4071
|
-
to: "/login"
|
|
4072
|
-
})
|
|
4073
|
-
}];
|
|
4074
|
-
};
|
|
4075
|
-
|
|
4076
|
-
var Routing = function Routing(dashboardProps) {
|
|
4077
|
-
var _useLoginStatus = andoncloudSdk.useLoginStatus(),
|
|
4078
|
-
status = _useLoginStatus.status;
|
|
4079
|
-
|
|
4080
|
-
return reactRouterDom.useRoutes(routes(status === 'connected', dashboardProps));
|
|
4081
|
-
};
|
|
4082
|
-
|
|
4083
|
-
var OAUTH2_BASE_URL = process.env.REACT_APP_DASHBOARD_OAUTH2_BASE_URL;
|
|
4084
|
-
|
|
4085
|
-
var WidgetPreview = function WidgetPreview(_ref) {
|
|
4086
|
-
var widgetName = _ref.widgetName,
|
|
4087
|
-
widgetDisplayName = _ref.widgetDisplayName,
|
|
4088
|
-
widgetWidth = _ref.widgetWidth,
|
|
4089
|
-
widgetHeight = _ref.widgetHeight,
|
|
4090
|
-
Widget = _ref.Widget;
|
|
4091
|
-
|
|
4092
|
-
var _useState = React.useState('pl'),
|
|
4093
|
-
lang = _useState[0],
|
|
4094
|
-
setLang = _useState[1];
|
|
4095
|
-
|
|
4096
|
-
var _useState2 = React.useState(true),
|
|
4097
|
-
editMode = _useState2[0],
|
|
4098
|
-
setEditMode = _useState2[1];
|
|
4099
|
-
|
|
4100
|
-
var getEditModeText = function getEditModeText() {
|
|
4101
|
-
if (editMode) {
|
|
4102
|
-
return lang === 'pl' ? 'Wyłącz tryb edycji' : 'Turn off edit mode';
|
|
4103
|
-
}
|
|
4104
|
-
|
|
4105
|
-
return lang === 'pl' ? 'Włącz tryb edycji' : 'Turn on edit mode';
|
|
4106
|
-
};
|
|
4107
|
-
|
|
4108
|
-
var menuItems = [{
|
|
4109
|
-
label: getEditModeText(),
|
|
4110
|
-
action: function action() {
|
|
4111
|
-
return setEditMode(function (current) {
|
|
4112
|
-
return !current;
|
|
4113
|
-
});
|
|
4114
|
-
}
|
|
4115
|
-
}, {
|
|
4116
|
-
label: lang === 'pl' ? 'Change language to English' : 'Zmień język na Polski',
|
|
4117
|
-
action: function action() {
|
|
4118
|
-
var newLang = lang === 'pl' ? 'en' : 'pl';
|
|
4119
|
-
setLang(newLang);
|
|
4120
|
-
andoncloudSdk.setLocale(newLang);
|
|
4121
|
-
}
|
|
4122
|
-
}];
|
|
4123
|
-
var authProps = {
|
|
4124
|
-
redirectPath: '/',
|
|
4125
|
-
clientId: 'sample-app-client-id',
|
|
4126
|
-
grantType: 'password'
|
|
4127
|
-
};
|
|
4128
|
-
var headerProps = {
|
|
4129
|
-
position: 'static',
|
|
4130
|
-
leadingText: widgetDisplayName(lang),
|
|
4131
|
-
menuProps: {
|
|
4132
|
-
items: menuItems,
|
|
4133
|
-
buttonColor: 'white'
|
|
4134
|
-
}
|
|
4135
|
-
};
|
|
4136
|
-
return React__default["default"].createElement(andoncloudSdk.App, {
|
|
4137
|
-
baseUrl: OAUTH2_BASE_URL,
|
|
4138
|
-
authProps: authProps
|
|
4139
|
-
}, React__default["default"].createElement(andoncloudSdk.Container, {
|
|
4140
|
-
headerProps: headerProps
|
|
4141
|
-
}, React__default["default"].createElement(Routing, {
|
|
4142
|
-
lang: lang,
|
|
4143
|
-
widgetName: widgetName,
|
|
4144
|
-
widgetDisplayName: widgetDisplayName,
|
|
4145
|
-
widgetWidth: widgetWidth,
|
|
4146
|
-
widgetHeight: widgetHeight,
|
|
4147
|
-
Widget: Widget,
|
|
4148
|
-
editMode: editMode
|
|
4149
|
-
})));
|
|
4150
|
-
};
|
|
4151
|
-
|
|
4152
|
-
exports.WidgetPreview = WidgetPreview;
|
|
1
|
+
var React=require("react"),andoncloudSdk=require("andoncloud-sdk"),reactRouterDom=require("react-router-dom");require("react-grid-layout/css/styles.css");var RGL=require("react-grid-layout"),andoncloudDashboardToolkit=require("andoncloud-dashboard-toolkit");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var React__default=/*#__PURE__*/_interopDefaultLegacy(React),RGL__default=/*#__PURE__*/_interopDefaultLegacy(RGL);function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var matchHtmlEntity=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,htmlEntities={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},unescapeHtmlEntity=function(e){return htmlEntities[e]},unescape$1=function(e){return e.replace(matchHtmlEntity,unescapeHtmlEntity)};function ownKeys$7(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _objectSpread$7(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$7(Object(r),!0).forEach(function(t){_defineProperty(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$7(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var defaultOptions={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:unescape$1};function setDefaults(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};defaultOptions=_objectSpread$7(_objectSpread$7({},defaultOptions),e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,_toPropertyKey(n.key),n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var initReactI18next={type:"3rdParty",init:function(e){setDefaults(e.options.react)}};function _arrayWithHoles(e){if(Array.isArray(e))return e}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}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.")}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _setPrototypeOf(e,t){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},_setPrototypeOf(e,t)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _possibleConstructorReturn(e,t){if(t&&("object"===_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _getPrototypeOf(e){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},_getPrototypeOf(e)}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _toArray(e){return _arrayWithHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableRest()}function ownKeys$6(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _objectSpread$6(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$6(Object(r),!0).forEach(function(t){_defineProperty(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$6(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}React.createContext(),_createClass(function e(){_classCallCheck(this,e),this.usedNamespaces={}},[{key:"addUsedNamespaces",value:function(e){var t=this;e.forEach(function(e){t.usedNamespaces[e]||(t.usedNamespaces[e]=!0)})}},{key:"getUsedNamespaces",value:function(){return Object.keys(this.usedNamespaces)}}]);var consoleLogger={type:"logger",log:function(e){this.output("log",e)},warn:function(e){this.output("warn",e)},error:function(e){this.output("error",e)},output:function(e,t){console&&console[e]&&console[e].apply(console,t)}},Logger=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),this.init(t,r)}return _createClass(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||consoleLogger,this.options=t,this.debug=t.debug}},{key:"setDebug",value:function(e){this.debug=e}},{key:"log",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"log","",!0)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"warn","",!0)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"error","")}},{key:"deprecate",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}},{key:"forward",value:function(e,t,r,n){return n&&!this.debug?null:("string"==typeof e[0]&&(e[0]="".concat(r).concat(this.prefix," ").concat(e[0])),this.logger[t](e))}},{key:"create",value:function(t){return new e(this.logger,_objectSpread$6(_objectSpread$6({},{prefix:"".concat(this.prefix,":").concat(t,":")}),this.options))}},{key:"clone",value:function(t){return(t=t||this.options).prefix=t.prefix||this.prefix,new e(this.logger,t)}}]),e}(),baseLogger=new Logger,EventEmitter=function(){function e(){_classCallCheck(this,e),this.observers={}}return _createClass(e,[{key:"on",value:function(e,t){var r=this;return e.split(" ").forEach(function(e){r.observers[e]=r.observers[e]||[],r.observers[e].push(t)}),this}},{key:"off",value:function(e,t){this.observers[e]&&(t?this.observers[e]=this.observers[e].filter(function(e){return e!==t}):delete this.observers[e])}},{key:"emit",value:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];if(this.observers[e]){var o=[].concat(this.observers[e]);o.forEach(function(e){e.apply(void 0,r)})}if(this.observers["*"]){var i=[].concat(this.observers["*"]);i.forEach(function(t){t.apply(t,[e].concat(r))})}}}]),e}();function defer(){var e,t,r=new Promise(function(r,n){e=r,t=n});return r.resolve=e,r.reject=t,r}function makeString(e){return null==e?"":""+e}function copy(e,t,r){e.forEach(function(e){t[e]&&(r[e]=t[e])})}function getLastOfPath(e,t,r){function n(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function o(){return!e||"string"==typeof e}for(var i="string"!=typeof t?[].concat(t):t.split(".");i.length>1;){if(o())return{};var a=n(i.shift());!e[a]&&r&&(e[a]=new r),e=Object.prototype.hasOwnProperty.call(e,a)?e[a]:{}}return o()?{}:{obj:e,k:n(i.shift())}}function setPath(e,t,r){var n=getLastOfPath(e,t,Object);n.obj[n.k]=r}function pushPath(e,t,r,n){var o=getLastOfPath(e,t,Object),i=o.obj,a=o.k;i[a]=i[a]||[],n&&(i[a]=i[a].concat(r)),n||i[a].push(r)}function getPath(e,t){var r=getLastOfPath(e,t),n=r.obj;if(n)return n[r.k]}function getPathWithDefaults(e,t,r){var n=getPath(e,r);return void 0!==n?n:getPath(t,r)}function deepExtend(e,t,r){for(var n in t)"__proto__"!==n&&"constructor"!==n&&(n in e?"string"==typeof e[n]||e[n]instanceof String||"string"==typeof t[n]||t[n]instanceof String?r&&(e[n]=t[n]):deepExtend(e[n],t[n],r):e[n]=t[n]);return e}function regexEscape(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var _entityMap={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function escape(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,function(e){return _entityMap[e]}):e}var isIE10="undefined"!=typeof window&&window.navigator&&void 0===window.navigator.userAgentData&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,chars=[" ",",","?","!",";"];function looksLikeObjectPath(e,t,r){t=t||"",r=r||"";var n=chars.filter(function(e){return t.indexOf(e)<0&&r.indexOf(e)<0});if(0===n.length)return!0;var o=new RegExp("(".concat(n.map(function(e){return"?"===e?"\\?":e}).join("|"),")")),i=!o.test(e);if(!i){var a=e.indexOf(r);a>0&&!o.test(e.substring(0,a))&&(i=!0)}return i}function ownKeys$5(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _objectSpread$5(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$5(Object(r),!0).forEach(function(t){_defineProperty(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$5(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function _createSuper$3(e){var t=_isNativeReflectConstruct$3();return function(){var r,n=_getPrototypeOf(e);if(t){var o=_getPrototypeOf(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return _possibleConstructorReturn(this,r)}}function _isNativeReflectConstruct$3(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function deepFind(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(e){if(e[t])return e[t];for(var n=t.split(r),o=e,i=0;i<n.length;++i){if(!o)return;if("string"==typeof o[n[i]]&&i+1<n.length)return;if(void 0===o[n[i]]){for(var a=2,s=n.slice(i,i+a).join(r),c=o[s];void 0===c&&n.length>i+a;)a++,c=o[s=n.slice(i,i+a).join(r)];if(void 0===c)return;if(null===c)return null;if(t.endsWith(s)){if("string"==typeof c)return c;if(s&&"string"==typeof c[s])return c[s]}var u=n.slice(i+a).join(r);return u?deepFind(c,u,r):void 0}o=o[n[i]]}return o}}var ResourceStore=function(e){_inherits(r,EventEmitter);var t=_createSuper$3(r);function r(e){var n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return _classCallCheck(this,r),n=t.call(this),isIE10&&EventEmitter.call(_assertThisInitialized(n)),n.data=e||{},n.options=o,void 0===n.options.keySeparator&&(n.options.keySeparator="."),void 0===n.options.ignoreJSONStructure&&(n.options.ignoreJSONStructure=!0),n}return _createClass(r,[{key:"addNamespaces",value:function(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,i=void 0!==n.ignoreJSONStructure?n.ignoreJSONStructure:this.options.ignoreJSONStructure,a=[e,t];r&&"string"!=typeof r&&(a=a.concat(r)),r&&"string"==typeof r&&(a=a.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(a=e.split("."));var s=getPath(this.data,a);return s||!i||"string"!=typeof r?s:deepFind(this.data&&this.data[e]&&this.data[e][t],r,o)}},{key:"addResource",value:function(e,t,r,n){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},i=this.options.keySeparator;void 0===i&&(i=".");var a=[e,t];r&&(a=a.concat(i?r.split(i):r)),e.indexOf(".")>-1&&(n=t,t=(a=e.split("."))[1]),this.addNamespaces(t),setPath(this.data,a,n),o.silent||this.emit("added",e,t,r,n)}},{key:"addResources",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var o in r)"string"!=typeof r[o]&&"[object Array]"!==Object.prototype.toString.apply(r[o])||this.addResource(e,t,o,r[o],{silent:!0});n.silent||this.emit("added",e,t,r)}},{key:"addResourceBundle",value:function(e,t,r,n,o){var i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},a=[e,t];e.indexOf(".")>-1&&(n=r,r=t,t=(a=e.split("."))[1]),this.addNamespaces(t);var s=getPath(this.data,a)||{};n?deepExtend(s,r,o):s=_objectSpread$5(_objectSpread$5({},s),r),setPath(this.data,a,s),i.silent||this.emit("added",e,t,r)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI?_objectSpread$5(_objectSpread$5({},{}),this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"hasLanguageSomeTranslations",value:function(e){var t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(function(e){return t[e]&&Object.keys(t[e]).length>0})}},{key:"toJSON",value:function(){return this.data}}]),r}(),postProcessor={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,r,n,o){var i=this;return e.forEach(function(e){i.processors[e]&&(t=i.processors[e].process(t,r,n,o))}),t}};function ownKeys$4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _objectSpread$4(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$4(Object(r),!0).forEach(function(t){_defineProperty(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$4(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function _createSuper$2(e){var t=_isNativeReflectConstruct$2();return function(){var r,n=_getPrototypeOf(e);if(t){var o=_getPrototypeOf(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return _possibleConstructorReturn(this,r)}}function _isNativeReflectConstruct$2(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}var checkedLoadedFor={},Translator=function(e){_inherits(r,EventEmitter);var t=_createSuper$2(r);function r(e){var n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return _classCallCheck(this,r),n=t.call(this),isIE10&&EventEmitter.call(_assertThisInitialized(n)),copy(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,_assertThisInitialized(n)),n.options=o,void 0===n.options.keySeparator&&(n.options.keySeparator="."),n.logger=baseLogger.create("translator"),n}return _createClass(r,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==e)return!1;var r=this.resolve(e,t);return r&&void 0!==r.res}},{key:"extractFromKey",value:function(e,t){var r=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===r&&(r=":");var n=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,o=t.ns||this.options.defaultNS||[],i=r&&e.indexOf(r)>-1,a=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||looksLikeObjectPath(e,r,n));if(i&&!a){var s=e.match(this.interpolator.nestingRegexp);if(s&&s.length>0)return{key:e,namespaces:o};var c=e.split(r);(r!==n||r===n&&this.options.ns.indexOf(c[0])>-1)&&(o=c.shift()),e=c.join(n)}return"string"==typeof o&&(o=[o]),{key:e,namespaces:o}}},{key:"translate",value:function(e,t,n){var o=this;if("object"!==_typeof(t)&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),t||(t={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var i=void 0!==t.returnDetails?t.returnDetails:this.options.returnDetails,a=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,s=this.extractFromKey(e[e.length-1],t),c=s.key,u=s.namespaces,l=u[u.length-1],f=t.lng||this.language,p=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f&&"cimode"===f.toLowerCase()){if(p){var h=t.nsSeparator||this.options.nsSeparator;return i?(d.res="".concat(l).concat(h).concat(c),d):"".concat(l).concat(h).concat(c)}return i?(d.res=c,d):c}var d=this.resolve(e,t),g=d&&d.res,y=d&&d.usedKey||c,v=d&&d.exactUsedKey||c,b=Object.prototype.toString.apply(g),m=["[object Number]","[object Function]","[object RegExp]"],S=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays,_=!this.i18nFormat||this.i18nFormat.handleAsObject,O="string"!=typeof g&&"boolean"!=typeof g&&"number"!=typeof g;if(_&&g&&O&&m.indexOf(b)<0&&("string"!=typeof S||"[object Array]"!==b)){if(!t.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var k=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,g,_objectSpread$4(_objectSpread$4({},t),{},{ns:u})):"key '".concat(c," (").concat(this.language,")' returned an object instead of string.");return i?(d.res=k,d):k}if(a){var R="[object Array]"===b,w=R?[]:{},E=R?v:y;for(var C in g)if(Object.prototype.hasOwnProperty.call(g,C)){var j="".concat(E).concat(a).concat(C);w[C]=this.translate(j,_objectSpread$4(_objectSpread$4({},t),{joinArrays:!1,ns:u})),w[C]===j&&(w[C]=g[C])}g=w}}else if(_&&"string"==typeof S&&"[object Array]"===b)(g=g.join(S))&&(g=this.extendTranslation(g,e,t,n));else{var x=!1,H=!1,P=void 0!==t.count&&"string"!=typeof t.count,A=r.hasDefaultValue(t),L=P?this.pluralResolver.getSuffix(f,t.count,t):"",N=t["defaultValue".concat(L)]||t.defaultValue;!this.isValidLookup(g)&&A&&(x=!0,g=N),this.isValidLookup(g)||(H=!0,g=c);var T=t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey,I=T&&H?void 0:g,D=A&&N!==g&&this.options.updateMissing;if(H||x||D){if(this.logger.log(D?"updateKey":"missingKey",f,l,c,D?N:g),a){var U=this.resolve(c,_objectSpread$4(_objectSpread$4({},t),{},{keySeparator:!1}));U&&U.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var F=[],B=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if("fallback"===this.options.saveMissingTo&&B&&B[0])for(var $=0;$<B.length;$++)F.push(B[$]);else"all"===this.options.saveMissingTo?F=this.languageUtils.toResolveHierarchy(t.lng||this.language):F.push(t.lng||this.language);var M=function(e,r,n){var i=A&&n!==g?n:I;o.options.missingKeyHandler?o.options.missingKeyHandler(e,l,r,i,D,t):o.backendConnector&&o.backendConnector.saveMissing&&o.backendConnector.saveMissing(e,l,r,i,D,t),o.emit("missingKey",e,l,r,g)};this.options.saveMissing&&(this.options.saveMissingPlurals&&P?F.forEach(function(e){o.pluralResolver.getSuffixes(e,t).forEach(function(r){M([e],c+r,t["defaultValue".concat(r)]||N)})}):M(F,c,N))}g=this.extendTranslation(g,e,t,d,n),H&&g===c&&this.options.appendNamespaceToMissingKey&&(g="".concat(l,":").concat(c)),(H||x)&&this.options.parseMissingKeyHandler&&(g="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?"".concat(l,":").concat(c):c,x?g:void 0):this.options.parseMissingKeyHandler(g))}return i?(d.res=g,d):g}},{key:"extendTranslation",value:function(e,t,r,n,o){var i=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,_objectSpread$4(_objectSpread$4({},this.options.interpolation.defaultVariables),r),n.usedLng,n.usedNS,n.usedKey,{resolved:n});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init(_objectSpread$4(_objectSpread$4({},r),{interpolation:_objectSpread$4(_objectSpread$4({},this.options.interpolation),r.interpolation)}));var a,s="string"==typeof e&&(r&&r.interpolation&&void 0!==r.interpolation.skipOnVariables?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(s){var c=e.match(this.interpolator.nestingRegexp);a=c&&c.length}var u=r.replace&&"string"!=typeof r.replace?r.replace:r;if(this.options.interpolation.defaultVariables&&(u=_objectSpread$4(_objectSpread$4({},this.options.interpolation.defaultVariables),u)),e=this.interpolator.interpolate(e,u,r.lng||this.language,r),s){var l=e.match(this.interpolator.nestingRegexp);a<(l&&l.length)&&(r.nest=!1)}!1!==r.nest&&(e=this.interpolator.nest(e,function(){for(var e=arguments.length,n=new Array(e),a=0;a<e;a++)n[a]=arguments[a];return o&&o[0]===n[0]&&!r.context?(i.logger.warn("It seems you are nesting recursively key: ".concat(n[0]," in key: ").concat(t[0])),null):i.translate.apply(i,n.concat([t]))},r)),r.interpolation&&this.interpolator.reset()}var f=r.postProcess||this.options.postProcess,p="string"==typeof f?[f]:f;return null!=e&&p&&p.length&&!1!==r.applyPostProcessor&&(e=postProcessor.handle(p,e,t,this.options&&this.options.postProcessPassResolved?_objectSpread$4({i18nResolved:n},r):r,this)),e}},{key:"resolve",value:function(e){var t,r,n,o,i,a=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach(function(e){if(!a.isValidLookup(t)){var c=a.extractFromKey(e,s),u=c.key;r=u;var l=c.namespaces;a.options.fallbackNS&&(l=l.concat(a.options.fallbackNS));var f=void 0!==s.count&&"string"!=typeof s.count,p=f&&!s.ordinal&&0===s.count&&a.pluralResolver.shouldUseIntlApi(),h=void 0!==s.context&&("string"==typeof s.context||"number"==typeof s.context)&&""!==s.context,d=s.lngs?s.lngs:a.languageUtils.toResolveHierarchy(s.lng||a.language,s.fallbackLng);l.forEach(function(e){a.isValidLookup(t)||(i=e,!checkedLoadedFor["".concat(d[0],"-").concat(e)]&&a.utils&&a.utils.hasLoadedNamespace&&!a.utils.hasLoadedNamespace(i)&&(checkedLoadedFor["".concat(d[0],"-").concat(e)]=!0,a.logger.warn('key "'.concat(r,'" for languages "').concat(d.join(", "),'" won\'t get resolved as namespace "').concat(i,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),d.forEach(function(r){if(!a.isValidLookup(t)){o=r;var i,c=[u];if(a.i18nFormat&&a.i18nFormat.addLookupKeys)a.i18nFormat.addLookupKeys(c,u,r,e,s);else{var l;f&&(l=a.pluralResolver.getSuffix(r,s.count,s));var d="".concat(a.options.pluralSeparator,"zero");if(f&&(c.push(u+l),p&&c.push(u+d)),h){var g="".concat(u).concat(a.options.contextSeparator).concat(s.context);c.push(g),f&&(c.push(g+l),p&&c.push(g+d))}}for(;i=c.pop();)a.isValidLookup(t)||(n=i,t=a.getResource(r,e,i,s))}}))})}}),{res:t,usedKey:r,exactUsedKey:n,usedLng:o,usedNS:i}}},{key:"isValidLookup",value:function(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,r,n):this.resourceStore.getResource(e,t,r,n)}}],[{key:"hasDefaultValue",value:function(e){var t="defaultValue";for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t===r.substring(0,t.length)&&void 0!==e[r])return!0;return!1}}]),r}();function capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)}var LanguageUtil=function(){function e(t){_classCallCheck(this,e),this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=baseLogger.create("languageUtils")}return _createClass(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return null;var t=e.split("-");return 2===t.length?null:(t.pop(),"x"===t[t.length-1].toLowerCase()?null:this.formatLanguageCode(t.join("-")))}},{key:"getLanguagePartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return e;var t=e.split("-");return this.formatLanguageCode(t[0])}},{key:"formatLanguageCode",value:function(e){if("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],r=e.split("-");return this.options.lowerCaseLng?r=r.map(function(e){return e.toLowerCase()}):2===r.length?(r[0]=r[0].toLowerCase(),r[1]=r[1].toUpperCase(),t.indexOf(r[1].toLowerCase())>-1&&(r[1]=capitalize(r[1].toLowerCase()))):3===r.length&&(r[0]=r[0].toLowerCase(),2===r[1].length&&(r[1]=r[1].toUpperCase()),"sgn"!==r[0]&&2===r[2].length&&(r[2]=r[2].toUpperCase()),t.indexOf(r[1].toLowerCase())>-1&&(r[1]=capitalize(r[1].toLowerCase())),t.indexOf(r[2].toLowerCase())>-1&&(r[2]=capitalize(r[2].toLowerCase()))),r.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isSupportedCode",value:function(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}},{key:"getBestMatchFromCodes",value:function(e){var t,r=this;return e?(e.forEach(function(e){if(!t){var n=r.formatLanguageCode(e);r.options.supportedLngs&&!r.isSupportedCode(n)||(t=n)}}),!t&&this.options.supportedLngs&&e.forEach(function(e){if(!t){var n=r.getLanguagePartFromCode(e);if(r.isSupportedCode(n))return t=n;t=r.options.supportedLngs.find(function(e){if(0===e.indexOf(n))return e})}}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),"string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];var r=e[t];return r||(r=e[this.getScriptPartFromCode(t)]),r||(r=e[this.formatLanguageCode(t)]),r||(r=e[this.getLanguagePartFromCode(t)]),r||(r=e.default),r||[]}},{key:"toResolveHierarchy",value:function(e,t){var r=this,n=this.getFallbackCodes(t||this.options.fallbackLng||[],e),o=[],i=function(e){e&&(r.isSupportedCode(e)?o.push(e):r.logger.warn("rejecting language code not found in supportedLngs: ".concat(e)))};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&i(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&i(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&i(this.getLanguagePartFromCode(e))):"string"==typeof e&&i(this.formatLanguageCode(e)),n.forEach(function(e){o.indexOf(e)<0&&i(r.formatLanguageCode(e))}),o}}]),e}(),sets=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],_rulesPluralsTypes={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(1==e||e%10==1&&e%100!=11?0:1)},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0==e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0==e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0)},22:function(e){return Number(1==e?0:2==e?1:(e<0||e>10)&&e%10==0?2:3)}},deprecatedJsonVersions=["v1","v2","v3"],suffixesOrder={zero:0,one:1,two:2,few:3,many:4,other:5};function createRules(){var e={};return sets.forEach(function(t){t.lngs.forEach(function(r){e[r]={numbers:t.nr,plurals:_rulesPluralsTypes[t.fc]}})}),e}var PluralResolver=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),this.languageUtils=t,this.options=r,this.logger=baseLogger.create("pluralResolver"),this.options.compatibilityJSON&&"v4"!==this.options.compatibilityJSON||"undefined"!=typeof Intl&&Intl.PluralRules||(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=createRules()}return _createClass(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(e,{type:t.ordinal?"ordinal":"cardinal"})}catch(e){return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this.getRule(e,t);return this.shouldUseIntlApi()?r&&r.resolvedOptions().pluralCategories.length>1:r&&r.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(e,r).map(function(e){return"".concat(t).concat(e)})}},{key:"getSuffixes",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getRule(e,r);return n?this.shouldUseIntlApi()?n.resolvedOptions().pluralCategories.sort(function(e,t){return suffixesOrder[e]-suffixesOrder[t]}).map(function(e){return"".concat(t.options.prepend).concat(e)}):n.numbers.map(function(n){return t.getSuffix(e,n,r)}):[]}},{key:"getSuffix",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this.getRule(e,r);return n?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(n.select(t)):this.getSuffixRetroCompatible(n,t):(this.logger.warn("no plural rule found for: ".concat(e)),"")}},{key:"getSuffixRetroCompatible",value:function(e,t){var r=this,n=e.plurals(e.noAbs?t:Math.abs(t)),o=e.numbers[n];this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]&&(2===o?o="plural":1===o&&(o=""));var i=function(){return r.options.prepend&&o.toString()?r.options.prepend+o.toString():o.toString()};return"v1"===this.options.compatibilityJSON?1===o?"":"number"==typeof o?"_plural_".concat(o.toString()):i():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?i():this.options.prepend&&n.toString()?this.options.prepend+n.toString():n.toString()}},{key:"shouldUseIntlApi",value:function(){return!deprecatedJsonVersions.includes(this.options.compatibilityJSON)}}]),e}();function ownKeys$3(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _objectSpread$3(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$3(Object(r),!0).forEach(function(t){_defineProperty(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$3(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var Interpolator=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};_classCallCheck(this,e),this.logger=baseLogger.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return _createClass(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:escape,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?regexEscape(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?regexEscape(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?regexEscape(t.nestingPrefix):t.nestingPrefixEscaped||regexEscape("$t("),this.nestingSuffix=t.nestingSuffix?regexEscape(t.nestingSuffix):t.nestingSuffixEscaped||regexEscape(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&t.alwaysFormat,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var e="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(e,"g");var t="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(t,"g");var r="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(r,"g")}},{key:"interpolate",value:function(e,t,r,n){var o,i,a,s=this,c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function u(e){return e.replace(/\$/g,"$$$$")}var l=function(e){if(e.indexOf(s.formatSeparator)<0){var o=getPathWithDefaults(t,c,e);return s.alwaysFormat?s.format(o,void 0,r,_objectSpread$3(_objectSpread$3(_objectSpread$3({},n),t),{},{interpolationkey:e})):o}var i=e.split(s.formatSeparator),a=i.shift().trim(),u=i.join(s.formatSeparator).trim();return s.format(getPathWithDefaults(t,c,a),u,r,_objectSpread$3(_objectSpread$3(_objectSpread$3({},n),t),{},{interpolationkey:a}))};this.resetRegExp();var f=n&&n.missingInterpolationHandler||this.options.missingInterpolationHandler,p=n&&n.interpolation&&void 0!==n.interpolation.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:function(e){return u(e)}},{regex:this.regexp,safeValue:function(e){return u(s.escapeValue?s.escape(e):e)}}].forEach(function(t){for(a=0;o=t.regex.exec(e);){var r=o[1].trim();if(void 0===(i=l(r)))if("function"==typeof f){var c=f(e,o,n);i="string"==typeof c?c:""}else if(n&&n.hasOwnProperty(r))i="";else{if(p){i=o[0];continue}s.logger.warn("missed to pass in variable ".concat(r," for interpolating ").concat(e)),i=""}else"string"==typeof i||s.useRawValueToEscape||(i=makeString(i));var u=t.safeValue(i);if(e=e.replace(o[0],u),p?(t.regex.lastIndex+=i.length,t.regex.lastIndex-=o[0].length):t.regex.lastIndex=0,++a>=s.maxReplaces)break}}),e}},{key:"nest",value:function(e,t){var r,n,o,i=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};function s(e,t){var r=this.nestingOptionsSeparator;if(e.indexOf(r)<0)return e;var n=e.split(new RegExp("".concat(r,"[ ]*{"))),i="{".concat(n[1]);e=n[0];var a=(i=this.interpolate(i,o)).match(/'/g),s=i.match(/"/g);(a&&a.length%2==0&&!s||s.length%2!=0)&&(i=i.replace(/'/g,'"'));try{o=JSON.parse(i),t&&(o=_objectSpread$3(_objectSpread$3({},t),o))}catch(t){return this.logger.warn("failed parsing options string in nesting for key ".concat(e),t),"".concat(e).concat(r).concat(i)}return delete o.defaultValue,e}for(;r=this.nestingRegexp.exec(e);){var c=[];(o=(o=_objectSpread$3({},a)).replace&&"string"!=typeof o.replace?o.replace:o).applyPostProcessor=!1,delete o.defaultValue;var u=!1;if(-1!==r[0].indexOf(this.formatSeparator)&&!/{.*}/.test(r[1])){var l=r[1].split(this.formatSeparator).map(function(e){return e.trim()});r[1]=l.shift(),c=l,u=!0}if((n=t(s.call(this,r[1].trim(),o),o))&&r[0]===e&&"string"!=typeof n)return n;"string"!=typeof n&&(n=makeString(n)),n||(this.logger.warn("missed to resolve ".concat(r[1]," for nesting ").concat(e)),n=""),u&&(n=c.reduce(function(e,t){return i.format(e,t,a.lng,_objectSpread$3(_objectSpread$3({},a),{},{interpolationkey:r[1].trim()}))},n.trim())),e=e.replace(r[0],n),this.regexp.lastIndex=0}return e}}]),e}();function ownKeys$2(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _objectSpread$2(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$2(Object(r),!0).forEach(function(t){_defineProperty(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$2(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function parseFormatStr(e){var t=e.toLowerCase().trim(),r={};if(e.indexOf("(")>-1){var n=e.split("(");t=n[0].toLowerCase().trim();var o=n[1].substring(0,n[1].length-1);"currency"===t&&o.indexOf(":")<0?r.currency||(r.currency=o.trim()):"relativetime"===t&&o.indexOf(":")<0?r.range||(r.range=o.trim()):o.split(";").forEach(function(e){if(e){var t=_toArray(e.split(":")),n=t[0],o=t.slice(1).join(":").trim().replace(/^'+|'+$/g,"");r[n.trim()]||(r[n.trim()]=o),"false"===o&&(r[n.trim()]=!1),"true"===o&&(r[n.trim()]=!0),isNaN(o)||(r[n.trim()]=parseInt(o,10))}})}return{formatName:t,formatOptions:r}}function createCachedFormatter(e){var t={};return function(r,n,o){var i=n+JSON.stringify(o),a=t[i];return a||(a=e(n,o),t[i]=a),a(r)}}var Formatter=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};_classCallCheck(this,e),this.logger=baseLogger.create("formatter"),this.options=t,this.formats={number:createCachedFormatter(function(e,t){var r=new Intl.NumberFormat(e,t);return function(e){return r.format(e)}}),currency:createCachedFormatter(function(e,t){var r=new Intl.NumberFormat(e,_objectSpread$2(_objectSpread$2({},t),{},{style:"currency"}));return function(e){return r.format(e)}}),datetime:createCachedFormatter(function(e,t){var r=new Intl.DateTimeFormat(e,_objectSpread$2({},t));return function(e){return r.format(e)}}),relativetime:createCachedFormatter(function(e,t){var r=new Intl.RelativeTimeFormat(e,_objectSpread$2({},t));return function(e){return r.format(e,t.range||"day")}}),list:createCachedFormatter(function(e,t){var r=new Intl.ListFormat(e,_objectSpread$2({},t));return function(e){return r.format(e)}})},this.init(t)}return _createClass(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}},r=t.interpolation;this.formatSeparator=r.formatSeparator?r.formatSeparator:r.formatSeparator||","}},{key:"add",value:function(e,t){this.formats[e.toLowerCase().trim()]=t}},{key:"addCached",value:function(e,t){this.formats[e.toLowerCase().trim()]=createCachedFormatter(t)}},{key:"format",value:function(e,t,r,n){var o=this;return t.split(this.formatSeparator).reduce(function(e,t){var i=parseFormatStr(t),a=i.formatName,s=i.formatOptions;if(o.formats[a]){var c=e;try{var u=n&&n.formatParams&&n.formatParams[n.interpolationkey]||{};c=o.formats[a](e,u.locale||u.lng||n.locale||n.lng||r,_objectSpread$2(_objectSpread$2(_objectSpread$2({},s),n),u))}catch(e){o.logger.warn(e)}return c}return o.logger.warn("there was no format function for ".concat(a)),e},e)}}]),e}();function ownKeys$1(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _objectSpread$1(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$1(Object(r),!0).forEach(function(t){_defineProperty(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$1(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function _createSuper$1(e){var t=_isNativeReflectConstruct$1();return function(){var r,n=_getPrototypeOf(e);if(t){var o=_getPrototypeOf(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return _possibleConstructorReturn(this,r)}}function _isNativeReflectConstruct$1(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function removePending(e,t){void 0!==e.pending[t]&&(delete e.pending[t],e.pendingCount--)}var Connector=function(e){_inherits(r,EventEmitter);var t=_createSuper$1(r);function r(e,n,o){var i,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return _classCallCheck(this,r),i=t.call(this),isIE10&&EventEmitter.call(_assertThisInitialized(i)),i.backend=e,i.store=n,i.services=o,i.languageUtils=o.languageUtils,i.options=a,i.logger=baseLogger.create("backendConnector"),i.waitingReads=[],i.maxParallelReads=a.maxParallelReads||10,i.readingCalls=0,i.maxRetries=a.maxRetries>=0?a.maxRetries:5,i.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,i.state={},i.queue=[],i.backend&&i.backend.init&&i.backend.init(o,a.backend,a),i}return _createClass(r,[{key:"queueLoad",value:function(e,t,r,n){var o=this,i={},a={},s={},c={};return e.forEach(function(e){var n=!0;t.forEach(function(t){var s="".concat(e,"|").concat(t);!r.reload&&o.store.hasResourceBundle(e,t)?o.state[s]=2:o.state[s]<0||(1===o.state[s]?void 0===a[s]&&(a[s]=!0):(o.state[s]=1,n=!1,void 0===a[s]&&(a[s]=!0),void 0===i[s]&&(i[s]=!0),void 0===c[t]&&(c[t]=!0)))}),n||(s[e]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:n}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(s),toLoadNamespaces:Object.keys(c)}}},{key:"loaded",value:function(e,t,r){var n=e.split("|"),o=n[0],i=n[1];t&&this.emit("failedLoading",o,i,t),r&&this.store.addResourceBundle(o,i,r),this.state[e]=t?-1:2;var a={};this.queue.forEach(function(r){pushPath(r.loaded,[o],i),removePending(r,e),t&&r.errors.push(t),0!==r.pendingCount||r.done||(Object.keys(r.loaded).forEach(function(e){a[e]||(a[e]={});var t=r.loaded[e];t.length&&t.forEach(function(t){void 0===a[e][t]&&(a[e][t]=!0)})}),r.done=!0,r.errors.length?r.callback(r.errors):r.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(function(e){return!e.done})}},{key:"read",value:function(e,t,r){var n=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads)this.waitingReads.push({lng:e,ns:t,fcName:r,tried:o,wait:i,callback:a});else{this.readingCalls++;var s=function(s,c){if(n.readingCalls--,n.waitingReads.length>0){var u=n.waitingReads.shift();n.read(u.lng,u.ns,u.fcName,u.tried,u.wait,u.callback)}s&&c&&o<n.maxRetries?setTimeout(function(){n.read.call(n,e,t,r,o+1,2*i,a)},i):a(s,c)},c=this.backend[r].bind(this.backend);if(2!==c.length)return c(e,t,s);try{var u=c(e,t);u&&"function"==typeof u.then?u.then(function(e){return s(null,e)}).catch(s):s(null,u)}catch(e){s(e)}}}},{key:"prepareLoading",value:function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),o&&o();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var i=this.queueLoad(e,t,n,o);if(!i.toLoad.length)return i.pending.length||o(),null;i.toLoad.forEach(function(e){r.loadOne(e)})}},{key:"load",value:function(e,t,r){this.prepareLoading(e,t,{},r)}},{key:"reload",value:function(e,t,r){this.prepareLoading(e,t,{reload:!0},r)}},{key:"loadOne",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=e.split("|"),o=n[0],i=n[1];this.read(o,i,"read",void 0,void 0,function(n,a){n&&t.logger.warn("".concat(r,"loading namespace ").concat(i," for language ").concat(o," failed"),n),!n&&a&&t.logger.log("".concat(r,"loaded namespace ").concat(i," for language ").concat(o),a),t.loaded(e,n,a)})}},{key:"saveMissing",value:function(e,t,r,n,o){var i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:function(){};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t))this.logger.warn('did not save key "'.concat(r,'" as the namespace "').concat(t,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");else if(null!=r&&""!==r){if(this.backend&&this.backend.create){var s=_objectSpread$1(_objectSpread$1({},i),{},{isUpdate:o}),c=this.backend.create.bind(this.backend);if(c.length<6)try{var u;(u=5===c.length?c(e,t,r,n,s):c(e,t,r,n))&&"function"==typeof u.then?u.then(function(e){return a(null,e)}).catch(a):a(null,u)}catch(e){a(e)}else c(e,t,r,n,a,s)}e&&e[0]&&this.store.addResource(e[0],t,r,n)}}}]),r}();function get(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if("object"===_typeof(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===_typeof(e[2])||"object"===_typeof(e[3])){var r=e[3]||e[2];Object.keys(r).forEach(function(e){t[e]=r[e]})}return t},interpolation:{escapeValue:!0,format:function(e,t,r,n){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function transformOptions(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach(function(t){_defineProperty(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function _createSuper(e){var t=_isNativeReflectConstruct();return function(){var r,n=_getPrototypeOf(e);if(t){var o=_getPrototypeOf(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return _possibleConstructorReturn(this,r)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function noop(){}function bindMemberFunctions(e){Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(function(t){"function"==typeof e[t]&&(e[t]=e[t].bind(e))})}var I18n=function(e){_inherits(r,EventEmitter);var t=_createSuper(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=arguments.length>1?arguments[1]:void 0;if(_classCallCheck(this,r),e=t.call(this),isIE10&&EventEmitter.call(_assertThisInitialized(e)),e.options=transformOptions(n),e.services={},e.logger=baseLogger,e.modules={external:[]},bindMemberFunctions(_assertThisInitialized(e)),o&&!e.isInitialized&&!n.isClone){if(!e.options.initImmediate)return e.init(n,o),_possibleConstructorReturn(e,_assertThisInitialized(e));setTimeout(function(){e.init(n,o)},0)}return e}return _createClass(r,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;"function"==typeof t&&(r=t,t={}),!t.defaultNS&&!1!==t.defaultNS&&t.ns&&("string"==typeof t.ns?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));var n=get();function o(e){return e?"function"==typeof e?new e:e:null}if(this.options=_objectSpread(_objectSpread(_objectSpread({},n),this.options),transformOptions(t)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=_objectSpread(_objectSpread({},n.interpolation),this.options.interpolation)),void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),!this.options.isClone){var i;baseLogger.init(this.modules.logger?o(this.modules.logger):null,this.options),this.modules.formatter?i=this.modules.formatter:"undefined"!=typeof Intl&&(i=Formatter);var a=new LanguageUtil(this.options);this.store=new ResourceStore(this.options.resources,this.options);var s=this.services;s.logger=baseLogger,s.resourceStore=this.store,s.languageUtils=a,s.pluralResolver=new PluralResolver(a,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),!i||this.options.interpolation.format&&this.options.interpolation.format!==n.interpolation.format||(s.formatter=o(i),s.formatter.init(s,this.options),this.options.interpolation.format=s.formatter.format.bind(s.formatter)),s.interpolator=new Interpolator(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},s.backendConnector=new Connector(o(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.on("*",function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];e.emit.apply(e,[t].concat(n))}),this.modules.languageDetector&&(s.languageDetector=o(this.modules.languageDetector),s.languageDetector.init&&s.languageDetector.init(s,this.options.detection,this.options)),this.modules.i18nFormat&&(s.i18nFormat=o(this.modules.i18nFormat),s.i18nFormat.init&&s.i18nFormat.init(this)),this.translator=new Translator(this.services,this.options),this.translator.on("*",function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];e.emit.apply(e,[t].concat(n))}),this.modules.external.forEach(function(t){t.init&&t.init(e)})}if(this.format=this.options.interpolation.format,r||(r=noop),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){var c=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);c.length>0&&"dev"!==c[0]&&(this.options.lng=c[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined");var u=["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"];u.forEach(function(t){e[t]=function(){var r;return(r=e.store)[t].apply(r,arguments)}});var l=["addResource","addResources","addResourceBundle","removeResourceBundle"];l.forEach(function(t){e[t]=function(){var r;return(r=e.store)[t].apply(r,arguments),e}});var f=defer(),p=function(){var t=function(t,n){e.isInitialized&&!e.initializedStoreOnce&&e.logger.warn("init: i18next is already initialized. You should call init just once!"),e.isInitialized=!0,e.options.isClone||e.logger.log("initialized",e.options),e.emit("initialized",e.options),f.resolve(n),r(t,n)};if(e.languages&&"v1"!==e.options.compatibilityAPI&&!e.isInitialized)return t(null,e.t.bind(e));e.changeLanguage(e.options.lng,t)};return this.options.resources||!this.options.initImmediate?p():setTimeout(p,0),f}},{key:"loadResources",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:noop,n=r,o="string"==typeof e?e:this.language;if("function"==typeof e&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(o&&"cimode"===o.toLowerCase())return n();var i=[],a=function(e){e&&t.services.languageUtils.toResolveHierarchy(e).forEach(function(e){i.indexOf(e)<0&&i.push(e)})};if(o)a(o);else{var s=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);s.forEach(function(e){return a(e)})}this.options.preload&&this.options.preload.forEach(function(e){return a(e)}),this.services.backendConnector.load(i,this.options.ns,function(e){e||t.resolvedLanguage||!t.language||t.setResolvedLanguage(t.language),n(e)})}else n(null)}},{key:"reloadResources",value:function(e,t,r){var n=defer();return e||(e=this.languages),t||(t=this.options.ns),r||(r=noop),this.services.backendConnector.reload(e,t,function(e){n.resolve(),r(e)}),n}},{key:"use",value:function(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&postProcessor.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"setResolvedLanguage",value:function(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1))for(var t=0;t<this.languages.length;t++){var r=this.languages[t];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}}},{key:"changeLanguage",value:function(e,t){var r=this;this.isLanguageChangingTo=e;var n=defer();this.emit("languageChanging",e);var o=function(e){r.language=e,r.languages=r.services.languageUtils.toResolveHierarchy(e),r.resolvedLanguage=void 0,r.setResolvedLanguage(e)},i=function(i){e||i||!r.services.languageDetector||(i=[]);var a="string"==typeof i?i:r.services.languageUtils.getBestMatchFromCodes(i);a&&(r.language||o(a),r.translator.language||r.translator.changeLanguage(a),r.services.languageDetector&&r.services.languageDetector.cacheUserLanguage&&r.services.languageDetector.cacheUserLanguage(a)),r.loadResources(a,function(e){!function(e,i){i?(o(i),r.translator.changeLanguage(i),r.isLanguageChangingTo=void 0,r.emit("languageChanged",i),r.logger.log("languageChanged",i)):r.isLanguageChangingTo=void 0,n.resolve(function(){return r.t.apply(r,arguments)}),t&&t(e,function(){return r.t.apply(r,arguments)})}(e,a)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(i):this.services.languageDetector.detect(i):i(e):i(this.services.languageDetector.detect()),n}},{key:"getFixedT",value:function(e,t,r){var n=this,o=function e(t,o){var i;if("object"!==_typeof(o)){for(var a=arguments.length,s=new Array(a>2?a-2:0),c=2;c<a;c++)s[c-2]=arguments[c];i=n.options.overloadTranslationOptionHandler([t,o].concat(s))}else i=_objectSpread({},o);i.lng=i.lng||e.lng,i.lngs=i.lngs||e.lngs,i.ns=i.ns||e.ns,i.keyPrefix=i.keyPrefix||r||e.keyPrefix;var u,l=n.options.keySeparator||".";return u=i.keyPrefix&&Array.isArray(t)?t.map(function(e){return"".concat(i.keyPrefix).concat(l).concat(e)}):i.keyPrefix?"".concat(i.keyPrefix).concat(l).concat(t):t,n.t(u,i)};return"string"==typeof e?o.lng=e:o.lngs=e,o.ns=t,o.keyPrefix=r,o}},{key:"t",value:function(){var e;return this.translator&&(e=this.translator).translate.apply(e,arguments)}},{key:"exists",value:function(){var e;return this.translator&&(e=this.translator).exists.apply(e,arguments)}},{key:"setDefaultNamespace",value:function(e){this.options.defaultNS=e}},{key:"hasLoadedNamespace",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var n=this.resolvedLanguage||this.languages[0],o=!!this.options&&this.options.fallbackLng,i=this.languages[this.languages.length-1];if("cimode"===n.toLowerCase())return!0;var a=function(e,r){var n=t.services.backendConnector.state["".concat(e,"|").concat(r)];return-1===n||2===n};if(r.precheck){var s=r.precheck(this,a);if(void 0!==s)return s}return!(!this.hasResourceBundle(n,e)&&this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages)&&(!a(n,e)||o&&!a(i,e)))}},{key:"loadNamespaces",value:function(e,t){var r=this,n=defer();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach(function(e){r.options.ns.indexOf(e)<0&&r.options.ns.push(e)}),this.loadResources(function(e){n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var r=defer();"string"==typeof e&&(e=[e]);var n=this.options.preload||[],o=e.filter(function(e){return n.indexOf(e)<0});return o.length?(this.options.preload=n.concat(o),this.loadResources(function(e){r.resolve(),t&&t(e)}),r):(t&&t(),Promise.resolve())}},{key:"dir",value:function(e){if(e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!e)return"rtl";var t=this.services&&this.services.languageUtils||new LanguageUtil(get());return["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(t.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}},{key:"cloneInstance",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:noop,o=_objectSpread(_objectSpread(_objectSpread({},this.options),t),{isClone:!0}),i=new r(o);void 0===t.debug&&void 0===t.prefix||(i.logger=i.logger.clone(t));var a=["store","services","language"];return a.forEach(function(t){i[t]=e[t]}),i.services=_objectSpread({},this.services),i.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},i.translator=new Translator(i.services,i.options),i.translator.on("*",function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];i.emit.apply(i,[e].concat(r))}),i.init(o,n),i.translator.options=i.options,i.translator.backendConnector.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},i}},{key:"toJSON",value:function(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}]),r}();_defineProperty(I18n,"createInstance",function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return new I18n(e,t)});var instance=I18n.createInstance();instance.createInstance=I18n.createInstance;var en={},pl={},resources={en:{translation:en},pl:{translation:pl}};instance.use(initReactI18next).init({resources:resources,lng:"pl",interpolation:{escapeValue:!1}});var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(e){var t={exports:{}};return e(t,t.exports),t.exports}var md5=createCommonjsModule(function(module){(function(){var ERROR="input is invalid type",WINDOW="object"==typeof window,root=WINDOW?window:{};root.JS_MD5_NO_WINDOW&&(WINDOW=!1);var WEB_WORKER=!WINDOW&&"object"==typeof self,NODE_JS=!root.JS_MD5_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;NODE_JS?root=commonjsGlobal:WEB_WORKER&&(root=self);var COMMON_JS=!root.JS_MD5_NO_COMMON_JS&&module.exports,ARRAY_BUFFER=!root.JS_MD5_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,HEX_CHARS="0123456789abcdef".split(""),EXTRA=[128,32768,8388608,-2147483648],SHIFT=[0,8,16,24],OUTPUT_TYPES=["hex","array","digest","buffer","arrayBuffer","base64"],BASE64_ENCODE_CHAR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),blocks=[],buffer8;if(ARRAY_BUFFER){var buffer=new ArrayBuffer(68);buffer8=new Uint8Array(buffer),blocks=new Uint32Array(buffer)}!root.JS_MD5_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!ARRAY_BUFFER||!root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});var createOutputMethod=function(e){return function(t){return new Md5(!0).update(t)[e]()}},createMethod=function(){var e=createOutputMethod("hex");NODE_JS&&(e=nodeWrap(e)),e.create=function(){return new Md5},e.update=function(t){return e.create().update(t)};for(var t=0;t<OUTPUT_TYPES.length;++t){var r=OUTPUT_TYPES[t];e[r]=createOutputMethod(r)}return e},nodeWrap=function(method){var crypto=eval("require('crypto')"),Buffer=eval("require('buffer').Buffer"),nodeMethod=function(e){if("string"==typeof e)return crypto.createHash("md5").update(e,"utf8").digest("hex");if(null==e)throw ERROR;return e.constructor===ArrayBuffer&&(e=new Uint8Array(e)),Array.isArray(e)||ArrayBuffer.isView(e)||e.constructor===Buffer?crypto.createHash("md5").update(new Buffer(e)).digest("hex"):method(e)};return nodeMethod};function Md5(e){if(e)blocks[0]=blocks[16]=blocks[1]=blocks[2]=blocks[3]=blocks[4]=blocks[5]=blocks[6]=blocks[7]=blocks[8]=blocks[9]=blocks[10]=blocks[11]=blocks[12]=blocks[13]=blocks[14]=blocks[15]=0,this.blocks=blocks,this.buffer8=buffer8;else if(ARRAY_BUFFER){var t=new ArrayBuffer(68);this.buffer8=new Uint8Array(t),this.blocks=new Uint32Array(t)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}Md5.prototype.update=function(e){if(!this.finalized){var t,r=typeof e;if("string"!==r){if("object"!==r)throw ERROR;if(null===e)throw ERROR;if(ARRAY_BUFFER&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||ARRAY_BUFFER&&ArrayBuffer.isView(e)))throw ERROR;t=!0}for(var n,o,i=0,a=e.length,s=this.blocks,c=this.buffer8;i<a;){if(this.hashed&&(this.hashed=!1,s[0]=s[16],s[16]=s[1]=s[2]=s[3]=s[4]=s[5]=s[6]=s[7]=s[8]=s[9]=s[10]=s[11]=s[12]=s[13]=s[14]=s[15]=0),t)if(ARRAY_BUFFER)for(o=this.start;i<a&&o<64;++i)c[o++]=e[i];else for(o=this.start;i<a&&o<64;++i)s[o>>2]|=e[i]<<SHIFT[3&o++];else if(ARRAY_BUFFER)for(o=this.start;i<a&&o<64;++i)(n=e.charCodeAt(i))<128?c[o++]=n:n<2048?(c[o++]=192|n>>6,c[o++]=128|63&n):n<55296||n>=57344?(c[o++]=224|n>>12,c[o++]=128|n>>6&63,c[o++]=128|63&n):(n=65536+((1023&n)<<10|1023&e.charCodeAt(++i)),c[o++]=240|n>>18,c[o++]=128|n>>12&63,c[o++]=128|n>>6&63,c[o++]=128|63&n);else for(o=this.start;i<a&&o<64;++i)(n=e.charCodeAt(i))<128?s[o>>2]|=n<<SHIFT[3&o++]:n<2048?(s[o>>2]|=(192|n>>6)<<SHIFT[3&o++],s[o>>2]|=(128|63&n)<<SHIFT[3&o++]):n<55296||n>=57344?(s[o>>2]|=(224|n>>12)<<SHIFT[3&o++],s[o>>2]|=(128|n>>6&63)<<SHIFT[3&o++],s[o>>2]|=(128|63&n)<<SHIFT[3&o++]):(n=65536+((1023&n)<<10|1023&e.charCodeAt(++i)),s[o>>2]|=(240|n>>18)<<SHIFT[3&o++],s[o>>2]|=(128|n>>12&63)<<SHIFT[3&o++],s[o>>2]|=(128|n>>6&63)<<SHIFT[3&o++],s[o>>2]|=(128|63&n)<<SHIFT[3&o++]);this.lastByteIndex=o,this.bytes+=o-this.start,o>=64?(this.start=o-64,this.hash(),this.hashed=!0):this.start=o}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},Md5.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[t>>2]|=EXTRA[3&t],t>=56&&(this.hashed||this.hash(),e[0]=e[16],e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.bytes<<3,e[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},Md5.prototype.hash=function(){var e,t,r,n,o,i,a=this.blocks;this.first?t=((t=((e=((e=a[0]-680876937)<<7|e>>>25)-271733879<<0)^(r=((r=(-271733879^(n=((n=(-1732584194^2004318071&e)+a[1]-117830708)<<12|n>>>20)+e<<0)&(-271733879^e))+a[2]-1126478375)<<17|r>>>15)+n<<0)&(n^e))+a[3]-1316259209)<<22|t>>>10)+r<<0:(e=this.h0,t=this.h1,t=((t+=((e=((e+=((n=this.h3)^t&((r=this.h2)^n))+a[0]-680876936)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+a[1]-389564586)<<12|n>>>20)+e<<0)&(e^t))+a[2]+606105819)<<17|r>>>15)+n<<0)&(n^e))+a[3]-1044525330)<<22|t>>>10)+r<<0),t=((t+=((e=((e+=(n^t&(r^n))+a[4]-176418897)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+a[5]+1200080426)<<12|n>>>20)+e<<0)&(e^t))+a[6]-1473231341)<<17|r>>>15)+n<<0)&(n^e))+a[7]-45705983)<<22|t>>>10)+r<<0,t=((t+=((e=((e+=(n^t&(r^n))+a[8]+1770035416)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+a[9]-1958414417)<<12|n>>>20)+e<<0)&(e^t))+a[10]-42063)<<17|r>>>15)+n<<0)&(n^e))+a[11]-1990404162)<<22|t>>>10)+r<<0,t=((t+=((e=((e+=(n^t&(r^n))+a[12]+1804603682)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+a[13]-40341101)<<12|n>>>20)+e<<0)&(e^t))+a[14]-1502002290)<<17|r>>>15)+n<<0)&(n^e))+a[15]+1236535329)<<22|t>>>10)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+a[1]-165796510)<<5|e>>>27)+t<<0)^t))+a[6]-1069501632)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+a[11]+643717713)<<14|r>>>18)+n<<0)^n))+a[0]-373897302)<<20|t>>>12)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+a[5]-701558691)<<5|e>>>27)+t<<0)^t))+a[10]+38016083)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+a[15]-660478335)<<14|r>>>18)+n<<0)^n))+a[4]-405537848)<<20|t>>>12)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+a[9]+568446438)<<5|e>>>27)+t<<0)^t))+a[14]-1019803690)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+a[3]-187363961)<<14|r>>>18)+n<<0)^n))+a[8]+1163531501)<<20|t>>>12)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+a[13]-1444681467)<<5|e>>>27)+t<<0)^t))+a[2]-51403784)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+a[7]+1735328473)<<14|r>>>18)+n<<0)^n))+a[12]-1926607734)<<20|t>>>12)+r<<0,t=((t+=((i=(n=((n+=((o=t^r)^(e=((e+=(o^n)+a[5]-378558)<<4|e>>>28)+t<<0))+a[8]-2022574463)<<11|n>>>21)+e<<0)^e)^(r=((r+=(i^t)+a[11]+1839030562)<<16|r>>>16)+n<<0))+a[14]-35309556)<<23|t>>>9)+r<<0,t=((t+=((i=(n=((n+=((o=t^r)^(e=((e+=(o^n)+a[1]-1530992060)<<4|e>>>28)+t<<0))+a[4]+1272893353)<<11|n>>>21)+e<<0)^e)^(r=((r+=(i^t)+a[7]-155497632)<<16|r>>>16)+n<<0))+a[10]-1094730640)<<23|t>>>9)+r<<0,t=((t+=((i=(n=((n+=((o=t^r)^(e=((e+=(o^n)+a[13]+681279174)<<4|e>>>28)+t<<0))+a[0]-358537222)<<11|n>>>21)+e<<0)^e)^(r=((r+=(i^t)+a[3]-722521979)<<16|r>>>16)+n<<0))+a[6]+76029189)<<23|t>>>9)+r<<0,t=((t+=((i=(n=((n+=((o=t^r)^(e=((e+=(o^n)+a[9]-640364487)<<4|e>>>28)+t<<0))+a[12]-421815835)<<11|n>>>21)+e<<0)^e)^(r=((r+=(i^t)+a[15]+530742520)<<16|r>>>16)+n<<0))+a[2]-995338651)<<23|t>>>9)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+a[0]-198630844)<<6|e>>>26)+t<<0)|~r))+a[7]+1126891415)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+a[14]-1416354905)<<15|r>>>17)+n<<0)|~e))+a[5]-57434055)<<21|t>>>11)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+a[12]+1700485571)<<6|e>>>26)+t<<0)|~r))+a[3]-1894986606)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+a[10]-1051523)<<15|r>>>17)+n<<0)|~e))+a[1]-2054922799)<<21|t>>>11)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+a[8]+1873313359)<<6|e>>>26)+t<<0)|~r))+a[15]-30611744)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+a[6]-1560198380)<<15|r>>>17)+n<<0)|~e))+a[13]+1309151649)<<21|t>>>11)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+a[4]-145523070)<<6|e>>>26)+t<<0)|~r))+a[11]-1120210379)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+a[2]+718787259)<<15|r>>>17)+n<<0)|~e))+a[9]-343485551)<<21|t>>>11)+r<<0,this.first?(this.h0=e+1732584193<<0,this.h1=t-271733879<<0,this.h2=r-1732584194<<0,this.h3=n+271733878<<0,this.first=!1):(this.h0=this.h0+e<<0,this.h1=this.h1+t<<0,this.h2=this.h2+r<<0,this.h3=this.h3+n<<0)},Md5.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3;return HEX_CHARS[e>>4&15]+HEX_CHARS[15&e]+HEX_CHARS[e>>12&15]+HEX_CHARS[e>>8&15]+HEX_CHARS[e>>20&15]+HEX_CHARS[e>>16&15]+HEX_CHARS[e>>28&15]+HEX_CHARS[e>>24&15]+HEX_CHARS[t>>4&15]+HEX_CHARS[15&t]+HEX_CHARS[t>>12&15]+HEX_CHARS[t>>8&15]+HEX_CHARS[t>>20&15]+HEX_CHARS[t>>16&15]+HEX_CHARS[t>>28&15]+HEX_CHARS[t>>24&15]+HEX_CHARS[r>>4&15]+HEX_CHARS[15&r]+HEX_CHARS[r>>12&15]+HEX_CHARS[r>>8&15]+HEX_CHARS[r>>20&15]+HEX_CHARS[r>>16&15]+HEX_CHARS[r>>28&15]+HEX_CHARS[r>>24&15]+HEX_CHARS[n>>4&15]+HEX_CHARS[15&n]+HEX_CHARS[n>>12&15]+HEX_CHARS[n>>8&15]+HEX_CHARS[n>>20&15]+HEX_CHARS[n>>16&15]+HEX_CHARS[n>>28&15]+HEX_CHARS[n>>24&15]},Md5.prototype.toString=Md5.prototype.hex,Md5.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3;return[255&e,e>>8&255,e>>16&255,e>>24&255,255&t,t>>8&255,t>>16&255,t>>24&255,255&r,r>>8&255,r>>16&255,r>>24&255,255&n,n>>8&255,n>>16&255,n>>24&255]},Md5.prototype.array=Md5.prototype.digest,Md5.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(16),t=new Uint32Array(e);return t[0]=this.h0,t[1]=this.h1,t[2]=this.h2,t[3]=this.h3,e},Md5.prototype.buffer=Md5.prototype.arrayBuffer,Md5.prototype.base64=function(){for(var e,t,r,n="",o=this.array(),i=0;i<15;)e=o[i++],t=o[i++],r=o[i++],n+=BASE64_ENCODE_CHAR[e>>>2]+BASE64_ENCODE_CHAR[63&(e<<4|t>>>4)]+BASE64_ENCODE_CHAR[63&(t<<2|r>>>6)]+BASE64_ENCODE_CHAR[63&r];return n+(BASE64_ENCODE_CHAR[(e=o[i])>>>2]+BASE64_ENCODE_CHAR[e<<4&63]+"==")};var exports=createMethod();COMMON_JS?module.exports=exports:root.md5=exports})()}),sha1=createCommonjsModule(function(module){(function(){var root="object"==typeof window?window:{},NODE_JS=!root.JS_SHA1_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;NODE_JS&&(root=commonjsGlobal);var COMMON_JS=!root.JS_SHA1_NO_COMMON_JS&&module.exports,HEX_CHARS="0123456789abcdef".split(""),EXTRA=[-2147483648,8388608,32768,128],SHIFT=[24,16,8,0],OUTPUT_TYPES=["hex","array","digest","arrayBuffer"],blocks=[],createOutputMethod=function(e){return function(t){return new Sha1(!0).update(t)[e]()}},createMethod=function(){var e=createOutputMethod("hex");NODE_JS&&(e=nodeWrap(e)),e.create=function(){return new Sha1},e.update=function(t){return e.create().update(t)};for(var t=0;t<OUTPUT_TYPES.length;++t){var r=OUTPUT_TYPES[t];e[r]=createOutputMethod(r)}return e},nodeWrap=function(method){var crypto=eval("require('crypto')"),Buffer=eval("require('buffer').Buffer"),nodeMethod=function(e){if("string"==typeof e)return crypto.createHash("sha1").update(e,"utf8").digest("hex");if(e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(void 0===e.length)return method(e);return crypto.createHash("sha1").update(new Buffer(e)).digest("hex")};return nodeMethod};function Sha1(e){e?(blocks[0]=blocks[16]=blocks[1]=blocks[2]=blocks[3]=blocks[4]=blocks[5]=blocks[6]=blocks[7]=blocks[8]=blocks[9]=blocks[10]=blocks[11]=blocks[12]=blocks[13]=blocks[14]=blocks[15]=0,this.blocks=blocks):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.h0=1732584193,this.h1=4023233417,this.h2=2562383102,this.h3=271733878,this.h4=3285377520,this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}Sha1.prototype.update=function(e){if(!this.finalized){var t="string"!=typeof e;t&&e.constructor===root.ArrayBuffer&&(e=new Uint8Array(e));for(var r,n,o=0,i=e.length||0,a=this.blocks;o<i;){if(this.hashed&&(this.hashed=!1,a[0]=this.block,a[16]=a[1]=a[2]=a[3]=a[4]=a[5]=a[6]=a[7]=a[8]=a[9]=a[10]=a[11]=a[12]=a[13]=a[14]=a[15]=0),t)for(n=this.start;o<i&&n<64;++o)a[n>>2]|=e[o]<<SHIFT[3&n++];else for(n=this.start;o<i&&n<64;++o)(r=e.charCodeAt(o))<128?a[n>>2]|=r<<SHIFT[3&n++]:r<2048?(a[n>>2]|=(192|r>>6)<<SHIFT[3&n++],a[n>>2]|=(128|63&r)<<SHIFT[3&n++]):r<55296||r>=57344?(a[n>>2]|=(224|r>>12)<<SHIFT[3&n++],a[n>>2]|=(128|r>>6&63)<<SHIFT[3&n++],a[n>>2]|=(128|63&r)<<SHIFT[3&n++]):(r=65536+((1023&r)<<10|1023&e.charCodeAt(++o)),a[n>>2]|=(240|r>>18)<<SHIFT[3&n++],a[n>>2]|=(128|r>>12&63)<<SHIFT[3&n++],a[n>>2]|=(128|r>>6&63)<<SHIFT[3&n++],a[n>>2]|=(128|63&r)<<SHIFT[3&n++]);this.lastByteIndex=n,this.bytes+=n-this.start,n>=64?(this.block=a[16],this.start=n-64,this.hash(),this.hashed=!0):this.start=n}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},Sha1.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>2]|=EXTRA[3&t],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}},Sha1.prototype.hash=function(){var e,t,r=this.h0,n=this.h1,o=this.h2,i=this.h3,a=this.h4,s=this.blocks;for(e=16;e<80;++e)s[e]=(t=s[e-3]^s[e-8]^s[e-14]^s[e-16])<<1|t>>>31;for(e=0;e<20;e+=5)r=(t=(n=(t=(o=(t=(i=(t=(a=(t=r<<5|r>>>27)+(n&o|~n&i)+a+1518500249+s[e]<<0)<<5|a>>>27)+(r&(n=n<<30|n>>>2)|~r&o)+i+1518500249+s[e+1]<<0)<<5|i>>>27)+(a&(r=r<<30|r>>>2)|~a&n)+o+1518500249+s[e+2]<<0)<<5|o>>>27)+(i&(a=a<<30|a>>>2)|~i&r)+n+1518500249+s[e+3]<<0)<<5|n>>>27)+(o&(i=i<<30|i>>>2)|~o&a)+r+1518500249+s[e+4]<<0,o=o<<30|o>>>2;for(;e<40;e+=5)r=(t=(n=(t=(o=(t=(i=(t=(a=(t=r<<5|r>>>27)+(n^o^i)+a+1859775393+s[e]<<0)<<5|a>>>27)+(r^(n=n<<30|n>>>2)^o)+i+1859775393+s[e+1]<<0)<<5|i>>>27)+(a^(r=r<<30|r>>>2)^n)+o+1859775393+s[e+2]<<0)<<5|o>>>27)+(i^(a=a<<30|a>>>2)^r)+n+1859775393+s[e+3]<<0)<<5|n>>>27)+(o^(i=i<<30|i>>>2)^a)+r+1859775393+s[e+4]<<0,o=o<<30|o>>>2;for(;e<60;e+=5)r=(t=(n=(t=(o=(t=(i=(t=(a=(t=r<<5|r>>>27)+(n&o|n&i|o&i)+a-1894007588+s[e]<<0)<<5|a>>>27)+(r&(n=n<<30|n>>>2)|r&o|n&o)+i-1894007588+s[e+1]<<0)<<5|i>>>27)+(a&(r=r<<30|r>>>2)|a&n|r&n)+o-1894007588+s[e+2]<<0)<<5|o>>>27)+(i&(a=a<<30|a>>>2)|i&r|a&r)+n-1894007588+s[e+3]<<0)<<5|n>>>27)+(o&(i=i<<30|i>>>2)|o&a|i&a)+r-1894007588+s[e+4]<<0,o=o<<30|o>>>2;for(;e<80;e+=5)r=(t=(n=(t=(o=(t=(i=(t=(a=(t=r<<5|r>>>27)+(n^o^i)+a-899497514+s[e]<<0)<<5|a>>>27)+(r^(n=n<<30|n>>>2)^o)+i-899497514+s[e+1]<<0)<<5|i>>>27)+(a^(r=r<<30|r>>>2)^n)+o-899497514+s[e+2]<<0)<<5|o>>>27)+(i^(a=a<<30|a>>>2)^r)+n-899497514+s[e+3]<<0)<<5|n>>>27)+(o^(i=i<<30|i>>>2)^a)+r-899497514+s[e+4]<<0,o=o<<30|o>>>2;this.h0=this.h0+r<<0,this.h1=this.h1+n<<0,this.h2=this.h2+o<<0,this.h3=this.h3+i<<0,this.h4=this.h4+a<<0},Sha1.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,o=this.h4;return HEX_CHARS[e>>28&15]+HEX_CHARS[e>>24&15]+HEX_CHARS[e>>20&15]+HEX_CHARS[e>>16&15]+HEX_CHARS[e>>12&15]+HEX_CHARS[e>>8&15]+HEX_CHARS[e>>4&15]+HEX_CHARS[15&e]+HEX_CHARS[t>>28&15]+HEX_CHARS[t>>24&15]+HEX_CHARS[t>>20&15]+HEX_CHARS[t>>16&15]+HEX_CHARS[t>>12&15]+HEX_CHARS[t>>8&15]+HEX_CHARS[t>>4&15]+HEX_CHARS[15&t]+HEX_CHARS[r>>28&15]+HEX_CHARS[r>>24&15]+HEX_CHARS[r>>20&15]+HEX_CHARS[r>>16&15]+HEX_CHARS[r>>12&15]+HEX_CHARS[r>>8&15]+HEX_CHARS[r>>4&15]+HEX_CHARS[15&r]+HEX_CHARS[n>>28&15]+HEX_CHARS[n>>24&15]+HEX_CHARS[n>>20&15]+HEX_CHARS[n>>16&15]+HEX_CHARS[n>>12&15]+HEX_CHARS[n>>8&15]+HEX_CHARS[n>>4&15]+HEX_CHARS[15&n]+HEX_CHARS[o>>28&15]+HEX_CHARS[o>>24&15]+HEX_CHARS[o>>20&15]+HEX_CHARS[o>>16&15]+HEX_CHARS[o>>12&15]+HEX_CHARS[o>>8&15]+HEX_CHARS[o>>4&15]+HEX_CHARS[15&o]},Sha1.prototype.toString=Sha1.prototype.hex,Sha1.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,o=this.h4;return[e>>24&255,e>>16&255,e>>8&255,255&e,t>>24&255,t>>16&255,t>>8&255,255&t,r>>24&255,r>>16&255,r>>8&255,255&r,n>>24&255,n>>16&255,n>>8&255,255&n,o>>24&255,o>>16&255,o>>8&255,255&o]},Sha1.prototype.array=Sha1.prototype.digest,Sha1.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(20),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),e};var exports=createMethod();COMMON_JS?module.exports=exports:root.sha1=exports})()}),HEX_DIGITS="0123456789abcdef".split(""),UUID_LENGTH=36,UUID_REGEXP=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i,HEX_TO_BYTE_MAP=function(){for(var e={},t=0;t<256;t++){var r=t.toString(16);e[1===r.length?"0"+r:r]=t}return e}(),uint8ToHex=function(e){var t=e>>4;return HEX_DIGITS[t]+HEX_DIGITS[e-(t<<4)]},uint8ArrayToHex=function(e){for(var t="",r=0;r<e.length;r++)t+=uint8ToHex(e[r]);return t},stringToCharBuffer=function(e){for(var t=unescape(encodeURIComponent(e)),r=new Uint8Array(t.length),n=0;n<t.length;n++)r[n]=t[n].charCodeAt(0);return r},md5Hash=function(e){return new Uint8Array(md5.arrayBuffer(e))},sha1Hash=function(e){return new Uint8Array(sha1.arrayBuffer(e))},concatBuffers=function(e,t){var r=new Uint8Array(e.length+t.length);return r.set(new Uint8Array(e),0),r.set(new Uint8Array(t),e.byteLength),r},validateUuid=function(e){return"string"==typeof e&&e.length===UUID_LENGTH&&UUID_REGEXP.test(e)},parseUuid=function(e){if(!validateUuid(e))throw TypeError("Invalid UUID");for(var t=new Uint8Array(16),r=0,n=0;r<e.length;)if("-"!==e[r]){var o=(e[r]+e[r+1]).toLowerCase();t[n]=HEX_TO_BYTE_MAP[o],n++,r+=2}else r++;return t},hashToUuid=function(e,t){return uint8ArrayToHex(e.slice(0,4))+"-"+uint8ArrayToHex(e.slice(4,6))+"-"+uint8ToHex(15&e[6]|parseInt(10*t,16))+uint8ToHex(e[7])+"-"+uint8ToHex(63&e[8]|128)+uint8ToHex(e[9])+"-"+uint8ArrayToHex(e.slice(10,16))},lib={uint8ToHex:uint8ToHex,uint8ArrayToHex:uint8ArrayToHex,stringToCharBuffer:stringToCharBuffer,md5Hash:md5Hash,sha1Hash:sha1Hash,concatBuffers:concatBuffers,validateUuid:validateUuid,parseUuid:parseUuid,hashToUuid:hashToUuid},EMPTY_UINT8_ARRAY=new Uint8Array(0);function generateUuid(e,t,r){if("string"!=typeof e)throw TypeError("Value must be string");if("number"==typeof t)return generateUuid(e,void 0,t);if(null==r)return generateUuid(e,t,5);if(3!==r&&5!==r)throw TypeError("Version of UUID can be only 3 or 5");var n=lib.stringToCharBuffer(e),o="string"==typeof t?lib.parseUuid(t):EMPTY_UINT8_ARRAY,i=lib.concatBuffers(o,n),a=3===r?lib.md5Hash(i):lib.sha1Hash(i);return lib.hashToUuid(a,r)}var src=generateUuid,ReactGridLayout=RGL.WidthProvider(RGL__default.default),Dashboard=function(e){var t=e.apiUrl,r=e.lang,n=e.widgetName,o=e.widgetDisplayName,i=e.widgetWidth,a=e.widgetHeight,s=e.Widget,c=e.editMode,u=andoncloudSdk.useLoginStatus().authResponse,l=React.useState(!1),f=l[0],p=l[1],h=src(n);return React__default.default.createElement(ReactGridLayout,{className:"layout",layout:[{i:h,x:0,y:0,w:i||3,h:a||4}],draggableHandle:".draggable-handle"},(null==u?void 0:u.accessToken)&&React__default.default.createElement(andoncloudDashboardToolkit.WidgetCard,{key:h,Widget:s,title:o(r),id:h,url:t,token:u.accessToken,lang:r,openSettingsModal:f,onSettingsModalOpened:function(){return p(!0)},onSettingsModalClosed:function(){return p(!1)},editMode:c}))},routes=function(e,t){return[{path:"/",element:e?React__default.default.createElement(Dashboard,{apiUrl:t.apiUrl,lang:t.lang,widgetName:t.widgetName,widgetDisplayName:t.widgetDisplayName,widgetWidth:t.widgetWidth,widgetHeight:t.widgetHeight,Widget:t.Widget,editMode:t.editMode}):React__default.default.createElement(reactRouterDom.Navigate,{to:"/login"})}]},Routing=function(e){var t=andoncloudSdk.useLoginStatus();return reactRouterDom.useRoutes(routes("connected"===t.status,e))},WidgetPreview=function(e){var t=e.baseUrl,r=e.apiUrl,n=e.widgetName,o=e.widgetDisplayName,i=e.widgetWidth,a=e.widgetHeight,s=e.Widget,c=React.useState("pl"),u=c[0],l=c[1],f=React.useState(!0),p=f[0],h=f[1],d=[{label:p?"pl"===u?"Wyłącz tryb edycji":"Turn off edit mode":"pl"===u?"Włącz tryb edycji":"Turn on edit mode",action:function(){return h(function(e){return!e})}},{label:"pl"===u?"Change language to English":"Zmień język na Polski",action:function(){var e="pl"===u?"en":"pl";l(e),andoncloudSdk.setLocale(e)}}],g={position:"static",leadingText:o(u),menuProps:{items:d,buttonColor:"white"}};return React__default.default.createElement(andoncloudSdk.App,{baseUrl:t,authProps:{redirectPath:"/",clientId:"sample-app-client-id",grantType:"password"}},React__default.default.createElement(andoncloudSdk.Container,{headerProps:g},React__default.default.createElement(Routing,{apiUrl:r,lang:u,widgetName:n,widgetDisplayName:o,widgetWidth:i,widgetHeight:a,Widget:s,editMode:p})))};exports.WidgetPreview=WidgetPreview;
|
|
4153
2
|
//# sourceMappingURL=index.js.map
|