Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.

  • Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
  • Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
  • Internet Explorer/Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
  • Opera: Strg+F5
//<nowiki>
/** vCard-Assistant
 * Source code: https://gitlab.com/muekoeff/vcard-assistant
 * Please report issues and requests preferably at https://gitlab.com/muekoeff/vcard-assistant/-/issues
 */
"use strict";

mw.VcardAssistantConfig.strings = {
    "action-edit": {
        de: "Bearbeiten"
    },
    "action-cancel": {
        de: "Abbrechen"
    },
    "action-copywikitexttoclipboard": {
        de: "In Zwischenablage kopieren"
    },
    "action-copywikitexttoclipboard-description": {
        de: "Den Wikitext der generierten vCard in die Zwischenablage deines Systems kopieren"
    },
    "action-delete": {
        de: "vCard löschen"
    },
    "action-delete-description": {
        de: "Diese vCard aus dem Artikel entfernen"
    },
    "action-discard": {
        de: "Änderungen verwerfen"
    },
    "action-discard-description": {
        de: "Änderungen verwerfen und Assistenten schließen"
    },
    "action-discard-message": {
        de: "Mit Schließen des Assistenten werden deine bisherigen Eingaben verworfen. Möchtest du das wirklich tun?"
    },
    "action-discard-title": {
        de: "Verwerfen von Änderungen"
    },
    "action-formatviolaction-description": {
        de: "Einige deiner Eingaben verletzen die Formatvorgaben. Möchtest du deine Eingaben noch einmal überprüfen? Alternativ kannst du auch direkt zur Vorschau fortfahren, jedoch kann dies zu Fehlern führen."
    },
    "action-formatviolaction-title": {
        de: "Verletzung von Formatvorgaben"
    },
    "action-help": {
        de: "Hilfe"
    },
    "action-help-description": {
        de: "Hilfe zum vCard-Assistant öffnen"
    },
    "action-preview": {
        de: "Vorschau"
    },
    "action-preview-description": {
        de: "Vorschau der finalen vCard anzeigen"
    },
    "action-publish": {
        de: "Änderungen veröffentlichen"
    },
    "action-publish-description": {
        de: "Änderungen in Wikivoyage speichern"
    },
    "action-returnToEdit": {
        de: "Weiter bearbeiten"
    },
    "action-returnToEdit-description": {
        de: "Mit Bearbeiten fortfahren"
    },
    "error-submitApi": {
        de: "Beim Speichern der vCard meldete der Server einen Fehler. Bitte versuche es erneut. ($1: $2)"
    },
    "error-submitBlacklist": {
        de: "Die Sperrliste deine Änderung gemeldet. Bitte überprüfe deine Änderungen und versuche es erneut. ($1)"
    },
    "error-submitEmpty": {
        de: "Der Server lieferte eine leere Antwort beim Speichern der vCard. Bitte versuche es erneut."
    },
    "error-submitHttp": {
        de: "Der Server lieferte einen HTTP-Fehler beim Speichern der vCard. Bitte versuche es erneut. ($1)"
    },
    "error-submitUnknown": {
        de: "Beim Speichern der vCard ist ein unbekannter Fehler ist ein Fehler aufgetreten. Bitte versuche es erneut."
    },
    "format-commons-mayNotIncludePrefixes": {
        de: 'Dieser Parameter darf keine Präfixes wie "Datei:", "File:", "Kategorie:", etc. enthalten'
    },
    "format-date": {
        de: "Bitte verwende das Format JAHR-MONAT-TAG, wobei MONAT und TAG aus zwei Ziffern bestehen."
    },
    "format-obligatoryParameter-description": {
        de: "Dieser Parameter muss ausgefüllt werden"
    },
    "format-wikidataItemId-qxxx": {
        de: "Wikidata-Datenobjekte haben das Format QXXX"
    },
    "list-novalue": {
        de: "(keine Angabe)"
    },
    "list-unknownvalue": {
        de: "$1 (unbekannter Wert)"
    },
    "notify-errorCopyWikitextToClipboard": {
        de: "Kopieren des Wikitexts in die Zwischenablage fehlgeschlagen. Bitte kopiere den Wikitext manuell aus dem entsprechenden Textfeld. Dies geht nach Auswahl des Textes mit der Tastenkombination <kbd>Strg</kbd> + <kbd>C</kbd>."
    },
    "notify-errorSubmit": {
        de: "Beim Speichern der vCard ist ein Fehler aufgetreten."
    },
    "notify-loadingFailed": {
        de: "Fehler beim Laden des vCard-Assistenten"
    },
    "notify-preparing": {
        de: "Assistent wird vorbereitet. Augenblick bitte…"
    },
    "notify-saving": {
        de: "Deine Änderungen werden gerade gespeichert. Du wirst in Kürze weitergeleitet."
    },
    "notify-successCopyWikitextToClipboard": {
        de: "Der Wikitext wurde in die Zwischenablage deines Systems kopiert. Du kannst ihn mithilfe von <kbd>Strg</kbd> + <kbd>D</kbd> einfügen."
    },
    "parameter-forExample": {
        de: "z.B. $1"
    },
    "parameter-markAsUpdated": {
        de: "Als aktualisiert markieren"
    },
    "parameter-markAsUpdated-description": {
        de: "Setzt das Datum der letzten Aktualisierung auf das heutige Datum"
    },
    "parameterButton-add": {
        de: "Diesen Parameter hinzufügen"
    },
    "parameterButton-remove": {
        de: "Diesen Parameter entfernen"
    },
    "preview-action-editSectionWikitext": {
        de: "Wikitext des gesamten Abschnitts vor dem Abspeichern manuell bearbeiten"
    },
    "preview-action-markAsUpdated": {
        de: "Datum der letzten Aktualisierung auf heute setzen"
    },
    "preview-action-minorChanges": {
        de: "Nur Kleinigkeiten wurden verändert (z.B. Tippfehler korrigiert)"
    },
    "preview-generatedCode-title": {
        de: "Generierter Mediawiki-Code"
    },
    "preview-map-description": {
        de: "Auf Karte ansehen"
    },
    "preview-map-markerFromParameter": {
        de: "Als Parameter angegebene Koordinaten"
    },
    "preview-map-markerFromWikidata": {
        de: "Von Wikidata bezogene Koordinaten"
    },
    "preview-prepare": {
        de: "Wird geladen. Augenblick bitte…"
    },
    "preview-summary": {
        de: "Zusammenfassung deiner Änderungen"
    },
    "preview-title": {
        de: "Vorschau"
    },
    "preview-url-description": {
        de: "In neuem Tab öffnen"
    },
    "prompt-delete-text": {
        de: 'Du bist dabei die vCard aus dem Artikel zu entfernen. Bitte gib eine Begründung für diese Löschung ein und klicke auf "Okay" um die Löschung zu bestätigen. Mit Klick auf "Abbrechen" wird die Löschung abgebrochen und du kannst die vCard weiterbearbeiten.'
    },
    "prompt-delete-input-placeholder": {
        de: "Begründung für die Löschung"
    },
    "summary-auto-deleted": {
        de: 'vCard "$1" gelöscht'
    },
    "summary-auto-edited": {
        de: 'vCard "$1" verändert'
    },
    "summary-format": {
        de: "$1 ($2)"
    },
    "warning-notLoggedIn": {
        de: "Du bearbeitest diesen Eintrag ohne angemeldet zu sein. Statt eines Benutzernamens wird die IP-Adresse in der Versionsgeschichte aufgezeichnet."
    },
    "warning-outdated": {
        de: "Dieser Eintrag wurde seit mehr als zwei Jahren nicht mehr als aktualisiert markiert. Falls du Zeit hast, so hilf bitte mit indem du alle Angaben auf Aktualität überprüfst und anschließend das Datum der letzten Änderung aktualisierst."
    },
    "wikidata-canBeObtainedFromWikidata": {
        de: "Diese Information kann von Wikidata bezogen werden"
    },
    "wikidata-editOnWikidata": {
        de: "Information auf Wikidata bearbeiten"
    }
};

"use strict";

function _typeof(obj) {
    "@babel/helpers - typeof";
    return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
        return typeof obj;
    } : function(obj) {
        return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
    }, _typeof(obj);
}

function _regeneratorRuntime() {
    "use strict";
    _regeneratorRuntime = function _regeneratorRuntime() {
        return exports;
    };
    var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
    function define(obj, key, value) {
        return Object.defineProperty(obj, key, {
            value: value,
            enumerable: !0,
            configurable: !0,
            writable: !0
        }), obj[key];
    }
    try {
        define({}, "");
    } catch (err) {
        define = function define(obj, key, value) {
            return obj[key] = value;
        };
    }
    function wrap(innerFn, outerFn, self, tryLocsList) {
        var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []);
        return generator._invoke = function(innerFn, self, context) {
            var state = "suspendedStart";
            return function(method, arg) {
                if ("executing" === state) throw new Error("Generator is already running");
                if ("completed" === state) {
                    if ("throw" === method) throw arg;
                    return doneResult();
                }
                for (context.method = method, context.arg = arg; ;) {
                    var delegate = context.delegate;
                    if (delegate) {
                        var delegateResult = maybeInvokeDelegate(delegate, context);
                        if (delegateResult) {
                            if (delegateResult === ContinueSentinel) continue;
                            return delegateResult;
                        }
                    }
                    if ("next" === context.method) context.sent = context._sent = context.arg; else if ("throw" === context.method) {
                        if ("suspendedStart" === state) throw state = "completed", 
                        context.arg;
                        context.dispatchException(context.arg);
                    } else "return" === context.method && context.abrupt("return", context.arg);
                    state = "executing";
                    var record = tryCatch(innerFn, self, context);
                    if ("normal" === record.type) {
                        if (state = context.done ? "completed" : "suspendedYield", 
                        record.arg === ContinueSentinel) continue;
                        return {
                            value: record.arg,
                            done: context.done
                        };
                    }
                    "throw" === record.type && (state = "completed", context.method = "throw", 
                    context.arg = record.arg);
                }
            };
        }(innerFn, self, context), generator;
    }
    function tryCatch(fn, obj, arg) {
        try {
            return {
                type: "normal",
                arg: fn.call(obj, arg)
            };
        } catch (err) {
            return {
                type: "throw",
                arg: err
            };
        }
    }
    exports.wrap = wrap;
    var ContinueSentinel = {};
    function Generator() {}
    function GeneratorFunction() {}
    function GeneratorFunctionPrototype() {}
    var IteratorPrototype = {};
    define(IteratorPrototype, iteratorSymbol, function() {
        return this;
    });
    var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([])));
    NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
    var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
    function defineIteratorMethods(prototype) {
        [ "next", "throw", "return" ].forEach(function(method) {
            define(prototype, method, function(arg) {
                return this._invoke(method, arg);
            });
        });
    }
    function AsyncIterator(generator, PromiseImpl) {
        function invoke(method, arg, resolve, reject) {
            var record = tryCatch(generator[method], generator, arg);
            if ("throw" !== record.type) {
                var result = record.arg, value = result.value;
                return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function(value) {
                    invoke("next", value, resolve, reject);
                }, function(err) {
                    invoke("throw", err, resolve, reject);
                }) : PromiseImpl.resolve(value).then(function(unwrapped) {
                    result.value = unwrapped, resolve(result);
                }, function(error) {
                    return invoke("throw", error, resolve, reject);
                });
            }
            reject(record.arg);
        }
        var previousPromise;
        this._invoke = function(method, arg) {
            function callInvokeWithMethodAndArg() {
                return new PromiseImpl(function(resolve, reject) {
                    invoke(method, arg, resolve, reject);
                });
            }
            return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
        };
    }
    function maybeInvokeDelegate(delegate, context) {
        var method = delegate.iterator[context.method];
        if (undefined === method) {
            if (context.delegate = null, "throw" === context.method) {
                if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, 
                maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
                context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
            }
            return ContinueSentinel;
        }
        var record = tryCatch(method, delegate.iterator, context.arg);
        if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, 
        context.delegate = null, ContinueSentinel;
        var info = record.arg;
        return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, 
        "return" !== context.method && (context.method = "next", context.arg = undefined), 
        context.delegate = null, ContinueSentinel) : info : (context.method = "throw", 
        context.arg = new TypeError("iterator result is not an object"), context.delegate = null, 
        ContinueSentinel);
    }
    function pushTryEntry(locs) {
        var entry = {
            tryLoc: locs[0]
        };
        1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], 
        entry.afterLoc = locs[3]), this.tryEntries.push(entry);
    }
    function resetTryEntry(entry) {
        var record = entry.completion || {};
        record.type = "normal", delete record.arg, entry.completion = record;
    }
    function Context(tryLocsList) {
        this.tryEntries = [ {
            tryLoc: "root"
        } ], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
    }
    function values(iterable) {
        if (iterable) {
            var iteratorMethod = iterable[iteratorSymbol];
            if (iteratorMethod) return iteratorMethod.call(iterable);
            if ("function" == typeof iterable.next) return iterable;
            if (!isNaN(iterable.length)) {
                var i = -1, next = function next() {
                    for (;++i < iterable.length; ) {
                        if (hasOwn.call(iterable, i)) return next.value = iterable[i], 
                        next.done = !1, next;
                    }
                    return next.value = undefined, next.done = !0, next;
                };
                return next.next = next;
            }
        }
        return {
            next: doneResult
        };
    }
    function doneResult() {
        return {
            value: undefined,
            done: !0
        };
    }
    return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), 
    define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), 
    exports.isGeneratorFunction = function(genFun) {
        var ctor = "function" == typeof genFun && genFun.constructor;
        return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
    }, exports.mark = function(genFun) {
        return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, 
        define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), 
        genFun;
    }, exports.awrap = function(arg) {
        return {
            __await: arg
        };
    }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function() {
        return this;
    }), exports.AsyncIterator = AsyncIterator, exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
        void 0 === PromiseImpl && (PromiseImpl = Promise);
        var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
        return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function(result) {
            return result.done ? result.value : iter.next();
        });
    }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function() {
        return this;
    }), define(Gp, "toString", function() {
        return "[object Generator]";
    }), exports.keys = function(object) {
        var keys = [];
        for (var key in object) {
            keys.push(key);
        }
        return keys.reverse(), function next() {
            for (;keys.length; ) {
                var key = keys.pop();
                if (key in object) return next.value = key, next.done = !1, next;
            }
            return next.done = !0, next;
        };
    }, exports.values = values, Context.prototype = {
        constructor: Context,
        reset: function reset(skipTempReset) {
            if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, 
            this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, 
            this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
                "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
            }
        },
        stop: function stop() {
            this.done = !0;
            var rootRecord = this.tryEntries[0].completion;
            if ("throw" === rootRecord.type) throw rootRecord.arg;
            return this.rval;
        },
        dispatchException: function dispatchException(exception) {
            if (this.done) throw exception;
            var context = this;
            function handle(loc, caught) {
                return record.type = "throw", record.arg = exception, context.next = loc, 
                caught && (context.method = "next", context.arg = undefined), !!caught;
            }
            for (var i = this.tryEntries.length - 1; i >= 0; --i) {
                var entry = this.tryEntries[i], record = entry.completion;
                if ("root" === entry.tryLoc) return handle("end");
                if (entry.tryLoc <= this.prev) {
                    var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc");
                    if (hasCatch && hasFinally) {
                        if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
                        if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
                    } else if (hasCatch) {
                        if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
                    } else {
                        if (!hasFinally) throw new Error("try statement without catch or finally");
                        if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
                    }
                }
            }
        },
        abrupt: function abrupt(type, arg) {
            for (var i = this.tryEntries.length - 1; i >= 0; --i) {
                var entry = this.tryEntries[i];
                if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
                    var finallyEntry = entry;
                    break;
                }
            }
            finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
            var record = finallyEntry ? finallyEntry.completion : {};
            return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", 
            this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
        },
        complete: function complete(record, afterLoc) {
            if ("throw" === record.type) throw record.arg;
            return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, 
            this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), 
            ContinueSentinel;
        },
        finish: function finish(finallyLoc) {
            for (var i = this.tryEntries.length - 1; i >= 0; --i) {
                var entry = this.tryEntries[i];
                if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), 
                resetTryEntry(entry), ContinueSentinel;
            }
        },
        catch: function _catch(tryLoc) {
            for (var i = this.tryEntries.length - 1; i >= 0; --i) {
                var entry = this.tryEntries[i];
                if (entry.tryLoc === tryLoc) {
                    var record = entry.completion;
                    if ("throw" === record.type) {
                        var thrown = record.arg;
                        resetTryEntry(entry);
                    }
                    return thrown;
                }
            }
            throw new Error("illegal catch attempt");
        },
        delegateYield: function delegateYield(iterable, resultName, nextLoc) {
            return this.delegate = {
                iterator: values(iterable),
                resultName: resultName,
                nextLoc: nextLoc
            }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
        }
    }, exports;
}

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
    try {
        var info = gen[key](arg);
        var value = info.value;
    } catch (error) {
        reject(error);
        return;
    }
    if (info.done) {
        resolve(value);
    } else {
        Promise.resolve(value).then(_next, _throw);
    }
}

function _asyncToGenerator(fn) {
    return function() {
        var self = this, args = arguments;
        return new Promise(function(resolve, reject) {
            var gen = fn.apply(self, args);
            function _next(value) {
                asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
            }
            function _throw(err) {
                asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
            }
            _next(undefined);
        });
    };
}

function _slicedToArray(arr, i) {
    return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}

function _nonIterableRest() {
    throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}

function _unsupportedIterableToArray(o, minLen) {
    if (!o) return;
    if (typeof o === "string") return _arrayLikeToArray(o, minLen);
    var n = Object.prototype.toString.call(o).slice(8, -1);
    if (n === "Object" && o.constructor) n = o.constructor.name;
    if (n === "Map" || n === "Set") return Array.from(o);
    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}

function _arrayLikeToArray(arr, len) {
    if (len == null || len > arr.length) len = arr.length;
    for (var i = 0, arr2 = new Array(len); i < len; i++) {
        arr2[i] = arr[i];
    }
    return arr2;
}

function _iterableToArrayLimit(arr, i) {
    var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
    if (_i == null) return;
    var _arr = [];
    var _n = true;
    var _d = false;
    var _s, _e;
    try {
        for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
            _arr.push(_s.value);
            if (i && _arr.length === i) break;
        }
    } catch (err) {
        _d = true;
        _e = err;
    } finally {
        try {
            if (!_n && _i["return"] != null) _i["return"]();
        } finally {
            if (_d) throw _e;
        }
    }
    return _arr;
}

function _arrayWithHoles(arr) {
    if (Array.isArray(arr)) return arr;
}

mw.VcardAssistant = function(vcardAssistantConfig, adaptations) {
    this.vcardAssistantConfig = vcardAssistantConfig;
    this.adaptations = adaptations;
    mw.VcardAssistant.setupStrings(mw.VcardAssistantConfig.strings);
};

mw.VcardAssistant.setupStrings = function(strings) {
    var lang = mw.config.get("wgUserLanguage");
    mw.messages.set(Object.fromEntries(Object.entries(strings).map(function(_ref) {
        var _stringValue$lang;
        var _ref2 = _slicedToArray(_ref, 2), stringKey = _ref2[0], stringValue = _ref2[1];
        return [ "va-msg-".concat(stringKey), (_stringValue$lang = stringValue[lang]) !== null && _stringValue$lang !== void 0 ? _stringValue$lang : stringValue.en ];
    })));
};

