@bigbinary/neeto-integrations-frontend 1.5.0 → 2.1.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.cjs.js CHANGED
@@ -8,9 +8,8 @@ var pure = require('@bigbinary/neeto-commons-frontend/pure');
8
8
  var utils = require('@bigbinary/neeto-commons-frontend/utils');
9
9
  var neetoui = require('@bigbinary/neetoui');
10
10
  var ramda = require('ramda');
11
+ var reactI18next = require('react-i18next');
11
12
  var neetoIcons = require('@bigbinary/neeto-icons');
12
- var formik = require('@bigbinary/neetoui/formik');
13
- var Yup = require('yup');
14
13
 
15
14
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
15
 
@@ -35,3670 +34,6 @@ function _interopNamespace(e) {
35
34
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
36
35
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
37
36
  var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
38
- var Yup__namespace = /*#__PURE__*/_interopNamespace(Yup);
39
-
40
- function _typeof$2(obj) {
41
- "@babel/helpers - typeof";
42
-
43
- return _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
44
- return typeof obj;
45
- } : function (obj) {
46
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
47
- }, _typeof$2(obj);
48
- }
49
-
50
- function _classCallCheck$1(instance, Constructor) {
51
- if (!(instance instanceof Constructor)) {
52
- throw new TypeError("Cannot call a class as a function");
53
- }
54
- }
55
-
56
- function _toPrimitive$2(input, hint) {
57
- if (_typeof$2(input) !== "object" || input === null) return input;
58
- var prim = input[Symbol.toPrimitive];
59
- if (prim !== undefined) {
60
- var res = prim.call(input, hint || "default");
61
- if (_typeof$2(res) !== "object") return res;
62
- throw new TypeError("@@toPrimitive must return a primitive value.");
63
- }
64
- return (hint === "string" ? String : Number)(input);
65
- }
66
-
67
- function _toPropertyKey$2(arg) {
68
- var key = _toPrimitive$2(arg, "string");
69
- return _typeof$2(key) === "symbol" ? key : String(key);
70
- }
71
-
72
- function _defineProperties$1(target, props) {
73
- for (var i = 0; i < props.length; i++) {
74
- var descriptor = props[i];
75
- descriptor.enumerable = descriptor.enumerable || false;
76
- descriptor.configurable = true;
77
- if ("value" in descriptor) descriptor.writable = true;
78
- Object.defineProperty(target, _toPropertyKey$2(descriptor.key), descriptor);
79
- }
80
- }
81
- function _createClass$1(Constructor, protoProps, staticProps) {
82
- if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
83
- if (staticProps) _defineProperties$1(Constructor, staticProps);
84
- Object.defineProperty(Constructor, "prototype", {
85
- writable: false
86
- });
87
- return Constructor;
88
- }
89
-
90
- function _assertThisInitialized(self) {
91
- if (self === void 0) {
92
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
93
- }
94
- return self;
95
- }
96
-
97
- function _setPrototypeOf(o, p) {
98
- _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
99
- o.__proto__ = p;
100
- return o;
101
- };
102
- return _setPrototypeOf(o, p);
103
- }
104
-
105
- function _inherits(subClass, superClass) {
106
- if (typeof superClass !== "function" && superClass !== null) {
107
- throw new TypeError("Super expression must either be null or a function");
108
- }
109
- subClass.prototype = Object.create(superClass && superClass.prototype, {
110
- constructor: {
111
- value: subClass,
112
- writable: true,
113
- configurable: true
114
- }
115
- });
116
- Object.defineProperty(subClass, "prototype", {
117
- writable: false
118
- });
119
- if (superClass) _setPrototypeOf(subClass, superClass);
120
- }
121
-
122
- function _possibleConstructorReturn(self, call) {
123
- if (call && (_typeof$2(call) === "object" || typeof call === "function")) {
124
- return call;
125
- } else if (call !== void 0) {
126
- throw new TypeError("Derived constructors may only return object or undefined");
127
- }
128
- return _assertThisInitialized(self);
129
- }
130
-
131
- function _getPrototypeOf(o) {
132
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
133
- return o.__proto__ || Object.getPrototypeOf(o);
134
- };
135
- return _getPrototypeOf(o);
136
- }
137
-
138
- function _defineProperty$2(obj, key, value) {
139
- key = _toPropertyKey$2(key);
140
- if (key in obj) {
141
- Object.defineProperty(obj, key, {
142
- value: value,
143
- enumerable: true,
144
- configurable: true,
145
- writable: true
146
- });
147
- } else {
148
- obj[key] = value;
149
- }
150
- return obj;
151
- }
152
-
153
- function _arrayWithHoles$2(arr) {
154
- if (Array.isArray(arr)) return arr;
155
- }
156
-
157
- function _iterableToArray(iter) {
158
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
159
- }
160
-
161
- function _arrayLikeToArray$2(arr, len) {
162
- if (len == null || len > arr.length) len = arr.length;
163
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
164
- return arr2;
165
- }
166
-
167
- function _unsupportedIterableToArray$2(o, minLen) {
168
- if (!o) return;
169
- if (typeof o === "string") return _arrayLikeToArray$2(o, minLen);
170
- var n = Object.prototype.toString.call(o).slice(8, -1);
171
- if (n === "Object" && o.constructor) n = o.constructor.name;
172
- if (n === "Map" || n === "Set") return Array.from(o);
173
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$2(o, minLen);
174
- }
175
-
176
- function _nonIterableRest$2() {
177
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
178
- }
179
-
180
- function _toArray(arr) {
181
- return _arrayWithHoles$2(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$2(arr) || _nonIterableRest$2();
182
- }
183
-
184
- function ownKeys$5(object, enumerableOnly) {
185
- var keys = Object.keys(object);
186
- if (Object.getOwnPropertySymbols) {
187
- var symbols = Object.getOwnPropertySymbols(object);
188
- if (enumerableOnly) {
189
- symbols = symbols.filter(function (sym) {
190
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
191
- });
192
- }
193
- keys.push.apply(keys, symbols);
194
- }
195
- return keys;
196
- }
197
- function _objectSpread$5(target) {
198
- for (var i = 1; i < arguments.length; i++) {
199
- var source = arguments[i] != null ? arguments[i] : {};
200
- if (i % 2) {
201
- ownKeys$5(Object(source), true).forEach(function (key) {
202
- _defineProperty$2(target, key, source[key]);
203
- });
204
- } else if (Object.getOwnPropertyDescriptors) {
205
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
206
- } else {
207
- ownKeys$5(Object(source)).forEach(function (key) {
208
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
209
- });
210
- }
211
- }
212
- return target;
213
- }
214
- var consoleLogger = {
215
- type: 'logger',
216
- log: function log(args) {
217
- this.output('log', args);
218
- },
219
- warn: function warn(args) {
220
- this.output('warn', args);
221
- },
222
- error: function error(args) {
223
- this.output('error', args);
224
- },
225
- output: function output(type, args) {
226
- if (console && console[type]) console[type].apply(console, args);
227
- }
228
- };
229
- var Logger = function () {
230
- function Logger(concreteLogger) {
231
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
232
- _classCallCheck$1(this, Logger);
233
- this.init(concreteLogger, options);
234
- }
235
- _createClass$1(Logger, [{
236
- key: "init",
237
- value: function init(concreteLogger) {
238
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
239
- this.prefix = options.prefix || 'i18next:';
240
- this.logger = concreteLogger || consoleLogger;
241
- this.options = options;
242
- this.debug = options.debug;
243
- }
244
- }, {
245
- key: "setDebug",
246
- value: function setDebug(bool) {
247
- this.debug = bool;
248
- }
249
- }, {
250
- key: "log",
251
- value: function log() {
252
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
253
- args[_key] = arguments[_key];
254
- }
255
- return this.forward(args, 'log', '', true);
256
- }
257
- }, {
258
- key: "warn",
259
- value: function warn() {
260
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
261
- args[_key2] = arguments[_key2];
262
- }
263
- return this.forward(args, 'warn', '', true);
264
- }
265
- }, {
266
- key: "error",
267
- value: function error() {
268
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
269
- args[_key3] = arguments[_key3];
270
- }
271
- return this.forward(args, 'error', '');
272
- }
273
- }, {
274
- key: "deprecate",
275
- value: function deprecate() {
276
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
277
- args[_key4] = arguments[_key4];
278
- }
279
- return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
280
- }
281
- }, {
282
- key: "forward",
283
- value: function forward(args, lvl, prefix, debugOnly) {
284
- if (debugOnly && !this.debug) return null;
285
- if (typeof args[0] === 'string') args[0] = "".concat(prefix).concat(this.prefix, " ").concat(args[0]);
286
- return this.logger[lvl](args);
287
- }
288
- }, {
289
- key: "create",
290
- value: function create(moduleName) {
291
- return new Logger(this.logger, _objectSpread$5(_objectSpread$5({}, {
292
- prefix: "".concat(this.prefix, ":").concat(moduleName, ":")
293
- }), this.options));
294
- }
295
- }]);
296
- return Logger;
297
- }();
298
- var baseLogger = new Logger();
299
- var EventEmitter = function () {
300
- function EventEmitter() {
301
- _classCallCheck$1(this, EventEmitter);
302
- this.observers = {};
303
- }
304
- _createClass$1(EventEmitter, [{
305
- key: "on",
306
- value: function on(events, listener) {
307
- var _this = this;
308
- events.split(' ').forEach(function (event) {
309
- _this.observers[event] = _this.observers[event] || [];
310
- _this.observers[event].push(listener);
311
- });
312
- return this;
313
- }
314
- }, {
315
- key: "off",
316
- value: function off(event, listener) {
317
- if (!this.observers[event]) return;
318
- if (!listener) {
319
- delete this.observers[event];
320
- return;
321
- }
322
- this.observers[event] = this.observers[event].filter(function (l) {
323
- return l !== listener;
324
- });
325
- }
326
- }, {
327
- key: "emit",
328
- value: function emit(event) {
329
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
330
- args[_key - 1] = arguments[_key];
331
- }
332
- if (this.observers[event]) {
333
- var cloned = [].concat(this.observers[event]);
334
- cloned.forEach(function (observer) {
335
- observer.apply(void 0, args);
336
- });
337
- }
338
- if (this.observers['*']) {
339
- var _cloned = [].concat(this.observers['*']);
340
- _cloned.forEach(function (observer) {
341
- observer.apply(observer, [event].concat(args));
342
- });
343
- }
344
- }
345
- }]);
346
- return EventEmitter;
347
- }();
348
- function defer() {
349
- var res;
350
- var rej;
351
- var promise = new Promise(function (resolve, reject) {
352
- res = resolve;
353
- rej = reject;
354
- });
355
- promise.resolve = res;
356
- promise.reject = rej;
357
- return promise;
358
- }
359
- function makeString(object) {
360
- if (object == null) return '';
361
- return '' + object;
362
- }
363
- function copy(a, s, t) {
364
- a.forEach(function (m) {
365
- if (s[m]) t[m] = s[m];
366
- });
367
- }
368
- function getLastOfPath(object, path, Empty) {
369
- function cleanKey(key) {
370
- return key && key.indexOf('###') > -1 ? key.replace(/###/g, '.') : key;
371
- }
372
- function canNotTraverseDeeper() {
373
- return !object || typeof object === 'string';
374
- }
375
- var stack = typeof path !== 'string' ? [].concat(path) : path.split('.');
376
- while (stack.length > 1) {
377
- if (canNotTraverseDeeper()) return {};
378
- var key = cleanKey(stack.shift());
379
- if (!object[key] && Empty) object[key] = new Empty();
380
- if (Object.prototype.hasOwnProperty.call(object, key)) {
381
- object = object[key];
382
- } else {
383
- object = {};
384
- }
385
- }
386
- if (canNotTraverseDeeper()) return {};
387
- return {
388
- obj: object,
389
- k: cleanKey(stack.shift())
390
- };
391
- }
392
- function setPath(object, path, newValue) {
393
- var _getLastOfPath = getLastOfPath(object, path, Object),
394
- obj = _getLastOfPath.obj,
395
- k = _getLastOfPath.k;
396
- obj[k] = newValue;
397
- }
398
- function pushPath(object, path, newValue, concat) {
399
- var _getLastOfPath2 = getLastOfPath(object, path, Object),
400
- obj = _getLastOfPath2.obj,
401
- k = _getLastOfPath2.k;
402
- obj[k] = obj[k] || [];
403
- if (concat) obj[k] = obj[k].concat(newValue);
404
- if (!concat) obj[k].push(newValue);
405
- }
406
- function getPath(object, path) {
407
- var _getLastOfPath3 = getLastOfPath(object, path),
408
- obj = _getLastOfPath3.obj,
409
- k = _getLastOfPath3.k;
410
- if (!obj) return undefined;
411
- return obj[k];
412
- }
413
- function getPathWithDefaults(data, defaultData, key) {
414
- var value = getPath(data, key);
415
- if (value !== undefined) {
416
- return value;
417
- }
418
- return getPath(defaultData, key);
419
- }
420
- function deepExtend(target, source, overwrite) {
421
- for (var prop in source) {
422
- if (prop !== '__proto__' && prop !== 'constructor') {
423
- if (prop in target) {
424
- if (typeof target[prop] === 'string' || target[prop] instanceof String || typeof source[prop] === 'string' || source[prop] instanceof String) {
425
- if (overwrite) target[prop] = source[prop];
426
- } else {
427
- deepExtend(target[prop], source[prop], overwrite);
428
- }
429
- } else {
430
- target[prop] = source[prop];
431
- }
432
- }
433
- }
434
- return target;
435
- }
436
- function regexEscape(str) {
437
- return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
438
- }
439
- var _entityMap = {
440
- '&': '&amp;',
441
- '<': '&lt;',
442
- '>': '&gt;',
443
- '"': '&quot;',
444
- "'": '&#39;',
445
- '/': '&#x2F;'
446
- };
447
- function escape(data) {
448
- if (typeof data === 'string') {
449
- return data.replace(/[&<>"'\/]/g, function (s) {
450
- return _entityMap[s];
451
- });
452
- }
453
- return data;
454
- }
455
- var isIE10 = typeof window !== 'undefined' && window.navigator && window.navigator.userAgent && window.navigator.userAgent.indexOf('MSIE') > -1;
456
- var chars = [' ', ',', '?', '!', ';'];
457
- function looksLikeObjectPath(key, nsSeparator, keySeparator) {
458
- nsSeparator = nsSeparator || '';
459
- keySeparator = keySeparator || '';
460
- var possibleChars = chars.filter(function (c) {
461
- return nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0;
462
- });
463
- if (possibleChars.length === 0) return true;
464
- var r = new RegExp("(".concat(possibleChars.map(function (c) {
465
- return c === '?' ? '\\?' : c;
466
- }).join('|'), ")"));
467
- var matched = !r.test(key);
468
- if (!matched) {
469
- var ki = key.indexOf(keySeparator);
470
- if (ki > 0 && !r.test(key.substring(0, ki))) {
471
- matched = true;
472
- }
473
- }
474
- return matched;
475
- }
476
- function ownKeys$1$1(object, enumerableOnly) {
477
- var keys = Object.keys(object);
478
- if (Object.getOwnPropertySymbols) {
479
- var symbols = Object.getOwnPropertySymbols(object);
480
- if (enumerableOnly) {
481
- symbols = symbols.filter(function (sym) {
482
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
483
- });
484
- }
485
- keys.push.apply(keys, symbols);
486
- }
487
- return keys;
488
- }
489
- function _objectSpread$1$1(target) {
490
- for (var i = 1; i < arguments.length; i++) {
491
- var source = arguments[i] != null ? arguments[i] : {};
492
- if (i % 2) {
493
- ownKeys$1$1(Object(source), true).forEach(function (key) {
494
- _defineProperty$2(target, key, source[key]);
495
- });
496
- } else if (Object.getOwnPropertyDescriptors) {
497
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
498
- } else {
499
- ownKeys$1$1(Object(source)).forEach(function (key) {
500
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
501
- });
502
- }
503
- }
504
- return target;
505
- }
506
- function _createSuper(Derived) {
507
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
508
- return function _createSuperInternal() {
509
- var Super = _getPrototypeOf(Derived),
510
- result;
511
- if (hasNativeReflectConstruct) {
512
- var NewTarget = _getPrototypeOf(this).constructor;
513
- result = Reflect.construct(Super, arguments, NewTarget);
514
- } else {
515
- result = Super.apply(this, arguments);
516
- }
517
- return _possibleConstructorReturn(this, result);
518
- };
519
- }
520
- function _isNativeReflectConstruct() {
521
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
522
- if (Reflect.construct.sham) return false;
523
- if (typeof Proxy === "function") return true;
524
- try {
525
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
526
- return true;
527
- } catch (e) {
528
- return false;
529
- }
530
- }
531
- function deepFind(obj, path) {
532
- var keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
533
- if (!obj) return undefined;
534
- if (obj[path]) return obj[path];
535
- var paths = path.split(keySeparator);
536
- var current = obj;
537
- for (var i = 0; i < paths.length; ++i) {
538
- if (!current) return undefined;
539
- if (typeof current[paths[i]] === 'string' && i + 1 < paths.length) {
540
- return undefined;
541
- }
542
- if (current[paths[i]] === undefined) {
543
- var j = 2;
544
- var p = paths.slice(i, i + j).join(keySeparator);
545
- var mix = current[p];
546
- while (mix === undefined && paths.length > i + j) {
547
- j++;
548
- p = paths.slice(i, i + j).join(keySeparator);
549
- mix = current[p];
550
- }
551
- if (mix === undefined) return undefined;
552
- if (path.endsWith(p)) {
553
- if (typeof mix === 'string') return mix;
554
- if (p && typeof mix[p] === 'string') return mix[p];
555
- }
556
- var joinedPath = paths.slice(i + j).join(keySeparator);
557
- if (joinedPath) return deepFind(mix, joinedPath, keySeparator);
558
- return undefined;
559
- }
560
- current = current[paths[i]];
561
- }
562
- return current;
563
- }
564
- var ResourceStore = function (_EventEmitter) {
565
- _inherits(ResourceStore, _EventEmitter);
566
- var _super = _createSuper(ResourceStore);
567
- function ResourceStore(data) {
568
- var _this;
569
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
570
- ns: ['translation'],
571
- defaultNS: 'translation'
572
- };
573
- _classCallCheck$1(this, ResourceStore);
574
- _this = _super.call(this);
575
- if (isIE10) {
576
- EventEmitter.call(_assertThisInitialized(_this));
577
- }
578
- _this.data = data || {};
579
- _this.options = options;
580
- if (_this.options.keySeparator === undefined) {
581
- _this.options.keySeparator = '.';
582
- }
583
- if (_this.options.ignoreJSONStructure === undefined) {
584
- _this.options.ignoreJSONStructure = true;
585
- }
586
- return _this;
587
- }
588
- _createClass$1(ResourceStore, [{
589
- key: "addNamespaces",
590
- value: function addNamespaces(ns) {
591
- if (this.options.ns.indexOf(ns) < 0) {
592
- this.options.ns.push(ns);
593
- }
594
- }
595
- }, {
596
- key: "removeNamespaces",
597
- value: function removeNamespaces(ns) {
598
- var index = this.options.ns.indexOf(ns);
599
- if (index > -1) {
600
- this.options.ns.splice(index, 1);
601
- }
602
- }
603
- }, {
604
- key: "getResource",
605
- value: function getResource(lng, ns, key) {
606
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
607
- var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
608
- var ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
609
- var path = [lng, ns];
610
- if (key && typeof key !== 'string') path = path.concat(key);
611
- if (key && typeof key === 'string') path = path.concat(keySeparator ? key.split(keySeparator) : key);
612
- if (lng.indexOf('.') > -1) {
613
- path = lng.split('.');
614
- }
615
- var result = getPath(this.data, path);
616
- if (result || !ignoreJSONStructure || typeof key !== 'string') return result;
617
- return deepFind(this.data && this.data[lng] && this.data[lng][ns], key, keySeparator);
618
- }
619
- }, {
620
- key: "addResource",
621
- value: function addResource(lng, ns, key, value) {
622
- var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
623
- silent: false
624
- };
625
- var keySeparator = this.options.keySeparator;
626
- if (keySeparator === undefined) keySeparator = '.';
627
- var path = [lng, ns];
628
- if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
629
- if (lng.indexOf('.') > -1) {
630
- path = lng.split('.');
631
- value = ns;
632
- ns = path[1];
633
- }
634
- this.addNamespaces(ns);
635
- setPath(this.data, path, value);
636
- if (!options.silent) this.emit('added', lng, ns, key, value);
637
- }
638
- }, {
639
- key: "addResources",
640
- value: function addResources(lng, ns, resources) {
641
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
642
- silent: false
643
- };
644
- for (var m in resources) {
645
- if (typeof resources[m] === 'string' || Object.prototype.toString.apply(resources[m]) === '[object Array]') this.addResource(lng, ns, m, resources[m], {
646
- silent: true
647
- });
648
- }
649
- if (!options.silent) this.emit('added', lng, ns, resources);
650
- }
651
- }, {
652
- key: "addResourceBundle",
653
- value: function addResourceBundle(lng, ns, resources, deep, overwrite) {
654
- var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
655
- silent: false
656
- };
657
- var path = [lng, ns];
658
- if (lng.indexOf('.') > -1) {
659
- path = lng.split('.');
660
- deep = resources;
661
- resources = ns;
662
- ns = path[1];
663
- }
664
- this.addNamespaces(ns);
665
- var pack = getPath(this.data, path) || {};
666
- if (deep) {
667
- deepExtend(pack, resources, overwrite);
668
- } else {
669
- pack = _objectSpread$1$1(_objectSpread$1$1({}, pack), resources);
670
- }
671
- setPath(this.data, path, pack);
672
- if (!options.silent) this.emit('added', lng, ns, resources);
673
- }
674
- }, {
675
- key: "removeResourceBundle",
676
- value: function removeResourceBundle(lng, ns) {
677
- if (this.hasResourceBundle(lng, ns)) {
678
- delete this.data[lng][ns];
679
- }
680
- this.removeNamespaces(ns);
681
- this.emit('removed', lng, ns);
682
- }
683
- }, {
684
- key: "hasResourceBundle",
685
- value: function hasResourceBundle(lng, ns) {
686
- return this.getResource(lng, ns) !== undefined;
687
- }
688
- }, {
689
- key: "getResourceBundle",
690
- value: function getResourceBundle(lng, ns) {
691
- if (!ns) ns = this.options.defaultNS;
692
- if (this.options.compatibilityAPI === 'v1') return _objectSpread$1$1(_objectSpread$1$1({}, {}), this.getResource(lng, ns));
693
- return this.getResource(lng, ns);
694
- }
695
- }, {
696
- key: "getDataByLanguage",
697
- value: function getDataByLanguage(lng) {
698
- return this.data[lng];
699
- }
700
- }, {
701
- key: "hasLanguageSomeTranslations",
702
- value: function hasLanguageSomeTranslations(lng) {
703
- var data = this.getDataByLanguage(lng);
704
- var n = data && Object.keys(data) || [];
705
- return !!n.find(function (v) {
706
- return data[v] && Object.keys(data[v]).length > 0;
707
- });
708
- }
709
- }, {
710
- key: "toJSON",
711
- value: function toJSON() {
712
- return this.data;
713
- }
714
- }]);
715
- return ResourceStore;
716
- }(EventEmitter);
717
- var postProcessor = {
718
- processors: {},
719
- addPostProcessor: function addPostProcessor(module) {
720
- this.processors[module.name] = module;
721
- },
722
- handle: function handle(processors, value, key, options, translator) {
723
- var _this = this;
724
- processors.forEach(function (processor) {
725
- if (_this.processors[processor]) value = _this.processors[processor].process(value, key, options, translator);
726
- });
727
- return value;
728
- }
729
- };
730
- function ownKeys$2$1(object, enumerableOnly) {
731
- var keys = Object.keys(object);
732
- if (Object.getOwnPropertySymbols) {
733
- var symbols = Object.getOwnPropertySymbols(object);
734
- if (enumerableOnly) {
735
- symbols = symbols.filter(function (sym) {
736
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
737
- });
738
- }
739
- keys.push.apply(keys, symbols);
740
- }
741
- return keys;
742
- }
743
- function _objectSpread$2$1(target) {
744
- for (var i = 1; i < arguments.length; i++) {
745
- var source = arguments[i] != null ? arguments[i] : {};
746
- if (i % 2) {
747
- ownKeys$2$1(Object(source), true).forEach(function (key) {
748
- _defineProperty$2(target, key, source[key]);
749
- });
750
- } else if (Object.getOwnPropertyDescriptors) {
751
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
752
- } else {
753
- ownKeys$2$1(Object(source)).forEach(function (key) {
754
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
755
- });
756
- }
757
- }
758
- return target;
759
- }
760
- function _createSuper$1(Derived) {
761
- var hasNativeReflectConstruct = _isNativeReflectConstruct$1();
762
- return function _createSuperInternal() {
763
- var Super = _getPrototypeOf(Derived),
764
- result;
765
- if (hasNativeReflectConstruct) {
766
- var NewTarget = _getPrototypeOf(this).constructor;
767
- result = Reflect.construct(Super, arguments, NewTarget);
768
- } else {
769
- result = Super.apply(this, arguments);
770
- }
771
- return _possibleConstructorReturn(this, result);
772
- };
773
- }
774
- function _isNativeReflectConstruct$1() {
775
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
776
- if (Reflect.construct.sham) return false;
777
- if (typeof Proxy === "function") return true;
778
- try {
779
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
780
- return true;
781
- } catch (e) {
782
- return false;
783
- }
784
- }
785
- var checkedLoadedFor = {};
786
- var Translator = function (_EventEmitter) {
787
- _inherits(Translator, _EventEmitter);
788
- var _super = _createSuper$1(Translator);
789
- function Translator(services) {
790
- var _this;
791
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
792
- _classCallCheck$1(this, Translator);
793
- _this = _super.call(this);
794
- if (isIE10) {
795
- EventEmitter.call(_assertThisInitialized(_this));
796
- }
797
- copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, _assertThisInitialized(_this));
798
- _this.options = options;
799
- if (_this.options.keySeparator === undefined) {
800
- _this.options.keySeparator = '.';
801
- }
802
- _this.logger = baseLogger.create('translator');
803
- return _this;
804
- }
805
- _createClass$1(Translator, [{
806
- key: "changeLanguage",
807
- value: function changeLanguage(lng) {
808
- if (lng) this.language = lng;
809
- }
810
- }, {
811
- key: "exists",
812
- value: function exists(key) {
813
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
814
- interpolation: {}
815
- };
816
- if (key === undefined || key === null) {
817
- return false;
818
- }
819
- var resolved = this.resolve(key, options);
820
- return resolved && resolved.res !== undefined;
821
- }
822
- }, {
823
- key: "extractFromKey",
824
- value: function extractFromKey(key, options) {
825
- var nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;
826
- if (nsSeparator === undefined) nsSeparator = ':';
827
- var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
828
- var namespaces = options.ns || this.options.defaultNS || [];
829
- var wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
830
- var seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
831
- if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
832
- var m = key.match(this.interpolator.nestingRegexp);
833
- if (m && m.length > 0) {
834
- return {
835
- key: key,
836
- namespaces: namespaces
837
- };
838
- }
839
- var parts = key.split(nsSeparator);
840
- if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
841
- key = parts.join(keySeparator);
842
- }
843
- if (typeof namespaces === 'string') namespaces = [namespaces];
844
- return {
845
- key: key,
846
- namespaces: namespaces
847
- };
848
- }
849
- }, {
850
- key: "translate",
851
- value: function translate(keys, options, lastKey) {
852
- var _this2 = this;
853
- if (_typeof$2(options) !== 'object' && this.options.overloadTranslationOptionHandler) {
854
- options = this.options.overloadTranslationOptionHandler(arguments);
855
- }
856
- if (!options) options = {};
857
- if (keys === undefined || keys === null) return '';
858
- if (!Array.isArray(keys)) keys = [String(keys)];
859
- var returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;
860
- var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
861
- var _this$extractFromKey = this.extractFromKey(keys[keys.length - 1], options),
862
- key = _this$extractFromKey.key,
863
- namespaces = _this$extractFromKey.namespaces;
864
- var namespace = namespaces[namespaces.length - 1];
865
- var lng = options.lng || this.language;
866
- var appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
867
- if (lng && lng.toLowerCase() === 'cimode') {
868
- if (appendNamespaceToCIMode) {
869
- var nsSeparator = options.nsSeparator || this.options.nsSeparator;
870
- if (returnDetails) {
871
- resolved.res = "".concat(namespace).concat(nsSeparator).concat(key);
872
- return resolved;
873
- }
874
- return "".concat(namespace).concat(nsSeparator).concat(key);
875
- }
876
- if (returnDetails) {
877
- resolved.res = key;
878
- return resolved;
879
- }
880
- return key;
881
- }
882
- var resolved = this.resolve(keys, options);
883
- var res = resolved && resolved.res;
884
- var resUsedKey = resolved && resolved.usedKey || key;
885
- var resExactUsedKey = resolved && resolved.exactUsedKey || key;
886
- var resType = Object.prototype.toString.apply(res);
887
- var noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
888
- var joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
889
- var handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
890
- var handleAsObject = typeof res !== 'string' && typeof res !== 'boolean' && typeof res !== 'number';
891
- if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(typeof joinArrays === 'string' && resType === '[object Array]')) {
892
- if (!options.returnObjects && !this.options.returnObjects) {
893
- if (!this.options.returnedObjectHandler) {
894
- this.logger.warn('accessing an object - but returnObjects options is not enabled!');
895
- }
896
- var r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, _objectSpread$2$1(_objectSpread$2$1({}, options), {}, {
897
- ns: namespaces
898
- })) : "key '".concat(key, " (").concat(this.language, ")' returned an object instead of string.");
899
- if (returnDetails) {
900
- resolved.res = r;
901
- return resolved;
902
- }
903
- return r;
904
- }
905
- if (keySeparator) {
906
- var resTypeIsArray = resType === '[object Array]';
907
- var copy = resTypeIsArray ? [] : {};
908
- var newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
909
- for (var m in res) {
910
- if (Object.prototype.hasOwnProperty.call(res, m)) {
911
- var deepKey = "".concat(newKeyToUse).concat(keySeparator).concat(m);
912
- copy[m] = this.translate(deepKey, _objectSpread$2$1(_objectSpread$2$1({}, options), {
913
- joinArrays: false,
914
- ns: namespaces
915
- }));
916
- if (copy[m] === deepKey) copy[m] = res[m];
917
- }
918
- }
919
- res = copy;
920
- }
921
- } else if (handleAsObjectInI18nFormat && typeof joinArrays === 'string' && resType === '[object Array]') {
922
- res = res.join(joinArrays);
923
- if (res) res = this.extendTranslation(res, keys, options, lastKey);
924
- } else {
925
- var usedDefault = false;
926
- var usedKey = false;
927
- var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
928
- var hasDefaultValue = Translator.hasDefaultValue(options);
929
- var defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
930
- var defaultValue = options["defaultValue".concat(defaultValueSuffix)] || options.defaultValue;
931
- if (!this.isValidLookup(res) && hasDefaultValue) {
932
- usedDefault = true;
933
- res = defaultValue;
934
- }
935
- if (!this.isValidLookup(res)) {
936
- usedKey = true;
937
- res = key;
938
- }
939
- var missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
940
- var resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
941
- var updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
942
- if (usedKey || usedDefault || updateMissing) {
943
- this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
944
- if (keySeparator) {
945
- var fk = this.resolve(key, _objectSpread$2$1(_objectSpread$2$1({}, options), {}, {
946
- keySeparator: false
947
- }));
948
- 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.');
949
- }
950
- var lngs = [];
951
- var fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
952
- if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
953
- for (var i = 0; i < fallbackLngs.length; i++) {
954
- lngs.push(fallbackLngs[i]);
955
- }
956
- } else if (this.options.saveMissingTo === 'all') {
957
- lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
958
- } else {
959
- lngs.push(options.lng || this.language);
960
- }
961
- var send = function send(l, k, specificDefaultValue) {
962
- var defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
963
- if (_this2.options.missingKeyHandler) {
964
- _this2.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
965
- } else if (_this2.backendConnector && _this2.backendConnector.saveMissing) {
966
- _this2.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
967
- }
968
- _this2.emit('missingKey', l, namespace, k, res);
969
- };
970
- if (this.options.saveMissing) {
971
- if (this.options.saveMissingPlurals && needsPluralHandling) {
972
- lngs.forEach(function (language) {
973
- _this2.pluralResolver.getSuffixes(language, options).forEach(function (suffix) {
974
- send([language], key + suffix, options["defaultValue".concat(suffix)] || defaultValue);
975
- });
976
- });
977
- } else {
978
- send(lngs, key, defaultValue);
979
- }
980
- }
981
- }
982
- res = this.extendTranslation(res, keys, options, resolved, lastKey);
983
- if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = "".concat(namespace, ":").concat(key);
984
- if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
985
- if (this.options.compatibilityAPI !== 'v1') {
986
- res = this.options.parseMissingKeyHandler(key, usedDefault ? res : undefined);
987
- } else {
988
- res = this.options.parseMissingKeyHandler(res);
989
- }
990
- }
991
- }
992
- if (returnDetails) {
993
- resolved.res = res;
994
- return resolved;
995
- }
996
- return res;
997
- }
998
- }, {
999
- key: "extendTranslation",
1000
- value: function extendTranslation(res, key, options, resolved, lastKey) {
1001
- var _this3 = this;
1002
- if (this.i18nFormat && this.i18nFormat.parse) {
1003
- res = this.i18nFormat.parse(res, _objectSpread$2$1(_objectSpread$2$1({}, this.options.interpolation.defaultVariables), options), resolved.usedLng, resolved.usedNS, resolved.usedKey, {
1004
- resolved: resolved
1005
- });
1006
- } else if (!options.skipInterpolation) {
1007
- if (options.interpolation) this.interpolator.init(_objectSpread$2$1(_objectSpread$2$1({}, options), {
1008
- interpolation: _objectSpread$2$1(_objectSpread$2$1({}, this.options.interpolation), options.interpolation)
1009
- }));
1010
- var skipOnVariables = typeof res === 'string' && (options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
1011
- var nestBef;
1012
- if (skipOnVariables) {
1013
- var nb = res.match(this.interpolator.nestingRegexp);
1014
- nestBef = nb && nb.length;
1015
- }
1016
- var data = options.replace && typeof options.replace !== 'string' ? options.replace : options;
1017
- if (this.options.interpolation.defaultVariables) data = _objectSpread$2$1(_objectSpread$2$1({}, this.options.interpolation.defaultVariables), data);
1018
- res = this.interpolator.interpolate(res, data, options.lng || this.language, options);
1019
- if (skipOnVariables) {
1020
- var na = res.match(this.interpolator.nestingRegexp);
1021
- var nestAft = na && na.length;
1022
- if (nestBef < nestAft) options.nest = false;
1023
- }
1024
- if (options.nest !== false) res = this.interpolator.nest(res, function () {
1025
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1026
- args[_key] = arguments[_key];
1027
- }
1028
- if (lastKey && lastKey[0] === args[0] && !options.context) {
1029
- _this3.logger.warn("It seems you are nesting recursively key: ".concat(args[0], " in key: ").concat(key[0]));
1030
- return null;
1031
- }
1032
- return _this3.translate.apply(_this3, args.concat([key]));
1033
- }, options);
1034
- if (options.interpolation) this.interpolator.reset();
1035
- }
1036
- var postProcess = options.postProcess || this.options.postProcess;
1037
- var postProcessorNames = typeof postProcess === 'string' ? [postProcess] : postProcess;
1038
- if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
1039
- res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? _objectSpread$2$1({
1040
- i18nResolved: resolved
1041
- }, options) : options, this);
1042
- }
1043
- return res;
1044
- }
1045
- }, {
1046
- key: "resolve",
1047
- value: function resolve(keys) {
1048
- var _this4 = this;
1049
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1050
- var found;
1051
- var usedKey;
1052
- var exactUsedKey;
1053
- var usedLng;
1054
- var usedNS;
1055
- if (typeof keys === 'string') keys = [keys];
1056
- keys.forEach(function (k) {
1057
- if (_this4.isValidLookup(found)) return;
1058
- var extracted = _this4.extractFromKey(k, options);
1059
- var key = extracted.key;
1060
- usedKey = key;
1061
- var namespaces = extracted.namespaces;
1062
- if (_this4.options.fallbackNS) namespaces = namespaces.concat(_this4.options.fallbackNS);
1063
- var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
1064
- var needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && _this4.pluralResolver.shouldUseIntlApi();
1065
- var needsContextHandling = options.context !== undefined && (typeof options.context === 'string' || typeof options.context === 'number') && options.context !== '';
1066
- var codes = options.lngs ? options.lngs : _this4.languageUtils.toResolveHierarchy(options.lng || _this4.language, options.fallbackLng);
1067
- namespaces.forEach(function (ns) {
1068
- if (_this4.isValidLookup(found)) return;
1069
- usedNS = ns;
1070
- if (!checkedLoadedFor["".concat(codes[0], "-").concat(ns)] && _this4.utils && _this4.utils.hasLoadedNamespace && !_this4.utils.hasLoadedNamespace(usedNS)) {
1071
- checkedLoadedFor["".concat(codes[0], "-").concat(ns)] = true;
1072
- _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!!!');
1073
- }
1074
- codes.forEach(function (code) {
1075
- if (_this4.isValidLookup(found)) return;
1076
- usedLng = code;
1077
- var finalKeys = [key];
1078
- if (_this4.i18nFormat && _this4.i18nFormat.addLookupKeys) {
1079
- _this4.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
1080
- } else {
1081
- var pluralSuffix;
1082
- if (needsPluralHandling) pluralSuffix = _this4.pluralResolver.getSuffix(code, options.count, options);
1083
- var zeroSuffix = '_zero';
1084
- if (needsPluralHandling) {
1085
- finalKeys.push(key + pluralSuffix);
1086
- if (needsZeroSuffixLookup) {
1087
- finalKeys.push(key + zeroSuffix);
1088
- }
1089
- }
1090
- if (needsContextHandling) {
1091
- var contextKey = "".concat(key).concat(_this4.options.contextSeparator).concat(options.context);
1092
- finalKeys.push(contextKey);
1093
- if (needsPluralHandling) {
1094
- finalKeys.push(contextKey + pluralSuffix);
1095
- if (needsZeroSuffixLookup) {
1096
- finalKeys.push(contextKey + zeroSuffix);
1097
- }
1098
- }
1099
- }
1100
- }
1101
- var possibleKey;
1102
- while (possibleKey = finalKeys.pop()) {
1103
- if (!_this4.isValidLookup(found)) {
1104
- exactUsedKey = possibleKey;
1105
- found = _this4.getResource(code, ns, possibleKey, options);
1106
- }
1107
- }
1108
- });
1109
- });
1110
- });
1111
- return {
1112
- res: found,
1113
- usedKey: usedKey,
1114
- exactUsedKey: exactUsedKey,
1115
- usedLng: usedLng,
1116
- usedNS: usedNS
1117
- };
1118
- }
1119
- }, {
1120
- key: "isValidLookup",
1121
- value: function isValidLookup(res) {
1122
- return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
1123
- }
1124
- }, {
1125
- key: "getResource",
1126
- value: function getResource(code, ns, key) {
1127
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1128
- if (this.i18nFormat && this.i18nFormat.getResource) return this.i18nFormat.getResource(code, ns, key, options);
1129
- return this.resourceStore.getResource(code, ns, key, options);
1130
- }
1131
- }], [{
1132
- key: "hasDefaultValue",
1133
- value: function hasDefaultValue(options) {
1134
- var prefix = 'defaultValue';
1135
- for (var option in options) {
1136
- if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {
1137
- return true;
1138
- }
1139
- }
1140
- return false;
1141
- }
1142
- }]);
1143
- return Translator;
1144
- }(EventEmitter);
1145
- function capitalize(string) {
1146
- return string.charAt(0).toUpperCase() + string.slice(1);
1147
- }
1148
- var LanguageUtil = function () {
1149
- function LanguageUtil(options) {
1150
- _classCallCheck$1(this, LanguageUtil);
1151
- this.options = options;
1152
- this.supportedLngs = this.options.supportedLngs || false;
1153
- this.logger = baseLogger.create('languageUtils');
1154
- }
1155
- _createClass$1(LanguageUtil, [{
1156
- key: "getScriptPartFromCode",
1157
- value: function getScriptPartFromCode(code) {
1158
- if (!code || code.indexOf('-') < 0) return null;
1159
- var p = code.split('-');
1160
- if (p.length === 2) return null;
1161
- p.pop();
1162
- if (p[p.length - 1].toLowerCase() === 'x') return null;
1163
- return this.formatLanguageCode(p.join('-'));
1164
- }
1165
- }, {
1166
- key: "getLanguagePartFromCode",
1167
- value: function getLanguagePartFromCode(code) {
1168
- if (!code || code.indexOf('-') < 0) return code;
1169
- var p = code.split('-');
1170
- return this.formatLanguageCode(p[0]);
1171
- }
1172
- }, {
1173
- key: "formatLanguageCode",
1174
- value: function formatLanguageCode(code) {
1175
- if (typeof code === 'string' && code.indexOf('-') > -1) {
1176
- var specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];
1177
- var p = code.split('-');
1178
- if (this.options.lowerCaseLng) {
1179
- p = p.map(function (part) {
1180
- return part.toLowerCase();
1181
- });
1182
- } else if (p.length === 2) {
1183
- p[0] = p[0].toLowerCase();
1184
- p[1] = p[1].toUpperCase();
1185
- if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
1186
- } else if (p.length === 3) {
1187
- p[0] = p[0].toLowerCase();
1188
- if (p[1].length === 2) p[1] = p[1].toUpperCase();
1189
- if (p[0] !== 'sgn' && p[2].length === 2) p[2] = p[2].toUpperCase();
1190
- if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
1191
- if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());
1192
- }
1193
- return p.join('-');
1194
- }
1195
- return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
1196
- }
1197
- }, {
1198
- key: "isSupportedCode",
1199
- value: function isSupportedCode(code) {
1200
- if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
1201
- code = this.getLanguagePartFromCode(code);
1202
- }
1203
- return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
1204
- }
1205
- }, {
1206
- key: "getBestMatchFromCodes",
1207
- value: function getBestMatchFromCodes(codes) {
1208
- var _this = this;
1209
- if (!codes) return null;
1210
- var found;
1211
- codes.forEach(function (code) {
1212
- if (found) return;
1213
- var cleanedLng = _this.formatLanguageCode(code);
1214
- if (!_this.options.supportedLngs || _this.isSupportedCode(cleanedLng)) found = cleanedLng;
1215
- });
1216
- if (!found && this.options.supportedLngs) {
1217
- codes.forEach(function (code) {
1218
- if (found) return;
1219
- var lngOnly = _this.getLanguagePartFromCode(code);
1220
- if (_this.isSupportedCode(lngOnly)) return found = lngOnly;
1221
- found = _this.options.supportedLngs.find(function (supportedLng) {
1222
- if (supportedLng.indexOf(lngOnly) === 0) return supportedLng;
1223
- });
1224
- });
1225
- }
1226
- if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
1227
- return found;
1228
- }
1229
- }, {
1230
- key: "getFallbackCodes",
1231
- value: function getFallbackCodes(fallbacks, code) {
1232
- if (!fallbacks) return [];
1233
- if (typeof fallbacks === 'function') fallbacks = fallbacks(code);
1234
- if (typeof fallbacks === 'string') fallbacks = [fallbacks];
1235
- if (Object.prototype.toString.apply(fallbacks) === '[object Array]') return fallbacks;
1236
- if (!code) return fallbacks["default"] || [];
1237
- var found = fallbacks[code];
1238
- if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
1239
- if (!found) found = fallbacks[this.formatLanguageCode(code)];
1240
- if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
1241
- if (!found) found = fallbacks["default"];
1242
- return found || [];
1243
- }
1244
- }, {
1245
- key: "toResolveHierarchy",
1246
- value: function toResolveHierarchy(code, fallbackCode) {
1247
- var _this2 = this;
1248
- var fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
1249
- var codes = [];
1250
- var addCode = function addCode(c) {
1251
- if (!c) return;
1252
- if (_this2.isSupportedCode(c)) {
1253
- codes.push(c);
1254
- } else {
1255
- _this2.logger.warn("rejecting language code not found in supportedLngs: ".concat(c));
1256
- }
1257
- };
1258
- if (typeof code === 'string' && code.indexOf('-') > -1) {
1259
- if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
1260
- if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
1261
- if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
1262
- } else if (typeof code === 'string') {
1263
- addCode(this.formatLanguageCode(code));
1264
- }
1265
- fallbackCodes.forEach(function (fc) {
1266
- if (codes.indexOf(fc) < 0) addCode(_this2.formatLanguageCode(fc));
1267
- });
1268
- return codes;
1269
- }
1270
- }]);
1271
- return LanguageUtil;
1272
- }();
1273
- var sets = [{
1274
- lngs: ['ach', 'ak', 'am', 'arn', 'br', 'fil', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt', 'pt-BR', 'tg', 'tl', 'ti', 'tr', 'uz', 'wa'],
1275
- nr: [1, 2],
1276
- fc: 1
1277
- }, {
1278
- 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'],
1279
- nr: [1, 2],
1280
- fc: 2
1281
- }, {
1282
- lngs: ['ay', 'bo', 'cgg', 'fa', 'ht', 'id', 'ja', 'jbo', 'ka', 'km', 'ko', 'ky', 'lo', 'ms', 'sah', 'su', 'th', 'tt', 'ug', 'vi', 'wo', 'zh'],
1283
- nr: [1],
1284
- fc: 3
1285
- }, {
1286
- lngs: ['be', 'bs', 'cnr', 'dz', 'hr', 'ru', 'sr', 'uk'],
1287
- nr: [1, 2, 5],
1288
- fc: 4
1289
- }, {
1290
- lngs: ['ar'],
1291
- nr: [0, 1, 2, 3, 11, 100],
1292
- fc: 5
1293
- }, {
1294
- lngs: ['cs', 'sk'],
1295
- nr: [1, 2, 5],
1296
- fc: 6
1297
- }, {
1298
- lngs: ['csb', 'pl'],
1299
- nr: [1, 2, 5],
1300
- fc: 7
1301
- }, {
1302
- lngs: ['cy'],
1303
- nr: [1, 2, 3, 8],
1304
- fc: 8
1305
- }, {
1306
- lngs: ['fr'],
1307
- nr: [1, 2],
1308
- fc: 9
1309
- }, {
1310
- lngs: ['ga'],
1311
- nr: [1, 2, 3, 7, 11],
1312
- fc: 10
1313
- }, {
1314
- lngs: ['gd'],
1315
- nr: [1, 2, 3, 20],
1316
- fc: 11
1317
- }, {
1318
- lngs: ['is'],
1319
- nr: [1, 2],
1320
- fc: 12
1321
- }, {
1322
- lngs: ['jv'],
1323
- nr: [0, 1],
1324
- fc: 13
1325
- }, {
1326
- lngs: ['kw'],
1327
- nr: [1, 2, 3, 4],
1328
- fc: 14
1329
- }, {
1330
- lngs: ['lt'],
1331
- nr: [1, 2, 10],
1332
- fc: 15
1333
- }, {
1334
- lngs: ['lv'],
1335
- nr: [1, 2, 0],
1336
- fc: 16
1337
- }, {
1338
- lngs: ['mk'],
1339
- nr: [1, 2],
1340
- fc: 17
1341
- }, {
1342
- lngs: ['mnk'],
1343
- nr: [0, 1, 2],
1344
- fc: 18
1345
- }, {
1346
- lngs: ['mt'],
1347
- nr: [1, 2, 11, 20],
1348
- fc: 19
1349
- }, {
1350
- lngs: ['or'],
1351
- nr: [2, 1],
1352
- fc: 2
1353
- }, {
1354
- lngs: ['ro'],
1355
- nr: [1, 2, 20],
1356
- fc: 20
1357
- }, {
1358
- lngs: ['sl'],
1359
- nr: [5, 1, 2, 3],
1360
- fc: 21
1361
- }, {
1362
- lngs: ['he', 'iw'],
1363
- nr: [1, 2, 20, 21],
1364
- fc: 22
1365
- }];
1366
- var _rulesPluralsTypes = {
1367
- 1: function _(n) {
1368
- return Number(n > 1);
1369
- },
1370
- 2: function _(n) {
1371
- return Number(n != 1);
1372
- },
1373
- 3: function _(n) {
1374
- return 0;
1375
- },
1376
- 4: function _(n) {
1377
- return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
1378
- },
1379
- 5: function _(n) {
1380
- return Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5);
1381
- },
1382
- 6: function _(n) {
1383
- return Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2);
1384
- },
1385
- 7: function _(n) {
1386
- return Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
1387
- },
1388
- 8: function _(n) {
1389
- return Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3);
1390
- },
1391
- 9: function _(n) {
1392
- return Number(n >= 2);
1393
- },
1394
- 10: function _(n) {
1395
- return Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4);
1396
- },
1397
- 11: function _(n) {
1398
- return Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3);
1399
- },
1400
- 12: function _(n) {
1401
- return Number(n % 10 != 1 || n % 100 == 11);
1402
- },
1403
- 13: function _(n) {
1404
- return Number(n !== 0);
1405
- },
1406
- 14: function _(n) {
1407
- return Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3);
1408
- },
1409
- 15: function _(n) {
1410
- return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
1411
- },
1412
- 16: function _(n) {
1413
- return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2);
1414
- },
1415
- 17: function _(n) {
1416
- return Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1);
1417
- },
1418
- 18: function _(n) {
1419
- return Number(n == 0 ? 0 : n == 1 ? 1 : 2);
1420
- },
1421
- 19: function _(n) {
1422
- return Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3);
1423
- },
1424
- 20: function _(n) {
1425
- return Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2);
1426
- },
1427
- 21: function _(n) {
1428
- return Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0);
1429
- },
1430
- 22: function _(n) {
1431
- return Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3);
1432
- }
1433
- };
1434
- var deprecatedJsonVersions = ['v1', 'v2', 'v3'];
1435
- var suffixesOrder = {
1436
- zero: 0,
1437
- one: 1,
1438
- two: 2,
1439
- few: 3,
1440
- many: 4,
1441
- other: 5
1442
- };
1443
- function createRules() {
1444
- var rules = {};
1445
- sets.forEach(function (set) {
1446
- set.lngs.forEach(function (l) {
1447
- rules[l] = {
1448
- numbers: set.nr,
1449
- plurals: _rulesPluralsTypes[set.fc]
1450
- };
1451
- });
1452
- });
1453
- return rules;
1454
- }
1455
- var PluralResolver = function () {
1456
- function PluralResolver(languageUtils) {
1457
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1458
- _classCallCheck$1(this, PluralResolver);
1459
- this.languageUtils = languageUtils;
1460
- this.options = options;
1461
- this.logger = baseLogger.create('pluralResolver');
1462
- if ((!this.options.compatibilityJSON || this.options.compatibilityJSON === 'v4') && (typeof Intl === 'undefined' || !Intl.PluralRules)) {
1463
- this.options.compatibilityJSON = 'v3';
1464
- 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.');
1465
- }
1466
- this.rules = createRules();
1467
- }
1468
- _createClass$1(PluralResolver, [{
1469
- key: "addRule",
1470
- value: function addRule(lng, obj) {
1471
- this.rules[lng] = obj;
1472
- }
1473
- }, {
1474
- key: "getRule",
1475
- value: function getRule(code) {
1476
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1477
- if (this.shouldUseIntlApi()) {
1478
- try {
1479
- return new Intl.PluralRules(code, {
1480
- type: options.ordinal ? 'ordinal' : 'cardinal'
1481
- });
1482
- } catch (_unused) {
1483
- return;
1484
- }
1485
- }
1486
- return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];
1487
- }
1488
- }, {
1489
- key: "needsPlural",
1490
- value: function needsPlural(code) {
1491
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1492
- var rule = this.getRule(code, options);
1493
- if (this.shouldUseIntlApi()) {
1494
- return rule && rule.resolvedOptions().pluralCategories.length > 1;
1495
- }
1496
- return rule && rule.numbers.length > 1;
1497
- }
1498
- }, {
1499
- key: "getPluralFormsOfKey",
1500
- value: function getPluralFormsOfKey(code, key) {
1501
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1502
- return this.getSuffixes(code, options).map(function (suffix) {
1503
- return "".concat(key).concat(suffix);
1504
- });
1505
- }
1506
- }, {
1507
- key: "getSuffixes",
1508
- value: function getSuffixes(code) {
1509
- var _this = this;
1510
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1511
- var rule = this.getRule(code, options);
1512
- if (!rule) {
1513
- return [];
1514
- }
1515
- if (this.shouldUseIntlApi()) {
1516
- return rule.resolvedOptions().pluralCategories.sort(function (pluralCategory1, pluralCategory2) {
1517
- return suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2];
1518
- }).map(function (pluralCategory) {
1519
- return "".concat(_this.options.prepend).concat(pluralCategory);
1520
- });
1521
- }
1522
- return rule.numbers.map(function (number) {
1523
- return _this.getSuffix(code, number, options);
1524
- });
1525
- }
1526
- }, {
1527
- key: "getSuffix",
1528
- value: function getSuffix(code, count) {
1529
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1530
- var rule = this.getRule(code, options);
1531
- if (rule) {
1532
- if (this.shouldUseIntlApi()) {
1533
- return "".concat(this.options.prepend).concat(rule.select(count));
1534
- }
1535
- return this.getSuffixRetroCompatible(rule, count);
1536
- }
1537
- this.logger.warn("no plural rule found for: ".concat(code));
1538
- return '';
1539
- }
1540
- }, {
1541
- key: "getSuffixRetroCompatible",
1542
- value: function getSuffixRetroCompatible(rule, count) {
1543
- var _this2 = this;
1544
- var idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
1545
- var suffix = rule.numbers[idx];
1546
- if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
1547
- if (suffix === 2) {
1548
- suffix = 'plural';
1549
- } else if (suffix === 1) {
1550
- suffix = '';
1551
- }
1552
- }
1553
- var returnSuffix = function returnSuffix() {
1554
- return _this2.options.prepend && suffix.toString() ? _this2.options.prepend + suffix.toString() : suffix.toString();
1555
- };
1556
- if (this.options.compatibilityJSON === 'v1') {
1557
- if (suffix === 1) return '';
1558
- if (typeof suffix === 'number') return "_plural_".concat(suffix.toString());
1559
- return returnSuffix();
1560
- } else if (this.options.compatibilityJSON === 'v2') {
1561
- return returnSuffix();
1562
- } else if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
1563
- return returnSuffix();
1564
- }
1565
- return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
1566
- }
1567
- }, {
1568
- key: "shouldUseIntlApi",
1569
- value: function shouldUseIntlApi() {
1570
- return !deprecatedJsonVersions.includes(this.options.compatibilityJSON);
1571
- }
1572
- }]);
1573
- return PluralResolver;
1574
- }();
1575
- function ownKeys$3$1(object, enumerableOnly) {
1576
- var keys = Object.keys(object);
1577
- if (Object.getOwnPropertySymbols) {
1578
- var symbols = Object.getOwnPropertySymbols(object);
1579
- if (enumerableOnly) {
1580
- symbols = symbols.filter(function (sym) {
1581
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
1582
- });
1583
- }
1584
- keys.push.apply(keys, symbols);
1585
- }
1586
- return keys;
1587
- }
1588
- function _objectSpread$3$1(target) {
1589
- for (var i = 1; i < arguments.length; i++) {
1590
- var source = arguments[i] != null ? arguments[i] : {};
1591
- if (i % 2) {
1592
- ownKeys$3$1(Object(source), true).forEach(function (key) {
1593
- _defineProperty$2(target, key, source[key]);
1594
- });
1595
- } else if (Object.getOwnPropertyDescriptors) {
1596
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
1597
- } else {
1598
- ownKeys$3$1(Object(source)).forEach(function (key) {
1599
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1600
- });
1601
- }
1602
- }
1603
- return target;
1604
- }
1605
- var Interpolator = function () {
1606
- function Interpolator() {
1607
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1608
- _classCallCheck$1(this, Interpolator);
1609
- this.logger = baseLogger.create('interpolator');
1610
- this.options = options;
1611
- this.format = options.interpolation && options.interpolation.format || function (value) {
1612
- return value;
1613
- };
1614
- this.init(options);
1615
- }
1616
- _createClass$1(Interpolator, [{
1617
- key: "init",
1618
- value: function init() {
1619
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1620
- if (!options.interpolation) options.interpolation = {
1621
- escapeValue: true
1622
- };
1623
- var iOpts = options.interpolation;
1624
- this.escape = iOpts.escape !== undefined ? iOpts.escape : escape;
1625
- this.escapeValue = iOpts.escapeValue !== undefined ? iOpts.escapeValue : true;
1626
- this.useRawValueToEscape = iOpts.useRawValueToEscape !== undefined ? iOpts.useRawValueToEscape : false;
1627
- this.prefix = iOpts.prefix ? regexEscape(iOpts.prefix) : iOpts.prefixEscaped || '{{';
1628
- this.suffix = iOpts.suffix ? regexEscape(iOpts.suffix) : iOpts.suffixEscaped || '}}';
1629
- this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
1630
- this.unescapePrefix = iOpts.unescapeSuffix ? '' : iOpts.unescapePrefix || '-';
1631
- this.unescapeSuffix = this.unescapePrefix ? '' : iOpts.unescapeSuffix || '';
1632
- this.nestingPrefix = iOpts.nestingPrefix ? regexEscape(iOpts.nestingPrefix) : iOpts.nestingPrefixEscaped || regexEscape('$t(');
1633
- this.nestingSuffix = iOpts.nestingSuffix ? regexEscape(iOpts.nestingSuffix) : iOpts.nestingSuffixEscaped || regexEscape(')');
1634
- this.nestingOptionsSeparator = iOpts.nestingOptionsSeparator ? iOpts.nestingOptionsSeparator : iOpts.nestingOptionsSeparator || ',';
1635
- this.maxReplaces = iOpts.maxReplaces ? iOpts.maxReplaces : 1000;
1636
- this.alwaysFormat = iOpts.alwaysFormat !== undefined ? iOpts.alwaysFormat : false;
1637
- this.resetRegExp();
1638
- }
1639
- }, {
1640
- key: "reset",
1641
- value: function reset() {
1642
- if (this.options) this.init(this.options);
1643
- }
1644
- }, {
1645
- key: "resetRegExp",
1646
- value: function resetRegExp() {
1647
- var regexpStr = "".concat(this.prefix, "(.+?)").concat(this.suffix);
1648
- this.regexp = new RegExp(regexpStr, 'g');
1649
- var regexpUnescapeStr = "".concat(this.prefix).concat(this.unescapePrefix, "(.+?)").concat(this.unescapeSuffix).concat(this.suffix);
1650
- this.regexpUnescape = new RegExp(regexpUnescapeStr, 'g');
1651
- var nestingRegexpStr = "".concat(this.nestingPrefix, "(.+?)").concat(this.nestingSuffix);
1652
- this.nestingRegexp = new RegExp(nestingRegexpStr, 'g');
1653
- }
1654
- }, {
1655
- key: "interpolate",
1656
- value: function interpolate(str, data, lng, options) {
1657
- var _this = this;
1658
- var match;
1659
- var value;
1660
- var replaces;
1661
- var defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
1662
- function regexSafe(val) {
1663
- return val.replace(/\$/g, '$$$$');
1664
- }
1665
- var handleFormat = function handleFormat(key) {
1666
- if (key.indexOf(_this.formatSeparator) < 0) {
1667
- var path = getPathWithDefaults(data, defaultData, key);
1668
- return _this.alwaysFormat ? _this.format(path, undefined, lng, _objectSpread$3$1(_objectSpread$3$1(_objectSpread$3$1({}, options), data), {}, {
1669
- interpolationkey: key
1670
- })) : path;
1671
- }
1672
- var p = key.split(_this.formatSeparator);
1673
- var k = p.shift().trim();
1674
- var f = p.join(_this.formatSeparator).trim();
1675
- return _this.format(getPathWithDefaults(data, defaultData, k), f, lng, _objectSpread$3$1(_objectSpread$3$1(_objectSpread$3$1({}, options), data), {}, {
1676
- interpolationkey: k
1677
- }));
1678
- };
1679
- this.resetRegExp();
1680
- var missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;
1681
- var skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
1682
- var todos = [{
1683
- regex: this.regexpUnescape,
1684
- safeValue: function safeValue(val) {
1685
- return regexSafe(val);
1686
- }
1687
- }, {
1688
- regex: this.regexp,
1689
- safeValue: function safeValue(val) {
1690
- return _this.escapeValue ? regexSafe(_this.escape(val)) : regexSafe(val);
1691
- }
1692
- }];
1693
- todos.forEach(function (todo) {
1694
- replaces = 0;
1695
- while (match = todo.regex.exec(str)) {
1696
- var matchedVar = match[1].trim();
1697
- value = handleFormat(matchedVar);
1698
- if (value === undefined) {
1699
- if (typeof missingInterpolationHandler === 'function') {
1700
- var temp = missingInterpolationHandler(str, match, options);
1701
- value = typeof temp === 'string' ? temp : '';
1702
- } else if (options && options.hasOwnProperty(matchedVar)) {
1703
- value = '';
1704
- } else if (skipOnVariables) {
1705
- value = match[0];
1706
- continue;
1707
- } else {
1708
- _this.logger.warn("missed to pass in variable ".concat(matchedVar, " for interpolating ").concat(str));
1709
- value = '';
1710
- }
1711
- } else if (typeof value !== 'string' && !_this.useRawValueToEscape) {
1712
- value = makeString(value);
1713
- }
1714
- var safeValue = todo.safeValue(value);
1715
- str = str.replace(match[0], safeValue);
1716
- if (skipOnVariables) {
1717
- todo.regex.lastIndex += safeValue.length;
1718
- todo.regex.lastIndex -= match[0].length;
1719
- } else {
1720
- todo.regex.lastIndex = 0;
1721
- }
1722
- replaces++;
1723
- if (replaces >= _this.maxReplaces) {
1724
- break;
1725
- }
1726
- }
1727
- });
1728
- return str;
1729
- }
1730
- }, {
1731
- key: "nest",
1732
- value: function nest(str, fc) {
1733
- var _this2 = this;
1734
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1735
- var match;
1736
- var value;
1737
- var clonedOptions = _objectSpread$3$1({}, options);
1738
- clonedOptions.applyPostProcessor = false;
1739
- delete clonedOptions.defaultValue;
1740
- function handleHasOptions(key, inheritedOptions) {
1741
- var sep = this.nestingOptionsSeparator;
1742
- if (key.indexOf(sep) < 0) return key;
1743
- var c = key.split(new RegExp("".concat(sep, "[ ]*{")));
1744
- var optionsString = "{".concat(c[1]);
1745
- key = c[0];
1746
- optionsString = this.interpolate(optionsString, clonedOptions);
1747
- optionsString = optionsString.replace(/'/g, '"');
1748
- try {
1749
- clonedOptions = JSON.parse(optionsString);
1750
- if (inheritedOptions) clonedOptions = _objectSpread$3$1(_objectSpread$3$1({}, inheritedOptions), clonedOptions);
1751
- } catch (e) {
1752
- this.logger.warn("failed parsing options string in nesting for key ".concat(key), e);
1753
- return "".concat(key).concat(sep).concat(optionsString);
1754
- }
1755
- delete clonedOptions.defaultValue;
1756
- return key;
1757
- }
1758
- while (match = this.nestingRegexp.exec(str)) {
1759
- var formatters = [];
1760
- var doReduce = false;
1761
- if (match[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match[1])) {
1762
- var r = match[1].split(this.formatSeparator).map(function (elem) {
1763
- return elem.trim();
1764
- });
1765
- match[1] = r.shift();
1766
- formatters = r;
1767
- doReduce = true;
1768
- }
1769
- value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
1770
- if (value && match[0] === str && typeof value !== 'string') return value;
1771
- if (typeof value !== 'string') value = makeString(value);
1772
- if (!value) {
1773
- this.logger.warn("missed to resolve ".concat(match[1], " for nesting ").concat(str));
1774
- value = '';
1775
- }
1776
- if (doReduce) {
1777
- value = formatters.reduce(function (v, f) {
1778
- return _this2.format(v, f, options.lng, _objectSpread$3$1(_objectSpread$3$1({}, options), {}, {
1779
- interpolationkey: match[1].trim()
1780
- }));
1781
- }, value.trim());
1782
- }
1783
- str = str.replace(match[0], value);
1784
- this.regexp.lastIndex = 0;
1785
- }
1786
- return str;
1787
- }
1788
- }]);
1789
- return Interpolator;
1790
- }();
1791
- function ownKeys$4$1(object, enumerableOnly) {
1792
- var keys = Object.keys(object);
1793
- if (Object.getOwnPropertySymbols) {
1794
- var symbols = Object.getOwnPropertySymbols(object);
1795
- if (enumerableOnly) {
1796
- symbols = symbols.filter(function (sym) {
1797
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
1798
- });
1799
- }
1800
- keys.push.apply(keys, symbols);
1801
- }
1802
- return keys;
1803
- }
1804
- function _objectSpread$4$1(target) {
1805
- for (var i = 1; i < arguments.length; i++) {
1806
- var source = arguments[i] != null ? arguments[i] : {};
1807
- if (i % 2) {
1808
- ownKeys$4$1(Object(source), true).forEach(function (key) {
1809
- _defineProperty$2(target, key, source[key]);
1810
- });
1811
- } else if (Object.getOwnPropertyDescriptors) {
1812
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
1813
- } else {
1814
- ownKeys$4$1(Object(source)).forEach(function (key) {
1815
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1816
- });
1817
- }
1818
- }
1819
- return target;
1820
- }
1821
- function parseFormatStr(formatStr) {
1822
- var formatName = formatStr.toLowerCase().trim();
1823
- var formatOptions = {};
1824
- if (formatStr.indexOf('(') > -1) {
1825
- var p = formatStr.split('(');
1826
- formatName = p[0].toLowerCase().trim();
1827
- var optStr = p[1].substring(0, p[1].length - 1);
1828
- if (formatName === 'currency' && optStr.indexOf(':') < 0) {
1829
- if (!formatOptions.currency) formatOptions.currency = optStr.trim();
1830
- } else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {
1831
- if (!formatOptions.range) formatOptions.range = optStr.trim();
1832
- } else {
1833
- var opts = optStr.split(';');
1834
- opts.forEach(function (opt) {
1835
- if (!opt) return;
1836
- var _opt$split = opt.split(':'),
1837
- _opt$split2 = _toArray(_opt$split),
1838
- key = _opt$split2[0],
1839
- rest = _opt$split2.slice(1);
1840
- var val = rest.join(':');
1841
- if (!formatOptions[key.trim()]) formatOptions[key.trim()] = val.trim();
1842
- if (val.trim() === 'false') formatOptions[key.trim()] = false;
1843
- if (val.trim() === 'true') formatOptions[key.trim()] = true;
1844
- if (!isNaN(val.trim())) formatOptions[key.trim()] = parseInt(val.trim(), 10);
1845
- });
1846
- }
1847
- }
1848
- return {
1849
- formatName: formatName,
1850
- formatOptions: formatOptions
1851
- };
1852
- }
1853
- var Formatter = function () {
1854
- function Formatter() {
1855
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1856
- _classCallCheck$1(this, Formatter);
1857
- this.logger = baseLogger.create('formatter');
1858
- this.options = options;
1859
- this.formats = {
1860
- number: function number(val, lng, options) {
1861
- return new Intl.NumberFormat(lng, options).format(val);
1862
- },
1863
- currency: function currency(val, lng, options) {
1864
- return new Intl.NumberFormat(lng, _objectSpread$4$1(_objectSpread$4$1({}, options), {}, {
1865
- style: 'currency'
1866
- })).format(val);
1867
- },
1868
- datetime: function datetime(val, lng, options) {
1869
- return new Intl.DateTimeFormat(lng, _objectSpread$4$1({}, options)).format(val);
1870
- },
1871
- relativetime: function relativetime(val, lng, options) {
1872
- return new Intl.RelativeTimeFormat(lng, _objectSpread$4$1({}, options)).format(val, options.range || 'day');
1873
- },
1874
- list: function list(val, lng, options) {
1875
- return new Intl.ListFormat(lng, _objectSpread$4$1({}, options)).format(val);
1876
- }
1877
- };
1878
- this.init(options);
1879
- }
1880
- _createClass$1(Formatter, [{
1881
- key: "init",
1882
- value: function init(services) {
1883
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
1884
- interpolation: {}
1885
- };
1886
- var iOpts = options.interpolation;
1887
- this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
1888
- }
1889
- }, {
1890
- key: "add",
1891
- value: function add(name, fc) {
1892
- this.formats[name.toLowerCase().trim()] = fc;
1893
- }
1894
- }, {
1895
- key: "format",
1896
- value: function format(value, _format, lng, options) {
1897
- var _this = this;
1898
- var formats = _format.split(this.formatSeparator);
1899
- var result = formats.reduce(function (mem, f) {
1900
- var _parseFormatStr = parseFormatStr(f),
1901
- formatName = _parseFormatStr.formatName,
1902
- formatOptions = _parseFormatStr.formatOptions;
1903
- if (_this.formats[formatName]) {
1904
- var formatted = mem;
1905
- try {
1906
- var valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || {};
1907
- var l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
1908
- formatted = _this.formats[formatName](mem, l, _objectSpread$4$1(_objectSpread$4$1(_objectSpread$4$1({}, formatOptions), options), valOptions));
1909
- } catch (error) {
1910
- _this.logger.warn(error);
1911
- }
1912
- return formatted;
1913
- } else {
1914
- _this.logger.warn("there was no format function for ".concat(formatName));
1915
- }
1916
- return mem;
1917
- }, value);
1918
- return result;
1919
- }
1920
- }]);
1921
- return Formatter;
1922
- }();
1923
- function ownKeys$5$1(object, enumerableOnly) {
1924
- var keys = Object.keys(object);
1925
- if (Object.getOwnPropertySymbols) {
1926
- var symbols = Object.getOwnPropertySymbols(object);
1927
- if (enumerableOnly) {
1928
- symbols = symbols.filter(function (sym) {
1929
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
1930
- });
1931
- }
1932
- keys.push.apply(keys, symbols);
1933
- }
1934
- return keys;
1935
- }
1936
- function _objectSpread$5$1(target) {
1937
- for (var i = 1; i < arguments.length; i++) {
1938
- var source = arguments[i] != null ? arguments[i] : {};
1939
- if (i % 2) {
1940
- ownKeys$5$1(Object(source), true).forEach(function (key) {
1941
- _defineProperty$2(target, key, source[key]);
1942
- });
1943
- } else if (Object.getOwnPropertyDescriptors) {
1944
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
1945
- } else {
1946
- ownKeys$5$1(Object(source)).forEach(function (key) {
1947
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1948
- });
1949
- }
1950
- }
1951
- return target;
1952
- }
1953
- function _createSuper$2(Derived) {
1954
- var hasNativeReflectConstruct = _isNativeReflectConstruct$2();
1955
- return function _createSuperInternal() {
1956
- var Super = _getPrototypeOf(Derived),
1957
- result;
1958
- if (hasNativeReflectConstruct) {
1959
- var NewTarget = _getPrototypeOf(this).constructor;
1960
- result = Reflect.construct(Super, arguments, NewTarget);
1961
- } else {
1962
- result = Super.apply(this, arguments);
1963
- }
1964
- return _possibleConstructorReturn(this, result);
1965
- };
1966
- }
1967
- function _isNativeReflectConstruct$2() {
1968
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
1969
- if (Reflect.construct.sham) return false;
1970
- if (typeof Proxy === "function") return true;
1971
- try {
1972
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
1973
- return true;
1974
- } catch (e) {
1975
- return false;
1976
- }
1977
- }
1978
- function remove(arr, what) {
1979
- var found = arr.indexOf(what);
1980
- while (found !== -1) {
1981
- arr.splice(found, 1);
1982
- found = arr.indexOf(what);
1983
- }
1984
- }
1985
- var Connector = function (_EventEmitter) {
1986
- _inherits(Connector, _EventEmitter);
1987
- var _super = _createSuper$2(Connector);
1988
- function Connector(backend, store, services) {
1989
- var _this;
1990
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1991
- _classCallCheck$1(this, Connector);
1992
- _this = _super.call(this);
1993
- if (isIE10) {
1994
- EventEmitter.call(_assertThisInitialized(_this));
1995
- }
1996
- _this.backend = backend;
1997
- _this.store = store;
1998
- _this.services = services;
1999
- _this.languageUtils = services.languageUtils;
2000
- _this.options = options;
2001
- _this.logger = baseLogger.create('backendConnector');
2002
- _this.state = {};
2003
- _this.queue = [];
2004
- if (_this.backend && _this.backend.init) {
2005
- _this.backend.init(services, options.backend, options);
2006
- }
2007
- return _this;
2008
- }
2009
- _createClass$1(Connector, [{
2010
- key: "queueLoad",
2011
- value: function queueLoad(languages, namespaces, options, callback) {
2012
- var _this2 = this;
2013
- var toLoad = [];
2014
- var pending = [];
2015
- var toLoadLanguages = [];
2016
- var toLoadNamespaces = [];
2017
- languages.forEach(function (lng) {
2018
- var hasAllNamespaces = true;
2019
- namespaces.forEach(function (ns) {
2020
- var name = "".concat(lng, "|").concat(ns);
2021
- if (!options.reload && _this2.store.hasResourceBundle(lng, ns)) {
2022
- _this2.state[name] = 2;
2023
- } else if (_this2.state[name] < 0) ;else if (_this2.state[name] === 1) {
2024
- if (pending.indexOf(name) < 0) pending.push(name);
2025
- } else {
2026
- _this2.state[name] = 1;
2027
- hasAllNamespaces = false;
2028
- if (pending.indexOf(name) < 0) pending.push(name);
2029
- if (toLoad.indexOf(name) < 0) toLoad.push(name);
2030
- if (toLoadNamespaces.indexOf(ns) < 0) toLoadNamespaces.push(ns);
2031
- }
2032
- });
2033
- if (!hasAllNamespaces) toLoadLanguages.push(lng);
2034
- });
2035
- if (toLoad.length || pending.length) {
2036
- this.queue.push({
2037
- pending: pending,
2038
- loaded: {},
2039
- errors: [],
2040
- callback: callback
2041
- });
2042
- }
2043
- return {
2044
- toLoad: toLoad,
2045
- pending: pending,
2046
- toLoadLanguages: toLoadLanguages,
2047
- toLoadNamespaces: toLoadNamespaces
2048
- };
2049
- }
2050
- }, {
2051
- key: "loaded",
2052
- value: function loaded(name, err, data) {
2053
- var s = name.split('|');
2054
- var lng = s[0];
2055
- var ns = s[1];
2056
- if (err) this.emit('failedLoading', lng, ns, err);
2057
- if (data) {
2058
- this.store.addResourceBundle(lng, ns, data);
2059
- }
2060
- this.state[name] = err ? -1 : 2;
2061
- var loaded = {};
2062
- this.queue.forEach(function (q) {
2063
- pushPath(q.loaded, [lng], ns);
2064
- remove(q.pending, name);
2065
- if (err) q.errors.push(err);
2066
- if (q.pending.length === 0 && !q.done) {
2067
- Object.keys(q.loaded).forEach(function (l) {
2068
- if (!loaded[l]) loaded[l] = [];
2069
- if (q.loaded[l].length) {
2070
- q.loaded[l].forEach(function (ns) {
2071
- if (loaded[l].indexOf(ns) < 0) loaded[l].push(ns);
2072
- });
2073
- }
2074
- });
2075
- q.done = true;
2076
- if (q.errors.length) {
2077
- q.callback(q.errors);
2078
- } else {
2079
- q.callback();
2080
- }
2081
- }
2082
- });
2083
- this.emit('loaded', loaded);
2084
- this.queue = this.queue.filter(function (q) {
2085
- return !q.done;
2086
- });
2087
- }
2088
- }, {
2089
- key: "read",
2090
- value: function read(lng, ns, fcName) {
2091
- var _this3 = this;
2092
- var tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
2093
- var wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 350;
2094
- var callback = arguments.length > 5 ? arguments[5] : undefined;
2095
- if (!lng.length) return callback(null, {});
2096
- return this.backend[fcName](lng, ns, function (err, data) {
2097
- if (err && data && tried < 5) {
2098
- setTimeout(function () {
2099
- _this3.read.call(_this3, lng, ns, fcName, tried + 1, wait * 2, callback);
2100
- }, wait);
2101
- return;
2102
- }
2103
- callback(err, data);
2104
- });
2105
- }
2106
- }, {
2107
- key: "prepareLoading",
2108
- value: function prepareLoading(languages, namespaces) {
2109
- var _this4 = this;
2110
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2111
- var callback = arguments.length > 3 ? arguments[3] : undefined;
2112
- if (!this.backend) {
2113
- this.logger.warn('No backend was added via i18next.use. Will not load resources.');
2114
- return callback && callback();
2115
- }
2116
- if (typeof languages === 'string') languages = this.languageUtils.toResolveHierarchy(languages);
2117
- if (typeof namespaces === 'string') namespaces = [namespaces];
2118
- var toLoad = this.queueLoad(languages, namespaces, options, callback);
2119
- if (!toLoad.toLoad.length) {
2120
- if (!toLoad.pending.length) callback();
2121
- return null;
2122
- }
2123
- toLoad.toLoad.forEach(function (name) {
2124
- _this4.loadOne(name);
2125
- });
2126
- }
2127
- }, {
2128
- key: "load",
2129
- value: function load(languages, namespaces, callback) {
2130
- this.prepareLoading(languages, namespaces, {}, callback);
2131
- }
2132
- }, {
2133
- key: "reload",
2134
- value: function reload(languages, namespaces, callback) {
2135
- this.prepareLoading(languages, namespaces, {
2136
- reload: true
2137
- }, callback);
2138
- }
2139
- }, {
2140
- key: "loadOne",
2141
- value: function loadOne(name) {
2142
- var _this5 = this;
2143
- var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
2144
- var s = name.split('|');
2145
- var lng = s[0];
2146
- var ns = s[1];
2147
- this.read(lng, ns, 'read', undefined, undefined, function (err, data) {
2148
- if (err) _this5.logger.warn("".concat(prefix, "loading namespace ").concat(ns, " for language ").concat(lng, " failed"), err);
2149
- if (!err && data) _this5.logger.log("".concat(prefix, "loaded namespace ").concat(ns, " for language ").concat(lng), data);
2150
- _this5.loaded(name, err, data);
2151
- });
2152
- }
2153
- }, {
2154
- key: "saveMissing",
2155
- value: function saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
2156
- var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
2157
- if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {
2158
- 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!!!');
2159
- return;
2160
- }
2161
- if (key === undefined || key === null || key === '') return;
2162
- if (this.backend && this.backend.create) {
2163
- this.backend.create(languages, namespace, key, fallbackValue, null, _objectSpread$5$1(_objectSpread$5$1({}, options), {}, {
2164
- isUpdate: isUpdate
2165
- }));
2166
- }
2167
- if (!languages || !languages[0]) return;
2168
- this.store.addResource(languages[0], namespace, key, fallbackValue);
2169
- }
2170
- }]);
2171
- return Connector;
2172
- }(EventEmitter);
2173
- function get() {
2174
- return {
2175
- debug: false,
2176
- initImmediate: true,
2177
- ns: ['translation'],
2178
- defaultNS: ['translation'],
2179
- fallbackLng: ['dev'],
2180
- fallbackNS: false,
2181
- supportedLngs: false,
2182
- nonExplicitSupportedLngs: false,
2183
- load: 'all',
2184
- preload: false,
2185
- simplifyPluralSuffix: true,
2186
- keySeparator: '.',
2187
- nsSeparator: ':',
2188
- pluralSeparator: '_',
2189
- contextSeparator: '_',
2190
- partialBundledLanguages: false,
2191
- saveMissing: false,
2192
- updateMissing: false,
2193
- saveMissingTo: 'fallback',
2194
- saveMissingPlurals: true,
2195
- missingKeyHandler: false,
2196
- missingInterpolationHandler: false,
2197
- postProcess: false,
2198
- postProcessPassResolved: false,
2199
- returnNull: true,
2200
- returnEmptyString: true,
2201
- returnObjects: false,
2202
- joinArrays: false,
2203
- returnedObjectHandler: false,
2204
- parseMissingKeyHandler: false,
2205
- appendNamespaceToMissingKey: false,
2206
- appendNamespaceToCIMode: false,
2207
- overloadTranslationOptionHandler: function handle(args) {
2208
- var ret = {};
2209
- if (_typeof$2(args[1]) === 'object') ret = args[1];
2210
- if (typeof args[1] === 'string') ret.defaultValue = args[1];
2211
- if (typeof args[2] === 'string') ret.tDescription = args[2];
2212
- if (_typeof$2(args[2]) === 'object' || _typeof$2(args[3]) === 'object') {
2213
- var options = args[3] || args[2];
2214
- Object.keys(options).forEach(function (key) {
2215
- ret[key] = options[key];
2216
- });
2217
- }
2218
- return ret;
2219
- },
2220
- interpolation: {
2221
- escapeValue: true,
2222
- format: function format(value, _format, lng, options) {
2223
- return value;
2224
- },
2225
- prefix: '{{',
2226
- suffix: '}}',
2227
- formatSeparator: ',',
2228
- unescapePrefix: '-',
2229
- nestingPrefix: '$t(',
2230
- nestingSuffix: ')',
2231
- nestingOptionsSeparator: ',',
2232
- maxReplaces: 1000,
2233
- skipOnVariables: true
2234
- }
2235
- };
2236
- }
2237
- function transformOptions(options) {
2238
- if (typeof options.ns === 'string') options.ns = [options.ns];
2239
- if (typeof options.fallbackLng === 'string') options.fallbackLng = [options.fallbackLng];
2240
- if (typeof options.fallbackNS === 'string') options.fallbackNS = [options.fallbackNS];
2241
- if (options.supportedLngs && options.supportedLngs.indexOf('cimode') < 0) {
2242
- options.supportedLngs = options.supportedLngs.concat(['cimode']);
2243
- }
2244
- return options;
2245
- }
2246
- function ownKeys$6(object, enumerableOnly) {
2247
- var keys = Object.keys(object);
2248
- if (Object.getOwnPropertySymbols) {
2249
- var symbols = Object.getOwnPropertySymbols(object);
2250
- if (enumerableOnly) {
2251
- symbols = symbols.filter(function (sym) {
2252
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
2253
- });
2254
- }
2255
- keys.push.apply(keys, symbols);
2256
- }
2257
- return keys;
2258
- }
2259
- function _objectSpread$6(target) {
2260
- for (var i = 1; i < arguments.length; i++) {
2261
- var source = arguments[i] != null ? arguments[i] : {};
2262
- if (i % 2) {
2263
- ownKeys$6(Object(source), true).forEach(function (key) {
2264
- _defineProperty$2(target, key, source[key]);
2265
- });
2266
- } else if (Object.getOwnPropertyDescriptors) {
2267
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
2268
- } else {
2269
- ownKeys$6(Object(source)).forEach(function (key) {
2270
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
2271
- });
2272
- }
2273
- }
2274
- return target;
2275
- }
2276
- function _createSuper$3(Derived) {
2277
- var hasNativeReflectConstruct = _isNativeReflectConstruct$3();
2278
- return function _createSuperInternal() {
2279
- var Super = _getPrototypeOf(Derived),
2280
- result;
2281
- if (hasNativeReflectConstruct) {
2282
- var NewTarget = _getPrototypeOf(this).constructor;
2283
- result = Reflect.construct(Super, arguments, NewTarget);
2284
- } else {
2285
- result = Super.apply(this, arguments);
2286
- }
2287
- return _possibleConstructorReturn(this, result);
2288
- };
2289
- }
2290
- function _isNativeReflectConstruct$3() {
2291
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
2292
- if (Reflect.construct.sham) return false;
2293
- if (typeof Proxy === "function") return true;
2294
- try {
2295
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
2296
- return true;
2297
- } catch (e) {
2298
- return false;
2299
- }
2300
- }
2301
- function noop() {}
2302
- function bindMemberFunctions(inst) {
2303
- var mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
2304
- mems.forEach(function (mem) {
2305
- if (typeof inst[mem] === 'function') {
2306
- inst[mem] = inst[mem].bind(inst);
2307
- }
2308
- });
2309
- }
2310
- var I18n = function (_EventEmitter) {
2311
- _inherits(I18n, _EventEmitter);
2312
- var _super = _createSuper$3(I18n);
2313
- function I18n() {
2314
- var _this;
2315
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2316
- var callback = arguments.length > 1 ? arguments[1] : undefined;
2317
- _classCallCheck$1(this, I18n);
2318
- _this = _super.call(this);
2319
- if (isIE10) {
2320
- EventEmitter.call(_assertThisInitialized(_this));
2321
- }
2322
- _this.options = transformOptions(options);
2323
- _this.services = {};
2324
- _this.logger = baseLogger;
2325
- _this.modules = {
2326
- external: []
2327
- };
2328
- bindMemberFunctions(_assertThisInitialized(_this));
2329
- if (callback && !_this.isInitialized && !options.isClone) {
2330
- if (!_this.options.initImmediate) {
2331
- _this.init(options, callback);
2332
- return _possibleConstructorReturn(_this, _assertThisInitialized(_this));
2333
- }
2334
- setTimeout(function () {
2335
- _this.init(options, callback);
2336
- }, 0);
2337
- }
2338
- return _this;
2339
- }
2340
- _createClass$1(I18n, [{
2341
- key: "init",
2342
- value: function init() {
2343
- var _this2 = this;
2344
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2345
- var callback = arguments.length > 1 ? arguments[1] : undefined;
2346
- if (typeof options === 'function') {
2347
- callback = options;
2348
- options = {};
2349
- }
2350
- if (!options.defaultNS && options.ns) {
2351
- if (typeof options.ns === 'string') {
2352
- options.defaultNS = options.ns;
2353
- } else if (options.ns.indexOf('translation') < 0) {
2354
- options.defaultNS = options.ns[0];
2355
- }
2356
- }
2357
- var defOpts = get();
2358
- this.options = _objectSpread$6(_objectSpread$6(_objectSpread$6({}, defOpts), this.options), transformOptions(options));
2359
- if (this.options.compatibilityAPI !== 'v1') {
2360
- this.options.interpolation = _objectSpread$6(_objectSpread$6({}, defOpts.interpolation), this.options.interpolation);
2361
- }
2362
- if (options.keySeparator !== undefined) {
2363
- this.options.userDefinedKeySeparator = options.keySeparator;
2364
- }
2365
- if (options.nsSeparator !== undefined) {
2366
- this.options.userDefinedNsSeparator = options.nsSeparator;
2367
- }
2368
- function createClassOnDemand(ClassOrObject) {
2369
- if (!ClassOrObject) return null;
2370
- if (typeof ClassOrObject === 'function') return new ClassOrObject();
2371
- return ClassOrObject;
2372
- }
2373
- if (!this.options.isClone) {
2374
- if (this.modules.logger) {
2375
- baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
2376
- } else {
2377
- baseLogger.init(null, this.options);
2378
- }
2379
- var formatter;
2380
- if (this.modules.formatter) {
2381
- formatter = this.modules.formatter;
2382
- } else if (typeof Intl !== 'undefined') {
2383
- formatter = Formatter;
2384
- }
2385
- var lu = new LanguageUtil(this.options);
2386
- this.store = new ResourceStore(this.options.resources, this.options);
2387
- var s = this.services;
2388
- s.logger = baseLogger;
2389
- s.resourceStore = this.store;
2390
- s.languageUtils = lu;
2391
- s.pluralResolver = new PluralResolver(lu, {
2392
- prepend: this.options.pluralSeparator,
2393
- compatibilityJSON: this.options.compatibilityJSON,
2394
- simplifyPluralSuffix: this.options.simplifyPluralSuffix
2395
- });
2396
- if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
2397
- s.formatter = createClassOnDemand(formatter);
2398
- s.formatter.init(s, this.options);
2399
- this.options.interpolation.format = s.formatter.format.bind(s.formatter);
2400
- }
2401
- s.interpolator = new Interpolator(this.options);
2402
- s.utils = {
2403
- hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
2404
- };
2405
- s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
2406
- s.backendConnector.on('*', function (event) {
2407
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
2408
- args[_key - 1] = arguments[_key];
2409
- }
2410
- _this2.emit.apply(_this2, [event].concat(args));
2411
- });
2412
- if (this.modules.languageDetector) {
2413
- s.languageDetector = createClassOnDemand(this.modules.languageDetector);
2414
- s.languageDetector.init(s, this.options.detection, this.options);
2415
- }
2416
- if (this.modules.i18nFormat) {
2417
- s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
2418
- if (s.i18nFormat.init) s.i18nFormat.init(this);
2419
- }
2420
- this.translator = new Translator(this.services, this.options);
2421
- this.translator.on('*', function (event) {
2422
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
2423
- args[_key2 - 1] = arguments[_key2];
2424
- }
2425
- _this2.emit.apply(_this2, [event].concat(args));
2426
- });
2427
- this.modules.external.forEach(function (m) {
2428
- if (m.init) m.init(_this2);
2429
- });
2430
- }
2431
- this.format = this.options.interpolation.format;
2432
- if (!callback) callback = noop;
2433
- if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
2434
- var codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
2435
- if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
2436
- }
2437
- if (!this.services.languageDetector && !this.options.lng) {
2438
- this.logger.warn('init: no languageDetector is used and no lng is defined');
2439
- }
2440
- var storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
2441
- storeApi.forEach(function (fcName) {
2442
- _this2[fcName] = function () {
2443
- var _this2$store;
2444
- return (_this2$store = _this2.store)[fcName].apply(_this2$store, arguments);
2445
- };
2446
- });
2447
- var storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
2448
- storeApiChained.forEach(function (fcName) {
2449
- _this2[fcName] = function () {
2450
- var _this2$store2;
2451
- (_this2$store2 = _this2.store)[fcName].apply(_this2$store2, arguments);
2452
- return _this2;
2453
- };
2454
- });
2455
- var deferred = defer();
2456
- var load = function load() {
2457
- var finish = function finish(err, t) {
2458
- if (_this2.isInitialized && !_this2.initializedStoreOnce) _this2.logger.warn('init: i18next is already initialized. You should call init just once!');
2459
- _this2.isInitialized = true;
2460
- if (!_this2.options.isClone) _this2.logger.log('initialized', _this2.options);
2461
- _this2.emit('initialized', _this2.options);
2462
- deferred.resolve(t);
2463
- callback(err, t);
2464
- };
2465
- if (_this2.languages && _this2.options.compatibilityAPI !== 'v1' && !_this2.isInitialized) return finish(null, _this2.t.bind(_this2));
2466
- _this2.changeLanguage(_this2.options.lng, finish);
2467
- };
2468
- if (this.options.resources || !this.options.initImmediate) {
2469
- load();
2470
- } else {
2471
- setTimeout(load, 0);
2472
- }
2473
- return deferred;
2474
- }
2475
- }, {
2476
- key: "loadResources",
2477
- value: function loadResources(language) {
2478
- var _this3 = this;
2479
- var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
2480
- var usedCallback = callback;
2481
- var usedLng = typeof language === 'string' ? language : this.language;
2482
- if (typeof language === 'function') usedCallback = language;
2483
- if (!this.options.resources || this.options.partialBundledLanguages) {
2484
- if (usedLng && usedLng.toLowerCase() === 'cimode') return usedCallback();
2485
- var toLoad = [];
2486
- var append = function append(lng) {
2487
- if (!lng) return;
2488
- var lngs = _this3.services.languageUtils.toResolveHierarchy(lng);
2489
- lngs.forEach(function (l) {
2490
- if (toLoad.indexOf(l) < 0) toLoad.push(l);
2491
- });
2492
- };
2493
- if (!usedLng) {
2494
- var fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
2495
- fallbacks.forEach(function (l) {
2496
- return append(l);
2497
- });
2498
- } else {
2499
- append(usedLng);
2500
- }
2501
- if (this.options.preload) {
2502
- this.options.preload.forEach(function (l) {
2503
- return append(l);
2504
- });
2505
- }
2506
- this.services.backendConnector.load(toLoad, this.options.ns, function (e) {
2507
- if (!e && !_this3.resolvedLanguage && _this3.language) _this3.setResolvedLanguage(_this3.language);
2508
- usedCallback(e);
2509
- });
2510
- } else {
2511
- usedCallback(null);
2512
- }
2513
- }
2514
- }, {
2515
- key: "reloadResources",
2516
- value: function reloadResources(lngs, ns, callback) {
2517
- var deferred = defer();
2518
- if (!lngs) lngs = this.languages;
2519
- if (!ns) ns = this.options.ns;
2520
- if (!callback) callback = noop;
2521
- this.services.backendConnector.reload(lngs, ns, function (err) {
2522
- deferred.resolve();
2523
- callback(err);
2524
- });
2525
- return deferred;
2526
- }
2527
- }, {
2528
- key: "use",
2529
- value: function use(module) {
2530
- if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');
2531
- if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');
2532
- if (module.type === 'backend') {
2533
- this.modules.backend = module;
2534
- }
2535
- if (module.type === 'logger' || module.log && module.warn && module.error) {
2536
- this.modules.logger = module;
2537
- }
2538
- if (module.type === 'languageDetector') {
2539
- this.modules.languageDetector = module;
2540
- }
2541
- if (module.type === 'i18nFormat') {
2542
- this.modules.i18nFormat = module;
2543
- }
2544
- if (module.type === 'postProcessor') {
2545
- postProcessor.addPostProcessor(module);
2546
- }
2547
- if (module.type === 'formatter') {
2548
- this.modules.formatter = module;
2549
- }
2550
- if (module.type === '3rdParty') {
2551
- this.modules.external.push(module);
2552
- }
2553
- return this;
2554
- }
2555
- }, {
2556
- key: "setResolvedLanguage",
2557
- value: function setResolvedLanguage(l) {
2558
- if (!l || !this.languages) return;
2559
- if (['cimode', 'dev'].indexOf(l) > -1) return;
2560
- for (var li = 0; li < this.languages.length; li++) {
2561
- var lngInLngs = this.languages[li];
2562
- if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;
2563
- if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
2564
- this.resolvedLanguage = lngInLngs;
2565
- break;
2566
- }
2567
- }
2568
- }
2569
- }, {
2570
- key: "changeLanguage",
2571
- value: function changeLanguage(lng, callback) {
2572
- var _this4 = this;
2573
- this.isLanguageChangingTo = lng;
2574
- var deferred = defer();
2575
- this.emit('languageChanging', lng);
2576
- var setLngProps = function setLngProps(l) {
2577
- _this4.language = l;
2578
- _this4.languages = _this4.services.languageUtils.toResolveHierarchy(l);
2579
- _this4.resolvedLanguage = undefined;
2580
- _this4.setResolvedLanguage(l);
2581
- };
2582
- var done = function done(err, l) {
2583
- if (l) {
2584
- setLngProps(l);
2585
- _this4.translator.changeLanguage(l);
2586
- _this4.isLanguageChangingTo = undefined;
2587
- _this4.emit('languageChanged', l);
2588
- _this4.logger.log('languageChanged', l);
2589
- } else {
2590
- _this4.isLanguageChangingTo = undefined;
2591
- }
2592
- deferred.resolve(function () {
2593
- return _this4.t.apply(_this4, arguments);
2594
- });
2595
- if (callback) callback(err, function () {
2596
- return _this4.t.apply(_this4, arguments);
2597
- });
2598
- };
2599
- var setLng = function setLng(lngs) {
2600
- if (!lng && !lngs && _this4.services.languageDetector) lngs = [];
2601
- var l = typeof lngs === 'string' ? lngs : _this4.services.languageUtils.getBestMatchFromCodes(lngs);
2602
- if (l) {
2603
- if (!_this4.language) {
2604
- setLngProps(l);
2605
- }
2606
- if (!_this4.translator.language) _this4.translator.changeLanguage(l);
2607
- if (_this4.services.languageDetector) _this4.services.languageDetector.cacheUserLanguage(l);
2608
- }
2609
- _this4.loadResources(l, function (err) {
2610
- done(err, l);
2611
- });
2612
- };
2613
- if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
2614
- setLng(this.services.languageDetector.detect());
2615
- } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
2616
- this.services.languageDetector.detect(setLng);
2617
- } else {
2618
- setLng(lng);
2619
- }
2620
- return deferred;
2621
- }
2622
- }, {
2623
- key: "getFixedT",
2624
- value: function getFixedT(lng, ns, keyPrefix) {
2625
- var _this5 = this;
2626
- var fixedT = function fixedT(key, opts) {
2627
- var options;
2628
- if (_typeof$2(opts) !== 'object') {
2629
- for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
2630
- rest[_key3 - 2] = arguments[_key3];
2631
- }
2632
- options = _this5.options.overloadTranslationOptionHandler([key, opts].concat(rest));
2633
- } else {
2634
- options = _objectSpread$6({}, opts);
2635
- }
2636
- options.lng = options.lng || fixedT.lng;
2637
- options.lngs = options.lngs || fixedT.lngs;
2638
- options.ns = options.ns || fixedT.ns;
2639
- var keySeparator = _this5.options.keySeparator || '.';
2640
- var resultKey = keyPrefix ? "".concat(keyPrefix).concat(keySeparator).concat(key) : key;
2641
- return _this5.t(resultKey, options);
2642
- };
2643
- if (typeof lng === 'string') {
2644
- fixedT.lng = lng;
2645
- } else {
2646
- fixedT.lngs = lng;
2647
- }
2648
- fixedT.ns = ns;
2649
- fixedT.keyPrefix = keyPrefix;
2650
- return fixedT;
2651
- }
2652
- }, {
2653
- key: "t",
2654
- value: function t() {
2655
- var _this$translator;
2656
- return this.translator && (_this$translator = this.translator).translate.apply(_this$translator, arguments);
2657
- }
2658
- }, {
2659
- key: "exists",
2660
- value: function exists() {
2661
- var _this$translator2;
2662
- return this.translator && (_this$translator2 = this.translator).exists.apply(_this$translator2, arguments);
2663
- }
2664
- }, {
2665
- key: "setDefaultNamespace",
2666
- value: function setDefaultNamespace(ns) {
2667
- this.options.defaultNS = ns;
2668
- }
2669
- }, {
2670
- key: "hasLoadedNamespace",
2671
- value: function hasLoadedNamespace(ns) {
2672
- var _this6 = this;
2673
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2674
- if (!this.isInitialized) {
2675
- this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
2676
- return false;
2677
- }
2678
- if (!this.languages || !this.languages.length) {
2679
- this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);
2680
- return false;
2681
- }
2682
- var lng = this.resolvedLanguage || this.languages[0];
2683
- var fallbackLng = this.options ? this.options.fallbackLng : false;
2684
- var lastLng = this.languages[this.languages.length - 1];
2685
- if (lng.toLowerCase() === 'cimode') return true;
2686
- var loadNotPending = function loadNotPending(l, n) {
2687
- var loadState = _this6.services.backendConnector.state["".concat(l, "|").concat(n)];
2688
- return loadState === -1 || loadState === 2;
2689
- };
2690
- if (options.precheck) {
2691
- var preResult = options.precheck(this, loadNotPending);
2692
- if (preResult !== undefined) return preResult;
2693
- }
2694
- if (this.hasResourceBundle(lng, ns)) return true;
2695
- if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
2696
- if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
2697
- return false;
2698
- }
2699
- }, {
2700
- key: "loadNamespaces",
2701
- value: function loadNamespaces(ns, callback) {
2702
- var _this7 = this;
2703
- var deferred = defer();
2704
- if (!this.options.ns) {
2705
- callback && callback();
2706
- return Promise.resolve();
2707
- }
2708
- if (typeof ns === 'string') ns = [ns];
2709
- ns.forEach(function (n) {
2710
- if (_this7.options.ns.indexOf(n) < 0) _this7.options.ns.push(n);
2711
- });
2712
- this.loadResources(function (err) {
2713
- deferred.resolve();
2714
- if (callback) callback(err);
2715
- });
2716
- return deferred;
2717
- }
2718
- }, {
2719
- key: "loadLanguages",
2720
- value: function loadLanguages(lngs, callback) {
2721
- var deferred = defer();
2722
- if (typeof lngs === 'string') lngs = [lngs];
2723
- var preloaded = this.options.preload || [];
2724
- var newLngs = lngs.filter(function (lng) {
2725
- return preloaded.indexOf(lng) < 0;
2726
- });
2727
- if (!newLngs.length) {
2728
- if (callback) callback();
2729
- return Promise.resolve();
2730
- }
2731
- this.options.preload = preloaded.concat(newLngs);
2732
- this.loadResources(function (err) {
2733
- deferred.resolve();
2734
- if (callback) callback(err);
2735
- });
2736
- return deferred;
2737
- }
2738
- }, {
2739
- key: "dir",
2740
- value: function dir(lng) {
2741
- if (!lng) lng = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language);
2742
- if (!lng) return 'rtl';
2743
- 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'];
2744
- return rtlLngs.indexOf(this.services.languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
2745
- }
2746
- }, {
2747
- key: "cloneInstance",
2748
- value: function cloneInstance() {
2749
- var _this8 = this;
2750
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2751
- var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
2752
- var mergedOptions = _objectSpread$6(_objectSpread$6(_objectSpread$6({}, this.options), options), {
2753
- isClone: true
2754
- });
2755
- var clone = new I18n(mergedOptions);
2756
- var membersToCopy = ['store', 'services', 'language'];
2757
- membersToCopy.forEach(function (m) {
2758
- clone[m] = _this8[m];
2759
- });
2760
- clone.services = _objectSpread$6({}, this.services);
2761
- clone.services.utils = {
2762
- hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2763
- };
2764
- clone.translator = new Translator(clone.services, clone.options);
2765
- clone.translator.on('*', function (event) {
2766
- for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
2767
- args[_key4 - 1] = arguments[_key4];
2768
- }
2769
- clone.emit.apply(clone, [event].concat(args));
2770
- });
2771
- clone.init(mergedOptions, callback);
2772
- clone.translator.options = clone.options;
2773
- clone.translator.backendConnector.services.utils = {
2774
- hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2775
- };
2776
- return clone;
2777
- }
2778
- }, {
2779
- key: "toJSON",
2780
- value: function toJSON() {
2781
- return {
2782
- options: this.options,
2783
- store: this.store,
2784
- language: this.language,
2785
- languages: this.languages,
2786
- resolvedLanguage: this.resolvedLanguage
2787
- };
2788
- }
2789
- }]);
2790
- return I18n;
2791
- }(EventEmitter);
2792
- _defineProperty$2(I18n, "createInstance", function () {
2793
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2794
- var callback = arguments.length > 1 ? arguments[1] : undefined;
2795
- return new I18n(options, callback);
2796
- });
2797
- var instance = I18n.createInstance();
2798
- instance.createInstance = I18n.createInstance;
2799
- instance.createInstance;
2800
- instance.init;
2801
- instance.loadResources;
2802
- instance.reloadResources;
2803
- instance.use;
2804
- instance.changeLanguage;
2805
- instance.getFixedT;
2806
- instance.t;
2807
- instance.exists;
2808
- instance.setDefaultNamespace;
2809
- instance.hasLoadedNamespace;
2810
- instance.loadNamespaces;
2811
- instance.loadLanguages;
2812
-
2813
- function _objectWithoutPropertiesLoose$1(source, excluded) {
2814
- if (source == null) return {};
2815
- var target = {};
2816
- var sourceKeys = Object.keys(source);
2817
- var key, i;
2818
- for (i = 0; i < sourceKeys.length; i++) {
2819
- key = sourceKeys[i];
2820
- if (excluded.indexOf(key) >= 0) continue;
2821
- target[key] = source[key];
2822
- }
2823
- return target;
2824
- }
2825
-
2826
- function _objectWithoutProperties$1(source, excluded) {
2827
- if (source == null) return {};
2828
- var target = _objectWithoutPropertiesLoose$1(source, excluded);
2829
- var key, i;
2830
- if (Object.getOwnPropertySymbols) {
2831
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
2832
- for (i = 0; i < sourceSymbolKeys.length; i++) {
2833
- key = sourceSymbolKeys[i];
2834
- if (excluded.indexOf(key) >= 0) continue;
2835
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
2836
- target[key] = source[key];
2837
- }
2838
- }
2839
- return target;
2840
- }
2841
-
2842
- function _typeof$1(obj) {
2843
- "@babel/helpers - typeof";
2844
-
2845
- return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
2846
- return typeof obj;
2847
- } : function (obj) {
2848
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
2849
- }, _typeof$1(obj);
2850
- }
2851
-
2852
- function _toPrimitive$1(input, hint) {
2853
- if (_typeof$1(input) !== "object" || input === null) return input;
2854
- var prim = input[Symbol.toPrimitive];
2855
- if (prim !== undefined) {
2856
- var res = prim.call(input, hint || "default");
2857
- if (_typeof$1(res) !== "object") return res;
2858
- throw new TypeError("@@toPrimitive must return a primitive value.");
2859
- }
2860
- return (hint === "string" ? String : Number)(input);
2861
- }
2862
-
2863
- function _toPropertyKey$1(arg) {
2864
- var key = _toPrimitive$1(arg, "string");
2865
- return _typeof$1(key) === "symbol" ? key : String(key);
2866
- }
2867
-
2868
- function _defineProperty$1(obj, key, value) {
2869
- key = _toPropertyKey$1(key);
2870
- if (key in obj) {
2871
- Object.defineProperty(obj, key, {
2872
- value: value,
2873
- enumerable: true,
2874
- configurable: true,
2875
- writable: true
2876
- });
2877
- } else {
2878
- obj[key] = value;
2879
- }
2880
- return obj;
2881
- }
2882
-
2883
- /**
2884
- * This file automatically generated from `pre-publish.js`.
2885
- * Do not manually edit.
2886
- */
2887
- var voidElements = {
2888
- "area": true,
2889
- "base": true,
2890
- "br": true,
2891
- "col": true,
2892
- "embed": true,
2893
- "hr": true,
2894
- "img": true,
2895
- "input": true,
2896
- "link": true,
2897
- "meta": true,
2898
- "param": true,
2899
- "source": true,
2900
- "track": true,
2901
- "wbr": true
2902
- };
2903
-
2904
- var t$1 = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;
2905
- function n$1(n) {
2906
- var r = {
2907
- type: "tag",
2908
- name: "",
2909
- voidElement: !1,
2910
- attrs: {},
2911
- children: []
2912
- },
2913
- i = n.match(/<\/?([^\s]+?)[/\s>]/);
2914
- if (i && (r.name = i[1], (voidElements[i[1]] || "/" === n.charAt(n.length - 2)) && (r.voidElement = !0), r.name.startsWith("!--"))) {
2915
- var s = n.indexOf("--\x3e");
2916
- return {
2917
- type: "comment",
2918
- comment: -1 !== s ? n.slice(4, s) : ""
2919
- };
2920
- }
2921
- for (var a = new RegExp(t$1), c = null; null !== (c = a.exec(n));) if (c[0].trim()) if (c[1]) {
2922
- var o = c[1].trim(),
2923
- l = [o, ""];
2924
- o.indexOf("=") > -1 && (l = o.split("=")), r.attrs[l[0]] = l[1], a.lastIndex--;
2925
- } else c[2] && (r.attrs[c[2]] = c[3].trim().substring(1, c[3].length - 1));
2926
- return r;
2927
- }
2928
- var r = /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,
2929
- i = /^\s*$/,
2930
- s = Object.create(null);
2931
- function a(e, t) {
2932
- switch (t.type) {
2933
- case "text":
2934
- return e + t.content;
2935
- case "tag":
2936
- return e += "<" + t.name + (t.attrs ? function (e) {
2937
- var t = [];
2938
- for (var n in e) t.push(n + '="' + e[n] + '"');
2939
- return t.length ? " " + t.join(" ") : "";
2940
- }(t.attrs) : "") + (t.voidElement ? "/>" : ">"), t.voidElement ? e : e + t.children.reduce(a, "") + "</" + t.name + ">";
2941
- case "comment":
2942
- return e + "\x3c!--" + t.comment + "--\x3e";
2943
- }
2944
- }
2945
- var c = {
2946
- parse: function parse(e, t) {
2947
- t || (t = {}), t.components || (t.components = s);
2948
- var a,
2949
- c = [],
2950
- o = [],
2951
- l = -1,
2952
- m = !1;
2953
- if (0 !== e.indexOf("<")) {
2954
- var u = e.indexOf("<");
2955
- c.push({
2956
- type: "text",
2957
- content: -1 === u ? e : e.substring(0, u)
2958
- });
2959
- }
2960
- return e.replace(r, function (r, s) {
2961
- if (m) {
2962
- if (r !== "</" + a.name + ">") return;
2963
- m = !1;
2964
- }
2965
- var u,
2966
- f = "/" !== r.charAt(1),
2967
- h = r.startsWith("\x3c!--"),
2968
- p = s + r.length,
2969
- d = e.charAt(p);
2970
- if (h) {
2971
- var v = n$1(r);
2972
- return l < 0 ? (c.push(v), c) : ((u = o[l]).children.push(v), c);
2973
- }
2974
- if (f && (l++, "tag" === (a = n$1(r)).type && t.components[a.name] && (a.type = "component", m = !0), a.voidElement || m || !d || "<" === d || a.children.push({
2975
- type: "text",
2976
- content: e.slice(p, e.indexOf("<", p))
2977
- }), 0 === l && c.push(a), (u = o[l - 1]) && u.children.push(a), o[l] = a), (!f || a.voidElement) && (l > -1 && (a.voidElement || a.name === r.slice(2, -1)) && (l--, a = -1 === l ? c : o[l]), !m && "<" !== d && d)) {
2978
- u = -1 === l ? c : o[l].children;
2979
- var x = e.indexOf("<", p),
2980
- g = e.slice(p, -1 === x ? void 0 : x);
2981
- i.test(g) && (g = " "), (x > -1 && l + u.length >= 0 || " " !== g) && u.push({
2982
- type: "text",
2983
- content: g
2984
- });
2985
- }
2986
- }), c;
2987
- },
2988
- stringify: function stringify(e) {
2989
- return e.reduce(function (e, t) {
2990
- return e + a("", t);
2991
- }, "");
2992
- }
2993
- };
2994
-
2995
- /**
2996
- * Copyright (C) 2017-present by Andrea Giammarchi - @WebReflection
2997
- *
2998
- * Permission is hereby granted, free of charge, to any person obtaining a copy
2999
- * of this software and associated documentation files (the "Software"), to deal
3000
- * in the Software without restriction, including without limitation the rights
3001
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3002
- * copies of the Software, and to permit persons to whom the Software is
3003
- * furnished to do so, subject to the following conditions:
3004
- *
3005
- * The above copyright notice and this permission notice shall be included in
3006
- * all copies or substantial portions of the Software.
3007
- *
3008
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3009
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3010
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3011
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3012
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3013
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3014
- * THE SOFTWARE.
3015
- */
3016
-
3017
- var replace = ''.replace;
3018
- var es = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g;
3019
- var unes = {
3020
- '&amp;': '&',
3021
- '&#38;': '&',
3022
- '&lt;': '<',
3023
- '&#60;': '<',
3024
- '&gt;': '>',
3025
- '&#62;': '>',
3026
- '&apos;': "'",
3027
- '&#39;': "'",
3028
- '&quot;': '"',
3029
- '&#34;': '"'
3030
- };
3031
- function unescape(un) {
3032
- return replace.call(un, es, cape);
3033
- }
3034
- function cape(m) {
3035
- return unes[m];
3036
- }
3037
-
3038
- function _classCallCheck(instance, Constructor) {
3039
- if (!(instance instanceof Constructor)) {
3040
- throw new TypeError("Cannot call a class as a function");
3041
- }
3042
- }
3043
-
3044
- function _defineProperties(target, props) {
3045
- for (var i = 0; i < props.length; i++) {
3046
- var descriptor = props[i];
3047
- descriptor.enumerable = descriptor.enumerable || false;
3048
- descriptor.configurable = true;
3049
- if ("value" in descriptor) descriptor.writable = true;
3050
- Object.defineProperty(target, _toPropertyKey$1(descriptor.key), descriptor);
3051
- }
3052
- }
3053
- function _createClass(Constructor, protoProps, staticProps) {
3054
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
3055
- if (staticProps) _defineProperties(Constructor, staticProps);
3056
- Object.defineProperty(Constructor, "prototype", {
3057
- writable: false
3058
- });
3059
- return Constructor;
3060
- }
3061
-
3062
- function ownKeys$4(object, enumerableOnly) {
3063
- var keys = Object.keys(object);
3064
- if (Object.getOwnPropertySymbols) {
3065
- var symbols = Object.getOwnPropertySymbols(object);
3066
- if (enumerableOnly) {
3067
- symbols = symbols.filter(function (sym) {
3068
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
3069
- });
3070
- }
3071
- keys.push.apply(keys, symbols);
3072
- }
3073
- return keys;
3074
- }
3075
- function _objectSpread$4(target) {
3076
- for (var i = 1; i < arguments.length; i++) {
3077
- var source = arguments[i] != null ? arguments[i] : {};
3078
- if (i % 2) {
3079
- ownKeys$4(Object(source), true).forEach(function (key) {
3080
- _defineProperty$1(target, key, source[key]);
3081
- });
3082
- } else if (Object.getOwnPropertyDescriptors) {
3083
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
3084
- } else {
3085
- ownKeys$4(Object(source)).forEach(function (key) {
3086
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3087
- });
3088
- }
3089
- }
3090
- return target;
3091
- }
3092
- var defaultOptions = {
3093
- bindI18n: 'languageChanged',
3094
- bindI18nStore: '',
3095
- transEmptyNodeValue: '',
3096
- transSupportBasicHtmlNodes: true,
3097
- transWrapTextNodes: '',
3098
- transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
3099
- useSuspense: true
3100
- };
3101
- var i18nInstance;
3102
- var I18nContext = /*#__PURE__*/React__default["default"].createContext();
3103
- function setDefaults() {
3104
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3105
- defaultOptions = _objectSpread$4(_objectSpread$4({}, defaultOptions), options);
3106
- }
3107
- function getDefaults() {
3108
- return defaultOptions;
3109
- }
3110
- var ReportNamespaces = function () {
3111
- function ReportNamespaces() {
3112
- _classCallCheck(this, ReportNamespaces);
3113
- this.usedNamespaces = {};
3114
- }
3115
- _createClass(ReportNamespaces, [{
3116
- key: "addUsedNamespaces",
3117
- value: function addUsedNamespaces(namespaces) {
3118
- var _this = this;
3119
- namespaces.forEach(function (ns) {
3120
- if (!_this.usedNamespaces[ns]) _this.usedNamespaces[ns] = true;
3121
- });
3122
- }
3123
- }, {
3124
- key: "getUsedNamespaces",
3125
- value: function getUsedNamespaces() {
3126
- return Object.keys(this.usedNamespaces);
3127
- }
3128
- }]);
3129
- return ReportNamespaces;
3130
- }();
3131
- function setI18n(instance) {
3132
- i18nInstance = instance;
3133
- }
3134
- function getI18n() {
3135
- return i18nInstance;
3136
- }
3137
- var initReactI18next = {
3138
- type: '3rdParty',
3139
- init: function init(instance) {
3140
- setDefaults(instance.options.react);
3141
- setI18n(instance);
3142
- }
3143
- };
3144
-
3145
- function warn() {
3146
- if (console && console.warn) {
3147
- var _console;
3148
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3149
- args[_key] = arguments[_key];
3150
- }
3151
- if (typeof args[0] === 'string') args[0] = "react-i18next:: ".concat(args[0]);
3152
- (_console = console).warn.apply(_console, args);
3153
- }
3154
- }
3155
- var alreadyWarned = {};
3156
- function warnOnce() {
3157
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3158
- args[_key2] = arguments[_key2];
3159
- }
3160
- if (typeof args[0] === 'string' && alreadyWarned[args[0]]) return;
3161
- if (typeof args[0] === 'string') alreadyWarned[args[0]] = new Date();
3162
- warn.apply(void 0, args);
3163
- }
3164
- function loadNamespaces(i18n, ns, cb) {
3165
- i18n.loadNamespaces(ns, function () {
3166
- if (i18n.isInitialized) {
3167
- cb();
3168
- } else {
3169
- var initialized = function initialized() {
3170
- setTimeout(function () {
3171
- i18n.off('initialized', initialized);
3172
- }, 0);
3173
- cb();
3174
- };
3175
- i18n.on('initialized', initialized);
3176
- }
3177
- });
3178
- }
3179
- function oldI18nextHasLoadedNamespace(ns, i18n) {
3180
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3181
- var lng = i18n.languages[0];
3182
- var fallbackLng = i18n.options ? i18n.options.fallbackLng : false;
3183
- var lastLng = i18n.languages[i18n.languages.length - 1];
3184
- if (lng.toLowerCase() === 'cimode') return true;
3185
- var loadNotPending = function loadNotPending(l, n) {
3186
- var loadState = i18n.services.backendConnector.state["".concat(l, "|").concat(n)];
3187
- return loadState === -1 || loadState === 2;
3188
- };
3189
- if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18n.services.backendConnector.backend && i18n.isLanguageChangingTo && !loadNotPending(i18n.isLanguageChangingTo, ns)) return false;
3190
- if (i18n.hasResourceBundle(lng, ns)) return true;
3191
- if (!i18n.services.backendConnector.backend || i18n.options.resources && !i18n.options.partialBundledLanguages) return true;
3192
- if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
3193
- return false;
3194
- }
3195
- function hasLoadedNamespace(ns, i18n) {
3196
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3197
- if (!i18n.languages || !i18n.languages.length) {
3198
- warnOnce('i18n.languages were undefined or empty', i18n.languages);
3199
- return true;
3200
- }
3201
- var isNewerI18next = i18n.options.ignoreJSONStructure !== undefined;
3202
- if (!isNewerI18next) {
3203
- return oldI18nextHasLoadedNamespace(ns, i18n, options);
3204
- }
3205
- return i18n.hasLoadedNamespace(ns, {
3206
- precheck: function precheck(i18nInstance, loadNotPending) {
3207
- if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18nInstance.services.backendConnector.backend && i18nInstance.isLanguageChangingTo && !loadNotPending(i18nInstance.isLanguageChangingTo, ns)) return false;
3208
- }
3209
- });
3210
- }
3211
-
3212
- var _excluded$2 = ["format"],
3213
- _excluded2 = ["children", "count", "parent", "i18nKey", "context", "tOptions", "values", "defaults", "components", "ns", "i18n", "t", "shouldUnescape"];
3214
- function ownKeys$3(object, enumerableOnly) {
3215
- var keys = Object.keys(object);
3216
- if (Object.getOwnPropertySymbols) {
3217
- var symbols = Object.getOwnPropertySymbols(object);
3218
- if (enumerableOnly) {
3219
- symbols = symbols.filter(function (sym) {
3220
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
3221
- });
3222
- }
3223
- keys.push.apply(keys, symbols);
3224
- }
3225
- return keys;
3226
- }
3227
- function _objectSpread$3(target) {
3228
- for (var i = 1; i < arguments.length; i++) {
3229
- var source = arguments[i] != null ? arguments[i] : {};
3230
- if (i % 2) {
3231
- ownKeys$3(Object(source), true).forEach(function (key) {
3232
- _defineProperty$1(target, key, source[key]);
3233
- });
3234
- } else if (Object.getOwnPropertyDescriptors) {
3235
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
3236
- } else {
3237
- ownKeys$3(Object(source)).forEach(function (key) {
3238
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3239
- });
3240
- }
3241
- }
3242
- return target;
3243
- }
3244
- function hasChildren(node, checkLength) {
3245
- if (!node) return false;
3246
- var base = node.props ? node.props.children : node.children;
3247
- if (checkLength) return base.length > 0;
3248
- return !!base;
3249
- }
3250
- function getChildren(node) {
3251
- if (!node) return [];
3252
- return node && node.children ? node.children : node.props && node.props.children;
3253
- }
3254
- function hasValidReactChildren(children) {
3255
- if (Object.prototype.toString.call(children) !== '[object Array]') return false;
3256
- return children.every(function (child) {
3257
- return /*#__PURE__*/React__default["default"].isValidElement(child);
3258
- });
3259
- }
3260
- function getAsArray(data) {
3261
- return Array.isArray(data) ? data : [data];
3262
- }
3263
- function mergeProps(source, target) {
3264
- var newTarget = _objectSpread$3({}, target);
3265
- newTarget.props = Object.assign(source.props, target.props);
3266
- return newTarget;
3267
- }
3268
- function nodesToString(children, i18nOptions) {
3269
- if (!children) return '';
3270
- var stringNode = '';
3271
- var childrenArray = getAsArray(children);
3272
- var keepArray = i18nOptions.transSupportBasicHtmlNodes && i18nOptions.transKeepBasicHtmlNodesFor ? i18nOptions.transKeepBasicHtmlNodesFor : [];
3273
- childrenArray.forEach(function (child, childIndex) {
3274
- if (typeof child === 'string') {
3275
- stringNode += "".concat(child);
3276
- } else if ( /*#__PURE__*/React__default["default"].isValidElement(child)) {
3277
- var childPropsCount = Object.keys(child.props).length;
3278
- var shouldKeepChild = keepArray.indexOf(child.type) > -1;
3279
- var childChildren = child.props.children;
3280
- if (!childChildren && shouldKeepChild && childPropsCount === 0) {
3281
- stringNode += "<".concat(child.type, "/>");
3282
- } else if (!childChildren && (!shouldKeepChild || childPropsCount !== 0)) {
3283
- stringNode += "<".concat(childIndex, "></").concat(childIndex, ">");
3284
- } else if (child.props.i18nIsDynamicList) {
3285
- stringNode += "<".concat(childIndex, "></").concat(childIndex, ">");
3286
- } else if (shouldKeepChild && childPropsCount === 1 && typeof childChildren === 'string') {
3287
- stringNode += "<".concat(child.type, ">").concat(childChildren, "</").concat(child.type, ">");
3288
- } else {
3289
- var content = nodesToString(childChildren, i18nOptions);
3290
- stringNode += "<".concat(childIndex, ">").concat(content, "</").concat(childIndex, ">");
3291
- }
3292
- } else if (child === null) {
3293
- warn("Trans: the passed in value is invalid - seems you passed in a null child.");
3294
- } else if (_typeof$1(child) === 'object') {
3295
- var format = child.format,
3296
- clone = _objectWithoutProperties$1(child, _excluded$2);
3297
- var keys = Object.keys(clone);
3298
- if (keys.length === 1) {
3299
- var value = format ? "".concat(keys[0], ", ").concat(format) : keys[0];
3300
- stringNode += "{{".concat(value, "}}");
3301
- } else {
3302
- warn("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.", child);
3303
- }
3304
- } else {
3305
- warn("Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.", child);
3306
- }
3307
- });
3308
- return stringNode;
3309
- }
3310
- function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts, shouldUnescape) {
3311
- if (targetString === '') return [];
3312
- var keepArray = i18nOptions.transKeepBasicHtmlNodesFor || [];
3313
- var emptyChildrenButNeedsHandling = targetString && new RegExp(keepArray.join('|')).test(targetString);
3314
- if (!children && !emptyChildrenButNeedsHandling) return [targetString];
3315
- var data = {};
3316
- function getData(childs) {
3317
- var childrenArray = getAsArray(childs);
3318
- childrenArray.forEach(function (child) {
3319
- if (typeof child === 'string') return;
3320
- if (hasChildren(child)) getData(getChildren(child));else if (_typeof$1(child) === 'object' && ! /*#__PURE__*/React__default["default"].isValidElement(child)) Object.assign(data, child);
3321
- });
3322
- }
3323
- getData(children);
3324
- var ast = c.parse("<0>".concat(targetString, "</0>"));
3325
- var opts = _objectSpread$3(_objectSpread$3({}, data), combinedTOpts);
3326
- function renderInner(child, node, rootReactNode) {
3327
- var childs = getChildren(child);
3328
- var mappedChildren = mapAST(childs, node.children, rootReactNode);
3329
- return hasValidReactChildren(childs) && mappedChildren.length === 0 ? childs : mappedChildren;
3330
- }
3331
- function pushTranslatedJSX(child, inner, mem, i, isVoid) {
3332
- if (child.dummy) child.children = inner;
3333
- mem.push( /*#__PURE__*/React__default["default"].cloneElement(child, _objectSpread$3(_objectSpread$3({}, child.props), {}, {
3334
- key: i
3335
- }), isVoid ? undefined : inner));
3336
- }
3337
- function mapAST(reactNode, astNode, rootReactNode) {
3338
- var reactNodes = getAsArray(reactNode);
3339
- var astNodes = getAsArray(astNode);
3340
- return astNodes.reduce(function (mem, node, i) {
3341
- var translationContent = node.children && node.children[0] && node.children[0].content && i18n.services.interpolator.interpolate(node.children[0].content, opts, i18n.language);
3342
- if (node.type === 'tag') {
3343
- var tmp = reactNodes[parseInt(node.name, 10)];
3344
- if (!tmp && rootReactNode.length === 1 && rootReactNode[0][node.name]) tmp = rootReactNode[0][node.name];
3345
- if (!tmp) tmp = {};
3346
- var child = Object.keys(node.attrs).length !== 0 ? mergeProps({
3347
- props: node.attrs
3348
- }, tmp) : tmp;
3349
- var isElement = /*#__PURE__*/React__default["default"].isValidElement(child);
3350
- var isValidTranslationWithChildren = isElement && hasChildren(node, true) && !node.voidElement;
3351
- var isEmptyTransWithHTML = emptyChildrenButNeedsHandling && _typeof$1(child) === 'object' && child.dummy && !isElement;
3352
- var isKnownComponent = _typeof$1(children) === 'object' && children !== null && Object.hasOwnProperty.call(children, node.name);
3353
- if (typeof child === 'string') {
3354
- var value = i18n.services.interpolator.interpolate(child, opts, i18n.language);
3355
- mem.push(value);
3356
- } else if (hasChildren(child) || isValidTranslationWithChildren) {
3357
- var inner = renderInner(child, node, rootReactNode);
3358
- pushTranslatedJSX(child, inner, mem, i);
3359
- } else if (isEmptyTransWithHTML) {
3360
- var _inner = mapAST(reactNodes, node.children, rootReactNode);
3361
- mem.push( /*#__PURE__*/React__default["default"].cloneElement(child, _objectSpread$3(_objectSpread$3({}, child.props), {}, {
3362
- key: i
3363
- }), _inner));
3364
- } else if (Number.isNaN(parseFloat(node.name))) {
3365
- if (isKnownComponent) {
3366
- var _inner2 = renderInner(child, node, rootReactNode);
3367
- pushTranslatedJSX(child, _inner2, mem, i, node.voidElement);
3368
- } else if (i18nOptions.transSupportBasicHtmlNodes && keepArray.indexOf(node.name) > -1) {
3369
- if (node.voidElement) {
3370
- mem.push( /*#__PURE__*/React__default["default"].createElement(node.name, {
3371
- key: "".concat(node.name, "-").concat(i)
3372
- }));
3373
- } else {
3374
- var _inner3 = mapAST(reactNodes, node.children, rootReactNode);
3375
- mem.push( /*#__PURE__*/React__default["default"].createElement(node.name, {
3376
- key: "".concat(node.name, "-").concat(i)
3377
- }, _inner3));
3378
- }
3379
- } else if (node.voidElement) {
3380
- mem.push("<".concat(node.name, " />"));
3381
- } else {
3382
- var _inner4 = mapAST(reactNodes, node.children, rootReactNode);
3383
- mem.push("<".concat(node.name, ">").concat(_inner4, "</").concat(node.name, ">"));
3384
- }
3385
- } else if (_typeof$1(child) === 'object' && !isElement) {
3386
- var content = node.children[0] ? translationContent : null;
3387
- if (content) mem.push(content);
3388
- } else if (node.children.length === 1 && translationContent) {
3389
- mem.push( /*#__PURE__*/React__default["default"].cloneElement(child, _objectSpread$3(_objectSpread$3({}, child.props), {}, {
3390
- key: i
3391
- }), translationContent));
3392
- } else {
3393
- mem.push( /*#__PURE__*/React__default["default"].cloneElement(child, _objectSpread$3(_objectSpread$3({}, child.props), {}, {
3394
- key: i
3395
- })));
3396
- }
3397
- } else if (node.type === 'text') {
3398
- var wrapTextNodes = i18nOptions.transWrapTextNodes;
3399
- var _content = shouldUnescape ? unescape(i18n.services.interpolator.interpolate(node.content, opts, i18n.language)) : i18n.services.interpolator.interpolate(node.content, opts, i18n.language);
3400
- if (wrapTextNodes) {
3401
- mem.push( /*#__PURE__*/React__default["default"].createElement(wrapTextNodes, {
3402
- key: "".concat(node.name, "-").concat(i)
3403
- }, _content));
3404
- } else {
3405
- mem.push(_content);
3406
- }
3407
- }
3408
- return mem;
3409
- }, []);
3410
- }
3411
- var result = mapAST([{
3412
- dummy: true,
3413
- children: children || []
3414
- }], ast, getAsArray(children || []));
3415
- return getChildren(result[0]);
3416
- }
3417
- function Trans(_ref) {
3418
- var children = _ref.children,
3419
- count = _ref.count,
3420
- parent = _ref.parent,
3421
- i18nKey = _ref.i18nKey,
3422
- context = _ref.context,
3423
- _ref$tOptions = _ref.tOptions,
3424
- tOptions = _ref$tOptions === void 0 ? {} : _ref$tOptions,
3425
- values = _ref.values,
3426
- defaults = _ref.defaults,
3427
- components = _ref.components,
3428
- ns = _ref.ns,
3429
- i18nFromProps = _ref.i18n,
3430
- tFromProps = _ref.t,
3431
- shouldUnescape = _ref.shouldUnescape,
3432
- additionalProps = _objectWithoutProperties$1(_ref, _excluded2);
3433
- var _ref2 = React.useContext(I18nContext) || {},
3434
- i18nFromContext = _ref2.i18n,
3435
- defaultNSFromContext = _ref2.defaultNS;
3436
- var i18n = i18nFromProps || i18nFromContext || getI18n();
3437
- if (!i18n) {
3438
- warnOnce('You will need to pass in an i18next instance by using i18nextReactModule');
3439
- return children;
3440
- }
3441
- var t = tFromProps || i18n.t.bind(i18n) || function (k) {
3442
- return k;
3443
- };
3444
- if (context) tOptions.context = context;
3445
- var reactI18nextOptions = _objectSpread$3(_objectSpread$3({}, getDefaults()), i18n.options && i18n.options.react);
3446
- var namespaces = ns || t.ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
3447
- namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
3448
- var defaultValue = defaults || nodesToString(children, reactI18nextOptions) || reactI18nextOptions.transEmptyNodeValue || i18nKey;
3449
- var hashTransKey = reactI18nextOptions.hashTransKey;
3450
- var key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue);
3451
- var interpolationOverride = values ? tOptions.interpolation : {
3452
- interpolation: _objectSpread$3(_objectSpread$3({}, tOptions.interpolation), {}, {
3453
- prefix: '#$?',
3454
- suffix: '?$#'
3455
- })
3456
- };
3457
- var combinedTOpts = _objectSpread$3(_objectSpread$3(_objectSpread$3(_objectSpread$3({}, tOptions), {}, {
3458
- count: count
3459
- }, values), interpolationOverride), {}, {
3460
- defaultValue: defaultValue,
3461
- ns: namespaces
3462
- });
3463
- var translation = key ? t(key, combinedTOpts) : defaultValue;
3464
- var content = renderNodes(components || children, translation, i18n, reactI18nextOptions, combinedTOpts, shouldUnescape);
3465
- var useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent;
3466
- return useAsParent ? /*#__PURE__*/React__default["default"].createElement(useAsParent, additionalProps, content) : content;
3467
- }
3468
-
3469
- function _arrayWithHoles$1(arr) {
3470
- if (Array.isArray(arr)) return arr;
3471
- }
3472
-
3473
- function _iterableToArrayLimit$1(arr, i) {
3474
- var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
3475
- if (null != _i) {
3476
- var _s,
3477
- _e,
3478
- _x,
3479
- _r,
3480
- _arr = [],
3481
- _n = !0,
3482
- _d = !1;
3483
- try {
3484
- if (_x = (_i = _i.call(arr)).next, 0 === i) {
3485
- if (Object(_i) !== _i) return;
3486
- _n = !1;
3487
- } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
3488
- } catch (err) {
3489
- _d = !0, _e = err;
3490
- } finally {
3491
- try {
3492
- if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
3493
- } finally {
3494
- if (_d) throw _e;
3495
- }
3496
- }
3497
- return _arr;
3498
- }
3499
- }
3500
-
3501
- function _arrayLikeToArray$1(arr, len) {
3502
- if (len == null || len > arr.length) len = arr.length;
3503
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
3504
- return arr2;
3505
- }
3506
-
3507
- function _unsupportedIterableToArray$1(o, minLen) {
3508
- if (!o) return;
3509
- if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
3510
- var n = Object.prototype.toString.call(o).slice(8, -1);
3511
- if (n === "Object" && o.constructor) n = o.constructor.name;
3512
- if (n === "Map" || n === "Set") return Array.from(o);
3513
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);
3514
- }
3515
-
3516
- function _nonIterableRest$1() {
3517
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3518
- }
3519
-
3520
- function _slicedToArray$1(arr, i) {
3521
- return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest$1();
3522
- }
3523
-
3524
- function ownKeys$2(object, enumerableOnly) {
3525
- var keys = Object.keys(object);
3526
- if (Object.getOwnPropertySymbols) {
3527
- var symbols = Object.getOwnPropertySymbols(object);
3528
- if (enumerableOnly) {
3529
- symbols = symbols.filter(function (sym) {
3530
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
3531
- });
3532
- }
3533
- keys.push.apply(keys, symbols);
3534
- }
3535
- return keys;
3536
- }
3537
- function _objectSpread$2(target) {
3538
- for (var i = 1; i < arguments.length; i++) {
3539
- var source = arguments[i] != null ? arguments[i] : {};
3540
- if (i % 2) {
3541
- ownKeys$2(Object(source), true).forEach(function (key) {
3542
- _defineProperty$1(target, key, source[key]);
3543
- });
3544
- } else if (Object.getOwnPropertyDescriptors) {
3545
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
3546
- } else {
3547
- ownKeys$2(Object(source)).forEach(function (key) {
3548
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3549
- });
3550
- }
3551
- }
3552
- return target;
3553
- }
3554
- function useTranslation(ns) {
3555
- var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3556
- var i18nFromProps = props.i18n;
3557
- var _ref = React.useContext(I18nContext) || {},
3558
- i18nFromContext = _ref.i18n,
3559
- defaultNSFromContext = _ref.defaultNS;
3560
- var i18n = i18nFromProps || i18nFromContext || getI18n();
3561
- if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
3562
- if (!i18n) {
3563
- warnOnce('You will need to pass in an i18next instance by using initReactI18next');
3564
- var notReadyT = function notReadyT(k) {
3565
- return Array.isArray(k) ? k[k.length - 1] : k;
3566
- };
3567
- var retNotReady = [notReadyT, {}, false];
3568
- retNotReady.t = notReadyT;
3569
- retNotReady.i18n = {};
3570
- retNotReady.ready = false;
3571
- return retNotReady;
3572
- }
3573
- if (i18n.options.react && i18n.options.react.wait !== undefined) warnOnce('It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.');
3574
- var i18nOptions = _objectSpread$2(_objectSpread$2(_objectSpread$2({}, getDefaults()), i18n.options.react), props);
3575
- var useSuspense = i18nOptions.useSuspense,
3576
- keyPrefix = i18nOptions.keyPrefix;
3577
- var namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
3578
- namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
3579
- if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces);
3580
- var ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(function (n) {
3581
- return hasLoadedNamespace(n, i18n, i18nOptions);
3582
- });
3583
- function getT() {
3584
- return i18n.getFixedT(null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0], keyPrefix);
3585
- }
3586
- var _useState = React.useState(getT),
3587
- _useState2 = _slicedToArray$1(_useState, 2),
3588
- t = _useState2[0],
3589
- setT = _useState2[1];
3590
- var isMounted = React.useRef(true);
3591
- React.useEffect(function () {
3592
- var bindI18n = i18nOptions.bindI18n,
3593
- bindI18nStore = i18nOptions.bindI18nStore;
3594
- isMounted.current = true;
3595
- if (!ready && !useSuspense) {
3596
- loadNamespaces(i18n, namespaces, function () {
3597
- if (isMounted.current) setT(getT);
3598
- });
3599
- }
3600
- function boundReset() {
3601
- if (isMounted.current) setT(getT);
3602
- }
3603
- if (bindI18n && i18n) i18n.on(bindI18n, boundReset);
3604
- if (bindI18nStore && i18n) i18n.store.on(bindI18nStore, boundReset);
3605
- return function () {
3606
- isMounted.current = false;
3607
- if (bindI18n && i18n) bindI18n.split(' ').forEach(function (e) {
3608
- return i18n.off(e, boundReset);
3609
- });
3610
- if (bindI18nStore && i18n) bindI18nStore.split(' ').forEach(function (e) {
3611
- return i18n.store.off(e, boundReset);
3612
- });
3613
- };
3614
- }, [i18n, namespaces.join()]);
3615
- var isInitial = React.useRef(true);
3616
- React.useEffect(function () {
3617
- if (isMounted.current && !isInitial.current) {
3618
- setT(getT);
3619
- }
3620
- isInitial.current = false;
3621
- }, [i18n]);
3622
- var ret = [t, i18n, ready];
3623
- ret.t = t;
3624
- ret.i18n = i18n;
3625
- ret.ready = ready;
3626
- if (ready) return ret;
3627
- if (!ready && !useSuspense) return ret;
3628
- throw new Promise(function (resolve) {
3629
- loadNamespaces(i18n, namespaces, function () {
3630
- resolve();
3631
- });
3632
- });
3633
- }
3634
-
3635
- var common = {
3636
- "continue": "Continue",
3637
- connect: "Connect",
3638
- connected: "Connected",
3639
- manage: "Manage",
3640
- disconnect: "Disconnect",
3641
- finish: "Finish",
3642
- required: "Required",
3643
- "delete": "Delete",
3644
- tryAgain: "Try Again"
3645
- };
3646
- var tags = {
3647
- connected: "Connected",
3648
- expired: "Expired"
3649
- };
3650
- var tooltip = {
3651
- integrationNotAvailable: "This integration is not available right now."
3652
- };
3653
- var demo = {
3654
- title: "Check how it behaves",
3655
- subtitle: "Watch the following video to understand how you can utilize this integration:",
3656
- iFrameTitle: "Watch this video to utilize the integration"
3657
- };
3658
- var walkthroughModal = {
3659
- header: "Check how it behaves",
3660
- "continue": "Continue"
3661
- };
3662
- var zapier = {
3663
- apiKeys: "API Keys",
3664
- copyApiKey: "Copy API Key to Clipboard",
3665
- emptyText: "Generate an API Key to connect to the Zapier platform",
3666
- generateApiKey: "Generate API Key",
3667
- labelInputPlaceholder: "Enter a Label for the new API Key",
3668
- tableColumns: {
3669
- createdAt: "Created At",
3670
- label: "Label"
3671
- },
3672
- newApiKeyInstruction: "Here is your Zapier API Key. Make sure to copy the API Key now. It will not be made visible again.",
3673
- tableTitle: "Previously Generated API Keys",
3674
- deleteApiKey: {
3675
- title: "Delete API Key?",
3676
- message: "You are permanently deleting the API Key <strong>{{key}}</strong>. This can't be undone."
3677
- },
3678
- walkthroughText: "Check how it behaves"
3679
- };
3680
- var en = {
3681
- common: common,
3682
- tags: tags,
3683
- tooltip: tooltip,
3684
- demo: demo,
3685
- walkthroughModal: walkthroughModal,
3686
- zapier: zapier
3687
- };
3688
-
3689
- instance.use(initReactI18next).init({
3690
- resources: {
3691
- en: {
3692
- translation: en
3693
- }
3694
- },
3695
- lng: "en",
3696
- fallbackLng: "en",
3697
- interpolation: {
3698
- escapeValue: false,
3699
- skipOnVariables: false
3700
- }
3701
- });
3702
37
 
