Skip to content
Snippets Groups Projects
fabric.min.js 361 KiB
Newer Older
Carsten  Rose's avatar
Carsten Rose committed
4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000
        }
    }), e.Polyline.ATTRIBUTE_NAMES = e.SHARED_ATTRIBUTES.concat(), e.Polyline.fromElement = function (t, i) {
        if (!t)return null;
        i || (i = {});
        var r = e.parsePointsAttribute(t.getAttribute("points")), n = e.parseAttributes(t, e.Polyline.ATTRIBUTE_NAMES);
        return new e.Polyline(r, e.util.object.extend(n, i))
    }, e.Polyline.fromObject = function (t, i, r) {
        return e.Object._fromObject("Polyline", t, i, r, "points")
    }
}("undefined" != typeof exports ? exports : this), function (t) {
    "use strict";
    var e = t.fabric || (t.fabric = {}), i = e.util.object.extend;
    return e.Polygon ? void e.warn("fabric.Polygon is already defined") : (e.Polygon = e.util.createClass(e.Polyline, {
        type: "polygon",
        _render: function (t, e) {
            this.commonRender(t, e) && (t.closePath(), this._renderFill(t), this._renderStroke(t))
        },
        _renderDashedStroke: function (t) {
            this.callSuper("_renderDashedStroke", t), t.closePath()
        }
    }),
        e.Polygon.ATTRIBUTE_NAMES = e.SHARED_ATTRIBUTES.concat(), e.Polygon.fromElement = function (t, r) {
        if (!t)return null;
        r || (r = {});
        var n = e.parsePointsAttribute(t.getAttribute("points")), s = e.parseAttributes(t, e.Polygon.ATTRIBUTE_NAMES);
        return new e.Polygon(n, i(s, r))
    }, void(e.Polygon.fromObject = function (t, i, r) {
        return e.Object._fromObject("Polygon", t, i, r, "points")
    }))
}("undefined" != typeof exports ? exports : this), function (t) {
    "use strict";
    var e = t.fabric || (t.fabric = {}), i = e.util.array.min, r = e.util.array.max, n = e.util.object.extend, s = Object.prototype.toString, o = e.util.drawArc, a = {
        m: 2,
        l: 2,
        h: 1,
        v: 1,
        c: 6,
        s: 4,
        q: 4,
        t: 2,
        a: 7
    }, h = {m: "l", M: "L"};
    if (e.Path)return void e.warn("fabric.Path is already defined");
    var c = e.Object.prototype.stateProperties.concat();
    c.push("path");
    var l = e.Object.prototype.cacheProperties.concat();
    l.push("path", "fillRule"), e.Path = e.util.createClass(e.Object, {
        type: "path",
        path: null,
        minX: 0,
        minY: 0,
        cacheProperties: l,
        stateProperties: c,
        initialize: function (t, e) {
            e = e || {}, this.callSuper("initialize", e), t || (t = []);
            var i = "[object Array]" === s.call(t);
            this.path = i ? t : t.match && t.match(/[mzlhvcsqta][^mzlhvcsqta]*/gi), this.path && (i || (this.path = this._parsePath()), this._setPositionDimensions(e))
        },
        _setPositionDimensions: function (t) {
            var e = this._parseDimensions();
            this.minX = e.left, this.minY = e.top, this.width = e.width, this.height = e.height, "undefined" == typeof t.left && (this.left = e.left + ("center" === this.originX ? this.width / 2 : "right" === this.originX ? this.width : 0)), "undefined" == typeof t.top && (this.top = e.top + ("center" === this.originY ? this.height / 2 : "bottom" === this.originY ? this.height : 0)), this.pathOffset = this.pathOffset || {
                    x: this.minX + this.width / 2,
                    y: this.minY + this.height / 2
                }
        },
        _renderPathCommands: function (t) {
            var e, i, r, n = null, s = 0, a = 0, h = 0, c = 0, l = 0, u = 0, f = -this.pathOffset.x, d = -this.pathOffset.y;
            this.group && "path-group" === this.group.type && (f = 0, d = 0), t.beginPath();
            for (var g = 0, p = this.path.length; g < p; ++g) {
                switch (e = this.path[g], e[0]) {
                    case"l":
                        h += e[1], c += e[2], t.lineTo(h + f, c + d);
                        break;
                    case"L":
                        h = e[1], c = e[2], t.lineTo(h + f, c + d);
                        break;
                    case"h":
                        h += e[1], t.lineTo(h + f, c + d);
                        break;
                    case"H":
                        h = e[1], t.lineTo(h + f, c + d);
                        break;
                    case"v":
                        c += e[1], t.lineTo(h + f, c + d);
                        break;
                    case"V":
                        c = e[1], t.lineTo(h + f, c + d);
                        break;
                    case"m":
                        h += e[1], c += e[2], s = h, a = c, t.moveTo(h + f, c + d);
                        break;
                    case"M":
                        h = e[1], c = e[2], s = h, a = c, t.moveTo(h + f, c + d);
                        break;
                    case"c":
                        i = h + e[5], r = c + e[6], l = h + e[3], u = c + e[4], t.bezierCurveTo(h + e[1] + f, c + e[2] + d, l + f, u + d, i + f, r + d), h = i, c = r;
                        break;
                    case"C":
                        h = e[5], c = e[6], l = e[3], u = e[4], t.bezierCurveTo(e[1] + f, e[2] + d, l + f, u + d, h + f, c + d);
                        break;
                    case"s":
                        i = h + e[3], r = c + e[4], null === n[0].match(/[CcSs]/) ? (l = h, u = c) : (l = 2 * h - l, u = 2 * c - u), t.bezierCurveTo(l + f, u + d, h + e[1] + f, c + e[2] + d, i + f, r + d), l = h + e[1], u = c + e[2], h = i, c = r;
                        break;
                    case"S":
                        i = e[3], r = e[4], null === n[0].match(/[CcSs]/) ? (l = h, u = c) : (l = 2 * h - l, u = 2 * c - u), t.bezierCurveTo(l + f, u + d, e[1] + f, e[2] + d, i + f, r + d), h = i, c = r, l = e[1], u = e[2];
                        break;
                    case"q":
                        i = h + e[3], r = c + e[4], l = h + e[1], u = c + e[2], t.quadraticCurveTo(l + f, u + d, i + f, r + d), h = i, c = r;
                        break;
                    case"Q":
                        i = e[3], r = e[4], t.quadraticCurveTo(e[1] + f, e[2] + d, i + f, r + d), h = i, c = r, l = e[1], u = e[2];
                        break;
                    case"t":
                        i = h + e[1], r = c + e[2], null === n[0].match(/[QqTt]/) ? (l = h, u = c) : (l = 2 * h - l, u = 2 * c - u), t.quadraticCurveTo(l + f, u + d, i + f, r + d), h = i, c = r;
                        break;
                    case"T":
                        i = e[1], r = e[2], null === n[0].match(/[QqTt]/) ? (l = h, u = c) : (l = 2 * h - l, u = 2 * c - u), t.quadraticCurveTo(l + f, u + d, i + f, r + d), h = i, c = r;
                        break;
                    case"a":
                        o(t, h + f, c + d, [e[1], e[2], e[3], e[4], e[5], e[6] + h + f, e[7] + c + d]), h += e[6], c += e[7];
                        break;
                    case"A":
                        o(t, h + f, c + d, [e[1], e[2], e[3], e[4], e[5], e[6] + f, e[7] + d]), h = e[6], c = e[7];
                        break;
                    case"z":
                    case"Z":
                        h = s, c = a, t.closePath()
                }
                n = e
            }
        },
        _render: function (t) {
            this._renderPathCommands(t), this._renderFill(t), this._renderStroke(t)
        },
        toString: function () {
            return "#<fabric.Path (" + this.complexity() + '): { "top": ' + this.top + ', "left": ' + this.left + " }>"
        },
        toObject: function (t) {
            var e = n(this.callSuper("toObject", ["sourcePath", "pathOffset"].concat(t)), {
                path: this.path.map(function (t) {
                    return t.slice()
                }), top: this.top, left: this.left
            });
            return e
        },
        toDatalessObject: function (t) {
            var e = this.toObject(t);
            return this.sourcePath && (e.path = this.sourcePath), delete e.sourcePath, e
        },
        toSVG: function (t) {
            for (var e = [], i = this._createBaseSVGMarkup(), r = "", n = 0, s = this.path.length; n < s; n++)e.push(this.path[n].join(" "));
            var o = e.join(" ");
            return this.group && "path-group" === this.group.type || (r = " translate(" + -this.pathOffset.x + ", " + -this.pathOffset.y + ") "), i.push("<path ", this.getSvgId(), 'd="', o, '" style="', this.getSvgStyles(), '" transform="', this.getSvgTransform(), r, this.getSvgTransformMatrix(), '" stroke-linecap="round" ', "/>\n"), t ? t(i.join("")) : i.join("")
        },
        complexity: function () {
            return this.path.length
        },
        _parsePath: function () {
            for (var t, e, i, r, n, s = [], o = [], c = /([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi, l = 0, u = this.path.length; l < u; l++) {
                for (t = this.path[l], r = t.slice(1).trim(), o.length = 0; i = c.exec(r);)o.push(i[0]);
                n = [t.charAt(0)];
                for (var f = 0, d = o.length; f < d; f++)e = parseFloat(o[f]), isNaN(e) || n.push(e);
                var g = n[0], p = a[g.toLowerCase()], v = h[g] || g;
                if (n.length - 1 > p)for (var b = 1, m = n.length; b < m; b += p)s.push([g].concat(n.slice(b, b + p))), g = v; else s.push(n)
            }
            return s
        },
        _parseDimensions: function () {
            for (var t, n, s, o, a = [], h = [], c = null, l = 0, u = 0, f = 0, d = 0, g = 0, p = 0, v = 0, b = this.path.length; v < b; ++v) {
                switch (t = this.path[v], t[0]) {
                    case"l":
                        f += t[1], d += t[2], o = [];
                        break;
                    case"L":
                        f = t[1], d = t[2], o = [];
                        break;
                    case"h":
                        f += t[1], o = [];
                        break;
                    case"H":
                        f = t[1], o = [];
                        break;
                    case"v":
                        d += t[1], o = [];
                        break;
                    case"V":
                        d = t[1], o = [];
                        break;
                    case"m":
                        f += t[1], d += t[2], l = f, u = d, o = [];
                        break;
                    case"M":
                        f = t[1], d = t[2], l = f, u = d, o = [];
                        break;
                    case"c":
                        n = f + t[5], s = d + t[6], g = f + t[3], p = d + t[4], o = e.util.getBoundsOfCurve(f, d, f + t[1], d + t[2], g, p, n, s), f = n, d = s;
                        break;
                    case"C":
                        g = t[3], p = t[4], o = e.util.getBoundsOfCurve(f, d, t[1], t[2], g, p, t[5], t[6]), f = t[5], d = t[6];
                        break;
                    case"s":
                        n = f + t[3], s = d + t[4], null === c[0].match(/[CcSs]/) ? (g = f, p = d) : (g = 2 * f - g, p = 2 * d - p), o = e.util.getBoundsOfCurve(f, d, g, p, f + t[1], d + t[2], n, s), g = f + t[1], p = d + t[2], f = n, d = s;
                        break;
                    case"S":
                        n = t[3], s = t[4], null === c[0].match(/[CcSs]/) ? (g = f, p = d) : (g = 2 * f - g, p = 2 * d - p), o = e.util.getBoundsOfCurve(f, d, g, p, t[1], t[2], n, s), f = n, d = s, g = t[1], p = t[2];
                        break;
                    case"q":
                        n = f + t[3], s = d + t[4], g = f + t[1], p = d + t[2], o = e.util.getBoundsOfCurve(f, d, g, p, g, p, n, s), f = n, d = s;
                        break;
                    case"Q":
                        g = t[1], p = t[2], o = e.util.getBoundsOfCurve(f, d, g, p, g, p, t[3], t[4]), f = t[3], d = t[4];
                        break;
                    case"t":
                        n = f + t[1], s = d + t[2], null === c[0].match(/[QqTt]/) ? (g = f, p = d) : (g = 2 * f - g, p = 2 * d - p), o = e.util.getBoundsOfCurve(f, d, g, p, g, p, n, s), f = n, d = s;
                        break;
                    case"T":
                        n = t[1], s = t[2], null === c[0].match(/[QqTt]/) ? (g = f, p = d) : (g = 2 * f - g, p = 2 * d - p), o = e.util.getBoundsOfCurve(f, d, g, p, g, p, n, s), f = n, d = s;
                        break;
                    case"a":
                        o = e.util.getBoundsOfArc(f, d, t[1], t[2], t[3], t[4], t[5], t[6] + f, t[7] + d), f += t[6], d += t[7];
                        break;
                    case"A":
                        o = e.util.getBoundsOfArc(f, d, t[1], t[2], t[3], t[4], t[5], t[6], t[7]), f = t[6], d = t[7];
                        break;
                    case"z":
                    case"Z":
                        f = l, d = u
                }
                c = t, o.forEach(function (t) {
                    a.push(t.x), h.push(t.y)
                }), a.push(f), h.push(d)
            }
            var m = i(a) || 0, y = i(h) || 0, _ = r(a) || 0, x = r(h) || 0, C = _ - m, S = x - y, w = {
                left: m,
                top: y,
                width: C,
                height: S
            };
            return w
        }
    }), e.Path.fromObject = function (t, i, r) {
        var n;
        return "string" != typeof t.path ? e.Object._fromObject("Path", t, i, r, "path") : void e.loadSVGFromURL(t.path, function (e) {
            var r = t.path;
            n = e[0], delete t.path, n.setOptions(t), n.setSourcePath(r), i && i(n)
        })
    }, e.Path.ATTRIBUTE_NAMES = e.SHARED_ATTRIBUTES.concat(["d"]), e.Path.fromElement = function (t, i, r) {
        var s = e.parseAttributes(t, e.Path.ATTRIBUTE_NAMES);
        i && i(new e.Path(s.d, n(s, r)))
    }, e.Path.async = !0
}("undefined" != typeof exports ? exports : this), function (t) {
    "use strict";
    var e = t.fabric || (t.fabric = {}), i = e.util.object.extend;
    return e.PathGroup ? void e.warn("fabric.PathGroup is already defined") : (e.PathGroup = e.util.createClass(e.Object, {
        type: "path-group",
        fill: "",
        cacheProperties: [],
        initialize: function (t, e) {
            e = e || {}, this.paths = t || [];
            for (var i = this.paths.length; i--;)this.paths[i].group = this;
            e.toBeParsed && (this.parseDimensionsFromPaths(e), delete e.toBeParsed), this.setOptions(e), this.setCoords()
        },
        parseDimensionsFromPaths: function (t) {
            for (var i, r, n, s, o, a, h = [], c = [], l = this.paths.length; l--;) {
                n = this.paths[l], s = n.height + n.strokeWidth, o = n.width + n.strokeWidth, i = [{
                    x: n.left,
                    y: n.top
                }, {x: n.left + o, y: n.top}, {x: n.left, y: n.top + s}, {
                    x: n.left + o,
                    y: n.top + s
                }], a = this.paths[l].transformMatrix;
                for (var u = 0; u < i.length; u++)r = i[u], a && (r = e.util.transformPoint(r, a, !1)), h.push(r.x), c.push(r.y)
            }
            t.width = Math.max.apply(null, h), t.height = Math.max.apply(null, c)
        },
        drawObject: function (t) {
            t.save(), t.translate(-this.width / 2, -this.height / 2);
            for (var e = 0, i = this.paths.length; e < i; ++e)this.paths[e].render(t, !0);
            t.restore()
        },
        shouldCache: function () {
            var t = this.objectCaching && (!this.group || this.needsItsOwnCache() || !this.group.isCaching());
            if (this.caching = t, t)for (var e = 0, i = this.paths.length; e < i; e++)if (this.paths[e].willDrawShadow())return this.caching = !1, !1;
            return t
        },
        willDrawShadow: function () {
            if (this.shadow)return !0;
            for (var t = 0, e = this.paths.length; t < e; t++)if (this.paths[t].willDrawShadow())return !0;
            return !1
        },
        isCaching: function () {
            return this.caching || this.group && this.group.isCaching()
        },
        isCacheDirty: function () {
            if (this.callSuper("isCacheDirty"))return !0;
            if (!this.statefullCache)return !1;
            for (var t = 0, e = this.paths.length; t < e; t++)if (this.paths[t].isCacheDirty(!0)) {
                if (this._cacheCanvas) {
                    var i = this.cacheWidth / this.zoomX, r = this.cacheHeight / this.zoomY;
                    this._cacheContext.clearRect(-i / 2, -r / 2, i, r)
                }
                return !0
            }
            return !1
        },
        _set: function (t, e) {
            if ("fill" === t && e && this.isSameColor())for (var i = this.paths.length; i--;)this.paths[i]._set(t, e);
            return this.callSuper("_set", t, e)
        },
        toObject: function (t) {
            var e = this.paths.map(function (e) {
                var i = e.includeDefaultValues;
                e.includeDefaultValues = e.group.includeDefaultValues;
                var r = e.toObject(t);
                return e.includeDefaultValues = i, r
            }), r = i(this.callSuper("toObject", ["sourcePath"].concat(t)), {paths: e});
            return r
        },
        toDatalessObject: function (t) {
            var e = this.toObject(t);
            return this.sourcePath && (e.paths = this.sourcePath), e
        },
        toSVG: function (t) {
            var e = this.getObjects(), i = this.getPointByOrigin("left", "top"), r = "translate(" + i.x + " " + i.y + ")", n = this._createBaseSVGMarkup();
            n.push("<g ", this.getSvgId(), 'style="', this.getSvgStyles(), '" ', 'transform="', this.getSvgTransformMatrix(), r, this.getSvgTransform(), '" ', ">\n");
            for (var s = 0, o = e.length; s < o; s++)n.push("\t", e[s].toSVG(t));
            return n.push("</g>\n"), t ? t(n.join("")) : n.join("")
        },
        toString: function () {
            return "#<fabric.PathGroup (" + this.complexity() + "): { top: " + this.top + ", left: " + this.left + " }>"
        },
        isSameColor: function () {
            var t = this.getObjects()[0].get("fill") || "";
            return "string" == typeof t && (t = t.toLowerCase(), this.getObjects().every(function (e) {
                    var i = e.get("fill") || "";
                    return "string" == typeof i && i.toLowerCase() === t
                }))
        },
        complexity: function () {
            return this.paths.reduce(function (t, e) {
                return t + (e && e.complexity ? e.complexity() : 0)
            }, 0)
        },
        getObjects: function () {
            return this.paths
        }
    }), e.PathGroup.fromObject = function (t, i) {
        var r = t.paths;
        delete t.paths, "string" == typeof r ? e.loadSVGFromURL(r, function (n) {
            var s = r, o = e.util.groupSVGElements(n, t, s);
            t.paths = r, i(o)
        }) : e.util.enlivenObjects(r, function (n) {
            var s = new e.PathGroup(n, t);
            t.paths = r, i(s)
        })
    }, void(e.PathGroup.async = !0))
}("undefined" != typeof exports ? exports : this), function (t) {
    "use strict";
    var e = t.fabric || (t.fabric = {}), i = e.util.object.extend, r = e.util.array.min, n = e.util.array.max;
    if (!e.Group) {
        var s = {
            lockMovementX: !0,
            lockMovementY: !0,
            lockRotation: !0,
            lockScalingX: !0,
            lockScalingY: !0,
            lockUniScaling: !0
        };
        e.Group = e.util.createClass(e.Object, e.Collection, {
            type: "group",
            strokeWidth: 0,
            subTargetCheck: !1,
            cacheProperties: [],
            initialize: function (t, e, i) {
                e = e || {}, this._objects = [], i && this.callSuper("initialize", e), this._objects = t || [];
                for (var r = this._objects.length; r--;)this._objects[r].group = this;
                e.originX && (this.originX = e.originX), e.originY && (this.originY = e.originY), i ? this._updateObjectsCoords(!0) : (this._calcBounds(), this._updateObjectsCoords(), this.callSuper("initialize", e)), this.setCoords(), this.saveCoords()
            },
            _updateObjectsCoords: function (t) {
                for (var e = this.getCenterPoint(), i = this._objects.length; i--;)this._updateObjectCoords(this._objects[i], e, t)
            },
            _updateObjectCoords: function (t, e, i) {
                if (t.__origHasControls = t.hasControls, t.hasControls = !1, !i) {
                    var r = t.getLeft(), n = t.getTop(), s = !0, o = !0;
                    t.set({left: r - e.x, top: n - e.y}), t.setCoords(s, o)
                }
            },
            toString: function () {
                return "#<fabric.Group: (" + this.complexity() + ")>"
            },
            addWithUpdate: function (t) {
                return this._restoreObjectsState(), e.util.resetObjectTransform(this), t && (this._objects.push(t), t.group = this, t._set("canvas", this.canvas)), this.forEachObject(this._setObjectActive, this), this._calcBounds(), this._updateObjectsCoords(), this.setCoords(), this.dirty = !0, this
            },
            _setObjectActive: function (t) {
                t.set("active", !0), t.group = this
            },
            removeWithUpdate: function (t) {
                return this._restoreObjectsState(), e.util.resetObjectTransform(this), this.forEachObject(this._setObjectActive, this), this.remove(t), this._calcBounds(), this._updateObjectsCoords(), this.setCoords(), this.dirty = !0, this
            },
            _onObjectAdded: function (t) {
                this.dirty = !0, t.group = this, t._set("canvas", this.canvas)
            },
            _onObjectRemoved: function (t) {
                this.dirty = !0, delete t.group, t.set("active", !1)
            },
            delegatedProperties: {
                fill: !0,
                stroke: !0,
                strokeWidth: !0,
                fontFamily: !0,
                fontWeight: !0,
                fontSize: !0,
                fontStyle: !0,
                lineHeight: !0,
                textDecoration: !0,
                textAlign: !0,
                backgroundColor: !0
            },
            _set: function (t, e) {
                var i = this._objects.length;
                if (this.delegatedProperties[t] || "canvas" === t)for (; i--;)this._objects[i].set(t, e); else for (; i--;)this._objects[i].setOnGroup(t, e);
                this.callSuper("_set", t, e)
            },
            toObject: function (t) {
                var e = this.getObjects().map(function (e) {
                    var i = e.includeDefaultValues;
                    e.includeDefaultValues = e.group.includeDefaultValues;
                    var r = e.toObject(t);
                    return e.includeDefaultValues = i, r
                });
                return i(this.callSuper("toObject", t), {objects: e})
            },
            toDatalessObject: function (t) {
                var e = this.getObjects().map(function (e) {
                    var i = e.includeDefaultValues;
                    e.includeDefaultValues = e.group.includeDefaultValues;
                    var r = e.toDatalessObject(t);
                    return e.includeDefaultValues = i, r
                });
                return i(this.callSuper("toDatalessObject", t), {objects: e})
            },
            render: function (t) {
                this._transformDone = !0, this.callSuper("render", t), this._transformDone = !1
            },
            shouldCache: function () {
                var t = this.objectCaching && (!this.group || this.needsItsOwnCache() || !this.group.isCaching());
                if (this.caching = t, t)for (var e = 0, i = this._objects.length; e < i; e++)if (this._objects[e].willDrawShadow())return this.caching = !1, !1;
                return t
            },
            willDrawShadow: function () {
                if (this.callSuper("willDrawShadow"))return !0;
                for (var t = 0, e = this._objects.length; t < e; t++)if (this._objects[t].willDrawShadow())return !0;
                return !1
            },
            isCaching: function () {
                return this.caching || this.group && this.group.isCaching()
            },
            drawObject: function (t) {
                for (var e = 0, i = this._objects.length; e < i; e++)this._renderObject(this._objects[e], t)
            },
            isCacheDirty: function () {
                if (this.callSuper("isCacheDirty"))return !0;
                if (!this.statefullCache)return !1;
                for (var t = 0, e = this._objects.length; t < e; t++)if (this._objects[t].isCacheDirty(!0)) {
                    if (this._cacheCanvas) {
                        var i = this.cacheWidth / this.zoomX, r = this.cacheHeight / this.zoomY;
                        this._cacheContext.clearRect(-i / 2, -r / 2, i, r)
                    }
                    return !0
                }
                return !1
            },
            _renderControls: function (t, e) {
                t.save(), t.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1, this.callSuper("_renderControls", t, e);
                for (var i = 0, r = this._objects.length; i < r; i++)this._objects[i]._renderControls(t);
                t.restore()
            },
            _renderObject: function (t, e) {
                if (t.visible) {
                    var i = t.hasRotatingPoint;
                    t.hasRotatingPoint = !1, t.render(e), t.hasRotatingPoint = i
                }
            },
            _restoreObjectsState: function () {
                return this._objects.forEach(this._restoreObjectState, this), this
            },
            realizeTransform: function (t) {
                var i = t.calcTransformMatrix(), r = e.util.qrDecompose(i), n = new e.Point(r.translateX, r.translateY);
                return t.flipX = !1, t.flipY = !1, t.set("scaleX", r.scaleX), t.set("scaleY", r.scaleY), t.skewX = r.skewX, t.skewY = r.skewY, t.angle = r.angle, t.setPositionByOrigin(n, "center", "center"), t
            },
            _restoreObjectState: function (t) {
                return this.realizeTransform(t), t.setCoords(), t.hasControls = t.__origHasControls, delete t.__origHasControls, t.set("active", !1), delete t.group, this
            },
            destroy: function () {
                return this._restoreObjectsState()
            },
            saveCoords: function () {
                return this._originalLeft = this.get("left"), this._originalTop = this.get("top"), this
            },
            hasMoved: function () {
                return this._originalLeft !== this.get("left") || this._originalTop !== this.get("top")
            },
            setObjectsCoords: function () {
                var t = !0, e = !0;
                return this.forEachObject(function (i) {
                    i.setCoords(t, e)
                }), this
            },
            _calcBounds: function (t) {
                for (var e, i, r, n = [], s = [], o = ["tr", "br", "bl", "tl"], a = 0, h = this._objects.length, c = o.length, l = !0; a < h; ++a)for (e = this._objects[a], e.setCoords(l), r = 0; r < c; r++)i = o[r], n.push(e.oCoords[i].x), s.push(e.oCoords[i].y);
                this.set(this._getBounds(n, s, t))
            },
            _getBounds: function (t, i, s) {
                var o = new e.Point(r(t), r(i)), a = new e.Point(n(t), n(i)), h = {
                    width: a.x - o.x || 0,
                    height: a.y - o.y || 0
                };
                return s || (h.left = o.x || 0, h.top = o.y || 0, "center" === this.originX && (h.left += h.width / 2), "right" === this.originX && (h.left += h.width), "center" === this.originY && (h.top += h.height / 2), "bottom" === this.originY && (h.top += h.height)), h
            },
            toSVG: function (t) {
                var e = this._createBaseSVGMarkup();
                e.push("<g ", this.getSvgId(), 'transform="', this.getSvgTransform(), this.getSvgTransformMatrix(), '" style="', this.getSvgFilter(), '">\n');
                for (var i = 0, r = this._objects.length; i < r; i++)e.push("\t", this._objects[i].toSVG(t));
                return e.push("</g>\n"), t ? t(e.join("")) : e.join("")
            },
            get: function (t) {
                if (t in s) {
                    if (this[t])return this[t];
                    for (var e = 0, i = this._objects.length; e < i; e++)if (this._objects[e][t])return !0;
                    return !1
                }
                return t in this.delegatedProperties ? this._objects[0] && this._objects[0].get(t) : this[t]
            }
        }), e.Group.fromObject = function (t, i) {
            e.util.enlivenObjects(t.objects, function (r) {
                var n = e.util.object.clone(t, !0);
                delete n.objects, i && i(new e.Group(r, n, !0))
            })
        }, e.Group.async = !0
    }
}("undefined" != typeof exports ? exports : this), function (t) {
    "use strict";
    var e = fabric.util.object.extend;
    if (t.fabric || (t.fabric = {}), t.fabric.Image)return void fabric.warn("fabric.Image is already defined.");
    var i = fabric.Object.prototype.stateProperties.concat();
    i.push("alignX", "alignY", "meetOrSlice"), fabric.Image = fabric.util.createClass(fabric.Object, {
        type: "image",
        crossOrigin: "",
        alignX: "none",
        alignY: "none",
        meetOrSlice: "meet",
        strokeWidth: 0,
        _lastScaleX: 1,
        _lastScaleY: 1,
        minimumScaleTrigger: .5,
        stateProperties: i,
        objectCaching: !1,
        initialize: function (t, e, i) {
            e || (e = {}), this.filters = [], this.resizeFilters = [], this.callSuper("initialize", e), this._initElement(t, e, i)
        },
        getElement: function () {
            return this._element
        },
        setElement: function (t, e, i) {
            var r, n;
            return this._element = t, this._originalElement = t, this._initConfig(i), 0 === this.resizeFilters.length ? r = e : (n = this, r = function () {
                n.applyFilters(e, n.resizeFilters, n._filteredEl || n._originalElement, !0)
            }), 0 !== this.filters.length ? this.applyFilters(r) : r && r(this), this
        },
        setCrossOrigin: function (t) {
            return this.crossOrigin = t, this._element.crossOrigin = t, this
        },
        getOriginalSize: function () {
            var t = this.getElement();
            return {width: t.width, height: t.height}
        },
        _stroke: function (t) {
            if (this.stroke && 0 !== this.strokeWidth) {
                var e = this.width / 2, i = this.height / 2;
                t.beginPath(), t.moveTo(-e, -i), t.lineTo(e, -i), t.lineTo(e, i), t.lineTo(-e, i), t.lineTo(-e, -i), t.closePath()
            }
        },
        _renderDashedStroke: function (t) {
            var e = -this.width / 2, i = -this.height / 2, r = this.width, n = this.height;
            t.save(), this._setStrokeStyles(t), t.beginPath(), fabric.util.drawDashedLine(t, e, i, e + r, i, this.strokeDashArray), fabric.util.drawDashedLine(t, e + r, i, e + r, i + n, this.strokeDashArray), fabric.util.drawDashedLine(t, e + r, i + n, e, i + n, this.strokeDashArray), fabric.util.drawDashedLine(t, e, i + n, e, i, this.strokeDashArray), t.closePath(), t.restore()
        },
        toObject: function (t) {
            var i = [], r = [], n = 1, s = 1;
            this.filters.forEach(function (t) {
                t && ("Resize" === t.type && (n *= t.scaleX, s *= t.scaleY), i.push(t.toObject()))
            }), this.resizeFilters.forEach(function (t) {
                t && r.push(t.toObject())
            });
            var o = e(this.callSuper("toObject", ["crossOrigin", "alignX", "alignY", "meetOrSlice"].concat(t)), {
                src: this.getSrc(),
                filters: i,
                resizeFilters: r
            });
            return o.width /= n, o.height /= s, o
        },
        toSVG: function (t) {
            var e = this._createBaseSVGMarkup(), i = -this.width / 2, r = -this.height / 2, n = "none", s = !0;
            if (this.group && "path-group" === this.group.type && (i = this.left, r = this.top), "none" !== this.alignX && "none" !== this.alignY && (n = "x" + this.alignX + "Y" + this.alignY + " " + this.meetOrSlice), e.push('<g transform="', this.getSvgTransform(), this.getSvgTransformMatrix(), '">\n', "<image ", this.getSvgId(), 'xlink:href="', this.getSvgSrc(s), '" x="', i, '" y="', r, '" style="', this.getSvgStyles(), '" width="', this.width, '" height="', this.height, '" preserveAspectRatio="', n, '"', "></image>\n"), this.stroke || this.strokeDashArray) {
                var o = this.fill;
                this.fill = null, e.push("<rect ", 'x="', i, '" y="', r, '" width="', this.width, '" height="', this.height, '" style="', this.getSvgStyles(), '"/>\n'), this.fill = o
            }
            return e.push("</g>\n"), t ? t(e.join("")) : e.join("")
        },
        getSrc: function (t) {
            var e = t ? this._element : this._originalElement;
            return e ? fabric.isLikelyNode ? e._src : e.src : this.src || ""
        },
        setSrc: function (t, e, i) {
            fabric.util.loadImage(t, function (t) {
                return this.setElement(t, e, i)
            }, this, i && i.crossOrigin)
        },
        toString: function () {
            return '#<fabric.Image: { src: "' + this.getSrc() + '" }>'
        },
        applyFilters: function (t, e, i, r) {
            if (e = e || this.filters, i = i || this._originalElement) {
                var n, s, o = fabric.util.createImage(), a = this.canvas ? this.canvas.getRetinaScaling() : fabric.devicePixelRatio, h = this.minimumScaleTrigger / a, c = this;
                if (0 === e.length)return this._element = i, t && t(this), i;
                var l = fabric.util.createCanvasElement();
                return l.width = i.width, l.height = i.height, l.getContext("2d").drawImage(i, 0, 0, i.width, i.height), e.forEach(function (t) {
                    t && (r ? (n = c.scaleX < h ? c.scaleX : 1, s = c.scaleY < h ? c.scaleY : 1, n * a < 1 && (n *= a), s * a < 1 && (s *= a)) : (n = t.scaleX, s = t.scaleY), t.applyTo(l, n, s), r || "Resize" !== t.type || (c.width *= t.scaleX, c.height *= t.scaleY))
                }), o.width = l.width, o.height = l.height, fabric.isLikelyNode ? (o.src = l.toBuffer(void 0, fabric.Image.pngCompression), c._element = o, !r && (c._filteredEl = o), t && t(c)) : (o.onload = function () {
                    c._element = o, !r && (c._filteredEl = o), t && t(c), o.onload = l = null
                }, o.src = l.toDataURL("image/png")), l
            }
        },
        _render: function (t, e) {
            var i, r, n, s = this._findMargins();
            i = e ? this.left : -this.width / 2, r = e ? this.top : -this.height / 2, "slice" === this.meetOrSlice && (t.beginPath(), t.rect(i, r, this.width, this.height), t.clip()), this.isMoving === !1 && this.resizeFilters.length && this._needsResize() ? (this._lastScaleX = this.scaleX, this._lastScaleY = this.scaleY, n = this.applyFilters(null, this.resizeFilters, this._filteredEl || this._originalElement, !0)) : n = this._element, n && t.drawImage(n, i + s.marginX, r + s.marginY, s.width, s.height), this._stroke(t), this._renderStroke(t)
        },
        _needsResize: function () {
            return this.scaleX !== this._lastScaleX || this.scaleY !== this._lastScaleY
        },
        _findMargins: function () {
            var t, e, i = this.width, r = this.height, n = 0, s = 0;
            return "none" === this.alignX && "none" === this.alignY || (t = [this.width / this._element.width, this.height / this._element.height], e = "meet" === this.meetOrSlice ? Math.min.apply(null, t) : Math.max.apply(null, t), i = this._element.width * e, r = this._element.height * e, "Mid" === this.alignX && (n = (this.width - i) / 2), "Max" === this.alignX && (n = this.width - i), "Mid" === this.alignY && (s = (this.height - r) / 2), "Max" === this.alignY && (s = this.height - r)), {
                width: i,
                height: r,
                marginX: n,
                marginY: s
            }
        },
        _resetWidthHeight: function () {
            var t = this.getElement();
            this.set("width", t.width), this.set("height", t.height)
        },
        _initElement: function (t, e, i) {
            this.setElement(fabric.util.getById(t), i, e), fabric.util.addClass(this.getElement(), fabric.Image.CSS_CANVAS)
        },
        _initConfig: function (t) {
            t || (t = {}), this.setOptions(t), this._setWidthHeight(t), this._element && this.crossOrigin && (this._element.crossOrigin = this.crossOrigin)
        },
        _initFilters: function (t, e) {
            t && t.length ? fabric.util.enlivenObjects(t, function (t) {
                e && e(t)
            }, "fabric.Image.filters") : e && e()
        },
        _setWidthHeight: function (t) {
            this.width = "width"in t ? t.width : this.getElement() ? this.getElement().width || 0 : 0, this.height = "height"in t ? t.height : this.getElement() ? this.getElement().height || 0 : 0
        }
    }), fabric.Image.CSS_CANVAS = "canvas-img", fabric.Image.prototype.getSvgSrc = fabric.Image.prototype.getSrc, fabric.Image.fromObject = function (t, e) {
        fabric.util.loadImage(t.src, function (i, r) {
            return r ? void(e && e(null, r)) : void fabric.Image.prototype._initFilters.call(t, t.filters, function (r) {
                t.filters = r || [], fabric.Image.prototype._initFilters.call(t, t.resizeFilters, function (r) {
                    return t.resizeFilters = r || [], new fabric.Image(i, t, e)
                })
            })
        }, null, t.crossOrigin)
    }, fabric.Image.fromURL = function (t, e, i) {
        fabric.util.loadImage(t, function (t) {
            e && e(new fabric.Image(t, i))
        }, null, i && i.crossOrigin)
    }, fabric.Image.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat("x y width height preserveAspectRatio xlink:href crossOrigin".split(" ")), fabric.Image.fromElement = function (t, i, r) {
        var n, s = fabric.parseAttributes(t, fabric.Image.ATTRIBUTE_NAMES);
        s.preserveAspectRatio && (n = fabric.util.parsePreserveAspectRatioAttribute(s.preserveAspectRatio), e(s, n)), fabric.Image.fromURL(s["xlink:href"], i, e(r ? fabric.util.object.clone(r) : {}, s))
    }, fabric.Image.async = !0, fabric.Image.pngCompression = 1
}("undefined" != typeof exports ? exports : this), fabric.util.object.extend(fabric.Object.prototype, {
    _getAngleValueForStraighten: function () {
        var t = this.getAngle() % 360;
        return t > 0 ? 90 * Math.round((t - 1) / 90) : 90 * Math.round(t / 90)
    }, straighten: function () {
        return this.setAngle(this._getAngleValueForStraighten()), this
    }, fxStraighten: function (t) {
        t = t || {};
        var e = function () {
        }, i = t.onComplete || e, r = t.onChange || e, n = this;
        return fabric.util.animate({
            startValue: this.get("angle"),
            endValue: this._getAngleValueForStraighten(),
            duration: this.FX_DURATION,
            onChange: function (t) {
                n.setAngle(t), r()
            },
            onComplete: function () {
                n.setCoords(), i()
            },
            onStart: function () {
                n.set("active", !1)
            }
        }), this
    }
}), fabric.util.object.extend(fabric.StaticCanvas.prototype, {
    straightenObject: function (t) {
        return t.straighten(), this.renderAll(), this
    }, fxStraightenObject: function (t) {
        return t.fxStraighten({onChange: this.renderAll.bind(this)}), this
    }
}), fabric.Image.filters = fabric.Image.filters || {}, fabric.Image.filters.BaseFilter = fabric.util.createClass({
    type: "BaseFilter",
    initialize: function (t) {
        t && this.setOptions(t)
    },
    setOptions: function (t) {
        for (var e in t)this[e] = t[e]
    },
    toObject: function () {
        return {type: this.type}
    },
    toJSON: function () {
        return this.toObject()
    }
}), fabric.Image.filters.BaseFilter.fromObject = function (t, e) {
    var i = new fabric.Image.filters[t.type](t);
    return e && e(i), i
}, function (t) {
    "use strict";
    var e = t.fabric || (t.fabric = {}), i = e.util.object.extend, r = e.Image.filters, n = e.util.createClass;
    r.Brightness = n(r.BaseFilter, {
        type: "Brightness", initialize: function (t) {
            t = t || {}, this.brightness = t.brightness || 0
        }, applyTo: function (t) {
            for (var e = t.getContext("2d"), i = e.getImageData(0, 0, t.width, t.height), r = i.data, n = this.brightness, s = 0, o = r.length; s < o; s += 4)r[s] += n, r[s + 1] += n, r[s + 2] += n;
            e.putImageData(i, 0, 0)
        }, toObject: function () {
            return i(this.callSuper("toObject"), {brightness: this.brightness})
        }
    }), e.Image.filters.Brightness.fromObject = e.Image.filters.BaseFilter.fromObject
}("undefined" != typeof exports ? exports : this), function (t) {
    "use strict";
    var e = t.fabric || (t.fabric = {}), i = e.util.object.extend, r = e.Image.filters, n = e.util.createClass;
    r.Convolute = n(r.BaseFilter, {
        type: "Convolute", initialize: function (t) {
            t = t || {}, this.opaque = t.opaque, this.matrix = t.matrix || [0, 0, 0, 0, 1, 0, 0, 0, 0]
        }, applyTo: function (t) {
            for (var e, i, r, n, s, o, a, h, c, l = this.matrix, u = t.getContext("2d"), f = u.getImageData(0, 0, t.width, t.height), d = Math.round(Math.sqrt(l.length)), g = Math.floor(d / 2), p = f.data, v = f.width, b = f.height, m = u.createImageData(v, b), y = m.data, _ = this.opaque ? 1 : 0, x = 0; x < b; x++)for (var C = 0; C < v; C++) {
                s = 4 * (x * v + C), e = 0, i = 0, r = 0, n = 0;
                for (var S = 0; S < d; S++)for (var w = 0; w < d; w++)a = x + S - g, o = C + w - g, a < 0 || a > b || o < 0 || o > v || (h = 4 * (a * v + o), c = l[S * d + w], e += p[h] * c, i += p[h + 1] * c, r += p[h + 2] * c, n += p[h + 3] * c);
                y[s] = e, y[s + 1] = i, y[s + 2] = r, y[s + 3] = n + _ * (255 - n)
            }
            u.putImageData(m, 0, 0)
        }, toObject: function () {
            return i(this.callSuper("toObject"), {opaque: this.opaque, matrix: this.matrix})
        }
    }), e.Image.filters.Convolute.fromObject = e.Image.filters.BaseFilter.fromObject
}("undefined" != typeof exports ? exports : this), function (t) {
    "use strict";
    var e = t.fabric || (t.fabric = {}), i = e.util.object.extend, r = e.Image.filters, n = e.util.createClass;
    r.GradientTransparency = n(r.BaseFilter, {
        type: "GradientTransparency", initialize: function (t) {
            t = t || {}, this.threshold = t.threshold || 100
        }, applyTo: function (t) {
            for (var e = t.getContext("2d"), i = e.getImageData(0, 0, t.width, t.height), r = i.data, n = this.threshold, s = r.length, o = 0, a = r.length; o < a; o += 4)r[o + 3] = n + 255 * (s - o) / s;
            e.putImageData(i, 0, 0)
        }, toObject: function () {
            return i(this.callSuper("toObject"), {threshold: this.threshold})
        }
    }), e.Image.filters.GradientTransparency.fromObject = e.Image.filters.BaseFilter.fromObject
}("undefined" != typeof exports ? exports : this), function (t) {
    "use strict";
    var e = t.fabric || (t.fabric = {}), i = e.Image.filters, r = e.util.createClass;
    i.Grayscale = r(i.BaseFilter, {
        type: "Grayscale", applyTo: function (t) {
            for (var e, i = t.getContext("2d"), r = i.getImageData(0, 0, t.width, t.height), n = r.data, s = r.width * r.height * 4, o = 0; o < s;)e = (n[o] + n[o + 1] + n[o + 2]) / 3, n[o] = e, n[o + 1] = e, n[o + 2] = e, o += 4;
            i.putImageData(r, 0, 0)
        }
    }), e.Image.filters.Grayscale.fromObject = function (t, i) {
        return t = t || {}, t.type = "Grayscale", e.Image.filters.BaseFilter.fromObject(t, i)
    }
}("undefined" != typeof exports ? exports : this), function (t) {
    "use strict";
    var e = t.fabric || (t.fabric = {}), i = e.Image.filters, r = e.util.createClass;
    i.Invert = r(i.BaseFilter, {
        type: "Invert", applyTo: function (t) {
            var e, i = t.getContext("2d"), r = i.getImageData(0, 0, t.width, t.height), n = r.data, s = n.length;
            for (e = 0; e < s; e += 4)n[e] = 255 - n[e], n[e + 1] = 255 - n[e + 1], n[e + 2] = 255 - n[e + 2];
            i.putImageData(r, 0, 0)
        }
    }), e.Image.filters.Invert.fromObject = function (t, i) {
        return t = t || {}, t.type = "Invert", e.Image.filters.BaseFilter.fromObject(t, i)
    }
}("undefined" != typeof exports ? exports : this), function (t) {
    "use strict";
    var e = t.fabric || (t.fabric = {}), i = e.util.object.extend, r = e.Image.filters, n = e.util.createClass;
    r.Mask = n(r.BaseFilter, {
        type: "Mask", initialize: function (t) {
            t = t || {}, this.mask = t.mask, this.channel = [0, 1, 2, 3].indexOf(t.channel) > -1 ? t.channel : 0
        }, applyTo: function (t) {
            if (this.mask) {
                var i, r = t.getContext("2d"), n = r.getImageData(0, 0, t.width, t.height), s = n.data, o = this.mask.getElement(), a = e.util.createCanvasElement(), h = this.channel, c = n.width * n.height * 4;
                a.width = t.width, a.height = t.height, a.getContext("2d").drawImage(o, 0, 0, t.width, t.height);
                var l = a.getContext("2d").getImageData(0, 0, t.width, t.height), u = l.data;
                for (i = 0; i < c; i += 4)s[i + 3] = u[i + h];
                r.putImageData(n, 0, 0)
            }
        }, toObject: function () {
            return i(this.callSuper("toObject"), {mask: this.mask.toObject(), channel: this.channel})
        }
    }), e.Image.filters.Mask.fromObject = function (t, i) {
        e.util.loadImage(t.mask.src, function (r) {
            return t.mask = new e.Image(r, t.mask), e.Image.filters.BaseFilter.fromObject(t, i)
        })
    }, e.Image.filters.Mask.async = !0
}("undefined" != typeof exports ? exports : this), function (t) {
    "use strict";
    var e = t.fabric || (t.fabric = {}), i = e.util.object.extend, r = e.Image.filters, n = e.util.createClass;
    r.Noise = n(r.BaseFilter, {
        type: "Noise", initialize: function (t) {
            t = t || {}, this.noise = t.noise || 0
        }, applyTo: function (t) {
            for (var e, i = t.getContext("2d"), r = i.getImageData(0, 0, t.width, t.height), n = r.data, s = this.noise, o = 0, a = n.length; o < a; o += 4)e = (.5 - Math.random()) * s, n[o] += e, n[o + 1] += e, n[o + 2] += e;
            i.putImageData(r, 0, 0)
        }, toObject: function () {
            return i(this.callSuper("toObject"), {noise: this.noise})
        }
    }), e.Image.filters.Noise.fromObject = e.Image.filters.BaseFilter.fromObject
}("undefined" != typeof exports ? exports : this), function (t) {
    "use strict";
    var e = t.fabric || (t.fabric = {}), i = e.util.object.extend, r = e.Image.filters, n = e.util.createClass;
    r.Pixelate = n(r.BaseFilter, {
        type: "Pixelate", initialize: function (t) {
            t = t || {}, this.blocksize = t.blocksize || 4
        }, applyTo: function (t) {
            var e, i, r, n, s, o, a, h = t.getContext("2d"), c = h.getImageData(0, 0, t.width, t.height), l = c.data, u = c.height, f = c.width;
            for (i = 0; i < u; i += this.blocksize)for (r = 0; r < f; r += this.blocksize) {
                e = 4 * i * f + 4 * r, n = l[e], s = l[e + 1], o = l[e + 2], a = l[e + 3];
                for (var d = i, g = i + this.blocksize; d < g; d++)for (var p = r, v = r + this.blocksize; p < v; p++)e = 4 * d * f + 4 * p, l[e] = n, l[e + 1] = s, l[e + 2] = o, l[e + 3] = a
            }
            h.putImageData(c, 0, 0)
        }, toObject: function () {
            return i(this.callSuper("toObject"), {blocksize: this.blocksize})
        }
    }), e.Image.filters.Pixelate.fromObject = e.Image.filters.BaseFilter.fromObject
}("undefined" != typeof exports ? exports : this), function (t) {
    "use strict";
    var e = t.fabric || (t.fabric = {}), i = e.util.object.extend, r = e.Image.filters, n = e.util.createClass;
    r.RemoveWhite = n(r.BaseFilter, {
        type: "RemoveWhite", initialize: function (t) {
            t = t || {}, this.threshold = t.threshold || 30, this.distance = t.distance || 20
        }, applyTo: function (t) {
            for (var e, i, r, n = t.getContext("2d"), s = n.getImageData(0, 0, t.width, t.height), o = s.data, a = this.threshold, h = this.distance, c = 255 - a, l = Math.abs, u = 0, f = o.length; u < f; u += 4)e = o[u], i = o[u + 1], r = o[u + 2], e > c && i > c && r > c && l(e - i) < h && l(e - r) < h && l(i - r) < h && (o[u + 3] = 0);
            n.putImageData(s, 0, 0)
        }, toObject: function () {
            return i(this.callSuper("toObject"), {threshold: this.threshold, distance: this.distance})
        }
    }), e.Image.filters.RemoveWhite.fromObject = e.Image.filters.BaseFilter.fromObject;
}("undefined" != typeof exports ? exports : this), function (t) {
    "use strict";
    var e = t.fabric || (t.fabric = {}), i = e.Image.filters, r = e.util.createClass;
    i.Sepia = r(i.BaseFilter, {
        type: "Sepia", applyTo: function (t) {
            var e, i, r = t.getContext("2d"), n = r.getImageData(0, 0, t.width, t.height), s = n.data, o = s.length;
            for (e = 0; e < o; e += 4)i = .3 * s[e] + .59 * s[e + 1] + .11 * s[e + 2], s[e] = i + 100, s[e + 1] = i + 50, s[e + 2] = i + 255;
            r.putImageData(n, 0, 0)
        }
    }), e.Image.filters.Sepia.fromObject = function (t, i) {
        return t = t || {}, t.type = "Sepia", new e.Image.filters.BaseFilter.fromObject(t, i)
    }
}("undefined" != typeof exports ? exports : this), function (t) {
    "use strict";
    var e = t.fabric || (t.fabric = {}), i = e.Image.filters, r = e.util.createClass;
    i.Sepia2 = r(i.BaseFilter, {
        type: "Sepia2", applyTo: function (t) {
            var e, i, r, n, s = t.getContext("2d"), o = s.getImageData(0, 0, t.width, t.height), a = o.data, h = a.length;
            for (e = 0; e < h; e += 4)i = a[e], r = a[e + 1], n = a[e + 2], a[e] = (.393 * i + .769 * r + .189 * n) / 1.351, a[e + 1] = (.349 * i + .686 * r + .168 * n) / 1.203, a[e + 2] = (.272 * i + .534 * r + .131 * n) / 2.14;
            s.putImageData(o, 0, 0)
        }
    }), e.Image.filters.Sepia2.fromObject = function (t, i) {
        return t = t || {}, t.type = "Sepia2", new e.Image.filters.BaseFilter.fromObject(t, i)
    }
}("undefined" != typeof exports ? exports : this), function (t) {
    "use strict";
    var e = t.fabric || (t.fabric = {}), i = e.util.object.extend, r = e.Image.filters, n = e.util.createClass;
    r.Tint = n(r.BaseFilter, {
        type: "Tint", initialize: function (t) {
            t = t || {}, this.color = t.color || "#000000", this.opacity = "undefined" != typeof t.opacity ? t.opacity : new e.Color(this.color).getAlpha()
        }, applyTo: function (t) {
            var i, r, n, s, o, a, h, c, l, u = t.getContext("2d"), f = u.getImageData(0, 0, t.width, t.height), d = f.data, g = d.length;
            for (l = new e.Color(this.color).getSource(), r = l[0] * this.opacity, n = l[1] * this.opacity, s = l[2] * this.opacity, c = 1 - this.opacity, i = 0; i < g; i += 4)o = d[i], a = d[i + 1], h = d[i + 2], d[i] = r + o * c, d[i + 1] = n + a * c, d[i + 2] = s + h * c;
            u.putImageData(f, 0, 0)
        }, toObject: function () {
            return i(this.callSuper("toObject"), {color: this.color, opacity: this.opacity})
        }
    }), e.Image.filters.Tint.fromObject = e.Image.filters.BaseFilter.fromObject
}("undefined" != typeof exports ? exports : this), function (t) {
    "use strict";
    var e = t.fabric || (t.fabric = {}), i = e.util.object.extend, r = e.Image.filters, n = e.util.createClass;
    r.Multiply = n(r.BaseFilter, {
        type: "Multiply", initialize: function (t) {
            t = t || {}, this.color = t.color || "#000000"
        }, applyTo: function (t) {
            var i, r, n = t.getContext("2d"), s = n.getImageData(0, 0, t.width, t.height), o = s.data, a = o.length;
            for (r = new e.Color(this.color).getSource(), i = 0; i < a; i += 4)o[i] *= r[0] / 255, o[i + 1] *= r[1] / 255, o[i + 2] *= r[2] / 255;
            n.putImageData(s, 0, 0)
        }, toObject: function () {
            return i(this.callSuper("toObject"), {color: this.color})
        }
    }), e.Image.filters.Multiply.fromObject = e.Image.filters.BaseFilter.fromObject
}("undefined" != typeof exports ? exports : this), function (t) {
    "use strict";
    var e = t.fabric, i = e.Image.filters, r = e.util.createClass;
    i.Blend = r(i.BaseFilter, {
        type: "Blend", initialize: function (t) {
            t = t || {}, this.color = t.color || "#000", this.image = t.image || !1, this.mode = t.mode || "multiply", this.alpha = t.alpha || 1
        }, applyTo: function (t) {
            var i, r, n, s, o, a, h, c, l, u, f = t.getContext("2d"), d = f.getImageData(0, 0, t.width, t.height), g = d.data, p = !1;
            if (this.image) {
                p = !0;
                var v = e.util.createCanvasElement();
                v.width = this.image.width, v.height = this.image.height;
                var b = new e.StaticCanvas(v);
                b.add(this.image);
                var m = b.getContext("2d");
                u = m.getImageData(0, 0, b.width, b.height).data
            } else u = new e.Color(this.color).getSource(), i = u[0] * this.alpha, r = u[1] * this.alpha, n = u[2] * this.alpha;
            for (var y = 0, _ = g.length; y < _; y += 4)switch (s = g[y], o = g[y + 1], a = g[y + 2], p && (i = u[y] * this.alpha, r = u[y + 1] * this.alpha, n = u[y + 2] * this.alpha), this.mode) {
                case"multiply":
                    g[y] = s * i / 255, g[y + 1] = o * r / 255, g[y + 2] = a * n / 255;
                    break;
                case"screen":
                    g[y] = 1 - (1 - s) * (1 - i), g[y + 1] = 1 - (1 - o) * (1 - r), g[y + 2] = 1 - (1 - a) * (1 - n);
                    break;
                case"add":
                    g[y] = Math.min(255, s + i), g[y + 1] = Math.min(255, o + r), g[y + 2] = Math.min(255, a + n);
                    break;
                case"diff":
                case"difference":
                    g[y] = Math.abs(s - i), g[y + 1] = Math.abs(o - r), g[y + 2] = Math.abs(a - n);
                    break;
                case"subtract":
                    h = s - i, c = o - r, l = a - n, g[y] = h < 0 ? 0 : h, g[y + 1] = c < 0 ? 0 : c, g[y + 2] = l < 0 ? 0 : l;
                    break;
                case"darken":
                    g[y] = Math.min(s, i), g[y + 1] = Math.min(o, r), g[y + 2] = Math.min(a, n);
                    break;
                case"lighten":
                    g[y] = Math.max(s, i), g[y + 1] = Math.max(o, r), g[y + 2] = Math.max(a, n)
            }
            f.putImageData(d, 0, 0)
        }, toObject: function () {
            return {color: this.color, image: this.image, mode: this.mode, alpha: this.alpha}
        }
    }), e.Image.filters.Blend.fromObject = e.Image.filters.BaseFilter.fromObject
}("undefined" != typeof exports ? exports : this), function (t) {
    "use strict";
    var e = t.fabric || (t.fabric = {}), i = Math.pow, r = Math.floor, n = Math.sqrt, s = Math.abs, o = Math.max, a = Math.round, h = Math.sin, c = Math.ceil, l = e.Image.filters, u = e.util.createClass;
    l.Resize = u(l.BaseFilter, {
        type: "Resize",
        resizeType: "hermite",
        scaleX: 0,
        scaleY: 0,
        lanczosLobes: 3,
        applyTo: function (t, e, i) {
            if (1 !== e || 1 !== i) {
                this.rcpScaleX = 1 / e, this.rcpScaleY = 1 / i;
                var r, n = t.width, s = t.height, o = a(n * e), h = a(s * i);
                "sliceHack" === this.resizeType && (r = this.sliceByTwo(t, n, s, o, h)), "hermite" === this.resizeType && (r = this.hermiteFastResize(t, n, s, o, h)), "bilinear" === this.resizeType && (r = this.bilinearFiltering(t, n, s, o, h)), "lanczos" === this.resizeType && (r = this.lanczosResize(t, n, s, o, h)), t.width = o, t.height = h, t.getContext("2d").putImageData(r, 0, 0)
            }
        },
        sliceByTwo: function (t, i, n, s, a) {
            var h, c = t.getContext("2d"), l = .5, u = .5, f = 1, d = 1, g = !1, p = !1, v = i, b = n, m = e.util.createCanvasElement(), y = m.getContext("2d");
            for (s = r(s), a = r(a), m.width = o(s, i), m.height = o(a, n), s > i && (l = 2, f = -1), a > n && (u = 2, d = -1), h = c.getImageData(0, 0, i, n), t.width = o(s, i), t.height = o(a, n), c.putImageData(h, 0, 0); !g || !p;)i = v, n = b, s * f < r(v * l * f) ? v = r(v * l) : (v = s, g = !0), a * d < r(b * u * d) ? b = r(b * u) : (b = a, p = !0), h = c.getImageData(0, 0, i, n), y.putImageData(h, 0, 0), c.clearRect(0, 0, v, b), c.drawImage(m, 0, 0, i, n, 0, 0, v, b);
            return c.getImageData(0, 0, s, a)
        },
        lanczosResize: function (t, e, o, a, l) {
            function u(t) {
                return function (e) {
                    if (e > t)return 0;
                    if (e *= Math.PI, s(e) < 1e-16)return 1;
                    var i = e / t;
                    return h(e) * h(i) / e / i
                }
            }

            function f(t) {
                var h, c, u, d, g, k, M, D, A, P, E;
                for (T.x = (t + .5) * y, j.x = r(T.x), h = 0; h < l; h++) {
                    for (T.y = (h + .5) * _, j.y = r(T.y), g = 0, k = 0, M = 0, D = 0, A = 0, c = j.x - S; c <= j.x + S; c++)if (!(c < 0 || c >= e)) {
                        P = r(1e3 * s(c - T.x)), O[P] || (O[P] = {});
                        for (var I = j.y - w; I <= j.y + w; I++)I < 0 || I >= o || (E = r(1e3 * s(I - T.y)), O[P][E] || (O[P][E] = m(n(i(P * x, 2) + i(E * C, 2)) / 1e3)), u = O[P][E], u > 0 && (d = 4 * (I * e + c), g += u, k += u * v[d], M += u * v[d + 1], D += u * v[d + 2], A += u * v[d + 3]))
                    }
                    d = 4 * (h * a + t), b[d] = k / g, b[d + 1] = M / g, b[d + 2] = D / g, b[d + 3] = A / g
                }
                return ++t < a ? f(t) : p
            }