mw.VcardAssistant.prototype.editVcard = function(sectionIndex, vcardIndex, displayBlock) {
    var that = this;
    function fail() {
        mw.notify(mw.msg("va-msg-notify-loadingFailed"), {
            tag: "vcardassistant",
            title: "vCard-Assistant",
            type: "error"
        });
    }
    function performSave(dialog, sectionText, editSectionText, summary, autoSummary, isMinor) {
        var finalSummary;
        var sectionName = that.getSectionName(sectionText);
        var sectionPrefix = sectionName === "" ? "" : "/* ".concat(sectionName, " */");
        if (summary !== "") {
            finalSummary = "".concat(sectionPrefix).concat(mw.msg("va-msg-summary-format", summary, autoSummary));
        } else {
            finalSummary = "".concat(sectionPrefix).concat(autoSummary);
        }
        if (editSectionText) {}
        mw.notify(mw.msg("va-msg-notify-saving"), {
            autoHide: false,
            tag: "vcardassistant",
            title: "vCard-Assistant"
        });
        that.saveSection(sectionText, sectionIndex, sectionName, finalSummary, isMinor)["catch"](function(msg) {
            mw.notify(mw.msg("va-msg-notify-errorSubmit"), {
                tag: "vcardassistant",
                title: "vCard-Assistant",
                type: "error"
            });
            OO.ui.alert(msg).done(_asyncToGenerator(_regeneratorRuntime().mark(function _callee() {
                return _regeneratorRuntime().wrap(function _callee$(_context) {
                    while (1) {
                        switch (_context.prev = _context.next) {
                          case 0:
                            dialog.open();
                            dialog.switchForm(dialog.editForm);

                          case 2:
                          case "end":
                            return _context.stop();
                        }
                    }
                }, _callee);
            })));
        });
    }
    return new Promise(function(resolve, reject) {
        mw.loader.using("mediawiki.notification").then(function() {
            var notification = mw.notification.notify(mw.msg("va-msg-notify-preparing"), {
                tag: "vcardassistant",
                title: "vCard-Assistant"
            });
            $.ajax({
                cache: false,
                data: {
                    action: "raw",
                    section: sectionIndex,
                    title: mw.config.get("wgPageName")
                },
                timeout: 3e3,
                url: mw.util.wikiScript("")
            }).done(function() {
                var _ref4 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee2(data) {
                    var _that$stripComments, _that$stripComments2, sectionText, replacements, vcardData, vcardParameters, _yield$mw$VcardAssist, _yield$mw$VcardAssist2, dialog, result, pre, post;
                    return _regeneratorRuntime().wrap(function _callee2$(_context2) {
                        while (1) {
                            switch (_context2.prev = _context2.next) {
                              case 0:
                                _that$stripComments = that.stripComments(data), 
                                _that$stripComments2 = _slicedToArray(_that$stripComments, 2), 
                                sectionText = _that$stripComments2[0], replacements = _that$stripComments2[1];
                                vcardData = that.getVcardInSection(sectionText, vcardIndex);
                                vcardParameters = that.wikitextToParameterMap(vcardData.wikitext, displayBlock, replacements);
                                notification.close();
                                _context2.next = 6;
                                return mw.VcardAssistant.UI.spawn(mw.VcardAssistant.UI.Mode.EDIT, that.vcardAssistantConfig, that.adaptations, vcardParameters);

                              case 6:
                                _yield$mw$VcardAssist = _context2.sent;
                                _yield$mw$VcardAssist2 = _slicedToArray(_yield$mw$VcardAssist, 2);
                                dialog = _yield$mw$VcardAssist2[0];
                                result = _yield$mw$VcardAssist2[1];
                                pre = sectionText.slice(0, vcardData.start);
                                post = sectionText.slice(vcardData.end);
                                if (result.action === mw.VcardAssistant.UI.Result.Action.EDIT) {
                                    performSave(dialog, that.restoreComments("".concat(pre).concat(result.wikitext).concat(post), replacements), result.editSectionWikitext, result.summary, mw.msg("va-msg-summary-auto-edited", result.displayName), result.isMinorEdit);
                                } else if (result.action === mw.VcardAssistant.UI.Result.Action.DELETE) {
                                    pre = that.removeVcardResidues(pre);
                                    performSave(dialog, that.restoreComments("".concat(pre).concat(post), replacements), false, result.summary, mw.msg("va-msg-summary-auto-deleted", result.displayName), false);
                                } else {
                                    mw.log.error("[VcardAssistant] Unexpected action returned by UI: ".concat(result.action), result);
                                }

                              case 13:
                              case "end":
                                return _context2.stop();
                            }
                        }
                    }, _callee2);
                }));
                return function(_x) {
                    return _ref4.apply(this, arguments);
                };
            }()).fail(function(e, message) {
                mw.log.error("[VcardAssistant]", message);
                fail();
                reject(e);
            });
        });
    });
};

mw.VcardAssistant.prototype.findPatternMatch = function(value, startPattern, endPattern) {
    var matchString = "";
    var startRegex = new RegExp("^" + this.replaceSpecial(startPattern), "i");
    if (startRegex.test(value)) {
        var endRegex = new RegExp("^" + this.replaceSpecial(endPattern), "i");
        var matchCount = 1;
        for (var i = startPattern.length; i < value.length; i++) {
            var remainingValue = value.slice(i);
            if (startRegex.test(remainingValue)) {
                matchCount++;
            } else if (endRegex.test(remainingValue)) {
                matchCount--;
            }
            if (matchCount === 0) {
                matchString = value.slice(0, i);
                break;
            }
        }
    }
    return matchString;
};

mw.VcardAssistant.prototype.getSectionName = function(sectionText) {
    var headingRegexp = /^=+\s*([^=]+)\s*=+\s*\n/;
    var result = headingRegexp.exec(sectionText);
    return result !== null ? result[1].trim() : "";
};

mw.VcardAssistant.prototype.getVcardTypesRegexp = function() {
    return new RegExp("({{\\s*(" + Object.keys(this.vcardAssistantConfig.config.templateToType).join("|") + ")\\b)(\\s*[\\|}])", "ig");
};

mw.VcardAssistant.prototype.getVcardInSection = function(sectionText, vcardIndex) {
    var listingRegex = this.getVcardTypesRegexp();
    var listingSyntax, regexResult, listingMatchIndex;
    for (var i = 0; i <= vcardIndex; i++) {
        regexResult = listingRegex.exec(sectionText);
        listingMatchIndex = regexResult.index;
        listingSyntax = regexResult[1];
    }
    var curlyBraceCount = 2;
    var endPos = sectionText.length;
    var startPos = listingMatchIndex + listingSyntax.length;
    var matchFound = false;
    var vcardEndPos = sectionText.length;
    for (var j = startPos; j < endPos; j++) {
        if (sectionText[j] === "{") {
            ++curlyBraceCount;
        } else if (sectionText[j] === "}") {
            --curlyBraceCount;
        }
        if (curlyBraceCount === 0 && j + 1 < endPos) {
            listingSyntax = sectionText.slice(listingMatchIndex, j + 1);
            matchFound = true;
            vcardEndPos = j + 1;
            break;
        }
    }
    if (!matchFound) {
        listingSyntax = sectionText.slice(listingMatchIndex);
        vcardEndPos = sectionText.length;
    }
    return {
        end: vcardEndPos,
        start: listingMatchIndex,
        wikitext: listingSyntax.trim()
    };
};

mw.VcardAssistant.prototype.listingTemplateToParamsArray = function(vcardWikiSyntax) {
    var results = [];
    var paramValue = "";
    var pos = 0;
    while (pos < vcardWikiSyntax.length) {
        var remainingString = vcardWikiSyntax.slice(pos);
        var patternMatch = this.findPatternMatch(remainingString, "{{", "}}");
        if (patternMatch.length === 0) {
            patternMatch = this.findPatternMatch(remainingString, "[[", "]]");
        }
        if (patternMatch.length) {
            paramValue += patternMatch;
            pos += patternMatch.length;
        } else if (vcardWikiSyntax.charAt(pos) === "|") {
            results.push(paramValue);
            paramValue = "";
            pos++;
        } else {
            paramValue += vcardWikiSyntax.charAt(pos);
            pos++;
        }
    }
    if (paramValue.length) {
        results.push(paramValue);
    }
    return results;
};

mw.VcardAssistant.prototype.removeCtrls = function(str, isContent, displayBlock) {
    if (displayBlock && isContent) {
        str = str.replace(/[\x00-\x09\x0B\x0C\x0E\x0F\x7F]/g, " ");
    } else {
        str = str.replace(/(<\/?br[^%/>]*\/*>|<\/?p[^%/>]*\/*>)/g, " ");
        if (!str.includes("<span")) {
            str = str.replace(/[\x00-\x0F\x7F]/g, " ");
        }
    }
    return str.trim().replace(/ {2,}/g, " ");
};

mw.VcardAssistant.prototype.removeVcardResidues = function(str) {
    return str.replace(/(\n+[:*#]*)?\s*$/, "");
};

mw.VcardAssistant.prototype.replaceSpecial = function(str) {
    return str.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&");
};

mw.VcardAssistant.prototype.restoreComments = function(text, replacements) {
    for (var key in replacements) {
        var val = replacements[key];
        text = text.replace(key, val);
    }
    return text;
};

mw.VcardAssistant.prototype.saveSection = function(sectionText, sectionIndex, sectionName, summary, isMinor) {
    var api = new mw.Api();
    return new Promise(function(resolve, reject) {
        api.postWithToken("csrf", {
            action: "edit",
            title: mw.config.get("wgPageName"),
            section: sectionIndex,
            text: sectionText,
            summary: summary,
            minor: isMinor
        }).done(function(data) {
            if (data && data.edit && data.edit.result === "Success") {
                var canonicalUrl = $('link[rel="canonical"]').attr("href");
                var currentUrlWithoutHash = window.location.href.replace(window.location.hash, "");
                var sectionHash = sectionName !== "" ? "#".concat(mw.util.escapeIdForLink(sectionName)) : "";
                var url = new URL(window.location.href);
                if (canonicalUrl && currentUrlWithoutHash !== canonicalUrl) {
                    window.location.href = "".concat(canonicalUrl, "?vcardassistant=saved").concat(sectionHash);
                } else if (url.searchParams.get("vcardassistant") === "saved") {
                    window.location.hash = sectionHash;
                    window.location.reload();
                } else {
                    window.location = "?vcardassistant=saved".concat(sectionHash);
                }
                resolve();
            } else if (data && data.error) {
                reject(mw.msg("va-msg-error-submitApi", data.error.code, data.error.info));
            } else if (data && data.edit.spamblacklist) {
                reject(mw.msg("va-msg-error-submitBlacklist", data.edit.spamblacklist));
            } else if (data && data.edit.captcha) {} else {
                reject(mw.msg("va-msg-error-submitUnknown"));
            }
        }).fail(function(code, result) {
            if (code === "http") {
                reject(mw.msg("va-msg-error-submitHttp", result.textStatus));
            } else if (code === "ok-but-empty") {
                reject(mw.msg("va-msg-error-submitEmpty"));
            } else {
                reject(mw.msg("va-msg-error-submitUnknown"));
            }
        });
    });
};

mw.VcardAssistant.prototype.stripComments = function(text) {
    var comments = text.match(/<!--[\s\S]*?-->/gim);
    var replacements = [];
    if (comments !== null) {
        for (var i = 0; i < comments.length; i++) {
            var comment = comments[i];
            var rep = "<<<COMMENT" + i + ">>>";
            text = text.replace(comment, rep);
            replacements[rep] = comment;
        }
    }
    return [ text, replacements ];
};

mw.VcardAssistant.prototype.wikitextToParameterMap = function(vcardWikiSyntax, displayBlock, replacements) {
    vcardWikiSyntax = vcardWikiSyntax.slice(0, -2);
    var vcardAsParameterMap = {};
    var listParams = this.listingTemplateToParamsArray(vcardWikiSyntax);
    var lastKey = null;
    var lastUnnamedParameterIndex = 0;
    for (var j = 1; j < listParams.length; j++) {
        var param = listParams[j];
        var index = param.indexOf("=");
        if (index > 0) {
            var key = param.slice(0, index).trim();
            var value = param.slice(index + 1).trim();
            vcardAsParameterMap[key] = value;
            lastKey = key;
        } else if (lastKey !== null && vcardAsParameterMap[lastKey].length > 0) {
            vcardAsParameterMap[lastKey] += "|" + param;
        } else {
            lastUnnamedParameterIndex++;
            while (Object.keys(vcardAsParameterMap).includes(lastUnnamedParameterIndex.toString())) {
                lastUnnamedParameterIndex++;
            }
            vcardAsParameterMap[lastUnnamedParameterIndex] = param;
        }
    }
    for (var _key in vcardAsParameterMap) {
        vcardAsParameterMap[_key] = this.restoreComments(vcardAsParameterMap[_key], replacements);
    }
    for (var categoryName in this.vcardAssistantConfig.parameters.categories) {
        for (var parameterName in this.vcardAssistantConfig.parameters.categories[categoryName]) {
            if (vcardAsParameterMap[parameterName] !== undefined) {
                if (typeof this.vcardAssistantConfig.parameters.categories[categoryName][parameterName].multiline === "number") {
                    vcardAsParameterMap[parameterName] = this.removeCtrls(vcardAsParameterMap[parameterName], true, displayBlock);
                    vcardAsParameterMap[parameterName] = vcardAsParameterMap[parameterName].replace(/\s*<p>\s*/g, "\n\n");
                } else {
                    vcardAsParameterMap[parameterName] = this.removeCtrls(vcardAsParameterMap[parameterName], false, displayBlock);
                }
            }
        }
    }
    return vcardAsParameterMap;
};

"use strict";

function _typeof(obj) {
    "@babel/helpers - typeof";
    return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
        return typeof obj;
    } : function(obj) {
        return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
    }, _typeof(obj);
}

function _regeneratorRuntime() {
    "use strict";
    _regeneratorRuntime = function _regeneratorRuntime() {
        return exports;
    };
    var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
    function define(obj, key, value) {
        return Object.defineProperty(obj, key, {
            value: value,
            enumerable: !0,
            configurable: !0,
            writable: !0
        }), obj[key];
    }
    try {
        define({}, "");
    } catch (err) {
        define = function define(obj, key, value) {
            return obj[key] = value;
        };
    }
    function wrap(innerFn, outerFn, self, tryLocsList) {
        var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []);
        return generator._invoke = function(innerFn, self, context) {
            var state = "suspendedStart";
            return function(method, arg) {
                if ("executing" === state) throw new Error("Generator is already running");
                if ("completed" === state) {
                    if ("throw" === method) throw arg;
                    return doneResult();
                }
                for (context.method = method, context.arg = arg; ;) {
                    var delegate = context.delegate;
                    if (delegate) {
                        var delegateResult = maybeInvokeDelegate(delegate, context);
                        if (delegateResult) {
                            if (delegateResult === ContinueSentinel) continue;
                            return delegateResult;
                        }
                    }
                    if ("next" === context.method) context.sent = context._sent = context.arg; else if ("throw" === context.method) {
                        if ("suspendedStart" === state) throw state = "completed", 
                        context.arg;
                        context.dispatchException(context.arg);
                    } else "return" === context.method && context.abrupt("return", context.arg);
                    state = "executing";
                    var record = tryCatch(innerFn, self, context);
                    if ("normal" === record.type) {
                        if (state = context.done ? "completed" : "suspendedYield", 
                        record.arg === ContinueSentinel) continue;
                        return {
                            value: record.arg,
                            done: context.done
                        };
                    }
                    "throw" === record.type && (state = "completed", context.method = "throw", 
                    context.arg = record.arg);
                }
            };
        }(innerFn, self, context), generator;
    }
    function tryCatch(fn, obj, arg) {
        try {
            return {
                type: "normal",
                arg: fn.call(obj, arg)
            };
        } catch (err) {
            return {
                type: "throw",
                arg: err
            };
        }
    }
    exports.wrap = wrap;
    var ContinueSentinel = {};
    function Generator() {}
    function GeneratorFunction() {}
    function GeneratorFunctionPrototype() {}
    var IteratorPrototype = {};
    define(IteratorPrototype, iteratorSymbol, function() {
        return this;
    });
    var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([])));
    NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
    var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
    function defineIteratorMethods(prototype) {
        [ "next", "throw", "return" ].forEach(function(method) {
            define(prototype, method, function(arg) {
                return this._invoke(method, arg);
            });
        });
    }
    function AsyncIterator(generator, PromiseImpl) {
        function invoke(method, arg, resolve, reject) {
            var record = tryCatch(generator[method], generator, arg);
            if ("throw" !== record.type) {
                var result = record.arg, value = result.value;
                return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function(value) {
                    invoke("next", value, resolve, reject);
                }, function(err) {
                    invoke("throw", err, resolve, reject);
                }) : PromiseImpl.resolve(value).then(function(unwrapped) {
                    result.value = unwrapped, resolve(result);
                }, function(error) {
                    return invoke("throw", error, resolve, reject);
                });
            }
            reject(record.arg);
        }
        var previousPromise;
        this._invoke = function(method, arg) {
            function callInvokeWithMethodAndArg() {
                return new PromiseImpl(function(resolve, reject) {
                    invoke(method, arg, resolve, reject);
                });
            }
            return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
        };
    }
    function maybeInvokeDelegate(delegate, context) {
        var method = delegate.iterator[context.method];
        if (undefined === method) {
            if (context.delegate = null, "throw" === context.method) {
                if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, 
                maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
                context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
            }
            return ContinueSentinel;
        }
        var record = tryCatch(method, delegate.iterator, context.arg);
        if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, 
        context.delegate = null, ContinueSentinel;
        var info = record.arg;
        return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, 
        "return" !== context.method && (context.method = "next", context.arg = undefined), 
        context.delegate = null, ContinueSentinel) : info : (context.method = "throw", 
        context.arg = new TypeError("iterator result is not an object"), context.delegate = null, 
        ContinueSentinel);
    }
    function pushTryEntry(locs) {
        var entry = {
            tryLoc: locs[0]
        };
        1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], 
        entry.afterLoc = locs[3]), this.tryEntries.push(entry);
    }
    function resetTryEntry(entry) {
        var record = entry.completion || {};
        record.type = "normal", delete record.arg, entry.completion = record;
    }
    function Context(tryLocsList) {
        this.tryEntries = [ {
            tryLoc: "root"
        } ], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
    }
    function values(iterable) {
        if (iterable) {
            var iteratorMethod = iterable[iteratorSymbol];
            if (iteratorMethod) return iteratorMethod.call(iterable);
            if ("function" == typeof iterable.next) return iterable;
            if (!isNaN(iterable.length)) {
                var i = -1, next = function next() {
                    for (;++i < iterable.length; ) {
                        if (hasOwn.call(iterable, i)) return next.value = iterable[i], 
                        next.done = !1, next;
                    }
                    return next.value = undefined, next.done = !0, next;
                };
                return next.next = next;
            }
        }
        return {
            next: doneResult
        };
    }
    function doneResult() {
        return {
            value: undefined,
            done: !0
        };
    }
    return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), 
    define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), 
    exports.isGeneratorFunction = function(genFun) {
        var ctor = "function" == typeof genFun && genFun.constructor;
        return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
    }, exports.mark = function(genFun) {
        return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, 
        define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), 
        genFun;
    }, exports.awrap = function(arg) {
        return {
            __await: arg
        };
    }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function() {
        return this;
    }), exports.AsyncIterator = AsyncIterator, exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
        void 0 === PromiseImpl && (PromiseImpl = Promise);
        var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
        return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function(result) {
            return result.done ? result.value : iter.next();
        });
    }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function() {
        return this;
    }), define(Gp, "toString", function() {
        return "[object Generator]";
    }), exports.keys = function(object) {
        var keys = [];
        for (var key in object) {
            keys.push(key);
        }
        return keys.reverse(), function next() {
            for (;keys.length; ) {
                var key = keys.pop();
                if (key in object) return next.value = key, next.done = !1, next;
            }
            return next.done = !0, next;
        };
    }, exports.values = values, Context.prototype = {
        constructor: Context,
        reset: function reset(skipTempReset) {
            if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, 
            this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, 
            this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
                "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
            }
        },
        stop: function stop() {
            this.done = !0;
            var rootRecord = this.tryEntries[0].completion;
            if ("throw" === rootRecord.type) throw rootRecord.arg;
            return this.rval;
        },
        dispatchException: function dispatchException(exception) {
            if (this.done) throw exception;
            var context = this;
            function handle(loc, caught) {
                return record.type = "throw", record.arg = exception, context.next = loc, 
                caught && (context.method = "next", context.arg = undefined), !!caught;
            }
            for (var i = this.tryEntries.length - 1; i >= 0; --i) {
                var entry = this.tryEntries[i], record = entry.completion;
                if ("root" === entry.tryLoc) return handle("end");
                if (entry.tryLoc <= this.prev) {
                    var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc");
                    if (hasCatch && hasFinally) {
                        if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
                        if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
                    } else if (hasCatch) {
                        if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
                    } else {
                        if (!hasFinally) throw new Error("try statement without catch or finally");
                        if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
                    }
                }
            }
        },
        abrupt: function abrupt(type, arg) {
            for (var i = this.tryEntries.length - 1; i >= 0; --i) {
                var entry = this.tryEntries[i];
                if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
                    var finallyEntry = entry;
                    break;
                }
            }
            finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
            var record = finallyEntry ? finallyEntry.completion : {};
            return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", 
            this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
        },
        complete: function complete(record, afterLoc) {
            if ("throw" === record.type) throw record.arg;
            return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, 
            this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), 
            ContinueSentinel;
        },
        finish: function finish(finallyLoc) {
            for (var i = this.tryEntries.length - 1; i >= 0; --i) {
                var entry = this.tryEntries[i];
                if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), 
                resetTryEntry(entry), ContinueSentinel;
            }
        },
        catch: function _catch(tryLoc) {
            for (var i = this.tryEntries.length - 1; i >= 0; --i) {
                var entry = this.tryEntries[i];
                if (entry.tryLoc === tryLoc) {
                    var record = entry.completion;
                    if ("throw" === record.type) {
                        var thrown = record.arg;
                        resetTryEntry(entry);
                    }
                    return thrown;
                }
            }
            throw new Error("illegal catch attempt");
        },
        delegateYield: function delegateYield(iterable, resultName, nextLoc) {
            return this.delegate = {
                iterator: values(iterable),
                resultName: resultName,
                nextLoc: nextLoc
            }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
        }
    }, exports;
}

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
    try {
        var info = gen[key](arg);
        var value = info.value;
    } catch (error) {
        reject(error);
        return;
    }
    if (info.done) {
        resolve(value);
    } else {
        Promise.resolve(value).then(_next, _throw);
    }
}