3703
38
  function _extends$1() {
3704
39
  _extends$1 = Object.assign ? Object.assign.bind() : function (target) {
@@ -3719,8 +54,8 @@ var renderDataCy = function renderDataCy(label, suffix) {
3719
54
  return "".concat(label.replace(/\./g, "").toLowerCase(), "-").concat(suffix);
3720
55
  };
3721
56
 
3722
- var Menu$1 = neetoui.Dropdown.Menu,
3723
- MenuItem$1 = neetoui.Dropdown.MenuItem;
57
+ var Menu = neetoui.Dropdown.Menu,
58
+ MenuItem = neetoui.Dropdown.MenuItem;
3724
59
  var Dropdown = function Dropdown(_ref) {
3725
60
  var _ref$customDropDown = _ref.customDropDown,
3726
61
  CustomDropdown = _ref$customDropDown === void 0 ? {} : _ref$customDropDown,
@@ -3730,7 +65,7 @@ var Dropdown = function Dropdown(_ref) {
3730
65
  hideDisconnect = _ref$hideDisconnect === void 0 ? false : _ref$hideDisconnect,
3731
66
  _ref$onDisconnect = _ref.onDisconnect,
3732
67
  onDisconnect = _ref$onDisconnect === void 0 ? pure.noop : _ref$onDisconnect;
3733
- var _useTranslation = useTranslation(),
68
+ var _useTranslation = reactI18next.useTranslation(),
3734
69
  t = _useTranslation.t;
3735
70
  var isManageable = ramda.isNotNil(handleManage);
3736
71
  if (ramda.isNotNil(CustomDropdown)) {
@@ -3752,28 +87,28 @@ var Dropdown = function Dropdown(_ref) {
3752
87
  }
3753
88
  },
3754
89
  icon: neetoIcons.MenuVertical
3755
- }, /*#__PURE__*/React__default["default"].createElement(Menu$1, null, isManageable && /*#__PURE__*/React__default["default"].createElement(MenuItem$1.Button, {
90
+ }, /*#__PURE__*/React__default["default"].createElement(Menu, null, isManageable && /*#__PURE__*/React__default["default"].createElement(MenuItem.Button, {
3756
91
  onClick: function onClick() {
3757
92
  return handleManage();
3758
93
  }
3759
- }, t("common.manage")), !hideDisconnect && /*#__PURE__*/React__default["default"].createElement(MenuItem$1.Button, {
94
+ }, t("neetoIntegrations.common.manage")), !hideDisconnect && /*#__PURE__*/React__default["default"].createElement(MenuItem.Button, {
3760
95
  onClick: function onClick() {
3761
96
  return onDisconnect();
3762
97
  }
3763
- }, t("common.disconnect"))));
98
+ }, t("neetoIntegrations.common.disconnect"))));
3764
99
  };
