(function(Q) {
Q.ImageCropper = function(E, R, J) {
function F(a) {
K();
x.show();
x.addClass("notransition");
k.addClass("notransition");
x[0].offsetHeight;
k[0].offsetHeight;
x.removeClass("notransition");
k.removeClass("notransition");
x.addClass("icrop-transition");
k.addClass("icrop-transition");
a ? C.setVals(a.x, a.y, a.w, a.h) : C.setVals(0, 0, k.width(), k.height());
clearTimeout(L);
L = setTimeout(function() {
x.removeClass("icrop-transition");
k.removeClass("icrop-transition")
}, 1E3)
}
function G() {
var a = Math.min(R, z.width());
if (t / u > a / J)
var b = a / t * u;
else
b = J,
a = b / u * t;
v.css({
width: a,
height: b
});
k.css({
width: a,
height: b
});
v[0].width = t;
v[0].height = u;
k[0].width = t;
k[0].height = u;
M(v[0], N, l, m);
M(k[0], S, l, m);
K()
}
function M(a, b, c, d) {
b.clearRect(0, 0, a.width, a.height);
b.translate(a.width / 2, a.height / 2);
var e = 90 === d || 270 === d;
b.scale(A && !e || B && e ? -1 : 1, B && !e || A && e ? -1 : 1);
0 < d ? (b.rotate(d / 180 * Math.PI),
180 === d ? (b.translate(-a.width / 2, -a.height / 2),
b.drawImage(c, 0, 0, a.width, a.height),
b.translate(a.width / 2, a.height / 2)) : (b.translate(-a.height / 2, -a.width / 2),
b.drawImage(c, 0, 0, a.height, a.width),
b.translate(a.height / 2, a.width / 2)),
b.rotate(-d / 180 * Math.PI)) : b.drawImage(c, -a.width / 2, -a.height / 2, a.width, a.height);
b.scale(1, 1);
b.translate(-a.width / 2, -a.height / 2)
}
function K() {
T.height(v.height()).width(v.width())
}
function w(a, b, c, d) {
b = b * d + c;
return {
r: a[4 * b],
g: a[4 * b + 1],
b: a[4 * b + 2],
a: a[4 * b + 3]
}
}
function D(a, b) {
return (a.r - b.r