function _asyncToGenerator(fn) {
    return function() {
        var self = this, args = arguments;
        return new Promise(function(resolve, reject) {
            var gen = fn.apply(self, args);
            function _next(value) {
                asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
            }
            function _throw(err) {
                asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
            }
            _next(undefined);
        });
    };
}

mw.VcardAssistant.UI = function(mode, windowManager, vcardAssistantConfig, resolve, reject, adaptations, prefill, config) {
    mw.VcardAssistant.UI["static"].actions = [ {
        action: "close",
        flags: [ "close", "safe" ],
        icon: "close",
        invisibleLabel: true,
        label: mw.msg("va-msg-action-discard"),
        modes: [ "edit", "preview" ],
        title: mw.msg("va-msg-action-discard-description")
    }, {
        action: "returntoedit",
        flags: [ "back", "safe" ],
        icon: "previous",
        label: mw.msg("va-msg-action-returnToEdit"),
        modes: "preview",
        title: mw.msg("va-msg-action-returnToEdit-description")
    }, {
        action: "help",
        framed: false,
        href: vcardAssistantConfig.config.helpurl,
        icon: "info",
        label: mw.msg("va-msg-action-help"),
        modes: [ "edit", "preview" ],
        title: mw.msg("va-msg-action-help-description")
    }, {
        action: "preview",
        flags: [ "primary", "progressive" ],
        icon: "eye",
        label: mw.msg("va-msg-action-preview"),
        modes: "edit",
        title: mw.msg("va-msg-action-preview-description")
    } ];
    if (mode === mw.VcardAssistant.UI.Mode.EDIT) {
        mw.VcardAssistant.UI["static"].actions.push({
            action: "delete",
            flags: [ "destructive" ],
            icon: "trash",
            label: mw.msg("va-msg-action-delete"),
            modes: "edit",
            title: mw.msg("va-msg-action-delete-description")
        });
    }
    if (mode === mw.VcardAssistant.UI.Mode.CREATE || mode === mw.VcardAssistant.UI.Mode.EDIT) {
        mw.VcardAssistant.UI["static"].actions.push({
            action: "save",
            flags: [ "primary", "progressive" ],
            icon: "check",
            label: mw.msg("va-msg-action-publish"),
            modes: "preview",
            title: mw.msg("va-msg-action-publish-description")
        });
    } else if (mode === mw.VcardAssistant.UI.Mode.TOOL) {
        mw.VcardAssistant.UI["static"].actions.push({
            action: "copytoclipboard",
            flags: [ "primary", "progressive" ],
            icon: "code",
            label: mw.msg("va-msg-action-copywikitexttoclipboard"),
            modes: "preview",
            title: mw.msg("va-msg-action-copywikitexttoclipboard-description")
        });
    }
    mw.VcardAssistant.UI["static"].title = vcardAssistantConfig.config.title;
    mw.VcardAssistant.UI.parent.call(this, config);
    this.adaptations = adaptations;
    this.mode = mode;
    this.prefill = prefill || null;
    this.vcardAssistantConfig = vcardAssistantConfig;
    this.resolve = resolve;
    this.reject = reject;
    this.windowManager = windowManager;
};

OO.inheritClass(mw.VcardAssistant.UI, OO.ui.ProcessDialog);

mw.VcardAssistant.UI["static"].name = "vcardAssistant";

mw.VcardAssistant.UI["static"].size = "larger";

mw.VcardAssistant.UI.ExitStatus = {
    CANCELLED: "cancelled"
};

mw.VcardAssistant.UI.Mode = {
    CREATE: "create",
    EDIT: "edit",
    TOOL: "tool"
};

mw.VcardAssistant.UI.prototype.initialize = function() {
    mw.VcardAssistant.UI.parent.prototype.initialize.apply(this, arguments);
    this.$body.addClass("ext-vcardassistant");
    this.editForm = new mw.VcardAssistant.UI.EditForm(this.vcardAssistantConfig, this.adaptations, this.prefill);
    this.previewForm = new mw.VcardAssistant.UI.PreviewForm(this.vcardAssistantConfig, this.editForm.parameters, this.vcardAssistantConfig.parameters.order, this.editForm.neverOmitParameters, this.editForm);
    this.actions.setMode("edit");
    this.$body.html(this.editForm.$element);
    this.editForm.$element.added = true;
};

mw.VcardAssistant.UI.prototype.getSetupProcess = function(data) {
    return mw.VcardAssistant.UI.parent.prototype.getSetupProcess.call(this, data).next(function() {
        this.actions.setMode("edit");
    }, this);
};

mw.VcardAssistant.UI.prototype.getActionProcess = function(action) {
    var _this = this;
    var that = this;
    switch (action) {
      case "close":
        return new OO.ui.Process(function() {
            return new Promise(function(resolve) {
                if (_this.editForm.countChanges() > 1) {
                    var windowManager = new OO.ui.WindowManager();
                    $(document.body).append(windowManager.$element);
                    var messageDialog = new OO.ui.MessageDialog();
                    messageDialog.getActionProcess = function(dialogAction) {
                        switch (dialogAction) {
                          case "close":
                            return new OO.ui.Process(function() {
                                _this.close({
                                    action: dialogAction
                                });
                                _this.reject(mw.VcardAssistant.UI.ExitStatus.CANCELLED);
                                windowManager.destroy();
                                resolve();
                            });

                          case "edit":
                            return new OO.ui.Process(function() {
                                windowManager.destroy();
                                resolve();
                            });
                        }
                    };
                    windowManager.addWindows([ messageDialog ]);
                    windowManager.openWindow(messageDialog, {
                        title: mw.msg("va-msg-action-discard-title"),
                        message: mw.msg("va-msg-action-discard-message"),
                        actions: [ {
                            action: "close",
                            flags: [ "destructive" ],
                            icon: "trash",
                            label: mw.msg("va-msg-action-discard"),
                            title: mw.msg("va-msg-action-discard-description")
                        }, {
                            action: "edit",
                            flags: [ "primary", "safe" ],
                            label: mw.msg("va-msg-action-returnToEdit"),
                            title: mw.msg("va-msg-action-returnToEdit-description")
                        } ]
                    });
                } else {
                    that.close({
                        action: action
                    });
                    that.reject(mw.VcardAssistant.UI.ExitStatus.CANCELLED);
                }
            });
        });

      case "copytoclipboard":
        return new OO.ui.Process(_asyncToGenerator(_regeneratorRuntime().mark(function _callee() {
            return _regeneratorRuntime().wrap(function _callee$(_context) {
                while (1) {
                    switch (_context.prev = _context.next) {
                      case 0:
                        _context.prev = 0;
                        _context.next = 3;
                        return navigator.clipboard.writeText(that.previewForm.getWikitext());

                      case 3:
                        _context.next = 9;
                        break;

                      case 5:
                        _context.prev = 5;
                        _context.t0 = _context["catch"](0);
                        mw.notify($("<span>".concat(mw.msg("va-msg-notify-errorCopyWikitextToClipboard"), "</span>")), {
                            tag: "vcardassistant",
                            title: "vCard-Assistant",
                            type: "error"
                        });
                        return _context.abrupt("return");

                      case 9:
                        mw.notify($("<span>".concat(mw.msg("va-msg-notify-successCopyWikitextToClipboard"), "</span>")), {
                            tag: "vcardassistant",
                            title: "vCard-Assistant"
                        });
                        that.close({
                            action: action
                        });
                        that.resolve(mw.VcardAssistant.UI.Result.tool(that.previewForm.getDisplayName(), that.previewForm.getWikitext(), that.previewForm.getParameters(), !that.editForm.validate()));

                      case 12:
                      case "end":
                        return _context.stop();
                    }
                }
            }, _callee, null, [ [ 0, 5 ] ]);
        })));

      case "delete":
        return new OO.ui.Process(_asyncToGenerator(_regeneratorRuntime().mark(function _callee2() {
            return _regeneratorRuntime().wrap(function _callee2$(_context2) {
                while (1) {
                    switch (_context2.prev = _context2.next) {
                      case 0:
                        that.close({
                            action: action
                        });
                        OO.ui.prompt(mw.msg("va-msg-prompt-delete-text"), {
                            textInput: {
                                placeholder: mw.msg("va-msg-prompt-delete-input-placeholder")
                            }
                        }).done(function(result) {
                            if (result !== null) {
                                that.resolve(mw.VcardAssistant.UI.Result["delete"](that.prefill !== null ? that.prefill[that.vcardAssistantConfig.special_parameters.name] : null, result));
                            } else {
                                that.open();
                            }
                        });

                      case 2:
                      case "end":
                        return _context2.stop();
                    }
                }
            }, _callee2);
        })));

      case "help":
        return new OO.ui.Process(function() {
            window.open(that.vcardAssistantConfig.config.helpurl, "_blank");
        });

      case "preview":
        return new OO.ui.Process(function() {
            return new Promise(function(resolve, reject) {
                function moveToPreview() {
                    return _moveToPreview.apply(this, arguments);
                }
                function _moveToPreview() {
                    _moveToPreview = _asyncToGenerator(_regeneratorRuntime().mark(function _callee3() {
                        return _regeneratorRuntime().wrap(function _callee3$(_context3) {
                            while (1) {
                                switch (_context3.prev = _context3.next) {
                                  case 0:
                                    that.actions.setMode("preview");
                                    that.setSize("medium");
                                    that.switchForm(that.previewForm);
                                    _context3.next = 5;
                                    return that.previewForm.updatePreview();

                                  case 5:
                                  case "end":
                                    return _context3.stop();
                                }
                            }
                        }, _callee3);
                    }));
                    return _moveToPreview.apply(this, arguments);
                }
                if (that.editForm.validate()) {
                    moveToPreview().then(resolve, reject);
                } else {
                    var windowManager = new OO.ui.WindowManager();
                    $(document.body).append(windowManager.$element);
                    var messageDialog = new OO.ui.MessageDialog();
                    messageDialog.getActionProcess = function(dialogAction) {
                        switch (dialogAction) {
                          case "edit":
                            return new OO.ui.Process(function() {
                                messageDialog.close({
                                    action: dialogAction
                                });
                                windowManager.destroy();
                                resolve();
                            });

                          case "preview":
                            return new OO.ui.Process(function() {
                                messageDialog.close({
                                    action: action
                                });
                                windowManager.destroy();
                                moveToPreview().then(resolve, reject);
                            });
                        }
                    };
                    windowManager.addWindows([ messageDialog ]);
                    windowManager.openWindow(messageDialog, {
                        title: mw.msg("va-msg-action-formatviolaction-title"),
                        message: mw.msg("va-msg-action-formatviolaction-description"),
                        actions: [ {
                            action: "edit",
                            flags: [ "primary", "safe" ],
                            label: mw.msg("va-msg-action-returnToEdit"),
                            title: mw.msg("va-msg-action-returnToEdit-description")
                        }, {
                            action: "preview",
                            flags: [ "progressive" ],
                            label: mw.msg("va-msg-action-preview"),
                            title: mw.msg("va-msg-action-preview-description")
                        } ]
                    });
                }
            });
        });

      case "returntoedit":
        return new OO.ui.Process(_asyncToGenerator(_regeneratorRuntime().mark(function _callee4() {
            return _regeneratorRuntime().wrap(function _callee4$(_context4) {
                while (1) {
                    switch (_context4.prev = _context4.next) {
                      case 0:
                        that.actions.setMode("edit");
                        that.setSize("larger");
                        that.switchForm(that.editForm);

                      case 3:
                      case "end":
                        return _context4.stop();
                    }
                }
            }, _callee4);
        })));

      case "save":
        return new OO.ui.Process(function() {
            that.close({
                action: action
            });
            that.resolve(mw.VcardAssistant.UI.Result.edit(that.previewForm.getDisplayName(), that.previewForm.getWikitext(), that.previewForm.getParameters(), that.previewForm.getSummary(), that.previewForm.isMinorEdit(), !that.editForm.validate(), that.previewForm.isEditSectionWikitext()));
        });

      default:
        mw.log.error("[VcardAssistant] Unknown action: ".concat(action));
        return mw.VcardAssistant.UI.parent.prototype.getActionProcess.call(this, action);
    }
};

mw.VcardAssistant.UI.prototype.getBodyHeight = function() {
    return 500;
};

mw.VcardAssistant.UI.prototype.switchForm = function(newForm) {
    this.$body.children().hide();
    this.$body.children().removeClass("switchform");
    if (typeof newForm.$element.added !== "undefined") {
        newForm.$element.addClass("switchform");
        newForm.$element.show();
    } else {
        newForm.$element.added = true;
        this.$body.append(newForm.$element);
    }
    if (typeof newForm.focus === "function") {
        newForm.focus();
    }
};

mw.VcardAssistant.UI.spawn = function(mode, vcardAssistantConfig, adaptations, prefill) {
    return new Promise(function(resolve, reject) {
        var windowManager = new OO.ui.WindowManager();
        $(document.body).append(windowManager.$element);
        var dialog = new mw.VcardAssistant.UI(mode, windowManager, vcardAssistantConfig, function(result) {
            resolve([ dialog, result ]);
        }, reject, adaptations, prefill);
        windowManager.addWindows([ dialog ]);
        windowManager.openWindow(dialog);
    });
};

"use strict";

function _createForOfIteratorHelper(o, allowArrayLike) {
    var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
    if (!it) {
        if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
            if (it) o = it;
            var i = 0;
            var F = function F() {};
            return {
                s: F,
                n: function n() {
                    if (i >= o.length) return {
                        done: true
                    };
                    return {
                        done: false,
                        value: o[i++]
                    };
                },
                e: function e(_e) {
                    throw _e;
                },
                f: F
            };
        }
        throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
    }
    var normalCompletion = true, didErr = false, err;
    return {
        s: function s() {
            it = it.call(o);
        },
        n: function n() {
            var step = it.next();
            normalCompletion = step.done;
            return step;
        },
        e: function e(_e2) {
            didErr = true;
            err = _e2;
        },
        f: function f() {
            try {
                if (!normalCompletion && it["return"] != null) it["return"]();
            } finally {
                if (didErr) throw err;
            }
        }
    };
}

function _unsupportedIterableToArray(o, minLen) {
    if (!o) return;
    if (typeof o === "string") return _arrayLikeToArray(o, minLen);
    var n = Object.prototype.toString.call(o).slice(8, -1);
    if (n === "Object" && o.constructor) n = o.constructor.name;
    if (n === "Map" || n === "Set") return Array.from(o);
    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}

function _arrayLikeToArray(arr, len) {
    if (len == null || len > arr.length) len = arr.length;
    for (var i = 0, arr2 = new Array(len); i < len; i++) {
        arr2[i] = arr[i];
    }
    return arr2;
}

mw.VcardAssistant.Util = {};

mw.VcardAssistant.Util.globalConfig = function(setting) {
    if (window.vcardassistantconfig === undefined) {
        return null;
    } else {
        return window.vcardassistantconfig[setting];
    }
};

mw.VcardAssistant.Util.on = function(emitters, events, handler) {
    if (!Array.isArray(emitters)) {
        emitters = [ emitters ];
    }
    if (!Array.isArray(events)) {
        events = [ events ];
    }
    var _iterator = _createForOfIteratorHelper(emitters), _step;
    try {
        for (_iterator.s(); !(_step = _iterator.n()).done; ) {
            var emitter = _step.value;
            var _iterator2 = _createForOfIteratorHelper(events), _step2;
            try {
                for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) {
                    var event = _step2.value;
                    emitter.on(event, handler);
                }
            } catch (err) {
                _iterator2.e(err);
            } finally {
                _iterator2.f();
            }
        }
    } catch (err) {
        _iterator.e(err);
    } finally {
        _iterator.f();
    }
};

"use strict";

mw.VcardAssistant.UI.CommonsSearchField = function(prefix, namespace, config) {
    mw.VcardAssistant.UI.CommonsSearchField["super"].call(this, config);
    OO.ui.mixin.LookupElement.call(this);
    this.prefix = prefix;
    this.namespace = namespace;
};

OO.inheritClass(mw.VcardAssistant.UI.CommonsSearchField, OO.ui.ComboBoxInputWidget);

OO.mixinClass(mw.VcardAssistant.UI.CommonsSearchField, OO.ui.mixin.LookupElement);