3765
100
 
3766
101
  var Status = function Status(_ref) {
3767
102
  var isExpired = _ref.isExpired;
3768
- var _useTranslation = useTranslation(),
103
+ var _useTranslation = reactI18next.useTranslation(),
3769
104
  t = _useTranslation.t;
3770
105
  var tagProps = isExpired ? {
3771
106
  icon: neetoIcons.Warning,
3772
- label: t("tags.expired"),
107
+ label: t("neetoIntegrations.tags.expired"),
3773
108
  style: "warning"
3774
109
  } : {
3775
110
  icon: neetoIcons.Check,
3776
- label: t("tags.connected"),
111
+ label: t("neetoIntegrations.tags.connected"),
3777
112
  style: "success"
3778
113
  };
3779
114
  return /*#__PURE__*/React__default["default"].createElement(neetoui.Tag, _extends$1({
@@ -3855,7 +190,7 @@ var Card = function Card(_ref) {
3855
190
  _ref$customDropDown = _ref.customDropDown,
3856
191
  customDropDown = _ref$customDropDown === void 0 ? null : _ref$customDropDown,
3857
192
  children = _ref.children;
3858
- var _useTranslation = useTranslation(),
193
+ var _useTranslation = reactI18next.useTranslation(),
3859
194
  t = _useTranslation.t;
3860
195
  var cardProps = function cardProps() {
3861
196
  return isConnected && ramda.isNotNil(onCardClick) ? {
@@ -3863,9 +198,9 @@ var Card = function Card(_ref) {
3863
198
  } : {};
3864
199
  };
3865
200
  return /*#__PURE__*/React__default["default"].createElement(TooltipWrapper, _extends$1({
3866
- content: disabled && t("tooltip.integrationNotAvailable"),
3867
201
  disabled: disabled,
3868
- position: "top"
202
+ position: "top",
203
+ content: disabled && t("neetoIntegrations.tooltip.integrationNotAvailable")
3869
204
  }, tooltipProps), /*#__PURE__*/React__default["default"].createElement("div", _extends$1({
3870
205
  className: classnames__default["default"]("outline-none neeto-ui-border-gray-300 neeto-ui-shadow-xs hover:neeto-ui-border-gray-500 focus:neeto-ui-border-gray-500 neeto-ui-rounded-lg flex flex-col border p-6 no-underline transition-colors", {
3871
206
  "hover:neeto-ui-bg-100 cursor-not-allowed opacity-50": disabled,
@@ -3913,13 +248,13 @@ var Card = function Card(_ref) {
3913
248
  className: "neeto-ui-text-warning-500",
3914
249
  "data-cy": renderDataCy(label, "connect-button"),
3915
250
  disabled: disabled || isLoading,
3916
- label: t("common.tryAgain"),
251
+ label: t("neetoIntegrations.common.tryAgain"),
3917
252
  style: "link",
3918
253
  onClick: onConnect
3919
254
  }), !isConnected && !isFailed && /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
3920
255
  "data-cy": renderDataCy(label, "connect-button"),
3921
256
  disabled: disabled || isLoading,
3922
- label: t("common.connect"),
257
+ label: t("neetoIntegrations.common.connect"),
3923
258
  style: "link",
3924
259
  onClick: onConnect
3925
260
  }), (isConnected || isFailed) && /*#__PURE__*/React__default["default"].createElement(Dropdown, {
@@ -3945,7 +280,7 @@ var DisconnectAlert = function DisconnectAlert(_ref) {
3945
280
  _ref$onDisconnect = _ref.onDisconnect,
3946
281
  onDisconnect = _ref$onDisconnect === void 0 ? pure.noop : _ref$onDisconnect,
3947
282
  otherProps = _objectWithoutProperties(_ref, _excluded);
3948
- var _useTranslation = useTranslation(),
283
+ var _useTranslation = reactI18next.useTranslation(),
3949
284
  t = _useTranslation.t;
3950
285
  return /*#__PURE__*/React__default["default"].createElement(neetoui.Alert, _extends$1({
3951
286
  closeOnEsc: true,
@@ -3953,7 +288,7 @@ var DisconnectAlert = function DisconnectAlert(_ref) {
3953
288
  isOpen: isOpen,
3954
289
  isSubmitting: isDisconnecting,
3955
290
  message: message,
3956
- submitButtonLabel: t("common.disconnect"),
291
+ submitButtonLabel: t("neetoIntegrations.common.disconnect"),
3957
292
  title: title,
3958
293
  onClose: onClose,
3959
294
  onSubmit: onDisconnect
@@ -4113,7 +448,7 @@ var Connect = function Connect(_ref) {
4113
448
  _ref$onConnect = _ref.onConnect,
4114
449
  onConnect = _ref$onConnect === void 0 ? pure.noop : _ref$onConnect,
4115
450
  children = _ref.children;
4116
- var _useTranslation = useTranslation(),
451
+ var _useTranslation = reactI18next.useTranslation(),
4117
452
  t = _useTranslation.t;
4118
453
  return /*#__PURE__*/React__default["default"].createElement("div", {
4119
454
  className: "mx-auto w-full max-w-lg"
@@ -4128,7 +463,7 @@ var Connect = function Connect(_ref) {
4128
463
  style: "body1",
4129
464
  weight: "normal"
4130
465
  }, description), children, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, _extends$1({
4131
- label: t("common.connect"),
466
+ label: t("neetoIntegrations.common.connect"),
4132
467
  onClick: onConnect
4133
468
  }, buttonProps)));
4134
469
  };
@@ -4166,7 +501,7 @@ var Demo = function Demo(_ref) {
4166
501
  _ref$videoUrl = _ref.videoUrl,
4167
502
  videoUrl = _ref$videoUrl === void 0 ? "" : _ref$videoUrl,
4168
503
  children = _ref.children;
4169
- var _useTranslation = useTranslation(),
504
+ var _useTranslation = reactI18next.useTranslation(),
4170
505
  t = _useTranslation.t;
4171
506
  var renderVideo = function renderVideo(videoUrl) {
4172
507
  return isYouTubeLink(videoUrl) ? /*#__PURE__*/React__default["default"].createElement("div", {
@@ -4176,7 +511,7 @@ var Demo = function Demo(_ref) {
4176
511
  frameBorder: "0",
4177
512
  id: "ytplayer",
4178
513
  src: videoUrl,
4179
- title: t("demo.iFrameTitle"),
514
+ title: t("neetoIntegrations.demo.iFrameTitle"),
4180
515
  type: "text/html"
4181
516
  })) : /*#__PURE__*/React__default["default"].createElement("video", {
4182
517
  autoPlay: true,
@@ -4194,15 +529,15 @@ var Demo = function Demo(_ref) {
4194
529
  className: "neeto-ui-text-gray-800 mt-4 py-2",
4195
530
  style: "h2",
4196
531
  weight: "semibold"
4197
- }, t("demo.title")), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
532
+ }, t("neetoIntegrations.demo.title")), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
4198
533
  style: "body2",
4199
534
  weight: "light"
4200
- }, t("demo.subtitle")), children, videoUrl && /*#__PURE__*/React__default["default"].createElement("div", {
535
+ }, t("neetoIntegrations.demo.subtitle")), children, videoUrl && /*#__PURE__*/React__default["default"].createElement("div", {
4201
536
  className: "py-10"
4202
537
  }, renderVideo(videoUrl)), /*#__PURE__*/React__default["default"].createElement("div", {
4203
538
  className: "flex w-full items-start space-x-2"
4204
539
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
4205
- label: t("common.finish"),
540
+ label: t("neetoIntegrations.common.finish"),
4206
541
  onClick: onClose
4207
542
  })));
4208
543
  };
@@ -4253,7 +588,7 @@ var Finish = function Finish(_ref) {
4253
588
  _ref$secondaryButtonP = _ref.secondaryButtonProps,
4254
589
  secondaryButtonProps = _ref$secondaryButtonP === void 0 ? {} : _ref$secondaryButtonP,
4255
590
  children = _ref.children;
4256
- var _useTranslation = useTranslation(),
591
+ var _useTranslation = reactI18next.useTranslation(),
4257
592
  t = _useTranslation.t;
4258
593
  return /*#__PURE__*/React__default["default"].createElement("div", {
4259
594
  className: "neeto-ui-w-full mx-auto max-w-lg"
@@ -4264,7 +599,7 @@ var Finish = function Finish(_ref) {
4264
599
  }, title), children, /*#__PURE__*/React__default["default"].createElement("div", {
4265
600
  className: "flex w-full items-start space-x-2"
4266
601
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, _extends$1({
4267
- label: t("common.continue"),
602
+ label: t("neetoIntegrations.common.continue"),
4268
603
  onClick: onClick
4269
604
  }, buttonProps)), pure.isNotEmpty(secondaryButtonProps) && /*#__PURE__*/React__default["default"].createElement(neetoui.Button, _extends$1({
4270
605
  style: "secondary"
@@ -4297,7 +632,7 @@ var WalkthroughModal = function WalkthroughModal(_ref) {
4297
632
  _ref$videoUrl = _ref.videoUrl,
4298
633
  videoUrl = _ref$videoUrl === void 0 ? "" : _ref$videoUrl,
4299
634
  children = _ref.children;
4300
- var _useTranslation = useTranslation(),
635
+ var _useTranslation = reactI18next.useTranslation(),
4301
636
  t = _useTranslation.t;
4302
637
  return /*#__PURE__*/React__default["default"].createElement(neetoui.Modal, {
4303
638
  isOpen: isOpen,
@@ -4306,7 +641,7 @@ var WalkthroughModal = function WalkthroughModal(_ref) {
4306
641
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Modal.Header, null, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
4307
642
  style: "h2",
4308
643
  weight: "semibold"
4309
- }, t("walkthroughModal.header"))), /*#__PURE__*/React__default["default"].createElement(neetoui.Modal.Body, null, /*#__PURE__*/React__default["default"].createElement("div", {
644
+ }, t("neetoIntegrations.walkthroughModal.header"))), /*#__PURE__*/React__default["default"].createElement(neetoui.Modal.Body, null, /*#__PURE__*/React__default["default"].createElement("div", {
4310
645
  className: "w-full py-10"
4311
646
  }, /*#__PURE__*/React__default["default"].createElement("video", {
4312
647
  autoPlay: true,
@@ -4317,331 +652,11 @@ var WalkthroughModal = function WalkthroughModal(_ref) {
4317
652
  }, /*#__PURE__*/React__default["default"].createElement("source", {
4318
653
  src: videoUrl
4319
654
  })), children)), /*#__PURE__*/React__default["default"].createElement(neetoui.Modal.Footer, null, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
4320
- label: t("walkthroughModal.continue"),
655
+ label: t("neetoIntegrations.walkthroughModal.continue"),
4321
656
  onClick: onClose
4322
657
  })));
4323
658
  };
4324
659
 
4325
- function _arrayWithHoles(arr) {
4326
- if (Array.isArray(arr)) return arr;
4327
- }
4328
-
4329
- function _iterableToArrayLimit(arr, i) {
4330
- var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
4331
- if (null != _i) {
4332
- var _s,
4333
- _e,
4334
- _x,
4335
- _r,
4336
- _arr = [],
4337
- _n = !0,
4338
- _d = !1;
4339
- try {
4340
- if (_x = (_i = _i.call(arr)).next, 0 === i) {
4341
- if (Object(_i) !== _i) return;
4342
- _n = !1;
4343
- } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
4344
- } catch (err) {
4345
- _d = !0, _e = err;
4346
- } finally {
4347
- try {
4348
- if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
4349
- } finally {
4350
- if (_d) throw _e;
4351
- }
4352
- }
4353
- return _arr;
4354
- }
4355
- }
4356
-
4357
- function _arrayLikeToArray(arr, len) {
4358
- if (len == null || len > arr.length) len = arr.length;
4359
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
4360
- return arr2;
4361
- }
4362
-
4363
- function _unsupportedIterableToArray(o, minLen) {
4364
- if (!o) return;
4365
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
4366
- var n = Object.prototype.toString.call(o).slice(8, -1);
4367
- if (n === "Object" && o.constructor) n = o.constructor.name;
4368
- if (n === "Map" || n === "Set") return Array.from(o);
4369
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
4370
- }
4371
-
4372
- function _nonIterableRest() {
4373
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
4374
- }
4375
-
4376
- function _slicedToArray(arr, i) {
4377
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
4378
- }
4379
-
4380
- function _typeof(obj) {
4381
- "@babel/helpers - typeof";
4382
-
4383
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
4384
- return typeof obj;
4385
- } : function (obj) {
4386
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
4387
- }, _typeof(obj);
4388
- }
4389
-
4390
- function _toPrimitive(input, hint) {
4391
- if (_typeof(input) !== "object" || input === null) return input;
4392
- var prim = input[Symbol.toPrimitive];
4393
- if (prim !== undefined) {
4394
- var res = prim.call(input, hint || "default");
4395
- if (_typeof(res) !== "object") return res;
4396
- throw new TypeError("@@toPrimitive must return a primitive value.");
4397
- }
4398
- return (hint === "string" ? String : Number)(input);
4399
- }
4400
-
4401
- function _toPropertyKey(arg) {
4402
- var key = _toPrimitive(arg, "string");
4403
- return _typeof(key) === "symbol" ? key : String(key);
4404
- }
4405
-
4406
- function _defineProperty(obj, key, value) {
4407
- key = _toPropertyKey(key);
4408
- if (key in obj) {
4409
- Object.defineProperty(obj, key, {
4410
- value: value,
4411
- enumerable: true,
4412
- configurable: true,
4413
- writable: true
4414
- });
4415
- } else {
4416
- obj[key] = value;
4417
- }
4418
- return obj;
4419
- }
4420
-
4421
- var Menu = neetoui.Dropdown.Menu,
4422
- MenuItem = neetoui.Dropdown.MenuItem;
4423
- var Actions = function Actions(_ref) {
4424
- var apiKey = _ref.apiKey,
4425
- setApiKeyToDelete = _ref.setApiKeyToDelete;
4426
- var _useTranslation = useTranslation(),
4427
- t = _useTranslation.t;
4428
- return /*#__PURE__*/React__default["default"].createElement(neetoui.Dropdown, {
4429
- buttonStyle: "text",
4430
- icon: neetoIcons.MenuHorizontal,
4431
- strategy: "fixed"
4432
- }, /*#__PURE__*/React__default["default"].createElement(Menu, null, /*#__PURE__*/React__default["default"].createElement(MenuItem.Button, {
4433
- "data-cy": "delete-apikey-button",
4434
- onClick: function onClick() {
4435
- return setApiKeyToDelete(apiKey);
4436
- }
4437
- }, t("common.delete"))));
4438
- };
4439
-
4440
- 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; }
4441
- 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; }
4442
- var getApiKeysTableColumnData = function getApiKeysTableColumnData() {
4443
- return [{
4444
- title: instance.t("zapier.tableColumns.label"),
4445
- dataIndex: "options",
4446
- key: "options",
4447
- width: 272,
4448
- render: function render(options, _ref) {
4449
- var actions = _ref.actions;
4450
- return /*#__PURE__*/React__default["default"].createElement("div", {
4451
- className: "flex items-center justify-between gap-x-3"
4452
- }, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
4453
- className: "w-4/5",
4454
- style: "body2"
4455
- }, options === null || options === void 0 ? void 0 : options.label), actions);
4456
- }
4457
- }, {
4458
- title: instance.t("zapier.tableColumns.createdAt"),
4459
- dataIndex: "createdAt",
4460
- key: "createdAt"
4461
- }];
4462
- };
4463
- var getApiKeysTableRowData = function getApiKeysTableRowData(_ref2) {
4464
- var apiKeys = _ref2.apiKeys,
4465
- setApiKeyToDelete = _ref2.setApiKeyToDelete;
4466
- return apiKeys.map(function (apiKey) {
4467
- return _objectSpread$1(_objectSpread$1({}, apiKey), {}, {
4468
- createdAt: utils.timeFormat.fromNow(apiKey.createdAt),
4469
- actions: /*#__PURE__*/React__default["default"].createElement(Actions, {
4470
- apiKey: apiKey,
4471
- setApiKeyToDelete: setApiKeyToDelete
4472
- })
4473
- });
4474
- });
4475
- };
4476
-
4477
- var ApiKeysList = function ApiKeysList(_ref) {
4478
- var _apiKeyToDelete$optio;
4479
- var _ref$apiKeys = _ref.apiKeys,
4480
- apiKeys = _ref$apiKeys === void 0 ? [] : _ref$apiKeys,
4481
- _ref$deleteApiKey = _ref.deleteApiKey,
4482
- deleteApiKey = _ref$deleteApiKey === void 0 ? pure.noop : _ref$deleteApiKey,
4483
- _ref$isDeleting = _ref.isDeleting,
4484
- isDeleting = _ref$isDeleting === void 0 ? false : _ref$isDeleting,
4485
- _ref$setNewlyCreatedA = _ref.setNewlyCreatedApiKey,
4486
- setNewlyCreatedApiKey = _ref$setNewlyCreatedA === void 0 ? pure.noop : _ref$setNewlyCreatedA;
4487
- var _useState = React.useState(null),
4488
- _useState2 = _slicedToArray(_useState, 2),
4489
- apiKeyToDelete = _useState2[0],
4490
- setApiKeyToDelete = _useState2[1];
4491
- var _useTranslation = useTranslation(),
4492
- t = _useTranslation.t;
4493
- var closeAlert = function closeAlert() {
4494
- return setApiKeyToDelete(null);
4495
- };
4496
- var handleSubmit = function handleSubmit() {
4497
- deleteApiKey(apiKeyToDelete === null || apiKeyToDelete === void 0 ? void 0 : apiKeyToDelete.id, {
4498
- onSuccess: function onSuccess() {
4499
- closeAlert();
4500
- setNewlyCreatedApiKey("");
4501
- }
4502
- });
4503
- };
4504
- if (ramda.isEmpty(apiKeys)) return null;
4505
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
4506
- className: "space-y-2"
4507
- }, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
4508
- style: "h3"
4509
- }, t("zapier.tableTitle")), /*#__PURE__*/React__default["default"].createElement(neetoui.Table, {
4510
- fixedHeight: true,
4511
- allowRowClick: false,
4512
- columnData: getApiKeysTableColumnData(),
4513
- rowData: getApiKeysTableRowData({
4514
- apiKeys: apiKeys,
4515
- setApiKeyToDelete: setApiKeyToDelete
4516
- })
4517
- })), /*#__PURE__*/React__default["default"].createElement(neetoui.Alert, {
4518
- backdropClassName: "zapier-delete-alert",
4519
- isOpen: ramda.isNotNil(apiKeyToDelete),
4520
- isSubmitting: isDeleting,
4521
- submitButtonLabel: t("common.delete"),
4522
- title: t("zapier.deleteApiKey.title"),
4523
- message: /*#__PURE__*/React__default["default"].createElement(Trans, {
4524
- i18nKey: "zapier.deleteApiKey.message",
4525
- values: {
4526
- key: apiKeyToDelete === null || apiKeyToDelete === void 0 ? void 0 : (_apiKeyToDelete$optio = apiKeyToDelete.options) === null || _apiKeyToDelete$optio === void 0 ? void 0 : _apiKeyToDelete$optio.label
4527
- }
4528
- }),
4529
- onClose: closeAlert,
4530
- onSubmit: handleSubmit
4531
- }));
4532
- };
4533
-
4534
- var GENERATE_API_KEY_VALIDATION = Yup__namespace.object({
4535
- label: Yup__namespace.string().required(instance.t("common.required"))
4536
- });
4537
- var GENERATE_API_KEY_FORMIK_PROPS = {
4538
- initialValues: {
4539
- label: ""
4540
- },
4541
- validationSchema: GENERATE_API_KEY_VALIDATION
4542
- };
4543
-
4544
- 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; }
4545
- 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; }
4546
- var GenerateKey = function GenerateKey(_ref) {
4547
- var handleSubmit = _ref.handleSubmit,
4548
- isLoading = _ref.isLoading;
4549
- var _useTranslation = useTranslation(),
4550
- t = _useTranslation.t;
4551
- var inputRef = React.useRef(null);
4552
- React.useEffect(function () {
4553
- if (inputRef.current) {
4554
- inputRef.current.focus();
4555
- }
4556
- }, []);
4557
- return /*#__PURE__*/React__default["default"].createElement(formik.Form, {
4558
- formikProps: _objectSpread(_objectSpread({}, GENERATE_API_KEY_FORMIK_PROPS), {}, {
4559
- onSubmit: handleSubmit
4560
- })
4561
- }, /*#__PURE__*/React__default["default"].createElement("div", {
4562
- className: "space-y-4"
4563
- }, /*#__PURE__*/React__default["default"].createElement(formik.Input, {
4564
- name: "label",
4565
- placeholder: t("zapier.labelInputPlaceholder"),
4566
- ref: inputRef
4567
- }), /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
4568
- label: t("zapier.generateApiKey"),
4569
- loading: isLoading,
4570
- type: "submit"
4571
- })));
4572
- };
4573
-
4574
- var NewApiKeyCallout = function NewApiKeyCallout(_ref) {
4575
- var apiKey = _ref.apiKey;
4576
- var _useTranslation = useTranslation(),
4577
- t = _useTranslation.t;
4578
- return /*#__PURE__*/React__default["default"].createElement("div", {
4579
- className: "mb-8 space-y-2"
4580
- }, /*#__PURE__*/React__default["default"].createElement(neetoui.Callout, null, t("zapier.newApiKeyInstruction")), /*#__PURE__*/React__default["default"].createElement(neetoui.Callout, {
4581
- className: "flex justify-between",
4582
- style: "success"
4583
- }, apiKey, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
4584
- icon: neetoIcons.Copy,
4585
- style: "text",
4586
- tooltipProps: {
4587
- content: t("zapier.copyApiKey")
4588
- },
4589
- onClick: function onClick() {
4590
- return utils.copyToClipboard(apiKey);
4591
- }
4592
- })));
4593
- };
4594
-
4595
- var ZapierForm = function ZapierForm(_ref) {
4596
- var _ref$newlyCreatedApiK = _ref.newlyCreatedApiKey,
4597
- newlyCreatedApiKey = _ref$newlyCreatedApiK === void 0 ? "" : _ref$newlyCreatedApiK,
4598
- _ref$videoUrl = _ref.videoUrl,
4599
- videoUrl = _ref$videoUrl === void 0 ? "" : _ref$videoUrl,
4600
- _ref$apiKeys = _ref.apiKeys,
4601
- apiKeys = _ref$apiKeys === void 0 ? [] : _ref$apiKeys,
4602
- _ref$isGenerating = _ref.isGenerating,
4603
- isGenerating = _ref$isGenerating === void 0 ? false : _ref$isGenerating,
4604
- _ref$isLoading = _ref.isLoading,
4605
- isLoading = _ref$isLoading === void 0 ? true : _ref$isLoading,
4606
- _ref$isDeleting = _ref.isDeleting,
4607
- isDeleting = _ref$isDeleting === void 0 ? false : _ref$isDeleting,
4608
- _ref$deleteApiKey = _ref.deleteApiKey,
4609
- deleteApiKey = _ref$deleteApiKey === void 0 ? pure.noop : _ref$deleteApiKey,
4610
- _ref$handleGenerateAp = _ref.handleGenerateApiKey,
4611
- handleGenerateApiKey = _ref$handleGenerateAp === void 0 ? pure.noop : _ref$handleGenerateAp,
4612
- _ref$setNewlyCreatedA = _ref.setNewlyCreatedApiKey,
4613
- setNewlyCreatedApiKey = _ref$setNewlyCreatedA === void 0 ? pure.noop : _ref$setNewlyCreatedA,
4614
- _ref$setIsDemoModalOp = _ref.setIsDemoModalOpen,
4615
- setIsDemoModalOpen = _ref$setIsDemoModalOp === void 0 ? pure.noop : _ref$setIsDemoModalOp;
4616
- var _useTranslation = useTranslation(),
4617
- t = _useTranslation.t;
4618
- if (isLoading) return /*#__PURE__*/React__default["default"].createElement(neetoui.Spinner, null);
4619
- return /*#__PURE__*/React__default["default"].createElement("div", {
4620
- className: "w-full max-w-xl space-y-10 p-10"
4621
- }, pure.isNotEmpty(newlyCreatedApiKey) && /*#__PURE__*/React__default["default"].createElement(NewApiKeyCallout, {
4622
- apiKey: newlyCreatedApiKey
4623
- }), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
4624
- style: "h2"
4625
- }, t("zapier.apiKeys")), ramda.isEmpty(apiKeys) && /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
4626
- style: "h4"
4627
- }, t("zapier.emptyText")), /*#__PURE__*/React__default["default"].createElement(GenerateKey, {
4628
- handleSubmit: handleGenerateApiKey,
4629
- isLoading: isGenerating
4630
- }), /*#__PURE__*/React__default["default"].createElement(ApiKeysList, {
4631
- apiKeys: apiKeys,
4632
- deleteApiKey: deleteApiKey,
4633
- isDeleting: isDeleting,
4634
- setNewlyCreatedApiKey: setNewlyCreatedApiKey
4635
- }), pure.isNotEmpty(videoUrl) && /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
4636
- className: "mb-6",
4637
- label: t("zapier.walkthroughText"),
4638
- style: "link",
4639
- onClick: function onClick() {
4640
- return setIsDemoModalOpen(true);
4641
- }
4642
- }));
4643
- };
4644
-
4645
660
  var e = [],
4646
661
  t = [];
4647
662
  function n(n, r) {
@@ -4674,5 +689,4 @@ exports.DisconnectAlert = DisconnectAlert;
4674
689
  exports.Finish = Finish;
4675
690
  exports.Modal = Modal;
4676
691
  exports.WalkthroughModal = WalkthroughModal;
4677
- exports.ZapierForm = ZapierForm;
4678
692
  //# sourceMappingURL=index.cjs.js.map