{"version":3,"file":"login-dev.js","sources":["webpack:///webpack/bootstrap","webpack:///../ewars/ewars/static/vendor/Font-Awesome-master/css/font-awesome.min.css?766e","webpack:///./common/Tags.react.js","webpack:///./common/c.action_button.js","webpack:///./common/c.app.js","webpack:///./common/c.button.js","webpack:///./common/c.button_group.js","webpack:///./common/c.button_set.js","webpack:///./common/c.cmp.button.js","webpack:///./common/c.cmp.checkbox.js","webpack:///./common/c.cmp.data_source_drop.js","webpack:///./common/c.cmp.data_source_tree.js","webpack:///./common/c.cmp.date_range_selector.js","webpack:///./common/c.cmp.rules.js","webpack:///./common/c.cmp.select.js","webpack:///./common/c.cmp.sources.js","webpack:///./common/c.cmp.text.js","webpack:///./common/c.collapser.js","webpack:///./common/c.context_menu.js","webpack:///./common/c.control.js","webpack:///./common/c.editable_list.js","webpack:///./common/c.editor.language.js","webpack:///./common/c.filler.js","webpack:///./common/c.form.js","webpack:///./common/c.form.settings.field.js","webpack:///./common/c.form.settings.js","webpack:///./common/c.form.settings.section.js","webpack:///./common/c.form.system.js","webpack:///./common/c.form_field.js","webpack:///./common/c.link.js","webpack:///./common/c.list.js","webpack:///./common/c.map.js","webpack:///./common/c.menu.dropdown.js","webpack:///./common/c.modal.js","webpack:///./common/c.option_set.js","webpack:///./common/c.panel.js","webpack:///./common/c.period_selector.js","webpack:///./common/c.prompt.js","webpack:///./common/c.report_browser.js","webpack:///./common/c.shade.js","webpack:///./common/c.spinner.js","webpack:///./common/c.tab.js","webpack:///./common/c.tab.vertical.js","webpack:///./common/c.toolbar.js","webpack:///./common/cmp/fields/AssignmentSelector.js","webpack:///./common/constants.js","webpack:///./common/constants/field_definition.js","webpack:///./common/datatable/c.datatable.cell.js","webpack:///./common/datatable/c.datatable.filter_control.js","webpack:///./common/datatable/c.datatable.header_cell.js","webpack:///./common/datatable/c.datatable.js","webpack:///./common/datatable/r.reducer.js","webpack:///./common/editors/form_definition/FieldSelector.js","webpack:///./common/editors/logic/Complex.js","webpack:///./common/editors/logic/Set.js","webpack:///./common/editors/logic/SetItem.js","webpack:///./common/editors/widgets/_shared/ComplexSourcesManager.react.js","webpack:///./common/fields/c.conditions.row.js","webpack:///./common/fields/c.date.day.js","webpack:///./common/fields/c.date.display.js","webpack:///./common/fields/c.date.month.js","webpack:///./common/fields/c.date.week.js","webpack:///./common/fields/c.date.year.js","webpack:///./common/fields/c.tree.form_fields.js","webpack:///./common/fields/f.assignment.js","webpack:///./common/fields/f.button_group.js","webpack:///./common/fields/f.calc_field_definition.js","webpack:///./common/fields/f.colour.js","webpack:///./common/fields/f.colour_thresholds.js","webpack:///./common/fields/f.conditions.js","webpack:///./common/fields/f.date.js","webpack:///./common/fields/f.display.calculated.js","webpack:///./common/fields/f.display.js","webpack:///./common/fields/f.dom_size_field.js","webpack:///./common/fields/f.file.js","webpack:///./common/fields/f.file_upload.js","webpack:///./common/fields/f.form_field.js","webpack:///./common/fields/f.form_field_condition.js","webpack:///./common/fields/f.form_field_select.js","webpack:///./common/fields/f.geometry.js","webpack:///./common/fields/f.header.js","webpack:///./common/fields/f.html.js","webpack:///./common/fields/f.indicator.js","webpack:///./common/fields/f.indicator_definition.js","webpack:///./common/fields/f.indicator_related_forms.js","webpack:///./common/fields/f.language_string.js","webpack:///./common/fields/f.lat_lng.js","webpack:///./common/fields/f.linked_lists.js","webpack:///./common/fields/f.location.js","webpack:///./common/fields/f.location_group.js","webpack:///./common/fields/f.location_input.js","webpack:///./common/fields/f.main_form_field.js","webpack:///./common/fields/f.margin.js","webpack:///./common/fields/f.matrix.cell.js","webpack:///./common/fields/f.matrix.js","webpack:///./common/fields/f.matrix.row.js","webpack:///./common/fields/f.media.content.js","webpack:///./common/fields/f.multi_select.js","webpack:///./common/fields/f.multiple_alarm.js","webpack:///./common/fields/f.multiple_location.js","webpack:///./common/fields/f.not_implemented.js","webpack:///./common/fields/f.numeric.js","webpack:///./common/fields/f.password.js","webpack:///./common/fields/f.point.js","webpack:///./common/fields/f.row.js","webpack:///./common/fields/f.searchfield.js","webpack:///./common/fields/f.select.form.field.options.js","webpack:///./common/fields/f.select.js","webpack:///./common/fields/f.slug.js","webpack:///./common/fields/f.switch.js","webpack:///./common/fields/f.text.js","webpack:///./common/fields/f.textarea.js","webpack:///./common/fields/f.time.js","webpack:///./common/fields/f.topojson.js","webpack:///./common/fields/f.total_formula_helper.js","webpack:///./common/fields/f.value_mapper.js","webpack:///./common/fields/index.js","webpack:///./common/fields/indicator/c.indicator.node.js","webpack:///./common/fields/indicator/c.indicator.tree.js","webpack:///./common/forms/form.source.variable.js","webpack:///./common/forms/indicators/ALERTS.js","webpack:///./common/forms/indicators/ASSIGNMENTS.js","webpack:///./common/forms/indicators/DEVICES.js","webpack:///./common/forms/indicators/FORMS.js","webpack:///./common/forms/indicators/FORM_SUBMISSIONS.js","webpack:///./common/forms/indicators/LOCATIONS.js","webpack:///./common/forms/indicators/OLD_ALERTS.js","webpack:///./common/forms/indicators/TASKS.js","webpack:///./common/forms/indicators/USERS.js","webpack:///./common/forms/indicators/index.js","webpack:///./common/index.js","webpack:///./common/layout.js","webpack:///./common/utils/DateUtils.js","webpack:///./common/utils/FormUtils.js","webpack:///./common/utils/RangeUtils.js","webpack:///./common/utils/User.js","webpack:///./documents/utils/DateUtils.js","webpack:///./ewars/app.js","webpack:///./ewars/components/Blocker.js","webpack:///./ewars/components/Confirmation.js","webpack:///./ewars/components/idle-timer.js","webpack:///./ewars/components/locker.js","webpack:///./ewars/components/notifications.js","webpack:///./ewars/components/prompt.js","webpack:///./ewars/lang/en.js","webpack:///./ewars/lib/combi.js","webpack:///./ewars/utils/cache.js","webpack:///./ewars/utils/formatters.js","webpack:///./ewars/utils/general.js","webpack:///./login/app.js","webpack:///./login/components/Component.react.js","webpack:///./node_modules/@babel/polyfill/lib/index.js","webpack:///./node_modules/@babel/polyfill/lib/noConflict.js","webpack:///./node_modules/@babel/runtime/helpers/arrayWithHoles.js","webpack:///./node_modules/@babel/runtime/helpers/assertThisInitialized.js","webpack:///./node_modules/@babel/runtime/helpers/asyncToGenerator.js","webpack:///./node_modules/@babel/runtime/helpers/classCallCheck.js","webpack:///./node_modules/@babel/runtime/helpers/createClass.js","webpack:///./node_modules/@babel/runtime/helpers/getPrototypeOf.js","webpack:///./node_modules/@babel/runtime/helpers/inherits.js","webpack:///./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js","webpack:///./node_modules/@babel/runtime/helpers/nonIterableRest.js","webpack:///./node_modules/@babel/runtime/helpers/possibleConstructorReturn.js","webpack:///./node_modules/@babel/runtime/helpers/setPrototypeOf.js","webpack:///./node_modules/@babel/runtime/helpers/slicedToArray.js","webpack:///./node_modules/@babel/runtime/helpers/typeof.js","webpack:///./node_modules/@babel/runtime/regenerator/index.js","webpack:///./node_modules/chroma-js/chroma.js","webpack:///./node_modules/codemirror/lib/codemirror.js","webpack:///./node_modules/core-js/es6/index.js","webpack:///./node_modules/core-js/fn/array/flat-map.js","webpack:///./node_modules/core-js/fn/array/includes.js","webpack:///./node_modules/core-js/fn/object/entries.js","webpack:///./node_modules/core-js/fn/object/get-own-property-descriptors.js","webpack:///./node_modules/core-js/fn/object/values.js","webpack:///./node_modules/core-js/fn/promise/finally.js","webpack:///./node_modules/core-js/fn/string/pad-end.js","webpack:///./node_modules/core-js/fn/string/pad-start.js","webpack:///./node_modules/core-js/fn/string/trim-end.js","webpack:///./node_modules/core-js/fn/string/trim-start.js","webpack:///./node_modules/core-js/fn/symbol/async-iterator.js","webpack:///./node_modules/core-js/library/fn/global.js","webpack:///./node_modules/core-js/library/modules/_a-function.js","webpack:///./node_modules/core-js/library/modules/_an-object.js","webpack:///./node_modules/core-js/library/modules/_core.js","webpack:///./node_modules/core-js/library/modules/_ctx.js","webpack:///./node_modules/core-js/library/modules/_descriptors.js","webpack:///./node_modules/core-js/library/modules/_dom-create.js","webpack:///./node_modules/core-js/library/modules/_export.js","webpack:///./node_modules/core-js/library/modules/_fails.js","webpack:///./node_modules/core-js/library/modules/_global.js","webpack:///./node_modules/core-js/library/modules/_has.js","webpack:///./node_modules/core-js/library/modules/_hide.js","webpack:///./node_modules/core-js/library/modules/_ie8-dom-define.js","webpack:///./node_modules/core-js/library/modules/_is-object.js","webpack:///./node_modules/core-js/library/modules/_object-dp.js","webpack:///./node_modules/core-js/library/modules/_property-desc.js","webpack:///./node_modules/core-js/library/modules/_to-primitive.js","webpack:///./node_modules/core-js/library/modules/es7.global.js","webpack:///./node_modules/core-js/modules/_a-function.js","webpack:///./node_modules/core-js/modules/_a-number-value.js","webpack:///./node_modules/core-js/modules/_add-to-unscopables.js","webpack:///./node_modules/core-js/modules/_advance-string-index.js","webpack:///./node_modules/core-js/modules/_an-instance.js","webpack:///./node_modules/core-js/modules/_an-object.js","webpack:///./node_modules/core-js/modules/_array-copy-within.js","webpack:///./node_modules/core-js/modules/_array-fill.js","webpack:///./node_modules/core-js/modules/_array-includes.js","webpack:///./node_modules/core-js/modules/_array-methods.js","webpack:///./node_modules/core-js/modules/_array-reduce.js","webpack:///./node_modules/core-js/modules/_array-species-constructor.js","webpack:///./node_modules/core-js/modules/_array-species-create.js","webpack:///./node_modules/core-js/modules/_bind.js","webpack:///./node_modules/core-js/modules/_classof.js","webpack:///./node_modules/core-js/modules/_cof.js","webpack:///./node_modules/core-js/modules/_collection-strong.js","webpack:///./node_modules/core-js/modules/_collection-weak.js","webpack:///./node_modules/core-js/modules/_collection.js","webpack:///./node_modules/core-js/modules/_core.js","webpack:///./node_modules/core-js/modules/_create-property.js","webpack:///./node_modules/core-js/modules/_ctx.js","webpack:///./node_modules/core-js/modules/_date-to-iso-string.js","webpack:///./node_modules/core-js/modules/_date-to-primitive.js","webpack:///./node_modules/core-js/modules/_defined.js","webpack:///./node_modules/core-js/modules/_descriptors.js","webpack:///./node_modules/core-js/modules/_dom-create.js","webpack:///./node_modules/core-js/modules/_enum-bug-keys.js","webpack:///./node_modules/core-js/modules/_enum-keys.js","webpack:///./node_modules/core-js/modules/_export.js","webpack:///./node_modules/core-js/modules/_fails-is-regexp.js","webpack:///./node_modules/core-js/modules/_fails.js","webpack:///./node_modules/core-js/modules/_fix-re-wks.js","webpack:///./node_modules/core-js/modules/_flags.js","webpack:///./node_modules/core-js/modules/_flatten-into-array.js","webpack:///./node_modules/core-js/modules/_for-of.js","webpack:///./node_modules/core-js/modules/_function-to-string.js","webpack:///./node_modules/core-js/modules/_global.js","webpack:///./node_modules/core-js/modules/_has.js","webpack:///./node_modules/core-js/modules/_hide.js","webpack:///./node_modules/core-js/modules/_html.js","webpack:///./node_modules/core-js/modules/_ie8-dom-define.js","webpack:///./node_modules/core-js/modules/_inherit-if-required.js","webpack:///./node_modules/core-js/modules/_invoke.js","webpack:///./node_modules/core-js/modules/_iobject.js","webpack:///./node_modules/core-js/modules/_is-array-iter.js","webpack:///./node_modules/core-js/modules/_is-array.js","webpack:///./node_modules/core-js/modules/_is-integer.js","webpack:///./node_modules/core-js/modules/_is-object.js","webpack:///./node_modules/core-js/modules/_is-regexp.js","webpack:///./node_modules/core-js/modules/_iter-call.js","webpack:///./node_modules/core-js/modules/_iter-create.js","webpack:///./node_modules/core-js/modules/_iter-define.js","webpack:///./node_modules/core-js/modules/_iter-detect.js","webpack:///./node_modules/core-js/modules/_iter-step.js","webpack:///./node_modules/core-js/modules/_iterators.js","webpack:///./node_modules/core-js/modules/_library.js","webpack:///./node_modules/core-js/modules/_math-expm1.js","webpack:///./node_modules/core-js/modules/_math-fround.js","webpack:///./node_modules/core-js/modules/_math-log1p.js","webpack:///./node_modules/core-js/modules/_math-sign.js","webpack:///./node_modules/core-js/modules/_meta.js","webpack:///./node_modules/core-js/modules/_microtask.js","webpack:///./node_modules/core-js/modules/_new-promise-capability.js","webpack:///./node_modules/core-js/modules/_object-assign.js","webpack:///./node_modules/core-js/modules/_object-create.js","webpack:///./node_modules/core-js/modules/_object-dp.js","webpack:///./node_modules/core-js/modules/_object-dps.js","webpack:///./node_modules/core-js/modules/_object-gopd.js","webpack:///./node_modules/core-js/modules/_object-gopn-ext.js","webpack:///./node_modules/core-js/modules/_object-gopn.js","webpack:///./node_modules/core-js/modules/_object-gops.js","webpack:///./node_modules/core-js/modules/_object-gpo.js","webpack:///./node_modules/core-js/modules/_object-keys-internal.js","webpack:///./node_modules/core-js/modules/_object-keys.js","webpack:///./node_modules/core-js/modules/_object-pie.js","webpack:///./node_modules/core-js/modules/_object-sap.js","webpack:///./node_modules/core-js/modules/_object-to-array.js","webpack:///./node_modules/core-js/modules/_own-keys.js","webpack:///./node_modules/core-js/modules/_parse-float.js","webpack:///./node_modules/core-js/modules/_parse-int.js","webpack:///./node_modules/core-js/modules/_perform.js","webpack:///./node_modules/core-js/modules/_promise-resolve.js","webpack:///./node_modules/core-js/modules/_property-desc.js","webpack:///./node_modules/core-js/modules/_redefine-all.js","webpack:///./node_modules/core-js/modules/_redefine.js","webpack:///./node_modules/core-js/modules/_regexp-exec-abstract.js","webpack:///./node_modules/core-js/modules/_regexp-exec.js","webpack:///./node_modules/core-js/modules/_same-value.js","webpack:///./node_modules/core-js/modules/_set-proto.js","webpack:///./node_modules/core-js/modules/_set-species.js","webpack:///./node_modules/core-js/modules/_set-to-string-tag.js","webpack:///./node_modules/core-js/modules/_shared-key.js","webpack:///./node_modules/core-js/modules/_shared.js","webpack:///./node_modules/core-js/modules/_species-constructor.js","webpack:///./node_modules/core-js/modules/_strict-method.js","webpack:///./node_modules/core-js/modules/_string-at.js","webpack:///./node_modules/core-js/modules/_string-context.js","webpack:///./node_modules/core-js/modules/_string-html.js","webpack:///./node_modules/core-js/modules/_string-pad.js","webpack:///./node_modules/core-js/modules/_string-repeat.js","webpack:///./node_modules/core-js/modules/_string-trim.js","webpack:///./node_modules/core-js/modules/_string-ws.js","webpack:///./node_modules/core-js/modules/_task.js","webpack:///./node_modules/core-js/modules/_to-absolute-index.js","webpack:///./node_modules/core-js/modules/_to-index.js","webpack:///./node_modules/core-js/modules/_to-integer.js","webpack:///./node_modules/core-js/modules/_to-iobject.js","webpack:///./node_modules/core-js/modules/_to-length.js","webpack:///./node_modules/core-js/modules/_to-object.js","webpack:///./node_modules/core-js/modules/_to-primitive.js","webpack:///./node_modules/core-js/modules/_typed-array.js","webpack:///./node_modules/core-js/modules/_typed-buffer.js","webpack:///./node_modules/core-js/modules/_typed.js","webpack:///./node_modules/core-js/modules/_uid.js","webpack:///./node_modules/core-js/modules/_user-agent.js","webpack:///./node_modules/core-js/modules/_validate-collection.js","webpack:///./node_modules/core-js/modules/_wks-define.js","webpack:///./node_modules/core-js/modules/_wks-ext.js","webpack:///./node_modules/core-js/modules/_wks.js","webpack:///./node_modules/core-js/modules/core.get-iterator-method.js","webpack:///./node_modules/core-js/modules/es6.array.copy-within.js","webpack:///./node_modules/core-js/modules/es6.array.every.js","webpack:///./node_modules/core-js/modules/es6.array.fill.js","webpack:///./node_modules/core-js/modules/es6.array.filter.js","webpack:///./node_modules/core-js/modules/es6.array.find-index.js","webpack:///./node_modules/core-js/modules/es6.array.find.js","webpack:///./node_modules/core-js/modules/es6.array.for-each.js","webpack:///./node_modules/core-js/modules/es6.array.from.js","webpack:///./node_modules/core-js/modules/es6.array.index-of.js","webpack:///./node_modules/core-js/modules/es6.array.is-array.js","webpack:///./node_modules/core-js/modules/es6.array.iterator.js","webpack:///./node_modules/core-js/modules/es6.array.join.js","webpack:///./node_modules/core-js/modules/es6.array.last-index-of.js","webpack:///./node_modules/core-js/modules/es6.array.map.js","webpack:///./node_modules/core-js/modules/es6.array.of.js","webpack:///./node_modules/core-js/modules/es6.array.reduce-right.js","webpack:///./node_modules/core-js/modules/es6.array.reduce.js","webpack:///./node_modules/core-js/modules/es6.array.slice.js","webpack:///./node_modules/core-js/modules/es6.array.some.js","webpack:///./node_modules/core-js/modules/es6.array.sort.js","webpack:///./node_modules/core-js/modules/es6.array.species.js","webpack:///./node_modules/core-js/modules/es6.date.now.js","webpack:///./node_modules/core-js/modules/es6.date.to-iso-string.js","webpack:///./node_modules/core-js/modules/es6.date.to-json.js","webpack:///./node_modules/core-js/modules/es6.date.to-primitive.js","webpack:///./node_modules/core-js/modules/es6.date.to-string.js","webpack:///./node_modules/core-js/modules/es6.function.bind.js","webpack:///./node_modules/core-js/modules/es6.function.has-instance.js","webpack:///./node_modules/core-js/modules/es6.function.name.js","webpack:///./node_modules/core-js/modules/es6.map.js","webpack:///./node_modules/core-js/modules/es6.math.acosh.js","webpack:///./node_modules/core-js/modules/es6.math.asinh.js","webpack:///./node_modules/core-js/modules/es6.math.atanh.js","webpack:///./node_modules/core-js/modules/es6.math.cbrt.js","webpack:///./node_modules/core-js/modules/es6.math.clz32.js","webpack:///./node_modules/core-js/modules/es6.math.cosh.js","webpack:///./node_modules/core-js/modules/es6.math.expm1.js","webpack:///./node_modules/core-js/modules/es6.math.fround.js","webpack:///./node_modules/core-js/modules/es6.math.hypot.js","webpack:///./node_modules/core-js/modules/es6.math.imul.js","webpack:///./node_modules/core-js/modules/es6.math.log10.js","webpack:///./node_modules/core-js/modules/es6.math.log1p.js","webpack:///./node_modules/core-js/modules/es6.math.log2.js","webpack:///./node_modules/core-js/modules/es6.math.sign.js","webpack:///./node_modules/core-js/modules/es6.math.sinh.js","webpack:///./node_modules/core-js/modules/es6.math.tanh.js","webpack:///./node_modules/core-js/modules/es6.math.trunc.js","webpack:///./node_modules/core-js/modules/es6.number.constructor.js","webpack:///./node_modules/core-js/modules/es6.number.epsilon.js","webpack:///./node_modules/core-js/modules/es6.number.is-finite.js","webpack:///./node_modules/core-js/modules/es6.number.is-integer.js","webpack:///./node_modules/core-js/modules/es6.number.is-nan.js","webpack:///./node_modules/core-js/modules/es6.number.is-safe-integer.js","webpack:///./node_modules/core-js/modules/es6.number.max-safe-integer.js","webpack:///./node_modules/core-js/modules/es6.number.min-safe-integer.js","webpack:///./node_modules/core-js/modules/es6.number.parse-float.js","webpack:///./node_modules/core-js/modules/es6.number.parse-int.js","webpack:///./node_modules/core-js/modules/es6.number.to-fixed.js","webpack:///./node_modules/core-js/modules/es6.number.to-precision.js","webpack:///./node_modules/core-js/modules/es6.object.assign.js","webpack:///./node_modules/core-js/modules/es6.object.create.js","webpack:///./node_modules/core-js/modules/es6.object.define-properties.js","webpack:///./node_modules/core-js/modules/es6.object.define-property.js","webpack:///./node_modules/core-js/modules/es6.object.freeze.js","webpack:///./node_modules/core-js/modules/es6.object.get-own-property-descriptor.js","webpack:///./node_modules/core-js/modules/es6.object.get-own-property-names.js","webpack:///./node_modules/core-js/modules/es6.object.get-prototype-of.js","webpack:///./node_modules/core-js/modules/es6.object.is-extensible.js","webpack:///./node_modules/core-js/modules/es6.object.is-frozen.js","webpack:///./node_modules/core-js/modules/es6.object.is-sealed.js","webpack:///./node_modules/core-js/modules/es6.object.is.js","webpack:///./node_modules/core-js/modules/es6.object.keys.js","webpack:///./node_modules/core-js/modules/es6.object.prevent-extensions.js","webpack:///./node_modules/core-js/modules/es6.object.seal.js","webpack:///./node_modules/core-js/modules/es6.object.set-prototype-of.js","webpack:///./node_modules/core-js/modules/es6.object.to-string.js","webpack:///./node_modules/core-js/modules/es6.parse-float.js","webpack:///./node_modules/core-js/modules/es6.parse-int.js","webpack:///./node_modules/core-js/modules/es6.promise.js","webpack:///./node_modules/core-js/modules/es6.reflect.apply.js","webpack:///./node_modules/core-js/modules/es6.reflect.construct.js","webpack:///./node_modules/core-js/modules/es6.reflect.define-property.js","webpack:///./node_modules/core-js/modules/es6.reflect.delete-property.js","webpack:///./node_modules/core-js/modules/es6.reflect.enumerate.js","webpack:///./node_modules/core-js/modules/es6.reflect.get-own-property-descriptor.js","webpack:///./node_modules/core-js/modules/es6.reflect.get-prototype-of.js","webpack:///./node_modules/core-js/modules/es6.reflect.get.js","webpack:///./node_modules/core-js/modules/es6.reflect.has.js","webpack:///./node_modules/core-js/modules/es6.reflect.is-extensible.js","webpack:///./node_modules/core-js/modules/es6.reflect.own-keys.js","webpack:///./node_modules/core-js/modules/es6.reflect.prevent-extensions.js","webpack:///./node_modules/core-js/modules/es6.reflect.set-prototype-of.js","webpack:///./node_modules/core-js/modules/es6.reflect.set.js","webpack:///./node_modules/core-js/modules/es6.regexp.constructor.js","webpack:///./node_modules/core-js/modules/es6.regexp.exec.js","webpack:///./node_modules/core-js/modules/es6.regexp.flags.js","webpack:///./node_modules/core-js/modules/es6.regexp.match.js","webpack:///./node_modules/core-js/modules/es6.regexp.replace.js","webpack:///./node_modules/core-js/modules/es6.regexp.search.js","webpack:///./node_modules/core-js/modules/es6.regexp.split.js","webpack:///./node_modules/core-js/modules/es6.regexp.to-string.js","webpack:///./node_modules/core-js/modules/es6.set.js","webpack:///./node_modules/core-js/modules/es6.string.anchor.js","webpack:///./node_modules/core-js/modules/es6.string.big.js","webpack:///./node_modules/core-js/modules/es6.string.blink.js","webpack:///./node_modules/core-js/modules/es6.string.bold.js","webpack:///./node_modules/core-js/modules/es6.string.code-point-at.js","webpack:///./node_modules/core-js/modules/es6.string.ends-with.js","webpack:///./node_modules/core-js/modules/es6.string.fixed.js","webpack:///./node_modules/core-js/modules/es6.string.fontcolor.js","webpack:///./node_modules/core-js/modules/es6.string.fontsize.js","webpack:///./node_modules/core-js/modules/es6.string.from-code-point.js","webpack:///./node_modules/core-js/modules/es6.string.includes.js","webpack:///./node_modules/core-js/modules/es6.string.italics.js","webpack:///./node_modules/core-js/modules/es6.string.iterator.js","webpack:///./node_modules/core-js/modules/es6.string.link.js","webpack:///./node_modules/core-js/modules/es6.string.raw.js","webpack:///./node_modules/core-js/modules/es6.string.repeat.js","webpack:///./node_modules/core-js/modules/es6.string.small.js","webpack:///./node_modules/core-js/modules/es6.string.starts-with.js","webpack:///./node_modules/core-js/modules/es6.string.strike.js","webpack:///./node_modules/core-js/modules/es6.string.sub.js","webpack:///./node_modules/core-js/modules/es6.string.sup.js","webpack:///./node_modules/core-js/modules/es6.string.trim.js","webpack:///./node_modules/core-js/modules/es6.symbol.js","webpack:///./node_modules/core-js/modules/es6.typed.array-buffer.js","webpack:///./node_modules/core-js/modules/es6.typed.data-view.js","webpack:///./node_modules/core-js/modules/es6.typed.float32-array.js","webpack:///./node_modules/core-js/modules/es6.typed.float64-array.js","webpack:///./node_modules/core-js/modules/es6.typed.int16-array.js","webpack:///./node_modules/core-js/modules/es6.typed.int32-array.js","webpack:///./node_modules/core-js/modules/es6.typed.int8-array.js","webpack:///./node_modules/core-js/modules/es6.typed.uint16-array.js","webpack:///./node_modules/core-js/modules/es6.typed.uint32-array.js","webpack:///./node_modules/core-js/modules/es6.typed.uint8-array.js","webpack:///./node_modules/core-js/modules/es6.typed.uint8-clamped-array.js","webpack:///./node_modules/core-js/modules/es6.weak-map.js","webpack:///./node_modules/core-js/modules/es6.weak-set.js","webpack:///./node_modules/core-js/modules/es7.array.flat-map.js","webpack:///./node_modules/core-js/modules/es7.array.includes.js","webpack:///./node_modules/core-js/modules/es7.object.entries.js","webpack:///./node_modules/core-js/modules/es7.object.get-own-property-descriptors.js","webpack:///./node_modules/core-js/modules/es7.object.values.js","webpack:///./node_modules/core-js/modules/es7.promise.finally.js","webpack:///./node_modules/core-js/modules/es7.string.pad-end.js","webpack:///./node_modules/core-js/modules/es7.string.pad-start.js","webpack:///./node_modules/core-js/modules/es7.string.trim-left.js","webpack:///./node_modules/core-js/modules/es7.string.trim-right.js","webpack:///./node_modules/core-js/modules/es7.symbol.async-iterator.js","webpack:///./node_modules/core-js/modules/web.dom.iterable.js","webpack:///./node_modules/core-js/modules/web.immediate.js","webpack:///./node_modules/core-js/modules/web.timers.js","webpack:///./node_modules/core-js/web/index.js","webpack:///../src/lib/css-tag.ts","webpack:///../src/lib/decorators.ts","webpack:///../src/lib/updating-element.ts","webpack:///src/lit-element.ts","webpack:///../src/lib/default-template-processor.ts","webpack:///../src/lib/directive.ts","webpack:///../src/lib/dom.ts","webpack:///../src/lib/modify-template.ts","webpack:///../src/lib/part.ts","webpack:///../src/lib/parts.ts","webpack:///../src/lib/render.ts","webpack:///../src/lib/shady-render.ts","webpack:///../src/lib/template-factory.ts","webpack:///../src/lib/template-instance.ts","webpack:///../src/lib/template-result.ts","webpack:///../src/lib/template.ts","webpack:///src/lit-html.ts","webpack:///../node_modules/@mapbox/unitbezier/index.js","webpack:///./node_modules/moment/locale sync ^\\.\\/.*$","webpack:///./node_modules/moment/locale/af.js","webpack:///./node_modules/moment/locale/ar-dz.js","webpack:///./node_modules/moment/locale/ar-kw.js","webpack:///./node_modules/moment/locale/ar-ly.js","webpack:///./node_modules/moment/locale/ar-ma.js","webpack:///./node_modules/moment/locale/ar-sa.js","webpack:///./node_modules/moment/locale/ar-tn.js","webpack:///./node_modules/moment/locale/ar.js","webpack:///./node_modules/moment/locale/az.js","webpack:///./node_modules/moment/locale/be.js","webpack:///./node_modules/moment/locale/bg.js","webpack:///./node_modules/moment/locale/bm.js","webpack:///./node_modules/moment/locale/bn.js","webpack:///./node_modules/moment/locale/bo.js","webpack:///./node_modules/moment/locale/br.js","webpack:///./node_modules/moment/locale/bs.js","webpack:///./node_modules/moment/locale/ca.js","webpack:///./node_modules/moment/locale/cs.js","webpack:///./node_modules/moment/locale/cv.js","webpack:///./node_modules/moment/locale/cy.js","webpack:///./node_modules/moment/locale/da.js","webpack:///./node_modules/moment/locale/de-at.js","webpack:///./node_modules/moment/locale/de-ch.js","webpack:///./node_modules/moment/locale/de.js","webpack:///./node_modules/moment/locale/dv.js","webpack:///./node_modules/moment/locale/el.js","webpack:///./node_modules/moment/locale/en-SG.js","webpack:///./node_modules/moment/locale/en-au.js","webpack:///./node_modules/moment/locale/en-ca.js","webpack:///./node_modules/moment/locale/en-gb.js","webpack:///./node_modules/moment/locale/en-ie.js","webpack:///./node_modules/moment/locale/en-il.js","webpack:///./node_modules/moment/locale/en-nz.js","webpack:///./node_modules/moment/locale/eo.js","webpack:///./node_modules/moment/locale/es-do.js","webpack:///./node_modules/moment/locale/es-us.js","webpack:///./node_modules/moment/locale/es.js","webpack:///./node_modules/moment/locale/et.js","webpack:///./node_modules/moment/locale/eu.js","webpack:///./node_modules/moment/locale/fa.js","webpack:///./node_modules/moment/locale/fi.js","webpack:///./node_modules/moment/locale/fo.js","webpack:///./node_modules/moment/locale/fr-ca.js","webpack:///./node_modules/moment/locale/fr-ch.js","webpack:///./node_modules/moment/locale/fr.js","webpack:///./node_modules/moment/locale/fy.js","webpack:///./node_modules/moment/locale/ga.js","webpack:///./node_modules/moment/locale/gd.js","webpack:///./node_modules/moment/locale/gl.js","webpack:///./node_modules/moment/locale/gom-latn.js","webpack:///./node_modules/moment/locale/gu.js","webpack:///./node_modules/moment/locale/he.js","webpack:///./node_modules/moment/locale/hi.js","webpack:///./node_modules/moment/locale/hr.js","webpack:///./node_modules/moment/locale/hu.js","webpack:///./node_modules/moment/locale/hy-am.js","webpack:///./node_modules/moment/locale/id.js","webpack:///./node_modules/moment/locale/is.js","webpack:///./node_modules/moment/locale/it-ch.js","webpack:///./node_modules/moment/locale/it.js","webpack:///./node_modules/moment/locale/ja.js","webpack:///./node_modules/moment/locale/jv.js","webpack:///./node_modules/moment/locale/ka.js","webpack:///./node_modules/moment/locale/kk.js","webpack:///./node_modules/moment/locale/km.js","webpack:///./node_modules/moment/locale/kn.js","webpack:///./node_modules/moment/locale/ko.js","webpack:///./node_modules/moment/locale/ku.js","webpack:///./node_modules/moment/locale/ky.js","webpack:///./node_modules/moment/locale/lb.js","webpack:///./node_modules/moment/locale/lo.js","webpack:///./node_modules/moment/locale/lt.js","webpack:///./node_modules/moment/locale/lv.js","webpack:///./node_modules/moment/locale/me.js","webpack:///./node_modules/moment/locale/mi.js","webpack:///./node_modules/moment/locale/mk.js","webpack:///./node_modules/moment/locale/ml.js","webpack:///./node_modules/moment/locale/mn.js","webpack:///./node_modules/moment/locale/mr.js","webpack:///./node_modules/moment/locale/ms-my.js","webpack:///./node_modules/moment/locale/ms.js","webpack:///./node_modules/moment/locale/mt.js","webpack:///./node_modules/moment/locale/my.js","webpack:///./node_modules/moment/locale/nb.js","webpack:///./node_modules/moment/locale/ne.js","webpack:///./node_modules/moment/locale/nl-be.js","webpack:///./node_modules/moment/locale/nl.js","webpack:///./node_modules/moment/locale/nn.js","webpack:///./node_modules/moment/locale/pa-in.js","webpack:///./node_modules/moment/locale/pl.js","webpack:///./node_modules/moment/locale/pt-br.js","webpack:///./node_modules/moment/locale/pt.js","webpack:///./node_modules/moment/locale/ro.js","webpack:///./node_modules/moment/locale/ru.js","webpack:///./node_modules/moment/locale/sd.js","webpack:///./node_modules/moment/locale/se.js","webpack:///./node_modules/moment/locale/si.js","webpack:///./node_modules/moment/locale/sk.js","webpack:///./node_modules/moment/locale/sl.js","webpack:///./node_modules/moment/locale/sq.js","webpack:///./node_modules/moment/locale/sr-cyrl.js","webpack:///./node_modules/moment/locale/sr.js","webpack:///./node_modules/moment/locale/ss.js","webpack:///./node_modules/moment/locale/sv.js","webpack:///./node_modules/moment/locale/sw.js","webpack:///./node_modules/moment/locale/ta.js","webpack:///./node_modules/moment/locale/te.js","webpack:///./node_modules/moment/locale/tet.js","webpack:///./node_modules/moment/locale/tg.js","webpack:///./node_modules/moment/locale/th.js","webpack:///./node_modules/moment/locale/tl-ph.js","webpack:///./node_modules/moment/locale/tlh.js","webpack:///./node_modules/moment/locale/tr.js","webpack:///./node_modules/moment/locale/tzl.js","webpack:///./node_modules/moment/locale/tzm-latn.js","webpack:///./node_modules/moment/locale/tzm.js","webpack:///./node_modules/moment/locale/ug-cn.js","webpack:///./node_modules/moment/locale/uk.js","webpack:///./node_modules/moment/locale/ur.js","webpack:///./node_modules/moment/locale/uz-latn.js","webpack:///./node_modules/moment/locale/uz.js","webpack:///./node_modules/moment/locale/vi.js","webpack:///./node_modules/moment/locale/x-pseudo.js","webpack:///./node_modules/moment/locale/yo.js","webpack:///./node_modules/moment/locale/zh-cn.js","webpack:///./node_modules/moment/locale/zh-hk.js","webpack:///./node_modules/moment/locale/zh-tw.js","webpack:///./node_modules/moment/moment.js","webpack:///./node_modules/numeral/numeral.js","webpack:///./node_modules/object-assign/index.js","webpack:///../ewars/ewars/static/vendor/Font-Awesome-master/css/font-awesome.min.css","webpack:///./node_modules/process/browser.js","webpack:///./node_modules/prop-types/checkPropTypes.js","webpack:///./node_modules/prop-types/factoryWithTypeCheckers.js","webpack:///./node_modules/prop-types/index.js","webpack:///./node_modules/prop-types/lib/ReactPropTypesSecret.js","webpack:///../src/utils.js","webpack:///../src/MessageChannel/methods/broadcastChannel.js","webpack:///../src/MessageChannel/ObliviousSet.js","webpack:///../src/MessageChannel/methods/localStorage.js","webpack:///../src/MessageChannel/methods/simulate.js","webpack:///../src/MessageChannel/methodChooser.js","webpack:///../src/MessageChannel/MessageChannel.js","webpack:///../src/MessageChannel/leaderElection.js","webpack:///../src/TabManager.js","webpack:///../src/IdleTimer.js","webpack:///../src/useIdleTimer.js","webpack:///./node_modules/react-is/cjs/react-is.development.js","webpack:///./node_modules/react-is/index.js","webpack:///./node_modules/regenerator-runtime/runtime.js","webpack:///./node_modules/style-loader/lib/addStyles.js","webpack:///./node_modules/style-loader/lib/urls.js","webpack:///(webpack)/buildin/module.js","webpack:///./profile/lang/en.js","webpack:///./reporting/components/modal/exportFormModal.js","webpack:///external \"React\""],"sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./login/app.js\");\n","\nvar content = require(\"!!../../../../../../ewars_client/node_modules/postcss-loader/src/index.js??ref--5-1!./font-awesome.min.css\");\n\nif(typeof content === 'string') content = [[module.id, content, '']];\n\nvar transform;\nvar insertInto;\n\n\n\nvar options = {\"singleton\":true,\"hmr\":true}\n\noptions.transform = transform\noptions.insertInto = undefined;\n\nvar update = require(\"!../../../../../../ewars_client/node_modules/style-loader/lib/addStyles.js\")(content, options);\n\nif(content.locals) module.exports = content.locals;\n\nif(module.hot) {\n\tmodule.hot.accept(\"!!../../../../../../ewars_client/node_modules/postcss-loader/src/index.js??ref--5-1!./font-awesome.min.css\", function() {\n\t\tvar newContent = require(\"!!../../../../../../ewars_client/node_modules/postcss-loader/src/index.js??ref--5-1!./font-awesome.min.css\");\n\n\t\tif(typeof newContent === 'string') newContent = [[module.id, newContent, '']];\n\n\t\tvar locals = (function(a, b) {\n\t\t\tvar key, idx = 0;\n\n\t\t\tfor(key in a) {\n\t\t\t\tif(!b || a[key] !== b[key]) return false;\n\t\t\t\tidx++;\n\t\t\t}\n\n\t\t\tfor(key in b) idx--;\n\n\t\t\treturn idx === 0;\n\t\t}(content.locals, newContent.locals));\n\n\t\tif(!locals) throw new Error('Aborting CSS HMR due to changed css-modules locals.');\n\n\t\tupdate(newContent);\n\t});\n\n\tmodule.hot.dispose(function() { update(); });\n}","import I18NString from '../common/fields/f.language_string'\nimport { of } from '../ewars/lang/en';\nimport SelectField from \"./c.cmp.select\";\nimport Shade from './c.shade';\nimport LanguageEditor from \"./c.editor.language\";\n\nconst MODAL_ACTIONS = [\n {label: __(\"CLOSE\"), icon: \"fa-times\", action: \"CLOSE\"}\n];\n\n\nclass Tag extends React.Component {\n constructor(props) {\n super(props)\n }\n\n render() {\n return (\n
\n
\n
this.props.onRemove(this.props.data)} title={__(\"DELETE_TAG\")}>\n \n
\n
this.props.onEdit(this.props.data)} title={__(\"EDIT_TAG\")}>\n \n
\n
{this.props.data.en}
\n
\n
\n )\n }\n}\n\nclass Tags extends React.Component {\n\n constructor(props) {\n super(props);\n this.state = {\n input: \"\",\n tags: this.props.value ? ewars.copy(this.props.value) : {},\n availableTags: [],\n results: [],\n highlightedIndex: -1,\n lang : [[\"en\" , 'English']],\n code : \"en\",\n allLanguageData : null,\n translationId : 1,\n showLangEditor : false,\n tagValue : null\n };\n }\n\n componentDidMount = async () => {\n window.addEventListener(\"close-shade\", this._closeShade);\n let languages = [];\n if (window.localStorage.language_array) {\n languages = JSON.parse(window.localStorage.language_array);\n } else {\n let resp = await ewars.tx(\"com.ewars.language.getLanguage\",[{\"filters\":{status:{booleaneq:true}}}]);\n if (resp.results) {\n languages = resp.results;\n window.localStorage.language_array=JSON.stringify(resp.results);\n }\n }\n let _languages = []\n for (let data of languages) {\n let array = []; array.push(data['code']); array.push(data['name']);\n let alraedyExsits = false;\n _languages.map(function (value, index) {\n if (value[0] === data['code']) {\n alraedyExsits = true\n }\n });\n if (!alraedyExsits && data[\"isActive\"]) {\n _languages.push(array)\n }\n }\n this.setState({\n lang : _languages,\n allLanguageData : languages\n })\n }\n \n _onKeyPress = (e) => {\n if (e.key == \"Enter\") {\n this._onAdd(this.state.input)\n }\n }\n\n componentWillReceiveProps = (nextProps) => { \n let updatedTagValue = [] ;\n if(this.state.showLangEditor){ \n let data = nextProps.value['tags'];\n for(let tag in data){ \n if(data[tag].en == this.state.tagValue.en) {\n updatedTagValue = data[tag];\n break;\n }\n } \n } \n this.setState({\n ...this.state,\n tags : nextProps.value ? nextProps.value : this.state.tags,\n input : \"\",\n tagValue: updatedTagValue || null\n })\n }\n\n componentWillUnmount() {\n window.removeEventListener(\"close-shade\", this._closeShade);\n }\n\n _closeShade = () => {\n this.setState({\n showLangEditor: false\n });\n };\n\n\n onChange = (e) =>{\n this.setState({\n input: e.target.value,\n highlightedIndex: -1\n })\n }\n\n _onAdd = async(tag) => {\n // To check if tag is already there or not\n let dataExist = [];\n if(this.state.tags != null){\n let isEmpty = (Object.keys(this.state.tags).length === 0 && this.state.tags.constructor === Object)\n if (!isEmpty){\n dataExist = this.state.tags.tags.filter((stateTag) => {\n if (stateTag.en == tag) {\n return true\n }\n })\n }else{\n await this.setState({\n ...this.state,\n tags: {\n \"tags\" : []\n }\n })\n }\n\n }\n else{\n await this.setState({\n ...this.state,\n tags: {\n \"tags\" : []\n }\n })\n }\n if (dataExist.length == 0) {\n this.state.tags['tags'].push.apply(this.state.tags.tags, [{en : tag}]);\n this.setState({\n tags: this.state.tags,\n input: \"\",\n results: [],\n highlightedIndex: -1\n });\n // this.refs.tagInput.focus();\n this.props.onUpdate(this.props.name, this.state.tags);\n }\n };\n\n _onRemove = (tag) => {\n this.state.tags.tags.splice(this.state.tags.tags.indexOf(tag), 1);\n this.setState({\n tags: this.state.tags\n });\n this.props.onUpdate(this.props.name, this.state.tags);\n };\n\n _onEditTag = (tag) =>{\n this.setState({\n showLangEditor : true ,\n tagValue : tag\n })\n }\n\n _action = (action) => {\n if (action == \"CLOSE\") {\n this.setState({\n showLangEditor: false\n })\n }\n }\n\n _onLangEditorValueChange = (prop ,value , code , oldValue) => { \n let tagUpdated = value; \n for(let tag in this.state.tags.tags){\n if(this.state.tags.tags[tag].en == tagUpdated.en){\n this.state.tags.tags[tag] = tagUpdated\n }else if(code == 'en' && this.state.tags.tags[tag].en == oldValue){\n this.state.tags.tags[tag].en = tagUpdated.en;\n }\n }\n this.setState({\n tagValue : tagUpdated,\n tags : this.state.tags\n })\n this.props.onUpdate(this.props.name, this.state.tags);\n }\n\n onLangchange = (prop ,value) =>{\n this.setState({\n code : value,\n })\n }\n\n autoTranslateAllTags = () =>{\n let code = this.state.code;\n let isEmpty = (Object.keys(this.state.tags).length === 0 && this.state.tags.constructor === Object) \n if(!isEmpty){\n let tagsTotranslate = [];\n Object.values(this.state.tags.tags).map((key , index) =>{\n let tagKeys = {\n key : '',\n string : ''\n } \n if((this.state.code in key) === false){\n tagKeys.key = key.en;\n tagKeys.string = key.en;\n tagsTotranslate.push(tagKeys)\n }\n }); \n if(tagsTotranslate.length > 0){\n this.translateTags(tagsTotranslate , this.state.code , true);\n }else{\n ewars.growl(__(\"TAGS_ALREADY_TRANSLATED\"))\n }\n }else{\n ewars.growl(__(\"NO_TAGS_TO_TRANSLATE\"))\n }\n }\n\n translateTags = (tagsTotranslate , code , autoTranslate) =>{\n this.langBlocker = new ewars.Blocker(null, __(\"TRANSLATING_TAGS\"));\n ewars.tx(\"com.ewars.language.translateformlabels\", [tagsTotranslate, code, autoTranslate])\n .then((res) => {\n this.langBlocker.destroy();\n if (res.status === 200) {\n ewars.growl(__(\"TAGS_TRANSLATED\"));\n this.updateTagsWithTranslation(res.translatedArray) \n } else {\n ewars.growl(__(\"TAGS_TRANSLATION_FAILED\"));\n }\n }).catch(err => {\n this.langBlocker.destroy();\n ewars.growl(__(\"TAGS_TRANSLATION_FAILED\"));\n })\n }\n\n updateTagsWithTranslation = (translations) =>{ \n Object.values(translations).map((translatedTag , index) => {\n for(let tag in this.state.tags.tags){ \n if(this.state.tags.tags[tag].en === translatedTag.key){\n this.state.tags.tags[tag][this.state.code] = translatedTag.translation;\n break;\n }\n }\n })\n this.setState({\n tags : this.state.tags\n })\n this.props.onUpdate(this.props.name, this.state.tags);\n }\n\n \n render() { \n let style = {selectView : {width: '150px'} , selectDropdown : {minWidth : '0'}}\n let tags = [];\n if(this.state.tags != null){\n let isEmpty = (Object.keys(this.state.tags).length === 0)\n if (!isEmpty){\n tags = this.state.tags.tags.map(function (val,index) {\n return \n }.bind(this));\n }\n }\n\n let results;\n let exactMatch = false;\n if (this.state.input.length >= 1) {\n exactMatch = true\n }\n\n\n return (\n
\n
\n
\n
\n \n \n
\n
\n
\n \n {exactMatch ?\n \n
\n
this._onAdd(this.state.input)}>\n
{__(\"ADD_TAG\")}: {this.state.input}
\n
\n
\n
\n : null}\n
\n
\n {tags.length > 0 ?\n
\n
\n
\n {tags}\n
\n
\n
\n : null}\n {this.state.showLangEditor ? \n \n {this.state.showLangEditor ?\n \n : null}\n \n : null}\n
\n
\n
\n {__(\"NOTE_TAG_WILL_BE_ADDED_IN_ENG\")}\n
\n \n )\n \n }\n\n\n}\n\n\nexport default Tags\n","import { html, css, LitElement } from \"lit-element\";\n\n\nclass ActionButton extends React.Component {\n static defaultProps = {\n height: \"20px\",\n tip: null\n };\n\n constructor(props) {\n super(props);\n\n this.state = {}\n }\n\n onClick = () => {\n this._hideHover();\n if (this.props.onClick) {\n this.props.onClick();\n } else {\n this.props.onAction(this.props.a);\n }\n };\n\n componentDidMount() {\n if (this.props.tip) {\n this.el.addEventListener('mouseover', this._showHover);\n this.el.addEventListener('mouseout', this._hideHover);\n }\n }\n\n componentWillUnmount() {\n if (this.props.tip) {\n this.el.removeEventListener('mouseover', this._showHover);\n this.el.removeEventListener('mouseout', this._hideHover);\n }\n }\n\n _showHover = () => {\n this._hover = document.createElement('div');\n if (this._hover) {\n this._hover.setAttribute('class', 'action-hover');\n this._hover.appendChild(document.createTextNode(this.props.tip));\n document.body.appendChild(this._hover);\n }\n };\n\n _hideHover = () => {\n if(document.getElementsByClassName('action-hover').length){\n if (this._hover) {\n document.body.removeChild(this._hover);\n }\n }\n };\n render() {\n let style = {\n height: this.props.height,\n lineHeight: this.props.height\n };\n\n return (\n {this.el = el;}}\n className=\"action-button\"\n style={style}\n onClick={this.onClick}>\n \n \n )\n }\n}\n\nclass LitActionButton extends LitElement {\n static get properties() {\n return {\n i: {type: String},\n a: {type: String},\n tip: {type: String},\n height: {type: Number}\n }\n }\n\n constructor() {\n super();\n\n this.height = 20;\n }\n\n _onClick = (e) => {\n this.dispatchEvent(new CustomEvent(\"action-click\", {detail: this.a}));\n };\n\n _hover = (e) => {\n if (this.tip) {\n this._hover = document.createElement(\"div\");\n this._hover.setAttribute(\"class\", \"action-hover\");\n this._hover.appendChild(document.createTextNode(this.tip));\n document.body.appendChild(this._hover);\n }\n };\n\n _hoverLeave = (e) => {\n if (this._hover) {\n document.body.removeChild(this._hover);\n }\n };\n\n connectedCallback() {\n super.connectedCallback();\n this.addEventListener(\"mouseover\", this._hover);\n this.addEventListener(\"mouseout\", this._hoverLeave);\n }\n\n disconnectedCallback() {\n this.removeEventListener(\"mouseover\", this._hover);\n this.removeEventListener(\"mouseout\", this._hoverLeave);\n }\n\n createRenderRoot() {\n return this;\n }\n\n render() {\n let iconClass = \"fal \" + this.i;\n return html`\n
\n \n
\n `;\n }\n}\nwindow.customElements.define(\"action-button\", LitActionButton);\n\nclass ActionGroup extends React.Component {\n static defaultProps = {\n height: \"20px\"\n };\n\n render() {\n let className = \"action-group\";\n if (this.props.right) {\n className += \" pull-right\";\n }\n\n let style = {\n height: this.props.height,\n lineHeight: this.props.height\n };\n\n return (\n \n {this.props.actions.map((action,index) => {\n return (\n {\n this.props.onAction(action)\n }}\n tip={action[2] || null}\n i={action[0]}\n a={action[1]}/>\n )\n })}\n \n )\n }\n}\n\n\nclass LitActionGroup extends LitElement {\n static get properties() {\n return {\n actions: {type: Array},\n height: {type: String},\n right: {type: Boolean}\n }\n }\n\n static get styles() {\n return css`\n :host {\n display: inline-block;\n line-height: 20px;\n height: 20px;\n }\n `\n }\n\n constructor() {\n super();\n this.height = \"20px\";\n this.actions = [];\n this.right = false;\n }\n\n _onClick = (e) => {\n console.log(\"HERE\", e, e.detail);\n this.dispatchEvent(new CustomEvent(\"actionSelected\", {detail: e.detail}));\n };\n\n createRenderRoot() {\n return this;\n }\n\n render() {\n let className = \"action-group\";\n if (this.right) className += \" pull-right\";\n return html`\n \n ${this.actions.map(item => {\n return html`\n \n `;\n })}\n `;\n }\n}\n\nwindow.customElements.define(\"action-group\", LitActionGroup);\n\nexport {\n LitActionGroup,\n ActionButton,\n ActionGroup\n}\n","import ewars from \"../ewars/app\";\n\nclass Application extends React.Component {\n\n constructor(props) {\n super(props);\n\n window.ewars = ewars;\n\n window.__ = ewars.setup();\n }\n\n render() {\n return this.props.children;\n }\n}\n\nexport default Application;\n","const btnClass = {\n red: \"btn-red\",\n green: \"btn-green\",\n amber: \"btn-amber\"\n};\n\nvar ButtonComponent = React.createClass({\n _id: null,\n\n propTypes: {\n label: React.PropTypes.string,\n icon: React.PropTypes.string,\n type: React.PropTypes.string\n },\n\n getDefaultProps: function () {\n return {\n enabled: true,\n processing: false,\n active: false\n }\n },\n\n getInitialState: function () {\n return {\n enabled: true,\n processing: false,\n processingMessage: \"Processing...\"\n }\n },\n\n /**\n * Public method to set button to processing mode\n * @param message\n */\n setProcessing: function (message) {\n this.state.processing = true;\n if (message != null && message != undefined) this.state.processingMessage = message;\n if (this.isMounted()) this.forceUpdate();\n },\n\n /**\n * Public method to set button to not processing mode\n */\n unsetProcessing: function () {\n this.state.processing = false;\n if (this.isMounted()) this.forceUpdate();\n },\n\n /**\n * Public method used to disable the button\n */\n disable: function () {\n this.state.enabled = false;\n if (this.isMounted()) this.forceUpdate();\n },\n\n /**\n * Pubilc method used to enable button\n */\n enable: function () {\n this.state.enabled = true;\n if (this.isMounted()) this.forceUpdate();\n },\n\n shouldComponentUpdate: function () {\n return true;\n },\n\n _onClick: function (e) {\n if (!this.props.enabled) return;\n if (!this.state.enabled) return;\n if (this.state.processing) return;\n if (this.props.processing) return;\n\n e.preventDefault();\n e.stopPropagation();\n this.props.onClick((this.props.data ? this.props.data : null));\n },\n\n render: function () {\n var colour;\n if (this.props.colour) colour = btnClass[this.props.colour];\n\n var className = \"bttn\";\n if (colour) className += \" \" + colour;\n var iconClass;\n if (this.props.icon) iconClass = \"fal \" + this.props.icon;\n\n if (this.props.active) className += \" active\";\n\n var title;\n if (this.props.title) title = this.props.title;\n\n if (!this.state.enabled || !this.props.enabled) className += \" disabled\";\n\n var label;\n if (this.props.label) label = ewars.formatters.I18N_FORMATTER(this.props.label);\n\n if (this.state.processing || this.props.processing) {\n iconClass = \"fal fa-circle-o-notch fa-spin\";\n label = this.state.processingMessage || \"Processing...\";\n }\n\n var view;\n if (iconClass && label) {\n view = (\n
\n  \n {label}\n
\n )\n } else if (iconClass && !label) {\n view = (\n
\n \n
\n )\n } else {\n view = (\n
{label}
\n )\n }\n\n return view;\n }\n});\n\nexport default ButtonComponent;\n","import Button from \"./c.cmp.button\";\n\nclass ButtonGroup extends React.Component {\n static defaultProps = {\n context_help: null,\n value: null,\n config: {\n context_help: null\n }\n };\n\n _onClick = (data) => {\n this.props.onUpdate(this.props.config.nameOverride || this.props.name, data[0], this.props.path || this.props.name);\n };\n\n render() {\n let contextHelp;\n if (this.props.config.context_help) {\n if (this.props.value != null) {\n contextHelp = __(this.props.config.context_help[this.props.value])\n }\n }\n return (\n
\n {this.props.config.options.map((button, index) => {\n let key = `BUTTON_${index}`;\n return \n })}\n
\n {contextHelp ?\n

{contextHelp}

\n : null}\n
\n )\n }\n}\n\nexport default ButtonGroup;\n","import Button from \"./c.cmp.button\";\n\nclass ButtonSet extends React.Component {\n static defaultProps = {\n value: null,\n data: {\n n: null,\n context_help: {},\n o: []\n },\n ro: false\n };\n\n static defaultProps = {\n context_help: null,\n value: null\n };\n\n _onClick = (data) => {\n if (this.props.ro) return;\n this.props.onChange(this.props.data.n, data[0], this.props.p || this.props.n);\n };\n\n render() {\n let contextHelp;\n if (this.props.data.context_help) {\n if (this.props.value != null) {\n contextHelp = __(this.props.data.context_help[this.props.value])\n }\n }\n return (\n
\n {this.props.data.o.map((button, index) => {\n let key = `BUTTON_${index}`;\n return \n })}\n
\n {contextHelp ?\n

{contextHelp}

\n : null}\n
\n )\n }\n}\n\nexport default ButtonSet;\n","// import {Layout, Row, Cell} from \"./Layout\";\n\nclass Button extends React.Component {\n static defaultProps = {\n color: false,\n active: true,\n highlight: false,\n closable: false,\n label: null\n };\n\n constructor(props) {\n super(props);\n }\n\n _onClick = (e) => {\n e.preventDefault();\n e.stopPropagation();\n this.props.onClick(this.props.data);\n };\n\n onClose = (e) => {\n e.preventDefault();\n e.stopPropagation();\n this.props.onClose();\n };\n\n render() {\n\n let className = \"bttn\";\n if (this.props.color) className += \" \" + this.props.color;\n if (!this.props.active) className += \" disabled\";\n if (this.props.highlight) className += \" active\";\n let closer;\n if (this.props.closable) {\n closer = \n }\n\n let icon;\n\n if (this.props.icon) {\n if (this.props.icon.constructor == Array) {\n icon = (\n
\n {this.props.icon.map((ic) => {\n return (\n \n )\n })}\n
\n )\n } else {\n icon = \n }\n }\n\n if (icon && this.props.label == null) {\n className += \" no-label\";\n }\n\n return (\n
\n {icon}\n {this.props.label ? __(this.props.label) : null}\n {closer}\n
\n )\n }\n}\n\nexport default Button;","export default class CommonCheckbox extends React.Component {\n\n\n static defaultProps = {\n label : \"Data\",\n value : \"CHECKBOX\",\n checked : false,\n index : -1\n }\n\n toggleCheckbox = () => {\n this.props.onToggle(this.props.value, this.props.index);\n }\n\n render() {\n return (\n
\n \n
\n )\n }\n\n\n}","import FORM_SOURCE_VARIABLE from \"./forms/form.source.variable\";\n\nconst ACTIONS = [\n [\"fa-pencil\", \"EDIT\"],\n [\"fa-trash\", \"REMOVE\"]\n]\n\nconst NONEDIT_ACTIONS = [\n [\"fa-trash\", \"REMOVE\"]\n]\n\nconst VAR_BLOCK = {\n border: \"1px solid #CCCCCC\",\n padding: \"8px\"\n\n}\n\nclass Variable extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = {\n data: {},\n id: null,\n name: \"Loading...\",\n var: null,\n shown: false,\n isValid: true\n };\n\n this._init(this.props.data);\n }\n\n componentWillReceiveProps(nextProps) {\n this.state.var = nextProps.data[2];\n }\n\n _init = (data) => {\n // validate config for the source\n\n if (data[0] == \"I\") {\n ewars.tx(\"com.ewars.resource\", [\"indicator\", data[1], null, null])\n .then((resp) => {\n this.setState({\n data: resp,\n name: __(resp.name),\n var: data[2]\n })\n })\n }\n\n if (data[0] == \"F\") {\n ewars.tx(\"com.ewars.form.field\", [data[1]])\n .then((resp) => {\n this.setState({\n name: __(resp[2]),\n var: data[2]\n })\n })\n }\n\n if (data[0] == \"D\") {\n // Data source column\n }\n\n if (data[0] == \"V\") {\n this.state.name = data[2] || \"VAR_\";\n }\n\n };\n\n _loadIndicator = () => {\n\n };\n\n _onAction = (action) => {\n if (action == \"REMOVE\") {\n this.props.remove(this.props.index)\n }\n\n if (action == \"EDIT\") {\n this.setState({\n shown: !this.state.shown\n })\n }\n };\n\n _onChange = (prop, value) => {\n this.props.onChange(this.props.index, prop, value);\n };\n\n render() {\n return (\n
\n
\n \n \n {this.state.var}: {this.state.name}\n \n \n \n \n \n
\n {this.state.shown ?\n
\n \n\n
\n : null}\n
\n )\n }\n}\n\nconst TYPES = [\n [\"INDICATOR\", \"\", null, {}],\n [\"FIELD\", \".\", null, {}],\n [\"DS\", \".\", null, {}],\n [\"VAR\", \"\", null, {}]\n]\n\nclass DataSourceDrop extends React.Component {\n static defaultProps = {\n name: null,\n value: []\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n data: []\n }\n }\n\n componentWillReceiveProps(nextProps) {\n console.log(nextProps);\n };\n\n _onDrop = (e) => {\n e.preventDefault();\n let node = e.dataTransfer.getData(\"n\");\n\n if (node.indexOf(\"[\") == 0) {\n node = JSON.parse(node);\n }\n\n\n let data = ewars.copy(this.props.value || []);\n if (node[0] == \"F\") {\n data.push([\"F\", node[1], node[2], {}]);\n }\n\n if (node[0] == \"I\") {\n data.push([\"I\", node[1], node[2], {}]);\n }\n\n if (node[0] == \"V\") {\n data.push([\"V\", null, \"NEW_VAR\", {}])\n }\n\n\n this._el.style.display = \"none\";\n\n this.props.onChange(this.props.name, data);\n\n };\n\n _onDragOver = (e) => {\n e.preventDefault();\n this._el.style.display = \"block\";\n };\n\n _onChange = (index, prop, value) => {\n let data = ewars.copy(this.props.value);\n console.log(data)\n if (prop == \"var\") {\n data[index][2] = value;\n } else {\n data[index][3][prop] = value;\n }\n\n this.props.onChange(this.props.name, data);\n };\n\n _remove = (index) => {\n let data = ewars.copy(this.props.value);\n data.splice(index, 1);\n\n this.props.onChange(this.props.name, data);\n };\n\n render() {\n let value = this.props.value;\n if (_isNullOrEmpty(value)) {\n return (\n
{\n this._el = el\n }} style={{...DROPZONE, ...DROPZONE_BASE}} onDrop={this._onDrop} onDragOver={this._onDragOver}>\n
{__(\"DROP_DATA_SOURCE_TO_START\")}
\n
\n )\n }\n\n return (\n
\n {value.map((item, index) => {\n return \n })}\n
{\n this._el = el\n }} style={DROPZONE} onDrop={this._onDrop} onDragOver={this._onDragOver}>\n
{__(\"DROP_DATA_SOURCE_TO_START\")}
\n
\n
\n )\n }\n}\n\nconst DROPZONE_BASE = {\n position: \"relative\",\n height: \"150px\",\n width: \"100%\",\n display: \"block\"\n}\n\nconst DROPZONE = {\n display: \"none\",\n height: \"100%\",\n width: \"100%\",\n background: \"rgba(0,0,0,0.9)\",\n position: \"absolute\",\n top: 0,\n lefT: 0\n}\n\nexport default DataSourceDrop;\n","\nvar charMap = {\n // latin\n 'À': 'A', 'Á': 'A', 'Â': 'A', 'Ã': 'A', 'Ä': 'A', 'Å': 'A', 'Æ': 'AE',\n 'Ç': 'C', 'È': 'E', 'É': 'E', 'Ê': 'E', 'Ë': 'E', 'Ì': 'I', 'Í': 'I',\n 'Î': 'I', 'Ï': 'I', 'Ð': 'D', 'Ñ': 'N', 'Ò': 'O', 'Ó': 'O', 'Ô': 'O',\n 'Õ': 'O', 'Ö': 'O', 'Ő': 'O', 'Ø': 'O', 'Ù': 'U', 'Ú': 'U', 'Û': 'U',\n 'Ü': 'U', 'Ű': 'U', 'Ý': 'Y', 'Þ': 'TH', 'ß': 'ss', 'à': 'a', 'á': 'a',\n 'â': 'a', 'ã': 'a', 'ä': 'a', 'å': 'a', 'æ': 'ae', 'ç': 'c', 'è': 'e',\n 'é': 'e', 'ê': 'e', 'ë': 'e', 'ì': 'i', 'í': 'i', 'î': 'i', 'ï': 'i',\n 'ð': 'd', 'ñ': 'n', 'ò': 'o', 'ó': 'o', 'ô': 'o', 'õ': 'o', 'ö': 'o',\n 'ő': 'o', 'ø': 'o', 'ù': 'u', 'ú': 'u', 'û': 'u', 'ü': 'u', 'ű': 'u',\n 'ý': 'y', 'þ': 'th', 'ÿ': 'y', 'ẞ': 'SS',\n // greek\n 'α': 'a', 'β': 'b', 'γ': 'g', 'δ': 'd', 'ε': 'e', 'ζ': 'z', 'η': 'h', 'θ': '8',\n 'ι': 'i', 'κ': 'k', 'λ': 'l', 'μ': 'm', 'ν': 'n', 'ξ': '3', 'ο': 'o', 'π': 'p',\n 'ρ': 'r', 'σ': 's', 'τ': 't', 'υ': 'y', 'φ': 'f', 'χ': 'x', 'ψ': 'ps', 'ω': 'w',\n 'ά': 'a', 'έ': 'e', 'ί': 'i', 'ό': 'o', 'ύ': 'y', 'ή': 'h', 'ώ': 'w', 'ς': 's',\n 'ϊ': 'i', 'ΰ': 'y', 'ϋ': 'y', 'ΐ': 'i',\n 'Α': 'A', 'Β': 'B', 'Γ': 'G', 'Δ': 'D', 'Ε': 'E', 'Ζ': 'Z', 'Η': 'H', 'Θ': '8',\n 'Ι': 'I', 'Κ': 'K', 'Λ': 'L', 'Μ': 'M', 'Ν': 'N', 'Ξ': '3', 'Ο': 'O', 'Π': 'P',\n 'Ρ': 'R', 'Σ': 'S', 'Τ': 'T', 'Υ': 'Y', 'Φ': 'F', 'Χ': 'X', 'Ψ': 'PS', 'Ω': 'W',\n 'Ά': 'A', 'Έ': 'E', 'Ί': 'I', 'Ό': 'O', 'Ύ': 'Y', 'Ή': 'H', 'Ώ': 'W', 'Ϊ': 'I',\n 'Ϋ': 'Y',\n // turkish\n 'ş': 's', 'Ş': 'S', 'ı': 'i', 'İ': 'I', 'ç': 'c', 'Ç': 'C', 'ü': 'u', 'Ü': 'U',\n 'ö': 'o', 'Ö': 'O', 'ğ': 'g', 'Ğ': 'G',\n // russian\n 'а': 'a', 'б': 'b', 'в': 'v', 'г': 'g', 'д': 'd', 'е': 'e', 'ё': 'yo', 'ж': 'zh',\n 'з': 'z', 'и': 'i', 'й': 'j', 'к': 'k', 'л': 'l', 'м': 'm', 'н': 'n', 'о': 'o',\n 'п': 'p', 'р': 'r', 'с': 's', 'т': 't', 'у': 'u', 'ф': 'f', 'х': 'h', 'ц': 'c',\n 'ч': 'ch', 'ш': 'sh', 'щ': 'sh', 'ъ': 'u', 'ы': 'y', 'ь': '', 'э': 'e', 'ю': 'yu',\n 'я': 'ya',\n 'А': 'A', 'Б': 'B', 'В': 'V', 'Г': 'G', 'Д': 'D', 'Е': 'E', 'Ё': 'Yo', 'Ж': 'Zh',\n 'З': 'Z', 'И': 'I', 'Й': 'J', 'К': 'K', 'Л': 'L', 'М': 'M', 'Н': 'N', 'О': 'O',\n 'П': 'P', 'Р': 'R', 'С': 'S', 'Т': 'T', 'У': 'U', 'Ф': 'F', 'Х': 'H', 'Ц': 'C',\n 'Ч': 'Ch', 'Ш': 'Sh', 'Щ': 'Sh', 'Ъ': 'U', 'Ы': 'Y', 'Ь': '', 'Э': 'E', 'Ю': 'Yu',\n 'Я': 'Ya',\n // ukranian\n 'Є': 'Ye', 'І': 'I', 'Ї': 'Yi', 'Ґ': 'G', 'є': 'ye', 'і': 'i', 'ї': 'yi', 'ґ': 'g',\n // czech\n 'č': 'c', 'ď': 'd', 'ě': 'e', 'ň': 'n', 'ř': 'r', 'š': 's', 'ť': 't', 'ů': 'u',\n 'ž': 'z', 'Č': 'C', 'Ď': 'D', 'Ě': 'E', 'Ň': 'N', 'Ř': 'R', 'Š': 'S', 'Ť': 'T',\n 'Ů': 'U', 'Ž': 'Z',\n // polish\n 'ą': 'a', 'ć': 'c', 'ę': 'e', 'ł': 'l', 'ń': 'n', 'ó': 'o', 'ś': 's', 'ź': 'z',\n 'ż': 'z', 'Ą': 'A', 'Ć': 'C', 'Ę': 'e', 'Ł': 'L', 'Ń': 'N', 'Ś': 'S',\n 'Ź': 'Z', 'Ż': 'Z',\n // latvian\n 'ā': 'a', 'č': 'c', 'ē': 'e', 'ģ': 'g', 'ī': 'i', 'ķ': 'k', 'ļ': 'l', 'ņ': 'n',\n 'š': 's', 'ū': 'u', 'ž': 'z', 'Ā': 'A', 'Č': 'C', 'Ē': 'E', 'Ģ': 'G', 'Ī': 'i',\n 'Ķ': 'k', 'Ļ': 'L', 'Ņ': 'N', 'Š': 'S', 'Ū': 'u', 'Ž': 'Z',\n // currency\n '€': 'euro', '₢': 'cruzeiro', '₣': 'french franc', '£': 'pound',\n '₤': 'lira', '₥': 'mill', '₦': 'naira', '₧': 'peseta', '₨': 'rupee',\n '₩': 'won', '₪': 'new shequel', '₫': 'dong', '₭': 'kip', '₮': 'tugrik',\n '₯': 'drachma', '₰': 'penny', '₱': 'peso', '₲': 'guarani', '₳': 'austral',\n '₴': 'hryvnia', '₵': 'cedi', '¢': 'cent', '¥': 'yen', '元': 'yuan',\n '円': 'yen', '﷼': 'rial', '₠': 'ecu', '¤': 'currency', '฿': 'baht',\n '$': 'dollar',\n // symbols\n '©': '(c)', 'œ': 'oe', 'Œ': 'OE', '∑': 'sum', '®': '(r)', '†': '+',\n '“': '\"', '”': '\"', '‘': \"'\", '’': \"'\", '∂': 'd', 'ƒ': 'f', '™': 'tm',\n '℠': 'sm', '…': '...', '˚': 'o', 'º': 'o', 'ª': 'a', '•': '*',\n '∆': 'delta', '∞': 'infinity', '♥': 'love', '&': 'and', '|': 'or',\n '<': 'less', '>': 'greater'\n}\n\nfunction slugify(string, replacement) {\n return string.split('').reduce(function (result, ch) {\n if (charMap[ch]) {\n ch = charMap[ch]\n }\n // allowed\n ch = ch.replace(/[^\\w\\s$*_+~.()'\"!\\-:@]/g, '')\n result += ch\n return result\n }, '')\n // trim leading/trailing spaces\n .replace(/^\\s+|\\s+$/g, '')\n // convert spaces\n .replace(/[-\\s]+/g, replacement || '-')\n // remove trailing separator\n .replace('#{replacement}$', '')\n .toLowerCase()\n}\n\nslugify.extend = function (customMap) {\n for (var key in customMap) {\n charMap[key] = customMap[key]\n }\n}\n\nclass Indicator extends React.Component {\n static defaultProps = {\n draggable: true,\n onClick: false\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n _show: false,\n items: [],\n _isLoaded: false\n }\n }\n\n _expand = () => {\n if (this.state._isLoaded) {\n this.setState({\n _show: !this.state._show\n })\n } else {\n this.refs.icon.className = \"fal fa-cog fa-spin\";\n ewars.tx(\"com.ewars.indicators\", [this.props.data.id])\n .then((resp) => {\n this.setState({\n _isLoaded: true,\n _show: true,\n items: resp\n })\n })\n }\n };\n\n _onDragStart = (e) => {\n ewars.emit(\"SHOW_DROPS\", \"I\")\n e.dataTransfer.setData(\"n\", JSON.stringify([\"I\", this.props.data.uuid, slugify(__(this.props.data.name), \"_\"), {}]));\n };\n\n _onClick = () => {\n if (this.props.onClick) {\n this.props.onClick([\n \"I\",\n this.props.data.uuid,\n slugify(__(this.props.data.name), \"_\"),\n {}\n ])\n }\n };\n\n render() {\n let view;\n if (this.props.data.context == \"FOLDER\") {\n view = (\n
\n \n \n \n \n \n {__(this.props.data.name)}\n \n \n
\n )\n }\n\n if (this.props.data.context == \"INDICATOR\") {\n view = (\n
\n {__(this.props.data.name)}\n
\n )\n }\n\n return (\n
\n {view}\n {this.state._show ?\n
\n {this.state.items.map((item) => {\n return \n })}\n
\n : null}\n
\n )\n }\n}\n\nclass IndicatorTree extends React.Component {\n static defaultProps = {\n draggable: true,\n onClick: false\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n items: [],\n _show: false\n }\n\n ewars.tx('com.ewars.indicators', [null])\n .then((resp) => {\n this.setState({items: resp})\n })\n }\n\n _show = () => {\n this.setState({\n _show: !this.state._show\n })\n };\n\n render() {\n let iconClass = this.state._show ? \"fa-caret-down\" : \"fa-caret-right\";\n return (\n
\n
\n \n \n \n \n \n \n \n \n {__(\"INDICATORS\")}\n \n \n
\n {this.state._show ?\n
\n {this.state.items.map((item) => {\n return \n })}\n\n
\n : null}\n
\n )\n }\n}\n\nclass FormNode extends React.Component {\n static defaultProps = {\n draggable: true,\n onClick: false\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n fields: null,\n shown: false\n }\n }\n\n _toggler = () => {\n if (!this.state.fields) {\n ewars.tx(\"com.ewars.form.fields\", [this.props.data.id])\n .then((resp) => {\n let sorted = resp.sort((a, b) => {\n if (a[0] > b[0]) return 1;\n if (a[0] < b[0]) return -1;\n return 0;\n })\n this.setState({\n fields: sorted,\n shown: true\n })\n })\n } else {\n this.setState({\n shown: !this.state.shown\n })\n }\n };\n\n render() {\n return (\n
\n
\n \n \n \n \n \n {__(this.props.data.name)}\n \n \n
\n {this.state.shown ?\n
\n {this.state.fields.map((item) => {\n return ;\n })}\n
\n : null}\n
\n )\n }\n}\n\nclass FormField extends React.Component {\n static defaultProps = {\n draggable: true,\n onClick: false\n };\n\n constructor(props) {\n super(props);\n }\n\n _onDragStart = (e) => {\n e.dataTransfer.setData(\"n\", JSON.stringify([\n \"F\",\n `${this.props.form_id}.${this.props.data[1]}`,\n slugify(this.props.data[2], \"_\")\n ]));\n };\n\n _onClick = () => {\n if (this.props.onClick) {\n this.props.onClick([\n \"F\",\n `${this.props.form_id}.${this.props.data[1]}`,\n slugify(this.props.data[2], \"_\"),\n {}\n ])\n }\n }\n\n render() {\n return (\n
\n
{__(this.props.data[2])}
\n
\n )\n }\n}\n\nclass FormTree extends React.Component {\n static defaultProps = {\n draggable: true,\n onClick: false\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n _show: false,\n forms: [],\n _isLoaded: false\n }\n }\n\n _show = () => {\n if (this.state._isLoaded) {\n this.setState({\n _show: !this.state._show\n })\n } else {\n this.refs.icon.className = \"fal fa-cog fa-spin\";\n ewars.tx(\"com.ewars.query\", [\"form\", [\"id\", \"name\"], {\"status\": {eq: \"ACTIVE\"}}, null, null, null, null])\n .then((resp) => {\n this.setState({\n forms: resp,\n _isLoaded: true,\n _show: true\n })\n })\n }\n };\n\n render() {\n\n return (\n
\n
\n \n \n \n \n \n \n \n \n {__(\"FORM_FIELDS\")}\n \n \n
\n {this.state._show ?\n
\n {this.state.forms.map((item) => {\n return \n })}\n
\n : null}\n
\n )\n }\n}\n\nclass DataSetTree extends React.Component {\n static defaultProps = {\n draggable: true,\n onClick: false\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n _show: false,\n sets: []\n }\n }\n\n _show = () => {\n this.setState({\n _show: !this.state._shown\n })\n };\n\n render() {\n let iconClass = this.state._show ? \"fa-caret-down\" : \"fa-caret-right\";\n return (\n
\n
\n \n \n \n \n \n \n \n \n {__(\"DATA_SET\")}\n \n \n
\n {this.state._show ?\n
\n\n
\n : null}\n
\n )\n }\n}\n\nclass DimensionTree extends React.Component {\n constructor(props) {\n super(props)\n }\n\n render() {\n return (\n
\n )\n }\n}\n\nclass DataSourceTree extends React.Component {\n static defaultPrpos = {\n draggable: true,\n onClick: null\n };\n\n constructor(props) {\n super(props)\n }\n\n _startDrag = (e) => {\n\n };\n\n _onVarDrag = (e) => {\n e.dataTransfer.setData(\"n\", JSON.stringify([\"V\", null, null, {}]));\n };\n\n _onClick = (data) => {\n this.props.onClick(data);\n };\n\n _onVarClick = () => {\n this.props.onClick([\"V\", null, null, {}]);\n };\n\n render() {\n return (\n
\n \n \n \n
\n
\n \n \n \n \n \n {_(\"VARIABLE\")}\n \n \n
\n
\n
\n )\n }\n}\n\nexport default DataSourceTree;\n","import Moment from \"moment\";\n\nimport RangeUtils from \"./utils/RangeUtils\";\n\nimport {\n NumericField as NumberField,\n TextField\n} from \"./fields\";\n\nimport DayPicker from \"./fields/c.date.day\";\n\nconst QUICK_RANGES = [\n [\n [\"-30D\", __(\"LAST_30_DAYS\")],\n [\"-60D\", __(\"LAST_60_DAYS\")],\n [\"-6M\", __(\"LAST_6_MONTHS\")],\n [\"-1Y\", __(\"LAST_1_YEAR\")],\n [\"-2Y\", __(\"LAST_2_YEAR\")],\n [\"-5Y\", __(\"LAST_5_YEAR\")]\n ],\n [\n [\"-1D\", __(\"YESTERDAY\")],\n [\"-2D\", __(\"DAY_BEFORE_YESTRDY\")],\n [\"-7D\", __(\"THIS_DAY_LAST_WEEK\")],\n [\"PREV_WEEK\", __(\"PREVIOUS_WEEK\")],\n [\"PREV_MONTH\", __(\"PREVIOUS_MONTH\")],\n [\"PREV_YEAR\", __(\"PREVIOUS_YEAR\")]\n ],\n [\n [\"NOW\", __(\"TODAY\")],\n [\"CUR_WEEK\", __(\"THIS_WEEK\")],\n [\"CUR_MONTH\", __(\"THIS_MONTH\")],\n [\"CUR_YEAR\", __(\"THIS_YEAR\")]\n ]\n];\n\nconst QUICK_RANGES_TEMPLATE = [\n [\n [\"DD-30D\", \"Previous 30 days\"],\n [\"DD-60D\", \"Previous 60 days\"],\n [\"DD-6M\", \"Previous 6 months\"],\n [\"DD-1Y\", \"Previous 1 year\"],\n [\"DD-2Y\", \"Previous 2 years\"],\n [\"DD-5Y\", \"Previous 5 years\"]\n ],\n [\n [\"DD-1D\", \"Previous Day\"],\n [\"DD-2D\", \"Day before previous day\"],\n [\"DD-7D\", \"Same day previous week\"],\n [\"D_PREV_WEEK\", \"Previous week\"],\n [\"D_PREV_MONTH\", \"Previous month\"],\n [\"D_PREV_YEAR\", \"Previous year\"]\n ],\n [\n [\"D_DATE\", \"Document date\"],\n [\"D_CUR_WEEK\", \"Document week\"],\n [\"D_CUR_MONTH\", \"Document month\"],\n [\"D_CUR_YEAR\", \"Document year\"]\n ]\n];\n\nconst PRESETS = [\n [\"NOW\", \"Today\"],\n [\"END\", \"End date\"],\n [\"N_W_S\", \"This week start\"],\n [\"N_W_E\", \"This week end\"],\n [\"N_M_S\", \"This month start\"],\n [\"N_M_E\", \"This month end\"],\n [\"N_Y_S\", \"This year start\"],\n [\"N_Y_E\", \"This year end\"]\n];\n\nconst PRESETS_TEMPLATE = [\n [\"D_DATE\", \"Document date\"],\n [\"NOW\", \"Today\"],\n [\"END\", \"End date\"],\n [\"D_W_S\", \"Document week start\"],\n [\"D_W_E\", \"Document week end\"],\n [\"D_M_S\", \"Document month start\"],\n [\"D_M_E\", \"Document month end\"],\n [\"D_Y_S\", \"Document year start\"],\n [\"D_Y_E\", \"Document year end\"],\n [\"N_W_S\", \"This week start\"],\n [\"N_W_E\", \"This week end\"],\n [\"N_M_S\", \"This month start\"],\n [\"N_M_E\", \"This month end\"],\n [\"N_Y_S\", \"This year start\"],\n [\"N_Y_E\", \"This year end\"]\n];\n\nclass QuickRange extends React.Component {\n constructor(props) {\n super(props)\n }\n\n _onClick = () => {\n this.props.onClick(this.props.data);\n };\n\n render() {\n return (\n
{this.props.data[1]}
\n )\n }\n}\n\nclass Offset extends React.Component {\n constructor(props) {\n super(props);\n }\n\n _onChange = (prop, value) => {\n this.props.onChange(value);\n };\n\n render() {\n return (\n
\n \n
\n \n
\n )\n }\n}\n\nclass DateSelect extends React.Component {\n static defaultProps = {\n showEndDate: false,\n showStartDate: false\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n shown: false,\n mode: \"CUSTOM\"\n }\n }\n\n componentDidMount() {\n window.__hack__.addEventListener(\"click\", this._handleBodyClick);\n }\n\n componentWillUnmount() {\n window.__hack__.removeEventListener(\"click\", this._handleBodyClick);\n }\n\n _handleBodyClick = (evt) => {\n if (this.refs.selector) {\n const area = this.refs.selector.getDOMNode ? this.refs.selector.getDOMNode() : this.refs.selector;\n\n if (!area.contains(evt.target)) {\n this.setState({\n shown: false\n })\n }\n }\n };\n\n _trigger = () => {\n this.setState({\n shown: !this.state.shown\n })\n\n };\n\n _setMode = (mode) => {\n this.setState({mode})\n };\n\n _onPickerChange = (value) => {\n this.props.onChange(this.props.prop, Moment.utc(value).format(\"YYYY-MM-DD\"));\n this.setState({\n shown: false\n })\n };\n\n _selectpreset = (preset) => {\n this.props.onChange(this.props.prop, \"{\" + preset[0] + \"}\");\n };\n\n _onOffsetChange = (value) => {\n let newValue = RangeUtils.applyOffset(this.props.value, value);\n this.props.onChange(this.props.prop, newValue);\n };\n\n render() {\n\n let label;\n\n let pickerValue;\n if (RangeUtils.isDate(this.props.value)) {\n pickerValue = RangeUtils.getDate(this.props.value);\n }\n label = RangeUtils.formatDateSpec(this.props.value);\n\n let code;\n if (RangeUtils.hasCode(this.props.value)) {\n code = RangeUtils.getCode(this.props.value);\n }\n\n let offset = RangeUtils.getOffset(this.props.value);\n\n let presets = PRESETS;\n if (this.props.mode == \"TEMPLATE\") presets = PRESETS_TEMPLATE;\n if (ewars.TEMPLATE_MODE == \"TEMPLATE\") presets = PRESETS_TEMPLATE;\n\n return (\n
\n
\n \n {label}\n \n \n \n \n
\n {this.state.shown ?\n
\n \n \n \n \n \n \n \n \n \n
\n
\n {presets.map(preset => {\n return ;\n })}\n
\n
\n
\n
\n \n \n \n \n \n
\n
\n
\n
\n
\n : null}\n
\n )\n }\n}\n\nclass DatePop extends React.Component {\n constructor(props) {\n super(props)\n }\n\n render() {\n return
\n }\n}\n\nclass PresetItem extends React.Component {\n constructor(props) {\n super(props)\n }\n\n _onClick = () => {\n this.props.onClick(this.props.data);\n };\n\n render() {\n let className = \"dr-preset\";\n if (this.props.code == this.props.data[0]) className += \" active\";\n\n return (\n
\n \n \n
\n
\n {this.props.data[1]}\n
\n
\n )\n\n }\n}\n\nclass DateRangeSelector extends React.Component {\n static defaultProps = {\n mode: \"DEFAULT\", // or TEMPLATE,\n value: [],\n vertical: false\n };\n\n constructor(props) {\n super(props);\n\n this.state = {}\n }\n\n _onQkSelect = (qk) => {\n let tmp = RangeUtils.processPreset(qk[0]);\n this.props.onChange(this.props.name, [tmp[0], tmp[1]])\n };\n\n _onPropChange = (prop, value) => {\n let data = this.props.value || [];\n\n if (prop == \"start\") data[0] = value;\n if (prop == \"end\") data[1] = value;\n\n this.props.onChange(this.props.n, data);\n };\n\n render() {\n let today = Moment.utc().format(\"YYYY-MM-DD\"),\n startDate = this.props.value ? this.props.value[0] || today : today,\n endDate = this.props.value ? this.props.value[1] || today : today,\n RANGES = QUICK_RANGES;\n if (ewars.TEMPLATE_MODE == \"TEMPLATE\") RANGES = QUICK_RANGES_TEMPLATE;\n\n if (this.props.vertical) {\n return (\n
\n \n \n \n \n \n {RANGES.map(item => {\n return (\n \n {item.map(qk => {\n return \n })}\n \n )\n })}\n \n \n \n \n \n \n \n \n
\n\n \n \n
\n
\n
\n
\n\n )\n }\n\n return (\n
\n \n \n \n \n \n
\n\n \n \n
\n \n \n \n {RANGES.map(item => {\n return (\n \n {item.map(qk => {\n return \n })}\n \n )\n })}\n \n \n \n\n
\n
\n
\n )\n }\n}\n\nexport default DateRangeSelector;\n","import SelectField from \"./c.cmp.select\";\nimport TextField from \"./c.cmp.text\";\nimport { Layout, Row, Cell } from \"./layout\";\nimport { ActionGroup } from \"./c.action_button\";\nimport Toolbar from \"./c.toolbar\";\nimport Button from \"./c.button\";\n\nconst ACTIONS = [\n [\"fa-plus\", \"ADD\"]\n];\n\nconst APPLICATION = {\n n: \"application\",\n o: [\n [\"ALL\", __(\"ALL_OF_FOLLOWING_ARE_TRUE\")],\n [\"ANY\", __(\"ANY_OF_FOLLLOWING_ARE_TRUE\")]\n ]\n};\n\nconst ROW_ACTIONS = [\n [\"fa-trash\", \"DELETE\"]\n]\n\nclass Rule extends React.Component {\n _onChange = (prop, value) => {\n let rule = ewars.copy(this.props.data);\n if (prop == 't_value') rule[2] = value;\n if (prop == 'comparator') rule[1] = value;\n if (prop == \"field\") rule[0] = value;\n\n this.props.onChange(this.props.index, rule);\n };\n\n _onAction = (action) => {\n this.props.onRemove(this.props.index);\n };\n\n render() {\n let val, cmp;\n let fieldOptions = this.props.fields.map(item => {\n return [item[2].path, item[1]];\n })\n if (this.props.data[0] != null) {\n let field;\n this.props.fields.forEach((item) => {\n if (item[2].path == this.props.data[0]){field = item}\n else if(item[0] === this.props.data[0]){ field= item};\n });\n if (field !== undefined && [\"null\", \"notnull\"].indexOf(this.props.data[1]) < 0) {\n switch (field[2].type) {\n case \"text\":\n case \"number\":\n case \"calculated\":\n cmp = (\n \n )\n break;\n case \"select\":\n cmp = (\n \n )\n break;\n default:\n // default case is text\n break;\n\n }\n }\n }\n\n return (\n
\n
\n \n \n \n\n \n \n \n\n \n \n {cmp}\n \n \n \n \n \n
\n
\n )\n }\n}\n\nconst DEFAULT = {\n application: \"ALL\",\n rules: []\n};\n\nexport default class RulesEditor extends React.Component {\n static defaultProps = {\n value: {\n application: \"ALL\",\n rules: []\n }\n };\n\n constructor(props) {\n super(props);\n }\n\n _action = (action, args) => {\n if (action == \"ADD\") {\n let cp = ewars.copy(this.props.value || DEFAULT);\n cp.rules.push([null, \"eq\", null]);\n\n this.props.onChange(this.props.data.n, cp);\n }\n\n if (action == \"DELETE\") {\n let cp = ewars.copy(this.props.value || DEFAULT);\n cp.rules.splice(args, 1);\n this.props.onChange(this.props.data.n, cp);\n }\n\n if (action == \"MERGE\") {\n\n }\n };\n\n _onTypeChange = (prop, value) => {\n let v = ewars.copy(this.props.value || DEFAULT);\n v.application = value;\n\n this.props.onChange(this.props.data.n, v);\n };\n\n _onRuleChange = (index, value) => {\n let v = ewars.copy(this.props.value || DEFAULT);\n v.rules[index] = value;\n this.props.onChange(this.props.data.n, v);\n };\n\n _removeRule = (index) => {\n let v = ewars.copy(this.props.value || DEFAULT);\n v.rules.splice(index, 1);\n this.props.onChange(this.props.data.n, v);\n };\n\n render() {\n let application = \"ALL\";\n if (this.props.value) {\n application = this.props.value.application || \"ALL\";\n }\n\n let rules = [];\n if (this.props.value) {\n if (this.props.value.rules) {\n rules = this.props.value.rules;\n }\n }\n\n let items = rules.map((item, index) => {\n return (\n \n )\n });\n\n let showRules = items.length > 0 ? true : false;\n\n return (\n \n \n \n \n
\n \n
\n\n
\n \n
\n this._action(\"ADD\")}/>\n
\n
\n
\n
\n {showRules ?\n \n \n
\n {items}\n
\n\n
\n
\n : null}\n
\n )\n }\n}\n","import { Layout, Row, Cell } from \"./layout\";\nimport {SearchField} from \"./fields\"\nclass SelectOption extends React.Component {\n _select = () => {\n this.props.onClick(this.props.data);\n };\n\n render() {\n return (\n
\n
\n {__(this.props.data[1])}\n
\n
\n )\n }\n}\n\nclass SingleSelect extends React.Component {\n _isLoaded = false;\n _initialLoaded = false;\n\n static defaultProps = {\n o: [],\n os: null,\n value: null,\n ro: false,\n searchProp: null\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n shown: false,\n options: props.o || [],\n rawOptions: null,\n align: \"left\",\n search: ''\n };\n\n this.handleChange = this._onSearchChange.bind(this);\n this.emitChangeDebounced = ewars.debounce(this.emitChange, 3);\n }\n\n componentDidMount() {\n window.__hack__.addEventListener(\"click\", this.handleBodyClick);\n\n let winWidth = this.refs.selector.parentNode.clientWidth;\n let right = this.refs.selector.getBoundingClientRect().left + this.refs.selector.getBoundingClientRect().width;\n let left = this.refs.selector.getBoundingClientRect().right + this.refs.selector.getBoundingClientRect().width;\n if ((winWidth - right) < 200) {\n this.setState({\n align: \"right\"\n })\n }\n\n if ((winWidth - left) < 200) {\n this.setState({\n align: \"left\"\n });\n }\n }\n\n componentWillUnmount() {\n window.__hack__.removeEventListener(\"click\", this.handleBodyClick);\n }\n\n handleBodyClick = (e) => {\n if (this.refs.selector) {\n const area = this.refs.selector.getDOMNode ? this.refs.selector.getDOMNode() : this.refs.selector;\n\n if (!area.contains(e.target)) {\n this.setState({\n shown: false,\n search: ''\n })\n }\n }\n };\n\n _handleClick = (e) => {\n e.stopPropagation();\n };\n\n componentWillMount() {\n this._id = ewars.utils.uuid();\n if (this.props.os && this.props.value) {\n this._init(this.props);\n } else {\n this._initialLoaded = true;\n this.state.options = this.props.o;\n }\n\n }\n\n componentWillReceiveProps(nextProps) {\n if (nextProps.os && nextProps.value) {\n if (nextProps.value != this.props.value) {\n this._init(nextProps);\n }\n } else {\n this._initialLoaded = true;\n this.state.options = nextProps.o;\n }\n }\n\n _select = (data) => {\n this.setState({\n shown: false\n });\n this.props.onSelect(data[0]);\n };\n\n _init = (props) => {\n if (props.os && props.value) {\n // Need to initialized and load up the value for the selected value\n if (!this._initialLoaded) {\n this._initialLoaded = true;\n let resource = props.os[0].toLowerCase();\n let selects = [props.os[1], props.os[2]];\n\n\n ewars.tx(\"com.ewars.resource\", [resource, props.value, selects, null])\n .then((resp) => {\n if (resp) {\n this.setState({\n options: [\n [\n resp[selects[0]],\n __(resp[selects[1]])\n ],\n ]\n })\n }\n })\n }\n }\n };\n\n _toggle = (e) => {\n if (e) e.stopPropagation();\n\n if (this.props.os) {\n if (!this._isLoaded) {\n let resource = this.props.os[0];\n let select = [this.props.os[1], this.props.os[2]];\n\n ewars.tx(\"com.ewars.query\", [resource, select, this.props.os[3] || null, null, null, null, null])\n .then((resp) => {\n this._isLoaded = true;\n this.setState({\n options: resp.map((item) => {\n return [\n item[this.props.os[1]],\n __(item[this.props.os[2]]),\n item\n ]\n }),\n search: '',\n rawOptions: resp,\n shown: true\n })\n\n })\n } else {\n this.setState({\n shown: !this.state.shown,\n search: ''\n })\n }\n } else {\n this.setState({\n shown: !this.state.shown,\n search: ''\n })\n }\n\n };\n\n _onSearchChange = (e) => {\n this.emitChangeDebounced(e.target.value);\n };\n\n emitChange = (value) => {\n this.setState({\n search: value\n })\n };\n\n render() {\n let dispValue = __(\"NONE_SELECTED\");\n\n if (this.props.value) {\n this.state.options.forEach((item) => {\n if (item[0] == this.props.value) {\n dispValue = item[1]\n }\n })\n }\n\n let style = {\n zIndex: 9999\n };\n if (this.state.align == \"right\") {\n style.right = 0;\n style.left = \"auto\";\n } else {\n style.left = 0;\n style.right = \"auto\";\n }\n\n let options = this.state.options;\n if (this.state.search != '') {\n let lowered = this.state.search.toLowerCase();\n options = this.state.options.filter(item => {\n return item[1].toLowerCase().indexOf(lowered) >= 0;\n })\n }\n\n return (\n
\n
\n \n \n {ewars.I18N(dispValue)}\n \n {!this.props.ro ?\n \n \n \n : null}\n \n
\n {this.state.shown && !this.props.ro ?\n
\n {this.props.searchProp ?\n \n : null}\n
\n {options.map((item,index) => {\n return (\n \n )\n })}\n
\n
\n : null}\n
\n )\n }\n}\n\nclass MultiSelect extends React.Component {\n render() {\n return (\n
\n )\n }\n}\n\nexport default class SelectField extends React.Component {\n static defaultProps = {\n data: {\n o: [],\n os: null,\n c: [],\n l: \"\",\n s: false,\n r: false,\n ml: false\n\n },\n searchProp: null,\n ro: false\n };\n\n _select = (value) => {\n this.props.onChange(this.props.data.n, value);\n };\n\n render() {\n \n let style = null;\n \n if(this.props.style) style = this.props.style;\n else if(this.props.data?.style) style = this.props.data.style;\n\n if (this.props.data.ml) {\n return (\n \n )\n } else {\n return (\n \n )\n }\n\n }\n}\n","import DataSourceTree from \"./c.cmp.data_source_tree\";\n\nconst ACTIONS = [\n [\"fa-minus\", \"REMOVE\"]\n];\n\nclass DataSourceSelect extends React.Component {\n constructor(props) {\n super(props)\n\n this.state = {\n expanded: false\n }\n\n }\n\n _toggle = () => {\n this.setState({\n expanded: !this.state.expanded\n })\n };\n\n _onClick = (data) => {\n this.setState({\n expanded: false\n })\n\n this.props.onSelect(data);\n };\n\n render() {\n let dispValue = __(\"ADD_SOURCES\");\n\n return (\n
\n
\n \n {dispValue}\n \n \n \n \n
\n {this.state.expanded ?\n
\n \n
\n : null}\n
\n )\n }\n}\n\nconst ROW_ACTIONS = [\n [\"fa-pencil\", \"EDIT\"],\n [\"fa-trash\", \"DELETE\"]\n]\n\n\nclass Source extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = {\n data: null\n }\n\n }\n\n componentWillMount() {\n if (this.props.data[0] == \"I\") {\n ewars.tx(\"com.ewars.resource\", [\"indicator\", this.props.data[1], null, null])\n .then((resp) => {\n this.setState({\n data: resp\n })\n })\n }\n\n if (this.props.data[0] == \"F\") {\n\n }\n }\n\n render() {\n let label;\n let iconClass = \"fal fa-cog fa-spin\";\n if (this.state.data) {\n iconClass = \"fal fa-code-branch\";\n if (this.props.data[0] == \"F\") {\n iconClass = \"fal fa-list\";\n }\n if (this.props.data[0] == \"I\") label = __(this.state.data.name);\n if (this.props.data[0] == \"F\") label = this.props.data[1];\n }\n\n\n return (\n
\n \n \n \n \n \n \n \n \n \n \n \n {label}\n \n \n \n
\n )\n }\n}\n\nclass Sources extends React.Component {\n constructor(props) {\n super(props);\n }\n\n _onSelect = (data) => {\n let sources = this.props.value || [];\n sources.push(data);\n this.props.onChange(this.props.name, sources);\n };\n\n render() {\n return (\n
\n \n
\n
\n {(this.props.value || []).map((item) => {\n return \n })}\n
\n
\n \n
\n
\n
\n )\n }\n}\n\nexport default Sources;\n","import LanguageEditor from \"./c.editor.language\";\nimport { Layout, Row, Cell } from \"./layout\";\nimport Shade from \"./c.shade\";\nimport { ActionGroup } from \"./c.action_button\";\n\nconst LANG_OPTIONS = [\n [\"fa-language\", \"EDIT\"]\n];\n\nconst MODAL_ACTIONS = [\n {label: __(\"CLOSE\"), icon: \"fa-times\", action: \"CLOSE\"}\n];\n\nclass TextField extends React.Component {\n static defaultProps = {\n data: {\n n: null, // name\n ml: false, // multi-line\n v: [], // Validations\n r: false, // required\n l: null, // Label,\n mkdwn: false,\n i18: false,\n p : __(\"ENTER_TEXT\")\n },\n value: \"\",\n ro: false\n\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n showLang: false\n }\n }\n\n componentDidMount() {\n window.addEventListener(\"close-shade\", this._closeShade);\n }\n\n componentWillUnmount() {\n window.removeEventListener(\"close-shade\", this._closeShade);\n }\n\n _closeShade = () => {\n this.setState({\n showLang: false\n });\n };\n\n _onChange = (e) => {\n let data = ewars.copy(this.props.value);\n if (this.props.data.i18) {\n if (data == \"\" || data == undefined) data={};\n else if(typeof data === 'string' || data instanceof String) data = {}\n \n if (window.user) {\n let [code, newValue] = [window.user.language, e.target.value];\n data[code] = newValue;\n }\n else {\n data.en = e.target.value;\n }\n this.props.onChange(this.props.data.n, data);\n }else{\n this.props.onChange(this.props.data.n, e.target.value);\n }\n \n };\n\n _action = (action) => {\n if (action == \"EDIT\") {\n this.setState({\n showLang: true\n })\n }\n\n if (action == \"CLOSE\") {\n this.setState({\n showLang: false\n })\n }\n\n };\n\n _onLangChange = (prop, value) => {\n this.props.onChange(this.props.data.n, value);\n };\n _ii8n =(data)=>{\n if (window.user) {\n if (data[window.user.language]) {\n return data[window.user.language];\n } else {\n // if (data.en) {\n // return data.en;\n // } else {\n return \"\";\n // }\n }\n }else {\n if (data.en) {\n return data.en;\n } else {\n return \"\";\n }\n }\n }\n render() {\n let value = this.props.value;\n\n if (value) {\n if (JSON.stringify(value).indexOf(\"{\") >= 0) {\n value = this.props.data.i18?this._ii8n(value):value.en;\n }\n }\n\n if (this.props.data.ml) {\n return (\n
\n \n \n \n \n {this.props.data.i18 ?\n \n \n \n : null}\n \n \n {this.state.showLang ?\n \n : null}\n \n
\n )\n }\n\n\n if (this.props.data.mkdwn) {\n return (\n

{value}

\n )\n }\n\n return (\n
\n \n \n \n \n {this.props.data.i18 ?\n \n \n \n : null}\n \n \n {this.state.showLang ?\n \n : null}\n \n
\n )\n\n }\n}\n\nexport default TextField;\n","export default class Collapser extends React.Component {\n static defaultProps = {\n open: false\n };\n\n render() {\n return (\n
\n \n
\n )\n }\n}","class ContextMenuItem extends React.Component {\n constructor(props) {\n super(props);\n }\n\n _onClick = (e) => {\n e.preventDefault();\n e.stopPropagation();\n this.props.onClick(this.props.data.action);\n };\n\n render() {\n let iconClass = `fal ${this.props.data.icon}`;\n\n return (\n
\n
\n
\n
{this.props.data.label}
\n
\n
\n )\n }\n}\n\nclass ContextMenu extends React.Component {\n constructor(props) {\n super(props);\n }\n\n _onClick = (action) => {\n this.props.onClick(action);\n };\n\n render() {\n let style = {};\n if (!this.props.absolute) style.position = \"relative\";\n\n let actions = this.props.actions.map(function (action) {\n return \n }.bind(this));\n\n return (\n
\n {actions}\n
\n )\n }\n}\n\nexport default ContextMenu;","class Control extends React.Component {\n constructor(props) {\n super(props);\n }\n\n onClick = () => {\n this.props.onClick(this.props.action);\n };\n\n render() {\n return (\n
\n \n
\n )\n }\n}\n\nexport default Control;","import Control from \"./c.control\";\n\nclass Dashboard extends React.Component {\n constructor(props) {\n super(props)\n }\n\n render() {\n let counter = 0;\n return (\n
\n
\n {this.props.data.definition.map((row, index) => {\n counter++;\n let key = `${this.props.data.uuid}_${counter}`;\n return \n })}\n
\n
\n )\n }\n}\n\nclass EditableList extends React.Component {\n static defaultProps = {\n orderable: false,\n onAdd: null,\n onRemove: null,\n onOrder: null,\n items: [],\n onChange: null,\n Template: null\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n selectedIndex: null\n }\n }\n\n _handleAction = (action) => {\n this.props.onAction(\n action,\n this.state.selectedIndex,\n this.props.items[this.state.selectedIndex]\n );\n };\n\n _onItemClick = (index) => {\n this.setState({\n selectedIndex: index\n })\n };\n\n _clearSelected = (evt) => {\n };\n\n render() {\n let selected;\n if (this.state.selectedIndex != null) {\n selected = this.props.items[this.state.selectedIndex];\n }\n var listStyle;\n if(this.props.minHeight)\n listStyle={ minHeight: this.props.minHeight };\n return (\n
\n
\n {this.props.items.map((item, index) => {\n return \n })}\n
\n
\n {this.props.actions.map(action => {\n let show = true;\n if (action.show && !action.show(this.props.items[this.state.selectedIndex])) {\n show = false;\n return ;\n }\n return (\n \n )\n })}\n
\n
\n )\n }\n}\n\nexport default EditableList;\n","import TextField from \"./c.cmp.text\";\nimport SelectField from \"./c.cmp.select\";\nimport { Layout, Row, Cell } from \"./layout\";\nimport Toolbar from \"./c.toolbar\";\nimport Shade from \"./c.shade\";\nimport { ActionGroup, LitActionGroup } from \"./c.action_button\";\nimport Panel from \"./c.panel\";\n\n\nconst ACTIONS = [\n [\"fa-plus\", \"ADD\", __(\"ADD_TRANSLATION\")],\n [\"fa-times\", \"CLOSE\", __(\"CLOSE\")]\n];\n\nconst ROW_ACTIONS = [\n [\"fa-trash\", \"REMOVE\"]\n];\n\nclass LangRow extends React.Component {\n\n constructor(props) {\n super(props);\n this.state = {\n languages: [\n [\"en\", \"English\"],\n [\"fr\", \"French\"]\n ]\n }\n };\n\n _action = () => {\n this.props.onAction(\"REMOVE\", this.props.code);\n };\n\n componentDidMount() {\n ewars.tx(\"com.ewars.language.getLanguage\")\n .then(function (resp) {\n let finalArry = []\n for (let data of resp['results']) {\n let array = []; array.push(data['code']); array.push(data['name']);\n let alraedyExsits = false;\n finalArry.map(function (value, index) {\n if (value[0] === data['code']) {\n alraedyExsits = true\n }\n });\n if (!alraedyExsits && data[\"isActive\"]) {\n finalArry.push(array)\n }\n }\n this.setState({languages:finalArry})\n }.bind(this))\n };\n\n _onKeyChange = (prop, value) => {\n this.props.onAction(\"KEY_CHANGE\", [this.props.code, value]);\n };\n\n _onValueChange = (prop, value) => {\n this.props.onAction(\"VALUE_CHANGE\", [this.props.code, value]);\n };\n\n render() {\n return (\n \n \n \n \n \n \n \n \n \n \n \n )\n }\n}\n\nexport default class LanguageEditor extends React.Component {\n static defaultProps = {\n value: {en: \"\"},\n data: {\n i18: false,\n ml: false // multiline\n }\n };\n\n constructor(props) {\n super(props);\n }\n\n _action = (action, args) => {\n let data = this.props.value;\n if (data) {\n if (JSON.stringify(data).indexOf(\"{\") < 0) {\n data = {en: this.props.value}\n }\n } else {\n data = {en: \"\"}\n }\n\n let cp = ewars.copy(data || {});\n\n switch (action) {\n case \"ADD\":\n cp[\"NW\"] = \"New String\";\n this.props.onChange(this.props.data.n, cp);\n break;\n case \"KEY_CHANGE\":\n let [oldCode, newCode] = args;\n if (oldCode != newCode) {\n let tmp = cp[oldCode];\n cp[newCode] = tmp\n delete cp[oldCode];\n this.props.onChange(this.props.data.n, cp);\n }\n break;\n case \"VALUE_CHANGE\":\n let [code, newValue] = args;\n let oldValue;\n if(this.props.isTagLangEditor) oldValue = cp[code];\n cp[code] = newValue;\n if(this.props.isTagLangEditor) this.props.onChange(this.props.data.n , cp, code , oldValue)\n else this.props.onChange(this.props.data.n, cp);\n break;\n case \"REMOVE\":\n delete cp[args];\n this.props.onChange(this.props.data.n, cp);\n break;\n case \"CLOSE\":\n window.dispatchEvent(new CustomEvent(\"close-shade\"));\n break;\n default:\n break;\n }\n\n };\n\n _onAction = (e) => {\n console.log(\"FIRED\", e);\n };\n\n render() {\n let data = this.props.value;\n if (data) {\n if (JSON.stringify(data).indexOf(\"{\") < 0) {\n data = {en: this.props.value}\n }\n } else {\n data = {en: this.props.value || \"\"};\n }\n\n let rows = [];\n for (let i in data) {\n rows.push(\n \n )\n }\n\n return (\n \n \n \n \n \n \n \n
\n \n \n \n \n \n \n \n \n \n {rows}\n \n
{__(\"CODE\")}{__(\"TRANSLATION\")} 
\n
\n
\n
\n
\n
\n )\n }\n}\n","/*\n * Copyright (c) 2015 WHO.\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains the property of WHO and its suppliers, if any. The intellectual concepts contained\n * herein are proprietary to WHO and its suppliers and\n * may be covered under U.S. and Foreign Patents, patents in process, and are protected\n * by trade secret or copyright law. Dissemination of this information or reproduction\n * of this material is strictly forbidden unless prior written permission is obtained\n * from WHO.\n */\n\nvar Filler = React.createClass({\n render: function () {\n var iconClass = \"fal \" + this.props.icon;\n return (\n
\n
\n \n
\n
\n )\n }\n});\n\nexport default Filler;\n","import FormField from \"./c.form_field\";\nimport FormUtils from \"./utils/FormUtils\";\n\nimport {\n SelectField,\n TextField,\n MarginField,\n DateField,\n MatrixField,\n TextAreaField,\n DisplayField,\n ConditionsField,\n RowField,\n TopoJSONField,\n LocationInputField,\n LocationField as LocationSelectField,\n LanguageStringField,\n TimeField,\n NumericField,\n SlugField,\n SwitchField,\n PointField,\n GeometryField,\n SelectFieldOptionsField,\n HeaderField,\n AssignmentLocationField,\n AssignmentField,\n DisplayCalculatedField,\n IndicatorDefinition,\n IndicatorField,\n DateRangeField, // Fix\n ColourThresholdsField, // Fix\n DOMSizeField, // Fix\n ColourField, // Fix\n FileField, // Fix\n LocationGroupField, // Fix\n LatLngField, // Fix\n GeometryEditor, // Fix\n FormFieldField,// Fix\n FormFieldSelect,\n FormFieldCondition,\n MultipleLocationsField,\n IndicatorRelatedForms,\n MultipleAlarmsField,\n ValueMapperField,\n TotalFormulaHelpField\n} from \"./fields\";\nimport MainFormField from \"./fields/f.main_form_field\"\nimport PeriodSelector from \"./c.period_selector\";\nimport { default as ButtonGroupField } from \"./c.button_group\";\nimport ComplexSourcesManager from \"./editors/widgets/_shared/ComplexSourcesManager.react\";\nimport TagField from \"../common/Tags.react\";\nimport AssignmentSelector from \"../common/cmp/fields/AssignmentSelector\";\nimport FileUploadField from \"./fields/f.file_upload\";\nimport MediaContentField from \"./fields/f.media.content\";\n\n\n/**\nimport Datefield from \"./fields/c.date\";\n\nimport MatrixField from \"./fields/MatrixField.react\";\nimport SelectField from \"./fields/SelectField.react\";\nimport TextAreaField from \"./fields/TextAreaField.react\";\nimport TextInputField from \"./fields/TextInputField.react\";\nimport DisplayField from \"./fields/DisplayField.react\";\nimport ConditionsField from \"./fields/ConditionsField.react\";\nimport RowField from \"./fields/RowField.react\";\nimport TopoJSONField from \"./fields/TopoJSONField.react\";\nimport LocationInputField from \"./fields/LocationInputField\";\nimport LocationSelectField from \"./fields/LocationSelectField.react\";\nimport LanguageStringField from \"./fields/LanguageStringInput.react\";\nimport NumberField from \"./fields/NumberField.react\";\nimport SlugField from \"./fields/SlugField.react\";\nimport SwitchFielf from \"./fields/SwitchField.react\";\nimport IndicatorSelector from \"../components/indicator/IndicatorSelectorComponent.react\";\nimport PointField from \"./fields/point/PointSelectionField.react\";\nimport MapGeometryField from \"./fields/MapGeometryField.react\";\nimport SelectFieldOptionsField from \"./fields/system/SelectFieldOptionsField.react\";\nimport HeaderField from \"./fields/HeaderField.react\";\nimport AssignmentLocationField from \"./fields/report_fields/AssignmentLocationField.react\";\nimport IndicatorDefinition from \"./fields/system/IndicatorDefinition.react\";\n// Only used in widget editors\nimport ComplexSourcesDefinition from \"./widget_editors/_shared/ComplexSourcesManager.react\";\n\n\nimport DisplayCalculatedField from \"./fields/DisplayCalculatedField.react\";\nimport AgeField from \"./fields/AgeField\";\nimport RangeSelector from \"../cmp/fields/RangeSelector\";\nimport ColourThresholds from \"../cmp/fields/ColourThresholds\";\nimport ButtonGroup from \"../cmp/fields/ButtonGroup\";\nimport DOMSizeField from \"../cmp/fields/DOMSizeField\";\nimport Colour from \"../cmp/fields/Colour\";\nimport FileUploadField from \"../cmp/fields/FileUploadField\";\nimport LocationGroupField from \"../cmp/fields/LocationGroupField\";\nimport LatLngField from './fields/LatLngField';\nimport BoundingBoxField from \"../cmp/fields/BoundingBox\";\nimport FormFieldField from './fields/system/field.form_field';\n **/\n\nclass NullComponent extends React.Component {\n constructor(props) {\n super(props)\n }\n\n render() {\n return (
)\n }\n}\n\nconst FIELDS = {\n tags: TagField,\n select: SelectField,\n text: TextField,\n time: TimeField,\n string: TextField,\n textarea: TextAreaField,\n margin:MarginField,\n date: DateField,\n email: TextField,\n matrix: MatrixField,\n number: NumericField,\n point: PointField,\n display: DisplayField,\n conditions: ConditionsField,\n row: RowField,\n topojson: TopoJSONField,\n location: LocationSelectField,\n language_string: LanguageStringField,\n slug: SlugField,\n switch: SwitchField,\n indicator: IndicatorField,\n //geometry: MapGeometryField,\n select_options: SelectFieldOptionsField,\n header: HeaderField,\n assignment_location: AssignmentField,\n indicator_definition: IndicatorDefinition,\n _complex_sources: ComplexSourcesManager,\n assignment: AssignmentSelector,\n date_range: PeriodSelector,\n colour_thresholds: ColourThresholdsField,\n button_group: ButtonGroupField,\n dom_size: DOMSizeField,\n color: ColourField,\n file: FileField,\n file_upload: FileUploadField,\n location_group: LocationGroupField,\n content: NullComponent,\n lat_long: LatLngField,\n form_field: FormFieldField,\n //bounds: GeoEditor,\n calculated: DisplayCalculatedField,\n main_form_field: MainFormField,\n form_field_select: FormFieldSelect,\n form_field_condition: FormFieldCondition,\n multiple_locations: MultipleLocationsField,\n indicators_forms : IndicatorRelatedForms,\n multiple_alarms : MultipleAlarmsField,\n value_mapper:ValueMapperField,\n total_formula_help:TotalFormulaHelpField,\n media : MediaContentField\n};\n\n\nvar NON_FIELDS = [\"display\", \"grid\"];\n\n/**\n * Comparator used for sorting the fields in the definition by\n * their order property\n * @param a\n * @param b\n * @returns {number}\n * @private\n */\nfunction _comparator(a, b) {\n if (parseInt(a.order) < parseInt(b.order)) {\n return -1;\n }\n if (parseInt(a.order) > parseInt(b.order)) {\n return 1;\n }\n return 0;\n}\n\nfunction _getFieldsAsArray(sourceFields) {\n var fields = [];\n for (let name in sourceFields) {\n let field = ewars.copy(sourceFields[name]);\n field.name = name;\n\n if (field.fields) {\n var children = _getFieldsAsArray(field.fields);\n field.fields = children;\n }\n\n fields.push(field);\n };\n\n return fields.sort(_comparator);\n}\n\nfunction _recursiveSetValue(definition, data, path, errors) {\n for (var i in definition) {\n var field = definition[i];\n if (path) {\n definition[i].path = `${path}.${i}`;\n } else {\n definition[i].path = i;\n }\n\n if (field.fields) {\n // This field doesn't have a value, it has children which have values\n field.fields = _recursiveSetValue(field.fields, data[i] || {}, field.path, errors);\n }\n\n let key = i;\n if (field.nameOverride) key = field.nameOverride;\n\n if (key.indexOf(\".\") >= 0) {\n field.value = ewars.getKeyPath(key, data);\n } else {\n if (data[key] == 0) {\n field.value = data[key];\n }\n else {\n field.value = data[key] || field.defaultValue || \"\";\n }\n }\n\n // Check for errors for this field\n // Only if it's a certain type of field\n if (NON_FIELDS.indexOf(field.type) < 0 && errors) {\n var fieldErrors = ewars.getKeyPath(definition[i].path, errors);\n if (fieldErrors) definition[i].error = fieldErrors;\n }\n\n }\n return definition;\n}\n\n/**\n * Check if a value isn't set, used for required fields\n * @param value\n * @returns {boolean}\n */\nfunction isNull(value) {\n if (value == \"\") return true;\n if (value == undefined) return true;\n if (value == \"null\") return true;\n if (value == \"None\") return true;\n if (value == null) return true;\n if (!value) return true;\n return false;\n}\n\n/**\n * Form class - Used to render forms throughout the application*\n */\nvar Form = React.createClass({\n\n _fields: null,\n\n /**\n * Retrieve the initial state of the form*\n * @returns {{fields: {}, dirty: boolean, tabs: null}}\n */\n\n getInitialState: function () {\n return {\n fields: {},\n dirty: false,\n tabs: null,\n errors: {},\n disabled: false\n }\n },\n\n componentDidMount() {\n // console.log(\"REF\", this.refs);\n },\n\n componentWillMount: function () {\n },\n\n enable: function () {\n this.state.disabled = false;\n if (this.isMounted()) this.forceUpdate();\n },\n\n disable: function () {\n this.state.disabled = true;\n if (this.isMounted()) this.forceUpdate();\n },\n\n getDefaultProps: function () {\n return {\n readOnly: true,\n light: true\n }\n },\n\n /**\n * Handles any changes to fields in the form and bubbles them up to the parent component*\n * @param property\n * @param value\n * @param path FQP for where the proeprty should be updated\n * @param * Any additional data that the field type has bubbled up (location, indicator, etc...)\n * @private\n * @param path\n */\n _handleChange: function (property, value, path, additionalData) {\n this.props.updateAction(this.props.data, property, value, path, additionalData);\n\n // TODO: Need to handle when the form is returned to it;s initial state by the users\n // track history of changes in client before a save call\n this.setState({\n dirty: true\n })\n },\n\n validateField: function (field_name, value) {\n let def = FormUtils.field(this.props.definition, field_name);\n this.state.errors[field_name] = [];\n\n if (def) {\n // Check if required\n if (def.required) {\n if (isNull(value)) {\n this.state.errors[field_name].push(ewars.I18N(def.label) + \" is a required field\");\n }\n }\n\n if (def.type == \"number\") {\n if (def.min) {\n if (value < def.min) {\n this.state.errors[field_name].push(\"Can not be below \" + def.min);\n }\n }\n\n if (def.max) {\n if (value > def.max) {\n this.state.errors[field_name].push(\"Can not be greate than \" + def.max);\n }\n }\n }\n }\n\n },\n\n /**\n * Public functions called via ref to check if a forms data is valid\n */\n isValid: function () {\n return true;\n },\n\n /**\n * Processes and creates any grids defined for the form*\n * @param field\n * @returns {XML}\n * @private\n */\n _processGrid: function (field) {\n var grid;\n\n var columns = [];\n for (var idx in field.fields) {\n var ff = field.fields[idx];\n var key = \"COLUMN_\" + ewars.utils.uuid();\n columns.push(\n \n )\n }\n\n var data = null;\n if (this.props.data[field.name]) data = this.props.data[field.name];\n\n grid = (\n
\n \n {columns}\n \n
\n );\n\n return grid;\n },\n\n _getRuleResult: function (rule, data) {\n var result;\n\n var sourceValue = ewars.getKeyPath(rule[0], data);\n if ([\"null\", \"notnull\"].indexOf(rule[1]) < 0){\n if (sourceValue == null || sourceValue == undefined) return false;\n }\n const isNumber = (val) => {\n try {\n parseFloat(val);\n return true;\n } catch (e) {\n return false;\n }\n };\n\n switch (rule[1]) {\n case \"eq\":\n if (Object.prototype.toString.call(sourceValue) == \"[object Array]\") {\n if (sourceValue.indexOf(rule[2]) >= 0) {\n result = true;\n } else {\n result = false;\n }\n } else {\n result = sourceValue == rule[2];\n }\n break;\n case \"ne\":\n case \"neq\":\n if (Object.prototype.toString.call(sourceValue) == \"[object Array]\") {\n if (sourceValue.indexOf(rule[2]) < 0) {\n result = true;\n } else {\n result = false;\n }\n } else {\n result = sourceValue != rule[2];\n }\n break;\n case \"gt\":\n if (!isNumber(sourceValue)) {\n result = false;\n } else {\n result = parseFloat(sourceValue) > parseFloat(rule[2]);\n }\n break;\n case \"lt\":\n if (!isNumber(sourceValue)) {\n result = false;\n } else {\n result = parseFloat(sourceValue) < parseFloat(rule[2]);\n }\n break;\n case 'gte':\n if (!isNumber(sourceValue)) {\n result = false;\n } else {\n result = parseFloat(sourceValue) >= parseFloat(rule[2]);\n }\n break;\n case 'lte':\n if (!isNumber(sourceValue)) {\n result = false;\n } else {\n result = parseFloat(sourceValue) <= parseFloat(rule[2]);\n }\n break;\n case 'null':\n if (isNull(sourceValue)) {\n result = true;\n } else {\n result = false;\n }\n break;\n case 'notnull':\n if (isNull(sourceValue)) {\n result = false;\n } else {\n result = true;\n }\n break;\n default:\n result = false;\n break\n }\n\n return result;\n },\n\n _checkFieldVisible: function (field, data) {\n if (field.conditional_bool == true) {\n var result = false;\n\n if (!field.conditions) return true;\n if (!field.conditions.rules) return true;\n\n if ([\"ANY\", \"any\"].indexOf(field.conditions.application) >= 0) {\n // Only one of the rules has to pass\n\n for (var conIdx in field.conditions.rules) {\n var rule = field.conditions.rules[conIdx];\n\n var tmpResult = this._getRuleResult(rule, data);\n if (result != true && tmpResult == true) result = true;\n }\n\n } else {\n var ruleCount = field.conditions.rules.length;\n var rulePassCount = 0;\n\n for (var ruleIdx in field.conditions.rules) {\n var rule = field.conditions.rules[ruleIdx];\n var ruleResult = this._getRuleResult(rule, data);\n if (ruleResult) rulePassCount++;\n }\n\n if (ruleCount == rulePassCount) result = true;\n\n }\n return result;\n } else {\n return true;\n }\n },\n\n /**\n * Renders the form into the parent container*\n * @returns {XML}\n */\n render: function () {\n var tabs = [];\n\n var readOnly = true;\n if (this.props.readOnly == false) readOnly = false;\n if (this.state.disabled == true) readOnly = true;\n\n var cancelText = \"Close\";\n if (this.state.dirty == true) {\n cancelText = \"Cancel\";\n }\n\n var definition;\n var defCopy = JSON.parse(JSON.stringify(this.props.definition));\n\n if (this.props.data) {\n definition = _recursiveSetValue(defCopy, this.props.data, null, this.props.errors);\n }\n\n var nodes = [];\n\n // Sort and set up the fields\n this._fields = _getFieldsAsArray(definition);\n\n // Instantiate defaults\n this._fields.forEach((field, index) => {\n if (FIELDS[field.type]) {\n var FieldControl = FIELDS[field.type];\n var options = (field.options ? field.options : null);\n\n // Handle default definition\n if (field.value == null || field.value == undefined) {\n if (field.defaultValue != null && field.defaultValue != undefined) {\n field.value = field.defaultValue;\n }\n }\n\n var visible = true;\n if (field.conditions) {\n visible = this._checkFieldVisible(field, this.props.data);\n }\n\n var fields;\n if (this.props.conditionalFieldOptions) {\n fields = this.props.conditionalFieldOptions;\n }\n\n if (visible) {\n if (field.type == 'content') {\n nodes.push(\n
\n
\n
\n
\n

{field.content}

\n
\n
\n
\n
\n )\n } else {\n var children;\n\n if (field.fields) {\n children = [];\n\n field.fields.forEach(subField => {\n var childOptions = (field.options ? field.options : null);\n var SubFieldControl = FIELDS[field.type];\n\n var wrapperKey = \"WRAPPER_\" + subField.type + \"_\" + subField.name;\n var controlKey = \"CONTROL_\" + subField.type + \"_\" + subField.name;\n\n let isVisible = true;\n if (subField.conditional_bool) {\n isVisible = this._checkFieldVisible(subField, this.props.data);\n }\n\n if (isVisible) {\n children.push(\n \n \n \n )\n }\n })\n }\n\n var wrapperKey = \"WRAPPER_\" + field.type + \"_\" + field.name;\n var controlKey = \"CONTROL_\" + field.type + \"_\" + field.name;\n\n nodes.push(\n \n \n {children}\n \n \n );\n }\n }\n\n }\n })\n\n var formClass = \"form\";\n if (this.props.readOnly) formClass += \" read-only\";\n if (this.props.light) formClass += \" light\";\n\n return (\n
\n {nodes}\n
\n\n )\n }\n});\n\nwindow._ewarsForm = Form;\nexport default Form;\n","class SettingsField extends React.Component {\n static defaultProps = {\n vertical: false,\n label: null,\n required: false\n }\n\n render() {\n return (\n
\n
{this.props.label}
\n
\n {this.props.children}\n
\n
\n )\n }\n}\n\nexport default SettingsField;\n","import Panel from \"./c.panel\";\n\nclass SettingsForm extends React.Component {\n static defaultProps = {\n title: null,\n icon: \"fa-wrench\",\n description: null\n }\n\n render() {\n let description = this.props.description ?\n
{this.props.description}
\n : null;\n\n return (\n \n
\n
\n
\n
{this.props.title}
\n
\n {description}\n\n
\n {this.props.children}\n
\n
\n
\n )\n }\n}\n\nexport default SettingsForm;\n","class SettingsSection extends React.Component {\n render() {\n return (\n
\n
{this.props.title}
\n {this.props.children}\n
\n )\n }\n}\n\nexport default SettingsSection;\n","import {\n LocationGroupField,\n IndicatorField,\n LocationField,\n ColourField,\n HTMLField as HTMLEditor,\n FileUploadField,\n MultiSelectField,\n CalcFieldDefinition as CalculatedFieldDefinition,\n SearchField\n} from \"./fields\";\n\nimport OptionsSet from \"./c.option_set\";\nimport ButtonSet from \"./c.button_set\";\n\nimport RulesEditor from \"./c.cmp.rules\";\nimport DataSourceDrop from \"./c.cmp.data_source_drop\";\nimport DateRangeSelector from \"./c.cmp.date_range_selector\";\nimport Sources from \"./c.cmp.sources\";\nimport SelectField from \"./c.cmp.select\";\nimport TextField from \"./c.cmp.text\";\nimport CommonCheckbox from \"./c.cmp.checkbox\";\n\n\nconst VERT = {\n borderBottom: \"1px solid rgba(0,0,0,0.9)\",\n marginTop: \"8px\",\n marginBottom: \"2px\"\n}\n\nclass Header extends React.Component {\n render() {\n return (\n \n \n {this.props.vertical ?\n
\n : null}\n
\n {this.props.data.i ?\n \n : null}\n {this.props.data.l}\n\n
\n
\n
\n )\n }\n}\n\nconst FIELDS = {\n TEXT: TextField,\n SELECT: SelectField,\n MULTI_SELECT : MultiSelectField,\n LOCATION: LocationField,\n BUTTONSET: ButtonSet,\n OPTIONSDEF: OptionsSet,\n FIELDRULES: RulesEditor,\n DATASOURCEDROP: DataSourceDrop,\n PERIOD: DateRangeSelector,\n INDICATOR: IndicatorField,\n CHECKBOX: CommonCheckbox,\n COLOUR: ColourField,\n HTML: HTMLEditor,\n SOURCES: Sources,\n CALC_FIELD_DEF: CalculatedFieldDefinition,\n FILE_UPLOAD : FileUploadField,\n SEARCH_SELECT : SearchField \n};\n\nclass Empty extends React.Component {\n render() {\n return (\n
Empty
\n )\n }\n}\n\n\nconst ERRORS = {\n REQUIRED: __(\"REQUIRED_FIELD\")\n}\n\n\nclass Field extends React.Component {\n static defaultProps = {\n errors: [],\n vertical: false,\n ro: false\n };\n\n _onChange = (prop, value, additional) => {\n let propKey=this.props.data.n;\n if(additional && additional.propKey){ // to change some other field value\n propKey=additional.propKey;\n }\n this.props.onChange(propKey, value, additional);\n };\n\n render() {\n let Cmp = Empty;\n\n if (FIELDS[this.props.data.t] != null) {\n Cmp = FIELDS[this.props.data.t.toUpperCase()];\n }\n\n let help;\n if (this.props.data.h) {\n help = __(this.props.data.h);\n }\n\n let hasErrors = this.props.errors.length > 0;\n\n let style = {};\n if (hasErrors) {\n style.borderLeft = \"3px solid #C62828\";\n }\n\n\n if (this.props.data.t == \"H\") {\n return ;\n }\n\n let labelStyle = {};\n if (this.props.data.label_style){\n labelStyle = {\n ...labelStyle,\n ...this.props.data.label_style\n }\n }\n if (this.props.vertical) labelStyle.fontWeight = \"normal\";\n if (this.props.boldLabels) labelStyle.fontWeight = \"bold\";\n\n const labelClass = this.props.labelClass ? this.props.labelClass : 'sys-label';\n \n return (\n \n {__(this.props.data.l)}\n \n \n {hasErrors ?\n
\n {this.props.errors.map((item) => {\n return (\n
{ERRORS[item]}
\n )\n })}\n
\n : null}\n
\n
\n )\n }\n}\n\nexport default class SystemForm extends React.Component {\n static defaultProps = {\n definition: [],\n id: null,\n onChange: null,\n enabled: true,\n vertical: false,\n errors: [],\n ro: false\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n data: ewars.copy(this.props.data, {})\n }\n\n }\n\n componentWillReceiveProps = (nextProps) => {\n this.state.data = ewars.copy(nextProps.data);\n };\n\n _onChange = (prop, value, additional) => {\n if (this.props.onChange) {\n this.props.onChange(prop, value);\n } else {\n this.setState({\n ...this.state,\n data: {\n ...this.state.data,\n [prop]: value\n }\n })\n }\n };\n\n validate = () => {\n\n };\n\n isValid = () => {\n\n };\n\n getData = () => {\n\n };\n\n render() {\n let sorted = this.props.definition.sort((a, b) => {\n if (a._o > b._o) return 1;\n if (a._o < b._o) return -1;\n return 0;\n });\n let fields = sorted.map((field) => {\n let shown = true;\n if (field.c) {\n let cmp = field.c[0];\n let rules = field.c.slice(1);\n\n if (cmp == \"ALL\") {\n let allTrue = true;\n rules.forEach((item) => {\n let [prop, comparison, value] = item.split(\":\");\n let dt = ewars.getKeyPath(prop, this.props.data);\n if (dt == \"true\") dt = true;\n if (dt == \"false\") dt = false;\n if (value == \"true\") value = true;\n if (value == \"false\") value = false;\n switch (comparison) {\n case \"=\":\n if (dt != value)\n allTrue = false;\n break;\n case \"!=\":\n if (dt == value)\n allTrue = false;\n break;\n case \">\":\n if (dt < value)\n allTrue = false;\n break;\n default:\n break;\n }\n });\n\n if (!allTrue) shown = false;\n } else {\n shown = false;\n rules.forEach((item) => {\n let [prop, comparison, value] = item.split(\":\");\n let dt = ewars.getKeyPath(prop, this.props.data);\n if (dt == \"true\") dt = true;\n if (dt == \"false\") dt = false;\n if (value == \"true\") value = true;\n if (value == \"false\") value = false;\n switch (comparison) {\n case \"=\":\n if (dt == value) shown = true;\n break;\n case \"!=\":\n if (dt != value) shown = true;\n break;\n case \">\":\n if (dt > value) shown = true;\n break;\n case \"<\":\n if (dt < value) shown = true;\n break;\n default:\n break;\n }\n })\n }\n }\n\n if (shown) {\n let value,\n errors = [];\n\n if (field.t != \"H\") {\n if (field.n.indexOf(\".\") >= 0) {\n value = ewars.getKeyPath(field.n, this.props.data);\n } else {\n value = this.props.data[field.n] != null ? this.props.data[field.n] : null;\n }\n if (value === null && field.t === \"TEXT\") value = \"\";\n\n // Check for errors\n this.props.errors.forEach((item) => {\n if (item[0] == field.n) {\n errors.push(item[1]);\n }\n });\n }\n\n return \n } else {\n return null;\n }\n });\n\n let className = \"system-form\";\n if (this.props.vertical) className += \" vertical\";\n\n return (\n
\n \n {fields}\n \n
\n )\n }\n}\n","var FormField = React.createClass({\n getInitialState: function () {\n return {\n content: \"\",\n helpShown: false,\n linkagesShown: false,\n errors: [],\n hasErrors: false,\n error: false\n };\n },\n\n _showHelp: function (e) {\n e.preventDefault();\n let title = ewars.I18N(this.props.field.label);\n ewars.prompt(\"fa-question-circle\", `Help: ${title}`, ewars.I18N(this.props.field.help));\n },\n\n _helpClick: function () {\n if (this.props.field.help) {\n ewars.prompt(\"fa-question-circle\", ewars.I18N(this.props.field.label), ewars.I18N(this.props.field.help), function () {\n\n })\n }\n },\n\n render: function () {\n var hasHelp = this.props.field.help ? true : false;\n var hasLinkages = this.props.field.linkages ? true : false;\n\n var fieldClass = \"form-field\";\n if (this.props.field.type == \"row\") fieldClass += \" form-row\";\n if (this.props.field.type == \"switch\") fieldClass += \" switch\";\n if (this.props.field.type == \"header\") fieldClass += \" header\";\n\n var labelClass = \"label\";\n if (this.props.field.type == \"row\") labelClass += \" row-label\";\n if (this.props.field.type == \"matrix\") labelClass += \" matrix-label\";\n\n var features = {\n help: true,\n error: true,\n label: true,\n fieldControls: true\n };\n\n if (this.props.readOnly || [\"row\", \"header\", \"matrix\"].indexOf(this.props.field.type) >= 0) {\n features.fieldControls = false;\n }\n\n let label = false;\n if (this.props.field.label !== false) {\n label = ewars.I18N(this.props.field.label);\n if(this.props.field.is_age_field) label += \" (\" + this.props.field.select_month_year_field + \"s)\"; \n if (this.props.field.required) label += \" *\";\n if (this.props.field.help) labelClass += \" has-help\";\n }\n\n var children = this.props.children;\n if (React.Children.count(this.props.children) == 1) {\n children = [this.props.children];\n }\n\n let showError = true;\n if ([\"matrix\", \"row\", \"header\"].indexOf(this.props.field.type) >= 0) showError = false;\n\n let errors;\n if (this.props.errors) {\n if (this.props.errors[this.props.field.path]) {\n errors = this.props.errors[this.props.field.path];\n }\n }\n\n let wrapper_style = {};\n if (label == false && !this.props.field.showLabelDiv) wrapper_style.paddingLeft = 15;\n\n if (this.props.field.type == 'content') {\n return (\n
\n
\n
\n
\n
\n

{this.props.field.content}

\n
\n
\n
\n
\n )\n }\n\n return (\n
\n {label || this.props.field.showLabelDiv?\n
\n \n
\n : null}\n\n
\n
\n
\n {children}\n
\n\n
\n
\n\n {features.fieldControls ?\n
\n \n \n \n \n \n \n
\n {errors ?\n
\n
\n
{errors}
\n
\n :\n  \n }\n
\n
\n : null}\n
\n )\n }\n\n});\n\nexport default FormField;\n","class LinkSelect extends React.Component {\n _onClick = (e) => {\n e.preventDefault();\n this.props.onClick();\n }\n\n render() {\n let view;\n if (this.props.icon && this.props.label) {\n view = (\n \n \n  {this.props.label}\n \n )\n } else if (this.props.icon && !this.props.label) {\n view = (\n \n \n \n )\n } else {\n view = (\n {this.props.label}\n )\n }\n return view;\n }\n}\n\n\nexport default LinkSelect;\n","var ListElement = React.createClass({\n _onClick: function () {\n this.props.onClick(this.props.data);\n },\n\n render: function () {\n\n var view;\n if (this.props.Template) {\n var Tmpl = this.props.Template;\n view = \n } else {\n var label = ewars.I18N(this.props.data.label);\n view =
{label}
\n }\n\n var className = \"ew-list-item\";\n if (this.props.value == this.props.data.id && this.props.value != null) className += \" active\";\n\n return (\n
\n {view}\n
\n )\n }\n});\n\nclass ListComponent extends React.Component {\n constructor(props) {\n super(props);\n }\n\n onChange = (item) => {\n if (!this.props.readOnly) {\n this.props.onUpdate(this.props.name, item.id, null, item);\n }\n };\n\n render() {\n let clickEvent = this.onChange;\n let listStyle={};\n if(this.props.width) listStyle.width=this.props.width;\n if (this.props.onClick) clickEvent = this.props.onClick;\n\n let items = this.props.items.map((item,index) => {\n return (\n \n )\n });\n\n if (items.length <= 0) {\n items =

No items available

;\n }\n\n return (\n
\n {items}\n
\n )\n }\n\n}\n\n\nexport default ListComponent;\n","import chroma from \"chroma-js\";\n\n// need to extend leaflet with TopoJSON support\nif (window.L) {\n L.TopoJSON = L.GeoJSON.extend({\n addData: function (jsonData) {\n if (jsonData.type === \"Topology\") {\n for (key in jsonData.objects) {\n geojson = topojson.feature(jsonData, jsonData.objects[key]);\n L.GeoJSON.prototype.addData.call(this, geojson);\n }\n }\n else {\n L.GeoJSON.prototype.addData.call(this, jsonData);\n }\n }\n });\n\n var _redIcon = L.icon({\n iconUrl: 'static/icons/map-markers/marker-red.png',\n\n iconSize: [21, 34], // size of the icon\n shadowSize: [26, 26], // size of the shadow\n iconAnchor: [10.5, 34], // point of the icon which will correspond to marker's location\n shadowAnchor: [10.5, 24], // the same for the shadow\n popupAnchor: [-3, -9] // point from which the popup should open relative to the iconAnchor\n });\n}\n\nvar _colorScale = chroma.scale(['#D5E3FF', '#003171']).domain([0, 1]);\n\nvar MapComponent = React.createClass({\n _map: null,\n _markers: [],\n _marker: null,\n\n propTypes: {\n layer: React.PropTypes.object,\n showTiles: React.PropTypes.bool,\n height: React.PropTypes.number,\n lat: React.PropTypes.number,\n lng: React.PropTypes.number,\n pointEditMode: React.PropTypes.bool,\n defaultLat: React.PropTypes.number,\n defaultLng: React.PropTypes.number\n },\n\n getDefaultProps: function () {\n return {\n showTiles: true,\n height: 300,\n pointEditMode: false,\n defaultLat: 51.505,\n defaultLng: -0.09\n }\n },\n\n getInitialState: function () {\n return {};\n },\n\n shouldComponentUpdate: function (nextProps, nextState) {\n if (this.props.height != nextProps.height) {\n return true;\n }\n\n if (nextProps.data) {\n if (nextProps.data.length > 0) {\n this._renderMarkers(nextProps.data);\n }\n }\n\n if (nextProps.lat != this.props.lat || nextProps.lng != this.props.lng) {\n if (this._marker) {\n if (nextProps.lat != \"-\" && nextProps.lat != \"\" && nextProps.lng != \"-\" && nextProps.lng != \"\") {\n this._map.setView([nextProps.lat, nextProps.lng]);\n this._marker.setLatLng([nextProps.lat, nextProps.lng]);\n }\n }\n }\n\n if (nextProps.defaultLat && nextProps.defaultLng) {\n this._map.setView([nextProps.defaultLat, nextProps.defaultLng]);\n }\n return false;\n },\n\n componentDidMount: function () {\n if (!this._map) this.renderEditor();\n },\n\n componentDidUpdate: function () {\n if (!this._map) this.renderEditor();\n if (this._map) this._map.invalidateSize();\n this._map.fitBounds(this._topoLayer.getBounds());\n },\n\n componentWillUnmount: function () {\n if (this._map) {\n this._map.off(\"click\", this.onMapClick);\n this._map = null;\n }\n },\n\n onChange: function (name, value) {\n this.props.onChange(name, value);\n },\n\n render: function () {\n if (this.props.height) {\n var style = {\n height: this.props.height + \"px\"\n }\n }\n\n return (\n
\n )\n },\n\n _renderMarkers: function (data) {\n for (var i in this._markers) {\n var item = this._markers[i];\n\n this._map.removeLayer(item);\n }\n\n this._markers = [];\n\n var redIcon = L.icon({\n iconUrl: 'static/icons/map-markers/marker-red.png',\n\n iconSize: [21, 34], // size of the icon\n shadowSize: [26, 26], // size of the shadow\n iconAnchor: [10.5, 34], // point of the icon which will correspond to marker's location\n shadowAnchor: [10.5, 24], // the same for the shadow\n popupAnchor: [-3, -9] // point from which the popup should open relative to the iconAnchor\n });\n\n for (i in data) {\n var item = data[i];\n\n var lat = ewars.getKeyPath(this.props.latProp, item);\n var lng = ewars.getKeyPath(this.props.lngProp, item);\n\n if ((lat && lng) && (lat != \"NULL\")) {\n var marker = L.marker([lat, lng], {\n icon: redIcon,\n zIndexOffset: 10000\n });\n\n this._markers.push(marker);\n this._map.addLayer(marker);\n }\n\n }\n\n },\n\n _onPointChange: function (lat, lng) {\n this.props.onPointChange(lat, lng);\n },\n\n renderEditor: function () {\n this._map = L.map(this.getDOMNode(), {\n minZoom: 0,\n maxZoom: 20,\n attributionControl: false,\n scrollWheelZoom: (this.props.pointEditMode ? false : true)\n });\n\n if (this.props.lat && this.props.lng) {\n this._map.setView([this.props.lat, this.props.lng], 1);\n } else {\n this._map.setView([this.props.defaultLat, this.props.defaultLng], 1);\n }\n\n var tiles = L.tileLayer(\n 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',\n {attribution: '© OpenStreetMap contributors, CC-BY-SA'});\n tiles.addTo(this._map);\n\n if (this.props.pointEditMode && this.props.defaultLat) {\n this._marker = L.marker([this.props.defaultLat, this.props.defaultLng], {\n icon: _redIcon,\n draggable: true,\n riseOnHover: true\n });\n\n this._map.addLayer(this._marker);\n this._map.setView([this.props.defaultLat, this.props.defaultLng], 10)\n }\n\n if (this.props.pointEditMode && this.props.lat) {\n this._marker = L.marker([this.props.lat, this.props.lng], {\n icon: _redIcon,\n draggable: true,\n riseOnHover: true\n });\n\n this._map.addLayer(this._marker);\n this._map.setView([this.props.lat, this.props.lng], 10)\n }\n\n if (this.props.data) {\n\n for (i in this.state.data) {\n var item = this.state.data[i];\n\n var lat = ewars.getKeyPath(this.props.latProp, item);\n var lng = ewars.getKeyPath(this.props.lngProp, item);\n\n if (lat && lng) {\n var marker = L.marker([lat, lng], {\n icon: _redIcon,\n zIndexOffset: 10000\n });\n\n this._markers.push(marker);\n this._map.addLayer(marker);\n }\n\n }\n\n }\n\n // Point editing features\n if (this.props.pointEditMode) {\n var self = this;\n this._map.on(\"click\", function (e) {\n if (self._marker) self._marker.setLatLng([e.latlng.lat, e.latlng.lng]);\n self._onPointChange(e.latlng.lat, e.latlng.lng);\n });\n\n if (this._marker) {\n this._marker.on(\"dragend\", function (e) {\n self._onPointChange(e.target.latlng.lat, e.target.latlng.lng);\n })\n }\n }\n\n if (this.props.layer) {\n this._topoLayer = new L.geoJson();\n\n this._topoLayer.addData(this.props.layer);\n this._topoLayer.setStyle({\n fillColor: _colorScale(Math.random()).hex(),\n fillOpacity: 0.1,\n color: \"#555\",\n weight: 1,\n opacity: 0.1\n });\n this._topoLayer.addTo(this._map);\n this._map.fitBounds(this._topoLayer.getBounds());\n }\n\n }\n\n});\n\nexport default MapComponent;\n","var MenuItem = React.createClass({\n _onClick: function () {\n this.props.data.handler();\n this.props.onClick();\n },\n\n render: function () {\n var icon;\n if (this.props.data.icon) {\n icon = \"fal \" + this.props.data.icon;\n }\n\n return (\n
\n {icon ?\n
\n : null}\n
{this.props.data.label}
\n
\n )\n }\n});\n\nvar DropDownMenu = React.createClass({\n getInitialProps: function () {\n return {\n isExpanded: false\n }\n },\n\n getInitialState: function () {\n return {\n isExpanded: false\n }\n },\n\n hide: function () {\n this.setState({isExpanded: false});\n document.removeEventListener(\"click\", this.hide);\n },\n\n _onHandleClick: function () {\n this.state.isExpanded = this.state.isExpanded ? false : true;\n if (this.state.isExpanded) {\n document.addEventListener(\"click\", this.hide);\n } else {\n document.removeEventListener(\"click\", this.hide);\n }\n this.forceUpdate();\n },\n\n _onClick: function () {\n this.state.isExpanded = false;\n document.removeEventListener(\"click\", this.hide);\n this.forceUpdate();\n },\n\n render: function () {\n var iconName = \"fal \" + this.props.icon;\n\n var items;\n items = _.map(this.props.menu, function (menuItem) {\n return \n }, this);\n\n return (\n
\n
\n
\n {this.props.label ?\n
{this.props.label}
\n : null}\n
\n
\n {this.state.isExpanded ?\n
\n {items}\n
\n : null}\n
\n )\n }\n});\n\nexport default DropDownMenu;\n","import Button from \"./c.button\";\nimport { SwitchField } from \"./fields\";\n\nvar ModalComponent = React.createClass({\n getDefaultProps: function () {\n return {\n visible: false,\n wizard: false,\n height: null,\n light: false,\n toggle: null,\n footer: true\n }\n },\n\n componentWillMount: function () {\n },\n\n getInitialState: function () {\n return {\n visible: false\n }\n },\n\n _onButtonAction: function (data) {\n if(this.props.data){\n this.props.onAction(data.action,this.props.data);\n }\n else{\n this.props.onAction(data.action);\n }\n },\n\n _processButtons: function () {\n var buttons = [];\n\n (this.props.buttons || []).forEach(button => {\n if(this.props.hasOwnProperty('showSpinner')){ \n this.props.showSpinner ? button.enabled = false : button.enabled = true\n }\n \n let key = ewars.utils.uuid();\n buttons.push()\n });\n\n return buttons;\n },\n\n _toggle: function () {\n this.props.onToggle(this.props.toggleState ? false : true)\n },\n\n _processToggle: function () {\n return (\n
\n \n \n \n \n \n
\n
{this.props.toggle.label}
\n
\n
\n \n
\n\n
\n
\n )\n },\n\n render: function () { \n \n var modalClass = \"modal-wrapper\";\n if (this.props.visible) modalClass += \" show\";\n if (!this.props.visible) modalClass += \" hide\";\n if (this.props.wizard) modalClass += \" wizard\";\n\n var buttons = this._processButtons();\n\n var hasButtons = false;\n if (buttons.length > 0) hasButtons = true;\n\n var style = {};\n if (this.props.width) {\n style.width = this.props.width + \"px\";\n }\n\n var bodyStyle = {};\n if (this.props.height) {\n bodyStyle.height = this.props.height;\n }\n\n if (this.props.overflowY) {\n bodyStyle.overflowY = this.props.overflowY;\n }\n var layoutStyle={};\n if(this.props.layoutMargin){\n layoutStyle.marginTop=this.props.layoutMargin;\n }\n var icon;\n if (this.props.icon) icon = \"fal \" + this.props.icon;\n\n var toggle;\n if (this.props.toggle) toggle = this._processToggle();\n\n return (\n
\n
\n
\n {this.props.title ?\n
\n
\n
\n {icon ?\n
\n \n
\n : null}\n
{this.props.title}
\n
\n
\n
\n : null}\n\n
\n
\n {this.props.children}\n
\n
\n {this.props.footer ?\n
\n
\n {toggle}\n\n {hasButtons ?\n
\n {buttons}\n
\n : null}\n
\n
\n : null}\n
\n\n\n
\n
\n )\n }\n});\n\nexport default ModalComponent;\n","import TextField from \"./c.cmp.text\";\nimport { Layout, Row, Cell } from \"./layout\";\nimport Panel from \"./c.panel\";\nimport Shade from \"./c.shade\";\nimport { ActionGroup } from \"./c.action_button\";\nimport Toolbar from \"./c.toolbar\";\nimport ButtonGroup from \"./c.button_group\";\n\nconst TYPE_SELECT = {\n options: [\n [\"STATIC\", \"STATIC\"],\n [\"DYNAMIC\", \"DYNAMIC\"]\n ]\n};\n\nconst ACTIONS = [,\n [\"fa-trash\", 'CLEAR'],\n [\"fa-plus\", \"ADD\"]\n];\n\nconst ACTIONS_OPTION = [\n [\"fa-caret-up\", \"UP\"],\n [\"fa-caret-down\", \"DOWN\"],\n [\"fa-trash\", \"REMOVE\"]\n];\n\nconst CONFIG_ACTIONS = [\n {label: __(\"CLOSE\"), icon: \"fa-times\", action: \"CLOSE\"}\n];\n\nclass OptionConfig extends React.Component {\n constructor(props) {\n super(props);\n }\n\n render() {\n return (\n \n \n \n \n \n \n \n \n )\n }\n}\n\nclass StaticOption extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = {\n showOptions: false\n }\n }\n\n _value = (prop, value) => {\n this.props.onChange(this.props.index, 0, value);\n };\n\n _display = (prop, value) => {\n this.props.onChange(this.props.index, 1, value);\n };\n\n _action = (action) => {\n if (action == \"REMOVE\") {\n this.props.onRemove(this.props.index);\n }\n\n if (action == \"UP\") {\n if (this.props.index > 0) {\n this.props.onUp(this.props.index);\n }\n }\n\n if (action == \"DOWN\") {\n this.props.onDown(this.props.index);\n }\n\n if (action == \"CONFIG\") {\n this.setState({\n showOptions: true\n })\n }\n\n if (action == \"CLOSE\") {\n this.setState({\n showOptions: false\n })\n }\n\n };\n\n _onConfigChange = (config) => {\n\n };\n\n render() {\n return (\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n \n {this.state.showOptions ?\n \n : null}\n\n \n
\n )\n }\n}\n\nexport default class OptionsSet extends React.Component {\n static defaultProps = {\n showTypes: true,\n title: __(\"OPTIONS_EDITOR\"),\n data: {\n i18: true\n },\n onChange: function () {\n }\n };\n\n constructor(props) {\n super(props);\n }\n\n _onFileChange = (e) => {\n console.log(e);\n console.log(e.target.files[0]);\n if (e.target.files[0]) {\n if (e.target.files[0].name.indexOf(\".csv\") < 0) {\n ewars.growl(__(\"UPLOAD_CSV_FILE_ONLY_MESSEGE\"));\n return;\n }\n }\n this.selectedFileName = e.target.files[0].name;\n let reader = new FileReader(e.target);\n\n reader.onloadend = function() {\n if (reader.error) {\n console.log(reader.error.message);\n }\n }\n\n reader.onload = () => {\n let dataURL = reader.result;\n\n let lines = dataURL.split(\"\\n\");\n let options = [];\n lines.forEach(item => {\n let nodes = item.split(',');\n options.push([nodes[0] || \"\", {en: nodes[1] || \"\"}]);\n });\n\n this.props.onChange(this.props.data.n, options);\n\n }\n\n let res = reader.readAsText(e.target.files[0]);\n };\n\n _action = (action, index) => {\n if (action == \"CLEAR\") {\n this.props.onChange(this.props.data.n, []);\n return;\n }\n\n if (action == \"ADD\") {\n let cp = ewars.copy(this.props.value || []);\n if (this.props.data.i18) {\n cp.push([\"\", {en: \"\"}])\n } else {\n cp.push([\"\", \"\"])\n }\n\n this.props.onChange(this.props.data.n, cp);\n return;\n }\n\n if (action == \"UP\") {\n let cp = ewars.copy(this.props.value || []);\n if (index > 0) {\n let tmp = cp[index - 1];\n cp[index - 1] = cp[index];\n cp[index] = tmp;\n this.props.onChange(this.props.data.n, cp);\n }\n return;\n }\n\n if (action == \"DOWN\") {\n let cp = ewars.copy(this.props.value || []);\n if (index < cp.length - 1) {\n let tmp = cp[index + 1];\n cp[index + 1] = cp[index];\n cp[index] = tmp;\n this.props.onChange(this.props.data.n, cp);\n }\n return;\n }\n\n };\n\n _onValueChange = (index, prop, value) => {\n let cp = ewars.copy(this.props.value || []);\n cp[index][prop] = value;\n\n this.props.onChange(this.props.data.n, cp);\n };\n\n _remove = (index) => {\n let cp = ewars.copy(this.props.value || []);\n cp.splice(index, 1);\n this.props.onChange(this.props.data.n, cp);\n\n };\n\n render() {\n let type_value = \"STATIC\";\n\n let options = (this.props.value || []).map((item, index) => {\n return {\n this._action(\"UP\", index)\n }}\n onDown={(index) => {\n this._action(\"DOWN\", index)\n }}\n data={item}/>;\n });\n\n return (\n
\n \n \n \n \n
\n document.getElementById('getFile').click()}>{__(\"CHOOSE_FILE\")}\n \n
\n \n
\n
\n \n \n \n \n\n \n \n \n \n \n
\n
\n
\n \n {__(\"STORED_VALUE\")}\n \n \n {__(\"DISPLAY_VALUE\")}\n \n \n \n
\n
\n {options}\n
\n
\n
\n
\n
\n )\n }\n}\n","class Panel extends React.Component {\n render() {\n let style = {};\n if (this.props.style) {\n for (let i in this.props.style) {\n style[i] = this.props.style[i];\n }\n }\n return (\n
\n {this.props.children}\n
\n )\n }\n}\n\nexport default Panel;\n","import Moment from \"moment\";\nimport RangeUtils from \"./utils/RangeUtils\";\n\nimport { Layout, Row, Cell } from \"./layout\";\nimport Toolbar from \"./c.toolbar\";\n\nimport {\n NumericField as NumberField,\n TextField\n} from \"./fields\";\n\nimport DayPicker from \"./fields/c.date.day\";\n\nconst STYLES = {\n QK_DROP: {\n position: \"absolute\",\n left: 0,\n width: \"100%\",\n bottom: \"-150px\",\n height: \"150px\",\n overflowY: \"scroll\",\n background: \"#fff\",\n padding: \"5px\",\n zIndex: 9,\n borderLeft: \"1px solid #000000\",\n borderRight: \"1px solid #000000\",\n borderBottom: \"1px solid #000000\",\n borderBottomRightRadius: \"3px\",\n borderBottomLeftRadius: \"3px\"\n\n }\n}\n\nconst QUICK_RANGES = [\n [\n [\"-30D\", __(\"LAST_30_DAYS\")],\n [\"-60D\", __(\"LAST_60_DAYS\")],\n [\"-6M\", __(\"LAST_6_MONTHS\")],\n [\"-1Y\", __(\"LAST_1_YEAR\")],\n [\"-2Y\", __(\"LAST_2_YEAR\")],\n [\"-5Y\", __(\"LAST_5_YEAR\")]\n ],\n [\n [\"-1D\", __(\"YESTERDAY\")],\n [\"-2D\", __(\"DAY_BEFORE_YESTRDY\")],\n [\"-7D\", __(\"THIS_DAY_LAST_WEEK\")],\n [\"PREV_WEEK\", __(\"PREVIOUS_WEEK\")],\n [\"PREV_52_WEEKS\", __(\"PREVIOUS_52_WEEKS\")],\n [\"PREV_MONTH\", __(\"PREVIOUS_MONTH\")],\n [\"PREV_YEAR\", __(\"PREVIOUS_YEAR\")]\n ],\n [\n [\"NOW\", __(\"TODAY\")],\n [\"CUR_WEEK\", __(\"THIS_WEEK\")],\n [\"CUR_MONTH\", __(\"THIS_MONTH\")],\n [\"CUR_YEAR\", __(\"THIS_YEAR\")],\n [\"CUR_YEAR_FIRST_WEEK\", __(\"CUR_YEAR_FIRST_WEEK\")], \n [\"CUR_YEAR_52_WEEKS\" , \"This year 52 weeks\"],\n [\"CUR_YEAR_WEEKS\" , \"This year weeks\"]\n\n ]\n];\n\nconst QUICK_RANGES_TEMPLATE = [\n [\n [\"DD-30D\", \"Previous 30 days\"],\n [\"DD-60D\", \"Previous 60 days\"],\n [\"DD-6M\", \"Previous 6 months\"],\n [\"DD-1Y\", \"Previous 1 year\"],\n [\"DD-2Y\", \"Previous 2 years\"],\n [\"DD-5Y\", \"Previous 5 years\"]\n ],\n [\n [\"DD-1D\", \"Previous Day\"],\n [\"DD-2D\", \"Day before previous day\"],\n [\"DD-7D\", \"Same day previous week\"],\n [\"D_PREV_WEEK\", \"Previous week\"],\n [\"D_PREV_MONTH\", \"Previous month\"],\n [\"D_PREV_YEAR\", \"Previous year\"],\n [\"CUR_YEAR\", __(\"THIS_YEAR\")]\n ],\n [\n [\"D_DATE\", \"Document date\"],\n [\"D_CUR_WEEK\", \"Document week\"],\n [\"D_CUR_MONTH\", \"Document month\"],\n [\"D_CUR_YEAR\", \"Document year\"],\n [\"D_YEAR_FIRST_WEEK\", \"Document year first week\"],\n [\"D_YEAR_WEEKS\" , \"Document year weeks\"],\n [\"D_YEAR_52_WEEKS\" , \"Document year 52 weeks\"]\n\n ]\n];\n\nconst PRESETS = [\n [\"NOW\", \"Today\"],\n [\"END\", \"End date\"],\n [\"N_W_S\", \"This week start\"],\n [\"N_W_E\", \"This week end\"],\n [\"N_M_S\", \"This month start\"],\n [\"N_M_E\", \"This month end\"],\n [\"N_Y_S\", \"This year start\"],\n [\"N_Y_E\", \"This year end\"],\n [\"N_Y_F_W_S\", \"This year first week start\"],\n [\"N_Y_F_W_E\", \"This year first week end\"]\n];\n\nconst PRESETS_TEMPLATE = [\n [\"D_DATE\", \"Document date\"],\n [\"NOW\", \"Today\"],\n [\"END\", \"End date\"],\n [\"D_W_S\", \"Document week start\"],\n [\"D_W_E\", \"Document week end\"],\n [\"D_M_S\", \"Document month start\"],\n [\"D_M_E\", \"Document month end\"],\n [\"D_Y_S\", \"Document year start\"],\n [\"D_Y_E\", \"Document year end\"],\n ['D_Y_S_ISO', 'Document year start (ISOW)'],\n ['D_Y_E_ISO', 'Document year end (ISOW)'],\n [\"N_W_S\", \"This week start\"],\n [\"N_W_E\", \"This week end\"],\n [\"N_M_S\", \"This month start\"],\n [\"N_M_E\", \"This month end\"],\n [\"N_Y_S\", \"This year start\"],\n [\"N_Y_E\", \"This year end\"],\n [\"N_Y_F_W_S\", \"This year first week start\"],\n [\"N_Y_F_W_E\", \"This year first week end\"],\n [\"D_Y_F_W_S\", \"Document year first week start\"],\n [\"D_Y_F_W_E\", \"Document year first week end\"],\n [\"D_CUR_YEAR_FIRST_WEEK\", \"Document year first week\"]\n\n\n\n\n];\n\nclass QuickRange extends React.Component {\n constructor(props) {\n super(props)\n }\n\n _onClick = (e) => {\n e.preventDefault();\n e.stopPropagation();\n this.props.onClick(this.props.data);\n };\n\n render() {\n return (\n
{this.props.data[1]}
\n )\n }\n}\n\nclass Offset extends React.Component {\n constructor(props) {\n super(props);\n }\n\n _onChange = (prop, value) => {\n this.props.onChange(value);\n };\n\n offsetHelp = () => {\n ewars.prompt(\"fa-question-circle\", __(\"OFFSET_HELP\"),\n __(\"OFFSET_DESCRIPTION\") \n ,async () => {\n \n }, () => { },\n __(\"CONFIRM\"), __(\"CANCEL\"), true, false);\n }\n\n render() {\n return (\n
\n
\n \n \n
\n
\n \n
\n )\n }\n}\n\nclass DateSelect extends React.Component {\n static defaultProps = {\n showEndDate: false,\n showStartDate: false\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n shown: false,\n mode: \"CUSTOM\"\n }\n }\n\n componentDidMount() {\n window.__hack__.addEventListener(\"click\", this._handleBodyClick);\n }\n\n componentWillUnmount() {\n window.__hack__.removeEventListener(\"click\", this._handleBodyClick);\n }\n\n _handleBodyClick = (evt) => {\n if (this.refs.selector) {\n const area = this.refs.selector.getDOMNode ? this.refs.selector.getDOMNode() : this.refs.selector;\n\n if (!area.contains(evt.target)) {\n this.setState({\n shown: false\n })\n }\n }\n };\n\n _trigger = () => {\n this.setState({\n shown: !this.state.shown\n })\n\n };\n\n _setMode = (mode) => {\n this.setState({mode})\n };\n\n _onPickerChange = (value) => {\n this.props.onChange(this.props.prop, Moment.utc(value).format(\"YYYY-MM-DD\"));\n this.setState({\n shown: false\n })\n };\n\n _selectpreset = (preset) => {\n this.props.onChange(this.props.prop, \"{\" + preset[0] + \"}\");\n };\n\n _onOffsetChange = (value) => {\n let newValue = RangeUtils.applyOffset(this.props.value, value);\n this.props.onChange(this.props.prop, newValue);\n };\n\n render() {\n\n let label;\n\n let pickerValue;\n if (RangeUtils.isDate(this.props.value)) {\n pickerValue = RangeUtils.getDate(this.props.value);\n }\n label = RangeUtils.formatDateSpec(this.props.value);\n\n let code;\n if (RangeUtils.hasCode(this.props.value)) {\n code = RangeUtils.getCode(this.props.value);\n }\n\n let offset = RangeUtils.getOffset(this.props.value);\n\n let presets = PRESETS;\n\n if (this.props.mode == \"TEMPLATE\") presets = PRESETS_TEMPLATE;\n if (ewars.TEMPLATE_MODE == \"TEMPLATE\") presets = PRESETS_TEMPLATE;\n\n return (\n
\n
\n \n {label}\n \n \n \n \n
\n {this.state.shown ?\n
\n \n \n \n \n \n \n \n \n \n
\n
\n {presets.map(preset => {\n return ;\n })}\n
\n
\n
\n
\n \n \n \n \n \n
\n
\n
\n
\n
\n : null}\n
\n )\n }\n}\n\nclass DatePop extends React.Component {\n constructor(props) {\n super(props)\n }\n\n render() {\n return
\n }\n}\n\nclass PresetItem extends React.Component {\n constructor(props) {\n super(props)\n }\n\n _onClick = () => {\n this.props.onClick(this.props.data);\n };\n\n render() {\n let className = \"dr-preset\";\n if (this.props.code == this.props.data[0]) className += \" active\";\n\n return (\n
\n \n \n
\n
\n {this.props.data[1]}\n
\n
\n )\n\n }\n}\n\nclass PeriodSelector extends React.Component {\n static defaultProps = {\n mode: \"DEFAULT\", // or TEMPLATE,\n value: [],\n vertical: false,\n showQuick: true\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n showRanges: false\n }\n }\n\n _onQkSelect = (qk) => {\n let tmp = RangeUtils.processPreset(qk[0]);\n if (this.props.onUpdate) this.props.onUpdate(this.props.config.nameOverride || this.props.name, [tmp[0], tmp[1]])\n if (this.props.onChange) this.props.onChange(this.props.n, [tmp[0], tmp[1]], null, null);\n\n this.setState({\n showRanges: false\n })\n };\n\n _onPropChange = (prop, value) => {\n let data = this.props.value || [];\n\n if (prop == \"start\") data[0] = value;\n if (prop == \"end\") data[1] = value;\n\n if (this.props.onChange) this.props.onChange(this.props.n, data);\n if (this.props.onUpdate) this.props.onUpdate(this.props.config.nameOverride || this.props.name, data, null, null);\n };\n\n quickRangeHelp = () => {\n ewars.prompt(\"fa-question-circle\", __(\"QUICK_RANGE_HELP\"),\n __(\"QUICK_RANGE_DESCRIPTION\") \n ,async () => {\n \n }, () => { },\n __(\"CONFIRM\"), __(\"CANCEL\"), true, false);\n };\n\n _showRanges = () => {\n this.setState({\n showRanges: !this.state.showRanges\n })\n };\n\n render() {\n let startDate = this.props.value && this.props.value[0] || Moment.utc().format(\"YYYY-MM-DD\");\n let endDate = this.props.value && this.props.value[1] || Moment.utc().format(\"YYYY-MM-DD\");\n let RANGES = QUICK_RANGES;\n if (ewars.TEMPLATE_MODE == \"TEMPLATE\") RANGES = QUICK_RANGES_TEMPLATE;\n\n if (this.props.vertical) {\n\n let items = [];\n RANGES.forEach((item, rangeIndex) => {\n item.forEach((qk, qkIndex) => {\n items.push()\n })\n })\n\n return (\n
\n \n \n \n \n \n
\n\n \n \n
\n
\n
\n \n \n  {__(\"QUICK_RANGES\")}\n \n \n \n \n {this.state.showRanges ?\n
\n {items}\n
\n : null}\n
\n
\n
\n
\n\n )\n }\n\n return (\n
\n \n \n \n \n \n
\n\n \n \n
\n {this.props.showQuick ?\n \n \n \n \n \n {RANGES.map((item,index) => {\n return (\n \n {item.map((qk,ind) => {\n return \n })}\n \n )\n })}\n \n \n \n : null}\n\n
\n
\n
\n )\n }\n}\n\nexport default PeriodSelector;\n","import Button from \"./c.button\";\n\nclass Prompt extends React.Component {\n static defaultProps = {\n confirmText: \"OK\",\n cancelText: \"Cancel\"\n };\n\n constructor(props) {\n super(props);\n }\n\n render() {\n console.log(this.props.data);\n\n let actions = [\n {label: this.props.confirmText, action: \"OK\"},\n {label: this.props.cancelText, action: \"CANCEL\"}\n ];\n\n if (this.props.data.actions) actions = this.props.data.actions;\n\n return (\n
\n
\n
\n
\n
{this.props.data.title}
\n
\n
{this.props.data.content}
\n
\n
\n {actions.map(item => {\n return (\n \n )\n })}\n
\n
\n
\n
\n
\n )\n }\n}\n\nexport default Prompt;\n","import DataTable from \"./datatable/c.datatable\";\n\nvar COLUMNS = [\n {\n name: \"data_date\",\n label: __(\"REPORT_DATE\"),\n width: 80,\n fmt: function (value) {\n return ewars.DATE(value, \"DAY\")\n }\n },\n {\n name: \"location_name\",\n label: __(\"LOCATION\"),\n width: 250,\n fmt: function (value) {\n return ewars.I18N(value)\n }\n },\n {\n name: \"submitted_date\",\n label: __(\"SUBMITTED_DATE\"),\n width: 100,\n fmt: function (value) {\n return ewars.DATE(value, \"DAY\")\n }\n },\n {\n name: \"creator_name\",\n filterKey: \"created_by\",\n label: __(\"SUBMITTED\"),\n width: 150\n },\n {\n name: \"created\",\n label: __(\"CREATED\"),\n width: 100,\n fmt: ewars.DATE\n },\n {\n name: \"form_id\",\n label: __(\"FORM_ID\"),\n width: 100\n },\n {\n name: \"form_version_id\",\n label: __(\"FORM_VEERSION_ID\"),\n width: 300\n },\n {\n name: \"source\",\n label: __(\"SOURCE\"),\n width: 100\n },\n {\n name: \"status\",\n label: __(\"STATUS\"),\n width: 100\n },\n {\n name: \"uuid\",\n label: __(\"UUID\"),\n width: 300\n }\n];\n\nclass ReportBrowser extends React.Component {\n static defaultProps = {\n form_id: null,\n filter: null,\n editor: false,\n actions: [],\n id: null,\n onAction: () => {\n }\n };\n\n constructor(props) {\n super(props);\n\n this.state = {};\n\n this._reload(props.form_id);\n }\n\n componentWillReceiveProps(nextProps) {\n if (nextProps.form_id != this.props.form_id) {\n this._reload(nextProps.form_id);\n }\n }\n\n _reload = (form_id) => {\n ewars.tx(\"com.ewars.form.definition\", [form_id])\n .then((resp) => {\n this.setState({\n definition: resp\n })\n })\n };\n\n render() {\n if (!this.state.definition) {\n return (\n
{__(\"LOADING_DEF\")}
\n )\n }\n\n let grid;\n if (this.state.definition.grid) {\n grid = ewars.copy(this.state.definition.grid);\n\n grid.columns.forEach((col) => {\n switch (col.name) {\n case \"submitted_date\":\n col.fmt = (val) => {\n return ewars.DATE(val, \"YYYY-MM-DD HH:mm\")\n };\n break;\n case \"created\":\n col.fmt = (val) => {\n ewars.DATE(val, \"YYYY-MM-DD HH:mm\");\n };\n break;\n case \"data_date\":\n col.fmt = (val) => {\n return ewars.DATE(val, this.state.definition.interval);\n };\n break;\n default:\n break;\n }\n })\n }\n\n\n return (\n
\n \n
\n )\n }\n}\n\nexport default ReportBrowser;\n","import { Layout, Row, Cell } from \"./layout\";\nimport Toolbar from \"./c.toolbar\";\nimport Button from \"./c.cmp.button\";\n\nclass Shade extends React.Component {\n static defaultProps = {\n shown: false,\n title: \"\",\n actions: [],\n onAction: null,\n toolbar: true\n };\n\n constructor(props) {\n super(props);\n }\n\n onClose = () => {\n this.props.onAction(\"CLOSE\", null);\n };\n\n _onAction = (data) => {\n this.props.onAction(data.action);\n };\n\n componentDidMount() {\n if (this.props.shown) {\n } else {\n\n }\n }\n\n componentWillReceiveProps(nextProps) {\n if (nextProps.shown && !this.props.shown) {\n }\n }\n\n render() {\n if (!this.props.shown) return (\n
\n );\n\n return (\n
\n \n \n \n
\n \n
\n
\n \n
\n \n {this.props.toolbar ?\n \n
\n {this.props.actions.map((item,index) => {\n return (\n \n\n )\n })}\n
\n
\n : null}\n\n \n \n {this.props.children}\n \n \n\n
\n
\n
\n
\n
\n
\n )\n }\n}\n\nexport default Shade;\n\n","var Spinner = React.createClass({\n render: function () {\n return (\n
\n
\n \n
\n
\n )\n }\n});\n\nexport default Spinner;\n","const ICON_STYLE = {\n maxWidth: \"20px\",\n flexBasis: \"0px\",\n flexGrow: 1,\n padding: \"8px 5px\",\n textAlign: \"center\",\n borderTopLeftRadius: \"3px\"\n}\n\nconst LABEL_STYLE = {\n wordBreak: \"keep-all\",\n flex: \"0 0 auto\",\n padding: \"8px\"\n}\n\nclass Tab extends React.Component {\n constructor(props) {\n super(props);\n }\n\n _onClick = (e) => {\n e.preventDefault();\n this.props.onClick(this.props.data);\n };\n\n render() {\n let className = \"panelsbar-btn\";\n if (this.props.active) className += \" panelsbar-btn-active\";\n\n let icon, label;\n if (this.props.icon) icon = ;\n if (this.props.label) label = __(this.props.label);\n\n return (\n
\n
\n {icon ?\n
{icon}
\n : null}\n
{label}
\n
\n
\n )\n }\n}\n\nexport default Tab;\n","'use strict';\n\nvar VertTab = React.createClass({\n getDefaultProps: function () {\n return {\n active: false\n }\n },\n\n _onClick: function () {\n this.props.onClick(this.props.view);\n },\n\n render: function () {\n var className = \"ide-tab\";\n if (this.props.active) className += \" ide-tab-down\";\n\n var iconClass = \"fal \" + this.props.icon;\n\n return (\n
\n  {this.props.label}\n
\n )\n }\n});\n\nexport default VertTab;\n","class Toolbar extends React.Component {\n static defaultProps = {\n label: null,\n buttons: []\n };\n\n constructor(props) {\n super(props);\n }\n\n render() {\n return (\n
\n
\n
\n {this.props.icon ?\n
\n \n
\n : null}\n {this.props.label ?\n
{__(this.props.label)}{this.props.note ? (*{__(this.props.note)}) : \"\"}
\n : null}\n\n
\n {this.props.buttons}\n
\n {this.props.children}\n
\n
\n
\n )\n }\n}\n\nexport default Toolbar;","class Handle extends React.Component {\n render() {\n let formName, locationName;\n if (this.props.value.form_id) {\n this.props.assignments.forEach((item) => {\n if (item.form_id == this.props.value.form_id) {\n formName = ewars.I18N(item.form_name);\n\n if (this.props.value.location_id) {\n item.locations.forEach((loc) => {\n if (loc.location_id == this.props.value.location_id) {\n locationName = ewars.I18N(loc.name[0]);\n }\n })\n }\n }\n })\n }\n\n let name = __(\"NO_SELECTION\");\n if (formName && locationName) name = `${formName} - ${locationName}`;\n\n return (\n
\n \n \n {name}\n \n \n \n \n \n
\n )\n }\n}\n\nclass SelectChild extends React.Component {\n render() {\n let locationName = ewars.I18N(this.props.data.name[0]);\n return (\n
{this.props.onClick(this.props.data)}}>\n
{locationName}
\n
\n )\n }\n}\n\nclass SelectItem extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = {\n show: false\n }\n }\n\n _toggle = () => {\n this.setState({\n show: !this.state.show\n })\n };\n\n _onClick = (location) => {\n this.props.onSelect([this.props.data, location]);\n };\n\n render() {\n let formName = ewars.I18N(this.props.data.form_name);\n\n let className = this.state.show ? \"fal fa-caret-down\" : \"fal fa-caret-right\";\n return (\n
\n
\n \n \n \n \n \n {formName}\n \n \n
\n {this.state.show ?\n
\n {this.props.data.locations.map((item,index) => {\n return \n })}\n
\n : null}\n
\n )\n }\n}\n\nexport default class AssignmentSelector extends React.Component {\n _initialLoad = false;\n _initialized = false;\n\n static defaultProps = {\n showForm: true\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n data: [],\n assignment: null,\n show: false\n };\n\n ewars.tx('com.ewars.user.assignments')\n .then((resp) => {\n this._isLoaded = true;\n this.setState({\n data: resp\n })\n })\n\n }\n\n componentDidMount() {\n window.__hack__.addEventListener('click', this.handleBodyClick);\n }\n\n componentWillUnmount() {\n window.__hack__.removeEventListener('click', this.handleBodyClick);\n }\n\n handleBodyClick = (evt) => {\n if (this.refs.selector) {\n const area = this.refs.selector.getDOMNode ? this.refs.selector.getDOMNode() : this.refs.selector;\n\n if (!area.contains(evt.target)) {\n this.state.showLocations = false;\n this.forceUpdate();\n }\n }\n };\n\n _toggle = (e) => {\n e.stopPropagation();\n this.setState({\n show: !this.state.show\n })\n };\n\n handleClick = (e) => {\n e.stopPropagation();\n };\n\n _init = (props) => {\n ewars.tx(\"com.ewars.user.assignments\")\n .then((resp) => {\n this.setState({\n data: resp\n })\n })\n };\n\n _onChange = (data) => {\n this.props.onUpdate(this.props.name, data);\n };\n\n _onSelect = (data) => {\n let loc = data[1];\n let value = loc.uuid;\n this.state.show = false;\n this.props.onUpdate(this.props.name, value, data);\n };\n\n render() {\n return (\n
\n \n {this.state.show ?\n
\n
\n {this.state.data.map((item,index) => {\n return (\n \n )\n })}\n
\n
\n : null}\n
\n )\n }\n}","module.exports = {\n // User Types\n SUPER_ADMIN: \"SUPER_ADMIN\",\n INSTANCE_ADMIN: \"INSTANCE_ADMIN\",\n GLOBAL_ADMIN: \"GLOBAL_ADMIN\",\n ACCOUNT_ADMIN: \"ACCOUNT_ADMIN\",\n USER: \"USER\",\n ORG_ADMIN: \"ORG_ADMIN\",\n LAB_USER: \"LAB_USER\",\n REGIONAL_ADMIN: \"REGIONAL_ADMIN\",\n COUNTRY_SUPERVISOR: \"ACCOUNT_ADMIN\",\n BOT: \"BOT\",\n API_USER: \"API_USER\",\n\n // General states\n DISABLED: \"DISABLED\",\n\n // Reporting intervals\n NONE: \"NONE\",\n DAY: \"DAY\",\n WEEK: \"WEEK\",\n MONTH: \"MONTH\",\n YEAR: \"YEAR\",\n\n // Filterable time periods\n ONEM: \"1M\",\n THREEM: \"3M\",\n SIXM: \"6M\",\n ONEY: \"1Y\",\n YTD: \"YTD\",\n ALL: \"ALL\",\n\n ACTIVE: \"ACTIVE\",\n INACTIVE: \"INACTIVE\",\n DRAFT: \"DRAFT\",\n DELETED: \"DELETED\",\n\n DEFAULT: \"DEFAULT\",\n\n DESC: \"DESC\",\n ASC: \"ASC\",\n\n FORWARD: \"FORWARD\",\n BACKWARD: \"BACKWARD\",\n\n // Icons\n ICO_DASHBOARD: \"fal fa-tachometer\",\n ICO_USERS: \"fal fa-users\",\n ICO_USER: \"fal fa-user\",\n ICO_REPORT: \"fal fa-file\",\n ICO_REPORTS: \"fal fa-clipboard\",\n ICO_GRAPH: \"fal fa-chart-bar\",\n ICO_INVESTIGATION: \"fal fa-search\",\n ICO_RELATED: \"fal fa-link\",\n ICO_GEAR: \"fal fa-gear\",\n ICO_CARET_DOWN: \"fal fa-caret-down\",\n ICO_SEND: \"fal fa-envelope\",\n ICO_SUBMIT: \"fal fa-senf\",\n ICO_SAVE: \"fal fa-save\",\n ICO_CANCEL: \"fal fa-times\",\n\n // Chart Types\n SERIES: \"SERIES\",\n BAR: \"BAR\",\n MAP: \"MAP\",\n PIE: \"PIE\",\n SCATTER: \"SCATTER\",\n\n // Indicator types\n CUSTOM: \"CUSTOM\",\n\n OPEN: \"OPEN\",\n CLOSED: \"CLOSED\",\n\n // Form types\n PRIMARY: \"PRIMARY\",\n INVESTIGATIVE: \"INVESTIGATIVE\",\n LAB: \"LAB\",\n SURVEY: \"SURVEY\",\n\n // Alert stages\n VERIFICATION: \"VERIFICATION\",\n RISK_ASSESS: \"RISK_ASSESS\",\n RISK_CHAR: \"RISK_CHAR\",\n OUTCOME: \"OUTCOME\",\n\n // OUtcomes\n\n // Stage states\n DISCARD: \"DISCARD\",\n MONITOR: \"MONITOR\",\n ADVANCE: \"ADVANCE\",\n COMPLETED: \"COMPLETED\",\n PENDING: \"PENDING\",\n RESPOND: \"RESPOND\",\n DISCARDED: \"DISCARDED\",\n AUTODISCARDED: \"AUTODISCARDED\",\n\n // Risk levels\n LOW: \"LOW\",\n MODERATE: \"MODERATE\",\n HIGH: \"HIGH\",\n SEVERE: \"SEVERE\",\n\n // Colors\n RED: \"red\",\n GREEN: \"green\",\n ORANGE: \"orange\",\n YELLOW: \"yellow\",\n\n // Default Formats\n DEFAULT_DATE: \"YYYY-MM-DD\",\n\n // Dates\n MONTHS_LONG: [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"],\n MONTHS_SHORT: [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"],\n CAL_DAYS_LABELS: [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thurs\", \"Fri\", \"Sat\"],\n CAL_DAYS_IN_MONTH: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],\n\n};","export let FIELD_FORM = [\n {\n _o: 0,\n n: \"label\",\n i18: true,\n t: \"TEXT\",\n l: __(\"FIELD_LABEL\"),\n d: {en: \"New Field\"},\n p : __(\"ENTER_FIELD_LABEL\"),\n },\n {\n _o: 1,\n n: \"export_label\",\n i18: true,\n t: \"TEXT\",\n l: __(\"FIELD_EXPORT_LABEL\"),\n p : __(\"ENTER_FIELD_EXPORT_LABEL\"),\n },\n {\n _o: 1,\n n: \"type\",\n t: \"SELECT\",\n l: __(\"FIELD_TYPE\"),\n d: \"text\",\n o: [\n [\"text\", __(\"TEXT_FIELD\")],\n [\"number\", __(\"NUMERIC_FIELD\")],\n [\"select\", __(\"SELECT_FIELD\")],\n [\"textarea\", __(\"TEXTAREA_FIELD\")],\n [\"header\", __(\"HEADER_FIELD\")],\n [\"matrix\", __(\"MATRIX_FIELD\")],\n [\"row\", __(\"MATRIX_ROW_FIELD\")],\n [\"display\", __(\"DISPLAY\")],\n [\"date\", __(\"DATE_FIELD\")],\n ['location', __('LOCATION')],\n ['lat_long', __('LAT_LONG_FIELD')],\n ['calculated', __('CALCULATED_FIELD')],\n // ['repeater', __('REPEATER_ONLY_WEB')],\n // ['related', __('RELEATED_RECORDS_WEB_ONLY')],\n [\"time\", __(\"TIME_FIELD\")],\n [\"main_form_field\", __(\"MAIN_FORM_FIELD\")],\n [\"media\", __(\"MEDIA_FIELD\")]\n ]\n },\n {\n _o: 3,\n n: \"name\",\n t: \"TEXT\",\n l: __(\"FIELD_NAME\"),\n p : __(\"ENTER_FIELD_NAME\"),\n },\n {\n _o: 2,\n n: \"main_form_field_key\",\n t: \"SELECT\",\n l: __(\"MAIN_FORM_FIELD\"),\n r: true,\n o: [],\n c: [\n \"ALL\",\n \"type:=:main_form_field\"\n ]\n },\n {\n _o: 2,\n n: \"media_type\",\n t: \"SELECT\",\n l: __(\"MEDIA_TYPE\"),\n r: true,\n o: [\n [\"ANY\", __(\"PHOTO_VIDEO\")],\n [\"IMAGE\", __(\"IMAGE\")],\n [\"VIDEO\", __(\"VIDEO\")]\n ],\n c: [\n \"ALL\",\n \"type:=:media\"\n ]\n },\n {\n _o: 3,\n n: \"main_form_field_editable\",\n l: __(\"IS_EDITABLE\"),\n t: \"BUTTONSET\",\n o: [\n [false, __(\"NO\")],\n [true, __(\"YES\")]\n ],\n d: false,\n c: [\n \"ALL\",\n \"type:=:main_form_field\"\n ]\n },\n \n {\n _o: 3,\n n: \"required\",\n l: __(\"REQUIRED\"),\n t: \"BUTTONSET\",\n o: [\n [false, __(\"NO\")],\n [true, __(\"YES\")]\n ],\n d: false,\n c: [\n \"ANY\",\n \"type:=:select\",\n \"type:=:text\",\n \"type:=:textarea\",\n \"type:=:date\",\n \"type:=:location\",\n \"type:=:number\",\n \"type:=:lat_long\",\n \"type:=:main_form_field\",\n \"type:=:media\"\n ]\n },\n {\n _: 4,\n n: \"is_search_field\",\n t: \"BUTTONSET\",\n l: __(\"SHOW_SEARCH_BOX\"),\n o: [\n [false, __(\"NO\")],\n [true, __(\"YES\")]\n ],\n c:[\n \"ALL\",\n \"type:=:select\"\n ]\n },\n /**\n {\n _o: 3.1,\n n: \"unique\",\n l: \"Unique Constraint\",\n t: \"BUTTONSET\",\n o: [\n [false, \"No\"],\n [true, \"Yes\"]\n ],\n h: \"Fields marked as unique will restrict the form from being submitted if a record with the same combination of values in its unique fields already exists.\",\n d: false,\n c: [\n \"ANY\",\n \"type:!=:header\",\n \"type:!=:matrix\",\n \"type:!=:row\",\n \"type:!=:display\",\n \"type:!=:markdown\",\n ]\n },\n **/\n {\n _: 4,\n n: \"show_mobile\",\n t: \"BUTTONSET\",\n l: __(\"SHOW_ON_MOBILE\"),\n o: [\n [false, __(\"NO\")],\n [true, __(\"YES\")]\n ]\n },\n {\n _o: 4,\n n: 'sti',\n t: 'SELECT',\n l: __(\"LOCATION_TYPE\"),\n r: true,\n o: [],\n c: [\n 'ALL',\n 'type:=:location'\n ],\n os: ['location_type', 'id', 'name', {}]\n\n },\n {\n _o: 5,\n n: \"show_row_label\",\n t: \"BUTTONSET\",\n l: __(\"SHOW_ROW_LABEL\"),\n o: [\n [false, __(\"NO\")],\n [true, __(\"YES\")]\n ],\n c: [\n \"ALL\",\n \"type:=:row\"\n ]\n },\n {\n _o: 5,\n n: \"is_age_field\",\n t: \"BUTTONSET\",\n l: __(\"IS_AGE_LABEL\"),\n o: [\n [false, __(\"NO\")],\n [true, __(\"YES\")]\n ],\n c: [\n \"ALL\",\n \"type:=:number\"\n ]\n },\n {\n _o: 6,\n n: \"date_type\",\n t: \"SELECT\",\n l: __(\"DATE_TYPE\"),\n r: true,\n d: \"DAY\",\n o: [\n [\"DAY\", __(\"DAY\")],\n [\"WEEK\", __(\"WEEK\")],\n [\"MONTH\", __(\"MONTH\")],\n [\"YEAR\", __(\"YEAR\")]\n // [\"CUSTOM\", \"Custom\"]\n ],\n c: [\n \"ALL\",\n \"type:=:date\"\n ]\n },\n /**\n {\n _o: 6.1,\n n: \"is_canonical_date\",\n t: \"BUTTONSET\",\n r: true,\n l: \"Canonical Date?\",\n o: [\n [false, \"No\"],\n [true, \"Yes\"]\n ],\n c: [\n \"ALL\",\n \"type:=:date\"\n ]\n },\n **/\n {\n _o: 6.2,\n n: \"interval_days\",\n t: \"NUMERIC\",\n l: __(\"NUMBER_OF_DAYS_IN_INTERVAL\"),\n r: true,\n d: 0,\n c: [\n \"ALL\",\n \"date_type:=:CUSTOM\"\n ]\n },\n {\n _o: 6.3,\n n: \"interval_base_date\",\n t: \"DATE\",\n dt: \"DAY\",\n l: __(\"BASE_DATE\"),\n r: true,\n c: [\n \"ALL\",\n \"date_type:=:CUSTOM\"\n ]\n },\n {\n _o: 6.4,\n n: \"date_format\",\n t: \"TEXT\",\n l: __(\"OUTPUT_FORMAT\"),\n c: [\n \"ALL\",\n \"type:=:date\"\n ],\n p : __(\"ENTER_OUTPUT_FORMAT\"),\n },\n {\n _o: 6,\n n: \"select_date_field\",\n t: \"SELECT\",\n l: __(\"CALCULATE_AGE_FROM\"),\n c: [\n \"ALL\",\n \"type:=:number\",\n \"is_age_field:=:true\"\n ],\n o: []\n },\n {\n _o: 7,\n n: \"select_month_year_field\",\n t: \"BUTTONSET\",\n l: __(\"SELECT_MONTH_DAY_LABEL\"),\n o: [\n [\"month\", __(\"Month(s)\")],\n [\"year\", __(\"YEARS\")]\n ],\n c: [\n \"ALL\",\n \"type:=:number\",\n \"is_age_field:=:true\",\n ]\n },\n {\n _o: 8,\n n: \"help\",\n t: \"TEXT\",\n i18: true,\n l: __(\"FIELD_INSTRUCTIONS\"),\n ml: true,\n p : __(\"ENTER_FIELD_INSTRUCTIONS\"),\n c: [\n \"ANY\",\n \"type:=:select\",\n \"type:=:text\",\n \"type:=:textarea\",\n \"type:=:date\",\n \"type:=:location\",\n \"type:=:number\"\n ]\n },\n {\n _o: 9,\n n: \"options\",\n t: \"OPTIONSDEF\",\n l: __(\"OPTIONS\"),\n o: [\n [\"month\", __(\"Month(s)\")],\n [\"day\", __(\"Day(s)\")]\n ],\n i18: true,\n c: [\n \"ALL\",\n \"type:=:select\"\n ]\n },\n \n {\n _o: 10,\n n: \"default\",\n t: \"TEXT\",\n p : __(\"ENTER_DEFAULT_VALUE\"),\n l: __(\"DEFAULT_VALUE\"),\n c: [\n \"ANY\",\n \"type:=:number\",\n \"type:=:select\",\n \"type:=:text\",\n \"type:=:textarea\",\n \"type:=:date\",\n \"type:=:location\"\n ]\n },\n {\n _o: 11,\n n: \"redacted\",\n t: \"BUTTONSET\",\n l: __(\"REDACTED\"),\n d: false,\n o: [\n [false, __(\"NO\")],\n [true, __(\"YES\")]\n ],\n c: [\n \"ANY\",\n \"type:=:select\",\n \"type:=:number\",\n \"type:=:text\",\n \"type:=:date\",\n \"type:=:location\",\n \"type:=:textarea\"\n ]\n },\n {\n _o: 11,\n n: \"header_style\",\n t: \"SELECT\",\n l: __(\"HEADER_STYLE\"),\n d: \"TITLE\",\n o: [\n [\"style-title\", __(\"TITLE\")],\n [\"style-sub-title\", __(\"SUB_TITLE\")]\n ],\n c: [\n \"ALL\",\n \"type:=:header\"\n ]\n },\n {\n _o: 12,\n n: \"placeholder\",\n t: \"TEXT\",\n p : __(\"ENTER_PLACEHOLDER\"),\n l: __(\"PLACEHOLDER\"),\n c: [\n \"ANY\",\n \"type:=:text\",\n \"type:=:number\",\n \"type:=:textarea\"\n ]\n },\n {\n _o: 13,\n n: \"barcode\",\n t: \"BUTTONSET\",\n l: __(\"BARCODE\"),\n o: [\n [false, __(\"NO\")],\n [true, __(\"YES\")]\n ],\n c: [\n \"ANY\",\n \"type:=:text\",\n \"type:=:number\"\n ]\n },\n {\n _o: 14,\n n: \"block_future\",\n t: \"BUTTONSET\",\n l: __(\"ALLOW_FUTURE_DATES\"),\n d: false,\n o: [\n [false, __(\"YES\")],\n [true, __(\"NO\")]\n ],\n c: [\n \"ALL\",\n \"type:=:date\"\n ]\n },\n {\n _o: 15,\n n: \"multiple\",\n t: \"BUTTONSET\",\n l: __(\"SELECT_MULTIPLE\"),\n o: [\n [false, __(\"NO\")],\n [true, __(\"YES\")]\n ],\n d: false,\n c: [\n \"ALL\",\n \"type:=:select\"\n ]\n },\n // {\n // _o: 16,\n // n: \"max\",\n // t: \"TEXT\",\n // p : __(\"ENTER_MAXIMUM\"),\n // l: __(\"MAXIMUM\"),\n // c: [\n // \"ALL\",\n // \"type:=:number\"\n // ]\n // },\n // {\n // _o: 17,\n // n: \"min\",\n // t: \"TEXT\",\n // p : __(\"ENTER_MINIMUM\"),\n // l: __(\"MINIMUM\"),\n // c: [\n // \"ALL\",\n // \"type:=:number\"\n // ]\n // },\n {\n _o: 18,\n n: \"decimal_allowed\",\n t: \"BUTTONSET\",\n l: __(\"ALLOW_DECIMALS\"),\n o: [\n [false, __(\"NO\")],\n [true, __(\"YES\")]\n ],\n d: true,\n c: [\n \"ALL\",\n \"type:=:number\"\n ]\n },\n {\n _o: 18,\n n: \"negative\",\n t: \"BUTTONSET\",\n l: __(\"ALLOW_NEGATIVE\"),\n o: [\n [false, __(\"NO\")],\n [true, __(\"YES\")]\n ],\n d: true,\n c: [\n \"ALL\",\n \"type:=:number\"\n ]\n },\n {\n _o: 19,\n n: \"conditional_bool\",\n t: \"BUTTONSET\",\n o: [\n [false, __(\"NO\")],\n [true, __(\"YES\")]\n ],\n l: __(\"CONDITIONAL_LOGIC\")\n },\n {\n _o: 20,\n n: \"conditions\",\n t: \"FIELDRULES\",\n l: __(\"RULES_EDITOR\"),\n c: [\n \"ALL\",\n \"conditional_bool:=:true\"\n ]\n },\n {\n _o: 21,\n n: \"calc_def\",\n t: \"CALC_FIELD_DEF\",\n l: __(\"SOURCE_FIELDS\"),\n c: [\n \"ALL\",\n \"type:=:calculated\"\n ]\n },\n {\n _o: 22,\n n: \"calc_def_formula\",\n t: \"BUTTONSET\",\n o: [\n [\"SUM\", __(\"SUM\")],\n [\"SUBTRACT\", __(\"SUBTRACT\")],\n [\"CONCATE\", __(\"CONCATENATE\")],\n \n ],\n d:\"CONCATE\",\n l: __(\"OPERATOR_TYPE\"),\n c: [\n \"ALL\",\n \"type:=:calculated\"\n ]\n },\n {\n _o: 23,\n n: \"calc_def_formula_separator\",\n t: \"TEXT\",\n p : __(\"ENTER_SEPARATOR\"),\n l: __(\"SEPARATOR\"),\n c: [\n \"ALL\",\n \"type:=:calculated\",\n \"calc_def_formula:=:CONCATE\"\n ]\n },\n {\n _o: 24,\n n: \"display_for_sort_view\",\n l: __('DISPLAY_IN_MAIN_RECORD'),\n t: \"BUTTONSET\",\n o: [\n [false, __(\"NO\")],\n [true, __(\"YES\")]\n ],\n d: false\n },\n];\n\nexport const setFormFieldsForAge = (fields) => {\n let formFieldForAge = [];\n for(const key in fields) {\n if(fields[key][\"type\"] === \"date\")\n formFieldForAge.push([fields[key].name, ewars.formatters.I18N_FORMATTER(fields[key].label)])\n }; \n FIELD_FORM = FIELD_FORM.map(field => {\n if(field.n===\"select_date_field\")\n return {...field, o:formFieldForAge}\n return field\n }) \n}","import {\n DateField,\n SelectField,\n TextAreaField,\n SwitchField,\n LocationField as LocationSelect,\n NumericField as NumberField,\n TextField\n} from \"../fields/\";\n\nimport Button from \"../c.button\";\nimport ContextMenu from \"../c.context_menu\";\n\nconst TYPES = {\n date: DateField,\n select: SelectField,\n text: TextField,\n textarea: TextAreaField,\n switch: SwitchField,\n location: LocationSelect,\n number: NumberField\n};\n\n\nconst CELL_ACTIONS = [\n [\"fa-save\", \"SAVE\", \"Save\"],\n [\"fa-times\", \"CANCEL\", \"Cancel\"]\n]\n\nclass DataTableCell extends React.Component {\n static defaultProps = {\n editable: false,\n editor: null\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n context: false,\n edit: false,\n tempVal: null\n }\n }\n\n componentWillMount() {\n window.__hack__.addEventListener(\"contextmenu\", this._clear);\n ewars.subscribe(\"UNMOUNT_EDIT\", this._unmountEdit);\n }\n\n componentWillUnmount() {\n window.__hack__.removeEventListener(\"contextmenu\", this._clear);\n }\n\n _unmountEdit = () => {\n this.setState({\n edit: false\n })\n };\n\n _clear = (evt) => {\n if (this.refs.item) {\n if (!this.refs.item.contains(evt.target)) {\n this.setState({\n context: false\n })\n }\n }\n };\n\n _edit = () => {\n };\n\n _context = (e) => {\n e.preventDefault();\n this.setState({\n context: true\n })\n };\n\n _onAction = (data) => {\n this.setState({\n context: false\n });\n this.props.onAction(data, this.props.col, this.props.row);\n };\n\n _onDblClick = (e) => {\n e.preventDefault();\n if (!this.props.editable) {\n this.props.onAction(\"CLICK\", this.props.col, this.props.row);\n } else {\n let val;\n if (this.props.col.name.startsWith(\"data.\")) {\n val = this.props.row.data[this.props.col.name.replace(\"data.\", \"\")]\n } else if (this.props.col.name.indexOf(\".\") > 0) {\n val = ewars.getKeyPath(this.props.col.name, this.props.row);\n } else {\n val = this.props.row[this.props.col.name] || null;\n }\n\n let editVal = val;\n if (this.props.col.editor) {\n // Edit a column other than this one\n if (this.props.col.editor.editColumn != null) {\n editVal = ewars.getKeyPath(this.props.col.editor.editColumn, this.props.row);\n }\n\n if (this.props.col.editor.editIndex != null) {\n editVal = editVal[this.props.col.editor.editIndex];\n }\n }\n\n ewars.emit(\"UNMOUNT_EDIT\");\n this.setState({\n edit: true,\n tempVal: editVal\n })\n }\n };\n\n _onCellAction = (action) => {\n switch (action) {\n case \"CANCEL\":\n this.setState({\n edit: false,\n tempVal: null\n });\n return true;\n case \"SAVE\":\n this.setState({\n edit: false\n });\n this.props.col.editor.onChange(this.props.col, this.props.row, this.state.tempVal);\n return true;\n default:\n return true;\n }\n };\n\n _onValueChange = (e) => {\n this.setState({\n tempVal: e.target.value\n })\n };\n\n render() {\n let style = {width: this.props.width};\n\n let val;\n if (this.props.col.name.startsWith(\"data.\")) {\n if (this.props.col.config.type == \"main_form_field\"){\n // val = this.props.row.main_report_data[this.props.col.config.main_form_field_key]\n val = this.props.row.main_report_data ? this.props.row.main_report_data[this.props.col.config.main_form_field_key] : null\n }else{\n val = this.props.row.data[this.props.col.name.replace(\"data.\", \"\")]\n }\n } else if (this.props.col.name.indexOf(\".\") > 0) {\n val = ewars.getKeyPath(this.props.col.name, this.props.row);\n } else {\n val = this.props.row[this.props.col.name] || null;\n }\n let rawVal = val;\n\n\n if (this.props.col.config.type == \"select\" && this.props.col.config.options) {\n if (this.props.col.config.multiple) {\n if (val) {\n let newVal = [];\n this.props.col.config.options.forEach((item) => {\n if (val.indexOf(item[0]) >= 0) {\n newVal.push(ewars.I18N(item[1]));\n }\n });\n\n val = newVal.join(\", \")\n }\n\n } else {\n this.props.col.config.options.forEach(function (item) {\n if (item[0] == val) val = item[1]\n })\n }\n }\n\n if (this.props.col.config.type == \"lat_long\" && val != null) val = `Lat: ${rawVal[0]}, Lng: ${rawVal[1]}`;\n\n if (this.props.col.fmt) val = this.props.col.fmt(val, this.props.row);\n\n if (val instanceof Object) val = ewars.I18N(val);\n\n let valueClass = \"dt-cell-value\";\n if (this.props.col.config.type == \"number\") valueClass += \" rh-align\";\n\n let EditControl;\n // if (this.state.edit) {\n // EditControl = TYPES[this.props.col.config.type];\n // }\n\n let cellStyle = {\n border: \"1px dashed transparent\",\n position: \"relative\",\n height: \"100%\"\n };\n if (this.props.col.color) {\n let color = this.props.col.color(rawVal);\n cellStyle.borderColor = color;\n cellStyle.textShadow = `0px -2px 3px ${color}`;\n }\n\n\n return (\n \n
\n {this.state.edit ?\n
\n \n
\n : null}\n {!this.state.edit ?\n
{val}
\n : null}\n {this.state.context ?\n
\n \n
\n : null}\n {this.state.edit ?\n
\n \n
\n : null}\n
\n \n )\n }\n}\n\nexport default DataTableCell;\n","import Button from \"../c.button\";\nimport {\n SelectField,\n NumericField as NumberField,\n DateField,\n TextField,\n LocationField,\n LocationGroupField\n} from \"../fields/\";\nimport { isRegionalAdminWithLocGroup } from \"../utils/User\";\n\nconst CONDITION_OPTIONS = [\n [\"EQ\", __(\"IS_EQ_TO\")],\n [\"NEQ\", __(\"IS_NEQ_TO\")],\n [\"NULL\", __(\"IS_EMPTY\")],\n [\"NOT_NULL\", __(\"IS_NOT_EMPTY\")],\n [\"STARTS_WITH\", __(\"BEGINS_WITH\")],\n [\"ENDS_WITH\", __(\"ENDS_WITH\")],\n [\"GT\", __(\"IS_GT\")],\n [\"GTE\", __(\"IS_GT_OR_EQ_TO\")],\n [\"LT\", __(\"IS_LT\")],\n [\"LTE\", __(\"IS_LT_OR_EQ_TO\")],\n [\"IN\", __(\"IS_BETWEEN\")],\n [\"NIN\", __(\"IS_NOT_BETWEEN\")],\n [\"WITHIN\", __(\"IS_WITHIN\")],\n [\"NWITHIN\", __(\"IS_NOT_WITHIN\")],\n [\"UNDER\", __(\"UNDER\")],\n [\"AT+UNDER\", __(\"AT_PLUS_UNDER\")],\n [\"CONTAINS\", __(\"CONTAINS\")]\n];\n\nvar FIELDS = {\n filter_condition: {\n type: \"select\",\n options: []\n },\n number_field: {}\n};\n\nconst TYPE_MAPS = {\n \"user\": [\"EQ\", \"NEQ\", \"IN\", \"NIN\"],\n \"number\": [\"NULL\", \"NOT_NULL\", \"EQ\", \"NEQ\", \"GT\", \"GTE\", \"LT\", \"LTE\", \"IN\", \"NIN\"],\n \"text\": [\"EQ\", \"NEQ\", \"NULL\", \"NOT_NULL\", \"CONTAINS\"],\n \"textarea\": [\"EQ\", \"NEQ\", \"NULL\", \"NOT_NULL\", \"CONTAINS\"],\n \"date\": [\"NULL\", \"NOT_NULL\", \"EQ\", \"NEQ\", \"GT\", \"GTE\", \"LT\", \"LTE\", \"IN\", \"NIN\"],\n \"location\": [\"EQ\", \"UNDER\"],\n \"select\": [\"NULL\", \"NOT_NULL\", \"EQ\", \"NEQ\"],\n \"LOCGROUPS\": [\"EQ\"],\n \"EQUALS\" : [\"EQ\"]\n};\n\nclass User extends React.Component {\n constructor(props) {\n super(props)\n }\n\n _select = () => {\n this.props.onSelect(this.props.data);\n };\n\n render() {\n let className = \"fal fa-square\";\n if([\"NIN\", \"IN\"].indexOf(this.props.condition) >= 0){\n if (this.props.value) {\n if (this.props.value.indexOf(this.props.data.id) >= 0) className = \"fal fa-check-square\"\n }\n }\n\n return (\n
\n
\n
\n {[\"NIN\", \"IN\"].indexOf(this.props.condition) >= 0 ?\n
\n \n
: null}\n
\n {this.props.data.name}\n
\n [{this.props.data.email}]\n
\n
\n
\n
\n )\n }\n}\n\nclass UserFilter extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = {\n search: \"\",\n data: [],\n resource: \"user\"\n }\n }\n\n componentDidMount() {\n if(this.props.applyResourceOffline){\n this.setState({\n resource : \"user_search\" \n })\n } \n }\n\n query = (term) => {\n ewars.tx(\"com.ewars.query\", [this.state.resource, ['id', 'name', 'email'], {name: {like: term}}, null, null, null, null])\n .then(function (resp) {\n this.setState({\n data: resp\n })\n }.bind(this))\n };\n\n _onSearchChange = (e) => {\n if (e.target.value.length > 2) {\n this.setState({search: e.target.value});\n this.query(this.state.search)\n } else {\n this.setState({search: e.target.value, data: []})\n }\n };\n\n _onSelect = (user) => {\n if([\"NIN\", \"IN\"].indexOf(this.props.condition) >= 0){\n let arrdata = this.props.value;\n if (!arrdata) arrdata = [];\n if (arrdata.indexOf(user.id) < 0) {\n arrdata.push(user.id);\n this.props.onUpdate(this.props.name, arrdata);\n } else {\n let place = arrdata.indexOf(user.id);\n arrdata.splice(place, 1);\n this.props.onUpdate(this.props.name, arrdata);\n }\n }else{\n this.props.onUpdate(this.props.name, user.id);\n }\n };\n\n render() {\n return (\n
\n
\n
\n \n
\n
\n {this.state.data.length > 0 ?\n
\n
\n
\n
\n {this.state.data.map(function (user) {\n return ;\n }.bind(this))}\n
\n
\n
\n
\n : null}\n
\n )\n }\n}\n\nclass DataTableFilterControl extends React.Component {\n static defaultProps = {\n filter: null,\n id: null,\n cell: null,\n top: 0,\n left: 0\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n filter: {},\n condition: \"EQ\",\n value: null,\n upper: null\n }\n\n let comparator = \"EQ\";\n let value = '';\n let cellName = this.props.cell.config.filterKey || this.props.cell.name;\n if (this.props.filter[cellName]) {\n // There is filtering applied\n let keys = Object.keys(this.props.filter[cellName]);\n if (keys.indexOf(\"type\") >= 0) keys.splice(keys.indexOf(\"type\"), 1);\n comparator = keys[0].toUpperCase();\n value = this.props.filter[cellName][keys[0]] || \"\"\n if(keys[0] == 'isEmpty' && this.props.filter[cellName][keys[0]]) value = \"\"\n }\n if (!value && this.props.cell.config.type == 'date') value = new Date();\n this.state.condition = comparator;\n this.state.value = value;\n }\n componentDidMount() {\n if(Array.isArray(this.state.value)){\n this.setState({\n ...this.state,\n value : this.state.value[0],\n upper : this.state.value[1],\n })\n }\n }\n componentWilReceiveProps(props) {\n let comparator = this.state.condition;\n let value = this.state.value;\n let cellName = props.cell.config.filterKey || props.cell.name;\n if (props.filter[cellName]) {\n // There is filtering applied\n let keys = Object.keys(props.filter[cellName]);\n if (keys.indexOf(\"type\") >= 0) keys.splice(keys.indexOf(\"type\"), 1);\n comparator = keys[0].toUpperCase();\n value = props.filter[cellName][keys[0]] || \"\"\n }\n\n if (!value && props.cell.config.type == 'date') value = new Date();\n\n this.state.condition = comparator;\n this.state.value = value;\n }\n\n _filterChange = (prop, value) => {\n this.setState({\n ...this.state,\n [prop]: value\n })\n };\n\n _clear = () => {\n this.setState({\n ...this.state,\n condition: null,\n value: null,\n upper: null\n });\n this.props.onSave(null);\n };\n\n _onSave = () => {\n if (!this.state.condition) {\n this.props.onSave(null);\n return;\n }\n if(this.state.value == undefined){\n ewars.growl(__(\"INVALID_FILTER_MESSAGE\"))\n return;\n }\n\n if(this.props.cell.config.type == \"user\"){\n if(this.state.value == ''){\n ewars.growl(__(\"SELECT_VALID_VALUE\"))\n return;\n }\n }\n\n if(this.state.condition == \"IN\" && this.props.cell.config.type != \"user\"){\n if(this.state.upper == undefined || this.state.upper == null || this.state.value == undefined || this.state.value == null){\n ewars.growl(__(\"INVALID_FILTER_MESSAGE\"))\n return;\n }\n }\n let filter = {};\n switch (this.state.condition) {\n case \"EQ\":\n filter.eq = this.state.value;\n filter.type = this.props.cell.config.type || null;\n break;\n case \"NEQ\":\n filter.neq = this.state.value;\n filter.type = this.props.cell.config.type || null;\n break;\n case \"GT\":\n filter.gt = this.state.value;\n filter.type = this.props.cell.config.type || null;\n break;\n case \"GTE\":\n filter.gte = this.state.value;\n filter.type = this.props.cell.config.type || null;\n break;\n case \"LT\":\n filter.lt = this.state.value;\n filter.type = this.props.cell.config.type || null;\n break;\n case \"LTE\":\n filter.lte = this.state.value;\n filter.type = this.props.cell.config.type || null;\n break;\n case \"UNDER\":\n filter.under = this.state.value;\n filter.type = this.props.cell.config.type || null;\n break;\n case \"AT+UNDER\":\n filter.within = this.state.value;\n filter.type = this.props.cell.config.type || null;\n break;\n case 'CONTAINS':\n filter.contains = this.state.value;\n filter.type = this.props.cell.config.type || null;\n break;\n case \"IN\":\n if(this.props.cell.config.type == \"user\") filter.in = this.state.value;\n else filter.in = [this.state.value,this.state.upper];\n filter.type = this.props.cell.config.type || null;\n break;\n case \"NIN\":\n if(this.props.cell.config.type == \"user\") filter.nin = this.state.value;\n else filter.nin = [this.state.value,this.state.upper];\n filter.type = this.props.cell.config.type || null;\n break;\n case \"NULL\":\n filter.isEmpty = true\n filter.type = this.props.cell.config.type || null;\n break;\n case \"NOT_NULL\":\n filter.isEmpty = false\n filter.type = this.props.cell.config.type || null;\n break;\n default:\n filter.eq = this.state.value;\n filter.type = this.props.cell.config.type || null;\n break;\n }\n\n this.props.onSave(filter);\n };\n\n render() {\n let Control;\n if (this.props.cell.config.type == \"date\") Control = DateField;\n if (this.props.cell.config.type == \"select\") Control = SelectField;\n if(this.props.cell.config.type == \"EQUALS\") Control = SelectField;\n if (this.props.cell.config.type == \"number\") Control = NumberField;\n if (this.props.cell.config.type == \"location\") Control = LocationField;\n if (this.props.cell.config.type == \"text\") Control = TextField;\n if (this.props.cell.config.type == \"textarea\") Control = TextField;\n if (this.props.cell.config.type == \"user\") Control = UserFilter;\n if (this.props.cell.config.type == \"LOCGROUPS\") Control = LocationGroupField;\n\n\n let SecondControl;\n if ([\"NIN\", \"IN\", \"WITHIN\", \"NWITHIN\"].indexOf(this.state.condition) >= 0 && this.props.cell.config.type != \"user\" ) {\n SecondControl = Control;\n }\n\n let options;\n if (TYPE_MAPS[this.props.cell.config.type]) {\n options = [];\n CONDITION_OPTIONS.forEach(function (item) {\n if (TYPE_MAPS[this.props.cell.config.type].indexOf(item[0]) >= 0) {\n options.push(item);\n }\n }.bind(this));\n FIELDS.filter_condition.options = options;\n }\n\n let controlConfig = ewars.copy(this.props.cell.config);\n if (this.props.cell.config.type == \"location\") {\n controlConfig[\"locationFilter\"] = true;\n if (window.user.user_type != \"SUPER_ADMIN\") {\n controlConfig.parentId = window.user.clid;\n if (window.user.user_type == \"REGIONAL_ADMIN\") {\n controlConfig.parentId = window.user.location_id;\n }\n }\n\n // Remove location id if location group is assigend to regional admin\n if(isRegionalAdminWithLocGroup()){\n controlConfig.parentId = null;\n }\n }\n\n let hasFilter = false;\n let cellName = this.props.cell.config.filterKey || this.props.cell.name;\n\n return (\n
\n
\n \n
\n
\n \n \n
\n {!(this.state.condition == \"NULL\" || this.state.condition == \"NOT_NULL\") ? \n
\n \n \n {SecondControl ?\n \n : null}\n
\n\n
\n
\n :null}\n
\n\n
\n \n \n
\n
\n
\n )\n }\n}\n\nexport default DataTableFilterControl;\n","import { isRegionalAdminWithLocGroup } from \"../utils/User\";\nimport DataTableFilterControl from \"./c.datatable.filter_control\";\n\nclass DataTableHeaderCell extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = {\n showControl: false,\n controls: false\n };\n }\n\n componentWillMount() {\n window.__hack__.addEventListener(\"click\", this._clear);\n window.__hack__.addEventListener(\"contextmenu\", this._clear);\n }\n\n componentWillUnmount() {\n window.__hack__.removeEventListener(\"click\", this._clear);\n window.__hack__.removeEventListener(\"contextmenu\", this._clear);\n }\n\n _clear = (evt) => {\n if (this.refs.item) {\n if (!this.refs.item.contains(evt.target)) {\n this.setState({\n controls: false\n })\n }\n }\n };\n\n static defaultProps = {\n sortable: false,\n filterable: false\n };\n\n _filter = () => {\n this.setState({\n controls: !this.state.controls\n })\n };\n\n _sort = (e) => {\n e.preventDefault();\n let colName;\n if (this.props.data.config) {\n if (this.props.data.config.name) colName = this.props.data.config.name;\n }\n if (this.props.data.name) colName = this.props.data.name;\n\n if (this.props.data.config.sortKey) colName = this.props.data.config.sortKey;\n ewars.z.dispatch(this.props.id || \"DT_TRANSIENT\", \"UPDATE_SORT\", {\n field: colName,\n fieldType: this.props.data.type || this.props.data.config.type\n })\n };\n\n _cancelFilter = () => {\n this.setState({\n controls: false\n })\n };\n\n _applyFilter = (value) => {\n this.setState({\n controls: false\n }, () => {\n ewars.z.dispatch(this.props.id || \"DT_TRANSIENT\", \"UPDATE_FILTER\", {\n key: this.props.data.config.filterKey || this.props.data.name,\n config: value\n });\n });\n\n };\n\n render() {\n let resourceoffline = false\n if(this.props.data.config.type === 'user' && !window.network_connection.isNetwork) resourceoffline = true;\n\n let label = ewars.I18N(this.props.data.config.label);\n let fieldType = this.props.data.config.type;\n let isDuplicateFilterApplied = this.props.id?.includes(\"DUPLICATE_FILTER_APPLIED\") ?? false;\n let hasControls = true;\n if ([\"matrix\", \"display\", \"row\"].indexOf(this.props.data.config.type) >= 0 || isDuplicateFilterApplied || !fieldType) hasControls = false;\n\n let colSpan = this.props.data.cols || 1,\n rowSpan = this.props.data.rows || 1;\n\n let width = (this.props.data.width || 90) + \"px\";\n\n let sortIcon;\n\n let colName;\n if (this.props.data.config) {\n if (this.props.data.config.name) colName = this.props.data.config.name\n }\n if (this.props.data.name) colName = this.props.data.name;\n\n sortIcon = ;\n if (this.props.sort[colName]) {\n if (this.props.sort[colName].indexOf(\"DESC\") >= 0) sortIcon = ;\n if (this.props.sort[colName].indexOf(\"ASC\") >= 0) sortIcon = ;\n }\n\n let actionControlClass = \"ide-col dt-filter-btn\";\n if (this.props.filter[this.props.data.config.filterKey || this.props.data.name]) actionControlClass += \" active\";\n\n let filterIconClass = \"fal fa-filter\";\n if (this.props.filter[this.props.data.config.filterKey || this.props.data.name]) filterIconClass += \" green\";\n\n let hasSort = true;\n let style = {position: \"relative\"};\n if (['row', 'matrix'].indexOf(this.props.data.config.type) >= 0 || !fieldType) {\n hasSort = false;\n style.background = \"rgba(0,0,0,0.1)\"\n }\n \n if(this.props.data.width){\n style.width = width;\n }\n if(isDuplicateFilterApplied){\n hasSort = false;\n if(this.props.bgColor) {\n style.color = \"white\"\n style.background = this.props.bgColor\n }\n }\n\n if (this.props.id == \"LANGUAGES\") {\n style.textAlign = 'left'\n }\n\n // Conditions for hiding filters\n let hideFilter;\n\n if(this.props.hideLocGroupFilter && this.props.data.config.name == \"groups\" && isRegionalAdminWithLocGroup()){\n hideFilter = true;\n }\n\n return (\n \n
\n
\n {label}\n
\n {hasSort ?\n
\n {sortIcon}\n
\n : null}\n {hasControls && !hideFilter ?\n
\n \n
\n : null}\n\n
\n {this.state.controls ?\n
\n \n
\n : null}\n \n )\n }\n\n}\n\nexport default DataTableHeaderCell;\n","import Button from \"../c.button\";\nimport Toolbar from \"../c.toolbar\";\nimport { Row, Cell, Layout } from \"../layout\";\nimport { ActionGroup } from \"../c.action_button\";\n\nimport DataTableHeaderCell from \"./c.datatable.header_cell\";\nimport DataTableFilterControl from \"./c.datatable.filter_control\";\nimport DataTableCell from \"./c.datatable.cell\";\n\nimport Form from \"../c.form\";\nimport FormUtils from \"../../common/utils/FormUtils\";\n\nimport DTReducer from \"./r.reducer\";\nimport ExportFormModal from \"../../reporting/components/modal/exportFormModal\";\n\n// if (!Array.prototype.unique) {\n// Array.prototype.unique = function () {\n// var a = this.concat();\n// for (var i = 0; i < a.length; ++i) {\n// for (var j = i + 1; j < a.length; ++j) {\n// if (a[i] === a[j])\n// a.splice(j--, 1);\n// }\n// }\n//\n// return a;\n// };\n// }\n\nconst STYLES = {\n INPUT_SEARCH: {\n borderRadius: \"3px\",\n fontSize: \"11px\"\n }\n}\n\nclass ShowSubFormsPopup extends React.Component {\n static defaultProps = {\n actions: []\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n show: false,\n showPopup: false\n }\n }\n\n _action = (action) => {\n this.props.onAction(action.action, action.subFormData);\n };\n render() {\n var content = [];\n this.props.subForms.forEach((subForm) => {\n content.push(
\n \n
)\n });\n if (content.length === 0) {\n content =
No Sub forms are there!
\n }\n return (\n
\n \n {content}\n
\n )\n }\n}\nclass DataControlCell extends React.Component {\n static defaultProps = {\n actions: []\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n show: false,\n showPopup: false,\n popUpAction: null\n }\n }\n componentWillMount() {\n window.__hack__.addEventListener(\"click\", this._clear);\n window.__hack__.addEventListener(\"contextmenu\", this._clear);\n }\n\n componentWillUnmount() {\n window.__hack__.removeEventListener(\"click\", this._clear);\n window.__hack__.removeEventListener(\"contextmenu\", this._clear);\n }\n\n _clear = (evt) => {\n if (this.refs.item) {\n if (!this.refs.item.contains(evt.target)) {\n this.setState({\n showPopup: false\n })\n }\n }\n };\n\n _onClick = () => {\n this.props.onAction(this.props.data.action, null, this.props.row);\n };\n\n _show = () => {\n this.setState({\n show: true\n })\n };\n\n _hide = () => {\n this.setState({\n show: false\n })\n };\n\n\n\n _isShowPopup = (action) => {\n var showPopupActions = this.props.actions.find((element) => {\n return element.showPopup == true;\n })\n return showPopupActions ? true : false\n };\n _action = (action, value) => {\n this.props.onAction(action, value, this.props.row);\n if (this._isShowPopup(action)) {\n this.setState({\n showPopup: !this.state.showPopup,\n popUpAction: action\n })\n }\n };\n componentWillMount() {\n window.__hack__.addEventListener(\"click\", this._clear);\n window.__hack__.addEventListener(\"contextmenu\", this._clear);\n }\n\n _clear = (evt) => {\n if (this.refs.item) {\n if (!this.refs.item.contains(evt.target)) {\n this.setState({\n showPopup: false\n })\n }\n }\n };\n\n render() {\n let dtActions = this.props.actions.map((item) => {\n return [\n item.icon,\n item.action,\n item.label,\n item.showPopup\n ]\n });\n var showPopup = this._isShowPopup();\n return (\n \n \n {/*
*/}\n {/**/}\n {/*{this.state.show ?*/}\n {/*
{this.props.data.label}
*/}\n {/*: null}*/}\n {/*
*/}\n {\n this.state.showPopup && showPopup ?\n
\n {\n this.state.popUpAction == \"PRINT\" ? \n
\n \n
\n :\n this.state.popUpAction == \"ADD_SUB_FORM\" ?\n
\n \n
\n : \n this.state.popUpAction == \"VIEW_SUB_RECORD\"?\n
\n \n
\n :null\n }\n \n\n
\n : null\n }\n\n \n )\n }\n}\n\nif (!ewars.g.DTS) {\n ewars.g.DTS = 0;\n}\n\nclass DataTable extends React.Component {\n static defaultProps = {\n resource: null,\n editable: false,\n columns: [],\n filter: {},\n searchParams: [],\n baseFilters: {},\n actions: [],\n isReports: false,\n grid: null,\n join: null,\n order: {},\n select: null,\n\n initialOrder: null,\n initialFilter: null,\n persistedData : true \n };\n _forceWidth = false;\n\n constructor(props) {\n super(props);\n\n ewars.z.register(this.props.id || \"DT_TRANSIENT\", DTReducer, {\n data: [],\n initialized: false,\n order: ewars.copy(this.props.initialOrder || {}),\n select: this.props.select || null,\n filter: {},\n limit: 10,\n offset: 0,\n page: 0,\n search: {},\n searchParam: \"\",\n count: null,\n join: this.props.join || null,\n filterControl: {\n shown: false,\n x: null,\n y: null,\n ref: null\n },\n context: {\n shown: false,\n ref: null,\n rowIndex: null\n },\n editor: {}\n }, this.props.persistedData);\n\n this.state = ewars.z.getState(this.props.id || \"DT_TRANSIENT\");\n\n ewars.z.subscribe(this.props.id || \"DT_TRANSIENT\", this._onChange);\n ewars.subscribe(\"RELOAD_DT\", this._onQueryChange, this.props.id);\n ewars.addEvent(window, \"resize\", this._recalc);\n }\n\n componentDidMount() {\n let height = this.refs.grid.clientHeight;\n let width = this.refs.grid.clientWidth;\n\n let numRows = (height - (height % 25)) / 25;\n this.state.limit = numRows + 5;\n\n this.refs.dt.style.height = height + \"px\";\n\n if (!this.state.initialized) {\n ewars.z.dispatch(this.props.id || \"DT_TRANSIENT\", \"SET_ITEMS\", {\n results : [],\n count : 0,\n state : this.state \n });\n this.query(this.props, this.state);\n }\n }\n\n componentWillUnmount() {\n ewars.removeEvent(window, \"resize\", this.recalc);\n ewars.z.unsubscribe(this.props.id || \"DT_TRANSIENT\", this._onChange);\n ewars.unsubscribe(\"RELOAD_DT\", this.props.id)\n ewars.z.deregister(this.props.id);\n }\n\n _recalc = () => {\n if (this._timer) {\n clearTimeout(this._timer);\n this._timer = null\n }\n this._timer = setTimeout(() => {\n if (this.refs.grid) {\n let height = this.refs.grid.clientHeight;\n\n let numRows = (height - (height % 25)) / 25;\n this.state.limit = numRows + 5;\n\n this.refs.dt.style.height = height + \"px\";\n\n this._timer = null;\n this.query(this.props, this.state);\n }\n }, 500);\n };\n\n componentWillReceiveProps(nextProps, nextState) {\n let id = nextProps.id || \"DT_TRANSIENT\";\n // If the new id doesn't match the current id, swap registers\n if (id != this.props.id) {\n ewars.z.unsubscribe(this.props.id, this._onChange);\n ewars.z.subscribe(id, this._onChange);\n }\n\n if (ewars.z.exists(id)) {\n let state = ewars.z.getState(id);\n if (!state.initialized) {\n this.query(nextProps, nextState);\n } else {\n this.setState({ ...state });\n }\n } else {\n let height = this.refs.grid.clientHeight;\n\n let numRows = (height - (height % 25)) / 25;\n let limit = numRows + 5;\n\n this.refs.dt.style.height = height + \"px\";\n ewars.z.register(id, DTReducer, {\n data: [],\n intialized: false,\n order: ewars.copy(nextProps.initialOrder || {}),\n select: nextProps.select || null,\n filter: {},\n limit: limit || 10,\n offset: 0,\n page: 0,\n search: {},\n searchParam: \"\",\n count: null,\n join: nextProps.join || null,\n filterControl: {\n shown: false,\n x: null,\n y: null,\n ref: null\n },\n context: {\n shown: false,\n ref: null,\n rowIndex: null\n },\n editor: {}\n }, nextProps.persistedData);\n\n let state = ewars.z.getState(nextProps.id || \"DT_TRANSIENT\");\n ewars.z.subscribe(id, this._onChange);\n this.query(nextProps, state);\n }\n }\n\n _onChange = (action) => {\n let newState = ewars.z.getState(this.props.id || \"DT_TRANSIENT\");\n\n if ([\"PAGINATE\", \"UPDATE_SORT\", \"UPDATE_FILTER\", \"CLEAR_SEARCH\"].indexOf(action) >= 0) {\n this.query(this.props, newState);\n } else {\n this.setState({\n ...newState\n })\n }\n };\n\n _onClickFilterDuplicate = () => {\n this.props.onAction(\"FILTER_DUPLICATE\")\n }\n\n _onClearDupFilter = () => {\n this.props.onAction(\"CLEAR_DUPLICATE_FILTER\",this.state, this.props)\n }\n\n _onQueryChange = () => {\n this.query(this.props, this.state);\n };\n\n\n query(props, state) {\n if (props.paused == true) return;\n\n let blocker = new ewars.Blocker(this.refs.wrapper, __(\"LOADING\"));\n let com = \"com.ewars.query\";\n if (props.isReports) com = \"com.ewars.collections.get\";\n\n let args = [];\n\n let joins = ewars.copy(state.join || []);\n (props.join || []).forEach(item => {\n if (joins.indexOf(item) < 0) joins.push(item);\n });\n\n if (props.isReports) {\n args = [\n props.formId,\n Object.assign({}, props.filter || {}, state.filter),\n state.order,\n state.limit || null,\n state.offset,\n joins\n ]\n } else {\n args = [\n props.resource,\n state.select || null,\n Object.assign({}, props.filter || {}, state.filter),\n state.order,\n state.limit,\n state.offset,\n joins\n ]\n }\n\n if (props.id == \"CONFLICTS\") {\n com = \"com.ewars.collection_version.get_all\";\n args = null\n } else if (props.id == 'LANGUAGES') {\n com = 'com.ewars.language.getLanguage';\n args = [\n {\n \"filters\" : state.filter || {},\n \"order\" : state.order,\n \"limit\" : state.limit,\n \"offset\" : state.offset\n }\n ]; ;\n ewars.tx(com, args).then(resp => {\n blocker.destroy();\n ewars.emit(\"LANGUAGES_LOADED\", resp.results);\n ewars.z.dispatch(this.props.id || \"DT_TRANSIENT\", \"SET_ITEMS\", {\n ...resp,\n state: state\n });\n });\n return;\n }\n else if(props.id?.includes(\"DUPLICATE_FILTER_APPLIED\") ?? false){\n com = \"com.ewars.report.get_duplicate\"\n args = [props.dupFilterMetadata.formId, props.dupFilterMetadata.fields, \n props.filter?.is_synced?.eq ?? null, props.filter.location_id ?? {}, state.limit , state.offset];\n }\n if (props.collectionUUID && props.isSubForm){\n let filter = args[1];\n filter[\"data ->> 'main_report_uuid'\"] = {eq:props.collectionUUID}\n args[1] = filter\n }\n if (props.isSubForm){\n let filter = args[1];\n filter[\"is_sub_form\"]=true;\n args[1] = filter\n }\n ewars.tx(com, args, { count: true })\n .then(function (resp) {\n blocker.destroy();\n ewars.z.dispatch(this.props.id || \"DT_TRANSIENT\", \"SET_ITEMS\", {\n ...resp,\n state: state\n });\n }.bind(this)).catch(err => {\n blocker.destroy();\n })\n }\n\n onButtonClick = (data) => {\n if (data.action) {\n data.action();\n }\n\n };\n\n onAction = (action, row) => {\n this.props.onAction(action, row);\n };\n\n _move = (data) => {\n ewars.z.dispatch(this.props.id || \"DT_TRANSIENT\", \"PAGINATE\", data);\n };\n\n _onCellAction = (action, cell, row) => {\n this.props.onCellAction(action, cell, row);\n };\n\n _modifyRow = (index, path, value) => {\n let data = ewars.copy(this.state.data);\n let row = data[index];\n\n if (path.split(\".\")[0] == \"data\") {\n let realPath = path.replace(\"data.\", \"\");\n row.data[realPath] = value;\n } else {\n row[path] = value;\n }\n\n data[index] = row;\n this.setState({\n data: data\n })\n };\n\n _searchParamChange = (e) => {\n ewars.z.dispatch(this.props.id || \"DT_TRANSIENT\", \"UPDATE_SEARCH\", {\n value: e.target.value\n })\n };\n\n _performSearch = () => {\n if (this.state.searchParam == \"\") {\n ewars.error(__(\"PROVIDE_SEARCH_TERM\"));\n return;\n }\n ewars.z.dispatch(this.props.id || \"DT_TRANSIENT\", \"UPDATE_FILTER\", {\n key: \"data\",\n config: { LIKE: this.state.searchParam }\n });\n\n };\n\n _clearSearch = () => {\n ewars.z.dispatch(this.props.id || \"DT_TRANSIENT\", \"CLEAR_SEARCH\", null);\n };\n\n render() {\n \n let colHeaders,\n colGroupsMaster = [],\n cellWidth = 200;\n let isDuplicateFilterApplied = this.props.id?.includes(\"DUPLICATE_FILTER_APPLIED\") ?? false;\n\n if (this._forceWidth) cellWidth = this.refs.dt.clientWidth / this.props.columns.length;\n\n //Used in report manager, if we're showing a grid composition\n if (this.props.grid) {\n colHeaders = [];\n\n if (this.props.actions) {\n this.props.actions.forEach(cell => {\n colGroupsMaster.push()\n })\n }\n\n let grouped = {};\n this.props.grid.definition.forEach(function (item) {\n if (!grouped[item.row]) grouped[item.row] = [];\n grouped[item.row].push(item);\n });\n\n this.props.grid.columns.forEach(function (item) {\n let labelLength = ewars.I18N(item.config.label).length;\n let width = labelLength * 6.3;\n if (width < 200) width = 200;\n if (this._forceWidth) width = cellWidth < item.width || 0 ? cellWidth : item.width;\n if (item.config.width) width = item.config.width;\n colGroupsMaster.push();\n }.bind(this));\n\n for (let k in grouped) {\n // Group\n grouped[k].sort(function (a, b) {\n if (a.cell < b.cell) return -1;\n if (a.cell > b.cell) return 1;\n return 0;\n });\n\n let cells = [];\n\n if (this.props.actions) {\n cells.push()\n }\n\n grouped[k].forEach(function (cell) {\n\n //For duplicate filter columns bgColor\n let cellBgColor; \n if(isDuplicateFilterApplied){\n this.props.dupFilterMetadata.fields.findIndex((fl) => (\"data.\"+fl.finalName == cell.name) || ((this.props.rootFields || []).includes(cell.config.name) && fl.name === cell.name)) > -1 ?\n cellBgColor = \"rgb(86 86 86 / 92%)\" : null;\n }\n cells.push();\n }.bind(this));\n\n colHeaders.push(\n \n {cells}\n \n )\n }\n\n } else {\n let headers = [];\n\n if (this.props.actions) {\n colGroupsMaster.push();\n headers.push()\n // this.props.actions.forEach(cell => {\n // colGroupsMaster.push()\n // headers.push()\n // })\n }\n\n this.props.columns.forEach(function (col, index) {\n let width = col.width || 200;\n let style = { width: width };\n if (this._forceWidth) style.width = cellWidth;\n colGroupsMaster.push();\n headers.push(\n \n )\n }.bind(this));\n colHeaders = \n {headers}\n \n }\n\n let rowHeaders;\n\n let rows = this.state.data.map(function (item, index) {\n let cells = [];\n let className = \"dt-row\";\n if (isDuplicateFilterApplied){\n if(item.dup_rec_group_number % 2 == 1) className += \" dup-dark-striped\";\n else className += \" dup-light-striped\"\n }\n else{\n if (index % 2 != 0) {\n className += \" striped\";\n }\n }\n\n if (this.props.actions) {\n cells.push(\n \n )\n }\n\n if (this.props.grid) {\n this.props.grid.columns.forEach(function (col) {\n cells.push(\n \n )\n }.bind(this))\n } else {\n this.props.columns.forEach(function (col) {\n cells.push(\n \n )\n }.bind(this))\n }\n\n return (\n \n {cells}\n \n )\n }.bind(this));\n\n\n let buttons;\n if (this.props.buttons) {\n buttons = this.props.buttons.map(function (btn) {\n return \n }.bind(this));\n }\n\n var paginationString;\n if (this.state.count) {\n var startShow, endShow;\n if (this.state.page == 0) {\n startShow = 1;\n if(this.state.limit > this.state.data.length){\n endShow = this.state.data.length;\n }\n else{\n endShow = this.state.limit;\n }\n } else {\n startShow = ((this.state.limit) * this.state.page) + 1;\n if(startShow > this.state.count){\n startShow = ((this.state.limit) * (this.state.page - 1)) + 1;\n }\n \n if (this.state.limit > this.state.data.length) {\n endShow = this.state.count;\n }\n else{\n endShow = startShow + this.state.limit - 1;\n }\n }\n\n paginationString = [\n __(\"SHOWING\"),\n startShow,\n __(\"to\"),\n endShow,\n __(\"of\"),\n this.state.count\n ].join(\"\");\n } else {\n paginationString = __(\"NO_ITEMS_FOUND\");\n }\n\n const showNoDataMsg = !!this.props.noDataMessage && rows.length == 0;\n\n return (\n
\n
\n {this.props.grid ?\n \n
\n {\n !isDuplicateFilterApplied ?\n
\n \n \n \n \n \n
\n\n \n {this.state.searchParam != \"\" ?\n \n : null}\n
\n
\n
\n
: null\n }\n {\n !this.state.searchParam && this.props.showDuplicateFilterBtn ?\n
\n \n
\n \n {\n isDuplicateFilterApplied ?\n \n : null}\n \n
\n
\n
\n : null\n }\n\n {this.props.isMainForm ? \n \n
\n {__(\"FILL_SUBFORM_CLICK_ON_MAIN_RECORD_PLUS_ICON\")}\n
\n
\n :null}\n
\n\n {this.props.header_actions.length > 0 ?\n
\n {this.props.header_actions.map((item, index) => {\n return (\n \n {item[0] == \"checkbox\" ? \n {\n if (event.target.checked) {\n this.props.onAction(item[1], item[3], false);\n } else {\n this.props.onAction(item[1], item[3], true);\n }\n }}\n type=\"checkbox\" /> {item[2]}\n :\n {\n this.props.onAction(item[1]);\n }}\n title={item[2]}\n />}\n \n )\n })}\n
\n : null}\n
\n : null}\n
\n
\n
\n\n \n \n {colHeaders}\n \n \n {rows}\n \n
\n {/**/}\n\n {\n showNoDataMsg ?\n
\n \n {this.props.noDataMessage}\n \n
: null\n }\n
\n
\n
\n
\n
\n
\n
{paginationString}
\n\n
\n {this.state.offset > 0 ?\n \n : null}\n {this.state.offset > 0 ?\n \n : null}\n {this.state.data.length >= this.state.limit ?\n \n : null}\n {this.state.data.length >= this.state.limit ?\n \n : null}\n
\n
\n \n
\n
\n
\n
\n
\n\n {\n this.state.showFilterControls ?\n \n : null\n }\n\n
\n )\n }\n}\n\nexport default DataTable;\n","function _updatePagination (STATE, data) {\n switch (data.page) {\n case \"FF\":\n if (STATE.offset < STATE.count) {\n var pages = STATE.count / STATE.limit;\n STATE.page = Math.ceil(pages);\n STATE.offset = (STATE.page - 1) * STATE.limit;\n }\n break;\n case \"F\":\n if (STATE.offset < STATE.count) {\n STATE.offset = (STATE.page + 1) * STATE.limit;\n STATE.page++;\n }\n break;\n case \"B\":\n STATE.offset = (STATE.page - 1) * STATE.limit;\n STATE.page--;\n break;\n case \"BB\":\n STATE.offset = 0;\n STATE.page = 0;\n break;\n default:\n break;\n }\n\n if (STATE.page < 0) STATE.page = 0;\n if (STATE.page <= 0) STATE.offset = 0;\n\n return STATE;\n}\n\nfunction _updateSort(state, cell, fieldType) {\n if (!state.order[cell]) {\n state.order = {};\n state.order[cell] = `DESC:${fieldType}`;\n } else if (state.order[cell] == `DESC:${fieldType}`) {\n state.order[cell] = `ASC:${fieldType}`;\n } else if (state.order[cell] == `ASC:${fieldType}`) {\n delete state.order[cell];\n } else if (state.order[cell] == \"DESC\") {\n state.order[cell] = \"ASC\";\n } else if (state.order[cell] == \"ASC\") {\n delete state.order[cell];\n }\n\n return state;\n}\n\nfunction _updateFilter(state, col, data) {\n if (!data) {\n delete state.filter[col];\n return state;\n }\n\n if (!col) return state;\n state.offset = 0;\n state.page = 0;\n state.filter[col] = data;\n\n return state;\n}\n\nconst _updateSearch = (state, value) => {\n if (value == \"\") {\n delete state.filter.data;\n state.searchParam = \"\";\n } else {\n state.searchParam = value;\n }\n return state;\n};\n\nconst _clearSearch = (state) => {\n state.searchParam = \"\";\n if (state.filter.data) {\n delete state.filter.data;\n }\n return state;\n};\n\nexport default (rawState, action, data) => {\n let state = ewars.copy(rawState);\n\n switch(action) {\n case \"SET_ITEMS\":\n data.state = {\n ...data.state,\n initialized: true\n }\n return Object.assign({}, state, data.state, {data: data.results, count: data.count});\n case \"PAGINATE\":\n return _updatePagination(state, data);\n case \"UPDATE_SORT\":\n return _updateSort(state, data.field, data.fieldType);\n case \"UPDATE_FILTER\":\n if(data.key == 'groups'){\n data.key = 'data.groups'\n if(data.config){\n data.config['isGroups'] = true\n }\n }else{\n if(data.config){\n delete data.config['isGroups']\n }\n }\n return _updateFilter(state, data.key, data.config);\n case \"UPDATE_SEARCH\":\n return _updateSearch(state, data.value);\n case \"CLEAR_SEARCH\":\n return _clearSearch(state);\n default:\n return state;\n }\n}","import FormUtils from \"../../utils/FormUtils\";\n\nfunction flatten(definition) {\n let results = [];\n\n for (var i in definition) {\n let item = definition[i];\n item.name = i;\n\n results.push(item);\n }\n\n return results.sort(function (a, b) {\n if (a.order < b.order) return -1;\n if (a.order > b.order) return 1;\n return 0\n })\n}\n\nclass Handle extends React.Component {\n constructor(props) {\n super(props);\n }\n\n render() {\n let label;\n if (this.props.field) label = ewars.I18N(this.props.field.label) + ` [${this.props.field.name}]`;\n\n return (\n
\n \n \n \n \n \n \n \n
{label}\n \n
\n
\n )\n }\n}\n\nclass FieldItem extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = {\n show: false\n }\n }\n\n _onClick = () => {\n if (this.props.data.fields) {\n this.setState({show: !this.state.show})\n } else {\n this.props.onSelect(this.props.name, this.props.data);\n }\n };\n\n render() {\n let iconClass;\n if (this.props.data.fields) {\n if (this.state.show) {\n iconClass = \"fa fa-caret-down\";\n } else {\n iconClass = \"fa fa-caret-right\";\n }\n }\n\n let children;\n if (this.state.show) {\n children = flatten(this.props.data.fields);\n children = children.map(function (item) {\n if ([\"display\", \"header\"].indexOf(item.type) < 0) {\n return \n }\n }.bind(this))\n }\n\n return (\n
\n
\n
\n
\n
{ewars.I18N(this.props.data.label)}
\n
\n
\n {this.state.show ?\n
\n {children}\n
\n : null}\n
\n )\n }\n}\n\nclass FieldSelector extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = {\n show: false\n }\n }\n\n _toggle = () => {\n this.setState({\n show: !this.state.show\n })\n };\n\n _onSelect = (field_name, data) => {\n this.setState({show: false});\n this.props.onUpdate(this.props.name, field_name);\n };\n\n render() {\n\n let flattened = flatten(this.props.definition, null);\n\n let rootNodes = flattened.map(function (item) {\n if ([\"header\", \"display\"].indexOf(item.type) < 0) {\n return \n }\n }.bind(this));\n\n let field;\n if (this.props.value && this.props.value != \"null\") {\n field = FormUtils.field(this.props.definition, this.props.value);\n }\n\n return (\n
\n
\n \n {this.state.show ?\n
\n
\n
\n {rootNodes}\n
\n
\n
\n : null}\n\n\n
\n
\n )\n }\n}\n\nexport default FieldSelector;\n","import Set from \"./Set\";\n\nclass Complex extends React.Component {\n constructor(props) {\n super(props);\n }\n\n _remove = () => {\n window.dispatchEvent(new CustomEvent('ind-remove-complex', {\n detail: {\n _event: \"ind-remove-complex\",\n id: this.props.indicator,\n index: this.props.index\n }\n }));\n };\n\n render() {\n return (\n
\n
\n
\n
\n
{__(\"COMPLEX\")}
\n
\n \n
\n
\n
\n
\n \n
\n
\n )\n }\n}\n\nexport default Complex;\n","import SetItem from \"./SetItem\";\n\nclass Set extends React.Component {\n constructor(props) {\n super(props);\n }\n\n _emit = (event, data) => {\n window.dispatchEvent(new CustomEvent(event, {\n detail: {\n ...data,\n _event: event\n }\n }));\n };\n\n _add = () => {\n this._emit(\"etl-add-field\", {\n id: this.props.indicator,\n path: this.props.path\n });\n };\n\n _addSet = () => {\n this._emit(\"etl-add-set\", {\n id: this.props.indicator,\n path: this.props.path\n })\n };\n\n _onRemove = () => {\n this._emit(\"etl-remove-set\", {\n id: this.props.indicator,\n path: this.props.path\n });\n };\n\n _onChangeRule = (e) => {\n this._emit(\"etl-set-change-provision\", {\n id: this.props.indicator,\n path: this.props.path,\n value: e.target.value\n });\n };\n\n render() {\n\n let items = this.props.data.map((item, index) => {\n if ([\"ANY\", \"ALL\"].indexOf(item) >= 0) {\n return (\n
\n
\n
\n \n
\n
{__(\"OF_FOLLOWING_ARE_TRUE\")}
\n
\n \n
\n {(!this.props.hasOwnProperty('addRemoveButton') || this.props.addRemoveButton == true) ? \n
\n \n
: null}\n
\n
\n )\n } else if (typeof item == \"string\") {\n return \n } else {\n // This is sub-ste\n return \n }\n });\n\n return (\n
\n {items}\n
\n )\n }\n}\n\nexport default Set;\n","import {\n SelectField,\n TextField,\n NumericField as NumberField,\n DateField\n} from \"../../fields\";\n\nimport FieldSelector from \"../form_definition/FieldSelector\";\nimport FormUtils from \"../../utils/FormUtils\";\n\nconst TYPE_MAP = {\n number: NumberField,\n select: SelectField,\n text: TextField,\n date: DateField\n\n};\n\nconst options = [\n [\"EQ\", __(\"IS_EQ_TO\")],\n [\"NEQ\", __(\"IS_NEQ_TO\")],\n [\"GT\", __(\"IS_GT\")],\n [\"LT\", __(\"IS_LT\")],\n [\"GTE\", __(\"IS_GT_OR_EQ_TO\")],\n [\"LTE\", __(\"IS_LT_OR_EQ_TO\")]\n];\n\nclass NoField extends React.Component {\n render() {\n return (\n

Please select a field

\n )\n }\n}\n\nclass SetItem extends React.Component {\n constructor(props) {\n super(props);\n }\n\n _onChange = (prop, value) => {\n window.dispatchEvent(new CustomEvent(\"etl-set-update-rule\", {\n detail: {\n _event: \"etl-set-update-rule\",\n id: this.props.indicator,\n path: this.props.path,\n prop,\n value\n }\n }));\n };\n\n _onRemove = () => {\n window.dispatchEvent(new CustomEvent(\"etl-set-remove-rule\", {\n detail: {\n _event: \"etl-set-remove-rule\",\n id: this.props.indicator,\n path: this.props.path\n }\n }));\n };\n\n\n render() {\n let fieldPath = this.props.data.split(\":\")[0];\n\n\n let Cmp, field;\n if (fieldPath != \"null\" && fieldPath) {\n field = FormUtils.field(this.props.definition, fieldPath);\n if (TYPE_MAP[field.type]) {\n Cmp = TYPE_MAP[field.type];\n } else {\n Cmp = NoField;\n }\n }\n\n if (!field && fieldPath.length == 3) {\n if (fieldPath[0] != \"null\") {\n return (\n
\n
\n

{__(\"UNRECOGNIZED_FIELD\")} {fieldPath}

\n
\n \n
\n
\n
\n )\n }\n }\n\n\n let endOptions = ewars.copy(options);\n let value = this.props.data.split(':')[2] || '';\n if (field) {\n if (field.multiple) {\n endOptions.push(['CNT', __(\"CONTAINS\")]);\n endOptions.push(['NCNT', __(\"DOES_NOT_CONTAIN\")]);\n\n // create an array from the value\n if (value != '' && value != null && value != 'null') {\n value = value.split(',');\n } else {\n value = [];\n }\n }\n }\n\n // endOptions.push(['NULL', __(\"NULL\")]);\n\n\n return (\n
\n
\n
\n
\n
\n \n\n
\n
\n \n
\n
\n {field ?\n \n : null}\n\n
\n
\n
\n
\n \n
\n\n
\n
\n )\n }\n}\n\nexport default SetItem;\n","import Button from \"../../../c.button\";\nimport TextField from \"../../../fields/f.text\";\nimport SelectField from \"../../../fields/f.select\";\nimport IndicatorField from \"../../../fields/f.indicator\";\nif (!ewars.copy) ewars.copy = function (item) {\n return JSON.parse(JSON.stringify(item));\n};\nvar DEFAULTS = {\n variable_name: \"var_name\",\n indicator: null,\n reduction: \"NONE\"\n};\nvar FORM = {\n reduction: {\n type: \"select\",\n label: {en: __(\"REDUCTION\")},\n options: [\n [\"NONE\", __(\"NONE\")],\n [\"SUM\", __(\"SUM\")],\n [\"MED\", __(\"MED\")]\n ]\n }\n};\nvar ComplexSource = React.createClass({\n getInitialState: function () {\n return {\n isExpanded: false\n }\n },\n _update: function (prop, value) {\n console.log(prop, value);\n if (prop == \"variable_name\") {\n value = value.replace(\" \", \"_\")\n }\n this.props.onChange(this.props.index, prop, value);\n },\n _expand: function () {\n this.setState({\n isExpanded: this.state.isExpanded ? false : true\n })\n },\n _delete: function () {\n this.props.onDelete(this.props.index);\n },\n render: function () {\n return (\n
\n
\n
{this.props.data.variable_name}
\n
\n
\n \n \n
\n
\n
\n {this.state.isExpanded ?\n
\n
\n
{__(\"VARIABLE_NAME\")}
\n
\n \n
\n
\n\n
\n
{__(\"INDICATOR\")}
\n
\n \n
\n
\n\n {/*
\n
{__(\"REDUCTION\")}
\n
\n \n
\n
*/}\n
\n : null }\n
\n )\n }\n});\n\nvar ComplexSourcesManager = React.createClass({\n getInitialState: function () {\n return {}\n },\n\n _onChange: function (index, prop, value) {\n var copy = ewars.copy(this.props.value || []);\n copy[index][prop] = value;\n this.props.onUpdate(this.props.config.nameOverride || this.props.name, copy);\n },\n\n _addVariable: function () {\n var copy = ewars.copy(this.props.value || []);\n copy.push({...{}, ...DEFAULTS});\n this.props.onUpdate(this.props.config.nameOverride || this.props.name, copy);\n },\n\n _delete: function (index) {\n var copy = ewars.copy(this.props.value || []);\n copy.splice(index, 1);\n this.props.onUpdate(this.props.config.nameOverride || this.props.name, copy);\n },\n\n render: function () {\n let variables = (this.props.value || []).map((series, index) => {\n return \n });\n\n return (\n
\n
\n \n\n
\n\n
\n {variables}\n
\n\n
\n\n )\n }\n});\n\nexport default ComplexSourcesManager;\n","import FormFieldTree from \"./c.tree.form_fields\";\nimport FormUtils from \"../utils/FormUtils\";\n\nfunction _findFieldByPath(options, path) {\n var found;\n\n _.each(options, function (field) {\n if (field.path == path) found = field;\n if (!found && field.children) {\n var subFound = _findFieldByPath(field.children, path);\n if (subFound) found = subFound;\n }\n }, this);\n\n return found;\n}\n\nvar ConditionRow = React.createClass({\n _data: [null, \"eq\", null],\n _node: null,\n\n getInitialProps: function () {\n return {\n data: [null, \"eq\", null]\n }\n },\n\n getInitialState: function () {\n return {\n data: [null, \"eq\", null]\n };\n },\n\n componentWillMount: function () {\n if (this.props.data) {\n this._node = _findFieldByPath(this.props.fieldOptions, this.props.data[0]);\n\n this.state.data = ewars.copy(this.props.data);\n }\n },\n\n componentWillReceiveProps: function (nextProps) {\n this.state.data = ewars.copy(nextProps.data);\n },\n\n _removeRule: function () {\n this.props.onRemove(this.props.index);\n },\n\n _onFieldSelect: function (e) {\n this.state.data[0] = e.target.value;\n this.props.onUpdate(this.props.index, this.state.data);\n },\n\n _onValueChange: function (prop, value) {\n this.state.data[2] = value;\n this.props.onUpdate(this.props.index, this.state.data);\n },\n\n _onCmpChange: function (e) {\n this.state.data[1] = e.target.value;\n this.props.onUpdate(this.props.index, this.state.data);\n },\n\n render: function () {\n var valueControl;\n\n if (this.state.data[0] && this.state.data[0] != \"none\") {\n // Find the field definition\n var fieldDef = _.find(this.props.fieldOptions, function (field) {\n if (field[0] == this.state.data[0]) return true;\n }, this);\n\n\n var FieldControl = this.props.map[fieldDef[2].type];\n\n valueControl = \n } else {\n valueControl = Please select a field;\n }\n\n var options = _.map(this.props.fieldOptions, function (optionSet) {\n var fieldLabel = optionSet[1];\n return \n }, this);\n options.unshift();\n\n return (\n
\n \n \n \n \n \n \n \n \n \n
\n \n \n \n \n {valueControl}\n \n
\n \n
\n
\n
\n )\n }\n});\n\nexport default ConditionRow;\n","import CONSTANTS from \"../constants\";\nimport Moment from \"moment\";\n\nimport {\n SelectField\n} from \"../../common/fields\";\nclass Day extends React.Component {\n constructor(props) {\n super(props);\n }\n\n _onClick = () => {\n if (this.props.active) {\n this.props.onClick(this.props.date);\n }\n };\n\n render() {\n\n let className = \"cal-day\";\n if (\n this.props.value.date() == this.props.date.date() &&\n this.props.value.month() == this.props.date.month() &&\n this.props.value.year() == this.props.date.year()\n ) {\n className += \" selected\";\n }\n\n if (!this.props.active) className += \" inactive\";\n\n if (!this.props.curDate.isSame(this.props.date, \"M\")) className = \"cal-day-nan\";\n\n let day = this.props.date.date();\n\n return (\n {day}\n )\n }\n}\n\nclass DayPicker extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = {\n curDate: Moment.utc(this.props.value || undefined),\n today: Moment.utc(),\n textDate : \"\",\n years : []\n }\n }\n componentWillMount(){\n let textDate = Moment(this.props.value).format(\"YYYY-MM-DD\"); // \"Sun, 3PM\"\n\n this.setState({\n ...this.state,\n curDate: Moment.utc(this.props.value || undefined),\n textDate : textDate\n })\n }\n\n componentDidMount(){\n }\n \n \n\n componentWillReceiveProps(nextProps) {\n let textDate = Moment.utc(nextProps.value).format(\"YYYY-MM-DD\"); // \"Sun, 3PM\"\n\n this.setState({\n curDate: Moment.utc(nextProps.value || undefined),\n textDate : textDate\n })\n }\n _clear = () => {\n this.props.clear();\n }\n _prevMonth = () => {\n if (this.props.hideYear && this.state.curDate.month() == 0) {\n return;\n }\n this.setState({\n ...this.state,\n curDate: this.state.curDate.clone().subtract(1, 'M')\n })\n };\n _prevYear = () => {\n if (this.props.hideYear) {\n return;\n }\n this.setState({\n ...this.state,\n curDate: this.state.curDate.clone().subtract(1, 'Y')\n })\n };\n\n\n _nextMonth = () => {\n if (this.props.hideYear && this.state.curDate.month() == 11) {\n return;\n }\n this.setState({\n ...this.state,\n curDate: this.state.curDate.clone().add(1, \"M\")\n })\n };\n _nextYear = () => {\n if (this.props.hideYear) {\n return;\n }\n this.setState({\n ...this.state,\n curDate: this.state.curDate.clone().add(1, \"Y\")\n })\n };\n\n _setDate = (date) => { \n this.setState({\n ...this.state,\n textDate: date\n });\n };\n _onYearChange = (prop,year) => { \n let curDate = this.state.curDate;\n curDate.set('year', year);\n \n this.setState({\n ...this.state,\n curDate: curDate\n });\n };\n _onMonthChange = (prop,month) => { \n let curDate = this.state.curDate;\n curDate.set('month', month-1);\n \n this.setState({\n ...this.state,\n curDate: curDate\n });\n };\n _saveDate = () => {\n let temp = Moment.utc(this.state.textDate); \n this.setState({\n ...this.state,\n curDate : temp,\n });\n this.props.onChange(temp);\n\n };\n\n _onDateSelect = (newDate) => {\n this.props.onChange(newDate);\n };\n\n _getDayHeaderAsPerDow = (dow) => {\n const dayList = [\n \"MON\", \"TUE\", \"WED\", \"THURS\", \"FRI\", \"SAT\", \"SUN\"\n ]\n\n // K means how much the array should be rotated\n const k = (8 - dow ) % 7;\n\n for (let i = 0; i < k; i++) {\n dayList.unshift(dayList.pop());\n }\n\n return dayList;\n }\n\n render() {\n let realValue = this.props.value;\n Moment.updateLocale(\"en\", {\n week: {\n dow: ewars.getDOWMod7(),\n doy: (7 + ewars.getDOWMod7() - ewars.getDOY())\n }\n });\n let selected = Moment(realValue || undefined);\n let value;\n if(this.state.curDate && this.state.curDate.isValid()){\n value = this.state.curDate\n } \n else{\n\n value = Moment.utc();\n }\n let currentYear = new Date().getFullYear();\n if (!this.props.block_future) {\n currentYear += 10;\n }\n\n let years = [];\n let startYear = 1970;\n let x = 0; \n while ( startYear <= currentYear ) {\n x = currentYear--;\n years.push([x,x]);\n } \n let months = [\n [1 , __(\"JANUARY\")],\n [2,__(\"FEBRUARY\")],\n [3,__(\"MARCH\")],\n [4,__(\"APRIL\")],\n [5, __(\"MAY\")],\n [6,__(\"JUNE\")],\n [7,__(\"JULY\") ],\n [8,__(\"AUGUST\")],\n [9,__(\"SEPTEMBER\")],\n [10,__(\"OCTOBER\")],\n [11,__(\"NOVEMBER\")],\n [12,__(\"DECEMBER\")]\n ]\n let dayHeaders = [];\n let dow = ewars.getDOWMod7();\n \n // reverseDow should be ((7(length_of_week) + 1(offset, which is monday) - dow) % 7)\n // So, for sunday as dow, (7 + 1 - 0) % 7 = 1\n // for saturday as dow, (7 + 1 - 6) % 7 = 2\n // It counts no of days between the monday and current dow in reverse order,\n // So if we want to have sunday as dow, it is 1 day gap from monday to sunday in reverse\n // let reverseDow = dow == 0 ? 1 : 0;\n let reverseDow = ( 7 + 1 - dow) % 7;\n\n const daysAsPerDow = this._getDayHeaderAsPerDow(dow);\n\n dayHeaders.push(\n \n {__(\"W\")}\n { daysAsPerDow.map(hdr => {__(hdr)}) }\n \n )\n \n //locations \n this.state.curDate = value\n let year = value.year();\n\n let logical_month = value.month() + 1;\n\n // get the first day of the month\n let first_day = Moment([value.year(), value.month(), 1]);\n let first_day_weekday = first_day.day();\n if(dow == 1 && first_day_weekday == 0){\n first_day_weekday = 7;\n }\n\n // Find number of dasy in month\n let month_length = this.state.curDate.daysInMonth();\n let previous_month_length = Moment.utc([this.state.curDate.year(), this.state.curDate.month(), 1]).subtract(1, \"M\").daysInMonth();\n\n let monthShortName = this.state.curDate.format(\"MMM\");\n\n\n let day = 1,\n prev = 1,\n next = 1;\n\n let rows = [];\n for (var i = 0; i < 9; i++) {\n let cells = [];\n let weekNo = Moment([value.year(), value.month(), day]).week();\n cells.push({weekNo});\n for (var j = 1; j <= 7; j++) {\n if (day <= month_length && (i > 0 || j > (Math.abs(first_day_weekday + (7 - dow)))%7) ) {\n let active = true;\n if (this.props.block_future) {\n let targetDate = Moment.utc([value.year(), value.month(), day]);\n let today = Moment.utc();\n\n if (targetDate.isAfter(today, \"d\")) active = false;\n }\n cells.push(\n \n );\n day++;\n } else {\n if (day <= month_length) {\n let dayValue = previous_month_length - first_day_weekday - reverseDow + prev + 1;\n cells.push({dayValue});\n prev++;\n } else {\n cells.push({next});\n next++;\n }\n }\n }\n\n // Stop making rows if we've run out of days\n rows.push({cells});\n if (day > month_length) {\n break;\n }\n\n }\n\n const pickerHeader = this.props.hideYear ? monthShortName : `${year} - ${monthShortName}`;\n return (\n
\n
\n
\n
\n
\n {\n !this.props.hideYear ?\n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n : null }\n
\n \n
\n {/*
\n {pickerHeader}\n
*/}\n
\n
\n \n
\n
\n \n\n
\n \n
\n
\n
\n
\n
\n
\n \n \n {dayHeaders}\n \n \n {rows}\n \n
\n
\n
\n
\n {/*
\n this._setDate(event.target.value) }>\n
\n \n
\n
\n \n
\n \n
*/}\n
\n )\n }\n}\n\nexport default DayPicker;\n","class DisplayPicker extends React.Component {\n constructor(props) {\n super(props);\n }\n\n render() {\n let value = ewars.DATE(this.props.value, this.props.interval);\n return (\n
\n {value}\n
\n )\n }\n}\n\nexport default DisplayPicker;","import CONSTANTS from \"../constants\";\nimport Moment from \"moment\";\n\nclass Month extends React.Component {\n constructor(props) {\n super(props);\n }\n\n _onClick = () => {\n let newDate = Moment.utc([this.props.year, this.props.month, 1]);\n newDate = newDate.clone().endOf(\"M\");\n this.props.onClick(newDate);\n };\n\n render() {\n let name = CONSTANTS.MONTHS_SHORT[this.props.month];\n\n let className = \"cal-month\";\n\n let nominalDate = Moment.utc([this.props.year, this.props.month, 1]).endOf(\"M\");\n\n if (this.props.value.isSame(nominalDate, \"day\")) className += \" selected\";\n\n return (\n {name}\n )\n }\n}\n\nconst MONTHS = [\n [0, 1, 2, 3],\n [4, 5, 6, 7],\n [8, 9, 10, 11]\n];\n\nclass MonthPicker extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = {\n curDate: Moment.utc(this.props.value) || Moment.utc()\n }\n }\n\n componentWillReceiveProps(nextProps) {\n this.setState({\n curDate: Moment.utc(nextProps.value) || Moment.utc()\n })\n }\n\n _prevMonth = () => {\n this.setState({\n curDate: this.state.curDate.clone().subtract(1, 'Y')\n })\n };\n\n _nextMonth = () => {\n if (!this.props.block_future || (this.props.block_future && this.state.curDate.clone().isSameOrBefore(Moment.utc()))) {\n this.setState({\n curDate: this.state.curDate.clone().add(1, \"Y\")\n })\n }\n };\n\n _onDateSelect = (newDate) => {\n if(this.props.block_future && !newDate.clone().endOf(\"M\").isSameOrBefore(Moment.utc().endOf(\"M\"))){\n return;\n }\n this.props.onChange(newDate);\n };\n\n render() {\n\n let months = [];\n let selected = Moment.utc(this.props.value);\n let year = this.state.curDate.year();\n\n for (var i = 0; i <= 2; i++) {\n let cells = [];\n for (var j = 0; j <= 3; j++) {\n let date = this.state.curDate.clone().month(MONTHS[i][j]).endOf(\"M\");\n if(this.props.block_future && !date.isSameOrBefore(Moment.utc().endOf(\"M\"))){\n continue;\n }\n cells.push(\n \n )\n }\n months.push({cells})\n }\n\n return (\n
\n
\n
\n
\n
\n
\n \n
\n
\n {year}\n
\n
\n \n
\n
\n
\n
\n
\n
\n \n \n {months}\n \n
\n
\n
\n
\n
\n )\n }\n}\n\nexport default MonthPicker;\n","import Moment from \"moment\";\n\nclass Week extends React.Component {\n constructor(props) {\n super(props);\n }\n\n _onClick = () => {\n Moment.updateLocale(\"en\", {\n week: {\n dow:ewars.getDOWMod7(),\n doy: (7 + ewars.getDOWMod7() - ewars.getDOY())\n },\n });\n console.log(\"moment\",Moment.utc(this.props.week).add(6, 'd'))\n this.props.onClick(Moment.utc(this.props.week).add(6, 'd'));\n };\n\n render() {\n\n Moment.updateLocale(\"en\", {\n week: {\n dow:ewars.getDOWMod7(),\n doy: (7 + ewars.getDOWMod7() - ewars.getDOY())\n },\n });\n\n // let weekStart = Moment.utc(this.props.week).subtract(7, 'd');\n\n let label = ewars.DATE(this.props.week, \"WEEK\");\n let weekNo = this.props.week.week();\n\n let className = \"cal-week\";\n\n if (this.props.block_future) {\n if (this.props.week.isAfter(Moment.utc())) className += \" inactive\";\n }\n\n return (\n \n \n
\n
{weekNo}
\n
{label}
\n
\n \n \n )\n }\n}\n\nclass WeekPicker extends React.Component {\n static defaultProps = {\n offsetAvailability: false\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n curYear: Moment.utc(this.props.value).year() || Moment.utc().year()\n }\n }\n\n componentWillReceiveProps(nextProps) {\n this.setState({\n curYear: Moment.utc(nextProps.value).year() || Moment.utc().year()\n })\n }\n\n _prevMonth = () => {\n this.setState({\n curYear: this.state.curYear - 1\n })\n };\n\n _nextMonth = () => {\n this.setState({\n curYear: this.state.curYear + 1\n })\n };\n\n _onDateSelect = (newDate) => {\n console.log('newDate', newDate)\n this.props.onChange(newDate);\n };\n\n render() {\n\n let isoWeeksInYear = 53;\n\n // For each week in the year, generate a list item.\n var weeks2 = [];\n\n let comparator = Moment.utc();\n Moment.updateLocale(\"en\", {\n week: {\n dow: ewars.getDOWMod7(),\n doy: (7 + ewars.getDOWMod7() - ewars.getDOY())\n },\n });\n if (this.props.offsetAvailability) comparator.add(2, 'days');\n\n for (var i = 1; i <= isoWeeksInYear; i++) {\n if (this.props.block_future) {\n if (Moment.utc().weekYear(this.state.curYear).week(i).endOf(\"week\").isBefore(comparator)) {\n let dt = Moment.utc()\n .weekYear(this.state.curYear)\n .week(i);\n if (dt.weekYear() == this.state.curYear) {\n weeks2.push(Moment.utc().weekYear(this.state.curYear).week(i).startOf(\"week\"))\n }\n }\n } else {\n let dt = Moment.utc()\n .weekYear(this.state.curYear)\n .week(i);\n\n if (dt.weekYear() == this.state.curYear) {\n weeks2.push(Moment.utc()\n .weekYear(this.state.curYear)\n .week(i).startOf(\"week\"))\n }\n }\n }\n\n weeks2.reverse();\n\n // Given the month of the date, get the isoweeks in the month\n\n let selected;\n let value;\n\n let weeks = weeks2.map(function (week, i) {\n // console.log(week)\n return \n }.bind(this));\n\n return (\n
\n
\n
\n
\n
\n
\n \n
\n
\n {this.state.curYear}\n
\n
\n \n
\n
\n
\n
\n
\n
\n \n \n {weeks}\n \n
\n
\n
\n
\n
\n )\n }\n}\n\nexport default WeekPicker;\n","import Moment from \"moment\";\n\nclass YearPicker extends React.Component {\n constructor(props) {\n super(props);\n }\n\n _movePrevious = () => {\n let newDate;\n if (Moment.isMoment(this.props.value)) {\n newDate = this.props.value.clone().subtract(1, \"y\").endOf(\"Y\");\n } else {\n newDate = Moment.utc(this.props.value || new Date()).subtract(1, 'y').endOf(\"Y\");\n }\n this.props.onChange(newDate);\n };\n\n _moveNext = (isSelectedValue) => {\n let newDate;\n if (Moment.isMoment(this.props.value)) {\n if(isSelectedValue){\n newDate =this.props.value.clone().endOf(\"y\");\n }else{\n newDate = this.props.value.clone().add(1, \"y\").endOf(\"y\");\n }\n } else {\n if(isSelectedValue){\n newDate = Moment.utc(this.props.value || new Date()).endOf(\"y\");\n }else{\n newDate = Moment.utc(this.props.value || new Date()).add(1, 'y').endOf(\"Y\");\n }\n }\n if(this.props.block_future && !newDate.clone().endOf(\"Y\").isSameOrBefore(Moment.utc().endOf(\"Y\"))){\n return;\n }\n this.props.onChange(newDate);\n };\n\n render() {\n let value = Moment.utc(this.props.value || new Date());\n let year = value.year();\n\n return (\n
\n
\n
\n
\n \n
\n
{year}
\n
\n \n
\n
\n
\n\n
\n )\n }\n}\n\nexport default YearPicker;\n","var TreeNode = React.createClass({\n _hasLoaded: false,\n\n getInitialState: function () {\n return {\n showChildren: false\n };\n },\n\n onCaretClick: function (e) {\n e.stopPropagation();\n e.preventDefault();\n\n if ([\"row\", \"group\", \"matrix\", \"form\"].indexOf(this.props.data.nodeType) >= 0) {\n this.setState({\n showChildren: this.state.showChildren ? false : true\n })\n } else {\n this._onLabelClick(e);\n }\n\n },\n\n _onLabelClick: function (e) {\n e.stopPropagation();\n e.preventDefault();\n\n if ([\"row\", \"group\", \"matrix\", \"form\"].indexOf(this.props.data.field.type) < 0) {\n this.props.onNodeSelect(this.props.data);\n } else {\n this.onCaretClick(e);\n }\n },\n\n _hasChildren: function () {\n if (!this.props.data.children) return false;\n if (this.props.data.children.length > 0) return true;\n return false;\n },\n\n _getIcon: function () {\n var icon = \"fal \";\n\n if ([\"form\", \"row\", \"matrix\"].indexOf(this.props.data.nodeType) >= 0) {\n icon += \"fa-circle\";\n if (this.props.data.children) {\n if (this.props.data.children.length > 0) icon = \"fal fa-caret-right\";\n if (this.props.data.children.length > 0 && this.state.showChildren) icon = \"fal fa-caret-down\";\n }\n } else {\n icon += \"fa-th\";\n }\n\n return icon;\n },\n\n render: function () {\n var childs;\n\n if (this.state.showChildren) {\n childs = _.map(this.props.data.children, function (child) {\n return \n }, this)\n }\n\n var iconClass = this._getIcon();\n\n var nodeName = ewars.formatters.I18N_FORMATTER(this.props.data.label);\n\n return (\n
  • \n
    \n
    {nodeName}
    \n {this.state.showChildren ?\n
    \n
      \n {childs}\n
    \n
    \n : null}\n
  • \n )\n }\n});\n\nfunction _findFieldByPath(options, path) {\n var found;\n\n _.each(options, function (field) {\n if (field.path == path) found = field;\n if (!found && field.children) {\n var subFound = _findFieldByPath(field.children, path);\n if (subFound) found = subFound;\n }\n }, this);\n\n return found;\n}\n\nvar FormFieldTree = React.createClass({\n getInitialState: function () {\n return {\n nodeName: \"None Selected\",\n nodePath: null,\n showTree: false\n }\n },\n\n componentWillMount: function () {\n if (this.props.value) {\n var node = _findFieldByPath(this.props.options, this.props.value);\n\n if (node) {\n this.state.nodeName = node.pathLabel;\n this.state.nodePath = node.path;\n }\n }\n },\n\n _processTree: function () {\n return _.map(this.props.options, function (option) {\n return ;\n }, this)\n },\n\n _hideTree: function (e) {\n this.setState({\n showTree: false\n })\n },\n\n _toggleTree: function () {\n this.setState({\n showTree: this.state.showTree ? false : true\n })\n },\n\n _onNodeSelection: function (node) {\n this.setState({\n nodeName: node.pathLabel,\n nodePath: node.path,\n showTree: false\n });\n\n this.props.onUpdate(node);\n },\n\n render: function () {\n var rootNodes = this._processTree();\n\n return (\n
    \n
    \n
    \n
    {this.state.nodeName}
    \n
    \n
    \n
    \n
    \n {this.state.showTree ?\n
    \n
    \n
    \n\n
    \n\n
      \n {rootNodes}\n
    \n\n
    \n
    \n
    \n
    \n : null}\n\n
    \n )\n }\n});\n\nexport default FormFieldTree;\n","import Spinner from \"../c.spinner\";\n\nvar AssignmentItem = React.createClass({\n getInitialState: function () {\n return {}\n },\n\n onNodeClick: function () {\n this.props.onClick(this.props.data);\n },\n\n render: function () {\n var locationName = ewars.formatters.I18N_FORMATTER(this.props.data.location_name);\n\n return (\n
    \n {locationName}\n
    \n )\n }\n});\n\nvar Handle = React.createClass({\n render: function () {\n var name = ewars.I18N(this.props.current.name);\n\n return (\n
    \n \n \n \n \n \n \n \n
    {name}\n \n
    \n
    \n )\n }\n});\n\nvar Item = React.createClass({\n _onClick: function () {\n this.props.onClick(this.props.data);\n },\n\n render: function () {\n var className = 'item';\n if (this.props.value == this.props.data[0]) className += \" active\";\n\n return (\n
    {this.props.data[1]}
    \n )\n }\n});\n\nvar AssignmentLocationField = React.createClass({\n _isLoaded: false,\n _initialLoad: false,\n\n getInitialState: function () {\n return {\n assignments: [],\n showTree: false,\n currentLocation: {\n name: {en: \"No Location Selected\"}\n }\n }\n },\n\n componentWillMount: function () {\n if (this.props.value) {\n this._loadSetLocation();\n } else {\n this._initialLoad = true;\n }\n },\n\n _loadSetLocation: function () {\n ewars.tx(\"com.ewars.resource\", [\"location\", this.props.value, [\"uuid\", \"name\"], null])\n .then(function (resp) {\n this.state.currentLocation = resp;\n this._initialLoad = true;\n if (this.isMounted()) this.forceUpdate();\n }.bind(this))\n },\n\n _loadAssignments: function () {\n if (this.props.config.form_id) {\n ewars.tx(\"com.ewars.user.assignments\", [])\n .then(function (resp) {\n this.state.assignments = resp;\n this._isLoaded = true;\n if (this.isMounted()) this.forceUpdate();\n }.bind(this))\n }\n },\n\n componentWillReceiveProps: function (nextProps) {\n if (nextProps.config.form_id != this.props.config.form_id) {\n if (nextProps.config.form_id) {\n ewars.tx(\"com.ewars.user.assignments\", [])\n .then(function (resp) {\n this.state.assignments = resp;\n if (this.isMounted()) this.forceUpdate();\n }.bind(this));\n\n if (this.props.value != nextProps.value) {\n ewars.tx(\"com.ewars.resource\", [\"location\", nextProps.value, [\"uuid\", \"name\"], null])\n .then(function (resp) {\n this.state.currentLocation = resp;\n if (this.isMounted()) this.forceUpdate();\n }.bind(this))\n }\n }\n } else if (this.props.value != nextProps.value) {\n ewars.tx(\"com.ewars.resource\", [\"location\", nextProps.value, [\"uuid\", \"name\"], null])\n .then(function (resp) {\n this.state.currentLocation = resp;\n if (this.isMounted()) this.forceUpdate();\n }.bind(this))\n }\n },\n\n onNodeSelect: function (node) {\n this.state.currentLocation = node;\n this.state.showTree = false;\n this.forceUpdate();\n this.props.onUpdate(this.props.name, node.location_uuid, this.props.config.path || \"\");\n },\n\n _processLocations: function () {\n var items = _.map(this.state.assignments, function (item,index) {\n if (item.form_id == this.props.config.form_id) {\n return \n }\n }, this);\n\n return items;\n },\n\n _toggle: function () {\n this.state.showTree = this.state.showTree ? false : true;\n this.forceUpdate();\n\n if (!this._isLoaded) {\n this._loadAssignments();\n }\n },\n\n componentDidMount: function () {\n window.__assign_hack__.addEventListener('click', this.handleBodyClick);\n },\n\n componentWillUnmount: function () {\n window.__assign_hack__.removeEventListener('click', this.handleBodyClick);\n },\n\n handleBodyClick: function (evt) {\n if (this.refs.selector) {\n const area = this.refs.selector;\n\n if (!area.contains(evt.target)) {\n this.state.showTree = false;\n this.forceUpdate();\n }\n }\n },\n\n\n render: function () {\n if (this.props.value && !this._initialLoad) {\n return (\n
    \n
    \n \n
    \n
    \n )\n }\n\n\n var items = _.map(this.state.assignments, function (item,index) {\n if (item.form_id == this.props.config.form_id) {\n return ;\n }\n }, this);\n\n var selectedName = \"No Location Selected\";\n if (!this.props.config.form_id) selectedName = \"Please select a form first.\";\n if (this.state.currentLocation) selectedName = ewars.formatters.I18N_FORMATTER(this.state.currentLocation.location_name);\n\n if (this.props.readOnly) {\n return (\n \n )\n }\n\n\n if (!this._isLoaded && this.state.showTree) {\n items = ;\n }\n\n return (\n
    \n \n {this.state.showTree ?\n
    \n {items}\n
    \n : null}\n
    \n )\n }\n\n});\n\nexport default AssignmentLocationField;\n","import Button from \"../c.cmp.button\";\n\nclass ButtonGroupField extends React.Component {\n static defaultProps = {\n context_help: null,\n value: null,\n config: {\n context_help: null\n }\n };\n\n _onClick = (data) => {\n this.props.onUpdate(this.props.config.nameOverride || this.props.name, data[0], this.props.path || this.props.name);\n };\n\n render() {\n let contextHelp;\n if (this.props.config.context_help) {\n if (this.props.value != null) {\n contextHelp = __(this.props.config.context_help[this.props.value])\n }\n }\n return (\n
    \n {this.props.config.options.map((button, index) => {\n let key = `BUTTON_${index}`;\n return \n })}\n
    \n {contextHelp ?\n

    {contextHelp}

    \n : null}\n
    \n )\n }\n}\n\nexport default ButtonGroupField;\n","import TextField from \"./f.text\";\nimport SelectField from \"./../c.cmp.select\";\n\nconst ACTIONS = [\n ['fa-plus', 'ADD_ITEM', 'ADD_ITEM']\n];\n\nconst ACTIONS_OPTION = [\n ['fa-trash', 'DELETE', 'DELETE']\n];\n\nclass Item extends React.Component {\n constructor(props) {\n super(props);\n }\n\n _action = (action) => {\n this.props.onRemove(this.props.index);\n };\n\n _value = (prop, value) => {\n this.props.onChange(this.props.index, value);\n };\n\n render() {\n return (\n
    \n
    \n \n \n \n \n \n \n \n \n
    \n
    \n )\n }\n}\n\nclass CalculatedFieldDefinition extends React.Component {\n constructor(props) {\n super(props);\n }\n\n _action = (action) => {\n switch (action) {\n case \"ADD_ITEM\":\n let items = this.props.value || [];\n items.push(\"\");\n this.props.onChange(this.props.data.n, items);\n break;\n default:\n break;\n }\n\n };\n\n _onChange = (data) => {\n this.props.onChange(this.props.data.n, data);\n };\n\n _remove = (index) => {\n let items = this.props.value || [];\n items.splice(index, 1);\n this.props.onChange(this.props.data.n, items);\n };\n\n _change = (index, value) => {\n let items = this.props.value || [];\n items[index] = value;\n console.log(this.props.data.n);\n this.props.onChange(this.props.data.n, items);\n // this.props.onChange(this.props.data.n, false,{propKey:\"show_mobile\"}); // update show_mobile=false\n };\n\n render() {\n\n let fields = (this.props.data.fo || []).filter(item => {\n return item[2].type == \"number\" || item[2].type == \"text\";\n });\n let fieldOptions = fields.map(item => {\n return [item[2].path, item[1]];\n })\n let options = (this.props.value || []).map((item, index) => {\n return \n });\n\n return (\n \n \n \n \n \n\n \n \n \n \n \n
    \n {options}\n
    \n\n
    \n
    \n
    \n )\n }\n}\n\nexport default CalculatedFieldDefinition;\n","import { Layout, Row, Cell } from \"../layout\";\n\nimport TextField from \"./f.text\";\n\nconst COLOURS = [\n [ \"#FFFFFF00\",\"#000000\", \"#191919\", \"#333333\", \"#4C4C4C\", \"#666666\"],\n [\"#7F7F7F\", \"#999999\", \"#B3B3B3\", \"#E6E6E6\", \"#FFFFFF\"],\n [\"#004080\", \"#000080\", \"#0000FF\", \"#0080FF\", \"#66CCFF\"],\n [\"#66FFFF\", \"#00FFFF\", \"#008080\", \"#008040\", \"#408000\"],\n [\"#008000\", \"#00FF00\", \"#80FF00\", \"#66FF66\", \"#00FF80\"],\n [\"#66FFCC\", \"#804000\", \"#800000\", \"#FF0000\", \"#FF6666\"],\n [\"#FF8000\", \"#FFFF00\", \"#FFFF66\", \"#FFCC66\", \"#400080\"],\n [\"#800080\", \"#800040\", \"#8000FF\", \"#FF00FF\", \"#FF0080\"],\n [\"#CC66FF\", \"#FF66FF\"]\n];\n\nclass ColorCell extends React.Component {\n constructor(props) {\n super(props);\n }\n\n _onClick = () => {\n this.props.onClick(this.props.data);\n };\n\n render() {\n return (\n \n\n \n )\n }\n}\n\nclass ColourField extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = {\n shown: false,\n showLeft: false\n }\n }\n\n componentWillMount() {\n window.__hack__.addEventListener(\"click\", this._onBodyClick);\n }\n\n componentWillUnmount() {\n window.__hack__.removeEventListener(\"click\", this._onBodyClick);\n }\n\n _onBodyClick = (evt) => {\n if (this.refs.selector) {\n const area = this.refs.selector.getDOMNode ? this.refs.selector.getDOMNode() : this.refs.selector;\n\n if (!area.contains(evt.target)) {\n this.setState({\n shown: false\n })\n }\n }\n };\n\n _trigger = () => {\n let boundingRect = this.refs.selector.getBoundingClientRect();\n let screenWidth = window.innerWidth;\n\n let showLeft = false;\n if (screenWidth - boundingRect.right < 250) {\n showLeft = true;\n }\n\n this.setState({\n shown: !this.state.shown,\n showLeft: showLeft\n })\n };\n\n _onColourSelect = (colour) => {\n this.setState({shown: false});\n this.props.onUpdate(this.props.name, colour);\n };\n\n _onCustomChange = (prop, value) => {\n this.props.onUpdate(this.props.name, value);\n };\n\n render() {\n let STYLE;\n \n if(this.props.style){\n STYLE = this.props.style\n }else{\n STYLE = {\n height: 30,\n backgroundColor: \"#FFFFFF\",\n padding: 5,\n textAlign: \"center\"\n };\n }\n if (this.props.value) STYLE.backgroundColor = this.props.value;\n\n let dropStyle = {\n padding: 5,\n width: 250\n };\n\n if (this.state.showLeft) {\n dropStyle.left = \"-271px\"\n }\n\n return (\n
    \n
    \n \n \n \n \n \n
    \n {this.state.shown ?\n
    \n \n \n \n \n {COLOURS.map((row, rowIndex) => {\n return (\n \n {row.map((cell, cellIndex) => {\n return (\n \n )\n })}\n \n )\n })}\n \n \n \n \n \n
    \n \n \n
    \n
    \n
    \n
    \n : null}\n
    \n )\n }\n}\n\nexport default ColourField;\n","import { Layout, Row, Cell} from \"../layout\";\n\nimport EditableList from \"../c.editable_list\";\nimport Colour from \"./f.colour\";\nimport TextField from \"./f.text\";\nimport NumericField from \"./f.numeric\";\n\nconst ACTIONS = [\n {icon: \"fa-plus\", action: \"ADD\" , tooltip : __(\"ADD_THRESHHOLD\")},\n {icon: \"fa-minus\", action: \"REMOVE\" ,tooltip : __(\"REMOVE_THRESHHOLD\") },\n {icon: \"fa-caret-up\", action: \"MOVE_UP\" ,tooltip : __(\"MOVE_UP\")},\n {icon: \"fa-caret-down\", action: \"MOVE_DOWN\", tooltip : __(\"MOVE_DOWN\")}\n];\n\nconst SEP_STYLE = {\n textAlign: \"center\",\n lineHeight: \"30px\"\n};\n\nlet INF_STYLE = {\n borderTopRightRadius: 3,\n borderBottomRightRadius: 3,\n borderTop: \"1px solid #505152\",\n borderRight: \"1px solid #505152\",\n borderBottom: \"1px solid #505152\",\n textAlign: \"center\",\n lineHeight: \"30px\",\n width: \"37px\",\n height: \"31px\"\n};\n\nclass ThresholdColour extends React.Component {\n onClick = () => {\n this.props.onClick(this.props.index);\n };\n\n _onChange = (prop, value) => {\n this.props.onChange(this.props.index, prop, value);\n };\n\n _setMaxInf = () => {\n let newValue = \"INF\";\n if (this.props.data[1] == \"INF\") newValue = 0;\n this.props.onChange(this.props.index, \"max\", newValue);\n };\n\n render() {\n let readOnly = false;\n if (this.props.data[1] == \"INF\") readOnly = true;\n let value = this.props.data[1];\n if (this.props.data[1] == \"INF\") value = \"Infinity\";\n\n let MAX_STYLE = {\n borderTopRightRadius: 0,\n borderBottomRightRadius: 0\n };\n let INF_STYLE_COPY = Object.assign({}, INF_STYLE)\n\n if (this.props.data[1] == \"INF\") {\n INF_STYLE_COPY.background = \"#505152\";\n INF_STYLE_COPY.color = \"#F2F2F2\";\n\n MAX_STYLE.background = \"#505152\";\n MAX_STYLE.color = \"#F2F2F2\";\n }\n\n let className = \"iw-list-edit-item\";\n if (this.props.active) className += \" active\";\n\n const hideMinField = (this.props.config && this.props.config.showOnlyMax);\n\n return (\n
    \n \n {!hideMinField &&\n \n \n \n }\n {!hideMinField && to}\n {hideMinField && {`<=`}}\n\n \n \n \n \n \n
    Inf
    \n
    \n
    \n =\n \n \n \n
    \n
    \n )\n }\n}\n\nclass ThresholdValue extends React.Component {\n onClick = () => {\n this.props.onClick(this.props.index);\n };\n\n _onChange = (prop, value) => {\n this.props.onChange(this.props.index, prop, value);\n };\n\n _setMaxInf = () => {\n let newValue = \"INF\";\n if (this.props.data[1] == \"INF\") newValue = 0;\n this.props.onChange(this.props.index, \"max\", newValue);\n };\n\n render() {\n let className = \"iw-list-edit-item\";\n if (this.props.active) className += \" active\";\n\n let readOnly = false;\n if (this.props.data[1] == \"INF\") readOnly = true;\n let value = this.props.data[1];\n if (this.props.data[1] == \"INF\") value = \"Infinity\";\n\n let MAX_STYLE = {\n borderTopRightRadius: 0,\n borderBottomRightRadius: 0\n };\n\n let INF_STYLE_COPY = Object.assign({}, INF_STYLE)\n\n\n if (this.props.data[1] == \"INF\") {\n INF_STYLE_COPY.background = \"#505152\";\n INF_STYLE_COPY.color = \"#F2F2F2\";\n\n MAX_STYLE.background = \"#505152\";\n MAX_STYLE.color = \"#F2F2F2\";\n }\n\n return (\n
    \n \n \n \n \n to\n \n \n \n \n \n
    Inf
    \n
    \n\n\n
    \n =\n \n \n \n
    \n
    \n )\n }\n}\n\nclass ColourThresholdsField extends React.Component {\n static defaultProps = {\n output_type: \"COLOUR\",\n config: {\n output_type: \"COLOUR\"\n }\n };\n\n constructor(props) {\n super(props);\n }\n\n _onListAction = (action, selectedIndex) => {\n if (action === \"ADD\") {\n let thresholds = this.props.value || [];\n thresholds.push([0, 0, \"\"]);\n this.props.onUpdate(this.props.name, thresholds);\n }\n\n if (action === \"REMOVE\") {\n let thresholds = this.props.value || [];\n thresholds.splice(selectedIndex, 1);\n this.props.onUpdate(this.props.name, thresholds);\n }\n\n if (action === \"MOVE_UP\") {\n if (selectedIndex > 0) {\n let thresholds = this.props.value || [];\n let tmp = thresholds[selectedIndex - 1];\n\n thresholds[selectedIndex - 1] = thresholds[selectedIndex];\n thresholds[selectedIndex] = tmp;\n\n this.props.onUpdate(this.props.name, thresholds);\n }\n }\n\n if (action === \"MOVE_DOWN\") {\n let thresholds = this.props.value || [];\n if (selectedIndex < thresholds.length) {\n let tmp = thresholds[selectedIndex + 1];\n thresholds[selectedIndex + 1] = thresholds[selectedIndex];\n thresholds[selectedIndex] = tmp;\n\n this.props.onUpdate(this.props.name, thresholds);\n }\n }\n\n };\n\n _onPropChange = (index, prop, value) => {\n let threshes = this.props.value;\n if (prop == \"colour\") threshes[index][2] = value;\n if (prop == \"output\") threshes[index][2] = value;\n if (prop == \"min\") threshes[index][0] = value;\n if (prop == \"max\") threshes[index][1] = value;\n\n this.props.onUpdate(this.props.name, threshes);\n };\n\n render() {\n let Template = ThresholdColour;\n if (this.props.config.output_type == \"VALUE\") Template = ThresholdValue;\n\n return (\n
    \n \n {this.props.config.from == 'solidgauge' ?\n

    ( Please enter thresholds value between 0 - 100 percentage )

    \n : null\n }\n
    \n )\n }\n}\n\nexport default ColourThresholdsField;\n","import ConditionsRow from \"./c.conditions.row\";\nimport Button from \"../c.button\";\n\nvar ConditionsField = React.createClass({\n\n getInitialState: function () {\n return {\n data: {\n rules: [\n [\"none\", \"eq\", null]\n ],\n application: \"ALL\"\n }\n };\n },\n\n _addRule: function () {\n var newConditions = this.state.data.rules ? this.state.data.rules : [];\n newConditions.push([null, \"eq\", null]);\n this.state.data.rules = newConditions;\n this.props.onUpdate(this.props.name, this.state.data);\n },\n\n _removeRule: function (index) {\n var rules = ewars.copy(this.state.data);\n rules.rules.splice(index, 1);\n this.props.onUpdate(this.props.name, rules);\n },\n\n _defaultRow: [\"none\", \"eq\", \"none\"],\n\n componentWillMount: function () {\n if (!this.props.value || this.props.value.length >= 0) {\n this.state.data = {\n application: \"ALL\",\n rules: [\n [\"none\", \"eq\", false]\n ]\n }\n } else {\n if (this.props.config.value != undefined) this.state.data = this.props.config.value;\n }\n },\n\n componentWillReceiveProps: function (nextProps) {\n this.state.data = nextProps.value;\n },\n\n _rowUpdate: function (index, data) {\n this.state.data.rules[index] = data;\n this.props.onUpdate(this.props.name, this.state.data);\n },\n\n _onApplicationChange: function (e) {\n this.state.data.application = e.target.value;\n this.props.onUpdate(this.props.name, this.state.data);\n },\n\n render: function () {\n var rules = [];\n\n if (this.state.data.rules) {\n rules = _.map(this.state.data.rules, function (rule, index) {\n return \n }, this);\n }\n\n return (\n
    \n
    \n \n \n \n \n \n \n \n
    Pass When\n \n
    \n\n {rules}\n\n
    \n \n
    \n
    \n
    \n )\n }\n});\n\nexport default ConditionsField;\n","import DayPicker from \"./c.date.day\";\nimport WeekPicker from \"./c.date.week\";\nimport MonthPicker from \"./c.date.month\";\nimport YearPicker from \"./c.date.year\";\nimport DisplayPicker from \"./c.date.display\";\nimport Moment from \"moment\";\nimport {getMonthsDaysBetweenDates} from \"../utils/DateUtils\"\n\nconst PICKERS = {\n NONE: DayPicker,\n DAY: DayPicker,\n WEEK: WeekPicker,\n MONTH: MonthPicker,\n YEAR: YearPicker,\n DISPLAY: DisplayPicker\n};\n\nclass Handle extends React.Component {\n constructor(props) {\n super(props);\n }\n\n render() {\n let name = __(\"NO_DATE_SELECTED\"),\n showClear = false;\n\n if (this.props.value) {\n let value = this.props.value;\n if(typeof value == 'object'){\n value = Moment(value).format('YYYY-MM-DD');\n }\n name = ewars.DATE(value, this.props.hideYear ? 'MMM DD' : this.props.format);\n showClear = true;\n }\n\n return (\n
    \n
    \n
    {name}
    \n {showClear ?\n
    \n \n
    \n : null}\n
    \n \n
    \n
    \n
    \n )\n }\n}\n\nclass DateField extends React.Component {\n constructor(props) {\n super(props);\n\n let val = this.props.value;\n if (!val) val = null;\n\n this.state = {\n showOptions: false,\n value: val || Moment()\n }\n }\n\n static defaultProps = {\n value: null,\n dispValue: null,\n name: null,\n config: {\n block_future: true,\n date_type: \"DAY\"\n }\n };\n\n componentWillMount() {\n window.__hack__.addEventListener(\"click\", this._handleBodyClick);\n if (!this.props.value) {\n this.state.value = Date.now()\n } else {\n let val = this.props.value;\n if (!val) val = null;\n this.state.value = val;\n }\n }\n\n componentWillReceiveProps(nextProps) {\n if (!nextProps.value) {\n this.state.value = Date.now()\n } else {\n let val = nextProps.value;\n if (!val) val = null;\n this.state.value = val;\n }\n }\n\n componentWillUnmount() {\n window.__hack__.removeEventListener(\"click\", this._handleBodyClick);\n }\n\n _handleBodyClick = (evt) => {\n if (this.refs.selector) {\n const area = this.refs.selector;\n\n if (!area.contains(evt.target)) {\n this.state.showOptions = false;\n this.forceUpdate();\n }\n }\n };\n\n _onValueChange = (newValue) => {\n let name = this.props.name;\n if (this.props.config.nameOverride) name = this.props.config.nameOverride;\n this.state.showOptions = false;\n this.props.onUpdate(name, newValue.clone().format(\"YYYY-MM-DD\"), this.props.config.path || null);\n let age_field;\n for (const key in this.props.definition) {\n if (\n this.props.definition.hasOwnProperty(key) &&\n typeof this.props.definition[key] === \"object\" &&\n this.props.definition[key] !== null\n ) {\n const field = this.props.definition[key];\n if (\n field.hasOwnProperty(\"is_age_field\") &&\n field.is_age_field === true\n ) {\n age_field = field;\n break;\n }\n }\n }\n\n if (age_field && age_field.select_date_field === name) {\n const age =\n age_field.select_month_year_field === \"month\"\n ? getMonthsDaysBetweenDates(newValue.clone().format(\"YYYY-MM-DD\")).months\n : getMonthsDaysBetweenDates(newValue.clone().format(\"YYYY-MM-DD\")).years;\n this.props.onUpdate(age_field.name, age, age_field.name);\n }\n };\n\n _toggle = () => {\n this.setState({\n showOptions: !this.state.showOptions\n })\n };\n\n _clear = (e) => {\n e.preventDefault();\n e.stopPropagation();\n let name = this.props.name;\n if (this.props.config.nameOverride) name = this.props.config.nameOverride;\n this.props.onUpdate(name, null, this.props.config.path || null);\n };\n\n render() {\n let view;\n let date_type = this.props.config.date_type || this.props.date_type;\n let ViewCmp = PICKERS[date_type || \"DAY\"];\n\n if (this.props.readOnly) {\n let label=ewars.DATE(this.state.value, date_type);\n if(!this.props.value) label= __(\"NO_DATE_SELECTED\");\n return (\n {}}/>\n )\n }\n let ewSelectStyle={};\n if (this.props.ewSelectWidth){\n ewSelectStyle.width=this.props.ewSelectWidth;\n }\n view = ;\n\n if (date_type == \"YEAR\") return view;\n\n\n return (\n
    \n \n {this.state.showOptions ?\n
    \n {view}\n
    \n : null}\n
    \n )\n }\n}\n\nexport default DateField;\n","function debounce(fn, delay) {\n var timer = null;\n return function () {\n var context = this, args = arguments;\n clearTimeout(timer);\n timer = setTimeout(function () {\n fn.apply(context, args);\n }, delay);\n };\n}\nclass DisplayCalculatedField extends React.Component {\n constructor(props) {\n super(props)\n this.onUpdate = debounce(this.onUpdate, 100);\n }\n onUpdate = (value) => {\n this.props.onUpdate(this.props.config.nameOverride || this.props.name, value, this.props.path || this.props.name);\n }\n componentWillReceiveProps(nextProps) {\n let value;\n (this.props.config.calc_def || []).forEach((item, index) => {\n let fieldVal = nextProps.data[item];\n if (this.props.config.calc_def_formula == \"SUM\") {\n value = value || 0;\n fieldVal = fieldVal || 0;\n value += parseFloat(fieldVal);\n } else if (this.props.config.calc_def_formula == 'SUBTRACT') {\n value = value || 0;\n fieldVal = fieldVal || 0;\n if (index == 0 ) value = parseFloat(fieldVal)\n else value -= parseFloat(fieldVal);\n } else {\n value = value == undefined ? '' : value;\n value += fieldVal || '';\n if (this.props.config.calc_def_formula_separator && ((index + 1) < this.props.config.calc_def.length)) {\n value += this.props.config.calc_def_formula_separator || '';\n }\n }\n });\n if (value !== nextProps.value && (value !== 0 || nextProps.value !== \"\")) {\n this.onUpdate(value);\n }\n }\n\n render() {\n return (\n \n )\n }\n}\n\nexport default DisplayCalculatedField;","var DisplayField = React.createClass({\n getInitialState: function () {\n return {};\n },\n\n render: function () {\n return (\n
    \n {this.props.config.defaultValue || this.props.value}\n
    \n )\n }\n});\n\nexport default DisplayField;\n","import { Layout, Row, Cell } from \"../layout\";\nimport ButtonGroup from \"./f.button_group\";\n\nimport NumericField from \"./f.numeric\";\nconst NumberField = NumericField;\n\nconst PX_REG = /([px])/g;\nconst EM_REG = /([em])/g;\nconst PERC_REG = /([%])/g;\n\nconst BUTTON_OPTIONS = [\n [\"px\", \"px\"],\n [\"%\", \"%\"],\n [\"em\", \"em\"]\n];\n\nconst UNITS_CONFIG = {\n options: BUTTON_OPTIONS\n};\n\nclass DOMSizeField extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = {\n units: \"px\"\n }\n }\n\n _onUnitsChange = (prop, units) => {\n let value = 0;\n if (PX_REG.test(this.props.value)) {\n value = this.props.value.replace(\"px\", \"\");\n this.props.onUpdate(this.props.name, value + units);\n return;\n }\n\n if (EM_REG.test(this.props.value)) {\n value = this.props.value.replace(\"em\", \"\");\n this.props.onUpdate(this.props.name, value + units);\n return;\n }\n\n if (PERC_REG.test(this.props.value)) {\n value = this.props.value.replace(\"%\", \"\");\n this.props.onUpdate(this.props.name, value + units);\n\n }\n };\n\n _onValueChange = (prop, value) => {\n let units;\n if (PX_REG.test(this.props.value)) units = \"px\";\n if (EM_REG.test(this.props.value)) units = \"em\";\n if (PERC_REG.test(this.props.value)) units = \"%\";\n\n if (!units) units = \"px\";\n\n let update;\n if (value) update = value + units;\n\n this.props.onUpdate(this.props.name, update);\n };\n\n\n render() {\n let value = this.props.value;\n let units = \"px\";\n if (isNaN(value)) {\n if (value.indexOf(\"px\") >= 0) {\n value = value.replace(\"px\", \"\");\n } else if (value.indexOf(\"em\") >= 0) {\n value = value.replace(\"em\", \"\");\n units = \"em\";\n } else if (value.indexOf(\"%\") >= 0) {\n value = value.replace(\"%\", \"\");\n units = \"%\";\n }\n }\n\n const unitsConfig = {...UNITS_CONFIG};\n \n if(this.props.config.hide){\n unitsConfig.options = UNITS_CONFIG.options.filter(unit_conf => !this.props.config.hide.includes(unit_conf[0]));\n }\n\n return (\n \n \n \n \n \n \n \n \n \n \n )\n }\n}\n\nexport default DOMSizeField;\n","const ALLOWED_TYPES = [\n \"image/png\",\n \"image/jpg\",\n \"image/jpeg\",\n \"application/pdf\",\n \"text/csv\",\n \"image/gif\"\n];\n\nclass FileField extends React.Component {\n static defaultProps = {\n filePath: \"/{account_id}/assets/\",\n allowedTypes: ALLOWED_TYPES.slice(\",\").join(\",\"),\n label: \"Choose file\",\n file_size: 2,\n local: false,\n return_data: false,\n onData: null,\n binary: false,\n showInput: true,\n showPreview: true,\n checkType:false\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n uploading: false,\n file: null,\n imagePreviewUrl: null\n }\n }\n\n componentWillMount() {\n this._uuid = ewars.utils.uuid();\n if (this.props.value) this.state.imagePreviewUrl = this.props.value;\n }\n\n componentWillReceiveProps(nextProps) {\n if (this.props.value != nextProps.value) this.state.imagePreviewUrl = nextProps.value;\n }\n _checkfile=(sender)=> {\n if(!this.props.checkType){\n return true;\n }\n var validExts = this.props.allowedTypes.trim().split(\",\");\n var fileExt = sender.type;\n // fileExt = fileExt.substring(fileExt.lastIndexOf('.'));\n if (validExts.indexOf(fileExt) < 0) {\n ewars.error(__(\"INVALID_FILE_TYPE\"));\n return false;\n }\n else return true;\n }\n _onFileChange = (event) => {\n event.preventDefault();\n\n let reader = new FileReader();\n let file = event.target.files[0];\n if(!this._checkfile(file)){\n return ;\n }\n reader.onloadend = () => {\n this.setState({\n file: file,\n imagePreviewUrl: reader.result,\n uploading: true\n });\n\n if (this.props.return_data) {\n this.props.onData(reader.result);\n } else {\n this._upload(reader.result);\n }\n };\n\n if (this.props.binary) {\n reader.readAsBinaryString(file);\n } else {\n reader.readAsDataURL(file);\n }\n\n };\n\n _upload = (fileData) => {\n let bl = new ewars.Blocker(null, __(\"UPLOADING_FILE\"));\n let formData = new FormData();\n formData.append(\"file\", this.refs.filer.files[0]);\n formData.append(\"fileName\", this.state.file.name);\n formData.append(\"fileType\", this.state.file.type);\n formData.append(\"tki\", window.user.tki);\n if (this.props.local || (this.props.data && this.props.data.local)) {\n formData.append(\"local\", true);\n }\n if (this.props.isCountryInstance){\n formData.append(\"countryInstance\", true);\n formData.append(\"domain\", this.props.domain);\n }\n let oReq = new XMLHttpRequest();\n\n oReq.onreadystatechange = () => {\n let DONE = 4;\n let OK = 200;\n\n if (oReq.readyState == DONE) {\n bl.destroy();\n if (oReq.status == OK) {\n let resp = JSON.parse(window.decodeURI(oReq.responseText));\n this.props.onUpdate(this.props.name, resp.fn);\n } else {\n if (oReq.status == 500) {\n }\n\n if (oReq.status == 101) {\n\n }\n }\n }\n };\n\n oReq.open(\"POST\", \"/upload\", true);\n oReq.send(formData);\n };\n\n render() {\n let imagePreviewUrl = this.state.imagePreviewUrl;\n let imagePreview;\n if (imagePreviewUrl) {\n imagePreview = ();\n }\n\n let inputStyle = {};\n if (!this.props.showInput) inputStyle.display = \"none\";\n\n return (\n
    \n \n \n {this.props.showPreview && imagePreview ?\n
    {imagePreview}
    \n : null}\n
    \n )\n }\n}\n\nexport default FileField;\n","import { NONE } from \"../constants\";\n\nconst ALLOWED_TYPES = [\n \"image/png\",\n \"image/jpg\",\n \"image/jpeg\",\n \"application/pdf\",\n \"text/csv\",\n \"image/gif\",\n \"text/javascript\",\n \"text/css\"\n];\n\nclass FileUploadField extends React.Component {\n static defaultProps = {\n filePath: \"/{account_id}/assets/\",\n allowedTypes: ALLOWED_TYPES.slice(\",\").join(\",\"),\n label: \"Choose file\",\n file_size: 2,\n local: false,\n return_data: false,\n onData: null,\n binary: false,\n showInput: true,\n showPreview: true,\n checkType:false,\n readFile : false\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n uploading: false,\n file: null,\n imagePreviewUrl: null\n }\n }\n\n componentWillMount() {\n this._uuid = ewars.utils.uuid();\n if (this.props.value) this.state.imagePreviewUrl = this.props.value;\n }\n\n componentWillReceiveProps(nextProps) {\n if (this.props.value != nextProps.value) this.state.imagePreviewUrl = nextProps.value;\n }\n _checkfile=(sender)=> {\n if(!this.props.checkType){\n return true;\n }\n var validExts = this.props.allowedTypes.trim().split(\",\");\n var fileExt = sender.type,fileName=sender.name;\n // fileExt = fileExt.substring(fileExt.lastIndexOf('.'));\n if(fileName.indexOf('#') >= 0){\n ewars.error(__(\"INVALID_FILE_NAME\"));\n return false;\n }\n if (validExts.indexOf(fileExt) < 0) {\n ewars.error(__(\"NOTALLOWED_FILE_TYPE\"));\n return false;\n }\n else return true;\n }\n _onFileChange = (event, label = null, refs = null) => {\n event.preventDefault();\n\n let reader = new FileReader();\n let file = event.target.files[0];\n if(!this._checkfile(file)){\n return ;\n }\n reader.onloadend = () => {\n this.setState({\n file: file,\n imagePreviewUrl: reader.result,\n uploading: true\n });\n\n if (this.props.return_data) {\n this.props.onData(reader.result);\n } else {\n this._upload(reader.result, label, refs, file);\n }\n };\n\n if (this.props.binary) {\n reader.readAsBinaryString(file);\n } else {\n reader.readAsDataURL(file);\n }\n\n };\n\n _upload = (fileData, label, refs, file) => {\n \n if(label) label = label;\n else if(this.props.config && this.props.config.bucket_path) label = this.props.config.bucket_path;\n else label = 'site_images'\n\n let bl = new ewars.Blocker(null, __(\"UPLOADING_FILE\"));\n let formData = new FormData();\n formData.append(\"file\", refs ? refs : this.refs.filer.files[0]);\n formData.append(\"filename\", refs ? refs.name : this.state.file.name);\n formData.append(\"label\", label);\n if(this.props.readFile){\n var reader = new FileReader();\n reader.onload = (event) => {\n let data = event.target.result;\n data = JSON.parse(data);\n let features = data[\"features\"] || [];\n let properties = [];\n let location = features[0];\n if(location){\n let obj = location[\"properties\"];\n properties = Object.keys(obj);\n this.props.onPropertiesFetch(refs ? refs.name : this.state.file.name,properties,data);\n }\n bl.destroy();\n };\n reader.readAsText(refs ? refs : this.refs.filer.files[0]);\n }\n else{\n if(!this.props.uploadAsBinary) formData.append(\"content_type\", file.type);\n\n let oReq = new XMLHttpRequest();\n\n oReq.onreadystatechange = () => {\n let DONE = 4;\n let OK = 200;\n\n if (oReq.readyState == DONE) {\n bl.destroy();\n if (oReq.status == OK) {\n let resp = JSON.parse(window.decodeURI(oReq.responseText));\n if(this.props.isDownload){\n let link=document.createElement('a');\n link.href = \"https://\" + ewars.domain + \"/download/\" + resp.file_name;\n link.download = link.href.substr(link.href.lastIndexOf('/') + 1);\n link.click();\n }\n if(this.props.isForUploadingCss){\n this.props.onUpdate(this.props.name, resp.data,this.state.file.type);\n }else{\n ewars.growl(__(\"FILE_UPLOADED_SUCCESSFULLY\"))\n this.props.onUpdate(this.props.name, resp.data);\n }\n } else {\n if (oReq.status == 500) {\n }\n\n if (oReq.status == 101) {\n\n }\n }\n }\n };\n \n let path = \"/api/s3Bucket\"\n if (this.props.api_path || (this.props.data && this.props.data.api_path)) {\n path = this.props.api_path || this.props.data.api_path;\n }\n oReq.open(\"POST\",path , true);\n oReq.send(formData);\n }\n };\n\n render() {\n let imagePreviewUrl = this.state.imagePreviewUrl;\n let imagePreview;\n if (imagePreviewUrl) {\n imagePreview = ();\n }\n let inputStyle = {};\n if (!this.props.showInput) inputStyle.display = \"none\";\n\n return (\n
    \n \n \n {this.props.showPreview && imagePreview ?\n
    {imagePreview}
    \n : null}\n
    \n )\n }\n}\n\nexport default FileUploadField;\n","class FormFieldField extends React.Component {\n static defaultProps = {\n required_type: null\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n forms: ewars.g.forms || null\n };\n\n if (!ewars.g.forms) {\n ewars.tx(\"com.ewars.mapping.layer_options\", [])\n .then(res => {\n ewars.g.forms = res.forms;\n this.setState({\n forms: res.forms\n })\n })\n .catch(err => {\n ewars.error(__(\"ERR_LOADING_FORM\"));\n })\n }\n }\n\n _onChange = (e) => {\n let value = this.props.value || [null, null];\n if (e.target.name == \"fid\") value[0] = e.target.value;\n if (e.target.name == \"field\") value[1] = e.target.value;\n this.props.onUpdate(this.props.name, value);\n };\n\n render() {\n\n if (!this.state.forms) {\n return (\n
    {__(\"LOADING\")}
    \n )\n }\n\n let fields = [];\n let form_id = (this.props.value || [null, null])[0] || null;\n if (form_id != null) {\n let form = this.state.forms.filter(item => {\n return item.id == form_id\n })[0] || null;\n\n if (form) {\n for (let i in form.definition) {\n fields.push([i, __(form.definition[i].label), form.definition[i].type]);\n }\n }\n\n // If we're only looking for a specific type of field,\n // fulter the fields available to that type\n if (this.props.config.required_type) {\n fields = fields.filter(item => {\n return item[2] === this.props.config.required_type;\n })\n }\n }\n\n return (\n
    \n \n
    \n \n \n {this.state.forms.map(item => {\n return (\n \n )\n })}\n \n
    \n\n
    \n\n \n
    \n \n \n {fields.map((item,index) => {\n return \n })}\n \n
    \n
    \n )\n }\n}\n\nexport default FormFieldField;\n","// Dependent upno the current form . The dynamic form configuration (json object) must be having the form_id as property\nimport Complex from \"../editors/logic/Complex\";\nimport Set from \"../editors/logic/Set\"\nconst events = [\n \"etl-add-field\",\n \"etl-add-set\",\n \"etl-remove_set\",\n \"etl-change-rule\",\n\n // Root-level events\n \"ind-rule-change\",\n \"ind-swap\",\n \"remove-ind\",\n \"dupe-ind\",\n \"ind-move-up\",\n \"ind-move-down\",\n\n \"ind-remove-field\",\n \"ind-update-field\",\n \"ind-remove-complex\",\n\n \"etl-set-update-rule\",\n \"etl-set-remove-rule\",\n \"etl-set-change-provision\"\n\n]\nclass FormFieldCondition extends React.Component {\n\n constructor(props) {\n super(props);\n\n this.state = {\n form_id: null,\n definition: null,\n items: [\"ALL\", \":EQ:\"],\n id : ewars.utils.uuid()\n };\n }\n componentDidMount() {\n if(this.props.value){\n this.state.items = this.props.value\n }\n events.forEach(event => {\n window.addEventListener(event, this._onAction);\n });\n }\n componentWillMount () {\n if (this.props.value) {\n this.state.items = this.props.value;\n }\n }\n componentWillReceiveProps(nextProps) {\n if(nextProps.value){\n this.state.items = nextProps.value;\n }\n }\n\n _onAction = (e) => {\n if(e.detail.id == this.state.id){\n switch (e.type) {\n case \"etl-add-field\":\n this._addSet()\n break;\n case \"etl-set-remove-rule\":\n this._removeSet(e.detail);\n break;\n case \"etl-set-update-rule\":\n this._updateSetValue(e.detail);\n break;\n case \"etl-set-change-provision\":\n this._updateCondition(e.detail);\n break;\n }}\n };\n\n _updateSetValue = (data) =>{\n let index = data.path.split(\".\")[1];\n let item = this.state.items[index];\n let split;\n if (item.split(\":\")[0] == \"data.Time\" && data.value.includes(\":\")) {\n split = item.split(\":\", 3);\n split.pop()\n }\n else {\n split = item.split(\":\");\n }\n switch (data.prop) {\n case \"field\":\n split[0] = data.value;\n break;\n case \"operator\":\n split[1] = data.value;\n break;\n case \"value\":\n split[2] = data.value;\n break;\n default:\n break;\n }\n let updatedItem = split.join(\":\");\n let x = this.state.items\n x[index] = updatedItem;\n this.setState({\n ...this.state,\n items: x\n })\n this.props.onUpdate(this.props.name, this.state.items);\n }\n\n _updateCondition = (data) =>{\n let x = this.state.items;\n x[0] = data.value;\n this.setState({\n ...this.state,\n items: x\n })\n this.props.onUpdate(this.props.name, this.state.items);\n }\n\n _addSet = () => {\n let x = this.state.items\n x.push(\":EQ:\");\n this.setState({\n ...this.state,\n items: x\n })\n this.props.onUpdate(this.props.name, this.state.items);\n }\n\n _removeSet = (data) => {\n let index = data.path.split(\".\")[1];\n\n let x = this.state.items;\n x.splice(index, 1);\n this.setState({\n ...this.state,\n items: x\n })\n this.props.onUpdate(this.props.name, this.state.items);\n }\n\n\n render() {\n\n let form_id = this.props.definition.form_id.value;\n if (form_id && form_id != this.state.form_id) {\n let joins = [\n \"version:version_id:uuid\"\n ];\n ewars.tx(\"com.ewars.resource\", [\"form\", form_id, null, joins])\n .then(res => {\n let form = res.version;\n this.setState({\n ...this.state,\n form_id: form_id,\n definition: form.definition\n })\n })\n .catch(err => {\n console.log(err);\n ewars.error(__(\"ERR_LOADING_FORM\"));\n })\n\n }\n return (\n
    \n
    \n \n
    \n
    \n\n\n
    \n )\n }\n}\n\nexport default FormFieldCondition;\n","// Dependent upno the current form . The dynamic form configuration (json object) must be having the form_id as property\nclass FormFieldSelect extends React.Component {\n static defaultProps = {\n required_type: null\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n form_id: null,\n fields: []\n };\n }\n\n _onChange = (e) => {\n let value = this.props.value || null;\n if (e.target.name == \"field\") value = e.target.value;\n this.props.onUpdate(this.props.name, value);\n };\n\n render() {\n let form_id_field_name = this.props.options[\"form_id_field_name\"];\n let form_id = null;\n if(form_id_field_name){\n form_id = this.props.definition[form_id_field_name].value;\n }else{\n let conditional_field_name=this.props.options[\"conditional_field_name\"];\n let conditional_field_value=this.props.definition[conditional_field_name].value;\n let mutiple_form_ids = this.props.options[\"mutiple_form_ids\"];\n Object.keys(mutiple_form_ids).forEach( (key) => {\n if(conditional_field_value == key){\n form_id = this.props.definition[mutiple_form_ids[key]].value;\n return;\n }\n })\n }\n \n if (form_id && form_id != this.state.form_id) {\n let joins = [\n \"version:version_id:uuid\"\n ];\n ewars.tx(\"com.ewars.resource\", [\"form\", form_id, null, joins])\n .then(res => {\n let form = res.version;\n let fields = [];\n let definition = form.definition\n let numericOnly = true\n if(this.props.hasOwnProperty(\"options\")){\n numericOnly = this.props.options[\"numericOnly\"]\n }\n for (let key in definition) {\n if(definition[key].type == \"matrix\"){\n let rows = definition[key].fields;\n for (let row in rows){\n let columns = rows[row].fields;\n for(let column in columns){\n if(columns[column].type != 'number' && numericOnly){\n continue\n }\n\n let label = __(form.definition[key].label)+\":\"+__(rows[row].label) +\":\"+ __(columns[column].label);\n let subkey = key+\".\"+row+\".\"+column \n fields.push([subkey, label, columns[column].type]);\n }\n }\n }else{\n if(form.definition[key].type != 'number' && numericOnly){\n continue\n }\n fields.push([key, __(form.definition[key].label), form.definition[key].type]);\n }\n }\n this.setState({\n form_id: form_id,\n fields: fields\n })\n })\n .catch(err => {\n console.log(err);\n ewars.error(__(\"ERR_LOADING_FORM\"));\n })\n\n }\n return (\n
    \n
    \n
    \n
    \n \n \n {this.state.fields.map((item, index) => {\n return \n })}\n \n
    \n
    \n
    \n )\n }\n}\n\nexport default FormFieldSelect;\n","import Button from \"../c.button\";\n\nvar GeometryField = React.createClass({\n getInitialState: function () {\n return {}\n },\n\n _editMode: function () {\n ewars.prompt(\"fa-cogs\", \"Feature Unavailable\", \"This feature is under active development and will be available soon\", function () {});\n },\n\n render: function () {\n return (\n
    \n \n
    \n )\n }\n});\n\nexport default GeometryField;\n","var HeaderField = React.createClass({\n getInitialState: function () {\n return {}\n },\n\n render: function () {\n var className = \"form-header\";\n var label = __(this.props.config.label);\n label = label.replace(/\\\\n/g, '\\n');\n if (this.props.config.header_style) {\n className += \" \" + this.props.config.header_style;\n } else {\n className += \" style-title\";\n }\n\n return (\n
    \n {this.props.config.icon ?\n
    \n
    {label}
    \n
    \n :\n
    {label}
    \n }\n
    \n )\n }\n});\n\nexport default HeaderField;\n","import CodeMirror from \"codemirror\";\n\nconst ACTIONS = [\n {icon: \"fa-save\", action: \"SAVE\", label: __(\"SAVE_CHANGESs\")},\n {icon: \"fa-times\", action: \"CLOSE\", label: __(\"CANCEL\")}\n];\n\nclass Editor extends React.Component {\n constructor(props) {\n super(props)\n }\n\n componentDidMount() {\n let height = this._el.getBoundingClientRect().height;\n this._editor = CodeMirror(this._el, {\n value: this.props.value,\n lineNumbers: true,\n mode: \"html\"\n })\n this._editor.setSize(\"100%\", height);\n }\n\n getValue = () => {\n return this._editor.getValue();\n };\n\n render() {\n return (\n {\n this._el = el\n }}\n style={{height: \"100%\", width: \"100%\"}}>\n\n\n
    \n )\n }\n}\n\n\nclass HTMLField extends React.Component {\n static defaultProps = {\n value: \"\"\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n edit: false,\n html: \"\"\n }\n }\n\n\n componentDidMount() {\n console.log(this._el);\n this._editor = CodeMirror(this._el, {\n lineNumbers: true,\n mode: \"html\"\n })\n };\n\n _edit = () => {\n this.setState({\n edit: true,\n html: this.props.value || \"\"\n })\n };\n\n _action = (action) => {\n if (action == \"CLOSE\") {\n this.setState({\n edit: false,\n html: \"\"\n })\n }\n\n if (action == \"SAVE\") {\n let value = this._editor.getValue();\n this.props.onChange(this.props.name, value);\n this.setState({\n edit: false,\n html: \"\"\n })\n }\n };\n\n _onChange = (value) => {\n this.setState({html: value});\n };\n\n render() {\n return (\n {\n this._editor = el\n }}\n value={this.state.html}\n onChange={this._onChange}/>\n )\n }\n}\n\nexport default HTMLField;\n","import Button from \"../c.button\";\nimport Spinner from \"../c.spinner\";\nimport SelectField from \"./f.select\";\nimport TextField from \"./f.text\";\nimport CONSTANTS from \"../constants\";\nimport TreeNode from \"./indicator/c.indicator.node\";\n\nimport IndicatorTreeComponents from \"./indicator/c.indicator.tree\";\n\nimport {\n USERS,\n OLD_ALERTS,\n ALERTS,\n ASSIGNMENTS,\n DEVICES,\n FORM_SUBMISSIONS,\n LOCATIONS,\n TASKS,\n FORMS\n} from \"../forms/indicators/index\";\n\nconst UUID_REG = /^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}/g;\n\n//import Form from \"../c.form\";\n\nconst SYSTEM_INDS = {\n USERS: USERS,\n ALERTS: ALERTS,\n OLD_ALERTS: OLD_ALERTS,\n ASSIGNMENTS: ASSIGNMENTS,\n DEVICES: DEVICES,\n FORM_SUBMISSIONS: FORM_SUBMISSIONS,\n LOCATIONS: LOCATIONS,\n TASKS: TASKS,\n FORMS: FORMS\n};\n\nvar SYSTEM_TYPES = {\n ALARM: null,\n FORM: null,\n ORGANIZATION: null,\n ALERT: null,\n TASK: null\n};\n\nconst resourceId = {\n \"form\": \"id\",\n alarm: \"uuid\",\n organization: \"uuid\"\n};\n\nconst LABELS = {\n form: __(\"FORMS\"),\n organization: __(\"ORGANIZATIONS\"),\n metric: __(\"METRIC\"),\n submitted_type: __(\"SUBMITTED_TYPE\"),\n form_id: __(\"FORM\"),\n organization_id: __(\"ORGANIZATION\"),\n source: __(\"SOURCE\")\n};\n\nconst queryDef = {\n form: {\n optionsSource: {\n resource: \"form\",\n valSource: \"id\",\n labelSource: \"name\",\n query: {\n status: {eq: \"ACTIVE\"}\n },\n orderby: {\"name.en\": \"ASC\"}\n }\n },\n alarm: {\n optionsSource: {\n resource: \"alarm\",\n valSource: \"uuid\",\n labelSource: \"name\",\n query: {},\n orderby: {\"name.en\": \"ASC\"}\n }\n },\n organization: {\n optionsSource: {\n resource: \"organization\",\n valSource: \"uuid\",\n labelSource: \"name\",\n query: {},\n orderby: {\"name.en\": \"ASC\"}\n }\n }\n\n};\n\nconst itemStyle = {\n marginTop: 8\n};\n\nvar ALARM_CONFIG = {\n optionsSource: {\n resource: \"alarm\",\n valSource: \"uuid\",\n labelSource: \"name\",\n query: (function () {\n var q = {\n status: {eq: true}\n };\n\n if (window.user) {\n if ([CONSTANTS.SUPER_ADMIN, CONSTANTS.GLOBAL_ADMIN, CONSTANTS.INSTANCE_ADMIN].indexOf(window.user.role) < 0) {\n q.account_id = window.user.account_id;\n }\n }\n\n return q;\n })()\n }\n};\n\nconst COMPARATORS = [\n [\"EQ\", \"Equal to\"],\n [\"NEQ\", \"Not equal to\"]\n];\n\nclass FilterControl extends React.Component {\n constructor(props) {\n super(props)\n }\n\n _onChange = (prop, value) => {\n let settings = ewars.copy(this.props.settings);\n if (value) {\n settings[prop] = value;\n } else {\n if (settings[prop]) delete settings[prop];\n }\n this.props.onChange(settings);\n };\n\n render() {\n let label = LABELS[this.props.data[0]];\n let valOpts = {};\n\n if (this.props.data[1]) {\n if (this.props.data[1].resource) {\n valOpts = queryDef[this.props.data[1].resource]\n } else {\n let options = this.props.data[1].map(item => {\n return [item, _l(item)]\n });\n valOpts.options = options;\n }\n }\n\n let value = this.props.settings[this.props.data[0]] || null;\n\n return (\n
    \n
    \n
    {label}
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n )\n }\n}\n\nclass IndicatorControl extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = {\n items: []\n }\n }\n\n _filterChange = (data, prop, value) => {\n let settings = ewars.copy(this.props.data);\n if (!typeof settings === 'object') {\n settings = {};\n }\n settings[prop] = value;\n this.props.onChange(settings);\n };\n\n render() {\n\n let FORM_DEF = SYSTEM_INDS[this.props.itype];\n\n if (!FORM_DEF) {\n return
    \n
    {__(\"LOADING\")}
    \n
    \n }\n\n let IndForm = this.props.Form || _ewarsForm;\n\n return (\n \n )\n }\n}\n\nvar Handle = React.createClass({\n render: function () {\n var name = __(\"NO_SELECTION\");\n\n if (this.props.value) {\n name = ewars.I18N(this.props.value.name);\n }\n return (\n
    \n \n \n \n \n \n \n \n
    {name}\n \n
    \n
    \n )\n }\n});\n\nclass IndicatorNode extends React.Component {\n _isLoaded = false;\n\n constructor(props) {\n super(props);\n\n this.state = {\n data: [],\n show: false\n }\n }\n\n _onClick = () => {\n if (!this._isLoaded && this.props.data.context == \"FOLDER\") {\n ewars.tx(\"com.ewars.indicators\", [this.props.data.id])\n .then(function (resp) {\n if(this.props.hide_extra_system_indicators){\n let indicators = [];\n indicators = resp.filter(function(indicator){\n if((indicator.hasOwnProperty(\"context\") && indicator.context == \"FOLDER\") || indicator.itype == 'DEFAULT' || indicator.itype == 'ALERTS' || indicator.itype == 'FORM_SUBMISSIONS' ||indicator.itype == 'FORMS' ) { return true;}\n else { return false;\n }\n });\n resp = indicators;\n \n }\n this._isLoaded = true;\n this.setState({\n data: resp,\n show: !this.state.show\n })\n }.bind(this));\n return;\n }\n\n this.setState({\n show: !this.state.show\n })\n };\n\n render() {\n var className = \"item locale-select\";\n if (this.props.value == this.props.data.uuid) className += \" active\";\n\n var name = ewars.I18N(this.props.data.name);\n\n var children;\n if (this.state.show && this._isLoaded) {\n children = this.state.data.map(function (item) {\n return \n }.bind(this))\n } else {\n children = ;\n }\n\n let iconClass;\n if (this.props.data.context == \"FOLDER\") iconClass = \"fal fa-folder\";\n if (this.props.data.context == \"FOLDER\" && this.state.show) iconClass = \"fal fa-folder-open\";\n\n var handleClass = \"locale-tree-node\";\n\n var showSelect = false;\n if (this.props.data.context == \"INDICATOR\") showSelect = true;\n if (showSelect) handleClass += \" has-button\";\n\n let handler = this._onClick;\n if (this.props.data.context == \"INDICATOR\") handler = () => {\n this.props.onSelect(this.props.data)\n };\n\n return (\n
    \n
    \n {iconClass ?\n
    \n : null}\n
    {name}
    \n
    \n {this.state.show ?\n
    \n {children}\n
    \n : null}\n
    \n )\n }\n}\n\n\nfunction debounce(fn, delay) {\n var timer = null;\n return function () {\n var context = this, args = arguments;\n clearTimeout(timer);\n timer = setTimeout(function () {\n fn.apply(context, args);\n }, delay);\n };\n}\n\nclass SearchInput extends React.Component {\n static defaultProps = {\n value: ''\n };\n\n constructor(props) {\n super(props);\n\n this.sendForSearch = debounce(this.sendForSearch, 250);\n }\n\n componentDidMount() {\n this._el.focus();\n }\n\n sendForUpdate = (e) => {\n this.props.onChange(e.target.value);\n\n if (e.target.value.length > 2) {\n this.sendForSearch(e.target.value);\n }\n\n if (e.target.value == \"\") this.sendForSearch(null);\n };\n\n sendForSearch = (searchTerm) => {\n this.props.onSearch(searchTerm);\n };\n\n render() {\n return (\n {this._el = el;}}\n onChange={this.sendForUpdate}\n value={this.props.value}/>\n )\n }\n}\n\nclass IndicatorField extends React.Component {\n static defaultProps = {\n formConfig:{},\n config: {\n showSystem: true\n },\n name: null,\n showSystem: true\n };\n\n _isLoaded: false;\n\n constructor(props) {\n super(props);\n\n this.state = {\n showTree: false,\n data: [],\n search: \"\",\n nodeName: __(\"SELECT_INDICATOR\"),\n nodeUUID: null,\n multiple: false,\n indicator: null\n }\n }\n\n _clearSearch = () => {\n ewars.tx(\"com.ewars.indicators\", [null])\n .then(function (resp) {\n this._isLoaded = true;\n this.setState({\n search: \"\",\n data: resp\n })\n }.bind(this));\n };\n\n _onSearchChange = (val) => {\n this.setState({\n search: val\n })\n };\n\n _onSearch = (term) => {\n if (term == null || term == '') {\n ewars.tx(\"com.ewars.indicators\", [null])\n .then((resp) => {\n this._isLoaded = true;\n this.setState({\n data: resp,\n search: ''\n })\n });\n } else {\n\n let filter = {\n \"name.en\": {LIKE: term}\n };\n if (!this.props.showSystem) filter.itype = {eq: \"DEFAULT\"};\n ewars.tx(\"com.ewars.query\", [\"indicator_search\", [\"uuid\", \"name\", \"itype\", \"definition\", \"status\"], filter, null, null, null, null])\n .then(resp => {\n this.setState({\n data: resp.map(item => {\n return {\n ...item,\n context: \"INDICATOR\"\n }\n })\n })\n })\n }\n };\n\n _toggle = () => {\n if (!this._isLoaded) {\n ewars.tx(\"com.ewars.indicators\", [null])\n .then(function (resp) {\n this._isLoaded = true;\n this.setState({\n data: resp,\n showTree: !this.state.showTree\n })\n }.bind(this));\n return;\n }\n\n this.setState({\n showTree: !this.state.showTree\n })\n };\n\n componentWillMount() {\n if (this.props.value) {\n if (typeof this.props.value === 'object' && this.props.value.uuid) {\n this._init(this.props.value.uuid);\n } else {\n this._init(this.props.value);\n }\n }\n }\n\n componentWillReceiveProps(nextProps) {\n if (this.state.node) {\n if (typeof nextProps.value === 'object') {\n // This is a dict based indicator\n if (nextProps.value.uuid != this.state.node.uuid) this._init(nextProps.value.uuid);\n } else {\n if (this.state.node.uuid != nextProps.value) this._init(nextProps.value);\n }\n } else {\n if (typeof nextProps.value === 'object') {\n this._init(nextProps.value.uuid);\n } else {\n this._init(nextProps.value);\n }\n }\n }\n\n _init = (value) => {\n if (value && value.context) {\n // This is a legacy indicator\n this.setState({\n nodeName: null,\n nodeUUID: null,\n node: null\n });\n return;\n }\n if (value && typeof value !== 'object') {\n if(!value.includes(\"NEW\")){\n ewars.tx(\"com.ewars.resource\", [\"indicator\", value, null, null])\n .then((resp) => {\n this.setState({\n nodeName: ewars.I18N(resp.name),\n nodeUUID: resp.uuid,\n node: resp\n })\n })\n }\n } else if (value && typeof value === 'object') {\n if (value.itype == \"CUSTOM\") {\n this.state.nodeName = value.name;\n this.state.nodeUUID = null;\n this.state.node = value;\n } else {\n ewars.tx(\"com.ewars.resource\", [\"indicator\", value.uuid, null, null])\n .then(function (resp) {\n if (resp != null) {\n this.state.nodeName = ewars.I18N(resp.name);\n this.state.nodeUUID = resp.uuid;\n this.state.node = resp\n }\n }.bind(this))\n }\n }\n };\n\n _onNodeSelection = (node) => {\n if (node.context != \"INDICATOR\") return;\n\n this.setState({\n nodeName: ewars.formatters.I18N_FORMATTER(node.name),\n nodeUUID: node.uuid || null,\n node: node,\n showTree: false\n });\n\n let name = this.props.config.nameOverride || this.props.name;\n\n var path = this.props.config ? this.props.config.path : null;\n if (node.itype == \"DEFAULT\") {\n this.props.onUpdate(name, node.uuid, path, node);\n } else {\n this.props.onUpdate(name, {uuid: node.uuid}, path, node);\n }\n };\n\n _systemIndUpdate = (data) => {\n let name = this.props.config.nameOverride || this.props.name;\n let noedeName = null;\n if(this.state.nodeName){\n noedeName = this.state.nodeName.toUpperCase();\n }\n this.props.onUpdate(name, data, this.props.config ? this.props.config.path : null, {itype: \"SYSTEM\",nodeName : noedeName});\n };\n\n removeSystemIndicator = (indicators) => {\n let systemIndicatorId = 1\n let new_indicators = [];\n if(this.props.formConfig.hide_system_indicator || this.props.config.hide_system_indicator){\n if(indicators && indicators.length > 0 && !indicators[0].hasOwnProperty('itype')) {\n new_indicators =[]\n new_indicators = indicators.filter(function(indicator){\n if(indicator.name.en == 'System' && indicator.context == 'FOLDER') { return false;}\n else { return true; }\n });\n }\n\n if(indicators && indicators.length > 0 && indicators[0].hasOwnProperty('itype')) {\n new_indicators = []\n new_indicators = indicators.filter(function(indicator){\n if(indicator.itype == 'DEFAULT' || indicator.itype == 'STATIC' ) { return true;}\n else { return false;\n }\n });\n }\n return new_indicators;\n }else{\n return indicators\n }\n }\n\n render() {\n var nodeName = __(\"SELECT_INDICATOR\");\n if (this.state.node) {\n nodeName = ewars.formatters.I18N_FORMATTER(this.state.node.name);\n if (this.state.node.itype == \"CUSTOM\") nodeName += \" [legacy]\";\n }\n\n var isConfigurable = false;\n if (this.state.node) {\n if ([\"STATIC\", \"DEFAULT\"].indexOf(this.state.node.itype) < 0) {\n isConfigurable = true\n }\n }\n\n let rootNodes;\n let newData = this.removeSystemIndicator(this.state.data);\n if (this._isLoaded && this.state.showTree) {\n rootNodes = newData.map(function (item) {\n return \n }.bind(this))\n }\n\n return (\n
    \n
    \n \n {this.state.showTree ?\n
    \n
    \n
    \n \n {this.state.search.length > 0 ?\n
    \n : null}\n
    \n
    \n {rootNodes}\n
    \n : null}\n\n\n
    \n {isConfigurable ?\n
    \n \n
    \n : null}\n
    \n )\n }\n}\n\nexport default IndicatorField;\n","import Button from \"../c.button\";\nimport TextField from \"./f.text\";\nimport SelectField from \"./f.select\";\n\nconst REDUCTION = {\n options: [\n [\"SUM\", \"Sum\"],\n [\"MEDIAN\", \"Median\"]\n ]\n};\n\nclass CompoundManager extends React.Component {\n constructor(props) {\n super(props);\n }\n\n _onUpdate = (prop, value) => {\n this.props.onUpdate(prop, value);\n };\n\n render() {\n return (\n
    \n
    \n
    Formula
    \n
    \n \n
    \n
    \n
    \n
    Indicators
    \n
    \n \n
    \n
    \n
    \n )\n\n }\n}\n\n\nclass IndicatorItem extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = {\n indicator: {}\n }\n\n }\n\n componentWillMount() {\n ewars.tx(\"com.ewars.resource\", [\"indicator\", this.props.data, [\"uuid\", \"name\", \"definition\", \"itype\", \"icode\"], null])\n .then(function (resp) {\n this.setState({\n indicator: resp\n })\n }.bind(this))\n }\n\n _remove = () => {\n this.props.onRemove(this.props.index);\n };\n\n render() {\n let indName = this.state.indicator.icode || \"\" + \" \" + ewars.I18N(this.state.indicator.name || \"Loading\");\n\n return (\n
    \n
    \n
    \n
    \n
    {indName}
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n )\n }\n}\n\n\nclass IndicatorList extends React.Component {\n constructor(props) {\n super(props);\n }\n\n _onDragEnter = (e) => {\n e.preventDefault();\n };\n\n _onDragLeave = (e) => {\n };\n\n _onDropped = (e) => {\n e.preventDefault();\n e.stopPropagation();\n\n let data = JSON.parse(e.dataTransfer.getData(\"item\"));\n\n let definition = ewars.copy(this.props.data.definition);\n definition.series.push(data.uuid);\n\n this.props.onUpdate(\"series\", definition.series);\n };\n\n _remove = (index) => {\n let definition = ewars.copy(this.props.data.definition);\n definition.series.splice(index, 1);\n this.props.onUpdate(\"series\", definition.series);\n };\n\n render() {\n let view;\n if (this.props.data.definition.series.length <= 0) {\n view =
    Drag 'n' Drop indicators here
    ;\n } else {\n view = this.props.data.definition.series.map(function (item, index) {\n return ;\n }.bind(this))\n }\n\n return (\n
    \n
    \n {view}\n
    \n
    \n )\n }\n}\n\nclass AggregateManager extends React.Component {\n constructor(props) {\n super(props);\n }\n\n _onUpdate = (prop, value) => {\n this.props.onUpdate(prop, value);\n };\n\n render() {\n return (\n
    \n
    \n
    Aggregation Type
    \n
    \n \n
    \n
    \n
    \n
    Indicators
    \n
    \n \n
    \n
    \n
    \n )\n }\n}\n\n\nvar IndicatorDefinition = React.createClass({\n getInitialState: function () {\n return {\n definition: {}\n }\n },\n\n _updateDefinition: function (prop, value) {\n let data = ewars.copy(this.props.value.definition);\n data[prop] = value;\n\n\n this.props.onUpdate(\"definition\", data);\n },\n\n render: function () {\n\n let edit;\n if (this.props.value) {\n if (this.props.value.itype == \"COMPOUND\") edit =\n ;\n if (this.props.value.itype == \"AGGREGATE\") edit =\n ;\n }\n\n return
    ;\n }\n});\n\nexport default IndicatorDefinition;\n\n","// Dependent upno the selected indicators .\nclass IndicatorRelatedForms extends React.Component {\n static defaultProps = {\n required_type: null\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n forms: []\n };\n }\n componentWillMount() {\n let indicators = [];\n let form_ids = [];\n this.state.forms = [];\n this.forceUpdate();\n let key = this.props.options['source_indicator_path'];\n if(this.props.value.length > 0){\n this.state.forms= this.props.value;\n this.forceUpdate();\n }\n (this.props.data[key] || []).forEach(element => {\n if(element.hasOwnProperty(\"series\") && element.series && element.series.length>0 ){\n element.series.forEach(el => {\n indicators.push(el.indicator)\n })\n }else{\n let indicator = element.indicator;\n if (typeof indicator == 'string') {\n indicators.push(element.indicator)\n } else {\n if (indicator && indicator.hasOwnProperty(\"form_id\")) {\n let form_id = indicator[\"form_id\"];\n form_ids.push(form_id);\n }\n }\n }\n \n });\n if(form_ids.length > 0){\n ewars.tx(\"com.ewars.forms.names\", [form_ids])\n .then(res => {\n let forms = this.state.forms;\n this.state.forms= [...forms,...res];\n this.forceUpdate();\n })\n .catch(err => {\n console.log(err);\n ewars.error(__(\"ERR_LOADING_FORM\"));\n })\n }\n if (indicators.length > 0) {\n ewars.tx(\"com.ewars.forms.indicaotrs\", [indicators,false])\n .then(res => {\n let forms = this.state.forms;\n forms =[...forms,...res];\n this.state.forms= forms;\n this.forceUpdate();\n \n })\n .catch(err => {\n console.log(err);\n ewars.error(__(\"ERR_LOADING_FORM\"));\n })\n }\n \n }\n\n _onChange = (e) => {\n let value = this.props.value || null;\n if (e.target.name == \"field\") value = e.target.value;\n this.props.onUpdate(this.props.name, value);\n };\n\n render() {\n return ( \n
    \n {this.state.forms.map((item) => {\n return
    {ewars.I18N(item[\"name\"])}
    \n })}\n
    \n )\n\n }\n}\n\nexport default IndicatorRelatedForms;\n","var _languages = [\"en\", \"fr\", \"ar\"];\n\nvar LanguageNode = React.createClass({\n render: function () {\n var className = \"language\";\n if (this.props.active) className += \" active\";\n\n return (\n
    {this.props.value}
    \n )\n }\n});\n\nvar LanguageStringField = React.createClass({\n _defaultLang: \"en\",\n\n getInitialState: function () {\n return {\n curLang: (window.user && window.user.language)?window.user.language:\"en\",\n showTree: false\n };\n },\n\n componentWillMount: async function () {\n // A little clean up, fix labels which are not dicts to dicts\n this.state.value = this.props.value;\n if (!this.props.value) {\n this.state.value = {en: \"\"}\n }\n\n if (typeof this.props.value == \"string\") {\n this.state.value = {en: this.props.value};\n }\n let languages = [];\n if (window.localStorage.language_array) {\n languages = JSON.parse(window.localStorage.language_array);\n } else {\n let resp = await ewars.tx(\"com.ewars.language.getLanguage\",[{\"filters\":{status:{booleaneq:true}}}]);\n if (resp.results) {\n languages = resp.results;\n window.localStorage.language_array=JSON.stringify(resp.results);\n }\n }\n _languages = []\n for (let data of languages) {\n let array = []; array.push(data['code']);\n let alraedyExsits = false;\n _languages.map(function (value, index) {\n if (value[0] === data['code']) {\n alraedyExsits = true\n }\n });\n if (!alraedyExsits && data[\"isActive\"]) {\n _languages.push(array)\n }\n }\n },\n\n componentWillReceiveProps: function (nextProps) {\n this.state.value = nextProps.value;\n if (!nextProps.value) {\n this.state.value = {en: \"\"}\n }\n\n if (typeof nextProps.value == \"string\") {\n this.state.value = {en: nextProps.value}\n }\n },\n\n onChange: function (e) {\n var copy = this.state.value;\n copy[this.state.curLang] = e.target.value;\n this.props.onUpdate(this.props.name, copy,this.state.curLang);\n },\n\n _handleLanguageChange: function (e) {\n e.preventDefault();\n e.stopPropagation();\n var language = e.target.dataset.lang;\n const value = this.state.value.hasOwnProperty(language) ? this.state.value : { ...this.state.value, [language]: \"\" }\n this.setState({\n showTree: false,\n curLang: language,\n value\n })\n },\n\n _hideTree: function () {\n this.setState({\n showTree: false\n })\n },\n\n _toggleTree: function (e) {\n this.setState({\n showTree: this.state.showTree == true ? false : true\n });\n\n },\n\n render: function () {\n var curValue = this.state.value[this.state.curLang];\n\n var languages = _languages.map(function (language) {\n var active = false;\n if (this.state.curLang == language) active = true;\n return (\n \n )\n }.bind(this));\n\n var nodes = [];\n for (var i in _languages) {\n var language = _languages[i];\n nodes.push(\n
  • \n
    {language}
    \n
  • \n )\n }\n\n var disabled = false;\n if (this.props.readOnly) disabled = true;\n\n return (\n
    \n
    \n
    \n \n
    \n
    \n
    \n {languages}\n
    \n \n
    \n
    \n\n {this.state.showTree ?\n
    \n
    \n

    {__(\"AVAILABLE_LANGUAGES\")}

    \n
      \n {nodes}\n
    \n\n
    \n
    \n : null}\n\n
    \n )\n }\n});\n\nexport default LanguageStringField;\n","import Modal from \"../c.modal\";\nimport mapboxgl from \"mapbox-gl\";\n\nimport Button from \"../c.button\";\nimport Shade from \"../c.shade\";\n\nconst MODAL_ACTIONS = [\n {icon: 'fa-times', action: 'CLOSE', label: __(\"CLOSE\")}\n]\n\nconst WARN_STYLE = {\n position: 'absolute',\n top: '10px',\n right: '10px',\n height: '20px',\n background: '#F2F2F2',\n color: '#333333',\n padding: '5px',\n zIndex: 1\n};\n\nclass LatLng extends React.Component {\n static defaultProps = {\n parent_id: null\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n isMapEnabled: false,\n parentGeom: null\n }\n\n this._map = null;\n this._layer = null;\n this._source = {\n type: 'geojson',\n data: {\n type: 'FeatureCollection',\n features: []\n }\n };\n\n this._sourceRaw = {\n type: 'geojson',\n data: {\n type: 'FeatureCollection',\n features: []\n }\n }\n\n this._sourceParentGeom = {\n type: 'geojson',\n data: {\n type: 'FeatureCollection',\n features: []\n }\n }\n }\n\n /**\n * Get the users current location from the browser\n * @private\n */\n _getLocation = () => {\n ewars.prompt(\"fa-globe\", __(\"LOCATION_DETECTION\"), __(\"LOCATION_DETECTION_QUESTION\"), function () {\n navigator.geolocation.getCurrentPosition(\n function (position) {\n this._setValue(position.coords.latitude, position.coords.longitude);\n }.bind(this),\n function (error) {\n if (error.code == error.PERMISSION_DENIED) {\n ewars.growl(__(\"ENABLE_LOCATION_MESSEGE\"));\n }\n }.bind(this));\n }.bind(this))\n };\n\n _setValue = (lat, lng) => {\n var value = {\n type: \"Point\",\n coordinates: [lng, lat]\n };\n this.props.onUpdate(this.props.name, JSON.stringify(value));\n };\n\n _showMap = () => {\n if (this.props.parent_id) {\n ewars.tx('com.ewars.location.geometry', [this.props.parent_id])\n .then(res => {\n this.setState({\n isMapEnabled: true\n }, () => {\n if (res.features != null) {\n this._renderMap(res);\n } else {\n this._renderMap();\n }\n })\n })\n } else {\n this.setState({\n isMapEnabled: true\n }, () => {\n this._renderMap();\n })\n }\n };\n\n\n /**\n * Render the map\n * @param parentGeom\n * @private\n */\n _renderMap(parentGeom) {\n if (this.state.isMapEnabled) {\n if (!this._map) {\n\n mapboxgl.accessToken = 'pk.eyJ1IjoiamR1cmVuIiwiYSI6IkQ5YXQ2UFUifQ.acHWe_O-ybfg7SN2qrAPHg';\n this._map = new mapboxgl.Map({\n container: this._el,\n minZoom: 0,\n style: 'mapbox://styles/jduren/cj95cps6g154x2rmnu6xphlya',\n maxZoom: 20,\n zoom: 1,\n width: \"100%\",\n height: '100%',\n attributionControl: false,\n doubleClickZoom: false,\n scrollWheelZoom: false\n });\n\n this._map.addControl(new mapboxgl.NavigationControl(), 'top-left');\n\n this._map.on(\"style.load\", () => {\n this._map.addSource(\"markers\", this._sourceRaw);\n\n if (parentGeom) {\n this._map.addSource('parent', this._sourceParentGeom);\n }\n\n this._source = this._map.getSource('markers');\n\n if (this.props.value) {\n let val;\n if (typeof this.props.value == 'string') {\n if (this.props.value.indexOf('{') >= 0) val = JSON.parse(this.props.value);\n } else {\n val = this.props.value || {};\n }\n\n let newData = {\n type: \"FeatureCollection\",\n features: [{\n type: \"Feature\",\n properties: {},\n geometry: val\n }]\n };\n\n this._source.setData(newData);\n\n if (val.coordinates[0] != 0 && val.coordinates[1] != 0) {\n this._map.jumpTo({center: val.coordinates, zoom: 11.15});\n }\n } else {\n this._map.jumpTo({center: [1, 1]});\n this._map.setZoom(1);\n }\n\n if (parentGeom) {\n this._sourceParentGeom = this._map.getSource('parent');\n this._parentLayer = this._map.addLayer({\n id: 'parent',\n type: 'fill',\n source: 'parent',\n paint: {\n 'fill-color': '#000000',\n 'fill-opacity': 0.4\n },\n 'filter': ['==', '$type', 'Polygon']\n })\n\n this._sourceParentGeom.setData(parentGeom);\n }\n\n this._layer = this._map.addLayer({\n id: \"markers\",\n interactive: true,\n type: \"symbol\",\n source: \"markers\",\n layout: {\n \"icon-image\": \"circle-15\"\n }\n })\n\n this._layer = this._map.on(\"dblclick\", (e) => {\n var newData = {\n type: \"FeatureCollection\",\n features: [{\n type: \"Feature\",\n geometry: {\n type: \"Point\",\n coordinates: [\n e.lngLat.lng,\n e.lngLat.lat\n ]\n }\n }]\n };\n this._source.setData(newData);\n\n this._setValue(e.lngLat.lat, e.lngLat.lng);\n })\n\n\n });\n\n\n } else {\n // map exists, we may need to update parent geometry\n console.log(this.state.parentGeom);\n }\n }\n };\n\n componentWillReceiveProps(nextProps) {\n if (this.state.isMapEnabled) {\n\n if (this._map) {\n var newData = {\n type: \"FeatureCollection\",\n features: [{\n type: \"Feature\",\n geometry: nextProps.value\n }]\n };\n this._source.setData(newData);\n\n }\n }\n };\n\n _setPos = (e) => {\n var val;\n if (this.props.value) {\n val = this.props.value;\n if (typeof (val) == \"string\") {\n val = JSON.parse(val);\n }\n } else {\n val = {\n type: \"Point\",\n coordinates: [0, 0]\n }\n }\n if (e.target.name == \"lat\") val.coordinates[1] = parseFloat(e.target.value);\n if (e.target.name == 'lng') val.coordinates[0] = parseFloat(e.target.value);\n this.props.onUpdate(this.props.name, JSON.stringify(val));\n };\n\n _closeModal = () => {\n this.state.isMapEnabled = false;\n this.forceUpdate();\n };\n\n _onAction = (action) => {\n if (action == 'CLOSE') {\n this._map = null;\n this._layer = null;\n this._source = {\n type: 'geojson',\n data: {\n type: 'FeatureCollection',\n features: []\n }\n };\n this._sourceRaw = {\n type: 'geojson',\n data: {\n type: 'FeatureCollection',\n features: []\n }\n }\n\n this._sourceParentGeom = {\n type: 'geojson',\n data: {\n type: 'FeatureCollection',\n features: []\n }\n\n }\n this.setState({\n isMapEnabled: false\n })\n }\n };\n\n render = () => {\n var lat = null, lng = null;\n\n if (this.props.value) {\n if (Array.isArray(this.props.value)) {\n lat = this.props.value[0]\n lng = this.props.value[1]\n } else {\n var val = JSON.parse(this.props.value);\n if (val && val.hasOwnProperty('coordinates') && val.coordinates) {\n lat = val.coordinates[1];\n lng = val.coordinates[0];\n }\n }\n }\n\n var hasGeoLocate = true;\n if (!navigator.geolocation) hasGeoLocate = false;\n\n var modalButtons = [\n {label: \"Close\", onClick: this._closeModal}\n ];\n\n\n return (\n
    \n \n \n \n \n \n \n {!this.props.readOnly ?\n \n \n \n : null}\n \n
    \n \n \n \n
    \n {hasGeoLocate ?\n \n : null}\n \n
    \n \n
    {__(\"PLACE_MARKER_MAP\")}
    \n {\n this._el = el\n }}>\n
    \n \n\n \n )\n }\n\n}\n\n\nexport default LatLng;\n","const STYLE = {\n item: {\n padding: 8,\n border: \"1px solid #CCCCCC\",\n marginBottom: 5,\n cursor: \"pointer\"\n },\n active: {\n background: \"#CCCCCC\",\n color: \"#FFFFFF\"\n },\n cell: {\n padding: 8\n },\n itemRaw: {\n border: \"1px solid #CCCCCC\",\n marginBottom: 5\n }\n\n};\n\nclass ListItem extends React.Component {\n static defaultProps = {\n active: false,\n index: null,\n name: null\n };\n\n _click = () => {\n this.props.click(this.props.index);\n };\n\n render() {\n let style = STYLE.item;\n if (this.props.active) style = {...style, ...STYLE.active};\n return (\n
    {ewars.I18N(this.props.name)}
    \n )\n }\n\n}\n\nclass OrderableListItem extends React.Component {\n static defaultProps = {\n active: false,\n index: null,\n name: null\n };\n\n _remove = () => {\n console.log(\"HERE\");\n this.props.remove(this.props.index);\n };\n\n _moveUp = () => {\n this.props.moveUp(this.props.index);\n };\n\n _moveDown = () => {\n this.props.moveDown(this.props.index);\n };\n\n render() {\n return (\n
    \n \n \n {ewars.I18N(this.props.name)}\n \n {this.props.index > 0 ?\n \n \n \n : null}\n \n \n \n \n \n \n \n
    \n )\n }\n\n}\n\nclass Source extends React.Component {\n static defaultProps = {\n correlary: \"id\",\n target: [],\n data: [],\n selected: null\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n selected: null\n }\n }\n\n _select = (index) => {\n this.props.select(index);\n };\n\n render() {\n\n let items = [];\n\n this.props.data.forEach((item, index) => {\n\n let hasItem = false;\n this.props.target.forEach((tgt) => {\n if (tgt[0] == item[this.props.correlary]) {\n hasItem = true;\n }\n });\n\n if (!hasItem) {\n items.push(\n \n )\n }\n });\n\n return (\n \n {this.props.sourceLabel?
    {ewars.formatters.I18N_FORMATTER(this.props.sourceLabel)}
    :null}\n
    \n
    \n {items}\n
    \n
    \n
    \n )\n }\n}\n\nclass Target extends React.Component {\n static defaultProps = {\n correlary: \"id\",\n source: [],\n target: []\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n selected: null,\n sourceSelected: null,\n targetSelected: null\n }\n }\n\n\n render() {\n\n let items = [];\n\n let data = [];\n\n this.props.target.map((item, index) => {\n let sourceI;\n this.props.source.forEach((src) => {\n if (src[this.props.correlary] == item[0]) {\n sourceI = src;\n }\n });\n\n if (sourceI) {\n items.push(\n \n )\n }\n });\n\n return (\n \n {this.props.targetLabel?
    {ewars.formatters.I18N_FORMATTER(this.props.targetLabel)}
    :null}\n
    \n
    \n {items}\n
    \n
    \n
    \n )\n }\n}\n\n\nclass LinkedListsField extends React.Component {\n static defaultProps = {\n source: [],\n target: [],\n correlary: \"id\"\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n sourceSelected: null,\n targetSelected: null\n }\n }\n\n _sourceSelect = (index) => {\n this.setState({\n sourceSelected: index,\n targetSelected: null\n })\n };\n\n _targetSelect = (index) => {\n this.setState({\n sourceSelected: null,\n targetSelected: index\n })\n };\n\n _moveRight = () => {\n let items = ewars.copy(this.props.target || []);\n items.push([this.props.source[this.state.sourceSelected][this.props.correlary], 999]);\n items.sort((a, b) => {\n if (a[1] > b[1]) return 1;\n if (a[1] < b[1]) return -1;\n return 0;\n });\n let cur = 0;\n items.forEach((item) => {\n item[1] = cur;\n cur++;\n });\n\n this.props.onUpdate(this.props.name, items)\n };\n\n _remove = (index) => {\n let items = ewars.copy(this.props.target || []);\n items.splice(index, 1);\n\n let cur = 0;\n items.forEach((item) => {\n item[1] = cur;\n cur++;\n });\n\n this.props.onUpdate(this.props.name, items);\n };\n\n _moveUp = (index) => {\n if (index <= 0) return;\n if (!this.props.target[index - 1]) return;\n\n let items = ewars.copy(this.props.target || []);\n let tmp = items[index - 1];\n items[index - 1] = items[index];\n items[index] = tmp;\n\n let cur = 0;\n items.forEach((item) => {\n item[1] = cur;\n cur++;\n });\n\n this.props.onUpdate(this.props.name, items);\n };\n\n _moveDown = (index) => {\n if (!this.props.target[index + 1]) return;\n\n let items = ewars.copy(this.props.target || []);\n let tmp = this.props.target[index + 1];\n items[index + 1] = items[index];\n items[index] = tmp;\n\n let cur = 0;\n items.forEach((item) => {\n item[1] = cur;\n cur++;\n });\n\n this.props.onUpdate(this.props.name, items);\n };\n\n render() {\n return (\n
    \n \n \n \n \n \n \n \n \n \n
    \n )\n }\n}\n\nexport default LinkedListsField;\n","import {Layout, Row, Cell} from \"../layout\";\nimport Button from \"../c.button\";\nimport Spinner from \"../c.spinner\";\nimport { isRegionalAdminWithLocGroup } from \"../utils/User\";\n\nconst LOCATION_SELECT = [\"uuid\", \"name\", \"parent_id\", \"@children\", \"site_type_id\", \"@lineage\"];\n\nvar _backupLocations = null;\n\nvar LocationTreeNode = React.createClass({\n _isLoaded: false,\n\n getDefaultProps: function () {\n return {\n hideInactive: true,\n lineageRoot: null,\n selectionTypeId: null\n }\n },\n\n getInitialState: function () {\n return {\n showLocations: false\n }\n },\n\n _onSelect: function () {\n this.props.onSelect(this.props.data);\n },\n\n _onClick: function () {\n if (this.props.selectionTypeId && this.props.data.site_type_id == this.props.selectionTypeId) {\n this._onSelect();\n return;\n }else if(isRegionalAdminWithLocGroup()){ // Dont select the value if reg admin with loc group\n return;\n }\n\n if (this.props.data.children <= 0) return;\n\n\n this.state.showLocations = this.state.showLocations ? false : true;\n if (this.isMounted()) this.forceUpdate();\n\n if (!this._isLoaded && this.state.showLocations) {\n var filters = {\n parent_id: {eq: this.props.data.uuid}\n };\n\n if(window.user.role == \"REGIONAL_ADMIN\"){\n if(window.user.location_group){\n filters['data.groups']= { eq: [window.user.location_group], isGroups: true, type: \"LOCGROUPS\" };\n }\n }\n\n if (this.props.hideInactive) filters.status = {eq: \"ACTIVE\"};\n if (!this.props.hideInactive) filters.status = {neq: \"DELETED\"};\n\n ewars.tx(\"com.ewars.query\", [\"location\", LOCATION_SELECT, filters, {\"name.en\": \"ASC\"}, null, null, [\"location_type:site_type_id:id\"]])\n .then(function (resp) {\n this.state.locations = resp;\n this._isLoaded = true;\n if (this.isMounted()) this.forceUpdate();\n }.bind(this))\n }\n },\n\n render: function () {\n var className = \"item locale-select\";\n if (this.props.value == this.props.data.uuid) className += \" active\";\n\n var name = ewars.I18N(this.props.data.name);\n name += \" (\" + ewars.I18N(this.props.data.location_type.name) + \")\";\n\n var children;\n if (this.state.showLocations && this._isLoaded) {\n children = this.state.locations.map(location => {\n return (\n \n )\n });\n } else {\n children = ;\n }\n\n var iconClass = \"fal\";\n if (this.state.showLocations) iconClass += \" fa-caret-down\";\n if (!this.state.showLocations) iconClass += \" fa-caret-right\";\n if (!this._isLoaded && this.state.showLocations) iconClass = \"fal fa-spin fa-cog\";\n\n if (this.props.data.children <= 0) iconClass = \"fal fa-map-marker\";\n if (this.props.selectionTypeId && this.props.data.site_type_id == this.props.selectionTypeId) iconClass = \"fal fa-map-marker\";\n\n // If regional admin with loc group, every location will be individual,\n // So mark every location with same icon\n if(isRegionalAdminWithLocGroup()) iconClass = \"fal fa-map-marker\"\n\n var childStyle = {display: \"none\"};\n if (this.state.showLocations) childStyle.display = \"block\";\n\n var handleClass = \"locale-tree-node\";\n if (this.props.data.site_type_id == this.props.selectionTypeId) handleClass += \" green\";\n\n var showSelect = false;\n if (!this.props.selectionTypeId || this.props.selectionTypeId == this.props.data.site_type_id) showSelect = true;\n if (showSelect) handleClass += \" has-button\";\n if(this.props.locationFilter && this.props.locationFilter==true ){\n showSelect = true;\n }\n let lineage;\n if (this.props.data['@lineage']) {\n lineage = (this.props.data['@lineage'] || []).join(' \\\\ ');\n }\n\n return (\n
    \n
    \n
    \n
    \n {name}\n {lineage ?
    : null}\n {lineage ?\n {lineage}\n : null}\n\n
    \n {showSelect ?\n
    \n \n
    \n : null}\n
    \n
    \n {children}\n
    \n
    \n )\n }\n});\n\nvar Handle = React.createClass({\n render: function () {\n var name = __(\"NO_SELECTION\");\n\n if (this.props.value.uuid) {\n name = ewars.I18N(this.props.value.name);\n name += \" (\" + ewars.I18N(this.props.value.location_type.name) + \")\";\n }\n return (\n
    \n \n \n \n {name}\n \n \n \n \n \n \n
    \n )\n }\n});\n\n\nfunction debounce(fn, delay) {\n var timer = null;\n return function () {\n var context = this, args = arguments;\n clearTimeout(timer);\n timer = setTimeout(function () {\n fn.apply(context, args);\n }, delay);\n };\n}\n\nclass SearchInput extends React.Component {\n static defaultProps = {\n value: ''\n };\n\n constructor(props) {\n super(props);\n\n this.sendForSearch = debounce(this.sendForSearch, 250);\n }\n\n componentDidMount() {\n this._el.focus();\n }\n\n sendForUpdate = (e) => {\n this.props.onChange(e.target.value);\n\n if (e.target.value.length > 2) {\n this.sendForSearch(e.target.value);\n }\n\n if (e.target.value == \"\") this.sendForSearch(null);\n };\n\n sendForSearch = (searchTerm) => {\n this.props.onSearch(searchTerm);\n };\n\n render() {\n return (\n {this._el = el;}}\n onChange={this.sendForUpdate}\n value={this.props.value}/>\n )\n }\n}\n\nvar LocationSelectField = React.createClass({\n _isLoaded: false,\n _initialLoad: false,\n _isSearch: false,\n\n propTypes: {\n _onChange: React.PropTypes.func,\n placeholder: React.PropTypes.string,\n name: React.PropTypes.string,\n readOnly: React.PropTypes.bool,\n emptyText: React.PropTypes.string\n },\n\n getDefaultProps: function () {\n return {\n config: {\n allowCheck: false,\n location_type: null,\n hideInactive: false,\n parentId: null,\n selectionTypeId: null,\n lineageRoot: null\n },\n emptyText: __(\"NO_LOCATION_SELECTED\")\n }\n },\n\n getInitialState: function () {\n return {\n showLocations: false,\n location: {\n uuid: null\n },\n search: \"\"\n };\n },\n\n _init: function (props) {\n if (props.value) {\n ewars.tx(\"com.ewars.resource\", [\"location\", props.value, [\"uuid\", \"name\", \"site_type_id\"], [\"location_type:site_type_id:id\"]])\n .then(function (resp) {\n if (resp) {\n this.state.location = resp;\n } else {\n this.state.location = {\n uuid: null,\n name: \"Unknown location\"\n }\n }\n this._initialLoad = true;\n if (this.isMounted()) this.forceUpdate();\n }.bind(this))\n }\n },\n\n componentWillMount: function () {\n if (this.props.value && this.props.value != this.state.location.uuid) {\n this._init(this.props);\n } else {\n this._initialLoad = true;\n }\n },\n\n componentWillReceiveProps: function (nextProps) {\n if (this.props.value != nextProps.value) {\n if (!nextProps.value) {\n this.state.location = {};\n } else {\n this._initialLoad = false;\n if (nextProps.value) this._init(nextProps);\n }\n } else {\n this._initialized = true;\n }\n },\n\n componentDidMount: function () {\n window.__hack__.addEventListener('click', this.handleBodyClick);\n },\n\n componentWillUnmount: function () {\n window.__hack__.removeEventListener('click', this.handleBodyClick);\n },\n\n componentDidUpdate: function () {\n if (this.state.showLocations) {\n }\n },\n\n handleBodyClick: function (evt) {\n if (this.refs.selector) {\n const area = this.refs.selector.getDOMNode ? this.refs.selector.getDOMNode() : this.refs.selector;\n\n if (!area.contains(evt.target)) {\n this.state.showLocations = false;\n this.forceUpdate();\n }\n }\n },\n\n handleClick: function (e) {\n e.stopPropagation();\n },\n\n _onChange: function (location) {\n let name = this.props.config.nameOverride || this.props.name;\n let path = this.props.config.path || null;\n\n this.state.showLocations = false;\n\n if (this._isSearch) {\n this._isSearch = false;\n this.state.search = \"\";\n this.state.locations = JSON.parse(_backupLocations);\n }\n\n this.state.location = location;\n this.props.onUpdate(name, location.uuid, path);\n\n if(this.props.config.updateAllRelatedFields){\n const location_data = {...location};\n location_data['location_full'] = location['@lineage'].join(\", \")\n const fieldToUpdate = {\n 'location_full': 'location_full',\n 'location_name' : 'name'\n };\n Object.keys(fieldToUpdate).forEach( field => {\n this.props.onUpdate(field, location_data[fieldToUpdate[field]] ,field)\n })\n }\n },\n\n _toggle: function (e) {\n e.stopPropagation();\n this.state.showLocations = this.state.showLocations ? false : true;\n\n this.forceUpdate();\n\n if (this.state.showLocations && !this._isLoaded) {\n // We need to load the options\n var resource = \"location\";\n var select = [\"uuid\", \"name\", \"@children\", \"site_type_id\"];\n var filters = {};\n if (this.props.config.hideInactive) filters.status = {eq: \"ACTIVE\"};\n if (!this.props.config.hideInactive) filters.status = {neq: \"DELETED\"};\n\n if (window.user.role != \"SUPER_ADMIN\") {\n if (window.user.role == \"REGIONAL_ADMIN\") {\n\n if(window.user.location_group){\n filters['data.groups']= { eq: [window.user.location_group], isGroups: true, type: \"LOCGROUPS\" };\n }else{\n filters.uuid = {eq: window.user.location_id}\n }\n } else {\n filters.uuid = {eq: window.user.clid}\n }\n } else {\n filters.parent_id = {eq: \"NULL\"}\n }\n\n ewars.tx(\"com.ewars.query\", [resource, select, filters, null, null, null, [\"location_type:site_type_id:id\"]])\n .then(function (resp) {\n this.state.locations = resp;\n this._isLoaded = true;\n if (this.isMounted()) this.forceUpdate();\n }.bind(this))\n }\n },\n\n _resetLocations: function() {\n var resource = \"location\";\n var select = [\"uuid\", \"name\", \"@children\", \"site_type_id\"];\n var filters = {};\n if (this.props.config.hideInactive) filters.status = {eq: \"ACTIVE\"};\n if (!this.props.config.hideInactive) filters.status = {neq: \"DELETED\"};\n\n if (window.user.role != \"SUPER_ADMIN\") {\n if (window.user.role == \"REGIONAL_ADMIN\") {\n if(window.user.location_group){\n filters['data.groups']= { eq: [window.user.location_group], isGroups: true, type: \"LOCGROUPS\" };\n }else{\n filters.uuid = {eq: window.user.location_id}\n }\n } else {\n filters.uuid = {eq: window.user.clid}\n }\n } else {\n filters.parent_id = {eq: \"NULL\"}\n }\n\n ewars.tx(\"com.ewars.query\", [resource, select, filters, null, null, null, [\"location_type:site_type_id:id\"]])\n .then((resp) => {\n this._isLoaded = true;\n this.setState({\n locations: resp,\n search: ''\n })\n })\n },\n\n _clearSearch: function () {\n this._resetLocations();\n },\n\n _onSearchChange: function (val) {\n this.setState({\n search: val\n })\n },\n\n _onSearch: function (val) {\n if (val == null || val == '') {\n this._resetLocations();\n } else {\n var query = {\n \"name.en\": {like: val}\n };\n if (this.props.config.hideInactive) query.status = {eq: \"ACTIVE\"};\n if (!this.props.config.hideInactive) query.status = {neq: \"DELETED\"};\n\n if (this.props.config.parentId) {\n query.lineage = {has: this.props.config.parentId};\n } else {\n if (window.user.role != \"SUPER_ADMIN\") {\n if (window.user.role == \"ACCOUNT_ADMIN\") {\n query.lineage = {under: window.user.clid};\n } else if (window.user.role == \"REGIONAL_ADMIN\") {\n if(window.user.location_group){\n query['data.groups']= { eq: [window.user.location_group], isGroups: true, type: \"LOCGROUPS\" };\n }else{\n query.lienage = {under: window.user.location_id};\n }\n } else {\n query.lineage = {under: window.user.clid};\n }\n }\n }\n\n\n if (this.state.search.length >= 2) {\n ewars.tx(\"com.ewars.query\", [\"location\", LOCATION_SELECT, query, null, null, null, [\"location_type:site_type_id:id\"]])\n .then((resp) => {\n this.setState({\n locations: resp\n });\n })\n }\n }\n },\n\n render: function () {\n if (!this._initialLoad) {\n return (\n
    \n
    \n \n
    \n
    \n )\n }\n\n if (this.props.readOnly) {\n var name = ewars.I18N(this.state.location.name);\n name += \" (\" + ewars.I18N(this.state.location.name) + \")\";\n return \n }\n\n var parent_id;\n if (this.props.config) {\n if (this.props.config.parent_id) parent_id = this.props.config.parent_id;\n }\n\n var rootNodes;\n if (!this._isLoaded && this.state.showLocations) rootNodes = ;\n\n if (this._isLoaded && this.state.showLocations) {\n rootNodes = this.state.locations.map(location => {\n return (\n \n )\n });\n }\n\n return (\n
    \n \n {this.state.showLocations ?\n
    \n
    \n
    \n \n {this.state.search.length > 0 ?\n
    \n \n
    \n : null}\n
    \n
    \n {rootNodes}\n
    \n : null}\n
    \n )\n }\n});\n\nexport default LocationSelectField;\n","import SelectField from \"./f.select\";\nimport DisplayField from \"./f.display\";\n\nconst STYLE = {\n display: \"inline-block\",\n background: \"#F2F2F2\",\n borderRadius: 3,\n padding: 5,\n marginRight: 8\n};\n\nclass Group extends React.Component {\n render() {\n return (\n
    \n \n {this.props.data}\n \n {\n this.props.onClose(this.props.data)\n }}>\n \n \n \n
    \n )\n }\n}\n\nclass LocationGroupField extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = {\n data: []\n }\n }\n\n componentWillMount() {\n this._getGroups();\n }\n\n componentWillReceiveProps() {\n if (!this.state.data) {\n this._getGroups();\n }\n }\n\n _getGroups = () => {\n ewars.tx(\"com.ewars.location.groups\")\n .then((data) => {\n this.setState({\n data: data\n })\n })\n };\n\n _onAdd = (prop, value) => {\n let newValue = [];\n if (this.props.value) newValue = ewars.copy(this.props.value);\n if (newValue.indexOf(value) < 0) {\n newValue.push(value);\n }\n\n this.props.onUpdate(this.props.name, newValue);\n };\n\n _onRemove = (group) => {\n let index = this.props.value.indexOf(group);\n if (index >= 0) {\n let newValue = ewars.copy(this.props.value);\n newValue.splice(index, 1);\n this.props.onUpdate(this.props.name, newValue);\n }\n };\n\n render() {\n let fieldConfig = {\n options: this.state.data.map((item) => {\n return [item, item];\n })\n };\n\n let value = \"\";\n let arrValue = [];\n\n if (this.props.value) {\n arrValue = this.props.value;\n value = this.props.value.join(\", \")\n }\n\n return (\n \n \n \n
    \n {arrValue.map((group,index) => {\n return \n })}\n\n
    \n
    \n
    \n \n \n \n \n \n
    \n )\n }\n}\n\nexport default LocationGroupField;\n","import MapComponent from \"../c.map\";\nimport Button from \"../c.button\";\n\nvar LocationInputField = React.createClass({\n propTypes: {\n value: React.PropTypes.object,\n name: React.PropTypes.string\n },\n\n getInitialState: function () {\n return {\n lat: 51.505,\n lng: -0.09\n }\n },\n\n componentDidMount: function () {\n this._getUsersPosition();\n },\n\n getDefaultProps: function () {\n return {\n value: {\n lat: 12.0000,\n lng: 8.33333\n }\n }\n },\n\n _getUsersPosition: function () {\n if (navigator.geolocation) {\n navigator.geolocation.getCurrentPosition(this._handleGeoLocate);\n }\n },\n\n _handleGeoLocate: function (data) {\n //this._handleChange(data.coords.latitude, data.coords.longitude);\n },\n\n _handleChange: function (lat, lng) {\n if (this.props.readOnly) return;\n this.props.onUpdate(this.props.name, {lat: lat, lng: lng}, this.props.config.path)\n },\n\n _handleSingleChange: function (e) {\n var copy = JSON.parse(JSON.stringify({lat: this.props.value.lat, lng: this.props.value.lng}));\n copy[e.target.name] = e.target.value;\n this.props.onUpdate(this.props.name, copy, this.props.config.path);\n },\n\n render: function () {\n\n var pointEditMode = true;\n if (this.props.readOnly) pointEditMode = false;\n\n return (\n
    \n
    \n \n
    \n {!this.props.readOnly ?\n
    \n
    \n
    \n Latitude\n \n
    \n
    \n Longitude\n \n
    \n
    \n
    \n : null}\n
    \n )\n }\n});\n\nexport default LocationInputField;\n","import {\n Form\n} from \"../../common\";\nimport FormUtils from \"../../common/utils/FormUtils\";\nclass MainFormField extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n definition:{}\n }\n }\n componentWillMount() {\n }\n _onDataChange = (data, prop, value, path) => {\n let fieldPath = this.props.config.path || this.props.name;\n this.props.onUpdate(prop, value, prop);\n this.props.onMainFormDataChange(this.props.config.main_form_field_key, value, this.props.config.main_form_field_key);\n }\n render() {\n var fieldDefinition=this.props.mainFormDefinition[this.props.config.main_form_field_key]?this.props.mainFormDefinition[this.props.config.main_form_field_key]:FormUtils.field(this.props.mainFormDefinition, this.props.config.main_form_field_key);\n var definition={},data={};\n definition[fieldDefinition.name]=fieldDefinition;\n if(this.props.data.main_data && this.props.data.main_data.hasOwnProperty(this.props.config.main_form_field_key)){\n data[fieldDefinition.name]= this.props.data.main_data[this.props.config.main_form_field_key];\n }else{\n if(!this.props.mainFormData) this.props.mainFormData={};\n data[fieldDefinition.name]= this.props.mainFormData[this.props.config.main_form_field_key];\n }\n \n return (\n \n )\n }\n}\n\nexport default MainFormField;","const MarginField = React.createClass({\n propTypes: {\n _onChange: React.PropTypes.func,\n placeholder: React.PropTypes.string,\n name: React.PropTypes.string,\n readOnly: React.PropTypes.bool\n },\n getInitialState: function () {\n return {\n margin : {}\n };\n },\n\n\n componentDidMount: function () {\n if (this.props.focus) {\n this.refs.inputField.focus();\n }\n },\n\n getDefaultProps: function () {\n return {\n path: null,\n name: null,\n config: {}\n }\n },\n\n getInitialState: function () {\n return {};\n },\n\n _handleKeyDown: function (e) {\n if (this.props.onKeyDown) this.props.onKeyDown(e);\n },\n\n _onChange: async function (event) {\n\n let margin;\n \n if(this.props.value != \"\"){\n margin = this.props.value\n }else{\n margin = {}\n }\n margin[event.target.name] = event.target.value;\n await this.setState({\n ...this.state,\n margin : margin\n })\n if (!this.props.config.useBlur) {\n this.props.onUpdate(this.props.name, this.state.margin, this.props.path);\n }\n },\n\n _onBlur: function (e) {\n // Perform validation here\n if (this.props.config.useBlur) {\n this.props.onUpdate(this.props.name, e.target.value, this.props.path);\n }\n },\n\n render: function() {\n let value = this.props.value;\n return (\n
    \n
    \n

    Top:

    \n
    \n \n
    \n
    \n
    \n

    Right:

    \n
    \n \n
    \n
    \n
    \n

    Bottom:

    \n
    \n \n
    \n
    \n
    \n
    \n

    Left:

    \n
    \n
    \n \n
    \n
    \n
    \n )\n }\n\n});\n\nexport default MarginField;\n","var MatrixCell = React.createClass({\n getInitialState: function () {\n return {};\n },\n\n render: function () {\n var label = ewars.formatters.I18N_FORMATTER(this.props.field.label);\n label = label.replace(/\\\\n/g, '\\n');\n if (this.props.field.required) label += \" *\";\n\n let errors;\n if (this.props.errors) {\n if (this.props.errors[this.props.field.path]) {\n errors = this.props.errors[this.props.field.path];\n }\n }\n\n return (\n \n
    \n
    \n {errors ?\n
    \n \n
    \n : null}\n
    \n
    {label}
    \n
    \n
    \n\n
    \n {[\"header\", \"display\"].indexOf(this.props.field.type) < 0 ?\n
    \n
    \n
    \n {this.props.children}\n
    \n {this.props.field.help ?\n
    \n \n
    \n : null}\n
    \n {errors ?\n
    \n
    \n {errors.map(err => {\n return
    {err}
    \n })}\n
    \n
    \n : null}\n\n
    \n : null}\n {this.state.showErrors ?\n
    \n\n
    \n : null}\n\n \n )\n }\n});\n\nexport default MatrixCell;\n","import MatrixRow from \"./f.matrix.row\";\nimport MatrixCell from \"./f.matrix.cell\";\n\nconst SORT_FIELDS = (a, b) => {\n let aO = parseInt(a.order),\n bO = parseInt(b.order);\n if (aO > bO) return 1;\n if (aO < bO) return -1;\n return 0;\n}\n\n/**\n * Retrieve the form definition fields as a flat array\n * @param sourceFields\n * @returns {Array.}\n * @private\n */\nfunction _getFieldsAsArray(sourceFields) {\n var fields = [];\n for (var token in sourceFields) {\n var field = sourceFields[token];\n if (typeof field == 'object') {\n field.name = token;\n fields.push(field);\n\n }\n }\n\n return fields.sort(SORT_FIELDS);\n}\n\nvar MatrixField = React.createClass({\n getInitialState: function () {\n return {};\n },\n\n _handleCellChange: function (prop, value, path) {\n this.props.onUpdate(prop, value, path);\n },\n\n _processheaders: function () {\n if (this.props.config.headers) {\n var headers = [];\n for (var i in this.props.config.headers) {\n headers.push(\n  \n )\n }\n\n return headers;\n }\n },\n _getRuleResult: function (rule, data) {\n var result;\n\n var sourceValue = rule[0].indexOf(\".\") >= 0 ? data[rule[0]] :ewars.getKeyPath(rule[0], data);\n if ([\"null\", \"notnull\"].indexOf(rule[1]) < 0) {\n if (sourceValue == null || sourceValue == undefined) return false;\n }\n const isNumber = (val) => {\n try {\n parseFloat(val);\n return true;\n } catch (e) {\n return false;\n }\n };\n\n switch (rule[1]) {\n case \"eq\":\n if (Object.prototype.toString.call(sourceValue) == \"[object Array]\") {\n if (sourceValue.indexOf(rule[2]) >= 0) {\n result = true;\n } else {\n result = false;\n }\n } else {\n result = sourceValue == rule[2];\n }\n break;\n case \"ne\":\n case \"neq\":\n if (Object.prototype.toString.call(sourceValue) == \"[object Array]\") {\n if (sourceValue.indexOf(rule[2]) < 0) {\n result = true;\n } else {\n result = false;\n }\n } else {\n result = sourceValue != rule[2];\n }\n break;\n case \"gt\":\n if (!isNumber(sourceValue)) {\n result = false;\n } else {\n result = parseFloat(sourceValue) > parseFloat(rule[2]);\n }\n break;\n case \"lt\":\n if (!isNumber(sourceValue)) {\n result = false;\n } else {\n result = parseFloat(sourceValue) < parseFloat(rule[2]);\n }\n break;\n case 'gte':\n if (!isNumber(sourceValue)) {\n result = false;\n } else {\n result = parseFloat(sourceValue) >= parseFloat(rule[2]);\n }\n break;\n case 'lte':\n if (!isNumber(sourceValue)) {\n result = false;\n } else {\n result = parseFloat(sourceValue) <= parseFloat(rule[2]);\n }\n break;\n case 'null':\n if (ewars.isNull(sourceValue)) {\n result = true;\n } else {\n result = false;\n }\n break;\n case 'notnull':\n if (ewars.isNull(sourceValue)) {\n result = false;\n } else {\n result = true;\n }\n break;\n default:\n result = false;\n break\n }\n\n return result;\n },\n\n _checkFieldVisible: function (field, data) {\n if (field.conditional_bool == true) {\n var result = false;\n\n if (!field.conditions) return true;\n if (!field.conditions.rules) return true;\n\n if ([\"ANY\", \"any\"].indexOf(field.conditions.application) >= 0) {\n // Only one of the rules has to pass\n\n for (var conIdx in field.conditions.rules) {\n var rule = field.conditions.rules[conIdx];\n\n var tmpResult = this._getRuleResult(rule, data);\n if (result != true && tmpResult == true) result = true;\n }\n\n } else {\n var ruleCount = field.conditions.rules.length;\n var rulePassCount = 0;\n\n for (var ruleIdx in field.conditions.rules) {\n var rule = field.conditions.rules[ruleIdx];\n var ruleResult = this._getRuleResult(rule, data);\n if (ruleResult) rulePassCount++;\n }\n\n if (ruleCount == rulePassCount) result = true;\n\n }\n return result;\n } else {\n return true;\n }\n },\n\n\n _processDefinition: function () {\n let result = []\n\n let sorted = this.props.config.fields.sort((a, b) => {\n if (parseFloat(a.order) > parseFloat(b.order)) return 1;\n if (parseFloat(a.order) < parseFloat(b.order)) return -1;\n return 0;\n });\n\n sorted.forEach((row, index) => {\n\n let visible = true;\n if (row.conditional_bool) {\n visible = this._checkFieldVisible(row, this.props.data);\n }\n\n if (visible) {\n\n let cells = [];\n let cellDefinition = [];\n row.fields && row.fields.forEach(field => {\n cellDefinition.push({\n ...field,\n name: `${this.props.name}.${row.name}.${field.name}`\n })\n })\n\n cellDefinition = cellDefinition.sort(SORT_FIELDS);\n\n cellDefinition.forEach((cell, index) => {\n let isVisible = true;\n if (cell.conditional_bool) {\n isVisible = this._checkFieldVisible(cell, this.props.data);\n }\n\n if (this.props.map[cell.type] && isVisible) {\n var FieldControl = this.props.map[cell.type];\n let value = this.props.data[cell.name] || \"\";\n cells.push(\n \n \n\n \n )\n } else {\n //TODO::\n // var Field = this.props.map._typeMap.none;\n // cells.push(\n // \n // \n // \n // )\n }\n })\n\n result.push(\n {cells}\n )\n }\n\n }, this);\n\n return result;\n },\n\n _processRow: function (rowDefinition) {\n return row;\n },\n\n render: function () {\n var content = this._processDefinition();\n return (\n
    \n \n \n {content}\n \n
    \n
    \n )\n }\n});\n\nexport default MatrixField;\n","var MatrixRow = React.createClass({\n getInitialState: function () {\n return {};\n },\n\n render: function () {\n\n var label;\n\n if (this.props.data.show_row_label) {\n var labelContent = ewars.I18N(this.props.data.label);\n label = (\n {labelContent}\n )\n }\n\n var children = this.props.children;\n if (!Array.isArray(children)) {\n children = [children];\n }\n\n return (\n \n {label}\n {children}\n \n )\n }\n});\n\nexport default MatrixRow;\n","const MEDIA_TYPES = {\n PHOTO: \"IMAGE\",\n VIDEO: \"VIDEO\"\n}\n\nconst VIDEO_EXTENTIONS = [\"mp4\"]\nconst IMAGE_EXTENTIONS = [\"jpg\", \"jpeg\", \"png\"]\n\nconst MESSAGE_BOX_CONTAINER = {\n margintTop: 2, border: '1px solid #d5cece', padding: 5, borderRadius: '5px'\n}\n\nclass MediaContentField extends React.Component {\n static defaultProps = {\n parent_id: null\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n }\n }\n\n componentWillMount() {\n try {\n this.state.mediaType = this.getMediaType();\n } catch (error) {\n this.state.mediaType = null;\n }\n }\n\n componentDidMount() {\n this.getMedia();\n }\n\n getTypeFromURI = (fileURI) => {\n\n if (!fileURI || fileURI == \"\") return;\n\n const fileExt = fileURI.split(\".\").pop();\n\n if (VIDEO_EXTENTIONS.includes(fileExt)) return MEDIA_TYPES.VIDEO;\n else if (IMAGE_EXTENTIONS.includes(fileExt)) return MEDIA_TYPES.PHOTO;\n else return;\n }\n\n // Get media type of the content\n getMediaType = () => {\n if (!this.props.config.media_type || this.props.config.media_type == \"ANY\") {\n return this.getTypeFromURI(this.props.value);\n }\n\n return this.props.config.media_type\n }\n\n // Checks url type of the content, to determine if its local or remote\n checkUrlType = (url) => {\n\n if (url.startsWith(\"http://\") || url.startsWith(\"https://\")) {\n return \"REMOTE\";\n }\n\n return \"LOCAL\";\n\n }\n\n // Gets the actual media content\n // If it is local type, it fetches from the server(which returns base 64 formatted data)\n // If remote then it will directly store the url of the content\n getMedia = () => {\n\n if (!this.props.readOnly) return;\n\n let value = this.props.value;\n if (value) {\n let strValue = String(value);\n if (strValue.indexOf(\"DUPE_\") >= 0) {\n value = strValue.replace(\"DUPE_\", \"\");\n }\n }\n\n if (!value) {\n return;\n }\n\n if (this.checkUrlType(value) != \"LOCAL\") {\n this.setState({\n data: value\n })\n }\n\n this.setState({\n isLoading: true\n })\n\n ewars.tx(\"com.ewars.report_media.get\", [value])\n .then((resp) => {\n if (resp.data) {\n this.setState({\n data: resp.data\n })\n }\n\n this.setState({\n isLoading: false\n })\n }).catch(err => {\n this.setState({\n isLoading: false\n })\n })\n }\n\n\n\n render = () => {\n\n\n if (!this.props.readOnly) {\n return
    {__(\"INPUT_NOT_ALLOWED_IN_WEB\")}
    \n }\n\n if (this.state.isLoading) {\n return
    {__(\"LOADING\")}
    \n }\n\n let value = this.props.value;\n if (value) {\n let strValue = String(value);\n if (strValue.indexOf(\"DUPE_\") >= 0) {\n value = strValue.replace(\"DUPE_\", \"\");\n }\n }\n\n\n return (\n
    \n {\n !value || !this.state.data ?
    \n {__(\"NO_DATA_AVAILABLE\")}\n
    :\n !this.state.mediaType ?\n
    {__(\"UNSUPPORTED_MEDIA\")}
    \n :\n
    \n {\n this.state.mediaType == MEDIA_TYPES.PHOTO ?\n \n :\n \n }\n
    \n }\n
    \n )\n }\n\n}\n\n\nexport default MediaContentField;\n","import SelectField from \"./f.select\";\nimport DisplayField from \"./f.display\";\n\nconst STYLE = {\n display: \"inline-block\",\n background: \"#F2F2F2\",\n color: \"#4E4E4E\",\n margin: \"1px 0px 2px\",\n borderRadius: 3,\n padding: \"3px 5px\",\n marginRight: 8\n};\n\nclass SelectedItem extends React.Component {\n render() {\n return (\n
    \n \n {this.props.data}\n \n {\n this.props.onClose(this.props.data)\n }}>\n \n \n \n
    \n )\n }\n}\n\nclass MultiSelectField extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = {\n data: {\n o: [],\n os: null,\n c: [],\n l: \"\",\n s: false,\n r: false,\n ml: false\n \n }\n }\n }\n\n _onAdd = (prop, value) => {\n if (!value) return;\n let newValue = [];\n if (this.props.value) newValue = ewars.copy(this.props.value);\n if (newValue.indexOf(value) < 0) {\n newValue.push(value);\n }\n\n this.props.onUpdate(this.props.name, newValue);\n };\n\n _onRemove = (group) => {\n let index = this.props.value.indexOf(group);\n if (index >= 0) {\n let newValue = ewars.copy(this.props.value);\n newValue.splice(index, 1);\n this.props.onUpdate(this.props.name, newValue);\n }\n };\n\n render() {\n let fieldConfig = {\n options: this.props.data.o.map((item) => {\n return [item, item];\n })\n };\n\n let styleClass = \" min-width-unset custom-scroll \";\n\n if(this.props.data.styleClass){\n styleClass += this.props.data.styleClass; \n }\n\n let value = \"\";\n let arrValue = [];\n\n if (this.props.value) {\n arrValue = this.props.value;\n value = this.props.value.join(\", \")\n }\n\n return (\n \n \n \n
    \n {\n arrValue && arrValue.length > 0 ? \n
    \n { \n arrValue.map((group,index) => {\n return \n })\n } \n
    : \n
    \n No primary columns selected\n
    \n }\n\n
    \n
    \n
    \n \n \n \n \n \n
    \n )\n }\n}\n\nexport default MultiSelectField;\n","import { Layout, Row, Cell } from \"../layout\";\nimport SelectField from \"./f.select\";\n\nconst STYLE = {\n display: \"inline-block\",\n background: \"#F2F2F2\",\n borderRadius: 3,\n padding: 5,\n marginRight: 8\n};\n\nclass Group extends React.Component {\n\n render() {\n return (\n
    \n \n {ewars.I18N(this.props.data.name)}\n \n {\n this.props.onClose(this.props.data)\n }}>\n \n \n \n
    \n )\n }\n}\n\n\nvar MultipleAlarmsField = React.createClass({\n _isLoaded: false,\n _initialLoad: false,\n _isSearch: false,\n\n propTypes: {\n _onChange: React.PropTypes.func,\n placeholder: React.PropTypes.string,\n name: React.PropTypes.string,\n readOnly: React.PropTypes.bool,\n emptyText: React.PropTypes.string\n },\n\n getDefaultProps: function () {\n return {\n config: {\n allowCheck: false,\n location_type: null,\n hideInactive: false,\n parentId: null,\n selectionTypeId: null,\n lineageRoot: null\n },\n emptyText: __(\"NO_LOCATION_SELECTED\")\n }\n },\n\n getInitialState: function () {\n return {\n alarms: [],\n data: [],\n alarm:null\n };\n },\n\n _init: function (props) {\n if (props.value.length > 0) {\n this.state.data = props.value;\n this._initialLoad = true;\n }\n },\n\n componentWillMount: function () {\n ewars.tx(\"com.ewars.query\", [\"alarm\", [\"uuid\", \"name\"], { \"status\": { eq: \"ACTIVE\" } }, null, null, null, null])\n .then((resp) => {\n this.state.alarms= resp;\n if (this.props.value && this.props.value != this.state.data) {\n this._init(this.props);\n } else {\n this._initialLoad = true;\n }\n this.forceUpdate();\n }\n )\n\n },\n\n componentWillReceiveProps: function (nextProps) {\n if (this.props.value != nextProps.value) {\n if (nextProps.value.length == 0) {\n this.state.data = [];\n } else {\n this._initialLoad = false;\n if (nextProps.value.length > 0) this._init(nextProps);\n }\n } else {\n this._initialized = true;\n }\n },\n\n componentDidMount: function () {\n window.__hack__.addEventListener('click', this.handleBodyClick);\n },\n\n componentWillUnmount: function () {\n window.__hack__.removeEventListener('click', this.handleBodyClick);\n },\n\n componentDidUpdate: function () {\n\n },\n\n\n handleClick: function (e) {\n e.stopPropagation();\n },\n\n _onChange: function (prop,alarm) {\n if (JSON.stringify(alarm).indexOf(\"{\") >= 0) {\n if (alarm) {\n alarm = JSON.parse(alarm)\n }\n let name = this.props.config.nameOverride || this.props.name;\n let path = this.props.config.path || null;\n this.state.data.push(alarm);\n this.state.alarm = null;\n this.props.onUpdate(name, this.state.data, path);\n }\n },\n\n\n _onRemove: function (group) {\n let alarms = ewars.copy(this.props.value);\n let newValue = alarms.filter((alarm) => alarm.uuid != group.uuid)\n if (newValue.length == 0) {\n this._initialLoad = true;\n }\n this.state.data = newValue;\n this.props.onUpdate(this.props.name, newValue);\n if (this.isMounted()) this.forceUpdate();\n\n },\n\n render: function () {\n let options = [];\n\n if (this.props.value) {\n options = this.props.value;\n } else {\n options = this.state.data\n }\n let fieldConfig = {\n options: this.state.alarms.map((item) => {\n return [JSON.stringify(item), item[\"name\"]];\n })\n };\n\n return (\n
    \n \n \n
    \n {options.map((group, index) => {\n return \n })}\n\n
    \n
    \n
    \n \n \n \n {/* */}\n \n \n
    \n )\n }\n});\n\nexport default MultipleAlarmsField;\n","import { Layout, Row, Cell } from \"../layout\";\nimport Button from \"../c.button\";\nimport Spinner from \"../c.spinner\";\n\nconst LOCATION_SELECT = [\"uuid\", \"name\", \"parent_id\", \"@children\", \"site_type_id\", \"@lineage\"];\nconst STYLE = {\n display: \"inline-block\",\n background: \"#F2F2F2\",\n borderRadius: 3,\n padding: 5,\n marginRight: 8\n};\n\nclass Group extends React.Component {\n render() {\n return (\n
    \n \n {ewars.I18N(this.props.data.name)}\n \n {\n this.props.onClose(this.props.data)\n }}>\n \n \n \n
    \n )\n }\n}\nvar _backupLocations = null;\n\nvar LocationTreeNode = React.createClass({\n _isLoaded: false,\n\n getDefaultProps: function () {\n return {\n hideInactive: true,\n lineageRoot: null,\n selectionTypeId: null\n }\n },\n\n getInitialState: function () {\n return {\n showLocations: false\n }\n },\n\n _onSelect: function () {\n this.props.onSelect(this.props.data);\n },\n\n _onClick: function () {\n if (this.props.selectionTypeId && this.props.data.site_type_id == this.props.selectionTypeId) {\n this._onSelect();\n return;\n }\n\n if (this.props.data.children <= 0) return;\n\n\n this.state.showLocations = this.state.showLocations ? false : true;\n if (this.isMounted()) this.forceUpdate();\n\n if (!this._isLoaded && this.state.showLocations) {\n var filters = {\n parent_id: { eq: this.props.data.uuid }\n };\n\n if (this.props.hideInactive) filters.status = { eq: \"ACTIVE\" };\n if (!this.props.hideInactive) filters.status = { neq: \"DELETED\" };\n\n ewars.tx(\"com.ewars.query\", [\"location\", LOCATION_SELECT, filters, { \"name.en\": \"ASC\" }, null, null, [\"location_type:site_type_id:id\"]])\n .then(function (resp) {\n this.state.locations = resp;\n this._isLoaded = true;\n if (this.isMounted()) this.forceUpdate();\n }.bind(this))\n }\n },\n\n render: function () {\n var className = \"item locale-select\";\n if (this.props.value == this.props.data.uuid) className += \" active\";\n\n var name = ewars.I18N(this.props.data.name);\n name += \" (\" + ewars.I18N(this.props.data.location_type.name) + \")\";\n\n var children;\n if (this.state.showLocations && this._isLoaded) {\n children = this.state.locations.map(location => {\n return (\n \n )\n });\n } else {\n children = ;\n }\n\n var iconClass = \"fal\";\n if (this.state.showLocations) iconClass += \" fa-caret-down\";\n if (!this.state.showLocations) iconClass += \" fa-caret-right\";\n if (!this._isLoaded && this.state.showLocations) iconClass = \"fal fa-spin fa-cog\";\n\n if (this.props.data.children <= 0) iconClass = \"fal fa-map-marker\";\n if (this.props.selectionTypeId && this.props.data.site_type_id == this.props.selectionTypeId) iconClass = \"fal fa-map-marker\";\n\n var childStyle = { display: \"none\" };\n if (this.state.showLocations) childStyle.display = \"block\";\n\n var handleClass = \"locale-tree-node\";\n if (this.props.data.site_type_id == this.props.selectionTypeId) handleClass += \" green\";\n\n var showSelect = false;\n if (!this.props.selectionTypeId || this.props.selectionTypeId == this.props.data.site_type_id) showSelect = true;\n if (showSelect) handleClass += \" has-button\";\n\n let lineage;\n if (this.props.data['@lineage']) {\n lineage = (this.props.data['@lineage'] || []).join(' \\\\ ');\n }\n\n return (\n
    \n
    \n
    \n
    \n {name}\n {lineage ?
    : null}\n {lineage ?\n {lineage}\n : null}\n\n
    \n {showSelect ?\n
    \n \n
    \n : null}\n
    \n
    \n {children}\n
    \n
    \n )\n }\n});\n\nvar Handle = React.createClass({\n render: function () {\n var name = __(\"NO_SELECTION\");\n\n if (this.props.value.uuid) {\n name = ewars.I18N(this.props.value.name);\n name += \" (\" + ewars.I18N(this.props.value.location_type.name) + \")\";\n }\n return (\n
    \n \n \n \n {name}\n \n \n \n \n \n \n
    \n )\n }\n});\n\n\nfunction debounce(fn, delay) {\n var timer = null;\n return function () {\n var context = this, args = arguments;\n clearTimeout(timer);\n timer = setTimeout(function () {\n fn.apply(context, args);\n }, delay);\n };\n}\n\nclass SearchInput extends React.Component {\n static defaultProps = {\n value: ''\n };\n\n constructor(props) {\n super(props);\n\n this.sendForSearch = debounce(this.sendForSearch, 250);\n }\n\n componentDidMount() {\n this._el.focus();\n }\n\n sendForUpdate = (e) => {\n this.props.onChange(e.target.value);\n\n if (e.target.value.length > 2) {\n this.sendForSearch(e.target.value);\n }\n\n if (e.target.value == \"\") this.sendForSearch(null);\n };\n\n sendForSearch = (searchTerm) => {\n this.props.onSearch(searchTerm);\n };\n\n render() {\n return (\n { this._el = el; }}\n onChange={this.sendForUpdate}\n value={this.props.value} />\n )\n }\n}\n\nvar MultipleLocationsField = React.createClass({\n _isLoaded: false,\n _initialLoad: false,\n _isSearch: false,\n\n propTypes: {\n _onChange: React.PropTypes.func,\n placeholder: React.PropTypes.string,\n name: React.PropTypes.string,\n readOnly: React.PropTypes.bool,\n emptyText: React.PropTypes.string\n },\n\n getDefaultProps: function () {\n return {\n config: {\n allowCheck: false,\n location_type: null,\n hideInactive: false,\n parentId: null,\n selectionTypeId: null,\n lineageRoot: null\n },\n emptyText: __(\"NO_LOCATION_SELECTED\")\n }\n },\n\n getInitialState: function () {\n return {\n showLocations: false,\n location: {\n uuid: null\n },\n search: \"\",\n data: []\n };\n },\n\n _init: function (props) {\n if (this.state.location && this.state.location.uuid) {\n ewars.tx(\"com.ewars.resource\", [\"location\", this.state.location.uuid, [\"uuid\", \"name\", \"site_type_id\"], [\"location_type:site_type_id:id\"]])\n .then(function (resp) {\n if (resp) {\n this.state.location = resp;\n } else {\n this.state.location = {\n uuid: null,\n name: \"Unknown location\"\n }\n }\n this._initialLoad = true;\n if (this.isMounted()) this.forceUpdate();\n }.bind(this))\n }\n if(props.value.length>0){\n this.state.data = props.value;\n this._initialLoad = true;\n }\n },\n\n componentWillMount: function () {\n if (this.props.value && this.props.value != this.state.data) {\n this._init(this.props);\n } else {\n this._initialLoad = true;\n }\n },\n\n componentWillReceiveProps: function (nextProps) {\n if (this.props.value != nextProps.value) {\n if (nextProps.value.length == 0) {\n this.state.location = {};\n this.state.data = [];\n } else {\n this._initialLoad = false;\n if (nextProps.value.length > 0) this._init(nextProps);\n }\n } else {\n this._initialized = true;\n }\n },\n\n componentDidMount: function () {\n window.__hack__.addEventListener('click', this.handleBodyClick);\n },\n\n componentWillUnmount: function () {\n window.__hack__.removeEventListener('click', this.handleBodyClick);\n },\n\n componentDidUpdate: function () {\n if (this.state.showLocations) {\n }\n },\n\n handleBodyClick: function (evt) {\n if (this.refs.selector) {\n const area = this.refs.selector.getDOMNode ? this.refs.selector.getDOMNode() : this.refs.selector;\n\n if (!area.contains(evt.target)) {\n this.state.showLocations = false;\n this.forceUpdate();\n }\n }\n },\n\n handleClick: function (e) {\n e.stopPropagation();\n },\n\n _onChange: function (location) {\n let name = this.props.config.nameOverride || this.props.name;\n let path = this.props.config.path || null;\n\n this.state.showLocations = false;\n\n if (this._isSearch) {\n this._isSearch = false;\n this.state.search = \"\";\n this.state.locations = JSON.parse(_backupLocations);\n }\n\n this.state.location = location;\n this.state.data.push(location);\n this.props.onUpdate(name, this.state.data, path);\n },\n\n _toggle: function (e) {\n e.stopPropagation();\n this.state.showLocations = this.state.showLocations ? false : true;\n\n this.forceUpdate();\n\n if (this.state.showLocations && !this._isLoaded) {\n // We need to load the options\n var resource = \"location\";\n var select = [\"uuid\", \"name\", \"@children\", \"site_type_id\"];\n var filters = {};\n if (this.props.config.hideInactive) filters.status = { eq: \"ACTIVE\" };\n if (!this.props.config.hideInactive) filters.status = { neq: \"DELETED\" };\n\n if (window.user.role != \"SUPER_ADMIN\") {\n if (window.user.role == \"REGIONAL_ADMIN\") {\n filters.uuid = { eq: window.user.location_id }\n } else {\n filters.uuid = { eq: window.user.clid }\n }\n } else {\n filters.parent_id = { eq: \"NULL\" }\n }\n\n ewars.tx(\"com.ewars.query\", [resource, select, filters, null, null, null, [\"location_type:site_type_id:id\"]])\n .then(function (resp) {\n this.state.locations = resp;\n this._isLoaded = true;\n if (this.isMounted()) this.forceUpdate();\n }.bind(this))\n }\n },\n\n _resetLocations: function () {\n var resource = \"location\";\n var select = [\"uuid\", \"name\", \"@children\", \"site_type_id\"];\n var filters = {};\n if (this.props.config.hideInactive) filters.status = { eq: \"ACTIVE\" };\n if (!this.props.config.hideInactive) filters.status = { neq: \"DELETED\" };\n\n if (window.user.role != \"SUPER_ADMIN\") {\n if (window.user.role == \"REGIONAL_ADMIN\") {\n filters.uuid = { eq: window.user.location_id }\n } else {\n filters.uuid = { eq: window.user.clid }\n }\n } else {\n filters.parent_id = { eq: \"NULL\" }\n }\n\n ewars.tx(\"com.ewars.query\", [resource, select, filters, null, null, null, [\"location_type:site_type_id:id\"]])\n .then((resp) => {\n this._isLoaded = true;\n this.setState({\n locations: resp,\n search: ''\n })\n })\n },\n\n _clearSearch: function () {\n this._resetLocations();\n },\n\n _onSearchChange: function (val) {\n this.setState({\n search: val\n })\n },\n\n _onSearch: function (val) {\n if (val == null || val == '') {\n this._resetLocations();\n } else {\n var query = {\n \"name.en\": { like: val }\n };\n if (this.props.config.hideInactive) query.status = { eq: \"ACTIVE\" };\n if (!this.props.config.hideInactive) query.status = { neq: \"DELETED\" };\n\n if (this.props.config.parentId) {\n query.lineage = { has: this.props.config.parentId };\n } else {\n if (window.user.role != \"SUPER_ADMIN\") {\n if (window.user.role == \"ACCOUNT_ADMIN\") {\n query.lineage = { under: window.user.clid };\n } else if (window.user.role == \"REGIONAL_ADMIN\") {\n query.lienage = { under: window.user.location_id };\n } else {\n query.lineage = { under: window.user.clid };\n }\n }\n }\n\n\n if (this.state.search.length >= 2) {\n ewars.tx(\"com.ewars.query\", [\"location\", LOCATION_SELECT, query, null, null, null, [\"location_type:site_type_id:id\"]])\n .then((resp) => {\n this.setState({\n locations: resp\n });\n })\n }\n }\n },\n _onRemove: function (group) {\n let locations = ewars.copy(this.props.value);\n let newValue = locations.filter((loc) => loc.uuid != group.uuid)\n if (newValue.length == 0) {\n this.state.location = {\n uuid: null,\n name: \"Unknown location\"\n }\n this._initialLoad = true;\n } \n this.state.data = newValue;\n this.props.onUpdate(this.props.name, newValue);\n if (this.isMounted()) this.forceUpdate();\n\n \n },\n\n render: function () {\n let arrValue = [];\n let value = \"\";\n\n if (!this._initialLoad) {\n return (\n
    \n
    \n \n
    \n
    \n )\n }\n\n if (this.props.readOnly) {\n var name = ewars.I18N(this.state.location.name);\n name += \" (\" + ewars.I18N(this.state.location.name) + \")\";\n return \n }\n\n var parent_id;\n if (this.props.config) {\n if (this.props.config.parent_id) parent_id = this.props.config.parent_id;\n }\n\n var rootNodes;\n if (!this._isLoaded && this.state.showLocations) rootNodes = ;\n\n if (this._isLoaded && this.state.showLocations) {\n rootNodes = this.state.locations.map(location => {\n return (\n \n )\n });\n }\n if (this.props.value) {\n arrValue = this.props.value;\n value = this.props.value.join(\", \")\n\n }\n\n return (\n
    \n \n \n
    \n {arrValue.map((group, index) => {\n return \n })}\n\n
    \n
    \n
    \n \n \n \n
    \n \n {this.state.showLocations ?\n
    \n
    \n
    \n \n {this.state.search.length > 0 ?\n
    \n \n
    \n : null}\n
    \n
    \n {rootNodes}\n
    \n : null}\n
    \n
    \n
    \n
    \n )\n }\n});\n\nexport default MultipleLocationsField;\n","var FieldNotImplemented = React.createClass({\n getInitialState: function () {\n return {};\n },\n\n render: function () {\n return (\n \n )\n }\n});\n\nexport default FieldNotImplemented;\n","const reg = /^\\d+$/;\n\nvar NumericField = React.createClass({\n propTypes: {\n placeholder: React.PropTypes.string,\n name: React.PropTypes.string,\n readOnly: React.PropTypes.bool,\n config: React.PropTypes.object\n },\n\n getDefaultProps: function () {\n return {\n placeholder: __(\"ENTER_NUMBER\"),\n name: null,\n readOnly: false,\n path: null,\n config: {\n allow_negative: true,\n decimal_allowed: true,\n style: {}\n }\n }\n },\n\n _options: {},\n\n componentDidMount: function () {\n if (this.props.focus) {\n this.refs.inputField.focus();\n }\n },\n\n getInitialState: function () {\n return {};\n },\n\n _onChange: function (e) {\n var value = e.target.value;\n\n if (!this.props.config.decimal_allowed) value = value.split(\".\")[0];\n if (!this.props.config.allow_negative) value = value.replace(\"-\", \"\");\n\n value = value.replace(/[^\\d.-]/g, '');\n if(this.props.config.decimal_allowed){\n let counter = 0;\n value = value.replace(/[^0-9.]|\\./g, ($0)=> {\n if ($0 == \".\" && this.props.config.decimal_allowed && !(counter++)) // dot found and counter is not incremented\n return \".\"; // that means we met first dot and we want to keep it\n return \"\"; // if we find anything else, let's erase it\n });\n }\n let name = this.props.config.nameOverride || this.props.name;\n let path = this.props.config.path || this.props.name;\n\n //value = value.replace(/^0+/, '');\n this.props.onUpdate(name, value, path);\n },\n\n render: function () {\n var value;\n if(this.props.value == 0){\n value = this.props.value;\n }else{\n value = this.props.value || \"\";\n }\n\n let style = {paddingRight: \"5px\"};\n if (this.props.style) Object.assign(style, this.props.style);\n if(this.props.config.is_age_field) this.props.config.readOnly = true;\n return (\n \n )\n\n }\n\n});\n\nexport default NumericField;\n","const PasswordField = React.createClass({\n propTypes: {\n _onChange: React.PropTypes.func,\n placeholder: React.PropTypes.string,\n name: React.PropTypes.string,\n readOnly: React.PropTypes.bool\n },\n\n _options: {\n\n },\n\n componentDidMount: function () {\n if (this.props.focus) {\n this.refs.inputField.focus();\n }\n },\n\n getDefaultProps: function () {\n return {\n path: null,\n name: null,\n config: {}\n }\n },\n\n getInitialState: function () {\n return {};\n },\n\n _handleKeyDown: function (e) {\n if (this.props.onKeyDown) this.props.onKeyDown(e);\n },\n\n _onChange: function (event) {\n if (!this.props.config.useBlur) {\n this.props.onUpdate(this.props.name, event.target.value, this.props.path);\n }\n },\n\n _onBlur: function (e) {\n // Perform validation here\n if (this.props.config.useBlur) {\n this.props.onUpdate(this.props.name, e.target.value, this.props.path);\n }\n },\n\n render: function() {\n\n let value = this.props.value;\n if (value) {\n let strValue = String(value);\n if (strValue.indexOf(\"DUPE_\") >= 0) {\n value = strValue.replace(\"DUPE_\", \"\");\n }\n }\n\n return (\n \n )\n }\n\n});\n\nexport default PasswordField;\n","var PointSelectionField = React.createClass({\n _map: null,\n _marker: null,\n\n getDefaultProps: function () {\n return {\n showTiles: true,\n height: 345,\n pointEditMode: false,\n defaultLat: 51.505,\n defaultLng: -0.09\n }\n },\n\n getInitialState: function () {\n return {};\n },\n\n componentDidMount: function () {\n if (!this._map) this.renderEditor();\n },\n\n componentDidUpdate: function () {\n if (!this._map) this.renderEditor();\n\n if (this.props.value) {\n var value = JSON.parse(this.props.value);\n //this._marker = L.marker(value.coordinates).addTo(this._map);\n this._marker.setLatLng(value.coordinates);\n this._map.panTo(new L.LatLng(value.coordinates[0], value.coordinates[1]));\n }\n\n },\n\n componentWillUnmount: function () {\n if (this._map) {\n this._map.off(\"click\", this.onMapClick);\n this._map = null;\n }\n },\n\n _useUsersLocation: function () {\n var startPos;\n var geoSuccess = function (position) {\n startPos = position;\n\n this._handleMapLocationChange(startPos.coords.latitude, startPos.coords.longitude);\n }.bind(this);\n\n var geoError = function (error) {\n\n if (error.code == 1) {\n ewars.notifications.notification(\"fa-bell\", \"Geocoding Error\", \"You have previously selected that you do not want to allow this site to use your location, please clear your browsers location settings in order to use this function.\");\n }\n\n if (error.code == 0) {\n ewars.notifications.notifications(\"fa-bell\", \"Unknown Error\", \"An unknown error occurred while trying to determing your location, please try again later.\");\n }\n\n if (error.code == 2) {\n ewars.notifications.notification(\"fa-bell\", \"Location Unkown\", \"We could not reliably determine your current location.\");\n }\n\n if (error.code == 3) {\n ewars.notifications.notification(\"fa-bell\", \"Geolocation Timeout\", \"Geolocation took too long and has been cancelled, please enter your location manually.\");\n }\n };\n\n navigator.geolocation.getCurrentPosition(geoSuccess, geoError);\n },\n\n _handleInputChange: function (e) {\n var prop = e.target.name;\n var value = e.target.value;\n\n var data = JSON.parse(this.props.value);\n if (prop == \"lat\") data.coordinates[0] = value;\n if (prop == \"lng\") data.coordinates[1] = value;\n\n this.props.onUpdate(this.props.name, JSON.stringify(data));\n },\n\n render: function () {\n if (this.props.value) {\n var value = JSON.parse(this.props.value);\n var lat = value.coordinates[0];\n var lng = value.coordinates[1];\n }\n\n return (\n
    \n
    \n\n
    Double Click on the map to set the location or manually enter lat/lng below
    \n
    \n \n \n \n \n \n \n
    LatLng\n \n
    \n
    \n
    \n )\n },\n\n _createGeoJSON: function (lat, lng) {\n return JSON.stringify({\"type\": \"Point\", \"coordinates\": [lat, lng]});\n },\n\n _handleMapLocationChange: function (lat, lng) {\n this.props.onUpdate(this.props.name, this._createGeoJSON(lat, lng));\n },\n\n renderEditor: function () {\n this._map = mapboxgl.Map(this.refs.mapControl.getDOMNode(), {\n minZoom: 0,\n maxZoom: 20,\n doubleClickZoom: false,\n worldCopyJump: true,\n attributionControl: false,\n scrollWheelZoom: false\n });\n\n\n if (this.props.value) {\n var value = JSON.parse(this.props.value);\n this._marker = L.marker(value.coordinates).addTo(this._map);\n this._map.setView(new L.LatLng(value.coordinates[0], value.coordinates[1]), 8);\n } else {\n this._marker = L.marker([46.232727, 6.134357]).addTo(this._map);\n this._map.setView(new L.LatLng(46.232727, 6.134357), 5);\n }\n\n this._map.on(\"dblclick\", function (e) {\n this._handleMapLocationChange(e.latlng.lat, e.latlng.lng);\n }.bind(this))\n\n }\n});\n\nexport default PointSelectionField;\n","import Button from \"../c.button\";\n\nvar RowField = React.createClass({\n getInitialState: function () {\n return {};\n },\n\n render: function () {\n var childs = [];\n if (this.props.children) {\n\n var childLength = this.props.children.length;\n var colWidth = 12 / childLength;\n var colString = \"col-\" + colWidth + \" column\";\n\n childs = [];\n for (var childIndex in this.props.children) {\n var child = this.props.children[childIndex];\n childs.push(\n
    \n {child}\n
    \n )\n }\n }\n\n return (\n
    \n
    \n {childs}\n\n
    \n\n
    \n
    \n
    \n )\n }\n});\n\nexport default RowField;\n","\n\nvar Handle = React.createClass({\n render: function () {\n var name = __(\"NO_SELECTION\");\n if (this.props.value) {\n let item = this.props.options.find(item => {\n return item[0] == this.props.value;\n });\n if (item) name = item[1];\n }\n return (\n
    \n \n \n \n \n \n \n \n
    {ewars.I18N(name)}\n \n
    \n
    \n )\n }\n});\n\n\nfunction debounce(fn, delay) {\n var timer = null;\n return function () {\n var context = this, args = arguments;\n clearTimeout(timer);\n timer = setTimeout(function () {\n fn.apply(context, args);\n }, delay);\n };\n}\n\n\n\nclass SearchInput extends React.Component {\n static defaultProps = {\n value: ''\n };\n\n constructor(props) {\n super(props);\n\n this.sendForSearch = debounce(this.sendForSearch, 200);\n }\n\n componentDidMount() {\n this._el.focus();\n }\n\n sendForUpdate = (e) => {\n this.props.onChange(e.target.value);\n\n if (e.target.value.length >= 1) {\n this.sendForSearch(e.target.value);\n }\n\n if (e.target.value == \"\") this.sendForSearch(null);\n };\n\n sendForSearch = (searchTerm) => {\n this.props.onSearch(searchTerm);\n };\n\n render() {\n return (\n { this._el = el; }}\n onChange={this.sendForUpdate}\n value={this.props.value} />\n )\n }\n}\n\n\nclass FieldNode extends React.Component {\n\n constructor(props) {\n super(props);\n\n this.state = {\n data: [],\n show: false\n }\n }\n\n _onClick = () => {\n this.setState({\n show: !this.state.show\n })\n this.props.onSelect(this.props.data)\n };\n\n render() {\n var className = \"item\";\n var handleClass = \"locale-tree-node\";\n\n let handler = this._onClick;\n\n return (\n
    \n
    {ewars.I18N(this.props.data[1])}
    \n
    \n )\n }\n}\nvar MultiSelectWrapper = React.createClass({\n getInitialState: function () {\n return {}\n },\n\n _onClick: function () {\n this.props.onClick(this.props.data);\n },\n\n render: function () {\n var iconClass = \"fal\";\n if (this.props.value) {\n if (this.props.value.indexOf(this.props.data[0]) >= 0) {\n iconClass += \" fa-check-square\";\n } else {\n iconClass += \" fa-square\";\n }\n } else {\n iconClass += \" fa-square\"\n }\n return (\n
    \n \n \n \n \n \n \n \n
    \n
    \n \n
    \n
    \n {this.props.children}\n
    \n
    \n )\n }\n});\n\nclass SeachField extends React.Component {\n static defaultProps = {\n formConfig: {},\n config: {\n showSystem: true\n },\n name: null,\n showSystem: true,\n data: {\n o: [],\n os: null,\n c: [],\n l: \"\",\n s: false,\n r: false,\n ml: false\n },\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n showTree: false,\n fullData: [],\n search: \"\",\n placeKey: ewars.utils.uuid()\n }\n }\n\n _clearSearch = () => {\n this.setState({\n search: \"\",\n fullData: this.props.data.o\n })\n };\n\n _onSearchChange = (val) => {\n this.setState({\n search: val\n })\n };\n\n _onSearch = (term) => {\n if (term == null || term == '') {\n this.setState({\n fullData: this.state.options,\n search: ''\n })\n } else {\n let options = this.state.options.filter(function (option) {\n return ewars.I18N(option[1]).toLowerCase().indexOf(term.toLowerCase()) != -1; // returns true or false\n });\n this.setState({\n fullData: options,\n search: term\n })\n }\n };\n\n _toggle = () => {\n this.setState({\n fullData: this.state.options,\n showTree: !this.state.showTree\n })\n };\n handleBodyClick = (evt) => {\n if (this.refs.selector) {\n const area = this.refs.selector.getDOMNode ? this.refs.selector.getDOMNode() : this.refs.selector;\n\n if (!area.contains(evt.target)) {\n this.state.search= \"\";\n this.state.data= this.props.options;\n this.state.showTree = false;\n this.forceUpdate();\n }\n }\n }\n componentWillMount() {\n this.setState({\n fullData: this.props.data.o,\n options: this.props.data.o,\n })\n }\n componentDidMount() {\n window.__hack__.addEventListener('click', this.handleBodyClick);\n }\n componentWillUnmount() {\n window.__hack__.removeEventListener('click', this.handleBodyClick);\n }\n componentWillReceiveProps(nextProps) {\n this.setState({\n // fullData: nextProps.data.o,\n options: nextProps.data.o,\n })\n }\n\n _onNodeSelection = (data) => {\n this.setState({\n search: \"\",\n showTree: !this.state.showTree\n })\n \n this.props.onUpdate(this.props.data.n, data[0],data);\n };\n\n\n render() {\n let rootNodes ;\n var dataClassName = \"ew-select-data \";\n \n if(this.props.styleClass){\n dataClassName = dataClassName+this.props.styleClass\n }\n\n var multiple = this.props.multiple;\n if (multiple) {\n dataClassName += \" multi-select\";\n }\n if (this.props.multiple) {\n rootNodes=this.state.fullData.map(function (option) {\n let id = ewars.utils.uuid();\n let item=;\n item = \n {item}\n \n return item;\n }.bind(this));\n }else{\n rootNodes=this.state.fullData.map(function (item) {\n return ()\n }.bind(this))\n if ((this.props.addNoSelection==undefined || this.props.addNoSelection == true) && !this.props.multiple) {\n rootNodes.unshift();\n }\n }\n return (\n
    \n
    \n {!this.props.multiple ? :null}\n {this.state.showTree || this.props.multiple ?\n
    \n
    \n
    \n \n {this.state.search.length > 0 ?\n
    \n : null}\n
    \n
    \n {rootNodes}\n
    \n : null}\n
    \n
    \n )\n }\n}\n\nexport default SeachField;\n","import Button from \"../c.button\";\nimport TextField from \"./f.text\";\n\nvar OptionRow = React.createClass({\n getInitialState: function () {\n return {};\n },\n\n _onUpdate: function () {\n\n },\n\n _addRow: function () {\n this.props.onAddRow();\n },\n\n _deleteRow: function () {\n this.props.onRemoveRow(this.props.index);\n },\n\n _updateLabel: function (prop, value) {\n this.props.onUpdate(this.props.index, \"LABEL\", value);\n },\n\n _updateValue: function (prop, value) {\n this.props.onUpdate(this.props.index, \"VALUE\", value);\n },\n\n render: function () {\n return (\n \n \n \n \n \n \n \n \n
    \n \n \n
    \n \n \n )\n }\n});\n\nvar SelectFieldOptionsField = React.createClass({\n getInitialState: function () {\n return {\n options: [\n [\"EXAMPLE\", \"Example\"]\n ]\n }\n },\n\n componentWillMount: function () {\n if (this.props.value) {\n var value = JSON.parse(JSON.stringify(this.props.value));\n this.state.options = value;\n }\n },\n\n componentWillReceiveProps: function (nextProps) {\n if (nextProps.value) {\n var value = JSON.parse(JSON.stringify(nextProps.value));\n this.state.options = value;\n }\n },\n\n _addRow: function () {\n this.state.options.push([\"\", \"\"]);\n this.props.onUpdate(this.props.name, this.state.options, this.props.config.path || null);\n },\n\n _removeRow: function (index) {\n var value = JSON.parse(JSON.stringify(this.state.options));\n value.splice(index, 1);\n this.props.onUpdate(this.props.name, value, this.props.config.path || null);\n },\n\n _onUpdate: function (index, type, value) {\n if (type == \"LABEL\") this.state.options[index][1] = value;\n if (type == \"VALUE\") this.state.options[index][0] = value;\n this.props.onUpdate(this.props.name, this.state.options, this.props.config.path || null);\n },\n\n render: function () {\n\n var options = this.state.options.map(function (item, index) {\n return \n }.bind(this));\n\n return (\n
    \n \n \n \n \n \n \n \n {options}\n \n
    ValueLabel
    \n
    \n\n
    \n
    \n )\n }\n});\n\nexport default SelectFieldOptionsField;\n","import Spinner from \"../c.spinner\";\nimport SearchField from \"./f.searchfield\";\nwindow.__hack__ = document.getElementById(\"application\");\n\nvar PRESET_TEMPLATES = {\n form: React.createClass({\n _onClick: function () {\n this.props.onClick(this.props.data);\n },\n\n render: function () {\n var formName, accountName;\n var item = this.props.data[2];\n var className = 'item';\n formName = ewars.I18N(item.name);\n if (item.account) accountName = ewars.I18N(item.account.name);\n if (this.props.value == this.props.data[0]) className += \" active\";\n\n return (\n
    \n
    {formName}
    \n {accountName}\n
    \n )\n }\n }),\n alarm: React.createClass({\n _onClick: function () {\n this.props.onClick(this.props.data);\n },\n\n render: function () {\n var alarmName, accountName;\n var item = this.props.data[2];\n var className = 'item';\n if (this.props.value == this.props.data[0]) className += \" active\";\n alarmName = ewars.I18N(item.name);\n accountName = ewars.I18N(item.account.name);\n\n return (\n
    \n
    {alarmName}
    \n {accountName}\n
    \n )\n }\n }),\n assignment: React.createClass({\n _onClick: function () {\n this.props.onClick(this.props.data);\n },\n\n render: function () {\n let shortName = ewars.I18N(this.props.data[2][0]);\n let longName = this.props.data[2][1];\n longName = longName.split(\",\");\n let longNameDOM = longName.map(function (item) {\n return {item}\n });\n var className = 'item';\n if (this.props.value == this.props.data[0]) className += \" active\";\n\n return (\n
    \n
    {shortName}
    \n
    \n
    \n {longNameDOM}\n
    \n
    \n
    \n )\n }\n })\n};\n\nfunction _recurseOptions(items, label, val, level) {\n var options = [];\n var dashes = \"\";\n\n if (level) {\n let dashes = \"\";\n for (let i = 0; i <= level; i++) {\n dashes += \" \";\n }\n dashes += \"-\";\n }\n\n items.forEach(option => {\n var itemLabel = dashes + \" \";\n itemLabel += ewars.I18N(option[label]);\n\n options.push([option[val], itemLabel]);\n\n if (option.children.length > 0) {\n var subOptions = _recurseOptions(option.children, label, val, level + 1);\n options.push.apply(options, subOptions);\n }\n });\n\n return options;\n}\n\nfunction _processExternalOptions(options, hProp) {\n var optionsMap = {};\n options.forEach(option => {\n if (!optionsMap[option.id]) optionsMap[option.id] = option;\n optionsMap[option.id].children = [];\n });\n\n optionsMap.forEach(option => {\n if (option.parent_id) {\n optionsMap[option.parent_id].children.push(option);\n }\n });\n\n let cleaned = optionsMap.filter(item => {\n if (item.parent_id) return false;\n return true;\n });\n\n return cleaned;\n}\n\nvar Handle = React.createClass({\n render: function () {\n var name = this.props.emptyText ?this.props.emptyText :__(\"NO_SELECTION\");\n\n\n if (this.props.value) {\n let item = this.props.options.find(item => {\n return item[0] == this.props.value;\n });\n if (item) name = item[1];\n }\n\n\n if (this.props.prefixed) {\n let suspects = this.props.prefixed.filter(item => {\n return item[0] == this.props.value;\n })\n if (suspects.length > 0) {\n name = suspects[0][1];\n }\n }\n\n const selectIconStyle = this.props.selectIconStyle || {} ;\n\n return (\n
    \n \n \n \n \n \n \n \n
    {ewars.I18N(name)}\n \n
    \n
    \n )\n }\n});\n\nvar MultiSelectWrapper = React.createClass({\n getInitialState: function () {\n return {}\n },\n\n _onClick: function () {\n this.props.onClick(this.props.data);\n },\n\n render: function () {\n var iconClass = \"fal\";\n if (this.props.value) {\n if (this.props.value.indexOf(this.props.data[0]) >= 0) {\n iconClass += \" fa-check-square\";\n } else {\n iconClass += \" fa-square\";\n }\n } else {\n iconClass += \" fa-square\"\n }\n return (\n
    \n \n \n \n \n \n \n \n
    \n
    \n \n
    \n
    \n {this.props.children}\n
    \n
    \n )\n }\n});\n\nvar Item = React.createClass({\n _onClick: function () {\n this.props.onClick(this.props.data);\n },\n\n render: function () {\n var className = 'item';\n if (this.props.value == this.props.data[0]) className += \" active\";\n\n let onClick = this._onClick;\n if (this.props.multiple) onClick = null;\n\n return (\n
    { ewars.I18N(this.props.data[1])}
    \n )\n }\n});\n\nvar SelectField = React.createClass({\n _isLoaded: false,\n _initialLoaded: false,\n\n PropTypes: {\n config: React.PropTypes.object\n },\n\n getDefaultProps: function () {\n return {\n path: null,\n name: null,\n config: {}\n }\n },\n\n getInitialProps: function () {\n return {\n name: null,\n config: {\n multiple: false,\n path: null,\n groups: false\n },\n emptyText: __(\"NO_SELECTION\")\n }\n },\n\n getInitialState: function () {\n return {\n options: [],\n rawOptions: [],\n showOptions: false,\n placeKey: ewars.utils.uuid()\n }\n },\n\n _init: function (props) {\n if (props.value && props.config.optionsSource) {\n if (props.config.multiple) {\n this._initialLoaded = true;\n if (this.isMounted()) this.forceUpdate();\n this._toggle(null);\n return;\n }\n var resource = props.config.optionsSource.resource.toLowerCase();\n var select = [props.config.optionsSource.labelSource, props.config.optionsSource.valSource];\n if (props.config.optionsSource.select) {\n select = props.config.optionsSource.select;\n }\n\n if (this.props.config.optionsSource.additionalProperties) {\n select = select.concat(this.props.config.optionsSource.additionalProperties);\n }\n\n let isPrefix;\n if (props.config.optionsSource.prefixed) {\n let suspects = props.config.optionsSource.prefixed.filter(item => {\n return item[0] == props.value;\n });\n if (suspects.length > 0) isPrefix = true;\n }\n\n if (!isPrefix) {\n ewars.tx(\"com.ewars.resource\", [resource, props.value, select, null])\n .then(function (resp) {\n if (resp) {\n this.state.options = [[resp[props.config.optionsSource.valSource], ewars.I18N(resp[props.config.optionsSource.labelSource])]];\n }\n\n if (props.config) {\n if (props.config.optionsSource) {\n if (props.config.optionsSource.additional) {\n props.config.optionsSource.additional.forEach(option => {\n var optionValue = option[0];\n if (optionValue == null) optionValue = \"null\";\n this.state.options.unshift([optionValue, option[1]]);\n });\n }\n }\n }\n\n this._initialLoaded = true;\n if (this.isMounted()) this.forceUpdate();\n }.bind(this))\n } else {\n this._initialLoaded = true;\n }\n }\n },\n\n componentWillMount: function () {\n this._id = ewars.utils.uuid();\n if (this.props.config && this.props.config.optionsSource && this.props.value) {\n this._init(this.props);\n } else {\n this._initialLoaded = true;\n this.state.options = this.props.config.options;\n }\n },\n\n componentWillReceiveProps: function (nextProps) {\n if (nextProps.config && nextProps.config.optionsSource && nextProps.value) {\n if (this.props.value != nextProps.value) this._init(nextProps);\n } else {\n this._initialLoaded = true;\n this.state.options = nextProps.config.options;\n }\n },\n\n componentDidMount: function () {\n window.__hack__.addEventListener('click', this.handleBodyClick);\n },\n\n componentWillUnmount: function () {\n window.__hack__.removeEventListener('click', this.handleBodyClick);\n },\n\n handleBodyClick: function (evt) {\n if (this.refs.selector) {\n const area = this.refs.selector.getDOMNode ? this.refs.selector.getDOMNode() : this.refs.selector;\n\n if (!area.contains(evt.target)) {\n this.state.showOptions = false;\n this.forceUpdate();\n }\n }\n },\n\n handleClick: function (e) {\n e.stopPropagation();\n },\n\n _selectNone: function (e) {\n e.preventDefault();\n\n let name = this.props.config.nameOverride || this.props.name;\n\n this.props.onUpdate(name, [], this.props.path, null);\n },\n\n _selectAll: function (e) {\n e.preventDefault();\n\n let name = this.props.config.nameOverride || this.props.name;\n\n let value;\n if (this.props.config.optionsSource) {\n value = this.state.rawOptions.map(function (item) {\n return item[this.props.config.optionsSource.valSource];\n }.bind(this));\n } else {\n value = this.props.config.options.map(function (item) {\n return item[0];\n }.bind(this))\n }\n\n this.props.onUpdate(name, value, this.props.path, null);\n },\n\n _onPrefixSelect: function (e) {\n if (this.props.readOnly) return;\n let val = e.target.getAttribute('data-value');\n\n let name = this.props.config.nameOverride || this.props.name;\n this.state.showOptions = false;\n\n this.props.onUpdate(name, val, this.props.path, null);\n },\n\n onChange: function (item) {\n if (this.props.readOnly) return;\n this.state.showOptions = false;\n\n let name = this.props.config.nameOverride || this.props.name;\n\n let path = this.props.path || this.props.name;\n\n var node = item;\n if (this.props.config.optionsSource) {\n node = this.state.rawOptions.find(result => {\n if (result[this.props.config.optionsSource.valSource] == item[0]) return true;\n });\n }\n\n if (!this.props.config.multiple) {\n if (this.props.config) this.props.onUpdate(name, item[0], path, node);\n if (!this.props.config) this.props.onUpdate(name, item[0], path, node);\n } else {\n let newVal = [];\n if (this.props.value && this.props.value.constructor === Array) {\n newVal = this.props.value;\n }\n\n if (newVal.indexOf(item[0]) < 0) {\n newVal.push(item[0]);\n } else {\n let tmp = newVal.filter(p => {\n if (p == item[0]) return false;\n return true;\n });\n newVal = tmp;\n }\n\n this.props.onUpdate(name, newVal, path, node);\n\n }\n },\n\n _processConfig: function () {\n var config = {};\n if (this.props.config) config = this.props.config;\n\n if (config.multiple == undefined || config.multiple == null) config.multiple = false;\n return config;\n },\n\n _getOptionDisplay: function () {\n var result;\n for (var i in this.state.options) {\n if (this.state.options[i][0] == this.props.value) {\n result = this.state.options[i][1];\n }\n }\n return result;\n },\n\n _getOptions: function () {\n if (this.props.options) return this.props.options;\n if (this.props.config.options) return this.props.config.options;\n if (this.state.options) return this.state.options;\n return [];\n },\n\n _toggle: function (e) {\n if (e) e.stopPropagation();\n this.state.showOptions = this.state.showOptions ? false : true;\n\n this.forceUpdate();\n\n if (this.props.config.optionsSource && this._isLoaded) {\n var options = [];\n\n if (this.props.config.optionsSource.hierarchical) {\n var optionsH = _processExternalOptions(this.state.rawOptions, this.props.config.optionsSource.hierarchyProp);\n options = _recurseOptions(optionsH, this.props.config.optionsSource.labelSource, this.props.config.optionsSource.valSource, 0);\n } else {\n\n this.state.rawOptions.forEach((item) => {\n options.push([\n item[this.props.config.optionsSource.valSource],\n ewars.I18N(item[this.props.config.optionsSource.labelSource]),\n item\n ])\n });\n\n if (this.props.config) {\n if (this.props.config.optionsSource) {\n if (this.props.config.optionsSource.additional) {\n props.config.optionsSource.additional.forEach(option => {\n var optionValue = option[0];\n if (optionValue == null) optionValue = \"null\";\n options.unshift([optionValue, option[1]]);\n });\n }\n }\n }\n }\n\n this.state.options = options;\n if (this.isMounted()) this.forceUpdate();\n }\n\n if (this.props.config.optionsSource && !this._isLoaded) {\n // We need to load the options\n var resource = this.props.config.optionsSource.resource.toLowerCase();\n var select = [this.props.config.optionsSource.labelSource, this.props.config.optionsSource.valSource];\n if (this.props.config.optionsSource.select) {\n select = this.props.config.optionsSource.select;\n }\n\n if (this.props.config.optionsSource.additionalProperties) {\n select = select.concat(this.props.config.optionsSource.additionalProperties);\n }\n\n var join = this.props.config.optionsSource.join || null;\n var orderby = this.props.config.optionsSource.orderby || null;\n \n ewars.tx(\"com.ewars.query\", [resource, select, this.props.config.optionsSource.query, orderby , null, null, join])\n .then(function (resp) {\n var options = [];\n\n if (this.props.config.optionsSource.hierarchical) {\n var optionsH = _processExternalOptions(resp, this.props.config.optionsSource.hierarchyProp);\n options = _recurseOptions(optionsH, this.props.config.optionsSource.labelSource, this.props.config.optionsSource.valSource, 0);\n } else {\n\n resp.forEach(item => {\n options.push([\n item[this.props.config.optionsSource.valSource],\n ewars.I18N(item[this.props.config.optionsSource.labelSource]),\n item\n ])\n });\n\n if (this.props.config) {\n if (this.props.config.optionsSource) {\n if (this.props.config.optionsSource.additional) {\n this.props.config.optionsSource.additional.forEach(option => {\n var optionValue = option[0];\n if (optionValue == null) optionValue = \"null\";\n options.unshift([optionValue, option[1]]);\n });\n }\n }\n }\n\n this.state.rawOptions = resp;\n }\n\n this.state.options = options;\n this._isLoaded = true;\n if (this.isMounted()) this.forceUpdate();\n }.bind(this))\n }\n },\n\n render: function () {\n var dataClassName = \"ew-select-data \";\n \n if(this.props.styleClass){\n dataClassName = dataClassName+this.props.styleClass\n }\n\n if (!this._initialLoaded) {\n return (\n
    \n
    \n \n
    \n
    \n )\n }\n\n\n var multiple = this.props.config.multiple;\n if (multiple) {\n dataClassName += \" multi-select\";\n }\n\n if (this.props.config) {\n if (this.props.config.multiple != undefined || this.props.config.multiple != null) {\n multiple = this.props.config.multiple;\n }\n }\n\n var config = this._processConfig();\n\n if (this.props.readOnly && !multiple) {\n var value = ewars.I18N(this._getOptionDisplay());\n return (\n \n )\n }\n if (this.props.config.is_search_field == true) {\n return (\n {\n this.onChange(dataArray || []);\n }}\n addNoSelection={this.props.addNoSelection}\n multiple={this.props.config.multiple}\n styleClass={this.props.styleClass}\n />\n )\n }\n var rawOptions = this._getOptions();\n\n let ItemTemplate = this.props.ItemTemplate || this.props.config.ItemTemplate;\n let templateName = (this.props.template || this.props.config.template) || null;\n if (templateName) ItemTemplate = PRESET_TEMPLATES[templateName];\n if (!ItemTemplate) ItemTemplate = Item;\n\n let options = rawOptions.map(option => {\n let id = ewars.utils.uuid();\n\n let item;\n if (ItemTemplate) {\n item = (\n \n )\n }\n\n if (multiple) {\n item = (\n \n {item}\n \n )\n }\n\n return item;\n });\n\n\n let prefixed = [];\n if (this.props.config.optionsSource) {\n if (this.props.config.optionsSource.prefixed) {\n prefixed = this.props.config.optionsSource.prefixed;\n this.props.config.optionsSource.prefixed.forEach(item => {\n options.unshift(\n {item[1]}\n )\n\n rawOptions.push(item);\n })\n }\n }\n\n if (!multiple && (!this.props.hasOwnProperty('addNoSelection') || this.props.addNoSelection == true)) {\n options.unshift({__(\"NO_SELECTION\")});\n }\n\n if (this.props.config.optionsSource && !this._isLoaded) {\n options = ;\n }\n\n var onClick = multiple ? null : this.handleBodyClick;\n var show = multiple ? true : this.state.showOptions;\n let handleClass = \"ew-select\";\n if (show) handleClass += \" ew-select-open\";\n var handleStyle;\n if (this.props.config.handleWidth)\n handleStyle={ width: this.props.config.handleWidth}\n\n return (\n
    \n {!multiple ?\n \n : null}\n {show ?\n
    \n {options}\n
    \n : null}\n {multiple && !this.props.readOnly ?\n \n : null}\n
    \n )\n }\n});\n\nexport default SelectField;\n","var TextInputField = React.createClass({\n propTypes: {\n _onChange: React.PropTypes.func,\n placeholder: React.PropTypes.string,\n name: React.PropTypes.string,\n readOnly: React.PropTypes.bool\n },\n\n _options: {\n\n },\n\n componentWillMount: function () {\n this.state.value = this.props.value;\n },\n\n componentDidMount: function () {\n if (this.props.focus) {\n this.refs.inputField.getDOMNode().focus();\n }\n },\n\n componentWillReceiveProps: function (nextProps) {\n this.state.value = nextProps.value;\n },\n\n getInitialState: function () {\n return {\n value: \"\"\n };\n },\n\n _handleKeyDown: function (e) {\n if (this.props.onKeyDown) this.props.onKeyDown(e);\n },\n\n _onBlur: function (event) {\n if (this.props.config.trigger != \"change\") {\n if (this.state.value != this.props.value) {\n this.props.onUpdate(this.props.name, this.state.value);\n }\n }\n },\n\n _onChange: function (e) {\n var value = e.target.value;\n value = value.replace(/\\s/g, \"_\").toLowerCase();\n value = value.replace(\"-\", \"_\");\n value = value.replace(\";\", \"_\");\n\n if (this.props.config.trigger == \"change\") {\n this.props.onUpdate(this.props.name, value)\n } else {\n this.setState({\n value: value\n })\n }\n },\n\n render: function() {\n\n return (\n \n )\n\n }\n\n});\n\nexport default TextInputField;\n","var SwitchField = React.createClass({\n getInitialState: function () {\n return {};\n },\n\n onChange: function () {\n let value;\n if ([true, \"true\"].indexOf(this.props.value) >= 0) value = true;\n if ([false, \"false\", -1, 0, \"\"].indexOf(this.props.value) >= 0) value = false;\n\n console.log(value);\n if (this.props.config && this.props.config.path) {\n this.props.onUpdate(this.props.name, !value, this.props.config.path);\n } else {\n this.props.onUpdate(this.props.name, !value);\n }\n },\n\n render: function () {\n var value = false;\n if (this.props.value) value = true;\n\n var name = ewars.utils.uniqueId(\"switch_\");\n\n let className = \"fal fa-toggle-off\";\n if (value) className = \"fal fa-toggle-on\";\n\n let style = {};\n if (value) style.color = \"green\";\n\n return (\n
    \n \n
    \n )\n }\n});\n\nexport default SwitchField;\n","import FileUploadField from \"../fields/f.file_upload\";\n\nconst allowedFileTypes = \"image/png,image/jpeg,image/jpg\"\n\nconst TextField = React.createClass({\n propTypes: {\n _onChange: React.PropTypes.func,\n placeholder: React.PropTypes.string,\n name: React.PropTypes.string,\n readOnly: React.PropTypes.bool\n },\n\n _options: {\n\n },\n\n componentDidMount: function () {\n if (this.props.focus) {\n this.refs.inputField.focus();\n }\n },\n\n getDefaultProps: function () {\n return {\n placeholder: __(\"ENTER_TEXT\"),\n path: null,\n name: null,\n config: {}\n }\n },\n\n getInitialState: function () {\n return {};\n },\n\n _handleKeyDown: function (e) {\n if (this.props.onKeyDown) this.props.onKeyDown(e);\n },\n\n _onChange: function (event) {\n if (!this.props.config.useBlur) {\n this.props.onUpdate(this.props.config.nameOverride || this.props.name, event.target.value, this.props.path || this.props.name);\n }\n },\n\n _onBlur: function (e) {\n // Perform validation here\n if (this.props.config.useBlur) {\n this.props.onUpdate(this.props.config.nameOverride || this.props.name, e.target.value, this.props.path);\n }\n },\n\n _fileUpped: function(name, value) {\n this.props.onUpdate(this.props.name, value, this.props.path || this.props.name);\n },\n\n render: function() {\n\n let value = this.props.value;\n if (value) {\n let strValue = String(value);\n if (strValue.indexOf(\"DUPE_\") >= 0) {\n value = strValue.replace(\"DUPE_\", \"\");\n }\n }\n\n return (\n
    \n {this.props.config.isUpload ? \n
    \n \n
    \n :null}\n \n {this.props.selectBoxOptions ? \n \n {this.props.selectBoxOptions.map((folder,index) => {\n return(\n \n )\n })}\n \n :null}\n {this.props.name == 'box_shadow'?\n
    \n

    ( e.g. box-shadow = \"x-offset y-offset blur spread color\" ( box-shadow = 1px 1px 1px 1px #333 ))

    \n
    \n :null}\n
    \n )\n }\n\n});\n\nexport default TextField;\n","var _languages = [\"en\", \"fr\", \"ar\"];\n\nvar LanguageNode = React.createClass({\n _onClick: function () {\n this.props.onClick(this.props.value);\n },\n\n render: function () {\n var className = __(\"LANGUAGE\");\n if (this.props.active) className += \" active\";\n\n return (\n
  • \n
    {this.props.value}
    \n
  • \n )\n }\n});\n\nvar TextAreaField = React.createClass({\n _value: null,\n\n getInitialProps: function () {\n return {\n config: {\n i18n: false,\n markdown: false\n }\n }\n },\n\n getInitialState: function () {\n return {\n curLang: \"en\"\n };\n },\n\n componentWillMount: async function () {\n // A little clean up, fix labels which are not dicts to dicts\n let languages = [];\n if (window.localStorage.language_array) {\n languages = JSON.parse(window.localStorage.language_array);\n } else {\n let resp = await ewars.tx(\"com.ewars.language.getLanguage\",[{\"filters\":{status:{booleaneq:true}}}]);\n if (resp.results) {\n languages = resp.results;\n window.localStorage.language_array=JSON.stringify(resp.results);\n }\n }\n _languages = []\n for (let data of languages) {\n let array = []; array.push(data['code']);\n let alraedyExsits = false;\n _languages.map(function (value, index) {\n if (value[0] === data['code']) {\n alraedyExsits = true\n }\n });\n if (!alraedyExsits && data[\"isActive\"]) {\n _languages.push(array)\n }\n }\n },\n\n componentWillReceiveProps: function (nextProps) {\n },\n\n onChange: function (event) {\n var path = this.props.config ? this.props.config.path : null;\n\n if (this.props.config.i18n) {\n this._value[this.state.curLang] = event.target.value;\n this.props.onUpdate(this.props.name, this._value, path);\n } else {\n this.props.onUpdate(this.props.name, event.target.value, path);\n }\n },\n\n _handleLanguageChange: function (lang) {\n this.setState({\n curLang: lang\n })\n },\n\n render: function () {\n this._value = this.props.value;\n var viewValue = this.props.value;\n\n if (this.props.config.i18n) {\n\n if (!this.props.value) {\n this._value = {en: \"\", fr: null};\n }\n\n if (typeof this.props.value == \"string\") {\n this._value = {\n en: this.props.value,\n fr: null\n }\n }\n\n if (!this._value[this.state.curLang]) this._value[this.state.curLang] = \"\";\n viewValue = this._value[this.state.curLang];\n }\n\n if (this.props.config.i18n) {\n var nodes = _languages.map(language => {\n return \n });\n\n nodes.unshift(\n
  • \n
    \n
  • \n )\n }\n\n if (!viewValue) viewValue = \"\";\n\n return (\n
    \n {this.props.config.i18n ?\n
    \n
      \n {nodes}\n
    \n
    \n : null}\n \n {this.props.config.markdown ?\n

     {__(\"FIELD_SUPPORT_MARKDOWN\")}

    \n : null}\n
    \n )\n }\n\n});\n\nexport default TextAreaField;\n","const STYLE = {\n fontSize: \"12px\",\n border: \"1px solid #e3e7e9\",\n padding: \"7px 5px 7px 5px\",\n margin: \"0px\",\n color: \"#525252\"\n}\n\nclass TimeField extends React.Component {\n constructor(props) {\n super(props);\n }\n\n _onChange = (e) => {\n if (this.props.onUpdate) this.props.onUpdate(this.props.name, e.target.value);\n if (this.props.onChange) this.props.onChange(this.props.n, e.target.value);\n\n };\n\n render() {\n\n return (\n \n )\n\n }\n}\n\nexport default TimeField;\n","\n// need to extend leaflet with TopoJSON support\nif (window.L != undefined && window.L != null) {\n L.TopoJSON = L.GeoJSON.extend({\n addData: function (jsonData) {\n if (jsonData.type === \"Topology\") {\n for (key in jsonData.objects) {\n geojson = topojson.feature(jsonData, jsonData.objects[key]);\n L.GeoJSON.prototype.addData.call(this, geojson);\n }\n }\n else {\n L.GeoJSON.prototype.addData.call(this, jsonData);\n }\n }\n });\n}\n\nvar TopoJSONField = React.createClass({\n getInitialState: function () {\n return {};\n },\n\n _render: function () {\n },\n\n componentWillReceiveProps: function () {\n\n },\n\n shouldComponentUpdate: function (nextProps, nextState) {\n return false;\n },\n\n componentDidMount: function () {\n this.renderEditor();\n },\n\n componentDidUpdate: function () {\n this.renderEditor();\n },\n\n componentWillUnmount: function () {\n this.map.off(\"click\", this.onMapClick);\n this.map = null;\n },\n\n onChange: function (name, value) {\n this.props.onChange(name, value);\n },\n\n render: function () {\n return (\n
    \n )\n },\n\n renderEditor: function () {\n\n var map = this.map = L.map(this.getDOMNode(), {\n minZoom: 2,\n maxZoom: 20,\n attributionControl: false\n });\n\n var topoLayer = new L.TopoJSON();\n\n topoLayer.addData(this.props.value);\n topoLayer.addTo(map);\n\n map.fitWorld();\n }\n\n});\n\nexport default TopoJSONField;\n","\n\nconst elementStyle = {\n padding: \"10px\",\n textAlign: \"center\",\n width: \"49%\",\n margin: \"2px\",\n background: \"rgb(242, 242, 242)\",\n borderRadius: \"3px\"\n}\n\n\n\nclass TotalFormulaHelpField extends React.Component {\n\n\n constructor(props) {\n super(props);\n\n this.state = {\n data: []\n }\n\n }\n\n componentWillReceiveProps = (nextProps) => {\n this.state.data = nextProps.value;\n };\n\n render() {\n let options = this.props.options;\n return (\n \n
    \n {options.map((item) => {\n return
    {ewars.I18N(item)}
    \n })}\n
    \n \n )\n }\n}\n\nexport default TotalFormulaHelpField;\n","import { Layout, Row, Cell } from \"../layout\";\nimport CommonCheckbox from \"../c.cmp.checkbox\"\n\nimport EditableList from \"../c.editable_list\";\nimport Colour from \"./f.colour\";\nimport TextField from \"./f.text\";\nimport NumericField from \"./f.numeric\";\nimport DateUtils from \"../../documents/utils/DateUtils\";\nimport ewars from \"../../ewars/app\";\n\nconst ACTIONS = [\n { icon: \"fa-plus\", action: \"ADD\", tooltip: __(\"ADD_THRESHHOLD\") },\n { icon: \"fa-minus\", action: \"REMOVE\", tooltip: __(\"REMOVE_THRESHHOLD\") },\n { icon: \"fa-caret-up\", action: \"MOVE_UP\", tooltip: __(\"MOVE_UP\") },\n { icon: \"fa-caret-down\", action: \"MOVE_DOWN\", tooltip: __(\"MOVE_DOWN\") }\n];\n\nconst SEP_STYLE = {\n textAlign: \"center\",\n lineHeight: \"30px\"\n};\n\nconst fieldHeaderStyle = {\n fontWeight: \"bolder\",\n padding: \"5px\"\n}\nconst mapperTitle = {\n fontWeight: \"bolder\",\n paddingTop: \"5px\",\n paddingLeft: \"10px\"\n}\nconst mapperTableHeader = {\n paddingTop: \"5px\",\n background: \"#edf1f4\",\n paddingBottom: \"30px\"\n}\n\nlet NOTE_STYLE = {\n \n border : \"none\",\n fontStyle: \"italic\",\n fontSize : \"11px\",\n \n};\n\nlet layoutStyle = {\n display: \"flex\",\n flexDirection: \"column\"\n}\n\nlet listStyle = {\n marginBottom: \"0px\",\n overflowY: \"auto\",\n maxHeight: \"208px\",\n padding: \"2px\"\n}\n\n\n\n\nclass ValueMapperField extends React.Component {\n\n\n constructor(props) {\n super(props);\n\n this.state = {\n data: [],\n group_by : null,\n message : \"\"\n }\n\n }\n\n _onFetch = () => {\n this.props.onUpdate(this.props.name, { \"data\": this.state.data, \"remove\": false, \"fetch\": true ,\"group_by\" : this.state.group_by });\n }\n\n _onAdd = () => {\n let newArray = this.state.data;\n let element = [\"\", \"\", false];\n newArray.push(element);\n this.props.onUpdate(this.props.name, { \"data\": newArray, \"remove\": false });\n\n }\n\n _onChangeValue = (idx, change) => {\n let newArray = this.state.data;\n let element = newArray[idx];\n element[1] = change;\n newArray[idx][1] = change;\n newArray = this._unique(newArray);\n this.props.onUpdate(this.props.name, { \"data\": newArray, \"remove\": false });\n\n }\n\n _onChangeKey = (idx, change) => {\n let newArray = this.state.data;\n let element = newArray[idx];\n element[0] = change;\n newArray[idx][0] = change;\n newArray = this._unique(newArray);\n this.props.onUpdate(this.props.name, { \"data\": newArray, \"remove\": false });\n\n }\n\n toggleCheckbox = (idx, change) => {\n let newArray = this.state.data;\n let flag = newArray[idx][2];\n flag = !flag;\n newArray[idx][2] = flag;\n this.props.onUpdate(this.props.name, { \"data\": newArray, \"remove\": false });\n\n }\n\n _onRemove = (idx) => {\n let newArray = this.state.data;\n let arr = [];\n if (this.state.data.length > 1) {\n if (idx == 0) {\n arr = newArray.slice(1, newArray.length);\n }\n else if (idx == newArray.length) {\n arr = newArray.slice(0, newArray.length - 1);\n } else {\n let arr1 = newArray.slice(0, idx);\n let arr2 = newArray.slice(idx + 1, newArray.length);\n arr = arr1.concat(arr2);\n }\n }\n this.props.onUpdate(this.props.name, { \"data\": arr, \"remove\": true });\n\n }\n\n _onRemoveAll = () => {\n this.props.onUpdate(this.props.name, { \"data\": [], \"remove\": true });\n }\n\n _unique = function (a) {\n for (var i = 0; i < a.length; ++i) {\n for (var j = i + 1; j < a.length; ++j) {\n if (a[i][0] === a[j][0])\n a.splice(j--, 1);\n }\n }\n return a;\n }\n componentWillReceiveProps = (nextProps) => {\n let options = nextProps.value.data || [];\n if (nextProps.value.remove) {\n this.state.data = options;\n this.state.data = this._unique(this.state.data);\n }\n else {\n if (this.state.data && this.state.data.length > 0) {\n this.state.data = this.state.data.concat(options);\n } else {\n this.state.data = options;\n }\n this.state.data = this._unique(this.state.data);\n }\n if(nextProps.value.hasOwnProperty(\"group_by\")){\n this.state.group_by = nextProps.value.group_by;\n }\n if(nextProps.value.hasOwnProperty(\"message\")){\n this.state.message = nextProps.value.message;\n }\n \n };\n\n componentWillMount = () => {\n let options = this.props.value.data || [];\n if (this.props.value.remove) {\n this.state.data = options;\n this.state.data = this._unique(this.state.data);\n }\n else {\n if (this.state.data && this.state.data.length > 0) {\n this.state.data = this.state.data.concat(options);\n } else {\n this.state.data = options;\n }\n this.state.data = this._unique(this.state.data);\n }\n if(this.props.value.hasOwnProperty(\"group_by\")){\n this.state.group_by = this.props.value.group_by;\n }else{\n this.state.group_by = this.props.data.ds_group_by;\n }\n \n };\n\n\n render() {\n let options = [];\n let className = \"iw-list-edit-item\";\n if(this.state.data.length > 0){\n options.push(\n \n
    \n {__(\"ORIGINAL_VALUE\")}\n
    \n
    \n \n \n
    \n {__(\"ALIAS\")}\n
    \n
    \n\n
    )\n }\n\n this.state.data.forEach((el, idx) => {\n\n options.push(\n \n \n \n \n to\n\n \n \n \n \n \n \n \n { this._onRemove(idx) }}\n label={__(\"REMOVE\")} />\n \n \n\n )\n })\n return (\n
    \n\n
    \n
    \n
    \n
    \n {__(\"GROUP_BY_COLUMN_VALUE\")}\n
    \n\n
    \n
    \n \n \n \n
    \n
    \n
    \n {options.length > 0 ? \n
    \n {options}\n
    \n :\n
    {this.state.message}
    \n }\n
    \n\n
    \n\n\n
    \n )\n }\n}\n\nexport default ValueMapperField;\n","export { default as AssignmentField } from \"./f.assignment\";\nexport { default as PasswordField } from \"./f.password\";\nexport { default as MarginField } from \"./f.margin\";\nexport { default as DisplayField } from \"./f.display\";\nexport { default as DisplayCalculatedField } from \"./f.display.calculated\";\n// export { default as MainFormField } from \"./f.main_form_field\";\nexport { default as FormField } from \"./f.form_field\";\nexport { default as GeometryField } from \"./f.geometry\";\nexport { default as HeaderField } from \"./f.header\";\nexport { default as LocationField } from \"./f.location\";\nexport { default as MatrixField } from \"./f.matrix\";\nexport { default as NotImplemented } from \"./f.not_implemented\";\nexport { default as NumericField } from \"./f.numeric\";\nexport { default as PointField } from \"./f.point\";\nexport { default as RowField } from \"./f.row\";\n//export { default as FormSelectField } from \"./f.select.form\";\nexport { default as SelectField } from \"./f.select\";\nexport { default as MultiSelectField } from \"./f.multi_select\";\nexport { default as SlugField } from \"./f.slug\";\nexport { default as SwitchField } from \"./f.switch\";\nexport { default as TextField } from \"./f.text\";\nexport { default as TextAreaField } from \"./f.textarea\";\nexport { default as TopoJSONField } from \"./f.topojson\";\nexport { default as LocationGroupField } from \"./f.location_group\";\nexport { default as LocationInputField } from \"./f.location_input\";\nexport { default as LatLngField } from \"./f.lat_lng\";\nexport { default as DateField } from \"./f.date\";\nexport { default as DOMSizeField } from \"./f.dom_size_field\";\nexport { default as ConditionsField } from \"./f.conditions\";\nexport { default as LanguageStringField } from \"./f.language_string\";\nexport { default as CalcFieldDefinition } from \"./f.calc_field_definition\";\nexport { default as LinkedListsField } from \"./f.linked_lists\";\nexport { default as ColourField } from \"./f.colour\";\nexport { default as ColourThresholdsField } from \"./f.colour_thresholds\";\nexport { default as IndicatorField } from \"./f.indicator\";\nexport { default as HTMLField } from \"./f.html\";\nexport { default as ButtonGroupField } from \"./f.button_group\";\nexport { default as FileField } from \"./f.file\";\nexport { default as FormFieldField } from \"./f.form_field\";\nexport { default as SelectFieldOptionsField } from \"./f.select.form.field.options\";\nexport { default as IndicatorDefinition } from \"./f.indicator_definition\";\nexport { default as TimeField } from \"./f.time\";\nexport { default as FormFieldSelect } from \"./f.form_field_select\";\nexport { default as FormFieldCondition } from \"./f.form_field_condition\";\nexport { default as MultipleLocationsField } from \"./f.multiple_location\";\nexport { default as IndicatorRelatedForms } from \"./f.indicator_related_forms\";\nexport { default as MultipleAlarmsField } from \"./f.multiple_alarm\";\nexport { default as ValueMapperField } from \"./f.value_mapper\";\nexport { default as TotalFormulaHelpField } from \"./f.total_formula_helper\";\nexport { default as FileUploadField } from \"./f.file\";\nexport { default as SearchField } from \"./f.searchfield\";\n\n","var TreeNodeComponent = React.createClass({\n _hasLoaded: false,\n\n getInitialState: function () {\n return {\n children: [],\n showChildren: false\n };\n },\n\n onCaretClick: function (e) {\n e.stopPropagation();\n e.preventDefault();\n this.toggleCaret();\n },\n\n toggleCaret: function () {\n if (this._hasLoaded) {\n this.setState({\n showChildren: this.state.showChildren ? false : true\n });\n return;\n }\n\n var self = this;\n ewars._connect().then(function (session) {\n session.call(\"com.ewars.indicators\", [self.props.data.id])\n .then(function (resp) {\n this._hasLoaded = true;\n\n if (resp.d.length > 0) {\n this.setState({\n children: resp.d,\n showChildren: true\n })\n } else {\n this.forceUpdate();\n }\n\n }.bind(self))\n })\n\n },\n\n _onLabelClick: function (e) {\n e.stopPropagation();\n e.preventDefault();\n\n if (this.props.data.type == \"node\") {\n this.props.onNodeSelect(this.props.data);\n } else {\n this.toggleCaret();\n }\n },\n\n _hasChildren: function () {\n if (this.props.data.child_count > 0) return true;\n return false;\n },\n\n _hasIndicators: function () {\n if (this.props.data.indicator_count > 0) return true;\n return false;\n },\n\n _processChildren: function () {\n var childs = [];\n\n for (var i in this.state.children) {\n var child = this.state.children[i];\n\n childs.push(\n \n )\n }\n\n return childs;\n },\n\n render: function () {\n\n var childs;\n if (this._hasChildren() || this._hasIndicators()) {\n childs = this._processChildren();\n }\n\n var iconClass = \"fal fa-circle\";\n if (this.props.data.type == \"folder\") iconClass = \"fal fa-caret-right\";\n if (this.props.data.type == \"folder\" && this._hasLoaded && this.state.showChildren) iconClass = \"fal fa-caret-down\";\n\n var nodeName = ewars.formatters.I18N_FORMATTER(this.props.data.name);\n\n return (\n
  • \n
    \n
    {nodeName}
    \n {this.state.showChildren ?\n
    \n
      \n {childs}\n
    \n
    \n : null}\n
  • \n )\n }\n});\n\nexport default TreeNodeComponent;\n","import ContextMenu from \"../../c.context_menu\";\n\nclass IndicatorNode extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = {\n showContext: false\n }\n }\n\n componentWillMount() {\n window.__hack__.addEventListener(\"click\", this._onBodyClick);\n }\n\n componentWillUnmount() {\n window.__hack__.removeEventListener(\"click\", this._onBodyClick);\n }\n\n _onBodyClick = (evt) => {\n if (!this.refs.item.contains(evt.target)) {\n this.setState({\n showContext: false\n })\n }\n };\n\n _onContext = (e) => {\n e.preventDefault();\n this.setState({\n showContext: true\n })\n };\n\n _onContextAction = (action) => {\n this.setState({\n showContext: false\n });\n this.props.onAction(action, this.props.data);\n };\n\n _onClick = () => {\n this.props.onAction(\"CHECK\", this.props.data);\n };\n\n _onCheck = () => {\n this.props.onAction(\"CHECK\", this.props.data);\n };\n\n _onSelect = () => {\n this.props.onAction(\"INDICATOR_SELECT\", this.props.data);\n };\n\n _dragStart = (e) => {\n e.dataTransfer.setData(\"item\", JSON.stringify(this.props.data));\n };\n\n render() {\n let label = ewars.I18N(this.props.data.name);\n\n let icon;\n if (this.props.allowCheck) {\n icon = \"fal fa-square\";\n if (this.props.checked.indexOf(this.props.data.uuid) >= 0) icon = \"fal fa-check-square\";\n }\n\n let className = \"block-content\";\n className = className + (this.props.data.status == \"ACTIVE\" ? \" status-green\" : \" status-red\");\n\n return (\n
    \n
    \n
    \n {this.props.allowCheck ?\n
    \n \n
    \n : null}\n
    {label}
    \n
    \n {this.props.actions && this.state.showContext ?\n \n : null}\n
    \n
    \n )\n }\n}\n\nclass IndicatorFolderNode extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = ewars.g[\"FOLDER_\" + this.props.data.id] || {\n showChildren: false,\n data: null,\n showContext: false\n }\n }\n\n componentWillMount() {\n window.__hack__.addEventListener(\"click\", this._onBodyClick);\n ewars.subscribe(\"RELOAD_INDICATORS\", this._reload);\n }\n\n _onBodyClick = (evt) => {\n if (!this.refs.item.contains(evt.target)) {\n this.setState({\n showContext: false\n })\n }\n };\n\n _reload = () => {\n ewars.tx(\"com.ewars.indicators\", [this.props.data.id])\n .then(function (resp) {\n this.setState({\n data: resp\n })\n }.bind(this))\n };\n\n getChildren = () => {\n if (this.state.data) {\n this.setState({\n showChildren: !this.state.showChildren\n });\n return;\n }\n\n this.refs.iconHandle.setAttribute(\"class\", \"fa fa-spin fa-gear\");\n\n // Get groups first\n ewars.tx(\"com.ewars.indicators\", [this.props.data.id])\n .then(function (resp) {\n this.setState({\n data: resp,\n showChildren: true\n })\n }.bind(this))\n };\n\n _onCaretClick = () => {\n this.getChildren();\n };\n\n componentWillUnmount() {\n window.__hack__.removeEventListener(\"click\", this._onBodyClick);\n ewars.g[\"FOLDER_\" + this.props.data.id] = ewars.copy(this.state);\n };\n\n _dragStart = (e) => {\n e.dataTransfer.setData(\"item\", JSON.stringify(this.props.data));\n };\n\n _onContext = (e) => {\n e.preventDefault();\n this.setState({\n showContext: true\n })\n };\n\n _onContextAction = (action) => {\n this.setState({\n showContext: false\n });\n\n this.props.onAction(action, this.props.data);\n };\n\n render() {\n\n let childs;\n\n if (this.state.data) {\n childs = this.state.data.map(function (item) {\n if (item.context == \"INDICATOR\") {\n return (\n \n )\n }\n\n if (item.context == \"FOLDER\") {\n return (\n \n )\n }\n }.bind(this))\n }\n\n let icon = \"fal \";\n if (this.state.showChildren) icon += \" fa-folder-open\";\n if (!this.state.showChildren) icon += \" fa-folder\";\n\n let label = ewars.I18N(this.props.data.name);\n\n return (\n
    \n
    \n
    \n
    \n \n
    \n
    {label}
    \n
    \n {this.props.actions && this.state.showContext ?\n \n : null}\n
    \n {this.state.showChildren ?\n
    \n {childs}\n
    \n : null}\n
    \n )\n }\n}\n\nvar TreeNodeComponent = React.createClass({\n _hasLoaded: false,\n\n getDefaultProps: function () {\n return {\n dark: false,\n hideInactive: true\n }\n },\n\n getInitialState: function () {\n return {\n children: [],\n showChildren: false,\n showContext: false\n };\n },\n\n componentWillMount: function () {\n window.__hack__.addEventListener(\"click\", this._onBodyClick);\n ewars.subscribe(\"RELOAD_INDICATORS\", this._reload);\n },\n\n componentWillUnmount: function () {\n window.__hack__.removeEventListener(\"click\", this._onBodyClick);\n },\n\n _onBodyClick: function (evt) {\n if (!evt.contains(this.refs.item)) {\n this.setState({\n showContext: false\n })\n }\n },\n\n _onContext: function (e) {\n e.preventDefault();\n this.setState({\n showContext: true\n })\n },\n\n _onContextAction: function (action) {\n this.props.onAction(action, this.props.data);\n },\n\n _reload: function () {\n if (this._hasLoaded && this.props.type != \"INDICATOR\") {\n // Get groups first\n\n ewars.tx(\"com.ewars.indicators\", [this.props.data.id])\n .then(function (resp) {\n this._hasLoaded = true;\n this.setState({\n children: resp,\n showChildren: true\n })\n }.bind(this))\n }\n },\n\n _onClick: function () {\n if (this.state.showChildren) {\n this.setState({\n showChildren: false\n });\n return;\n }\n\n if (!this._hasLoaded) {\n ewars.tx(\"com.ewars.indicators\", [this.props.data.id])\n .then(function (resp) {\n this._hasLoaded = true;\n this.setState({\n children: resp,\n showChildren: true\n })\n }.bind(this))\n } else {\n\n this.setState({\n showChildren: true\n })\n }\n },\n\n _hasChildren: function () {\n return true;\n },\n\n _onEdit: function () {\n this.props.onEdit(null, this.props.data);\n },\n\n render: function () {\n let className = \"block\";\n\n let label = ewars.I18N(this.props.data.name);\n\n let showSelect = false;\n\n let caret;\n if ([\"SYSTEM\", \"FOLDER\"].indexOf(this.props.data.context) >= 0) {\n if (this.state.showChildren) caret = \"fal fa-folder-open\";\n if (!this.state.showChildren) caret = \"fal fa-folder\";\n }\n\n let children;\n\n if (this.state.showChildren && this._hasLoaded) {\n children = [];\n this.state.children.forEach(function (item) {\n children.push();\n }.bind(this))\n }\n\n if (this.state.showChildren && !this._hasLoaded) {\n children = ;\n }\n\n if (this.props.data.context == \"INDICATOR\") showSelect = true;\n\n let handleStyle = {flexGrow: 1, flexBasis: 0};\n\n return (\n
    \n
    \n
    \n {caret ?\n
    \n \n
    \n : null}\n
    {label}
    \n
    \n {this.props.actions && this.state.showContext ?\n \n : null}\n
    \n {this.state.showChildren ?\n
    \n {children}\n
    \n : null}\n
    \n )\n }\n});\n\nfunction debounce(fn, delay) {\n var timer = null;\n return function () {\n var context = this, args = arguments;\n clearTimeout(timer);\n timer = setTimeout(function () {\n fn.apply(context, args);\n }, delay);\n };\n}\n\nclass SearchInput extends React.Component {\n static defaultProps = {\n value: ''\n };\n\n constructor(props) {\n super(props);\n\n this.sendForSearch = debounce(this.sendForSearch, 300);\n }\n\n sendForUpdate = (e) => {\n this.props.onChange(e.target.value);\n\n if (e.target.value.length > 2) {\n this.sendForSearch(e.target.value);\n }\n\n if (e.target.value == \"\") this.sendForSearch(null);\n };\n\n sendForSearch = (searchTerm) => {\n this.props.onSearch(searchTerm);\n };\n\n render() {\n return (\n \n )\n }\n}\n\nclass IndicatorTreeView extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = {\n search: \"\",\n data: []\n }\n\n this._handleSearchChange = debounce(this._handleSearchChange, 500);\n }\n\n static defaultProps = {\n allowCheck: false,\n checked: [],\n value: null,\n hideInactive: true\n };\n\n componentWillMount() {\n this._init();\n ewars.subscribe(\"RELOAD_INDICATORS\", this._init);\n }\n\n _init = () => {\n ewars.tx(\"com.ewars.indicators\", [null])\n .then(function (resp) {\n this.setState({\n data: resp\n });\n ewars.emit(\"RELOAD_CHILDS\");\n }.bind(this))\n };\n\n _onSearchChange = (value) => {\n this.setState({\n search: value\n })\n };\n\n _onSearch = (val) => {\n if (val == \"\" || val == null) {\n this._init();\n } else {\n ewars.tx(\"com.ewars.query\", [\"indicator\", null, {\"name.en\": {like: val}}, null, null, null, null])\n .then(resp => {\n this.setState({\n data: resp\n })\n })\n }\n };\n\n _clearSearch = () => {\n this.setState({\n search: \"\"\n });\n\n this._init();\n };\n\n _onItemAction = (action, data) => {\n this.props.onAction(action, data);\n };\n\n\n render() {\n let nodes = this.state.data.map((item) => {\n if (this.state.search != \"\" && this.state.search != null) {\n return (\n \n );\n } else {\n return (\n\n \n )\n }\n });\n\n return (\n \n \n \n
    \n
    \n \n \n \n \n \n \n \n {this.state.search != \"\" ?\n \n \n \n : null}\n \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n {nodes}\n
    \n
    \n
    \n
    \n
    \n\n )\n }\n}\n\nexport default IndicatorTreeView;\n","const FORM_SOURCE_VARIABLE = [\n {\n _o: 0,\n n: \"var\",\n l: \"Variable Name\",\n t: \"TEXT\",\n r: true\n },\n {\n _o: 1,\n n: \"reduction\",\n t: \"BUTTONSET\",\n l: \"Reduction\",\n o: [\n [\"SUM\", \"Sum\"],\n [\"AVG\", \"Mean\"]\n ]\n }\n];\n\n\nexport default FORM_SOURCE_VARIABLE;","\nlet obj = (window.config && window.config.EVENTS) ? window.config.EVENTS : '[]';\nlet events = JSON.parse(obj) || [];\nconst ALERTS = {\n alarm_id: {\n type: \"select\",\n label: __(\"ALARM\"),\n optionsSource: {\n resource: \"alarm\",\n valSource: \"uuid\",\n labelSource: \"name\",\n query: {},\n additionalOptions: [\n [\"ANY\", \"Any\"]\n ]\n }\n },\n dimension: {\n type: \"select\",\n label: __(\"DIMENTION\"),\n options: [\n [\"ALERTS_TRIGGERED\", __(\"ALERTS_TRIGGERED\")],\n\n [\"ALERTS_OPEN\", __(\"ALERTS_OPEN\")],\n [\"ALERTS_CLOSED\", __(\"ALERTS_CLOSED\")],\n [\"ALERTS_CLOSED_NON_AUTO\", __(\"ALERTS_CLOSED_NON_AUTO\")],\n [\"ALERTS_AUTO_DISCARDED\", __(\"ALERTS_AUTO_DISCARDED\")],\n\n [\"ALERTS_DISCARDED\", __(\"ALERTS_DISCARDED\")],\n [\"ALERTS_MONITORED\", __(\"ALERTS_MONITORED\")],\n [\"ALERTS_RESPOND\", __(\"ALERTS_RESPOND\")],\n\n [\"ALERTS_IN_VERIFICATION\", __(\"ALERTS_IN_VERIFICATION\")],\n [\"ALERTS_AWAIT_VERIFICATION\", __(\"ALERTS_AWAIT_VERIFICATION\")],\n [\"ALERTS_VERIFIED\", __(\"ALERTS_VERIFIED\")],\n [\"ALERTS_DISCARDED_VERIFICATION\", __(\"ALERTS_DISCARDED_VERIFICATION\")],\n [\"ALERTS_MONITORED_VERIFICATION\", __(\"ALERTS_MONITORED_VERIFICATION\")],\n\n [\"ALERTS_IN_RISK_ASSESS\", __(\"ALERTS_IN_RISK_ASSESS\")],\n [\"ALERTS_AWAIT_RISK_ASSESS\", __(\"ALERTS_AWAIT_RISK_ASSESS\")],\n [\"ALERTS_RISK_ASSESSED\", __(\"ALERTS_RISK_ASSESSED\")],\n\n [\"ALERTS_IN_RISK_CHAR\", __(\"ALERTS_IN_RISK_CHAR\")],\n [\"ALERTS_AWAIT_RISK_CHAR\", __(\"ALERTS_AWAIT_RISK_CHAR\")],\n [\"ALERTS_RISK_CHAR\", __(\"ALERTS_RISK_CHAR\")],\n\n [\"ALERTS_IN_OUTCOME\", __(\"ALERTS_IN_OUTCOME\")],\n [\"ALERTS_AWAIT_OUTCOME\", __(\"ALERTS_AWAIT_OUTCOME\")],\n [\"ALERTS_OUTCOME\", __(\"ALERTS_OUTCOME\")],\n [\"ALERTS_DISCARD_OUTCOME\", __(\"ALERTS_DISCARD_OUTCOME\")],\n [\"ALERTS_MONITORED_OUTCOME\", __(\"ALERTS_MONITORED_OUTCOME\")],\n [\"ALERTS_RESPOND_OUTCOME\", __(\"ALERTS_RESPOND_OUTCOME\")],\n\n [\"ALERTS_RISK_LOW\", __(\"ALERTS_RISK_LOW\")],\n [\"ALERTS_RISK_MODERATE\", __(\"ALERTS_RISK_MODERATE\")],\n [\"ALERTS_RISK_HIGH\", __(\"ALERTS_RISK_HIGH\")],\n [\"ALERTS_RISK_SEVERE\", __(\"ALERTS_RISK_SEVERE\")]\n ]\n },\n likely_event: {\n type: \"select\",\n label: __(\"LIKELY_EVENT\"),\n options : events\n }\n ,\n include: {\n type: \"select\",\n label: __(\"INCLUDE\"),\n options: [\n [\"ALERTS_VERIFIED_WITHIN\", __(\"VERIFIED_WHITHIN\")],\n [\"ALERTS_RISK_ASSESS_WITHIN\", __(\"RISK_ASSESSED_WITHIN\")],\n [\"ALERTS_RISK_CHAR_WITHIN\", __(\"RISK_CHARD_WITHIN\")],\n [\"ALERTS_OUTCOME_WITHIN\", __(\"ALERTS_OUTCOME_WITHIN\")],\n\n ]\n },\n \n hours_whithin: {\n type: \"number\",\n label: __(\"NO_OF_HOURS\"),\n conditional_bool: true,\n required: true,\n conditions: {\n application: \"all\",\n rules: [\n [\"include\", \"neq\", \"null\"]\n ]\n\n }\n }\n};\n\nexport default ALERTS;\n\n","const ASSIGNMENTS = {\n form_id: {\n type: \"select\",\n label: __(\"FORM\"),\n optionsSource: {\n resource: \"form\",\n valSource: \"id\",\n labelSource: \"name\",\n query: {}\n }\n },\n status: {\n type: \"select\",\n label: __(\"STATUS\"),\n options: [\n [\"ACTIVE\", __(\"ACTIVE\")],\n [\"ELAPSED\", __(\"ELAPSED\")],\n [\"INACTIVE\", __(\"INACTIVE\")]\n ]\n }\n};\n\nexport default ASSIGNMENTS;\n\n","const DEVICES = {\n type: {\n type: \"select\",\n label: __(\"DEVICE_TYPE\"),\n options: [\n [\"ANDROID\", \"Android\"],\n [\"IOS\", \"iOS\"],\n [\"DESKTOP\", \"Desktop\"],\n [\"NODE\", \"Node\"]\n ]\n },\n organization_id: {\n type: \"select\",\n label: __(\"ORGANIZATION\"),\n optionsSource: {\n resource: \"organization\",\n valSource: \"uuid\",\n labelSource: \"name\",\n query: {}\n }\n },\n status: {\n type: \"select\",\n label: __(\"STATUS\"),\n options: [\n [\"ANY\", __(\"ANY\")],\n [\"SYNCED\", __(\"SYNCED\")],\n [\"UNSYNCED\", __(\"UNSYNCED\")]\n ]\n }\n};\n\nexport default DEVICES;\n\n","var FORMS = {\n\n form_id: {\n type: \"select\",\n label: __(\"FORM\"),\n optionsSource: {\n resource: \"form\",\n valSource: \"id\",\n labelSource: \"name\",\n query: {\n status: {eq: \"ACTIVE\"}\n }\n }\n },\n dimension: {\n type: \"select\",\n label: __(\"ACTIVITY\"),\n options: [\n \n [\"LOCATIONS\", __(\"COUNT_REPORTING_LOCATIONS\")],\n [\"FORM_FIELD\", __(\"SUM_OF_FIELD_VALUE\")],\n [\"CONCAT_TEXT\",__(\"CONCAT_FIELD_VALUE\")],\n [\"COUNT_REPORT\",__(\"COUNT_REPORTS\")]\n ]\n },\n form_field: {\n type: \"form_field_select\",\n label: __(\"SELECT_FIELD\") ,\n conditional_bool: true,\n conditions: {\n application: \"any\",\n rules: [\n ['dimension', 'eq', 'FORM_FIELD'],\n ['dimension', 'eq', 'CONCAT_TEXT']\n ]\n },\n options:{\n form_id_field_name : \"form_id\"\n }\n },\n field_restrict: {\n type: \"button_group\",\n label:__(\"CONDITION_ON_FIELD\"),\n options: [\n [false, __(\"NO\")],\n [true, __(\"YES\")]\n ],\n conditional_bool: true,\n conditions: {\n application: \"any\",\n rules: [\n ['dimension', 'eq', 'FORM_FIELD'],\n ['dimension', 'eq', 'COUNT_REPORT'],\n ['dimension', 'eq', 'CONCAT_TEXT']\n ]\n }\n },\n field_condition: {\n type: \"form_field_condition\",\n label: __(\"CONDITIONS\"),\n conditional_bool: true,\n conditions: {\n application: \"all\",\n rules: [\n ['field_restrict', 'eq', true]\n ]\n } ,\n defaultValue: [\"ALL\", \":EQ:\"]\n \n \n },\n};\n\nexport default FORMS;\n\n","const FORM_SUBMISSIONS = {\n form_id: {\n type: \"select\",\n label: __(\"FORM\"),\n optionsSource: {\n resource: \"form\",\n valSource: \"id\",\n labelSource: \"name\",\n query: {\n status: {eq: \"ACTIVE\"}\n }\n }\n },\n metric: {\n type: \"select\",\n label: __(\"DIMENTION\"),\n options: [\n [\"SUBMITTED\", __(\"SUBMITTED\")],\n [\"LATE\", __(\"LATE\")],\n [\"EXPECTED\", __(\"EXPECTED\")],\n [\"ON_TIME\", __(\"ON_TIME\")],\n [\"MISSING\", __(\"MISSING\")],\n [\"COMPLETENESS\", __(\"COMPLETENESS\") + \" (%)\" ],\n [\"TIMELINESS\", __(\"TIMELINESS\") + \" (%)\"]\n ]\n },\n // organization_id: {\n // type: \"select\",\n // label: __(\"ORGANIZATION\"),\n // optionsSource: {\n // resource: \"organization\",\n // valSource: \"uuid\",\n // labelSource: \"name\",\n // query: {}\n // }\n // },\n source: {\n type: \"select\",\n label: __(\"SOURCE\"),\n options: [\n [\"ANDROID\", __(\"MOBILE\")],\n [\"SYSTEM\", __(\"WEB\")],\n // [\"DESKTOP\", __(\"DESKTOP\")],\n // [\"SMS\", __(\"SMS\")]\n ]\n }\n};\n\nexport default FORM_SUBMISSIONS;\n\n","const LOCATIONS = {\n status: {\n type: \"select\",\n label: __(\"STATUS\"),\n options: [\n [\"ACTIVE\", __(\"ACTIVE\")],\n [\"DISABLED\", __(\"DISABLED\")]\n ]\n },\n site_type_id: {\n type: \"select\",\n label: __(\"LOCATION_TYPE\"),\n optionsSource: {\n resource: \"location_type\",\n valSource: \"id\",\n labelSource: \"name\",\n query: {}\n }\n }\n};\n\nexport default LOCATIONS;\n","const OLD_ALERTS = {\n alarm_id: {\n type: \"select\",\n label: __(\"alarm_id\"),\n optionsSource: {\n resource: \"alarm\",\n valSource: \"uuid\",\n labelSource: \"name\",\n query: {}\n }\n },\n state: {\n type: \"select\",\n label: __(\"STATE\"),\n options: [\n [\"OPEN\", __(\"OPEN\")],\n [\"CLOSED\", __(\"CLOSED\")],\n [\"AUTODISCARDED\", __(\"AUTO_DISCARDED\")]\n ]\n },\n stage: {\n type: \"select\",\n label: __(\"stage\"),\n options: [\n [\"VERIFICATION\", __(\"VERIFICATION\")],\n [\"RISK_ASSESS\", __(\"RISK_ASSESSMENT\")],\n [\"RISK_CHAR\", __(\"RISK_CHARACTERIZATION\")],\n [\"OUTCOME\", __(\"OUTCOME\")]\n ]\n },\n stage_state: {\n type: \"select\",\n label: __(\"stage_state\"),\n options: [\n [\"PENDING\", __(\"PENDING\")],\n [\"COMPLETED\", __(\"COMPLETED\")]\n ]\n },\n risk: {\n type: \"select\",\n label: __(\"RISK\"),\n options: [\n [\"LOW\", __(\"LOW_RISK\")],\n [\"MODERATE\", __(\"MODERATE_RISK\")],\n [\"HIGH\", __(\"HIGH_RISK\")],\n [\"SEVERE\", __(\"VERY_HIGH_RISK\")]\n ]\n },\n\n};\n\nexport default OLD_ALERTS;\n\n","const TASKS = {\n type: {\n type: \"select\",\n label: __(\"TASK_TYPE\"),\n options: [\n [\"REGISTRATION\", __(\"REGISTRATION\")],\n [\"AMENDMENT\", __(\"AMENDMENT\")],\n [\"DISCARD\", __(\"DISCARD\")]\n ]\n },\n status: {\n type: \"select\",\n label: __(\"STATUS\"),\n options: [\n [\"ANY\", __(\"ANY\")],\n [\"PENDING\", __(\"PENDING\")],\n [\"APPROVED\", __(\"APPROVED\")],\n [\"REJECTED\", __(\"REJECTED\")]\n ]\n }\n};\n\nexport default TASKS;\n\n","const USERS = {\n status: {\n type: \"select\",\n label: __(\"STATUS\"),\n options: [\n [\"ACTIVE\", __(\"ACTIVE\")],\n [\"INACTIVE\", __(\"INACTIVE\")],\n [\"PENDING_APPROVAL\", __(\"PENDIG_APPROVAL\")]\n ]\n },\n organization_id: {\n type: \"select\",\n label: __(\"ORGANIZATION\"),\n optionsSource: {\n resource: \"organization\",\n labelSource: \"name\",\n valSource: \"uuid\",\n query: {}\n }\n },\n type: {\n type: \"select\",\n label: __(\"USER_TYPE\"),\n options: [\n [\"USER\", __(\"REPORTING_USER\")],\n [\"REGIONAL_ADMIN\", __(\"GEOGRAPHIC_ADMIN\")],\n [\"ACCOUNT_ADMIN\", __(\"ACCOUNT_ADMIN\")]\n ]\n }\n};\n\nexport default USERS;\n\n","import ALERTS from \"./ALERTS\";\nimport ASSIGNMENTS from \"./ASSIGNMENTS\";\nimport DEVICES from \"./DEVICES\";\nimport FORM_SUBMISSIONS from \"./FORM_SUBMISSIONS\";\nimport FORMS from \"./FORMS\";\nimport LOCATIONS from \"./LOCATIONS\";\nimport OLD_ALERTS from \"./OLD_ALERTS\";\nimport TASKS from \"./TASKS\";\nimport USERS from \"./USERS\";\n\nexport {\n ALERTS,\n ASSIGNMENTS,\n DEVICES,\n FORM_SUBMISSIONS,\n FORMS,\n LOCATIONS,\n OLD_ALERTS,\n TASKS,\n USERS\n}\n","import Button from \"./c.button\";\nimport Modal from \"./c.modal\";\nimport Shade from \"./c.shade\";\nimport Filler from \"./c.filler\";\nimport VertTab from \"./c.tab.vertical\";\nimport Spinner from \"./c.spinner\";\nimport Form from \"./c.form\";\nimport ReportingForm from \"./c.form.reporting\";\nimport Prompt from \"./c.prompt\";\nimport DropDownMenu from \"./c.menu.dropdown\";\nimport CmpButton from \"./c.cmp.button\";\nimport ContextMenu from \"./c.context_menu\";\nimport DataTable from \"./datatable/c.datatable\";\nimport Collapser from \"./c.collapser\";\nimport Toolbar from \"./c.toolbar\";\nimport { Layout, Row, Cell, Panel } from \"./layout\";\nimport ListComponent from \"./c.list\";\nimport LinkSelect from \"./c.link\";\nimport Tab from \"./c.tab\";\nimport ButtonGroup from \"./c.button_group\";\n\n// Cmp\nimport ReportBrowser from \"./c.report_browser\";\nimport Sources from \"./c.cmp.sources\";\nimport EditableList from \"./c.editable_list\";\nimport PeriodSelector from \"./c.period_selector\";\n\nimport { ActionGroup, ActionButton } from \"./c.action_button\";\nimport Application from \"./c.app\";\n\n// Settings Form\nexport { default as SettingsForm } from \"./c.form.settings\";\nexport { default as SettingsSection } from \"./c.form.settings.section\";\nexport { default as SettingsField } from \"./c.form.settings.field\";\n\n// Systems Form\nexport { default as SystemForm } from \"./c.form.system\";\n\nexport {\n ActionGroup,\n ActionButton,\n ButtonGroup,\n Button,\n Modal,\n Shade,\n Filler,\n VertTab,\n Spinner,\n Form,\n ReportingForm,\n Prompt,\n DropDownMenu,\n CmpButton,\n ContextMenu,\n DataTable,\n Collapser,\n Toolbar,\n Layout, Row, Cell, Panel,\n ListComponent,\n LinkSelect,\n Tab,\n\n // Cmp\n Sources,\n ReportBrowser,\n EditableList,\n PeriodSelector,\n\n Application\n}\n","class Cell extends React.Component {\n static defaultProps = {\n width: null,\n borderTop: false,\n borderRight: false,\n borderBottom: false,\n borderLeft: false,\n addClass: null,\n padding: null,\n onClick: null,\n style: {}\n };\n\n constructor(props) {\n super(props);\n }\n\n _onClick = () => {\n if (this.props.onClick) this.props.onClick();\n };\n\n render() {\n let style = {};\n\n style.maxWidth = this.props.width || null;\n style.padding = this.props.padding || null;\n\n let className = \"ide-col\";\n className += this.props.borderRight ? \" border-right\" : \"\";\n className += this.props.borderBottom ? \" border-bottom\" : \"\";\n className += this.props.borderLeft ? \" border-left\" : \"\";\n className += this.props.borderTop ? \" border-top\" : \"\";\n className += this.props.addClass ? ` ${this.props.addClass}` : \"\";\n\n if (this.props.onClick) style.cursor = \"pointer\";\n\n Object.assign(style, this.props.style || {});\n\n return (\n
    \n {this.props.children}\n
    \n )\n }\n}\n\nclass Row extends React.Component {\n static defaultProps = {\n height: null,\n borderTop: false,\n borderBottom: false,\n borderRight: false,\n borderLeft: false,\n style: null,\n addClass: null,\n onClick: null\n };\n\n constructor(props) {\n super(props);\n }\n\n render() {\n let className = \"ide-row\";\n if (this.props.addClass) className += \" \" + this.props.addClass;\n let style = {};\n\n style.maxHeight = this.props.height || null;\n\n if (this.props.style) Object.assign(style, this.props.style);\n\n let onClick = this.props.onClick || null;\n\n return (\n
    \n {this.props.children}\n
    \n )\n }\n}\n\nclass Layout extends React.Component {\n constructor(props) {\n super(props);\n }\n\n render() {\n let style = {};\n let classname = ''\n if (this.props.style) Object.assign(style, this.props.style);\n if(this.props.className) classname = this.props.className;\n return (\n
    \n {this.props.children}\n
    \n )\n }\n}\n\nclass Panel extends React.Component {\n constructor(props) {\n super(props);\n }\n\n render() {\n let style = {};\n if (this.props.style) {\n for (let i in this.props.style) {\n style[i] = this.props.style[i];\n }\n }\n return (\n
    \n {this.props.children}\n
    \n )\n }\n}\n\nexport {\n Layout,\n Row,\n Cell,\n Panel\n};\n","var Moment = require('moment');\n\nvar CONSTANTS = require(\"../constants\");\n\n/**\n * Get most recently completed interval date\n * @param specDate\n * @param interval\n * @returns {*}\n */\nvar getActualDate = function (specDate, interval, no_future) {\n \n Moment.updateLocale(\"en\", {\n week: {\n dow: ewars.getDOWMod7(),\n doy: (7 + ewars.getDOWMod7() - ewars.getDOY())\n }\n });\n\n \n if (interval == CONSTANTS.DAY) return specDate;\n\n if (interval == CONSTANTS.WEEK) {\n var actualEndWeek = specDate.clone().endOf(\"week\");\n\n if (no_future) {\n if (actualEndWeek.isAfter(specDate, \"d\")) {\n return actualEndWeek.clone().subtract(7, \"d\");\n } else {\n return actualEndWeek;\n }\n } else {\n return actualEndWeek;\n }\n }\n\n if (interval == CONSTANTS.MONTH) {\n var actualEndMonth = specDate.clone().endOf(\"month\");\n\n if (specDate.isSame(actualEndMonth, \"day\")) return actualEndMonth;\n if (specDate.isBefore(actualEndMonth, \"day\")) return actualEndMonth.clone()\n .subtract(1, \"M\")\n .endOf(\"month\");\n }\n\n if (interval == CONSTANTS.YEAR) {\n var actualEndYear = specDate.clone().endOf(\"year\");\n\n if (specDate.isSame(actualEndYear, \"day\")) return actualEndYear;\n if (specDate.isBefore(actualEndYear, \"day\"))\n return actualEndYear.clone().subtract(1, \"y\").endOf(\"year\");\n }\n};\n\nvar getDaysBetween = function (startDate, endDate) {\n var resultantDates = [startDate];\n\n var cur_date = startDate.clone();\n\n while (cur_date.isBefore(endDate, CONSTANTS.DAY)) {\n var newDate = cur_date.clone().add(1, \"d\");\n resultantDates.push(newDate);\n cur_date = newDate;\n }\n\n return resultantDates;\n\n};\n\nvar getWeeksBetween = function (startDate, endDate) {\n var resultantDates = [startDate.clone()];\n\n var cur_date = startDate.clone();\n\n while (cur_date.isBefore(endDate, \"day\")) {\n var newDate = cur_date.clone().add(7, \"d\");\n resultantDates.push(newDate);\n cur_date = newDate;\n }\n\n\n return resultantDates;\n\n};\n\nvar getMonthsBetween = function (startDate, endDate) {\n\n};\n\nvar getYearsBetween = function (startDate, endDate) {\n\n};\n\nvar INTERVAL_MAP = {\n \"DAY\": \"d\",\n \"WEEK\": \"d\",\n \"MONTH\": \"M\",\n \"YEAR\": \"Y\"\n};\n\nmodule.exports = {\n /**\n * Returns a list of dates occurring between two dates\n * of a specific interval type\n * @param start_date\n * @param end_date\n * @param interval\n */\n getDatesInInterval: function (start_date, end_date, interval) {\n\n var startDate = Moment(start_date),\n endDate;\n\n if (end_date) endDate = Moment(end_date);\n if (!end_date) endDate = Moment();\n\n var actualEnd = getActualDate(endDate, interval, true);\n var actualStart = getActualDate(startDate, interval);\n\n if (interval == CONSTANTS.DAY) return getDaysBetween(actualStart, actualEnd);\n if (interval == CONSTANTS.WEEK) return getWeeksBetween(actualStart, actualEnd);\n if (interval == CONSTANTS.MONTH) return getMonthsBetween(actualStart, actualEnd);\n if (interval == CONSTNATS.YEAR) return getYearsBetween(actualStart, actualEnd);\n\n return []\n },\n getMonthsDaysBetweenDates: function(startDate) {\n const start = Moment(startDate);\n const end = Moment(new Date());\n \n const months = end.diff(start, \"months\");\n const years = end.diff(start, \"years\");\n \n return {months, years};\n },\n getMostRecentlyEndedInterval: function (reportDate, interval) {\n return getActualDate(reportDate, interval);\n },\n\n getStartDate: function (specDate, interval) {\n Moment.updateLocale(\"en\", {\n week: {\n dow: ewars.getDOWMod7(),\n doy: (7 + ewars.getDOWMod7() - ewars.getDOY()) \n }\n });\n\n if (interval == CONSTANTS.DAY) return Moment(specDate).clone();\n if (interval == CONSTANTS.WEEK) return Moment(specDate).clone().startOf(\"week\");\n if (interval == CONSTANTS.MONTH) return Moment(specDate).clone().startOf(\"month\");\n if (interval == CONSTANTS.YEAR) return Moment(specDate).clone().startOf(\"year\");\n },\n\n getEndDate: function (specDate, interval) {\n Moment.updateLocale(\"en\", {\n week: {\n dow: ewars.getDOWMod7(),\n doy: (7 + ewars.getDOWMod7() - ewars.getDOY()) \n }\n });\n\n if (interval == CONSTANTS.DAY) return Moment(specDate).clone();\n if (interval == CONSTANTS.WEEK) return Moment(specDate).clone().endOf(\"week\");\n if (interval == CONSTANTS.MONTH) return Moment(specDate).clone().endOf(\"month\");\n if (interval == CONSTANTS.YEAR) return Moment(specDate).clone().endOf(\"year\");\n },\n\n processDateSpec: function (definition, reportDate) {\n var startDate,\n endDate;\n\n if (definition.filter) {\n if (!reportDate) endDate = Moment();\n var filterSpec = definition.filter;\n\n if (filterSpec == \"1M\") startDate = endDate.clone().subtract(1, 'M');\n if (filterSpec == \"3M\") startDate = endDate.clone().subtract(3, \"M\");\n if (filterSpec == \"6M\") startDate = endDate.clone().subtract(6, \"M\");\n if (filterSpec == \"1Y\") startDate = endDate.clone().subtract(1, \"Y\");\n if (filterSpec == \"YTD\") {\n startDate = endDate.clone().startOf(\"year\");\n }\n\n } else {\n if (definition.end_date_spec == \"MANUAL\") {\n endDate = Moment(definition.end_date);\n }\n\n if (definition.end_date_spec == \"REPORT_DATE\") {\n endDate = Moment(reportDate);\n }\n\n if (definition.end_date_spec == \"REPORT_DATE_SUBTRACTION\") {\n var units = parseInt(definition.end_intervals);\n // If the time interval is weeks, we use days for the subtraction as\n // isoweeks isn't very reliable\n if (definition.timeInterval == \"WEEK\") {\n units = 7 * units;\n }\n endDate = Moment(reportDate).clone().subtract(units, INTERVAL_MAP[definition.timeInterval]);\n }\n\n if (definition.start_date_spec == \"MANUAL\") {\n startDate = Moment(definition.start_date);\n }\n\n if (definition.start_date_spec == \"END_SUBTRACTION\") {\n var units = parseInt(definition.start_intervals);\n // If the time interval is weeks, we use days for the subtraction as\n // isoweeks isn't very reliable\n if (definition.timeInterval == \"WEEK\") {\n units = 7 * units;\n }\n startDate = endDate.clone().subtract(units, INTERVAL_MAP[definition.timeInterval]);\n }\n\n if (definition.start_date_spec == \"REPORT_DATE\") {\n startDate = Moment(reportDate).startOf(INTERVAL_MAP[definition.timeInterval]);\n }\n }\n\n return [startDate.format(\"YYYY-MM-DD\"), endDate.format(\"YYYY-MM-DD\")];\n\n },\n\n getNextPeriod: function (startDate, interval) {\n if ([CONSTANTS.NONE, CONSTANTS.DAY].indexOf(interval) >= 0) return startDate.clone().add(1, 'd');\n if (interval == CONSTANTS.WEEK) return startDate.clone().add(7, 'd');\n if (interval == CONSTANTS.MONTH) return null;\n if (interval == CONSTANTS.YEAR) return startDate.clone().add(365, \"d\");\n },\n\n getPreviousPeriod: function (startDate, interval) {\n if ([CONSTANTS.NONE, CONSTANTS.DAY].indexOf(interval) >= 0) return startDate.clone().subtract(1, \"d\");\n if (interval == CONSTANTS.WEEK) return startDate.clone().subtract(7, 'd');\n if (interval == CONSTANTS.MONTH) return null;\n if (interval == CONSTANTS.YEAR) return startDate.clone().subtract(365, 'd');\n },\n\n getUTCOffsetFromTZ : function(tzInfo){\n \n if(tzInfo){\n const utcoffset = tzInfo.split('@@')[1]; \n return parseInt(utcoffset, 10);\n }\n\n return 0;\n }\n\n};","import {FIELD_FORM} from '../constants/field_definition.js'\n\nfunction _convertFormToOptions(definition, path, lLabel) {\n var options = [];\n\n for (let key in definition) {\n let field = definition[key];\n let fieldName = ewars.formatters.I18N_FORMATTER(field.label);\n let realName = fieldName;\n if (lLabel) realName = `${lLabel.join(\" \\\\ \")} \\\\ ${fieldName}`;\n let fieldPath = `${key}`;\n if (path) fieldPath = `${path}.${fieldPath}`;\n options.push([key, realName, {...field, path: fieldPath}]);\n\n if (field.fields) {\n let subLabel = [fieldName];\n if (lLabel) {\n subLabel = ewars.copy(lLabel);\n subLabel.push(fieldName);\n }\n\n let subPath;\n if (path) {\n subPath = path + \".\" + key;\n } else {\n subPath = key;\n }\n let subFields = _convertFormToOptions(field.fields, fieldPath, subLabel);\n options.push.apply(options, subFields);\n }\n }\n\n return options;\n}\n\n/**\n * Convert all form labels for transaltion\n * @param {*} definition \n * \n * \n */\nfunction _convertFormLabelsForTranslation(formData){\n var labels = [];\n\n Object.entries(formData).map((key , value) => { \n if(key[1]){\n if(key[1].isTranslate){\n let labelName = key[0];\n let dispalyName = labelName;\n let fieldpath = `${key[0]}`\n labels.push([key[0], dispalyName, {...key[1], path: fieldpath}]);\n }\n }\n if(key[0] == 'version'){\n let definitionData = _converDefinitionToLabel(key[1].definition , null)\n let _allLabels = _getAllLabelsFromDefinationFields(definitionData)\n labels.push.apply(labels , _allLabels)\n }\n })\n\n return labels\n}\n\n/**\n * Convert all definition labels for transaltion\n * @param {*} definition \n * @param {*} \n * @param {*} \n */\nfunction _converDefinitionToLabel(definition , path , subfield) {\n var label = [];\n\n for (let key in definition) {\n let field = definition[key];\n let labelName = field.name;\n let dispalyName = labelName;\n if (subfield) dispalyName = `${subfield.join(\" \\\\ \")} \\\\ ${labelName}`;\n let fieldPath = `${key}`;\n if (path) fieldPath = `${path}.${fieldPath}`;\n label.push([labelName, dispalyName, {...field, path: fieldPath}]);\n\n if (field.fields) {\n let subLabel = [labelName];\n if (subfield) {\n subLabel = ewars.copy(subfield);\n subLabel.push(labelName);\n }\n\n let subPath;\n if (path) {\n subPath = path + \".\" + key;\n } else {\n subPath = key;\n }\n let subFields = _converDefinitionToLabel(field.fields, fieldPath, subLabel);\n label.push.apply(label, subFields);\n }\n } \n return label;\n\n}\n\n/**\n * get all the labels that can be translated\n */\nfunction _getAllLabelsFromDefinationFields(sortedDefinition){\n let allLabels = [];\n for(let field in sortedDefinition){\n for(let fieldKey in sortedDefinition[field][2]){\n for(let keys in FIELD_FORM) {\n if(fieldKey == FIELD_FORM[keys].n && FIELD_FORM[keys].i18){\n let labelName , dispalyName , labelValue;\n labelName = sortedDefinition[field][2].name + \"__\" + fieldKey\n if(fieldKey != 'label'){\n dispalyName = sortedDefinition[field][1] + ` ${FIELD_FORM[keys].l}`;\n }else\n {\n // labelName = sortedDefinition[field][2].name ;\n dispalyName = sortedDefinition[field][1];\n }\n if(Array.isArray(sortedDefinition[field][2][fieldKey])){\n for(let opt in sortedDefinition[field][2][fieldKey]){\n let lName = labelName + \"__\" + sortedDefinition[field][2][fieldKey][opt][0];\n let dName = dispalyName + ` ${sortedDefinition[field][2][fieldKey][opt][0]}`;\n let lValue = sortedDefinition[field][2][fieldKey][opt][1]\n allLabels.push([lName , dName , lValue])\n continue\n }\n break;\n }else{\n labelValue = sortedDefinition[field][2][fieldKey]\n }\n allLabels.push([labelName , dispalyName , labelValue])\n break;\n }\n }\n }\n } \n return allLabels\n}\n\n/**\n * Converts a form definition to a tree\n * @param definition\n * @param place\n * @param placeName\n * @returns {Array}\n * @private\n */\nfunction _convertFormToTree(definition, place, placeName) {\n var items = [];\n\n var asArray = _.map(definition, function (field, fieldName) {\n var newField = _.extend({}, field, {name: fieldName});\n return newField;\n }, this);\n\n var asSorted = _.sortBy(asArray, function (item) {\n return item.order;\n }, true);\n\n _.each(asSorted, function (field) {\n if (field.fields) {\n var path;\n if (!place) path = field.name;\n if (place) path = place + \"/\" + field.name;\n\n var pathName;\n if (!placeName) pathName = ewars.formatters.I18N_FORMATTER(field.label);\n if (placeName) pathName = placeName + \" / \" + ewars.formatters.I18N_FORMATTER(field.label);\n\n var children = _convertFormToTree(field.fields, path, pathName);\n\n items.push({\n label: ewars.formatters.I18N_FORMATTER(field.label),\n pathLabel: pathName,\n name: field.name,\n path: path,\n field: field,\n nodeType: field.type,\n children: children\n })\n } else {\n var path;\n if (!place) path = field.name;\n if (place) path = place + \"/\" + field.name;\n\n var pathName;\n if (!placeName) pathName = ewars.formatters.I18N_FORMATTER(field.label);\n if (placeName) pathName = placeName + \" / \" + ewars.formatters.I18N_FORMATTER(field.label);\n\n items.push({\n label: ewars.formatters.I18N_FORMATTER(field.label),\n name: field.name,\n pathLabel: pathName,\n path: path,\n field: field,\n nodeType: field.type\n })\n }\n }, this);\n\n return items;\n}\n\nfunction _findField(definition, fieldName) {\n var current = definition;\n\n if (definition[fieldName]) {\n current = definition[fieldName];\n }\n}\n\n/**\n * Retrieve a field from within the definition\n * @param definition\n * @param path\n * @returns {*}\n * @private\n */\nfunction _getField(definition, specPath) {\n let item = definition;\n\n let path = specPath.split(\".\");\n if (path.indexOf(\"data.\") >= 0) path.shift();\n\n path.forEach(function (pathItem) {\n if (item[pathItem]) {\n if (item[pathItem].fields) {\n item = item[pathItem].fields;\n } else {\n item = item[pathItem];\n }\n }\n }.bind(this));\n\n return item;\n}\n\n\nfunction _getFieldProperty(definition, field, prop) {\n if (field.indexOf(\".\") >= 0) {\n let splat = field.split(\".\");\n\n let defn = definition;\n let splatLen = splat.length;\n for (var i in splat) {\n if (defn[i]) {\n if (defn[i].fields) {\n defn = defn[i].fields;\n } else {\n defn = defn[i];\n }\n } else {\n\n }\n }\n return defn[prop];\n } else {\n return definition[field][prop] || null;\n }\n}\n\nconst _getRuleResult = (rule, data) => {\n var result;\n\n var sourceValue = data[rule[0]] || null;;\n if ([\"null\", \"notnull\"].indexOf(rule[1]) < 0) {\n if (sourceValue == null || sourceValue == undefined) return false;\n }\n\n switch (rule[1]) {\n case \"eq\":\n if (Object.prototype.toString.call(sourceValue) == \"[object Array]\") {\n if (sourceValue.indexOf(rule[2]) >= 0) {\n result = true;\n } else {\n result = false;\n }\n } else {\n result = sourceValue == rule[2];\n }\n break;\n case \"ne\":\n case \"neq\":\n if (Object.prototype.toString.call(sourceValue) == \"[object Array]\") {\n if (sourceValue.indexOf(rule[2]) < 0) {\n result = true;\n } else {\n result = false;\n }\n } else {\n result = sourceValue != rule[2];\n }\n break;\n case \"gt\":\n result = sourceValue > rule[2];\n break;\n case \"lt\":\n result = sourceValue < rule[2];\n break;\n case 'lte':\n result = sourceValue <= rule[2];\n break;\n case 'gte':\n result = sourceValue >= rule[2];\n break;\n case 'null':\n if (ewars.isNull(sourceValue)) {\n result = true;\n } else {\n result = false;\n }\n break;\n case 'notnull':\n if (ewars.isNull(sourceValue)) {\n result = false;\n } else {\n result = true;\n }\n break;\n default:\n result = false;\n break\n }\n\n return result;\n};\n\n/**\n * Check if a field is visible if it isnt' we shouldn'y\n * try to vlaidate it\n * @param data The data in the system\n * @param fieldDef The definition for the field\n * @param fieldKey\n * @private\n */\nfunction _isVisible(data, field, fieldKey) {\n if (!field.conditional_bool) return true;\n\n if (field.conditional_bool == true) {\n let result = false;\n\n if (!field.conditions) return true;\n if (!field.conditions.rules) return true;\n\n if ([\"ANY\", \"any\"].indexOf(field.conditions.application) >= 0) {\n // Only one of the rules has to pass\n\n for (let conIdx in field.conditions.rules) {\n let rule = field.conditions.rules[conIdx];\n\n var tmpResult = _getRuleResult(rule, data);\n if (result != true && tmpResult == true) result = true;\n }\n\n } else {\n let ruleCount = field.conditions.rules.length;\n let rulePassCount = 0;\n\n for (let ruleIdx in field.conditions.rules) {\n let rule = field.conditions.rules[ruleIdx];\n let ruleResult = _getRuleResult(rule, data);\n if (ruleResult) rulePassCount++;\n }\n\n if (ruleCount == rulePassCount) result = true;\n\n }\n return result;\n } else {\n return true;\n }\n\n}\n\n/**\n * Instantiate an object with the defaults from a form definition\n * @param definition\n * @param flattened\n * @returns {{}}\n */\nfunction setFormDefaults(definition, flattened) {\n let data = {};\n\n return data;\n}\n\nfunction isSet(value) {\n if (value == null) return false;\n if (value == undefined) return false;\n if (value == \"\") return false;\n if (value == \"null\") return false;\n if (value == \"NULL\") return false;\n if (value == \"None\") return false;\n\n return true\n}\n\nconst NON_VALIDATE = ['matrix', 'row', 'header', 'display', 'media'];\n\nfunction _validate(definition, data, flattened) {\n let errors = {};\n let hasErrors = false;\n for (var i in definition) {\n let field = definition[i];\n let value;\n if(field.hasOwnProperty('nameOverride')){\n let pr = field.nameOverride\n let arr = pr.split(\".\")\n let parent_field = arr[0]\n let child_field = arr[1]\n if(data.hasOwnProperty(parent_field) && data[parent_field]){\n value = data[parent_field][child_field]\n }else{\n value = null\n }\n }\n else if (flattened) {\n value = data[i] || null;\n } else {\n value = ewars.getKeyPath(i, data);\n }\n errors[i] = [];\n \n let dotCount = (i.match(/\\./g) || []).length;\n\n let isVisible = true;\n if (dotCount > 0 && NON_VALIDATE.indexOf(field.type) < 0) {\n // This is a non-root field, we need to evaluate whether it's parents are\n // visible before evaluating whether the actual field is\n let key;\n let fieldTree = [];\n i.split(\".\").forEach(item => {\n if (!key) {\n key = item;\n } else {\n key += \".\" + item;\n }\n\n fieldTree.push(key);\n })\n fieldTree.pop();\n\n fieldTree.forEach(item => {\n let _vis = _isVisible(data, definition[item], item);\n if (!_vis) isVisible = false;\n })\n //this is for the last fieldtree value check if parent is visible\n if(isVisible){\n isVisible = _isVisible(data, field, i);\n }\n } else {\n isVisible = _isVisible(data, field, i);\n }\n if (isVisible && NON_VALIDATE.indexOf(field.type) < 0) {\n if (field.required && NON_VALIDATE.indexOf(field.type) < 0) {\n if (!isSet(value)) {\n hasErrors = true;\n errors[i].push(ewars.I18N(field.label) + \" is a required field\");\n } else {\n let typeErrors = [];\n switch (field.type) {\n case \"number\":\n typeErrors = _validateNumber(field, value);\n break;\n case \"text\":\n typeErrors = _validateText(field, value);\n break;\n case \"select\":\n typeErrors = _validateSelect(field, value);\n break;\n case \"date\":\n typeErrors = _validateDate(field, value);\n break;\n case \"location\":\n typeErrors = _validateLocation(field, value);\n break;\n default:\n break;\n }\n\n if (typeErrors.length > 0) hasErrors = true;\n errors[i].push.apply(errors[i], typeErrors);\n }\n }\n }\n }\n\n for (var f in errors) {\n if (errors[f].length <= 0) delete errors[f];\n }\n\n return {hasErrors, errors};\n}\n\nfunction _validateNumber(def, value) {\n let errors = [];\n\n return errors;\n}\n\nfunction _validateText(def, value) {\n return [];\n}\n\nfunction _validateSelect(def, value) {\n return [];\n}\n\nfunction _validateDate(def, value) {\n return [];\n}\n\nfunction _validateLocation(def, value) {\n return [];\n}\n\n\nfunction _getFieldsAsArray(sourceFields, parent) {\n let result = {};\n\n for (var i in sourceFields) {\n let field = sourceFields[i];\n\n let key;\n if (parent) {\n key = `${parent}.${i}`;\n } else {\n key = `${i}`;\n }\n\n if (field.type == \"matrix\") {\n let results = _getFieldsAsArray(field.fields, key);\n result[key] = field;\n for (var f in results) {\n result[f] = results[f];\n }\n } else if (field.type == \"row\") {\n let results = _getFieldsAsArray(field.fields, key);\n result[key] = field;\n for (var f in results) {\n result[f] = results[f];\n }\n } else {\n result[key] = field;\n }\n }\n\n return result;\n}\n\nexport default {\n validate: _validate,\n flattenDefinition: function (definition) {\n\n },\n asOptions: function (definition) {\n return _convertFormToOptions(definition, null);\n },\n translateOption: function(formData) {\n return _convertFormLabelsForTranslation(formData , null)\n },\n getField: function (definition, fieldPath) {\n return _findField(definition, fieldPath);\n },\n\n nest: function (data) {\n let unnested = {};\n\n for (var i in data) {\n let path = i.split(\".\");\n let last = path[path.length - 1];\n\n let term = unnested;\n\n path.forEach(item => {\n if (term[item]) {\n term = term[item];\n } else {\n if (item != last) {\n term[item] = {};\n term = term[item]\n } else {\n term[item] = data[i]\n }\n }\n })\n\n }\n\n return unnested;\n },\n flatten: function (definition) {\n return _getFieldsAsArray(definition, null);\n },\n field: _getField,\n fieldProperty: _getFieldProperty,\n asTree: function (form) {\n let formItems;\n if (form.version) formItems = _convertFormToTree(form.version.definition, null, \"Form\");\n if (!form.version) formItems = _convertFormToTree(form, null, \"Form\");\n\n if (form.location_aware) {\n formItems.unshift({\n label: ewars.formatters.I18N_FORMATTER({\n en: \"Report Location\"\n }),\n field: {\n type: \"location\",\n required: true\n },\n nodeType: \"location\",\n type: \"location\",\n name: \"location_id\",\n path: \"form/location_id\",\n pathLabel: \"Form / Location\"\n })\n }\n\n formItems.unshift({\n label: ewars.formatters.I18N_FORMATTER({\n en: \"Report Date\"\n }),\n type: \"date\",\n field: {\n type: \"date\",\n required: true\n },\n nodeType: \"date\",\n name: \"data_date\",\n path: \"form/data_date\",\n pathLabel: \"Form / Report Date\"\n });\n\n return [{\n nodeType: \"form\",\n label: \"Form\",\n name: \"form\",\n field: {\n type: \"form\"\n },\n type: \"form\",\n children: formItems\n }];\n }\n};\n","const Moment = require(\"moment\");\n\nlet RangeUtils = {};\n\nconst OFFSET_REG = /([-|+][0-9]*[DWMY])/g;\nconst DATE_REG = /([0-9]{4}-[0-9]{2}-[0-9]{2})/;\nconst CODE_REG = /^([{][A-Z_]*[}])/;\n\nconst NUMERALS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];\n\nconst CODES = {\n \"{D_DATE}\": \"Document date\",\n \"{NOW}\": \"Today\",\n \"{END}\": \"End date\",\n \"{D_W_S}\": \"Document week start\",\n \"{D_W_E}\": \"Document week end\",\n \"{D_M_S}\": \"Document month start\",\n \"{D_M_E}\": \"Document month end\",\n \"{D_Y_S}\": \"Document year start\",\n \"{D_Y_E}\": \"Document year end\",\n \"{N_W_S}\": \"This week start\",\n \"{N_W_E}\": \"This week end\",\n \"{N_M_S}\": \"This month start\",\n \"{N_M_E}\": \"This month end\",\n \"{N_Y_F_W}\": \"This year first week\",\n \"{N_Y_S}\": \"This year start\",\n \"{N_Y_E}\": \"This year end\",\n \"{D_Y_S_ISO\": \"Document year start (ISO)\",\n \"{D_Y_E_ISO\": \"Document year end (ISO)\",\n \"{N_Y_F_W_S}\": \"This year first week start\",\n \"{N_Y_F_W_E}\": \"This year first week end\",\n \"{D_Y_F_W_S}\": \"Document year first week start\",\n \"{D_Y_F_W_E}\": \"Document year first week end\",\n \"{N_Y_L_W}\": \"This year last week end\",\n \"{D_Y_L_W}\": \"Document year last week end\" \n\n\n};\n\nconst PRESETS_DEFAULT = {\n \"-30D\": [\"{NOW}-30D\", \"{NOW}\"],\n \"-60D\": [\"{NOW}-60D\", \"{NOW}\"],\n \"-6M\": [\"{NOW}-6M\", \"{NOW}\"],\n \"-1Y\": [\"{NOW}-1Y\", \"{NOW}\"],\n \"-2Y\": [\"{NOW}-2Y\", \"{NOW}\"],\n \"-5Y\": [\"{NOW}-5Y\", \"{NOW}\"],\n \"-1D\": [\"{NOW}-1D\", \"{NOW}-1D\"],\n \"-2D\": [\"{NOW}-2D\", \"{NOW}-2D\"],\n \"-7D\": [\"{NOW}-7D\", \"{NOW}-7D\"],\n \"PREV_WEEK\": [\"{N_W_S}-1W\", \"{N_W_E}-1W\"],\n \"PREV_52_WEEKS\":[\"{N_W_S}-52W\", \"{N_W_E}-1W\"],\n \"PREV_MONTH\": [\"{N_M_S}-1M\", \"{N_M_E}-1M\"],\n \"PREV_YEAR\": [\"{N_Y_S}-1Y\", \"{N_Y_E}-1Y\"],\n \"NOW\": [\"{NOW}\", \"{NOW}\"],\n \"CUR_WEEK\": [\"{N_W_S}\", \"{N_W_E}\"],\n \"CUR_MONTH\": [\"{N_M_S}\", \"{N_M_E}\"],\n \"CUR_YEAR\": [\"{N_Y_S}\", \"{N_Y_E}\"],\n \"CUR_YEAR_FIRST_WEEK\" : [\"{N_Y_F_W_S}\",\"{N_Y_F_W_E}\"],\n \"CUR_YEAR_52_WEEKS\" : [\"{N_Y_F_W_S}\",\"{N_Y_F_W_E}+51W\"],\n \"CUR_YEAR_WEEKS\" : [\"{N_Y_F_W_S}\",\"{N_Y_L_W}\"],\n\n // TEMPLATE PRESETS\n \"DD-30D\": [\"{D_DATE}-30D\", \"{D_DATE}\"],\n \"DD-60D\": [\"{D_DATE}-60D\", \"{D_DATE}\"],\n \"DD-6M\": [\"{D_DATE}-6M\", \"{D_DATE}\"],\n \"DD-1Y\": [\"{D_DATE}-1Y\", \"{D_DATE}\"],\n \"DD-2Y\": [\"{D_DATE}-2Y\", \"{D_DATE}\"],\n \"DD-5Y\": [\"{D_DATE}-5Y\", \"{D_DATE}\"],\n \"DD-1D\": [\"{D_DATE}-1D\", \"{D_DATE}-1D\"],\n \"DD-2D\": [\"{D_DATE}-2D\", \"{D_DATE}-2D\"],\n \"DD-7D\": [\"{D_DATE}-7D\", \"{D_DATE}-7D\"],\n \"D_PREV_WEEK\": [\"{D_W_S}-1W\", \"{D_W_E}-1W\"],\n \"D_PREV_MONTH\": [\"{D_M_S}-1M\", \"{D_M_E}-1M\"],\n \"D_PREV_YEAR\": [\"{D_Y_S}-1Y\", \"{D_Y_E}-1Y\"],\n \"D_DATE\": [\"{D_DATE}\", \"{D_DATE}\"],\n \"D_CUR_WEEK\": [\"{D_W_S}\", \"{D_W_E}\"],\n \"D_CUR_MONTH\": [\"{D_M_S}\", \"{D_M_E}\"],\n \"D_CUR_YEAR\": [\"{D_Y_S}\", \"{D_Y_E}\"],\n \"D_YEAR_FIRST_WEEK\" : [\"{D_Y_F_W_S}\",\"{D_Y_F_W_E}\"],\n \"D_YEAR_WEEKS\" : [\"{D_Y_F_W_S}\",\"{D_Y_L_W}\"],\n \"D_YEAR_52_WEEKS\" : [\"{D_Y_F_W_S}\",\"{D_Y_F_W_E}+51W\"],\n\n};\n\nconst PRESETS_TEMPLATE = {\n \"-30D\": [\"{D_DATE}-30D\", \"{D_DATE}\"],\n \"-60D\": [\"{D_DATE}-60D\", \"{D_DATE}\"],\n \"-6M\": [\"{D_DATE}-6M\", \"{D_DATE}\"],\n \"-1Y\": [\"{D_DATE}-1Y\", \"{D_DATE}\"],\n \"-2Y\": [\"{D_DATE}-2Y\", \"{D_DATE}\"],\n \"-5Y\": [\"{D_DATE}-5Y\", \"{D_DATE}\"],\n \"-1D\": [\"{D_DATE}-1D\", \"{D_DATE}\"],\n \"-2D\": [\"{D_DATE}-2D\", \"{D_DATE}\"],\n \"-7D\": [\"{D_DATE}-7D\", \"{D_DATE}\"],\n \"PREV_WEEK\": [\"{D_W_S}-7D\", \"{D_W_E}-7D\"],\n \"PREV_MONTH\": [\"{D_M_S}-1M\", \"{D_M_E}-1M\"],\n \"PREV_YEAR\": [\"{D_Y_S}-1Y\", \"{D_Y_E}-1Y\"],\n \"NOW\": [\"{D_DATE}\", \"{D_DATE}\"],\n \"CUR_WEEK\": [\"{D_W_S}\", \"{D_W_E}\"],\n \"CUR_MONTH\": [\"{D_M_S}\", \"{D_M_E}\"],\n \"CUR_YEAR\": [\"{D_Y_S}\", \"{D_Y_E}\"]\n};\n\nconst INT_MARKERS = [\"D\", \"W\", \"M\", \"Y\"];\nconst DIGITS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];\n\nconst DIGIT_STRINGS = {\n D: \"day(s)\",\n W: \"week(s)\",\n M: \"month(s)\",\n Y: \"year(s)\"\n};\n\nRangeUtils.processPreset = function (preset) {\n return PRESETS_DEFAULT[preset];\n};\n\nRangeUtils.formatDateSpec = function (dateSpec) {\n let result = \"\";\n\n if (DATE_REG.test(dateSpec)) {\n let datePortion = dateSpec.match(DATE_REG)[0];\n let offset = RangeUtils.getOffset(dateSpec);\n\n if (offset == \"\") {\n return datePortion;\n }\n\n result = datePortion;\n\n if (offset.indexOf(\"-\") >= 0) {\n result = result + \" - \";\n offset = offset.replace(\"-\", \"\");\n }\n\n if (offset.indexOf(\"+\") >= 0) {\n result = result + \" + \";\n offset = offset.replace(\"+\", \"\");\n }\n\n let lastChar = offset.substr(offset.length - 1);\n let period;\n if (INT_MARKERS.indexOf(lastChar) >= 0) {\n period = DIGIT_STRINGS[lastChar];\n offset = offset.replace(lastChar, \"\");\n } else {\n period = \"day(s)\";\n }\n\n result = result + \" \" + offset + \" \" + period;\n return result;\n\n } else if (CODE_REG.test(dateSpec)) {\n let codePortion = dateSpec.match(CODE_REG)[0];\n let offset = RangeUtils.getOffset(dateSpec);\n\n result = CODES[codePortion];\n let arr_offset = dateSpec.match(OFFSET_REG) || [];\n for (let i = 0 ; i= 0) {\n result = result + \" - \";\n offset = offset.replace(\"-\", \"\");\n }\n \n if (offset.indexOf(\"+\") >= 0) {\n result = result + \" + \";\n offset = offset.replace(\"+\", \"\");\n }\n \n let lastChar = offset.substr(offset.length - 1);\n let period;\n if (INT_MARKERS.indexOf(lastChar) >= 0) {\n period = DIGIT_STRINGS[lastChar];\n offset = offset.replace(lastChar, \"\");\n } else {\n period = \"day(s)\";\n }\n \n result = result + \" \" + offset + \" \" + period;\n \n }\n\n\n\n return result;\n }\n\n return dateSpec;\n};\n\n\n/**\n * Check if the string is a date\n * @param dateSpec\n * @returns {boolean}\n */\nRangeUtils.isDate = function (dateSpec) {\n return DATE_REG.test(dateSpec);\n};\n\nRangeUtils.getDate = function (dateSpec) {\n return dateSpec.match(DATE_REG)[0];\n};\n\n/**\n * Determine if a date specification contains a code\n * @param dateSpec\n * @returns {boolean}\n */\nRangeUtils.hasCode = function (dateSpec) {\n let hasCode = false;\n\n for (let i in CODES) {\n if (dateSpec.indexOf(i) >= 0) hasCode = true;\n }\n\n return hasCode;\n};\n\nRangeUtils.getCode = function (dateSpec) {\n let code;\n\n for (let i in CODES) {\n if (dateSpec.indexOf(i) >= 0) code = i;\n }\n\n code = code.replace(\"{\", \"\");\n code = code.replace(\"}\", \"\");\n\n return code;\n};\n\n/**\n * Test if a string contains an offset\n * @param dateSpec\n * @returns {boolean}\n */\nRangeUtils.hasOffset = function (dateSpec) {\n let result = OFFSET_REG.test(dateSpec); // We don't have a full offset, but we might have a partial\n\n return result;\n};\n\n/**\n * Get the offset out of a string spec\n * @param dateSpec\n * @returns {string}\n */\nRangeUtils.getOffset = function (dateSpec) {\n let result = \"\";\n\n if (DATE_REG.test(dateSpec)) {\n // This has a date in it, let's get it and strip it\n let tested = dateSpec.match(DATE_REG);\n result = dateSpec.replace(tested[0], \"\");\n return result;\n } else if (CODE_REG.test(dateSpec)) {\n let codeTest = dateSpec.match(CODE_REG);\n result = dateSpec.replace(codeTest[0], \"\");\n return result;\n }\n};\n\n\n/**\n * Apply an offset to the date spec\n * @param dateSpec\n * @param newOffset\n * @returns {*}\n */\nRangeUtils.applyOffset = function (dateSpec, newOffset) {\n let curOffset = RangeUtils.getOffset(dateSpec);\n\n if (curOffset == \"\") {\n return dateSpec + newOffset;\n } else {\n if (DATE_REG.test(dateSpec)) {\n let origDate = dateSpec.match(DATE_REG)[0];\n return origDate + newOffset;\n } else if (CODE_REG.test(dateSpec)) {\n let origCode = dateSpec.match(CODE_REG)[0];\n return origCode + newOffset;\n }\n }\n\n return dateSpec;\n};\n\nRangeUtils.parseCode = function (code, reportDate, endDate) {\n Moment.updateLocale(\"en\", {\n week: {\n dow: ewars.getDOWMod7(),\n doy: (7 + ewars.getDOWMod7() - ewars.getDOY())\n }\n });\n \n switch (code) {\n case \"{NOW}\":\n return Moment.utc().format(\"YYYY-MM-DD\");\n case \"{D_DATE}\":\n return Moment.utc(reportDate).format(\"YYYY-MM-DD\");\n case \"{END}\":\n return endDate;\n case \"{D_W_S}\":\n return Moment.utc(reportDate).clone().startOf(\"week\").format(\"YYYY-MM-DD\");\n case \"{D_W_E}\":\n return Moment.utc(reportDate).clone().endOf(\"week\").format(\"YYYY-MM-DD\");\n case \"{D_M_S}\":\n return Moment.utc(reportDate).clone().startOf(\"month\").format(\"YYYY-MM-DD\");\n case \"{D_M_E}\":\n return Moment.utc(reportDate).clone().endOf(\"month\").format(\"YYYY-MM-DD\");\n case \"{D_Y_S}\":\n return Moment.utc(reportDate).clone().startOf(\"year\").format(\"YYYY-MM-DD\");\n case \"{D_Y_E}\":\n return Moment.utc(reportDate).clone().endOf(\"year\").format(\"YYYY-MM-DD\");\n case \"{N_W_S}\":\n return Moment.utc().startOf(\"week\").format(\"YYYY-MM-DD\");\n case \"{N_W_E}\":\n return Moment.utc().endOf(\"week\").format(\"YYYY-MM-DD\");\n case \"{N_M_S}\":\n return Moment.utc().startOf(\"month\").format(\"YYYY-MM-DD\");\n case \"{N_M_E}\":\n return Moment.utc().endOf(\"month\").format(\"YYYY-MM-DD\");\n case \"{N_Y_S}\":\n return Moment.utc().startOf(\"year\").format(\"YYYY-MM-DD\");\n case \"{N_Y_E}\":\n return Moment.utc().endOf(\"year\").format(\"YYYY-MM-DD\");\n case \"{D_Y_S_ISO}\":\n return Moment.utc(reportDate).week(1).endOf('week').format('YYYY-MM-DD');\n case '{D_Y_E_ISO}':\n let weeksInYear = 53;\n return Moment.utc(reportDate).week(weeksInYear).endOf('week').format('YYYY-MM-DD');\n case \"{N_Y_F_W_S}\":\n return Moment.utc().week(1).startOf('week').format('YYYY-MM-DD');\n \n case \"{N_Y_L_W}\":\n let lw = Moment.utc().weeksInYear();\n return Moment.utc().week(lw).endOf('week').format('YYYY-MM-DD');\n \n case \"{D_Y_L_W}\":\n let dlw = Moment.utc(reportDate).weeksInYear();\n return Moment.utc().week(dlw).endOf('week').format('YYYY-MM-DD');\n \n case \"{N_Y_F_W_E}\":\n return Moment.utc().week(1).endOf('week').format('YYYY-MM-DD');\n case \"{D_Y_F_W_S}\":\n return Moment.utc(reportDate).week(1).startOf('week').format('YYYY-MM-DD');\n \n case \"{D_Y_F_W_E}\":\n return Moment.utc(reportDate).week(1).endOf('week').format('YYYY-MM-DD');\n \n default:\n return Moment.utc().format(\"YYYY-MM-DD\");\n }\n};\n\nRangeUtils.getOperator = function (offset) {\n if (offset.indexOf(\"-\") >= 0) {\n return \"-\";\n }\n\n if (offset.indexOf(\"+\") >= 0) {\n return \"+\";\n }\n\n return \"+\";\n};\n\nRangeUtils.getRawOffset = function (offset) {\n let result = offset.replace(\"-\", \"\");\n result = result.replace(\"+\", \"\");\n result = result.replace(\"D\", \"\");\n result = result.replace(\"W\", \"\");\n result = result.replace(\"M\", \"\");\n result = result.replace(\"Y\", \"\");\n\n return result;\n};\n\nRangeUtils._replaceAll = function (str, find, replace) {\n var re = new RegExp(find, 'g');\n str = str.replace(re, replace);\n return str;\n};\n\n\nRangeUtils.getInterval = function (offset) {\n let result = offset.replace(\"-\", \"\");\n result = result.replace(\"+\", \"\");\n\n for (var i in NUMERALS) {\n result = RangeUtils._replaceAll(result,NUMERALS[i], \"\");\n }\n\n return result;\n};\n\nRangeUtils.getAsDays = function (count, period) {\n if (period == \"D\") return count;\n if (period == \"W\") return count * 7;\n if (period == \"M\") return count * 30;\n if (period == \"Y\") return count * 365;\n};\n\nRangeUtils.sortOffsetArray = function (offset) {\n let sorted = [];\n let years = [];\n let weeks = [];\n let months = [];\n let days = [];\n for (let val of offset){\n if(val.indexOf(\"Y\") != -1){\n years.push(val);\n }\n else if(val.indexOf(\"M\") != -1){\n months.push(val);\n }\n else if(val.indexOf(\"W\") != -1){\n weeks.push(val);\n }\n else{\n days.push(val);\n }\n }\n sorted = [...years,...months,...weeks,...days]; \n return sorted;\n};\n/**\n * Process a date spec into an actual date\n */\nRangeUtils.process = function (dateSpec, reportDate, endDate) {\n let code, offset, spec;\n let arr_offset = [];\n\n Moment.updateLocale(\"en\", {\n week: {\n dow: ewars.getDOWMod7(),\n doy: (7 + ewars.getDOWMod7() - ewars.getDOY())\n }\n });\n \n let resultDate;\n let doy = ewars.getDOY();\n\n if (CODE_REG.test(dateSpec)) {\n code = dateSpec.match(CODE_REG)[0];\n }\n\n if (DATE_REG.test(dateSpec)) {\n spec = dateSpec.match(DATE_REG)[0];\n }\n\n if (OFFSET_REG.test(dateSpec)) {\n arr_offset = dateSpec.match(OFFSET_REG);\n // sort offset with year , month , week and day\n arr_offset = RangeUtils.sortOffsetArray(arr_offset);\n offset = arr_offset[0];\n }\n\n if (!code && !offset) return spec;\n\n if (code && !offset) {\n return RangeUtils.parseCode(code, reportDate)\n }\n\n if (code && offset) {\n let result = RangeUtils.parseCode(code, reportDate, endDate);\n let operator = RangeUtils.getOperator(offset);\n let rawValue = RangeUtils.getRawOffset(offset);\n let interval = RangeUtils.getInterval(offset);\n\n let recResult;\n result = Moment.utc(result);\n if ((code == \"{N_Y_F_W_S}\" || code == \"{D_Y_F_W_S}\" ) && interval == \"Y\"){\n \n if (operator == \"-\") {\n let year = result.add(parseInt(7), \"d\").year();\n year = year - parseInt(rawValue);\n let date = Moment.utc([year, 0, doy]);\n recResult = date.week(1).startOf('week');\n }\n else{\n let year = result.add(parseInt(7), \"d\").year();\n year = year + parseInt(rawValue);\n let date = Moment.utc([year, 0, doy]);\n recResult = date.week(1).startOf('week');\n }\n\n\n }\n else if((code == \"{N_Y_F_W_E}\" || code == \"{D_Y_F_W_E}\") && interval == \"Y\"){\n \n if (operator == \"-\") {\n let year = result.year();\n year = year - parseInt(rawValue);\n let date = Moment.utc([year, 0, doy]);\n recResult = date.week(1).endOf('week');\n }\n else{\n let year = result.year();\n year = year + parseInt(rawValue);\n let date = Moment.utc([year, 0, doy]);\n recResult = date.week(1).endOf('week');\n }\n }\n else if((code == \"{N_Y_L_W}\" || code == \"{D_Y_L_W}\") && interval == \"Y\"){\n if (operator == \"-\") {\n let year = result.subtract(parseInt(7), \"d\").year();\n year = year - parseInt(rawValue);\n let lw = Moment.utc([year, 0, doy]).weeksInYear();\n recResult = Moment.utc([year, 0, doy]).week(lw).endOf('week');\n }\n else{\n let year = result.subtract(parseInt(7), \"d\").year();\n year = year + parseInt(rawValue);\n let lw = Moment.utc([year, 0, doy]).weeksInYear();\n recResult = Moment.utc([year, 0, doy]).week(lw).endOf('week');\n }\n }\n \n else{\n\n let calcOffsetDays = RangeUtils.getAsDays(rawValue, interval);\n \n if (operator == \"-\") recResult = result.subtract(parseInt(calcOffsetDays), \"d\");\n if (operator == \"+\") recResult = result.add(parseInt(calcOffsetDays), \"d\");\n }\n\n\n for (let i =1 ; i window.user.role == \"REGIONAL_ADMIN\"\n\n\nexport const isLocGroupAssigned = () => !!window.user.location_group; \n\nexport const isRegionalAdminWithLocGroup = () => {\n return isRegionalAdmin() && isLocGroupAssigned(); \n}\n\n","import { startState } from \"codemirror\";\nimport Moment from \"moment\";\nimport CONSTANTS from \"../../common/constants\";\n\n/**\n * Get most recently compvared interval date\n * @param specDate\n * @param interval\n * @returns {*}\n */\nvar getActualDate = function (specDate, interval, no_future) {\n \n Moment.updateLocale(\"en\", {\n week: {\n dow: ewars.getDOWMod7(),\n doy: (7 + ewars.getDOWMod7() - ewars.getDOY()) \n }\n });\n\n if (interval == CONSTANTS.DAY) return specDate;\n\n if (interval == CONSTANTS.WEEK) {\n var actualEndWeek = specDate.clone().endOf(\"week\");\n\n if (no_future) {\n if (actualEndWeek.isAfter(specDate, \"d\")) {\n return actualEndWeek.clone().subtract(7, \"d\");\n } else {\n return actualEndWeek;\n }\n } else {\n return actualEndWeek;\n }\n }\n\n if (interval == CONSTANTS.MONTH) {\n var actualEndMonth = specDate.clone().endOf(\"month\");\n\n if (specDate.isSame(actualEndMonth, \"day\")) return actualEndMonth;\n if (specDate.isBefore(actualEndMonth, \"day\")) return actualEndMonth.clone()\n .subtract(1, \"M\")\n .endOf(\"month\");\n }\n\n if (interval == CONSTANTS.YEAR) {\n var actualEndYear = specDate.clone().endOf(\"year\");\n\n if (specDate.isSame(actualEndYear, \"day\")) return actualEndYear;\n if (specDate.isBefore(actualEndYear, \"day\"))\n return actualEndYear.clone().subtract(1, \"y\").endOf(\"year\");\n }\n};\n\nvar getDaysBetween = function (startDate, endDate) {\n var resultantDates = [startDate];\n\n var cur_date = startDate.clone();\n\n while (cur_date.isBefore(endDate, CONSTANTS.DAY)) {\n var newDate = cur_date.clone().add(1, \"d\");\n resultantDates.push(newDate);\n cur_date = newDate;\n }\n\n return resultantDates;\n\n};\n\nvar getWeeksBetween = function (startDate, endDate) {\n var resultantDates = [startDate.clone()];\n\n var cur_date = startDate.clone();\n\n while (cur_date.isBefore(endDate, \"day\")) {\n var newDate = cur_date.clone().add(7, \"d\");\n resultantDates.push(newDate);\n cur_date = newDate;\n }\n\n\n return resultantDates;\n\n};\n\nvar getMonthsBetween = function (startDate, endDate) {\n\n};\n\nvar getYearsBetween = function (startDate, endDate) {\n\n};\n\nvar INTERVAL_MAP = {\n \"NONE\": \"d\",\n \"DAY\": \"d\",\n \"WEEK\": \"d\",\n \"MONTH\": \"M\",\n \"YEAR\": \"Y\"\n};\n\n/**\n * retrieve the most recently completed interval from a date\n * @param sourceDate The date to source from\n * @param interval The interval type\n * @returns {*}\n */\nfunction getMostRecentlyCompletedInterval(sourceDate, interval) {\n if (interval == \"DAY\") return Moment.utc(sourceDate).clone().subtract(1, \"d\");\n if (interval == \"WEEK\") {\n let selectedWeek = Moment.utc(sourceDate).clone();\n let today = Moment.utc();\n\n if (selectedWeek.isAfter(today, 'day') || selectedWeek.isSame(today, 'day')) {\n // Date is in the future or same date, get the last completed week from todays date\n let prevEnd = today.subtract(7, 'd');\n prevEnd.weekday(7);\n return prevEnd;\n } else {\n // The date is before the current date in this case, we need to find the last completed week\n let curEnd = sourceDate.clone();\n curEnd = curEnd.weekday(7);\n return curEnd;\n }\n\n }\n if (interval == \"MONTH\") return Moment.utc(sourceDate).clone();\n if (interval == \"YEAR\") return Moment.utc(sourceDate).clone();\n return Moment.utc(sourceDate).clone();\n}\n\nfunction getBeginningOfPeriod(sourceDate, interval) {\n if (interval == \"DAY\") return sourceDate.clone();\n if (interval == \"WEEK\") {\n let selectedWeek = sourceDate.clone();\n selectedWeek.weekday(1);\n return selectedWeek;\n }\n\n if (interval == \"MONTH\") {\n return sourceDate\n .clone()\n .day(1);\n }\n\n if (interval == \"YEAR\") {\n return sourceDate\n .clone()\n .month(1)\n .day(1);\n }\n}\n\nconst DateUtils = {\n /**\n * Returns a list of dates occurring between two dates\n * of a specific interval type\n * @param start_date\n * @param end_date\n * @param interval\n */\n getDatesInInterval: function (start_date, end_date, interval) {\n\n var startDate = Moment.utc(start_date),\n endDate;\n\n if (end_date) endDate = Moment.utc(end_date);\n if (!end_date) endDate = Moment();\n\n if (interval == CONSTANTS.DAY) endDate.subtract(1, 'd');\n\n var actualEnd = getActualDate(endDate, interval, true);\n var actualStart = getActualDate(startDate, interval);\n\n if (interval == CONSTANTS.DAY) return getDaysBetween(actualStart, actualEnd);\n if (interval == CONSTANTS.WEEK) return getWeeksBetween(actualStart, actualEnd);\n if (interval == CONSTANTS.MONTH) return getMonthsBetween(actualStart, actualEnd);\n if (interval == CONSTANTS.YEAR) return getYearsBetween(actualStart, actualEnd);\n\n return []\n },\n\n getMostRecentlyEndedInterval: function (reportDate, interval) {\n return getActualDate(reportDate, interval);\n },\n\n getStartDate: function (specDate, interval) {\n Moment.updateLocale(\"en\", {\n week: {\n dow: ewars.getDOWMod7(),\n doy: (7 + ewars.getDOWMod7() - ewars.getDOY()) \n }\n });\n \n if (!interval) return Moment(specDate).clone();\n if (interval == CONSTANTS.NONE) return Moment(specDate).clone();\n if (interval == CONSTANTS.DAY) return Moment(specDate).clone();\n if (interval == CONSTANTS.WEEK) return Moment(specDate).clone().startOf(\"week\");\n if (interval == CONSTANTS.MONTH) return Moment(specDate).clone().startOf(\"month\");\n if (interval == CONSTANTS.YEAR) return Moment(specDate).clone().startOf(\"year\");\n },\n\n getEndDate: function (specDate, interval) {\n Moment.updateLocale(\"en\", {\n week: {\n dow: ewars.getDOWMod7(),\n doy: (7 + ewars.getDOWMod7() - ewars.getDOY()) \n }\n });\n\n if (!interval) return Moment(startDate).clone();\n if (interval == CONSTANTS.NONE) return Moment(specDate).clone();\n if (interval == CONSTANTS.DAY) return Moment(specDate).clone();\n if (interval == CONSTANTS.WEEK) return Moment(specDate).clone().endOf(\"week\");\n if (interval == CONSTANTS.MONTH) return Moment(specDate).clone().endOf(\"month\");\n if (interval == CONSTANTS.YEAR) return Moment(specDate).clone().endOf(\"year\");\n },\n\n processDateSpec: function (definition, reportDate) {\n var startDate,\n endDate;\n\n Moment.updateLocale(\"en\", {\n week: {\n dow: ewars.getDOWMod7(),\n doy: (7 + ewars.getDOWMod7() - ewars.getDOY()) \n }\n });\n \n if (definition.filter) {\n if (!reportDate) endDate = Moment.utc();\n var filterSpec = definition.filter;\n\n if (filterSpec == \"1M\") startDate = endDate.clone().subtract(1, 'M');\n if (filterSpec == \"3M\") startDate = endDate.clone().subtract(3, \"M\");\n if (filterSpec == \"6M\") startDate = endDate.clone().subtract(6, \"M\");\n if (filterSpec == \"1Y\") startDate = endDate.clone().subtract(1, \"Y\");\n if (filterSpec == \"YTD\") {\n startDate = endDate.clone().startOf(\"year\");\n }\n if (filterSpec == \"ALL\") startDate = endDate.clone().subtract(20, \"Y\");\n\n } else if (definition.end_date_spec && definition.start_date_spec) {\n if (definition.end_date_spec == \"MANUAL\") {\n endDate = Moment.utc(definition.end_date);\n }\n\n if (definition.end_date_spec == \"CURRENT\") {\n endDate = Moment.utc();\n\n endDate = getMostRecentlyCompletedInterval(endDate, definition.interval || \"DAY\");\n }\n\n if (definition.end_date_spec == \"REPORT_DATE\") {\n endDate = Moment.utc(reportDate);\n }\n\n if (definition.end_date_spec == \"REPORT_DATE_SUBTRACTION\") {\n var units = parseInt(definition.end_intervals);\n // If the time interval is weeks, we use days for the subtraction as\n // isoweeks isn't very reliable\n var interval = definition.timeInterval || definition.interval;\n if (interval == \"WEEK\") {\n units = 7 * units;\n }\n endDate = Moment.utc(reportDate).clone().subtract(units, \"d\");\n }\n\n if (definition.start_date_spec == \"MANUAL\") {\n startDate = Moment.utc(definition.start_date);\n }\n\n if (definition.start_date_spec == \"END_SUBTRACTION\") {\n var units = parseInt(definition.start_intervals);\n // If the time interval is weeks, we use days for the subtraction as\n // isoweeks isn't very reliable\n var interval = definition.timeInterval || definition.interval;\n if (definition.type == \"RAW\" && !interval) interval = \"WEEK\";\n\n if (interval == \"WEEK\") {\n units = 7 * units;\n }\n\n startDate = Moment(endDate).clone().subtract(units, 'd');\n }\n\n if (definition.start_date_spec == \"CURRENT\") {\n let tmpEndDate = getMostRecentlyCompletedInterval(startDate, definition.interval || \"DAY\");\n startDate = getBeginningOfPeriod(tmpEndDate, definition.interval || \"DAY\");\n }\n\n if (definition.start_date_spec == \"REPORT_DATE\") {\n var interval = definition.timeInterval || definition.interval;\n startDate = Moment.utc(reportDate).startOf(INTERVAL_MAP[interval || \"NONE\"]);\n }\n\n return [startDate.format(\"YYYY-MM-DD\"), endDate.format(\"YYYY-MM-DD\")];\n } else {\n startDate = Moment.utc(definition.start_date);\n endDate = Moment.utc(definition.end_date);\n }\n\n return [startDate.format(\"YYYY-MM-DD\"), endDate.format(\"YYYY-MM-DD\")];\n\n },\n\n getNextPeriod: function (startDate, interval) {\n if ([CONSTANTS.NONE, CONSTANTS.DAY].indexOf(interval) >= 0) return startDate.clone().add(1, 'd');\n if (interval == CONSTANTS.WEEK) return startDate.clone().add(7, 'd');\n if (interval == CONSTANTS.MONTH) return null;\n if (interval == CONSTANTS.YEAR) return startDate.clone().add(365, \"d\");\n },\n\n getPreviousPeriod: function (startDate, interval) {\n if ([CONSTANTS.NONE, CONSTANTS.DAY].indexOf(interval) >= 0) return startDate.clone().subtract(1, \"d\");\n if (interval == CONSTANTS.WEEK) return startDate.clone().subtract(7, 'd');\n if (interval == CONSTANTS.MONTH) return null;\n if (interval == CONSTANTS.YEAR) return startDate.clone().subtract(365, 'd');\n },\n\n getCurrentWeek: function(date){\n let dow = ewars.getDOWMod7();\n Moment.updateLocale(\"en\", { week: {\n dow: dow, \n doy: (7 + ewars.getDOWMod7() - ewars.getDOY()) // First week of year must contain 4 January (7 + 1 - 4)\n }});\n let week_no = Moment(date, \"YYYY-MM-DD\").week();\n return week_no;\n },\n\n formatWeekInterval: function (date){\n let dow = ewars.getDOWMod7();\n Moment.updateLocale(\"en\", { week: {\n dow: dow, \n doy: (7 + ewars.getDOWMod7() - ewars.getDOY()) // First week of year must contain 4 January (7 + 1 - 4)\n }});\n \n let startDate = Moment(date).startOf('week');\n let startDay = startDate.date();\n let startMonth = startDate.month();\n let startYear = startDate.year();\n let endDay = Moment(date).endOf('week').date();\n date = new Date(Date.parse(date));\n let weekNo = Moment(date, \"YYYY-MM-DD\").week();\n startDate = Moment([startYear, startMonth, startDay]).format('YYYY-MM-DD');\n let midDate = Moment(startDate, \"YYYY-MM-DD\").add(3, 'days');\n let year = midDate.year();\n let month = midDate.format(\"MMMM\");\n let formattedInterval = \" W\"+weekNo+ \" | \"+startDay+\"-\"+endDay+\" \"+month+ \" \"+year;\n return formattedInterval;\n },\n\n formatMonthInterval: function (date){\n let dow = ewars.getDOWMod7();\n Moment.updateLocale(\"en\", { week: {\n dow: dow, \n doy: (7 + ewars.getDOWMod7() - ewars.getDOY()) // First week of year must contain 4 January (7 + 1 - 4)\n }});\n date = new Date(Date.parse(date));\n date = Moment(date, \"YYYY-MM-DD\");\n let year = date.year();\n let month = date.format(\"MMMM\");\n let formattedInterval = \" \"+month+ \" \"+year;\n return formattedInterval;\n },\n\n formatYearInterval: function (date){\n let dow = ewars.getDOWMod7();\n Moment.updateLocale(\"en\", { week: {\n dow: dow, \n doy: (7 + ewars.getDOWMod7() - ewars.getDOY()) // First week of year must contain 4 January (7 + 1 - 4)\n }});\n date = new Date(Date.parse(date));\n date = Moment(date, \"YYYY-MM-DD\");\n let year = date.year();\n let formattedInterval = \" \"+year;\n return formattedInterval;\n },\n\n formatDayInterval: function (date){\n let dow = ewars.getDOWMod7();\n Moment.updateLocale(\"en\", { week: {\n dow: dow, \n doy: (7 + ewars.getDOWMod7() - ewars.getDOY()) // First week of year must contain 4 January (7 + 1 - 4)\n }});\n date = new Date(Date.parse(date));\n date = Moment(date, \"YYYY-MM-DD\");\n let day = date.date();\n let month = date.format(\"MMMM\");\n let year = date.year();\n let formattedInterval = \" \"+day+\" \"+month+\" \"+year;\n return formattedInterval;\n },\n\n formatInterval: function(date,interval){\n if ([CONSTANTS.NONE, CONSTANTS.DAY].indexOf(interval) >= 0) return this.formatDayInterval(date);\n if (interval == CONSTANTS.WEEK) return this.formatWeekInterval(date);\n if (interval == CONSTANTS.MONTH) return this.formatMonthInterval(date);\n if (interval == CONSTANTS.YEAR) return this.formatYearInterval(date);\n\n }\n\n};\n\nexport default DateUtils;\n","import \"@babel/polyfill\";\nimport * as ProfileEN from '../profile/lang/en';\nwindow.__assign_hack__ = window.__hack__ = document.getElementById(\"application\");\n\newars = {};\n\nconst i18n = function (code,isDoubleLanguage = null) {\n let userLang = navigator.language || navigator.userLanguage;\n if (!code) return \"UNKNOWN\";\n // Check if this is an internationalization string\n if (JSON.stringify(code).indexOf(\"{\") >= 0) {\n return code.en;\n }\n // Get users lang and load string\n if (__.__dict__[code]) {\n if (isDoubleLanguage){\n if (window.user.language != 'en'){\n if (!__.__dict__[code].includes(\"(\")){\n __.__dict__[code] = __.__dict__[code] +\" ( \"+ProfileEN[code]+\" )\"\n }\n return __.__dict__[code];\n }\n else{\n return __.__dict__[code];\n }\n }else{\n return __.__dict__[code];\n }\n } else {\n return code;\n }\n};\newars.__ = i18n;\nwindow.__ = i18n;\nwindow._l = i18n;\n\nwindow.__.__dict__ = EN;\n\nwindow.__.register = function (items) {\n for (let key in items) {\n __.__dict__[key] = items[key];\n }\n};\n\nwindow.__.registerTranslation = function (moduleName) {\n const translation = window.localStorage.getItem(\"translation\");\n if (translation) {\n const languagesTranslation = JSON.parse(translation);\n __.register(languagesTranslation[moduleName]);\n }\n};\n\nwindow.__.registerTranslation('ewars');\n\nimport notifications from \"./components/notifications\";\n\nimport formatters from \"./utils/formatters\";\nimport general from \"./utils/general\";\nimport Cache from \"./utils/cache\";\nimport prompt from \"./components/prompt\";\nimport Blocker from \"./components/Blocker\";\nimport Confirmation from \"./components/Confirmation\";\nimport Combi from \"./lib/combi\";\nimport EN from \"./lang/en.js\";\nimport utils from \"../ewars/utils/general\";\nimport IdleTimeout from './components/idle-timer';\nimport LockModal from './components/locker';\n\nconst setIdleTime = function(isModalClosed) {\n const idleElement = document.getElementById('idle-timer');\n if (idleElement) {\n ReactDOM.render(\n ,\n idleElement\n );\n }\n}\n\nsetIdleTime(false)\n!window.user && window.localStorage.setItem('isIdleTimerTriggered', 'false');\n\n\nif(window.localStorage.isIdleTimerTriggered === 'true'){\n const idleElement = document.getElementById('idle-timer');\n ReactDOM.render(\n ,\n idleElement\n );\n}\n\nvar ewars = {\n checkIdelTime : setIdleTime,\n z: new Combi(),\n isSet: function (value) {\n if (value == undefined) return false;\n if (value == null) return false;\n if (value == \"\") return false;\n if (value == NaN) return false;\n if (Infinity) {\n if (value == Infinity) return false;\n if (value == -Infinity) return false;\n }\n return true;\n },\n isNull: function (value) {\n if (value == \"\") return true;\n if (value == undefined) return true;\n if (value == \"null\") return true;\n if (value == \"None\") return true;\n if (value == null) return true;\n if (!value) return true;\n return false;\n },\n notifications: notifications,\n utils: general,\n prompt: prompt,\n growl: function (content , timeout , fadeOut) {\n if ( timeout == 0 )\n {\n notifications.notify( \"fa-bullhorn\", \"\", content, null, \"fa-times\" , fadeOut);\n } else\n {\n notifications.notification( \"fa-bullhorn\", \"\", content, null, null );\n }\n },\n error: function (message) {\n notifications.error(message);\n },\n cache: Cache,\n Blocker: Blocker,\n formats: formatters,\n formatters: formatters,\n I18N: formatters.I18N_FORMATTER,\n DATE: formatters.DATE_FORMATTER,\n NUM: formatters.NUM,\n notify: function (title, message) {\n notifications.notification(\"fa-bullhorn\", title, message, null, null);\n },\n success: function (title, message) {\n notifications.notification(\"fa-check\", title, message, null, \"green\");\n },\n isEmpty: function (obj) {\n if (obj == null) return true;\n if (obj == \"\") return true;\n return false;\n },\n Confirmation: Confirmation,\n fetch: function (uri) {\n return new Promise((resolve, reject) => {\n if (window.fetch) {\n fetch(uri)\n .then((resp) => {\n resolve(resp);\n })\n .catch((err) => {\n reject(err);\n })\n }\n });\n },\n _l: _l,\n help: function (source) {\n if (source.indexOf(\"page:\") >= 0) {\n //. This is a help page\n } else {\n // This is a token and we need to retrieve it\n }\n },\n _saveRegister: [],\n registerSave: function (method) {\n ewars._saveRegister.push(method);\n },\n deregisterSave: function (method) {\n let removalIndex = null;\n ewars._saveRegister.forEach((item, index) => {\n if (item == method) {\n removalIndex = index;\n }\n })\n\n if (removalIndex != null)\n ewars._saveRegister.splice(removalIndex, 1);\n },\n getDOWMod7:function(){\n let date_of_week=1;\n if(window.user && window.user.dow && window.user.dow != \"None\"){\n date_of_week=window.user.dow % 7;\n }\n else if(window.dt && window.dt.dow && window.dt.dow != \"None\"){\n date_of_week=window.dt.dow % 7;\n }\n return date_of_week;\n },\n getDOY:function(){\n let doy=4;\n if(window.user && window.user.doy && window.user.doy != \"None\"){\n doy=window.user.doy;\n }\n else if(window.dt && window.dt.doy && window.dt.doy != \"None\"){\n doy=window.dt.doy;\n }\n return doy;\n }\n};\n\nwindow.ewars = ewars;\newars.d = {};\newars.g = {};\newars.g.online = true;\ndocument.addEventListener(\"keydown\", (e) => {\n if ((e.ctrlKey || e.metaKey) && e.key == \"s\") {\n e.preventDefault();\n ewars._saveRegister.forEach((method) => {\n method();\n })\n }\n})\n/**\n * Domain Setup\n */\nif ([\"127.0.0.1\", \"localhost\"].indexOf(document.domain) >= 0) {\n ewars.domain = document.domain + \":\"+window.server_port; \n} else {\n ewars.domain = document.domain\n}\n\n\n/**\n * Convenience check to see if a user is an administrative role\n * @param user\n * @returns {boolean}\n */\newars.isAdmin = function (user) {\n return false;\n};\n\newars.addEvent = function (object, type, callback) {\n if (object == null || typeof(object) == 'undefined') return;\n if (object.addEventListener) {\n object.addEventListener(type, callback, false);\n } else if (object.attachEvent) {\n object.attachEvent(\"on\" + type, callback);\n } else {\n object[\"on\" + type] = callback;\n }\n};\n\newars.removeEvent = function (object, type, callback) {\n if (object == null || typeof(object) == \"undefined\") return;\n if (object.removeEventListener) {\n object.removeEventListener(type, callback);\n } else if (object.removeEvent) {\n object.removeEvent(\"on\" + type, callback);\n } else {\n object['on' + type] = null;\n }\n};\n\n/**\n * Get the intersect between two arrays\n * @param a\n * @param b\n * @returns {Array}\n */\newars.intersect = function intersect_safe(a, b) {\n var ai = bi = 0;\n var result = [];\n\n while (ai < a.length && bi < b.length) {\n if (a[ai] < b[bi]) {\n ai++;\n }\n else if (a[ai] > b[bi]) {\n bi++;\n }\n else /* they're equal */\n {\n result.push(ai);\n ai++;\n bi++;\n }\n }\n\n return result;\n};\n\n/**\n * Quick and dirty copy mechanism\n */\newars.copy = function (data) {\n return JSON.parse(JSON.stringify(data));\n};\n\nvar _queue = [];\nvar _queueLimit = 1;\nvar _isQueueRunning = false;\nvar WorkerQueue = function (frequency) {\n this.queue = [];\n this.timeout = 0;\n this.current = null;\n this.frequency = frequency;\n this.load = 0;\n this.max = 6;\n\n this.pop = function () {\n if (this.load >= this.max) return;\n let current;\n if (!this.queue.length) {\n window.clearInterval(this.timeout);\n this.timeout = 0;\n return;\n }\n\n current = this.queue.shift();\n this.load++;\n\n if (current) {\n let deferred = current[0];\n let uri = current[1];\n let query = current[2];\n\n //TODO testing rust\n // uri = \"http://localhost:3000/ping\";\n\n let xhr = new XMLHttpRequest();\n\n let oReq = new XMLHttpRequest();\n oReq.open(\"POST\", uri, true);\n oReq.setRequestHeader(\"Content-Type\", \"application/json;charset=UTF-8\");\n if (window.dt) {\n if (window.dt.token) oReq.setRequestHeader(\"Authorization\", window.dt.token);\n }\n\n oReq.onreadystatechange = function () {\n let DONE = 4;\n let OK = 200;\n\n if (oReq.readyState == DONE) {\n if (oReq.status == OK) {\n let resp = JSON.parse(oReq.responseText);\n deferred[0](resp);\n this.load--;\n } else {\n if (oReq.status == 500) {\n }\n\n if (oReq.status == 101) {\n }\n deferred[1](false);\n this.load--;\n }\n }\n }.bind(this);\n\n oReq.send(JSON.stringify(query));\n }\n };\n\n this.clear = function () {\n this.queue = [];\n };\n\n this.push = function (uri, query) {\n var self = this;\n let dResolve, dReject;\n let deferred = new Promise((resolve, reject) => {\n dResolve = resolve;\n dReject = reject;\n });\n this.queue.push([[dResolve, dReject], uri, query]);\n if (!this.timeout) {\n this.timeout = window.setInterval(function () {\n if (self.load < self.max) {\n self.pop()\n }\n }, this.frequency);\n }\n this.pop();\n\n return deferred;\n }\n};\n\newars._queue = new WorkerQueue(6);\n\n/**\n * Fallback method if websockets fail\n */\newars.tx = function (method, args, kwargs) {\n return new Promise((resolve, reject) => {\n let oReq = new XMLHttpRequest();\n oReq.open(\"POST\", \"/api/_w\", true);\n oReq.setRequestHeader(\"Content-Type\", \"application/json;charset=UTF-8\");\n\n oReq.onreadystatechange = function () {\n let DONE = 4;\n let OK = 200;\n let promptObject;\n if (oReq.readyState == DONE) {\n if (oReq.status == OK) {\n if (oReq.responseText == \"NO_AUTH\") {\n document.location = \"/login\";\n }\n let resp = JSON.parse(oReq.responseText);\n // for hub: if internet connection is not there then show this prompt\n if (resp.data && resp.data.status == 12029 && !promptObject) {\n promptObject = ewars.prompt(\"fa-info-circle\", __(\"ONLINE_FEATURE\"), __(\"CANNOT_CONNECT_WITHOUT_AN_INTERNET\"),\n () => {\n window.history.back();\n }, null, __(\"OK\"), null, true);\n }\n if(resp.status == 500){\n resolve(resp);\n }else{\n resolve(resp.data);\n }\n } else { \n if (oReq.status == 500) {\n }\n\n if (oReq.status == 101) {\n oReq.responseText=\"EWARS is currently down for routine maintenance, the application will be available again shortly.!\"\n }\n if (oReq.status == 403) {\n document.location = \"/login\";\n }\n ewars.growl(oReq.responseText)\n reject(oReq);\n }\n }\n }.bind(this);\n\n oReq.send(JSON.stringify([method, args, kwargs]));\n })\n};\n\n/**\n * Method for unsecured APIs\n */\newars.txOpen = function (rqType ,url, payload , isJson = true ,setRequestTimeout = false) {\n return new Promise((resolve, reject) => {\n let resp;\n let oReq = new XMLHttpRequest();\n oReq.open(rqType, url, true);\n oReq.setRequestHeader(\"Content-Type\", \"application/json;charset=UTF-8\");\n if (setRequestTimeout){\n oReq.timeout = 15000;\n }\n oReq.ontimeout = function () {\n ewars.growl(__(\"REQUEST_TIMEOUT\"))\n }\n oReq.onreadystatechange = function () {\n let DONE = 4;\n let OK = 200;\n let promptObject;\n if (oReq.readyState == DONE) {\n if (oReq.status == OK) {\n if (oReq.responseText == \"NO_AUTH\") {\n document.location = \"/login\";\n }\n if(!isJson){ \n resp = oReq.responseText;\n }else\n resp = JSON.parse(oReq.responseText);\n // for hub: if internet connection is not there then show this prompt\n if (resp && resp.hasOwnProperty('status') && resp.status == 12029 && !promptObject) {\n promptObject=ewars.prompt(\"fa-info-circle\", __(\"ONLINE_FEATURE\"), __(\"CANNOT_CONNECT_WITHOUT_AN_INTERNET\"),\n () => {\n document.location = \"/\"\n }, () => {\n document.location = \"/\"\n }, \"OK\",\"\",true)\n }\n resolve(resp);\n } else {\n if (oReq.status == 500) {\n }\n\n if (oReq.status == 101) {\n }\n reject(oReq);\n }\n }\n }.bind(this);\n if (payload){\n oReq.send(JSON.stringify(payload));\n }else{\n oReq.send()\n }\n })\n};\n\n\newars.once = function (func) {\n var ran = false, memo;\n return function () {\n if (ran) return memo;\n ran = true;\n memo = func.apply(this.arguments);\n func = null;\n return memo;\n }\n};\n\newars.setKeyPath = function (obj, prop, value) {\n if (typeof prop === \"string\")\n prop = prop.split(\".\");\n\n if (prop.length > 1) {\n var e = prop.shift();\n ewars.setKeyPath(obj[e] = Object.prototype.toString.call(obj[e]) === \"[object Object]\" ? obj[e] : {},\n prop,\n value);\n } else {\n obj[prop[0]] = value;\n }\n};\n\newars.getKeyPath = function (path, obj) {\n try {\n return path.split('.').reduce((o, i) => o[i], obj)\n } catch (e) {\n return null;\n }\n};\n\newars.requestNewCookie = function () {\n $.ajax({\n url: \"/cookie\",\n contentType: \"application/json\",\n dataType: \"json\",\n success: function (resp) {\n if (resp.d != true) {\n ewars.notifications.notification(\"fa-exclamation-triangle\", __(\"ERROR\"), __(\"REQUESTING_NEW_COOKIE_ERROR\"), 3000, \"red\");\n }\n }\n })\n};\n\nvar _events = {};\newars.subscribe = function (event_name, callback, id) {\n var args = [[callback]];\n if (id) args[0].unshift(id);\n if (_events[event_name]) {\n _events[event_name].push.apply(_events[event_name], args);\n } else {\n _events[event_name] = [];\n _events[event_name].push.apply(_events[event_name], args);\n }\n};\n\newars.unsubscribe = function (event_name, id) {\n var eventArray = _events[event_name];\n\n var events = [];\n eventArray.forEach((item, index) => {\n if (item.length > 1) {\n if (item[0] != id) {\n events.push(item);\n }\n } else {\n events.push(item);\n }\n });\n\n _events[event_name] = events;\n};\n\newars.emit = function (event_name, data) {\n for (var i in _events[event_name]) {\n var callback = _events[event_name][i];\n if (callback.length > 1) {\n callback[1](data);\n } else {\n callback[0](data);\n }\n }\n};\n\nfunction _setConnectionClosed() {\n\n if (!document.getElementById(\"offline\") && window.server_type == \"GLOBAL\") {\n var el = document.createElement(\"div\");\n el.setAttribute(\"id\", \"offline\");\n el.setAttribute(\"class\", \"offline\");\n el.innerText = __(\"CURRENTLY_OFFLINE_PLEASE_CHECK_CONNECTION\");\n document.body.appendChild(el)\n }\n}\n\nfunction _reconnected() {\n let node = document.getElementById(\"offline\");\n if(node){\n node.parentNode.removeChild(node);\n }\n ewars.notifications.notification(\"fa-plug\", __(\"RECONNECTED\"), __(\"YOUR_CONNECTION_HAS_RE_ESTABLISHED\"))\n}\n\nfunction changePercentageOfProgressBar (progress,is_last){\n \n if((progress <= percentageAfterCompletetionOfCurrentSyncEntity || is_last) && (syncPercentage <= progress)){ \n width = progress + \"%\";\n syncPercentage = progress;\n }\n}\nvar blocker;\nvar width;\nvar intervalForSync = null\nvar totalRecordsCount = 0\nvar syncPercentage = 0\nvar currentSycingEntity = \"\"\nvar percentageAfterCompletetionOfCurrentSyncEntity;\nvar isSyncAllClicked = false\nvar accountLength = 0;\nvar accountCounter = 1;\nfunction syncSocketConnection() {\n var ws = new WebSocket('ws://'+window.location.host+'/api/_sync_info');\n ws.onopen = function() {\n // subscribe to some channels\n // let r = new XMLHttpRequest();\n // r.open(\"POST\", \"/api/_start_udp_for_sync\", true);\n // r.send();\n };\n\n ws.onmessage = evt => {\n // listen to data sent from the websocket server\n const message = JSON.parse(evt.data)\n const responseKey = Object.keys(message);\n if ( responseKey[0] == 'current_sync_entity'){\n if(message['status']=='STARTED'){\n if (message['progress'] == 0){\n if(blocker){\n blocker.destroy()\n }\n blocker = new ewars.Blocker(null, __(\"SYNCING_ACCOUNT\"),true);\n }\n }\n }\n if (responseKey[0] == \"403\" || message[responseKey[0]] == \"403\") {\n blocker.destroy();\n ewars.growl(__(\"USER_APPROVAL_PENDING\"));\n }\n if (responseKey[0] == \"500\" || message[responseKey[0]] == \"500\") {\n blocker.destroy();\n ewars.growl(__(\"INTERNAL_SERVER_ERROR\"));\n }\n \n \n if (responseKey[0] == \"pull_complete\") {\n \n if (blocker){\n blocker.destroy();\n }\n ewars.growl(__(\"SYNCED_SUCCESSFULLY\"));\n }\n if (responseKey[0] == \"invalid_data\") {\n blocker.destroy();\n ewars.growl(__(\"INTERNAL_SERVER_ERROR\"));\n }\n }\n\n ws.onclose = () => {\n console.log('disconnected')\n syncSocketConnection()\n }\n\n ws.onerror = function (err) {\n console.error('Socket encountered error: ', err.message, 'Closing socket');\n syncSocketConnection()\n // ws.close();\n };\n}\n\nfunction _connect() {\n window.isElectron = (utils.isElectron());\n var ws = null;\n if (window.isElectron && ws == null) {\n let cred = {};\n if(window.name) cred = JSON.parse(window.name)\n else if (window.user && window.user.email) cred['username'] = window.user.email\n else cred['username'] = \"Ewars Local Hub\"\n\n ewars.txOpen('POST',\"/api/_hubsync\", {\"user_email\":cred['username']})\n .then(res => { \n if (res.err) {\n ewars.growl(__(\"AUTHENTICATION_FAILED\"));\n }\n }\n ).catch(err => { \n ewars.growl(err.responseText);\n })\n \n \n\n ws = new WebSocket(`ws://${window.location.host}/api/_sync_mobile_local`);\n window.webSocket = ws\n ws.onopen = function () {\n };\n\n ws.onmessage = evt => {\n const message = JSON.parse(evt.data)\n\n if (message.hasOwnProperty(\"isUDPConnectionEstablish\")) {\n ewars.prompt(\"fa-info-circle\", __(\"CONFIRMATION\"), __(\"WANT_TO_RECIEVE_DATA_FROM_USER\") + message[\"userName\"] + \"?\",\n () => {\n ws.send(`{\"CAN_SYNC_WITH_UDP\" : \"yes\"}`)\n }, () => {\n ws.send(`{\"CAN_SYNC_WITH_UDP\" : \"no\"}`)\n }, \"Yes\", \"No\")\n }\n\n if (message.hasOwnProperty(\"UDP_CONFIRMATION_FOR_HUB\")) {\n let account_info = message['account_info']\n ewars.prompt(\"fa-info-circle\", __(\"CONFIRMATION\"), account_info + __(\"WILL_BE_SYNCED_BY\") + message[\"userName\"] + __(\"DO_YOU_WANT_TO_CONTINUE\"),\n () => {\n ws.send(`{\"CAN_SYNC_WITH_UDP\" : \"yes\"}`)\n // blocker = new ewars.Blocker(null, \"Syncing account...\",true);\n syncSocketConnection();\n }, () => {\n ws.send(`{\"CAN_SYNC_WITH_UDP\" : \"no\"}`)\n }, \"Yes\", \"No\")\n }\n \n\n }\n\n ws.onclose = () => {\n }\n\n ws.onerror = function (err) {\n console.error('Socket encountered error: ', err.message, 'Closing socket');\n ws.close();\n };\n }\n \n}\n\nvar forceOffline = false;\nif (!window._isPDF) {\n if (!forceOffline) {\n _connect();\n window.setInterval(function () {\n if (navigator.onLine == false) {\n _setConnectionClosed();\n ewars.g.online = false;\n window.network_connection.isNetwork = false\n } else {\n if (!ewars.g.online) {\n ewars.g.online = true;\n _reconnected();\n }\n if (window.server_type == \"LOCAL\") {\n let response = fetch('//google.com', {\n mode: 'no-cors',\n }).then(() => {\n window.network_connection.isNetwork = true;\n }).catch(() => {\n window.network_connection.isNetwork = false\n })\n }\n }\n }, 3000);\n }\n}\n\nwindow._isNull = (value) => {\n if (value == null) return true;\n if (value == undefined) return true;\n return false;\n}\n\nwindow._isNullOrEmpty = (value) => {\n if (value == null) return true;\n if (value == \"\") return true;\n if (value == undefined) return true;\n if (value instanceof Array) {\n if (value.length <= 0) return true;\n }\n\n return false;\n};\n\nlet accLink = document.getElementById('acc-swapper'),\n accMenu = document.getElementById('acc-drop');\n\nconst checkAccMenuConstraint = (e) => {\n if (accMenu != e.target && !accMenu.contains(e.target)) {\n if (accMenu.style.display == 'block') {\n accMenu.style.display = 'none';\n }\n }\n};\n\nif (accLink) {\n accLink.addEventListener('click', (e) => {\n e.stopPropagation();\n if(accMenu){\n accMenu.style.display = accMenu.style.display != 'none' ? 'none' : 'block';\n if (accMenu.style.display != 'none') {\n document.body.addEventListener('click', checkAccMenuConstraint);\n } else {\n document.body.removeEventListener('click', checkAccMenuConstraint);\n }\n }\n });\n}\n\nconst restArguments = (func, startIndex) => {\n startIndex = startIndex == null ? func.length - 1 : +startIndex;\n return function() {\n let length = Math.max(arguments.length - startIndex, 0),\n rest = Array(length),\n index = 0;\n for (; index < length; index++) {\n rest[index] = arguments[index + startIndex];\n }\n switch (startIndex) {\n case 0: return func.call(this, rest);\n case 1: return func.call(this, arguments[0], rest);\n case 3: return func.call(this, arguments[0], arguments[1], rest);\n }\n\n let args = Array(startIndex + 1);\n for (index = 0; index < startIndex; index++) {\n args[index] = arguments[index];\n }\n\n args[startIndex] = rest;\n return func.apply(this, args);\n };\n};\n\nconst _delay = restArguments(function(func, wait, args) {\n return setTimeout(function() {\n return func.apply(null, args);\n }, wait);\n});\n\newars.debounce = function(func, wait, args) {\n let timeout, result;\n\n let later = function(context, args) {\n timeout = null;\n if (args) result = func.apply(context, args);\n }\n\n let debounced = restArguments(function(args) {\n if (timeout) clearTimeout(timeout);\n \n tiemout = _delay(later, wait, this, args);\n return result;\n });\n\n debounced.cancel = function() {\n clearTimeout(timeout);\n timeout = null;\n };\n\n return debounced;\n}\n\n\nexport default ewars;\n","function Blocker(target, message, isCloseable = null,closeCallback=null) {\n this._message = message;\n this._el = null;\n this._id = ewars.utils.uuid();\n let close = null;\n\n let elTarget = target || document.body;\n let outer = document.createElement(\"div\");\n outer.setAttribute(\"class\", \"gui-blocker\");\n outer.setAttribute(\"id\", this._id);\n\n let inner = document.createElement(\"div\");\n inner.setAttribute(\"class\", \"gui-blocker-msg\");\n\n let iconWrapper = document.createElement(\"div\");\n iconWrapper.setAttribute(\"class\", \"gui-blocker-icon\");\n\n let icon = document.createElement(\"i\");\n icon.setAttribute(\"class\", \"fal fa-circle-o-notch fa-spin\");\n\n iconWrapper.appendChild(icon);\n inner.appendChild(iconWrapper);\n\n let msg = document.createElement(\"div\");\n msg.setAttribute(\"class\", \"gui-message\");\n msg.setAttribute(\"id\", \"inner-message\");\n msg.appendChild(document.createTextNode(message));\n\n inner.appendChild(msg);\n\n outer.appendChild(inner);\n\n elTarget.appendChild(outer);\n\n this._el = document.getElementById(this._id);\n\n if(isCloseable){\n let closeWrapper = document.createElement(\"div\");\n closeWrapper.setAttribute(\"class\", \"gui-blocker-close\");\n\n close = document.createElement(\"i\");\n close.setAttribute(\"class\", \"fal fa-times\");\n\n closeWrapper.appendChild(close);\n outer.appendChild(closeWrapper);\n\n var local_el = this._el;\n var local_id = this._id;\n\n close.onclick = function (){\n if (local_el.parentNode) {\n local_el.parentNode.removeChild(local_el);\n } else {\n let el = document.getElementById(local_id);\n if (el)\n el.parentNode.removeChild(el);\n }\n if (closeCallback) closeCallback();\n }\n }\n}\nBlocker.prototype.destroy = function () {\n if (this._el.parentNode) {\n this._el.parentNode.removeChild(this._el);\n } else {\n let el = document.getElementById(this._id);\n if (el)\n el.parentNode.removeChild(el);\n }\n delete this;\n};\n\nBlocker.prototype.hide = function () {\n this._el.style.display = \"none\";\n};\n\nBlocker.prototype.show = function () {\n this._el.style.display = \"block\";\n};\n\nBlocker.prototype.setMessage = function (message) {\n document.getElementById(\"inner-message\").innerText = message;\n};\n\nexport default Blocker;\n","export default class Confirmation {\n static buttons = [\n [\"CONFIRM\", \"Confirm\"],\n [\"CANCEL\", \"Cancel\"]\n ];\n\n constructor(config) {\n this._config = config;\n this._build();\n }\n\n _build = () => {\n this._id = \"PROMPT_\" + ewars.utils.uuid();\n\n this._base = document.createElement(\"div\");\n this._base.setAttribute(\"class\", \"prompt-wrapper\");\n this._base.setAttribute(\"id\", this._id);\n\n var _main = document.createElement(\"div\");\n _main.setAttribute(\"class\", \"prompt-container\");\n\n var _header = document.createElement(\"div\");\n _header.setAttribute(\"class\", \"prompt-header\");\n\n // Set up icon\n var _icon = document.createElement(\"div\");\n _icon.setAttribute(\"class\", \"prompt-icon\");\n var _iconItem = document.createElement(\"i\");\n _iconItem.setAttribute(\"class\", \"fa \" + this._config.icon);\n _icon.appendChild(_iconItem);\n\n // Set up prompt title\n var _title = document.createElement(\"div\");\n _title.setAttribute(\"class\", \"prompt-title\");\n\n var _titleText = document.createTextNode(this._config.title);\n _title.appendChild(_titleText);\n _header.appendChild(_icon);\n _header.appendChild(_title);\n\n _main.appendChild(_header);\n // Header setup complete\n\n var _body = document.createElement(\"div\");\n _body.setAttribute(\"class\", \"prompt-body\");\n var _content = document.createTextNode(this._config.body);\n _body.appendChild(_content);\n\n _main.appendChild(_body);\n // Main body set up\n\n // Buttons\n var buttonsWrapper = document.createElement(\"div\");\n buttonsWrapper.setAttribute(\"class\", \"footer\");\n\n var btnGroup = document.createElement(\"div\");\n btnGroup.setAttribute(\"class\", \"btn-group pull-right\");\n buttonsWrapper.appendChild(btnGroup);\n\n let buttons = this.buttons;\n if (this._config.buttons) {\n buttons = this._config.buttons;\n }\n\n buttons.forEach((button) => {\n let btn = document.createElement(\"button\");\n btn.setAttribute(\"class\", \"btn-flat\");\n btn.appendChild(document.createTextNode(button[1]));\n btn.addEventListener(\"click\", () => {\n this.onAction(button[0]);\n });\n btnGroup.appendChild(btn);\n });\n\n // BUG: Need to fix layout with pull-right\n var clearer = document.createElement(\"div\");\n clearer.setAttribute(\"class\", \"clearer\");\n buttonsWrapper.appendChild(clearer);\n\n _main.appendChild(buttonsWrapper);\n this._base.appendChild(_main);\n\n document.getElementsByTagName('body')[0].appendChild(this._base);\n\n };\n\n show = () => {\n\n };\n\n listen = (listener) => {\n this._listener = listener;\n };\n\n destroy = () => {\n this._base.parentNode.removeChild(this._base);\n };\n\n onAction = (action) => {\n this._listener(action);\n }\n}","import React, { Component } from 'react'\nimport IdleTimer from 'react-idle-timer'\nimport LockModal from './locker'\n\nexport default class IdleTimeout extends Component {\n constructor(props) {\n super(props)\n this.idleTimer = {}\n this.onIdle = this._onIdle.bind(this)\n this.onAction = this._onAction.bind(this)\n this.state = {\n lockmodal : false,\n lockTime : null\n }\n }\n\n ltime;\n componentWillMount = async () =>{\n this.ltime = await this.get_screen_lock_time()\n if(this.refs.ref) this.setState({lockTime : this.ltime})\n }\n\n componentWillReceiveProps = async (nextProps) => {\n let newTime = await this.get_screen_lock_time();\n if(nextProps.isUnlocked){\n this.setState({\n lockmodal : false,\n lockTime : newTime != this.state.lockTime ? newTime : this.state.lockTime\n })\n }\n }\n\n async get_screen_lock_time () {\n let respTime = window.user ? window.user.screen_lock_time : null;\n return respTime\n }\n\n timeoutInMS;\n render() {\n this.timeoutInMS = this.state.lockTime!=null ? (this.state.lockTime === 0) ? this.state.lockTime : (this.state.lockTime * 60 * 1000) : (15*60*1000); \n let view = null;\n if(this.timeoutInMS != 0){\n if(!this.state.lockmodal){\n view= { this.idleTimer = ref }}\n element={document}\n onIdle={this.onIdle}\n debounce={2000}\n onActive={this.onActive}\n onAction={this.onAction}\n timeout={this.timeoutInMS} />\n }else{\n view = \n }\n }\n return (\n
    \n {view}\n
    \n )\n }\n\n _onAction() {\n window.localStorage.isIdleTimerTriggered = 'false';\n window.localStorage.lastActiveTime = this.idleTimer.getLastActiveTime();\n }\n\n _onIdle() { \n const inactiveTime = (new Date().getTime() - window.localStorage.lastActiveTime);\n if(inactiveTime >= this.timeoutInMS){\n window.localStorage.isIdleTimerTriggered = 'true';\n this.setState({\n lockmodal : true\n })\n }\n }\n}","import ewars from '../../ewars/app';\n\nconst style = {\n 'outsideHeader': {\n padding: \"10px 10px 10px 20px\",\n borderBottom: \"1px solid lightgrey\",\n height: 40,\n fontSize: 18,\n background: \"#EDF1F4\",\n\n },\n 'insideLeft': {\n float: \"left\"\n },\n 'error': {\n position: \"absolute\",\n top: 69,\n right: 400\n },\n 'container': {\n // height: \"100vh\",\n },\n 'labelStyle': {\n fontSize: 18,\n fontWeight: \"bold\"\n },\n 'buttonMargin': {\n margin: '0px 10px'\n },\n 'pTagLeft': {\n fontSize: 14,\n color:\"#CCC\"\n },\n 'input': {\n padding: \"0px 20px\",\n marginTop: 10,\n width: \"30%\",\n display: \"inline\"\n },\n 'inputStyle': {\n width: \"100%\",\n padding: '7px',\n color: '#CCC'\n },\n 'upperHalfStyle': {\n display: 'flex',\n marginTop: 10,\n },\n 'authButton': {\n textAlign: \"center\",\n cursor: \"pointer\",\n display: 'grid'\n },\n 'authButtonStyle': {\n marginTop: 20\n },\n 'loginAgainSpan': {\n textAlign: 'right',\n marginTop: '3px',\n },\n 'emailTxt': {\n width: \"100%\",\n padding: '10px 10px 10px 10px',\n fontSize: '15px',\n color:\"#CCC\"\n }\n \n};\n\n\nclass LockModal extends React.Component {\n\n constructor(props) {\n super(props);\n this.state = {\n email: window.user.email,\n password: '',\n error: '',\n credentials: {},\n showLockmodal : true\n };\n }\n\n\n checkAuthentication = () => { \n var blocker = new ewars.Blocker(null, __(\"AUTHENTICATING\"));\n let argument = {\n \"user_email\": this.state.email,\n \"user_password\": this.state.password,\n }\n argument.authenticate_local = true\n ewars.txOpen('POST', '/api/_authenticate', argument)\n .then(async resp => {\n blocker.destroy();\n if (resp.err) {\n ewars.growl(__(\"AUTHENTICATION_FAILED\"));\n }\n else {\n let cred = {\n \"username\": (this.state.email).trim(),\n \"password\": this.state.password\n }\n window.name = JSON.stringify(cred);\n window.localStorage.isIdleTimerTriggered = 'false';\n this.setState({\n showLockmodal : false\n })\n ewars.checkIdelTime(true) ;\n }\n }\n ).catch(err => {\n ewars.growl(__(\"AUTHENTICATION_FAILED\"));\n })\n };\n\n _onIndicatorChange = (event) => {\n var curState = this.state;\n curState[event.target.name] = event.target.value;\n this.setState(curState);\n }\n\n _handleEnter = (event) => {\n if (event.keyCode == 13) {\n event.stopPropagation();\n this.checkAuthentication();\n }\n }\n\n _clearError = () => {\n this.setState({\n error: null\n })\n }\n\n render() {\n if(this.props.showLocker && this.state.showLockmodal){ \n return (\n
    \n\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    {__(\"EWARS_LOCKED\")}
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n \n
    \n
    \n
    this.checkAuthentication()} className=\"btnstyle\">\n  {__(\"AUTHENTICATE\")}\n
    \n \n \n {__(\"LOGIN_AGAIN\")}\n \n \n
    \n {this.state.error ?\n
    \n  \n {this.state.error}\n
    \n : null}\n
    \n
    \n
    \n
    \n
    \n\n
    \n
    \n\n )\n }\n else{\n return (\n
    \n )\n }\n }\n}\n\nexport default LockModal\n","import utils from \"../utils/general\";\n\nvar _notifications = [];\nvar notififyId = null;\n\n\n\nfunction _fadeOut(el) {\n el.style.opacity = 1;\n\n (function fade() {\n if ((el.style.opacity -= .1) < 0) {\n el.parentNode.removeChild(el);\n } else {\n requestAnimationFrame(fade);\n }\n })();\n}\n\nconst Notification = {\n _buildBase: function ( id, iconString, titleString, contentString, colour, closeBtnString ) {\n if (!colour) colour = 'blue';\n\n\n var wrapper = document.createElement(\"div\");\n wrapper.setAttribute(\"class\", \"ew-not-modal modal \" + colour);\n wrapper.setAttribute(\"id\", id);\n\n\n // Set up header\n var header = document.createElement(\"div\");\n header.setAttribute(\"class\", \"header\");\n\n if ( closeBtnString )\n {\n var closeBtnWrapper = document.createElement( \"div\" );\n closeBtnWrapper.setAttribute( \"class\", \"closebtn pull-right\" );\n var closeIcon = document.createElement( \"I\" );\n closeIcon.setAttribute( \"class\", \"fal \" + closeBtnString );\n closeIcon.setAttribute( \"style\", \"font-size : inherit ; margin : 10px\" );\n closeIcon.addEventListener( \"click\", function ()\n {\n notififyId = null;\n var item = document.getElementById( id );\n _fadeOut( item );\n } );\n closeBtnWrapper.appendChild( closeIcon );\n\n }\n \n var iconWrapper = document.createElement(\"div\");\n iconWrapper.setAttribute(\"class\", \"icon\");\n var icon = document.createElement(\"I\");\n icon.setAttribute(\"class\", \"fal \" + iconString);\n iconWrapper.appendChild(icon);\n\n var title = document.createElement(\"div\");\n title.setAttribute(\"class\", \"title\");\n\n var titleText = document.createTextNode(titleString);\n title.appendChild(titleText);\n if ( closeBtnString )\n {\n header.appendChild( closeBtnWrapper );\n }\n header.appendChild(iconWrapper);\n header.appendChild(title);\n\n wrapper.appendChild(header);\n\n // Set up Body\n var body = document.createElement(\"div\");\n body.setAttribute(\"class\", \"body\");\n var content = document.createTextNode(contentString);\n body.appendChild(content);\n\n wrapper.appendChild(body);\n\n return wrapper;\n },\n /**\n * Provides a way to show notifications to the user form anywhere in the application\n * @param icon\n * @param title\n * @param content\n */\n notification: function (iconString, titleString, contentString, timeout, colour) {\n if (!timeout) timeout = 5000;\n\n var id = utils.uniqueId(\"notification\");\n\n var wrapper = this._buildBase(id, iconString, titleString, contentString, colour);\n\n var notStream = document.getElementById(\"notification-stream\");\n\n notStream.appendChild(wrapper);\n\n setTimeout(function () {\n var item = document.getElementById(id);\n _fadeOut(item);\n }, timeout);\n },\n notify: function ( iconString, titleString, contentString, colour, closeBtnString , fadeOut )\n {\n if ( notififyId == null )\n {\n var id = utils.uniqueId( \"notification\" );\n notififyId = id;\n var wrapper = this._buildBase( id, iconString, titleString, contentString, colour, closeBtnString );\n var notifyStream = document.getElementById( \"notification-stream\" );\n notifyStream.appendChild( wrapper );\n } else\n {\n var item = document.getElementById( notififyId );\n item.childNodes[1].textContent = contentString;\n }\n if(fadeOut){\n var item = document.getElementById(notififyId);\n _fadeOut(item);\n notififyId = null;\n\n }\n\n },\n error: function (message) {\n let id = utils.uniqueId(\"error\");\n let wrapper = document.createElement(\"div\");\n wrapper.setAttribute(\"id\", id);\n wrapper.setAttribute(\"class\", \"error-wrapper\");\n\n let inner = document.createElement(\"div\");\n inner.setAttribute(\"class\", \"error-inner\");\n\n let icon = document.createElement(\"i\");\n icon.setAttribute(\"class\", 'fal fa-exclamation-triangle');\n let text = document.createTextNode(\" \" + message);\n\n inner.appendChild(icon);\n inner.appendChild(text);\n wrapper.appendChild(inner);\n\n let notStream = document.getElementById(\"notification-stream\");\n notStream.appendChild(wrapper);\n\n setTimeout(() => {\n let item = document.getElementById(id);\n _fadeOut(item);\n }, 5000)\n },\n /**\n * Create a prompt which requires user feedback before an action is undertaken\n * @param icon\n * @param title\n * @param content\n * @param ok\n * @param cancel\n */\n prompt: function (iconString, titleString, contentString, okCallback, cancelCallback, okText, cancelText) {\n if (!okText) okText = \"OK\";\n if (!cancelText) cancelText = \"Cancel\";\n\n var id = utils.uniqueId(\"notification\");\n\n var wrapper = this._buildBase(id, iconString, titleString, contentString);\n\n // Buttons\n var buttonsWrapper = document.createElement(\"div\");\n buttonsWrapper.setAttribute(\"class\", \"footer\");\n\n var okBtn = document.createElement('button');\n okBtn.setAttribute(\"class\", \"btn-flat\");\n okBtn.appendChild(document.createTextNode(okText));\n okBtn.addEventListener(\"click\", function () {\n var item = document.getElementById(id);\n _fadeOut(item);\n okCallback();\n });\n\n var cancelBtn = document.createElement(\"button\");\n cancelBtn.setAttribute(\"class\", \"btn-flat\");\n cancelBtn.appendChild(document.createTextNode(cancelText));\n cancelBtn.addEventListener(\"click\", function () {\n var item = document.getElementById(id);\n _fadeOut(item);\n if (cancelCallback) cancelCallback();\n });\n\n var btnGroup = document.createElement(\"div\");\n btnGroup.setAttribute(\"class\", \"btn-group pull-right\");\n btnGroup.appendChild(okBtn);\n btnGroup.appendChild(cancelBtn);\n buttonsWrapper.appendChild(btnGroup);\n\n // BUG: Need to fix layout with pull-right\n var clearer = document.createElement(\"div\");\n clearer.setAttribute(\"class\", \"clearer\");\n buttonsWrapper.appendChild(clearer);\n\n wrapper.appendChild(buttonsWrapper);\n // END Buttons\n\n var notStream = document.getElementById(\"notification-stream\");\n\n notStream.appendChild(wrapper);\n },\n /**\n * Show a progress indicator and fire a callback when finished\n * @param icon\n * @param title\n * @param processHandler\n * @param finishedCallback\n */\n progress: function (icon, title, processHandler, finishedCallback) {\n\n },\n\n killPrompts: function () {\n\n }\n};\n\nexport default Notification;\n","\nfunction _fadeOut(el) {\n el.style.opacity = 1;\n\n (function fade() {\n if ((el.style.opacity -= .1) < 0) {\n el.parentNode.removeChild(el);\n } else {\n requestAnimationFrame(fade);\n }\n })();\n}\n\nconst Prompt = function (icon, title, content, callback, cancelCallback, OK_TEXT = __(\"CONFIRM\"), CANCEL_TEXT = __(\"CANCEL\"), showOnlyOk = false,showCrossIcon = false) {\n var _id = ewars.utils.uuid();\n\n var _base = document.createElement(\"div\");\n _base.setAttribute(\"class\", \"prompt-wrapper\");\n _base.setAttribute(\"id\", _id);\n\n var _main = document.createElement(\"div\");\n _main.setAttribute(\"class\", \"prompt-container\");\n\n var _header = document.createElement(\"div\");\n _header.setAttribute(\"class\", \"prompt-header\");\n\n // Set up icon\n var _icon = document.createElement(\"div\");\n _icon.setAttribute(\"class\", \"prompt-icon\");\n var _iconItem = document.createElement(\"i\");\n _iconItem.setAttribute(\"class\", \"fal \" + icon);\n _icon.appendChild(_iconItem);\n\n // Set up prompt title\n var _title = document.createElement(\"div\");\n _title.setAttribute(\"class\", \"prompt-title\");\n\n var _titleText = document.createTextNode(title);\n _title.appendChild(_titleText);\n _header.appendChild(_icon);\n if (showCrossIcon) {\n var _crossiconItem = document.createElement(\"i\");\n _crossiconItem.setAttribute(\"class\", \"fal fa-times\");\n _crossiconItem.style.float = 'right';\n _crossiconItem.style.cursor = 'pointer';\n _crossiconItem.addEventListener(\"click\", function () {\n var item = document.getElementById(_id);\n _fadeOut(item);\n });\n _title.appendChild(_crossiconItem);\n }\n _header.appendChild(_title);\n\n _main.appendChild(_header);\n // Header setup complete\n\n var _body = document.createElement(\"div\");\n _body.setAttribute(\"class\", \"prompt-body\");\n var _content = document.createTextNode(content);\n _body.appendChild(_content);\n\n _main.appendChild(_body);\n // Main body set up\n\n // Buttons\n var buttonsWrapper = document.createElement(\"div\");\n buttonsWrapper.setAttribute(\"class\", \"footer\");\n\n var okBtn = document.createElement('button');\n okBtn.setAttribute(\"class\", \"btn-flat\");\n okBtn.appendChild(document.createTextNode(OK_TEXT));\n okBtn.addEventListener(\"click\", function () {\n var item = document.getElementById(_id);\n _fadeOut(item);\n callback();\n });\n if (!showOnlyOk) {\n var cancelBtn = document.createElement(\"button\");\n cancelBtn.setAttribute(\"class\", \"btn-flat\");\n cancelBtn.appendChild(document.createTextNode(CANCEL_TEXT));\n cancelBtn.addEventListener(\"click\", function () {\n var item = document.getElementById(_id);\n _fadeOut(item);\n if (cancelCallback) cancelCallback();\n });\n }\n\n var btnGroup = document.createElement(\"div\");\n \n btnGroup.appendChild(okBtn);\n if (showOnlyOk) {\n btnGroup.setAttribute(\"class\", \"btn-group alert-btn\");\n } else {\n btnGroup.appendChild(cancelBtn);\n btnGroup.setAttribute(\"class\", \"btn-group pull-right\");\n }\n buttonsWrapper.appendChild(btnGroup);\n\n // BUG: Need to fix layout with pull-right\n var clearer = document.createElement(\"div\");\n clearer.setAttribute(\"class\", \"clearer\");\n buttonsWrapper.appendChild(clearer);\n\n _main.appendChild(buttonsWrapper);\n _base.appendChild(_main);\n\n document.getElementsByTagName('body')[0].appendChild(_base);\n\n return {\n el: _base,\n id: _id,\n close: function () {},\n show: function () {}\n }\n\n};\n\nexport default Prompt;\n","const EN = {\n ALARMS_DISCRIPTION:\"View and configure alarms within the system\",\n CONFIG_TRANSFER_DESCRIPTION:\"Transfer configured items from one account to another account.\",\n CONFIGURATION_TRANSFER:\"Configuration Transfer\",\n DASHBOARDS_DESCRIPTION:\"Manage system dashboards.\",\n IMPORT_DESCRIPTION:\"Import and map data from outside the system\",\n DATA_IMPORT:\"Data Import\",\n DOCUMENT_TEMPLATES_DESCRIPTION:\"Access reports and information\",\n TEAM_MANAGEMENT_DESCRIPTION:\"Create and manage teams\",\n DOCUMENT_TEMPLATES:\"Document Templates\",\n TEAM_MANAGEMENT:\"Teams Management\",\n EWARS_LOGS_DESCRIPTION:\"Ewars Error Log Files & Upload.\",\n EWARS_LOGS:\"EWARS Logs\",\n WEB_CONTENT:\"Web Content\",\n WEB_CONTENT_DESCRIPTION:\"Manage Web Content Upload\",\n WEBSITE_BUILDER: \"Website Builder\",\n SITE_BUILDER_DESCRIPTION: \"Create & Publish Website\",\n FORMS_DESCRIPTION:\"Create and manage custom forms and data collection systems\",\n INDICATORS_DESCRIPTION:\"Create and manage indicators available within the system\",\n LOCATIONS_DESCRIPTION:\"Manage administrative and site locations\",\n OUTBREAKS_DESCRIPTION:\"Declare and manage outbreaks\",\n SUBMISSIONS:\"Submissions\",\n SUBMISSIONS_DESCRIPTION:\"Manage reports within the system\",\n THIRD_PARTY_CLIENTS:\"Third Party Clients\",\n INTEGRATION: \"Integration\",\n THIRD_PARTY_CLIENTS_DESCRIPTION:\"Manage third party clients of system\",\n USERS_DESCRIPTION:\"Manage the users within the system\",\n DOWNLOADS:\"Downloads\",\n DOWNLOADS_DESCRIPTION:\"Download latest APKs and Desktop Application.\",\n MEAUITOR:\"M&E Auditor\",\n MEAUITOR_DESCRIPTION:\"Review key indicators of system performance\",\n DOCUMENTS_DESCRIPTION:\"Access reports and information\",\n EXPORT_DESCRIPTION:\"Export data for use in other systems\",\n MAPPING_DESCRIPTION:\"Explore data through a map interface\",\n NOTEBOOKS_DESCRIPTION:\"Perform complex queries against data within the system\",\n PLOT_DESCRIPTION:\"Plot and share charts and diagrams\",\n ALERT_LOG_DESCRIPTION:\"View and track alerts occurring within the system\",\n ALERT_LOG:\"Alert log\",\n REPORT_MANAGER_DESCRIPTION:\"Perform routine reporting\",\n DATA_COLLECTION:\"Data Collection\",\n EVALUATION:\"Evaluation\",\n AVAILABLE_ONLINE:\"Available Online\",\n AVAILABLE_OFFLINE:\"Available Offline\",\n INDICATOR: \"Indicator\",\n LANGUAGES:\"Languages\",\n MANAGE_LANGUAGES:\"Manage Languages\",\n SELECT_LANGUAGE:\"Select Language\",\n ALARM: \"Alarm\",\n ALARMS: \"Alarms\",\n DATA: \"Data\",\n DASHBOARD: \"Dashboard\",\n EQUAL_TO: \"Equal to\",\n HOME: \"Home\",\n LOGGED_IN_AS_: \"Logged in as \",\n NOT_EQUAL_TO: \"Not equal to\",\n NO_SELECTION: \"No selection\",\n FIELD_SEARCH:\"Search fields...\",\n ORGANIZATION: \"Organization\",\n OVERVIEW: \"OverviewOverview\",\n RISK: \"Risk\",\n SETTING: \"Setting\",\n STAGE_STATE: \"Stage state\",\n STAGE: \"Stage\",\n STATE: \"State\",\n ALERT: \"Alert\",\n ALERTS: \"Alerts\",\n RISK_ASSESSMENT: \"Risk Assessment\",\n RECORDS: \"Records\",\n RISK_CHARACTERIZATION: \"Risk Characterization\",\n OUTCOME: \"Outcome\",\n VERIFICATION: \"Verification\",\n VERIFIED: \"Verified\",\n UNVERIFIED: \"Unverified\",\n DISCARDED: \"Discarded\",\n DISCARD: \"Discard\",\n MAP: \"Map\",\n ANALYSIS: \"Analysis\",\n PLOT: \"Plot\",\n EXPORT: \"Export\",\n IMPORT: \"Import\",\n ASSIGNMENTS: \"Assignments\",\n DOCUMENTS: \"Documents\",\n ACTIVITY: \"Activity\",\n METRICS: \"Metrics\",\n METRICS_OVERALL: \"Overall Metrics\",\n WORKLOAD: \"Workload\",\n ALERT_MAP: \"Alerts Map\",\n TASKS: \"Tasks\",\n PERFORMANCE: \"Performance\",\n SYSTEM: \"System\",\n ANDROID: \"Android\",\n DESKTOP: \"Desktop\",\n IOS: \"iOS\",\n NAME: \"Name\",\n USERNAME : \"Username\",\n TITLE: \"Title\",\n EMAIL: \"Email\",\n DEFINITION:\"Definition\",\n SELECT_ALL : \"Select All\",\n SELECT_NONE : \"Select None\",\n NO_DATE_SELECTED : \"No date selected\",\n MAPPING : \"Mapping\",\n\n ACTIVE: \"Active\",\n INACTIVE: \"Inactive\",\n SUPER_ADMIN: \"Super Administrator\",\n REPORTING_USER: \"Reporting User\",\n ACCOUNT_ADMIN: \"Account Administrator\",\n GEOGRAPHIC_ADMIN: \"Geographic Administrator\",\n\n NO_RETRACTIONS: \"There are currently no pending deletions\",\n NO_AMENDMENTS: \"There are currently no pending amendments\",\n\n OPEN: \"Open\",\n CLOSED: \"Closed\",\n state: \"State\",\n stage_state: \"Stage State\",\n stage: \"Stage\",\n risk: \"Risk\",\n alarm_id: \"Alarm\",\n organization_id: \"Organization\",\n LEVEL_OF_RISK: \"Level of risk\",\n\n FIELD_LABEL: \"Field label\",\n ENTER_FIELD_LABEL:\"Enter field label\",\n ENTER_FIELD_EXPORT_LABEL: \"Enter field export label\",\n ENTER_FIELD_NAME: \"Enter field name\",\n ENTER_OUTPUT_FORMAT: \"Enter output format\",\n ENTER_FIELD_INSTRUCTIONS: \"Enter field instructions\",\n ENTER_DEFAULT_VALUE: \"Enter default value\",\n ENTER_PLACEHOLDER: \"Enter placeholder\",\n ENTER_MAXIMUM: \"Enter maximum\",\n ENTER_MINIMUM: \"Enter minimum\",\n ENTER_SEPARATOR: \"Enter separator\",\n FIELD_TYPE: \"Field type\",\n FIELD_NAME: \"Field name\",\n REQUIRED: \"Required\",\n FIELD_INSTRUCTIONS: \"Field instructions\",\n OPTIONS: \"Options\",\n DEFAULT_VALUE: \"Default value\",\n REDACTED: \"Redacted\",\n HEADER_STYLE: \"Header style\",\n PLACEHOLDER: \"Placeholder\",\n DATE_TYPE: \"Date type\",\n ALLOW_FUTURE_DATES: \"Allow future dates\",\n ACCESS: \"Access\",\n CONDITIONAL_LOGIC: \"Conditional logic\",\n CONDITIONAL_RULES: \"Conditional rules\",\n SELECT_MULTIPLE: \"Multi-Select\",\n MINIMUM: \"Minimum\",\n MAXIMUM: \"Maximum\",\n ALLOW_NEGATIVE: \"Allow negative\",\n\n SUBMITTED: \"Submitted\",\n LATE: \"Late\",\n EXPECTED: \"Expected\",\n ON_TIME : \"On Time\",\n NEW_VALUE : \"New Value\",\n ORIGINAL_VALUE : \"Original Value\",\n VALUE_DISPLAYED: \"Value to be displayed\",\n VALUE_TABLE: \"Value Table\",\n FIRST_VALUE_ONLY : \"First Value Only\",\n RETURNS : \"Returns\",\n GROUP_BY_COLUMN_VALUE : \"Group by column value\",\n HIDE_COLUMN : \"Hide This Column\",\n MISSING: \"Missing\",\n COMPLETENESS: \"Completeness\",\n TIMELINESS: \"Timeliness\",\n USER: \"User\",\n REGIONAL_ADMIN: \"Geographic Administrator\",\n\n COUNT_REPORTING_LOCATIONS: \"Count Reporting Locations\",\n SUM_OF_FIELD_VALUE : \"Sum of field value\",\n CONCAT_FIELD_VALUE : \"Concat field value\",\n COUNT_REPORTS : \"Count Reports\",\n CONDITION_ON_FIELD : \"Apply condition on fields\",\n\n ALL: \"All\",\n MOBILE: \"Mobile\",\n WEB: \"Web\",\n NODE: \"Node\",\n SUBMITTER_TYPE: \"Submitter Type\",\n DELETE: \"Delete\",\n SOURCE: \"Source\",\n SAVE_CHANGES: \"Save Changes\",\n CANCEL: \"Cancel\",\n ALARM_UPDATED: \"The alarm has been updated\",\n CLOSE: \"Close\",\n SAVE_CHANGESs : \"Save Change(s)\",\n NEW : \"New\",\n DUPLICATE : \"Duplicate\",\n\n TEXT_FIELD: \"Text Field\",\n NUMERIC_FIELD: \"Numeric Field\",\n SELECT_FIELD: \"Select Field\",\n TEXTAREA_FIELD: \"Text area Field\",\n SWITCH_FIELD: \"Switch Field\",\n HEADER_FIELD: \"Header Field\",\n MATRIX_FIELD: \"Matrix\",\n ROW_FIELD: \"Row\",\n DISPLAY: \"Display Field\",\n DATE_FIELD : \"Date field\",\n LOC_FIELD : \"Location field\",\n LAT_LNG_FIELD : \"Lat/Lng field\",\n LAT_LONG_FIELD : \"Lat/Long field\",\n CALCULATED :\"Calculated\",\n TIME_INPUT : \"Time Input\",\n MATRIX_ROW_FIELD : \"Matrix Row Field\",\n CALCULATED_FIELD : \"Calculated Field\",\n MEDIA_FIELD : \"Media Field\",\n REPEATER_ONLY_WEB : \"Repeater (Web Only)\",\n RELEATED_RECORDS_WEB_ONLY :\"Related Records (Web Only)\",\n TIME_FIELD :\"Time Field\",\n\n SUB_TITLE: \"Sub-title\",\n\n DAY: \"Day\",\n WEEK: \"Week\",\n MONTH: \"Month\",\n YEAR: \"Year\",\n\n DESC_SETTINGS_GENERAL: \"Modify general settings for how this account operates\",\n DESC_SETTINGS_DASHBOARD: \"Configure dashboard for different user types.\",\n\n DELETE_INDICATOR_GROUP: \"Are you sure you want to delete this item? All associated data and children will be remove including alerts, alarms and form logic items which are based on or rely on any indicators which belong to this group. This operation is permanent.\",\n ALARM_UPDATE: \"Alarm updated\",\n\n SUBMISSIONS: \"Form submissions\",\n REPORTING_LOCATIONS: \"Reporting locations\",\n USER_ORGANIZATIONS:\"User assigned Organizations\",\n USERS: \"Users\",\n LOCATIONS: \"Locations\",\n MONITOR: \"Monitor\",\n RESPONSE: \"Response\",\n RESPOND: \"Respond\",\n AUTO_DISCARDED: \"Auto-Discarded\",\n NO_OUTCOME: \"No Outcome\",\n PENDING: \"Pending\",\n COMPLETED: \"Completed\",\n IN_PROGRESS: \"In Progress\",\n UNASSIGNED: \"Unassigned\",\n\n VERY_HIGH_RISK: \"Very High Risk\",\n HIGH_RISK: \"High Risk\",\n MODERATE_RISK: \"Moderate Risk\",\n LOW_RISK: \"Low Risk\",\n NO_RISK: \"No Risk\",\n\n EID: \"EID\",\n PERIOD_OF_ALERT: \"Period of Alert\",\n TRIGGERED_ON: \"Triggered On\",\n LOCATION_EXACT: \"Location (Exact)\",\n STAGE: \"Stage\",\n RISK_CHAR: \"Risk Characterization\",\n RISK_ASSESS: \"Risk Assessment\",\n ALERTS_OPEN: \"Open alerts\",\n ALERTS_TOTAL: \"Alerts total\",\n ALERTS_CLOSED: \"Alerts closed\",\n FORMS: \"Forms\",\n DEVICES: \"Devices\",\n PARTNERS: \"Partners\",\n TASKS_OPEN: \"Tasks open\",\n TASKS_UNACTIONED: \"Tasks unactioned\",\n TASKS_TOTAL: \"Tasks total\",\n\n TEXT: \"Text\",\n ALERTS_LIST: \"Alerts List\",\n ALERTS_MAP: \"Alerts Map\",\n IMAGE: \"Image\",\n OVERDUE: \"Overdue\",\n UPCOMING: \"Upcoming\",\n NOTIFICATIONS: \"Notifications\",\n DELETIONS: \"Deletions\",\n AMENDMENTS: \"Amendments\",\n FORM_SUBMISSIONS: \"Form Submissions\",\n OTHER : \"Other\",\n ACTIVITY_FEED : \"Activity Feed\",\n\n DASHBOARD_SETTINGS: \"Dashboard Settings\",\n HEADER_ICON: \"Widget Header Icon\",\n HEADER_TEXT_COLOUR: \"Widget Header Text Colour\",\n HEADER_BACKGROUND_COLOUR: \"Widget Background Colour\",\n HEADER_HEADER_TEXT_COLOUR: \"Widget Header Text Colour\",\n WIDGET_FOOTER_TEXT : \"Widget footer text\",\n SAVING_CHANGES: \"Saving changes...\",\n CHANGES_SAVED: \"Changes saved...\",\n\n GENERATED: \"Generated\",\n PER_REPORT: \"Per-report\",\n ONE_OFF: \"One-off\",\n PORTRAIT: \"Portrait\",\n LANDSCAPE: \"Landscape\",\n PDF_ORIENTATION: \"PDF Page Orientation\",\n TEMPLATE_TYPE: \"Template type\",\n INSTANCE_NAME: \"Instance name\",\n TEMPLATE_NAME: \"Template name\",\n GENERAL: \"General\",\n DOCUMENT_DATE: \"Document date\",\n STATUS: \"Status\",\n DESCRIPTION: \"Description\",\n GENERATION: \"Generation\",\n INTERVAL: \"Interval\",\n LOCATION_SPEC: \"Location spec\",\n MONITOR_FOR : \"Monitor For\",\n SET_ALARM_LOCATION_TYPE : \"Set alarm for location type\",\n RESTRICT_DATA_SOURCE:\"Restrict data source\",\n DATA_REPORTED_LOCATION_TYPE :\"Data reported on location type\",\n SOURCE_OF_DATA_BY_LOC_TYPE :\"Source of data by location type\",\n GENERATE_FOR_SPECIFIC_LOC: \"Generate for specific location\",\n GENERATE_FOR_TYPE: \"Generate for type\",\n LOCATION: \"Location\",\n LOCATION_TYPE: \"Location Type\",\n START_DATE: \"Start Date\",\n END_DATE: \"End Date\",\n SOURCE_FORM: \"Source Form\",\n ACCESS_CONSTRAINTS: \"Access constraints\",\n PUBLIC: \"Public\",\n PRIVATE: \"Private\",\n SHARING: \"Sharing\",\n ENABLED: \"Enabled\",\n DISABLED: \"Disabled\",\n ADDITIONAL: \"Additional\",\n NOTIFY_ON_AVAILABLE: \"Notify on availability\",\n DRAFT: \"Draft\",\n UUID : \"UUID\",\n CACHE_EXPIRY_TIME : \"Cache Expiry (hours)\",\n HELP : \"Help\",\n LAST_MODIFIED :\"Last Modified\",\n CREATED_DATE : \"Created Date\",\n\n SETTINGS : \"Settings\",\n WIDGET_EDITOR : \"Widget Editor\",\n TABLE_COLUMNS : \"Table Columns\",\n ADD_COLUMN : \"Add Column\",\n TOTAL_ADVENCED_FORMULA_HELP : \"Use 'variable.{series title}' as operands.Here any series total from the widget can be used in operands. For example 'variable.cholera_male / variable.cholera_total'\",\n ADVENCED_FORMULA_HELP : \"Use 'd.{series title}' as operands.Here series total from the widget can be used in operands. For example 'd.cholera_male / d.cholera_total'\",\n AVAILABLE_OPERANDS :\"Available Operands\",\n AVAILABLE_VARIABLES:\"Available Variables\",\n ALIAS:\"Alias\",\n OPERANDS_HELP : \"You can use these serires total in the formula\",\n CHANGESs_APPLIED : \"Change(s) applied\",\n SOURCE_EDITOR : \"Source Editor\",\n UPDATE : \"Update\",\n SPECIFIC_LOCATION : \"Specific Location\",\n REPORT_LOCATION : \"Report Location\",\n RAW_WIDGET_EDITOR : \"Raw Widget Editor\",\n SERIES_WIDGET_EDITOR : \"Series Widget Editor\",\n ADD_SERIES : \"Add Series\",\n LOCATION_SOURCE : \"Location source\",\n GENERATOR : \"Generator\",\n CATEGORY_WIDGET_EDITOR : \"Category Widget Editor\",\n ADD_CATEGORY : \"Add Category\",\n DOCUMENT_LOCATION :\"Document Location\",\n THRESHOLDS : \"Thresholds\",\n LAYERS : \"Layers\",\n ADD_LAYERS : \"Add Layer\",\n\n\n JSON_EDITOR_ERROR : \"There is an error in your JSON, please review and make changes.\",\n\n\n YES: \"Yes\",\n NO: \"No\",\n VERTICAL_STACK: \"Vertical Stack\",\n HORIZONTAL_STACK: \"Horizontal Stack\",\n SERIES: \"Time series\",\n CATEGORY: \"Categorical\",\n RAW: \"Raw Value\",\n TABLE: \"Table\",\n PIVOT: \"Pivot Table\",\n RECENT_SUBMISSIONS: \"Recent submissions\",\n VIDEO: \"Video\",\n LINKLIST: \"Link list\",\n RECENT_ARTICLES: \"Recent articles\",\n CATEGORY_CHART : \"Category Chart\",\n OVERDUE_SUBMISSION : \"Overdue Submissions\",\n DRAFT_SUBMISSIONS : \"Draft Submissions\",\n\n V_TXT: \"Stack items vertically\",\n H_TXT: \"Stack item horizontally\",\n DATAPOINT: 'DataPoint',\n DATAPOINT_TXT: \"Display a single value\",\n ALERTS_LIST_TXT: \"Display a list of alerts\",\n ALERTS_MAP_TXT: \"Display a map of alerts\",\n MAP_TXT: \"Visualize data on a map\",\n GAUGE: \"Gauge\",\n GAUGE_TXT: \"Display a gauge\",\n HEATMAP: \"Heatmap\",\n HEATMAP_TXT: \"Display a uniform heatmap\",\n TREEMAP: \"Treemap\",\n TREEMAP_TXT: \"Display hierarchical data\",\n ASSIGNMENTS_TXT: \"Display a users current assignments\",\n TABLE_TXT: \"Create a table of values\",\n PIVOT_TXT: \"Create complex tables of data\",\n ACTIVITY_TXT: \"Show recent activity for a user/account\",\n OVERDUE_TXT: \"Show current users overdue form submissions\",\n RECENT_SUBMISSIONS_TXT: \"Show recently submitted forms\",\n DOCUMENTS_TXT: \"Show available documents in system\",\n AMENDMENTS_TXT: \"Show pending amendments\",\n HTML_TXT: \"Manually edit HTML content\",\n IMAGE_TXT: \"Insert an image into a layout\",\n VIDEO_TXT: \"Embed a video from an external service\",\n LINKLIST_TXT: \"Display a list of external links\",\n RECENT_ARTICLES_TXT: \"Display a list of recently published articles\",\n TASKS_TXT: \"Display a users current pending tasks\",\n USER_TXT: \"Display a summary profile widget for the current user\",\n PERFORMANCE_TXT: \"Display summary performance metrics for a user\",\n XRANGE: 'X-Range',\n XRANGE_TXT: 'Bar progress indications',\n SPARK: 'Spark',\n SPARK_TXT: 'Minimal series chart',\n PIE: 'Pie',\n PIE_TXT: 'Display sliced data',\n FUNNEL: 'Funnel',\n FUNNEL_TXT: 'organize data as funnel',\n PYRAMID: 'Pyramid',\n PYRAMID_TXT: 'Hierarchical single values',\n STREAM: 'Stream',\n STREAM_TXT: 'Distribution over time',\n CANDLE: 'Candlestick',\n CANDLE_TXT: 'Display variance',\n BULLET: 'Bullet',\n BULLET_TXT: 'Progress/variance',\n DEFAULT: 'Default',\n DEFAULT_TXT: 'Default Vis',\n CALENDAR: 'Calendar',\n CALENDAR_TXT: 'Plot data against a calendar',\n BARCODE: \"Barcode\",\n EDIT: \"Edit\",\n PAGE_EDIT: \"Page Edit\",\n SITE_EDIT: \"Site Edit\",\n EDIT_ASSIGNMENTS: \"Edit assignments\",\n CHANGE_PASSWORD: \"Change password\",\n REVOKE_ACCESS: \"Revoke access\",\n ACCESS_REVOKED: \"Access Revoked\",\n CONFIRM: \"Confirm\",\n INFO : \"Info\",\n //Profile\n ALERT_TRIGGERED: \"An alert is triggered\",\n ALERT_CLOSED: \"An alert is closed\",\n ALERT_REOPENED: \"An alert is re-opened\",\n ALERT_COMMENT: \"Someone comments on an alert\",\n ALERT_AUTOCLOSED: \"An alert is automatically closed due to expiration\",\n ALERT_OTHER: \"Other alert activity not listed above occurs.\",\n SUCCESS_SUBMIT: \"A new form is submitted\",\n AMENDMENT_REJECTED: \"Your amendment is rejected\",\n AMENDMENT_APPROVED: \"Your amendment is approved\",\n SUBMISSION_RETRACT_APPROVED: \"Your submission retraction request is approved\",\n SUBMISSION_RETRACT_REJECTED: \"Your submission retraction request is rejected\",\n OVERDUE_REPORT: \"You have a report overdue\",\n REPORT_COMMENT: \"Someone comments on a report\",\n OTHER_FORM_SUBMISSION_NOT_LISTED: \"Other form submission activity not listed above occurs\",\n WEEKLY_DIGEST: \"Weekly Digest\",\n DOCUMENT_AVAILABLE: \"New Documents Digest\",\n OTHER_DIGEST_NOT_LISTED: \"Other digest activity not listed above occurs\",\n FORM_REVISION_CREATED: \"A revision is created\",\n FORM_NEW_AVAILABLE: \"A new form becomes available\",\n OTHER_FORM_ACTIVITY_NOT_LISTED: \"Other form activity not listed above occurs\",\n NEW_INDICATOR_AVAILABLE: \"A new indicator becomes available\",\n INDICATOR_OTHER_ACTIVITY_NOT_LISTED: \"Other indicator activity not listed above occurs\",\n NEW_TASK_AVAILABLE: \"A new task becomes available\",\n TASK_STATUS_CHANGE: \"A tasks status changes\",\n TASK_OWNER_CHANGE: \"A tasks owner changes\",\n TASK_COMMENT: \"Someone comments on a task\",\n OTHER_TASK_ACTIVITY_NOT_LISTED: \"Other task activity not listed above occurs\",\n NEW_LOCATION_AVAILABLE: \"A new location becomes available\",\n NEW_LOCATION_REPORTING: \"A new reporting period for a location opens\",\n CLOSED_LOC_REPORTING: \"A locations reporting period closes\",\n LOCATION_DELETED: \"A location is deleted\",\n OTHER_LOCATION: \"Other location activity not listed above occurs\",\n IGNORE: \"Ignore\",\n NOTIFY: \"Notify\",\n DEFAULT_HTML_EMAIL: \"Default (Send HTML Email)\",\n HTML_EMAIL: \"Send HTML Email\",\n PLAINTEXT: \"Send plain text email\",\n DEFAULT_ENABLE_EMAIL_NOTIFICATION: \"Default (Enable Email Notifications)\",\n ENABLE_EMAIL_NOTIFICATION: \"Enable Email Notifications\",\n DISABLE_EMAIL_NOTIFICATION: \"Disable Email Notifications\",\n DEFAULT_DISABLE_PUSH_NOTIFICATION: \"Default (Disable Push Notifications)\",\n ENABLE_PUSH_NOTIFICATION: \"Enable Push Notifications\",\n DISABLE_PUSH_NOTIFICATION: \"Disable Push Notifications\",\n ONLY_APP_NOTIFICATION: \"Send Application Notifications Only\",\n DESKTOP_NOTIFICATION: \"Send Desktop Notifications Too\",\n UPDATED_THEIR_PROFILE: \" updated their profile\",\n UPDATED_HIS_PROFILE: \" updated his profile\",\n UPDATED_HER_PROFILE: \" updated her profile\",\n INSERT: \"Insert\",\n TWO_FACTOR_AUTHENTICATION_NOTE : \"Choose 'Enabled' option to turn on Two-factor authentication.\",\n\n //settings\n DASHBOARDS: \"Dashboards\",\n ORGANIZATIONS: \"Organizations\",\n INVITATIONS: \"Invitations\",\n THEME: \"Theme\",\n PUSH_NOTIFICATIONS: \"Push Notifications\",\n NOTIFICATION_WILL_BE_DELETED_AFTER_30_DAYS: \"Notifications will be automatically deleted after 30 days.\",\n SEND: \"Send\",\n TITLE: \"Title\",\n BODY: \"Body\",\n TEAM: \"Team\",\n SELECT_TEAM_FOR_NOTIFICATION: \"Select team to send the notification\",\n ACCOUNT_NAME: \"Account name\",\n DOMAIN_NAME: \"Domain name\",\n OFFLINE_EXPIRY: \"Offline Sync Expiry Time(Days)\",\n AUTH_SECURITY: \"Authentication & Security\",\n CHANGE_SETTING_MESSEGE: \"Change settings pertaining to how users access the EWARS systems\",\n TWO_FACTOR_AUTH: \"Two-factor authentication\",\n ENFORCE_SSL: \"Enforce SSL\",\n SYSTEM_DEFAULTS: \"System Defaults\",\n SYSTEM_DEFAULTS_MSG: \"Set sane defaults for some user-overridable settings\",\n DEFAULT_LANGUAGE: \"Default language\",\n TIMEZONE: \"Timezone\",\n DATE_FORMAT: \"Date format\",\n TIME_FORMAT: \"Time format\",\n TRANSLATION: \"Translation\",\n ACCOUNT_INFO: \"System/Account Information\",\n OCTET_VERSION: \"Octet version\",\n HUB_ACCESS: \"Hub access\",\n TEMP_DOMAIN: \"Temp domain\",\n ID: \"ID\",\n STORAGE: \"Storage\",\n EMAILS_SENT: \"Emails Sent\",\n GENERAL_SETTINGS: \"General Settings\",\n DEFAULT_BOUNDS: \"Default Bounds\",\n DRAW_DEFAULT_BOUNDS_U_WANT_TO_FOCUS: \"Draw the default bounds that you would like alert maps to focus to\",\n SELECT_LOCATION_TYPE_SHOULD_DEFAULT_BEING_VISUALIZED: \"Select the location type which should default to being visualized on alert maps\",\n AUTO_DISCARD_NOTIFICATION: \"Notify on Auto-Discard\",\n AUTO_DISCARD_NOTIFICATION_ALL_STACKEHOLDER: \"Notify all stakeholders when an alert is auto-discarded?\",\n VIEW: \"View\",\n VIEW_CAPITAL: \"VIEW\",\n DEVICE_TYPE: \"Device Type\",\n DEVICE_ID: \"Device ID\",\n DEVICE_OS_VERSION: \"Device OS Version\",\n NUMBER: \"Number\",\n USER_EMAIL: \"User Email\",\n LAST_SEEN: \"Last Seen\",\n APP_VERSION: \"App Version\",\n APP_VERSION_NAME: \"App Version Name\",\n ANDROID_VERSION: \"Android Version\",\n DEVICE_TYPE_NAME: \"Device Type Name\",\n ADD: \"Add\",\n RESEND: \"RESEND\",\n ORGANIZATION_NAME: \"Organization Name\",\n ACRONYM: \"Acronym\",\n WEB_SITE: \"Web Site\",\n CREATED_BY: \"Created by\",\n APPLICATION_NAME: \"Application name\",\n GENERAL_SETTING_INFORMATION: \"Administer general settings for the account.\",\n DASHBOARDS_SETTING_INFORMATION: \"Configure individual role types dashboards.\",\n // ALARMS_SETTING_INFORMATION: \"Configure and administer settings for alerts within EWARS.\",\n ALERTS_SETTING_INFORMATION: \"Configure and administer settings for alerts within EWARS.\",\n LOCATIONS_SETTING_INFORMATION: \"Set and configure settings for how locations operate within the account.\",\n ORGANIZATIONS_SETTING_INFORMATION: \"Customize the organizations that users for this account can belong to.\",\n DEVICES_SETTING_INFORMATION: \"Manage and view devices connexted to your account.\",\n SCREEN_LOCK_TIME_MINUTES :\"Screen Lock Time(Minutes)\",\n SMS_PHONE_NUMBER : \"SMS Phone Number\",\n ENTER_SMS_PHONE_NUMBER: \"Enter SMS phone number\",\n EPI_WEEK_START_LABEL: \"epi week Start\",\n FIRST_WEEK_CONTAINS: \"1st Week Contains\",\n MONDAY:\"Monday\",\n TUESDAY:\"Tuesday\",\n WENDESDAY:\"Wednesday\",\n THURSDAY:\"Thursday\",\n FRIDAY:\"Friday\",\n SATURDAY:\"Saturday\",\n SUNDAY:\"Sunday\",\n\n JANUARY : \"January\",\n FEBRUARY : \"February\",\n MARCH : \"March\",\n APRIL : \"April\",\n MAY : \"May\",\n JUNE : \"June\",\n JULY : \"July\",\n AUGUST : \"August\",\n SEPTEMBER : \"September\",\n OCTOBER : \"October\",\n NOVEMBER : \"November\",\n DECEMBER : \"December\",\n //locations\n LOCATION_GROUPS: \"Location Group(s)\",\n PARENT: \"Parent\",\n LOCATION_TYPE: \"Location Type\",\n GEOMETRY_TYPE: \"Geometry Type\",\n DEFAULT_ZOOM: \"Default zoom\",\n CREATED: \"Created\",\n LOADING: \"Loading...\",\n DELETE_LOCATION: \"Delete Location?\",\n DELETE_LOCATION_BUTTON_TEXT: \"I understand the consequences, delete this location\",\n MERGE_LOCATION: \"Merge Location\",\n MOVE_DATA_T: \"Move Data\",\n MOVE_DATA_B: \"Commit Transfer\",\n ARCHIVE_LOCATION: \"Archive Location\",\n COMMIT_TO_ARCHIVE: \"Commit to Archive\",\n ADD_CHILD: \"Add Child\",\n MERGE_INTO: \"Merge Into\",\n ENABLE_CHILDREN: \"Enable Children\",\n DISABLE_CHILDREN: \"Disable Children\",\n //outbreaks\n OUTBREAKS : \"Outbreaks\",\n MODIFIED: \"Modified\",\n OUTBREAK_NAME: \"Outbreak Name\",\n NEW_OUTBREAK: \"New Outbreak\",\n //inbox\n NO_TASKS_MESSEGE: \"You currently do not have any tasks available\",\n HIGH: \"High\",\n MODERATE: \"Moderate\",\n LOW: \"Low\",\n DELETION_REQUEST: \"Deletion Request\",\n AMENDMENT_REQUEST: \"Amendment Request\",\n USER_ACC_REQUEST: \"User Account Request\",\n ASSIGNMENT_REQUEST: \"Assignment Request\",\n IN: \"in\",\n NO_ACTIVITY: \"No Activity\",\n LOAD_MORE: \"Load more\",\n JOINED_EWARS_MESSEGE: \"has joined ewars\",\n NEW_REPORT_SUBMITTED: \"submitted a new report\",\n //report_manager\n PROVIDE_SEARCH_TERM: \"Please provide a search term\",\n\n //dashboards\n ALARM_STATUS : \"Alarm Status\",\n ANY : \"Any\",\n REPORT_COUNT : \"Report Count\",\n ACTIVE_ALERTS : \"Active Alerts\",\n GRID : \"Grid\",\n LIST : \"LIst\",\n EXPLORE : \"Explore\",\n\n MOVE_ROW_UP : \"Move Row Up\",\n MOVE_ROW_DOWN : \"Move Row Down\",\n MOVE_CELL_LEFT : \"Move Cell Left\",\n MOVE_CELL_RIGHT : \"Move Cell Right\",\n DUPLICATE_ROW : \"Duplicate Row\",\n DUPLICATE_CELL : \"Duplicate Cell\",\n REMOVE_CELL : \"Remove Cell\",\n REMOVE_ROW : \"Remove Row\",\n CHART_COMPONENT: \"Chart Component\",\n SERIES_CHART : \"Series Chart\",\n CATEGORY_WIDGET : \"Category Widget\",\n LAYOUT_NAME : \"Layout Name\",\n COLOR : \"Color\",\n RAW_WIDGET : \"Raw Widget\",\n SUMMARY_STATISTICS : \"Summary Statistics\",\n OVERDUE_REPORTS : \"Overdue Reports\",\n CELL : \"Cell\",\n ROW_D : \"Row\",\n CONTENT : \"Content\",\n RAW_D : \"Raw\",\n\n DATA_SOURCE : \"Data Source\",\n SOURCE_TYPE : \"Source Type\",\n COMPLEX : \"Complex\",\n IND_SOURCE : \"Indicator Source\",\n FORMULA : \"Formula\",\n VARIABLES :\"Variables\",\n ZONES : \"Zones\",\n REDUCTION : \"Reduction\",\n PERIOD : \"Period\",\n STYLE : \"Style\",\n VALUE_FORMATTING : \"Value Formatting\",\n PREFIX : \"Prefix\",\n SUFFIX : \"Suffix\",\n VALUE_COLOURING : \"Value Colouring\",\n VALUE_MAPPING :\"Value Mapping\",\n //Alerts\n PROBABILITY_GT_95: \"Is expected to occur in most circumstances (e.g. probability of 95% or more) \",\n PROBABILITY_70_TO_94: \"Will probably occur in most circumstances (e.g. a probability of between 70% and 94%) \",\n PROBABILITY_30_TO_69: \"Will occur some of the time (e.g. a probability of between 30% and 69%) \",\n PROBABILITY_5_TO_29: \"Could occur some of the time (e.g. a probability of between 5% and 29%) \",\n PROBABILITY_LT_5: \"Could occur under exceptional circumstances (e.g. a probability of less than 5%)\",\n\n LIMITED_IMPACT: \"Limited impact on the affected population\",\n MINOR_IMPACT: \"Minor impact for a small population or at-risk group \",\n MODERATE_IMPACT: \"Moderate impact as a large population or at-risk group is affected\",\n MAJOR_IMPACT: \"Major impact for a small population or at-risk group \",\n SEVER_IMPACT: \"Severe impact for a large population or at-risk group \",\n\n LITTLE_DISRUPTION: \"Little disruption to normal activities and services\",\n LIMITED_DISRUPTION: \"Limited disruption to normal activities and services\",\n MODERATE_DISRUPTION: \"Moderate disruption to normal activities and services\",\n MAJOR_DISRUPTION: \"Major disruption to normal activities and services\",\n SEVERE_DISRUPTION: \"Severe disruption to normal activities and services\",\n\n FEW_INCREASE: \"Few extra costs for authorities and stakeholders \",\n SOME_INCREASE: \"Some increase in costs for authorities and stakeholders\",\n MODERATE_INCREASE: \"Moderate increase in costs for authorities and stakeholders \",\n SIGNIFICANT_INCREASE: \"Significant increase in costs for authorities and stakeholders \",\n SERIOUS_INCREASE: \"Serious increase in costs for authorities and stakeholders\",\n\n NO_RESOURCES: \"Routine responses are adequate and there is no need to implement additional control measures\",\n MINIMAL_RESOURCES: \"A small number of additional control measures will be needed that require minimal resources\",\n MODERATE_RESOURCES: \"Some additional control measures will be needed and some of these require moderate resources to implement\",\n SOME_SIGNIFICANT_RESOURCES: \"A large number of additional control measures will be needed and some of these require significant resources to implement\",\n MOST_SIGNIFICANT_RESOURCES: \"A large number of additional control measures will be needed and most of these require significant resources to implement\",\n\n MINIMAL: \"Minimal\",\n MINOR: \"Minor\",\n MODERATE: \"Moderate\",\n MAJOR: \"Major\",\n SEVERE: \"Severe\",\n\n ALMOST_CERTAIN: \"Almost Certain\",\n HIGHLY_LIKELY: \"Highly Likely\",\n LIKELY: \"Likely\",\n UNLIKELY: \"Unlikely\",\n VERY_UNLIKELY: \"Very Unlikely\",\n\n ON: \"On\",\n OFF: \"Off\",\n\n START_RISK_ASSESSMENT_CAMEL: \"Start Risk Assessment\",\n\n VERIFIED_THIS_ALERT: \"verified this alert on\",\n ASSESSED_THIS_ALERT: \"assessed this alert on\",\n CHARACTERIZED_THIS_ALERT: \"characterized this alert on\",\n SET_OUTCOME_FOR__THIS_ALERT: \"set the outcome for this alert on\",\n REOPEN_THIS_ALERT: \"reopened this alert on\",\n DISCARDED_THIS_ALERT: \"discarded this alert on\",\n AUTOCLOSED_THIS_ALERT: \"discarded this alert on\",\n MONITOR_THIS_ALERT_STATE: \"set this alerts state to Monitor on\",\n RESPOND_THIS_ALERT_OUTCOME: \"set this alerts outcome to Respond on\",\n CLOSED_THIS_ALERT: \"caused this alert to close on\",\n SET_RESPONSE_THIS_ALERT: \"set this alerts outcome to Respond on\",\n INVESTIGATION_REPORT_SUBMISSION: \"submitted an investigation report on\",\n\n ALERT_EVENTS_OPENED: \"Alert opened on\",\n ALERT_EVENTS_CLOSED: \"Alert was closed on\",\n ALERT_EVENTS_TRIGGERED: \"Alert was raised on\",\n ALERT_EVENTS_AUTODISCARDED: \"Alert was auto-discarded by the system due to inaction on\",\n ALERT_EVENTS_AUTOCLOSED: \"Alert was auto-discarded by the system due to inaction on\",\n\n CONSTANTS_ONEM: \"ONEM\",\n CONSTANTS_THREEM: \"THREEM\",\n CONSTANTS_SIXM: \"SIXM\",\n CONSTANTS_ONEY: \"ONEY\",\n CONSTANTS_YTD: \"YTD\",\n CONSTANTS_ALL: \"ALL\",\n CONSTANTS_DAY: \"DAY\",\n CONSTANTS_WEEK: \"WEEK\",\n CONSTANTS_MONTH: \"MONTH\",\n CONSTANTS_YEAR: \"YEAR\",\n\n NEARBY: \"NEARBY\",\n \n RISK_UNASSIGNED: \"Risk unassigned\",\n OUTCOME_UNASSIGNED: \"Outcome unassigned\",\n\n ALERT_WORKFLOW: \"Alert Workflow\",\n TRIGGERED_ALERT: \"Alert Triggered\",\n SAVE_DRAFT: \"Save Draft\",\n SUBMIT: \"Submit\",\n GUIDANCE: \"Guidance\",\n\n STAGE_1_VERIFICATION: \"Stage 1 | Verification\",\n STAGE_2_RISK_ASSESSMENT: \"Stage 2 | Risk Assessment\",\n STAGE_3_RISK_CHARACTERIZATION: \"Stage 3 | Risk Characterisation\",\n STAGE_4_OUTCOME: \"Stage 4 | Outcome\",\n\n VERIFICATION_NOTES: \"Verification notes\",\n VERIFICATION_QUESTION_1: \"Has the event been reported by an official source (for example, local health-care centre or clinic, public health authorities, animal health workers?\",\n VERIFICATION_QUESTION_2: \"Has the event been reported by multiple independent sources (for example, residents, news media, health-care workers, animal health status )?\",\n VERIFICATION_QUESTION_3: \"Does the event description include details about time, place and people involved (for example, six people are sick and two died three days after a ending a local celebration on in community X)?\",\n VERIFICATION_QUESTION_4: \"Is the clinical presentation of the cases described (for example, a cluster of seven people admitted to hospital with atypical pneumonia, of whom two have died)?\",\n VERIFICATION_QUESTION_5: \"Has a similar event been reported previously (for example, with a similar presentation, affecting a similar population and geographical area, over the same time period)?\",\n\n VERIFY_ALERT_MSG: \"Verify the alert to determine if it needs to be risk assessed, monitored or discarded\",\n\n START_VERIFICATION: \"Start verification\",\n OPEN_VERIFICATION: \"Open verification\",\n REVIEW_VERIFICATION: \"Review verification\",\n UPDATE_VERIFICATION: \"Update verification\",\n \n ALERT_REOPEN: \"Re-Open Alert\",\n\n START_OUTCOME: \"Start outcome\",\n OPEN_OUTCOME: \"Open outcome\",\n REVIEW_OUTCOME: \"Review outcome\",\n UPDATE_OUTCOME: \"Update outcome\",\n\n DESIGNATE_OUTCOME_MSG: \"Designate a final outcome to the alert.\",\n SELECT_OUTCOME_MSG: \"Please select an outcome for the alert below\",\n\n START_RISK_ASSESSMENT: \"Start risk assessment\",\n OPEN_RISK_ASSESSMENT: \"Open risk assessment\",\n REVIEW_RISK_ASSESSMENT: \"Review risk assessment\",\n UPDATE_RISK_ASSESSMENT: \"Update risk assessment\",\n RISK_ASSESSMENT_MESSEGE: \"Complete risk assessment to describe the hazard, exposure and context\",\n\n ALERT_RISK_LEVEL_MESSEGE: \"Characterise the alert to assign a level of risk, from low to very high\",\n\n RISK_CHARACTERIZATION_WARNING: \"Please select a risk characterisation\",\n START_RISK_CHARACTERIZATION: \"Start risk characterisation\",\n OPEN_RISK_CHARACTERIZATION: \"Open risk characterisation\",\n REVIEW_RISK_CHARACTERIZATION: \"Review risk characterisation\",\n UPDATE_RISK_CHARACTERIZATION: \"Update risk characterisation\",\n\n LOW_RISK_CONTENT: \"Managed according to standard response protocols, routine control programmes and regulation (e.g. monitoring through routine surveillance systems) \",\n MODERATE_RISK_CONTENT: \"Roles and responsibility for the response must be specified. Specific monitoring or control measures required (e.g. enhanced surveillance, additional vaccination campaigns) \",\n HIGH_RISK_CONTENT: \"Senior management attention needed: there may be a need to establish command and control structures; a range of additional control measures will be required some of which may have significant consequences \",\n SEVERE_RISK_CONTENT: \"Immediate response required even if the event is reported out of normal working hours. Immediate senior management attention needed (e.g. the command and control structure should be established within hours); the implementation of control measures with serious consequences is highly likely \",\n\n LIKELIHOOD: \"Likelihood\",\n CONSEQUENCES: \"Consequences\",\n ACTIONS: \"Actions\",\n\n RISK_MATRIX: \"Risk Matrix\",\n SELECT_EVENT_MSG: \"Select likelihood and potential consequences of the hazard/event in the grid below:\",\n OVERALL_LEVEL_OF_RISK: \"Overall level of risk\",\n\n HAZARD_ASSESSMENT: \"Hazard Assessment\",\n HAZARD_ASSESSMENT_INCLUDES: \"Hazard assessment includes:\",\n HAZARD_ASSESSMENT_INCLUDES_1: \"identifying the hazard(s) that could be causing the event\",\n HAZARD_ASSESSMENT_INCLUDES_2: \"reviewing key information about the potential hazard(s) (i.e. characterizing the hazard)\",\n HAZARD_ASSESSMENT_INCLUDES_3: \"ranking potential hazards when more than one is considered a possible cause of the event (equivalent to a differential diagnosis in clinical medicine).\",\n \n EXPOSURE_ASSESSMENT: \"Exposure Assessment\",\n EXPOSURE_ASSESSMENT_OUTPUT: \"The key output of the assessment is an estimate of the:\",\n EXPOSURE_ASSESSMENT_OUTPUT_1: \"number of people or group known or likely to have been exposed.\",\n EXPOSURE_ASSESSMENT_OUTPUT_2: \"number of exposed people or groups who are likely to be susceptible (i.e capable of getting a disease because they not immune)\",\n \n CONTEXT_ASSESSMENT: \"Context Assessment\",\n CONTEXT_ASSESSMENT_QUESTIONS: \"Context assessment addresses the following questions:\",\n CONTEXT_ASSESSMENT_QUESTIONS_1: \"What are the factors associated with the environment, health status, behaviours, social or cultural practices, health infrastructure and legal and policy frameworks that increase a population’s vulnerability?\",\n\n SELECT_RISK_LEVEL_MSG: \"Please select a risk level from the options at left.\",\n ALERT_INDICATOR_TREND: \"Alert Indicator Trend\",\n ALERT_THRESHOLD: \"Alert Threshold\",\n\n COMMENTS: \"Comments\",\n ADD_COMMENT_MESSEGE: \"Add any other relevant comments\",\n\n REASON: \"Reason\",\n REASON_FOR_REOPENING_ALERT_MSG: \"Please enter a reason below for re-opening this alert\",\n\n LOADING_ALERT: \"Loading alert...\",\n DRAFT_UPDATED: \"Draft updated...\",\n SAVING: \"Saving...\",\n SUBMITTING: \"Submitting...\",\n SAVE_COMMENT: \"Saving comment...\",\n COMMENTED_ON: \" commented on \",\n REOPENING_ALERT: \"Re-opening alert...\",\n VALIDATING_REPORT: \"Validating Report...\",\n SUBMITTING_REPORT: \"Submitting Report...\",\n\n PROVIDE_VALID_HAZARD_ASSESSMENT: \"Please provide a valid hazard assessment\",\n PROVIDE_VALID_CONTEXT_ASSESSMENT: \"Please provide a valid context assessment\",\n PROVIDE_VALID_EXPOSURE_ASSESSMENT: \"Please provide a valid exposure assessment\",\n \n PROVIDE_VALID_VERIFICATION_NOTES: \"Please provide valid Verification notes\",\n PROVIDE_VALID_VERIFICATION_OUTCOME: \"Please provide a valid verification outcome\",\n\n VALID_REASON_FOR_REOPEN_ALERT_ERROR: \"Please provide a valid reason for re-opening this alert.\",\n\n VALID_COMMENT_ERROR: \"Please provide a valid comment\",\n SUBMIT_REPORT: \"Submit Report\",\n CREATE_REPORT: \"Create Report\",\n ERR_IN_REPORT: \"There is an error in the report\",\n CONFIRMATION_FOR_SUBMIT_REPORT: \"Are you sure you want to submit this report? Once submitted, the report will not be editable.\",\n REPORT_SUBMITTED_SUCCESSFULLY: \"Report submitted successfully\",\n REPORT_LINKED_SUCCESSFULLY: \"Report linked successfully\",\n ATTACHED_REPORTS: \"Attached reports\",\n LINK_RECORD:\"Link Report\",\n LINK_RECORD_DESC:\"Are you sure you want to link this report? Once linked, the report will not be unlinked.\",\n LINKING_REPORT: \"Linking Report...\",\n NONE : \"None\",\n SUM : \"Sum\",\n MED :\"Average/Mean\",\n VARIABLE_NAME : \"Variable Name\",\n SEARCHING_INDICATOR : \"Search indicators...\",\n SELECT_INDICATOR : \"Select Indicator\",\n ADD_VARIABLE : \"Add Variable\",\n COLOUR_THRESHOLDS : \"Colour Thresholds\",\n LANGUAGE : \"language\",\n FIELD_SUPPORT_MARKDOWN : \"This field supports markdown\",\n NO_LOCATION_SELECTED : \"No location selected\",\n AVAILABLE_LANGUAGES : \"Available Languages\",\n ENTER_NUMBER : \"Enter number\",\n ENTER_TEXT : \"Enter text\",\n SLICE_LABEL : \"Slice Label\",\n COLOUR : \"Colour\",\n LOCATION_SPECIFICATION : \"Location Specification\",\n VALUE_FOR : \"Value For\",\n COLUMN_TOTAL : \"Column Total\",\n EXISTING_DATA_SOURCE : \"Use Existing Data Source\",\n USE_EXISTING_DATA_SOURCE : \"Use existing data source\",\n ROW_VALUE_SELECTION : \"Row Value Selection\",\n DATA_COLUMN : \"Data Column\",\n GROUP_OUTPUT : \"Group Output\",\n AGGREGATE : \"Aggregate\",\n INDIVIDUAL : \"Individual\",\n GENERATOR_PARENT_LOCATION : \"Generator parent location\",\n GENERATOR_LOCATION_TYPE : \"Generator location type\",\n LOCATION_STATUS : \"Location Status\",\n CATEGORY_LABEL_SOURCE : \"Category Label Source\",\n INDICATOR_LOCACTION_VALUE : \"Indicator - Location - Value\",\n INDICATOR_LOCATION : \"Indicator - Location\",\n REDUCTION_TYPE : \"Reduction Type\",\n AVG : \"Average/Median\",\n INHERIT : \"Inherit\",\n OVERRIDE : \"Override\",\n CUSTOM : \"Custom\",\n CHART_TITLE : \"Chart Title\",\n SAMPLE_INTERVAL : \"Sample Interval\",\n CONTROLS : \"Controls\",\n LEGEND : \"Legend\",\n SHOW_DATA_LABELS : \"Data Labels\",\n CONNECTORS_DISTANCE:\"Data Label connector's distance\",\n LEGEND_POSITION : \"Legend Position\",\n CHART_MIN_SIZE: \"Chart Min. Size\",\n CHART_STYLE : \"Chart Style\",\n DONUT : \"Donut\",\n ARC : \"Arc\",\n BAR_GRAPH : \"Bar Graph\",\n SLICE_ORDRING : \"Slice Ordering\",\n START_ANGLE:\"Start Angle\",\n CATEGORY_NAME_ASCENDING : \"Category Title Ascending\",\n CATEGORY_NAME_DESCENDING : \"Category Title Descending\",\n VALUE_ASCENDING : \"Value Ascending\",\n VALUE_DESCENDING : \"Value Descending\",\n ADVANCED_OPTION :\"Advanced Options\",\n SLICE_WITH_NO_DATA : \"Slices with no data\",\n DATA_QUERY_PERIOD : \"Data Query Period\",\n TIME_INTERVAL : \"Time Interval\",\n QUERY_RANGE : \"Query Range\",\n RANGES : \"Ranges\",\n COLOURS : \"Colours\",\n STYLING : \"Styling\",\n NUM_FORMATTING : \"Number Formatting\",\n LOCATION_SOURCE : \"Locations Source\",\n LOCATIONs : \"Location(s)\",\n SPECIFIC : \"Specific\",\n OF_TYPE : \"Of Type\",\n QUERY_TYPE : \"Query Type\",\n FORMULA_AGGREGATION_INTERVAL :\"Formula Aggregation Interval\",\n OPACITY : \"Opacity\",\n BASE_GEOMETRY_COLOR : \"Base Geometry Colour\",\n BACKGROUND_COLOR : \"Background Colour\",\n HOVER_COLOR : \"Hover Colour\",\n STROKE_COLOR : \"Stroke Colour\",\n STROKE_WIDTH : \"Stroke Width\",\n STROKE_STYLE : \"Stroke style\",\n LABEL_STYLING :\"Label Styling\",\n SHOW_LABEL : \"Show labels\",\n LABELLING_STYLE :\"Labelling style\",\n NUMBERED : \"Numbered\",\n LABEL_FONT_SIZE : \"Label Font Size (px)\",\n LABEL_COLOUR : \"Label Colour\",\n LABEL_THRESHOLD : \"Label Threshold (gte)\",\n LAYER_TITLE : \"Layer title\",\n VISUALIZATION : \"Visualization\",\n LOC_OF_TYPE : \"Locations of type\",\n SINGLE_LOCATION : \"Single location\",\n COLLECTED_LAT_LNG : \"Collected Lat/Lng\",\n ALERT_MAP : \"Alerts Map\",\n COMPLEX_INDICATOR : \"Complex Indicator\",\n DOWNLOADING_FAILED:\"Downloading Failed!\",\n DOWNLOADING:\"Downloading pdf...\",\n CALCULATION :\"Calculation\",\n SOURCE_PERIOD : \"Source period\",\n SHOW_SCALE : \"Show scale\",\n SCALE_POSITION : \"Scale pos.\",\n DATE_RANGE : \"Date Range\",\n FORMATTING : \"Formatting\",\n VALUE_TEXT_SIZE : \"Value Text Size\",\n\n\n\n WIDGET_SETTING :\"Widget settings\",\n BASE_COLOUR : \"Base colour\",\n HIGHLIGHT_COLOUR : \"Highlight colour\",\n ICON :\"Icon\",\n WIDGET_SUB_TEXT :\"Widget sub-text\",\n WIDGET_FOOTER_TEXT : \"Widget footer text\",\n HEADER_COLOUR : \"Header Colour\",\n HEADER_TEXT_CLR : \"Header Text Colour\",\n WIGDET_TEXT_CLR :\"Widget Text Colour\",\n WIDGET_TITLE : \"Widget Title\",\n WIDGET_ICON : \"Widget Icon\",\n WIDGET_STYLING : \"Widget styling\",\n HEADR_ICON : \"Header icon\",\n\n AVGERAGE : \"Average\",\n LOCATION_GROUP : \"Location group\",\n CUSTOM_GEOJSON : \"Custom geojson\",\n FORM_FIELD : \"Form field\",\n FILL_COLOR : \"Fill color\",\n FILL_OPACITY : \"Fill opacity\",\n MARKER_TYPE : \"Marker type\",\n MARKER_SIZE : \"Marker size\",\n LABELS : \"Labels\",\n LABEL_TYPE : \"Label type\",\n IN_PLACE : \"In-place\",\n NO_LABELLING : \"No labelling\",\n LABEL_COLOR :\"Label color\",\n LABEL_SIZE : \"Label size\",\n MAP_BOUNDS : \"Map bounds\",\n BACKGROUND_COLOR : \"Background color\",\n TIME_CONTROLS : \"Time controls\",\n ZOOM_CONTROLS : \"Zoom controls\",\n LAYER_CONTROLS : \"Layer controls\",\n MAPBOX_LAYER : \"Mapbox layer\",\n LAYOUT : \"Layout\",\n SELECTED_METRICS : \"Selected Metrics\",\n LOCATION_TOTAL : \"Locations Total\",\n ALERT_OPEN : \"Alerts Open\",\n ALERT_TRIGGERED : \"Alerts Triggered\",\n DOCUMNETS_TOTAL : \"Documents Total\",\n SPECIFIC_ALARM_OPTIONAL : \"Specific Alarm (Optional)\",\n ALERT_STATE_OPTIONAL : \"Alert State (Optional)\",\n ALERT_STAGE : \"Alert Stage\",\n ALERT_STAGE_STATE : \"Alert Stage State\",\n PENDING : \"Pending\",\n COMPLETED : \"Completed\",\n ALERT_RISK: \"Alert Risk\",\n SPECIFIC_FORM_OPTIONAL : \"Specific Form (Optional)\",\n IMAGE_URL : \"Image URL\",\n IMAGE_LINK : \"Image link\",\n LINK_URL:\"Link Url\",\n REDIRECTION_URL: \"Redirection URL\",\n REDIRECTION_URL_PLACEHOLDER: \"Enter the URL of the website,document etc.\",\n DOMAIN:\"Domain\",\n AGGREGATION_INTERVAL : \"Aggregation Interval\",\n GROUPs : \"Group(s)\",\n INDICATOR_SPECIFICATION : \"Indicator Specification\",\n LINE_WIDTH : \"Line Width\",\n LINE_STYLE : \"Line Style\",\n MARKER_RADIUS : \"Marker Radius\",\n MARKER_STYLE : \"Marker style\",\n DATA_PERIOD : \"Data Period\",\n NAVIGATOR : \"Navigator\",\n COLUMN_HEADER : \"Column Headers\",\n ADDITIONAL_CLASS_NAME : \"Additional Class Name\",\n\n DAILY : \"Daily\",\n WEEKLY :\"Weekly\",\n MONTHLY : \"Monthly\",\n ANNUALY : \"Annually\",\n ON : \"On\",\n OFF : \"Off\",\n SHOW : \"Show\",\n HIDE : \"Hide\",\n TOP : \"Top\",\n RIGHT : \"Right\",\n BOTTOM : \"Bottom\",\n LEFT : \"Left\",\n Y_AXIS_LABEL :\"Y Axis label\",\n Y_AXIS_FORMAT :\"Y Axis format\",\n Y_AXIS_DECIMALS :\"Y Axis decimals\",\n WIDTH : \"Width\",\n HEIGHT : \"Height\",\n SOLID : \"Solid\",\n DOTTED : \"Dotted\",\n DASHED : \"Dashed\",\n CIRCLE: \"Circle\",\n SQUARE : 'Square',\n TRIANGLE : \"Triangle\",\n STAR: \"Star\",\n BAR : \"Bar\",\n DIAMOND : \"Diamond\",\n TRIANGLE_DOWN : \"Triangle-Down\",\n ZOOM : \"Zoom\",\n Y_AXIS : \"Y Axis\",\n SECOND_Y_AXIS:\"Secondary Y Axis\",\n X_LABEL_EXCLUDE_YEARS:\"Exclude years from X Axis labels\",\n X_AXIS_INVERTED:\"X Axis Inverted\",\n SHOW_ONLY_TITLE_IN_LEGEND:\"Show only title (Legends)\",\n X_AXIS_TITLE: \"X Axis title\",\n Y_AXIS_TITLE: \"Y Axis title\",\n SLICES_WITH_NO_DATA: \"Show slices with no data\",\n DECIMALS : \"Decimals\",\n MAX_Y_VALUE : \"Max. Y value\",\n Y_AXIS_INTRVL : \"Y Axis interval\",\n X_AXIS_INTRVL : \"X Axis interval\",\n X_AXIS : \"X Axis\",\n X_AXIS_LABELS: \"X Axis labels\",\n X_LABEL_ROTATION : \"X Axis label rotation\",\n X_AXIS_LABEL_STAGGER_LINES : \"X Axis label stagger lines\", \n CHART_WIDTH_PX : \"Chart width (px)\",\n CHART_HIEGHT_PX : \"Chart height (px)\",\n STACKED : \"Stacked\",\n SHOW_PARENT_COLUMN : \"Show parent column?\",\n PARENT_LOCATION : \"Parent Location\",\n ADVANCED : \"Advanced\",\n SORTING_COLUMN : \"Sorting Column\",\n HIDE_ROW_0_NO_DATA : \"Hide rows with 0 or no data\",\n LIMIT_ROWS : \"Limit rows\",\n\n LINE : \"Line\",\n AREA : \"Area\",\n COLUMN : \"Column\",\n SCATTER : \"Scatter\",\n SPLINE : \"Spline\",\n WATERFALL : \"Waterfall\",\n\n\n Top_Center : 'Top-center',\n Top_Right : \"Top-right\",\n Middle_Right : \"Middle-right\",\n Bottom_Right : \"Bottom-right\",\n Bottom_Center : 'Bottom-center',\n Bottom_Left : \"Bottom-left\",\n Middle_Left : \"Middle-left\",\n Top_Left : \"Top-left\",\n Middle_Center : \"Middle-Center\",\n\n SHORT_DASH: \"Short Dash\",\n SHORT_DOT : \"Short Dot\",\n SHORT_DASH_DOT : \"Short Dash Dot\",\n SHORT_DASH_DOT_DOT : \"Short Dash Dot Dot\",\n DOT : \"Dot\",\n DASH: \"Dash\",\n LONG_DASH : \"Long Dash\",\n DASH_DOT : \"Dash Dot\",\n LONG_DASH_DOT : \"Long Dash Dot\",\n LONG_DASH_DOT_DOT : \"Long Dash Dot Dot\",\n\n\n W : \"W\",\n MON : \"Mon\",\n TUE : \"Tue\",\n WED : \"Wed\",\n THURS : \"Thurs\",\n FRI : \"Fri\",\n SAT : \"Sat\",\n SUN : \"Sun\",\n \n //Alarms\n GENERAL:\"General\",\n MONITORING:\"Monitoring\",\n AUTO_DISCARD:\"Auto-Discard\",\n INVESTIGATION:\"Investigation\",\n ADMINSTRATION:\"Administration\",\n ALERT_EID_PREFIX: \"Alert EID Prefix\",\n EID_HELP: \"Set a prefix for the ID of any alerts generated by this alarm\",\n GENERAL_SETTING_FOR_THE_ALARM:\"General settings for the alarm\",\n MONITORING_TYPE:\"Monitoring Type\",\n DESC_AGGREGATE_CONTENT:\"Aggregate type alarms use an aggregation from multiple records for a given source to evaluate an alert. The record date for the form submission which triggered the evaluation is used as the period of data to aggregate. Only a single active alert can exist per location/date.\",\n DESC_RECORD_OCNTENT:\"Record constrained alarms are sandboxed to indicator values coming from the record which triggered the evaluation and will be raised against the records location and date. Multiple alerts can be raised for a single location/date.\",\n LOCATION_SPECIFICATIONS : \"Location Source Specifications\",\n DATA_SOURCE_SPECIFICATION:\"Data Source Specifications\",\n MONITORED_BY:\"Monitored By\",\n DATA_SOURCE_INTERVAL_AS:\"Data Source Interval as\",\n RANGE_OF_INTERVAL : \"Range of Intervals\",\n MONITOR_LOCATION : \"Location\",\n INTERVAL:\"Interval\",\n NO_OF_INTERVALS:\"No. of Intervals\",\n AUTO_DISCARD_SETTINGS:\"Auto-discard settings\",\n AUTO_DISCARD_DESCRIPTION:\"Define interval and no. of interval when the alert should be auto-closed\",\n AUTO_DISCARDED_INTERVAL:\"Auto-discard interval\",\n RESTRICTED_LOCATIONS:\"Restrict Location(s)\",\n RESTRICTED_LOCATION_TYPE:\"Restrict location type\",\n EVELUATE_AT_LOCATION_TYPE:\"Evaluate at location type\",\n EXCLUDE_ZERO_VALUE: \"Exclude zero value\",\n IS_SEASONAL: \"Seasonal Variation\",\n SD_MEAN_PER:\"SD/Mean/Percentile\",\n RNG_OF_INTVS:\"Range of Intervals\",\n ALARM_FIELD_REQUIRED: \"Please provide required fields in the alarm configuration\",\n ALARM_FIELD_MANDATORY: \"Please provide mandatory fields\",\n NO_OF_WEEKS:\"No. of +/- Weeks\",\n NO_OF_PREV_YEARS:\"No. of previous years\",\n PRE_CONFIGURED_FORMULA:\"Pre-Configured Formula\",\n STI_AGG_ROLLUP_HELP:\"Roll up data to this location type\",\n DATA_SOURCE_INTERVAL_SOURCE:\"Data Source Interval Source\",\n RANGE_INTERVAL:\"Range Intervals\",\n DATA_SOURCE_INTERVAL:\"Data Source Interval\",\n AGGREGATE_BASED:\"Aggregate-based\",\n RECORD_BASED:\"Record-based\",\n REPORT_PERIOD:\"Report Period\",\n RANGE:\"Range\",\n SOURCE_INDICATOR:\"Source Indicator\",\n AGGREGATE_LOWER_LEVELS_LOCATIONS:\"Aggregate Lower levels(Locations)\",\n AGGREGATION:\"Aggregation\",\n SUM:\"Sum\",\n AVERAGE_MEAN:\"Average/Mean\",\n AVERAGE: \"Average\",\n MODIFIER:\"Modifier\",\n ALERT_CRITERIA:\"Alert Criteria\",\n COMPERATOR:\"Comparator\",\n CRITARIA_DATA_SOURCE:\"Criteria Data Source\",\n STATIC_VALUE:\"Static Value\",\n START_DATE_SPECIFICATION:\"Start date specification\",\n INTERVAL_BACK:\"Intervals Back from end date\",\n REPORT_DATE:\"Report date\",\n START_DATE_INTERVALS:\"Start Date Intervals\",\n END_DATE_SPECIFICATION:\"End date specification\",\n END_DATE_INTERVALS:\"End Date Intervals\",\n SD_FORMULA_HELP: \"Use variables SD -> Standard Deviation, MEAN -> Mean, SUM -> Sum, IDV -> Indicator Value, PERCENTILE -> Percentile\",\n SOURCES:\"Sources\",\n MODIFIER:\"Modifier\",\n MODIFIER_HELP:\"The aggregate value will be multiplied by this value before comparison\",\n VALUE:\"Value\",\n FLOOR:\"Floor\",\n MONITORING_INTRODUCTION:\"Configure how, where and when this alarm generates alerts.\",\n DAYS:\"Day(s)\",\n WEEKS:\"Week(s)\",\n MONTHS:\"Month(s)\",\n YEARS:\"Year(s)\",\n COMOPARATOR_SOURCE:\"Comparator Source\",\n CRITARIA_VALUE:\"Criteria Value\",\n ERROR:\"Error\",\n CONFIRMATION:\"Confirmation\",\n AN_ERROR_OCCURED:\"An error occurred\",\n PENDIG_APPROVAL:\"Pending Approval\",\n USER_TYPE:\"User Type\",\n AUTO_DISCARDED:\"Auto-Discarded\",\n PENDING:\"Pending\",\n COMPLETED:\"Completed\",\n DIMENTION:\"Dimension\",\n ALERTS_TRIGGERED: \"Alerts triggered\",\n ALERTS_CLOSED_NON_AUTO: \"Closed alerts (not incl. auto-discarded\",\n ALERTS_AUTO_DISCARDED: \"Auto-discarded alerts\",\n ALERTS_DISCARDED: \"Alerts discarded\",\n ALERTS_MONITORED: \"Alerts monitor\",\n ALERTS_RESPOND: \"Alerts response\",\n ALERTS_IN_VERIFICATION: \"Alerts in verification\",\n ALERTS_AWAIT_VERIFICATION: \"Alerts awaiting verification\",\n NO_OF_HOURS : \"No. of hours\",\n VERIFIED_WHITHIN : \"Verified within\",\n INCLUDE : \"Include\",\n ALERTS_VERIFIED: \"Alerts verified\",\n ALERTS_RISK_ASSESS_WITHIN : \"Risk assessment within\",\n RISK_ASSESS_WITHIN : \"Risk assess within\",\n RISK_ASSESSED_WITHIN : \"Risk assessed within\",\n RISK_CHARD_WITHIN : \"Risk characterized within\",\n\n\n RISK_CHAR_WITHIN : \"Risk characterize within\",\n INC_REPORT_DATA: \"Include report data\",\n\n\n\n ALERTS_RISK_CHAR_WITHIN : \"Risk Characterization within\",\n ALERTS_OUTCOME_WITHIN : \"Outcome within\",\n ALERTS_DISCARDED_VERIFICATION: \"Alerts discarded at verification\",\n ALERTS_MONITORED_VERIFICATION: \"Alerts monitoring at verification\",\n ALERTS_IN_RISK_ASSESS: \"Alerts in risk assessment\",\n ALERTS_AWAIT_RISK_ASSESS: \"Alerts awaiting risk assessment\",\n ALERTS_RISK_ASSESSED: \"Alerts risk assessed\",\n ALERTS_IN_RISK_CHAR: \"Alerts in risk characterization\",\n ALERTS_AWAIT_RISK_CHAR: \"Alerts awaiting risk characterization\",\n ALERTS_RISK_CHAR: \"Alerts risk characterized\",\n ALERTS_IN_OUTCOME: \"Alerts in outcome\",\n ALERTS_AWAIT_OUTCOME: \"Alerts awaiting outcome\",\n ALERTS_OUTCOME: \"Alerts with outcome\",\n ALERTS_DISCARD_OUTCOME: \"Alerts discarded at outcome\",\n ALERTS_MONITORED_OUTCOME: \"Alerts monitoring at outcome\",\n ALERTS_RESPOND_OUTCOME: \"Alerts respond at outcome\",\n ALERTS_RISK_LOW: \"Alerts (low risk)\",\n ALERTS_RISK_MODERATE: \"Alerts (moderate risk)\",\n ALERTS_RISK_HIGH: \"Alerts (high risk)\",\n ALERTS_RISK_SEVERE: \"Alerts (very high risk)\",\n FORM:\"Form\",\n ELAPSED:\"Elapsed\",\n SYNCED:\"Synced\",\n UNSYNCED:\"UnSynced\",\n SMS:\"SMS\",\n TASK_TYPE:\"Task Type\",\n REGISTRATION:\"Registration\",\n AMENDMENT:\"Amendment\",\n DISCARD:\"Discard\",\n APPROVED:\"Approved\",\n REJECTED:\"Rejected\",\n COUNT:\"Count\",\n NONE:\"None\",\n ALARMS_DISABLED_FIELDS_NOTE:\"**Note: Data Source selected as SD/MEAN, you will not be able to edit Alert criteria\",\n FORMULA_NOTE:\"**Note: Variable names for Standard Deviation is SD, Mean is MEAN, Indicator Value is IDV and Percentile is PERCENTILE\",\n DATA_POINT_NOTE: \"To evaluate alarm there must be atleast 8 reports submitted for given interval related to selected Source Indicator\",\n WEEKS_BOUND_NOTE: \"Max Number of +/- weeks are allowed is 6\",\n PREVIOUS_YEAR_NOTE: \"Max Number of previous years are allowed is 10\",\n THRESHOLDS_NOTE:\"**Note: If you selected Indicator as Form Submissions and Dimension is Timeliness/Completeness the value will be between 0-100\",\n // EXPORT\n CHILDREN_OF_TYPE:\"Children of type\",\n SELECTED:\"Selected\",\n ANNUAL:\"Annual\",\n\n //ANALYSIS\n SERIES_CHART: \"Series Chart\",\n CATEGORY_CHART: \"Category Chart\",\n DATA_TABLE: \"Data Table\",\n PROVIDE_VALID_NOTEBOOK_TITLE: \"Please provide a title for your notebook\",\n NOTEBOOK_SAVED: \"Notebook saved\",\n SHARED: \"Shared\",\n GENERATING_EXCEL: \"Generating excel...\",\n GENERATING_PDF : \"Generating pdf...\",\n //PLOTS\n SERIES_STYLE: \"Series Style\",\n SERIES_COLOR: \"Series Color\",\n DATA_SET: \"Data Set\",\n CHART_TYPE: \"Chart Type\",\n TIME_SERIES: \"Time Series\",\n CATEGORYS: \"Category\",\n STACKED_BAR: 'Stacked Bar',\n TABULAR_REPORT: 'Tabular Report',\n AGGREGATE_DATA_INTERVAL_MESSEGE: \"The interval at which to aggregate the data in the series\", \n SERIES_START_DATE: \"The start date of the series\",\n SERIES_END_DATE: \"The end date of the series\",\n VALUES_FOR_INDICATORS_WILLBE_AGGREGATED: \"Values for indicators will be aggregated using the specified function\",\n NEW_CHART: \"New Chart\",\n\n\n //documents\n SHARE : \"Share\",\n LOADING_LOCATION : \"Loading locations...\",\n BACK : \"Back\",\n DOCUMENT_TITLE : \"Document Title\",\n DOCUMENT_DATE : \"Document Date\",\n PDF : \"Pdf\",\n \n // FORMS\n DELETE_FORM_BUTTON_TEXT:\"I understand the consequences, delete this form\",\n MOVE_UP:\"Move Up\",\n MOVE_DOWN:\"Move Down\",\n PINNED:\"Pinned\",\n EARLY_WARNING:\"Early Warning\",\n VALIDATING :\"Validating...\",\n NEW_FIELD : \"New Field\",\n ADD_FIELD : \"Add Field\",\n PREVIEW : \"Preview\",\n CLOSE_PREW :\"Close Preview\",\n ADD_ONE :\"Add one\",\n MAX_SIX :\"Maximum Six\",\n UNRECOGNIZED_FIELD : \"Unrecognized field\",\n ON_SUBMIT : \"On submit\",\n ON_UPDATE : \"On update\",\n ON_DELETE : \"On delete\",\n DATA_MAPPING :\"Data mapping\",\n TASK : \"Task\",\n STAKEHOLDERS :\"Stakeholders\",\n HOOKS : \"Hooks\",\n PRE : \"Pre\",\n POST : \"Post\",\n ADD_ACTION : \"Add action\",\n DELETE_STAGE : \"Delete stage\",\n EDIT_ACTION : \"Edit action\",\n COPY_ACTION : \"Copy action\",\n REMOVE_ACTION : \"Remove action\",\n ACTION_EDITOR : \"Action Editor\",\n TARGET : \"Target\",\n GENERATE_NEW_RECORD : \"Generate new record\",\n SEND_NOTIFICATIONs:\"Send notification(s)\",\n MODIFY_FORM : \"Modify form\",\n GENERATE_ALERT : \"Generate alert\",\n LOCK_TO_ROLE : \"Lock to role\",\n COMPLETE : \"Complete\",\n CREATE_DIMENSION : \"Create dimension\",\n CREATE_MEASURE : \"Create measure\",\n SAVE : \"Save\",\n JSON: \"JSON\",\n XML:\"XML\",\n YAML: \"YAML\",\n PROTOBUF: \"ProtoBuf\",\n BINARY: \"Binary\",\n TYPE : \"Type\",\n MODIFY_RECORD : \"Modify Record\",\n SHOW_ON_MOBILE :\"Show on mobile?\",\n MEDIA_TYPE : \"Media Type\",\n PHOTO_VIDEO : \"Image / Video\",\n MAX_MEDIA_FIELD_ALLOWED_IS : \"The maximum number of media fields allowed in form is\",\n SHOW_ROW_LABEL : \"Show row label\",\n IS_AGE_LABEL: \"Calculate Age\",\n SELECT_MONTH_DAY_LABEL: \"Display Age in\",\n ISO8601_WEEKLY : \"ISO8601 Weekly\",\n NUMBER_OF_DAYS_IN_INTERVAL :\"Number of days in interval\",\n BASE_DATE : \"Base Date\",\n OUTPUT_FORMAT : \"Output Format\",\n RULES_EDITOR : \"Rules editor\",\n SOURCE_FIELDS : \"Source field(s)\",\n TRANSLATIONS :\"Translations\",\n LANGUAGE_EDITOR : \"Language Editor\",\n CODE :\"Code\",\n ADD_TRANSLATION : \"Add Translation\",\n REMOVE : \"Remove\",\n CLEAR : \"CLEAR\",\n UPLOAD_CSV_FILE_ONLY_MESSEGE : \"Please upload CSV files only\",\n UPLOAD_CSV_OPTIONS : \"Upload CSV Options\",\n STORED_VALUE :\"Stored Value\",\n DISPLAY_VALUE :\"Display Value\",\n ALL_OF_FOLLOWING_ARE_TRUE : \"All of the following are true\",\n ANY_OF_FOLLLOWING_ARE_TRUE : \"Any of the following are true\",\n GREATER_THAN :\"Greater than\",\n GREATER_THAN_EQUAL_TO : \"Greater than / equal to\",\n LESS_THAN : \"Less than\",\n LESS_THAN_EQUAL_TO : \"Less than / equal to\",\n CONDITIONS_EDITOR : \"Conditions Editor\",\n DROP_DATA_SOURCE_TO_START : \"Drop data source to start\",\n OFFSET :\"Offset\",\n FROM : \"From\",\n TO : \"To\",\n QUICK_RANGES : \"Quick Ranges\",\n ADD_SOURCES : \"Add Source\",\n VARIABLE : \"Variable\",\n INDICATORS : \"Indicators\",\n FORM_FIELDS :\"Form Fields\",\n DATA_SET : \"Data Set\",\n SOURCE_FIELDS : \"Source Fields\",\n ADD_INDICATOR : \"Add Indicator\",\n NO_INDICATOR_SELECTED : \"No indicator selected\",\n CONTAINS : \"Contains\",\n DOES_NOT_CONTAIN : \"Does not contain\",\n NULL : \"Null\",\n GENERATE_CUSTOM_ID :\"Generate Custom Id\",\n DISPLAY_IN_MAIN_RECORD : \"Display in Main Record\",\n FILL_SUB_FORM:\"Fill sub form\",\n VIEW_SUB_RECORDS:\"View sub form records\",\n\n INTERVAL_BASED_REPORTING : \"Interval-Based Reporting\",\n INTRVL_BASED_REPORTNG_DESCRIPTION:\"Form is configure to be submitted on a routine basis\",\n REPORTING_INTERVAL : \"Reporting Interval\",\n BLOCK_DATE_IN_FUTURE : \"Block dates in the future\",\n LOCATION_BASED_REPORTING : \"Location-Based Reporting\",\n LOCATION_BASED_REPORTING_DESCRIPTION :\"Forms are submitted with a correlated location of a specific type\",\n OVERDUE_THRESHOLDS : \"Overdue Thresholds\",\n OVERDUE_THRESHOLDS_DESCRIPTION : \"Form can be configured to be overdue\",\n OVERDUE_INTERVAL_TYPE : \"Overdue Interval Type\",\n OVRDUE_THRESHOLD : \"Overdue Threshold\",\n GENERATE_UNIQUE_ID_LABEL:\"Generate unique sequence on form submissions.\",\n UNIQUE_ID_FIELD_NAME: \"Unique ID Field Name\",\n ENABLE_UNIQUE_ID_GENERATION:\"Enable Unique ID Generation.\",\n GENERATE_UNIQUE_ID_DESCRIPTION:\"Forms are submitted with a Unique Id\",\n PREFIX_LOCATION_TYPE:\"Prefix Location Type\",\n SERIAL_NUMBER_LENGTH:\"Serial number length\",\n FORM_PREFIX:\"Form Prefix\",\n AMMENDMENT_DESCRIPTION :\"Force users to have to submit amendments for approval\",\n REQ_APPROVAL : \"Require approval\",\n RETRACTIONS : \"Retractions\",\n RETRACTION_DESCRIPTION :\"Force users to have to submit deletions for approval\",\n ATTACHABLE_TO_ALERT : \"Attachable to Alerts\",\n ATTACHABL_TO_ALERT_DESCRIPTION : \"Allow this form to be configured to be used in alert investigations\",\n\n\n\n DRAG_FIELD_TO_START_MESSEGE :\"Drag a field here to start\",\n NO_FIELD_CONFIGURED_MESSEGE :\"There are currently no fields configured\",\n MAX_SIX_FIELD_CAN_CONFIGURED_MESSEGE :\"A row can only contain a maximum of six items\",\n DROP_FIELD_HERE :\"Drop field here\",\n SURE_WANT_DELETE_STAGE_MESSEGE :\"Are you sure you want to delete this stage?\",\n OF_FOLLOWING_ARE_TRUE : \"of the following are TRUE\",\n NO_ACTION_TYPE_SELECTED : \"No action type selected\",\n\n IS_EQ_TO : \"Is equal to\",\n IS_NEQ_TO : \"Is not equal to\",\n IS_GT : \"Is greater than\",\n IS_LT : \"Is less than\",\n IS_GT_OR_EQ_TO :\"Is greater-than or equal to\",\n IS_LT_OR_EQ_TO : \"Is less-than or equal to\",\n IS_EMPTY: \"Is empty\",\n IS_NOT_EMPTY: \"Is not empty\",\n BEGINS_WITH: \"Begins with\",\n ENDS_WITH: \"Ends with\",\n IS_BETWEEN: \"Is between\",\n IS_NOT_BETWEEN: \"Is not between\",\n IS_WITHIN: \"Is within\",\n IS_NOT_WITHIN: \"Is not within\",\n UNDER: \"Under\",\n AT_PLUS_UNDER: \"At + under\",\n Days : \"Day(s)\",\n Weeks : \"Week(s)\",\n Months : \"Month(s)\",\n Years : \"Year(s)\",\n\n FORM_NAME : \"Form Name\",\n FORM_NAME_HELP : \"Enter a descriptive name for the form\",\n FORM_TYPE : \"Form Type\",\n PRIMARY_COLLECTION : \"Primary Collection\",\n INVESTIGATIVE : \"Investigative\",\n FORM_TYPE_HELP :\"Type of context that this form will be used within, default is 'Primary Collection' for normal surveillance\",\n REPORTING_INTERVAL_HELP :\"Select the reporting period that this form should be submittable for, if None, a report can be submitted for any date\",\n ACCOUNT : \"Account\",\n LOCATION_AWARE : \"Location Aware\",\n LOCATION_AWARE_HELP : \"Turn this on if this form should be submitted for specific locations\",\n ALLOWED_LOCATION_TYPE : \"Allowed Location Type\",\n SINGLE_REPORT_RESTRICTION : \"Single Report Restriction\",\n SINGLE_REPORT_RESTRICTION_HELP : \"Disable this setting if you would like to allow multiple reports with the same report date / location selected\",\n OVERDUE_INTERVAL : \"Overdue Interval\",\n OVERDUE_INTERVAL_HELP :\"The interval at which the report will become overdue\",\n OVRDUE_THRESHOLD_HELP :\"The number of the Overdue Interval after which the report will become overdue\",\n BLOCK_FUTURE_DATES: \"Block Future Dates\",\n BLOCK_FUTURE_DATE_HELP :\"Do not allow reports to be submitted past the current date\",\n FORM_STATUS : \"Form Status\",\n ARCHIVED : \"Archived\",\n MULTIPLE_ALLOWED_1_REQUIRED : \"Multiple allowed; 1 required\",\n NOT_REQUIRED : \"Not required\",\n FORM_DESCRIPTION : \"Form Description\",\n FORM_DESCRIPTION_HELP :\"Enter a concise description of the form\",\n CONDITIONS : \"Conditions\",\n ADD_IN_TO_IND_VAL : \"Add 'in' to indicator value\",\n\n LAST_30_DAYS : \"Last 30 days\",\n LAST_60_DAYS :\"Last 60 days\",\n LAST_6_MONTHS : \"Last 6 months\",\n LAST_1_YEAR : \"Last 1 year\",\n LAST_2_YEAR : \"Last 2 years\",\n LAST_5_YEAR : \"Last 5 years\",\n YESTERDAY : \"Yesterday\",\n DAY_BEFORE_YESTRDY : \"Day before yesterday\",\n THIS_DAY_LAST_WEEK :\"This day last week\" ,\n PREVIOUS_WEEK :\"Previous week\",\n PREVIOUS_52_WEEKS :\"Previous 52 weeks\",\n PREVIOUS_MONTH :\"Previous month\",\n PREVIOUS_YEAR :\"Previous year\",\n TODAY :\"Today\",\n THIS_WEEK : \"This week\",\n THIS_MONTH : \"This month\",\n THIS_YEAR :\"This year\",\n CUR_YEAR_FIRST_WEEK : \"This year first week\",\n\n \n //MAP\n TARGET_LOCATION_TYPE: \"Target Location Type\",\n COMPLEX_DATA_SOURCE: \"Complex Data Source\",\n SITE_TYPE: \"Site Type\",\n MEDIAN_AVERAGE: \"Median/Average\",\n SOURCE_SPECIFICATION: \"Source Specification\",\n TARGET_INTERVAL: \"Target Interval\",\n INDICATOR_SOURCE_DATA: \"Indicator Source Data\",\n SPECIFIC_LOCATIONS: \"Specific Locations\",\n COUNTRY: \"Country\",\n TARGET_LOCATION_STATUS: \"Target Location Status\",\n DISPLAY_MODE: \"Display Mode\",\n MOVEMENT: \"Movement\",\n SCALE: \"Scale\",\n RED_BLUE: \"Red -> Blue\",\n BLUE_RED: \"Blue -> Red\",\n LAYER_OPACITY: \"Layer Opacity\",\n AVERAGE: \"Average\",\n STANDARD_DEVIATION: \"Standard Deviation\",\n QUARTILE: \"Quartile\",\n \n\n //imports\n PROCESSING_DATA :\"Processing data...\" ,\n DATA_LOADED : \"Data loaded\",\n DELETING : \"Deleting...\",\n IMPORTING : \"Importing...\",\n UPLOADING_FILE : \"Uploading file...\",\n PROJECT_NAME: \"Project name\",\n TARGET_IMPORT_TYPE: \"Target import type\",\n DATASET: \"Dataset\",\n TOTAL_ITEMS : \"Total Items\",\n ITEMS_IMPORTED :\"Items Imported\",\n RESULTS : \"Results\",\n TARGET_FORM_FIELD: \"Target form field\",\n SOURCE_DATE_FORMAT : \"Source Date Format\",\n MISSING_DATA_PLAN: \"Missing data plan\",\n CUSTOM_DATE_FORMAT : \"Custom date format\",\n SET_NULL : \"Set NULL\",\n SET_ZERO: \"Set Zero (0)\",\n IGNORE_ROW : \"Ignore Row\",\n LOCATION : \"Location\",\n LOADING_DEF : \"Loading definition\",\n SUBMITTED_DATE : \"Submitted Date\",\n FORM_ID : \"Form ID\",\n FORM_VEERSION_ID : \"Form Version ID\",\n LOCATION_COLUMN : \"Location Column\",\n LOCATION_MATCH_TYPE: \"Location Match Type\",\n OVERRIDE_LOCATION_MATCH_TYPE : \"Override location type match?\",\n LOCATION_TYPE_MATCH : \"Location type match\",\n REPORT_DATE_COLUMN : \"Report Date Column\",\n REPORT_DATE_FORMAT : \"Report Date Format\",\n SUBMITTED_DATE_COLUMN : \"Submitted Date Column\",\n SYSTEM_TODAY : \"System Today\",\n SYSTEM_REPORT_DATE : \"System Report Date\",\n SUBMITTED_DATE_FORMAT : \"Submitted Date Format\",\n ALLOW_FUTURE : \"Allow future?\",\n DELETE_PROJECT: \"Delete project\",\n REVOMED_ALREADY_IMPORTED_PROJECT_DATA : \"Remove already imported data?\",\n ACTION : \"Action\",\n REQUIRED_FIELD : \"Required field\",\n\n //mapping\n DEFAULT_CENTER: \"Default Center\",\n GROUP : \"Group\",\n SHOW_LEGEND : \"Show legend\",\n LEGEND_POS : \"Legend pos.\",\n STROKE_COLOR : \"Stroke color\",\n CROSS : \"Cross\",\n WYE : \"Wye\",\n INTERACTIVITY : \"Interactivity\",\n NO_FORM_SELCTED :\"No form selected\",\n FIELD : \"Field\",\n NO_FIELD_SELECTED : \"No field selected\",\n CREATE_NEW: \"Create New\",\n ERR_LOADING_FORM : \"error loading forms\",\n SETTING_CHANGED : \"Settings Changed!\",\n \n //map mapping common \n SAVING_MAP: \"Saving map...\",\n DELETING_MAP: \"Deleting map...\",\n MAP_DELETED: \"Map deleted\",\n DELETE_MAP: \"Delete Map?\",\n DELETE_MAP_CONFIRMATION_MESSEGE: \"Are you sure you want to delete this map?\",\n UPDATE_MAP: \"Update Map\",\n CREATE_MAP: \"Create Map\",\n MAP_BROWSER: \"Map Browser\",\n SAVED_MAPS: \"Saved Map(s)\",\n OPEN_CREATE_MAP_INSTRUCTION: '\"Open\" to view an existing map or click \"Create\" below to create your own.',\n \n //dashboard\n OVERDUE_RECORDS : \"Overdue records\",\n DRAFTS : \"DRAFTS\",\n REQUEST_ASSIGNMENT : \"Request Assignment\",\n PLOTS : \"Plots\",\n DOCUMENT_TEMPLATE : \"Document Templates\",\n ALERTS : \"Alerts\",\n\n //reporting\n UPCOMNG_REPORT_NOT_AVAILABLE_FOR_ROLE : \"Upcoming reports are not available for your role.\",\n OVRDUE_REPORT_NOT_AVAILABLE_FOR_ROLE : \"Overdue reports are not available for your role.\",\n CLAIM_REPORT: \"Claim Report\",\n CLAIM_REPORT_MESSAGE: \"Are you sure you want to claim this report. All associated data and responsibility for this report will be transferred to you.\",\n CLAIM_SUCCESS: \"This report now belongs to you\",\n DELETING_SUBMISSION: \"Deleting form submission...\",\n REPORT_DATE_HELP : \"Select the date that this report is for.\",\n REPORT_LOCATION_HELP :\"Select the location this report belongs to.\",\n REPORT_ASSGNMNT_HELP : \"Select the assignment you are submitting this report for\",\n DATE_OF_ADMISSION : \"Date of admission\",\n UNIQUE_ID:\"Unique Id\",\n MAIN_FORM_ID: \"Main Form Id\",\n VIEW_EDIT : \"View/Edit\",\n PRINT :\" Print\",\n RE_EVALUATE : \"Re-evaluate\",\n FROM_SERVER : \"From Server\",\n KEEP_GLOBAL_CHANGES : \"Keep global changes\",\n KEEP_LOCAL_CHANGES :\"Keep local changes\",\n RESOLVE_CONFLICT : \"Resolve Conflict\",\n CONFLICT_RESOLVED_SUCCESSFULLY :\"Conflict Resolved Successfully\",\n REPORT_TYPE: \"Report Type\",\n PROPOSED_CHANGES : \"Proposed Changes\",\n UNCATEGORIZED : \"Uncategorized\",\n GLOBAL :\"Global\",\n LOCAL : \"Local\",\n LOADING_USERS : \"Loading users\",\n NO_USER_AVBL : \"No users available\",\n LOADING_REPORTNG_PERIOD : \"Loading reporting periods\",\n NO_REPORTING_PERIOD_FOR_LOCATION : \"No reporting periods set for this location\",\n LOADING_ASSIGNMNETS : \"Loading assignments\",\n NO_ASSGNMNTS : \"No assignments\",\n LOCATION_NAME: \"Location name\",\n IMPORT_GEOJSON : \"Import Geojson\",\n UPLOAD_FILE : \"Upload File\",\n LOCATION_PCODE : \"Location pcode\",\n PARENT_LOCATION_PCODE : \"Parent location pcode\",\n GEOJSON_FILE_COLUMN : \"GeoJson file column\",\n PROVIDE_FIELD_MANDATORY: \"Please provide mandatory fields\",\n\n IMPORT_LOCATION_AS:\"Import location as\",\n ADDING_LOCATIONS : \"Adding Locations\",\n LOCATIONS_ADDED : \"Locations Added\",\n PCODE : \"PCode\",\n LOC_PATH : \"Location Path\",\n LOAD_LOCATION : \"Loading location...\",\n ASSIGNMENT_REQUEST_SUBMITTED : \"Assignment Request Submitted\",\n ASSIGNMENT_REQUEST_MESSEGE :\"Your assignment request has been submitted. An administrator will review your request and you will receive feedback soon.\",\n SELECT_ANOTHER_FORM_FOR_REQUEST : \"Select another form opposite to request another assignment.\",\n ASSIGNMENT_DETAILS :\"Assignment Details\",\n ASSIGNMENT_FORM_REQUIRE_ADMIN_APPROVAL : \"Assignments for this form require approval by an administrator before they can be used.\",\n ASSIGNMENT_LOCATION : \"Assignment Location\",\n SELECT_VALID_LOCATION: \"Please select a valid location\",\n SUBMITTING_ASSIGNMENT_REQUEST : \"Submitting assignment request...\",\n SELECT_FORM_TO_REQUEST_ASSIGNMENT : \"Select a form from the left to request an assignment\",\n NO_ITEMS_FOUND : \"No items found\",\n DETAILS : \"Details\",\n REPORTING_PERIOD : \"Reporting Periods\",\n STRUCTURE : \"Structure\",\n REPORTS_SUBMIITED : \"Reports Submitted\",\n REPORT_REPRSNTIVENSS : \"Reporting Representativeness\",\n ASSIGNMENT_ACTIVE : \"Assignments (Active)\",\n REGIONAL_ADMINS : \"Regional Admins\",\n ALERTSOPEN : \"Alerts (Open)\",\n ALERTSTRIGGRED : \"Alerts (Triggered)\",\n CHILD_LOCATION_ACTIVE : \"Child Locations (Active)\",\n CHILD_LOCATION_ARCHIVED : \"Child Locations (Archived)\",\n\n USER_WITH_THIS_ROLE_HAVE_NO_ASSGNMNT : \"Users with this role type do not have assignments.\",\n LOADING_ASSGNMNT :\"Loading assignments...\",\n LOADING_USER_DETAILS : \"Loading user details...\",\n SHOW_UNSYNCED_DATA : \"Show UnSynced Data\",\n FILL_SUBFORM_CLICK_ON_MAIN_RECORD_PLUS_ICON:\"To fill sub form click on the Main Record icon.\",\n SHOWING : \"Showing \",\n to : \" to \",\n of : \" of \",\n\n ASSIGNMENT_NOT_APPLICABLE_FOR_THIS_ROLE : \"Assignments are not applicable to your user type.\",\n REQUEST_NEW_ASSIGNMENT : \"Request new assignment\",\n\n //common\n REQUEST_TO_FOLLOWING_REPORT : \" has requested an amendment to the following report:\",\n ORIGINAL_VALUE : \"Original Value\",\n AMENDED_VALUE : \"Amended Value\",\n REJECTION_MESSEGE_FOR_AMMENDMENT_REQUEST : \"You are rejecting this amendment request, please provide a reason the request is being rejected and EWARS will notify the requestor.\",\n REJECTION_REASON :\"Rejection Reason\",\n PROCESSING : \"Processing...\",\n APPROVE : \"Approve\",\n REJECT : \"Reject\",\n REQUEST_DELETION_OF_REPORT : \" has requested deletion of the following report:\",\n VIEW_REPORT : \"View Report\",\n REJECTION_MESSEGE_FOR_DELETION_REQUEST : \"You are rejecting this deletion request, please provide a reason the request is being rejected and EWARS will notify the requestor.\",\n REPORT_DELETION_REQUEST : \"Report Deletion Request\",\n REQUEST_OF_ASSIGNMENT : \" has requested a new assignment:\",\n REJECTION_MESSEGE_FOR_ASSIGNMENT_REQUEST : \"You are rejecting this assignment request, please provide a reason the request is being rejected and EWARS will notify the requestor.\",\n LOCATION_FULL : \"Location (Full)\",\n ACCOUNT_REQUEST : \" has requested an account:\",\n USER_DETAILS : \"User Details\",\n NEW_ORGANIZATION_NAME : \"New organization name\",\n ACCESS_DETAILS : \"Access Details\",\n ROLE: \"Role\",\n REJECTION_MESSEGE_FOR_USER_REGISTRATION :\"You are rejecting this user registration, please provide a reason the request is being rejected and EWARS will notify the requestor.\",\n\n SPECIFY_VALID_ROLE : \"Please specify a valid role\",\n SPECIFY_VALID_STATUS :\"Please specify a valid status\",\n SPECIFY_LOCATION_FOR_GEOGRAPHIC_ADMIN : \"Please specify a location for this Geographic Administrator\",\n REGISTRATION_REQUEST :\"Registration Request\",\n\n ONLINE_FEATURE : \"Online feature\",\n CANNOT_CONNECT_WITHOUT_AN_INTERNET : \"Sorry: you can’t access this feature without an internet connection!\", \n CANNOT_CONNECT_WITHOUT_INTERNET :\"Sorry you can't access this feature without internet connection!! \",\n REQUESTING_NEW_COOKIE_ERROR : \"There was an error requesting new cookie.\",\n CURRENTLY_OFFLINE_PLEASE_CHECK_CONNECTION : \"You are currently offline, please check your internet connection before proceeding with any work.\",\n RECONNECTED : \"Reconnected\",\n YOUR_CONNECTION_HAS_RE_ESTABLISHED :\"Your internet connection has been re-established.\",\n SYNCING_ACCOUNT: \"Syncing account...\",\n USER_APPROVAL_PENDING: \"User Approval Pending\",\n INTERNAL_SERVER_ERROR: \"Internal server error\",\n SYNCED_SUCCESSFULLY: \"Synced Successfully!\",\n AUTHENTICATION_FAILED: \"Authentication Failed!!!\",\n WANT_TO_RECIEVE_DATA_FROM_USER : \"Do you want to receive data from user \",\n WILL_BE_SYNCED_BY :\" will be synced from user \",\n DO_YOU_WANT_TO_CONTINUE : \" , Do you want to continue?\",\n REGISTERED : \"Registered\",\n SYSTEM_USER : \"System User\",\n PHONE : \"Phone\",\n NUMERIC : \"Numeric\",\n STATIC : \"Static\",\n\n IS_REQUIRED_FILED : \" is a required field.\",\n SCHEDULED : \"Scheduled\",\n COMMENT: \"Comment\",\n ACTIVITY_COMMENTS: \"Comments\",\n ANNUALLY: \"Annually\",\n NONE_SELECTED: \"No selection\",\n OPTIONS_EDITOR: \"Options Editor\",\n CHOOSE_FILE: \"Choose File\",\n CHOOSE_FILE_TO : \"Choose a file to\",\n CHOOSE_CSV_FILE_TO : \"Choose a CSV file to\",\n DOWNLOAD_TEMPLATE_CSV: \"Download Template CSV\",\n IMPORTING_DATA: \"Importing data...\",\n DATA_IMPORTED: \"Data imported successfully.\",\n LINK_GOOGLE_SHEET : \"Link Google Sheet\",\n VIA_CSV : \"Via csv\",\n GOOGLE_SHEET : \"Google Sheet\",\n APPEND_ROWS: \"Append rows\",\n UPDATE_AND_APPEND_ROWS: \"Update and append rows\",\n IMPORT_FAILED: \"Failed to import\", \n DOWNLOAD_TEMPLATE_CSV_FROM_HERE : \"You can download the template from here\",\n NO_FILE_CHOSEN: 'No File Chosen',\n YEARLY : \"Yearly\",\n SHAREABLE:\"Shareable\",\n PDF_PAGE_ORIENTATION : \"PDF Page Orientation\",\n NO_DATA_AVAILABLE: \"No data available\",\n //field helps\n LOCATION_INFORMATION: \"The location to source the indicator data at\",\n EXPORT_HELP: \"Show export button for exporting images, pdf, etc...\",\n ZOOM_HELP: \"Allow zooming into the chart by click dragging\",\n NAVIGATOR_HELP: \"Show the timeline navigator below the chart\",\n SERIES_TITLE_HELP: \"The series title displayed in the chart, if left blank, indicator name will be used\",\n LABEL_HELP: \"Labels are scaled based on the overall map scale, use em scaling to rescale labels\",\n THRESHOLD_HELP: \"Threshold above which labels will be displayed\",\n CSS_CLASSNAME_HELP: \"Specify a CSS class name to set on the main element in order to apply custom styling\",\n PREFIX_TEXT_HELP: \"Text shown to the left of the value\",\n SUFFIX_TEXT_HELP: \"Text shown after the value in\",\n FONT_SIZE_HELP: \"Size is in pixels (px), default 30px\",\n LOCATION_GORUP_HELP: \"Aggregate: A single line is produced aggregating the locations data together, Individual: Individual lines are produced for each location in the group\",\n INDICATOR_HELP: \"The data to use\",\n CHART_TYPE_HELP: \"The type of series chart to display\",\n SERIES_COLOR_HELP: \"The colour to use for the series, if unset, will default to indicator defined colour or random\",\n START_DATE_SPECIFICATION: \"Start Date Specification\",\n END_DATE_SPECIFICATION: \"End Date Specification\",\n INVERVAL_END_DATE: \"Intervals to Subtract from End Date\",\n INVERVAL_REPORT_DATE: \"Intervals to Subtract from Report Date\",\n INVERVAL_END_DATE_HELP: \"The amount of the chart interval back that will be subtracted from the Start Date\",\n SERIES_TYPE: \"Series Type\",\n SERIES_TITLE: \"Series Title\",\n SERIES_COLOR: \"Series Colour\",\n SERIES_MODIFIER_HELP: \"A value to multiply each value in the series by, no modifier will be use if left blank\",\n NEW_COLUMN: \"New Column\",\n WIDGET_ID: \"Widget Id\",\n DATA_FORM: \"Data Form\",\n SOURCE_FORM:\"Source Form\",\n SELECT_FORM:\"Select Form\",\n DATA_AGGREGATION: \"Data Aggregation\",\n GROUP_BY: \"Group By\",\n ALL:\"All\",\n FETCH: \"Fetch\",\n SPECIFIC_FORM:\"Specific Form\",\n TIME_INTERVAL:\"Time Interval\",\n NO_GROUPING:\"No Grouping\",\n ALERT_DATA: \"Alert Data\",\n WIDGET_TYPE:\"Widget Type\",\n ADD_WIDGET:\"Add Widget\",\n ENH_TABLE : \"Enh Table\",\n PF_IND:\"Performance Indicators\",\n REPORTING_LOCATION: \"Reporting Location\",\n SOURCE_ALARM: \"Source Alarm\",\n SELECTED_ALARM: \"Selected Alarms\",\n USE_TOTAL_FORMULA:\"Use Total Formula\",\n USE_FORMULA_TOTAL:\"Use formula for total\",\n SELECT_ALARMS: \"Select Alarms\",\n ALERT_DATA_COLUMN: \"Alert Data Column\",\n ALARM_NAME: \"Alarm Name\",\n ALERT_STATE: \"Alert State\",\n ALERT_OUTCOME: \"Alert Outcome\",\n LIKELY_EVENT:\"Likely event\",\n VALUE_MAPPING_EXCLUDE:\"Value Mapping & Exclude Values\",\n VALUE_ALIASING_EXCLUDING:\"Group by column value aliasing and excluding it\",\n VALUE_ALIASING: \"Value Aliasing\",\n PROVIDE_VALID_CONFIG : \"Please provide valid configuration\",\n NO_DATA_FETCH: \"No data to fetch\",\n TOTAL_FORMULA_NOTE:\"Enter arithmetic expression using arithmetic operators '+,-,*,/,(,)' and following variables \",\n REMOVE_ALL : \"Remove All\",\n SHOW_TOTALS: \"Show totals\",\n GROUP_BY_COLUMN_TITLE:\"Group by column title\",\n COLUMN_TITLE: \"Column Title\",\n VALUE_MAPPER : \"Value Mapper\",\n SHOW_TOTAL: \"Show Total\",\n TITLE_HELP:\"Any Special characters are not allowed.Use '_' instade of space in between words .\",\n SERIES_DESCRIPTION:\"Short description about the series\",\n EXCLUDE: \"Exclude\",\n LOCATION_TYPE: \"Location Type\",\n LOCATIONS: \"Locations\",\n LOCATION_GROUPS: \"Location Group\",\n DISPLAY_BY : \"Display by\",\n INDICATOR: \"Indicator\",\n FORM_FIELD: \"Form Field\",\n DATA_LOCATION:\"Data Location\",\n SELECT_LOCATIONS: \"Select Locations\",\n DATA_PERIOD: \"Data Period\",\n SORTING_FILTERING: \"Sorting & Filtering\",\n TABLE_CSS_CLASS: \"Table CSS Class\",\n DATA_SOURCE_FORMS: \"Data Source Forms\",\n INPUT_NOT_ALLOWED_IN_WEB : \"Input not allowed in the web.\",\n UNSUPPORTED_MEDIA :\"Unsupported Media\",\n\n //HEADER\n DAYS_LEFT: \" days left to sync\",\n ONLINE: \"Online\",\n OFFLINE: \"Offline\",\n LOADER_MSG2: \"Thank you for using EWARS. We appreciate it!\",\n LOADER_MSG3: \"- Your friends at EWARS\",\n SHORTCUTS: \"Shortcuts : \",\n HARD_REFRESH: \"Hard Refresh\",\n REFRESH: \"Refresh\",\n GO_BACK: \"Go Back\",\n OPEN_DEVTOOLS: \"Open DevTools\",\n ALL_RIGHTS_RESERVED: \"All Rights Reserved.\",\n //validators\n ENTER_VALID_NUMBER : \"Please enter a valid number.\",\n DECIMAL_NUMBER_NOT_ALLOWED_ENTER_WHOLE_NUMBER : \"Decimal numbers are not allowed, please only provide whole numbers.\",\n MAX_VALUE_ALLOWED_IS : \"Maximum allowed value is \",\n MIN_VALUE_ALLOWED_IS : \"Mininum allowed value is \",\n NEGATIVE_NUMBER_NOT_ALLOWED_ENTER_POSITIVE_NUMBER : \"Negative values are not allowed, please use only positive numbers\",\n MUST_SPECIFY_ATLEAST_ONE_VALUE_IN_ONE_LANGUAGE : \"You must specify at least one value in at least one language\",\n USER_EXISTS_AT_ROOT: \"The email specified is already exists in the system.\",\n\n LOCATION_DETECTION: \"Location Detection\",\n LOCATION_DETECTION_QUESTION: \"Would you like EWARS to try and use your current location?\",\n CURRENT_LOCATION: \"Current Location\",\n MAP_LOCATION: \"Map Location\",\n FILTER_BY_CONDITION: \"Filter by condition:\",\n FILTER_BY_VALUE: \"Filter by value:\",\n REMOVE_FILTER: \"Remove filter\",\n INVALID_FILE_TYPE:\"Invalid file selected!\",\n NOTALLOWED_FILE_TYPE:\"This File Type is not allowed!\",\n INVALID_FILE_NAME:\"# in the File Name is not allowed! \",\n\n COLLAPSE : \"Collapse\",\n SEARCH : \"Search\",\n CLEAR_SEARCH : \"Clear search\",\n USERVIEW : \"Userview\",\n APPLY_FILTER : \"Apply filter\",\n SORT : \"Sort\",\n SELECT_DATE : \"Select date\",\n CLEAR_DATE : \"Clear date\",\n ADD_THRESHOLD : \"Add threshold\",\n GENERATE_PDF : \"Generate pdf\",\n DOWNLOAD : \"Download\",\n DOWNLOAD_CSV : \"Download as CSV\",\n \n REDIRECT: \"Redirect\",\n EXTERNAL_LINK : \"External link\",\n BROWSE : \"Browse\",\n ADD_THRESHHOLD : \"Add threshold\",\n REMOVE_THRESHHOLD : \"Remove threshold\",\n CHANGE_FILTER : \"Change Filter\",\n FILTER_DUPLICATE_RECORDS : \"Filter Duplicate Records\",\n CLEAR_FILTER : \"Clear Filter\",\n\n FAST_BACKWARD : \"Fast backward\",\n STEP_BACKWARD : \"Step backward\",\n STEP_FORWARD : \"Step forward\",\n FAST_FORWARD : \"Fast forward\",\n SYNC: \"Sync\",\n OK:\"Ok\",\n\n REPORT_MANAGER : \"Report manager\",\n ALERT_LOGS: \"Alert logs\",\n LOGOUT : \"logout\",\n USER_PROFILE : \"User profile\",\n WIFI : \"Wifi\",\n THIRD_PARTY_CLIENT : \"Third party client\",\n COPY_CLIENT_DETAILS : \"Copy Client Details\",\n NETWORK_STATUS : \"Network status\",\n CREATE_NEW_RECORD : \"Create new record\",\n EXPAND : \"expand\",\n OR_BASED_SYNC : \"QR based sync\",\n\n ADD_SECTION: \"Add section\",\n EDIT_SECTION : \"Edit section\",\n MOVE : \"Move\",\n RESEND_INVITE : \"Resend invite\",\n DELETE_INVITE: \"Delete invite\",\n PRINT_FORM : \"Print form\",\n EXPORT_FORM : \"Export form\",\n NOTEBOOKS: \"Notebooks\",\n MAPS: \"Maps\",\n KEY: \"Key\",\n\n RECEIVE_DATA: \"Receive Data\",\n DOC : \"Doc\",\n GROUP_BY: \"Group By\",\n ERROR_IN_PDF_DOWNLOADING : \"Some error in downloading pdf.Please try again !\",\n ERROR_DOWNLOAING_DOCUMENT : \"Some error in downloading doc, please try again later!\",\n FIELD_EXPORT_LABEL: \"Export label\",\n CONCATENATE:\"Concate\",\n SUBTRACT:\"Subtract\",\n OPERATOR_TYPE:\"Operator type\",\n SEPARATOR:\"Separator\",\n TABLE_VIEW:\"Table View\",\n CUMULATIVE:\"Cumulative\",\n CUMULATIVE_DESCRIPTION:\"If true then it will show cumulative value of data in the series\",\n NO_AUTH: \"Incorrect Email/Password\",\n USER_DELETED: \"Incorrect Email/Password\",\n EMAIL_PENDING_VERIFICATION: \"Account is pending email verification, please check your inbox.\",\n USER_EXISTS_NO_ACCESS_ACCOUNTS: \"You do not have access to any accounts at this time.\",\n USER_EXISTS_NO_ACCESS_ACCOUNT: \"You do not have access to this account at this time.\",\n NO_ACCOUNT: \"You do not have access to any accounts at this time\",\n USER_ACCESS_REVOKED: \"Your access to the account was revoked\",\n USER_PENDING_APPROVAL: \"You account access is currently pending approval\",\n USER_NO_ACCESS_ACCOUNTS: \"You currently do not have access to any accounts\",\n SELECT_LANGUAGE: \"Select any language first!\",\n ADDING_LANGUAGE: \"Adding new language... please wait...\",\n LANGUAGE_ALREADY_EXISTS: \"Selected language Already exists!\",\n LANGUAGE_ADDED: \"Added language Successfully.\",\n FETCHING_TRANSLATION: \"Fetching Translation...\",\n AUTO_TRANSLATE_T: \"Auto Translate\",\n AUTO_TRANSLATE_Q: \"It will only translate and replace empty values of language json. Do you want to continue?\",\n TRANSLATING_LABELS: \"Translating labels...Please wait as this may take a few minutes...\",\n LANGUAGE_TRANSLATED: \"Language translated successfully.\",\n LANGUAGE_TRANSLATION_FAILED: \"Language translation failed!\",\n LANGUAGES: \"Languages\",\n ADD_LANGUAGE: \"Add Language\",\n EDIT_TRANSLATION: \"Edit Translation\",\n AUTO_TRANSLATE: \"Auto Translate\",\n ENGLISH: \"English\",\n MODULE: \"Module\",\n\n //team\n TEAM_MEMBERS:\"Team Members\",\n MEMBERS_COUNT: \"Members\",\n SELECT_MEMBER: \"Select Member\",\n IS_ALREADY_IN_TEAM :\"is already in team\",\n TEAM_EDITOR:\"Team editor\",\n TEAM_SETTINGS:\"General Team Details\",\n TEAM_SETTING_INTRODUCTION:\"Define your team\",\n TEAM_MEMBER_SETTINGS :\"Team Members\",\n TEAM_MEMBER_SETTING_INTRODUCTION :\"Define your Team Member\",\n SELECT_USER_AND_MAKE_TEAM :\"Select user from here to create a team\",\n TEAM_UPDATED:\"Team Updated\",\n TEAM_CREATING:\"Team Creating\",\n TEAM_CREATED:\"Team Created\",\n DELETE_TEAM : \"Delete Team\",\n DELETE_TEAM_MESSEGE:\"Are you sure youn want to delete team?\",\n DELETING_TEAM:\"Team Deleting\",\n TEAM_DELETED:\"Team Deleted\",\n SMS_PHONE_NUMBER : \"SMS Phone Number\",\n TWELVE_DIGIT_NUMBER:\"Enter 12 Digit SMS Phone Number\",\n PHONE_NUMBER_WITH_COUNTRY_CODE : \"Enter Phone number with Country code (+1232323232)\",\n\n\n //lock\n PASSWORD: \"Password\",\n AUTHENTICATE: \"Authenticate\",\n EWARS_LOCKED: \"Ewars Locked\",\n LOGIN_AGAIN: \"Login Again\",\n CHANGE_STATUS: \"Change Status\",\n DUPLICATE_LANGUAGE: \"Duplicate Language\",\n DUPLICATE_LANGUAGE_CONF: \"Do you still want to add it for your account?\",\n\n CHANGE_LANG_STATUS: \"Are you sure you want to mark this language as \",\n SET_AS_DEFAULT: \"Set as default\",\n LANGUAGE_EXISTS: \"This language already exists\",\n SET_DEFAULT_LANGUAGE_ERROR: \"You can not set inactive language as default\",\n CHANGE_DEFAULT_LANGUAGE_T : \"Set default language\",\n // CHANGE_DEFAULT_LANGUAGE_Q : \"Do you want to change default language for all user?\",\n CHANGE_DEFAULT_LANGUAGE_QUES : \"Do you want to change default language as \",\n UPDATE_ALL_USER : \"All Users\",\n OLNY_ACCOUNT : \"Current User\",\n UPDATED_DEFAULT_LANGUAGE:\"Successfully updated default language\",\n NOT_SET_DEFAULT_LANGUAGE: \"Failed to update default language\",\n NOT_SET_DEFAULT_LANGUAGE_AS_INACTIVE: \"You can't change default language status as inactive\",\n MY_IP_ADDRESSES:\"My IP Addresses\",\n IP: \"IP Addresses\",\n GROUP_BY_INDICATORS: \"Group By Indicators\",\n PYRAMID_CHART: \"Pyramid Chart\",\n AUTHENTICATING: \"Authenticating...\",\n REQUEST_TIMEOUT: \"Request timeout\",\n MAIN_FORM_FIELD: \"Parent form field\",\n IS_EDITABLE: \"Is Editable\",\n SHOW_SEARCH_BOX:\"Show search box?\",\n AUTO_TRANSLATE_TEXT: \"Auto Translate\",\n AUTO_TRANSLATE_QUESTION : \"It will only translate the labels that are checked and replace empty values of labels. Do you want to continue?\",\n LABELS : \"Labels\",\n ENGLISH_TRANSLATION : \"English Translation\",\n PLEASE_COMPLETE_ENGLISH_RANSLATION : \"Please complete all the english translations for the labels!\",\n NO_LABELS_TO_TRANSLATE : \"No labels to translate!\",\n\n ONLINE_FEATURE_CANT_ACCESS_OFFLINE : \"You won't able to access this feature as you're offline. Please go to online and try again!\",\n COMPARE_YEARS: \"Compare Years\",\n SELECT_YEARS_TO_COMPARE: \"Select years to compare\",\n TAG: \"Tag\",\n ADD_TAG: \"Add Tag\",\n\n TAGS_ALREADY_TRANSLATED :\"Tags Already Translated...\",\n NO_TAGS_TO_TRANSLATE : \"No Tags to Translate.\",\n TRANSLATING_TAGS: \"Translating Tags...Please wait as this may take a few minutes...\",\n TAGS_TRANSLATED : \"Tags Translated\",\n TAGS_TRANSLATION_FAILED : \"Tags Translation Failed\",\n DELETE_TAG:\"Delete Tag\",\n EDIT_TAG : \"Edit Tag\",\n AUTO_TRANSLATE_ALL_TAGS:\"Auto Translate all Tags\",\n NOTE_TAG_WILL_BE_ADDED_IN_ENG : \"*Note: The tags will be added in english by default... You can edit and translate the tags in multiple languages.*\",\n \n CONFIGURED_EVENT : \"Configured Event\",\n EVENT_CONFIG_DESCRIPTION : \"Configure when and what to execute on trigger of an event\",\n\n COPY_LINK:\"Copy Link\",\n REPORT_URL_COPIED:\"Report URL Copied!\",\n CANNOT_ACCESS_MAP_URL: \"you cannot copy link of a private map! You need to change the access to public\",\n URL_COPIED : \"URL copied..\",\n CANNOT_ACCESS_PRIVATE_NOTEBOOK : \"You cannot access link of a private notebook! You need to change the access to public.\",\n\n //site builder\n IN_PX : \" (in px)\",\n LETTER_SPACING : 'Letter Spacing',\n LINE_HEIGHT : \"Line Height\",\n TEXT_STYLE : \"Text Style\",\n MARGIN : \"Margin\",\n OPACITY : \"Opacity\",\n BOX_SHADOW: \"Box Shadow\",\n EDITOR : 'Editor',\n PAGE_NAME : \"Page Name\",\n DELETE_PAGE : \"Delete Page\",\n WEBSITE_NAME : \"Website Name\",\n MENU : \"Menu\",\n EMPTY : \"Empty\",\n TEXT_FONT_SIZE : \"Text Font Size\",\n TEXT_COLOUR : \"Text Colour\", \n VIDEO_URL : \"Video Url\",\n FRAME_WIDTH : \"Frame Width\",\n FRAME_HEIGHT : \"Frame Height\",\n CAROUSEL : \"Carousel\",\n CELL_SETTINGS: \"Cell Settings\",\n IMAGE_DESCRIPTION: \"Image Description\",\n LINK_ACTION: \"Link Action\",\n DUPLICATE_SITE: \"Duplicate Site\",\n DUPLICATE_SITE_CONFIG: \"Are you sure you want to duplicate site -\",\n DUPLICATING_SITE: \"Duplicating website config...\",\n // IMAGE_CONTENT : \"Image Content\",\n IMAGE_TEXT : \"Image Text\",\n CAROUSEL_SHOULD_ATLEAST_HAVE_TWO_IMG : \"Cannot Delete. Carousel must have atleast 2 images..\",\n CAROUSEL_EDITOR : \"Carousel Editor\",\n ALLOW_AUTOPLAY : \"Allow Autoplay\",\n ENTER_INTERVAL_IN_SEC : \"Enter interval in seconds\",\n IMAGES :\"Images\",\n ADD_IMAGES : \"Add Images\",\n INVALID_FILTER_MESSAGE : \"Please select valid filter\",\n AVERAGE_MEDIAN:\"Average/Median\",\n SUBSCRIBE : \"Subscribe\" ,\n LATEST_DOCUMENT_LINK:\"Copy latest report link\",\n REPORT_LINK_PRIVATE_MSG:\"You report access is private , to access this report via copied link set Access to Pubilc\",\n BOLD: \"Bold\",\n ITALIC: \"Italic\",\n UNDERLINE: \"Underline\",\n DOCUMENT_LIST : \"Documents List\",\n SUBSCRIBE_DOCUMENT : \"Subscribe Document\",\n SITE_SETTING : \"Site Settings\",\n PUBLISHED : \"Published\",\n UNPUBLISHED : \"Unpublished\",\n WEBSITE :\"Website\",\n CSS_SETTINGS : \"Css Setting\",\n CELL_CLASS : \"Cell Class\",\n CELL_CONTENT_DESCRIPTION : \"Cell Content Description\",\n STYLE_EDITOR_HELP:\"Style Editor Help\",\n STYLR_EDITOR_DESCRIPTION :\"Information about how to add styling.\",\n CSS_EDITOR: \"CSS Editor\",\n GLOBAL_ADMIN : \"Global Administrator\",\n MENU_CONFIG: \"Menu\",\n MENU_CONFIG_SETTING_INFORMATION: \"Configure menu based on role and user\",\n ROLE_EXISTS :\"Role already assigned to selected menu\",\n USER_EXISTS :\"User have already assigned to selected menu\",\n ACCOUNT_SECURITY: \"Account Security\",\n canEdit : \"Can Edit\",\n canAdd : \"Can Add\",\n canDelete : \"Can Delete\",\n canView : \"Can View\",\n DELETE_ACCESS: \"Delete Access\",\n DELETE_ACCESS_QUESTION: \"Are you sure you want to delete this access\",\n LIST_OF_MENU: \"List of Menu\",\n ACCESS_RIGHTS : \"Access Rights\",\n\n //Web_Content\n UPLOAD: \"Upload\",\n USER_LOCATION: \"User's Location\",\n DELETE_FILE : \"Delete Uploaded File\",\n CANNOT_ADD_MORE_CSS_FILE : \"Cannot add more files.You already added 5 CSS files.!\",\n CANNOT_ADD_MORE_JS_FILE:\"Cannot add more files.You already added 5 JS files.!\",\n SITE_EDITOR: \"Site Editor\",\n UPLOAD_CSS_OR_JS :\"Upload CSS or JS file\",\n CSS_LINK : \"CSS File Links:\",\n JS_LINKS : \"JS File Links:\",\n FILE_UPLOADED_SUCCESSFULLY:\"File Uploaded Successfully\",\n FILE_DELETED_SUCCESSFULLY:\"File Deleted Successfully\",\n\n OFFSET_HELP: \"Offset Help\",\n OFFSET_DESCRIPTION: \"e.g. :\\n -1Y : Before one year \\n -1M : Before one month \\n -1D : Before one day \\n Similarly for After...\",\n QUICK_RANGE_HELP: \"Quick Range Help\",\n QUICK_RANGE_DESCRIPTION: \"'Last' keyword is used to refer to the immediately preceding period from today itself & 'Previous' keyword is used for previous calendar event\",\n MONITORED_DATA_HELP:\"Monitored Data Help\",\n MONITORED_DATA_DESCRIPTION: \"Monitored Data Description\",\n ALERT_MAP_SETTING : \"Alert Maps Setting\",\n DUPLICATE_ORGANIZATION_FOUND_MESSEGE : \"We found an existing organization within EWARS with this name! Create with another name of organization instead.\",\n SELECT_VALID_VALUE : \"Select valid value\",\n EVENT : \"Event\",\n DISPLAY_NAME : \"Display Name\",\n ALERT_LOG_SETTING : \"Alerts Log Setting\",\n EVENTS : \"Events\",\n EVENTS_D : \"Events(Diseases)\",\n LIKELY_EVENTS_D : \"Likely Events(Diseases)\",\n LIKELY_EVENT:\"Likely Event\",\n SHOW_LIKELY_EVENTS_IN_RISK_ASSESS : \"Show Likely Event in Risk Assessment\",\n ADD_STYLE_IN_ROW_WIDGET :\"Adds styles to the rows in website.\",\n ADD_STYLE_TO_CELL_WIDGET : \"Adds styles to the cells containing the widgets in website.\",\n ADD_STYLE_TO_IMG_WIDGET : \"Adds styles to the image widget in website.\",\n ADD_STYLE_TO_MENU_BAR : \"Adds styles to the menu bar in website.\",\n ADD_STYLE_TO_TEXT_WEIDGET : \"Adds styles to the text widget in website.\", \n ADD_STYLE_TO_PAGE : \"Adds style to the pages in website\",\n ENTER_DOMAIN_PLACEHOLDER : \"Enter Domain\",\n PAGE_CLASS : \"Page Class\",\n PAGE_CLASS_PLACEHOLDER : \"Add Class for Page\",\n PAGE_CLASS_NOTE : \"*Note:You can add multiple class name after a comma ( , ) . Eg: class_1,class_2*\",\n APPLY : \"Apply\",\n EXPORT_AS_PDF_LABEL : \"Export as PDF\",\n EXPORT_AS_PDF : \"Export as Pdf\",\n EXPORT_AS_EXCEL : \"Export as Excel\",\n ENHANCED_TABLE:\"Enh Table\",\n ENHANCED_CHART:\"Enhanced Chart\",\n ENHANCED__TABLE:\"Enhanced Table\",\n ENHANCED__MAP:\"Enhanced Map\",\n EXPORT_PDF:\"PDF\",\n PUSH_DATA : \"Push Data\",\n AUTHENTICATE: \"Authenticate\",\n EWARS_FORM : \"EWARS Form\",\n DHIS2_DATASET : \"DHIS2 Dataset\",\n SERVER_URL : \"Server URL\",\n AUTO_PUSH : \"Auto Push\",\n README_DOWNLOAD_DESC : \"All the information is given in Readme. You can download the Readme file\",\n\n //Integration\n ORG_UNIT_ERR : \"Org unit error\",\n INVALID_DATA : \"Invalid data\",\n INVALID : \"Invalid\",\n ORG_NOT_ASSIGNED : \"Org unit is not assigned to Program\",\n SEARCH_FOR_FIELDS:\"Search for fields\",\n NO_VALUE_AVAILABLE:\"No Value Available\",\n RETRACTED_SUCCESS : \"Retracted successfully\",\n RETRACT : \"Retract\",\n REPORTING_AND_FORMS:\"Reporting & Forms\",\n FORM_AND_REPORTING_SETTING:\"Reporting & Forms setting\",\n SHOW_FORM_SEARCH_IN_REPORTING:\"Show Form search bar\",\n SEARCH_WILL_SHOW_IN_WEB_MOBILE:\"Show search bar in Reporting for web & mobile?\",\n SHOW_SYNC_OPTIONS_IN_MOBILE:\"Show Sync options in Mobile?\",\n SHOW_SYNC_OPTIONS_IN_MOBILE_DESC:\"This will show Sync options in EWARS mobile application.(Mobile to EWARS web,Mobile to Desktop app,Mobile to Mobile)\",\n SHOW_ALERT_FEATURE_IN_MOBILE:\"Show Alert feature in Mobile?\",\n SHOW_ALERT_FEATURE_IN_MOBILE_DESC:\"This will show Alert feature in EWARS mobile application.\",\n ALERT_NOTIFICATION_ENABLED:\"Enable Alert Notifications\",\n ALERT_NOTIFICATION_ENABLED_DESC:\"Email / Notification will be sent to all the stakeholders related to that specific alert.\",\n\n PUSH_NOTIFICATION: \"Push Notification\",\n SUBJECT: \"Subject\",\n MESSAGE: \"Message\",\n\n CALCULATE_AGE_FROM: \"Calculate age from\",\n\n YOUR_EMAIL: \"Your Email\",\n YOUR_NAME: \"Your Name\",\n CONFIRM_EMAIL: \"Confirm Email\",\n CONFIRM_PASSWORD: \"Confirm Password\",\n COMPLETE_REGISTRATION: \"Complete Registration\",\n PROVIDE_DETAIL: \"Please provide us with the details below to complete your registration.\",\n EWARS_INVITATION: \"EWARS Invitation\",\n ADDTIONAL_INFO: \"If you've received an invite from us by mistake, or you're unsure of whether you need this account, just close this page, we will not send you any other emails. For additional information please contact \",\n INVITE_HEADER_LABEL_1: \"You've been invited to join the\",\n INVITE_HEADER_LABEL_2: \"account as a\",\n INVITE_HEADER_LABEL_3: \"please complete registration below to start using EWARS.\",\n INVITE_MAIL_LABEL_1: \"You've been invited to join the\",\n INVITE_MAIL_LABEL_2: \"EWARS account\",\n INVITE_MAIL_LABEL_3: \"Click here\",\n INVITE_MAIL_LABEL_4: \"to join the account.\",\n INVITE_SUBJECT: \"[EWARS] You\\'ve been invited to EWARS\",\n DO_NOT_REPLY_LABEL: \"You are receiving this email because you previously signed up for EWARS or because another EWARS user has shared this message with you. Please do not reply to this email.\",\n LEARN_MORE: \"Learn more about EWARS\",\n WELCOME: \"Welcome to EWARS\",\n LOGIN_LINK: \"Welcome to EWARS, you can now log in to your account at\",\n ACCEPT_INVITATION: \"You can accept the invitation by clicking \\\"Complete registration\\\" below.\",\n SENT_ON: \"Sent on\"\n\n};\nmodule.exports = EN;","var Combi = function Combi() {\n var _this = this;\n\n // (0, _classCallCheck3.default)(this, Combi);\n\n this.register = function (name, reduction, initialState, persisted=true) {\n // Register a subStore into the store\n if (_this.subStores[name]) return;\n\n _this.subStores[name] = {\n s: ewars.copy(initialState || {}),\n r: reduction\n };\n\n \n if (persisted && _this.delayed[name]) {\n _this.delayed[name].forEach(function (item) {\n var reducer = _this.subStores[name].r;\n var state = _this.subStores[name].s;\n\n _this.subStores[name].s = reducer(state, item[0], item[1]);\n initialState = _this.subStores[name].s;\n });\n _this.signal(name, 'PRELOAD');\n }\n\n return initialState;\n };\n\n this.deregister = function (name) {\n // Remove a subStore from the store\n delete _this.subStores[name];\n };\n\n this.force = function (name, data) {\n _this.subStores[name].s = data;\n return _this.subStores[name].s;\n };\n\n this.dispatch = function (name, action, data) {\n if (_this.subStores[name]) {\n var reducer = _this.subStores[name].r;\n var state = _this.subStores[name].s;\n\n _this.subStores[name].s = reducer(state, action, data);\n _this.signal(name, action);\n } else {\n if (_this.delayed[name]) {\n _this.delayed[name].push([action, data]);\n } else {\n _this.delayed[name] = [[action, data]];\n }\n }\n };\n\n this.subscribe = function (name, method) {\n if (_this.subscribers[name]) {\n _this.subscribers[name].push(method);\n } else {\n _this.subscribers[name] = [method];\n }\n };\n\n this.unsubscribe = function (name, method) {\n var index = _this.subscribers[name].indexOf(method);\n\n if (index >= 0) {\n _this.subscribers[name].splice(index, 1);\n }\n };\n\n this.exists = function (name) {\n return _this.subStores[name];\n };\n\n this.signal = function (name, action) {\n if (_this.subscribers[name]) {\n _this.subscribers[name].forEach(function (method) {\n method(action);\n });\n }\n };\n\n this.getState = function (name) {\n if (_this.subStores[name]) return _this.subStores[name].s;\n return null;\n };\n\n this.subStores = {};\n this.subscribers = {};\n this.delayed = {};\n}\nexport default Combi;","var cache = {};\n\nfunction _createCache (id, data) {\n cache[id] = data;\n}\n\nfunction _getCached (key, data) {\n if (cache[key]) return cache[key];\n return null;\n}\n\nexport default {\n get: _getCached,\n add: _createCache\n};\n","import Moment from \"moment\";\nimport Numeral from \"numeral\";\n\nfunction formatPercentage(n, format) {\n var space = '',\n output,\n value = n * 100;\n\n // check for space before %\n if (format.indexOf(' %') > -1) {\n space = ' ';\n format = format.replace(' %', '');\n } else {\n format = format.replace('%', '');\n }\n\n output = formatNumber(value, format);\n\n if (output.indexOf(')') > -1) {\n output = output.split('');\n output.splice(-1, 0, space + '%');\n output = output.join('');\n } else {\n output = output + space + '%';\n }\n\n return output;\n}\n\nfunction toFixed (value, maxDecimals, optionals) {\n var splitValue = value.toString().split('.'),\n minDecimals = maxDecimals - (optionals || 0),\n boundedPrecision,\n optionalsRegExp,\n power,\n output;\n\n // Use the smallest precision value possible to avoid errors from floating point representation\n if (splitValue.length === 2) {\n boundedPrecision = Math.min(Math.max(splitValue[1].length, minDecimals), maxDecimals);\n } else {\n boundedPrecision = minDecimals;\n }\n\n power = Math.pow(10, boundedPrecision);\n\n //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round);\n // Multiply up by precision, round accurately, then divide and use native toFixed():\n output = (Math.round(value * power) / power).toFixed(boundedPrecision);\n\n if (optionals > maxDecimals - boundedPrecision) {\n optionalsRegExp = new RegExp('\\\\.?0{1,' + (optionals - (maxDecimals - boundedPrecision)) + '}$');\n output = output.replace(optionalsRegExp, '');\n }\n\n return output;\n}\n\nfunction formatNumber(value, format) {\n var negP = false,\n signed = false,\n optDec = false,\n abbr = '',\n abbrK = false, // force abbreviation to thousands\n abbrM = false, // force abbreviation to millions\n abbrB = false, // force abbreviation to billions\n abbrT = false, // force abbreviation to trillions\n abbrForce = false, // force abbreviation\n bytes = '',\n ord = '',\n abs = Math.abs(value),\n w,\n precision,\n thousands,\n d = '',\n neg = false;\n\n // check if number is zero and a custom zero format has been set\n // see if we should use parentheses for negative number or if we should prefix with a sign\n // if both are present we default to parentheses\n if (format.indexOf('(') > -1) {\n negP = true;\n format = format.slice(1, -1);\n } else if (format.indexOf('+') > -1) {\n signed = true;\n format = format.replace(/\\+/g, '');\n }\n\n // see if abbreviation is wanted\n if (format.indexOf('a') > -1) {\n // check if abbreviation is specified\n abbrK = format.indexOf('aK') >= 0;\n abbrM = format.indexOf('aM') >= 0;\n abbrB = format.indexOf('aB') >= 0;\n abbrT = format.indexOf('aT') >= 0;\n abbrForce = abbrK || abbrM || abbrB || abbrT;\n\n // check for space before abbreviation\n if (format.indexOf(' a') > -1) {\n abbr = ' ';\n }\n\n format = format.replace(new RegExp(abbr + 'a[KMBT]?'), '');\n\n if (abs >= Math.pow(10, 12) && !abbrForce || abbrT) {\n // trillion\n value = value / Math.pow(10, 12);\n } else if (abs < Math.pow(10, 12) && abs >= Math.pow(10, 9) && !abbrForce || abbrB) {\n // billion\n value = value / Math.pow(10, 9);\n } else if (abs < Math.pow(10, 9) && abs >= Math.pow(10, 6) && !abbrForce || abbrM) {\n // million\n value = value / Math.pow(10, 6);\n } else if (abs < Math.pow(10, 6) && abs >= Math.pow(10, 3) && !abbrForce || abbrK) {\n // thousand\n value = value / Math.pow(10, 3);\n }\n }\n\n if (format.indexOf('[.]') > -1) {\n optDec = true;\n format = format.replace('[.]', '.');\n }\n\n w = value.toString().split('.')[0];\n precision = format.split('.')[1];\n thousands = format.indexOf(',');\n\n if (precision) {\n if (precision.indexOf('[') > -1) {\n precision = precision.replace(']', '');\n precision = precision.split('[');\n d = toFixed(value, (precision[0].length + precision[1].length), precision[1].length);\n } else {\n d = toFixed(value, precision.length);\n }\n\n w = d.split('.')[0];\n\n if (d.indexOf('.') > -1) {\n d = \".\" + d.split('.')[1];\n } else {\n d = '';\n }\n\n if (optDec && Number(d.slice(1)) === 0) {\n d = '';\n }\n } else {\n w = toFixed(value, null);\n }\n\n // format number\n if (w.indexOf('-') > -1) {\n w = w.slice(1);\n neg = true;\n }\n\n if (thousands > -1) {\n w = w.toString().replace(/(\\d)(?=(\\d{3})+(?!\\d))/g, '$1' + \",\");\n }\n\n if (format.indexOf('.') === 0) {\n w = '';\n }\n\n return ((negP && neg) ? '(' : '') + ((!negP && neg) ? '-' : '') + ((!neg && signed) ? '+' : '') + w + d + ((ord) ? ord : '') + ((abbr) ? abbr : '') + ((bytes) ? bytes : '') + ((negP && neg) ? ')' : '');\n}\n\nconst FORMATTERS = {\n AGE_FORMATTER: function (value) {\n if (!value) return \"Unknown\";\n if (!value.units) return \"Unknown\";\n var result = value.value + \" \" + value.units + \"(s)\";\n return result;\n },\n DATE_FORMATTER: function (value, format) {\n if (!value) return \"Unknown\";\n\n var defFormat = 'YYYY-MM-DD';\n\n if (format == \"WEEK\") {\n Moment.updateLocale(\"en\", {\n week: {\n dow: ewars.getDOWMod7(),\n doy: (7 + ewars.getDOWMod7() - ewars.getDOY())\n },\n });\n var startDate = Moment.utc(value).startOf('week').format(\"DD\");\n var endDate = Moment.utc(value).endOf(\"week\").format(\"DD\");\n var stringDate = Moment.utc(value).format(\"[W]w gggg | [START - END] [MTH]\");\n stringDate = stringDate.replace(\"START\", startDate).replace(\"END\", endDate).replace(\"MTH\", Moment.utc(value).endOf(\"week\").format(\"MMMM\"));\n return stringDate;\n }\n\n if (format === 'MMM DD') {\n return Moment.utc(value).format(format);\n }\n if (format === 'MONTH') {\n return Moment.utc(value).format('MMMM , YYYY');\n }\n if (format === 'YEAR') {\n return Moment.utc(value).format('YYYY');\n }\n\n if (!format || typeof format === 'object' || typeof format === 'Array') return Moment.utc(value).format(defFormat);\n return Moment.utc(value).format(defFormat);\n },\n I18N_FORMATTER: function (data) {\n if (typeof(data) == \"string\") {\n if (data.indexOf(\"{\") == 0) {\n data = JSON.parse(data);\n } else {\n return data;\n }\n }\n if (typeof(data) == \"number\") {\n return data;\n }\n if (!data) return \"Unknown\";\n if (window.user) {\n if (data[window.user.language] && data[window.user.language] != \"\") {\n return data[window.user.language];\n } else {\n if (data.en) {\n return data.en;\n } else {\n return \"\";\n }\n }\n }else {\n if (data.en) {\n return data.en;\n } else {\n return \"\";\n }\n }\n },\n NUM_FORMATTER: function (num) {\n return Numeral(num).format(\"0,0.00\");\n },\n NUM: function (value, format) {\n if (value === undefined || value === null || value === \"\") return \"\";\n if (format.indexOf(\"%\") > -1) {\n return formatPercentage(value, format);\n } else {\n return formatNumber(value, format);\n }\n\n }\n};\n\nexport default FORMATTERS;","var _idCounter = 0;\n\nvar eq = function(a, b, aStack, bStack) {\n // Identical objects are equal. `0 === -0`, but they aren't identical.\n // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).\n if (a === b) return a !== 0 || 1 / a === 1 / b;\n // A strict comparison is necessary because `null == undefined`.\n if (a == null || b == null) return a === b;\n // Unwrap any wrapped objects.\n if (a instanceof _) a = a._wrapped;\n if (b instanceof _) b = b._wrapped;\n // Compare `[[Class]]` names.\n var className = toString.call(a);\n if (className !== toString.call(b)) return false;\n switch (className) {\n // Strings, numbers, regular expressions, dates, and booleans are compared by value.\n case '[object RegExp]':\n // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i')\n case '[object String]':\n // Primitives and their corresponding object wrappers are equivalent; thus, `\"5\"` is\n // equivalent to `new String(\"5\")`.\n return '' + a === '' + b;\n case '[object Number]':\n // `NaN`s are equivalent, but non-reflexive.\n // Object(NaN) is equivalent to NaN\n if (+a !== +a) return +b !== +b;\n // An `egal` comparison is performed for other numeric values.\n return +a === 0 ? 1 / +a === 1 / b : +a === +b;\n case '[object Date]':\n case '[object Boolean]':\n // Coerce dates and booleans to numeric primitive values. Dates are compared by their\n // millisecond representations. Note that invalid dates with millisecond representations\n // of `NaN` are not equivalent.\n return +a === +b;\n }\n};\n\nvar eqJSON = function (obA, obB) {\n return (JSON.stringify(obA) == JSON.stringify(obB));\n};\n\nfunction unwrapStringOrNumber(obj) {\n return (obj instanceof Number || obj instanceof String\n ? obj.valueOf()\n : obj);\n}\nfunction areEquivalent(a, b) {\n a = unwrapStringOrNumber(a);\n b = unwrapStringOrNumber(b);\n if (a === b) return true; //e.g. a and b both null\n if (a === null || b === null || typeof (a) !== typeof (b)) return false;\n if (a instanceof Date)\n return b instanceof Date && a.valueOf() === b.valueOf();\n if (typeof (a) !== \"object\")\n return a == b; //for boolean, number, string, xml\n\n var newA = (a.areEquivalent_Eq_91_2_34 === undefined),\n newB = (b.areEquivalent_Eq_91_2_34 === undefined);\n try {\n if (newA) a.areEquivalent_Eq_91_2_34 = [];\n else if (a.areEquivalent_Eq_91_2_34.some(\n function (other) { return other === b; })) return true;\n if (newB) b.areEquivalent_Eq_91_2_34 = [];\n else if (b.areEquivalent_Eq_91_2_34.some(\n function (other) { return other === a; })) return true;\n a.areEquivalent_Eq_91_2_34.push(b);\n b.areEquivalent_Eq_91_2_34.push(a);\n\n var tmp = {};\n for (var prop in a)\n if(prop != \"areEquivalent_Eq_91_2_34\")\n tmp[prop] = null;\n for (var prop in b)\n if (prop != \"areEquivalent_Eq_91_2_34\")\n tmp[prop] = null;\n\n for (var prop in tmp)\n if (!areEquivalent(a[prop], b[prop]))\n return false;\n return true;\n } finally {\n if (newA) delete a.areEquivalent_Eq_91_2_34;\n if (newB) delete b.areEquivalent_Eq_91_2_34;\n }\n}\n\nconst GENERAL = {\n uniqueId: function (prefix) {\n var id = ++_idCounter + '';\n return prefix ? prefix + id : id;\n },\n uuid: function () {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {\n var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);\n return v.toString(16);\n });\n\n },\n\n isSame: function (obA, obB) {\n return areEquivalent(obA, obB);\n },\n \n isElectron:function() {\n // Renderer process\n if (typeof window !== 'undefined' && typeof window.process === 'object' && window.process.type === 'renderer') {\n return true;\n }\n // Main process\n if (typeof process !== 'undefined' && typeof process.versions === 'object' && !!process.versions.electron) {\n return true;\n }\n // Detect the user agent when the `nodeIntegration` option is set to true\n if (typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Electron') >= 0) {\n return true;\n }\n return false;\n }\n};\n\nexport default GENERAL;\n","var Component = require(\"./components/Component.react\");\n\nimport {\n Layout,\n Row,\n Cell,\n Toolbar,\n Panel,\n Button,\n ButtonGroup,\n Shade,\n Modal\n} from \"../common\";\n\newars.d = {\n Layout,\n Row,\n Cell,\n Toolbar,\n Panel,\n Button,\n ButtonGroup,\n Shade,\n Modal\n};\n\nReactDOM.render(\n ,\n document.getElementById('app')\n);\n\n\n","const { default: ewars } = require('../../ewars/app');\n\nconst ERROR_CODES = {\n NO_AUTH: \"Incorrect Email/Password\",\n USER_DELETED: \"Incorrect Email/Password\",\n EMAIL_PENDING_VERIFICATION: \"Account is pending email verification, please check your inbox.\",\n USER_EXISTS_NO_ACCESS_ACCOUNTS: \"You do not have access to any accounts at this time.\",\n USER_EXISTS_NO_ACCESS_ACCOUNT: \"You do not have access to this account at this time.\",\n NO_ACCOUNT: \"You do not have access to any accounts at this time\",\n USER_ACCESS_REVOKED: \"Your access to the account was revoked\",\n USER_PENDING_APPROVAL: \"You account access is currently pending approval\",\n USER_NO_ACCESS_ACCOUNTS: \"You currently do not have access to any accounts\",\n PASSCODE_WAS_EXPIRED: \"Your One Time Password Was Expired\",\n PASSCODE_WAS_WRONG: \"Your One Time Password is Wrong\",\n PASSCODE_NOT_PROVIDED: \"Please enter passcode\",\n NO_DOMAIN:\"Domain is incorrect,please try again!\"\n};\n\nvar DEFAULT = 'Global EWARS is designed with the needs of frontline users in mind. We use technology and innovation to make disease control in emergencies easier and more effective.';\nrequire('../../../ewars/ewars/static/vendor/Font-Awesome-master/css/font-awesome.min.css')\nconst style = {\n error: {\n position: \"absolute\",\n top: -50\n },\n 'setMargin': {\n marginTop: 20\n },\n 'buttonsync': {\n padding: 9,\n fontSize: 14,\n textAlign: \"center\",\n margin: \"-10px -10px 0px auto\",\n zIndex: 10\n },\n 'paddingChange': {\n padding: 10\n },\n 'syncStyle': {\n float: \"right\",\n marginTop: -6,\n },\n 'pointerStyle': {\n cursor: \"pointer\"\n }\n};\n\nvar Component = React.createClass({\n _isMobile: false,\n\n getInitialState: function (props) {\n return {\n email: \"\",\n password: \"\",\n passcode:\"\",\n error: null,\n multiple: false,\n selectedAccountId: \"\",\n syncButtonName: \"Sync\",\n modalHeader: \"Sync Account\",\n modalBody: \"No Account has been synchronized locally for this user.\",\n showModal: false,\n is_two_factor_auth: false,\n passcodeerror:null,\n showPassword: false,\n }\n },\n\n componentWillMount: function () {\n var check = false;\n (function (a) {\n if (/(android|bb\\d+|meego).+mobile|avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\-(n|u)|c55\\/|capi|ccwa|cdm\\-|cell|chtm|cldc|cmd\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\\-|_)|g1 u|g560|gene|gf\\-5|g\\-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd\\-(m|p|t)|hei\\-|hi(pt|ta)|hp( i|ip)|hs\\-c|ht(c(\\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\\-(20|go|ma)|i230|iac( |\\-|\\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\\/)|klon|kpt |kwc\\-|kyo(c|k)|le(no|xi)|lg( g|\\/(k|l|u)|50|54|\\-[a-w])|libw|lynx|m1\\-w|m3ga|m50\\/|ma(te|ui|xo)|mc(01|21|ca)|m\\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\\-2|po(ck|rt|se)|prox|psio|pt\\-g|qa\\-a|qc(07|12|21|32|60|\\-[2-7]|i\\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\\-|oo|p\\-)|sdk\\/|se(c(\\-|0|1)|47|mc|nd|ri)|sgh\\-|shar|sie(\\-|m)|sk\\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\\-|v\\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\\-|tdg\\-|tel(i|m)|tim\\-|t\\-mo|to(pl|sh)|ts(70|m\\-|m3|m5)|tx\\-9|up(\\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\\-|your|zeto|zte\\-/i.test(a.substr(0, 4))) check = true\n })(navigator.userAgent || navigator.vendor || window.opera);\n if (check) {\n // This is a mobile browser\n this._isMobile = true;\n }\n\n document.body.className = \"app-public\";\n },\n\n componentDidMount: function () {\n this.refs.emailInput.focus();\n },\n\n _redirectToSyncPage: function () {\n window.location = \"/sync\"\n },\n\n _onIndicatorChange: function (event) {\n var curState = this.state;\n curState[event.target.name] = event.target.value;\n this.setState(curState);\n },\n\n _handleEnter: function (event) {\n if (event.keyCode == 13) {\n event.stopPropagation();\n // var blocker = new ewars.Blocker(null, \"Logging in...\");\n this._onLogin();\n }\n },\n\n _onLogin: function () {\n // var blocker = new ewars.Blocker(null, \"Logging in...\");\n if (!this.state.password || this.state.password == \"\") {\n // blocker.destroy();\n this.setState({\n error: \"Please provide a valid email/password\"\n });\n return;\n }\n\n if (!this.state.email || this.state.email == \"\") {\n // blocker.destroy();\n this.setState({\n error: \"Please provide a valid email/password\"\n });\n return;\n }\n\n if (window.server_type == \"LOCAL\") {\n let r = new XMLHttpRequest();\n let data = {\n \"user_name\": (this.state.email).trim(),\n \"password\": this.state.password\n }\n r.open(\"POST\", \"/api/_check_user_sync\", true);\n r.onreadystatechange = () => {\n // blocker.destroy();\n if (r.readyState != 4 && r.status != 200) {\n ewars.growl(r.responseText)\n } else {\n if (r.readyState == 4 && r.status == 200) {\n let resp = JSON.parse(r.responseText);\n if (resp.status == 200) {\n if (resp.data.is_user_available && resp.data.is_schema_available) {\n if (resp.data.is_auth) {\n this._doLogin((this.state.email).trim(), this.state.password);\n }\n else {\n this.setState({\n error: \"Unauthorized User\"\n })\n }\n\n }\n else {\n ewars.prompt(\"fa-sync\", this.state.modalHeader,\n this.state.modalBody, () => {\n cred = {\n \"username\": (this.state.email).trim(),\n \"password\": this.state.password\n }\n window.name = JSON.stringify(cred)\n document.location = \"/sync\"\n }, null, \"Sync now\", \"Cancel\");\n }\n }\n\n }\n }\n };\n r.send(JSON.stringify(data));\n }\n else {\n this._doLogin((this.state.email).trim(), this.state.password);\n }\n },\n\n _doLogin: function (email, password) {\n cred = {\n \"username\": (this.state.email).trim(),\n \"password\": this.state.password\n }\n window.name = JSON.stringify(cred)\n\n let self = this;\n let data = JSON.stringify({\n email: email,\n password: password\n });\n let bl = new ewars.Blocker(null, __(\"AUTHENTICATING\"));\n let r = new XMLHttpRequest();\n r.open(\"POST\", \"/login\", true);\n r.onreadystatechange = () => {\n // blocker.destroy();\n if (r.readyState != 4 && r.status != 200) {\n bl.destroy();\n this.setState({\n error: ERROR_CODES[3]\n })\n window.name = \"\"\n } else {\n if (r.readyState == 4 && r.status == 200) {\n bl.destroy();\n let resp = JSON.parse(r.responseText);\n\n if(resp.is_two_factor_auth){\n this.setState({is_two_factor_auth:true})\n return;\n }\n\n if (resp.code) {\n switch (resp.code) {\n case \"MULTI_ACCOUNT\":\n this.setState({\n multiple: true,\n accounts: resp.accounts\n });\n break;\n default:\n this.setState({ error: ERROR_CODES[resp.code] });\n }\n } else {\n if (resp.cortex) {\n document.location = \"/cortex\";\n } else {\n if(resp.language_array && window.server_type == \"LOCAL\"){\n window.localStorage.language_array=JSON.stringify(resp.language_array.results);\n }\n document.location = \"/\";\n }\n }\n }\n }\n };\n r.send(data);\n },\n\n _twoFactorLogin: function () {\n if (!this.state.passcode || this.state.passcode == \"\") {\n // blocker.destroy();\n this.setState({\n passcodeerror: \"PASSCODE_NOT_PROVIDED\"\n });\n return;\n }\n\n cred = {\n \"username\": (this.state.email).trim(),\n \"password\": this.state.password,\n \"passcode\" : this.state.passcode\n }\n window.name = JSON.stringify(cred)\n\n let self = this;\n let data = JSON.stringify({\n email: this.state.email,\n password: this.state.password,\n passcode : this.state.passcode\n });\n let bl = new ewars.Blocker(null, __(\"AUTHENTICATING\"));\n let r = new XMLHttpRequest();\n r.open(\"POST\", \"/login\", true);\n r.onreadystatechange = () => {\n // blocker.destroy();\n if (r.readyState != 4 && r.status != 200) {\n bl.destroy();\n this.setState({\n error: ERROR_CODES[3]\n })\n window.name = \"\"\n } else {\n if (r.readyState == 4 && r.status == 200) {\n bl.destroy();\n let resp = JSON.parse(r.responseText);\n if (resp.code) {\n switch (resp.code) {\n case \"MULTI_ACCOUNT\":\n this.setState({\n is_two_factor_auth:false,\n multiple: true,\n accounts: resp.accounts\n });\n break;\n case \"PASSCODE_WAS_EXPIRED\":\n case \"PASSCODE_WAS_WRONG\":\n this.setState({\n passcodeerror: resp.code,\n accounts: resp.accounts\n });\n break;\n default:\n this.setState({ error: ERROR_CODES[resp.code] });\n }\n } else {\n if (resp.cortex) {\n document.location = \"/cortex\";\n } else {\n if(resp.language_array && window.server_type == \"LOCAL\"){\n window.localStorage.language_array=JSON.stringify(resp.language_array.results);\n }\n document.location = \"/\";\n }\n }\n }\n }\n };\n r.send(data);\n },\n\n _clearError: function () {\n this.setState({\n error: null\n })\n },\n\n navigateToSync: function (accId) {\n var cred = JSON.parse(window.name)\n cred = {\n ...cred,\n \"accountId\": accId\n }\n window.name = JSON.stringify(cred)\n },\n\n checkNetwork: function( isLocal, path){\n if(isLocal){\n if(!window.network_connection.isNetwork){\n ewars.growl(__(\"ONLINE_FEATURE_CANT_ACCESS_OFFLINE\"))\n }\n else{\n window.open(\n window.global_server_url + path,\n '_blank'\n );\n }\n }\n else{\n window.location = path\n }\n },\n\n _selectAccount: function (accId) {\n let data = {}\n if (window.name) {\n var cred = JSON.parse(window.name)\n data = JSON.stringify({\n email: cred.username,\n password: cred.password,\n account_id: accId,\n passcode:this.state.passcode\n });\n }\n else {\n data = JSON.stringify({\n email: this.state.email,\n password: this.state.password,\n account_id: accId,\n passcode:this.state.passcode\n });\n }\n\n\n // let bl = new ewars.Blocker(null, \"Authenticating...\");\n let r = new XMLHttpRequest();\n r.open(\"POST\", \"/login\");\n r.onreadystatechange = () => {\n // bl.destroy();\n if (r.readyState != 4 && r.status != 200) {\n this.setState({\n error: ERROR_CODES[3]\n })\n } else {\n if (r.readyState == 4 && r.status == 200) {\n let resp = JSON.parse(r.responseText);\n\n if (resp.err) {\n this.setState({ error: ERROR_CODES[resp.code] });\n ewars.growl(ERROR_CODES[resp.code]);\n\n } else {\n if(resp.language_array && window.server_type == \"LOCAL\"){\n window.localStorage.language_array=JSON.stringify(resp.language_array.results);\n }\n document.location = \"/\";\n }\n }\n }\n };\n r.send(data);\n },\n\n returnBack:function(){\n document.location = \"/\";\n },\n _resendPasscode:function(){\n this.setState({passcode : \"\"})\n this._doLogin(this.state.email,this.state.password)\n },\n\n togglePasswordVisibility: function(){\n this.setState({showPassword: !this.state.showPassword})\n },\n\n\n render: function () {\n var error;\n if (this.state.passcodeerror) {\n error =
    \n  \n {ERROR_CODES[this.state.passcodeerror] || this.state.passcodeerror}\n
    \n }\n if (this.state.is_two_factor_auth) {\n return (\n
    \n
    \n
    \n
    Two Factor Authentication\n
    \n \n
    \n
    \n
    \n {error}\n \n \n
    \n

    Please click 'Resend OTP' button, If One Time Password was not received

    \n
    \n this._twoFactorLogin()} />\n this._resendPasscode()} />\n
    \n
    \n
    \n
    \n
    \n )\n }\n\n if (this.state.multiple) {\n return (\n
    \n

    Accounts

    \n

    Please select the account you would like to access.

    \n\n
    \n
    \n
    \n {this.state.accounts.map((acc) => {\n return (\n
    { acc[3] ? this._selectAccount(acc[0]) : null }}>\n
    \n {ewars.I18N(acc[1])} {acc[2]}\n {acc[3] ?\n null\n :\n window.server_type == \"LOCAL\" ?\n
    \n this._redirectToSyncPage()} />\n
    \n : null \n }\n
    \n
    \n )\n })}\n\n
    \n
    \n
    \n\n {window.server_type == \"LOCAL\" ?\n
    \n \n
    \n : null}\n\n
    \n )\n }\n\n if (this._isMobile) {\n return (\n
    \n
    \n

    Mobile Unsupported

    \n\n

    Unfortunately, at this time, mobile browsers are not supported by the EWARS platform. A\n mobile application is under active development and will be released for various platforms\n (Android, iOS, Windows Phone) in the coming months.

    \n

    In the meantime, please access the EWARS application through either a desktop browser, or the\n desktop client.

    \n

    If you have any questions or concerns, please contact ewars@who.int\n

    \n
    \n
    \n )\n }\n\n var accName = \"Global\";\n if (window.account) accName = window.account.name;\n\n let year = new Date().getFullYear();\n\n return (\n
    \n
    \n
    \n
    \n\n

    Existing User? Sign in

    \n {this.state.error ?\n
    \n  \n {this.state.error}\n
    \n : null\n }\n\n \n \n
    \n\n \n
    \n \n \n {this.state.showPassword ? (\n \n ) : (\n \n )}\n
    \n
    \n\n
    \n
    Login\n
    \n
    \n {window.server_type == \"LOCAL\" ?\n \n :\n \n }\n
    \n\n
    \n
    \n
    \n\n
    \n {window.account.account_flag && window.account.account_flag != \"\" ?\n
    \n \"\"\n
    \n : null}\n
    \n
    {accName}
    \n
    {window.config.APP_NAME || \"EWARS\"}
    \n
    \n
    \n
    \n\n\n {window.account.name ?\n

    {window.account.description}

    \n :\n

    {DEFAULT}

    \n }\n\n
    \n\n {window.account.account_logo && window.account.account_logo != \"\" ?\n \"\"\n : null}\n\n
    \n
    All Content Copyright WHO {year}.\n All Rights Reserved. Powered by ewars\n
    \n
    \n
    \n
    \n )\n\n }\n});\n\nmodule.exports = Component;\n","\"use strict\";\n\nrequire(\"./noConflict\");\n\nvar _global = _interopRequireDefault(require(\"core-js/library/fn/global\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { \"default\": obj }; }\n\nif (_global[\"default\"]._babelPolyfill && typeof console !== \"undefined\" && console.warn) {\n console.warn(\"@babel/polyfill is loaded more than once on this page. This is probably not desirable/intended \" + \"and may have consequences if different versions of the polyfills are applied sequentially. \" + \"If you do need to load the polyfill more than once, use @babel/polyfill/noConflict \" + \"instead to bypass the warning.\");\n}\n\n_global[\"default\"]._babelPolyfill = true;","\"use strict\";\n\nrequire(\"core-js/es6\");\n\nrequire(\"core-js/fn/array/includes\");\n\nrequire(\"core-js/fn/array/flat-map\");\n\nrequire(\"core-js/fn/string/pad-start\");\n\nrequire(\"core-js/fn/string/pad-end\");\n\nrequire(\"core-js/fn/string/trim-start\");\n\nrequire(\"core-js/fn/string/trim-end\");\n\nrequire(\"core-js/fn/symbol/async-iterator\");\n\nrequire(\"core-js/fn/object/get-own-property-descriptors\");\n\nrequire(\"core-js/fn/object/values\");\n\nrequire(\"core-js/fn/object/entries\");\n\nrequire(\"core-js/fn/promise/finally\");\n\nrequire(\"core-js/web\");\n\nrequire(\"regenerator-runtime/runtime\");","function _arrayWithHoles(arr) {\n if (Array.isArray(arr)) return arr;\n}\n\nmodule.exports = _arrayWithHoles;","function _assertThisInitialized(self) {\n if (self === void 0) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n\n return self;\n}\n\nmodule.exports = _assertThisInitialized;","function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {\n try {\n var info = gen[key](arg);\n var value = info.value;\n } catch (error) {\n reject(error);\n return;\n }\n\n if (info.done) {\n resolve(value);\n } else {\n Promise.resolve(value).then(_next, _throw);\n }\n}\n\nfunction _asyncToGenerator(fn) {\n return function () {\n var self = this,\n args = arguments;\n return new Promise(function (resolve, reject) {\n var gen = fn.apply(self, args);\n\n function _next(value) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value);\n }\n\n function _throw(err) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err);\n }\n\n _next(undefined);\n });\n };\n}\n\nmodule.exports = _asyncToGenerator;","function _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}\n\nmodule.exports = _classCallCheck;","function _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n}\n\nfunction _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n return Constructor;\n}\n\nmodule.exports = _createClass;","function _getPrototypeOf(o) {\n module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n return o.__proto__ || Object.getPrototypeOf(o);\n };\n return _getPrototypeOf(o);\n}\n\nmodule.exports = _getPrototypeOf;","var setPrototypeOf = require(\"./setPrototypeOf\");\n\nfunction _inherits(subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n writable: true,\n configurable: true\n }\n });\n if (superClass) setPrototypeOf(subClass, superClass);\n}\n\nmodule.exports = _inherits;","function _iterableToArrayLimit(arr, i) {\n if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === \"[object Arguments]\")) {\n return;\n }\n\n var _arr = [];\n var _n = true;\n var _d = false;\n var _e = undefined;\n\n try {\n for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i[\"return\"] != null) _i[\"return\"]();\n } finally {\n if (_d) throw _e;\n }\n }\n\n return _arr;\n}\n\nmodule.exports = _iterableToArrayLimit;","function _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance\");\n}\n\nmodule.exports = _nonIterableRest;","var _typeof = require(\"../helpers/typeof\");\n\nvar assertThisInitialized = require(\"./assertThisInitialized\");\n\nfunction _possibleConstructorReturn(self, call) {\n if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) {\n return call;\n }\n\n return assertThisInitialized(self);\n}\n\nmodule.exports = _possibleConstructorReturn;","function _setPrototypeOf(o, p) {\n module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n\n return _setPrototypeOf(o, p);\n}\n\nmodule.exports = _setPrototypeOf;","var arrayWithHoles = require(\"./arrayWithHoles\");\n\nvar iterableToArrayLimit = require(\"./iterableToArrayLimit\");\n\nvar nonIterableRest = require(\"./nonIterableRest\");\n\nfunction _slicedToArray(arr, i) {\n return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || nonIterableRest();\n}\n\nmodule.exports = _slicedToArray;","function _typeof(obj) {\n if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n module.exports = _typeof = function _typeof(obj) {\n return typeof obj;\n };\n } else {\n module.exports = _typeof = function _typeof(obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n };\n }\n\n return _typeof(obj);\n}\n\nmodule.exports = _typeof;","module.exports = require(\"regenerator-runtime\");\n","/**\n * chroma.js - JavaScript library for color conversions\n *\n * Copyright (c) 2011-2019, Gregor Aisch\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * 3. The name Gregor Aisch may not be used to endorse or promote products\n * derived from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\n * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\n * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n * -------------------------------------------------------\n *\n * chroma.js includes colors from colorbrewer2.org, which are released under\n * the following license:\n *\n * Copyright (c) 2002 Cynthia Brewer, Mark Harrower,\n * and The Pennsylvania State University.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n * either express or implied. See the License for the specific\n * language governing permissions and limitations under the License.\n *\n * ------------------------------------------------------\n *\n * Named colors are taken from X11 Color Names.\n * http://www.w3.org/TR/css3-color/#svg-color\n *\n * @preserve\n */\n\n(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n (global.chroma = factory());\n}(this, (function () { 'use strict';\n\n var limit = function (x, min, max) {\n if ( min === void 0 ) min=0;\n if ( max === void 0 ) max=1;\n\n return x < min ? min : x > max ? max : x;\n };\n\n var clip_rgb = function (rgb) {\n rgb._clipped = false;\n rgb._unclipped = rgb.slice(0);\n for (var i=0; i<=3; i++) {\n if (i < 3) {\n if (rgb[i] < 0 || rgb[i] > 255) { rgb._clipped = true; }\n rgb[i] = limit(rgb[i], 0, 255);\n } else if (i === 3) {\n rgb[i] = limit(rgb[i], 0, 1);\n }\n }\n return rgb;\n };\n\n // ported from jQuery's $.type\n var classToType = {};\n for (var i = 0, list = ['Boolean', 'Number', 'String', 'Function', 'Array', 'Date', 'RegExp', 'Undefined', 'Null']; i < list.length; i += 1) {\n var name = list[i];\n\n classToType[(\"[object \" + name + \"]\")] = name.toLowerCase();\n }\n var type = function(obj) {\n return classToType[Object.prototype.toString.call(obj)] || \"object\";\n };\n\n var unpack = function (args, keyOrder) {\n if ( keyOrder === void 0 ) keyOrder=null;\n\n \t// if called with more than 3 arguments, we return the arguments\n if (args.length >= 3) { return Array.prototype.slice.call(args); }\n // with less than 3 args we check if first arg is object\n // and use the keyOrder string to extract and sort properties\n \tif (type(args[0]) == 'object' && keyOrder) {\n \t\treturn keyOrder.split('')\n \t\t\t.filter(function (k) { return args[0][k] !== undefined; })\n \t\t\t.map(function (k) { return args[0][k]; });\n \t}\n \t// otherwise we just return the first argument\n \t// (which we suppose is an array of args)\n return args[0];\n };\n\n var last = function (args) {\n if (args.length < 2) { return null; }\n var l = args.length-1;\n if (type(args[l]) == 'string') { return args[l].toLowerCase(); }\n return null;\n };\n\n var PI = Math.PI;\n\n var utils = {\n \tclip_rgb: clip_rgb,\n \tlimit: limit,\n \ttype: type,\n \tunpack: unpack,\n \tlast: last,\n \tPI: PI,\n \tTWOPI: PI*2,\n \tPITHIRD: PI/3,\n \tDEG2RAD: PI / 180,\n \tRAD2DEG: 180 / PI\n };\n\n var input = {\n \tformat: {},\n \tautodetect: []\n };\n\n var last$1 = utils.last;\n var clip_rgb$1 = utils.clip_rgb;\n var type$1 = utils.type;\n\n\n var Color = function Color() {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n var me = this;\n if (type$1(args[0]) === 'object' &&\n args[0].constructor &&\n args[0].constructor === this.constructor) {\n // the argument is already a Color instance\n return args[0];\n }\n\n // last argument could be the mode\n var mode = last$1(args);\n var autodetect = false;\n\n if (!mode) {\n autodetect = true;\n if (!input.sorted) {\n input.autodetect = input.autodetect.sort(function (a,b) { return b.p - a.p; });\n input.sorted = true;\n }\n // auto-detect format\n for (var i = 0, list = input.autodetect; i < list.length; i += 1) {\n var chk = list[i];\n\n mode = chk.test.apply(chk, args);\n if (mode) { break; }\n }\n }\n\n if (input.format[mode]) {\n var rgb = input.format[mode].apply(null, autodetect ? args : args.slice(0,-1));\n me._rgb = clip_rgb$1(rgb);\n } else {\n throw new Error('unknown format: '+args);\n }\n\n // add alpha channel\n if (me._rgb.length === 3) { me._rgb.push(1); }\n };\n\n Color.prototype.toString = function toString () {\n if (type$1(this.hex) == 'function') { return this.hex(); }\n return (\"[\" + (this._rgb.join(',')) + \"]\");\n };\n\n var Color_1 = Color;\n\n var chroma = function () {\n \tvar args = [], len = arguments.length;\n \twhile ( len-- ) args[ len ] = arguments[ len ];\n\n \treturn new (Function.prototype.bind.apply( chroma.Color, [ null ].concat( args) ));\n };\n\n chroma.Color = Color_1;\n chroma.version = '2.1.0';\n\n var chroma_1 = chroma;\n\n var unpack$1 = utils.unpack;\n var max = Math.max;\n\n var rgb2cmyk = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n var ref = unpack$1(args, 'rgb');\n var r = ref[0];\n var g = ref[1];\n var b = ref[2];\n r = r / 255;\n g = g / 255;\n b = b / 255;\n var k = 1 - max(r,max(g,b));\n var f = k < 1 ? 1 / (1-k) : 0;\n var c = (1-r-k) * f;\n var m = (1-g-k) * f;\n var y = (1-b-k) * f;\n return [c,m,y,k];\n };\n\n var rgb2cmyk_1 = rgb2cmyk;\n\n var unpack$2 = utils.unpack;\n\n var cmyk2rgb = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n args = unpack$2(args, 'cmyk');\n var c = args[0];\n var m = args[1];\n var y = args[2];\n var k = args[3];\n var alpha = args.length > 4 ? args[4] : 1;\n if (k === 1) { return [0,0,0,alpha]; }\n return [\n c >= 1 ? 0 : 255 * (1-c) * (1-k), // r\n m >= 1 ? 0 : 255 * (1-m) * (1-k), // g\n y >= 1 ? 0 : 255 * (1-y) * (1-k), // b\n alpha\n ];\n };\n\n var cmyk2rgb_1 = cmyk2rgb;\n\n var unpack$3 = utils.unpack;\n var type$2 = utils.type;\n\n\n\n Color_1.prototype.cmyk = function() {\n return rgb2cmyk_1(this._rgb);\n };\n\n chroma_1.cmyk = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['cmyk']) ));\n };\n\n input.format.cmyk = cmyk2rgb_1;\n\n input.autodetect.push({\n p: 2,\n test: function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n args = unpack$3(args, 'cmyk');\n if (type$2(args) === 'array' && args.length === 4) {\n return 'cmyk';\n }\n }\n });\n\n var unpack$4 = utils.unpack;\n var last$2 = utils.last;\n var rnd = function (a) { return Math.round(a*100)/100; };\n\n /*\n * supported arguments:\n * - hsl2css(h,s,l)\n * - hsl2css(h,s,l,a)\n * - hsl2css([h,s,l], mode)\n * - hsl2css([h,s,l,a], mode)\n * - hsl2css({h,s,l,a}, mode)\n */\n var hsl2css = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n var hsla = unpack$4(args, 'hsla');\n var mode = last$2(args) || 'lsa';\n hsla[0] = rnd(hsla[0] || 0);\n hsla[1] = rnd(hsla[1]*100) + '%';\n hsla[2] = rnd(hsla[2]*100) + '%';\n if (mode === 'hsla' || (hsla.length > 3 && hsla[3]<1)) {\n hsla[3] = hsla.length > 3 ? hsla[3] : 1;\n mode = 'hsla';\n } else {\n hsla.length = 3;\n }\n return (mode + \"(\" + (hsla.join(',')) + \")\");\n };\n\n var hsl2css_1 = hsl2css;\n\n var unpack$5 = utils.unpack;\n\n /*\n * supported arguments:\n * - rgb2hsl(r,g,b)\n * - rgb2hsl(r,g,b,a)\n * - rgb2hsl([r,g,b])\n * - rgb2hsl([r,g,b,a])\n * - rgb2hsl({r,g,b,a})\n */\n var rgb2hsl = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n args = unpack$5(args, 'rgba');\n var r = args[0];\n var g = args[1];\n var b = args[2];\n\n r /= 255;\n g /= 255;\n b /= 255;\n\n var min = Math.min(r, g, b);\n var max = Math.max(r, g, b);\n\n var l = (max + min) / 2;\n var s, h;\n\n if (max === min){\n s = 0;\n h = Number.NaN;\n } else {\n s = l < 0.5 ? (max - min) / (max + min) : (max - min) / (2 - max - min);\n }\n\n if (r == max) { h = (g - b) / (max - min); }\n else if (g == max) { h = 2 + (b - r) / (max - min); }\n else if (b == max) { h = 4 + (r - g) / (max - min); }\n\n h *= 60;\n if (h < 0) { h += 360; }\n if (args.length>3 && args[3]!==undefined) { return [h,s,l,args[3]]; }\n return [h,s,l];\n };\n\n var rgb2hsl_1 = rgb2hsl;\n\n var unpack$6 = utils.unpack;\n var last$3 = utils.last;\n\n\n var round = Math.round;\n\n /*\n * supported arguments:\n * - rgb2css(r,g,b)\n * - rgb2css(r,g,b,a)\n * - rgb2css([r,g,b], mode)\n * - rgb2css([r,g,b,a], mode)\n * - rgb2css({r,g,b,a}, mode)\n */\n var rgb2css = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n var rgba = unpack$6(args, 'rgba');\n var mode = last$3(args) || 'rgb';\n if (mode.substr(0,3) == 'hsl') {\n return hsl2css_1(rgb2hsl_1(rgba), mode);\n }\n rgba[0] = round(rgba[0]);\n rgba[1] = round(rgba[1]);\n rgba[2] = round(rgba[2]);\n if (mode === 'rgba' || (rgba.length > 3 && rgba[3]<1)) {\n rgba[3] = rgba.length > 3 ? rgba[3] : 1;\n mode = 'rgba';\n }\n return (mode + \"(\" + (rgba.slice(0,mode==='rgb'?3:4).join(',')) + \")\");\n };\n\n var rgb2css_1 = rgb2css;\n\n var unpack$7 = utils.unpack;\n var round$1 = Math.round;\n\n var hsl2rgb = function () {\n var assign;\n\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n args = unpack$7(args, 'hsl');\n var h = args[0];\n var s = args[1];\n var l = args[2];\n var r,g,b;\n if (s === 0) {\n r = g = b = l*255;\n } else {\n var t3 = [0,0,0];\n var c = [0,0,0];\n var t2 = l < 0.5 ? l * (1+s) : l+s-l*s;\n var t1 = 2 * l - t2;\n var h_ = h / 360;\n t3[0] = h_ + 1/3;\n t3[1] = h_;\n t3[2] = h_ - 1/3;\n for (var i=0; i<3; i++) {\n if (t3[i] < 0) { t3[i] += 1; }\n if (t3[i] > 1) { t3[i] -= 1; }\n if (6 * t3[i] < 1)\n { c[i] = t1 + (t2 - t1) * 6 * t3[i]; }\n else if (2 * t3[i] < 1)\n { c[i] = t2; }\n else if (3 * t3[i] < 2)\n { c[i] = t1 + (t2 - t1) * ((2 / 3) - t3[i]) * 6; }\n else\n { c[i] = t1; }\n }\n (assign = [round$1(c[0]*255),round$1(c[1]*255),round$1(c[2]*255)], r = assign[0], g = assign[1], b = assign[2]);\n }\n if (args.length > 3) {\n // keep alpha channel\n return [r,g,b,args[3]];\n }\n return [r,g,b,1];\n };\n\n var hsl2rgb_1 = hsl2rgb;\n\n var RE_RGB = /^rgb\\(\\s*(-?\\d+),\\s*(-?\\d+)\\s*,\\s*(-?\\d+)\\s*\\)$/;\n var RE_RGBA = /^rgba\\(\\s*(-?\\d+),\\s*(-?\\d+)\\s*,\\s*(-?\\d+)\\s*,\\s*([01]|[01]?\\.\\d+)\\)$/;\n var RE_RGB_PCT = /^rgb\\(\\s*(-?\\d+(?:\\.\\d+)?)%,\\s*(-?\\d+(?:\\.\\d+)?)%\\s*,\\s*(-?\\d+(?:\\.\\d+)?)%\\s*\\)$/;\n var RE_RGBA_PCT = /^rgba\\(\\s*(-?\\d+(?:\\.\\d+)?)%,\\s*(-?\\d+(?:\\.\\d+)?)%\\s*,\\s*(-?\\d+(?:\\.\\d+)?)%\\s*,\\s*([01]|[01]?\\.\\d+)\\)$/;\n var RE_HSL = /^hsl\\(\\s*(-?\\d+(?:\\.\\d+)?),\\s*(-?\\d+(?:\\.\\d+)?)%\\s*,\\s*(-?\\d+(?:\\.\\d+)?)%\\s*\\)$/;\n var RE_HSLA = /^hsla\\(\\s*(-?\\d+(?:\\.\\d+)?),\\s*(-?\\d+(?:\\.\\d+)?)%\\s*,\\s*(-?\\d+(?:\\.\\d+)?)%\\s*,\\s*([01]|[01]?\\.\\d+)\\)$/;\n\n var round$2 = Math.round;\n\n var css2rgb = function (css) {\n css = css.toLowerCase().trim();\n var m;\n\n if (input.format.named) {\n try {\n return input.format.named(css);\n } catch (e) {\n // eslint-disable-next-line\n }\n }\n\n // rgb(250,20,0)\n if ((m = css.match(RE_RGB))) {\n var rgb = m.slice(1,4);\n for (var i=0; i<3; i++) {\n rgb[i] = +rgb[i];\n }\n rgb[3] = 1; // default alpha\n return rgb;\n }\n\n // rgba(250,20,0,0.4)\n if ((m = css.match(RE_RGBA))) {\n var rgb$1 = m.slice(1,5);\n for (var i$1=0; i$1<4; i$1++) {\n rgb$1[i$1] = +rgb$1[i$1];\n }\n return rgb$1;\n }\n\n // rgb(100%,0%,0%)\n if ((m = css.match(RE_RGB_PCT))) {\n var rgb$2 = m.slice(1,4);\n for (var i$2=0; i$2<3; i$2++) {\n rgb$2[i$2] = round$2(rgb$2[i$2] * 2.55);\n }\n rgb$2[3] = 1; // default alpha\n return rgb$2;\n }\n\n // rgba(100%,0%,0%,0.4)\n if ((m = css.match(RE_RGBA_PCT))) {\n var rgb$3 = m.slice(1,5);\n for (var i$3=0; i$3<3; i$3++) {\n rgb$3[i$3] = round$2(rgb$3[i$3] * 2.55);\n }\n rgb$3[3] = +rgb$3[3];\n return rgb$3;\n }\n\n // hsl(0,100%,50%)\n if ((m = css.match(RE_HSL))) {\n var hsl = m.slice(1,4);\n hsl[1] *= 0.01;\n hsl[2] *= 0.01;\n var rgb$4 = hsl2rgb_1(hsl);\n rgb$4[3] = 1;\n return rgb$4;\n }\n\n // hsla(0,100%,50%,0.5)\n if ((m = css.match(RE_HSLA))) {\n var hsl$1 = m.slice(1,4);\n hsl$1[1] *= 0.01;\n hsl$1[2] *= 0.01;\n var rgb$5 = hsl2rgb_1(hsl$1);\n rgb$5[3] = +m[4]; // default alpha = 1\n return rgb$5;\n }\n };\n\n css2rgb.test = function (s) {\n return RE_RGB.test(s) ||\n RE_RGBA.test(s) ||\n RE_RGB_PCT.test(s) ||\n RE_RGBA_PCT.test(s) ||\n RE_HSL.test(s) ||\n RE_HSLA.test(s);\n };\n\n var css2rgb_1 = css2rgb;\n\n var type$3 = utils.type;\n\n\n\n\n Color_1.prototype.css = function(mode) {\n return rgb2css_1(this._rgb, mode);\n };\n\n chroma_1.css = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['css']) ));\n };\n\n input.format.css = css2rgb_1;\n\n input.autodetect.push({\n p: 5,\n test: function (h) {\n var rest = [], len = arguments.length - 1;\n while ( len-- > 0 ) rest[ len ] = arguments[ len + 1 ];\n\n if (!rest.length && type$3(h) === 'string' && css2rgb_1.test(h)) {\n return 'css';\n }\n }\n });\n\n var unpack$8 = utils.unpack;\n\n input.format.gl = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n var rgb = unpack$8(args, 'rgba');\n rgb[0] *= 255;\n rgb[1] *= 255;\n rgb[2] *= 255;\n return rgb;\n };\n\n chroma_1.gl = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['gl']) ));\n };\n\n Color_1.prototype.gl = function() {\n var rgb = this._rgb;\n return [rgb[0]/255, rgb[1]/255, rgb[2]/255, rgb[3]];\n };\n\n var unpack$9 = utils.unpack;\n\n var rgb2hcg = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n var ref = unpack$9(args, 'rgb');\n var r = ref[0];\n var g = ref[1];\n var b = ref[2];\n var min = Math.min(r, g, b);\n var max = Math.max(r, g, b);\n var delta = max - min;\n var c = delta * 100 / 255;\n var _g = min / (255 - delta) * 100;\n var h;\n if (delta === 0) {\n h = Number.NaN;\n } else {\n if (r === max) { h = (g - b) / delta; }\n if (g === max) { h = 2+(b - r) / delta; }\n if (b === max) { h = 4+(r - g) / delta; }\n h *= 60;\n if (h < 0) { h += 360; }\n }\n return [h, c, _g];\n };\n\n var rgb2hcg_1 = rgb2hcg;\n\n var unpack$a = utils.unpack;\n var floor = Math.floor;\n\n /*\n * this is basically just HSV with some minor tweaks\n *\n * hue.. [0..360]\n * chroma .. [0..1]\n * grayness .. [0..1]\n */\n\n var hcg2rgb = function () {\n var assign, assign$1, assign$2, assign$3, assign$4, assign$5;\n\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n args = unpack$a(args, 'hcg');\n var h = args[0];\n var c = args[1];\n var _g = args[2];\n var r,g,b;\n _g = _g * 255;\n var _c = c * 255;\n if (c === 0) {\n r = g = b = _g;\n } else {\n if (h === 360) { h = 0; }\n if (h > 360) { h -= 360; }\n if (h < 0) { h += 360; }\n h /= 60;\n var i = floor(h);\n var f = h - i;\n var p = _g * (1 - c);\n var q = p + _c * (1 - f);\n var t = p + _c * f;\n var v = p + _c;\n switch (i) {\n case 0: (assign = [v, t, p], r = assign[0], g = assign[1], b = assign[2]); break\n case 1: (assign$1 = [q, v, p], r = assign$1[0], g = assign$1[1], b = assign$1[2]); break\n case 2: (assign$2 = [p, v, t], r = assign$2[0], g = assign$2[1], b = assign$2[2]); break\n case 3: (assign$3 = [p, q, v], r = assign$3[0], g = assign$3[1], b = assign$3[2]); break\n case 4: (assign$4 = [t, p, v], r = assign$4[0], g = assign$4[1], b = assign$4[2]); break\n case 5: (assign$5 = [v, p, q], r = assign$5[0], g = assign$5[1], b = assign$5[2]); break\n }\n }\n return [r, g, b, args.length > 3 ? args[3] : 1];\n };\n\n var hcg2rgb_1 = hcg2rgb;\n\n var unpack$b = utils.unpack;\n var type$4 = utils.type;\n\n\n\n\n\n\n Color_1.prototype.hcg = function() {\n return rgb2hcg_1(this._rgb);\n };\n\n chroma_1.hcg = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['hcg']) ));\n };\n\n input.format.hcg = hcg2rgb_1;\n\n input.autodetect.push({\n p: 1,\n test: function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n args = unpack$b(args, 'hcg');\n if (type$4(args) === 'array' && args.length === 3) {\n return 'hcg';\n }\n }\n });\n\n var unpack$c = utils.unpack;\n var last$4 = utils.last;\n var round$3 = Math.round;\n\n var rgb2hex = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n var ref = unpack$c(args, 'rgba');\n var r = ref[0];\n var g = ref[1];\n var b = ref[2];\n var a = ref[3];\n var mode = last$4(args) || 'auto';\n if (a === undefined) { a = 1; }\n if (mode === 'auto') {\n mode = a < 1 ? 'rgba' : 'rgb';\n }\n r = round$3(r);\n g = round$3(g);\n b = round$3(b);\n var u = r << 16 | g << 8 | b;\n var str = \"000000\" + u.toString(16); //#.toUpperCase();\n str = str.substr(str.length - 6);\n var hxa = '0' + round$3(a * 255).toString(16);\n hxa = hxa.substr(hxa.length - 2);\n switch (mode.toLowerCase()) {\n case 'rgba': return (\"#\" + str + hxa);\n case 'argb': return (\"#\" + hxa + str);\n default: return (\"#\" + str);\n }\n };\n\n var rgb2hex_1 = rgb2hex;\n\n var RE_HEX = /^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;\n var RE_HEXA = /^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/;\n\n var hex2rgb = function (hex) {\n if (hex.match(RE_HEX)) {\n // remove optional leading #\n if (hex.length === 4 || hex.length === 7) {\n hex = hex.substr(1);\n }\n // expand short-notation to full six-digit\n if (hex.length === 3) {\n hex = hex.split('');\n hex = hex[0]+hex[0]+hex[1]+hex[1]+hex[2]+hex[2];\n }\n var u = parseInt(hex, 16);\n var r = u >> 16;\n var g = u >> 8 & 0xFF;\n var b = u & 0xFF;\n return [r,g,b,1];\n }\n\n // match rgba hex format, eg #FF000077\n if (hex.match(RE_HEXA)) {\n if (hex.length === 5 || hex.length === 9) {\n // remove optional leading #\n hex = hex.substr(1);\n }\n // expand short-notation to full eight-digit\n if (hex.length === 4) {\n hex = hex.split('');\n hex = hex[0]+hex[0]+hex[1]+hex[1]+hex[2]+hex[2]+hex[3]+hex[3];\n }\n var u$1 = parseInt(hex, 16);\n var r$1 = u$1 >> 24 & 0xFF;\n var g$1 = u$1 >> 16 & 0xFF;\n var b$1 = u$1 >> 8 & 0xFF;\n var a = Math.round((u$1 & 0xFF) / 0xFF * 100) / 100;\n return [r$1,g$1,b$1,a];\n }\n\n // we used to check for css colors here\n // if _input.css? and rgb = _input.css hex\n // return rgb\n\n throw new Error((\"unknown hex color: \" + hex));\n };\n\n var hex2rgb_1 = hex2rgb;\n\n var type$5 = utils.type;\n\n\n\n\n Color_1.prototype.hex = function(mode) {\n return rgb2hex_1(this._rgb, mode);\n };\n\n chroma_1.hex = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['hex']) ));\n };\n\n input.format.hex = hex2rgb_1;\n input.autodetect.push({\n p: 4,\n test: function (h) {\n var rest = [], len = arguments.length - 1;\n while ( len-- > 0 ) rest[ len ] = arguments[ len + 1 ];\n\n if (!rest.length && type$5(h) === 'string' && [3,4,5,6,7,8,9].indexOf(h.length) >= 0) {\n return 'hex';\n }\n }\n });\n\n var unpack$d = utils.unpack;\n var TWOPI = utils.TWOPI;\n var min = Math.min;\n var sqrt = Math.sqrt;\n var acos = Math.acos;\n\n var rgb2hsi = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n /*\n borrowed from here:\n http://hummer.stanford.edu/museinfo/doc/examples/humdrum/keyscape2/rgb2hsi.cpp\n */\n var ref = unpack$d(args, 'rgb');\n var r = ref[0];\n var g = ref[1];\n var b = ref[2];\n r /= 255;\n g /= 255;\n b /= 255;\n var h;\n var min_ = min(r,g,b);\n var i = (r+g+b) / 3;\n var s = i > 0 ? 1 - min_/i : 0;\n if (s === 0) {\n h = NaN;\n } else {\n h = ((r-g)+(r-b)) / 2;\n h /= sqrt((r-g)*(r-g) + (r-b)*(g-b));\n h = acos(h);\n if (b > g) {\n h = TWOPI - h;\n }\n h /= TWOPI;\n }\n return [h*360,s,i];\n };\n\n var rgb2hsi_1 = rgb2hsi;\n\n var unpack$e = utils.unpack;\n var limit$1 = utils.limit;\n var TWOPI$1 = utils.TWOPI;\n var PITHIRD = utils.PITHIRD;\n var cos = Math.cos;\n\n /*\n * hue [0..360]\n * saturation [0..1]\n * intensity [0..1]\n */\n var hsi2rgb = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n /*\n borrowed from here:\n http://hummer.stanford.edu/museinfo/doc/examples/humdrum/keyscape2/hsi2rgb.cpp\n */\n args = unpack$e(args, 'hsi');\n var h = args[0];\n var s = args[1];\n var i = args[2];\n var r,g,b;\n\n if (isNaN(h)) { h = 0; }\n if (isNaN(s)) { s = 0; }\n // normalize hue\n if (h > 360) { h -= 360; }\n if (h < 0) { h += 360; }\n h /= 360;\n if (h < 1/3) {\n b = (1-s)/3;\n r = (1+s*cos(TWOPI$1*h)/cos(PITHIRD-TWOPI$1*h))/3;\n g = 1 - (b+r);\n } else if (h < 2/3) {\n h -= 1/3;\n r = (1-s)/3;\n g = (1+s*cos(TWOPI$1*h)/cos(PITHIRD-TWOPI$1*h))/3;\n b = 1 - (r+g);\n } else {\n h -= 2/3;\n g = (1-s)/3;\n b = (1+s*cos(TWOPI$1*h)/cos(PITHIRD-TWOPI$1*h))/3;\n r = 1 - (g+b);\n }\n r = limit$1(i*r*3);\n g = limit$1(i*g*3);\n b = limit$1(i*b*3);\n return [r*255, g*255, b*255, args.length > 3 ? args[3] : 1];\n };\n\n var hsi2rgb_1 = hsi2rgb;\n\n var unpack$f = utils.unpack;\n var type$6 = utils.type;\n\n\n\n\n\n\n Color_1.prototype.hsi = function() {\n return rgb2hsi_1(this._rgb);\n };\n\n chroma_1.hsi = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['hsi']) ));\n };\n\n input.format.hsi = hsi2rgb_1;\n\n input.autodetect.push({\n p: 2,\n test: function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n args = unpack$f(args, 'hsi');\n if (type$6(args) === 'array' && args.length === 3) {\n return 'hsi';\n }\n }\n });\n\n var unpack$g = utils.unpack;\n var type$7 = utils.type;\n\n\n\n\n\n\n Color_1.prototype.hsl = function() {\n return rgb2hsl_1(this._rgb);\n };\n\n chroma_1.hsl = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['hsl']) ));\n };\n\n input.format.hsl = hsl2rgb_1;\n\n input.autodetect.push({\n p: 2,\n test: function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n args = unpack$g(args, 'hsl');\n if (type$7(args) === 'array' && args.length === 3) {\n return 'hsl';\n }\n }\n });\n\n var unpack$h = utils.unpack;\n var min$1 = Math.min;\n var max$1 = Math.max;\n\n /*\n * supported arguments:\n * - rgb2hsv(r,g,b)\n * - rgb2hsv([r,g,b])\n * - rgb2hsv({r,g,b})\n */\n var rgb2hsl$1 = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n args = unpack$h(args, 'rgb');\n var r = args[0];\n var g = args[1];\n var b = args[2];\n var min_ = min$1(r, g, b);\n var max_ = max$1(r, g, b);\n var delta = max_ - min_;\n var h,s,v;\n v = max_ / 255.0;\n if (max_ === 0) {\n h = Number.NaN;\n s = 0;\n } else {\n s = delta / max_;\n if (r === max_) { h = (g - b) / delta; }\n if (g === max_) { h = 2+(b - r) / delta; }\n if (b === max_) { h = 4+(r - g) / delta; }\n h *= 60;\n if (h < 0) { h += 360; }\n }\n return [h, s, v]\n };\n\n var rgb2hsv = rgb2hsl$1;\n\n var unpack$i = utils.unpack;\n var floor$1 = Math.floor;\n\n var hsv2rgb = function () {\n var assign, assign$1, assign$2, assign$3, assign$4, assign$5;\n\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n args = unpack$i(args, 'hsv');\n var h = args[0];\n var s = args[1];\n var v = args[2];\n var r,g,b;\n v *= 255;\n if (s === 0) {\n r = g = b = v;\n } else {\n if (h === 360) { h = 0; }\n if (h > 360) { h -= 360; }\n if (h < 0) { h += 360; }\n h /= 60;\n\n var i = floor$1(h);\n var f = h - i;\n var p = v * (1 - s);\n var q = v * (1 - s * f);\n var t = v * (1 - s * (1 - f));\n\n switch (i) {\n case 0: (assign = [v, t, p], r = assign[0], g = assign[1], b = assign[2]); break\n case 1: (assign$1 = [q, v, p], r = assign$1[0], g = assign$1[1], b = assign$1[2]); break\n case 2: (assign$2 = [p, v, t], r = assign$2[0], g = assign$2[1], b = assign$2[2]); break\n case 3: (assign$3 = [p, q, v], r = assign$3[0], g = assign$3[1], b = assign$3[2]); break\n case 4: (assign$4 = [t, p, v], r = assign$4[0], g = assign$4[1], b = assign$4[2]); break\n case 5: (assign$5 = [v, p, q], r = assign$5[0], g = assign$5[1], b = assign$5[2]); break\n }\n }\n return [r,g,b,args.length > 3?args[3]:1];\n };\n\n var hsv2rgb_1 = hsv2rgb;\n\n var unpack$j = utils.unpack;\n var type$8 = utils.type;\n\n\n\n\n\n\n Color_1.prototype.hsv = function() {\n return rgb2hsv(this._rgb);\n };\n\n chroma_1.hsv = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['hsv']) ));\n };\n\n input.format.hsv = hsv2rgb_1;\n\n input.autodetect.push({\n p: 2,\n test: function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n args = unpack$j(args, 'hsv');\n if (type$8(args) === 'array' && args.length === 3) {\n return 'hsv';\n }\n }\n });\n\n var labConstants = {\n // Corresponds roughly to RGB brighter/darker\n Kn: 18,\n\n // D65 standard referent\n Xn: 0.950470,\n Yn: 1,\n Zn: 1.088830,\n\n t0: 0.137931034, // 4 / 29\n t1: 0.206896552, // 6 / 29\n t2: 0.12841855, // 3 * t1 * t1\n t3: 0.008856452, // t1 * t1 * t1\n };\n\n var unpack$k = utils.unpack;\n var pow = Math.pow;\n\n var rgb2lab = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n var ref = unpack$k(args, 'rgb');\n var r = ref[0];\n var g = ref[1];\n var b = ref[2];\n var ref$1 = rgb2xyz(r,g,b);\n var x = ref$1[0];\n var y = ref$1[1];\n var z = ref$1[2];\n var l = 116 * y - 16;\n return [l < 0 ? 0 : l, 500 * (x - y), 200 * (y - z)];\n };\n\n var rgb_xyz = function (r) {\n if ((r /= 255) <= 0.04045) { return r / 12.92; }\n return pow((r + 0.055) / 1.055, 2.4);\n };\n\n var xyz_lab = function (t) {\n if (t > labConstants.t3) { return pow(t, 1 / 3); }\n return t / labConstants.t2 + labConstants.t0;\n };\n\n var rgb2xyz = function (r,g,b) {\n r = rgb_xyz(r);\n g = rgb_xyz(g);\n b = rgb_xyz(b);\n var x = xyz_lab((0.4124564 * r + 0.3575761 * g + 0.1804375 * b) / labConstants.Xn);\n var y = xyz_lab((0.2126729 * r + 0.7151522 * g + 0.0721750 * b) / labConstants.Yn);\n var z = xyz_lab((0.0193339 * r + 0.1191920 * g + 0.9503041 * b) / labConstants.Zn);\n return [x,y,z];\n };\n\n var rgb2lab_1 = rgb2lab;\n\n var unpack$l = utils.unpack;\n var pow$1 = Math.pow;\n\n /*\n * L* [0..100]\n * a [-100..100]\n * b [-100..100]\n */\n var lab2rgb = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n args = unpack$l(args, 'lab');\n var l = args[0];\n var a = args[1];\n var b = args[2];\n var x,y,z, r,g,b_;\n\n y = (l + 16) / 116;\n x = isNaN(a) ? y : y + a / 500;\n z = isNaN(b) ? y : y - b / 200;\n\n y = labConstants.Yn * lab_xyz(y);\n x = labConstants.Xn * lab_xyz(x);\n z = labConstants.Zn * lab_xyz(z);\n\n r = xyz_rgb(3.2404542 * x - 1.5371385 * y - 0.4985314 * z); // D65 -> sRGB\n g = xyz_rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z);\n b_ = xyz_rgb(0.0556434 * x - 0.2040259 * y + 1.0572252 * z);\n\n return [r,g,b_,args.length > 3 ? args[3] : 1];\n };\n\n var xyz_rgb = function (r) {\n return 255 * (r <= 0.00304 ? 12.92 * r : 1.055 * pow$1(r, 1 / 2.4) - 0.055)\n };\n\n var lab_xyz = function (t) {\n return t > labConstants.t1 ? t * t * t : labConstants.t2 * (t - labConstants.t0)\n };\n\n var lab2rgb_1 = lab2rgb;\n\n var unpack$m = utils.unpack;\n var type$9 = utils.type;\n\n\n\n\n\n\n Color_1.prototype.lab = function() {\n return rgb2lab_1(this._rgb);\n };\n\n chroma_1.lab = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['lab']) ));\n };\n\n input.format.lab = lab2rgb_1;\n\n input.autodetect.push({\n p: 2,\n test: function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n args = unpack$m(args, 'lab');\n if (type$9(args) === 'array' && args.length === 3) {\n return 'lab';\n }\n }\n });\n\n var unpack$n = utils.unpack;\n var RAD2DEG = utils.RAD2DEG;\n var sqrt$1 = Math.sqrt;\n var atan2 = Math.atan2;\n var round$4 = Math.round;\n\n var lab2lch = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n var ref = unpack$n(args, 'lab');\n var l = ref[0];\n var a = ref[1];\n var b = ref[2];\n var c = sqrt$1(a * a + b * b);\n var h = (atan2(b, a) * RAD2DEG + 360) % 360;\n if (round$4(c*10000) === 0) { h = Number.NaN; }\n return [l, c, h];\n };\n\n var lab2lch_1 = lab2lch;\n\n var unpack$o = utils.unpack;\n\n\n\n var rgb2lch = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n var ref = unpack$o(args, 'rgb');\n var r = ref[0];\n var g = ref[1];\n var b = ref[2];\n var ref$1 = rgb2lab_1(r,g,b);\n var l = ref$1[0];\n var a = ref$1[1];\n var b_ = ref$1[2];\n return lab2lch_1(l,a,b_);\n };\n\n var rgb2lch_1 = rgb2lch;\n\n var unpack$p = utils.unpack;\n var DEG2RAD = utils.DEG2RAD;\n var sin = Math.sin;\n var cos$1 = Math.cos;\n\n var lch2lab = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n /*\n Convert from a qualitative parameter h and a quantitative parameter l to a 24-bit pixel.\n These formulas were invented by David Dalrymple to obtain maximum contrast without going\n out of gamut if the parameters are in the range 0-1.\n\n A saturation multiplier was added by Gregor Aisch\n */\n var ref = unpack$p(args, 'lch');\n var l = ref[0];\n var c = ref[1];\n var h = ref[2];\n if (isNaN(h)) { h = 0; }\n h = h * DEG2RAD;\n return [l, cos$1(h) * c, sin(h) * c]\n };\n\n var lch2lab_1 = lch2lab;\n\n var unpack$q = utils.unpack;\n\n\n\n var lch2rgb = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n args = unpack$q(args, 'lch');\n var l = args[0];\n var c = args[1];\n var h = args[2];\n var ref = lch2lab_1 (l,c,h);\n var L = ref[0];\n var a = ref[1];\n var b_ = ref[2];\n var ref$1 = lab2rgb_1 (L,a,b_);\n var r = ref$1[0];\n var g = ref$1[1];\n var b = ref$1[2];\n return [r, g, b, args.length > 3 ? args[3] : 1];\n };\n\n var lch2rgb_1 = lch2rgb;\n\n var unpack$r = utils.unpack;\n\n\n var hcl2rgb = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n var hcl = unpack$r(args, 'hcl').reverse();\n return lch2rgb_1.apply(void 0, hcl);\n };\n\n var hcl2rgb_1 = hcl2rgb;\n\n var unpack$s = utils.unpack;\n var type$a = utils.type;\n\n\n\n\n\n\n Color_1.prototype.lch = function() { return rgb2lch_1(this._rgb); };\n Color_1.prototype.hcl = function() { return rgb2lch_1(this._rgb).reverse(); };\n\n chroma_1.lch = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['lch']) ));\n };\n chroma_1.hcl = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['hcl']) ));\n };\n\n input.format.lch = lch2rgb_1;\n input.format.hcl = hcl2rgb_1;\n\n ['lch','hcl'].forEach(function (m) { return input.autodetect.push({\n p: 2,\n test: function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n args = unpack$s(args, m);\n if (type$a(args) === 'array' && args.length === 3) {\n return m;\n }\n }\n }); });\n\n /**\n \tX11 color names\n\n \thttp://www.w3.org/TR/css3-color/#svg-color\n */\n\n var w3cx11 = {\n aliceblue: '#f0f8ff',\n antiquewhite: '#faebd7',\n aqua: '#00ffff',\n aquamarine: '#7fffd4',\n azure: '#f0ffff',\n beige: '#f5f5dc',\n bisque: '#ffe4c4',\n black: '#000000',\n blanchedalmond: '#ffebcd',\n blue: '#0000ff',\n blueviolet: '#8a2be2',\n brown: '#a52a2a',\n burlywood: '#deb887',\n cadetblue: '#5f9ea0',\n chartreuse: '#7fff00',\n chocolate: '#d2691e',\n coral: '#ff7f50',\n cornflower: '#6495ed',\n cornflowerblue: '#6495ed',\n cornsilk: '#fff8dc',\n crimson: '#dc143c',\n cyan: '#00ffff',\n darkblue: '#00008b',\n darkcyan: '#008b8b',\n darkgoldenrod: '#b8860b',\n darkgray: '#a9a9a9',\n darkgreen: '#006400',\n darkgrey: '#a9a9a9',\n darkkhaki: '#bdb76b',\n darkmagenta: '#8b008b',\n darkolivegreen: '#556b2f',\n darkorange: '#ff8c00',\n darkorchid: '#9932cc',\n darkred: '#8b0000',\n darksalmon: '#e9967a',\n darkseagreen: '#8fbc8f',\n darkslateblue: '#483d8b',\n darkslategray: '#2f4f4f',\n darkslategrey: '#2f4f4f',\n darkturquoise: '#00ced1',\n darkviolet: '#9400d3',\n deeppink: '#ff1493',\n deepskyblue: '#00bfff',\n dimgray: '#696969',\n dimgrey: '#696969',\n dodgerblue: '#1e90ff',\n firebrick: '#b22222',\n floralwhite: '#fffaf0',\n forestgreen: '#228b22',\n fuchsia: '#ff00ff',\n gainsboro: '#dcdcdc',\n ghostwhite: '#f8f8ff',\n gold: '#ffd700',\n goldenrod: '#daa520',\n gray: '#808080',\n green: '#008000',\n greenyellow: '#adff2f',\n grey: '#808080',\n honeydew: '#f0fff0',\n hotpink: '#ff69b4',\n indianred: '#cd5c5c',\n indigo: '#4b0082',\n ivory: '#fffff0',\n khaki: '#f0e68c',\n laserlemon: '#ffff54',\n lavender: '#e6e6fa',\n lavenderblush: '#fff0f5',\n lawngreen: '#7cfc00',\n lemonchiffon: '#fffacd',\n lightblue: '#add8e6',\n lightcoral: '#f08080',\n lightcyan: '#e0ffff',\n lightgoldenrod: '#fafad2',\n lightgoldenrodyellow: '#fafad2',\n lightgray: '#d3d3d3',\n lightgreen: '#90ee90',\n lightgrey: '#d3d3d3',\n lightpink: '#ffb6c1',\n lightsalmon: '#ffa07a',\n lightseagreen: '#20b2aa',\n lightskyblue: '#87cefa',\n lightslategray: '#778899',\n lightslategrey: '#778899',\n lightsteelblue: '#b0c4de',\n lightyellow: '#ffffe0',\n lime: '#00ff00',\n limegreen: '#32cd32',\n linen: '#faf0e6',\n magenta: '#ff00ff',\n maroon: '#800000',\n maroon2: '#7f0000',\n maroon3: '#b03060',\n mediumaquamarine: '#66cdaa',\n mediumblue: '#0000cd',\n mediumorchid: '#ba55d3',\n mediumpurple: '#9370db',\n mediumseagreen: '#3cb371',\n mediumslateblue: '#7b68ee',\n mediumspringgreen: '#00fa9a',\n mediumturquoise: '#48d1cc',\n mediumvioletred: '#c71585',\n midnightblue: '#191970',\n mintcream: '#f5fffa',\n mistyrose: '#ffe4e1',\n moccasin: '#ffe4b5',\n navajowhite: '#ffdead',\n navy: '#000080',\n oldlace: '#fdf5e6',\n olive: '#808000',\n olivedrab: '#6b8e23',\n orange: '#ffa500',\n orangered: '#ff4500',\n orchid: '#da70d6',\n palegoldenrod: '#eee8aa',\n palegreen: '#98fb98',\n paleturquoise: '#afeeee',\n palevioletred: '#db7093',\n papayawhip: '#ffefd5',\n peachpuff: '#ffdab9',\n peru: '#cd853f',\n pink: '#ffc0cb',\n plum: '#dda0dd',\n powderblue: '#b0e0e6',\n purple: '#800080',\n purple2: '#7f007f',\n purple3: '#a020f0',\n rebeccapurple: '#663399',\n red: '#ff0000',\n rosybrown: '#bc8f8f',\n royalblue: '#4169e1',\n saddlebrown: '#8b4513',\n salmon: '#fa8072',\n sandybrown: '#f4a460',\n seagreen: '#2e8b57',\n seashell: '#fff5ee',\n sienna: '#a0522d',\n silver: '#c0c0c0',\n skyblue: '#87ceeb',\n slateblue: '#6a5acd',\n slategray: '#708090',\n slategrey: '#708090',\n snow: '#fffafa',\n springgreen: '#00ff7f',\n steelblue: '#4682b4',\n tan: '#d2b48c',\n teal: '#008080',\n thistle: '#d8bfd8',\n tomato: '#ff6347',\n turquoise: '#40e0d0',\n violet: '#ee82ee',\n wheat: '#f5deb3',\n white: '#ffffff',\n whitesmoke: '#f5f5f5',\n yellow: '#ffff00',\n yellowgreen: '#9acd32'\n };\n\n var w3cx11_1 = w3cx11;\n\n var type$b = utils.type;\n\n\n\n\n\n Color_1.prototype.name = function() {\n var hex = rgb2hex_1(this._rgb, 'rgb');\n for (var i = 0, list = Object.keys(w3cx11_1); i < list.length; i += 1) {\n var n = list[i];\n\n if (w3cx11_1[n] === hex) { return n.toLowerCase(); }\n }\n return hex;\n };\n\n input.format.named = function (name) {\n name = name.toLowerCase();\n if (w3cx11_1[name]) { return hex2rgb_1(w3cx11_1[name]); }\n throw new Error('unknown color name: '+name);\n };\n\n input.autodetect.push({\n p: 5,\n test: function (h) {\n var rest = [], len = arguments.length - 1;\n while ( len-- > 0 ) rest[ len ] = arguments[ len + 1 ];\n\n if (!rest.length && type$b(h) === 'string' && w3cx11_1[h.toLowerCase()]) {\n return 'named';\n }\n }\n });\n\n var unpack$t = utils.unpack;\n\n var rgb2num = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n var ref = unpack$t(args, 'rgb');\n var r = ref[0];\n var g = ref[1];\n var b = ref[2];\n return (r << 16) + (g << 8) + b;\n };\n\n var rgb2num_1 = rgb2num;\n\n var type$c = utils.type;\n\n var num2rgb = function (num) {\n if (type$c(num) == \"number\" && num >= 0 && num <= 0xFFFFFF) {\n var r = num >> 16;\n var g = (num >> 8) & 0xFF;\n var b = num & 0xFF;\n return [r,g,b,1];\n }\n throw new Error(\"unknown num color: \"+num);\n };\n\n var num2rgb_1 = num2rgb;\n\n var type$d = utils.type;\n\n\n\n Color_1.prototype.num = function() {\n return rgb2num_1(this._rgb);\n };\n\n chroma_1.num = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['num']) ));\n };\n\n input.format.num = num2rgb_1;\n\n input.autodetect.push({\n p: 5,\n test: function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n if (args.length === 1 && type$d(args[0]) === 'number' && args[0] >= 0 && args[0] <= 0xFFFFFF) {\n return 'num';\n }\n }\n });\n\n var unpack$u = utils.unpack;\n var type$e = utils.type;\n var round$5 = Math.round;\n\n Color_1.prototype.rgb = function(rnd) {\n if ( rnd === void 0 ) rnd=true;\n\n if (rnd === false) { return this._rgb.slice(0,3); }\n return this._rgb.slice(0,3).map(round$5);\n };\n\n Color_1.prototype.rgba = function(rnd) {\n if ( rnd === void 0 ) rnd=true;\n\n return this._rgb.slice(0,4).map(function (v,i) {\n return i<3 ? (rnd === false ? v : round$5(v)) : v;\n });\n };\n\n chroma_1.rgb = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['rgb']) ));\n };\n\n input.format.rgb = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n var rgba = unpack$u(args, 'rgba');\n if (rgba[3] === undefined) { rgba[3] = 1; }\n return rgba;\n };\n\n input.autodetect.push({\n p: 3,\n test: function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n args = unpack$u(args, 'rgba');\n if (type$e(args) === 'array' && (args.length === 3 ||\n args.length === 4 && type$e(args[3]) == 'number' && args[3] >= 0 && args[3] <= 1)) {\n return 'rgb';\n }\n }\n });\n\n /*\n * Based on implementation by Neil Bartlett\n * https://github.com/neilbartlett/color-temperature\n */\n\n var log = Math.log;\n\n var temperature2rgb = function (kelvin) {\n var temp = kelvin / 100;\n var r,g,b;\n if (temp < 66) {\n r = 255;\n g = -155.25485562709179 - 0.44596950469579133 * (g = temp-2) + 104.49216199393888 * log(g);\n b = temp < 20 ? 0 : -254.76935184120902 + 0.8274096064007395 * (b = temp-10) + 115.67994401066147 * log(b);\n } else {\n r = 351.97690566805693 + 0.114206453784165 * (r = temp-55) - 40.25366309332127 * log(r);\n g = 325.4494125711974 + 0.07943456536662342 * (g = temp-50) - 28.0852963507957 * log(g);\n b = 255;\n }\n return [r,g,b,1];\n };\n\n var temperature2rgb_1 = temperature2rgb;\n\n /*\n * Based on implementation by Neil Bartlett\n * https://github.com/neilbartlett/color-temperature\n **/\n\n\n var unpack$v = utils.unpack;\n var round$6 = Math.round;\n\n var rgb2temperature = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n var rgb = unpack$v(args, 'rgb');\n var r = rgb[0], b = rgb[2];\n var minTemp = 1000;\n var maxTemp = 40000;\n var eps = 0.4;\n var temp;\n while (maxTemp - minTemp > eps) {\n temp = (maxTemp + minTemp) * 0.5;\n var rgb$1 = temperature2rgb_1(temp);\n if ((rgb$1[2] / rgb$1[0]) >= (b / r)) {\n maxTemp = temp;\n } else {\n minTemp = temp;\n }\n }\n return round$6(temp);\n };\n\n var rgb2temperature_1 = rgb2temperature;\n\n Color_1.prototype.temp =\n Color_1.prototype.kelvin =\n Color_1.prototype.temperature = function() {\n return rgb2temperature_1(this._rgb);\n };\n\n chroma_1.temp =\n chroma_1.kelvin =\n chroma_1.temperature = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n return new (Function.prototype.bind.apply( Color_1, [ null ].concat( args, ['temp']) ));\n };\n\n input.format.temp =\n input.format.kelvin =\n input.format.temperature = temperature2rgb_1;\n\n var type$f = utils.type;\n\n Color_1.prototype.alpha = function(a, mutate) {\n if ( mutate === void 0 ) mutate=false;\n\n if (a !== undefined && type$f(a) === 'number') {\n if (mutate) {\n this._rgb[3] = a;\n return this;\n }\n return new Color_1([this._rgb[0], this._rgb[1], this._rgb[2], a], 'rgb');\n }\n return this._rgb[3];\n };\n\n Color_1.prototype.clipped = function() {\n return this._rgb._clipped || false;\n };\n\n Color_1.prototype.darken = function(amount) {\n \tif ( amount === void 0 ) amount=1;\n\n \tvar me = this;\n \tvar lab = me.lab();\n \tlab[0] -= labConstants.Kn * amount;\n \treturn new Color_1(lab, 'lab').alpha(me.alpha(), true);\n };\n\n Color_1.prototype.brighten = function(amount) {\n \tif ( amount === void 0 ) amount=1;\n\n \treturn this.darken(-amount);\n };\n\n Color_1.prototype.darker = Color_1.prototype.darken;\n Color_1.prototype.brighter = Color_1.prototype.brighten;\n\n Color_1.prototype.get = function(mc) {\n var ref = mc.split('.');\n var mode = ref[0];\n var channel = ref[1];\n var src = this[mode]();\n if (channel) {\n var i = mode.indexOf(channel);\n if (i > -1) { return src[i]; }\n throw new Error((\"unknown channel \" + channel + \" in mode \" + mode));\n } else {\n return src;\n }\n };\n\n var type$g = utils.type;\n var pow$2 = Math.pow;\n\n var EPS = 1e-7;\n var MAX_ITER = 20;\n\n Color_1.prototype.luminance = function(lum) {\n if (lum !== undefined && type$g(lum) === 'number') {\n if (lum === 0) {\n // return pure black\n return new Color_1([0,0,0,this._rgb[3]], 'rgb');\n }\n if (lum === 1) {\n // return pure white\n return new Color_1([255,255,255,this._rgb[3]], 'rgb');\n }\n // compute new color using...\n var cur_lum = this.luminance();\n var mode = 'rgb';\n var max_iter = MAX_ITER;\n\n var test = function (low, high) {\n var mid = low.interpolate(high, 0.5, mode);\n var lm = mid.luminance();\n if (Math.abs(lum - lm) < EPS || !max_iter--) {\n // close enough\n return mid;\n }\n return lm > lum ? test(low, mid) : test(mid, high);\n };\n\n var rgb = (cur_lum > lum ? test(new Color_1([0,0,0]), this) : test(this, new Color_1([255,255,255]))).rgb();\n return new Color_1(rgb.concat( [this._rgb[3]]));\n }\n return rgb2luminance.apply(void 0, (this._rgb).slice(0,3));\n };\n\n\n var rgb2luminance = function (r,g,b) {\n // relative luminance\n // see http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef\n r = luminance_x(r);\n g = luminance_x(g);\n b = luminance_x(b);\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n };\n\n var luminance_x = function (x) {\n x /= 255;\n return x <= 0.03928 ? x/12.92 : pow$2((x+0.055)/1.055, 2.4);\n };\n\n var interpolator = {};\n\n var type$h = utils.type;\n\n\n var mix = function (col1, col2, f) {\n if ( f === void 0 ) f=0.5;\n var rest = [], len = arguments.length - 3;\n while ( len-- > 0 ) rest[ len ] = arguments[ len + 3 ];\n\n var mode = rest[0] || 'lrgb';\n if (!interpolator[mode] && !rest.length) {\n // fall back to the first supported mode\n mode = Object.keys(interpolator)[0];\n }\n if (!interpolator[mode]) {\n throw new Error((\"interpolation mode \" + mode + \" is not defined\"));\n }\n if (type$h(col1) !== 'object') { col1 = new Color_1(col1); }\n if (type$h(col2) !== 'object') { col2 = new Color_1(col2); }\n return interpolator[mode](col1, col2, f)\n .alpha(col1.alpha() + f * (col2.alpha() - col1.alpha()));\n };\n\n Color_1.prototype.mix =\n Color_1.prototype.interpolate = function(col2, f) {\n \tif ( f === void 0 ) f=0.5;\n \tvar rest = [], len = arguments.length - 2;\n \twhile ( len-- > 0 ) rest[ len ] = arguments[ len + 2 ];\n\n \treturn mix.apply(void 0, [ this, col2, f ].concat( rest ));\n };\n\n Color_1.prototype.premultiply = function(mutate) {\n \tif ( mutate === void 0 ) mutate=false;\n\n \tvar rgb = this._rgb;\n \tvar a = rgb[3];\n \tif (mutate) {\n \t\tthis._rgb = [rgb[0]*a, rgb[1]*a, rgb[2]*a, a];\n \t\treturn this;\n \t} else {\n \t\treturn new Color_1([rgb[0]*a, rgb[1]*a, rgb[2]*a, a], 'rgb');\n \t}\n };\n\n Color_1.prototype.saturate = function(amount) {\n \tif ( amount === void 0 ) amount=1;\n\n \tvar me = this;\n \tvar lch = me.lch();\n \tlch[1] += labConstants.Kn * amount;\n \tif (lch[1] < 0) { lch[1] = 0; }\n \treturn new Color_1(lch, 'lch').alpha(me.alpha(), true);\n };\n\n Color_1.prototype.desaturate = function(amount) {\n \tif ( amount === void 0 ) amount=1;\n\n \treturn this.saturate(-amount);\n };\n\n var type$i = utils.type;\n\n Color_1.prototype.set = function(mc, value, mutate) {\n if ( mutate === void 0 ) mutate=false;\n\n var ref = mc.split('.');\n var mode = ref[0];\n var channel = ref[1];\n var src = this[mode]();\n if (channel) {\n var i = mode.indexOf(channel);\n if (i > -1) {\n if (type$i(value) == 'string') {\n switch(value.charAt(0)) {\n case '+': src[i] += +value; break;\n case '-': src[i] += +value; break;\n case '*': src[i] *= +(value.substr(1)); break;\n case '/': src[i] /= +(value.substr(1)); break;\n default: src[i] = +value;\n }\n } else if (type$i(value) === 'number') {\n src[i] = value;\n } else {\n throw new Error(\"unsupported value for Color.set\");\n }\n var out = new Color_1(src, mode);\n if (mutate) {\n this._rgb = out._rgb;\n return this;\n }\n return out;\n }\n throw new Error((\"unknown channel \" + channel + \" in mode \" + mode));\n } else {\n return src;\n }\n };\n\n var rgb$1 = function (col1, col2, f) {\n var xyz0 = col1._rgb;\n var xyz1 = col2._rgb;\n return new Color_1(\n xyz0[0] + f * (xyz1[0]-xyz0[0]),\n xyz0[1] + f * (xyz1[1]-xyz0[1]),\n xyz0[2] + f * (xyz1[2]-xyz0[2]),\n 'rgb'\n )\n };\n\n // register interpolator\n interpolator.rgb = rgb$1;\n\n var sqrt$2 = Math.sqrt;\n var pow$3 = Math.pow;\n\n var lrgb = function (col1, col2, f) {\n var ref = col1._rgb;\n var x1 = ref[0];\n var y1 = ref[1];\n var z1 = ref[2];\n var ref$1 = col2._rgb;\n var x2 = ref$1[0];\n var y2 = ref$1[1];\n var z2 = ref$1[2];\n return new Color_1(\n sqrt$2(pow$3(x1,2) * (1-f) + pow$3(x2,2) * f),\n sqrt$2(pow$3(y1,2) * (1-f) + pow$3(y2,2) * f),\n sqrt$2(pow$3(z1,2) * (1-f) + pow$3(z2,2) * f),\n 'rgb'\n )\n };\n\n // register interpolator\n interpolator.lrgb = lrgb;\n\n var lab$1 = function (col1, col2, f) {\n var xyz0 = col1.lab();\n var xyz1 = col2.lab();\n return new Color_1(\n xyz0[0] + f * (xyz1[0]-xyz0[0]),\n xyz0[1] + f * (xyz1[1]-xyz0[1]),\n xyz0[2] + f * (xyz1[2]-xyz0[2]),\n 'lab'\n )\n };\n\n // register interpolator\n interpolator.lab = lab$1;\n\n var _hsx = function (col1, col2, f, m) {\n var assign, assign$1;\n\n var xyz0, xyz1;\n if (m === 'hsl') {\n xyz0 = col1.hsl();\n xyz1 = col2.hsl();\n } else if (m === 'hsv') {\n xyz0 = col1.hsv();\n xyz1 = col2.hsv();\n } else if (m === 'hcg') {\n xyz0 = col1.hcg();\n xyz1 = col2.hcg();\n } else if (m === 'hsi') {\n xyz0 = col1.hsi();\n xyz1 = col2.hsi();\n } else if (m === 'lch' || m === 'hcl') {\n m = 'hcl';\n xyz0 = col1.hcl();\n xyz1 = col2.hcl();\n }\n\n var hue0, hue1, sat0, sat1, lbv0, lbv1;\n if (m.substr(0, 1) === 'h') {\n (assign = xyz0, hue0 = assign[0], sat0 = assign[1], lbv0 = assign[2]);\n (assign$1 = xyz1, hue1 = assign$1[0], sat1 = assign$1[1], lbv1 = assign$1[2]);\n }\n\n var sat, hue, lbv, dh;\n\n if (!isNaN(hue0) && !isNaN(hue1)) {\n // both colors have hue\n if (hue1 > hue0 && hue1 - hue0 > 180) {\n dh = hue1-(hue0+360);\n } else if (hue1 < hue0 && hue0 - hue1 > 180) {\n dh = hue1+360-hue0;\n } else{\n dh = hue1 - hue0;\n }\n hue = hue0 + f * dh;\n } else if (!isNaN(hue0)) {\n hue = hue0;\n if ((lbv1 == 1 || lbv1 == 0) && m != 'hsv') { sat = sat0; }\n } else if (!isNaN(hue1)) {\n hue = hue1;\n if ((lbv0 == 1 || lbv0 == 0) && m != 'hsv') { sat = sat1; }\n } else {\n hue = Number.NaN;\n }\n\n if (sat === undefined) { sat = sat0 + f * (sat1 - sat0); }\n lbv = lbv0 + f * (lbv1-lbv0);\n return new Color_1([hue, sat, lbv], m);\n };\n\n var lch$1 = function (col1, col2, f) {\n \treturn _hsx(col1, col2, f, 'lch');\n };\n\n // register interpolator\n interpolator.lch = lch$1;\n interpolator.hcl = lch$1;\n\n var num$1 = function (col1, col2, f) {\n var c1 = col1.num();\n var c2 = col2.num();\n return new Color_1(c1 + f * (c2-c1), 'num')\n };\n\n // register interpolator\n interpolator.num = num$1;\n\n var hcg$1 = function (col1, col2, f) {\n \treturn _hsx(col1, col2, f, 'hcg');\n };\n\n // register interpolator\n interpolator.hcg = hcg$1;\n\n var hsi$1 = function (col1, col2, f) {\n \treturn _hsx(col1, col2, f, 'hsi');\n };\n\n // register interpolator\n interpolator.hsi = hsi$1;\n\n var hsl$1 = function (col1, col2, f) {\n \treturn _hsx(col1, col2, f, 'hsl');\n };\n\n // register interpolator\n interpolator.hsl = hsl$1;\n\n var hsv$1 = function (col1, col2, f) {\n \treturn _hsx(col1, col2, f, 'hsv');\n };\n\n // register interpolator\n interpolator.hsv = hsv$1;\n\n var clip_rgb$2 = utils.clip_rgb;\n var pow$4 = Math.pow;\n var sqrt$3 = Math.sqrt;\n var PI$1 = Math.PI;\n var cos$2 = Math.cos;\n var sin$1 = Math.sin;\n var atan2$1 = Math.atan2;\n\n var average = function (colors, mode, weights) {\n if ( mode === void 0 ) mode='lrgb';\n if ( weights === void 0 ) weights=null;\n\n var l = colors.length;\n if (!weights) { weights = Array.from(new Array(l)).map(function () { return 1; }); }\n // normalize weights\n var k = l / weights.reduce(function(a, b) { return a + b; });\n weights.forEach(function (w,i) { weights[i] *= k; });\n // convert colors to Color objects\n colors = colors.map(function (c) { return new Color_1(c); });\n if (mode === 'lrgb') {\n return _average_lrgb(colors, weights)\n }\n var first = colors.shift();\n var xyz = first.get(mode);\n var cnt = [];\n var dx = 0;\n var dy = 0;\n // initial color\n for (var i=0; i= 360) { A$1 -= 360; }\n xyz[i$1] = A$1;\n } else {\n xyz[i$1] = xyz[i$1]/cnt[i$1];\n }\n }\n alpha /= l;\n return (new Color_1(xyz, mode)).alpha(alpha > 0.99999 ? 1 : alpha, true);\n };\n\n\n var _average_lrgb = function (colors, weights) {\n var l = colors.length;\n var xyz = [0,0,0,0];\n for (var i=0; i < colors.length; i++) {\n var col = colors[i];\n var f = weights[i] / l;\n var rgb = col._rgb;\n xyz[0] += pow$4(rgb[0],2) * f;\n xyz[1] += pow$4(rgb[1],2) * f;\n xyz[2] += pow$4(rgb[2],2) * f;\n xyz[3] += rgb[3] * f;\n }\n xyz[0] = sqrt$3(xyz[0]);\n xyz[1] = sqrt$3(xyz[1]);\n xyz[2] = sqrt$3(xyz[2]);\n if (xyz[3] > 0.9999999) { xyz[3] = 1; }\n return new Color_1(clip_rgb$2(xyz));\n };\n\n // minimal multi-purpose interface\n\n // @requires utils color analyze\n\n\n var type$j = utils.type;\n\n var pow$5 = Math.pow;\n\n var scale = function(colors) {\n\n // constructor\n var _mode = 'rgb';\n var _nacol = chroma_1('#ccc');\n var _spread = 0;\n // const _fixed = false;\n var _domain = [0, 1];\n var _pos = [];\n var _padding = [0,0];\n var _classes = false;\n var _colors = [];\n var _out = false;\n var _min = 0;\n var _max = 1;\n var _correctLightness = false;\n var _colorCache = {};\n var _useCache = true;\n var _gamma = 1;\n\n // private methods\n\n var setColors = function(colors) {\n colors = colors || ['#fff', '#000'];\n if (colors && type$j(colors) === 'string' && chroma_1.brewer &&\n chroma_1.brewer[colors.toLowerCase()]) {\n colors = chroma_1.brewer[colors.toLowerCase()];\n }\n if (type$j(colors) === 'array') {\n // handle single color\n if (colors.length === 1) {\n colors = [colors[0], colors[0]];\n }\n // make a copy of the colors\n colors = colors.slice(0);\n // convert to chroma classes\n for (var c=0; c= _classes[i]) {\n i++;\n }\n return i-1;\n }\n return 0;\n };\n\n var tMapLightness = function (t) { return t; };\n var tMapDomain = function (t) { return t; };\n\n // const classifyValue = function(value) {\n // let val = value;\n // if (_classes.length > 2) {\n // const n = _classes.length-1;\n // const i = getClass(value);\n // const minc = _classes[0] + ((_classes[1]-_classes[0]) * (0 + (_spread * 0.5))); // center of 1st class\n // const maxc = _classes[n-1] + ((_classes[n]-_classes[n-1]) * (1 - (_spread * 0.5))); // center of last class\n // val = _min + ((((_classes[i] + ((_classes[i+1] - _classes[i]) * 0.5)) - minc) / (maxc-minc)) * (_max - _min));\n // }\n // return val;\n // };\n\n var getColor = function(val, bypassMap) {\n var col, t;\n if (bypassMap == null) { bypassMap = false; }\n if (isNaN(val) || (val === null)) { return _nacol; }\n if (!bypassMap) {\n if (_classes && (_classes.length > 2)) {\n // find the class\n var c = getClass(val);\n t = c / (_classes.length-2);\n } else if (_max !== _min) {\n // just interpolate between min/max\n t = (val - _min) / (_max - _min);\n } else {\n t = 1;\n }\n } else {\n t = val;\n }\n\n // domain map\n t = tMapDomain(t);\n\n if (!bypassMap) {\n t = tMapLightness(t); // lightness correction\n }\n\n if (_gamma !== 1) { t = pow$5(t, _gamma); }\n\n t = _padding[0] + (t * (1 - _padding[0] - _padding[1]));\n\n t = Math.min(1, Math.max(0, t));\n\n var k = Math.floor(t * 10000);\n\n if (_useCache && _colorCache[k]) {\n col = _colorCache[k];\n } else {\n if (type$j(_colors) === 'array') {\n //for i in [0.._pos.length-1]\n for (var i=0; i<_pos.length; i++) {\n var p = _pos[i];\n if (t <= p) {\n col = _colors[i];\n break;\n }\n if ((t >= p) && (i === (_pos.length-1))) {\n col = _colors[i];\n break;\n }\n if (t > p && t < _pos[i+1]) {\n t = (t-p)/(_pos[i+1]-p);\n col = chroma_1.interpolate(_colors[i], _colors[i+1], t, _mode);\n break;\n }\n }\n } else if (type$j(_colors) === 'function') {\n col = _colors(t);\n }\n if (_useCache) { _colorCache[k] = col; }\n }\n return col;\n };\n\n var resetCache = function () { return _colorCache = {}; };\n\n setColors(colors);\n\n // public interface\n\n var f = function(v) {\n var c = chroma_1(getColor(v));\n if (_out && c[_out]) { return c[_out](); } else { return c; }\n };\n\n f.classes = function(classes) {\n if (classes != null) {\n if (type$j(classes) === 'array') {\n _classes = classes;\n _domain = [classes[0], classes[classes.length-1]];\n } else {\n var d = chroma_1.analyze(_domain);\n if (classes === 0) {\n _classes = [d.min, d.max];\n } else {\n _classes = chroma_1.limits(d, 'e', classes);\n }\n }\n return f;\n }\n return _classes;\n };\n\n\n f.domain = function(domain) {\n if (!arguments.length) {\n return _domain;\n }\n _min = domain[0];\n _max = domain[domain.length-1];\n _pos = [];\n var k = _colors.length;\n if ((domain.length === k) && (_min !== _max)) {\n // update positions\n for (var i = 0, list = Array.from(domain); i < list.length; i += 1) {\n var d = list[i];\n\n _pos.push((d-_min) / (_max-_min));\n }\n } else {\n for (var c=0; c 2) {\n // set domain map\n var tOut = domain.map(function (d,i) { return i/(domain.length-1); });\n var tBreaks = domain.map(function (d) { return (d - _min) / (_max - _min); });\n if (!tBreaks.every(function (val, i) { return tOut[i] === val; })) {\n tMapDomain = function (t) {\n if (t <= 0 || t >= 1) { return t; }\n var i = 0;\n while (t >= tBreaks[i+1]) { i++; }\n var f = (t - tBreaks[i]) / (tBreaks[i+1] - tBreaks[i]);\n var out = tOut[i] + f * (tOut[i+1] - tOut[i]);\n return out;\n };\n }\n\n }\n }\n _domain = [_min, _max];\n return f;\n };\n\n f.mode = function(_m) {\n if (!arguments.length) {\n return _mode;\n }\n _mode = _m;\n resetCache();\n return f;\n };\n\n f.range = function(colors, _pos) {\n setColors(colors, _pos);\n return f;\n };\n\n f.out = function(_o) {\n _out = _o;\n return f;\n };\n\n f.spread = function(val) {\n if (!arguments.length) {\n return _spread;\n }\n _spread = val;\n return f;\n };\n\n f.correctLightness = function(v) {\n if (v == null) { v = true; }\n _correctLightness = v;\n resetCache();\n if (_correctLightness) {\n tMapLightness = function(t) {\n var L0 = getColor(0, true).lab()[0];\n var L1 = getColor(1, true).lab()[0];\n var pol = L0 > L1;\n var L_actual = getColor(t, true).lab()[0];\n var L_ideal = L0 + ((L1 - L0) * t);\n var L_diff = L_actual - L_ideal;\n var t0 = 0;\n var t1 = 1;\n var max_iter = 20;\n while ((Math.abs(L_diff) > 1e-2) && (max_iter-- > 0)) {\n (function() {\n if (pol) { L_diff *= -1; }\n if (L_diff < 0) {\n t0 = t;\n t += (t1 - t) * 0.5;\n } else {\n t1 = t;\n t += (t0 - t) * 0.5;\n }\n L_actual = getColor(t, true).lab()[0];\n return L_diff = L_actual - L_ideal;\n })();\n }\n return t;\n };\n } else {\n tMapLightness = function (t) { return t; };\n }\n return f;\n };\n\n f.padding = function(p) {\n if (p != null) {\n if (type$j(p) === 'number') {\n p = [p,p];\n }\n _padding = p;\n return f;\n } else {\n return _padding;\n }\n };\n\n f.colors = function(numColors, out) {\n // If no arguments are given, return the original colors that were provided\n if (arguments.length < 2) { out = 'hex'; }\n var result = [];\n\n if (arguments.length === 0) {\n result = _colors.slice(0);\n\n } else if (numColors === 1) {\n result = [f(0.5)];\n\n } else if (numColors > 1) {\n var dm = _domain[0];\n var dd = _domain[1] - dm;\n result = __range__(0, numColors, false).map(function (i) { return f( dm + ((i/(numColors-1)) * dd) ); });\n\n } else { // returns all colors based on the defined classes\n colors = [];\n var samples = [];\n if (_classes && (_classes.length > 2)) {\n for (var i = 1, end = _classes.length, asc = 1 <= end; asc ? i < end : i > end; asc ? i++ : i--) {\n samples.push((_classes[i-1]+_classes[i])*0.5);\n }\n } else {\n samples = _domain;\n }\n result = samples.map(function (v) { return f(v); });\n }\n\n if (chroma_1[out]) {\n result = result.map(function (c) { return c[out](); });\n }\n return result;\n };\n\n f.cache = function(c) {\n if (c != null) {\n _useCache = c;\n return f;\n } else {\n return _useCache;\n }\n };\n\n f.gamma = function(g) {\n if (g != null) {\n _gamma = g;\n return f;\n } else {\n return _gamma;\n }\n };\n\n f.nodata = function(d) {\n if (d != null) {\n _nacol = chroma_1(d);\n return f;\n } else {\n return _nacol;\n }\n };\n\n return f;\n };\n\n function __range__(left, right, inclusive) {\n var range = [];\n var ascending = left < right;\n var end = !inclusive ? right : ascending ? right + 1 : right - 1;\n for (var i = left; ascending ? i < end : i > end; ascending ? i++ : i--) {\n range.push(i);\n }\n return range;\n }\n\n //\n // interpolates between a set of colors uzing a bezier spline\n //\n\n // @requires utils lab\n\n\n\n\n var bezier = function(colors) {\n var assign, assign$1, assign$2;\n\n var I, lab0, lab1, lab2;\n colors = colors.map(function (c) { return new Color_1(c); });\n if (colors.length === 2) {\n // linear interpolation\n (assign = colors.map(function (c) { return c.lab(); }), lab0 = assign[0], lab1 = assign[1]);\n I = function(t) {\n var lab = ([0, 1, 2].map(function (i) { return lab0[i] + (t * (lab1[i] - lab0[i])); }));\n return new Color_1(lab, 'lab');\n };\n } else if (colors.length === 3) {\n // quadratic bezier interpolation\n (assign$1 = colors.map(function (c) { return c.lab(); }), lab0 = assign$1[0], lab1 = assign$1[1], lab2 = assign$1[2]);\n I = function(t) {\n var lab = ([0, 1, 2].map(function (i) { return ((1-t)*(1-t) * lab0[i]) + (2 * (1-t) * t * lab1[i]) + (t * t * lab2[i]); }));\n return new Color_1(lab, 'lab');\n };\n } else if (colors.length === 4) {\n // cubic bezier interpolation\n var lab3;\n (assign$2 = colors.map(function (c) { return c.lab(); }), lab0 = assign$2[0], lab1 = assign$2[1], lab2 = assign$2[2], lab3 = assign$2[3]);\n I = function(t) {\n var lab = ([0, 1, 2].map(function (i) { return ((1-t)*(1-t)*(1-t) * lab0[i]) + (3 * (1-t) * (1-t) * t * lab1[i]) + (3 * (1-t) * t * t * lab2[i]) + (t*t*t * lab3[i]); }));\n return new Color_1(lab, 'lab');\n };\n } else if (colors.length === 5) {\n var I0 = bezier(colors.slice(0, 3));\n var I1 = bezier(colors.slice(2, 5));\n I = function(t) {\n if (t < 0.5) {\n return I0(t*2);\n } else {\n return I1((t-0.5)*2);\n }\n };\n }\n return I;\n };\n\n var bezier_1 = function (colors) {\n var f = bezier(colors);\n f.scale = function () { return scale(f); };\n return f;\n };\n\n /*\n * interpolates between a set of colors uzing a bezier spline\n * blend mode formulas taken from http://www.venture-ware.com/kevin/coding/lets-learn-math-photoshop-blend-modes/\n */\n\n\n\n\n var blend = function (bottom, top, mode) {\n if (!blend[mode]) {\n throw new Error('unknown blend mode ' + mode);\n }\n return blend[mode](bottom, top);\n };\n\n var blend_f = function (f) { return function (bottom,top) {\n var c0 = chroma_1(top).rgb();\n var c1 = chroma_1(bottom).rgb();\n return chroma_1.rgb(f(c0, c1));\n }; };\n\n var each = function (f) { return function (c0, c1) {\n var out = [];\n out[0] = f(c0[0], c1[0]);\n out[1] = f(c0[1], c1[1]);\n out[2] = f(c0[2], c1[2]);\n return out;\n }; };\n\n var normal = function (a) { return a; };\n var multiply = function (a,b) { return a * b / 255; };\n var darken$1 = function (a,b) { return a > b ? b : a; };\n var lighten = function (a,b) { return a > b ? a : b; };\n var screen = function (a,b) { return 255 * (1 - (1-a/255) * (1-b/255)); };\n var overlay = function (a,b) { return b < 128 ? 2 * a * b / 255 : 255 * (1 - 2 * (1 - a / 255 ) * ( 1 - b / 255 )); };\n var burn = function (a,b) { return 255 * (1 - (1 - b / 255) / (a/255)); };\n var dodge = function (a,b) {\n if (a === 255) { return 255; }\n a = 255 * (b / 255) / (1 - a / 255);\n return a > 255 ? 255 : a\n };\n\n // # add = (a,b) ->\n // # if (a + b > 255) then 255 else a + b\n\n blend.normal = blend_f(each(normal));\n blend.multiply = blend_f(each(multiply));\n blend.screen = blend_f(each(screen));\n blend.overlay = blend_f(each(overlay));\n blend.darken = blend_f(each(darken$1));\n blend.lighten = blend_f(each(lighten));\n blend.dodge = blend_f(each(dodge));\n blend.burn = blend_f(each(burn));\n // blend.add = blend_f(each(add));\n\n var blend_1 = blend;\n\n // cubehelix interpolation\n // based on D.A. Green \"A colour scheme for the display of astronomical intensity images\"\n // http://astron-soc.in/bulletin/11June/289392011.pdf\n\n var type$k = utils.type;\n var clip_rgb$3 = utils.clip_rgb;\n var TWOPI$2 = utils.TWOPI;\n var pow$6 = Math.pow;\n var sin$2 = Math.sin;\n var cos$3 = Math.cos;\n\n\n var cubehelix = function(start, rotations, hue, gamma, lightness) {\n if ( start === void 0 ) start=300;\n if ( rotations === void 0 ) rotations=-1.5;\n if ( hue === void 0 ) hue=1;\n if ( gamma === void 0 ) gamma=1;\n if ( lightness === void 0 ) lightness=[0,1];\n\n var dh = 0, dl;\n if (type$k(lightness) === 'array') {\n dl = lightness[1] - lightness[0];\n } else {\n dl = 0;\n lightness = [lightness, lightness];\n }\n\n var f = function(fract) {\n var a = TWOPI$2 * (((start+120)/360) + (rotations * fract));\n var l = pow$6(lightness[0] + (dl * fract), gamma);\n var h = dh !== 0 ? hue[0] + (fract * dh) : hue;\n var amp = (h * l * (1-l)) / 2;\n var cos_a = cos$3(a);\n var sin_a = sin$2(a);\n var r = l + (amp * ((-0.14861 * cos_a) + (1.78277* sin_a)));\n var g = l + (amp * ((-0.29227 * cos_a) - (0.90649* sin_a)));\n var b = l + (amp * (+1.97294 * cos_a));\n return chroma_1(clip_rgb$3([r*255,g*255,b*255,1]));\n };\n\n f.start = function(s) {\n if ((s == null)) { return start; }\n start = s;\n return f;\n };\n\n f.rotations = function(r) {\n if ((r == null)) { return rotations; }\n rotations = r;\n return f;\n };\n\n f.gamma = function(g) {\n if ((g == null)) { return gamma; }\n gamma = g;\n return f;\n };\n\n f.hue = function(h) {\n if ((h == null)) { return hue; }\n hue = h;\n if (type$k(hue) === 'array') {\n dh = hue[1] - hue[0];\n if (dh === 0) { hue = hue[1]; }\n } else {\n dh = 0;\n }\n return f;\n };\n\n f.lightness = function(h) {\n if ((h == null)) { return lightness; }\n if (type$k(h) === 'array') {\n lightness = h;\n dl = h[1] - h[0];\n } else {\n lightness = [h,h];\n dl = 0;\n }\n return f;\n };\n\n f.scale = function () { return chroma_1.scale(f); };\n\n f.hue(hue);\n\n return f;\n };\n\n var digits = '0123456789abcdef';\n\n var floor$2 = Math.floor;\n var random = Math.random;\n\n var random_1 = function () {\n var code = '#';\n for (var i=0; i<6; i++) {\n code += digits.charAt(floor$2(random() * 16));\n }\n return new Color_1(code, 'hex');\n };\n\n var log$1 = Math.log;\n var pow$7 = Math.pow;\n var floor$3 = Math.floor;\n var abs = Math.abs;\n\n\n var analyze = function (data, key) {\n if ( key === void 0 ) key=null;\n\n var r = {\n min: Number.MAX_VALUE,\n max: Number.MAX_VALUE*-1,\n sum: 0,\n values: [],\n count: 0\n };\n if (type(data) === 'object') {\n data = Object.values(data);\n }\n data.forEach(function (val) {\n if (key && type(val) === 'object') { val = val[key]; }\n if (val !== undefined && val !== null && !isNaN(val)) {\n r.values.push(val);\n r.sum += val;\n if (val < r.min) { r.min = val; }\n if (val > r.max) { r.max = val; }\n r.count += 1;\n }\n });\n\n r.domain = [r.min, r.max];\n\n r.limits = function (mode, num) { return limits(r, mode, num); };\n\n return r;\n };\n\n\n var limits = function (data, mode, num) {\n if ( mode === void 0 ) mode='equal';\n if ( num === void 0 ) num=7;\n\n if (type(data) == 'array') {\n data = analyze(data);\n }\n var min = data.min;\n var max = data.max;\n var values = data.values.sort(function (a,b) { return a-b; });\n\n if (num === 1) { return [min,max]; }\n\n var limits = [];\n\n if (mode.substr(0,1) === 'c') { // continuous\n limits.push(min);\n limits.push(max);\n }\n\n if (mode.substr(0,1) === 'e') { // equal interval\n limits.push(min);\n for (var i=1; i 0');\n }\n var min_log = Math.LOG10E * log$1(min);\n var max_log = Math.LOG10E * log$1(max);\n limits.push(min);\n for (var i$1=1; i$1 pb\n var pr = p - pb;\n limits.push((values[pb]*(1-pr)) + (values[pb+1]*pr));\n }\n }\n limits.push(max);\n\n }\n\n else if (mode.substr(0,1) === 'k') { // k-means clustering\n /*\n implementation based on\n http://code.google.com/p/figue/source/browse/trunk/figue.js#336\n simplified for 1-d input values\n */\n var cluster;\n var n = values.length;\n var assignments = new Array(n);\n var clusterSizes = new Array(num);\n var repeat = true;\n var nb_iters = 0;\n var centroids = null;\n\n // get seed values\n centroids = [];\n centroids.push(min);\n for (var i$3=1; i$3 200) {\n repeat = false;\n }\n }\n\n // finished k-means clustering\n // the next part is borrowed from gabrielflor.it\n var kClusters = {};\n for (var j$5=0; j$5 l2 ? (l1 + 0.05) / (l2 + 0.05) : (l2 + 0.05) / (l1 + 0.05);\n };\n\n var sqrt$4 = Math.sqrt;\n var atan2$2 = Math.atan2;\n var abs$1 = Math.abs;\n var cos$4 = Math.cos;\n var PI$2 = Math.PI;\n\n var deltaE = function(a, b, L, C) {\n if ( L === void 0 ) L=1;\n if ( C === void 0 ) C=1;\n\n // Delta E (CMC)\n // see http://www.brucelindbloom.com/index.html?Eqn_DeltaE_CMC.html\n a = new Color_1(a);\n b = new Color_1(b);\n var ref = Array.from(a.lab());\n var L1 = ref[0];\n var a1 = ref[1];\n var b1 = ref[2];\n var ref$1 = Array.from(b.lab());\n var L2 = ref$1[0];\n var a2 = ref$1[1];\n var b2 = ref$1[2];\n var c1 = sqrt$4((a1 * a1) + (b1 * b1));\n var c2 = sqrt$4((a2 * a2) + (b2 * b2));\n var sl = L1 < 16.0 ? 0.511 : (0.040975 * L1) / (1.0 + (0.01765 * L1));\n var sc = ((0.0638 * c1) / (1.0 + (0.0131 * c1))) + 0.638;\n var h1 = c1 < 0.000001 ? 0.0 : (atan2$2(b1, a1) * 180.0) / PI$2;\n while (h1 < 0) { h1 += 360; }\n while (h1 >= 360) { h1 -= 360; }\n var t = (h1 >= 164.0) && (h1 <= 345.0) ? (0.56 + abs$1(0.2 * cos$4((PI$2 * (h1 + 168.0)) / 180.0))) : (0.36 + abs$1(0.4 * cos$4((PI$2 * (h1 + 35.0)) / 180.0)));\n var c4 = c1 * c1 * c1 * c1;\n var f = sqrt$4(c4 / (c4 + 1900.0));\n var sh = sc * (((f * t) + 1.0) - f);\n var delL = L1 - L2;\n var delC = c1 - c2;\n var delA = a1 - a2;\n var delB = b1 - b2;\n var dH2 = ((delA * delA) + (delB * delB)) - (delC * delC);\n var v1 = delL / (L * sl);\n var v2 = delC / (C * sc);\n var v3 = sh;\n return sqrt$4((v1 * v1) + (v2 * v2) + (dH2 / (v3 * v3)));\n };\n\n // simple Euclidean distance\n var distance = function(a, b, mode) {\n if ( mode === void 0 ) mode='lab';\n\n // Delta E (CIE 1976)\n // see http://www.brucelindbloom.com/index.html?Equations.html\n a = new Color_1(a);\n b = new Color_1(b);\n var l1 = a.get(mode);\n var l2 = b.get(mode);\n var sum_sq = 0;\n for (var i in l1) {\n var d = (l1[i] || 0) - (l2[i] || 0);\n sum_sq += d*d;\n }\n return Math.sqrt(sum_sq);\n };\n\n var valid = function () {\n var args = [], len = arguments.length;\n while ( len-- ) args[ len ] = arguments[ len ];\n\n try {\n new (Function.prototype.bind.apply( Color_1, [ null ].concat( args) ));\n return true;\n } catch (e) {\n return false;\n }\n };\n\n // some pre-defined color scales:\n\n\n\n\n var scales = {\n \tcool: function cool() { return scale([chroma_1.hsl(180,1,.9), chroma_1.hsl(250,.7,.4)]) },\n \thot: function hot() { return scale(['#000','#f00','#ff0','#fff'], [0,.25,.75,1]).mode('rgb') }\n };\n\n /**\n ColorBrewer colors for chroma.js\n\n Copyright (c) 2002 Cynthia Brewer, Mark Harrower, and The\n Pennsylvania State University.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software distributed\n under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n CONDITIONS OF ANY KIND, either express or implied. See the License for the\n specific language governing permissions and limitations under the License.\n */\n\n var colorbrewer = {\n // sequential\n OrRd: ['#fff7ec', '#fee8c8', '#fdd49e', '#fdbb84', '#fc8d59', '#ef6548', '#d7301f', '#b30000', '#7f0000'],\n PuBu: ['#fff7fb', '#ece7f2', '#d0d1e6', '#a6bddb', '#74a9cf', '#3690c0', '#0570b0', '#045a8d', '#023858'],\n BuPu: ['#f7fcfd', '#e0ecf4', '#bfd3e6', '#9ebcda', '#8c96c6', '#8c6bb1', '#88419d', '#810f7c', '#4d004b'],\n Oranges: ['#fff5eb', '#fee6ce', '#fdd0a2', '#fdae6b', '#fd8d3c', '#f16913', '#d94801', '#a63603', '#7f2704'],\n BuGn: ['#f7fcfd', '#e5f5f9', '#ccece6', '#99d8c9', '#66c2a4', '#41ae76', '#238b45', '#006d2c', '#00441b'],\n YlOrBr: ['#ffffe5', '#fff7bc', '#fee391', '#fec44f', '#fe9929', '#ec7014', '#cc4c02', '#993404', '#662506'],\n YlGn: ['#ffffe5', '#f7fcb9', '#d9f0a3', '#addd8e', '#78c679', '#41ab5d', '#238443', '#006837', '#004529'],\n Reds: ['#fff5f0', '#fee0d2', '#fcbba1', '#fc9272', '#fb6a4a', '#ef3b2c', '#cb181d', '#a50f15', '#67000d'],\n RdPu: ['#fff7f3', '#fde0dd', '#fcc5c0', '#fa9fb5', '#f768a1', '#dd3497', '#ae017e', '#7a0177', '#49006a'],\n Greens: ['#f7fcf5', '#e5f5e0', '#c7e9c0', '#a1d99b', '#74c476', '#41ab5d', '#238b45', '#006d2c', '#00441b'],\n YlGnBu: ['#ffffd9', '#edf8b1', '#c7e9b4', '#7fcdbb', '#41b6c4', '#1d91c0', '#225ea8', '#253494', '#081d58'],\n Purples: ['#fcfbfd', '#efedf5', '#dadaeb', '#bcbddc', '#9e9ac8', '#807dba', '#6a51a3', '#54278f', '#3f007d'],\n GnBu: ['#f7fcf0', '#e0f3db', '#ccebc5', '#a8ddb5', '#7bccc4', '#4eb3d3', '#2b8cbe', '#0868ac', '#084081'],\n Greys: ['#ffffff', '#f0f0f0', '#d9d9d9', '#bdbdbd', '#969696', '#737373', '#525252', '#252525', '#000000'],\n YlOrRd: ['#ffffcc', '#ffeda0', '#fed976', '#feb24c', '#fd8d3c', '#fc4e2a', '#e31a1c', '#bd0026', '#800026'],\n PuRd: ['#f7f4f9', '#e7e1ef', '#d4b9da', '#c994c7', '#df65b0', '#e7298a', '#ce1256', '#980043', '#67001f'],\n Blues: ['#f7fbff', '#deebf7', '#c6dbef', '#9ecae1', '#6baed6', '#4292c6', '#2171b5', '#08519c', '#08306b'],\n PuBuGn: ['#fff7fb', '#ece2f0', '#d0d1e6', '#a6bddb', '#67a9cf', '#3690c0', '#02818a', '#016c59', '#014636'],\n Viridis: ['#440154', '#482777', '#3f4a8a', '#31678e', '#26838f', '#1f9d8a', '#6cce5a', '#b6de2b', '#fee825'],\n\n // diverging\n\n Spectral: ['#9e0142', '#d53e4f', '#f46d43', '#fdae61', '#fee08b', '#ffffbf', '#e6f598', '#abdda4', '#66c2a5', '#3288bd', '#5e4fa2'],\n RdYlGn: ['#a50026', '#d73027', '#f46d43', '#fdae61', '#fee08b', '#ffffbf', '#d9ef8b', '#a6d96a', '#66bd63', '#1a9850', '#006837'],\n RdBu: ['#67001f', '#b2182b', '#d6604d', '#f4a582', '#fddbc7', '#f7f7f7', '#d1e5f0', '#92c5de', '#4393c3', '#2166ac', '#053061'],\n PiYG: ['#8e0152', '#c51b7d', '#de77ae', '#f1b6da', '#fde0ef', '#f7f7f7', '#e6f5d0', '#b8e186', '#7fbc41', '#4d9221', '#276419'],\n PRGn: ['#40004b', '#762a83', '#9970ab', '#c2a5cf', '#e7d4e8', '#f7f7f7', '#d9f0d3', '#a6dba0', '#5aae61', '#1b7837', '#00441b'],\n RdYlBu: ['#a50026', '#d73027', '#f46d43', '#fdae61', '#fee090', '#ffffbf', '#e0f3f8', '#abd9e9', '#74add1', '#4575b4', '#313695'],\n BrBG: ['#543005', '#8c510a', '#bf812d', '#dfc27d', '#f6e8c3', '#f5f5f5', '#c7eae5', '#80cdc1', '#35978f', '#01665e', '#003c30'],\n RdGy: ['#67001f', '#b2182b', '#d6604d', '#f4a582', '#fddbc7', '#ffffff', '#e0e0e0', '#bababa', '#878787', '#4d4d4d', '#1a1a1a'],\n PuOr: ['#7f3b08', '#b35806', '#e08214', '#fdb863', '#fee0b6', '#f7f7f7', '#d8daeb', '#b2abd2', '#8073ac', '#542788', '#2d004b'],\n\n // qualitative\n\n Set2: ['#66c2a5', '#fc8d62', '#8da0cb', '#e78ac3', '#a6d854', '#ffd92f', '#e5c494', '#b3b3b3'],\n Accent: ['#7fc97f', '#beaed4', '#fdc086', '#ffff99', '#386cb0', '#f0027f', '#bf5b17', '#666666'],\n Set1: ['#e41a1c', '#377eb8', '#4daf4a', '#984ea3', '#ff7f00', '#ffff33', '#a65628', '#f781bf', '#999999'],\n Set3: ['#8dd3c7', '#ffffb3', '#bebada', '#fb8072', '#80b1d3', '#fdb462', '#b3de69', '#fccde5', '#d9d9d9', '#bc80bd', '#ccebc5', '#ffed6f'],\n Dark2: ['#1b9e77', '#d95f02', '#7570b3', '#e7298a', '#66a61e', '#e6ab02', '#a6761d', '#666666'],\n Paired: ['#a6cee3', '#1f78b4', '#b2df8a', '#33a02c', '#fb9a99', '#e31a1c', '#fdbf6f', '#ff7f00', '#cab2d6', '#6a3d9a', '#ffff99', '#b15928'],\n Pastel2: ['#b3e2cd', '#fdcdac', '#cbd5e8', '#f4cae4', '#e6f5c9', '#fff2ae', '#f1e2cc', '#cccccc'],\n Pastel1: ['#fbb4ae', '#b3cde3', '#ccebc5', '#decbe4', '#fed9a6', '#ffffcc', '#e5d8bd', '#fddaec', '#f2f2f2'],\n };\n\n // add lowercase aliases for case-insensitive matches\n for (var i$1 = 0, list$1 = Object.keys(colorbrewer); i$1 < list$1.length; i$1 += 1) {\n var key = list$1[i$1];\n\n colorbrewer[key.toLowerCase()] = colorbrewer[key];\n }\n\n var colorbrewer_1 = colorbrewer;\n\n // feel free to comment out anything to rollup\n // a smaller chroma.js built\n\n // io --> convert colors\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n // operators --> modify existing Colors\n\n\n\n\n\n\n\n\n\n\n // interpolators\n\n\n\n\n\n\n\n\n\n\n // generators -- > create new colors\n chroma_1.average = average;\n chroma_1.bezier = bezier_1;\n chroma_1.blend = blend_1;\n chroma_1.cubehelix = cubehelix;\n chroma_1.mix = chroma_1.interpolate = mix;\n chroma_1.random = random_1;\n chroma_1.scale = scale;\n\n // other utility methods\n chroma_1.analyze = analyze_1.analyze;\n chroma_1.contrast = contrast;\n chroma_1.deltaE = deltaE;\n chroma_1.distance = distance;\n chroma_1.limits = analyze_1.limits;\n chroma_1.valid = valid;\n\n // scale\n chroma_1.scales = scales;\n\n // colors\n chroma_1.colors = w3cx11_1;\n chroma_1.brewer = colorbrewer_1;\n\n var chroma_js = chroma_1;\n\n return chroma_js;\n\n})));\n","// CodeMirror, copyright (c) by Marijn Haverbeke and others\n// Distributed under an MIT license: https://codemirror.net/LICENSE\n\n// This is CodeMirror (https://codemirror.net), a code editor\n// implemented in JavaScript on top of the browser's DOM.\n//\n// You can find some technical background for some of the code below\n// at http://marijnhaverbeke.nl/blog/#cm-internals .\n\n(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n (global.CodeMirror = factory());\n}(this, (function () { 'use strict';\n\n // Kludges for bugs and behavior differences that can't be feature\n // detected are enabled based on userAgent etc sniffing.\n var userAgent = navigator.userAgent;\n var platform = navigator.platform;\n\n var gecko = /gecko\\/\\d/i.test(userAgent);\n var ie_upto10 = /MSIE \\d/.test(userAgent);\n var ie_11up = /Trident\\/(?:[7-9]|\\d{2,})\\..*rv:(\\d+)/.exec(userAgent);\n var edge = /Edge\\/(\\d+)/.exec(userAgent);\n var ie = ie_upto10 || ie_11up || edge;\n var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1]);\n var webkit = !edge && /WebKit\\//.test(userAgent);\n var qtwebkit = webkit && /Qt\\/\\d+\\.\\d+/.test(userAgent);\n var chrome = !edge && /Chrome\\//.test(userAgent);\n var presto = /Opera\\//.test(userAgent);\n var safari = /Apple Computer/.test(navigator.vendor);\n var mac_geMountainLion = /Mac OS X 1\\d\\D([8-9]|\\d\\d)\\D/.test(userAgent);\n var phantom = /PhantomJS/.test(userAgent);\n\n var ios = !edge && /AppleWebKit/.test(userAgent) && /Mobile\\/\\w+/.test(userAgent);\n var android = /Android/.test(userAgent);\n // This is woefully incomplete. Suggestions for alternative methods welcome.\n var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);\n var mac = ios || /Mac/.test(platform);\n var chromeOS = /\\bCrOS\\b/.test(userAgent);\n var windows = /win/i.test(platform);\n\n var presto_version = presto && userAgent.match(/Version\\/(\\d*\\.\\d*)/);\n if (presto_version) { presto_version = Number(presto_version[1]); }\n if (presto_version && presto_version >= 15) { presto = false; webkit = true; }\n // Some browsers use the wrong event properties to signal cmd/ctrl on OS X\n var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11));\n var captureRightClick = gecko || (ie && ie_version >= 9);\n\n function classTest(cls) { return new RegExp(\"(^|\\\\s)\" + cls + \"(?:$|\\\\s)\\\\s*\") }\n\n var rmClass = function(node, cls) {\n var current = node.className;\n var match = classTest(cls).exec(current);\n if (match) {\n var after = current.slice(match.index + match[0].length);\n node.className = current.slice(0, match.index) + (after ? match[1] + after : \"\");\n }\n };\n\n function removeChildren(e) {\n for (var count = e.childNodes.length; count > 0; --count)\n { e.removeChild(e.firstChild); }\n return e\n }\n\n function removeChildrenAndAdd(parent, e) {\n return removeChildren(parent).appendChild(e)\n }\n\n function elt(tag, content, className, style) {\n var e = document.createElement(tag);\n if (className) { e.className = className; }\n if (style) { e.style.cssText = style; }\n if (typeof content == \"string\") { e.appendChild(document.createTextNode(content)); }\n else if (content) { for (var i = 0; i < content.length; ++i) { e.appendChild(content[i]); } }\n return e\n }\n // wrapper for elt, which removes the elt from the accessibility tree\n function eltP(tag, content, className, style) {\n var e = elt(tag, content, className, style);\n e.setAttribute(\"role\", \"presentation\");\n return e\n }\n\n var range;\n if (document.createRange) { range = function(node, start, end, endNode) {\n var r = document.createRange();\n r.setEnd(endNode || node, end);\n r.setStart(node, start);\n return r\n }; }\n else { range = function(node, start, end) {\n var r = document.body.createTextRange();\n try { r.moveToElementText(node.parentNode); }\n catch(e) { return r }\n r.collapse(true);\n r.moveEnd(\"character\", end);\n r.moveStart(\"character\", start);\n return r\n }; }\n\n function contains(parent, child) {\n if (child.nodeType == 3) // Android browser always returns false when child is a textnode\n { child = child.parentNode; }\n if (parent.contains)\n { return parent.contains(child) }\n do {\n if (child.nodeType == 11) { child = child.host; }\n if (child == parent) { return true }\n } while (child = child.parentNode)\n }\n\n function activeElt() {\n // IE and Edge may throw an \"Unspecified Error\" when accessing document.activeElement.\n // IE < 10 will throw when accessed while the page is loading or in an iframe.\n // IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable.\n var activeElement;\n try {\n activeElement = document.activeElement;\n } catch(e) {\n activeElement = document.body || null;\n }\n while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement)\n { activeElement = activeElement.shadowRoot.activeElement; }\n return activeElement\n }\n\n function addClass(node, cls) {\n var current = node.className;\n if (!classTest(cls).test(current)) { node.className += (current ? \" \" : \"\") + cls; }\n }\n function joinClasses(a, b) {\n var as = a.split(\" \");\n for (var i = 0; i < as.length; i++)\n { if (as[i] && !classTest(as[i]).test(b)) { b += \" \" + as[i]; } }\n return b\n }\n\n var selectInput = function(node) { node.select(); };\n if (ios) // Mobile Safari apparently has a bug where select() is broken.\n { selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length; }; }\n else if (ie) // Suppress mysterious IE10 errors\n { selectInput = function(node) { try { node.select(); } catch(_e) {} }; }\n\n function bind(f) {\n var args = Array.prototype.slice.call(arguments, 1);\n return function(){return f.apply(null, args)}\n }\n\n function copyObj(obj, target, overwrite) {\n if (!target) { target = {}; }\n for (var prop in obj)\n { if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)))\n { target[prop] = obj[prop]; } }\n return target\n }\n\n // Counts the column offset in a string, taking tabs into account.\n // Used mostly to find indentation.\n function countColumn(string, end, tabSize, startIndex, startValue) {\n if (end == null) {\n end = string.search(/[^\\s\\u00a0]/);\n if (end == -1) { end = string.length; }\n }\n for (var i = startIndex || 0, n = startValue || 0;;) {\n var nextTab = string.indexOf(\"\\t\", i);\n if (nextTab < 0 || nextTab >= end)\n { return n + (end - i) }\n n += nextTab - i;\n n += tabSize - (n % tabSize);\n i = nextTab + 1;\n }\n }\n\n var Delayed = function() {\n this.id = null;\n this.f = null;\n this.time = 0;\n this.handler = bind(this.onTimeout, this);\n };\n Delayed.prototype.onTimeout = function (self) {\n self.id = 0;\n if (self.time <= +new Date) {\n self.f();\n } else {\n setTimeout(self.handler, self.time - +new Date);\n }\n };\n Delayed.prototype.set = function (ms, f) {\n this.f = f;\n var time = +new Date + ms;\n if (!this.id || time < this.time) {\n clearTimeout(this.id);\n this.id = setTimeout(this.handler, ms);\n this.time = time;\n }\n };\n\n function indexOf(array, elt) {\n for (var i = 0; i < array.length; ++i)\n { if (array[i] == elt) { return i } }\n return -1\n }\n\n // Number of pixels added to scroller and sizer to hide scrollbar\n var scrollerGap = 30;\n\n // Returned or thrown by various protocols to signal 'I'm not\n // handling this'.\n var Pass = {toString: function(){return \"CodeMirror.Pass\"}};\n\n // Reused option objects for setSelection & friends\n var sel_dontScroll = {scroll: false}, sel_mouse = {origin: \"*mouse\"}, sel_move = {origin: \"+move\"};\n\n // The inverse of countColumn -- find the offset that corresponds to\n // a particular column.\n function findColumn(string, goal, tabSize) {\n for (var pos = 0, col = 0;;) {\n var nextTab = string.indexOf(\"\\t\", pos);\n if (nextTab == -1) { nextTab = string.length; }\n var skipped = nextTab - pos;\n if (nextTab == string.length || col + skipped >= goal)\n { return pos + Math.min(skipped, goal - col) }\n col += nextTab - pos;\n col += tabSize - (col % tabSize);\n pos = nextTab + 1;\n if (col >= goal) { return pos }\n }\n }\n\n var spaceStrs = [\"\"];\n function spaceStr(n) {\n while (spaceStrs.length <= n)\n { spaceStrs.push(lst(spaceStrs) + \" \"); }\n return spaceStrs[n]\n }\n\n function lst(arr) { return arr[arr.length-1] }\n\n function map(array, f) {\n var out = [];\n for (var i = 0; i < array.length; i++) { out[i] = f(array[i], i); }\n return out\n }\n\n function insertSorted(array, value, score) {\n var pos = 0, priority = score(value);\n while (pos < array.length && score(array[pos]) <= priority) { pos++; }\n array.splice(pos, 0, value);\n }\n\n function nothing() {}\n\n function createObj(base, props) {\n var inst;\n if (Object.create) {\n inst = Object.create(base);\n } else {\n nothing.prototype = base;\n inst = new nothing();\n }\n if (props) { copyObj(props, inst); }\n return inst\n }\n\n var nonASCIISingleCaseWordChar = /[\\u00df\\u0587\\u0590-\\u05f4\\u0600-\\u06ff\\u3040-\\u309f\\u30a0-\\u30ff\\u3400-\\u4db5\\u4e00-\\u9fcc\\uac00-\\ud7af]/;\n function isWordCharBasic(ch) {\n return /\\w/.test(ch) || ch > \"\\x80\" &&\n (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch))\n }\n function isWordChar(ch, helper) {\n if (!helper) { return isWordCharBasic(ch) }\n if (helper.source.indexOf(\"\\\\w\") > -1 && isWordCharBasic(ch)) { return true }\n return helper.test(ch)\n }\n\n function isEmpty(obj) {\n for (var n in obj) { if (obj.hasOwnProperty(n) && obj[n]) { return false } }\n return true\n }\n\n // Extending unicode characters. A series of a non-extending char +\n // any number of extending chars is treated as a single unit as far\n // as editing and measuring is concerned. This is not fully correct,\n // since some scripts/fonts/browsers also treat other configurations\n // of code points as a group.\n var extendingChars = /[\\u0300-\\u036f\\u0483-\\u0489\\u0591-\\u05bd\\u05bf\\u05c1\\u05c2\\u05c4\\u05c5\\u05c7\\u0610-\\u061a\\u064b-\\u065e\\u0670\\u06d6-\\u06dc\\u06de-\\u06e4\\u06e7\\u06e8\\u06ea-\\u06ed\\u0711\\u0730-\\u074a\\u07a6-\\u07b0\\u07eb-\\u07f3\\u0816-\\u0819\\u081b-\\u0823\\u0825-\\u0827\\u0829-\\u082d\\u0900-\\u0902\\u093c\\u0941-\\u0948\\u094d\\u0951-\\u0955\\u0962\\u0963\\u0981\\u09bc\\u09be\\u09c1-\\u09c4\\u09cd\\u09d7\\u09e2\\u09e3\\u0a01\\u0a02\\u0a3c\\u0a41\\u0a42\\u0a47\\u0a48\\u0a4b-\\u0a4d\\u0a51\\u0a70\\u0a71\\u0a75\\u0a81\\u0a82\\u0abc\\u0ac1-\\u0ac5\\u0ac7\\u0ac8\\u0acd\\u0ae2\\u0ae3\\u0b01\\u0b3c\\u0b3e\\u0b3f\\u0b41-\\u0b44\\u0b4d\\u0b56\\u0b57\\u0b62\\u0b63\\u0b82\\u0bbe\\u0bc0\\u0bcd\\u0bd7\\u0c3e-\\u0c40\\u0c46-\\u0c48\\u0c4a-\\u0c4d\\u0c55\\u0c56\\u0c62\\u0c63\\u0cbc\\u0cbf\\u0cc2\\u0cc6\\u0ccc\\u0ccd\\u0cd5\\u0cd6\\u0ce2\\u0ce3\\u0d3e\\u0d41-\\u0d44\\u0d4d\\u0d57\\u0d62\\u0d63\\u0dca\\u0dcf\\u0dd2-\\u0dd4\\u0dd6\\u0ddf\\u0e31\\u0e34-\\u0e3a\\u0e47-\\u0e4e\\u0eb1\\u0eb4-\\u0eb9\\u0ebb\\u0ebc\\u0ec8-\\u0ecd\\u0f18\\u0f19\\u0f35\\u0f37\\u0f39\\u0f71-\\u0f7e\\u0f80-\\u0f84\\u0f86\\u0f87\\u0f90-\\u0f97\\u0f99-\\u0fbc\\u0fc6\\u102d-\\u1030\\u1032-\\u1037\\u1039\\u103a\\u103d\\u103e\\u1058\\u1059\\u105e-\\u1060\\u1071-\\u1074\\u1082\\u1085\\u1086\\u108d\\u109d\\u135f\\u1712-\\u1714\\u1732-\\u1734\\u1752\\u1753\\u1772\\u1773\\u17b7-\\u17bd\\u17c6\\u17c9-\\u17d3\\u17dd\\u180b-\\u180d\\u18a9\\u1920-\\u1922\\u1927\\u1928\\u1932\\u1939-\\u193b\\u1a17\\u1a18\\u1a56\\u1a58-\\u1a5e\\u1a60\\u1a62\\u1a65-\\u1a6c\\u1a73-\\u1a7c\\u1a7f\\u1b00-\\u1b03\\u1b34\\u1b36-\\u1b3a\\u1b3c\\u1b42\\u1b6b-\\u1b73\\u1b80\\u1b81\\u1ba2-\\u1ba5\\u1ba8\\u1ba9\\u1c2c-\\u1c33\\u1c36\\u1c37\\u1cd0-\\u1cd2\\u1cd4-\\u1ce0\\u1ce2-\\u1ce8\\u1ced\\u1dc0-\\u1de6\\u1dfd-\\u1dff\\u200c\\u200d\\u20d0-\\u20f0\\u2cef-\\u2cf1\\u2de0-\\u2dff\\u302a-\\u302f\\u3099\\u309a\\ua66f-\\ua672\\ua67c\\ua67d\\ua6f0\\ua6f1\\ua802\\ua806\\ua80b\\ua825\\ua826\\ua8c4\\ua8e0-\\ua8f1\\ua926-\\ua92d\\ua947-\\ua951\\ua980-\\ua982\\ua9b3\\ua9b6-\\ua9b9\\ua9bc\\uaa29-\\uaa2e\\uaa31\\uaa32\\uaa35\\uaa36\\uaa43\\uaa4c\\uaab0\\uaab2-\\uaab4\\uaab7\\uaab8\\uaabe\\uaabf\\uaac1\\uabe5\\uabe8\\uabed\\udc00-\\udfff\\ufb1e\\ufe00-\\ufe0f\\ufe20-\\ufe26\\uff9e\\uff9f]/;\n function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch) }\n\n // Returns a number from the range [`0`; `str.length`] unless `pos` is outside that range.\n function skipExtendingChars(str, pos, dir) {\n while ((dir < 0 ? pos > 0 : pos < str.length) && isExtendingChar(str.charAt(pos))) { pos += dir; }\n return pos\n }\n\n // Returns the value from the range [`from`; `to`] that satisfies\n // `pred` and is closest to `from`. Assumes that at least `to`\n // satisfies `pred`. Supports `from` being greater than `to`.\n function findFirst(pred, from, to) {\n // At any point we are certain `to` satisfies `pred`, don't know\n // whether `from` does.\n var dir = from > to ? -1 : 1;\n for (;;) {\n if (from == to) { return from }\n var midF = (from + to) / 2, mid = dir < 0 ? Math.ceil(midF) : Math.floor(midF);\n if (mid == from) { return pred(mid) ? from : to }\n if (pred(mid)) { to = mid; }\n else { from = mid + dir; }\n }\n }\n\n // BIDI HELPERS\n\n function iterateBidiSections(order, from, to, f) {\n if (!order) { return f(from, to, \"ltr\", 0) }\n var found = false;\n for (var i = 0; i < order.length; ++i) {\n var part = order[i];\n if (part.from < to && part.to > from || from == to && part.to == from) {\n f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? \"rtl\" : \"ltr\", i);\n found = true;\n }\n }\n if (!found) { f(from, to, \"ltr\"); }\n }\n\n var bidiOther = null;\n function getBidiPartAt(order, ch, sticky) {\n var found;\n bidiOther = null;\n for (var i = 0; i < order.length; ++i) {\n var cur = order[i];\n if (cur.from < ch && cur.to > ch) { return i }\n if (cur.to == ch) {\n if (cur.from != cur.to && sticky == \"before\") { found = i; }\n else { bidiOther = i; }\n }\n if (cur.from == ch) {\n if (cur.from != cur.to && sticky != \"before\") { found = i; }\n else { bidiOther = i; }\n }\n }\n return found != null ? found : bidiOther\n }\n\n // Bidirectional ordering algorithm\n // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm\n // that this (partially) implements.\n\n // One-char codes used for character types:\n // L (L): Left-to-Right\n // R (R): Right-to-Left\n // r (AL): Right-to-Left Arabic\n // 1 (EN): European Number\n // + (ES): European Number Separator\n // % (ET): European Number Terminator\n // n (AN): Arabic Number\n // , (CS): Common Number Separator\n // m (NSM): Non-Spacing Mark\n // b (BN): Boundary Neutral\n // s (B): Paragraph Separator\n // t (S): Segment Separator\n // w (WS): Whitespace\n // N (ON): Other Neutrals\n\n // Returns null if characters are ordered as they appear\n // (left-to-right), or an array of sections ({from, to, level}\n // objects) in the order in which they occur visually.\n var bidiOrdering = (function() {\n // Character types for codepoints 0 to 0xff\n var lowTypes = \"bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN\";\n // Character types for codepoints 0x600 to 0x6f9\n var arabicTypes = \"nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111\";\n function charType(code) {\n if (code <= 0xf7) { return lowTypes.charAt(code) }\n else if (0x590 <= code && code <= 0x5f4) { return \"R\" }\n else if (0x600 <= code && code <= 0x6f9) { return arabicTypes.charAt(code - 0x600) }\n else if (0x6ee <= code && code <= 0x8ac) { return \"r\" }\n else if (0x2000 <= code && code <= 0x200b) { return \"w\" }\n else if (code == 0x200c) { return \"b\" }\n else { return \"L\" }\n }\n\n var bidiRE = /[\\u0590-\\u05f4\\u0600-\\u06ff\\u0700-\\u08ac]/;\n var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/;\n\n function BidiSpan(level, from, to) {\n this.level = level;\n this.from = from; this.to = to;\n }\n\n return function(str, direction) {\n var outerType = direction == \"ltr\" ? \"L\" : \"R\";\n\n if (str.length == 0 || direction == \"ltr\" && !bidiRE.test(str)) { return false }\n var len = str.length, types = [];\n for (var i = 0; i < len; ++i)\n { types.push(charType(str.charCodeAt(i))); }\n\n // W1. Examine each non-spacing mark (NSM) in the level run, and\n // change the type of the NSM to the type of the previous\n // character. If the NSM is at the start of the level run, it will\n // get the type of sor.\n for (var i$1 = 0, prev = outerType; i$1 < len; ++i$1) {\n var type = types[i$1];\n if (type == \"m\") { types[i$1] = prev; }\n else { prev = type; }\n }\n\n // W2. Search backwards from each instance of a European number\n // until the first strong type (R, L, AL, or sor) is found. If an\n // AL is found, change the type of the European number to Arabic\n // number.\n // W3. Change all ALs to R.\n for (var i$2 = 0, cur = outerType; i$2 < len; ++i$2) {\n var type$1 = types[i$2];\n if (type$1 == \"1\" && cur == \"r\") { types[i$2] = \"n\"; }\n else if (isStrong.test(type$1)) { cur = type$1; if (type$1 == \"r\") { types[i$2] = \"R\"; } }\n }\n\n // W4. A single European separator between two European numbers\n // changes to a European number. A single common separator between\n // two numbers of the same type changes to that type.\n for (var i$3 = 1, prev$1 = types[0]; i$3 < len - 1; ++i$3) {\n var type$2 = types[i$3];\n if (type$2 == \"+\" && prev$1 == \"1\" && types[i$3+1] == \"1\") { types[i$3] = \"1\"; }\n else if (type$2 == \",\" && prev$1 == types[i$3+1] &&\n (prev$1 == \"1\" || prev$1 == \"n\")) { types[i$3] = prev$1; }\n prev$1 = type$2;\n }\n\n // W5. A sequence of European terminators adjacent to European\n // numbers changes to all European numbers.\n // W6. Otherwise, separators and terminators change to Other\n // Neutral.\n for (var i$4 = 0; i$4 < len; ++i$4) {\n var type$3 = types[i$4];\n if (type$3 == \",\") { types[i$4] = \"N\"; }\n else if (type$3 == \"%\") {\n var end = (void 0);\n for (end = i$4 + 1; end < len && types[end] == \"%\"; ++end) {}\n var replace = (i$4 && types[i$4-1] == \"!\") || (end < len && types[end] == \"1\") ? \"1\" : \"N\";\n for (var j = i$4; j < end; ++j) { types[j] = replace; }\n i$4 = end - 1;\n }\n }\n\n // W7. Search backwards from each instance of a European number\n // until the first strong type (R, L, or sor) is found. If an L is\n // found, then change the type of the European number to L.\n for (var i$5 = 0, cur$1 = outerType; i$5 < len; ++i$5) {\n var type$4 = types[i$5];\n if (cur$1 == \"L\" && type$4 == \"1\") { types[i$5] = \"L\"; }\n else if (isStrong.test(type$4)) { cur$1 = type$4; }\n }\n\n // N1. A sequence of neutrals takes the direction of the\n // surrounding strong text if the text on both sides has the same\n // direction. European and Arabic numbers act as if they were R in\n // terms of their influence on neutrals. Start-of-level-run (sor)\n // and end-of-level-run (eor) are used at level run boundaries.\n // N2. Any remaining neutrals take the embedding direction.\n for (var i$6 = 0; i$6 < len; ++i$6) {\n if (isNeutral.test(types[i$6])) {\n var end$1 = (void 0);\n for (end$1 = i$6 + 1; end$1 < len && isNeutral.test(types[end$1]); ++end$1) {}\n var before = (i$6 ? types[i$6-1] : outerType) == \"L\";\n var after = (end$1 < len ? types[end$1] : outerType) == \"L\";\n var replace$1 = before == after ? (before ? \"L\" : \"R\") : outerType;\n for (var j$1 = i$6; j$1 < end$1; ++j$1) { types[j$1] = replace$1; }\n i$6 = end$1 - 1;\n }\n }\n\n // Here we depart from the documented algorithm, in order to avoid\n // building up an actual levels array. Since there are only three\n // levels (0, 1, 2) in an implementation that doesn't take\n // explicit embedding into account, we can build up the order on\n // the fly, without following the level-based algorithm.\n var order = [], m;\n for (var i$7 = 0; i$7 < len;) {\n if (countsAsLeft.test(types[i$7])) {\n var start = i$7;\n for (++i$7; i$7 < len && countsAsLeft.test(types[i$7]); ++i$7) {}\n order.push(new BidiSpan(0, start, i$7));\n } else {\n var pos = i$7, at = order.length;\n for (++i$7; i$7 < len && types[i$7] != \"L\"; ++i$7) {}\n for (var j$2 = pos; j$2 < i$7;) {\n if (countsAsNum.test(types[j$2])) {\n if (pos < j$2) { order.splice(at, 0, new BidiSpan(1, pos, j$2)); }\n var nstart = j$2;\n for (++j$2; j$2 < i$7 && countsAsNum.test(types[j$2]); ++j$2) {}\n order.splice(at, 0, new BidiSpan(2, nstart, j$2));\n pos = j$2;\n } else { ++j$2; }\n }\n if (pos < i$7) { order.splice(at, 0, new BidiSpan(1, pos, i$7)); }\n }\n }\n if (direction == \"ltr\") {\n if (order[0].level == 1 && (m = str.match(/^\\s+/))) {\n order[0].from = m[0].length;\n order.unshift(new BidiSpan(0, 0, m[0].length));\n }\n if (lst(order).level == 1 && (m = str.match(/\\s+$/))) {\n lst(order).to -= m[0].length;\n order.push(new BidiSpan(0, len - m[0].length, len));\n }\n }\n\n return direction == \"rtl\" ? order.reverse() : order\n }\n })();\n\n // Get the bidi ordering for the given line (and cache it). Returns\n // false for lines that are fully left-to-right, and an array of\n // BidiSpan objects otherwise.\n function getOrder(line, direction) {\n var order = line.order;\n if (order == null) { order = line.order = bidiOrdering(line.text, direction); }\n return order\n }\n\n // EVENT HANDLING\n\n // Lightweight event framework. on/off also work on DOM nodes,\n // registering native DOM handlers.\n\n var noHandlers = [];\n\n var on = function(emitter, type, f) {\n if (emitter.addEventListener) {\n emitter.addEventListener(type, f, false);\n } else if (emitter.attachEvent) {\n emitter.attachEvent(\"on\" + type, f);\n } else {\n var map$$1 = emitter._handlers || (emitter._handlers = {});\n map$$1[type] = (map$$1[type] || noHandlers).concat(f);\n }\n };\n\n function getHandlers(emitter, type) {\n return emitter._handlers && emitter._handlers[type] || noHandlers\n }\n\n function off(emitter, type, f) {\n if (emitter.removeEventListener) {\n emitter.removeEventListener(type, f, false);\n } else if (emitter.detachEvent) {\n emitter.detachEvent(\"on\" + type, f);\n } else {\n var map$$1 = emitter._handlers, arr = map$$1 && map$$1[type];\n if (arr) {\n var index = indexOf(arr, f);\n if (index > -1)\n { map$$1[type] = arr.slice(0, index).concat(arr.slice(index + 1)); }\n }\n }\n }\n\n function signal(emitter, type /*, values...*/) {\n var handlers = getHandlers(emitter, type);\n if (!handlers.length) { return }\n var args = Array.prototype.slice.call(arguments, 2);\n for (var i = 0; i < handlers.length; ++i) { handlers[i].apply(null, args); }\n }\n\n // The DOM events that CodeMirror handles can be overridden by\n // registering a (non-DOM) handler on the editor for the event name,\n // and preventDefault-ing the event in that handler.\n function signalDOMEvent(cm, e, override) {\n if (typeof e == \"string\")\n { e = {type: e, preventDefault: function() { this.defaultPrevented = true; }}; }\n signal(cm, override || e.type, cm, e);\n return e_defaultPrevented(e) || e.codemirrorIgnore\n }\n\n function signalCursorActivity(cm) {\n var arr = cm._handlers && cm._handlers.cursorActivity;\n if (!arr) { return }\n var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []);\n for (var i = 0; i < arr.length; ++i) { if (indexOf(set, arr[i]) == -1)\n { set.push(arr[i]); } }\n }\n\n function hasHandler(emitter, type) {\n return getHandlers(emitter, type).length > 0\n }\n\n // Add on and off methods to a constructor's prototype, to make\n // registering events on such objects more convenient.\n function eventMixin(ctor) {\n ctor.prototype.on = function(type, f) {on(this, type, f);};\n ctor.prototype.off = function(type, f) {off(this, type, f);};\n }\n\n // Due to the fact that we still support jurassic IE versions, some\n // compatibility wrappers are needed.\n\n function e_preventDefault(e) {\n if (e.preventDefault) { e.preventDefault(); }\n else { e.returnValue = false; }\n }\n function e_stopPropagation(e) {\n if (e.stopPropagation) { e.stopPropagation(); }\n else { e.cancelBubble = true; }\n }\n function e_defaultPrevented(e) {\n return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false\n }\n function e_stop(e) {e_preventDefault(e); e_stopPropagation(e);}\n\n function e_target(e) {return e.target || e.srcElement}\n function e_button(e) {\n var b = e.which;\n if (b == null) {\n if (e.button & 1) { b = 1; }\n else if (e.button & 2) { b = 3; }\n else if (e.button & 4) { b = 2; }\n }\n if (mac && e.ctrlKey && b == 1) { b = 3; }\n return b\n }\n\n // Detect drag-and-drop\n var dragAndDrop = function() {\n // There is *some* kind of drag-and-drop support in IE6-8, but I\n // couldn't get it to work yet.\n if (ie && ie_version < 9) { return false }\n var div = elt('div');\n return \"draggable\" in div || \"dragDrop\" in div\n }();\n\n var zwspSupported;\n function zeroWidthElement(measure) {\n if (zwspSupported == null) {\n var test = elt(\"span\", \"\\u200b\");\n removeChildrenAndAdd(measure, elt(\"span\", [test, document.createTextNode(\"x\")]));\n if (measure.firstChild.offsetHeight != 0)\n { zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8); }\n }\n var node = zwspSupported ? elt(\"span\", \"\\u200b\") :\n elt(\"span\", \"\\u00a0\", null, \"display: inline-block; width: 1px; margin-right: -1px\");\n node.setAttribute(\"cm-text\", \"\");\n return node\n }\n\n // Feature-detect IE's crummy client rect reporting for bidi text\n var badBidiRects;\n function hasBadBidiRects(measure) {\n if (badBidiRects != null) { return badBidiRects }\n var txt = removeChildrenAndAdd(measure, document.createTextNode(\"A\\u062eA\"));\n var r0 = range(txt, 0, 1).getBoundingClientRect();\n var r1 = range(txt, 1, 2).getBoundingClientRect();\n removeChildren(measure);\n if (!r0 || r0.left == r0.right) { return false } // Safari returns null in some cases (#2780)\n return badBidiRects = (r1.right - r0.right < 3)\n }\n\n // See if \"\".split is the broken IE version, if so, provide an\n // alternative way to split lines.\n var splitLinesAuto = \"\\n\\nb\".split(/\\n/).length != 3 ? function (string) {\n var pos = 0, result = [], l = string.length;\n while (pos <= l) {\n var nl = string.indexOf(\"\\n\", pos);\n if (nl == -1) { nl = string.length; }\n var line = string.slice(pos, string.charAt(nl - 1) == \"\\r\" ? nl - 1 : nl);\n var rt = line.indexOf(\"\\r\");\n if (rt != -1) {\n result.push(line.slice(0, rt));\n pos += rt + 1;\n } else {\n result.push(line);\n pos = nl + 1;\n }\n }\n return result\n } : function (string) { return string.split(/\\r\\n?|\\n/); };\n\n var hasSelection = window.getSelection ? function (te) {\n try { return te.selectionStart != te.selectionEnd }\n catch(e) { return false }\n } : function (te) {\n var range$$1;\n try {range$$1 = te.ownerDocument.selection.createRange();}\n catch(e) {}\n if (!range$$1 || range$$1.parentElement() != te) { return false }\n return range$$1.compareEndPoints(\"StartToEnd\", range$$1) != 0\n };\n\n var hasCopyEvent = (function () {\n var e = elt(\"div\");\n if (\"oncopy\" in e) { return true }\n e.setAttribute(\"oncopy\", \"return;\");\n return typeof e.oncopy == \"function\"\n })();\n\n var badZoomedRects = null;\n function hasBadZoomedRects(measure) {\n if (badZoomedRects != null) { return badZoomedRects }\n var node = removeChildrenAndAdd(measure, elt(\"span\", \"x\"));\n var normal = node.getBoundingClientRect();\n var fromRange = range(node, 0, 1).getBoundingClientRect();\n return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1\n }\n\n // Known modes, by name and by MIME\n var modes = {}, mimeModes = {};\n\n // Extra arguments are stored as the mode's dependencies, which is\n // used by (legacy) mechanisms like loadmode.js to automatically\n // load a mode. (Preferred mechanism is the require/define calls.)\n function defineMode(name, mode) {\n if (arguments.length > 2)\n { mode.dependencies = Array.prototype.slice.call(arguments, 2); }\n modes[name] = mode;\n }\n\n function defineMIME(mime, spec) {\n mimeModes[mime] = spec;\n }\n\n // Given a MIME type, a {name, ...options} config object, or a name\n // string, return a mode config object.\n function resolveMode(spec) {\n if (typeof spec == \"string\" && mimeModes.hasOwnProperty(spec)) {\n spec = mimeModes[spec];\n } else if (spec && typeof spec.name == \"string\" && mimeModes.hasOwnProperty(spec.name)) {\n var found = mimeModes[spec.name];\n if (typeof found == \"string\") { found = {name: found}; }\n spec = createObj(found, spec);\n spec.name = found.name;\n } else if (typeof spec == \"string\" && /^[\\w\\-]+\\/[\\w\\-]+\\+xml$/.test(spec)) {\n return resolveMode(\"application/xml\")\n } else if (typeof spec == \"string\" && /^[\\w\\-]+\\/[\\w\\-]+\\+json$/.test(spec)) {\n return resolveMode(\"application/json\")\n }\n if (typeof spec == \"string\") { return {name: spec} }\n else { return spec || {name: \"null\"} }\n }\n\n // Given a mode spec (anything that resolveMode accepts), find and\n // initialize an actual mode object.\n function getMode(options, spec) {\n spec = resolveMode(spec);\n var mfactory = modes[spec.name];\n if (!mfactory) { return getMode(options, \"text/plain\") }\n var modeObj = mfactory(options, spec);\n if (modeExtensions.hasOwnProperty(spec.name)) {\n var exts = modeExtensions[spec.name];\n for (var prop in exts) {\n if (!exts.hasOwnProperty(prop)) { continue }\n if (modeObj.hasOwnProperty(prop)) { modeObj[\"_\" + prop] = modeObj[prop]; }\n modeObj[prop] = exts[prop];\n }\n }\n modeObj.name = spec.name;\n if (spec.helperType) { modeObj.helperType = spec.helperType; }\n if (spec.modeProps) { for (var prop$1 in spec.modeProps)\n { modeObj[prop$1] = spec.modeProps[prop$1]; } }\n\n return modeObj\n }\n\n // This can be used to attach properties to mode objects from\n // outside the actual mode definition.\n var modeExtensions = {};\n function extendMode(mode, properties) {\n var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});\n copyObj(properties, exts);\n }\n\n function copyState(mode, state) {\n if (state === true) { return state }\n if (mode.copyState) { return mode.copyState(state) }\n var nstate = {};\n for (var n in state) {\n var val = state[n];\n if (val instanceof Array) { val = val.concat([]); }\n nstate[n] = val;\n }\n return nstate\n }\n\n // Given a mode and a state (for that mode), find the inner mode and\n // state at the position that the state refers to.\n function innerMode(mode, state) {\n var info;\n while (mode.innerMode) {\n info = mode.innerMode(state);\n if (!info || info.mode == mode) { break }\n state = info.state;\n mode = info.mode;\n }\n return info || {mode: mode, state: state}\n }\n\n function startState(mode, a1, a2) {\n return mode.startState ? mode.startState(a1, a2) : true\n }\n\n // STRING STREAM\n\n // Fed to the mode parsers, provides helper functions to make\n // parsers more succinct.\n\n var StringStream = function(string, tabSize, lineOracle) {\n this.pos = this.start = 0;\n this.string = string;\n this.tabSize = tabSize || 8;\n this.lastColumnPos = this.lastColumnValue = 0;\n this.lineStart = 0;\n this.lineOracle = lineOracle;\n };\n\n StringStream.prototype.eol = function () {return this.pos >= this.string.length};\n StringStream.prototype.sol = function () {return this.pos == this.lineStart};\n StringStream.prototype.peek = function () {return this.string.charAt(this.pos) || undefined};\n StringStream.prototype.next = function () {\n if (this.pos < this.string.length)\n { return this.string.charAt(this.pos++) }\n };\n StringStream.prototype.eat = function (match) {\n var ch = this.string.charAt(this.pos);\n var ok;\n if (typeof match == \"string\") { ok = ch == match; }\n else { ok = ch && (match.test ? match.test(ch) : match(ch)); }\n if (ok) {++this.pos; return ch}\n };\n StringStream.prototype.eatWhile = function (match) {\n var start = this.pos;\n while (this.eat(match)){}\n return this.pos > start\n };\n StringStream.prototype.eatSpace = function () {\n var this$1 = this;\n\n var start = this.pos;\n while (/[\\s\\u00a0]/.test(this.string.charAt(this.pos))) { ++this$1.pos; }\n return this.pos > start\n };\n StringStream.prototype.skipToEnd = function () {this.pos = this.string.length;};\n StringStream.prototype.skipTo = function (ch) {\n var found = this.string.indexOf(ch, this.pos);\n if (found > -1) {this.pos = found; return true}\n };\n StringStream.prototype.backUp = function (n) {this.pos -= n;};\n StringStream.prototype.column = function () {\n if (this.lastColumnPos < this.start) {\n this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);\n this.lastColumnPos = this.start;\n }\n return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)\n };\n StringStream.prototype.indentation = function () {\n return countColumn(this.string, null, this.tabSize) -\n (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)\n };\n StringStream.prototype.match = function (pattern, consume, caseInsensitive) {\n if (typeof pattern == \"string\") {\n var cased = function (str) { return caseInsensitive ? str.toLowerCase() : str; };\n var substr = this.string.substr(this.pos, pattern.length);\n if (cased(substr) == cased(pattern)) {\n if (consume !== false) { this.pos += pattern.length; }\n return true\n }\n } else {\n var match = this.string.slice(this.pos).match(pattern);\n if (match && match.index > 0) { return null }\n if (match && consume !== false) { this.pos += match[0].length; }\n return match\n }\n };\n StringStream.prototype.current = function (){return this.string.slice(this.start, this.pos)};\n StringStream.prototype.hideFirstChars = function (n, inner) {\n this.lineStart += n;\n try { return inner() }\n finally { this.lineStart -= n; }\n };\n StringStream.prototype.lookAhead = function (n) {\n var oracle = this.lineOracle;\n return oracle && oracle.lookAhead(n)\n };\n StringStream.prototype.baseToken = function () {\n var oracle = this.lineOracle;\n return oracle && oracle.baseToken(this.pos)\n };\n\n // Find the line object corresponding to the given line number.\n function getLine(doc, n) {\n n -= doc.first;\n if (n < 0 || n >= doc.size) { throw new Error(\"There is no line \" + (n + doc.first) + \" in the document.\") }\n var chunk = doc;\n while (!chunk.lines) {\n for (var i = 0;; ++i) {\n var child = chunk.children[i], sz = child.chunkSize();\n if (n < sz) { chunk = child; break }\n n -= sz;\n }\n }\n return chunk.lines[n]\n }\n\n // Get the part of a document between two positions, as an array of\n // strings.\n function getBetween(doc, start, end) {\n var out = [], n = start.line;\n doc.iter(start.line, end.line + 1, function (line) {\n var text = line.text;\n if (n == end.line) { text = text.slice(0, end.ch); }\n if (n == start.line) { text = text.slice(start.ch); }\n out.push(text);\n ++n;\n });\n return out\n }\n // Get the lines between from and to, as array of strings.\n function getLines(doc, from, to) {\n var out = [];\n doc.iter(from, to, function (line) { out.push(line.text); }); // iter aborts when callback returns truthy value\n return out\n }\n\n // Update the height of a line, propagating the height change\n // upwards to parent nodes.\n function updateLineHeight(line, height) {\n var diff = height - line.height;\n if (diff) { for (var n = line; n; n = n.parent) { n.height += diff; } }\n }\n\n // Given a line object, find its line number by walking up through\n // its parent links.\n function lineNo(line) {\n if (line.parent == null) { return null }\n var cur = line.parent, no = indexOf(cur.lines, line);\n for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {\n for (var i = 0;; ++i) {\n if (chunk.children[i] == cur) { break }\n no += chunk.children[i].chunkSize();\n }\n }\n return no + cur.first\n }\n\n // Find the line at the given vertical position, using the height\n // information in the document tree.\n function lineAtHeight(chunk, h) {\n var n = chunk.first;\n outer: do {\n for (var i$1 = 0; i$1 < chunk.children.length; ++i$1) {\n var child = chunk.children[i$1], ch = child.height;\n if (h < ch) { chunk = child; continue outer }\n h -= ch;\n n += child.chunkSize();\n }\n return n\n } while (!chunk.lines)\n var i = 0;\n for (; i < chunk.lines.length; ++i) {\n var line = chunk.lines[i], lh = line.height;\n if (h < lh) { break }\n h -= lh;\n }\n return n + i\n }\n\n function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size}\n\n function lineNumberFor(options, i) {\n return String(options.lineNumberFormatter(i + options.firstLineNumber))\n }\n\n // A Pos instance represents a position within the text.\n function Pos(line, ch, sticky) {\n if ( sticky === void 0 ) sticky = null;\n\n if (!(this instanceof Pos)) { return new Pos(line, ch, sticky) }\n this.line = line;\n this.ch = ch;\n this.sticky = sticky;\n }\n\n // Compare two positions, return 0 if they are the same, a negative\n // number when a is less, and a positive number otherwise.\n function cmp(a, b) { return a.line - b.line || a.ch - b.ch }\n\n function equalCursorPos(a, b) { return a.sticky == b.sticky && cmp(a, b) == 0 }\n\n function copyPos(x) {return Pos(x.line, x.ch)}\n function maxPos(a, b) { return cmp(a, b) < 0 ? b : a }\n function minPos(a, b) { return cmp(a, b) < 0 ? a : b }\n\n // Most of the external API clips given positions to make sure they\n // actually exist within the document.\n function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1))}\n function clipPos(doc, pos) {\n if (pos.line < doc.first) { return Pos(doc.first, 0) }\n var last = doc.first + doc.size - 1;\n if (pos.line > last) { return Pos(last, getLine(doc, last).text.length) }\n return clipToLen(pos, getLine(doc, pos.line).text.length)\n }\n function clipToLen(pos, linelen) {\n var ch = pos.ch;\n if (ch == null || ch > linelen) { return Pos(pos.line, linelen) }\n else if (ch < 0) { return Pos(pos.line, 0) }\n else { return pos }\n }\n function clipPosArray(doc, array) {\n var out = [];\n for (var i = 0; i < array.length; i++) { out[i] = clipPos(doc, array[i]); }\n return out\n }\n\n var SavedContext = function(state, lookAhead) {\n this.state = state;\n this.lookAhead = lookAhead;\n };\n\n var Context = function(doc, state, line, lookAhead) {\n this.state = state;\n this.doc = doc;\n this.line = line;\n this.maxLookAhead = lookAhead || 0;\n this.baseTokens = null;\n this.baseTokenPos = 1;\n };\n\n Context.prototype.lookAhead = function (n) {\n var line = this.doc.getLine(this.line + n);\n if (line != null && n > this.maxLookAhead) { this.maxLookAhead = n; }\n return line\n };\n\n Context.prototype.baseToken = function (n) {\n var this$1 = this;\n\n if (!this.baseTokens) { return null }\n while (this.baseTokens[this.baseTokenPos] <= n)\n { this$1.baseTokenPos += 2; }\n var type = this.baseTokens[this.baseTokenPos + 1];\n return {type: type && type.replace(/( |^)overlay .*/, \"\"),\n size: this.baseTokens[this.baseTokenPos] - n}\n };\n\n Context.prototype.nextLine = function () {\n this.line++;\n if (this.maxLookAhead > 0) { this.maxLookAhead--; }\n };\n\n Context.fromSaved = function (doc, saved, line) {\n if (saved instanceof SavedContext)\n { return new Context(doc, copyState(doc.mode, saved.state), line, saved.lookAhead) }\n else\n { return new Context(doc, copyState(doc.mode, saved), line) }\n };\n\n Context.prototype.save = function (copy) {\n var state = copy !== false ? copyState(this.doc.mode, this.state) : this.state;\n return this.maxLookAhead > 0 ? new SavedContext(state, this.maxLookAhead) : state\n };\n\n\n // Compute a style array (an array starting with a mode generation\n // -- for invalidation -- followed by pairs of end positions and\n // style strings), which is used to highlight the tokens on the\n // line.\n function highlightLine(cm, line, context, forceToEnd) {\n // A styles array always starts with a number identifying the\n // mode/overlays that it is based on (for easy invalidation).\n var st = [cm.state.modeGen], lineClasses = {};\n // Compute the base array of styles\n runMode(cm, line.text, cm.doc.mode, context, function (end, style) { return st.push(end, style); },\n lineClasses, forceToEnd);\n var state = context.state;\n\n // Run overlays, adjust style array.\n var loop = function ( o ) {\n context.baseTokens = st;\n var overlay = cm.state.overlays[o], i = 1, at = 0;\n context.state = true;\n runMode(cm, line.text, overlay.mode, context, function (end, style) {\n var start = i;\n // Ensure there's a token end at the current position, and that i points at it\n while (at < end) {\n var i_end = st[i];\n if (i_end > end)\n { st.splice(i, 1, end, st[i+1], i_end); }\n i += 2;\n at = Math.min(end, i_end);\n }\n if (!style) { return }\n if (overlay.opaque) {\n st.splice(start, i - start, end, \"overlay \" + style);\n i = start + 2;\n } else {\n for (; start < i; start += 2) {\n var cur = st[start+1];\n st[start+1] = (cur ? cur + \" \" : \"\") + \"overlay \" + style;\n }\n }\n }, lineClasses);\n context.state = state;\n context.baseTokens = null;\n context.baseTokenPos = 1;\n };\n\n for (var o = 0; o < cm.state.overlays.length; ++o) loop( o );\n\n return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null}\n }\n\n function getLineStyles(cm, line, updateFrontier) {\n if (!line.styles || line.styles[0] != cm.state.modeGen) {\n var context = getContextBefore(cm, lineNo(line));\n var resetState = line.text.length > cm.options.maxHighlightLength && copyState(cm.doc.mode, context.state);\n var result = highlightLine(cm, line, context);\n if (resetState) { context.state = resetState; }\n line.stateAfter = context.save(!resetState);\n line.styles = result.styles;\n if (result.classes) { line.styleClasses = result.classes; }\n else if (line.styleClasses) { line.styleClasses = null; }\n if (updateFrontier === cm.doc.highlightFrontier)\n { cm.doc.modeFrontier = Math.max(cm.doc.modeFrontier, ++cm.doc.highlightFrontier); }\n }\n return line.styles\n }\n\n function getContextBefore(cm, n, precise) {\n var doc = cm.doc, display = cm.display;\n if (!doc.mode.startState) { return new Context(doc, true, n) }\n var start = findStartLine(cm, n, precise);\n var saved = start > doc.first && getLine(doc, start - 1).stateAfter;\n var context = saved ? Context.fromSaved(doc, saved, start) : new Context(doc, startState(doc.mode), start);\n\n doc.iter(start, n, function (line) {\n processLine(cm, line.text, context);\n var pos = context.line;\n line.stateAfter = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo ? context.save() : null;\n context.nextLine();\n });\n if (precise) { doc.modeFrontier = context.line; }\n return context\n }\n\n // Lightweight form of highlight -- proceed over this line and\n // update state, but don't save a style array. Used for lines that\n // aren't currently visible.\n function processLine(cm, text, context, startAt) {\n var mode = cm.doc.mode;\n var stream = new StringStream(text, cm.options.tabSize, context);\n stream.start = stream.pos = startAt || 0;\n if (text == \"\") { callBlankLine(mode, context.state); }\n while (!stream.eol()) {\n readToken(mode, stream, context.state);\n stream.start = stream.pos;\n }\n }\n\n function callBlankLine(mode, state) {\n if (mode.blankLine) { return mode.blankLine(state) }\n if (!mode.innerMode) { return }\n var inner = innerMode(mode, state);\n if (inner.mode.blankLine) { return inner.mode.blankLine(inner.state) }\n }\n\n function readToken(mode, stream, state, inner) {\n for (var i = 0; i < 10; i++) {\n if (inner) { inner[0] = innerMode(mode, state).mode; }\n var style = mode.token(stream, state);\n if (stream.pos > stream.start) { return style }\n }\n throw new Error(\"Mode \" + mode.name + \" failed to advance stream.\")\n }\n\n var Token = function(stream, type, state) {\n this.start = stream.start; this.end = stream.pos;\n this.string = stream.current();\n this.type = type || null;\n this.state = state;\n };\n\n // Utility for getTokenAt and getLineTokens\n function takeToken(cm, pos, precise, asArray) {\n var doc = cm.doc, mode = doc.mode, style;\n pos = clipPos(doc, pos);\n var line = getLine(doc, pos.line), context = getContextBefore(cm, pos.line, precise);\n var stream = new StringStream(line.text, cm.options.tabSize, context), tokens;\n if (asArray) { tokens = []; }\n while ((asArray || stream.pos < pos.ch) && !stream.eol()) {\n stream.start = stream.pos;\n style = readToken(mode, stream, context.state);\n if (asArray) { tokens.push(new Token(stream, style, copyState(doc.mode, context.state))); }\n }\n return asArray ? tokens : new Token(stream, style, context.state)\n }\n\n function extractLineClasses(type, output) {\n if (type) { for (;;) {\n var lineClass = type.match(/(?:^|\\s+)line-(background-)?(\\S+)/);\n if (!lineClass) { break }\n type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length);\n var prop = lineClass[1] ? \"bgClass\" : \"textClass\";\n if (output[prop] == null)\n { output[prop] = lineClass[2]; }\n else if (!(new RegExp(\"(?:^|\\s)\" + lineClass[2] + \"(?:$|\\s)\")).test(output[prop]))\n { output[prop] += \" \" + lineClass[2]; }\n } }\n return type\n }\n\n // Run the given mode's parser over a line, calling f for each token.\n function runMode(cm, text, mode, context, f, lineClasses, forceToEnd) {\n var flattenSpans = mode.flattenSpans;\n if (flattenSpans == null) { flattenSpans = cm.options.flattenSpans; }\n var curStart = 0, curStyle = null;\n var stream = new StringStream(text, cm.options.tabSize, context), style;\n var inner = cm.options.addModeClass && [null];\n if (text == \"\") { extractLineClasses(callBlankLine(mode, context.state), lineClasses); }\n while (!stream.eol()) {\n if (stream.pos > cm.options.maxHighlightLength) {\n flattenSpans = false;\n if (forceToEnd) { processLine(cm, text, context, stream.pos); }\n stream.pos = text.length;\n style = null;\n } else {\n style = extractLineClasses(readToken(mode, stream, context.state, inner), lineClasses);\n }\n if (inner) {\n var mName = inner[0].name;\n if (mName) { style = \"m-\" + (style ? mName + \" \" + style : mName); }\n }\n if (!flattenSpans || curStyle != style) {\n while (curStart < stream.start) {\n curStart = Math.min(stream.start, curStart + 5000);\n f(curStart, curStyle);\n }\n curStyle = style;\n }\n stream.start = stream.pos;\n }\n while (curStart < stream.pos) {\n // Webkit seems to refuse to render text nodes longer than 57444\n // characters, and returns inaccurate measurements in nodes\n // starting around 5000 chars.\n var pos = Math.min(stream.pos, curStart + 5000);\n f(pos, curStyle);\n curStart = pos;\n }\n }\n\n // Finds the line to start with when starting a parse. Tries to\n // find a line with a stateAfter, so that it can start with a\n // valid state. If that fails, it returns the line with the\n // smallest indentation, which tends to need the least context to\n // parse correctly.\n function findStartLine(cm, n, precise) {\n var minindent, minline, doc = cm.doc;\n var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100);\n for (var search = n; search > lim; --search) {\n if (search <= doc.first) { return doc.first }\n var line = getLine(doc, search - 1), after = line.stateAfter;\n if (after && (!precise || search + (after instanceof SavedContext ? after.lookAhead : 0) <= doc.modeFrontier))\n { return search }\n var indented = countColumn(line.text, null, cm.options.tabSize);\n if (minline == null || minindent > indented) {\n minline = search - 1;\n minindent = indented;\n }\n }\n return minline\n }\n\n function retreatFrontier(doc, n) {\n doc.modeFrontier = Math.min(doc.modeFrontier, n);\n if (doc.highlightFrontier < n - 10) { return }\n var start = doc.first;\n for (var line = n - 1; line > start; line--) {\n var saved = getLine(doc, line).stateAfter;\n // change is on 3\n // state on line 1 looked ahead 2 -- so saw 3\n // test 1 + 2 < 3 should cover this\n if (saved && (!(saved instanceof SavedContext) || line + saved.lookAhead < n)) {\n start = line + 1;\n break\n }\n }\n doc.highlightFrontier = Math.min(doc.highlightFrontier, start);\n }\n\n // Optimize some code when these features are not used.\n var sawReadOnlySpans = false, sawCollapsedSpans = false;\n\n function seeReadOnlySpans() {\n sawReadOnlySpans = true;\n }\n\n function seeCollapsedSpans() {\n sawCollapsedSpans = true;\n }\n\n // TEXTMARKER SPANS\n\n function MarkedSpan(marker, from, to) {\n this.marker = marker;\n this.from = from; this.to = to;\n }\n\n // Search an array of spans for a span matching the given marker.\n function getMarkedSpanFor(spans, marker) {\n if (spans) { for (var i = 0; i < spans.length; ++i) {\n var span = spans[i];\n if (span.marker == marker) { return span }\n } }\n }\n // Remove a span from an array, returning undefined if no spans are\n // left (we don't store arrays for lines without spans).\n function removeMarkedSpan(spans, span) {\n var r;\n for (var i = 0; i < spans.length; ++i)\n { if (spans[i] != span) { (r || (r = [])).push(spans[i]); } }\n return r\n }\n // Add a span to a line.\n function addMarkedSpan(line, span) {\n line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];\n span.marker.attachLine(line);\n }\n\n // Used for the algorithm that adjusts markers for a change in the\n // document. These functions cut an array of spans at a given\n // character position, returning an array of remaining chunks (or\n // undefined if nothing remains).\n function markedSpansBefore(old, startCh, isInsert) {\n var nw;\n if (old) { for (var i = 0; i < old.length; ++i) {\n var span = old[i], marker = span.marker;\n var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh);\n if (startsBefore || span.from == startCh && marker.type == \"bookmark\" && (!isInsert || !span.marker.insertLeft)) {\n var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh)\n ;(nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to));\n }\n } }\n return nw\n }\n function markedSpansAfter(old, endCh, isInsert) {\n var nw;\n if (old) { for (var i = 0; i < old.length; ++i) {\n var span = old[i], marker = span.marker;\n var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh);\n if (endsAfter || span.from == endCh && marker.type == \"bookmark\" && (!isInsert || span.marker.insertLeft)) {\n var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh)\n ;(nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh,\n span.to == null ? null : span.to - endCh));\n }\n } }\n return nw\n }\n\n // Given a change object, compute the new set of marker spans that\n // cover the line in which the change took place. Removes spans\n // entirely within the change, reconnects spans belonging to the\n // same marker that appear on both sides of the change, and cuts off\n // spans partially within the change. Returns an array of span\n // arrays with one element for each line in (after) the change.\n function stretchSpansOverChange(doc, change) {\n if (change.full) { return null }\n var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans;\n var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans;\n if (!oldFirst && !oldLast) { return null }\n\n var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0;\n // Get the spans that 'stick out' on both sides\n var first = markedSpansBefore(oldFirst, startCh, isInsert);\n var last = markedSpansAfter(oldLast, endCh, isInsert);\n\n // Next, merge those two ends\n var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0);\n if (first) {\n // Fix up .to properties of first\n for (var i = 0; i < first.length; ++i) {\n var span = first[i];\n if (span.to == null) {\n var found = getMarkedSpanFor(last, span.marker);\n if (!found) { span.to = startCh; }\n else if (sameLine) { span.to = found.to == null ? null : found.to + offset; }\n }\n }\n }\n if (last) {\n // Fix up .from in last (or move them into first in case of sameLine)\n for (var i$1 = 0; i$1 < last.length; ++i$1) {\n var span$1 = last[i$1];\n if (span$1.to != null) { span$1.to += offset; }\n if (span$1.from == null) {\n var found$1 = getMarkedSpanFor(first, span$1.marker);\n if (!found$1) {\n span$1.from = offset;\n if (sameLine) { (first || (first = [])).push(span$1); }\n }\n } else {\n span$1.from += offset;\n if (sameLine) { (first || (first = [])).push(span$1); }\n }\n }\n }\n // Make sure we didn't create any zero-length spans\n if (first) { first = clearEmptySpans(first); }\n if (last && last != first) { last = clearEmptySpans(last); }\n\n var newMarkers = [first];\n if (!sameLine) {\n // Fill gap with whole-line-spans\n var gap = change.text.length - 2, gapMarkers;\n if (gap > 0 && first)\n { for (var i$2 = 0; i$2 < first.length; ++i$2)\n { if (first[i$2].to == null)\n { (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i$2].marker, null, null)); } } }\n for (var i$3 = 0; i$3 < gap; ++i$3)\n { newMarkers.push(gapMarkers); }\n newMarkers.push(last);\n }\n return newMarkers\n }\n\n // Remove spans that are empty and don't have a clearWhenEmpty\n // option of false.\n function clearEmptySpans(spans) {\n for (var i = 0; i < spans.length; ++i) {\n var span = spans[i];\n if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false)\n { spans.splice(i--, 1); }\n }\n if (!spans.length) { return null }\n return spans\n }\n\n // Used to 'clip' out readOnly ranges when making a change.\n function removeReadOnlyRanges(doc, from, to) {\n var markers = null;\n doc.iter(from.line, to.line + 1, function (line) {\n if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) {\n var mark = line.markedSpans[i].marker;\n if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))\n { (markers || (markers = [])).push(mark); }\n } }\n });\n if (!markers) { return null }\n var parts = [{from: from, to: to}];\n for (var i = 0; i < markers.length; ++i) {\n var mk = markers[i], m = mk.find(0);\n for (var j = 0; j < parts.length; ++j) {\n var p = parts[j];\n if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) { continue }\n var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to);\n if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)\n { newParts.push({from: p.from, to: m.from}); }\n if (dto > 0 || !mk.inclusiveRight && !dto)\n { newParts.push({from: m.to, to: p.to}); }\n parts.splice.apply(parts, newParts);\n j += newParts.length - 3;\n }\n }\n return parts\n }\n\n // Connect or disconnect spans from a line.\n function detachMarkedSpans(line) {\n var spans = line.markedSpans;\n if (!spans) { return }\n for (var i = 0; i < spans.length; ++i)\n { spans[i].marker.detachLine(line); }\n line.markedSpans = null;\n }\n function attachMarkedSpans(line, spans) {\n if (!spans) { return }\n for (var i = 0; i < spans.length; ++i)\n { spans[i].marker.attachLine(line); }\n line.markedSpans = spans;\n }\n\n // Helpers used when computing which overlapping collapsed span\n // counts as the larger one.\n function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0 }\n function extraRight(marker) { return marker.inclusiveRight ? 1 : 0 }\n\n // Returns a number indicating which of two overlapping collapsed\n // spans is larger (and thus includes the other). Falls back to\n // comparing ids when the spans cover exactly the same range.\n function compareCollapsedMarkers(a, b) {\n var lenDiff = a.lines.length - b.lines.length;\n if (lenDiff != 0) { return lenDiff }\n var aPos = a.find(), bPos = b.find();\n var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b);\n if (fromCmp) { return -fromCmp }\n var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b);\n if (toCmp) { return toCmp }\n return b.id - a.id\n }\n\n // Find out whether a line ends or starts in a collapsed span. If\n // so, return the marker for that span.\n function collapsedSpanAtSide(line, start) {\n var sps = sawCollapsedSpans && line.markedSpans, found;\n if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) {\n sp = sps[i];\n if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&\n (!found || compareCollapsedMarkers(found, sp.marker) < 0))\n { found = sp.marker; }\n } }\n return found\n }\n function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true) }\n function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false) }\n\n function collapsedSpanAround(line, ch) {\n var sps = sawCollapsedSpans && line.markedSpans, found;\n if (sps) { for (var i = 0; i < sps.length; ++i) {\n var sp = sps[i];\n if (sp.marker.collapsed && (sp.from == null || sp.from < ch) && (sp.to == null || sp.to > ch) &&\n (!found || compareCollapsedMarkers(found, sp.marker) < 0)) { found = sp.marker; }\n } }\n return found\n }\n\n // Test whether there exists a collapsed span that partially\n // overlaps (covers the start or end, but not both) of a new span.\n // Such overlap is not allowed.\n function conflictingCollapsedRange(doc, lineNo$$1, from, to, marker) {\n var line = getLine(doc, lineNo$$1);\n var sps = sawCollapsedSpans && line.markedSpans;\n if (sps) { for (var i = 0; i < sps.length; ++i) {\n var sp = sps[i];\n if (!sp.marker.collapsed) { continue }\n var found = sp.marker.find(0);\n var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker);\n var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker);\n if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) { continue }\n if (fromCmp <= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.to, from) >= 0 : cmp(found.to, from) > 0) ||\n fromCmp >= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.from, to) <= 0 : cmp(found.from, to) < 0))\n { return true }\n } }\n }\n\n // A visual line is a line as drawn on the screen. Folding, for\n // example, can cause multiple logical lines to appear on the same\n // visual line. This finds the start of the visual line that the\n // given line is part of (usually that is the line itself).\n function visualLine(line) {\n var merged;\n while (merged = collapsedSpanAtStart(line))\n { line = merged.find(-1, true).line; }\n return line\n }\n\n function visualLineEnd(line) {\n var merged;\n while (merged = collapsedSpanAtEnd(line))\n { line = merged.find(1, true).line; }\n return line\n }\n\n // Returns an array of logical lines that continue the visual line\n // started by the argument, or undefined if there are no such lines.\n function visualLineContinued(line) {\n var merged, lines;\n while (merged = collapsedSpanAtEnd(line)) {\n line = merged.find(1, true).line\n ;(lines || (lines = [])).push(line);\n }\n return lines\n }\n\n // Get the line number of the start of the visual line that the\n // given line number is part of.\n function visualLineNo(doc, lineN) {\n var line = getLine(doc, lineN), vis = visualLine(line);\n if (line == vis) { return lineN }\n return lineNo(vis)\n }\n\n // Get the line number of the start of the next visual line after\n // the given line.\n function visualLineEndNo(doc, lineN) {\n if (lineN > doc.lastLine()) { return lineN }\n var line = getLine(doc, lineN), merged;\n if (!lineIsHidden(doc, line)) { return lineN }\n while (merged = collapsedSpanAtEnd(line))\n { line = merged.find(1, true).line; }\n return lineNo(line) + 1\n }\n\n // Compute whether a line is hidden. Lines count as hidden when they\n // are part of a visual line that starts with another line, or when\n // they are entirely covered by collapsed, non-widget span.\n function lineIsHidden(doc, line) {\n var sps = sawCollapsedSpans && line.markedSpans;\n if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) {\n sp = sps[i];\n if (!sp.marker.collapsed) { continue }\n if (sp.from == null) { return true }\n if (sp.marker.widgetNode) { continue }\n if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))\n { return true }\n } }\n }\n function lineIsHiddenInner(doc, line, span) {\n if (span.to == null) {\n var end = span.marker.find(1, true);\n return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker))\n }\n if (span.marker.inclusiveRight && span.to == line.text.length)\n { return true }\n for (var sp = (void 0), i = 0; i < line.markedSpans.length; ++i) {\n sp = line.markedSpans[i];\n if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&\n (sp.to == null || sp.to != span.from) &&\n (sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&\n lineIsHiddenInner(doc, line, sp)) { return true }\n }\n }\n\n // Find the height above the given line.\n function heightAtLine(lineObj) {\n lineObj = visualLine(lineObj);\n\n var h = 0, chunk = lineObj.parent;\n for (var i = 0; i < chunk.lines.length; ++i) {\n var line = chunk.lines[i];\n if (line == lineObj) { break }\n else { h += line.height; }\n }\n for (var p = chunk.parent; p; chunk = p, p = chunk.parent) {\n for (var i$1 = 0; i$1 < p.children.length; ++i$1) {\n var cur = p.children[i$1];\n if (cur == chunk) { break }\n else { h += cur.height; }\n }\n }\n return h\n }\n\n // Compute the character length of a line, taking into account\n // collapsed ranges (see markText) that might hide parts, and join\n // other lines onto it.\n function lineLength(line) {\n if (line.height == 0) { return 0 }\n var len = line.text.length, merged, cur = line;\n while (merged = collapsedSpanAtStart(cur)) {\n var found = merged.find(0, true);\n cur = found.from.line;\n len += found.from.ch - found.to.ch;\n }\n cur = line;\n while (merged = collapsedSpanAtEnd(cur)) {\n var found$1 = merged.find(0, true);\n len -= cur.text.length - found$1.from.ch;\n cur = found$1.to.line;\n len += cur.text.length - found$1.to.ch;\n }\n return len\n }\n\n // Find the longest line in the document.\n function findMaxLine(cm) {\n var d = cm.display, doc = cm.doc;\n d.maxLine = getLine(doc, doc.first);\n d.maxLineLength = lineLength(d.maxLine);\n d.maxLineChanged = true;\n doc.iter(function (line) {\n var len = lineLength(line);\n if (len > d.maxLineLength) {\n d.maxLineLength = len;\n d.maxLine = line;\n }\n });\n }\n\n // LINE DATA STRUCTURE\n\n // Line objects. These hold state related to a line, including\n // highlighting info (the styles array).\n var Line = function(text, markedSpans, estimateHeight) {\n this.text = text;\n attachMarkedSpans(this, markedSpans);\n this.height = estimateHeight ? estimateHeight(this) : 1;\n };\n\n Line.prototype.lineNo = function () { return lineNo(this) };\n eventMixin(Line);\n\n // Change the content (text, markers) of a line. Automatically\n // invalidates cached information and tries to re-estimate the\n // line's height.\n function updateLine(line, text, markedSpans, estimateHeight) {\n line.text = text;\n if (line.stateAfter) { line.stateAfter = null; }\n if (line.styles) { line.styles = null; }\n if (line.order != null) { line.order = null; }\n detachMarkedSpans(line);\n attachMarkedSpans(line, markedSpans);\n var estHeight = estimateHeight ? estimateHeight(line) : 1;\n if (estHeight != line.height) { updateLineHeight(line, estHeight); }\n }\n\n // Detach a line from the document tree and its markers.\n function cleanUpLine(line) {\n line.parent = null;\n detachMarkedSpans(line);\n }\n\n // Convert a style as returned by a mode (either null, or a string\n // containing one or more styles) to a CSS style. This is cached,\n // and also looks for line-wide styles.\n var styleToClassCache = {}, styleToClassCacheWithMode = {};\n function interpretTokenStyle(style, options) {\n if (!style || /^\\s*$/.test(style)) { return null }\n var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache;\n return cache[style] ||\n (cache[style] = style.replace(/\\S+/g, \"cm-$&\"))\n }\n\n // Render the DOM representation of the text of a line. Also builds\n // up a 'line map', which points at the DOM nodes that represent\n // specific stretches of text, and is used by the measuring code.\n // The returned object contains the DOM node, this map, and\n // information about line-wide styles that were set by the mode.\n function buildLineContent(cm, lineView) {\n // The padding-right forces the element to have a 'border', which\n // is needed on Webkit to be able to get line-level bounding\n // rectangles for it (in measureChar).\n var content = eltP(\"span\", null, null, webkit ? \"padding-right: .1px\" : null);\n var builder = {pre: eltP(\"pre\", [content], \"CodeMirror-line\"), content: content,\n col: 0, pos: 0, cm: cm,\n trailingSpace: false,\n splitSpaces: cm.getOption(\"lineWrapping\")};\n lineView.measure = {};\n\n // Iterate over the logical lines that make up this visual line.\n for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {\n var line = i ? lineView.rest[i - 1] : lineView.line, order = (void 0);\n builder.pos = 0;\n builder.addToken = buildToken;\n // Optionally wire in some hacks into the token-rendering\n // algorithm, to deal with browser quirks.\n if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line, cm.doc.direction)))\n { builder.addToken = buildTokenBadBidi(builder.addToken, order); }\n builder.map = [];\n var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line);\n insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate));\n if (line.styleClasses) {\n if (line.styleClasses.bgClass)\n { builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || \"\"); }\n if (line.styleClasses.textClass)\n { builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || \"\"); }\n }\n\n // Ensure at least a single node is present, for measuring.\n if (builder.map.length == 0)\n { builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure))); }\n\n // Store the map and a cache object for the current logical line\n if (i == 0) {\n lineView.measure.map = builder.map;\n lineView.measure.cache = {};\n } else {\n (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map)\n ;(lineView.measure.caches || (lineView.measure.caches = [])).push({});\n }\n }\n\n // See issue #2901\n if (webkit) {\n var last = builder.content.lastChild;\n if (/\\bcm-tab\\b/.test(last.className) || (last.querySelector && last.querySelector(\".cm-tab\")))\n { builder.content.className = \"cm-tab-wrap-hack\"; }\n }\n\n signal(cm, \"renderLine\", cm, lineView.line, builder.pre);\n if (builder.pre.className)\n { builder.textClass = joinClasses(builder.pre.className, builder.textClass || \"\"); }\n\n return builder\n }\n\n function defaultSpecialCharPlaceholder(ch) {\n var token = elt(\"span\", \"\\u2022\", \"cm-invalidchar\");\n token.title = \"\\\\u\" + ch.charCodeAt(0).toString(16);\n token.setAttribute(\"aria-label\", token.title);\n return token\n }\n\n // Build up the DOM representation for a single token, and add it to\n // the line map. Takes care to render special characters separately.\n function buildToken(builder, text, style, startStyle, endStyle, css, attributes) {\n if (!text) { return }\n var displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text;\n var special = builder.cm.state.specialChars, mustWrap = false;\n var content;\n if (!special.test(text)) {\n builder.col += text.length;\n content = document.createTextNode(displayText);\n builder.map.push(builder.pos, builder.pos + text.length, content);\n if (ie && ie_version < 9) { mustWrap = true; }\n builder.pos += text.length;\n } else {\n content = document.createDocumentFragment();\n var pos = 0;\n while (true) {\n special.lastIndex = pos;\n var m = special.exec(text);\n var skipped = m ? m.index - pos : text.length - pos;\n if (skipped) {\n var txt = document.createTextNode(displayText.slice(pos, pos + skipped));\n if (ie && ie_version < 9) { content.appendChild(elt(\"span\", [txt])); }\n else { content.appendChild(txt); }\n builder.map.push(builder.pos, builder.pos + skipped, txt);\n builder.col += skipped;\n builder.pos += skipped;\n }\n if (!m) { break }\n pos += skipped + 1;\n var txt$1 = (void 0);\n if (m[0] == \"\\t\") {\n var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize;\n txt$1 = content.appendChild(elt(\"span\", spaceStr(tabWidth), \"cm-tab\"));\n txt$1.setAttribute(\"role\", \"presentation\");\n txt$1.setAttribute(\"cm-text\", \"\\t\");\n builder.col += tabWidth;\n } else if (m[0] == \"\\r\" || m[0] == \"\\n\") {\n txt$1 = content.appendChild(elt(\"span\", m[0] == \"\\r\" ? \"\\u240d\" : \"\\u2424\", \"cm-invalidchar\"));\n txt$1.setAttribute(\"cm-text\", m[0]);\n builder.col += 1;\n } else {\n txt$1 = builder.cm.options.specialCharPlaceholder(m[0]);\n txt$1.setAttribute(\"cm-text\", m[0]);\n if (ie && ie_version < 9) { content.appendChild(elt(\"span\", [txt$1])); }\n else { content.appendChild(txt$1); }\n builder.col += 1;\n }\n builder.map.push(builder.pos, builder.pos + 1, txt$1);\n builder.pos++;\n }\n }\n builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32;\n if (style || startStyle || endStyle || mustWrap || css) {\n var fullStyle = style || \"\";\n if (startStyle) { fullStyle += startStyle; }\n if (endStyle) { fullStyle += endStyle; }\n var token = elt(\"span\", [content], fullStyle, css);\n if (attributes) {\n for (var attr in attributes) { if (attributes.hasOwnProperty(attr) && attr != \"style\" && attr != \"class\")\n { token.setAttribute(attr, attributes[attr]); } }\n }\n return builder.content.appendChild(token)\n }\n builder.content.appendChild(content);\n }\n\n // Change some spaces to NBSP to prevent the browser from collapsing\n // trailing spaces at the end of a line when rendering text (issue #1362).\n function splitSpaces(text, trailingBefore) {\n if (text.length > 1 && !/ /.test(text)) { return text }\n var spaceBefore = trailingBefore, result = \"\";\n for (var i = 0; i < text.length; i++) {\n var ch = text.charAt(i);\n if (ch == \" \" && spaceBefore && (i == text.length - 1 || text.charCodeAt(i + 1) == 32))\n { ch = \"\\u00a0\"; }\n result += ch;\n spaceBefore = ch == \" \";\n }\n return result\n }\n\n // Work around nonsense dimensions being reported for stretches of\n // right-to-left text.\n function buildTokenBadBidi(inner, order) {\n return function (builder, text, style, startStyle, endStyle, css, attributes) {\n style = style ? style + \" cm-force-border\" : \"cm-force-border\";\n var start = builder.pos, end = start + text.length;\n for (;;) {\n // Find the part that overlaps with the start of this text\n var part = (void 0);\n for (var i = 0; i < order.length; i++) {\n part = order[i];\n if (part.to > start && part.from <= start) { break }\n }\n if (part.to >= end) { return inner(builder, text, style, startStyle, endStyle, css, attributes) }\n inner(builder, text.slice(0, part.to - start), style, startStyle, null, css, attributes);\n startStyle = null;\n text = text.slice(part.to - start);\n start = part.to;\n }\n }\n }\n\n function buildCollapsedSpan(builder, size, marker, ignoreWidget) {\n var widget = !ignoreWidget && marker.widgetNode;\n if (widget) { builder.map.push(builder.pos, builder.pos + size, widget); }\n if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) {\n if (!widget)\n { widget = builder.content.appendChild(document.createElement(\"span\")); }\n widget.setAttribute(\"cm-marker\", marker.id);\n }\n if (widget) {\n builder.cm.display.input.setUneditable(widget);\n builder.content.appendChild(widget);\n }\n builder.pos += size;\n builder.trailingSpace = false;\n }\n\n // Outputs a number of spans to make up a line, taking highlighting\n // and marked text into account.\n function insertLineContent(line, builder, styles) {\n var spans = line.markedSpans, allText = line.text, at = 0;\n if (!spans) {\n for (var i$1 = 1; i$1 < styles.length; i$1+=2)\n { builder.addToken(builder, allText.slice(at, at = styles[i$1]), interpretTokenStyle(styles[i$1+1], builder.cm.options)); }\n return\n }\n\n var len = allText.length, pos = 0, i = 1, text = \"\", style, css;\n var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, collapsed, attributes;\n for (;;) {\n if (nextChange == pos) { // Update current marker set\n spanStyle = spanEndStyle = spanStartStyle = css = \"\";\n attributes = null;\n collapsed = null; nextChange = Infinity;\n var foundBookmarks = [], endStyles = (void 0);\n for (var j = 0; j < spans.length; ++j) {\n var sp = spans[j], m = sp.marker;\n if (m.type == \"bookmark\" && sp.from == pos && m.widgetNode) {\n foundBookmarks.push(m);\n } else if (sp.from <= pos && (sp.to == null || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) {\n if (sp.to != null && sp.to != pos && nextChange > sp.to) {\n nextChange = sp.to;\n spanEndStyle = \"\";\n }\n if (m.className) { spanStyle += \" \" + m.className; }\n if (m.css) { css = (css ? css + \";\" : \"\") + m.css; }\n if (m.startStyle && sp.from == pos) { spanStartStyle += \" \" + m.startStyle; }\n if (m.endStyle && sp.to == nextChange) { (endStyles || (endStyles = [])).push(m.endStyle, sp.to); }\n // support for the old title property\n // https://github.com/codemirror/CodeMirror/pull/5673\n if (m.title) { (attributes || (attributes = {})).title = m.title; }\n if (m.attributes) {\n for (var attr in m.attributes)\n { (attributes || (attributes = {}))[attr] = m.attributes[attr]; }\n }\n if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))\n { collapsed = sp; }\n } else if (sp.from > pos && nextChange > sp.from) {\n nextChange = sp.from;\n }\n }\n if (endStyles) { for (var j$1 = 0; j$1 < endStyles.length; j$1 += 2)\n { if (endStyles[j$1 + 1] == nextChange) { spanEndStyle += \" \" + endStyles[j$1]; } } }\n\n if (!collapsed || collapsed.from == pos) { for (var j$2 = 0; j$2 < foundBookmarks.length; ++j$2)\n { buildCollapsedSpan(builder, 0, foundBookmarks[j$2]); } }\n if (collapsed && (collapsed.from || 0) == pos) {\n buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,\n collapsed.marker, collapsed.from == null);\n if (collapsed.to == null) { return }\n if (collapsed.to == pos) { collapsed = false; }\n }\n }\n if (pos >= len) { break }\n\n var upto = Math.min(len, nextChange);\n while (true) {\n if (text) {\n var end = pos + text.length;\n if (!collapsed) {\n var tokenText = end > upto ? text.slice(0, upto - pos) : text;\n builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle,\n spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : \"\", css, attributes);\n }\n if (end >= upto) {text = text.slice(upto - pos); pos = upto; break}\n pos = end;\n spanStartStyle = \"\";\n }\n text = allText.slice(at, at = styles[i++]);\n style = interpretTokenStyle(styles[i++], builder.cm.options);\n }\n }\n }\n\n\n // These objects are used to represent the visible (currently drawn)\n // part of the document. A LineView may correspond to multiple\n // logical lines, if those are connected by collapsed ranges.\n function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n }\n\n // Create a range of LineView objects for the given lines.\n function buildViewArray(cm, from, to) {\n var array = [], nextPos;\n for (var pos = from; pos < to; pos = nextPos) {\n var view = new LineView(cm.doc, getLine(cm.doc, pos), pos);\n nextPos = pos + view.size;\n array.push(view);\n }\n return array\n }\n\n var operationGroup = null;\n\n function pushOperation(op) {\n if (operationGroup) {\n operationGroup.ops.push(op);\n } else {\n op.ownsGroup = operationGroup = {\n ops: [op],\n delayedCallbacks: []\n };\n }\n }\n\n function fireCallbacksForOps(group) {\n // Calls delayed callbacks and cursorActivity handlers until no\n // new ones appear\n var callbacks = group.delayedCallbacks, i = 0;\n do {\n for (; i < callbacks.length; i++)\n { callbacks[i].call(null); }\n for (var j = 0; j < group.ops.length; j++) {\n var op = group.ops[j];\n if (op.cursorActivityHandlers)\n { while (op.cursorActivityCalled < op.cursorActivityHandlers.length)\n { op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm); } }\n }\n } while (i < callbacks.length)\n }\n\n function finishOperation(op, endCb) {\n var group = op.ownsGroup;\n if (!group) { return }\n\n try { fireCallbacksForOps(group); }\n finally {\n operationGroup = null;\n endCb(group);\n }\n }\n\n var orphanDelayedCallbacks = null;\n\n // Often, we want to signal events at a point where we are in the\n // middle of some work, but don't want the handler to start calling\n // other methods on the editor, which might be in an inconsistent\n // state or simply not expect any other events to happen.\n // signalLater looks whether there are any handlers, and schedules\n // them to be executed when the last operation ends, or, if no\n // operation is active, when a timeout fires.\n function signalLater(emitter, type /*, values...*/) {\n var arr = getHandlers(emitter, type);\n if (!arr.length) { return }\n var args = Array.prototype.slice.call(arguments, 2), list;\n if (operationGroup) {\n list = operationGroup.delayedCallbacks;\n } else if (orphanDelayedCallbacks) {\n list = orphanDelayedCallbacks;\n } else {\n list = orphanDelayedCallbacks = [];\n setTimeout(fireOrphanDelayed, 0);\n }\n var loop = function ( i ) {\n list.push(function () { return arr[i].apply(null, args); });\n };\n\n for (var i = 0; i < arr.length; ++i)\n loop( i );\n }\n\n function fireOrphanDelayed() {\n var delayed = orphanDelayedCallbacks;\n orphanDelayedCallbacks = null;\n for (var i = 0; i < delayed.length; ++i) { delayed[i](); }\n }\n\n // When an aspect of a line changes, a string is added to\n // lineView.changes. This updates the relevant part of the line's\n // DOM structure.\n function updateLineForChanges(cm, lineView, lineN, dims) {\n for (var j = 0; j < lineView.changes.length; j++) {\n var type = lineView.changes[j];\n if (type == \"text\") { updateLineText(cm, lineView); }\n else if (type == \"gutter\") { updateLineGutter(cm, lineView, lineN, dims); }\n else if (type == \"class\") { updateLineClasses(cm, lineView); }\n else if (type == \"widget\") { updateLineWidgets(cm, lineView, dims); }\n }\n lineView.changes = null;\n }\n\n // Lines with gutter elements, widgets or a background class need to\n // be wrapped, and have the extra elements added to the wrapper div\n function ensureLineWrapped(lineView) {\n if (lineView.node == lineView.text) {\n lineView.node = elt(\"div\", null, null, \"position: relative\");\n if (lineView.text.parentNode)\n { lineView.text.parentNode.replaceChild(lineView.node, lineView.text); }\n lineView.node.appendChild(lineView.text);\n if (ie && ie_version < 8) { lineView.node.style.zIndex = 2; }\n }\n return lineView.node\n }\n\n function updateLineBackground(cm, lineView) {\n var cls = lineView.bgClass ? lineView.bgClass + \" \" + (lineView.line.bgClass || \"\") : lineView.line.bgClass;\n if (cls) { cls += \" CodeMirror-linebackground\"; }\n if (lineView.background) {\n if (cls) { lineView.background.className = cls; }\n else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; }\n } else if (cls) {\n var wrap = ensureLineWrapped(lineView);\n lineView.background = wrap.insertBefore(elt(\"div\", null, cls), wrap.firstChild);\n cm.display.input.setUneditable(lineView.background);\n }\n }\n\n // Wrapper around buildLineContent which will reuse the structure\n // in display.externalMeasured when possible.\n function getLineContent(cm, lineView) {\n var ext = cm.display.externalMeasured;\n if (ext && ext.line == lineView.line) {\n cm.display.externalMeasured = null;\n lineView.measure = ext.measure;\n return ext.built\n }\n return buildLineContent(cm, lineView)\n }\n\n // Redraw the line's text. Interacts with the background and text\n // classes because the mode may output tokens that influence these\n // classes.\n function updateLineText(cm, lineView) {\n var cls = lineView.text.className;\n var built = getLineContent(cm, lineView);\n if (lineView.text == lineView.node) { lineView.node = built.pre; }\n lineView.text.parentNode.replaceChild(built.pre, lineView.text);\n lineView.text = built.pre;\n if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {\n lineView.bgClass = built.bgClass;\n lineView.textClass = built.textClass;\n updateLineClasses(cm, lineView);\n } else if (cls) {\n lineView.text.className = cls;\n }\n }\n\n function updateLineClasses(cm, lineView) {\n updateLineBackground(cm, lineView);\n if (lineView.line.wrapClass)\n { ensureLineWrapped(lineView).className = lineView.line.wrapClass; }\n else if (lineView.node != lineView.text)\n { lineView.node.className = \"\"; }\n var textClass = lineView.textClass ? lineView.textClass + \" \" + (lineView.line.textClass || \"\") : lineView.line.textClass;\n lineView.text.className = textClass || \"\";\n }\n\n function updateLineGutter(cm, lineView, lineN, dims) {\n if (lineView.gutter) {\n lineView.node.removeChild(lineView.gutter);\n lineView.gutter = null;\n }\n if (lineView.gutterBackground) {\n lineView.node.removeChild(lineView.gutterBackground);\n lineView.gutterBackground = null;\n }\n if (lineView.line.gutterClass) {\n var wrap = ensureLineWrapped(lineView);\n lineView.gutterBackground = elt(\"div\", null, \"CodeMirror-gutter-background \" + lineView.line.gutterClass,\n (\"left: \" + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + \"px; width: \" + (dims.gutterTotalWidth) + \"px\"));\n cm.display.input.setUneditable(lineView.gutterBackground);\n wrap.insertBefore(lineView.gutterBackground, lineView.text);\n }\n var markers = lineView.line.gutterMarkers;\n if (cm.options.lineNumbers || markers) {\n var wrap$1 = ensureLineWrapped(lineView);\n var gutterWrap = lineView.gutter = elt(\"div\", null, \"CodeMirror-gutter-wrapper\", (\"left: \" + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + \"px\"));\n cm.display.input.setUneditable(gutterWrap);\n wrap$1.insertBefore(gutterWrap, lineView.text);\n if (lineView.line.gutterClass)\n { gutterWrap.className += \" \" + lineView.line.gutterClass; }\n if (cm.options.lineNumbers && (!markers || !markers[\"CodeMirror-linenumbers\"]))\n { lineView.lineNumber = gutterWrap.appendChild(\n elt(\"div\", lineNumberFor(cm.options, lineN),\n \"CodeMirror-linenumber CodeMirror-gutter-elt\",\n (\"left: \" + (dims.gutterLeft[\"CodeMirror-linenumbers\"]) + \"px; width: \" + (cm.display.lineNumInnerWidth) + \"px\"))); }\n if (markers) { for (var k = 0; k < cm.display.gutterSpecs.length; ++k) {\n var id = cm.display.gutterSpecs[k].className, found = markers.hasOwnProperty(id) && markers[id];\n if (found)\n { gutterWrap.appendChild(elt(\"div\", [found], \"CodeMirror-gutter-elt\",\n (\"left: \" + (dims.gutterLeft[id]) + \"px; width: \" + (dims.gutterWidth[id]) + \"px\"))); }\n } }\n }\n }\n\n function updateLineWidgets(cm, lineView, dims) {\n if (lineView.alignable) { lineView.alignable = null; }\n for (var node = lineView.node.firstChild, next = (void 0); node; node = next) {\n next = node.nextSibling;\n if (node.className == \"CodeMirror-linewidget\")\n { lineView.node.removeChild(node); }\n }\n insertLineWidgets(cm, lineView, dims);\n }\n\n // Build a line's DOM representation from scratch\n function buildLineElement(cm, lineView, lineN, dims) {\n var built = getLineContent(cm, lineView);\n lineView.text = lineView.node = built.pre;\n if (built.bgClass) { lineView.bgClass = built.bgClass; }\n if (built.textClass) { lineView.textClass = built.textClass; }\n\n updateLineClasses(cm, lineView);\n updateLineGutter(cm, lineView, lineN, dims);\n insertLineWidgets(cm, lineView, dims);\n return lineView.node\n }\n\n // A lineView may contain multiple logical lines (when merged by\n // collapsed spans). The widgets for all of them need to be drawn.\n function insertLineWidgets(cm, lineView, dims) {\n insertLineWidgetsFor(cm, lineView.line, lineView, dims, true);\n if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++)\n { insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false); } }\n }\n\n function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {\n if (!line.widgets) { return }\n var wrap = ensureLineWrapped(lineView);\n for (var i = 0, ws = line.widgets; i < ws.length; ++i) {\n var widget = ws[i], node = elt(\"div\", [widget.node], \"CodeMirror-linewidget\");\n if (!widget.handleMouseEvents) { node.setAttribute(\"cm-ignore-events\", \"true\"); }\n positionLineWidget(widget, node, lineView, dims);\n cm.display.input.setUneditable(node);\n if (allowAbove && widget.above)\n { wrap.insertBefore(node, lineView.gutter || lineView.text); }\n else\n { wrap.appendChild(node); }\n signalLater(widget, \"redraw\");\n }\n }\n\n function positionLineWidget(widget, node, lineView, dims) {\n if (widget.noHScroll) {\n (lineView.alignable || (lineView.alignable = [])).push(node);\n var width = dims.wrapperWidth;\n node.style.left = dims.fixedPos + \"px\";\n if (!widget.coverGutter) {\n width -= dims.gutterTotalWidth;\n node.style.paddingLeft = dims.gutterTotalWidth + \"px\";\n }\n node.style.width = width + \"px\";\n }\n if (widget.coverGutter) {\n node.style.zIndex = 5;\n node.style.position = \"relative\";\n if (!widget.noHScroll) { node.style.marginLeft = -dims.gutterTotalWidth + \"px\"; }\n }\n }\n\n function widgetHeight(widget) {\n if (widget.height != null) { return widget.height }\n var cm = widget.doc.cm;\n if (!cm) { return 0 }\n if (!contains(document.body, widget.node)) {\n var parentStyle = \"position: relative;\";\n if (widget.coverGutter)\n { parentStyle += \"margin-left: -\" + cm.display.gutters.offsetWidth + \"px;\"; }\n if (widget.noHScroll)\n { parentStyle += \"width: \" + cm.display.wrapper.clientWidth + \"px;\"; }\n removeChildrenAndAdd(cm.display.measure, elt(\"div\", [widget.node], null, parentStyle));\n }\n return widget.height = widget.node.parentNode.offsetHeight\n }\n\n // Return true when the given mouse event happened in a widget\n function eventInWidget(display, e) {\n for (var n = e_target(e); n != display.wrapper; n = n.parentNode) {\n if (!n || (n.nodeType == 1 && n.getAttribute(\"cm-ignore-events\") == \"true\") ||\n (n.parentNode == display.sizer && n != display.mover))\n { return true }\n }\n }\n\n // POSITION MEASUREMENT\n\n function paddingTop(display) {return display.lineSpace.offsetTop}\n function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight}\n function paddingH(display) {\n if (display.cachedPaddingH) { return display.cachedPaddingH }\n var e = removeChildrenAndAdd(display.measure, elt(\"pre\", \"x\", \"CodeMirror-line-like\"));\n var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle;\n var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)};\n if (!isNaN(data.left) && !isNaN(data.right)) { display.cachedPaddingH = data; }\n return data\n }\n\n function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth }\n function displayWidth(cm) {\n return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth\n }\n function displayHeight(cm) {\n return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight\n }\n\n // Ensure the lineView.wrapping.heights array is populated. This is\n // an array of bottom offsets for the lines that make up a drawn\n // line. When lineWrapping is on, there might be more than one\n // height.\n function ensureLineHeights(cm, lineView, rect) {\n var wrapping = cm.options.lineWrapping;\n var curWidth = wrapping && displayWidth(cm);\n if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {\n var heights = lineView.measure.heights = [];\n if (wrapping) {\n lineView.measure.width = curWidth;\n var rects = lineView.text.firstChild.getClientRects();\n for (var i = 0; i < rects.length - 1; i++) {\n var cur = rects[i], next = rects[i + 1];\n if (Math.abs(cur.bottom - next.bottom) > 2)\n { heights.push((cur.bottom + next.top) / 2 - rect.top); }\n }\n }\n heights.push(rect.bottom - rect.top);\n }\n }\n\n // Find a line map (mapping character offsets to text nodes) and a\n // measurement cache for the given line number. (A line view might\n // contain multiple lines when collapsed ranges are present.)\n function mapFromLineView(lineView, line, lineN) {\n if (lineView.line == line)\n { return {map: lineView.measure.map, cache: lineView.measure.cache} }\n for (var i = 0; i < lineView.rest.length; i++)\n { if (lineView.rest[i] == line)\n { return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]} } }\n for (var i$1 = 0; i$1 < lineView.rest.length; i$1++)\n { if (lineNo(lineView.rest[i$1]) > lineN)\n { return {map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true} } }\n }\n\n // Render a line into the hidden node display.externalMeasured. Used\n // when measurement is needed for a line that's not in the viewport.\n function updateExternalMeasurement(cm, line) {\n line = visualLine(line);\n var lineN = lineNo(line);\n var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN);\n view.lineN = lineN;\n var built = view.built = buildLineContent(cm, view);\n view.text = built.pre;\n removeChildrenAndAdd(cm.display.lineMeasure, built.pre);\n return view\n }\n\n // Get a {top, bottom, left, right} box (in line-local coordinates)\n // for a given character.\n function measureChar(cm, line, ch, bias) {\n return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias)\n }\n\n // Find a line view that corresponds to the given line number.\n function findViewForLine(cm, lineN) {\n if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)\n { return cm.display.view[findViewIndex(cm, lineN)] }\n var ext = cm.display.externalMeasured;\n if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)\n { return ext }\n }\n\n // Measurement can be split in two steps, the set-up work that\n // applies to the whole line, and the measurement of the actual\n // character. Functions like coordsChar, that need to do a lot of\n // measurements in a row, can thus ensure that the set-up work is\n // only done once.\n function prepareMeasureForLine(cm, line) {\n var lineN = lineNo(line);\n var view = findViewForLine(cm, lineN);\n if (view && !view.text) {\n view = null;\n } else if (view && view.changes) {\n updateLineForChanges(cm, view, lineN, getDimensions(cm));\n cm.curOp.forceUpdate = true;\n }\n if (!view)\n { view = updateExternalMeasurement(cm, line); }\n\n var info = mapFromLineView(view, line, lineN);\n return {\n line: line, view: view, rect: null,\n map: info.map, cache: info.cache, before: info.before,\n hasHeights: false\n }\n }\n\n // Given a prepared measurement object, measures the position of an\n // actual character (or fetches it from the cache).\n function measureCharPrepared(cm, prepared, ch, bias, varHeight) {\n if (prepared.before) { ch = -1; }\n var key = ch + (bias || \"\"), found;\n if (prepared.cache.hasOwnProperty(key)) {\n found = prepared.cache[key];\n } else {\n if (!prepared.rect)\n { prepared.rect = prepared.view.text.getBoundingClientRect(); }\n if (!prepared.hasHeights) {\n ensureLineHeights(cm, prepared.view, prepared.rect);\n prepared.hasHeights = true;\n }\n found = measureCharInner(cm, prepared, ch, bias);\n if (!found.bogus) { prepared.cache[key] = found; }\n }\n return {left: found.left, right: found.right,\n top: varHeight ? found.rtop : found.top,\n bottom: varHeight ? found.rbottom : found.bottom}\n }\n\n var nullRect = {left: 0, right: 0, top: 0, bottom: 0};\n\n function nodeAndOffsetInLineMap(map$$1, ch, bias) {\n var node, start, end, collapse, mStart, mEnd;\n // First, search the line map for the text node corresponding to,\n // or closest to, the target character.\n for (var i = 0; i < map$$1.length; i += 3) {\n mStart = map$$1[i];\n mEnd = map$$1[i + 1];\n if (ch < mStart) {\n start = 0; end = 1;\n collapse = \"left\";\n } else if (ch < mEnd) {\n start = ch - mStart;\n end = start + 1;\n } else if (i == map$$1.length - 3 || ch == mEnd && map$$1[i + 3] > ch) {\n end = mEnd - mStart;\n start = end - 1;\n if (ch >= mEnd) { collapse = \"right\"; }\n }\n if (start != null) {\n node = map$$1[i + 2];\n if (mStart == mEnd && bias == (node.insertLeft ? \"left\" : \"right\"))\n { collapse = bias; }\n if (bias == \"left\" && start == 0)\n { while (i && map$$1[i - 2] == map$$1[i - 3] && map$$1[i - 1].insertLeft) {\n node = map$$1[(i -= 3) + 2];\n collapse = \"left\";\n } }\n if (bias == \"right\" && start == mEnd - mStart)\n { while (i < map$$1.length - 3 && map$$1[i + 3] == map$$1[i + 4] && !map$$1[i + 5].insertLeft) {\n node = map$$1[(i += 3) + 2];\n collapse = \"right\";\n } }\n break\n }\n }\n return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd}\n }\n\n function getUsefulRect(rects, bias) {\n var rect = nullRect;\n if (bias == \"left\") { for (var i = 0; i < rects.length; i++) {\n if ((rect = rects[i]).left != rect.right) { break }\n } } else { for (var i$1 = rects.length - 1; i$1 >= 0; i$1--) {\n if ((rect = rects[i$1]).left != rect.right) { break }\n } }\n return rect\n }\n\n function measureCharInner(cm, prepared, ch, bias) {\n var place = nodeAndOffsetInLineMap(prepared.map, ch, bias);\n var node = place.node, start = place.start, end = place.end, collapse = place.collapse;\n\n var rect;\n if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates.\n for (var i$1 = 0; i$1 < 4; i$1++) { // Retry a maximum of 4 times when nonsense rectangles are returned\n while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) { --start; }\n while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) { ++end; }\n if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart)\n { rect = node.parentNode.getBoundingClientRect(); }\n else\n { rect = getUsefulRect(range(node, start, end).getClientRects(), bias); }\n if (rect.left || rect.right || start == 0) { break }\n end = start;\n start = start - 1;\n collapse = \"right\";\n }\n if (ie && ie_version < 11) { rect = maybeUpdateRectForZooming(cm.display.measure, rect); }\n } else { // If it is a widget, simply get the box for the whole widget.\n if (start > 0) { collapse = bias = \"right\"; }\n var rects;\n if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1)\n { rect = rects[bias == \"right\" ? rects.length - 1 : 0]; }\n else\n { rect = node.getBoundingClientRect(); }\n }\n if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) {\n var rSpan = node.parentNode.getClientRects()[0];\n if (rSpan)\n { rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom}; }\n else\n { rect = nullRect; }\n }\n\n var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top;\n var mid = (rtop + rbot) / 2;\n var heights = prepared.view.measure.heights;\n var i = 0;\n for (; i < heights.length - 1; i++)\n { if (mid < heights[i]) { break } }\n var top = i ? heights[i - 1] : 0, bot = heights[i];\n var result = {left: (collapse == \"right\" ? rect.right : rect.left) - prepared.rect.left,\n right: (collapse == \"left\" ? rect.left : rect.right) - prepared.rect.left,\n top: top, bottom: bot};\n if (!rect.left && !rect.right) { result.bogus = true; }\n if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot; }\n\n return result\n }\n\n // Work around problem with bounding client rects on ranges being\n // returned incorrectly when zoomed on IE10 and below.\n function maybeUpdateRectForZooming(measure, rect) {\n if (!window.screen || screen.logicalXDPI == null ||\n screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure))\n { return rect }\n var scaleX = screen.logicalXDPI / screen.deviceXDPI;\n var scaleY = screen.logicalYDPI / screen.deviceYDPI;\n return {left: rect.left * scaleX, right: rect.right * scaleX,\n top: rect.top * scaleY, bottom: rect.bottom * scaleY}\n }\n\n function clearLineMeasurementCacheFor(lineView) {\n if (lineView.measure) {\n lineView.measure.cache = {};\n lineView.measure.heights = null;\n if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++)\n { lineView.measure.caches[i] = {}; } }\n }\n }\n\n function clearLineMeasurementCache(cm) {\n cm.display.externalMeasure = null;\n removeChildren(cm.display.lineMeasure);\n for (var i = 0; i < cm.display.view.length; i++)\n { clearLineMeasurementCacheFor(cm.display.view[i]); }\n }\n\n function clearCaches(cm) {\n clearLineMeasurementCache(cm);\n cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null;\n if (!cm.options.lineWrapping) { cm.display.maxLineChanged = true; }\n cm.display.lineNumChars = null;\n }\n\n function pageScrollX() {\n // Work around https://bugs.chromium.org/p/chromium/issues/detail?id=489206\n // which causes page_Offset and bounding client rects to use\n // different reference viewports and invalidate our calculations.\n if (chrome && android) { return -(document.body.getBoundingClientRect().left - parseInt(getComputedStyle(document.body).marginLeft)) }\n return window.pageXOffset || (document.documentElement || document.body).scrollLeft\n }\n function pageScrollY() {\n if (chrome && android) { return -(document.body.getBoundingClientRect().top - parseInt(getComputedStyle(document.body).marginTop)) }\n return window.pageYOffset || (document.documentElement || document.body).scrollTop\n }\n\n function widgetTopHeight(lineObj) {\n var height = 0;\n if (lineObj.widgets) { for (var i = 0; i < lineObj.widgets.length; ++i) { if (lineObj.widgets[i].above)\n { height += widgetHeight(lineObj.widgets[i]); } } }\n return height\n }\n\n // Converts a {top, bottom, left, right} box from line-local\n // coordinates into another coordinate system. Context may be one of\n // \"line\", \"div\" (display.lineDiv), \"local\"./null (editor), \"window\",\n // or \"page\".\n function intoCoordSystem(cm, lineObj, rect, context, includeWidgets) {\n if (!includeWidgets) {\n var height = widgetTopHeight(lineObj);\n rect.top += height; rect.bottom += height;\n }\n if (context == \"line\") { return rect }\n if (!context) { context = \"local\"; }\n var yOff = heightAtLine(lineObj);\n if (context == \"local\") { yOff += paddingTop(cm.display); }\n else { yOff -= cm.display.viewOffset; }\n if (context == \"page\" || context == \"window\") {\n var lOff = cm.display.lineSpace.getBoundingClientRect();\n yOff += lOff.top + (context == \"window\" ? 0 : pageScrollY());\n var xOff = lOff.left + (context == \"window\" ? 0 : pageScrollX());\n rect.left += xOff; rect.right += xOff;\n }\n rect.top += yOff; rect.bottom += yOff;\n return rect\n }\n\n // Coverts a box from \"div\" coords to another coordinate system.\n // Context may be \"window\", \"page\", \"div\", or \"local\"./null.\n function fromCoordSystem(cm, coords, context) {\n if (context == \"div\") { return coords }\n var left = coords.left, top = coords.top;\n // First move into \"page\" coordinate system\n if (context == \"page\") {\n left -= pageScrollX();\n top -= pageScrollY();\n } else if (context == \"local\" || !context) {\n var localBox = cm.display.sizer.getBoundingClientRect();\n left += localBox.left;\n top += localBox.top;\n }\n\n var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect();\n return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top}\n }\n\n function charCoords(cm, pos, context, lineObj, bias) {\n if (!lineObj) { lineObj = getLine(cm.doc, pos.line); }\n return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context)\n }\n\n // Returns a box for a given cursor position, which may have an\n // 'other' property containing the position of the secondary cursor\n // on a bidi boundary.\n // A cursor Pos(line, char, \"before\") is on the same visual line as `char - 1`\n // and after `char - 1` in writing order of `char - 1`\n // A cursor Pos(line, char, \"after\") is on the same visual line as `char`\n // and before `char` in writing order of `char`\n // Examples (upper-case letters are RTL, lower-case are LTR):\n // Pos(0, 1, ...)\n // before after\n // ab a|b a|b\n // aB a|B aB|\n // Ab |Ab A|b\n // AB B|A B|A\n // Every position after the last character on a line is considered to stick\n // to the last character on the line.\n function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {\n lineObj = lineObj || getLine(cm.doc, pos.line);\n if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); }\n function get(ch, right) {\n var m = measureCharPrepared(cm, preparedMeasure, ch, right ? \"right\" : \"left\", varHeight);\n if (right) { m.left = m.right; } else { m.right = m.left; }\n return intoCoordSystem(cm, lineObj, m, context)\n }\n var order = getOrder(lineObj, cm.doc.direction), ch = pos.ch, sticky = pos.sticky;\n if (ch >= lineObj.text.length) {\n ch = lineObj.text.length;\n sticky = \"before\";\n } else if (ch <= 0) {\n ch = 0;\n sticky = \"after\";\n }\n if (!order) { return get(sticky == \"before\" ? ch - 1 : ch, sticky == \"before\") }\n\n function getBidi(ch, partPos, invert) {\n var part = order[partPos], right = part.level == 1;\n return get(invert ? ch - 1 : ch, right != invert)\n }\n var partPos = getBidiPartAt(order, ch, sticky);\n var other = bidiOther;\n var val = getBidi(ch, partPos, sticky == \"before\");\n if (other != null) { val.other = getBidi(ch, other, sticky != \"before\"); }\n return val\n }\n\n // Used to cheaply estimate the coordinates for a position. Used for\n // intermediate scroll updates.\n function estimateCoords(cm, pos) {\n var left = 0;\n pos = clipPos(cm.doc, pos);\n if (!cm.options.lineWrapping) { left = charWidth(cm.display) * pos.ch; }\n var lineObj = getLine(cm.doc, pos.line);\n var top = heightAtLine(lineObj) + paddingTop(cm.display);\n return {left: left, right: left, top: top, bottom: top + lineObj.height}\n }\n\n // Positions returned by coordsChar contain some extra information.\n // xRel is the relative x position of the input coordinates compared\n // to the found position (so xRel > 0 means the coordinates are to\n // the right of the character position, for example). When outside\n // is true, that means the coordinates lie outside the line's\n // vertical range.\n function PosWithInfo(line, ch, sticky, outside, xRel) {\n var pos = Pos(line, ch, sticky);\n pos.xRel = xRel;\n if (outside) { pos.outside = outside; }\n return pos\n }\n\n // Compute the character position closest to the given coordinates.\n // Input must be lineSpace-local (\"div\" coordinate system).\n function coordsChar(cm, x, y) {\n var doc = cm.doc;\n y += cm.display.viewOffset;\n if (y < 0) { return PosWithInfo(doc.first, 0, null, -1, -1) }\n var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1;\n if (lineN > last)\n { return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, null, 1, 1) }\n if (x < 0) { x = 0; }\n\n var lineObj = getLine(doc, lineN);\n for (;;) {\n var found = coordsCharInner(cm, lineObj, lineN, x, y);\n var collapsed = collapsedSpanAround(lineObj, found.ch + (found.xRel > 0 || found.outside > 0 ? 1 : 0));\n if (!collapsed) { return found }\n var rangeEnd = collapsed.find(1);\n if (rangeEnd.line == lineN) { return rangeEnd }\n lineObj = getLine(doc, lineN = rangeEnd.line);\n }\n }\n\n function wrappedLineExtent(cm, lineObj, preparedMeasure, y) {\n y -= widgetTopHeight(lineObj);\n var end = lineObj.text.length;\n var begin = findFirst(function (ch) { return measureCharPrepared(cm, preparedMeasure, ch - 1).bottom <= y; }, end, 0);\n end = findFirst(function (ch) { return measureCharPrepared(cm, preparedMeasure, ch).top > y; }, begin, end);\n return {begin: begin, end: end}\n }\n\n function wrappedLineExtentChar(cm, lineObj, preparedMeasure, target) {\n if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); }\n var targetTop = intoCoordSystem(cm, lineObj, measureCharPrepared(cm, preparedMeasure, target), \"line\").top;\n return wrappedLineExtent(cm, lineObj, preparedMeasure, targetTop)\n }\n\n // Returns true if the given side of a box is after the given\n // coordinates, in top-to-bottom, left-to-right order.\n function boxIsAfter(box, x, y, left) {\n return box.bottom <= y ? false : box.top > y ? true : (left ? box.left : box.right) > x\n }\n\n function coordsCharInner(cm, lineObj, lineNo$$1, x, y) {\n // Move y into line-local coordinate space\n y -= heightAtLine(lineObj);\n var preparedMeasure = prepareMeasureForLine(cm, lineObj);\n // When directly calling `measureCharPrepared`, we have to adjust\n // for the widgets at this line.\n var widgetHeight$$1 = widgetTopHeight(lineObj);\n var begin = 0, end = lineObj.text.length, ltr = true;\n\n var order = getOrder(lineObj, cm.doc.direction);\n // If the line isn't plain left-to-right text, first figure out\n // which bidi section the coordinates fall into.\n if (order) {\n var part = (cm.options.lineWrapping ? coordsBidiPartWrapped : coordsBidiPart)\n (cm, lineObj, lineNo$$1, preparedMeasure, order, x, y);\n ltr = part.level != 1;\n // The awkward -1 offsets are needed because findFirst (called\n // on these below) will treat its first bound as inclusive,\n // second as exclusive, but we want to actually address the\n // characters in the part's range\n begin = ltr ? part.from : part.to - 1;\n end = ltr ? part.to : part.from - 1;\n }\n\n // A binary search to find the first character whose bounding box\n // starts after the coordinates. If we run across any whose box wrap\n // the coordinates, store that.\n var chAround = null, boxAround = null;\n var ch = findFirst(function (ch) {\n var box = measureCharPrepared(cm, preparedMeasure, ch);\n box.top += widgetHeight$$1; box.bottom += widgetHeight$$1;\n if (!boxIsAfter(box, x, y, false)) { return false }\n if (box.top <= y && box.left <= x) {\n chAround = ch;\n boxAround = box;\n }\n return true\n }, begin, end);\n\n var baseX, sticky, outside = false;\n // If a box around the coordinates was found, use that\n if (boxAround) {\n // Distinguish coordinates nearer to the left or right side of the box\n var atLeft = x - boxAround.left < boxAround.right - x, atStart = atLeft == ltr;\n ch = chAround + (atStart ? 0 : 1);\n sticky = atStart ? \"after\" : \"before\";\n baseX = atLeft ? boxAround.left : boxAround.right;\n } else {\n // (Adjust for extended bound, if necessary.)\n if (!ltr && (ch == end || ch == begin)) { ch++; }\n // To determine which side to associate with, get the box to the\n // left of the character and compare it's vertical position to the\n // coordinates\n sticky = ch == 0 ? \"after\" : ch == lineObj.text.length ? \"before\" :\n (measureCharPrepared(cm, preparedMeasure, ch - (ltr ? 1 : 0)).bottom + widgetHeight$$1 <= y) == ltr ?\n \"after\" : \"before\";\n // Now get accurate coordinates for this place, in order to get a\n // base X position\n var coords = cursorCoords(cm, Pos(lineNo$$1, ch, sticky), \"line\", lineObj, preparedMeasure);\n baseX = coords.left;\n outside = y < coords.top ? -1 : y >= coords.bottom ? 1 : 0;\n }\n\n ch = skipExtendingChars(lineObj.text, ch, 1);\n return PosWithInfo(lineNo$$1, ch, sticky, outside, x - baseX)\n }\n\n function coordsBidiPart(cm, lineObj, lineNo$$1, preparedMeasure, order, x, y) {\n // Bidi parts are sorted left-to-right, and in a non-line-wrapping\n // situation, we can take this ordering to correspond to the visual\n // ordering. This finds the first part whose end is after the given\n // coordinates.\n var index = findFirst(function (i) {\n var part = order[i], ltr = part.level != 1;\n return boxIsAfter(cursorCoords(cm, Pos(lineNo$$1, ltr ? part.to : part.from, ltr ? \"before\" : \"after\"),\n \"line\", lineObj, preparedMeasure), x, y, true)\n }, 0, order.length - 1);\n var part = order[index];\n // If this isn't the first part, the part's start is also after\n // the coordinates, and the coordinates aren't on the same line as\n // that start, move one part back.\n if (index > 0) {\n var ltr = part.level != 1;\n var start = cursorCoords(cm, Pos(lineNo$$1, ltr ? part.from : part.to, ltr ? \"after\" : \"before\"),\n \"line\", lineObj, preparedMeasure);\n if (boxIsAfter(start, x, y, true) && start.top > y)\n { part = order[index - 1]; }\n }\n return part\n }\n\n function coordsBidiPartWrapped(cm, lineObj, _lineNo, preparedMeasure, order, x, y) {\n // In a wrapped line, rtl text on wrapping boundaries can do things\n // that don't correspond to the ordering in our `order` array at\n // all, so a binary search doesn't work, and we want to return a\n // part that only spans one line so that the binary search in\n // coordsCharInner is safe. As such, we first find the extent of the\n // wrapped line, and then do a flat search in which we discard any\n // spans that aren't on the line.\n var ref = wrappedLineExtent(cm, lineObj, preparedMeasure, y);\n var begin = ref.begin;\n var end = ref.end;\n if (/\\s/.test(lineObj.text.charAt(end - 1))) { end--; }\n var part = null, closestDist = null;\n for (var i = 0; i < order.length; i++) {\n var p = order[i];\n if (p.from >= end || p.to <= begin) { continue }\n var ltr = p.level != 1;\n var endX = measureCharPrepared(cm, preparedMeasure, ltr ? Math.min(end, p.to) - 1 : Math.max(begin, p.from)).right;\n // Weigh against spans ending before this, so that they are only\n // picked if nothing ends after\n var dist = endX < x ? x - endX + 1e9 : endX - x;\n if (!part || closestDist > dist) {\n part = p;\n closestDist = dist;\n }\n }\n if (!part) { part = order[order.length - 1]; }\n // Clip the part to the wrapped line.\n if (part.from < begin) { part = {from: begin, to: part.to, level: part.level}; }\n if (part.to > end) { part = {from: part.from, to: end, level: part.level}; }\n return part\n }\n\n var measureText;\n // Compute the default text height.\n function textHeight(display) {\n if (display.cachedTextHeight != null) { return display.cachedTextHeight }\n if (measureText == null) {\n measureText = elt(\"pre\", null, \"CodeMirror-line-like\");\n // Measure a bunch of lines, for browsers that compute\n // fractional heights.\n for (var i = 0; i < 49; ++i) {\n measureText.appendChild(document.createTextNode(\"x\"));\n measureText.appendChild(elt(\"br\"));\n }\n measureText.appendChild(document.createTextNode(\"x\"));\n }\n removeChildrenAndAdd(display.measure, measureText);\n var height = measureText.offsetHeight / 50;\n if (height > 3) { display.cachedTextHeight = height; }\n removeChildren(display.measure);\n return height || 1\n }\n\n // Compute the default character width.\n function charWidth(display) {\n if (display.cachedCharWidth != null) { return display.cachedCharWidth }\n var anchor = elt(\"span\", \"xxxxxxxxxx\");\n var pre = elt(\"pre\", [anchor], \"CodeMirror-line-like\");\n removeChildrenAndAdd(display.measure, pre);\n var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10;\n if (width > 2) { display.cachedCharWidth = width; }\n return width || 10\n }\n\n // Do a bulk-read of the DOM positions and sizes needed to draw the\n // view, so that we don't interleave reading and writing to the DOM.\n function getDimensions(cm) {\n var d = cm.display, left = {}, width = {};\n var gutterLeft = d.gutters.clientLeft;\n for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {\n var id = cm.display.gutterSpecs[i].className;\n left[id] = n.offsetLeft + n.clientLeft + gutterLeft;\n width[id] = n.clientWidth;\n }\n return {fixedPos: compensateForHScroll(d),\n gutterTotalWidth: d.gutters.offsetWidth,\n gutterLeft: left,\n gutterWidth: width,\n wrapperWidth: d.wrapper.clientWidth}\n }\n\n // Computes display.scroller.scrollLeft + display.gutters.offsetWidth,\n // but using getBoundingClientRect to get a sub-pixel-accurate\n // result.\n function compensateForHScroll(display) {\n return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left\n }\n\n // Returns a function that estimates the height of a line, to use as\n // first approximation until the line becomes visible (and is thus\n // properly measurable).\n function estimateHeight(cm) {\n var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;\n var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);\n return function (line) {\n if (lineIsHidden(cm.doc, line)) { return 0 }\n\n var widgetsHeight = 0;\n if (line.widgets) { for (var i = 0; i < line.widgets.length; i++) {\n if (line.widgets[i].height) { widgetsHeight += line.widgets[i].height; }\n } }\n\n if (wrapping)\n { return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th }\n else\n { return widgetsHeight + th }\n }\n }\n\n function estimateLineHeights(cm) {\n var doc = cm.doc, est = estimateHeight(cm);\n doc.iter(function (line) {\n var estHeight = est(line);\n if (estHeight != line.height) { updateLineHeight(line, estHeight); }\n });\n }\n\n // Given a mouse event, find the corresponding position. If liberal\n // is false, it checks whether a gutter or scrollbar was clicked,\n // and returns null if it was. forRect is used by rectangular\n // selections, and tries to estimate a character position even for\n // coordinates beyond the right of the text.\n function posFromMouse(cm, e, liberal, forRect) {\n var display = cm.display;\n if (!liberal && e_target(e).getAttribute(\"cm-not-content\") == \"true\") { return null }\n\n var x, y, space = display.lineSpace.getBoundingClientRect();\n // Fails unpredictably on IE[67] when mouse is dragged around quickly.\n try { x = e.clientX - space.left; y = e.clientY - space.top; }\n catch (e) { return null }\n var coords = coordsChar(cm, x, y), line;\n if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {\n var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length;\n coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff));\n }\n return coords\n }\n\n // Find the view element corresponding to a given line. Return null\n // when the line isn't visible.\n function findViewIndex(cm, n) {\n if (n >= cm.display.viewTo) { return null }\n n -= cm.display.viewFrom;\n if (n < 0) { return null }\n var view = cm.display.view;\n for (var i = 0; i < view.length; i++) {\n n -= view[i].size;\n if (n < 0) { return i }\n }\n }\n\n // Updates the display.view data structure for a given change to the\n // document. From and to are in pre-change coordinates. Lendiff is\n // the amount of lines added or subtracted by the change. This is\n // used for changes that span multiple lines, or change the way\n // lines are divided into visual lines. regLineChange (below)\n // registers single-line changes.\n function regChange(cm, from, to, lendiff) {\n if (from == null) { from = cm.doc.first; }\n if (to == null) { to = cm.doc.first + cm.doc.size; }\n if (!lendiff) { lendiff = 0; }\n\n var display = cm.display;\n if (lendiff && to < display.viewTo &&\n (display.updateLineNumbers == null || display.updateLineNumbers > from))\n { display.updateLineNumbers = from; }\n\n cm.curOp.viewChanged = true;\n\n if (from >= display.viewTo) { // Change after\n if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo)\n { resetView(cm); }\n } else if (to <= display.viewFrom) { // Change before\n if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) {\n resetView(cm);\n } else {\n display.viewFrom += lendiff;\n display.viewTo += lendiff;\n }\n } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap\n resetView(cm);\n } else if (from <= display.viewFrom) { // Top overlap\n var cut = viewCuttingPoint(cm, to, to + lendiff, 1);\n if (cut) {\n display.view = display.view.slice(cut.index);\n display.viewFrom = cut.lineN;\n display.viewTo += lendiff;\n } else {\n resetView(cm);\n }\n } else if (to >= display.viewTo) { // Bottom overlap\n var cut$1 = viewCuttingPoint(cm, from, from, -1);\n if (cut$1) {\n display.view = display.view.slice(0, cut$1.index);\n display.viewTo = cut$1.lineN;\n } else {\n resetView(cm);\n }\n } else { // Gap in the middle\n var cutTop = viewCuttingPoint(cm, from, from, -1);\n var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1);\n if (cutTop && cutBot) {\n display.view = display.view.slice(0, cutTop.index)\n .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN))\n .concat(display.view.slice(cutBot.index));\n display.viewTo += lendiff;\n } else {\n resetView(cm);\n }\n }\n\n var ext = display.externalMeasured;\n if (ext) {\n if (to < ext.lineN)\n { ext.lineN += lendiff; }\n else if (from < ext.lineN + ext.size)\n { display.externalMeasured = null; }\n }\n }\n\n // Register a change to a single line. Type must be one of \"text\",\n // \"gutter\", \"class\", \"widget\"\n function regLineChange(cm, line, type) {\n cm.curOp.viewChanged = true;\n var display = cm.display, ext = cm.display.externalMeasured;\n if (ext && line >= ext.lineN && line < ext.lineN + ext.size)\n { display.externalMeasured = null; }\n\n if (line < display.viewFrom || line >= display.viewTo) { return }\n var lineView = display.view[findViewIndex(cm, line)];\n if (lineView.node == null) { return }\n var arr = lineView.changes || (lineView.changes = []);\n if (indexOf(arr, type) == -1) { arr.push(type); }\n }\n\n // Clear the view.\n function resetView(cm) {\n cm.display.viewFrom = cm.display.viewTo = cm.doc.first;\n cm.display.view = [];\n cm.display.viewOffset = 0;\n }\n\n function viewCuttingPoint(cm, oldN, newN, dir) {\n var index = findViewIndex(cm, oldN), diff, view = cm.display.view;\n if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size)\n { return {index: index, lineN: newN} }\n var n = cm.display.viewFrom;\n for (var i = 0; i < index; i++)\n { n += view[i].size; }\n if (n != oldN) {\n if (dir > 0) {\n if (index == view.length - 1) { return null }\n diff = (n + view[index].size) - oldN;\n index++;\n } else {\n diff = n - oldN;\n }\n oldN += diff; newN += diff;\n }\n while (visualLineNo(cm.doc, newN) != newN) {\n if (index == (dir < 0 ? 0 : view.length - 1)) { return null }\n newN += dir * view[index - (dir < 0 ? 1 : 0)].size;\n index += dir;\n }\n return {index: index, lineN: newN}\n }\n\n // Force the view to cover a given range, adding empty view element\n // or clipping off existing ones as needed.\n function adjustView(cm, from, to) {\n var display = cm.display, view = display.view;\n if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {\n display.view = buildViewArray(cm, from, to);\n display.viewFrom = from;\n } else {\n if (display.viewFrom > from)\n { display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view); }\n else if (display.viewFrom < from)\n { display.view = display.view.slice(findViewIndex(cm, from)); }\n display.viewFrom = from;\n if (display.viewTo < to)\n { display.view = display.view.concat(buildViewArray(cm, display.viewTo, to)); }\n else if (display.viewTo > to)\n { display.view = display.view.slice(0, findViewIndex(cm, to)); }\n }\n display.viewTo = to;\n }\n\n // Count the number of lines in the view whose DOM representation is\n // out of date (or nonexistent).\n function countDirtyView(cm) {\n var view = cm.display.view, dirty = 0;\n for (var i = 0; i < view.length; i++) {\n var lineView = view[i];\n if (!lineView.hidden && (!lineView.node || lineView.changes)) { ++dirty; }\n }\n return dirty\n }\n\n function updateSelection(cm) {\n cm.display.input.showSelection(cm.display.input.prepareSelection());\n }\n\n function prepareSelection(cm, primary) {\n if ( primary === void 0 ) primary = true;\n\n var doc = cm.doc, result = {};\n var curFragment = result.cursors = document.createDocumentFragment();\n var selFragment = result.selection = document.createDocumentFragment();\n\n for (var i = 0; i < doc.sel.ranges.length; i++) {\n if (!primary && i == doc.sel.primIndex) { continue }\n var range$$1 = doc.sel.ranges[i];\n if (range$$1.from().line >= cm.display.viewTo || range$$1.to().line < cm.display.viewFrom) { continue }\n var collapsed = range$$1.empty();\n if (collapsed || cm.options.showCursorWhenSelecting)\n { drawSelectionCursor(cm, range$$1.head, curFragment); }\n if (!collapsed)\n { drawSelectionRange(cm, range$$1, selFragment); }\n }\n return result\n }\n\n // Draws a cursor for the given range\n function drawSelectionCursor(cm, head, output) {\n var pos = cursorCoords(cm, head, \"div\", null, null, !cm.options.singleCursorHeightPerLine);\n\n var cursor = output.appendChild(elt(\"div\", \"\\u00a0\", \"CodeMirror-cursor\"));\n cursor.style.left = pos.left + \"px\";\n cursor.style.top = pos.top + \"px\";\n cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + \"px\";\n\n if (pos.other) {\n // Secondary cursor, shown when on a 'jump' in bi-directional text\n var otherCursor = output.appendChild(elt(\"div\", \"\\u00a0\", \"CodeMirror-cursor CodeMirror-secondarycursor\"));\n otherCursor.style.display = \"\";\n otherCursor.style.left = pos.other.left + \"px\";\n otherCursor.style.top = pos.other.top + \"px\";\n otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + \"px\";\n }\n }\n\n function cmpCoords(a, b) { return a.top - b.top || a.left - b.left }\n\n // Draws the given range as a highlighted selection\n function drawSelectionRange(cm, range$$1, output) {\n var display = cm.display, doc = cm.doc;\n var fragment = document.createDocumentFragment();\n var padding = paddingH(cm.display), leftSide = padding.left;\n var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right;\n var docLTR = doc.direction == \"ltr\";\n\n function add(left, top, width, bottom) {\n if (top < 0) { top = 0; }\n top = Math.round(top);\n bottom = Math.round(bottom);\n fragment.appendChild(elt(\"div\", null, \"CodeMirror-selected\", (\"position: absolute; left: \" + left + \"px;\\n top: \" + top + \"px; width: \" + (width == null ? rightSide - left : width) + \"px;\\n height: \" + (bottom - top) + \"px\")));\n }\n\n function drawForLine(line, fromArg, toArg) {\n var lineObj = getLine(doc, line);\n var lineLen = lineObj.text.length;\n var start, end;\n function coords(ch, bias) {\n return charCoords(cm, Pos(line, ch), \"div\", lineObj, bias)\n }\n\n function wrapX(pos, dir, side) {\n var extent = wrappedLineExtentChar(cm, lineObj, null, pos);\n var prop = (dir == \"ltr\") == (side == \"after\") ? \"left\" : \"right\";\n var ch = side == \"after\" ? extent.begin : extent.end - (/\\s/.test(lineObj.text.charAt(extent.end - 1)) ? 2 : 1);\n return coords(ch, prop)[prop]\n }\n\n var order = getOrder(lineObj, doc.direction);\n iterateBidiSections(order, fromArg || 0, toArg == null ? lineLen : toArg, function (from, to, dir, i) {\n var ltr = dir == \"ltr\";\n var fromPos = coords(from, ltr ? \"left\" : \"right\");\n var toPos = coords(to - 1, ltr ? \"right\" : \"left\");\n\n var openStart = fromArg == null && from == 0, openEnd = toArg == null && to == lineLen;\n var first = i == 0, last = !order || i == order.length - 1;\n if (toPos.top - fromPos.top <= 3) { // Single line\n var openLeft = (docLTR ? openStart : openEnd) && first;\n var openRight = (docLTR ? openEnd : openStart) && last;\n var left = openLeft ? leftSide : (ltr ? fromPos : toPos).left;\n var right = openRight ? rightSide : (ltr ? toPos : fromPos).right;\n add(left, fromPos.top, right - left, fromPos.bottom);\n } else { // Multiple lines\n var topLeft, topRight, botLeft, botRight;\n if (ltr) {\n topLeft = docLTR && openStart && first ? leftSide : fromPos.left;\n topRight = docLTR ? rightSide : wrapX(from, dir, \"before\");\n botLeft = docLTR ? leftSide : wrapX(to, dir, \"after\");\n botRight = docLTR && openEnd && last ? rightSide : toPos.right;\n } else {\n topLeft = !docLTR ? leftSide : wrapX(from, dir, \"before\");\n topRight = !docLTR && openStart && first ? rightSide : fromPos.right;\n botLeft = !docLTR && openEnd && last ? leftSide : toPos.left;\n botRight = !docLTR ? rightSide : wrapX(to, dir, \"after\");\n }\n add(topLeft, fromPos.top, topRight - topLeft, fromPos.bottom);\n if (fromPos.bottom < toPos.top) { add(leftSide, fromPos.bottom, null, toPos.top); }\n add(botLeft, toPos.top, botRight - botLeft, toPos.bottom);\n }\n\n if (!start || cmpCoords(fromPos, start) < 0) { start = fromPos; }\n if (cmpCoords(toPos, start) < 0) { start = toPos; }\n if (!end || cmpCoords(fromPos, end) < 0) { end = fromPos; }\n if (cmpCoords(toPos, end) < 0) { end = toPos; }\n });\n return {start: start, end: end}\n }\n\n var sFrom = range$$1.from(), sTo = range$$1.to();\n if (sFrom.line == sTo.line) {\n drawForLine(sFrom.line, sFrom.ch, sTo.ch);\n } else {\n var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line);\n var singleVLine = visualLine(fromLine) == visualLine(toLine);\n var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end;\n var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start;\n if (singleVLine) {\n if (leftEnd.top < rightStart.top - 2) {\n add(leftEnd.right, leftEnd.top, null, leftEnd.bottom);\n add(leftSide, rightStart.top, rightStart.left, rightStart.bottom);\n } else {\n add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom);\n }\n }\n if (leftEnd.bottom < rightStart.top)\n { add(leftSide, leftEnd.bottom, null, rightStart.top); }\n }\n\n output.appendChild(fragment);\n }\n\n // Cursor-blinking\n function restartBlink(cm) {\n if (!cm.state.focused) { return }\n var display = cm.display;\n clearInterval(display.blinker);\n var on = true;\n display.cursorDiv.style.visibility = \"\";\n if (cm.options.cursorBlinkRate > 0)\n { display.blinker = setInterval(function () { return display.cursorDiv.style.visibility = (on = !on) ? \"\" : \"hidden\"; },\n cm.options.cursorBlinkRate); }\n else if (cm.options.cursorBlinkRate < 0)\n { display.cursorDiv.style.visibility = \"hidden\"; }\n }\n\n function ensureFocus(cm) {\n if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }\n }\n\n function delayBlurEvent(cm) {\n cm.state.delayingBlurEvent = true;\n setTimeout(function () { if (cm.state.delayingBlurEvent) {\n cm.state.delayingBlurEvent = false;\n onBlur(cm);\n } }, 100);\n }\n\n function onFocus(cm, e) {\n if (cm.state.delayingBlurEvent) { cm.state.delayingBlurEvent = false; }\n\n if (cm.options.readOnly == \"nocursor\") { return }\n if (!cm.state.focused) {\n signal(cm, \"focus\", cm, e);\n cm.state.focused = true;\n addClass(cm.display.wrapper, \"CodeMirror-focused\");\n // This test prevents this from firing when a context\n // menu is closed (since the input reset would kill the\n // select-all detection hack)\n if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) {\n cm.display.input.reset();\n if (webkit) { setTimeout(function () { return cm.display.input.reset(true); }, 20); } // Issue #1730\n }\n cm.display.input.receivedFocus();\n }\n restartBlink(cm);\n }\n function onBlur(cm, e) {\n if (cm.state.delayingBlurEvent) { return }\n\n if (cm.state.focused) {\n signal(cm, \"blur\", cm, e);\n cm.state.focused = false;\n rmClass(cm.display.wrapper, \"CodeMirror-focused\");\n }\n clearInterval(cm.display.blinker);\n setTimeout(function () { if (!cm.state.focused) { cm.display.shift = false; } }, 150);\n }\n\n // Read the actual heights of the rendered lines, and update their\n // stored heights to match.\n function updateHeightsInViewport(cm) {\n var display = cm.display;\n var prevBottom = display.lineDiv.offsetTop;\n for (var i = 0; i < display.view.length; i++) {\n var cur = display.view[i], wrapping = cm.options.lineWrapping;\n var height = (void 0), width = 0;\n if (cur.hidden) { continue }\n if (ie && ie_version < 8) {\n var bot = cur.node.offsetTop + cur.node.offsetHeight;\n height = bot - prevBottom;\n prevBottom = bot;\n } else {\n var box = cur.node.getBoundingClientRect();\n height = box.bottom - box.top;\n // Check that lines don't extend past the right of the current\n // editor width\n if (!wrapping && cur.text.firstChild)\n { width = cur.text.firstChild.getBoundingClientRect().right - box.left - 1; }\n }\n var diff = cur.line.height - height;\n if (diff > .005 || diff < -.005) {\n updateLineHeight(cur.line, height);\n updateWidgetHeight(cur.line);\n if (cur.rest) { for (var j = 0; j < cur.rest.length; j++)\n { updateWidgetHeight(cur.rest[j]); } }\n }\n if (width > cm.display.sizerWidth) {\n var chWidth = Math.ceil(width / charWidth(cm.display));\n if (chWidth > cm.display.maxLineLength) {\n cm.display.maxLineLength = chWidth;\n cm.display.maxLine = cur.line;\n cm.display.maxLineChanged = true;\n }\n }\n }\n }\n\n // Read and store the height of line widgets associated with the\n // given line.\n function updateWidgetHeight(line) {\n if (line.widgets) { for (var i = 0; i < line.widgets.length; ++i) {\n var w = line.widgets[i], parent = w.node.parentNode;\n if (parent) { w.height = parent.offsetHeight; }\n } }\n }\n\n // Compute the lines that are visible in a given viewport (defaults\n // the the current scroll position). viewport may contain top,\n // height, and ensure (see op.scrollToPos) properties.\n function visibleLines(display, doc, viewport) {\n var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;\n top = Math.floor(top - paddingTop(display));\n var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight;\n\n var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);\n // Ensure is a {from: {line, ch}, to: {line, ch}} object, and\n // forces those lines into the viewport (if possible).\n if (viewport && viewport.ensure) {\n var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line;\n if (ensureFrom < from) {\n from = ensureFrom;\n to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight);\n } else if (Math.min(ensureTo, doc.lastLine()) >= to) {\n from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight);\n to = ensureTo;\n }\n }\n return {from: from, to: Math.max(to, from + 1)}\n }\n\n // SCROLLING THINGS INTO VIEW\n\n // If an editor sits on the top or bottom of the window, partially\n // scrolled out of view, this ensures that the cursor is visible.\n function maybeScrollWindow(cm, rect) {\n if (signalDOMEvent(cm, \"scrollCursorIntoView\")) { return }\n\n var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;\n if (rect.top + box.top < 0) { doScroll = true; }\n else if (rect.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) { doScroll = false; }\n if (doScroll != null && !phantom) {\n var scrollNode = elt(\"div\", \"\\u200b\", null, (\"position: absolute;\\n top: \" + (rect.top - display.viewOffset - paddingTop(cm.display)) + \"px;\\n height: \" + (rect.bottom - rect.top + scrollGap(cm) + display.barHeight) + \"px;\\n left: \" + (rect.left) + \"px; width: \" + (Math.max(2, rect.right - rect.left)) + \"px;\"));\n cm.display.lineSpace.appendChild(scrollNode);\n scrollNode.scrollIntoView(doScroll);\n cm.display.lineSpace.removeChild(scrollNode);\n }\n }\n\n // Scroll a given position into view (immediately), verifying that\n // it actually became visible (as line heights are accurately\n // measured, the position of something may 'drift' during drawing).\n function scrollPosIntoView(cm, pos, end, margin) {\n if (margin == null) { margin = 0; }\n var rect;\n if (!cm.options.lineWrapping && pos == end) {\n // Set pos and end to the cursor positions around the character pos sticks to\n // If pos.sticky == \"before\", that is around pos.ch - 1, otherwise around pos.ch\n // If pos == Pos(_, 0, \"before\"), pos and end are unchanged\n pos = pos.ch ? Pos(pos.line, pos.sticky == \"before\" ? pos.ch - 1 : pos.ch, \"after\") : pos;\n end = pos.sticky == \"before\" ? Pos(pos.line, pos.ch + 1, \"before\") : pos;\n }\n for (var limit = 0; limit < 5; limit++) {\n var changed = false;\n var coords = cursorCoords(cm, pos);\n var endCoords = !end || end == pos ? coords : cursorCoords(cm, end);\n rect = {left: Math.min(coords.left, endCoords.left),\n top: Math.min(coords.top, endCoords.top) - margin,\n right: Math.max(coords.left, endCoords.left),\n bottom: Math.max(coords.bottom, endCoords.bottom) + margin};\n var scrollPos = calculateScrollPos(cm, rect);\n var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft;\n if (scrollPos.scrollTop != null) {\n updateScrollTop(cm, scrollPos.scrollTop);\n if (Math.abs(cm.doc.scrollTop - startTop) > 1) { changed = true; }\n }\n if (scrollPos.scrollLeft != null) {\n setScrollLeft(cm, scrollPos.scrollLeft);\n if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) { changed = true; }\n }\n if (!changed) { break }\n }\n return rect\n }\n\n // Scroll a given set of coordinates into view (immediately).\n function scrollIntoView(cm, rect) {\n var scrollPos = calculateScrollPos(cm, rect);\n if (scrollPos.scrollTop != null) { updateScrollTop(cm, scrollPos.scrollTop); }\n if (scrollPos.scrollLeft != null) { setScrollLeft(cm, scrollPos.scrollLeft); }\n }\n\n // Calculate a new scroll position needed to scroll the given\n // rectangle into view. Returns an object with scrollTop and\n // scrollLeft properties. When these are undefined, the\n // vertical/horizontal position does not need to be adjusted.\n function calculateScrollPos(cm, rect) {\n var display = cm.display, snapMargin = textHeight(cm.display);\n if (rect.top < 0) { rect.top = 0; }\n var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop;\n var screen = displayHeight(cm), result = {};\n if (rect.bottom - rect.top > screen) { rect.bottom = rect.top + screen; }\n var docBottom = cm.doc.height + paddingVert(display);\n var atTop = rect.top < snapMargin, atBottom = rect.bottom > docBottom - snapMargin;\n if (rect.top < screentop) {\n result.scrollTop = atTop ? 0 : rect.top;\n } else if (rect.bottom > screentop + screen) {\n var newTop = Math.min(rect.top, (atBottom ? docBottom : rect.bottom) - screen);\n if (newTop != screentop) { result.scrollTop = newTop; }\n }\n\n var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft;\n var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0);\n var tooWide = rect.right - rect.left > screenw;\n if (tooWide) { rect.right = rect.left + screenw; }\n if (rect.left < 10)\n { result.scrollLeft = 0; }\n else if (rect.left < screenleft)\n { result.scrollLeft = Math.max(0, rect.left - (tooWide ? 0 : 10)); }\n else if (rect.right > screenw + screenleft - 3)\n { result.scrollLeft = rect.right + (tooWide ? 0 : 10) - screenw; }\n return result\n }\n\n // Store a relative adjustment to the scroll position in the current\n // operation (to be applied when the operation finishes).\n function addToScrollTop(cm, top) {\n if (top == null) { return }\n resolveScrollToPos(cm);\n cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top;\n }\n\n // Make sure that at the end of the operation the current cursor is\n // shown.\n function ensureCursorVisible(cm) {\n resolveScrollToPos(cm);\n var cur = cm.getCursor();\n cm.curOp.scrollToPos = {from: cur, to: cur, margin: cm.options.cursorScrollMargin};\n }\n\n function scrollToCoords(cm, x, y) {\n if (x != null || y != null) { resolveScrollToPos(cm); }\n if (x != null) { cm.curOp.scrollLeft = x; }\n if (y != null) { cm.curOp.scrollTop = y; }\n }\n\n function scrollToRange(cm, range$$1) {\n resolveScrollToPos(cm);\n cm.curOp.scrollToPos = range$$1;\n }\n\n // When an operation has its scrollToPos property set, and another\n // scroll action is applied before the end of the operation, this\n // 'simulates' scrolling that position into view in a cheap way, so\n // that the effect of intermediate scroll commands is not ignored.\n function resolveScrollToPos(cm) {\n var range$$1 = cm.curOp.scrollToPos;\n if (range$$1) {\n cm.curOp.scrollToPos = null;\n var from = estimateCoords(cm, range$$1.from), to = estimateCoords(cm, range$$1.to);\n scrollToCoordsRange(cm, from, to, range$$1.margin);\n }\n }\n\n function scrollToCoordsRange(cm, from, to, margin) {\n var sPos = calculateScrollPos(cm, {\n left: Math.min(from.left, to.left),\n top: Math.min(from.top, to.top) - margin,\n right: Math.max(from.right, to.right),\n bottom: Math.max(from.bottom, to.bottom) + margin\n });\n scrollToCoords(cm, sPos.scrollLeft, sPos.scrollTop);\n }\n\n // Sync the scrollable area and scrollbars, ensure the viewport\n // covers the visible area.\n function updateScrollTop(cm, val) {\n if (Math.abs(cm.doc.scrollTop - val) < 2) { return }\n if (!gecko) { updateDisplaySimple(cm, {top: val}); }\n setScrollTop(cm, val, true);\n if (gecko) { updateDisplaySimple(cm); }\n startWorker(cm, 100);\n }\n\n function setScrollTop(cm, val, forceScroll) {\n val = Math.min(cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight, val);\n if (cm.display.scroller.scrollTop == val && !forceScroll) { return }\n cm.doc.scrollTop = val;\n cm.display.scrollbars.setScrollTop(val);\n if (cm.display.scroller.scrollTop != val) { cm.display.scroller.scrollTop = val; }\n }\n\n // Sync scroller and scrollbar, ensure the gutter elements are\n // aligned.\n function setScrollLeft(cm, val, isScroller, forceScroll) {\n val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth);\n if ((isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) && !forceScroll) { return }\n cm.doc.scrollLeft = val;\n alignHorizontally(cm);\n if (cm.display.scroller.scrollLeft != val) { cm.display.scroller.scrollLeft = val; }\n cm.display.scrollbars.setScrollLeft(val);\n }\n\n // SCROLLBARS\n\n // Prepare DOM reads needed to update the scrollbars. Done in one\n // shot to minimize update/measure roundtrips.\n function measureForScrollbars(cm) {\n var d = cm.display, gutterW = d.gutters.offsetWidth;\n var docH = Math.round(cm.doc.height + paddingVert(cm.display));\n return {\n clientHeight: d.scroller.clientHeight,\n viewHeight: d.wrapper.clientHeight,\n scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth,\n viewWidth: d.wrapper.clientWidth,\n barLeft: cm.options.fixedGutter ? gutterW : 0,\n docHeight: docH,\n scrollHeight: docH + scrollGap(cm) + d.barHeight,\n nativeBarWidth: d.nativeBarWidth,\n gutterWidth: gutterW\n }\n }\n\n var NativeScrollbars = function(place, scroll, cm) {\n this.cm = cm;\n var vert = this.vert = elt(\"div\", [elt(\"div\", null, null, \"min-width: 1px\")], \"CodeMirror-vscrollbar\");\n var horiz = this.horiz = elt(\"div\", [elt(\"div\", null, null, \"height: 100%; min-height: 1px\")], \"CodeMirror-hscrollbar\");\n vert.tabIndex = horiz.tabIndex = -1;\n place(vert); place(horiz);\n\n on(vert, \"scroll\", function () {\n if (vert.clientHeight) { scroll(vert.scrollTop, \"vertical\"); }\n });\n on(horiz, \"scroll\", function () {\n if (horiz.clientWidth) { scroll(horiz.scrollLeft, \"horizontal\"); }\n });\n\n this.checkedZeroWidth = false;\n // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).\n if (ie && ie_version < 8) { this.horiz.style.minHeight = this.vert.style.minWidth = \"18px\"; }\n };\n\n NativeScrollbars.prototype.update = function (measure) {\n var needsH = measure.scrollWidth > measure.clientWidth + 1;\n var needsV = measure.scrollHeight > measure.clientHeight + 1;\n var sWidth = measure.nativeBarWidth;\n\n if (needsV) {\n this.vert.style.display = \"block\";\n this.vert.style.bottom = needsH ? sWidth + \"px\" : \"0\";\n var totalHeight = measure.viewHeight - (needsH ? sWidth : 0);\n // A bug in IE8 can cause this value to be negative, so guard it.\n this.vert.firstChild.style.height =\n Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + \"px\";\n } else {\n this.vert.style.display = \"\";\n this.vert.firstChild.style.height = \"0\";\n }\n\n if (needsH) {\n this.horiz.style.display = \"block\";\n this.horiz.style.right = needsV ? sWidth + \"px\" : \"0\";\n this.horiz.style.left = measure.barLeft + \"px\";\n var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0);\n this.horiz.firstChild.style.width =\n Math.max(0, measure.scrollWidth - measure.clientWidth + totalWidth) + \"px\";\n } else {\n this.horiz.style.display = \"\";\n this.horiz.firstChild.style.width = \"0\";\n }\n\n if (!this.checkedZeroWidth && measure.clientHeight > 0) {\n if (sWidth == 0) { this.zeroWidthHack(); }\n this.checkedZeroWidth = true;\n }\n\n return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0}\n };\n\n NativeScrollbars.prototype.setScrollLeft = function (pos) {\n if (this.horiz.scrollLeft != pos) { this.horiz.scrollLeft = pos; }\n if (this.disableHoriz) { this.enableZeroWidthBar(this.horiz, this.disableHoriz, \"horiz\"); }\n };\n\n NativeScrollbars.prototype.setScrollTop = function (pos) {\n if (this.vert.scrollTop != pos) { this.vert.scrollTop = pos; }\n if (this.disableVert) { this.enableZeroWidthBar(this.vert, this.disableVert, \"vert\"); }\n };\n\n NativeScrollbars.prototype.zeroWidthHack = function () {\n var w = mac && !mac_geMountainLion ? \"12px\" : \"18px\";\n this.horiz.style.height = this.vert.style.width = w;\n this.horiz.style.pointerEvents = this.vert.style.pointerEvents = \"none\";\n this.disableHoriz = new Delayed;\n this.disableVert = new Delayed;\n };\n\n NativeScrollbars.prototype.enableZeroWidthBar = function (bar, delay, type) {\n bar.style.pointerEvents = \"auto\";\n function maybeDisable() {\n // To find out whether the scrollbar is still visible, we\n // check whether the element under the pixel in the bottom\n // right corner of the scrollbar box is the scrollbar box\n // itself (when the bar is still visible) or its filler child\n // (when the bar is hidden). If it is still visible, we keep\n // it enabled, if it's hidden, we disable pointer events.\n var box = bar.getBoundingClientRect();\n var elt$$1 = type == \"vert\" ? document.elementFromPoint(box.right - 1, (box.top + box.bottom) / 2)\n : document.elementFromPoint((box.right + box.left) / 2, box.bottom - 1);\n if (elt$$1 != bar) { bar.style.pointerEvents = \"none\"; }\n else { delay.set(1000, maybeDisable); }\n }\n delay.set(1000, maybeDisable);\n };\n\n NativeScrollbars.prototype.clear = function () {\n var parent = this.horiz.parentNode;\n parent.removeChild(this.horiz);\n parent.removeChild(this.vert);\n };\n\n var NullScrollbars = function () {};\n\n NullScrollbars.prototype.update = function () { return {bottom: 0, right: 0} };\n NullScrollbars.prototype.setScrollLeft = function () {};\n NullScrollbars.prototype.setScrollTop = function () {};\n NullScrollbars.prototype.clear = function () {};\n\n function updateScrollbars(cm, measure) {\n if (!measure) { measure = measureForScrollbars(cm); }\n var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight;\n updateScrollbarsInner(cm, measure);\n for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) {\n if (startWidth != cm.display.barWidth && cm.options.lineWrapping)\n { updateHeightsInViewport(cm); }\n updateScrollbarsInner(cm, measureForScrollbars(cm));\n startWidth = cm.display.barWidth; startHeight = cm.display.barHeight;\n }\n }\n\n // Re-synchronize the fake scrollbars with the actual size of the\n // content.\n function updateScrollbarsInner(cm, measure) {\n var d = cm.display;\n var sizes = d.scrollbars.update(measure);\n\n d.sizer.style.paddingRight = (d.barWidth = sizes.right) + \"px\";\n d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + \"px\";\n d.heightForcer.style.borderBottom = sizes.bottom + \"px solid transparent\";\n\n if (sizes.right && sizes.bottom) {\n d.scrollbarFiller.style.display = \"block\";\n d.scrollbarFiller.style.height = sizes.bottom + \"px\";\n d.scrollbarFiller.style.width = sizes.right + \"px\";\n } else { d.scrollbarFiller.style.display = \"\"; }\n if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {\n d.gutterFiller.style.display = \"block\";\n d.gutterFiller.style.height = sizes.bottom + \"px\";\n d.gutterFiller.style.width = measure.gutterWidth + \"px\";\n } else { d.gutterFiller.style.display = \"\"; }\n }\n\n var scrollbarModel = {\"native\": NativeScrollbars, \"null\": NullScrollbars};\n\n function initScrollbars(cm) {\n if (cm.display.scrollbars) {\n cm.display.scrollbars.clear();\n if (cm.display.scrollbars.addClass)\n { rmClass(cm.display.wrapper, cm.display.scrollbars.addClass); }\n }\n\n cm.display.scrollbars = new scrollbarModel[cm.options.scrollbarStyle](function (node) {\n cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller);\n // Prevent clicks in the scrollbars from killing focus\n on(node, \"mousedown\", function () {\n if (cm.state.focused) { setTimeout(function () { return cm.display.input.focus(); }, 0); }\n });\n node.setAttribute(\"cm-not-content\", \"true\");\n }, function (pos, axis) {\n if (axis == \"horizontal\") { setScrollLeft(cm, pos); }\n else { updateScrollTop(cm, pos); }\n }, cm);\n if (cm.display.scrollbars.addClass)\n { addClass(cm.display.wrapper, cm.display.scrollbars.addClass); }\n }\n\n // Operations are used to wrap a series of changes to the editor\n // state in such a way that each change won't have to update the\n // cursor and display (which would be awkward, slow, and\n // error-prone). Instead, display updates are batched and then all\n // combined and executed at once.\n\n var nextOpId = 0;\n // Start a new operation.\n function startOperation(cm) {\n cm.curOp = {\n cm: cm,\n viewChanged: false, // Flag that indicates that lines might need to be redrawn\n startHeight: cm.doc.height, // Used to detect need to update scrollbar\n forceUpdate: false, // Used to force a redraw\n updateInput: 0, // Whether to reset the input textarea\n typing: false, // Whether this reset should be careful to leave existing text (for compositing)\n changeObjs: null, // Accumulated changes, for firing change events\n cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on\n cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already\n selectionChanged: false, // Whether the selection needs to be redrawn\n updateMaxLine: false, // Set when the widest line needs to be determined anew\n scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet\n scrollToPos: null, // Used to scroll to a specific position\n focus: false,\n id: ++nextOpId // Unique ID\n };\n pushOperation(cm.curOp);\n }\n\n // Finish an operation, updating the display and signalling delayed events\n function endOperation(cm) {\n var op = cm.curOp;\n if (op) { finishOperation(op, function (group) {\n for (var i = 0; i < group.ops.length; i++)\n { group.ops[i].cm.curOp = null; }\n endOperations(group);\n }); }\n }\n\n // The DOM updates done when an operation finishes are batched so\n // that the minimum number of relayouts are required.\n function endOperations(group) {\n var ops = group.ops;\n for (var i = 0; i < ops.length; i++) // Read DOM\n { endOperation_R1(ops[i]); }\n for (var i$1 = 0; i$1 < ops.length; i$1++) // Write DOM (maybe)\n { endOperation_W1(ops[i$1]); }\n for (var i$2 = 0; i$2 < ops.length; i$2++) // Read DOM\n { endOperation_R2(ops[i$2]); }\n for (var i$3 = 0; i$3 < ops.length; i$3++) // Write DOM (maybe)\n { endOperation_W2(ops[i$3]); }\n for (var i$4 = 0; i$4 < ops.length; i$4++) // Read DOM\n { endOperation_finish(ops[i$4]); }\n }\n\n function endOperation_R1(op) {\n var cm = op.cm, display = cm.display;\n maybeClipScrollbars(cm);\n if (op.updateMaxLine) { findMaxLine(cm); }\n\n op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null ||\n op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom ||\n op.scrollToPos.to.line >= display.viewTo) ||\n display.maxLineChanged && cm.options.lineWrapping;\n op.update = op.mustUpdate &&\n new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate);\n }\n\n function endOperation_W1(op) {\n op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update);\n }\n\n function endOperation_R2(op) {\n var cm = op.cm, display = cm.display;\n if (op.updatedDisplay) { updateHeightsInViewport(cm); }\n\n op.barMeasure = measureForScrollbars(cm);\n\n // If the max line changed since it was last measured, measure it,\n // and ensure the document's width matches it.\n // updateDisplay_W2 will use these properties to do the actual resizing\n if (display.maxLineChanged && !cm.options.lineWrapping) {\n op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3;\n cm.display.sizerWidth = op.adjustWidthTo;\n op.barMeasure.scrollWidth =\n Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth);\n op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm));\n }\n\n if (op.updatedDisplay || op.selectionChanged)\n { op.preparedSelection = display.input.prepareSelection(); }\n }\n\n function endOperation_W2(op) {\n var cm = op.cm;\n\n if (op.adjustWidthTo != null) {\n cm.display.sizer.style.minWidth = op.adjustWidthTo + \"px\";\n if (op.maxScrollLeft < cm.doc.scrollLeft)\n { setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true); }\n cm.display.maxLineChanged = false;\n }\n\n var takeFocus = op.focus && op.focus == activeElt();\n if (op.preparedSelection)\n { cm.display.input.showSelection(op.preparedSelection, takeFocus); }\n if (op.updatedDisplay || op.startHeight != cm.doc.height)\n { updateScrollbars(cm, op.barMeasure); }\n if (op.updatedDisplay)\n { setDocumentHeight(cm, op.barMeasure); }\n\n if (op.selectionChanged) { restartBlink(cm); }\n\n if (cm.state.focused && op.updateInput)\n { cm.display.input.reset(op.typing); }\n if (takeFocus) { ensureFocus(op.cm); }\n }\n\n function endOperation_finish(op) {\n var cm = op.cm, display = cm.display, doc = cm.doc;\n\n if (op.updatedDisplay) { postUpdateDisplay(cm, op.update); }\n\n // Abort mouse wheel delta measurement, when scrolling explicitly\n if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos))\n { display.wheelStartX = display.wheelStartY = null; }\n\n // Propagate the scroll position to the actual DOM scroller\n if (op.scrollTop != null) { setScrollTop(cm, op.scrollTop, op.forceScroll); }\n\n if (op.scrollLeft != null) { setScrollLeft(cm, op.scrollLeft, true, true); }\n // If we need to scroll a specific position into view, do so.\n if (op.scrollToPos) {\n var rect = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from),\n clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin);\n maybeScrollWindow(cm, rect);\n }\n\n // Fire events for markers that are hidden/unidden by editing or\n // undoing\n var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers;\n if (hidden) { for (var i = 0; i < hidden.length; ++i)\n { if (!hidden[i].lines.length) { signal(hidden[i], \"hide\"); } } }\n if (unhidden) { for (var i$1 = 0; i$1 < unhidden.length; ++i$1)\n { if (unhidden[i$1].lines.length) { signal(unhidden[i$1], \"unhide\"); } } }\n\n if (display.wrapper.offsetHeight)\n { doc.scrollTop = cm.display.scroller.scrollTop; }\n\n // Fire change events, and delayed event handlers\n if (op.changeObjs)\n { signal(cm, \"changes\", cm, op.changeObjs); }\n if (op.update)\n { op.update.finish(); }\n }\n\n // Run the given function in an operation\n function runInOp(cm, f) {\n if (cm.curOp) { return f() }\n startOperation(cm);\n try { return f() }\n finally { endOperation(cm); }\n }\n // Wraps a function in an operation. Returns the wrapped function.\n function operation(cm, f) {\n return function() {\n if (cm.curOp) { return f.apply(cm, arguments) }\n startOperation(cm);\n try { return f.apply(cm, arguments) }\n finally { endOperation(cm); }\n }\n }\n // Used to add methods to editor and doc instances, wrapping them in\n // operations.\n function methodOp(f) {\n return function() {\n if (this.curOp) { return f.apply(this, arguments) }\n startOperation(this);\n try { return f.apply(this, arguments) }\n finally { endOperation(this); }\n }\n }\n function docMethodOp(f) {\n return function() {\n var cm = this.cm;\n if (!cm || cm.curOp) { return f.apply(this, arguments) }\n startOperation(cm);\n try { return f.apply(this, arguments) }\n finally { endOperation(cm); }\n }\n }\n\n // HIGHLIGHT WORKER\n\n function startWorker(cm, time) {\n if (cm.doc.highlightFrontier < cm.display.viewTo)\n { cm.state.highlight.set(time, bind(highlightWorker, cm)); }\n }\n\n function highlightWorker(cm) {\n var doc = cm.doc;\n if (doc.highlightFrontier >= cm.display.viewTo) { return }\n var end = +new Date + cm.options.workTime;\n var context = getContextBefore(cm, doc.highlightFrontier);\n var changedLines = [];\n\n doc.iter(context.line, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function (line) {\n if (context.line >= cm.display.viewFrom) { // Visible\n var oldStyles = line.styles;\n var resetState = line.text.length > cm.options.maxHighlightLength ? copyState(doc.mode, context.state) : null;\n var highlighted = highlightLine(cm, line, context, true);\n if (resetState) { context.state = resetState; }\n line.styles = highlighted.styles;\n var oldCls = line.styleClasses, newCls = highlighted.classes;\n if (newCls) { line.styleClasses = newCls; }\n else if (oldCls) { line.styleClasses = null; }\n var ischange = !oldStyles || oldStyles.length != line.styles.length ||\n oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass);\n for (var i = 0; !ischange && i < oldStyles.length; ++i) { ischange = oldStyles[i] != line.styles[i]; }\n if (ischange) { changedLines.push(context.line); }\n line.stateAfter = context.save();\n context.nextLine();\n } else {\n if (line.text.length <= cm.options.maxHighlightLength)\n { processLine(cm, line.text, context); }\n line.stateAfter = context.line % 5 == 0 ? context.save() : null;\n context.nextLine();\n }\n if (+new Date > end) {\n startWorker(cm, cm.options.workDelay);\n return true\n }\n });\n doc.highlightFrontier = context.line;\n doc.modeFrontier = Math.max(doc.modeFrontier, context.line);\n if (changedLines.length) { runInOp(cm, function () {\n for (var i = 0; i < changedLines.length; i++)\n { regLineChange(cm, changedLines[i], \"text\"); }\n }); }\n }\n\n // DISPLAY DRAWING\n\n var DisplayUpdate = function(cm, viewport, force) {\n var display = cm.display;\n\n this.viewport = viewport;\n // Store some values that we'll need later (but don't want to force a relayout for)\n this.visible = visibleLines(display, cm.doc, viewport);\n this.editorIsHidden = !display.wrapper.offsetWidth;\n this.wrapperHeight = display.wrapper.clientHeight;\n this.wrapperWidth = display.wrapper.clientWidth;\n this.oldDisplayWidth = displayWidth(cm);\n this.force = force;\n this.dims = getDimensions(cm);\n this.events = [];\n };\n\n DisplayUpdate.prototype.signal = function (emitter, type) {\n if (hasHandler(emitter, type))\n { this.events.push(arguments); }\n };\n DisplayUpdate.prototype.finish = function () {\n var this$1 = this;\n\n for (var i = 0; i < this.events.length; i++)\n { signal.apply(null, this$1.events[i]); }\n };\n\n function maybeClipScrollbars(cm) {\n var display = cm.display;\n if (!display.scrollbarsClipped && display.scroller.offsetWidth) {\n display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth;\n display.heightForcer.style.height = scrollGap(cm) + \"px\";\n display.sizer.style.marginBottom = -display.nativeBarWidth + \"px\";\n display.sizer.style.borderRightWidth = scrollGap(cm) + \"px\";\n display.scrollbarsClipped = true;\n }\n }\n\n function selectionSnapshot(cm) {\n if (cm.hasFocus()) { return null }\n var active = activeElt();\n if (!active || !contains(cm.display.lineDiv, active)) { return null }\n var result = {activeElt: active};\n if (window.getSelection) {\n var sel = window.getSelection();\n if (sel.anchorNode && sel.extend && contains(cm.display.lineDiv, sel.anchorNode)) {\n result.anchorNode = sel.anchorNode;\n result.anchorOffset = sel.anchorOffset;\n result.focusNode = sel.focusNode;\n result.focusOffset = sel.focusOffset;\n }\n }\n return result\n }\n\n function restoreSelection(snapshot) {\n if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt()) { return }\n snapshot.activeElt.focus();\n if (snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {\n var sel = window.getSelection(), range$$1 = document.createRange();\n range$$1.setEnd(snapshot.anchorNode, snapshot.anchorOffset);\n range$$1.collapse(false);\n sel.removeAllRanges();\n sel.addRange(range$$1);\n sel.extend(snapshot.focusNode, snapshot.focusOffset);\n }\n }\n\n // Does the actual updating of the line display. Bails out\n // (returning false) when there is nothing to be done and forced is\n // false.\n function updateDisplayIfNeeded(cm, update) {\n var display = cm.display, doc = cm.doc;\n\n if (update.editorIsHidden) {\n resetView(cm);\n return false\n }\n\n // Bail out if the visible area is already rendered and nothing changed.\n if (!update.force &&\n update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&\n (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&\n display.renderedView == display.view && countDirtyView(cm) == 0)\n { return false }\n\n if (maybeUpdateLineNumberWidth(cm)) {\n resetView(cm);\n update.dims = getDimensions(cm);\n }\n\n // Compute a suitable new viewport (from & to)\n var end = doc.first + doc.size;\n var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first);\n var to = Math.min(end, update.visible.to + cm.options.viewportMargin);\n if (display.viewFrom < from && from - display.viewFrom < 20) { from = Math.max(doc.first, display.viewFrom); }\n if (display.viewTo > to && display.viewTo - to < 20) { to = Math.min(end, display.viewTo); }\n if (sawCollapsedSpans) {\n from = visualLineNo(cm.doc, from);\n to = visualLineEndNo(cm.doc, to);\n }\n\n var different = from != display.viewFrom || to != display.viewTo ||\n display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth;\n adjustView(cm, from, to);\n\n display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom));\n // Position the mover div to align with the current scroll position\n cm.display.mover.style.top = display.viewOffset + \"px\";\n\n var toUpdate = countDirtyView(cm);\n if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view &&\n (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))\n { return false }\n\n // For big changes, we hide the enclosing element during the\n // update, since that speeds up the operations on most browsers.\n var selSnapshot = selectionSnapshot(cm);\n if (toUpdate > 4) { display.lineDiv.style.display = \"none\"; }\n patchDisplay(cm, display.updateLineNumbers, update.dims);\n if (toUpdate > 4) { display.lineDiv.style.display = \"\"; }\n display.renderedView = display.view;\n // There might have been a widget with a focused element that got\n // hidden or updated, if so re-focus it.\n restoreSelection(selSnapshot);\n\n // Prevent selection and cursors from interfering with the scroll\n // width and height.\n removeChildren(display.cursorDiv);\n removeChildren(display.selectionDiv);\n display.gutters.style.height = display.sizer.style.minHeight = 0;\n\n if (different) {\n display.lastWrapHeight = update.wrapperHeight;\n display.lastWrapWidth = update.wrapperWidth;\n startWorker(cm, 400);\n }\n\n display.updateLineNumbers = null;\n\n return true\n }\n\n function postUpdateDisplay(cm, update) {\n var viewport = update.viewport;\n\n for (var first = true;; first = false) {\n if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {\n // Clip forced viewport to actual scrollable area.\n if (viewport && viewport.top != null)\n { viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)}; }\n // Updated line heights might result in the drawn area not\n // actually covering the viewport. Keep looping until it does.\n update.visible = visibleLines(cm.display, cm.doc, viewport);\n if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)\n { break }\n }\n if (!updateDisplayIfNeeded(cm, update)) { break }\n updateHeightsInViewport(cm);\n var barMeasure = measureForScrollbars(cm);\n updateSelection(cm);\n updateScrollbars(cm, barMeasure);\n setDocumentHeight(cm, barMeasure);\n update.force = false;\n }\n\n update.signal(cm, \"update\", cm);\n if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {\n update.signal(cm, \"viewportChange\", cm, cm.display.viewFrom, cm.display.viewTo);\n cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo;\n }\n }\n\n function updateDisplaySimple(cm, viewport) {\n var update = new DisplayUpdate(cm, viewport);\n if (updateDisplayIfNeeded(cm, update)) {\n updateHeightsInViewport(cm);\n postUpdateDisplay(cm, update);\n var barMeasure = measureForScrollbars(cm);\n updateSelection(cm);\n updateScrollbars(cm, barMeasure);\n setDocumentHeight(cm, barMeasure);\n update.finish();\n }\n }\n\n // Sync the actual display DOM structure with display.view, removing\n // nodes for lines that are no longer in view, and creating the ones\n // that are not there yet, and updating the ones that are out of\n // date.\n function patchDisplay(cm, updateNumbersFrom, dims) {\n var display = cm.display, lineNumbers = cm.options.lineNumbers;\n var container = display.lineDiv, cur = container.firstChild;\n\n function rm(node) {\n var next = node.nextSibling;\n // Works around a throw-scroll bug in OS X Webkit\n if (webkit && mac && cm.display.currentWheelTarget == node)\n { node.style.display = \"none\"; }\n else\n { node.parentNode.removeChild(node); }\n return next\n }\n\n var view = display.view, lineN = display.viewFrom;\n // Loop over the elements in the view, syncing cur (the DOM nodes\n // in display.lineDiv) with the view as we go.\n for (var i = 0; i < view.length; i++) {\n var lineView = view[i];\n if (lineView.hidden) ; else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet\n var node = buildLineElement(cm, lineView, lineN, dims);\n container.insertBefore(node, cur);\n } else { // Already drawn\n while (cur != lineView.node) { cur = rm(cur); }\n var updateNumber = lineNumbers && updateNumbersFrom != null &&\n updateNumbersFrom <= lineN && lineView.lineNumber;\n if (lineView.changes) {\n if (indexOf(lineView.changes, \"gutter\") > -1) { updateNumber = false; }\n updateLineForChanges(cm, lineView, lineN, dims);\n }\n if (updateNumber) {\n removeChildren(lineView.lineNumber);\n lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));\n }\n cur = lineView.node.nextSibling;\n }\n lineN += lineView.size;\n }\n while (cur) { cur = rm(cur); }\n }\n\n function updateGutterSpace(display) {\n var width = display.gutters.offsetWidth;\n display.sizer.style.marginLeft = width + \"px\";\n }\n\n function setDocumentHeight(cm, measure) {\n cm.display.sizer.style.minHeight = measure.docHeight + \"px\";\n cm.display.heightForcer.style.top = measure.docHeight + \"px\";\n cm.display.gutters.style.height = (measure.docHeight + cm.display.barHeight + scrollGap(cm)) + \"px\";\n }\n\n // Re-align line numbers and gutter marks to compensate for\n // horizontal scrolling.\n function alignHorizontally(cm) {\n var display = cm.display, view = display.view;\n if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) { return }\n var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;\n var gutterW = display.gutters.offsetWidth, left = comp + \"px\";\n for (var i = 0; i < view.length; i++) { if (!view[i].hidden) {\n if (cm.options.fixedGutter) {\n if (view[i].gutter)\n { view[i].gutter.style.left = left; }\n if (view[i].gutterBackground)\n { view[i].gutterBackground.style.left = left; }\n }\n var align = view[i].alignable;\n if (align) { for (var j = 0; j < align.length; j++)\n { align[j].style.left = left; } }\n } }\n if (cm.options.fixedGutter)\n { display.gutters.style.left = (comp + gutterW) + \"px\"; }\n }\n\n // Used to ensure that the line number gutter is still the right\n // size for the current document size. Returns true when an update\n // is needed.\n function maybeUpdateLineNumberWidth(cm) {\n if (!cm.options.lineNumbers) { return false }\n var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;\n if (last.length != display.lineNumChars) {\n var test = display.measure.appendChild(elt(\"div\", [elt(\"div\", last)],\n \"CodeMirror-linenumber CodeMirror-gutter-elt\"));\n var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;\n display.lineGutter.style.width = \"\";\n display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1;\n display.lineNumWidth = display.lineNumInnerWidth + padding;\n display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;\n display.lineGutter.style.width = display.lineNumWidth + \"px\";\n updateGutterSpace(cm.display);\n return true\n }\n return false\n }\n\n function getGutters(gutters, lineNumbers) {\n var result = [], sawLineNumbers = false;\n for (var i = 0; i < gutters.length; i++) {\n var name = gutters[i], style = null;\n if (typeof name != \"string\") { style = name.style; name = name.className; }\n if (name == \"CodeMirror-linenumbers\") {\n if (!lineNumbers) { continue }\n else { sawLineNumbers = true; }\n }\n result.push({className: name, style: style});\n }\n if (lineNumbers && !sawLineNumbers) { result.push({className: \"CodeMirror-linenumbers\", style: null}); }\n return result\n }\n\n // Rebuild the gutter elements, ensure the margin to the left of the\n // code matches their width.\n function renderGutters(display) {\n var gutters = display.gutters, specs = display.gutterSpecs;\n removeChildren(gutters);\n display.lineGutter = null;\n for (var i = 0; i < specs.length; ++i) {\n var ref = specs[i];\n var className = ref.className;\n var style = ref.style;\n var gElt = gutters.appendChild(elt(\"div\", null, \"CodeMirror-gutter \" + className));\n if (style) { gElt.style.cssText = style; }\n if (className == \"CodeMirror-linenumbers\") {\n display.lineGutter = gElt;\n gElt.style.width = (display.lineNumWidth || 1) + \"px\";\n }\n }\n gutters.style.display = specs.length ? \"\" : \"none\";\n updateGutterSpace(display);\n }\n\n function updateGutters(cm) {\n renderGutters(cm.display);\n regChange(cm);\n alignHorizontally(cm);\n }\n\n // The display handles the DOM integration, both for input reading\n // and content drawing. It holds references to DOM nodes and\n // display-related state.\n\n function Display(place, doc, input, options) {\n var d = this;\n this.input = input;\n\n // Covers bottom-right square when both scrollbars are present.\n d.scrollbarFiller = elt(\"div\", null, \"CodeMirror-scrollbar-filler\");\n d.scrollbarFiller.setAttribute(\"cm-not-content\", \"true\");\n // Covers bottom of gutter when coverGutterNextToScrollbar is on\n // and h scrollbar is present.\n d.gutterFiller = elt(\"div\", null, \"CodeMirror-gutter-filler\");\n d.gutterFiller.setAttribute(\"cm-not-content\", \"true\");\n // Will contain the actual code, positioned to cover the viewport.\n d.lineDiv = eltP(\"div\", null, \"CodeMirror-code\");\n // Elements are added to these to represent selection and cursors.\n d.selectionDiv = elt(\"div\", null, null, \"position: relative; z-index: 1\");\n d.cursorDiv = elt(\"div\", null, \"CodeMirror-cursors\");\n // A visibility: hidden element used to find the size of things.\n d.measure = elt(\"div\", null, \"CodeMirror-measure\");\n // When lines outside of the viewport are measured, they are drawn in this.\n d.lineMeasure = elt(\"div\", null, \"CodeMirror-measure\");\n // Wraps everything that needs to exist inside the vertically-padded coordinate system\n d.lineSpace = eltP(\"div\", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],\n null, \"position: relative; outline: none\");\n var lines = eltP(\"div\", [d.lineSpace], \"CodeMirror-lines\");\n // Moved around its parent to cover visible view.\n d.mover = elt(\"div\", [lines], null, \"position: relative\");\n // Set to the height of the document, allowing scrolling.\n d.sizer = elt(\"div\", [d.mover], \"CodeMirror-sizer\");\n d.sizerWidth = null;\n // Behavior of elts with overflow: auto and padding is\n // inconsistent across browsers. This is used to ensure the\n // scrollable area is big enough.\n d.heightForcer = elt(\"div\", null, null, \"position: absolute; height: \" + scrollerGap + \"px; width: 1px;\");\n // Will contain the gutters, if any.\n d.gutters = elt(\"div\", null, \"CodeMirror-gutters\");\n d.lineGutter = null;\n // Actual scrollable element.\n d.scroller = elt(\"div\", [d.sizer, d.heightForcer, d.gutters], \"CodeMirror-scroll\");\n d.scroller.setAttribute(\"tabIndex\", \"-1\");\n // The element in which the editor lives.\n d.wrapper = elt(\"div\", [d.scrollbarFiller, d.gutterFiller, d.scroller], \"CodeMirror\");\n\n // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)\n if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }\n if (!webkit && !(gecko && mobile)) { d.scroller.draggable = true; }\n\n if (place) {\n if (place.appendChild) { place.appendChild(d.wrapper); }\n else { place(d.wrapper); }\n }\n\n // Current rendered range (may be bigger than the view window).\n d.viewFrom = d.viewTo = doc.first;\n d.reportedViewFrom = d.reportedViewTo = doc.first;\n // Information about the rendered lines.\n d.view = [];\n d.renderedView = null;\n // Holds info about a single rendered line when it was rendered\n // for measurement, while not in view.\n d.externalMeasured = null;\n // Empty space (in pixels) above the view\n d.viewOffset = 0;\n d.lastWrapHeight = d.lastWrapWidth = 0;\n d.updateLineNumbers = null;\n\n d.nativeBarWidth = d.barHeight = d.barWidth = 0;\n d.scrollbarsClipped = false;\n\n // Used to only resize the line number gutter when necessary (when\n // the amount of lines crosses a boundary that makes its width change)\n d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;\n // Set to true when a non-horizontal-scrolling line widget is\n // added. As an optimization, line widget aligning is skipped when\n // this is false.\n d.alignWidgets = false;\n\n d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;\n\n // Tracks the maximum line length so that the horizontal scrollbar\n // can be kept static when scrolling.\n d.maxLine = null;\n d.maxLineLength = 0;\n d.maxLineChanged = false;\n\n // Used for measuring wheel scrolling granularity\n d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;\n\n // True when shift is held down.\n d.shift = false;\n\n // Used to track whether anything happened since the context menu\n // was opened.\n d.selForContextMenu = null;\n\n d.activeTouch = null;\n\n d.gutterSpecs = getGutters(options.gutters, options.lineNumbers);\n renderGutters(d);\n\n input.init(d);\n }\n\n // Since the delta values reported on mouse wheel events are\n // unstandardized between browsers and even browser versions, and\n // generally horribly unpredictable, this code starts by measuring\n // the scroll effect that the first few mouse wheel events have,\n // and, from that, detects the way it can convert deltas to pixel\n // offsets afterwards.\n //\n // The reason we want to know the amount a wheel event will scroll\n // is that it gives us a chance to update the display before the\n // actual scrolling happens, reducing flickering.\n\n var wheelSamples = 0, wheelPixelsPerUnit = null;\n // Fill in a browser-detected starting value on browsers where we\n // know one. These don't have to be accurate -- the result of them\n // being wrong would just be a slight flicker on the first wheel\n // scroll (if it is large enough).\n if (ie) { wheelPixelsPerUnit = -.53; }\n else if (gecko) { wheelPixelsPerUnit = 15; }\n else if (chrome) { wheelPixelsPerUnit = -.7; }\n else if (safari) { wheelPixelsPerUnit = -1/3; }\n\n function wheelEventDelta(e) {\n var dx = e.wheelDeltaX, dy = e.wheelDeltaY;\n if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) { dx = e.detail; }\n if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) { dy = e.detail; }\n else if (dy == null) { dy = e.wheelDelta; }\n return {x: dx, y: dy}\n }\n function wheelEventPixels(e) {\n var delta = wheelEventDelta(e);\n delta.x *= wheelPixelsPerUnit;\n delta.y *= wheelPixelsPerUnit;\n return delta\n }\n\n function onScrollWheel(cm, e) {\n var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y;\n\n var display = cm.display, scroll = display.scroller;\n // Quit if there's nothing to scroll here\n var canScrollX = scroll.scrollWidth > scroll.clientWidth;\n var canScrollY = scroll.scrollHeight > scroll.clientHeight;\n if (!(dx && canScrollX || dy && canScrollY)) { return }\n\n // Webkit browsers on OS X abort momentum scrolls when the target\n // of the scroll event is removed from the scrollable element.\n // This hack (see related code in patchDisplay) makes sure the\n // element is kept around.\n if (dy && mac && webkit) {\n outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) {\n for (var i = 0; i < view.length; i++) {\n if (view[i].node == cur) {\n cm.display.currentWheelTarget = cur;\n break outer\n }\n }\n }\n }\n\n // On some browsers, horizontal scrolling will cause redraws to\n // happen before the gutter has been realigned, causing it to\n // wriggle around in a most unseemly way. When we have an\n // estimated pixels/delta value, we just handle horizontal\n // scrolling entirely here. It'll be slightly off from native, but\n // better than glitching out.\n if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {\n if (dy && canScrollY)\n { updateScrollTop(cm, Math.max(0, scroll.scrollTop + dy * wheelPixelsPerUnit)); }\n setScrollLeft(cm, Math.max(0, scroll.scrollLeft + dx * wheelPixelsPerUnit));\n // Only prevent default scrolling if vertical scrolling is\n // actually possible. Otherwise, it causes vertical scroll\n // jitter on OSX trackpads when deltaX is small and deltaY\n // is large (issue #3579)\n if (!dy || (dy && canScrollY))\n { e_preventDefault(e); }\n display.wheelStartX = null; // Abort measurement, if in progress\n return\n }\n\n // 'Project' the visible viewport to cover the area that is being\n // scrolled into view (if we know enough to estimate it).\n if (dy && wheelPixelsPerUnit != null) {\n var pixels = dy * wheelPixelsPerUnit;\n var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight;\n if (pixels < 0) { top = Math.max(0, top + pixels - 50); }\n else { bot = Math.min(cm.doc.height, bot + pixels + 50); }\n updateDisplaySimple(cm, {top: top, bottom: bot});\n }\n\n if (wheelSamples < 20) {\n if (display.wheelStartX == null) {\n display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop;\n display.wheelDX = dx; display.wheelDY = dy;\n setTimeout(function () {\n if (display.wheelStartX == null) { return }\n var movedX = scroll.scrollLeft - display.wheelStartX;\n var movedY = scroll.scrollTop - display.wheelStartY;\n var sample = (movedY && display.wheelDY && movedY / display.wheelDY) ||\n (movedX && display.wheelDX && movedX / display.wheelDX);\n display.wheelStartX = display.wheelStartY = null;\n if (!sample) { return }\n wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1);\n ++wheelSamples;\n }, 200);\n } else {\n display.wheelDX += dx; display.wheelDY += dy;\n }\n }\n }\n\n // Selection objects are immutable. A new one is created every time\n // the selection changes. A selection is one or more non-overlapping\n // (and non-touching) ranges, sorted, and an integer that indicates\n // which one is the primary selection (the one that's scrolled into\n // view, that getCursor returns, etc).\n var Selection = function(ranges, primIndex) {\n this.ranges = ranges;\n this.primIndex = primIndex;\n };\n\n Selection.prototype.primary = function () { return this.ranges[this.primIndex] };\n\n Selection.prototype.equals = function (other) {\n var this$1 = this;\n\n if (other == this) { return true }\n if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) { return false }\n for (var i = 0; i < this.ranges.length; i++) {\n var here = this$1.ranges[i], there = other.ranges[i];\n if (!equalCursorPos(here.anchor, there.anchor) || !equalCursorPos(here.head, there.head)) { return false }\n }\n return true\n };\n\n Selection.prototype.deepCopy = function () {\n var this$1 = this;\n\n var out = [];\n for (var i = 0; i < this.ranges.length; i++)\n { out[i] = new Range(copyPos(this$1.ranges[i].anchor), copyPos(this$1.ranges[i].head)); }\n return new Selection(out, this.primIndex)\n };\n\n Selection.prototype.somethingSelected = function () {\n var this$1 = this;\n\n for (var i = 0; i < this.ranges.length; i++)\n { if (!this$1.ranges[i].empty()) { return true } }\n return false\n };\n\n Selection.prototype.contains = function (pos, end) {\n var this$1 = this;\n\n if (!end) { end = pos; }\n for (var i = 0; i < this.ranges.length; i++) {\n var range = this$1.ranges[i];\n if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)\n { return i }\n }\n return -1\n };\n\n var Range = function(anchor, head) {\n this.anchor = anchor; this.head = head;\n };\n\n Range.prototype.from = function () { return minPos(this.anchor, this.head) };\n Range.prototype.to = function () { return maxPos(this.anchor, this.head) };\n Range.prototype.empty = function () { return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch };\n\n // Take an unsorted, potentially overlapping set of ranges, and\n // build a selection out of it. 'Consumes' ranges array (modifying\n // it).\n function normalizeSelection(cm, ranges, primIndex) {\n var mayTouch = cm && cm.options.selectionsMayTouch;\n var prim = ranges[primIndex];\n ranges.sort(function (a, b) { return cmp(a.from(), b.from()); });\n primIndex = indexOf(ranges, prim);\n for (var i = 1; i < ranges.length; i++) {\n var cur = ranges[i], prev = ranges[i - 1];\n var diff = cmp(prev.to(), cur.from());\n if (mayTouch && !cur.empty() ? diff > 0 : diff >= 0) {\n var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to());\n var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head;\n if (i <= primIndex) { --primIndex; }\n ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to));\n }\n }\n return new Selection(ranges, primIndex)\n }\n\n function simpleSelection(anchor, head) {\n return new Selection([new Range(anchor, head || anchor)], 0)\n }\n\n // Compute the position of the end of a change (its 'to' property\n // refers to the pre-change end).\n function changeEnd(change) {\n if (!change.text) { return change.to }\n return Pos(change.from.line + change.text.length - 1,\n lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0))\n }\n\n // Adjust a position to refer to the post-change position of the\n // same text, or the end of the change if the change covers it.\n function adjustForChange(pos, change) {\n if (cmp(pos, change.from) < 0) { return pos }\n if (cmp(pos, change.to) <= 0) { return changeEnd(change) }\n\n var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;\n if (pos.line == change.to.line) { ch += changeEnd(change).ch - change.to.ch; }\n return Pos(line, ch)\n }\n\n function computeSelAfterChange(doc, change) {\n var out = [];\n for (var i = 0; i < doc.sel.ranges.length; i++) {\n var range = doc.sel.ranges[i];\n out.push(new Range(adjustForChange(range.anchor, change),\n adjustForChange(range.head, change)));\n }\n return normalizeSelection(doc.cm, out, doc.sel.primIndex)\n }\n\n function offsetPos(pos, old, nw) {\n if (pos.line == old.line)\n { return Pos(nw.line, pos.ch - old.ch + nw.ch) }\n else\n { return Pos(nw.line + (pos.line - old.line), pos.ch) }\n }\n\n // Used by replaceSelections to allow moving the selection to the\n // start or around the replaced test. Hint may be \"start\" or \"around\".\n function computeReplacedSel(doc, changes, hint) {\n var out = [];\n var oldPrev = Pos(doc.first, 0), newPrev = oldPrev;\n for (var i = 0; i < changes.length; i++) {\n var change = changes[i];\n var from = offsetPos(change.from, oldPrev, newPrev);\n var to = offsetPos(changeEnd(change), oldPrev, newPrev);\n oldPrev = change.to;\n newPrev = to;\n if (hint == \"around\") {\n var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0;\n out[i] = new Range(inv ? to : from, inv ? from : to);\n } else {\n out[i] = new Range(from, from);\n }\n }\n return new Selection(out, doc.sel.primIndex)\n }\n\n // Used to get the editor into a consistent state again when options change.\n\n function loadMode(cm) {\n cm.doc.mode = getMode(cm.options, cm.doc.modeOption);\n resetModeState(cm);\n }\n\n function resetModeState(cm) {\n cm.doc.iter(function (line) {\n if (line.stateAfter) { line.stateAfter = null; }\n if (line.styles) { line.styles = null; }\n });\n cm.doc.modeFrontier = cm.doc.highlightFrontier = cm.doc.first;\n startWorker(cm, 100);\n cm.state.modeGen++;\n if (cm.curOp) { regChange(cm); }\n }\n\n // DOCUMENT DATA STRUCTURE\n\n // By default, updates that start and end at the beginning of a line\n // are treated specially, in order to make the association of line\n // widgets and marker elements with the text behave more intuitive.\n function isWholeLineUpdate(doc, change) {\n return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == \"\" &&\n (!doc.cm || doc.cm.options.wholeLineUpdateBefore)\n }\n\n // Perform a change on the document data structure.\n function updateDoc(doc, change, markedSpans, estimateHeight$$1) {\n function spansFor(n) {return markedSpans ? markedSpans[n] : null}\n function update(line, text, spans) {\n updateLine(line, text, spans, estimateHeight$$1);\n signalLater(line, \"change\", line, change);\n }\n function linesFor(start, end) {\n var result = [];\n for (var i = start; i < end; ++i)\n { result.push(new Line(text[i], spansFor(i), estimateHeight$$1)); }\n return result\n }\n\n var from = change.from, to = change.to, text = change.text;\n var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line);\n var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line;\n\n // Adjust the line structure\n if (change.full) {\n doc.insert(0, linesFor(0, text.length));\n doc.remove(text.length, doc.size - text.length);\n } else if (isWholeLineUpdate(doc, change)) {\n // This is a whole-line replace. Treated specially to make\n // sure line objects move the way they are supposed to.\n var added = linesFor(0, text.length - 1);\n update(lastLine, lastLine.text, lastSpans);\n if (nlines) { doc.remove(from.line, nlines); }\n if (added.length) { doc.insert(from.line, added); }\n } else if (firstLine == lastLine) {\n if (text.length == 1) {\n update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans);\n } else {\n var added$1 = linesFor(1, text.length - 1);\n added$1.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight$$1));\n update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));\n doc.insert(from.line + 1, added$1);\n }\n } else if (text.length == 1) {\n update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0));\n doc.remove(from.line + 1, nlines);\n } else {\n update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));\n update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans);\n var added$2 = linesFor(1, text.length - 1);\n if (nlines > 1) { doc.remove(from.line + 1, nlines - 1); }\n doc.insert(from.line + 1, added$2);\n }\n\n signalLater(doc, \"change\", doc, change);\n }\n\n // Call f for all linked documents.\n function linkedDocs(doc, f, sharedHistOnly) {\n function propagate(doc, skip, sharedHist) {\n if (doc.linked) { for (var i = 0; i < doc.linked.length; ++i) {\n var rel = doc.linked[i];\n if (rel.doc == skip) { continue }\n var shared = sharedHist && rel.sharedHist;\n if (sharedHistOnly && !shared) { continue }\n f(rel.doc, shared);\n propagate(rel.doc, doc, shared);\n } }\n }\n propagate(doc, null, true);\n }\n\n // Attach a document to an editor.\n function attachDoc(cm, doc) {\n if (doc.cm) { throw new Error(\"This document is already in use.\") }\n cm.doc = doc;\n doc.cm = cm;\n estimateLineHeights(cm);\n loadMode(cm);\n setDirectionClass(cm);\n if (!cm.options.lineWrapping) { findMaxLine(cm); }\n cm.options.mode = doc.modeOption;\n regChange(cm);\n }\n\n function setDirectionClass(cm) {\n (cm.doc.direction == \"rtl\" ? addClass : rmClass)(cm.display.lineDiv, \"CodeMirror-rtl\");\n }\n\n function directionChanged(cm) {\n runInOp(cm, function () {\n setDirectionClass(cm);\n regChange(cm);\n });\n }\n\n function History(startGen) {\n // Arrays of change events and selections. Doing something adds an\n // event to done and clears undo. Undoing moves events from done\n // to undone, redoing moves them in the other direction.\n this.done = []; this.undone = [];\n this.undoDepth = Infinity;\n // Used to track when changes can be merged into a single undo\n // event\n this.lastModTime = this.lastSelTime = 0;\n this.lastOp = this.lastSelOp = null;\n this.lastOrigin = this.lastSelOrigin = null;\n // Used by the isClean() method\n this.generation = this.maxGeneration = startGen || 1;\n }\n\n // Create a history change event from an updateDoc-style change\n // object.\n function historyChangeFromChange(doc, change) {\n var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)};\n attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);\n linkedDocs(doc, function (doc) { return attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); }, true);\n return histChange\n }\n\n // Pop all selection events off the end of a history array. Stop at\n // a change event.\n function clearSelectionEvents(array) {\n while (array.length) {\n var last = lst(array);\n if (last.ranges) { array.pop(); }\n else { break }\n }\n }\n\n // Find the top change event in the history. Pop off selection\n // events that are in the way.\n function lastChangeEvent(hist, force) {\n if (force) {\n clearSelectionEvents(hist.done);\n return lst(hist.done)\n } else if (hist.done.length && !lst(hist.done).ranges) {\n return lst(hist.done)\n } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {\n hist.done.pop();\n return lst(hist.done)\n }\n }\n\n // Register a change in the history. Merges changes that are within\n // a single operation, or are close together with an origin that\n // allows merging (starting with \"+\") into a single event.\n function addChangeToHistory(doc, change, selAfter, opId) {\n var hist = doc.history;\n hist.undone.length = 0;\n var time = +new Date, cur;\n var last;\n\n if ((hist.lastOp == opId ||\n hist.lastOrigin == change.origin && change.origin &&\n ((change.origin.charAt(0) == \"+\" && hist.lastModTime > time - (doc.cm ? doc.cm.options.historyEventDelay : 500)) ||\n change.origin.charAt(0) == \"*\")) &&\n (cur = lastChangeEvent(hist, hist.lastOp == opId))) {\n // Merge this change into the last event\n last = lst(cur.changes);\n if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) {\n // Optimized case for simple insertion -- don't want to add\n // new changesets for every character typed\n last.to = changeEnd(change);\n } else {\n // Add new sub-event\n cur.changes.push(historyChangeFromChange(doc, change));\n }\n } else {\n // Can not be merged, start a new event.\n var before = lst(hist.done);\n if (!before || !before.ranges)\n { pushSelectionToHistory(doc.sel, hist.done); }\n cur = {changes: [historyChangeFromChange(doc, change)],\n generation: hist.generation};\n hist.done.push(cur);\n while (hist.done.length > hist.undoDepth) {\n hist.done.shift();\n if (!hist.done[0].ranges) { hist.done.shift(); }\n }\n }\n hist.done.push(selAfter);\n hist.generation = ++hist.maxGeneration;\n hist.lastModTime = hist.lastSelTime = time;\n hist.lastOp = hist.lastSelOp = opId;\n hist.lastOrigin = hist.lastSelOrigin = change.origin;\n\n if (!last) { signal(doc, \"historyAdded\"); }\n }\n\n function selectionEventCanBeMerged(doc, origin, prev, sel) {\n var ch = origin.charAt(0);\n return ch == \"*\" ||\n ch == \"+\" &&\n prev.ranges.length == sel.ranges.length &&\n prev.somethingSelected() == sel.somethingSelected() &&\n new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500)\n }\n\n // Called whenever the selection changes, sets the new selection as\n // the pending selection in the history, and pushes the old pending\n // selection into the 'done' array when it was significantly\n // different (in number of selected ranges, emptiness, or time).\n function addSelectionToHistory(doc, sel, opId, options) {\n var hist = doc.history, origin = options && options.origin;\n\n // A new event is started when the previous origin does not match\n // the current, or the origins don't allow matching. Origins\n // starting with * are always merged, those starting with + are\n // merged when similar and close together in time.\n if (opId == hist.lastSelOp ||\n (origin && hist.lastSelOrigin == origin &&\n (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin ||\n selectionEventCanBeMerged(doc, origin, lst(hist.done), sel))))\n { hist.done[hist.done.length - 1] = sel; }\n else\n { pushSelectionToHistory(sel, hist.done); }\n\n hist.lastSelTime = +new Date;\n hist.lastSelOrigin = origin;\n hist.lastSelOp = opId;\n if (options && options.clearRedo !== false)\n { clearSelectionEvents(hist.undone); }\n }\n\n function pushSelectionToHistory(sel, dest) {\n var top = lst(dest);\n if (!(top && top.ranges && top.equals(sel)))\n { dest.push(sel); }\n }\n\n // Used to store marked span information in the history.\n function attachLocalSpans(doc, change, from, to) {\n var existing = change[\"spans_\" + doc.id], n = 0;\n doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function (line) {\n if (line.markedSpans)\n { (existing || (existing = change[\"spans_\" + doc.id] = {}))[n] = line.markedSpans; }\n ++n;\n });\n }\n\n // When un/re-doing restores text containing marked spans, those\n // that have been explicitly cleared should not be restored.\n function removeClearedSpans(spans) {\n if (!spans) { return null }\n var out;\n for (var i = 0; i < spans.length; ++i) {\n if (spans[i].marker.explicitlyCleared) { if (!out) { out = spans.slice(0, i); } }\n else if (out) { out.push(spans[i]); }\n }\n return !out ? spans : out.length ? out : null\n }\n\n // Retrieve and filter the old marked spans stored in a change event.\n function getOldSpans(doc, change) {\n var found = change[\"spans_\" + doc.id];\n if (!found) { return null }\n var nw = [];\n for (var i = 0; i < change.text.length; ++i)\n { nw.push(removeClearedSpans(found[i])); }\n return nw\n }\n\n // Used for un/re-doing changes from the history. Combines the\n // result of computing the existing spans with the set of spans that\n // existed in the history (so that deleting around a span and then\n // undoing brings back the span).\n function mergeOldSpans(doc, change) {\n var old = getOldSpans(doc, change);\n var stretched = stretchSpansOverChange(doc, change);\n if (!old) { return stretched }\n if (!stretched) { return old }\n\n for (var i = 0; i < old.length; ++i) {\n var oldCur = old[i], stretchCur = stretched[i];\n if (oldCur && stretchCur) {\n spans: for (var j = 0; j < stretchCur.length; ++j) {\n var span = stretchCur[j];\n for (var k = 0; k < oldCur.length; ++k)\n { if (oldCur[k].marker == span.marker) { continue spans } }\n oldCur.push(span);\n }\n } else if (stretchCur) {\n old[i] = stretchCur;\n }\n }\n return old\n }\n\n // Used both to provide a JSON-safe object in .getHistory, and, when\n // detaching a document, to split the history in two\n function copyHistoryArray(events, newGroup, instantiateSel) {\n var copy = [];\n for (var i = 0; i < events.length; ++i) {\n var event = events[i];\n if (event.ranges) {\n copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event);\n continue\n }\n var changes = event.changes, newChanges = [];\n copy.push({changes: newChanges});\n for (var j = 0; j < changes.length; ++j) {\n var change = changes[j], m = (void 0);\n newChanges.push({from: change.from, to: change.to, text: change.text});\n if (newGroup) { for (var prop in change) { if (m = prop.match(/^spans_(\\d+)$/)) {\n if (indexOf(newGroup, Number(m[1])) > -1) {\n lst(newChanges)[prop] = change[prop];\n delete change[prop];\n }\n } } }\n }\n }\n return copy\n }\n\n // The 'scroll' parameter given to many of these indicated whether\n // the new cursor position should be scrolled into view after\n // modifying the selection.\n\n // If shift is held or the extend flag is set, extends a range to\n // include a given position (and optionally a second position).\n // Otherwise, simply returns the range between the given positions.\n // Used for cursor motion and such.\n function extendRange(range, head, other, extend) {\n if (extend) {\n var anchor = range.anchor;\n if (other) {\n var posBefore = cmp(head, anchor) < 0;\n if (posBefore != (cmp(other, anchor) < 0)) {\n anchor = head;\n head = other;\n } else if (posBefore != (cmp(head, other) < 0)) {\n head = other;\n }\n }\n return new Range(anchor, head)\n } else {\n return new Range(other || head, head)\n }\n }\n\n // Extend the primary selection range, discard the rest.\n function extendSelection(doc, head, other, options, extend) {\n if (extend == null) { extend = doc.cm && (doc.cm.display.shift || doc.extend); }\n setSelection(doc, new Selection([extendRange(doc.sel.primary(), head, other, extend)], 0), options);\n }\n\n // Extend all selections (pos is an array of selections with length\n // equal the number of selections)\n function extendSelections(doc, heads, options) {\n var out = [];\n var extend = doc.cm && (doc.cm.display.shift || doc.extend);\n for (var i = 0; i < doc.sel.ranges.length; i++)\n { out[i] = extendRange(doc.sel.ranges[i], heads[i], null, extend); }\n var newSel = normalizeSelection(doc.cm, out, doc.sel.primIndex);\n setSelection(doc, newSel, options);\n }\n\n // Updates a single range in the selection.\n function replaceOneSelection(doc, i, range, options) {\n var ranges = doc.sel.ranges.slice(0);\n ranges[i] = range;\n setSelection(doc, normalizeSelection(doc.cm, ranges, doc.sel.primIndex), options);\n }\n\n // Reset the selection to a single range.\n function setSimpleSelection(doc, anchor, head, options) {\n setSelection(doc, simpleSelection(anchor, head), options);\n }\n\n // Give beforeSelectionChange handlers a change to influence a\n // selection update.\n function filterSelectionChange(doc, sel, options) {\n var obj = {\n ranges: sel.ranges,\n update: function(ranges) {\n var this$1 = this;\n\n this.ranges = [];\n for (var i = 0; i < ranges.length; i++)\n { this$1.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),\n clipPos(doc, ranges[i].head)); }\n },\n origin: options && options.origin\n };\n signal(doc, \"beforeSelectionChange\", doc, obj);\n if (doc.cm) { signal(doc.cm, \"beforeSelectionChange\", doc.cm, obj); }\n if (obj.ranges != sel.ranges) { return normalizeSelection(doc.cm, obj.ranges, obj.ranges.length - 1) }\n else { return sel }\n }\n\n function setSelectionReplaceHistory(doc, sel, options) {\n var done = doc.history.done, last = lst(done);\n if (last && last.ranges) {\n done[done.length - 1] = sel;\n setSelectionNoUndo(doc, sel, options);\n } else {\n setSelection(doc, sel, options);\n }\n }\n\n // Set a new selection.\n function setSelection(doc, sel, options) {\n setSelectionNoUndo(doc, sel, options);\n addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options);\n }\n\n function setSelectionNoUndo(doc, sel, options) {\n if (hasHandler(doc, \"beforeSelectionChange\") || doc.cm && hasHandler(doc.cm, \"beforeSelectionChange\"))\n { sel = filterSelectionChange(doc, sel, options); }\n\n var bias = options && options.bias ||\n (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);\n setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));\n\n if (!(options && options.scroll === false) && doc.cm)\n { ensureCursorVisible(doc.cm); }\n }\n\n function setSelectionInner(doc, sel) {\n if (sel.equals(doc.sel)) { return }\n\n doc.sel = sel;\n\n if (doc.cm) {\n doc.cm.curOp.updateInput = 1;\n doc.cm.curOp.selectionChanged = true;\n signalCursorActivity(doc.cm);\n }\n signalLater(doc, \"cursorActivity\", doc);\n }\n\n // Verify that the selection does not partially select any atomic\n // marked ranges.\n function reCheckSelection(doc) {\n setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false));\n }\n\n // Return a selection that does not partially select any atomic\n // ranges.\n function skipAtomicInSelection(doc, sel, bias, mayClear) {\n var out;\n for (var i = 0; i < sel.ranges.length; i++) {\n var range = sel.ranges[i];\n var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i];\n var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear);\n var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear);\n if (out || newAnchor != range.anchor || newHead != range.head) {\n if (!out) { out = sel.ranges.slice(0, i); }\n out[i] = new Range(newAnchor, newHead);\n }\n }\n return out ? normalizeSelection(doc.cm, out, sel.primIndex) : sel\n }\n\n function skipAtomicInner(doc, pos, oldPos, dir, mayClear) {\n var line = getLine(doc, pos.line);\n if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) {\n var sp = line.markedSpans[i], m = sp.marker;\n\n // Determine if we should prevent the cursor being placed to the left/right of an atomic marker\n // Historically this was determined using the inclusiveLeft/Right option, but the new way to control it\n // is with selectLeft/Right\n var preventCursorLeft = (\"selectLeft\" in m) ? !m.selectLeft : m.inclusiveLeft;\n var preventCursorRight = (\"selectRight\" in m) ? !m.selectRight : m.inclusiveRight;\n\n if ((sp.from == null || (preventCursorLeft ? sp.from <= pos.ch : sp.from < pos.ch)) &&\n (sp.to == null || (preventCursorRight ? sp.to >= pos.ch : sp.to > pos.ch))) {\n if (mayClear) {\n signal(m, \"beforeCursorEnter\");\n if (m.explicitlyCleared) {\n if (!line.markedSpans) { break }\n else {--i; continue}\n }\n }\n if (!m.atomic) { continue }\n\n if (oldPos) {\n var near = m.find(dir < 0 ? 1 : -1), diff = (void 0);\n if (dir < 0 ? preventCursorRight : preventCursorLeft)\n { near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null); }\n if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))\n { return skipAtomicInner(doc, near, pos, dir, mayClear) }\n }\n\n var far = m.find(dir < 0 ? -1 : 1);\n if (dir < 0 ? preventCursorLeft : preventCursorRight)\n { far = movePos(doc, far, dir, far.line == pos.line ? line : null); }\n return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null\n }\n } }\n return pos\n }\n\n // Ensure a given position is not inside an atomic range.\n function skipAtomic(doc, pos, oldPos, bias, mayClear) {\n var dir = bias || 1;\n var found = skipAtomicInner(doc, pos, oldPos, dir, mayClear) ||\n (!mayClear && skipAtomicInner(doc, pos, oldPos, dir, true)) ||\n skipAtomicInner(doc, pos, oldPos, -dir, mayClear) ||\n (!mayClear && skipAtomicInner(doc, pos, oldPos, -dir, true));\n if (!found) {\n doc.cantEdit = true;\n return Pos(doc.first, 0)\n }\n return found\n }\n\n function movePos(doc, pos, dir, line) {\n if (dir < 0 && pos.ch == 0) {\n if (pos.line > doc.first) { return clipPos(doc, Pos(pos.line - 1)) }\n else { return null }\n } else if (dir > 0 && pos.ch == (line || getLine(doc, pos.line)).text.length) {\n if (pos.line < doc.first + doc.size - 1) { return Pos(pos.line + 1, 0) }\n else { return null }\n } else {\n return new Pos(pos.line, pos.ch + dir)\n }\n }\n\n function selectAll(cm) {\n cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll);\n }\n\n // UPDATING\n\n // Allow \"beforeChange\" event handlers to influence a change\n function filterChange(doc, change, update) {\n var obj = {\n canceled: false,\n from: change.from,\n to: change.to,\n text: change.text,\n origin: change.origin,\n cancel: function () { return obj.canceled = true; }\n };\n if (update) { obj.update = function (from, to, text, origin) {\n if (from) { obj.from = clipPos(doc, from); }\n if (to) { obj.to = clipPos(doc, to); }\n if (text) { obj.text = text; }\n if (origin !== undefined) { obj.origin = origin; }\n }; }\n signal(doc, \"beforeChange\", doc, obj);\n if (doc.cm) { signal(doc.cm, \"beforeChange\", doc.cm, obj); }\n\n if (obj.canceled) {\n if (doc.cm) { doc.cm.curOp.updateInput = 2; }\n return null\n }\n return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin}\n }\n\n // Apply a change to a document, and add it to the document's\n // history, and propagating it to all linked documents.\n function makeChange(doc, change, ignoreReadOnly) {\n if (doc.cm) {\n if (!doc.cm.curOp) { return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly) }\n if (doc.cm.state.suppressEdits) { return }\n }\n\n if (hasHandler(doc, \"beforeChange\") || doc.cm && hasHandler(doc.cm, \"beforeChange\")) {\n change = filterChange(doc, change, true);\n if (!change) { return }\n }\n\n // Possibly split or suppress the update based on the presence\n // of read-only spans in its range.\n var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to);\n if (split) {\n for (var i = split.length - 1; i >= 0; --i)\n { makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [\"\"] : change.text, origin: change.origin}); }\n } else {\n makeChangeInner(doc, change);\n }\n }\n\n function makeChangeInner(doc, change) {\n if (change.text.length == 1 && change.text[0] == \"\" && cmp(change.from, change.to) == 0) { return }\n var selAfter = computeSelAfterChange(doc, change);\n addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN);\n\n makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change));\n var rebased = [];\n\n linkedDocs(doc, function (doc, sharedHist) {\n if (!sharedHist && indexOf(rebased, doc.history) == -1) {\n rebaseHist(doc.history, change);\n rebased.push(doc.history);\n }\n makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change));\n });\n }\n\n // Revert a change stored in a document's history.\n function makeChangeFromHistory(doc, type, allowSelectionOnly) {\n var suppress = doc.cm && doc.cm.state.suppressEdits;\n if (suppress && !allowSelectionOnly) { return }\n\n var hist = doc.history, event, selAfter = doc.sel;\n var source = type == \"undo\" ? hist.done : hist.undone, dest = type == \"undo\" ? hist.undone : hist.done;\n\n // Verify that there is a useable event (so that ctrl-z won't\n // needlessly clear selection events)\n var i = 0;\n for (; i < source.length; i++) {\n event = source[i];\n if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges)\n { break }\n }\n if (i == source.length) { return }\n hist.lastOrigin = hist.lastSelOrigin = null;\n\n for (;;) {\n event = source.pop();\n if (event.ranges) {\n pushSelectionToHistory(event, dest);\n if (allowSelectionOnly && !event.equals(doc.sel)) {\n setSelection(doc, event, {clearRedo: false});\n return\n }\n selAfter = event;\n } else if (suppress) {\n source.push(event);\n return\n } else { break }\n }\n\n // Build up a reverse change object to add to the opposite history\n // stack (redo when undoing, and vice versa).\n var antiChanges = [];\n pushSelectionToHistory(selAfter, dest);\n dest.push({changes: antiChanges, generation: hist.generation});\n hist.generation = event.generation || ++hist.maxGeneration;\n\n var filter = hasHandler(doc, \"beforeChange\") || doc.cm && hasHandler(doc.cm, \"beforeChange\");\n\n var loop = function ( i ) {\n var change = event.changes[i];\n change.origin = type;\n if (filter && !filterChange(doc, change, false)) {\n source.length = 0;\n return {}\n }\n\n antiChanges.push(historyChangeFromChange(doc, change));\n\n var after = i ? computeSelAfterChange(doc, change) : lst(source);\n makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change));\n if (!i && doc.cm) { doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)}); }\n var rebased = [];\n\n // Propagate to the linked documents\n linkedDocs(doc, function (doc, sharedHist) {\n if (!sharedHist && indexOf(rebased, doc.history) == -1) {\n rebaseHist(doc.history, change);\n rebased.push(doc.history);\n }\n makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change));\n });\n };\n\n for (var i$1 = event.changes.length - 1; i$1 >= 0; --i$1) {\n var returned = loop( i$1 );\n\n if ( returned ) return returned.v;\n }\n }\n\n // Sub-views need their line numbers shifted when text is added\n // above or below them in the parent document.\n function shiftDoc(doc, distance) {\n if (distance == 0) { return }\n doc.first += distance;\n doc.sel = new Selection(map(doc.sel.ranges, function (range) { return new Range(\n Pos(range.anchor.line + distance, range.anchor.ch),\n Pos(range.head.line + distance, range.head.ch)\n ); }), doc.sel.primIndex);\n if (doc.cm) {\n regChange(doc.cm, doc.first, doc.first - distance, distance);\n for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++)\n { regLineChange(doc.cm, l, \"gutter\"); }\n }\n }\n\n // More lower-level change function, handling only a single document\n // (not linked ones).\n function makeChangeSingleDoc(doc, change, selAfter, spans) {\n if (doc.cm && !doc.cm.curOp)\n { return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans) }\n\n if (change.to.line < doc.first) {\n shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line));\n return\n }\n if (change.from.line > doc.lastLine()) { return }\n\n // Clip the change to the size of this doc\n if (change.from.line < doc.first) {\n var shift = change.text.length - 1 - (doc.first - change.from.line);\n shiftDoc(doc, shift);\n change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),\n text: [lst(change.text)], origin: change.origin};\n }\n var last = doc.lastLine();\n if (change.to.line > last) {\n change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),\n text: [change.text[0]], origin: change.origin};\n }\n\n change.removed = getBetween(doc, change.from, change.to);\n\n if (!selAfter) { selAfter = computeSelAfterChange(doc, change); }\n if (doc.cm) { makeChangeSingleDocInEditor(doc.cm, change, spans); }\n else { updateDoc(doc, change, spans); }\n setSelectionNoUndo(doc, selAfter, sel_dontScroll);\n\n if (doc.cantEdit && skipAtomic(doc, Pos(doc.firstLine(), 0)))\n { doc.cantEdit = false; }\n }\n\n // Handle the interaction of a change to a document with the editor\n // that this document is part of.\n function makeChangeSingleDocInEditor(cm, change, spans) {\n var doc = cm.doc, display = cm.display, from = change.from, to = change.to;\n\n var recomputeMaxLength = false, checkWidthStart = from.line;\n if (!cm.options.lineWrapping) {\n checkWidthStart = lineNo(visualLine(getLine(doc, from.line)));\n doc.iter(checkWidthStart, to.line + 1, function (line) {\n if (line == display.maxLine) {\n recomputeMaxLength = true;\n return true\n }\n });\n }\n\n if (doc.sel.contains(change.from, change.to) > -1)\n { signalCursorActivity(cm); }\n\n updateDoc(doc, change, spans, estimateHeight(cm));\n\n if (!cm.options.lineWrapping) {\n doc.iter(checkWidthStart, from.line + change.text.length, function (line) {\n var len = lineLength(line);\n if (len > display.maxLineLength) {\n display.maxLine = line;\n display.maxLineLength = len;\n display.maxLineChanged = true;\n recomputeMaxLength = false;\n }\n });\n if (recomputeMaxLength) { cm.curOp.updateMaxLine = true; }\n }\n\n retreatFrontier(doc, from.line);\n startWorker(cm, 400);\n\n var lendiff = change.text.length - (to.line - from.line) - 1;\n // Remember that these lines changed, for updating the display\n if (change.full)\n { regChange(cm); }\n else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change))\n { regLineChange(cm, from.line, \"text\"); }\n else\n { regChange(cm, from.line, to.line + 1, lendiff); }\n\n var changesHandler = hasHandler(cm, \"changes\"), changeHandler = hasHandler(cm, \"change\");\n if (changeHandler || changesHandler) {\n var obj = {\n from: from, to: to,\n text: change.text,\n removed: change.removed,\n origin: change.origin\n };\n if (changeHandler) { signalLater(cm, \"change\", cm, obj); }\n if (changesHandler) { (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj); }\n }\n cm.display.selForContextMenu = null;\n }\n\n function replaceRange(doc, code, from, to, origin) {\n var assign;\n\n if (!to) { to = from; }\n if (cmp(to, from) < 0) { (assign = [to, from], from = assign[0], to = assign[1]); }\n if (typeof code == \"string\") { code = doc.splitLines(code); }\n makeChange(doc, {from: from, to: to, text: code, origin: origin});\n }\n\n // Rebasing/resetting history to deal with externally-sourced changes\n\n function rebaseHistSelSingle(pos, from, to, diff) {\n if (to < pos.line) {\n pos.line += diff;\n } else if (from < pos.line) {\n pos.line = from;\n pos.ch = 0;\n }\n }\n\n // Tries to rebase an array of history events given a change in the\n // document. If the change touches the same lines as the event, the\n // event, and everything 'behind' it, is discarded. If the change is\n // before the event, the event's positions are updated. Uses a\n // copy-on-write scheme for the positions, to avoid having to\n // reallocate them all on every rebase, but also avoid problems with\n // shared position objects being unsafely updated.\n function rebaseHistArray(array, from, to, diff) {\n for (var i = 0; i < array.length; ++i) {\n var sub = array[i], ok = true;\n if (sub.ranges) {\n if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; }\n for (var j = 0; j < sub.ranges.length; j++) {\n rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff);\n rebaseHistSelSingle(sub.ranges[j].head, from, to, diff);\n }\n continue\n }\n for (var j$1 = 0; j$1 < sub.changes.length; ++j$1) {\n var cur = sub.changes[j$1];\n if (to < cur.from.line) {\n cur.from = Pos(cur.from.line + diff, cur.from.ch);\n cur.to = Pos(cur.to.line + diff, cur.to.ch);\n } else if (from <= cur.to.line) {\n ok = false;\n break\n }\n }\n if (!ok) {\n array.splice(0, i + 1);\n i = 0;\n }\n }\n }\n\n function rebaseHist(hist, change) {\n var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1;\n rebaseHistArray(hist.done, from, to, diff);\n rebaseHistArray(hist.undone, from, to, diff);\n }\n\n // Utility for applying a change to a line by handle or number,\n // returning the number and optionally registering the line as\n // changed.\n function changeLine(doc, handle, changeType, op) {\n var no = handle, line = handle;\n if (typeof handle == \"number\") { line = getLine(doc, clipLine(doc, handle)); }\n else { no = lineNo(handle); }\n if (no == null) { return null }\n if (op(line, no) && doc.cm) { regLineChange(doc.cm, no, changeType); }\n return line\n }\n\n // The document is represented as a BTree consisting of leaves, with\n // chunk of lines in them, and branches, with up to ten leaves or\n // other branch nodes below them. The top node is always a branch\n // node, and is the document object itself (meaning it has\n // additional methods and properties).\n //\n // All nodes have parent links. The tree is used both to go from\n // line numbers to line objects, and to go from objects to numbers.\n // It also indexes by height, and is used to convert between height\n // and line object, and to find the total height of the document.\n //\n // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html\n\n function LeafChunk(lines) {\n var this$1 = this;\n\n this.lines = lines;\n this.parent = null;\n var height = 0;\n for (var i = 0; i < lines.length; ++i) {\n lines[i].parent = this$1;\n height += lines[i].height;\n }\n this.height = height;\n }\n\n LeafChunk.prototype = {\n chunkSize: function() { return this.lines.length },\n\n // Remove the n lines at offset 'at'.\n removeInner: function(at, n) {\n var this$1 = this;\n\n for (var i = at, e = at + n; i < e; ++i) {\n var line = this$1.lines[i];\n this$1.height -= line.height;\n cleanUpLine(line);\n signalLater(line, \"delete\");\n }\n this.lines.splice(at, n);\n },\n\n // Helper used to collapse a small branch into a single leaf.\n collapse: function(lines) {\n lines.push.apply(lines, this.lines);\n },\n\n // Insert the given array of lines at offset 'at', count them as\n // having the given height.\n insertInner: function(at, lines, height) {\n var this$1 = this;\n\n this.height += height;\n this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at));\n for (var i = 0; i < lines.length; ++i) { lines[i].parent = this$1; }\n },\n\n // Used to iterate over a part of the tree.\n iterN: function(at, n, op) {\n var this$1 = this;\n\n for (var e = at + n; at < e; ++at)\n { if (op(this$1.lines[at])) { return true } }\n }\n };\n\n function BranchChunk(children) {\n var this$1 = this;\n\n this.children = children;\n var size = 0, height = 0;\n for (var i = 0; i < children.length; ++i) {\n var ch = children[i];\n size += ch.chunkSize(); height += ch.height;\n ch.parent = this$1;\n }\n this.size = size;\n this.height = height;\n this.parent = null;\n }\n\n BranchChunk.prototype = {\n chunkSize: function() { return this.size },\n\n removeInner: function(at, n) {\n var this$1 = this;\n\n this.size -= n;\n for (var i = 0; i < this.children.length; ++i) {\n var child = this$1.children[i], sz = child.chunkSize();\n if (at < sz) {\n var rm = Math.min(n, sz - at), oldHeight = child.height;\n child.removeInner(at, rm);\n this$1.height -= oldHeight - child.height;\n if (sz == rm) { this$1.children.splice(i--, 1); child.parent = null; }\n if ((n -= rm) == 0) { break }\n at = 0;\n } else { at -= sz; }\n }\n // If the result is smaller than 25 lines, ensure that it is a\n // single leaf node.\n if (this.size - n < 25 &&\n (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {\n var lines = [];\n this.collapse(lines);\n this.children = [new LeafChunk(lines)];\n this.children[0].parent = this;\n }\n },\n\n collapse: function(lines) {\n var this$1 = this;\n\n for (var i = 0; i < this.children.length; ++i) { this$1.children[i].collapse(lines); }\n },\n\n insertInner: function(at, lines, height) {\n var this$1 = this;\n\n this.size += lines.length;\n this.height += height;\n for (var i = 0; i < this.children.length; ++i) {\n var child = this$1.children[i], sz = child.chunkSize();\n if (at <= sz) {\n child.insertInner(at, lines, height);\n if (child.lines && child.lines.length > 50) {\n // To avoid memory thrashing when child.lines is huge (e.g. first view of a large file), it's never spliced.\n // Instead, small slices are taken. They're taken in order because sequential memory accesses are fastest.\n var remaining = child.lines.length % 25 + 25;\n for (var pos = remaining; pos < child.lines.length;) {\n var leaf = new LeafChunk(child.lines.slice(pos, pos += 25));\n child.height -= leaf.height;\n this$1.children.splice(++i, 0, leaf);\n leaf.parent = this$1;\n }\n child.lines = child.lines.slice(0, remaining);\n this$1.maybeSpill();\n }\n break\n }\n at -= sz;\n }\n },\n\n // When a node has grown, check whether it should be split.\n maybeSpill: function() {\n if (this.children.length <= 10) { return }\n var me = this;\n do {\n var spilled = me.children.splice(me.children.length - 5, 5);\n var sibling = new BranchChunk(spilled);\n if (!me.parent) { // Become the parent node\n var copy = new BranchChunk(me.children);\n copy.parent = me;\n me.children = [copy, sibling];\n me = copy;\n } else {\n me.size -= sibling.size;\n me.height -= sibling.height;\n var myIndex = indexOf(me.parent.children, me);\n me.parent.children.splice(myIndex + 1, 0, sibling);\n }\n sibling.parent = me.parent;\n } while (me.children.length > 10)\n me.parent.maybeSpill();\n },\n\n iterN: function(at, n, op) {\n var this$1 = this;\n\n for (var i = 0; i < this.children.length; ++i) {\n var child = this$1.children[i], sz = child.chunkSize();\n if (at < sz) {\n var used = Math.min(n, sz - at);\n if (child.iterN(at, used, op)) { return true }\n if ((n -= used) == 0) { break }\n at = 0;\n } else { at -= sz; }\n }\n }\n };\n\n // Line widgets are block elements displayed above or below a line.\n\n var LineWidget = function(doc, node, options) {\n var this$1 = this;\n\n if (options) { for (var opt in options) { if (options.hasOwnProperty(opt))\n { this$1[opt] = options[opt]; } } }\n this.doc = doc;\n this.node = node;\n };\n\n LineWidget.prototype.clear = function () {\n var this$1 = this;\n\n var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line);\n if (no == null || !ws) { return }\n for (var i = 0; i < ws.length; ++i) { if (ws[i] == this$1) { ws.splice(i--, 1); } }\n if (!ws.length) { line.widgets = null; }\n var height = widgetHeight(this);\n updateLineHeight(line, Math.max(0, line.height - height));\n if (cm) {\n runInOp(cm, function () {\n adjustScrollWhenAboveVisible(cm, line, -height);\n regLineChange(cm, no, \"widget\");\n });\n signalLater(cm, \"lineWidgetCleared\", cm, this, no);\n }\n };\n\n LineWidget.prototype.changed = function () {\n var this$1 = this;\n\n var oldH = this.height, cm = this.doc.cm, line = this.line;\n this.height = null;\n var diff = widgetHeight(this) - oldH;\n if (!diff) { return }\n if (!lineIsHidden(this.doc, line)) { updateLineHeight(line, line.height + diff); }\n if (cm) {\n runInOp(cm, function () {\n cm.curOp.forceUpdate = true;\n adjustScrollWhenAboveVisible(cm, line, diff);\n signalLater(cm, \"lineWidgetChanged\", cm, this$1, lineNo(line));\n });\n }\n };\n eventMixin(LineWidget);\n\n function adjustScrollWhenAboveVisible(cm, line, diff) {\n if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))\n { addToScrollTop(cm, diff); }\n }\n\n function addLineWidget(doc, handle, node, options) {\n var widget = new LineWidget(doc, node, options);\n var cm = doc.cm;\n if (cm && widget.noHScroll) { cm.display.alignWidgets = true; }\n changeLine(doc, handle, \"widget\", function (line) {\n var widgets = line.widgets || (line.widgets = []);\n if (widget.insertAt == null) { widgets.push(widget); }\n else { widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget); }\n widget.line = line;\n if (cm && !lineIsHidden(doc, line)) {\n var aboveVisible = heightAtLine(line) < doc.scrollTop;\n updateLineHeight(line, line.height + widgetHeight(widget));\n if (aboveVisible) { addToScrollTop(cm, widget.height); }\n cm.curOp.forceUpdate = true;\n }\n return true\n });\n if (cm) { signalLater(cm, \"lineWidgetAdded\", cm, widget, typeof handle == \"number\" ? handle : lineNo(handle)); }\n return widget\n }\n\n // TEXTMARKERS\n\n // Created with markText and setBookmark methods. A TextMarker is a\n // handle that can be used to clear or find a marked position in the\n // document. Line objects hold arrays (markedSpans) containing\n // {from, to, marker} object pointing to such marker objects, and\n // indicating that such a marker is present on that line. Multiple\n // lines may point to the same marker when it spans across lines.\n // The spans will have null for their from/to properties when the\n // marker continues beyond the start/end of the line. Markers have\n // links back to the lines they currently touch.\n\n // Collapsed markers have unique ids, in order to be able to order\n // them, which is needed for uniquely determining an outer marker\n // when they overlap (they may nest, but not partially overlap).\n var nextMarkerId = 0;\n\n var TextMarker = function(doc, type) {\n this.lines = [];\n this.type = type;\n this.doc = doc;\n this.id = ++nextMarkerId;\n };\n\n // Clear the marker.\n TextMarker.prototype.clear = function () {\n var this$1 = this;\n\n if (this.explicitlyCleared) { return }\n var cm = this.doc.cm, withOp = cm && !cm.curOp;\n if (withOp) { startOperation(cm); }\n if (hasHandler(this, \"clear\")) {\n var found = this.find();\n if (found) { signalLater(this, \"clear\", found.from, found.to); }\n }\n var min = null, max = null;\n for (var i = 0; i < this.lines.length; ++i) {\n var line = this$1.lines[i];\n var span = getMarkedSpanFor(line.markedSpans, this$1);\n if (cm && !this$1.collapsed) { regLineChange(cm, lineNo(line), \"text\"); }\n else if (cm) {\n if (span.to != null) { max = lineNo(line); }\n if (span.from != null) { min = lineNo(line); }\n }\n line.markedSpans = removeMarkedSpan(line.markedSpans, span);\n if (span.from == null && this$1.collapsed && !lineIsHidden(this$1.doc, line) && cm)\n { updateLineHeight(line, textHeight(cm.display)); }\n }\n if (cm && this.collapsed && !cm.options.lineWrapping) { for (var i$1 = 0; i$1 < this.lines.length; ++i$1) {\n var visual = visualLine(this$1.lines[i$1]), len = lineLength(visual);\n if (len > cm.display.maxLineLength) {\n cm.display.maxLine = visual;\n cm.display.maxLineLength = len;\n cm.display.maxLineChanged = true;\n }\n } }\n\n if (min != null && cm && this.collapsed) { regChange(cm, min, max + 1); }\n this.lines.length = 0;\n this.explicitlyCleared = true;\n if (this.atomic && this.doc.cantEdit) {\n this.doc.cantEdit = false;\n if (cm) { reCheckSelection(cm.doc); }\n }\n if (cm) { signalLater(cm, \"markerCleared\", cm, this, min, max); }\n if (withOp) { endOperation(cm); }\n if (this.parent) { this.parent.clear(); }\n };\n\n // Find the position of the marker in the document. Returns a {from,\n // to} object by default. Side can be passed to get a specific side\n // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the\n // Pos objects returned contain a line object, rather than a line\n // number (used to prevent looking up the same line twice).\n TextMarker.prototype.find = function (side, lineObj) {\n var this$1 = this;\n\n if (side == null && this.type == \"bookmark\") { side = 1; }\n var from, to;\n for (var i = 0; i < this.lines.length; ++i) {\n var line = this$1.lines[i];\n var span = getMarkedSpanFor(line.markedSpans, this$1);\n if (span.from != null) {\n from = Pos(lineObj ? line : lineNo(line), span.from);\n if (side == -1) { return from }\n }\n if (span.to != null) {\n to = Pos(lineObj ? line : lineNo(line), span.to);\n if (side == 1) { return to }\n }\n }\n return from && {from: from, to: to}\n };\n\n // Signals that the marker's widget changed, and surrounding layout\n // should be recomputed.\n TextMarker.prototype.changed = function () {\n var this$1 = this;\n\n var pos = this.find(-1, true), widget = this, cm = this.doc.cm;\n if (!pos || !cm) { return }\n runInOp(cm, function () {\n var line = pos.line, lineN = lineNo(pos.line);\n var view = findViewForLine(cm, lineN);\n if (view) {\n clearLineMeasurementCacheFor(view);\n cm.curOp.selectionChanged = cm.curOp.forceUpdate = true;\n }\n cm.curOp.updateMaxLine = true;\n if (!lineIsHidden(widget.doc, line) && widget.height != null) {\n var oldHeight = widget.height;\n widget.height = null;\n var dHeight = widgetHeight(widget) - oldHeight;\n if (dHeight)\n { updateLineHeight(line, line.height + dHeight); }\n }\n signalLater(cm, \"markerChanged\", cm, this$1);\n });\n };\n\n TextMarker.prototype.attachLine = function (line) {\n if (!this.lines.length && this.doc.cm) {\n var op = this.doc.cm.curOp;\n if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1)\n { (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this); }\n }\n this.lines.push(line);\n };\n\n TextMarker.prototype.detachLine = function (line) {\n this.lines.splice(indexOf(this.lines, line), 1);\n if (!this.lines.length && this.doc.cm) {\n var op = this.doc.cm.curOp\n ;(op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this);\n }\n };\n eventMixin(TextMarker);\n\n // Create a marker, wire it up to the right lines, and\n function markText(doc, from, to, options, type) {\n // Shared markers (across linked documents) are handled separately\n // (markTextShared will call out to this again, once per\n // document).\n if (options && options.shared) { return markTextShared(doc, from, to, options, type) }\n // Ensure we are in an operation.\n if (doc.cm && !doc.cm.curOp) { return operation(doc.cm, markText)(doc, from, to, options, type) }\n\n var marker = new TextMarker(doc, type), diff = cmp(from, to);\n if (options) { copyObj(options, marker, false); }\n // Don't connect empty markers unless clearWhenEmpty is false\n if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false)\n { return marker }\n if (marker.replacedWith) {\n // Showing up as a widget implies collapsed (widget replaces text)\n marker.collapsed = true;\n marker.widgetNode = eltP(\"span\", [marker.replacedWith], \"CodeMirror-widget\");\n if (!options.handleMouseEvents) { marker.widgetNode.setAttribute(\"cm-ignore-events\", \"true\"); }\n if (options.insertLeft) { marker.widgetNode.insertLeft = true; }\n }\n if (marker.collapsed) {\n if (conflictingCollapsedRange(doc, from.line, from, to, marker) ||\n from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker))\n { throw new Error(\"Inserting collapsed marker partially overlapping an existing one\") }\n seeCollapsedSpans();\n }\n\n if (marker.addToHistory)\n { addChangeToHistory(doc, {from: from, to: to, origin: \"markText\"}, doc.sel, NaN); }\n\n var curLine = from.line, cm = doc.cm, updateMaxLine;\n doc.iter(curLine, to.line + 1, function (line) {\n if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine)\n { updateMaxLine = true; }\n if (marker.collapsed && curLine != from.line) { updateLineHeight(line, 0); }\n addMarkedSpan(line, new MarkedSpan(marker,\n curLine == from.line ? from.ch : null,\n curLine == to.line ? to.ch : null));\n ++curLine;\n });\n // lineIsHidden depends on the presence of the spans, so needs a second pass\n if (marker.collapsed) { doc.iter(from.line, to.line + 1, function (line) {\n if (lineIsHidden(doc, line)) { updateLineHeight(line, 0); }\n }); }\n\n if (marker.clearOnEnter) { on(marker, \"beforeCursorEnter\", function () { return marker.clear(); }); }\n\n if (marker.readOnly) {\n seeReadOnlySpans();\n if (doc.history.done.length || doc.history.undone.length)\n { doc.clearHistory(); }\n }\n if (marker.collapsed) {\n marker.id = ++nextMarkerId;\n marker.atomic = true;\n }\n if (cm) {\n // Sync editor state\n if (updateMaxLine) { cm.curOp.updateMaxLine = true; }\n if (marker.collapsed)\n { regChange(cm, from.line, to.line + 1); }\n else if (marker.className || marker.startStyle || marker.endStyle || marker.css ||\n marker.attributes || marker.title)\n { for (var i = from.line; i <= to.line; i++) { regLineChange(cm, i, \"text\"); } }\n if (marker.atomic) { reCheckSelection(cm.doc); }\n signalLater(cm, \"markerAdded\", cm, marker);\n }\n return marker\n }\n\n // SHARED TEXTMARKERS\n\n // A shared marker spans multiple linked documents. It is\n // implemented as a meta-marker-object controlling multiple normal\n // markers.\n var SharedTextMarker = function(markers, primary) {\n var this$1 = this;\n\n this.markers = markers;\n this.primary = primary;\n for (var i = 0; i < markers.length; ++i)\n { markers[i].parent = this$1; }\n };\n\n SharedTextMarker.prototype.clear = function () {\n var this$1 = this;\n\n if (this.explicitlyCleared) { return }\n this.explicitlyCleared = true;\n for (var i = 0; i < this.markers.length; ++i)\n { this$1.markers[i].clear(); }\n signalLater(this, \"clear\");\n };\n\n SharedTextMarker.prototype.find = function (side, lineObj) {\n return this.primary.find(side, lineObj)\n };\n eventMixin(SharedTextMarker);\n\n function markTextShared(doc, from, to, options, type) {\n options = copyObj(options);\n options.shared = false;\n var markers = [markText(doc, from, to, options, type)], primary = markers[0];\n var widget = options.widgetNode;\n linkedDocs(doc, function (doc) {\n if (widget) { options.widgetNode = widget.cloneNode(true); }\n markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type));\n for (var i = 0; i < doc.linked.length; ++i)\n { if (doc.linked[i].isParent) { return } }\n primary = lst(markers);\n });\n return new SharedTextMarker(markers, primary)\n }\n\n function findSharedMarkers(doc) {\n return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())), function (m) { return m.parent; })\n }\n\n function copySharedMarkers(doc, markers) {\n for (var i = 0; i < markers.length; i++) {\n var marker = markers[i], pos = marker.find();\n var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to);\n if (cmp(mFrom, mTo)) {\n var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type);\n marker.markers.push(subMark);\n subMark.parent = marker;\n }\n }\n }\n\n function detachSharedMarkers(markers) {\n var loop = function ( i ) {\n var marker = markers[i], linked = [marker.primary.doc];\n linkedDocs(marker.primary.doc, function (d) { return linked.push(d); });\n for (var j = 0; j < marker.markers.length; j++) {\n var subMarker = marker.markers[j];\n if (indexOf(linked, subMarker.doc) == -1) {\n subMarker.parent = null;\n marker.markers.splice(j--, 1);\n }\n }\n };\n\n for (var i = 0; i < markers.length; i++) loop( i );\n }\n\n var nextDocId = 0;\n var Doc = function(text, mode, firstLine, lineSep, direction) {\n if (!(this instanceof Doc)) { return new Doc(text, mode, firstLine, lineSep, direction) }\n if (firstLine == null) { firstLine = 0; }\n\n BranchChunk.call(this, [new LeafChunk([new Line(\"\", null)])]);\n this.first = firstLine;\n this.scrollTop = this.scrollLeft = 0;\n this.cantEdit = false;\n this.cleanGeneration = 1;\n this.modeFrontier = this.highlightFrontier = firstLine;\n var start = Pos(firstLine, 0);\n this.sel = simpleSelection(start);\n this.history = new History(null);\n this.id = ++nextDocId;\n this.modeOption = mode;\n this.lineSep = lineSep;\n this.direction = (direction == \"rtl\") ? \"rtl\" : \"ltr\";\n this.extend = false;\n\n if (typeof text == \"string\") { text = this.splitLines(text); }\n updateDoc(this, {from: start, to: start, text: text});\n setSelection(this, simpleSelection(start), sel_dontScroll);\n };\n\n Doc.prototype = createObj(BranchChunk.prototype, {\n constructor: Doc,\n // Iterate over the document. Supports two forms -- with only one\n // argument, it calls that for each line in the document. With\n // three, it iterates over the range given by the first two (with\n // the second being non-inclusive).\n iter: function(from, to, op) {\n if (op) { this.iterN(from - this.first, to - from, op); }\n else { this.iterN(this.first, this.first + this.size, from); }\n },\n\n // Non-public interface for adding and removing lines.\n insert: function(at, lines) {\n var height = 0;\n for (var i = 0; i < lines.length; ++i) { height += lines[i].height; }\n this.insertInner(at - this.first, lines, height);\n },\n remove: function(at, n) { this.removeInner(at - this.first, n); },\n\n // From here, the methods are part of the public interface. Most\n // are also available from CodeMirror (editor) instances.\n\n getValue: function(lineSep) {\n var lines = getLines(this, this.first, this.first + this.size);\n if (lineSep === false) { return lines }\n return lines.join(lineSep || this.lineSeparator())\n },\n setValue: docMethodOp(function(code) {\n var top = Pos(this.first, 0), last = this.first + this.size - 1;\n makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),\n text: this.splitLines(code), origin: \"setValue\", full: true}, true);\n if (this.cm) { scrollToCoords(this.cm, 0, 0); }\n setSelection(this, simpleSelection(top), sel_dontScroll);\n }),\n replaceRange: function(code, from, to, origin) {\n from = clipPos(this, from);\n to = to ? clipPos(this, to) : from;\n replaceRange(this, code, from, to, origin);\n },\n getRange: function(from, to, lineSep) {\n var lines = getBetween(this, clipPos(this, from), clipPos(this, to));\n if (lineSep === false) { return lines }\n return lines.join(lineSep || this.lineSeparator())\n },\n\n getLine: function(line) {var l = this.getLineHandle(line); return l && l.text},\n\n getLineHandle: function(line) {if (isLine(this, line)) { return getLine(this, line) }},\n getLineNumber: function(line) {return lineNo(line)},\n\n getLineHandleVisualStart: function(line) {\n if (typeof line == \"number\") { line = getLine(this, line); }\n return visualLine(line)\n },\n\n lineCount: function() {return this.size},\n firstLine: function() {return this.first},\n lastLine: function() {return this.first + this.size - 1},\n\n clipPos: function(pos) {return clipPos(this, pos)},\n\n getCursor: function(start) {\n var range$$1 = this.sel.primary(), pos;\n if (start == null || start == \"head\") { pos = range$$1.head; }\n else if (start == \"anchor\") { pos = range$$1.anchor; }\n else if (start == \"end\" || start == \"to\" || start === false) { pos = range$$1.to(); }\n else { pos = range$$1.from(); }\n return pos\n },\n listSelections: function() { return this.sel.ranges },\n somethingSelected: function() {return this.sel.somethingSelected()},\n\n setCursor: docMethodOp(function(line, ch, options) {\n setSimpleSelection(this, clipPos(this, typeof line == \"number\" ? Pos(line, ch || 0) : line), null, options);\n }),\n setSelection: docMethodOp(function(anchor, head, options) {\n setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options);\n }),\n extendSelection: docMethodOp(function(head, other, options) {\n extendSelection(this, clipPos(this, head), other && clipPos(this, other), options);\n }),\n extendSelections: docMethodOp(function(heads, options) {\n extendSelections(this, clipPosArray(this, heads), options);\n }),\n extendSelectionsBy: docMethodOp(function(f, options) {\n var heads = map(this.sel.ranges, f);\n extendSelections(this, clipPosArray(this, heads), options);\n }),\n setSelections: docMethodOp(function(ranges, primary, options) {\n var this$1 = this;\n\n if (!ranges.length) { return }\n var out = [];\n for (var i = 0; i < ranges.length; i++)\n { out[i] = new Range(clipPos(this$1, ranges[i].anchor),\n clipPos(this$1, ranges[i].head)); }\n if (primary == null) { primary = Math.min(ranges.length - 1, this.sel.primIndex); }\n setSelection(this, normalizeSelection(this.cm, out, primary), options);\n }),\n addSelection: docMethodOp(function(anchor, head, options) {\n var ranges = this.sel.ranges.slice(0);\n ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor)));\n setSelection(this, normalizeSelection(this.cm, ranges, ranges.length - 1), options);\n }),\n\n getSelection: function(lineSep) {\n var this$1 = this;\n\n var ranges = this.sel.ranges, lines;\n for (var i = 0; i < ranges.length; i++) {\n var sel = getBetween(this$1, ranges[i].from(), ranges[i].to());\n lines = lines ? lines.concat(sel) : sel;\n }\n if (lineSep === false) { return lines }\n else { return lines.join(lineSep || this.lineSeparator()) }\n },\n getSelections: function(lineSep) {\n var this$1 = this;\n\n var parts = [], ranges = this.sel.ranges;\n for (var i = 0; i < ranges.length; i++) {\n var sel = getBetween(this$1, ranges[i].from(), ranges[i].to());\n if (lineSep !== false) { sel = sel.join(lineSep || this$1.lineSeparator()); }\n parts[i] = sel;\n }\n return parts\n },\n replaceSelection: function(code, collapse, origin) {\n var dup = [];\n for (var i = 0; i < this.sel.ranges.length; i++)\n { dup[i] = code; }\n this.replaceSelections(dup, collapse, origin || \"+input\");\n },\n replaceSelections: docMethodOp(function(code, collapse, origin) {\n var this$1 = this;\n\n var changes = [], sel = this.sel;\n for (var i = 0; i < sel.ranges.length; i++) {\n var range$$1 = sel.ranges[i];\n changes[i] = {from: range$$1.from(), to: range$$1.to(), text: this$1.splitLines(code[i]), origin: origin};\n }\n var newSel = collapse && collapse != \"end\" && computeReplacedSel(this, changes, collapse);\n for (var i$1 = changes.length - 1; i$1 >= 0; i$1--)\n { makeChange(this$1, changes[i$1]); }\n if (newSel) { setSelectionReplaceHistory(this, newSel); }\n else if (this.cm) { ensureCursorVisible(this.cm); }\n }),\n undo: docMethodOp(function() {makeChangeFromHistory(this, \"undo\");}),\n redo: docMethodOp(function() {makeChangeFromHistory(this, \"redo\");}),\n undoSelection: docMethodOp(function() {makeChangeFromHistory(this, \"undo\", true);}),\n redoSelection: docMethodOp(function() {makeChangeFromHistory(this, \"redo\", true);}),\n\n setExtending: function(val) {this.extend = val;},\n getExtending: function() {return this.extend},\n\n historySize: function() {\n var hist = this.history, done = 0, undone = 0;\n for (var i = 0; i < hist.done.length; i++) { if (!hist.done[i].ranges) { ++done; } }\n for (var i$1 = 0; i$1 < hist.undone.length; i$1++) { if (!hist.undone[i$1].ranges) { ++undone; } }\n return {undo: done, redo: undone}\n },\n clearHistory: function() {this.history = new History(this.history.maxGeneration);},\n\n markClean: function() {\n this.cleanGeneration = this.changeGeneration(true);\n },\n changeGeneration: function(forceSplit) {\n if (forceSplit)\n { this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null; }\n return this.history.generation\n },\n isClean: function (gen) {\n return this.history.generation == (gen || this.cleanGeneration)\n },\n\n getHistory: function() {\n return {done: copyHistoryArray(this.history.done),\n undone: copyHistoryArray(this.history.undone)}\n },\n setHistory: function(histData) {\n var hist = this.history = new History(this.history.maxGeneration);\n hist.done = copyHistoryArray(histData.done.slice(0), null, true);\n hist.undone = copyHistoryArray(histData.undone.slice(0), null, true);\n },\n\n setGutterMarker: docMethodOp(function(line, gutterID, value) {\n return changeLine(this, line, \"gutter\", function (line) {\n var markers = line.gutterMarkers || (line.gutterMarkers = {});\n markers[gutterID] = value;\n if (!value && isEmpty(markers)) { line.gutterMarkers = null; }\n return true\n })\n }),\n\n clearGutter: docMethodOp(function(gutterID) {\n var this$1 = this;\n\n this.iter(function (line) {\n if (line.gutterMarkers && line.gutterMarkers[gutterID]) {\n changeLine(this$1, line, \"gutter\", function () {\n line.gutterMarkers[gutterID] = null;\n if (isEmpty(line.gutterMarkers)) { line.gutterMarkers = null; }\n return true\n });\n }\n });\n }),\n\n lineInfo: function(line) {\n var n;\n if (typeof line == \"number\") {\n if (!isLine(this, line)) { return null }\n n = line;\n line = getLine(this, line);\n if (!line) { return null }\n } else {\n n = lineNo(line);\n if (n == null) { return null }\n }\n return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers,\n textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass,\n widgets: line.widgets}\n },\n\n addLineClass: docMethodOp(function(handle, where, cls) {\n return changeLine(this, handle, where == \"gutter\" ? \"gutter\" : \"class\", function (line) {\n var prop = where == \"text\" ? \"textClass\"\n : where == \"background\" ? \"bgClass\"\n : where == \"gutter\" ? \"gutterClass\" : \"wrapClass\";\n if (!line[prop]) { line[prop] = cls; }\n else if (classTest(cls).test(line[prop])) { return false }\n else { line[prop] += \" \" + cls; }\n return true\n })\n }),\n removeLineClass: docMethodOp(function(handle, where, cls) {\n return changeLine(this, handle, where == \"gutter\" ? \"gutter\" : \"class\", function (line) {\n var prop = where == \"text\" ? \"textClass\"\n : where == \"background\" ? \"bgClass\"\n : where == \"gutter\" ? \"gutterClass\" : \"wrapClass\";\n var cur = line[prop];\n if (!cur) { return false }\n else if (cls == null) { line[prop] = null; }\n else {\n var found = cur.match(classTest(cls));\n if (!found) { return false }\n var end = found.index + found[0].length;\n line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? \"\" : \" \") + cur.slice(end) || null;\n }\n return true\n })\n }),\n\n addLineWidget: docMethodOp(function(handle, node, options) {\n return addLineWidget(this, handle, node, options)\n }),\n removeLineWidget: function(widget) { widget.clear(); },\n\n markText: function(from, to, options) {\n return markText(this, clipPos(this, from), clipPos(this, to), options, options && options.type || \"range\")\n },\n setBookmark: function(pos, options) {\n var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),\n insertLeft: options && options.insertLeft,\n clearWhenEmpty: false, shared: options && options.shared,\n handleMouseEvents: options && options.handleMouseEvents};\n pos = clipPos(this, pos);\n return markText(this, pos, pos, realOpts, \"bookmark\")\n },\n findMarksAt: function(pos) {\n pos = clipPos(this, pos);\n var markers = [], spans = getLine(this, pos.line).markedSpans;\n if (spans) { for (var i = 0; i < spans.length; ++i) {\n var span = spans[i];\n if ((span.from == null || span.from <= pos.ch) &&\n (span.to == null || span.to >= pos.ch))\n { markers.push(span.marker.parent || span.marker); }\n } }\n return markers\n },\n findMarks: function(from, to, filter) {\n from = clipPos(this, from); to = clipPos(this, to);\n var found = [], lineNo$$1 = from.line;\n this.iter(from.line, to.line + 1, function (line) {\n var spans = line.markedSpans;\n if (spans) { for (var i = 0; i < spans.length; i++) {\n var span = spans[i];\n if (!(span.to != null && lineNo$$1 == from.line && from.ch >= span.to ||\n span.from == null && lineNo$$1 != from.line ||\n span.from != null && lineNo$$1 == to.line && span.from >= to.ch) &&\n (!filter || filter(span.marker)))\n { found.push(span.marker.parent || span.marker); }\n } }\n ++lineNo$$1;\n });\n return found\n },\n getAllMarks: function() {\n var markers = [];\n this.iter(function (line) {\n var sps = line.markedSpans;\n if (sps) { for (var i = 0; i < sps.length; ++i)\n { if (sps[i].from != null) { markers.push(sps[i].marker); } } }\n });\n return markers\n },\n\n posFromIndex: function(off) {\n var ch, lineNo$$1 = this.first, sepSize = this.lineSeparator().length;\n this.iter(function (line) {\n var sz = line.text.length + sepSize;\n if (sz > off) { ch = off; return true }\n off -= sz;\n ++lineNo$$1;\n });\n return clipPos(this, Pos(lineNo$$1, ch))\n },\n indexFromPos: function (coords) {\n coords = clipPos(this, coords);\n var index = coords.ch;\n if (coords.line < this.first || coords.ch < 0) { return 0 }\n var sepSize = this.lineSeparator().length;\n this.iter(this.first, coords.line, function (line) { // iter aborts when callback returns a truthy value\n index += line.text.length + sepSize;\n });\n return index\n },\n\n copy: function(copyHistory) {\n var doc = new Doc(getLines(this, this.first, this.first + this.size),\n this.modeOption, this.first, this.lineSep, this.direction);\n doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft;\n doc.sel = this.sel;\n doc.extend = false;\n if (copyHistory) {\n doc.history.undoDepth = this.history.undoDepth;\n doc.setHistory(this.getHistory());\n }\n return doc\n },\n\n linkedDoc: function(options) {\n if (!options) { options = {}; }\n var from = this.first, to = this.first + this.size;\n if (options.from != null && options.from > from) { from = options.from; }\n if (options.to != null && options.to < to) { to = options.to; }\n var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep, this.direction);\n if (options.sharedHist) { copy.history = this.history\n ; }(this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist});\n copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}];\n copySharedMarkers(copy, findSharedMarkers(this));\n return copy\n },\n unlinkDoc: function(other) {\n var this$1 = this;\n\n if (other instanceof CodeMirror) { other = other.doc; }\n if (this.linked) { for (var i = 0; i < this.linked.length; ++i) {\n var link = this$1.linked[i];\n if (link.doc != other) { continue }\n this$1.linked.splice(i, 1);\n other.unlinkDoc(this$1);\n detachSharedMarkers(findSharedMarkers(this$1));\n break\n } }\n // If the histories were shared, split them again\n if (other.history == this.history) {\n var splitIds = [other.id];\n linkedDocs(other, function (doc) { return splitIds.push(doc.id); }, true);\n other.history = new History(null);\n other.history.done = copyHistoryArray(this.history.done, splitIds);\n other.history.undone = copyHistoryArray(this.history.undone, splitIds);\n }\n },\n iterLinkedDocs: function(f) {linkedDocs(this, f);},\n\n getMode: function() {return this.mode},\n getEditor: function() {return this.cm},\n\n splitLines: function(str) {\n if (this.lineSep) { return str.split(this.lineSep) }\n return splitLinesAuto(str)\n },\n lineSeparator: function() { return this.lineSep || \"\\n\" },\n\n setDirection: docMethodOp(function (dir) {\n if (dir != \"rtl\") { dir = \"ltr\"; }\n if (dir == this.direction) { return }\n this.direction = dir;\n this.iter(function (line) { return line.order = null; });\n if (this.cm) { directionChanged(this.cm); }\n })\n });\n\n // Public alias.\n Doc.prototype.eachLine = Doc.prototype.iter;\n\n // Kludge to work around strange IE behavior where it'll sometimes\n // re-fire a series of drag-related events right after the drop (#1551)\n var lastDrop = 0;\n\n function onDrop(e) {\n var cm = this;\n clearDragCursor(cm);\n if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))\n { return }\n e_preventDefault(e);\n if (ie) { lastDrop = +new Date; }\n var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;\n if (!pos || cm.isReadOnly()) { return }\n // Might be a file drop, in which case we simply extract the text\n // and insert it.\n if (files && files.length && window.FileReader && window.File) {\n var n = files.length, text = Array(n), read = 0;\n var loadFile = function (file, i) {\n if (cm.options.allowDropFileTypes &&\n indexOf(cm.options.allowDropFileTypes, file.type) == -1)\n { return }\n\n var reader = new FileReader;\n reader.onload = operation(cm, function () {\n var content = reader.result;\n if (/[\\x00-\\x08\\x0e-\\x1f]{2}/.test(content)) { content = \"\"; }\n text[i] = content;\n if (++read == n) {\n pos = clipPos(cm.doc, pos);\n var change = {from: pos, to: pos,\n text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())),\n origin: \"paste\"};\n makeChange(cm.doc, change);\n setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));\n }\n });\n reader.readAsText(file);\n };\n for (var i = 0; i < n; ++i) { loadFile(files[i], i); }\n } else { // Normal drop\n // Don't do a replace if the drop happened inside of the selected text.\n if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {\n cm.state.draggingText(e);\n // Ensure the editor is re-focused\n setTimeout(function () { return cm.display.input.focus(); }, 20);\n return\n }\n try {\n var text$1 = e.dataTransfer.getData(\"Text\");\n if (text$1) {\n var selected;\n if (cm.state.draggingText && !cm.state.draggingText.copy)\n { selected = cm.listSelections(); }\n setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));\n if (selected) { for (var i$1 = 0; i$1 < selected.length; ++i$1)\n { replaceRange(cm.doc, \"\", selected[i$1].anchor, selected[i$1].head, \"drag\"); } }\n cm.replaceSelection(text$1, \"around\", \"paste\");\n cm.display.input.focus();\n }\n }\n catch(e){}\n }\n }\n\n function onDragStart(cm, e) {\n if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return }\n if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) { return }\n\n e.dataTransfer.setData(\"Text\", cm.getSelection());\n e.dataTransfer.effectAllowed = \"copyMove\";\n\n // Use dummy image instead of default browsers image.\n // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.\n if (e.dataTransfer.setDragImage && !safari) {\n var img = elt(\"img\", null, null, \"position: fixed; left: 0; top: 0;\");\n img.src = \"data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\";\n if (presto) {\n img.width = img.height = 1;\n cm.display.wrapper.appendChild(img);\n // Force a relayout, or Opera won't use our image for some obscure reason\n img._top = img.offsetTop;\n }\n e.dataTransfer.setDragImage(img, 0, 0);\n if (presto) { img.parentNode.removeChild(img); }\n }\n }\n\n function onDragOver(cm, e) {\n var pos = posFromMouse(cm, e);\n if (!pos) { return }\n var frag = document.createDocumentFragment();\n drawSelectionCursor(cm, pos, frag);\n if (!cm.display.dragCursor) {\n cm.display.dragCursor = elt(\"div\", null, \"CodeMirror-cursors CodeMirror-dragcursors\");\n cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv);\n }\n removeChildrenAndAdd(cm.display.dragCursor, frag);\n }\n\n function clearDragCursor(cm) {\n if (cm.display.dragCursor) {\n cm.display.lineSpace.removeChild(cm.display.dragCursor);\n cm.display.dragCursor = null;\n }\n }\n\n // These must be handled carefully, because naively registering a\n // handler for each editor will cause the editors to never be\n // garbage collected.\n\n function forEachCodeMirror(f) {\n if (!document.getElementsByClassName) { return }\n var byClass = document.getElementsByClassName(\"CodeMirror\"), editors = [];\n for (var i = 0; i < byClass.length; i++) {\n var cm = byClass[i].CodeMirror;\n if (cm) { editors.push(cm); }\n }\n if (editors.length) { editors[0].operation(function () {\n for (var i = 0; i < editors.length; i++) { f(editors[i]); }\n }); }\n }\n\n var globalsRegistered = false;\n function ensureGlobalHandlers() {\n if (globalsRegistered) { return }\n registerGlobalHandlers();\n globalsRegistered = true;\n }\n function registerGlobalHandlers() {\n // When the window resizes, we need to refresh active editors.\n var resizeTimer;\n on(window, \"resize\", function () {\n if (resizeTimer == null) { resizeTimer = setTimeout(function () {\n resizeTimer = null;\n forEachCodeMirror(onResize);\n }, 100); }\n });\n // When the window loses focus, we want to show the editor as blurred\n on(window, \"blur\", function () { return forEachCodeMirror(onBlur); });\n }\n // Called when the window resizes\n function onResize(cm) {\n var d = cm.display;\n // Might be a text scaling operation, clear size caches.\n d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;\n d.scrollbarsClipped = false;\n cm.setSize();\n }\n\n var keyNames = {\n 3: \"Pause\", 8: \"Backspace\", 9: \"Tab\", 13: \"Enter\", 16: \"Shift\", 17: \"Ctrl\", 18: \"Alt\",\n 19: \"Pause\", 20: \"CapsLock\", 27: \"Esc\", 32: \"Space\", 33: \"PageUp\", 34: \"PageDown\", 35: \"End\",\n 36: \"Home\", 37: \"Left\", 38: \"Up\", 39: \"Right\", 40: \"Down\", 44: \"PrintScrn\", 45: \"Insert\",\n 46: \"Delete\", 59: \";\", 61: \"=\", 91: \"Mod\", 92: \"Mod\", 93: \"Mod\",\n 106: \"*\", 107: \"=\", 109: \"-\", 110: \".\", 111: \"/\", 145: \"ScrollLock\",\n 173: \"-\", 186: \";\", 187: \"=\", 188: \",\", 189: \"-\", 190: \".\", 191: \"/\", 192: \"`\", 219: \"[\", 220: \"\\\\\",\n 221: \"]\", 222: \"'\", 63232: \"Up\", 63233: \"Down\", 63234: \"Left\", 63235: \"Right\", 63272: \"Delete\",\n 63273: \"Home\", 63275: \"End\", 63276: \"PageUp\", 63277: \"PageDown\", 63302: \"Insert\"\n };\n\n // Number keys\n for (var i = 0; i < 10; i++) { keyNames[i + 48] = keyNames[i + 96] = String(i); }\n // Alphabetic keys\n for (var i$1 = 65; i$1 <= 90; i$1++) { keyNames[i$1] = String.fromCharCode(i$1); }\n // Function keys\n for (var i$2 = 1; i$2 <= 12; i$2++) { keyNames[i$2 + 111] = keyNames[i$2 + 63235] = \"F\" + i$2; }\n\n var keyMap = {};\n\n keyMap.basic = {\n \"Left\": \"goCharLeft\", \"Right\": \"goCharRight\", \"Up\": \"goLineUp\", \"Down\": \"goLineDown\",\n \"End\": \"goLineEnd\", \"Home\": \"goLineStartSmart\", \"PageUp\": \"goPageUp\", \"PageDown\": \"goPageDown\",\n \"Delete\": \"delCharAfter\", \"Backspace\": \"delCharBefore\", \"Shift-Backspace\": \"delCharBefore\",\n \"Tab\": \"defaultTab\", \"Shift-Tab\": \"indentAuto\",\n \"Enter\": \"newlineAndIndent\", \"Insert\": \"toggleOverwrite\",\n \"Esc\": \"singleSelection\"\n };\n // Note that the save and find-related commands aren't defined by\n // default. User code or addons can define them. Unknown commands\n // are simply ignored.\n keyMap.pcDefault = {\n \"Ctrl-A\": \"selectAll\", \"Ctrl-D\": \"deleteLine\", \"Ctrl-Z\": \"undo\", \"Shift-Ctrl-Z\": \"redo\", \"Ctrl-Y\": \"redo\",\n \"Ctrl-Home\": \"goDocStart\", \"Ctrl-End\": \"goDocEnd\", \"Ctrl-Up\": \"goLineUp\", \"Ctrl-Down\": \"goLineDown\",\n \"Ctrl-Left\": \"goGroupLeft\", \"Ctrl-Right\": \"goGroupRight\", \"Alt-Left\": \"goLineStart\", \"Alt-Right\": \"goLineEnd\",\n \"Ctrl-Backspace\": \"delGroupBefore\", \"Ctrl-Delete\": \"delGroupAfter\", \"Ctrl-S\": \"save\", \"Ctrl-F\": \"find\",\n \"Ctrl-G\": \"findNext\", \"Shift-Ctrl-G\": \"findPrev\", \"Shift-Ctrl-F\": \"replace\", \"Shift-Ctrl-R\": \"replaceAll\",\n \"Ctrl-[\": \"indentLess\", \"Ctrl-]\": \"indentMore\",\n \"Ctrl-U\": \"undoSelection\", \"Shift-Ctrl-U\": \"redoSelection\", \"Alt-U\": \"redoSelection\",\n \"fallthrough\": \"basic\"\n };\n // Very basic readline/emacs-style bindings, which are standard on Mac.\n keyMap.emacsy = {\n \"Ctrl-F\": \"goCharRight\", \"Ctrl-B\": \"goCharLeft\", \"Ctrl-P\": \"goLineUp\", \"Ctrl-N\": \"goLineDown\",\n \"Alt-F\": \"goWordRight\", \"Alt-B\": \"goWordLeft\", \"Ctrl-A\": \"goLineStart\", \"Ctrl-E\": \"goLineEnd\",\n \"Ctrl-V\": \"goPageDown\", \"Shift-Ctrl-V\": \"goPageUp\", \"Ctrl-D\": \"delCharAfter\", \"Ctrl-H\": \"delCharBefore\",\n \"Alt-D\": \"delWordAfter\", \"Alt-Backspace\": \"delWordBefore\", \"Ctrl-K\": \"killLine\", \"Ctrl-T\": \"transposeChars\",\n \"Ctrl-O\": \"openLine\"\n };\n keyMap.macDefault = {\n \"Cmd-A\": \"selectAll\", \"Cmd-D\": \"deleteLine\", \"Cmd-Z\": \"undo\", \"Shift-Cmd-Z\": \"redo\", \"Cmd-Y\": \"redo\",\n \"Cmd-Home\": \"goDocStart\", \"Cmd-Up\": \"goDocStart\", \"Cmd-End\": \"goDocEnd\", \"Cmd-Down\": \"goDocEnd\", \"Alt-Left\": \"goGroupLeft\",\n \"Alt-Right\": \"goGroupRight\", \"Cmd-Left\": \"goLineLeft\", \"Cmd-Right\": \"goLineRight\", \"Alt-Backspace\": \"delGroupBefore\",\n \"Ctrl-Alt-Backspace\": \"delGroupAfter\", \"Alt-Delete\": \"delGroupAfter\", \"Cmd-S\": \"save\", \"Cmd-F\": \"find\",\n \"Cmd-G\": \"findNext\", \"Shift-Cmd-G\": \"findPrev\", \"Cmd-Alt-F\": \"replace\", \"Shift-Cmd-Alt-F\": \"replaceAll\",\n \"Cmd-[\": \"indentLess\", \"Cmd-]\": \"indentMore\", \"Cmd-Backspace\": \"delWrappedLineLeft\", \"Cmd-Delete\": \"delWrappedLineRight\",\n \"Cmd-U\": \"undoSelection\", \"Shift-Cmd-U\": \"redoSelection\", \"Ctrl-Up\": \"goDocStart\", \"Ctrl-Down\": \"goDocEnd\",\n \"fallthrough\": [\"basic\", \"emacsy\"]\n };\n keyMap[\"default\"] = mac ? keyMap.macDefault : keyMap.pcDefault;\n\n // KEYMAP DISPATCH\n\n function normalizeKeyName(name) {\n var parts = name.split(/-(?!$)/);\n name = parts[parts.length - 1];\n var alt, ctrl, shift, cmd;\n for (var i = 0; i < parts.length - 1; i++) {\n var mod = parts[i];\n if (/^(cmd|meta|m)$/i.test(mod)) { cmd = true; }\n else if (/^a(lt)?$/i.test(mod)) { alt = true; }\n else if (/^(c|ctrl|control)$/i.test(mod)) { ctrl = true; }\n else if (/^s(hift)?$/i.test(mod)) { shift = true; }\n else { throw new Error(\"Unrecognized modifier name: \" + mod) }\n }\n if (alt) { name = \"Alt-\" + name; }\n if (ctrl) { name = \"Ctrl-\" + name; }\n if (cmd) { name = \"Cmd-\" + name; }\n if (shift) { name = \"Shift-\" + name; }\n return name\n }\n\n // This is a kludge to keep keymaps mostly working as raw objects\n // (backwards compatibility) while at the same time support features\n // like normalization and multi-stroke key bindings. It compiles a\n // new normalized keymap, and then updates the old object to reflect\n // this.\n function normalizeKeyMap(keymap) {\n var copy = {};\n for (var keyname in keymap) { if (keymap.hasOwnProperty(keyname)) {\n var value = keymap[keyname];\n if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) { continue }\n if (value == \"...\") { delete keymap[keyname]; continue }\n\n var keys = map(keyname.split(\" \"), normalizeKeyName);\n for (var i = 0; i < keys.length; i++) {\n var val = (void 0), name = (void 0);\n if (i == keys.length - 1) {\n name = keys.join(\" \");\n val = value;\n } else {\n name = keys.slice(0, i + 1).join(\" \");\n val = \"...\";\n }\n var prev = copy[name];\n if (!prev) { copy[name] = val; }\n else if (prev != val) { throw new Error(\"Inconsistent bindings for \" + name) }\n }\n delete keymap[keyname];\n } }\n for (var prop in copy) { keymap[prop] = copy[prop]; }\n return keymap\n }\n\n function lookupKey(key, map$$1, handle, context) {\n map$$1 = getKeyMap(map$$1);\n var found = map$$1.call ? map$$1.call(key, context) : map$$1[key];\n if (found === false) { return \"nothing\" }\n if (found === \"...\") { return \"multi\" }\n if (found != null && handle(found)) { return \"handled\" }\n\n if (map$$1.fallthrough) {\n if (Object.prototype.toString.call(map$$1.fallthrough) != \"[object Array]\")\n { return lookupKey(key, map$$1.fallthrough, handle, context) }\n for (var i = 0; i < map$$1.fallthrough.length; i++) {\n var result = lookupKey(key, map$$1.fallthrough[i], handle, context);\n if (result) { return result }\n }\n }\n }\n\n // Modifier key presses don't count as 'real' key presses for the\n // purpose of keymap fallthrough.\n function isModifierKey(value) {\n var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n }\n\n function addModifierNames(name, event, noShift) {\n var base = name;\n if (event.altKey && base != \"Alt\") { name = \"Alt-\" + name; }\n if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != \"Ctrl\") { name = \"Ctrl-\" + name; }\n if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != \"Cmd\") { name = \"Cmd-\" + name; }\n if (!noShift && event.shiftKey && base != \"Shift\") { name = \"Shift-\" + name; }\n return name\n }\n\n // Look up the name of a key as indicated by an event object.\n function keyName(event, noShift) {\n if (presto && event.keyCode == 34 && event[\"char\"]) { return false }\n var name = keyNames[event.keyCode];\n if (name == null || event.altGraphKey) { return false }\n // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,\n // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)\n if (event.keyCode == 3 && event.code) { name = event.code; }\n return addModifierNames(name, event, noShift)\n }\n\n function getKeyMap(val) {\n return typeof val == \"string\" ? keyMap[val] : val\n }\n\n // Helper for deleting text near the selection(s), used to implement\n // backspace, delete, and similar functionality.\n function deleteNearSelection(cm, compute) {\n var ranges = cm.doc.sel.ranges, kill = [];\n // Build up a set of ranges to kill first, merging overlapping\n // ranges.\n for (var i = 0; i < ranges.length; i++) {\n var toKill = compute(ranges[i]);\n while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {\n var replaced = kill.pop();\n if (cmp(replaced.from, toKill.from) < 0) {\n toKill.from = replaced.from;\n break\n }\n }\n kill.push(toKill);\n }\n // Next, remove those actual ranges.\n runInOp(cm, function () {\n for (var i = kill.length - 1; i >= 0; i--)\n { replaceRange(cm.doc, \"\", kill[i].from, kill[i].to, \"+delete\"); }\n ensureCursorVisible(cm);\n });\n }\n\n function moveCharLogically(line, ch, dir) {\n var target = skipExtendingChars(line.text, ch + dir, dir);\n return target < 0 || target > line.text.length ? null : target\n }\n\n function moveLogically(line, start, dir) {\n var ch = moveCharLogically(line, start.ch, dir);\n return ch == null ? null : new Pos(start.line, ch, dir < 0 ? \"after\" : \"before\")\n }\n\n function endOfLine(visually, cm, lineObj, lineNo, dir) {\n if (visually) {\n var order = getOrder(lineObj, cm.doc.direction);\n if (order) {\n var part = dir < 0 ? lst(order) : order[0];\n var moveInStorageOrder = (dir < 0) == (part.level == 1);\n var sticky = moveInStorageOrder ? \"after\" : \"before\";\n var ch;\n // With a wrapped rtl chunk (possibly spanning multiple bidi parts),\n // it could be that the last bidi part is not on the last visual line,\n // since visual lines contain content order-consecutive chunks.\n // Thus, in rtl, we are looking for the first (content-order) character\n // in the rtl chunk that is on the last line (that is, the same line\n // as the last (content-order) character).\n if (part.level > 0 || cm.doc.direction == \"rtl\") {\n var prep = prepareMeasureForLine(cm, lineObj);\n ch = dir < 0 ? lineObj.text.length - 1 : 0;\n var targetTop = measureCharPrepared(cm, prep, ch).top;\n ch = findFirst(function (ch) { return measureCharPrepared(cm, prep, ch).top == targetTop; }, (dir < 0) == (part.level == 1) ? part.from : part.to - 1, ch);\n if (sticky == \"before\") { ch = moveCharLogically(lineObj, ch, 1); }\n } else { ch = dir < 0 ? part.to : part.from; }\n return new Pos(lineNo, ch, sticky)\n }\n }\n return new Pos(lineNo, dir < 0 ? lineObj.text.length : 0, dir < 0 ? \"before\" : \"after\")\n }\n\n function moveVisually(cm, line, start, dir) {\n var bidi = getOrder(line, cm.doc.direction);\n if (!bidi) { return moveLogically(line, start, dir) }\n if (start.ch >= line.text.length) {\n start.ch = line.text.length;\n start.sticky = \"before\";\n } else if (start.ch <= 0) {\n start.ch = 0;\n start.sticky = \"after\";\n }\n var partPos = getBidiPartAt(bidi, start.ch, start.sticky), part = bidi[partPos];\n if (cm.doc.direction == \"ltr\" && part.level % 2 == 0 && (dir > 0 ? part.to > start.ch : part.from < start.ch)) {\n // Case 1: We move within an ltr part in an ltr editor. Even with wrapped lines,\n // nothing interesting happens.\n return moveLogically(line, start, dir)\n }\n\n var mv = function (pos, dir) { return moveCharLogically(line, pos instanceof Pos ? pos.ch : pos, dir); };\n var prep;\n var getWrappedLineExtent = function (ch) {\n if (!cm.options.lineWrapping) { return {begin: 0, end: line.text.length} }\n prep = prep || prepareMeasureForLine(cm, line);\n return wrappedLineExtentChar(cm, line, prep, ch)\n };\n var wrappedLineExtent = getWrappedLineExtent(start.sticky == \"before\" ? mv(start, -1) : start.ch);\n\n if (cm.doc.direction == \"rtl\" || part.level == 1) {\n var moveInStorageOrder = (part.level == 1) == (dir < 0);\n var ch = mv(start, moveInStorageOrder ? 1 : -1);\n if (ch != null && (!moveInStorageOrder ? ch >= part.from && ch >= wrappedLineExtent.begin : ch <= part.to && ch <= wrappedLineExtent.end)) {\n // Case 2: We move within an rtl part or in an rtl editor on the same visual line\n var sticky = moveInStorageOrder ? \"before\" : \"after\";\n return new Pos(start.line, ch, sticky)\n }\n }\n\n // Case 3: Could not move within this bidi part in this visual line, so leave\n // the current bidi part\n\n var searchInVisualLine = function (partPos, dir, wrappedLineExtent) {\n var getRes = function (ch, moveInStorageOrder) { return moveInStorageOrder\n ? new Pos(start.line, mv(ch, 1), \"before\")\n : new Pos(start.line, ch, \"after\"); };\n\n for (; partPos >= 0 && partPos < bidi.length; partPos += dir) {\n var part = bidi[partPos];\n var moveInStorageOrder = (dir > 0) == (part.level != 1);\n var ch = moveInStorageOrder ? wrappedLineExtent.begin : mv(wrappedLineExtent.end, -1);\n if (part.from <= ch && ch < part.to) { return getRes(ch, moveInStorageOrder) }\n ch = moveInStorageOrder ? part.from : mv(part.to, -1);\n if (wrappedLineExtent.begin <= ch && ch < wrappedLineExtent.end) { return getRes(ch, moveInStorageOrder) }\n }\n };\n\n // Case 3a: Look for other bidi parts on the same visual line\n var res = searchInVisualLine(partPos + dir, dir, wrappedLineExtent);\n if (res) { return res }\n\n // Case 3b: Look for other bidi parts on the next visual line\n var nextCh = dir > 0 ? wrappedLineExtent.end : mv(wrappedLineExtent.begin, -1);\n if (nextCh != null && !(dir > 0 && nextCh == line.text.length)) {\n res = searchInVisualLine(dir > 0 ? 0 : bidi.length - 1, dir, getWrappedLineExtent(nextCh));\n if (res) { return res }\n }\n\n // Case 4: Nowhere to move\n return null\n }\n\n // Commands are parameter-less actions that can be performed on an\n // editor, mostly used for keybindings.\n var commands = {\n selectAll: selectAll,\n singleSelection: function (cm) { return cm.setSelection(cm.getCursor(\"anchor\"), cm.getCursor(\"head\"), sel_dontScroll); },\n killLine: function (cm) { return deleteNearSelection(cm, function (range) {\n if (range.empty()) {\n var len = getLine(cm.doc, range.head.line).text.length;\n if (range.head.ch == len && range.head.line < cm.lastLine())\n { return {from: range.head, to: Pos(range.head.line + 1, 0)} }\n else\n { return {from: range.head, to: Pos(range.head.line, len)} }\n } else {\n return {from: range.from(), to: range.to()}\n }\n }); },\n deleteLine: function (cm) { return deleteNearSelection(cm, function (range) { return ({\n from: Pos(range.from().line, 0),\n to: clipPos(cm.doc, Pos(range.to().line + 1, 0))\n }); }); },\n delLineLeft: function (cm) { return deleteNearSelection(cm, function (range) { return ({\n from: Pos(range.from().line, 0), to: range.from()\n }); }); },\n delWrappedLineLeft: function (cm) { return deleteNearSelection(cm, function (range) {\n var top = cm.charCoords(range.head, \"div\").top + 5;\n var leftPos = cm.coordsChar({left: 0, top: top}, \"div\");\n return {from: leftPos, to: range.from()}\n }); },\n delWrappedLineRight: function (cm) { return deleteNearSelection(cm, function (range) {\n var top = cm.charCoords(range.head, \"div\").top + 5;\n var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, \"div\");\n return {from: range.from(), to: rightPos }\n }); },\n undo: function (cm) { return cm.undo(); },\n redo: function (cm) { return cm.redo(); },\n undoSelection: function (cm) { return cm.undoSelection(); },\n redoSelection: function (cm) { return cm.redoSelection(); },\n goDocStart: function (cm) { return cm.extendSelection(Pos(cm.firstLine(), 0)); },\n goDocEnd: function (cm) { return cm.extendSelection(Pos(cm.lastLine())); },\n goLineStart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStart(cm, range.head.line); },\n {origin: \"+move\", bias: 1}\n ); },\n goLineStartSmart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStartSmart(cm, range.head); },\n {origin: \"+move\", bias: 1}\n ); },\n goLineEnd: function (cm) { return cm.extendSelectionsBy(function (range) { return lineEnd(cm, range.head.line); },\n {origin: \"+move\", bias: -1}\n ); },\n goLineRight: function (cm) { return cm.extendSelectionsBy(function (range) {\n var top = cm.cursorCoords(range.head, \"div\").top + 5;\n return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, \"div\")\n }, sel_move); },\n goLineLeft: function (cm) { return cm.extendSelectionsBy(function (range) {\n var top = cm.cursorCoords(range.head, \"div\").top + 5;\n return cm.coordsChar({left: 0, top: top}, \"div\")\n }, sel_move); },\n goLineLeftSmart: function (cm) { return cm.extendSelectionsBy(function (range) {\n var top = cm.cursorCoords(range.head, \"div\").top + 5;\n var pos = cm.coordsChar({left: 0, top: top}, \"div\");\n if (pos.ch < cm.getLine(pos.line).search(/\\S/)) { return lineStartSmart(cm, range.head) }\n return pos\n }, sel_move); },\n goLineUp: function (cm) { return cm.moveV(-1, \"line\"); },\n goLineDown: function (cm) { return cm.moveV(1, \"line\"); },\n goPageUp: function (cm) { return cm.moveV(-1, \"page\"); },\n goPageDown: function (cm) { return cm.moveV(1, \"page\"); },\n goCharLeft: function (cm) { return cm.moveH(-1, \"char\"); },\n goCharRight: function (cm) { return cm.moveH(1, \"char\"); },\n goColumnLeft: function (cm) { return cm.moveH(-1, \"column\"); },\n goColumnRight: function (cm) { return cm.moveH(1, \"column\"); },\n goWordLeft: function (cm) { return cm.moveH(-1, \"word\"); },\n goGroupRight: function (cm) { return cm.moveH(1, \"group\"); },\n goGroupLeft: function (cm) { return cm.moveH(-1, \"group\"); },\n goWordRight: function (cm) { return cm.moveH(1, \"word\"); },\n delCharBefore: function (cm) { return cm.deleteH(-1, \"char\"); },\n delCharAfter: function (cm) { return cm.deleteH(1, \"char\"); },\n delWordBefore: function (cm) { return cm.deleteH(-1, \"word\"); },\n delWordAfter: function (cm) { return cm.deleteH(1, \"word\"); },\n delGroupBefore: function (cm) { return cm.deleteH(-1, \"group\"); },\n delGroupAfter: function (cm) { return cm.deleteH(1, \"group\"); },\n indentAuto: function (cm) { return cm.indentSelection(\"smart\"); },\n indentMore: function (cm) { return cm.indentSelection(\"add\"); },\n indentLess: function (cm) { return cm.indentSelection(\"subtract\"); },\n insertTab: function (cm) { return cm.replaceSelection(\"\\t\"); },\n insertSoftTab: function (cm) {\n var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize;\n for (var i = 0; i < ranges.length; i++) {\n var pos = ranges[i].from();\n var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize);\n spaces.push(spaceStr(tabSize - col % tabSize));\n }\n cm.replaceSelections(spaces);\n },\n defaultTab: function (cm) {\n if (cm.somethingSelected()) { cm.indentSelection(\"add\"); }\n else { cm.execCommand(\"insertTab\"); }\n },\n // Swap the two chars left and right of each selection's head.\n // Move cursor behind the two swapped characters afterwards.\n //\n // Doesn't consider line feeds a character.\n // Doesn't scan more than one line above to find a character.\n // Doesn't do anything on an empty line.\n // Doesn't do anything with non-empty selections.\n transposeChars: function (cm) { return runInOp(cm, function () {\n var ranges = cm.listSelections(), newSel = [];\n for (var i = 0; i < ranges.length; i++) {\n if (!ranges[i].empty()) { continue }\n var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text;\n if (line) {\n if (cur.ch == line.length) { cur = new Pos(cur.line, cur.ch - 1); }\n if (cur.ch > 0) {\n cur = new Pos(cur.line, cur.ch + 1);\n cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2),\n Pos(cur.line, cur.ch - 2), cur, \"+transpose\");\n } else if (cur.line > cm.doc.first) {\n var prev = getLine(cm.doc, cur.line - 1).text;\n if (prev) {\n cur = new Pos(cur.line, 1);\n cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() +\n prev.charAt(prev.length - 1),\n Pos(cur.line - 1, prev.length - 1), cur, \"+transpose\");\n }\n }\n }\n newSel.push(new Range(cur, cur));\n }\n cm.setSelections(newSel);\n }); },\n newlineAndIndent: function (cm) { return runInOp(cm, function () {\n var sels = cm.listSelections();\n for (var i = sels.length - 1; i >= 0; i--)\n { cm.replaceRange(cm.doc.lineSeparator(), sels[i].anchor, sels[i].head, \"+input\"); }\n sels = cm.listSelections();\n for (var i$1 = 0; i$1 < sels.length; i$1++)\n { cm.indentLine(sels[i$1].from().line, null, true); }\n ensureCursorVisible(cm);\n }); },\n openLine: function (cm) { return cm.replaceSelection(\"\\n\", \"start\"); },\n toggleOverwrite: function (cm) { return cm.toggleOverwrite(); }\n };\n\n\n function lineStart(cm, lineN) {\n var line = getLine(cm.doc, lineN);\n var visual = visualLine(line);\n if (visual != line) { lineN = lineNo(visual); }\n return endOfLine(true, cm, visual, lineN, 1)\n }\n function lineEnd(cm, lineN) {\n var line = getLine(cm.doc, lineN);\n var visual = visualLineEnd(line);\n if (visual != line) { lineN = lineNo(visual); }\n return endOfLine(true, cm, line, lineN, -1)\n }\n function lineStartSmart(cm, pos) {\n var start = lineStart(cm, pos.line);\n var line = getLine(cm.doc, start.line);\n var order = getOrder(line, cm.doc.direction);\n if (!order || order[0].level == 0) {\n var firstNonWS = Math.max(0, line.text.search(/\\S/));\n var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch;\n return Pos(start.line, inWS ? 0 : firstNonWS, start.sticky)\n }\n return start\n }\n\n // Run a handler that was bound to a key.\n function doHandleBinding(cm, bound, dropShift) {\n if (typeof bound == \"string\") {\n bound = commands[bound];\n if (!bound) { return false }\n }\n // Ensure previous input has been read, so that the handler sees a\n // consistent view of the document\n cm.display.input.ensurePolled();\n var prevShift = cm.display.shift, done = false;\n try {\n if (cm.isReadOnly()) { cm.state.suppressEdits = true; }\n if (dropShift) { cm.display.shift = false; }\n done = bound(cm) != Pass;\n } finally {\n cm.display.shift = prevShift;\n cm.state.suppressEdits = false;\n }\n return done\n }\n\n function lookupKeyForEditor(cm, name, handle) {\n for (var i = 0; i < cm.state.keyMaps.length; i++) {\n var result = lookupKey(name, cm.state.keyMaps[i], handle, cm);\n if (result) { return result }\n }\n return (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm))\n || lookupKey(name, cm.options.keyMap, handle, cm)\n }\n\n // Note that, despite the name, this function is also used to check\n // for bound mouse clicks.\n\n var stopSeq = new Delayed;\n\n function dispatchKey(cm, name, e, handle) {\n var seq = cm.state.keySeq;\n if (seq) {\n if (isModifierKey(name)) { return \"handled\" }\n if (/\\'$/.test(name))\n { cm.state.keySeq = null; }\n else\n { stopSeq.set(50, function () {\n if (cm.state.keySeq == seq) {\n cm.state.keySeq = null;\n cm.display.input.reset();\n }\n }); }\n if (dispatchKeyInner(cm, seq + \" \" + name, e, handle)) { return true }\n }\n return dispatchKeyInner(cm, name, e, handle)\n }\n\n function dispatchKeyInner(cm, name, e, handle) {\n var result = lookupKeyForEditor(cm, name, handle);\n\n if (result == \"multi\")\n { cm.state.keySeq = name; }\n if (result == \"handled\")\n { signalLater(cm, \"keyHandled\", cm, name, e); }\n\n if (result == \"handled\" || result == \"multi\") {\n e_preventDefault(e);\n restartBlink(cm);\n }\n\n return !!result\n }\n\n // Handle a key from the keydown event.\n function handleKeyBinding(cm, e) {\n var name = keyName(e, true);\n if (!name) { return false }\n\n if (e.shiftKey && !cm.state.keySeq) {\n // First try to resolve full name (including 'Shift-'). Failing\n // that, see if there is a cursor-motion command (starting with\n // 'go') bound to the keyname without 'Shift-'.\n return dispatchKey(cm, \"Shift-\" + name, e, function (b) { return doHandleBinding(cm, b, true); })\n || dispatchKey(cm, name, e, function (b) {\n if (typeof b == \"string\" ? /^go[A-Z]/.test(b) : b.motion)\n { return doHandleBinding(cm, b) }\n })\n } else {\n return dispatchKey(cm, name, e, function (b) { return doHandleBinding(cm, b); })\n }\n }\n\n // Handle a key from the keypress event\n function handleCharBinding(cm, e, ch) {\n return dispatchKey(cm, \"'\" + ch + \"'\", e, function (b) { return doHandleBinding(cm, b, true); })\n }\n\n var lastStoppedKey = null;\n function onKeyDown(e) {\n var cm = this;\n cm.curOp.focus = activeElt();\n if (signalDOMEvent(cm, e)) { return }\n // IE does strange things with escape.\n if (ie && ie_version < 11 && e.keyCode == 27) { e.returnValue = false; }\n var code = e.keyCode;\n cm.display.shift = code == 16 || e.shiftKey;\n var handled = handleKeyBinding(cm, e);\n if (presto) {\n lastStoppedKey = handled ? code : null;\n // Opera has no cut event... we try to at least catch the key combo\n if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey))\n { cm.replaceSelection(\"\", null, \"cut\"); }\n }\n\n // Turn mouse into crosshair when Alt is held on Mac.\n if (code == 18 && !/\\bCodeMirror-crosshair\\b/.test(cm.display.lineDiv.className))\n { showCrossHair(cm); }\n }\n\n function showCrossHair(cm) {\n var lineDiv = cm.display.lineDiv;\n addClass(lineDiv, \"CodeMirror-crosshair\");\n\n function up(e) {\n if (e.keyCode == 18 || !e.altKey) {\n rmClass(lineDiv, \"CodeMirror-crosshair\");\n off(document, \"keyup\", up);\n off(document, \"mouseover\", up);\n }\n }\n on(document, \"keyup\", up);\n on(document, \"mouseover\", up);\n }\n\n function onKeyUp(e) {\n if (e.keyCode == 16) { this.doc.sel.shift = false; }\n signalDOMEvent(this, e);\n }\n\n function onKeyPress(e) {\n var cm = this;\n if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) { return }\n var keyCode = e.keyCode, charCode = e.charCode;\n if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return}\n if ((presto && (!e.which || e.which < 10)) && handleKeyBinding(cm, e)) { return }\n var ch = String.fromCharCode(charCode == null ? keyCode : charCode);\n // Some browsers fire keypress events for backspace\n if (ch == \"\\x08\") { return }\n if (handleCharBinding(cm, e, ch)) { return }\n cm.display.input.onKeyPress(e);\n }\n\n var DOUBLECLICK_DELAY = 400;\n\n var PastClick = function(time, pos, button) {\n this.time = time;\n this.pos = pos;\n this.button = button;\n };\n\n PastClick.prototype.compare = function (time, pos, button) {\n return this.time + DOUBLECLICK_DELAY > time &&\n cmp(pos, this.pos) == 0 && button == this.button\n };\n\n var lastClick, lastDoubleClick;\n function clickRepeat(pos, button) {\n var now = +new Date;\n if (lastDoubleClick && lastDoubleClick.compare(now, pos, button)) {\n lastClick = lastDoubleClick = null;\n return \"triple\"\n } else if (lastClick && lastClick.compare(now, pos, button)) {\n lastDoubleClick = new PastClick(now, pos, button);\n lastClick = null;\n return \"double\"\n } else {\n lastClick = new PastClick(now, pos, button);\n lastDoubleClick = null;\n return \"single\"\n }\n }\n\n // A mouse down can be a single click, double click, triple click,\n // start of selection drag, start of text drag, new cursor\n // (ctrl-click), rectangle drag (alt-drag), or xwin\n // middle-click-paste. Or it might be a click on something we should\n // not interfere with, such as a scrollbar or widget.\n function onMouseDown(e) {\n var cm = this, display = cm.display;\n if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) { return }\n display.input.ensurePolled();\n display.shift = e.shiftKey;\n\n if (eventInWidget(display, e)) {\n if (!webkit) {\n // Briefly turn off draggability, to allow widgets to do\n // normal dragging things.\n display.scroller.draggable = false;\n setTimeout(function () { return display.scroller.draggable = true; }, 100);\n }\n return\n }\n if (clickInGutter(cm, e)) { return }\n var pos = posFromMouse(cm, e), button = e_button(e), repeat = pos ? clickRepeat(pos, button) : \"single\";\n window.focus();\n\n // #3261: make sure, that we're not starting a second selection\n if (button == 1 && cm.state.selectingText)\n { cm.state.selectingText(e); }\n\n if (pos && handleMappedButton(cm, button, pos, repeat, e)) { return }\n\n if (button == 1) {\n if (pos) { leftButtonDown(cm, pos, repeat, e); }\n else if (e_target(e) == display.scroller) { e_preventDefault(e); }\n } else if (button == 2) {\n if (pos) { extendSelection(cm.doc, pos); }\n setTimeout(function () { return display.input.focus(); }, 20);\n } else if (button == 3) {\n if (captureRightClick) { cm.display.input.onContextMenu(e); }\n else { delayBlurEvent(cm); }\n }\n }\n\n function handleMappedButton(cm, button, pos, repeat, event) {\n var name = \"Click\";\n if (repeat == \"double\") { name = \"Double\" + name; }\n else if (repeat == \"triple\") { name = \"Triple\" + name; }\n name = (button == 1 ? \"Left\" : button == 2 ? \"Middle\" : \"Right\") + name;\n\n return dispatchKey(cm, addModifierNames(name, event), event, function (bound) {\n if (typeof bound == \"string\") { bound = commands[bound]; }\n if (!bound) { return false }\n var done = false;\n try {\n if (cm.isReadOnly()) { cm.state.suppressEdits = true; }\n done = bound(cm, pos) != Pass;\n } finally {\n cm.state.suppressEdits = false;\n }\n return done\n })\n }\n\n function configureMouse(cm, repeat, event) {\n var option = cm.getOption(\"configureMouse\");\n var value = option ? option(cm, repeat, event) : {};\n if (value.unit == null) {\n var rect = chromeOS ? event.shiftKey && event.metaKey : event.altKey;\n value.unit = rect ? \"rectangle\" : repeat == \"single\" ? \"char\" : repeat == \"double\" ? \"word\" : \"line\";\n }\n if (value.extend == null || cm.doc.extend) { value.extend = cm.doc.extend || event.shiftKey; }\n if (value.addNew == null) { value.addNew = mac ? event.metaKey : event.ctrlKey; }\n if (value.moveOnDrag == null) { value.moveOnDrag = !(mac ? event.altKey : event.ctrlKey); }\n return value\n }\n\n function leftButtonDown(cm, pos, repeat, event) {\n if (ie) { setTimeout(bind(ensureFocus, cm), 0); }\n else { cm.curOp.focus = activeElt(); }\n\n var behavior = configureMouse(cm, repeat, event);\n\n var sel = cm.doc.sel, contained;\n if (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() &&\n repeat == \"single\" && (contained = sel.contains(pos)) > -1 &&\n (cmp((contained = sel.ranges[contained]).from(), pos) < 0 || pos.xRel > 0) &&\n (cmp(contained.to(), pos) > 0 || pos.xRel < 0))\n { leftButtonStartDrag(cm, event, pos, behavior); }\n else\n { leftButtonSelect(cm, event, pos, behavior); }\n }\n\n // Start a text drag. When it ends, see if any dragging actually\n // happen, and treat as a click if it didn't.\n function leftButtonStartDrag(cm, event, pos, behavior) {\n var display = cm.display, moved = false;\n var dragEnd = operation(cm, function (e) {\n if (webkit) { display.scroller.draggable = false; }\n cm.state.draggingText = false;\n off(display.wrapper.ownerDocument, \"mouseup\", dragEnd);\n off(display.wrapper.ownerDocument, \"mousemove\", mouseMove);\n off(display.scroller, \"dragstart\", dragStart);\n off(display.scroller, \"drop\", dragEnd);\n if (!moved) {\n e_preventDefault(e);\n if (!behavior.addNew)\n { extendSelection(cm.doc, pos, null, null, behavior.extend); }\n // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)\n if (webkit || ie && ie_version == 9)\n { setTimeout(function () {display.wrapper.ownerDocument.body.focus(); display.input.focus();}, 20); }\n else\n { display.input.focus(); }\n }\n });\n var mouseMove = function(e2) {\n moved = moved || Math.abs(event.clientX - e2.clientX) + Math.abs(event.clientY - e2.clientY) >= 10;\n };\n var dragStart = function () { return moved = true; };\n // Let the drag handler handle this.\n if (webkit) { display.scroller.draggable = true; }\n cm.state.draggingText = dragEnd;\n dragEnd.copy = !behavior.moveOnDrag;\n // IE's approach to draggable\n if (display.scroller.dragDrop) { display.scroller.dragDrop(); }\n on(display.wrapper.ownerDocument, \"mouseup\", dragEnd);\n on(display.wrapper.ownerDocument, \"mousemove\", mouseMove);\n on(display.scroller, \"dragstart\", dragStart);\n on(display.scroller, \"drop\", dragEnd);\n\n delayBlurEvent(cm);\n setTimeout(function () { return display.input.focus(); }, 20);\n }\n\n function rangeForUnit(cm, pos, unit) {\n if (unit == \"char\") { return new Range(pos, pos) }\n if (unit == \"word\") { return cm.findWordAt(pos) }\n if (unit == \"line\") { return new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))) }\n var result = unit(cm, pos);\n return new Range(result.from, result.to)\n }\n\n // Normal selection, as opposed to text dragging.\n function leftButtonSelect(cm, event, start, behavior) {\n var display = cm.display, doc = cm.doc;\n e_preventDefault(event);\n\n var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges;\n if (behavior.addNew && !behavior.extend) {\n ourIndex = doc.sel.contains(start);\n if (ourIndex > -1)\n { ourRange = ranges[ourIndex]; }\n else\n { ourRange = new Range(start, start); }\n } else {\n ourRange = doc.sel.primary();\n ourIndex = doc.sel.primIndex;\n }\n\n if (behavior.unit == \"rectangle\") {\n if (!behavior.addNew) { ourRange = new Range(start, start); }\n start = posFromMouse(cm, event, true, true);\n ourIndex = -1;\n } else {\n var range$$1 = rangeForUnit(cm, start, behavior.unit);\n if (behavior.extend)\n { ourRange = extendRange(ourRange, range$$1.anchor, range$$1.head, behavior.extend); }\n else\n { ourRange = range$$1; }\n }\n\n if (!behavior.addNew) {\n ourIndex = 0;\n setSelection(doc, new Selection([ourRange], 0), sel_mouse);\n startSel = doc.sel;\n } else if (ourIndex == -1) {\n ourIndex = ranges.length;\n setSelection(doc, normalizeSelection(cm, ranges.concat([ourRange]), ourIndex),\n {scroll: false, origin: \"*mouse\"});\n } else if (ranges.length > 1 && ranges[ourIndex].empty() && behavior.unit == \"char\" && !behavior.extend) {\n setSelection(doc, normalizeSelection(cm, ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),\n {scroll: false, origin: \"*mouse\"});\n startSel = doc.sel;\n } else {\n replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);\n }\n\n var lastPos = start;\n function extendTo(pos) {\n if (cmp(lastPos, pos) == 0) { return }\n lastPos = pos;\n\n if (behavior.unit == \"rectangle\") {\n var ranges = [], tabSize = cm.options.tabSize;\n var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);\n var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);\n var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);\n for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));\n line <= end; line++) {\n var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize);\n if (left == right)\n { ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); }\n else if (text.length > leftPos)\n { ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); }\n }\n if (!ranges.length) { ranges.push(new Range(start, start)); }\n setSelection(doc, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),\n {origin: \"*mouse\", scroll: false});\n cm.scrollIntoView(pos);\n } else {\n var oldRange = ourRange;\n var range$$1 = rangeForUnit(cm, pos, behavior.unit);\n var anchor = oldRange.anchor, head;\n if (cmp(range$$1.anchor, anchor) > 0) {\n head = range$$1.head;\n anchor = minPos(oldRange.from(), range$$1.anchor);\n } else {\n head = range$$1.anchor;\n anchor = maxPos(oldRange.to(), range$$1.head);\n }\n var ranges$1 = startSel.ranges.slice(0);\n ranges$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc, anchor), head));\n setSelection(doc, normalizeSelection(cm, ranges$1, ourIndex), sel_mouse);\n }\n }\n\n var editorSize = display.wrapper.getBoundingClientRect();\n // Used to ensure timeout re-tries don't fire when another extend\n // happened in the meantime (clearTimeout isn't reliable -- at\n // least on Chrome, the timeouts still happen even when cleared,\n // if the clear happens after their scheduled firing time).\n var counter = 0;\n\n function extend(e) {\n var curCount = ++counter;\n var cur = posFromMouse(cm, e, true, behavior.unit == \"rectangle\");\n if (!cur) { return }\n if (cmp(cur, lastPos) != 0) {\n cm.curOp.focus = activeElt();\n extendTo(cur);\n var visible = visibleLines(display, doc);\n if (cur.line >= visible.to || cur.line < visible.from)\n { setTimeout(operation(cm, function () {if (counter == curCount) { extend(e); }}), 150); }\n } else {\n var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0;\n if (outside) { setTimeout(operation(cm, function () {\n if (counter != curCount) { return }\n display.scroller.scrollTop += outside;\n extend(e);\n }), 50); }\n }\n }\n\n function done(e) {\n cm.state.selectingText = false;\n counter = Infinity;\n // If e is null or undefined we interpret this as someone trying\n // to explicitly cancel the selection rather than the user\n // letting go of the mouse button.\n if (e) {\n e_preventDefault(e);\n display.input.focus();\n }\n off(display.wrapper.ownerDocument, \"mousemove\", move);\n off(display.wrapper.ownerDocument, \"mouseup\", up);\n doc.history.lastSelOrigin = null;\n }\n\n var move = operation(cm, function (e) {\n if (e.buttons === 0 || !e_button(e)) { done(e); }\n else { extend(e); }\n });\n var up = operation(cm, done);\n cm.state.selectingText = up;\n on(display.wrapper.ownerDocument, \"mousemove\", move);\n on(display.wrapper.ownerDocument, \"mouseup\", up);\n }\n\n // Used when mouse-selecting to adjust the anchor to the proper side\n // of a bidi jump depending on the visual position of the head.\n function bidiSimplify(cm, range$$1) {\n var anchor = range$$1.anchor;\n var head = range$$1.head;\n var anchorLine = getLine(cm.doc, anchor.line);\n if (cmp(anchor, head) == 0 && anchor.sticky == head.sticky) { return range$$1 }\n var order = getOrder(anchorLine);\n if (!order) { return range$$1 }\n var index = getBidiPartAt(order, anchor.ch, anchor.sticky), part = order[index];\n if (part.from != anchor.ch && part.to != anchor.ch) { return range$$1 }\n var boundary = index + ((part.from == anchor.ch) == (part.level != 1) ? 0 : 1);\n if (boundary == 0 || boundary == order.length) { return range$$1 }\n\n // Compute the relative visual position of the head compared to the\n // anchor (<0 is to the left, >0 to the right)\n var leftSide;\n if (head.line != anchor.line) {\n leftSide = (head.line - anchor.line) * (cm.doc.direction == \"ltr\" ? 1 : -1) > 0;\n } else {\n var headIndex = getBidiPartAt(order, head.ch, head.sticky);\n var dir = headIndex - index || (head.ch - anchor.ch) * (part.level == 1 ? -1 : 1);\n if (headIndex == boundary - 1 || headIndex == boundary)\n { leftSide = dir < 0; }\n else\n { leftSide = dir > 0; }\n }\n\n var usePart = order[boundary + (leftSide ? -1 : 0)];\n var from = leftSide == (usePart.level == 1);\n var ch = from ? usePart.from : usePart.to, sticky = from ? \"after\" : \"before\";\n return anchor.ch == ch && anchor.sticky == sticky ? range$$1 : new Range(new Pos(anchor.line, ch, sticky), head)\n }\n\n\n // Determines whether an event happened in the gutter, and fires the\n // handlers for the corresponding event.\n function gutterEvent(cm, e, type, prevent) {\n var mX, mY;\n if (e.touches) {\n mX = e.touches[0].clientX;\n mY = e.touches[0].clientY;\n } else {\n try { mX = e.clientX; mY = e.clientY; }\n catch(e) { return false }\n }\n if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) { return false }\n if (prevent) { e_preventDefault(e); }\n\n var display = cm.display;\n var lineBox = display.lineDiv.getBoundingClientRect();\n\n if (mY > lineBox.bottom || !hasHandler(cm, type)) { return e_defaultPrevented(e) }\n mY -= lineBox.top - display.viewOffset;\n\n for (var i = 0; i < cm.display.gutterSpecs.length; ++i) {\n var g = display.gutters.childNodes[i];\n if (g && g.getBoundingClientRect().right >= mX) {\n var line = lineAtHeight(cm.doc, mY);\n var gutter = cm.display.gutterSpecs[i];\n signal(cm, type, cm, line, gutter.className, e);\n return e_defaultPrevented(e)\n }\n }\n }\n\n function clickInGutter(cm, e) {\n return gutterEvent(cm, e, \"gutterClick\", true)\n }\n\n // CONTEXT MENU HANDLING\n\n // To make the context menu work, we need to briefly unhide the\n // textarea (making it as unobtrusive as possible) to let the\n // right-click take effect on it.\n function onContextMenu(cm, e) {\n if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) { return }\n if (signalDOMEvent(cm, e, \"contextmenu\")) { return }\n if (!captureRightClick) { cm.display.input.onContextMenu(e); }\n }\n\n function contextMenuInGutter(cm, e) {\n if (!hasHandler(cm, \"gutterContextMenu\")) { return false }\n return gutterEvent(cm, e, \"gutterContextMenu\", false)\n }\n\n function themeChanged(cm) {\n cm.display.wrapper.className = cm.display.wrapper.className.replace(/\\s*cm-s-\\S+/g, \"\") +\n cm.options.theme.replace(/(^|\\s)\\s*/g, \" cm-s-\");\n clearCaches(cm);\n }\n\n var Init = {toString: function(){return \"CodeMirror.Init\"}};\n\n var defaults = {};\n var optionHandlers = {};\n\n function defineOptions(CodeMirror) {\n var optionHandlers = CodeMirror.optionHandlers;\n\n function option(name, deflt, handle, notOnInit) {\n CodeMirror.defaults[name] = deflt;\n if (handle) { optionHandlers[name] =\n notOnInit ? function (cm, val, old) {if (old != Init) { handle(cm, val, old); }} : handle; }\n }\n\n CodeMirror.defineOption = option;\n\n // Passed to option handlers when there is no old value.\n CodeMirror.Init = Init;\n\n // These two are, on init, called from the constructor because they\n // have to be initialized before the editor can start at all.\n option(\"value\", \"\", function (cm, val) { return cm.setValue(val); }, true);\n option(\"mode\", null, function (cm, val) {\n cm.doc.modeOption = val;\n loadMode(cm);\n }, true);\n\n option(\"indentUnit\", 2, loadMode, true);\n option(\"indentWithTabs\", false);\n option(\"smartIndent\", true);\n option(\"tabSize\", 4, function (cm) {\n resetModeState(cm);\n clearCaches(cm);\n regChange(cm);\n }, true);\n\n option(\"lineSeparator\", null, function (cm, val) {\n cm.doc.lineSep = val;\n if (!val) { return }\n var newBreaks = [], lineNo = cm.doc.first;\n cm.doc.iter(function (line) {\n for (var pos = 0;;) {\n var found = line.text.indexOf(val, pos);\n if (found == -1) { break }\n pos = found + val.length;\n newBreaks.push(Pos(lineNo, found));\n }\n lineNo++;\n });\n for (var i = newBreaks.length - 1; i >= 0; i--)\n { replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)); }\n });\n option(\"specialChars\", /[\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u061c\\u200b-\\u200f\\u2028\\u2029\\ufeff\\ufff9-\\ufffc]/g, function (cm, val, old) {\n cm.state.specialChars = new RegExp(val.source + (val.test(\"\\t\") ? \"\" : \"|\\t\"), \"g\");\n if (old != Init) { cm.refresh(); }\n });\n option(\"specialCharPlaceholder\", defaultSpecialCharPlaceholder, function (cm) { return cm.refresh(); }, true);\n option(\"electricChars\", true);\n option(\"inputStyle\", mobile ? \"contenteditable\" : \"textarea\", function () {\n throw new Error(\"inputStyle can not (yet) be changed in a running editor\") // FIXME\n }, true);\n option(\"spellcheck\", false, function (cm, val) { return cm.getInputField().spellcheck = val; }, true);\n option(\"autocorrect\", false, function (cm, val) { return cm.getInputField().autocorrect = val; }, true);\n option(\"autocapitalize\", false, function (cm, val) { return cm.getInputField().autocapitalize = val; }, true);\n option(\"rtlMoveVisually\", !windows);\n option(\"wholeLineUpdateBefore\", true);\n\n option(\"theme\", \"default\", function (cm) {\n themeChanged(cm);\n updateGutters(cm);\n }, true);\n option(\"keyMap\", \"default\", function (cm, val, old) {\n var next = getKeyMap(val);\n var prev = old != Init && getKeyMap(old);\n if (prev && prev.detach) { prev.detach(cm, next); }\n if (next.attach) { next.attach(cm, prev || null); }\n });\n option(\"extraKeys\", null);\n option(\"configureMouse\", null);\n\n option(\"lineWrapping\", false, wrappingChanged, true);\n option(\"gutters\", [], function (cm, val) {\n cm.display.gutterSpecs = getGutters(val, cm.options.lineNumbers);\n updateGutters(cm);\n }, true);\n option(\"fixedGutter\", true, function (cm, val) {\n cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + \"px\" : \"0\";\n cm.refresh();\n }, true);\n option(\"coverGutterNextToScrollbar\", false, function (cm) { return updateScrollbars(cm); }, true);\n option(\"scrollbarStyle\", \"native\", function (cm) {\n initScrollbars(cm);\n updateScrollbars(cm);\n cm.display.scrollbars.setScrollTop(cm.doc.scrollTop);\n cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft);\n }, true);\n option(\"lineNumbers\", false, function (cm, val) {\n cm.display.gutterSpecs = getGutters(cm.options.gutters, val);\n updateGutters(cm);\n }, true);\n option(\"firstLineNumber\", 1, updateGutters, true);\n option(\"lineNumberFormatter\", function (integer) { return integer; }, updateGutters, true);\n option(\"showCursorWhenSelecting\", false, updateSelection, true);\n\n option(\"resetSelectionOnContextMenu\", true);\n option(\"lineWiseCopyCut\", true);\n option(\"pasteLinesPerSelection\", true);\n option(\"selectionsMayTouch\", false);\n\n option(\"readOnly\", false, function (cm, val) {\n if (val == \"nocursor\") {\n onBlur(cm);\n cm.display.input.blur();\n }\n cm.display.input.readOnlyChanged(val);\n });\n option(\"disableInput\", false, function (cm, val) {if (!val) { cm.display.input.reset(); }}, true);\n option(\"dragDrop\", true, dragDropChanged);\n option(\"allowDropFileTypes\", null);\n\n option(\"cursorBlinkRate\", 530);\n option(\"cursorScrollMargin\", 0);\n option(\"cursorHeight\", 1, updateSelection, true);\n option(\"singleCursorHeightPerLine\", true, updateSelection, true);\n option(\"workTime\", 100);\n option(\"workDelay\", 100);\n option(\"flattenSpans\", true, resetModeState, true);\n option(\"addModeClass\", false, resetModeState, true);\n option(\"pollInterval\", 100);\n option(\"undoDepth\", 200, function (cm, val) { return cm.doc.history.undoDepth = val; });\n option(\"historyEventDelay\", 1250);\n option(\"viewportMargin\", 10, function (cm) { return cm.refresh(); }, true);\n option(\"maxHighlightLength\", 10000, resetModeState, true);\n option(\"moveInputWithCursor\", true, function (cm, val) {\n if (!val) { cm.display.input.resetPosition(); }\n });\n\n option(\"tabindex\", null, function (cm, val) { return cm.display.input.getField().tabIndex = val || \"\"; });\n option(\"autofocus\", null);\n option(\"direction\", \"ltr\", function (cm, val) { return cm.doc.setDirection(val); }, true);\n option(\"phrases\", null);\n }\n\n function dragDropChanged(cm, value, old) {\n var wasOn = old && old != Init;\n if (!value != !wasOn) {\n var funcs = cm.display.dragFunctions;\n var toggle = value ? on : off;\n toggle(cm.display.scroller, \"dragstart\", funcs.start);\n toggle(cm.display.scroller, \"dragenter\", funcs.enter);\n toggle(cm.display.scroller, \"dragover\", funcs.over);\n toggle(cm.display.scroller, \"dragleave\", funcs.leave);\n toggle(cm.display.scroller, \"drop\", funcs.drop);\n }\n }\n\n function wrappingChanged(cm) {\n if (cm.options.lineWrapping) {\n addClass(cm.display.wrapper, \"CodeMirror-wrap\");\n cm.display.sizer.style.minWidth = \"\";\n cm.display.sizerWidth = null;\n } else {\n rmClass(cm.display.wrapper, \"CodeMirror-wrap\");\n findMaxLine(cm);\n }\n estimateLineHeights(cm);\n regChange(cm);\n clearCaches(cm);\n setTimeout(function () { return updateScrollbars(cm); }, 100);\n }\n\n // A CodeMirror instance represents an editor. This is the object\n // that user code is usually dealing with.\n\n function CodeMirror(place, options) {\n var this$1 = this;\n\n if (!(this instanceof CodeMirror)) { return new CodeMirror(place, options) }\n\n this.options = options = options ? copyObj(options) : {};\n // Determine effective options based on given values and defaults.\n copyObj(defaults, options, false);\n\n var doc = options.value;\n if (typeof doc == \"string\") { doc = new Doc(doc, options.mode, null, options.lineSeparator, options.direction); }\n else if (options.mode) { doc.modeOption = options.mode; }\n this.doc = doc;\n\n var input = new CodeMirror.inputStyles[options.inputStyle](this);\n var display = this.display = new Display(place, doc, input, options);\n display.wrapper.CodeMirror = this;\n themeChanged(this);\n if (options.lineWrapping)\n { this.display.wrapper.className += \" CodeMirror-wrap\"; }\n initScrollbars(this);\n\n this.state = {\n keyMaps: [], // stores maps added by addKeyMap\n overlays: [], // highlighting overlays, as added by addOverlay\n modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info\n overwrite: false,\n delayingBlurEvent: false,\n focused: false,\n suppressEdits: false, // used to disable editing during key handlers when in readOnly mode\n pasteIncoming: -1, cutIncoming: -1, // help recognize paste/cut edits in input.poll\n selectingText: false,\n draggingText: false,\n highlight: new Delayed(), // stores highlight worker timeout\n keySeq: null, // Unfinished key sequence\n specialChars: null\n };\n\n if (options.autofocus && !mobile) { display.input.focus(); }\n\n // Override magic textarea content restore that IE sometimes does\n // on our hidden textarea on reload\n if (ie && ie_version < 11) { setTimeout(function () { return this$1.display.input.reset(true); }, 20); }\n\n registerEventHandlers(this);\n ensureGlobalHandlers();\n\n startOperation(this);\n this.curOp.forceUpdate = true;\n attachDoc(this, doc);\n\n if ((options.autofocus && !mobile) || this.hasFocus())\n { setTimeout(bind(onFocus, this), 20); }\n else\n { onBlur(this); }\n\n for (var opt in optionHandlers) { if (optionHandlers.hasOwnProperty(opt))\n { optionHandlers[opt](this$1, options[opt], Init); } }\n maybeUpdateLineNumberWidth(this);\n if (options.finishInit) { options.finishInit(this); }\n for (var i = 0; i < initHooks.length; ++i) { initHooks[i](this$1); }\n endOperation(this);\n // Suppress optimizelegibility in Webkit, since it breaks text\n // measuring on line wrapping boundaries.\n if (webkit && options.lineWrapping &&\n getComputedStyle(display.lineDiv).textRendering == \"optimizelegibility\")\n { display.lineDiv.style.textRendering = \"auto\"; }\n }\n\n // The default configuration options.\n CodeMirror.defaults = defaults;\n // Functions to run when options are changed.\n CodeMirror.optionHandlers = optionHandlers;\n\n // Attach the necessary event handlers when initializing the editor\n function registerEventHandlers(cm) {\n var d = cm.display;\n on(d.scroller, \"mousedown\", operation(cm, onMouseDown));\n // Older IE's will not fire a second mousedown for a double click\n if (ie && ie_version < 11)\n { on(d.scroller, \"dblclick\", operation(cm, function (e) {\n if (signalDOMEvent(cm, e)) { return }\n var pos = posFromMouse(cm, e);\n if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) { return }\n e_preventDefault(e);\n var word = cm.findWordAt(pos);\n extendSelection(cm.doc, word.anchor, word.head);\n })); }\n else\n { on(d.scroller, \"dblclick\", function (e) { return signalDOMEvent(cm, e) || e_preventDefault(e); }); }\n // Some browsers fire contextmenu *after* opening the menu, at\n // which point we can't mess with it anymore. Context menu is\n // handled in onMouseDown for these browsers.\n on(d.scroller, \"contextmenu\", function (e) { return onContextMenu(cm, e); });\n\n // Used to suppress mouse event handling when a touch happens\n var touchFinished, prevTouch = {end: 0};\n function finishTouch() {\n if (d.activeTouch) {\n touchFinished = setTimeout(function () { return d.activeTouch = null; }, 1000);\n prevTouch = d.activeTouch;\n prevTouch.end = +new Date;\n }\n }\n function isMouseLikeTouchEvent(e) {\n if (e.touches.length != 1) { return false }\n var touch = e.touches[0];\n return touch.radiusX <= 1 && touch.radiusY <= 1\n }\n function farAway(touch, other) {\n if (other.left == null) { return true }\n var dx = other.left - touch.left, dy = other.top - touch.top;\n return dx * dx + dy * dy > 20 * 20\n }\n on(d.scroller, \"touchstart\", function (e) {\n if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e) && !clickInGutter(cm, e)) {\n d.input.ensurePolled();\n clearTimeout(touchFinished);\n var now = +new Date;\n d.activeTouch = {start: now, moved: false,\n prev: now - prevTouch.end <= 300 ? prevTouch : null};\n if (e.touches.length == 1) {\n d.activeTouch.left = e.touches[0].pageX;\n d.activeTouch.top = e.touches[0].pageY;\n }\n }\n });\n on(d.scroller, \"touchmove\", function () {\n if (d.activeTouch) { d.activeTouch.moved = true; }\n });\n on(d.scroller, \"touchend\", function (e) {\n var touch = d.activeTouch;\n if (touch && !eventInWidget(d, e) && touch.left != null &&\n !touch.moved && new Date - touch.start < 300) {\n var pos = cm.coordsChar(d.activeTouch, \"page\"), range;\n if (!touch.prev || farAway(touch, touch.prev)) // Single tap\n { range = new Range(pos, pos); }\n else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap\n { range = cm.findWordAt(pos); }\n else // Triple tap\n { range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))); }\n cm.setSelection(range.anchor, range.head);\n cm.focus();\n e_preventDefault(e);\n }\n finishTouch();\n });\n on(d.scroller, \"touchcancel\", finishTouch);\n\n // Sync scrolling between fake scrollbars and real scrollable\n // area, ensure viewport is updated when scrolling.\n on(d.scroller, \"scroll\", function () {\n if (d.scroller.clientHeight) {\n updateScrollTop(cm, d.scroller.scrollTop);\n setScrollLeft(cm, d.scroller.scrollLeft, true);\n signal(cm, \"scroll\", cm);\n }\n });\n\n // Listen to wheel events in order to try and update the viewport on time.\n on(d.scroller, \"mousewheel\", function (e) { return onScrollWheel(cm, e); });\n on(d.scroller, \"DOMMouseScroll\", function (e) { return onScrollWheel(cm, e); });\n\n // Prevent wrapper from ever scrolling\n on(d.wrapper, \"scroll\", function () { return d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });\n\n d.dragFunctions = {\n enter: function (e) {if (!signalDOMEvent(cm, e)) { e_stop(e); }},\n over: function (e) {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e); }},\n start: function (e) { return onDragStart(cm, e); },\n drop: operation(cm, onDrop),\n leave: function (e) {if (!signalDOMEvent(cm, e)) { clearDragCursor(cm); }}\n };\n\n var inp = d.input.getField();\n on(inp, \"keyup\", function (e) { return onKeyUp.call(cm, e); });\n on(inp, \"keydown\", operation(cm, onKeyDown));\n on(inp, \"keypress\", operation(cm, onKeyPress));\n on(inp, \"focus\", function (e) { return onFocus(cm, e); });\n on(inp, \"blur\", function (e) { return onBlur(cm, e); });\n }\n\n var initHooks = [];\n CodeMirror.defineInitHook = function (f) { return initHooks.push(f); };\n\n // Indent the given line. The how parameter can be \"smart\",\n // \"add\"/null, \"subtract\", or \"prev\". When aggressive is false\n // (typically set to true for forced single-line indents), empty\n // lines are not indented, and places where the mode returns Pass\n // are left alone.\n function indentLine(cm, n, how, aggressive) {\n var doc = cm.doc, state;\n if (how == null) { how = \"add\"; }\n if (how == \"smart\") {\n // Fall back to \"prev\" when the mode doesn't have an indentation\n // method.\n if (!doc.mode.indent) { how = \"prev\"; }\n else { state = getContextBefore(cm, n).state; }\n }\n\n var tabSize = cm.options.tabSize;\n var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize);\n if (line.stateAfter) { line.stateAfter = null; }\n var curSpaceString = line.text.match(/^\\s*/)[0], indentation;\n if (!aggressive && !/\\S/.test(line.text)) {\n indentation = 0;\n how = \"not\";\n } else if (how == \"smart\") {\n indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text);\n if (indentation == Pass || indentation > 150) {\n if (!aggressive) { return }\n how = \"prev\";\n }\n }\n if (how == \"prev\") {\n if (n > doc.first) { indentation = countColumn(getLine(doc, n-1).text, null, tabSize); }\n else { indentation = 0; }\n } else if (how == \"add\") {\n indentation = curSpace + cm.options.indentUnit;\n } else if (how == \"subtract\") {\n indentation = curSpace - cm.options.indentUnit;\n } else if (typeof how == \"number\") {\n indentation = curSpace + how;\n }\n indentation = Math.max(0, indentation);\n\n var indentString = \"\", pos = 0;\n if (cm.options.indentWithTabs)\n { for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += \"\\t\";} }\n if (pos < indentation) { indentString += spaceStr(indentation - pos); }\n\n if (indentString != curSpaceString) {\n replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), \"+input\");\n line.stateAfter = null;\n return true\n } else {\n // Ensure that, if the cursor was in the whitespace at the start\n // of the line, it is moved to the end of that space.\n for (var i$1 = 0; i$1 < doc.sel.ranges.length; i$1++) {\n var range = doc.sel.ranges[i$1];\n if (range.head.line == n && range.head.ch < curSpaceString.length) {\n var pos$1 = Pos(n, curSpaceString.length);\n replaceOneSelection(doc, i$1, new Range(pos$1, pos$1));\n break\n }\n }\n }\n }\n\n // This will be set to a {lineWise: bool, text: [string]} object, so\n // that, when pasting, we know what kind of selections the copied\n // text was made out of.\n var lastCopied = null;\n\n function setLastCopied(newLastCopied) {\n lastCopied = newLastCopied;\n }\n\n function applyTextInput(cm, inserted, deleted, sel, origin) {\n var doc = cm.doc;\n cm.display.shift = false;\n if (!sel) { sel = doc.sel; }\n\n var recent = +new Date - 200;\n var paste = origin == \"paste\" || cm.state.pasteIncoming > recent;\n var textLines = splitLinesAuto(inserted), multiPaste = null;\n // When pasting N lines into N selections, insert one line per selection\n if (paste && sel.ranges.length > 1) {\n if (lastCopied && lastCopied.text.join(\"\\n\") == inserted) {\n if (sel.ranges.length % lastCopied.text.length == 0) {\n multiPaste = [];\n for (var i = 0; i < lastCopied.text.length; i++)\n { multiPaste.push(doc.splitLines(lastCopied.text[i])); }\n }\n } else if (textLines.length == sel.ranges.length && cm.options.pasteLinesPerSelection) {\n multiPaste = map(textLines, function (l) { return [l]; });\n }\n }\n\n var updateInput = cm.curOp.updateInput;\n // Normal behavior is to insert the new text into every selection\n for (var i$1 = sel.ranges.length - 1; i$1 >= 0; i$1--) {\n var range$$1 = sel.ranges[i$1];\n var from = range$$1.from(), to = range$$1.to();\n if (range$$1.empty()) {\n if (deleted && deleted > 0) // Handle deletion\n { from = Pos(from.line, from.ch - deleted); }\n else if (cm.state.overwrite && !paste) // Handle overwrite\n { to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length)); }\n else if (paste && lastCopied && lastCopied.lineWise && lastCopied.text.join(\"\\n\") == inserted)\n { from = to = Pos(from.line, 0); }\n }\n var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i$1 % multiPaste.length] : textLines,\n origin: origin || (paste ? \"paste\" : cm.state.cutIncoming > recent ? \"cut\" : \"+input\")};\n makeChange(cm.doc, changeEvent);\n signalLater(cm, \"inputRead\", cm, changeEvent);\n }\n if (inserted && !paste)\n { triggerElectric(cm, inserted); }\n\n ensureCursorVisible(cm);\n if (cm.curOp.updateInput < 2) { cm.curOp.updateInput = updateInput; }\n cm.curOp.typing = true;\n cm.state.pasteIncoming = cm.state.cutIncoming = -1;\n }\n\n function handlePaste(e, cm) {\n var pasted = e.clipboardData && e.clipboardData.getData(\"Text\");\n if (pasted) {\n e.preventDefault();\n if (!cm.isReadOnly() && !cm.options.disableInput)\n { runInOp(cm, function () { return applyTextInput(cm, pasted, 0, null, \"paste\"); }); }\n return true\n }\n }\n\n function triggerElectric(cm, inserted) {\n // When an 'electric' character is inserted, immediately trigger a reindent\n if (!cm.options.electricChars || !cm.options.smartIndent) { return }\n var sel = cm.doc.sel;\n\n for (var i = sel.ranges.length - 1; i >= 0; i--) {\n var range$$1 = sel.ranges[i];\n if (range$$1.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range$$1.head.line)) { continue }\n var mode = cm.getModeAt(range$$1.head);\n var indented = false;\n if (mode.electricChars) {\n for (var j = 0; j < mode.electricChars.length; j++)\n { if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {\n indented = indentLine(cm, range$$1.head.line, \"smart\");\n break\n } }\n } else if (mode.electricInput) {\n if (mode.electricInput.test(getLine(cm.doc, range$$1.head.line).text.slice(0, range$$1.head.ch)))\n { indented = indentLine(cm, range$$1.head.line, \"smart\"); }\n }\n if (indented) { signalLater(cm, \"electricInput\", cm, range$$1.head.line); }\n }\n }\n\n function copyableRanges(cm) {\n var text = [], ranges = [];\n for (var i = 0; i < cm.doc.sel.ranges.length; i++) {\n var line = cm.doc.sel.ranges[i].head.line;\n var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)};\n ranges.push(lineRange);\n text.push(cm.getRange(lineRange.anchor, lineRange.head));\n }\n return {text: text, ranges: ranges}\n }\n\n function disableBrowserMagic(field, spellcheck, autocorrect, autocapitalize) {\n field.setAttribute(\"autocorrect\", autocorrect ? \"\" : \"off\");\n field.setAttribute(\"autocapitalize\", autocapitalize ? \"\" : \"off\");\n field.setAttribute(\"spellcheck\", !!spellcheck);\n }\n\n function hiddenTextarea() {\n var te = elt(\"textarea\", null, null, \"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none\");\n var div = elt(\"div\", [te], null, \"overflow: hidden; position: relative; width: 3px; height: 0px;\");\n // The textarea is kept positioned near the cursor to prevent the\n // fact that it'll be scrolled into view on input from scrolling\n // our fake cursor out of view. On webkit, when wrap=off, paste is\n // very slow. So make the area wide instead.\n if (webkit) { te.style.width = \"1000px\"; }\n else { te.setAttribute(\"wrap\", \"off\"); }\n // If border: 0; -- iOS fails to open keyboard (issue #1287)\n if (ios) { te.style.border = \"1px solid black\"; }\n disableBrowserMagic(te);\n return div\n }\n\n // The publicly visible API. Note that methodOp(f) means\n // 'wrap f in an operation, performed on its `this` parameter'.\n\n // This is not the complete set of editor methods. Most of the\n // methods defined on the Doc type are also injected into\n // CodeMirror.prototype, for backwards compatibility and\n // convenience.\n\n function addEditorMethods(CodeMirror) {\n var optionHandlers = CodeMirror.optionHandlers;\n\n var helpers = CodeMirror.helpers = {};\n\n CodeMirror.prototype = {\n constructor: CodeMirror,\n focus: function(){window.focus(); this.display.input.focus();},\n\n setOption: function(option, value) {\n var options = this.options, old = options[option];\n if (options[option] == value && option != \"mode\") { return }\n options[option] = value;\n if (optionHandlers.hasOwnProperty(option))\n { operation(this, optionHandlers[option])(this, value, old); }\n signal(this, \"optionChange\", this, option);\n },\n\n getOption: function(option) {return this.options[option]},\n getDoc: function() {return this.doc},\n\n addKeyMap: function(map$$1, bottom) {\n this.state.keyMaps[bottom ? \"push\" : \"unshift\"](getKeyMap(map$$1));\n },\n removeKeyMap: function(map$$1) {\n var maps = this.state.keyMaps;\n for (var i = 0; i < maps.length; ++i)\n { if (maps[i] == map$$1 || maps[i].name == map$$1) {\n maps.splice(i, 1);\n return true\n } }\n },\n\n addOverlay: methodOp(function(spec, options) {\n var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec);\n if (mode.startState) { throw new Error(\"Overlays may not be stateful.\") }\n insertSorted(this.state.overlays,\n {mode: mode, modeSpec: spec, opaque: options && options.opaque,\n priority: (options && options.priority) || 0},\n function (overlay) { return overlay.priority; });\n this.state.modeGen++;\n regChange(this);\n }),\n removeOverlay: methodOp(function(spec) {\n var this$1 = this;\n\n var overlays = this.state.overlays;\n for (var i = 0; i < overlays.length; ++i) {\n var cur = overlays[i].modeSpec;\n if (cur == spec || typeof spec == \"string\" && cur.name == spec) {\n overlays.splice(i, 1);\n this$1.state.modeGen++;\n regChange(this$1);\n return\n }\n }\n }),\n\n indentLine: methodOp(function(n, dir, aggressive) {\n if (typeof dir != \"string\" && typeof dir != \"number\") {\n if (dir == null) { dir = this.options.smartIndent ? \"smart\" : \"prev\"; }\n else { dir = dir ? \"add\" : \"subtract\"; }\n }\n if (isLine(this.doc, n)) { indentLine(this, n, dir, aggressive); }\n }),\n indentSelection: methodOp(function(how) {\n var this$1 = this;\n\n var ranges = this.doc.sel.ranges, end = -1;\n for (var i = 0; i < ranges.length; i++) {\n var range$$1 = ranges[i];\n if (!range$$1.empty()) {\n var from = range$$1.from(), to = range$$1.to();\n var start = Math.max(end, from.line);\n end = Math.min(this$1.lastLine(), to.line - (to.ch ? 0 : 1)) + 1;\n for (var j = start; j < end; ++j)\n { indentLine(this$1, j, how); }\n var newRanges = this$1.doc.sel.ranges;\n if (from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0)\n { replaceOneSelection(this$1.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll); }\n } else if (range$$1.head.line > end) {\n indentLine(this$1, range$$1.head.line, how, true);\n end = range$$1.head.line;\n if (i == this$1.doc.sel.primIndex) { ensureCursorVisible(this$1); }\n }\n }\n }),\n\n // Fetch the parser token for a given character. Useful for hacks\n // that want to inspect the mode state (say, for completion).\n getTokenAt: function(pos, precise) {\n return takeToken(this, pos, precise)\n },\n\n getLineTokens: function(line, precise) {\n return takeToken(this, Pos(line), precise, true)\n },\n\n getTokenTypeAt: function(pos) {\n pos = clipPos(this.doc, pos);\n var styles = getLineStyles(this, getLine(this.doc, pos.line));\n var before = 0, after = (styles.length - 1) / 2, ch = pos.ch;\n var type;\n if (ch == 0) { type = styles[2]; }\n else { for (;;) {\n var mid = (before + after) >> 1;\n if ((mid ? styles[mid * 2 - 1] : 0) >= ch) { after = mid; }\n else if (styles[mid * 2 + 1] < ch) { before = mid + 1; }\n else { type = styles[mid * 2 + 2]; break }\n } }\n var cut = type ? type.indexOf(\"overlay \") : -1;\n return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1)\n },\n\n getModeAt: function(pos) {\n var mode = this.doc.mode;\n if (!mode.innerMode) { return mode }\n return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode\n },\n\n getHelper: function(pos, type) {\n return this.getHelpers(pos, type)[0]\n },\n\n getHelpers: function(pos, type) {\n var this$1 = this;\n\n var found = [];\n if (!helpers.hasOwnProperty(type)) { return found }\n var help = helpers[type], mode = this.getModeAt(pos);\n if (typeof mode[type] == \"string\") {\n if (help[mode[type]]) { found.push(help[mode[type]]); }\n } else if (mode[type]) {\n for (var i = 0; i < mode[type].length; i++) {\n var val = help[mode[type][i]];\n if (val) { found.push(val); }\n }\n } else if (mode.helperType && help[mode.helperType]) {\n found.push(help[mode.helperType]);\n } else if (help[mode.name]) {\n found.push(help[mode.name]);\n }\n for (var i$1 = 0; i$1 < help._global.length; i$1++) {\n var cur = help._global[i$1];\n if (cur.pred(mode, this$1) && indexOf(found, cur.val) == -1)\n { found.push(cur.val); }\n }\n return found\n },\n\n getStateAfter: function(line, precise) {\n var doc = this.doc;\n line = clipLine(doc, line == null ? doc.first + doc.size - 1: line);\n return getContextBefore(this, line + 1, precise).state\n },\n\n cursorCoords: function(start, mode) {\n var pos, range$$1 = this.doc.sel.primary();\n if (start == null) { pos = range$$1.head; }\n else if (typeof start == \"object\") { pos = clipPos(this.doc, start); }\n else { pos = start ? range$$1.from() : range$$1.to(); }\n return cursorCoords(this, pos, mode || \"page\")\n },\n\n charCoords: function(pos, mode) {\n return charCoords(this, clipPos(this.doc, pos), mode || \"page\")\n },\n\n coordsChar: function(coords, mode) {\n coords = fromCoordSystem(this, coords, mode || \"page\");\n return coordsChar(this, coords.left, coords.top)\n },\n\n lineAtHeight: function(height, mode) {\n height = fromCoordSystem(this, {top: height, left: 0}, mode || \"page\").top;\n return lineAtHeight(this.doc, height + this.display.viewOffset)\n },\n heightAtLine: function(line, mode, includeWidgets) {\n var end = false, lineObj;\n if (typeof line == \"number\") {\n var last = this.doc.first + this.doc.size - 1;\n if (line < this.doc.first) { line = this.doc.first; }\n else if (line > last) { line = last; end = true; }\n lineObj = getLine(this.doc, line);\n } else {\n lineObj = line;\n }\n return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || \"page\", includeWidgets || end).top +\n (end ? this.doc.height - heightAtLine(lineObj) : 0)\n },\n\n defaultTextHeight: function() { return textHeight(this.display) },\n defaultCharWidth: function() { return charWidth(this.display) },\n\n getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo}},\n\n addWidget: function(pos, node, scroll, vert, horiz) {\n var display = this.display;\n pos = cursorCoords(this, clipPos(this.doc, pos));\n var top = pos.bottom, left = pos.left;\n node.style.position = \"absolute\";\n node.setAttribute(\"cm-ignore-events\", \"true\");\n this.display.input.setUneditable(node);\n display.sizer.appendChild(node);\n if (vert == \"over\") {\n top = pos.top;\n } else if (vert == \"above\" || vert == \"near\") {\n var vspace = Math.max(display.wrapper.clientHeight, this.doc.height),\n hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth);\n // Default to positioning above (if specified and possible); otherwise default to positioning below\n if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight)\n { top = pos.top - node.offsetHeight; }\n else if (pos.bottom + node.offsetHeight <= vspace)\n { top = pos.bottom; }\n if (left + node.offsetWidth > hspace)\n { left = hspace - node.offsetWidth; }\n }\n node.style.top = top + \"px\";\n node.style.left = node.style.right = \"\";\n if (horiz == \"right\") {\n left = display.sizer.clientWidth - node.offsetWidth;\n node.style.right = \"0px\";\n } else {\n if (horiz == \"left\") { left = 0; }\n else if (horiz == \"middle\") { left = (display.sizer.clientWidth - node.offsetWidth) / 2; }\n node.style.left = left + \"px\";\n }\n if (scroll)\n { scrollIntoView(this, {left: left, top: top, right: left + node.offsetWidth, bottom: top + node.offsetHeight}); }\n },\n\n triggerOnKeyDown: methodOp(onKeyDown),\n triggerOnKeyPress: methodOp(onKeyPress),\n triggerOnKeyUp: onKeyUp,\n triggerOnMouseDown: methodOp(onMouseDown),\n\n execCommand: function(cmd) {\n if (commands.hasOwnProperty(cmd))\n { return commands[cmd].call(null, this) }\n },\n\n triggerElectric: methodOp(function(text) { triggerElectric(this, text); }),\n\n findPosH: function(from, amount, unit, visually) {\n var this$1 = this;\n\n var dir = 1;\n if (amount < 0) { dir = -1; amount = -amount; }\n var cur = clipPos(this.doc, from);\n for (var i = 0; i < amount; ++i) {\n cur = findPosH(this$1.doc, cur, dir, unit, visually);\n if (cur.hitSide) { break }\n }\n return cur\n },\n\n moveH: methodOp(function(dir, unit) {\n var this$1 = this;\n\n this.extendSelectionsBy(function (range$$1) {\n if (this$1.display.shift || this$1.doc.extend || range$$1.empty())\n { return findPosH(this$1.doc, range$$1.head, dir, unit, this$1.options.rtlMoveVisually) }\n else\n { return dir < 0 ? range$$1.from() : range$$1.to() }\n }, sel_move);\n }),\n\n deleteH: methodOp(function(dir, unit) {\n var sel = this.doc.sel, doc = this.doc;\n if (sel.somethingSelected())\n { doc.replaceSelection(\"\", null, \"+delete\"); }\n else\n { deleteNearSelection(this, function (range$$1) {\n var other = findPosH(doc, range$$1.head, dir, unit, false);\n return dir < 0 ? {from: other, to: range$$1.head} : {from: range$$1.head, to: other}\n }); }\n }),\n\n findPosV: function(from, amount, unit, goalColumn) {\n var this$1 = this;\n\n var dir = 1, x = goalColumn;\n if (amount < 0) { dir = -1; amount = -amount; }\n var cur = clipPos(this.doc, from);\n for (var i = 0; i < amount; ++i) {\n var coords = cursorCoords(this$1, cur, \"div\");\n if (x == null) { x = coords.left; }\n else { coords.left = x; }\n cur = findPosV(this$1, coords, dir, unit);\n if (cur.hitSide) { break }\n }\n return cur\n },\n\n moveV: methodOp(function(dir, unit) {\n var this$1 = this;\n\n var doc = this.doc, goals = [];\n var collapse = !this.display.shift && !doc.extend && doc.sel.somethingSelected();\n doc.extendSelectionsBy(function (range$$1) {\n if (collapse)\n { return dir < 0 ? range$$1.from() : range$$1.to() }\n var headPos = cursorCoords(this$1, range$$1.head, \"div\");\n if (range$$1.goalColumn != null) { headPos.left = range$$1.goalColumn; }\n goals.push(headPos.left);\n var pos = findPosV(this$1, headPos, dir, unit);\n if (unit == \"page\" && range$$1 == doc.sel.primary())\n { addToScrollTop(this$1, charCoords(this$1, pos, \"div\").top - headPos.top); }\n return pos\n }, sel_move);\n if (goals.length) { for (var i = 0; i < doc.sel.ranges.length; i++)\n { doc.sel.ranges[i].goalColumn = goals[i]; } }\n }),\n\n // Find the word at the given position (as returned by coordsChar).\n findWordAt: function(pos) {\n var doc = this.doc, line = getLine(doc, pos.line).text;\n var start = pos.ch, end = pos.ch;\n if (line) {\n var helper = this.getHelper(pos, \"wordChars\");\n if ((pos.sticky == \"before\" || end == line.length) && start) { --start; } else { ++end; }\n var startChar = line.charAt(start);\n var check = isWordChar(startChar, helper)\n ? function (ch) { return isWordChar(ch, helper); }\n : /\\s/.test(startChar) ? function (ch) { return /\\s/.test(ch); }\n : function (ch) { return (!/\\s/.test(ch) && !isWordChar(ch)); };\n while (start > 0 && check(line.charAt(start - 1))) { --start; }\n while (end < line.length && check(line.charAt(end))) { ++end; }\n }\n return new Range(Pos(pos.line, start), Pos(pos.line, end))\n },\n\n toggleOverwrite: function(value) {\n if (value != null && value == this.state.overwrite) { return }\n if (this.state.overwrite = !this.state.overwrite)\n { addClass(this.display.cursorDiv, \"CodeMirror-overwrite\"); }\n else\n { rmClass(this.display.cursorDiv, \"CodeMirror-overwrite\"); }\n\n signal(this, \"overwriteToggle\", this, this.state.overwrite);\n },\n hasFocus: function() { return this.display.input.getField() == activeElt() },\n isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit) },\n\n scrollTo: methodOp(function (x, y) { scrollToCoords(this, x, y); }),\n getScrollInfo: function() {\n var scroller = this.display.scroller;\n return {left: scroller.scrollLeft, top: scroller.scrollTop,\n height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight,\n width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth,\n clientHeight: displayHeight(this), clientWidth: displayWidth(this)}\n },\n\n scrollIntoView: methodOp(function(range$$1, margin) {\n if (range$$1 == null) {\n range$$1 = {from: this.doc.sel.primary().head, to: null};\n if (margin == null) { margin = this.options.cursorScrollMargin; }\n } else if (typeof range$$1 == \"number\") {\n range$$1 = {from: Pos(range$$1, 0), to: null};\n } else if (range$$1.from == null) {\n range$$1 = {from: range$$1, to: null};\n }\n if (!range$$1.to) { range$$1.to = range$$1.from; }\n range$$1.margin = margin || 0;\n\n if (range$$1.from.line != null) {\n scrollToRange(this, range$$1);\n } else {\n scrollToCoordsRange(this, range$$1.from, range$$1.to, range$$1.margin);\n }\n }),\n\n setSize: methodOp(function(width, height) {\n var this$1 = this;\n\n var interpret = function (val) { return typeof val == \"number\" || /^\\d+$/.test(String(val)) ? val + \"px\" : val; };\n if (width != null) { this.display.wrapper.style.width = interpret(width); }\n if (height != null) { this.display.wrapper.style.height = interpret(height); }\n if (this.options.lineWrapping) { clearLineMeasurementCache(this); }\n var lineNo$$1 = this.display.viewFrom;\n this.doc.iter(lineNo$$1, this.display.viewTo, function (line) {\n if (line.widgets) { for (var i = 0; i < line.widgets.length; i++)\n { if (line.widgets[i].noHScroll) { regLineChange(this$1, lineNo$$1, \"widget\"); break } } }\n ++lineNo$$1;\n });\n this.curOp.forceUpdate = true;\n signal(this, \"refresh\", this);\n }),\n\n operation: function(f){return runInOp(this, f)},\n startOperation: function(){return startOperation(this)},\n endOperation: function(){return endOperation(this)},\n\n refresh: methodOp(function() {\n var oldHeight = this.display.cachedTextHeight;\n regChange(this);\n this.curOp.forceUpdate = true;\n clearCaches(this);\n scrollToCoords(this, this.doc.scrollLeft, this.doc.scrollTop);\n updateGutterSpace(this.display);\n if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5)\n { estimateLineHeights(this); }\n signal(this, \"refresh\", this);\n }),\n\n swapDoc: methodOp(function(doc) {\n var old = this.doc;\n old.cm = null;\n // Cancel the current text selection if any (#5821)\n if (this.state.selectingText) { this.state.selectingText(); }\n attachDoc(this, doc);\n clearCaches(this);\n this.display.input.reset();\n scrollToCoords(this, doc.scrollLeft, doc.scrollTop);\n this.curOp.forceScroll = true;\n signalLater(this, \"swapDoc\", this, old);\n return old\n }),\n\n phrase: function(phraseText) {\n var phrases = this.options.phrases;\n return phrases && Object.prototype.hasOwnProperty.call(phrases, phraseText) ? phrases[phraseText] : phraseText\n },\n\n getInputField: function(){return this.display.input.getField()},\n getWrapperElement: function(){return this.display.wrapper},\n getScrollerElement: function(){return this.display.scroller},\n getGutterElement: function(){return this.display.gutters}\n };\n eventMixin(CodeMirror);\n\n CodeMirror.registerHelper = function(type, name, value) {\n if (!helpers.hasOwnProperty(type)) { helpers[type] = CodeMirror[type] = {_global: []}; }\n helpers[type][name] = value;\n };\n CodeMirror.registerGlobalHelper = function(type, name, predicate, value) {\n CodeMirror.registerHelper(type, name, value);\n helpers[type]._global.push({pred: predicate, val: value});\n };\n }\n\n // Used for horizontal relative motion. Dir is -1 or 1 (left or\n // right), unit can be \"char\", \"column\" (like char, but doesn't\n // cross line boundaries), \"word\" (across next word), or \"group\" (to\n // the start of next group of word or non-word-non-whitespace\n // chars). The visually param controls whether, in right-to-left\n // text, direction 1 means to move towards the next index in the\n // string, or towards the character to the right of the current\n // position. The resulting position will have a hitSide=true\n // property if it reached the end of the document.\n function findPosH(doc, pos, dir, unit, visually) {\n var oldPos = pos;\n var origDir = dir;\n var lineObj = getLine(doc, pos.line);\n function findNextLine() {\n var l = pos.line + dir;\n if (l < doc.first || l >= doc.first + doc.size) { return false }\n pos = new Pos(l, pos.ch, pos.sticky);\n return lineObj = getLine(doc, l)\n }\n function moveOnce(boundToLine) {\n var next;\n if (visually) {\n next = moveVisually(doc.cm, lineObj, pos, dir);\n } else {\n next = moveLogically(lineObj, pos, dir);\n }\n if (next == null) {\n if (!boundToLine && findNextLine())\n { pos = endOfLine(visually, doc.cm, lineObj, pos.line, dir); }\n else\n { return false }\n } else {\n pos = next;\n }\n return true\n }\n\n if (unit == \"char\") {\n moveOnce();\n } else if (unit == \"column\") {\n moveOnce(true);\n } else if (unit == \"word\" || unit == \"group\") {\n var sawType = null, group = unit == \"group\";\n var helper = doc.cm && doc.cm.getHelper(pos, \"wordChars\");\n for (var first = true;; first = false) {\n if (dir < 0 && !moveOnce(!first)) { break }\n var cur = lineObj.text.charAt(pos.ch) || \"\\n\";\n var type = isWordChar(cur, helper) ? \"w\"\n : group && cur == \"\\n\" ? \"n\"\n : !group || /\\s/.test(cur) ? null\n : \"p\";\n if (group && !first && !type) { type = \"s\"; }\n if (sawType && sawType != type) {\n if (dir < 0) {dir = 1; moveOnce(); pos.sticky = \"after\";}\n break\n }\n\n if (type) { sawType = type; }\n if (dir > 0 && !moveOnce(!first)) { break }\n }\n }\n var result = skipAtomic(doc, pos, oldPos, origDir, true);\n if (equalCursorPos(oldPos, result)) { result.hitSide = true; }\n return result\n }\n\n // For relative vertical movement. Dir may be -1 or 1. Unit can be\n // \"page\" or \"line\". The resulting position will have a hitSide=true\n // property if it reached the end of the document.\n function findPosV(cm, pos, dir, unit) {\n var doc = cm.doc, x = pos.left, y;\n if (unit == \"page\") {\n var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);\n var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3);\n y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount;\n\n } else if (unit == \"line\") {\n y = dir > 0 ? pos.bottom + 3 : pos.top - 3;\n }\n var target;\n for (;;) {\n target = coordsChar(cm, x, y);\n if (!target.outside) { break }\n if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break }\n y += dir * 5;\n }\n return target\n }\n\n // CONTENTEDITABLE INPUT STYLE\n\n var ContentEditableInput = function(cm) {\n this.cm = cm;\n this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null;\n this.polling = new Delayed();\n this.composing = null;\n this.gracePeriod = false;\n this.readDOMTimeout = null;\n };\n\n ContentEditableInput.prototype.init = function (display) {\n var this$1 = this;\n\n var input = this, cm = input.cm;\n var div = input.div = display.lineDiv;\n disableBrowserMagic(div, cm.options.spellcheck, cm.options.autocorrect, cm.options.autocapitalize);\n\n on(div, \"paste\", function (e) {\n if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }\n // IE doesn't fire input events, so we schedule a read for the pasted content in this way\n if (ie_version <= 11) { setTimeout(operation(cm, function () { return this$1.updateFromDOM(); }), 20); }\n });\n\n on(div, \"compositionstart\", function (e) {\n this$1.composing = {data: e.data, done: false};\n });\n on(div, \"compositionupdate\", function (e) {\n if (!this$1.composing) { this$1.composing = {data: e.data, done: false}; }\n });\n on(div, \"compositionend\", function (e) {\n if (this$1.composing) {\n if (e.data != this$1.composing.data) { this$1.readFromDOMSoon(); }\n this$1.composing.done = true;\n }\n });\n\n on(div, \"touchstart\", function () { return input.forceCompositionEnd(); });\n\n on(div, \"input\", function () {\n if (!this$1.composing) { this$1.readFromDOMSoon(); }\n });\n\n function onCopyCut(e) {\n if (signalDOMEvent(cm, e)) { return }\n if (cm.somethingSelected()) {\n setLastCopied({lineWise: false, text: cm.getSelections()});\n if (e.type == \"cut\") { cm.replaceSelection(\"\", null, \"cut\"); }\n } else if (!cm.options.lineWiseCopyCut) {\n return\n } else {\n var ranges = copyableRanges(cm);\n setLastCopied({lineWise: true, text: ranges.text});\n if (e.type == \"cut\") {\n cm.operation(function () {\n cm.setSelections(ranges.ranges, 0, sel_dontScroll);\n cm.replaceSelection(\"\", null, \"cut\");\n });\n }\n }\n if (e.clipboardData) {\n e.clipboardData.clearData();\n var content = lastCopied.text.join(\"\\n\");\n // iOS exposes the clipboard API, but seems to discard content inserted into it\n e.clipboardData.setData(\"Text\", content);\n if (e.clipboardData.getData(\"Text\") == content) {\n e.preventDefault();\n return\n }\n }\n // Old-fashioned briefly-focus-a-textarea hack\n var kludge = hiddenTextarea(), te = kludge.firstChild;\n cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);\n te.value = lastCopied.text.join(\"\\n\");\n var hadFocus = document.activeElement;\n selectInput(te);\n setTimeout(function () {\n cm.display.lineSpace.removeChild(kludge);\n hadFocus.focus();\n if (hadFocus == div) { input.showPrimarySelection(); }\n }, 50);\n }\n on(div, \"copy\", onCopyCut);\n on(div, \"cut\", onCopyCut);\n };\n\n ContentEditableInput.prototype.prepareSelection = function () {\n var result = prepareSelection(this.cm, false);\n result.focus = this.cm.state.focused;\n return result\n };\n\n ContentEditableInput.prototype.showSelection = function (info, takeFocus) {\n if (!info || !this.cm.display.view.length) { return }\n if (info.focus || takeFocus) { this.showPrimarySelection(); }\n this.showMultipleSelections(info);\n };\n\n ContentEditableInput.prototype.getSelection = function () {\n return this.cm.display.wrapper.ownerDocument.getSelection()\n };\n\n ContentEditableInput.prototype.showPrimarySelection = function () {\n var sel = this.getSelection(), cm = this.cm, prim = cm.doc.sel.primary();\n var from = prim.from(), to = prim.to();\n\n if (cm.display.viewTo == cm.display.viewFrom || from.line >= cm.display.viewTo || to.line < cm.display.viewFrom) {\n sel.removeAllRanges();\n return\n }\n\n var curAnchor = domToPos(cm, sel.anchorNode, sel.anchorOffset);\n var curFocus = domToPos(cm, sel.focusNode, sel.focusOffset);\n if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad &&\n cmp(minPos(curAnchor, curFocus), from) == 0 &&\n cmp(maxPos(curAnchor, curFocus), to) == 0)\n { return }\n\n var view = cm.display.view;\n var start = (from.line >= cm.display.viewFrom && posToDOM(cm, from)) ||\n {node: view[0].measure.map[2], offset: 0};\n var end = to.line < cm.display.viewTo && posToDOM(cm, to);\n if (!end) {\n var measure = view[view.length - 1].measure;\n var map$$1 = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map;\n end = {node: map$$1[map$$1.length - 1], offset: map$$1[map$$1.length - 2] - map$$1[map$$1.length - 3]};\n }\n\n if (!start || !end) {\n sel.removeAllRanges();\n return\n }\n\n var old = sel.rangeCount && sel.getRangeAt(0), rng;\n try { rng = range(start.node, start.offset, end.offset, end.node); }\n catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible\n if (rng) {\n if (!gecko && cm.state.focused) {\n sel.collapse(start.node, start.offset);\n if (!rng.collapsed) {\n sel.removeAllRanges();\n sel.addRange(rng);\n }\n } else {\n sel.removeAllRanges();\n sel.addRange(rng);\n }\n if (old && sel.anchorNode == null) { sel.addRange(old); }\n else if (gecko) { this.startGracePeriod(); }\n }\n this.rememberSelection();\n };\n\n ContentEditableInput.prototype.startGracePeriod = function () {\n var this$1 = this;\n\n clearTimeout(this.gracePeriod);\n this.gracePeriod = setTimeout(function () {\n this$1.gracePeriod = false;\n if (this$1.selectionChanged())\n { this$1.cm.operation(function () { return this$1.cm.curOp.selectionChanged = true; }); }\n }, 20);\n };\n\n ContentEditableInput.prototype.showMultipleSelections = function (info) {\n removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors);\n removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection);\n };\n\n ContentEditableInput.prototype.rememberSelection = function () {\n var sel = this.getSelection();\n this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset;\n this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset;\n };\n\n ContentEditableInput.prototype.selectionInEditor = function () {\n var sel = this.getSelection();\n if (!sel.rangeCount) { return false }\n var node = sel.getRangeAt(0).commonAncestorContainer;\n return contains(this.div, node)\n };\n\n ContentEditableInput.prototype.focus = function () {\n if (this.cm.options.readOnly != \"nocursor\") {\n if (!this.selectionInEditor())\n { this.showSelection(this.prepareSelection(), true); }\n this.div.focus();\n }\n };\n ContentEditableInput.prototype.blur = function () { this.div.blur(); };\n ContentEditableInput.prototype.getField = function () { return this.div };\n\n ContentEditableInput.prototype.supportsTouch = function () { return true };\n\n ContentEditableInput.prototype.receivedFocus = function () {\n var input = this;\n if (this.selectionInEditor())\n { this.pollSelection(); }\n else\n { runInOp(this.cm, function () { return input.cm.curOp.selectionChanged = true; }); }\n\n function poll() {\n if (input.cm.state.focused) {\n input.pollSelection();\n input.polling.set(input.cm.options.pollInterval, poll);\n }\n }\n this.polling.set(this.cm.options.pollInterval, poll);\n };\n\n ContentEditableInput.prototype.selectionChanged = function () {\n var sel = this.getSelection();\n return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset ||\n sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset\n };\n\n ContentEditableInput.prototype.pollSelection = function () {\n if (this.readDOMTimeout != null || this.gracePeriod || !this.selectionChanged()) { return }\n var sel = this.getSelection(), cm = this.cm;\n // On Android Chrome (version 56, at least), backspacing into an\n // uneditable block element will put the cursor in that element,\n // and then, because it's not editable, hide the virtual keyboard.\n // Because Android doesn't allow us to actually detect backspace\n // presses in a sane way, this code checks for when that happens\n // and simulates a backspace press in this case.\n if (android && chrome && this.cm.display.gutterSpecs.length && isInGutter(sel.anchorNode)) {\n this.cm.triggerOnKeyDown({type: \"keydown\", keyCode: 8, preventDefault: Math.abs});\n this.blur();\n this.focus();\n return\n }\n if (this.composing) { return }\n this.rememberSelection();\n var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset);\n var head = domToPos(cm, sel.focusNode, sel.focusOffset);\n if (anchor && head) { runInOp(cm, function () {\n setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll);\n if (anchor.bad || head.bad) { cm.curOp.selectionChanged = true; }\n }); }\n };\n\n ContentEditableInput.prototype.pollContent = function () {\n if (this.readDOMTimeout != null) {\n clearTimeout(this.readDOMTimeout);\n this.readDOMTimeout = null;\n }\n\n var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary();\n var from = sel.from(), to = sel.to();\n if (from.ch == 0 && from.line > cm.firstLine())\n { from = Pos(from.line - 1, getLine(cm.doc, from.line - 1).length); }\n if (to.ch == getLine(cm.doc, to.line).text.length && to.line < cm.lastLine())\n { to = Pos(to.line + 1, 0); }\n if (from.line < display.viewFrom || to.line > display.viewTo - 1) { return false }\n\n var fromIndex, fromLine, fromNode;\n if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) {\n fromLine = lineNo(display.view[0].line);\n fromNode = display.view[0].node;\n } else {\n fromLine = lineNo(display.view[fromIndex].line);\n fromNode = display.view[fromIndex - 1].node.nextSibling;\n }\n var toIndex = findViewIndex(cm, to.line);\n var toLine, toNode;\n if (toIndex == display.view.length - 1) {\n toLine = display.viewTo - 1;\n toNode = display.lineDiv.lastChild;\n } else {\n toLine = lineNo(display.view[toIndex + 1].line) - 1;\n toNode = display.view[toIndex + 1].node.previousSibling;\n }\n\n if (!fromNode) { return false }\n var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine));\n var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length));\n while (newText.length > 1 && oldText.length > 1) {\n if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; }\n else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++; }\n else { break }\n }\n\n var cutFront = 0, cutEnd = 0;\n var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length);\n while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront))\n { ++cutFront; }\n var newBot = lst(newText), oldBot = lst(oldText);\n var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0),\n oldBot.length - (oldText.length == 1 ? cutFront : 0));\n while (cutEnd < maxCutEnd &&\n newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1))\n { ++cutEnd; }\n // Try to move start of change to start of selection if ambiguous\n if (newText.length == 1 && oldText.length == 1 && fromLine == from.line) {\n while (cutFront && cutFront > from.ch &&\n newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1)) {\n cutFront--;\n cutEnd++;\n }\n }\n\n newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd).replace(/^\\u200b+/, \"\");\n newText[0] = newText[0].slice(cutFront).replace(/\\u200b+$/, \"\");\n\n var chFrom = Pos(fromLine, cutFront);\n var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0);\n if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) {\n replaceRange(cm.doc, newText, chFrom, chTo, \"+input\");\n return true\n }\n };\n\n ContentEditableInput.prototype.ensurePolled = function () {\n this.forceCompositionEnd();\n };\n ContentEditableInput.prototype.reset = function () {\n this.forceCompositionEnd();\n };\n ContentEditableInput.prototype.forceCompositionEnd = function () {\n if (!this.composing) { return }\n clearTimeout(this.readDOMTimeout);\n this.composing = null;\n this.updateFromDOM();\n this.div.blur();\n this.div.focus();\n };\n ContentEditableInput.prototype.readFromDOMSoon = function () {\n var this$1 = this;\n\n if (this.readDOMTimeout != null) { return }\n this.readDOMTimeout = setTimeout(function () {\n this$1.readDOMTimeout = null;\n if (this$1.composing) {\n if (this$1.composing.done) { this$1.composing = null; }\n else { return }\n }\n this$1.updateFromDOM();\n }, 80);\n };\n\n ContentEditableInput.prototype.updateFromDOM = function () {\n var this$1 = this;\n\n if (this.cm.isReadOnly() || !this.pollContent())\n { runInOp(this.cm, function () { return regChange(this$1.cm); }); }\n };\n\n ContentEditableInput.prototype.setUneditable = function (node) {\n node.contentEditable = \"false\";\n };\n\n ContentEditableInput.prototype.onKeyPress = function (e) {\n if (e.charCode == 0 || this.composing) { return }\n e.preventDefault();\n if (!this.cm.isReadOnly())\n { operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0); }\n };\n\n ContentEditableInput.prototype.readOnlyChanged = function (val) {\n this.div.contentEditable = String(val != \"nocursor\");\n };\n\n ContentEditableInput.prototype.onContextMenu = function () {};\n ContentEditableInput.prototype.resetPosition = function () {};\n\n ContentEditableInput.prototype.needsContentAttribute = true;\n\n function posToDOM(cm, pos) {\n var view = findViewForLine(cm, pos.line);\n if (!view || view.hidden) { return null }\n var line = getLine(cm.doc, pos.line);\n var info = mapFromLineView(view, line, pos.line);\n\n var order = getOrder(line, cm.doc.direction), side = \"left\";\n if (order) {\n var partPos = getBidiPartAt(order, pos.ch);\n side = partPos % 2 ? \"right\" : \"left\";\n }\n var result = nodeAndOffsetInLineMap(info.map, pos.ch, side);\n result.offset = result.collapse == \"right\" ? result.end : result.start;\n return result\n }\n\n function isInGutter(node) {\n for (var scan = node; scan; scan = scan.parentNode)\n { if (/CodeMirror-gutter-wrapper/.test(scan.className)) { return true } }\n return false\n }\n\n function badPos(pos, bad) { if (bad) { pos.bad = true; } return pos }\n\n function domTextBetween(cm, from, to, fromLine, toLine) {\n var text = \"\", closing = false, lineSep = cm.doc.lineSeparator(), extraLinebreak = false;\n function recognizeMarker(id) { return function (marker) { return marker.id == id; } }\n function close() {\n if (closing) {\n text += lineSep;\n if (extraLinebreak) { text += lineSep; }\n closing = extraLinebreak = false;\n }\n }\n function addText(str) {\n if (str) {\n close();\n text += str;\n }\n }\n function walk(node) {\n if (node.nodeType == 1) {\n var cmText = node.getAttribute(\"cm-text\");\n if (cmText) {\n addText(cmText);\n return\n }\n var markerID = node.getAttribute(\"cm-marker\"), range$$1;\n if (markerID) {\n var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));\n if (found.length && (range$$1 = found[0].find(0)))\n { addText(getBetween(cm.doc, range$$1.from, range$$1.to).join(lineSep)); }\n return\n }\n if (node.getAttribute(\"contenteditable\") == \"false\") { return }\n var isBlock = /^(pre|div|p|li|table|br)$/i.test(node.nodeName);\n if (!/^br$/i.test(node.nodeName) && node.textContent.length == 0) { return }\n\n if (isBlock) { close(); }\n for (var i = 0; i < node.childNodes.length; i++)\n { walk(node.childNodes[i]); }\n\n if (/^(pre|p)$/i.test(node.nodeName)) { extraLinebreak = true; }\n if (isBlock) { closing = true; }\n } else if (node.nodeType == 3) {\n addText(node.nodeValue.replace(/\\u200b/g, \"\").replace(/\\u00a0/g, \" \"));\n }\n }\n for (;;) {\n walk(from);\n if (from == to) { break }\n from = from.nextSibling;\n extraLinebreak = false;\n }\n return text\n }\n\n function domToPos(cm, node, offset) {\n var lineNode;\n if (node == cm.display.lineDiv) {\n lineNode = cm.display.lineDiv.childNodes[offset];\n if (!lineNode) { return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true) }\n node = null; offset = 0;\n } else {\n for (lineNode = node;; lineNode = lineNode.parentNode) {\n if (!lineNode || lineNode == cm.display.lineDiv) { return null }\n if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) { break }\n }\n }\n for (var i = 0; i < cm.display.view.length; i++) {\n var lineView = cm.display.view[i];\n if (lineView.node == lineNode)\n { return locateNodeInLineView(lineView, node, offset) }\n }\n }\n\n function locateNodeInLineView(lineView, node, offset) {\n var wrapper = lineView.text.firstChild, bad = false;\n if (!node || !contains(wrapper, node)) { return badPos(Pos(lineNo(lineView.line), 0), true) }\n if (node == wrapper) {\n bad = true;\n node = wrapper.childNodes[offset];\n offset = 0;\n if (!node) {\n var line = lineView.rest ? lst(lineView.rest) : lineView.line;\n return badPos(Pos(lineNo(line), line.text.length), bad)\n }\n }\n\n var textNode = node.nodeType == 3 ? node : null, topNode = node;\n if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) {\n textNode = node.firstChild;\n if (offset) { offset = textNode.nodeValue.length; }\n }\n while (topNode.parentNode != wrapper) { topNode = topNode.parentNode; }\n var measure = lineView.measure, maps = measure.maps;\n\n function find(textNode, topNode, offset) {\n for (var i = -1; i < (maps ? maps.length : 0); i++) {\n var map$$1 = i < 0 ? measure.map : maps[i];\n for (var j = 0; j < map$$1.length; j += 3) {\n var curNode = map$$1[j + 2];\n if (curNode == textNode || curNode == topNode) {\n var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]);\n var ch = map$$1[j] + offset;\n if (offset < 0 || curNode != textNode) { ch = map$$1[j + (offset ? 1 : 0)]; }\n return Pos(line, ch)\n }\n }\n }\n }\n var found = find(textNode, topNode, offset);\n if (found) { return badPos(found, bad) }\n\n // FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems\n for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) {\n found = find(after, after.firstChild, 0);\n if (found)\n { return badPos(Pos(found.line, found.ch - dist), bad) }\n else\n { dist += after.textContent.length; }\n }\n for (var before = topNode.previousSibling, dist$1 = offset; before; before = before.previousSibling) {\n found = find(before, before.firstChild, -1);\n if (found)\n { return badPos(Pos(found.line, found.ch + dist$1), bad) }\n else\n { dist$1 += before.textContent.length; }\n }\n }\n\n // TEXTAREA INPUT STYLE\n\n var TextareaInput = function(cm) {\n this.cm = cm;\n // See input.poll and input.reset\n this.prevInput = \"\";\n\n // Flag that indicates whether we expect input to appear real soon\n // now (after some event like 'keypress' or 'input') and are\n // polling intensively.\n this.pollingFast = false;\n // Self-resetting timeout for the poller\n this.polling = new Delayed();\n // Used to work around IE issue with selection being forgotten when focus moves away from textarea\n this.hasSelection = false;\n this.composing = null;\n };\n\n TextareaInput.prototype.init = function (display) {\n var this$1 = this;\n\n var input = this, cm = this.cm;\n this.createField(display);\n var te = this.textarea;\n\n display.wrapper.insertBefore(this.wrapper, display.wrapper.firstChild);\n\n // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)\n if (ios) { te.style.width = \"0px\"; }\n\n on(te, \"input\", function () {\n if (ie && ie_version >= 9 && this$1.hasSelection) { this$1.hasSelection = null; }\n input.poll();\n });\n\n on(te, \"paste\", function (e) {\n if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }\n\n cm.state.pasteIncoming = +new Date;\n input.fastPoll();\n });\n\n function prepareCopyCut(e) {\n if (signalDOMEvent(cm, e)) { return }\n if (cm.somethingSelected()) {\n setLastCopied({lineWise: false, text: cm.getSelections()});\n } else if (!cm.options.lineWiseCopyCut) {\n return\n } else {\n var ranges = copyableRanges(cm);\n setLastCopied({lineWise: true, text: ranges.text});\n if (e.type == \"cut\") {\n cm.setSelections(ranges.ranges, null, sel_dontScroll);\n } else {\n input.prevInput = \"\";\n te.value = ranges.text.join(\"\\n\");\n selectInput(te);\n }\n }\n if (e.type == \"cut\") { cm.state.cutIncoming = +new Date; }\n }\n on(te, \"cut\", prepareCopyCut);\n on(te, \"copy\", prepareCopyCut);\n\n on(display.scroller, \"paste\", function (e) {\n if (eventInWidget(display, e) || signalDOMEvent(cm, e)) { return }\n if (!te.dispatchEvent) {\n cm.state.pasteIncoming = +new Date;\n input.focus();\n return\n }\n\n // Pass the `paste` event to the textarea so it's handled by its event listener.\n var event = new Event(\"paste\");\n event.clipboardData = e.clipboardData;\n te.dispatchEvent(event);\n });\n\n // Prevent normal selection in the editor (we handle our own)\n on(display.lineSpace, \"selectstart\", function (e) {\n if (!eventInWidget(display, e)) { e_preventDefault(e); }\n });\n\n on(te, \"compositionstart\", function () {\n var start = cm.getCursor(\"from\");\n if (input.composing) { input.composing.range.clear(); }\n input.composing = {\n start: start,\n range: cm.markText(start, cm.getCursor(\"to\"), {className: \"CodeMirror-composing\"})\n };\n });\n on(te, \"compositionend\", function () {\n if (input.composing) {\n input.poll();\n input.composing.range.clear();\n input.composing = null;\n }\n });\n };\n\n TextareaInput.prototype.createField = function (_display) {\n // Wraps and hides input textarea\n this.wrapper = hiddenTextarea();\n // The semihidden textarea that is focused when the editor is\n // focused, and receives input.\n this.textarea = this.wrapper.firstChild;\n };\n\n TextareaInput.prototype.prepareSelection = function () {\n // Redraw the selection and/or cursor\n var cm = this.cm, display = cm.display, doc = cm.doc;\n var result = prepareSelection(cm);\n\n // Move the hidden textarea near the cursor to prevent scrolling artifacts\n if (cm.options.moveInputWithCursor) {\n var headPos = cursorCoords(cm, doc.sel.primary().head, \"div\");\n var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect();\n result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,\n headPos.top + lineOff.top - wrapOff.top));\n result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,\n headPos.left + lineOff.left - wrapOff.left));\n }\n\n return result\n };\n\n TextareaInput.prototype.showSelection = function (drawn) {\n var cm = this.cm, display = cm.display;\n removeChildrenAndAdd(display.cursorDiv, drawn.cursors);\n removeChildrenAndAdd(display.selectionDiv, drawn.selection);\n if (drawn.teTop != null) {\n this.wrapper.style.top = drawn.teTop + \"px\";\n this.wrapper.style.left = drawn.teLeft + \"px\";\n }\n };\n\n // Reset the input to correspond to the selection (or to be empty,\n // when not typing and nothing is selected)\n TextareaInput.prototype.reset = function (typing) {\n if (this.contextMenuPending || this.composing) { return }\n var cm = this.cm;\n if (cm.somethingSelected()) {\n this.prevInput = \"\";\n var content = cm.getSelection();\n this.textarea.value = content;\n if (cm.state.focused) { selectInput(this.textarea); }\n if (ie && ie_version >= 9) { this.hasSelection = content; }\n } else if (!typing) {\n this.prevInput = this.textarea.value = \"\";\n if (ie && ie_version >= 9) { this.hasSelection = null; }\n }\n };\n\n TextareaInput.prototype.getField = function () { return this.textarea };\n\n TextareaInput.prototype.supportsTouch = function () { return false };\n\n TextareaInput.prototype.focus = function () {\n if (this.cm.options.readOnly != \"nocursor\" && (!mobile || activeElt() != this.textarea)) {\n try { this.textarea.focus(); }\n catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM\n }\n };\n\n TextareaInput.prototype.blur = function () { this.textarea.blur(); };\n\n TextareaInput.prototype.resetPosition = function () {\n this.wrapper.style.top = this.wrapper.style.left = 0;\n };\n\n TextareaInput.prototype.receivedFocus = function () { this.slowPoll(); };\n\n // Poll for input changes, using the normal rate of polling. This\n // runs as long as the editor is focused.\n TextareaInput.prototype.slowPoll = function () {\n var this$1 = this;\n\n if (this.pollingFast) { return }\n this.polling.set(this.cm.options.pollInterval, function () {\n this$1.poll();\n if (this$1.cm.state.focused) { this$1.slowPoll(); }\n });\n };\n\n // When an event has just come in that is likely to add or change\n // something in the input textarea, we poll faster, to ensure that\n // the change appears on the screen quickly.\n TextareaInput.prototype.fastPoll = function () {\n var missed = false, input = this;\n input.pollingFast = true;\n function p() {\n var changed = input.poll();\n if (!changed && !missed) {missed = true; input.polling.set(60, p);}\n else {input.pollingFast = false; input.slowPoll();}\n }\n input.polling.set(20, p);\n };\n\n // Read input from the textarea, and update the document to match.\n // When something is selected, it is present in the textarea, and\n // selected (unless it is huge, in which case a placeholder is\n // used). When nothing is selected, the cursor sits after previously\n // seen text (can be empty), which is stored in prevInput (we must\n // not reset the textarea when typing, because that breaks IME).\n TextareaInput.prototype.poll = function () {\n var this$1 = this;\n\n var cm = this.cm, input = this.textarea, prevInput = this.prevInput;\n // Since this is called a *lot*, try to bail out as cheaply as\n // possible when it is clear that nothing happened. hasSelection\n // will be the case when there is a lot of text in the textarea,\n // in which case reading its value would be expensive.\n if (this.contextMenuPending || !cm.state.focused ||\n (hasSelection(input) && !prevInput && !this.composing) ||\n cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)\n { return false }\n\n var text = input.value;\n // If nothing changed, bail.\n if (text == prevInput && !cm.somethingSelected()) { return false }\n // Work around nonsensical selection resetting in IE9/10, and\n // inexplicable appearance of private area unicode characters on\n // some key combos in Mac (#2689).\n if (ie && ie_version >= 9 && this.hasSelection === text ||\n mac && /[\\uf700-\\uf7ff]/.test(text)) {\n cm.display.input.reset();\n return false\n }\n\n if (cm.doc.sel == cm.display.selForContextMenu) {\n var first = text.charCodeAt(0);\n if (first == 0x200b && !prevInput) { prevInput = \"\\u200b\"; }\n if (first == 0x21da) { this.reset(); return this.cm.execCommand(\"undo\") }\n }\n // Find the part of the input that is actually new\n var same = 0, l = Math.min(prevInput.length, text.length);\n while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) { ++same; }\n\n runInOp(cm, function () {\n applyTextInput(cm, text.slice(same), prevInput.length - same,\n null, this$1.composing ? \"*compose\" : null);\n\n // Don't leave long text in the textarea, since it makes further polling slow\n if (text.length > 1000 || text.indexOf(\"\\n\") > -1) { input.value = this$1.prevInput = \"\"; }\n else { this$1.prevInput = text; }\n\n if (this$1.composing) {\n this$1.composing.range.clear();\n this$1.composing.range = cm.markText(this$1.composing.start, cm.getCursor(\"to\"),\n {className: \"CodeMirror-composing\"});\n }\n });\n return true\n };\n\n TextareaInput.prototype.ensurePolled = function () {\n if (this.pollingFast && this.poll()) { this.pollingFast = false; }\n };\n\n TextareaInput.prototype.onKeyPress = function () {\n if (ie && ie_version >= 9) { this.hasSelection = null; }\n this.fastPoll();\n };\n\n TextareaInput.prototype.onContextMenu = function (e) {\n var input = this, cm = input.cm, display = cm.display, te = input.textarea;\n if (input.contextMenuPending) { input.contextMenuPending(); }\n var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;\n if (!pos || presto) { return } // Opera is difficult.\n\n // Reset the current text selection only if the click is done outside of the selection\n // and 'resetSelectionOnContextMenu' option is true.\n var reset = cm.options.resetSelectionOnContextMenu;\n if (reset && cm.doc.sel.contains(pos) == -1)\n { operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll); }\n\n var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText;\n var wrapperBox = input.wrapper.offsetParent.getBoundingClientRect();\n input.wrapper.style.cssText = \"position: static\";\n te.style.cssText = \"position: absolute; width: 30px; height: 30px;\\n top: \" + (e.clientY - wrapperBox.top - 5) + \"px; left: \" + (e.clientX - wrapperBox.left - 5) + \"px;\\n z-index: 1000; background: \" + (ie ? \"rgba(255, 255, 255, .05)\" : \"transparent\") + \";\\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);\";\n var oldScrollY;\n if (webkit) { oldScrollY = window.scrollY; } // Work around Chrome issue (#2712)\n display.input.focus();\n if (webkit) { window.scrollTo(null, oldScrollY); }\n display.input.reset();\n // Adds \"Select all\" to context menu in FF\n if (!cm.somethingSelected()) { te.value = input.prevInput = \" \"; }\n input.contextMenuPending = rehide;\n display.selForContextMenu = cm.doc.sel;\n clearTimeout(display.detectingSelectAll);\n\n // Select-all will be greyed out if there's nothing to select, so\n // this adds a zero-width space so that we can later check whether\n // it got selected.\n function prepareSelectAllHack() {\n if (te.selectionStart != null) {\n var selected = cm.somethingSelected();\n var extval = \"\\u200b\" + (selected ? te.value : \"\");\n te.value = \"\\u21da\"; // Used to catch context-menu undo\n te.value = extval;\n input.prevInput = selected ? \"\" : \"\\u200b\";\n te.selectionStart = 1; te.selectionEnd = extval.length;\n // Re-set this, in case some other handler touched the\n // selection in the meantime.\n display.selForContextMenu = cm.doc.sel;\n }\n }\n function rehide() {\n if (input.contextMenuPending != rehide) { return }\n input.contextMenuPending = false;\n input.wrapper.style.cssText = oldWrapperCSS;\n te.style.cssText = oldCSS;\n if (ie && ie_version < 9) { display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos); }\n\n // Try to detect the user choosing select-all\n if (te.selectionStart != null) {\n if (!ie || (ie && ie_version < 9)) { prepareSelectAllHack(); }\n var i = 0, poll = function () {\n if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&\n te.selectionEnd > 0 && input.prevInput == \"\\u200b\") {\n operation(cm, selectAll)(cm);\n } else if (i++ < 10) {\n display.detectingSelectAll = setTimeout(poll, 500);\n } else {\n display.selForContextMenu = null;\n display.input.reset();\n }\n };\n display.detectingSelectAll = setTimeout(poll, 200);\n }\n }\n\n if (ie && ie_version >= 9) { prepareSelectAllHack(); }\n if (captureRightClick) {\n e_stop(e);\n var mouseup = function () {\n off(window, \"mouseup\", mouseup);\n setTimeout(rehide, 20);\n };\n on(window, \"mouseup\", mouseup);\n } else {\n setTimeout(rehide, 50);\n }\n };\n\n TextareaInput.prototype.readOnlyChanged = function (val) {\n if (!val) { this.reset(); }\n this.textarea.disabled = val == \"nocursor\";\n };\n\n TextareaInput.prototype.setUneditable = function () {};\n\n TextareaInput.prototype.needsContentAttribute = false;\n\n function fromTextArea(textarea, options) {\n options = options ? copyObj(options) : {};\n options.value = textarea.value;\n if (!options.tabindex && textarea.tabIndex)\n { options.tabindex = textarea.tabIndex; }\n if (!options.placeholder && textarea.placeholder)\n { options.placeholder = textarea.placeholder; }\n // Set autofocus to true if this textarea is focused, or if it has\n // autofocus and no other element is focused.\n if (options.autofocus == null) {\n var hasFocus = activeElt();\n options.autofocus = hasFocus == textarea ||\n textarea.getAttribute(\"autofocus\") != null && hasFocus == document.body;\n }\n\n function save() {textarea.value = cm.getValue();}\n\n var realSubmit;\n if (textarea.form) {\n on(textarea.form, \"submit\", save);\n // Deplorable hack to make the submit method do the right thing.\n if (!options.leaveSubmitMethodAlone) {\n var form = textarea.form;\n realSubmit = form.submit;\n try {\n var wrappedSubmit = form.submit = function () {\n save();\n form.submit = realSubmit;\n form.submit();\n form.submit = wrappedSubmit;\n };\n } catch(e) {}\n }\n }\n\n options.finishInit = function (cm) {\n cm.save = save;\n cm.getTextArea = function () { return textarea; };\n cm.toTextArea = function () {\n cm.toTextArea = isNaN; // Prevent this from being ran twice\n save();\n textarea.parentNode.removeChild(cm.getWrapperElement());\n textarea.style.display = \"\";\n if (textarea.form) {\n off(textarea.form, \"submit\", save);\n if (!options.leaveSubmitMethodAlone && typeof textarea.form.submit == \"function\")\n { textarea.form.submit = realSubmit; }\n }\n };\n };\n\n textarea.style.display = \"none\";\n var cm = CodeMirror(function (node) { return textarea.parentNode.insertBefore(node, textarea.nextSibling); },\n options);\n return cm\n }\n\n function addLegacyProps(CodeMirror) {\n CodeMirror.off = off;\n CodeMirror.on = on;\n CodeMirror.wheelEventPixels = wheelEventPixels;\n CodeMirror.Doc = Doc;\n CodeMirror.splitLines = splitLinesAuto;\n CodeMirror.countColumn = countColumn;\n CodeMirror.findColumn = findColumn;\n CodeMirror.isWordChar = isWordCharBasic;\n CodeMirror.Pass = Pass;\n CodeMirror.signal = signal;\n CodeMirror.Line = Line;\n CodeMirror.changeEnd = changeEnd;\n CodeMirror.scrollbarModel = scrollbarModel;\n CodeMirror.Pos = Pos;\n CodeMirror.cmpPos = cmp;\n CodeMirror.modes = modes;\n CodeMirror.mimeModes = mimeModes;\n CodeMirror.resolveMode = resolveMode;\n CodeMirror.getMode = getMode;\n CodeMirror.modeExtensions = modeExtensions;\n CodeMirror.extendMode = extendMode;\n CodeMirror.copyState = copyState;\n CodeMirror.startState = startState;\n CodeMirror.innerMode = innerMode;\n CodeMirror.commands = commands;\n CodeMirror.keyMap = keyMap;\n CodeMirror.keyName = keyName;\n CodeMirror.isModifierKey = isModifierKey;\n CodeMirror.lookupKey = lookupKey;\n CodeMirror.normalizeKeyMap = normalizeKeyMap;\n CodeMirror.StringStream = StringStream;\n CodeMirror.SharedTextMarker = SharedTextMarker;\n CodeMirror.TextMarker = TextMarker;\n CodeMirror.LineWidget = LineWidget;\n CodeMirror.e_preventDefault = e_preventDefault;\n CodeMirror.e_stopPropagation = e_stopPropagation;\n CodeMirror.e_stop = e_stop;\n CodeMirror.addClass = addClass;\n CodeMirror.contains = contains;\n CodeMirror.rmClass = rmClass;\n CodeMirror.keyNames = keyNames;\n }\n\n // EDITOR CONSTRUCTOR\n\n defineOptions(CodeMirror);\n\n addEditorMethods(CodeMirror);\n\n // Set up methods on CodeMirror's prototype to redirect to the editor's document.\n var dontDelegate = \"iter insert remove copy getEditor constructor\".split(\" \");\n for (var prop in Doc.prototype) { if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)\n { CodeMirror.prototype[prop] = (function(method) {\n return function() {return method.apply(this.doc, arguments)}\n })(Doc.prototype[prop]); } }\n\n eventMixin(Doc);\n CodeMirror.inputStyles = {\"textarea\": TextareaInput, \"contenteditable\": ContentEditableInput};\n\n // Extra arguments are stored as the mode's dependencies, which is\n // used by (legacy) mechanisms like loadmode.js to automatically\n // load a mode. (Preferred mechanism is the require/define calls.)\n CodeMirror.defineMode = function(name/*, mode, …*/) {\n if (!CodeMirror.defaults.mode && name != \"null\") { CodeMirror.defaults.mode = name; }\n defineMode.apply(this, arguments);\n };\n\n CodeMirror.defineMIME = defineMIME;\n\n // Minimal default mode.\n CodeMirror.defineMode(\"null\", function () { return ({token: function (stream) { return stream.skipToEnd(); }}); });\n CodeMirror.defineMIME(\"text/plain\", \"null\");\n\n // EXTENSIONS\n\n CodeMirror.defineExtension = function (name, func) {\n CodeMirror.prototype[name] = func;\n };\n CodeMirror.defineDocExtension = function (name, func) {\n Doc.prototype[name] = func;\n };\n\n CodeMirror.fromTextArea = fromTextArea;\n\n addLegacyProps(CodeMirror);\n\n CodeMirror.version = \"5.49.2\";\n\n return CodeMirror;\n\n})));\n","require('../modules/es6.symbol');\nrequire('../modules/es6.object.create');\nrequire('../modules/es6.object.define-property');\nrequire('../modules/es6.object.define-properties');\nrequire('../modules/es6.object.get-own-property-descriptor');\nrequire('../modules/es6.object.get-prototype-of');\nrequire('../modules/es6.object.keys');\nrequire('../modules/es6.object.get-own-property-names');\nrequire('../modules/es6.object.freeze');\nrequire('../modules/es6.object.seal');\nrequire('../modules/es6.object.prevent-extensions');\nrequire('../modules/es6.object.is-frozen');\nrequire('../modules/es6.object.is-sealed');\nrequire('../modules/es6.object.is-extensible');\nrequire('../modules/es6.object.assign');\nrequire('../modules/es6.object.is');\nrequire('../modules/es6.object.set-prototype-of');\nrequire('../modules/es6.object.to-string');\nrequire('../modules/es6.function.bind');\nrequire('../modules/es6.function.name');\nrequire('../modules/es6.function.has-instance');\nrequire('../modules/es6.parse-int');\nrequire('../modules/es6.parse-float');\nrequire('../modules/es6.number.constructor');\nrequire('../modules/es6.number.to-fixed');\nrequire('../modules/es6.number.to-precision');\nrequire('../modules/es6.number.epsilon');\nrequire('../modules/es6.number.is-finite');\nrequire('../modules/es6.number.is-integer');\nrequire('../modules/es6.number.is-nan');\nrequire('../modules/es6.number.is-safe-integer');\nrequire('../modules/es6.number.max-safe-integer');\nrequire('../modules/es6.number.min-safe-integer');\nrequire('../modules/es6.number.parse-float');\nrequire('../modules/es6.number.parse-int');\nrequire('../modules/es6.math.acosh');\nrequire('../modules/es6.math.asinh');\nrequire('../modules/es6.math.atanh');\nrequire('../modules/es6.math.cbrt');\nrequire('../modules/es6.math.clz32');\nrequire('../modules/es6.math.cosh');\nrequire('../modules/es6.math.expm1');\nrequire('../modules/es6.math.fround');\nrequire('../modules/es6.math.hypot');\nrequire('../modules/es6.math.imul');\nrequire('../modules/es6.math.log10');\nrequire('../modules/es6.math.log1p');\nrequire('../modules/es6.math.log2');\nrequire('../modules/es6.math.sign');\nrequire('../modules/es6.math.sinh');\nrequire('../modules/es6.math.tanh');\nrequire('../modules/es6.math.trunc');\nrequire('../modules/es6.string.from-code-point');\nrequire('../modules/es6.string.raw');\nrequire('../modules/es6.string.trim');\nrequire('../modules/es6.string.iterator');\nrequire('../modules/es6.string.code-point-at');\nrequire('../modules/es6.string.ends-with');\nrequire('../modules/es6.string.includes');\nrequire('../modules/es6.string.repeat');\nrequire('../modules/es6.string.starts-with');\nrequire('../modules/es6.string.anchor');\nrequire('../modules/es6.string.big');\nrequire('../modules/es6.string.blink');\nrequire('../modules/es6.string.bold');\nrequire('../modules/es6.string.fixed');\nrequire('../modules/es6.string.fontcolor');\nrequire('../modules/es6.string.fontsize');\nrequire('../modules/es6.string.italics');\nrequire('../modules/es6.string.link');\nrequire('../modules/es6.string.small');\nrequire('../modules/es6.string.strike');\nrequire('../modules/es6.string.sub');\nrequire('../modules/es6.string.sup');\nrequire('../modules/es6.date.now');\nrequire('../modules/es6.date.to-json');\nrequire('../modules/es6.date.to-iso-string');\nrequire('../modules/es6.date.to-string');\nrequire('../modules/es6.date.to-primitive');\nrequire('../modules/es6.array.is-array');\nrequire('../modules/es6.array.from');\nrequire('../modules/es6.array.of');\nrequire('../modules/es6.array.join');\nrequire('../modules/es6.array.slice');\nrequire('../modules/es6.array.sort');\nrequire('../modules/es6.array.for-each');\nrequire('../modules/es6.array.map');\nrequire('../modules/es6.array.filter');\nrequire('../modules/es6.array.some');\nrequire('../modules/es6.array.every');\nrequire('../modules/es6.array.reduce');\nrequire('../modules/es6.array.reduce-right');\nrequire('../modules/es6.array.index-of');\nrequire('../modules/es6.array.last-index-of');\nrequire('../modules/es6.array.copy-within');\nrequire('../modules/es6.array.fill');\nrequire('../modules/es6.array.find');\nrequire('../modules/es6.array.find-index');\nrequire('../modules/es6.array.species');\nrequire('../modules/es6.array.iterator');\nrequire('../modules/es6.regexp.constructor');\nrequire('../modules/es6.regexp.exec');\nrequire('../modules/es6.regexp.to-string');\nrequire('../modules/es6.regexp.flags');\nrequire('../modules/es6.regexp.match');\nrequire('../modules/es6.regexp.replace');\nrequire('../modules/es6.regexp.search');\nrequire('../modules/es6.regexp.split');\nrequire('../modules/es6.promise');\nrequire('../modules/es6.map');\nrequire('../modules/es6.set');\nrequire('../modules/es6.weak-map');\nrequire('../modules/es6.weak-set');\nrequire('../modules/es6.typed.array-buffer');\nrequire('../modules/es6.typed.data-view');\nrequire('../modules/es6.typed.int8-array');\nrequire('../modules/es6.typed.uint8-array');\nrequire('../modules/es6.typed.uint8-clamped-array');\nrequire('../modules/es6.typed.int16-array');\nrequire('../modules/es6.typed.uint16-array');\nrequire('../modules/es6.typed.int32-array');\nrequire('../modules/es6.typed.uint32-array');\nrequire('../modules/es6.typed.float32-array');\nrequire('../modules/es6.typed.float64-array');\nrequire('../modules/es6.reflect.apply');\nrequire('../modules/es6.reflect.construct');\nrequire('../modules/es6.reflect.define-property');\nrequire('../modules/es6.reflect.delete-property');\nrequire('../modules/es6.reflect.enumerate');\nrequire('../modules/es6.reflect.get');\nrequire('../modules/es6.reflect.get-own-property-descriptor');\nrequire('../modules/es6.reflect.get-prototype-of');\nrequire('../modules/es6.reflect.has');\nrequire('../modules/es6.reflect.is-extensible');\nrequire('../modules/es6.reflect.own-keys');\nrequire('../modules/es6.reflect.prevent-extensions');\nrequire('../modules/es6.reflect.set');\nrequire('../modules/es6.reflect.set-prototype-of');\nmodule.exports = require('../modules/_core');\n","require('../../modules/es7.array.flat-map');\nmodule.exports = require('../../modules/_core').Array.flatMap;\n","require('../../modules/es7.array.includes');\nmodule.exports = require('../../modules/_core').Array.includes;\n","require('../../modules/es7.object.entries');\nmodule.exports = require('../../modules/_core').Object.entries;\n","require('../../modules/es7.object.get-own-property-descriptors');\nmodule.exports = require('../../modules/_core').Object.getOwnPropertyDescriptors;\n","require('../../modules/es7.object.values');\nmodule.exports = require('../../modules/_core').Object.values;\n","'use strict';\nrequire('../../modules/es6.promise');\nrequire('../../modules/es7.promise.finally');\nmodule.exports = require('../../modules/_core').Promise['finally'];\n","require('../../modules/es7.string.pad-end');\nmodule.exports = require('../../modules/_core').String.padEnd;\n","require('../../modules/es7.string.pad-start');\nmodule.exports = require('../../modules/_core').String.padStart;\n","require('../../modules/es7.string.trim-right');\nmodule.exports = require('../../modules/_core').String.trimRight;\n","require('../../modules/es7.string.trim-left');\nmodule.exports = require('../../modules/_core').String.trimLeft;\n","require('../../modules/es7.symbol.async-iterator');\nmodule.exports = require('../../modules/_wks-ext').f('asyncIterator');\n","require('../modules/es7.global');\nmodule.exports = require('../modules/_core').global;\n","module.exports = function (it) {\n if (typeof it != 'function') throw TypeError(it + ' is not a function!');\n return it;\n};\n","var isObject = require('./_is-object');\nmodule.exports = function (it) {\n if (!isObject(it)) throw TypeError(it + ' is not an object!');\n return it;\n};\n","var core = module.exports = { version: '2.6.11' };\nif (typeof __e == 'number') __e = core; // eslint-disable-line no-undef\n","// optional / simple context binding\nvar aFunction = require('./_a-function');\nmodule.exports = function (fn, that, length) {\n aFunction(fn);\n if (that === undefined) return fn;\n switch (length) {\n case 1: return function (a) {\n return fn.call(that, a);\n };\n case 2: return function (a, b) {\n return fn.call(that, a, b);\n };\n case 3: return function (a, b, c) {\n return fn.call(that, a, b, c);\n };\n }\n return function (/* ...args */) {\n return fn.apply(that, arguments);\n };\n};\n","// Thank's IE8 for his funny defineProperty\nmodule.exports = !require('./_fails')(function () {\n return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;\n});\n","var isObject = require('./_is-object');\nvar document = require('./_global').document;\n// typeof document.createElement is 'object' in old IE\nvar is = isObject(document) && isObject(document.createElement);\nmodule.exports = function (it) {\n return is ? document.createElement(it) : {};\n};\n","var global = require('./_global');\nvar core = require('./_core');\nvar ctx = require('./_ctx');\nvar hide = require('./_hide');\nvar has = require('./_has');\nvar PROTOTYPE = 'prototype';\n\nvar $export = function (type, name, source) {\n var IS_FORCED = type & $export.F;\n var IS_GLOBAL = type & $export.G;\n var IS_STATIC = type & $export.S;\n var IS_PROTO = type & $export.P;\n var IS_BIND = type & $export.B;\n var IS_WRAP = type & $export.W;\n var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});\n var expProto = exports[PROTOTYPE];\n var target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE];\n var key, own, out;\n if (IS_GLOBAL) source = name;\n for (key in source) {\n // contains in native\n own = !IS_FORCED && target && target[key] !== undefined;\n if (own && has(exports, key)) continue;\n // export native or passed\n out = own ? target[key] : source[key];\n // prevent global pollution for namespaces\n exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]\n // bind timers to global for call from export context\n : IS_BIND && own ? ctx(out, global)\n // wrap global constructors for prevent change them in library\n : IS_WRAP && target[key] == out ? (function (C) {\n var F = function (a, b, c) {\n if (this instanceof C) {\n switch (arguments.length) {\n case 0: return new C();\n case 1: return new C(a);\n case 2: return new C(a, b);\n } return new C(a, b, c);\n } return C.apply(this, arguments);\n };\n F[PROTOTYPE] = C[PROTOTYPE];\n return F;\n // make static versions for prototype methods\n })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;\n // export proto methods to core.%CONSTRUCTOR%.methods.%NAME%\n if (IS_PROTO) {\n (exports.virtual || (exports.virtual = {}))[key] = out;\n // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%\n if (type & $export.R && expProto && !expProto[key]) hide(expProto, key, out);\n }\n }\n};\n// type bitmap\n$export.F = 1; // forced\n$export.G = 2; // global\n$export.S = 4; // static\n$export.P = 8; // proto\n$export.B = 16; // bind\n$export.W = 32; // wrap\n$export.U = 64; // safe\n$export.R = 128; // real proto method for `library`\nmodule.exports = $export;\n","module.exports = function (exec) {\n try {\n return !!exec();\n } catch (e) {\n return true;\n }\n};\n","// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028\nvar global = module.exports = typeof window != 'undefined' && window.Math == Math\n ? window : typeof self != 'undefined' && self.Math == Math ? self\n // eslint-disable-next-line no-new-func\n : Function('return this')();\nif (typeof __g == 'number') __g = global; // eslint-disable-line no-undef\n","var hasOwnProperty = {}.hasOwnProperty;\nmodule.exports = function (it, key) {\n return hasOwnProperty.call(it, key);\n};\n","var dP = require('./_object-dp');\nvar createDesc = require('./_property-desc');\nmodule.exports = require('./_descriptors') ? function (object, key, value) {\n return dP.f(object, key, createDesc(1, value));\n} : function (object, key, value) {\n object[key] = value;\n return object;\n};\n","module.exports = !require('./_descriptors') && !require('./_fails')(function () {\n return Object.defineProperty(require('./_dom-create')('div'), 'a', { get: function () { return 7; } }).a != 7;\n});\n","module.exports = function (it) {\n return typeof it === 'object' ? it !== null : typeof it === 'function';\n};\n","var anObject = require('./_an-object');\nvar IE8_DOM_DEFINE = require('./_ie8-dom-define');\nvar toPrimitive = require('./_to-primitive');\nvar dP = Object.defineProperty;\n\nexports.f = require('./_descriptors') ? Object.defineProperty : function defineProperty(O, P, Attributes) {\n anObject(O);\n P = toPrimitive(P, true);\n anObject(Attributes);\n if (IE8_DOM_DEFINE) try {\n return dP(O, P, Attributes);\n } catch (e) { /* empty */ }\n if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');\n if ('value' in Attributes) O[P] = Attributes.value;\n return O;\n};\n","module.exports = function (bitmap, value) {\n return {\n enumerable: !(bitmap & 1),\n configurable: !(bitmap & 2),\n writable: !(bitmap & 4),\n value: value\n };\n};\n","// 7.1.1 ToPrimitive(input [, PreferredType])\nvar isObject = require('./_is-object');\n// instead of the ES6 spec version, we didn't implement @@toPrimitive case\n// and the second argument - flag - preferred type is a string\nmodule.exports = function (it, S) {\n if (!isObject(it)) return it;\n var fn, val;\n if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;\n if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;\n if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;\n throw TypeError(\"Can't convert object to primitive value\");\n};\n","// https://github.com/tc39/proposal-global\nvar $export = require('./_export');\n\n$export($export.G, { global: require('./_global') });\n","module.exports = function (it) {\n if (typeof it != 'function') throw TypeError(it + ' is not a function!');\n return it;\n};\n","var cof = require('./_cof');\nmodule.exports = function (it, msg) {\n if (typeof it != 'number' && cof(it) != 'Number') throw TypeError(msg);\n return +it;\n};\n","// 22.1.3.31 Array.prototype[@@unscopables]\nvar UNSCOPABLES = require('./_wks')('unscopables');\nvar ArrayProto = Array.prototype;\nif (ArrayProto[UNSCOPABLES] == undefined) require('./_hide')(ArrayProto, UNSCOPABLES, {});\nmodule.exports = function (key) {\n ArrayProto[UNSCOPABLES][key] = true;\n};\n","'use strict';\nvar at = require('./_string-at')(true);\n\n // `AdvanceStringIndex` abstract operation\n// https://tc39.github.io/ecma262/#sec-advancestringindex\nmodule.exports = function (S, index, unicode) {\n return index + (unicode ? at(S, index).length : 1);\n};\n","module.exports = function (it, Constructor, name, forbiddenField) {\n if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {\n throw TypeError(name + ': incorrect invocation!');\n } return it;\n};\n","var isObject = require('./_is-object');\nmodule.exports = function (it) {\n if (!isObject(it)) throw TypeError(it + ' is not an object!');\n return it;\n};\n","// 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)\n'use strict';\nvar toObject = require('./_to-object');\nvar toAbsoluteIndex = require('./_to-absolute-index');\nvar toLength = require('./_to-length');\n\nmodule.exports = [].copyWithin || function copyWithin(target /* = 0 */, start /* = 0, end = @length */) {\n var O = toObject(this);\n var len = toLength(O.length);\n var to = toAbsoluteIndex(target, len);\n var from = toAbsoluteIndex(start, len);\n var end = arguments.length > 2 ? arguments[2] : undefined;\n var count = Math.min((end === undefined ? len : toAbsoluteIndex(end, len)) - from, len - to);\n var inc = 1;\n if (from < to && to < from + count) {\n inc = -1;\n from += count - 1;\n to += count - 1;\n }\n while (count-- > 0) {\n if (from in O) O[to] = O[from];\n else delete O[to];\n to += inc;\n from += inc;\n } return O;\n};\n","// 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)\n'use strict';\nvar toObject = require('./_to-object');\nvar toAbsoluteIndex = require('./_to-absolute-index');\nvar toLength = require('./_to-length');\nmodule.exports = function fill(value /* , start = 0, end = @length */) {\n var O = toObject(this);\n var length = toLength(O.length);\n var aLen = arguments.length;\n var index = toAbsoluteIndex(aLen > 1 ? arguments[1] : undefined, length);\n var end = aLen > 2 ? arguments[2] : undefined;\n var endPos = end === undefined ? length : toAbsoluteIndex(end, length);\n while (endPos > index) O[index++] = value;\n return O;\n};\n","// false -> Array#indexOf\n// true -> Array#includes\nvar toIObject = require('./_to-iobject');\nvar toLength = require('./_to-length');\nvar toAbsoluteIndex = require('./_to-absolute-index');\nmodule.exports = function (IS_INCLUDES) {\n return function ($this, el, fromIndex) {\n var O = toIObject($this);\n var length = toLength(O.length);\n var index = toAbsoluteIndex(fromIndex, length);\n var value;\n // Array#includes uses SameValueZero equality algorithm\n // eslint-disable-next-line no-self-compare\n if (IS_INCLUDES && el != el) while (length > index) {\n value = O[index++];\n // eslint-disable-next-line no-self-compare\n if (value != value) return true;\n // Array#indexOf ignores holes, Array#includes - not\n } else for (;length > index; index++) if (IS_INCLUDES || index in O) {\n if (O[index] === el) return IS_INCLUDES || index || 0;\n } return !IS_INCLUDES && -1;\n };\n};\n","// 0 -> Array#forEach\n// 1 -> Array#map\n// 2 -> Array#filter\n// 3 -> Array#some\n// 4 -> Array#every\n// 5 -> Array#find\n// 6 -> Array#findIndex\nvar ctx = require('./_ctx');\nvar IObject = require('./_iobject');\nvar toObject = require('./_to-object');\nvar toLength = require('./_to-length');\nvar asc = require('./_array-species-create');\nmodule.exports = function (TYPE, $create) {\n var IS_MAP = TYPE == 1;\n var IS_FILTER = TYPE == 2;\n var IS_SOME = TYPE == 3;\n var IS_EVERY = TYPE == 4;\n var IS_FIND_INDEX = TYPE == 6;\n var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;\n var create = $create || asc;\n return function ($this, callbackfn, that) {\n var O = toObject($this);\n var self = IObject(O);\n var f = ctx(callbackfn, that, 3);\n var length = toLength(self.length);\n var index = 0;\n var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;\n var val, res;\n for (;length > index; index++) if (NO_HOLES || index in self) {\n val = self[index];\n res = f(val, index, O);\n if (TYPE) {\n if (IS_MAP) result[index] = res; // map\n else if (res) switch (TYPE) {\n case 3: return true; // some\n case 5: return val; // find\n case 6: return index; // findIndex\n case 2: result.push(val); // filter\n } else if (IS_EVERY) return false; // every\n }\n }\n return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;\n };\n};\n","var aFunction = require('./_a-function');\nvar toObject = require('./_to-object');\nvar IObject = require('./_iobject');\nvar toLength = require('./_to-length');\n\nmodule.exports = function (that, callbackfn, aLen, memo, isRight) {\n aFunction(callbackfn);\n var O = toObject(that);\n var self = IObject(O);\n var length = toLength(O.length);\n var index = isRight ? length - 1 : 0;\n var i = isRight ? -1 : 1;\n if (aLen < 2) for (;;) {\n if (index in self) {\n memo = self[index];\n index += i;\n break;\n }\n index += i;\n if (isRight ? index < 0 : length <= index) {\n throw TypeError('Reduce of empty array with no initial value');\n }\n }\n for (;isRight ? index >= 0 : length > index; index += i) if (index in self) {\n memo = callbackfn(memo, self[index], index, O);\n }\n return memo;\n};\n","var isObject = require('./_is-object');\nvar isArray = require('./_is-array');\nvar SPECIES = require('./_wks')('species');\n\nmodule.exports = function (original) {\n var C;\n if (isArray(original)) {\n C = original.constructor;\n // cross-realm fallback\n if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;\n if (isObject(C)) {\n C = C[SPECIES];\n if (C === null) C = undefined;\n }\n } return C === undefined ? Array : C;\n};\n","// 9.4.2.3 ArraySpeciesCreate(originalArray, length)\nvar speciesConstructor = require('./_array-species-constructor');\n\nmodule.exports = function (original, length) {\n return new (speciesConstructor(original))(length);\n};\n","'use strict';\nvar aFunction = require('./_a-function');\nvar isObject = require('./_is-object');\nvar invoke = require('./_invoke');\nvar arraySlice = [].slice;\nvar factories = {};\n\nvar construct = function (F, len, args) {\n if (!(len in factories)) {\n for (var n = [], i = 0; i < len; i++) n[i] = 'a[' + i + ']';\n // eslint-disable-next-line no-new-func\n factories[len] = Function('F,a', 'return new F(' + n.join(',') + ')');\n } return factories[len](F, args);\n};\n\nmodule.exports = Function.bind || function bind(that /* , ...args */) {\n var fn = aFunction(this);\n var partArgs = arraySlice.call(arguments, 1);\n var bound = function (/* args... */) {\n var args = partArgs.concat(arraySlice.call(arguments));\n return this instanceof bound ? construct(fn, args.length, args) : invoke(fn, args, that);\n };\n if (isObject(fn.prototype)) bound.prototype = fn.prototype;\n return bound;\n};\n","// getting tag from 19.1.3.6 Object.prototype.toString()\nvar cof = require('./_cof');\nvar TAG = require('./_wks')('toStringTag');\n// ES3 wrong here\nvar ARG = cof(function () { return arguments; }()) == 'Arguments';\n\n// fallback for IE11 Script Access Denied error\nvar tryGet = function (it, key) {\n try {\n return it[key];\n } catch (e) { /* empty */ }\n};\n\nmodule.exports = function (it) {\n var O, T, B;\n return it === undefined ? 'Undefined' : it === null ? 'Null'\n // @@toStringTag case\n : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T\n // builtinTag case\n : ARG ? cof(O)\n // ES3 arguments fallback\n : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;\n};\n","var toString = {}.toString;\n\nmodule.exports = function (it) {\n return toString.call(it).slice(8, -1);\n};\n","'use strict';\nvar dP = require('./_object-dp').f;\nvar create = require('./_object-create');\nvar redefineAll = require('./_redefine-all');\nvar ctx = require('./_ctx');\nvar anInstance = require('./_an-instance');\nvar forOf = require('./_for-of');\nvar $iterDefine = require('./_iter-define');\nvar step = require('./_iter-step');\nvar setSpecies = require('./_set-species');\nvar DESCRIPTORS = require('./_descriptors');\nvar fastKey = require('./_meta').fastKey;\nvar validate = require('./_validate-collection');\nvar SIZE = DESCRIPTORS ? '_s' : 'size';\n\nvar getEntry = function (that, key) {\n // fast case\n var index = fastKey(key);\n var entry;\n if (index !== 'F') return that._i[index];\n // frozen object case\n for (entry = that._f; entry; entry = entry.n) {\n if (entry.k == key) return entry;\n }\n};\n\nmodule.exports = {\n getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {\n var C = wrapper(function (that, iterable) {\n anInstance(that, C, NAME, '_i');\n that._t = NAME; // collection type\n that._i = create(null); // index\n that._f = undefined; // first entry\n that._l = undefined; // last entry\n that[SIZE] = 0; // size\n if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);\n });\n redefineAll(C.prototype, {\n // 23.1.3.1 Map.prototype.clear()\n // 23.2.3.2 Set.prototype.clear()\n clear: function clear() {\n for (var that = validate(this, NAME), data = that._i, entry = that._f; entry; entry = entry.n) {\n entry.r = true;\n if (entry.p) entry.p = entry.p.n = undefined;\n delete data[entry.i];\n }\n that._f = that._l = undefined;\n that[SIZE] = 0;\n },\n // 23.1.3.3 Map.prototype.delete(key)\n // 23.2.3.4 Set.prototype.delete(value)\n 'delete': function (key) {\n var that = validate(this, NAME);\n var entry = getEntry(that, key);\n if (entry) {\n var next = entry.n;\n var prev = entry.p;\n delete that._i[entry.i];\n entry.r = true;\n if (prev) prev.n = next;\n if (next) next.p = prev;\n if (that._f == entry) that._f = next;\n if (that._l == entry) that._l = prev;\n that[SIZE]--;\n } return !!entry;\n },\n // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)\n // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)\n forEach: function forEach(callbackfn /* , that = undefined */) {\n validate(this, NAME);\n var f = ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);\n var entry;\n while (entry = entry ? entry.n : this._f) {\n f(entry.v, entry.k, this);\n // revert to the last existing entry\n while (entry && entry.r) entry = entry.p;\n }\n },\n // 23.1.3.7 Map.prototype.has(key)\n // 23.2.3.7 Set.prototype.has(value)\n has: function has(key) {\n return !!getEntry(validate(this, NAME), key);\n }\n });\n if (DESCRIPTORS) dP(C.prototype, 'size', {\n get: function () {\n return validate(this, NAME)[SIZE];\n }\n });\n return C;\n },\n def: function (that, key, value) {\n var entry = getEntry(that, key);\n var prev, index;\n // change existing entry\n if (entry) {\n entry.v = value;\n // create new entry\n } else {\n that._l = entry = {\n i: index = fastKey(key, true), // <- index\n k: key, // <- key\n v: value, // <- value\n p: prev = that._l, // <- previous entry\n n: undefined, // <- next entry\n r: false // <- removed\n };\n if (!that._f) that._f = entry;\n if (prev) prev.n = entry;\n that[SIZE]++;\n // add to index\n if (index !== 'F') that._i[index] = entry;\n } return that;\n },\n getEntry: getEntry,\n setStrong: function (C, NAME, IS_MAP) {\n // add .keys, .values, .entries, [@@iterator]\n // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11\n $iterDefine(C, NAME, function (iterated, kind) {\n this._t = validate(iterated, NAME); // target\n this._k = kind; // kind\n this._l = undefined; // previous\n }, function () {\n var that = this;\n var kind = that._k;\n var entry = that._l;\n // revert to the last existing entry\n while (entry && entry.r) entry = entry.p;\n // get next entry\n if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) {\n // or finish the iteration\n that._t = undefined;\n return step(1);\n }\n // return step by kind\n if (kind == 'keys') return step(0, entry.k);\n if (kind == 'values') return step(0, entry.v);\n return step(0, [entry.k, entry.v]);\n }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);\n\n // add [@@species], 23.1.2.2, 23.2.2.2\n setSpecies(NAME);\n }\n};\n","'use strict';\nvar redefineAll = require('./_redefine-all');\nvar getWeak = require('./_meta').getWeak;\nvar anObject = require('./_an-object');\nvar isObject = require('./_is-object');\nvar anInstance = require('./_an-instance');\nvar forOf = require('./_for-of');\nvar createArrayMethod = require('./_array-methods');\nvar $has = require('./_has');\nvar validate = require('./_validate-collection');\nvar arrayFind = createArrayMethod(5);\nvar arrayFindIndex = createArrayMethod(6);\nvar id = 0;\n\n// fallback for uncaught frozen keys\nvar uncaughtFrozenStore = function (that) {\n return that._l || (that._l = new UncaughtFrozenStore());\n};\nvar UncaughtFrozenStore = function () {\n this.a = [];\n};\nvar findUncaughtFrozen = function (store, key) {\n return arrayFind(store.a, function (it) {\n return it[0] === key;\n });\n};\nUncaughtFrozenStore.prototype = {\n get: function (key) {\n var entry = findUncaughtFrozen(this, key);\n if (entry) return entry[1];\n },\n has: function (key) {\n return !!findUncaughtFrozen(this, key);\n },\n set: function (key, value) {\n var entry = findUncaughtFrozen(this, key);\n if (entry) entry[1] = value;\n else this.a.push([key, value]);\n },\n 'delete': function (key) {\n var index = arrayFindIndex(this.a, function (it) {\n return it[0] === key;\n });\n if (~index) this.a.splice(index, 1);\n return !!~index;\n }\n};\n\nmodule.exports = {\n getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {\n var C = wrapper(function (that, iterable) {\n anInstance(that, C, NAME, '_i');\n that._t = NAME; // collection type\n that._i = id++; // collection id\n that._l = undefined; // leak store for uncaught frozen objects\n if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);\n });\n redefineAll(C.prototype, {\n // 23.3.3.2 WeakMap.prototype.delete(key)\n // 23.4.3.3 WeakSet.prototype.delete(value)\n 'delete': function (key) {\n if (!isObject(key)) return false;\n var data = getWeak(key);\n if (data === true) return uncaughtFrozenStore(validate(this, NAME))['delete'](key);\n return data && $has(data, this._i) && delete data[this._i];\n },\n // 23.3.3.4 WeakMap.prototype.has(key)\n // 23.4.3.4 WeakSet.prototype.has(value)\n has: function has(key) {\n if (!isObject(key)) return false;\n var data = getWeak(key);\n if (data === true) return uncaughtFrozenStore(validate(this, NAME)).has(key);\n return data && $has(data, this._i);\n }\n });\n return C;\n },\n def: function (that, key, value) {\n var data = getWeak(anObject(key), true);\n if (data === true) uncaughtFrozenStore(that).set(key, value);\n else data[that._i] = value;\n return that;\n },\n ufstore: uncaughtFrozenStore\n};\n","'use strict';\nvar global = require('./_global');\nvar $export = require('./_export');\nvar redefine = require('./_redefine');\nvar redefineAll = require('./_redefine-all');\nvar meta = require('./_meta');\nvar forOf = require('./_for-of');\nvar anInstance = require('./_an-instance');\nvar isObject = require('./_is-object');\nvar fails = require('./_fails');\nvar $iterDetect = require('./_iter-detect');\nvar setToStringTag = require('./_set-to-string-tag');\nvar inheritIfRequired = require('./_inherit-if-required');\n\nmodule.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {\n var Base = global[NAME];\n var C = Base;\n var ADDER = IS_MAP ? 'set' : 'add';\n var proto = C && C.prototype;\n var O = {};\n var fixMethod = function (KEY) {\n var fn = proto[KEY];\n redefine(proto, KEY,\n KEY == 'delete' ? function (a) {\n return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);\n } : KEY == 'has' ? function has(a) {\n return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);\n } : KEY == 'get' ? function get(a) {\n return IS_WEAK && !isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a);\n } : KEY == 'add' ? function add(a) { fn.call(this, a === 0 ? 0 : a); return this; }\n : function set(a, b) { fn.call(this, a === 0 ? 0 : a, b); return this; }\n );\n };\n if (typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function () {\n new C().entries().next();\n }))) {\n // create collection constructor\n C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);\n redefineAll(C.prototype, methods);\n meta.NEED = true;\n } else {\n var instance = new C();\n // early implementations not supports chaining\n var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;\n // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false\n var THROWS_ON_PRIMITIVES = fails(function () { instance.has(1); });\n // most early implementations doesn't supports iterables, most modern - not close it correctly\n var ACCEPT_ITERABLES = $iterDetect(function (iter) { new C(iter); }); // eslint-disable-line no-new\n // for early implementations -0 and +0 not the same\n var BUGGY_ZERO = !IS_WEAK && fails(function () {\n // V8 ~ Chromium 42- fails only with 5+ elements\n var $instance = new C();\n var index = 5;\n while (index--) $instance[ADDER](index, index);\n return !$instance.has(-0);\n });\n if (!ACCEPT_ITERABLES) {\n C = wrapper(function (target, iterable) {\n anInstance(target, C, NAME);\n var that = inheritIfRequired(new Base(), target, C);\n if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);\n return that;\n });\n C.prototype = proto;\n proto.constructor = C;\n }\n if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {\n fixMethod('delete');\n fixMethod('has');\n IS_MAP && fixMethod('get');\n }\n if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER);\n // weak collections should not contains .clear method\n if (IS_WEAK && proto.clear) delete proto.clear;\n }\n\n setToStringTag(C, NAME);\n\n O[NAME] = C;\n $export($export.G + $export.W + $export.F * (C != Base), O);\n\n if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);\n\n return C;\n};\n","var core = module.exports = { version: '2.6.11' };\nif (typeof __e == 'number') __e = core; // eslint-disable-line no-undef\n","'use strict';\nvar $defineProperty = require('./_object-dp');\nvar createDesc = require('./_property-desc');\n\nmodule.exports = function (object, index, value) {\n if (index in object) $defineProperty.f(object, index, createDesc(0, value));\n else object[index] = value;\n};\n","// optional / simple context binding\nvar aFunction = require('./_a-function');\nmodule.exports = function (fn, that, length) {\n aFunction(fn);\n if (that === undefined) return fn;\n switch (length) {\n case 1: return function (a) {\n return fn.call(that, a);\n };\n case 2: return function (a, b) {\n return fn.call(that, a, b);\n };\n case 3: return function (a, b, c) {\n return fn.call(that, a, b, c);\n };\n }\n return function (/* ...args */) {\n return fn.apply(that, arguments);\n };\n};\n","'use strict';\n// 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString()\nvar fails = require('./_fails');\nvar getTime = Date.prototype.getTime;\nvar $toISOString = Date.prototype.toISOString;\n\nvar lz = function (num) {\n return num > 9 ? num : '0' + num;\n};\n\n// PhantomJS / old WebKit has a broken implementations\nmodule.exports = (fails(function () {\n return $toISOString.call(new Date(-5e13 - 1)) != '0385-07-25T07:06:39.999Z';\n}) || !fails(function () {\n $toISOString.call(new Date(NaN));\n})) ? function toISOString() {\n if (!isFinite(getTime.call(this))) throw RangeError('Invalid time value');\n var d = this;\n var y = d.getUTCFullYear();\n var m = d.getUTCMilliseconds();\n var s = y < 0 ? '-' : y > 9999 ? '+' : '';\n return s + ('00000' + Math.abs(y)).slice(s ? -6 : -4) +\n '-' + lz(d.getUTCMonth() + 1) + '-' + lz(d.getUTCDate()) +\n 'T' + lz(d.getUTCHours()) + ':' + lz(d.getUTCMinutes()) +\n ':' + lz(d.getUTCSeconds()) + '.' + (m > 99 ? m : '0' + lz(m)) + 'Z';\n} : $toISOString;\n","'use strict';\nvar anObject = require('./_an-object');\nvar toPrimitive = require('./_to-primitive');\nvar NUMBER = 'number';\n\nmodule.exports = function (hint) {\n if (hint !== 'string' && hint !== NUMBER && hint !== 'default') throw TypeError('Incorrect hint');\n return toPrimitive(anObject(this), hint != NUMBER);\n};\n","// 7.2.1 RequireObjectCoercible(argument)\nmodule.exports = function (it) {\n if (it == undefined) throw TypeError(\"Can't call method on \" + it);\n return it;\n};\n","// Thank's IE8 for his funny defineProperty\nmodule.exports = !require('./_fails')(function () {\n return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;\n});\n","var isObject = require('./_is-object');\nvar document = require('./_global').document;\n// typeof document.createElement is 'object' in old IE\nvar is = isObject(document) && isObject(document.createElement);\nmodule.exports = function (it) {\n return is ? document.createElement(it) : {};\n};\n","// IE 8- don't enum bug keys\nmodule.exports = (\n 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'\n).split(',');\n","// all enumerable object keys, includes symbols\nvar getKeys = require('./_object-keys');\nvar gOPS = require('./_object-gops');\nvar pIE = require('./_object-pie');\nmodule.exports = function (it) {\n var result = getKeys(it);\n var getSymbols = gOPS.f;\n if (getSymbols) {\n var symbols = getSymbols(it);\n var isEnum = pIE.f;\n var i = 0;\n var key;\n while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key);\n } return result;\n};\n","var global = require('./_global');\nvar core = require('./_core');\nvar hide = require('./_hide');\nvar redefine = require('./_redefine');\nvar ctx = require('./_ctx');\nvar PROTOTYPE = 'prototype';\n\nvar $export = function (type, name, source) {\n var IS_FORCED = type & $export.F;\n var IS_GLOBAL = type & $export.G;\n var IS_STATIC = type & $export.S;\n var IS_PROTO = type & $export.P;\n var IS_BIND = type & $export.B;\n var target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE];\n var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});\n var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});\n var key, own, out, exp;\n if (IS_GLOBAL) source = name;\n for (key in source) {\n // contains in native\n own = !IS_FORCED && target && target[key] !== undefined;\n // export native or passed\n out = (own ? target : source)[key];\n // bind timers to global for call from export context\n exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;\n // extend global\n if (target) redefine(target, key, out, type & $export.U);\n // export\n if (exports[key] != out) hide(exports, key, exp);\n if (IS_PROTO && expProto[key] != out) expProto[key] = out;\n }\n};\nglobal.core = core;\n// type bitmap\n$export.F = 1; // forced\n$export.G = 2; // global\n$export.S = 4; // static\n$export.P = 8; // proto\n$export.B = 16; // bind\n$export.W = 32; // wrap\n$export.U = 64; // safe\n$export.R = 128; // real proto method for `library`\nmodule.exports = $export;\n","var MATCH = require('./_wks')('match');\nmodule.exports = function (KEY) {\n var re = /./;\n try {\n '/./'[KEY](re);\n } catch (e) {\n try {\n re[MATCH] = false;\n return !'/./'[KEY](re);\n } catch (f) { /* empty */ }\n } return true;\n};\n","module.exports = function (exec) {\n try {\n return !!exec();\n } catch (e) {\n return true;\n }\n};\n","'use strict';\nrequire('./es6.regexp.exec');\nvar redefine = require('./_redefine');\nvar hide = require('./_hide');\nvar fails = require('./_fails');\nvar defined = require('./_defined');\nvar wks = require('./_wks');\nvar regexpExec = require('./_regexp-exec');\n\nvar SPECIES = wks('species');\n\nvar REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {\n // #replace needs built-in support for named groups.\n // #match works fine because it just return the exec results, even if it has\n // a \"grops\" property.\n var re = /./;\n re.exec = function () {\n var result = [];\n result.groups = { a: '7' };\n return result;\n };\n return ''.replace(re, '$') !== '7';\n});\n\nvar SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = (function () {\n // Chrome 51 has a buggy \"split\" implementation when RegExp#exec !== nativeExec\n var re = /(?:)/;\n var originalExec = re.exec;\n re.exec = function () { return originalExec.apply(this, arguments); };\n var result = 'ab'.split(re);\n return result.length === 2 && result[0] === 'a' && result[1] === 'b';\n})();\n\nmodule.exports = function (KEY, length, exec) {\n var SYMBOL = wks(KEY);\n\n var DELEGATES_TO_SYMBOL = !fails(function () {\n // String methods call symbol-named RegEp methods\n var O = {};\n O[SYMBOL] = function () { return 7; };\n return ''[KEY](O) != 7;\n });\n\n var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL ? !fails(function () {\n // Symbol-named RegExp methods call .exec\n var execCalled = false;\n var re = /a/;\n re.exec = function () { execCalled = true; return null; };\n if (KEY === 'split') {\n // RegExp[@@split] doesn't call the regex's exec method, but first creates\n // a new one. We need to return the patched regex when creating the new one.\n re.constructor = {};\n re.constructor[SPECIES] = function () { return re; };\n }\n re[SYMBOL]('');\n return !execCalled;\n }) : undefined;\n\n if (\n !DELEGATES_TO_SYMBOL ||\n !DELEGATES_TO_EXEC ||\n (KEY === 'replace' && !REPLACE_SUPPORTS_NAMED_GROUPS) ||\n (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC)\n ) {\n var nativeRegExpMethod = /./[SYMBOL];\n var fns = exec(\n defined,\n SYMBOL,\n ''[KEY],\n function maybeCallNative(nativeMethod, regexp, str, arg2, forceStringMethod) {\n if (regexp.exec === regexpExec) {\n if (DELEGATES_TO_SYMBOL && !forceStringMethod) {\n // The native String method already delegates to @@method (this\n // polyfilled function), leasing to infinite recursion.\n // We avoid it by directly calling the native @@method method.\n return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };\n }\n return { done: true, value: nativeMethod.call(str, regexp, arg2) };\n }\n return { done: false };\n }\n );\n var strfn = fns[0];\n var rxfn = fns[1];\n\n redefine(String.prototype, KEY, strfn);\n hide(RegExp.prototype, SYMBOL, length == 2\n // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)\n // 21.2.5.11 RegExp.prototype[@@split](string, limit)\n ? function (string, arg) { return rxfn.call(string, this, arg); }\n // 21.2.5.6 RegExp.prototype[@@match](string)\n // 21.2.5.9 RegExp.prototype[@@search](string)\n : function (string) { return rxfn.call(string, this); }\n );\n }\n};\n","'use strict';\n// 21.2.5.3 get RegExp.prototype.flags\nvar anObject = require('./_an-object');\nmodule.exports = function () {\n var that = anObject(this);\n var result = '';\n if (that.global) result += 'g';\n if (that.ignoreCase) result += 'i';\n if (that.multiline) result += 'm';\n if (that.unicode) result += 'u';\n if (that.sticky) result += 'y';\n return result;\n};\n","'use strict';\n// https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray\nvar isArray = require('./_is-array');\nvar isObject = require('./_is-object');\nvar toLength = require('./_to-length');\nvar ctx = require('./_ctx');\nvar IS_CONCAT_SPREADABLE = require('./_wks')('isConcatSpreadable');\n\nfunction flattenIntoArray(target, original, source, sourceLen, start, depth, mapper, thisArg) {\n var targetIndex = start;\n var sourceIndex = 0;\n var mapFn = mapper ? ctx(mapper, thisArg, 3) : false;\n var element, spreadable;\n\n while (sourceIndex < sourceLen) {\n if (sourceIndex in source) {\n element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];\n\n spreadable = false;\n if (isObject(element)) {\n spreadable = element[IS_CONCAT_SPREADABLE];\n spreadable = spreadable !== undefined ? !!spreadable : isArray(element);\n }\n\n if (spreadable && depth > 0) {\n targetIndex = flattenIntoArray(target, original, element, toLength(element.length), targetIndex, depth - 1) - 1;\n } else {\n if (targetIndex >= 0x1fffffffffffff) throw TypeError();\n target[targetIndex] = element;\n }\n\n targetIndex++;\n }\n sourceIndex++;\n }\n return targetIndex;\n}\n\nmodule.exports = flattenIntoArray;\n","var ctx = require('./_ctx');\nvar call = require('./_iter-call');\nvar isArrayIter = require('./_is-array-iter');\nvar anObject = require('./_an-object');\nvar toLength = require('./_to-length');\nvar getIterFn = require('./core.get-iterator-method');\nvar BREAK = {};\nvar RETURN = {};\nvar exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {\n var iterFn = ITERATOR ? function () { return iterable; } : getIterFn(iterable);\n var f = ctx(fn, that, entries ? 2 : 1);\n var index = 0;\n var length, step, iterator, result;\n if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');\n // fast case for arrays with default iterator\n if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) {\n result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);\n if (result === BREAK || result === RETURN) return result;\n } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {\n result = call(iterator, f, step.value, entries);\n if (result === BREAK || result === RETURN) return result;\n }\n};\nexports.BREAK = BREAK;\nexports.RETURN = RETURN;\n","module.exports = require('./_shared')('native-function-to-string', Function.toString);\n","// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028\nvar global = module.exports = typeof window != 'undefined' && window.Math == Math\n ? window : typeof self != 'undefined' && self.Math == Math ? self\n // eslint-disable-next-line no-new-func\n : Function('return this')();\nif (typeof __g == 'number') __g = global; // eslint-disable-line no-undef\n","var hasOwnProperty = {}.hasOwnProperty;\nmodule.exports = function (it, key) {\n return hasOwnProperty.call(it, key);\n};\n","var dP = require('./_object-dp');\nvar createDesc = require('./_property-desc');\nmodule.exports = require('./_descriptors') ? function (object, key, value) {\n return dP.f(object, key, createDesc(1, value));\n} : function (object, key, value) {\n object[key] = value;\n return object;\n};\n","var document = require('./_global').document;\nmodule.exports = document && document.documentElement;\n","module.exports = !require('./_descriptors') && !require('./_fails')(function () {\n return Object.defineProperty(require('./_dom-create')('div'), 'a', { get: function () { return 7; } }).a != 7;\n});\n","var isObject = require('./_is-object');\nvar setPrototypeOf = require('./_set-proto').set;\nmodule.exports = function (that, target, C) {\n var S = target.constructor;\n var P;\n if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && setPrototypeOf) {\n setPrototypeOf(that, P);\n } return that;\n};\n","// fast apply, http://jsperf.lnkit.com/fast-apply/5\nmodule.exports = function (fn, args, that) {\n var un = that === undefined;\n switch (args.length) {\n case 0: return un ? fn()\n : fn.call(that);\n case 1: return un ? fn(args[0])\n : fn.call(that, args[0]);\n case 2: return un ? fn(args[0], args[1])\n : fn.call(that, args[0], args[1]);\n case 3: return un ? fn(args[0], args[1], args[2])\n : fn.call(that, args[0], args[1], args[2]);\n case 4: return un ? fn(args[0], args[1], args[2], args[3])\n : fn.call(that, args[0], args[1], args[2], args[3]);\n } return fn.apply(that, args);\n};\n","// fallback for non-array-like ES3 and non-enumerable old V8 strings\nvar cof = require('./_cof');\n// eslint-disable-next-line no-prototype-builtins\nmodule.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {\n return cof(it) == 'String' ? it.split('') : Object(it);\n};\n","// check on default Array iterator\nvar Iterators = require('./_iterators');\nvar ITERATOR = require('./_wks')('iterator');\nvar ArrayProto = Array.prototype;\n\nmodule.exports = function (it) {\n return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);\n};\n","// 7.2.2 IsArray(argument)\nvar cof = require('./_cof');\nmodule.exports = Array.isArray || function isArray(arg) {\n return cof(arg) == 'Array';\n};\n","// 20.1.2.3 Number.isInteger(number)\nvar isObject = require('./_is-object');\nvar floor = Math.floor;\nmodule.exports = function isInteger(it) {\n return !isObject(it) && isFinite(it) && floor(it) === it;\n};\n","module.exports = function (it) {\n return typeof it === 'object' ? it !== null : typeof it === 'function';\n};\n","// 7.2.8 IsRegExp(argument)\nvar isObject = require('./_is-object');\nvar cof = require('./_cof');\nvar MATCH = require('./_wks')('match');\nmodule.exports = function (it) {\n var isRegExp;\n return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp');\n};\n","// call something on iterator step with safe closing on error\nvar anObject = require('./_an-object');\nmodule.exports = function (iterator, fn, value, entries) {\n try {\n return entries ? fn(anObject(value)[0], value[1]) : fn(value);\n // 7.4.6 IteratorClose(iterator, completion)\n } catch (e) {\n var ret = iterator['return'];\n if (ret !== undefined) anObject(ret.call(iterator));\n throw e;\n }\n};\n","'use strict';\nvar create = require('./_object-create');\nvar descriptor = require('./_property-desc');\nvar setToStringTag = require('./_set-to-string-tag');\nvar IteratorPrototype = {};\n\n// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()\nrequire('./_hide')(IteratorPrototype, require('./_wks')('iterator'), function () { return this; });\n\nmodule.exports = function (Constructor, NAME, next) {\n Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });\n setToStringTag(Constructor, NAME + ' Iterator');\n};\n","'use strict';\nvar LIBRARY = require('./_library');\nvar $export = require('./_export');\nvar redefine = require('./_redefine');\nvar hide = require('./_hide');\nvar Iterators = require('./_iterators');\nvar $iterCreate = require('./_iter-create');\nvar setToStringTag = require('./_set-to-string-tag');\nvar getPrototypeOf = require('./_object-gpo');\nvar ITERATOR = require('./_wks')('iterator');\nvar BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`\nvar FF_ITERATOR = '@@iterator';\nvar KEYS = 'keys';\nvar VALUES = 'values';\n\nvar returnThis = function () { return this; };\n\nmodule.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {\n $iterCreate(Constructor, NAME, next);\n var getMethod = function (kind) {\n if (!BUGGY && kind in proto) return proto[kind];\n switch (kind) {\n case KEYS: return function keys() { return new Constructor(this, kind); };\n case VALUES: return function values() { return new Constructor(this, kind); };\n } return function entries() { return new Constructor(this, kind); };\n };\n var TAG = NAME + ' Iterator';\n var DEF_VALUES = DEFAULT == VALUES;\n var VALUES_BUG = false;\n var proto = Base.prototype;\n var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];\n var $default = $native || getMethod(DEFAULT);\n var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;\n var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;\n var methods, key, IteratorPrototype;\n // Fix native\n if ($anyNative) {\n IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));\n if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {\n // Set @@toStringTag to native iterators\n setToStringTag(IteratorPrototype, TAG, true);\n // fix for some old engines\n if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis);\n }\n }\n // fix Array#{values, @@iterator}.name in V8 / FF\n if (DEF_VALUES && $native && $native.name !== VALUES) {\n VALUES_BUG = true;\n $default = function values() { return $native.call(this); };\n }\n // Define iterator\n if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {\n hide(proto, ITERATOR, $default);\n }\n // Plug for library\n Iterators[NAME] = $default;\n Iterators[TAG] = returnThis;\n if (DEFAULT) {\n methods = {\n values: DEF_VALUES ? $default : getMethod(VALUES),\n keys: IS_SET ? $default : getMethod(KEYS),\n entries: $entries\n };\n if (FORCED) for (key in methods) {\n if (!(key in proto)) redefine(proto, key, methods[key]);\n } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);\n }\n return methods;\n};\n","var ITERATOR = require('./_wks')('iterator');\nvar SAFE_CLOSING = false;\n\ntry {\n var riter = [7][ITERATOR]();\n riter['return'] = function () { SAFE_CLOSING = true; };\n // eslint-disable-next-line no-throw-literal\n Array.from(riter, function () { throw 2; });\n} catch (e) { /* empty */ }\n\nmodule.exports = function (exec, skipClosing) {\n if (!skipClosing && !SAFE_CLOSING) return false;\n var safe = false;\n try {\n var arr = [7];\n var iter = arr[ITERATOR]();\n iter.next = function () { return { done: safe = true }; };\n arr[ITERATOR] = function () { return iter; };\n exec(arr);\n } catch (e) { /* empty */ }\n return safe;\n};\n","module.exports = function (done, value) {\n return { value: value, done: !!done };\n};\n","module.exports = {};\n","module.exports = false;\n","// 20.2.2.14 Math.expm1(x)\nvar $expm1 = Math.expm1;\nmodule.exports = (!$expm1\n // Old FF bug\n || $expm1(10) > 22025.465794806719 || $expm1(10) < 22025.4657948067165168\n // Tor Browser bug\n || $expm1(-2e-17) != -2e-17\n) ? function expm1(x) {\n return (x = +x) == 0 ? x : x > -1e-6 && x < 1e-6 ? x + x * x / 2 : Math.exp(x) - 1;\n} : $expm1;\n","// 20.2.2.16 Math.fround(x)\nvar sign = require('./_math-sign');\nvar pow = Math.pow;\nvar EPSILON = pow(2, -52);\nvar EPSILON32 = pow(2, -23);\nvar MAX32 = pow(2, 127) * (2 - EPSILON32);\nvar MIN32 = pow(2, -126);\n\nvar roundTiesToEven = function (n) {\n return n + 1 / EPSILON - 1 / EPSILON;\n};\n\nmodule.exports = Math.fround || function fround(x) {\n var $abs = Math.abs(x);\n var $sign = sign(x);\n var a, result;\n if ($abs < MIN32) return $sign * roundTiesToEven($abs / MIN32 / EPSILON32) * MIN32 * EPSILON32;\n a = (1 + EPSILON32 / EPSILON) * $abs;\n result = a - (a - $abs);\n // eslint-disable-next-line no-self-compare\n if (result > MAX32 || result != result) return $sign * Infinity;\n return $sign * result;\n};\n","// 20.2.2.20 Math.log1p(x)\nmodule.exports = Math.log1p || function log1p(x) {\n return (x = +x) > -1e-8 && x < 1e-8 ? x - x * x / 2 : Math.log(1 + x);\n};\n","// 20.2.2.28 Math.sign(x)\nmodule.exports = Math.sign || function sign(x) {\n // eslint-disable-next-line no-self-compare\n return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1;\n};\n","var META = require('./_uid')('meta');\nvar isObject = require('./_is-object');\nvar has = require('./_has');\nvar setDesc = require('./_object-dp').f;\nvar id = 0;\nvar isExtensible = Object.isExtensible || function () {\n return true;\n};\nvar FREEZE = !require('./_fails')(function () {\n return isExtensible(Object.preventExtensions({}));\n});\nvar setMeta = function (it) {\n setDesc(it, META, { value: {\n i: 'O' + ++id, // object ID\n w: {} // weak collections IDs\n } });\n};\nvar fastKey = function (it, create) {\n // return primitive with prefix\n if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;\n if (!has(it, META)) {\n // can't set metadata to uncaught frozen object\n if (!isExtensible(it)) return 'F';\n // not necessary to add metadata\n if (!create) return 'E';\n // add missing metadata\n setMeta(it);\n // return object ID\n } return it[META].i;\n};\nvar getWeak = function (it, create) {\n if (!has(it, META)) {\n // can't set metadata to uncaught frozen object\n if (!isExtensible(it)) return true;\n // not necessary to add metadata\n if (!create) return false;\n // add missing metadata\n setMeta(it);\n // return hash weak collections IDs\n } return it[META].w;\n};\n// add metadata on freeze-family methods calling\nvar onFreeze = function (it) {\n if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);\n return it;\n};\nvar meta = module.exports = {\n KEY: META,\n NEED: false,\n fastKey: fastKey,\n getWeak: getWeak,\n onFreeze: onFreeze\n};\n","var global = require('./_global');\nvar macrotask = require('./_task').set;\nvar Observer = global.MutationObserver || global.WebKitMutationObserver;\nvar process = global.process;\nvar Promise = global.Promise;\nvar isNode = require('./_cof')(process) == 'process';\n\nmodule.exports = function () {\n var head, last, notify;\n\n var flush = function () {\n var parent, fn;\n if (isNode && (parent = process.domain)) parent.exit();\n while (head) {\n fn = head.fn;\n head = head.next;\n try {\n fn();\n } catch (e) {\n if (head) notify();\n else last = undefined;\n throw e;\n }\n } last = undefined;\n if (parent) parent.enter();\n };\n\n // Node.js\n if (isNode) {\n notify = function () {\n process.nextTick(flush);\n };\n // browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339\n } else if (Observer && !(global.navigator && global.navigator.standalone)) {\n var toggle = true;\n var node = document.createTextNode('');\n new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new\n notify = function () {\n node.data = toggle = !toggle;\n };\n // environments with maybe non-completely correct, but existent Promise\n } else if (Promise && Promise.resolve) {\n // Promise.resolve without an argument throws an error in LG WebOS 2\n var promise = Promise.resolve(undefined);\n notify = function () {\n promise.then(flush);\n };\n // for other environments - macrotask based on:\n // - setImmediate\n // - MessageChannel\n // - window.postMessag\n // - onreadystatechange\n // - setTimeout\n } else {\n notify = function () {\n // strange IE + webpack dev server bug - use .call(global)\n macrotask.call(global, flush);\n };\n }\n\n return function (fn) {\n var task = { fn: fn, next: undefined };\n if (last) last.next = task;\n if (!head) {\n head = task;\n notify();\n } last = task;\n };\n};\n","'use strict';\n// 25.4.1.5 NewPromiseCapability(C)\nvar aFunction = require('./_a-function');\n\nfunction PromiseCapability(C) {\n var resolve, reject;\n this.promise = new C(function ($$resolve, $$reject) {\n if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');\n resolve = $$resolve;\n reject = $$reject;\n });\n this.resolve = aFunction(resolve);\n this.reject = aFunction(reject);\n}\n\nmodule.exports.f = function (C) {\n return new PromiseCapability(C);\n};\n","'use strict';\n// 19.1.2.1 Object.assign(target, source, ...)\nvar DESCRIPTORS = require('./_descriptors');\nvar getKeys = require('./_object-keys');\nvar gOPS = require('./_object-gops');\nvar pIE = require('./_object-pie');\nvar toObject = require('./_to-object');\nvar IObject = require('./_iobject');\nvar $assign = Object.assign;\n\n// should work with symbols and should have deterministic property order (V8 bug)\nmodule.exports = !$assign || require('./_fails')(function () {\n var A = {};\n var B = {};\n // eslint-disable-next-line no-undef\n var S = Symbol();\n var K = 'abcdefghijklmnopqrst';\n A[S] = 7;\n K.split('').forEach(function (k) { B[k] = k; });\n return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;\n}) ? function assign(target, source) { // eslint-disable-line no-unused-vars\n var T = toObject(target);\n var aLen = arguments.length;\n var index = 1;\n var getSymbols = gOPS.f;\n var isEnum = pIE.f;\n while (aLen > index) {\n var S = IObject(arguments[index++]);\n var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);\n var length = keys.length;\n var j = 0;\n var key;\n while (length > j) {\n key = keys[j++];\n if (!DESCRIPTORS || isEnum.call(S, key)) T[key] = S[key];\n }\n } return T;\n} : $assign;\n","// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])\nvar anObject = require('./_an-object');\nvar dPs = require('./_object-dps');\nvar enumBugKeys = require('./_enum-bug-keys');\nvar IE_PROTO = require('./_shared-key')('IE_PROTO');\nvar Empty = function () { /* empty */ };\nvar PROTOTYPE = 'prototype';\n\n// Create object with fake `null` prototype: use iframe Object with cleared prototype\nvar createDict = function () {\n // Thrash, waste and sodomy: IE GC bug\n var iframe = require('./_dom-create')('iframe');\n var i = enumBugKeys.length;\n var lt = '<';\n var gt = '>';\n var iframeDocument;\n iframe.style.display = 'none';\n require('./_html').appendChild(iframe);\n iframe.src = 'javascript:'; // eslint-disable-line no-script-url\n // createDict = iframe.contentWindow.Object;\n // html.removeChild(iframe);\n iframeDocument = iframe.contentWindow.document;\n iframeDocument.open();\n iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);\n iframeDocument.close();\n createDict = iframeDocument.F;\n while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];\n return createDict();\n};\n\nmodule.exports = Object.create || function create(O, Properties) {\n var result;\n if (O !== null) {\n Empty[PROTOTYPE] = anObject(O);\n result = new Empty();\n Empty[PROTOTYPE] = null;\n // add \"__proto__\" for Object.getPrototypeOf polyfill\n result[IE_PROTO] = O;\n } else result = createDict();\n return Properties === undefined ? result : dPs(result, Properties);\n};\n","var anObject = require('./_an-object');\nvar IE8_DOM_DEFINE = require('./_ie8-dom-define');\nvar toPrimitive = require('./_to-primitive');\nvar dP = Object.defineProperty;\n\nexports.f = require('./_descriptors') ? Object.defineProperty : function defineProperty(O, P, Attributes) {\n anObject(O);\n P = toPrimitive(P, true);\n anObject(Attributes);\n if (IE8_DOM_DEFINE) try {\n return dP(O, P, Attributes);\n } catch (e) { /* empty */ }\n if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');\n if ('value' in Attributes) O[P] = Attributes.value;\n return O;\n};\n","var dP = require('./_object-dp');\nvar anObject = require('./_an-object');\nvar getKeys = require('./_object-keys');\n\nmodule.exports = require('./_descriptors') ? Object.defineProperties : function defineProperties(O, Properties) {\n anObject(O);\n var keys = getKeys(Properties);\n var length = keys.length;\n var i = 0;\n var P;\n while (length > i) dP.f(O, P = keys[i++], Properties[P]);\n return O;\n};\n","var pIE = require('./_object-pie');\nvar createDesc = require('./_property-desc');\nvar toIObject = require('./_to-iobject');\nvar toPrimitive = require('./_to-primitive');\nvar has = require('./_has');\nvar IE8_DOM_DEFINE = require('./_ie8-dom-define');\nvar gOPD = Object.getOwnPropertyDescriptor;\n\nexports.f = require('./_descriptors') ? gOPD : function getOwnPropertyDescriptor(O, P) {\n O = toIObject(O);\n P = toPrimitive(P, true);\n if (IE8_DOM_DEFINE) try {\n return gOPD(O, P);\n } catch (e) { /* empty */ }\n if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);\n};\n","// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window\nvar toIObject = require('./_to-iobject');\nvar gOPN = require('./_object-gopn').f;\nvar toString = {}.toString;\n\nvar windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames\n ? Object.getOwnPropertyNames(window) : [];\n\nvar getWindowNames = function (it) {\n try {\n return gOPN(it);\n } catch (e) {\n return windowNames.slice();\n }\n};\n\nmodule.exports.f = function getOwnPropertyNames(it) {\n return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));\n};\n","// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)\nvar $keys = require('./_object-keys-internal');\nvar hiddenKeys = require('./_enum-bug-keys').concat('length', 'prototype');\n\nexports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {\n return $keys(O, hiddenKeys);\n};\n","exports.f = Object.getOwnPropertySymbols;\n","// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)\nvar has = require('./_has');\nvar toObject = require('./_to-object');\nvar IE_PROTO = require('./_shared-key')('IE_PROTO');\nvar ObjectProto = Object.prototype;\n\nmodule.exports = Object.getPrototypeOf || function (O) {\n O = toObject(O);\n if (has(O, IE_PROTO)) return O[IE_PROTO];\n if (typeof O.constructor == 'function' && O instanceof O.constructor) {\n return O.constructor.prototype;\n } return O instanceof Object ? ObjectProto : null;\n};\n","var has = require('./_has');\nvar toIObject = require('./_to-iobject');\nvar arrayIndexOf = require('./_array-includes')(false);\nvar IE_PROTO = require('./_shared-key')('IE_PROTO');\n\nmodule.exports = function (object, names) {\n var O = toIObject(object);\n var i = 0;\n var result = [];\n var key;\n for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key);\n // Don't enum bug & hidden keys\n while (names.length > i) if (has(O, key = names[i++])) {\n ~arrayIndexOf(result, key) || result.push(key);\n }\n return result;\n};\n","// 19.1.2.14 / 15.2.3.14 Object.keys(O)\nvar $keys = require('./_object-keys-internal');\nvar enumBugKeys = require('./_enum-bug-keys');\n\nmodule.exports = Object.keys || function keys(O) {\n return $keys(O, enumBugKeys);\n};\n","exports.f = {}.propertyIsEnumerable;\n","// most Object methods by ES6 should accept primitives\nvar $export = require('./_export');\nvar core = require('./_core');\nvar fails = require('./_fails');\nmodule.exports = function (KEY, exec) {\n var fn = (core.Object || {})[KEY] || Object[KEY];\n var exp = {};\n exp[KEY] = exec(fn);\n $export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp);\n};\n","var DESCRIPTORS = require('./_descriptors');\nvar getKeys = require('./_object-keys');\nvar toIObject = require('./_to-iobject');\nvar isEnum = require('./_object-pie').f;\nmodule.exports = function (isEntries) {\n return function (it) {\n var O = toIObject(it);\n var keys = getKeys(O);\n var length = keys.length;\n var i = 0;\n var result = [];\n var key;\n while (length > i) {\n key = keys[i++];\n if (!DESCRIPTORS || isEnum.call(O, key)) {\n result.push(isEntries ? [key, O[key]] : O[key]);\n }\n }\n return result;\n };\n};\n","// all object keys, includes non-enumerable and symbols\nvar gOPN = require('./_object-gopn');\nvar gOPS = require('./_object-gops');\nvar anObject = require('./_an-object');\nvar Reflect = require('./_global').Reflect;\nmodule.exports = Reflect && Reflect.ownKeys || function ownKeys(it) {\n var keys = gOPN.f(anObject(it));\n var getSymbols = gOPS.f;\n return getSymbols ? keys.concat(getSymbols(it)) : keys;\n};\n","var $parseFloat = require('./_global').parseFloat;\nvar $trim = require('./_string-trim').trim;\n\nmodule.exports = 1 / $parseFloat(require('./_string-ws') + '-0') !== -Infinity ? function parseFloat(str) {\n var string = $trim(String(str), 3);\n var result = $parseFloat(string);\n return result === 0 && string.charAt(0) == '-' ? -0 : result;\n} : $parseFloat;\n","var $parseInt = require('./_global').parseInt;\nvar $trim = require('./_string-trim').trim;\nvar ws = require('./_string-ws');\nvar hex = /^[-+]?0[xX]/;\n\nmodule.exports = $parseInt(ws + '08') !== 8 || $parseInt(ws + '0x16') !== 22 ? function parseInt(str, radix) {\n var string = $trim(String(str), 3);\n return $parseInt(string, (radix >>> 0) || (hex.test(string) ? 16 : 10));\n} : $parseInt;\n","module.exports = function (exec) {\n try {\n return { e: false, v: exec() };\n } catch (e) {\n return { e: true, v: e };\n }\n};\n","var anObject = require('./_an-object');\nvar isObject = require('./_is-object');\nvar newPromiseCapability = require('./_new-promise-capability');\n\nmodule.exports = function (C, x) {\n anObject(C);\n if (isObject(x) && x.constructor === C) return x;\n var promiseCapability = newPromiseCapability.f(C);\n var resolve = promiseCapability.resolve;\n resolve(x);\n return promiseCapability.promise;\n};\n","module.exports = function (bitmap, value) {\n return {\n enumerable: !(bitmap & 1),\n configurable: !(bitmap & 2),\n writable: !(bitmap & 4),\n value: value\n };\n};\n","var redefine = require('./_redefine');\nmodule.exports = function (target, src, safe) {\n for (var key in src) redefine(target, key, src[key], safe);\n return target;\n};\n","var global = require('./_global');\nvar hide = require('./_hide');\nvar has = require('./_has');\nvar SRC = require('./_uid')('src');\nvar $toString = require('./_function-to-string');\nvar TO_STRING = 'toString';\nvar TPL = ('' + $toString).split(TO_STRING);\n\nrequire('./_core').inspectSource = function (it) {\n return $toString.call(it);\n};\n\n(module.exports = function (O, key, val, safe) {\n var isFunction = typeof val == 'function';\n if (isFunction) has(val, 'name') || hide(val, 'name', key);\n if (O[key] === val) return;\n if (isFunction) has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));\n if (O === global) {\n O[key] = val;\n } else if (!safe) {\n delete O[key];\n hide(O, key, val);\n } else if (O[key]) {\n O[key] = val;\n } else {\n hide(O, key, val);\n }\n// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative\n})(Function.prototype, TO_STRING, function toString() {\n return typeof this == 'function' && this[SRC] || $toString.call(this);\n});\n","'use strict';\n\nvar classof = require('./_classof');\nvar builtinExec = RegExp.prototype.exec;\n\n // `RegExpExec` abstract operation\n// https://tc39.github.io/ecma262/#sec-regexpexec\nmodule.exports = function (R, S) {\n var exec = R.exec;\n if (typeof exec === 'function') {\n var result = exec.call(R, S);\n if (typeof result !== 'object') {\n throw new TypeError('RegExp exec method returned something other than an Object or null');\n }\n return result;\n }\n if (classof(R) !== 'RegExp') {\n throw new TypeError('RegExp#exec called on incompatible receiver');\n }\n return builtinExec.call(R, S);\n};\n","'use strict';\n\nvar regexpFlags = require('./_flags');\n\nvar nativeExec = RegExp.prototype.exec;\n// This always refers to the native implementation, because the\n// String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js,\n// which loads this file before patching the method.\nvar nativeReplace = String.prototype.replace;\n\nvar patchedExec = nativeExec;\n\nvar LAST_INDEX = 'lastIndex';\n\nvar UPDATES_LAST_INDEX_WRONG = (function () {\n var re1 = /a/,\n re2 = /b*/g;\n nativeExec.call(re1, 'a');\n nativeExec.call(re2, 'a');\n return re1[LAST_INDEX] !== 0 || re2[LAST_INDEX] !== 0;\n})();\n\n// nonparticipating capturing group, copied from es5-shim's String#split patch.\nvar NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;\n\nvar PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED;\n\nif (PATCH) {\n patchedExec = function exec(str) {\n var re = this;\n var lastIndex, reCopy, match, i;\n\n if (NPCG_INCLUDED) {\n reCopy = new RegExp('^' + re.source + '$(?!\\\\s)', regexpFlags.call(re));\n }\n if (UPDATES_LAST_INDEX_WRONG) lastIndex = re[LAST_INDEX];\n\n match = nativeExec.call(re, str);\n\n if (UPDATES_LAST_INDEX_WRONG && match) {\n re[LAST_INDEX] = re.global ? match.index + match[0].length : lastIndex;\n }\n if (NPCG_INCLUDED && match && match.length > 1) {\n // Fix browsers whose `exec` methods don't consistently return `undefined`\n // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/\n // eslint-disable-next-line no-loop-func\n nativeReplace.call(match[0], reCopy, function () {\n for (i = 1; i < arguments.length - 2; i++) {\n if (arguments[i] === undefined) match[i] = undefined;\n }\n });\n }\n\n return match;\n };\n}\n\nmodule.exports = patchedExec;\n","// 7.2.9 SameValue(x, y)\nmodule.exports = Object.is || function is(x, y) {\n // eslint-disable-next-line no-self-compare\n return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;\n};\n","// Works with __proto__ only. Old v8 can't work with null proto objects.\n/* eslint-disable no-proto */\nvar isObject = require('./_is-object');\nvar anObject = require('./_an-object');\nvar check = function (O, proto) {\n anObject(O);\n if (!isObject(proto) && proto !== null) throw TypeError(proto + \": can't set as prototype!\");\n};\nmodule.exports = {\n set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line\n function (test, buggy, set) {\n try {\n set = require('./_ctx')(Function.call, require('./_object-gopd').f(Object.prototype, '__proto__').set, 2);\n set(test, []);\n buggy = !(test instanceof Array);\n } catch (e) { buggy = true; }\n return function setPrototypeOf(O, proto) {\n check(O, proto);\n if (buggy) O.__proto__ = proto;\n else set(O, proto);\n return O;\n };\n }({}, false) : undefined),\n check: check\n};\n","'use strict';\nvar global = require('./_global');\nvar dP = require('./_object-dp');\nvar DESCRIPTORS = require('./_descriptors');\nvar SPECIES = require('./_wks')('species');\n\nmodule.exports = function (KEY) {\n var C = global[KEY];\n if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, {\n configurable: true,\n get: function () { return this; }\n });\n};\n","var def = require('./_object-dp').f;\nvar has = require('./_has');\nvar TAG = require('./_wks')('toStringTag');\n\nmodule.exports = function (it, tag, stat) {\n if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });\n};\n","var shared = require('./_shared')('keys');\nvar uid = require('./_uid');\nmodule.exports = function (key) {\n return shared[key] || (shared[key] = uid(key));\n};\n","var core = require('./_core');\nvar global = require('./_global');\nvar SHARED = '__core-js_shared__';\nvar store = global[SHARED] || (global[SHARED] = {});\n\n(module.exports = function (key, value) {\n return store[key] || (store[key] = value !== undefined ? value : {});\n})('versions', []).push({\n version: core.version,\n mode: require('./_library') ? 'pure' : 'global',\n copyright: '© 2019 Denis Pushkarev (zloirock.ru)'\n});\n","// 7.3.20 SpeciesConstructor(O, defaultConstructor)\nvar anObject = require('./_an-object');\nvar aFunction = require('./_a-function');\nvar SPECIES = require('./_wks')('species');\nmodule.exports = function (O, D) {\n var C = anObject(O).constructor;\n var S;\n return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);\n};\n","'use strict';\nvar fails = require('./_fails');\n\nmodule.exports = function (method, arg) {\n return !!method && fails(function () {\n // eslint-disable-next-line no-useless-call\n arg ? method.call(null, function () { /* empty */ }, 1) : method.call(null);\n });\n};\n","var toInteger = require('./_to-integer');\nvar defined = require('./_defined');\n// true -> String#at\n// false -> String#codePointAt\nmodule.exports = function (TO_STRING) {\n return function (that, pos) {\n var s = String(defined(that));\n var i = toInteger(pos);\n var l = s.length;\n var a, b;\n if (i < 0 || i >= l) return TO_STRING ? '' : undefined;\n a = s.charCodeAt(i);\n return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff\n ? TO_STRING ? s.charAt(i) : a\n : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;\n };\n};\n","// helper for String#{startsWith, endsWith, includes}\nvar isRegExp = require('./_is-regexp');\nvar defined = require('./_defined');\n\nmodule.exports = function (that, searchString, NAME) {\n if (isRegExp(searchString)) throw TypeError('String#' + NAME + \" doesn't accept regex!\");\n return String(defined(that));\n};\n","var $export = require('./_export');\nvar fails = require('./_fails');\nvar defined = require('./_defined');\nvar quot = /\"/g;\n// B.2.3.2.1 CreateHTML(string, tag, attribute, value)\nvar createHTML = function (string, tag, attribute, value) {\n var S = String(defined(string));\n var p1 = '<' + tag;\n if (attribute !== '') p1 += ' ' + attribute + '=\"' + String(value).replace(quot, '"') + '\"';\n return p1 + '>' + S + '';\n};\nmodule.exports = function (NAME, exec) {\n var O = {};\n O[NAME] = exec(createHTML);\n $export($export.P + $export.F * fails(function () {\n var test = ''[NAME]('\"');\n return test !== test.toLowerCase() || test.split('\"').length > 3;\n }), 'String', O);\n};\n","// https://github.com/tc39/proposal-string-pad-start-end\nvar toLength = require('./_to-length');\nvar repeat = require('./_string-repeat');\nvar defined = require('./_defined');\n\nmodule.exports = function (that, maxLength, fillString, left) {\n var S = String(defined(that));\n var stringLength = S.length;\n var fillStr = fillString === undefined ? ' ' : String(fillString);\n var intMaxLength = toLength(maxLength);\n if (intMaxLength <= stringLength || fillStr == '') return S;\n var fillLen = intMaxLength - stringLength;\n var stringFiller = repeat.call(fillStr, Math.ceil(fillLen / fillStr.length));\n if (stringFiller.length > fillLen) stringFiller = stringFiller.slice(0, fillLen);\n return left ? stringFiller + S : S + stringFiller;\n};\n","'use strict';\nvar toInteger = require('./_to-integer');\nvar defined = require('./_defined');\n\nmodule.exports = function repeat(count) {\n var str = String(defined(this));\n var res = '';\n var n = toInteger(count);\n if (n < 0 || n == Infinity) throw RangeError(\"Count can't be negative\");\n for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) res += str;\n return res;\n};\n","var $export = require('./_export');\nvar defined = require('./_defined');\nvar fails = require('./_fails');\nvar spaces = require('./_string-ws');\nvar space = '[' + spaces + ']';\nvar non = '\\u200b\\u0085';\nvar ltrim = RegExp('^' + space + space + '*');\nvar rtrim = RegExp(space + space + '*$');\n\nvar exporter = function (KEY, exec, ALIAS) {\n var exp = {};\n var FORCE = fails(function () {\n return !!spaces[KEY]() || non[KEY]() != non;\n });\n var fn = exp[KEY] = FORCE ? exec(trim) : spaces[KEY];\n if (ALIAS) exp[ALIAS] = fn;\n $export($export.P + $export.F * FORCE, 'String', exp);\n};\n\n// 1 -> String#trimLeft\n// 2 -> String#trimRight\n// 3 -> String#trim\nvar trim = exporter.trim = function (string, TYPE) {\n string = String(defined(string));\n if (TYPE & 1) string = string.replace(ltrim, '');\n if (TYPE & 2) string = string.replace(rtrim, '');\n return string;\n};\n\nmodule.exports = exporter;\n","module.exports = '\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\xA0\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003' +\n '\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF';\n","var ctx = require('./_ctx');\nvar invoke = require('./_invoke');\nvar html = require('./_html');\nvar cel = require('./_dom-create');\nvar global = require('./_global');\nvar process = global.process;\nvar setTask = global.setImmediate;\nvar clearTask = global.clearImmediate;\nvar MessageChannel = global.MessageChannel;\nvar Dispatch = global.Dispatch;\nvar counter = 0;\nvar queue = {};\nvar ONREADYSTATECHANGE = 'onreadystatechange';\nvar defer, channel, port;\nvar run = function () {\n var id = +this;\n // eslint-disable-next-line no-prototype-builtins\n if (queue.hasOwnProperty(id)) {\n var fn = queue[id];\n delete queue[id];\n fn();\n }\n};\nvar listener = function (event) {\n run.call(event.data);\n};\n// Node.js 0.9+ & IE10+ has setImmediate, otherwise:\nif (!setTask || !clearTask) {\n setTask = function setImmediate(fn) {\n var args = [];\n var i = 1;\n while (arguments.length > i) args.push(arguments[i++]);\n queue[++counter] = function () {\n // eslint-disable-next-line no-new-func\n invoke(typeof fn == 'function' ? fn : Function(fn), args);\n };\n defer(counter);\n return counter;\n };\n clearTask = function clearImmediate(id) {\n delete queue[id];\n };\n // Node.js 0.8-\n if (require('./_cof')(process) == 'process') {\n defer = function (id) {\n process.nextTick(ctx(run, id, 1));\n };\n // Sphere (JS game engine) Dispatch API\n } else if (Dispatch && Dispatch.now) {\n defer = function (id) {\n Dispatch.now(ctx(run, id, 1));\n };\n // Browsers with MessageChannel, includes WebWorkers\n } else if (MessageChannel) {\n channel = new MessageChannel();\n port = channel.port2;\n channel.port1.onmessage = listener;\n defer = ctx(port.postMessage, port, 1);\n // Browsers with postMessage, skip WebWorkers\n // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'\n } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) {\n defer = function (id) {\n global.postMessage(id + '', '*');\n };\n global.addEventListener('message', listener, false);\n // IE8-\n } else if (ONREADYSTATECHANGE in cel('script')) {\n defer = function (id) {\n html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function () {\n html.removeChild(this);\n run.call(id);\n };\n };\n // Rest old browsers\n } else {\n defer = function (id) {\n setTimeout(ctx(run, id, 1), 0);\n };\n }\n}\nmodule.exports = {\n set: setTask,\n clear: clearTask\n};\n","var toInteger = require('./_to-integer');\nvar max = Math.max;\nvar min = Math.min;\nmodule.exports = function (index, length) {\n index = toInteger(index);\n return index < 0 ? max(index + length, 0) : min(index, length);\n};\n","// https://tc39.github.io/ecma262/#sec-toindex\nvar toInteger = require('./_to-integer');\nvar toLength = require('./_to-length');\nmodule.exports = function (it) {\n if (it === undefined) return 0;\n var number = toInteger(it);\n var length = toLength(number);\n if (number !== length) throw RangeError('Wrong length!');\n return length;\n};\n","// 7.1.4 ToInteger\nvar ceil = Math.ceil;\nvar floor = Math.floor;\nmodule.exports = function (it) {\n return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);\n};\n","// to indexed object, toObject with fallback for non-array-like ES3 strings\nvar IObject = require('./_iobject');\nvar defined = require('./_defined');\nmodule.exports = function (it) {\n return IObject(defined(it));\n};\n","// 7.1.15 ToLength\nvar toInteger = require('./_to-integer');\nvar min = Math.min;\nmodule.exports = function (it) {\n return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991\n};\n","// 7.1.13 ToObject(argument)\nvar defined = require('./_defined');\nmodule.exports = function (it) {\n return Object(defined(it));\n};\n","// 7.1.1 ToPrimitive(input [, PreferredType])\nvar isObject = require('./_is-object');\n// instead of the ES6 spec version, we didn't implement @@toPrimitive case\n// and the second argument - flag - preferred type is a string\nmodule.exports = function (it, S) {\n if (!isObject(it)) return it;\n var fn, val;\n if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;\n if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;\n if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;\n throw TypeError(\"Can't convert object to primitive value\");\n};\n","'use strict';\nif (require('./_descriptors')) {\n var LIBRARY = require('./_library');\n var global = require('./_global');\n var fails = require('./_fails');\n var $export = require('./_export');\n var $typed = require('./_typed');\n var $buffer = require('./_typed-buffer');\n var ctx = require('./_ctx');\n var anInstance = require('./_an-instance');\n var propertyDesc = require('./_property-desc');\n var hide = require('./_hide');\n var redefineAll = require('./_redefine-all');\n var toInteger = require('./_to-integer');\n var toLength = require('./_to-length');\n var toIndex = require('./_to-index');\n var toAbsoluteIndex = require('./_to-absolute-index');\n var toPrimitive = require('./_to-primitive');\n var has = require('./_has');\n var classof = require('./_classof');\n var isObject = require('./_is-object');\n var toObject = require('./_to-object');\n var isArrayIter = require('./_is-array-iter');\n var create = require('./_object-create');\n var getPrototypeOf = require('./_object-gpo');\n var gOPN = require('./_object-gopn').f;\n var getIterFn = require('./core.get-iterator-method');\n var uid = require('./_uid');\n var wks = require('./_wks');\n var createArrayMethod = require('./_array-methods');\n var createArrayIncludes = require('./_array-includes');\n var speciesConstructor = require('./_species-constructor');\n var ArrayIterators = require('./es6.array.iterator');\n var Iterators = require('./_iterators');\n var $iterDetect = require('./_iter-detect');\n var setSpecies = require('./_set-species');\n var arrayFill = require('./_array-fill');\n var arrayCopyWithin = require('./_array-copy-within');\n var $DP = require('./_object-dp');\n var $GOPD = require('./_object-gopd');\n var dP = $DP.f;\n var gOPD = $GOPD.f;\n var RangeError = global.RangeError;\n var TypeError = global.TypeError;\n var Uint8Array = global.Uint8Array;\n var ARRAY_BUFFER = 'ArrayBuffer';\n var SHARED_BUFFER = 'Shared' + ARRAY_BUFFER;\n var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT';\n var PROTOTYPE = 'prototype';\n var ArrayProto = Array[PROTOTYPE];\n var $ArrayBuffer = $buffer.ArrayBuffer;\n var $DataView = $buffer.DataView;\n var arrayForEach = createArrayMethod(0);\n var arrayFilter = createArrayMethod(2);\n var arraySome = createArrayMethod(3);\n var arrayEvery = createArrayMethod(4);\n var arrayFind = createArrayMethod(5);\n var arrayFindIndex = createArrayMethod(6);\n var arrayIncludes = createArrayIncludes(true);\n var arrayIndexOf = createArrayIncludes(false);\n var arrayValues = ArrayIterators.values;\n var arrayKeys = ArrayIterators.keys;\n var arrayEntries = ArrayIterators.entries;\n var arrayLastIndexOf = ArrayProto.lastIndexOf;\n var arrayReduce = ArrayProto.reduce;\n var arrayReduceRight = ArrayProto.reduceRight;\n var arrayJoin = ArrayProto.join;\n var arraySort = ArrayProto.sort;\n var arraySlice = ArrayProto.slice;\n var arrayToString = ArrayProto.toString;\n var arrayToLocaleString = ArrayProto.toLocaleString;\n var ITERATOR = wks('iterator');\n var TAG = wks('toStringTag');\n var TYPED_CONSTRUCTOR = uid('typed_constructor');\n var DEF_CONSTRUCTOR = uid('def_constructor');\n var ALL_CONSTRUCTORS = $typed.CONSTR;\n var TYPED_ARRAY = $typed.TYPED;\n var VIEW = $typed.VIEW;\n var WRONG_LENGTH = 'Wrong length!';\n\n var $map = createArrayMethod(1, function (O, length) {\n return allocate(speciesConstructor(O, O[DEF_CONSTRUCTOR]), length);\n });\n\n var LITTLE_ENDIAN = fails(function () {\n // eslint-disable-next-line no-undef\n return new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;\n });\n\n var FORCED_SET = !!Uint8Array && !!Uint8Array[PROTOTYPE].set && fails(function () {\n new Uint8Array(1).set({});\n });\n\n var toOffset = function (it, BYTES) {\n var offset = toInteger(it);\n if (offset < 0 || offset % BYTES) throw RangeError('Wrong offset!');\n return offset;\n };\n\n var validate = function (it) {\n if (isObject(it) && TYPED_ARRAY in it) return it;\n throw TypeError(it + ' is not a typed array!');\n };\n\n var allocate = function (C, length) {\n if (!(isObject(C) && TYPED_CONSTRUCTOR in C)) {\n throw TypeError('It is not a typed array constructor!');\n } return new C(length);\n };\n\n var speciesFromList = function (O, list) {\n return fromList(speciesConstructor(O, O[DEF_CONSTRUCTOR]), list);\n };\n\n var fromList = function (C, list) {\n var index = 0;\n var length = list.length;\n var result = allocate(C, length);\n while (length > index) result[index] = list[index++];\n return result;\n };\n\n var addGetter = function (it, key, internal) {\n dP(it, key, { get: function () { return this._d[internal]; } });\n };\n\n var $from = function from(source /* , mapfn, thisArg */) {\n var O = toObject(source);\n var aLen = arguments.length;\n var mapfn = aLen > 1 ? arguments[1] : undefined;\n var mapping = mapfn !== undefined;\n var iterFn = getIterFn(O);\n var i, length, values, result, step, iterator;\n if (iterFn != undefined && !isArrayIter(iterFn)) {\n for (iterator = iterFn.call(O), values = [], i = 0; !(step = iterator.next()).done; i++) {\n values.push(step.value);\n } O = values;\n }\n if (mapping && aLen > 2) mapfn = ctx(mapfn, arguments[2], 2);\n for (i = 0, length = toLength(O.length), result = allocate(this, length); length > i; i++) {\n result[i] = mapping ? mapfn(O[i], i) : O[i];\n }\n return result;\n };\n\n var $of = function of(/* ...items */) {\n var index = 0;\n var length = arguments.length;\n var result = allocate(this, length);\n while (length > index) result[index] = arguments[index++];\n return result;\n };\n\n // iOS Safari 6.x fails here\n var TO_LOCALE_BUG = !!Uint8Array && fails(function () { arrayToLocaleString.call(new Uint8Array(1)); });\n\n var $toLocaleString = function toLocaleString() {\n return arrayToLocaleString.apply(TO_LOCALE_BUG ? arraySlice.call(validate(this)) : validate(this), arguments);\n };\n\n var proto = {\n copyWithin: function copyWithin(target, start /* , end */) {\n return arrayCopyWithin.call(validate(this), target, start, arguments.length > 2 ? arguments[2] : undefined);\n },\n every: function every(callbackfn /* , thisArg */) {\n return arrayEvery(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n },\n fill: function fill(value /* , start, end */) { // eslint-disable-line no-unused-vars\n return arrayFill.apply(validate(this), arguments);\n },\n filter: function filter(callbackfn /* , thisArg */) {\n return speciesFromList(this, arrayFilter(validate(this), callbackfn,\n arguments.length > 1 ? arguments[1] : undefined));\n },\n find: function find(predicate /* , thisArg */) {\n return arrayFind(validate(this), predicate, arguments.length > 1 ? arguments[1] : undefined);\n },\n findIndex: function findIndex(predicate /* , thisArg */) {\n return arrayFindIndex(validate(this), predicate, arguments.length > 1 ? arguments[1] : undefined);\n },\n forEach: function forEach(callbackfn /* , thisArg */) {\n arrayForEach(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n },\n indexOf: function indexOf(searchElement /* , fromIndex */) {\n return arrayIndexOf(validate(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);\n },\n includes: function includes(searchElement /* , fromIndex */) {\n return arrayIncludes(validate(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);\n },\n join: function join(separator) { // eslint-disable-line no-unused-vars\n return arrayJoin.apply(validate(this), arguments);\n },\n lastIndexOf: function lastIndexOf(searchElement /* , fromIndex */) { // eslint-disable-line no-unused-vars\n return arrayLastIndexOf.apply(validate(this), arguments);\n },\n map: function map(mapfn /* , thisArg */) {\n return $map(validate(this), mapfn, arguments.length > 1 ? arguments[1] : undefined);\n },\n reduce: function reduce(callbackfn /* , initialValue */) { // eslint-disable-line no-unused-vars\n return arrayReduce.apply(validate(this), arguments);\n },\n reduceRight: function reduceRight(callbackfn /* , initialValue */) { // eslint-disable-line no-unused-vars\n return arrayReduceRight.apply(validate(this), arguments);\n },\n reverse: function reverse() {\n var that = this;\n var length = validate(that).length;\n var middle = Math.floor(length / 2);\n var index = 0;\n var value;\n while (index < middle) {\n value = that[index];\n that[index++] = that[--length];\n that[length] = value;\n } return that;\n },\n some: function some(callbackfn /* , thisArg */) {\n return arraySome(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n },\n sort: function sort(comparefn) {\n return arraySort.call(validate(this), comparefn);\n },\n subarray: function subarray(begin, end) {\n var O = validate(this);\n var length = O.length;\n var $begin = toAbsoluteIndex(begin, length);\n return new (speciesConstructor(O, O[DEF_CONSTRUCTOR]))(\n O.buffer,\n O.byteOffset + $begin * O.BYTES_PER_ELEMENT,\n toLength((end === undefined ? length : toAbsoluteIndex(end, length)) - $begin)\n );\n }\n };\n\n var $slice = function slice(start, end) {\n return speciesFromList(this, arraySlice.call(validate(this), start, end));\n };\n\n var $set = function set(arrayLike /* , offset */) {\n validate(this);\n var offset = toOffset(arguments[1], 1);\n var length = this.length;\n var src = toObject(arrayLike);\n var len = toLength(src.length);\n var index = 0;\n if (len + offset > length) throw RangeError(WRONG_LENGTH);\n while (index < len) this[offset + index] = src[index++];\n };\n\n var $iterators = {\n entries: function entries() {\n return arrayEntries.call(validate(this));\n },\n keys: function keys() {\n return arrayKeys.call(validate(this));\n },\n values: function values() {\n return arrayValues.call(validate(this));\n }\n };\n\n var isTAIndex = function (target, key) {\n return isObject(target)\n && target[TYPED_ARRAY]\n && typeof key != 'symbol'\n && key in target\n && String(+key) == String(key);\n };\n var $getDesc = function getOwnPropertyDescriptor(target, key) {\n return isTAIndex(target, key = toPrimitive(key, true))\n ? propertyDesc(2, target[key])\n : gOPD(target, key);\n };\n var $setDesc = function defineProperty(target, key, desc) {\n if (isTAIndex(target, key = toPrimitive(key, true))\n && isObject(desc)\n && has(desc, 'value')\n && !has(desc, 'get')\n && !has(desc, 'set')\n // TODO: add validation descriptor w/o calling accessors\n && !desc.configurable\n && (!has(desc, 'writable') || desc.writable)\n && (!has(desc, 'enumerable') || desc.enumerable)\n ) {\n target[key] = desc.value;\n return target;\n } return dP(target, key, desc);\n };\n\n if (!ALL_CONSTRUCTORS) {\n $GOPD.f = $getDesc;\n $DP.f = $setDesc;\n }\n\n $export($export.S + $export.F * !ALL_CONSTRUCTORS, 'Object', {\n getOwnPropertyDescriptor: $getDesc,\n defineProperty: $setDesc\n });\n\n if (fails(function () { arrayToString.call({}); })) {\n arrayToString = arrayToLocaleString = function toString() {\n return arrayJoin.call(this);\n };\n }\n\n var $TypedArrayPrototype$ = redefineAll({}, proto);\n redefineAll($TypedArrayPrototype$, $iterators);\n hide($TypedArrayPrototype$, ITERATOR, $iterators.values);\n redefineAll($TypedArrayPrototype$, {\n slice: $slice,\n set: $set,\n constructor: function () { /* noop */ },\n toString: arrayToString,\n toLocaleString: $toLocaleString\n });\n addGetter($TypedArrayPrototype$, 'buffer', 'b');\n addGetter($TypedArrayPrototype$, 'byteOffset', 'o');\n addGetter($TypedArrayPrototype$, 'byteLength', 'l');\n addGetter($TypedArrayPrototype$, 'length', 'e');\n dP($TypedArrayPrototype$, TAG, {\n get: function () { return this[TYPED_ARRAY]; }\n });\n\n // eslint-disable-next-line max-statements\n module.exports = function (KEY, BYTES, wrapper, CLAMPED) {\n CLAMPED = !!CLAMPED;\n var NAME = KEY + (CLAMPED ? 'Clamped' : '') + 'Array';\n var GETTER = 'get' + KEY;\n var SETTER = 'set' + KEY;\n var TypedArray = global[NAME];\n var Base = TypedArray || {};\n var TAC = TypedArray && getPrototypeOf(TypedArray);\n var FORCED = !TypedArray || !$typed.ABV;\n var O = {};\n var TypedArrayPrototype = TypedArray && TypedArray[PROTOTYPE];\n var getter = function (that, index) {\n var data = that._d;\n return data.v[GETTER](index * BYTES + data.o, LITTLE_ENDIAN);\n };\n var setter = function (that, index, value) {\n var data = that._d;\n if (CLAMPED) value = (value = Math.round(value)) < 0 ? 0 : value > 0xff ? 0xff : value & 0xff;\n data.v[SETTER](index * BYTES + data.o, value, LITTLE_ENDIAN);\n };\n var addElement = function (that, index) {\n dP(that, index, {\n get: function () {\n return getter(this, index);\n },\n set: function (value) {\n return setter(this, index, value);\n },\n enumerable: true\n });\n };\n if (FORCED) {\n TypedArray = wrapper(function (that, data, $offset, $length) {\n anInstance(that, TypedArray, NAME, '_d');\n var index = 0;\n var offset = 0;\n var buffer, byteLength, length, klass;\n if (!isObject(data)) {\n length = toIndex(data);\n byteLength = length * BYTES;\n buffer = new $ArrayBuffer(byteLength);\n } else if (data instanceof $ArrayBuffer || (klass = classof(data)) == ARRAY_BUFFER || klass == SHARED_BUFFER) {\n buffer = data;\n offset = toOffset($offset, BYTES);\n var $len = data.byteLength;\n if ($length === undefined) {\n if ($len % BYTES) throw RangeError(WRONG_LENGTH);\n byteLength = $len - offset;\n if (byteLength < 0) throw RangeError(WRONG_LENGTH);\n } else {\n byteLength = toLength($length) * BYTES;\n if (byteLength + offset > $len) throw RangeError(WRONG_LENGTH);\n }\n length = byteLength / BYTES;\n } else if (TYPED_ARRAY in data) {\n return fromList(TypedArray, data);\n } else {\n return $from.call(TypedArray, data);\n }\n hide(that, '_d', {\n b: buffer,\n o: offset,\n l: byteLength,\n e: length,\n v: new $DataView(buffer)\n });\n while (index < length) addElement(that, index++);\n });\n TypedArrayPrototype = TypedArray[PROTOTYPE] = create($TypedArrayPrototype$);\n hide(TypedArrayPrototype, 'constructor', TypedArray);\n } else if (!fails(function () {\n TypedArray(1);\n }) || !fails(function () {\n new TypedArray(-1); // eslint-disable-line no-new\n }) || !$iterDetect(function (iter) {\n new TypedArray(); // eslint-disable-line no-new\n new TypedArray(null); // eslint-disable-line no-new\n new TypedArray(1.5); // eslint-disable-line no-new\n new TypedArray(iter); // eslint-disable-line no-new\n }, true)) {\n TypedArray = wrapper(function (that, data, $offset, $length) {\n anInstance(that, TypedArray, NAME);\n var klass;\n // `ws` module bug, temporarily remove validation length for Uint8Array\n // https://github.com/websockets/ws/pull/645\n if (!isObject(data)) return new Base(toIndex(data));\n if (data instanceof $ArrayBuffer || (klass = classof(data)) == ARRAY_BUFFER || klass == SHARED_BUFFER) {\n return $length !== undefined\n ? new Base(data, toOffset($offset, BYTES), $length)\n : $offset !== undefined\n ? new Base(data, toOffset($offset, BYTES))\n : new Base(data);\n }\n if (TYPED_ARRAY in data) return fromList(TypedArray, data);\n return $from.call(TypedArray, data);\n });\n arrayForEach(TAC !== Function.prototype ? gOPN(Base).concat(gOPN(TAC)) : gOPN(Base), function (key) {\n if (!(key in TypedArray)) hide(TypedArray, key, Base[key]);\n });\n TypedArray[PROTOTYPE] = TypedArrayPrototype;\n if (!LIBRARY) TypedArrayPrototype.constructor = TypedArray;\n }\n var $nativeIterator = TypedArrayPrototype[ITERATOR];\n var CORRECT_ITER_NAME = !!$nativeIterator\n && ($nativeIterator.name == 'values' || $nativeIterator.name == undefined);\n var $iterator = $iterators.values;\n hide(TypedArray, TYPED_CONSTRUCTOR, true);\n hide(TypedArrayPrototype, TYPED_ARRAY, NAME);\n hide(TypedArrayPrototype, VIEW, true);\n hide(TypedArrayPrototype, DEF_CONSTRUCTOR, TypedArray);\n\n if (CLAMPED ? new TypedArray(1)[TAG] != NAME : !(TAG in TypedArrayPrototype)) {\n dP(TypedArrayPrototype, TAG, {\n get: function () { return NAME; }\n });\n }\n\n O[NAME] = TypedArray;\n\n $export($export.G + $export.W + $export.F * (TypedArray != Base), O);\n\n $export($export.S, NAME, {\n BYTES_PER_ELEMENT: BYTES\n });\n\n $export($export.S + $export.F * fails(function () { Base.of.call(TypedArray, 1); }), NAME, {\n from: $from,\n of: $of\n });\n\n if (!(BYTES_PER_ELEMENT in TypedArrayPrototype)) hide(TypedArrayPrototype, BYTES_PER_ELEMENT, BYTES);\n\n $export($export.P, NAME, proto);\n\n setSpecies(NAME);\n\n $export($export.P + $export.F * FORCED_SET, NAME, { set: $set });\n\n $export($export.P + $export.F * !CORRECT_ITER_NAME, NAME, $iterators);\n\n if (!LIBRARY && TypedArrayPrototype.toString != arrayToString) TypedArrayPrototype.toString = arrayToString;\n\n $export($export.P + $export.F * fails(function () {\n new TypedArray(1).slice();\n }), NAME, { slice: $slice });\n\n $export($export.P + $export.F * (fails(function () {\n return [1, 2].toLocaleString() != new TypedArray([1, 2]).toLocaleString();\n }) || !fails(function () {\n TypedArrayPrototype.toLocaleString.call([1, 2]);\n })), NAME, { toLocaleString: $toLocaleString });\n\n Iterators[NAME] = CORRECT_ITER_NAME ? $nativeIterator : $iterator;\n if (!LIBRARY && !CORRECT_ITER_NAME) hide(TypedArrayPrototype, ITERATOR, $iterator);\n };\n} else module.exports = function () { /* empty */ };\n","'use strict';\nvar global = require('./_global');\nvar DESCRIPTORS = require('./_descriptors');\nvar LIBRARY = require('./_library');\nvar $typed = require('./_typed');\nvar hide = require('./_hide');\nvar redefineAll = require('./_redefine-all');\nvar fails = require('./_fails');\nvar anInstance = require('./_an-instance');\nvar toInteger = require('./_to-integer');\nvar toLength = require('./_to-length');\nvar toIndex = require('./_to-index');\nvar gOPN = require('./_object-gopn').f;\nvar dP = require('./_object-dp').f;\nvar arrayFill = require('./_array-fill');\nvar setToStringTag = require('./_set-to-string-tag');\nvar ARRAY_BUFFER = 'ArrayBuffer';\nvar DATA_VIEW = 'DataView';\nvar PROTOTYPE = 'prototype';\nvar WRONG_LENGTH = 'Wrong length!';\nvar WRONG_INDEX = 'Wrong index!';\nvar $ArrayBuffer = global[ARRAY_BUFFER];\nvar $DataView = global[DATA_VIEW];\nvar Math = global.Math;\nvar RangeError = global.RangeError;\n// eslint-disable-next-line no-shadow-restricted-names\nvar Infinity = global.Infinity;\nvar BaseBuffer = $ArrayBuffer;\nvar abs = Math.abs;\nvar pow = Math.pow;\nvar floor = Math.floor;\nvar log = Math.log;\nvar LN2 = Math.LN2;\nvar BUFFER = 'buffer';\nvar BYTE_LENGTH = 'byteLength';\nvar BYTE_OFFSET = 'byteOffset';\nvar $BUFFER = DESCRIPTORS ? '_b' : BUFFER;\nvar $LENGTH = DESCRIPTORS ? '_l' : BYTE_LENGTH;\nvar $OFFSET = DESCRIPTORS ? '_o' : BYTE_OFFSET;\n\n// IEEE754 conversions based on https://github.com/feross/ieee754\nfunction packIEEE754(value, mLen, nBytes) {\n var buffer = new Array(nBytes);\n var eLen = nBytes * 8 - mLen - 1;\n var eMax = (1 << eLen) - 1;\n var eBias = eMax >> 1;\n var rt = mLen === 23 ? pow(2, -24) - pow(2, -77) : 0;\n var i = 0;\n var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;\n var e, m, c;\n value = abs(value);\n // eslint-disable-next-line no-self-compare\n if (value != value || value === Infinity) {\n // eslint-disable-next-line no-self-compare\n m = value != value ? 1 : 0;\n e = eMax;\n } else {\n e = floor(log(value) / LN2);\n if (value * (c = pow(2, -e)) < 1) {\n e--;\n c *= 2;\n }\n if (e + eBias >= 1) {\n value += rt / c;\n } else {\n value += rt * pow(2, 1 - eBias);\n }\n if (value * c >= 2) {\n e++;\n c /= 2;\n }\n if (e + eBias >= eMax) {\n m = 0;\n e = eMax;\n } else if (e + eBias >= 1) {\n m = (value * c - 1) * pow(2, mLen);\n e = e + eBias;\n } else {\n m = value * pow(2, eBias - 1) * pow(2, mLen);\n e = 0;\n }\n }\n for (; mLen >= 8; buffer[i++] = m & 255, m /= 256, mLen -= 8);\n e = e << mLen | m;\n eLen += mLen;\n for (; eLen > 0; buffer[i++] = e & 255, e /= 256, eLen -= 8);\n buffer[--i] |= s * 128;\n return buffer;\n}\nfunction unpackIEEE754(buffer, mLen, nBytes) {\n var eLen = nBytes * 8 - mLen - 1;\n var eMax = (1 << eLen) - 1;\n var eBias = eMax >> 1;\n var nBits = eLen - 7;\n var i = nBytes - 1;\n var s = buffer[i--];\n var e = s & 127;\n var m;\n s >>= 7;\n for (; nBits > 0; e = e * 256 + buffer[i], i--, nBits -= 8);\n m = e & (1 << -nBits) - 1;\n e >>= -nBits;\n nBits += mLen;\n for (; nBits > 0; m = m * 256 + buffer[i], i--, nBits -= 8);\n if (e === 0) {\n e = 1 - eBias;\n } else if (e === eMax) {\n return m ? NaN : s ? -Infinity : Infinity;\n } else {\n m = m + pow(2, mLen);\n e = e - eBias;\n } return (s ? -1 : 1) * m * pow(2, e - mLen);\n}\n\nfunction unpackI32(bytes) {\n return bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0];\n}\nfunction packI8(it) {\n return [it & 0xff];\n}\nfunction packI16(it) {\n return [it & 0xff, it >> 8 & 0xff];\n}\nfunction packI32(it) {\n return [it & 0xff, it >> 8 & 0xff, it >> 16 & 0xff, it >> 24 & 0xff];\n}\nfunction packF64(it) {\n return packIEEE754(it, 52, 8);\n}\nfunction packF32(it) {\n return packIEEE754(it, 23, 4);\n}\n\nfunction addGetter(C, key, internal) {\n dP(C[PROTOTYPE], key, { get: function () { return this[internal]; } });\n}\n\nfunction get(view, bytes, index, isLittleEndian) {\n var numIndex = +index;\n var intIndex = toIndex(numIndex);\n if (intIndex + bytes > view[$LENGTH]) throw RangeError(WRONG_INDEX);\n var store = view[$BUFFER]._b;\n var start = intIndex + view[$OFFSET];\n var pack = store.slice(start, start + bytes);\n return isLittleEndian ? pack : pack.reverse();\n}\nfunction set(view, bytes, index, conversion, value, isLittleEndian) {\n var numIndex = +index;\n var intIndex = toIndex(numIndex);\n if (intIndex + bytes > view[$LENGTH]) throw RangeError(WRONG_INDEX);\n var store = view[$BUFFER]._b;\n var start = intIndex + view[$OFFSET];\n var pack = conversion(+value);\n for (var i = 0; i < bytes; i++) store[start + i] = pack[isLittleEndian ? i : bytes - i - 1];\n}\n\nif (!$typed.ABV) {\n $ArrayBuffer = function ArrayBuffer(length) {\n anInstance(this, $ArrayBuffer, ARRAY_BUFFER);\n var byteLength = toIndex(length);\n this._b = arrayFill.call(new Array(byteLength), 0);\n this[$LENGTH] = byteLength;\n };\n\n $DataView = function DataView(buffer, byteOffset, byteLength) {\n anInstance(this, $DataView, DATA_VIEW);\n anInstance(buffer, $ArrayBuffer, DATA_VIEW);\n var bufferLength = buffer[$LENGTH];\n var offset = toInteger(byteOffset);\n if (offset < 0 || offset > bufferLength) throw RangeError('Wrong offset!');\n byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength);\n if (offset + byteLength > bufferLength) throw RangeError(WRONG_LENGTH);\n this[$BUFFER] = buffer;\n this[$OFFSET] = offset;\n this[$LENGTH] = byteLength;\n };\n\n if (DESCRIPTORS) {\n addGetter($ArrayBuffer, BYTE_LENGTH, '_l');\n addGetter($DataView, BUFFER, '_b');\n addGetter($DataView, BYTE_LENGTH, '_l');\n addGetter($DataView, BYTE_OFFSET, '_o');\n }\n\n redefineAll($DataView[PROTOTYPE], {\n getInt8: function getInt8(byteOffset) {\n return get(this, 1, byteOffset)[0] << 24 >> 24;\n },\n getUint8: function getUint8(byteOffset) {\n return get(this, 1, byteOffset)[0];\n },\n getInt16: function getInt16(byteOffset /* , littleEndian */) {\n var bytes = get(this, 2, byteOffset, arguments[1]);\n return (bytes[1] << 8 | bytes[0]) << 16 >> 16;\n },\n getUint16: function getUint16(byteOffset /* , littleEndian */) {\n var bytes = get(this, 2, byteOffset, arguments[1]);\n return bytes[1] << 8 | bytes[0];\n },\n getInt32: function getInt32(byteOffset /* , littleEndian */) {\n return unpackI32(get(this, 4, byteOffset, arguments[1]));\n },\n getUint32: function getUint32(byteOffset /* , littleEndian */) {\n return unpackI32(get(this, 4, byteOffset, arguments[1])) >>> 0;\n },\n getFloat32: function getFloat32(byteOffset /* , littleEndian */) {\n return unpackIEEE754(get(this, 4, byteOffset, arguments[1]), 23, 4);\n },\n getFloat64: function getFloat64(byteOffset /* , littleEndian */) {\n return unpackIEEE754(get(this, 8, byteOffset, arguments[1]), 52, 8);\n },\n setInt8: function setInt8(byteOffset, value) {\n set(this, 1, byteOffset, packI8, value);\n },\n setUint8: function setUint8(byteOffset, value) {\n set(this, 1, byteOffset, packI8, value);\n },\n setInt16: function setInt16(byteOffset, value /* , littleEndian */) {\n set(this, 2, byteOffset, packI16, value, arguments[2]);\n },\n setUint16: function setUint16(byteOffset, value /* , littleEndian */) {\n set(this, 2, byteOffset, packI16, value, arguments[2]);\n },\n setInt32: function setInt32(byteOffset, value /* , littleEndian */) {\n set(this, 4, byteOffset, packI32, value, arguments[2]);\n },\n setUint32: function setUint32(byteOffset, value /* , littleEndian */) {\n set(this, 4, byteOffset, packI32, value, arguments[2]);\n },\n setFloat32: function setFloat32(byteOffset, value /* , littleEndian */) {\n set(this, 4, byteOffset, packF32, value, arguments[2]);\n },\n setFloat64: function setFloat64(byteOffset, value /* , littleEndian */) {\n set(this, 8, byteOffset, packF64, value, arguments[2]);\n }\n });\n} else {\n if (!fails(function () {\n $ArrayBuffer(1);\n }) || !fails(function () {\n new $ArrayBuffer(-1); // eslint-disable-line no-new\n }) || fails(function () {\n new $ArrayBuffer(); // eslint-disable-line no-new\n new $ArrayBuffer(1.5); // eslint-disable-line no-new\n new $ArrayBuffer(NaN); // eslint-disable-line no-new\n return $ArrayBuffer.name != ARRAY_BUFFER;\n })) {\n $ArrayBuffer = function ArrayBuffer(length) {\n anInstance(this, $ArrayBuffer);\n return new BaseBuffer(toIndex(length));\n };\n var ArrayBufferProto = $ArrayBuffer[PROTOTYPE] = BaseBuffer[PROTOTYPE];\n for (var keys = gOPN(BaseBuffer), j = 0, key; keys.length > j;) {\n if (!((key = keys[j++]) in $ArrayBuffer)) hide($ArrayBuffer, key, BaseBuffer[key]);\n }\n if (!LIBRARY) ArrayBufferProto.constructor = $ArrayBuffer;\n }\n // iOS Safari 7.x bug\n var view = new $DataView(new $ArrayBuffer(2));\n var $setInt8 = $DataView[PROTOTYPE].setInt8;\n view.setInt8(0, 2147483648);\n view.setInt8(1, 2147483649);\n if (view.getInt8(0) || !view.getInt8(1)) redefineAll($DataView[PROTOTYPE], {\n setInt8: function setInt8(byteOffset, value) {\n $setInt8.call(this, byteOffset, value << 24 >> 24);\n },\n setUint8: function setUint8(byteOffset, value) {\n $setInt8.call(this, byteOffset, value << 24 >> 24);\n }\n }, true);\n}\nsetToStringTag($ArrayBuffer, ARRAY_BUFFER);\nsetToStringTag($DataView, DATA_VIEW);\nhide($DataView[PROTOTYPE], $typed.VIEW, true);\nexports[ARRAY_BUFFER] = $ArrayBuffer;\nexports[DATA_VIEW] = $DataView;\n","var global = require('./_global');\nvar hide = require('./_hide');\nvar uid = require('./_uid');\nvar TYPED = uid('typed_array');\nvar VIEW = uid('view');\nvar ABV = !!(global.ArrayBuffer && global.DataView);\nvar CONSTR = ABV;\nvar i = 0;\nvar l = 9;\nvar Typed;\n\nvar TypedArrayConstructors = (\n 'Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array'\n).split(',');\n\nwhile (i < l) {\n if (Typed = global[TypedArrayConstructors[i++]]) {\n hide(Typed.prototype, TYPED, true);\n hide(Typed.prototype, VIEW, true);\n } else CONSTR = false;\n}\n\nmodule.exports = {\n ABV: ABV,\n CONSTR: CONSTR,\n TYPED: TYPED,\n VIEW: VIEW\n};\n","var id = 0;\nvar px = Math.random();\nmodule.exports = function (key) {\n return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));\n};\n","var global = require('./_global');\nvar navigator = global.navigator;\n\nmodule.exports = navigator && navigator.userAgent || '';\n","var isObject = require('./_is-object');\nmodule.exports = function (it, TYPE) {\n if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');\n return it;\n};\n","var global = require('./_global');\nvar core = require('./_core');\nvar LIBRARY = require('./_library');\nvar wksExt = require('./_wks-ext');\nvar defineProperty = require('./_object-dp').f;\nmodule.exports = function (name) {\n var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});\n if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) });\n};\n","exports.f = require('./_wks');\n","var store = require('./_shared')('wks');\nvar uid = require('./_uid');\nvar Symbol = require('./_global').Symbol;\nvar USE_SYMBOL = typeof Symbol == 'function';\n\nvar $exports = module.exports = function (name) {\n return store[name] || (store[name] =\n USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));\n};\n\n$exports.store = store;\n","var classof = require('./_classof');\nvar ITERATOR = require('./_wks')('iterator');\nvar Iterators = require('./_iterators');\nmodule.exports = require('./_core').getIteratorMethod = function (it) {\n if (it != undefined) return it[ITERATOR]\n || it['@@iterator']\n || Iterators[classof(it)];\n};\n","// 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)\nvar $export = require('./_export');\n\n$export($export.P, 'Array', { copyWithin: require('./_array-copy-within') });\n\nrequire('./_add-to-unscopables')('copyWithin');\n","'use strict';\nvar $export = require('./_export');\nvar $every = require('./_array-methods')(4);\n\n$export($export.P + $export.F * !require('./_strict-method')([].every, true), 'Array', {\n // 22.1.3.5 / 15.4.4.16 Array.prototype.every(callbackfn [, thisArg])\n every: function every(callbackfn /* , thisArg */) {\n return $every(this, callbackfn, arguments[1]);\n }\n});\n","// 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)\nvar $export = require('./_export');\n\n$export($export.P, 'Array', { fill: require('./_array-fill') });\n\nrequire('./_add-to-unscopables')('fill');\n","'use strict';\nvar $export = require('./_export');\nvar $filter = require('./_array-methods')(2);\n\n$export($export.P + $export.F * !require('./_strict-method')([].filter, true), 'Array', {\n // 22.1.3.7 / 15.4.4.20 Array.prototype.filter(callbackfn [, thisArg])\n filter: function filter(callbackfn /* , thisArg */) {\n return $filter(this, callbackfn, arguments[1]);\n }\n});\n","'use strict';\n// 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined)\nvar $export = require('./_export');\nvar $find = require('./_array-methods')(6);\nvar KEY = 'findIndex';\nvar forced = true;\n// Shouldn't skip holes\nif (KEY in []) Array(1)[KEY](function () { forced = false; });\n$export($export.P + $export.F * forced, 'Array', {\n findIndex: function findIndex(callbackfn /* , that = undefined */) {\n return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\nrequire('./_add-to-unscopables')(KEY);\n","'use strict';\n// 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined)\nvar $export = require('./_export');\nvar $find = require('./_array-methods')(5);\nvar KEY = 'find';\nvar forced = true;\n// Shouldn't skip holes\nif (KEY in []) Array(1)[KEY](function () { forced = false; });\n$export($export.P + $export.F * forced, 'Array', {\n find: function find(callbackfn /* , that = undefined */) {\n return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\nrequire('./_add-to-unscopables')(KEY);\n","'use strict';\nvar $export = require('./_export');\nvar $forEach = require('./_array-methods')(0);\nvar STRICT = require('./_strict-method')([].forEach, true);\n\n$export($export.P + $export.F * !STRICT, 'Array', {\n // 22.1.3.10 / 15.4.4.18 Array.prototype.forEach(callbackfn [, thisArg])\n forEach: function forEach(callbackfn /* , thisArg */) {\n return $forEach(this, callbackfn, arguments[1]);\n }\n});\n","'use strict';\nvar ctx = require('./_ctx');\nvar $export = require('./_export');\nvar toObject = require('./_to-object');\nvar call = require('./_iter-call');\nvar isArrayIter = require('./_is-array-iter');\nvar toLength = require('./_to-length');\nvar createProperty = require('./_create-property');\nvar getIterFn = require('./core.get-iterator-method');\n\n$export($export.S + $export.F * !require('./_iter-detect')(function (iter) { Array.from(iter); }), 'Array', {\n // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)\n from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {\n var O = toObject(arrayLike);\n var C = typeof this == 'function' ? this : Array;\n var aLen = arguments.length;\n var mapfn = aLen > 1 ? arguments[1] : undefined;\n var mapping = mapfn !== undefined;\n var index = 0;\n var iterFn = getIterFn(O);\n var length, result, step, iterator;\n if (mapping) mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);\n // if object isn't iterable or it's array with default iterator - use simple case\n if (iterFn != undefined && !(C == Array && isArrayIter(iterFn))) {\n for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) {\n createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);\n }\n } else {\n length = toLength(O.length);\n for (result = new C(length); length > index; index++) {\n createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);\n }\n }\n result.length = index;\n return result;\n }\n});\n","'use strict';\nvar $export = require('./_export');\nvar $indexOf = require('./_array-includes')(false);\nvar $native = [].indexOf;\nvar NEGATIVE_ZERO = !!$native && 1 / [1].indexOf(1, -0) < 0;\n\n$export($export.P + $export.F * (NEGATIVE_ZERO || !require('./_strict-method')($native)), 'Array', {\n // 22.1.3.11 / 15.4.4.14 Array.prototype.indexOf(searchElement [, fromIndex])\n indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {\n return NEGATIVE_ZERO\n // convert -0 to +0\n ? $native.apply(this, arguments) || 0\n : $indexOf(this, searchElement, arguments[1]);\n }\n});\n","// 22.1.2.2 / 15.4.3.2 Array.isArray(arg)\nvar $export = require('./_export');\n\n$export($export.S, 'Array', { isArray: require('./_is-array') });\n","'use strict';\nvar addToUnscopables = require('./_add-to-unscopables');\nvar step = require('./_iter-step');\nvar Iterators = require('./_iterators');\nvar toIObject = require('./_to-iobject');\n\n// 22.1.3.4 Array.prototype.entries()\n// 22.1.3.13 Array.prototype.keys()\n// 22.1.3.29 Array.prototype.values()\n// 22.1.3.30 Array.prototype[@@iterator]()\nmodule.exports = require('./_iter-define')(Array, 'Array', function (iterated, kind) {\n this._t = toIObject(iterated); // target\n this._i = 0; // next index\n this._k = kind; // kind\n// 22.1.5.2.1 %ArrayIteratorPrototype%.next()\n}, function () {\n var O = this._t;\n var kind = this._k;\n var index = this._i++;\n if (!O || index >= O.length) {\n this._t = undefined;\n return step(1);\n }\n if (kind == 'keys') return step(0, index);\n if (kind == 'values') return step(0, O[index]);\n return step(0, [index, O[index]]);\n}, 'values');\n\n// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)\nIterators.Arguments = Iterators.Array;\n\naddToUnscopables('keys');\naddToUnscopables('values');\naddToUnscopables('entries');\n","'use strict';\n// 22.1.3.13 Array.prototype.join(separator)\nvar $export = require('./_export');\nvar toIObject = require('./_to-iobject');\nvar arrayJoin = [].join;\n\n// fallback for not array-like strings\n$export($export.P + $export.F * (require('./_iobject') != Object || !require('./_strict-method')(arrayJoin)), 'Array', {\n join: function join(separator) {\n return arrayJoin.call(toIObject(this), separator === undefined ? ',' : separator);\n }\n});\n","'use strict';\nvar $export = require('./_export');\nvar toIObject = require('./_to-iobject');\nvar toInteger = require('./_to-integer');\nvar toLength = require('./_to-length');\nvar $native = [].lastIndexOf;\nvar NEGATIVE_ZERO = !!$native && 1 / [1].lastIndexOf(1, -0) < 0;\n\n$export($export.P + $export.F * (NEGATIVE_ZERO || !require('./_strict-method')($native)), 'Array', {\n // 22.1.3.14 / 15.4.4.15 Array.prototype.lastIndexOf(searchElement [, fromIndex])\n lastIndexOf: function lastIndexOf(searchElement /* , fromIndex = @[*-1] */) {\n // convert -0 to +0\n if (NEGATIVE_ZERO) return $native.apply(this, arguments) || 0;\n var O = toIObject(this);\n var length = toLength(O.length);\n var index = length - 1;\n if (arguments.length > 1) index = Math.min(index, toInteger(arguments[1]));\n if (index < 0) index = length + index;\n for (;index >= 0; index--) if (index in O) if (O[index] === searchElement) return index || 0;\n return -1;\n }\n});\n","'use strict';\nvar $export = require('./_export');\nvar $map = require('./_array-methods')(1);\n\n$export($export.P + $export.F * !require('./_strict-method')([].map, true), 'Array', {\n // 22.1.3.15 / 15.4.4.19 Array.prototype.map(callbackfn [, thisArg])\n map: function map(callbackfn /* , thisArg */) {\n return $map(this, callbackfn, arguments[1]);\n }\n});\n","'use strict';\nvar $export = require('./_export');\nvar createProperty = require('./_create-property');\n\n// WebKit Array.of isn't generic\n$export($export.S + $export.F * require('./_fails')(function () {\n function F() { /* empty */ }\n return !(Array.of.call(F) instanceof F);\n}), 'Array', {\n // 22.1.2.3 Array.of( ...items)\n of: function of(/* ...args */) {\n var index = 0;\n var aLen = arguments.length;\n var result = new (typeof this == 'function' ? this : Array)(aLen);\n while (aLen > index) createProperty(result, index, arguments[index++]);\n result.length = aLen;\n return result;\n }\n});\n","'use strict';\nvar $export = require('./_export');\nvar $reduce = require('./_array-reduce');\n\n$export($export.P + $export.F * !require('./_strict-method')([].reduceRight, true), 'Array', {\n // 22.1.3.19 / 15.4.4.22 Array.prototype.reduceRight(callbackfn [, initialValue])\n reduceRight: function reduceRight(callbackfn /* , initialValue */) {\n return $reduce(this, callbackfn, arguments.length, arguments[1], true);\n }\n});\n","'use strict';\nvar $export = require('./_export');\nvar $reduce = require('./_array-reduce');\n\n$export($export.P + $export.F * !require('./_strict-method')([].reduce, true), 'Array', {\n // 22.1.3.18 / 15.4.4.21 Array.prototype.reduce(callbackfn [, initialValue])\n reduce: function reduce(callbackfn /* , initialValue */) {\n return $reduce(this, callbackfn, arguments.length, arguments[1], false);\n }\n});\n","'use strict';\nvar $export = require('./_export');\nvar html = require('./_html');\nvar cof = require('./_cof');\nvar toAbsoluteIndex = require('./_to-absolute-index');\nvar toLength = require('./_to-length');\nvar arraySlice = [].slice;\n\n// fallback for not array-like ES3 strings and DOM objects\n$export($export.P + $export.F * require('./_fails')(function () {\n if (html) arraySlice.call(html);\n}), 'Array', {\n slice: function slice(begin, end) {\n var len = toLength(this.length);\n var klass = cof(this);\n end = end === undefined ? len : end;\n if (klass == 'Array') return arraySlice.call(this, begin, end);\n var start = toAbsoluteIndex(begin, len);\n var upTo = toAbsoluteIndex(end, len);\n var size = toLength(upTo - start);\n var cloned = new Array(size);\n var i = 0;\n for (; i < size; i++) cloned[i] = klass == 'String'\n ? this.charAt(start + i)\n : this[start + i];\n return cloned;\n }\n});\n","'use strict';\nvar $export = require('./_export');\nvar $some = require('./_array-methods')(3);\n\n$export($export.P + $export.F * !require('./_strict-method')([].some, true), 'Array', {\n // 22.1.3.23 / 15.4.4.17 Array.prototype.some(callbackfn [, thisArg])\n some: function some(callbackfn /* , thisArg */) {\n return $some(this, callbackfn, arguments[1]);\n }\n});\n","'use strict';\nvar $export = require('./_export');\nvar aFunction = require('./_a-function');\nvar toObject = require('./_to-object');\nvar fails = require('./_fails');\nvar $sort = [].sort;\nvar test = [1, 2, 3];\n\n$export($export.P + $export.F * (fails(function () {\n // IE8-\n test.sort(undefined);\n}) || !fails(function () {\n // V8 bug\n test.sort(null);\n // Old WebKit\n}) || !require('./_strict-method')($sort)), 'Array', {\n // 22.1.3.25 Array.prototype.sort(comparefn)\n sort: function sort(comparefn) {\n return comparefn === undefined\n ? $sort.call(toObject(this))\n : $sort.call(toObject(this), aFunction(comparefn));\n }\n});\n","require('./_set-species')('Array');\n","// 20.3.3.1 / 15.9.4.4 Date.now()\nvar $export = require('./_export');\n\n$export($export.S, 'Date', { now: function () { return new Date().getTime(); } });\n","// 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString()\nvar $export = require('./_export');\nvar toISOString = require('./_date-to-iso-string');\n\n// PhantomJS / old WebKit has a broken implementations\n$export($export.P + $export.F * (Date.prototype.toISOString !== toISOString), 'Date', {\n toISOString: toISOString\n});\n","'use strict';\nvar $export = require('./_export');\nvar toObject = require('./_to-object');\nvar toPrimitive = require('./_to-primitive');\n\n$export($export.P + $export.F * require('./_fails')(function () {\n return new Date(NaN).toJSON() !== null\n || Date.prototype.toJSON.call({ toISOString: function () { return 1; } }) !== 1;\n}), 'Date', {\n // eslint-disable-next-line no-unused-vars\n toJSON: function toJSON(key) {\n var O = toObject(this);\n var pv = toPrimitive(O);\n return typeof pv == 'number' && !isFinite(pv) ? null : O.toISOString();\n }\n});\n","var TO_PRIMITIVE = require('./_wks')('toPrimitive');\nvar proto = Date.prototype;\n\nif (!(TO_PRIMITIVE in proto)) require('./_hide')(proto, TO_PRIMITIVE, require('./_date-to-primitive'));\n","var DateProto = Date.prototype;\nvar INVALID_DATE = 'Invalid Date';\nvar TO_STRING = 'toString';\nvar $toString = DateProto[TO_STRING];\nvar getTime = DateProto.getTime;\nif (new Date(NaN) + '' != INVALID_DATE) {\n require('./_redefine')(DateProto, TO_STRING, function toString() {\n var value = getTime.call(this);\n // eslint-disable-next-line no-self-compare\n return value === value ? $toString.call(this) : INVALID_DATE;\n });\n}\n","// 19.2.3.2 / 15.3.4.5 Function.prototype.bind(thisArg, args...)\nvar $export = require('./_export');\n\n$export($export.P, 'Function', { bind: require('./_bind') });\n","'use strict';\nvar isObject = require('./_is-object');\nvar getPrototypeOf = require('./_object-gpo');\nvar HAS_INSTANCE = require('./_wks')('hasInstance');\nvar FunctionProto = Function.prototype;\n// 19.2.3.6 Function.prototype[@@hasInstance](V)\nif (!(HAS_INSTANCE in FunctionProto)) require('./_object-dp').f(FunctionProto, HAS_INSTANCE, { value: function (O) {\n if (typeof this != 'function' || !isObject(O)) return false;\n if (!isObject(this.prototype)) return O instanceof this;\n // for environment w/o native `@@hasInstance` logic enough `instanceof`, but add this:\n while (O = getPrototypeOf(O)) if (this.prototype === O) return true;\n return false;\n} });\n","var dP = require('./_object-dp').f;\nvar FProto = Function.prototype;\nvar nameRE = /^\\s*function ([^ (]*)/;\nvar NAME = 'name';\n\n// 19.2.4.2 name\nNAME in FProto || require('./_descriptors') && dP(FProto, NAME, {\n configurable: true,\n get: function () {\n try {\n return ('' + this).match(nameRE)[1];\n } catch (e) {\n return '';\n }\n }\n});\n","'use strict';\nvar strong = require('./_collection-strong');\nvar validate = require('./_validate-collection');\nvar MAP = 'Map';\n\n// 23.1 Map Objects\nmodule.exports = require('./_collection')(MAP, function (get) {\n return function Map() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };\n}, {\n // 23.1.3.6 Map.prototype.get(key)\n get: function get(key) {\n var entry = strong.getEntry(validate(this, MAP), key);\n return entry && entry.v;\n },\n // 23.1.3.9 Map.prototype.set(key, value)\n set: function set(key, value) {\n return strong.def(validate(this, MAP), key === 0 ? 0 : key, value);\n }\n}, strong, true);\n","// 20.2.2.3 Math.acosh(x)\nvar $export = require('./_export');\nvar log1p = require('./_math-log1p');\nvar sqrt = Math.sqrt;\nvar $acosh = Math.acosh;\n\n$export($export.S + $export.F * !($acosh\n // V8 bug: https://code.google.com/p/v8/issues/detail?id=3509\n && Math.floor($acosh(Number.MAX_VALUE)) == 710\n // Tor Browser bug: Math.acosh(Infinity) -> NaN\n && $acosh(Infinity) == Infinity\n), 'Math', {\n acosh: function acosh(x) {\n return (x = +x) < 1 ? NaN : x > 94906265.62425156\n ? Math.log(x) + Math.LN2\n : log1p(x - 1 + sqrt(x - 1) * sqrt(x + 1));\n }\n});\n","// 20.2.2.5 Math.asinh(x)\nvar $export = require('./_export');\nvar $asinh = Math.asinh;\n\nfunction asinh(x) {\n return !isFinite(x = +x) || x == 0 ? x : x < 0 ? -asinh(-x) : Math.log(x + Math.sqrt(x * x + 1));\n}\n\n// Tor Browser bug: Math.asinh(0) -> -0\n$export($export.S + $export.F * !($asinh && 1 / $asinh(0) > 0), 'Math', { asinh: asinh });\n","// 20.2.2.7 Math.atanh(x)\nvar $export = require('./_export');\nvar $atanh = Math.atanh;\n\n// Tor Browser bug: Math.atanh(-0) -> 0\n$export($export.S + $export.F * !($atanh && 1 / $atanh(-0) < 0), 'Math', {\n atanh: function atanh(x) {\n return (x = +x) == 0 ? x : Math.log((1 + x) / (1 - x)) / 2;\n }\n});\n","// 20.2.2.9 Math.cbrt(x)\nvar $export = require('./_export');\nvar sign = require('./_math-sign');\n\n$export($export.S, 'Math', {\n cbrt: function cbrt(x) {\n return sign(x = +x) * Math.pow(Math.abs(x), 1 / 3);\n }\n});\n","// 20.2.2.11 Math.clz32(x)\nvar $export = require('./_export');\n\n$export($export.S, 'Math', {\n clz32: function clz32(x) {\n return (x >>>= 0) ? 31 - Math.floor(Math.log(x + 0.5) * Math.LOG2E) : 32;\n }\n});\n","// 20.2.2.12 Math.cosh(x)\nvar $export = require('./_export');\nvar exp = Math.exp;\n\n$export($export.S, 'Math', {\n cosh: function cosh(x) {\n return (exp(x = +x) + exp(-x)) / 2;\n }\n});\n","// 20.2.2.14 Math.expm1(x)\nvar $export = require('./_export');\nvar $expm1 = require('./_math-expm1');\n\n$export($export.S + $export.F * ($expm1 != Math.expm1), 'Math', { expm1: $expm1 });\n","// 20.2.2.16 Math.fround(x)\nvar $export = require('./_export');\n\n$export($export.S, 'Math', { fround: require('./_math-fround') });\n","// 20.2.2.17 Math.hypot([value1[, value2[, … ]]])\nvar $export = require('./_export');\nvar abs = Math.abs;\n\n$export($export.S, 'Math', {\n hypot: function hypot(value1, value2) { // eslint-disable-line no-unused-vars\n var sum = 0;\n var i = 0;\n var aLen = arguments.length;\n var larg = 0;\n var arg, div;\n while (i < aLen) {\n arg = abs(arguments[i++]);\n if (larg < arg) {\n div = larg / arg;\n sum = sum * div * div + 1;\n larg = arg;\n } else if (arg > 0) {\n div = arg / larg;\n sum += div * div;\n } else sum += arg;\n }\n return larg === Infinity ? Infinity : larg * Math.sqrt(sum);\n }\n});\n","// 20.2.2.18 Math.imul(x, y)\nvar $export = require('./_export');\nvar $imul = Math.imul;\n\n// some WebKit versions fails with big numbers, some has wrong arity\n$export($export.S + $export.F * require('./_fails')(function () {\n return $imul(0xffffffff, 5) != -5 || $imul.length != 2;\n}), 'Math', {\n imul: function imul(x, y) {\n var UINT16 = 0xffff;\n var xn = +x;\n var yn = +y;\n var xl = UINT16 & xn;\n var yl = UINT16 & yn;\n return 0 | xl * yl + ((UINT16 & xn >>> 16) * yl + xl * (UINT16 & yn >>> 16) << 16 >>> 0);\n }\n});\n","// 20.2.2.21 Math.log10(x)\nvar $export = require('./_export');\n\n$export($export.S, 'Math', {\n log10: function log10(x) {\n return Math.log(x) * Math.LOG10E;\n }\n});\n","// 20.2.2.20 Math.log1p(x)\nvar $export = require('./_export');\n\n$export($export.S, 'Math', { log1p: require('./_math-log1p') });\n","// 20.2.2.22 Math.log2(x)\nvar $export = require('./_export');\n\n$export($export.S, 'Math', {\n log2: function log2(x) {\n return Math.log(x) / Math.LN2;\n }\n});\n","// 20.2.2.28 Math.sign(x)\nvar $export = require('./_export');\n\n$export($export.S, 'Math', { sign: require('./_math-sign') });\n","// 20.2.2.30 Math.sinh(x)\nvar $export = require('./_export');\nvar expm1 = require('./_math-expm1');\nvar exp = Math.exp;\n\n// V8 near Chromium 38 has a problem with very small numbers\n$export($export.S + $export.F * require('./_fails')(function () {\n return !Math.sinh(-2e-17) != -2e-17;\n}), 'Math', {\n sinh: function sinh(x) {\n return Math.abs(x = +x) < 1\n ? (expm1(x) - expm1(-x)) / 2\n : (exp(x - 1) - exp(-x - 1)) * (Math.E / 2);\n }\n});\n","// 20.2.2.33 Math.tanh(x)\nvar $export = require('./_export');\nvar expm1 = require('./_math-expm1');\nvar exp = Math.exp;\n\n$export($export.S, 'Math', {\n tanh: function tanh(x) {\n var a = expm1(x = +x);\n var b = expm1(-x);\n return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (exp(x) + exp(-x));\n }\n});\n","// 20.2.2.34 Math.trunc(x)\nvar $export = require('./_export');\n\n$export($export.S, 'Math', {\n trunc: function trunc(it) {\n return (it > 0 ? Math.floor : Math.ceil)(it);\n }\n});\n","'use strict';\nvar global = require('./_global');\nvar has = require('./_has');\nvar cof = require('./_cof');\nvar inheritIfRequired = require('./_inherit-if-required');\nvar toPrimitive = require('./_to-primitive');\nvar fails = require('./_fails');\nvar gOPN = require('./_object-gopn').f;\nvar gOPD = require('./_object-gopd').f;\nvar dP = require('./_object-dp').f;\nvar $trim = require('./_string-trim').trim;\nvar NUMBER = 'Number';\nvar $Number = global[NUMBER];\nvar Base = $Number;\nvar proto = $Number.prototype;\n// Opera ~12 has broken Object#toString\nvar BROKEN_COF = cof(require('./_object-create')(proto)) == NUMBER;\nvar TRIM = 'trim' in String.prototype;\n\n// 7.1.3 ToNumber(argument)\nvar toNumber = function (argument) {\n var it = toPrimitive(argument, false);\n if (typeof it == 'string' && it.length > 2) {\n it = TRIM ? it.trim() : $trim(it, 3);\n var first = it.charCodeAt(0);\n var third, radix, maxCode;\n if (first === 43 || first === 45) {\n third = it.charCodeAt(2);\n if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix\n } else if (first === 48) {\n switch (it.charCodeAt(1)) {\n case 66: case 98: radix = 2; maxCode = 49; break; // fast equal /^0b[01]+$/i\n case 79: case 111: radix = 8; maxCode = 55; break; // fast equal /^0o[0-7]+$/i\n default: return +it;\n }\n for (var digits = it.slice(2), i = 0, l = digits.length, code; i < l; i++) {\n code = digits.charCodeAt(i);\n // parseInt parses a string to a first unavailable symbol\n // but ToNumber should return NaN if a string contains unavailable symbols\n if (code < 48 || code > maxCode) return NaN;\n } return parseInt(digits, radix);\n }\n } return +it;\n};\n\nif (!$Number(' 0o1') || !$Number('0b1') || $Number('+0x1')) {\n $Number = function Number(value) {\n var it = arguments.length < 1 ? 0 : value;\n var that = this;\n return that instanceof $Number\n // check on 1..constructor(foo) case\n && (BROKEN_COF ? fails(function () { proto.valueOf.call(that); }) : cof(that) != NUMBER)\n ? inheritIfRequired(new Base(toNumber(it)), that, $Number) : toNumber(it);\n };\n for (var keys = require('./_descriptors') ? gOPN(Base) : (\n // ES3:\n 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +\n // ES6 (in case, if modules with ES6 Number statics required before):\n 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' +\n 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger'\n ).split(','), j = 0, key; keys.length > j; j++) {\n if (has(Base, key = keys[j]) && !has($Number, key)) {\n dP($Number, key, gOPD(Base, key));\n }\n }\n $Number.prototype = proto;\n proto.constructor = $Number;\n require('./_redefine')(global, NUMBER, $Number);\n}\n","// 20.1.2.1 Number.EPSILON\nvar $export = require('./_export');\n\n$export($export.S, 'Number', { EPSILON: Math.pow(2, -52) });\n","// 20.1.2.2 Number.isFinite(number)\nvar $export = require('./_export');\nvar _isFinite = require('./_global').isFinite;\n\n$export($export.S, 'Number', {\n isFinite: function isFinite(it) {\n return typeof it == 'number' && _isFinite(it);\n }\n});\n","// 20.1.2.3 Number.isInteger(number)\nvar $export = require('./_export');\n\n$export($export.S, 'Number', { isInteger: require('./_is-integer') });\n","// 20.1.2.4 Number.isNaN(number)\nvar $export = require('./_export');\n\n$export($export.S, 'Number', {\n isNaN: function isNaN(number) {\n // eslint-disable-next-line no-self-compare\n return number != number;\n }\n});\n","// 20.1.2.5 Number.isSafeInteger(number)\nvar $export = require('./_export');\nvar isInteger = require('./_is-integer');\nvar abs = Math.abs;\n\n$export($export.S, 'Number', {\n isSafeInteger: function isSafeInteger(number) {\n return isInteger(number) && abs(number) <= 0x1fffffffffffff;\n }\n});\n","// 20.1.2.6 Number.MAX_SAFE_INTEGER\nvar $export = require('./_export');\n\n$export($export.S, 'Number', { MAX_SAFE_INTEGER: 0x1fffffffffffff });\n","// 20.1.2.10 Number.MIN_SAFE_INTEGER\nvar $export = require('./_export');\n\n$export($export.S, 'Number', { MIN_SAFE_INTEGER: -0x1fffffffffffff });\n","var $export = require('./_export');\nvar $parseFloat = require('./_parse-float');\n// 20.1.2.12 Number.parseFloat(string)\n$export($export.S + $export.F * (Number.parseFloat != $parseFloat), 'Number', { parseFloat: $parseFloat });\n","var $export = require('./_export');\nvar $parseInt = require('./_parse-int');\n// 20.1.2.13 Number.parseInt(string, radix)\n$export($export.S + $export.F * (Number.parseInt != $parseInt), 'Number', { parseInt: $parseInt });\n","'use strict';\nvar $export = require('./_export');\nvar toInteger = require('./_to-integer');\nvar aNumberValue = require('./_a-number-value');\nvar repeat = require('./_string-repeat');\nvar $toFixed = 1.0.toFixed;\nvar floor = Math.floor;\nvar data = [0, 0, 0, 0, 0, 0];\nvar ERROR = 'Number.toFixed: incorrect invocation!';\nvar ZERO = '0';\n\nvar multiply = function (n, c) {\n var i = -1;\n var c2 = c;\n while (++i < 6) {\n c2 += n * data[i];\n data[i] = c2 % 1e7;\n c2 = floor(c2 / 1e7);\n }\n};\nvar divide = function (n) {\n var i = 6;\n var c = 0;\n while (--i >= 0) {\n c += data[i];\n data[i] = floor(c / n);\n c = (c % n) * 1e7;\n }\n};\nvar numToString = function () {\n var i = 6;\n var s = '';\n while (--i >= 0) {\n if (s !== '' || i === 0 || data[i] !== 0) {\n var t = String(data[i]);\n s = s === '' ? t : s + repeat.call(ZERO, 7 - t.length) + t;\n }\n } return s;\n};\nvar pow = function (x, n, acc) {\n return n === 0 ? acc : n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc);\n};\nvar log = function (x) {\n var n = 0;\n var x2 = x;\n while (x2 >= 4096) {\n n += 12;\n x2 /= 4096;\n }\n while (x2 >= 2) {\n n += 1;\n x2 /= 2;\n } return n;\n};\n\n$export($export.P + $export.F * (!!$toFixed && (\n 0.00008.toFixed(3) !== '0.000' ||\n 0.9.toFixed(0) !== '1' ||\n 1.255.toFixed(2) !== '1.25' ||\n 1000000000000000128.0.toFixed(0) !== '1000000000000000128'\n) || !require('./_fails')(function () {\n // V8 ~ Android 4.3-\n $toFixed.call({});\n})), 'Number', {\n toFixed: function toFixed(fractionDigits) {\n var x = aNumberValue(this, ERROR);\n var f = toInteger(fractionDigits);\n var s = '';\n var m = ZERO;\n var e, z, j, k;\n if (f < 0 || f > 20) throw RangeError(ERROR);\n // eslint-disable-next-line no-self-compare\n if (x != x) return 'NaN';\n if (x <= -1e21 || x >= 1e21) return String(x);\n if (x < 0) {\n s = '-';\n x = -x;\n }\n if (x > 1e-21) {\n e = log(x * pow(2, 69, 1)) - 69;\n z = e < 0 ? x * pow(2, -e, 1) : x / pow(2, e, 1);\n z *= 0x10000000000000;\n e = 52 - e;\n if (e > 0) {\n multiply(0, z);\n j = f;\n while (j >= 7) {\n multiply(1e7, 0);\n j -= 7;\n }\n multiply(pow(10, j, 1), 0);\n j = e - 1;\n while (j >= 23) {\n divide(1 << 23);\n j -= 23;\n }\n divide(1 << j);\n multiply(1, 1);\n divide(2);\n m = numToString();\n } else {\n multiply(0, z);\n multiply(1 << -e, 0);\n m = numToString() + repeat.call(ZERO, f);\n }\n }\n if (f > 0) {\n k = m.length;\n m = s + (k <= f ? '0.' + repeat.call(ZERO, f - k) + m : m.slice(0, k - f) + '.' + m.slice(k - f));\n } else {\n m = s + m;\n } return m;\n }\n});\n","'use strict';\nvar $export = require('./_export');\nvar $fails = require('./_fails');\nvar aNumberValue = require('./_a-number-value');\nvar $toPrecision = 1.0.toPrecision;\n\n$export($export.P + $export.F * ($fails(function () {\n // IE7-\n return $toPrecision.call(1, undefined) !== '1';\n}) || !$fails(function () {\n // V8 ~ Android 4.3-\n $toPrecision.call({});\n})), 'Number', {\n toPrecision: function toPrecision(precision) {\n var that = aNumberValue(this, 'Number#toPrecision: incorrect invocation!');\n return precision === undefined ? $toPrecision.call(that) : $toPrecision.call(that, precision);\n }\n});\n","// 19.1.3.1 Object.assign(target, source)\nvar $export = require('./_export');\n\n$export($export.S + $export.F, 'Object', { assign: require('./_object-assign') });\n","var $export = require('./_export');\n// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])\n$export($export.S, 'Object', { create: require('./_object-create') });\n","var $export = require('./_export');\n// 19.1.2.3 / 15.2.3.7 Object.defineProperties(O, Properties)\n$export($export.S + $export.F * !require('./_descriptors'), 'Object', { defineProperties: require('./_object-dps') });\n","var $export = require('./_export');\n// 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)\n$export($export.S + $export.F * !require('./_descriptors'), 'Object', { defineProperty: require('./_object-dp').f });\n","// 19.1.2.5 Object.freeze(O)\nvar isObject = require('./_is-object');\nvar meta = require('./_meta').onFreeze;\n\nrequire('./_object-sap')('freeze', function ($freeze) {\n return function freeze(it) {\n return $freeze && isObject(it) ? $freeze(meta(it)) : it;\n };\n});\n","// 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)\nvar toIObject = require('./_to-iobject');\nvar $getOwnPropertyDescriptor = require('./_object-gopd').f;\n\nrequire('./_object-sap')('getOwnPropertyDescriptor', function () {\n return function getOwnPropertyDescriptor(it, key) {\n return $getOwnPropertyDescriptor(toIObject(it), key);\n };\n});\n","// 19.1.2.7 Object.getOwnPropertyNames(O)\nrequire('./_object-sap')('getOwnPropertyNames', function () {\n return require('./_object-gopn-ext').f;\n});\n","// 19.1.2.9 Object.getPrototypeOf(O)\nvar toObject = require('./_to-object');\nvar $getPrototypeOf = require('./_object-gpo');\n\nrequire('./_object-sap')('getPrototypeOf', function () {\n return function getPrototypeOf(it) {\n return $getPrototypeOf(toObject(it));\n };\n});\n","// 19.1.2.11 Object.isExtensible(O)\nvar isObject = require('./_is-object');\n\nrequire('./_object-sap')('isExtensible', function ($isExtensible) {\n return function isExtensible(it) {\n return isObject(it) ? $isExtensible ? $isExtensible(it) : true : false;\n };\n});\n","// 19.1.2.12 Object.isFrozen(O)\nvar isObject = require('./_is-object');\n\nrequire('./_object-sap')('isFrozen', function ($isFrozen) {\n return function isFrozen(it) {\n return isObject(it) ? $isFrozen ? $isFrozen(it) : false : true;\n };\n});\n","// 19.1.2.13 Object.isSealed(O)\nvar isObject = require('./_is-object');\n\nrequire('./_object-sap')('isSealed', function ($isSealed) {\n return function isSealed(it) {\n return isObject(it) ? $isSealed ? $isSealed(it) : false : true;\n };\n});\n","// 19.1.3.10 Object.is(value1, value2)\nvar $export = require('./_export');\n$export($export.S, 'Object', { is: require('./_same-value') });\n","// 19.1.2.14 Object.keys(O)\nvar toObject = require('./_to-object');\nvar $keys = require('./_object-keys');\n\nrequire('./_object-sap')('keys', function () {\n return function keys(it) {\n return $keys(toObject(it));\n };\n});\n","// 19.1.2.15 Object.preventExtensions(O)\nvar isObject = require('./_is-object');\nvar meta = require('./_meta').onFreeze;\n\nrequire('./_object-sap')('preventExtensions', function ($preventExtensions) {\n return function preventExtensions(it) {\n return $preventExtensions && isObject(it) ? $preventExtensions(meta(it)) : it;\n };\n});\n","// 19.1.2.17 Object.seal(O)\nvar isObject = require('./_is-object');\nvar meta = require('./_meta').onFreeze;\n\nrequire('./_object-sap')('seal', function ($seal) {\n return function seal(it) {\n return $seal && isObject(it) ? $seal(meta(it)) : it;\n };\n});\n","// 19.1.3.19 Object.setPrototypeOf(O, proto)\nvar $export = require('./_export');\n$export($export.S, 'Object', { setPrototypeOf: require('./_set-proto').set });\n","'use strict';\n// 19.1.3.6 Object.prototype.toString()\nvar classof = require('./_classof');\nvar test = {};\ntest[require('./_wks')('toStringTag')] = 'z';\nif (test + '' != '[object z]') {\n require('./_redefine')(Object.prototype, 'toString', function toString() {\n return '[object ' + classof(this) + ']';\n }, true);\n}\n","var $export = require('./_export');\nvar $parseFloat = require('./_parse-float');\n// 18.2.4 parseFloat(string)\n$export($export.G + $export.F * (parseFloat != $parseFloat), { parseFloat: $parseFloat });\n","var $export = require('./_export');\nvar $parseInt = require('./_parse-int');\n// 18.2.5 parseInt(string, radix)\n$export($export.G + $export.F * (parseInt != $parseInt), { parseInt: $parseInt });\n","'use strict';\nvar LIBRARY = require('./_library');\nvar global = require('./_global');\nvar ctx = require('./_ctx');\nvar classof = require('./_classof');\nvar $export = require('./_export');\nvar isObject = require('./_is-object');\nvar aFunction = require('./_a-function');\nvar anInstance = require('./_an-instance');\nvar forOf = require('./_for-of');\nvar speciesConstructor = require('./_species-constructor');\nvar task = require('./_task').set;\nvar microtask = require('./_microtask')();\nvar newPromiseCapabilityModule = require('./_new-promise-capability');\nvar perform = require('./_perform');\nvar userAgent = require('./_user-agent');\nvar promiseResolve = require('./_promise-resolve');\nvar PROMISE = 'Promise';\nvar TypeError = global.TypeError;\nvar process = global.process;\nvar versions = process && process.versions;\nvar v8 = versions && versions.v8 || '';\nvar $Promise = global[PROMISE];\nvar isNode = classof(process) == 'process';\nvar empty = function () { /* empty */ };\nvar Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;\nvar newPromiseCapability = newGenericPromiseCapability = newPromiseCapabilityModule.f;\n\nvar USE_NATIVE = !!function () {\n try {\n // correct subclassing with @@species support\n var promise = $Promise.resolve(1);\n var FakePromise = (promise.constructor = {})[require('./_wks')('species')] = function (exec) {\n exec(empty, empty);\n };\n // unhandled rejections tracking support, NodeJS Promise without it fails @@species test\n return (isNode || typeof PromiseRejectionEvent == 'function')\n && promise.then(empty) instanceof FakePromise\n // v8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables\n // https://bugs.chromium.org/p/chromium/issues/detail?id=830565\n // we can't detect it synchronously, so just check versions\n && v8.indexOf('6.6') !== 0\n && userAgent.indexOf('Chrome/66') === -1;\n } catch (e) { /* empty */ }\n}();\n\n// helpers\nvar isThenable = function (it) {\n var then;\n return isObject(it) && typeof (then = it.then) == 'function' ? then : false;\n};\nvar notify = function (promise, isReject) {\n if (promise._n) return;\n promise._n = true;\n var chain = promise._c;\n microtask(function () {\n var value = promise._v;\n var ok = promise._s == 1;\n var i = 0;\n var run = function (reaction) {\n var handler = ok ? reaction.ok : reaction.fail;\n var resolve = reaction.resolve;\n var reject = reaction.reject;\n var domain = reaction.domain;\n var result, then, exited;\n try {\n if (handler) {\n if (!ok) {\n if (promise._h == 2) onHandleUnhandled(promise);\n promise._h = 1;\n }\n if (handler === true) result = value;\n else {\n if (domain) domain.enter();\n result = handler(value); // may throw\n if (domain) {\n domain.exit();\n exited = true;\n }\n }\n if (result === reaction.promise) {\n reject(TypeError('Promise-chain cycle'));\n } else if (then = isThenable(result)) {\n then.call(result, resolve, reject);\n } else resolve(result);\n } else reject(value);\n } catch (e) {\n if (domain && !exited) domain.exit();\n reject(e);\n }\n };\n while (chain.length > i) run(chain[i++]); // variable length - can't use forEach\n promise._c = [];\n promise._n = false;\n if (isReject && !promise._h) onUnhandled(promise);\n });\n};\nvar onUnhandled = function (promise) {\n task.call(global, function () {\n var value = promise._v;\n var unhandled = isUnhandled(promise);\n var result, handler, console;\n if (unhandled) {\n result = perform(function () {\n if (isNode) {\n process.emit('unhandledRejection', value, promise);\n } else if (handler = global.onunhandledrejection) {\n handler({ promise: promise, reason: value });\n } else if ((console = global.console) && console.error) {\n console.error('Unhandled promise rejection', value);\n }\n });\n // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should\n promise._h = isNode || isUnhandled(promise) ? 2 : 1;\n } promise._a = undefined;\n if (unhandled && result.e) throw result.v;\n });\n};\nvar isUnhandled = function (promise) {\n return promise._h !== 1 && (promise._a || promise._c).length === 0;\n};\nvar onHandleUnhandled = function (promise) {\n task.call(global, function () {\n var handler;\n if (isNode) {\n process.emit('rejectionHandled', promise);\n } else if (handler = global.onrejectionhandled) {\n handler({ promise: promise, reason: promise._v });\n }\n });\n};\nvar $reject = function (value) {\n var promise = this;\n if (promise._d) return;\n promise._d = true;\n promise = promise._w || promise; // unwrap\n promise._v = value;\n promise._s = 2;\n if (!promise._a) promise._a = promise._c.slice();\n notify(promise, true);\n};\nvar $resolve = function (value) {\n var promise = this;\n var then;\n if (promise._d) return;\n promise._d = true;\n promise = promise._w || promise; // unwrap\n try {\n if (promise === value) throw TypeError(\"Promise can't be resolved itself\");\n if (then = isThenable(value)) {\n microtask(function () {\n var wrapper = { _w: promise, _d: false }; // wrap\n try {\n then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));\n } catch (e) {\n $reject.call(wrapper, e);\n }\n });\n } else {\n promise._v = value;\n promise._s = 1;\n notify(promise, false);\n }\n } catch (e) {\n $reject.call({ _w: promise, _d: false }, e); // wrap\n }\n};\n\n// constructor polyfill\nif (!USE_NATIVE) {\n // 25.4.3.1 Promise(executor)\n $Promise = function Promise(executor) {\n anInstance(this, $Promise, PROMISE, '_h');\n aFunction(executor);\n Internal.call(this);\n try {\n executor(ctx($resolve, this, 1), ctx($reject, this, 1));\n } catch (err) {\n $reject.call(this, err);\n }\n };\n // eslint-disable-next-line no-unused-vars\n Internal = function Promise(executor) {\n this._c = []; // <- awaiting reactions\n this._a = undefined; // <- checked in isUnhandled reactions\n this._s = 0; // <- state\n this._d = false; // <- done\n this._v = undefined; // <- value\n this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled\n this._n = false; // <- notify\n };\n Internal.prototype = require('./_redefine-all')($Promise.prototype, {\n // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)\n then: function then(onFulfilled, onRejected) {\n var reaction = newPromiseCapability(speciesConstructor(this, $Promise));\n reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;\n reaction.fail = typeof onRejected == 'function' && onRejected;\n reaction.domain = isNode ? process.domain : undefined;\n this._c.push(reaction);\n if (this._a) this._a.push(reaction);\n if (this._s) notify(this, false);\n return reaction.promise;\n },\n // 25.4.5.1 Promise.prototype.catch(onRejected)\n 'catch': function (onRejected) {\n return this.then(undefined, onRejected);\n }\n });\n OwnPromiseCapability = function () {\n var promise = new Internal();\n this.promise = promise;\n this.resolve = ctx($resolve, promise, 1);\n this.reject = ctx($reject, promise, 1);\n };\n newPromiseCapabilityModule.f = newPromiseCapability = function (C) {\n return C === $Promise || C === Wrapper\n ? new OwnPromiseCapability(C)\n : newGenericPromiseCapability(C);\n };\n}\n\n$export($export.G + $export.W + $export.F * !USE_NATIVE, { Promise: $Promise });\nrequire('./_set-to-string-tag')($Promise, PROMISE);\nrequire('./_set-species')(PROMISE);\nWrapper = require('./_core')[PROMISE];\n\n// statics\n$export($export.S + $export.F * !USE_NATIVE, PROMISE, {\n // 25.4.4.5 Promise.reject(r)\n reject: function reject(r) {\n var capability = newPromiseCapability(this);\n var $$reject = capability.reject;\n $$reject(r);\n return capability.promise;\n }\n});\n$export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {\n // 25.4.4.6 Promise.resolve(x)\n resolve: function resolve(x) {\n return promiseResolve(LIBRARY && this === Wrapper ? $Promise : this, x);\n }\n});\n$export($export.S + $export.F * !(USE_NATIVE && require('./_iter-detect')(function (iter) {\n $Promise.all(iter)['catch'](empty);\n})), PROMISE, {\n // 25.4.4.1 Promise.all(iterable)\n all: function all(iterable) {\n var C = this;\n var capability = newPromiseCapability(C);\n var resolve = capability.resolve;\n var reject = capability.reject;\n var result = perform(function () {\n var values = [];\n var index = 0;\n var remaining = 1;\n forOf(iterable, false, function (promise) {\n var $index = index++;\n var alreadyCalled = false;\n values.push(undefined);\n remaining++;\n C.resolve(promise).then(function (value) {\n if (alreadyCalled) return;\n alreadyCalled = true;\n values[$index] = value;\n --remaining || resolve(values);\n }, reject);\n });\n --remaining || resolve(values);\n });\n if (result.e) reject(result.v);\n return capability.promise;\n },\n // 25.4.4.4 Promise.race(iterable)\n race: function race(iterable) {\n var C = this;\n var capability = newPromiseCapability(C);\n var reject = capability.reject;\n var result = perform(function () {\n forOf(iterable, false, function (promise) {\n C.resolve(promise).then(capability.resolve, reject);\n });\n });\n if (result.e) reject(result.v);\n return capability.promise;\n }\n});\n","// 26.1.1 Reflect.apply(target, thisArgument, argumentsList)\nvar $export = require('./_export');\nvar aFunction = require('./_a-function');\nvar anObject = require('./_an-object');\nvar rApply = (require('./_global').Reflect || {}).apply;\nvar fApply = Function.apply;\n// MS Edge argumentsList argument is optional\n$export($export.S + $export.F * !require('./_fails')(function () {\n rApply(function () { /* empty */ });\n}), 'Reflect', {\n apply: function apply(target, thisArgument, argumentsList) {\n var T = aFunction(target);\n var L = anObject(argumentsList);\n return rApply ? rApply(T, thisArgument, L) : fApply.call(T, thisArgument, L);\n }\n});\n","// 26.1.2 Reflect.construct(target, argumentsList [, newTarget])\nvar $export = require('./_export');\nvar create = require('./_object-create');\nvar aFunction = require('./_a-function');\nvar anObject = require('./_an-object');\nvar isObject = require('./_is-object');\nvar fails = require('./_fails');\nvar bind = require('./_bind');\nvar rConstruct = (require('./_global').Reflect || {}).construct;\n\n// MS Edge supports only 2 arguments and argumentsList argument is optional\n// FF Nightly sets third argument as `new.target`, but does not create `this` from it\nvar NEW_TARGET_BUG = fails(function () {\n function F() { /* empty */ }\n return !(rConstruct(function () { /* empty */ }, [], F) instanceof F);\n});\nvar ARGS_BUG = !fails(function () {\n rConstruct(function () { /* empty */ });\n});\n\n$export($export.S + $export.F * (NEW_TARGET_BUG || ARGS_BUG), 'Reflect', {\n construct: function construct(Target, args /* , newTarget */) {\n aFunction(Target);\n anObject(args);\n var newTarget = arguments.length < 3 ? Target : aFunction(arguments[2]);\n if (ARGS_BUG && !NEW_TARGET_BUG) return rConstruct(Target, args, newTarget);\n if (Target == newTarget) {\n // w/o altered newTarget, optimization for 0-4 arguments\n switch (args.length) {\n case 0: return new Target();\n case 1: return new Target(args[0]);\n case 2: return new Target(args[0], args[1]);\n case 3: return new Target(args[0], args[1], args[2]);\n case 4: return new Target(args[0], args[1], args[2], args[3]);\n }\n // w/o altered newTarget, lot of arguments case\n var $args = [null];\n $args.push.apply($args, args);\n return new (bind.apply(Target, $args))();\n }\n // with altered newTarget, not support built-in constructors\n var proto = newTarget.prototype;\n var instance = create(isObject(proto) ? proto : Object.prototype);\n var result = Function.apply.call(Target, instance, args);\n return isObject(result) ? result : instance;\n }\n});\n","// 26.1.3 Reflect.defineProperty(target, propertyKey, attributes)\nvar dP = require('./_object-dp');\nvar $export = require('./_export');\nvar anObject = require('./_an-object');\nvar toPrimitive = require('./_to-primitive');\n\n// MS Edge has broken Reflect.defineProperty - throwing instead of returning false\n$export($export.S + $export.F * require('./_fails')(function () {\n // eslint-disable-next-line no-undef\n Reflect.defineProperty(dP.f({}, 1, { value: 1 }), 1, { value: 2 });\n}), 'Reflect', {\n defineProperty: function defineProperty(target, propertyKey, attributes) {\n anObject(target);\n propertyKey = toPrimitive(propertyKey, true);\n anObject(attributes);\n try {\n dP.f(target, propertyKey, attributes);\n return true;\n } catch (e) {\n return false;\n }\n }\n});\n","// 26.1.4 Reflect.deleteProperty(target, propertyKey)\nvar $export = require('./_export');\nvar gOPD = require('./_object-gopd').f;\nvar anObject = require('./_an-object');\n\n$export($export.S, 'Reflect', {\n deleteProperty: function deleteProperty(target, propertyKey) {\n var desc = gOPD(anObject(target), propertyKey);\n return desc && !desc.configurable ? false : delete target[propertyKey];\n }\n});\n","'use strict';\n// 26.1.5 Reflect.enumerate(target)\nvar $export = require('./_export');\nvar anObject = require('./_an-object');\nvar Enumerate = function (iterated) {\n this._t = anObject(iterated); // target\n this._i = 0; // next index\n var keys = this._k = []; // keys\n var key;\n for (key in iterated) keys.push(key);\n};\nrequire('./_iter-create')(Enumerate, 'Object', function () {\n var that = this;\n var keys = that._k;\n var key;\n do {\n if (that._i >= keys.length) return { value: undefined, done: true };\n } while (!((key = keys[that._i++]) in that._t));\n return { value: key, done: false };\n});\n\n$export($export.S, 'Reflect', {\n enumerate: function enumerate(target) {\n return new Enumerate(target);\n }\n});\n","// 26.1.7 Reflect.getOwnPropertyDescriptor(target, propertyKey)\nvar gOPD = require('./_object-gopd');\nvar $export = require('./_export');\nvar anObject = require('./_an-object');\n\n$export($export.S, 'Reflect', {\n getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey) {\n return gOPD.f(anObject(target), propertyKey);\n }\n});\n","// 26.1.8 Reflect.getPrototypeOf(target)\nvar $export = require('./_export');\nvar getProto = require('./_object-gpo');\nvar anObject = require('./_an-object');\n\n$export($export.S, 'Reflect', {\n getPrototypeOf: function getPrototypeOf(target) {\n return getProto(anObject(target));\n }\n});\n","// 26.1.6 Reflect.get(target, propertyKey [, receiver])\nvar gOPD = require('./_object-gopd');\nvar getPrototypeOf = require('./_object-gpo');\nvar has = require('./_has');\nvar $export = require('./_export');\nvar isObject = require('./_is-object');\nvar anObject = require('./_an-object');\n\nfunction get(target, propertyKey /* , receiver */) {\n var receiver = arguments.length < 3 ? target : arguments[2];\n var desc, proto;\n if (anObject(target) === receiver) return target[propertyKey];\n if (desc = gOPD.f(target, propertyKey)) return has(desc, 'value')\n ? desc.value\n : desc.get !== undefined\n ? desc.get.call(receiver)\n : undefined;\n if (isObject(proto = getPrototypeOf(target))) return get(proto, propertyKey, receiver);\n}\n\n$export($export.S, 'Reflect', { get: get });\n","// 26.1.9 Reflect.has(target, propertyKey)\nvar $export = require('./_export');\n\n$export($export.S, 'Reflect', {\n has: function has(target, propertyKey) {\n return propertyKey in target;\n }\n});\n","// 26.1.10 Reflect.isExtensible(target)\nvar $export = require('./_export');\nvar anObject = require('./_an-object');\nvar $isExtensible = Object.isExtensible;\n\n$export($export.S, 'Reflect', {\n isExtensible: function isExtensible(target) {\n anObject(target);\n return $isExtensible ? $isExtensible(target) : true;\n }\n});\n","// 26.1.11 Reflect.ownKeys(target)\nvar $export = require('./_export');\n\n$export($export.S, 'Reflect', { ownKeys: require('./_own-keys') });\n","// 26.1.12 Reflect.preventExtensions(target)\nvar $export = require('./_export');\nvar anObject = require('./_an-object');\nvar $preventExtensions = Object.preventExtensions;\n\n$export($export.S, 'Reflect', {\n preventExtensions: function preventExtensions(target) {\n anObject(target);\n try {\n if ($preventExtensions) $preventExtensions(target);\n return true;\n } catch (e) {\n return false;\n }\n }\n});\n","// 26.1.14 Reflect.setPrototypeOf(target, proto)\nvar $export = require('./_export');\nvar setProto = require('./_set-proto');\n\nif (setProto) $export($export.S, 'Reflect', {\n setPrototypeOf: function setPrototypeOf(target, proto) {\n setProto.check(target, proto);\n try {\n setProto.set(target, proto);\n return true;\n } catch (e) {\n return false;\n }\n }\n});\n","// 26.1.13 Reflect.set(target, propertyKey, V [, receiver])\nvar dP = require('./_object-dp');\nvar gOPD = require('./_object-gopd');\nvar getPrototypeOf = require('./_object-gpo');\nvar has = require('./_has');\nvar $export = require('./_export');\nvar createDesc = require('./_property-desc');\nvar anObject = require('./_an-object');\nvar isObject = require('./_is-object');\n\nfunction set(target, propertyKey, V /* , receiver */) {\n var receiver = arguments.length < 4 ? target : arguments[3];\n var ownDesc = gOPD.f(anObject(target), propertyKey);\n var existingDescriptor, proto;\n if (!ownDesc) {\n if (isObject(proto = getPrototypeOf(target))) {\n return set(proto, propertyKey, V, receiver);\n }\n ownDesc = createDesc(0);\n }\n if (has(ownDesc, 'value')) {\n if (ownDesc.writable === false || !isObject(receiver)) return false;\n if (existingDescriptor = gOPD.f(receiver, propertyKey)) {\n if (existingDescriptor.get || existingDescriptor.set || existingDescriptor.writable === false) return false;\n existingDescriptor.value = V;\n dP.f(receiver, propertyKey, existingDescriptor);\n } else dP.f(receiver, propertyKey, createDesc(0, V));\n return true;\n }\n return ownDesc.set === undefined ? false : (ownDesc.set.call(receiver, V), true);\n}\n\n$export($export.S, 'Reflect', { set: set });\n","var global = require('./_global');\nvar inheritIfRequired = require('./_inherit-if-required');\nvar dP = require('./_object-dp').f;\nvar gOPN = require('./_object-gopn').f;\nvar isRegExp = require('./_is-regexp');\nvar $flags = require('./_flags');\nvar $RegExp = global.RegExp;\nvar Base = $RegExp;\nvar proto = $RegExp.prototype;\nvar re1 = /a/g;\nvar re2 = /a/g;\n// \"new\" creates a new object, old webkit buggy here\nvar CORRECT_NEW = new $RegExp(re1) !== re1;\n\nif (require('./_descriptors') && (!CORRECT_NEW || require('./_fails')(function () {\n re2[require('./_wks')('match')] = false;\n // RegExp constructor can alter flags and IsRegExp works correct with @@match\n return $RegExp(re1) != re1 || $RegExp(re2) == re2 || $RegExp(re1, 'i') != '/a/i';\n}))) {\n $RegExp = function RegExp(p, f) {\n var tiRE = this instanceof $RegExp;\n var piRE = isRegExp(p);\n var fiU = f === undefined;\n return !tiRE && piRE && p.constructor === $RegExp && fiU ? p\n : inheritIfRequired(CORRECT_NEW\n ? new Base(piRE && !fiU ? p.source : p, f)\n : Base((piRE = p instanceof $RegExp) ? p.source : p, piRE && fiU ? $flags.call(p) : f)\n , tiRE ? this : proto, $RegExp);\n };\n var proxy = function (key) {\n key in $RegExp || dP($RegExp, key, {\n configurable: true,\n get: function () { return Base[key]; },\n set: function (it) { Base[key] = it; }\n });\n };\n for (var keys = gOPN(Base), i = 0; keys.length > i;) proxy(keys[i++]);\n proto.constructor = $RegExp;\n $RegExp.prototype = proto;\n require('./_redefine')(global, 'RegExp', $RegExp);\n}\n\nrequire('./_set-species')('RegExp');\n","'use strict';\nvar regexpExec = require('./_regexp-exec');\nrequire('./_export')({\n target: 'RegExp',\n proto: true,\n forced: regexpExec !== /./.exec\n}, {\n exec: regexpExec\n});\n","// 21.2.5.3 get RegExp.prototype.flags()\nif (require('./_descriptors') && /./g.flags != 'g') require('./_object-dp').f(RegExp.prototype, 'flags', {\n configurable: true,\n get: require('./_flags')\n});\n","'use strict';\n\nvar anObject = require('./_an-object');\nvar toLength = require('./_to-length');\nvar advanceStringIndex = require('./_advance-string-index');\nvar regExpExec = require('./_regexp-exec-abstract');\n\n// @@match logic\nrequire('./_fix-re-wks')('match', 1, function (defined, MATCH, $match, maybeCallNative) {\n return [\n // `String.prototype.match` method\n // https://tc39.github.io/ecma262/#sec-string.prototype.match\n function match(regexp) {\n var O = defined(this);\n var fn = regexp == undefined ? undefined : regexp[MATCH];\n return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));\n },\n // `RegExp.prototype[@@match]` method\n // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match\n function (regexp) {\n var res = maybeCallNative($match, regexp, this);\n if (res.done) return res.value;\n var rx = anObject(regexp);\n var S = String(this);\n if (!rx.global) return regExpExec(rx, S);\n var fullUnicode = rx.unicode;\n rx.lastIndex = 0;\n var A = [];\n var n = 0;\n var result;\n while ((result = regExpExec(rx, S)) !== null) {\n var matchStr = String(result[0]);\n A[n] = matchStr;\n if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);\n n++;\n }\n return n === 0 ? null : A;\n }\n ];\n});\n","'use strict';\n\nvar anObject = require('./_an-object');\nvar toObject = require('./_to-object');\nvar toLength = require('./_to-length');\nvar toInteger = require('./_to-integer');\nvar advanceStringIndex = require('./_advance-string-index');\nvar regExpExec = require('./_regexp-exec-abstract');\nvar max = Math.max;\nvar min = Math.min;\nvar floor = Math.floor;\nvar SUBSTITUTION_SYMBOLS = /\\$([$&`']|\\d\\d?|<[^>]*>)/g;\nvar SUBSTITUTION_SYMBOLS_NO_NAMED = /\\$([$&`']|\\d\\d?)/g;\n\nvar maybeToString = function (it) {\n return it === undefined ? it : String(it);\n};\n\n// @@replace logic\nrequire('./_fix-re-wks')('replace', 2, function (defined, REPLACE, $replace, maybeCallNative) {\n return [\n // `String.prototype.replace` method\n // https://tc39.github.io/ecma262/#sec-string.prototype.replace\n function replace(searchValue, replaceValue) {\n var O = defined(this);\n var fn = searchValue == undefined ? undefined : searchValue[REPLACE];\n return fn !== undefined\n ? fn.call(searchValue, O, replaceValue)\n : $replace.call(String(O), searchValue, replaceValue);\n },\n // `RegExp.prototype[@@replace]` method\n // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace\n function (regexp, replaceValue) {\n var res = maybeCallNative($replace, regexp, this, replaceValue);\n if (res.done) return res.value;\n\n var rx = anObject(regexp);\n var S = String(this);\n var functionalReplace = typeof replaceValue === 'function';\n if (!functionalReplace) replaceValue = String(replaceValue);\n var global = rx.global;\n if (global) {\n var fullUnicode = rx.unicode;\n rx.lastIndex = 0;\n }\n var results = [];\n while (true) {\n var result = regExpExec(rx, S);\n if (result === null) break;\n results.push(result);\n if (!global) break;\n var matchStr = String(result[0]);\n if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);\n }\n var accumulatedResult = '';\n var nextSourcePosition = 0;\n for (var i = 0; i < results.length; i++) {\n result = results[i];\n var matched = String(result[0]);\n var position = max(min(toInteger(result.index), S.length), 0);\n var captures = [];\n // NOTE: This is equivalent to\n // captures = result.slice(1).map(maybeToString)\n // but for some reason `nativeSlice.call(result, 1, result.length)` (called in\n // the slice polyfill when slicing native arrays) \"doesn't work\" in safari 9 and\n // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.\n for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j]));\n var namedCaptures = result.groups;\n if (functionalReplace) {\n var replacerArgs = [matched].concat(captures, position, S);\n if (namedCaptures !== undefined) replacerArgs.push(namedCaptures);\n var replacement = String(replaceValue.apply(undefined, replacerArgs));\n } else {\n replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);\n }\n if (position >= nextSourcePosition) {\n accumulatedResult += S.slice(nextSourcePosition, position) + replacement;\n nextSourcePosition = position + matched.length;\n }\n }\n return accumulatedResult + S.slice(nextSourcePosition);\n }\n ];\n\n // https://tc39.github.io/ecma262/#sec-getsubstitution\n function getSubstitution(matched, str, position, captures, namedCaptures, replacement) {\n var tailPos = position + matched.length;\n var m = captures.length;\n var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;\n if (namedCaptures !== undefined) {\n namedCaptures = toObject(namedCaptures);\n symbols = SUBSTITUTION_SYMBOLS;\n }\n return $replace.call(replacement, symbols, function (match, ch) {\n var capture;\n switch (ch.charAt(0)) {\n case '$': return '$';\n case '&': return matched;\n case '`': return str.slice(0, position);\n case \"'\": return str.slice(tailPos);\n case '<':\n capture = namedCaptures[ch.slice(1, -1)];\n break;\n default: // \\d\\d?\n var n = +ch;\n if (n === 0) return match;\n if (n > m) {\n var f = floor(n / 10);\n if (f === 0) return match;\n if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);\n return match;\n }\n capture = captures[n - 1];\n }\n return capture === undefined ? '' : capture;\n });\n }\n});\n","'use strict';\n\nvar anObject = require('./_an-object');\nvar sameValue = require('./_same-value');\nvar regExpExec = require('./_regexp-exec-abstract');\n\n// @@search logic\nrequire('./_fix-re-wks')('search', 1, function (defined, SEARCH, $search, maybeCallNative) {\n return [\n // `String.prototype.search` method\n // https://tc39.github.io/ecma262/#sec-string.prototype.search\n function search(regexp) {\n var O = defined(this);\n var fn = regexp == undefined ? undefined : regexp[SEARCH];\n return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O));\n },\n // `RegExp.prototype[@@search]` method\n // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@search\n function (regexp) {\n var res = maybeCallNative($search, regexp, this);\n if (res.done) return res.value;\n var rx = anObject(regexp);\n var S = String(this);\n var previousLastIndex = rx.lastIndex;\n if (!sameValue(previousLastIndex, 0)) rx.lastIndex = 0;\n var result = regExpExec(rx, S);\n if (!sameValue(rx.lastIndex, previousLastIndex)) rx.lastIndex = previousLastIndex;\n return result === null ? -1 : result.index;\n }\n ];\n});\n","'use strict';\n\nvar isRegExp = require('./_is-regexp');\nvar anObject = require('./_an-object');\nvar speciesConstructor = require('./_species-constructor');\nvar advanceStringIndex = require('./_advance-string-index');\nvar toLength = require('./_to-length');\nvar callRegExpExec = require('./_regexp-exec-abstract');\nvar regexpExec = require('./_regexp-exec');\nvar fails = require('./_fails');\nvar $min = Math.min;\nvar $push = [].push;\nvar $SPLIT = 'split';\nvar LENGTH = 'length';\nvar LAST_INDEX = 'lastIndex';\nvar MAX_UINT32 = 0xffffffff;\n\n// babel-minify transpiles RegExp('x', 'y') -> /x/y and it causes SyntaxError\nvar SUPPORTS_Y = !fails(function () { RegExp(MAX_UINT32, 'y'); });\n\n// @@split logic\nrequire('./_fix-re-wks')('split', 2, function (defined, SPLIT, $split, maybeCallNative) {\n var internalSplit;\n if (\n 'abbc'[$SPLIT](/(b)*/)[1] == 'c' ||\n 'test'[$SPLIT](/(?:)/, -1)[LENGTH] != 4 ||\n 'ab'[$SPLIT](/(?:ab)*/)[LENGTH] != 2 ||\n '.'[$SPLIT](/(.?)(.?)/)[LENGTH] != 4 ||\n '.'[$SPLIT](/()()/)[LENGTH] > 1 ||\n ''[$SPLIT](/.?/)[LENGTH]\n ) {\n // based on es5-shim implementation, need to rework it\n internalSplit = function (separator, limit) {\n var string = String(this);\n if (separator === undefined && limit === 0) return [];\n // If `separator` is not a regex, use native split\n if (!isRegExp(separator)) return $split.call(string, separator, limit);\n var output = [];\n var flags = (separator.ignoreCase ? 'i' : '') +\n (separator.multiline ? 'm' : '') +\n (separator.unicode ? 'u' : '') +\n (separator.sticky ? 'y' : '');\n var lastLastIndex = 0;\n var splitLimit = limit === undefined ? MAX_UINT32 : limit >>> 0;\n // Make `global` and avoid `lastIndex` issues by working with a copy\n var separatorCopy = new RegExp(separator.source, flags + 'g');\n var match, lastIndex, lastLength;\n while (match = regexpExec.call(separatorCopy, string)) {\n lastIndex = separatorCopy[LAST_INDEX];\n if (lastIndex > lastLastIndex) {\n output.push(string.slice(lastLastIndex, match.index));\n if (match[LENGTH] > 1 && match.index < string[LENGTH]) $push.apply(output, match.slice(1));\n lastLength = match[0][LENGTH];\n lastLastIndex = lastIndex;\n if (output[LENGTH] >= splitLimit) break;\n }\n if (separatorCopy[LAST_INDEX] === match.index) separatorCopy[LAST_INDEX]++; // Avoid an infinite loop\n }\n if (lastLastIndex === string[LENGTH]) {\n if (lastLength || !separatorCopy.test('')) output.push('');\n } else output.push(string.slice(lastLastIndex));\n return output[LENGTH] > splitLimit ? output.slice(0, splitLimit) : output;\n };\n // Chakra, V8\n } else if ('0'[$SPLIT](undefined, 0)[LENGTH]) {\n internalSplit = function (separator, limit) {\n return separator === undefined && limit === 0 ? [] : $split.call(this, separator, limit);\n };\n } else {\n internalSplit = $split;\n }\n\n return [\n // `String.prototype.split` method\n // https://tc39.github.io/ecma262/#sec-string.prototype.split\n function split(separator, limit) {\n var O = defined(this);\n var splitter = separator == undefined ? undefined : separator[SPLIT];\n return splitter !== undefined\n ? splitter.call(separator, O, limit)\n : internalSplit.call(String(O), separator, limit);\n },\n // `RegExp.prototype[@@split]` method\n // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@split\n //\n // NOTE: This cannot be properly polyfilled in engines that don't support\n // the 'y' flag.\n function (regexp, limit) {\n var res = maybeCallNative(internalSplit, regexp, this, limit, internalSplit !== $split);\n if (res.done) return res.value;\n\n var rx = anObject(regexp);\n var S = String(this);\n var C = speciesConstructor(rx, RegExp);\n\n var unicodeMatching = rx.unicode;\n var flags = (rx.ignoreCase ? 'i' : '') +\n (rx.multiline ? 'm' : '') +\n (rx.unicode ? 'u' : '') +\n (SUPPORTS_Y ? 'y' : 'g');\n\n // ^(? + rx + ) is needed, in combination with some S slicing, to\n // simulate the 'y' flag.\n var splitter = new C(SUPPORTS_Y ? rx : '^(?:' + rx.source + ')', flags);\n var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;\n if (lim === 0) return [];\n if (S.length === 0) return callRegExpExec(splitter, S) === null ? [S] : [];\n var p = 0;\n var q = 0;\n var A = [];\n while (q < S.length) {\n splitter.lastIndex = SUPPORTS_Y ? q : 0;\n var z = callRegExpExec(splitter, SUPPORTS_Y ? S : S.slice(q));\n var e;\n if (\n z === null ||\n (e = $min(toLength(splitter.lastIndex + (SUPPORTS_Y ? 0 : q)), S.length)) === p\n ) {\n q = advanceStringIndex(S, q, unicodeMatching);\n } else {\n A.push(S.slice(p, q));\n if (A.length === lim) return A;\n for (var i = 1; i <= z.length - 1; i++) {\n A.push(z[i]);\n if (A.length === lim) return A;\n }\n q = p = e;\n }\n }\n A.push(S.slice(p));\n return A;\n }\n ];\n});\n","'use strict';\nrequire('./es6.regexp.flags');\nvar anObject = require('./_an-object');\nvar $flags = require('./_flags');\nvar DESCRIPTORS = require('./_descriptors');\nvar TO_STRING = 'toString';\nvar $toString = /./[TO_STRING];\n\nvar define = function (fn) {\n require('./_redefine')(RegExp.prototype, TO_STRING, fn, true);\n};\n\n// 21.2.5.14 RegExp.prototype.toString()\nif (require('./_fails')(function () { return $toString.call({ source: 'a', flags: 'b' }) != '/a/b'; })) {\n define(function toString() {\n var R = anObject(this);\n return '/'.concat(R.source, '/',\n 'flags' in R ? R.flags : !DESCRIPTORS && R instanceof RegExp ? $flags.call(R) : undefined);\n });\n// FF44- RegExp#toString has a wrong name\n} else if ($toString.name != TO_STRING) {\n define(function toString() {\n return $toString.call(this);\n });\n}\n","'use strict';\nvar strong = require('./_collection-strong');\nvar validate = require('./_validate-collection');\nvar SET = 'Set';\n\n// 23.2 Set Objects\nmodule.exports = require('./_collection')(SET, function (get) {\n return function Set() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };\n}, {\n // 23.2.3.1 Set.prototype.add(value)\n add: function add(value) {\n return strong.def(validate(this, SET), value = value === 0 ? 0 : value, value);\n }\n}, strong);\n","'use strict';\n// B.2.3.2 String.prototype.anchor(name)\nrequire('./_string-html')('anchor', function (createHTML) {\n return function anchor(name) {\n return createHTML(this, 'a', 'name', name);\n };\n});\n","'use strict';\n// B.2.3.3 String.prototype.big()\nrequire('./_string-html')('big', function (createHTML) {\n return function big() {\n return createHTML(this, 'big', '', '');\n };\n});\n","'use strict';\n// B.2.3.4 String.prototype.blink()\nrequire('./_string-html')('blink', function (createHTML) {\n return function blink() {\n return createHTML(this, 'blink', '', '');\n };\n});\n","'use strict';\n// B.2.3.5 String.prototype.bold()\nrequire('./_string-html')('bold', function (createHTML) {\n return function bold() {\n return createHTML(this, 'b', '', '');\n };\n});\n","'use strict';\nvar $export = require('./_export');\nvar $at = require('./_string-at')(false);\n$export($export.P, 'String', {\n // 21.1.3.3 String.prototype.codePointAt(pos)\n codePointAt: function codePointAt(pos) {\n return $at(this, pos);\n }\n});\n","// 21.1.3.6 String.prototype.endsWith(searchString [, endPosition])\n'use strict';\nvar $export = require('./_export');\nvar toLength = require('./_to-length');\nvar context = require('./_string-context');\nvar ENDS_WITH = 'endsWith';\nvar $endsWith = ''[ENDS_WITH];\n\n$export($export.P + $export.F * require('./_fails-is-regexp')(ENDS_WITH), 'String', {\n endsWith: function endsWith(searchString /* , endPosition = @length */) {\n var that = context(this, searchString, ENDS_WITH);\n var endPosition = arguments.length > 1 ? arguments[1] : undefined;\n var len = toLength(that.length);\n var end = endPosition === undefined ? len : Math.min(toLength(endPosition), len);\n var search = String(searchString);\n return $endsWith\n ? $endsWith.call(that, search, end)\n : that.slice(end - search.length, end) === search;\n }\n});\n","'use strict';\n// B.2.3.6 String.prototype.fixed()\nrequire('./_string-html')('fixed', function (createHTML) {\n return function fixed() {\n return createHTML(this, 'tt', '', '');\n };\n});\n","'use strict';\n// B.2.3.7 String.prototype.fontcolor(color)\nrequire('./_string-html')('fontcolor', function (createHTML) {\n return function fontcolor(color) {\n return createHTML(this, 'font', 'color', color);\n };\n});\n","'use strict';\n// B.2.3.8 String.prototype.fontsize(size)\nrequire('./_string-html')('fontsize', function (createHTML) {\n return function fontsize(size) {\n return createHTML(this, 'font', 'size', size);\n };\n});\n","var $export = require('./_export');\nvar toAbsoluteIndex = require('./_to-absolute-index');\nvar fromCharCode = String.fromCharCode;\nvar $fromCodePoint = String.fromCodePoint;\n\n// length should be 1, old FF problem\n$export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {\n // 21.1.2.2 String.fromCodePoint(...codePoints)\n fromCodePoint: function fromCodePoint(x) { // eslint-disable-line no-unused-vars\n var res = [];\n var aLen = arguments.length;\n var i = 0;\n var code;\n while (aLen > i) {\n code = +arguments[i++];\n if (toAbsoluteIndex(code, 0x10ffff) !== code) throw RangeError(code + ' is not a valid code point');\n res.push(code < 0x10000\n ? fromCharCode(code)\n : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)\n );\n } return res.join('');\n }\n});\n","// 21.1.3.7 String.prototype.includes(searchString, position = 0)\n'use strict';\nvar $export = require('./_export');\nvar context = require('./_string-context');\nvar INCLUDES = 'includes';\n\n$export($export.P + $export.F * require('./_fails-is-regexp')(INCLUDES), 'String', {\n includes: function includes(searchString /* , position = 0 */) {\n return !!~context(this, searchString, INCLUDES)\n .indexOf(searchString, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n","'use strict';\n// B.2.3.9 String.prototype.italics()\nrequire('./_string-html')('italics', function (createHTML) {\n return function italics() {\n return createHTML(this, 'i', '', '');\n };\n});\n","'use strict';\nvar $at = require('./_string-at')(true);\n\n// 21.1.3.27 String.prototype[@@iterator]()\nrequire('./_iter-define')(String, 'String', function (iterated) {\n this._t = String(iterated); // target\n this._i = 0; // next index\n// 21.1.5.2.1 %StringIteratorPrototype%.next()\n}, function () {\n var O = this._t;\n var index = this._i;\n var point;\n if (index >= O.length) return { value: undefined, done: true };\n point = $at(O, index);\n this._i += point.length;\n return { value: point, done: false };\n});\n","'use strict';\n// B.2.3.10 String.prototype.link(url)\nrequire('./_string-html')('link', function (createHTML) {\n return function link(url) {\n return createHTML(this, 'a', 'href', url);\n };\n});\n","var $export = require('./_export');\nvar toIObject = require('./_to-iobject');\nvar toLength = require('./_to-length');\n\n$export($export.S, 'String', {\n // 21.1.2.4 String.raw(callSite, ...substitutions)\n raw: function raw(callSite) {\n var tpl = toIObject(callSite.raw);\n var len = toLength(tpl.length);\n var aLen = arguments.length;\n var res = [];\n var i = 0;\n while (len > i) {\n res.push(String(tpl[i++]));\n if (i < aLen) res.push(String(arguments[i]));\n } return res.join('');\n }\n});\n","var $export = require('./_export');\n\n$export($export.P, 'String', {\n // 21.1.3.13 String.prototype.repeat(count)\n repeat: require('./_string-repeat')\n});\n","'use strict';\n// B.2.3.11 String.prototype.small()\nrequire('./_string-html')('small', function (createHTML) {\n return function small() {\n return createHTML(this, 'small', '', '');\n };\n});\n","// 21.1.3.18 String.prototype.startsWith(searchString [, position ])\n'use strict';\nvar $export = require('./_export');\nvar toLength = require('./_to-length');\nvar context = require('./_string-context');\nvar STARTS_WITH = 'startsWith';\nvar $startsWith = ''[STARTS_WITH];\n\n$export($export.P + $export.F * require('./_fails-is-regexp')(STARTS_WITH), 'String', {\n startsWith: function startsWith(searchString /* , position = 0 */) {\n var that = context(this, searchString, STARTS_WITH);\n var index = toLength(Math.min(arguments.length > 1 ? arguments[1] : undefined, that.length));\n var search = String(searchString);\n return $startsWith\n ? $startsWith.call(that, search, index)\n : that.slice(index, index + search.length) === search;\n }\n});\n","'use strict';\n// B.2.3.12 String.prototype.strike()\nrequire('./_string-html')('strike', function (createHTML) {\n return function strike() {\n return createHTML(this, 'strike', '', '');\n };\n});\n","'use strict';\n// B.2.3.13 String.prototype.sub()\nrequire('./_string-html')('sub', function (createHTML) {\n return function sub() {\n return createHTML(this, 'sub', '', '');\n };\n});\n","'use strict';\n// B.2.3.14 String.prototype.sup()\nrequire('./_string-html')('sup', function (createHTML) {\n return function sup() {\n return createHTML(this, 'sup', '', '');\n };\n});\n","'use strict';\n// 21.1.3.25 String.prototype.trim()\nrequire('./_string-trim')('trim', function ($trim) {\n return function trim() {\n return $trim(this, 3);\n };\n});\n","'use strict';\n// ECMAScript 6 symbols shim\nvar global = require('./_global');\nvar has = require('./_has');\nvar DESCRIPTORS = require('./_descriptors');\nvar $export = require('./_export');\nvar redefine = require('./_redefine');\nvar META = require('./_meta').KEY;\nvar $fails = require('./_fails');\nvar shared = require('./_shared');\nvar setToStringTag = require('./_set-to-string-tag');\nvar uid = require('./_uid');\nvar wks = require('./_wks');\nvar wksExt = require('./_wks-ext');\nvar wksDefine = require('./_wks-define');\nvar enumKeys = require('./_enum-keys');\nvar isArray = require('./_is-array');\nvar anObject = require('./_an-object');\nvar isObject = require('./_is-object');\nvar toObject = require('./_to-object');\nvar toIObject = require('./_to-iobject');\nvar toPrimitive = require('./_to-primitive');\nvar createDesc = require('./_property-desc');\nvar _create = require('./_object-create');\nvar gOPNExt = require('./_object-gopn-ext');\nvar $GOPD = require('./_object-gopd');\nvar $GOPS = require('./_object-gops');\nvar $DP = require('./_object-dp');\nvar $keys = require('./_object-keys');\nvar gOPD = $GOPD.f;\nvar dP = $DP.f;\nvar gOPN = gOPNExt.f;\nvar $Symbol = global.Symbol;\nvar $JSON = global.JSON;\nvar _stringify = $JSON && $JSON.stringify;\nvar PROTOTYPE = 'prototype';\nvar HIDDEN = wks('_hidden');\nvar TO_PRIMITIVE = wks('toPrimitive');\nvar isEnum = {}.propertyIsEnumerable;\nvar SymbolRegistry = shared('symbol-registry');\nvar AllSymbols = shared('symbols');\nvar OPSymbols = shared('op-symbols');\nvar ObjectProto = Object[PROTOTYPE];\nvar USE_NATIVE = typeof $Symbol == 'function' && !!$GOPS.f;\nvar QObject = global.QObject;\n// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173\nvar setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;\n\n// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687\nvar setSymbolDesc = DESCRIPTORS && $fails(function () {\n return _create(dP({}, 'a', {\n get: function () { return dP(this, 'a', { value: 7 }).a; }\n })).a != 7;\n}) ? function (it, key, D) {\n var protoDesc = gOPD(ObjectProto, key);\n if (protoDesc) delete ObjectProto[key];\n dP(it, key, D);\n if (protoDesc && it !== ObjectProto) dP(ObjectProto, key, protoDesc);\n} : dP;\n\nvar wrap = function (tag) {\n var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);\n sym._k = tag;\n return sym;\n};\n\nvar isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function (it) {\n return typeof it == 'symbol';\n} : function (it) {\n return it instanceof $Symbol;\n};\n\nvar $defineProperty = function defineProperty(it, key, D) {\n if (it === ObjectProto) $defineProperty(OPSymbols, key, D);\n anObject(it);\n key = toPrimitive(key, true);\n anObject(D);\n if (has(AllSymbols, key)) {\n if (!D.enumerable) {\n if (!has(it, HIDDEN)) dP(it, HIDDEN, createDesc(1, {}));\n it[HIDDEN][key] = true;\n } else {\n if (has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false;\n D = _create(D, { enumerable: createDesc(0, false) });\n } return setSymbolDesc(it, key, D);\n } return dP(it, key, D);\n};\nvar $defineProperties = function defineProperties(it, P) {\n anObject(it);\n var keys = enumKeys(P = toIObject(P));\n var i = 0;\n var l = keys.length;\n var key;\n while (l > i) $defineProperty(it, key = keys[i++], P[key]);\n return it;\n};\nvar $create = function create(it, P) {\n return P === undefined ? _create(it) : $defineProperties(_create(it), P);\n};\nvar $propertyIsEnumerable = function propertyIsEnumerable(key) {\n var E = isEnum.call(this, key = toPrimitive(key, true));\n if (this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return false;\n return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;\n};\nvar $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {\n it = toIObject(it);\n key = toPrimitive(key, true);\n if (it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return;\n var D = gOPD(it, key);\n if (D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true;\n return D;\n};\nvar $getOwnPropertyNames = function getOwnPropertyNames(it) {\n var names = gOPN(toIObject(it));\n var result = [];\n var i = 0;\n var key;\n while (names.length > i) {\n if (!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key);\n } return result;\n};\nvar $getOwnPropertySymbols = function getOwnPropertySymbols(it) {\n var IS_OP = it === ObjectProto;\n var names = gOPN(IS_OP ? OPSymbols : toIObject(it));\n var result = [];\n var i = 0;\n var key;\n while (names.length > i) {\n if (has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true)) result.push(AllSymbols[key]);\n } return result;\n};\n\n// 19.4.1.1 Symbol([description])\nif (!USE_NATIVE) {\n $Symbol = function Symbol() {\n if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!');\n var tag = uid(arguments.length > 0 ? arguments[0] : undefined);\n var $set = function (value) {\n if (this === ObjectProto) $set.call(OPSymbols, value);\n if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;\n setSymbolDesc(this, tag, createDesc(1, value));\n };\n if (DESCRIPTORS && setter) setSymbolDesc(ObjectProto, tag, { configurable: true, set: $set });\n return wrap(tag);\n };\n redefine($Symbol[PROTOTYPE], 'toString', function toString() {\n return this._k;\n });\n\n $GOPD.f = $getOwnPropertyDescriptor;\n $DP.f = $defineProperty;\n require('./_object-gopn').f = gOPNExt.f = $getOwnPropertyNames;\n require('./_object-pie').f = $propertyIsEnumerable;\n $GOPS.f = $getOwnPropertySymbols;\n\n if (DESCRIPTORS && !require('./_library')) {\n redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);\n }\n\n wksExt.f = function (name) {\n return wrap(wks(name));\n };\n}\n\n$export($export.G + $export.W + $export.F * !USE_NATIVE, { Symbol: $Symbol });\n\nfor (var es6Symbols = (\n // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14\n 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'\n).split(','), j = 0; es6Symbols.length > j;)wks(es6Symbols[j++]);\n\nfor (var wellKnownSymbols = $keys(wks.store), k = 0; wellKnownSymbols.length > k;) wksDefine(wellKnownSymbols[k++]);\n\n$export($export.S + $export.F * !USE_NATIVE, 'Symbol', {\n // 19.4.2.1 Symbol.for(key)\n 'for': function (key) {\n return has(SymbolRegistry, key += '')\n ? SymbolRegistry[key]\n : SymbolRegistry[key] = $Symbol(key);\n },\n // 19.4.2.5 Symbol.keyFor(sym)\n keyFor: function keyFor(sym) {\n if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!');\n for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key;\n },\n useSetter: function () { setter = true; },\n useSimple: function () { setter = false; }\n});\n\n$export($export.S + $export.F * !USE_NATIVE, 'Object', {\n // 19.1.2.2 Object.create(O [, Properties])\n create: $create,\n // 19.1.2.4 Object.defineProperty(O, P, Attributes)\n defineProperty: $defineProperty,\n // 19.1.2.3 Object.defineProperties(O, Properties)\n defineProperties: $defineProperties,\n // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)\n getOwnPropertyDescriptor: $getOwnPropertyDescriptor,\n // 19.1.2.7 Object.getOwnPropertyNames(O)\n getOwnPropertyNames: $getOwnPropertyNames,\n // 19.1.2.8 Object.getOwnPropertySymbols(O)\n getOwnPropertySymbols: $getOwnPropertySymbols\n});\n\n// Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives\n// https://bugs.chromium.org/p/v8/issues/detail?id=3443\nvar FAILS_ON_PRIMITIVES = $fails(function () { $GOPS.f(1); });\n\n$export($export.S + $export.F * FAILS_ON_PRIMITIVES, 'Object', {\n getOwnPropertySymbols: function getOwnPropertySymbols(it) {\n return $GOPS.f(toObject(it));\n }\n});\n\n// 24.3.2 JSON.stringify(value [, replacer [, space]])\n$JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function () {\n var S = $Symbol();\n // MS Edge converts symbol values to JSON as {}\n // WebKit converts symbol values to JSON as null\n // V8 throws on boxed symbols\n return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}';\n})), 'JSON', {\n stringify: function stringify(it) {\n var args = [it];\n var i = 1;\n var replacer, $replacer;\n while (arguments.length > i) args.push(arguments[i++]);\n $replacer = replacer = args[1];\n if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined\n if (!isArray(replacer)) replacer = function (key, value) {\n if (typeof $replacer == 'function') value = $replacer.call(this, key, value);\n if (!isSymbol(value)) return value;\n };\n args[1] = replacer;\n return _stringify.apply($JSON, args);\n }\n});\n\n// 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)\n$Symbol[PROTOTYPE][TO_PRIMITIVE] || require('./_hide')($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);\n// 19.4.3.5 Symbol.prototype[@@toStringTag]\nsetToStringTag($Symbol, 'Symbol');\n// 20.2.1.9 Math[@@toStringTag]\nsetToStringTag(Math, 'Math', true);\n// 24.3.3 JSON[@@toStringTag]\nsetToStringTag(global.JSON, 'JSON', true);\n","'use strict';\nvar $export = require('./_export');\nvar $typed = require('./_typed');\nvar buffer = require('./_typed-buffer');\nvar anObject = require('./_an-object');\nvar toAbsoluteIndex = require('./_to-absolute-index');\nvar toLength = require('./_to-length');\nvar isObject = require('./_is-object');\nvar ArrayBuffer = require('./_global').ArrayBuffer;\nvar speciesConstructor = require('./_species-constructor');\nvar $ArrayBuffer = buffer.ArrayBuffer;\nvar $DataView = buffer.DataView;\nvar $isView = $typed.ABV && ArrayBuffer.isView;\nvar $slice = $ArrayBuffer.prototype.slice;\nvar VIEW = $typed.VIEW;\nvar ARRAY_BUFFER = 'ArrayBuffer';\n\n$export($export.G + $export.W + $export.F * (ArrayBuffer !== $ArrayBuffer), { ArrayBuffer: $ArrayBuffer });\n\n$export($export.S + $export.F * !$typed.CONSTR, ARRAY_BUFFER, {\n // 24.1.3.1 ArrayBuffer.isView(arg)\n isView: function isView(it) {\n return $isView && $isView(it) || isObject(it) && VIEW in it;\n }\n});\n\n$export($export.P + $export.U + $export.F * require('./_fails')(function () {\n return !new $ArrayBuffer(2).slice(1, undefined).byteLength;\n}), ARRAY_BUFFER, {\n // 24.1.4.3 ArrayBuffer.prototype.slice(start, end)\n slice: function slice(start, end) {\n if ($slice !== undefined && end === undefined) return $slice.call(anObject(this), start); // FF fix\n var len = anObject(this).byteLength;\n var first = toAbsoluteIndex(start, len);\n var fin = toAbsoluteIndex(end === undefined ? len : end, len);\n var result = new (speciesConstructor(this, $ArrayBuffer))(toLength(fin - first));\n var viewS = new $DataView(this);\n var viewT = new $DataView(result);\n var index = 0;\n while (first < fin) {\n viewT.setUint8(index++, viewS.getUint8(first++));\n } return result;\n }\n});\n\nrequire('./_set-species')(ARRAY_BUFFER);\n","var $export = require('./_export');\n$export($export.G + $export.W + $export.F * !require('./_typed').ABV, {\n DataView: require('./_typed-buffer').DataView\n});\n","require('./_typed-array')('Float32', 4, function (init) {\n return function Float32Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","require('./_typed-array')('Float64', 8, function (init) {\n return function Float64Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","require('./_typed-array')('Int16', 2, function (init) {\n return function Int16Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","require('./_typed-array')('Int32', 4, function (init) {\n return function Int32Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","require('./_typed-array')('Int8', 1, function (init) {\n return function Int8Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","require('./_typed-array')('Uint16', 2, function (init) {\n return function Uint16Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","require('./_typed-array')('Uint32', 4, function (init) {\n return function Uint32Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","require('./_typed-array')('Uint8', 1, function (init) {\n return function Uint8Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","require('./_typed-array')('Uint8', 1, function (init) {\n return function Uint8ClampedArray(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n}, true);\n","'use strict';\nvar global = require('./_global');\nvar each = require('./_array-methods')(0);\nvar redefine = require('./_redefine');\nvar meta = require('./_meta');\nvar assign = require('./_object-assign');\nvar weak = require('./_collection-weak');\nvar isObject = require('./_is-object');\nvar validate = require('./_validate-collection');\nvar NATIVE_WEAK_MAP = require('./_validate-collection');\nvar IS_IE11 = !global.ActiveXObject && 'ActiveXObject' in global;\nvar WEAK_MAP = 'WeakMap';\nvar getWeak = meta.getWeak;\nvar isExtensible = Object.isExtensible;\nvar uncaughtFrozenStore = weak.ufstore;\nvar InternalMap;\n\nvar wrapper = function (get) {\n return function WeakMap() {\n return get(this, arguments.length > 0 ? arguments[0] : undefined);\n };\n};\n\nvar methods = {\n // 23.3.3.3 WeakMap.prototype.get(key)\n get: function get(key) {\n if (isObject(key)) {\n var data = getWeak(key);\n if (data === true) return uncaughtFrozenStore(validate(this, WEAK_MAP)).get(key);\n return data ? data[this._i] : undefined;\n }\n },\n // 23.3.3.5 WeakMap.prototype.set(key, value)\n set: function set(key, value) {\n return weak.def(validate(this, WEAK_MAP), key, value);\n }\n};\n\n// 23.3 WeakMap Objects\nvar $WeakMap = module.exports = require('./_collection')(WEAK_MAP, wrapper, methods, weak, true, true);\n\n// IE11 WeakMap frozen keys fix\nif (NATIVE_WEAK_MAP && IS_IE11) {\n InternalMap = weak.getConstructor(wrapper, WEAK_MAP);\n assign(InternalMap.prototype, methods);\n meta.NEED = true;\n each(['delete', 'has', 'get', 'set'], function (key) {\n var proto = $WeakMap.prototype;\n var method = proto[key];\n redefine(proto, key, function (a, b) {\n // store frozen objects on internal weakmap shim\n if (isObject(a) && !isExtensible(a)) {\n if (!this._f) this._f = new InternalMap();\n var result = this._f[key](a, b);\n return key == 'set' ? this : result;\n // store all the rest on native weakmap\n } return method.call(this, a, b);\n });\n });\n}\n","'use strict';\nvar weak = require('./_collection-weak');\nvar validate = require('./_validate-collection');\nvar WEAK_SET = 'WeakSet';\n\n// 23.4 WeakSet Objects\nrequire('./_collection')(WEAK_SET, function (get) {\n return function WeakSet() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };\n}, {\n // 23.4.3.1 WeakSet.prototype.add(value)\n add: function add(value) {\n return weak.def(validate(this, WEAK_SET), value, true);\n }\n}, weak, false, true);\n","'use strict';\n// https://tc39.github.io/proposal-flatMap/#sec-Array.prototype.flatMap\nvar $export = require('./_export');\nvar flattenIntoArray = require('./_flatten-into-array');\nvar toObject = require('./_to-object');\nvar toLength = require('./_to-length');\nvar aFunction = require('./_a-function');\nvar arraySpeciesCreate = require('./_array-species-create');\n\n$export($export.P, 'Array', {\n flatMap: function flatMap(callbackfn /* , thisArg */) {\n var O = toObject(this);\n var sourceLen, A;\n aFunction(callbackfn);\n sourceLen = toLength(O.length);\n A = arraySpeciesCreate(O, 0);\n flattenIntoArray(A, O, O, sourceLen, 0, 1, callbackfn, arguments[1]);\n return A;\n }\n});\n\nrequire('./_add-to-unscopables')('flatMap');\n","'use strict';\n// https://github.com/tc39/Array.prototype.includes\nvar $export = require('./_export');\nvar $includes = require('./_array-includes')(true);\n\n$export($export.P, 'Array', {\n includes: function includes(el /* , fromIndex = 0 */) {\n return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n\nrequire('./_add-to-unscopables')('includes');\n","// https://github.com/tc39/proposal-object-values-entries\nvar $export = require('./_export');\nvar $entries = require('./_object-to-array')(true);\n\n$export($export.S, 'Object', {\n entries: function entries(it) {\n return $entries(it);\n }\n});\n","// https://github.com/tc39/proposal-object-getownpropertydescriptors\nvar $export = require('./_export');\nvar ownKeys = require('./_own-keys');\nvar toIObject = require('./_to-iobject');\nvar gOPD = require('./_object-gopd');\nvar createProperty = require('./_create-property');\n\n$export($export.S, 'Object', {\n getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) {\n var O = toIObject(object);\n var getDesc = gOPD.f;\n var keys = ownKeys(O);\n var result = {};\n var i = 0;\n var key, desc;\n while (keys.length > i) {\n desc = getDesc(O, key = keys[i++]);\n if (desc !== undefined) createProperty(result, key, desc);\n }\n return result;\n }\n});\n","// https://github.com/tc39/proposal-object-values-entries\nvar $export = require('./_export');\nvar $values = require('./_object-to-array')(false);\n\n$export($export.S, 'Object', {\n values: function values(it) {\n return $values(it);\n }\n});\n","// https://github.com/tc39/proposal-promise-finally\n'use strict';\nvar $export = require('./_export');\nvar core = require('./_core');\nvar global = require('./_global');\nvar speciesConstructor = require('./_species-constructor');\nvar promiseResolve = require('./_promise-resolve');\n\n$export($export.P + $export.R, 'Promise', { 'finally': function (onFinally) {\n var C = speciesConstructor(this, core.Promise || global.Promise);\n var isFunction = typeof onFinally == 'function';\n return this.then(\n isFunction ? function (x) {\n return promiseResolve(C, onFinally()).then(function () { return x; });\n } : onFinally,\n isFunction ? function (e) {\n return promiseResolve(C, onFinally()).then(function () { throw e; });\n } : onFinally\n );\n} });\n","'use strict';\n// https://github.com/tc39/proposal-string-pad-start-end\nvar $export = require('./_export');\nvar $pad = require('./_string-pad');\nvar userAgent = require('./_user-agent');\n\n// https://github.com/zloirock/core-js/issues/280\nvar WEBKIT_BUG = /Version\\/10\\.\\d+(\\.\\d+)?( Mobile\\/\\w+)? Safari\\//.test(userAgent);\n\n$export($export.P + $export.F * WEBKIT_BUG, 'String', {\n padEnd: function padEnd(maxLength /* , fillString = ' ' */) {\n return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, false);\n }\n});\n","'use strict';\n// https://github.com/tc39/proposal-string-pad-start-end\nvar $export = require('./_export');\nvar $pad = require('./_string-pad');\nvar userAgent = require('./_user-agent');\n\n// https://github.com/zloirock/core-js/issues/280\nvar WEBKIT_BUG = /Version\\/10\\.\\d+(\\.\\d+)?( Mobile\\/\\w+)? Safari\\//.test(userAgent);\n\n$export($export.P + $export.F * WEBKIT_BUG, 'String', {\n padStart: function padStart(maxLength /* , fillString = ' ' */) {\n return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, true);\n }\n});\n","'use strict';\n// https://github.com/sebmarkbage/ecmascript-string-left-right-trim\nrequire('./_string-trim')('trimLeft', function ($trim) {\n return function trimLeft() {\n return $trim(this, 1);\n };\n}, 'trimStart');\n","'use strict';\n// https://github.com/sebmarkbage/ecmascript-string-left-right-trim\nrequire('./_string-trim')('trimRight', function ($trim) {\n return function trimRight() {\n return $trim(this, 2);\n };\n}, 'trimEnd');\n","require('./_wks-define')('asyncIterator');\n","var $iterators = require('./es6.array.iterator');\nvar getKeys = require('./_object-keys');\nvar redefine = require('./_redefine');\nvar global = require('./_global');\nvar hide = require('./_hide');\nvar Iterators = require('./_iterators');\nvar wks = require('./_wks');\nvar ITERATOR = wks('iterator');\nvar TO_STRING_TAG = wks('toStringTag');\nvar ArrayValues = Iterators.Array;\n\nvar DOMIterables = {\n CSSRuleList: true, // TODO: Not spec compliant, should be false.\n CSSStyleDeclaration: false,\n CSSValueList: false,\n ClientRectList: false,\n DOMRectList: false,\n DOMStringList: false,\n DOMTokenList: true,\n DataTransferItemList: false,\n FileList: false,\n HTMLAllCollection: false,\n HTMLCollection: false,\n HTMLFormElement: false,\n HTMLSelectElement: false,\n MediaList: true, // TODO: Not spec compliant, should be false.\n MimeTypeArray: false,\n NamedNodeMap: false,\n NodeList: true,\n PaintRequestList: false,\n Plugin: false,\n PluginArray: false,\n SVGLengthList: false,\n SVGNumberList: false,\n SVGPathSegList: false,\n SVGPointList: false,\n SVGStringList: false,\n SVGTransformList: false,\n SourceBufferList: false,\n StyleSheetList: true, // TODO: Not spec compliant, should be false.\n TextTrackCueList: false,\n TextTrackList: false,\n TouchList: false\n};\n\nfor (var collections = getKeys(DOMIterables), i = 0; i < collections.length; i++) {\n var NAME = collections[i];\n var explicit = DOMIterables[NAME];\n var Collection = global[NAME];\n var proto = Collection && Collection.prototype;\n var key;\n if (proto) {\n if (!proto[ITERATOR]) hide(proto, ITERATOR, ArrayValues);\n if (!proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME);\n Iterators[NAME] = ArrayValues;\n if (explicit) for (key in $iterators) if (!proto[key]) redefine(proto, key, $iterators[key], true);\n }\n}\n","var $export = require('./_export');\nvar $task = require('./_task');\n$export($export.G + $export.B, {\n setImmediate: $task.set,\n clearImmediate: $task.clear\n});\n","// ie9- setTimeout & setInterval additional parameters fix\nvar global = require('./_global');\nvar $export = require('./_export');\nvar userAgent = require('./_user-agent');\nvar slice = [].slice;\nvar MSIE = /MSIE .\\./.test(userAgent); // <- dirty ie9- check\nvar wrap = function (set) {\n return function (fn, time /* , ...args */) {\n var boundArgs = arguments.length > 2;\n var args = boundArgs ? slice.call(arguments, 2) : false;\n return set(boundArgs ? function () {\n // eslint-disable-next-line no-new-func\n (typeof fn == 'function' ? fn : Function(fn)).apply(this, args);\n } : fn, time);\n };\n};\n$export($export.G + $export.B + $export.F * MSIE, {\n setTimeout: wrap(global.setTimeout),\n setInterval: wrap(global.setInterval)\n});\n","require('../modules/web.timers');\nrequire('../modules/web.immediate');\nrequire('../modules/web.dom.iterable');\nmodule.exports = require('../modules/_core');\n","/**\n@license\nCopyright (c) 2019 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at\nhttp://polymer.github.io/LICENSE.txt The complete set of authors may be found at\nhttp://polymer.github.io/AUTHORS.txt The complete set of contributors may be\nfound at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as\npart of the polymer project is also subject to an additional IP rights grant\nfound at http://polymer.github.io/PATENTS.txt\n*/\n\nexport const supportsAdoptingStyleSheets =\n ('adoptedStyleSheets' in Document.prototype) &&\n ('replace' in CSSStyleSheet.prototype);\n\nconst constructionToken = Symbol();\n\nexport class CSSResult {\n _styleSheet?: CSSStyleSheet|null;\n\n readonly cssText: string;\n\n constructor(cssText: string, safeToken: symbol) {\n if (safeToken !== constructionToken) {\n throw new Error(\n 'CSSResult is not constructable. Use `unsafeCSS` or `css` instead.');\n }\n this.cssText = cssText;\n }\n\n // Note, this is a getter so that it's lazy. In practice, this means\n // stylesheets are not created until the first element instance is made.\n get styleSheet(): CSSStyleSheet|null {\n if (this._styleSheet === undefined) {\n // Note, if `adoptedStyleSheets` is supported then we assume CSSStyleSheet\n // is constructable.\n if (supportsAdoptingStyleSheets) {\n this._styleSheet = new CSSStyleSheet();\n this._styleSheet.replaceSync(this.cssText);\n } else {\n this._styleSheet = null;\n }\n }\n return this._styleSheet;\n }\n\n toString(): string {\n return this.cssText;\n }\n}\n\n/**\n * Wrap a value for interpolation in a css tagged template literal.\n *\n * This is unsafe because untrusted CSS text can be used to phone home\n * or exfiltrate data to an attacker controlled site. Take care to only use\n * this with trusted input.\n */\nexport const unsafeCSS = (value: unknown) => {\n return new CSSResult(String(value), constructionToken);\n};\n\nconst textFromCSSResult = (value: CSSResult|number) => {\n if (value instanceof CSSResult) {\n return value.cssText;\n } else if (typeof value === 'number') {\n return value;\n } else {\n throw new Error(\n `Value passed to 'css' function must be a 'css' function result: ${\n value}. Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security.`);\n }\n};\n\n/**\n * Template tag which which can be used with LitElement's `style` property to\n * set element styles. For security reasons, only literal string values may be\n * used. To incorporate non-literal values `unsafeCSS` may be used inside a\n * template string part.\n */\nexport const css =\n (strings: TemplateStringsArray, ...values: (CSSResult|number)[]) => {\n const cssText = values.reduce(\n (acc, v, idx) => acc + textFromCSSResult(v) + strings[idx + 1],\n strings[0]);\n return new CSSResult(cssText, constructionToken);\n };\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\nimport {LitElement} from '../lit-element.js';\n\nimport {PropertyDeclaration, UpdatingElement} from './updating-element.js';\n\nexport type Constructor = {\n new (...args: unknown[]): T\n};\n\n// From the TC39 Decorators proposal\ninterface ClassDescriptor {\n kind: 'class';\n elements: ClassElement[];\n finisher?: (clazz: Constructor) => undefined | Constructor;\n}\n\n// From the TC39 Decorators proposal\ninterface ClassElement {\n kind: 'field'|'method';\n key: PropertyKey;\n placement: 'static'|'prototype'|'own';\n initializer?: Function;\n extras?: ClassElement[];\n finisher?: (clazz: Constructor) => undefined | Constructor;\n descriptor?: PropertyDescriptor;\n}\n\nconst legacyCustomElement =\n (tagName: string, clazz: Constructor) => {\n window.customElements.define(tagName, clazz);\n // Cast as any because TS doesn't recognize the return type as being a\n // subtype of the decorated class when clazz is typed as\n // `Constructor` for some reason.\n // `Constructor` is helpful to make sure the decorator is\n // applied to elements however.\n // tslint:disable-next-line:no-any\n return clazz as any;\n };\n\nconst standardCustomElement =\n (tagName: string, descriptor: ClassDescriptor) => {\n const {kind, elements} = descriptor;\n return {\n kind,\n elements,\n // This callback is called once the class is otherwise fully defined\n finisher(clazz: Constructor) {\n window.customElements.define(tagName, clazz);\n }\n };\n };\n\n/**\n * Class decorator factory that defines the decorated class as a custom element.\n *\n * @param tagName the name of the custom element to define\n */\nexport const customElement = (tagName: string) =>\n (classOrDescriptor: Constructor|ClassDescriptor) =>\n (typeof classOrDescriptor === 'function') ?\n legacyCustomElement(tagName, classOrDescriptor) :\n standardCustomElement(tagName, classOrDescriptor);\n\nconst standardProperty =\n (options: PropertyDeclaration, element: ClassElement) => {\n // When decorating an accessor, pass it through and add property metadata.\n // Note, the `hasOwnProperty` check in `createProperty` ensures we don't\n // stomp over the user's accessor.\n if (element.kind === 'method' && element.descriptor &&\n !('value' in element.descriptor)) {\n return {\n ...element,\n finisher(clazz: typeof UpdatingElement) {\n clazz.createProperty(element.key, options);\n }\n };\n } else {\n // createProperty() takes care of defining the property, but we still\n // must return some kind of descriptor, so return a descriptor for an\n // unused prototype field. The finisher calls createProperty().\n return {\n kind: 'field',\n key: Symbol(),\n placement: 'own',\n descriptor: {},\n // When @babel/plugin-proposal-decorators implements initializers,\n // do this instead of the initializer below. See:\n // https://github.com/babel/babel/issues/9260 extras: [\n // {\n // kind: 'initializer',\n // placement: 'own',\n // initializer: descriptor.initializer,\n // }\n // ],\n initializer(this: {[key: string]: unknown}) {\n if (typeof element.initializer === 'function') {\n this[element.key as string] = element.initializer.call(this);\n }\n },\n finisher(clazz: typeof UpdatingElement) {\n clazz.createProperty(element.key, options);\n }\n };\n }\n };\n\nconst legacyProperty =\n (options: PropertyDeclaration, proto: Object, name: PropertyKey) => {\n (proto.constructor as typeof UpdatingElement)\n .createProperty(name, options);\n };\n\n/**\n * A property decorator which creates a LitElement property which reflects a\n * corresponding attribute value. A `PropertyDeclaration` may optionally be\n * supplied to configure property features.\n *\n * @ExportDecoratedItems\n */\nexport function property(options?: PropertyDeclaration) {\n // tslint:disable-next-line:no-any decorator\n return (protoOrDescriptor: Object|ClassElement, name?: PropertyKey): any =>\n (name !== undefined) ?\n legacyProperty(options!, protoOrDescriptor as Object, name) :\n standardProperty(options!, protoOrDescriptor as ClassElement);\n}\n\n/**\n * A property decorator that converts a class property into a getter that\n * executes a querySelector on the element's renderRoot.\n *\n * @ExportDecoratedItems\n */\nexport function query(selector: string) {\n return (protoOrDescriptor: Object|ClassElement,\n // tslint:disable-next-line:no-any decorator\n name?: PropertyKey): any => {\n const descriptor = {\n get(this: LitElement) {\n return this.renderRoot.querySelector(selector);\n },\n enumerable: true,\n configurable: true,\n };\n return (name !== undefined) ?\n legacyQuery(descriptor, protoOrDescriptor as Object, name) :\n standardQuery(descriptor, protoOrDescriptor as ClassElement);\n };\n}\n\n/**\n * A property decorator that converts a class property into a getter\n * that executes a querySelectorAll on the element's renderRoot.\n *\n * @ExportDecoratedItems\n */\nexport function queryAll(selector: string) {\n return (protoOrDescriptor: Object|ClassElement,\n // tslint:disable-next-line:no-any decorator\n name?: PropertyKey): any => {\n const descriptor = {\n get(this: LitElement) {\n return this.renderRoot.querySelectorAll(selector);\n },\n enumerable: true,\n configurable: true,\n };\n return (name !== undefined) ?\n legacyQuery(descriptor, protoOrDescriptor as Object, name) :\n standardQuery(descriptor, protoOrDescriptor as ClassElement);\n };\n}\n\nconst legacyQuery =\n (descriptor: PropertyDescriptor, proto: Object, name: PropertyKey) => {\n Object.defineProperty(proto, name, descriptor);\n };\n\nconst standardQuery = (descriptor: PropertyDescriptor, element: ClassElement) =>\n ({\n kind: 'method',\n placement: 'prototype',\n key: element.key,\n descriptor,\n });\n\nconst standardEventOptions =\n (options: AddEventListenerOptions, element: ClassElement) => {\n return {\n ...element,\n finisher(clazz: typeof UpdatingElement) {\n Object.assign(\n clazz.prototype[element.key as keyof UpdatingElement], options);\n }\n };\n };\n\nconst legacyEventOptions =\n // tslint:disable-next-line:no-any legacy decorator\n (options: AddEventListenerOptions, proto: any, name: PropertyKey) => {\n Object.assign(proto[name], options);\n };\n\n/**\n * Adds event listener options to a method used as an event listener in a\n * lit-html template.\n *\n * @param options An object that specifis event listener options as accepted by\n * `EventTarget#addEventListener` and `EventTarget#removeEventListener`.\n *\n * Current browsers support the `capture`, `passive`, and `once` options. See:\n * https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Parameters\n *\n * @example\n *\n * class MyElement {\n *\n * clicked = false;\n *\n * render() {\n * return html`
    `;\n * }\n *\n * @eventOptions({capture: true})\n * _onClick(e) {\n * this.clicked = true;\n * }\n * }\n */\nexport const eventOptions = (options: AddEventListenerOptions) =>\n // Return value typed as any to prevent TypeScript from complaining that\n // standard decorator function signature does not match TypeScript decorator\n // signature\n // TODO(kschaaf): unclear why it was only failing on this decorator and not\n // the others\n ((protoOrDescriptor: Object|ClassElement, name?: string) =>\n (name !== undefined) ?\n legacyEventOptions(options, protoOrDescriptor as Object, name) :\n standardEventOptions(options, protoOrDescriptor as ClassElement)) as\n // tslint:disable-next-line:no-any decorator\n any;\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\n/**\n * When using Closure Compiler, JSCompiler_renameProperty(property, object) is\n * replaced at compile time by the munged name for object[property]. We cannot\n * alias this function, so we have to use a small shim that has the same\n * behavior when not compiling.\n */\nwindow.JSCompiler_renameProperty =\n

    (prop: P, _obj: unknown): P => prop;\n\ndeclare global {\n var JSCompiler_renameProperty:

    (\n prop: P, _obj: unknown) => P;\n\n interface Window {\n JSCompiler_renameProperty: typeof JSCompiler_renameProperty;\n }\n}\n\n/**\n * Converts property values to and from attribute values.\n */\nexport interface ComplexAttributeConverter {\n /**\n * Function called to convert an attribute value to a property\n * value.\n */\n fromAttribute?(value: string|null, type?: TypeHint): Type;\n\n /**\n * Function called to convert a property value to an attribute\n * value.\n *\n * It returns unknown instead of string, to be compatible with\n * https://github.com/WICG/trusted-types (and similar efforts).\n */\n toAttribute?(value: Type, type?: TypeHint): unknown;\n}\n\ntype AttributeConverter =\n ComplexAttributeConverter|((value: string, type?: TypeHint) => Type);\n\n/**\n * Defines options for a property accessor.\n */\nexport interface PropertyDeclaration {\n /**\n * Indicates how and whether the property becomes an observed attribute.\n * If the value is `false`, the property is not added to `observedAttributes`.\n * If true or absent, the lowercased property name is observed (e.g. `fooBar`\n * becomes `foobar`). If a string, the string value is observed (e.g\n * `attribute: 'foo-bar'`).\n */\n readonly attribute?: boolean|string;\n\n /**\n * Indicates the type of the property. This is used only as a hint for the\n * `converter` to determine how to convert the attribute\n * to/from a property.\n */\n readonly type?: TypeHint;\n\n /**\n * Indicates how to convert the attribute to/from a property. If this value\n * is a function, it is used to convert the attribute value a the property\n * value. If it's an object, it can have keys for `fromAttribute` and\n * `toAttribute`. If no `toAttribute` function is provided and\n * `reflect` is set to `true`, the property value is set directly to the\n * attribute. A default `converter` is used if none is provided; it supports\n * `Boolean`, `String`, `Number`, `Object`, and `Array`. Note,\n * when a property changes and the converter is used to update the attribute,\n * the property is never updated again as a result of the attribute changing,\n * and vice versa.\n */\n readonly converter?: AttributeConverter;\n\n /**\n * Indicates if the property should reflect to an attribute.\n * If `true`, when the property is set, the attribute is set using the\n * attribute name determined according to the rules for the `attribute`\n * property option and the value of the property converted using the rules\n * from the `converter` property option.\n */\n readonly reflect?: boolean;\n\n /**\n * A function that indicates if a property should be considered changed when\n * it is set. The function should take the `newValue` and `oldValue` and\n * return `true` if an update should be requested.\n */\n hasChanged?(value: Type, oldValue: Type): boolean;\n\n /**\n * Indicates whether an accessor will be created for this property. By\n * default, an accessor will be generated for this property that requests an\n * update when set. If this flag is `true`, no accessor will be created, and\n * it will be the user's responsibility to call\n * `this.requestUpdate(propertyName, oldValue)` to request an update when\n * the property changes.\n */\n readonly noAccessor?: boolean;\n}\n\n/**\n * Map of properties to PropertyDeclaration options. For each property an\n * accessor is made, and the property is processed according to the\n * PropertyDeclaration options.\n */\nexport interface PropertyDeclarations {\n readonly [key: string]: PropertyDeclaration;\n}\n\ntype PropertyDeclarationMap = Map;\n\ntype AttributeMap = Map;\n\nexport type PropertyValues = Map;\n\nexport const defaultConverter: ComplexAttributeConverter = {\n\n toAttribute(value: unknown, type?: unknown): unknown {\n switch (type) {\n case Boolean:\n return value ? '' : null;\n case Object:\n case Array:\n // if the value is `null` or `undefined` pass this through\n // to allow removing/no change behavior.\n return value == null ? value : JSON.stringify(value);\n }\n return value;\n },\n\n fromAttribute(value: string|null, type?: unknown) {\n switch (type) {\n case Boolean:\n return value !== null;\n case Number:\n return value === null ? null : Number(value);\n case Object:\n case Array:\n return JSON.parse(value!);\n }\n return value;\n }\n\n};\n\nexport interface HasChanged {\n (value: unknown, old: unknown): boolean;\n}\n\n/**\n * Change function that returns true if `value` is different from `oldValue`.\n * This method is used as the default for a property's `hasChanged` function.\n */\nexport const notEqual: HasChanged = (value: unknown, old: unknown): boolean => {\n // This ensures (old==NaN, value==NaN) always returns false\n return old !== value && (old === old || value === value);\n};\n\nconst defaultPropertyDeclaration: PropertyDeclaration = {\n attribute: true,\n type: String,\n converter: defaultConverter,\n reflect: false,\n hasChanged: notEqual\n};\n\nconst microtaskPromise = Promise.resolve(true);\n\nconst STATE_HAS_UPDATED = 1;\nconst STATE_UPDATE_REQUESTED = 1 << 2;\nconst STATE_IS_REFLECTING_TO_ATTRIBUTE = 1 << 3;\nconst STATE_IS_REFLECTING_TO_PROPERTY = 1 << 4;\nconst STATE_HAS_CONNECTED = 1 << 5;\ntype UpdateState = typeof STATE_HAS_UPDATED|typeof STATE_UPDATE_REQUESTED|\n typeof STATE_IS_REFLECTING_TO_ATTRIBUTE|\n typeof STATE_IS_REFLECTING_TO_PROPERTY|typeof STATE_HAS_CONNECTED;\n\n/**\n * The Closure JS Compiler doesn't currently have good support for static\n * property semantics where \"this\" is dynamic (e.g.\n * https://github.com/google/closure-compiler/issues/3177 and others) so we use\n * this hack to bypass any rewriting by the compiler.\n */\nconst finalized = 'finalized';\n\n/**\n * Base element class which manages element properties and attributes. When\n * properties change, the `update` method is asynchronously called. This method\n * should be supplied by subclassers to render updates as desired.\n */\nexport abstract class UpdatingElement extends HTMLElement {\n /*\n * Due to closure compiler ES6 compilation bugs, @nocollapse is required on\n * all static methods and properties with initializers. Reference:\n * - https://github.com/google/closure-compiler/issues/1776\n */\n\n /**\n * Maps attribute names to properties; for example `foobar` attribute to\n * `fooBar` property. Created lazily on user subclasses when finalizing the\n * class.\n */\n private static _attributeToPropertyMap: AttributeMap;\n\n /**\n * Marks class as having finished creating properties.\n */\n protected static[finalized] = true;\n\n /**\n * Memoized list of all class properties, including any superclass properties.\n * Created lazily on user subclasses when finalizing the class.\n */\n private static _classProperties?: PropertyDeclarationMap;\n\n /**\n * User-supplied object that maps property names to `PropertyDeclaration`\n * objects containing options for configuring the property.\n */\n static properties: PropertyDeclarations;\n\n /**\n * Returns a list of attributes corresponding to the registered properties.\n * @nocollapse\n */\n static get observedAttributes() {\n // note: piggy backing on this to ensure we're finalized.\n this.finalize();\n const attributes: string[] = [];\n // Use forEach so this works even if for/of loops are compiled to for loops\n // expecting arrays\n this._classProperties!.forEach((v, p) => {\n const attr = this._attributeNameForProperty(p, v);\n if (attr !== undefined) {\n this._attributeToPropertyMap.set(attr, p);\n attributes.push(attr);\n }\n });\n return attributes;\n }\n\n /**\n * Ensures the private `_classProperties` property metadata is created.\n * In addition to `finalize` this is also called in `createProperty` to\n * ensure the `@property` decorator can add property metadata.\n */\n /** @nocollapse */\n private static _ensureClassProperties() {\n // ensure private storage for property declarations.\n if (!this.hasOwnProperty(\n JSCompiler_renameProperty('_classProperties', this))) {\n this._classProperties = new Map();\n // NOTE: Workaround IE11 not supporting Map constructor argument.\n const superProperties: PropertyDeclarationMap =\n Object.getPrototypeOf(this)._classProperties;\n if (superProperties !== undefined) {\n superProperties.forEach(\n (v: PropertyDeclaration, k: PropertyKey) =>\n this._classProperties!.set(k, v));\n }\n }\n }\n\n /**\n * Creates a property accessor on the element prototype if one does not exist.\n * The property setter calls the property's `hasChanged` property option\n * or uses a strict identity check to determine whether or not to request\n * an update.\n * @nocollapse\n */\n static createProperty(\n name: PropertyKey,\n options: PropertyDeclaration = defaultPropertyDeclaration) {\n // Note, since this can be called by the `@property` decorator which\n // is called before `finalize`, we ensure storage exists for property\n // metadata.\n this._ensureClassProperties();\n this._classProperties!.set(name, options);\n // Do not generate an accessor if the prototype already has one, since\n // it would be lost otherwise and that would never be the user's intention;\n // Instead, we expect users to call `requestUpdate` themselves from\n // user-defined accessors. Note that if the super has an accessor we will\n // still overwrite it\n if (options.noAccessor || this.prototype.hasOwnProperty(name)) {\n return;\n }\n const key = typeof name === 'symbol' ? Symbol() : `__${name}`;\n Object.defineProperty(this.prototype, name, {\n // tslint:disable-next-line:no-any no symbol in index\n get(): any {\n return (this as {[key: string]: unknown})[key as string];\n },\n set(this: UpdatingElement, value: unknown) {\n const oldValue =\n (this as {} as {[key: string]: unknown})[name as string];\n (this as {} as {[key: string]: unknown})[key as string] = value;\n (this as unknown as UpdatingElement)._requestUpdate(name, oldValue);\n },\n configurable: true,\n enumerable: true\n });\n }\n\n /**\n * Creates property accessors for registered properties and ensures\n * any superclasses are also finalized.\n * @nocollapse\n */\n protected static finalize() {\n // finalize any superclasses\n const superCtor = Object.getPrototypeOf(this);\n if (!superCtor.hasOwnProperty(finalized)) {\n superCtor.finalize();\n }\n this[finalized] = true;\n this._ensureClassProperties();\n // initialize Map populated in observedAttributes\n this._attributeToPropertyMap = new Map();\n // make any properties\n // Note, only process \"own\" properties since this element will inherit\n // any properties defined on the superClass, and finalization ensures\n // the entire prototype chain is finalized.\n if (this.hasOwnProperty(JSCompiler_renameProperty('properties', this))) {\n const props = this.properties;\n // support symbols in properties (IE11 does not support this)\n const propKeys = [\n ...Object.getOwnPropertyNames(props),\n ...(typeof Object.getOwnPropertySymbols === 'function') ?\n Object.getOwnPropertySymbols(props) :\n []\n ];\n // This for/of is ok because propKeys is an array\n for (const p of propKeys) {\n // note, use of `any` is due to TypeSript lack of support for symbol in\n // index types\n // tslint:disable-next-line:no-any no symbol in index\n this.createProperty(p, (props as any)[p]);\n }\n }\n }\n\n /**\n * Returns the property name for the given attribute `name`.\n * @nocollapse\n */\n private static _attributeNameForProperty(\n name: PropertyKey, options: PropertyDeclaration) {\n const attribute = options.attribute;\n return attribute === false ?\n undefined :\n (typeof attribute === 'string' ?\n attribute :\n (typeof name === 'string' ? name.toLowerCase() : undefined));\n }\n\n /**\n * Returns true if a property should request an update.\n * Called when a property value is set and uses the `hasChanged`\n * option for the property if present or a strict identity check.\n * @nocollapse\n */\n private static _valueHasChanged(\n value: unknown, old: unknown, hasChanged: HasChanged = notEqual) {\n return hasChanged(value, old);\n }\n\n /**\n * Returns the property value for the given attribute value.\n * Called via the `attributeChangedCallback` and uses the property's\n * `converter` or `converter.fromAttribute` property option.\n * @nocollapse\n */\n private static _propertyValueFromAttribute(\n value: string|null, options: PropertyDeclaration) {\n const type = options.type;\n const converter = options.converter || defaultConverter;\n const fromAttribute =\n (typeof converter === 'function' ? converter : converter.fromAttribute);\n return fromAttribute ? fromAttribute(value, type) : value;\n }\n\n /**\n * Returns the attribute value for the given property value. If this\n * returns undefined, the property will *not* be reflected to an attribute.\n * If this returns null, the attribute will be removed, otherwise the\n * attribute will be set to the value.\n * This uses the property's `reflect` and `type.toAttribute` property options.\n * @nocollapse\n */\n private static _propertyValueToAttribute(\n value: unknown, options: PropertyDeclaration) {\n if (options.reflect === undefined) {\n return;\n }\n const type = options.type;\n const converter = options.converter;\n const toAttribute =\n converter && (converter as ComplexAttributeConverter).toAttribute ||\n defaultConverter.toAttribute;\n return toAttribute!(value, type);\n }\n\n private _updateState: UpdateState = 0;\n private _instanceProperties: PropertyValues|undefined = undefined;\n private _updatePromise: Promise = microtaskPromise;\n private _hasConnectedResolver: (() => void)|undefined = undefined;\n\n /**\n * Map with keys for any properties that have changed since the last\n * update cycle with previous values.\n */\n private _changedProperties: PropertyValues = new Map();\n\n /**\n * Map with keys of properties that should be reflected when updated.\n */\n private _reflectingProperties: Map|\n undefined = undefined;\n\n constructor() {\n super();\n this.initialize();\n }\n\n /**\n * Performs element initialization. By default captures any pre-set values for\n * registered properties.\n */\n protected initialize() {\n this._saveInstanceProperties();\n // ensures first update will be caught by an early access of\n // `updateComplete`\n this._requestUpdate();\n }\n\n /**\n * Fixes any properties set on the instance before upgrade time.\n * Otherwise these would shadow the accessor and break these properties.\n * The properties are stored in a Map which is played back after the\n * constructor runs. Note, on very old versions of Safari (<=9) or Chrome\n * (<=41), properties created for native platform properties like (`id` or\n * `name`) may not have default values set in the element constructor. On\n * these browsers native properties appear on instances and therefore their\n * default value will overwrite any element default (e.g. if the element sets\n * this.id = 'id' in the constructor, the 'id' will become '' since this is\n * the native platform default).\n */\n private _saveInstanceProperties() {\n // Use forEach so this works even if for/of loops are compiled to for loops\n // expecting arrays\n (this.constructor as typeof UpdatingElement)\n ._classProperties!.forEach((_v, p) => {\n if (this.hasOwnProperty(p)) {\n const value = this[p as keyof this];\n delete this[p as keyof this];\n if (!this._instanceProperties) {\n this._instanceProperties = new Map();\n }\n this._instanceProperties.set(p, value);\n }\n });\n }\n\n /**\n * Applies previously saved instance properties.\n */\n private _applyInstanceProperties() {\n // Use forEach so this works even if for/of loops are compiled to for loops\n // expecting arrays\n // tslint:disable-next-line:no-any\n this._instanceProperties!.forEach((v, p) => (this as any)[p] = v);\n this._instanceProperties = undefined;\n }\n\n connectedCallback() {\n this._updateState = this._updateState | STATE_HAS_CONNECTED;\n // Ensure first connection completes an update. Updates cannot complete\n // before connection and if one is pending connection the\n // `_hasConnectionResolver` will exist. If so, resolve it to complete the\n // update, otherwise requestUpdate.\n if (this._hasConnectedResolver) {\n this._hasConnectedResolver();\n this._hasConnectedResolver = undefined;\n }\n }\n\n /**\n * Allows for `super.disconnectedCallback()` in extensions while\n * reserving the possibility of making non-breaking feature additions\n * when disconnecting at some point in the future.\n */\n disconnectedCallback() {\n }\n\n /**\n * Synchronizes property values when attributes change.\n */\n attributeChangedCallback(name: string, old: string|null, value: string|null) {\n if (old !== value) {\n this._attributeToProperty(name, value);\n }\n }\n\n private _propertyToAttribute(\n name: PropertyKey, value: unknown,\n options: PropertyDeclaration = defaultPropertyDeclaration) {\n const ctor = (this.constructor as typeof UpdatingElement);\n const attr = ctor._attributeNameForProperty(name, options);\n if (attr !== undefined) {\n const attrValue = ctor._propertyValueToAttribute(value, options);\n // an undefined value does not change the attribute.\n if (attrValue === undefined) {\n return;\n }\n // Track if the property is being reflected to avoid\n // setting the property again via `attributeChangedCallback`. Note:\n // 1. this takes advantage of the fact that the callback is synchronous.\n // 2. will behave incorrectly if multiple attributes are in the reaction\n // stack at time of calling. However, since we process attributes\n // in `update` this should not be possible (or an extreme corner case\n // that we'd like to discover).\n // mark state reflecting\n this._updateState = this._updateState | STATE_IS_REFLECTING_TO_ATTRIBUTE;\n if (attrValue == null) {\n this.removeAttribute(attr);\n } else {\n this.setAttribute(attr, attrValue as string);\n }\n // mark state not reflecting\n this._updateState = this._updateState & ~STATE_IS_REFLECTING_TO_ATTRIBUTE;\n }\n }\n\n private _attributeToProperty(name: string, value: string|null) {\n // Use tracking info to avoid deserializing attribute value if it was\n // just set from a property setter.\n if (this._updateState & STATE_IS_REFLECTING_TO_ATTRIBUTE) {\n return;\n }\n const ctor = (this.constructor as typeof UpdatingElement);\n const propName = ctor._attributeToPropertyMap.get(name);\n if (propName !== undefined) {\n const options =\n ctor._classProperties!.get(propName) || defaultPropertyDeclaration;\n // mark state reflecting\n this._updateState = this._updateState | STATE_IS_REFLECTING_TO_PROPERTY;\n this[propName as keyof this] =\n // tslint:disable-next-line:no-any\n ctor._propertyValueFromAttribute(value, options) as any;\n // mark state not reflecting\n this._updateState = this._updateState & ~STATE_IS_REFLECTING_TO_PROPERTY;\n }\n }\n\n /**\n * This private version of `requestUpdate` does not access or return the\n * `updateComplete` promise. This promise can be overridden and is therefore\n * not free to access.\n */\n private _requestUpdate(name?: PropertyKey, oldValue?: unknown) {\n let shouldRequestUpdate = true;\n // If we have a property key, perform property update steps.\n if (name !== undefined) {\n const ctor = this.constructor as typeof UpdatingElement;\n const options =\n ctor._classProperties!.get(name) || defaultPropertyDeclaration;\n if (ctor._valueHasChanged(\n this[name as keyof this], oldValue, options.hasChanged)) {\n if (!this._changedProperties.has(name)) {\n this._changedProperties.set(name, oldValue);\n }\n // Add to reflecting properties set.\n // Note, it's important that every change has a chance to add the\n // property to `_reflectingProperties`. This ensures setting\n // attribute + property reflects correctly.\n if (options.reflect === true &&\n !(this._updateState & STATE_IS_REFLECTING_TO_PROPERTY)) {\n if (this._reflectingProperties === undefined) {\n this._reflectingProperties = new Map();\n }\n this._reflectingProperties.set(name, options);\n }\n } else {\n // Abort the request if the property should not be considered changed.\n shouldRequestUpdate = false;\n }\n }\n if (!this._hasRequestedUpdate && shouldRequestUpdate) {\n this._enqueueUpdate();\n }\n }\n\n /**\n * Requests an update which is processed asynchronously. This should\n * be called when an element should update based on some state not triggered\n * by setting a property. In this case, pass no arguments. It should also be\n * called when manually implementing a property setter. In this case, pass the\n * property `name` and `oldValue` to ensure that any configured property\n * options are honored. Returns the `updateComplete` Promise which is resolved\n * when the update completes.\n *\n * @param name {PropertyKey} (optional) name of requesting property\n * @param oldValue {any} (optional) old value of requesting property\n * @returns {Promise} A Promise that is resolved when the update completes.\n */\n requestUpdate(name?: PropertyKey, oldValue?: unknown) {\n this._requestUpdate(name, oldValue);\n return this.updateComplete;\n }\n\n /**\n * Sets up the element to asynchronously update.\n */\n private async _enqueueUpdate() {\n // Mark state updating...\n this._updateState = this._updateState | STATE_UPDATE_REQUESTED;\n let resolve!: (r: boolean) => void;\n let reject!: (e: Error) => void;\n const previousUpdatePromise = this._updatePromise;\n this._updatePromise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n try {\n // Ensure any previous update has resolved before updating.\n // This `await` also ensures that property changes are batched.\n await previousUpdatePromise;\n } catch (e) {\n // Ignore any previous errors. We only care that the previous cycle is\n // done. Any error should have been handled in the previous update.\n }\n // Make sure the element has connected before updating.\n if (!this._hasConnected) {\n await new Promise((res) => this._hasConnectedResolver = res);\n }\n try {\n const result = this.performUpdate();\n // If `performUpdate` returns a Promise, we await it. This is done to\n // enable coordinating updates with a scheduler. Note, the result is\n // checked to avoid delaying an additional microtask unless we need to.\n if (result != null) {\n await result;\n }\n } catch (e) {\n reject(e);\n }\n resolve(!this._hasRequestedUpdate);\n }\n\n private get _hasConnected() {\n return (this._updateState & STATE_HAS_CONNECTED);\n }\n\n private get _hasRequestedUpdate() {\n return (this._updateState & STATE_UPDATE_REQUESTED);\n }\n\n protected get hasUpdated() {\n return (this._updateState & STATE_HAS_UPDATED);\n }\n\n /**\n * Performs an element update. Note, if an exception is thrown during the\n * update, `firstUpdated` and `updated` will not be called.\n *\n * You can override this method to change the timing of updates. If this\n * method is overridden, `super.performUpdate()` must be called.\n *\n * For instance, to schedule updates to occur just before the next frame:\n *\n * ```\n * protected async performUpdate(): Promise {\n * await new Promise((resolve) => requestAnimationFrame(() => resolve()));\n * super.performUpdate();\n * }\n * ```\n */\n protected performUpdate(): void|Promise {\n // Mixin instance properties once, if they exist.\n if (this._instanceProperties) {\n this._applyInstanceProperties();\n }\n let shouldUpdate = false;\n const changedProperties = this._changedProperties;\n try {\n shouldUpdate = this.shouldUpdate(changedProperties);\n if (shouldUpdate) {\n this.update(changedProperties);\n }\n } catch (e) {\n // Prevent `firstUpdated` and `updated` from running when there's an\n // update exception.\n shouldUpdate = false;\n throw e;\n } finally {\n // Ensure element can accept additional updates after an exception.\n this._markUpdated();\n }\n if (shouldUpdate) {\n if (!(this._updateState & STATE_HAS_UPDATED)) {\n this._updateState = this._updateState | STATE_HAS_UPDATED;\n this.firstUpdated(changedProperties);\n }\n this.updated(changedProperties);\n }\n }\n\n private _markUpdated() {\n this._changedProperties = new Map();\n this._updateState = this._updateState & ~STATE_UPDATE_REQUESTED;\n }\n\n /**\n * Returns a Promise that resolves when the element has completed updating.\n * The Promise value is a boolean that is `true` if the element completed the\n * update without triggering another update. The Promise result is `false` if\n * a property was set inside `updated()`. If the Promise is rejected, an\n * exception was thrown during the update.\n *\n * To await additional asynchronous work, override the `_getUpdateComplete`\n * method. For example, it is sometimes useful to await a rendered element\n * before fulfilling this Promise. To do this, first await\n * `super._getUpdateComplete()`, then any subsequent state.\n *\n * @returns {Promise} The Promise returns a boolean that indicates if the\n * update resolved without triggering another update.\n */\n get updateComplete() {\n return this._getUpdateComplete();\n }\n\n /**\n * Override point for the `updateComplete` promise.\n *\n * It is not safe to override the `updateComplete` getter directly due to a\n * limitation in TypeScript which means it is not possible to call a\n * superclass getter (e.g. `super.updateComplete.then(...)`) when the target\n * language is ES5 (https://github.com/microsoft/TypeScript/issues/338).\n * This method should be overridden instead. For example:\n *\n * class MyElement extends LitElement {\n * async _getUpdateComplete() {\n * await super._getUpdateComplete();\n * await this._myChild.updateComplete;\n * }\n * }\n */\n protected _getUpdateComplete() {\n return this._updatePromise;\n }\n\n /**\n * Controls whether or not `update` should be called when the element requests\n * an update. By default, this method always returns `true`, but this can be\n * customized to control when to update.\n *\n * * @param _changedProperties Map of changed properties with old values\n */\n protected shouldUpdate(_changedProperties: PropertyValues): boolean {\n return true;\n }\n\n /**\n * Updates the element. This method reflects property values to attributes.\n * It can be overridden to render and keep updated element DOM.\n * Setting properties inside this method will *not* trigger\n * another update.\n *\n * * @param _changedProperties Map of changed properties with old values\n */\n protected update(_changedProperties: PropertyValues) {\n if (this._reflectingProperties !== undefined &&\n this._reflectingProperties.size > 0) {\n // Use forEach so this works even if for/of loops are compiled to for\n // loops expecting arrays\n this._reflectingProperties.forEach(\n (v, k) => this._propertyToAttribute(k, this[k as keyof this], v));\n this._reflectingProperties = undefined;\n }\n }\n\n /**\n * Invoked whenever the element is updated. Implement to perform\n * post-updating tasks via DOM APIs, for example, focusing an element.\n *\n * Setting properties inside this method will trigger the element to update\n * again after this update cycle completes.\n *\n * * @param _changedProperties Map of changed properties with old values\n */\n protected updated(_changedProperties: PropertyValues) {\n }\n\n /**\n * Invoked when the element is first updated. Implement to perform one time\n * work on the element after update.\n *\n * Setting properties inside this method will trigger the element to update\n * again after this update cycle completes.\n *\n * * @param _changedProperties Map of changed properties with old values\n */\n protected firstUpdated(_changedProperties: PropertyValues) {\n }\n}\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\nimport {TemplateResult} from 'lit-html';\nimport {render} from 'lit-html/lib/shady-render.js';\n\nimport {PropertyValues, UpdatingElement} from './lib/updating-element.js';\n\nexport * from './lib/updating-element.js';\nexport * from './lib/decorators.js';\nexport {html, svg, TemplateResult, SVGTemplateResult} from 'lit-html/lit-html.js';\nimport {supportsAdoptingStyleSheets, CSSResult} from './lib/css-tag.js';\nexport * from './lib/css-tag.js';\n\ndeclare global {\n interface Window {\n litElementVersions: string[];\n }\n}\n\n// IMPORTANT: do not change the property name or the assignment expression.\n// This line will be used in regexes to search for LitElement usage.\n// TODO(justinfagnani): inject version number at build time\n(window['litElementVersions'] || (window['litElementVersions'] = []))\n .push('2.2.1');\n\nexport interface CSSResultArray extends Array {}\n\n/**\n * Minimal implementation of Array.prototype.flat\n * @param arr the array to flatten\n * @param result the accumlated result\n */\nfunction arrayFlat(\n styles: CSSResultArray, result: CSSResult[] = []): CSSResult[] {\n for (let i = 0, length = styles.length; i < length; i++) {\n const value = styles[i];\n if (Array.isArray(value)) {\n arrayFlat(value, result);\n } else {\n result.push(value);\n }\n }\n return result;\n}\n\n/** Deeply flattens styles array. Uses native flat if available. */\nconst flattenStyles = (styles: CSSResultArray): CSSResult[] =>\n styles.flat ? styles.flat(Infinity) : arrayFlat(styles);\n\nexport class LitElement extends UpdatingElement {\n\n /**\n * Ensure this class is marked as `finalized` as an optimization ensuring\n * it will not needlessly try to `finalize`.\n *\n * Note this property name is a string to prevent breaking Closure JS Compiler\n * optimizations. See updating-element.ts for more information.\n */\n protected static['finalized'] = true;\n /**\n * Render method used to render the lit-html TemplateResult to the element's\n * DOM.\n * @param {TemplateResult} Template to render.\n * @param {Element|DocumentFragment} Node into which to render.\n * @param {String} Element name.\n * @nocollapse\n */\n static render = render;\n\n /**\n * Array of styles to apply to the element. The styles should be defined\n * using the `css` tag function.\n */\n static styles?: CSSResult|CSSResultArray;\n\n private static _styles: CSSResult[]|undefined;\n\n /** @nocollapse */\n protected static finalize() {\n // The Closure JS Compiler does not always preserve the correct \"this\"\n // when calling static super methods (b/137460243), so explicitly bind.\n super.finalize.call(this);\n // Prepare styling that is stamped at first render time. Styling\n // is built from user provided `styles` or is inherited from the superclass.\n this._styles =\n this.hasOwnProperty(JSCompiler_renameProperty('styles', this)) ?\n this._getUniqueStyles() :\n this._styles || [];\n }\n\n /** @nocollapse */\n private static _getUniqueStyles(): CSSResult[] {\n // Take care not to call `this.styles` multiple times since this generates\n // new CSSResults each time.\n // TODO(sorvell): Since we do not cache CSSResults by input, any\n // shared styles will generate new stylesheet objects, which is wasteful.\n // This should be addressed when a browser ships constructable\n // stylesheets.\n const userStyles = this.styles;\n const styles: CSSResult[] = [];\n if (Array.isArray(userStyles)) {\n const flatStyles = flattenStyles(userStyles);\n // As a performance optimization to avoid duplicated styling that can\n // occur especially when composing via subclassing, de-duplicate styles\n // preserving the last item in the list. The last item is kept to\n // try to preserve cascade order with the assumption that it's most\n // important that last added styles override previous styles.\n const styleSet = flatStyles.reduceRight((set, s) => {\n set.add(s);\n // on IE set.add does not return the set.\n return set;\n }, new Set());\n // Array.from does not work on Set in IE\n styleSet.forEach((v) => styles.unshift(v));\n } else if (userStyles) {\n styles.push(userStyles);\n }\n return styles;\n }\n\n private _needsShimAdoptedStyleSheets?: boolean;\n\n /**\n * Node or ShadowRoot into which element DOM should be rendered. Defaults\n * to an open shadowRoot.\n */\n readonly renderRoot!: Element|DocumentFragment;\n\n /**\n * Performs element initialization. By default this calls `createRenderRoot`\n * to create the element `renderRoot` node and captures any pre-set values for\n * registered properties.\n */\n protected initialize() {\n super.initialize();\n (this as {renderRoot: Element | DocumentFragment}).renderRoot =\n this.createRenderRoot();\n // Note, if renderRoot is not a shadowRoot, styles would/could apply to the\n // element's getRootNode(). While this could be done, we're choosing not to\n // support this now since it would require different logic around de-duping.\n if (window.ShadowRoot && this.renderRoot instanceof window.ShadowRoot) {\n this.adoptStyles();\n }\n }\n\n /**\n * Returns the node into which the element should render and by default\n * creates and returns an open shadowRoot. Implement to customize where the\n * element's DOM is rendered. For example, to render into the element's\n * childNodes, return `this`.\n * @returns {Element|DocumentFragment} Returns a node into which to render.\n */\n protected createRenderRoot(): Element|ShadowRoot {\n return this.attachShadow({mode: 'open'});\n }\n\n /**\n * Applies styling to the element shadowRoot using the `static get styles`\n * property. Styling will apply using `shadowRoot.adoptedStyleSheets` where\n * available and will fallback otherwise. When Shadow DOM is polyfilled,\n * ShadyCSS scopes styles and adds them to the document. When Shadow DOM\n * is available but `adoptedStyleSheets` is not, styles are appended to the\n * end of the `shadowRoot` to [mimic spec\n * behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).\n */\n protected adoptStyles() {\n const styles = (this.constructor as typeof LitElement)._styles!;\n if (styles.length === 0) {\n return;\n }\n // There are three separate cases here based on Shadow DOM support.\n // (1) shadowRoot polyfilled: use ShadyCSS\n // (2) shadowRoot.adoptedStyleSheets available: use it.\n // (3) shadowRoot.adoptedStyleSheets polyfilled: append styles after\n // rendering\n if (window.ShadyCSS !== undefined && !window.ShadyCSS.nativeShadow) {\n window.ShadyCSS.ScopingShim!.prepareAdoptedCssText(\n styles.map((s) => s.cssText), this.localName);\n } else if (supportsAdoptingStyleSheets) {\n (this.renderRoot as ShadowRoot).adoptedStyleSheets =\n styles.map((s) => s.styleSheet!);\n } else {\n // This must be done after rendering so the actual style insertion is done\n // in `update`.\n this._needsShimAdoptedStyleSheets = true;\n }\n }\n\n connectedCallback() {\n super.connectedCallback();\n // Note, first update/render handles styleElement so we only call this if\n // connected after first update.\n if (this.hasUpdated && window.ShadyCSS !== undefined) {\n window.ShadyCSS.styleElement(this);\n }\n }\n\n /**\n * Updates the element. This method reflects property values to attributes\n * and calls `render` to render DOM via lit-html. Setting properties inside\n * this method will *not* trigger another update.\n * * @param _changedProperties Map of changed properties with old values\n */\n protected update(changedProperties: PropertyValues) {\n super.update(changedProperties);\n const templateResult = this.render() as unknown;\n if (templateResult instanceof TemplateResult) {\n (this.constructor as typeof LitElement)\n .render(\n templateResult,\n this.renderRoot,\n {scopeName: this.localName, eventContext: this});\n }\n // When native Shadow DOM is used but adoptedStyles are not supported,\n // insert styling after rendering to ensure adoptedStyles have highest\n // priority.\n if (this._needsShimAdoptedStyleSheets) {\n this._needsShimAdoptedStyleSheets = false;\n (this.constructor as typeof LitElement)._styles!.forEach((s) => {\n const style = document.createElement('style');\n style.textContent = s.cssText;\n this.renderRoot.appendChild(style);\n });\n }\n }\n\n /**\n * Invoked on each update to perform rendering tasks. This method must return\n * a lit-html TemplateResult. Setting properties inside this method will *not*\n * trigger the element to update.\n */\n protected render(): TemplateResult|void {\n }\n}\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\n/**\n * @module lit-html\n */\n\nimport {Part} from './part.js';\nimport {AttributeCommitter, BooleanAttributePart, EventPart, NodePart, PropertyCommitter} from './parts.js';\nimport {RenderOptions} from './render-options.js';\nimport {TemplateProcessor} from './template-processor.js';\n\n/**\n * Creates Parts when a template is instantiated.\n */\nexport class DefaultTemplateProcessor implements TemplateProcessor {\n /**\n * Create parts for an attribute-position binding, given the event, attribute\n * name, and string literals.\n *\n * @param element The element containing the binding\n * @param name The attribute name\n * @param strings The string literals. There are always at least two strings,\n * event for fully-controlled bindings with a single expression.\n */\n handleAttributeExpressions(\n element: Element, name: string, strings: string[],\n options: RenderOptions): ReadonlyArray {\n const prefix = name[0];\n if (prefix === '.') {\n const committer = new PropertyCommitter(element, name.slice(1), strings);\n return committer.parts;\n }\n if (prefix === '@') {\n return [new EventPart(element, name.slice(1), options.eventContext)];\n }\n if (prefix === '?') {\n return [new BooleanAttributePart(element, name.slice(1), strings)];\n }\n const committer = new AttributeCommitter(element, name, strings);\n return committer.parts;\n }\n /**\n * Create parts for a text-position binding.\n * @param templateFactory\n */\n handleTextExpression(options: RenderOptions) {\n return new NodePart(options);\n }\n}\n\nexport const defaultTemplateProcessor = new DefaultTemplateProcessor();\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\n/**\n * @module lit-html\n */\n\nimport {Part} from './part.js';\n\nconst directives = new WeakMap();\n\n// tslint:disable-next-line:no-any\nexport type DirectiveFactory = (...args: any[]) => object;\n\nexport type DirectiveFn = (part: Part) => void;\n\n/**\n * Brands a function as a directive factory function so that lit-html will call\n * the function during template rendering, rather than passing as a value.\n *\n * A _directive_ is a function that takes a Part as an argument. It has the\n * signature: `(part: Part) => void`.\n *\n * A directive _factory_ is a function that takes arguments for data and\n * configuration and returns a directive. Users of directive usually refer to\n * the directive factory as the directive. For example, \"The repeat directive\".\n *\n * Usually a template author will invoke a directive factory in their template\n * with relevant arguments, which will then return a directive function.\n *\n * Here's an example of using the `repeat()` directive factory that takes an\n * array and a function to render an item:\n *\n * ```js\n * html`

      <${repeat(items, (item) => html`
    • ${item}
    • `)}
    `\n * ```\n *\n * When `repeat` is invoked, it returns a directive function that closes over\n * `items` and the template function. When the outer template is rendered, the\n * return directive function is called with the Part for the expression.\n * `repeat` then performs it's custom logic to render multiple items.\n *\n * @param f The directive factory function. Must be a function that returns a\n * function of the signature `(part: Part) => void`. The returned function will\n * be called with the part object.\n *\n * @example\n *\n * import {directive, html} from 'lit-html';\n *\n * const immutable = directive((v) => (part) => {\n * if (part.value !== v) {\n * part.setValue(v)\n * }\n * });\n */\nexport const directive = (f: F): F =>\n ((...args: unknown[]) => {\n const d = f(...args);\n directives.set(d, true);\n return d;\n }) as F;\n\nexport const isDirective = (o: unknown): o is DirectiveFn => {\n return typeof o === 'function' && directives.has(o);\n};\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\n/**\n * @module lit-html\n */\n\ninterface MaybePolyfilledCe extends CustomElementRegistry {\n readonly polyfillWrapFlushCallback?: object;\n}\n\n/**\n * True if the custom elements polyfill is in use.\n */\nexport const isCEPolyfill = window.customElements !== undefined &&\n (window.customElements as MaybePolyfilledCe).polyfillWrapFlushCallback !==\n undefined;\n\n/**\n * Reparents nodes, starting from `start` (inclusive) to `end` (exclusive),\n * into another container (could be the same container), before `before`. If\n * `before` is null, it appends the nodes to the container.\n */\nexport const reparentNodes =\n (container: Node,\n start: Node|null,\n end: Node|null = null,\n before: Node|null = null): void => {\n while (start !== end) {\n const n = start!.nextSibling;\n container.insertBefore(start!, before);\n start = n;\n }\n };\n\n/**\n * Removes nodes, starting from `start` (inclusive) to `end` (exclusive), from\n * `container`.\n */\nexport const removeNodes =\n (container: Node, start: Node|null, end: Node|null = null): void => {\n while (start !== end) {\n const n = start!.nextSibling;\n container.removeChild(start!);\n start = n;\n }\n };\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\n/**\n * @module shady-render\n */\n\nimport {isTemplatePartActive, Template, TemplatePart} from './template.js';\n\nconst walkerNodeFilter = 133 /* NodeFilter.SHOW_{ELEMENT|COMMENT|TEXT} */;\n\n/**\n * Removes the list of nodes from a Template safely. In addition to removing\n * nodes from the Template, the Template part indices are updated to match\n * the mutated Template DOM.\n *\n * As the template is walked the removal state is tracked and\n * part indices are adjusted as needed.\n *\n * div\n * div#1 (remove) <-- start removing (removing node is div#1)\n * div\n * div#2 (remove) <-- continue removing (removing node is still div#1)\n * div\n * div <-- stop removing since previous sibling is the removing node (div#1,\n * removed 4 nodes)\n */\nexport function removeNodesFromTemplate(\n template: Template, nodesToRemove: Set) {\n const {element: {content}, parts} = template;\n const walker =\n document.createTreeWalker(content, walkerNodeFilter, null, false);\n let partIndex = nextActiveIndexInTemplateParts(parts);\n let part = parts[partIndex];\n let nodeIndex = -1;\n let removeCount = 0;\n const nodesToRemoveInTemplate = [];\n let currentRemovingNode: Node|null = null;\n while (walker.nextNode()) {\n nodeIndex++;\n const node = walker.currentNode as Element;\n // End removal if stepped past the removing node\n if (node.previousSibling === currentRemovingNode) {\n currentRemovingNode = null;\n }\n // A node to remove was found in the template\n if (nodesToRemove.has(node)) {\n nodesToRemoveInTemplate.push(node);\n // Track node we're removing\n if (currentRemovingNode === null) {\n currentRemovingNode = node;\n }\n }\n // When removing, increment count by which to adjust subsequent part indices\n if (currentRemovingNode !== null) {\n removeCount++;\n }\n while (part !== undefined && part.index === nodeIndex) {\n // If part is in a removed node deactivate it by setting index to -1 or\n // adjust the index as needed.\n part.index = currentRemovingNode !== null ? -1 : part.index - removeCount;\n // go to the next active part.\n partIndex = nextActiveIndexInTemplateParts(parts, partIndex);\n part = parts[partIndex];\n }\n }\n nodesToRemoveInTemplate.forEach((n) => n.parentNode!.removeChild(n));\n}\n\nconst countNodes = (node: Node) => {\n let count = (node.nodeType === 11 /* Node.DOCUMENT_FRAGMENT_NODE */) ? 0 : 1;\n const walker = document.createTreeWalker(node, walkerNodeFilter, null, false);\n while (walker.nextNode()) {\n count++;\n }\n return count;\n};\n\nconst nextActiveIndexInTemplateParts =\n (parts: TemplatePart[], startIndex: number = -1) => {\n for (let i = startIndex + 1; i < parts.length; i++) {\n const part = parts[i];\n if (isTemplatePartActive(part)) {\n return i;\n }\n }\n return -1;\n };\n\n/**\n * Inserts the given node into the Template, optionally before the given\n * refNode. In addition to inserting the node into the Template, the Template\n * part indices are updated to match the mutated Template DOM.\n */\nexport function insertNodeIntoTemplate(\n template: Template, node: Node, refNode: Node|null = null) {\n const {element: {content}, parts} = template;\n // If there's no refNode, then put node at end of template.\n // No part indices need to be shifted in this case.\n if (refNode === null || refNode === undefined) {\n content.appendChild(node);\n return;\n }\n const walker =\n document.createTreeWalker(content, walkerNodeFilter, null, false);\n let partIndex = nextActiveIndexInTemplateParts(parts);\n let insertCount = 0;\n let walkerIndex = -1;\n while (walker.nextNode()) {\n walkerIndex++;\n const walkerNode = walker.currentNode as Element;\n if (walkerNode === refNode) {\n insertCount = countNodes(node);\n refNode.parentNode!.insertBefore(node, refNode);\n }\n while (partIndex !== -1 && parts[partIndex].index === walkerIndex) {\n // If we've inserted the node, simply adjust all subsequent parts\n if (insertCount > 0) {\n while (partIndex !== -1) {\n parts[partIndex].index += insertCount;\n partIndex = nextActiveIndexInTemplateParts(parts, partIndex);\n }\n return;\n }\n partIndex = nextActiveIndexInTemplateParts(parts, partIndex);\n }\n }\n}\n","/**\n * @license\n * Copyright (c) 2018 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\n/**\n * @module lit-html\n */\n\n/**\n * The Part interface represents a dynamic part of a template instance rendered\n * by lit-html.\n */\nexport interface Part {\n readonly value: unknown;\n\n /**\n * Sets the current part value, but does not write it to the DOM.\n * @param value The value that will be committed.\n */\n setValue(value: unknown): void;\n\n /**\n * Commits the current part value, causing it to actually be written to the\n * DOM.\n *\n * Directives are run at the start of `commit`, so that if they call\n * `part.setValue(...)` synchronously that value will be used in the current\n * commit, and there's no need to call `part.commit()` within the directive.\n * If directives set a part value asynchronously, then they must call\n * `part.commit()` manually.\n */\n commit(): void;\n}\n\n/**\n * A sentinel value that signals that a value was handled by a directive and\n * should not be written to the DOM.\n */\nexport const noChange = {};\n\n/**\n * A sentinel value that signals a NodePart to fully clear its content.\n */\nexport const nothing = {};\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\n/**\n * @module lit-html\n */\n\nimport {isDirective} from './directive.js';\nimport {removeNodes} from './dom.js';\nimport {noChange, nothing, Part} from './part.js';\nimport {RenderOptions} from './render-options.js';\nimport {TemplateInstance} from './template-instance.js';\nimport {TemplateResult} from './template-result.js';\nimport {createMarker} from './template.js';\n\n// https://tc39.github.io/ecma262/#sec-typeof-operator\nexport type Primitive = null|undefined|boolean|number|string|Symbol|bigint;\nexport const isPrimitive = (value: unknown): value is Primitive => {\n return (\n value === null ||\n !(typeof value === 'object' || typeof value === 'function'));\n};\nexport const isIterable = (value: unknown): value is Iterable => {\n return Array.isArray(value) ||\n // tslint:disable-next-line:no-any\n !!(value && (value as any)[Symbol.iterator]);\n};\n\n/**\n * Writes attribute values to the DOM for a group of AttributeParts bound to a\n * single attibute. The value is only set once even if there are multiple parts\n * for an attribute.\n */\nexport class AttributeCommitter {\n readonly element: Element;\n readonly name: string;\n readonly strings: ReadonlyArray;\n readonly parts: ReadonlyArray;\n dirty = true;\n\n constructor(element: Element, name: string, strings: ReadonlyArray) {\n this.element = element;\n this.name = name;\n this.strings = strings;\n this.parts = [];\n for (let i = 0; i < strings.length - 1; i++) {\n (this.parts as AttributePart[])[i] = this._createPart();\n }\n }\n\n /**\n * Creates a single part. Override this to create a differnt type of part.\n */\n protected _createPart(): AttributePart {\n return new AttributePart(this);\n }\n\n protected _getValue(): unknown {\n const strings = this.strings;\n const l = strings.length - 1;\n let text = '';\n\n for (let i = 0; i < l; i++) {\n text += strings[i];\n const part = this.parts[i];\n if (part !== undefined) {\n const v = part.value;\n if (isPrimitive(v) || !isIterable(v)) {\n text += typeof v === 'string' ? v : String(v);\n } else {\n for (const t of v) {\n text += typeof t === 'string' ? t : String(t);\n }\n }\n }\n }\n\n text += strings[l];\n return text;\n }\n\n commit(): void {\n if (this.dirty) {\n this.dirty = false;\n this.element.setAttribute(this.name, this._getValue() as string);\n }\n }\n}\n\n/**\n * A Part that controls all or part of an attribute value.\n */\nexport class AttributePart implements Part {\n readonly committer: AttributeCommitter;\n value: unknown = undefined;\n\n constructor(committer: AttributeCommitter) {\n this.committer = committer;\n }\n\n setValue(value: unknown): void {\n if (value !== noChange && (!isPrimitive(value) || value !== this.value)) {\n this.value = value;\n // If the value is a not a directive, dirty the committer so that it'll\n // call setAttribute. If the value is a directive, it'll dirty the\n // committer if it calls setValue().\n if (!isDirective(value)) {\n this.committer.dirty = true;\n }\n }\n }\n\n commit() {\n while (isDirective(this.value)) {\n const directive = this.value;\n this.value = noChange;\n directive(this);\n }\n if (this.value === noChange) {\n return;\n }\n this.committer.commit();\n }\n}\n\n/**\n * A Part that controls a location within a Node tree. Like a Range, NodePart\n * has start and end locations and can set and update the Nodes between those\n * locations.\n *\n * NodeParts support several value types: primitives, Nodes, TemplateResults,\n * as well as arrays and iterables of those types.\n */\nexport class NodePart implements Part {\n readonly options: RenderOptions;\n startNode!: Node;\n endNode!: Node;\n value: unknown = undefined;\n private __pendingValue: unknown = undefined;\n\n constructor(options: RenderOptions) {\n this.options = options;\n }\n\n /**\n * Appends this part into a container.\n *\n * This part must be empty, as its contents are not automatically moved.\n */\n appendInto(container: Node) {\n this.startNode = container.appendChild(createMarker());\n this.endNode = container.appendChild(createMarker());\n }\n\n /**\n * Inserts this part after the `ref` node (between `ref` and `ref`'s next\n * sibling). Both `ref` and its next sibling must be static, unchanging nodes\n * such as those that appear in a literal section of a template.\n *\n * This part must be empty, as its contents are not automatically moved.\n */\n insertAfterNode(ref: Node) {\n this.startNode = ref;\n this.endNode = ref.nextSibling!;\n }\n\n /**\n * Appends this part into a parent part.\n *\n * This part must be empty, as its contents are not automatically moved.\n */\n appendIntoPart(part: NodePart) {\n part.__insert(this.startNode = createMarker());\n part.__insert(this.endNode = createMarker());\n }\n\n /**\n * Inserts this part after the `ref` part.\n *\n * This part must be empty, as its contents are not automatically moved.\n */\n insertAfterPart(ref: NodePart) {\n ref.__insert(this.startNode = createMarker());\n this.endNode = ref.endNode;\n ref.endNode = this.startNode;\n }\n\n setValue(value: unknown): void {\n this.__pendingValue = value;\n }\n\n commit() {\n while (isDirective(this.__pendingValue)) {\n const directive = this.__pendingValue;\n this.__pendingValue = noChange;\n directive(this);\n }\n const value = this.__pendingValue;\n if (value === noChange) {\n return;\n }\n if (isPrimitive(value)) {\n if (value !== this.value) {\n this.__commitText(value);\n }\n } else if (value instanceof TemplateResult) {\n this.__commitTemplateResult(value);\n } else if (value instanceof Node) {\n this.__commitNode(value);\n } else if (isIterable(value)) {\n this.__commitIterable(value);\n } else if (value === nothing) {\n this.value = nothing;\n this.clear();\n } else {\n // Fallback, will render the string representation\n this.__commitText(value);\n }\n }\n\n private __insert(node: Node) {\n this.endNode.parentNode!.insertBefore(node, this.endNode);\n }\n\n private __commitNode(value: Node): void {\n if (this.value === value) {\n return;\n }\n this.clear();\n this.__insert(value);\n this.value = value;\n }\n\n private __commitText(value: unknown): void {\n const node = this.startNode.nextSibling!;\n value = value == null ? '' : value;\n // If `value` isn't already a string, we explicitly convert it here in case\n // it can't be implicitly converted - i.e. it's a symbol.\n const valueAsString: string =\n typeof value === 'string' ? value : String(value);\n if (node === this.endNode.previousSibling &&\n node.nodeType === 3 /* Node.TEXT_NODE */) {\n // If we only have a single text node between the markers, we can just\n // set its value, rather than replacing it.\n // TODO(justinfagnani): Can we just check if this.value is primitive?\n (node as Text).data = valueAsString;\n } else {\n this.__commitNode(document.createTextNode(valueAsString));\n }\n this.value = value;\n }\n\n private __commitTemplateResult(value: TemplateResult): void {\n const template = this.options.templateFactory(value);\n if (this.value instanceof TemplateInstance &&\n this.value.template === template) {\n this.value.update(value.values);\n } else {\n // Make sure we propagate the template processor from the TemplateResult\n // so that we use its syntax extension, etc. The template factory comes\n // from the render function options so that it can control template\n // caching and preprocessing.\n const instance =\n new TemplateInstance(template, value.processor, this.options);\n const fragment = instance._clone();\n instance.update(value.values);\n this.__commitNode(fragment);\n this.value = instance;\n }\n }\n\n private __commitIterable(value: Iterable): void {\n // For an Iterable, we create a new InstancePart per item, then set its\n // value to the item. This is a little bit of overhead for every item in\n // an Iterable, but it lets us recurse easily and efficiently update Arrays\n // of TemplateResults that will be commonly returned from expressions like:\n // array.map((i) => html`${i}`), by reusing existing TemplateInstances.\n\n // If _value is an array, then the previous render was of an\n // iterable and _value will contain the NodeParts from the previous\n // render. If _value is not an array, clear this part and make a new\n // array for NodeParts.\n if (!Array.isArray(this.value)) {\n this.value = [];\n this.clear();\n }\n\n // Lets us keep track of how many items we stamped so we can clear leftover\n // items from a previous render\n const itemParts = this.value as NodePart[];\n let partIndex = 0;\n let itemPart: NodePart|undefined;\n\n for (const item of value) {\n // Try to reuse an existing part\n itemPart = itemParts[partIndex];\n\n // If no existing part, create a new one\n if (itemPart === undefined) {\n itemPart = new NodePart(this.options);\n itemParts.push(itemPart);\n if (partIndex === 0) {\n itemPart.appendIntoPart(this);\n } else {\n itemPart.insertAfterPart(itemParts[partIndex - 1]);\n }\n }\n itemPart.setValue(item);\n itemPart.commit();\n partIndex++;\n }\n\n if (partIndex < itemParts.length) {\n // Truncate the parts array so _value reflects the current state\n itemParts.length = partIndex;\n this.clear(itemPart && itemPart.endNode);\n }\n }\n\n clear(startNode: Node = this.startNode) {\n removeNodes(\n this.startNode.parentNode!, startNode.nextSibling!, this.endNode);\n }\n}\n\n/**\n * Implements a boolean attribute, roughly as defined in the HTML\n * specification.\n *\n * If the value is truthy, then the attribute is present with a value of\n * ''. If the value is falsey, the attribute is removed.\n */\nexport class BooleanAttributePart implements Part {\n readonly element: Element;\n readonly name: string;\n readonly strings: ReadonlyArray;\n value: unknown = undefined;\n private __pendingValue: unknown = undefined;\n\n constructor(element: Element, name: string, strings: ReadonlyArray) {\n if (strings.length !== 2 || strings[0] !== '' || strings[1] !== '') {\n throw new Error(\n 'Boolean attributes can only contain a single expression');\n }\n this.element = element;\n this.name = name;\n this.strings = strings;\n }\n\n setValue(value: unknown): void {\n this.__pendingValue = value;\n }\n\n commit() {\n while (isDirective(this.__pendingValue)) {\n const directive = this.__pendingValue;\n this.__pendingValue = noChange;\n directive(this);\n }\n if (this.__pendingValue === noChange) {\n return;\n }\n const value = !!this.__pendingValue;\n if (this.value !== value) {\n if (value) {\n this.element.setAttribute(this.name, '');\n } else {\n this.element.removeAttribute(this.name);\n }\n this.value = value;\n }\n this.__pendingValue = noChange;\n }\n}\n\n/**\n * Sets attribute values for PropertyParts, so that the value is only set once\n * even if there are multiple parts for a property.\n *\n * If an expression controls the whole property value, then the value is simply\n * assigned to the property under control. If there are string literals or\n * multiple expressions, then the strings are expressions are interpolated into\n * a string first.\n */\nexport class PropertyCommitter extends AttributeCommitter {\n readonly single: boolean;\n\n constructor(element: Element, name: string, strings: ReadonlyArray) {\n super(element, name, strings);\n this.single =\n (strings.length === 2 && strings[0] === '' && strings[1] === '');\n }\n\n protected _createPart(): PropertyPart {\n return new PropertyPart(this);\n }\n\n protected _getValue() {\n if (this.single) {\n return this.parts[0].value;\n }\n return super._getValue();\n }\n\n commit(): void {\n if (this.dirty) {\n this.dirty = false;\n // tslint:disable-next-line:no-any\n (this.element as any)[this.name] = this._getValue();\n }\n }\n}\n\nexport class PropertyPart extends AttributePart {}\n\n// Detect event listener options support. If the `capture` property is read\n// from the options object, then options are supported. If not, then the thrid\n// argument to add/removeEventListener is interpreted as the boolean capture\n// value so we should only pass the `capture` property.\nlet eventOptionsSupported = false;\n\ntry {\n const options = {\n get capture() {\n eventOptionsSupported = true;\n return false;\n }\n };\n // tslint:disable-next-line:no-any\n window.addEventListener('test', options as any, options);\n // tslint:disable-next-line:no-any\n window.removeEventListener('test', options as any, options);\n} catch (_e) {\n}\n\n\ntype EventHandlerWithOptions =\n EventListenerOrEventListenerObject&Partial;\nexport class EventPart implements Part {\n readonly element: Element;\n readonly eventName: string;\n readonly eventContext?: EventTarget;\n value: undefined|EventHandlerWithOptions = undefined;\n private __options?: AddEventListenerOptions;\n private __pendingValue: undefined|EventHandlerWithOptions = undefined;\n private readonly __boundHandleEvent: (event: Event) => void;\n\n constructor(element: Element, eventName: string, eventContext?: EventTarget) {\n this.element = element;\n this.eventName = eventName;\n this.eventContext = eventContext;\n this.__boundHandleEvent = (e) => this.handleEvent(e);\n }\n\n setValue(value: undefined|EventHandlerWithOptions): void {\n this.__pendingValue = value;\n }\n\n commit() {\n while (isDirective(this.__pendingValue)) {\n const directive = this.__pendingValue;\n this.__pendingValue = noChange as EventHandlerWithOptions;\n directive(this);\n }\n if (this.__pendingValue === noChange) {\n return;\n }\n\n const newListener = this.__pendingValue;\n const oldListener = this.value;\n const shouldRemoveListener = newListener == null ||\n oldListener != null &&\n (newListener.capture !== oldListener.capture ||\n newListener.once !== oldListener.once ||\n newListener.passive !== oldListener.passive);\n const shouldAddListener =\n newListener != null && (oldListener == null || shouldRemoveListener);\n\n if (shouldRemoveListener) {\n this.element.removeEventListener(\n this.eventName, this.__boundHandleEvent, this.__options);\n }\n if (shouldAddListener) {\n this.__options = getOptions(newListener);\n this.element.addEventListener(\n this.eventName, this.__boundHandleEvent, this.__options);\n }\n this.value = newListener;\n this.__pendingValue = noChange as EventHandlerWithOptions;\n }\n\n handleEvent(event: Event) {\n if (typeof this.value === 'function') {\n this.value.call(this.eventContext || this.element, event);\n } else {\n (this.value as EventListenerObject).handleEvent(event);\n }\n }\n}\n\n// We copy options because of the inconsistent behavior of browsers when reading\n// the third argument of add/removeEventListener. IE11 doesn't support options\n// at all. Chrome 41 only reads `capture` if the argument is an object.\nconst getOptions = (o: AddEventListenerOptions|undefined) => o &&\n (eventOptionsSupported ?\n {capture: o.capture, passive: o.passive, once: o.once} :\n o.capture as AddEventListenerOptions);\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\n/**\n * @module lit-html\n */\n\nimport {removeNodes} from './dom.js';\nimport {NodePart} from './parts.js';\nimport {RenderOptions} from './render-options.js';\nimport {templateFactory} from './template-factory.js';\n\nexport const parts = new WeakMap();\n\n/**\n * Renders a template result or other value to a container.\n *\n * To update a container with new values, reevaluate the template literal and\n * call `render` with the new result.\n *\n * @param result Any value renderable by NodePart - typically a TemplateResult\n * created by evaluating a template tag like `html` or `svg`.\n * @param container A DOM parent to render to. The entire contents are either\n * replaced, or efficiently updated if the same result type was previous\n * rendered there.\n * @param options RenderOptions for the entire render tree rendered to this\n * container. Render options must *not* change between renders to the same\n * container, as those changes will not effect previously rendered DOM.\n */\nexport const render =\n (result: unknown,\n container: Element|DocumentFragment,\n options?: Partial) => {\n let part = parts.get(container);\n if (part === undefined) {\n removeNodes(container, container.firstChild);\n parts.set(container, part = new NodePart({\n templateFactory,\n ...options,\n }));\n part.appendInto(container);\n }\n part.setValue(result);\n part.commit();\n };\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\n/**\n * Module to add shady DOM/shady CSS polyfill support to lit-html template\n * rendering. See the [[render]] method for details.\n *\n * @module shady-render\n * @preferred\n */\n\n/**\n * Do not remove this comment; it keeps typedoc from misplacing the module\n * docs.\n */\nimport {removeNodes} from './dom.js';\nimport {insertNodeIntoTemplate, removeNodesFromTemplate} from './modify-template.js';\nimport {RenderOptions} from './render-options.js';\nimport {parts, render as litRender} from './render.js';\nimport {templateCaches} from './template-factory.js';\nimport {TemplateInstance} from './template-instance.js';\nimport {TemplateResult} from './template-result.js';\nimport {marker, Template} from './template.js';\n\nexport {html, svg, TemplateResult} from '../lit-html.js';\n\n// Get a key to lookup in `templateCaches`.\nconst getTemplateCacheKey = (type: string, scopeName: string) =>\n `${type}--${scopeName}`;\n\nlet compatibleShadyCSSVersion = true;\n\nif (typeof window.ShadyCSS === 'undefined') {\n compatibleShadyCSSVersion = false;\n} else if (typeof window.ShadyCSS.prepareTemplateDom === 'undefined') {\n console.warn(\n `Incompatible ShadyCSS version detected. ` +\n `Please update to at least @webcomponents/webcomponentsjs@2.0.2 and ` +\n `@webcomponents/shadycss@1.3.1.`);\n compatibleShadyCSSVersion = false;\n}\n\n/**\n * Template factory which scopes template DOM using ShadyCSS.\n * @param scopeName {string}\n */\nconst shadyTemplateFactory = (scopeName: string) =>\n (result: TemplateResult) => {\n const cacheKey = getTemplateCacheKey(result.type, scopeName);\n let templateCache = templateCaches.get(cacheKey);\n if (templateCache === undefined) {\n templateCache = {\n stringsArray: new WeakMap(),\n keyString: new Map()\n };\n templateCaches.set(cacheKey, templateCache);\n }\n\n let template = templateCache.stringsArray.get(result.strings);\n if (template !== undefined) {\n return template;\n }\n\n const key = result.strings.join(marker);\n template = templateCache.keyString.get(key);\n if (template === undefined) {\n const element = result.getTemplateElement();\n if (compatibleShadyCSSVersion) {\n window.ShadyCSS!.prepareTemplateDom(element, scopeName);\n }\n template = new Template(result, element);\n templateCache.keyString.set(key, template);\n }\n templateCache.stringsArray.set(result.strings, template);\n return template;\n };\n\nconst TEMPLATE_TYPES = ['html', 'svg'];\n\n/**\n * Removes all style elements from Templates for the given scopeName.\n */\nconst removeStylesFromLitTemplates = (scopeName: string) => {\n TEMPLATE_TYPES.forEach((type) => {\n const templates = templateCaches.get(getTemplateCacheKey(type, scopeName));\n if (templates !== undefined) {\n templates.keyString.forEach((template) => {\n const {element: {content}} = template;\n // IE 11 doesn't support the iterable param Set constructor\n const styles = new Set();\n Array.from(content.querySelectorAll('style')).forEach((s: Element) => {\n styles.add(s);\n });\n removeNodesFromTemplate(template, styles);\n });\n }\n });\n};\n\nconst shadyRenderSet = new Set();\n\n/**\n * For the given scope name, ensures that ShadyCSS style scoping is performed.\n * This is done just once per scope name so the fragment and template cannot\n * be modified.\n * (1) extracts styles from the rendered fragment and hands them to ShadyCSS\n * to be scoped and appended to the document\n * (2) removes style elements from all lit-html Templates for this scope name.\n *\n * Note,