mw.VcardAssistant.UI.CommonsSearchField.prototype.getLookupRequest = function() {
    return $.ajax({
        data: {
            action: "opensearch",
            format: "json",
            namespace: this.namespace,
            origin: "*",
            redirects: "resolve",
            search: this.getValue()
        },
        url: "https://commons.wikimedia.org/w/api.php"
    });
};

mw.VcardAssistant.UI.CommonsSearchField.prototype.getLookupCacheDataFromResponse = function(response) {
    var _this = this;
    this.searchresults = response[1];
    var searchResults = this.searchresults.map(function(result) {
        var name = result.indexOf("".concat(_this.prefix, ":")) === 0 ? result.slice("".concat(_this.prefix, ":").length) : result;
        return {
            data: name,
            label: name
        };
    });
    return searchResults;
};

mw.VcardAssistant.UI.CommonsSearchField.prototype.getLookupMenuOptionsFromData = function(data) {
    return data.map(function(result) {
        return new mw.VcardAssistant.UI.SearchResult(result);
    });
};

mw.VcardAssistant.UI.CommonsSearchField.prototype.onLookupMenuChoose = function(item) {
    this.setValue(item.getData());
};

"use strict";

function _createForOfIteratorHelper(o, allowArrayLike) {
    var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
    if (!it) {
        if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
            if (it) o = it;
            var i = 0;
            var F = function F() {};
            return {
                s: F,
                n: function n() {
                    if (i >= o.length) return {
                        done: true
                    };
                    return {
                        done: false,
                        value: o[i++]
                    };
                },
                e: function e(_e) {
                    throw _e;
                },
                f: F
            };
        }
        throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
    }
    var normalCompletion = true, didErr = false, err;
    return {
        s: function s() {
            it = it.call(o);
        },
        n: function n() {
            var step = it.next();
            normalCompletion = step.done;
            return step;
        },
        e: function e(_e2) {
            didErr = true;
            err = _e2;
        },
        f: function f() {
            try {
                if (!normalCompletion && it["return"] != null) it["return"]();
            } finally {
                if (didErr) throw err;
            }
        }
    };
}

function _unsupportedIterableToArray(o, minLen) {
    if (!o) return;
    if (typeof o === "string") return _arrayLikeToArray(o, minLen);
    var n = Object.prototype.toString.call(o).slice(8, -1);
    if (n === "Object" && o.constructor) n = o.constructor.name;
    if (n === "Map" || n === "Set") return Array.from(o);
    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}

function _arrayLikeToArray(arr, len) {
    if (len == null || len > arr.length) len = arr.length;
    for (var i = 0, arr2 = new Array(len); i < len; i++) {
        arr2[i] = arr[i];
    }
    return arr2;
}

mw.VcardAssistant.UI.Condition = function(options, caller, parameters) {
    this.parameters = parameters;
    this.sender = options.sender !== undefined ? options.sender : "$this";
    this.senderParameter = this.sender === "$this" ? caller : null;
    this.value = options.value !== undefined ? options.value : null;
};

mw.VcardAssistant.UI.Condition.parseRawConditionList = function(rawConditionList, caller, parameters) {
    var conditionList = [];
    var _iterator = _createForOfIteratorHelper(rawConditionList), _step;
    try {
        for (_iterator.s(); !(_step = _iterator.n()).done; ) {
            var rawCondition = _step.value;
            var condition = new mw.VcardAssistant.UI.Condition(rawCondition, caller, parameters);
            conditionList.push(condition);
        }
    } catch (err) {
        _iterator.e(err);
    } finally {
        _iterator.f();
    }
    return conditionList;
};

mw.VcardAssistant.UI.Condition.prototype.evaluate = function() {
    return this.getEvaluationFunction()();
};

mw.VcardAssistant.UI.Condition.prototype.getEvaluationFunction = function() {
    var _this = this;
    if (this.sender !== null && this.value !== null) {
        this.senderParameter = this.senderParameter || this.parameters[this.sender];
        return function() {
            return new RegExp(_this.value).test(_this.senderParameter.getValue());
        };
    }
};

mw.VcardAssistant.UI.Condition.prototype.watchSender = function(callback) {
    this.senderParameter = this.senderParameter || this.parameters[this.sender];
    this.senderParameter.inputWidget.on("change", callback);
};

mw.VcardAssistant.UI.Condition.evaluateConjunctiveConditions = function(conditionList) {
    return conditionList.reduce(function(accumulator, currentCondition) {
        return accumulator && currentCondition.evaluate();
    }, true);
};

mw.VcardAssistant.UI.Condition.evaluateRawConjunctiveConditions = function(rawConditionList, caller, parameters) {
    return mw.VcardAssistant.UI.Condition.evaluateConjunctiveConditions(mw.VcardAssistant.UI.Condition.parseRawConditionList(rawConditionList, caller, parameters));
};

"use strict";

mw.VcardAssistant.UI.CustomMenuTagMultiselectWidget = function(colorMap, config) {
    var _config$menu, _config$menu$filterMo, _config$allowSearchFo;
    config.menu = (_config$menu = config.menu) !== null && _config$menu !== void 0 ? _config$menu : {};
    config.menu.filterMode = (_config$menu$filterMo = config.menu.filterMode) !== null && _config$menu$filterMo !== void 0 ? _config$menu$filterMo : "substring";
    mw.VcardAssistant.UI.CustomMenuTagMultiselectWidget["super"].call(this, config);
    this.allowSearchForData = (_config$allowSearchFo = config.allowSearchForData) !== null && _config$allowSearchFo !== void 0 ? _config$allowSearchFo : true;
    this.colorMap = colorMap !== null && colorMap !== void 0 ? colorMap : null;
    this.pendingCounter = 0;
};

OO.inheritClass(mw.VcardAssistant.UI.CustomMenuTagMultiselectWidget, OO.ui.MenuTagMultiselectWidget);

mw.VcardAssistant.UI.CustomMenuTagMultiselectWidget.prototype.addOptions = function(menuOptions) {
    var _this = this;
    var items = menuOptions.map(function(obj) {
        return _this.createMenuOptionWidget(obj);
    });
    this.menu.addItems(items);
};

mw.VcardAssistant.UI.CustomMenuTagMultiselectWidget.prototype.createMenuOptionWidget = function(obj) {
    if (obj.optgroup !== undefined) {
        return new OO.ui.MenuSectionOptionWidget({
            label: "".concat(obj.optgroup)
        });
    } else {
        var _obj$label;
        var menuOptionWidget = new OO.ui.MenuOptionWidget({
            data: obj.data,
            label: (_obj$label = obj.label) !== null && _obj$label !== void 0 ? _obj$label : obj.data,
            icon: obj.icon
        });
        var color = this.getColorFormDataItem(obj.data);
        if (color !== null) {
            menuOptionWidget.$label.prepend('<span class="indicatordot" style="background-color:'.concat(color, '"></span>'));
        }
        menuOptionWidget.$element.attr("title", obj.data);
        if (this.allowSearchForData) {
            menuOptionWidget.getMatchText = function() {
                return "".concat(obj.label, ", ").concat(obj.data);
            };
        }
        return menuOptionWidget;
    }
};

mw.VcardAssistant.UI.CustomMenuTagMultiselectWidget.prototype.createTagItemWidget = function(data, label) {
    label = label || data;
    var tagItemWidget = new OO.ui.TagItemWidget({
        data: data,
        label: label
    });
    var color = this.getColorFormDataItem(data);
    if (color !== null) {
        tagItemWidget.$label.prepend('<span class="indicatordot" style="background-color:'.concat(color, '"></span>'));
    }
    tagItemWidget.$element.attr("title", data);
    return tagItemWidget;
};

mw.VcardAssistant.UI.CustomMenuTagMultiselectWidget.prototype.getColorFormDataItem = function(dataItem) {
    if (this.colorMap !== null && this.colorMap[dataItem] !== undefined) {
        return this.colorMap[dataItem];
    } else {
        return null;
    }
};

mw.VcardAssistant.UI.CustomMenuTagMultiselectWidget.prototype.popPending = function() {
    this.pendingCounter--;
    if (this.pendingCounter === 0) {
        this.$element.find("input[type=text]").removeClass("oo-ui-pendingElement-pending");
    }
};

mw.VcardAssistant.UI.CustomMenuTagMultiselectWidget.prototype.pushPending = function() {
    this.pendingCounter++;
    this.$element.find("input[type=text]").addClass("oo-ui-pendingElement-pending");
};

"use strict";

function _typeof(obj) {
    "@babel/helpers - typeof";
    return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
        return typeof obj;
    } : function(obj) {
        return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
    }, _typeof(obj);
}

function _regeneratorRuntime() {
    "use strict";
    _regeneratorRuntime = function _regeneratorRuntime() {
        return exports;
    };
    var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
    function define(obj, key, value) {
        return Object.defineProperty(obj, key, {
            value: value,
            enumerable: !0,
            configurable: !0,
            writable: !0
        }), obj[key];
    }
    try {
        define({}, "");
    } catch (err) {
        define = function define(obj, key, value) {
            return obj[key] = value;
        };
    }
    function wrap(innerFn, outerFn, self, tryLocsList) {
        var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []);
        return generator._invoke = function(innerFn, self, context) {
            var state = "suspendedStart";
            return function(method, arg) {
                if ("executing" === state) throw new Error("Generator is already running");
                if ("completed" === state) {
                    if ("throw" === method) throw arg;
                    return doneResult();
                }
                for (context.method = method, context.arg = arg; ;) {
                    var delegate = context.delegate;
                    if (delegate) {
                        var delegateResult = maybeInvokeDelegate(delegate, context);
                        if (delegateResult) {
                            if (delegateResult === ContinueSentinel) continue;
                            return delegateResult;
                        }
                    }
                    if ("next" === context.method) context.sent = context._sent = context.arg; else if ("throw" === context.method) {
                        if ("suspendedStart" === state) throw state = "completed", 
                        context.arg;
                        context.dispatchException(context.arg);
                    } else "return" === context.method && context.abrupt("return", context.arg);
                    state = "executing";
                    var record = tryCatch(innerFn, self, context);
                    if ("normal" === record.type) {
                        if (state = context.done ? "completed" : "suspendedYield", 
                        record.arg === ContinueSentinel) continue;
                        return {
                            value: record.arg,
                            done: context.done
                        };
                    }
                    "throw" === record.type && (state = "completed", context.method = "throw", 
                    context.arg = record.arg);
                }
            };
        }(innerFn, self, context), generator;
    }
    function tryCatch(fn, obj, arg) {
        try {
            return {
                type: "normal",
                arg: fn.call(obj, arg)
            };
        } catch (err) {
            return {
                type: "throw",
                arg: err
            };
        }
    }
    exports.wrap = wrap;
    var ContinueSentinel = {};
    function Generator() {}
    function GeneratorFunction() {}
    function GeneratorFunctionPrototype() {}
    var IteratorPrototype = {};
    define(IteratorPrototype, iteratorSymbol, function() {
        return this;
    });
    var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([])));
    NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
    var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
    function defineIteratorMethods(prototype) {
        [ "next", "throw", "return" ].forEach(function(method) {
            define(prototype, method, function(arg) {
                return this._invoke(method, arg);
            });
        });
    }
    function AsyncIterator(generator, PromiseImpl) {
        function invoke(method, arg, resolve, reject) {
            var record = tryCatch(generator[method], generator, arg);
            if ("throw" !== record.type) {
                var result = record.arg, value = result.value;
                return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function(value) {
                    invoke("next", value, resolve, reject);
                }, function(err) {
                    invoke("throw", err, resolve, reject);
                }) : PromiseImpl.resolve(value).then(function(unwrapped) {
                    result.value = unwrapped, resolve(result);
                }, function(error) {
                    return invoke("throw", error, resolve, reject);
                });
            }
            reject(record.arg);
        }
        var previousPromise;
        this._invoke = function(method, arg) {
            function callInvokeWithMethodAndArg() {
                return new PromiseImpl(function(resolve, reject) {
                    invoke(method, arg, resolve, reject);
                });
            }
            return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
        };
    }
    function maybeInvokeDelegate(delegate, context) {
        var method = delegate.iterator[context.method];
        if (undefined === method) {
            if (context.delegate = null, "throw" === context.method) {
                if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, 
                maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
                context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
            }
            return ContinueSentinel;
        }
        var record = tryCatch(method, delegate.iterator, context.arg);
        if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, 
        context.delegate = null, ContinueSentinel;
        var info = record.arg;
        return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, 
        "return" !== context.method && (context.method = "next", context.arg = undefined), 
        context.delegate = null, ContinueSentinel) : info : (context.method = "throw", 
        context.arg = new TypeError("iterator result is not an object"), context.delegate = null, 
        ContinueSentinel);
    }
    function pushTryEntry(locs) {
        var entry = {
            tryLoc: locs[0]
        };
        1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], 
        entry.afterLoc = locs[3]), this.tryEntries.push(entry);
    }
    function resetTryEntry(entry) {
        var record = entry.completion || {};
        record.type = "normal", delete record.arg, entry.completion = record;
    }
    function Context(tryLocsList) {
        this.tryEntries = [ {
            tryLoc: "root"
        } ], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
    }
    function values(iterable) {
        if (iterable) {
            var iteratorMethod = iterable[iteratorSymbol];
            if (iteratorMethod) return iteratorMethod.call(iterable);
            if ("function" == typeof iterable.next) return iterable;
            if (!isNaN(iterable.length)) {
                var i = -1, next = function next() {
                    for (;++i < iterable.length; ) {
                        if (hasOwn.call(iterable, i)) return next.value = iterable[i], 
                        next.done = !1, next;
                    }
                    return next.value = undefined, next.done = !0, next;
                };
                return next.next = next;
            }
        }
        return {
            next: doneResult
        };
    }
    function doneResult() {
        return {
            value: undefined,
            done: !0
        };
    }
    return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), 
    define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), 
    exports.isGeneratorFunction = function(genFun) {
        var ctor = "function" == typeof genFun && genFun.constructor;
        return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
    }, exports.mark = function(genFun) {
        return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, 
        define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), 
        genFun;
    }, exports.awrap = function(arg) {
        return {
            __await: arg
        };
    }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function() {
        return this;
    }), exports.AsyncIterator = AsyncIterator, exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
        void 0 === PromiseImpl && (PromiseImpl = Promise);
        var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
        return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function(result) {
            return result.done ? result.value : iter.next();
        });
    }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function() {
        return this;
    }), define(Gp, "toString", function() {
        return "[object Generator]";
    }), exports.keys = function(object) {
        var keys = [];
        for (var key in object) {
            keys.push(key);
        }
        return keys.reverse(), function next() {
            for (;keys.length; ) {
                var key = keys.pop();
                if (key in object) return next.value = key, next.done = !1, next;
            }
            return next.done = !0, next;
        };
    }, exports.values = values, Context.prototype = {
        constructor: Context,
        reset: function reset(skipTempReset) {
            if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, 
            this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, 
            this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
                "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
            }
        },
        stop: function stop() {
            this.done = !0;
            var rootRecord = this.tryEntries[0].completion;
            if ("throw" === rootRecord.type) throw rootRecord.arg;
            return this.rval;
        },
        dispatchException: function dispatchException(exception) {
            if (this.done) throw exception;
            var context = this;
            function handle(loc, caught) {
                return record.type = "throw", record.arg = exception, context.next = loc, 
                caught && (context.method = "next", context.arg = undefined), !!caught;
            }
            for (var i = this.tryEntries.length - 1; i >= 0; --i) {
                var entry = this.tryEntries[i], record = entry.completion;
                if ("root" === entry.tryLoc) return handle("end");
                if (entry.tryLoc <= this.prev) {
                    var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc");
                    if (hasCatch && hasFinally) {
                        if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
                        if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
                    } else if (hasCatch) {
                        if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
                    } else {
                        if (!hasFinally) throw new Error("try statement without catch or finally");
                        if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
                    }
                }
            }
        },
        abrupt: function abrupt(type, arg) {
            for (var i = this.tryEntries.length - 1; i >= 0; --i) {
                var entry = this.tryEntries[i];
                if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
                    var finallyEntry = entry;
                    break;
                }
            }
            finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
            var record = finallyEntry ? finallyEntry.completion : {};
            return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", 
            this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
        },
        complete: function complete(record, afterLoc) {
            if ("throw" === record.type) throw record.arg;
            return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, 
            this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), 
            ContinueSentinel;
        },
        finish: function finish(finallyLoc) {
            for (var i = this.tryEntries.length - 1; i >= 0; --i) {
                var entry = this.tryEntries[i];
                if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), 
                resetTryEntry(entry), ContinueSentinel;
            }
        },
        catch: function _catch(tryLoc) {
            for (var i = this.tryEntries.length - 1; i >= 0; --i) {
                var entry = this.tryEntries[i];
                if (entry.tryLoc === tryLoc) {
                    var record = entry.completion;
                    if ("throw" === record.type) {
                        var thrown = record.arg;
                        resetTryEntry(entry);
                    }
                    return thrown;
                }
            }
            throw new Error("illegal catch attempt");
        },
        delegateYield: function delegateYield(iterable, resultName, nextLoc) {
            return this.delegate = {
                iterator: values(iterable),
                resultName: resultName,
                nextLoc: nextLoc
            }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
        }
    }, exports;
}

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
    try {
        var info = gen[key](arg);
        var value = info.value;
    } catch (error) {
        reject(error);
        return;
    }
    if (info.done) {
        resolve(value);
    } else {
        Promise.resolve(value).then(_next, _throw);
    }
}

function _asyncToGenerator(fn) {
    return function() {
        var self = this, args = arguments;
        return new Promise(function(resolve, reject) {
            var gen = fn.apply(self, args);
            function _next(value) {
                asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
            }
            function _throw(err) {
                asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
            }
            _next(undefined);
        });
    };
}

function _slicedToArray(arr, i) {
    return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}

function _nonIterableRest() {
    throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}

function _iterableToArrayLimit(arr, i) {
    var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
    if (_i == null) return;
    var _arr = [];
    var _n = true;
    var _d = false;
    var _s, _e;
    try {
        for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
            _arr.push(_s.value);
            if (i && _arr.length === i) break;
        }
    } catch (err) {
        _d = true;
        _e = err;
    } finally {
        try {
            if (!_n && _i["return"] != null) _i["return"]();
        } finally {
            if (_d) throw _e;
        }
    }
    return _arr;
}

function _arrayWithHoles(arr) {
    if (Array.isArray(arr)) return arr;
}

function _createForOfIteratorHelper(o, allowArrayLike) {
    var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
    if (!it) {
        if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
            if (it) o = it;
            var i = 0;
            var F = function F() {};
            return {
                s: F,
                n: function n() {
                    if (i >= o.length) return {
                        done: true
                    };
                    return {
                        done: false,
                        value: o[i++]
                    };
                },
                e: function e(_e2) {
                    throw _e2;
                },
                f: F
            };
        }
        throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
    }
    var normalCompletion = true, didErr = false, err;
    return {
        s: function s() {
            it = it.call(o);
        },
        n: function n() {
            var step = it.next();
            normalCompletion = step.done;
            return step;
        },
        e: function e(_e3) {
            didErr = true;
            err = _e3;
        },
        f: function f() {
            try {
                if (!normalCompletion && it["return"] != null) it["return"]();
            } finally {
                if (didErr) throw err;
            }
        }
    };
}

function _unsupportedIterableToArray(o, minLen) {
    if (!o) return;
    if (typeof o === "string") return _arrayLikeToArray(o, minLen);
    var n = Object.prototype.toString.call(o).slice(8, -1);
    if (n === "Object" && o.constructor) n = o.constructor.name;
    if (n === "Map" || n === "Set") return Array.from(o);
    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}

