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