"use strict";
!function(F, d) {
function t(a) {
return k.l10n._(a);
}
function G(a, b, c) {
return k.l10n.n(a, b, c);
}
function y(a) {
return a.format(0, ".", Ba);
}
function Ca(a) {
k.ajax.post("sync", ja, function(b) {
const c = [];
var f = b.pot, g = b.po;
const r = b.done || {
add: [],
del: [],
fuz: []
};
var n = r.add.length;
const u = r.del.length, z = r.fuz.length, B = r.trn || 0;
C.clear().load(g);
h.load(C);
Y(h);
if (n || u || z || B) {
if (f ? c.push(v(t("Merged from %s"), f)) : c.push(t("Merged from source code")),
n && c.push(v(G("%s new string added", "%s new strings added", n), y(n))), u && c.push(v(G("%s obsolete string removed", "%s obsolete strings removed", u), y(u))),
z && c.push(v(G("%s string marked Fuzzy", "%s strings marked Fuzzy", z), y(z))),
B && c.push(v(G("%s translation copied", "%s translations copied", B), y(B))), d(H).trigger("poUnsaved", []),
R(), Da && F.console) {
f = console;
g = -1;
for (n = r.add.length; ++g < n; ) f.log(" + " + String(r.add[g]));
n = r.del.length;
for (g = 0; g < n; g++) f.log(" - " + String(r.del[g]));
n = r.fuz.length;
for (g = 0; g < n; g++) f.log(" ~ " + String(r.fuz[g]));
}
} else f ? c.push(v(t("Strings up to date with %s"), f)) : c.push(t("Strings up to date with source code"));
k.notices.success(c.join(". "));
d(H).trigger("poMerge", [ b ]);
a && a();
}, a);
}
function Ea(a) {
const b = a.currentTarget;
a.stopImmediatePropagation();
b.disabled = !0;
ka();
b.disabled = !1;
}
function ka() {
const a = [];
C.each(function(b, c) {
h.validate(c) && a.push(c);
});
k.notices.clear();
la(a);
}
function Y(a) {
a.invalid && (la(a.invalid), a.invalid = null);
}
function la(a) {
const b = a.length;
if (0 === b) k.notices.success(t("No formatting errors detected")); else {
const c = [ v(G("%s possible error detected", "%s possible errors detected", b), b), t("Check the translations marked with a warning sign") ];
k.notices.warn(c.join(". ")).slow();
}
0 < b && h.current(a[0]);
}
function Fa(a) {
const b = a.id, c = k.apis, f = c.providers();
return c.create(a, f[b] || f._);
}
function ma() {
for (var a = -1, b, c = [], f = K, g = f.length, r = String(Ga); ++a < g; ) try {
b = f[a], null == b.src && (b.src = r), c.push(Fa(b));
} catch (n) {
k.notices.error(String(n));
}
return c;
}
function na(a) {
function b(f) {
Z = new Date().getTime();
K = f && f.apis || [];
0 === K.length ? N = aa("loco-apis-empty", f.html) : S = aa("loco-apis-batch", f.html);
c.remove();
a(K);
}
if (T || oa) k.notices.error("APIs not available in current mode"); else if (null == K || 0 === K.length || 10 < Math.round((new Date().getTime() - Z) / 1e3)) {
N && N.remove();
N = null;
S && S.remove();
S = null;
U && U.remove();
K = U = null;
var c = d('
').dialog({
dialogClass: "loco-modal loco-modal-no-close",
appendTo: "#loco-admin.wrap",
title: "Loading..",
modal: !0,
autoOpen: !0,
closeOnEscape: !1,
resizable: !1,
draggable: !1,
position: pa,
height: 200
});
k.ajax.get("apis", {
locale: String(D)
}, b);
} else Z = new Date().getTime(), a(K);
}
function aa(a, b) {
b = d(b);
b.attr("id", a);
b.dialog({
dialogClass: "loco-modal",
appendTo: "#loco-admin.wrap",
title: b.attr("title"),
modal: !0,
autoOpen: !1,
closeOnEscape: !0,
resizable: !1,
draggable: !1,
position: pa
});
return b;
}
function qa() {
na(function(a) {
a.length ? Ha() : ra();
});
}
function Ia(a) {
a.preventDefault();
na(function(b) {
b.length ? Ja() : ra();
});
return !1;
}
function ra() {
N ? N.dialog("open") : k.notices.error("Logic error. Unconfigured API modal missing");
}
function Ja() {
function a(e) {
a: {
var q = d(e.api).val();
for (var O, L = X || (X = ma()), P = L.length, Q = -1; ++Q < P; ) if (O = L[Q],
O.getId() === q) {
q = O;
break a;
}
k.notices.error("No " + q + " client");
q = void 0;
}
e = e.existing.checked;
M.text("Calculating....");
g = k.apis.createJob(q);
g.init(C, e);
r = q.toString();
M.text(v(t("%s unique source strings."), y(g.length)) + " " + v(t("%s characters will be sent for translation."), y(g.chars)));
E[0].disabled = g.length ? !1 : !0;
n = null;
}
function b(e) {
g && (B && e.fuzzy(0, !0), h.pasteMessage(e), e === h.active && h.setStatus(e),
h.unsave(e, 0), u++, z && !e.valid() && (z = !1));
}
function c(e, q) {
e = q ? 100 * e / q : 0;
M.text(v(t("Translation progress %s%%"), y(e)));
}
function f() {
E.removeClass("loco-loading");
if (g && n) {
var e = n.todo();
e && k.notices.warn(v(G("Translation job aborted with %s string remaining", "Translation job aborted with %s strings remaining", e), y(e))).slow();
e = [];
const q = n.did();
q && e.push(v(G("%1$s string translated via %2$s", "%1$s strings translated via %2$s", q), y(q), r));
u ? e.push(v(G("%s string updated", "%s strings updated", u), y(u))) : q && e.push(t("Nothing needed updating"));
e.length && k.notices.success(e.join(". ")).slow();
n = g = null;
}
u && (R(), h.rebuildSearch());
I && (I.off("dialogclose").dialog("close"), I = null);
h.fire("poAuto");
z || ka();
}
let g, r, n, u = 0, z = !0, B = !1, I = S.dialog("open");
const x = I.find("form"), E = x.find("button.button-primary"), M = d("#loco-job-progress");
E.removeClass("loco-loading");
E[0].disabled = !0;
k.notices.clear();
x.off("submit change");
a(x[0]);
x.on("change", function(e) {
e = e.target;
const q = e.name;
"api" !== q && "existing" !== q || a(e.form);
return !0;
}).on("submit", function(e) {
e.preventDefault();
E.addClass("loco-loading");
E[0].disabled = !0;
u = 0;
c(0);
B = e.target.fuzzy.checked;
n = g.dispatch().done(f).each(b).prog(c).stat();
});
I.off("dialogclose").on("dialogclose", function() {
g.abort();
I = null;
f();
});
}
function Ha() {
function a(l) {
if (l.isDefaultPrevented()) return !1;
var p = l.which;
let m = -1;
49 <= p && 57 >= p ? m = p - 49 : 97 <= p && 105 >= p && (m = p - 97);
return 0 <= m && 9 > m && (p = e && e.find("button.button-primary").eq(m)) && 1 === p.length ? (p.click(),
l.preventDefault(), l.stopPropagation(), !1) : !0;
}
function b(l, p) {
return function(m) {
m.preventDefault();
m.stopPropagation();
g();
m = h.current();
const A = h.getTargetOffset();
m.translate(p, A);
h.focus().reloadMessage(m);
};
}
function c(l, p, m, A) {
let ba = A.getId(), ca = P[ba], sa = String(ca + 1), Ka = A.getUrl(), ta = t("Use this translation");
A = String(A);
let ua = V && V[ba];
l = d('').attr("tabindex", String(1 + M + ca)).on("click", b(l, p));
l.attr("accesskey", sa);
1 < q.length && (ta += " (" + sa + ")");
l.text(ta);
ua && ua.replaceWith(d('').append(d('
Translated by
').append(d('').attr("href", Ka).text(A))).append(d("").text(p || "FAILED")).append(l));
++Q === O && (e && e.dialog("option", "title", t("Suggested translations") + " — " + m.label),
M += Q, x.attr("disabled") && x.attr("disabled", !1));
0 === ca && l.focus();
}
function f(l) {
const p = d('').text("Calling " + l + " ...");
return V[l.getId()] = p;
}
function g(l) {
e && null == l && e.dialog("close");
V = P = e = null;
d(F).off("keydown", a);
}
function r(l) {
return function(p, m, A) {
L[l.getId()] = m;
c(p, m, A, l);
};
}
function n(l) {
L = va[l] || (va[l] = {});
let p = -1;
for (;++p < O; ) {
const m = q[p], A = m.getId();
e.append(f(m));
P[A] = p;
L[A] ? c(l, L[A], D, m) : m.translate(l, D, r(m));
}
}
const u = h.current();
if (!u) return !1;
var z = u.pluralized();
const B = z ? Math.min(h.getTargetOffset(), 1) : 0, I = 'lang="' + String(D) + '" dir="' + (D.isRTL() ? "RTL" : "LTR") + '"';
let x, E = u.source(null, B);
z ? (x = d(''), u.eachSrc(function(l, p) {
var m = h.t();
m = l ? m._x("Plural", "Editor") : m._x("Single", "Editor");
m = d("").attr("label", m);
x.append(m.append(d("").attr("value", String(l)).text(p)));
}), x.val(String(B)), x.on("change", function(l) {
e.find("div.loco-api-result").remove();
V = {};
P = {};
Q = 0;
E = u.source(null, l.target.selectedIndex);
x.attr("disabled", "true");
n(E);
})) : x = d('').text(E);
let M = 99, e = (U || (U = aa("loco-apis-hint", ""))).html("").append(d('