function _arrayLikeToArray(arr, len) {
    if (len == null || len > arr.length) len = arr.length;
    for (var i = 0, arr2 = new Array(len); i < len; i++) {
        arr2[i] = arr[i];
    }
    return arr2;
}

mw.VcardAssistant.UI.EditForm = function(vcardAssistantConfig, adaptations, prefill) {
    var _this = this;
    function getCategory(catConfig) {
        return new OO.ui.FieldsetLayout({
            label: catConfig.label
        });
    }
    mw.VcardAssistant.UI.EditForm.parent.call(this);
    this.adaptations = adaptations;
    this.neverOmitParameters = [];
    this.parameters = {};
    this.prefill = prefill !== null && prefill !== void 0 ? prefill : {};
    this.wikidataClaims = {};
    var contentPanel = new OO.ui.PanelLayout({
        classes: [ "ext-vcardassistant-editform-contentpanel" ],
        expanded: true,
        padded: true
    });
    var menuCategories = [];
    var triggers = [];
    if (mw.config.get("wgUserName") === null) {
        mw.loader.using([ "oojs-ui.styles.icons-user" ]);
        var notLogginPanel = new OO.ui.PanelLayout({
            classes: [ "usermessage", "vcardassistant-warning" ],
            content: [ new OO.ui.HorizontalLayout({
                classes: [ "vcardassistant-warning" ],
                expanded: false,
                items: [ new OO.ui.IconWidget({
                    icon: "userAnonymous"
                }), new OO.ui.Widget({
                    classes: [ "vcardassistant-warning-text" ],
                    text: mw.msg("va-msg-warning-notLoggedIn")
                }) ]
            }) ],
            expanded: false
        });
        contentPanel.$element.append(notLogginPanel.$element);
    }
    if (vcardAssistantConfig.config.outdatedwarning === true && vcardAssistantConfig.special_parameters.lastupdate !== null && prefill !== null && prefill !== void 0 && prefill[vcardAssistantConfig.special_parameters.lastupdate]) {
        var lastupdate = this.adaptations.parseTimestamp(vcardAssistantConfig.special_parameters.lastupdate, prefill[vcardAssistantConfig.special_parameters.lastupdate]);
        var threshold = new Date(Date.now() - adaptations.getOutdatedThreshold(prefill));
        if (lastupdate < threshold) {
            mw.loader.using([ "oojs-ui.styles.icons-editing-advanced" ]);
            var outdatedPanel = new OO.ui.PanelLayout({
                classes: [ "usermessage", "vcardassistant-warning" ],
                content: [ new OO.ui.HorizontalLayout({
                    classes: [ "vcardassistant-warning" ],
                    expanded: false,
                    items: [ new OO.ui.IconWidget({
                        icon: "calendar"
                    }), new OO.ui.Widget({
                        classes: [ "vcardassistant-warning-text" ],
                        text: mw.msg("va-msg-warning-outdated")
                    }) ]
                }) ],
                expanded: false
            });
            contentPanel.$element.append(outdatedPanel.$element);
        }
    }
    var _iterator = _createForOfIteratorHelper(vcardAssistantConfig.parameters.categories), _step;
    try {
        for (_iterator.s(); !(_step = _iterator.n()).done; ) {
            var category = _step.value;
            var categoryConfig = category.category;
            var rawParameters = category.params;
            var categoryFieldsetLayout = getCategory(categoryConfig);
            var fields = [];
            var menuItems = [];
            var parameters = [];
            for (var _i3 = 0, _Object$keys = Object.keys(rawParameters); _i3 < _Object$keys.length; _i3++) {
                var _prefill$parameterNam;
                var parameterName = _Object$keys[_i3];
                var parameter = new mw.VcardAssistant.UI.Parameter(vcardAssistantConfig, adaptations, parameterName, rawParameters[parameterName], prefill !== null ? (_prefill$parameterNam = prefill[parameterName]) !== null && _prefill$parameterNam !== void 0 ? _prefill$parameterNam : null : null, this);
                var parameterField = parameter.getParameterInputField();
                parameters.push(parameter);
                fields.push(parameterField);
                if (parameter.hidden) {
                    menuItems.push($("<div>").append(parameter.getParameterButton().$element));
                }
                if (parameter.type === "lastedit") {
                    this.lastEditParameter = parameter;
                }
                this.parameters[parameterName] = parameter;
                if (parameter.neverOmit) {
                    this.neverOmitParameters.push(parameterName);
                }
                if (parameter.wikidata !== null) {
                    this.wikidataClaims["".concat(parameter.wikidata.property).concat(typeof parameter.wikidata.value !== "undefined" ? "-".concat(parameter.wikidata.value) : "")] = {
                        config: parameter.wikidata,
                        target: parameter.parameterName
                    };
                }
                if (parameter.triggers !== null) {
                    var _iterator2 = _createForOfIteratorHelper(parameter.triggers), _step2;
                    try {
                        for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) {
                            var trigger = _step2.value;
                            triggers.push({
                                target: parameter,
                                trigger: trigger
                            });
                        }
                    } catch (err) {
                        _iterator2.e(err);
                    } finally {
                        _iterator2.f();
                    }
                }
            }
            categoryFieldsetLayout.addItems(fields);
            contentPanel.$element.append(categoryFieldsetLayout.$element);
            var _menuCategory = new mw.VcardAssistant.UI.MenuCategory(this, categoryConfig, menuItems, categoryFieldsetLayout);
            menuCategories.push(_menuCategory);
        }
    } catch (err) {
        _iterator.e(err);
    } finally {
        _iterator.f();
    }
    for (var _i = 0, _triggers = triggers; _i < _triggers.length; _i++) {
        var triggerPair = _triggers[_i];
        triggerPair.target.setupTrigger(triggerPair.trigger, this.parameters);
    }
    var menuPanel = new OO.ui.PanelLayout({
        expanded: true,
        padded: true
    });
    var $parameterMenu = $("<div>").addClass("ext-vcardassistant-parameterlist");
    for (var _i2 = 0, _menuCategories = menuCategories; _i2 < _menuCategories.length; _i2++) {
        var menuCategory = _menuCategories[_i2];
        $parameterMenu.append(menuCategory.$element);
    }
    menuPanel.$element.append($parameterMenu);
    var menuLayout = new OO.ui.MenuLayout({
        contentPanel: contentPanel,
        menuPanel: menuPanel
    });
    if (prefill !== null && prefill[vcardAssistantConfig.special_parameters.wikidata] !== undefined) {
        this.applyWikidataId(prefill[vcardAssistantConfig.special_parameters.wikidata]);
    }
    $(window).on("resize", function() {
        _this.onWindowResize(menuLayout);
    });
    this.onWindowResize(menuLayout);
    this.$element.append(menuLayout.$element);
};

OO.inheritClass(mw.VcardAssistant.UI.EditForm, OO.ui.Widget);

mw.VcardAssistant.UI.EditForm.prototype.initialize = function() {
    this.$element.find(".fadein").removeClass("fadein");
};

mw.VcardAssistant.UI.EditForm.prototype.applyParameter = function(parameter, value) {
    this.parameters[parameter].setValue(value);
};

mw.VcardAssistant.UI.EditForm.prototype.applyParameters = function(parameters) {
    for (var _i4 = 0, _Object$entries = Object.entries(parameters); _i4 < _Object$entries.length; _i4++) {
        var _Object$entries$_i = _slicedToArray(_Object$entries[_i4], 2), key = _Object$entries$_i[0], value = _Object$entries$_i[1];
        this.parameters[key].setValue(value);
    }
};

mw.VcardAssistant.UI.EditForm.prototype.applyWikidataId = function() {
    var _ref = _asyncToGenerator(_regeneratorRuntime().mark(function _callee(wikidataId) {
        var wikidataStatement, _i5, _Object$values, propertyValue, parameterName, parameter, res, _i6, _Object$values2, _propertyValue, _parameterName, _parameter, value;
        return _regeneratorRuntime().wrap(function _callee$(_context) {
            while (1) {
                switch (_context.prev = _context.next) {
                  case 0:
                    wikidataStatement = function _wikidataStatement(entity, wikidataConfig) {
                        if (!entity || !entity.claims || !entity.claims[wikidataConfig.property]) {
                            return null;
                        }
                        var propertyObj = entity.claims[wikidataConfig.property];
                        if (!propertyObj || propertyObj.length < 1 || !propertyObj[0].mainsnak || !propertyObj[0].mainsnak.datavalue) {
                            return null;
                        }
                        var value;
                        switch (propertyObj[0].mainsnak.datavalue.type) {
                          case "globecoordinate":
                            if (typeof wikidataConfig.value !== "undefined") {
                                value = propertyObj[0].mainsnak.datavalue.value[wikidataConfig.value];
                            } else {
                                value = "".concat(propertyObj[0].mainsnak.datavalue.value.latitude, ", ").concat(propertyObj[0].mainsnak.datavalue.value.longitude);
                            }
                            break;

                          case "monolingualtext":
                            value = propertyObj[0].mainsnak.datavalue.value.text;
                            break;

                          default:
                            value = propertyObj[0].mainsnak.datavalue.value;
                        }
                        if (typeof wikidataConfig.filter !== "undefined" && typeof wikidataConfig.filter.regexp !== "undefined") {
                            value = value.match(wikidataConfig.filter.regexp)[wikidataConfig.filter.group || 1];
                        }
                        return {
                            id: propertyObj[0].id,
                            value: value
                        };
                    };
                    if (!(wikidataId === null)) {
                        _context.next = 5;
                        break;
                    }
                    for (_i5 = 0, _Object$values = Object.values(this.wikidataClaims); _i5 < _Object$values.length; _i5++) {
                        propertyValue = _Object$values[_i5];
                        parameterName = propertyValue.target;
                        parameter = this.parameters[parameterName];
                        parameter.clearWikidata();
                    }
                    _context.next = 9;
                    break;

                  case 5:
                    _context.next = 7;
                    return $.ajax({
                        data: {
                            action: "wbgetentities",
                            format: "json",
                            ids: wikidataId,
                            redirects: "yes",
                            origin: "*",
                            props: "info|sitelinks|aliases|labels|descriptions|claims|datatype"
                        },
                        url: "https://www.wikidata.org/w/api.php"
                    });

                  case 7:
                    res = _context.sent;
                    if (Object.keys(res.entities).length > 0) {
                        for (_i6 = 0, _Object$values2 = Object.values(this.wikidataClaims); _i6 < _Object$values2.length; _i6++) {
                            _propertyValue = _Object$values2[_i6];
                            _parameterName = _propertyValue.target;
                            _parameter = this.parameters[_parameterName];
                            value = wikidataStatement(res.entities[Object.keys(res.entities)[0]], _propertyValue.config);
                            if (value !== null) {
                                _parameter.applyWikidata(value.value, value.id, wikidataId);
                            }
                        }
                    }

                  case 9:
                  case "end":
                    return _context.stop();
                }
            }
        }, _callee, this);
    }));
    return function(_x) {
        return _ref.apply(this, arguments);
    };
}();

mw.VcardAssistant.UI.EditForm.prototype.countChanges = function() {
    return Object.values(this.parameters).reduce(function(accumulator, parameterValue) {
        return accumulator + (parameterValue.wasChanged() ? 1 : 0);
    }, 0);
};

mw.VcardAssistant.UI.EditForm.prototype.getUpdateLastEdit = function() {
    console.assert(this.lastEditParameter !== null);
    return this.lastEditParameter.getUpdateLastEdit();
};

mw.VcardAssistant.UI.EditForm.prototype.onWindowResize = function(menuLayout) {
    if ($(window).width() > 600) {
        menuLayout.setMenuPosition("before");
    } else {
        menuLayout.setMenuPosition("bottom");
    }
};

mw.VcardAssistant.UI.EditForm.prototype.setUpdateLastEdit = function(value) {
    console.assert(this.lastEditParameter !== null);
    this.lastEditParameter.setUpdateLastEdit(value);
};

mw.VcardAssistant.UI.EditForm.prototype.validate = function() {
    return Object.values(this.parameters).reduce(function(accumulator, parameterValue) {
        return accumulator && parameterValue.validate(true);
    }, true);
};

"use strict";

mw.VcardAssistant.UI.MenuCategory = function(editForm, category, menuItems, categoryFieldsetLayout, config) {
    mw.VcardAssistant.UI.MenuCategory["super"].call(this, config);
    this.editForm = editForm;
    this.category = category;
    this.menuItems = menuItems;
    this.categoryFieldsetLayout = categoryFieldsetLayout;
    var $title = $('<span class="ext-vcardassistant-menu-categorylabel">'.concat(category.label, "</span>"));
    $title.on("click", function(e) {
        e.preventDefault();
        categoryFieldsetLayout.$element[0].scrollIntoView({
            behavior: "smooth"
        });
    });
    this.$element.append($title);
    this.$element.append(menuItems);
};

OO.inheritClass(mw.VcardAssistant.UI.MenuCategory, OO.ui.Widget);

"use strict";

mw.VcardAssistant.UI.ParameterButton = function(editForm, parameter, initiallyVisible, config) {
    config = $.extend({
        icon: "add",
        framed: false,
        flags: "progressive"
    }, config);
    mw.VcardAssistant.UI.ParameterButton["super"].call(this, config);
    this.editForm = editForm;
    this.parameter = parameter;
    this.setLabel(parameter.label);
    this.toggleAction(initiallyVisible);
    this.connect(this, {
        click: "toggleAction"
    });
};

OO.inheritClass(mw.VcardAssistant.UI.ParameterButton, OO.ui.ButtonWidget);

mw.VcardAssistant.UI.ParameterButton.prototype.toggleAction = function(show) {
    if (show === undefined) {
        show = !this.isEnabled;
    }
    if (show) {
        this.setIcon("subtract");
        this.setFlags({
            destructive: true,
            progressive: false
        });
        this.setTitle(mw.msg("va-msg-parameterButton-remove"));
        this.parameter.toggle(true);
        this.parameter.inputFieldLayoutWidget.$element.addClass("fadein");
        this.parameter.inputFieldLayoutWidget.$element[0].scrollIntoView({
            behavior: "smooth"
        });
    } else {
        this.setIcon("add");
        this.setFlags({
            progressive: true,
            destructive: false
        });
        this.setTitle(mw.msg("va-msg-parameterButton-add"));
        this.parameter.toggle(false);
        this.parameter.inputFieldLayoutWidget.$element.removeClass("fadein");
    }
    this.isEnabled = show;
};

"use strict";

function _createForOfIteratorHelper(o, allowArrayLike) {
    var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
    if (!it) {
        if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
            if (it) o = it;
            var i = 0;
            var F = function F() {};
            return {
                s: F,
                n: function n() {
                    if (i >= o.length) return {
                        done: true
                    };
                    return {
                        done: false,
                        value: o[i++]
                    };
                },
                e: function e(_e) {
                    throw _e;
                },
                f: F
            };
        }
        throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
    }
    var normalCompletion = true, didErr = false, err;
    return {
        s: function s() {
            it = it.call(o);
        },
        n: function n() {
            var step = it.next();
            normalCompletion = step.done;
            return step;
        },
        e: function e(_e2) {
            didErr = true;
            err = _e2;
        },
        f: function f() {
            try {
                if (!normalCompletion && it["return"] != null) it["return"]();
            } finally {
                if (didErr) throw err;
            }
        }
    };
}

function _unsupportedIterableToArray(o, minLen) {
    if (!o) return;
    if (typeof o === "string") return _arrayLikeToArray(o, minLen);
    var n = Object.prototype.toString.call(o).slice(8, -1);
    if (n === "Object" && o.constructor) n = o.constructor.name;
    if (n === "Map" || n === "Set") return Array.from(o);
    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}

function _arrayLikeToArray(arr, len) {
    if (len == null || len > arr.length) len = arr.length;
    for (var i = 0, arr2 = new Array(len); i < len; i++) {
        arr2[i] = arr[i];
    }
    return arr2;
}

