@formio/js 5.0.0-rc.14 → 5.0.0-rc.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -2827,7 +2827,7 @@ eval("var __WEBPACK_AMD_DEFINE_RESULT__;(function (global) {\n 'use strict';\n\
2827
2827
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
2828
2828
 
2829
2829
  "use strict";
2830
- eval("\n\nvar _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ \"./node_modules/@babel/runtime/helpers/typeof.js\");\nvar _classCallCheck = __webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ \"./node_modules/@babel/runtime/helpers/classCallCheck.js\");\nvar _createClass = __webpack_require__(/*! @babel/runtime/helpers/createClass */ \"./node_modules/@babel/runtime/helpers/createClass.js\");\nvar _assertThisInitialized = __webpack_require__(/*! @babel/runtime/helpers/assertThisInitialized */ \"./node_modules/@babel/runtime/helpers/assertThisInitialized.js\");\nvar _inherits = __webpack_require__(/*! @babel/runtime/helpers/inherits */ \"./node_modules/@babel/runtime/helpers/inherits.js\");\nvar _possibleConstructorReturn = __webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ \"./node_modules/@babel/runtime/helpers/possibleConstructorReturn.js\");\nvar _getPrototypeOf = __webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ \"./node_modules/@babel/runtime/helpers/getPrototypeOf.js\");\nvar _defineProperty = __webpack_require__(/*! @babel/runtime/helpers/defineProperty */ \"./node_modules/@babel/runtime/helpers/defineProperty.js\");\nvar _toArray = __webpack_require__(/*! @babel/runtime/helpers/toArray */ \"./node_modules/@babel/runtime/helpers/toArray.js\");\n\nfunction _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }\n\nvar _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);\nvar _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallCheck);\nvar _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass);\nvar _assertThisInitialized__default = /*#__PURE__*/_interopDefaultLegacy(_assertThisInitialized);\nvar _inherits__default = /*#__PURE__*/_interopDefaultLegacy(_inherits);\nvar _possibleConstructorReturn__default = /*#__PURE__*/_interopDefaultLegacy(_possibleConstructorReturn);\nvar _getPrototypeOf__default = /*#__PURE__*/_interopDefaultLegacy(_getPrototypeOf);\nvar _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);\nvar _toArray__default = /*#__PURE__*/_interopDefaultLegacy(_toArray);\n\nfunction ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) { _defineProperty__default[\"default\"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nvar consoleLogger = {\n type: 'logger',\n log: function log(args) {\n this.output('log', args);\n },\n warn: function warn(args) {\n this.output('warn', args);\n },\n error: function error(args) {\n this.output('error', args);\n },\n output: function output(type, args) {\n if (console && console[type]) console[type].apply(console, args);\n }\n};\nvar Logger = function () {\n function Logger(concreteLogger) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n _classCallCheck__default[\"default\"](this, Logger);\n this.init(concreteLogger, options);\n }\n _createClass__default[\"default\"](Logger, [{\n key: \"init\",\n value: function init(concreteLogger) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n this.prefix = options.prefix || 'i18next:';\n this.logger = concreteLogger || consoleLogger;\n this.options = options;\n this.debug = options.debug;\n }\n }, {\n key: \"setDebug\",\n value: function setDebug(bool) {\n this.debug = bool;\n }\n }, {\n key: \"log\",\n value: function log() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n return this.forward(args, 'log', '', true);\n }\n }, {\n key: \"warn\",\n value: function warn() {\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n return this.forward(args, 'warn', '', true);\n }\n }, {\n key: \"error\",\n value: function error() {\n for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n args[_key3] = arguments[_key3];\n }\n return this.forward(args, 'error', '');\n }\n }, {\n key: \"deprecate\",\n value: function deprecate() {\n for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n args[_key4] = arguments[_key4];\n }\n return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);\n }\n }, {\n key: \"forward\",\n value: function forward(args, lvl, prefix, debugOnly) {\n if (debugOnly && !this.debug) return null;\n if (typeof args[0] === 'string') args[0] = \"\".concat(prefix).concat(this.prefix, \" \").concat(args[0]);\n return this.logger[lvl](args);\n }\n }, {\n key: \"create\",\n value: function create(moduleName) {\n return new Logger(this.logger, _objectSpread$6(_objectSpread$6({}, {\n prefix: \"\".concat(this.prefix, \":\").concat(moduleName, \":\")\n }), this.options));\n }\n }, {\n key: \"clone\",\n value: function clone(options) {\n options = options || this.options;\n options.prefix = options.prefix || this.prefix;\n return new Logger(this.logger, options);\n }\n }]);\n return Logger;\n}();\nvar baseLogger = new Logger();\n\nvar EventEmitter = function () {\n function EventEmitter() {\n _classCallCheck__default[\"default\"](this, EventEmitter);\n this.observers = {};\n }\n _createClass__default[\"default\"](EventEmitter, [{\n key: \"on\",\n value: function on(events, listener) {\n var _this = this;\n events.split(' ').forEach(function (event) {\n _this.observers[event] = _this.observers[event] || [];\n _this.observers[event].push(listener);\n });\n return this;\n }\n }, {\n key: \"off\",\n value: function off(event, listener) {\n if (!this.observers[event]) return;\n if (!listener) {\n delete this.observers[event];\n return;\n }\n this.observers[event] = this.observers[event].filter(function (l) {\n return l !== listener;\n });\n }\n }, {\n key: \"emit\",\n value: function emit(event) {\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n if (this.observers[event]) {\n var cloned = [].concat(this.observers[event]);\n cloned.forEach(function (observer) {\n observer.apply(void 0, args);\n });\n }\n if (this.observers['*']) {\n var _cloned = [].concat(this.observers['*']);\n _cloned.forEach(function (observer) {\n observer.apply(observer, [event].concat(args));\n });\n }\n }\n }]);\n return EventEmitter;\n}();\n\nfunction defer() {\n var res;\n var rej;\n var promise = new Promise(function (resolve, reject) {\n res = resolve;\n rej = reject;\n });\n promise.resolve = res;\n promise.reject = rej;\n return promise;\n}\nfunction makeString(object) {\n if (object == null) return '';\n return '' + object;\n}\nfunction copy(a, s, t) {\n a.forEach(function (m) {\n if (s[m]) t[m] = s[m];\n });\n}\nfunction getLastOfPath(object, path, Empty) {\n function cleanKey(key) {\n return key && key.indexOf('###') > -1 ? key.replace(/###/g, '.') : key;\n }\n function canNotTraverseDeeper() {\n return !object || typeof object === 'string';\n }\n var stack = typeof path !== 'string' ? [].concat(path) : path.split('.');\n while (stack.length > 1) {\n if (canNotTraverseDeeper()) return {};\n var key = cleanKey(stack.shift());\n if (!object[key] && Empty) object[key] = new Empty();\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n object = object[key];\n } else {\n object = {};\n }\n }\n if (canNotTraverseDeeper()) return {};\n return {\n obj: object,\n k: cleanKey(stack.shift())\n };\n}\nfunction setPath(object, path, newValue) {\n var _getLastOfPath = getLastOfPath(object, path, Object),\n obj = _getLastOfPath.obj,\n k = _getLastOfPath.k;\n obj[k] = newValue;\n}\nfunction pushPath(object, path, newValue, concat) {\n var _getLastOfPath2 = getLastOfPath(object, path, Object),\n obj = _getLastOfPath2.obj,\n k = _getLastOfPath2.k;\n obj[k] = obj[k] || [];\n if (concat) obj[k] = obj[k].concat(newValue);\n if (!concat) obj[k].push(newValue);\n}\nfunction getPath(object, path) {\n var _getLastOfPath3 = getLastOfPath(object, path),\n obj = _getLastOfPath3.obj,\n k = _getLastOfPath3.k;\n if (!obj) return undefined;\n return obj[k];\n}\nfunction getPathWithDefaults(data, defaultData, key) {\n var value = getPath(data, key);\n if (value !== undefined) {\n return value;\n }\n return getPath(defaultData, key);\n}\nfunction deepExtend(target, source, overwrite) {\n for (var prop in source) {\n if (prop !== '__proto__' && prop !== 'constructor') {\n if (prop in target) {\n if (typeof target[prop] === 'string' || target[prop] instanceof String || typeof source[prop] === 'string' || source[prop] instanceof String) {\n if (overwrite) target[prop] = source[prop];\n } else {\n deepExtend(target[prop], source[prop], overwrite);\n }\n } else {\n target[prop] = source[prop];\n }\n }\n }\n return target;\n}\nfunction regexEscape(str) {\n return str.replace(/[\\-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, '\\\\$&');\n}\nvar _entityMap = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\"': '&quot;',\n \"'\": '&#39;',\n '/': '&#x2F;'\n};\nfunction escape(data) {\n if (typeof data === 'string') {\n return data.replace(/[&<>\"'\\/]/g, function (s) {\n return _entityMap[s];\n });\n }\n return data;\n}\nvar isIE10 = typeof window !== 'undefined' && window.navigator && typeof window.navigator.userAgentData === 'undefined' && window.navigator.userAgent && window.navigator.userAgent.indexOf('MSIE') > -1;\nvar chars = [' ', ',', '?', '!', ';'];\nfunction looksLikeObjectPath(key, nsSeparator, keySeparator) {\n nsSeparator = nsSeparator || '';\n keySeparator = keySeparator || '';\n var possibleChars = chars.filter(function (c) {\n return nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0;\n });\n if (possibleChars.length === 0) return true;\n var r = new RegExp(\"(\".concat(possibleChars.map(function (c) {\n return c === '?' ? '\\\\?' : c;\n }).join('|'), \")\"));\n var matched = !r.test(key);\n if (!matched) {\n var ki = key.indexOf(keySeparator);\n if (ki > 0 && !r.test(key.substring(0, ki))) {\n matched = true;\n }\n }\n return matched;\n}\n\nfunction ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty__default[\"default\"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$3(); return function _createSuperInternal() { var Super = _getPrototypeOf__default[\"default\"](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default[\"default\"](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default[\"default\"](this, result); }; }\nfunction _isNativeReflectConstruct$3() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction deepFind(obj, path) {\n var keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';\n if (!obj) return undefined;\n if (obj[path]) return obj[path];\n var paths = path.split(keySeparator);\n var current = obj;\n for (var i = 0; i < paths.length; ++i) {\n if (!current) return undefined;\n if (typeof current[paths[i]] === 'string' && i + 1 < paths.length) {\n return undefined;\n }\n if (current[paths[i]] === undefined) {\n var j = 2;\n var p = paths.slice(i, i + j).join(keySeparator);\n var mix = current[p];\n while (mix === undefined && paths.length > i + j) {\n j++;\n p = paths.slice(i, i + j).join(keySeparator);\n mix = current[p];\n }\n if (mix === undefined) return undefined;\n if (mix === null) return null;\n if (path.endsWith(p)) {\n if (typeof mix === 'string') return mix;\n if (p && typeof mix[p] === 'string') return mix[p];\n }\n var joinedPath = paths.slice(i + j).join(keySeparator);\n if (joinedPath) return deepFind(mix, joinedPath, keySeparator);\n return undefined;\n }\n current = current[paths[i]];\n }\n return current;\n}\nvar ResourceStore = function (_EventEmitter) {\n _inherits__default[\"default\"](ResourceStore, _EventEmitter);\n var _super = _createSuper$3(ResourceStore);\n function ResourceStore(data) {\n var _this;\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {\n ns: ['translation'],\n defaultNS: 'translation'\n };\n _classCallCheck__default[\"default\"](this, ResourceStore);\n _this = _super.call(this);\n if (isIE10) {\n EventEmitter.call(_assertThisInitialized__default[\"default\"](_this));\n }\n _this.data = data || {};\n _this.options = options;\n if (_this.options.keySeparator === undefined) {\n _this.options.keySeparator = '.';\n }\n if (_this.options.ignoreJSONStructure === undefined) {\n _this.options.ignoreJSONStructure = true;\n }\n return _this;\n }\n _createClass__default[\"default\"](ResourceStore, [{\n key: \"addNamespaces\",\n value: function addNamespaces(ns) {\n if (this.options.ns.indexOf(ns) < 0) {\n this.options.ns.push(ns);\n }\n }\n }, {\n key: \"removeNamespaces\",\n value: function removeNamespaces(ns) {\n var index = this.options.ns.indexOf(ns);\n if (index > -1) {\n this.options.ns.splice(index, 1);\n }\n }\n }, {\n key: \"getResource\",\n value: function getResource(lng, ns, key) {\n var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;\n var ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;\n var path = [lng, ns];\n if (key && typeof key !== 'string') path = path.concat(key);\n if (key && typeof key === 'string') path = path.concat(keySeparator ? key.split(keySeparator) : key);\n if (lng.indexOf('.') > -1) {\n path = lng.split('.');\n }\n var result = getPath(this.data, path);\n if (result || !ignoreJSONStructure || typeof key !== 'string') return result;\n return deepFind(this.data && this.data[lng] && this.data[lng][ns], key, keySeparator);\n }\n }, {\n key: \"addResource\",\n value: function addResource(lng, ns, key, value) {\n var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {\n silent: false\n };\n var keySeparator = this.options.keySeparator;\n if (keySeparator === undefined) keySeparator = '.';\n var path = [lng, ns];\n if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);\n if (lng.indexOf('.') > -1) {\n path = lng.split('.');\n value = ns;\n ns = path[1];\n }\n this.addNamespaces(ns);\n setPath(this.data, path, value);\n if (!options.silent) this.emit('added', lng, ns, key, value);\n }\n }, {\n key: \"addResources\",\n value: function addResources(lng, ns, resources) {\n var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {\n silent: false\n };\n for (var m in resources) {\n if (typeof resources[m] === 'string' || Object.prototype.toString.apply(resources[m]) === '[object Array]') this.addResource(lng, ns, m, resources[m], {\n silent: true\n });\n }\n if (!options.silent) this.emit('added', lng, ns, resources);\n }\n }, {\n key: \"addResourceBundle\",\n value: function addResourceBundle(lng, ns, resources, deep, overwrite) {\n var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {\n silent: false\n };\n var path = [lng, ns];\n if (lng.indexOf('.') > -1) {\n path = lng.split('.');\n deep = resources;\n resources = ns;\n ns = path[1];\n }\n this.addNamespaces(ns);\n var pack = getPath(this.data, path) || {};\n if (deep) {\n deepExtend(pack, resources, overwrite);\n } else {\n pack = _objectSpread$5(_objectSpread$5({}, pack), resources);\n }\n setPath(this.data, path, pack);\n if (!options.silent) this.emit('added', lng, ns, resources);\n }\n }, {\n key: \"removeResourceBundle\",\n value: function removeResourceBundle(lng, ns) {\n if (this.hasResourceBundle(lng, ns)) {\n delete this.data[lng][ns];\n }\n this.removeNamespaces(ns);\n this.emit('removed', lng, ns);\n }\n }, {\n key: \"hasResourceBundle\",\n value: function hasResourceBundle(lng, ns) {\n return this.getResource(lng, ns) !== undefined;\n }\n }, {\n key: \"getResourceBundle\",\n value: function getResourceBundle(lng, ns) {\n if (!ns) ns = this.options.defaultNS;\n if (this.options.compatibilityAPI === 'v1') return _objectSpread$5(_objectSpread$5({}, {}), this.getResource(lng, ns));\n return this.getResource(lng, ns);\n }\n }, {\n key: \"getDataByLanguage\",\n value: function getDataByLanguage(lng) {\n return this.data[lng];\n }\n }, {\n key: \"hasLanguageSomeTranslations\",\n value: function hasLanguageSomeTranslations(lng) {\n var data = this.getDataByLanguage(lng);\n var n = data && Object.keys(data) || [];\n return !!n.find(function (v) {\n return data[v] && Object.keys(data[v]).length > 0;\n });\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n return this.data;\n }\n }]);\n return ResourceStore;\n}(EventEmitter);\n\nvar postProcessor = {\n processors: {},\n addPostProcessor: function addPostProcessor(module) {\n this.processors[module.name] = module;\n },\n handle: function handle(processors, value, key, options, translator) {\n var _this = this;\n processors.forEach(function (processor) {\n if (_this.processors[processor]) value = _this.processors[processor].process(value, key, options, translator);\n });\n return value;\n }\n};\n\nfunction ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty__default[\"default\"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { var Super = _getPrototypeOf__default[\"default\"](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default[\"default\"](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default[\"default\"](this, result); }; }\nfunction _isNativeReflectConstruct$2() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nvar checkedLoadedFor = {};\nvar Translator = function (_EventEmitter) {\n _inherits__default[\"default\"](Translator, _EventEmitter);\n var _super = _createSuper$2(Translator);\n function Translator(services) {\n var _this;\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n _classCallCheck__default[\"default\"](this, Translator);\n _this = _super.call(this);\n if (isIE10) {\n EventEmitter.call(_assertThisInitialized__default[\"default\"](_this));\n }\n copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, _assertThisInitialized__default[\"default\"](_this));\n _this.options = options;\n if (_this.options.keySeparator === undefined) {\n _this.options.keySeparator = '.';\n }\n _this.logger = baseLogger.create('translator');\n return _this;\n }\n _createClass__default[\"default\"](Translator, [{\n key: \"changeLanguage\",\n value: function changeLanguage(lng) {\n if (lng) this.language = lng;\n }\n }, {\n key: \"exists\",\n value: function exists(key) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {\n interpolation: {}\n };\n if (key === undefined || key === null) {\n return false;\n }\n var resolved = this.resolve(key, options);\n return resolved && resolved.res !== undefined;\n }\n }, {\n key: \"extractFromKey\",\n value: function extractFromKey(key, options) {\n var nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;\n if (nsSeparator === undefined) nsSeparator = ':';\n var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;\n var namespaces = options.ns || this.options.defaultNS || [];\n var wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;\n var seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);\n if (wouldCheckForNsInKey && !seemsNaturalLanguage) {\n var m = key.match(this.interpolator.nestingRegexp);\n if (m && m.length > 0) {\n return {\n key: key,\n namespaces: namespaces\n };\n }\n var parts = key.split(nsSeparator);\n if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();\n key = parts.join(keySeparator);\n }\n if (typeof namespaces === 'string') namespaces = [namespaces];\n return {\n key: key,\n namespaces: namespaces\n };\n }\n }, {\n key: \"translate\",\n value: function translate(keys, options, lastKey) {\n var _this2 = this;\n if (_typeof__default[\"default\"](options) !== 'object' && this.options.overloadTranslationOptionHandler) {\n options = this.options.overloadTranslationOptionHandler(arguments);\n }\n if (!options) options = {};\n if (keys === undefined || keys === null) return '';\n if (!Array.isArray(keys)) keys = [String(keys)];\n var returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;\n var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;\n var _this$extractFromKey = this.extractFromKey(keys[keys.length - 1], options),\n key = _this$extractFromKey.key,\n namespaces = _this$extractFromKey.namespaces;\n var namespace = namespaces[namespaces.length - 1];\n var lng = options.lng || this.language;\n var appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;\n if (lng && lng.toLowerCase() === 'cimode') {\n if (appendNamespaceToCIMode) {\n var nsSeparator = options.nsSeparator || this.options.nsSeparator;\n if (returnDetails) {\n return {\n res: \"\".concat(namespace).concat(nsSeparator).concat(key),\n usedKey: key,\n exactUsedKey: key,\n usedLng: lng,\n usedNS: namespace\n };\n }\n return \"\".concat(namespace).concat(nsSeparator).concat(key);\n }\n if (returnDetails) {\n return {\n res: key,\n usedKey: key,\n exactUsedKey: key,\n usedLng: lng,\n usedNS: namespace\n };\n }\n return key;\n }\n var resolved = this.resolve(keys, options);\n var res = resolved && resolved.res;\n var resUsedKey = resolved && resolved.usedKey || key;\n var resExactUsedKey = resolved && resolved.exactUsedKey || key;\n var resType = Object.prototype.toString.apply(res);\n var noObject = ['[object Number]', '[object Function]', '[object RegExp]'];\n var joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;\n var handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;\n var handleAsObject = typeof res !== 'string' && typeof res !== 'boolean' && typeof res !== 'number';\n if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(typeof joinArrays === 'string' && resType === '[object Array]')) {\n if (!options.returnObjects && !this.options.returnObjects) {\n if (!this.options.returnedObjectHandler) {\n this.logger.warn('accessing an object - but returnObjects options is not enabled!');\n }\n var r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, _objectSpread$4(_objectSpread$4({}, options), {}, {\n ns: namespaces\n })) : \"key '\".concat(key, \" (\").concat(this.language, \")' returned an object instead of string.\");\n if (returnDetails) {\n resolved.res = r;\n return resolved;\n }\n return r;\n }\n if (keySeparator) {\n var resTypeIsArray = resType === '[object Array]';\n var copy = resTypeIsArray ? [] : {};\n var newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;\n for (var m in res) {\n if (Object.prototype.hasOwnProperty.call(res, m)) {\n var deepKey = \"\".concat(newKeyToUse).concat(keySeparator).concat(m);\n copy[m] = this.translate(deepKey, _objectSpread$4(_objectSpread$4({}, options), {\n joinArrays: false,\n ns: namespaces\n }));\n if (copy[m] === deepKey) copy[m] = res[m];\n }\n }\n res = copy;\n }\n } else if (handleAsObjectInI18nFormat && typeof joinArrays === 'string' && resType === '[object Array]') {\n res = res.join(joinArrays);\n if (res) res = this.extendTranslation(res, keys, options, lastKey);\n } else {\n var usedDefault = false;\n var usedKey = false;\n var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';\n var hasDefaultValue = Translator.hasDefaultValue(options);\n var defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';\n var defaultValue = options[\"defaultValue\".concat(defaultValueSuffix)] || options.defaultValue;\n if (!this.isValidLookup(res) && hasDefaultValue) {\n usedDefault = true;\n res = defaultValue;\n }\n if (!this.isValidLookup(res)) {\n usedKey = true;\n res = key;\n }\n var missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;\n var resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;\n var updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;\n if (usedKey || usedDefault || updateMissing) {\n this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);\n if (keySeparator) {\n var fk = this.resolve(key, _objectSpread$4(_objectSpread$4({}, options), {}, {\n keySeparator: false\n }));\n 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.');\n }\n var lngs = [];\n var fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);\n if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {\n for (var i = 0; i < fallbackLngs.length; i++) {\n lngs.push(fallbackLngs[i]);\n }\n } else if (this.options.saveMissingTo === 'all') {\n lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);\n } else {\n lngs.push(options.lng || this.language);\n }\n var send = function send(l, k, specificDefaultValue) {\n var defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;\n if (_this2.options.missingKeyHandler) {\n _this2.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);\n } else if (_this2.backendConnector && _this2.backendConnector.saveMissing) {\n _this2.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);\n }\n _this2.emit('missingKey', l, namespace, k, res);\n };\n if (this.options.saveMissing) {\n if (this.options.saveMissingPlurals && needsPluralHandling) {\n lngs.forEach(function (language) {\n _this2.pluralResolver.getSuffixes(language, options).forEach(function (suffix) {\n send([language], key + suffix, options[\"defaultValue\".concat(suffix)] || defaultValue);\n });\n });\n } else {\n send(lngs, key, defaultValue);\n }\n }\n }\n res = this.extendTranslation(res, keys, options, resolved, lastKey);\n if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = \"\".concat(namespace, \":\").concat(key);\n if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {\n if (this.options.compatibilityAPI !== 'v1') {\n res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? \"\".concat(namespace, \":\").concat(key) : key, usedDefault ? res : undefined);\n } else {\n res = this.options.parseMissingKeyHandler(res);\n }\n }\n }\n if (returnDetails) {\n resolved.res = res;\n return resolved;\n }\n return res;\n }\n }, {\n key: \"extendTranslation\",\n value: function extendTranslation(res, key, options, resolved, lastKey) {\n var _this3 = this;\n if (this.i18nFormat && this.i18nFormat.parse) {\n res = this.i18nFormat.parse(res, _objectSpread$4(_objectSpread$4({}, this.options.interpolation.defaultVariables), options), resolved.usedLng, resolved.usedNS, resolved.usedKey, {\n resolved: resolved\n });\n } else if (!options.skipInterpolation) {\n if (options.interpolation) this.interpolator.init(_objectSpread$4(_objectSpread$4({}, options), {\n interpolation: _objectSpread$4(_objectSpread$4({}, this.options.interpolation), options.interpolation)\n }));\n var skipOnVariables = typeof res === 'string' && (options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);\n var nestBef;\n if (skipOnVariables) {\n var nb = res.match(this.interpolator.nestingRegexp);\n nestBef = nb && nb.length;\n }\n var data = options.replace && typeof options.replace !== 'string' ? options.replace : options;\n if (this.options.interpolation.defaultVariables) data = _objectSpread$4(_objectSpread$4({}, this.options.interpolation.defaultVariables), data);\n res = this.interpolator.interpolate(res, data, options.lng || this.language, options);\n if (skipOnVariables) {\n var na = res.match(this.interpolator.nestingRegexp);\n var nestAft = na && na.length;\n if (nestBef < nestAft) options.nest = false;\n }\n if (options.nest !== false) res = this.interpolator.nest(res, function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n if (lastKey && lastKey[0] === args[0] && !options.context) {\n _this3.logger.warn(\"It seems you are nesting recursively key: \".concat(args[0], \" in key: \").concat(key[0]));\n return null;\n }\n return _this3.translate.apply(_this3, args.concat([key]));\n }, options);\n if (options.interpolation) this.interpolator.reset();\n }\n var postProcess = options.postProcess || this.options.postProcess;\n var postProcessorNames = typeof postProcess === 'string' ? [postProcess] : postProcess;\n if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {\n res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? _objectSpread$4({\n i18nResolved: resolved\n }, options) : options, this);\n }\n return res;\n }\n }, {\n key: \"resolve\",\n value: function resolve(keys) {\n var _this4 = this;\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var found;\n var usedKey;\n var exactUsedKey;\n var usedLng;\n var usedNS;\n if (typeof keys === 'string') keys = [keys];\n keys.forEach(function (k) {\n if (_this4.isValidLookup(found)) return;\n var extracted = _this4.extractFromKey(k, options);\n var key = extracted.key;\n usedKey = key;\n var namespaces = extracted.namespaces;\n if (_this4.options.fallbackNS) namespaces = namespaces.concat(_this4.options.fallbackNS);\n var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';\n var needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && _this4.pluralResolver.shouldUseIntlApi();\n var needsContextHandling = options.context !== undefined && (typeof options.context === 'string' || typeof options.context === 'number') && options.context !== '';\n var codes = options.lngs ? options.lngs : _this4.languageUtils.toResolveHierarchy(options.lng || _this4.language, options.fallbackLng);\n namespaces.forEach(function (ns) {\n if (_this4.isValidLookup(found)) return;\n usedNS = ns;\n if (!checkedLoadedFor[\"\".concat(codes[0], \"-\").concat(ns)] && _this4.utils && _this4.utils.hasLoadedNamespace && !_this4.utils.hasLoadedNamespace(usedNS)) {\n checkedLoadedFor[\"\".concat(codes[0], \"-\").concat(ns)] = true;\n _this4.logger.warn(\"key \\\"\".concat(usedKey, \"\\\" for languages \\\"\").concat(codes.join(', '), \"\\\" won't get resolved as namespace \\\"\").concat(usedNS, \"\\\" was not yet loaded\"), 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');\n }\n codes.forEach(function (code) {\n if (_this4.isValidLookup(found)) return;\n usedLng = code;\n var finalKeys = [key];\n if (_this4.i18nFormat && _this4.i18nFormat.addLookupKeys) {\n _this4.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);\n } else {\n var pluralSuffix;\n if (needsPluralHandling) pluralSuffix = _this4.pluralResolver.getSuffix(code, options.count, options);\n var zeroSuffix = \"\".concat(_this4.options.pluralSeparator, \"zero\");\n if (needsPluralHandling) {\n finalKeys.push(key + pluralSuffix);\n if (needsZeroSuffixLookup) {\n finalKeys.push(key + zeroSuffix);\n }\n }\n if (needsContextHandling) {\n var contextKey = \"\".concat(key).concat(_this4.options.contextSeparator).concat(options.context);\n finalKeys.push(contextKey);\n if (needsPluralHandling) {\n finalKeys.push(contextKey + pluralSuffix);\n if (needsZeroSuffixLookup) {\n finalKeys.push(contextKey + zeroSuffix);\n }\n }\n }\n }\n var possibleKey;\n while (possibleKey = finalKeys.pop()) {\n if (!_this4.isValidLookup(found)) {\n exactUsedKey = possibleKey;\n found = _this4.getResource(code, ns, possibleKey, options);\n }\n }\n });\n });\n });\n return {\n res: found,\n usedKey: usedKey,\n exactUsedKey: exactUsedKey,\n usedLng: usedLng,\n usedNS: usedNS\n };\n }\n }, {\n key: \"isValidLookup\",\n value: function isValidLookup(res) {\n return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');\n }\n }, {\n key: \"getResource\",\n value: function getResource(code, ns, key) {\n var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n if (this.i18nFormat && this.i18nFormat.getResource) return this.i18nFormat.getResource(code, ns, key, options);\n return this.resourceStore.getResource(code, ns, key, options);\n }\n }], [{\n key: \"hasDefaultValue\",\n value: function hasDefaultValue(options) {\n var prefix = 'defaultValue';\n for (var option in options) {\n if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {\n return true;\n }\n }\n return false;\n }\n }]);\n return Translator;\n}(EventEmitter);\n\nfunction capitalize(string) {\n return string.charAt(0).toUpperCase() + string.slice(1);\n}\nvar LanguageUtil = function () {\n function LanguageUtil(options) {\n _classCallCheck__default[\"default\"](this, LanguageUtil);\n this.options = options;\n this.supportedLngs = this.options.supportedLngs || false;\n this.logger = baseLogger.create('languageUtils');\n }\n _createClass__default[\"default\"](LanguageUtil, [{\n key: \"getScriptPartFromCode\",\n value: function getScriptPartFromCode(code) {\n if (!code || code.indexOf('-') < 0) return null;\n var p = code.split('-');\n if (p.length === 2) return null;\n p.pop();\n if (p[p.length - 1].toLowerCase() === 'x') return null;\n return this.formatLanguageCode(p.join('-'));\n }\n }, {\n key: \"getLanguagePartFromCode\",\n value: function getLanguagePartFromCode(code) {\n if (!code || code.indexOf('-') < 0) return code;\n var p = code.split('-');\n return this.formatLanguageCode(p[0]);\n }\n }, {\n key: \"formatLanguageCode\",\n value: function formatLanguageCode(code) {\n if (typeof code === 'string' && code.indexOf('-') > -1) {\n var specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];\n var p = code.split('-');\n if (this.options.lowerCaseLng) {\n p = p.map(function (part) {\n return part.toLowerCase();\n });\n } else if (p.length === 2) {\n p[0] = p[0].toLowerCase();\n p[1] = p[1].toUpperCase();\n if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());\n } else if (p.length === 3) {\n p[0] = p[0].toLowerCase();\n if (p[1].length === 2) p[1] = p[1].toUpperCase();\n if (p[0] !== 'sgn' && p[2].length === 2) p[2] = p[2].toUpperCase();\n if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());\n if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());\n }\n return p.join('-');\n }\n return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;\n }\n }, {\n key: \"isSupportedCode\",\n value: function isSupportedCode(code) {\n if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {\n code = this.getLanguagePartFromCode(code);\n }\n return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;\n }\n }, {\n key: \"getBestMatchFromCodes\",\n value: function getBestMatchFromCodes(codes) {\n var _this = this;\n if (!codes) return null;\n var found;\n codes.forEach(function (code) {\n if (found) return;\n var cleanedLng = _this.formatLanguageCode(code);\n if (!_this.options.supportedLngs || _this.isSupportedCode(cleanedLng)) found = cleanedLng;\n });\n if (!found && this.options.supportedLngs) {\n codes.forEach(function (code) {\n if (found) return;\n var lngOnly = _this.getLanguagePartFromCode(code);\n if (_this.isSupportedCode(lngOnly)) return found = lngOnly;\n found = _this.options.supportedLngs.find(function (supportedLng) {\n if (supportedLng === lngOnly) return supportedLng;\n if (supportedLng.indexOf('-') < 0 && lngOnly.indexOf('-') < 0) return;\n if (supportedLng.indexOf(lngOnly) === 0) return supportedLng;\n });\n });\n }\n if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];\n return found;\n }\n }, {\n key: \"getFallbackCodes\",\n value: function getFallbackCodes(fallbacks, code) {\n if (!fallbacks) return [];\n if (typeof fallbacks === 'function') fallbacks = fallbacks(code);\n if (typeof fallbacks === 'string') fallbacks = [fallbacks];\n if (Object.prototype.toString.apply(fallbacks) === '[object Array]') return fallbacks;\n if (!code) return fallbacks[\"default\"] || [];\n var found = fallbacks[code];\n if (!found) found = fallbacks[this.getScriptPartFromCode(code)];\n if (!found) found = fallbacks[this.formatLanguageCode(code)];\n if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];\n if (!found) found = fallbacks[\"default\"];\n return found || [];\n }\n }, {\n key: \"toResolveHierarchy\",\n value: function toResolveHierarchy(code, fallbackCode) {\n var _this2 = this;\n var fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);\n var codes = [];\n var addCode = function addCode(c) {\n if (!c) return;\n if (_this2.isSupportedCode(c)) {\n codes.push(c);\n } else {\n _this2.logger.warn(\"rejecting language code not found in supportedLngs: \".concat(c));\n }\n };\n if (typeof code === 'string' && code.indexOf('-') > -1) {\n if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));\n if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));\n if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));\n } else if (typeof code === 'string') {\n addCode(this.formatLanguageCode(code));\n }\n fallbackCodes.forEach(function (fc) {\n if (codes.indexOf(fc) < 0) addCode(_this2.formatLanguageCode(fc));\n });\n return codes;\n }\n }]);\n return LanguageUtil;\n}();\n\nvar sets = [{\n lngs: ['ach', 'ak', 'am', 'arn', 'br', 'fil', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt', 'pt-BR', 'tg', 'tl', 'ti', 'tr', 'uz', 'wa'],\n nr: [1, 2],\n fc: 1\n}, {\n 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'],\n nr: [1, 2],\n fc: 2\n}, {\n lngs: ['ay', 'bo', 'cgg', 'fa', 'ht', 'id', 'ja', 'jbo', 'ka', 'km', 'ko', 'ky', 'lo', 'ms', 'sah', 'su', 'th', 'tt', 'ug', 'vi', 'wo', 'zh'],\n nr: [1],\n fc: 3\n}, {\n lngs: ['be', 'bs', 'cnr', 'dz', 'hr', 'ru', 'sr', 'uk'],\n nr: [1, 2, 5],\n fc: 4\n}, {\n lngs: ['ar'],\n nr: [0, 1, 2, 3, 11, 100],\n fc: 5\n}, {\n lngs: ['cs', 'sk'],\n nr: [1, 2, 5],\n fc: 6\n}, {\n lngs: ['csb', 'pl'],\n nr: [1, 2, 5],\n fc: 7\n}, {\n lngs: ['cy'],\n nr: [1, 2, 3, 8],\n fc: 8\n}, {\n lngs: ['fr'],\n nr: [1, 2],\n fc: 9\n}, {\n lngs: ['ga'],\n nr: [1, 2, 3, 7, 11],\n fc: 10\n}, {\n lngs: ['gd'],\n nr: [1, 2, 3, 20],\n fc: 11\n}, {\n lngs: ['is'],\n nr: [1, 2],\n fc: 12\n}, {\n lngs: ['jv'],\n nr: [0, 1],\n fc: 13\n}, {\n lngs: ['kw'],\n nr: [1, 2, 3, 4],\n fc: 14\n}, {\n lngs: ['lt'],\n nr: [1, 2, 10],\n fc: 15\n}, {\n lngs: ['lv'],\n nr: [1, 2, 0],\n fc: 16\n}, {\n lngs: ['mk'],\n nr: [1, 2],\n fc: 17\n}, {\n lngs: ['mnk'],\n nr: [0, 1, 2],\n fc: 18\n}, {\n lngs: ['mt'],\n nr: [1, 2, 11, 20],\n fc: 19\n}, {\n lngs: ['or'],\n nr: [2, 1],\n fc: 2\n}, {\n lngs: ['ro'],\n nr: [1, 2, 20],\n fc: 20\n}, {\n lngs: ['sl'],\n nr: [5, 1, 2, 3],\n fc: 21\n}, {\n lngs: ['he', 'iw'],\n nr: [1, 2, 20, 21],\n fc: 22\n}];\nvar _rulesPluralsTypes = {\n 1: function _(n) {\n return Number(n > 1);\n },\n 2: function _(n) {\n return Number(n != 1);\n },\n 3: function _(n) {\n return 0;\n },\n 4: function _(n) {\n return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);\n },\n 5: function _(n) {\n return Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5);\n },\n 6: function _(n) {\n return Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2);\n },\n 7: function _(n) {\n return Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);\n },\n 8: function _(n) {\n return Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3);\n },\n 9: function _(n) {\n return Number(n >= 2);\n },\n 10: function _(n) {\n return Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4);\n },\n 11: function _(n) {\n return Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3);\n },\n 12: function _(n) {\n return Number(n % 10 != 1 || n % 100 == 11);\n },\n 13: function _(n) {\n return Number(n !== 0);\n },\n 14: function _(n) {\n return Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3);\n },\n 15: function _(n) {\n return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);\n },\n 16: function _(n) {\n return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2);\n },\n 17: function _(n) {\n return Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1);\n },\n 18: function _(n) {\n return Number(n == 0 ? 0 : n == 1 ? 1 : 2);\n },\n 19: function _(n) {\n return Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3);\n },\n 20: function _(n) {\n return Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2);\n },\n 21: function _(n) {\n return Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0);\n },\n 22: function _(n) {\n return Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3);\n }\n};\nvar deprecatedJsonVersions = ['v1', 'v2', 'v3'];\nvar suffixesOrder = {\n zero: 0,\n one: 1,\n two: 2,\n few: 3,\n many: 4,\n other: 5\n};\nfunction createRules() {\n var rules = {};\n sets.forEach(function (set) {\n set.lngs.forEach(function (l) {\n rules[l] = {\n numbers: set.nr,\n plurals: _rulesPluralsTypes[set.fc]\n };\n });\n });\n return rules;\n}\nvar PluralResolver = function () {\n function PluralResolver(languageUtils) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n _classCallCheck__default[\"default\"](this, PluralResolver);\n this.languageUtils = languageUtils;\n this.options = options;\n this.logger = baseLogger.create('pluralResolver');\n if ((!this.options.compatibilityJSON || this.options.compatibilityJSON === 'v4') && (typeof Intl === 'undefined' || !Intl.PluralRules)) {\n this.options.compatibilityJSON = 'v3';\n 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.');\n }\n this.rules = createRules();\n }\n _createClass__default[\"default\"](PluralResolver, [{\n key: \"addRule\",\n value: function addRule(lng, obj) {\n this.rules[lng] = obj;\n }\n }, {\n key: \"getRule\",\n value: function getRule(code) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n if (this.shouldUseIntlApi()) {\n try {\n return new Intl.PluralRules(code, {\n type: options.ordinal ? 'ordinal' : 'cardinal'\n });\n } catch (_unused) {\n return;\n }\n }\n return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];\n }\n }, {\n key: \"needsPlural\",\n value: function needsPlural(code) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var rule = this.getRule(code, options);\n if (this.shouldUseIntlApi()) {\n return rule && rule.resolvedOptions().pluralCategories.length > 1;\n }\n return rule && rule.numbers.length > 1;\n }\n }, {\n key: \"getPluralFormsOfKey\",\n value: function getPluralFormsOfKey(code, key) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n return this.getSuffixes(code, options).map(function (suffix) {\n return \"\".concat(key).concat(suffix);\n });\n }\n }, {\n key: \"getSuffixes\",\n value: function getSuffixes(code) {\n var _this = this;\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var rule = this.getRule(code, options);\n if (!rule) {\n return [];\n }\n if (this.shouldUseIntlApi()) {\n return rule.resolvedOptions().pluralCategories.sort(function (pluralCategory1, pluralCategory2) {\n return suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2];\n }).map(function (pluralCategory) {\n return \"\".concat(_this.options.prepend).concat(pluralCategory);\n });\n }\n return rule.numbers.map(function (number) {\n return _this.getSuffix(code, number, options);\n });\n }\n }, {\n key: \"getSuffix\",\n value: function getSuffix(code, count) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n var rule = this.getRule(code, options);\n if (rule) {\n if (this.shouldUseIntlApi()) {\n return \"\".concat(this.options.prepend).concat(rule.select(count));\n }\n return this.getSuffixRetroCompatible(rule, count);\n }\n this.logger.warn(\"no plural rule found for: \".concat(code));\n return '';\n }\n }, {\n key: \"getSuffixRetroCompatible\",\n value: function getSuffixRetroCompatible(rule, count) {\n var _this2 = this;\n var idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));\n var suffix = rule.numbers[idx];\n if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {\n if (suffix === 2) {\n suffix = 'plural';\n } else if (suffix === 1) {\n suffix = '';\n }\n }\n var returnSuffix = function returnSuffix() {\n return _this2.options.prepend && suffix.toString() ? _this2.options.prepend + suffix.toString() : suffix.toString();\n };\n if (this.options.compatibilityJSON === 'v1') {\n if (suffix === 1) return '';\n if (typeof suffix === 'number') return \"_plural_\".concat(suffix.toString());\n return returnSuffix();\n } else if (this.options.compatibilityJSON === 'v2') {\n return returnSuffix();\n } else if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {\n return returnSuffix();\n }\n return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();\n }\n }, {\n key: \"shouldUseIntlApi\",\n value: function shouldUseIntlApi() {\n return !deprecatedJsonVersions.includes(this.options.compatibilityJSON);\n }\n }]);\n return PluralResolver;\n}();\n\nfunction ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty__default[\"default\"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nvar Interpolator = function () {\n function Interpolator() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n _classCallCheck__default[\"default\"](this, Interpolator);\n this.logger = baseLogger.create('interpolator');\n this.options = options;\n this.format = options.interpolation && options.interpolation.format || function (value) {\n return value;\n };\n this.init(options);\n }\n _createClass__default[\"default\"](Interpolator, [{\n key: \"init\",\n value: function init() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n if (!options.interpolation) options.interpolation = {\n escapeValue: true\n };\n var iOpts = options.interpolation;\n this.escape = iOpts.escape !== undefined ? iOpts.escape : escape;\n this.escapeValue = iOpts.escapeValue !== undefined ? iOpts.escapeValue : true;\n this.useRawValueToEscape = iOpts.useRawValueToEscape !== undefined ? iOpts.useRawValueToEscape : false;\n this.prefix = iOpts.prefix ? regexEscape(iOpts.prefix) : iOpts.prefixEscaped || '{{';\n this.suffix = iOpts.suffix ? regexEscape(iOpts.suffix) : iOpts.suffixEscaped || '}}';\n this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';\n this.unescapePrefix = iOpts.unescapeSuffix ? '' : iOpts.unescapePrefix || '-';\n this.unescapeSuffix = this.unescapePrefix ? '' : iOpts.unescapeSuffix || '';\n this.nestingPrefix = iOpts.nestingPrefix ? regexEscape(iOpts.nestingPrefix) : iOpts.nestingPrefixEscaped || regexEscape('$t(');\n this.nestingSuffix = iOpts.nestingSuffix ? regexEscape(iOpts.nestingSuffix) : iOpts.nestingSuffixEscaped || regexEscape(')');\n this.nestingOptionsSeparator = iOpts.nestingOptionsSeparator ? iOpts.nestingOptionsSeparator : iOpts.nestingOptionsSeparator || ',';\n this.maxReplaces = iOpts.maxReplaces ? iOpts.maxReplaces : 1000;\n this.alwaysFormat = iOpts.alwaysFormat !== undefined ? iOpts.alwaysFormat : false;\n this.resetRegExp();\n }\n }, {\n key: \"reset\",\n value: function reset() {\n if (this.options) this.init(this.options);\n }\n }, {\n key: \"resetRegExp\",\n value: function resetRegExp() {\n var regexpStr = \"\".concat(this.prefix, \"(.+?)\").concat(this.suffix);\n this.regexp = new RegExp(regexpStr, 'g');\n var regexpUnescapeStr = \"\".concat(this.prefix).concat(this.unescapePrefix, \"(.+?)\").concat(this.unescapeSuffix).concat(this.suffix);\n this.regexpUnescape = new RegExp(regexpUnescapeStr, 'g');\n var nestingRegexpStr = \"\".concat(this.nestingPrefix, \"(.+?)\").concat(this.nestingSuffix);\n this.nestingRegexp = new RegExp(nestingRegexpStr, 'g');\n }\n }, {\n key: \"interpolate\",\n value: function interpolate(str, data, lng, options) {\n var _this = this;\n var match;\n var value;\n var replaces;\n var defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};\n function regexSafe(val) {\n return val.replace(/\\$/g, '$$$$');\n }\n var handleFormat = function handleFormat(key) {\n if (key.indexOf(_this.formatSeparator) < 0) {\n var path = getPathWithDefaults(data, defaultData, key);\n return _this.alwaysFormat ? _this.format(path, undefined, lng, _objectSpread$3(_objectSpread$3(_objectSpread$3({}, options), data), {}, {\n interpolationkey: key\n })) : path;\n }\n var p = key.split(_this.formatSeparator);\n var k = p.shift().trim();\n var f = p.join(_this.formatSeparator).trim();\n return _this.format(getPathWithDefaults(data, defaultData, k), f, lng, _objectSpread$3(_objectSpread$3(_objectSpread$3({}, options), data), {}, {\n interpolationkey: k\n }));\n };\n this.resetRegExp();\n var missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;\n var skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;\n var todos = [{\n regex: this.regexpUnescape,\n safeValue: function safeValue(val) {\n return regexSafe(val);\n }\n }, {\n regex: this.regexp,\n safeValue: function safeValue(val) {\n return _this.escapeValue ? regexSafe(_this.escape(val)) : regexSafe(val);\n }\n }];\n todos.forEach(function (todo) {\n replaces = 0;\n while (match = todo.regex.exec(str)) {\n var matchedVar = match[1].trim();\n value = handleFormat(matchedVar);\n if (value === undefined) {\n if (typeof missingInterpolationHandler === 'function') {\n var temp = missingInterpolationHandler(str, match, options);\n value = typeof temp === 'string' ? temp : '';\n } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {\n value = '';\n } else if (skipOnVariables) {\n value = match[0];\n continue;\n } else {\n _this.logger.warn(\"missed to pass in variable \".concat(matchedVar, \" for interpolating \").concat(str));\n value = '';\n }\n } else if (typeof value !== 'string' && !_this.useRawValueToEscape) {\n value = makeString(value);\n }\n var safeValue = todo.safeValue(value);\n str = str.replace(match[0], safeValue);\n if (skipOnVariables) {\n todo.regex.lastIndex += value.length;\n todo.regex.lastIndex -= match[0].length;\n } else {\n todo.regex.lastIndex = 0;\n }\n replaces++;\n if (replaces >= _this.maxReplaces) {\n break;\n }\n }\n });\n return str;\n }\n }, {\n key: \"nest\",\n value: function nest(str, fc) {\n var _this2 = this;\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n var match;\n var value;\n var clonedOptions;\n function handleHasOptions(key, inheritedOptions) {\n var sep = this.nestingOptionsSeparator;\n if (key.indexOf(sep) < 0) return key;\n var c = key.split(new RegExp(\"\".concat(sep, \"[ ]*{\")));\n var optionsString = \"{\".concat(c[1]);\n key = c[0];\n optionsString = this.interpolate(optionsString, clonedOptions);\n var matchedSingleQuotes = optionsString.match(/'/g);\n var matchedDoubleQuotes = optionsString.match(/\"/g);\n if (matchedSingleQuotes && matchedSingleQuotes.length % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {\n optionsString = optionsString.replace(/'/g, '\"');\n }\n try {\n clonedOptions = JSON.parse(optionsString);\n if (inheritedOptions) clonedOptions = _objectSpread$3(_objectSpread$3({}, inheritedOptions), clonedOptions);\n } catch (e) {\n this.logger.warn(\"failed parsing options string in nesting for key \".concat(key), e);\n return \"\".concat(key).concat(sep).concat(optionsString);\n }\n delete clonedOptions.defaultValue;\n return key;\n }\n while (match = this.nestingRegexp.exec(str)) {\n var formatters = [];\n clonedOptions = _objectSpread$3({}, options);\n clonedOptions = clonedOptions.replace && typeof clonedOptions.replace !== 'string' ? clonedOptions.replace : clonedOptions;\n clonedOptions.applyPostProcessor = false;\n delete clonedOptions.defaultValue;\n var doReduce = false;\n if (match[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match[1])) {\n var r = match[1].split(this.formatSeparator).map(function (elem) {\n return elem.trim();\n });\n match[1] = r.shift();\n formatters = r;\n doReduce = true;\n }\n value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);\n if (value && match[0] === str && typeof value !== 'string') return value;\n if (typeof value !== 'string') value = makeString(value);\n if (!value) {\n this.logger.warn(\"missed to resolve \".concat(match[1], \" for nesting \").concat(str));\n value = '';\n }\n if (doReduce) {\n value = formatters.reduce(function (v, f) {\n return _this2.format(v, f, options.lng, _objectSpread$3(_objectSpread$3({}, options), {}, {\n interpolationkey: match[1].trim()\n }));\n }, value.trim());\n }\n str = str.replace(match[0], value);\n this.regexp.lastIndex = 0;\n }\n return str;\n }\n }]);\n return Interpolator;\n}();\n\nfunction ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty__default[\"default\"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction parseFormatStr(formatStr) {\n var formatName = formatStr.toLowerCase().trim();\n var formatOptions = {};\n if (formatStr.indexOf('(') > -1) {\n var p = formatStr.split('(');\n formatName = p[0].toLowerCase().trim();\n var optStr = p[1].substring(0, p[1].length - 1);\n if (formatName === 'currency' && optStr.indexOf(':') < 0) {\n if (!formatOptions.currency) formatOptions.currency = optStr.trim();\n } else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {\n if (!formatOptions.range) formatOptions.range = optStr.trim();\n } else {\n var opts = optStr.split(';');\n opts.forEach(function (opt) {\n if (!opt) return;\n var _opt$split = opt.split(':'),\n _opt$split2 = _toArray__default[\"default\"](_opt$split),\n key = _opt$split2[0],\n rest = _opt$split2.slice(1);\n var val = rest.join(':').trim().replace(/^'+|'+$/g, '');\n if (!formatOptions[key.trim()]) formatOptions[key.trim()] = val;\n if (val === 'false') formatOptions[key.trim()] = false;\n if (val === 'true') formatOptions[key.trim()] = true;\n if (!isNaN(val)) formatOptions[key.trim()] = parseInt(val, 10);\n });\n }\n }\n return {\n formatName: formatName,\n formatOptions: formatOptions\n };\n}\nfunction createCachedFormatter(fn) {\n var cache = {};\n return function invokeFormatter(val, lng, options) {\n var key = lng + JSON.stringify(options);\n var formatter = cache[key];\n if (!formatter) {\n formatter = fn(lng, options);\n cache[key] = formatter;\n }\n return formatter(val);\n };\n}\nvar Formatter = function () {\n function Formatter() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n _classCallCheck__default[\"default\"](this, Formatter);\n this.logger = baseLogger.create('formatter');\n this.options = options;\n this.formats = {\n number: createCachedFormatter(function (lng, opt) {\n var formatter = new Intl.NumberFormat(lng, _objectSpread$2({}, opt));\n return function (val) {\n return formatter.format(val);\n };\n }),\n currency: createCachedFormatter(function (lng, opt) {\n var formatter = new Intl.NumberFormat(lng, _objectSpread$2(_objectSpread$2({}, opt), {}, {\n style: 'currency'\n }));\n return function (val) {\n return formatter.format(val);\n };\n }),\n datetime: createCachedFormatter(function (lng, opt) {\n var formatter = new Intl.DateTimeFormat(lng, _objectSpread$2({}, opt));\n return function (val) {\n return formatter.format(val);\n };\n }),\n relativetime: createCachedFormatter(function (lng, opt) {\n var formatter = new Intl.RelativeTimeFormat(lng, _objectSpread$2({}, opt));\n return function (val) {\n return formatter.format(val, opt.range || 'day');\n };\n }),\n list: createCachedFormatter(function (lng, opt) {\n var formatter = new Intl.ListFormat(lng, _objectSpread$2({}, opt));\n return function (val) {\n return formatter.format(val);\n };\n })\n };\n this.init(options);\n }\n _createClass__default[\"default\"](Formatter, [{\n key: \"init\",\n value: function init(services) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {\n interpolation: {}\n };\n var iOpts = options.interpolation;\n this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';\n }\n }, {\n key: \"add\",\n value: function add(name, fc) {\n this.formats[name.toLowerCase().trim()] = fc;\n }\n }, {\n key: \"addCached\",\n value: function addCached(name, fc) {\n this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);\n }\n }, {\n key: \"format\",\n value: function format(value, _format, lng) {\n var _this = this;\n var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n var formats = _format.split(this.formatSeparator);\n var result = formats.reduce(function (mem, f) {\n var _parseFormatStr = parseFormatStr(f),\n formatName = _parseFormatStr.formatName,\n formatOptions = _parseFormatStr.formatOptions;\n if (_this.formats[formatName]) {\n var formatted = mem;\n try {\n var valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || {};\n var l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;\n formatted = _this.formats[formatName](mem, l, _objectSpread$2(_objectSpread$2(_objectSpread$2({}, formatOptions), options), valOptions));\n } catch (error) {\n _this.logger.warn(error);\n }\n return formatted;\n } else {\n _this.logger.warn(\"there was no format function for \".concat(formatName));\n }\n return mem;\n }, value);\n return result;\n }\n }]);\n return Formatter;\n}();\n\nfunction ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty__default[\"default\"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf__default[\"default\"](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default[\"default\"](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default[\"default\"](this, result); }; }\nfunction _isNativeReflectConstruct$1() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction removePending(q, name) {\n if (q.pending[name] !== undefined) {\n delete q.pending[name];\n q.pendingCount--;\n }\n}\nvar Connector = function (_EventEmitter) {\n _inherits__default[\"default\"](Connector, _EventEmitter);\n var _super = _createSuper$1(Connector);\n function Connector(backend, store, services) {\n var _this;\n var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n _classCallCheck__default[\"default\"](this, Connector);\n _this = _super.call(this);\n if (isIE10) {\n EventEmitter.call(_assertThisInitialized__default[\"default\"](_this));\n }\n _this.backend = backend;\n _this.store = store;\n _this.services = services;\n _this.languageUtils = services.languageUtils;\n _this.options = options;\n _this.logger = baseLogger.create('backendConnector');\n _this.waitingReads = [];\n _this.maxParallelReads = options.maxParallelReads || 10;\n _this.readingCalls = 0;\n _this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;\n _this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;\n _this.state = {};\n _this.queue = [];\n if (_this.backend && _this.backend.init) {\n _this.backend.init(services, options.backend, options);\n }\n return _this;\n }\n _createClass__default[\"default\"](Connector, [{\n key: \"queueLoad\",\n value: function queueLoad(languages, namespaces, options, callback) {\n var _this2 = this;\n var toLoad = {};\n var pending = {};\n var toLoadLanguages = {};\n var toLoadNamespaces = {};\n languages.forEach(function (lng) {\n var hasAllNamespaces = true;\n namespaces.forEach(function (ns) {\n var name = \"\".concat(lng, \"|\").concat(ns);\n if (!options.reload && _this2.store.hasResourceBundle(lng, ns)) {\n _this2.state[name] = 2;\n } else if (_this2.state[name] < 0) ; else if (_this2.state[name] === 1) {\n if (pending[name] === undefined) pending[name] = true;\n } else {\n _this2.state[name] = 1;\n hasAllNamespaces = false;\n if (pending[name] === undefined) pending[name] = true;\n if (toLoad[name] === undefined) toLoad[name] = true;\n if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;\n }\n });\n if (!hasAllNamespaces) toLoadLanguages[lng] = true;\n });\n if (Object.keys(toLoad).length || Object.keys(pending).length) {\n this.queue.push({\n pending: pending,\n pendingCount: Object.keys(pending).length,\n loaded: {},\n errors: [],\n callback: callback\n });\n }\n return {\n toLoad: Object.keys(toLoad),\n pending: Object.keys(pending),\n toLoadLanguages: Object.keys(toLoadLanguages),\n toLoadNamespaces: Object.keys(toLoadNamespaces)\n };\n }\n }, {\n key: \"loaded\",\n value: function loaded(name, err, data) {\n var s = name.split('|');\n var lng = s[0];\n var ns = s[1];\n if (err) this.emit('failedLoading', lng, ns, err);\n if (data) {\n this.store.addResourceBundle(lng, ns, data);\n }\n this.state[name] = err ? -1 : 2;\n var loaded = {};\n this.queue.forEach(function (q) {\n pushPath(q.loaded, [lng], ns);\n removePending(q, name);\n if (err) q.errors.push(err);\n if (q.pendingCount === 0 && !q.done) {\n Object.keys(q.loaded).forEach(function (l) {\n if (!loaded[l]) loaded[l] = {};\n var loadedKeys = q.loaded[l];\n if (loadedKeys.length) {\n loadedKeys.forEach(function (n) {\n if (loaded[l][n] === undefined) loaded[l][n] = true;\n });\n }\n });\n q.done = true;\n if (q.errors.length) {\n q.callback(q.errors);\n } else {\n q.callback();\n }\n }\n });\n this.emit('loaded', loaded);\n this.queue = this.queue.filter(function (q) {\n return !q.done;\n });\n }\n }, {\n key: \"read\",\n value: function read(lng, ns, fcName) {\n var _this3 = this;\n var tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;\n var wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;\n var callback = arguments.length > 5 ? arguments[5] : undefined;\n if (!lng.length) return callback(null, {});\n if (this.readingCalls >= this.maxParallelReads) {\n this.waitingReads.push({\n lng: lng,\n ns: ns,\n fcName: fcName,\n tried: tried,\n wait: wait,\n callback: callback\n });\n return;\n }\n this.readingCalls++;\n var resolver = function resolver(err, data) {\n _this3.readingCalls--;\n if (_this3.waitingReads.length > 0) {\n var next = _this3.waitingReads.shift();\n _this3.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);\n }\n if (err && data && tried < _this3.maxRetries) {\n setTimeout(function () {\n _this3.read.call(_this3, lng, ns, fcName, tried + 1, wait * 2, callback);\n }, wait);\n return;\n }\n callback(err, data);\n };\n var fc = this.backend[fcName].bind(this.backend);\n if (fc.length === 2) {\n try {\n var r = fc(lng, ns);\n if (r && typeof r.then === 'function') {\n r.then(function (data) {\n return resolver(null, data);\n })[\"catch\"](resolver);\n } else {\n resolver(null, r);\n }\n } catch (err) {\n resolver(err);\n }\n return;\n }\n return fc(lng, ns, resolver);\n }\n }, {\n key: \"prepareLoading\",\n value: function prepareLoading(languages, namespaces) {\n var _this4 = this;\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n var callback = arguments.length > 3 ? arguments[3] : undefined;\n if (!this.backend) {\n this.logger.warn('No backend was added via i18next.use. Will not load resources.');\n return callback && callback();\n }\n if (typeof languages === 'string') languages = this.languageUtils.toResolveHierarchy(languages);\n if (typeof namespaces === 'string') namespaces = [namespaces];\n var toLoad = this.queueLoad(languages, namespaces, options, callback);\n if (!toLoad.toLoad.length) {\n if (!toLoad.pending.length) callback();\n return null;\n }\n toLoad.toLoad.forEach(function (name) {\n _this4.loadOne(name);\n });\n }\n }, {\n key: \"load\",\n value: function load(languages, namespaces, callback) {\n this.prepareLoading(languages, namespaces, {}, callback);\n }\n }, {\n key: \"reload\",\n value: function reload(languages, namespaces, callback) {\n this.prepareLoading(languages, namespaces, {\n reload: true\n }, callback);\n }\n }, {\n key: \"loadOne\",\n value: function loadOne(name) {\n var _this5 = this;\n var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';\n var s = name.split('|');\n var lng = s[0];\n var ns = s[1];\n this.read(lng, ns, 'read', undefined, undefined, function (err, data) {\n if (err) _this5.logger.warn(\"\".concat(prefix, \"loading namespace \").concat(ns, \" for language \").concat(lng, \" failed\"), err);\n if (!err && data) _this5.logger.log(\"\".concat(prefix, \"loaded namespace \").concat(ns, \" for language \").concat(lng), data);\n _this5.loaded(name, err, data);\n });\n }\n }, {\n key: \"saveMissing\",\n value: function saveMissing(languages, namespace, key, fallbackValue, isUpdate) {\n var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};\n var clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : function () {};\n if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {\n this.logger.warn(\"did not save key \\\"\".concat(key, \"\\\" as the namespace \\\"\").concat(namespace, \"\\\" was not yet loaded\"), 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');\n return;\n }\n if (key === undefined || key === null || key === '') return;\n if (this.backend && this.backend.create) {\n var opts = _objectSpread$1(_objectSpread$1({}, options), {}, {\n isUpdate: isUpdate\n });\n var fc = this.backend.create.bind(this.backend);\n if (fc.length < 6) {\n try {\n var r;\n if (fc.length === 5) {\n r = fc(languages, namespace, key, fallbackValue, opts);\n } else {\n r = fc(languages, namespace, key, fallbackValue);\n }\n if (r && typeof r.then === 'function') {\n r.then(function (data) {\n return clb(null, data);\n })[\"catch\"](clb);\n } else {\n clb(null, r);\n }\n } catch (err) {\n clb(err);\n }\n } else {\n fc(languages, namespace, key, fallbackValue, clb, opts);\n }\n }\n if (!languages || !languages[0]) return;\n this.store.addResource(languages[0], namespace, key, fallbackValue);\n }\n }]);\n return Connector;\n}(EventEmitter);\n\nfunction get() {\n return {\n debug: false,\n initImmediate: true,\n ns: ['translation'],\n defaultNS: ['translation'],\n fallbackLng: ['dev'],\n fallbackNS: false,\n supportedLngs: false,\n nonExplicitSupportedLngs: false,\n load: 'all',\n preload: false,\n simplifyPluralSuffix: true,\n keySeparator: '.',\n nsSeparator: ':',\n pluralSeparator: '_',\n contextSeparator: '_',\n partialBundledLanguages: false,\n saveMissing: false,\n updateMissing: false,\n saveMissingTo: 'fallback',\n saveMissingPlurals: true,\n missingKeyHandler: false,\n missingInterpolationHandler: false,\n postProcess: false,\n postProcessPassResolved: false,\n returnNull: true,\n returnEmptyString: true,\n returnObjects: false,\n joinArrays: false,\n returnedObjectHandler: false,\n parseMissingKeyHandler: false,\n appendNamespaceToMissingKey: false,\n appendNamespaceToCIMode: false,\n overloadTranslationOptionHandler: function handle(args) {\n var ret = {};\n if (_typeof__default[\"default\"](args[1]) === 'object') ret = args[1];\n if (typeof args[1] === 'string') ret.defaultValue = args[1];\n if (typeof args[2] === 'string') ret.tDescription = args[2];\n if (_typeof__default[\"default\"](args[2]) === 'object' || _typeof__default[\"default\"](args[3]) === 'object') {\n var options = args[3] || args[2];\n Object.keys(options).forEach(function (key) {\n ret[key] = options[key];\n });\n }\n return ret;\n },\n interpolation: {\n escapeValue: true,\n format: function format(value, _format, lng, options) {\n return value;\n },\n prefix: '{{',\n suffix: '}}',\n formatSeparator: ',',\n unescapePrefix: '-',\n nestingPrefix: '$t(',\n nestingSuffix: ')',\n nestingOptionsSeparator: ',',\n maxReplaces: 1000,\n skipOnVariables: true\n }\n };\n}\nfunction transformOptions(options) {\n if (typeof options.ns === 'string') options.ns = [options.ns];\n if (typeof options.fallbackLng === 'string') options.fallbackLng = [options.fallbackLng];\n if (typeof options.fallbackNS === 'string') options.fallbackNS = [options.fallbackNS];\n if (options.supportedLngs && options.supportedLngs.indexOf('cimode') < 0) {\n options.supportedLngs = options.supportedLngs.concat(['cimode']);\n }\n return options;\n}\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default[\"default\"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf__default[\"default\"](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default[\"default\"](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default[\"default\"](this, result); }; }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction noop() {}\nfunction bindMemberFunctions(inst) {\n var mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));\n mems.forEach(function (mem) {\n if (typeof inst[mem] === 'function') {\n inst[mem] = inst[mem].bind(inst);\n }\n });\n}\nvar I18n = function (_EventEmitter) {\n _inherits__default[\"default\"](I18n, _EventEmitter);\n var _super = _createSuper(I18n);\n function I18n() {\n var _this;\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var callback = arguments.length > 1 ? arguments[1] : undefined;\n _classCallCheck__default[\"default\"](this, I18n);\n _this = _super.call(this);\n if (isIE10) {\n EventEmitter.call(_assertThisInitialized__default[\"default\"](_this));\n }\n _this.options = transformOptions(options);\n _this.services = {};\n _this.logger = baseLogger;\n _this.modules = {\n external: []\n };\n bindMemberFunctions(_assertThisInitialized__default[\"default\"](_this));\n if (callback && !_this.isInitialized && !options.isClone) {\n if (!_this.options.initImmediate) {\n _this.init(options, callback);\n return _possibleConstructorReturn__default[\"default\"](_this, _assertThisInitialized__default[\"default\"](_this));\n }\n setTimeout(function () {\n _this.init(options, callback);\n }, 0);\n }\n return _this;\n }\n _createClass__default[\"default\"](I18n, [{\n key: \"init\",\n value: function init() {\n var _this2 = this;\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var callback = arguments.length > 1 ? arguments[1] : undefined;\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n if (!options.defaultNS && options.defaultNS !== false && options.ns) {\n if (typeof options.ns === 'string') {\n options.defaultNS = options.ns;\n } else if (options.ns.indexOf('translation') < 0) {\n options.defaultNS = options.ns[0];\n }\n }\n var defOpts = get();\n this.options = _objectSpread(_objectSpread(_objectSpread({}, defOpts), this.options), transformOptions(options));\n if (this.options.compatibilityAPI !== 'v1') {\n this.options.interpolation = _objectSpread(_objectSpread({}, defOpts.interpolation), this.options.interpolation);\n }\n if (options.keySeparator !== undefined) {\n this.options.userDefinedKeySeparator = options.keySeparator;\n }\n if (options.nsSeparator !== undefined) {\n this.options.userDefinedNsSeparator = options.nsSeparator;\n }\n function createClassOnDemand(ClassOrObject) {\n if (!ClassOrObject) return null;\n if (typeof ClassOrObject === 'function') return new ClassOrObject();\n return ClassOrObject;\n }\n if (!this.options.isClone) {\n if (this.modules.logger) {\n baseLogger.init(createClassOnDemand(this.modules.logger), this.options);\n } else {\n baseLogger.init(null, this.options);\n }\n var formatter;\n if (this.modules.formatter) {\n formatter = this.modules.formatter;\n } else if (typeof Intl !== 'undefined') {\n formatter = Formatter;\n }\n var lu = new LanguageUtil(this.options);\n this.store = new ResourceStore(this.options.resources, this.options);\n var s = this.services;\n s.logger = baseLogger;\n s.resourceStore = this.store;\n s.languageUtils = lu;\n s.pluralResolver = new PluralResolver(lu, {\n prepend: this.options.pluralSeparator,\n compatibilityJSON: this.options.compatibilityJSON,\n simplifyPluralSuffix: this.options.simplifyPluralSuffix\n });\n if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {\n s.formatter = createClassOnDemand(formatter);\n s.formatter.init(s, this.options);\n this.options.interpolation.format = s.formatter.format.bind(s.formatter);\n }\n s.interpolator = new Interpolator(this.options);\n s.utils = {\n hasLoadedNamespace: this.hasLoadedNamespace.bind(this)\n };\n s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);\n s.backendConnector.on('*', function (event) {\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n _this2.emit.apply(_this2, [event].concat(args));\n });\n if (this.modules.languageDetector) {\n s.languageDetector = createClassOnDemand(this.modules.languageDetector);\n if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);\n }\n if (this.modules.i18nFormat) {\n s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);\n if (s.i18nFormat.init) s.i18nFormat.init(this);\n }\n this.translator = new Translator(this.services, this.options);\n this.translator.on('*', function (event) {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n _this2.emit.apply(_this2, [event].concat(args));\n });\n this.modules.external.forEach(function (m) {\n if (m.init) m.init(_this2);\n });\n }\n this.format = this.options.interpolation.format;\n if (!callback) callback = noop;\n if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {\n var codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);\n if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];\n }\n if (!this.services.languageDetector && !this.options.lng) {\n this.logger.warn('init: no languageDetector is used and no lng is defined');\n }\n var storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];\n storeApi.forEach(function (fcName) {\n _this2[fcName] = function () {\n var _this2$store;\n return (_this2$store = _this2.store)[fcName].apply(_this2$store, arguments);\n };\n });\n var storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];\n storeApiChained.forEach(function (fcName) {\n _this2[fcName] = function () {\n var _this2$store2;\n (_this2$store2 = _this2.store)[fcName].apply(_this2$store2, arguments);\n return _this2;\n };\n });\n var deferred = defer();\n var load = function load() {\n var finish = function finish(err, t) {\n if (_this2.isInitialized && !_this2.initializedStoreOnce) _this2.logger.warn('init: i18next is already initialized. You should call init just once!');\n _this2.isInitialized = true;\n if (!_this2.options.isClone) _this2.logger.log('initialized', _this2.options);\n _this2.emit('initialized', _this2.options);\n deferred.resolve(t);\n callback(err, t);\n };\n if (_this2.languages && _this2.options.compatibilityAPI !== 'v1' && !_this2.isInitialized) return finish(null, _this2.t.bind(_this2));\n _this2.changeLanguage(_this2.options.lng, finish);\n };\n if (this.options.resources || !this.options.initImmediate) {\n load();\n } else {\n setTimeout(load, 0);\n }\n return deferred;\n }\n }, {\n key: \"loadResources\",\n value: function loadResources(language) {\n var _this3 = this;\n var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;\n var usedCallback = callback;\n var usedLng = typeof language === 'string' ? language : this.language;\n if (typeof language === 'function') usedCallback = language;\n if (!this.options.resources || this.options.partialBundledLanguages) {\n if (usedLng && usedLng.toLowerCase() === 'cimode') return usedCallback();\n var toLoad = [];\n var append = function append(lng) {\n if (!lng) return;\n var lngs = _this3.services.languageUtils.toResolveHierarchy(lng);\n lngs.forEach(function (l) {\n if (toLoad.indexOf(l) < 0) toLoad.push(l);\n });\n };\n if (!usedLng) {\n var fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);\n fallbacks.forEach(function (l) {\n return append(l);\n });\n } else {\n append(usedLng);\n }\n if (this.options.preload) {\n this.options.preload.forEach(function (l) {\n return append(l);\n });\n }\n this.services.backendConnector.load(toLoad, this.options.ns, function (e) {\n if (!e && !_this3.resolvedLanguage && _this3.language) _this3.setResolvedLanguage(_this3.language);\n usedCallback(e);\n });\n } else {\n usedCallback(null);\n }\n }\n }, {\n key: \"reloadResources\",\n value: function reloadResources(lngs, ns, callback) {\n var deferred = defer();\n if (!lngs) lngs = this.languages;\n if (!ns) ns = this.options.ns;\n if (!callback) callback = noop;\n this.services.backendConnector.reload(lngs, ns, function (err) {\n deferred.resolve();\n callback(err);\n });\n return deferred;\n }\n }, {\n key: \"use\",\n value: function use(module) {\n if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');\n if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');\n if (module.type === 'backend') {\n this.modules.backend = module;\n }\n if (module.type === 'logger' || module.log && module.warn && module.error) {\n this.modules.logger = module;\n }\n if (module.type === 'languageDetector') {\n this.modules.languageDetector = module;\n }\n if (module.type === 'i18nFormat') {\n this.modules.i18nFormat = module;\n }\n if (module.type === 'postProcessor') {\n postProcessor.addPostProcessor(module);\n }\n if (module.type === 'formatter') {\n this.modules.formatter = module;\n }\n if (module.type === '3rdParty') {\n this.modules.external.push(module);\n }\n return this;\n }\n }, {\n key: \"setResolvedLanguage\",\n value: function setResolvedLanguage(l) {\n if (!l || !this.languages) return;\n if (['cimode', 'dev'].indexOf(l) > -1) return;\n for (var li = 0; li < this.languages.length; li++) {\n var lngInLngs = this.languages[li];\n if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;\n if (this.store.hasLanguageSomeTranslations(lngInLngs)) {\n this.resolvedLanguage = lngInLngs;\n break;\n }\n }\n }\n }, {\n key: \"changeLanguage\",\n value: function changeLanguage(lng, callback) {\n var _this4 = this;\n this.isLanguageChangingTo = lng;\n var deferred = defer();\n this.emit('languageChanging', lng);\n var setLngProps = function setLngProps(l) {\n _this4.language = l;\n _this4.languages = _this4.services.languageUtils.toResolveHierarchy(l);\n _this4.resolvedLanguage = undefined;\n _this4.setResolvedLanguage(l);\n };\n var done = function done(err, l) {\n if (l) {\n setLngProps(l);\n _this4.translator.changeLanguage(l);\n _this4.isLanguageChangingTo = undefined;\n _this4.emit('languageChanged', l);\n _this4.logger.log('languageChanged', l);\n } else {\n _this4.isLanguageChangingTo = undefined;\n }\n deferred.resolve(function () {\n return _this4.t.apply(_this4, arguments);\n });\n if (callback) callback(err, function () {\n return _this4.t.apply(_this4, arguments);\n });\n };\n var setLng = function setLng(lngs) {\n if (!lng && !lngs && _this4.services.languageDetector) lngs = [];\n var l = typeof lngs === 'string' ? lngs : _this4.services.languageUtils.getBestMatchFromCodes(lngs);\n if (l) {\n if (!_this4.language) {\n setLngProps(l);\n }\n if (!_this4.translator.language) _this4.translator.changeLanguage(l);\n if (_this4.services.languageDetector && _this4.services.languageDetector.cacheUserLanguage) _this4.services.languageDetector.cacheUserLanguage(l);\n }\n _this4.loadResources(l, function (err) {\n done(err, l);\n });\n };\n if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {\n setLng(this.services.languageDetector.detect());\n } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {\n if (this.services.languageDetector.detect.length === 0) {\n this.services.languageDetector.detect().then(setLng);\n } else {\n this.services.languageDetector.detect(setLng);\n }\n } else {\n setLng(lng);\n }\n return deferred;\n }\n }, {\n key: \"getFixedT\",\n value: function getFixedT(lng, ns, keyPrefix) {\n var _this5 = this;\n var fixedT = function fixedT(key, opts) {\n var options;\n if (_typeof__default[\"default\"](opts) !== 'object') {\n for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {\n rest[_key3 - 2] = arguments[_key3];\n }\n options = _this5.options.overloadTranslationOptionHandler([key, opts].concat(rest));\n } else {\n options = _objectSpread({}, opts);\n }\n options.lng = options.lng || fixedT.lng;\n options.lngs = options.lngs || fixedT.lngs;\n options.ns = options.ns || fixedT.ns;\n options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;\n var keySeparator = _this5.options.keySeparator || '.';\n var resultKey;\n if (options.keyPrefix && Array.isArray(key)) {\n resultKey = key.map(function (k) {\n return \"\".concat(options.keyPrefix).concat(keySeparator).concat(k);\n });\n } else {\n resultKey = options.keyPrefix ? \"\".concat(options.keyPrefix).concat(keySeparator).concat(key) : key;\n }\n return _this5.t(resultKey, options);\n };\n if (typeof lng === 'string') {\n fixedT.lng = lng;\n } else {\n fixedT.lngs = lng;\n }\n fixedT.ns = ns;\n fixedT.keyPrefix = keyPrefix;\n return fixedT;\n }\n }, {\n key: \"t\",\n value: function t() {\n var _this$translator;\n return this.translator && (_this$translator = this.translator).translate.apply(_this$translator, arguments);\n }\n }, {\n key: \"exists\",\n value: function exists() {\n var _this$translator2;\n return this.translator && (_this$translator2 = this.translator).exists.apply(_this$translator2, arguments);\n }\n }, {\n key: \"setDefaultNamespace\",\n value: function setDefaultNamespace(ns) {\n this.options.defaultNS = ns;\n }\n }, {\n key: \"hasLoadedNamespace\",\n value: function hasLoadedNamespace(ns) {\n var _this6 = this;\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n if (!this.isInitialized) {\n this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);\n return false;\n }\n if (!this.languages || !this.languages.length) {\n this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);\n return false;\n }\n var lng = this.resolvedLanguage || this.languages[0];\n var fallbackLng = this.options ? this.options.fallbackLng : false;\n var lastLng = this.languages[this.languages.length - 1];\n if (lng.toLowerCase() === 'cimode') return true;\n var loadNotPending = function loadNotPending(l, n) {\n var loadState = _this6.services.backendConnector.state[\"\".concat(l, \"|\").concat(n)];\n return loadState === -1 || loadState === 2;\n };\n if (options.precheck) {\n var preResult = options.precheck(this, loadNotPending);\n if (preResult !== undefined) return preResult;\n }\n if (this.hasResourceBundle(lng, ns)) return true;\n if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;\n if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;\n return false;\n }\n }, {\n key: \"loadNamespaces\",\n value: function loadNamespaces(ns, callback) {\n var _this7 = this;\n var deferred = defer();\n if (!this.options.ns) {\n if (callback) callback();\n return Promise.resolve();\n }\n if (typeof ns === 'string') ns = [ns];\n ns.forEach(function (n) {\n if (_this7.options.ns.indexOf(n) < 0) _this7.options.ns.push(n);\n });\n this.loadResources(function (err) {\n deferred.resolve();\n if (callback) callback(err);\n });\n return deferred;\n }\n }, {\n key: \"loadLanguages\",\n value: function loadLanguages(lngs, callback) {\n var deferred = defer();\n if (typeof lngs === 'string') lngs = [lngs];\n var preloaded = this.options.preload || [];\n var newLngs = lngs.filter(function (lng) {\n return preloaded.indexOf(lng) < 0;\n });\n if (!newLngs.length) {\n if (callback) callback();\n return Promise.resolve();\n }\n this.options.preload = preloaded.concat(newLngs);\n this.loadResources(function (err) {\n deferred.resolve();\n if (callback) callback(err);\n });\n return deferred;\n }\n }, {\n key: \"dir\",\n value: function dir(lng) {\n if (!lng) lng = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language);\n if (!lng) return 'rtl';\n var rtlLngs = ['ar', 'shu', 'sqr', 'ssh', 'xaa', 'yhd', 'yud', 'aao', 'abh', 'abv', 'acm', 'acq', 'acw', 'acx', 'acy', 'adf', 'ads', 'aeb', 'aec', 'afb', 'ajp', 'apc', 'apd', 'arb', 'arq', 'ars', 'ary', 'arz', 'auz', 'avl', 'ayh', 'ayl', 'ayn', 'ayp', 'bbz', 'pga', 'he', 'iw', 'ps', 'pbt', 'pbu', 'pst', 'prp', 'prd', 'ug', 'ur', 'ydd', 'yds', 'yih', 'ji', 'yi', 'hbo', 'men', 'xmn', 'fa', 'jpr', 'peo', 'pes', 'prs', 'dv', 'sam', 'ckb'];\n var languageUtils = this.services && this.services.languageUtils || new LanguageUtil(get());\n return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';\n }\n }, {\n key: \"cloneInstance\",\n value: function cloneInstance() {\n var _this8 = this;\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;\n var mergedOptions = _objectSpread(_objectSpread(_objectSpread({}, this.options), options), {\n isClone: true\n });\n var clone = new I18n(mergedOptions);\n if (options.debug !== undefined || options.prefix !== undefined) {\n clone.logger = clone.logger.clone(options);\n }\n var membersToCopy = ['store', 'services', 'language'];\n membersToCopy.forEach(function (m) {\n clone[m] = _this8[m];\n });\n clone.services = _objectSpread({}, this.services);\n clone.services.utils = {\n hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)\n };\n clone.translator = new Translator(clone.services, clone.options);\n clone.translator.on('*', function (event) {\n for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {\n args[_key4 - 1] = arguments[_key4];\n }\n clone.emit.apply(clone, [event].concat(args));\n });\n clone.init(mergedOptions, callback);\n clone.translator.options = clone.options;\n clone.translator.backendConnector.services.utils = {\n hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)\n };\n return clone;\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n return {\n options: this.options,\n store: this.store,\n language: this.language,\n languages: this.languages,\n resolvedLanguage: this.resolvedLanguage\n };\n }\n }]);\n return I18n;\n}(EventEmitter);\n_defineProperty__default[\"default\"](I18n, \"createInstance\", function () {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var callback = arguments.length > 1 ? arguments[1] : undefined;\n return new I18n(options, callback);\n});\nvar instance = I18n.createInstance();\ninstance.createInstance = I18n.createInstance;\n\nmodule.exports = instance;\n\n\n//# sourceURL=webpack://Formio/./node_modules/i18next/dist/cjs/i18next.js?");
2830
+ eval("\n\nvar _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ \"./node_modules/@babel/runtime/helpers/typeof.js\");\nvar _classCallCheck = __webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ \"./node_modules/@babel/runtime/helpers/classCallCheck.js\");\nvar _createClass = __webpack_require__(/*! @babel/runtime/helpers/createClass */ \"./node_modules/@babel/runtime/helpers/createClass.js\");\nvar _assertThisInitialized = __webpack_require__(/*! @babel/runtime/helpers/assertThisInitialized */ \"./node_modules/@babel/runtime/helpers/assertThisInitialized.js\");\nvar _inherits = __webpack_require__(/*! @babel/runtime/helpers/inherits */ \"./node_modules/@babel/runtime/helpers/inherits.js\");\nvar _possibleConstructorReturn = __webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ \"./node_modules/@babel/runtime/helpers/possibleConstructorReturn.js\");\nvar _getPrototypeOf = __webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ \"./node_modules/@babel/runtime/helpers/getPrototypeOf.js\");\nvar _defineProperty = __webpack_require__(/*! @babel/runtime/helpers/defineProperty */ \"./node_modules/@babel/runtime/helpers/defineProperty.js\");\nvar _toArray = __webpack_require__(/*! @babel/runtime/helpers/toArray */ \"./node_modules/@babel/runtime/helpers/toArray.js\");\n\nfunction _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }\n\nvar _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);\nvar _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallCheck);\nvar _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass);\nvar _assertThisInitialized__default = /*#__PURE__*/_interopDefaultLegacy(_assertThisInitialized);\nvar _inherits__default = /*#__PURE__*/_interopDefaultLegacy(_inherits);\nvar _possibleConstructorReturn__default = /*#__PURE__*/_interopDefaultLegacy(_possibleConstructorReturn);\nvar _getPrototypeOf__default = /*#__PURE__*/_interopDefaultLegacy(_getPrototypeOf);\nvar _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);\nvar _toArray__default = /*#__PURE__*/_interopDefaultLegacy(_toArray);\n\nfunction ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) { _defineProperty__default[\"default\"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nvar consoleLogger = {\n type: 'logger',\n log: function log(args) {\n this.output('log', args);\n },\n warn: function warn(args) {\n this.output('warn', args);\n },\n error: function error(args) {\n this.output('error', args);\n },\n output: function output(type, args) {\n if (console && console[type]) console[type].apply(console, args);\n }\n};\nvar Logger = function () {\n function Logger(concreteLogger) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n _classCallCheck__default[\"default\"](this, Logger);\n this.init(concreteLogger, options);\n }\n _createClass__default[\"default\"](Logger, [{\n key: \"init\",\n value: function init(concreteLogger) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n this.prefix = options.prefix || 'i18next:';\n this.logger = concreteLogger || consoleLogger;\n this.options = options;\n this.debug = options.debug;\n }\n }, {\n key: \"setDebug\",\n value: function setDebug(bool) {\n this.debug = bool;\n }\n }, {\n key: \"log\",\n value: function log() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n return this.forward(args, 'log', '', true);\n }\n }, {\n key: \"warn\",\n value: function warn() {\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n return this.forward(args, 'warn', '', true);\n }\n }, {\n key: \"error\",\n value: function error() {\n for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n args[_key3] = arguments[_key3];\n }\n return this.forward(args, 'error', '');\n }\n }, {\n key: \"deprecate\",\n value: function deprecate() {\n for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n args[_key4] = arguments[_key4];\n }\n return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);\n }\n }, {\n key: \"forward\",\n value: function forward(args, lvl, prefix, debugOnly) {\n if (debugOnly && !this.debug) return null;\n if (typeof args[0] === 'string') args[0] = \"\".concat(prefix).concat(this.prefix, \" \").concat(args[0]);\n return this.logger[lvl](args);\n }\n }, {\n key: \"create\",\n value: function create(moduleName) {\n return new Logger(this.logger, _objectSpread$6(_objectSpread$6({}, {\n prefix: \"\".concat(this.prefix, \":\").concat(moduleName, \":\")\n }), this.options));\n }\n }, {\n key: \"clone\",\n value: function clone(options) {\n options = options || this.options;\n options.prefix = options.prefix || this.prefix;\n return new Logger(this.logger, options);\n }\n }]);\n return Logger;\n}();\nvar baseLogger = new Logger();\n\nvar EventEmitter = function () {\n function EventEmitter() {\n _classCallCheck__default[\"default\"](this, EventEmitter);\n this.observers = {};\n }\n _createClass__default[\"default\"](EventEmitter, [{\n key: \"on\",\n value: function on(events, listener) {\n var _this = this;\n events.split(' ').forEach(function (event) {\n _this.observers[event] = _this.observers[event] || [];\n _this.observers[event].push(listener);\n });\n return this;\n }\n }, {\n key: \"off\",\n value: function off(event, listener) {\n if (!this.observers[event]) return;\n if (!listener) {\n delete this.observers[event];\n return;\n }\n this.observers[event] = this.observers[event].filter(function (l) {\n return l !== listener;\n });\n }\n }, {\n key: \"emit\",\n value: function emit(event) {\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n if (this.observers[event]) {\n var cloned = [].concat(this.observers[event]);\n cloned.forEach(function (observer) {\n observer.apply(void 0, args);\n });\n }\n if (this.observers['*']) {\n var _cloned = [].concat(this.observers['*']);\n _cloned.forEach(function (observer) {\n observer.apply(observer, [event].concat(args));\n });\n }\n }\n }]);\n return EventEmitter;\n}();\n\nfunction defer() {\n var res;\n var rej;\n var promise = new Promise(function (resolve, reject) {\n res = resolve;\n rej = reject;\n });\n promise.resolve = res;\n promise.reject = rej;\n return promise;\n}\nfunction makeString(object) {\n if (object == null) return '';\n return '' + object;\n}\nfunction copy(a, s, t) {\n a.forEach(function (m) {\n if (s[m]) t[m] = s[m];\n });\n}\nfunction getLastOfPath(object, path, Empty) {\n function cleanKey(key) {\n return key && key.indexOf('###') > -1 ? key.replace(/###/g, '.') : key;\n }\n function canNotTraverseDeeper() {\n return !object || typeof object === 'string';\n }\n var stack = typeof path !== 'string' ? [].concat(path) : path.split('.');\n while (stack.length > 1) {\n if (canNotTraverseDeeper()) return {};\n var key = cleanKey(stack.shift());\n if (!object[key] && Empty) object[key] = new Empty();\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n object = object[key];\n } else {\n object = {};\n }\n }\n if (canNotTraverseDeeper()) return {};\n return {\n obj: object,\n k: cleanKey(stack.shift())\n };\n}\nfunction setPath(object, path, newValue) {\n var _getLastOfPath = getLastOfPath(object, path, Object),\n obj = _getLastOfPath.obj,\n k = _getLastOfPath.k;\n obj[k] = newValue;\n}\nfunction pushPath(object, path, newValue, concat) {\n var _getLastOfPath2 = getLastOfPath(object, path, Object),\n obj = _getLastOfPath2.obj,\n k = _getLastOfPath2.k;\n obj[k] = obj[k] || [];\n if (concat) obj[k] = obj[k].concat(newValue);\n if (!concat) obj[k].push(newValue);\n}\nfunction getPath(object, path) {\n var _getLastOfPath3 = getLastOfPath(object, path),\n obj = _getLastOfPath3.obj,\n k = _getLastOfPath3.k;\n if (!obj) return undefined;\n return obj[k];\n}\nfunction getPathWithDefaults(data, defaultData, key) {\n var value = getPath(data, key);\n if (value !== undefined) {\n return value;\n }\n return getPath(defaultData, key);\n}\nfunction deepExtend(target, source, overwrite) {\n for (var prop in source) {\n if (prop !== '__proto__' && prop !== 'constructor') {\n if (prop in target) {\n if (typeof target[prop] === 'string' || target[prop] instanceof String || typeof source[prop] === 'string' || source[prop] instanceof String) {\n if (overwrite) target[prop] = source[prop];\n } else {\n deepExtend(target[prop], source[prop], overwrite);\n }\n } else {\n target[prop] = source[prop];\n }\n }\n }\n return target;\n}\nfunction regexEscape(str) {\n return str.replace(/[\\-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, '\\\\$&');\n}\nvar _entityMap = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\"': '&quot;',\n \"'\": '&#39;',\n '/': '&#x2F;'\n};\nfunction escape(data) {\n if (typeof data === 'string') {\n return data.replace(/[&<>\"'\\/]/g, function (s) {\n return _entityMap[s];\n });\n }\n return data;\n}\nvar isIE10 = typeof window !== 'undefined' && window.navigator && typeof window.navigator.userAgentData === 'undefined' && window.navigator.userAgent && window.navigator.userAgent.indexOf('MSIE') > -1;\nvar chars = [' ', ',', '?', '!', ';'];\nfunction looksLikeObjectPath(key, nsSeparator, keySeparator) {\n nsSeparator = nsSeparator || '';\n keySeparator = keySeparator || '';\n var possibleChars = chars.filter(function (c) {\n return nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0;\n });\n if (possibleChars.length === 0) return true;\n var r = new RegExp(\"(\".concat(possibleChars.map(function (c) {\n return c === '?' ? '\\\\?' : c;\n }).join('|'), \")\"));\n var matched = !r.test(key);\n if (!matched) {\n var ki = key.indexOf(keySeparator);\n if (ki > 0 && !r.test(key.substring(0, ki))) {\n matched = true;\n }\n }\n return matched;\n}\nfunction deepFind(obj, path) {\n var keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';\n if (!obj) return undefined;\n if (obj[path]) return obj[path];\n var paths = path.split(keySeparator);\n var current = obj;\n for (var i = 0; i < paths.length; ++i) {\n if (!current) return undefined;\n if (typeof current[paths[i]] === 'string' && i + 1 < paths.length) {\n return undefined;\n }\n if (current[paths[i]] === undefined) {\n var j = 2;\n var p = paths.slice(i, i + j).join(keySeparator);\n var mix = current[p];\n while (mix === undefined && paths.length > i + j) {\n j++;\n p = paths.slice(i, i + j).join(keySeparator);\n mix = current[p];\n }\n if (mix === undefined) return undefined;\n if (mix === null) return null;\n if (path.endsWith(p)) {\n if (typeof mix === 'string') return mix;\n if (p && typeof mix[p] === 'string') return mix[p];\n }\n var joinedPath = paths.slice(i + j).join(keySeparator);\n if (joinedPath) return deepFind(mix, joinedPath, keySeparator);\n return undefined;\n }\n current = current[paths[i]];\n }\n return current;\n}\n\nfunction ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty__default[\"default\"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$3(); return function _createSuperInternal() { var Super = _getPrototypeOf__default[\"default\"](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default[\"default\"](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default[\"default\"](this, result); }; }\nfunction _isNativeReflectConstruct$3() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nvar ResourceStore = function (_EventEmitter) {\n _inherits__default[\"default\"](ResourceStore, _EventEmitter);\n var _super = _createSuper$3(ResourceStore);\n function ResourceStore(data) {\n var _this;\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {\n ns: ['translation'],\n defaultNS: 'translation'\n };\n _classCallCheck__default[\"default\"](this, ResourceStore);\n _this = _super.call(this);\n if (isIE10) {\n EventEmitter.call(_assertThisInitialized__default[\"default\"](_this));\n }\n _this.data = data || {};\n _this.options = options;\n if (_this.options.keySeparator === undefined) {\n _this.options.keySeparator = '.';\n }\n if (_this.options.ignoreJSONStructure === undefined) {\n _this.options.ignoreJSONStructure = true;\n }\n return _this;\n }\n _createClass__default[\"default\"](ResourceStore, [{\n key: \"addNamespaces\",\n value: function addNamespaces(ns) {\n if (this.options.ns.indexOf(ns) < 0) {\n this.options.ns.push(ns);\n }\n }\n }, {\n key: \"removeNamespaces\",\n value: function removeNamespaces(ns) {\n var index = this.options.ns.indexOf(ns);\n if (index > -1) {\n this.options.ns.splice(index, 1);\n }\n }\n }, {\n key: \"getResource\",\n value: function getResource(lng, ns, key) {\n var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;\n var ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;\n var path = [lng, ns];\n if (key && typeof key !== 'string') path = path.concat(key);\n if (key && typeof key === 'string') path = path.concat(keySeparator ? key.split(keySeparator) : key);\n if (lng.indexOf('.') > -1) {\n path = lng.split('.');\n }\n var result = getPath(this.data, path);\n if (result || !ignoreJSONStructure || typeof key !== 'string') return result;\n return deepFind(this.data && this.data[lng] && this.data[lng][ns], key, keySeparator);\n }\n }, {\n key: \"addResource\",\n value: function addResource(lng, ns, key, value) {\n var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {\n silent: false\n };\n var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;\n var path = [lng, ns];\n if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);\n if (lng.indexOf('.') > -1) {\n path = lng.split('.');\n value = ns;\n ns = path[1];\n }\n this.addNamespaces(ns);\n setPath(this.data, path, value);\n if (!options.silent) this.emit('added', lng, ns, key, value);\n }\n }, {\n key: \"addResources\",\n value: function addResources(lng, ns, resources) {\n var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {\n silent: false\n };\n for (var m in resources) {\n if (typeof resources[m] === 'string' || Object.prototype.toString.apply(resources[m]) === '[object Array]') this.addResource(lng, ns, m, resources[m], {\n silent: true\n });\n }\n if (!options.silent) this.emit('added', lng, ns, resources);\n }\n }, {\n key: \"addResourceBundle\",\n value: function addResourceBundle(lng, ns, resources, deep, overwrite) {\n var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {\n silent: false\n };\n var path = [lng, ns];\n if (lng.indexOf('.') > -1) {\n path = lng.split('.');\n deep = resources;\n resources = ns;\n ns = path[1];\n }\n this.addNamespaces(ns);\n var pack = getPath(this.data, path) || {};\n if (deep) {\n deepExtend(pack, resources, overwrite);\n } else {\n pack = _objectSpread$5(_objectSpread$5({}, pack), resources);\n }\n setPath(this.data, path, pack);\n if (!options.silent) this.emit('added', lng, ns, resources);\n }\n }, {\n key: \"removeResourceBundle\",\n value: function removeResourceBundle(lng, ns) {\n if (this.hasResourceBundle(lng, ns)) {\n delete this.data[lng][ns];\n }\n this.removeNamespaces(ns);\n this.emit('removed', lng, ns);\n }\n }, {\n key: \"hasResourceBundle\",\n value: function hasResourceBundle(lng, ns) {\n return this.getResource(lng, ns) !== undefined;\n }\n }, {\n key: \"getResourceBundle\",\n value: function getResourceBundle(lng, ns) {\n if (!ns) ns = this.options.defaultNS;\n if (this.options.compatibilityAPI === 'v1') return _objectSpread$5(_objectSpread$5({}, {}), this.getResource(lng, ns));\n return this.getResource(lng, ns);\n }\n }, {\n key: \"getDataByLanguage\",\n value: function getDataByLanguage(lng) {\n return this.data[lng];\n }\n }, {\n key: \"hasLanguageSomeTranslations\",\n value: function hasLanguageSomeTranslations(lng) {\n var data = this.getDataByLanguage(lng);\n var n = data && Object.keys(data) || [];\n return !!n.find(function (v) {\n return data[v] && Object.keys(data[v]).length > 0;\n });\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n return this.data;\n }\n }]);\n return ResourceStore;\n}(EventEmitter);\n\nvar postProcessor = {\n processors: {},\n addPostProcessor: function addPostProcessor(module) {\n this.processors[module.name] = module;\n },\n handle: function handle(processors, value, key, options, translator) {\n var _this = this;\n processors.forEach(function (processor) {\n if (_this.processors[processor]) value = _this.processors[processor].process(value, key, options, translator);\n });\n return value;\n }\n};\n\nfunction ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty__default[\"default\"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { var Super = _getPrototypeOf__default[\"default\"](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default[\"default\"](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default[\"default\"](this, result); }; }\nfunction _isNativeReflectConstruct$2() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nvar checkedLoadedFor = {};\nvar Translator = function (_EventEmitter) {\n _inherits__default[\"default\"](Translator, _EventEmitter);\n var _super = _createSuper$2(Translator);\n function Translator(services) {\n var _this;\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n _classCallCheck__default[\"default\"](this, Translator);\n _this = _super.call(this);\n if (isIE10) {\n EventEmitter.call(_assertThisInitialized__default[\"default\"](_this));\n }\n copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, _assertThisInitialized__default[\"default\"](_this));\n _this.options = options;\n if (_this.options.keySeparator === undefined) {\n _this.options.keySeparator = '.';\n }\n _this.logger = baseLogger.create('translator');\n return _this;\n }\n _createClass__default[\"default\"](Translator, [{\n key: \"changeLanguage\",\n value: function changeLanguage(lng) {\n if (lng) this.language = lng;\n }\n }, {\n key: \"exists\",\n value: function exists(key) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {\n interpolation: {}\n };\n if (key === undefined || key === null) {\n return false;\n }\n var resolved = this.resolve(key, options);\n return resolved && resolved.res !== undefined;\n }\n }, {\n key: \"extractFromKey\",\n value: function extractFromKey(key, options) {\n var nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;\n if (nsSeparator === undefined) nsSeparator = ':';\n var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;\n var namespaces = options.ns || this.options.defaultNS || [];\n var wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;\n var seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);\n if (wouldCheckForNsInKey && !seemsNaturalLanguage) {\n var m = key.match(this.interpolator.nestingRegexp);\n if (m && m.length > 0) {\n return {\n key: key,\n namespaces: namespaces\n };\n }\n var parts = key.split(nsSeparator);\n if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();\n key = parts.join(keySeparator);\n }\n if (typeof namespaces === 'string') namespaces = [namespaces];\n return {\n key: key,\n namespaces: namespaces\n };\n }\n }, {\n key: \"translate\",\n value: function translate(keys, options, lastKey) {\n var _this2 = this;\n if (_typeof__default[\"default\"](options) !== 'object' && this.options.overloadTranslationOptionHandler) {\n options = this.options.overloadTranslationOptionHandler(arguments);\n }\n if (_typeof__default[\"default\"](options) === 'object') options = _objectSpread$4({}, options);\n if (!options) options = {};\n if (keys === undefined || keys === null) return '';\n if (!Array.isArray(keys)) keys = [String(keys)];\n var returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;\n var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;\n var _this$extractFromKey = this.extractFromKey(keys[keys.length - 1], options),\n key = _this$extractFromKey.key,\n namespaces = _this$extractFromKey.namespaces;\n var namespace = namespaces[namespaces.length - 1];\n var lng = options.lng || this.language;\n var appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;\n if (lng && lng.toLowerCase() === 'cimode') {\n if (appendNamespaceToCIMode) {\n var nsSeparator = options.nsSeparator || this.options.nsSeparator;\n if (returnDetails) {\n return {\n res: \"\".concat(namespace).concat(nsSeparator).concat(key),\n usedKey: key,\n exactUsedKey: key,\n usedLng: lng,\n usedNS: namespace\n };\n }\n return \"\".concat(namespace).concat(nsSeparator).concat(key);\n }\n if (returnDetails) {\n return {\n res: key,\n usedKey: key,\n exactUsedKey: key,\n usedLng: lng,\n usedNS: namespace\n };\n }\n return key;\n }\n var resolved = this.resolve(keys, options);\n var res = resolved && resolved.res;\n var resUsedKey = resolved && resolved.usedKey || key;\n var resExactUsedKey = resolved && resolved.exactUsedKey || key;\n var resType = Object.prototype.toString.apply(res);\n var noObject = ['[object Number]', '[object Function]', '[object RegExp]'];\n var joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;\n var handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;\n var handleAsObject = typeof res !== 'string' && typeof res !== 'boolean' && typeof res !== 'number';\n if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(typeof joinArrays === 'string' && resType === '[object Array]')) {\n if (!options.returnObjects && !this.options.returnObjects) {\n if (!this.options.returnedObjectHandler) {\n this.logger.warn('accessing an object - but returnObjects options is not enabled!');\n }\n var r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, _objectSpread$4(_objectSpread$4({}, options), {}, {\n ns: namespaces\n })) : \"key '\".concat(key, \" (\").concat(this.language, \")' returned an object instead of string.\");\n if (returnDetails) {\n resolved.res = r;\n return resolved;\n }\n return r;\n }\n if (keySeparator) {\n var resTypeIsArray = resType === '[object Array]';\n var copy = resTypeIsArray ? [] : {};\n var newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;\n for (var m in res) {\n if (Object.prototype.hasOwnProperty.call(res, m)) {\n var deepKey = \"\".concat(newKeyToUse).concat(keySeparator).concat(m);\n copy[m] = this.translate(deepKey, _objectSpread$4(_objectSpread$4({}, options), {\n joinArrays: false,\n ns: namespaces\n }));\n if (copy[m] === deepKey) copy[m] = res[m];\n }\n }\n res = copy;\n }\n } else if (handleAsObjectInI18nFormat && typeof joinArrays === 'string' && resType === '[object Array]') {\n res = res.join(joinArrays);\n if (res) res = this.extendTranslation(res, keys, options, lastKey);\n } else {\n var usedDefault = false;\n var usedKey = false;\n var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';\n var hasDefaultValue = Translator.hasDefaultValue(options);\n var defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';\n var defaultValue = options[\"defaultValue\".concat(defaultValueSuffix)] || options.defaultValue;\n if (!this.isValidLookup(res) && hasDefaultValue) {\n usedDefault = true;\n res = defaultValue;\n }\n if (!this.isValidLookup(res)) {\n usedKey = true;\n res = key;\n }\n var missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;\n var resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;\n var updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;\n if (usedKey || usedDefault || updateMissing) {\n this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);\n if (keySeparator) {\n var fk = this.resolve(key, _objectSpread$4(_objectSpread$4({}, options), {}, {\n keySeparator: false\n }));\n 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.');\n }\n var lngs = [];\n var fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);\n if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {\n for (var i = 0; i < fallbackLngs.length; i++) {\n lngs.push(fallbackLngs[i]);\n }\n } else if (this.options.saveMissingTo === 'all') {\n lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);\n } else {\n lngs.push(options.lng || this.language);\n }\n var send = function send(l, k, specificDefaultValue) {\n var defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;\n if (_this2.options.missingKeyHandler) {\n _this2.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);\n } else if (_this2.backendConnector && _this2.backendConnector.saveMissing) {\n _this2.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);\n }\n _this2.emit('missingKey', l, namespace, k, res);\n };\n if (this.options.saveMissing) {\n if (this.options.saveMissingPlurals && needsPluralHandling) {\n lngs.forEach(function (language) {\n _this2.pluralResolver.getSuffixes(language, options).forEach(function (suffix) {\n send([language], key + suffix, options[\"defaultValue\".concat(suffix)] || defaultValue);\n });\n });\n } else {\n send(lngs, key, defaultValue);\n }\n }\n }\n res = this.extendTranslation(res, keys, options, resolved, lastKey);\n if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = \"\".concat(namespace, \":\").concat(key);\n if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {\n if (this.options.compatibilityAPI !== 'v1') {\n res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? \"\".concat(namespace, \":\").concat(key) : key, usedDefault ? res : undefined);\n } else {\n res = this.options.parseMissingKeyHandler(res);\n }\n }\n }\n if (returnDetails) {\n resolved.res = res;\n return resolved;\n }\n return res;\n }\n }, {\n key: \"extendTranslation\",\n value: function extendTranslation(res, key, options, resolved, lastKey) {\n var _this3 = this;\n if (this.i18nFormat && this.i18nFormat.parse) {\n res = this.i18nFormat.parse(res, _objectSpread$4(_objectSpread$4({}, this.options.interpolation.defaultVariables), options), resolved.usedLng, resolved.usedNS, resolved.usedKey, {\n resolved: resolved\n });\n } else if (!options.skipInterpolation) {\n if (options.interpolation) this.interpolator.init(_objectSpread$4(_objectSpread$4({}, options), {\n interpolation: _objectSpread$4(_objectSpread$4({}, this.options.interpolation), options.interpolation)\n }));\n var skipOnVariables = typeof res === 'string' && (options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);\n var nestBef;\n if (skipOnVariables) {\n var nb = res.match(this.interpolator.nestingRegexp);\n nestBef = nb && nb.length;\n }\n var data = options.replace && typeof options.replace !== 'string' ? options.replace : options;\n if (this.options.interpolation.defaultVariables) data = _objectSpread$4(_objectSpread$4({}, this.options.interpolation.defaultVariables), data);\n res = this.interpolator.interpolate(res, data, options.lng || this.language, options);\n if (skipOnVariables) {\n var na = res.match(this.interpolator.nestingRegexp);\n var nestAft = na && na.length;\n if (nestBef < nestAft) options.nest = false;\n }\n if (!options.lng && this.options.compatibilityAPI !== 'v1' && resolved && resolved.res) options.lng = resolved.usedLng;\n if (options.nest !== false) res = this.interpolator.nest(res, function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n if (lastKey && lastKey[0] === args[0] && !options.context) {\n _this3.logger.warn(\"It seems you are nesting recursively key: \".concat(args[0], \" in key: \").concat(key[0]));\n return null;\n }\n return _this3.translate.apply(_this3, args.concat([key]));\n }, options);\n if (options.interpolation) this.interpolator.reset();\n }\n var postProcess = options.postProcess || this.options.postProcess;\n var postProcessorNames = typeof postProcess === 'string' ? [postProcess] : postProcess;\n if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {\n res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? _objectSpread$4({\n i18nResolved: resolved\n }, options) : options, this);\n }\n return res;\n }\n }, {\n key: \"resolve\",\n value: function resolve(keys) {\n var _this4 = this;\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var found;\n var usedKey;\n var exactUsedKey;\n var usedLng;\n var usedNS;\n if (typeof keys === 'string') keys = [keys];\n keys.forEach(function (k) {\n if (_this4.isValidLookup(found)) return;\n var extracted = _this4.extractFromKey(k, options);\n var key = extracted.key;\n usedKey = key;\n var namespaces = extracted.namespaces;\n if (_this4.options.fallbackNS) namespaces = namespaces.concat(_this4.options.fallbackNS);\n var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';\n var needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && _this4.pluralResolver.shouldUseIntlApi();\n var needsContextHandling = options.context !== undefined && (typeof options.context === 'string' || typeof options.context === 'number') && options.context !== '';\n var codes = options.lngs ? options.lngs : _this4.languageUtils.toResolveHierarchy(options.lng || _this4.language, options.fallbackLng);\n namespaces.forEach(function (ns) {\n if (_this4.isValidLookup(found)) return;\n usedNS = ns;\n if (!checkedLoadedFor[\"\".concat(codes[0], \"-\").concat(ns)] && _this4.utils && _this4.utils.hasLoadedNamespace && !_this4.utils.hasLoadedNamespace(usedNS)) {\n checkedLoadedFor[\"\".concat(codes[0], \"-\").concat(ns)] = true;\n _this4.logger.warn(\"key \\\"\".concat(usedKey, \"\\\" for languages \\\"\").concat(codes.join(', '), \"\\\" won't get resolved as namespace \\\"\").concat(usedNS, \"\\\" was not yet loaded\"), 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');\n }\n codes.forEach(function (code) {\n if (_this4.isValidLookup(found)) return;\n usedLng = code;\n var finalKeys = [key];\n if (_this4.i18nFormat && _this4.i18nFormat.addLookupKeys) {\n _this4.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);\n } else {\n var pluralSuffix;\n if (needsPluralHandling) pluralSuffix = _this4.pluralResolver.getSuffix(code, options.count, options);\n var zeroSuffix = \"\".concat(_this4.options.pluralSeparator, \"zero\");\n if (needsPluralHandling) {\n finalKeys.push(key + pluralSuffix);\n if (needsZeroSuffixLookup) {\n finalKeys.push(key + zeroSuffix);\n }\n }\n if (needsContextHandling) {\n var contextKey = \"\".concat(key).concat(_this4.options.contextSeparator).concat(options.context);\n finalKeys.push(contextKey);\n if (needsPluralHandling) {\n finalKeys.push(contextKey + pluralSuffix);\n if (needsZeroSuffixLookup) {\n finalKeys.push(contextKey + zeroSuffix);\n }\n }\n }\n }\n var possibleKey;\n while (possibleKey = finalKeys.pop()) {\n if (!_this4.isValidLookup(found)) {\n exactUsedKey = possibleKey;\n found = _this4.getResource(code, ns, possibleKey, options);\n }\n }\n });\n });\n });\n return {\n res: found,\n usedKey: usedKey,\n exactUsedKey: exactUsedKey,\n usedLng: usedLng,\n usedNS: usedNS\n };\n }\n }, {\n key: \"isValidLookup\",\n value: function isValidLookup(res) {\n return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');\n }\n }, {\n key: \"getResource\",\n value: function getResource(code, ns, key) {\n var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n if (this.i18nFormat && this.i18nFormat.getResource) return this.i18nFormat.getResource(code, ns, key, options);\n return this.resourceStore.getResource(code, ns, key, options);\n }\n }], [{\n key: \"hasDefaultValue\",\n value: function hasDefaultValue(options) {\n var prefix = 'defaultValue';\n for (var option in options) {\n if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {\n return true;\n }\n }\n return false;\n }\n }]);\n return Translator;\n}(EventEmitter);\n\nfunction capitalize(string) {\n return string.charAt(0).toUpperCase() + string.slice(1);\n}\nvar LanguageUtil = function () {\n function LanguageUtil(options) {\n _classCallCheck__default[\"default\"](this, LanguageUtil);\n this.options = options;\n this.supportedLngs = this.options.supportedLngs || false;\n this.logger = baseLogger.create('languageUtils');\n }\n _createClass__default[\"default\"](LanguageUtil, [{\n key: \"getScriptPartFromCode\",\n value: function getScriptPartFromCode(code) {\n if (!code || code.indexOf('-') < 0) return null;\n var p = code.split('-');\n if (p.length === 2) return null;\n p.pop();\n if (p[p.length - 1].toLowerCase() === 'x') return null;\n return this.formatLanguageCode(p.join('-'));\n }\n }, {\n key: \"getLanguagePartFromCode\",\n value: function getLanguagePartFromCode(code) {\n if (!code || code.indexOf('-') < 0) return code;\n var p = code.split('-');\n return this.formatLanguageCode(p[0]);\n }\n }, {\n key: \"formatLanguageCode\",\n value: function formatLanguageCode(code) {\n if (typeof code === 'string' && code.indexOf('-') > -1) {\n var specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];\n var p = code.split('-');\n if (this.options.lowerCaseLng) {\n p = p.map(function (part) {\n return part.toLowerCase();\n });\n } else if (p.length === 2) {\n p[0] = p[0].toLowerCase();\n p[1] = p[1].toUpperCase();\n if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());\n } else if (p.length === 3) {\n p[0] = p[0].toLowerCase();\n if (p[1].length === 2) p[1] = p[1].toUpperCase();\n if (p[0] !== 'sgn' && p[2].length === 2) p[2] = p[2].toUpperCase();\n if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());\n if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());\n }\n return p.join('-');\n }\n return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;\n }\n }, {\n key: \"isSupportedCode\",\n value: function isSupportedCode(code) {\n if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {\n code = this.getLanguagePartFromCode(code);\n }\n return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;\n }\n }, {\n key: \"getBestMatchFromCodes\",\n value: function getBestMatchFromCodes(codes) {\n var _this = this;\n if (!codes) return null;\n var found;\n codes.forEach(function (code) {\n if (found) return;\n var cleanedLng = _this.formatLanguageCode(code);\n if (!_this.options.supportedLngs || _this.isSupportedCode(cleanedLng)) found = cleanedLng;\n });\n if (!found && this.options.supportedLngs) {\n codes.forEach(function (code) {\n if (found) return;\n var lngOnly = _this.getLanguagePartFromCode(code);\n if (_this.isSupportedCode(lngOnly)) return found = lngOnly;\n found = _this.options.supportedLngs.find(function (supportedLng) {\n if (supportedLng === lngOnly) return supportedLng;\n if (supportedLng.indexOf('-') < 0 && lngOnly.indexOf('-') < 0) return;\n if (supportedLng.indexOf(lngOnly) === 0) return supportedLng;\n });\n });\n }\n if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];\n return found;\n }\n }, {\n key: \"getFallbackCodes\",\n value: function getFallbackCodes(fallbacks, code) {\n if (!fallbacks) return [];\n if (typeof fallbacks === 'function') fallbacks = fallbacks(code);\n if (typeof fallbacks === 'string') fallbacks = [fallbacks];\n if (Object.prototype.toString.apply(fallbacks) === '[object Array]') return fallbacks;\n if (!code) return fallbacks[\"default\"] || [];\n var found = fallbacks[code];\n if (!found) found = fallbacks[this.getScriptPartFromCode(code)];\n if (!found) found = fallbacks[this.formatLanguageCode(code)];\n if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];\n if (!found) found = fallbacks[\"default\"];\n return found || [];\n }\n }, {\n key: \"toResolveHierarchy\",\n value: function toResolveHierarchy(code, fallbackCode) {\n var _this2 = this;\n var fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);\n var codes = [];\n var addCode = function addCode(c) {\n if (!c) return;\n if (_this2.isSupportedCode(c)) {\n codes.push(c);\n } else {\n _this2.logger.warn(\"rejecting language code not found in supportedLngs: \".concat(c));\n }\n };\n if (typeof code === 'string' && code.indexOf('-') > -1) {\n if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));\n if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));\n if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));\n } else if (typeof code === 'string') {\n addCode(this.formatLanguageCode(code));\n }\n fallbackCodes.forEach(function (fc) {\n if (codes.indexOf(fc) < 0) addCode(_this2.formatLanguageCode(fc));\n });\n return codes;\n }\n }]);\n return LanguageUtil;\n}();\n\nvar sets = [{\n lngs: ['ach', 'ak', 'am', 'arn', 'br', 'fil', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt', 'pt-BR', 'tg', 'tl', 'ti', 'tr', 'uz', 'wa'],\n nr: [1, 2],\n fc: 1\n}, {\n 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'],\n nr: [1, 2],\n fc: 2\n}, {\n lngs: ['ay', 'bo', 'cgg', 'fa', 'ht', 'id', 'ja', 'jbo', 'ka', 'km', 'ko', 'ky', 'lo', 'ms', 'sah', 'su', 'th', 'tt', 'ug', 'vi', 'wo', 'zh'],\n nr: [1],\n fc: 3\n}, {\n lngs: ['be', 'bs', 'cnr', 'dz', 'hr', 'ru', 'sr', 'uk'],\n nr: [1, 2, 5],\n fc: 4\n}, {\n lngs: ['ar'],\n nr: [0, 1, 2, 3, 11, 100],\n fc: 5\n}, {\n lngs: ['cs', 'sk'],\n nr: [1, 2, 5],\n fc: 6\n}, {\n lngs: ['csb', 'pl'],\n nr: [1, 2, 5],\n fc: 7\n}, {\n lngs: ['cy'],\n nr: [1, 2, 3, 8],\n fc: 8\n}, {\n lngs: ['fr'],\n nr: [1, 2],\n fc: 9\n}, {\n lngs: ['ga'],\n nr: [1, 2, 3, 7, 11],\n fc: 10\n}, {\n lngs: ['gd'],\n nr: [1, 2, 3, 20],\n fc: 11\n}, {\n lngs: ['is'],\n nr: [1, 2],\n fc: 12\n}, {\n lngs: ['jv'],\n nr: [0, 1],\n fc: 13\n}, {\n lngs: ['kw'],\n nr: [1, 2, 3, 4],\n fc: 14\n}, {\n lngs: ['lt'],\n nr: [1, 2, 10],\n fc: 15\n}, {\n lngs: ['lv'],\n nr: [1, 2, 0],\n fc: 16\n}, {\n lngs: ['mk'],\n nr: [1, 2],\n fc: 17\n}, {\n lngs: ['mnk'],\n nr: [0, 1, 2],\n fc: 18\n}, {\n lngs: ['mt'],\n nr: [1, 2, 11, 20],\n fc: 19\n}, {\n lngs: ['or'],\n nr: [2, 1],\n fc: 2\n}, {\n lngs: ['ro'],\n nr: [1, 2, 20],\n fc: 20\n}, {\n lngs: ['sl'],\n nr: [5, 1, 2, 3],\n fc: 21\n}, {\n lngs: ['he', 'iw'],\n nr: [1, 2, 20, 21],\n fc: 22\n}];\nvar _rulesPluralsTypes = {\n 1: function _(n) {\n return Number(n > 1);\n },\n 2: function _(n) {\n return Number(n != 1);\n },\n 3: function _(n) {\n return 0;\n },\n 4: function _(n) {\n return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);\n },\n 5: function _(n) {\n return Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5);\n },\n 6: function _(n) {\n return Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2);\n },\n 7: function _(n) {\n return Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);\n },\n 8: function _(n) {\n return Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3);\n },\n 9: function _(n) {\n return Number(n >= 2);\n },\n 10: function _(n) {\n return Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4);\n },\n 11: function _(n) {\n return Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3);\n },\n 12: function _(n) {\n return Number(n % 10 != 1 || n % 100 == 11);\n },\n 13: function _(n) {\n return Number(n !== 0);\n },\n 14: function _(n) {\n return Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3);\n },\n 15: function _(n) {\n return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);\n },\n 16: function _(n) {\n return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2);\n },\n 17: function _(n) {\n return Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1);\n },\n 18: function _(n) {\n return Number(n == 0 ? 0 : n == 1 ? 1 : 2);\n },\n 19: function _(n) {\n return Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3);\n },\n 20: function _(n) {\n return Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2);\n },\n 21: function _(n) {\n return Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0);\n },\n 22: function _(n) {\n return Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3);\n }\n};\nvar deprecatedJsonVersions = ['v1', 'v2', 'v3'];\nvar suffixesOrder = {\n zero: 0,\n one: 1,\n two: 2,\n few: 3,\n many: 4,\n other: 5\n};\nfunction createRules() {\n var rules = {};\n sets.forEach(function (set) {\n set.lngs.forEach(function (l) {\n rules[l] = {\n numbers: set.nr,\n plurals: _rulesPluralsTypes[set.fc]\n };\n });\n });\n return rules;\n}\nvar PluralResolver = function () {\n function PluralResolver(languageUtils) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n _classCallCheck__default[\"default\"](this, PluralResolver);\n this.languageUtils = languageUtils;\n this.options = options;\n this.logger = baseLogger.create('pluralResolver');\n if ((!this.options.compatibilityJSON || this.options.compatibilityJSON === 'v4') && (typeof Intl === 'undefined' || !Intl.PluralRules)) {\n this.options.compatibilityJSON = 'v3';\n 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.');\n }\n this.rules = createRules();\n }\n _createClass__default[\"default\"](PluralResolver, [{\n key: \"addRule\",\n value: function addRule(lng, obj) {\n this.rules[lng] = obj;\n }\n }, {\n key: \"getRule\",\n value: function getRule(code) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n if (this.shouldUseIntlApi()) {\n try {\n return new Intl.PluralRules(code, {\n type: options.ordinal ? 'ordinal' : 'cardinal'\n });\n } catch (_unused) {\n return;\n }\n }\n return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];\n }\n }, {\n key: \"needsPlural\",\n value: function needsPlural(code) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var rule = this.getRule(code, options);\n if (this.shouldUseIntlApi()) {\n return rule && rule.resolvedOptions().pluralCategories.length > 1;\n }\n return rule && rule.numbers.length > 1;\n }\n }, {\n key: \"getPluralFormsOfKey\",\n value: function getPluralFormsOfKey(code, key) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n return this.getSuffixes(code, options).map(function (suffix) {\n return \"\".concat(key).concat(suffix);\n });\n }\n }, {\n key: \"getSuffixes\",\n value: function getSuffixes(code) {\n var _this = this;\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var rule = this.getRule(code, options);\n if (!rule) {\n return [];\n }\n if (this.shouldUseIntlApi()) {\n return rule.resolvedOptions().pluralCategories.sort(function (pluralCategory1, pluralCategory2) {\n return suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2];\n }).map(function (pluralCategory) {\n return \"\".concat(_this.options.prepend).concat(pluralCategory);\n });\n }\n return rule.numbers.map(function (number) {\n return _this.getSuffix(code, number, options);\n });\n }\n }, {\n key: \"getSuffix\",\n value: function getSuffix(code, count) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n var rule = this.getRule(code, options);\n if (rule) {\n if (this.shouldUseIntlApi()) {\n return \"\".concat(this.options.prepend).concat(rule.select(count));\n }\n return this.getSuffixRetroCompatible(rule, count);\n }\n this.logger.warn(\"no plural rule found for: \".concat(code));\n return '';\n }\n }, {\n key: \"getSuffixRetroCompatible\",\n value: function getSuffixRetroCompatible(rule, count) {\n var _this2 = this;\n var idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));\n var suffix = rule.numbers[idx];\n if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {\n if (suffix === 2) {\n suffix = 'plural';\n } else if (suffix === 1) {\n suffix = '';\n }\n }\n var returnSuffix = function returnSuffix() {\n return _this2.options.prepend && suffix.toString() ? _this2.options.prepend + suffix.toString() : suffix.toString();\n };\n if (this.options.compatibilityJSON === 'v1') {\n if (suffix === 1) return '';\n if (typeof suffix === 'number') return \"_plural_\".concat(suffix.toString());\n return returnSuffix();\n } else if (this.options.compatibilityJSON === 'v2') {\n return returnSuffix();\n } else if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {\n return returnSuffix();\n }\n return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();\n }\n }, {\n key: \"shouldUseIntlApi\",\n value: function shouldUseIntlApi() {\n return !deprecatedJsonVersions.includes(this.options.compatibilityJSON);\n }\n }]);\n return PluralResolver;\n}();\n\nfunction ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty__default[\"default\"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction deepFindWithDefaults(data, defaultData, key) {\n var keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';\n var ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;\n var path = getPathWithDefaults(data, defaultData, key);\n if (!path && ignoreJSONStructure && typeof key === 'string') {\n path = deepFind(data, key, keySeparator);\n if (path === undefined) path = deepFind(defaultData, key, keySeparator);\n }\n return path;\n}\nvar Interpolator = function () {\n function Interpolator() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n _classCallCheck__default[\"default\"](this, Interpolator);\n this.logger = baseLogger.create('interpolator');\n this.options = options;\n this.format = options.interpolation && options.interpolation.format || function (value) {\n return value;\n };\n this.init(options);\n }\n _createClass__default[\"default\"](Interpolator, [{\n key: \"init\",\n value: function init() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n if (!options.interpolation) options.interpolation = {\n escapeValue: true\n };\n var iOpts = options.interpolation;\n this.escape = iOpts.escape !== undefined ? iOpts.escape : escape;\n this.escapeValue = iOpts.escapeValue !== undefined ? iOpts.escapeValue : true;\n this.useRawValueToEscape = iOpts.useRawValueToEscape !== undefined ? iOpts.useRawValueToEscape : false;\n this.prefix = iOpts.prefix ? regexEscape(iOpts.prefix) : iOpts.prefixEscaped || '{{';\n this.suffix = iOpts.suffix ? regexEscape(iOpts.suffix) : iOpts.suffixEscaped || '}}';\n this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';\n this.unescapePrefix = iOpts.unescapeSuffix ? '' : iOpts.unescapePrefix || '-';\n this.unescapeSuffix = this.unescapePrefix ? '' : iOpts.unescapeSuffix || '';\n this.nestingPrefix = iOpts.nestingPrefix ? regexEscape(iOpts.nestingPrefix) : iOpts.nestingPrefixEscaped || regexEscape('$t(');\n this.nestingSuffix = iOpts.nestingSuffix ? regexEscape(iOpts.nestingSuffix) : iOpts.nestingSuffixEscaped || regexEscape(')');\n this.nestingOptionsSeparator = iOpts.nestingOptionsSeparator ? iOpts.nestingOptionsSeparator : iOpts.nestingOptionsSeparator || ',';\n this.maxReplaces = iOpts.maxReplaces ? iOpts.maxReplaces : 1000;\n this.alwaysFormat = iOpts.alwaysFormat !== undefined ? iOpts.alwaysFormat : false;\n this.resetRegExp();\n }\n }, {\n key: \"reset\",\n value: function reset() {\n if (this.options) this.init(this.options);\n }\n }, {\n key: \"resetRegExp\",\n value: function resetRegExp() {\n var regexpStr = \"\".concat(this.prefix, \"(.+?)\").concat(this.suffix);\n this.regexp = new RegExp(regexpStr, 'g');\n var regexpUnescapeStr = \"\".concat(this.prefix).concat(this.unescapePrefix, \"(.+?)\").concat(this.unescapeSuffix).concat(this.suffix);\n this.regexpUnescape = new RegExp(regexpUnescapeStr, 'g');\n var nestingRegexpStr = \"\".concat(this.nestingPrefix, \"(.+?)\").concat(this.nestingSuffix);\n this.nestingRegexp = new RegExp(nestingRegexpStr, 'g');\n }\n }, {\n key: \"interpolate\",\n value: function interpolate(str, data, lng, options) {\n var _this = this;\n var match;\n var value;\n var replaces;\n var defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};\n function regexSafe(val) {\n return val.replace(/\\$/g, '$$$$');\n }\n var handleFormat = function handleFormat(key) {\n if (key.indexOf(_this.formatSeparator) < 0) {\n var path = deepFindWithDefaults(data, defaultData, key, _this.options.keySeparator, _this.options.ignoreJSONStructure);\n return _this.alwaysFormat ? _this.format(path, undefined, lng, _objectSpread$3(_objectSpread$3(_objectSpread$3({}, options), data), {}, {\n interpolationkey: key\n })) : path;\n }\n var p = key.split(_this.formatSeparator);\n var k = p.shift().trim();\n var f = p.join(_this.formatSeparator).trim();\n return _this.format(deepFindWithDefaults(data, defaultData, k, _this.options.keySeparator, _this.options.ignoreJSONStructure), f, lng, _objectSpread$3(_objectSpread$3(_objectSpread$3({}, options), data), {}, {\n interpolationkey: k\n }));\n };\n this.resetRegExp();\n var missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;\n var skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;\n var todos = [{\n regex: this.regexpUnescape,\n safeValue: function safeValue(val) {\n return regexSafe(val);\n }\n }, {\n regex: this.regexp,\n safeValue: function safeValue(val) {\n return _this.escapeValue ? regexSafe(_this.escape(val)) : regexSafe(val);\n }\n }];\n todos.forEach(function (todo) {\n replaces = 0;\n while (match = todo.regex.exec(str)) {\n var matchedVar = match[1].trim();\n value = handleFormat(matchedVar);\n if (value === undefined) {\n if (typeof missingInterpolationHandler === 'function') {\n var temp = missingInterpolationHandler(str, match, options);\n value = typeof temp === 'string' ? temp : '';\n } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {\n value = '';\n } else if (skipOnVariables) {\n value = match[0];\n continue;\n } else {\n _this.logger.warn(\"missed to pass in variable \".concat(matchedVar, \" for interpolating \").concat(str));\n value = '';\n }\n } else if (typeof value !== 'string' && !_this.useRawValueToEscape) {\n value = makeString(value);\n }\n var safeValue = todo.safeValue(value);\n str = str.replace(match[0], safeValue);\n if (skipOnVariables) {\n todo.regex.lastIndex += value.length;\n todo.regex.lastIndex -= match[0].length;\n } else {\n todo.regex.lastIndex = 0;\n }\n replaces++;\n if (replaces >= _this.maxReplaces) {\n break;\n }\n }\n });\n return str;\n }\n }, {\n key: \"nest\",\n value: function nest(str, fc) {\n var _this2 = this;\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n var match;\n var value;\n var clonedOptions;\n function handleHasOptions(key, inheritedOptions) {\n var sep = this.nestingOptionsSeparator;\n if (key.indexOf(sep) < 0) return key;\n var c = key.split(new RegExp(\"\".concat(sep, \"[ ]*{\")));\n var optionsString = \"{\".concat(c[1]);\n key = c[0];\n optionsString = this.interpolate(optionsString, clonedOptions);\n var matchedSingleQuotes = optionsString.match(/'/g);\n var matchedDoubleQuotes = optionsString.match(/\"/g);\n if (matchedSingleQuotes && matchedSingleQuotes.length % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {\n optionsString = optionsString.replace(/'/g, '\"');\n }\n try {\n clonedOptions = JSON.parse(optionsString);\n if (inheritedOptions) clonedOptions = _objectSpread$3(_objectSpread$3({}, inheritedOptions), clonedOptions);\n } catch (e) {\n this.logger.warn(\"failed parsing options string in nesting for key \".concat(key), e);\n return \"\".concat(key).concat(sep).concat(optionsString);\n }\n delete clonedOptions.defaultValue;\n return key;\n }\n while (match = this.nestingRegexp.exec(str)) {\n var formatters = [];\n clonedOptions = _objectSpread$3({}, options);\n clonedOptions = clonedOptions.replace && typeof clonedOptions.replace !== 'string' ? clonedOptions.replace : clonedOptions;\n clonedOptions.applyPostProcessor = false;\n delete clonedOptions.defaultValue;\n var doReduce = false;\n if (match[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match[1])) {\n var r = match[1].split(this.formatSeparator).map(function (elem) {\n return elem.trim();\n });\n match[1] = r.shift();\n formatters = r;\n doReduce = true;\n }\n value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);\n if (value && match[0] === str && typeof value !== 'string') return value;\n if (typeof value !== 'string') value = makeString(value);\n if (!value) {\n this.logger.warn(\"missed to resolve \".concat(match[1], \" for nesting \").concat(str));\n value = '';\n }\n if (doReduce) {\n value = formatters.reduce(function (v, f) {\n return _this2.format(v, f, options.lng, _objectSpread$3(_objectSpread$3({}, options), {}, {\n interpolationkey: match[1].trim()\n }));\n }, value.trim());\n }\n str = str.replace(match[0], value);\n this.regexp.lastIndex = 0;\n }\n return str;\n }\n }]);\n return Interpolator;\n}();\n\nfunction ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty__default[\"default\"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction parseFormatStr(formatStr) {\n var formatName = formatStr.toLowerCase().trim();\n var formatOptions = {};\n if (formatStr.indexOf('(') > -1) {\n var p = formatStr.split('(');\n formatName = p[0].toLowerCase().trim();\n var optStr = p[1].substring(0, p[1].length - 1);\n if (formatName === 'currency' && optStr.indexOf(':') < 0) {\n if (!formatOptions.currency) formatOptions.currency = optStr.trim();\n } else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {\n if (!formatOptions.range) formatOptions.range = optStr.trim();\n } else {\n var opts = optStr.split(';');\n opts.forEach(function (opt) {\n if (!opt) return;\n var _opt$split = opt.split(':'),\n _opt$split2 = _toArray__default[\"default\"](_opt$split),\n key = _opt$split2[0],\n rest = _opt$split2.slice(1);\n var val = rest.join(':').trim().replace(/^'+|'+$/g, '');\n if (!formatOptions[key.trim()]) formatOptions[key.trim()] = val;\n if (val === 'false') formatOptions[key.trim()] = false;\n if (val === 'true') formatOptions[key.trim()] = true;\n if (!isNaN(val)) formatOptions[key.trim()] = parseInt(val, 10);\n });\n }\n }\n return {\n formatName: formatName,\n formatOptions: formatOptions\n };\n}\nfunction createCachedFormatter(fn) {\n var cache = {};\n return function invokeFormatter(val, lng, options) {\n var key = lng + JSON.stringify(options);\n var formatter = cache[key];\n if (!formatter) {\n formatter = fn(lng, options);\n cache[key] = formatter;\n }\n return formatter(val);\n };\n}\nvar Formatter = function () {\n function Formatter() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n _classCallCheck__default[\"default\"](this, Formatter);\n this.logger = baseLogger.create('formatter');\n this.options = options;\n this.formats = {\n number: createCachedFormatter(function (lng, opt) {\n var formatter = new Intl.NumberFormat(lng, _objectSpread$2({}, opt));\n return function (val) {\n return formatter.format(val);\n };\n }),\n currency: createCachedFormatter(function (lng, opt) {\n var formatter = new Intl.NumberFormat(lng, _objectSpread$2(_objectSpread$2({}, opt), {}, {\n style: 'currency'\n }));\n return function (val) {\n return formatter.format(val);\n };\n }),\n datetime: createCachedFormatter(function (lng, opt) {\n var formatter = new Intl.DateTimeFormat(lng, _objectSpread$2({}, opt));\n return function (val) {\n return formatter.format(val);\n };\n }),\n relativetime: createCachedFormatter(function (lng, opt) {\n var formatter = new Intl.RelativeTimeFormat(lng, _objectSpread$2({}, opt));\n return function (val) {\n return formatter.format(val, opt.range || 'day');\n };\n }),\n list: createCachedFormatter(function (lng, opt) {\n var formatter = new Intl.ListFormat(lng, _objectSpread$2({}, opt));\n return function (val) {\n return formatter.format(val);\n };\n })\n };\n this.init(options);\n }\n _createClass__default[\"default\"](Formatter, [{\n key: \"init\",\n value: function init(services) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {\n interpolation: {}\n };\n var iOpts = options.interpolation;\n this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';\n }\n }, {\n key: \"add\",\n value: function add(name, fc) {\n this.formats[name.toLowerCase().trim()] = fc;\n }\n }, {\n key: \"addCached\",\n value: function addCached(name, fc) {\n this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);\n }\n }, {\n key: \"format\",\n value: function format(value, _format, lng) {\n var _this = this;\n var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n var formats = _format.split(this.formatSeparator);\n var result = formats.reduce(function (mem, f) {\n var _parseFormatStr = parseFormatStr(f),\n formatName = _parseFormatStr.formatName,\n formatOptions = _parseFormatStr.formatOptions;\n if (_this.formats[formatName]) {\n var formatted = mem;\n try {\n var valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || {};\n var l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;\n formatted = _this.formats[formatName](mem, l, _objectSpread$2(_objectSpread$2(_objectSpread$2({}, formatOptions), options), valOptions));\n } catch (error) {\n _this.logger.warn(error);\n }\n return formatted;\n } else {\n _this.logger.warn(\"there was no format function for \".concat(formatName));\n }\n return mem;\n }, value);\n return result;\n }\n }]);\n return Formatter;\n}();\n\nfunction ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty__default[\"default\"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf__default[\"default\"](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default[\"default\"](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default[\"default\"](this, result); }; }\nfunction _isNativeReflectConstruct$1() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction removePending(q, name) {\n if (q.pending[name] !== undefined) {\n delete q.pending[name];\n q.pendingCount--;\n }\n}\nvar Connector = function (_EventEmitter) {\n _inherits__default[\"default\"](Connector, _EventEmitter);\n var _super = _createSuper$1(Connector);\n function Connector(backend, store, services) {\n var _this;\n var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n _classCallCheck__default[\"default\"](this, Connector);\n _this = _super.call(this);\n if (isIE10) {\n EventEmitter.call(_assertThisInitialized__default[\"default\"](_this));\n }\n _this.backend = backend;\n _this.store = store;\n _this.services = services;\n _this.languageUtils = services.languageUtils;\n _this.options = options;\n _this.logger = baseLogger.create('backendConnector');\n _this.waitingReads = [];\n _this.maxParallelReads = options.maxParallelReads || 10;\n _this.readingCalls = 0;\n _this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;\n _this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;\n _this.state = {};\n _this.queue = [];\n if (_this.backend && _this.backend.init) {\n _this.backend.init(services, options.backend, options);\n }\n return _this;\n }\n _createClass__default[\"default\"](Connector, [{\n key: \"queueLoad\",\n value: function queueLoad(languages, namespaces, options, callback) {\n var _this2 = this;\n var toLoad = {};\n var pending = {};\n var toLoadLanguages = {};\n var toLoadNamespaces = {};\n languages.forEach(function (lng) {\n var hasAllNamespaces = true;\n namespaces.forEach(function (ns) {\n var name = \"\".concat(lng, \"|\").concat(ns);\n if (!options.reload && _this2.store.hasResourceBundle(lng, ns)) {\n _this2.state[name] = 2;\n } else if (_this2.state[name] < 0) ; else if (_this2.state[name] === 1) {\n if (pending[name] === undefined) pending[name] = true;\n } else {\n _this2.state[name] = 1;\n hasAllNamespaces = false;\n if (pending[name] === undefined) pending[name] = true;\n if (toLoad[name] === undefined) toLoad[name] = true;\n if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;\n }\n });\n if (!hasAllNamespaces) toLoadLanguages[lng] = true;\n });\n if (Object.keys(toLoad).length || Object.keys(pending).length) {\n this.queue.push({\n pending: pending,\n pendingCount: Object.keys(pending).length,\n loaded: {},\n errors: [],\n callback: callback\n });\n }\n return {\n toLoad: Object.keys(toLoad),\n pending: Object.keys(pending),\n toLoadLanguages: Object.keys(toLoadLanguages),\n toLoadNamespaces: Object.keys(toLoadNamespaces)\n };\n }\n }, {\n key: \"loaded\",\n value: function loaded(name, err, data) {\n var s = name.split('|');\n var lng = s[0];\n var ns = s[1];\n if (err) this.emit('failedLoading', lng, ns, err);\n if (data) {\n this.store.addResourceBundle(lng, ns, data);\n }\n this.state[name] = err ? -1 : 2;\n var loaded = {};\n this.queue.forEach(function (q) {\n pushPath(q.loaded, [lng], ns);\n removePending(q, name);\n if (err) q.errors.push(err);\n if (q.pendingCount === 0 && !q.done) {\n Object.keys(q.loaded).forEach(function (l) {\n if (!loaded[l]) loaded[l] = {};\n var loadedKeys = q.loaded[l];\n if (loadedKeys.length) {\n loadedKeys.forEach(function (n) {\n if (loaded[l][n] === undefined) loaded[l][n] = true;\n });\n }\n });\n q.done = true;\n if (q.errors.length) {\n q.callback(q.errors);\n } else {\n q.callback();\n }\n }\n });\n this.emit('loaded', loaded);\n this.queue = this.queue.filter(function (q) {\n return !q.done;\n });\n }\n }, {\n key: \"read\",\n value: function read(lng, ns, fcName) {\n var _this3 = this;\n var tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;\n var wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;\n var callback = arguments.length > 5 ? arguments[5] : undefined;\n if (!lng.length) return callback(null, {});\n if (this.readingCalls >= this.maxParallelReads) {\n this.waitingReads.push({\n lng: lng,\n ns: ns,\n fcName: fcName,\n tried: tried,\n wait: wait,\n callback: callback\n });\n return;\n }\n this.readingCalls++;\n var resolver = function resolver(err, data) {\n _this3.readingCalls--;\n if (_this3.waitingReads.length > 0) {\n var next = _this3.waitingReads.shift();\n _this3.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);\n }\n if (err && data && tried < _this3.maxRetries) {\n setTimeout(function () {\n _this3.read.call(_this3, lng, ns, fcName, tried + 1, wait * 2, callback);\n }, wait);\n return;\n }\n callback(err, data);\n };\n var fc = this.backend[fcName].bind(this.backend);\n if (fc.length === 2) {\n try {\n var r = fc(lng, ns);\n if (r && typeof r.then === 'function') {\n r.then(function (data) {\n return resolver(null, data);\n })[\"catch\"](resolver);\n } else {\n resolver(null, r);\n }\n } catch (err) {\n resolver(err);\n }\n return;\n }\n return fc(lng, ns, resolver);\n }\n }, {\n key: \"prepareLoading\",\n value: function prepareLoading(languages, namespaces) {\n var _this4 = this;\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n var callback = arguments.length > 3 ? arguments[3] : undefined;\n if (!this.backend) {\n this.logger.warn('No backend was added via i18next.use. Will not load resources.');\n return callback && callback();\n }\n if (typeof languages === 'string') languages = this.languageUtils.toResolveHierarchy(languages);\n if (typeof namespaces === 'string') namespaces = [namespaces];\n var toLoad = this.queueLoad(languages, namespaces, options, callback);\n if (!toLoad.toLoad.length) {\n if (!toLoad.pending.length) callback();\n return null;\n }\n toLoad.toLoad.forEach(function (name) {\n _this4.loadOne(name);\n });\n }\n }, {\n key: \"load\",\n value: function load(languages, namespaces, callback) {\n this.prepareLoading(languages, namespaces, {}, callback);\n }\n }, {\n key: \"reload\",\n value: function reload(languages, namespaces, callback) {\n this.prepareLoading(languages, namespaces, {\n reload: true\n }, callback);\n }\n }, {\n key: \"loadOne\",\n value: function loadOne(name) {\n var _this5 = this;\n var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';\n var s = name.split('|');\n var lng = s[0];\n var ns = s[1];\n this.read(lng, ns, 'read', undefined, undefined, function (err, data) {\n if (err) _this5.logger.warn(\"\".concat(prefix, \"loading namespace \").concat(ns, \" for language \").concat(lng, \" failed\"), err);\n if (!err && data) _this5.logger.log(\"\".concat(prefix, \"loaded namespace \").concat(ns, \" for language \").concat(lng), data);\n _this5.loaded(name, err, data);\n });\n }\n }, {\n key: \"saveMissing\",\n value: function saveMissing(languages, namespace, key, fallbackValue, isUpdate) {\n var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};\n var clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : function () {};\n if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {\n this.logger.warn(\"did not save key \\\"\".concat(key, \"\\\" as the namespace \\\"\").concat(namespace, \"\\\" was not yet loaded\"), 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');\n return;\n }\n if (key === undefined || key === null || key === '') return;\n if (this.backend && this.backend.create) {\n var opts = _objectSpread$1(_objectSpread$1({}, options), {}, {\n isUpdate: isUpdate\n });\n var fc = this.backend.create.bind(this.backend);\n if (fc.length < 6) {\n try {\n var r;\n if (fc.length === 5) {\n r = fc(languages, namespace, key, fallbackValue, opts);\n } else {\n r = fc(languages, namespace, key, fallbackValue);\n }\n if (r && typeof r.then === 'function') {\n r.then(function (data) {\n return clb(null, data);\n })[\"catch\"](clb);\n } else {\n clb(null, r);\n }\n } catch (err) {\n clb(err);\n }\n } else {\n fc(languages, namespace, key, fallbackValue, clb, opts);\n }\n }\n if (!languages || !languages[0]) return;\n this.store.addResource(languages[0], namespace, key, fallbackValue);\n }\n }]);\n return Connector;\n}(EventEmitter);\n\nfunction get() {\n return {\n debug: false,\n initImmediate: true,\n ns: ['translation'],\n defaultNS: ['translation'],\n fallbackLng: ['dev'],\n fallbackNS: false,\n supportedLngs: false,\n nonExplicitSupportedLngs: false,\n load: 'all',\n preload: false,\n simplifyPluralSuffix: true,\n keySeparator: '.',\n nsSeparator: ':',\n pluralSeparator: '_',\n contextSeparator: '_',\n partialBundledLanguages: false,\n saveMissing: false,\n updateMissing: false,\n saveMissingTo: 'fallback',\n saveMissingPlurals: true,\n missingKeyHandler: false,\n missingInterpolationHandler: false,\n postProcess: false,\n postProcessPassResolved: false,\n returnNull: true,\n returnEmptyString: true,\n returnObjects: false,\n joinArrays: false,\n returnedObjectHandler: false,\n parseMissingKeyHandler: false,\n appendNamespaceToMissingKey: false,\n appendNamespaceToCIMode: false,\n overloadTranslationOptionHandler: function handle(args) {\n var ret = {};\n if (_typeof__default[\"default\"](args[1]) === 'object') ret = args[1];\n if (typeof args[1] === 'string') ret.defaultValue = args[1];\n if (typeof args[2] === 'string') ret.tDescription = args[2];\n if (_typeof__default[\"default\"](args[2]) === 'object' || _typeof__default[\"default\"](args[3]) === 'object') {\n var options = args[3] || args[2];\n Object.keys(options).forEach(function (key) {\n ret[key] = options[key];\n });\n }\n return ret;\n },\n interpolation: {\n escapeValue: true,\n format: function format(value, _format, lng, options) {\n return value;\n },\n prefix: '{{',\n suffix: '}}',\n formatSeparator: ',',\n unescapePrefix: '-',\n nestingPrefix: '$t(',\n nestingSuffix: ')',\n nestingOptionsSeparator: ',',\n maxReplaces: 1000,\n skipOnVariables: true\n }\n };\n}\nfunction transformOptions(options) {\n if (typeof options.ns === 'string') options.ns = [options.ns];\n if (typeof options.fallbackLng === 'string') options.fallbackLng = [options.fallbackLng];\n if (typeof options.fallbackNS === 'string') options.fallbackNS = [options.fallbackNS];\n if (options.supportedLngs && options.supportedLngs.indexOf('cimode') < 0) {\n options.supportedLngs = options.supportedLngs.concat(['cimode']);\n }\n return options;\n}\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default[\"default\"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf__default[\"default\"](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default[\"default\"](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default[\"default\"](this, result); }; }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction noop() {}\nfunction bindMemberFunctions(inst) {\n var mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));\n mems.forEach(function (mem) {\n if (typeof inst[mem] === 'function') {\n inst[mem] = inst[mem].bind(inst);\n }\n });\n}\nvar I18n = function (_EventEmitter) {\n _inherits__default[\"default\"](I18n, _EventEmitter);\n var _super = _createSuper(I18n);\n function I18n() {\n var _this;\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var callback = arguments.length > 1 ? arguments[1] : undefined;\n _classCallCheck__default[\"default\"](this, I18n);\n _this = _super.call(this);\n if (isIE10) {\n EventEmitter.call(_assertThisInitialized__default[\"default\"](_this));\n }\n _this.options = transformOptions(options);\n _this.services = {};\n _this.logger = baseLogger;\n _this.modules = {\n external: []\n };\n bindMemberFunctions(_assertThisInitialized__default[\"default\"](_this));\n if (callback && !_this.isInitialized && !options.isClone) {\n if (!_this.options.initImmediate) {\n _this.init(options, callback);\n return _possibleConstructorReturn__default[\"default\"](_this, _assertThisInitialized__default[\"default\"](_this));\n }\n setTimeout(function () {\n _this.init(options, callback);\n }, 0);\n }\n return _this;\n }\n _createClass__default[\"default\"](I18n, [{\n key: \"init\",\n value: function init() {\n var _this2 = this;\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var callback = arguments.length > 1 ? arguments[1] : undefined;\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n if (!options.defaultNS && options.defaultNS !== false && options.ns) {\n if (typeof options.ns === 'string') {\n options.defaultNS = options.ns;\n } else if (options.ns.indexOf('translation') < 0) {\n options.defaultNS = options.ns[0];\n }\n }\n var defOpts = get();\n this.options = _objectSpread(_objectSpread(_objectSpread({}, defOpts), this.options), transformOptions(options));\n if (this.options.compatibilityAPI !== 'v1') {\n this.options.interpolation = _objectSpread(_objectSpread({}, defOpts.interpolation), this.options.interpolation);\n }\n if (options.keySeparator !== undefined) {\n this.options.userDefinedKeySeparator = options.keySeparator;\n }\n if (options.nsSeparator !== undefined) {\n this.options.userDefinedNsSeparator = options.nsSeparator;\n }\n function createClassOnDemand(ClassOrObject) {\n if (!ClassOrObject) return null;\n if (typeof ClassOrObject === 'function') return new ClassOrObject();\n return ClassOrObject;\n }\n if (!this.options.isClone) {\n if (this.modules.logger) {\n baseLogger.init(createClassOnDemand(this.modules.logger), this.options);\n } else {\n baseLogger.init(null, this.options);\n }\n var formatter;\n if (this.modules.formatter) {\n formatter = this.modules.formatter;\n } else if (typeof Intl !== 'undefined') {\n formatter = Formatter;\n }\n var lu = new LanguageUtil(this.options);\n this.store = new ResourceStore(this.options.resources, this.options);\n var s = this.services;\n s.logger = baseLogger;\n s.resourceStore = this.store;\n s.languageUtils = lu;\n s.pluralResolver = new PluralResolver(lu, {\n prepend: this.options.pluralSeparator,\n compatibilityJSON: this.options.compatibilityJSON,\n simplifyPluralSuffix: this.options.simplifyPluralSuffix\n });\n if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {\n s.formatter = createClassOnDemand(formatter);\n s.formatter.init(s, this.options);\n this.options.interpolation.format = s.formatter.format.bind(s.formatter);\n }\n s.interpolator = new Interpolator(this.options);\n s.utils = {\n hasLoadedNamespace: this.hasLoadedNamespace.bind(this)\n };\n s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);\n s.backendConnector.on('*', function (event) {\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n _this2.emit.apply(_this2, [event].concat(args));\n });\n if (this.modules.languageDetector) {\n s.languageDetector = createClassOnDemand(this.modules.languageDetector);\n if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);\n }\n if (this.modules.i18nFormat) {\n s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);\n if (s.i18nFormat.init) s.i18nFormat.init(this);\n }\n this.translator = new Translator(this.services, this.options);\n this.translator.on('*', function (event) {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n _this2.emit.apply(_this2, [event].concat(args));\n });\n this.modules.external.forEach(function (m) {\n if (m.init) m.init(_this2);\n });\n }\n this.format = this.options.interpolation.format;\n if (!callback) callback = noop;\n if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {\n var codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);\n if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];\n }\n if (!this.services.languageDetector && !this.options.lng) {\n this.logger.warn('init: no languageDetector is used and no lng is defined');\n }\n var storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];\n storeApi.forEach(function (fcName) {\n _this2[fcName] = function () {\n var _this2$store;\n return (_this2$store = _this2.store)[fcName].apply(_this2$store, arguments);\n };\n });\n var storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];\n storeApiChained.forEach(function (fcName) {\n _this2[fcName] = function () {\n var _this2$store2;\n (_this2$store2 = _this2.store)[fcName].apply(_this2$store2, arguments);\n return _this2;\n };\n });\n var deferred = defer();\n var load = function load() {\n var finish = function finish(err, t) {\n if (_this2.isInitialized && !_this2.initializedStoreOnce) _this2.logger.warn('init: i18next is already initialized. You should call init just once!');\n _this2.isInitialized = true;\n if (!_this2.options.isClone) _this2.logger.log('initialized', _this2.options);\n _this2.emit('initialized', _this2.options);\n deferred.resolve(t);\n callback(err, t);\n };\n if (_this2.languages && _this2.options.compatibilityAPI !== 'v1' && !_this2.isInitialized) return finish(null, _this2.t.bind(_this2));\n _this2.changeLanguage(_this2.options.lng, finish);\n };\n if (this.options.resources || !this.options.initImmediate) {\n load();\n } else {\n setTimeout(load, 0);\n }\n return deferred;\n }\n }, {\n key: \"loadResources\",\n value: function loadResources(language) {\n var _this3 = this;\n var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;\n var usedCallback = callback;\n var usedLng = typeof language === 'string' ? language : this.language;\n if (typeof language === 'function') usedCallback = language;\n if (!this.options.resources || this.options.partialBundledLanguages) {\n if (usedLng && usedLng.toLowerCase() === 'cimode') return usedCallback();\n var toLoad = [];\n var append = function append(lng) {\n if (!lng) return;\n var lngs = _this3.services.languageUtils.toResolveHierarchy(lng);\n lngs.forEach(function (l) {\n if (toLoad.indexOf(l) < 0) toLoad.push(l);\n });\n };\n if (!usedLng) {\n var fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);\n fallbacks.forEach(function (l) {\n return append(l);\n });\n } else {\n append(usedLng);\n }\n if (this.options.preload) {\n this.options.preload.forEach(function (l) {\n return append(l);\n });\n }\n this.services.backendConnector.load(toLoad, this.options.ns, function (e) {\n if (!e && !_this3.resolvedLanguage && _this3.language) _this3.setResolvedLanguage(_this3.language);\n usedCallback(e);\n });\n } else {\n usedCallback(null);\n }\n }\n }, {\n key: \"reloadResources\",\n value: function reloadResources(lngs, ns, callback) {\n var deferred = defer();\n if (!lngs) lngs = this.languages;\n if (!ns) ns = this.options.ns;\n if (!callback) callback = noop;\n this.services.backendConnector.reload(lngs, ns, function (err) {\n deferred.resolve();\n callback(err);\n });\n return deferred;\n }\n }, {\n key: \"use\",\n value: function use(module) {\n if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');\n if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');\n if (module.type === 'backend') {\n this.modules.backend = module;\n }\n if (module.type === 'logger' || module.log && module.warn && module.error) {\n this.modules.logger = module;\n }\n if (module.type === 'languageDetector') {\n this.modules.languageDetector = module;\n }\n if (module.type === 'i18nFormat') {\n this.modules.i18nFormat = module;\n }\n if (module.type === 'postProcessor') {\n postProcessor.addPostProcessor(module);\n }\n if (module.type === 'formatter') {\n this.modules.formatter = module;\n }\n if (module.type === '3rdParty') {\n this.modules.external.push(module);\n }\n return this;\n }\n }, {\n key: \"setResolvedLanguage\",\n value: function setResolvedLanguage(l) {\n if (!l || !this.languages) return;\n if (['cimode', 'dev'].indexOf(l) > -1) return;\n for (var li = 0; li < this.languages.length; li++) {\n var lngInLngs = this.languages[li];\n if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;\n if (this.store.hasLanguageSomeTranslations(lngInLngs)) {\n this.resolvedLanguage = lngInLngs;\n break;\n }\n }\n }\n }, {\n key: \"changeLanguage\",\n value: function changeLanguage(lng, callback) {\n var _this4 = this;\n this.isLanguageChangingTo = lng;\n var deferred = defer();\n this.emit('languageChanging', lng);\n var setLngProps = function setLngProps(l) {\n _this4.language = l;\n _this4.languages = _this4.services.languageUtils.toResolveHierarchy(l);\n _this4.resolvedLanguage = undefined;\n _this4.setResolvedLanguage(l);\n };\n var done = function done(err, l) {\n if (l) {\n setLngProps(l);\n _this4.translator.changeLanguage(l);\n _this4.isLanguageChangingTo = undefined;\n _this4.emit('languageChanged', l);\n _this4.logger.log('languageChanged', l);\n } else {\n _this4.isLanguageChangingTo = undefined;\n }\n deferred.resolve(function () {\n return _this4.t.apply(_this4, arguments);\n });\n if (callback) callback(err, function () {\n return _this4.t.apply(_this4, arguments);\n });\n };\n var setLng = function setLng(lngs) {\n if (!lng && !lngs && _this4.services.languageDetector) lngs = [];\n var l = typeof lngs === 'string' ? lngs : _this4.services.languageUtils.getBestMatchFromCodes(lngs);\n if (l) {\n if (!_this4.language) {\n setLngProps(l);\n }\n if (!_this4.translator.language) _this4.translator.changeLanguage(l);\n if (_this4.services.languageDetector && _this4.services.languageDetector.cacheUserLanguage) _this4.services.languageDetector.cacheUserLanguage(l);\n }\n _this4.loadResources(l, function (err) {\n done(err, l);\n });\n };\n if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {\n setLng(this.services.languageDetector.detect());\n } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {\n if (this.services.languageDetector.detect.length === 0) {\n this.services.languageDetector.detect().then(setLng);\n } else {\n this.services.languageDetector.detect(setLng);\n }\n } else {\n setLng(lng);\n }\n return deferred;\n }\n }, {\n key: \"getFixedT\",\n value: function getFixedT(lng, ns, keyPrefix) {\n var _this5 = this;\n var fixedT = function fixedT(key, opts) {\n var options;\n if (_typeof__default[\"default\"](opts) !== 'object') {\n for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {\n rest[_key3 - 2] = arguments[_key3];\n }\n options = _this5.options.overloadTranslationOptionHandler([key, opts].concat(rest));\n } else {\n options = _objectSpread({}, opts);\n }\n options.lng = options.lng || fixedT.lng;\n options.lngs = options.lngs || fixedT.lngs;\n options.ns = options.ns || fixedT.ns;\n options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;\n var keySeparator = _this5.options.keySeparator || '.';\n var resultKey;\n if (options.keyPrefix && Array.isArray(key)) {\n resultKey = key.map(function (k) {\n return \"\".concat(options.keyPrefix).concat(keySeparator).concat(k);\n });\n } else {\n resultKey = options.keyPrefix ? \"\".concat(options.keyPrefix).concat(keySeparator).concat(key) : key;\n }\n return _this5.t(resultKey, options);\n };\n if (typeof lng === 'string') {\n fixedT.lng = lng;\n } else {\n fixedT.lngs = lng;\n }\n fixedT.ns = ns;\n fixedT.keyPrefix = keyPrefix;\n return fixedT;\n }\n }, {\n key: \"t\",\n value: function t() {\n var _this$translator;\n return this.translator && (_this$translator = this.translator).translate.apply(_this$translator, arguments);\n }\n }, {\n key: \"exists\",\n value: function exists() {\n var _this$translator2;\n return this.translator && (_this$translator2 = this.translator).exists.apply(_this$translator2, arguments);\n }\n }, {\n key: \"setDefaultNamespace\",\n value: function setDefaultNamespace(ns) {\n this.options.defaultNS = ns;\n }\n }, {\n key: \"hasLoadedNamespace\",\n value: function hasLoadedNamespace(ns) {\n var _this6 = this;\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n if (!this.isInitialized) {\n this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);\n return false;\n }\n if (!this.languages || !this.languages.length) {\n this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);\n return false;\n }\n var lng = options.lng || this.resolvedLanguage || this.languages[0];\n var fallbackLng = this.options ? this.options.fallbackLng : false;\n var lastLng = this.languages[this.languages.length - 1];\n if (lng.toLowerCase() === 'cimode') return true;\n var loadNotPending = function loadNotPending(l, n) {\n var loadState = _this6.services.backendConnector.state[\"\".concat(l, \"|\").concat(n)];\n return loadState === -1 || loadState === 2;\n };\n if (options.precheck) {\n var preResult = options.precheck(this, loadNotPending);\n if (preResult !== undefined) return preResult;\n }\n if (this.hasResourceBundle(lng, ns)) return true;\n if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;\n if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;\n return false;\n }\n }, {\n key: \"loadNamespaces\",\n value: function loadNamespaces(ns, callback) {\n var _this7 = this;\n var deferred = defer();\n if (!this.options.ns) {\n if (callback) callback();\n return Promise.resolve();\n }\n if (typeof ns === 'string') ns = [ns];\n ns.forEach(function (n) {\n if (_this7.options.ns.indexOf(n) < 0) _this7.options.ns.push(n);\n });\n this.loadResources(function (err) {\n deferred.resolve();\n if (callback) callback(err);\n });\n return deferred;\n }\n }, {\n key: \"loadLanguages\",\n value: function loadLanguages(lngs, callback) {\n var deferred = defer();\n if (typeof lngs === 'string') lngs = [lngs];\n var preloaded = this.options.preload || [];\n var newLngs = lngs.filter(function (lng) {\n return preloaded.indexOf(lng) < 0;\n });\n if (!newLngs.length) {\n if (callback) callback();\n return Promise.resolve();\n }\n this.options.preload = preloaded.concat(newLngs);\n this.loadResources(function (err) {\n deferred.resolve();\n if (callback) callback(err);\n });\n return deferred;\n }\n }, {\n key: \"dir\",\n value: function dir(lng) {\n if (!lng) lng = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language);\n if (!lng) return 'rtl';\n var rtlLngs = ['ar', 'shu', 'sqr', 'ssh', 'xaa', 'yhd', 'yud', 'aao', 'abh', 'abv', 'acm', 'acq', 'acw', 'acx', 'acy', 'adf', 'ads', 'aeb', 'aec', 'afb', 'ajp', 'apc', 'apd', 'arb', 'arq', 'ars', 'ary', 'arz', 'auz', 'avl', 'ayh', 'ayl', 'ayn', 'ayp', 'bbz', 'pga', 'he', 'iw', 'ps', 'pbt', 'pbu', 'pst', 'prp', 'prd', 'ug', 'ur', 'ydd', 'yds', 'yih', 'ji', 'yi', 'hbo', 'men', 'xmn', 'fa', 'jpr', 'peo', 'pes', 'prs', 'dv', 'sam', 'ckb'];\n var languageUtils = this.services && this.services.languageUtils || new LanguageUtil(get());\n return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';\n }\n }, {\n key: \"cloneInstance\",\n value: function cloneInstance() {\n var _this8 = this;\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;\n var mergedOptions = _objectSpread(_objectSpread(_objectSpread({}, this.options), options), {\n isClone: true\n });\n var clone = new I18n(mergedOptions);\n if (options.debug !== undefined || options.prefix !== undefined) {\n clone.logger = clone.logger.clone(options);\n }\n var membersToCopy = ['store', 'services', 'language'];\n membersToCopy.forEach(function (m) {\n clone[m] = _this8[m];\n });\n clone.services = _objectSpread({}, this.services);\n clone.services.utils = {\n hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)\n };\n clone.translator = new Translator(clone.services, clone.options);\n clone.translator.on('*', function (event) {\n for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {\n args[_key4 - 1] = arguments[_key4];\n }\n clone.emit.apply(clone, [event].concat(args));\n });\n clone.init(mergedOptions, callback);\n clone.translator.options = clone.options;\n clone.translator.backendConnector.services.utils = {\n hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)\n };\n return clone;\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n return {\n options: this.options,\n store: this.store,\n language: this.language,\n languages: this.languages,\n resolvedLanguage: this.resolvedLanguage\n };\n }\n }]);\n return I18n;\n}(EventEmitter);\n_defineProperty__default[\"default\"](I18n, \"createInstance\", function () {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var callback = arguments.length > 1 ? arguments[1] : undefined;\n return new I18n(options, callback);\n});\nvar instance = I18n.createInstance();\ninstance.createInstance = I18n.createInstance;\n\nmodule.exports = instance;\n\n\n//# sourceURL=webpack://Formio/./node_modules/i18next/dist/cjs/i18next.js?");
2831
2831
 
2832
2832
  /***/ }),
2833
2833
 
@@ -5291,7 +5291,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
5291
5291
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
5292
5292
 
5293
5293
  "use strict";
5294
- eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst Webform_1 = __importDefault(__webpack_require__(/*! ./Webform */ \"./lib/cjs/Webform.js\"));\nconst Component_1 = __importDefault(__webpack_require__(/*! ./components/_classes/component/Component */ \"./lib/cjs/components/_classes/component/Component.js\"));\nconst tippy_js_1 = __importDefault(__webpack_require__(/*! tippy.js */ \"./node_modules/tippy.js/dist/tippy.esm.js\"));\nconst native_promise_only_1 = __importDefault(__webpack_require__(/*! native-promise-only */ \"./node_modules/native-promise-only/lib/npo.src.js\"));\nconst Components_1 = __importDefault(__webpack_require__(/*! ./components/Components */ \"./lib/cjs/components/Components.js\"));\nconst Formio_1 = __webpack_require__(/*! ./Formio */ \"./lib/cjs/Formio.js\");\nconst utils_1 = __webpack_require__(/*! ./utils/utils */ \"./lib/cjs/utils/utils.js\");\nconst formUtils_1 = __webpack_require__(/*! ./utils/formUtils */ \"./lib/cjs/utils/formUtils.js\");\nconst builder_1 = __importDefault(__webpack_require__(/*! ./utils/builder */ \"./lib/cjs/utils/builder.js\"));\nconst lodash_1 = __importDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nconst dom_autoscroller_1 = __importDefault(__webpack_require__(/*! dom-autoscroller */ \"./node_modules/dom-autoscroller/dist/bundle.js\"));\nconst Templates_1 = __importDefault(__webpack_require__(/*! ./templates/Templates */ \"./lib/cjs/templates/Templates.js\"));\n__webpack_require__(/*! ./components/builder */ \"./lib/cjs/components/builder.js\");\nconst dragula_1 = __importDefault(__webpack_require__(/*! dragula */ \"./node_modules/dragula/dragula.js\"));\nclass WebformBuilder extends Component_1.default {\n // eslint-disable-next-line max-statements\n constructor() {\n let element, options;\n if (arguments[0] instanceof HTMLElement || arguments[1]) {\n element = arguments[0];\n options = arguments[1];\n }\n else {\n options = arguments[0];\n }\n // Reset skipInit in case PDFBuilder has set it.\n options.skipInit = false;\n options.display = options.display || 'form';\n super(null, options);\n this.moveHandler = (e) => {\n e.stopPropagation();\n e.preventDefault();\n if (e.keyCode === 38) {\n this.updateComponentPlacement(true);\n }\n if (e.keyCode === 40) {\n this.updateComponentPlacement(false);\n }\n if (e.keyCode === 13) {\n this.stopMoving(this.selectedElement);\n }\n };\n this.setElement(element);\n this.builderHeight = 0;\n this.schemas = {};\n this.repeatablePaths = [];\n this.sideBarScroll = lodash_1.default.get(this.options, 'sideBarScroll', true);\n this.sideBarScrollOffset = lodash_1.default.get(this.options, 'sideBarScrollOffset', 0);\n this.dragDropEnabled = true;\n // Setup the builder options.\n this.builder = lodash_1.default.defaultsDeep({}, this.options.builder, this.defaultGroups);\n // Turn off if explicitely said to do so...\n lodash_1.default.each(this.defaultGroups, (config, key) => {\n if (config === false) {\n this.builder[key] = false;\n }\n });\n // Add the groups.////\n this.groups = {};\n this.groupOrder = [];\n for (const group in this.builder) {\n if (this.builder[group]) {\n this.builder[group].key = group;\n this.groups[group] = this.builder[group];\n this.groups[group].components = this.groups[group].components || {};\n this.groups[group].componentOrder = this.groups[group].componentOrder || [];\n this.groups[group].subgroups = Object.keys(this.groups[group].groups || {}).map((groupKey) => {\n this.groups[group].groups[groupKey].componentOrder = Object.keys(this.groups[group].groups[groupKey].components).map((key) => key);\n return this.groups[group].groups[groupKey];\n });\n this.groupOrder.push(this.groups[group]);\n }\n }\n this.groupOrder = this.groupOrder\n .filter(group => group && !group.ignore)\n .sort((a, b) => a.weight - b.weight)\n .map(group => group.key);\n for (const type in Components_1.default.components) {\n const component = Components_1.default.components[type];\n if (component.builderInfo && component.builderInfo.schema) {\n this.schemas[type] = component.builderInfo.schema;\n component.type = type;\n const builderInfo = component.builderInfo;\n builderInfo.key = component.type;\n this.addBuilderComponentInfo(builderInfo);\n }\n }\n // Filter out any extra components.\n // Add the components in each group.\n for (const group in this.groups) {\n const info = this.groups[group];\n for (const key in info.components) {\n const compKey = group === 'resource' ? `component-${key}` : key;\n let comp = info.components[compKey];\n if (comp === true &&\n Components_1.default.components[key] &&\n Components_1.default.components[key].builderInfo) {\n comp = Components_1.default.components[key].builderInfo;\n }\n if (comp && comp.schema) {\n this.schemas[key] = comp.schema;\n info.components[compKey] = comp;\n info.components[compKey].key = key;\n }\n else {\n // Do not include this component in the components array.\n delete info.components[compKey];\n }\n }\n // Order the components.\n this.orderComponents(info);\n }\n this.options.hooks = this.options.hooks || {};\n this.options.hooks.renderComponent = (html, { component, self }) => {\n var _a;\n if (self.type === 'form' && !self.key) {\n const template = this.hook('renderComponentFormTemplate', html.replace('formio-component-form', ''));\n // The main webform shouldn't have this class as it adds extra styles.\n return template;\n }\n if (this.options.disabled && this.options.disabled.includes(self.key) || self.parent.noDragDrop) {\n return html;\n }\n return this.renderTemplate('builderComponent', {\n html,\n disableBuilderActions: (_a = self === null || self === void 0 ? void 0 : self.component) === null || _a === void 0 ? void 0 : _a.disableBuilderActions,\n childComponent: component,\n });\n };\n this.options.hooks.renderComponents = (html, { components, self }) => {\n // if Datagrid and already has a component, don't make it droppable.\n if (self.type === 'datagrid' && components.length > 0 || self.noDragDrop) {\n return html;\n }\n if (!components ||\n (!components.length && !components.nodrop) ||\n (self.type === 'form' && components.length <= 1 && (components.length === 0 || components[0].type === 'button'))) {\n html = this.renderTemplate('builderPlaceholder', {\n position: 0\n }) + html;\n }\n return this.renderTemplate('builderComponents', {\n key: self.key,\n type: self.type,\n html,\n });\n };\n this.options.hooks.renderInput = (html, { self }) => {\n if (self.type === 'hidden') {\n return html + self.name;\n }\n return html;\n };\n this.options.hooks.renderLoading = (html, { self }) => {\n if (self.type === 'form' && self.key) {\n return self.name;\n }\n return html;\n };\n this.options.hooks.attachComponents = (element, components, container, component) => {\n // Don't attach if no element was found or component doesn't participate in drag'n'drop.\n if (!element) {\n return;\n }\n if (component.noDragDrop) {\n return element;\n }\n // Attach container and component to element for later reference.\n const containerElement = element.querySelector(`[ref=\"${component.component.key}-container\"]`) || element;\n containerElement.formioContainer = container;\n containerElement.formioComponent = component;\n // Add container to draggable list.\n if (this.dragula && this.allowDrop(element)) {\n this.dragula.containers.push(containerElement);\n }\n // If this is an existing datagrid element, don't make it draggable.\n if ((component.type === 'datagrid' || component.type === 'datamap') && components.length > 0) {\n return element;\n }\n // Since we added a wrapper, need to return the original element so that we can find the components inside it.\n return element.children[0];\n };\n this.options.hooks.attachDatagrid = (element, component) => {\n component.loadRefs(element, {\n [`${component.key}-container`]: 'single',\n });\n const dataGridContainer = component.refs[`${component.key}-container`];\n if (dataGridContainer) {\n component.attachComponents(dataGridContainer.parentNode, [], component.component.components);\n }\n // Need to set up horizontal rearrangement of fields.\n };\n this.options.hooks.attachComponent = this.attachComponent.bind(this);\n // Load resources tagged as 'builder'\n const query = {\n params: {\n type: 'resource',\n limit: 1000000,\n select: '_id,title,name,components'\n }\n };\n if (this.options && this.options.resourceTag) {\n query.params.tags = [this.options.resourceTag];\n }\n else if (!this.options || !this.options.hasOwnProperty('resourceTag')) {\n query.params.tags = ['builder'];\n }\n const formio = new Formio_1.Formio(Formio_1.Formio.projectUrl);\n const isResourcesDisabled = this.options.builder && this.options.builder.resource === false;\n formio.loadProject().then((project) => {\n if (project && (lodash_1.default.get(project, 'settings.addConfigToForms', false) || lodash_1.default.get(project, 'addConfigToForms', false))) {\n const config = project.config || {};\n this.options.formConfig = config;\n const pathToFormConfig = 'webform._form.config';\n const webformConfig = lodash_1.default.get(this, pathToFormConfig);\n if (this.webform && !webformConfig) {\n lodash_1.default.set(this, pathToFormConfig, config);\n }\n }\n }).catch((err) => {\n console.warn(`Could not load project settings: ${err.message || err}`);\n });\n if (!formio.noProject && !isResourcesDisabled && formio.formsUrl) {\n const resourceOptions = this.options.builder && this.options.builder.resource;\n formio.loadForms(query)\n .then((resources) => {\n if (resources.length) {\n this.builder.resource = {\n title: resourceOptions ? resourceOptions.title : 'Existing Resource Fields',\n key: 'resource',\n weight: resourceOptions ? resourceOptions.weight : 50,\n subgroups: [],\n components: [],\n componentOrder: []\n };\n this.groups.resource = {\n title: resourceOptions ? resourceOptions.title : 'Existing Resource Fields',\n key: 'resource',\n weight: resourceOptions ? resourceOptions.weight : 50,\n subgroups: [],\n components: [],\n componentOrder: []\n };\n if (!this.groupOrder.includes('resource')) {\n this.groupOrder.push('resource');\n }\n this.addExistingResourceFields(resources);\n }\n });\n }\n // Notify components if they need to modify their render.\n this.options.attachMode = 'builder';\n this.webform = this.webform || this.createForm(this.options);\n this.pathComponentsMapping = {};\n this.arrayDataComponentPaths = [];\n this.nestedDataComponents = [];\n this.arrayDataComponents = [];\n }\n allowDrop() {\n return true;\n }\n addExistingResourceFields(resources) {\n lodash_1.default.each(resources, (resource, index) => {\n const resourceKey = `resource-${resource.name}`;\n const subgroup = {\n key: resourceKey,\n title: resource.title,\n components: [],\n componentOrder: [],\n default: index === 0,\n };\n (0, formUtils_1.eachComponent)(resource.components, (component) => {\n if (component.type === 'button')\n return;\n if (this.options &&\n this.options.resourceFilter &&\n (!component.tags || component.tags.indexOf(this.options.resourceFilter) === -1))\n return;\n let componentName = component.label;\n if (!componentName && component.key) {\n componentName = lodash_1.default.upperFirst(component.key);\n }\n subgroup.componentOrder.push(`component-${component.key}`);\n subgroup.components[`component-${component.key}`] = lodash_1.default.merge((0, utils_1.fastCloneDeep)(Components_1.default.components[component.type]\n ? Components_1.default.components[component.type].builderInfo\n : Components_1.default.components['unknown'].builderInfo), {\n key: component.key,\n title: componentName,\n group: 'resource',\n subgroup: resourceKey,\n }, {\n schema: Object.assign(Object.assign({}, component), { label: component.label, key: component.key, lockKey: true, source: (!this.options.noSource ? resource._id : undefined), isNew: true })\n });\n }, true);\n this.groups.resource.subgroups.push(subgroup);\n });\n this.triggerRedraw();\n }\n attachTooltip(component, title) {\n return (0, tippy_js_1.default)(component, {\n allowHTML: true,\n trigger: 'mouseenter focus',\n placement: 'top',\n delay: [200, 0],\n zIndex: 10000,\n content: title\n });\n }\n attachComponent(element, component) {\n // Add component to element for later reference.\n element.formioComponent = component;\n component.loadRefs(element, {\n removeComponent: 'single',\n editComponent: 'single',\n moveComponent: 'single',\n copyComponent: 'single',\n pasteComponent: 'single',\n editJson: 'single'\n });\n if (component.refs.copyComponent) {\n this.attachTooltip(component.refs.copyComponent, this.t('Copy'));\n component.addEventListener(component.refs.copyComponent, 'click', () => this.copyComponent(component));\n }\n if (component.refs.pasteComponent) {\n const pasteToolTip = this.attachTooltip(component.refs.pasteComponent, this.t('Paste below'));\n component.addEventListener(component.refs.pasteComponent, 'click', () => {\n pasteToolTip.hide();\n this.pasteComponent(component);\n });\n }\n if (component.refs.moveComponent) {\n this.attachTooltip(component.refs.moveComponent, this.t('Move'));\n if (this.keyboardActionsEnabled) {\n component.addEventListener(component.refs.moveComponent, 'click', () => {\n this.moveComponent(component);\n });\n }\n }\n const parent = this.getParentElement(element);\n if (component.refs.editComponent) {\n this.attachTooltip(component.refs.editComponent, this.t('Edit'));\n component.addEventListener(component.refs.editComponent, 'click', () => this.editComponent(component.schema, parent, false, false, component.component, { inDataGrid: component.isInDataGrid }));\n }\n if (component.refs.editJson) {\n this.attachTooltip(component.refs.editJson, this.t('Edit JSON'));\n component.addEventListener(component.refs.editJson, 'click', () => this.editComponent(component.schema, parent, false, true, component.component));\n }\n if (component.refs.removeComponent) {\n this.attachTooltip(component.refs.removeComponent, this.t('Remove'));\n component.addEventListener(component.refs.removeComponent, 'click', () => this.removeComponent(component.schema, parent, component.component));\n }\n return element;\n }\n createForm(options) {\n this.webform = new Webform_1.default(this.element, options);\n if (this.element) {\n this.loadRefs(this.element, {\n form: 'single'\n });\n if (this.refs.form) {\n this.webform.element = this.refs.form;\n }\n }\n return this.webform;\n }\n /**\n * Called when everything is ready.\n *\n * @returns {Promise} - Wait for webform to be ready.\n */\n get ready() {\n return this.webform.ready;\n }\n get defaultGroups() {\n return {\n basic: {\n title: 'Basic',\n weight: 0,\n default: true,\n },\n advanced: {\n title: 'Advanced',\n weight: 10\n },\n layout: {\n title: 'Layout',\n weight: 20\n },\n data: {\n title: 'Data',\n weight: 30\n },\n premium: {\n title: 'Premium',\n weight: 40\n },\n };\n }\n redraw() {\n return Webform_1.default.prototype.redraw.call(this);\n }\n get form() {\n return this.webform.form;\n }\n get schema() {\n return this.webform.schema;\n }\n set form(value) {\n this.setForm(value);\n }\n get container() {\n return this.webform.form.components;\n }\n /**\n * When a component sets its api key, we need to check if it is unique within its namespace. Find the namespace root\n * so we can calculate this correctly.\n * @param component\n */\n findNamespaceRoot(component) {\n const path = (0, utils_1.getArrayFromComponentPath)(component.path);\n // First get the component with nested parents.\n let comp = this.webform.getComponent(path);\n comp = Array.isArray(comp) ? comp[0] : comp;\n const namespaceKey = this.recurseNamespace(comp);\n // If there is no key, it is the root form.\n if (!namespaceKey || this.form.key === namespaceKey) {\n return this.form.components;\n }\n const componentSchema = component.component;\n // If the current component is the namespace, we don't need to find it again.\n if (namespaceKey === component.key) {\n return [...componentSchema.components, componentSchema];\n }\n // Get the namespace component so we have the original object.\n const namespaceComponent = (0, formUtils_1.getComponent)(this.form.components, namespaceKey, true);\n return namespaceComponent ? namespaceComponent.components : comp.components;\n }\n recurseNamespace(component) {\n // If there is no parent, we are at the root level.\n if (!component) {\n return null;\n }\n // Some components are their own namespace.\n if (['address', 'container', 'datagrid', 'editgrid', 'dynamicWizard', 'tree'].includes(component.type) || component.tree || component.arrayTree) {\n return component.key;\n }\n // Anything else, keep going up.\n return this.recurseNamespace(component.parent);\n }\n render() {\n return this.renderTemplate('builder', {\n sidebar: this.renderTemplate('builderSidebar', {\n scrollEnabled: this.sideBarScroll,\n groupOrder: this.groupOrder,\n groupId: `builder-sidebar-${this.id}`,\n groups: this.groupOrder.map((groupKey) => this.renderTemplate('builderSidebarGroup', {\n group: this.groups[groupKey],\n groupKey,\n groupId: `builder-sidebar-${this.id}`,\n subgroups: this.groups[groupKey].subgroups.map((group) => this.renderTemplate('builderSidebarGroup', {\n group,\n groupKey: group.key,\n groupId: `group-container-${groupKey}`,\n subgroups: []\n })),\n keyboardActionsEnabled: this.keyboardActionsEnabled,\n })),\n }),\n form: this.webform.render(),\n });\n }\n attach(element) {\n this.on('change', (form) => {\n this.populateRecaptchaSettings(form);\n });\n return super.attach(element).then(() => {\n this.loadRefs(element, {\n form: 'single',\n sidebar: 'single',\n 'sidebar-search': 'single',\n 'sidebar-groups': 'single',\n 'container': 'multiple',\n 'sidebar-anchor': 'multiple',\n 'sidebar-group': 'multiple',\n 'sidebar-container': 'multiple',\n 'sidebar-component': 'multiple',\n });\n if (this.sideBarScroll && Templates_1.default.current.handleBuilderSidebarScroll) {\n Templates_1.default.current.handleBuilderSidebarScroll.call(this, this);\n }\n // Add the paste status in form\n if (typeof window !== 'undefined' && window.sessionStorage) {\n const data = window.sessionStorage.getItem('formio.clipboard');\n if (data) {\n this.addClass(this.refs.form, 'builder-paste-mode');\n }\n }\n if (!(0, utils_1.bootstrapVersion)(this.options)) {\n const getAttribute = (anchor, attribute) => {\n let elem = anchor.getAttribute(`data-${attribute}`);\n if (!elem) {\n elem = anchor.getAttribute(`data-bs-${attribute}`);\n }\n return elem;\n };\n const hideShow = (group, show) => {\n if (show) {\n group.classList.add(['show']);\n group.style.display = 'inherit';\n }\n else {\n group.classList.remove(['show']);\n group.style.display = 'none';\n }\n };\n // Initialize\n this.refs['sidebar-group'].forEach((group) => {\n hideShow(group, getAttribute(group, 'default') === 'true');\n });\n // Click event\n this.refs['sidebar-anchor'].forEach((anchor, index) => {\n this.addEventListener(anchor, 'click', () => {\n const clickedParentId = getAttribute(anchor, 'parent').slice('#builder-sidebar-'.length);\n const clickedId = getAttribute(anchor, 'target').slice('#group-'.length);\n this.refs['sidebar-group'].forEach((group, groupIndex) => {\n const openByDefault = getAttribute(group, 'default') === 'true';\n const groupId = group.getAttribute('id').slice('group-'.length);\n const groupParent = getAttribute(group, 'parent').slice('#builder-sidebar-'.length);\n hideShow(group, ((openByDefault && groupParent === clickedId) || groupId === clickedParentId || groupIndex === index));\n });\n }, true);\n });\n }\n if (this.keyboardActionsEnabled) {\n this.refs['sidebar-component'].forEach((component) => {\n this.addEventListener(component, 'keydown', (event) => {\n if (event.keyCode === 13) {\n this.addNewComponent(component);\n }\n });\n });\n }\n this.addEventListener(this.refs['sidebar-search'], 'input', lodash_1.default.debounce((e) => {\n const searchString = e.target.value;\n this.searchFields(searchString);\n }, 300));\n if (this.dragDropEnabled) {\n this.initDragula();\n }\n const drake = this.dragula;\n if (this.refs.form) {\n (0, dom_autoscroller_1.default)([window], {\n margin: 20,\n maxSpeed: 6,\n scrollWhenOutside: true,\n autoScroll: function () {\n return this.down && (drake === null || drake === void 0 ? void 0 : drake.dragging);\n }\n });\n return this.webform.attach(this.refs.form);\n }\n });\n }\n searchFields(searchString = '') {\n const searchValue = searchString.toLowerCase();\n const sidebar = this.refs['sidebar'];\n const sidebarGroups = this.refs['sidebar-groups'];\n if (!sidebar || !sidebarGroups) {\n return;\n }\n const filterGroupBy = (group, searchValue = '') => {\n const result = lodash_1.default.toPlainObject(group);\n const { subgroups = [], components } = result;\n const filteredComponents = [];\n for (const key in components) {\n const isMatchedToTitle = components[key].title.toLowerCase().match(searchValue);\n const isMatchedToKey = components[key].key.toLowerCase().match(searchValue);\n if (isMatchedToTitle || isMatchedToKey) {\n filteredComponents.push(components[key]);\n }\n }\n this.orderComponents(result, filteredComponents);\n if (searchValue) {\n result.default = true;\n }\n if (result.componentOrder.length || subgroups.length) {\n return result;\n }\n return null;\n };\n const filterGroupOrder = (groupOrder, searchValue) => {\n const result = lodash_1.default.cloneDeep(groupOrder);\n return result.filter(key => filterGroupBy(this.groups[key], searchValue));\n };\n const filterSubgroups = (groups, searchValue) => {\n const result = lodash_1.default.clone(groups);\n return result\n .map(subgroup => filterGroupBy(subgroup, searchValue))\n .filter(subgroup => !lodash_1.default.isNull(subgroup));\n };\n const toTemplate = groupKey => {\n return {\n group: filterGroupBy(this.groups[groupKey], searchValue),\n groupKey,\n groupId: sidebar.id || sidebarGroups.id,\n subgroups: filterSubgroups(this.groups[groupKey].subgroups, searchValue)\n .map((group) => this.renderTemplate('builderSidebarGroup', {\n group,\n groupKey: group.key,\n groupId: `group-container-${groupKey}`,\n subgroups: []\n })),\n };\n };\n sidebarGroups.innerHTML = filterGroupOrder(this.groupOrder, searchValue)\n .map(groupKey => this.renderTemplate('builderSidebarGroup', toTemplate(groupKey)))\n .join('');\n this.loadRefs(this.element, {\n 'sidebar-groups': 'single',\n 'sidebar-anchor': 'multiple',\n 'sidebar-group': 'multiple',\n 'sidebar-container': 'multiple',\n });\n this.updateDragAndDrop();\n if (searchValue === '') {\n this.triggerRedraw();\n }\n }\n orderComponents(groupInfo, foundComponents) {\n const components = foundComponents || groupInfo.components;\n const isResource = groupInfo.key.indexOf('resource-') === 0;\n if (components) {\n groupInfo.componentOrder = Object.keys(components)\n .map(key => components[key])\n .filter(component => component && !component.ignore && !component.ignoreForForm)\n .sort((a, b) => a.weight - b.weight)\n .map(component => isResource ? `component-${component.key}` : component.key);\n }\n }\n updateDragAndDrop() {\n if (this.dragDropEnabled) {\n this.initDragula();\n }\n if (this.refs.form) {\n return this.webform.attach(this.refs.form);\n }\n }\n initDragula() {\n const options = this.options;\n if (this.dragula) {\n this.dragula.destroy();\n }\n const containersArray = Array.prototype.slice.call(this.refs['sidebar-container']).filter(item => {\n return item.id !== 'group-container-resource';\n });\n if (!dragula_1.default) {\n return;\n }\n this.dragula = (0, dragula_1.default)(containersArray, {\n moves(el) {\n let moves = true;\n const list = Array.from(el.classList).filter(item => item.indexOf('formio-component-') === 0);\n list.forEach(item => {\n const key = item.slice('formio-component-'.length);\n if (options.disabled && options.disabled.includes(key)) {\n moves = false;\n }\n });\n if (el.classList.contains('no-drag')) {\n moves = false;\n }\n return moves;\n },\n copy(el) {\n return el.classList.contains('drag-copy');\n },\n accepts(el, target) {\n return !el.contains(target) && !target.classList.contains('no-drop');\n }\n }).on('drop', (element, target, source, sibling) => this.onDrop(element, target, source, sibling));\n }\n detach() {\n if (this.dragula) {\n this.dragula.destroy();\n }\n this.dragula = null;\n if (this.sideBarScroll && Templates_1.default.current.clearBuilderSidebarScroll) {\n Templates_1.default.current.clearBuilderSidebarScroll.call(this, this);\n }\n super.detach();\n }\n getComponentInfo(key, group) {\n let info;\n // This is a new component\n if (this.schemas.hasOwnProperty(key)) {\n info = (0, utils_1.fastCloneDeep)(this.schemas[key]);\n }\n else if (this.groups.hasOwnProperty(group)) {\n const groupComponents = this.groups[group].components;\n if (groupComponents.hasOwnProperty(key)) {\n info = (0, utils_1.fastCloneDeep)(groupComponents[key].schema);\n }\n }\n else if (group.slice(0, group.indexOf('-')) === 'resource') {\n // This is an existing resource field.\n const resourceGroups = this.groups.resource.subgroups;\n const resourceGroup = lodash_1.default.find(resourceGroups, { key: group });\n if (resourceGroup && resourceGroup.components.hasOwnProperty(`component-${key}`)) {\n info = (0, utils_1.fastCloneDeep)(resourceGroup.components[`component-${key}`].schema);\n }\n }\n else if (group === 'searchFields') { //Search components go into this group\n const resourceGroups = this.groups.resource.subgroups;\n for (let ix = 0; ix < resourceGroups.length; ix++) {\n const resourceGroup = resourceGroups[ix];\n if (resourceGroup.components.hasOwnProperty(`component-${key}`)) {\n info = (0, utils_1.fastCloneDeep)(resourceGroup.components[`component-${key}`].schema);\n break;\n }\n }\n }\n if (info) {\n info.key = this.generateKey(info);\n }\n return info;\n }\n getComponentsPath(component, parent) {\n // Get path to the component in the parent component.\n let path = 'components';\n let columnIndex = 0;\n let tableRowIndex = 0;\n let tableColumnIndex = 0;\n let tabIndex = 0;\n switch (parent.type) {\n case 'table':\n tableRowIndex = lodash_1.default.findIndex(parent.rows, row => row.some(column => column.components.some(comp => comp.key === component.key)));\n tableColumnIndex = lodash_1.default.findIndex(parent.rows[tableRowIndex], (column => column.components.some(comp => comp.key === component.key)));\n path = `rows[${tableRowIndex}][${tableColumnIndex}].components`;\n break;\n case 'columns':\n columnIndex = lodash_1.default.findIndex(parent.columns, column => column.components.some(comp => comp.key === component.key));\n path = `columns[${columnIndex}].components`;\n break;\n case 'tabs':\n tabIndex = lodash_1.default.findIndex(parent.components, tab => tab.components.some(comp => comp.key === component.key));\n path = `components[${tabIndex}].components`;\n break;\n }\n return path;\n }\n /* eslint-disable max-statements */\n onDrop(element, target, source, sibling) {\n var _a;\n if (!target) {\n return;\n }\n // If you try to drop within itself.\n if (element.contains(target)) {\n return;\n }\n const key = element.getAttribute('data-key');\n const type = element.getAttribute('data-type');\n const group = element.getAttribute('data-group');\n let info, isNew, path, index;\n if (key && group) {\n // This is a new component.\n info = this.getComponentInfo(key, group);\n if (!info && type) {\n info = this.getComponentInfo(type, group);\n }\n isNew = true;\n }\n else if (source.formioContainer) {\n index = lodash_1.default.findIndex(source.formioContainer, { key: element.formioComponent.component.key });\n if (index !== -1) {\n // Grab and remove the component from the source container.\n info = source.formioContainer.splice(lodash_1.default.findIndex(source.formioContainer, { key: element.formioComponent.component.key }), 1);\n // Since splice returns an array of one object, we need to destructure it.\n info = info[0];\n }\n }\n // If we haven't found the component, stop.\n if (!info) {\n return;\n }\n // Show an error if siblings are disabled for a component and such a component already exists.\n const compKey = (group === 'resource') ? `component-${key}` : key;\n const draggableComponent = ((_a = this.groups[group]) === null || _a === void 0 ? void 0 : _a.components[compKey]) || {};\n if (draggableComponent.disableSiblings) {\n let isCompAlreadyExists = false;\n (0, formUtils_1.eachComponent)(this.webform.components, (component) => {\n if (component.type === draggableComponent.schema.type) {\n isCompAlreadyExists = true;\n return;\n }\n }, true);\n if (isCompAlreadyExists) {\n this.webform.redraw();\n this.webform.setAlert('danger', `You cannot add more than one ${draggableComponent.key} component to one page.`);\n return;\n }\n }\n if (target !== source) {\n // Ensure the key remains unique in its new container.\n builder_1.default.uniquify(this.findNamespaceRoot(target.formioComponent), info);\n }\n const parent = target.formioComponent;\n // Insert in the new container.\n if (target.formioContainer) {\n if (sibling) {\n if (!sibling.getAttribute('data-noattach')) {\n index = lodash_1.default.findIndex(target.formioContainer, { key: lodash_1.default.get(sibling, 'formioComponent.component.key') });\n index = (index === -1) ? 0 : index;\n }\n else {\n index = sibling.getAttribute('data-position');\n }\n if (index !== -1) {\n target.formioContainer.splice(index, 0, info);\n }\n }\n else {\n target.formioContainer.push(info);\n }\n path = this.getComponentsPath(info, parent.component);\n index = lodash_1.default.findIndex(lodash_1.default.get(parent.schema, path), { key: info.key });\n if (index === -1) {\n index = 0;\n }\n }\n if (parent && parent.addChildComponent) {\n parent.addChildComponent(info, element, target, source, sibling);\n }\n const componentInDataGrid = parent.type === 'datagrid';\n if (isNew && !this.options.noNewEdit && !info.noNewEdit) {\n this.editComponent(info, target, isNew, null, null, { inDataGrid: componentInDataGrid });\n }\n // Only rebuild the parts needing to be rebuilt.\n let rebuild;\n if (target !== source) {\n if (source.formioContainer && source.contains(target)) {\n rebuild = source.formioComponent.rebuild();\n }\n else if (target.contains(source)) {\n rebuild = target.formioComponent.rebuild();\n }\n else {\n if (source.formioContainer) {\n rebuild = source.formioComponent.rebuild();\n }\n rebuild = target.formioComponent.rebuild();\n }\n }\n else {\n // If they are the same, only rebuild one.\n rebuild = target.formioComponent.rebuild();\n }\n if (!rebuild) {\n rebuild = native_promise_only_1.default.resolve();\n }\n return rebuild.then(() => {\n this.emit('addComponent', info, parent, path, index, isNew && !this.options.noNewEdit && !info.noNewEdit);\n if (!isNew || this.options.noNewEdit || info.noNewEdit) {\n this.emit('change', this.form);\n }\n });\n }\n setForm(form) {\n var _a;\n if (!form.components) {\n form.components = [];\n }\n if (form && form.properties) {\n this.options.properties = form.properties;\n }\n this.keyboardActionsEnabled = lodash_1.default.get(this.options, 'keyboardBuilder', false) || ((_a = this.options.properties) === null || _a === void 0 ? void 0 : _a.keyboardBuilder);\n const isShowSubmitButton = !this.options.noDefaultSubmitButton\n && !form.components.length;\n // Ensure there is at least a submit button.\n if (isShowSubmitButton) {\n form.components.push({\n type: 'button',\n label: 'Submit',\n key: 'submit',\n size: 'md',\n block: false,\n action: 'submit',\n disableOnInvalid: true,\n theme: 'primary'\n });\n }\n if (this.webform) {\n const shouldRebuild = !this.webform.form.components ||\n (form.components.length !== this.webform.form.components.length);\n return this.webform.setForm(form, { keepAsReference: true }).then(() => {\n if (this.refs.form) {\n this.builderHeight = this.refs.form.offsetHeight;\n }\n if (!shouldRebuild) {\n return this.form;\n }\n return this.rebuild().then(() => this.form);\n });\n }\n return native_promise_only_1.default.resolve(form);\n }\n populateRecaptchaSettings(form) {\n //populate isEnabled for recaptcha form settings\n let isRecaptchaEnabled = false;\n if (this.form.components) {\n (0, formUtils_1.eachComponent)(form.components, component => {\n if (isRecaptchaEnabled) {\n return;\n }\n if (component.type === 'recaptcha') {\n isRecaptchaEnabled = true;\n return false;\n }\n });\n if (isRecaptchaEnabled) {\n lodash_1.default.set(form, 'settings.recaptcha.isEnabled', true);\n }\n else if (lodash_1.default.get(form, 'settings.recaptcha.isEnabled')) {\n lodash_1.default.set(form, 'settings.recaptcha.isEnabled', false);\n }\n }\n }\n removeComponent(component, parent, original) {\n if (!parent) {\n return;\n }\n let remove = true;\n const removingComponentsGroup = !component.skipRemoveConfirm &&\n ((Array.isArray(component.components) && component.components.length) ||\n (Array.isArray(component.rows) && component.rows.length) ||\n (Array.isArray(component.columns) && component.columns.length));\n if (this.options.alwaysConfirmComponentRemoval || removingComponentsGroup) {\n const message = removingComponentsGroup ? 'Removing this component will also remove all of its children. Are you sure you want to do this?'\n : 'Are you sure you want to remove this component?';\n remove = window.confirm(this.t(message));\n }\n if (!original) {\n original = parent.formioContainer.find((comp) => comp.id === component.id);\n }\n const index = parent.formioContainer ? parent.formioContainer.indexOf(original) : 0;\n if (remove && index !== -1) {\n const path = this.getComponentsPath(component, parent.formioComponent.component);\n if (parent.formioContainer) {\n parent.formioContainer.splice(index, 1);\n }\n else if (parent.formioComponent && parent.formioComponent.removeChildComponent) {\n parent.formioComponent.removeChildComponent(component);\n }\n const rebuild = parent.formioComponent.rebuild() || native_promise_only_1.default.resolve();\n rebuild.then(() => {\n this.emit('removeComponent', component, parent.formioComponent.schema, path, index);\n this.emit('change', this.form);\n });\n }\n return remove;\n }\n replaceDoubleQuotes(data, fieldsToRemoveDoubleQuotes = []) {\n if (data) {\n fieldsToRemoveDoubleQuotes.forEach((key) => {\n if (data[key]) {\n data[key] = data[key].replace(/\"/g, \"'\");\n }\n });\n return data;\n }\n }\n updateComponent(component, changed) {\n // Update the preview.\n if (this.preview) {\n this.preview.form = {\n components: [lodash_1.default.omit(Object.assign({}, component), [\n 'hidden',\n 'conditional',\n 'calculateValue',\n 'logic',\n 'autofocus',\n 'customConditional',\n ])],\n config: this.options.formConfig || {}\n };\n const fieldsToRemoveDoubleQuotes = ['label', 'tooltip'];\n this.preview.form.components.forEach(component => this.replaceDoubleQuotes(component, fieldsToRemoveDoubleQuotes));\n const previewElement = this.componentEdit.querySelector('[ref=\"preview\"]');\n if (previewElement) {\n this.setContent(previewElement, this.preview.render());\n this.preview.attach(previewElement);\n }\n }\n // Change the \"default value\" field to be reflective of this component.\n const defaultValueComponent = (0, formUtils_1.getComponent)(this.editForm.components, 'defaultValue', true);\n if (defaultValueComponent && component.type !== 'hidden') {\n const defaultChanged = changed && ((changed.component && changed.component.key === 'defaultValue')\n || (changed.instance && defaultValueComponent.hasComponent && defaultValueComponent.hasComponent(changed.instance)));\n if (!defaultChanged) {\n lodash_1.default.assign(defaultValueComponent.component, lodash_1.default.omit(Object.assign({}, component), [\n 'key',\n 'label',\n 'placeholder',\n 'tooltip',\n 'hidden',\n 'autofocus',\n 'validate',\n 'disabled',\n 'defaultValue',\n 'customDefaultValue',\n 'calculateValue',\n 'conditional',\n 'customConditional',\n 'id'\n ]));\n const parentComponent = defaultValueComponent.parent;\n let tabIndex = -1;\n let index = -1;\n parentComponent.tabs.some((tab, tIndex) => {\n tab.some((comp, compIndex) => {\n if (comp.id === defaultValueComponent.id) {\n tabIndex = tIndex;\n index = compIndex;\n return true;\n }\n return false;\n });\n });\n if (tabIndex !== -1 && index !== -1 && changed && changed.value) {\n const sibling = parentComponent.tabs[tabIndex][index + 1];\n parentComponent.removeComponent(defaultValueComponent);\n const newComp = parentComponent.addComponent(defaultValueComponent.component, defaultValueComponent.data, sibling);\n lodash_1.default.pull(newComp.validators, 'required');\n parentComponent.tabs[tabIndex].splice(index, 1, newComp);\n newComp.checkValidity = () => true;\n newComp.build(defaultValueComponent.element);\n }\n }\n else {\n let dataPath = changed.instance._data.key;\n const path = (0, utils_1.getArrayFromComponentPath)(changed.instance.path);\n path.shift();\n if (path.length) {\n path.unshift(component.key);\n dataPath = (0, utils_1.getStringFromComponentPath)(path);\n }\n lodash_1.default.set(this.preview._data, dataPath, changed.value);\n lodash_1.default.set(this.webform._data, dataPath, changed.value);\n }\n }\n // Called when we update a component.\n this.emit('updateComponent', component);\n }\n findRepeatablePaths() {\n const repeatablePaths = [];\n const keys = new Map();\n (0, formUtils_1.eachComponent)(this.form.components, (comp, path) => {\n if (!comp.key) {\n return;\n }\n if (keys.has(comp.key)) {\n if (keys.get(comp.key).includes(path)) {\n repeatablePaths.push(path);\n }\n else {\n keys.set(comp.key, [...keys.get(comp.key), path]);\n }\n }\n else {\n keys.set(comp.key, [path]);\n }\n }, true);\n return repeatablePaths;\n }\n highlightInvalidComponents() {\n const repeatablePaths = this.findRepeatablePaths();\n let hasInvalidComponents = false;\n this.webform.everyComponent((comp) => {\n var _a, _b;\n const path = comp.path;\n if (repeatablePaths.includes(path)) {\n comp.setCustomValidity(`API Key is not unique: ${comp.key}`);\n hasInvalidComponents = true;\n }\n else if ((_b = (_a = comp.error) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.startsWith('API Key is not unique')) {\n comp.setCustomValidity('');\n }\n });\n this.emit('builderFormValidityChange', hasInvalidComponents);\n }\n /**\n * Called when a new component is saved.\n *\n * @param parent\n * @param component\n * @return {boolean}\n */\n saveComponent(component, parent, isNew, original) {\n this.editForm.detach();\n const parentContainer = parent ? parent.formioContainer : this.container;\n const parentComponent = parent ? parent.formioComponent : this;\n this.dialog.close();\n const path = parentContainer ? this.getComponentsPath(component, parentComponent.component) : '';\n if (!original) {\n original = parent.formioContainer.find((comp) => comp.id === component.id);\n }\n const index = parentContainer ? parentContainer.indexOf(original) : 0;\n if (index !== -1) {\n let submissionData = this.editForm.submission.data;\n submissionData = submissionData.componentJson || submissionData;\n const fieldsToRemoveDoubleQuotes = ['label', 'tooltip'];\n this.replaceDoubleQuotes(submissionData, fieldsToRemoveDoubleQuotes);\n this.hook('beforeSaveComponentSettings', submissionData);\n let comp = null;\n parentComponent.getComponents().forEach((component) => {\n if (component.component.key === original.key) {\n comp = component;\n }\n });\n const originalComp = comp.component;\n const originalComponentSchema = comp.schema;\n const isParentSaveChildMethod = this.isParentSaveChildMethod(parent.formioComponent);\n if (parentContainer && !isParentSaveChildMethod) {\n parentContainer[index] = submissionData;\n if (comp) {\n comp.component = submissionData;\n }\n }\n else if (isParentSaveChildMethod) {\n parent.formioComponent.saveChildComponent(submissionData);\n }\n const rebuild = parentComponent.rebuild() || native_promise_only_1.default.resolve();\n return rebuild.then(() => {\n const schema = parentContainer ? parentContainer[index] : (comp ? comp.schema : []);\n this.emitSaveComponentEvent(schema, originalComp, parentComponent.schema, path, index, isNew, originalComponentSchema);\n this.emit('change', this.form);\n this.highlightInvalidComponents();\n if (this.isComponentCreated) {\n const component = parent.formioComponent.components[0];\n this.moveComponent(component);\n this.isComponentCreated = false;\n }\n });\n }\n this.highlightInvalidComponents();\n return native_promise_only_1.default.resolve();\n }\n emitSaveComponentEvent(schema, originalComp, parentComponentSchema, path, index, isNew, originalComponentSchema) {\n this.emit('saveComponent', schema, originalComp, parentComponentSchema, path, index, isNew, originalComponentSchema);\n }\n editComponent(component, parent, isNew, isJsonEdit, original, flags = {}) {\n if (!component.key) {\n return;\n }\n let saved = false;\n const componentCopy = (0, utils_1.fastCloneDeep)(component);\n let ComponentClass = Components_1.default.components[componentCopy.type];\n const isCustom = ComponentClass === undefined;\n isJsonEdit = isJsonEdit || isCustom;\n ComponentClass = isCustom ? Components_1.default.components.unknown : ComponentClass;\n // Make sure we only have one dialog open at a time.\n if (this.dialog) {\n this.dialog.close();\n this.highlightInvalidComponents();\n }\n // This is the render step.\n const editFormOptions = lodash_1.default.clone(lodash_1.default.get(this, 'options.editForm', {}));\n if (this.editForm) {\n this.editForm.destroy();\n }\n // Allow editForm overrides per component.\n const overrides = lodash_1.default.get(this.options, `editForm.${componentCopy.type}`, {});\n // Pass along the form being edited.\n editFormOptions.editForm = this.form;\n editFormOptions.editComponent = component;\n editFormOptions.flags = flags;\n this.hook('editComponentParentInstance', editFormOptions, parent);\n this.editForm = new Webform_1.default(Object.assign(Object.assign(Object.assign({}, lodash_1.default.omit(this.options, ['hooks', 'builder', 'events', 'attachMode', 'skipInit'])), { language: this.options.language }), editFormOptions));\n this.hook('editFormProperties', parent);\n this.editForm.form = (isJsonEdit && !isCustom) ? {\n components: [\n {\n type: 'textarea',\n as: 'json',\n editor: 'ace',\n weight: 10,\n input: true,\n key: 'componentJson',\n label: 'Component JSON',\n tooltip: 'Edit the JSON for this component.'\n },\n {\n type: 'checkbox',\n key: 'showFullSchema',\n label: 'Full Schema'\n }\n ]\n } : ComponentClass.editForm(lodash_1.default.cloneDeep(overrides));\n const instanceOptions = {};\n this.hook('instanceOptionsPreview', instanceOptions);\n const instance = new ComponentClass(componentCopy, instanceOptions);\n const schema = this.hook('builderComponentSchema', component, instance);\n this.editForm.submission = isJsonEdit ? {\n data: {\n componentJson: schema,\n showFullSchema: this.options.showFullJsonSchema\n },\n } : {\n data: instance.component,\n };\n if (this.preview) {\n this.preview.destroy();\n }\n if (!ComponentClass.builderInfo.hasOwnProperty('preview') || ComponentClass.builderInfo.preview) {\n this.preview = new Webform_1.default(lodash_1.default.omit(Object.assign(Object.assign({}, this.options), { preview: true }), [\n 'hooks',\n 'builder',\n 'events',\n 'attachMode',\n 'calculateValue'\n ]));\n this.hook('previewFormSettitngs', schema, isJsonEdit);\n }\n this.componentEdit = this.ce('div', { 'class': 'component-edit-container' });\n this.setContent(this.componentEdit, this.renderTemplate('builderEditForm', {\n componentInfo: ComponentClass.builderInfo,\n editForm: this.editForm.render(),\n preview: this.preview ? this.preview.render() : false,\n helplinks: this.helplinks,\n }));\n this.dialog = this.createModal(this.componentEdit, lodash_1.default.get(this.options, 'dialogAttr', {}));\n // This is the attach step.\n this.editForm.attach(this.componentEdit.querySelector('[ref=\"editForm\"]'));\n this.hook('editFormWrapper');\n this.updateComponent(componentCopy);\n this.editForm.on('change', (event) => {\n if (event.changed) {\n if (event.changed.component && event.changed.component.key === 'showFullSchema') {\n const { value } = event.changed;\n this.editForm.submission = {\n data: {\n componentJson: value ? instance.component : component,\n showFullSchema: value\n },\n };\n return;\n }\n // See if this is a manually modified key. Treat custom component keys as manually modified\n if ((event.changed.component && (event.changed.component.key === 'key')) || isJsonEdit) {\n componentCopy.keyModified = true;\n }\n let isComponentLabelChanged = false;\n if (event.changed.instance) {\n isComponentLabelChanged = ['label', 'title'].includes(event.changed.instance.path);\n }\n else if (event.changed.component) {\n isComponentLabelChanged = ['label', 'title'].includes(event.changed.component.key);\n }\n if (isComponentLabelChanged) {\n // Ensure this component has a key.\n if (isNew) {\n if (!event.data.keyModified) {\n this.editForm.everyComponent(component => {\n if (component.key === 'key' && component.parent.component.key === 'tabs') {\n component.setValue(this.updateComponentKey(event.data));\n return false;\n }\n });\n }\n if (this.form) {\n let formComponents = this.findNamespaceRoot(parent.formioComponent);\n // excluding component which key uniqueness is to be checked to prevent the comparing of the same keys\n formComponents = formComponents.filter(comp => editFormOptions.editComponent.id !== comp.id);\n // Set a unique key for this component.\n builder_1.default.uniquify(formComponents, event.data);\n }\n }\n }\n // Update the component.\n this.updateComponent(event.data.componentJson || event.data, event.changed);\n }\n });\n const cancelButtons = this.componentEdit.querySelectorAll('[ref=\"cancelButton\"]');\n cancelButtons.forEach((cancelButton) => {\n this.addEventListener(cancelButton, 'click', (event) => {\n event.preventDefault();\n this.editForm.detach();\n this.emit('cancelComponent', component);\n this.dialog.close();\n this.highlightInvalidComponents();\n });\n });\n const removeButtons = this.componentEdit.querySelectorAll('[ref=\"removeButton\"]');\n removeButtons.forEach((removeButton) => {\n this.addEventListener(removeButton, 'click', (event) => {\n event.preventDefault();\n // Since we are already removing the component, don't trigger another remove.\n saved = true;\n this.editForm.detach();\n this.removeComponent(component, parent, original);\n this.dialog.close();\n this.highlightInvalidComponents();\n });\n });\n const saveButtons = this.componentEdit.querySelectorAll('[ref=\"saveButton\"]');\n saveButtons.forEach((saveButton) => {\n this.addEventListener(saveButton, 'click', (event) => {\n event.preventDefault();\n if (!this.editForm.checkValidity(this.editForm.data, true, this.editForm.data)) {\n this.editForm.setPristine(false);\n this.editForm.showErrors();\n return false;\n }\n saved = true;\n this.saveComponent(component, parent, isNew, original);\n });\n });\n const dialogClose = () => {\n this.editForm.destroy(true);\n if (this.preview) {\n this.preview.destroy(true);\n this.preview = null;\n }\n if (isNew && !saved) {\n this.removeComponent(component, parent, original);\n this.highlightInvalidComponents();\n }\n // Clean up.\n this.removeEventListener(this.dialog, 'close', dialogClose);\n this.dialog = null;\n };\n this.addEventListener(this.dialog, 'close', dialogClose);\n // Called when we edit a component.\n this.emit('editComponent', component);\n }\n updateComponentKey(data) {\n return lodash_1.default.camelCase(data.title ||\n data.label ||\n data.placeholder ||\n data.type).replace(/^[0-9]*/, '');\n }\n moveComponent(component) {\n component.element.focus();\n component.element.classList.add('builder-selected');\n this.selectedElement = component;\n this.removeEventListener(component.element, 'keydown');\n this.addEventListener(component.element, 'keydown', this.moveHandler.bind(this));\n }\n updateComponentPlacement(direction) {\n const component = this.selectedElement;\n let index, info;\n const step = direction ? -1 : 1;\n if (component) {\n const element = component.element;\n const sibling = direction ? element.previousElementSibling : element.nextElementSibling;\n const source = element.parentNode;\n const containerLength = source.formioContainer.length;\n if (containerLength && containerLength <= 1) {\n return;\n }\n if (source.formioContainer) {\n index = lodash_1.default.findIndex(source.formioContainer, { key: element.formioComponent.component.key });\n if (index !== -1) {\n info = source.formioContainer.splice(lodash_1.default.findIndex(source.formioContainer, { key: element.formioComponent.component.key }), 1);\n info = info[0];\n source.removeChild(element);\n }\n }\n const len = source.formioComponent.components.length;\n index = (index === -1) ? 0 : index + step;\n if (index === -1) {\n source.formioContainer.push(info);\n source.appendChild(element);\n }\n else if (index === len) {\n const key = source.formioContainer[0].key;\n index = lodash_1.default.findIndex(source.formioComponent.components, { key: key });\n const firstElement = source.formioComponent.components[index].element;\n source.formioContainer.splice(0, 0, info);\n source.insertBefore(element, firstElement);\n }\n else if (index !== -1) {\n source.formioContainer.splice(index, 0, info);\n direction\n ? source.insertBefore(element, sibling)\n : source.insertBefore(element, sibling.nextElementSibling);\n }\n element.focus();\n }\n }\n stopMoving(comp) {\n const parent = comp.element.parentNode;\n parent.formioComponent.rebuild();\n }\n addNewComponent(element) {\n var _a;\n const source = document.querySelector('.formio-builder-form');\n const key = element.getAttribute('data-key');\n const group = element.getAttribute('data-group');\n const isNew = true;\n let info;\n if (key && group) {\n info = this.getComponentInfo(key, group);\n }\n if (isNew && !this.options.noNewEdit && !info.noNewEdit) {\n builder_1.default.uniquify(this.findNamespaceRoot(source.formioComponent), info);\n this.editComponent(info, source, isNew, null, null);\n }\n const firstComponent = (_a = source.formioComponent.components[0]) === null || _a === void 0 ? void 0 : _a.element;\n if (firstComponent) {\n source.formioContainer.splice(0, 0, info);\n }\n else {\n source.formioContainer.push(info);\n }\n source.formioComponent.rebuild().then(() => {\n this.isComponentCreated = true;\n });\n }\n /**\n * Creates copy of component schema and stores it under sessionStorage.\n * @param {Component} component\n * @return {*}\n */\n copyComponent(component) {\n if (!window.sessionStorage) {\n return console.warn('Session storage is not supported in this browser.');\n }\n this.addClass(this.refs.form, 'builder-paste-mode');\n window.sessionStorage.setItem('formio.clipboard', JSON.stringify(component.schema));\n }\n /**\n * Paste copied component after the current component.\n * @param {Component} component\n * @return {*}\n */\n pasteComponent(component) {\n if (!window.sessionStorage) {\n return console.warn('Session storage is not supported in this browser.');\n }\n this.removeClass(this.refs.form, 'builder-paste-mode');\n if (window.sessionStorage) {\n const data = window.sessionStorage.getItem('formio.clipboard');\n if (data) {\n const schema = JSON.parse(data);\n const parent = this.getParentElement(component.element);\n if (parent) {\n builder_1.default.uniquify(this.findNamespaceRoot(parent.formioComponent), schema);\n let path = '';\n let index = 0;\n const isParentSaveChildMethod = this.isParentSaveChildMethod(parent.formioComponent);\n if (parent.formioContainer && !isParentSaveChildMethod) {\n index = parent.formioContainer.indexOf(component.component);\n path = this.getComponentsPath(schema, parent.formioComponent.component);\n parent.formioContainer.splice(index + 1, 0, schema);\n }\n else if (isParentSaveChildMethod) {\n parent.formioComponent.saveChildComponent(schema, false);\n }\n parent.formioComponent.rebuild();\n this.emitSaveComponentEvent(schema, schema, parent.formioComponent.component, path, (index + 1), true, schema);\n }\n this.emit('change', this.form);\n }\n }\n }\n isParentSaveChildMethod(parentComp) {\n return !!(parentComp && parentComp.saveChildComponent);\n }\n getParentElement(element) {\n let container = element;\n do {\n container = container.parentNode;\n } while (container && !container.formioComponent);\n return container;\n }\n addBuilderComponentInfo(component) {\n if (!component || !component.group || !this.groups[component.group]) {\n return;\n }\n component = lodash_1.default.clone(component);\n const groupInfo = this.groups[component.group];\n if (!groupInfo.components.hasOwnProperty(component.key)) {\n groupInfo.components[component.key] = component;\n }\n return component;\n }\n init() {\n if (this.webform) {\n this.webform.init();\n }\n return super.init();\n }\n clear() {\n if (this.webform.initialized) {\n this.webform.clear();\n }\n }\n destroy(all = false) {\n if (this.webform.initialized) {\n this.webform.destroy(all);\n }\n super.destroy(all);\n }\n addBuilderGroup(name, group) {\n if (!this.groups[name]) {\n this.groups[name] = group;\n this.groupOrder.push(name);\n this.triggerRedraw();\n }\n else {\n this.updateBuilderGroup(name, group);\n }\n }\n updateBuilderGroup(name, group) {\n if (this.groups[name]) {\n this.groups[name] = group;\n this.triggerRedraw();\n }\n }\n generateKey(info) {\n return info.key || lodash_1.default.camelCase(info.title ||\n info.label ||\n info.placeholder ||\n info.type);\n }\n}\nexports[\"default\"] = WebformBuilder;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/WebformBuilder.js?");
5294
+ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst Webform_1 = __importDefault(__webpack_require__(/*! ./Webform */ \"./lib/cjs/Webform.js\"));\nconst Component_1 = __importDefault(__webpack_require__(/*! ./components/_classes/component/Component */ \"./lib/cjs/components/_classes/component/Component.js\"));\nconst tippy_js_1 = __importDefault(__webpack_require__(/*! tippy.js */ \"./node_modules/tippy.js/dist/tippy.esm.js\"));\nconst native_promise_only_1 = __importDefault(__webpack_require__(/*! native-promise-only */ \"./node_modules/native-promise-only/lib/npo.src.js\"));\nconst Components_1 = __importDefault(__webpack_require__(/*! ./components/Components */ \"./lib/cjs/components/Components.js\"));\nconst Formio_1 = __webpack_require__(/*! ./Formio */ \"./lib/cjs/Formio.js\");\nconst utils_1 = __webpack_require__(/*! ./utils/utils */ \"./lib/cjs/utils/utils.js\");\nconst formUtils_1 = __webpack_require__(/*! ./utils/formUtils */ \"./lib/cjs/utils/formUtils.js\");\nconst builder_1 = __importDefault(__webpack_require__(/*! ./utils/builder */ \"./lib/cjs/utils/builder.js\"));\nconst lodash_1 = __importDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nconst dom_autoscroller_1 = __importDefault(__webpack_require__(/*! dom-autoscroller */ \"./node_modules/dom-autoscroller/dist/bundle.js\"));\nconst Templates_1 = __importDefault(__webpack_require__(/*! ./templates/Templates */ \"./lib/cjs/templates/Templates.js\"));\n__webpack_require__(/*! ./components/builder */ \"./lib/cjs/components/builder.js\");\n// We need this here because dragula pulls in CustomEvent class that requires global to exist.\nif (typeof window !== 'undefined' && typeof window.global === 'undefined') {\n window.global = window;\n}\nconst dragula_1 = __importDefault(__webpack_require__(/*! dragula */ \"./node_modules/dragula/dragula.js\"));\nclass WebformBuilder extends Component_1.default {\n // eslint-disable-next-line max-statements\n constructor() {\n let element, options;\n if (arguments[0] instanceof HTMLElement || arguments[1]) {\n element = arguments[0];\n options = arguments[1];\n }\n else {\n options = arguments[0];\n }\n // Reset skipInit in case PDFBuilder has set it.\n options.skipInit = false;\n options.display = options.display || 'form';\n super(null, options);\n this.moveHandler = (e) => {\n e.stopPropagation();\n e.preventDefault();\n if (e.keyCode === 38) {\n this.updateComponentPlacement(true);\n }\n if (e.keyCode === 40) {\n this.updateComponentPlacement(false);\n }\n if (e.keyCode === 13) {\n this.stopMoving(this.selectedElement);\n }\n };\n this.setElement(element);\n this.dragulaLib = dragula_1.default;\n this.builderHeight = 0;\n this.schemas = {};\n this.repeatablePaths = [];\n this.sideBarScroll = lodash_1.default.get(this.options, 'sideBarScroll', true);\n this.sideBarScrollOffset = lodash_1.default.get(this.options, 'sideBarScrollOffset', 0);\n this.dragDropEnabled = true;\n // Setup the builder options.\n this.builder = lodash_1.default.defaultsDeep({}, this.options.builder, this.defaultGroups);\n // Turn off if explicitely said to do so...\n lodash_1.default.each(this.defaultGroups, (config, key) => {\n if (config === false) {\n this.builder[key] = false;\n }\n });\n // Add the groups.////\n this.groups = {};\n this.groupOrder = [];\n for (const group in this.builder) {\n if (this.builder[group]) {\n this.builder[group].key = group;\n this.groups[group] = this.builder[group];\n this.groups[group].components = this.groups[group].components || {};\n this.groups[group].componentOrder = this.groups[group].componentOrder || [];\n this.groups[group].subgroups = Object.keys(this.groups[group].groups || {}).map((groupKey) => {\n this.groups[group].groups[groupKey].componentOrder = Object.keys(this.groups[group].groups[groupKey].components).map((key) => key);\n return this.groups[group].groups[groupKey];\n });\n this.groupOrder.push(this.groups[group]);\n }\n }\n this.groupOrder = this.groupOrder\n .filter(group => group && !group.ignore)\n .sort((a, b) => a.weight - b.weight)\n .map(group => group.key);\n for (const type in Components_1.default.components) {\n const component = Components_1.default.components[type];\n if (component.builderInfo && component.builderInfo.schema) {\n this.schemas[type] = component.builderInfo.schema;\n component.type = type;\n const builderInfo = component.builderInfo;\n builderInfo.key = component.type;\n this.addBuilderComponentInfo(builderInfo);\n }\n }\n // Filter out any extra components.\n // Add the components in each group.\n for (const group in this.groups) {\n const info = this.groups[group];\n for (const key in info.components) {\n const compKey = group === 'resource' ? `component-${key}` : key;\n let comp = info.components[compKey];\n if (comp === true &&\n Components_1.default.components[key] &&\n Components_1.default.components[key].builderInfo) {\n comp = Components_1.default.components[key].builderInfo;\n }\n if (comp && comp.schema) {\n this.schemas[key] = comp.schema;\n info.components[compKey] = comp;\n info.components[compKey].key = key;\n }\n else {\n // Do not include this component in the components array.\n delete info.components[compKey];\n }\n }\n // Order the components.\n this.orderComponents(info);\n }\n this.options.hooks = this.options.hooks || {};\n this.options.hooks.renderComponent = (html, { component, self }) => {\n var _a;\n if (self.type === 'form' && !self.key) {\n const template = this.hook('renderComponentFormTemplate', html.replace('formio-component-form', ''));\n // The main webform shouldn't have this class as it adds extra styles.\n return template;\n }\n if (this.options.disabled && this.options.disabled.includes(self.key) || self.parent.noDragDrop) {\n return html;\n }\n return this.renderTemplate('builderComponent', {\n html,\n disableBuilderActions: (_a = self === null || self === void 0 ? void 0 : self.component) === null || _a === void 0 ? void 0 : _a.disableBuilderActions,\n childComponent: component,\n });\n };\n this.options.hooks.renderComponents = (html, { components, self }) => {\n // if Datagrid and already has a component, don't make it droppable.\n if (self.type === 'datagrid' && components.length > 0 || self.noDragDrop) {\n return html;\n }\n if (!components ||\n (!components.length && !components.nodrop) ||\n (self.type === 'form' && components.length <= 1 && (components.length === 0 || components[0].type === 'button'))) {\n html = this.renderTemplate('builderPlaceholder', {\n position: 0\n }) + html;\n }\n return this.renderTemplate('builderComponents', {\n key: self.key,\n type: self.type,\n html,\n });\n };\n this.options.hooks.renderInput = (html, { self }) => {\n if (self.type === 'hidden') {\n return html + self.name;\n }\n return html;\n };\n this.options.hooks.renderLoading = (html, { self }) => {\n if (self.type === 'form' && self.key) {\n return self.name;\n }\n return html;\n };\n this.options.hooks.attachComponents = (element, components, container, component) => {\n // Don't attach if no element was found or component doesn't participate in drag'n'drop.\n if (!element) {\n return;\n }\n if (component.noDragDrop) {\n return element;\n }\n // Attach container and component to element for later reference.\n const containerElement = element.querySelector(`[ref=\"${component.component.key}-container\"]`) || element;\n containerElement.formioContainer = container;\n containerElement.formioComponent = component;\n // Add container to draggable list.\n if (this.dragula && this.allowDrop(element)) {\n this.dragula.containers.push(containerElement);\n }\n // If this is an existing datagrid element, don't make it draggable.\n if ((component.type === 'datagrid' || component.type === 'datamap') && components.length > 0) {\n return element;\n }\n // Since we added a wrapper, need to return the original element so that we can find the components inside it.\n return element.children[0];\n };\n this.options.hooks.attachDatagrid = (element, component) => {\n component.loadRefs(element, {\n [`${component.key}-container`]: 'single',\n });\n const dataGridContainer = component.refs[`${component.key}-container`];\n if (dataGridContainer) {\n component.attachComponents(dataGridContainer.parentNode, [], component.component.components);\n }\n // Need to set up horizontal rearrangement of fields.\n };\n this.options.hooks.attachComponent = this.attachComponent.bind(this);\n // Load resources tagged as 'builder'\n const query = {\n params: {\n type: 'resource',\n limit: 1000000,\n select: '_id,title,name,components'\n }\n };\n if (this.options && this.options.resourceTag) {\n query.params.tags = [this.options.resourceTag];\n }\n else if (!this.options || !this.options.hasOwnProperty('resourceTag')) {\n query.params.tags = ['builder'];\n }\n const formio = new Formio_1.Formio(Formio_1.Formio.projectUrl);\n const isResourcesDisabled = this.options.builder && this.options.builder.resource === false;\n formio.loadProject().then((project) => {\n if (project && (lodash_1.default.get(project, 'settings.addConfigToForms', false) || lodash_1.default.get(project, 'addConfigToForms', false))) {\n const config = project.config || {};\n this.options.formConfig = config;\n const pathToFormConfig = 'webform._form.config';\n const webformConfig = lodash_1.default.get(this, pathToFormConfig);\n if (this.webform && !webformConfig) {\n lodash_1.default.set(this, pathToFormConfig, config);\n }\n }\n }).catch((err) => {\n console.warn(`Could not load project settings: ${err.message || err}`);\n });\n if (!formio.noProject && !isResourcesDisabled && formio.formsUrl) {\n const resourceOptions = this.options.builder && this.options.builder.resource;\n formio.loadForms(query)\n .then((resources) => {\n if (resources.length) {\n this.builder.resource = {\n title: resourceOptions ? resourceOptions.title : 'Existing Resource Fields',\n key: 'resource',\n weight: resourceOptions ? resourceOptions.weight : 50,\n subgroups: [],\n components: [],\n componentOrder: []\n };\n this.groups.resource = {\n title: resourceOptions ? resourceOptions.title : 'Existing Resource Fields',\n key: 'resource',\n weight: resourceOptions ? resourceOptions.weight : 50,\n subgroups: [],\n components: [],\n componentOrder: []\n };\n if (!this.groupOrder.includes('resource')) {\n this.groupOrder.push('resource');\n }\n this.addExistingResourceFields(resources);\n }\n });\n }\n // Notify components if they need to modify their render.\n this.options.attachMode = 'builder';\n this.webform = this.webform || this.createForm(this.options);\n this.pathComponentsMapping = {};\n this.arrayDataComponentPaths = [];\n this.nestedDataComponents = [];\n this.arrayDataComponents = [];\n }\n allowDrop() {\n return true;\n }\n addExistingResourceFields(resources) {\n lodash_1.default.each(resources, (resource, index) => {\n const resourceKey = `resource-${resource.name}`;\n const subgroup = {\n key: resourceKey,\n title: resource.title,\n components: [],\n componentOrder: [],\n default: index === 0,\n };\n (0, formUtils_1.eachComponent)(resource.components, (component) => {\n if (component.type === 'button')\n return;\n if (this.options &&\n this.options.resourceFilter &&\n (!component.tags || component.tags.indexOf(this.options.resourceFilter) === -1))\n return;\n let componentName = component.label;\n if (!componentName && component.key) {\n componentName = lodash_1.default.upperFirst(component.key);\n }\n subgroup.componentOrder.push(`component-${component.key}`);\n subgroup.components[`component-${component.key}`] = lodash_1.default.merge((0, utils_1.fastCloneDeep)(Components_1.default.components[component.type]\n ? Components_1.default.components[component.type].builderInfo\n : Components_1.default.components['unknown'].builderInfo), {\n key: component.key,\n title: componentName,\n group: 'resource',\n subgroup: resourceKey,\n }, {\n schema: Object.assign(Object.assign({}, component), { label: component.label, key: component.key, lockKey: true, source: (!this.options.noSource ? resource._id : undefined), isNew: true })\n });\n }, true);\n this.groups.resource.subgroups.push(subgroup);\n });\n this.triggerRedraw();\n }\n attachTooltip(component, title) {\n return (0, tippy_js_1.default)(component, {\n allowHTML: true,\n trigger: 'mouseenter focus',\n placement: 'top',\n delay: [200, 0],\n zIndex: 10000,\n content: title\n });\n }\n attachComponent(element, component) {\n // Add component to element for later reference.\n element.formioComponent = component;\n component.loadRefs(element, {\n removeComponent: 'single',\n editComponent: 'single',\n moveComponent: 'single',\n copyComponent: 'single',\n pasteComponent: 'single',\n editJson: 'single'\n });\n if (component.refs.copyComponent) {\n this.attachTooltip(component.refs.copyComponent, this.t('Copy'));\n component.addEventListener(component.refs.copyComponent, 'click', () => this.copyComponent(component));\n }\n if (component.refs.pasteComponent) {\n const pasteToolTip = this.attachTooltip(component.refs.pasteComponent, this.t('Paste below'));\n component.addEventListener(component.refs.pasteComponent, 'click', () => {\n pasteToolTip.hide();\n this.pasteComponent(component);\n });\n }\n if (component.refs.moveComponent) {\n this.attachTooltip(component.refs.moveComponent, this.t('Move'));\n if (this.keyboardActionsEnabled) {\n component.addEventListener(component.refs.moveComponent, 'click', () => {\n this.moveComponent(component);\n });\n }\n }\n const parent = this.getParentElement(element);\n if (component.refs.editComponent) {\n this.attachTooltip(component.refs.editComponent, this.t('Edit'));\n component.addEventListener(component.refs.editComponent, 'click', () => this.editComponent(component.schema, parent, false, false, component.component, { inDataGrid: component.isInDataGrid }));\n }\n if (component.refs.editJson) {\n this.attachTooltip(component.refs.editJson, this.t('Edit JSON'));\n component.addEventListener(component.refs.editJson, 'click', () => this.editComponent(component.schema, parent, false, true, component.component));\n }\n if (component.refs.removeComponent) {\n this.attachTooltip(component.refs.removeComponent, this.t('Remove'));\n component.addEventListener(component.refs.removeComponent, 'click', () => this.removeComponent(component.schema, parent, component.component));\n }\n return element;\n }\n createForm(options) {\n this.webform = new Webform_1.default(this.element, options);\n if (this.element) {\n this.loadRefs(this.element, {\n form: 'single'\n });\n if (this.refs.form) {\n this.webform.element = this.refs.form;\n }\n }\n return this.webform;\n }\n /**\n * Called when everything is ready.\n *\n * @returns {Promise} - Wait for webform to be ready.\n */\n get ready() {\n return this.webform.ready;\n }\n get defaultGroups() {\n return {\n basic: {\n title: 'Basic',\n weight: 0,\n default: true,\n },\n advanced: {\n title: 'Advanced',\n weight: 10\n },\n layout: {\n title: 'Layout',\n weight: 20\n },\n data: {\n title: 'Data',\n weight: 30\n },\n premium: {\n title: 'Premium',\n weight: 40\n },\n };\n }\n redraw() {\n return Webform_1.default.prototype.redraw.call(this);\n }\n get form() {\n return this.webform.form;\n }\n get schema() {\n return this.webform.schema;\n }\n set form(value) {\n this.setForm(value);\n }\n get container() {\n return this.webform.form.components;\n }\n /**\n * When a component sets its api key, we need to check if it is unique within its namespace. Find the namespace root\n * so we can calculate this correctly.\n * @param component\n */\n findNamespaceRoot(component) {\n const path = (0, utils_1.getArrayFromComponentPath)(component.path);\n // First get the component with nested parents.\n let comp = this.webform.getComponent(path);\n comp = Array.isArray(comp) ? comp[0] : comp;\n const namespaceKey = this.recurseNamespace(comp);\n // If there is no key, it is the root form.\n if (!namespaceKey || this.form.key === namespaceKey) {\n return this.form.components;\n }\n const componentSchema = component.component;\n // If the current component is the namespace, we don't need to find it again.\n if (namespaceKey === component.key) {\n return [...componentSchema.components, componentSchema];\n }\n // Get the namespace component so we have the original object.\n const namespaceComponent = (0, formUtils_1.getComponent)(this.form.components, namespaceKey, true);\n return namespaceComponent ? namespaceComponent.components : comp.components;\n }\n recurseNamespace(component) {\n // If there is no parent, we are at the root level.\n if (!component) {\n return null;\n }\n // Some components are their own namespace.\n if (['address', 'container', 'datagrid', 'editgrid', 'dynamicWizard', 'tree'].includes(component.type) || component.tree || component.arrayTree) {\n return component.key;\n }\n // Anything else, keep going up.\n return this.recurseNamespace(component.parent);\n }\n render() {\n return this.renderTemplate('builder', {\n sidebar: this.renderTemplate('builderSidebar', {\n scrollEnabled: this.sideBarScroll,\n groupOrder: this.groupOrder,\n groupId: `builder-sidebar-${this.id}`,\n groups: this.groupOrder.map((groupKey) => this.renderTemplate('builderSidebarGroup', {\n group: this.groups[groupKey],\n groupKey,\n groupId: `builder-sidebar-${this.id}`,\n subgroups: this.groups[groupKey].subgroups.map((group) => this.renderTemplate('builderSidebarGroup', {\n group,\n groupKey: group.key,\n groupId: `group-container-${groupKey}`,\n subgroups: []\n })),\n keyboardActionsEnabled: this.keyboardActionsEnabled,\n })),\n }),\n form: this.webform.render(),\n });\n }\n attach(element) {\n this.on('change', (form) => {\n this.populateRecaptchaSettings(form);\n });\n return super.attach(element).then(() => {\n this.loadRefs(element, {\n form: 'single',\n sidebar: 'single',\n 'sidebar-search': 'single',\n 'sidebar-groups': 'single',\n 'container': 'multiple',\n 'sidebar-anchor': 'multiple',\n 'sidebar-group': 'multiple',\n 'sidebar-container': 'multiple',\n 'sidebar-component': 'multiple',\n });\n if (this.sideBarScroll && Templates_1.default.current.handleBuilderSidebarScroll) {\n Templates_1.default.current.handleBuilderSidebarScroll.call(this, this);\n }\n // Add the paste status in form\n if (typeof window !== 'undefined' && window.sessionStorage) {\n const data = window.sessionStorage.getItem('formio.clipboard');\n if (data) {\n this.addClass(this.refs.form, 'builder-paste-mode');\n }\n }\n if (!(0, utils_1.bootstrapVersion)(this.options)) {\n const getAttribute = (anchor, attribute) => {\n let elem = anchor.getAttribute(`data-${attribute}`);\n if (!elem) {\n elem = anchor.getAttribute(`data-bs-${attribute}`);\n }\n return elem;\n };\n const hideShow = (group, show) => {\n if (show) {\n group.classList.add(['show']);\n group.style.display = 'inherit';\n }\n else {\n group.classList.remove(['show']);\n group.style.display = 'none';\n }\n };\n // Initialize\n this.refs['sidebar-group'].forEach((group) => {\n hideShow(group, getAttribute(group, 'default') === 'true');\n });\n // Click event\n this.refs['sidebar-anchor'].forEach((anchor, index) => {\n this.addEventListener(anchor, 'click', () => {\n const clickedParentId = getAttribute(anchor, 'parent').slice('#builder-sidebar-'.length);\n const clickedId = getAttribute(anchor, 'target').slice('#group-'.length);\n this.refs['sidebar-group'].forEach((group, groupIndex) => {\n const openByDefault = getAttribute(group, 'default') === 'true';\n const groupId = group.getAttribute('id').slice('group-'.length);\n const groupParent = getAttribute(group, 'parent').slice('#builder-sidebar-'.length);\n hideShow(group, ((openByDefault && groupParent === clickedId) || groupId === clickedParentId || groupIndex === index));\n });\n }, true);\n });\n }\n if (this.keyboardActionsEnabled) {\n this.refs['sidebar-component'].forEach((component) => {\n this.addEventListener(component, 'keydown', (event) => {\n if (event.keyCode === 13) {\n this.addNewComponent(component);\n }\n });\n });\n }\n this.addEventListener(this.refs['sidebar-search'], 'input', lodash_1.default.debounce((e) => {\n const searchString = e.target.value;\n this.searchFields(searchString);\n }, 300));\n if (this.dragDropEnabled) {\n this.initDragula();\n }\n const drake = this.dragula;\n if (this.refs.form) {\n (0, dom_autoscroller_1.default)([window], {\n margin: 20,\n maxSpeed: 6,\n scrollWhenOutside: true,\n autoScroll: function () {\n return this.down && (drake === null || drake === void 0 ? void 0 : drake.dragging);\n }\n });\n return this.webform.attach(this.refs.form);\n }\n });\n }\n searchFields(searchString = '') {\n const searchValue = searchString.toLowerCase();\n const sidebar = this.refs['sidebar'];\n const sidebarGroups = this.refs['sidebar-groups'];\n if (!sidebar || !sidebarGroups) {\n return;\n }\n const filterGroupBy = (group, searchValue = '') => {\n const result = lodash_1.default.toPlainObject(group);\n const { subgroups = [], components } = result;\n const filteredComponents = [];\n for (const key in components) {\n const isMatchedToTitle = components[key].title.toLowerCase().match(searchValue);\n const isMatchedToKey = components[key].key.toLowerCase().match(searchValue);\n if (isMatchedToTitle || isMatchedToKey) {\n filteredComponents.push(components[key]);\n }\n }\n this.orderComponents(result, filteredComponents);\n if (searchValue) {\n result.default = true;\n }\n if (result.componentOrder.length || subgroups.length) {\n return result;\n }\n return null;\n };\n const filterGroupOrder = (groupOrder, searchValue) => {\n const result = lodash_1.default.cloneDeep(groupOrder);\n return result.filter(key => filterGroupBy(this.groups[key], searchValue));\n };\n const filterSubgroups = (groups, searchValue) => {\n const result = lodash_1.default.clone(groups);\n return result\n .map(subgroup => filterGroupBy(subgroup, searchValue))\n .filter(subgroup => !lodash_1.default.isNull(subgroup));\n };\n const toTemplate = groupKey => {\n return {\n group: filterGroupBy(this.groups[groupKey], searchValue),\n groupKey,\n groupId: sidebar.id || sidebarGroups.id,\n subgroups: filterSubgroups(this.groups[groupKey].subgroups, searchValue)\n .map((group) => this.renderTemplate('builderSidebarGroup', {\n group,\n groupKey: group.key,\n groupId: `group-container-${groupKey}`,\n subgroups: []\n })),\n };\n };\n sidebarGroups.innerHTML = filterGroupOrder(this.groupOrder, searchValue)\n .map(groupKey => this.renderTemplate('builderSidebarGroup', toTemplate(groupKey)))\n .join('');\n this.loadRefs(this.element, {\n 'sidebar-groups': 'single',\n 'sidebar-anchor': 'multiple',\n 'sidebar-group': 'multiple',\n 'sidebar-container': 'multiple',\n });\n this.updateDragAndDrop();\n if (searchValue === '') {\n this.triggerRedraw();\n }\n }\n orderComponents(groupInfo, foundComponents) {\n const components = foundComponents || groupInfo.components;\n const isResource = groupInfo.key.indexOf('resource-') === 0;\n if (components) {\n groupInfo.componentOrder = Object.keys(components)\n .map(key => components[key])\n .filter(component => component && !component.ignore && !component.ignoreForForm)\n .sort((a, b) => a.weight - b.weight)\n .map(component => isResource ? `component-${component.key}` : component.key);\n }\n }\n updateDragAndDrop() {\n if (this.dragDropEnabled) {\n this.initDragula();\n }\n if (this.refs.form) {\n return this.webform.attach(this.refs.form);\n }\n }\n initDragula() {\n const options = this.options;\n if (this.dragula) {\n this.dragula.destroy();\n }\n const containersArray = Array.prototype.slice.call(this.refs['sidebar-container']).filter(item => {\n return item.id !== 'group-container-resource';\n });\n if (!dragula_1.default) {\n return;\n }\n this.dragula = (0, dragula_1.default)(containersArray, {\n moves(el) {\n let moves = true;\n const list = Array.from(el.classList).filter(item => item.indexOf('formio-component-') === 0);\n list.forEach(item => {\n const key = item.slice('formio-component-'.length);\n if (options.disabled && options.disabled.includes(key)) {\n moves = false;\n }\n });\n if (el.classList.contains('no-drag')) {\n moves = false;\n }\n return moves;\n },\n copy(el) {\n return el.classList.contains('drag-copy');\n },\n accepts(el, target) {\n return !el.contains(target) && !target.classList.contains('no-drop');\n }\n }).on('drop', (element, target, source, sibling) => this.onDrop(element, target, source, sibling));\n }\n detach() {\n if (this.dragula) {\n this.dragula.destroy();\n }\n this.dragula = null;\n if (this.sideBarScroll && Templates_1.default.current.clearBuilderSidebarScroll) {\n Templates_1.default.current.clearBuilderSidebarScroll.call(this, this);\n }\n super.detach();\n }\n getComponentInfo(key, group) {\n let info;\n // This is a new component\n if (this.schemas.hasOwnProperty(key)) {\n info = (0, utils_1.fastCloneDeep)(this.schemas[key]);\n }\n else if (this.groups.hasOwnProperty(group)) {\n const groupComponents = this.groups[group].components;\n if (groupComponents.hasOwnProperty(key)) {\n info = (0, utils_1.fastCloneDeep)(groupComponents[key].schema);\n }\n }\n else if (group.slice(0, group.indexOf('-')) === 'resource') {\n // This is an existing resource field.\n const resourceGroups = this.groups.resource.subgroups;\n const resourceGroup = lodash_1.default.find(resourceGroups, { key: group });\n if (resourceGroup && resourceGroup.components.hasOwnProperty(`component-${key}`)) {\n info = (0, utils_1.fastCloneDeep)(resourceGroup.components[`component-${key}`].schema);\n }\n }\n else if (group === 'searchFields') { //Search components go into this group\n const resourceGroups = this.groups.resource.subgroups;\n for (let ix = 0; ix < resourceGroups.length; ix++) {\n const resourceGroup = resourceGroups[ix];\n if (resourceGroup.components.hasOwnProperty(`component-${key}`)) {\n info = (0, utils_1.fastCloneDeep)(resourceGroup.components[`component-${key}`].schema);\n break;\n }\n }\n }\n if (info) {\n info.key = this.generateKey(info);\n }\n return info;\n }\n getComponentsPath(component, parent) {\n // Get path to the component in the parent component.\n let path = 'components';\n let columnIndex = 0;\n let tableRowIndex = 0;\n let tableColumnIndex = 0;\n let tabIndex = 0;\n switch (parent.type) {\n case 'table':\n tableRowIndex = lodash_1.default.findIndex(parent.rows, row => row.some(column => column.components.some(comp => comp.key === component.key)));\n tableColumnIndex = lodash_1.default.findIndex(parent.rows[tableRowIndex], (column => column.components.some(comp => comp.key === component.key)));\n path = `rows[${tableRowIndex}][${tableColumnIndex}].components`;\n break;\n case 'columns':\n columnIndex = lodash_1.default.findIndex(parent.columns, column => column.components.some(comp => comp.key === component.key));\n path = `columns[${columnIndex}].components`;\n break;\n case 'tabs':\n tabIndex = lodash_1.default.findIndex(parent.components, tab => tab.components.some(comp => comp.key === component.key));\n path = `components[${tabIndex}].components`;\n break;\n }\n return path;\n }\n /* eslint-disable max-statements */\n onDrop(element, target, source, sibling) {\n var _a;\n if (!target) {\n return;\n }\n // If you try to drop within itself.\n if (element.contains(target)) {\n return;\n }\n const key = element.getAttribute('data-key');\n const type = element.getAttribute('data-type');\n const group = element.getAttribute('data-group');\n let info, isNew, path, index;\n if (key && group) {\n // This is a new component.\n info = this.getComponentInfo(key, group);\n if (!info && type) {\n info = this.getComponentInfo(type, group);\n }\n isNew = true;\n }\n else if (source.formioContainer) {\n index = lodash_1.default.findIndex(source.formioContainer, { key: element.formioComponent.component.key });\n if (index !== -1) {\n // Grab and remove the component from the source container.\n info = source.formioContainer.splice(lodash_1.default.findIndex(source.formioContainer, { key: element.formioComponent.component.key }), 1);\n // Since splice returns an array of one object, we need to destructure it.\n info = info[0];\n }\n }\n // If we haven't found the component, stop.\n if (!info) {\n return;\n }\n // Show an error if siblings are disabled for a component and such a component already exists.\n const compKey = (group === 'resource') ? `component-${key}` : key;\n const draggableComponent = ((_a = this.groups[group]) === null || _a === void 0 ? void 0 : _a.components[compKey]) || {};\n if (draggableComponent.disableSiblings) {\n let isCompAlreadyExists = false;\n (0, formUtils_1.eachComponent)(this.webform.components, (component) => {\n if (component.type === draggableComponent.schema.type) {\n isCompAlreadyExists = true;\n return;\n }\n }, true);\n if (isCompAlreadyExists) {\n this.webform.redraw();\n this.webform.setAlert('danger', `You cannot add more than one ${draggableComponent.key} component to one page.`);\n return;\n }\n }\n if (target !== source) {\n // Ensure the key remains unique in its new container.\n builder_1.default.uniquify(this.findNamespaceRoot(target.formioComponent), info);\n }\n const parent = target.formioComponent;\n // Insert in the new container.\n if (target.formioContainer) {\n if (sibling) {\n if (!sibling.getAttribute('data-noattach')) {\n index = lodash_1.default.findIndex(target.formioContainer, { key: lodash_1.default.get(sibling, 'formioComponent.component.key') });\n index = (index === -1) ? 0 : index;\n }\n else {\n index = sibling.getAttribute('data-position');\n }\n if (index !== -1) {\n target.formioContainer.splice(index, 0, info);\n }\n }\n else {\n target.formioContainer.push(info);\n }\n path = this.getComponentsPath(info, parent.component);\n index = lodash_1.default.findIndex(lodash_1.default.get(parent.schema, path), { key: info.key });\n if (index === -1) {\n index = 0;\n }\n }\n if (parent && parent.addChildComponent) {\n parent.addChildComponent(info, element, target, source, sibling);\n }\n const componentInDataGrid = parent.type === 'datagrid';\n if (isNew && !this.options.noNewEdit && !info.noNewEdit) {\n this.editComponent(info, target, isNew, null, null, { inDataGrid: componentInDataGrid });\n }\n // Only rebuild the parts needing to be rebuilt.\n let rebuild;\n if (target !== source) {\n if (source.formioContainer && source.contains(target)) {\n rebuild = source.formioComponent.rebuild();\n }\n else if (target.contains(source)) {\n rebuild = target.formioComponent.rebuild();\n }\n else {\n if (source.formioContainer) {\n rebuild = source.formioComponent.rebuild();\n }\n rebuild = target.formioComponent.rebuild();\n }\n }\n else {\n // If they are the same, only rebuild one.\n rebuild = target.formioComponent.rebuild();\n }\n if (!rebuild) {\n rebuild = native_promise_only_1.default.resolve();\n }\n return rebuild.then(() => {\n this.emit('addComponent', info, parent, path, index, isNew && !this.options.noNewEdit && !info.noNewEdit);\n if (!isNew || this.options.noNewEdit || info.noNewEdit) {\n this.emit('change', this.form);\n }\n });\n }\n setForm(form) {\n var _a;\n if (!form.components) {\n form.components = [];\n }\n if (form && form.properties) {\n this.options.properties = form.properties;\n }\n this.keyboardActionsEnabled = lodash_1.default.get(this.options, 'keyboardBuilder', false) || ((_a = this.options.properties) === null || _a === void 0 ? void 0 : _a.keyboardBuilder);\n const isShowSubmitButton = !this.options.noDefaultSubmitButton\n && !form.components.length;\n // Ensure there is at least a submit button.\n if (isShowSubmitButton) {\n form.components.push({\n type: 'button',\n label: 'Submit',\n key: 'submit',\n size: 'md',\n block: false,\n action: 'submit',\n disableOnInvalid: true,\n theme: 'primary'\n });\n }\n if (this.webform) {\n const shouldRebuild = !this.webform.form.components ||\n (form.components.length !== this.webform.form.components.length);\n return this.webform.setForm(form, { keepAsReference: true }).then(() => {\n if (this.refs.form) {\n this.builderHeight = this.refs.form.offsetHeight;\n }\n if (!shouldRebuild) {\n return this.form;\n }\n return this.rebuild().then(() => this.form);\n });\n }\n return native_promise_only_1.default.resolve(form);\n }\n populateRecaptchaSettings(form) {\n //populate isEnabled for recaptcha form settings\n let isRecaptchaEnabled = false;\n if (this.form.components) {\n (0, formUtils_1.eachComponent)(form.components, component => {\n if (isRecaptchaEnabled) {\n return;\n }\n if (component.type === 'recaptcha') {\n isRecaptchaEnabled = true;\n return false;\n }\n });\n if (isRecaptchaEnabled) {\n lodash_1.default.set(form, 'settings.recaptcha.isEnabled', true);\n }\n else if (lodash_1.default.get(form, 'settings.recaptcha.isEnabled')) {\n lodash_1.default.set(form, 'settings.recaptcha.isEnabled', false);\n }\n }\n }\n removeComponent(component, parent, original) {\n if (!parent) {\n return;\n }\n let remove = true;\n const removingComponentsGroup = !component.skipRemoveConfirm &&\n ((Array.isArray(component.components) && component.components.length) ||\n (Array.isArray(component.rows) && component.rows.length) ||\n (Array.isArray(component.columns) && component.columns.length));\n if (this.options.alwaysConfirmComponentRemoval || removingComponentsGroup) {\n const message = removingComponentsGroup ? 'Removing this component will also remove all of its children. Are you sure you want to do this?'\n : 'Are you sure you want to remove this component?';\n remove = window.confirm(this.t(message));\n }\n if (!original) {\n original = parent.formioContainer.find((comp) => comp.id === component.id);\n }\n const index = parent.formioContainer ? parent.formioContainer.indexOf(original) : 0;\n if (remove && index !== -1) {\n const path = this.getComponentsPath(component, parent.formioComponent.component);\n if (parent.formioContainer) {\n parent.formioContainer.splice(index, 1);\n }\n else if (parent.formioComponent && parent.formioComponent.removeChildComponent) {\n parent.formioComponent.removeChildComponent(component);\n }\n const rebuild = parent.formioComponent.rebuild() || native_promise_only_1.default.resolve();\n rebuild.then(() => {\n this.emit('removeComponent', component, parent.formioComponent.schema, path, index);\n this.emit('change', this.form);\n });\n }\n return remove;\n }\n replaceDoubleQuotes(data, fieldsToRemoveDoubleQuotes = []) {\n if (data) {\n fieldsToRemoveDoubleQuotes.forEach((key) => {\n if (data[key]) {\n data[key] = data[key].replace(/\"/g, \"'\");\n }\n });\n return data;\n }\n }\n updateComponent(component, changed) {\n // Update the preview.\n if (this.preview) {\n this.preview.form = {\n components: [lodash_1.default.omit(Object.assign({}, component), [\n 'hidden',\n 'conditional',\n 'calculateValue',\n 'logic',\n 'autofocus',\n 'customConditional',\n ])],\n config: this.options.formConfig || {}\n };\n const fieldsToRemoveDoubleQuotes = ['label', 'tooltip'];\n this.preview.form.components.forEach(component => this.replaceDoubleQuotes(component, fieldsToRemoveDoubleQuotes));\n const previewElement = this.componentEdit.querySelector('[ref=\"preview\"]');\n if (previewElement) {\n this.setContent(previewElement, this.preview.render());\n this.preview.attach(previewElement);\n }\n }\n // Change the \"default value\" field to be reflective of this component.\n const defaultValueComponent = (0, formUtils_1.getComponent)(this.editForm.components, 'defaultValue', true);\n if (defaultValueComponent && component.type !== 'hidden') {\n const defaultChanged = changed && ((changed.component && changed.component.key === 'defaultValue')\n || (changed.instance && defaultValueComponent.hasComponent && defaultValueComponent.hasComponent(changed.instance)));\n if (!defaultChanged) {\n lodash_1.default.assign(defaultValueComponent.component, lodash_1.default.omit(Object.assign({}, component), [\n 'key',\n 'label',\n 'placeholder',\n 'tooltip',\n 'hidden',\n 'autofocus',\n 'validate',\n 'disabled',\n 'defaultValue',\n 'customDefaultValue',\n 'calculateValue',\n 'conditional',\n 'customConditional',\n 'id'\n ]));\n const parentComponent = defaultValueComponent.parent;\n let tabIndex = -1;\n let index = -1;\n parentComponent.tabs.some((tab, tIndex) => {\n tab.some((comp, compIndex) => {\n if (comp.id === defaultValueComponent.id) {\n tabIndex = tIndex;\n index = compIndex;\n return true;\n }\n return false;\n });\n });\n if (tabIndex !== -1 && index !== -1 && changed && changed.value) {\n const sibling = parentComponent.tabs[tabIndex][index + 1];\n parentComponent.removeComponent(defaultValueComponent);\n const newComp = parentComponent.addComponent(defaultValueComponent.component, defaultValueComponent.data, sibling);\n lodash_1.default.pull(newComp.validators, 'required');\n parentComponent.tabs[tabIndex].splice(index, 1, newComp);\n newComp.checkValidity = () => true;\n newComp.build(defaultValueComponent.element);\n }\n }\n else {\n let dataPath = changed.instance._data.key;\n const path = (0, utils_1.getArrayFromComponentPath)(changed.instance.path);\n path.shift();\n if (path.length) {\n path.unshift(component.key);\n dataPath = (0, utils_1.getStringFromComponentPath)(path);\n }\n lodash_1.default.set(this.preview._data, dataPath, changed.value);\n lodash_1.default.set(this.webform._data, dataPath, changed.value);\n }\n }\n // Called when we update a component.\n this.emit('updateComponent', component);\n }\n findRepeatablePaths() {\n const repeatablePaths = [];\n const keys = new Map();\n (0, formUtils_1.eachComponent)(this.form.components, (comp, path) => {\n if (!comp.key) {\n return;\n }\n if (keys.has(comp.key)) {\n if (keys.get(comp.key).includes(path)) {\n repeatablePaths.push(path);\n }\n else {\n keys.set(comp.key, [...keys.get(comp.key), path]);\n }\n }\n else {\n keys.set(comp.key, [path]);\n }\n }, true);\n return repeatablePaths;\n }\n highlightInvalidComponents() {\n const repeatablePaths = this.findRepeatablePaths();\n let hasInvalidComponents = false;\n this.webform.everyComponent((comp) => {\n var _a, _b;\n const path = comp.path;\n if (repeatablePaths.includes(path)) {\n comp.setCustomValidity(`API Key is not unique: ${comp.key}`);\n hasInvalidComponents = true;\n }\n else if ((_b = (_a = comp.error) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.startsWith('API Key is not unique')) {\n comp.setCustomValidity('');\n }\n });\n this.emit('builderFormValidityChange', hasInvalidComponents);\n }\n /**\n * Called when a new component is saved.\n *\n * @param parent\n * @param component\n * @return {boolean}\n */\n saveComponent(component, parent, isNew, original) {\n this.editForm.detach();\n const parentContainer = parent ? parent.formioContainer : this.container;\n const parentComponent = parent ? parent.formioComponent : this;\n this.dialog.close();\n const path = parentContainer ? this.getComponentsPath(component, parentComponent.component) : '';\n if (!original) {\n original = parent.formioContainer.find((comp) => comp.id === component.id);\n }\n const index = parentContainer ? parentContainer.indexOf(original) : 0;\n if (index !== -1) {\n let submissionData = this.editForm.submission.data;\n submissionData = submissionData.componentJson || submissionData;\n const fieldsToRemoveDoubleQuotes = ['label', 'tooltip'];\n this.replaceDoubleQuotes(submissionData, fieldsToRemoveDoubleQuotes);\n this.hook('beforeSaveComponentSettings', submissionData);\n let comp = null;\n parentComponent.getComponents().forEach((component) => {\n if (component.component.key === original.key) {\n comp = component;\n }\n });\n const originalComp = comp.component;\n const originalComponentSchema = comp.schema;\n const isParentSaveChildMethod = this.isParentSaveChildMethod(parent.formioComponent);\n if (parentContainer && !isParentSaveChildMethod) {\n parentContainer[index] = submissionData;\n if (comp) {\n comp.component = submissionData;\n }\n }\n else if (isParentSaveChildMethod) {\n parent.formioComponent.saveChildComponent(submissionData);\n }\n const rebuild = parentComponent.rebuild() || native_promise_only_1.default.resolve();\n return rebuild.then(() => {\n const schema = parentContainer ? parentContainer[index] : (comp ? comp.schema : []);\n this.emitSaveComponentEvent(schema, originalComp, parentComponent.schema, path, index, isNew, originalComponentSchema);\n this.emit('change', this.form);\n this.highlightInvalidComponents();\n if (this.isComponentCreated) {\n const component = parent.formioComponent.components[0];\n this.moveComponent(component);\n this.isComponentCreated = false;\n }\n });\n }\n this.highlightInvalidComponents();\n return native_promise_only_1.default.resolve();\n }\n emitSaveComponentEvent(schema, originalComp, parentComponentSchema, path, index, isNew, originalComponentSchema) {\n this.emit('saveComponent', schema, originalComp, parentComponentSchema, path, index, isNew, originalComponentSchema);\n }\n editComponent(component, parent, isNew, isJsonEdit, original, flags = {}) {\n if (!component.key) {\n return;\n }\n let saved = false;\n const componentCopy = (0, utils_1.fastCloneDeep)(component);\n let ComponentClass = Components_1.default.components[componentCopy.type];\n const isCustom = ComponentClass === undefined;\n isJsonEdit = isJsonEdit || isCustom;\n ComponentClass = isCustom ? Components_1.default.components.unknown : ComponentClass;\n // Make sure we only have one dialog open at a time.\n if (this.dialog) {\n this.dialog.close();\n this.highlightInvalidComponents();\n }\n // This is the render step.\n const editFormOptions = lodash_1.default.clone(lodash_1.default.get(this, 'options.editForm', {}));\n if (this.editForm) {\n this.editForm.destroy();\n }\n // Allow editForm overrides per component.\n const overrides = lodash_1.default.get(this.options, `editForm.${componentCopy.type}`, {});\n // Pass along the form being edited.\n editFormOptions.editForm = this.form;\n editFormOptions.editComponent = component;\n editFormOptions.flags = flags;\n this.hook('editComponentParentInstance', editFormOptions, parent);\n this.editForm = new Webform_1.default(Object.assign(Object.assign(Object.assign({}, lodash_1.default.omit(this.options, ['hooks', 'builder', 'events', 'attachMode', 'skipInit'])), { language: this.options.language }), editFormOptions));\n this.hook('editFormProperties', parent);\n this.editForm.form = (isJsonEdit && !isCustom) ? {\n components: [\n {\n type: 'textarea',\n as: 'json',\n editor: 'ace',\n weight: 10,\n input: true,\n key: 'componentJson',\n label: 'Component JSON',\n tooltip: 'Edit the JSON for this component.'\n },\n {\n type: 'checkbox',\n key: 'showFullSchema',\n label: 'Full Schema'\n }\n ]\n } : ComponentClass.editForm(lodash_1.default.cloneDeep(overrides));\n const instanceOptions = {};\n this.hook('instanceOptionsPreview', instanceOptions);\n const instance = new ComponentClass(componentCopy, instanceOptions);\n const schema = this.hook('builderComponentSchema', component, instance);\n this.editForm.submission = isJsonEdit ? {\n data: {\n componentJson: schema,\n showFullSchema: this.options.showFullJsonSchema\n },\n } : {\n data: instance.component,\n };\n if (this.preview) {\n this.preview.destroy();\n }\n if (!ComponentClass.builderInfo.hasOwnProperty('preview') || ComponentClass.builderInfo.preview) {\n this.preview = new Webform_1.default(lodash_1.default.omit(Object.assign(Object.assign({}, this.options), { preview: true }), [\n 'hooks',\n 'builder',\n 'events',\n 'attachMode',\n 'calculateValue'\n ]));\n this.hook('previewFormSettitngs', schema, isJsonEdit);\n }\n this.componentEdit = this.ce('div', { 'class': 'component-edit-container' });\n this.setContent(this.componentEdit, this.renderTemplate('builderEditForm', {\n componentInfo: ComponentClass.builderInfo,\n editForm: this.editForm.render(),\n preview: this.preview ? this.preview.render() : false,\n helplinks: this.helplinks,\n }));\n this.dialog = this.createModal(this.componentEdit, lodash_1.default.get(this.options, 'dialogAttr', {}));\n // This is the attach step.\n this.editForm.attach(this.componentEdit.querySelector('[ref=\"editForm\"]'));\n this.hook('editFormWrapper');\n this.updateComponent(componentCopy);\n this.editForm.on('change', (event) => {\n if (event.changed) {\n if (event.changed.component && event.changed.component.key === 'showFullSchema') {\n const { value } = event.changed;\n this.editForm.submission = {\n data: {\n componentJson: value ? instance.component : component,\n showFullSchema: value\n },\n };\n return;\n }\n // See if this is a manually modified key. Treat custom component keys as manually modified\n if ((event.changed.component && (event.changed.component.key === 'key')) || isJsonEdit) {\n componentCopy.keyModified = true;\n }\n let isComponentLabelChanged = false;\n if (event.changed.instance) {\n isComponentLabelChanged = ['label', 'title'].includes(event.changed.instance.path);\n }\n else if (event.changed.component) {\n isComponentLabelChanged = ['label', 'title'].includes(event.changed.component.key);\n }\n if (isComponentLabelChanged) {\n // Ensure this component has a key.\n if (isNew) {\n if (!event.data.keyModified) {\n this.editForm.everyComponent(component => {\n if (component.key === 'key' && component.parent.component.key === 'tabs') {\n component.setValue(this.updateComponentKey(event.data));\n return false;\n }\n });\n }\n if (this.form) {\n let formComponents = this.findNamespaceRoot(parent.formioComponent);\n // excluding component which key uniqueness is to be checked to prevent the comparing of the same keys\n formComponents = formComponents.filter(comp => editFormOptions.editComponent.id !== comp.id);\n // Set a unique key for this component.\n builder_1.default.uniquify(formComponents, event.data);\n }\n }\n }\n // Update the component.\n this.updateComponent(event.data.componentJson || event.data, event.changed);\n }\n });\n const cancelButtons = this.componentEdit.querySelectorAll('[ref=\"cancelButton\"]');\n cancelButtons.forEach((cancelButton) => {\n this.addEventListener(cancelButton, 'click', (event) => {\n event.preventDefault();\n this.editForm.detach();\n this.emit('cancelComponent', component);\n this.dialog.close();\n this.highlightInvalidComponents();\n });\n });\n const removeButtons = this.componentEdit.querySelectorAll('[ref=\"removeButton\"]');\n removeButtons.forEach((removeButton) => {\n this.addEventListener(removeButton, 'click', (event) => {\n event.preventDefault();\n // Since we are already removing the component, don't trigger another remove.\n saved = true;\n this.editForm.detach();\n this.removeComponent(component, parent, original);\n this.dialog.close();\n this.highlightInvalidComponents();\n });\n });\n const saveButtons = this.componentEdit.querySelectorAll('[ref=\"saveButton\"]');\n saveButtons.forEach((saveButton) => {\n this.addEventListener(saveButton, 'click', (event) => {\n event.preventDefault();\n if (!this.editForm.checkValidity(this.editForm.data, true, this.editForm.data)) {\n this.editForm.setPristine(false);\n this.editForm.showErrors();\n return false;\n }\n saved = true;\n this.saveComponent(component, parent, isNew, original);\n });\n });\n const dialogClose = () => {\n this.editForm.destroy(true);\n if (this.preview) {\n this.preview.destroy(true);\n this.preview = null;\n }\n if (isNew && !saved) {\n this.removeComponent(component, parent, original);\n this.highlightInvalidComponents();\n }\n // Clean up.\n this.removeEventListener(this.dialog, 'close', dialogClose);\n this.dialog = null;\n };\n this.addEventListener(this.dialog, 'close', dialogClose);\n // Called when we edit a component.\n this.emit('editComponent', component);\n }\n updateComponentKey(data) {\n return lodash_1.default.camelCase(data.title ||\n data.label ||\n data.placeholder ||\n data.type).replace(/^[0-9]*/, '');\n }\n moveComponent(component) {\n component.element.focus();\n component.element.classList.add('builder-selected');\n this.selectedElement = component;\n this.removeEventListener(component.element, 'keydown');\n this.addEventListener(component.element, 'keydown', this.moveHandler.bind(this));\n }\n updateComponentPlacement(direction) {\n const component = this.selectedElement;\n let index, info;\n const step = direction ? -1 : 1;\n if (component) {\n const element = component.element;\n const sibling = direction ? element.previousElementSibling : element.nextElementSibling;\n const source = element.parentNode;\n const containerLength = source.formioContainer.length;\n if (containerLength && containerLength <= 1) {\n return;\n }\n if (source.formioContainer) {\n index = lodash_1.default.findIndex(source.formioContainer, { key: element.formioComponent.component.key });\n if (index !== -1) {\n info = source.formioContainer.splice(lodash_1.default.findIndex(source.formioContainer, { key: element.formioComponent.component.key }), 1);\n info = info[0];\n source.removeChild(element);\n }\n }\n const len = source.formioComponent.components.length;\n index = (index === -1) ? 0 : index + step;\n if (index === -1) {\n source.formioContainer.push(info);\n source.appendChild(element);\n }\n else if (index === len) {\n const key = source.formioContainer[0].key;\n index = lodash_1.default.findIndex(source.formioComponent.components, { key: key });\n const firstElement = source.formioComponent.components[index].element;\n source.formioContainer.splice(0, 0, info);\n source.insertBefore(element, firstElement);\n }\n else if (index !== -1) {\n source.formioContainer.splice(index, 0, info);\n direction\n ? source.insertBefore(element, sibling)\n : source.insertBefore(element, sibling.nextElementSibling);\n }\n element.focus();\n }\n }\n stopMoving(comp) {\n const parent = comp.element.parentNode;\n parent.formioComponent.rebuild();\n }\n addNewComponent(element) {\n var _a;\n const source = document.querySelector('.formio-builder-form');\n const key = element.getAttribute('data-key');\n const group = element.getAttribute('data-group');\n const isNew = true;\n let info;\n if (key && group) {\n info = this.getComponentInfo(key, group);\n }\n if (isNew && !this.options.noNewEdit && !info.noNewEdit) {\n builder_1.default.uniquify(this.findNamespaceRoot(source.formioComponent), info);\n this.editComponent(info, source, isNew, null, null);\n }\n const firstComponent = (_a = source.formioComponent.components[0]) === null || _a === void 0 ? void 0 : _a.element;\n if (firstComponent) {\n source.formioContainer.splice(0, 0, info);\n }\n else {\n source.formioContainer.push(info);\n }\n source.formioComponent.rebuild().then(() => {\n this.isComponentCreated = true;\n });\n }\n /**\n * Creates copy of component schema and stores it under sessionStorage.\n * @param {Component} component\n * @return {*}\n */\n copyComponent(component) {\n if (!window.sessionStorage) {\n return console.warn('Session storage is not supported in this browser.');\n }\n this.addClass(this.refs.form, 'builder-paste-mode');\n window.sessionStorage.setItem('formio.clipboard', JSON.stringify(component.schema));\n }\n /**\n * Paste copied component after the current component.\n * @param {Component} component\n * @return {*}\n */\n pasteComponent(component) {\n if (!window.sessionStorage) {\n return console.warn('Session storage is not supported in this browser.');\n }\n this.removeClass(this.refs.form, 'builder-paste-mode');\n if (window.sessionStorage) {\n const data = window.sessionStorage.getItem('formio.clipboard');\n if (data) {\n const schema = JSON.parse(data);\n const parent = this.getParentElement(component.element);\n if (parent) {\n builder_1.default.uniquify(this.findNamespaceRoot(parent.formioComponent), schema);\n let path = '';\n let index = 0;\n const isParentSaveChildMethod = this.isParentSaveChildMethod(parent.formioComponent);\n if (parent.formioContainer && !isParentSaveChildMethod) {\n index = parent.formioContainer.indexOf(component.component);\n path = this.getComponentsPath(schema, parent.formioComponent.component);\n parent.formioContainer.splice(index + 1, 0, schema);\n }\n else if (isParentSaveChildMethod) {\n parent.formioComponent.saveChildComponent(schema, false);\n }\n parent.formioComponent.rebuild();\n this.emitSaveComponentEvent(schema, schema, parent.formioComponent.component, path, (index + 1), true, schema);\n }\n this.emit('change', this.form);\n }\n }\n }\n isParentSaveChildMethod(parentComp) {\n return !!(parentComp && parentComp.saveChildComponent);\n }\n getParentElement(element) {\n let container = element;\n do {\n container = container.parentNode;\n } while (container && !container.formioComponent);\n return container;\n }\n addBuilderComponentInfo(component) {\n if (!component || !component.group || !this.groups[component.group]) {\n return;\n }\n component = lodash_1.default.clone(component);\n const groupInfo = this.groups[component.group];\n if (!groupInfo.components.hasOwnProperty(component.key)) {\n groupInfo.components[component.key] = component;\n }\n return component;\n }\n init() {\n if (this.webform) {\n this.webform.init();\n }\n return super.init();\n }\n clear() {\n if (this.webform.initialized) {\n this.webform.clear();\n }\n }\n destroy(all = false) {\n if (this.webform.initialized) {\n this.webform.destroy(all);\n }\n super.destroy(all);\n }\n addBuilderGroup(name, group) {\n if (!this.groups[name]) {\n this.groups[name] = group;\n this.groupOrder.push(name);\n this.triggerRedraw();\n }\n else {\n this.updateBuilderGroup(name, group);\n }\n }\n updateBuilderGroup(name, group) {\n if (this.groups[name]) {\n this.groups[name] = group;\n this.triggerRedraw();\n }\n }\n generateKey(info) {\n return info.key || lodash_1.default.camelCase(info.title ||\n info.label ||\n info.placeholder ||\n info.type);\n }\n}\nexports[\"default\"] = WebformBuilder;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/WebformBuilder.js?");
5295
5295
 
5296
5296
  /***/ }),
5297
5297
 
@@ -5313,7 +5313,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
5313
5313
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
5314
5314
 
5315
5315
  "use strict";
5316
- eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst WebformBuilder_1 = __importDefault(__webpack_require__(/*! ./WebformBuilder */ \"./lib/cjs/WebformBuilder.js\"));\nconst Webform_1 = __importDefault(__webpack_require__(/*! ./Webform */ \"./lib/cjs/Webform.js\"));\nconst builder_1 = __importDefault(__webpack_require__(/*! ./utils/builder */ \"./lib/cjs/utils/builder.js\"));\nconst lodash_1 = __importDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nconst utils_1 = __webpack_require__(/*! ./utils/utils */ \"./lib/cjs/utils/utils.js\");\nconst dragula_1 = __importDefault(__webpack_require__(/*! dragula */ \"./node_modules/dragula/dragula.js\"));\nclass WizardBuilder extends WebformBuilder_1.default {\n constructor() {\n let element, options;\n if (arguments[0] instanceof HTMLElement || arguments[1]) {\n element = arguments[0];\n options = arguments[1];\n }\n else {\n options = arguments[0];\n }\n // Reset skipInit in case PDFBuilder has set it.\n options.skipInit = false;\n options.display = 'wizard';\n super(element, options);\n this._form = {\n components: [\n this.getPageConfig(1),\n ],\n };\n this.page = 0;\n // Need to create a component order for each group.\n for (const group in this.groups) {\n if (this.groups[group] && this.groups[group].components) {\n this.groups[group].componentOrder = Object.keys(this.groups[group].components)\n .map(key => this.groups[group].components[key])\n .filter(component => component && !component.ignore)\n .sort((a, b) => a.weight - b.weight)\n .map(component => component.key);\n }\n }\n const originalRenderComponentsHook = this.options.hooks.renderComponents;\n this.options.hooks.renderComponents = (html, { components, self }) => {\n if (self.type === 'form' && !self.root) {\n return html;\n }\n else {\n return originalRenderComponentsHook(html, { components, self });\n }\n };\n const originalAttachComponentsHook = this.options.hooks.attachComponents;\n this.options.hooks.attachComponents = (element, components, container, component) => {\n if (component.type === 'form' && !component.root) {\n return element;\n }\n return originalAttachComponentsHook(element, components, container, component);\n };\n // Wizard pages don't replace themselves in the right array. Do that here.\n this.on('saveComponent', (component, originalComponent) => {\n const webformComponents = this.webform.components.map(({ component }) => component);\n if (this._form.components.includes(originalComponent)) {\n this._form.components[this._form.components.indexOf(originalComponent)] = component;\n this.rebuild();\n }\n else if (webformComponents.includes(originalComponent)) {\n this._form.components.push(component);\n this.rebuild();\n }\n else {\n // Fallback to look for panel based on key.\n const formComponentIndex = this._form.components.findIndex((comp) => originalComponent.key === comp.key);\n if (formComponentIndex !== -1) {\n this._form.components[formComponentIndex] = component;\n this.rebuild();\n }\n }\n }, true);\n }\n removeComponent(component, parent, original) {\n const remove = super.removeComponent(component, parent, original);\n // If user agrees to remove the whole group of the components and it could be a Wizard page, find it and remove\n if (remove && component.type === 'panel') {\n const pageIndex = this.pages.findIndex((page) => page.key === component.key);\n const componentIndex = this._form.components.findIndex((comp) => comp.key === component.key);\n if (pageIndex !== -1) {\n this.removePage(pageIndex, componentIndex);\n }\n }\n return remove;\n }\n allowDrop(element) {\n return (this.webform && this.webform.refs && this.webform.refs.webform === element) ? false : true;\n }\n get pages() {\n return lodash_1.default.filter(this._form.components, { type: 'panel' });\n }\n get currentPage() {\n const pages = this.pages;\n return (pages && (pages.length >= this.page)) ? pages[this.page] : null;\n }\n set form(value) {\n this._form = value;\n if (!this._form.components || !Array.isArray(this._form.components)) {\n this._form.components = [];\n }\n if (this.pages.length === 0) {\n const components = this._form.components.filter((component) => component.type !== 'button');\n this._form.components = [this.getPageConfig(1, components)];\n }\n this.rebuild();\n }\n get form() {\n return this._form;\n }\n get schema() {\n lodash_1.default.assign(this.currentPage, this.webform._form.components[0]);\n const webform = new Webform_1.default(this.options);\n webform.setForm(this._form, { noEmit: true });\n return webform.schema;\n }\n render() {\n return this.renderTemplate('builderWizard', {\n sidebar: this.renderTemplate('builderSidebar', {\n scrollEnabled: this.sideBarScroll,\n groupOrder: this.groupOrder,\n groupId: `builder-sidebar-${this.id}`,\n groups: this.groupOrder.map((groupKey) => this.renderTemplate('builderSidebarGroup', {\n group: this.groups[groupKey],\n groupKey,\n groupId: `builder-sidebar-${this.id}`,\n subgroups: this.groups[groupKey].subgroups.map((group) => this.renderTemplate('builderSidebarGroup', {\n group,\n groupKey: group.key,\n groupId: `group-container-${groupKey}`,\n subgroups: []\n })),\n })),\n }),\n pages: this.pages,\n form: this.webform.render(),\n });\n }\n attach(element) {\n this.loadRefs(element, {\n addPage: 'multiple',\n gotoPage: 'multiple',\n });\n this.refs.gotoPage.forEach((page, index) => {\n page.parentNode.dragInfo = { index };\n });\n if (dragula_1.default) {\n (0, dragula_1.default)([this.element.querySelector('.wizard-pages')])\n .on('drop', this.onReorder.bind(this));\n }\n this.refs.addPage.forEach(link => {\n this.addEventListener(link, 'click', (event) => {\n event.preventDefault();\n this.addPage();\n });\n });\n this.refs.gotoPage.forEach((link, index) => {\n this.addEventListener(link, 'click', (event) => {\n event.preventDefault();\n this.setPage(index);\n });\n });\n return super.attach(element);\n }\n rebuild() {\n var _a;\n const page = this.currentPage;\n this.webform.setForm({\n display: 'form',\n type: 'form',\n components: page ? [page] : [],\n controller: ((_a = this._form) === null || _a === void 0 ? void 0 : _a.controller) || ''\n }, { keepAsReference: true });\n return this.redraw();\n }\n addPage(page) {\n const newPage = page && page.schema ? (0, utils_1.fastCloneDeep)(page.schema) : this.getPageConfig(this.pages.length + 1);\n builder_1.default.uniquify(this._form.components, newPage);\n this._form.components.push(newPage);\n this.emitSaveComponentEvent(newPage, newPage, this._form, 'components', (this._form.components.length - 1), true, newPage);\n this.emit('change', this._form);\n return this.rebuild();\n }\n removePage(pageIndex, componentIndex) {\n this._form.components.splice(componentIndex, 1);\n this.emit('change', this._form);\n if (pageIndex === this.pages.length) {\n // If the last page is removed.\n if (pageIndex === 0) {\n this._form.components.push(this.getPageConfig(1));\n return this.rebuild();\n }\n else {\n return this.setPage(pageIndex - 1);\n }\n }\n else {\n return this.rebuild();\n }\n }\n onReorder(element, _target, _source, sibling) {\n if (!element.dragInfo || (sibling && !sibling.dragInfo)) {\n console.warn('There is no Drag Info available for either dragged or sibling element');\n return;\n }\n const oldPosition = element.dragInfo.index;\n //should drop at next sibling position; no next sibling means drop to last position\n const newPosition = (sibling ? sibling.dragInfo.index : this.pages.length);\n const movedBelow = newPosition > oldPosition;\n const formComponents = (0, utils_1.fastCloneDeep)(this._form.components);\n const draggedRowData = this._form.components[oldPosition];\n //insert element at new position\n formComponents.splice(newPosition, 0, draggedRowData);\n //remove element from old position (if was moved above, after insertion it's at +1 index)\n formComponents.splice(movedBelow ? oldPosition : oldPosition + 1, 1);\n this._form.components = (0, utils_1.fastCloneDeep)(formComponents);\n return this.rebuild().then(() => {\n this.emit('change', this._form);\n });\n }\n setPage(index) {\n if (index === this.page) {\n return;\n }\n this.page = index;\n return this.rebuild();\n }\n getPageConfig(index, components = []) {\n return {\n title: `Page ${index}`,\n label: `Page ${index}`,\n type: 'panel',\n key: `page${index}`,\n components,\n };\n }\n pasteComponent(component) {\n if (component instanceof WizardBuilder) {\n return;\n }\n if (this._form.components.find(comp => lodash_1.default.isEqual(component.component, comp))) {\n this.addPage(component);\n }\n else {\n return super.pasteComponent(component);\n }\n }\n}\nexports[\"default\"] = WizardBuilder;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/WizardBuilder.js?");
5316
+ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst WebformBuilder_1 = __importDefault(__webpack_require__(/*! ./WebformBuilder */ \"./lib/cjs/WebformBuilder.js\"));\nconst Webform_1 = __importDefault(__webpack_require__(/*! ./Webform */ \"./lib/cjs/Webform.js\"));\nconst builder_1 = __importDefault(__webpack_require__(/*! ./utils/builder */ \"./lib/cjs/utils/builder.js\"));\nconst lodash_1 = __importDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nconst utils_1 = __webpack_require__(/*! ./utils/utils */ \"./lib/cjs/utils/utils.js\");\nclass WizardBuilder extends WebformBuilder_1.default {\n constructor() {\n let element, options;\n if (arguments[0] instanceof HTMLElement || arguments[1]) {\n element = arguments[0];\n options = arguments[1];\n }\n else {\n options = arguments[0];\n }\n // Reset skipInit in case PDFBuilder has set it.\n options.skipInit = false;\n options.display = 'wizard';\n super(element, options);\n this._form = {\n components: [\n this.getPageConfig(1),\n ],\n };\n this.page = 0;\n // Need to create a component order for each group.\n for (const group in this.groups) {\n if (this.groups[group] && this.groups[group].components) {\n this.groups[group].componentOrder = Object.keys(this.groups[group].components)\n .map(key => this.groups[group].components[key])\n .filter(component => component && !component.ignore)\n .sort((a, b) => a.weight - b.weight)\n .map(component => component.key);\n }\n }\n const originalRenderComponentsHook = this.options.hooks.renderComponents;\n this.options.hooks.renderComponents = (html, { components, self }) => {\n if (self.type === 'form' && !self.root) {\n return html;\n }\n else {\n return originalRenderComponentsHook(html, { components, self });\n }\n };\n const originalAttachComponentsHook = this.options.hooks.attachComponents;\n this.options.hooks.attachComponents = (element, components, container, component) => {\n if (component.type === 'form' && !component.root) {\n return element;\n }\n return originalAttachComponentsHook(element, components, container, component);\n };\n // Wizard pages don't replace themselves in the right array. Do that here.\n this.on('saveComponent', (component, originalComponent) => {\n const webformComponents = this.webform.components.map(({ component }) => component);\n if (this._form.components.includes(originalComponent)) {\n this._form.components[this._form.components.indexOf(originalComponent)] = component;\n this.rebuild();\n }\n else if (webformComponents.includes(originalComponent)) {\n this._form.components.push(component);\n this.rebuild();\n }\n else {\n // Fallback to look for panel based on key.\n const formComponentIndex = this._form.components.findIndex((comp) => originalComponent.key === comp.key);\n if (formComponentIndex !== -1) {\n this._form.components[formComponentIndex] = component;\n this.rebuild();\n }\n }\n }, true);\n }\n removeComponent(component, parent, original) {\n const remove = super.removeComponent(component, parent, original);\n // If user agrees to remove the whole group of the components and it could be a Wizard page, find it and remove\n if (remove && component.type === 'panel') {\n const pageIndex = this.pages.findIndex((page) => page.key === component.key);\n const componentIndex = this._form.components.findIndex((comp) => comp.key === component.key);\n if (pageIndex !== -1) {\n this.removePage(pageIndex, componentIndex);\n }\n }\n return remove;\n }\n allowDrop(element) {\n return (this.webform && this.webform.refs && this.webform.refs.webform === element) ? false : true;\n }\n get pages() {\n return lodash_1.default.filter(this._form.components, { type: 'panel' });\n }\n get currentPage() {\n const pages = this.pages;\n return (pages && (pages.length >= this.page)) ? pages[this.page] : null;\n }\n set form(value) {\n this._form = value;\n if (!this._form.components || !Array.isArray(this._form.components)) {\n this._form.components = [];\n }\n if (this.pages.length === 0) {\n const components = this._form.components.filter((component) => component.type !== 'button');\n this._form.components = [this.getPageConfig(1, components)];\n }\n this.rebuild();\n }\n get form() {\n return this._form;\n }\n get schema() {\n lodash_1.default.assign(this.currentPage, this.webform._form.components[0]);\n const webform = new Webform_1.default(this.options);\n webform.setForm(this._form, { noEmit: true });\n return webform.schema;\n }\n render() {\n return this.renderTemplate('builderWizard', {\n sidebar: this.renderTemplate('builderSidebar', {\n scrollEnabled: this.sideBarScroll,\n groupOrder: this.groupOrder,\n groupId: `builder-sidebar-${this.id}`,\n groups: this.groupOrder.map((groupKey) => this.renderTemplate('builderSidebarGroup', {\n group: this.groups[groupKey],\n groupKey,\n groupId: `builder-sidebar-${this.id}`,\n subgroups: this.groups[groupKey].subgroups.map((group) => this.renderTemplate('builderSidebarGroup', {\n group,\n groupKey: group.key,\n groupId: `group-container-${groupKey}`,\n subgroups: []\n })),\n })),\n }),\n pages: this.pages,\n form: this.webform.render(),\n });\n }\n attach(element) {\n this.loadRefs(element, {\n addPage: 'multiple',\n gotoPage: 'multiple',\n });\n this.refs.gotoPage.forEach((page, index) => {\n page.parentNode.dragInfo = { index };\n });\n if (this.dragulaLib) {\n this.dragulaLib([this.element.querySelector('.wizard-pages')])\n .on('drop', this.onReorder.bind(this));\n }\n this.refs.addPage.forEach(link => {\n this.addEventListener(link, 'click', (event) => {\n event.preventDefault();\n this.addPage();\n });\n });\n this.refs.gotoPage.forEach((link, index) => {\n this.addEventListener(link, 'click', (event) => {\n event.preventDefault();\n this.setPage(index);\n });\n });\n return super.attach(element);\n }\n rebuild() {\n var _a;\n const page = this.currentPage;\n this.webform.setForm({\n display: 'form',\n type: 'form',\n components: page ? [page] : [],\n controller: ((_a = this._form) === null || _a === void 0 ? void 0 : _a.controller) || ''\n }, { keepAsReference: true });\n return this.redraw();\n }\n addPage(page) {\n const newPage = page && page.schema ? (0, utils_1.fastCloneDeep)(page.schema) : this.getPageConfig(this.pages.length + 1);\n builder_1.default.uniquify(this._form.components, newPage);\n this._form.components.push(newPage);\n this.emitSaveComponentEvent(newPage, newPage, this._form, 'components', (this._form.components.length - 1), true, newPage);\n this.emit('change', this._form);\n return this.rebuild();\n }\n removePage(pageIndex, componentIndex) {\n this._form.components.splice(componentIndex, 1);\n this.emit('change', this._form);\n if (pageIndex === this.pages.length) {\n // If the last page is removed.\n if (pageIndex === 0) {\n this._form.components.push(this.getPageConfig(1));\n return this.rebuild();\n }\n else {\n return this.setPage(pageIndex - 1);\n }\n }\n else {\n return this.rebuild();\n }\n }\n onReorder(element, _target, _source, sibling) {\n if (!element.dragInfo || (sibling && !sibling.dragInfo)) {\n console.warn('There is no Drag Info available for either dragged or sibling element');\n return;\n }\n const oldPosition = element.dragInfo.index;\n //should drop at next sibling position; no next sibling means drop to last position\n const newPosition = (sibling ? sibling.dragInfo.index : this.pages.length);\n const movedBelow = newPosition > oldPosition;\n const formComponents = (0, utils_1.fastCloneDeep)(this._form.components);\n const draggedRowData = this._form.components[oldPosition];\n //insert element at new position\n formComponents.splice(newPosition, 0, draggedRowData);\n //remove element from old position (if was moved above, after insertion it's at +1 index)\n formComponents.splice(movedBelow ? oldPosition : oldPosition + 1, 1);\n this._form.components = (0, utils_1.fastCloneDeep)(formComponents);\n return this.rebuild().then(() => {\n this.emit('change', this._form);\n });\n }\n setPage(index) {\n if (index === this.page) {\n return;\n }\n this.page = index;\n return this.rebuild();\n }\n getPageConfig(index, components = []) {\n return {\n title: `Page ${index}`,\n label: `Page ${index}`,\n type: 'panel',\n key: `page${index}`,\n components,\n };\n }\n pasteComponent(component) {\n if (component instanceof WizardBuilder) {\n return;\n }\n if (this._form.components.find(comp => lodash_1.default.isEqual(component.component, comp))) {\n this.addPage(component);\n }\n else {\n return super.pasteComponent(component);\n }\n }\n}\nexports[\"default\"] = WizardBuilder;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/WizardBuilder.js?");
5317
5317
 
5318
5318
  /***/ }),
5319
5319
 
@@ -5973,7 +5973,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
5973
5973
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
5974
5974
 
5975
5975
  "use strict";
5976
- eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst lodash_1 = __importDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nconst NestedArrayComponent_1 = __importDefault(__webpack_require__(/*! ../_classes/nestedarray/NestedArrayComponent */ \"./lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js\"));\nconst utils_1 = __webpack_require__(/*! ../../utils/utils */ \"./lib/cjs/utils/utils.js\");\nconst dragula_1 = __importDefault(__webpack_require__(/*! dragula */ \"./node_modules/dragula/dragula.js\"));\nclass DataGridComponent extends NestedArrayComponent_1.default {\n static schema(...extend) {\n return NestedArrayComponent_1.default.schema({\n label: 'Data Grid',\n key: 'dataGrid',\n type: 'datagrid',\n clearOnHide: true,\n input: true,\n tree: true,\n components: []\n }, ...extend);\n }\n static get builderInfo() {\n return {\n title: 'Data Grid',\n icon: 'th',\n group: 'data',\n documentation: '/userguide/form-building/data-components#data-grid',\n weight: 30,\n schema: DataGridComponent.schema()\n };\n }\n constructor(...args) {\n super(...args);\n this.type = 'datagrid';\n this.tabIndex = 0;\n }\n init() {\n this.components = this.components || [];\n // Add new values based on minLength.\n this.rows = [];\n this.columns = [...this.component.components];\n if (this.initRows || !lodash_1.default.isEqual(this.dataValue, this.emptyValue)) {\n this.createRows(true);\n }\n this.visibleColumns = {};\n this.prevHasAddButton = this.hasAddButton();\n this.checkColumns();\n }\n get dataValue() {\n const dataValue = super.dataValue;\n if (!dataValue || !Array.isArray(dataValue)) {\n return this.emptyValue;\n }\n return dataValue;\n }\n set dataValue(value) {\n super.dataValue = value;\n }\n get defaultSchema() {\n return DataGridComponent.schema();\n }\n get initEmpty() {\n return this.component.initEmpty || this.component.noFirstRow;\n }\n get initRows() {\n return this.builderMode || this.path === 'defaultValue' || !this.initEmpty;\n }\n get emptyValue() {\n return this.initEmpty ? [] : [{}];\n }\n get addAnotherPosition() {\n return lodash_1.default.get(this.component, 'addAnotherPosition', 'bottom');\n }\n get minLength() {\n if (this.hasRowGroups()) {\n return lodash_1.default.sum(this.getGroupSizes());\n }\n else {\n return lodash_1.default.get(this.component, 'validate.minLength', 0);\n }\n }\n get defaultValue() {\n const isBuilderMode = this.builderMode;\n const isEmptyInit = this.initEmpty;\n // Ensure we have one and only one row in builder mode.\n if (isBuilderMode || (isEmptyInit && !this.dataValue.length)) {\n return isEmptyInit && !isBuilderMode ? [] : [{}];\n }\n const value = super.defaultValue;\n let defaultValue;\n if (Array.isArray(value)) {\n defaultValue = value;\n }\n else if (value && (typeof value === 'object')) {\n defaultValue = [value];\n }\n else {\n defaultValue = this.emptyValue;\n }\n for (let dIndex = defaultValue.length; dIndex < this.minLength; dIndex++) {\n defaultValue.push({});\n }\n return defaultValue;\n }\n set disabled(disabled) {\n super.disabled = disabled;\n lodash_1.default.each(this.refs[`${this.datagridKey}-addRow`], (button) => {\n button.disabled = disabled;\n });\n lodash_1.default.each(this.refs[`${this.datagridKey}-removeRow`], (button) => {\n button.disabled = disabled;\n });\n }\n get disabled() {\n return super.disabled;\n }\n get datagridKey() {\n return `datagrid-${this.key}`;\n }\n get allowReorder() {\n return !this.options.readOnly && lodash_1.default.get(this.component, 'reorder', false);\n }\n get iteratableRows() {\n return this.rows.map((row, index) => ({\n components: row,\n data: this.dataValue[index],\n }));\n }\n /**\n * Split rows into chunks.\n * @param {Number[]} groups - array of numbers where each item is size of group\n * @param {Array<T>} rows - rows collection\n * @return {Array<T[]>}\n */\n getRowChunks(groups, rows) {\n const [, chunks] = groups.reduce(([startIndex, acc], size) => {\n const endIndex = startIndex + size;\n return [endIndex, [...acc, [startIndex, endIndex]]];\n }, [0, []]);\n return chunks.map(range => lodash_1.default.slice(rows, ...range));\n }\n /**\n * Create groups object.\n * Each key in object represents index of first row in group.\n * @return {Object}\n */\n getGroups() {\n const groups = lodash_1.default.get(this.component, 'rowGroups', []);\n const sizes = lodash_1.default.map(groups, 'numberOfRows').slice(0, -1);\n const indexes = sizes.reduce((groupIndexes, size) => {\n const last = groupIndexes[groupIndexes.length - 1];\n return groupIndexes.concat(last + size);\n }, [0]);\n return groups.reduce((gidxs, group, idx) => {\n return Object.assign(Object.assign({}, gidxs), { [indexes[idx]]: group });\n }, {});\n }\n /**\n * Retrun group sizes.\n * @return {Number[]}\n */\n getGroupSizes() {\n return lodash_1.default.map(lodash_1.default.get(this.component, 'rowGroups', []), 'numberOfRows');\n }\n hasRowGroups() {\n return lodash_1.default.get(this, 'component.enableRowGroups', false) && !this.builderMode;\n }\n totalRowsNumber(groups) {\n return lodash_1.default.sum(lodash_1.default.map(groups, 'numberOfRows'));\n }\n setStaticValue(n) {\n this.dataValue = lodash_1.default.range(n).map(() => ({}));\n }\n hasExtraColumn() {\n return (this.hasRemoveButtons() || this.canAddColumn);\n }\n hasRemoveButtons() {\n return !this.builderMode && !this.component.disableAddingRemovingRows &&\n !this.options.readOnly &&\n !this.disabled &&\n this.fullMode &&\n (this.dataValue.length > lodash_1.default.get(this.component, 'validate.minLength', 0));\n }\n hasTopSubmit() {\n return this.hasAddButton() && ['top', 'both'].includes(this.addAnotherPosition);\n }\n hasBottomSubmit() {\n return this.hasAddButton() && ['bottom', 'both'].includes(this.addAnotherPosition);\n }\n get canAddColumn() {\n return this.builderMode;\n }\n render() {\n const columns = this.getColumns();\n let columnExtra = 0;\n const hasRemoveButtons = this.hasRemoveButtons();\n if (this.component.reorder) {\n columnExtra++;\n }\n if (hasRemoveButtons) {\n columnExtra++;\n }\n if (this.canAddColumn) {\n columnExtra++;\n }\n const colWidth = Math.floor(12 / (columns.length + columnExtra));\n return super.render(this.renderTemplate('datagrid', {\n rows: this.getRows(),\n columns: columns,\n groups: this.hasRowGroups() ? this.getGroups() : [],\n visibleColumns: this.visibleColumns,\n hasToggle: lodash_1.default.get(this, 'component.groupToggle', false),\n hasHeader: this.hasHeader(),\n hasExtraColumn: this.hasExtraColumn(),\n hasAddButton: this.hasAddButton(),\n hasRemoveButtons,\n hasTopSubmit: this.hasTopSubmit(),\n hasBottomSubmit: this.hasBottomSubmit(),\n hasGroups: this.hasRowGroups(),\n numColumns: columns.length + (this.hasExtraColumn() ? 1 : 0),\n datagridKey: this.datagridKey,\n allowReorder: this.allowReorder,\n builder: this.builderMode,\n canAddColumn: this.canAddColumn,\n tabIndex: this.tabIndex,\n placeholder: this.renderTemplate('builderPlaceholder', {\n position: this.componentComponents.length,\n }),\n colWidth: colWidth.toString()\n }));\n }\n getRows() {\n return this.rows.map(row => {\n const components = {};\n lodash_1.default.each(row, (col, key) => {\n components[key] = col.render();\n });\n return components;\n });\n }\n getColumns() {\n return this.columns.filter((comp) => {\n return (!this.visibleColumns.hasOwnProperty(comp.key) || this.visibleColumns[comp.key]);\n });\n }\n hasHeader() {\n return this.component.components.reduce((hasHeader, col) => {\n // If any of the components has a title and it isn't hidden, display the header.\n return hasHeader || ((col.label || col.title) && !col.hideLabel);\n }, false);\n }\n loadRefs(element, refs) {\n super.loadRefs(element, refs);\n if (refs['messageContainer'] === 'single') {\n const container = lodash_1.default.last(element.querySelectorAll('[ref=messageContainer]'));\n this.refs['messageContainer'] = container || this.refs['messageContainer'];\n }\n }\n attach(element) {\n this.loadRefs(element, {\n [`${this.datagridKey}-row`]: 'multiple',\n [`${this.datagridKey}-tbody`]: 'single',\n [`${this.datagridKey}-addRow`]: 'multiple',\n [`${this.datagridKey}-removeRow`]: 'multiple',\n [`${this.datagridKey}-group-header`]: 'multiple',\n [this.datagridKey]: 'multiple',\n 'messageContainer': 'single'\n });\n if (this.allowReorder) {\n this.refs[`${this.datagridKey}-row`].forEach((row, index) => {\n row.dragInfo = { index };\n });\n if (dragula_1.default) {\n this.dragula = (0, dragula_1.default)([this.refs[`${this.datagridKey}-tbody`]], {\n moves: (_draggedElement, _oldParent, clickedElement) => {\n const clickedElementKey = clickedElement.getAttribute('data-key');\n const oldParentKey = _oldParent.getAttribute('data-key');\n //Check if the clicked button belongs to that container, if false, it belongs to the nested container\n if (oldParentKey === clickedElementKey) {\n return clickedElement.classList.contains('formio-drag-button');\n }\n }\n }).on('drop', this.onReorder.bind(this));\n this.dragula.on('cloned', (el, original) => {\n if (el && el.children && original && original.children) {\n lodash_1.default.each(original.children, (child, index) => {\n const styles = getComputedStyle(child, null);\n if (styles.cssText !== '') {\n el.children[index].style.cssText = styles.cssText;\n }\n else {\n const cssText = Object.values(styles).reduce((css, propertyName) => {\n return `${css}${propertyName}:${styles.getPropertyValue(propertyName)};`;\n }, '');\n el.children[index].style.cssText = cssText;\n }\n });\n }\n });\n }\n }\n this.refs[`${this.datagridKey}-addRow`].forEach((addButton) => {\n this.addEventListener(addButton, 'click', this.addRow.bind(this));\n });\n this.refs[`${this.datagridKey}-removeRow`].forEach((removeButton, index) => {\n this.addEventListener(removeButton, 'click', this.removeRow.bind(this, index));\n });\n if (this.hasRowGroups()) {\n this.refs.chunks = this.getRowChunks(this.getGroupSizes(), this.refs[`${this.datagridKey}-row`]);\n this.refs[`${this.datagridKey}-group-header`].forEach((header, index) => {\n this.addEventListener(header, 'click', () => this.toggleGroup(header, index));\n });\n }\n const columns = this.getColumns();\n const rowLength = columns.length;\n this.rows.forEach((row, rowIndex) => {\n let columnIndex = 0;\n columns.forEach((col) => {\n this.attachComponents(this.refs[this.datagridKey][(rowIndex * rowLength) + columnIndex], [this.rows[rowIndex][col.key]], this.getComponentsContainer());\n columnIndex++;\n });\n });\n return super.attach(element);\n }\n getComponentsContainer() {\n return this.component.components;\n }\n onReorder(element, _target, _source, sibling) {\n if (!element.dragInfo || (sibling && !sibling.dragInfo)) {\n console.warn('There is no Drag Info available for either dragged or sibling element');\n return;\n }\n const oldPosition = element.dragInfo.index;\n //should drop at next sibling position; no next sibling means drop to last position\n const newPosition = sibling ? sibling.dragInfo.index : this.dataValue.length;\n const movedBelow = newPosition > oldPosition;\n const dataValue = (0, utils_1.fastCloneDeep)(this.dataValue);\n const draggedRowData = dataValue[oldPosition];\n //insert element at new position\n dataValue.splice(newPosition, 0, draggedRowData);\n //remove element from old position (if was moved above, after insertion it's at +1 index)\n dataValue.splice(movedBelow ? oldPosition : oldPosition + 1, 1);\n //need to re-build rows to re-calculate indexes and other indexed fields for component instance (like rows for ex.)\n this.setValue(dataValue, { isReordered: true });\n this.rebuild();\n }\n focusOnNewRowElement(row) {\n Object.keys(row).find((key) => {\n const focusableElements = (0, utils_1.getFocusableElements)(row[key].element);\n if (focusableElements && focusableElements[0]) {\n focusableElements[0].focus();\n return true;\n }\n return false;\n });\n }\n addRow() {\n const index = this.rows.length;\n // Handle length mismatch between rows and dataValue\n if (this.dataValue.length === index) {\n this.dataValue.push({});\n }\n let row;\n const dataValue = this.dataValue;\n const defaultValue = this.defaultValue;\n if (this.initEmpty && defaultValue[index]) {\n row = defaultValue[index];\n dataValue[index] = row;\n }\n else {\n row = dataValue[index];\n }\n this.rows[index] = this.createRowComponents(row, index);\n this.emit('dataGridAddRow', {\n component: this.component,\n row\n });\n this.checkConditions();\n this.triggerChange();\n this.redraw().then(() => {\n this.focusOnNewRowElement(this.rows[index]);\n });\n }\n updateComponentsRowIndex(components, rowIndex) {\n components.forEach((component, colIndex) => {\n var _a;\n if ((_a = component.options) === null || _a === void 0 ? void 0 : _a.name) {\n const newName = `[${this.key}][${rowIndex}]`;\n component.options.name = component.options.name.replace(`[${this.key}][${component.rowIndex}]`, newName);\n }\n component.rowIndex = rowIndex;\n component.row = `${rowIndex}-${colIndex}`;\n component.path = this.calculateComponentPath(component);\n });\n }\n updateRowsComponents(rowIndex) {\n this.rows.slice(rowIndex).forEach((row, index) => {\n this.updateComponentsRowIndex(Object.values(row), rowIndex + index);\n });\n }\n removeRow(index) {\n this.splice(index, { isReordered: true });\n this.emit('dataGridDeleteRow', { index });\n const [row] = this.rows.splice(index, 1);\n this.removeRowComponents(row);\n this.updateRowsComponents(index);\n this.setValue(this.dataValue, { isReordered: true });\n this.redraw();\n }\n removeRowComponents(row) {\n lodash_1.default.each(row, (component) => this.removeComponent(component));\n }\n getRowValues() {\n return this.dataValue;\n }\n setRowComponentsData(rowIndex, rowData) {\n lodash_1.default.each(this.rows[rowIndex], (component) => {\n component.data = rowData;\n });\n }\n createRows(init, rebuild) {\n let added = false;\n const rowValues = this.getRowValues();\n // Create any missing rows.\n rowValues.forEach((row, index) => {\n if (!rebuild && this.rows[index]) {\n this.setRowComponentsData(index, row);\n }\n else {\n if (this.rows[index]) {\n this.removeRowComponents(this.rows[index]);\n }\n this.rows[index] = this.createRowComponents(row, index);\n added = true;\n }\n });\n // Delete any extra rows.\n const removedRows = this.rows.splice(rowValues.length);\n const removed = !!removedRows.length;\n // Delete components of extra rows (to make sure that this.components contain only components of exisiting rows)\n if (removed) {\n removedRows.forEach(row => this.removeRowComponents(row));\n }\n if (!init && (added || removed)) {\n this.redraw();\n }\n return added;\n }\n createRowComponents(row, rowIndex) {\n const components = {};\n this.tabIndex = 0;\n this.component.components.map((col, colIndex) => {\n const options = lodash_1.default.clone(this.options);\n options.name += `[${rowIndex}]`;\n options.row = `${rowIndex}-${colIndex}`;\n let columnComponent;\n if (this.builderMode) {\n col.id = col.id + rowIndex;\n columnComponent = col;\n }\n else {\n columnComponent = Object.assign(Object.assign({}, col), { id: (col.id + rowIndex) });\n }\n const component = this.createComponent(columnComponent, options, row);\n component.parentDisabled = !!this.disabled;\n component.rowIndex = rowIndex;\n component.inDataGrid = true;\n if (columnComponent.tabindex &&\n parseInt(columnComponent.tabindex) > this.tabIndex) {\n this.tabIndex = parseInt(columnComponent.tabindex);\n }\n components[col.key] = component;\n });\n return components;\n }\n /**\n * Checks the validity of this datagrid.\n *\n * @param data\n * @param dirty\n * @return {*}\n */\n checkValidity(data, dirty, row, silentCheck) {\n data = data || this.rootValue;\n row = row || this.data;\n if (!this.checkCondition(row, data)) {\n this.setCustomValidity('');\n return true;\n }\n if (!this.checkComponentValidity(data, dirty, row, { silentCheck })) {\n return false;\n }\n const isValid = this.checkRows('checkValidity', data, dirty, true, silentCheck);\n this.checkModal(isValid, dirty);\n return isValid;\n }\n checkColumns(data, flags = {}) {\n data = data || this.rootValue;\n let show = false;\n if (!this.rows || !this.rows.length) {\n return { rebuild: false, show: false };\n }\n if (this.builderMode) {\n return { rebuild: false, show: true };\n }\n const visibility = {};\n let logicRebuild = false;\n const dataValue = this.dataValue;\n this.rows.forEach((row, rowIndex) => {\n lodash_1.default.each(row, (col, key) => {\n if (col && (typeof col.checkConditions === 'function')) {\n const firstRowCheck = visibility[key] === undefined;\n visibility[key] = !!visibility[key] ||\n (col.checkConditions(data, flags, dataValue[rowIndex]) && col.type !== 'hidden');\n if (col.component.logic && firstRowCheck) {\n const compIndex = lodash_1.default.findIndex(this.columns, ['key', key]);\n if (!lodash_1.default.isEqual(this.columns[compIndex], col.component)) {\n logicRebuild = true;\n this.columns[compIndex] = col.component;\n }\n }\n }\n });\n });\n const rebuild = !lodash_1.default.isEqual(visibility, this.visibleColumns) || logicRebuild;\n lodash_1.default.each(visibility, (col) => {\n show |= col;\n });\n this.visibleColumns = visibility;\n return { rebuild, show };\n }\n checkComponentConditions(data, flags, row) {\n const isVisible = this.visible;\n // If table isn't visible, don't bother calculating columns.\n if (!super.checkComponentConditions(data, flags, row)) {\n return false;\n }\n const { rebuild, show } = this.checkColumns(data, flags);\n // Check if a rebuild is needed or the visibility changes.\n if (rebuild || !isVisible) {\n this.createRows(false, rebuild);\n }\n // Return if this table should show.\n return show;\n }\n setValue(value, flags = {}) {\n if (!value) {\n this.dataValue = this.defaultValue;\n this.createRows();\n return false;\n }\n if (!Array.isArray(value)) {\n if (typeof value === 'object') {\n value = [value];\n }\n else {\n this.createRows();\n value = [{}];\n }\n }\n // Make sure we always have at least one row.\n // NOTE: Removing this will break \"Public Configurations\" in portal. ;)\n if (value && !value.length && !this.initEmpty) {\n value.push({});\n }\n const isSettingSubmission = flags.fromSubmission && !lodash_1.default.isEqual(value, this.emptyValue);\n const changed = this.hasChanged(value, this.dataValue);\n this.dataValue = value;\n if (this.initRows || isSettingSubmission) {\n if (!this.createRows() && changed) {\n this.redraw();\n }\n }\n if (this.componentModal && isSettingSubmission) {\n this.componentModal.setValue(value);\n }\n this.rows.forEach((row, rowIndex) => {\n if (value.length <= rowIndex) {\n return;\n }\n lodash_1.default.each(row, (col) => {\n col.rowIndex = rowIndex;\n this.setNestedValue(col, value[rowIndex], flags);\n });\n });\n this.updateOnChange(flags, changed);\n return changed;\n }\n restoreComponentsContext() {\n this.rows.forEach((row, index) => lodash_1.default.forIn(row, (component) => component.data = this.dataValue[index]));\n }\n getComponent(path, fn) {\n path = Array.isArray(path) ? path : [path];\n const [key, ...remainingPath] = path;\n let result = [];\n if (lodash_1.default.isNumber(key) && remainingPath.length) {\n const compKey = remainingPath.pop();\n result = this.rows[key][compKey];\n // If the component is inside a Layout Component, try to find it among all the row's components\n if (!result) {\n Object.entries(this.rows[key]).forEach(([, comp]) => {\n if ('getComponent' in comp) {\n const possibleResult = comp.getComponent([compKey], fn);\n if (possibleResult) {\n result = possibleResult;\n }\n }\n });\n }\n if (result && lodash_1.default.isFunction(fn)) {\n fn(result, this.getComponents());\n }\n if (remainingPath.length && 'getComponent' in result) {\n return result.getComponent(remainingPath, fn);\n }\n return result;\n }\n if (!lodash_1.default.isString(key)) {\n return result;\n }\n this.everyComponent((component, components) => {\n if (component.component.key === key) {\n let comp = component;\n if (remainingPath.length > 0 && 'getComponent' in component) {\n comp = component.getComponent(remainingPath, fn);\n }\n else if (fn) {\n fn(component, components);\n }\n result = result.concat(comp);\n }\n });\n return result.length > 0 ? result : null;\n }\n toggleGroup(element, index) {\n element.classList.toggle('collapsed');\n lodash_1.default.each(this.refs.chunks[index], row => {\n row.classList.toggle('hidden');\n });\n }\n}\nexports[\"default\"] = DataGridComponent;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/components/datagrid/DataGrid.js?");
5976
+ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst lodash_1 = __importDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nconst NestedArrayComponent_1 = __importDefault(__webpack_require__(/*! ../_classes/nestedarray/NestedArrayComponent */ \"./lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js\"));\nconst utils_1 = __webpack_require__(/*! ../../utils/utils */ \"./lib/cjs/utils/utils.js\");\nclass DataGridComponent extends NestedArrayComponent_1.default {\n static schema(...extend) {\n return NestedArrayComponent_1.default.schema({\n label: 'Data Grid',\n key: 'dataGrid',\n type: 'datagrid',\n clearOnHide: true,\n input: true,\n tree: true,\n components: []\n }, ...extend);\n }\n static get builderInfo() {\n return {\n title: 'Data Grid',\n icon: 'th',\n group: 'data',\n documentation: '/userguide/form-building/data-components#data-grid',\n weight: 30,\n schema: DataGridComponent.schema()\n };\n }\n constructor(...args) {\n super(...args);\n this.type = 'datagrid';\n this.tabIndex = 0;\n }\n init() {\n this.components = this.components || [];\n // Add new values based on minLength.\n this.rows = [];\n this.columns = [...this.component.components];\n if (this.initRows || !lodash_1.default.isEqual(this.dataValue, this.emptyValue)) {\n this.createRows(true);\n }\n this.visibleColumns = {};\n this.prevHasAddButton = this.hasAddButton();\n this.checkColumns();\n }\n get dataValue() {\n const dataValue = super.dataValue;\n if (!dataValue || !Array.isArray(dataValue)) {\n return this.emptyValue;\n }\n return dataValue;\n }\n set dataValue(value) {\n super.dataValue = value;\n }\n get defaultSchema() {\n return DataGridComponent.schema();\n }\n get initEmpty() {\n return this.component.initEmpty || this.component.noFirstRow;\n }\n get initRows() {\n return this.builderMode || this.path === 'defaultValue' || !this.initEmpty;\n }\n get emptyValue() {\n return this.initEmpty ? [] : [{}];\n }\n get addAnotherPosition() {\n return lodash_1.default.get(this.component, 'addAnotherPosition', 'bottom');\n }\n get minLength() {\n if (this.hasRowGroups()) {\n return lodash_1.default.sum(this.getGroupSizes());\n }\n else {\n return lodash_1.default.get(this.component, 'validate.minLength', 0);\n }\n }\n get defaultValue() {\n const isBuilderMode = this.builderMode;\n const isEmptyInit = this.initEmpty;\n // Ensure we have one and only one row in builder mode.\n if (isBuilderMode || (isEmptyInit && !this.dataValue.length)) {\n return isEmptyInit && !isBuilderMode ? [] : [{}];\n }\n const value = super.defaultValue;\n let defaultValue;\n if (Array.isArray(value)) {\n defaultValue = value;\n }\n else if (value && (typeof value === 'object')) {\n defaultValue = [value];\n }\n else {\n defaultValue = this.emptyValue;\n }\n for (let dIndex = defaultValue.length; dIndex < this.minLength; dIndex++) {\n defaultValue.push({});\n }\n return defaultValue;\n }\n set disabled(disabled) {\n super.disabled = disabled;\n lodash_1.default.each(this.refs[`${this.datagridKey}-addRow`], (button) => {\n button.disabled = disabled;\n });\n lodash_1.default.each(this.refs[`${this.datagridKey}-removeRow`], (button) => {\n button.disabled = disabled;\n });\n }\n get disabled() {\n return super.disabled;\n }\n get datagridKey() {\n return `datagrid-${this.key}`;\n }\n get allowReorder() {\n return !this.options.readOnly && lodash_1.default.get(this.component, 'reorder', false);\n }\n get iteratableRows() {\n return this.rows.map((row, index) => ({\n components: row,\n data: this.dataValue[index],\n }));\n }\n /**\n * Split rows into chunks.\n * @param {Number[]} groups - array of numbers where each item is size of group\n * @param {Array<T>} rows - rows collection\n * @return {Array<T[]>}\n */\n getRowChunks(groups, rows) {\n const [, chunks] = groups.reduce(([startIndex, acc], size) => {\n const endIndex = startIndex + size;\n return [endIndex, [...acc, [startIndex, endIndex]]];\n }, [0, []]);\n return chunks.map(range => lodash_1.default.slice(rows, ...range));\n }\n /**\n * Create groups object.\n * Each key in object represents index of first row in group.\n * @return {Object}\n */\n getGroups() {\n const groups = lodash_1.default.get(this.component, 'rowGroups', []);\n const sizes = lodash_1.default.map(groups, 'numberOfRows').slice(0, -1);\n const indexes = sizes.reduce((groupIndexes, size) => {\n const last = groupIndexes[groupIndexes.length - 1];\n return groupIndexes.concat(last + size);\n }, [0]);\n return groups.reduce((gidxs, group, idx) => {\n return Object.assign(Object.assign({}, gidxs), { [indexes[idx]]: group });\n }, {});\n }\n /**\n * Retrun group sizes.\n * @return {Number[]}\n */\n getGroupSizes() {\n return lodash_1.default.map(lodash_1.default.get(this.component, 'rowGroups', []), 'numberOfRows');\n }\n hasRowGroups() {\n return lodash_1.default.get(this, 'component.enableRowGroups', false) && !this.builderMode;\n }\n totalRowsNumber(groups) {\n return lodash_1.default.sum(lodash_1.default.map(groups, 'numberOfRows'));\n }\n setStaticValue(n) {\n this.dataValue = lodash_1.default.range(n).map(() => ({}));\n }\n hasExtraColumn() {\n return (this.hasRemoveButtons() || this.canAddColumn);\n }\n hasRemoveButtons() {\n return !this.builderMode && !this.component.disableAddingRemovingRows &&\n !this.options.readOnly &&\n !this.disabled &&\n this.fullMode &&\n (this.dataValue.length > lodash_1.default.get(this.component, 'validate.minLength', 0));\n }\n hasTopSubmit() {\n return this.hasAddButton() && ['top', 'both'].includes(this.addAnotherPosition);\n }\n hasBottomSubmit() {\n return this.hasAddButton() && ['bottom', 'both'].includes(this.addAnotherPosition);\n }\n get canAddColumn() {\n return this.builderMode;\n }\n render() {\n const columns = this.getColumns();\n let columnExtra = 0;\n const hasRemoveButtons = this.hasRemoveButtons();\n if (this.component.reorder) {\n columnExtra++;\n }\n if (hasRemoveButtons) {\n columnExtra++;\n }\n if (this.canAddColumn) {\n columnExtra++;\n }\n const colWidth = Math.floor(12 / (columns.length + columnExtra));\n return super.render(this.renderTemplate('datagrid', {\n rows: this.getRows(),\n columns: columns,\n groups: this.hasRowGroups() ? this.getGroups() : [],\n visibleColumns: this.visibleColumns,\n hasToggle: lodash_1.default.get(this, 'component.groupToggle', false),\n hasHeader: this.hasHeader(),\n hasExtraColumn: this.hasExtraColumn(),\n hasAddButton: this.hasAddButton(),\n hasRemoveButtons,\n hasTopSubmit: this.hasTopSubmit(),\n hasBottomSubmit: this.hasBottomSubmit(),\n hasGroups: this.hasRowGroups(),\n numColumns: columns.length + (this.hasExtraColumn() ? 1 : 0),\n datagridKey: this.datagridKey,\n allowReorder: this.allowReorder,\n builder: this.builderMode,\n canAddColumn: this.canAddColumn,\n tabIndex: this.tabIndex,\n placeholder: this.renderTemplate('builderPlaceholder', {\n position: this.componentComponents.length,\n }),\n colWidth: colWidth.toString()\n }));\n }\n getRows() {\n return this.rows.map(row => {\n const components = {};\n lodash_1.default.each(row, (col, key) => {\n components[key] = col.render();\n });\n return components;\n });\n }\n getColumns() {\n return this.columns.filter((comp) => {\n return (!this.visibleColumns.hasOwnProperty(comp.key) || this.visibleColumns[comp.key]);\n });\n }\n hasHeader() {\n return this.component.components.reduce((hasHeader, col) => {\n // If any of the components has a title and it isn't hidden, display the header.\n return hasHeader || ((col.label || col.title) && !col.hideLabel);\n }, false);\n }\n loadRefs(element, refs) {\n super.loadRefs(element, refs);\n if (refs['messageContainer'] === 'single') {\n const container = lodash_1.default.last(element.querySelectorAll('[ref=messageContainer]'));\n this.refs['messageContainer'] = container || this.refs['messageContainer'];\n }\n }\n attach(element) {\n this.loadRefs(element, {\n [`${this.datagridKey}-row`]: 'multiple',\n [`${this.datagridKey}-tbody`]: 'single',\n [`${this.datagridKey}-addRow`]: 'multiple',\n [`${this.datagridKey}-removeRow`]: 'multiple',\n [`${this.datagridKey}-group-header`]: 'multiple',\n [this.datagridKey]: 'multiple',\n 'messageContainer': 'single'\n });\n if (this.allowReorder) {\n this.refs[`${this.datagridKey}-row`].forEach((row, index) => {\n row.dragInfo = { index };\n });\n if (this.root.dragulaLib) {\n this.dragula = this.root.dragulaLib([this.refs[`${this.datagridKey}-tbody`]], {\n moves: (_draggedElement, _oldParent, clickedElement) => {\n const clickedElementKey = clickedElement.getAttribute('data-key');\n const oldParentKey = _oldParent.getAttribute('data-key');\n //Check if the clicked button belongs to that container, if false, it belongs to the nested container\n if (oldParentKey === clickedElementKey) {\n return clickedElement.classList.contains('formio-drag-button');\n }\n }\n }).on('drop', this.onReorder.bind(this));\n this.dragula.on('cloned', (el, original) => {\n if (el && el.children && original && original.children) {\n lodash_1.default.each(original.children, (child, index) => {\n const styles = getComputedStyle(child, null);\n if (styles.cssText !== '') {\n el.children[index].style.cssText = styles.cssText;\n }\n else {\n const cssText = Object.values(styles).reduce((css, propertyName) => {\n return `${css}${propertyName}:${styles.getPropertyValue(propertyName)};`;\n }, '');\n el.children[index].style.cssText = cssText;\n }\n });\n }\n });\n }\n }\n this.refs[`${this.datagridKey}-addRow`].forEach((addButton) => {\n this.addEventListener(addButton, 'click', this.addRow.bind(this));\n });\n this.refs[`${this.datagridKey}-removeRow`].forEach((removeButton, index) => {\n this.addEventListener(removeButton, 'click', this.removeRow.bind(this, index));\n });\n if (this.hasRowGroups()) {\n this.refs.chunks = this.getRowChunks(this.getGroupSizes(), this.refs[`${this.datagridKey}-row`]);\n this.refs[`${this.datagridKey}-group-header`].forEach((header, index) => {\n this.addEventListener(header, 'click', () => this.toggleGroup(header, index));\n });\n }\n const columns = this.getColumns();\n const rowLength = columns.length;\n this.rows.forEach((row, rowIndex) => {\n let columnIndex = 0;\n columns.forEach((col) => {\n this.attachComponents(this.refs[this.datagridKey][(rowIndex * rowLength) + columnIndex], [this.rows[rowIndex][col.key]], this.getComponentsContainer());\n columnIndex++;\n });\n });\n return super.attach(element);\n }\n getComponentsContainer() {\n return this.component.components;\n }\n onReorder(element, _target, _source, sibling) {\n if (!element.dragInfo || (sibling && !sibling.dragInfo)) {\n console.warn('There is no Drag Info available for either dragged or sibling element');\n return;\n }\n const oldPosition = element.dragInfo.index;\n //should drop at next sibling position; no next sibling means drop to last position\n const newPosition = sibling ? sibling.dragInfo.index : this.dataValue.length;\n const movedBelow = newPosition > oldPosition;\n const dataValue = (0, utils_1.fastCloneDeep)(this.dataValue);\n const draggedRowData = dataValue[oldPosition];\n //insert element at new position\n dataValue.splice(newPosition, 0, draggedRowData);\n //remove element from old position (if was moved above, after insertion it's at +1 index)\n dataValue.splice(movedBelow ? oldPosition : oldPosition + 1, 1);\n //need to re-build rows to re-calculate indexes and other indexed fields for component instance (like rows for ex.)\n this.setValue(dataValue, { isReordered: true });\n this.rebuild();\n }\n focusOnNewRowElement(row) {\n Object.keys(row).find((key) => {\n const focusableElements = (0, utils_1.getFocusableElements)(row[key].element);\n if (focusableElements && focusableElements[0]) {\n focusableElements[0].focus();\n return true;\n }\n return false;\n });\n }\n addRow() {\n const index = this.rows.length;\n // Handle length mismatch between rows and dataValue\n if (this.dataValue.length === index) {\n this.dataValue.push({});\n }\n let row;\n const dataValue = this.dataValue;\n const defaultValue = this.defaultValue;\n if (this.initEmpty && defaultValue[index]) {\n row = defaultValue[index];\n dataValue[index] = row;\n }\n else {\n row = dataValue[index];\n }\n this.rows[index] = this.createRowComponents(row, index);\n this.emit('dataGridAddRow', {\n component: this.component,\n row\n });\n this.checkConditions();\n this.triggerChange();\n this.redraw().then(() => {\n this.focusOnNewRowElement(this.rows[index]);\n });\n }\n updateComponentsRowIndex(components, rowIndex) {\n components.forEach((component, colIndex) => {\n var _a;\n if ((_a = component.options) === null || _a === void 0 ? void 0 : _a.name) {\n const newName = `[${this.key}][${rowIndex}]`;\n component.options.name = component.options.name.replace(`[${this.key}][${component.rowIndex}]`, newName);\n }\n component.rowIndex = rowIndex;\n component.row = `${rowIndex}-${colIndex}`;\n component.path = this.calculateComponentPath(component);\n });\n }\n updateRowsComponents(rowIndex) {\n this.rows.slice(rowIndex).forEach((row, index) => {\n this.updateComponentsRowIndex(Object.values(row), rowIndex + index);\n });\n }\n removeRow(index) {\n this.splice(index, { isReordered: true });\n this.emit('dataGridDeleteRow', { index });\n const [row] = this.rows.splice(index, 1);\n this.removeRowComponents(row);\n this.updateRowsComponents(index);\n this.setValue(this.dataValue, { isReordered: true });\n this.redraw();\n }\n removeRowComponents(row) {\n lodash_1.default.each(row, (component) => this.removeComponent(component));\n }\n getRowValues() {\n return this.dataValue;\n }\n setRowComponentsData(rowIndex, rowData) {\n lodash_1.default.each(this.rows[rowIndex], (component) => {\n component.data = rowData;\n });\n }\n createRows(init, rebuild) {\n let added = false;\n const rowValues = this.getRowValues();\n // Create any missing rows.\n rowValues.forEach((row, index) => {\n if (!rebuild && this.rows[index]) {\n this.setRowComponentsData(index, row);\n }\n else {\n if (this.rows[index]) {\n this.removeRowComponents(this.rows[index]);\n }\n this.rows[index] = this.createRowComponents(row, index);\n added = true;\n }\n });\n // Delete any extra rows.\n const removedRows = this.rows.splice(rowValues.length);\n const removed = !!removedRows.length;\n // Delete components of extra rows (to make sure that this.components contain only components of exisiting rows)\n if (removed) {\n removedRows.forEach(row => this.removeRowComponents(row));\n }\n if (!init && (added || removed)) {\n this.redraw();\n }\n return added;\n }\n createRowComponents(row, rowIndex) {\n const components = {};\n this.tabIndex = 0;\n this.component.components.map((col, colIndex) => {\n const options = lodash_1.default.clone(this.options);\n options.name += `[${rowIndex}]`;\n options.row = `${rowIndex}-${colIndex}`;\n let columnComponent;\n if (this.builderMode) {\n col.id = col.id + rowIndex;\n columnComponent = col;\n }\n else {\n columnComponent = Object.assign(Object.assign({}, col), { id: (col.id + rowIndex) });\n }\n const component = this.createComponent(columnComponent, options, row);\n component.parentDisabled = !!this.disabled;\n component.rowIndex = rowIndex;\n component.inDataGrid = true;\n if (columnComponent.tabindex &&\n parseInt(columnComponent.tabindex) > this.tabIndex) {\n this.tabIndex = parseInt(columnComponent.tabindex);\n }\n components[col.key] = component;\n });\n return components;\n }\n /**\n * Checks the validity of this datagrid.\n *\n * @param data\n * @param dirty\n * @return {*}\n */\n checkValidity(data, dirty, row, silentCheck) {\n data = data || this.rootValue;\n row = row || this.data;\n if (!this.checkCondition(row, data)) {\n this.setCustomValidity('');\n return true;\n }\n if (!this.checkComponentValidity(data, dirty, row, { silentCheck })) {\n return false;\n }\n const isValid = this.checkRows('checkValidity', data, dirty, true, silentCheck);\n this.checkModal(isValid, dirty);\n return isValid;\n }\n checkColumns(data, flags = {}) {\n data = data || this.rootValue;\n let show = false;\n if (!this.rows || !this.rows.length) {\n return { rebuild: false, show: false };\n }\n if (this.builderMode) {\n return { rebuild: false, show: true };\n }\n const visibility = {};\n let logicRebuild = false;\n const dataValue = this.dataValue;\n this.rows.forEach((row, rowIndex) => {\n lodash_1.default.each(row, (col, key) => {\n if (col && (typeof col.checkConditions === 'function')) {\n const firstRowCheck = visibility[key] === undefined;\n visibility[key] = !!visibility[key] ||\n (col.checkConditions(data, flags, dataValue[rowIndex]) && col.type !== 'hidden');\n if (col.component.logic && firstRowCheck) {\n const compIndex = lodash_1.default.findIndex(this.columns, ['key', key]);\n if (!lodash_1.default.isEqual(this.columns[compIndex], col.component)) {\n logicRebuild = true;\n this.columns[compIndex] = col.component;\n }\n }\n }\n });\n });\n const rebuild = !lodash_1.default.isEqual(visibility, this.visibleColumns) || logicRebuild;\n lodash_1.default.each(visibility, (col) => {\n show |= col;\n });\n this.visibleColumns = visibility;\n return { rebuild, show };\n }\n checkComponentConditions(data, flags, row) {\n const isVisible = this.visible;\n // If table isn't visible, don't bother calculating columns.\n if (!super.checkComponentConditions(data, flags, row)) {\n return false;\n }\n const { rebuild, show } = this.checkColumns(data, flags);\n // Check if a rebuild is needed or the visibility changes.\n if (rebuild || !isVisible) {\n this.createRows(false, rebuild);\n }\n // Return if this table should show.\n return show;\n }\n setValue(value, flags = {}) {\n if (!value) {\n this.dataValue = this.defaultValue;\n this.createRows();\n return false;\n }\n if (!Array.isArray(value)) {\n if (typeof value === 'object') {\n value = [value];\n }\n else {\n this.createRows();\n value = [{}];\n }\n }\n // Make sure we always have at least one row.\n // NOTE: Removing this will break \"Public Configurations\" in portal. ;)\n if (value && !value.length && !this.initEmpty) {\n value.push({});\n }\n const isSettingSubmission = flags.fromSubmission && !lodash_1.default.isEqual(value, this.emptyValue);\n const changed = this.hasChanged(value, this.dataValue);\n this.dataValue = value;\n if (this.initRows || isSettingSubmission) {\n if (!this.createRows() && changed) {\n this.redraw();\n }\n }\n if (this.componentModal && isSettingSubmission) {\n this.componentModal.setValue(value);\n }\n this.rows.forEach((row, rowIndex) => {\n if (value.length <= rowIndex) {\n return;\n }\n lodash_1.default.each(row, (col) => {\n col.rowIndex = rowIndex;\n this.setNestedValue(col, value[rowIndex], flags);\n });\n });\n this.updateOnChange(flags, changed);\n return changed;\n }\n restoreComponentsContext() {\n this.rows.forEach((row, index) => lodash_1.default.forIn(row, (component) => component.data = this.dataValue[index]));\n }\n getComponent(path, fn) {\n path = Array.isArray(path) ? path : [path];\n const [key, ...remainingPath] = path;\n let result = [];\n if (lodash_1.default.isNumber(key) && remainingPath.length) {\n const compKey = remainingPath.pop();\n result = this.rows[key][compKey];\n // If the component is inside a Layout Component, try to find it among all the row's components\n if (!result) {\n Object.entries(this.rows[key]).forEach(([, comp]) => {\n if ('getComponent' in comp) {\n const possibleResult = comp.getComponent([compKey], fn);\n if (possibleResult) {\n result = possibleResult;\n }\n }\n });\n }\n if (result && lodash_1.default.isFunction(fn)) {\n fn(result, this.getComponents());\n }\n if (remainingPath.length && 'getComponent' in result) {\n return result.getComponent(remainingPath, fn);\n }\n return result;\n }\n if (!lodash_1.default.isString(key)) {\n return result;\n }\n this.everyComponent((component, components) => {\n if (component.component.key === key) {\n let comp = component;\n if (remainingPath.length > 0 && 'getComponent' in component) {\n comp = component.getComponent(remainingPath, fn);\n }\n else if (fn) {\n fn(component, components);\n }\n result = result.concat(comp);\n }\n });\n return result.length > 0 ? result : null;\n }\n toggleGroup(element, index) {\n element.classList.toggle('collapsed');\n lodash_1.default.each(this.refs.chunks[index], row => {\n row.classList.toggle('hidden');\n });\n }\n}\nexports[\"default\"] = DataGridComponent;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/components/datagrid/DataGrid.js?");
5977
5977
 
5978
5978
  /***/ }),
5979
5979
 
@@ -7766,7 +7766,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
7766
7766
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
7767
7767
 
7768
7768
  "use strict";
7769
- eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst index_1 = __importDefault(__webpack_require__(/*! ./index */ \"./lib/cjs/templates/index.js\"));\nconst lodash_1 = __importDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nclass Templates {\n static get templates() {\n if (!Templates._templates) {\n Templates._templates = index_1.default;\n }\n return Templates._templates;\n }\n static addTemplate(name, template) {\n Templates.templates[name] = template;\n }\n static extendTemplate(name, template) {\n Templates.templates[name] = lodash_1.default.merge({}, Templates.templates[name], template);\n }\n static setTemplate(name, template) {\n Templates.addTemplate(name, template);\n }\n static set current(templates) {\n const defaultTemplates = Templates.current;\n Templates._current = lodash_1.default.merge({}, defaultTemplates, templates);\n }\n static get current() {\n if (Templates._current) {\n return Templates._current;\n }\n return Templates.defaultTemplates;\n }\n static get defaultTemplates() {\n return Templates.templates.bootstrap;\n }\n static set framework(framework) {\n if (Templates.templates.hasOwnProperty(framework)) {\n Templates._framework = framework;\n Templates._current = Templates.templates[framework];\n }\n }\n static get framework() {\n return Templates._framework;\n }\n}\nexports[\"default\"] = Templates;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/templates/Templates.js?");
7769
+ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst lodash_1 = __importDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nclass Templates {\n static get templates() {\n return Templates._templates;\n }\n static addTemplate(name, template) {\n Templates.templates[name] = template;\n }\n static extendTemplate(name, template) {\n Templates.templates[name] = lodash_1.default.merge({}, Templates.templates[name], template);\n }\n static setTemplate(name, template) {\n Templates.addTemplate(name, template);\n }\n static set current(templates) {\n const defaultTemplates = Templates.current;\n Templates._current = lodash_1.default.merge({}, defaultTemplates, templates);\n }\n static get current() {\n if (Templates._current) {\n return Templates._current;\n }\n return Templates.defaultTemplates;\n }\n static get defaultTemplates() {\n return Templates.templates.hasOwnProperty('bootstrap') ? Templates.templates.bootstrap : {};\n }\n static set framework(framework) {\n if (Templates.templates.hasOwnProperty(framework)) {\n Templates._framework = framework;\n Templates._current = Templates.templates[framework];\n }\n }\n static get framework() {\n return Templates._framework;\n }\n}\nexports[\"default\"] = Templates;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/templates/Templates.js?");
7770
7770
 
7771
7771
  /***/ }),
7772
7772