@twab/visualization 0.2.0 → 0.2.2

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.
@@ -1,172 +1,6 @@
1
1
  /******/ (function() { // webpackBootstrap
2
2
  /******/ var __webpack_modules__ = ({
3
3
 
4
- /***/ 9394:
5
- /***/ (function(__unused_webpack_module, exports) {
6
-
7
- "use strict";
8
- var __webpack_unused_export__;
9
-
10
-
11
- __webpack_unused_export__ = ({
12
- value: true
13
- });
14
- function install(Vue, {
15
- i18next,
16
- rerenderOn = ['languageChanged', 'loaded', 'added', 'removed']
17
- }) {
18
- const genericT = i18next.t.bind(i18next);
19
- const changeTracker = Vue.observable({
20
- lastI18nChange: new Date()
21
- });
22
- const invalidate = () => changeTracker.lastI18nChange = new Date();
23
- const usingTranslation = () => changeTracker.lastI18nChange;
24
- rerenderOn.forEach(event => {
25
- var _a;
26
- switch (event) {
27
- case 'added':
28
- case 'removed':
29
- (_a = i18next.store) === null || _a === void 0 ? void 0 : _a.on(event, invalidate);
30
- break;
31
- default:
32
- i18next.on(event, invalidate);
33
- break;
34
- }
35
- });
36
- Vue.mixin({
37
- beforeCreate() {
38
- var _a, _b;
39
- const options = this.$options;
40
- if (!options.__i18n && !options.i18nOptions) {
41
- this.__translate = undefined;
42
- return;
43
- }
44
- const name = this.$options.name;
45
- const rand = (Math.random() * 10 ** 8 | 0).toString();
46
- const localNs = [name, rand].filter(x => !!x).join("-");
47
- this.__bundles = [];
48
- const loadBundle = bundle => {
49
- Object.entries(bundle).forEach(([lng, resources]) => {
50
- i18next.addResourceBundle(lng, localNs, resources, true, false);
51
- this.__bundles.push([lng, localNs]);
52
- });
53
- };
54
- (_a = options.__i18n) === null || _a === void 0 ? void 0 : _a.forEach(bundle => {
55
- loadBundle(JSON.parse(bundle));
56
- });
57
- let {
58
- lng,
59
- ns,
60
- keyPrefix
61
- } = handleI18nOptions(options, loadBundle);
62
- if ((_b = this.__bundles) === null || _b === void 0 ? void 0 : _b.length) {
63
- ns = [localNs].concat(ns !== null && ns !== void 0 ? ns : []);
64
- }
65
- const t = getTranslationFunction(lng, ns);
66
- this.__translate = (key, options) => {
67
- if (!keyPrefix || includesNs(key)) {
68
- return t(key, options);
69
- } else {
70
- return t(keyPrefix + '.' + key, options);
71
- }
72
- };
73
- },
74
- destroyed() {
75
- var _a;
76
- (_a = this.__bundles) === null || _a === void 0 ? void 0 : _a.forEach(([lng, ns]) => i18next.removeResourceBundle(lng, ns));
77
- }
78
- });
79
- Vue.prototype.$t = function (key, options) {
80
- var _a;
81
- usingTranslation();
82
- if (i18next.isInitialized) {
83
- return ((_a = this === null || this === void 0 ? void 0 : this.__translate) !== null && _a !== void 0 ? _a : genericT)(key, options);
84
- } else {
85
- return key;
86
- }
87
- };
88
- Vue.prototype.$i18next = typeof Proxy === 'function' ? new Proxy(i18next, {
89
- get(target, prop) {
90
- usingTranslation();
91
- return Reflect.get(target, prop);
92
- }
93
- }) : i18next;
94
- function getTranslationFunction(lng, ns) {
95
- if (lng) {
96
- return i18next.getFixedT(lng, ns);
97
- } else if (ns) {
98
- return i18next.getFixedT(null, ns);
99
- } else {
100
- return genericT;
101
- }
102
- }
103
- function includesNs(key) {
104
- const nsSeparator = i18next.options.nsSeparator;
105
- return typeof nsSeparator === "string" && key.includes(nsSeparator);
106
- }
107
- function handleI18nOptions(options, loadBundle) {
108
- let lng;
109
- let ns;
110
- let keyPrefix;
111
- if (options.i18nOptions) {
112
- let messages;
113
- let namespaces;
114
- ({
115
- lng,
116
- namespaces = i18next.options.defaultNS,
117
- keyPrefix,
118
- messages
119
- } = options.i18nOptions);
120
- if (messages) {
121
- loadBundle(messages);
122
- }
123
- ns = typeof namespaces === 'string' ? [namespaces] : namespaces;
124
- if (ns) {
125
- i18next.loadNamespaces(ns);
126
- }
127
- }
128
- return {
129
- lng,
130
- ns,
131
- keyPrefix
132
- };
133
- }
134
- const slotNamePattern = new RegExp('{\\s*([a-z0-9\\-]+)\\s*}', 'gi');
135
- const TranslationComponent = {
136
- functional: true,
137
- props: {
138
- translation: {
139
- type: String,
140
- required: true
141
- }
142
- },
143
- render(_createElement, context) {
144
- const textNode = context._v;
145
- const translation = context.props.translation;
146
- const result = [];
147
- let match;
148
- let lastIndex = 0;
149
- while ((match = slotNamePattern.exec(translation)) !== null) {
150
- result.push(textNode(translation.substring(lastIndex, match.index)));
151
- const slot = context.scopedSlots[match[1]];
152
- if (slot) {
153
- const nodes = slot({});
154
- nodes === null || nodes === void 0 ? void 0 : nodes.forEach(n => result.push(n));
155
- } else {
156
- result.push(textNode(match[0]));
157
- }
158
- lastIndex = slotNamePattern.lastIndex;
159
- }
160
- result.push(textNode(translation.substring(lastIndex)));
161
- return result;
162
- }
163
- };
164
- Vue.component('i18next', TranslationComponent);
165
- }
166
- exports.Z = install;
167
-
168
- /***/ }),
169
-
170
4
  /***/ 2573:
171
5
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
172
6
 
@@ -10697,12 +10531,12 @@ if (typeof window !== 'undefined') {
10697
10531
  // Indicate to webpack that this file can be concatenated
10698
10532
  /* harmony default export */ var setPublicPath = (null);
10699
10533
 
10700
- ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Visualization.vue?vue&type=template&id=301b4a1c&scoped=true&
10534
+ ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Visualization.vue?vue&type=template&id=50ffcc14&scoped=true&
10701
10535
  var render = function render() {
10702
10536
  var _vm = this,
10703
10537
  _c = _vm._self._c;
10704
10538
  return _c('div', {
10705
- staticClass: "row",
10539
+ staticClass: "visualization-row",
10706
10540
  attrs: {
10707
10541
  "id": "visualization-container"
10708
10542
  },
@@ -10791,7 +10625,7 @@ var render = function render() {
10791
10625
  }
10792
10626
  }) : _vm._e(), _c('div', {
10793
10627
  class: {
10794
- card: true,
10628
+ 'visualization-card': true,
10795
10629
  'active-tab': _vm.active
10796
10630
  },
10797
10631
  staticStyle: {
@@ -10872,7 +10706,10 @@ var render = function render() {
10872
10706
  }), _vm._l(_vm.numberOfRows, function (rowNumber) {
10873
10707
  return _c('div', {
10874
10708
  key: 'row-' + rowNumber,
10875
- staticClass: "row",
10709
+ staticClass: "visualization-row",
10710
+ staticStyle: {
10711
+ "padding": "12px"
10712
+ },
10876
10713
  attrs: {
10877
10714
  "id": 'row-' + rowNumber
10878
10715
  }
@@ -10901,7 +10738,7 @@ var render = function render() {
10901
10738
  }), _vm._l(_vm.frames.slice(_vm.framesPerRow * (rowNumber - 1), _vm.framesPerRow * rowNumber), function (frame, frameNumber) {
10902
10739
  return _c('div', {
10903
10740
  key: 'row-' + rowNumber + '-frame-' + frameNumber,
10904
- staticClass: "col",
10741
+ staticClass: "visualization-col",
10905
10742
  class: {
10906
10743
  loaderImg: !!frame.img
10907
10744
  },
@@ -10953,8 +10790,8 @@ var render = function render() {
10953
10790
  };
10954
10791
  var staticRenderFns = [];
10955
10792
 
10956
- ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/Frame.vue?vue&type=template&id=59f2115a&scoped=true&
10957
- var Framevue_type_template_id_59f2115a_scoped_true_render = function render() {
10793
+ ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/Frame.vue?vue&type=template&id=50ccd370&scoped=true&
10794
+ var Framevue_type_template_id_50ccd370_scoped_true_render = function render() {
10958
10795
  var _vm = this,
10959
10796
  _c = _vm._self._c;
10960
10797
  return _c('div', {
@@ -10967,7 +10804,8 @@ var Framevue_type_template_id_59f2115a_scoped_true_render = function render() {
10967
10804
  },
10968
10805
  style: {
10969
10806
  height: `${_vm.maxHeight}px`,
10970
- width: `${_vm.maxWidth}px`
10807
+ width: '100%',
10808
+ position: 'relative'
10971
10809
  }
10972
10810
  }, [_vm.active && _vm.activeTab ? _c('GlobalEvents', {
10973
10811
  on: {
@@ -11007,15 +10845,18 @@ var Framevue_type_template_id_59f2115a_scoped_true_render = function render() {
11007
10845
  "background-color": "#ededed",
11008
10846
  "text": _vm.videoIsLoading ? 'A criar vídeo temporário...' : ''
11009
10847
  }
11010
- }), !_vm.loading ? _c('div', {
10848
+ }), _c('div', {
10849
+ staticStyle: {
10850
+ "background-color": "black"
10851
+ }
10852
+ }, [!_vm.loading ? _c('div', {
11011
10853
  class: {
11012
10854
  'frame-content': _vm.frame.title === -1 || _vm.videoStatus !== _vm.Status.stopped
11013
10855
  },
11014
10856
  style: {
11015
10857
  height: `${_vm.height}px`,
11016
10858
  width: `${_vm.width}px`,
11017
- color: 'white',
11018
- position: 'relative'
10859
+ color: 'white'
11019
10860
  },
11020
10861
  on: {
11021
10862
  "dblclick": _vm.playOrPause
@@ -11043,7 +10884,7 @@ var Framevue_type_template_id_59f2115a_scoped_true_render = function render() {
11043
10884
  }
11044
10885
  }) : _vm._e(), _c('div', {
11045
10886
  staticClass: "overlay"
11046
- })]) : _vm._e(), _c('dialog', {
10887
+ })]) : _vm._e()]), _c('dialog', {
11047
10888
  ref: "imageDetailsDialog",
11048
10889
  class: {
11049
10890
  'dummy-frame': _vm.frame.title === -1
@@ -11058,7 +10899,7 @@ var Framevue_type_template_id_59f2115a_scoped_true_render = function render() {
11058
10899
  }
11059
10900
  })], 1);
11060
10901
  };
11061
- var Framevue_type_template_id_59f2115a_scoped_true_staticRenderFns = [];
10902
+ var Framevue_type_template_id_50ccd370_scoped_true_staticRenderFns = [];
11062
10903
 
11063
10904
  // EXTERNAL MODULE: ./node_modules/vue-loading-twa/lib/vue-loading-twa.min.js
11064
10905
  var vue_loading_twa_min = __webpack_require__(3093);
@@ -11267,10 +11108,10 @@ const Status = Object.freeze({
11267
11108
  });
11268
11109
  ;// CONCATENATED MODULE: ./src/components/Frame.vue?vue&type=script&lang=js&
11269
11110
  /* harmony default export */ var components_Framevue_type_script_lang_js_ = (Framevue_type_script_lang_js_);
11270
- ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-12.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-12.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-12.use[2]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/Frame.vue?vue&type=style&index=0&id=59f2115a&prod&scoped=true&lang=css&
11111
+ ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-12.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-12.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-12.use[2]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/Frame.vue?vue&type=style&index=0&id=50ccd370&prod&scoped=true&lang=css&
11271
11112
  // extracted by mini-css-extract-plugin
11272
11113
 
11273
- ;// CONCATENATED MODULE: ./src/components/Frame.vue?vue&type=style&index=0&id=59f2115a&prod&scoped=true&lang=css&
11114
+ ;// CONCATENATED MODULE: ./src/components/Frame.vue?vue&type=style&index=0&id=50ccd370&prod&scoped=true&lang=css&
11274
11115
 
11275
11116
  ;// CONCATENATED MODULE: ./node_modules/@vue/vue-loader-v15/lib/runtime/componentNormalizer.js
11276
11117
  /* globals __VUE_SSR_CONTEXT__ */
@@ -11381,11 +11222,11 @@ function normalizeComponent(
11381
11222
 
11382
11223
  var component = normalizeComponent(
11383
11224
  components_Framevue_type_script_lang_js_,
11384
- Framevue_type_template_id_59f2115a_scoped_true_render,
11385
- Framevue_type_template_id_59f2115a_scoped_true_staticRenderFns,
11225
+ Framevue_type_template_id_50ccd370_scoped_true_render,
11226
+ Framevue_type_template_id_50ccd370_scoped_true_staticRenderFns,
11386
11227
  false,
11387
11228
  null,
11388
- "59f2115a",
11229
+ "50ccd370",
11389
11230
  null
11390
11231
 
11391
11232
  )
@@ -14968,22 +14809,22 @@ FramesInterface.prototype.getVideoRequestByUrl = function (url_path, t) {
14968
14809
  return url + 'StreamFromVideo?url=' + url_path + params + '#t=' + t;
14969
14810
  };
14970
14811
  /* harmony default export */ var utils_FramesInterface = (FramesInterface);
14971
- ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/Commands.vue?vue&type=template&id=e71d900a&
14972
- var Commandsvue_type_template_id_e71d900a_render = function render() {
14812
+ ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/Commands.vue?vue&type=template&id=781eccb8&
14813
+ var Commandsvue_type_template_id_781eccb8_render = function render() {
14973
14814
  var _vm = this,
14974
14815
  _c = _vm._self._c;
14975
14816
  return _c('div', {
14976
- staticClass: "col pa-0",
14817
+ staticClass: "visualization-col pa-0",
14977
14818
  attrs: {
14978
14819
  "id": "command-bar"
14979
14820
  }
14980
14821
  }, [_vm.commandBarShow ? _c('div', {
14981
- staticClass: "row justify-center"
14822
+ staticClass: "visualization-row visualization-justify-center"
14982
14823
  }, _vm._l(_vm.commandBarBtns, function (btn, index) {
14983
14824
  return _c('div', {
14984
14825
  key: 'command-btn-' + index
14985
14826
  }, [!btn ? _c('hr', {
14986
- staticClass: "divider vertical",
14827
+ staticClass: "visualization-divider vertical",
14987
14828
  staticStyle: {
14988
14829
  "margin": "0 4px"
14989
14830
  }
@@ -15008,10 +14849,10 @@ var Commandsvue_type_template_id_e71d900a_render = function render() {
15008
14849
  }
15009
14850
  })], 1) : _vm._e()]);
15010
14851
  }), 0) : _vm._e(), _c('hr', {
15011
- staticClass: "divider"
14852
+ staticClass: "visualization-divider"
15012
14853
  })]);
15013
14854
  };
15014
- var Commandsvue_type_template_id_e71d900a_staticRenderFns = [];
14855
+ var Commandsvue_type_template_id_781eccb8_staticRenderFns = [];
15015
14856
 
15016
14857
  ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/Commands.vue?vue&type=script&lang=js&
15017
14858
  /* harmony default export */ var Commandsvue_type_script_lang_js_ = ({
@@ -15158,8 +14999,8 @@ var Commandsvue_type_template_id_e71d900a_staticRenderFns = [];
15158
14999
  ;
15159
15000
  var Commands_component = normalizeComponent(
15160
15001
  components_Commandsvue_type_script_lang_js_,
15161
- Commandsvue_type_template_id_e71d900a_render,
15162
- Commandsvue_type_template_id_e71d900a_staticRenderFns,
15002
+ Commandsvue_type_template_id_781eccb8_render,
15003
+ Commandsvue_type_template_id_781eccb8_staticRenderFns,
15163
15004
  false,
15164
15005
  null,
15165
15006
  null,
@@ -15168,12 +15009,12 @@ var Commands_component = normalizeComponent(
15168
15009
  )
15169
15010
 
15170
15011
  /* harmony default export */ var Commands = (Commands_component.exports);
15171
- ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/Infos.vue?vue&type=template&id=c15b4388&
15172
- var Infosvue_type_template_id_c15b4388_render = function render() {
15012
+ ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/Infos.vue?vue&type=template&id=441ca26a&
15013
+ var Infosvue_type_template_id_441ca26a_render = function render() {
15173
15014
  var _vm = this,
15174
15015
  _c = _vm._self._c;
15175
15016
  return _c('div', {
15176
- staticClass: "row justify-center align-center",
15017
+ staticClass: "visualization-row visualization-justify-center visualization-align-center",
15177
15018
  staticStyle: {
15178
15019
  "padding": "4px"
15179
15020
  },
@@ -15181,7 +15022,7 @@ var Infosvue_type_template_id_c15b4388_render = function render() {
15181
15022
  "id": "info-bar"
15182
15023
  }
15183
15024
  }, [_c('span', [_vm._v(" " + _vm._s(_vm.playbackRate) + "x ")]), _c('hr', {
15184
- staticClass: "divider vertical",
15025
+ staticClass: "visualization-divider vertical",
15185
15026
  staticStyle: {
15186
15027
  "margin": "0 8px"
15187
15028
  }
@@ -15190,14 +15031,14 @@ var Infosvue_type_template_id_c15b4388_render = function render() {
15190
15031
  hour_ini: _vm.convertToAudienceTime(_vm.hourIni),
15191
15032
  hour_end: _vm.convertToAudienceTime(_vm.hourEnd)
15192
15033
  })) + " ")]), _c('hr', {
15193
- staticClass: "divider vertical",
15034
+ staticClass: "visualization-divider vertical",
15194
15035
  staticStyle: {
15195
15036
  "margin": "0 8px"
15196
15037
  }
15197
15038
  }), _c('span', [_vm._v(" " + _vm._s(_vm.$t('infoBar.interval', {
15198
15039
  seconds: _vm.secondsPerFrame
15199
15040
  })) + " ")]), _c('hr', {
15200
- staticClass: "divider vertical",
15041
+ staticClass: "visualization-divider vertical",
15201
15042
  staticStyle: {
15202
15043
  "margin": "0 8px"
15203
15044
  }
@@ -15205,17 +15046,17 @@ var Infosvue_type_template_id_c15b4388_render = function render() {
15205
15046
  time1: _vm.convertToAudienceTime(_vm.blockStartTime),
15206
15047
  time2: _vm.convertToAudienceTime(_vm.blockTotalTime)
15207
15048
  })) + " ")]), _c('hr', {
15208
- staticClass: "divider vertical",
15049
+ staticClass: "visualization-divider vertical",
15209
15050
  staticStyle: {
15210
15051
  "margin": "0 8px"
15211
15052
  }
15212
15053
  }), _vm._v(" " + _vm._s(_vm.framesPerRow * _vm.numberOfRows) + " "), _c('hr', {
15213
- staticClass: "divider vertical",
15054
+ staticClass: "visualization-divider vertical",
15214
15055
  staticStyle: {
15215
15056
  "margin": "0 8px"
15216
15057
  }
15217
15058
  }), _vm._v(" " + _vm._s(_vm.framesPerRow + '*' + _vm.numberOfRows) + " "), _vm.alternativeServer || !_vm.cache ? _c('span', {
15218
- staticClass: "divider vertical",
15059
+ staticClass: "visualization-divider vertical",
15219
15060
  staticStyle: {
15220
15061
  "margin": "0 8px"
15221
15062
  }
@@ -15226,7 +15067,7 @@ var Infosvue_type_template_id_c15b4388_render = function render() {
15226
15067
  "left": ""
15227
15068
  }
15228
15069
  }, [_vm._v("fa-exclamation-triangle")]), _c('strong', [_vm._v(_vm._s(_vm.$t('infoBar.alternativeServer')))])], 1) : _vm._e(), _vm.alternativeServer && !_vm.cache ? _c('span', {
15229
- staticClass: "divider vertical",
15070
+ staticClass: "visualization-divider vertical",
15230
15071
  staticStyle: {
15231
15072
  "margin": "0 8px"
15232
15073
  }
@@ -15285,7 +15126,7 @@ var Infosvue_type_template_id_c15b4388_render = function render() {
15285
15126
  }
15286
15127
  })], 1)]);
15287
15128
  };
15288
- var Infosvue_type_template_id_c15b4388_staticRenderFns = [];
15129
+ var Infosvue_type_template_id_441ca26a_staticRenderFns = [];
15289
15130
 
15290
15131
  ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/Infos.vue?vue&type=script&lang=js&
15291
15132
  /* harmony default export */ var Infosvue_type_script_lang_js_ = ({
@@ -15380,8 +15221,8 @@ var Infosvue_type_template_id_c15b4388_staticRenderFns = [];
15380
15221
  ;
15381
15222
  var Infos_component = normalizeComponent(
15382
15223
  components_Infosvue_type_script_lang_js_,
15383
- Infosvue_type_template_id_c15b4388_render,
15384
- Infosvue_type_template_id_c15b4388_staticRenderFns,
15224
+ Infosvue_type_template_id_441ca26a_render,
15225
+ Infosvue_type_template_id_441ca26a_staticRenderFns,
15385
15226
  false,
15386
15227
  null,
15387
15228
  null,
@@ -15390,12 +15231,12 @@ var Infos_component = normalizeComponent(
15390
15231
  )
15391
15232
 
15392
15233
  /* harmony default export */ var Infos = (Infos_component.exports);
15393
- ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/VideoProgress.vue?vue&type=template&id=816cceb8&scoped=true&
15394
- var VideoProgressvue_type_template_id_816cceb8_scoped_true_render = function render() {
15234
+ ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/VideoProgress.vue?vue&type=template&id=7fe6f244&scoped=true&
15235
+ var VideoProgressvue_type_template_id_7fe6f244_scoped_true_render = function render() {
15395
15236
  var _vm = this,
15396
15237
  _c = _vm._self._c;
15397
15238
  return _c('div', [_c('div', {
15398
- staticClass: "row",
15239
+ staticClass: "visualization-row",
15399
15240
  attrs: {
15400
15241
  "id": "progress"
15401
15242
  },
@@ -15407,10 +15248,10 @@ var VideoProgressvue_type_template_id_816cceb8_scoped_true_render = function ren
15407
15248
  }, [_vm._v(" " + _vm._s(_vm.convertToAudienceTime(_vm.videoTime)) + " ")]), _c('span', {
15408
15249
  staticClass: "progressBar"
15409
15250
  })]), _c('hr', {
15410
- staticClass: "divider"
15251
+ staticClass: "visualization-divider"
15411
15252
  })]);
15412
15253
  };
15413
- var VideoProgressvue_type_template_id_816cceb8_scoped_true_staticRenderFns = [];
15254
+ var VideoProgressvue_type_template_id_7fe6f244_scoped_true_staticRenderFns = [];
15414
15255
 
15415
15256
  ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/VideoProgress.vue?vue&type=script&lang=js&
15416
15257
  /* harmony default export */ var VideoProgressvue_type_script_lang_js_ = ({
@@ -15502,10 +15343,10 @@ var VideoProgressvue_type_template_id_816cceb8_scoped_true_staticRenderFns = [];
15502
15343
  });
15503
15344
  ;// CONCATENATED MODULE: ./src/components/VideoProgress.vue?vue&type=script&lang=js&
15504
15345
  /* harmony default export */ var components_VideoProgressvue_type_script_lang_js_ = (VideoProgressvue_type_script_lang_js_);
15505
- ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-12.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-12.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-12.use[2]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/VideoProgress.vue?vue&type=style&index=0&id=816cceb8&prod&scoped=true&lang=css&
15346
+ ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-12.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-12.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-12.use[2]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/VideoProgress.vue?vue&type=style&index=0&id=7fe6f244&prod&scoped=true&lang=css&
15506
15347
  // extracted by mini-css-extract-plugin
15507
15348
 
15508
- ;// CONCATENATED MODULE: ./src/components/VideoProgress.vue?vue&type=style&index=0&id=816cceb8&prod&scoped=true&lang=css&
15349
+ ;// CONCATENATED MODULE: ./src/components/VideoProgress.vue?vue&type=style&index=0&id=7fe6f244&prod&scoped=true&lang=css&
15509
15350
 
15510
15351
  ;// CONCATENATED MODULE: ./src/components/VideoProgress.vue
15511
15352
 
@@ -15518,37 +15359,37 @@ var VideoProgressvue_type_template_id_816cceb8_scoped_true_staticRenderFns = [];
15518
15359
 
15519
15360
  var VideoProgress_component = normalizeComponent(
15520
15361
  components_VideoProgressvue_type_script_lang_js_,
15521
- VideoProgressvue_type_template_id_816cceb8_scoped_true_render,
15522
- VideoProgressvue_type_template_id_816cceb8_scoped_true_staticRenderFns,
15362
+ VideoProgressvue_type_template_id_7fe6f244_scoped_true_render,
15363
+ VideoProgressvue_type_template_id_7fe6f244_scoped_true_staticRenderFns,
15523
15364
  false,
15524
15365
  null,
15525
- "816cceb8",
15366
+ "7fe6f244",
15526
15367
  null
15527
15368
 
15528
15369
  )
15529
15370
 
15530
15371
  /* harmony default export */ var VideoProgress = (VideoProgress_component.exports);
15531
- ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/Settings.vue?vue&type=template&id=3f38ed2c&scoped=true&
15532
- var Settingsvue_type_template_id_3f38ed2c_scoped_true_render = function render() {
15372
+ ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/Settings.vue?vue&type=template&id=ace6f9c6&scoped=true&
15373
+ var Settingsvue_type_template_id_ace6f9c6_scoped_true_render = function render() {
15533
15374
  var _vm = this,
15534
15375
  _c = _vm._self._c;
15535
15376
  return _c('div', [_c('dialog', {
15536
15377
  ref: "frames"
15537
15378
  }, [_c('div', {
15538
- staticClass: "row",
15379
+ staticClass: "visualization-row",
15539
15380
  staticStyle: {
15540
15381
  "padding": "12px",
15541
15382
  "font-weight": "bold"
15542
15383
  }
15543
15384
  }, [_vm._v(" Formato da grelha ")]), _c('div', {
15544
- staticClass: "row",
15385
+ staticClass: "visualization-row",
15545
15386
  staticStyle: {
15546
15387
  "justify-content": "center"
15547
15388
  }
15548
15389
  }, _vm._l(_vm.items, function (item, index) {
15549
15390
  return _c('div', {
15550
15391
  key: index,
15551
- staticClass: "col",
15392
+ staticClass: "visualization-col",
15552
15393
  staticStyle: {
15553
15394
  "min-width": "200px",
15554
15395
  "max-width": "200px"
@@ -15564,9 +15405,9 @@ var Settingsvue_type_template_id_3f38ed2c_scoped_true_render = function render()
15564
15405
  }
15565
15406
  })]);
15566
15407
  }), 0), _c('div', {
15567
- staticClass: "divider"
15408
+ staticClass: "visualization-divider"
15568
15409
  }), _c('div', {
15569
- staticClass: "row"
15410
+ staticClass: "visualization-row"
15570
15411
  }, [_c('button', {
15571
15412
  on: {
15572
15413
  "click": function ($event) {
@@ -15576,13 +15417,13 @@ var Settingsvue_type_template_id_3f38ed2c_scoped_true_render = function render()
15576
15417
  }, [_vm._v("Ok")])])]), _c('dialog', {
15577
15418
  ref: "secondsPerFrame"
15578
15419
  }, [_c('div', {
15579
- staticClass: "row",
15420
+ staticClass: "visualization-row",
15580
15421
  staticStyle: {
15581
15422
  "padding": "12px",
15582
15423
  "font-weight": "bold"
15583
15424
  }
15584
15425
  }, [_vm._v(" Segundos por Imagem ")]), _c('div', {
15585
- staticClass: "row"
15426
+ staticClass: "visualization-row"
15586
15427
  }, [_c('input', {
15587
15428
  directives: [{
15588
15429
  name: "model",
@@ -15606,9 +15447,9 @@ var Settingsvue_type_template_id_3f38ed2c_scoped_true_render = function render()
15606
15447
  }
15607
15448
  }
15608
15449
  })]), _c('div', {
15609
- staticClass: "divider"
15450
+ staticClass: "visualization-divider"
15610
15451
  }), _c('div', {
15611
- staticClass: "row"
15452
+ staticClass: "visualization-row"
15612
15453
  }, [_c('button', {
15613
15454
  on: {
15614
15455
  "click": function ($event) {
@@ -15618,13 +15459,13 @@ var Settingsvue_type_template_id_3f38ed2c_scoped_true_render = function render()
15618
15459
  }, [_vm._v("Ok")])])]), _c('dialog', {
15619
15460
  ref: "goTo"
15620
15461
  }, [_c('div', {
15621
- staticClass: "row",
15462
+ staticClass: "visualization-row",
15622
15463
  staticStyle: {
15623
15464
  "padding": "12px",
15624
15465
  "font-weight": "bold"
15625
15466
  }
15626
15467
  }, [_vm._v(" Saltar para: ")]), _c('div', {
15627
- staticClass: "row"
15468
+ staticClass: "visualization-row"
15628
15469
  }, [_c('input', {
15629
15470
  directives: [{
15630
15471
  name: "model",
@@ -15651,9 +15492,9 @@ var Settingsvue_type_template_id_3f38ed2c_scoped_true_render = function render()
15651
15492
  }
15652
15493
  }
15653
15494
  })]), _c('div', {
15654
- staticClass: "divider"
15495
+ staticClass: "visualization-divider"
15655
15496
  }), _c('div', {
15656
- staticClass: "row"
15497
+ staticClass: "visualization-row"
15657
15498
  }, [_c('button', {
15658
15499
  on: {
15659
15500
  "click": () => {
@@ -15675,13 +15516,13 @@ var Settingsvue_type_template_id_3f38ed2c_scoped_true_render = function render()
15675
15516
  }), _c('dialog', {
15676
15517
  ref: "playbackRate"
15677
15518
  }, [_c('div', {
15678
- staticClass: "row",
15519
+ staticClass: "visualization-row",
15679
15520
  staticStyle: {
15680
15521
  "padding": "12px",
15681
15522
  "font-weight": "bold"
15682
15523
  }
15683
15524
  }, [_vm._v(" Velocidade de Reprodução ")]), _c('div', {
15684
- staticClass: "row"
15525
+ staticClass: "visualization-row"
15685
15526
  }, [_c('input', {
15686
15527
  directives: [{
15687
15528
  name: "model",
@@ -15705,9 +15546,9 @@ var Settingsvue_type_template_id_3f38ed2c_scoped_true_render = function render()
15705
15546
  }
15706
15547
  }
15707
15548
  })]), _c('div', {
15708
- staticClass: "divider"
15549
+ staticClass: "visualization-divider"
15709
15550
  }), _c('div', {
15710
- staticClass: "row"
15551
+ staticClass: "visualization-row"
15711
15552
  }, [_c('button', {
15712
15553
  on: {
15713
15554
  "click": function ($event) {
@@ -15716,9 +15557,9 @@ var Settingsvue_type_template_id_3f38ed2c_scoped_true_render = function render()
15716
15557
  }
15717
15558
  }, [_vm._v("Ok")])])])], 1);
15718
15559
  };
15719
- var Settingsvue_type_template_id_3f38ed2c_scoped_true_staticRenderFns = [];
15560
+ var Settingsvue_type_template_id_ace6f9c6_scoped_true_staticRenderFns = [];
15720
15561
 
15721
- ;// CONCATENATED MODULE: ./src/components/Settings.vue?vue&type=template&id=3f38ed2c&scoped=true&
15562
+ ;// CONCATENATED MODULE: ./src/components/Settings.vue?vue&type=template&id=ace6f9c6&scoped=true&
15722
15563
 
15723
15564
  ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/Settings.vue?vue&type=script&lang=js&
15724
15565
  /* harmony default export */ var Settingsvue_type_script_lang_js_ = ({
@@ -15861,10 +15702,10 @@ var Settingsvue_type_template_id_3f38ed2c_scoped_true_staticRenderFns = [];
15861
15702
  });
15862
15703
  ;// CONCATENATED MODULE: ./src/components/Settings.vue?vue&type=script&lang=js&
15863
15704
  /* harmony default export */ var components_Settingsvue_type_script_lang_js_ = (Settingsvue_type_script_lang_js_);
15864
- ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-12.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-12.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-12.use[2]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/Settings.vue?vue&type=style&index=0&id=3f38ed2c&prod&scoped=true&lang=css&
15705
+ ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-12.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-12.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-12.use[2]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/Settings.vue?vue&type=style&index=0&id=ace6f9c6&prod&scoped=true&lang=css&
15865
15706
  // extracted by mini-css-extract-plugin
15866
15707
 
15867
- ;// CONCATENATED MODULE: ./src/components/Settings.vue?vue&type=style&index=0&id=3f38ed2c&prod&scoped=true&lang=css&
15708
+ ;// CONCATENATED MODULE: ./src/components/Settings.vue?vue&type=style&index=0&id=ace6f9c6&prod&scoped=true&lang=css&
15868
15709
 
15869
15710
  ;// CONCATENATED MODULE: ./src/components/Settings.vue
15870
15711
 
@@ -15877,11 +15718,11 @@ var Settingsvue_type_template_id_3f38ed2c_scoped_true_staticRenderFns = [];
15877
15718
 
15878
15719
  var Settings_component = normalizeComponent(
15879
15720
  components_Settingsvue_type_script_lang_js_,
15880
- Settingsvue_type_template_id_3f38ed2c_scoped_true_render,
15881
- Settingsvue_type_template_id_3f38ed2c_scoped_true_staticRenderFns,
15721
+ Settingsvue_type_template_id_ace6f9c6_scoped_true_render,
15722
+ Settingsvue_type_template_id_ace6f9c6_scoped_true_staticRenderFns,
15882
15723
  false,
15883
15724
  null,
15884
- "3f38ed2c",
15725
+ "ace6f9c6",
15885
15726
  null
15886
15727
 
15887
15728
  )
@@ -16586,10 +16427,10 @@ const Positions = Object.freeze({
16586
16427
  });
16587
16428
  ;// CONCATENATED MODULE: ./src/Visualization.vue?vue&type=script&lang=js&
16588
16429
  /* harmony default export */ var src_Visualizationvue_type_script_lang_js_ = (Visualizationvue_type_script_lang_js_);
16589
- ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-12.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-12.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-12.use[2]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Visualization.vue?vue&type=style&index=0&id=301b4a1c&prod&scoped=true&lang=css&
16430
+ ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-12.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-12.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-12.use[2]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Visualization.vue?vue&type=style&index=0&id=50ffcc14&prod&scoped=true&lang=css&
16590
16431
  // extracted by mini-css-extract-plugin
16591
16432
 
16592
- ;// CONCATENATED MODULE: ./src/Visualization.vue?vue&type=style&index=0&id=301b4a1c&prod&scoped=true&lang=css&
16433
+ ;// CONCATENATED MODULE: ./src/Visualization.vue?vue&type=style&index=0&id=50ffcc14&prod&scoped=true&lang=css&
16593
16434
 
16594
16435
  ;// CONCATENATED MODULE: ./src/Visualization.vue
16595
16436
 
@@ -16606,7 +16447,7 @@ var Visualization_component = normalizeComponent(
16606
16447
  staticRenderFns,
16607
16448
  false,
16608
16449
  null,
16609
- "301b4a1c",
16450
+ "50ffcc14",
16610
16451
  null
16611
16452
 
16612
16453
  )
@@ -25055,2739 +24896,68 @@ var v_mask_esm_plugin = function (Vue) {
25055
24896
  Vue.filter('VMask', createFilter(options));
25056
24897
  };
25057
24898
 
25058
- ;// CONCATENATED MODULE: ./node_modules/i18next/dist/esm/i18next.js
25059
- const consoleLogger = {
25060
- type: 'logger',
25061
- log(args) {
25062
- this.output('log', args);
25063
- },
25064
- warn(args) {
25065
- this.output('warn', args);
25066
- },
25067
- error(args) {
25068
- this.output('error', args);
25069
- },
25070
- output(type, args) {
25071
- if (console && console[type]) console[type].apply(console, args);
25072
- }
25073
- };
25074
- class Logger {
25075
- constructor(concreteLogger) {
25076
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
25077
- this.init(concreteLogger, options);
25078
- }
25079
- init(concreteLogger) {
25080
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
25081
- this.prefix = options.prefix || 'i18next:';
25082
- this.logger = concreteLogger || consoleLogger;
25083
- this.options = options;
25084
- this.debug = options.debug;
25085
- }
25086
- log() {
25087
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
25088
- args[_key] = arguments[_key];
25089
- }
25090
- return this.forward(args, 'log', '', true);
25091
- }
25092
- warn() {
25093
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
25094
- args[_key2] = arguments[_key2];
25095
- }
25096
- return this.forward(args, 'warn', '', true);
25097
- }
25098
- error() {
25099
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
25100
- args[_key3] = arguments[_key3];
25101
- }
25102
- return this.forward(args, 'error', '');
25103
- }
25104
- deprecate() {
25105
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
25106
- args[_key4] = arguments[_key4];
25107
- }
25108
- return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
25109
- }
25110
- forward(args, lvl, prefix, debugOnly) {
25111
- if (debugOnly && !this.debug) return null;
25112
- if (typeof args[0] === 'string') args[0] = `${prefix}${this.prefix} ${args[0]}`;
25113
- return this.logger[lvl](args);
25114
- }
25115
- create(moduleName) {
25116
- return new Logger(this.logger, {
25117
- ...{
25118
- prefix: `${this.prefix}:${moduleName}:`
25119
- },
25120
- ...this.options
25121
- });
25122
- }
25123
- clone(options) {
25124
- options = options || this.options;
25125
- options.prefix = options.prefix || this.prefix;
25126
- return new Logger(this.logger, options);
25127
- }
25128
- }
25129
- var baseLogger = new Logger();
25130
- class EventEmitter {
25131
- constructor() {
25132
- this.observers = {};
25133
- }
25134
- on(events, listener) {
25135
- events.split(' ').forEach(event => {
25136
- this.observers[event] = this.observers[event] || [];
25137
- this.observers[event].push(listener);
25138
- });
25139
- return this;
25140
- }
25141
- off(event, listener) {
25142
- if (!this.observers[event]) return;
25143
- if (!listener) {
25144
- delete this.observers[event];
24899
+ ;// CONCATENATED MODULE: ./src/index.js
24900
+
24901
+
24902
+
24903
+
24904
+
24905
+
24906
+
24907
+ // import i18next from 'i18next'
24908
+ // import I18NextVue from 'i18next-vue'
24909
+ // import LanguageDetector from 'i18next-browser-languagedetector'
24910
+ // import en from './assets/locales/en-GB'
24911
+ // import pt from './assets/locales/pt-PT'
24912
+
24913
+ /* harmony default export */ var src_0 = ({
24914
+ install(Vue) {
24915
+ let settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
24916
+ if (!settings.client || !settings.base_url || !settings.theme?.primary) {
24917
+ console.error('Visualization: Missing required settings');
25145
24918
  return;
25146
24919
  }
25147
- this.observers[event] = this.observers[event].filter(l => l !== listener);
25148
- }
25149
- emit(event) {
25150
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
25151
- args[_key - 1] = arguments[_key];
25152
- }
25153
- if (this.observers[event]) {
25154
- const cloned = [].concat(this.observers[event]);
25155
- cloned.forEach(observer => {
25156
- observer(...args);
25157
- });
25158
- }
25159
- if (this.observers['*']) {
25160
- const cloned = [].concat(this.observers['*']);
25161
- cloned.forEach(observer => {
25162
- observer.apply(observer, [event, ...args]);
25163
- });
25164
- }
25165
- }
25166
- }
25167
- function defer() {
25168
- let res;
25169
- let rej;
25170
- const promise = new Promise((resolve, reject) => {
25171
- res = resolve;
25172
- rej = reject;
25173
- });
25174
- promise.resolve = res;
25175
- promise.reject = rej;
25176
- return promise;
25177
- }
25178
- function makeString(object) {
25179
- if (object == null) return '';
25180
- return '' + object;
25181
- }
25182
- function copy(a, s, t) {
25183
- a.forEach(m => {
25184
- if (s[m]) t[m] = s[m];
25185
- });
25186
- }
25187
- function getLastOfPath(object, path, Empty) {
25188
- function cleanKey(key) {
25189
- return key && key.indexOf('###') > -1 ? key.replace(/###/g, '.') : key;
25190
- }
25191
- function canNotTraverseDeeper() {
25192
- return !object || typeof object === 'string';
25193
- }
25194
- const stack = typeof path !== 'string' ? [].concat(path) : path.split('.');
25195
- while (stack.length > 1) {
25196
- if (canNotTraverseDeeper()) return {};
25197
- const key = cleanKey(stack.shift());
25198
- if (!object[key] && Empty) object[key] = new Empty();
25199
- if (Object.prototype.hasOwnProperty.call(object, key)) {
25200
- object = object[key];
25201
- } else {
25202
- object = {};
25203
- }
25204
- }
25205
- if (canNotTraverseDeeper()) return {};
25206
- return {
25207
- obj: object,
25208
- k: cleanKey(stack.shift())
25209
- };
25210
- }
25211
- function setPath(object, path, newValue) {
25212
- const {
25213
- obj,
25214
- k
25215
- } = getLastOfPath(object, path, Object);
25216
- obj[k] = newValue;
25217
- }
25218
- function pushPath(object, path, newValue, concat) {
25219
- const {
25220
- obj,
25221
- k
25222
- } = getLastOfPath(object, path, Object);
25223
- obj[k] = obj[k] || [];
25224
- if (concat) obj[k] = obj[k].concat(newValue);
25225
- if (!concat) obj[k].push(newValue);
25226
- }
25227
- function getPath(object, path) {
25228
- const {
25229
- obj,
25230
- k
25231
- } = getLastOfPath(object, path);
25232
- if (!obj) return undefined;
25233
- return obj[k];
25234
- }
25235
- function getPathWithDefaults(data, defaultData, key) {
25236
- const value = getPath(data, key);
25237
- if (value !== undefined) {
25238
- return value;
25239
- }
25240
- return getPath(defaultData, key);
25241
- }
25242
- function deepExtend(target, source, overwrite) {
25243
- for (const prop in source) {
25244
- if (prop !== '__proto__' && prop !== 'constructor') {
25245
- if (prop in target) {
25246
- if (typeof target[prop] === 'string' || target[prop] instanceof String || typeof source[prop] === 'string' || source[prop] instanceof String) {
25247
- if (overwrite) target[prop] = source[prop];
25248
- } else {
25249
- deepExtend(target[prop], source[prop], overwrite);
25250
- }
25251
- } else {
25252
- target[prop] = source[prop];
25253
- }
25254
- }
25255
- }
25256
- return target;
25257
- }
25258
- function regexEscape(str) {
25259
- return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
25260
- }
25261
- var _entityMap = {
25262
- '&': '&amp;',
25263
- '<': '&lt;',
25264
- '>': '&gt;',
25265
- '"': '&quot;',
25266
- "'": '&#39;',
25267
- '/': '&#x2F;'
25268
- };
25269
- function i18next_escape(data) {
25270
- if (typeof data === 'string') {
25271
- return data.replace(/[&<>"'\/]/g, s => _entityMap[s]);
25272
- }
25273
- return data;
25274
- }
25275
- const chars = [' ', ',', '?', '!', ';'];
25276
- function looksLikeObjectPath(key, nsSeparator, keySeparator) {
25277
- nsSeparator = nsSeparator || '';
25278
- keySeparator = keySeparator || '';
25279
- const possibleChars = chars.filter(c => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
25280
- if (possibleChars.length === 0) return true;
25281
- const r = new RegExp(`(${possibleChars.map(c => c === '?' ? '\\?' : c).join('|')})`);
25282
- let matched = !r.test(key);
25283
- if (!matched) {
25284
- const ki = key.indexOf(keySeparator);
25285
- if (ki > 0 && !r.test(key.substring(0, ki))) {
25286
- matched = true;
25287
- }
25288
- }
25289
- return matched;
25290
- }
25291
- function deepFind(obj, path) {
25292
- let keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
25293
- if (!obj) return undefined;
25294
- if (obj[path]) return obj[path];
25295
- const paths = path.split(keySeparator);
25296
- let current = obj;
25297
- for (let i = 0; i < paths.length; ++i) {
25298
- if (!current) return undefined;
25299
- if (typeof current[paths[i]] === 'string' && i + 1 < paths.length) {
25300
- return undefined;
25301
- }
25302
- if (current[paths[i]] === undefined) {
25303
- let j = 2;
25304
- let p = paths.slice(i, i + j).join(keySeparator);
25305
- let mix = current[p];
25306
- while (mix === undefined && paths.length > i + j) {
25307
- j++;
25308
- p = paths.slice(i, i + j).join(keySeparator);
25309
- mix = current[p];
25310
- }
25311
- if (mix === undefined) return undefined;
25312
- if (mix === null) return null;
25313
- if (path.endsWith(p)) {
25314
- if (typeof mix === 'string') return mix;
25315
- if (p && typeof mix[p] === 'string') return mix[p];
25316
- }
25317
- const joinedPath = paths.slice(i + j).join(keySeparator);
25318
- if (joinedPath) return deepFind(mix, joinedPath, keySeparator);
25319
- return undefined;
25320
- }
25321
- current = current[paths[i]];
25322
- }
25323
- return current;
25324
- }
25325
- function getCleanedCode(code) {
25326
- if (code && code.indexOf('_') > 0) return code.replace('_', '-');
25327
- return code;
25328
- }
25329
- class ResourceStore extends EventEmitter {
25330
- constructor(data) {
25331
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
25332
- ns: ['translation'],
25333
- defaultNS: 'translation'
25334
- };
25335
- super();
25336
- this.data = data || {};
25337
- this.options = options;
25338
- if (this.options.keySeparator === undefined) {
25339
- this.options.keySeparator = '.';
25340
- }
25341
- if (this.options.ignoreJSONStructure === undefined) {
25342
- this.options.ignoreJSONStructure = true;
25343
- }
25344
- }
25345
- addNamespaces(ns) {
25346
- if (this.options.ns.indexOf(ns) < 0) {
25347
- this.options.ns.push(ns);
25348
- }
25349
- }
25350
- removeNamespaces(ns) {
25351
- const index = this.options.ns.indexOf(ns);
25352
- if (index > -1) {
25353
- this.options.ns.splice(index, 1);
25354
- }
25355
- }
25356
- getResource(lng, ns, key) {
25357
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
25358
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
25359
- const ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
25360
- let path = [lng, ns];
25361
- if (key && typeof key !== 'string') path = path.concat(key);
25362
- if (key && typeof key === 'string') path = path.concat(keySeparator ? key.split(keySeparator) : key);
25363
- if (lng.indexOf('.') > -1) {
25364
- path = lng.split('.');
25365
- }
25366
- const result = getPath(this.data, path);
25367
- if (result || !ignoreJSONStructure || typeof key !== 'string') return result;
25368
- return deepFind(this.data && this.data[lng] && this.data[lng][ns], key, keySeparator);
25369
- }
25370
- addResource(lng, ns, key, value) {
25371
- let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
25372
- silent: false
25373
- };
25374
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
25375
- let path = [lng, ns];
25376
- if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
25377
- if (lng.indexOf('.') > -1) {
25378
- path = lng.split('.');
25379
- value = ns;
25380
- ns = path[1];
25381
- }
25382
- this.addNamespaces(ns);
25383
- setPath(this.data, path, value);
25384
- if (!options.silent) this.emit('added', lng, ns, key, value);
25385
- }
25386
- addResources(lng, ns, resources) {
25387
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
25388
- silent: false
25389
- };
25390
- for (const m in resources) {
25391
- if (typeof resources[m] === 'string' || Object.prototype.toString.apply(resources[m]) === '[object Array]') this.addResource(lng, ns, m, resources[m], {
25392
- silent: true
25393
- });
25394
- }
25395
- if (!options.silent) this.emit('added', lng, ns, resources);
25396
- }
25397
- addResourceBundle(lng, ns, resources, deep, overwrite) {
25398
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
25399
- silent: false
25400
- };
25401
- let path = [lng, ns];
25402
- if (lng.indexOf('.') > -1) {
25403
- path = lng.split('.');
25404
- deep = resources;
25405
- resources = ns;
25406
- ns = path[1];
25407
- }
25408
- this.addNamespaces(ns);
25409
- let pack = getPath(this.data, path) || {};
25410
- if (deep) {
25411
- deepExtend(pack, resources, overwrite);
25412
- } else {
25413
- pack = {
25414
- ...pack,
25415
- ...resources
25416
- };
25417
- }
25418
- setPath(this.data, path, pack);
25419
- if (!options.silent) this.emit('added', lng, ns, resources);
25420
- }
25421
- removeResourceBundle(lng, ns) {
25422
- if (this.hasResourceBundle(lng, ns)) {
25423
- delete this.data[lng][ns];
25424
- }
25425
- this.removeNamespaces(ns);
25426
- this.emit('removed', lng, ns);
25427
- }
25428
- hasResourceBundle(lng, ns) {
25429
- return this.getResource(lng, ns) !== undefined;
25430
- }
25431
- getResourceBundle(lng, ns) {
25432
- if (!ns) ns = this.options.defaultNS;
25433
- if (this.options.compatibilityAPI === 'v1') return {
25434
- ...{},
25435
- ...this.getResource(lng, ns)
25436
- };
25437
- return this.getResource(lng, ns);
25438
- }
25439
- getDataByLanguage(lng) {
25440
- return this.data[lng];
25441
- }
25442
- hasLanguageSomeTranslations(lng) {
25443
- const data = this.getDataByLanguage(lng);
25444
- const n = data && Object.keys(data) || [];
25445
- return !!n.find(v => data[v] && Object.keys(data[v]).length > 0);
25446
- }
25447
- toJSON() {
25448
- return this.data;
25449
- }
25450
- }
25451
- var postProcessor = {
25452
- processors: {},
25453
- addPostProcessor(module) {
25454
- this.processors[module.name] = module;
25455
- },
25456
- handle(processors, value, key, options, translator) {
25457
- processors.forEach(processor => {
25458
- if (this.processors[processor]) value = this.processors[processor].process(value, key, options, translator);
25459
- });
25460
- return value;
25461
- }
25462
- };
25463
- const checkedLoadedFor = {};
25464
- class Translator extends EventEmitter {
25465
- constructor(services) {
25466
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
25467
- super();
25468
- copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, this);
25469
- this.options = options;
25470
- if (this.options.keySeparator === undefined) {
25471
- this.options.keySeparator = '.';
25472
- }
25473
- this.logger = baseLogger.create('translator');
25474
- }
25475
- changeLanguage(lng) {
25476
- if (lng) this.language = lng;
25477
- }
25478
- exists(key) {
25479
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
25480
- interpolation: {}
25481
- };
25482
- if (key === undefined || key === null) {
25483
- return false;
25484
- }
25485
- const resolved = this.resolve(key, options);
25486
- return resolved && resolved.res !== undefined;
25487
- }
25488
- extractFromKey(key, options) {
25489
- let nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;
25490
- if (nsSeparator === undefined) nsSeparator = ':';
25491
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
25492
- let namespaces = options.ns || this.options.defaultNS || [];
25493
- const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
25494
- const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
25495
- if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
25496
- const m = key.match(this.interpolator.nestingRegexp);
25497
- if (m && m.length > 0) {
25498
- return {
25499
- key,
25500
- namespaces
25501
- };
25502
- }
25503
- const parts = key.split(nsSeparator);
25504
- if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
25505
- key = parts.join(keySeparator);
25506
- }
25507
- if (typeof namespaces === 'string') namespaces = [namespaces];
25508
- return {
25509
- key,
25510
- namespaces
25511
- };
25512
- }
25513
- translate(keys, options, lastKey) {
25514
- if (typeof options !== 'object' && this.options.overloadTranslationOptionHandler) {
25515
- options = this.options.overloadTranslationOptionHandler(arguments);
25516
- }
25517
- if (typeof options === 'object') options = {
25518
- ...options
25519
- };
25520
- if (!options) options = {};
25521
- if (keys === undefined || keys === null) return '';
25522
- if (!Array.isArray(keys)) keys = [String(keys)];
25523
- const returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;
25524
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
25525
- const {
25526
- key,
25527
- namespaces
25528
- } = this.extractFromKey(keys[keys.length - 1], options);
25529
- const namespace = namespaces[namespaces.length - 1];
25530
- const lng = options.lng || this.language;
25531
- const appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
25532
- if (lng && lng.toLowerCase() === 'cimode') {
25533
- if (appendNamespaceToCIMode) {
25534
- const nsSeparator = options.nsSeparator || this.options.nsSeparator;
25535
- if (returnDetails) {
25536
- return {
25537
- res: `${namespace}${nsSeparator}${key}`,
25538
- usedKey: key,
25539
- exactUsedKey: key,
25540
- usedLng: lng,
25541
- usedNS: namespace,
25542
- usedParams: this.getUsedParamsDetails(options)
25543
- };
25544
- }
25545
- return `${namespace}${nsSeparator}${key}`;
25546
- }
25547
- if (returnDetails) {
25548
- return {
25549
- res: key,
25550
- usedKey: key,
25551
- exactUsedKey: key,
25552
- usedLng: lng,
25553
- usedNS: namespace,
25554
- usedParams: this.getUsedParamsDetails(options)
25555
- };
25556
- }
25557
- return key;
25558
- }
25559
- const resolved = this.resolve(keys, options);
25560
- let res = resolved && resolved.res;
25561
- const resUsedKey = resolved && resolved.usedKey || key;
25562
- const resExactUsedKey = resolved && resolved.exactUsedKey || key;
25563
- const resType = Object.prototype.toString.apply(res);
25564
- const noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
25565
- const joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
25566
- const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
25567
- const handleAsObject = typeof res !== 'string' && typeof res !== 'boolean' && typeof res !== 'number';
25568
- if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(typeof joinArrays === 'string' && resType === '[object Array]')) {
25569
- if (!options.returnObjects && !this.options.returnObjects) {
25570
- if (!this.options.returnedObjectHandler) {
25571
- this.logger.warn('accessing an object - but returnObjects options is not enabled!');
25572
- }
25573
- const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, {
25574
- ...options,
25575
- ns: namespaces
25576
- }) : `key '${key} (${this.language})' returned an object instead of string.`;
25577
- if (returnDetails) {
25578
- resolved.res = r;
25579
- resolved.usedParams = this.getUsedParamsDetails(options);
25580
- return resolved;
25581
- }
25582
- return r;
25583
- }
25584
- if (keySeparator) {
25585
- const resTypeIsArray = resType === '[object Array]';
25586
- const copy = resTypeIsArray ? [] : {};
25587
- const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
25588
- for (const m in res) {
25589
- if (Object.prototype.hasOwnProperty.call(res, m)) {
25590
- const deepKey = `${newKeyToUse}${keySeparator}${m}`;
25591
- copy[m] = this.translate(deepKey, {
25592
- ...options,
25593
- ...{
25594
- joinArrays: false,
25595
- ns: namespaces
25596
- }
25597
- });
25598
- if (copy[m] === deepKey) copy[m] = res[m];
25599
- }
25600
- }
25601
- res = copy;
25602
- }
25603
- } else if (handleAsObjectInI18nFormat && typeof joinArrays === 'string' && resType === '[object Array]') {
25604
- res = res.join(joinArrays);
25605
- if (res) res = this.extendTranslation(res, keys, options, lastKey);
25606
- } else {
25607
- let usedDefault = false;
25608
- let usedKey = false;
25609
- const needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
25610
- const hasDefaultValue = Translator.hasDefaultValue(options);
25611
- const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
25612
- const defaultValueSuffixOrdinalFallback = options.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, {
25613
- ordinal: false
25614
- }) : '';
25615
- const defaultValue = options[`defaultValue${defaultValueSuffix}`] || options[`defaultValue${defaultValueSuffixOrdinalFallback}`] || options.defaultValue;
25616
- if (!this.isValidLookup(res) && hasDefaultValue) {
25617
- usedDefault = true;
25618
- res = defaultValue;
25619
- }
25620
- if (!this.isValidLookup(res)) {
25621
- usedKey = true;
25622
- res = key;
25623
- }
25624
- const missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
25625
- const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
25626
- const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
25627
- if (usedKey || usedDefault || updateMissing) {
25628
- this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
25629
- if (keySeparator) {
25630
- const fk = this.resolve(key, {
25631
- ...options,
25632
- keySeparator: false
25633
- });
25634
- 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.');
25635
- }
25636
- let lngs = [];
25637
- const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
25638
- if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
25639
- for (let i = 0; i < fallbackLngs.length; i++) {
25640
- lngs.push(fallbackLngs[i]);
25641
- }
25642
- } else if (this.options.saveMissingTo === 'all') {
25643
- lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
25644
- } else {
25645
- lngs.push(options.lng || this.language);
25646
- }
25647
- const send = (l, k, specificDefaultValue) => {
25648
- const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
25649
- if (this.options.missingKeyHandler) {
25650
- this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
25651
- } else if (this.backendConnector && this.backendConnector.saveMissing) {
25652
- this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
25653
- }
25654
- this.emit('missingKey', l, namespace, k, res);
25655
- };
25656
- if (this.options.saveMissing) {
25657
- if (this.options.saveMissingPlurals && needsPluralHandling) {
25658
- lngs.forEach(language => {
25659
- this.pluralResolver.getSuffixes(language, options).forEach(suffix => {
25660
- send([language], key + suffix, options[`defaultValue${suffix}`] || defaultValue);
25661
- });
25662
- });
25663
- } else {
25664
- send(lngs, key, defaultValue);
25665
- }
25666
- }
25667
- }
25668
- res = this.extendTranslation(res, keys, options, resolved, lastKey);
25669
- if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}:${key}`;
25670
- if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
25671
- if (this.options.compatibilityAPI !== 'v1') {
25672
- res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : undefined);
25673
- } else {
25674
- res = this.options.parseMissingKeyHandler(res);
25675
- }
25676
- }
25677
- }
25678
- if (returnDetails) {
25679
- resolved.res = res;
25680
- resolved.usedParams = this.getUsedParamsDetails(options);
25681
- return resolved;
24920
+ if (this.installed) {
24921
+ return;
25682
24922
  }
25683
- return res;
25684
- }
25685
- extendTranslation(res, key, options, resolved, lastKey) {
25686
- var _this = this;
25687
- if (this.i18nFormat && this.i18nFormat.parse) {
25688
- res = this.i18nFormat.parse(res, {
25689
- ...this.options.interpolation.defaultVariables,
25690
- ...options
25691
- }, options.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
25692
- resolved
25693
- });
25694
- } else if (!options.skipInterpolation) {
25695
- if (options.interpolation) this.interpolator.init({
25696
- ...options,
25697
- ...{
25698
- interpolation: {
25699
- ...this.options.interpolation,
25700
- ...options.interpolation
25701
- }
25702
- }
25703
- });
25704
- const skipOnVariables = typeof res === 'string' && (options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
25705
- let nestBef;
25706
- if (skipOnVariables) {
25707
- const nb = res.match(this.interpolator.nestingRegexp);
25708
- nestBef = nb && nb.length;
25709
- }
25710
- let data = options.replace && typeof options.replace !== 'string' ? options.replace : options;
25711
- if (this.options.interpolation.defaultVariables) data = {
25712
- ...this.options.interpolation.defaultVariables,
25713
- ...data
25714
- };
25715
- res = this.interpolator.interpolate(res, data, options.lng || this.language, options);
25716
- if (skipOnVariables) {
25717
- const na = res.match(this.interpolator.nestingRegexp);
25718
- const nestAft = na && na.length;
25719
- if (nestBef < nestAft) options.nest = false;
25720
- }
25721
- if (!options.lng && this.options.compatibilityAPI !== 'v1' && resolved && resolved.res) options.lng = resolved.usedLng;
25722
- if (options.nest !== false) res = this.interpolator.nest(res, function () {
25723
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
25724
- args[_key] = arguments[_key];
25725
- }
25726
- if (lastKey && lastKey[0] === args[0] && !options.context) {
25727
- _this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
25728
- return null;
25729
- }
25730
- return _this.translate(...args, key);
25731
- }, options);
25732
- if (options.interpolation) this.interpolator.reset();
25733
- }
25734
- const postProcess = options.postProcess || this.options.postProcess;
25735
- const postProcessorNames = typeof postProcess === 'string' ? [postProcess] : postProcess;
25736
- if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
25737
- res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
25738
- i18nResolved: resolved,
25739
- ...options
25740
- } : options, this);
25741
- }
25742
- return res;
25743
- }
25744
- resolve(keys) {
25745
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
25746
- let found;
25747
- let usedKey;
25748
- let exactUsedKey;
25749
- let usedLng;
25750
- let usedNS;
25751
- if (typeof keys === 'string') keys = [keys];
25752
- keys.forEach(k => {
25753
- if (this.isValidLookup(found)) return;
25754
- const extracted = this.extractFromKey(k, options);
25755
- const key = extracted.key;
25756
- usedKey = key;
25757
- let namespaces = extracted.namespaces;
25758
- if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
25759
- const needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
25760
- const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && this.pluralResolver.shouldUseIntlApi();
25761
- const needsContextHandling = options.context !== undefined && (typeof options.context === 'string' || typeof options.context === 'number') && options.context !== '';
25762
- const codes = options.lngs ? options.lngs : this.languageUtils.toResolveHierarchy(options.lng || this.language, options.fallbackLng);
25763
- namespaces.forEach(ns => {
25764
- if (this.isValidLookup(found)) return;
25765
- usedNS = ns;
25766
- if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils && this.utils.hasLoadedNamespace && !this.utils.hasLoadedNamespace(usedNS)) {
25767
- checkedLoadedFor[`${codes[0]}-${ns}`] = true;
25768
- this.logger.warn(`key "${usedKey}" for languages "${codes.join(', ')}" won't get resolved as namespace "${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!!!');
25769
- }
25770
- codes.forEach(code => {
25771
- if (this.isValidLookup(found)) return;
25772
- usedLng = code;
25773
- const finalKeys = [key];
25774
- if (this.i18nFormat && this.i18nFormat.addLookupKeys) {
25775
- this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
25776
- } else {
25777
- let pluralSuffix;
25778
- if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, options.count, options);
25779
- const zeroSuffix = `${this.options.pluralSeparator}zero`;
25780
- const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
25781
- if (needsPluralHandling) {
25782
- finalKeys.push(key + pluralSuffix);
25783
- if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
25784
- finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
25785
- }
25786
- if (needsZeroSuffixLookup) {
25787
- finalKeys.push(key + zeroSuffix);
25788
- }
25789
- }
25790
- if (needsContextHandling) {
25791
- const contextKey = `${key}${this.options.contextSeparator}${options.context}`;
25792
- finalKeys.push(contextKey);
25793
- if (needsPluralHandling) {
25794
- finalKeys.push(contextKey + pluralSuffix);
25795
- if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
25796
- finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
25797
- }
25798
- if (needsZeroSuffixLookup) {
25799
- finalKeys.push(contextKey + zeroSuffix);
25800
- }
25801
- }
25802
- }
25803
- }
25804
- let possibleKey;
25805
- while (possibleKey = finalKeys.pop()) {
25806
- if (!this.isValidLookup(found)) {
25807
- exactUsedKey = possibleKey;
25808
- found = this.getResource(code, ns, possibleKey, options);
25809
- }
25810
- }
25811
- });
25812
- });
25813
- });
25814
- return {
25815
- res: found,
25816
- usedKey,
25817
- exactUsedKey,
25818
- usedLng,
25819
- usedNS
24923
+ this.installed = true;
24924
+
24925
+ // Vue.use(I18NextVue, { i18next })
24926
+
24927
+ // i18next.on('initialized', () => {
24928
+ Vue.use(v_tooltip_esm);
24929
+ Vue.use(v_mask_esm_plugin);
24930
+ assets_icons();
24931
+ Vue.component('font-awesome-icon', FontAwesomeIcon);
24932
+ sessionStorage.setItem('server', 'principal');
24933
+ sessionStorage.setItem('client', settings.client);
24934
+ sessionStorage.setItem('base_url', settings.base_url);
24935
+ const headTag = document.getElementsByTagName('head')[0];
24936
+ const styleTag = document.createElement('style');
24937
+ const theme = {
24938
+ primary: settings.theme.primary,
24939
+ secondary: colorVariation(settings.theme.primary),
24940
+ start: settings.theme.start || '#4caf50',
24941
+ end: settings.theme.end || '#ff5252'
25820
24942
  };
25821
- }
25822
- isValidLookup(res) {
25823
- return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
25824
- }
25825
- getResource(code, ns, key) {
25826
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
25827
- if (this.i18nFormat && this.i18nFormat.getResource) return this.i18nFormat.getResource(code, ns, key, options);
25828
- return this.resourceStore.getResource(code, ns, key, options);
25829
- }
25830
- getUsedParamsDetails() {
25831
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
25832
- const optionsKeys = ['defaultValue', 'ordinal', 'context', 'replace', 'lng', 'lngs', 'fallbackLng', 'ns', 'keySeparator', 'nsSeparator', 'returnObjects', 'returnDetails', 'joinArrays', 'postProcess', 'interpolation'];
25833
- const useOptionsReplaceForData = options.replace && typeof options.replace !== 'string';
25834
- let data = useOptionsReplaceForData ? options.replace : options;
25835
- if (useOptionsReplaceForData && typeof options.count !== 'undefined') {
25836
- data.count = options.count;
25837
- }
25838
- if (this.options.interpolation.defaultVariables) {
25839
- data = {
25840
- ...this.options.interpolation.defaultVariables,
25841
- ...data
25842
- };
25843
- }
25844
- if (!useOptionsReplaceForData) {
25845
- data = {
25846
- ...data
25847
- };
25848
- for (const key of optionsKeys) {
25849
- delete data[key];
25850
- }
25851
- }
25852
- return data;
25853
- }
25854
- static hasDefaultValue(options) {
25855
- const prefix = 'defaultValue';
25856
- for (const option in options) {
25857
- if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {
25858
- return true;
25859
- }
25860
- }
25861
- return false;
25862
- }
25863
- }
25864
- function capitalize(string) {
25865
- return string.charAt(0).toUpperCase() + string.slice(1);
25866
- }
25867
- class LanguageUtil {
25868
- constructor(options) {
25869
- this.options = options;
25870
- this.supportedLngs = this.options.supportedLngs || false;
25871
- this.logger = baseLogger.create('languageUtils');
25872
- }
25873
- getScriptPartFromCode(code) {
25874
- code = getCleanedCode(code);
25875
- if (!code || code.indexOf('-') < 0) return null;
25876
- const p = code.split('-');
25877
- if (p.length === 2) return null;
25878
- p.pop();
25879
- if (p[p.length - 1].toLowerCase() === 'x') return null;
25880
- return this.formatLanguageCode(p.join('-'));
25881
- }
25882
- getLanguagePartFromCode(code) {
25883
- code = getCleanedCode(code);
25884
- if (!code || code.indexOf('-') < 0) return code;
25885
- const p = code.split('-');
25886
- return this.formatLanguageCode(p[0]);
25887
- }
25888
- formatLanguageCode(code) {
25889
- if (typeof code === 'string' && code.indexOf('-') > -1) {
25890
- const specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];
25891
- let p = code.split('-');
25892
- if (this.options.lowerCaseLng) {
25893
- p = p.map(part => part.toLowerCase());
25894
- } else if (p.length === 2) {
25895
- p[0] = p[0].toLowerCase();
25896
- p[1] = p[1].toUpperCase();
25897
- if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
25898
- } else if (p.length === 3) {
25899
- p[0] = p[0].toLowerCase();
25900
- if (p[1].length === 2) p[1] = p[1].toUpperCase();
25901
- if (p[0] !== 'sgn' && p[2].length === 2) p[2] = p[2].toUpperCase();
25902
- if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
25903
- if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());
25904
- }
25905
- return p.join('-');
25906
- }
25907
- return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
25908
- }
25909
- isSupportedCode(code) {
25910
- if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
25911
- code = this.getLanguagePartFromCode(code);
25912
- }
25913
- return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
25914
- }
25915
- getBestMatchFromCodes(codes) {
25916
- if (!codes) return null;
25917
- let found;
25918
- codes.forEach(code => {
25919
- if (found) return;
25920
- const cleanedLng = this.formatLanguageCode(code);
25921
- if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;
25922
- });
25923
- if (!found && this.options.supportedLngs) {
25924
- codes.forEach(code => {
25925
- if (found) return;
25926
- const lngOnly = this.getLanguagePartFromCode(code);
25927
- if (this.isSupportedCode(lngOnly)) return found = lngOnly;
25928
- found = this.options.supportedLngs.find(supportedLng => {
25929
- if (supportedLng === lngOnly) return supportedLng;
25930
- if (supportedLng.indexOf('-') < 0 && lngOnly.indexOf('-') < 0) return;
25931
- if (supportedLng.indexOf(lngOnly) === 0) return supportedLng;
25932
- });
25933
- });
25934
- }
25935
- if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
25936
- return found;
25937
- }
25938
- getFallbackCodes(fallbacks, code) {
25939
- if (!fallbacks) return [];
25940
- if (typeof fallbacks === 'function') fallbacks = fallbacks(code);
25941
- if (typeof fallbacks === 'string') fallbacks = [fallbacks];
25942
- if (Object.prototype.toString.apply(fallbacks) === '[object Array]') return fallbacks;
25943
- if (!code) return fallbacks.default || [];
25944
- let found = fallbacks[code];
25945
- if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
25946
- if (!found) found = fallbacks[this.formatLanguageCode(code)];
25947
- if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
25948
- if (!found) found = fallbacks.default;
25949
- return found || [];
25950
- }
25951
- toResolveHierarchy(code, fallbackCode) {
25952
- const fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
25953
- const codes = [];
25954
- const addCode = c => {
25955
- if (!c) return;
25956
- if (this.isSupportedCode(c)) {
25957
- codes.push(c);
25958
- } else {
25959
- this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
25960
- }
25961
- };
25962
- if (typeof code === 'string' && (code.indexOf('-') > -1 || code.indexOf('_') > -1)) {
25963
- if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
25964
- if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
25965
- if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
25966
- } else if (typeof code === 'string') {
25967
- addCode(this.formatLanguageCode(code));
25968
- }
25969
- fallbackCodes.forEach(fc => {
25970
- if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
25971
- });
25972
- return codes;
25973
- }
25974
- }
25975
- let sets = [{
25976
- lngs: ['ach', 'ak', 'am', 'arn', 'br', 'fil', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt', 'pt-BR', 'tg', 'tl', 'ti', 'tr', 'uz', 'wa'],
25977
- nr: [1, 2],
25978
- fc: 1
25979
- }, {
25980
- 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'],
25981
- nr: [1, 2],
25982
- fc: 2
25983
- }, {
25984
- lngs: ['ay', 'bo', 'cgg', 'fa', 'ht', 'id', 'ja', 'jbo', 'ka', 'km', 'ko', 'ky', 'lo', 'ms', 'sah', 'su', 'th', 'tt', 'ug', 'vi', 'wo', 'zh'],
25985
- nr: [1],
25986
- fc: 3
25987
- }, {
25988
- lngs: ['be', 'bs', 'cnr', 'dz', 'hr', 'ru', 'sr', 'uk'],
25989
- nr: [1, 2, 5],
25990
- fc: 4
25991
- }, {
25992
- lngs: ['ar'],
25993
- nr: [0, 1, 2, 3, 11, 100],
25994
- fc: 5
25995
- }, {
25996
- lngs: ['cs', 'sk'],
25997
- nr: [1, 2, 5],
25998
- fc: 6
25999
- }, {
26000
- lngs: ['csb', 'pl'],
26001
- nr: [1, 2, 5],
26002
- fc: 7
26003
- }, {
26004
- lngs: ['cy'],
26005
- nr: [1, 2, 3, 8],
26006
- fc: 8
26007
- }, {
26008
- lngs: ['fr'],
26009
- nr: [1, 2],
26010
- fc: 9
26011
- }, {
26012
- lngs: ['ga'],
26013
- nr: [1, 2, 3, 7, 11],
26014
- fc: 10
26015
- }, {
26016
- lngs: ['gd'],
26017
- nr: [1, 2, 3, 20],
26018
- fc: 11
26019
- }, {
26020
- lngs: ['is'],
26021
- nr: [1, 2],
26022
- fc: 12
26023
- }, {
26024
- lngs: ['jv'],
26025
- nr: [0, 1],
26026
- fc: 13
26027
- }, {
26028
- lngs: ['kw'],
26029
- nr: [1, 2, 3, 4],
26030
- fc: 14
26031
- }, {
26032
- lngs: ['lt'],
26033
- nr: [1, 2, 10],
26034
- fc: 15
26035
- }, {
26036
- lngs: ['lv'],
26037
- nr: [1, 2, 0],
26038
- fc: 16
26039
- }, {
26040
- lngs: ['mk'],
26041
- nr: [1, 2],
26042
- fc: 17
26043
- }, {
26044
- lngs: ['mnk'],
26045
- nr: [0, 1, 2],
26046
- fc: 18
26047
- }, {
26048
- lngs: ['mt'],
26049
- nr: [1, 2, 11, 20],
26050
- fc: 19
26051
- }, {
26052
- lngs: ['or'],
26053
- nr: [2, 1],
26054
- fc: 2
26055
- }, {
26056
- lngs: ['ro'],
26057
- nr: [1, 2, 20],
26058
- fc: 20
26059
- }, {
26060
- lngs: ['sl'],
26061
- nr: [5, 1, 2, 3],
26062
- fc: 21
26063
- }, {
26064
- lngs: ['he', 'iw'],
26065
- nr: [1, 2, 20, 21],
26066
- fc: 22
26067
- }];
26068
- let _rulesPluralsTypes = {
26069
- 1: function (n) {
26070
- return Number(n > 1);
26071
- },
26072
- 2: function (n) {
26073
- return Number(n != 1);
26074
- },
26075
- 3: function (n) {
26076
- return 0;
26077
- },
26078
- 4: function (n) {
26079
- return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
26080
- },
26081
- 5: function (n) {
26082
- return Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5);
26083
- },
26084
- 6: function (n) {
26085
- return Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2);
26086
- },
26087
- 7: function (n) {
26088
- return Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
26089
- },
26090
- 8: function (n) {
26091
- return Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3);
26092
- },
26093
- 9: function (n) {
26094
- return Number(n >= 2);
26095
- },
26096
- 10: function (n) {
26097
- return Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4);
26098
- },
26099
- 11: function (n) {
26100
- return Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3);
26101
- },
26102
- 12: function (n) {
26103
- return Number(n % 10 != 1 || n % 100 == 11);
26104
- },
26105
- 13: function (n) {
26106
- return Number(n !== 0);
26107
- },
26108
- 14: function (n) {
26109
- return Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3);
26110
- },
26111
- 15: function (n) {
26112
- return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
26113
- },
26114
- 16: function (n) {
26115
- return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2);
26116
- },
26117
- 17: function (n) {
26118
- return Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1);
26119
- },
26120
- 18: function (n) {
26121
- return Number(n == 0 ? 0 : n == 1 ? 1 : 2);
26122
- },
26123
- 19: function (n) {
26124
- return Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3);
26125
- },
26126
- 20: function (n) {
26127
- return Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2);
26128
- },
26129
- 21: function (n) {
26130
- return Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0);
26131
- },
26132
- 22: function (n) {
26133
- return Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3);
26134
- }
26135
- };
26136
- const nonIntlVersions = ['v1', 'v2', 'v3'];
26137
- const intlVersions = ['v4'];
26138
- const suffixesOrder = {
26139
- zero: 0,
26140
- one: 1,
26141
- two: 2,
26142
- few: 3,
26143
- many: 4,
26144
- other: 5
26145
- };
26146
- function createRules() {
26147
- const rules = {};
26148
- sets.forEach(set => {
26149
- set.lngs.forEach(l => {
26150
- rules[l] = {
26151
- numbers: set.nr,
26152
- plurals: _rulesPluralsTypes[set.fc]
26153
- };
26154
- });
26155
- });
26156
- return rules;
26157
- }
26158
- class PluralResolver {
26159
- constructor(languageUtils) {
26160
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
26161
- this.languageUtils = languageUtils;
26162
- this.options = options;
26163
- this.logger = baseLogger.create('pluralResolver');
26164
- if ((!this.options.compatibilityJSON || intlVersions.includes(this.options.compatibilityJSON)) && (typeof Intl === 'undefined' || !Intl.PluralRules)) {
26165
- this.options.compatibilityJSON = 'v3';
26166
- 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.');
26167
- }
26168
- this.rules = createRules();
26169
- }
26170
- addRule(lng, obj) {
26171
- this.rules[lng] = obj;
26172
- }
26173
- getRule(code) {
26174
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
26175
- if (this.shouldUseIntlApi()) {
26176
- try {
26177
- return new Intl.PluralRules(getCleanedCode(code), {
26178
- type: options.ordinal ? 'ordinal' : 'cardinal'
26179
- });
26180
- } catch {
26181
- return;
26182
- }
26183
- }
26184
- return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];
26185
- }
26186
- needsPlural(code) {
26187
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
26188
- const rule = this.getRule(code, options);
26189
- if (this.shouldUseIntlApi()) {
26190
- return rule && rule.resolvedOptions().pluralCategories.length > 1;
26191
- }
26192
- return rule && rule.numbers.length > 1;
26193
- }
26194
- getPluralFormsOfKey(code, key) {
26195
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
26196
- return this.getSuffixes(code, options).map(suffix => `${key}${suffix}`);
26197
- }
26198
- getSuffixes(code) {
26199
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
26200
- const rule = this.getRule(code, options);
26201
- if (!rule) {
26202
- return [];
26203
- }
26204
- if (this.shouldUseIntlApi()) {
26205
- return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map(pluralCategory => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${pluralCategory}`);
26206
- }
26207
- return rule.numbers.map(number => this.getSuffix(code, number, options));
26208
- }
26209
- getSuffix(code, count) {
26210
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
26211
- const rule = this.getRule(code, options);
26212
- if (rule) {
26213
- if (this.shouldUseIntlApi()) {
26214
- return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${rule.select(count)}`;
26215
- }
26216
- return this.getSuffixRetroCompatible(rule, count);
26217
- }
26218
- this.logger.warn(`no plural rule found for: ${code}`);
26219
- return '';
26220
- }
26221
- getSuffixRetroCompatible(rule, count) {
26222
- const idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
26223
- let suffix = rule.numbers[idx];
26224
- if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
26225
- if (suffix === 2) {
26226
- suffix = 'plural';
26227
- } else if (suffix === 1) {
26228
- suffix = '';
26229
- }
26230
- }
26231
- const returnSuffix = () => this.options.prepend && suffix.toString() ? this.options.prepend + suffix.toString() : suffix.toString();
26232
- if (this.options.compatibilityJSON === 'v1') {
26233
- if (suffix === 1) return '';
26234
- if (typeof suffix === 'number') return `_plural_${suffix.toString()}`;
26235
- return returnSuffix();
26236
- } else if (this.options.compatibilityJSON === 'v2') {
26237
- return returnSuffix();
26238
- } else if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
26239
- return returnSuffix();
26240
- }
26241
- return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
26242
- }
26243
- shouldUseIntlApi() {
26244
- return !nonIntlVersions.includes(this.options.compatibilityJSON);
26245
- }
26246
- }
26247
- function deepFindWithDefaults(data, defaultData, key) {
26248
- let keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
26249
- let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
26250
- let path = getPathWithDefaults(data, defaultData, key);
26251
- if (!path && ignoreJSONStructure && typeof key === 'string') {
26252
- path = deepFind(data, key, keySeparator);
26253
- if (path === undefined) path = deepFind(defaultData, key, keySeparator);
26254
- }
26255
- return path;
26256
- }
26257
- class Interpolator {
26258
- constructor() {
26259
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26260
- this.logger = baseLogger.create('interpolator');
26261
- this.options = options;
26262
- this.format = options.interpolation && options.interpolation.format || (value => value);
26263
- this.init(options);
26264
- }
26265
- init() {
26266
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26267
- if (!options.interpolation) options.interpolation = {
26268
- escapeValue: true
26269
- };
26270
- const iOpts = options.interpolation;
26271
- this.escape = iOpts.escape !== undefined ? iOpts.escape : i18next_escape;
26272
- this.escapeValue = iOpts.escapeValue !== undefined ? iOpts.escapeValue : true;
26273
- this.useRawValueToEscape = iOpts.useRawValueToEscape !== undefined ? iOpts.useRawValueToEscape : false;
26274
- this.prefix = iOpts.prefix ? regexEscape(iOpts.prefix) : iOpts.prefixEscaped || '{{';
26275
- this.suffix = iOpts.suffix ? regexEscape(iOpts.suffix) : iOpts.suffixEscaped || '}}';
26276
- this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
26277
- this.unescapePrefix = iOpts.unescapeSuffix ? '' : iOpts.unescapePrefix || '-';
26278
- this.unescapeSuffix = this.unescapePrefix ? '' : iOpts.unescapeSuffix || '';
26279
- this.nestingPrefix = iOpts.nestingPrefix ? regexEscape(iOpts.nestingPrefix) : iOpts.nestingPrefixEscaped || regexEscape('$t(');
26280
- this.nestingSuffix = iOpts.nestingSuffix ? regexEscape(iOpts.nestingSuffix) : iOpts.nestingSuffixEscaped || regexEscape(')');
26281
- this.nestingOptionsSeparator = iOpts.nestingOptionsSeparator ? iOpts.nestingOptionsSeparator : iOpts.nestingOptionsSeparator || ',';
26282
- this.maxReplaces = iOpts.maxReplaces ? iOpts.maxReplaces : 1000;
26283
- this.alwaysFormat = iOpts.alwaysFormat !== undefined ? iOpts.alwaysFormat : false;
26284
- this.resetRegExp();
26285
- }
26286
- reset() {
26287
- if (this.options) this.init(this.options);
26288
- }
26289
- resetRegExp() {
26290
- const regexpStr = `${this.prefix}(.+?)${this.suffix}`;
26291
- this.regexp = new RegExp(regexpStr, 'g');
26292
- const regexpUnescapeStr = `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`;
26293
- this.regexpUnescape = new RegExp(regexpUnescapeStr, 'g');
26294
- const nestingRegexpStr = `${this.nestingPrefix}(.+?)${this.nestingSuffix}`;
26295
- this.nestingRegexp = new RegExp(nestingRegexpStr, 'g');
26296
- }
26297
- interpolate(str, data, lng, options) {
26298
- let match;
26299
- let value;
26300
- let replaces;
26301
- const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
26302
- function regexSafe(val) {
26303
- return val.replace(/\$/g, '$$$$');
26304
- }
26305
- const handleFormat = key => {
26306
- if (key.indexOf(this.formatSeparator) < 0) {
26307
- const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
26308
- return this.alwaysFormat ? this.format(path, undefined, lng, {
26309
- ...options,
26310
- ...data,
26311
- interpolationkey: key
26312
- }) : path;
26313
- }
26314
- const p = key.split(this.formatSeparator);
26315
- const k = p.shift().trim();
26316
- const f = p.join(this.formatSeparator).trim();
26317
- return this.format(deepFindWithDefaults(data, defaultData, k, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, {
26318
- ...options,
26319
- ...data,
26320
- interpolationkey: k
26321
- });
26322
- };
26323
- this.resetRegExp();
26324
- const missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;
26325
- const skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
26326
- const todos = [{
26327
- regex: this.regexpUnescape,
26328
- safeValue: val => regexSafe(val)
26329
- }, {
26330
- regex: this.regexp,
26331
- safeValue: val => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
26332
- }];
26333
- todos.forEach(todo => {
26334
- replaces = 0;
26335
- while (match = todo.regex.exec(str)) {
26336
- const matchedVar = match[1].trim();
26337
- value = handleFormat(matchedVar);
26338
- if (value === undefined) {
26339
- if (typeof missingInterpolationHandler === 'function') {
26340
- const temp = missingInterpolationHandler(str, match, options);
26341
- value = typeof temp === 'string' ? temp : '';
26342
- } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
26343
- value = '';
26344
- } else if (skipOnVariables) {
26345
- value = match[0];
26346
- continue;
26347
- } else {
26348
- this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
26349
- value = '';
26350
- }
26351
- } else if (typeof value !== 'string' && !this.useRawValueToEscape) {
26352
- value = makeString(value);
26353
- }
26354
- const safeValue = todo.safeValue(value);
26355
- str = str.replace(match[0], safeValue);
26356
- if (skipOnVariables) {
26357
- todo.regex.lastIndex += value.length;
26358
- todo.regex.lastIndex -= match[0].length;
26359
- } else {
26360
- todo.regex.lastIndex = 0;
26361
- }
26362
- replaces++;
26363
- if (replaces >= this.maxReplaces) {
26364
- break;
26365
- }
26366
- }
26367
- });
26368
- return str;
26369
- }
26370
- nest(str, fc) {
26371
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
26372
- let match;
26373
- let value;
26374
- let clonedOptions;
26375
- function handleHasOptions(key, inheritedOptions) {
26376
- const sep = this.nestingOptionsSeparator;
26377
- if (key.indexOf(sep) < 0) return key;
26378
- const c = key.split(new RegExp(`${sep}[ ]*{`));
26379
- let optionsString = `{${c[1]}`;
26380
- key = c[0];
26381
- optionsString = this.interpolate(optionsString, clonedOptions);
26382
- const matchedSingleQuotes = optionsString.match(/'/g);
26383
- const matchedDoubleQuotes = optionsString.match(/"/g);
26384
- if (matchedSingleQuotes && matchedSingleQuotes.length % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
26385
- optionsString = optionsString.replace(/'/g, '"');
26386
- }
26387
- try {
26388
- clonedOptions = JSON.parse(optionsString);
26389
- if (inheritedOptions) clonedOptions = {
26390
- ...inheritedOptions,
26391
- ...clonedOptions
26392
- };
26393
- } catch (e) {
26394
- this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);
26395
- return `${key}${sep}${optionsString}`;
26396
- }
26397
- delete clonedOptions.defaultValue;
26398
- return key;
26399
- }
26400
- while (match = this.nestingRegexp.exec(str)) {
26401
- let formatters = [];
26402
- clonedOptions = {
26403
- ...options
26404
- };
26405
- clonedOptions = clonedOptions.replace && typeof clonedOptions.replace !== 'string' ? clonedOptions.replace : clonedOptions;
26406
- clonedOptions.applyPostProcessor = false;
26407
- delete clonedOptions.defaultValue;
26408
- let doReduce = false;
26409
- if (match[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match[1])) {
26410
- const r = match[1].split(this.formatSeparator).map(elem => elem.trim());
26411
- match[1] = r.shift();
26412
- formatters = r;
26413
- doReduce = true;
26414
- }
26415
- value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
26416
- if (value && match[0] === str && typeof value !== 'string') return value;
26417
- if (typeof value !== 'string') value = makeString(value);
26418
- if (!value) {
26419
- this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
26420
- value = '';
26421
- }
26422
- if (doReduce) {
26423
- value = formatters.reduce((v, f) => this.format(v, f, options.lng, {
26424
- ...options,
26425
- interpolationkey: match[1].trim()
26426
- }), value.trim());
26427
- }
26428
- str = str.replace(match[0], value);
26429
- this.regexp.lastIndex = 0;
26430
- }
26431
- return str;
26432
- }
26433
- }
26434
- function parseFormatStr(formatStr) {
26435
- let formatName = formatStr.toLowerCase().trim();
26436
- const formatOptions = {};
26437
- if (formatStr.indexOf('(') > -1) {
26438
- const p = formatStr.split('(');
26439
- formatName = p[0].toLowerCase().trim();
26440
- const optStr = p[1].substring(0, p[1].length - 1);
26441
- if (formatName === 'currency' && optStr.indexOf(':') < 0) {
26442
- if (!formatOptions.currency) formatOptions.currency = optStr.trim();
26443
- } else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {
26444
- if (!formatOptions.range) formatOptions.range = optStr.trim();
26445
- } else {
26446
- const opts = optStr.split(';');
26447
- opts.forEach(opt => {
26448
- if (!opt) return;
26449
- const [key, ...rest] = opt.split(':');
26450
- const val = rest.join(':').trim().replace(/^'+|'+$/g, '');
26451
- if (!formatOptions[key.trim()]) formatOptions[key.trim()] = val;
26452
- if (val === 'false') formatOptions[key.trim()] = false;
26453
- if (val === 'true') formatOptions[key.trim()] = true;
26454
- if (!isNaN(val)) formatOptions[key.trim()] = parseInt(val, 10);
26455
- });
26456
- }
26457
- }
26458
- return {
26459
- formatName,
26460
- formatOptions
26461
- };
26462
- }
26463
- function createCachedFormatter(fn) {
26464
- const cache = {};
26465
- return function invokeFormatter(val, lng, options) {
26466
- const key = lng + JSON.stringify(options);
26467
- let formatter = cache[key];
26468
- if (!formatter) {
26469
- formatter = fn(getCleanedCode(lng), options);
26470
- cache[key] = formatter;
26471
- }
26472
- return formatter(val);
26473
- };
26474
- }
26475
- class Formatter {
26476
- constructor() {
26477
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26478
- this.logger = baseLogger.create('formatter');
26479
- this.options = options;
26480
- this.formats = {
26481
- number: createCachedFormatter((lng, opt) => {
26482
- const formatter = new Intl.NumberFormat(lng, {
26483
- ...opt
26484
- });
26485
- return val => formatter.format(val);
26486
- }),
26487
- currency: createCachedFormatter((lng, opt) => {
26488
- const formatter = new Intl.NumberFormat(lng, {
26489
- ...opt,
26490
- style: 'currency'
26491
- });
26492
- return val => formatter.format(val);
26493
- }),
26494
- datetime: createCachedFormatter((lng, opt) => {
26495
- const formatter = new Intl.DateTimeFormat(lng, {
26496
- ...opt
26497
- });
26498
- return val => formatter.format(val);
26499
- }),
26500
- relativetime: createCachedFormatter((lng, opt) => {
26501
- const formatter = new Intl.RelativeTimeFormat(lng, {
26502
- ...opt
26503
- });
26504
- return val => formatter.format(val, opt.range || 'day');
26505
- }),
26506
- list: createCachedFormatter((lng, opt) => {
26507
- const formatter = new Intl.ListFormat(lng, {
26508
- ...opt
26509
- });
26510
- return val => formatter.format(val);
26511
- })
26512
- };
26513
- this.init(options);
26514
- }
26515
- init(services) {
26516
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
26517
- interpolation: {}
26518
- };
26519
- const iOpts = options.interpolation;
26520
- this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
26521
- }
26522
- add(name, fc) {
26523
- this.formats[name.toLowerCase().trim()] = fc;
26524
- }
26525
- addCached(name, fc) {
26526
- this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
26527
- }
26528
- format(value, format, lng) {
26529
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
26530
- const formats = format.split(this.formatSeparator);
26531
- const result = formats.reduce((mem, f) => {
26532
- const {
26533
- formatName,
26534
- formatOptions
26535
- } = parseFormatStr(f);
26536
- if (this.formats[formatName]) {
26537
- let formatted = mem;
26538
- try {
26539
- const valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || {};
26540
- const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
26541
- formatted = this.formats[formatName](mem, l, {
26542
- ...formatOptions,
26543
- ...options,
26544
- ...valOptions
26545
- });
26546
- } catch (error) {
26547
- this.logger.warn(error);
26548
- }
26549
- return formatted;
26550
- } else {
26551
- this.logger.warn(`there was no format function for ${formatName}`);
26552
- }
26553
- return mem;
26554
- }, value);
26555
- return result;
26556
- }
26557
- }
26558
- function removePending(q, name) {
26559
- if (q.pending[name] !== undefined) {
26560
- delete q.pending[name];
26561
- q.pendingCount--;
26562
- }
26563
- }
26564
- class Connector extends EventEmitter {
26565
- constructor(backend, store, services) {
26566
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
26567
- super();
26568
- this.backend = backend;
26569
- this.store = store;
26570
- this.services = services;
26571
- this.languageUtils = services.languageUtils;
26572
- this.options = options;
26573
- this.logger = baseLogger.create('backendConnector');
26574
- this.waitingReads = [];
26575
- this.maxParallelReads = options.maxParallelReads || 10;
26576
- this.readingCalls = 0;
26577
- this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
26578
- this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
26579
- this.state = {};
26580
- this.queue = [];
26581
- if (this.backend && this.backend.init) {
26582
- this.backend.init(services, options.backend, options);
26583
- }
26584
- }
26585
- queueLoad(languages, namespaces, options, callback) {
26586
- const toLoad = {};
26587
- const pending = {};
26588
- const toLoadLanguages = {};
26589
- const toLoadNamespaces = {};
26590
- languages.forEach(lng => {
26591
- let hasAllNamespaces = true;
26592
- namespaces.forEach(ns => {
26593
- const name = `${lng}|${ns}`;
26594
- if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
26595
- this.state[name] = 2;
26596
- } else if (this.state[name] < 0) ;else if (this.state[name] === 1) {
26597
- if (pending[name] === undefined) pending[name] = true;
26598
- } else {
26599
- this.state[name] = 1;
26600
- hasAllNamespaces = false;
26601
- if (pending[name] === undefined) pending[name] = true;
26602
- if (toLoad[name] === undefined) toLoad[name] = true;
26603
- if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;
26604
- }
26605
- });
26606
- if (!hasAllNamespaces) toLoadLanguages[lng] = true;
26607
- });
26608
- if (Object.keys(toLoad).length || Object.keys(pending).length) {
26609
- this.queue.push({
26610
- pending,
26611
- pendingCount: Object.keys(pending).length,
26612
- loaded: {},
26613
- errors: [],
26614
- callback
26615
- });
26616
- }
26617
- return {
26618
- toLoad: Object.keys(toLoad),
26619
- pending: Object.keys(pending),
26620
- toLoadLanguages: Object.keys(toLoadLanguages),
26621
- toLoadNamespaces: Object.keys(toLoadNamespaces)
26622
- };
26623
- }
26624
- loaded(name, err, data) {
26625
- const s = name.split('|');
26626
- const lng = s[0];
26627
- const ns = s[1];
26628
- if (err) this.emit('failedLoading', lng, ns, err);
26629
- if (data) {
26630
- this.store.addResourceBundle(lng, ns, data);
26631
- }
26632
- this.state[name] = err ? -1 : 2;
26633
- const loaded = {};
26634
- this.queue.forEach(q => {
26635
- pushPath(q.loaded, [lng], ns);
26636
- removePending(q, name);
26637
- if (err) q.errors.push(err);
26638
- if (q.pendingCount === 0 && !q.done) {
26639
- Object.keys(q.loaded).forEach(l => {
26640
- if (!loaded[l]) loaded[l] = {};
26641
- const loadedKeys = q.loaded[l];
26642
- if (loadedKeys.length) {
26643
- loadedKeys.forEach(n => {
26644
- if (loaded[l][n] === undefined) loaded[l][n] = true;
26645
- });
26646
- }
26647
- });
26648
- q.done = true;
26649
- if (q.errors.length) {
26650
- q.callback(q.errors);
26651
- } else {
26652
- q.callback();
26653
- }
26654
- }
26655
- });
26656
- this.emit('loaded', loaded);
26657
- this.queue = this.queue.filter(q => !q.done);
26658
- }
26659
- read(lng, ns, fcName) {
26660
- let tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
26661
- let wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
26662
- let callback = arguments.length > 5 ? arguments[5] : undefined;
26663
- if (!lng.length) return callback(null, {});
26664
- if (this.readingCalls >= this.maxParallelReads) {
26665
- this.waitingReads.push({
26666
- lng,
26667
- ns,
26668
- fcName,
26669
- tried,
26670
- wait,
26671
- callback
26672
- });
26673
- return;
26674
- }
26675
- this.readingCalls++;
26676
- const resolver = (err, data) => {
26677
- this.readingCalls--;
26678
- if (this.waitingReads.length > 0) {
26679
- const next = this.waitingReads.shift();
26680
- this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
26681
- }
26682
- if (err && data && tried < this.maxRetries) {
26683
- setTimeout(() => {
26684
- this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
26685
- }, wait);
26686
- return;
26687
- }
26688
- callback(err, data);
26689
- };
26690
- const fc = this.backend[fcName].bind(this.backend);
26691
- if (fc.length === 2) {
26692
- try {
26693
- const r = fc(lng, ns);
26694
- if (r && typeof r.then === 'function') {
26695
- r.then(data => resolver(null, data)).catch(resolver);
26696
- } else {
26697
- resolver(null, r);
26698
- }
26699
- } catch (err) {
26700
- resolver(err);
26701
- }
26702
- return;
26703
- }
26704
- return fc(lng, ns, resolver);
26705
- }
26706
- prepareLoading(languages, namespaces) {
26707
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
26708
- let callback = arguments.length > 3 ? arguments[3] : undefined;
26709
- if (!this.backend) {
26710
- this.logger.warn('No backend was added via i18next.use. Will not load resources.');
26711
- return callback && callback();
26712
- }
26713
- if (typeof languages === 'string') languages = this.languageUtils.toResolveHierarchy(languages);
26714
- if (typeof namespaces === 'string') namespaces = [namespaces];
26715
- const toLoad = this.queueLoad(languages, namespaces, options, callback);
26716
- if (!toLoad.toLoad.length) {
26717
- if (!toLoad.pending.length) callback();
26718
- return null;
26719
- }
26720
- toLoad.toLoad.forEach(name => {
26721
- this.loadOne(name);
26722
- });
26723
- }
26724
- load(languages, namespaces, callback) {
26725
- this.prepareLoading(languages, namespaces, {}, callback);
26726
- }
26727
- reload(languages, namespaces, callback) {
26728
- this.prepareLoading(languages, namespaces, {
26729
- reload: true
26730
- }, callback);
26731
- }
26732
- loadOne(name) {
26733
- let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
26734
- const s = name.split('|');
26735
- const lng = s[0];
26736
- const ns = s[1];
26737
- this.read(lng, ns, 'read', undefined, undefined, (err, data) => {
26738
- if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
26739
- if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
26740
- this.loaded(name, err, data);
26741
- });
26742
- }
26743
- saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
26744
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
26745
- let clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : () => {};
26746
- if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {
26747
- this.logger.warn(`did not save key "${key}" as the namespace "${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!!!');
26748
- return;
26749
- }
26750
- if (key === undefined || key === null || key === '') return;
26751
- if (this.backend && this.backend.create) {
26752
- const opts = {
26753
- ...options,
26754
- isUpdate
26755
- };
26756
- const fc = this.backend.create.bind(this.backend);
26757
- if (fc.length < 6) {
26758
- try {
26759
- let r;
26760
- if (fc.length === 5) {
26761
- r = fc(languages, namespace, key, fallbackValue, opts);
26762
- } else {
26763
- r = fc(languages, namespace, key, fallbackValue);
26764
- }
26765
- if (r && typeof r.then === 'function') {
26766
- r.then(data => clb(null, data)).catch(clb);
26767
- } else {
26768
- clb(null, r);
26769
- }
26770
- } catch (err) {
26771
- clb(err);
26772
- }
26773
- } else {
26774
- fc(languages, namespace, key, fallbackValue, clb, opts);
26775
- }
26776
- }
26777
- if (!languages || !languages[0]) return;
26778
- this.store.addResource(languages[0], namespace, key, fallbackValue);
26779
- }
26780
- }
26781
- function get() {
26782
- return {
26783
- debug: false,
26784
- initImmediate: true,
26785
- ns: ['translation'],
26786
- defaultNS: ['translation'],
26787
- fallbackLng: ['dev'],
26788
- fallbackNS: false,
26789
- supportedLngs: false,
26790
- nonExplicitSupportedLngs: false,
26791
- load: 'all',
26792
- preload: false,
26793
- simplifyPluralSuffix: true,
26794
- keySeparator: '.',
26795
- nsSeparator: ':',
26796
- pluralSeparator: '_',
26797
- contextSeparator: '_',
26798
- partialBundledLanguages: false,
26799
- saveMissing: false,
26800
- updateMissing: false,
26801
- saveMissingTo: 'fallback',
26802
- saveMissingPlurals: true,
26803
- missingKeyHandler: false,
26804
- missingInterpolationHandler: false,
26805
- postProcess: false,
26806
- postProcessPassResolved: false,
26807
- returnNull: false,
26808
- returnEmptyString: true,
26809
- returnObjects: false,
26810
- joinArrays: false,
26811
- returnedObjectHandler: false,
26812
- parseMissingKeyHandler: false,
26813
- appendNamespaceToMissingKey: false,
26814
- appendNamespaceToCIMode: false,
26815
- overloadTranslationOptionHandler: function handle(args) {
26816
- let ret = {};
26817
- if (typeof args[1] === 'object') ret = args[1];
26818
- if (typeof args[1] === 'string') ret.defaultValue = args[1];
26819
- if (typeof args[2] === 'string') ret.tDescription = args[2];
26820
- if (typeof args[2] === 'object' || typeof args[3] === 'object') {
26821
- const options = args[3] || args[2];
26822
- Object.keys(options).forEach(key => {
26823
- ret[key] = options[key];
26824
- });
26825
- }
26826
- return ret;
26827
- },
26828
- interpolation: {
26829
- escapeValue: true,
26830
- format: (value, format, lng, options) => value,
26831
- prefix: '{{',
26832
- suffix: '}}',
26833
- formatSeparator: ',',
26834
- unescapePrefix: '-',
26835
- nestingPrefix: '$t(',
26836
- nestingSuffix: ')',
26837
- nestingOptionsSeparator: ',',
26838
- maxReplaces: 1000,
26839
- skipOnVariables: true
26840
- }
26841
- };
26842
- }
26843
- function transformOptions(options) {
26844
- if (typeof options.ns === 'string') options.ns = [options.ns];
26845
- if (typeof options.fallbackLng === 'string') options.fallbackLng = [options.fallbackLng];
26846
- if (typeof options.fallbackNS === 'string') options.fallbackNS = [options.fallbackNS];
26847
- if (options.supportedLngs && options.supportedLngs.indexOf('cimode') < 0) {
26848
- options.supportedLngs = options.supportedLngs.concat(['cimode']);
26849
- }
26850
- return options;
26851
- }
26852
- function i18next_noop() {}
26853
- function bindMemberFunctions(inst) {
26854
- const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
26855
- mems.forEach(mem => {
26856
- if (typeof inst[mem] === 'function') {
26857
- inst[mem] = inst[mem].bind(inst);
26858
- }
26859
- });
26860
- }
26861
- class I18n extends EventEmitter {
26862
- constructor() {
26863
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26864
- let callback = arguments.length > 1 ? arguments[1] : undefined;
26865
- super();
26866
- this.options = transformOptions(options);
26867
- this.services = {};
26868
- this.logger = baseLogger;
26869
- this.modules = {
26870
- external: []
26871
- };
26872
- bindMemberFunctions(this);
26873
- if (callback && !this.isInitialized && !options.isClone) {
26874
- if (!this.options.initImmediate) {
26875
- this.init(options, callback);
26876
- return this;
26877
- }
26878
- setTimeout(() => {
26879
- this.init(options, callback);
26880
- }, 0);
26881
- }
26882
- }
26883
- init() {
26884
- var _this = this;
26885
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26886
- let callback = arguments.length > 1 ? arguments[1] : undefined;
26887
- if (typeof options === 'function') {
26888
- callback = options;
26889
- options = {};
26890
- }
26891
- if (!options.defaultNS && options.defaultNS !== false && options.ns) {
26892
- if (typeof options.ns === 'string') {
26893
- options.defaultNS = options.ns;
26894
- } else if (options.ns.indexOf('translation') < 0) {
26895
- options.defaultNS = options.ns[0];
26896
- }
26897
- }
26898
- const defOpts = get();
26899
- this.options = {
26900
- ...defOpts,
26901
- ...this.options,
26902
- ...transformOptions(options)
26903
- };
26904
- if (this.options.compatibilityAPI !== 'v1') {
26905
- this.options.interpolation = {
26906
- ...defOpts.interpolation,
26907
- ...this.options.interpolation
26908
- };
26909
- }
26910
- if (options.keySeparator !== undefined) {
26911
- this.options.userDefinedKeySeparator = options.keySeparator;
26912
- }
26913
- if (options.nsSeparator !== undefined) {
26914
- this.options.userDefinedNsSeparator = options.nsSeparator;
26915
- }
26916
- function createClassOnDemand(ClassOrObject) {
26917
- if (!ClassOrObject) return null;
26918
- if (typeof ClassOrObject === 'function') return new ClassOrObject();
26919
- return ClassOrObject;
26920
- }
26921
- if (!this.options.isClone) {
26922
- if (this.modules.logger) {
26923
- baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
26924
- } else {
26925
- baseLogger.init(null, this.options);
26926
- }
26927
- let formatter;
26928
- if (this.modules.formatter) {
26929
- formatter = this.modules.formatter;
26930
- } else if (typeof Intl !== 'undefined') {
26931
- formatter = Formatter;
26932
- }
26933
- const lu = new LanguageUtil(this.options);
26934
- this.store = new ResourceStore(this.options.resources, this.options);
26935
- const s = this.services;
26936
- s.logger = baseLogger;
26937
- s.resourceStore = this.store;
26938
- s.languageUtils = lu;
26939
- s.pluralResolver = new PluralResolver(lu, {
26940
- prepend: this.options.pluralSeparator,
26941
- compatibilityJSON: this.options.compatibilityJSON,
26942
- simplifyPluralSuffix: this.options.simplifyPluralSuffix
26943
- });
26944
- if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
26945
- s.formatter = createClassOnDemand(formatter);
26946
- s.formatter.init(s, this.options);
26947
- this.options.interpolation.format = s.formatter.format.bind(s.formatter);
26948
- }
26949
- s.interpolator = new Interpolator(this.options);
26950
- s.utils = {
26951
- hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
26952
- };
26953
- s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
26954
- s.backendConnector.on('*', function (event) {
26955
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
26956
- args[_key - 1] = arguments[_key];
26957
- }
26958
- _this.emit(event, ...args);
26959
- });
26960
- if (this.modules.languageDetector) {
26961
- s.languageDetector = createClassOnDemand(this.modules.languageDetector);
26962
- if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
26963
- }
26964
- if (this.modules.i18nFormat) {
26965
- s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
26966
- if (s.i18nFormat.init) s.i18nFormat.init(this);
26967
- }
26968
- this.translator = new Translator(this.services, this.options);
26969
- this.translator.on('*', function (event) {
26970
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
26971
- args[_key2 - 1] = arguments[_key2];
26972
- }
26973
- _this.emit(event, ...args);
26974
- });
26975
- this.modules.external.forEach(m => {
26976
- if (m.init) m.init(this);
26977
- });
26978
- }
26979
- this.format = this.options.interpolation.format;
26980
- if (!callback) callback = i18next_noop;
26981
- if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
26982
- const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
26983
- if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
26984
- }
26985
- if (!this.services.languageDetector && !this.options.lng) {
26986
- this.logger.warn('init: no languageDetector is used and no lng is defined');
26987
- }
26988
- const storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
26989
- storeApi.forEach(fcName => {
26990
- this[fcName] = function () {
26991
- return _this.store[fcName](...arguments);
26992
- };
26993
- });
26994
- const storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
26995
- storeApiChained.forEach(fcName => {
26996
- this[fcName] = function () {
26997
- _this.store[fcName](...arguments);
26998
- return _this;
26999
- };
27000
- });
27001
- const deferred = defer();
27002
- const load = () => {
27003
- const finish = (err, t) => {
27004
- if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn('init: i18next is already initialized. You should call init just once!');
27005
- this.isInitialized = true;
27006
- if (!this.options.isClone) this.logger.log('initialized', this.options);
27007
- this.emit('initialized', this.options);
27008
- deferred.resolve(t);
27009
- callback(err, t);
27010
- };
27011
- if (this.languages && this.options.compatibilityAPI !== 'v1' && !this.isInitialized) return finish(null, this.t.bind(this));
27012
- this.changeLanguage(this.options.lng, finish);
27013
- };
27014
- if (this.options.resources || !this.options.initImmediate) {
27015
- load();
27016
- } else {
27017
- setTimeout(load, 0);
27018
- }
27019
- return deferred;
27020
- }
27021
- loadResources(language) {
27022
- let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : i18next_noop;
27023
- let usedCallback = callback;
27024
- const usedLng = typeof language === 'string' ? language : this.language;
27025
- if (typeof language === 'function') usedCallback = language;
27026
- if (!this.options.resources || this.options.partialBundledLanguages) {
27027
- if (usedLng && usedLng.toLowerCase() === 'cimode' && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
27028
- const toLoad = [];
27029
- const append = lng => {
27030
- if (!lng) return;
27031
- if (lng === 'cimode') return;
27032
- const lngs = this.services.languageUtils.toResolveHierarchy(lng);
27033
- lngs.forEach(l => {
27034
- if (l === 'cimode') return;
27035
- if (toLoad.indexOf(l) < 0) toLoad.push(l);
27036
- });
27037
- };
27038
- if (!usedLng) {
27039
- const fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
27040
- fallbacks.forEach(l => append(l));
27041
- } else {
27042
- append(usedLng);
27043
- }
27044
- if (this.options.preload) {
27045
- this.options.preload.forEach(l => append(l));
27046
- }
27047
- this.services.backendConnector.load(toLoad, this.options.ns, e => {
27048
- if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
27049
- usedCallback(e);
27050
- });
27051
- } else {
27052
- usedCallback(null);
27053
- }
27054
- }
27055
- reloadResources(lngs, ns, callback) {
27056
- const deferred = defer();
27057
- if (!lngs) lngs = this.languages;
27058
- if (!ns) ns = this.options.ns;
27059
- if (!callback) callback = i18next_noop;
27060
- this.services.backendConnector.reload(lngs, ns, err => {
27061
- deferred.resolve();
27062
- callback(err);
27063
- });
27064
- return deferred;
27065
- }
27066
- use(module) {
27067
- if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');
27068
- if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');
27069
- if (module.type === 'backend') {
27070
- this.modules.backend = module;
27071
- }
27072
- if (module.type === 'logger' || module.log && module.warn && module.error) {
27073
- this.modules.logger = module;
27074
- }
27075
- if (module.type === 'languageDetector') {
27076
- this.modules.languageDetector = module;
27077
- }
27078
- if (module.type === 'i18nFormat') {
27079
- this.modules.i18nFormat = module;
27080
- }
27081
- if (module.type === 'postProcessor') {
27082
- postProcessor.addPostProcessor(module);
27083
- }
27084
- if (module.type === 'formatter') {
27085
- this.modules.formatter = module;
27086
- }
27087
- if (module.type === '3rdParty') {
27088
- this.modules.external.push(module);
27089
- }
27090
- return this;
27091
- }
27092
- setResolvedLanguage(l) {
27093
- if (!l || !this.languages) return;
27094
- if (['cimode', 'dev'].indexOf(l) > -1) return;
27095
- for (let li = 0; li < this.languages.length; li++) {
27096
- const lngInLngs = this.languages[li];
27097
- if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;
27098
- if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
27099
- this.resolvedLanguage = lngInLngs;
27100
- break;
27101
- }
27102
- }
27103
- }
27104
- changeLanguage(lng, callback) {
27105
- var _this2 = this;
27106
- this.isLanguageChangingTo = lng;
27107
- const deferred = defer();
27108
- this.emit('languageChanging', lng);
27109
- const setLngProps = l => {
27110
- this.language = l;
27111
- this.languages = this.services.languageUtils.toResolveHierarchy(l);
27112
- this.resolvedLanguage = undefined;
27113
- this.setResolvedLanguage(l);
27114
- };
27115
- const done = (err, l) => {
27116
- if (l) {
27117
- setLngProps(l);
27118
- this.translator.changeLanguage(l);
27119
- this.isLanguageChangingTo = undefined;
27120
- this.emit('languageChanged', l);
27121
- this.logger.log('languageChanged', l);
27122
- } else {
27123
- this.isLanguageChangingTo = undefined;
27124
- }
27125
- deferred.resolve(function () {
27126
- return _this2.t(...arguments);
27127
- });
27128
- if (callback) callback(err, function () {
27129
- return _this2.t(...arguments);
27130
- });
27131
- };
27132
- const setLng = lngs => {
27133
- if (!lng && !lngs && this.services.languageDetector) lngs = [];
27134
- const l = typeof lngs === 'string' ? lngs : this.services.languageUtils.getBestMatchFromCodes(lngs);
27135
- if (l) {
27136
- if (!this.language) {
27137
- setLngProps(l);
27138
- }
27139
- if (!this.translator.language) this.translator.changeLanguage(l);
27140
- if (this.services.languageDetector && this.services.languageDetector.cacheUserLanguage) this.services.languageDetector.cacheUserLanguage(l);
27141
- }
27142
- this.loadResources(l, err => {
27143
- done(err, l);
27144
- });
27145
- };
27146
- if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
27147
- setLng(this.services.languageDetector.detect());
27148
- } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
27149
- if (this.services.languageDetector.detect.length === 0) {
27150
- this.services.languageDetector.detect().then(setLng);
27151
- } else {
27152
- this.services.languageDetector.detect(setLng);
27153
- }
27154
- } else {
27155
- setLng(lng);
27156
- }
27157
- return deferred;
27158
- }
27159
- getFixedT(lng, ns, keyPrefix) {
27160
- var _this3 = this;
27161
- const fixedT = function (key, opts) {
27162
- let options;
27163
- if (typeof opts !== 'object') {
27164
- for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
27165
- rest[_key3 - 2] = arguments[_key3];
27166
- }
27167
- options = _this3.options.overloadTranslationOptionHandler([key, opts].concat(rest));
27168
- } else {
27169
- options = {
27170
- ...opts
27171
- };
27172
- }
27173
- options.lng = options.lng || fixedT.lng;
27174
- options.lngs = options.lngs || fixedT.lngs;
27175
- options.ns = options.ns || fixedT.ns;
27176
- options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
27177
- const keySeparator = _this3.options.keySeparator || '.';
27178
- let resultKey;
27179
- if (options.keyPrefix && Array.isArray(key)) {
27180
- resultKey = key.map(k => `${options.keyPrefix}${keySeparator}${k}`);
27181
- } else {
27182
- resultKey = options.keyPrefix ? `${options.keyPrefix}${keySeparator}${key}` : key;
27183
- }
27184
- return _this3.t(resultKey, options);
27185
- };
27186
- if (typeof lng === 'string') {
27187
- fixedT.lng = lng;
27188
- } else {
27189
- fixedT.lngs = lng;
27190
- }
27191
- fixedT.ns = ns;
27192
- fixedT.keyPrefix = keyPrefix;
27193
- return fixedT;
27194
- }
27195
- t() {
27196
- return this.translator && this.translator.translate(...arguments);
27197
- }
27198
- exists() {
27199
- return this.translator && this.translator.exists(...arguments);
27200
- }
27201
- setDefaultNamespace(ns) {
27202
- this.options.defaultNS = ns;
27203
- }
27204
- hasLoadedNamespace(ns) {
27205
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
27206
- if (!this.isInitialized) {
27207
- this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
27208
- return false;
27209
- }
27210
- if (!this.languages || !this.languages.length) {
27211
- this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);
27212
- return false;
27213
- }
27214
- const lng = options.lng || this.resolvedLanguage || this.languages[0];
27215
- const fallbackLng = this.options ? this.options.fallbackLng : false;
27216
- const lastLng = this.languages[this.languages.length - 1];
27217
- if (lng.toLowerCase() === 'cimode') return true;
27218
- const loadNotPending = (l, n) => {
27219
- const loadState = this.services.backendConnector.state[`${l}|${n}`];
27220
- return loadState === -1 || loadState === 2;
27221
- };
27222
- if (options.precheck) {
27223
- const preResult = options.precheck(this, loadNotPending);
27224
- if (preResult !== undefined) return preResult;
27225
- }
27226
- if (this.hasResourceBundle(lng, ns)) return true;
27227
- if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
27228
- if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
27229
- return false;
27230
- }
27231
- loadNamespaces(ns, callback) {
27232
- const deferred = defer();
27233
- if (!this.options.ns) {
27234
- if (callback) callback();
27235
- return Promise.resolve();
27236
- }
27237
- if (typeof ns === 'string') ns = [ns];
27238
- ns.forEach(n => {
27239
- if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
27240
- });
27241
- this.loadResources(err => {
27242
- deferred.resolve();
27243
- if (callback) callback(err);
27244
- });
27245
- return deferred;
27246
- }
27247
- loadLanguages(lngs, callback) {
27248
- const deferred = defer();
27249
- if (typeof lngs === 'string') lngs = [lngs];
27250
- const preloaded = this.options.preload || [];
27251
- const newLngs = lngs.filter(lng => preloaded.indexOf(lng) < 0);
27252
- if (!newLngs.length) {
27253
- if (callback) callback();
27254
- return Promise.resolve();
27255
- }
27256
- this.options.preload = preloaded.concat(newLngs);
27257
- this.loadResources(err => {
27258
- deferred.resolve();
27259
- if (callback) callback(err);
27260
- });
27261
- return deferred;
27262
- }
27263
- dir(lng) {
27264
- if (!lng) lng = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language);
27265
- if (!lng) return 'rtl';
27266
- const 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'];
27267
- const languageUtils = this.services && this.services.languageUtils || new LanguageUtil(get());
27268
- return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
27269
- }
27270
- static createInstance() {
27271
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
27272
- let callback = arguments.length > 1 ? arguments[1] : undefined;
27273
- return new I18n(options, callback);
27274
- }
27275
- cloneInstance() {
27276
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
27277
- let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : i18next_noop;
27278
- const forkResourceStore = options.forkResourceStore;
27279
- if (forkResourceStore) delete options.forkResourceStore;
27280
- const mergedOptions = {
27281
- ...this.options,
27282
- ...options,
27283
- ...{
27284
- isClone: true
27285
- }
27286
- };
27287
- const clone = new I18n(mergedOptions);
27288
- if (options.debug !== undefined || options.prefix !== undefined) {
27289
- clone.logger = clone.logger.clone(options);
27290
- }
27291
- const membersToCopy = ['store', 'services', 'language'];
27292
- membersToCopy.forEach(m => {
27293
- clone[m] = this[m];
27294
- });
27295
- clone.services = {
27296
- ...this.services
27297
- };
27298
- clone.services.utils = {
27299
- hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
27300
- };
27301
- if (forkResourceStore) {
27302
- clone.store = new ResourceStore(this.store.data, mergedOptions);
27303
- clone.services.resourceStore = clone.store;
27304
- }
27305
- clone.translator = new Translator(clone.services, mergedOptions);
27306
- clone.translator.on('*', function (event) {
27307
- for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
27308
- args[_key4 - 1] = arguments[_key4];
27309
- }
27310
- clone.emit(event, ...args);
27311
- });
27312
- clone.init(mergedOptions, callback);
27313
- clone.translator.options = mergedOptions;
27314
- clone.translator.backendConnector.services.utils = {
27315
- hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
27316
- };
27317
- return clone;
27318
- }
27319
- toJSON() {
27320
- return {
27321
- options: this.options,
27322
- store: this.store,
27323
- language: this.language,
27324
- languages: this.languages,
27325
- resolvedLanguage: this.resolvedLanguage
27326
- };
27327
- }
27328
- }
27329
- const instance = I18n.createInstance();
27330
- instance.createInstance = I18n.createInstance;
27331
- const i18next_createInstance = instance.createInstance;
27332
- const dir = instance.dir;
27333
- const init = instance.init;
27334
- const loadResources = instance.loadResources;
27335
- const reloadResources = instance.reloadResources;
27336
- const use = instance.use;
27337
- const changeLanguage = instance.changeLanguage;
27338
- const getFixedT = instance.getFixedT;
27339
- const t = instance.t;
27340
- const exists = instance.exists;
27341
- const setDefaultNamespace = instance.setDefaultNamespace;
27342
- const hasLoadedNamespace = instance.hasLoadedNamespace;
27343
- const loadNamespaces = instance.loadNamespaces;
27344
- const loadLanguages = instance.loadLanguages;
27345
-
27346
- // EXTERNAL MODULE: ./node_modules/i18next-vue/dist/index.js
27347
- var dist = __webpack_require__(9394);
27348
- ;// CONCATENATED MODULE: ./node_modules/i18next-browser-languagedetector/dist/esm/i18nextBrowserLanguageDetector.js
27349
-
27350
-
27351
- var arr = [];
27352
- var each = arr.forEach;
27353
- var slice = arr.slice;
27354
- function i18nextBrowserLanguageDetector_defaults(obj) {
27355
- each.call(slice.call(arguments, 1), function (source) {
27356
- if (source) {
27357
- for (var prop in source) {
27358
- if (obj[prop] === undefined) obj[prop] = source[prop];
27359
- }
27360
- }
27361
- });
27362
- return obj;
27363
- }
27364
-
27365
- // eslint-disable-next-line no-control-regex
27366
- var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
27367
- var serializeCookie = function serializeCookie(name, val, options) {
27368
- var opt = options || {};
27369
- opt.path = opt.path || '/';
27370
- var value = encodeURIComponent(val);
27371
- var str = "".concat(name, "=").concat(value);
27372
- if (opt.maxAge > 0) {
27373
- var maxAge = opt.maxAge - 0;
27374
- if (Number.isNaN(maxAge)) throw new Error('maxAge should be a Number');
27375
- str += "; Max-Age=".concat(Math.floor(maxAge));
27376
- }
27377
- if (opt.domain) {
27378
- if (!fieldContentRegExp.test(opt.domain)) {
27379
- throw new TypeError('option domain is invalid');
27380
- }
27381
- str += "; Domain=".concat(opt.domain);
27382
- }
27383
- if (opt.path) {
27384
- if (!fieldContentRegExp.test(opt.path)) {
27385
- throw new TypeError('option path is invalid');
27386
- }
27387
- str += "; Path=".concat(opt.path);
27388
- }
27389
- if (opt.expires) {
27390
- if (typeof opt.expires.toUTCString !== 'function') {
27391
- throw new TypeError('option expires is invalid');
27392
- }
27393
- str += "; Expires=".concat(opt.expires.toUTCString());
27394
- }
27395
- if (opt.httpOnly) str += '; HttpOnly';
27396
- if (opt.secure) str += '; Secure';
27397
- if (opt.sameSite) {
27398
- var sameSite = typeof opt.sameSite === 'string' ? opt.sameSite.toLowerCase() : opt.sameSite;
27399
- switch (sameSite) {
27400
- case true:
27401
- str += '; SameSite=Strict';
27402
- break;
27403
- case 'lax':
27404
- str += '; SameSite=Lax';
27405
- break;
27406
- case 'strict':
27407
- str += '; SameSite=Strict';
27408
- break;
27409
- case 'none':
27410
- str += '; SameSite=None';
27411
- break;
27412
- default:
27413
- throw new TypeError('option sameSite is invalid');
27414
- }
27415
- }
27416
- return str;
27417
- };
27418
- var cookie = {
27419
- create: function create(name, value, minutes, domain) {
27420
- var cookieOptions = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
27421
- path: '/',
27422
- sameSite: 'strict'
27423
- };
27424
- if (minutes) {
27425
- cookieOptions.expires = new Date();
27426
- cookieOptions.expires.setTime(cookieOptions.expires.getTime() + minutes * 60 * 1000);
27427
- }
27428
- if (domain) cookieOptions.domain = domain;
27429
- document.cookie = serializeCookie(name, encodeURIComponent(value), cookieOptions);
27430
- },
27431
- read: function read(name) {
27432
- var nameEQ = "".concat(name, "=");
27433
- var ca = document.cookie.split(';');
27434
- for (var i = 0; i < ca.length; i++) {
27435
- var c = ca[i];
27436
- while (c.charAt(0) === ' ') {
27437
- c = c.substring(1, c.length);
27438
- }
27439
- if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
27440
- }
27441
- return null;
27442
- },
27443
- remove: function remove(name) {
27444
- this.create(name, '', -1);
27445
- }
27446
- };
27447
- var cookie$1 = {
27448
- name: 'cookie',
27449
- lookup: function lookup(options) {
27450
- var found;
27451
- if (options.lookupCookie && typeof document !== 'undefined') {
27452
- var c = cookie.read(options.lookupCookie);
27453
- if (c) found = c;
27454
- }
27455
- return found;
27456
- },
27457
- cacheUserLanguage: function cacheUserLanguage(lng, options) {
27458
- if (options.lookupCookie && typeof document !== 'undefined') {
27459
- cookie.create(options.lookupCookie, lng, options.cookieMinutes, options.cookieDomain, options.cookieOptions);
27460
- }
27461
- }
27462
- };
27463
- var querystring = {
27464
- name: 'querystring',
27465
- lookup: function lookup(options) {
27466
- var found;
27467
- if (typeof window !== 'undefined') {
27468
- var search = window.location.search;
27469
- if (!window.location.search && window.location.hash && window.location.hash.indexOf('?') > -1) {
27470
- search = window.location.hash.substring(window.location.hash.indexOf('?'));
27471
- }
27472
- var query = search.substring(1);
27473
- var params = query.split('&');
27474
- for (var i = 0; i < params.length; i++) {
27475
- var pos = params[i].indexOf('=');
27476
- if (pos > 0) {
27477
- var key = params[i].substring(0, pos);
27478
- if (key === options.lookupQuerystring) {
27479
- found = params[i].substring(pos + 1);
27480
- }
27481
- }
27482
- }
27483
- }
27484
- return found;
27485
- }
27486
- };
27487
- var hasLocalStorageSupport = null;
27488
- var localStorageAvailable = function localStorageAvailable() {
27489
- if (hasLocalStorageSupport !== null) return hasLocalStorageSupport;
27490
- try {
27491
- hasLocalStorageSupport = window !== 'undefined' && window.localStorage !== null;
27492
- var testKey = 'i18next.translate.boo';
27493
- window.localStorage.setItem(testKey, 'foo');
27494
- window.localStorage.removeItem(testKey);
27495
- } catch (e) {
27496
- hasLocalStorageSupport = false;
27497
- }
27498
- return hasLocalStorageSupport;
27499
- };
27500
- var localStorage = {
27501
- name: 'localStorage',
27502
- lookup: function lookup(options) {
27503
- var found;
27504
- if (options.lookupLocalStorage && localStorageAvailable()) {
27505
- var lng = window.localStorage.getItem(options.lookupLocalStorage);
27506
- if (lng) found = lng;
27507
- }
27508
- return found;
27509
- },
27510
- cacheUserLanguage: function cacheUserLanguage(lng, options) {
27511
- if (options.lookupLocalStorage && localStorageAvailable()) {
27512
- window.localStorage.setItem(options.lookupLocalStorage, lng);
27513
- }
27514
- }
27515
- };
27516
- var hasSessionStorageSupport = null;
27517
- var sessionStorageAvailable = function sessionStorageAvailable() {
27518
- if (hasSessionStorageSupport !== null) return hasSessionStorageSupport;
27519
- try {
27520
- hasSessionStorageSupport = window !== 'undefined' && window.sessionStorage !== null;
27521
- var testKey = 'i18next.translate.boo';
27522
- window.sessionStorage.setItem(testKey, 'foo');
27523
- window.sessionStorage.removeItem(testKey);
27524
- } catch (e) {
27525
- hasSessionStorageSupport = false;
27526
- }
27527
- return hasSessionStorageSupport;
27528
- };
27529
- var i18nextBrowserLanguageDetector_sessionStorage = {
27530
- name: 'sessionStorage',
27531
- lookup: function lookup(options) {
27532
- var found;
27533
- if (options.lookupSessionStorage && sessionStorageAvailable()) {
27534
- var lng = window.sessionStorage.getItem(options.lookupSessionStorage);
27535
- if (lng) found = lng;
27536
- }
27537
- return found;
27538
- },
27539
- cacheUserLanguage: function cacheUserLanguage(lng, options) {
27540
- if (options.lookupSessionStorage && sessionStorageAvailable()) {
27541
- window.sessionStorage.setItem(options.lookupSessionStorage, lng);
27542
- }
27543
- }
27544
- };
27545
- var navigator$1 = {
27546
- name: 'navigator',
27547
- lookup: function lookup(options) {
27548
- var found = [];
27549
- if (typeof navigator !== 'undefined') {
27550
- if (navigator.languages) {
27551
- // chrome only; not an array, so can't use .push.apply instead of iterating
27552
- for (var i = 0; i < navigator.languages.length; i++) {
27553
- found.push(navigator.languages[i]);
27554
- }
27555
- }
27556
- if (navigator.userLanguage) {
27557
- found.push(navigator.userLanguage);
27558
- }
27559
- if (navigator.language) {
27560
- found.push(navigator.language);
27561
- }
27562
- }
27563
- return found.length > 0 ? found : undefined;
27564
- }
27565
- };
27566
- var htmlTag = {
27567
- name: 'htmlTag',
27568
- lookup: function lookup(options) {
27569
- var found;
27570
- var htmlTag = options.htmlTag || (typeof document !== 'undefined' ? document.documentElement : null);
27571
- if (htmlTag && typeof htmlTag.getAttribute === 'function') {
27572
- found = htmlTag.getAttribute('lang');
27573
- }
27574
- return found;
27575
- }
27576
- };
27577
- var path = {
27578
- name: 'path',
27579
- lookup: function lookup(options) {
27580
- var found;
27581
- if (typeof window !== 'undefined') {
27582
- var language = window.location.pathname.match(/\/([a-zA-Z-]*)/g);
27583
- if (language instanceof Array) {
27584
- if (typeof options.lookupFromPathIndex === 'number') {
27585
- if (typeof language[options.lookupFromPathIndex] !== 'string') {
27586
- return undefined;
27587
- }
27588
- found = language[options.lookupFromPathIndex].replace('/', '');
27589
- } else {
27590
- found = language[0].replace('/', '');
27591
- }
27592
- }
27593
- }
27594
- return found;
27595
- }
27596
- };
27597
- var subdomain = {
27598
- name: 'subdomain',
27599
- lookup: function lookup(options) {
27600
- // If given get the subdomain index else 1
27601
- var lookupFromSubdomainIndex = typeof options.lookupFromSubdomainIndex === 'number' ? options.lookupFromSubdomainIndex + 1 : 1;
27602
- // get all matches if window.location. is existing
27603
- // first item of match is the match itself and the second is the first group macht which sould be the first subdomain match
27604
- // is the hostname no public domain get the or option of localhost
27605
- var language = typeof window !== 'undefined' && window.location && window.location.hostname && window.location.hostname.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);
27606
-
27607
- // if there is no match (null) return undefined
27608
- if (!language) return undefined;
27609
- // return the given group match
27610
- return language[lookupFromSubdomainIndex];
27611
- }
27612
- };
27613
- function getDefaults() {
27614
- return {
27615
- order: ['querystring', 'cookie', 'localStorage', 'sessionStorage', 'navigator', 'htmlTag'],
27616
- lookupQuerystring: 'lng',
27617
- lookupCookie: 'i18next',
27618
- lookupLocalStorage: 'i18nextLng',
27619
- lookupSessionStorage: 'i18nextLng',
27620
- // cache user language
27621
- caches: ['localStorage'],
27622
- excludeCacheFor: ['cimode'],
27623
- // cookieMinutes: 10,
27624
- // cookieDomain: 'myDomain'
27625
-
27626
- convertDetectedLanguage: function convertDetectedLanguage(l) {
27627
- return l;
27628
- }
27629
- };
27630
- }
27631
- var Browser = /*#__PURE__*/function () {
27632
- function Browser(services) {
27633
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
27634
- _classCallCheck(this, Browser);
27635
- this.type = 'languageDetector';
27636
- this.detectors = {};
27637
- this.init(services, options);
27638
- }
27639
- _createClass(Browser, [{
27640
- key: "init",
27641
- value: function init(services) {
27642
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
27643
- var i18nOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
27644
- this.services = services || {
27645
- languageUtils: {}
27646
- }; // this way the language detector can be used without i18next
27647
- this.options = i18nextBrowserLanguageDetector_defaults(options, this.options || {}, getDefaults());
27648
- if (typeof this.options.convertDetectedLanguage === 'string' && this.options.convertDetectedLanguage.indexOf('15897') > -1) {
27649
- this.options.convertDetectedLanguage = function (l) {
27650
- return l.replace('-', '_');
27651
- };
27652
- }
27653
-
27654
- // backwards compatibility
27655
- if (this.options.lookupFromUrlIndex) this.options.lookupFromPathIndex = this.options.lookupFromUrlIndex;
27656
- this.i18nOptions = i18nOptions;
27657
- this.addDetector(cookie$1);
27658
- this.addDetector(querystring);
27659
- this.addDetector(localStorage);
27660
- this.addDetector(i18nextBrowserLanguageDetector_sessionStorage);
27661
- this.addDetector(navigator$1);
27662
- this.addDetector(htmlTag);
27663
- this.addDetector(path);
27664
- this.addDetector(subdomain);
27665
- }
27666
- }, {
27667
- key: "addDetector",
27668
- value: function addDetector(detector) {
27669
- this.detectors[detector.name] = detector;
27670
- }
27671
- }, {
27672
- key: "detect",
27673
- value: function detect(detectionOrder) {
27674
- var _this = this;
27675
- if (!detectionOrder) detectionOrder = this.options.order;
27676
- var detected = [];
27677
- detectionOrder.forEach(function (detectorName) {
27678
- if (_this.detectors[detectorName]) {
27679
- var lookup = _this.detectors[detectorName].lookup(_this.options);
27680
- if (lookup && typeof lookup === 'string') lookup = [lookup];
27681
- if (lookup) detected = detected.concat(lookup);
27682
- }
27683
- });
27684
- detected = detected.map(function (d) {
27685
- return _this.options.convertDetectedLanguage(d);
27686
- });
27687
- if (this.services.languageUtils.getBestMatchFromCodes) return detected; // new i18next v19.5.0
27688
- return detected.length > 0 ? detected[0] : null; // a little backward compatibility
27689
- }
27690
- }, {
27691
- key: "cacheUserLanguage",
27692
- value: function cacheUserLanguage(lng, caches) {
27693
- var _this2 = this;
27694
- if (!caches) caches = this.options.caches;
27695
- if (!caches) return;
27696
- if (this.options.excludeCacheFor && this.options.excludeCacheFor.indexOf(lng) > -1) return;
27697
- caches.forEach(function (cacheName) {
27698
- if (_this2.detectors[cacheName]) _this2.detectors[cacheName].cacheUserLanguage(lng, _this2.options);
27699
- });
27700
- }
27701
- }]);
27702
- return Browser;
27703
- }();
27704
- Browser.type = 'languageDetector';
27705
-
27706
- ;// CONCATENATED MODULE: ./src/assets/locales/en-GB.js
27707
- /* harmony default export */ var en_GB = ({
27708
- translation: {
27709
- infoBar: {
27710
- selected: 'Selected {seconds}s: < {hour_ini} - {hour_end} >',
27711
- interval: 'Interval: {seconds}s',
27712
- time: 'Time: {time}',
27713
- block: 'Block: {time1} - {time2}',
27714
- alternativeServer: 'Alternative server',
27715
- changeServer: 'Change server of frames'
27716
- }
27717
- }
27718
- });
27719
- ;// CONCATENATED MODULE: ./src/assets/locales/pt-PT.js
27720
- /* harmony default export */ var pt_PT = ({
27721
- translation: {
27722
- infoBar: {
27723
- selected: 'Selecionados {{seconds}}s: < {{hour_ini}} - {{hour_end}} >',
27724
- interval: 'Intervalo: {{seconds}}s',
27725
- time: 'Tempo: {{time}}',
27726
- block: 'Bloco: {{time1}} - {{time2}}',
27727
- alternativeServer: 'Servidor alternativo',
27728
- changeServer: 'Trocar de servidor de frames'
27729
- }
27730
- }
27731
- });
27732
- ;// CONCATENATED MODULE: ./src/index.js
27733
-
27734
-
27735
-
27736
-
27737
-
27738
-
27739
-
27740
-
27741
-
27742
-
27743
-
27744
- /* harmony default export */ var src_0 = ({
27745
- install(Vue) {
27746
- let settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
27747
- if (!settings.client || !settings.base_url || !settings.theme?.primary) {
27748
- console.error('Visualization: Missing required settings');
27749
- return;
27750
- }
27751
- if (this.installed) {
27752
- return;
27753
- }
27754
- this.installed = true;
27755
- Vue.use(dist/* default */.Z, {
27756
- i18next: instance
27757
- });
27758
- instance.on('initialized', () => {
27759
- Vue.use(v_tooltip_esm);
27760
- Vue.use(v_mask_esm_plugin);
27761
- assets_icons();
27762
- Vue.component('font-awesome-icon', FontAwesomeIcon);
27763
- sessionStorage.setItem('server', 'principal');
27764
- sessionStorage.setItem('client', settings.client);
27765
- sessionStorage.setItem('base_url', settings.base_url);
27766
- const headTag = document.getElementsByTagName('head')[0];
27767
- const styleTag = document.createElement('style');
27768
- const theme = {
27769
- primary: settings.theme.primary,
27770
- secondary: colorVariation(settings.theme.primary),
27771
- start: settings.theme.start || '#4caf50',
27772
- end: settings.theme.end || '#ff5252'
27773
- };
27774
- let themeCss = [];
27775
- for (const color in theme) {
27776
- themeCss.push(`--visualization-${color}: ${theme[color]};`);
27777
- }
27778
- themeCss = [':root {', ...themeCss, '}'].join(' ');
27779
- styleTag.innerHTML = themeCss;
27780
- headTag.appendChild(styleTag);
27781
- Vue.component('Visualization', Visualization);
27782
- });
27783
- instance.use(Browser).init({
27784
- debug: true,
27785
- fallbackLng: 'en',
27786
- resources: {
27787
- en: en_GB,
27788
- 'pt-PT': pt_PT
27789
- }
27790
- });
24943
+ let themeCss = [];
24944
+ for (const color in theme) {
24945
+ themeCss.push(`--visualization-${color}: ${theme[color]};`);
24946
+ }
24947
+ themeCss = [':root {', ...themeCss, '}'].join(' ');
24948
+ styleTag.innerHTML = themeCss;
24949
+ headTag.appendChild(styleTag);
24950
+ Vue.component('Visualization', Visualization);
24951
+ // })
24952
+
24953
+ // i18next.use(LanguageDetector).init({
24954
+ // debug: true,
24955
+ // fallbackLng: 'en',
24956
+ // resources: {
24957
+ // en: en,
24958
+ // 'pt-PT': pt,
24959
+ // },
24960
+ // })
27791
24961
  }
27792
24962
  });
27793
24963
  ;// CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-lib.js