function _regeneratorRuntime() {
    "use strict";
    _regeneratorRuntime = function _regeneratorRuntime() {
        return exports;
    };
    var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
    function define(obj, key, value) {
        return Object.defineProperty(obj, key, {
            value: value,
            enumerable: !0,
            configurable: !0,
            writable: !0
        }), obj[key];
    }
    try {
        define({}, "");
    } catch (err) {
        define = function define(obj, key, value) {
            return obj[key] = value;
        };
    }
    function wrap(innerFn, outerFn, self, tryLocsList) {
        var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []);
        return generator._invoke = function(innerFn, self, context) {
            var state = "suspendedStart";
            return function(method, arg) {
                if ("executing" === state) throw new Error("Generator is already running");
                if ("completed" === state) {
                    if ("throw" === method) throw arg;
                    return doneResult();
                }
                for (context.method = method, context.arg = arg; ;) {
                    var delegate = context.delegate;
                    if (delegate) {
                        var delegateResult = maybeInvokeDelegate(delegate, context);
                        if (delegateResult) {
                            if (delegateResult === ContinueSentinel) continue;
                            return delegateResult;
                        }
                    }
                    if ("next" === context.method) context.sent = context._sent = context.arg; else if ("throw" === context.method) {
                        if ("suspendedStart" === state) throw state = "completed", 
                        context.arg;
                        context.dispatchException(context.arg);
                    } else "return" === context.method && context.abrupt("return", context.arg);
                    state = "executing";
                    var record = tryCatch(innerFn, self, context);
                    if ("normal" === record.type) {
                        if (state = context.done ? "completed" : "suspendedYield", 
                        record.arg === ContinueSentinel) continue;
                        return {
                            value: record.arg,
                            done: context.done
                        };
                    }
                    "throw" === record.type && (state = "completed", context.method = "throw", 
                    context.arg = record.arg);
                }
            };
        }(innerFn, self, context), generator;
    }
    function tryCatch(fn, obj, arg) {
        try {
            return {
                type: "normal",
                arg: fn.call(obj, arg)
            };
        } catch (err) {
            return {
                type: "throw",
                arg: err
            };
        }
    }
    exports.wrap = wrap;
    var ContinueSentinel = {};
    function Generator() {}
    function GeneratorFunction() {}
    function GeneratorFunctionPrototype() {}
    var IteratorPrototype = {};
    define(IteratorPrototype, iteratorSymbol, function() {
        return this;
    });
    var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([])));
    NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
    var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
    function defineIteratorMethods(prototype) {
        [ "next", "throw", "return" ].forEach(function(method) {
            define(prototype, method, function(arg) {
                return this._invoke(method, arg);
            });
        });
    }
    function AsyncIterator(generator, PromiseImpl) {
        function invoke(method, arg, resolve, reject) {
            var record = tryCatch(generator[method], generator, arg);
            if ("throw" !== record.type) {
                var result = record.arg, value = result.value;
                return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function(value) {
                    invoke("next", value, resolve, reject);
                }, function(err) {
                    invoke("throw", err, resolve, reject);
                }) : PromiseImpl.resolve(value).then(function(unwrapped) {
                    result.value = unwrapped, resolve(result);
                }, function(error) {
                    return invoke("throw", error, resolve, reject);
                });
            }
            reject(record.arg);
        }
        var previousPromise;
        this._invoke = function(method, arg) {
            function callInvokeWithMethodAndArg() {
                return new PromiseImpl(function(resolve, reject) {
                    invoke(method, arg, resolve, reject);
                });
            }
            return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
        };
    }
    function maybeInvokeDelegate(delegate, context) {
        var method = delegate.iterator[context.method];
        if (undefined === method) {
            if (context.delegate = null, "throw" === context.method) {
                if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, 
                maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
                context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
            }
            return ContinueSentinel;
        }
        var record = tryCatch(method, delegate.iterator, context.arg);
        if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, 
        context.delegate = null, ContinueSentinel;
        var info = record.arg;
        return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, 
        "return" !== context.method && (context.method = "next", context.arg = undefined), 
        context.delegate = null, ContinueSentinel) : info : (context.method = "throw", 
        context.arg = new TypeError("iterator result is not an object"), context.delegate = null, 
        ContinueSentinel);
    }
    function pushTryEntry(locs) {
        var entry = {
            tryLoc: locs[0]
        };
        1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], 
        entry.afterLoc = locs[3]), this.tryEntries.push(entry);
    }
    function resetTryEntry(entry) {
        var record = entry.completion || {};
        record.type = "normal", delete record.arg, entry.completion = record;
    }
    function Context(tryLocsList) {
        this.tryEntries = [ {
            tryLoc: "root"
        } ], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
    }
    function values(iterable) {
        if (iterable) {
            var iteratorMethod = iterable[iteratorSymbol];
            if (iteratorMethod) return iteratorMethod.call(iterable);
            if ("function" == typeof iterable.next) return iterable;
            if (!isNaN(iterable.length)) {
                var i = -1, next = function next() {
                    for (;++i < iterable.length; ) {
                        if (hasOwn.call(iterable, i)) return next.value = iterable[i], 
                        next.done = !1, next;
                    }
                    return next.value = undefined, next.done = !0, next;
                };
                return next.next = next;
            }
        }
        return {
            next: doneResult
        };
    }
    function doneResult() {
        return {
            value: undefined,
            done: !0
        };
    }
    return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), 
    define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), 
    exports.isGeneratorFunction = function(genFun) {
        var ctor = "function" == typeof genFun && genFun.constructor;
        return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
    }, exports.mark = function(genFun) {
        return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, 
        define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), 
        genFun;
    }, exports.awrap = function(arg) {
        return {
            __await: arg
        };
    }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function() {
        return this;
    }), exports.AsyncIterator = AsyncIterator, exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
        void 0 === PromiseImpl && (PromiseImpl = Promise);
        var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
        return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function(result) {
            return result.done ? result.value : iter.next();
        });
    }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function() {
        return this;
    }), define(Gp, "toString", function() {
        return "[object Generator]";
    }), exports.keys = function(object) {
        var keys = [];
        for (var key in object) {
            keys.push(key);
        }
        return keys.reverse(), function next() {
            for (;keys.length; ) {
                var key = keys.pop();
                if (key in object) return next.value = key, next.done = !1, next;
            }
            return next.done = !0, next;
        };
    }, exports.values = values, Context.prototype = {
        constructor: Context,
        reset: function reset(skipTempReset) {
            if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, 
            this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, 
            this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
                "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
            }
        },
        stop: function stop() {
            this.done = !0;
            var rootRecord = this.tryEntries[0].completion;
            if ("throw" === rootRecord.type) throw rootRecord.arg;
            return this.rval;
        },
        dispatchException: function dispatchException(exception) {
            if (this.done) throw exception;
            var context = this;
            function handle(loc, caught) {
                return record.type = "throw", record.arg = exception, context.next = loc, 
                caught && (context.method = "next", context.arg = undefined), !!caught;
            }
            for (var i = this.tryEntries.length - 1; i >= 0; --i) {
                var entry = this.tryEntries[i], record = entry.completion;
                if ("root" === entry.tryLoc) return handle("end");
                if (entry.tryLoc <= this.prev) {
                    var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc");
                    if (hasCatch && hasFinally) {
                        if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
                        if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
                    } else if (hasCatch) {
                        if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
                    } else {
                        if (!hasFinally) throw new Error("try statement without catch or finally");
                        if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
                    }
                }
            }
        },
        abrupt: function abrupt(type, arg) {
            for (var i = this.tryEntries.length - 1; i >= 0; --i) {
                var entry = this.tryEntries[i];
                if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
                    var finallyEntry = entry;
                    break;
                }
            }
            finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
            var record = finallyEntry ? finallyEntry.completion : {};
            return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", 
            this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
        },
        complete: function complete(record, afterLoc) {
            if ("throw" === record.type) throw record.arg;
            return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, 
            this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), 
            ContinueSentinel;
        },
        finish: function finish(finallyLoc) {
            for (var i = this.tryEntries.length - 1; i >= 0; --i) {
                var entry = this.tryEntries[i];
                if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), 
                resetTryEntry(entry), ContinueSentinel;
            }
        },
        catch: function _catch(tryLoc) {
            for (var i = this.tryEntries.length - 1; i >= 0; --i) {
                var entry = this.tryEntries[i];
                if (entry.tryLoc === tryLoc) {
                    var record = entry.completion;
                    if ("throw" === record.type) {
                        var thrown = record.arg;
                        resetTryEntry(entry);
                    }
                    return thrown;
                }
            }
            throw new Error("illegal catch attempt");
        },
        delegateYield: function delegateYield(iterable, resultName, nextLoc) {
            return this.delegate = {
                iterator: values(iterable),
                resultName: resultName,
                nextLoc: nextLoc
            }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
        }
    }, exports;
}

function _typeof(obj) {
    "@babel/helpers - typeof";
    return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
        return typeof obj;
    } : function(obj) {
        return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
    }, _typeof(obj);
}

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
    try {
        var info = gen[key](arg);
        var value = info.value;
    } catch (error) {
        reject(error);
        return;
    }
    if (info.done) {
        resolve(value);
    } else {
        Promise.resolve(value).then(_next, _throw);
    }
}

function _asyncToGenerator(fn) {
    return function() {
        var self = this, args = arguments;
        return new Promise(function(resolve, reject) {
            var gen = fn.apply(self, args);
            function _next(value) {
                asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
            }
            function _throw(err) {
                asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
            }
            _next(undefined);
        });
    };
}

mw.VcardAssistant.UI.Parameter = function(vcardAssistantConfig, adaptations, parameterName, options, prefill, editForm) {
    var _options$description, _options$enum, _options$example, _options$format, _options$hidden, _options$max, _options$min, _options$multiline, _options$multiple, _options$neverOmit, _options$preview, _options$required, _options$triggers;
    this.vcardAssistantConfig = vcardAssistantConfig;
    this.adaptations = adaptations;
    this.prefill = prefill;
    this.editForm = editForm;
    this.excluded = false;
    this.inputFieldLayoutWidget = null;
    this.inputWidget = null;
    this.messagePopupWidget = null;
    this.parameterButton = null;
    this.previewButton = null;
    this.wikidataButton = null;
    this.wikidataClaim = null;
    this.description = (_options$description = options.description) !== null && _options$description !== void 0 ? _options$description : null;
    this["enum"] = (_options$enum = options["enum"]) !== null && _options$enum !== void 0 ? _options$enum : null;
    this.example = (_options$example = options.example) !== null && _options$example !== void 0 ? _options$example : null;
    this.format = (_options$format = options.format) !== null && _options$format !== void 0 ? _options$format : null;
    this.hidden = (_options$hidden = options.hidden) !== null && _options$hidden !== void 0 ? _options$hidden : false;
    this.label = options.label;
    this.max = (_options$max = options.max) !== null && _options$max !== void 0 ? _options$max : null;
    this.min = (_options$min = options.min) !== null && _options$min !== void 0 ? _options$min : null;
    this.multiline = (_options$multiline = options.multiline) !== null && _options$multiline !== void 0 ? _options$multiline : null;
    this.multiple = (_options$multiple = options.multiple) !== null && _options$multiple !== void 0 ? _options$multiple : null;
    this.neverOmit = (_options$neverOmit = options.neverOmit) !== null && _options$neverOmit !== void 0 ? _options$neverOmit : false;
    this.parameterName = parameterName;
    this.preview = (_options$preview = options.preview) !== null && _options$preview !== void 0 ? _options$preview : null;
    this.required = (_options$required = options.required) !== null && _options$required !== void 0 ? _options$required : false;
    this.triggers = (_options$triggers = options.triggers) !== null && _options$triggers !== void 0 ? _options$triggers : null;
    this.type = options.type;
    if (options.wikidata === undefined) {
        this.wikidata = null;
    } else if (typeof options.wikidata === "string") {
        this.wikidata = {
            property: options.wikidata
        };
    } else {
        this.wikidata = options.wikidata;
    }
    var eventDelegate = document.createDocumentFragment();
    this.on = function() {
        for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
            args[_key] = arguments[_key];
        }
        eventDelegate.addEventListener.apply(eventDelegate, args);
    };
    this.emit = function() {
        for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
            args[_key2] = arguments[_key2];
        }
        return eventDelegate.dispatchEvent.apply(eventDelegate, args);
    };
    this.off = function() {
        for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
            args[_key3] = arguments[_key3];
        }
        eventDelegate.removeEventListener.apply(eventDelegate, args);
    };
    switch (this.type) {
      case "commons-category":
      case "commons-file":
        this.format = this.format || [];
        this.format.push({
            message: mw.msg("va-msg-format-commons-mayNotIncludePrefixes"),
            regexp: "^[^:]*$"
        });
        if (this.type === "commons-category") {
            this.preview = this.preview || [];
            this.preview.push({
                type: "url",
                url: "https://commons.wikimedia.org/wiki/Category:{parameter}"
            });
        }
        break;

      case "lastedit":
        this.format = this.format || [];
        this.format.push({
            message: mw.msg("va-msg-format-date"),
            regexp: "^20[0-9]{2}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$"
        });
        break;

      case "url":
        this.format = this.format || [];
        this.format.push({
            regexp: "http(s)?:\\/\\/[-a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)"
        });
        this.preview = this.preview || [];
        this.preview.push({
            type: "url",
            url: "{parameter}"
        });
        break;

      case "wikidata-item-id":
        this.format = this.format || [];
        this.format.push({
            message: mw.msg("va-msg-format-wikidataItemId-qxxx"),
            regexp: "^Q[0-9]+$"
        });
        this.preview = this.preview || [];
        this.preview.push({
            type: "url",
            url: "https://www.wikidata.org/wiki/{parameter}"
        });
        break;
    }
};

mw.VcardAssistant.UI.Parameter.prototype.emit = null;

mw.VcardAssistant.UI.Parameter.prototype.off = null;

mw.VcardAssistant.UI.Parameter.prototype.on = null;

mw.VcardAssistant.UI.Parameter.prototype.applyWikidata = function(claimValue, claimId, wikidataId) {
    this.inputFieldLayoutWidget.$element.addClass("has-wikidata");
    if (this.wikidataButton !== null) {
        this.wikidataButton.setDisabled(false);
        this.wikidataButton.setTitle(mw.msg("va-msg-wikidata-editOnWikidata"));
        this.wikidataButton.$button.attr("href", "https://www.wikidata.org/wiki/".concat(wikidataId, "#").concat(claimId));
    }
    this.wikidataClaim = {
        claimId: claimId,
        claimValue: claimValue,
        wikidataId: wikidataId
    };
    this.inputWidget.$input.attr("placeholder", "Wikidata: ".concat(claimValue));
    var event = new Event("wikidataidchange");
    event.wikidataId = wikidataId;
    this.emit(event);
};

mw.VcardAssistant.UI.Parameter.prototype.clearWikidata = function() {
    this.inputFieldLayoutWidget.$element.removeClass("has-wikidata");
    if (typeof this.wikidataButton !== "undefined") {
        this.wikidataButton.setDisabled(true);
        this.wikidataButton.setTitle(mw.msg("va-msg-wikidata-canBeObtainedFromWikidata"));
        this.wikidataButton.$button.removeAttr("href");
        this.wikidataButton.$button.removeAttr("target");
    }
    this.wikidataClaim = null;
    this.inputWidget.$input.attr("placeholder", this.example !== null ? mw.msg("va-msg-parameter-forExample", this.example) : "");
};

mw.VcardAssistant.UI.Parameter.prototype.getParameterButton = function() {
    if (this.parameterButton !== null) {
        return this.parameterButton;
    } else {
        this.parameterButton = new mw.VcardAssistant.UI.ParameterButton(this.editForm, this, this.prefill !== null);
        return this.parameterButton;
    }
};

mw.VcardAssistant.UI.Parameter.prototype.getParameterInputField = function() {
    var _this = this, _this$multiple;
    function toggleUpdateLastEdit(parameter, value) {
        parameter.updateLastEditButton.setValue(value);
    }
    if (this.inputFieldLayoutWidget !== null) {
        return this.inputFieldLayoutWidget;
    } else {
        var fieldLayoutConfig = {
            align: "top",
            label: this.label
        }, inputWidgetConfig = {};
        if (this.description !== null) {
            fieldLayoutConfig.help = this.description;
        }
        if (this.example !== null) {
            inputWidgetConfig.placeholder = mw.msg("va-msg-parameter-forExample", this.example);
        }
        if (this.max !== null) {
            inputWidgetConfig.max = this.max;
        }
        if (this.min !== null) {
            inputWidgetConfig.min = this.min;
        }
        if (this.multiline !== null) {
            inputWidgetConfig.rows = this.multiline;
        }
        if (this.prefill !== null) {
            fieldLayoutConfig.value = this.prefill;
        }
        if (this.required !== null) {
            inputWidgetConfig.required = this.required;
        }
        var actualInput = null;
        switch (this.type) {
          case "commons-category":
            this.inputWidget = new mw.VcardAssistant.UI.CommonsSearchField("Category", "14", inputWidgetConfig);
            actualInput = this.inputWidget.$input;
            this.inputWidget.getParameterValue = function() {
                return _this.inputWidget.getValue();
            };
            if (this.prefill !== null) {
                this.inputWidget.setValue(this.prefill);
            }
            this.inputFieldLayoutWidget = new OO.ui.FieldLayout(this.inputWidget, fieldLayoutConfig);
            break;

          case "commons-file":
            this.inputWidget = new mw.VcardAssistant.UI.CommonsSearchField("File", "6", inputWidgetConfig);
            actualInput = this.inputWidget.$input;
            this.inputWidget.getParameterValue = function() {
                return _this.inputWidget.getValue();
            };
            if (this.prefill !== null) {
                this.inputWidget.setValue(this.prefill);
            }
            this.inputFieldLayoutWidget = new OO.ui.FieldLayout(this.inputWidget, fieldLayoutConfig);
            break;

          case "enum":
            inputWidgetConfig.allowArbitrary = true;
            if ((_this$multiple = this.multiple) !== null && _this$multiple !== void 0 ? _this$multiple : false) {
                inputWidgetConfig.inputPosition = "outline";
                this.inputWidget = new mw.VcardAssistant.UI.CustomMenuTagMultiselectWidget(null, inputWidgetConfig);
                this.inputWidget.pushPending();
                this.inputWidget.getParameterValue = function() {
                    return _this.inputWidget.getValue().map(function(item) {
                        return item;
                    }).join(", ");
                };
                this.getEnumItems()["finally"](function() {
                    _this.inputWidget.popPending();
                }).then(function(v) {
                    var colorMap = {};
                    for (var _i = 0, _Object$keys = Object.keys(v); _i < _Object$keys.length; _i++) {
                        var _v$key$color;
                        var key = _Object$keys[_i];
                        colorMap[v[key].data] = (_v$key$color = v[key].color) !== null && _v$key$color !== void 0 ? _v$key$color : null;
                    }
                    _this.inputWidget.colorMap = colorMap;
                    _this.inputWidget.addOptions(v);
                    if (_this.inputWidget.getParameterValue().length > 0) {
                        _this.inputWidget.setValue(_this.inputWidget.getParameterValue().split(","));
                    }
                })["catch"](function(e) {
                    mw.log.error(e);
                });
                if (this.prefill !== null) {
                    this.inputWidget.setValue(this.prefill.replace(/ ?, /g, ",").split(","));
                }
                this.inputFieldLayoutWidget = new OO.ui.FieldLayout(this.inputWidget, fieldLayoutConfig);
            } else {
                this.inputWidget = new OO.ui.DropdownInputWidget(inputWidgetConfig);
                if (this.prefill !== null) {
                    this.inputWidget.setOptions([ {
                        data: "",
                        label: mw.msg("va-msg-list-novalue")
                    }, {
                        data: this.prefill,
                        label: this.prefill
                    } ]);
                    this.inputWidget.setValue(this.prefill);
                }
                this.inputWidget.getParameterValue = function() {
                    return _this.inputWidget.getValue();
                };
                this.getEnumItems().then(function(v) {
                    if (_this.prefill !== null && v.find(function(item) {
                        return item.data === _this.prefill;
                    }) === undefined) {
                        v.unshift({
                            data: _this.prefill,
                            label: mw.msg("va-msg-list-unknownvalue", _this.prefill)
                        });
                    }
                    v.unshift({
                        data: "",
                        label: mw.msg("va-msg-list-novalue")
                    });
                    _this.inputWidget.setOptions(v);
                    if (_this.prefill !== null) {
                        _this.inputWidget.setValue(_this.prefill);
                    }
                })["catch"](function(e) {
                    mw.log.error(e);
                });
                this.inputFieldLayoutWidget = new OO.ui.FieldLayout(this.inputWidget, fieldLayoutConfig);
            }
            break;

          case "lastedit":
            this.inputWidget = new OO.ui.TextInputWidget();
            actualInput = this.inputWidget.$input;
            this.inputWidget.getParameterValue = function() {
                return _this.inputWidget.getValue();
            };
            if (this.prefill !== null) {
                this.inputWidget.setValue(this.prefill);
            }
            this.inputWidget.oldvalue = "";
            var updateButton = new OO.ui.ToggleButtonWidget({
                label: mw.msg("va-msg-parameter-markAsUpdated"),
                title: mw.msg("va-msg-parameter-markAsUpdated-description")
            });
            this.inputFieldLayoutWidget = new OO.ui.ActionFieldLayout(this.inputWidget, updateButton, fieldLayoutConfig);
            updateButton.on("change", function(value) {
                if (value) {
                    var date = new Date();
                    _this.inputWidget.oldvalue = _this.inputWidget.getValue();
                    _this.inputWidget.setValue("".concat(String(date.getFullYear()).padStart(4, "0"), "-").concat(String(date.getMonth() + 1).padStart(2, "0"), "-").concat(String(date.getDate()).padStart(2, "0")));
                } else {
                    _this.inputWidget.setValue(_this.inputWidget.oldvalue);
                }
            });
            this.updateLastEditButton = updateButton;
            this.getUpdateLastEdit = function() {
                return updateButton.getValue();
            };
            this.setUpdateLastEdit = function(value) {
                toggleUpdateLastEdit(_this, value);
            };
            break;

          case "number":
            this.inputWidget = new OO.ui.NumberInputWidget(inputWidgetConfig);
            actualInput = this.inputWidget.$input;
            this.inputWidget.getParameterValue = function() {
                return _this.inputWidget.getValue();
            };
            if (this.prefill !== null) {
                this.inputWidget.setValue(this.prefill);
            }
            this.inputFieldLayoutWidget = new OO.ui.FieldLayout(this.inputWidget, fieldLayoutConfig);
            break;

          case "toggle":
            this.inputWidget = new OO.ui.ToggleSwitchWidget(inputWidgetConfig);
            this.inputWidget.getParameterValue = function() {
                return _this.inputWidget.getValue() ? _this.vcardAssistantConfig.config.togglevalue_on : _this.vcardAssistantConfig.config.togglevalue_off;
            };
            if (this.prefill !== null && /^j|ja|n|no|y|yes$/.test(this.prefill)) {
                this.inputWidget.setValue(!/^n|no$/.test(this.prefill));
            }
            this.inputFieldLayoutWidget = new OO.ui.FieldLayout(this.inputWidget, fieldLayoutConfig);
            break;

          case "wikidata-item-id":
            this.inputWidget = new mw.VcardAssistant.UI.WikidataSearchField(this.editForm, inputWidgetConfig);
            actualInput = this.inputWidget.$input;
            this.inputWidget.getParameterValue = function() {
                return _this.inputWidget.getValue();
            };
            if (this.prefill !== null) {
                this.inputWidget.setValue(this.prefill);
            }
            this.inputFieldLayoutWidget = new OO.ui.FieldLayout(this.inputWidget, fieldLayoutConfig);
            break;

          case "string":
          default:
            if (this.type === "string" && this.multiline !== null) {
                this.inputWidget = new OO.ui.MultilineTextInputWidget(inputWidgetConfig);
                actualInput = this.inputWidget.$input;
                this.inputWidget.$element.css("resize", "vertical");
                this.inputWidget.getParameterValue = function() {
                    return _this.inputWidget.getValue();
                };
                if (this.prefill !== null) {
                    this.inputWidget.setValue(this.prefill);
                }
                this.inputFieldLayoutWidget = new OO.ui.FieldLayout(this.inputWidget, fieldLayoutConfig);
            } else {
                this.inputWidget = new OO.ui.TextInputWidget(inputWidgetConfig);
                actualInput = this.inputWidget.$input;
                this.inputWidget.getParameterValue = function() {
                    return _this.inputWidget.getValue();
                };
                if (this.prefill !== null) {
                    this.inputWidget.setValue(this.prefill);
                }
                this.inputFieldLayoutWidget = new OO.ui.FieldLayout(this.inputWidget, fieldLayoutConfig);
                if (this.type === "url") {
                    actualInput.attr("type", "url");
                }
            }
        }
        this.inputFieldLayoutWidget.$label.attr("title", this.parameterName);
        this.addHeaderButtons();
        if (this.prefill !== null) {
            this.validate(true);
        }
        this.inputWidget.on("change", function(value) {
            var event = new Event("change");
            event.value = value;
            _this.emit(event);
        });
        if (actualInput !== null) {
            actualInput.on("blur", function() {
                var event = new Event("blur");
                _this.emit(event);
            });
            actualInput.on("focus", function() {
                var event = new Event("focus");
                _this.emit(event);
            });
        }
        this.on("blur", function() {
            _this.validate(true);
        });
        this.on("change", function() {
            _this.validate(false);
        });
        return this.inputFieldLayoutWidget;
    }
};

