{"version":3,"file":"iife-Editor.js","sources":["../../node_modules/.pnpm/i18next@23.7.8/node_modules/i18next/dist/esm/i18next.js","../../src/editor/locale.js","../../src/editor/components/seButton.js","../../src/editor/components/seFlyingButton.js","../../src/editor/components/seExplorerButton.js","../../src/editor/components/seZoom.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/core/htmlLiterals.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/core/internal.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/core/AttributeMarshallingMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/core/ReactiveMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/core/ShadowTemplateMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/core/ReactiveElement.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/internal.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/DelegateInputLabelMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/core/dom.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/FocusVisibleMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/FormElementMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/TrackTextSelectionMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/DelegateFocusMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/WrappedStandardElement.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/Input.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/plain/PlainInputMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/plain/PlainInput.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/define/Input.js","../../src/editor/components/seInput.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/ComposedFocusMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/Button.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/RepeatMousedownMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/RepeatButton.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/plain/PlainButtonMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/plain/PlainRepeatButton.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/plain/PlainSpinBoxMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/core/template.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/DelegateInputSelectionMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/DisabledMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/KeyboardDirectionMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/KeyboardMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/SpinBox.js","../../src/editor/dialogs/se-elix/src/base/NumberSpinBox.js","../../src/editor/dialogs/se-elix/src/plain/PlainNumberSpinBox.js","../../src/editor/dialogs/se-elix/define/NumberSpinBox.js","../../src/editor/components/seSpinInput.js","../../src/editor/components/sePalette.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/CurrentMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/SelectableMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/MenuItem.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/plain/PlainMenuItem.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/define/MenuItem.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/accessibility.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/AriaMenuMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/CursorAPIMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/scrolling.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/CursorInViewMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/DirectionCursorMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/ItemsAPIMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/ItemsCursorMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/content.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/ItemsTextMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/KeyboardPagedCursorMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/constants.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/KeyboardPrefixCursorMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/LanguageDirectionMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/ContentItemsMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/SlotContentMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/SlotItemsMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/TapCursorMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/Menu.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/PopupDragSelectMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/layoutPopup.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/OpenCloseMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/AriaRoleMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/Backdrop.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/OverlayFrame.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/OverlayMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/Overlay.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/PopupModalityMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/Popup.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/PopupSource.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/PopupButton.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/PopupListMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/MenuButton.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/UpDownToggle.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/PopupToggleMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/plain/PlainButton.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/plain/PlainBorderButton.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/plain/PlainMenu.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/plain/PlainOpenCloseToggle.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/plain/PlainBackdrop.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/plain/PlainOverlayFrame.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/plain/PlainPopup.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/plain/PlainMenuButton.js","../../src/editor/components/sePlainBorderButton.js","../../src/editor/components/sePlainMenuButton.js","../../src/editor/components/seMenu.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/define/Menu.js","../../src/editor/components/seMenuItem.js","../../src/editor/components/seList.js","../../src/editor/components/seListItem.js","../../packages/svgcanvas/dist/svgcanvas.js","../../src/editor/components/jgraduate/ColorValuePicker.js","../../packages/svgcanvas/common/util.js","../../src/editor/components/jgraduate/Slider.js","../../src/editor/components/jgraduate/jQuery.jPicker.js","../../src/editor/components/jgraduate/jQuery.jGraduate.js","../../src/editor/components/PaintBox.js","../../src/editor/components/seColorPicker.js","../../src/editor/components/seSelect.js","../../src/editor/components/seText.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/DialogModalityMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/FocusCaptureMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/ModalBackdrop.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/Dialog.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/plain/PlainModalBackdrop.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/plain/PlainModalOverlayMixin.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/plain/PlainDialog.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/define/Dialog.js","../../src/editor/dialogs/imagePropertiesDialog.js","../../src/editor/dialogs/editorPreferencesDialog.js","../../src/editor/dialogs/svgSourceDialog.js","../../src/editor/dialogs/cmenuDialog.js","../../src/editor/dialogs/cmenuLayersDialog.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/base/AlertDialog.js","../../node_modules/.pnpm/elix@15.0.1/node_modules/elix/src/plain/PlainAlertDialog.js","../../src/editor/dialogs/SePlainAlertDialog.js","../../src/editor/dialogs/seSelectDialog.js","../../src/editor/dialogs/seConfirmDialog.js","../../src/editor/dialogs/sePromptDialog.js","../../src/editor/dialogs/seAlertDialog.js","../../src/editor/dialogs/exportDialog.js","../../packages/svgcanvas/common/browser.js","../../src/editor/ConfigObj.js","../../src/editor/contextmenu.js","../../src/editor/Rulers.js","../../src/editor/EditorStartup.js","../../src/editor/panels/LeftPanel.js","../../src/editor/panels/TopPanel.js","../../src/editor/panels/BottomPanel.js","../../src/editor/panels/LayersPanel.js","../../src/editor/MainMenu.js","../../src/editor/Editor.js","../../src/editor/locale/lang.af.js","../../src/editor/locale/lang.ar.js","../../src/editor/locale/lang.az.js","../../src/editor/locale/lang.be.js","../../src/editor/locale/lang.bg.js","../../src/editor/locale/lang.ca.js","../../src/editor/locale/lang.cs.js","../../src/editor/locale/lang.cy.js","../../src/editor/locale/lang.da.js","../../src/editor/locale/lang.de.js","../../src/editor/locale/lang.el.js","../../src/editor/locale/lang.en.js","../../src/editor/locale/lang.es.js","../../src/editor/locale/lang.et.js","../../src/editor/locale/lang.fa.js","../../src/editor/locale/lang.fi.js","../../src/editor/locale/lang.fr.js","../../src/editor/locale/lang.fy.js","../../src/editor/locale/lang.ga.js","../../src/editor/locale/lang.gl.js","../../src/editor/locale/lang.he.js","../../src/editor/locale/lang.hi.js","../../src/editor/locale/lang.hr.js","../../src/editor/locale/lang.hu.js","../../src/editor/locale/lang.hy.js","../../src/editor/locale/lang.id.js","../../src/editor/locale/lang.is.js","../../src/editor/locale/lang.it.js","../../src/editor/locale/lang.ja.js","../../src/editor/locale/lang.ko.js","../../src/editor/locale/lang.lt.js","../../src/editor/locale/lang.lv.js","../../src/editor/locale/lang.mk.js","../../src/editor/locale/lang.ms.js","../../src/editor/locale/lang.mt.js","../../src/editor/locale/lang.nl.js","../../src/editor/locale/lang.no.js","../../src/editor/locale/lang.pl.js","../../src/editor/locale/lang.pt-BR.js","../../src/editor/locale/lang.pt-PT.js","../../src/editor/locale/lang.ro.js","../../src/editor/locale/lang.ru.js","../../src/editor/locale/lang.sk.js","../../src/editor/locale/lang.sl.js","../../src/editor/locale/lang.sq.js","../../src/editor/locale/lang.sr.js","../../src/editor/locale/lang.sv.js","../../src/editor/locale/lang.sw.js","../../src/editor/locale/lang.test.js","../../src/editor/locale/lang.th.js","../../src/editor/locale/lang.tl.js","../../src/editor/locale/lang.tr.js","../../src/editor/locale/lang.uk.js","../../src/editor/locale/lang.vi.js","../../src/editor/locale/lang.yi.js","../../src/editor/locale/lang.zh-CN.js","../../src/editor/locale/lang.zh-HK.js","../../src/editor/locale/lang.zh-TW.js"],"sourcesContent":["const consoleLogger = {\n type: 'logger',\n log(args) {\n this.output('log', args);\n },\n warn(args) {\n this.output('warn', args);\n },\n error(args) {\n this.output('error', args);\n },\n output(type, args) {\n if (console && console[type]) console[type].apply(console, args);\n }\n};\nclass Logger {\n constructor(concreteLogger) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n this.init(concreteLogger, options);\n }\n init(concreteLogger) {\n let 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 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 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 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 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 forward(args, lvl, prefix, debugOnly) {\n if (debugOnly && !this.debug) return null;\n if (typeof args[0] === 'string') args[0] = `${prefix}${this.prefix} ${args[0]}`;\n return this.logger[lvl](args);\n }\n create(moduleName) {\n return new Logger(this.logger, {\n ...{\n prefix: `${this.prefix}:${moduleName}:`\n },\n ...this.options\n });\n }\n clone(options) {\n options = options || this.options;\n options.prefix = options.prefix || this.prefix;\n return new Logger(this.logger, options);\n }\n}\nvar baseLogger = new Logger();\n\nclass EventEmitter {\n constructor() {\n this.observers = {};\n }\n on(events, listener) {\n events.split(' ').forEach(event => {\n this.observers[event] = this.observers[event] || [];\n this.observers[event].push(listener);\n });\n return this;\n }\n 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(l => l !== listener);\n }\n 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 const cloned = [].concat(this.observers[event]);\n cloned.forEach(observer => {\n observer(...args);\n });\n }\n if (this.observers['*']) {\n const cloned = [].concat(this.observers['*']);\n cloned.forEach(observer => {\n observer.apply(observer, [event, ...args]);\n });\n }\n }\n}\n\nfunction defer() {\n let res;\n let rej;\n const promise = new Promise((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(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 const stack = typeof path !== 'string' ? [].concat(path) : path.split('.');\n while (stack.length > 1) {\n if (canNotTraverseDeeper()) return {};\n const 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 const {\n obj,\n k\n } = getLastOfPath(object, path, Object);\n obj[k] = newValue;\n}\nfunction pushPath(object, path, newValue, concat) {\n const {\n obj,\n k\n } = getLastOfPath(object, path, Object);\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 const {\n obj,\n k\n } = getLastOfPath(object, path);\n if (!obj) return undefined;\n return obj[k];\n}\nfunction getPathWithDefaults(data, defaultData, key) {\n const 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 (const 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 '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": ''',\n '/': '/'\n};\nfunction escape(data) {\n if (typeof data === 'string') {\n return data.replace(/[&<>\"'\\/]/g, s => _entityMap[s]);\n }\n return data;\n}\nconst chars = [' ', ',', '?', '!', ';'];\nfunction looksLikeObjectPath(key, nsSeparator, keySeparator) {\n nsSeparator = nsSeparator || '';\n keySeparator = keySeparator || '';\n const possibleChars = chars.filter(c => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);\n if (possibleChars.length === 0) return true;\n const r = new RegExp(`(${possibleChars.map(c => c === '?' ? '\\\\?' : c).join('|')})`);\n let matched = !r.test(key);\n if (!matched) {\n const 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 let keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';\n if (!obj) return undefined;\n if (obj[path]) return obj[path];\n const paths = path.split(keySeparator);\n let current = obj;\n for (let 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 let j = 2;\n let p = paths.slice(i, i + j).join(keySeparator);\n let 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 const 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}\nfunction getCleanedCode(code) {\n if (code && code.indexOf('_') > 0) return code.replace('_', '-');\n return code;\n}\n\nclass ResourceStore extends EventEmitter {\n constructor(data) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {\n ns: ['translation'],\n defaultNS: 'translation'\n };\n super();\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 }\n addNamespaces(ns) {\n if (this.options.ns.indexOf(ns) < 0) {\n this.options.ns.push(ns);\n }\n }\n removeNamespaces(ns) {\n const index = this.options.ns.indexOf(ns);\n if (index > -1) {\n this.options.ns.splice(index, 1);\n }\n }\n getResource(lng, ns, key) {\n let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;\n const ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;\n let 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 const 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 addResource(lng, ns, key, value) {\n let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {\n silent: false\n };\n const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;\n let 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 addResources(lng, ns, resources) {\n let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {\n silent: false\n };\n for (const 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 addResourceBundle(lng, ns, resources, deep, overwrite) {\n let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {\n silent: false\n };\n let 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 let pack = getPath(this.data, path) || {};\n if (deep) {\n deepExtend(pack, resources, overwrite);\n } else {\n pack = {\n ...pack,\n ...resources\n };\n }\n setPath(this.data, path, pack);\n if (!options.silent) this.emit('added', lng, ns, resources);\n }\n 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 hasResourceBundle(lng, ns) {\n return this.getResource(lng, ns) !== undefined;\n }\n getResourceBundle(lng, ns) {\n if (!ns) ns = this.options.defaultNS;\n if (this.options.compatibilityAPI === 'v1') return {\n ...{},\n ...this.getResource(lng, ns)\n };\n return this.getResource(lng, ns);\n }\n getDataByLanguage(lng) {\n return this.data[lng];\n }\n hasLanguageSomeTranslations(lng) {\n const data = this.getDataByLanguage(lng);\n const n = data && Object.keys(data) || [];\n return !!n.find(v => data[v] && Object.keys(data[v]).length > 0);\n }\n toJSON() {\n return this.data;\n }\n}\n\nvar postProcessor = {\n processors: {},\n addPostProcessor(module) {\n this.processors[module.name] = module;\n },\n handle(processors, value, key, options, translator) {\n processors.forEach(processor => {\n if (this.processors[processor]) value = this.processors[processor].process(value, key, options, translator);\n });\n return value;\n }\n};\n\nconst checkedLoadedFor = {};\nclass Translator extends EventEmitter {\n constructor(services) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n super();\n copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, this);\n this.options = options;\n if (this.options.keySeparator === undefined) {\n this.options.keySeparator = '.';\n }\n this.logger = baseLogger.create('translator');\n }\n changeLanguage(lng) {\n if (lng) this.language = lng;\n }\n exists(key) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {\n interpolation: {}\n };\n if (key === undefined || key === null) {\n return false;\n }\n const resolved = this.resolve(key, options);\n return resolved && resolved.res !== undefined;\n }\n extractFromKey(key, options) {\n let nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;\n if (nsSeparator === undefined) nsSeparator = ':';\n const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;\n let namespaces = options.ns || this.options.defaultNS || [];\n const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;\n const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);\n if (wouldCheckForNsInKey && !seemsNaturalLanguage) {\n const m = key.match(this.interpolator.nestingRegexp);\n if (m && m.length > 0) {\n return {\n key,\n namespaces\n };\n }\n const 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,\n namespaces\n };\n }\n translate(keys, options, lastKey) {\n if (typeof options !== 'object' && this.options.overloadTranslationOptionHandler) {\n options = this.options.overloadTranslationOptionHandler(arguments);\n }\n if (typeof options === 'object') options = {\n ...options\n };\n if (!options) options = {};\n if (keys === undefined || keys === null) return '';\n if (!Array.isArray(keys)) keys = [String(keys)];\n const returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;\n const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;\n const {\n key,\n namespaces\n } = this.extractFromKey(keys[keys.length - 1], options);\n const namespace = namespaces[namespaces.length - 1];\n const lng = options.lng || this.language;\n const appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;\n if (lng && lng.toLowerCase() === 'cimode') {\n if (appendNamespaceToCIMode) {\n const nsSeparator = options.nsSeparator || this.options.nsSeparator;\n if (returnDetails) {\n return {\n res: `${namespace}${nsSeparator}${key}`,\n usedKey: key,\n exactUsedKey: key,\n usedLng: lng,\n usedNS: namespace,\n usedParams: this.getUsedParamsDetails(options)\n };\n }\n return `${namespace}${nsSeparator}${key}`;\n }\n if (returnDetails) {\n return {\n res: key,\n usedKey: key,\n exactUsedKey: key,\n usedLng: lng,\n usedNS: namespace,\n usedParams: this.getUsedParamsDetails(options)\n };\n }\n return key;\n }\n const resolved = this.resolve(keys, options);\n let res = resolved && resolved.res;\n const resUsedKey = resolved && resolved.usedKey || key;\n const resExactUsedKey = resolved && resolved.exactUsedKey || key;\n const resType = Object.prototype.toString.apply(res);\n const noObject = ['[object Number]', '[object Function]', '[object RegExp]'];\n const joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;\n const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;\n const 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 const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, {\n ...options,\n ns: namespaces\n }) : `key '${key} (${this.language})' returned an object instead of string.`;\n if (returnDetails) {\n resolved.res = r;\n resolved.usedParams = this.getUsedParamsDetails(options);\n return resolved;\n }\n return r;\n }\n if (keySeparator) {\n const resTypeIsArray = resType === '[object Array]';\n const copy = resTypeIsArray ? [] : {};\n const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;\n for (const m in res) {\n if (Object.prototype.hasOwnProperty.call(res, m)) {\n const deepKey = `${newKeyToUse}${keySeparator}${m}`;\n copy[m] = this.translate(deepKey, {\n ...options,\n ...{\n joinArrays: false,\n ns: namespaces\n }\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 let usedDefault = false;\n let usedKey = false;\n const needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';\n const hasDefaultValue = Translator.hasDefaultValue(options);\n const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';\n const defaultValueSuffixOrdinalFallback = options.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, {\n ordinal: false\n }) : '';\n const defaultValue = options[`defaultValue${defaultValueSuffix}`] || options[`defaultValue${defaultValueSuffixOrdinalFallback}`] || 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 const missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;\n const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;\n const 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 const fk = this.resolve(key, {\n ...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 let lngs = [];\n const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);\n if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {\n for (let 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 const send = (l, k, specificDefaultValue) => {\n const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;\n if (this.options.missingKeyHandler) {\n this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);\n } else if (this.backendConnector && this.backendConnector.saveMissing) {\n this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);\n }\n this.emit('missingKey', l, namespace, k, res);\n };\n if (this.options.saveMissing) {\n if (this.options.saveMissingPlurals && needsPluralHandling) {\n lngs.forEach(language => {\n this.pluralResolver.getSuffixes(language, options).forEach(suffix => {\n send([language], key + suffix, options[`defaultValue${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 = `${namespace}:${key}`;\n if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {\n if (this.options.compatibilityAPI !== 'v1') {\n res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : undefined);\n } else {\n res = this.options.parseMissingKeyHandler(res);\n }\n }\n }\n if (returnDetails) {\n resolved.res = res;\n resolved.usedParams = this.getUsedParamsDetails(options);\n return resolved;\n }\n return res;\n }\n extendTranslation(res, key, options, resolved, lastKey) {\n var _this = this;\n if (this.i18nFormat && this.i18nFormat.parse) {\n res = this.i18nFormat.parse(res, {\n ...this.options.interpolation.defaultVariables,\n ...options\n }, options.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {\n resolved\n });\n } else if (!options.skipInterpolation) {\n if (options.interpolation) this.interpolator.init({\n ...options,\n ...{\n interpolation: {\n ...this.options.interpolation,\n ...options.interpolation\n }\n }\n });\n const skipOnVariables = typeof res === 'string' && (options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);\n let nestBef;\n if (skipOnVariables) {\n const nb = res.match(this.interpolator.nestingRegexp);\n nestBef = nb && nb.length;\n }\n let data = options.replace && typeof options.replace !== 'string' ? options.replace : options;\n if (this.options.interpolation.defaultVariables) data = {\n ...this.options.interpolation.defaultVariables,\n ...data\n };\n res = this.interpolator.interpolate(res, data, options.lng || this.language, options);\n if (skipOnVariables) {\n const na = res.match(this.interpolator.nestingRegexp);\n const 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 _this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);\n return null;\n }\n return _this.translate(...args, key);\n }, options);\n if (options.interpolation) this.interpolator.reset();\n }\n const postProcess = options.postProcess || this.options.postProcess;\n const 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 ? {\n i18nResolved: {\n ...resolved,\n usedParams: this.getUsedParamsDetails(options)\n },\n ...options\n } : options, this);\n }\n return res;\n }\n resolve(keys) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n let found;\n let usedKey;\n let exactUsedKey;\n let usedLng;\n let usedNS;\n if (typeof keys === 'string') keys = [keys];\n keys.forEach(k => {\n if (this.isValidLookup(found)) return;\n const extracted = this.extractFromKey(k, options);\n const key = extracted.key;\n usedKey = key;\n let namespaces = extracted.namespaces;\n if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);\n const needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';\n const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && this.pluralResolver.shouldUseIntlApi();\n const needsContextHandling = options.context !== undefined && (typeof options.context === 'string' || typeof options.context === 'number') && options.context !== '';\n const codes = options.lngs ? options.lngs : this.languageUtils.toResolveHierarchy(options.lng || this.language, options.fallbackLng);\n namespaces.forEach(ns => {\n if (this.isValidLookup(found)) return;\n usedNS = ns;\n if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils && this.utils.hasLoadedNamespace && !this.utils.hasLoadedNamespace(usedNS)) {\n checkedLoadedFor[`${codes[0]}-${ns}`] = true;\n this.logger.warn(`key \"${usedKey}\" for languages \"${codes.join(', ')}\" won't get resolved as namespace \"${usedNS}\" was not yet loaded`, 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');\n }\n codes.forEach(code => {\n if (this.isValidLookup(found)) return;\n usedLng = code;\n const finalKeys = [key];\n if (this.i18nFormat && this.i18nFormat.addLookupKeys) {\n this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);\n } else {\n let pluralSuffix;\n if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, options.count, options);\n const zeroSuffix = `${this.options.pluralSeparator}zero`;\n const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;\n if (needsPluralHandling) {\n finalKeys.push(key + pluralSuffix);\n if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {\n finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));\n }\n if (needsZeroSuffixLookup) {\n finalKeys.push(key + zeroSuffix);\n }\n }\n if (needsContextHandling) {\n const contextKey = `${key}${this.options.contextSeparator}${options.context}`;\n finalKeys.push(contextKey);\n if (needsPluralHandling) {\n finalKeys.push(contextKey + pluralSuffix);\n if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {\n finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));\n }\n if (needsZeroSuffixLookup) {\n finalKeys.push(contextKey + zeroSuffix);\n }\n }\n }\n }\n let possibleKey;\n while (possibleKey = finalKeys.pop()) {\n if (!this.isValidLookup(found)) {\n exactUsedKey = possibleKey;\n found = this.getResource(code, ns, possibleKey, options);\n }\n }\n });\n });\n });\n return {\n res: found,\n usedKey,\n exactUsedKey,\n usedLng,\n usedNS\n };\n }\n isValidLookup(res) {\n return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');\n }\n getResource(code, ns, key) {\n let 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 getUsedParamsDetails() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n const optionsKeys = ['defaultValue', 'ordinal', 'context', 'replace', 'lng', 'lngs', 'fallbackLng', 'ns', 'keySeparator', 'nsSeparator', 'returnObjects', 'returnDetails', 'joinArrays', 'postProcess', 'interpolation'];\n const useOptionsReplaceForData = options.replace && typeof options.replace !== 'string';\n let data = useOptionsReplaceForData ? options.replace : options;\n if (useOptionsReplaceForData && typeof options.count !== 'undefined') {\n data.count = options.count;\n }\n if (this.options.interpolation.defaultVariables) {\n data = {\n ...this.options.interpolation.defaultVariables,\n ...data\n };\n }\n if (!useOptionsReplaceForData) {\n data = {\n ...data\n };\n for (const key of optionsKeys) {\n delete data[key];\n }\n }\n return data;\n }\n static hasDefaultValue(options) {\n const prefix = 'defaultValue';\n for (const 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\nfunction capitalize(string) {\n return string.charAt(0).toUpperCase() + string.slice(1);\n}\nclass LanguageUtil {\n constructor(options) {\n this.options = options;\n this.supportedLngs = this.options.supportedLngs || false;\n this.logger = baseLogger.create('languageUtils');\n }\n getScriptPartFromCode(code) {\n code = getCleanedCode(code);\n if (!code || code.indexOf('-') < 0) return null;\n const 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 getLanguagePartFromCode(code) {\n code = getCleanedCode(code);\n if (!code || code.indexOf('-') < 0) return code;\n const p = code.split('-');\n return this.formatLanguageCode(p[0]);\n }\n formatLanguageCode(code) {\n if (typeof code === 'string' && code.indexOf('-') > -1) {\n const specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];\n let p = code.split('-');\n if (this.options.lowerCaseLng) {\n p = p.map(part => part.toLowerCase());\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 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 getBestMatchFromCodes(codes) {\n if (!codes) return null;\n let found;\n codes.forEach(code => {\n if (found) return;\n const cleanedLng = this.formatLanguageCode(code);\n if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;\n });\n if (!found && this.options.supportedLngs) {\n codes.forEach(code => {\n if (found) return;\n const lngOnly = this.getLanguagePartFromCode(code);\n if (this.isSupportedCode(lngOnly)) return found = lngOnly;\n found = this.options.supportedLngs.find(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 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 let 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 toResolveHierarchy(code, fallbackCode) {\n const fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);\n const codes = [];\n const addCode = c => {\n if (!c) return;\n if (this.isSupportedCode(c)) {\n codes.push(c);\n } else {\n this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);\n }\n };\n if (typeof code === 'string' && (code.indexOf('-') > -1 || 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(fc => {\n if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));\n });\n return codes;\n }\n}\n\nlet 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}];\nlet _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};\nconst nonIntlVersions = ['v1', 'v2', 'v3'];\nconst intlVersions = ['v4'];\nconst suffixesOrder = {\n zero: 0,\n one: 1,\n two: 2,\n few: 3,\n many: 4,\n other: 5\n};\nfunction createRules() {\n const rules = {};\n sets.forEach(set => {\n set.lngs.forEach(l => {\n rules[l] = {\n numbers: set.nr,\n plurals: _rulesPluralsTypes[set.fc]\n };\n });\n });\n return rules;\n}\nclass PluralResolver {\n constructor(languageUtils) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n this.languageUtils = languageUtils;\n this.options = options;\n this.logger = baseLogger.create('pluralResolver');\n if ((!this.options.compatibilityJSON || intlVersions.includes(this.options.compatibilityJSON)) && (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 addRule(lng, obj) {\n this.rules[lng] = obj;\n }\n getRule(code) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n if (this.shouldUseIntlApi()) {\n try {\n return new Intl.PluralRules(getCleanedCode(code), {\n type: options.ordinal ? 'ordinal' : 'cardinal'\n });\n } catch (err) {\n return;\n }\n }\n return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];\n }\n needsPlural(code) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n const 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 getPluralFormsOfKey(code, key) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n return this.getSuffixes(code, options).map(suffix => `${key}${suffix}`);\n }\n getSuffixes(code) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n const rule = this.getRule(code, options);\n if (!rule) {\n return [];\n }\n if (this.shouldUseIntlApi()) {\n return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map(pluralCategory => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${pluralCategory}`);\n }\n return rule.numbers.map(number => this.getSuffix(code, number, options));\n }\n getSuffix(code, count) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n const rule = this.getRule(code, options);\n if (rule) {\n if (this.shouldUseIntlApi()) {\n return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${rule.select(count)}`;\n }\n return this.getSuffixRetroCompatible(rule, count);\n }\n this.logger.warn(`no plural rule found for: ${code}`);\n return '';\n }\n getSuffixRetroCompatible(rule, count) {\n const idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));\n let 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 const returnSuffix = () => this.options.prepend && suffix.toString() ? this.options.prepend + suffix.toString() : suffix.toString();\n if (this.options.compatibilityJSON === 'v1') {\n if (suffix === 1) return '';\n if (typeof suffix === 'number') return `_plural_${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 shouldUseIntlApi() {\n return !nonIntlVersions.includes(this.options.compatibilityJSON);\n }\n}\n\nfunction deepFindWithDefaults(data, defaultData, key) {\n let keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';\n let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;\n let 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}\nclass Interpolator {\n constructor() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n this.logger = baseLogger.create('interpolator');\n this.options = options;\n this.format = options.interpolation && options.interpolation.format || (value => value);\n this.init(options);\n }\n init() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n if (!options.interpolation) options.interpolation = {\n escapeValue: true\n };\n const 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 reset() {\n if (this.options) this.init(this.options);\n }\n resetRegExp() {\n const regexpStr = `${this.prefix}(.+?)${this.suffix}`;\n this.regexp = new RegExp(regexpStr, 'g');\n const regexpUnescapeStr = `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`;\n this.regexpUnescape = new RegExp(regexpUnescapeStr, 'g');\n const nestingRegexpStr = `${this.nestingPrefix}(.+?)${this.nestingSuffix}`;\n this.nestingRegexp = new RegExp(nestingRegexpStr, 'g');\n }\n interpolate(str, data, lng, options) {\n let match;\n let value;\n let replaces;\n const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};\n function regexSafe(val) {\n return val.replace(/\\$/g, '$$$$');\n }\n const handleFormat = key => {\n if (key.indexOf(this.formatSeparator) < 0) {\n const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);\n return this.alwaysFormat ? this.format(path, undefined, lng, {\n ...options,\n ...data,\n interpolationkey: key\n }) : path;\n }\n const p = key.split(this.formatSeparator);\n const k = p.shift().trim();\n const f = p.join(this.formatSeparator).trim();\n return this.format(deepFindWithDefaults(data, defaultData, k, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, {\n ...options,\n ...data,\n interpolationkey: k\n });\n };\n this.resetRegExp();\n const missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;\n const skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;\n const todos = [{\n regex: this.regexpUnescape,\n safeValue: val => regexSafe(val)\n }, {\n regex: this.regexp,\n safeValue: val => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)\n }];\n todos.forEach(todo => {\n replaces = 0;\n while (match = todo.regex.exec(str)) {\n const matchedVar = match[1].trim();\n value = handleFormat(matchedVar);\n if (value === undefined) {\n if (typeof missingInterpolationHandler === 'function') {\n const 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 ${matchedVar} for interpolating ${str}`);\n value = '';\n }\n } else if (typeof value !== 'string' && !this.useRawValueToEscape) {\n value = makeString(value);\n }\n const 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 nest(str, fc) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n let match;\n let value;\n let clonedOptions;\n function handleHasOptions(key, inheritedOptions) {\n const sep = this.nestingOptionsSeparator;\n if (key.indexOf(sep) < 0) return key;\n const c = key.split(new RegExp(`${sep}[ ]*{`));\n let optionsString = `{${c[1]}`;\n key = c[0];\n optionsString = this.interpolate(optionsString, clonedOptions);\n const matchedSingleQuotes = optionsString.match(/'/g);\n const 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 = {\n ...inheritedOptions,\n ...clonedOptions\n };\n } catch (e) {\n this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);\n return `${key}${sep}${optionsString}`;\n }\n delete clonedOptions.defaultValue;\n return key;\n }\n while (match = this.nestingRegexp.exec(str)) {\n let formatters = [];\n clonedOptions = {\n ...options\n };\n clonedOptions = clonedOptions.replace && typeof clonedOptions.replace !== 'string' ? clonedOptions.replace : clonedOptions;\n clonedOptions.applyPostProcessor = false;\n delete clonedOptions.defaultValue;\n let doReduce = false;\n if (match[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match[1])) {\n const r = match[1].split(this.formatSeparator).map(elem => elem.trim());\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 ${match[1]} for nesting ${str}`);\n value = '';\n }\n if (doReduce) {\n value = formatters.reduce((v, f) => this.format(v, f, options.lng, {\n ...options,\n interpolationkey: match[1].trim()\n }), value.trim());\n }\n str = str.replace(match[0], value);\n this.regexp.lastIndex = 0;\n }\n return str;\n }\n}\n\nfunction parseFormatStr(formatStr) {\n let formatName = formatStr.toLowerCase().trim();\n const formatOptions = {};\n if (formatStr.indexOf('(') > -1) {\n const p = formatStr.split('(');\n formatName = p[0].toLowerCase().trim();\n const 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 const opts = optStr.split(';');\n opts.forEach(opt => {\n if (!opt) return;\n const [key, ...rest] = opt.split(':');\n const 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,\n formatOptions\n };\n}\nfunction createCachedFormatter(fn) {\n const cache = {};\n return function invokeFormatter(val, lng, options) {\n const key = lng + JSON.stringify(options);\n let formatter = cache[key];\n if (!formatter) {\n formatter = fn(getCleanedCode(lng), options);\n cache[key] = formatter;\n }\n return formatter(val);\n };\n}\nclass Formatter {\n constructor() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n this.logger = baseLogger.create('formatter');\n this.options = options;\n this.formats = {\n number: createCachedFormatter((lng, opt) => {\n const formatter = new Intl.NumberFormat(lng, {\n ...opt\n });\n return val => formatter.format(val);\n }),\n currency: createCachedFormatter((lng, opt) => {\n const formatter = new Intl.NumberFormat(lng, {\n ...opt,\n style: 'currency'\n });\n return val => formatter.format(val);\n }),\n datetime: createCachedFormatter((lng, opt) => {\n const formatter = new Intl.DateTimeFormat(lng, {\n ...opt\n });\n return val => formatter.format(val);\n }),\n relativetime: createCachedFormatter((lng, opt) => {\n const formatter = new Intl.RelativeTimeFormat(lng, {\n ...opt\n });\n return val => formatter.format(val, opt.range || 'day');\n }),\n list: createCachedFormatter((lng, opt) => {\n const formatter = new Intl.ListFormat(lng, {\n ...opt\n });\n return val => formatter.format(val);\n })\n };\n this.init(options);\n }\n init(services) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {\n interpolation: {}\n };\n const iOpts = options.interpolation;\n this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';\n }\n add(name, fc) {\n this.formats[name.toLowerCase().trim()] = fc;\n }\n addCached(name, fc) {\n this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);\n }\n format(value, format, lng) {\n let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n const formats = format.split(this.formatSeparator);\n const result = formats.reduce((mem, f) => {\n const {\n formatName,\n formatOptions\n } = parseFormatStr(f);\n if (this.formats[formatName]) {\n let formatted = mem;\n try {\n const valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || {};\n const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;\n formatted = this.formats[formatName](mem, l, {\n ...formatOptions,\n ...options,\n ...valOptions\n });\n } catch (error) {\n this.logger.warn(error);\n }\n return formatted;\n } else {\n this.logger.warn(`there was no format function for ${formatName}`);\n }\n return mem;\n }, value);\n return result;\n }\n}\n\nfunction removePending(q, name) {\n if (q.pending[name] !== undefined) {\n delete q.pending[name];\n q.pendingCount--;\n }\n}\nclass Connector extends EventEmitter {\n constructor(backend, store, services) {\n let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n super();\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 }\n queueLoad(languages, namespaces, options, callback) {\n const toLoad = {};\n const pending = {};\n const toLoadLanguages = {};\n const toLoadNamespaces = {};\n languages.forEach(lng => {\n let hasAllNamespaces = true;\n namespaces.forEach(ns => {\n const name = `${lng}|${ns}`;\n if (!options.reload && this.store.hasResourceBundle(lng, ns)) {\n this.state[name] = 2;\n } else if (this.state[name] < 0) ; else if (this.state[name] === 1) {\n if (pending[name] === undefined) pending[name] = true;\n } else {\n this.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,\n pendingCount: Object.keys(pending).length,\n loaded: {},\n errors: [],\n 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 loaded(name, err, data) {\n const s = name.split('|');\n const lng = s[0];\n const 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 const loaded = {};\n this.queue.forEach(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(l => {\n if (!loaded[l]) loaded[l] = {};\n const loadedKeys = q.loaded[l];\n if (loadedKeys.length) {\n loadedKeys.forEach(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(q => !q.done);\n }\n read(lng, ns, fcName) {\n let tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;\n let wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;\n let 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,\n ns,\n fcName,\n tried,\n wait,\n callback\n });\n return;\n }\n this.readingCalls++;\n const resolver = (err, data) => {\n this.readingCalls--;\n if (this.waitingReads.length > 0) {\n const next = this.waitingReads.shift();\n this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);\n }\n if (err && data && tried < this.maxRetries) {\n setTimeout(() => {\n this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);\n }, wait);\n return;\n }\n callback(err, data);\n };\n const fc = this.backend[fcName].bind(this.backend);\n if (fc.length === 2) {\n try {\n const r = fc(lng, ns);\n if (r && typeof r.then === 'function') {\n r.then(data => resolver(null, data)).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 prepareLoading(languages, namespaces) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n let 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 const 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(name => {\n this.loadOne(name);\n });\n }\n load(languages, namespaces, callback) {\n this.prepareLoading(languages, namespaces, {}, callback);\n }\n reload(languages, namespaces, callback) {\n this.prepareLoading(languages, namespaces, {\n reload: true\n }, callback);\n }\n loadOne(name) {\n let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';\n const s = name.split('|');\n const lng = s[0];\n const ns = s[1];\n this.read(lng, ns, 'read', undefined, undefined, (err, data) => {\n if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);\n if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);\n this.loaded(name, err, data);\n });\n }\n saveMissing(languages, namespace, key, fallbackValue, isUpdate) {\n let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};\n let clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : () => {};\n if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {\n this.logger.warn(`did not save key \"${key}\" as the namespace \"${namespace}\" was not yet loaded`, 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');\n return;\n }\n if (key === undefined || key === null || key === '') return;\n if (this.backend && this.backend.create) {\n const opts = {\n ...options,\n isUpdate\n };\n const fc = this.backend.create.bind(this.backend);\n if (fc.length < 6) {\n try {\n let 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(data => clb(null, data)).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\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: false,\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 let ret = {};\n if (typeof 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 args[2] === 'object' || typeof args[3] === 'object') {\n const options = args[3] || args[2];\n Object.keys(options).forEach(key => {\n ret[key] = options[key];\n });\n }\n return ret;\n },\n interpolation: {\n escapeValue: true,\n format: (value, format, lng, options) => value,\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 noop() {}\nfunction bindMemberFunctions(inst) {\n const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));\n mems.forEach(mem => {\n if (typeof inst[mem] === 'function') {\n inst[mem] = inst[mem].bind(inst);\n }\n });\n}\nclass I18n extends EventEmitter {\n constructor() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n let callback = arguments.length > 1 ? arguments[1] : undefined;\n super();\n this.options = transformOptions(options);\n this.services = {};\n this.logger = baseLogger;\n this.modules = {\n external: []\n };\n bindMemberFunctions(this);\n if (callback && !this.isInitialized && !options.isClone) {\n if (!this.options.initImmediate) {\n this.init(options, callback);\n return this;\n }\n setTimeout(() => {\n this.init(options, callback);\n }, 0);\n }\n }\n init() {\n var _this = this;\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n let 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 const defOpts = get();\n this.options = {\n ...defOpts,\n ...this.options,\n ...transformOptions(options)\n };\n if (this.options.compatibilityAPI !== 'v1') {\n this.options.interpolation = {\n ...defOpts.interpolation,\n ...this.options.interpolation\n };\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 let formatter;\n if (this.modules.formatter) {\n formatter = this.modules.formatter;\n } else if (typeof Intl !== 'undefined') {\n formatter = Formatter;\n }\n const lu = new LanguageUtil(this.options);\n this.store = new ResourceStore(this.options.resources, this.options);\n const 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 _this.emit(event, ...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 _this.emit(event, ...args);\n });\n this.modules.external.forEach(m => {\n if (m.init) m.init(this);\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 const 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 const storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];\n storeApi.forEach(fcName => {\n this[fcName] = function () {\n return _this.store[fcName](...arguments);\n };\n });\n const storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];\n storeApiChained.forEach(fcName => {\n this[fcName] = function () {\n _this.store[fcName](...arguments);\n return _this;\n };\n });\n const deferred = defer();\n const load = () => {\n const finish = (err, t) => {\n if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn('init: i18next is already initialized. You should call init just once!');\n this.isInitialized = true;\n if (!this.options.isClone) this.logger.log('initialized', this.options);\n this.emit('initialized', this.options);\n deferred.resolve(t);\n callback(err, t);\n };\n if (this.languages && this.options.compatibilityAPI !== 'v1' && !this.isInitialized) return finish(null, this.t.bind(this));\n this.changeLanguage(this.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 loadResources(language) {\n let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;\n let usedCallback = callback;\n const 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' && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();\n const toLoad = [];\n const append = lng => {\n if (!lng) return;\n if (lng === 'cimode') return;\n const lngs = this.services.languageUtils.toResolveHierarchy(lng);\n lngs.forEach(l => {\n if (l === 'cimode') return;\n if (toLoad.indexOf(l) < 0) toLoad.push(l);\n });\n };\n if (!usedLng) {\n const fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);\n fallbacks.forEach(l => append(l));\n } else {\n append(usedLng);\n }\n if (this.options.preload) {\n this.options.preload.forEach(l => append(l));\n }\n this.services.backendConnector.load(toLoad, this.options.ns, e => {\n if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);\n usedCallback(e);\n });\n } else {\n usedCallback(null);\n }\n }\n reloadResources(lngs, ns, callback) {\n const 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, err => {\n deferred.resolve();\n callback(err);\n });\n return deferred;\n }\n 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 setResolvedLanguage(l) {\n if (!l || !this.languages) return;\n if (['cimode', 'dev'].indexOf(l) > -1) return;\n for (let li = 0; li < this.languages.length; li++) {\n const 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 changeLanguage(lng, callback) {\n var _this2 = this;\n this.isLanguageChangingTo = lng;\n const deferred = defer();\n this.emit('languageChanging', lng);\n const setLngProps = l => {\n this.language = l;\n this.languages = this.services.languageUtils.toResolveHierarchy(l);\n this.resolvedLanguage = undefined;\n this.setResolvedLanguage(l);\n };\n const done = (err, l) => {\n if (l) {\n setLngProps(l);\n this.translator.changeLanguage(l);\n this.isLanguageChangingTo = undefined;\n this.emit('languageChanged', l);\n this.logger.log('languageChanged', l);\n } else {\n this.isLanguageChangingTo = undefined;\n }\n deferred.resolve(function () {\n return _this2.t(...arguments);\n });\n if (callback) callback(err, function () {\n return _this2.t(...arguments);\n });\n };\n const setLng = lngs => {\n if (!lng && !lngs && this.services.languageDetector) lngs = [];\n const l = typeof lngs === 'string' ? lngs : this.services.languageUtils.getBestMatchFromCodes(lngs);\n if (l) {\n if (!this.language) {\n setLngProps(l);\n }\n if (!this.translator.language) this.translator.changeLanguage(l);\n if (this.services.languageDetector && this.services.languageDetector.cacheUserLanguage) this.services.languageDetector.cacheUserLanguage(l);\n }\n this.loadResources(l, 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 getFixedT(lng, ns, keyPrefix) {\n var _this3 = this;\n const fixedT = function (key, opts) {\n let options;\n if (typeof 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 = _this3.options.overloadTranslationOptionHandler([key, opts].concat(rest));\n } else {\n options = {\n ...opts\n };\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 const keySeparator = _this3.options.keySeparator || '.';\n let resultKey;\n if (options.keyPrefix && Array.isArray(key)) {\n resultKey = key.map(k => `${options.keyPrefix}${keySeparator}${k}`);\n } else {\n resultKey = options.keyPrefix ? `${options.keyPrefix}${keySeparator}${key}` : key;\n }\n return _this3.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 t() {\n return this.translator && this.translator.translate(...arguments);\n }\n exists() {\n return this.translator && this.translator.exists(...arguments);\n }\n setDefaultNamespace(ns) {\n this.options.defaultNS = ns;\n }\n hasLoadedNamespace(ns) {\n let 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 const lng = options.lng || this.resolvedLanguage || this.languages[0];\n const fallbackLng = this.options ? this.options.fallbackLng : false;\n const lastLng = this.languages[this.languages.length - 1];\n if (lng.toLowerCase() === 'cimode') return true;\n const loadNotPending = (l, n) => {\n const loadState = this.services.backendConnector.state[`${l}|${n}`];\n return loadState === -1 || loadState === 2;\n };\n if (options.precheck) {\n const 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 loadNamespaces(ns, callback) {\n const 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(n => {\n if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);\n });\n this.loadResources(err => {\n deferred.resolve();\n if (callback) callback(err);\n });\n return deferred;\n }\n loadLanguages(lngs, callback) {\n const deferred = defer();\n if (typeof lngs === 'string') lngs = [lngs];\n const preloaded = this.options.preload || [];\n const newLngs = lngs.filter(lng => preloaded.indexOf(lng) < 0);\n if (!newLngs.length) {\n if (callback) callback();\n return Promise.resolve();\n }\n this.options.preload = preloaded.concat(newLngs);\n this.loadResources(err => {\n deferred.resolve();\n if (callback) callback(err);\n });\n return deferred;\n }\n 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 const rtlLngs = ['ar', 'shu', 'sqr', 'ssh', 'xaa', 'yhd', 'yud', 'aao', 'abh', 'abv', 'acm', 'acq', 'acw', 'acx', 'acy', 'adf', 'ads', 'aeb', 'aec', 'afb', 'ajp', 'apc', 'apd', 'arb', 'arq', 'ars', 'ary', 'arz', 'auz', 'avl', 'ayh', 'ayl', 'ayn', 'ayp', 'bbz', 'pga', 'he', 'iw', 'ps', 'pbt', 'pbu', 'pst', 'prp', 'prd', 'ug', 'ur', 'ydd', 'yds', 'yih', 'ji', 'yi', 'hbo', 'men', 'xmn', 'fa', 'jpr', 'peo', 'pes', 'prs', 'dv', 'sam', 'ckb'];\n const 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 static createInstance() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n let callback = arguments.length > 1 ? arguments[1] : undefined;\n return new I18n(options, callback);\n }\n cloneInstance() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;\n const forkResourceStore = options.forkResourceStore;\n if (forkResourceStore) delete options.forkResourceStore;\n const mergedOptions = {\n ...this.options,\n ...options,\n ...{\n isClone: true\n }\n };\n const clone = new I18n(mergedOptions);\n if (options.debug !== undefined || options.prefix !== undefined) {\n clone.logger = clone.logger.clone(options);\n }\n const membersToCopy = ['store', 'services', 'language'];\n membersToCopy.forEach(m => {\n clone[m] = this[m];\n });\n clone.services = {\n ...this.services\n };\n clone.services.utils = {\n hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)\n };\n if (forkResourceStore) {\n clone.store = new ResourceStore(this.store.data, mergedOptions);\n clone.services.resourceStore = clone.store;\n }\n clone.translator = new Translator(clone.services, mergedOptions);\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(event, ...args);\n });\n clone.init(mergedOptions, callback);\n clone.translator.options = mergedOptions;\n clone.translator.backendConnector.services.utils = {\n hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)\n };\n return clone;\n }\n 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}\nconst instance = I18n.createInstance();\ninstance.createInstance = I18n.createInstance;\n\nconst createInstance = instance.createInstance;\nconst dir = instance.dir;\nconst init = instance.init;\nconst loadResources = instance.loadResources;\nconst reloadResources = instance.reloadResources;\nconst use = instance.use;\nconst changeLanguage = instance.changeLanguage;\nconst getFixedT = instance.getFixedT;\nconst t = instance.t;\nconst exists = instance.exists;\nconst setDefaultNamespace = instance.setDefaultNamespace;\nconst hasLoadedNamespace = instance.hasLoadedNamespace;\nconst loadNamespaces = instance.loadNamespaces;\nconst loadLanguages = instance.loadLanguages;\n\nexport { changeLanguage, createInstance, instance as default, dir, exists, getFixedT, hasLoadedNamespace, init, loadLanguages, loadNamespaces, loadResources, reloadResources, setDefaultNamespace, t, use };\n","/**\n * Localizing script for SVG-edit UI.\n * @module locale\n * @license MIT\n *\n * @copyright 2010 Narendra Sisodya\n * @copyright 2010 Alexis Deveria\n *\n */\n\nimport i18next from 'i18next'\n\n/**\n * The string keys of the object are two-letter language codes.\n * @tutorial LocaleDocs\n * @typedef {PlainObject} module:locale.LocaleStrings\n */\n// keyed to an array of objects with \"id\" and \"title\" or \"textContent\" properties\n/**\n * @typedef {PlainObject} module:locale.LocaleSelectorValue\n */\n\nlet langParam\n\n/**\n* The \"data\" property is generally set to an an array of objects with\n* \"id\" and \"title\" or \"textContent\" properties.\n* @typedef {PlainObject} module:locale.AddLangExtensionLocaleData\n* @property {module:locale.LocaleStrings[]} data See {@tutorial LocaleDocs}\n*/\n\n/**\n* @interface module:locale.LocaleEditorInit\n*/\n/**\n * @function module:locale.LocaleEditorInit#addLangData\n * @param {string} langParam\n * @returns {module:locale.AddLangExtensionLocaleData}\n*/\n/**\n* @typedef {PlainObject} module:locale.LangAndData\n* @property {string} langParam\n* @property {module:locale.LocaleStrings} langData\n*/\n\n/**\n *\n * @function module:locale.putLocale\n * @param {string} givenParam\n * @param {string[]} goodLangs\n * @fires module:svgcanvas.SvgCanvas#event:ext_addLangData\n * @fires module:svgcanvas.SvgCanvas#event:ext_langReady\n * @fires module:svgcanvas.SvgCanvas#event:ext_langChanged\n * @returns {Promise} Resolves to result of {@link module:locale.readLang}\n*/\n\nexport const putLocale = async function (givenParam, goodLangs) {\n if (givenParam) {\n langParam = givenParam\n } else if (navigator.userLanguage) { // Explorer\n langParam = navigator.userLanguage\n } else if (navigator.language) { // FF, Opera, ...\n langParam = navigator.language\n }\n\n // Set to English if language is not in list of good langs\n if (!goodLangs.includes(langParam) && langParam !== 'test') {\n langParam = 'en'\n }\n const module = await import(`./locale/lang.${encodeURIComponent(langParam)}.js`)\n i18next.init({\n lng: langParam,\n debug: false,\n resources: {\n [langParam]: {\n translation: module.default\n }\n }\n })\n return { langParam, i18next }\n}\n\nexport const t = function (key) {\n return i18next.t(key)\n}\n","/* globals svgEditor */\nimport { t } from '../locale.js'\nconst template = document.createElement('template')\ntemplate.innerHTML = `\n \n
\n \"icon\"\n
\n`\n/**\n * @class ToolButton\n */\nexport class ToolButton extends HTMLElement {\n /**\n * @function constructor\n */\n constructor () {\n super()\n // create the shadowDom and insert the template\n this._shadowRoot = this.attachShadow({ mode: 'open' })\n this._shadowRoot.append(template.content.cloneNode(true))\n // locate the component\n this.$div = this._shadowRoot.querySelector('div')\n this.$img = this._shadowRoot.querySelector('img')\n this.imgPath = svgEditor.configObj.curConfig.imgPath\n }\n\n /**\n * @function observedAttributes\n * @returns {any} observed\n */\n static get observedAttributes () {\n return ['title', 'src', 'pressed', 'disabled', 'size', 'style']\n }\n\n /**\n * @function attributeChangedCallback\n * @param {string} name\n * @param {string} oldValue\n * @param {string} newValue\n * @returns {void}\n */\n attributeChangedCallback (name, oldValue, newValue) {\n if (oldValue === newValue) return\n switch (name) {\n case 'title':\n {\n const shortcut = this.getAttribute('shortcut')\n this.$div.setAttribute('title', `${t(newValue)} ${shortcut ? `[${t(shortcut)}]` : ''}`)\n }\n break\n case 'style':\n this.$div.style = newValue\n break\n case 'src':\n if (newValue.indexOf('data:') !== -1) {\n this.$img.setAttribute('src', newValue)\n } else {\n this.$img.setAttribute('src', this.imgPath + '/' + newValue)\n }\n break\n case 'pressed':\n if (newValue === null) {\n this.$div.classList.remove('pressed')\n } else {\n this.$div.classList.add('pressed')\n }\n break\n case 'size':\n if (newValue === 'small') {\n this.$div.classList.add('small')\n } else {\n this.$div.classList.remove('small')\n }\n break\n case 'disabled':\n if (newValue) {\n this.$div.classList.add('disabled')\n } else {\n this.$div.classList.remove('disabled')\n }\n break\n default:\n console.error(`unknown attribute: ${name}`)\n break\n }\n }\n\n /**\n * @function get\n * @returns {any}\n */\n get title () {\n return this.getAttribute('title')\n }\n\n /**\n * @function set\n * @returns {void}\n */\n set title (value) {\n this.setAttribute('title', value)\n }\n\n /**\n * @function get\n * @returns {any}\n */\n get pressed () {\n return this.hasAttribute('pressed')\n }\n\n /**\n * @function set\n * @returns {void}\n */\n set pressed (value) {\n // boolean value => existence = true\n if (value) {\n this.setAttribute('pressed', 'true')\n } else {\n this.removeAttribute('pressed')\n }\n }\n\n /**\n * @function get\n * @returns {any}\n */\n get disabled () {\n return this.hasAttribute('disabled')\n }\n\n /**\n * @function set\n * @returns {void}\n */\n set disabled (value) {\n // boolean value => existence = true\n if (value) {\n this.setAttribute('disabled', 'true')\n } else {\n this.removeAttribute('disabled')\n }\n }\n\n /**\n * @function get\n * @returns {any}\n */\n get src () {\n return this.getAttribute('src')\n }\n\n /**\n * @function set\n * @returns {void}\n */\n set src (value) {\n this.setAttribute('src', value)\n }\n\n /**\n * @function get\n * @returns {any}\n */\n get size () {\n return this.getAttribute('size')\n }\n\n /**\n * @function set\n * @returns {void}\n */\n set size (value) {\n this.setAttribute('size', value)\n }\n\n /**\n * @function connectedCallback\n * @returns {void}\n */\n connectedCallback () {\n // capture shortcuts\n const shortcut = this.getAttribute('shortcut')\n if (shortcut) {\n // register the keydown event\n document.addEventListener('keydown', (e) => {\n // only track keyboard shortcuts for the body containing the SVG-Editor\n if (e.target.nodeName !== 'BODY') return\n // normalize key\n const key = `${(e.metaKey) ? 'meta+' : ''}${(e.ctrlKey) ? 'ctrl+' : ''}${e.key.toUpperCase()}`\n if (shortcut !== key) return\n // launch the click event\n this.click()\n e.preventDefault()\n })\n }\n }\n}\n\n// Register\ncustomElements.define('se-button', ToolButton)\n","/* globals svgEditor */\nimport { t } from '../locale.js'\n\n/**\n * @class FlyingButton\n */\nexport class FlyingButton extends HTMLElement {\n /**\n * @function constructor\n */\n constructor () {\n super()\n // create the shadowDom and insert the template\n this.imgPath = svgEditor.configObj.curConfig.imgPath\n this.template = this.createTemplate(this.imgPath)\n this._shadowRoot = this.attachShadow({ mode: 'open' })\n this._shadowRoot.append(this.template.content.cloneNode(true))\n // locate the component\n this.$button = this._shadowRoot.querySelector('.menu-button')\n this.$handle = this._shadowRoot.querySelector('.handle')\n this.$overall = this._shadowRoot.querySelector('.overall')\n this.$img = this._shadowRoot.querySelector('img')\n this.$menu = this._shadowRoot.querySelector('.menu')\n // the last element of the div is the slot\n // we retrieve all elements added in the slot (i.e. se-buttons)\n this.$elements = this.$menu.lastElementChild.assignedElements()\n }\n\n /**\n * @function createTemplate\n * @param {string} imgPath\n * @returns {any} template\n */\n\n createTemplate (imgPath) {\n const template = document.createElement('template')\n template.innerHTML = `\n \n\n
\n
\n \n
\n
\n \"icon\"\n
\n
\n
`\n return template\n }\n\n /**\n * @function observedAttributes\n * @returns {any} observed\n */\n static get observedAttributes () {\n return ['title', 'pressed', 'disabled', 'opened']\n }\n\n /**\n * @function attributeChangedCallback\n * @param {string} name\n * @param {string} oldValue\n * @param {string} newValue\n * @returns {void}\n */\n attributeChangedCallback (name, oldValue, newValue) {\n if (oldValue === newValue) return\n switch (name) {\n case 'title':\n {\n const shortcut = this.getAttribute('shortcut')\n this.$button.setAttribute('title', `${t(newValue)} ${shortcut ? `[${t(shortcut)}]` : ''}`)\n }\n break\n case 'pressed':\n if (newValue) {\n this.$overall.classList.add('pressed')\n } else {\n this.$overall.classList.remove('pressed')\n }\n break\n case 'opened':\n if (newValue) {\n this.$menu.classList.add('open')\n } else {\n this.$menu.classList.remove('open')\n }\n break\n case 'disabled':\n if (newValue) {\n this.$overall.classList.add('disabled')\n } else {\n this.$overall.classList.remove('disabled')\n }\n break\n default:\n console.error(`unknown attribute: ${name}`)\n break\n }\n }\n\n /**\n * @function get\n * @returns {any}\n */\n get title () {\n return this.getAttribute('title')\n }\n\n /**\n * @function set\n * @returns {void}\n */\n set title (value) {\n this.setAttribute('title', value)\n }\n\n /**\n * @function get\n * @returns {any}\n */\n get pressed () {\n return this.hasAttribute('pressed')\n }\n\n /**\n * @function set\n * @returns {void}\n */\n set pressed (value) {\n // boolean value => existence = true\n if (value) {\n this.setAttribute('pressed', 'true')\n } else {\n this.removeAttribute('pressed', '')\n // close also the menu if open\n this.removeAttribute('opened')\n }\n }\n\n /**\n * @function get\n * @returns {any}\n */\n get opened () {\n return this.hasAttribute('opened')\n }\n\n /**\n * @function set\n * @returns {void}\n */\n set opened (value) {\n // boolean value => existence = true\n if (value) {\n this.setAttribute('opened', 'opened')\n } else {\n this.removeAttribute('opened')\n }\n }\n\n /**\n * @function get\n * @returns {any}\n */\n get disabled () {\n return this.hasAttribute('disabled')\n }\n\n /**\n * @function set\n * @returns {void}\n */\n set disabled (value) {\n // boolean value => existence = true\n if (value) {\n this.setAttribute('disabled', 'true')\n } else {\n this.removeAttribute('disabled', '')\n }\n }\n\n /**\n * @function connectedCallback\n * @returns {void}\n */\n connectedCallback () {\n this.activeSlot = this.shadowRoot.querySelector('slot').assignedElements()[0]\n this.$img.setAttribute('src', this.imgPath + '/' + this.activeSlot.getAttribute('src'))\n // capture click event on the button to manage the logic\n const onClickHandler = (ev) => {\n ev.stopPropagation()\n switch (ev.target.nodeName) {\n case 'SE-FLYINGBUTTON':\n if (this.pressed) {\n this.setAttribute('opened', 'opened')\n } else {\n // launch current action\n this.activeSlot.click()\n this.setAttribute('pressed', 'pressed')\n }\n break\n case 'SE-BUTTON':\n // change to the current action\n this.$img.setAttribute('src', this.imgPath + '/' + ev.target.getAttribute('src'))\n this.activeSlot = ev.target\n this.setAttribute('pressed', 'pressed')\n // and close the menu\n this.$menu.classList.remove('open')\n break\n case 'DIV':\n // this is a click on the handle so let's open/close the menu.\n if (this.opened) {\n this.removeAttribute('opened')\n } else {\n this.setAttribute('opened', 'opened')\n // In case menu scroll on top or bottom position based popup position set\n const rect = this.getBoundingClientRect()\n this.$menu.style.top = rect.top + 'px'\n }\n break\n default:\n console.error('unkonw nodeName for:', ev.target, ev.target.className)\n }\n }\n // capture event from slots\n svgEditor.$click(this, onClickHandler)\n svgEditor.$click(this.$handle, onClickHandler)\n }\n}\n\n// Register\ncustomElements.define('se-flyingbutton', FlyingButton)\n","/* globals svgEditor */\n\n/**\n * @class ExplorerButton\n */\nexport class ExplorerButton extends HTMLElement {\n /**\n * @function constructor\n */\n constructor () {\n super()\n // create the shadowDom and insert the template\n // create the shadowDom and insert the template\n this.imgPath = svgEditor.configObj.curConfig.imgPath\n this.template = this.createTemplate(this.imgPath)\n this._shadowRoot = this.attachShadow({ mode: 'open' })\n this._shadowRoot.append(this.template.content.cloneNode(true))\n // locate the component\n this.$button = this._shadowRoot.querySelector('.menu-button')\n this.$overall = this._shadowRoot.querySelector('.overall')\n this.$img = this._shadowRoot.querySelector('.menu-button img')\n this.$menu = this._shadowRoot.querySelector('.menu')\n this.$handle = this._shadowRoot.querySelector('.handle')\n this.$lib = this._shadowRoot.querySelector('.image-lib')\n this.files = []\n this.request = new XMLHttpRequest()\n this.imgPath = svgEditor.configObj.curConfig.imgPath\n }\n\n /**\n * @function createTemplate\n * @param {string} imgPath\n * @returns {any} template\n */\n\n createTemplate (imgPath) {\n const template = document.createElement('template')\n template.innerHTML = `\n \n \n
\n
\n \"icon\"\n
\n
\n
\n \n
\n
\n
menu
\n
\n
`\n return template\n }\n\n /**\n * @function observedAttributes\n * @returns {any} observed\n */\n static get observedAttributes () {\n return ['title', 'pressed', 'disabled', 'lib', 'src']\n }\n\n /**\n * @function attributeChangedCallback\n * @param {string} name\n * @param {string} oldValue\n * @param {string} newValue\n * @returns {void}\n */\n async attributeChangedCallback (name, oldValue, newValue) {\n if (oldValue === newValue) return\n switch (name) {\n case 'title':\n {\n const shortcut = this.getAttribute('shortcut')\n this.$button.setAttribute('title', `${newValue} [${shortcut}]`)\n }\n break\n case 'pressed':\n if (newValue) {\n this.$overall.classList.add('pressed')\n } else {\n this.$overall.classList.remove('pressed')\n }\n break\n case 'disabled':\n if (newValue) {\n this.$overall.classList.add('disabled')\n } else {\n this.$overall.classList.remove('disabled')\n }\n break\n case 'lib':\n try {\n const response = await fetch(`${newValue}index.json`)\n const json = await response.json()\n const { lib } = json\n this.$menu.innerHTML = lib.map((menu, i) => (\n `
${menu}
`\n )).join('')\n await this.updateLib(lib[0])\n } catch (error) {\n console.error(error)\n }\n break\n case 'src':\n this.$img.setAttribute('src', this.imgPath + '/' + newValue)\n break\n default:\n console.error(`unknown attribute: ${name}`)\n break\n }\n }\n\n /**\n * @function get\n * @returns {any}\n */\n get title () {\n return this.getAttribute('title')\n }\n\n /**\n * @function set\n * @returns {void}\n */\n set title (value) {\n this.setAttribute('title', value)\n }\n\n /**\n * @function get\n * @returns {any}\n */\n get pressed () {\n return this.hasAttribute('pressed')\n }\n\n /**\n * @function set\n * @returns {void}\n */\n set pressed (value) {\n // boolean value => existence = true\n if (value) {\n this.setAttribute('pressed', 'true')\n } else {\n this.removeAttribute('pressed', '')\n }\n }\n\n /**\n * @function get\n * @returns {any}\n */\n get disabled () {\n return this.hasAttribute('disabled')\n }\n\n /**\n * @function set\n * @returns {void}\n */\n set disabled (value) {\n // boolean value => existence = true\n if (value) {\n this.setAttribute('disabled', 'true')\n } else {\n this.removeAttribute('disabled', '')\n }\n }\n\n /**\n * @function connectedCallback\n * @returns {void}\n */\n connectedCallback () {\n // capture click event on the button to manage the logic\n const onClickHandler = (ev) => {\n ev.stopPropagation()\n switch (ev.target.nodeName) {\n case 'SE-EXPLORERBUTTON':\n this.$menu.classList.add('open')\n this.$lib.classList.add('open-lib')\n break\n case 'SE-BUTTON':\n // change to the current action\n this.currentAction = ev.target\n this.$img.setAttribute('src', this.currentAction.getAttribute('src'))\n this.dataset.draw = this.data[this.currentAction.dataset.shape]\n this._shadowRoot.querySelectorAll('.image-lib [pressed]').forEach((b) => { b.pressed = false })\n this.currentAction.setAttribute('pressed', 'pressed')\n // and close the menu\n this.$menu.classList.remove('open')\n this.$lib.classList.remove('open-lib')\n break\n case 'DIV':\n if (ev.target.classList[0] === 'handle') {\n // this is a click on the handle so let's open/close the menu.\n this.$menu.classList.toggle('open')\n this.$lib.classList.toggle('open-lib')\n } else {\n this._shadowRoot.querySelectorAll('.menu > .pressed').forEach((b) => { b.classList.remove('pressed') })\n ev.target.classList.add('pressed')\n this.updateLib(ev.target.dataset.menu)\n }\n break\n default:\n console.error('unknown nodeName for:', ev.target, ev.target.className)\n }\n }\n // capture event from slots\n svgEditor.$click(this, onClickHandler)\n svgEditor.$click(this.$menu, onClickHandler)\n svgEditor.$click(this.$lib, onClickHandler)\n svgEditor.$click(this.$handle, onClickHandler)\n }\n\n /**\n * @function updateLib\n * @param {string} lib\n * @returns {void}\n */\n async updateLib (lib) {\n const libDir = this.getAttribute('lib')\n try {\n // initialize buttons for all shapes defined for this library\n const response = await fetch(`${libDir}${lib}.json`)\n const json = await response.json()\n this.data = json.data\n const size = json.size ?? 300\n const fill = json.fill ? '#333' : 'none'\n const off = size * 0.05\n const vb = [-off, -off, size + off * 2, size + off * 2].join(' ')\n const stroke = json.fill ? 0 : (size / 30)\n this.$lib.innerHTML = Object.entries(this.data).map(([key, path]) => {\n const encoded = btoa(`\n \n \n `)\n return ``\n }).join('')\n } catch (error) {\n console.error(`could not read file:${libDir}${lib}.json`, error)\n }\n }\n}\n\n// Register\ncustomElements.define('se-explorerbutton', ExplorerButton)\n","/* globals svgEditor */\nconst template = document.createElement('template')\ntemplate.innerHTML = `\n \n
\n \"icon\"\n \n
\n
\n
\n
\n
\n \n
\n
\n
\n \n
\n`\n\nclass SeZoom extends HTMLElement {\n constructor () {\n super()\n\n this.handleMouseDown = this.handleMouseDown.bind(this)\n this.handleMouseUp = this.handleMouseUp.bind(this)\n this.handleKeyDown = this.handleKeyDown.bind(this)\n this.initPopup = this.initPopup.bind(this)\n this.handleInput = this.handleInput.bind(this)\n\n // create the shadowDom and insert the template\n this._shadowRoot = this.attachShadow({ mode: 'open' })\n // locate the component\n this._shadowRoot.append(template.content.cloneNode(true))\n\n // prepare the slot element\n this.slotElement = this._shadowRoot.querySelector('slot')\n this.slotElement.addEventListener(\n 'slotchange',\n this.handleOptionsChange.bind(this)\n )\n\n // hookup events for the input box\n this.inputElement = this._shadowRoot.querySelector('input')\n this.inputElement.addEventListener('click', this.handleClick.bind(this))\n this.inputElement.addEventListener('change', this.handleInput)\n this.inputElement.addEventListener('keydown', this.handleKeyDown)\n\n this.clickArea = this._shadowRoot.querySelector('#down')\n this.clickArea.addEventListener('click', this.handleClick.bind(this))\n\n this.imgPath = svgEditor.configObj.curConfig.imgPath\n\n this.downImageElement = this.clickArea.querySelector('img')\n this.downImageElement.setAttribute(\n 'src',\n (this.imgPath + '/' + this.downImageElement.getAttribute('src'))\n )\n\n // set src for imageElement\n this.imageElement = this._shadowRoot.querySelector('img')\n this.imageElement.setAttribute(\n 'src',\n (this.imgPath + '/' + this.getAttribute('src'))\n )\n\n // hookup events for arrow buttons\n this.arrowUp = this._shadowRoot.querySelector('#arrow-up')\n this.arrowUp.addEventListener('click', this.increment.bind(this))\n this.arrowUp.addEventListener('mousedown', e =>\n this.handleMouseDown('up', true)\n )\n this.arrowUp.addEventListener('mouseleave', e => this.handleMouseUp('up'))\n this.arrowUp.addEventListener('mouseup', e => this.handleMouseUp('up'))\n\n this.arrowDown = this._shadowRoot.querySelector('#arrow-down')\n this.arrowDown.addEventListener('click', this.decrement.bind(this))\n this.arrowDown.addEventListener('mousedown', e =>\n this.handleMouseDown('down', true)\n )\n this.arrowDown.addEventListener('mouseleave', e =>\n this.handleMouseUp('down')\n )\n this.arrowDown.addEventListener('mouseup', e => this.handleMouseUp('down'))\n\n this.optionsContainer = this._shadowRoot.querySelector(\n '#options-container'\n )\n\n // add an event listener to close the popup\n document.addEventListener('click', e => this.handleClose(e))\n this.changedTimeout = null\n }\n\n static get observedAttributes () {\n return ['value']\n }\n\n /**\n * @function get\n * @returns {any}\n */\n get value () {\n return this.getAttribute('value')\n }\n\n /**\n * @function set\n * @returns {void}\n */\n set value (value) {\n this.setAttribute('value', value)\n }\n\n /**\n * @function attributeChangedCallback\n * @param {string} name\n * @param {string} oldValue\n * @param {string} newValue\n * @returns {void}\n */\n attributeChangedCallback (name, oldValue, newValue) {\n if (oldValue === newValue) {\n switch (name) {\n case 'value':\n if (parseInt(this.inputElement.value) !== newValue) {\n this.inputElement.value = newValue\n }\n break\n }\n\n return\n }\n\n switch (name) {\n case 'value':\n this.inputElement.value = newValue\n this.dispatchEvent(\n new CustomEvent('change', { detail: { value: newValue } })\n )\n break\n }\n }\n\n /**\n * @function handleOptionsChange\n * @returns {void}\n */\n handleOptionsChange () {\n if (this.slotElement.assignedElements().length > 0) {\n this.options = this.slotElement.assignedElements()\n this.selectedValue = this.options[0].textContent\n\n this.initPopup()\n\n this.options.forEach(option => {\n option.addEventListener('click', e => this.handleSelect(e))\n })\n }\n }\n\n /**\n * @function handleClick\n * @returns {void}\n */\n handleClick () {\n this.optionsContainer.style.display = 'flex'\n this.inputElement.select()\n this.initPopup()\n }\n\n /**\n * @function handleSelect\n * @param {Event} e\n * @returns {void}\n */\n handleSelect (e) {\n this.value = e.target.getAttribute('value')\n this.title = e.target.getAttribute('text')\n }\n\n /**\n * @function handleShow\n * @returns {void}\n * initialises the popup menu position\n */\n initPopup () {\n const zoomPos = this.getBoundingClientRect()\n const popupPos = this.optionsContainer.getBoundingClientRect()\n const top = zoomPos.top - popupPos.height\n const left = zoomPos.left\n\n this.optionsContainer.style.position = 'fixed'\n this.optionsContainer.style.top = `${top}px`\n this.optionsContainer.style.left = `${left}px`\n }\n\n /**\n * @function handleClose\n * @param {Event} e\n * @returns {void}\n * Close the popup menu\n */\n handleClose (e) {\n if (e.target !== this) {\n this.optionsContainer.style.display = 'none'\n this.inputElement.blur()\n }\n }\n\n /**\n * @function handleInput\n * @returns {void}\n */\n handleInput () {\n if (this.changedTimeout) {\n clearTimeout(this.changedTimeout)\n }\n\n this.changedTimeout = setTimeout(this.triggerInputChanged.bind(this), 500)\n }\n\n /**\n * @function triggerInputChanged\n * @returns {void}\n */\n triggerInputChanged () {\n const newValue = this.inputElement.value\n this.value = newValue\n }\n\n /**\n * @function increment\n * @returns {void}\n */\n increment () {\n this.value = parseInt(this.value) + 10\n }\n\n /**\n * @function decrement\n * @returns {void}\n */\n decrement () {\n if (this.value - 10 <= 0) {\n this.value = 10\n } else {\n this.value = parseInt(this.value) - 10\n }\n }\n\n /**\n * @function handleMouseDown\n * @param {string} dir\n * @param {boolean} isFirst\n * @returns {void}\n * Increment/Decrement on mouse held down, if its the first call add a delay before starting\n */\n handleMouseDown (dir, isFirst) {\n if (dir === 'up') {\n this.incrementHold = true\n !isFirst && this.increment()\n\n setTimeout(\n () => {\n if (this.incrementHold) {\n this.handleMouseDown(dir, false)\n }\n },\n isFirst ? 500 : 50\n )\n } else if (dir === 'down') {\n this.decrementHold = true\n !isFirst && this.decrement()\n\n setTimeout(\n () => {\n if (this.decrementHold) {\n this.handleMouseDown(dir, false)\n }\n },\n isFirst ? 500 : 50\n )\n }\n }\n\n /**\n * @function handleMouseUp\n * @param {string} dir\n * @returns {void}\n */\n handleMouseUp (dir) {\n if (dir === 'up') {\n this.incrementHold = false\n } else {\n this.decrementHold = false\n }\n }\n\n /**\n * @function handleKeyDown\n * @param {Event} e\n * @returns {void}\n */\n handleKeyDown (e) {\n if (e.key === 'ArrowUp') {\n this.increment()\n } else if (e.key === 'ArrowDown') {\n this.decrement()\n }\n }\n}\n\n// Register\ncustomElements.define('se-zoom', SeZoom)\n","/**\n * JavaScript template literals for constructing DOM nodes from HTML\n *\n * @module html\n */\n\n/**\n * A JavaScript template string literal that returns an HTML document fragment.\n *\n * Example:\n *\n * const fragment = fragmentFrom.html`Hello, world.`\n *\n * returns a `DocumentFragment` whose `innerHTML` is `Hello, world.`\n *\n * This function is called `html` so that it can be easily used with HTML\n * syntax-highlighting extensions for various popular code editors.\n *\n * See also [templateFrom.html](template#html), which returns a similar result but\n * as an HTMLTemplateElement.\n *\n * @param {TemplateStringsArray} strings - the strings passed to the JavaScript template\n * literal\n * @param {string[]} substitutions - the variable values passed to the\n * JavaScript template literal\n * @returns {DocumentFragment}\n */\nexport const fragmentFrom = {\n html(strings, ...substitutions) {\n return templateFrom.html(strings, ...substitutions).content;\n },\n};\n\n/**\n * A JavaScript template string literal that returns an HTML template.\n *\n * Example:\n *\n * const myTemplate = templateFrom.html`Hello, world.`\n *\n * returns an `HTMLTemplateElement` whose `innerHTML` is `Hello, world.`\n *\n * This function is called `html` so that it can be easily used with HTML\n * syntax-highlighting extensions for various popular code editors.\n *\n * See also [html](html), a helper which returns a similar result but as an\n * DocumentFragment.\n *\n * @param {TemplateStringsArray} strings - the strings passed to the JavaScript template\n * literal\n * @param {string[]} substitutions - the variable values passed to the\n * JavaScript template literal\n * @returns {HTMLTemplateElement}\n */\nexport const templateFrom = {\n html(strings, ...substitutions) {\n const template = document.createElement(\"template\");\n template.innerHTML = String.raw(strings, ...substitutions);\n return template;\n },\n};\n","/**\n * Collection of shared Symbol objects for internal component communication.\n *\n * The shared `Symbol` objects in this module let mixins and a component\n * internally communicate without exposing these internal properties and methods\n * in the component's public API. They also help avoid unintentional name\n * collisions, as a component developer must specifically import the `internal`\n * module and reference one of its symbols.\n *\n * To use these `Symbol` objects in your own component, include this module and\n * then create a property or method whose key is the desired Symbol. E.g.,\n * [ShadowTemplateMixin](ShadowTemplateMixin) expects a component to define\n * a property called [template](#template):\n *\n * import { template } from 'elix/src/core/internal.js';\n * import { templateFrom } from 'elix/src/core/htmlLiterals.js'\n * import ShadowTemplateMixin from 'elix/src/core/ShadowTemplateMixin.js';\n *\n * class MyElement extends ShadowTemplateMixin(HTMLElement) {\n * [template]() {\n * return templateFrom.html`Hello, world.`;\n * }\n * }\n *\n * The above use of the internal `template` member lets the mixin find the\n * component's template in a way that will not pollute the component's public\n * API or interfere with other component logic. For example, if for some reason\n * the component wants to define a separate property with the plain string name,\n * \"template\", it can do so without affecting the above property setter.\n *\n * @module internal\n */\n\n/**\n * Symbol for the default state for this element.\n */\nexport const defaultState = Symbol(\"defaultState\");\n\n/**\n * Symbol for the `delegatesFocus` property.\n *\n * [DelegatesFocusMixin](DelegatesFocusMixin) defines this property, returning\n * true to indicate that the focus is being delegated, even in browsers that\n * don't support that natively. Mixins like [KeyboardMixin](KeyboardMixin) use\n * this to accommodate focus delegation.\n */\nexport const delegatesFocus = Symbol(\"delegatesFocus\");\n\n/**\n * Symbol for the `firstRender` property.\n *\n * [ReactiveMixin](ReactiveMixin) sets the property to `true` during the\n * element's first `render` and `rendered` callback, then `false` in subsequent\n * callbacks.\n *\n * You can inspect this property in your own `rendered` callback handler to do\n * work like wiring up events that should only happen once.\n */\nexport const firstRender = Symbol(\"firstRender\");\n\n/**\n * Symbol for the `focusTarget` property.\n *\n * [DelegatesFocusMixin](DelegatesFocusMixin) defines this property as either:\n * 1) the element itself, in browsers that support native focus delegation or,\n * 2) the shadow root's first focusable element.\n */\nexport const focusTarget = Symbol(\"focusTarget\");\n\n/**\n * Symbol for the `hasDynamicTemplate` property.\n *\n * If your component class does not always use the same template, define a\n * static class property getter with this symbol and have it return `true`.\n * This will disable template caching for your component.\n */\nexport const hasDynamicTemplate = Symbol(\"hasDynamicTemplate\");\n\n/**\n * Symbol for the `ids` property.\n *\n * [ShadowTemplateMixin](ShadowTemplateMixin) defines a shorthand function\n * `internal.ids` that can be used to obtain a reference to a shadow element with\n * a given ID.\n *\n * Example: if component's template contains a shadow element\n * `