mw.VcardAssistant.UI.Parameter.prototype.getEnumItems = _asyncToGenerator(_regeneratorRuntime().mark(function _callee() {
    return _regeneratorRuntime().wrap(function _callee$(_context) {
        while (1) {
            switch (_context.prev = _context.next) {
              case 0:
                if (!(typeof this["enum"] === "string")) {
                    _context.next = 6;
                    break;
                }
                _context.next = 3;
                return this.adaptations.queryEnum(this["enum"]);

              case 3:
                return _context.abrupt("return", _context.sent);

              case 6:
                if (!(_typeof(this["enum"]) === "object")) {
                    _context.next = 8;
                    break;
                }
                return _context.abrupt("return", this["enum"].map(function(item) {
                    var data;
                    if (typeof item === "string") {
                        data = {
                            data: item,
                            label: item
                        };
                        return data;
                    } else {
                        var _item$label;
                        return {
                            data: item.data,
                            label: "".concat((_item$label = item.label) !== null && _item$label !== void 0 ? _item$label : item.data)
                        };
                    }
                }));

              case 8:
              case "end":
                return _context.stop();
            }
        }
    }, _callee, this);
}));

mw.VcardAssistant.UI.Parameter.prototype.getMessagePopupWidget = function() {
    var _this2 = this;
    if (this.messagePopupWidget === null) {
        this.messagePopupWidget = new OO.ui.PopupWidget({
            $content: $("<ul>"),
            padded: true,
            width: 300
        });
        this.messagePopupWidget.$element.on("click", function(e) {
            if (!e.ctrlKey) {
                _this2.messagePopupWidget.toggle(false);
            }
        });
        this.inputFieldLayoutWidget.$element.append(this.messagePopupWidget.$element);
    }
    return this.messagePopupWidget;
};

mw.VcardAssistant.UI.Parameter.prototype.getValue = function() {
    return this.inputWidget.getParameterValue();
};

mw.VcardAssistant.UI.Parameter.prototype.setValue = function(value) {
    this.inputWidget.setValue(value);
};

mw.VcardAssistant.UI.Parameter.prototype.toggle = function(target) {
    this.inputFieldLayoutWidget.toggle(target);
    this.hidden = !target;
};

mw.VcardAssistant.UI.Parameter.prototype.validate = function(showWarning, suppressEvent) {
    var value = this.getValue();
    var result;
    if (!this.required && value === "") {
        this.clearValidation(true, true);
        result = true;
    } else if (this.required && value === "") {
        this.setValidationViolation([ mw.msg("va-msg-format-obligatoryParameter-description") ], showWarning);
        result = false;
    } else if (this.format === null) {
        this.clearValidation(true, true);
        result = true;
    } else {
        var errorMessages = [];
        var isValid = this.format.reduce(function(accumulator, currentValue) {
            var validationResult = new RegExp(currentValue.regexp).test(value);
            if (!validationResult && currentValue.message !== undefined) {
                errorMessages.push(currentValue.message);
            }
            return accumulator && validationResult;
        }, true);
        if (isValid) {
            this.clearValidation(true, true);
        } else {
            this.setValidationViolation(errorMessages, showWarning);
        }
        result = isValid;
    }
    if (suppressEvent === undefined || !suppressEvent) {
        var event = new Event("validate");
        event.valid = result;
        event.value = this.getValue();
        this.emit(event);
    }
    return result;
};

mw.VcardAssistant.UI.Parameter.prototype.wasChanged = function() {
    if (this.hidden) {
        return this.prefill !== null && this.prefill !== "";
    } else {
        if (this.prefill === null) {
            return this.getValue() !== "";
        } else {
            return this.getValue() !== this.prefill;
        }
    }
};

mw.VcardAssistant.UI.Parameter.prototype.addHeaderButtons = function() {
    var $header = this.inputFieldLayoutWidget.$element.find(".oo-ui-fieldLayout-header");
    this.addWikidataHeaderButton($header);
    this.addPreviewHeaderButton($header);
};

mw.VcardAssistant.UI.Parameter.prototype.addPreviewHeaderButton = function($header) {
    var _this3 = this;
    var that = this;
    function setUrlHref(value, caller, parameters) {
        var urlDeclaration = caller.preview.url.find(function(url) {
            return url.conditions === undefined || mw.VcardAssistant.UI.Condition.evaluateRawConjunctiveConditions(url.conditions, caller, parameters);
        });
        caller.previewButton.$button.attr("href", urlDeclaration.url.replace(/{parameter}/, value).replace(/{encodedparameter}/, encodeURIComponent(value)));
    }
    function updateFromCoordinateParameters(valid, lat, _long, previewButton, mapPopup) {
        mapPopup.toggle(false);
        if (mapPopup.destroyMap !== undefined) {
            try {
                mapPopup.destroyMap();
            } catch (ex) {}
        }
        if (lat.wikidataClaim !== null && _long.wikidataClaim !== null || valid && lat.getValue() !== "" && _long.getValue() !== "") {
            previewButton.setDisabled(false);
        } else {
            previewButton.setDisabled(true);
        }
    }
    if (this.preview !== null) {
        switch (this.preview.type) {
          case "coordinates":
            {
                var mapPopup = new OO.ui.PopupWidget({
                    $content: $("<i>".concat(mw.msg("va-msg-preview-prepare"), "</i>")),
                    classes: [ "mappreviewcontainer" ],
                    height: 300,
                    width: 300
                });
                mapPopup.$element.append(new OO.ui.ProgressBarWidget({
                    progress: false
                }));
                var lat;
                var _long2;
                if (this.preview.lat === "$this") {
                    lat = this;
                    _long2 = this.editForm.parameters[this.preview["long"]];
                } else {
                    lat = this.editForm.parameters[this.preview.lat];
                    _long2 = this;
                }
                this.previewButton = new OO.ui.ButtonWidget({
                    classes: [ "ext-vcardassistant-headeraction", "ext-vcardassistant-previewaction" ],
                    disabled: true,
                    framed: false,
                    icon: "map",
                    title: mw.msg("va-msg-preview-map-description")
                });
                this.previewButton.$button.attr("rel", "noopener noreferrer").attr("target", "_blank");
                this.previewButton.$element.append(mapPopup.$element);
                this.previewButton.on("click", function() {
                    mapPopup.toggle();
                    if (mapPopup.isVisible()) {
                        _this3.setupMapPreviewPopup(lat, _long2, mapPopup);
                    }
                });
                if ($header.find(".oo-ui-fieldLayout-help").length > 0) {
                    $header.find(".oo-ui-fieldLayout-help").after(this.previewButton.$element);
                } else {
                    $header.prepend(this.previewButton.$element);
                }
                mw.VcardAssistant.Util.on([ lat, _long2 ], [ "validate", "wikidataidchange" ], function() {
                    updateFromCoordinateParameters(lat.validate(false, true) && _long2.validate(false, true), lat, _long2, that.previewButton, mapPopup);
                });
                break;
            }

          case "url":
            {
                if (typeof this.preview.url === "string") {
                    this.preview.url = [ {
                        url: this.preview.url
                    } ];
                }
                this.previewButton = new OO.ui.ButtonWidget({
                    classes: [ "ext-vcardassistant-headeraction", "ext-vcardassistant-previewaction" ],
                    disabled: true,
                    framed: false,
                    icon: "linkExternal",
                    title: mw.msg("va-msg-preview-url-description")
                });
                this.previewButton.$button.attr("rel", "noopener noreferrer");
                this.previewButton.$button.attr("target", "_blank");
                if ($header.find(".oo-ui-fieldLayout-help").length > 0) {
                    $header.find(".oo-ui-fieldLayout-help").after(this.previewButton.$element);
                } else {
                    $header.prepend(this.previewButton.$element);
                }
                mw.VcardAssistant.Util.on(this, [ "validate", "wikidataidchange" ], function(e) {
                    if (that.validate(false, true) && that.getValue() !== "") {
                        that.previewButton.setDisabled(false);
                        setUrlHref(e.value, that, that.editForm.parameters);
                    } else if (that.wikidataClaim !== null) {
                        that.previewButton.setDisabled(false);
                        setUrlHref(that.wikidataClaim.claimValue, that, that.editForm.parameters);
                    } else {
                        that.previewButton.setDisabled(true);
                    }
                });
                break;
            }
        }
    }
};

mw.VcardAssistant.UI.Parameter.prototype.addWikidataHeaderButton = function($header) {
    if (this.wikidata !== null) {
        this.wikidataButton = new OO.ui.ButtonWidget({
            classes: [ "ext-vcardassistant-headeraction", "ext-vcardassistant-wikidataaction" ],
            disabled: true,
            framed: false,
            icon: "logoWikidata",
            title: mw.msg("va-msg-wikidata-canBeObtainedFromWikidata")
        });
        this.wikidataButton.$button.attr("rel", "noopener noreferrer");
        this.wikidataButton.$button.attr("target", "_blank");
        if ($header.find(".oo-ui-fieldLayout-help").length > 0) {
            $header.find(".oo-ui-fieldLayout-help").after(this.wikidataButton.$element);
        } else {
            $header.prepend(this.wikidataButton.$element);
        }
    }
};

mw.VcardAssistant.UI.Parameter.prototype.clearValidation = function() {
    var field = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
    var popup = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
    if (field) {
        this.inputFieldLayoutWidget.$element.removeClass("invalid");
    }
    if (popup && this.messagePopupWidget !== null) {
        this.messagePopupWidget.toggle(false);
    }
};

mw.VcardAssistant.UI.Parameter.prototype.performTriggerAction = function(trigger) {
    if (typeof trigger.action.value !== "undefined") {
        this.setValue(trigger.action.value);
    } else if (typeof trigger.action.visible !== "undefined") {
        if (trigger.action.visible) {
            this.toggle(true);
            this.inputFieldLayoutWidget.$element.addClass("fadein");
        } else {
            this.toggle(false);
            this.inputFieldLayoutWidget.$element.removeClass("fadein");
        }
    } else if (typeof trigger.action.excluded !== "undefined") {
        this.excluded = trigger.action.excluded;
    }
};

mw.VcardAssistant.UI.Parameter.prototype.setupMapPreviewPopup = function(lat, _long3, mapPopup) {
    mw.loader.using([ "ext.kartographer.box" ], function() {
        var kartoBox = mw.loader.require("ext.kartographer.box");
        var mapContainer = $(mapPopup.$body[0]).empty().append("<div>").children().css({
            height: 300
        });
        var coordinates = null;
        var markers = [];
        if (lat.wikidataClaim !== null && _long3.wikidataClaim !== null) {
            markers.push({
                type: "Feature",
                properties: {
                    "marker-color": "#9a0000",
                    "marker-size": "medium",
                    "marker-symbol": "marker",
                    title: mw.msg("va-msg-preview-map-markerFromWikidata"),
                    description: "(".concat(lat.wikidataClaim.claimValue, ", ").concat(_long3.wikidataClaim.claimValue, ")")
                },
                geometry: {
                    type: "Point",
                    coordinates: [ _long3.wikidataClaim.claimValue, lat.wikidataClaim.claimValue ]
                }
            });
            coordinates = [ lat.wikidataClaim.claimValue, _long3.wikidataClaim.claimValue ];
        }
        if (lat.validate(false, true) && lat.getValue() !== "" && _long3.validate(false, true) && _long3.getValue() !== "") {
            markers.push({
                type: "Feature",
                properties: {
                    "marker-color": "#3366cc",
                    "marker-size": "medium",
                    "marker-symbol": "marker",
                    title: mw.msg("va-msg-preview-map-markerFromParameter"),
                    description: "(".concat(lat.getValue(), ", ").concat(_long3.getValue(), ")")
                },
                geometry: {
                    type: "Point",
                    coordinates: [ parseFloat(_long3.getValue()), parseFloat(lat.getValue()) ]
                }
            });
            coordinates = [ parseFloat(lat.getValue()), parseFloat(_long3.getValue()) ];
        }
        var map = kartoBox.map({
            allowFullScreen: true,
            container: mapContainer[0],
            center: coordinates,
            data: markers,
            zoom: 14
        });
        mapPopup.destroyMap = function() {
            map.remove();
        };
    });
};

mw.VcardAssistant.UI.Parameter.prototype.setupTrigger = function(trigger, parameters) {
    var that = this;
    function checkConditions(conditions) {
        if (mw.VcardAssistant.UI.Condition.evaluateConjunctiveConditions(conditions)) {
            that.performTriggerAction(trigger);
            return true;
        } else {
            return false;
        }
    }
    var conditionList = mw.VcardAssistant.UI.Condition.parseRawConditionList(trigger.conditions, that, parameters);
    var _iterator = _createForOfIteratorHelper(conditionList), _step;
    try {
        for (_iterator.s(); !(_step = _iterator.n()).done; ) {
            var condition = _step.value;
            condition.watchSender(function() {
                checkConditions(conditionList);
            });
        }
    } catch (err) {
        _iterator.e(err);
    } finally {
        _iterator.f();
    }
    return checkConditions(conditionList);
};

mw.VcardAssistant.UI.Parameter.prototype.setValidationViolation = function(errorMessages, openPopup) {
    if (errorMessages.length > 0) {
        var messagePopupWidget = this.getMessagePopupWidget();
        $(messagePopupWidget.$body[0]).html("<ul>".concat(errorMessages.map(function(val) {
            return "<li>".concat(val, "</li>");
        }).join(""), "</ul>"));
        if (openPopup) {
            messagePopupWidget.toggle(true);
        }
    }
    this.inputFieldLayoutWidget.$element.addClass("invalid");
};

"use strict";

function _typeof(obj) {
    "@babel/helpers - typeof";
    return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
        return typeof obj;
    } : function(obj) {
        return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
    }, _typeof(obj);
}

function _slicedToArray(arr, i) {
    return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}

function _nonIterableRest() {
    throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}

function _unsupportedIterableToArray(o, minLen) {
    if (!o) return;
    if (typeof o === "string") return _arrayLikeToArray(o, minLen);
    var n = Object.prototype.toString.call(o).slice(8, -1);
    if (n === "Object" && o.constructor) n = o.constructor.name;
    if (n === "Map" || n === "Set") return Array.from(o);
    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}

function _arrayLikeToArray(arr, len) {
    if (len == null || len > arr.length) len = arr.length;
    for (var i = 0, arr2 = new Array(len); i < len; i++) {
        arr2[i] = arr[i];
    }
    return arr2;
}

function _iterableToArrayLimit(arr, i) {
    var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
    if (_i == null) return;
    var _arr = [];
    var _n = true;
    var _d = false;
    var _s, _e;
    try {
        for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
            _arr.push(_s.value);
            if (i && _arr.length === i) break;
        }
    } catch (err) {
        _d = true;
        _e = err;
    } finally {
        try {
            if (!_n && _i["return"] != null) _i["return"]();
        } finally {
            if (_d) throw _e;
        }
    }
    return _arr;
}

function _arrayWithHoles(arr) {
    if (Array.isArray(arr)) return arr;
}

function _regeneratorRuntime() {
    "use strict";
    _regeneratorRuntime = function _regeneratorRuntime() {
        return exports;
    };
    var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
    function define(obj, key, value) {
        return Object.defineProperty(obj, key, {
            value: value,
            enumerable: !0,
            configurable: !0,
            writable: !0
        }), obj[key];
    }
    try {
        define({}, "");
    } catch (err) {
        define = function define(obj, key, value) {
            return obj[key] = value;
        };
    }
    function wrap(innerFn, outerFn, self, tryLocsList) {
        var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []);
        return generator._invoke = function(innerFn, self, context) {
            var state = "suspendedStart";
            return function(method, arg) {
                if ("executing" === state) throw new Error("Generator is already running");
                if ("completed" === state) {
                    if ("throw" === method) throw arg;
                    return doneResult();
                }
                for (context.method = method, context.arg = arg; ;) {
                    var delegate = context.delegate;
                    if (delegate) {
                        var delegateResult = maybeInvokeDelegate(delegate, context);
                        if (delegateResult) {
                            if (delegateResult === ContinueSentinel) continue;
                            return delegateResult;
                        }
                    }
                    if ("next" === context.method) context.sent = context._sent = context.arg; else if ("throw" === context.method) {
                        if ("suspendedStart" === state) throw state = "completed", 
                        context.arg;
                        context.dispatchException(context.arg);
                    } else "return" === context.method && context.abrupt("return", context.arg);
                    state = "executing";
                    var record = tryCatch(innerFn, self, context);
                    if ("normal" === record.type) {
                        if (state = context.done ? "completed" : "suspendedYield", 
                        record.arg === ContinueSentinel) continue;
                        return {
                            value: record.arg,
                            done: context.done
                        };
                    }
                    "throw" === record.type && (state = "completed", context.method = "throw", 
                    context.arg = record.arg);
                }
            };
        }(innerFn, self, context), generator;
    }
    function tryCatch(fn, obj, arg) {
        try {
            return {
                type: "normal",
                arg: fn.call(obj, arg)
            };
        } catch (err) {
            return {
                type: "throw",
                arg: err
            };
        }
    }
    exports.wrap = wrap;
    var ContinueSentinel = {};
    function Generator() {}
    function GeneratorFunction() {}
    function GeneratorFunctionPrototype() {}
    var IteratorPrototype = {};
    define(IteratorPrototype, iteratorSymbol, function() {
        return this;
    });
    var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([])));
    NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
    var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
    function defineIteratorMethods(prototype) {
        [ "next", "throw", "return" ].forEach(function(method) {
            define(prototype, method, function(arg) {
                return this._invoke(method, arg);
            });
        });
    }
    function AsyncIterator(generator, PromiseImpl) {
        function invoke(method, arg, resolve, reject) {
            var record = tryCatch(generator[method], generator, arg);
            if ("throw" !== record.type) {
                var result = record.arg, value = result.value;
                return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function(value) {
                    invoke("next", value, resolve, reject);
                }, function(err) {
                    invoke("throw", err, resolve, reject);
                }) : PromiseImpl.resolve(value).then(function(unwrapped) {
                    result.value = unwrapped, resolve(result);
                }, function(error) {
                    return invoke("throw", error, resolve, reject);
                });
            }
            reject(record.arg);
        }
        var previousPromise;
        this._invoke = function(method, arg) {
            function callInvokeWithMethodAndArg() {
                return new PromiseImpl(function(resolve, reject) {
                    invoke(method, arg, resolve, reject);
                });
            }
            return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
        };
    }
    function maybeInvokeDelegate(delegate, context) {
        var method = delegate.iterator[context.method];
        if (undefined === method) {
            if (context.delegate = null, "throw" === context.method) {
                if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, 
                maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
                context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
            }
            return ContinueSentinel;
        }
        var record = tryCatch(method, delegate.iterator, context.arg);
        if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, 
        context.delegate = null, ContinueSentinel;
        var info = record.arg;
        return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, 
        "return" !== context.method && (context.method = "next", context.arg = undefined), 
        context.delegate = null, ContinueSentinel) : info : (context.method = "throw", 
        context.arg = new TypeError("iterator result is not an object"), context.delegate = null, 
        ContinueSentinel);
    }
    function pushTryEntry(locs) {
        var entry = {
            tryLoc: locs[0]
        };
        1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], 
        entry.afterLoc = locs[3]), this.tryEntries.push(entry);
    }
    function resetTryEntry(entry) {
        var record = entry.completion || {};
        record.type = "normal", delete record.arg, entry.completion = record;
    }
    function Context(tryLocsList) {
        this.tryEntries = [ {
            tryLoc: "root"
        } ], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
    }
    function values(iterable) {
        if (iterable) {
            var iteratorMethod = iterable[iteratorSymbol];
            if (iteratorMethod) return iteratorMethod.call(iterable);
            if ("function" == typeof iterable.next) return iterable;
            if (!isNaN(iterable.length)) {
                var i = -1, next = function next() {
                    for (;++i < iterable.length; ) {
                        if (hasOwn.call(iterable, i)) return next.value = iterable[i], 
                        next.done = !1, next;
                    }
                    return next.value = undefined, next.done = !0, next;
                };
                return next.next = next;
            }
        }
        return {
            next: doneResult
        };
    }
    function doneResult() {
        return {
            value: undefined,
            done: !0
        };
    }
    return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), 
    define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), 
    exports.isGeneratorFunction = function(genFun) {
        var ctor = "function" == typeof genFun && genFun.constructor;
        return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
    }, exports.mark = function(genFun) {
        return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, 
        define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), 
        genFun;
    }, exports.awrap = function(arg) {
        return {
            __await: arg
        };
    }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function() {
        return this;
    }), exports.AsyncIterator = AsyncIterator, exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
        void 0 === PromiseImpl && (PromiseImpl = Promise);
        var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
        return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function(result) {
            return result.done ? result.value : iter.next();
        });
    }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function() {
        return this;
    }), define(Gp, "toString", function() {
        return "[object Generator]";
    }), exports.keys = function(object) {
        var keys = [];
        for (var key in object) {
            keys.push(key);
        }
        return keys.reverse(), function next() {
            for (;keys.length; ) {
                var key = keys.pop();
                if (key in object) return next.value = key, next.done = !1, next;
            }
            return next.done = !0, next;
        };
    }, exports.values = values, Context.prototype = {
        constructor: Context,
        reset: function reset(skipTempReset) {
            if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, 
            this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, 
            this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
                "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
            }
        },
        stop: function stop() {
            this.done = !0;
            var rootRecord = this.tryEntries[0].completion;
            if ("throw" === rootRecord.type) throw rootRecord.arg;
            return this.rval;
        },
        dispatchException: function dispatchException(exception) {
            if (this.done) throw exception;
            var context = this;
            function handle(loc, caught) {
                return record.type = "throw", record.arg = exception, context.next = loc, 
                caught && (context.method = "next", context.arg = undefined), !!caught;
            }
            for (var i = this.tryEntries.length - 1; i >= 0; --i) {
                var entry = this.tryEntries[i], record = entry.completion;
                if ("root" === entry.tryLoc) return handle("end");
                if (entry.tryLoc <= this.prev) {
                    var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc");
                    if (hasCatch && hasFinally) {
                        if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
                        if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
                    } else if (hasCatch) {
                        if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
                    } else {
                        if (!hasFinally) throw new Error("try statement without catch or finally");
                        if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
                    }
                }
            }
        },
        abrupt: function abrupt(type, arg) {
            for (var i = this.tryEntries.length - 1; i >= 0; --i) {
                var entry = this.tryEntries[i];
                if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
                    var finallyEntry = entry;
                    break;
                }
            }
            finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
            var record = finallyEntry ? finallyEntry.completion : {};
            return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", 
            this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
        },
        complete: function complete(record, afterLoc) {
            if ("throw" === record.type) throw record.arg;
            return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, 
            this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), 
            ContinueSentinel;
        },
        finish: function finish(finallyLoc) {
            for (var i = this.tryEntries.length - 1; i >= 0; --i) {
                var entry = this.tryEntries[i];
                if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), 
                resetTryEntry(entry), ContinueSentinel;
            }
        },
        catch: function _catch(tryLoc) {
            for (var i = this.tryEntries.length - 1; i >= 0; --i) {
                var entry = this.tryEntries[i];
                if (entry.tryLoc === tryLoc) {
                    var record = entry.completion;
                    if ("throw" === record.type) {
                        var thrown = record.arg;
                        resetTryEntry(entry);
                    }
                    return thrown;
                }
            }
            throw new Error("illegal catch attempt");
        },
        delegateYield: function delegateYield(iterable, resultName, nextLoc) {
            return this.delegate = {
                iterator: values(iterable),
                resultName: resultName,
                nextLoc: nextLoc
            }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
        }
    }, exports;
}

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
    try {
        var info = gen[key](arg);
        var value = info.value;
    } catch (error) {
        reject(error);
        return;
    }
    if (info.done) {
        resolve(value);
    } else {
        Promise.resolve(value).then(_next, _throw);
    }
}

function _asyncToGenerator(fn) {
    return function() {
        var self = this, args = arguments;
        return new Promise(function(resolve, reject) {
            var gen = fn.apply(self, args);
            function _next(value) {
                asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
            }
            function _throw(err) {
                asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
            }
            _next(undefined);
        });
    };
}

mw.VcardAssistant.UI.PreviewForm = function(vcardAssistantConfig, parameters, parameterOrder, neverOmitParameters, editForm) {
    var _this = this;
    mw.VcardAssistant.UI.PreviewForm.parent.call(this);
    this.editForm = editForm;
    this.neverOmitParameters = neverOmitParameters;
    this.parameters = parameters;
    this.parameterOrder = parameterOrder;
    this.vcardAssistantConfig = vcardAssistantConfig;
    var contentPanel = new OO.ui.StackLayout({
        classes: [ "ext-vcardassistant-previewform-contentpanel" ],
        expanded: true,
        padded: true
    }), previewPanel = new OO.ui.PanelLayout({
        classes: [ "ext-vcardassistant-previewform-previewpanel" ],
        expanded: false
    });
    previewPanel.$element.append(new OO.ui.LabelWidget({
        label: mw.msg("va-msg-preview-title")
    }).$element);
    this.previewPanel = new OO.ui.PanelLayout({
        classes: [ "ext-vcardassistant-previewform-previewpanel" ],
        framed: true,
        expanded: false,
        padded: false
    });
    previewPanel.$element.append(this.previewPanel.$element);
    this.mediawikiCodeInputWidget = new OO.ui.MultilineTextInputWidget({
        rows: 5
    });
    this.mediawikiCodeInputWidget.$input.attr("readonly", true);
    previewPanel.$element.append(new OO.ui.FieldLayout(this.mediawikiCodeInputWidget, {
        align: "top",
        label: mw.msg("va-msg-preview-generatedCode-title")
    }).$element);
    contentPanel.$element.append(previewPanel.$element);
    var submitPanel = new OO.ui.PanelLayout({
        classes: [ "ext-vcardassistant-previewform-submitpanel" ],
        expanded: false,
        padded: false
    });
    this.summaryInputWidget = new OO.ui.TextInputWidget();
    this.lastUpdateCheckboxInputWidget = new OO.ui.CheckboxInputWidget({
        selected: false,
        value: "update-lastedit"
    });
    this.lastUpdateCheckboxInputWidget.on("change", function(value) {
        _this.editForm.setUpdateLastEdit(value);
        _this.updatePreview();
    });
    this.lastUpdateFieldLayout = new OO.ui.FieldLayout(this.lastUpdateCheckboxInputWidget, {
        align: "inline",
        label: mw.msg("va-msg-preview-action-markAsUpdated")
    });
    this.minorEditCheckboxInputWidget = new OO.ui.CheckboxInputWidget({
        value: "minoredit"
    });
    this.editSectionWikitextCheckboxInputWidget = new OO.ui.CheckboxInputWidget({
        value: "editsectionwikitext"
    });
    var summaryFieldsetLayout = new OO.ui.FieldsetLayout({
        classes: [ "ext-vcardassistant-previewform-summaryfieldset" ],
        label: null,
        items: [ new OO.ui.FieldLayout(this.summaryInputWidget, {
            align: "top",
            label: mw.msg("va-msg-preview-summary")
        }), new OO.ui.FieldLayout(new OO.ui.Widget({
            content: [ new OO.ui.HorizontalLayout({
                items: [ this.lastUpdateFieldLayout, new OO.ui.FieldLayout(this.minorEditCheckboxInputWidget, {
                    align: "inline",
                    label: mw.msg("va-msg-preview-action-minorChanges")
                }), new OO.ui.FieldLayout(this.editSectionWikitextCheckboxInputWidget, {
                    align: "inline",
                    label: mw.msg("va-msg-preview-action-editSectionWikitext")
                }) ]
            }) ]
        }), {
            align: "top",
            label: null
        }) ]
    });
    submitPanel.$element.append(summaryFieldsetLayout.$element);
    submitPanel.$element.append(new OO.ui.HtmlSnippet('<div class="ext-vcardassistant-legal">'.concat(this.vcardAssistantConfig.config.submitLegal, "</div>")).toString());
    contentPanel.$element.append(submitPanel.$element);
    this.$element.append(contentPanel.$element);
};

OO.inheritClass(mw.VcardAssistant.UI.PreviewForm, OO.ui.Widget);

mw.VcardAssistant.UI.PreviewForm.prototype.initialize = _asyncToGenerator(_regeneratorRuntime().mark(function _callee() {
    return _regeneratorRuntime().wrap(function _callee$(_context) {
        while (1) {
            switch (_context.prev = _context.next) {
              case 0:
                if (this.editForm.getUpdateLastEdit() === null) {
                    this.lastUpdateFieldLayout.toggle(false);
                } else {
                    this.lastUpdateCheckboxInputWidget.setSelected(this.editForm.getUpdateLastEdit());
                }
                _context.next = 3;
                return this.updatePreview();

              case 3:
              case "end":
                return _context.stop();
            }
        }
    }, _callee, this);
}));

mw.VcardAssistant.UI.PreviewForm.prototype.focus = function() {
    this.summaryInputWidget.focus();
};

mw.VcardAssistant.UI.PreviewForm.prototype.getDisplayName = function() {
    return this.parameters[this.vcardAssistantConfig.special_parameters.name].getValue();
};

mw.VcardAssistant.UI.PreviewForm.prototype.getParameters = function() {
    var _this2 = this;
    var parameterValueMap = [];
    for (var _i = 0, _Object$entries = Object.entries(this.parameters); _i < _Object$entries.length; _i++) {
        var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), parameterName = _Object$entries$_i[0], parameter = _Object$entries$_i[1];
        var value = void 0;
        if (parameter.hidden) {
            value = "";
        } else {
            value = parameter.getValue();
        }
        if (!parameter.excluded && (value !== "" || this.neverOmitParameters.includes(parameterName))) {
            parameterValueMap.push({
                parameter: parameterName,
                prefill: parameter.prefill,
                value: value.trim()
            });
        }
    }
    var sortedParameterValueMap = parameterValueMap.sort(function(a, b) {
        return _this2.parameterOrder.indexOf(a.parameter) - _this2.parameterOrder.indexOf(b.parameter);
    });
    return sortedParameterValueMap;
};

mw.VcardAssistant.UI.PreviewForm.prototype.getSummary = function() {
    return this.summaryInputWidget.getValue();
};

mw.VcardAssistant.UI.PreviewForm.prototype.getWikitext = function() {
    var parameters = this.getParameters();
    var parameterString = "";
    if (parameters.length > 0) {
        parameterString = " |".concat(parameters.map(function(parameter) {
            return "".concat(parameter.parameter, "=").concat(parameter.value);
        }).join(" |"));
    }
    return "{{vCard".concat(parameterString, "\n}}");
};

mw.VcardAssistant.UI.PreviewForm.prototype.isEditSectionWikitext = function() {
    return this.editSectionWikitextCheckboxInputWidget.isSelected();
};

mw.VcardAssistant.UI.PreviewForm.prototype.isMinorEdit = function() {
    return this.minorEditCheckboxInputWidget.isSelected();
};

mw.VcardAssistant.UI.PreviewForm.prototype.updatePreview = _asyncToGenerator(_regeneratorRuntime().mark(function _callee2() {
    var _this3 = this;
    var wikitext, progressBarWidget, e;
    return _regeneratorRuntime().wrap(function _callee2$(_context2) {
        while (1) {
            switch (_context2.prev = _context2.next) {
              case 0:
                wikitext = this.getWikitext();
                this.mediawikiCodeInputWidget.setValue(wikitext).adjustSize();
                this.previewPanel.$element.html("<i>".concat(mw.msg("va-msg-preview-prepare"), "</i>"));
                progressBarWidget = new OO.ui.ProgressBarWidget({
                    progress: false
                });
                this.previewPanel.$element.append(progressBarWidget.$element);
                _context2.next = 7;
                return $.ajax({
                    data: {
                        action: "parse",
                        format: "json",
                        prop: "text",
                        contentmodel: "wikitext",
                        text: wikitext
                    },
                    method: "GET",
                    url: mw.util.wikiScript("api")
                });

              case 7:
                e = _context2.sent;
                this.previewPanel.$element.html(e.parse.text["*"]);
                this.previewPanel.$element.find("a").each(function() {
                    if ($(_this3).attr("target") === undefined) {
                        $(_this3).attr("target", "_blank");
                    } else if (!$(_this3).attr("target").includes("_blank ")) {
                        $(_this3).attr("target", "".concat($(_this3).attr("target"), " _blank"));
                    }
                });

              case 10:
              case "end":
                return _context2.stop();
            }
        }
    }, _callee2, this);
}));

"use strict";

mw.VcardAssistant.UI.Result = function(action, displayName) {
    this.action = action;
    this.displayName = displayName;
};

mw.VcardAssistant.UI.Result.Action = {
    DELETE: "delete",
    EDIT: "edit"
};

mw.VcardAssistant.UI.Result["delete"] = function(displayName, summary) {
    var result = new mw.VcardAssistant.UI.Result(mw.VcardAssistant.UI.Result.Action.DELETE, displayName);
    result.summary = summary;
    return result;
};

mw.VcardAssistant.UI.Result.edit = function(displayName, wikitext, parameters, summary, isMinorEdit, hasFormatErrors, editSectionWikitext) {
    var result = new mw.VcardAssistant.UI.Result(mw.VcardAssistant.UI.Result.Action.EDIT, displayName);
    result.wikitext = wikitext;
    result.parameters = parameters;
    result.summary = summary;
    result.editSectionWikitext = editSectionWikitext;
    result.isMinorEdit = isMinorEdit;
    result.hasFormatErrors = hasFormatErrors;
    return result;
};

mw.VcardAssistant.UI.Result.tool = function(displayName, wikitext, parameters, hasFormatErrors) {
    var result = new mw.VcardAssistant.UI.Result(mw.VcardAssistant.UI.Result.Action.EDIT, displayName);
    result.wikitext = wikitext;
    result.parameters = parameters;
    result.hasFormatErrors = hasFormatErrors;
    return result;
};

"use strict";

mw.VcardAssistant.UI.SearchResult = function(config) {
    mw.VcardAssistant.UI.SearchResult["super"].call(this, config);
    var $description = $("<span>").addClass("ext-vcardassistant-description").append($("<bdi>").text(config.description || ""));
    this.$element.append($description);
};

OO.inheritClass(mw.VcardAssistant.UI.SearchResult, OO.ui.MenuOptionWidget);

"use strict";

mw.VcardAssistant.UI.WikidataSearchField = function(editForm, config) {
    var _this = this;
    this.editForm = editForm;
    mw.VcardAssistant.UI.WikidataSearchField["super"].call(this, config);
    OO.ui.mixin.LookupElement.call(this);
    this.on("change", function() {
        _this.editForm.applyWikidataId(null);
    });
};

OO.inheritClass(mw.VcardAssistant.UI.WikidataSearchField, OO.ui.ComboBoxInputWidget);

OO.mixinClass(mw.VcardAssistant.UI.WikidataSearchField, OO.ui.mixin.LookupElement);

mw.VcardAssistant.UI.WikidataSearchField.prototype.getLookupRequest = function() {
    return $.ajax({
        data: {
            action: "wbsearchentities",
            format: "json",
            language: mw.config.get("wgUserLanguage"),
            limit: 20,
            origin: "*",
            search: this.getValue(),
            type: "item",
            uselang: mw.config.get("wgUserLanguage")
        },
        url: "https://www.wikidata.org/w/api.php"
    });
};

mw.VcardAssistant.UI.WikidataSearchField.prototype.getLookupCacheDataFromResponse = function(response) {
    this.searchresults = response.search;
    var searchResults = this.searchresults.map(function(result) {
        return {
            data: result.id,
            label: result.label,
            description: result.description
        };
    });
    return searchResults;
};

mw.VcardAssistant.UI.WikidataSearchField.prototype.getLookupMenuOptionsFromData = function(data) {
    return data.map(function(result) {
        return new mw.VcardAssistant.UI.SearchResult(result);
    });
};

mw.VcardAssistant.UI.WikidataSearchField.prototype.onLookupMenuChoose = function(item) {
    this.setValue(item.getData());
    this.editForm.applyParameter("auto", 1);
    this.editForm.applyWikidataId(item.getData());
};
//</nowiki>