var em = Object.defineProperty;
var tm = (t, e, r) => e in t ? em(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
var Ce = (t, e, r) => (tm(t, typeof e != "symbol" ? e + "" : e, r), r);
import * as Se from "react";
import ae, { forwardRef as et, useDebugValue as rm, createContext as sr, useContext as De, useLayoutEffect as pi, useEffect as xe, useRef as de, useCallback as Ie, useMemo as Je, createElement as Ch, useId as yt, useState as Ae, useInsertionEffect as im, cloneElement as dt, Children as Sr, isValidElement as tr, memo as nm, Fragment as Gt } from "react";
import * as om from "react-dom";
import sm, { createPortal as Th } from "react-dom";
var Hr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function am(t) {
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
}
function lm(t) {
  var e = t.default;
  if (typeof e == "function") {
    var r = function() {
      return e.apply(this, arguments);
    };
    r.prototype = e.prototype;
  } else
    r = {};
  return Object.defineProperty(r, "__esModule", { value: !0 }), Object.keys(t).forEach(function(i) {
    var o = Object.getOwnPropertyDescriptor(t, i);
    Object.defineProperty(r, i, o.get ? o : {
      enumerable: !0,
      get: function() {
        return t[i];
      }
    });
  }), r;
}
var cm = function(e) {
  return um(e) && !hm(e);
};
function um(t) {
  return !!t && typeof t == "object";
}
function hm(t) {
  var e = Object.prototype.toString.call(t);
  return e === "[object RegExp]" || e === "[object Date]" || pm(t);
}
var fm = typeof Symbol == "function" && Symbol.for, dm = fm ? Symbol.for("react.element") : 60103;
function pm(t) {
  return t.$$typeof === dm;
}
function gm(t) {
  return Array.isArray(t) ? [] : {};
}
function Di(t, e) {
  return e.clone !== !1 && e.isMergeableObject(t) ? oi(gm(t), t, e) : t;
}
function mm(t, e, r) {
  return t.concat(e).map(function(i) {
    return Di(i, r);
  });
}
function vm(t, e) {
  if (!e.customMerge)
    return oi;
  var r = e.customMerge(t);
  return typeof r == "function" ? r : oi;
}
function bm(t) {
  return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(t).filter(function(e) {
    return t.propertyIsEnumerable(e);
  }) : [];
}
function Gl(t) {
  return Object.keys(t).concat(bm(t));
}
function kh(t, e) {
  try {
    return e in t;
  } catch {
    return !1;
  }
}
function ym(t, e) {
  return kh(t, e) && !(Object.hasOwnProperty.call(t, e) && Object.propertyIsEnumerable.call(t, e));
}
function wm(t, e, r) {
  var i = {};
  return r.isMergeableObject(t) && Gl(t).forEach(function(o) {
    i[o] = Di(t[o], r);
  }), Gl(e).forEach(function(o) {
    ym(t, o) || (kh(t, o) && r.isMergeableObject(e[o]) ? i[o] = vm(o, r)(t[o], e[o], r) : i[o] = Di(e[o], r));
  }), i;
}
function oi(t, e, r) {
  r = r || {}, r.arrayMerge = r.arrayMerge || mm, r.isMergeableObject = r.isMergeableObject || cm, r.cloneUnlessOtherwiseSpecified = Di;
  var i = Array.isArray(e), o = Array.isArray(t), p = i === o;
  return p ? i ? r.arrayMerge(t, e, r) : wm(t, e, r) : Di(e, r);
}
oi.all = function(e, r) {
  if (!Array.isArray(e))
    throw new Error("first argument should be an array");
  return e.reduce(function(i, o) {
    return oi(i, o, r);
  }, {});
};
var xm = oi, Eh = xm;
function _m(t, e) {
  e === void 0 && (e = {});
  var r = e.insertAt;
  if (!(!t || typeof document > "u")) {
    var i = document.head || document.getElementsByTagName("head")[0], o = document.createElement("style");
    o.type = "text/css", r === "top" && i.firstChild ? i.insertBefore(o, i.firstChild) : i.appendChild(o), o.styleSheet ? o.styleSheet.cssText = t : o.appendChild(document.createTextNode(t));
  }
}
function Ma(t, e) {
  return e === void 0 && (e = 15), +parseFloat(Number(t).toPrecision(e));
}
function Tt(t) {
  var e = t.toString().split(/[eE]/), r = (e[0].split(".")[1] || "").length - +(e[1] || 0);
  return r > 0 ? r : 0;
}
function Ii(t) {
  if (t.toString().indexOf("e") === -1)
    return Number(t.toString().replace(".", ""));
  var e = Tt(t);
  return e > 0 ? Ma(Number(t) * Math.pow(10, e)) : Number(t);
}
function Cs(t) {
  Mh && (t > Number.MAX_SAFE_INTEGER || t < Number.MIN_SAFE_INTEGER) && console.warn(t + " is beyond boundary when transfer to integer, the results may not be accurate");
}
function mo(t, e) {
  var r = t[0], i = t[1], o = t.slice(2), p = e(r, i);
  return o.forEach(function(g) {
    p = e(p, g);
  }), p;
}
function Rt() {
  for (var t = [], e = 0; e < arguments.length; e++)
    t[e] = arguments[e];
  if (t.length > 2)
    return mo(t, Rt);
  var r = t[0], i = t[1], o = Ii(r), p = Ii(i), g = Tt(r) + Tt(i), a = o * p;
  return Cs(a), a / Math.pow(10, g);
}
function Oh() {
  for (var t = [], e = 0; e < arguments.length; e++)
    t[e] = arguments[e];
  if (t.length > 2)
    return mo(t, Oh);
  var r = t[0], i = t[1], o = Math.pow(10, Math.max(Tt(r), Tt(i)));
  return (Rt(r, o) + Rt(i, o)) / o;
}
function Ph() {
  for (var t = [], e = 0; e < arguments.length; e++)
    t[e] = arguments[e];
  if (t.length > 2)
    return mo(t, Ph);
  var r = t[0], i = t[1], o = Math.pow(10, Math.max(Tt(r), Tt(i)));
  return (Rt(r, o) - Rt(i, o)) / o;
}
function Aa() {
  for (var t = [], e = 0; e < arguments.length; e++)
    t[e] = arguments[e];
  if (t.length > 2)
    return mo(t, Aa);
  var r = t[0], i = t[1], o = Ii(r), p = Ii(i);
  return Cs(o), Cs(p), Rt(o / p, Ma(Math.pow(10, Tt(i) - Tt(r))));
}
function Sm(t, e) {
  var r = Math.pow(10, e), i = Aa(Math.round(Math.abs(Rt(t, r))), r);
  return t < 0 && i !== 0 && (i = Rt(i, -1)), i;
}
var Mh = !0;
function Cm(t) {
  t === void 0 && (t = !0), Mh = t;
}
var Ts = {
  strip: Ma,
  plus: Oh,
  minus: Ph,
  times: Rt,
  divide: Aa,
  round: Sm,
  digitLength: Tt,
  float2Fixed: Ii,
  enableBoundaryChecking: Cm
};
function mn(t) {
  return t && t.Math == Math ? t : void 0;
}
var Ah = typeof globalThis == "object" && mn(globalThis) || typeof window == "object" && mn(window) || typeof self == "object" && mn(self) || typeof global == "object" && mn(global) || function() {
  return this;
}() || {};
function Ve() {
  return Ah;
}
function Da(t, e, r) {
  var i = r || Ah, o = i.__SENTRY__ = i.__SENTRY__ || {}, p = o[t] || (o[t] = e());
  return p;
}
var Dh = Object.prototype.toString;
function Ih(t) {
  switch (Dh.call(t)) {
    case "[object Error]":
    case "[object Exception]":
    case "[object DOMException]":
      return !0;
    default:
      return ar(t, Error);
  }
}
function gi(t, e) {
  return Dh.call(t) === `[object ${e}]`;
}
function Rh(t) {
  return gi(t, "ErrorEvent");
}
function ql(t) {
  return gi(t, "DOMError");
}
function Tm(t) {
  return gi(t, "DOMException");
}
function si(t) {
  return gi(t, "String");
}
function Lh(t) {
  return t === null || typeof t != "object" && typeof t != "function";
}
function ai(t) {
  return gi(t, "Object");
}
function Ia(t) {
  return typeof Event < "u" && ar(t, Event);
}
function km(t) {
  return typeof Element < "u" && ar(t, Element);
}
function Em(t) {
  return gi(t, "RegExp");
}
function Ra(t) {
  return Boolean(t && t.then && typeof t.then == "function");
}
function Om(t) {
  return ai(t) && "nativeEvent" in t && "preventDefault" in t && "stopPropagation" in t;
}
function Pm(t) {
  return typeof t == "number" && t !== t;
}
function ar(t, e) {
  try {
    return t instanceof e;
  } catch {
    return !1;
  }
}
function ks(t, e) {
  try {
    let a = t;
    var r = 5, i = 80, o = [];
    let n = 0, u = 0;
    var p = " > ", g = p.length;
    let h;
    for (; a && n++ < r && (h = Mm(a, e), !(h === "html" || n > 1 && u + o.length * g + h.length >= i)); )
      o.push(h), u += h.length, a = a.parentNode;
    return o.reverse().join(p);
  } catch {
    return "<unknown>";
  }
}
function Mm(t, e) {
  var r = t, i = [];
  let o, p, g, a, n;
  if (!r || !r.tagName)
    return "";
  i.push(r.tagName.toLowerCase());
  var u = e && e.length ? e.filter((s) => r.getAttribute(s)).map((s) => [s, r.getAttribute(s)]) : null;
  if (u && u.length)
    u.forEach((s) => {
      i.push(`[${s[0]}="${s[1]}"]`);
    });
  else if (r.id && i.push(`#${r.id}`), o = r.className, o && si(o))
    for (p = o.split(/\s+/), n = 0; n < p.length; n++)
      i.push(`.${p[n]}`);
  var h = ["type", "name", "title", "alt"];
  for (n = 0; n < h.length; n++)
    g = h[n], a = r.getAttribute(g), a && i.push(`[${g}="${a}"]`);
  return i.join("");
}
function Am() {
  var t = Ve();
  try {
    return t.document.location.href;
  } catch {
    return "";
  }
}
class Ke extends Error {
  constructor(e, r = "warn") {
    super(e), this.message = e, this.name = new.target.prototype.constructor.name, Object.setPrototypeOf(this, new.target.prototype), this.logLevel = r;
  }
}
var Dm = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/;
function Im(t) {
  return t === "http" || t === "https";
}
function La(t, e = !1) {
  const { host: r, path: i, pass: o, port: p, projectId: g, protocol: a, publicKey: n } = t;
  return `${a}://${n}${e && o ? `:${o}` : ""}@${r}${p ? `:${p}` : ""}/${i && `${i}/`}${g}`;
}
function Rm(t) {
  var e = Dm.exec(t);
  if (!e)
    throw new Ke(`Invalid Sentry Dsn: ${t}`);
  const [r, i, o = "", p, g = "", a] = e.slice(1);
  let n = "", u = a;
  var h = u.split("/");
  if (h.length > 1 && (n = h.slice(0, -1).join("/"), u = h.pop()), u) {
    var s = u.match(/^\d+/);
    s && (u = s[0]);
  }
  return Fh({ host: p, pass: o, path: n, projectId: u, port: g, protocol: r, publicKey: i });
}
function Fh(t) {
  return {
    protocol: t.protocol,
    publicKey: t.publicKey || "",
    pass: t.pass || "",
    host: t.host,
    port: t.port || "",
    path: t.path || "",
    projectId: t.projectId
  };
}
function Lm(t) {
  if (!(typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__))
    return;
  const { port: e, projectId: r, protocol: i } = t;
  var o = ["protocol", "publicKey", "host", "projectId"];
  if (o.forEach((p) => {
    if (!t[p])
      throw new Ke(`Invalid Sentry Dsn: ${p} missing`);
  }), !r.match(/^\d+$/))
    throw new Ke(`Invalid Sentry Dsn: Invalid projectId ${r}`);
  if (!Im(i))
    throw new Ke(`Invalid Sentry Dsn: Invalid protocol ${i}`);
  if (e && isNaN(parseInt(e, 10)))
    throw new Ke(`Invalid Sentry Dsn: Invalid port ${e}`);
  return !0;
}
function Fm(t) {
  var e = typeof t == "string" ? Rm(t) : Fh(t);
  return Lm(e), e;
}
var zm = Ve(), jm = "Sentry Logger ", $n = ["debug", "info", "warn", "error", "log", "assert", "trace"];
function zh(t) {
  var e = Ve();
  if (!("console" in e))
    return t();
  var r = e.console, i = {};
  $n.forEach((o) => {
    var p = r[o] && r[o].__sentry_original__;
    o in e.console && p && (i[o] = r[o], r[o] = p);
  });
  try {
    return t();
  } finally {
    Object.keys(i).forEach((o) => {
      r[o] = i[o];
    });
  }
}
function Kl() {
  let t = !1;
  var e = {
    enable: () => {
      t = !0;
    },
    disable: () => {
      t = !1;
    }
  };
  return typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__ ? $n.forEach((r) => {
    e[r] = (...i) => {
      t && zh(() => {
        zm.console[r](`${jm}[${r}]:`, ...i);
      });
    };
  }) : $n.forEach((r) => {
    e[r] = () => {
    };
  }), e;
}
let Te;
typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__ ? Te = Da("logger", Kl) : Te = Kl();
function Ci(t, e = 0) {
  return typeof t != "string" || e === 0 || t.length <= e ? t : `${t.substr(0, e)}...`;
}
function Zl(t, e) {
  if (!Array.isArray(t))
    return "";
  var r = [];
  for (let o = 0; o < t.length; o++) {
    var i = t[o];
    try {
      r.push(String(i));
    } catch {
      r.push("[value cannot be serialized]");
    }
  }
  return r.join(e);
}
function Fa(t, e) {
  return si(t) ? Em(e) ? e.test(t) : typeof e == "string" ? t.indexOf(e) !== -1 : !1 : !1;
}
function Ze(t, e, r) {
  if (e in t) {
    var i = t[e], o = r(i);
    if (typeof o == "function")
      try {
        jh(o, i);
      } catch {
      }
    t[e] = o;
  }
}
function za(t, e, r) {
  Object.defineProperty(t, e, {
    value: r,
    writable: !0,
    configurable: !0
  });
}
function jh(t, e) {
  var r = e.prototype || {};
  t.prototype = e.prototype = r, za(t, "__sentry_original__", e);
}
function ja(t) {
  return t.__sentry_original__;
}
function Bm(t) {
  return Object.keys(t).map((e) => `${encodeURIComponent(e)}=${encodeURIComponent(t[e])}`).join("&");
}
function Bh(t) {
  if (Ih(t))
    return {
      message: t.message,
      name: t.name,
      stack: t.stack,
      ...Ql(t)
    };
  if (Ia(t)) {
    var e = {
      type: t.type,
      target: Jl(t.target),
      currentTarget: Jl(t.currentTarget),
      ...Ql(t)
    };
    return typeof CustomEvent < "u" && ar(t, CustomEvent) && (e.detail = t.detail), e;
  } else
    return t;
}
function Jl(t) {
  try {
    return km(t) ? ks(t) : Object.prototype.toString.call(t);
  } catch {
    return "<unknown>";
  }
}
function Ql(t) {
  if (typeof t == "object" && t !== null) {
    var e = {};
    for (var r in t)
      Object.prototype.hasOwnProperty.call(t, r) && (e[r] = t[r]);
    return e;
  } else
    return {};
}
function Nm(t, e = 40) {
  var r = Object.keys(Bh(t));
  if (r.sort(), !r.length)
    return "[object has no keys]";
  if (r[0].length >= e)
    return Ci(r[0], e);
  for (let o = r.length; o > 0; o--) {
    var i = r.slice(0, o).join(", ");
    if (!(i.length > e))
      return o === r.length ? i : Ci(i, e);
  }
  return "";
}
function Ba(t) {
  var e = /* @__PURE__ */ new Map();
  return Es(t, e);
}
function Es(t, e) {
  if (ai(t)) {
    var r = e.get(t);
    if (r !== void 0)
      return r;
    var i = {};
    e.set(t, i);
    for (var o of Object.keys(t))
      typeof t[o] < "u" && (i[o] = Es(t[o], e));
    return i;
  }
  if (Array.isArray(t)) {
    var r = e.get(t);
    if (r !== void 0)
      return r;
    var i = [];
    return e.set(t, i), t.forEach((a) => {
      i.push(Es(a, e));
    }), i;
  }
  return t;
}
var Vm = 50;
function Nh(...t) {
  var e = t.sort((r, i) => r[0] - i[0]).map((r) => r[1]);
  return (r, i = 0) => {
    var o = [];
    for (var p of r.split(`
`).slice(i)) {
      var g = p.replace(/\(error: (.*)\)/, "$1");
      for (var a of e) {
        var n = a(g);
        if (n) {
          o.push(n);
          break;
        }
      }
    }
    return Hm(o);
  };
}
function $m(t) {
  return Array.isArray(t) ? Nh(...t) : t;
}
function Hm(t) {
  if (!t.length)
    return [];
  let e = t;
  var r = e[0].function || "", i = e[e.length - 1].function || "";
  return (r.indexOf("captureMessage") !== -1 || r.indexOf("captureException") !== -1) && (e = e.slice(1)), i.indexOf("sentryWrapped") !== -1 && (e = e.slice(0, -1)), e.slice(0, Vm).map((o) => ({
    ...o,
    filename: o.filename || e[0].filename,
    function: o.function || "?"
  })).reverse();
}
var Go = "<anonymous>";
function rr(t) {
  try {
    return !t || typeof t != "function" ? Go : t.name || Go;
  } catch {
    return Go;
  }
}
function Vh() {
  if (!("fetch" in Ve()))
    return !1;
  try {
    return new Headers(), new Request("http://www.example.com"), new Response(), !0;
  } catch {
    return !1;
  }
}
function Os(t) {
  return t && /^function fetch\(\)\s+\{\s+\[native code\]\s+\}$/.test(t.toString());
}
function Um() {
  if (!Vh())
    return !1;
  var t = Ve();
  if (Os(t.fetch))
    return !0;
  let e = !1;
  var r = t.document;
  if (r && typeof r.createElement == "function")
    try {
      var i = r.createElement("iframe");
      i.hidden = !0, r.head.appendChild(i), i.contentWindow && i.contentWindow.fetch && (e = Os(i.contentWindow.fetch)), r.head.removeChild(i);
    } catch (o) {
      (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ", o);
    }
  return e;
}
function Wm() {
  var t = Ve(), e = t.chrome, r = e && e.app && e.app.runtime, i = "history" in t && !!t.history.pushState && !!t.history.replaceState;
  return !r && i;
}
var Fe = Ve(), Ti = {}, ec = {};
function Ym(t) {
  if (!ec[t])
    switch (ec[t] = !0, t) {
      case "console":
        Xm();
        break;
      case "dom":
        rv();
        break;
      case "xhr":
        Zm();
        break;
      case "fetch":
        Gm();
        break;
      case "history":
        Jm();
        break;
      case "error":
        iv();
        break;
      case "unhandledrejection":
        nv();
        break;
      default:
        (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.warn("unknown instrumentation type:", t);
        return;
    }
}
function Ht(t, e) {
  Ti[t] = Ti[t] || [], Ti[t].push(e), Ym(t);
}
function bt(t, e) {
  if (!(!t || !Ti[t]))
    for (var r of Ti[t] || [])
      try {
        r(e);
      } catch (i) {
        (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.error(
          `Error while triggering instrumentation handler.
Type: ${t}
Name: ${rr(r)}
Error:`,
          i
        );
      }
}
function Xm() {
  "console" in Fe && $n.forEach(function(t) {
    t in Fe.console && Ze(Fe.console, t, function(e) {
      return function(...r) {
        bt("console", { args: r, level: t }), e && e.apply(Fe.console, r);
      };
    });
  });
}
function Gm() {
  !Um() || Ze(Fe, "fetch", function(t) {
    return function(...e) {
      var r = {
        args: e,
        fetchData: {
          method: qm(e),
          url: Km(e)
        },
        startTimestamp: Date.now()
      };
      return bt("fetch", {
        ...r
      }), t.apply(Fe, e).then(
        (i) => (bt("fetch", {
          ...r,
          endTimestamp: Date.now(),
          response: i
        }), i),
        (i) => {
          throw bt("fetch", {
            ...r,
            endTimestamp: Date.now(),
            error: i
          }), i;
        }
      );
    };
  });
}
function qm(t = []) {
  return "Request" in Fe && ar(t[0], Request) && t[0].method ? String(t[0].method).toUpperCase() : t[1] && t[1].method ? String(t[1].method).toUpperCase() : "GET";
}
function Km(t = []) {
  return typeof t[0] == "string" ? t[0] : "Request" in Fe && ar(t[0], Request) ? t[0].url : String(t[0]);
}
function Zm() {
  if ("XMLHttpRequest" in Fe) {
    var t = XMLHttpRequest.prototype;
    Ze(t, "open", function(e) {
      return function(...r) {
        var i = this, o = r[1], p = i.__sentry_xhr__ = {
          method: si(r[0]) ? r[0].toUpperCase() : r[0],
          url: r[1]
        };
        si(o) && p.method === "POST" && o.match(/sentry_key/) && (i.__sentry_own_request__ = !0);
        var g = function() {
          if (i.readyState === 4) {
            try {
              p.status_code = i.status;
            } catch {
            }
            bt("xhr", {
              args: r,
              endTimestamp: Date.now(),
              startTimestamp: Date.now(),
              xhr: i
            });
          }
        };
        return "onreadystatechange" in i && typeof i.onreadystatechange == "function" ? Ze(i, "onreadystatechange", function(a) {
          return function(...n) {
            return g(), a.apply(i, n);
          };
        }) : i.addEventListener("readystatechange", g), e.apply(i, r);
      };
    }), Ze(t, "send", function(e) {
      return function(...r) {
        return this.__sentry_xhr__ && r[0] !== void 0 && (this.__sentry_xhr__.body = r[0]), bt("xhr", {
          args: r,
          startTimestamp: Date.now(),
          xhr: this
        }), e.apply(this, r);
      };
    });
  }
}
let vn;
function Jm() {
  if (!Wm())
    return;
  var t = Fe.onpopstate;
  Fe.onpopstate = function(...r) {
    var i = Fe.location.href, o = vn;
    if (vn = i, bt("history", {
      from: o,
      to: i
    }), t)
      try {
        return t.apply(this, r);
      } catch {
      }
  };
  function e(r) {
    return function(...i) {
      var o = i.length > 2 ? i[2] : void 0;
      if (o) {
        var p = vn, g = String(o);
        vn = g, bt("history", {
          from: p,
          to: g
        });
      }
      return r.apply(this, i);
    };
  }
  Ze(Fe.history, "pushState", e), Ze(Fe.history, "replaceState", e);
}
var Qm = 1e3;
let bn, yn;
function ev(t, e) {
  if (!t || t.type !== e.type)
    return !0;
  try {
    if (t.target !== e.target)
      return !0;
  } catch {
  }
  return !1;
}
function tv(t) {
  if (t.type !== "keypress")
    return !1;
  try {
    var e = t.target;
    if (!e || !e.tagName)
      return !0;
    if (e.tagName === "INPUT" || e.tagName === "TEXTAREA" || e.isContentEditable)
      return !1;
  } catch {
  }
  return !0;
}
function tc(t, e = !1) {
  return (r) => {
    if (!(!r || yn === r) && !tv(r)) {
      var i = r.type === "keypress" ? "input" : r.type;
      bn === void 0 ? (t({
        event: r,
        name: i,
        global: e
      }), yn = r) : ev(yn, r) && (t({
        event: r,
        name: i,
        global: e
      }), yn = r), clearTimeout(bn), bn = Fe.setTimeout(() => {
        bn = void 0;
      }, Qm);
    }
  };
}
function rv() {
  if ("document" in Fe) {
    var t = bt.bind(null, "dom"), e = tc(t, !0);
    Fe.document.addEventListener("click", e, !1), Fe.document.addEventListener("keypress", e, !1), ["EventTarget", "Node"].forEach((r) => {
      var i = Fe[r] && Fe[r].prototype;
      !i || !i.hasOwnProperty || !i.hasOwnProperty("addEventListener") || (Ze(i, "addEventListener", function(o) {
        return function(p, g, a) {
          if (p === "click" || p == "keypress")
            try {
              var n = this, u = n.__sentry_instrumentation_handlers__ = n.__sentry_instrumentation_handlers__ || {}, h = u[p] = u[p] || { refCount: 0 };
              if (!h.handler) {
                var s = tc(t);
                h.handler = s, o.call(this, p, s, a);
              }
              h.refCount += 1;
            } catch {
            }
          return o.call(this, p, g, a);
        };
      }), Ze(
        i,
        "removeEventListener",
        function(o) {
          return function(p, g, a) {
            if (p === "click" || p == "keypress")
              try {
                var n = this, u = n.__sentry_instrumentation_handlers__ || {}, h = u[p];
                h && (h.refCount -= 1, h.refCount <= 0 && (o.call(this, p, h.handler, a), h.handler = void 0, delete u[p]), Object.keys(u).length === 0 && delete n.__sentry_instrumentation_handlers__);
              } catch {
              }
            return o.call(this, p, g, a);
          };
        }
      ));
    });
  }
}
let qo = null;
function iv() {
  qo = Fe.onerror, Fe.onerror = function(t, e, r, i, o) {
    return bt("error", {
      column: i,
      error: o,
      line: r,
      msg: t,
      url: e
    }), qo ? qo.apply(this, arguments) : !1;
  };
}
let Ko = null;
function nv() {
  Ko = Fe.onunhandledrejection, Fe.onunhandledrejection = function(t) {
    return bt("unhandledrejection", t), Ko ? Ko.apply(this, arguments) : !0;
  };
}
function ov() {
  var t = typeof WeakSet == "function", e = t ? /* @__PURE__ */ new WeakSet() : [];
  function r(o) {
    if (t)
      return e.has(o) ? !0 : (e.add(o), !1);
    for (let g = 0; g < e.length; g++) {
      var p = e[g];
      if (p === o)
        return !0;
    }
    return e.push(o), !1;
  }
  function i(o) {
    if (t)
      e.delete(o);
    else
      for (let p = 0; p < e.length; p++)
        if (e[p] === o) {
          e.splice(p, 1);
          break;
        }
  }
  return [r, i];
}
function Zr() {
  var t = Ve(), e = t.crypto || t.msCrypto;
  if (e && e.randomUUID)
    return e.randomUUID().replace(/-/g, "");
  var r = e && e.getRandomValues ? () => e.getRandomValues(new Uint8Array(1))[0] : () => Math.random() * 16;
  return ([1e7] + 1e3 + 4e3 + 8e3 + 1e11).replace(
    /[018]/g,
    (i) => (i ^ (r() & 15) >> i / 4).toString(16)
  );
}
function $h(t) {
  return t.exception && t.exception.values ? t.exception.values[0] : void 0;
}
function wr(t) {
  const { message: e, event_id: r } = t;
  if (e)
    return e;
  var i = $h(t);
  return i ? i.type && i.value ? `${i.type}: ${i.value}` : i.type || i.value || r || "<unknown>" : r || "<unknown>";
}
function Ps(t, e, r) {
  var i = t.exception = t.exception || {}, o = i.values = i.values || [], p = o[0] = o[0] || {};
  p.value || (p.value = e || ""), p.type || (p.type = r || "Error");
}
function Ri(t, e) {
  var r = $h(t);
  if (!!r) {
    var i = { type: "generic", handled: !0 }, o = r.mechanism;
    if (r.mechanism = { ...i, ...o, ...e }, e && "data" in e) {
      var p = { ...o && o.data, ...e.data };
      r.mechanism.data = p;
    }
  }
}
function rc(t) {
  if (t && t.__sentry_captured__)
    return !0;
  try {
    za(t, "__sentry_captured__", !0);
  } catch {
  }
  return !1;
}
function Hh(t) {
  return Array.isArray(t) ? t : [t];
}
function sv() {
  return typeof __SENTRY_BROWSER_BUNDLE__ < "u" && !!__SENTRY_BROWSER_BUNDLE__;
}
function Uh() {
  return !sv() && Object.prototype.toString.call(typeof process < "u" ? process : 0) === "[object process]";
}
function av(t, e) {
  return t.require(e);
}
function vr(t, e = 1 / 0, r = 1 / 0) {
  try {
    return Ms("", t, e, r);
  } catch (i) {
    return { ERROR: `**non-serializable** (${i})` };
  }
}
function Wh(t, e = 3, r = 100 * 1024) {
  var i = vr(t, e);
  return uv(i) > r ? Wh(t, e - 1, r) : i;
}
function Ms(t, e, r = 1 / 0, i = 1 / 0, o = ov()) {
  const [p, g] = o;
  if (e === null || ["number", "boolean", "string"].includes(typeof e) && !Pm(e))
    return e;
  var a = lv(t, e);
  if (!a.startsWith("[object "))
    return a;
  if (e.__sentry_skip_normalization__)
    return e;
  if (r === 0)
    return a.replace("object ", "");
  if (p(e))
    return "[Circular ~]";
  var n = e;
  if (n && typeof n.toJSON == "function")
    try {
      var u = n.toJSON();
      return Ms("", u, r - 1, i, o);
    } catch {
    }
  var h = Array.isArray(e) ? [] : {};
  let s = 0;
  var l = Bh(e);
  for (var c in l)
    if (!!Object.prototype.hasOwnProperty.call(l, c)) {
      if (s >= i) {
        h[c] = "[MaxProperties ~]";
        break;
      }
      var f = l[c];
      h[c] = Ms(c, f, r - 1, i, o), s += 1;
    }
  return g(e), h;
}
function lv(t, e) {
  try {
    return t === "domain" && e && typeof e == "object" && e._events ? "[Domain]" : t === "domainEmitter" ? "[DomainEmitter]" : typeof global < "u" && e === global ? "[Global]" : typeof window < "u" && e === window ? "[Window]" : typeof document < "u" && e === document ? "[Document]" : Om(e) ? "[SyntheticEvent]" : typeof e == "number" && e !== e ? "[NaN]" : e === void 0 ? "[undefined]" : typeof e == "function" ? `[Function: ${rr(e)}]` : typeof e == "symbol" ? `[${String(e)}]` : typeof e == "bigint" ? `[BigInt: ${String(e)}]` : `[object ${Object.getPrototypeOf(e).constructor.name}]`;
  } catch (r) {
    return `**non-serializable** (${r})`;
  }
}
function cv(t) {
  return ~-encodeURI(t).split(/%..|./).length;
}
function uv(t) {
  return cv(JSON.stringify(t));
}
var Pt;
(function(t) {
  var e = 0;
  t[t.PENDING = e] = "PENDING";
  var r = 1;
  t[t.RESOLVED = r] = "RESOLVED";
  var i = 2;
  t[t.REJECTED = i] = "REJECTED";
})(Pt || (Pt = {}));
function Cr(t) {
  return new nt((e) => {
    e(t);
  });
}
function As(t) {
  return new nt((e, r) => {
    r(t);
  });
}
class nt {
  __init() {
    this._state = Pt.PENDING;
  }
  __init2() {
    this._handlers = [];
  }
  constructor(e) {
    nt.prototype.__init.call(this), nt.prototype.__init2.call(this), nt.prototype.__init3.call(this), nt.prototype.__init4.call(this), nt.prototype.__init5.call(this), nt.prototype.__init6.call(this);
    try {
      e(this._resolve, this._reject);
    } catch (r) {
      this._reject(r);
    }
  }
  then(e, r) {
    return new nt((i, o) => {
      this._handlers.push([
        !1,
        (p) => {
          if (!e)
            i(p);
          else
            try {
              i(e(p));
            } catch (g) {
              o(g);
            }
        },
        (p) => {
          if (!r)
            o(p);
          else
            try {
              i(r(p));
            } catch (g) {
              o(g);
            }
        }
      ]), this._executeHandlers();
    });
  }
  catch(e) {
    return this.then((r) => r, e);
  }
  finally(e) {
    return new nt((r, i) => {
      let o, p;
      return this.then(
        (g) => {
          p = !1, o = g, e && e();
        },
        (g) => {
          p = !0, o = g, e && e();
        }
      ).then(() => {
        if (p) {
          i(o);
          return;
        }
        r(o);
      });
    });
  }
  __init3() {
    this._resolve = (e) => {
      this._setResult(Pt.RESOLVED, e);
    };
  }
  __init4() {
    this._reject = (e) => {
      this._setResult(Pt.REJECTED, e);
    };
  }
  __init5() {
    this._setResult = (e, r) => {
      if (this._state === Pt.PENDING) {
        if (Ra(r)) {
          r.then(this._resolve, this._reject);
          return;
        }
        this._state = e, this._value = r, this._executeHandlers();
      }
    };
  }
  __init6() {
    this._executeHandlers = () => {
      if (this._state !== Pt.PENDING) {
        var e = this._handlers.slice();
        this._handlers = [], e.forEach((r) => {
          r[0] || (this._state === Pt.RESOLVED && r[1](this._value), this._state === Pt.REJECTED && r[2](this._value), r[0] = !0);
        });
      }
    };
  }
}
function hv(t) {
  var e = [];
  function r() {
    return t === void 0 || e.length < t;
  }
  function i(g) {
    return e.splice(e.indexOf(g), 1)[0];
  }
  function o(g) {
    if (!r())
      return As(new Ke("Not adding Promise because buffer limit was reached."));
    var a = g();
    return e.indexOf(a) === -1 && e.push(a), a.then(() => i(a)).then(
      null,
      () => i(a).then(null, () => {
      })
    ), a;
  }
  function p(g) {
    return new nt((a, n) => {
      let u = e.length;
      if (!u)
        return a(!0);
      var h = setTimeout(() => {
        g && g > 0 && a(!1);
      }, g);
      e.forEach((s) => {
        Cr(s).then(() => {
          --u || (clearTimeout(h), a(!0));
        }, n);
      });
    });
  }
  return {
    $: e,
    add: o,
    drain: p
  };
}
function Zo(t) {
  if (!t)
    return {};
  var e = t.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);
  if (!e)
    return {};
  var r = e[6] || "", i = e[8] || "";
  return {
    host: e[4],
    path: e[5],
    protocol: e[2],
    relative: e[5] + r + i
  };
}
var fv = ["fatal", "error", "warning", "log", "info", "debug"];
function dv(t) {
  return t === "warn" ? "warning" : fv.includes(t) ? t : "log";
}
var Ds = {
  nowSeconds: () => Date.now() / 1e3
};
function pv() {
  const { performance: t } = Ve();
  if (!(!t || !t.now)) {
    var e = Date.now() - t.now();
    return {
      now: () => t.now(),
      timeOrigin: e
    };
  }
}
function gv() {
  try {
    var t = av(module, "perf_hooks");
    return t.performance;
  } catch {
    return;
  }
}
var Jo = Uh() ? gv() : pv(), ic = Jo === void 0 ? Ds : {
  nowSeconds: () => (Jo.timeOrigin + Jo.now()) / 1e3
}, vo = Ds.nowSeconds.bind(Ds), Yh = ic.nowSeconds.bind(ic);
(() => {
  const { performance: t } = Ve();
  if (!(!t || !t.now)) {
    var e = 3600 * 1e3, r = t.now(), i = Date.now(), o = t.timeOrigin ? Math.abs(t.timeOrigin + r - i) : e, p = o < e, g = t.timing && t.timing.navigationStart, a = typeof g == "number", n = a ? Math.abs(g + r - i) : e, u = n < e;
    return p || u ? o <= n ? t.timeOrigin : g : i;
  }
})();
function bo(t, e = []) {
  return [t, e];
}
function mv(t, e) {
  const [r, i] = t;
  return [r, [...i, e]];
}
function nc(t, e) {
  var r = t[1];
  r.forEach((i) => {
    var o = i[0].type;
    e(i, o);
  });
}
function Is(t, e) {
  var r = e || new TextEncoder();
  return r.encode(t);
}
function Xh(t, e) {
  const [r, i] = t;
  let o = JSON.stringify(r);
  function p(a) {
    typeof o == "string" ? o = typeof a == "string" ? o + a : [Is(o, e), a] : o.push(typeof a == "string" ? Is(a, e) : a);
  }
  for (var g of i) {
    const [a, n] = g;
    p(`
${JSON.stringify(a)}
`), p(typeof n == "string" || n instanceof Uint8Array ? n : JSON.stringify(n));
  }
  return typeof o == "string" ? o : vv(o);
}
function vv(t) {
  var e = t.reduce((p, g) => p + g.length, 0), r = new Uint8Array(e);
  let i = 0;
  for (var o of t)
    r.set(o, i), i += o.length;
  return r;
}
function bv(t, e) {
  var r = typeof t.data == "string" ? Is(t.data, e) : t.data;
  return [
    Ba({
      type: "attachment",
      length: r.length,
      filename: t.filename,
      content_type: t.contentType,
      attachment_type: t.attachmentType
    }),
    r
  ];
}
var yv = {
  session: "session",
  sessions: "session",
  attachment: "attachment",
  transaction: "transaction",
  event: "error",
  client_report: "internal",
  user_report: "default"
};
function oc(t) {
  return yv[t];
}
function wv(t, e, r) {
  var i = [
    { type: "client_report" },
    {
      timestamp: r || vo(),
      discarded_events: t
    }
  ];
  return bo(e ? { dsn: e } : {}, [i]);
}
var xv = 60 * 1e3;
function _v(t, e = Date.now()) {
  var r = parseInt(`${t}`, 10);
  if (!isNaN(r))
    return r * 1e3;
  var i = Date.parse(`${t}`);
  return isNaN(i) ? xv : i - e;
}
function Sv(t, e) {
  return t[e] || t.all || 0;
}
function Cv(t, e, r = Date.now()) {
  return Sv(t, e) > r;
}
function Tv(t, { statusCode: e, headers: r }, i = Date.now()) {
  var o = {
    ...t
  }, p = r && r["x-sentry-rate-limits"], g = r && r["retry-after"];
  if (p)
    for (var a of p.trim().split(",")) {
      const [s, l] = a.split(":", 2);
      var n = parseInt(s, 10), u = (isNaN(n) ? 60 : n) * 1e3;
      if (!l)
        o.all = i + u;
      else
        for (var h of l.split(";"))
          o[h] = i + u;
    }
  else
    g ? o.all = i + _v(g, i) : e === 429 && (o.all = i + 60 * 1e3);
  return o;
}
function kv(t) {
  var e = Yh(), r = {
    sid: Zr(),
    init: !0,
    timestamp: e,
    started: e,
    duration: 0,
    status: "ok",
    errors: 0,
    ignoreDuration: !1,
    toJSON: () => Ov(r)
  };
  return t && li(r, t), r;
}
function li(t, e = {}) {
  if (e.user && (!t.ipAddress && e.user.ip_address && (t.ipAddress = e.user.ip_address), !t.did && !e.did && (t.did = e.user.id || e.user.email || e.user.username)), t.timestamp = e.timestamp || Yh(), e.ignoreDuration && (t.ignoreDuration = e.ignoreDuration), e.sid && (t.sid = e.sid.length === 32 ? e.sid : Zr()), e.init !== void 0 && (t.init = e.init), !t.did && e.did && (t.did = `${e.did}`), typeof e.started == "number" && (t.started = e.started), t.ignoreDuration)
    t.duration = void 0;
  else if (typeof e.duration == "number")
    t.duration = e.duration;
  else {
    var r = t.timestamp - t.started;
    t.duration = r >= 0 ? r : 0;
  }
  e.release && (t.release = e.release), e.environment && (t.environment = e.environment), !t.ipAddress && e.ipAddress && (t.ipAddress = e.ipAddress), !t.userAgent && e.userAgent && (t.userAgent = e.userAgent), typeof e.errors == "number" && (t.errors = e.errors), e.status && (t.status = e.status);
}
function Ev(t, e) {
  let r = {};
  e ? r = { status: e } : t.status === "ok" && (r = { status: "exited" }), li(t, r);
}
function Ov(t) {
  return Ba({
    sid: `${t.sid}`,
    init: t.init,
    started: new Date(t.started * 1e3).toISOString(),
    timestamp: new Date(t.timestamp * 1e3).toISOString(),
    status: t.status,
    errors: t.errors,
    did: typeof t.did == "number" || typeof t.did == "string" ? `${t.did}` : void 0,
    duration: t.duration,
    attrs: {
      release: t.release,
      environment: t.environment,
      ip_address: t.ipAddress,
      user_agent: t.userAgent
    }
  });
}
var sc = 100;
class qt {
  constructor() {
    this._notifyingListeners = !1, this._scopeListeners = [], this._eventProcessors = [], this._breadcrumbs = [], this._attachments = [], this._user = {}, this._tags = {}, this._extra = {}, this._contexts = {}, this._sdkProcessingMetadata = {};
  }
  static clone(e) {
    var r = new qt();
    return e && (r._breadcrumbs = [...e._breadcrumbs], r._tags = { ...e._tags }, r._extra = { ...e._extra }, r._contexts = { ...e._contexts }, r._user = e._user, r._level = e._level, r._span = e._span, r._session = e._session, r._transactionName = e._transactionName, r._fingerprint = e._fingerprint, r._eventProcessors = [...e._eventProcessors], r._requestSession = e._requestSession, r._attachments = [...e._attachments]), r;
  }
  addScopeListener(e) {
    this._scopeListeners.push(e);
  }
  addEventProcessor(e) {
    return this._eventProcessors.push(e), this;
  }
  setUser(e) {
    return this._user = e || {}, this._session && li(this._session, { user: e }), this._notifyScopeListeners(), this;
  }
  getUser() {
    return this._user;
  }
  getRequestSession() {
    return this._requestSession;
  }
  setRequestSession(e) {
    return this._requestSession = e, this;
  }
  setTags(e) {
    return this._tags = {
      ...this._tags,
      ...e
    }, this._notifyScopeListeners(), this;
  }
  setTag(e, r) {
    return this._tags = { ...this._tags, [e]: r }, this._notifyScopeListeners(), this;
  }
  setExtras(e) {
    return this._extra = {
      ...this._extra,
      ...e
    }, this._notifyScopeListeners(), this;
  }
  setExtra(e, r) {
    return this._extra = { ...this._extra, [e]: r }, this._notifyScopeListeners(), this;
  }
  setFingerprint(e) {
    return this._fingerprint = e, this._notifyScopeListeners(), this;
  }
  setLevel(e) {
    return this._level = e, this._notifyScopeListeners(), this;
  }
  setTransactionName(e) {
    return this._transactionName = e, this._notifyScopeListeners(), this;
  }
  setContext(e, r) {
    return r === null ? delete this._contexts[e] : this._contexts = { ...this._contexts, [e]: r }, this._notifyScopeListeners(), this;
  }
  setSpan(e) {
    return this._span = e, this._notifyScopeListeners(), this;
  }
  getSpan() {
    return this._span;
  }
  getTransaction() {
    var e = this.getSpan();
    return e && e.transaction;
  }
  setSession(e) {
    return e ? this._session = e : delete this._session, this._notifyScopeListeners(), this;
  }
  getSession() {
    return this._session;
  }
  update(e) {
    if (!e)
      return this;
    if (typeof e == "function") {
      var r = e(this);
      return r instanceof qt ? r : this;
    }
    return e instanceof qt ? (this._tags = { ...this._tags, ...e._tags }, this._extra = { ...this._extra, ...e._extra }, this._contexts = { ...this._contexts, ...e._contexts }, e._user && Object.keys(e._user).length && (this._user = e._user), e._level && (this._level = e._level), e._fingerprint && (this._fingerprint = e._fingerprint), e._requestSession && (this._requestSession = e._requestSession)) : ai(e) && (e = e, this._tags = { ...this._tags, ...e.tags }, this._extra = { ...this._extra, ...e.extra }, this._contexts = { ...this._contexts, ...e.contexts }, e.user && (this._user = e.user), e.level && (this._level = e.level), e.fingerprint && (this._fingerprint = e.fingerprint), e.requestSession && (this._requestSession = e.requestSession)), this;
  }
  clear() {
    return this._breadcrumbs = [], this._tags = {}, this._extra = {}, this._user = {}, this._contexts = {}, this._level = void 0, this._transactionName = void 0, this._fingerprint = void 0, this._requestSession = void 0, this._span = void 0, this._session = void 0, this._notifyScopeListeners(), this._attachments = [], this;
  }
  addBreadcrumb(e, r) {
    var i = typeof r == "number" ? Math.min(r, sc) : sc;
    if (i <= 0)
      return this;
    var o = {
      timestamp: vo(),
      ...e
    };
    return this._breadcrumbs = [...this._breadcrumbs, o].slice(-i), this._notifyScopeListeners(), this;
  }
  clearBreadcrumbs() {
    return this._breadcrumbs = [], this._notifyScopeListeners(), this;
  }
  addAttachment(e) {
    return this._attachments.push(e), this;
  }
  getAttachments() {
    return this._attachments;
  }
  clearAttachments() {
    return this._attachments = [], this;
  }
  applyToEvent(e, r = {}) {
    if (this._extra && Object.keys(this._extra).length && (e.extra = { ...this._extra, ...e.extra }), this._tags && Object.keys(this._tags).length && (e.tags = { ...this._tags, ...e.tags }), this._user && Object.keys(this._user).length && (e.user = { ...this._user, ...e.user }), this._contexts && Object.keys(this._contexts).length && (e.contexts = { ...this._contexts, ...e.contexts }), this._level && (e.level = this._level), this._transactionName && (e.transaction = this._transactionName), this._span) {
      e.contexts = { trace: this._span.getTraceContext(), ...e.contexts };
      var i = this._span.transaction && this._span.transaction.name;
      i && (e.tags = { transaction: i, ...e.tags });
    }
    return this._applyFingerprint(e), e.breadcrumbs = [...e.breadcrumbs || [], ...this._breadcrumbs], e.breadcrumbs = e.breadcrumbs.length > 0 ? e.breadcrumbs : void 0, e.sdkProcessingMetadata = { ...e.sdkProcessingMetadata, ...this._sdkProcessingMetadata }, this._notifyEventProcessors([...Gh(), ...this._eventProcessors], e, r);
  }
  setSDKProcessingMetadata(e) {
    return this._sdkProcessingMetadata = { ...this._sdkProcessingMetadata, ...e }, this;
  }
  _notifyEventProcessors(e, r, i, o = 0) {
    return new nt((p, g) => {
      var a = e[o];
      if (r === null || typeof a != "function")
        p(r);
      else {
        var n = a({ ...r }, i);
        (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && a.id && n === null && Te.log(`Event processor "${a.id}" dropped event`), Ra(n) ? n.then((u) => this._notifyEventProcessors(e, u, i, o + 1).then(p)).then(null, g) : this._notifyEventProcessors(e, n, i, o + 1).then(p).then(null, g);
      }
    });
  }
  _notifyScopeListeners() {
    this._notifyingListeners || (this._notifyingListeners = !0, this._scopeListeners.forEach((e) => {
      e(this);
    }), this._notifyingListeners = !1);
  }
  _applyFingerprint(e) {
    e.fingerprint = e.fingerprint ? Hh(e.fingerprint) : [], this._fingerprint && (e.fingerprint = e.fingerprint.concat(this._fingerprint)), e.fingerprint && !e.fingerprint.length && delete e.fingerprint;
  }
}
function Gh() {
  return Da("globalEventProcessors", () => []);
}
function Na(t) {
  Gh().push(t);
}
var Va = 4, Pv = 100;
class Qi {
  __init() {
    this._stack = [{}];
  }
  constructor(e, r = new qt(), i = Va) {
    this._version = i, Qi.prototype.__init.call(this), this.getStackTop().scope = r, e && this.bindClient(e);
  }
  isOlderThan(e) {
    return this._version < e;
  }
  bindClient(e) {
    var r = this.getStackTop();
    r.client = e, e && e.setupIntegrations && e.setupIntegrations();
  }
  pushScope() {
    var e = qt.clone(this.getScope());
    return this.getStack().push({
      client: this.getClient(),
      scope: e
    }), e;
  }
  popScope() {
    return this.getStack().length <= 1 ? !1 : !!this.getStack().pop();
  }
  withScope(e) {
    var r = this.pushScope();
    try {
      e(r);
    } finally {
      this.popScope();
    }
  }
  getClient() {
    return this.getStackTop().client;
  }
  getScope() {
    return this.getStackTop().scope;
  }
  getStack() {
    return this._stack;
  }
  getStackTop() {
    return this._stack[this._stack.length - 1];
  }
  captureException(e, r) {
    var i = this._lastEventId = r && r.event_id ? r.event_id : Zr(), o = new Error("Sentry syntheticException");
    return this._withClient((p, g) => {
      p.captureException(
        e,
        {
          originalException: e,
          syntheticException: o,
          ...r,
          event_id: i
        },
        g
      );
    }), i;
  }
  captureMessage(e, r, i) {
    var o = this._lastEventId = i && i.event_id ? i.event_id : Zr(), p = new Error(e);
    return this._withClient((g, a) => {
      g.captureMessage(
        e,
        r,
        {
          originalException: e,
          syntheticException: p,
          ...i,
          event_id: o
        },
        a
      );
    }), o;
  }
  captureEvent(e, r) {
    var i = r && r.event_id ? r.event_id : Zr();
    return e.type !== "transaction" && (this._lastEventId = i), this._withClient((o, p) => {
      o.captureEvent(e, { ...r, event_id: i }, p);
    }), i;
  }
  lastEventId() {
    return this._lastEventId;
  }
  addBreadcrumb(e, r) {
    const { scope: i, client: o } = this.getStackTop();
    if (!i || !o)
      return;
    const { beforeBreadcrumb: p = null, maxBreadcrumbs: g = Pv } = o.getOptions && o.getOptions() || {};
    if (!(g <= 0)) {
      var a = vo(), n = { timestamp: a, ...e }, u = p ? zh(() => p(n, r)) : n;
      u !== null && i.addBreadcrumb(u, g);
    }
  }
  setUser(e) {
    var r = this.getScope();
    r && r.setUser(e);
  }
  setTags(e) {
    var r = this.getScope();
    r && r.setTags(e);
  }
  setExtras(e) {
    var r = this.getScope();
    r && r.setExtras(e);
  }
  setTag(e, r) {
    var i = this.getScope();
    i && i.setTag(e, r);
  }
  setExtra(e, r) {
    var i = this.getScope();
    i && i.setExtra(e, r);
  }
  setContext(e, r) {
    var i = this.getScope();
    i && i.setContext(e, r);
  }
  configureScope(e) {
    const { scope: r, client: i } = this.getStackTop();
    r && i && e(r);
  }
  run(e) {
    var r = ac(this);
    try {
      e(this);
    } finally {
      ac(r);
    }
  }
  getIntegration(e) {
    var r = this.getClient();
    if (!r)
      return null;
    try {
      return r.getIntegration(e);
    } catch {
      return (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.warn(`Cannot retrieve integration ${e.id} from the current Hub`), null;
    }
  }
  startTransaction(e, r) {
    return this._callExtensionMethod("startTransaction", e, r);
  }
  traceHeaders() {
    return this._callExtensionMethod("traceHeaders");
  }
  captureSession(e = !1) {
    if (e)
      return this.endSession();
    this._sendSessionUpdate();
  }
  endSession() {
    var e = this.getStackTop(), r = e && e.scope, i = r && r.getSession();
    i && Ev(i), this._sendSessionUpdate(), r && r.setSession();
  }
  startSession(e) {
    const { scope: r, client: i } = this.getStackTop(), { release: o, environment: p } = i && i.getOptions() || {};
    var g = Ve();
    const { userAgent: a } = g.navigator || {};
    var n = kv({
      release: o,
      environment: p,
      ...r && { user: r.getUser() },
      ...a && { userAgent: a },
      ...e
    });
    if (r) {
      var u = r.getSession && r.getSession();
      u && u.status === "ok" && li(u, { status: "exited" }), this.endSession(), r.setSession(n);
    }
    return n;
  }
  shouldSendDefaultPii() {
    var e = this.getClient(), r = e && e.getOptions();
    return Boolean(r && r.sendDefaultPii);
  }
  _sendSessionUpdate() {
    const { scope: e, client: r } = this.getStackTop();
    if (!!e) {
      var i = e.getSession();
      i && r && r.captureSession && r.captureSession(i);
    }
  }
  _withClient(e) {
    const { scope: r, client: i } = this.getStackTop();
    i && e(i, r);
  }
  _callExtensionMethod(e, ...r) {
    var i = yo(), o = i.__SENTRY__;
    if (o && o.extensions && typeof o.extensions[e] == "function")
      return o.extensions[e].apply(this, r);
    (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.warn(`Extension method ${e} couldn't be found, doing nothing.`);
  }
}
function yo() {
  var t = Ve();
  return t.__SENTRY__ = t.__SENTRY__ || {
    extensions: {},
    hub: void 0
  }, t;
}
function ac(t) {
  var e = yo(), r = Ut(e);
  return $a(e, t), r;
}
function Xe() {
  var t = yo();
  return (!qh(t) || Ut(t).isOlderThan(Va)) && $a(t, new Qi()), Uh() ? Mv(t) : Ut(t);
}
function Mv(t) {
  try {
    var e = yo().__SENTRY__, r = e && e.extensions && e.extensions.domain && e.extensions.domain.active;
    if (!r)
      return Ut(t);
    if (!qh(r) || Ut(r).isOlderThan(Va)) {
      var i = Ut(t).getStackTop();
      $a(r, new Qi(i.client, qt.clone(i.scope)));
    }
    return Ut(r);
  } catch {
    return Ut(t);
  }
}
function qh(t) {
  return !!(t && t.__SENTRY__ && t.__SENTRY__.hub);
}
function Ut(t) {
  return Da("hub", () => new Qi(), t);
}
function $a(t, e) {
  if (!t)
    return !1;
  var r = t.__SENTRY__ = t.__SENTRY__ || {};
  return r.hub = e, !0;
}
function Av(t, e) {
  return Xe().captureException(t, { captureContext: e });
}
function Dv(t) {
  Xe().withScope(t);
}
var Iv = "7";
function Rv(t) {
  var e = t.protocol ? `${t.protocol}:` : "", r = t.port ? `:${t.port}` : "";
  return `${e}//${t.host}${r}${t.path ? `/${t.path}` : ""}/api/`;
}
function Lv(t) {
  return `${Rv(t)}${t.projectId}/envelope/`;
}
function Fv(t, e) {
  return Bm({
    sentry_key: t.publicKey,
    sentry_version: Iv,
    ...e && { sentry_client: `${e.name}/${e.version}` }
  });
}
function Kh(t, e = {}) {
  var r = typeof e == "string" ? e : e.tunnel, i = typeof e == "string" || !e._metadata ? void 0 : e._metadata.sdk;
  return r || `${Lv(t)}?${Fv(t, i)}`;
}
function Zh(t) {
  if (!t || !t.sdk)
    return;
  const { name: e, version: r } = t.sdk;
  return { name: e, version: r };
}
function zv(t, e) {
  return e && (t.sdk = t.sdk || {}, t.sdk.name = t.sdk.name || e.name, t.sdk.version = t.sdk.version || e.version, t.sdk.integrations = [...t.sdk.integrations || [], ...e.integrations || []], t.sdk.packages = [...t.sdk.packages || [], ...e.packages || []]), t;
}
function jv(t, e, r, i) {
  var o = Zh(r), p = {
    sent_at: new Date().toISOString(),
    ...o && { sdk: o },
    ...!!i && { dsn: La(e) }
  }, g = "aggregates" in t ? [{ type: "sessions" }, t] : [{ type: "session" }, t];
  return bo(p, [g]);
}
function Bv(t, e, r, i) {
  var o = Zh(r), p = t.type || "event";
  zv(t, r && r.sdk);
  var g = Nv(t, o, i, e);
  delete t.sdkProcessingMetadata;
  var a = [{ type: p }, t];
  return bo(g, [a]);
}
function Nv(t, e, r, i) {
  var o = t.sdkProcessingMetadata && t.sdkProcessingMetadata.dynamicSamplingContext;
  return {
    event_id: t.event_id,
    sent_at: new Date().toISOString(),
    ...e && { sdk: e },
    ...!!r && { dsn: La(i) },
    ...t.type === "transaction" && o && {
      trace: Ba({ ...o })
    }
  };
}
var lc = [];
function Vv(t) {
  var e = {};
  return t.forEach((r) => {
    const { name: i } = r;
    var o = e[i];
    o && !o.isDefaultInstance && r.isDefaultInstance || (e[i] = r);
  }), Object.values(e);
}
function $v(t) {
  var e = t.defaultIntegrations || [], r = t.integrations;
  e.forEach((g) => {
    g.isDefaultInstance = !0;
  });
  let i;
  Array.isArray(r) ? i = [...e, ...r] : typeof r == "function" ? i = Hh(r(e)) : i = e;
  var o = Vv(i), p = o.findIndex((g) => g.name === "Debug");
  if (p !== -1) {
    const [g] = o.splice(p, 1);
    o.push(g);
  }
  return o;
}
function Hv(t) {
  var e = {};
  return t.forEach((r) => {
    e[r.name] = r, lc.indexOf(r.name) === -1 && (r.setupOnce(Na, Xe), lc.push(r.name), (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.log(`Integration installed: ${r.name}`));
  }), e;
}
var cc = "Not capturing exception because it's already been captured.";
class Gr {
  __init() {
    this._integrations = {};
  }
  __init2() {
    this._integrationsInitialized = !1;
  }
  __init3() {
    this._numProcessing = 0;
  }
  __init4() {
    this._outcomes = {};
  }
  constructor(e) {
    if (Gr.prototype.__init.call(this), Gr.prototype.__init2.call(this), Gr.prototype.__init3.call(this), Gr.prototype.__init4.call(this), this._options = e, e.dsn) {
      this._dsn = Fm(e.dsn);
      var r = Kh(this._dsn, e);
      this._transport = e.transport({
        recordDroppedEvent: this.recordDroppedEvent.bind(this),
        ...e.transportOptions,
        url: r
      });
    } else
      (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.warn("No DSN provided, client will not do anything.");
  }
  captureException(e, r, i) {
    if (rc(e)) {
      (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.log(cc);
      return;
    }
    let o = r && r.event_id;
    return this._process(
      this.eventFromException(e, r).then((p) => this._captureEvent(p, r, i)).then((p) => {
        o = p;
      })
    ), o;
  }
  captureMessage(e, r, i, o) {
    let p = i && i.event_id;
    var g = Lh(e) ? this.eventFromMessage(String(e), r, i) : this.eventFromException(e, i);
    return this._process(
      g.then((a) => this._captureEvent(a, i, o)).then((a) => {
        p = a;
      })
    ), p;
  }
  captureEvent(e, r, i) {
    if (r && r.originalException && rc(r.originalException)) {
      (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.log(cc);
      return;
    }
    let o = r && r.event_id;
    return this._process(
      this._captureEvent(e, r, i).then((p) => {
        o = p;
      })
    ), o;
  }
  captureSession(e) {
    if (!this._isEnabled()) {
      (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.warn("SDK not enabled, will not capture session.");
      return;
    }
    typeof e.release != "string" ? (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.warn("Discarded session because of missing or non-string release") : (this.sendSession(e), li(e, { init: !1 }));
  }
  getDsn() {
    return this._dsn;
  }
  getOptions() {
    return this._options;
  }
  getTransport() {
    return this._transport;
  }
  flush(e) {
    var r = this._transport;
    return r ? this._isClientDoneProcessing(e).then((i) => r.flush(e).then((o) => i && o)) : Cr(!0);
  }
  close(e) {
    return this.flush(e).then((r) => (this.getOptions().enabled = !1, r));
  }
  setupIntegrations() {
    this._isEnabled() && !this._integrationsInitialized && (this._integrations = Hv(this._options.integrations), this._integrationsInitialized = !0);
  }
  getIntegrationById(e) {
    return this._integrations[e];
  }
  getIntegration(e) {
    try {
      return this._integrations[e.id] || null;
    } catch {
      return (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.warn(`Cannot retrieve integration ${e.id} from the current Client`), null;
    }
  }
  sendEvent(e, r = {}) {
    if (this._dsn) {
      let o = Bv(e, this._dsn, this._options._metadata, this._options.tunnel);
      for (var i of r.attachments || [])
        o = mv(
          o,
          bv(
            i,
            this._options.transportOptions && this._options.transportOptions.textEncoder
          )
        );
      this._sendEnvelope(o);
    }
  }
  sendSession(e) {
    if (this._dsn) {
      var r = jv(e, this._dsn, this._options._metadata, this._options.tunnel);
      this._sendEnvelope(r);
    }
  }
  recordDroppedEvent(e, r) {
    if (this._options.sendClientReports) {
      var i = `${e}:${r}`;
      (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.log(`Adding outcome: "${i}"`), this._outcomes[i] = this._outcomes[i] + 1 || 1;
    }
  }
  _updateSessionFromEvent(e, r) {
    let i = !1, o = !1;
    var p = r.exception && r.exception.values;
    if (p) {
      o = !0;
      for (var g of p) {
        var a = g.mechanism;
        if (a && a.handled === !1) {
          i = !0;
          break;
        }
      }
    }
    var n = e.status === "ok", u = n && e.errors === 0 || n && i;
    u && (li(e, {
      ...i && { status: "crashed" },
      errors: e.errors || Number(o || i)
    }), this.captureSession(e));
  }
  _isClientDoneProcessing(e) {
    return new nt((r) => {
      let i = 0;
      var o = 1, p = setInterval(() => {
        this._numProcessing == 0 ? (clearInterval(p), r(!0)) : (i += o, e && i >= e && (clearInterval(p), r(!1)));
      }, o);
    });
  }
  _isEnabled() {
    return this.getOptions().enabled !== !1 && this._dsn !== void 0;
  }
  _prepareEvent(e, r, i) {
    const { normalizeDepth: o = 3, normalizeMaxBreadth: p = 1e3 } = this.getOptions();
    var g = {
      ...e,
      event_id: e.event_id || r.event_id || Zr(),
      timestamp: e.timestamp || vo()
    };
    this._applyClientOptions(g), this._applyIntegrationsMetadata(g);
    let a = i;
    r.captureContext && (a = qt.clone(a).update(r.captureContext));
    let n = Cr(g);
    if (a) {
      var u = [...r.attachments || [], ...a.getAttachments()];
      u.length && (r.attachments = u), n = a.applyToEvent(g, r);
    }
    return n.then((h) => typeof o == "number" && o > 0 ? this._normalizeEvent(h, o, p) : h);
  }
  _normalizeEvent(e, r, i) {
    if (!e)
      return null;
    var o = {
      ...e,
      ...e.breadcrumbs && {
        breadcrumbs: e.breadcrumbs.map((p) => ({
          ...p,
          ...p.data && {
            data: vr(p.data, r, i)
          }
        }))
      },
      ...e.user && {
        user: vr(e.user, r, i)
      },
      ...e.contexts && {
        contexts: vr(e.contexts, r, i)
      },
      ...e.extra && {
        extra: vr(e.extra, r, i)
      }
    };
    return e.contexts && e.contexts.trace && o.contexts && (o.contexts.trace = e.contexts.trace, e.contexts.trace.data && (o.contexts.trace.data = vr(e.contexts.trace.data, r, i))), e.spans && (o.spans = e.spans.map((p) => (p.data && (p.data = vr(p.data, r, i)), p))), o;
  }
  _applyClientOptions(e) {
    var r = this.getOptions();
    const { environment: i, release: o, dist: p, maxValueLength: g = 250 } = r;
    "environment" in e || (e.environment = "environment" in r ? i : "production"), e.release === void 0 && o !== void 0 && (e.release = o), e.dist === void 0 && p !== void 0 && (e.dist = p), e.message && (e.message = Ci(e.message, g));
    var a = e.exception && e.exception.values && e.exception.values[0];
    a && a.value && (a.value = Ci(a.value, g));
    var n = e.request;
    n && n.url && (n.url = Ci(n.url, g));
  }
  _applyIntegrationsMetadata(e) {
    var r = Object.keys(this._integrations);
    r.length > 0 && (e.sdk = e.sdk || {}, e.sdk.integrations = [...e.sdk.integrations || [], ...r]);
  }
  _captureEvent(e, r = {}, i) {
    return this._processEvent(e, r, i).then(
      (o) => o.event_id,
      (o) => {
        if (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) {
          var p = o;
          p.logLevel === "log" ? Te.log(p.message) : Te.warn(p);
        }
      }
    );
  }
  _processEvent(e, r, i) {
    const { beforeSend: o, sampleRate: p } = this.getOptions();
    if (!this._isEnabled())
      return As(new Ke("SDK not enabled, will not capture event.", "log"));
    var g = e.type === "transaction";
    return !g && typeof p == "number" && Math.random() > p ? (this.recordDroppedEvent("sample_rate", "error"), As(
      new Ke(
        `Discarding event because it's not included in the random sample (sampling rate = ${p})`,
        "log"
      )
    )) : this._prepareEvent(e, r, i).then((a) => {
      if (a === null)
        throw this.recordDroppedEvent("event_processor", e.type || "error"), new Ke("An event processor returned null, will not send event.", "log");
      var n = r.data && r.data.__sentry__ === !0;
      if (n || g || !o)
        return a;
      var u = o(a, r);
      return Uv(u);
    }).then((a) => {
      if (a === null)
        throw this.recordDroppedEvent("before_send", e.type || "error"), new Ke("`beforeSend` returned `null`, will not send event.", "log");
      var n = i && i.getSession();
      !g && n && this._updateSessionFromEvent(n, a);
      var u = a.transaction_info;
      if (g && u && a.transaction !== e.transaction) {
        var h = "custom";
        a.transaction_info = {
          ...u,
          source: h,
          changes: [
            ...u.changes,
            {
              source: h,
              timestamp: a.timestamp,
              propagations: u.propagations
            }
          ]
        };
      }
      return this.sendEvent(a, r), a;
    }).then(null, (a) => {
      throw a instanceof Ke ? a : (this.captureException(a, {
        data: {
          __sentry__: !0
        },
        originalException: a
      }), new Ke(
        `Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.
Reason: ${a}`
      ));
    });
  }
  _process(e) {
    this._numProcessing += 1, e.then(
      (r) => (this._numProcessing -= 1, r),
      (r) => (this._numProcessing -= 1, r)
    );
  }
  _sendEnvelope(e) {
    this._transport && this._dsn ? this._transport.send(e).then(null, (r) => {
      (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.error("Error while sending event:", r);
    }) : (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.error("Transport disabled");
  }
  _clearOutcomes() {
    var e = this._outcomes;
    return this._outcomes = {}, Object.keys(e).map((r) => {
      const [i, o] = r.split(":");
      return {
        reason: i,
        category: o,
        quantity: e[r]
      };
    });
  }
}
function Uv(t) {
  var e = "`beforeSend` method has to return `null` or a valid event.";
  if (Ra(t))
    return t.then(
      (r) => {
        if (!(ai(r) || r === null))
          throw new Ke(e);
        return r;
      },
      (r) => {
        throw new Ke(`beforeSend rejected with ${r}`);
      }
    );
  if (!(ai(t) || t === null))
    throw new Ke(e);
  return t;
}
function Wv(t, e) {
  e.debug === !0 && (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__ ? Te.enable() : console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle."));
  var r = Xe(), i = r.getScope();
  i && i.update(e.initialScope);
  var o = new t(e);
  r.bindClient(o);
}
var Yv = 30;
function Jh(t, e, r = hv(t.bufferSize || Yv)) {
  let i = {};
  var o = (g) => r.drain(g);
  function p(g) {
    var a = [];
    if (nc(g, (s, l) => {
      var c = oc(l);
      Cv(i, c) ? t.recordDroppedEvent("ratelimit_backoff", c) : a.push(s);
    }), a.length === 0)
      return Cr();
    var n = bo(g[0], a), u = (s) => {
      nc(n, (l, c) => {
        t.recordDroppedEvent(s, oc(c));
      });
    }, h = () => e({ body: Xh(n, t.textEncoder) }).then(
      (s) => {
        s.statusCode !== void 0 && (s.statusCode < 200 || s.statusCode >= 300) && (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.warn(`Sentry responded with status code ${s.statusCode} to sent event.`), i = Tv(i, s);
      },
      (s) => {
        (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.error("Failed while sending event:", s), u("network_error");
      }
    );
    return r.add(h).then(
      (s) => s,
      (s) => {
        if (s instanceof Ke)
          return (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.error("Skipped sending event because buffer is full."), u("queue_overflow"), Cr();
        throw s;
      }
    );
  }
  return {
    send: p,
    flush: o
  };
}
var Hn = "7.14.0";
let uc;
class Li {
  constructor() {
    Li.prototype.__init.call(this);
  }
  static __initStatic() {
    this.id = "FunctionToString";
  }
  __init() {
    this.name = Li.id;
  }
  setupOnce() {
    uc = Function.prototype.toString, Function.prototype.toString = function(...e) {
      var r = ja(this) || this;
      return uc.apply(r, e);
    };
  }
}
Li.__initStatic();
var Xv = [/^Script error\.?$/, /^Javascript error: Script error\.? on line 0$/];
class Jr {
  static __initStatic() {
    this.id = "InboundFilters";
  }
  __init() {
    this.name = Jr.id;
  }
  constructor(e = {}) {
    this._options = e, Jr.prototype.__init.call(this);
  }
  setupOnce(e, r) {
    var i = (o) => {
      var p = r();
      if (p) {
        var g = p.getIntegration(Jr);
        if (g) {
          var a = p.getClient(), n = a ? a.getOptions() : {}, u = Gv(g._options, n);
          return qv(o, u) ? null : o;
        }
      }
      return o;
    };
    i.id = this.name, e(i);
  }
}
Jr.__initStatic();
function Gv(t = {}, e = {}) {
  return {
    allowUrls: [...t.allowUrls || [], ...e.allowUrls || []],
    denyUrls: [...t.denyUrls || [], ...e.denyUrls || []],
    ignoreErrors: [
      ...t.ignoreErrors || [],
      ...e.ignoreErrors || [],
      ...Xv
    ],
    ignoreInternal: t.ignoreInternal !== void 0 ? t.ignoreInternal : !0
  };
}
function qv(t, e) {
  return e.ignoreInternal && e0(t) ? ((typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.warn(`Event dropped due to being internal Sentry Error.
Event: ${wr(t)}`), !0) : Kv(t, e.ignoreErrors) ? ((typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.warn(
    `Event dropped due to being matched by \`ignoreErrors\` option.
Event: ${wr(t)}`
  ), !0) : Zv(t, e.denyUrls) ? ((typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.warn(
    `Event dropped due to being matched by \`denyUrls\` option.
Event: ${wr(
      t
    )}.
Url: ${Un(t)}`
  ), !0) : Jv(t, e.allowUrls) ? !1 : ((typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.warn(
    `Event dropped due to not being matched by \`allowUrls\` option.
Event: ${wr(
      t
    )}.
Url: ${Un(t)}`
  ), !0);
}
function Kv(t, e) {
  return !e || !e.length ? !1 : Qv(t).some(
    (r) => e.some((i) => Fa(r, i))
  );
}
function Zv(t, e) {
  if (!e || !e.length)
    return !1;
  var r = Un(t);
  return r ? e.some((i) => Fa(r, i)) : !1;
}
function Jv(t, e) {
  if (!e || !e.length)
    return !0;
  var r = Un(t);
  return r ? e.some((i) => Fa(r, i)) : !0;
}
function Qv(t) {
  if (t.message)
    return [t.message];
  if (t.exception)
    try {
      const { type: e = "", value: r = "" } = t.exception.values && t.exception.values[0] || {};
      return [`${r}`, `${e}: ${r}`];
    } catch {
      return (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.error(`Cannot extract message for event ${wr(t)}`), [];
    }
  return [];
}
function e0(t) {
  try {
    return t.exception.values[0].type === "SentryError";
  } catch {
  }
  return !1;
}
function t0(t = []) {
  for (let r = t.length - 1; r >= 0; r--) {
    var e = t[r];
    if (e && e.filename !== "<anonymous>" && e.filename !== "[native code]")
      return e.filename || null;
  }
  return null;
}
function Un(t) {
  try {
    let e;
    try {
      e = t.exception.values[0].stacktrace.frames;
    } catch {
    }
    return e ? t0(e) : null;
  } catch {
    return (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.error(`Cannot extract url for event ${wr(t)}`), null;
  }
}
function Qh(t, e) {
  var r = Ha(t, e), i = {
    type: e && e.name,
    value: o0(e)
  };
  return r.length && (i.stacktrace = { frames: r }), i.type === void 0 && i.value === "" && (i.value = "Unrecoverable error caught"), i;
}
function r0(t, e, r, i) {
  var o = Xe(), p = o.getClient(), g = p && p.getOptions().normalizeDepth, a = {
    exception: {
      values: [
        {
          type: Ia(e) ? e.constructor.name : i ? "UnhandledRejection" : "Error",
          value: `Non-Error ${i ? "promise rejection" : "exception"} captured with keys: ${Nm(e)}`
        }
      ]
    },
    extra: {
      __serialized__: Wh(e, g)
    }
  };
  if (r) {
    var n = Ha(t, r);
    n.length && (a.exception.values[0].stacktrace = { frames: n });
  }
  return a;
}
function Qo(t, e) {
  return {
    exception: {
      values: [Qh(t, e)]
    }
  };
}
function Ha(t, e) {
  var r = e.stacktrace || e.stack || "", i = n0(e);
  try {
    return t(r, i);
  } catch {
  }
  return [];
}
var i0 = /Minified React error #\d+;/i;
function n0(t) {
  if (t) {
    if (typeof t.framesToPop == "number")
      return t.framesToPop;
    if (i0.test(t.message))
      return 1;
  }
  return 0;
}
function o0(t) {
  var e = t && t.message;
  return e ? e.error && typeof e.error.message == "string" ? e.error.message : e : "No error message";
}
function s0(t, e, r, i) {
  var o = r && r.syntheticException || void 0, p = Ua(t, e, o, i);
  return Ri(p), p.level = "error", r && r.event_id && (p.event_id = r.event_id), Cr(p);
}
function a0(t, e, r = "info", i, o) {
  var p = i && i.syntheticException || void 0, g = Rs(t, e, p, o);
  return g.level = r, i && i.event_id && (g.event_id = i.event_id), Cr(g);
}
function Ua(t, e, r, i, o) {
  let p;
  if (Rh(e) && e.error) {
    var g = e;
    return Qo(t, g.error);
  }
  if (ql(e) || Tm(e)) {
    var a = e;
    if ("stack" in e)
      p = Qo(t, e);
    else {
      var n = a.name || (ql(a) ? "DOMError" : "DOMException"), u = a.message ? `${n}: ${a.message}` : n;
      p = Rs(t, u, r, i), Ps(p, u);
    }
    return "code" in a && (p.tags = { ...p.tags, "DOMException.code": `${a.code}` }), p;
  }
  if (Ih(e))
    return Qo(t, e);
  if (ai(e) || Ia(e)) {
    var h = e;
    return p = r0(t, h, r, o), Ri(p, {
      synthetic: !0
    }), p;
  }
  return p = Rs(t, e, r, i), Ps(p, `${e}`, void 0), Ri(p, {
    synthetic: !0
  }), p;
}
function Rs(t, e, r, i) {
  var o = {
    message: e
  };
  if (i && r) {
    var p = Ha(t, r);
    p.length && (o.exception = {
      values: [{ value: e, stacktrace: { frames: p } }]
    });
  }
  return o;
}
var ef = "Breadcrumbs";
class Fi {
  static __initStatic() {
    this.id = ef;
  }
  __init() {
    this.name = Fi.id;
  }
  constructor(e) {
    Fi.prototype.__init.call(this), this.options = {
      console: !0,
      dom: !0,
      fetch: !0,
      history: !0,
      sentry: !0,
      xhr: !0,
      ...e
    };
  }
  setupOnce() {
    this.options.console && Ht("console", c0), this.options.dom && Ht("dom", l0(this.options.dom)), this.options.xhr && Ht("xhr", u0), this.options.fetch && Ht("fetch", h0), this.options.history && Ht("history", f0);
  }
}
Fi.__initStatic();
function l0(t) {
  function e(r) {
    let i, o = typeof t == "object" ? t.serializeAttribute : void 0;
    typeof o == "string" && (o = [o]);
    try {
      i = r.event.target ? ks(r.event.target, o) : ks(r.event, o);
    } catch {
      i = "<unknown>";
    }
    i.length !== 0 && Xe().addBreadcrumb(
      {
        category: `ui.${r.name}`,
        message: i
      },
      {
        event: r.event,
        name: r.name,
        global: r.global
      }
    );
  }
  return e;
}
function c0(t) {
  var e = {
    category: "console",
    data: {
      arguments: t.args,
      logger: "console"
    },
    level: dv(t.level),
    message: Zl(t.args, " ")
  };
  if (t.level === "assert")
    if (t.args[0] === !1)
      e.message = `Assertion failed: ${Zl(t.args.slice(1), " ") || "console.assert"}`, e.data.arguments = t.args.slice(1);
    else
      return;
  Xe().addBreadcrumb(e, {
    input: t.args,
    level: t.level
  });
}
function u0(t) {
  if (t.endTimestamp) {
    if (t.xhr.__sentry_own_request__)
      return;
    const { method: e, url: r, status_code: i, body: o } = t.xhr.__sentry_xhr__ || {};
    Xe().addBreadcrumb(
      {
        category: "xhr",
        data: {
          method: e,
          url: r,
          status_code: i
        },
        type: "http"
      },
      {
        xhr: t.xhr,
        input: o
      }
    );
    return;
  }
}
function h0(t) {
  !t.endTimestamp || t.fetchData.url.match(/sentry_key/) && t.fetchData.method === "POST" || (t.error ? Xe().addBreadcrumb(
    {
      category: "fetch",
      data: t.fetchData,
      level: "error",
      type: "http"
    },
    {
      data: t.error,
      input: t.args
    }
  ) : Xe().addBreadcrumb(
    {
      category: "fetch",
      data: {
        ...t.fetchData,
        status_code: t.response.status
      },
      type: "http"
    },
    {
      input: t.args,
      response: t.response
    }
  ));
}
function f0(t) {
  var e = Ve();
  let r = t.from, i = t.to;
  var o = Zo(e.location.href);
  let p = Zo(r);
  var g = Zo(i);
  p.path || (p = o), o.protocol === g.protocol && o.host === g.host && (i = g.relative), o.protocol === p.protocol && o.host === p.host && (r = p.relative), Xe().addBreadcrumb({
    category: "navigation",
    data: {
      from: r,
      to: i
    }
  });
}
var es = Ve();
class d0 extends Gr {
  constructor(e) {
    e._metadata = e._metadata || {}, e._metadata.sdk = e._metadata.sdk || {
      name: "sentry.javascript.browser",
      packages: [
        {
          name: "npm:@sentry/browser",
          version: Hn
        }
      ],
      version: Hn
    }, super(e), e.sendClientReports && es.document && es.document.addEventListener("visibilitychange", () => {
      es.document.visibilityState === "hidden" && this._flushOutcomes();
    });
  }
  eventFromException(e, r) {
    return s0(this._options.stackParser, e, r, this._options.attachStacktrace);
  }
  eventFromMessage(e, r = "info", i) {
    return a0(this._options.stackParser, e, r, i, this._options.attachStacktrace);
  }
  sendEvent(e, r) {
    var i = this.getIntegrationById(ef);
    i && i.options && i.options.sentry && Xe().addBreadcrumb(
      {
        category: `sentry.${e.type === "transaction" ? "transaction" : "event"}`,
        event_id: e.event_id,
        level: e.level,
        message: wr(e)
      },
      {
        event: e
      }
    ), super.sendEvent(e, r);
  }
  _prepareEvent(e, r, i) {
    return e.platform = e.platform || "javascript", super._prepareEvent(e, r, i);
  }
  _flushOutcomes() {
    var e = this._clearOutcomes();
    if (e.length === 0) {
      (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.log("No outcomes to send");
      return;
    }
    if (!this._dsn) {
      (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.log("No dsn provided, will not send outcomes");
      return;
    }
    (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.log("Sending outcomes:", e);
    var r = Kh(this._dsn, this._options), i = wv(e, this._options.tunnel && La(this._dsn));
    try {
      var o = Ve(), p = Object.prototype.toString.call(o && o.navigator) === "[object Navigator]", g = p && typeof o.navigator.sendBeacon == "function";
      if (g && !this._options.transportOptions) {
        var a = o.navigator.sendBeacon.bind(o.navigator);
        a(r, Xh(i));
      } else
        this._sendEnvelope(i);
    } catch (n) {
      (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.error(n);
    }
  }
}
var Br = Ve();
let wn;
function p0() {
  if (wn)
    return wn;
  if (Os(Br.fetch))
    return wn = Br.fetch.bind(Br);
  var t = Br.document;
  let e = Br.fetch;
  if (t && typeof t.createElement == "function")
    try {
      var r = t.createElement("iframe");
      r.hidden = !0, t.head.appendChild(r);
      var i = r.contentWindow;
      i && i.fetch && (e = i.fetch), t.head.removeChild(r);
    } catch (o) {
      (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ", o);
    }
  return wn = e.bind(Br);
}
function g0(t, e = p0()) {
  function r(i) {
    var o = {
      body: i.body,
      method: "POST",
      referrerPolicy: "origin",
      headers: t.headers,
      keepalive: i.body.length <= 65536,
      ...t.fetchOptions
    };
    return e(t.url, o).then((p) => ({
      statusCode: p.status,
      headers: {
        "x-sentry-rate-limits": p.headers.get("X-Sentry-Rate-Limits"),
        "retry-after": p.headers.get("Retry-After")
      }
    }));
  }
  return Jh(t, r);
}
var m0 = 4;
function v0(t) {
  function e(r) {
    return new nt((i, o) => {
      var p = new XMLHttpRequest();
      p.onerror = o, p.onreadystatechange = () => {
        p.readyState === m0 && i({
          statusCode: p.status,
          headers: {
            "x-sentry-rate-limits": p.getResponseHeader("X-Sentry-Rate-Limits"),
            "retry-after": p.getResponseHeader("Retry-After")
          }
        });
      }, p.open("POST", t.url);
      for (var g in t.headers)
        Object.prototype.hasOwnProperty.call(t.headers, g) && p.setRequestHeader(g, t.headers[g]);
      p.send(r.body);
    });
  }
  return Jh(t, e);
}
var wo = "?", b0 = 30, y0 = 40, w0 = 50;
function Wa(t, e, r, i) {
  var o = {
    filename: t,
    function: e,
    in_app: !0
  };
  return r !== void 0 && (o.lineno = r), i !== void 0 && (o.colno = i), o;
}
var x0 = /^\s*at (?:(.*\).*?|.*?) ?\((?:address at )?)?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i, _0 = /\((\S*)(?::(\d+))(?::(\d+))\)/, S0 = (t) => {
  var e = x0.exec(t);
  if (e) {
    var r = e[2] && e[2].indexOf("eval") === 0;
    if (r) {
      var i = _0.exec(e[2]);
      i && (e[2] = i[1], e[3] = i[2], e[4] = i[3]);
    }
    const [o, p] = tf(e[1] || wo, e[2]);
    return Wa(p, o, e[3] ? +e[3] : void 0, e[4] ? +e[4] : void 0);
  }
}, C0 = [b0, S0], T0 = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|safari-extension|safari-web-extension|capacitor)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i, k0 = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i, E0 = (t) => {
  var e = T0.exec(t);
  if (e) {
    var r = e[3] && e[3].indexOf(" > eval") > -1;
    if (r) {
      var i = k0.exec(e[3]);
      i && (e[1] = e[1] || "eval", e[3] = i[1], e[4] = i[2], e[5] = "");
    }
    let o = e[3], p = e[1] || wo;
    return [p, o] = tf(p, o), Wa(o, p, e[4] ? +e[4] : void 0, e[5] ? +e[5] : void 0);
  }
}, O0 = [w0, E0], P0 = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i, M0 = (t) => {
  var e = P0.exec(t);
  return e ? Wa(e[2], e[1] || wo, +e[3], e[4] ? +e[4] : void 0) : void 0;
}, A0 = [y0, M0], D0 = [C0, O0, A0], I0 = Nh(...D0), tf = (t, e) => {
  var r = t.indexOf("safari-extension") !== -1, i = t.indexOf("safari-web-extension") !== -1;
  return r || i ? [
    t.indexOf("@") !== -1 ? t.split("@")[0] : wo,
    r ? `safari-extension:${e}` : `safari-web-extension:${e}`
  ] : [t, e];
};
let Ls = 0;
function rf() {
  return Ls > 0;
}
function R0() {
  Ls += 1, setTimeout(() => {
    Ls -= 1;
  });
}
function ci(t, e = {}, r) {
  if (typeof t != "function")
    return t;
  try {
    var i = t.__sentry_wrapped__;
    if (i)
      return i;
    if (ja(t))
      return t;
  } catch {
    return t;
  }
  var o = function() {
    var a = Array.prototype.slice.call(arguments);
    try {
      r && typeof r == "function" && r.apply(this, arguments);
      var n = a.map((u) => ci(u, e));
      return t.apply(this, n);
    } catch (u) {
      throw R0(), Dv((h) => {
        h.addEventProcessor((s) => (e.mechanism && (Ps(s, void 0, void 0), Ri(s, e.mechanism)), s.extra = {
          ...s.extra,
          arguments: a
        }, s)), Av(u);
      }), u;
    }
  };
  try {
    for (var p in t)
      Object.prototype.hasOwnProperty.call(t, p) && (o[p] = t[p]);
  } catch {
  }
  jh(o, t), za(t, "__sentry_wrapped__", o);
  try {
    var g = Object.getOwnPropertyDescriptor(o, "name");
    g.configurable && Object.defineProperty(o, "name", {
      get() {
        return t.name;
      }
    });
  } catch {
  }
  return o;
}
class Kt {
  static __initStatic() {
    this.id = "GlobalHandlers";
  }
  __init() {
    this.name = Kt.id;
  }
  __init2() {
    this._installFunc = {
      onerror: L0,
      onunhandledrejection: F0
    };
  }
  constructor(e) {
    Kt.prototype.__init.call(this), Kt.prototype.__init2.call(this), this._options = {
      onerror: !0,
      onunhandledrejection: !0,
      ...e
    };
  }
  setupOnce() {
    Error.stackTraceLimit = 50;
    var e = this._options;
    for (var r in e) {
      var i = this._installFunc[r];
      i && e[r] && (B0(r), i(), this._installFunc[r] = void 0);
    }
  }
}
Kt.__initStatic();
function L0() {
  Ht(
    "error",
    (t) => {
      const [e, r, i] = sf();
      if (!e.getIntegration(Kt))
        return;
      const { msg: o, url: p, line: g, column: a, error: n } = t;
      if (!(rf() || n && n.__sentry_own_request__)) {
        var u = n === void 0 && si(o) ? j0(o, p, g, a) : nf(
          Ua(r, n || o, void 0, i, !1),
          p,
          g,
          a
        );
        u.level = "error", of(e, n, u, "onerror");
      }
    }
  );
}
function F0() {
  Ht(
    "unhandledrejection",
    (t) => {
      const [e, r, i] = sf();
      if (!e.getIntegration(Kt))
        return;
      let o = t;
      try {
        "reason" in t ? o = t.reason : "detail" in t && "reason" in t.detail && (o = t.detail.reason);
      } catch {
      }
      if (rf() || o && o.__sentry_own_request__)
        return !0;
      var p = Lh(o) ? z0(o) : Ua(r, o, void 0, i, !0);
      p.level = "error", of(e, o, p, "onunhandledrejection");
    }
  );
}
function z0(t) {
  return {
    exception: {
      values: [
        {
          type: "UnhandledRejection",
          value: `Non-Error promise rejection captured with value: ${String(t)}`
        }
      ]
    }
  };
}
function j0(t, e, r, i) {
  var o = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;
  let p = Rh(t) ? t.message : t, g = "Error";
  var a = p.match(o);
  a && (g = a[1], p = a[2]);
  var n = {
    exception: {
      values: [
        {
          type: g,
          value: p
        }
      ]
    }
  };
  return nf(n, e, r, i);
}
function nf(t, e, r, i) {
  var o = t.exception = t.exception || {}, p = o.values = o.values || [], g = p[0] = p[0] || {}, a = g.stacktrace = g.stacktrace || {}, n = a.frames = a.frames || [], u = isNaN(parseInt(i, 10)) ? void 0 : i, h = isNaN(parseInt(r, 10)) ? void 0 : r, s = si(e) && e.length > 0 ? e : Am();
  return n.length === 0 && n.push({
    colno: u,
    filename: s,
    function: "?",
    in_app: !0,
    lineno: h
  }), t;
}
function B0(t) {
  (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.log(`Global Handler attached: ${t}`);
}
function of(t, e, r, i) {
  Ri(r, {
    handled: !1,
    type: i
  }), t.captureEvent(r, {
    originalException: e
  });
}
function sf() {
  var t = Xe(), e = t.getClient(), r = e && e.getOptions() || {
    stackParser: () => [],
    attachStacktrace: !1
  };
  return [t, r.stackParser, r.attachStacktrace];
}
var N0 = [
  "EventTarget",
  "Window",
  "Node",
  "ApplicationCache",
  "AudioTrackList",
  "ChannelMergerNode",
  "CryptoOperation",
  "EventSource",
  "FileReader",
  "HTMLUnknownElement",
  "IDBDatabase",
  "IDBRequest",
  "IDBTransaction",
  "KeyOperation",
  "MediaController",
  "MessagePort",
  "ModalWindow",
  "Notification",
  "SVGElementInstance",
  "Screen",
  "TextTrack",
  "TextTrackCue",
  "TextTrackList",
  "WebSocket",
  "WebSocketWorker",
  "Worker",
  "XMLHttpRequest",
  "XMLHttpRequestEventTarget",
  "XMLHttpRequestUpload"
];
class zi {
  static __initStatic() {
    this.id = "TryCatch";
  }
  __init() {
    this.name = zi.id;
  }
  constructor(e) {
    zi.prototype.__init.call(this), this._options = {
      XMLHttpRequest: !0,
      eventTarget: !0,
      requestAnimationFrame: !0,
      setInterval: !0,
      setTimeout: !0,
      ...e
    };
  }
  setupOnce() {
    var e = Ve();
    this._options.setTimeout && Ze(e, "setTimeout", hc), this._options.setInterval && Ze(e, "setInterval", hc), this._options.requestAnimationFrame && Ze(e, "requestAnimationFrame", V0), this._options.XMLHttpRequest && "XMLHttpRequest" in e && Ze(XMLHttpRequest.prototype, "send", $0);
    var r = this._options.eventTarget;
    if (r) {
      var i = Array.isArray(r) ? r : N0;
      i.forEach(H0);
    }
  }
}
zi.__initStatic();
function hc(t) {
  return function(...e) {
    var r = e[0];
    return e[0] = ci(r, {
      mechanism: {
        data: { function: rr(t) },
        handled: !0,
        type: "instrument"
      }
    }), t.apply(this, e);
  };
}
function V0(t) {
  return function(e) {
    return t.apply(this, [
      ci(e, {
        mechanism: {
          data: {
            function: "requestAnimationFrame",
            handler: rr(t)
          },
          handled: !0,
          type: "instrument"
        }
      })
    ]);
  };
}
function $0(t) {
  return function(...e) {
    var r = this, i = ["onload", "onerror", "onprogress", "onreadystatechange"];
    return i.forEach((o) => {
      o in r && typeof r[o] == "function" && Ze(r, o, function(p) {
        var g = {
          mechanism: {
            data: {
              function: o,
              handler: rr(p)
            },
            handled: !0,
            type: "instrument"
          }
        }, a = ja(p);
        return a && (g.mechanism.data.handler = rr(a)), ci(p, g);
      });
    }), t.apply(this, e);
  };
}
function H0(t) {
  var e = Ve(), r = e[t] && e[t].prototype;
  !r || !r.hasOwnProperty || !r.hasOwnProperty("addEventListener") || (Ze(r, "addEventListener", function(i) {
    return function(o, p, g) {
      try {
        typeof p.handleEvent == "function" && (p.handleEvent = ci(p.handleEvent, {
          mechanism: {
            data: {
              function: "handleEvent",
              handler: rr(p),
              target: t
            },
            handled: !0,
            type: "instrument"
          }
        }));
      } catch {
      }
      return i.apply(this, [
        o,
        ci(p, {
          mechanism: {
            data: {
              function: "addEventListener",
              handler: rr(p),
              target: t
            },
            handled: !0,
            type: "instrument"
          }
        }),
        g
      ]);
    };
  }), Ze(
    r,
    "removeEventListener",
    function(i) {
      return function(o, p, g) {
        var a = p;
        try {
          var n = a && a.__sentry_wrapped__;
          n && i.call(this, o, n, g);
        } catch {
        }
        return i.call(this, o, a, g);
      };
    }
  ));
}
var U0 = "cause", W0 = 5;
class Qr {
  static __initStatic() {
    this.id = "LinkedErrors";
  }
  __init() {
    this.name = Qr.id;
  }
  constructor(e = {}) {
    Qr.prototype.__init.call(this), this._key = e.key || U0, this._limit = e.limit || W0;
  }
  setupOnce() {
    var e = Xe().getClient();
    !e || Na((r, i) => {
      var o = Xe().getIntegration(Qr);
      return o ? Y0(e.getOptions().stackParser, o._key, o._limit, r, i) : r;
    });
  }
}
Qr.__initStatic();
function Y0(t, e, r, i, o) {
  if (!i.exception || !i.exception.values || !o || !ar(o.originalException, Error))
    return i;
  var p = af(t, r, o.originalException, e);
  return i.exception.values = [...p, ...i.exception.values], i;
}
function af(t, e, r, i, o = []) {
  if (!ar(r[i], Error) || o.length + 1 >= e)
    return o;
  var p = Qh(t, r[i]);
  return af(t, e, r[i], i, [p, ...o]);
}
var fr = Ve();
class ei {
  constructor() {
    ei.prototype.__init.call(this);
  }
  static __initStatic() {
    this.id = "HttpContext";
  }
  __init() {
    this.name = ei.id;
  }
  setupOnce() {
    Na((e) => {
      if (Xe().getIntegration(ei)) {
        if (!fr.navigator && !fr.location && !fr.document)
          return e;
        var r = e.request && e.request.url || fr.location && fr.location.href;
        const { referrer: p } = fr.document || {}, { userAgent: g } = fr.navigator || {};
        var i = {
          ...e.request && e.request.headers,
          ...p && { Referer: p },
          ...g && { "User-Agent": g }
        }, o = { ...r && { url: r }, headers: i };
        return { ...e, request: o };
      }
      return e;
    });
  }
}
ei.__initStatic();
class ti {
  constructor() {
    ti.prototype.__init.call(this);
  }
  static __initStatic() {
    this.id = "Dedupe";
  }
  __init() {
    this.name = ti.id;
  }
  setupOnce(e, r) {
    var i = (o) => {
      var p = r().getIntegration(ti);
      if (p) {
        try {
          if (X0(o, p._previousEvent))
            return (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.warn("Event dropped due to being a duplicate of previously captured event."), null;
        } catch {
          return p._previousEvent = o;
        }
        return p._previousEvent = o;
      }
      return o;
    };
    i.id = this.name, e(i);
  }
}
ti.__initStatic();
function X0(t, e) {
  return e ? !!(G0(t, e) || q0(t, e)) : !1;
}
function G0(t, e) {
  var r = t.message, i = e.message;
  return !(!r && !i || r && !i || !r && i || r !== i || !cf(t, e) || !lf(t, e));
}
function q0(t, e) {
  var r = fc(e), i = fc(t);
  return !(!r || !i || r.type !== i.type || r.value !== i.value || !cf(t, e) || !lf(t, e));
}
function lf(t, e) {
  let r = dc(t), i = dc(e);
  if (!r && !i)
    return !0;
  if (r && !i || !r && i || (r = r, i = i, i.length !== r.length))
    return !1;
  for (let g = 0; g < i.length; g++) {
    var o = i[g], p = r[g];
    if (o.filename !== p.filename || o.lineno !== p.lineno || o.colno !== p.colno || o.function !== p.function)
      return !1;
  }
  return !0;
}
function cf(t, e) {
  let r = t.fingerprint, i = e.fingerprint;
  if (!r && !i)
    return !0;
  if (r && !i || !r && i)
    return !1;
  r = r, i = i;
  try {
    return r.join("") === i.join("");
  } catch {
    return !1;
  }
}
function fc(t) {
  return t.exception && t.exception.values && t.exception.values[0];
}
function dc(t) {
  var e = t.exception;
  if (e)
    try {
      return e.values[0].stacktrace.frames;
    } catch {
      return;
    }
}
var K0 = [
  new Jr(),
  new Li(),
  new zi(),
  new Fi(),
  new Kt(),
  new Qr(),
  new ti(),
  new ei()
];
function Z0(t = {}) {
  if (t.defaultIntegrations === void 0 && (t.defaultIntegrations = K0), t.release === void 0) {
    var e = Ve();
    e.SENTRY_RELEASE && e.SENTRY_RELEASE.id && (t.release = e.SENTRY_RELEASE.id);
  }
  t.autoSessionTracking === void 0 && (t.autoSessionTracking = !0), t.sendClientReports === void 0 && (t.sendClientReports = !0);
  var r = {
    ...t,
    stackParser: $m(t.stackParser || I0),
    integrations: $v(t),
    transport: t.transport || (Vh() ? g0 : v0)
  };
  Wv(d0, r), t.autoSessionTracking && J0();
}
function pc(t) {
  t.startSession({ ignoreDuration: !0 }), t.captureSession();
}
function J0() {
  var t = Ve(), e = t.document;
  if (typeof e > "u") {
    (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && Te.warn("Session tracking in non-browser environment with @sentry/browser is not supported.");
    return;
  }
  var r = Xe();
  !r.captureSession || (pc(r), Ht("history", ({ from: i, to: o }) => {
    i === void 0 || i === o || pc(Xe());
  }));
}
function Q0(t) {
  t._metadata = t._metadata || {}, t._metadata.sdk = t._metadata.sdk || {
    name: "sentry.javascript.react",
    packages: [
      {
        name: "npm:@sentry/react",
        version: Hn
      }
    ],
    version: Hn
  }, Z0(t);
}
var xo = { exports: {} }, _o = {};
/**
 * @license React
 * react-jsx-runtime.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var eb = ae, tb = Symbol.for("react.element"), rb = Symbol.for("react.fragment"), ib = Object.prototype.hasOwnProperty, nb = eb.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, ob = { key: !0, ref: !0, __self: !0, __source: !0 };
function uf(t, e, r) {
  var i, o = {}, p = null, g = null;
  r !== void 0 && (p = "" + r), e.key !== void 0 && (p = "" + e.key), e.ref !== void 0 && (g = e.ref);
  for (i in e)
    ib.call(e, i) && !ob.hasOwnProperty(i) && (o[i] = e[i]);
  if (t && t.defaultProps)
    for (i in e = t.defaultProps, e)
      o[i] === void 0 && (o[i] = e[i]);
  return { $$typeof: tb, type: t, key: p, ref: g, props: o, _owner: nb.current };
}
_o.Fragment = rb;
_o.jsx = uf;
_o.jsxs = uf;
(function(t) {
  t.exports = _o;
})(xo);
const ji = xo.exports.Fragment, x = xo.exports.jsx, ie = xo.exports.jsxs;
var Ya = /* @__PURE__ */ ((t) => (t.INLINE = "inline", t.OVERLAY = "overlay", t))(Ya || {}), hf = /* @__PURE__ */ ((t) => (t.TOP = "top", t.BOTTOM = "bottom", t.HIDDEN = "", t))(hf || {});
const sb = [
  {
    name: "circle",
    type: "Circle"
  },
  {
    name: "square",
    type: "Rect",
    options: {
      lockUniScaling: !1
    }
  },
  {
    name: "triangle",
    type: "Triangle"
  },
  {
    name: "ellipse",
    type: "Ellipse",
    options: {
      lockUniScaling: !1
    }
  },
  {
    name: "Arrow #1",
    type: "Path",
    options: {
      path: "M 294.9 16.4 l 15.7 42.2 c -171.4 70.3 -294 242.3 -289.1 437.4 l 14.7 -1 c 9.1 -0.6 18.1 -1.2 27.1 -1.9 l 14.7 -1 c -4.3 -170.1 102.5 -320 252 -381.3 l 15.7 42.2 c 34.7 -40.5 83.1 -76.6 144.8 -99.8 c -58.1 -26.2 -124.9 -39.6 -195.6 -36.8 z"
    }
  },
  {
    name: "Arrow #2",
    type: "Path",
    options: {
      path: "M 16 248.4 v 14.9 h 447.5 l -93.2 82.5 l 11.9 10.5 l 113.8 -100.2 l -113.6 -100.4 l -11.8 10.5 l 92.9 82.2 z"
    }
  },
  {
    name: "Arrow #3",
    type: "Path",
    options: {
      path: "M 496 256 l -118.6 -66 v 40.8 h -361.4 v 50.4 h 361.4 v 40.8 l 118.6 -66 z"
    }
  },
  {
    name: "Line",
    type: "Path",
    options: {
      path: "M 16 256 h 480",
      strokeWidth: 10,
      stroke: "#000",
      padding: 10
    }
  },
  {
    name: "Star",
    type: "Path",
    options: {
      path: "M 256 406.3 l 148.3 78 l -28.3 -165.2 l 120 -117 l -165.8 -24.1 l -74.2 -150.3 l -74.2 150.3 l -165.8 24.1 l 120 117 l -28.3 165.2 z"
    }
  },
  {
    name: "Polygon",
    type: "Path",
    options: {
      path: "M 256 19.6 l 156.6 57.1 l 83.4 144.3 l -28.9 164.2 l -127.7 107.2 h -166.8 l -127.7 -107.2 l -28.9 -164.2 l 83.4 -144.3 z"
    }
  },
  {
    name: "Badge",
    type: "Path",
    options: {
      path: "M 257.3 16.2 s -148 58.2 -204.4 81.4 c 0 75.7 -16.8 303.5 204.4 398.2 c 218.7 -94.6 201.9 -322.4 201.9 -398.2 c -62.1 -23.6 -201.9 -81.4 -201.9 -81.4 z"
    }
  }
], ab = [
  "afro-1",
  "afro",
  "agent",
  "alien-1",
  "alien",
  "angel",
  "angry-1",
  "angry-2",
  "angry-3",
  "angry-4",
  "angry-5",
  "angry",
  "arguing",
  "arrogant",
  "asian-1",
  "asian",
  "avatar",
  "baby-1",
  "baby-2",
  "baby",
  "bully",
  "burglar",
  "businessman",
  "cheeky-1",
  "cheeky",
  "clown",
  "confused-1",
  "confused-2",
  "confused-3",
  "confused",
  "creepy",
  "crying-1",
  "crying-2",
  "crying-3",
  "crying",
  "dazed-1",
  "dazed-2",
  "dazed-3",
  "dazed",
  "dead-1",
  "dead-2",
  "dead-3",
  "dead-4",
  "dead-5",
  "dead-6",
  "dead",
  "desperate-1",
  "desperate",
  "detective",
  "dissapointment",
  "doctor",
  "drunk",
  "dumb",
  "emo-1",
  "emo-2",
  "emo",
  "emoticon",
  "evil",
  "faint-1",
  "faint",
  "flirt-1",
  "flirt-2",
  "flirt",
  "flirty",
  "gangster",
  "geek-1",
  "geek",
  "gentleman-1",
  "gentleman-2",
  "gentleman-3",
  "gentleman-4",
  "gentleman",
  "ginger",
  "girl-1",
  "girl",
  "goofy-1",
  "goofy-2",
  "goofy-3",
  "goofy-4",
  "goofy",
  "grubby-1",
  "grubby",
  "happy-1",
  "happy-10",
  "happy-11",
  "happy-12",
  "happy-13",
  "happy-14",
  "happy-15",
  "happy-16",
  "happy-2",
  "happy-3",
  "happy-4",
  "happy-5",
  "happy-6",
  "happy-7",
  "happy-8",
  "happy-9",
  "happy",
  "harry-potter",
  "heisenberg",
  "hipster-1",
  "hipster-2",
  "hipster",
  "in-love-1",
  "in-love-2",
  "in-love-3",
  "in-love-4",
  "in-love-5",
  "in-love-6",
  "in-love",
  "japan",
  "jew",
  "joyful-1",
  "joyful-2",
  "joyful",
  "kiss-1",
  "kiss-2",
  "kiss-3",
  "kiss-4",
  "kiss",
  "laughing-1",
  "laughing-2",
  "laughing-3",
  "laughing",
  "listening",
  "love",
  "manly",
  "miserly-1",
  "miserly",
  "nerd-1",
  "nerd-2",
  "nerd-3",
  "nerd-4",
  "nerd",
  "ninja",
  "pirate-1",
  "pirate-2",
  "pirate",
  "punk-1",
  "punk-2",
  "punk",
  "rapper",
  "relieved",
  "rich-1",
  "rich-2",
  "rich",
  "rockstar",
  "sad-1",
  "sad-2",
  "sad-3",
  "sad-4",
  "sad-5",
  "sad-6",
  "sad",
  "scared-1",
  "scared-2",
  "scared-3",
  "scared",
  "sceptic-1",
  "sceptic-2",
  "sceptic-3",
  "sceptic-4",
  "sceptic-5",
  "sceptic-6",
  "sceptic-7",
  "sceptic",
  "secret",
  "shocked-1",
  "shocked-2",
  "shocked-3",
  "shocked",
  "sick-1",
  "sick-2",
  "sick-3",
  "sick-4",
  "sick",
  "silent",
  "skeleton",
  "smile",
  "smiling-1",
  "smiling",
  "smoked",
  "smug-1",
  "smug-2",
  "smug-3",
  "smug-4",
  "smug-5",
  "smug-6",
  "smug",
  "sporty",
  "stunned",
  "superhero-1",
  "superhero-2",
  "superhero-3",
  "superhero-4",
  "superhero",
  "surprised-1",
  "surprised",
  "thinking",
  "tired-1",
  "tired-2",
  "tired-3",
  "tired",
  "tough-1",
  "tough",
  "trendy",
  "vampire-1",
  "vampire",
  "wink-1",
  "wink-2",
  "wink",
  "winking-1",
  "winking",
  "yawning-1",
  "yawning-2",
  "yawning-3",
  "yawning",
  "yelling",
  "zombie"
];
function ce(t, e) {
  return { ...e, message: t };
}
const lb = [
  {
    name: "emoticons",
    list: ab,
    type: "svg",
    thumbnailUrl: "images/stickers/categories/emoticon.svg"
  },
  {
    name: "doodles",
    items: 100,
    type: "svg",
    thumbnailUrl: "images/stickers/categories/doodles.svg"
  },
  {
    name: "landmarks",
    items: 100,
    type: "svg",
    thumbnailUrl: "images/stickers/categories/landmark.svg",
    invertPreview: !0
  },
  {
    name: "bubbles",
    items: 104,
    type: "png",
    thumbnailUrl: "images/stickers/categories/speech-bubble.svg"
  },
  {
    name: "transportation",
    items: 22,
    type: "svg",
    thumbnailUrl: "images/stickers/categories/transportation.svg",
    invertPreview: !0
  },
  {
    name: "beach",
    items: 22,
    type: "svg",
    thumbnailUrl: "images/stickers/categories/beach.svg",
    invertPreview: !0
  }
], cb = {
  emoticons: ce("Emoticons"),
  doodles: ce("Doodles"),
  landmarks: ce("Landmarks"),
  bubbles: ce("Bubbles"),
  transportation: ce("Transportation"),
  beach: ce("Beach")
}, Xa = {
  fill: "#1565C0",
  opacity: 1,
  backgroundColor: null,
  strokeWidth: 0.05,
  stroke: "#000"
}, ub = [
  "PencilBrush",
  "SprayBrush",
  "CircleBrush",
  "DiamondBrush",
  "VLineBrush",
  "HLineBrush",
  "SquareBrush"
], ff = [1, 8, 15, 20, 25];
var Wn = /* @__PURE__ */ ((t) => (t.DARK = "dark", t.LIGHT = "light", t))(Wn || {});
const Fs = [
  {
    name: Wn.LIGHT,
    colors: {
      "--be-foreground-base": "0 0 0",
      "--be-primary-light": "191 219 254",
      "--be-primary": "59 130 246",
      "--be-primary-dark": "37 99 235",
      "--be-on-primary": "255 255 255",
      "--be-danger": "179 38 30",
      "--be-on-danger": "255 255 255",
      "--be-background": "255 255 255",
      "--be-background-alt": "250 250 250",
      "--be-paper": "255 255 255",
      "--be-disabled-bg-opacity": "12%",
      "--be-disabled-fg-opacity": "26%",
      "--be-hover-opacity": "4%",
      "--be-focus-opacity": "12%",
      "--be-selected-opacity": "8%",
      "--be-text-main-opacity": "87%",
      "--be-text-muted-opacity": "60%",
      "--be-divider-opacity": "12%"
    }
  },
  {
    name: Wn.DARK,
    isDark: !0,
    colors: {
      "--be-foreground-base": "255 255 255",
      "--be-primary-light": "239 246 255",
      "--be-primary": "191 219 254",
      "--be-primary-dark": "147 197 253",
      "--be-on-primary": "56 30 114",
      "--be-danger": "242 184 181",
      "--be-on-danger": "96 20 16",
      "--be-background": "20 21 23",
      "--be-background-alt": "26 27 30",
      "--be-paper": "44 46 51",
      "--be-disabled-bg-opacity": "12%",
      "--be-disabled-fg-opacity": "30%",
      "--be-hover-opacity": "8%",
      "--be-focus-opacity": "12%",
      "--be-selected-opacity": "16%",
      "--be-text-main-opacity": "100%",
      "--be-text-muted-opacity": "70%",
      "--be-divider-opacity": "12%"
    }
  }
];
var Pe = /* @__PURE__ */ ((t) => (t.FILTER = "filter", t.RESIZE = "resize", t.CROP = "crop", t.DRAW = "draw", t.TEXT = "text", t.SHAPES = "shapes", t.STICKERS = "stickers", t.FRAME = "frame", t.CORNERS = "corners", t.MERGE = "merge", t))(Pe || {});
function df(t) {
  var e, r, i = "";
  if (typeof t == "string" || typeof t == "number")
    i += t;
  else if (typeof t == "object")
    if (Array.isArray(t))
      for (e = 0; e < t.length; e++)
        t[e] && (r = df(t[e])) && (i && (i += " "), i += r);
    else
      for (e in t)
        t[e] && (i && (i += " "), i += e);
  return i;
}
function ue() {
  for (var t, e, r = 0, i = ""; r < arguments.length; )
    (t = arguments[r++]) && (e = df(t)) && (i && (i += " "), i += e);
  return i;
}
const hb = et((t, e) => {
  const {
    attr: r,
    size: i,
    title: o,
    className: p,
    color: g,
    style: a,
    children: n,
    viewBox: u,
    width: h,
    height: s,
    ...l
  } = t;
  return /* @__PURE__ */ ie("svg", {
    "aria-hidden": !o,
    focusable: !1,
    xmlns: "http://www.w3.org/2000/svg",
    viewBox: u || "0 0 24 24",
    ...r,
    ...l,
    className: ue("svg-icon", p, fb(i)),
    style: {
      color: g,
      ...a
    },
    ref: e,
    height: s || "1em",
    width: h || "1em",
    children: [o && /* @__PURE__ */ x("title", {
      children: o
    }), n]
  });
});
function fb(t) {
  switch (t) {
    case "2xs":
      return "icon-2xs";
    case "xs":
      return "icon-xs";
    case "sm":
      return "icon-sm";
    case "md":
      return "icon-md";
    case "lg":
      return "icon-lg";
    case "xl":
      return "icon-xl";
    default:
      return "";
  }
}
function me(t, e = "", r) {
  const i = (o, p) => /* @__PURE__ */ x(hb, {
    "data-testid": `${e}Icon`,
    ref: p,
    viewBox: r,
    ...o,
    size: o.size || "md",
    children: t
  });
  return ae.memo(ae.forwardRef(i));
}
function db(t, e = "") {
  const r = pf(t);
  return me(r, e);
}
function pf(t) {
  return (t == null ? void 0 : t.map) && t.map((e, r) => ae.createElement(e.tag, {
    key: r,
    ...e.attr
  }, pf(e.child)));
}
const gf = me(/* @__PURE__ */ x("path", {
  d: "M3 17v2h6v-2H3zM3 5v2h10V5H3zm10 16v-2h8v-2h-8v-2h-2v6h2zM7 9v2H3v2h4v2h2V9H7zm14 4v-2H11v2h10zm-6-4h2V7h4V5h-4V3h-2v6z"
}), "TuneOutlined"), pb = me(/* @__PURE__ */ x("path", {
  d: "M21 15h2v2h-2v-2zm0-4h2v2h-2v-2zm2 8h-2v2c1 0 2-1 2-2zM13 3h2v2h-2V3zm8 4h2v2h-2V7zm0-4v2h2c0-1-1-2-2-2zM1 7h2v2H1V7zm16-4h2v2h-2V3zm0 16h2v2h-2v-2zM3 3C2 3 1 4 1 5h2V3zm6 0h2v2H9V3zM5 3h2v2H5V3zm-4 8v8c0 1.1.9 2 2 2h12V11H1zm2 8 2.5-3.21 1.79 2.15 2.5-3.22L13 19H3z"
}), "PhotoSizeSelectLargeOutlined"), gb = me(/* @__PURE__ */ x("path", {
  d: "M17 15h2V7c0-1.1-.9-2-2-2H9v2h8v8zM7 17V1H5v4H1v2h4v10c0 1.1.9 2 2 2h10v4h2v-4h4v-2H7z"
}), "CropOutlined"), mb = me(/* @__PURE__ */ x("path", {
  d: "M2.5 4v3h5v12h3V7h5V4h-13zm19 5h-9v3h3v7h3v-7h3V9z"
}), "TextFieldsOutlined"), vb = me(/* @__PURE__ */ x("path", {
  d: "M10.5 4.5c.28 0 .5.22.5.5v2h6v6h2c.28 0 .5.22.5.5s-.22.5-.5.5h-2v6h-2.12c-.68-1.75-2.39-3-4.38-3s-3.7 1.25-4.38 3H4v-2.12c1.75-.68 3-2.39 3-4.38 0-1.99-1.24-3.7-2.99-4.38L4 7h6V5c0-.28.22-.5.5-.5m0-2C9.12 2.5 8 3.62 8 5H4c-1.1 0-1.99.9-1.99 2v3.8h.29c1.49 0 2.7 1.21 2.7 2.7s-1.21 2.7-2.7 2.7H2V20c0 1.1.9 2 2 2h3.8v-.3c0-1.49 1.21-2.7 2.7-2.7s2.7 1.21 2.7 2.7v.3H17c1.1 0 2-.9 2-2v-4c1.38 0 2.5-1.12 2.5-2.5S20.38 11 19 11V7c0-1.1-.9-2-2-2h-4c0-1.38-1.12-2.5-2.5-2.5z"
}), "ExtensionOutlined"), bb = me(/* @__PURE__ */ x("path", {
  d: "M10.25 13c0 .69-.56 1.25-1.25 1.25S7.75 13.69 7.75 13s.56-1.25 1.25-1.25 1.25.56 1.25 1.25zM15 11.75c-.69 0-1.25.56-1.25 1.25s.56 1.25 1.25 1.25 1.25-.56 1.25-1.25-.56-1.25-1.25-1.25zm7 .25c0 5.52-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2s10 4.48 10 10zM10.66 4.12C12.06 6.44 14.6 8 17.5 8c.46 0 .91-.05 1.34-.12C17.44 5.56 14.9 4 12 4c-.46 0-.91.05-1.34.12zM4.42 9.47c1.71-.97 3.03-2.55 3.66-4.44C6.37 6 5.05 7.58 4.42 9.47zM20 12c0-.78-.12-1.53-.33-2.24-.7.15-1.42.24-2.17.24-3.13 0-5.92-1.44-7.76-3.69C8.69 8.87 6.6 10.88 4 11.86c.01.04 0 .09 0 .14 0 4.41 3.59 8 8 8s8-3.59 8-8z"
}), "FaceOutlined"), yb = me(/* @__PURE__ */ x("path", {
  d: "M20 4h-4l-4-4-4 4H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 16H4V6h4.52l3.52-3.5L15.52 6H20v14zM6 18h12V8H6v10zm2-8h8v6H8v-6z"
}), "FilterFramesOutlined"), wb = me(/* @__PURE__ */ x("path", {
  d: "M6.41 21 5 19.59l4.83-4.83c.75-.75 1.17-1.77 1.17-2.83v-5.1L9.41 8.41 8 7l4-4 4 4-1.41 1.41L13 6.83v5.1c0 1.06.42 2.08 1.17 2.83L19 19.59 17.59 21 12 15.41 6.41 21z"
}), "MergeOutlined"), xb = me(/* @__PURE__ */ x("path", {
  d: "M19 19h2v2h-2v-2zm0-2h2v-2h-2v2zM3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm0-4h2V3H3v2zm4 0h2V3H7v2zm8 16h2v-2h-2v2zm-4 0h2v-2h-2v2zm4 0h2v-2h-2v2zm-8 0h2v-2H7v2zm-4 0h2v-2H3v2zM21 8c0-2.76-2.24-5-5-5h-5v2h5c1.65 0 3 1.35 3 3v5h2V8z"
}), "RoundedCornerOutlined"), gc = me(/* @__PURE__ */ x("path", {
  d: "M20 4v12H8V4h12m0-2H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-8.5 9.67 1.69 2.26 2.48-3.1L19 15H9zM2 6v14c0 1.1.9 2 2 2h14v-2H4V6H2z"
}), "PhotoLibraryOutlined"), mf = me(/* @__PURE__ */ x("path", {
  d: "M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.25 2.52.77-1.28-3.52-2.09V8z"
}), "HistoryOutlined"), _b = me([/* @__PURE__ */ x("path", {
  d: "m2.53 19.65 1.34.56v-9.03l-2.43 5.86c-.41 1.02.08 2.19 1.09 2.61zm19.5-3.7L17.07 3.98c-.31-.75-1.04-1.21-1.81-1.23-.26 0-.53.04-.79.15L7.1 5.95c-.75.31-1.21 1.03-1.23 1.8-.01.27.04.54.15.8l4.96 11.97c.31.76 1.05 1.22 1.83 1.23.26 0 .52-.05.77-.15l7.36-3.05c1.02-.42 1.51-1.59 1.09-2.6zm-9.2 3.8L7.87 7.79l7.35-3.04h.01l4.95 11.95-7.35 3.05z"
}, "0"), /* @__PURE__ */ x("circle", {
  cx: "11",
  cy: "9",
  r: "1"
}, "1"), /* @__PURE__ */ x("path", {
  d: "M5.88 19.75c0 1.1.9 2 2 2h1.45l-3.45-8.34v6.34z"
}, "2")], "StyleOutlined"), Sb = me(/* @__PURE__ */ x("path", {
  d: "M16 9v10H8V9h8m-1.5-6h-5l-1 1H5v2h14V4h-3.5l-1-1zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7z"
}), "DeleteOutlined"), Cb = me(/* @__PURE__ */ x("path", {
  d: "M18.85,10.39l1.06-1.06c0.78-0.78,0.78-2.05,0-2.83L18.5,5.09c-0.78-0.78-2.05-0.78-2.83,0l-1.06,1.06L18.85,10.39z M14.61,11.81L7.41,19H6v-1.41l7.19-7.19L14.61,11.81z M13.19,7.56L4,16.76V21h4.24l9.19-9.19L13.19,7.56L13.19,7.56z M19,17.5 c0,2.19-2.54,3.5-5,3.5c-0.55,0-1-0.45-1-1s0.45-1,1-1c1.54,0,3-0.73,3-1.5c0-0.47-0.48-0.87-1.23-1.2l1.48-1.48 C18.32,15.45,19,16.29,19,17.5z M4.58,13.35C3.61,12.79,3,12.06,3,11c0-1.8,1.89-2.63,3.56-3.36C7.59,7.18,9,6.56,9,6 c0-0.41-0.78-1-2-1C5.74,5,5.2,5.61,5.17,5.64C4.82,6.05,4.19,6.1,3.77,5.76C3.36,5.42,3.28,4.81,3.62,4.38C3.73,4.24,4.76,3,7,3 c2.24,0,4,1.32,4,3c0,1.87-1.93,2.72-3.64,3.47C6.42,9.88,5,10.5,5,11c0,0.31,0.43,0.6,1.07,0.86L4.58,13.35z"
}), "Draw"), Tb = me(/* @__PURE__ */ x("path", {
  d: "m12 5.69 5 4.5V18h-2v-6H9v6H7v-7.81l5-4.5M12 3 2 12h3v8h6v-6h2v6h6v-8h3L12 3z"
}), "HomeOutlined"), $t = {
  [Pe.FILTER]: {
    name: ce("Applied Filters"),
    icon: gf
  },
  [Pe.RESIZE]: {
    name: ce("Resized Image"),
    icon: pb
  },
  [Pe.CROP]: {
    name: ce("Cropped Image"),
    icon: gb
  },
  [Pe.DRAW]: {
    name: ce("Added Drawing"),
    icon: Cb
  },
  [Pe.TEXT]: {
    name: ce("Added Text"),
    icon: mb
  },
  [Pe.SHAPES]: {
    name: ce("Added Shape"),
    icon: vb
  },
  [Pe.STICKERS]: {
    name: ce("Added Sticker"),
    icon: bb
  },
  [Pe.FRAME]: {
    name: ce("Added Frame"),
    icon: yb
  },
  [Pe.MERGE]: {
    name: ce("Merged Objects"),
    icon: wb
  },
  [Pe.CORNERS]: {
    name: ce("Rounded Corner"),
    icon: xb
  },
  bgImage: {
    name: ce("Replaced Background Image"),
    icon: gc
  },
  overlayImage: {
    name: ce("Added Image"),
    icon: gc
  },
  initial: { name: ce("Initial"), icon: Tb },
  loadedState: {
    name: ce("Loaded State"),
    icon: mf
  },
  objectStyle: {
    name: ce("Changed Style"),
    icon: _b
  },
  deletedObject: {
    name: ce("Deleted object"),
    icon: Sb
  }
}, kb = Object.values(Pe).map(
  (t) => ({
    name: t,
    icon: $t[t].icon,
    action: t === Pe.MERGE ? (e) => {
      e.tools.merge.apply();
    } : t
  })
), Eb = {
  filter: ce("Filter"),
  resize: ce("Resize"),
  crop: ce("Crop"),
  draw: ce("Draw"),
  text: ce("Text"),
  shapes: ce("Shapes"),
  Stickers: ce("Stickers"),
  frame: ce("Frame"),
  corners: ce("Corners"),
  merge: ce("Merge")
}, Ob = me(/* @__PURE__ */ x("path", {
  d: "M18 15v3H6v-3H4v3c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-3h-2zm-1-4-1.41-1.41L13 12.17V4h-2v8.17L8.41 9.59 7 11l5 5 5-5z"
}), "FileDownloadOutlined"), Pb = "pixie", Mb = "3.0.3", Ab = "dist/pixie.umd.js", Db = "dist/pixie.es.js", Ib = "dist/types/src/pixie.d.ts", Rb = {
  ".": {
    import: "./dist/pixie.es.js",
    require: "./dist/pixie.umd.js"
  }
}, Lb = [
  "dist"
], Fb = {
  dev: "vite --host",
  build: "vite build && npm run build-umd && npm run types && npm run build-cc",
  types: "tsc --skipLibCheck --emitDeclarationOnly --noEmit false --declarationMap false",
  "build-umd": "vite build --config scripts/vite-umd.config.ts",
  "build-cc": "./scripts/build-cc.sh",
  serve: "vite preview",
  extract: "node ./scripts/extract-translations.js"
}, zb = {
  "@floating-ui/react-dom": "^1.0.0",
  "@internationalized/date": "^3.0.1",
  "@internationalized/number": "^3.0.3",
  "@react-aria/focus": "3.7.0",
  "@react-aria/interactions": "^3.11.0",
  "@react-aria/overlays": "^3.10.1",
  "@react-aria/ssr": "^3.3.0",
  "@react-aria/utils": "^3.13.3",
  "@react-stately/color": "^3.1.1",
  "@react-stately/utils": "^3.5.1",
  "@sentry/react": "^7.13.0",
  "@sentry/tracing": "^7.13.0",
  "@tanstack/react-query": "^4.3.4",
  "@tanstack/react-virtual": "^3.0.0-beta.18",
  "@use-gesture/react": "^10.2.20",
  axios: "^0.27.2",
  "axios-retry": "^3.3.1",
  clsx: "^1.2.1",
  color: "^4.2.3",
  "deep-object-diff": "^1.1.7",
  deepmerge: "^4.2.2",
  "dot-object": "^2.1.4",
  fabric: "^5.2.4",
  "file-saver": "^2.0.5",
  "framer-motion": "^7.3.6",
  immer: "^9.0.15",
  "mime-match": "^1.0.2",
  "nano-memoize": "^1.3.0",
  nanoid: "^4.0.0",
  "number-precision": "^1.5.1",
  react: ">=18.2.0",
  "react-ace": "^10.1.0",
  "react-colorful": "^5.6.1",
  "react-dom": ">=18.2.0",
  "react-hook-form": "^7.36.1",
  "react-merge-refs": "^2.0.1",
  "react-router-dom": "^6.4.1",
  "react-textarea-autosize": "^8.3.3",
  "react-use-clipboard": "^1.0.7",
  "react-use-cookie": "^1.4.0",
  "style-inject": "^0.3.0",
  "tus-js-client": "^3.0.1",
  zustand: "^4.1.1"
}, jb = {
  react: ">=18.2.0",
  "react-dom": ">=18.2.0"
}, Bb = {
  "@faker-js/faker": "^7.5.0",
  "@storybook/addon-actions": "^6.5.11",
  "@storybook/addon-essentials": "^6.5.11",
  "@storybook/addon-interactions": "^6.5.11",
  "@storybook/addon-links": "^6.5.11",
  "@storybook/builder-vite": "^0.2.2",
  "@storybook/react": "^6.5.12",
  "@storybook/testing-library": "^0.0.13",
  "@tailwindcss/typography": "^0.5.7",
  "@types/color": "^3.0.2",
  "@types/dot-object": "^2.1.2",
  "@types/fabric": "^4.5.12",
  "@types/file-saver": "^2.0.4",
  "@types/lodash.debounce": "^4.0.6",
  "@types/react": "^18.0.21",
  "@types/react-dom": "^18.0.6",
  "@types/react-recaptcha-v3": "^1.1.2",
  "@types/swagger-ui-react": "^4.11.0",
  "@typescript-eslint/eslint-plugin": "^5.38.0",
  "@typescript-eslint/parser": "^5.38.0",
  "@vitejs/plugin-react": "^2.1.0",
  autoprefixer: "^10.4.12",
  cssnano: "^5.1.13",
  eslint: "8.22",
  "eslint-config-prettier": "^8.3.0",
  "eslint-plugin-import": "^2.25.2",
  "eslint-plugin-jsx-a11y": "^6.6.1",
  "eslint-plugin-react": "^7.31.8",
  "eslint-plugin-react-hooks": "^4.6.0",
  "eslint-plugin-storybook": "^0.6.3",
  "fast-glob": "^3.2.12",
  "fast-xml-parser": "^4.0.10",
  "fs-extra": "^10.1.0",
  postcss: "^8.4.16",
  prettier: "^2.7.1",
  "rollup-plugin-visualizer": "^5.8.1",
  tailwindcss: "^3.1.8",
  typescript: "^4.8.3",
  "utility-types": "^3.10.0",
  vite: "^3.1.3",
  "vite-plugin-checker": "^0.5.1",
  "vite-tsconfig-paths": "^3.5.0"
}, Nb = {
  name: Pb,
  version: Mb,
  main: Ab,
  module: Db,
  types: Ib,
  private: !0,
  exports: Rb,
  files: Lb,
  scripts: Fb,
  dependencies: zb,
  peerDependencies: jb,
  devDependencies: Bb
}, Vb = Nb.version, vf = {
  selector: "pixie-editor",
  textureSize: 4096,
  activeLanguage: "en",
  ui: {
    visible: !0,
    mode: Ya.INLINE,
    forceOverlayModeOnMobile: !0,
    activeTheme: Wn.LIGHT,
    themes: Fs,
    allowEditorClose: !0,
    menubar: {
      items: [
        {
          type: "undoWidget",
          align: "left"
        },
        {
          type: "zoomWidget",
          align: "center",
          desktopOnly: !0
        },
        {
          type: "button",
          icon: mf,
          align: "right",
          desktopOnly: !0,
          action: (t) => {
            t.togglePanel("history");
          }
        },
        {
          type: "button",
          icon: Ob,
          label: ce("Done"),
          align: "right",
          action: (t) => {
            var e;
            (e = t.state.config.ui) != null && e.showExportPanel ? t.state.togglePanel("export", !0) : t.tools.export.save("image");
          }
        }
      ]
    },
    nav: {
      position: hf.BOTTOM,
      items: [...kb]
    },
    openImageDialog: {
      show: !0,
      sampleImages: [
        {
          url: "images/samples/sample1.jpg",
          thumbnail: "images/samples/sample1_thumbnail.jpg"
        },
        {
          url: "images/samples/sample2.jpg",
          thumbnail: "images/samples/sample2_thumbnail.jpg"
        },
        {
          url: "images/samples/sample3.jpg",
          thumbnail: "images/samples/sample3_thumbnail.jpg"
        }
      ]
    },
    colorPresets: {
      items: [
        "rgb(0,0,0)",
        "rgb(255, 255, 255)",
        "rgb(242, 38, 19)",
        "rgb(249, 105, 14)",
        "rgb(253, 227, 167)",
        "rgb(4, 147, 114)",
        "rgb(30, 139, 195)",
        "rgb(142, 68, 173)"
      ]
    }
  },
  objectDefaults: {
    global: {
      ...Xa
    },
    sticker: {
      fill: void 0
    },
    text: {
      textAlign: "initial",
      underline: !1,
      linethrough: !1,
      fontStyle: "normal",
      fontFamily: "Times New Roman",
      fontWeight: "normal",
      stroke: void 0,
      fontSize: 40
    }
  },
  tools: {
    filter: {
      items: [
        "grayscale",
        "blackWhite",
        "sharpen",
        "invert",
        "vintage",
        "polaroid",
        "kodachrome",
        "technicolor",
        "brownie",
        "sepia",
        "removeColor",
        "brightness",
        "gamma",
        "noise",
        "pixelate",
        "blur",
        "emboss",
        "blendColor"
      ]
    },
    zoom: {
      allowUserZoom: !0,
      fitImageToScreen: !0
    },
    crop: {
      allowCustomRatio: !0,
      defaultRatio: "1:1",
      presets: [
        { ratio: null, name: "Custom" },
        { ratio: "1:1", name: "Square" },
        { ratio: "4:3" },
        { ratio: "16:9" },
        { ratio: "5:3" },
        { ratio: "5:4" },
        { ratio: "6:4" },
        { ratio: "7:5" },
        { ratio: "10:8" }
      ]
    },
    text: {
      defaultText: "Double click to edit",
      items: [
        {
          family: "Roboto",
          src: "fonts/open-sans-v27-latin-ext_latin-regular.woff2"
        },
        {
          family: "Fuzzy Bubbles",
          src: "fonts/fuzzy-bubbles-v3-latin-700.woff2",
          descriptors: { weight: "700" }
        },
        {
          family: "Aleo Bold",
          src: "fonts/aleo-v4-latin-ext_latin-700.woff2",
          descriptors: { weight: "700" }
        },
        {
          family: "Amatic SC",
          src: "fonts/amatic-sc-v16-latin-ext_latin-regular.woff2"
        },
        {
          family: "Corinthia Bold",
          src: "fonts/corinthia-v7-latin-ext_latin-700.woff2"
        },
        {
          family: "Bungee Inline",
          src: "fonts/bungee-inline-v6-latin-ext_latin-regular.woff2"
        },
        {
          family: "Robot Slab Bold",
          src: "fonts/roboto-slab-v16-latin-ext_latin-500.woff2"
        },
        {
          family: "Carter One",
          src: "fonts/carter-one-v12-latin-regular.woff2"
        },
        {
          family: "Cody Star",
          src: "fonts/codystar-v10-latin-ext_latin-regular.woff2"
        },
        {
          family: "Fira Sans",
          src: "fonts/fira-sans-v11-latin-ext_latin_cyrillic-regular.woff2"
        },
        {
          family: "Krona One",
          src: "fonts/krona-one-v9-latin-ext_latin-regular.woff2"
        },
        {
          family: "Kumar One Outline",
          src: "fonts/kumar-one-outline-v8-latin-ext_latin-regular.woff2"
        },
        {
          family: "Lobster Two",
          src: "fonts/lobster-two-v13-latin-regular.woff2"
        },
        {
          family: "Molle Italic",
          src: "fonts/molle-v11-latin-ext_latin-italic.woff2"
        },
        {
          family: "Monoton",
          src: "fonts/monoton-v10-latin-regular.woff2"
        },
        {
          family: "Nixie One",
          src: "fonts/nixie-one-v11-latin-regular.woff2"
        },
        {
          family: "Permanent Marker",
          src: "fonts/permanent-marker-v10-latin-regular.woff2"
        },
        {
          family: "Sancreek",
          src: "fonts/sancreek-v13-latin-ext_latin-regular.woff2"
        },
        {
          family: "Stint Ultra Expanded",
          src: "fonts/stint-ultra-expanded-v10-latin-regular.woff2"
        },
        {
          family: "VT323",
          src: "fonts/vt323-v12-latin-ext_latin-regular.woff2"
        },
        {
          family: "Trash Hand",
          src: "fonts/TrashHand.ttf"
        }
      ]
    },
    draw: {
      brushSizes: ff,
      brushTypes: ub
    },
    shapes: {
      items: sb.slice()
    },
    stickers: {
      items: lb
    },
    import: {
      validImgExtensions: ["png", "jpg", "jpeg", "svg", "gif"],
      fitOverlayToScreen: !0,
      openDroppedImageAsBackground: !1
    },
    export: {
      defaultFormat: "png",
      defaultQuality: 0.8,
      defaultName: "image"
    },
    frame: {
      items: [
        {
          name: "basic",
          mode: "basic",
          size: {
            min: 1,
            max: 35,
            default: 10
          }
        },
        {
          name: "pine",
          mode: "stretch",
          size: {
            min: 1,
            max: 35,
            default: 15
          }
        },
        {
          name: "oak",
          mode: "stretch",
          size: {
            min: 1,
            max: 35,
            default: 15
          }
        },
        {
          name: "rainbow",
          mode: "stretch",
          size: {
            min: 1,
            max: 35,
            default: 15
          }
        },
        {
          name: "grunge1",
          display_name: "grunge #1",
          mode: "stretch",
          size: {
            min: 1,
            max: 35,
            default: 15
          }
        },
        {
          name: "grunge2",
          display_name: "grunge #2",
          mode: "stretch",
          size: {
            min: 1,
            max: 35,
            default: 20
          }
        },
        {
          name: "ebony",
          mode: "stretch",
          size: {
            min: 1,
            max: 35,
            default: 15
          }
        },
        {
          name: "art1",
          display_name: "Art #1",
          mode: "repeat",
          size: {
            min: 10,
            max: 70,
            default: 55
          }
        },
        {
          name: "art2",
          display_name: "Art #2",
          mode: "repeat",
          size: {
            min: 10,
            max: 70,
            default: 55
          }
        }
      ]
    }
  }
}, mc = (t) => {
  let e;
  const r = /* @__PURE__ */ new Set(), i = (n, u) => {
    const h = typeof n == "function" ? n(e) : n;
    if (h !== e) {
      const s = e;
      e = (u != null ? u : typeof h != "object") ? h : Object.assign({}, e, h), r.forEach((l) => l(e, s));
    }
  }, o = () => e, a = { setState: i, getState: o, subscribe: (n) => (r.add(n), () => r.delete(n)), destroy: () => r.clear() };
  return e = t(
    i,
    o,
    a
  ), a;
}, $b = (t) => t ? mc(t) : mc;
var bf = { exports: {} }, yf = {}, wf = { exports: {} }, xf = {};
/**
 * @license React
 * use-sync-external-store-shim.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var ui = ae;
function Hb(t, e) {
  return t === e && (t !== 0 || 1 / t === 1 / e) || t !== t && e !== e;
}
var Ub = typeof Object.is == "function" ? Object.is : Hb, Wb = ui.useState, Yb = ui.useEffect, Xb = ui.useLayoutEffect, Gb = ui.useDebugValue;
function qb(t, e) {
  var r = e(), i = Wb({ inst: { value: r, getSnapshot: e } }), o = i[0].inst, p = i[1];
  return Xb(function() {
    o.value = r, o.getSnapshot = e, ts(o) && p({ inst: o });
  }, [t, r, e]), Yb(function() {
    return ts(o) && p({ inst: o }), t(function() {
      ts(o) && p({ inst: o });
    });
  }, [t]), Gb(r), r;
}
function ts(t) {
  var e = t.getSnapshot;
  t = t.value;
  try {
    var r = e();
    return !Ub(t, r);
  } catch {
    return !0;
  }
}
function Kb(t, e) {
  return e();
}
var Zb = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? Kb : qb;
xf.useSyncExternalStore = ui.useSyncExternalStore !== void 0 ? ui.useSyncExternalStore : Zb;
(function(t) {
  t.exports = xf;
})(wf);
/**
 * @license React
 * use-sync-external-store-shim/with-selector.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var So = ae, Jb = wf.exports;
function Qb(t, e) {
  return t === e && (t !== 0 || 1 / t === 1 / e) || t !== t && e !== e;
}
var e1 = typeof Object.is == "function" ? Object.is : Qb, t1 = Jb.useSyncExternalStore, r1 = So.useRef, i1 = So.useEffect, n1 = So.useMemo, o1 = So.useDebugValue;
yf.useSyncExternalStoreWithSelector = function(t, e, r, i, o) {
  var p = r1(null);
  if (p.current === null) {
    var g = { hasValue: !1, value: null };
    p.current = g;
  } else
    g = p.current;
  p = n1(function() {
    function n(c) {
      if (!u) {
        if (u = !0, h = c, c = i(c), o !== void 0 && g.hasValue) {
          var f = g.value;
          if (o(f, c))
            return s = f;
        }
        return s = c;
      }
      if (f = s, e1(h, c))
        return f;
      var m = i(c);
      return o !== void 0 && o(f, m) ? f : (h = c, s = m);
    }
    var u = !1, h, s, l = r === void 0 ? null : r;
    return [function() {
      return n(e());
    }, l === null ? void 0 : function() {
      return n(l());
    }];
  }, [e, r, i, o]);
  var a = t1(t, p[0], p[1]);
  return i1(function() {
    g.hasValue = !0, g.value = a;
  }, [a]), o1(a), a;
};
(function(t) {
  t.exports = yf;
})(bf);
const s1 = /* @__PURE__ */ am(bf.exports), { useSyncExternalStoreWithSelector: a1 } = s1;
function l1(t, e = t.getState, r) {
  const i = a1(
    t.subscribe,
    t.getState,
    t.getServerState || t.getState,
    e,
    r
  );
  return rm(i), i;
}
const vc = (t) => {
  const e = typeof t == "function" ? $b(t) : t, r = (i, o) => l1(e, i, o);
  return Object.assign(r, e), r;
}, c1 = (t) => t ? vc(t) : vc;
var _f = c1;
const u1 = (t) => (e, r, i) => {
  const o = i.subscribe;
  return i.subscribe = (g, a, n) => {
    let u = g;
    if (a) {
      const h = (n == null ? void 0 : n.equalityFn) || Object.is;
      let s = g(i.getState());
      u = (l) => {
        const c = g(l);
        if (!h(s, c)) {
          const f = s;
          a(s = c, f);
        }
      }, n != null && n.fireImmediately && a(s, s);
    }
    return o(u);
  }, t(e, r, i);
}, h1 = u1;
function gt(t) {
  for (var e = arguments.length, r = Array(e > 1 ? e - 1 : 0), i = 1; i < e; i++)
    r[i - 1] = arguments[i];
  throw Error("[Immer] minified error nr: " + t + (r.length ? " " + r.map(function(o) {
    return "'" + o + "'";
  }).join(",") : "") + ". Find the full error at: https://bit.ly/3cXEKWf");
}
function hi(t) {
  return !!t && !!t[ut];
}
function Tr(t) {
  return !!t && (function(e) {
    if (!e || typeof e != "object")
      return !1;
    var r = Object.getPrototypeOf(e);
    if (r === null)
      return !0;
    var i = Object.hasOwnProperty.call(r, "constructor") && r.constructor;
    return i === Object || typeof i == "function" && Function.toString.call(i) === y1;
  }(t) || Array.isArray(t) || !!t[Tc] || !!t.constructor[Tc] || Ga(t) || qa(t));
}
function Bi(t, e, r) {
  r === void 0 && (r = !1), mi(t) === 0 ? (r ? Object.keys : el)(t).forEach(function(i) {
    r && typeof i == "symbol" || e(i, t[i], t);
  }) : t.forEach(function(i, o) {
    return e(o, i, t);
  });
}
function mi(t) {
  var e = t[ut];
  return e ? e.i > 3 ? e.i - 4 : e.i : Array.isArray(t) ? 1 : Ga(t) ? 2 : qa(t) ? 3 : 0;
}
function zs(t, e) {
  return mi(t) === 2 ? t.has(e) : Object.prototype.hasOwnProperty.call(t, e);
}
function f1(t, e) {
  return mi(t) === 2 ? t.get(e) : t[e];
}
function Sf(t, e, r) {
  var i = mi(t);
  i === 2 ? t.set(e, r) : i === 3 ? (t.delete(e), t.add(r)) : t[e] = r;
}
function d1(t, e) {
  return t === e ? t !== 0 || 1 / t == 1 / e : t != t && e != e;
}
function Ga(t) {
  return v1 && t instanceof Map;
}
function qa(t) {
  return b1 && t instanceof Set;
}
function br(t) {
  return t.o || t.t;
}
function Ka(t) {
  if (Array.isArray(t))
    return Array.prototype.slice.call(t);
  var e = w1(t);
  delete e[ut];
  for (var r = el(e), i = 0; i < r.length; i++) {
    var o = r[i], p = e[o];
    p.writable === !1 && (p.writable = !0, p.configurable = !0), (p.get || p.set) && (e[o] = { configurable: !0, writable: !0, enumerable: p.enumerable, value: t[o] });
  }
  return Object.create(Object.getPrototypeOf(t), e);
}
function Za(t, e) {
  return e === void 0 && (e = !1), Ja(t) || hi(t) || !Tr(t) || (mi(t) > 1 && (t.set = t.add = t.clear = t.delete = p1), Object.freeze(t), e && Bi(t, function(r, i) {
    return Za(i, !0);
  }, !0)), t;
}
function p1() {
  gt(2);
}
function Ja(t) {
  return t == null || typeof t != "object" || Object.isFrozen(t);
}
function St(t) {
  var e = x1[t];
  return e || gt(18, t), e;
}
function bc() {
  return Ni;
}
function rs(t, e) {
  e && (St("Patches"), t.u = [], t.s = [], t.v = e);
}
function Yn(t) {
  js(t), t.p.forEach(g1), t.p = null;
}
function js(t) {
  t === Ni && (Ni = t.l);
}
function yc(t) {
  return Ni = { p: [], l: Ni, h: t, m: !0, _: 0 };
}
function g1(t) {
  var e = t[ut];
  e.i === 0 || e.i === 1 ? e.j() : e.O = !0;
}
function is(t, e) {
  e._ = e.p.length;
  var r = e.p[0], i = t !== void 0 && t !== r;
  return e.h.g || St("ES5").S(e, t, i), i ? (r[ut].P && (Yn(e), gt(4)), Tr(t) && (t = Xn(e, t), e.l || Gn(e, t)), e.u && St("Patches").M(r[ut].t, t, e.u, e.s)) : t = Xn(e, r, []), Yn(e), e.u && e.v(e.u, e.s), t !== Cf ? t : void 0;
}
function Xn(t, e, r) {
  if (Ja(e))
    return e;
  var i = e[ut];
  if (!i)
    return Bi(e, function(p, g) {
      return wc(t, i, e, p, g, r);
    }, !0), e;
  if (i.A !== t)
    return e;
  if (!i.P)
    return Gn(t, i.t, !0), i.t;
  if (!i.I) {
    i.I = !0, i.A._--;
    var o = i.i === 4 || i.i === 5 ? i.o = Ka(i.k) : i.o;
    Bi(i.i === 3 ? new Set(o) : o, function(p, g) {
      return wc(t, i, o, p, g, r);
    }), Gn(t, o, !1), r && t.u && St("Patches").R(i, r, t.u, t.s);
  }
  return i.o;
}
function wc(t, e, r, i, o, p) {
  if (hi(o)) {
    var g = Xn(t, o, p && e && e.i !== 3 && !zs(e.D, i) ? p.concat(i) : void 0);
    if (Sf(r, i, g), !hi(g))
      return;
    t.m = !1;
  }
  if (Tr(o) && !Ja(o)) {
    if (!t.h.F && t._ < 1)
      return;
    Xn(t, o), e && e.A.l || Gn(t, o);
  }
}
function Gn(t, e, r) {
  r === void 0 && (r = !1), t.h.F && t.m && Za(e, r);
}
function ns(t, e) {
  var r = t[ut];
  return (r ? br(r) : t)[e];
}
function xc(t, e) {
  if (e in t)
    for (var r = Object.getPrototypeOf(t); r; ) {
      var i = Object.getOwnPropertyDescriptor(r, e);
      if (i)
        return i;
      r = Object.getPrototypeOf(r);
    }
}
function Bs(t) {
  t.P || (t.P = !0, t.l && Bs(t.l));
}
function os(t) {
  t.o || (t.o = Ka(t.t));
}
function Ns(t, e, r) {
  var i = Ga(e) ? St("MapSet").N(e, r) : qa(e) ? St("MapSet").T(e, r) : t.g ? function(o, p) {
    var g = Array.isArray(o), a = { i: g ? 1 : 0, A: p ? p.A : bc(), P: !1, I: !1, D: {}, l: p, t: o, k: null, o: null, j: null, C: !1 }, n = a, u = Vs;
    g && (n = [a], u = _i);
    var h = Proxy.revocable(n, u), s = h.revoke, l = h.proxy;
    return a.k = l, a.j = s, l;
  }(e, r) : St("ES5").J(e, r);
  return (r ? r.A : bc()).p.push(i), i;
}
function m1(t) {
  return hi(t) || gt(22, t), function e(r) {
    if (!Tr(r))
      return r;
    var i, o = r[ut], p = mi(r);
    if (o) {
      if (!o.P && (o.i < 4 || !St("ES5").K(o)))
        return o.t;
      o.I = !0, i = _c(r, p), o.I = !1;
    } else
      i = _c(r, p);
    return Bi(i, function(g, a) {
      o && f1(o.t, g) === a || Sf(i, g, e(a));
    }), p === 3 ? new Set(i) : i;
  }(t);
}
function _c(t, e) {
  switch (e) {
    case 2:
      return new Map(t);
    case 3:
      return Array.from(t);
  }
  return Ka(t);
}
var Sc, Ni, Qa = typeof Symbol < "u" && typeof Symbol("x") == "symbol", v1 = typeof Map < "u", b1 = typeof Set < "u", Cc = typeof Proxy < "u" && Proxy.revocable !== void 0 && typeof Reflect < "u", Cf = Qa ? Symbol.for("immer-nothing") : ((Sc = {})["immer-nothing"] = !0, Sc), Tc = Qa ? Symbol.for("immer-draftable") : "__$immer_draftable", ut = Qa ? Symbol.for("immer-state") : "__$immer_state", y1 = "" + Object.prototype.constructor, el = typeof Reflect < "u" && Reflect.ownKeys ? Reflect.ownKeys : Object.getOwnPropertySymbols !== void 0 ? function(t) {
  return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t));
} : Object.getOwnPropertyNames, w1 = Object.getOwnPropertyDescriptors || function(t) {
  var e = {};
  return el(t).forEach(function(r) {
    e[r] = Object.getOwnPropertyDescriptor(t, r);
  }), e;
}, x1 = {}, Vs = { get: function(t, e) {
  if (e === ut)
    return t;
  var r = br(t);
  if (!zs(r, e))
    return function(o, p, g) {
      var a, n = xc(p, g);
      return n ? "value" in n ? n.value : (a = n.get) === null || a === void 0 ? void 0 : a.call(o.k) : void 0;
    }(t, r, e);
  var i = r[e];
  return t.I || !Tr(i) ? i : i === ns(t.t, e) ? (os(t), t.o[e] = Ns(t.A.h, i, t)) : i;
}, has: function(t, e) {
  return e in br(t);
}, ownKeys: function(t) {
  return Reflect.ownKeys(br(t));
}, set: function(t, e, r) {
  var i = xc(br(t), e);
  if (i != null && i.set)
    return i.set.call(t.k, r), !0;
  if (!t.P) {
    var o = ns(br(t), e), p = o == null ? void 0 : o[ut];
    if (p && p.t === r)
      return t.o[e] = r, t.D[e] = !1, !0;
    if (d1(r, o) && (r !== void 0 || zs(t.t, e)))
      return !0;
    os(t), Bs(t);
  }
  return t.o[e] === r && typeof r != "number" && (r !== void 0 || e in t.o) || (t.o[e] = r, t.D[e] = !0, !0);
}, deleteProperty: function(t, e) {
  return ns(t.t, e) !== void 0 || e in t.t ? (t.D[e] = !1, os(t), Bs(t)) : delete t.D[e], t.o && delete t.o[e], !0;
}, getOwnPropertyDescriptor: function(t, e) {
  var r = br(t), i = Reflect.getOwnPropertyDescriptor(r, e);
  return i && { writable: !0, configurable: t.i !== 1 || e !== "length", enumerable: i.enumerable, value: r[e] };
}, defineProperty: function() {
  gt(11);
}, getPrototypeOf: function(t) {
  return Object.getPrototypeOf(t.t);
}, setPrototypeOf: function() {
  gt(12);
} }, _i = {};
Bi(Vs, function(t, e) {
  _i[t] = function() {
    return arguments[0] = arguments[0][0], e.apply(this, arguments);
  };
}), _i.deleteProperty = function(t, e) {
  return _i.set.call(this, t, e, void 0);
}, _i.set = function(t, e, r) {
  return Vs.set.call(this, t[0], e, r, t[0]);
};
var _1 = function() {
  function t(r) {
    var i = this;
    this.g = Cc, this.F = !0, this.produce = function(o, p, g) {
      if (typeof o == "function" && typeof p != "function") {
        var a = p;
        p = o;
        var n = i;
        return function(m) {
          var d = this;
          m === void 0 && (m = a);
          for (var v = arguments.length, b = Array(v > 1 ? v - 1 : 0), y = 1; y < v; y++)
            b[y - 1] = arguments[y];
          return n.produce(m, function(w) {
            var _;
            return (_ = p).call.apply(_, [d, w].concat(b));
          });
        };
      }
      var u;
      if (typeof p != "function" && gt(6), g !== void 0 && typeof g != "function" && gt(7), Tr(o)) {
        var h = yc(i), s = Ns(i, o, void 0), l = !0;
        try {
          u = p(s), l = !1;
        } finally {
          l ? Yn(h) : js(h);
        }
        return typeof Promise < "u" && u instanceof Promise ? u.then(function(m) {
          return rs(h, g), is(m, h);
        }, function(m) {
          throw Yn(h), m;
        }) : (rs(h, g), is(u, h));
      }
      if (!o || typeof o != "object") {
        if ((u = p(o)) === void 0 && (u = o), u === Cf && (u = void 0), i.F && Za(u, !0), g) {
          var c = [], f = [];
          St("Patches").M(o, u, c, f), g(c, f);
        }
        return u;
      }
      gt(21, o);
    }, this.produceWithPatches = function(o, p) {
      if (typeof o == "function")
        return function(u) {
          for (var h = arguments.length, s = Array(h > 1 ? h - 1 : 0), l = 1; l < h; l++)
            s[l - 1] = arguments[l];
          return i.produceWithPatches(u, function(c) {
            return o.apply(void 0, [c].concat(s));
          });
        };
      var g, a, n = i.produce(o, p, function(u, h) {
        g = u, a = h;
      });
      return typeof Promise < "u" && n instanceof Promise ? n.then(function(u) {
        return [u, g, a];
      }) : [n, g, a];
    }, typeof (r == null ? void 0 : r.useProxies) == "boolean" && this.setUseProxies(r.useProxies), typeof (r == null ? void 0 : r.autoFreeze) == "boolean" && this.setAutoFreeze(r.autoFreeze);
  }
  var e = t.prototype;
  return e.createDraft = function(r) {
    Tr(r) || gt(8), hi(r) && (r = m1(r));
    var i = yc(this), o = Ns(this, r, void 0);
    return o[ut].C = !0, js(i), o;
  }, e.finishDraft = function(r, i) {
    var o = r && r[ut], p = o.A;
    return rs(p, i), is(void 0, p);
  }, e.setAutoFreeze = function(r) {
    this.F = r;
  }, e.setUseProxies = function(r) {
    r && !Cc && gt(20), this.g = r;
  }, e.applyPatches = function(r, i) {
    var o;
    for (o = i.length - 1; o >= 0; o--) {
      var p = i[o];
      if (p.path.length === 0 && p.op === "replace") {
        r = p.value;
        break;
      }
    }
    o > -1 && (i = i.slice(o + 1));
    var g = St("Patches").$;
    return hi(r) ? g(r, i) : this.produce(r, function(a) {
      return g(a, i);
    });
  }, t;
}(), ht = new _1(), S1 = ht.produce;
ht.produceWithPatches.bind(ht);
ht.setAutoFreeze.bind(ht);
ht.setUseProxies.bind(ht);
ht.applyPatches.bind(ht);
ht.createDraft.bind(ht);
ht.finishDraft.bind(ht);
function C1(t) {
  return t ? t.charAt(0).toLowerCase() + t.slice(1) : "";
}
function T1(t, e) {
  const r = Eh(e, t);
  return Tf(r, t);
}
function Tf(t, e) {
  return Object.keys(t).forEach((r) => {
    if (r.startsWith("replaceDefault") && t[r]) {
      const i = C1(
        r.replace("replaceDefault", "") || "items"
      );
      t[i] = e ? e[i] : [], delete t[r];
    } else
      typeof t[r] == "object" && t[r] !== null && Tf(t[r], e == null ? void 0 : e[r]);
  }), t;
}
const k1 = (t, e) => ({
  history: {
    ...kc,
    updatePointerById: (r) => {
      const i = e().history.items.findIndex((o) => o.id === r);
      e().history.update(i);
    },
    update: (r, i) => {
      t((o) => {
        o.history.pointer = r, i && (o.history.items = i), o.history.canUndo = o.history.pointer > 0, o.history.canRedo = o.history.items.length > o.history.pointer + 1;
      });
    },
    reset: () => {
      t({ history: { ...e().history, ...kc } });
    }
  }
}), kc = {
  items: [],
  pointer: 0,
  canUndo: !1,
  canRedo: !1
};
var mt = /* @__PURE__ */ ((t) => (t.Filter = "filter", t.Frame = "frame", t.ActiveObject = "activeObj", t.Text = "text", t))(mt || {});
const E1 = (t, e) => ({
  filter: {
    ...Ec,
    select(r, i = !1) {
      t((o) => {
        o.filter.selected = r, o.activeToolOverlay = i ? mt.Filter : null, o.dirty = !0;
      });
    },
    deselect(r) {
      e().filter.selected === r && t((i) => {
        i.filter.selected = null, i.activeToolOverlay = null, i.dirty = !0;
      });
    },
    reset() {
      t({ filter: { ...e().filter, ...Ec } });
    }
  }
}), Ec = {
  selected: null,
  applied: []
}, O1 = (t, e) => ({
  crop: {
    ...Oc,
    setCropzoneRect: (r) => {
      t((i) => {
        i.crop.zoneRect = r;
      });
    },
    setAspectRatio: (r) => {
      t((i) => {
        i.crop.selectedAspectRatio = r;
      });
    },
    setTransformAngle: (r) => {
      t((i) => {
        i.crop.straightenAngle = r;
      });
    },
    apply: async () => {
      const r = e().crop.zoneRect;
      if (r) {
        const i = {
          width: Math.ceil(r.width / e().zoom),
          height: Math.ceil(r.height / e().zoom),
          left: Math.ceil(r.left / e().zoom),
          top: Math.ceil(r.top / e().zoom)
        };
        await e().editor.tools.crop.apply(i);
      }
    },
    reset: () => {
      t({ crop: { ...e().crop, ...Oc } });
    }
  }
}), Oc = {
  zoneRect: null,
  selectedAspectRatio: null,
  straightenAngle: 0
};
function lr(t) {
  return (t == null ? void 0 : t.type) === "i-text";
}
var Ne = /* @__PURE__ */ ((t) => (t.Text = "text", t.Shape = "shape", t.Sticker = "sticker", t.Drawing = "drawing", t.Image = "image", t.MainImage = "mainImage", t.StraightenAnchor = "straightenHelper", t))(Ne || {});
const P1 = {
  text: {
    name: ce("Text"),
    icon: $t.text.icon
  },
  shape: {
    name: ce("Shape"),
    icon: $t.shapes.icon
  },
  sticker: {
    name: ce("Sticker"),
    icon: $t.stickers.icon
  },
  drawing: {
    name: ce("Drawing"),
    icon: $t.draw.icon
  },
  image: {
    name: ce("Image"),
    icon: $t.overlayImage.icon
  },
  mainImage: {
    name: ce("Background Image"),
    icon: $t.bgImage.icon
  }
};
function M1(t) {
  return t.name === Ne.Image;
}
const kf = {
  isMoving: !1,
  editableProps: {},
  id: null,
  isText: !1,
  isImage: !1,
  name: null
};
function A1(t) {
  if (!t)
    return {};
  const e = {
    fill: t.fill,
    opacity: t.opacity,
    backgroundColor: t.backgroundColor,
    stroke: t.stroke,
    strokeWidth: t.strokeWidth
  }, r = t.shadow;
  return r && (e.shadow = {
    color: r.color,
    blur: r.blur,
    offsetX: r.offsetX,
    offsetY: r.offsetY
  }), lr(t) && (e.textAlign = t.textAlign, e.underline = t.underline, e.linethrough = t.linethrough, e.fontStyle = t.fontStyle, e.fontFamily = t.fontFamily, e.fontWeight = t.fontWeight, e.fontSize = t.fontSize), e;
}
const D1 = (t, e) => ({
  objects: {
    ...Pc,
    setActiveIsMoving: (r) => {
      t((i) => {
        i.objects.active.isMoving = r;
      });
    },
    setIsEditingText: (r) => {
      t((i) => {
        i.objects.isEditingText = r;
      });
    },
    setActive: (r) => {
      t(r ? (i) => {
        var o;
        i.objects.active.editableProps = A1(r), i.objects.active.id = r.data.id, i.objects.active.name = (o = r.name) != null ? o : null, i.objects.active.isText = lr(r), i.objects.active.isImage = M1(r);
      } : (i) => {
        var p, g, a, n, u;
        const o = {
          ...(p = e().config.objectDefaults) == null ? void 0 : p.global,
          fontFamily: (a = (g = e().config.objectDefaults) == null ? void 0 : g.text) == null ? void 0 : a.fontFamily,
          fontSize: (u = (n = e().config.objectDefaults) == null ? void 0 : n.text) == null ? void 0 : u.fontSize
        };
        i.objects.active = {
          ...kf,
          editableProps: o
        };
      });
    },
    reset() {
      t({ objects: { ...e().objects, ...Pc } });
    }
  }
}), Pc = {
  all: [],
  isEditingText: !1,
  active: kf
}, I1 = (t, e) => ({
  frame: {
    ...Mc,
    select: (r) => {
      t((i) => {
        i.frame.active = r;
      }), e().frame.showOptionsPanel();
    },
    deselect: () => {
      t((r) => {
        r.frame.active = null, r.activeToolOverlay = null;
      });
    },
    showOptionsPanel: () => {
      e().activeTool === Pe.FRAME && t((r) => {
        r.activeToolOverlay = mt.Frame;
      });
    },
    reset() {
      t({ frame: { ...e().frame, ...Mc } });
    }
  }
}), Mc = {
  active: null
}, R1 = (t, e) => ({
  resize: {
    ...Ac,
    setFormValue: (r) => {
      t((i) => {
        Object.entries(r).forEach(([o, p]) => {
          i.resize.formValue[o] = p;
        });
      });
    },
    apply() {
      const r = e().resize.formValue, i = e().original;
      if (r.width === i.width && r.height === i.height)
        return !1;
      e().editor.tools.resize.apply(r);
    },
    reset() {
      t({ resize: { ...e().resize, ...Ac } });
    }
  }
}), Ac = {
  formValue: {
    width: 1,
    height: 1,
    maintainAspect: !0,
    usePercentages: !1
  }
}, L1 = (t, e) => ({
  corners: {
    ...Dc,
    setRadius: (r) => {
      t((i) => {
        i.corners.radius = r;
      });
    },
    apply() {
      return e().editor.tools.corners.apply(e().corners.radius);
    },
    reset() {
      t({ corners: { ...e().corners, ...Dc } });
    }
  }
}), Dc = {
  radius: 50
}, F1 = (t) => (e, r, i) => (i.setState = (o, p, ...g) => {
  const a = typeof o == "function" ? S1(o) : o;
  return e(a, p, ...g);
}, t(i.setState, r, i)), Ef = F1;
var Of = { exports: {} }, z1 = {
  aliceblue: [240, 248, 255],
  antiquewhite: [250, 235, 215],
  aqua: [0, 255, 255],
  aquamarine: [127, 255, 212],
  azure: [240, 255, 255],
  beige: [245, 245, 220],
  bisque: [255, 228, 196],
  black: [0, 0, 0],
  blanchedalmond: [255, 235, 205],
  blue: [0, 0, 255],
  blueviolet: [138, 43, 226],
  brown: [165, 42, 42],
  burlywood: [222, 184, 135],
  cadetblue: [95, 158, 160],
  chartreuse: [127, 255, 0],
  chocolate: [210, 105, 30],
  coral: [255, 127, 80],
  cornflowerblue: [100, 149, 237],
  cornsilk: [255, 248, 220],
  crimson: [220, 20, 60],
  cyan: [0, 255, 255],
  darkblue: [0, 0, 139],
  darkcyan: [0, 139, 139],
  darkgoldenrod: [184, 134, 11],
  darkgray: [169, 169, 169],
  darkgreen: [0, 100, 0],
  darkgrey: [169, 169, 169],
  darkkhaki: [189, 183, 107],
  darkmagenta: [139, 0, 139],
  darkolivegreen: [85, 107, 47],
  darkorange: [255, 140, 0],
  darkorchid: [153, 50, 204],
  darkred: [139, 0, 0],
  darksalmon: [233, 150, 122],
  darkseagreen: [143, 188, 143],
  darkslateblue: [72, 61, 139],
  darkslategray: [47, 79, 79],
  darkslategrey: [47, 79, 79],
  darkturquoise: [0, 206, 209],
  darkviolet: [148, 0, 211],
  deeppink: [255, 20, 147],
  deepskyblue: [0, 191, 255],
  dimgray: [105, 105, 105],
  dimgrey: [105, 105, 105],
  dodgerblue: [30, 144, 255],
  firebrick: [178, 34, 34],
  floralwhite: [255, 250, 240],
  forestgreen: [34, 139, 34],
  fuchsia: [255, 0, 255],
  gainsboro: [220, 220, 220],
  ghostwhite: [248, 248, 255],
  gold: [255, 215, 0],
  goldenrod: [218, 165, 32],
  gray: [128, 128, 128],
  green: [0, 128, 0],
  greenyellow: [173, 255, 47],
  grey: [128, 128, 128],
  honeydew: [240, 255, 240],
  hotpink: [255, 105, 180],
  indianred: [205, 92, 92],
  indigo: [75, 0, 130],
  ivory: [255, 255, 240],
  khaki: [240, 230, 140],
  lavender: [230, 230, 250],
  lavenderblush: [255, 240, 245],
  lawngreen: [124, 252, 0],
  lemonchiffon: [255, 250, 205],
  lightblue: [173, 216, 230],
  lightcoral: [240, 128, 128],
  lightcyan: [224, 255, 255],
  lightgoldenrodyellow: [250, 250, 210],
  lightgray: [211, 211, 211],
  lightgreen: [144, 238, 144],
  lightgrey: [211, 211, 211],
  lightpink: [255, 182, 193],
  lightsalmon: [255, 160, 122],
  lightseagreen: [32, 178, 170],
  lightskyblue: [135, 206, 250],
  lightslategray: [119, 136, 153],
  lightslategrey: [119, 136, 153],
  lightsteelblue: [176, 196, 222],
  lightyellow: [255, 255, 224],
  lime: [0, 255, 0],
  limegreen: [50, 205, 50],
  linen: [250, 240, 230],
  magenta: [255, 0, 255],
  maroon: [128, 0, 0],
  mediumaquamarine: [102, 205, 170],
  mediumblue: [0, 0, 205],
  mediumorchid: [186, 85, 211],
  mediumpurple: [147, 112, 219],
  mediumseagreen: [60, 179, 113],
  mediumslateblue: [123, 104, 238],
  mediumspringgreen: [0, 250, 154],
  mediumturquoise: [72, 209, 204],
  mediumvioletred: [199, 21, 133],
  midnightblue: [25, 25, 112],
  mintcream: [245, 255, 250],
  mistyrose: [255, 228, 225],
  moccasin: [255, 228, 181],
  navajowhite: [255, 222, 173],
  navy: [0, 0, 128],
  oldlace: [253, 245, 230],
  olive: [128, 128, 0],
  olivedrab: [107, 142, 35],
  orange: [255, 165, 0],
  orangered: [255, 69, 0],
  orchid: [218, 112, 214],
  palegoldenrod: [238, 232, 170],
  palegreen: [152, 251, 152],
  paleturquoise: [175, 238, 238],
  palevioletred: [219, 112, 147],
  papayawhip: [255, 239, 213],
  peachpuff: [255, 218, 185],
  peru: [205, 133, 63],
  pink: [255, 192, 203],
  plum: [221, 160, 221],
  powderblue: [176, 224, 230],
  purple: [128, 0, 128],
  rebeccapurple: [102, 51, 153],
  red: [255, 0, 0],
  rosybrown: [188, 143, 143],
  royalblue: [65, 105, 225],
  saddlebrown: [139, 69, 19],
  salmon: [250, 128, 114],
  sandybrown: [244, 164, 96],
  seagreen: [46, 139, 87],
  seashell: [255, 245, 238],
  sienna: [160, 82, 45],
  silver: [192, 192, 192],
  skyblue: [135, 206, 235],
  slateblue: [106, 90, 205],
  slategray: [112, 128, 144],
  slategrey: [112, 128, 144],
  snow: [255, 250, 250],
  springgreen: [0, 255, 127],
  steelblue: [70, 130, 180],
  tan: [210, 180, 140],
  teal: [0, 128, 128],
  thistle: [216, 191, 216],
  tomato: [255, 99, 71],
  turquoise: [64, 224, 208],
  violet: [238, 130, 238],
  wheat: [245, 222, 179],
  white: [255, 255, 255],
  whitesmoke: [245, 245, 245],
  yellow: [255, 255, 0],
  yellowgreen: [154, 205, 50]
}, Pf = { exports: {} }, j1 = function(e) {
  return !e || typeof e == "string" ? !1 : e instanceof Array || Array.isArray(e) || e.length >= 0 && (e.splice instanceof Function || Object.getOwnPropertyDescriptor(e, e.length - 1) && e.constructor.name !== "String");
}, B1 = j1, N1 = Array.prototype.concat, V1 = Array.prototype.slice, Ic = Pf.exports = function(e) {
  for (var r = [], i = 0, o = e.length; i < o; i++) {
    var p = e[i];
    B1(p) ? r = N1.call(r, V1.call(p)) : r.push(p);
  }
  return r;
};
Ic.wrap = function(t) {
  return function() {
    return t(Ic(arguments));
  };
};
var ki = z1, en = Pf.exports, Mf = Object.hasOwnProperty, Af = /* @__PURE__ */ Object.create(null);
for (var ss in ki)
  Mf.call(ki, ss) && (Af[ki[ss]] = ss);
var at = Of.exports = {
  to: {},
  get: {}
};
at.get = function(t) {
  var e = t.substring(0, 3).toLowerCase(), r, i;
  switch (e) {
    case "hsl":
      r = at.get.hsl(t), i = "hsl";
      break;
    case "hwb":
      r = at.get.hwb(t), i = "hwb";
      break;
    default:
      r = at.get.rgb(t), i = "rgb";
      break;
  }
  return r ? { model: i, value: r } : null;
};
at.get.rgb = function(t) {
  if (!t)
    return null;
  var e = /^#([a-f0-9]{3,4})$/i, r = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i, i = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/, o = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/, p = /^(\w+)$/, g = [0, 0, 0, 1], a, n, u;
  if (a = t.match(r)) {
    for (u = a[2], a = a[1], n = 0; n < 3; n++) {
      var h = n * 2;
      g[n] = parseInt(a.slice(h, h + 2), 16);
    }
    u && (g[3] = parseInt(u, 16) / 255);
  } else if (a = t.match(e)) {
    for (a = a[1], u = a[3], n = 0; n < 3; n++)
      g[n] = parseInt(a[n] + a[n], 16);
    u && (g[3] = parseInt(u + u, 16) / 255);
  } else if (a = t.match(i)) {
    for (n = 0; n < 3; n++)
      g[n] = parseInt(a[n + 1], 0);
    a[4] && (a[5] ? g[3] = parseFloat(a[4]) * 0.01 : g[3] = parseFloat(a[4]));
  } else if (a = t.match(o)) {
    for (n = 0; n < 3; n++)
      g[n] = Math.round(parseFloat(a[n + 1]) * 2.55);
    a[4] && (a[5] ? g[3] = parseFloat(a[4]) * 0.01 : g[3] = parseFloat(a[4]));
  } else
    return (a = t.match(p)) ? a[1] === "transparent" ? [0, 0, 0, 0] : Mf.call(ki, a[1]) ? (g = ki[a[1]], g[3] = 1, g) : null : null;
  for (n = 0; n < 3; n++)
    g[n] = Zt(g[n], 0, 255);
  return g[3] = Zt(g[3], 0, 1), g;
};
at.get.hsl = function(t) {
  if (!t)
    return null;
  var e = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/, r = t.match(e);
  if (r) {
    var i = parseFloat(r[4]), o = (parseFloat(r[1]) % 360 + 360) % 360, p = Zt(parseFloat(r[2]), 0, 100), g = Zt(parseFloat(r[3]), 0, 100), a = Zt(isNaN(i) ? 1 : i, 0, 1);
    return [o, p, g, a];
  }
  return null;
};
at.get.hwb = function(t) {
  if (!t)
    return null;
  var e = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/, r = t.match(e);
  if (r) {
    var i = parseFloat(r[4]), o = (parseFloat(r[1]) % 360 + 360) % 360, p = Zt(parseFloat(r[2]), 0, 100), g = Zt(parseFloat(r[3]), 0, 100), a = Zt(isNaN(i) ? 1 : i, 0, 1);
    return [o, p, g, a];
  }
  return null;
};
at.to.hex = function() {
  var t = en(arguments);
  return "#" + xn(t[0]) + xn(t[1]) + xn(t[2]) + (t[3] < 1 ? xn(Math.round(t[3] * 255)) : "");
};
at.to.rgb = function() {
  var t = en(arguments);
  return t.length < 4 || t[3] === 1 ? "rgb(" + Math.round(t[0]) + ", " + Math.round(t[1]) + ", " + Math.round(t[2]) + ")" : "rgba(" + Math.round(t[0]) + ", " + Math.round(t[1]) + ", " + Math.round(t[2]) + ", " + t[3] + ")";
};
at.to.rgb.percent = function() {
  var t = en(arguments), e = Math.round(t[0] / 255 * 100), r = Math.round(t[1] / 255 * 100), i = Math.round(t[2] / 255 * 100);
  return t.length < 4 || t[3] === 1 ? "rgb(" + e + "%, " + r + "%, " + i + "%)" : "rgba(" + e + "%, " + r + "%, " + i + "%, " + t[3] + ")";
};
at.to.hsl = function() {
  var t = en(arguments);
  return t.length < 4 || t[3] === 1 ? "hsl(" + t[0] + ", " + t[1] + "%, " + t[2] + "%)" : "hsla(" + t[0] + ", " + t[1] + "%, " + t[2] + "%, " + t[3] + ")";
};
at.to.hwb = function() {
  var t = en(arguments), e = "";
  return t.length >= 4 && t[3] !== 1 && (e = ", " + t[3]), "hwb(" + t[0] + ", " + t[1] + "%, " + t[2] + "%" + e + ")";
};
at.to.keyword = function(t) {
  return Af[t.slice(0, 3)];
};
function Zt(t, e, r) {
  return Math.min(Math.max(e, t), r);
}
function xn(t) {
  var e = Math.round(t).toString(16).toUpperCase();
  return e.length < 2 ? "0" + e : e;
}
var $1 = {
  aliceblue: [240, 248, 255],
  antiquewhite: [250, 235, 215],
  aqua: [0, 255, 255],
  aquamarine: [127, 255, 212],
  azure: [240, 255, 255],
  beige: [245, 245, 220],
  bisque: [255, 228, 196],
  black: [0, 0, 0],
  blanchedalmond: [255, 235, 205],
  blue: [0, 0, 255],
  blueviolet: [138, 43, 226],
  brown: [165, 42, 42],
  burlywood: [222, 184, 135],
  cadetblue: [95, 158, 160],
  chartreuse: [127, 255, 0],
  chocolate: [210, 105, 30],
  coral: [255, 127, 80],
  cornflowerblue: [100, 149, 237],
  cornsilk: [255, 248, 220],
  crimson: [220, 20, 60],
  cyan: [0, 255, 255],
  darkblue: [0, 0, 139],
  darkcyan: [0, 139, 139],
  darkgoldenrod: [184, 134, 11],
  darkgray: [169, 169, 169],
  darkgreen: [0, 100, 0],
  darkgrey: [169, 169, 169],
  darkkhaki: [189, 183, 107],
  darkmagenta: [139, 0, 139],
  darkolivegreen: [85, 107, 47],
  darkorange: [255, 140, 0],
  darkorchid: [153, 50, 204],
  darkred: [139, 0, 0],
  darksalmon: [233, 150, 122],
  darkseagreen: [143, 188, 143],
  darkslateblue: [72, 61, 139],
  darkslategray: [47, 79, 79],
  darkslategrey: [47, 79, 79],
  darkturquoise: [0, 206, 209],
  darkviolet: [148, 0, 211],
  deeppink: [255, 20, 147],
  deepskyblue: [0, 191, 255],
  dimgray: [105, 105, 105],
  dimgrey: [105, 105, 105],
  dodgerblue: [30, 144, 255],
  firebrick: [178, 34, 34],
  floralwhite: [255, 250, 240],
  forestgreen: [34, 139, 34],
  fuchsia: [255, 0, 255],
  gainsboro: [220, 220, 220],
  ghostwhite: [248, 248, 255],
  gold: [255, 215, 0],
  goldenrod: [218, 165, 32],
  gray: [128, 128, 128],
  green: [0, 128, 0],
  greenyellow: [173, 255, 47],
  grey: [128, 128, 128],
  honeydew: [240, 255, 240],
  hotpink: [255, 105, 180],
  indianred: [205, 92, 92],
  indigo: [75, 0, 130],
  ivory: [255, 255, 240],
  khaki: [240, 230, 140],
  lavender: [230, 230, 250],
  lavenderblush: [255, 240, 245],
  lawngreen: [124, 252, 0],
  lemonchiffon: [255, 250, 205],
  lightblue: [173, 216, 230],
  lightcoral: [240, 128, 128],
  lightcyan: [224, 255, 255],
  lightgoldenrodyellow: [250, 250, 210],
  lightgray: [211, 211, 211],
  lightgreen: [144, 238, 144],
  lightgrey: [211, 211, 211],
  lightpink: [255, 182, 193],
  lightsalmon: [255, 160, 122],
  lightseagreen: [32, 178, 170],
  lightskyblue: [135, 206, 250],
  lightslategray: [119, 136, 153],
  lightslategrey: [119, 136, 153],
  lightsteelblue: [176, 196, 222],
  lightyellow: [255, 255, 224],
  lime: [0, 255, 0],
  limegreen: [50, 205, 50],
  linen: [250, 240, 230],
  magenta: [255, 0, 255],
  maroon: [128, 0, 0],
  mediumaquamarine: [102, 205, 170],
  mediumblue: [0, 0, 205],
  mediumorchid: [186, 85, 211],
  mediumpurple: [147, 112, 219],
  mediumseagreen: [60, 179, 113],
  mediumslateblue: [123, 104, 238],
  mediumspringgreen: [0, 250, 154],
  mediumturquoise: [72, 209, 204],
  mediumvioletred: [199, 21, 133],
  midnightblue: [25, 25, 112],
  mintcream: [245, 255, 250],
  mistyrose: [255, 228, 225],
  moccasin: [255, 228, 181],
  navajowhite: [255, 222, 173],
  navy: [0, 0, 128],
  oldlace: [253, 245, 230],
  olive: [128, 128, 0],
  olivedrab: [107, 142, 35],
  orange: [255, 165, 0],
  orangered: [255, 69, 0],
  orchid: [218, 112, 214],
  palegoldenrod: [238, 232, 170],
  palegreen: [152, 251, 152],
  paleturquoise: [175, 238, 238],
  palevioletred: [219, 112, 147],
  papayawhip: [255, 239, 213],
  peachpuff: [255, 218, 185],
  peru: [205, 133, 63],
  pink: [255, 192, 203],
  plum: [221, 160, 221],
  powderblue: [176, 224, 230],
  purple: [128, 0, 128],
  rebeccapurple: [102, 51, 153],
  red: [255, 0, 0],
  rosybrown: [188, 143, 143],
  royalblue: [65, 105, 225],
  saddlebrown: [139, 69, 19],
  salmon: [250, 128, 114],
  sandybrown: [244, 164, 96],
  seagreen: [46, 139, 87],
  seashell: [255, 245, 238],
  sienna: [160, 82, 45],
  silver: [192, 192, 192],
  skyblue: [135, 206, 235],
  slateblue: [106, 90, 205],
  slategray: [112, 128, 144],
  slategrey: [112, 128, 144],
  snow: [255, 250, 250],
  springgreen: [0, 255, 127],
  steelblue: [70, 130, 180],
  tan: [210, 180, 140],
  teal: [0, 128, 128],
  thistle: [216, 191, 216],
  tomato: [255, 99, 71],
  turquoise: [64, 224, 208],
  violet: [238, 130, 238],
  wheat: [245, 222, 179],
  white: [255, 255, 255],
  whitesmoke: [245, 245, 245],
  yellow: [255, 255, 0],
  yellowgreen: [154, 205, 50]
};
const Vi = $1, Df = {};
for (const t of Object.keys(Vi))
  Df[Vi[t]] = t;
const fe = {
  rgb: { channels: 3, labels: "rgb" },
  hsl: { channels: 3, labels: "hsl" },
  hsv: { channels: 3, labels: "hsv" },
  hwb: { channels: 3, labels: "hwb" },
  cmyk: { channels: 4, labels: "cmyk" },
  xyz: { channels: 3, labels: "xyz" },
  lab: { channels: 3, labels: "lab" },
  lch: { channels: 3, labels: "lch" },
  hex: { channels: 1, labels: ["hex"] },
  keyword: { channels: 1, labels: ["keyword"] },
  ansi16: { channels: 1, labels: ["ansi16"] },
  ansi256: { channels: 1, labels: ["ansi256"] },
  hcg: { channels: 3, labels: ["h", "c", "g"] },
  apple: { channels: 3, labels: ["r16", "g16", "b16"] },
  gray: { channels: 1, labels: ["gray"] }
};
var If = fe;
for (const t of Object.keys(fe)) {
  if (!("channels" in fe[t]))
    throw new Error("missing channels property: " + t);
  if (!("labels" in fe[t]))
    throw new Error("missing channel labels property: " + t);
  if (fe[t].labels.length !== fe[t].channels)
    throw new Error("channel and label counts mismatch: " + t);
  const { channels: e, labels: r } = fe[t];
  delete fe[t].channels, delete fe[t].labels, Object.defineProperty(fe[t], "channels", { value: e }), Object.defineProperty(fe[t], "labels", { value: r });
}
fe.rgb.hsl = function(t) {
  const e = t[0] / 255, r = t[1] / 255, i = t[2] / 255, o = Math.min(e, r, i), p = Math.max(e, r, i), g = p - o;
  let a, n;
  p === o ? a = 0 : e === p ? a = (r - i) / g : r === p ? a = 2 + (i - e) / g : i === p && (a = 4 + (e - r) / g), a = Math.min(a * 60, 360), a < 0 && (a += 360);
  const u = (o + p) / 2;
  return p === o ? n = 0 : u <= 0.5 ? n = g / (p + o) : n = g / (2 - p - o), [a, n * 100, u * 100];
};
fe.rgb.hsv = function(t) {
  let e, r, i, o, p;
  const g = t[0] / 255, a = t[1] / 255, n = t[2] / 255, u = Math.max(g, a, n), h = u - Math.min(g, a, n), s = function(l) {
    return (u - l) / 6 / h + 1 / 2;
  };
  return h === 0 ? (o = 0, p = 0) : (p = h / u, e = s(g), r = s(a), i = s(n), g === u ? o = i - r : a === u ? o = 1 / 3 + e - i : n === u && (o = 2 / 3 + r - e), o < 0 ? o += 1 : o > 1 && (o -= 1)), [
    o * 360,
    p * 100,
    u * 100
  ];
};
fe.rgb.hwb = function(t) {
  const e = t[0], r = t[1];
  let i = t[2];
  const o = fe.rgb.hsl(t)[0], p = 1 / 255 * Math.min(e, Math.min(r, i));
  return i = 1 - 1 / 255 * Math.max(e, Math.max(r, i)), [o, p * 100, i * 100];
};
fe.rgb.cmyk = function(t) {
  const e = t[0] / 255, r = t[1] / 255, i = t[2] / 255, o = Math.min(1 - e, 1 - r, 1 - i), p = (1 - e - o) / (1 - o) || 0, g = (1 - r - o) / (1 - o) || 0, a = (1 - i - o) / (1 - o) || 0;
  return [p * 100, g * 100, a * 100, o * 100];
};
function H1(t, e) {
  return (t[0] - e[0]) ** 2 + (t[1] - e[1]) ** 2 + (t[2] - e[2]) ** 2;
}
fe.rgb.keyword = function(t) {
  const e = Df[t];
  if (e)
    return e;
  let r = 1 / 0, i;
  for (const o of Object.keys(Vi)) {
    const p = Vi[o], g = H1(t, p);
    g < r && (r = g, i = o);
  }
  return i;
};
fe.keyword.rgb = function(t) {
  return Vi[t];
};
fe.rgb.xyz = function(t) {
  let e = t[0] / 255, r = t[1] / 255, i = t[2] / 255;
  e = e > 0.04045 ? ((e + 0.055) / 1.055) ** 2.4 : e / 12.92, r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92, i = i > 0.04045 ? ((i + 0.055) / 1.055) ** 2.4 : i / 12.92;
  const o = e * 0.4124 + r * 0.3576 + i * 0.1805, p = e * 0.2126 + r * 0.7152 + i * 0.0722, g = e * 0.0193 + r * 0.1192 + i * 0.9505;
  return [o * 100, p * 100, g * 100];
};
fe.rgb.lab = function(t) {
  const e = fe.rgb.xyz(t);
  let r = e[0], i = e[1], o = e[2];
  r /= 95.047, i /= 100, o /= 108.883, r = r > 8856e-6 ? r ** (1 / 3) : 7.787 * r + 16 / 116, i = i > 8856e-6 ? i ** (1 / 3) : 7.787 * i + 16 / 116, o = o > 8856e-6 ? o ** (1 / 3) : 7.787 * o + 16 / 116;
  const p = 116 * i - 16, g = 500 * (r - i), a = 200 * (i - o);
  return [p, g, a];
};
fe.hsl.rgb = function(t) {
  const e = t[0] / 360, r = t[1] / 100, i = t[2] / 100;
  let o, p, g;
  if (r === 0)
    return g = i * 255, [g, g, g];
  i < 0.5 ? o = i * (1 + r) : o = i + r - i * r;
  const a = 2 * i - o, n = [0, 0, 0];
  for (let u = 0; u < 3; u++)
    p = e + 1 / 3 * -(u - 1), p < 0 && p++, p > 1 && p--, 6 * p < 1 ? g = a + (o - a) * 6 * p : 2 * p < 1 ? g = o : 3 * p < 2 ? g = a + (o - a) * (2 / 3 - p) * 6 : g = a, n[u] = g * 255;
  return n;
};
fe.hsl.hsv = function(t) {
  const e = t[0];
  let r = t[1] / 100, i = t[2] / 100, o = r;
  const p = Math.max(i, 0.01);
  i *= 2, r *= i <= 1 ? i : 2 - i, o *= p <= 1 ? p : 2 - p;
  const g = (i + r) / 2, a = i === 0 ? 2 * o / (p + o) : 2 * r / (i + r);
  return [e, a * 100, g * 100];
};
fe.hsv.rgb = function(t) {
  const e = t[0] / 60, r = t[1] / 100;
  let i = t[2] / 100;
  const o = Math.floor(e) % 6, p = e - Math.floor(e), g = 255 * i * (1 - r), a = 255 * i * (1 - r * p), n = 255 * i * (1 - r * (1 - p));
  switch (i *= 255, o) {
    case 0:
      return [i, n, g];
    case 1:
      return [a, i, g];
    case 2:
      return [g, i, n];
    case 3:
      return [g, a, i];
    case 4:
      return [n, g, i];
    case 5:
      return [i, g, a];
  }
};
fe.hsv.hsl = function(t) {
  const e = t[0], r = t[1] / 100, i = t[2] / 100, o = Math.max(i, 0.01);
  let p, g;
  g = (2 - r) * i;
  const a = (2 - r) * o;
  return p = r * o, p /= a <= 1 ? a : 2 - a, p = p || 0, g /= 2, [e, p * 100, g * 100];
};
fe.hwb.rgb = function(t) {
  const e = t[0] / 360;
  let r = t[1] / 100, i = t[2] / 100;
  const o = r + i;
  let p;
  o > 1 && (r /= o, i /= o);
  const g = Math.floor(6 * e), a = 1 - i;
  p = 6 * e - g, (g & 1) !== 0 && (p = 1 - p);
  const n = r + p * (a - r);
  let u, h, s;
  switch (g) {
    default:
    case 6:
    case 0:
      u = a, h = n, s = r;
      break;
    case 1:
      u = n, h = a, s = r;
      break;
    case 2:
      u = r, h = a, s = n;
      break;
    case 3:
      u = r, h = n, s = a;
      break;
    case 4:
      u = n, h = r, s = a;
      break;
    case 5:
      u = a, h = r, s = n;
      break;
  }
  return [u * 255, h * 255, s * 255];
};
fe.cmyk.rgb = function(t) {
  const e = t[0] / 100, r = t[1] / 100, i = t[2] / 100, o = t[3] / 100, p = 1 - Math.min(1, e * (1 - o) + o), g = 1 - Math.min(1, r * (1 - o) + o), a = 1 - Math.min(1, i * (1 - o) + o);
  return [p * 255, g * 255, a * 255];
};
fe.xyz.rgb = function(t) {
  const e = t[0] / 100, r = t[1] / 100, i = t[2] / 100;
  let o, p, g;
  return o = e * 3.2406 + r * -1.5372 + i * -0.4986, p = e * -0.9689 + r * 1.8758 + i * 0.0415, g = e * 0.0557 + r * -0.204 + i * 1.057, o = o > 31308e-7 ? 1.055 * o ** (1 / 2.4) - 0.055 : o * 12.92, p = p > 31308e-7 ? 1.055 * p ** (1 / 2.4) - 0.055 : p * 12.92, g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92, o = Math.min(Math.max(0, o), 1), p = Math.min(Math.max(0, p), 1), g = Math.min(Math.max(0, g), 1), [o * 255, p * 255, g * 255];
};
fe.xyz.lab = function(t) {
  let e = t[0], r = t[1], i = t[2];
  e /= 95.047, r /= 100, i /= 108.883, e = e > 8856e-6 ? e ** (1 / 3) : 7.787 * e + 16 / 116, r = r > 8856e-6 ? r ** (1 / 3) : 7.787 * r + 16 / 116, i = i > 8856e-6 ? i ** (1 / 3) : 7.787 * i + 16 / 116;
  const o = 116 * r - 16, p = 500 * (e - r), g = 200 * (r - i);
  return [o, p, g];
};
fe.lab.xyz = function(t) {
  const e = t[0], r = t[1], i = t[2];
  let o, p, g;
  p = (e + 16) / 116, o = r / 500 + p, g = p - i / 200;
  const a = p ** 3, n = o ** 3, u = g ** 3;
  return p = a > 8856e-6 ? a : (p - 16 / 116) / 7.787, o = n > 8856e-6 ? n : (o - 16 / 116) / 7.787, g = u > 8856e-6 ? u : (g - 16 / 116) / 7.787, o *= 95.047, p *= 100, g *= 108.883, [o, p, g];
};
fe.lab.lch = function(t) {
  const e = t[0], r = t[1], i = t[2];
  let o;
  o = Math.atan2(i, r) * 360 / 2 / Math.PI, o < 0 && (o += 360);
  const g = Math.sqrt(r * r + i * i);
  return [e, g, o];
};
fe.lch.lab = function(t) {
  const e = t[0], r = t[1], o = t[2] / 360 * 2 * Math.PI, p = r * Math.cos(o), g = r * Math.sin(o);
  return [e, p, g];
};
fe.rgb.ansi16 = function(t, e = null) {
  const [r, i, o] = t;
  let p = e === null ? fe.rgb.hsv(t)[2] : e;
  if (p = Math.round(p / 50), p === 0)
    return 30;
  let g = 30 + (Math.round(o / 255) << 2 | Math.round(i / 255) << 1 | Math.round(r / 255));
  return p === 2 && (g += 60), g;
};
fe.hsv.ansi16 = function(t) {
  return fe.rgb.ansi16(fe.hsv.rgb(t), t[2]);
};
fe.rgb.ansi256 = function(t) {
  const e = t[0], r = t[1], i = t[2];
  return e === r && r === i ? e < 8 ? 16 : e > 248 ? 231 : Math.round((e - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(e / 255 * 5) + 6 * Math.round(r / 255 * 5) + Math.round(i / 255 * 5);
};
fe.ansi16.rgb = function(t) {
  let e = t % 10;
  if (e === 0 || e === 7)
    return t > 50 && (e += 3.5), e = e / 10.5 * 255, [e, e, e];
  const r = (~~(t > 50) + 1) * 0.5, i = (e & 1) * r * 255, o = (e >> 1 & 1) * r * 255, p = (e >> 2 & 1) * r * 255;
  return [i, o, p];
};
fe.ansi256.rgb = function(t) {
  if (t >= 232) {
    const p = (t - 232) * 10 + 8;
    return [p, p, p];
  }
  t -= 16;
  let e;
  const r = Math.floor(t / 36) / 5 * 255, i = Math.floor((e = t % 36) / 6) / 5 * 255, o = e % 6 / 5 * 255;
  return [r, i, o];
};
fe.rgb.hex = function(t) {
  const r = (((Math.round(t[0]) & 255) << 16) + ((Math.round(t[1]) & 255) << 8) + (Math.round(t[2]) & 255)).toString(16).toUpperCase();
  return "000000".substring(r.length) + r;
};
fe.hex.rgb = function(t) {
  const e = t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
  if (!e)
    return [0, 0, 0];
  let r = e[0];
  e[0].length === 3 && (r = r.split("").map((a) => a + a).join(""));
  const i = parseInt(r, 16), o = i >> 16 & 255, p = i >> 8 & 255, g = i & 255;
  return [o, p, g];
};
fe.rgb.hcg = function(t) {
  const e = t[0] / 255, r = t[1] / 255, i = t[2] / 255, o = Math.max(Math.max(e, r), i), p = Math.min(Math.min(e, r), i), g = o - p;
  let a, n;
  return g < 1 ? a = p / (1 - g) : a = 0, g <= 0 ? n = 0 : o === e ? n = (r - i) / g % 6 : o === r ? n = 2 + (i - e) / g : n = 4 + (e - r) / g, n /= 6, n %= 1, [n * 360, g * 100, a * 100];
};
fe.hsl.hcg = function(t) {
  const e = t[1] / 100, r = t[2] / 100, i = r < 0.5 ? 2 * e * r : 2 * e * (1 - r);
  let o = 0;
  return i < 1 && (o = (r - 0.5 * i) / (1 - i)), [t[0], i * 100, o * 100];
};
fe.hsv.hcg = function(t) {
  const e = t[1] / 100, r = t[2] / 100, i = e * r;
  let o = 0;
  return i < 1 && (o = (r - i) / (1 - i)), [t[0], i * 100, o * 100];
};
fe.hcg.rgb = function(t) {
  const e = t[0] / 360, r = t[1] / 100, i = t[2] / 100;
  if (r === 0)
    return [i * 255, i * 255, i * 255];
  const o = [0, 0, 0], p = e % 1 * 6, g = p % 1, a = 1 - g;
  let n = 0;
  switch (Math.floor(p)) {
    case 0:
      o[0] = 1, o[1] = g, o[2] = 0;
      break;
    case 1:
      o[0] = a, o[1] = 1, o[2] = 0;
      break;
    case 2:
      o[0] = 0, o[1] = 1, o[2] = g;
      break;
    case 3:
      o[0] = 0, o[1] = a, o[2] = 1;
      break;
    case 4:
      o[0] = g, o[1] = 0, o[2] = 1;
      break;
    default:
      o[0] = 1, o[1] = 0, o[2] = a;
  }
  return n = (1 - r) * i, [
    (r * o[0] + n) * 255,
    (r * o[1] + n) * 255,
    (r * o[2] + n) * 255
  ];
};
fe.hcg.hsv = function(t) {
  const e = t[1] / 100, r = t[2] / 100, i = e + r * (1 - e);
  let o = 0;
  return i > 0 && (o = e / i), [t[0], o * 100, i * 100];
};
fe.hcg.hsl = function(t) {
  const e = t[1] / 100, i = t[2] / 100 * (1 - e) + 0.5 * e;
  let o = 0;
  return i > 0 && i < 0.5 ? o = e / (2 * i) : i >= 0.5 && i < 1 && (o = e / (2 * (1 - i))), [t[0], o * 100, i * 100];
};
fe.hcg.hwb = function(t) {
  const e = t[1] / 100, r = t[2] / 100, i = e + r * (1 - e);
  return [t[0], (i - e) * 100, (1 - i) * 100];
};
fe.hwb.hcg = function(t) {
  const e = t[1] / 100, r = t[2] / 100, i = 1 - r, o = i - e;
  let p = 0;
  return o < 1 && (p = (i - o) / (1 - o)), [t[0], o * 100, p * 100];
};
fe.apple.rgb = function(t) {
  return [t[0] / 65535 * 255, t[1] / 65535 * 255, t[2] / 65535 * 255];
};
fe.rgb.apple = function(t) {
  return [t[0] / 255 * 65535, t[1] / 255 * 65535, t[2] / 255 * 65535];
};
fe.gray.rgb = function(t) {
  return [t[0] / 100 * 255, t[0] / 100 * 255, t[0] / 100 * 255];
};
fe.gray.hsl = function(t) {
  return [0, 0, t[0]];
};
fe.gray.hsv = fe.gray.hsl;
fe.gray.hwb = function(t) {
  return [0, 100, t[0]];
};
fe.gray.cmyk = function(t) {
  return [0, 0, 0, t[0]];
};
fe.gray.lab = function(t) {
  return [t[0], 0, 0];
};
fe.gray.hex = function(t) {
  const e = Math.round(t[0] / 100 * 255) & 255, i = ((e << 16) + (e << 8) + e).toString(16).toUpperCase();
  return "000000".substring(i.length) + i;
};
fe.rgb.gray = function(t) {
  return [(t[0] + t[1] + t[2]) / 3 / 255 * 100];
};
const qn = If;
function U1() {
  const t = {}, e = Object.keys(qn);
  for (let r = e.length, i = 0; i < r; i++)
    t[e[i]] = {
      distance: -1,
      parent: null
    };
  return t;
}
function W1(t) {
  const e = U1(), r = [t];
  for (e[t].distance = 0; r.length; ) {
    const i = r.pop(), o = Object.keys(qn[i]);
    for (let p = o.length, g = 0; g < p; g++) {
      const a = o[g], n = e[a];
      n.distance === -1 && (n.distance = e[i].distance + 1, n.parent = i, r.unshift(a));
    }
  }
  return e;
}
function Y1(t, e) {
  return function(r) {
    return e(t(r));
  };
}
function X1(t, e) {
  const r = [e[t].parent, t];
  let i = qn[e[t].parent][t], o = e[t].parent;
  for (; e[o].parent; )
    r.unshift(e[o].parent), i = Y1(qn[e[o].parent][o], i), o = e[o].parent;
  return i.conversion = r, i;
}
var G1 = function(t) {
  const e = W1(t), r = {}, i = Object.keys(e);
  for (let o = i.length, p = 0; p < o; p++) {
    const g = i[p];
    e[g].parent !== null && (r[g] = X1(g, e));
  }
  return r;
};
const $s = If, q1 = G1, Ur = {}, K1 = Object.keys($s);
function Z1(t) {
  const e = function(...r) {
    const i = r[0];
    return i == null ? i : (i.length > 1 && (r = i), t(r));
  };
  return "conversion" in t && (e.conversion = t.conversion), e;
}
function J1(t) {
  const e = function(...r) {
    const i = r[0];
    if (i == null)
      return i;
    i.length > 1 && (r = i);
    const o = t(r);
    if (typeof o == "object")
      for (let p = o.length, g = 0; g < p; g++)
        o[g] = Math.round(o[g]);
    return o;
  };
  return "conversion" in t && (e.conversion = t.conversion), e;
}
K1.forEach((t) => {
  Ur[t] = {}, Object.defineProperty(Ur[t], "channels", { value: $s[t].channels }), Object.defineProperty(Ur[t], "labels", { value: $s[t].labels });
  const e = q1(t);
  Object.keys(e).forEach((i) => {
    const o = e[i];
    Ur[t][i] = J1(o), Ur[t][i].raw = Z1(o);
  });
});
var Q1 = Ur;
const Wr = Of.exports, st = Q1, Rf = [
  "keyword",
  "gray",
  "hex"
], Hs = {};
for (const t of Object.keys(st))
  Hs[[...st[t].labels].sort().join("")] = t;
const Kn = {};
function Ye(t, e) {
  if (!(this instanceof Ye))
    return new Ye(t, e);
  if (e && e in Rf && (e = null), e && !(e in st))
    throw new Error("Unknown model: " + e);
  let r, i;
  if (t == null)
    this.model = "rgb", this.color = [0, 0, 0], this.valpha = 1;
  else if (t instanceof Ye)
    this.model = t.model, this.color = [...t.color], this.valpha = t.valpha;
  else if (typeof t == "string") {
    const o = Wr.get(t);
    if (o === null)
      throw new Error("Unable to parse color from string: " + t);
    this.model = o.model, i = st[this.model].channels, this.color = o.value.slice(0, i), this.valpha = typeof o.value[i] == "number" ? o.value[i] : 1;
  } else if (t.length > 0) {
    this.model = e || "rgb", i = st[this.model].channels;
    const o = Array.prototype.slice.call(t, 0, i);
    this.color = Us(o, i), this.valpha = typeof t[i] == "number" ? t[i] : 1;
  } else if (typeof t == "number")
    this.model = "rgb", this.color = [
      t >> 16 & 255,
      t >> 8 & 255,
      t & 255
    ], this.valpha = 1;
  else {
    this.valpha = 1;
    const o = Object.keys(t);
    "alpha" in t && (o.splice(o.indexOf("alpha"), 1), this.valpha = typeof t.alpha == "number" ? t.alpha : 0);
    const p = o.sort().join("");
    if (!(p in Hs))
      throw new Error("Unable to parse color from object: " + JSON.stringify(t));
    this.model = Hs[p];
    const { labels: g } = st[this.model], a = [];
    for (r = 0; r < g.length; r++)
      a.push(t[g[r]]);
    this.color = Us(a);
  }
  if (Kn[this.model])
    for (i = st[this.model].channels, r = 0; r < i; r++) {
      const o = Kn[this.model][r];
      o && (this.color[r] = o(this.color[r]));
    }
  this.valpha = Math.max(0, Math.min(1, this.valpha)), Object.freeze && Object.freeze(this);
}
Ye.prototype = {
  toString() {
    return this.string();
  },
  toJSON() {
    return this[this.model]();
  },
  string(t) {
    let e = this.model in Wr.to ? this : this.rgb();
    e = e.round(typeof t == "number" ? t : 1);
    const r = e.valpha === 1 ? e.color : [...e.color, this.valpha];
    return Wr.to[e.model](r);
  },
  percentString(t) {
    const e = this.rgb().round(typeof t == "number" ? t : 1), r = e.valpha === 1 ? e.color : [...e.color, this.valpha];
    return Wr.to.rgb.percent(r);
  },
  array() {
    return this.valpha === 1 ? [...this.color] : [...this.color, this.valpha];
  },
  object() {
    const t = {}, { channels: e } = st[this.model], { labels: r } = st[this.model];
    for (let i = 0; i < e; i++)
      t[r[i]] = this.color[i];
    return this.valpha !== 1 && (t.alpha = this.valpha), t;
  },
  unitArray() {
    const t = this.rgb().color;
    return t[0] /= 255, t[1] /= 255, t[2] /= 255, this.valpha !== 1 && t.push(this.valpha), t;
  },
  unitObject() {
    const t = this.rgb().object();
    return t.r /= 255, t.g /= 255, t.b /= 255, this.valpha !== 1 && (t.alpha = this.valpha), t;
  },
  round(t) {
    return t = Math.max(t || 0, 0), new Ye([...this.color.map(ty(t)), this.valpha], this.model);
  },
  alpha(t) {
    return t !== void 0 ? new Ye([...this.color, Math.max(0, Math.min(1, t))], this.model) : this.valpha;
  },
  red: je("rgb", 0, Ue(255)),
  green: je("rgb", 1, Ue(255)),
  blue: je("rgb", 2, Ue(255)),
  hue: je(["hsl", "hsv", "hsl", "hwb", "hcg"], 0, (t) => (t % 360 + 360) % 360),
  saturationl: je("hsl", 1, Ue(100)),
  lightness: je("hsl", 2, Ue(100)),
  saturationv: je("hsv", 1, Ue(100)),
  value: je("hsv", 2, Ue(100)),
  chroma: je("hcg", 1, Ue(100)),
  gray: je("hcg", 2, Ue(100)),
  white: je("hwb", 1, Ue(100)),
  wblack: je("hwb", 2, Ue(100)),
  cyan: je("cmyk", 0, Ue(100)),
  magenta: je("cmyk", 1, Ue(100)),
  yellow: je("cmyk", 2, Ue(100)),
  black: je("cmyk", 3, Ue(100)),
  x: je("xyz", 0, Ue(95.047)),
  y: je("xyz", 1, Ue(100)),
  z: je("xyz", 2, Ue(108.833)),
  l: je("lab", 0, Ue(100)),
  a: je("lab", 1),
  b: je("lab", 2),
  keyword(t) {
    return t !== void 0 ? new Ye(t) : st[this.model].keyword(this.color);
  },
  hex(t) {
    return t !== void 0 ? new Ye(t) : Wr.to.hex(this.rgb().round().color);
  },
  hexa(t) {
    if (t !== void 0)
      return new Ye(t);
    const e = this.rgb().round().color;
    let r = Math.round(this.valpha * 255).toString(16).toUpperCase();
    return r.length === 1 && (r = "0" + r), Wr.to.hex(e) + r;
  },
  rgbNumber() {
    const t = this.rgb().color;
    return (t[0] & 255) << 16 | (t[1] & 255) << 8 | t[2] & 255;
  },
  luminosity() {
    const t = this.rgb().color, e = [];
    for (const [r, i] of t.entries()) {
      const o = i / 255;
      e[r] = o <= 0.04045 ? o / 12.92 : ((o + 0.055) / 1.055) ** 2.4;
    }
    return 0.2126 * e[0] + 0.7152 * e[1] + 0.0722 * e[2];
  },
  contrast(t) {
    const e = this.luminosity(), r = t.luminosity();
    return e > r ? (e + 0.05) / (r + 0.05) : (r + 0.05) / (e + 0.05);
  },
  level(t) {
    const e = this.contrast(t);
    return e >= 7 ? "AAA" : e >= 4.5 ? "AA" : "";
  },
  isDark() {
    const t = this.rgb().color;
    return (t[0] * 2126 + t[1] * 7152 + t[2] * 722) / 1e4 < 128;
  },
  isLight() {
    return !this.isDark();
  },
  negate() {
    const t = this.rgb();
    for (let e = 0; e < 3; e++)
      t.color[e] = 255 - t.color[e];
    return t;
  },
  lighten(t) {
    const e = this.hsl();
    return e.color[2] += e.color[2] * t, e;
  },
  darken(t) {
    const e = this.hsl();
    return e.color[2] -= e.color[2] * t, e;
  },
  saturate(t) {
    const e = this.hsl();
    return e.color[1] += e.color[1] * t, e;
  },
  desaturate(t) {
    const e = this.hsl();
    return e.color[1] -= e.color[1] * t, e;
  },
  whiten(t) {
    const e = this.hwb();
    return e.color[1] += e.color[1] * t, e;
  },
  blacken(t) {
    const e = this.hwb();
    return e.color[2] += e.color[2] * t, e;
  },
  grayscale() {
    const t = this.rgb().color, e = t[0] * 0.3 + t[1] * 0.59 + t[2] * 0.11;
    return Ye.rgb(e, e, e);
  },
  fade(t) {
    return this.alpha(this.valpha - this.valpha * t);
  },
  opaquer(t) {
    return this.alpha(this.valpha + this.valpha * t);
  },
  rotate(t) {
    const e = this.hsl();
    let r = e.color[0];
    return r = (r + t) % 360, r = r < 0 ? 360 + r : r, e.color[0] = r, e;
  },
  mix(t, e) {
    if (!t || !t.rgb)
      throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof t);
    const r = t.rgb(), i = this.rgb(), o = e === void 0 ? 0.5 : e, p = 2 * o - 1, g = r.alpha() - i.alpha(), a = ((p * g === -1 ? p : (p + g) / (1 + p * g)) + 1) / 2, n = 1 - a;
    return Ye.rgb(
      a * r.red() + n * i.red(),
      a * r.green() + n * i.green(),
      a * r.blue() + n * i.blue(),
      r.alpha() * o + i.alpha() * (1 - o)
    );
  }
};
for (const t of Object.keys(st)) {
  if (Rf.includes(t))
    continue;
  const { channels: e } = st[t];
  Ye.prototype[t] = function(...r) {
    return this.model === t ? new Ye(this) : r.length > 0 ? new Ye(r, t) : new Ye([...ry(st[this.model][t].raw(this.color)), this.valpha], t);
  }, Ye[t] = function(...r) {
    let i = r[0];
    return typeof i == "number" && (i = Us(r, e)), new Ye(i, t);
  };
}
function ey(t, e) {
  return Number(t.toFixed(e));
}
function ty(t) {
  return function(e) {
    return ey(e, t);
  };
}
function je(t, e, r) {
  t = Array.isArray(t) ? t : [t];
  for (const i of t)
    (Kn[i] || (Kn[i] = []))[e] = r;
  return t = t[0], function(i) {
    let o;
    return i !== void 0 ? (r && (i = r(i)), o = this[t](), o.color[e] = i, o) : (o = this[t]().color[e], r && (o = r(o)), o);
  };
}
function Ue(t) {
  return function(e) {
    return Math.max(0, Math.min(t, e));
  };
}
function ry(t) {
  return Array.isArray(t) ? t : [t];
}
function Us(t, e) {
  for (let r = 0; r < e; r++)
    typeof t[r] != "number" && (t[r] = 0);
  return t;
}
var iy = Ye;
const ny = iy;
function oy(t) {
  const e = t.isDark ? Fs.find((o) => o.isDark) : Fs.find((o) => !o.isDark), r = {
    ...e,
    ...t,
    colors: {
      ...e == null ? void 0 : e.colors,
      ...t.colors
    }
  }, i = Object.entries(r.colors).map(
    ([o, p]) => [o, sy(p)]
  );
  return {
    id: r.name,
    name: r.name,
    colors: Object.fromEntries(i),
    is_dark: r.isDark
  };
}
function sy(t) {
  return t.endsWith("%") || t.split(" ").length === 3 ? t : ny(t).rgb().array().slice(0, 3).join(" ");
}
var xh;
let Ct = typeof document < "u" ? (xh = document.getElementById("root")) != null ? xh : document.body : void 0;
function ay(t) {
  Ct = t;
}
function ly(t, e) {
  Ct == null || Ct.style.setProperty(t, e);
}
function cy(t) {
  Object.entries(t.colors).forEach(([e, r]) => {
    ly(e, r);
  }), t.is_dark ? Ct.classList.add("dark") : Ct.classList.remove("dark");
}
const Rc = {
  top: 0,
  right: 0,
  bottom: 0,
  left: 0,
  width: 0,
  height: 0
}, oe = _f()(
  h1(
    Ef((t, e) => ({
      editor: null,
      fabric: null,
      bootstrapData: {},
      config: vf,
      zoom: 1,
      dirty: !1,
      original: {
        width: 1,
        height: 1
      },
      stageSize: Rc,
      canvasSize: Rc,
      canvasRef: null,
      activeTool: null,
      activeToolOverlay: null,
      loading: !1,
      openPanels: {
        newImage: !1,
        history: !1,
        objects: !1,
        export: !1
      },
      ...k1(t, e),
      ...D1(t, e),
      ...E1(t, e),
      ...O1(t, e),
      ...I1(t, e),
      ...R1(t, e),
      ...L1(t, e),
      setZoom: (r) => t((i) => {
        i.zoom = r;
      }),
      setOriginal: (r, i) => t((o) => {
        o.original = { width: r, height: i };
      }),
      setDirty: (r) => t((i) => {
        i.dirty = r;
      }),
      toggleLoading: (r) => t((i) => {
        i.loading = r;
      }),
      setStageSize: (r) => t((i) => {
        i.stageSize = r;
      }),
      setCanvasSize: (r) => t((i) => {
        i.canvasSize = r;
      }),
      setActiveTool: (r, i) => {
        t((o) => {
          o.activeTool = r, o.activeToolOverlay = i;
        });
      },
      setConfig: (r) => t((i) => {
        var u, h;
        const o = T1(r, e().config);
        i.config = o;
        const p = o.activeLanguage || "en", g = (u = o.languages) == null ? void 0 : u[p], a = (((h = o.ui) == null ? void 0 : h.themes) || []).map(
          (s) => oy(s)
        ), n = a.find(
          (s) => {
            var l;
            return s.id === ((l = o.ui) == null ? void 0 : l.activeTheme);
          }
        );
        n && cy(n), i.bootstrapData = {
          i18n: { language: p, name: p, id: 0, lines: g },
          themes: {
            all: a
          }
        };
      }),
      togglePanel: (r, i) => t((o) => {
        o.openPanels[r] = i != null ? i : !o.openPanels[r];
      }),
      applyChanges: async () => {
        var p;
        const r = e().activeTool;
        if (!r)
          return;
        const i = e()[r], o = await ((p = i == null ? void 0 : i.apply) == null ? void 0 : p.call(i));
        t((g) => {
          g.dirty = !1, g.activeTool = null, g.activeToolOverlay = null;
        }), o !== !1 && e().editor.tools.history.addHistoryItem({ name: r }), i == null || i.reset();
      },
      cancelChanges: async () => {
        const r = e().activeTool;
        if (!r)
          return;
        const i = e().dirty;
        t((p) => {
          p.dirty = !1, p.activeTool = null, p.activeToolOverlay = null;
        }), i && await e().editor.tools.history.reload();
        const o = e()[r];
        o == null || o.reset();
      },
      reset: () => {
        e().editor.tools.transform.resetStraightenAnchor(), t({
          activeTool: null,
          activeToolOverlay: null,
          zoom: 1,
          dirty: !1,
          loading: !1,
          openPanels: {
            newImage: !1,
            history: !1,
            objects: !1,
            export: !1
          }
        }), e().history.reset(), e().objects.reset(), e().filter.reset(), e().crop.reset(), e().frame.reset(), e().resize.reset(), e().corners.reset();
      }
    }))
  )
);
function O() {
  return oe.getState();
}
function I() {
  return O().editor.tools;
}
function he() {
  return O().fabric;
}
function Ws(t) {
  return I().canvas.clear(), I().frame.remove(), O().setConfig({ image: void 0, blankCanvasSize: void 0, ...t }), O().reset(), new Promise((e) => setTimeout(e));
}
async function Co(t) {
  return (await fetch(t)).json();
}
const Pr = {
  selectable: !1,
  evented: !1,
  lockMovementX: !0,
  lockMovementY: !0,
  lockRotation: !0,
  lockScalingX: !0,
  lockScalingY: !0,
  lockUniScaling: !0,
  hasControls: !1,
  hasBorders: !1,
  hasRotatingPoint: !1,
  strokeWidth: 0
};
function Zn(t = []) {
  var i;
  t = [
    ...Object.keys(Pr),
    "crossOrigin",
    "name",
    "displayName",
    "data",
    ...t
  ];
  const e = he().toJSON(
    t
  );
  e.objects = e.objects.filter((o) => !o.data.pixieInternal).map((o) => (o.type === "image" && O().config.crossOrigin && (o.crossOrigin = "anonymous"), lr(o) && (o.selectable = !0, o.lockMovementX = !1, o.lockMovementY = !1, o.lockUniScaling = !1), { ...o, data: o.data ? { ...o.data } : {} }));
  const r = I().frame.active.config ? {
    name: I().frame.active.config.name,
    sizePercent: I().frame.active.currentSizeInPercent
  } : null;
  return {
    canvas: e,
    editor: {
      frame: r,
      zoom: O().zoom,
      activeObjectId: ((i = O().objects.active) == null ? void 0 : i.id) || null
    },
    canvasWidth: O().original.width,
    canvasHeight: O().original.height
  };
}
function tl(t = null) {
  if (O().dirty)
    return;
  I().zoom.fitToScreen();
  const [e, r] = Lf(
    he().getActiveObject()
  );
  t ? O().setActiveTool(t, e === t ? r : null) : O().setActiveTool(e, r);
}
function Lf(t) {
  switch (t == null ? void 0 : t.name) {
    case Ne.Text:
      return [Pe.TEXT, mt.Text];
    case Ne.Sticker:
    case Ne.Image:
      return [Pe.STICKERS, mt.ActiveObject];
    case Ne.Shape:
      return [Pe.SHAPES, mt.ActiveObject];
    default:
      return [null, null];
  }
}
function rl() {
  return !O().config.image && !O().config.blankCanvasSize && (!he() || he().getObjects().length === 0);
}
const uy = `/*! tailwindcss v3.1.8 | MIT License | https://tailwindcss.com*/.pi *,.pi :after,.pi :before{border-color:rgb(var(--be-foreground-base)/var(--be-divider-opacity));border-style:solid;border-width:0;box-sizing:border-box}.pi :after,.pi :before{--tw-content:""}.pi hr{border-top-width:1px;color:inherit;height:0}.pi abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.pi h1,.pi h2,.pi h3,.pi h4,.pi h5,.pi h6{font-size:inherit;font-weight:inherit}.pi a{color:inherit;text-decoration:inherit}.pi b,.pi strong{font-weight:bolder}.pi code,.pi kbd,.pi pre,.pi samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}.pi small{font-size:80%}.pi sub,.pi sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}.pi sub{bottom:-.25em}.pi sup{top:-.5em}.pi table{border-collapse:collapse;border-color:inherit;text-indent:0}.pi button,.pi input,.pi optgroup,.pi select,.pi textarea{color:inherit;font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;margin:0;padding:0}.pi button,.pi select{text-transform:none}.pi [type=button],.pi [type=reset],.pi [type=submit],.pi button{-webkit-appearance:button;background-color:transparent;background-image:none}.pi :-moz-focusring{outline:auto}.pi :-moz-ui-invalid{box-shadow:none}.pi progress{vertical-align:baseline}.pi ::-webkit-inner-spin-button,.pi ::-webkit-outer-spin-button{height:auto}.pi [type=search]{-webkit-appearance:textfield;outline-offset:-2px}.pi ::-webkit-search-decoration{-webkit-appearance:none}.pi ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}.pi summary{display:list-item}.pi blockquote,.pi dd,.pi dl,.pi figure,.pi h1,.pi h2,.pi h3,.pi h4,.pi h5,.pi h6,.pi hr,.pi p,.pi pre{margin:0}.pi fieldset{margin:0;padding:0}.pi legend{padding:0}.pi menu,.pi ol,.pi ul{list-style:none;margin:0;padding:0}.pi textarea{resize:vertical}.pi input::-moz-placeholder,.pi textarea::-moz-placeholder{color:#9ca3af;opacity:1}.pi input::placeholder,.pi textarea::placeholder{color:#9ca3af;opacity:1}.pi [role=button],.pi button{cursor:pointer}.pi :disabled{cursor:default}.pi audio,.pi canvas,.pi embed,.pi iframe,.pi img,.pi object,.pi svg,.pi video{display:block;vertical-align:middle}.pi img,.pi video{height:auto;max-width:100%}.pi *,.pi :after,.pi :before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(147,197,253,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.pi ::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(147,197,253,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.pi .container{width:100%}.pi .\\!container{width:100%!important}@media (min-width:640px){.pi .container{max-width:640px}.pi .\\!container{max-width:640px!important}}@media (min-width:768px){.pi .container{max-width:768px}.pi .\\!container{max-width:768px!important}}@media (min-width:1024px){.pi .container{max-width:1024px}.pi .\\!container{max-width:1024px!important}}@media (min-width:1280px){.pi .container{max-width:1280px}.pi .\\!container{max-width:1280px!important}}@media (min-width:1536px){.pi .container{max-width:1536px}.pi .\\!container{max-width:1536px!important}}.pi .sr-only{clip:rect(0,0,0,0);border-width:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}.pi .pointer-events-none{pointer-events:none}.pi .pointer-events-auto{pointer-events:auto}.pi .visible{visibility:visible}.pi .\\!visible{visibility:visible!important}.pi .invisible{visibility:hidden}.pi .static{position:static}.pi .fixed{position:fixed}.pi .absolute{position:absolute}.pi .relative{position:relative}.pi .sticky{position:sticky}.pi .inset-0{bottom:0;top:0}.pi .inset-0,.pi .inset-x-0{left:0;right:0}.pi .right-2{right:2px}.pi .top-2{top:2px}.pi .top-0{top:0}.pi .left-0{left:0}.pi .left-16{left:16px}.pi .top-26{top:26px}.pi .-left-5{left:-5px}.pi .-top-5{top:-5px}.pi .bottom-0{bottom:0}.pi .-bottom-5{bottom:-5px}.pi .right-0{right:0}.pi .-right-5{right:-5px}.pi .bottom-20{bottom:20px}.pi .right-20{right:20px}.pi .top-24{top:24px}.pi .-bottom-14{bottom:-14px}.pi .left-30{left:30px}.pi .right-4{right:4px}.pi .top-1\\/2{top:50%}.pi .-bottom-20{bottom:-20px}.pi .left-1\\/2{left:50%}.pi .-bottom-10{bottom:-10px}.pi .-left-8{left:-8px}.pi .-left-80{left:-80px}.pi .-bottom-2{bottom:-2px}.pi .-right-2{right:-2px}.pi .isolate{isolation:isolate}.pi .z-20{z-index:20}.pi .z-modal{z-index:110}.pi .z-10{z-index:10}.pi .z-obj-box{z-index:20}.pi .z-navbar{z-index:40}.pi .z-tool-overlay{z-index:30}.pi .z-50,.pi .z-loading-indicator{z-index:50}.pi .z-popover{z-index:130}.pi .z-tray{z-index:120}.pi .z-toast{z-index:160}.pi .z-tooltip{z-index:150}.pi .z-cropzone{z-index:10}.pi .col-auto{grid-column:auto}.pi .m-auto{margin:auto}.pi .m-10{margin:10px}.pi .my-20{margin-bottom:20px;margin-top:20px}.pi .my-12{margin-bottom:12px;margin-top:12px}.pi .mx-auto{margin-left:auto;margin-right:auto}.pi .my-50{margin-bottom:50px;margin-top:50px}.pi .mx-14{margin-left:14px;margin-right:14px}.pi .my-30{margin-bottom:30px;margin-top:30px}.pi .my-24{margin-bottom:24px;margin-top:24px}.pi .my-80{margin-bottom:80px;margin-top:80px}.pi .my-32{margin-bottom:32px;margin-top:32px}.pi .my-40{margin-bottom:40px;margin-top:40px}.pi .my-8{margin-bottom:8px;margin-top:8px}.pi .my-10{margin-bottom:10px;margin-top:10px}.pi .my-100{margin-bottom:6.25rem;margin-top:6.25rem}.pi .mx-4{margin-left:4px;margin-right:4px}.pi .my-4{margin-bottom:4px;margin-top:4px}.pi .mx-8{margin-left:8px;margin-right:8px}.pi .mx-20{margin-left:20px;margin-right:20px}.pi .my-auto{margin-bottom:auto;margin-top:auto}.pi .mr-5{margin-right:5px}.pi .ml-auto{margin-left:auto}.pi .mr-20{margin-right:20px}.pi .mb-16{margin-bottom:16px}.pi .mr-10{margin-right:10px}.pi .mt-auto{margin-top:auto}.pi .mt-80{margin-top:80px}.pi .mt-30{margin-top:30px}.pi .mt-4{margin-top:4px}.pi .mb-30{margin-bottom:30px}.pi .mb-20{margin-bottom:20px}.pi .mr-auto{margin-right:auto}.pi .mr-24{margin-right:24px}.pi .mb-24{margin-bottom:24px}.pi .mb-14{margin-bottom:14px}.pi .mt-6{margin-top:6px}.pi .mt-12{margin-top:12px}.pi .mb-4{margin-bottom:4px}.pi .mt-14{margin-top:14px}.pi .ml-6{margin-left:6px}.pi .mr-14{margin-right:14px}.pi .mt-8{margin-top:8px}.pi .mb-10{margin-bottom:10px}.pi .mb-8{margin-bottom:8px}.pi .mt-20{margin-top:20px}.pi .mb-1{margin-bottom:1px}.pi .ml-10{margin-left:10px}.pi .mt-10{margin-top:10px}.pi .mt-2{margin-top:2px}.pi .mb-12{margin-bottom:12px}.pi .mb-40{margin-bottom:40px}.pi .mt-40{margin-top:40px}.pi .mb-32{margin-bottom:32px}.pi .mb-64{margin-bottom:64px}.pi .mt-32{margin-top:32px}.pi .mb-48{margin-bottom:48px}.pi .mt-50{margin-top:50px}.pi .mb-6{margin-bottom:6px}.pi .mt-60{margin-top:60px}.pi .-ml-1{margin-left:-1px}.pi .-ml-4{margin-left:-4px}.pi .mr-8{margin-right:8px}.pi .-mr-4{margin-right:-4px}.pi .ml-8{margin-left:8px}.pi .mt-16{margin-top:16px}.pi .mb-2{margin-bottom:2px}.pi .mt-24{margin-top:24px}.pi .-mt-2{margin-top:-2px}.pi .mt-36{margin-top:36px}.pi .mb-110{margin-bottom:110px}.pi .mt-18{margin-top:18px}.pi .mr-6{margin-right:6px}.pi .mr-16{margin-right:16px}.pi .ml-12{margin-left:12px}.pi .mr-4{margin-right:4px}.pi .mr-12{margin-right:12px}.pi .mr-2{margin-right:2px}.pi .mb-18{margin-bottom:18px}.pi .-ml-3{margin-left:-3px}.pi .-ml-12{margin-left:-12px}.pi .-ml-6{margin-left:-6px}.pi .box-content{box-sizing:content-box}.pi .block{display:block}.pi .inline-block{display:inline-block}.pi .inline{display:inline}.pi .flex{display:flex}.pi .inline-flex{display:inline-flex}.pi .table{display:table}.pi .table-cell{display:table-cell}.pi .table-row{display:table-row}.pi .grid{display:grid}.pi .\\!grid{display:grid!important}.pi .contents{display:contents}.pi .hidden{display:none}.pi .aspect-square{aspect-ratio:1/1}.pi .h-2\\/4{height:50%}.pi .h-full{height:100%}.pi .h-font{height:1em}.pi .h-1{height:1px}.pi .h-80{height:80px}.pi .h-400{height:25rem}.pi .h-50{height:50px}.pi .h-42{height:42px}.pi .h-54{height:3.375rem}.pi .h-8{height:8px}.pi .h-24{height:24px}.pi .h-36{height:36px}.pi .h-40{height:40px}.pi .h-20{height:20px}.pi .h-30{height:30px}.pi .h-84{height:84px}.pi .h-68{height:68px}.pi .h-32{height:32px}.pi .h-\\[54px\\]{height:54px}.pi .h-\\[186px\\]{height:186px}.pi .h-60{height:60px}.pi .h-18{height:18px}.pi .h-12{height:12px}.pi .h-26{height:26px}.pi .h-90{height:5.625rem}.pi .h-128{height:128px}.pi .h-6{height:6px}.pi .h-4{height:4px}.pi .h-48{height:48px}.pi .h-2{height:2px}.pi .h-16{height:16px}.pi .h-56{height:56px}.pi .h-64{height:64px}.pi .h-144{height:144px}.pi .h-100{height:6.25rem}.pi .h-max{height:-moz-max-content;height:max-content}.pi .h-px{height:1px}.pi .h-28{height:28px}.pi .h-92{height:92px}.pi .h-14{height:14px}.pi .h-38{height:2.375rem}.pi .h-22{height:22px}.pi .max-h-\\[calc\\(100vh-90px\\)\\]{max-height:calc(100vh - 90px)}.pi .max-h-\\[calc\\(100\\%-40px\\)\\]{max-height:calc(100% - 40px)}.pi .max-h-620{max-height:38.75rem}.pi .max-h-100{max-height:6.25rem}.pi .max-h-\\[36px\\]{max-height:36px}.pi .max-h-8{max-height:8px}.pi .max-h-tray{max-height:calc(var(--be-viewport-height, 100vh)*.9)}.pi .max-h-\\[calc\\(100\\%-30px\\)\\]{max-height:calc(100% - 30px)}.pi .max-h-40{max-height:40px}.pi .max-h-inherit{max-height:inherit}.pi .max-h-\\[583px\\]{max-height:583px}.pi .max-h-full{max-height:100%}.pi .max-h-26{max-height:26px}.pi .max-h-36{max-height:36px}.pi .max-h-dialog{max-height:calc(var(--be-viewport-height, 100vh)*.9)}.pi .max-h-240{max-height:240px}.pi .min-h-440{min-height:27.5rem}.pi .min-h-full{min-height:100%}.pi .min-h-\\[238px\\]{min-height:238px}.pi .min-h-86{min-height:86px}.pi .min-h-90{min-height:5.625rem}.pi .min-h-36{min-height:36px}.pi .min-h-42{min-height:42px}.pi .min-h-dialog{min-height:calc(var(--be-viewport-height, 100vh)*.9)}.pi .min-h-50{min-height:50px}.pi .min-h-\\[228px\\]{min-height:228px}.pi .min-h-30{min-height:30px}.pi .min-h-60{min-height:60px}.pi .w-max{width:-moz-max-content;width:max-content}.pi .w-full{width:100%}.pi .w-font{width:1em}.pi .w-80{width:80px}.pi .w-50{width:50px}.pi .w-8{width:8px}.pi .w-24{width:24px}.pi .w-36{width:36px}.pi .w-20{width:20px}.pi .w-30{width:30px}.pi .w-224{width:224px}.pi .w-68{width:68px}.pi .w-96{width:96px}.pi .w-144{width:144px}.pi .w-auto{width:auto}.pi .w-1{width:1px}.pi .w-240{width:240px}.pi .w-\\[168px\\]{width:168px}.pi .w-1\\/2{width:50%}.pi .w-384{width:384px}.pi .w-min{width:-moz-min-content;width:min-content}.pi .w-256{width:256px}.pi .w-18{width:18px}.pi .w-12{width:12px}.pi .w-42{width:42px}.pi .w-60{width:60px}.pi .\\!w-auto{width:auto!important}.pi .w-26{width:26px}.pi .w-32{width:32px}.pi .w-850{width:53.125rem}.pi .w-288{width:288px}.pi .w-320{width:320px}.pi .w-440{width:27.5rem}.pi .w-40{width:40px}.pi .w-64{width:64px}.pi .w-1\\/3{width:33.333333%}.pi .w-16{width:16px}.pi .w-56{width:56px}.pi .w-2{width:2px}.pi .w-110{width:110px}.pi .w-\\[4ch\\]{width:4ch}.pi .w-\\[233px\\]{width:233px}.pi .w-46{width:2.875rem}.pi .w-38{width:2.375rem}.pi .w-\\[210px\\]{width:210px}.pi .w-100{width:6.25rem}.pi .w-620{width:38.75rem}.pi .w-780{width:48.75rem}.pi .w-\\[calc\\(100\\%-40px\\)\\]{width:calc(100% - 40px)}.pi .w-px{width:1px}.pi .w-28{width:28px}.pi .w-90{width:5.625rem}.pi .w-14{width:14px}.pi .w-22{width:22px}.pi .w-280{width:17.5rem}.pi .min-w-0{min-width:0}.pi .min-w-320{min-width:320px}.pi .min-w-80{min-width:80px}.pi .min-w-224{min-width:224px}.pi .min-w-288{min-width:288px}.pi .min-w-240{min-width:240px}.pi .min-w-42{min-width:42px}.pi .min-w-90{min-width:5.625rem}.pi .min-w-180{min-width:11.25rem}.pi .min-w-128{min-width:128px}.pi .min-w-4{min-width:4px}.pi .min-w-192{min-width:192px}.pi .max-w-\\[calc\\(100vw-90px\\)\\]{max-width:calc(100vw - 90px)}.pi .max-w-max{max-width:-moz-max-content;max-width:max-content}.pi .max-w-280{max-width:17.5rem}.pi .max-w-620{max-width:38.75rem}.pi .max-w-440{max-width:27.5rem}.pi .max-w-\\[calc\\(100\\%-40px\\)\\]{max-width:calc(100% - 40px)}.pi .max-w-\\[90\\%\\]{max-width:90%}.pi .max-w-full{max-width:100%}.pi .max-w-500{max-width:31.25rem}.pi .max-w-\\[464px\\]{max-width:464px}.pi .max-w-180{max-width:11.25rem}.pi .max-w-400{max-width:25rem}.pi .max-w-780{max-width:48.75rem}.pi .max-w-375{max-width:375px}.pi .max-w-240{max-width:240px}.pi .max-w-320{max-width:320px}.pi .max-w-288{max-width:288px}.pi .max-w-112{max-width:112px}.pi .max-w-80{max-width:80px}.pi .max-w-850{max-width:53.125rem}.pi .max-w-580{max-width:36.25rem}.pi .max-w-dialog{max-width:calc(var(--be-viewport-width, 100vw)*.9)}.pi .max-w-950{max-width:59.375rem}.pi .flex-auto{flex:1 1 auto}.pi .flex-shrink-0,.pi .shrink-0{flex-shrink:0}.pi .flex-grow-0{flex-grow:0}.pi .origin-\\[100\\%\\]{transform-origin:100%}.pi .-translate-y-1\\/2{--tw-translate-y:-50%}.pi .-translate-x-1\\/2,.pi .-translate-y-1\\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .-translate-x-1\\/2{--tw-translate-x:-50%}.pi .rotate-180{--tw-rotate:180deg}.pi .rotate-0,.pi .rotate-180{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .rotate-0{--tw-rotate:0deg}.pi .rotate-45{--tw-rotate:45deg}.pi .rotate-45,.pi .rotate-90{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .rotate-90{--tw-rotate:90deg}.pi .transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .cursor-pointer{cursor:pointer}.pi .cursor-nwse-resize{cursor:nwse-resize}.pi .cursor-nesw-resize{cursor:nesw-resize}.pi .cursor-se-resize{cursor:se-resize}.pi .cursor-sw-resize{cursor:sw-resize}.pi .cursor-zoom-in{cursor:zoom-in}.pi .cursor-default{cursor:default}.pi .cursor-move{cursor:move}.pi .cursor-not-allowed{cursor:not-allowed}.pi .touch-none{touch-action:none}.pi .select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.pi .resize-none{resize:none}.pi .resize{resize:both}.pi .appearance-none{-webkit-appearance:none;-moz-appearance:none;appearance:none}.pi .break-inside-avoid{-moz-column-break-inside:avoid;break-inside:avoid}.pi .grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.pi .grid-cols-5-min-content{grid-template-columns:repeat(5,min-content)}.pi .flex-row{flex-direction:row}.pi .flex-col{flex-direction:column}.pi .flex-col-reverse{flex-direction:column-reverse}.pi .flex-wrap{flex-wrap:wrap}.pi .flex-nowrap{flex-wrap:nowrap}.pi .items-start{align-items:flex-start}.pi .items-center{align-items:center}.pi .items-stretch{align-items:stretch}.pi .justify-start{justify-content:flex-start}.pi .justify-end{justify-content:flex-end}.pi .justify-center{justify-content:center}.pi .justify-between{justify-content:space-between}.pi .gap-16{gap:16px}.pi .gap-20{gap:20px}.pi .gap-8{gap:8px}.pi .gap-14{gap:14px}.pi .gap-24{gap:24px}.pi .gap-6{gap:6px}.pi .gap-30{gap:30px}.pi .gap-10{gap:10px}.pi .gap-12{gap:12px}.pi .gap-4{gap:4px}.pi .gap-18{gap:18px}.pi .gap-32{gap:32px}.pi .gap-40{gap:40px}.pi .gap-64{gap:64px}.pi .gap-36{gap:36px}.pi .gap-x-10{-moz-column-gap:10px;column-gap:10px}.pi .space-y-10>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(10px*var(--tw-space-y-reverse));margin-top:calc(10px*(1 - var(--tw-space-y-reverse)))}.pi .self-stretch{align-self:stretch}.pi .overflow-auto{overflow:auto}.pi .overflow-hidden{overflow:hidden}.pi .overflow-visible{overflow:visible}.pi .overflow-scroll{overflow:scroll}.pi .overflow-x-auto{overflow-x:auto}.pi .overflow-y-auto{overflow-y:auto}.pi .overflow-x-hidden{overflow-x:hidden}.pi .overflow-y-hidden{overflow-y:hidden}.pi .truncate{overflow:hidden;white-space:nowrap}.pi .overflow-ellipsis,.pi .text-ellipsis,.pi .truncate{text-overflow:ellipsis}.pi .whitespace-normal{white-space:normal}.pi .whitespace-nowrap{white-space:nowrap}.pi .whitespace-pre-wrap{white-space:pre-wrap}.pi .break-words{overflow-wrap:break-word}.pi .rounded{border-radius:4px}.pi .rounded-md{border-radius:6px}.pi .rounded-full{border-radius:9999px}.pi .rounded-lg{border-radius:8px}.pi .rounded-none{border-radius:0}.pi .rounded-2xl{border-radius:16px}.pi .rounded-sm{border-radius:2px}.pi .rounded-\\[16px\\]{border-radius:16px}.pi .rounded-\\[64px\\]{border-radius:64px}.pi .rounded-\\[32px\\]{border-radius:32px}.pi .rounded-3xl{border-radius:24px}.pi .rounded-xl{border-radius:12px}.pi .rounded-t{border-top-left-radius:4px;border-top-right-radius:4px}.pi .rounded-l{border-bottom-left-radius:4px;border-top-left-radius:4px}.pi .rounded-r-md{border-bottom-right-radius:6px;border-top-right-radius:6px}.pi .rounded-l-md{border-bottom-left-radius:6px;border-top-left-radius:6px}.pi .rounded-r{border-bottom-right-radius:4px;border-top-right-radius:4px}.pi .rounded-l-none{border-bottom-left-radius:0;border-top-left-radius:0}.pi .rounded-r-none{border-bottom-right-radius:0;border-top-right-radius:0}.pi .rounded-l-full{border-bottom-left-radius:9999px;border-top-left-radius:9999px}.pi .rounded-r-full{border-bottom-right-radius:9999px;border-top-right-radius:9999px}.pi .rounded-tr-none{border-top-right-radius:0}.pi .rounded-br-none{border-bottom-right-radius:0}.pi .rounded-tl-none{border-top-left-radius:0}.pi .rounded-bl-none{border-bottom-left-radius:0}.pi .border{border-width:1px}.pi .border-2{border-width:2px}.pi .border-4{border-width:4px}.pi .border-\\[3px\\]{border-width:3px}.pi .border-y{border-bottom-width:1px;border-top-width:1px}.pi .border-r{border-right-width:1px}.pi .border-l-4{border-left-width:4px}.pi .border-b{border-bottom-width:1px}.pi .border-t-4{border-top-width:4px}.pi .border-r-4{border-right-width:4px}.pi .border-b-4{border-bottom-width:4px}.pi .border-t{border-top-width:1px}.pi .border-l{border-left-width:1px}.pi .border-dotted{border-style:dotted}.pi .border-none{border-style:none}.pi .border-divider{border-color:rgb(var(--be-foreground-base)/var(--be-divider-opacity))}.pi .border-white{--tw-border-opacity:1;border-color:rgb(255 255 255/var(--tw-border-opacity))}.pi .border-primary\\/50{border-color:rgb(var(--be-primary)/.5)}.pi .border-danger\\/50{border-color:#ef444480}.pi .border-transparent{border-color:transparent}.pi .border-primary{--tw-border-opacity:1;border-color:rgb(var(--be-primary)/var(--tw-border-opacity))}.pi .border-danger{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity))}.pi .border-chip{--tw-border-opacity:1;border-color:rgb(var(--be-background-chip)/var(--tw-border-opacity))}.pi .border-paper{--tw-border-opacity:1;border-color:rgb(var(--be-paper)/var(--tw-border-opacity))}.pi .border-background{--tw-border-opacity:1;border-color:rgb(var(--be-background)/var(--tw-border-opacity))}.pi .border-text-muted{border-color:rgb(var(--be-foreground-base)/var(--be-text-muted-opacity))}.pi .border-white\\/50{border-color:#ffffff80}.pi .border-l-primary{--tw-border-opacity:1;border-left-color:rgb(var(--be-primary)/var(--tw-border-opacity))}.pi .border-l-transparent{border-left-color:transparent}.pi .border-l-positive{--tw-border-opacity:1;border-left-color:rgb(34 197 94/var(--tw-border-opacity))}.pi .border-l-warning{--tw-border-opacity:1;border-left-color:rgb(243 164 50/var(--tw-border-opacity))}.pi .border-l-danger{--tw-border-opacity:1;border-left-color:rgb(239 68 68/var(--tw-border-opacity))}.pi .border-r-transparent{border-right-color:transparent}.pi .border-r-primary-light{--tw-border-opacity:1;border-right-color:rgb(var(--be-primary-light)/var(--tw-border-opacity))}.pi .border-b-primary{--tw-border-opacity:1;border-bottom-color:rgb(var(--be-primary)/var(--tw-border-opacity))}.pi .bg-background{--tw-bg-opacity:1;background-color:rgb(var(--be-background)/var(--tw-bg-opacity))}.pi .bg-divider{background-color:rgb(var(--be-foreground-base)/var(--be-divider-opacity))}.pi .bg-paper{--tw-bg-opacity:1;background-color:rgb(var(--be-paper)/var(--tw-bg-opacity))}.pi .bg{--tw-bg-opacity:1;background-color:rgb(var(--be-background)/var(--tw-bg-opacity))}.pi .bg-alt{--tw-bg-opacity:1;background-color:rgb(var(--be-background-alt)/var(--tw-bg-opacity))}.pi .bg-primary\\/hover{background-color:rgb(var(--be-primary)/var(--be-hover-opacity))}.pi .bg-primary{--tw-bg-opacity:1;background-color:rgb(var(--be-primary)/var(--tw-bg-opacity))}.pi .bg-positive\\/focus{background-color:rgb(34 197 94/var(--be-focus-opacity))}.pi .bg-warning\\/focus{background-color:rgb(243 164 50/var(--be-focus-opacity))}.pi .bg-danger\\/focus{background-color:rgb(239 68 68/var(--be-focus-opacity))}.pi .bg-primary\\/focus{background-color:rgb(var(--be-primary)/var(--be-focus-opacity))}.pi .bg-primary\\/5{background-color:rgb(var(--be-primary)/.05)}.pi .bg-controls{--tw-bg-opacity:1;background-color:rgb(50 50 50/var(--tw-bg-opacity))}.pi .bg-chip{--tw-bg-opacity:1;background-color:rgb(var(--be-background-chip)/var(--tw-bg-opacity))}.pi .bg-primary-light\\/20{background-color:rgb(var(--be-primary-light)/.2)}.pi .bg-primary\\/selected{background-color:rgb(var(--be-primary)/var(--be-selected-opacity))}.pi .bg-warning{--tw-bg-opacity:1;background-color:rgb(243 164 50/var(--tw-bg-opacity))}.pi .bg-transparent{background-color:transparent}.pi .bg-danger{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity))}.pi .bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.pi .bg-toast{--tw-bg-opacity:1;background-color:rgb(50 50 50/var(--tw-bg-opacity))}.pi .bg-focus{background-color:rgb(var(--be-foreground-base)/var(--be-focus-opacity))}.pi .bg-black\\/30{background-color:#0000004d}.pi .bg-primary-light{--tw-bg-opacity:1;background-color:rgb(var(--be-primary-light)/var(--tw-bg-opacity))}.pi .bg-fg-base\\/4{background-color:rgb(var(--be-foreground-base)/4%)}.pi .bg-positive{--tw-bg-opacity:1;background-color:rgb(34 197 94/var(--tw-bg-opacity))}.pi .bg-inherit{background-color:inherit}.pi .bg-background\\/70{background-color:rgb(var(--be-background)/.7)}.pi .bg-envato{--tw-bg-opacity:1;background-color:rgb(108 161 43/var(--tw-bg-opacity))}.pi .bg-disabled{background-color:rgb(var(--be-foreground-base)/var(--be-disabled-bg-opacity))}.pi .bg-disabled-fg{background-color:rgb(var(--be-foreground-base)/var(--be-disabled-fg-opacity))}.pi .bg-slider-disabled{--tw-bg-opacity:1;background-color:rgb(189 189 189/var(--tw-bg-opacity))}.pi .bg-primary-dark{--tw-bg-opacity:1;background-color:rgb(var(--be-primary-dark)/var(--tw-bg-opacity))}.pi .bg-white\\/50{background-color:#ffffff80}.pi .bg-black\\/50{background-color:#00000080}.pi .bg-primary-light\\/40{background-color:rgb(var(--be-primary-light)/.4)}.pi .bg-positive-lighter{--tw-bg-opacity:1;background-color:rgb(187 247 208/var(--tw-bg-opacity))}.pi .bg-danger-lighter{--tw-bg-opacity:1;background-color:rgb(254 202 202/var(--tw-bg-opacity))}.pi .bg-opacity-95{--tw-bg-opacity:.95}.pi .bg-no-repeat{background-repeat:no-repeat}.pi .fill-current{fill:currentColor}.pi .fill-transparent{fill:transparent}.pi .stroke-current{stroke:currentColor}.pi .object-contain{-o-object-fit:contain;object-fit:contain}.pi .object-cover{-o-object-fit:cover;object-fit:cover}.pi .p-0{padding:0}.pi .p-14{padding:14px}.pi .p-16{padding:16px}.pi .p-24{padding:24px}.pi .p-10{padding:10px}.pi .p-8{padding:8px}.pi .p-6{padding:6px}.pi .p-12{padding:12px}.pi .p-20{padding:20px}.pi .p-4{padding:4px}.pi .p-18{padding:18px}.pi .p-40{padding:40px}.pi .p-2{padding:2px}.pi .px-24{padding-left:24px;padding-right:24px}.pi .py-20{padding-bottom:20px;padding-top:20px}.pi .px-6{padding-left:6px;padding-right:6px}.pi .px-8{padding-left:8px;padding-right:8px}.pi .py-12{padding-bottom:12px;padding-top:12px}.pi .px-16{padding-left:16px;padding-right:16px}.pi .py-14{padding-bottom:14px;padding-top:14px}.pi .px-14{padding-left:14px;padding-right:14px}.pi .px-20{padding-left:20px;padding-right:20px}.pi .px-32{padding-left:32px;padding-right:32px}.pi .py-10{padding-bottom:10px;padding-top:10px}.pi .px-4{padding-left:4px;padding-right:4px}.pi .px-10{padding-left:10px;padding-right:10px}.pi .py-2{padding-bottom:2px;padding-top:2px}.pi .px-5vw{padding-left:5vw;padding-right:5vw}.pi .px-12{padding-left:12px;padding-right:12px}.pi .py-\\[9px\\]{padding-bottom:9px;padding-top:9px}.pi .px-40{padding-left:40px;padding-right:40px}.pi .py-32{padding-bottom:32px;padding-top:32px}.pi .px-28{padding-left:28px;padding-right:28px}.pi .py-56{padding-bottom:56px;padding-top:56px}.pi .py-28{padding-bottom:28px;padding-top:28px}.pi .py-90{padding-bottom:5.625rem;padding-top:5.625rem}.pi .py-4{padding-bottom:4px;padding-top:4px}.pi .px-18{padding-left:18px;padding-right:18px}.pi .px-22{padding-left:22px;padding-right:22px}.pi .px-26{padding-left:26px;padding-right:26px}.pi .py-8{padding-bottom:8px;padding-top:8px}.pi .py-96{padding-bottom:96px;padding-top:96px}.pi .py-6{padding-bottom:6px;padding-top:6px}.pi .py-3{padding-bottom:3px;padding-top:3px}.pi .py-5{padding-bottom:5px;padding-top:5px}.pi .py-40{padding-bottom:40px;padding-top:40px}.pi .pt-14{padding-top:14px}.pi .pt-24{padding-top:24px}.pi .pb-12{padding-bottom:12px}.pi .pt-26{padding-top:26px}.pi .pb-16{padding-bottom:16px}.pi .pb-24{padding-bottom:24px}.pi .pt-50{padding-top:50px}.pi .pt-20{padding-top:20px}.pi .pb-10{padding-bottom:10px}.pi .pb-4{padding-bottom:4px}.pi .pr-10{padding-right:10px}.pi .pl-10{padding-left:10px}.pi .pb-20{padding-bottom:20px}.pi .pb-30{padding-bottom:30px}.pi .pt-30{padding-top:30px}.pi .pl-8{padding-left:8px}.pi .pb-14{padding-bottom:14px}.pi .pl-14{padding-left:14px}.pi .pt-54{padding-top:3.375rem}.pi .pb-28{padding-bottom:28px}.pi .pb-48{padding-bottom:48px}.pi .pb-safe-area{padding-bottom:env(safe-area-inset-bottom)}.pi .pl-24{padding-left:24px}.pi .pr-16{padding-right:16px}.pi .pr-24{padding-right:24px}.pi .pl-16{padding-left:16px}.pi .pr-6{padding-right:6px}.pi .pb-18{padding-bottom:18px}.pi .pt-6{padding-top:6px}.pi .pt-16{padding-top:16px}.pi .pt-10{padding-top:10px}.pi .pl-12{padding-left:12px}.pi .pr-12{padding-right:12px}.pi .pb-6{padding-bottom:6px}.pi .pt-42{padding-top:42px}.pi .pb-32{padding-bottom:32px}.pi .pt-70{padding-top:70px}.pi .pt-40{padding-top:40px}.pi .pr-8{padding-right:8px}.pi .pl-46{padding-left:2.875rem}.pi .pr-46{padding-right:2.875rem}.pi .pl-6{padding-left:6px}.pi .pl-18{padding-left:18px}.pi .pr-18{padding-right:18px}.pi .text-left{text-align:left}.pi .text-center{text-align:center}.pi .text-right{text-align:right}.pi .align-top{vertical-align:top}.pi .align-middle{vertical-align:middle}.pi .text-sm{font-size:14px;line-height:20px}.pi .text-xs{font-size:12px;line-height:16px}.pi .text-xl{font-size:20px;line-height:28px}.pi .text-6xl{font-size:60px;line-height:1}.pi .text-2xl{font-size:24px;line-height:32px}.pi .text-3xl{font-size:30px;line-height:36px}.pi .text-base{font-size:16px;line-height:24px}.pi .text-lg{font-size:18px;line-height:28px}.pi .text-4xl{font-size:36px;line-height:40px}.pi .font-medium{font-weight:500}.pi .font-semibold{font-weight:600}.pi .font-light{font-weight:300}.pi .font-bold{font-weight:700}.pi .font-normal{font-weight:400}.pi .uppercase{text-transform:uppercase}.pi .capitalize{text-transform:capitalize}.pi .italic{font-style:italic}.pi .tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.pi .leading-none{line-height:1}.pi .leading-5{line-height:1.25rem}.pi .tracking-wide{letter-spacing:.025em}.pi .text,.pi .text-main{color:rgb(var(--be-foreground-base)/var(--be-text-main-opacity))}.pi .text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.pi .text-muted{color:rgb(var(--be-foreground-base)/var(--be-text-muted-opacity))}.pi .text-positive{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity))}.pi .text-danger{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity))}.pi .text-primary{--tw-text-opacity:1;color:rgb(var(--be-primary)/var(--tw-text-opacity))}.pi .\\!text{color:rgb(var(--be-foreground-base)/var(--be-text-main-opacity))!important}.pi .text-facebook{--tw-text-opacity:1;color:rgb(59 89 152/var(--tw-text-opacity))}.pi .text-twitter{--tw-text-opacity:1;color:rgb(29 161 242/var(--tw-text-opacity))}.pi .text-positive-darker{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity))}.pi .text-disabled{color:rgb(var(--be-foreground-base)/var(--be-disabled-fg-opacity))}.pi .text-on-primary{--tw-text-opacity:1;color:rgb(var(--be-on-primary)/var(--tw-text-opacity))}.pi .text-primary-light{--tw-text-opacity:1;color:rgb(var(--be-primary-light)/var(--tw-text-opacity))}.pi .text-primary\\/40{color:rgb(var(--be-primary)/.4)}.pi .text-black\\/30{color:#0000004d}.pi .text-danger-darker{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity))}.pi .underline{text-decoration-line:underline}.pi .no-underline{text-decoration-line:none}.pi .caret-transparent{caret-color:transparent}.pi .opacity-0{opacity:0}.pi .opacity-100{opacity:1}.pi .opacity-80{opacity:.8}.pi .opacity-90{opacity:.9}.pi .shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.pi .shadow,.pi .shadow-lg{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.pi .shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.pi .shadow-xl{--tw-shadow:0 20px 25px -5px rgba(0,0,0,.1),0 8px 10px -6px rgba(0,0,0,.1);--tw-shadow-colored:0 20px 25px -5px var(--tw-shadow-color),0 8px 10px -6px var(--tw-shadow-color)}.pi .shadow-\\[15px_0_30px_0_rgb\\(0_0_0_\\/_18\\%\\)\\],.pi .shadow-xl{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.pi .shadow-\\[15px_0_30px_0_rgb\\(0_0_0_\\/_18\\%\\)\\]{--tw-shadow:15px 0 30px 0 rgba(0,0,0,.18);--tw-shadow-colored:15px 0 30px 0 var(--tw-shadow-color)}.pi .shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color)}.pi .shadow-md,.pi .shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.pi .shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.pi .shadow-2xl{--tw-shadow:0 25px 50px -12px rgba(0,0,0,.25);--tw-shadow-colored:0 25px 50px -12px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.pi .outline-none{outline:2px solid transparent;outline-offset:2px}.pi .outline{outline-color:rgb(var(--be-primary-lighter)/1);outline-style:solid;outline-width:2px}.pi .ring{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.pi .ring-inset{--tw-ring-inset:inset}.pi .ring-offset-4{--tw-ring-offset-width:4px}.pi .blur{--tw-blur:blur(8px)}.pi .blur,.pi .grayscale{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.pi .grayscale{--tw-grayscale:grayscale(100%)}.pi .invert{--tw-invert:invert(100%)}.pi .invert,.pi .sepia{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.pi .sepia{--tw-sepia:sepia(100%)}.pi .filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.pi .transition-transform{transition-duration:.15s;transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .transition-shadow{transition-duration:.15s;transition-property:box-shadow;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .transition-opacity{transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .transition-bg-color{transition-duration:.15s;transition-property:background-color;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .transition-button{transition-duration:.15s;transition-property:background-color,box-shadow,border-color,color;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .transition-width{transition-duration:.15s;transition-property:width;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .duration-200{transition-duration:.2s}.pi .duration-100{transition-duration:.1s}.pi .will-change-\\[width\\]{will-change:width}.pi .will-change-transform{will-change:transform}.pi .icon-2xs{font-size:.75rem}.pi .icon-xs{font-size:1rem}.pi .icon-sm{font-size:1.25rem}.pi .icon-md{font-size:1.5rem}.pi .icon-lg{font-size:2.1875rem}.pi .icon-xl{font-size:2.6875rem}.pi .col-w-1{flex:1 0 0px}.pi .col-w-2{flex:2 0 0px}.pi .col-w-3{flex:3 0 0px}.pi .no-tap-highlight{-webkit-tap-highlight-color:transparent}@media only screen and (min-device-width:768px){.pi .tiny-scrollbar{scrollbar-color:rgba(0,0,0,.2) transparent;scrollbar-width:thin}.pi .tiny-scrollbar::-webkit-scrollbar{background-color:transparent;height:6px;width:6px}.pi .tiny-scrollbar::-webkit-scrollbar-thumb{background-color:rgb(var(--be-foreground-base)/.2);border-radius:10px}.pi .tiny-scrollbar::-webkit-scrollbar-track-piece:start{background:transparent}.pi .tiny-scrollbar::-webkit-scrollbar-track-piece:end{background:transparent}}.pi .hide-scrollbar{scrollbar-width:none}.pi .hide-scrollbar::-webkit-scrollbar{background:transparent;height:0;width:0}.pi .svg-icon{fill:currentColor;display:inline-block;flex-shrink:0;transition-duration:.15s;transition-property:transform,fill;transition-timing-function:cubic-bezier(.4,0,.2,1);-webkit-user-select:none;-moz-user-select:none;user-select:none}.pi .cropzone:not(.moving) .cropzone-transition{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .first-letter\\:capitalize:first-letter{text-transform:capitalize}.pi .file\\:mr-10::file-selector-button{margin-right:10px}.pi .file\\:h-24::file-selector-button{height:24px}.pi .file\\:rounded::file-selector-button{border-radius:4px}.pi .file\\:border-none::file-selector-button{border-style:none}.pi .file\\:bg-primary::file-selector-button{--tw-bg-opacity:1;background-color:rgb(var(--be-primary)/var(--tw-bg-opacity))}.pi .file\\:px-10::file-selector-button{padding-left:10px;padding-right:10px}.pi .file\\:text-sm::file-selector-button{font-size:14px;line-height:20px}.pi .file\\:font-semibold::file-selector-button{font-weight:600}.pi .file\\:text-on-primary::file-selector-button{--tw-text-opacity:1;color:rgb(var(--be-on-primary)/var(--tw-text-opacity))}.pi .before\\:absolute:before{content:var(--tw-content);position:absolute}.pi .before\\:left-0:before{content:var(--tw-content);left:0}.pi .before\\:top-1\\/2:before{content:var(--tw-content);top:50%}.pi .before\\:z-10:before{content:var(--tw-content);z-index:10}.pi .before\\:block:before{content:var(--tw-content);display:block}.pi .before\\:h-1:before{content:var(--tw-content);height:1px}.pi .before\\:h-full:before{content:var(--tw-content);height:100%}.pi .before\\:h-28:before{content:var(--tw-content);height:28px}.pi .before\\:h-22:before{content:var(--tw-content);height:22px}.pi .before\\:h-18:before{content:var(--tw-content);height:18px}.pi .before\\:h-12:before{content:var(--tw-content);height:12px}.pi .before\\:h-14:before{content:var(--tw-content);height:14px}.pi .before\\:w-full:before{content:var(--tw-content);width:100%}.pi .before\\:w-28:before{content:var(--tw-content);width:28px}.pi .before\\:w-22:before{content:var(--tw-content);width:22px}.pi .before\\:w-18:before{content:var(--tw-content);width:18px}.pi .before\\:w-12:before{content:var(--tw-content);width:12px}.pi .before\\:w-14:before{content:var(--tw-content);width:14px}.pi .before\\:-translate-y-1\\/2:before{--tw-translate-y:-50%}.pi .before\\:-translate-y-1\\/2:before,.pi .before\\:translate-x-2:before{content:var(--tw-content);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .before\\:translate-x-2:before{--tw-translate-x:2px}.pi .before\\:scale-10:before{--tw-scale-x:.1;--tw-scale-y:.1;content:var(--tw-content);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .before\\:rounded-full:before{border-radius:9999px;content:var(--tw-content)}.pi .before\\:rounded-3xl:before{border-radius:24px;content:var(--tw-content)}.pi .before\\:border:before{border-width:1px;content:var(--tw-content)}.pi .before\\:bg-divider:before{background-color:rgb(var(--be-foreground-base)/var(--be-divider-opacity));content:var(--tw-content)}.pi .before\\:bg-primary:before{--tw-bg-opacity:1;background-color:rgb(var(--be-primary)/var(--tw-bg-opacity));content:var(--tw-content)}.pi .before\\:bg-white:before{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity));content:var(--tw-content)}.pi .before\\:opacity-0:before{content:var(--tw-content);opacity:0}.pi .before\\:transition:before{content:var(--tw-content);transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .before\\:transition-transform:before{content:var(--tw-content);transition-duration:.15s;transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1)}.pi .before\\:duration-200:before{content:var(--tw-content);transition-duration:.2s}.pi .before\\:content-\\[\\\\\\\\00a0\\]:before{--tw-content:\\\\00a0;content:var(--tw-content)}.pi .after\\:pointer-events-none:after{content:var(--tw-content);pointer-events:none}.pi .after\\:absolute:after{content:var(--tw-content);position:absolute}.pi .after\\:inset-0:after{bottom:0;content:var(--tw-content);left:0;right:0;top:0}.pi .first\\:capitalize:first-child{text-transform:capitalize}.pi .checked\\:border-primary:checked{--tw-border-opacity:1;border-color:rgb(var(--be-primary)/var(--tw-border-opacity))}.pi .checked\\:border-danger:checked{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity))}.pi .checked\\:bg-primary:checked{--tw-bg-opacity:1;background-color:rgb(var(--be-primary)/var(--tw-bg-opacity))}.pi .checked\\:bg-danger:checked{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity))}.pi .checked\\:before\\:translate-x-36:checked:before{--tw-translate-x:36px}.pi .checked\\:before\\:translate-x-30:checked:before,.pi .checked\\:before\\:translate-x-36:checked:before{content:var(--tw-content);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .checked\\:before\\:translate-x-30:checked:before{--tw-translate-x:30px}.pi .checked\\:before\\:translate-x-24:checked:before{--tw-translate-x:24px}.pi .checked\\:before\\:translate-x-16:checked:before,.pi .checked\\:before\\:translate-x-24:checked:before{content:var(--tw-content);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .checked\\:before\\:translate-x-16:checked:before{--tw-translate-x:16px}.pi .checked\\:before\\:translate-x-20:checked:before{--tw-translate-x:20px}.pi .checked\\:before\\:scale-\\[\\.65\\]:checked:before,.pi .checked\\:before\\:translate-x-20:checked:before{content:var(--tw-content);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .checked\\:before\\:scale-\\[\\.65\\]:checked:before{--tw-scale-x:.65;--tw-scale-y:.65}.pi .checked\\:before\\:border-white:checked:before{--tw-border-opacity:1;border-color:rgb(255 255 255/var(--tw-border-opacity));content:var(--tw-content)}.pi .checked\\:before\\:opacity-100:checked:before{content:var(--tw-content);opacity:1}.pi .focus-within\\:border-primary\\/60:focus-within{border-color:rgb(var(--be-primary)/.6)}.pi .focus-within\\:ring:focus-within{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.pi .focus-within\\:ring-primary\\/focus:focus-within{--tw-ring-color:rgb(var(--be-primary)/var(--be-focus-opacity))}.pi .focus-within\\:ring-primary-light:focus-within{--tw-ring-opacity:1;--tw-ring-color:rgb(var(--be-primary-light)/var(--tw-ring-opacity))}.pi .hover\\:scale-105:hover{--tw-scale-x:1.05;--tw-scale-y:1.05}.pi .hover\\:scale-105:hover,.pi .hover\\:scale-110:hover{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.pi .hover\\:scale-110:hover{--tw-scale-x:1.1;--tw-scale-y:1.1}.pi .hover\\:cursor-move:hover{cursor:move}.pi .hover\\:border-primary:hover{--tw-border-opacity:1;border-color:rgb(var(--be-primary)/var(--tw-border-opacity))}.pi .hover\\:border-danger:hover{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity))}.pi .hover\\:border-primary-dark:hover{--tw-border-opacity:1;border-color:rgb(var(--be-primary-dark)/var(--tw-border-opacity))}.pi .hover\\:border-danger\\/90:hover{border-color:#ef4444e6}.pi .hover\\:border-chip\\/90:hover{border-color:rgb(var(--be-background-chip)/.9)}.pi .hover\\:bg-hover:hover{background-color:rgb(var(--be-foreground-base)/var(--be-hover-opacity))}.pi .hover\\:bg-primary\\/10:hover{background-color:rgb(var(--be-primary)/.1)}.pi .hover\\:bg-white\\/hover:hover{background-color:rgb(255 255 255/var(--be-hover-opacity))}.pi .hover\\:bg-primary\\/hover:hover{background-color:rgb(var(--be-primary)/var(--be-hover-opacity))}.pi .hover\\:bg-danger\\/4:hover{background-color:#ef44440a}.pi .hover\\:bg-primary\\/4:hover{background-color:rgb(var(--be-primary)/4%)}.pi .hover\\:bg-primary-dark:hover{--tw-bg-opacity:1;background-color:rgb(var(--be-primary-dark)/var(--tw-bg-opacity))}.pi .hover\\:bg-danger\\/90:hover{background-color:#ef4444e6}.pi .hover\\:bg-chip\\/90:hover{background-color:rgb(var(--be-background-chip)/.9)}.pi .hover\\:bg-paper\\/90:hover{background-color:rgb(var(--be-paper)/.9)}.pi .hover\\:bg-primary\\/focus:hover{background-color:rgb(var(--be-primary)/var(--be-focus-opacity))}.pi .hover\\:bg-fg-base\\/15:hover{background-color:rgb(var(--be-foreground-base)/15%)}.pi .hover\\:text-primary-dark:hover{--tw-text-opacity:1;color:rgb(var(--be-primary-dark)/var(--tw-text-opacity))}.pi .hover\\:text-main:hover{color:rgb(var(--be-foreground-base)/var(--be-text-main-opacity))}.pi .hover\\:text-fg-base:hover{--tw-text-opacity:1;color:rgb(var(--be-foreground-base)/var(--tw-text-opacity))}.pi .hover\\:underline:hover{text-decoration-line:underline}.pi .hover\\:opacity-100:hover{opacity:1}.pi .hover\\:shadow-md:hover{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.pi .before\\:hover\\:bg-primary-dark:hover:before{--tw-bg-opacity:1;background-color:rgb(var(--be-primary-dark)/var(--tw-bg-opacity));content:var(--tw-content)}.pi .hover\\:after\\:bg-black\\/5:hover:after{background-color:#0000000d;content:var(--tw-content)}.pi .checked\\:hover\\:border-primary-dark:hover:checked{--tw-border-opacity:1;border-color:rgb(var(--be-primary-dark)/var(--tw-border-opacity))}.pi .focus\\:border-danger\\/60:focus{border-color:#ef444499}.pi .focus\\:border-primary\\/60:focus{border-color:rgb(var(--be-primary)/.6)}.pi .focus\\:bg-primary:focus{--tw-bg-opacity:1;background-color:rgb(var(--be-primary)/var(--tw-bg-opacity))}.pi .focus\\:text-on-primary:focus{--tw-text-opacity:1;color:rgb(var(--be-on-primary)/var(--tw-text-opacity))}.pi .focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.pi .focus\\:ring:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color)}.pi .focus\\:ring-2:focus,.pi .focus\\:ring:focus{box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.pi .focus\\:ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color)}.pi .focus\\:ring-danger\\/focus:focus{--tw-ring-color:rgb(239 68 68/var(--be-focus-opacity))}.pi .focus\\:ring-primary\\/focus:focus{--tw-ring-color:rgb(var(--be-primary)/var(--be-focus-opacity))}.pi .focus\\:ring-offset-2:focus{--tw-ring-offset-width:2px}.pi .focus\\:after\\:bg-black\\/10:focus:after{background-color:#0000001a;content:var(--tw-content)}.pi .focus-visible\\:bg-primary\\/focus:focus-visible{background-color:rgb(var(--be-primary)/var(--be-focus-opacity))}.pi .focus-visible\\:bg-focus:focus-visible{background-color:rgb(var(--be-foreground-base)/var(--be-focus-opacity))}.pi .focus-visible\\:outline:focus-visible{outline-style:solid;outline-width:2px}.pi .focus-visible\\:outline-offset-2:focus-visible{outline-offset:2px}.pi .focus-visible\\:outline:focus-visible{outline-color:rgb(var(--be-primary-lighter)/1)}.pi .focus-visible\\:outline-primary-light:focus-visible{outline-color:rgb(var(--be-primary-light)/1)}.pi .focus-visible\\:ring-2:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.pi .focus-visible\\:ring:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.pi .disabled\\:pointer-events-none:disabled{pointer-events:none}.pi .disabled\\:cursor-default:disabled{cursor:default}.pi .disabled\\:border-disabled-bg:disabled{border-color:rgb(var(--be-foreground-base)/var(--be-disabled-bg-opacity))}.pi .disabled\\:border-transparent:disabled{border-color:transparent}.pi .disabled\\:border-disabled-fg:disabled{border-color:rgb(var(--be-foreground-base)/var(--be-disabled-fg-opacity))}.pi .disabled\\:border-r-transparent:disabled{border-right-color:transparent}.pi .disabled\\:bg-transparent:disabled{background-color:transparent}.pi .disabled\\:bg-disabled:disabled{background-color:rgb(var(--be-foreground-base)/var(--be-disabled-bg-opacity))}.pi .disabled\\:text-disabled:disabled{color:rgb(var(--be-foreground-base)/var(--be-disabled-fg-opacity))}.pi .disabled\\:shadow-none:disabled{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.pi .disabled\\:before\\:bg-disabled-fg:disabled:before{background-color:rgb(var(--be-foreground-base)/var(--be-disabled-fg-opacity));content:var(--tw-content)}.pi .dark .dark\\:bg-alt{--tw-bg-opacity:1;background-color:rgb(var(--be-background-alt)/var(--tw-bg-opacity))}.pi .dark .dark\\:bg-none{background-image:none}.pi .dark .dark\\:text-white\\/50{color:#ffffff80}.pi .dark .dark\\:opacity-5{opacity:.05}.pi .dark .dark\\:opacity-80{opacity:.8}.pi .dark .dark\\:checked\\:border-primary-dark:checked{--tw-border-opacity:1;border-color:rgb(var(--be-primary-dark)/var(--tw-border-opacity))}.pi .dark .dark\\:checked\\:bg-primary-dark:checked{--tw-bg-opacity:1;background-color:rgb(var(--be-primary-dark)/var(--tw-bg-opacity))}@media (min-width:640px){.pi .sm\\:justify-start{justify-content:flex-start}.pi .sm\\:text-sm{font-size:14px;line-height:20px}}@media (min-width:768px){.pi .md\\:invisible{visibility:hidden}.pi .md\\:my-24{margin-bottom:24px;margin-top:24px}.pi .md\\:mx-40{margin-left:40px;margin-right:40px}.pi .md\\:my-64{margin-bottom:64px;margin-top:64px}.pi .md\\:my-100{margin-bottom:6.25rem;margin-top:6.25rem}.pi .md\\:mr-0{margin-right:0}.pi .md\\:mb-0{margin-bottom:0}.pi .md\\:mr-10{margin-right:10px}.pi .md\\:mb-40{margin-bottom:40px}.pi .md\\:mb-24{margin-bottom:24px}.pi .md\\:mt-60{margin-top:60px}.pi .md\\:mb-70{margin-bottom:70px}.pi .md\\:mt-0{margin-top:0}.pi .md\\:mr-24{margin-right:24px}.pi .md\\:mr-80{margin-right:80px}.pi .md\\:block{display:block}.pi .md\\:flex{display:flex}.pi .md\\:h-0{height:0}.pi .md\\:w-min{width:-moz-min-content;width:min-content}.pi .md\\:w-320{width:320px}.pi .md\\:w-400{width:25rem}.pi .md\\:min-w-440{min-width:27.5rem}.pi .md\\:max-w-950{max-width:59.375rem}.pi .md\\:max-w-350{max-width:21.875rem}.pi .md\\:flex-row{flex-direction:row}.pi .md\\:items-start{align-items:flex-start}.pi .md\\:gap-12{gap:12px}.pi .md\\:gap-24{gap:24px}.pi .md\\:gap-80{gap:80px}.pi .md\\:gap-112{gap:112px}.pi .md\\:overflow-hidden{overflow:hidden}.pi .md\\:p-24{padding:24px}.pi .md\\:px-24{padding-left:24px;padding-right:24px}.pi .md\\:px-30{padding-left:30px;padding-right:30px}.pi .md\\:px-0{padding-left:0;padding-right:0}.pi .md\\:px-20{padding-left:20px;padding-right:20px}.pi .md\\:py-80{padding-bottom:80px;padding-top:80px}.pi .md\\:px-176{padding-left:176px;padding-right:176px}.pi .md\\:px-10vw{padding-left:10vw;padding-right:10vw}.pi .md\\:pt-128{padding-top:128px}.pi .md\\:pl-20{padding-left:20px}.pi .md\\:pb-0{padding-bottom:0}.pi .md\\:pb-54{padding-bottom:3.375rem}.pi .md\\:text-left{text-align:left}.pi .md\\:text-3xl{font-size:30px;line-height:36px}.pi .md\\:text-4xl{font-size:36px;line-height:40px}.pi .md\\:text-lg{font-size:18px;line-height:28px}.pi .md\\:text-base{font-size:16px;line-height:24px}.pi .md\\:font-medium{font-weight:500}.pi .md\\:font-normal{font-weight:400}.pi .md\\:shadow-xl{--tw-shadow:0 20px 25px -5px rgba(0,0,0,.1),0 8px 10px -6px rgba(0,0,0,.1);--tw-shadow-colored:0 20px 25px -5px var(--tw-shadow-color),0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}}@media (min-width:1024px){.pi .lg\\:min-w-500{min-width:31.25rem}.pi .lg\\:flex-row{flex-direction:row}.pi .lg\\:items-center{align-items:center}.pi .lg\\:px-96{padding-left:96px;padding-right:96px}.pi .lg\\:py-96{padding-bottom:96px;padding-top:96px}.pi .lg\\:pb-0{padding-bottom:0}}@media (min-width:1280px){.pi .xl\\:w-1\\/2{width:50%}.pi .xl\\:pt-96{padding-top:96px}}.pi .\\[\\&\\>\\.tree-label\\]\\:focus-visible\\:ring:focus-visible>.tree-label{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.pi .\\[\\&\\>\\.tree-label\\]\\:focus-visible\\:ring-2:focus-visible>.tree-label{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.pi .\\[\\&\\>\\.tree-label\\]\\:focus-visible\\:ring-inset:focus-visible>.tree-label{--tw-ring-inset:inset}
`;
let Ff = (t = 21) => crypto.getRandomValues(new Uint8Array(t)).reduce((e, r) => (r &= 63, r < 36 ? e += r.toString(36) : r < 62 ? e += (r - 26).toString(36).toUpperCase() : r > 62 ? e += "-" : e += "_", e), "");
class hy {
  constructor(e, r) {
    Ce(this, "timerId");
    Ce(this, "createdAt", 0);
    this.callback = e, this.remaining = r, this.resume();
  }
  pause() {
    clearTimeout(this.timerId), this.remaining -= Date.now() - this.createdAt;
  }
  resume() {
    this.createdAt = Date.now(), this.timerId && clearTimeout(this.timerId), this.timerId = setTimeout(this.callback, this.remaining);
  }
  clear() {
    clearTimeout(this.timerId);
  }
}
const fy = 1;
function dy(t) {
  switch (t) {
    case "danger":
      return 8e3;
    default:
      return 3e3;
  }
}
const zf = _f()(
  Ef((t, e) => ({
    toasts: [],
    add: (r, i) => {
      var h;
      const o = e().toasts.length + 1 - fy;
      o > 0 && t((s) => {
        s.toasts.splice(0, o);
      });
      const p = (i == null ? void 0 : i.id) || Ff(6), g = (i == null ? void 0 : i.type) || "positive", a = (h = i == null ? void 0 : i.duration) != null ? h : dy(g), n = {
        timer: a > 0 ? new hy(() => e().remove(p), a) : null,
        message: r,
        ...i,
        id: p,
        type: g,
        position: (i == null ? void 0 : i.position) || "bottom-center",
        duration: a
      }, u = e().toasts.findIndex((s) => s.id === n.id);
      u > -1 ? t((s) => {
        s.toasts[u] = n;
      }) : t((s) => {
        s.toasts.push(n);
      });
    },
    remove: (r) => {
      const i = e().toasts.filter((o) => {
        var p;
        return r === o.id ? ((p = o.timer) == null || p.clear(), !1) : !0;
      });
      t((o) => {
        o.toasts = i;
      });
    }
  }))
);
function $i() {
  return zf.getState();
}
function tn(t, e) {
  $i().add(t, e);
}
tn.danger = (t, e) => {
  $i().add(t, { ...e, type: "danger" });
};
tn.positive = (t, e) => {
  $i().add(t, { ...e, type: "positive" });
};
var jf, Lc = sm;
jf = Lc.createRoot, Lc.hydrateRoot;
const Bf = sr({
  transformPagePoint: (t) => t,
  isStatic: !1,
  reducedMotion: "never"
}), To = sr({});
function py() {
  return De(To).visualElement;
}
const rn = sr(null), Mr = typeof document < "u", Jn = Mr ? pi : xe, il = sr({ strict: !1 });
function gy(t, e, r, i) {
  const o = py(), p = De(il), g = De(rn), a = De(Bf).reducedMotion, n = de(void 0);
  i = i || p.renderer, !n.current && i && (n.current = i(t, {
    visualState: e,
    parent: o,
    props: r,
    presenceId: g ? g.id : void 0,
    blockInitialAnimation: g ? g.initial === !1 : !1,
    reducedMotionConfig: a
  }));
  const u = n.current;
  return Jn(() => {
    u && u.syncRender();
  }), xe(() => {
    u && u.animationState && u.animationState.animateChanges();
  }), Jn(() => () => u && u.notifyUnmount(), []), u;
}
function Nf(t) {
  return typeof t == "object" && Object.prototype.hasOwnProperty.call(t, "current");
}
function my(t, e, r) {
  return Ie(
    (i) => {
      i && t.mount && t.mount(i), e && (i ? e.mount(i) : e.unmount()), r && (typeof r == "function" ? r(i) : Nf(r) && (r.current = i));
    },
    [e]
  );
}
function Hi(t) {
  return typeof t == "string" || Array.isArray(t);
}
function ko(t) {
  return typeof t == "object" && typeof t.start == "function";
}
const vy = [
  "initial",
  "animate",
  "exit",
  "whileHover",
  "whileDrag",
  "whileTap",
  "whileFocus",
  "whileInView"
];
function Eo(t) {
  return ko(t.animate) || vy.some((e) => Hi(t[e]));
}
function Vf(t) {
  return Boolean(Eo(t) || t.variants);
}
function by(t, e) {
  if (Eo(t)) {
    const { initial: r, animate: i } = t;
    return {
      initial: r === !1 || Hi(r) ? r : void 0,
      animate: Hi(i) ? i : void 0
    };
  }
  return t.inherit !== !1 ? e : {};
}
function yy(t) {
  const { initial: e, animate: r } = by(t, De(To));
  return Je(() => ({ initial: e, animate: r }), [Fc(e), Fc(r)]);
}
function Fc(t) {
  return Array.isArray(t) ? t.join(" ") : t;
}
const Et = (t) => ({
  isEnabled: (e) => t.some((r) => !!e[r])
}), Ui = {
  measureLayout: Et(["layout", "layoutId", "drag"]),
  animation: Et([
    "animate",
    "exit",
    "variants",
    "whileHover",
    "whileTap",
    "whileFocus",
    "whileDrag",
    "whileInView"
  ]),
  exit: Et(["exit"]),
  drag: Et(["drag", "dragControls"]),
  focus: Et(["whileFocus"]),
  hover: Et(["whileHover", "onHoverStart", "onHoverEnd"]),
  tap: Et(["whileTap", "onTap", "onTapStart", "onTapCancel"]),
  pan: Et([
    "onPan",
    "onPanStart",
    "onPanSessionStart",
    "onPanEnd"
  ]),
  inView: Et([
    "whileInView",
    "onViewportEnter",
    "onViewportLeave"
  ])
};
function Ys(t) {
  for (const e in t)
    e === "projectionNodeConstructor" ? Ui.projectionNodeConstructor = t[e] : Ui[e].Component = t[e];
}
function nl(t) {
  const e = de(null);
  return e.current === null && (e.current = t()), e.current;
}
const wy = {
  hasAnimatedSinceResize: !0,
  hasEverUpdated: !1
};
let xy = 1;
function _y() {
  return nl(() => {
    if (wy.hasEverUpdated)
      return xy++;
  });
}
const $f = sr({});
class Sy extends ae.Component {
  getSnapshotBeforeUpdate() {
    const { visualElement: e, props: r } = this.props;
    return e && e.setProps(r), null;
  }
  componentDidUpdate() {
  }
  render() {
    return this.props.children;
  }
}
const Cy = sr({}), Ty = Symbol.for("motionComponentSymbol");
function ky({
  preloadedFeatures: t,
  createVisualElement: e,
  projectionNodeConstructor: r,
  useRender: i,
  useVisualState: o,
  Component: p
}) {
  t && Ys(t);
  function g(n, u) {
    const h = {
      ...De(Bf),
      ...n,
      layoutId: Ey(n)
    }, {
      isStatic: s
    } = h;
    let l = null;
    const c = yy(n), f = s ? void 0 : _y(), m = o(n, s);
    if (!s && Mr) {
      c.visualElement = gy(p, m, h, e);
      const d = De(il).strict, v = De(Cy);
      c.visualElement && (l = c.visualElement.loadFeatures(
        h,
        d,
        t,
        f,
        r || Ui.projectionNodeConstructor,
        v
      ));
    }
    return /* @__PURE__ */ ie(Sy, {
      visualElement: c.visualElement,
      props: h,
      children: [l, /* @__PURE__ */ x(To.Provider, {
        value: c,
        children: i(p, n, f, my(m, c.visualElement, u), m, s, c.visualElement)
      })]
    });
  }
  const a = et(g);
  return a[Ty] = p, a;
}
function Ey({
  layoutId: t
}) {
  const e = De($f).id;
  return e && t !== void 0 ? e + "-" + t : t;
}
function Oy(t) {
  function e(i, o = {}) {
    return ky(t(i, o));
  }
  if (typeof Proxy > "u")
    return e;
  const r = /* @__PURE__ */ new Map();
  return new Proxy(e, {
    get: (i, o) => (r.has(o) || r.set(o, e(o)), r.get(o))
  });
}
const Py = [
  "animate",
  "circle",
  "defs",
  "desc",
  "ellipse",
  "g",
  "image",
  "line",
  "filter",
  "marker",
  "mask",
  "metadata",
  "path",
  "pattern",
  "polygon",
  "polyline",
  "rect",
  "stop",
  "svg",
  "switch",
  "symbol",
  "text",
  "tspan",
  "use",
  "view"
];
function ol(t) {
  return typeof t != "string" || t.includes("-") ? !1 : !!(Py.indexOf(t) > -1 || /[A-Z]/.test(t));
}
const My = {}, Qn = [
  "transformPerspective",
  "x",
  "y",
  "z",
  "translateX",
  "translateY",
  "translateZ",
  "scale",
  "scaleX",
  "scaleY",
  "rotate",
  "rotateX",
  "rotateY",
  "rotateZ",
  "skew",
  "skewX",
  "skewY"
], nn = new Set(Qn);
function Hf(t, { layout: e, layoutId: r }) {
  return nn.has(t) || t.startsWith("origin") || (e || r !== void 0) && (!!My[t] || t === "opacity");
}
const Lt = (t) => !!(t != null && t.getVelocity), Ay = {
  x: "translateX",
  y: "translateY",
  z: "translateZ",
  transformPerspective: "perspective"
}, Dy = (t, e) => Qn.indexOf(t) - Qn.indexOf(e);
function Iy({ transform: t, transformKeys: e }, { enableHardwareAcceleration: r = !0, allowTransformNone: i = !0 }, o, p) {
  let g = "";
  e.sort(Dy);
  for (const a of e)
    g += `${Ay[a] || a}(${t[a]}) `;
  return r && !t.z && (g += "translateZ(0)"), g = g.trim(), p ? g = p(t, o ? "" : g) : i && o && (g = "none"), g;
}
function Uf(t) {
  return t.startsWith("--");
}
const Ry = (t, e) => e && typeof t == "number" ? e.transform(t) : t, Wf = (t, e) => (r) => Math.max(Math.min(r, e), t), Ei = (t) => t % 1 ? Number(t.toFixed(5)) : t, Wi = /(-)?([\d]*\.?[\d])+/g, Xs = /(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))/gi, Ly = /^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))$/i;
function on(t) {
  return typeof t == "string";
}
const Ar = {
  test: (t) => typeof t == "number",
  parse: parseFloat,
  transform: (t) => t
}, Oi = Object.assign(Object.assign({}, Ar), { transform: Wf(0, 1) }), _n = Object.assign(Object.assign({}, Ar), { default: 1 }), sn = (t) => ({
  test: (e) => on(e) && e.endsWith(t) && e.split(" ").length === 1,
  parse: parseFloat,
  transform: (e) => `${e}${t}`
}), Vt = sn("deg"), ri = sn("%"), be = sn("px"), Fy = sn("vh"), zy = sn("vw"), zc = Object.assign(Object.assign({}, ri), { parse: (t) => ri.parse(t) / 100, transform: (t) => ri.transform(t * 100) }), sl = (t, e) => (r) => Boolean(on(r) && Ly.test(r) && r.startsWith(t) || e && Object.prototype.hasOwnProperty.call(r, e)), Yf = (t, e, r) => (i) => {
  if (!on(i))
    return i;
  const [o, p, g, a] = i.match(Wi);
  return {
    [t]: parseFloat(o),
    [e]: parseFloat(p),
    [r]: parseFloat(g),
    alpha: a !== void 0 ? parseFloat(a) : 1
  };
}, xr = {
  test: sl("hsl", "hue"),
  parse: Yf("hue", "saturation", "lightness"),
  transform: ({ hue: t, saturation: e, lightness: r, alpha: i = 1 }) => "hsla(" + Math.round(t) + ", " + ri.transform(Ei(e)) + ", " + ri.transform(Ei(r)) + ", " + Ei(Oi.transform(i)) + ")"
}, jy = Wf(0, 255), as = Object.assign(Object.assign({}, Ar), { transform: (t) => Math.round(jy(t)) }), Wt = {
  test: sl("rgb", "red"),
  parse: Yf("red", "green", "blue"),
  transform: ({ red: t, green: e, blue: r, alpha: i = 1 }) => "rgba(" + as.transform(t) + ", " + as.transform(e) + ", " + as.transform(r) + ", " + Ei(Oi.transform(i)) + ")"
};
function By(t) {
  let e = "", r = "", i = "", o = "";
  return t.length > 5 ? (e = t.substr(1, 2), r = t.substr(3, 2), i = t.substr(5, 2), o = t.substr(7, 2)) : (e = t.substr(1, 1), r = t.substr(2, 1), i = t.substr(3, 1), o = t.substr(4, 1), e += e, r += r, i += i, o += o), {
    red: parseInt(e, 16),
    green: parseInt(r, 16),
    blue: parseInt(i, 16),
    alpha: o ? parseInt(o, 16) / 255 : 1
  };
}
const Gs = {
  test: sl("#"),
  parse: By,
  transform: Wt.transform
}, rt = {
  test: (t) => Wt.test(t) || Gs.test(t) || xr.test(t),
  parse: (t) => Wt.test(t) ? Wt.parse(t) : xr.test(t) ? xr.parse(t) : Gs.parse(t),
  transform: (t) => on(t) ? t : t.hasOwnProperty("red") ? Wt.transform(t) : xr.transform(t)
}, Xf = "${c}", Gf = "${n}";
function Ny(t) {
  var e, r, i, o;
  return isNaN(t) && on(t) && ((r = (e = t.match(Wi)) === null || e === void 0 ? void 0 : e.length) !== null && r !== void 0 ? r : 0) + ((o = (i = t.match(Xs)) === null || i === void 0 ? void 0 : i.length) !== null && o !== void 0 ? o : 0) > 0;
}
function qf(t) {
  typeof t == "number" && (t = `${t}`);
  const e = [];
  let r = 0;
  const i = t.match(Xs);
  i && (r = i.length, t = t.replace(Xs, Xf), e.push(...i.map(rt.parse)));
  const o = t.match(Wi);
  return o && (t = t.replace(Wi, Gf), e.push(...o.map(Ar.parse))), { values: e, numColors: r, tokenised: t };
}
function Kf(t) {
  return qf(t).values;
}
function Zf(t) {
  const { values: e, numColors: r, tokenised: i } = qf(t), o = e.length;
  return (p) => {
    let g = i;
    for (let a = 0; a < o; a++)
      g = g.replace(a < r ? Xf : Gf, a < r ? rt.transform(p[a]) : Ei(p[a]));
    return g;
  };
}
const Vy = (t) => typeof t == "number" ? 0 : t;
function $y(t) {
  const e = Kf(t);
  return Zf(t)(e.map(Vy));
}
const Dr = { test: Ny, parse: Kf, createTransformer: Zf, getAnimatableNone: $y }, Hy = /* @__PURE__ */ new Set(["brightness", "contrast", "saturate", "opacity"]);
function Uy(t) {
  let [e, r] = t.slice(0, -1).split("(");
  if (e === "drop-shadow")
    return t;
  const [i] = r.match(Wi) || [];
  if (!i)
    return t;
  const o = r.replace(i, "");
  let p = Hy.has(e) ? 1 : 0;
  return i !== r && (p *= 100), e + "(" + p + o + ")";
}
const Wy = /([a-z-]*)\(.*?\)/g, qs = Object.assign(Object.assign({}, Dr), { getAnimatableNone: (t) => {
  const e = t.match(Wy);
  return e ? e.map(Uy).join(" ") : t;
} }), jc = {
  ...Ar,
  transform: Math.round
}, Jf = {
  borderWidth: be,
  borderTopWidth: be,
  borderRightWidth: be,
  borderBottomWidth: be,
  borderLeftWidth: be,
  borderRadius: be,
  radius: be,
  borderTopLeftRadius: be,
  borderTopRightRadius: be,
  borderBottomRightRadius: be,
  borderBottomLeftRadius: be,
  width: be,
  maxWidth: be,
  height: be,
  maxHeight: be,
  size: be,
  top: be,
  right: be,
  bottom: be,
  left: be,
  padding: be,
  paddingTop: be,
  paddingRight: be,
  paddingBottom: be,
  paddingLeft: be,
  margin: be,
  marginTop: be,
  marginRight: be,
  marginBottom: be,
  marginLeft: be,
  rotate: Vt,
  rotateX: Vt,
  rotateY: Vt,
  rotateZ: Vt,
  scale: _n,
  scaleX: _n,
  scaleY: _n,
  scaleZ: _n,
  skew: Vt,
  skewX: Vt,
  skewY: Vt,
  distance: be,
  translateX: be,
  translateY: be,
  translateZ: be,
  x: be,
  y: be,
  z: be,
  perspective: be,
  transformPerspective: be,
  opacity: Oi,
  originX: zc,
  originY: zc,
  originZ: be,
  zIndex: jc,
  fillOpacity: Oi,
  strokeOpacity: Oi,
  numOctaves: jc
};
function al(t, e, r, i) {
  const { style: o, vars: p, transform: g, transformKeys: a, transformOrigin: n } = t;
  a.length = 0;
  let u = !1, h = !1, s = !0;
  for (const l in e) {
    const c = e[l];
    if (Uf(l)) {
      p[l] = c;
      continue;
    }
    const f = Jf[l], m = Ry(c, f);
    if (nn.has(l)) {
      if (u = !0, g[l] = m, a.push(l), !s)
        continue;
      c !== (f.default || 0) && (s = !1);
    } else
      l.startsWith("origin") ? (h = !0, n[l] = m) : o[l] = m;
  }
  if (e.transform || (u || i ? o.transform = Iy(t, r, s, i) : o.transform && (o.transform = "none")), h) {
    const { originX: l = "50%", originY: c = "50%", originZ: f = 0 } = n;
    o.transformOrigin = `${l} ${c} ${f}`;
  }
}
const ll = () => ({
  style: {},
  transform: {},
  transformKeys: [],
  transformOrigin: {},
  vars: {}
});
function Qf(t, e, r) {
  for (const i in e)
    !Lt(e[i]) && !Hf(i, r) && (t[i] = e[i]);
}
function Yy({ transformTemplate: t }, e, r) {
  return Je(() => {
    const i = ll();
    return al(i, e, { enableHardwareAcceleration: !r }, t), Object.assign({}, i.vars, i.style);
  }, [e]);
}
function Xy(t, e, r) {
  const i = t.style || {}, o = {};
  return Qf(o, i, t), Object.assign(o, Yy(t, e, r)), t.transformValues ? t.transformValues(o) : o;
}
function Gy(t, e, r) {
  const i = {}, o = Xy(t, e, r);
  return t.drag && t.dragListener !== !1 && (i.draggable = !1, o.userSelect = o.WebkitUserSelect = o.WebkitTouchCallout = "none", o.touchAction = t.drag === !0 ? "none" : `pan-${t.drag === "x" ? "y" : "x"}`), i.style = o, i;
}
const qy = [
  "animate",
  "exit",
  "variants",
  "whileHover",
  "whileTap",
  "whileFocus",
  "whileDrag",
  "whileInView"
], Ky = ["whileTap", "onTap", "onTapStart", "onTapCancel"], Zy = ["onPan", "onPanStart", "onPanSessionStart", "onPanEnd"], Jy = [
  "whileInView",
  "onViewportEnter",
  "onViewportLeave",
  "viewport"
], Qy = /* @__PURE__ */ new Set([
  "initial",
  "style",
  "values",
  "variants",
  "transition",
  "transformTemplate",
  "transformValues",
  "custom",
  "inherit",
  "layout",
  "layoutId",
  "layoutDependency",
  "onLayoutAnimationStart",
  "onLayoutAnimationComplete",
  "onLayoutMeasure",
  "onBeforeLayoutMeasure",
  "onAnimationStart",
  "onAnimationComplete",
  "onUpdate",
  "onDragStart",
  "onDrag",
  "onDragEnd",
  "onMeasureDragConstraints",
  "onDirectionLock",
  "onDragTransitionEnd",
  "drag",
  "dragControls",
  "dragListener",
  "dragConstraints",
  "dragDirectionLock",
  "dragSnapToOrigin",
  "_dragX",
  "_dragY",
  "dragElastic",
  "dragMomentum",
  "dragPropagation",
  "dragTransition",
  "onHoverStart",
  "onHoverEnd",
  "layoutScroll",
  ...Jy,
  ...Ky,
  ...qy,
  ...Zy
]);
function eo(t) {
  return Qy.has(t);
}
let ed = (t) => !eo(t);
function ew(t) {
  !t || (ed = (e) => e.startsWith("on") ? !eo(e) : t(e));
}
try {
  ew(require("@emotion/is-prop-valid").default);
} catch {
}
function tw(t, e, r) {
  const i = {};
  for (const o in t)
    (ed(o) || r === !0 && eo(o) || !e && !eo(o) || t.draggable && o.startsWith("onDrag")) && (i[o] = t[o]);
  return i;
}
function Bc(t, e, r) {
  return typeof t == "string" ? t : be.transform(e + r * t);
}
function rw(t, e, r) {
  const i = Bc(e, t.x, t.width), o = Bc(r, t.y, t.height);
  return `${i} ${o}`;
}
const iw = {
  offset: "stroke-dashoffset",
  array: "stroke-dasharray"
}, nw = {
  offset: "strokeDashoffset",
  array: "strokeDasharray"
};
function ow(t, e, r = 1, i = 0, o = !0) {
  t.pathLength = 1;
  const p = o ? iw : nw;
  t[p.offset] = be.transform(-i);
  const g = be.transform(e), a = be.transform(r);
  t[p.array] = `${g} ${a}`;
}
function cl(t, {
  attrX: e,
  attrY: r,
  originX: i,
  originY: o,
  pathLength: p,
  pathSpacing: g = 1,
  pathOffset: a = 0,
  ...n
}, u, h) {
  al(t, n, u, h), t.attrs = t.style, t.style = {};
  const { attrs: s, style: l, dimensions: c } = t;
  s.transform && (c && (l.transform = s.transform), delete s.transform), c && (i !== void 0 || o !== void 0 || l.transform) && (l.transformOrigin = rw(c, i !== void 0 ? i : 0.5, o !== void 0 ? o : 0.5)), e !== void 0 && (s.x = e), r !== void 0 && (s.y = r), p !== void 0 && ow(s, p, g, a, !1);
}
const td = () => ({
  ...ll(),
  attrs: {}
});
function sw(t, e) {
  const r = Je(() => {
    const i = td();
    return cl(i, e, { enableHardwareAcceleration: !1 }, t.transformTemplate), {
      ...i.attrs,
      style: { ...i.style }
    };
  }, [e]);
  if (t.style) {
    const i = {};
    Qf(i, t.style, t), r.style = { ...i, ...r.style };
  }
  return r;
}
function aw(t = !1) {
  return (r, i, o, p, { latestValues: g }, a) => {
    const u = (ol(r) ? sw : Gy)(i, g, a), s = {
      ...tw(i, typeof r == "string", t),
      ...u,
      ref: p
    };
    return o && (s["data-projection-id"] = o), Ch(r, s);
  };
}
const rd = (t) => t.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
function id(t, { style: e, vars: r }, i, o) {
  Object.assign(t.style, e, o && o.getProjectionStyles(i));
  for (const p in r)
    t.style.setProperty(p, r[p]);
}
const nd = /* @__PURE__ */ new Set([
  "baseFrequency",
  "diffuseConstant",
  "kernelMatrix",
  "kernelUnitLength",
  "keySplines",
  "keyTimes",
  "limitingConeAngle",
  "markerHeight",
  "markerWidth",
  "numOctaves",
  "targetX",
  "targetY",
  "surfaceScale",
  "specularConstant",
  "specularExponent",
  "stdDeviation",
  "tableValues",
  "viewBox",
  "gradientTransform",
  "pathLength"
]);
function od(t, e, r, i) {
  id(t, e, void 0, i);
  for (const o in e.attrs)
    t.setAttribute(nd.has(o) ? o : rd(o), e.attrs[o]);
}
function ul(t) {
  const { style: e } = t, r = {};
  for (const i in e)
    (Lt(e[i]) || Hf(i, t)) && (r[i] = e[i]);
  return r;
}
function sd(t) {
  const e = ul(t);
  for (const r in t)
    if (Lt(t[r])) {
      const i = r === "x" || r === "y" ? "attr" + r.toUpperCase() : r;
      e[i] = t[r];
    }
  return e;
}
function ad(t, e, r, i = {}, o = {}) {
  return typeof e == "function" && (e = e(r !== void 0 ? r : t.custom, i, o)), typeof e == "string" && (e = t.variants && t.variants[e]), typeof e == "function" && (e = e(r !== void 0 ? r : t.custom, i, o)), e;
}
const Yi = (t) => Array.isArray(t), lw = (t) => Boolean(t && typeof t == "object" && t.mix && t.toValue), ld = (t) => Yi(t) ? t[t.length - 1] || 0 : t;
function cw(t) {
  const e = Lt(t) ? t.get() : t;
  return lw(e) ? e.toValue() : e;
}
function uw({ scrapeMotionValuesFromProps: t, createRenderState: e, onMount: r }, i, o, p) {
  const g = {
    latestValues: hw(i, o, p, t),
    renderState: e()
  };
  return r && (g.mount = (a) => r(i, a, g)), g;
}
const cd = (t) => (e, r) => {
  const i = De(To), o = De(rn), p = () => uw(t, e, i, o);
  return r ? p() : nl(p);
};
function hw(t, e, r, i) {
  const o = {}, p = i(t);
  for (const l in p)
    o[l] = cw(p[l]);
  let { initial: g, animate: a } = t;
  const n = Eo(t), u = Vf(t);
  e && u && !n && t.inherit !== !1 && (g === void 0 && (g = e.initial), a === void 0 && (a = e.animate));
  let h = r ? r.initial === !1 : !1;
  h = h || g === !1;
  const s = h ? a : g;
  return s && typeof s != "boolean" && !ko(s) && (Array.isArray(s) ? s : [s]).forEach((c) => {
    const f = ad(t, c);
    if (!f)
      return;
    const { transitionEnd: m, transition: d, ...v } = f;
    for (const b in v) {
      let y = v[b];
      if (Array.isArray(y)) {
        const w = h ? y.length - 1 : 0;
        y = y[w];
      }
      y !== null && (o[b] = y);
    }
    for (const b in m)
      o[b] = m[b];
  }), o;
}
const fw = {
  useVisualState: cd({
    scrapeMotionValuesFromProps: sd,
    createRenderState: td,
    onMount: (t, e, { renderState: r, latestValues: i }) => {
      try {
        r.dimensions = typeof e.getBBox == "function" ? e.getBBox() : e.getBoundingClientRect();
      } catch {
        r.dimensions = {
          x: 0,
          y: 0,
          width: 0,
          height: 0
        };
      }
      cl(r, i, { enableHardwareAcceleration: !1 }, t.transformTemplate), od(e, r);
    }
  })
}, dw = {
  useVisualState: cd({
    scrapeMotionValuesFromProps: ul,
    createRenderState: ll
  })
};
function pw(t, { forwardMotionProps: e = !1 }, r, i, o) {
  return {
    ...ol(t) ? fw : dw,
    preloadedFeatures: r,
    useRender: aw(e),
    createVisualElement: i,
    projectionNodeConstructor: o,
    Component: t
  };
}
var Le;
(function(t) {
  t.Animate = "animate", t.Hover = "whileHover", t.Tap = "whileTap", t.Drag = "whileDrag", t.Focus = "whileFocus", t.InView = "whileInView", t.Exit = "exit";
})(Le || (Le = {}));
function ud(t, e, r, i = { passive: !0 }) {
  return t.addEventListener(e, r, i), () => t.removeEventListener(e, r);
}
function Ks(t, e, r, i) {
  xe(() => {
    const o = t.current;
    if (r && o)
      return ud(o, e, r, i);
  }, [t, e, r, i]);
}
function gw({ whileFocus: t, visualElement: e }) {
  const { animationState: r } = e, i = () => {
    r && r.setActive(Le.Focus, !0);
  }, o = () => {
    r && r.setActive(Le.Focus, !1);
  };
  Ks(e, "focus", t ? i : void 0), Ks(e, "blur", t ? o : void 0);
}
function mw(t) {
  return typeof PointerEvent < "u" && t instanceof PointerEvent ? t.pointerType === "mouse" : t instanceof MouseEvent;
}
function vw(t) {
  return !!t.touches;
}
function bw(t) {
  return (e) => {
    const r = e instanceof MouseEvent;
    (!r || r && e.button === 0) && t(e);
  };
}
const yw = { pageX: 0, pageY: 0 };
function ww(t, e = "page") {
  const i = t.touches[0] || t.changedTouches[0] || yw;
  return {
    x: i[e + "X"],
    y: i[e + "Y"]
  };
}
function xw(t, e = "page") {
  return {
    x: t[e + "X"],
    y: t[e + "Y"]
  };
}
function _w(t, e = "page") {
  return {
    point: vw(t) ? ww(t, e) : xw(t, e)
  };
}
const hd = (t, e = !1) => {
  const r = (i) => t(i, _w(i));
  return e ? bw(r) : r;
}, Sw = () => Mr && window.onpointerdown === null, Cw = () => Mr && window.ontouchstart === null, Tw = () => Mr && window.onmousedown === null, kw = {
  pointerdown: "mousedown",
  pointermove: "mousemove",
  pointerup: "mouseup",
  pointercancel: "mousecancel",
  pointerover: "mouseover",
  pointerout: "mouseout",
  pointerenter: "mouseenter",
  pointerleave: "mouseleave"
}, Ew = {
  pointerdown: "touchstart",
  pointermove: "touchmove",
  pointerup: "touchend",
  pointercancel: "touchcancel"
};
function fd(t) {
  return Sw() ? t : Cw() ? Ew[t] : Tw() ? kw[t] : t;
}
function Nc(t, e, r, i) {
  return ud(t, fd(e), hd(r, e === "pointerdown"), i);
}
function Zs(t, e, r, i) {
  return Ks(t, fd(e), r && hd(r, e === "pointerdown"), i);
}
function dd(t) {
  let e = null;
  return () => {
    const r = () => {
      e = null;
    };
    return e === null ? (e = t, r) : !1;
  };
}
const Vc = dd("dragHorizontal"), $c = dd("dragVertical");
function Ow(t) {
  let e = !1;
  if (t === "y")
    e = $c();
  else if (t === "x")
    e = Vc();
  else {
    const r = Vc(), i = $c();
    r && i ? e = () => {
      r(), i();
    } : (r && r(), i && i());
  }
  return e;
}
function pd() {
  const t = Ow(!0);
  return t ? (t(), !1) : !0;
}
function Hc(t, e, r) {
  return (i, o) => {
    !mw(i) || pd() || (t.animationState && t.animationState.setActive(Le.Hover, e), r && r(i, o));
  };
}
function Pw({ onHoverStart: t, onHoverEnd: e, whileHover: r, visualElement: i }) {
  Zs(i, "pointerenter", t || r ? Hc(i, !0, t) : void 0, { passive: !t }), Zs(i, "pointerleave", e || r ? Hc(i, !1, e) : void 0, { passive: !e });
}
const gd = (t, e) => e ? t === e ? !0 : gd(t, e.parentElement) : !1;
function md(t) {
  return xe(() => () => t(), []);
}
function vd(t, e) {
  var r = {};
  for (var i in t)
    Object.prototype.hasOwnProperty.call(t, i) && e.indexOf(i) < 0 && (r[i] = t[i]);
  if (t != null && typeof Object.getOwnPropertySymbols == "function")
    for (var o = 0, i = Object.getOwnPropertySymbols(t); o < i.length; o++)
      e.indexOf(i[o]) < 0 && Object.prototype.propertyIsEnumerable.call(t, i[o]) && (r[i[o]] = t[i[o]]);
  return r;
}
var Mw = function() {
}, to = function() {
};
const Js = (t, e, r) => Math.min(Math.max(r, t), e), ls = 1e-3, Aw = 0.01, Uc = 10, Dw = 0.05, Iw = 1;
function Rw({ duration: t = 800, bounce: e = 0.25, velocity: r = 0, mass: i = 1 }) {
  let o, p;
  Mw(t <= Uc * 1e3);
  let g = 1 - e;
  g = Js(Dw, Iw, g), t = Js(Aw, Uc, t / 1e3), g < 1 ? (o = (u) => {
    const h = u * g, s = h * t, l = h - r, c = Qs(u, g), f = Math.exp(-s);
    return ls - l / c * f;
  }, p = (u) => {
    const s = u * g * t, l = s * r + r, c = Math.pow(g, 2) * Math.pow(u, 2) * t, f = Math.exp(-s), m = Qs(Math.pow(u, 2), g);
    return (-o(u) + ls > 0 ? -1 : 1) * ((l - c) * f) / m;
  }) : (o = (u) => {
    const h = Math.exp(-u * t), s = (u - r) * t + 1;
    return -ls + h * s;
  }, p = (u) => {
    const h = Math.exp(-u * t), s = (r - u) * (t * t);
    return h * s;
  });
  const a = 5 / t, n = Fw(o, p, a);
  if (t = t * 1e3, isNaN(n))
    return {
      stiffness: 100,
      damping: 10,
      duration: t
    };
  {
    const u = Math.pow(n, 2) * i;
    return {
      stiffness: u,
      damping: g * 2 * Math.sqrt(i * u),
      duration: t
    };
  }
}
const Lw = 12;
function Fw(t, e, r) {
  let i = r;
  for (let o = 1; o < Lw; o++)
    i = i - t(i) / e(i);
  return i;
}
function Qs(t, e) {
  return t * Math.sqrt(1 - e * e);
}
const zw = ["duration", "bounce"], jw = ["stiffness", "damping", "mass"];
function Wc(t, e) {
  return e.some((r) => t[r] !== void 0);
}
function Bw(t) {
  let e = Object.assign({ velocity: 0, stiffness: 100, damping: 10, mass: 1, isResolvedFromDuration: !1 }, t);
  if (!Wc(t, jw) && Wc(t, zw)) {
    const r = Rw(t);
    e = Object.assign(Object.assign(Object.assign({}, e), r), { velocity: 0, mass: 1 }), e.isResolvedFromDuration = !0;
  }
  return e;
}
function hl(t) {
  var { from: e = 0, to: r = 1, restSpeed: i = 2, restDelta: o } = t, p = vd(t, ["from", "to", "restSpeed", "restDelta"]);
  const g = { done: !1, value: e };
  let { stiffness: a, damping: n, mass: u, velocity: h, duration: s, isResolvedFromDuration: l } = Bw(p), c = Yc, f = Yc;
  function m() {
    const d = h ? -(h / 1e3) : 0, v = r - e, b = n / (2 * Math.sqrt(a * u)), y = Math.sqrt(a / u) / 1e3;
    if (o === void 0 && (o = Math.min(Math.abs(r - e) / 100, 0.4)), b < 1) {
      const w = Qs(y, b);
      c = (_) => {
        const S = Math.exp(-b * y * _);
        return r - S * ((d + b * y * v) / w * Math.sin(w * _) + v * Math.cos(w * _));
      }, f = (_) => {
        const S = Math.exp(-b * y * _);
        return b * y * S * (Math.sin(w * _) * (d + b * y * v) / w + v * Math.cos(w * _)) - S * (Math.cos(w * _) * (d + b * y * v) - w * v * Math.sin(w * _));
      };
    } else if (b === 1)
      c = (w) => r - Math.exp(-y * w) * (v + (d + y * v) * w);
    else {
      const w = y * Math.sqrt(b * b - 1);
      c = (_) => {
        const S = Math.exp(-b * y * _), T = Math.min(w * _, 300);
        return r - S * ((d + b * y * v) * Math.sinh(T) + w * v * Math.cosh(T)) / w;
      };
    }
  }
  return m(), {
    next: (d) => {
      const v = c(d);
      if (l)
        g.done = d >= s;
      else {
        const b = f(d) * 1e3, y = Math.abs(b) <= i, w = Math.abs(r - v) <= o;
        g.done = y && w;
      }
      return g.value = g.done ? r : v, g;
    },
    flipTarget: () => {
      h = -h, [e, r] = [r, e], m();
    }
  };
}
hl.needsInterpolation = (t, e) => typeof t == "string" || typeof e == "string";
const Yc = (t) => 0, bd = (t, e, r) => {
  const i = e - t;
  return i === 0 ? 1 : (r - t) / i;
}, fl = (t, e, r) => -r * t + r * e + t;
function cs(t, e, r) {
  return r < 0 && (r += 1), r > 1 && (r -= 1), r < 1 / 6 ? t + (e - t) * 6 * r : r < 1 / 2 ? e : r < 2 / 3 ? t + (e - t) * (2 / 3 - r) * 6 : t;
}
function Xc({ hue: t, saturation: e, lightness: r, alpha: i }) {
  t /= 360, e /= 100, r /= 100;
  let o = 0, p = 0, g = 0;
  if (!e)
    o = p = g = r;
  else {
    const a = r < 0.5 ? r * (1 + e) : r + e - r * e, n = 2 * r - a;
    o = cs(n, a, t + 1 / 3), p = cs(n, a, t), g = cs(n, a, t - 1 / 3);
  }
  return {
    red: Math.round(o * 255),
    green: Math.round(p * 255),
    blue: Math.round(g * 255),
    alpha: i
  };
}
const Nw = (t, e, r) => {
  const i = t * t, o = e * e;
  return Math.sqrt(Math.max(0, r * (o - i) + i));
}, Vw = [Gs, Wt, xr], Gc = (t) => Vw.find((e) => e.test(t)), yd = (t, e) => {
  let r = Gc(t), i = Gc(e), o = r.parse(t), p = i.parse(e);
  r === xr && (o = Xc(o), r = Wt), i === xr && (p = Xc(p), i = Wt);
  const g = Object.assign({}, o);
  return (a) => {
    for (const n in g)
      n !== "alpha" && (g[n] = Nw(o[n], p[n], a));
    return g.alpha = fl(o.alpha, p.alpha, a), r.transform(g);
  };
}, $w = (t) => typeof t == "number", Hw = (t, e) => (r) => e(t(r)), dl = (...t) => t.reduce(Hw);
function wd(t, e) {
  return $w(t) ? (r) => fl(t, e, r) : rt.test(t) ? yd(t, e) : _d(t, e);
}
const xd = (t, e) => {
  const r = [...t], i = r.length, o = t.map((p, g) => wd(p, e[g]));
  return (p) => {
    for (let g = 0; g < i; g++)
      r[g] = o[g](p);
    return r;
  };
}, Uw = (t, e) => {
  const r = Object.assign(Object.assign({}, t), e), i = {};
  for (const o in r)
    t[o] !== void 0 && e[o] !== void 0 && (i[o] = wd(t[o], e[o]));
  return (o) => {
    for (const p in i)
      r[p] = i[p](o);
    return r;
  };
};
function qc(t) {
  const e = Dr.parse(t), r = e.length;
  let i = 0, o = 0, p = 0;
  for (let g = 0; g < r; g++)
    i || typeof e[g] == "number" ? i++ : e[g].hue !== void 0 ? p++ : o++;
  return { parsed: e, numNumbers: i, numRGB: o, numHSL: p };
}
const _d = (t, e) => {
  const r = Dr.createTransformer(e), i = qc(t), o = qc(e);
  return i.numHSL === o.numHSL && i.numRGB === o.numRGB && i.numNumbers >= o.numNumbers ? dl(xd(i.parsed, o.parsed), r) : (g) => `${g > 0 ? e : t}`;
}, Ww = (t, e) => (r) => fl(t, e, r);
function Yw(t) {
  if (typeof t == "number")
    return Ww;
  if (typeof t == "string")
    return rt.test(t) ? yd : _d;
  if (Array.isArray(t))
    return xd;
  if (typeof t == "object")
    return Uw;
}
function Xw(t, e, r) {
  const i = [], o = r || Yw(t[0]), p = t.length - 1;
  for (let g = 0; g < p; g++) {
    let a = o(t[g], t[g + 1]);
    if (e) {
      const n = Array.isArray(e) ? e[g] : e;
      a = dl(n, a);
    }
    i.push(a);
  }
  return i;
}
function Gw([t, e], [r]) {
  return (i) => r(bd(t, e, i));
}
function qw(t, e) {
  const r = t.length, i = r - 1;
  return (o) => {
    let p = 0, g = !1;
    if (o <= t[0] ? g = !0 : o >= t[i] && (p = i - 1, g = !0), !g) {
      let n = 1;
      for (; n < r && !(t[n] > o || n === i); n++)
        ;
      p = n - 1;
    }
    const a = bd(t[p], t[p + 1], o);
    return e[p](a);
  };
}
function Sd(t, e, { clamp: r = !0, ease: i, mixer: o } = {}) {
  const p = t.length;
  to(p === e.length), to(!i || !Array.isArray(i) || i.length === p - 1), t[0] > t[p - 1] && (t = [].concat(t), e = [].concat(e), t.reverse(), e.reverse());
  const g = Xw(e, i, o), a = p === 2 ? Gw(t, g) : qw(t, g);
  return r ? (n) => a(Js(t[0], t[p - 1], n)) : a;
}
const Oo = (t) => (e) => 1 - t(1 - e), pl = (t) => (e) => e <= 0.5 ? t(2 * e) / 2 : (2 - t(2 * (1 - e))) / 2, Kw = (t) => (e) => Math.pow(e, t), Cd = (t) => (e) => e * e * ((t + 1) * e - t), Zw = (t) => {
  const e = Cd(t);
  return (r) => (r *= 2) < 1 ? 0.5 * e(r) : 0.5 * (2 - Math.pow(2, -10 * (r - 1)));
}, Td = 1.525, Jw = 4 / 11, Qw = 8 / 11, ex = 9 / 10, kd = (t) => t, gl = Kw(2), tx = Oo(gl), Ed = pl(gl), Od = (t) => 1 - Math.sin(Math.acos(t)), Pd = Oo(Od), rx = pl(Pd), ml = Cd(Td), ix = Oo(ml), nx = pl(ml), ox = Zw(Td), sx = 4356 / 361, ax = 35442 / 1805, lx = 16061 / 1805, ro = (t) => {
  if (t === 1 || t === 0)
    return t;
  const e = t * t;
  return t < Jw ? 7.5625 * e : t < Qw ? 9.075 * e - 9.9 * t + 3.4 : t < ex ? sx * e - ax * t + lx : 10.8 * t * t - 20.52 * t + 10.72;
}, cx = Oo(ro), ux = (t) => t < 0.5 ? 0.5 * (1 - ro(1 - t * 2)) : 0.5 * ro(t * 2 - 1) + 0.5;
function hx(t, e) {
  return t.map(() => e || Ed).splice(0, t.length - 1);
}
function fx(t) {
  const e = t.length;
  return t.map((r, i) => i !== 0 ? i / (e - 1) : 0);
}
function dx(t, e) {
  return t.map((r) => r * e);
}
function zn({ from: t = 0, to: e = 1, ease: r, offset: i, duration: o = 300 }) {
  const p = { done: !1, value: t }, g = Array.isArray(e) ? e : [t, e], a = dx(i && i.length === g.length ? i : fx(g), o);
  function n() {
    return Sd(a, g, {
      ease: Array.isArray(r) ? r : hx(g, r)
    });
  }
  let u = n();
  return {
    next: (h) => (p.value = u(h), p.done = h >= o, p),
    flipTarget: () => {
      g.reverse(), u = n();
    }
  };
}
function px({ velocity: t = 0, from: e = 0, power: r = 0.8, timeConstant: i = 350, restDelta: o = 0.5, modifyTarget: p }) {
  const g = { done: !1, value: e };
  let a = r * t;
  const n = e + a, u = p === void 0 ? n : p(n);
  return u !== n && (a = u - e), {
    next: (h) => {
      const s = -a * Math.exp(-h / i);
      return g.done = !(s > o || s < -o), g.value = g.done ? u : u + s, g;
    },
    flipTarget: () => {
    }
  };
}
const Kc = { keyframes: zn, spring: hl, decay: px };
function gx(t) {
  if (Array.isArray(t.to))
    return zn;
  if (Kc[t.type])
    return Kc[t.type];
  const e = new Set(Object.keys(t));
  return e.has("ease") || e.has("duration") && !e.has("dampingRatio") ? zn : e.has("dampingRatio") || e.has("stiffness") || e.has("mass") || e.has("damping") || e.has("restSpeed") || e.has("restDelta") ? hl : zn;
}
const Md = 1 / 60 * 1e3, mx = typeof performance < "u" ? () => performance.now() : () => Date.now(), Ad = typeof window < "u" ? (t) => window.requestAnimationFrame(t) : (t) => setTimeout(() => t(mx()), Md);
function vx(t) {
  let e = [], r = [], i = 0, o = !1, p = !1;
  const g = /* @__PURE__ */ new WeakSet(), a = {
    schedule: (n, u = !1, h = !1) => {
      const s = h && o, l = s ? e : r;
      return u && g.add(n), l.indexOf(n) === -1 && (l.push(n), s && o && (i = e.length)), n;
    },
    cancel: (n) => {
      const u = r.indexOf(n);
      u !== -1 && r.splice(u, 1), g.delete(n);
    },
    process: (n) => {
      if (o) {
        p = !0;
        return;
      }
      if (o = !0, [e, r] = [r, e], r.length = 0, i = e.length, i)
        for (let u = 0; u < i; u++) {
          const h = e[u];
          h(n), g.has(h) && (a.schedule(h), t());
        }
      o = !1, p && (p = !1, a.process(n));
    }
  };
  return a;
}
const bx = 40;
let ea = !0, Xi = !1, ta = !1;
const ii = {
  delta: 0,
  timestamp: 0
}, an = [
  "read",
  "update",
  "preRender",
  "render",
  "postRender"
], Po = an.reduce((t, e) => (t[e] = vx(() => Xi = !0), t), {}), fi = an.reduce((t, e) => {
  const r = Po[e];
  return t[e] = (i, o = !1, p = !1) => (Xi || wx(), r.schedule(i, o, p)), t;
}, {}), ra = an.reduce((t, e) => (t[e] = Po[e].cancel, t), {});
an.reduce((t, e) => (t[e] = () => Po[e].process(ii), t), {});
const yx = (t) => Po[t].process(ii), Dd = (t) => {
  Xi = !1, ii.delta = ea ? Md : Math.max(Math.min(t - ii.timestamp, bx), 1), ii.timestamp = t, ta = !0, an.forEach(yx), ta = !1, Xi && (ea = !1, Ad(Dd));
}, wx = () => {
  Xi = !0, ea = !0, ta || Ad(Dd);
}, Id = () => ii;
function Rd(t, e, r = 0) {
  return t - e - r;
}
function xx(t, e, r = 0, i = !0) {
  return i ? Rd(e + -t, e, r) : e - (t - e) + r;
}
function _x(t, e, r, i) {
  return i ? t >= e + r : t <= -r;
}
const Sx = (t) => {
  const e = ({ delta: r }) => t(r);
  return {
    start: () => fi.update(e, !0),
    stop: () => ra.update(e)
  };
};
function Ld(t) {
  var e, r, { from: i, autoplay: o = !0, driver: p = Sx, elapsed: g = 0, repeat: a = 0, repeatType: n = "loop", repeatDelay: u = 0, onPlay: h, onStop: s, onComplete: l, onRepeat: c, onUpdate: f } = t, m = vd(t, ["from", "autoplay", "driver", "elapsed", "repeat", "repeatType", "repeatDelay", "onPlay", "onStop", "onComplete", "onRepeat", "onUpdate"]);
  let { to: d } = m, v, b = 0, y = m.duration, w, _ = !1, S = !0, T;
  const A = gx(m);
  !((r = (e = A).needsInterpolation) === null || r === void 0) && r.call(e, i, d) && (T = Sd([0, 100], [i, d], {
    clamp: !1
  }), i = 0, d = 100);
  const R = A(Object.assign(Object.assign({}, m), { from: i, to: d }));
  function N() {
    b++, n === "reverse" ? (S = b % 2 === 0, g = xx(g, y, u, S)) : (g = Rd(g, y, u), n === "mirror" && R.flipTarget()), _ = !1, c && c();
  }
  function U() {
    v.stop(), l && l();
  }
  function Q(J) {
    if (S || (J = -J), g += J, !_) {
      const q = R.next(Math.max(0, g));
      w = q.value, T && (w = T(w)), _ = S ? q.done : g <= 0;
    }
    f == null || f(w), _ && (b === 0 && (y != null || (y = g)), b < a ? _x(g, y, u, S) && N() : U());
  }
  function ee() {
    h == null || h(), v = p(Q), v.start();
  }
  return o && ee(), {
    stop: () => {
      s == null || s(), v.stop();
    }
  };
}
function Fd(t, e) {
  return e ? t * (1e3 / e) : 0;
}
function Cx({ from: t = 0, velocity: e = 0, min: r, max: i, power: o = 0.8, timeConstant: p = 750, bounceStiffness: g = 500, bounceDamping: a = 10, restDelta: n = 1, modifyTarget: u, driver: h, onUpdate: s, onComplete: l, onStop: c }) {
  let f;
  function m(y) {
    return r !== void 0 && y < r || i !== void 0 && y > i;
  }
  function d(y) {
    return r === void 0 ? i : i === void 0 || Math.abs(r - y) < Math.abs(i - y) ? r : i;
  }
  function v(y) {
    f == null || f.stop(), f = Ld(Object.assign(Object.assign({}, y), {
      driver: h,
      onUpdate: (w) => {
        var _;
        s == null || s(w), (_ = y.onUpdate) === null || _ === void 0 || _.call(y, w);
      },
      onComplete: l,
      onStop: c
    }));
  }
  function b(y) {
    v(Object.assign({ type: "spring", stiffness: g, damping: a, restDelta: n }, y));
  }
  if (m(t))
    b({ from: t, velocity: e, to: d(t) });
  else {
    let y = o * e + t;
    typeof u < "u" && (y = u(y));
    const w = d(y), _ = w === r ? -1 : 1;
    let S, T;
    const A = (R) => {
      S = T, T = R, e = Fd(R - S, Id().delta), (_ === 1 && R > w || _ === -1 && R < w) && b({ from: R, to: w, velocity: e });
    };
    v({
      type: "decay",
      from: t,
      velocity: e,
      timeConstant: p,
      power: o,
      restDelta: n,
      modifyTarget: u,
      onUpdate: m(y) ? A : void 0
    });
  }
  return {
    stop: () => f == null ? void 0 : f.stop()
  };
}
const zd = (t, e) => 1 - 3 * e + 3 * t, jd = (t, e) => 3 * e - 6 * t, Bd = (t) => 3 * t, io = (t, e, r) => ((zd(e, r) * t + jd(e, r)) * t + Bd(e)) * t, Nd = (t, e, r) => 3 * zd(e, r) * t * t + 2 * jd(e, r) * t + Bd(e), Tx = 1e-7, kx = 10;
function Ex(t, e, r, i, o) {
  let p, g, a = 0;
  do
    g = e + (r - e) / 2, p = io(g, i, o) - t, p > 0 ? r = g : e = g;
  while (Math.abs(p) > Tx && ++a < kx);
  return g;
}
const Ox = 8, Px = 1e-3;
function Mx(t, e, r, i) {
  for (let o = 0; o < Ox; ++o) {
    const p = Nd(e, r, i);
    if (p === 0)
      return e;
    e -= (io(e, r, i) - t) / p;
  }
  return e;
}
const jn = 11, Sn = 1 / (jn - 1);
function Ax(t, e, r, i) {
  if (t === e && r === i)
    return kd;
  const o = new Float32Array(jn);
  for (let g = 0; g < jn; ++g)
    o[g] = io(g * Sn, t, r);
  function p(g) {
    let a = 0, n = 1;
    const u = jn - 1;
    for (; n !== u && o[n] <= g; ++n)
      a += Sn;
    --n;
    const h = (g - o[n]) / (o[n + 1] - o[n]), s = a + h * Sn, l = Nd(s, t, r);
    return l >= Px ? Mx(g, s, t, r) : l === 0 ? s : Ex(g, a, a + Sn, t, r);
  }
  return (g) => g === 0 || g === 1 ? g : io(p(g), e, i);
}
function Dx({ onTap: t, onTapStart: e, onTapCancel: r, whileTap: i, visualElement: o }) {
  const p = t || e || r || i, g = de(!1), a = de(null), n = {
    passive: !(e || t || r || c)
  };
  function u() {
    a.current && a.current(), a.current = null;
  }
  function h() {
    return u(), g.current = !1, o.animationState && o.animationState.setActive(Le.Tap, !1), !pd();
  }
  function s(f, m) {
    !h() || (gd(o.getInstance(), f.target) ? t && t(f, m) : r && r(f, m));
  }
  function l(f, m) {
    !h() || r && r(f, m);
  }
  function c(f, m) {
    u(), !g.current && (g.current = !0, a.current = dl(Nc(window, "pointerup", s, n), Nc(window, "pointercancel", l, n)), o.animationState && o.animationState.setActive(Le.Tap, !0), e && e(f, m));
  }
  Zs(o, "pointerdown", p ? c : void 0, n), md(u);
}
const Ix = "production", Vd = typeof process > "u" || process.env === void 0 ? Ix : "production", Zc = /* @__PURE__ */ new Set();
function $d(t, e, r) {
  t || Zc.has(e) || (console.warn(e), r && console.warn(r), Zc.add(e));
}
const ia = /* @__PURE__ */ new WeakMap(), us = /* @__PURE__ */ new WeakMap(), Rx = (t) => {
  const e = ia.get(t.target);
  e && e(t);
}, Lx = (t) => {
  t.forEach(Rx);
};
function Fx({ root: t, ...e }) {
  const r = t || document;
  us.has(r) || us.set(r, {});
  const i = us.get(r), o = JSON.stringify(e);
  return i[o] || (i[o] = new IntersectionObserver(Lx, { root: t, ...e })), i[o];
}
function zx(t, e, r) {
  const i = Fx(e);
  return ia.set(t, r), i.observe(t), () => {
    ia.delete(t), i.unobserve(t);
  };
}
function jx({ visualElement: t, whileInView: e, onViewportEnter: r, onViewportLeave: i, viewport: o = {} }) {
  const p = de({
    hasEnteredView: !1,
    isInView: !1
  });
  let g = Boolean(e || r || i);
  o.once && p.current.hasEnteredView && (g = !1), (typeof IntersectionObserver > "u" ? Vx : Nx)(g, p.current, t, o);
}
const Bx = {
  some: 0,
  all: 1
};
function Nx(t, e, r, { root: i, margin: o, amount: p = "some", once: g }) {
  xe(() => {
    if (!t)
      return;
    const a = {
      root: i == null ? void 0 : i.current,
      rootMargin: o,
      threshold: typeof p == "number" ? p : Bx[p]
    }, n = (u) => {
      const { isIntersecting: h } = u;
      if (e.isInView === h || (e.isInView = h, g && !h && e.hasEnteredView))
        return;
      h && (e.hasEnteredView = !0), r.animationState && r.animationState.setActive(Le.InView, h);
      const s = r.getProps(), l = h ? s.onViewportEnter : s.onViewportLeave;
      l && l(u);
    };
    return zx(r.getInstance(), a, n);
  }, [t, i, o, p]);
}
function Vx(t, e, r, { fallback: i = !0 }) {
  xe(() => {
    !t || !i || (Vd !== "production" && $d(!1, "IntersectionObserver not available on this device. whileInView animations will trigger on mount."), requestAnimationFrame(() => {
      e.hasEnteredView = !0;
      const { onViewportEnter: o } = r.getProps();
      o && o(null), r.animationState && r.animationState.setActive(Le.InView, !0);
    }));
  }, [t]);
}
const qr = (t) => (e) => (t(e), null), $x = {
  inView: qr(jx),
  tap: qr(Dx),
  focus: qr(gw),
  hover: qr(Pw)
};
function Hx() {
  const t = De(rn);
  if (t === null)
    return [!0, null];
  const { isPresent: e, onExitComplete: r, register: i } = t, o = yt();
  return xe(() => i(o), []), !e && r ? [!1, () => r && r(o)] : [!0];
}
function Hd(t, e) {
  if (!Array.isArray(e))
    return !1;
  const r = e.length;
  if (r !== t.length)
    return !1;
  for (let i = 0; i < r; i++)
    if (e[i] !== t[i])
      return !1;
  return !0;
}
const na = (t) => t * 1e3, Ux = {
  linear: kd,
  easeIn: gl,
  easeInOut: Ed,
  easeOut: tx,
  circIn: Od,
  circInOut: rx,
  circOut: Pd,
  backIn: ml,
  backInOut: nx,
  backOut: ix,
  anticipate: ox,
  bounceIn: cx,
  bounceInOut: ux,
  bounceOut: ro
}, Jc = (t) => {
  if (Array.isArray(t)) {
    to(t.length === 4);
    const [e, r, i, o] = t;
    return Ax(e, r, i, o);
  } else if (typeof t == "string")
    return Ux[t];
  return t;
}, Wx = (t) => Array.isArray(t) && typeof t[0] != "number", Qc = (t, e) => t === "zIndex" ? !1 : !!(typeof e == "number" || Array.isArray(e) || typeof e == "string" && Dr.test(e) && !e.startsWith("url(")), dr = () => ({
  type: "spring",
  stiffness: 500,
  damping: 25,
  restSpeed: 10
}), Cn = (t) => ({
  type: "spring",
  stiffness: 550,
  damping: t === 0 ? 2 * Math.sqrt(550) : 30,
  restSpeed: 10
}), hs = () => ({
  type: "keyframes",
  ease: "linear",
  duration: 0.3
}), Yx = (t) => ({
  type: "keyframes",
  duration: 0.8,
  values: t
}), eu = {
  x: dr,
  y: dr,
  z: dr,
  rotate: dr,
  rotateX: dr,
  rotateY: dr,
  rotateZ: dr,
  scaleX: Cn,
  scaleY: Cn,
  scale: Cn,
  opacity: hs,
  backgroundColor: hs,
  color: hs,
  default: Cn
}, Xx = (t, e) => {
  let r;
  return Yi(e) ? r = Yx : r = eu[t] || eu.default, { to: e, ...r(e) };
}, Gx = {
  ...Jf,
  color: rt,
  backgroundColor: rt,
  outlineColor: rt,
  fill: rt,
  stroke: rt,
  borderColor: rt,
  borderTopColor: rt,
  borderRightColor: rt,
  borderBottomColor: rt,
  borderLeftColor: rt,
  filter: qs,
  WebkitFilter: qs
}, vl = (t) => Gx[t];
function bl(t, e) {
  var r;
  let i = vl(t);
  return i !== qs && (i = Dr), (r = i.getAnimatableNone) === null || r === void 0 ? void 0 : r.call(i, e);
}
const qx = {
  current: !1
};
function Kx({ when: t, delay: e, delayChildren: r, staggerChildren: i, staggerDirection: o, repeat: p, repeatType: g, repeatDelay: a, from: n, ...u }) {
  return !!Object.keys(u).length;
}
function Zx({ ease: t, times: e, yoyo: r, flip: i, loop: o, ...p }) {
  const g = { ...p };
  return e && (g.offset = e), p.duration && (g.duration = na(p.duration)), p.repeatDelay && (g.repeatDelay = na(p.repeatDelay)), t && (g.ease = Wx(t) ? t.map(Jc) : Jc(t)), p.type === "tween" && (g.type = "keyframes"), (r || o || i) && (r ? g.repeatType = "reverse" : o ? g.repeatType = "loop" : i && (g.repeatType = "mirror"), g.repeat = o || r || i || p.repeat), p.type !== "spring" && (g.type = "keyframes"), g;
}
function Jx(t, e) {
  var r, i;
  return (i = (r = (Ud(t, e) || {}).delay) !== null && r !== void 0 ? r : t.delay) !== null && i !== void 0 ? i : 0;
}
function Qx(t) {
  return Array.isArray(t.to) && t.to[0] === null && (t.to = [...t.to], t.to[0] = t.from), t;
}
function e2(t, e, r) {
  return Array.isArray(e.to) && t.duration === void 0 && (t.duration = 0.8), Qx(e), Kx(t) || (t = {
    ...t,
    ...Xx(r, e.to)
  }), {
    ...e,
    ...Zx(t)
  };
}
function t2(t, e, r, i, o) {
  const p = Ud(i, t) || {};
  let g = p.from !== void 0 ? p.from : e.get();
  const a = Qc(t, r);
  g === "none" && a && typeof r == "string" ? g = bl(t, r) : tu(g) && typeof r == "string" ? g = ru(r) : !Array.isArray(r) && tu(r) && typeof g == "string" && (r = ru(g));
  const n = Qc(t, g);
  function u() {
    const s = {
      from: g,
      to: r,
      velocity: e.getVelocity(),
      onComplete: o,
      onUpdate: (l) => e.set(l)
    };
    return p.type === "inertia" || p.type === "decay" ? Cx({ ...s, ...p }) : Ld({
      ...e2(p, s, t),
      onUpdate: (l) => {
        s.onUpdate(l), p.onUpdate && p.onUpdate(l);
      },
      onComplete: () => {
        s.onComplete(), p.onComplete && p.onComplete();
      }
    });
  }
  function h() {
    const s = ld(r);
    return e.set(s), o(), p.onUpdate && p.onUpdate(s), p.onComplete && p.onComplete(), { stop: () => {
    } };
  }
  return !n || !a || p.type === !1 ? h : u;
}
function tu(t) {
  return t === 0 || typeof t == "string" && parseFloat(t) === 0 && t.indexOf(" ") === -1;
}
function ru(t) {
  return typeof t == "number" ? 0 : bl("", t);
}
function Ud(t, e) {
  return t[e] || t.default || t;
}
function r2(t, e, r, i = {}) {
  return qx.current && (i = { type: !1 }), e.start((o) => {
    let p, g;
    const a = t2(t, e, r, i, o), n = Jx(i, t), u = () => g = a();
    return n ? p = window.setTimeout(u, na(n)) : u(), () => {
      clearTimeout(p), g && g.stop();
    };
  });
}
const i2 = (t) => /^\-?\d*\.?\d+$/.test(t), n2 = (t) => /^0[^.\s]+$/.test(t);
function o2(t, e) {
  t.indexOf(e) === -1 && t.push(e);
}
function s2(t, e) {
  const r = t.indexOf(e);
  r > -1 && t.splice(r, 1);
}
class Bn {
  constructor() {
    this.subscriptions = [];
  }
  add(e) {
    return o2(this.subscriptions, e), () => s2(this.subscriptions, e);
  }
  notify(e, r, i) {
    const o = this.subscriptions.length;
    if (!!o)
      if (o === 1)
        this.subscriptions[0](e, r, i);
      else
        for (let p = 0; p < o; p++) {
          const g = this.subscriptions[p];
          g && g(e, r, i);
        }
  }
  getSize() {
    return this.subscriptions.length;
  }
  clear() {
    this.subscriptions.length = 0;
  }
}
const a2 = (t) => !isNaN(parseFloat(t));
class l2 {
  constructor(e) {
    this.version = "7.5.1", this.timeDelta = 0, this.lastUpdated = 0, this.updateSubscribers = new Bn(), this.velocityUpdateSubscribers = new Bn(), this.renderSubscribers = new Bn(), this.canTrackVelocity = !1, this.updateAndNotify = (r, i = !0) => {
      this.prev = this.current, this.current = r;
      const { delta: o, timestamp: p } = Id();
      this.lastUpdated !== p && (this.timeDelta = o, this.lastUpdated = p, fi.postRender(this.scheduleVelocityCheck)), this.prev !== this.current && this.updateSubscribers.notify(this.current), this.velocityUpdateSubscribers.getSize() && this.velocityUpdateSubscribers.notify(this.getVelocity()), i && this.renderSubscribers.notify(this.current);
    }, this.scheduleVelocityCheck = () => fi.postRender(this.velocityCheck), this.velocityCheck = ({ timestamp: r }) => {
      r !== this.lastUpdated && (this.prev = this.current, this.velocityUpdateSubscribers.notify(this.getVelocity()));
    }, this.hasAnimated = !1, this.prev = this.current = e, this.canTrackVelocity = a2(this.current);
  }
  onChange(e) {
    return this.updateSubscribers.add(e);
  }
  clearListeners() {
    this.updateSubscribers.clear();
  }
  onRenderRequest(e) {
    return e(this.get()), this.renderSubscribers.add(e);
  }
  attach(e) {
    this.passiveEffect = e;
  }
  set(e, r = !0) {
    !r || !this.passiveEffect ? this.updateAndNotify(e, r) : this.passiveEffect(e, this.updateAndNotify);
  }
  get() {
    return this.current;
  }
  getPrevious() {
    return this.prev;
  }
  getVelocity() {
    return this.canTrackVelocity ? Fd(parseFloat(this.current) - parseFloat(this.prev), this.timeDelta) : 0;
  }
  start(e) {
    return this.stop(), new Promise((r) => {
      this.hasAnimated = !0, this.stopAnimation = e(r);
    }).then(() => this.clearAnimation());
  }
  stop() {
    this.stopAnimation && this.stopAnimation(), this.clearAnimation();
  }
  isAnimating() {
    return !!this.stopAnimation;
  }
  clearAnimation() {
    this.stopAnimation = null;
  }
  destroy() {
    this.updateSubscribers.clear(), this.renderSubscribers.clear(), this.stop();
  }
}
function Gi(t) {
  return new l2(t);
}
const Wd = (t) => (e) => e.test(t), c2 = {
  test: (t) => t === "auto",
  parse: (t) => t
}, Yd = [Ar, be, ri, Vt, zy, Fy, c2], xi = (t) => Yd.find(Wd(t)), u2 = [...Yd, rt, Dr], h2 = (t) => u2.find(Wd(t));
function f2(t) {
  const e = {};
  return t.forEachValue((r, i) => e[i] = r.get()), e;
}
function d2(t) {
  const e = {};
  return t.forEachValue((r, i) => e[i] = r.getVelocity()), e;
}
function Mo(t, e, r) {
  const i = t.getProps();
  return ad(i, e, r !== void 0 ? r : i.custom, f2(t), d2(t));
}
function p2(t, e, r) {
  t.hasValue(e) ? t.getValue(e).set(r) : t.addValue(e, Gi(r));
}
function g2(t, e) {
  const r = Mo(t, e);
  let { transitionEnd: i = {}, transition: o = {}, ...p } = r ? t.makeTargetAnimatable(r, !1) : {};
  p = { ...p, ...i };
  for (const g in p) {
    const a = ld(p[g]);
    p2(t, g, a);
  }
}
function m2(t, e, r) {
  var i, o;
  const p = Object.keys(e).filter((a) => !t.hasValue(a)), g = p.length;
  if (!!g)
    for (let a = 0; a < g; a++) {
      const n = p[a], u = e[n];
      let h = null;
      Array.isArray(u) && (h = u[0]), h === null && (h = (o = (i = r[n]) !== null && i !== void 0 ? i : t.readValue(n)) !== null && o !== void 0 ? o : e[n]), h != null && (typeof h == "string" && (i2(h) || n2(h)) ? h = parseFloat(h) : !h2(h) && Dr.test(u) && (h = bl(n, u)), t.addValue(n, Gi(h)), r[n] === void 0 && (r[n] = h), t.setBaseTarget(n, h));
    }
}
function v2(t, e) {
  return e ? (e[t] || e.default || e).from : void 0;
}
function b2(t, e, r) {
  var i;
  const o = {};
  for (const p in t) {
    const g = v2(p, e);
    o[p] = g !== void 0 ? g : (i = r.getValue(p)) === null || i === void 0 ? void 0 : i.get();
  }
  return o;
}
function no(t) {
  return Boolean(Lt(t) && t.add);
}
function y2(t, e, r = {}) {
  t.notifyAnimationStart(e);
  let i;
  if (Array.isArray(e)) {
    const o = e.map((p) => oa(t, p, r));
    i = Promise.all(o);
  } else if (typeof e == "string")
    i = oa(t, e, r);
  else {
    const o = typeof e == "function" ? Mo(t, e, r.custom) : e;
    i = Xd(t, o, r);
  }
  return i.then(() => t.notifyAnimationComplete(e));
}
function oa(t, e, r = {}) {
  var i;
  const o = Mo(t, e, r.custom);
  let { transition: p = t.getDefaultTransition() || {} } = o || {};
  r.transitionOverride && (p = r.transitionOverride);
  const g = o ? () => Xd(t, o, r) : () => Promise.resolve(), a = !((i = t.variantChildren) === null || i === void 0) && i.size ? (u = 0) => {
    const { delayChildren: h = 0, staggerChildren: s, staggerDirection: l } = p;
    return w2(t, e, h + u, s, l, r);
  } : () => Promise.resolve(), { when: n } = p;
  if (n) {
    const [u, h] = n === "beforeChildren" ? [g, a] : [a, g];
    return u().then(h);
  } else
    return Promise.all([g(), a(r.delay)]);
}
function Xd(t, e, { delay: r = 0, transitionOverride: i, type: o } = {}) {
  var p;
  let { transition: g = t.getDefaultTransition(), transitionEnd: a, ...n } = t.makeTargetAnimatable(e);
  const u = t.getValue("willChange");
  i && (g = i);
  const h = [], s = o && ((p = t.animationState) === null || p === void 0 ? void 0 : p.getState()[o]);
  for (const l in n) {
    const c = t.getValue(l), f = n[l];
    if (!c || f === void 0 || s && _2(s, l))
      continue;
    let m = { delay: r, ...g };
    t.shouldReduceMotion && nn.has(l) && (m = {
      ...m,
      type: !1,
      delay: 0
    });
    let d = r2(l, c, f, m);
    no(u) && (u.add(l), d = d.then(() => u.remove(l))), h.push(d);
  }
  return Promise.all(h).then(() => {
    a && g2(t, a);
  });
}
function w2(t, e, r = 0, i = 0, o = 1, p) {
  const g = [], a = (t.variantChildren.size - 1) * i, n = o === 1 ? (u = 0) => u * i : (u = 0) => a - u * i;
  return Array.from(t.variantChildren).sort(x2).forEach((u, h) => {
    g.push(oa(u, e, {
      ...p,
      delay: r + n(h)
    }).then(() => u.notifyAnimationComplete(e)));
  }), Promise.all(g);
}
function x2(t, e) {
  return t.sortNodePosition(e);
}
function _2({ protectedKeys: t, needsAnimating: e }, r) {
  const i = t.hasOwnProperty(r) && e[r] !== !0;
  return e[r] = !1, i;
}
const yl = [
  Le.Animate,
  Le.InView,
  Le.Focus,
  Le.Hover,
  Le.Tap,
  Le.Drag,
  Le.Exit
], S2 = [...yl].reverse(), C2 = yl.length;
function T2(t) {
  return (e) => Promise.all(e.map(({ animation: r, options: i }) => y2(t, r, i)));
}
function k2(t) {
  let e = T2(t);
  const r = O2();
  let i = !0;
  const o = (n, u) => {
    const h = Mo(t, u);
    if (h) {
      const { transition: s, transitionEnd: l, ...c } = h;
      n = { ...n, ...c, ...l };
    }
    return n;
  };
  function p(n) {
    e = n(t);
  }
  function g(n, u) {
    var h;
    const s = t.getProps(), l = t.getVariantContext(!0) || {}, c = [], f = /* @__PURE__ */ new Set();
    let m = {}, d = 1 / 0;
    for (let b = 0; b < C2; b++) {
      const y = S2[b], w = r[y], _ = (h = s[y]) !== null && h !== void 0 ? h : l[y], S = Hi(_), T = y === u ? w.isActive : null;
      T === !1 && (d = b);
      let A = _ === l[y] && _ !== s[y] && S;
      if (A && i && t.manuallyAnimateOnMount && (A = !1), w.protectedKeys = { ...m }, !w.isActive && T === null || !_ && !w.prevProp || ko(_) || typeof _ == "boolean")
        continue;
      const R = E2(w.prevProp, _);
      let N = R || y === u && w.isActive && !A && S || b > d && S;
      const U = Array.isArray(_) ? _ : [_];
      let Q = U.reduce(o, {});
      T === !1 && (Q = {});
      const { prevResolvedValues: ee = {} } = w, J = {
        ...ee,
        ...Q
      }, q = (re) => {
        N = !0, f.delete(re), w.needsAnimating[re] = !0;
      };
      for (const re in J) {
        const le = Q[re], ne = ee[re];
        m.hasOwnProperty(re) || (le !== ne ? Yi(le) && Yi(ne) ? !Hd(le, ne) || R ? q(re) : w.protectedKeys[re] = !0 : le !== void 0 ? q(re) : f.add(re) : le !== void 0 && f.has(re) ? q(re) : w.protectedKeys[re] = !0);
      }
      w.prevProp = _, w.prevResolvedValues = Q, w.isActive && (m = { ...m, ...Q }), i && t.blockInitialAnimation && (N = !1), N && !A && c.push(...U.map((re) => ({
        animation: re,
        options: { type: y, ...n }
      })));
    }
    if (f.size) {
      const b = {};
      f.forEach((y) => {
        const w = t.getBaseTarget(y);
        w !== void 0 && (b[y] = w);
      }), c.push({ animation: b });
    }
    let v = Boolean(c.length);
    return i && s.initial === !1 && !t.manuallyAnimateOnMount && (v = !1), i = !1, v ? e(c) : Promise.resolve();
  }
  function a(n, u, h) {
    var s;
    if (r[n].isActive === u)
      return Promise.resolve();
    (s = t.variantChildren) === null || s === void 0 || s.forEach((c) => {
      var f;
      return (f = c.animationState) === null || f === void 0 ? void 0 : f.setActive(n, u);
    }), r[n].isActive = u;
    const l = g(h, n);
    for (const c in r)
      r[c].protectedKeys = {};
    return l;
  }
  return {
    animateChanges: g,
    setActive: a,
    setAnimateFunction: p,
    getState: () => r
  };
}
function E2(t, e) {
  return typeof e == "string" ? e !== t : Array.isArray(e) ? !Hd(e, t) : !1;
}
function pr(t = !1) {
  return {
    isActive: t,
    protectedKeys: {},
    needsAnimating: {},
    prevResolvedValues: {}
  };
}
function O2() {
  return {
    [Le.Animate]: pr(!0),
    [Le.InView]: pr(),
    [Le.Hover]: pr(),
    [Le.Tap]: pr(),
    [Le.Drag]: pr(),
    [Le.Focus]: pr(),
    [Le.Exit]: pr()
  };
}
const P2 = {
  animation: qr(({ visualElement: t, animate: e }) => {
    t.animationState || (t.animationState = k2(t)), ko(e) && xe(() => e.subscribe(t), [e]);
  }),
  exit: qr((t) => {
    const { custom: e, visualElement: r } = t, [i, o] = Hx(), p = De(rn);
    xe(() => {
      r.isPresent = i;
      const g = r.animationState && r.animationState.setActive(Le.Exit, !i, {
        custom: p && p.custom || e
      });
      g && !i && g.then(o);
    }, [i]);
  })
};
function M2({ top: t, left: e, right: r, bottom: i }) {
  return {
    x: { min: e, max: r },
    y: { min: t, max: i }
  };
}
function A2(t, e) {
  if (!e)
    return t;
  const r = e({ x: t.left, y: t.top }), i = e({ x: t.right, y: t.bottom });
  return {
    top: r.y,
    left: r.x,
    bottom: i.y,
    right: i.x
  };
}
function D2(t, e) {
  return M2(A2(t.getBoundingClientRect(), e));
}
const sa = { current: null }, Gd = { current: !1 };
function I2() {
  if (Gd.current = !0, !!Mr)
    if (window.matchMedia) {
      const t = window.matchMedia("(prefers-reduced-motion)"), e = () => sa.current = t.matches;
      t.addListener(e), e();
    } else
      sa.current = !1;
}
const Tn = [
  "LayoutMeasure",
  "BeforeLayoutMeasure",
  "LayoutUpdate",
  "ViewportBoxUpdate",
  "Update",
  "Render",
  "AnimationComplete",
  "LayoutAnimationComplete",
  "AnimationStart",
  "LayoutAnimationStart",
  "SetAxisTarget",
  "Unmount"
];
function R2() {
  const t = Tn.map(() => new Bn()), e = {}, r = {
    clearAllListeners: () => t.forEach((i) => i.clear()),
    updatePropListeners: (i) => {
      Tn.forEach((o) => {
        var p;
        const g = "on" + o, a = i[g];
        (p = e[o]) === null || p === void 0 || p.call(e), a && (e[o] = r[g](a));
      });
    }
  };
  return t.forEach((i, o) => {
    r["on" + Tn[o]] = (p) => i.add(p), r["notify" + Tn[o]] = (...p) => i.notify(...p);
  }), r;
}
function L2(t, e, r) {
  const { willChange: i } = e;
  for (const o in e) {
    const p = e[o], g = r[o];
    if (Lt(p))
      t.addValue(o, p), no(i) && i.add(o);
    else if (Lt(g))
      t.addValue(o, Gi(p)), no(i) && i.remove(o);
    else if (g !== p)
      if (t.hasValue(o)) {
        const a = t.getValue(o);
        !a.hasAnimated && a.set(p);
      } else {
        const a = t.getStaticValue(o);
        t.addValue(o, Gi(a !== void 0 ? a : p));
      }
  }
  for (const o in r)
    e[o] === void 0 && t.removeValue(o);
  return e;
}
const qd = Object.keys(Ui), F2 = qd.length, Kd = ({ treeType: t = "", build: e, getBaseTarget: r, makeTargetAnimatable: i, measureViewportBox: o, render: p, readValueFromInstance: g, removeValueFromRenderState: a, sortNodePosition: n, scrapeMotionValuesFromProps: u }) => ({ parent: h, props: s, presenceId: l, blockInitialAnimation: c, visualState: f, reducedMotionConfig: m }, d = {}) => {
  let v = !1;
  const { latestValues: b, renderState: y } = f;
  let w;
  const _ = R2(), S = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Map();
  let A = {};
  const R = {
    ...b
  };
  let N;
  function U() {
    !w || !v || (Q(), p(w, y, s.style, C.projection));
  }
  function Q() {
    e(C, y, b, d, s);
  }
  function ee() {
    _.notifyUpdate(b);
  }
  function J(k, P) {
    const D = P.onChange((M) => {
      b[k] = M, s.onUpdate && fi.update(ee, !1, !0);
    }), B = P.onRenderRequest(C.scheduleRender);
    T.set(k, () => {
      D(), B();
    });
  }
  const { willChange: q, ...re } = u(s);
  for (const k in re) {
    const P = re[k];
    b[k] !== void 0 && Lt(P) && (P.set(b[k], !1), no(q) && q.add(k));
  }
  if (s.values)
    for (const k in s.values)
      b[k] !== void 0 && s.values[k].set(b[k]);
  const le = Eo(s), ne = Vf(s), C = {
    treeType: t,
    current: null,
    depth: h ? h.depth + 1 : 0,
    parent: h,
    children: /* @__PURE__ */ new Set(),
    presenceId: l,
    shouldReduceMotion: null,
    variantChildren: ne ? /* @__PURE__ */ new Set() : void 0,
    isVisible: void 0,
    manuallyAnimateOnMount: Boolean(h == null ? void 0 : h.isMounted()),
    blockInitialAnimation: c,
    isMounted: () => Boolean(w),
    mount(k) {
      v = !0, w = C.current = k, C.projection && C.projection.mount(k), ne && h && !le && (N = h == null ? void 0 : h.addVariantChild(C)), S.forEach((P, D) => J(D, P)), Gd.current || I2(), C.shouldReduceMotion = m === "never" ? !1 : m === "always" ? !0 : sa.current, h == null || h.children.add(C), C.setProps(s);
    },
    unmount() {
      var k;
      (k = C.projection) === null || k === void 0 || k.unmount(), ra.update(ee), ra.render(U), T.forEach((P) => P()), N == null || N(), h == null || h.children.delete(C), _.clearAllListeners(), w = void 0, v = !1;
    },
    loadFeatures(k, P, D, B, M, E) {
      const L = [];
      for (let z = 0; z < F2; z++) {
        const Y = qd[z], { isEnabled: $, Component: W } = Ui[Y];
        $(k) && W && L.push(Ch(W, {
          key: Y,
          ...k,
          visualElement: C
        }));
      }
      if (!C.projection && M) {
        C.projection = new M(B, C.getLatestValues(), h && h.projection);
        const { layoutId: z, layout: Y, drag: $, dragConstraints: W, layoutScroll: j } = k;
        C.projection.setOptions({
          layoutId: z,
          layout: Y,
          alwaysMeasureLayout: Boolean($) || W && Nf(W),
          visualElement: C,
          scheduleRender: () => C.scheduleRender(),
          animationType: typeof Y == "string" ? Y : "both",
          initialPromotionConfig: E,
          layoutScroll: j
        });
      }
      return L;
    },
    addVariantChild(k) {
      var P;
      const D = C.getClosestVariantNode();
      if (D)
        return (P = D.variantChildren) === null || P === void 0 || P.add(k), () => D.variantChildren.delete(k);
    },
    sortNodePosition(k) {
      return !n || t !== k.treeType ? 0 : n(C.getInstance(), k.getInstance());
    },
    getClosestVariantNode: () => ne ? C : h == null ? void 0 : h.getClosestVariantNode(),
    getLayoutId: () => s.layoutId,
    getInstance: () => w,
    getStaticValue: (k) => b[k],
    setStaticValue: (k, P) => b[k] = P,
    getLatestValues: () => b,
    setVisibility(k) {
      C.isVisible !== k && (C.isVisible = k, C.scheduleRender());
    },
    makeTargetAnimatable(k, P = !0) {
      return i(C, k, s, P);
    },
    measureViewportBox() {
      return o(w, s);
    },
    addValue(k, P) {
      C.hasValue(k) && C.removeValue(k), S.set(k, P), b[k] = P.get(), J(k, P);
    },
    removeValue(k) {
      var P;
      S.delete(k), (P = T.get(k)) === null || P === void 0 || P(), T.delete(k), delete b[k], a(k, y);
    },
    hasValue: (k) => S.has(k),
    getValue(k, P) {
      if (s.values && s.values[k])
        return s.values[k];
      let D = S.get(k);
      return D === void 0 && P !== void 0 && (D = Gi(P), C.addValue(k, D)), D;
    },
    forEachValue: (k) => S.forEach(k),
    readValue: (k) => b[k] !== void 0 ? b[k] : g(w, k, d),
    setBaseTarget(k, P) {
      R[k] = P;
    },
    getBaseTarget(k) {
      if (r) {
        const P = r(s, k);
        if (P !== void 0 && !Lt(P))
          return P;
      }
      return R[k];
    },
    ..._,
    build() {
      return Q(), y;
    },
    scheduleRender() {
      fi.render(U, !1, !0);
    },
    syncRender: U,
    setProps(k) {
      (k.transformTemplate || s.transformTemplate) && C.scheduleRender(), s = k, _.updatePropListeners(k), A = L2(C, u(s), A);
    },
    getProps: () => s,
    getVariant: (k) => {
      var P;
      return (P = s.variants) === null || P === void 0 ? void 0 : P[k];
    },
    getDefaultTransition: () => s.transition,
    getTransformPagePoint: () => s.transformPagePoint,
    getVariantContext(k = !1) {
      if (k)
        return h == null ? void 0 : h.getVariantContext();
      if (!le) {
        const D = (h == null ? void 0 : h.getVariantContext()) || {};
        return s.initial !== void 0 && (D.initial = s.initial), D;
      }
      const P = {};
      for (let D = 0; D < z2; D++) {
        const B = Zd[D], M = s[B];
        (Hi(M) || M === !1) && (P[B] = M);
      }
      return P;
    }
  };
  return C;
}, Zd = ["initial", ...yl], z2 = Zd.length;
function aa(t) {
  return typeof t == "string" && t.startsWith("var(--");
}
const j2 = /var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/;
function B2(t) {
  const e = j2.exec(t);
  if (!e)
    return [,];
  const [, r, i] = e;
  return [r, i];
}
function la(t, e, r = 1) {
  const [i, o] = B2(t);
  if (!i)
    return;
  const p = window.getComputedStyle(e).getPropertyValue(i);
  return p ? p.trim() : aa(o) ? la(o, e, r + 1) : o;
}
function N2(t, { ...e }, r) {
  const i = t.getInstance();
  if (!(i instanceof Element))
    return { target: e, transitionEnd: r };
  r && (r = { ...r }), t.forEachValue((o) => {
    const p = o.get();
    if (!aa(p))
      return;
    const g = la(p, i);
    g && o.set(g);
  });
  for (const o in e) {
    const p = e[o];
    if (!aa(p))
      continue;
    const g = la(p, i);
    !g || (e[o] = g, r && r[o] === void 0 && (r[o] = p));
  }
  return { target: e, transitionEnd: r };
}
const V2 = /* @__PURE__ */ new Set([
  "width",
  "height",
  "top",
  "left",
  "right",
  "bottom",
  "x",
  "y"
]), Jd = (t) => V2.has(t), $2 = (t) => Object.keys(t).some(Jd), Qd = (t, e) => {
  t.set(e, !1), t.set(e);
}, iu = (t) => t === Ar || t === be;
var nu;
(function(t) {
  t.width = "width", t.height = "height", t.left = "left", t.right = "right", t.top = "top", t.bottom = "bottom";
})(nu || (nu = {}));
const ou = (t, e) => parseFloat(t.split(", ")[e]), su = (t, e) => (r, { transform: i }) => {
  if (i === "none" || !i)
    return 0;
  const o = i.match(/^matrix3d\((.+)\)$/);
  if (o)
    return ou(o[1], e);
  {
    const p = i.match(/^matrix\((.+)\)$/);
    return p ? ou(p[1], t) : 0;
  }
}, H2 = /* @__PURE__ */ new Set(["x", "y", "z"]), U2 = Qn.filter((t) => !H2.has(t));
function W2(t) {
  const e = [];
  return U2.forEach((r) => {
    const i = t.getValue(r);
    i !== void 0 && (e.push([r, i.get()]), i.set(r.startsWith("scale") ? 1 : 0));
  }), e.length && t.syncRender(), e;
}
const au = {
  width: ({ x: t }, { paddingLeft: e = "0", paddingRight: r = "0" }) => t.max - t.min - parseFloat(e) - parseFloat(r),
  height: ({ y: t }, { paddingTop: e = "0", paddingBottom: r = "0" }) => t.max - t.min - parseFloat(e) - parseFloat(r),
  top: (t, { top: e }) => parseFloat(e),
  left: (t, { left: e }) => parseFloat(e),
  bottom: ({ y: t }, { top: e }) => parseFloat(e) + (t.max - t.min),
  right: ({ x: t }, { left: e }) => parseFloat(e) + (t.max - t.min),
  x: su(4, 13),
  y: su(5, 14)
}, Y2 = (t, e, r) => {
  const i = e.measureViewportBox(), o = e.getInstance(), p = getComputedStyle(o), { display: g } = p, a = {};
  g === "none" && e.setStaticValue("display", t.display || "block"), r.forEach((u) => {
    a[u] = au[u](i, p);
  }), e.syncRender();
  const n = e.measureViewportBox();
  return r.forEach((u) => {
    const h = e.getValue(u);
    Qd(h, a[u]), t[u] = au[u](n, p);
  }), t;
}, X2 = (t, e, r = {}, i = {}) => {
  e = { ...e }, i = { ...i };
  const o = Object.keys(e).filter(Jd);
  let p = [], g = !1;
  const a = [];
  if (o.forEach((n) => {
    const u = t.getValue(n);
    if (!t.hasValue(n))
      return;
    let h = r[n], s = xi(h);
    const l = e[n];
    let c;
    if (Yi(l)) {
      const f = l.length, m = l[0] === null ? 1 : 0;
      h = l[m], s = xi(h);
      for (let d = m; d < f; d++)
        c ? to(xi(l[d]) === c) : c = xi(l[d]);
    } else
      c = xi(l);
    if (s !== c)
      if (iu(s) && iu(c)) {
        const f = u.get();
        typeof f == "string" && u.set(parseFloat(f)), typeof l == "string" ? e[n] = parseFloat(l) : Array.isArray(l) && c === be && (e[n] = l.map(parseFloat));
      } else
        (s == null ? void 0 : s.transform) && (c == null ? void 0 : c.transform) && (h === 0 || l === 0) ? h === 0 ? u.set(c.transform(h)) : e[n] = s.transform(l) : (g || (p = W2(t), g = !0), a.push(n), i[n] = i[n] !== void 0 ? i[n] : e[n], Qd(u, l));
  }), a.length) {
    const n = a.indexOf("height") >= 0 ? window.pageYOffset : null, u = Y2(e, t, a);
    return p.length && p.forEach(([h, s]) => {
      t.getValue(h).set(s);
    }), t.syncRender(), Mr && n !== null && window.scrollTo({ top: n }), { target: u, transitionEnd: i };
  } else
    return { target: e, transitionEnd: i };
};
function G2(t, e, r, i) {
  return $2(e) ? X2(t, e, r, i) : { target: e, transitionEnd: i };
}
const q2 = (t, e, r, i) => {
  const o = N2(t, e, i);
  return e = o.target, i = o.transitionEnd, G2(t, e, r, i);
};
function K2(t) {
  return window.getComputedStyle(t);
}
const ep = {
  treeType: "dom",
  readValueFromInstance(t, e) {
    if (nn.has(e)) {
      const r = vl(e);
      return r && r.default || 0;
    } else {
      const r = K2(t), i = (Uf(e) ? r.getPropertyValue(e) : r[e]) || 0;
      return typeof i == "string" ? i.trim() : i;
    }
  },
  sortNodePosition(t, e) {
    return t.compareDocumentPosition(e) & 2 ? 1 : -1;
  },
  getBaseTarget(t, e) {
    var r;
    return (r = t.style) === null || r === void 0 ? void 0 : r[e];
  },
  measureViewportBox(t, { transformPagePoint: e }) {
    return D2(t, e);
  },
  resetTransform(t, e, r) {
    const { transformTemplate: i } = r;
    e.style.transform = i ? i({}, "") : "none", t.scheduleRender();
  },
  restoreTransform(t, e) {
    t.style.transform = e.style.transform;
  },
  removeValueFromRenderState(t, { vars: e, style: r }) {
    delete e[t], delete r[t];
  },
  makeTargetAnimatable(t, { transition: e, transitionEnd: r, ...i }, { transformValues: o }, p = !0) {
    let g = b2(i, e || {}, t);
    if (o && (r && (r = o(r)), i && (i = o(i)), g && (g = o(g))), p) {
      m2(t, i, g);
      const a = q2(t, i, g, r);
      r = a.transitionEnd, i = a.target;
    }
    return {
      transition: e,
      transitionEnd: r,
      ...i
    };
  },
  scrapeMotionValuesFromProps: ul,
  build(t, e, r, i, o) {
    t.isVisible !== void 0 && (e.style.visibility = t.isVisible ? "visible" : "hidden"), al(e, r, i, o.transformTemplate);
  },
  render: id
}, Z2 = Kd(ep), J2 = Kd({
  ...ep,
  getBaseTarget(t, e) {
    return t[e];
  },
  readValueFromInstance(t, e) {
    var r;
    return nn.has(e) ? ((r = vl(e)) === null || r === void 0 ? void 0 : r.default) || 0 : (e = nd.has(e) ? e : rd(e), t.getAttribute(e));
  },
  scrapeMotionValuesFromProps: sd,
  build(t, e, r, i, o) {
    cl(e, r, i, o.transformTemplate);
  },
  render: od
}), Q2 = (t, e) => ol(t) ? J2(e, { enableHardwareAcceleration: !1 }) : Z2(e, { enableHardwareAcceleration: !0 }), ot = Oy(pw);
function tp() {
  const t = de(!1);
  return Jn(() => (t.current = !0, () => {
    t.current = !1;
  }), []), t;
}
function e_() {
  const t = tp(), [e, r] = Ae(0), i = Ie(() => {
    t.current && r(e + 1);
  }, [e]);
  return [Ie(() => fi.postRender(i), [i]), e];
}
class t_ extends Se.Component {
  getSnapshotBeforeUpdate(e) {
    const r = this.props.childRef.current;
    if (r && e.isPresent && !this.props.isPresent) {
      const i = this.props.sizeRef.current;
      i.height = r.offsetHeight || 0, i.width = r.offsetWidth || 0, i.top = r.offsetTop, i.left = r.offsetLeft;
    }
    return null;
  }
  componentDidUpdate() {
  }
  render() {
    return this.props.children;
  }
}
function r_({
  children: t,
  isPresent: e
}) {
  const r = yt(), i = de(null), o = de({
    width: 0,
    height: 0,
    top: 0,
    left: 0
  });
  return im(() => {
    const {
      width: p,
      height: g,
      top: a,
      left: n
    } = o.current;
    if (e || !i.current || !p || !g)
      return;
    i.current.dataset.motionPopId = r;
    const u = document.createElement("style");
    return document.head.appendChild(u), u.sheet && u.sheet.insertRule(`
          [data-motion-pop-id="${r}"] {
            position: absolute !important;
            width: ${p}px !important;
            height: ${g}px !important;
            top: ${a}px !important;
            left: ${n}px !important;
          }
        `), () => {
      document.head.removeChild(u);
    };
  }, [e]), /* @__PURE__ */ x(t_, {
    isPresent: e,
    childRef: i,
    sizeRef: o,
    children: Se.cloneElement(t, {
      ref: i
    })
  });
}
const fs = ({
  children: t,
  initial: e,
  isPresent: r,
  onExitComplete: i,
  custom: o,
  presenceAffectsLayout: p,
  mode: g
}) => {
  const a = nl(i_), n = yt(), u = Je(
    () => ({
      id: n,
      initial: e,
      isPresent: r,
      custom: o,
      onExitComplete: (h) => {
        a.set(h, !0);
        for (const s of a.values())
          if (!s)
            return;
        i && i();
      },
      register: (h) => (a.set(h, !1), () => a.delete(h))
    }),
    p ? void 0 : [r]
  );
  return Je(() => {
    a.forEach((h, s) => a.set(s, !1));
  }, [r]), Se.useEffect(() => {
    !r && !a.size && i && i();
  }, [r]), g === "popLayout" && (t = /* @__PURE__ */ x(r_, {
    isPresent: r,
    children: t
  })), /* @__PURE__ */ x(rn.Provider, {
    value: u,
    children: t
  });
};
function i_() {
  return /* @__PURE__ */ new Map();
}
const Yr = (t) => t.key || "";
function n_(t, e) {
  t.forEach((r) => {
    const i = Yr(r);
    e.set(i, r);
  });
}
function o_(t) {
  const e = [];
  return Sr.forEach(t, (r) => {
    tr(r) && e.push(r);
  }), e;
}
const cr = ({
  children: t,
  custom: e,
  initial: r = !0,
  onExitComplete: i,
  exitBeforeEnter: o,
  presenceAffectsLayout: p = !0,
  mode: g = "sync"
}) => {
  o && (g = "wait", $d(!1, "Replace exitBeforeEnter with mode='wait'"));
  let [a] = e_();
  const n = De($f).forceRender;
  n && (a = n);
  const u = tp(), h = o_(t);
  let s = h;
  const l = /* @__PURE__ */ new Set(), c = de(s), f = de(/* @__PURE__ */ new Map()).current, m = de(!0);
  if (Jn(() => {
    m.current = !1, n_(h, f), c.current = s;
  }), md(() => {
    m.current = !0, f.clear(), l.clear();
  }), m.current)
    return /* @__PURE__ */ x(ji, {
      children: s.map((y) => /* @__PURE__ */ x(fs, {
        isPresent: !0,
        initial: r ? void 0 : !1,
        presenceAffectsLayout: p,
        mode: g,
        children: y
      }, Yr(y)))
    });
  s = [...s];
  const d = c.current.map(Yr), v = h.map(Yr), b = d.length;
  for (let y = 0; y < b; y++) {
    const w = d[y];
    v.indexOf(w) === -1 && l.add(w);
  }
  return g === "wait" && l.size && (s = []), l.forEach((y) => {
    if (v.indexOf(y) !== -1)
      return;
    const w = f.get(y);
    if (!w)
      return;
    const _ = d.indexOf(y), S = () => {
      f.delete(y), l.delete(y);
      const T = c.current.findIndex((A) => A.key === y);
      if (c.current.splice(T, 1), !l.size) {
        if (c.current = h, u.current === !1)
          return;
        a(), i && i();
      }
    };
    s.splice(_, 0, /* @__PURE__ */ x(fs, {
      isPresent: !1,
      onExitComplete: S,
      custom: e,
      presenceAffectsLayout: p,
      mode: g,
      children: w
    }, Yr(w)));
  }), s = s.map((y) => {
    const w = y.key;
    return l.has(w) ? y : /* @__PURE__ */ x(fs, {
      isPresent: !0,
      presenceAffectsLayout: p,
      mode: g,
      children: y
    }, Yr(y));
  }), Vd !== "production" && g === "wait" && s.length > 1 && console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`), /* @__PURE__ */ x(ji, {
    children: l.size ? s : s.map((y) => dt(y))
  });
};
function s_({
  children: t,
  features: e,
  strict: r = !1
}) {
  const [, i] = Ae(!ds(e)), o = de(void 0);
  if (!ds(e)) {
    const {
      renderer: p,
      ...g
    } = e;
    o.current = p, Ys(g);
  }
  return xe(() => {
    ds(e) && e().then(({
      renderer: p,
      ...g
    }) => {
      Ys(g), o.current = p, i(!0);
    });
  }, []), /* @__PURE__ */ x(il.Provider, {
    value: {
      renderer: o.current,
      strict: r
    },
    children: t
  });
}
function ds(t) {
  return typeof t == "function";
}
const a_ = {
  renderer: Q2,
  ...P2,
  ...$x
};
function kr(t, e, r) {
  let [i, o] = Ae(t || e), p = de(t !== void 0), g = p.current, a = t !== void 0, n = de(i);
  g !== a && console.warn(`WARN: A component changed from ${g ? "controlled" : "uncontrolled"} to ${a ? "controlled" : "uncontrolled"}.`), p.current = a;
  let u = Ie((h, ...s) => {
    let l = (c, ...f) => {
      r && (Object.is(n.current, c) || r(c, ...f)), a || (n.current = c);
    };
    typeof h == "function" ? (console.warn("We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320"), o((f, ...m) => {
      let d = h(a ? n.current : f, ...m);
      return l(d, ...s), a ? f : d;
    })) : (a || o(h), l(h, ...s));
  }, [
    a,
    r
  ]);
  return a ? n.current = t : t = i, [
    t,
    u
  ];
}
function _r(t, e = -1 / 0, r = 1 / 0) {
  return Math.min(Math.max(t, e), r);
}
function l_(t, e, r, i) {
  let o = (t - (isNaN(e) ? 0 : e)) % i, p = Math.abs(o) * 2 >= i ? t + Math.sign(o) * (i - Math.abs(o)) : t - o;
  isNaN(e) ? !isNaN(r) && p > r && (p = Math.floor(r / i) * i) : p < e ? p = e : !isNaN(r) && p > r && (p = e + Math.floor((r - e) / i) * i);
  let g = i.toString(), a = g.indexOf("."), n = a >= 0 ? g.length - a : 0;
  if (n > 0) {
    let u = Math.pow(10, n);
    p = Math.round(p * u) / u;
  }
  return p;
}
function He(t, e, r = 10) {
  const i = Math.pow(r, e);
  return Math.round(t * i) / i;
}
const rp = {
  prefix: String(Math.round(Math.random() * 1e10)),
  current: 0
}, c_ = /* @__PURE__ */ ae.createContext(rp);
function u_() {
  let e = De(c_) !== rp, [r, i] = Ae(e);
  return typeof window < "u" && e && pi(() => {
    i(!1);
  }, []), r;
}
const Ft = typeof window < "u" ? ae.useLayoutEffect : () => {
};
let lu = /* @__PURE__ */ new Map();
function h_(t, e) {
  if (t === e)
    return t;
  let r = lu.get(t);
  if (r)
    return r(e), e;
  let i = lu.get(e);
  return i ? (i(t), t) : e;
}
function f_(...t) {
  return (...e) => {
    for (let r of t)
      typeof r == "function" && r(...e);
  };
}
function vi(...t) {
  let e = {
    ...t[0]
  };
  for (let r = 1; r < t.length; r++) {
    let i = t[r];
    for (let o in i) {
      let p = e[o], g = i[o];
      typeof p == "function" && typeof g == "function" && o[0] === "o" && o[1] === "n" && o.charCodeAt(2) >= 65 && o.charCodeAt(2) <= 90 ? e[o] = f_(p, g) : (o === "className" || o === "UNSAFE_className") && typeof p == "string" && typeof g == "string" ? e[o] = ue(p, g) : o === "id" && p && g ? e.id = h_(p, g) : e[o] = g !== void 0 ? g : p;
    }
  }
  return e;
}
function cu(t) {
  if (d_())
    t.focus({
      preventScroll: !0
    });
  else {
    let e = p_(t);
    t.focus(), g_(e);
  }
}
let kn = null;
function d_() {
  if (kn == null) {
    kn = !1;
    try {
      var t = document.createElement("div");
      t.focus({
        get preventScroll() {
          return kn = !0, !0;
        }
      });
    } catch {
    }
  }
  return kn;
}
function p_(t) {
  for (var e = t.parentNode, r = [], i = document.scrollingElement || document.documentElement; e instanceof HTMLElement && e !== i; )
    (e.offsetHeight < e.scrollHeight || e.offsetWidth < e.scrollWidth) && r.push({
      element: e,
      scrollTop: e.scrollTop,
      scrollLeft: e.scrollLeft
    }), e = e.parentNode;
  return i instanceof HTMLElement && r.push({
    element: i,
    scrollTop: i.scrollTop,
    scrollLeft: i.scrollLeft
  }), r;
}
function g_(t) {
  for (let { element: e, scrollTop: r, scrollLeft: i } of t)
    e.scrollTop = r, e.scrollLeft = i;
}
let Xr = /* @__PURE__ */ new Map(), ca = /* @__PURE__ */ new Set();
function uu() {
  if (typeof window > "u")
    return;
  let t = (r) => {
    let i = Xr.get(r.target);
    i || (i = /* @__PURE__ */ new Set(), Xr.set(r.target, i), r.target.addEventListener("transitioncancel", e)), i.add(r.propertyName);
  }, e = (r) => {
    let i = Xr.get(r.target);
    if (!!i && (i.delete(r.propertyName), i.size === 0 && (r.target.removeEventListener("transitioncancel", e), Xr.delete(r.target)), Xr.size === 0)) {
      for (let o of ca)
        o();
      ca.clear();
    }
  };
  document.body.addEventListener("transitionrun", t), document.body.addEventListener("transitionend", e);
}
typeof document < "u" && (document.readyState !== "loading" ? uu() : document.addEventListener("DOMContentLoaded", uu));
function m_(t) {
  requestAnimationFrame(() => {
    Xr.size === 0 ? t() : ca.add(t);
  });
}
function wl() {
  let t = de(/* @__PURE__ */ new Map()), e = Ie((o, p, g, a) => {
    let n = a != null && a.once ? (...u) => {
      t.current.delete(g), g(...u);
    } : g;
    t.current.set(g, {
      type: p,
      eventTarget: o,
      fn: n,
      options: a
    }), o.addEventListener(p, g, a);
  }, []), r = Ie((o, p, g, a) => {
    var n;
    let u = ((n = t.current.get(g)) === null || n === void 0 ? void 0 : n.fn) || g;
    o.removeEventListener(p, u, a), t.current.delete(g);
  }, []), i = Ie(() => {
    t.current.forEach((o, p) => {
      r(o.eventTarget, o.type, p, o.options);
    });
  }, [
    r
  ]);
  return xe(() => i, [
    i
  ]), {
    addGlobalListener: e,
    removeGlobalListener: r,
    removeAllGlobalListeners: i
  };
}
function Ir(t) {
  const e = de();
  return Ft(() => {
    !t || (typeof t == "function" ? t(e.current) : t.current = e.current);
  }, [
    t
  ]), e;
}
let xt = typeof window < "u" && window.visualViewport;
function v_() {
  let [t, e] = Ae(
    () => hu()
  );
  return xe(() => {
    let r = () => {
      e((i) => {
        let o = hu();
        return o.width === i.width && o.height === i.height ? i : o;
      });
    };
    return xt ? xt.addEventListener("resize", r) : window.addEventListener("resize", r), () => {
      xt ? xt.removeEventListener("resize", r) : window.removeEventListener("resize", r);
    };
  }, []), t;
}
function hu() {
  return {
    width: (xt == null ? void 0 : xt.width) || window.innerWidth,
    height: (xt == null ? void 0 : xt.height) || window.innerHeight
  };
}
function b_(t) {
  var e;
  return typeof window < "u" && window.navigator != null ? t.test(((e = window.navigator.userAgentData) === null || e === void 0 ? void 0 : e.platform) || window.navigator.platform) : !1;
}
function ip() {
  return b_(/^Mac/i);
}
var ve = {};
const y_ = {}, w_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: y_
}, Symbol.toStringTag, { value: "Module" })), ps = /* @__PURE__ */ lm(w_);
(function(t) {
  /*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */
  var e = e || { version: "5.2.4" };
  if (t.fabric = e, typeof document < "u" && typeof window < "u")
    document instanceof (typeof HTMLDocument < "u" ? HTMLDocument : Document) ? e.document = document : e.document = document.implementation.createHTMLDocument(""), e.window = window;
  else {
    var r = ps, i = new r.JSDOM(
      decodeURIComponent("%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E"),
      {
        features: {
          FetchExternalResources: ["img"]
        },
        resources: "usable"
      }
    ).window;
    e.document = i.document, e.jsdomImplForWrapper = ps.implForWrapper, e.nodeCanvas = ps.Canvas, e.window = i, DOMParser = e.window.DOMParser;
  }
  e.isTouchSupported = "ontouchstart" in e.window || "ontouchstart" in e.document || e.window && e.window.navigator && e.window.navigator.maxTouchPoints > 0, e.isLikelyNode = typeof Buffer < "u" && typeof window > "u", e.SHARED_ATTRIBUTES = [
    "display",
    "transform",
    "fill",
    "fill-opacity",
    "fill-rule",
    "opacity",
    "stroke",
    "stroke-dasharray",
    "stroke-linecap",
    "stroke-dashoffset",
    "stroke-linejoin",
    "stroke-miterlimit",
    "stroke-opacity",
    "stroke-width",
    "id",
    "paint-order",
    "vector-effect",
    "instantiated_by_use",
    "clip-path"
  ], e.DPI = 96, e.reNum = "(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)", e.commaWsp = "(?:\\s+,?\\s*|,\\s*)", e.rePathCommand = /([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:[eE][-+]?\d+)?)/ig, e.reNonWord = /[ \n\.,;!\?\-]/, e.fontPaths = {}, e.iMatrix = [1, 0, 0, 1, 0, 0], e.svgNS = "http://www.w3.org/2000/svg", e.perfLimitSizeTotal = 2097152, e.maxCacheSideLimit = 4096, e.minCacheSideLimit = 256, e.charWidthsCache = {}, e.textureSize = 2048, e.disableStyleCopyPaste = !1, e.enableGLFiltering = !0, e.devicePixelRatio = e.window.devicePixelRatio || e.window.webkitDevicePixelRatio || e.window.mozDevicePixelRatio || 1, e.browserShadowBlurConstant = 1, e.arcToSegmentsCache = {}, e.boundsOfCurveCache = {}, e.cachesBoundsOfCurve = !0, e.forceGLPutImageData = !1, e.initFilterBackend = function() {
    if (e.enableGLFiltering && e.isWebglSupported && e.isWebglSupported(e.textureSize))
      return console.log("max texture size: " + e.maxTextureSize), new e.WebglFilterBackend({ tileSize: e.textureSize });
    if (e.Canvas2dFilterBackend)
      return new e.Canvas2dFilterBackend();
  }, typeof document < "u" && typeof window < "u" && (window.fabric = e), function() {
    function a(c, f) {
      if (!!this.__eventListeners[c]) {
        var m = this.__eventListeners[c];
        f ? m[m.indexOf(f)] = !1 : e.util.array.fill(m, !1);
      }
    }
    function n(c, f) {
      if (this.__eventListeners || (this.__eventListeners = {}), arguments.length === 1)
        for (var m in c)
          this.on(m, c[m]);
      else
        this.__eventListeners[c] || (this.__eventListeners[c] = []), this.__eventListeners[c].push(f);
      return this;
    }
    function u(c, f) {
      var m = function() {
        f.apply(this, arguments), this.off(c, m);
      }.bind(this);
      this.on(c, m);
    }
    function h(c, f) {
      if (arguments.length === 1)
        for (var m in c)
          u.call(this, m, c[m]);
      else
        u.call(this, c, f);
      return this;
    }
    function s(c, f) {
      if (!this.__eventListeners)
        return this;
      if (arguments.length === 0)
        for (c in this.__eventListeners)
          a.call(this, c);
      else if (arguments.length === 1 && typeof arguments[0] == "object")
        for (var m in c)
          a.call(this, m, c[m]);
      else
        a.call(this, c, f);
      return this;
    }
    function l(c, f) {
      if (!this.__eventListeners)
        return this;
      var m = this.__eventListeners[c];
      if (!m)
        return this;
      for (var d = 0, v = m.length; d < v; d++)
        m[d] && m[d].call(this, f || {});
      return this.__eventListeners[c] = m.filter(function(b) {
        return b !== !1;
      }), this;
    }
    e.Observable = {
      fire: l,
      on: n,
      once: h,
      off: s
    };
  }(), e.Collection = {
    _objects: [],
    add: function() {
      if (this._objects.push.apply(this._objects, arguments), this._onObjectAdded)
        for (var a = 0, n = arguments.length; a < n; a++)
          this._onObjectAdded(arguments[a]);
      return this.renderOnAddRemove && this.requestRenderAll(), this;
    },
    insertAt: function(a, n, u) {
      var h = this._objects;
      return u ? h[n] = a : h.splice(n, 0, a), this._onObjectAdded && this._onObjectAdded(a), this.renderOnAddRemove && this.requestRenderAll(), this;
    },
    remove: function() {
      for (var a = this._objects, n, u = !1, h = 0, s = arguments.length; h < s; h++)
        n = a.indexOf(arguments[h]), n !== -1 && (u = !0, a.splice(n, 1), this._onObjectRemoved && this._onObjectRemoved(arguments[h]));
      return this.renderOnAddRemove && u && this.requestRenderAll(), this;
    },
    forEachObject: function(a, n) {
      for (var u = this.getObjects(), h = 0, s = u.length; h < s; h++)
        a.call(n, u[h], h, u);
      return this;
    },
    getObjects: function(a) {
      return typeof a > "u" ? this._objects.concat() : this._objects.filter(function(n) {
        return n.type === a;
      });
    },
    item: function(a) {
      return this._objects[a];
    },
    isEmpty: function() {
      return this._objects.length === 0;
    },
    size: function() {
      return this._objects.length;
    },
    contains: function(a, n) {
      return this._objects.indexOf(a) > -1 ? !0 : n ? this._objects.some(function(u) {
        return typeof u.contains == "function" && u.contains(a, !0);
      }) : !1;
    },
    complexity: function() {
      return this._objects.reduce(function(a, n) {
        return a += n.complexity ? n.complexity() : 0, a;
      }, 0);
    }
  }, e.CommonMethods = {
    _setOptions: function(a) {
      for (var n in a)
        this.set(n, a[n]);
    },
    _initGradient: function(a, n) {
      a && a.colorStops && !(a instanceof e.Gradient) && this.set(n, new e.Gradient(a));
    },
    _initPattern: function(a, n, u) {
      a && a.source && !(a instanceof e.Pattern) ? this.set(n, new e.Pattern(a, u)) : u && u();
    },
    _setObject: function(a) {
      for (var n in a)
        this._set(n, a[n]);
    },
    set: function(a, n) {
      return typeof a == "object" ? this._setObject(a) : this._set(a, n), this;
    },
    _set: function(a, n) {
      this[a] = n;
    },
    toggle: function(a) {
      var n = this.get(a);
      return typeof n == "boolean" && this.set(a, !n), this;
    },
    get: function(a) {
      return this[a];
    }
  }, function(a) {
    var n = Math.sqrt, u = Math.atan2, h = Math.pow, s = Math.PI / 180, l = Math.PI / 2;
    e.util = {
      cos: function(c) {
        if (c === 0)
          return 1;
        c < 0 && (c = -c);
        var f = c / l;
        switch (f) {
          case 1:
          case 3:
            return 0;
          case 2:
            return -1;
        }
        return Math.cos(c);
      },
      sin: function(c) {
        if (c === 0)
          return 0;
        var f = c / l, m = 1;
        switch (c < 0 && (m = -1), f) {
          case 1:
            return m;
          case 2:
            return 0;
          case 3:
            return -m;
        }
        return Math.sin(c);
      },
      removeFromArray: function(c, f) {
        var m = c.indexOf(f);
        return m !== -1 && c.splice(m, 1), c;
      },
      getRandomInt: function(c, f) {
        return Math.floor(Math.random() * (f - c + 1)) + c;
      },
      degreesToRadians: function(c) {
        return c * s;
      },
      radiansToDegrees: function(c) {
        return c / s;
      },
      rotatePoint: function(c, f, m) {
        var d = new e.Point(c.x - f.x, c.y - f.y), v = e.util.rotateVector(d, m);
        return new e.Point(v.x, v.y).addEquals(f);
      },
      rotateVector: function(c, f) {
        var m = e.util.sin(f), d = e.util.cos(f), v = c.x * d - c.y * m, b = c.x * m + c.y * d;
        return {
          x: v,
          y: b
        };
      },
      createVector: function(c, f) {
        return new e.Point(f.x - c.x, f.y - c.y);
      },
      calcAngleBetweenVectors: function(c, f) {
        return Math.acos((c.x * f.x + c.y * f.y) / (Math.hypot(c.x, c.y) * Math.hypot(f.x, f.y)));
      },
      getHatVector: function(c) {
        return new e.Point(c.x, c.y).multiply(1 / Math.hypot(c.x, c.y));
      },
      getBisector: function(c, f, m) {
        var d = e.util.createVector(c, f), v = e.util.createVector(c, m), b = e.util.calcAngleBetweenVectors(d, v), y = e.util.calcAngleBetweenVectors(e.util.rotateVector(d, b), v), w = b * (y === 0 ? 1 : -1) / 2;
        return {
          vector: e.util.getHatVector(e.util.rotateVector(d, w)),
          angle: b
        };
      },
      projectStrokeOnPoints: function(c, f, m) {
        var d = [], v = f.strokeWidth / 2, b = f.strokeUniform ? new e.Point(1 / f.scaleX, 1 / f.scaleY) : new e.Point(1, 1), y = function(w) {
          var _ = v / Math.hypot(w.x, w.y);
          return new e.Point(w.x * _ * b.x, w.y * _ * b.y);
        };
        return c.length <= 1 || c.forEach(function(w, _) {
          var S = new e.Point(w.x, w.y), T, A;
          _ === 0 ? (A = c[_ + 1], T = m ? y(e.util.createVector(A, S)).addEquals(S) : c[c.length - 1]) : _ === c.length - 1 ? (T = c[_ - 1], A = m ? y(e.util.createVector(T, S)).addEquals(S) : c[0]) : (T = c[_ - 1], A = c[_ + 1]);
          var R = e.util.getBisector(S, T, A), N = R.vector, U = R.angle, Q, ee;
          if (f.strokeLineJoin === "miter" && (Q = -v / Math.sin(U / 2), ee = new e.Point(
            N.x * Q * b.x,
            N.y * Q * b.y
          ), Math.hypot(ee.x, ee.y) / v <= f.strokeMiterLimit)) {
            d.push(S.add(ee)), d.push(S.subtract(ee));
            return;
          }
          Q = -v * Math.SQRT2, ee = new e.Point(
            N.x * Q * b.x,
            N.y * Q * b.y
          ), d.push(S.add(ee)), d.push(S.subtract(ee));
        }), d;
      },
      transformPoint: function(c, f, m) {
        return m ? new e.Point(
          f[0] * c.x + f[2] * c.y,
          f[1] * c.x + f[3] * c.y
        ) : new e.Point(
          f[0] * c.x + f[2] * c.y + f[4],
          f[1] * c.x + f[3] * c.y + f[5]
        );
      },
      makeBoundingBoxFromPoints: function(c, f) {
        if (f)
          for (var m = 0; m < c.length; m++)
            c[m] = e.util.transformPoint(c[m], f);
        var d = [c[0].x, c[1].x, c[2].x, c[3].x], v = e.util.array.min(d), b = e.util.array.max(d), y = b - v, w = [c[0].y, c[1].y, c[2].y, c[3].y], _ = e.util.array.min(w), S = e.util.array.max(w), T = S - _;
        return {
          left: v,
          top: _,
          width: y,
          height: T
        };
      },
      invertTransform: function(c) {
        var f = 1 / (c[0] * c[3] - c[1] * c[2]), m = [f * c[3], -f * c[1], -f * c[2], f * c[0]], d = e.util.transformPoint({ x: c[4], y: c[5] }, m, !0);
        return m[4] = -d.x, m[5] = -d.y, m;
      },
      toFixed: function(c, f) {
        return parseFloat(Number(c).toFixed(f));
      },
      parseUnit: function(c, f) {
        var m = /\D{0,2}$/.exec(c), d = parseFloat(c);
        switch (f || (f = e.Text.DEFAULT_SVG_FONT_SIZE), m[0]) {
          case "mm":
            return d * e.DPI / 25.4;
          case "cm":
            return d * e.DPI / 2.54;
          case "in":
            return d * e.DPI;
          case "pt":
            return d * e.DPI / 72;
          case "pc":
            return d * e.DPI / 72 * 12;
          case "em":
            return d * f;
          default:
            return d;
        }
      },
      falseFunction: function() {
        return !1;
      },
      getKlass: function(c, f) {
        return c = e.util.string.camelize(c.charAt(0).toUpperCase() + c.slice(1)), e.util.resolveNamespace(f)[c];
      },
      getSvgAttributes: function(c) {
        var f = [
          "instantiated_by_use",
          "style",
          "id",
          "class"
        ];
        switch (c) {
          case "linearGradient":
            f = f.concat(["x1", "y1", "x2", "y2", "gradientUnits", "gradientTransform"]);
            break;
          case "radialGradient":
            f = f.concat(["gradientUnits", "gradientTransform", "cx", "cy", "r", "fx", "fy", "fr"]);
            break;
          case "stop":
            f = f.concat(["offset", "stop-color", "stop-opacity"]);
            break;
        }
        return f;
      },
      resolveNamespace: function(c) {
        if (!c)
          return e;
        var f = c.split("."), m = f.length, d, v = a || e.window;
        for (d = 0; d < m; ++d)
          v = v[f[d]];
        return v;
      },
      loadImage: function(c, f, m, d) {
        if (!c) {
          f && f.call(m, c);
          return;
        }
        var v = e.util.createImage(), b = function() {
          f && f.call(m, v, !1), v = v.onload = v.onerror = null;
        };
        v.onload = b, v.onerror = function() {
          e.log("Error loading " + v.src), f && f.call(m, null, !0), v = v.onload = v.onerror = null;
        }, c.indexOf("data") !== 0 && d !== void 0 && d !== null && (v.crossOrigin = d), c.substring(0, 14) === "data:image/svg" && (v.onload = null, e.util.loadImageInDom(v, b)), v.src = c;
      },
      loadImageInDom: function(c, f) {
        var m = e.document.createElement("div");
        m.style.width = m.style.height = "1px", m.style.left = m.style.top = "-100%", m.style.position = "absolute", m.appendChild(c), e.document.querySelector("body").appendChild(m), c.onload = function() {
          f(), m.parentNode.removeChild(m), m = null;
        };
      },
      enlivenObjects: function(c, f, m, d) {
        c = c || [];
        var v = [], b = 0, y = c.length;
        function w() {
          ++b === y && f && f(v.filter(function(_) {
            return _;
          }));
        }
        if (!y) {
          f && f(v);
          return;
        }
        c.forEach(function(_, S) {
          if (!_ || !_.type) {
            w();
            return;
          }
          var T = e.util.getKlass(_.type, m);
          T.fromObject(_, function(A, R) {
            R || (v[S] = A), d && d(_, A, R), w();
          });
        });
      },
      enlivenObjectEnlivables: function(c, f, m) {
        var d = e.Object.ENLIVEN_PROPS.filter(function(v) {
          return !!c[v];
        });
        e.util.enlivenObjects(d.map(function(v) {
          return c[v];
        }), function(v) {
          var b = {};
          d.forEach(function(y, w) {
            b[y] = v[w], f && (f[y] = v[w]);
          }), m && m(b);
        });
      },
      enlivenPatterns: function(c, f) {
        c = c || [];
        function m() {
          ++v === b && f && f(d);
        }
        var d = [], v = 0, b = c.length;
        if (!b) {
          f && f(d);
          return;
        }
        c.forEach(function(y, w) {
          y && y.source ? new e.Pattern(y, function(_) {
            d[w] = _, m();
          }) : (d[w] = y, m());
        });
      },
      groupSVGElements: function(c, f, m) {
        var d;
        return c && c.length === 1 ? (typeof m < "u" && (c[0].sourcePath = m), c[0]) : (f && (f.width && f.height ? f.centerPoint = {
          x: f.width / 2,
          y: f.height / 2
        } : (delete f.width, delete f.height)), d = new e.Group(c, f), typeof m < "u" && (d.sourcePath = m), d);
      },
      populateWithProperties: function(c, f, m) {
        if (m && Array.isArray(m))
          for (var d = 0, v = m.length; d < v; d++)
            m[d] in c && (f[m[d]] = c[m[d]]);
      },
      createCanvasElement: function() {
        return e.document.createElement("canvas");
      },
      copyCanvasElement: function(c) {
        var f = e.util.createCanvasElement();
        return f.width = c.width, f.height = c.height, f.getContext("2d").drawImage(c, 0, 0), f;
      },
      toDataURL: function(c, f, m) {
        return c.toDataURL("image/" + f, m);
      },
      createImage: function() {
        return e.document.createElement("img");
      },
      multiplyTransformMatrices: function(c, f, m) {
        return [
          c[0] * f[0] + c[2] * f[1],
          c[1] * f[0] + c[3] * f[1],
          c[0] * f[2] + c[2] * f[3],
          c[1] * f[2] + c[3] * f[3],
          m ? 0 : c[0] * f[4] + c[2] * f[5] + c[4],
          m ? 0 : c[1] * f[4] + c[3] * f[5] + c[5]
        ];
      },
      qrDecompose: function(c) {
        var f = u(c[1], c[0]), m = h(c[0], 2) + h(c[1], 2), d = n(m), v = (c[0] * c[3] - c[2] * c[1]) / d, b = u(c[0] * c[2] + c[1] * c[3], m);
        return {
          angle: f / s,
          scaleX: d,
          scaleY: v,
          skewX: b / s,
          skewY: 0,
          translateX: c[4],
          translateY: c[5]
        };
      },
      calcRotateMatrix: function(c) {
        if (!c.angle)
          return e.iMatrix.concat();
        var f = e.util.degreesToRadians(c.angle), m = e.util.cos(f), d = e.util.sin(f);
        return [m, d, -d, m, 0, 0];
      },
      calcDimensionsMatrix: function(c) {
        var f = typeof c.scaleX > "u" ? 1 : c.scaleX, m = typeof c.scaleY > "u" ? 1 : c.scaleY, d = [
          c.flipX ? -f : f,
          0,
          0,
          c.flipY ? -m : m,
          0,
          0
        ], v = e.util.multiplyTransformMatrices, b = e.util.degreesToRadians;
        return c.skewX && (d = v(
          d,
          [1, 0, Math.tan(b(c.skewX)), 1],
          !0
        )), c.skewY && (d = v(
          d,
          [1, Math.tan(b(c.skewY)), 0, 1],
          !0
        )), d;
      },
      composeMatrix: function(c) {
        var f = [1, 0, 0, 1, c.translateX || 0, c.translateY || 0], m = e.util.multiplyTransformMatrices;
        return c.angle && (f = m(f, e.util.calcRotateMatrix(c))), (c.scaleX !== 1 || c.scaleY !== 1 || c.skewX || c.skewY || c.flipX || c.flipY) && (f = m(f, e.util.calcDimensionsMatrix(c))), f;
      },
      resetObjectTransform: function(c) {
        c.scaleX = 1, c.scaleY = 1, c.skewX = 0, c.skewY = 0, c.flipX = !1, c.flipY = !1, c.rotate(0);
      },
      saveObjectTransform: function(c) {
        return {
          scaleX: c.scaleX,
          scaleY: c.scaleY,
          skewX: c.skewX,
          skewY: c.skewY,
          angle: c.angle,
          left: c.left,
          flipX: c.flipX,
          flipY: c.flipY,
          top: c.top
        };
      },
      isTransparent: function(c, f, m, d) {
        d > 0 && (f > d ? f -= d : f = 0, m > d ? m -= d : m = 0);
        var v = !0, b, y, w = c.getImageData(f, m, d * 2 || 1, d * 2 || 1), _ = w.data.length;
        for (b = 3; b < _ && (y = w.data[b], v = y <= 0, v !== !1); b += 4)
          ;
        return w = null, v;
      },
      parsePreserveAspectRatioAttribute: function(c) {
        var f = "meet", m = "Mid", d = "Mid", v = c.split(" "), b;
        return v && v.length && (f = v.pop(), f !== "meet" && f !== "slice" ? (b = f, f = "meet") : v.length && (b = v.pop())), m = b !== "none" ? b.slice(1, 4) : "none", d = b !== "none" ? b.slice(5, 8) : "none", {
          meetOrSlice: f,
          alignX: m,
          alignY: d
        };
      },
      clearFabricFontCache: function(c) {
        c = (c || "").toLowerCase(), c ? e.charWidthsCache[c] && delete e.charWidthsCache[c] : e.charWidthsCache = {};
      },
      limitDimsByArea: function(c, f) {
        var m = Math.sqrt(f * c), d = Math.floor(f / m);
        return { x: Math.floor(m), y: d };
      },
      capValue: function(c, f, m) {
        return Math.max(c, Math.min(f, m));
      },
      findScaleToFit: function(c, f) {
        return Math.min(f.width / c.width, f.height / c.height);
      },
      findScaleToCover: function(c, f) {
        return Math.max(f.width / c.width, f.height / c.height);
      },
      matrixToSVG: function(c) {
        return "matrix(" + c.map(function(f) {
          return e.util.toFixed(f, e.Object.NUM_FRACTION_DIGITS);
        }).join(" ") + ")";
      },
      removeTransformFromObject: function(c, f) {
        var m = e.util.invertTransform(f), d = e.util.multiplyTransformMatrices(m, c.calcOwnMatrix());
        e.util.applyTransformToObject(c, d);
      },
      addTransformToObject: function(c, f) {
        e.util.applyTransformToObject(
          c,
          e.util.multiplyTransformMatrices(f, c.calcOwnMatrix())
        );
      },
      applyTransformToObject: function(c, f) {
        var m = e.util.qrDecompose(f), d = new e.Point(m.translateX, m.translateY);
        c.flipX = !1, c.flipY = !1, c.set("scaleX", m.scaleX), c.set("scaleY", m.scaleY), c.skewX = m.skewX, c.skewY = m.skewY, c.angle = m.angle, c.setPositionByOrigin(d, "center", "center");
      },
      sizeAfterTransform: function(c, f, m) {
        var d = c / 2, v = f / 2, b = [
          {
            x: -d,
            y: -v
          },
          {
            x: d,
            y: -v
          },
          {
            x: -d,
            y: v
          },
          {
            x: d,
            y: v
          }
        ], y = e.util.calcDimensionsMatrix(m), w = e.util.makeBoundingBoxFromPoints(b, y);
        return {
          x: w.width,
          y: w.height
        };
      },
      mergeClipPaths: function(c, f) {
        var m = c, d = f;
        m.inverted && !d.inverted && (m = f, d = c), e.util.applyTransformToObject(
          d,
          e.util.multiplyTransformMatrices(
            e.util.invertTransform(m.calcTransformMatrix()),
            d.calcTransformMatrix()
          )
        );
        var v = m.inverted && d.inverted;
        return v && (m.inverted = d.inverted = !1), new e.Group([m], { clipPath: d, inverted: v });
      },
      hasStyleChanged: function(c, f, m) {
        return m = m || !1, c.fill !== f.fill || c.stroke !== f.stroke || c.strokeWidth !== f.strokeWidth || c.fontSize !== f.fontSize || c.fontFamily !== f.fontFamily || c.fontWeight !== f.fontWeight || c.fontStyle !== f.fontStyle || c.deltaY !== f.deltaY || m && (c.overline !== f.overline || c.underline !== f.underline || c.linethrough !== f.linethrough);
      },
      stylesToArray: function(m, f) {
        for (var m = e.util.object.clone(m, !0), d = f.split(`
`), v = -1, b = {}, y = [], w = 0; w < d.length; w++) {
          if (!m[w]) {
            v += d[w].length;
            continue;
          }
          for (var _ = 0; _ < d[w].length; _++) {
            v++;
            var S = m[w][_];
            if (S) {
              var T = e.util.hasStyleChanged(b, S, !0);
              T ? y.push({
                start: v,
                end: v + 1,
                style: S
              }) : y[y.length - 1].end++;
            }
            b = S || {};
          }
        }
        return y;
      },
      stylesFromArray: function(c, f) {
        if (!Array.isArray(c))
          return c;
        for (var m = f.split(`
`), d = -1, v = 0, b = {}, y = 0; y < m.length; y++)
          for (var w = 0; w < m[y].length; w++)
            d++, c[v] && c[v].start <= d && d < c[v].end && (b[y] = b[y] || {}, b[y][w] = Object.assign({}, c[v].style), d === c[v].end - 1 && v++);
        return b;
      }
    };
  }(t), function() {
    var a = Array.prototype.join, n = {
      m: 2,
      l: 2,
      h: 1,
      v: 1,
      c: 6,
      s: 4,
      q: 4,
      t: 2,
      a: 7
    }, u = {
      m: "l",
      M: "L"
    };
    function h(C, k, P, D, B, M, E, L, z, Y, $) {
      var W = e.util.cos(C), j = e.util.sin(C), te = e.util.cos(k), V = e.util.sin(k), F = P * B * te - D * M * V + E, X = D * B * te + P * M * V + L, G = Y + z * (-P * B * j - D * M * W), H = $ + z * (-D * B * j + P * M * W), Z = F + z * (P * B * V + D * M * te), se = X + z * (D * B * V - P * M * te);
      return [
        "C",
        G,
        H,
        Z,
        se,
        F,
        X
      ];
    }
    function s(C, k, P, D, B, M, E) {
      var L = Math.PI, z = E * L / 180, Y = e.util.sin(z), $ = e.util.cos(z), W = 0, j = 0;
      P = Math.abs(P), D = Math.abs(D);
      var te = -$ * C * 0.5 - Y * k * 0.5, V = -$ * k * 0.5 + Y * C * 0.5, F = P * P, X = D * D, G = V * V, H = te * te, Z = F * X - F * G - X * H, se = 0;
      if (Z < 0) {
        var ye = Math.sqrt(1 - Z / (F * X));
        P *= ye, D *= ye;
      } else
        se = (B === M ? -1 : 1) * Math.sqrt(Z / (F * G + X * H));
      var pe = se * P * V / D, K = -se * D * te / P, ge = $ * pe - Y * K + C * 0.5, _e = Y * pe + $ * K + k * 0.5, ke = l(1, 0, (te - pe) / P, (V - K) / D), Re = l((te - pe) / P, (V - K) / D, (-te - pe) / P, (-V - K) / D);
      M === 0 && Re > 0 ? Re -= 2 * L : M === 1 && Re < 0 && (Re += 2 * L);
      for (var Oe = Math.ceil(Math.abs(Re / L * 2)), tt = [], $e = Re / Oe, hr = 8 / 3 * Math.sin($e / 4) * Math.sin($e / 4) / Math.sin($e / 2), wi = ke + $e, wt = 0; wt < Oe; wt++)
        tt[wt] = h(ke, wi, $, Y, P, D, ge, _e, hr, W, j), W = tt[wt][5], j = tt[wt][6], ke = wi, wi += $e;
      return tt;
    }
    function l(C, k, P, D) {
      var B = Math.atan2(k, C), M = Math.atan2(D, P);
      return M >= B ? M - B : 2 * Math.PI - (B - M);
    }
    function c(C, k, P, D, B, M, E, L) {
      var z;
      if (e.cachesBoundsOfCurve && (z = a.call(arguments), e.boundsOfCurveCache[z]))
        return e.boundsOfCurveCache[z];
      var Y = Math.sqrt, $ = Math.min, W = Math.max, j = Math.abs, te = [], V = [[], []], F, X, G, H, Z, se, ye, pe;
      X = 6 * C - 12 * P + 6 * B, F = -3 * C + 9 * P - 9 * B + 3 * E, G = 3 * P - 3 * C;
      for (var K = 0; K < 2; ++K) {
        if (K > 0 && (X = 6 * k - 12 * D + 6 * M, F = -3 * k + 9 * D - 9 * M + 3 * L, G = 3 * D - 3 * k), j(F) < 1e-12) {
          if (j(X) < 1e-12)
            continue;
          H = -G / X, 0 < H && H < 1 && te.push(H);
          continue;
        }
        ye = X * X - 4 * G * F, !(ye < 0) && (pe = Y(ye), Z = (-X + pe) / (2 * F), 0 < Z && Z < 1 && te.push(Z), se = (-X - pe) / (2 * F), 0 < se && se < 1 && te.push(se));
      }
      for (var ge, _e, ke = te.length, Re = ke, Oe; ke--; )
        H = te[ke], Oe = 1 - H, ge = Oe * Oe * Oe * C + 3 * Oe * Oe * H * P + 3 * Oe * H * H * B + H * H * H * E, V[0][ke] = ge, _e = Oe * Oe * Oe * k + 3 * Oe * Oe * H * D + 3 * Oe * H * H * M + H * H * H * L, V[1][ke] = _e;
      V[0][Re] = C, V[1][Re] = k, V[0][Re + 1] = E, V[1][Re + 1] = L;
      var tt = [
        {
          x: $.apply(null, V[0]),
          y: $.apply(null, V[1])
        },
        {
          x: W.apply(null, V[0]),
          y: W.apply(null, V[1])
        }
      ];
      return e.cachesBoundsOfCurve && (e.boundsOfCurveCache[z] = tt), tt;
    }
    function f(C, k, P) {
      for (var D = P[1], B = P[2], M = P[3], E = P[4], L = P[5], z = P[6], Y = P[7], $ = s(z - C, Y - k, D, B, E, L, M), W = 0, j = $.length; W < j; W++)
        $[W][1] += C, $[W][2] += k, $[W][3] += C, $[W][4] += k, $[W][5] += C, $[W][6] += k;
      return $;
    }
    function m(C) {
      var k = 0, P = 0, D = C.length, B = 0, M = 0, E, L, z, Y = [], $, W, j;
      for (L = 0; L < D; ++L) {
        switch (z = !1, E = C[L].slice(0), E[0]) {
          case "l":
            E[0] = "L", E[1] += k, E[2] += P;
          case "L":
            k = E[1], P = E[2];
            break;
          case "h":
            E[1] += k;
          case "H":
            E[0] = "L", E[2] = P, k = E[1];
            break;
          case "v":
            E[1] += P;
          case "V":
            E[0] = "L", P = E[1], E[1] = k, E[2] = P;
            break;
          case "m":
            E[0] = "M", E[1] += k, E[2] += P;
          case "M":
            k = E[1], P = E[2], B = E[1], M = E[2];
            break;
          case "c":
            E[0] = "C", E[1] += k, E[2] += P, E[3] += k, E[4] += P, E[5] += k, E[6] += P;
          case "C":
            W = E[3], j = E[4], k = E[5], P = E[6];
            break;
          case "s":
            E[0] = "S", E[1] += k, E[2] += P, E[3] += k, E[4] += P;
          case "S":
            $ === "C" ? (W = 2 * k - W, j = 2 * P - j) : (W = k, j = P), k = E[3], P = E[4], E[0] = "C", E[5] = E[3], E[6] = E[4], E[3] = E[1], E[4] = E[2], E[1] = W, E[2] = j, W = E[3], j = E[4];
            break;
          case "q":
            E[0] = "Q", E[1] += k, E[2] += P, E[3] += k, E[4] += P;
          case "Q":
            W = E[1], j = E[2], k = E[3], P = E[4];
            break;
          case "t":
            E[0] = "T", E[1] += k, E[2] += P;
          case "T":
            $ === "Q" ? (W = 2 * k - W, j = 2 * P - j) : (W = k, j = P), E[0] = "Q", k = E[1], P = E[2], E[1] = W, E[2] = j, E[3] = k, E[4] = P;
            break;
          case "a":
            E[0] = "A", E[6] += k, E[7] += P;
          case "A":
            z = !0, Y = Y.concat(f(k, P, E)), k = E[6], P = E[7];
            break;
          case "z":
          case "Z":
            k = B, P = M;
            break;
        }
        z || Y.push(E), $ = E[0];
      }
      return Y;
    }
    function d(C, k, P, D) {
      return Math.sqrt((P - C) * (P - C) + (D - k) * (D - k));
    }
    function v(C) {
      return C * C * C;
    }
    function b(C) {
      return 3 * C * C * (1 - C);
    }
    function y(C) {
      return 3 * C * (1 - C) * (1 - C);
    }
    function w(C) {
      return (1 - C) * (1 - C) * (1 - C);
    }
    function _(C, k, P, D, B, M, E, L) {
      return function(z) {
        var Y = v(z), $ = b(z), W = y(z), j = w(z);
        return {
          x: E * Y + B * $ + P * W + C * j,
          y: L * Y + M * $ + D * W + k * j
        };
      };
    }
    function S(C, k, P, D, B, M, E, L) {
      return function(z) {
        var Y = 1 - z, $ = 3 * Y * Y * (P - C) + 6 * Y * z * (B - P) + 3 * z * z * (E - B), W = 3 * Y * Y * (D - k) + 6 * Y * z * (M - D) + 3 * z * z * (L - M);
        return Math.atan2(W, $);
      };
    }
    function T(C) {
      return C * C;
    }
    function A(C) {
      return 2 * C * (1 - C);
    }
    function R(C) {
      return (1 - C) * (1 - C);
    }
    function N(C, k, P, D, B, M) {
      return function(E) {
        var L = T(E), z = A(E), Y = R(E);
        return {
          x: B * L + P * z + C * Y,
          y: M * L + D * z + k * Y
        };
      };
    }
    function U(C, k, P, D, B, M) {
      return function(E) {
        var L = 1 - E, z = 2 * L * (P - C) + 2 * E * (B - P), Y = 2 * L * (D - k) + 2 * E * (M - D);
        return Math.atan2(Y, z);
      };
    }
    function Q(C, k, P) {
      var D = { x: k, y: P }, B, M = 0, E;
      for (E = 1; E <= 100; E += 1)
        B = C(E / 100), M += d(D.x, D.y, B.x, B.y), D = B;
      return M;
    }
    function ee(C, k) {
      for (var P = 0, D = 0, B = C.iterator, M = { x: C.x, y: C.y }, E, L, z = 0.01, Y = C.angleFinder, $; D < k && z > 1e-4; )
        E = B(P), $ = P, L = d(M.x, M.y, E.x, E.y), L + D > k ? (P -= z, z /= 2) : (M = E, P += z, D += L);
      return E.angle = Y($), E;
    }
    function J(C) {
      for (var k = 0, P = C.length, D, B = 0, M = 0, E = 0, L = 0, z = [], Y, $, W, j = 0; j < P; j++) {
        switch (D = C[j], $ = {
          x: B,
          y: M,
          command: D[0]
        }, D[0]) {
          case "M":
            $.length = 0, E = B = D[1], L = M = D[2];
            break;
          case "L":
            $.length = d(B, M, D[1], D[2]), B = D[1], M = D[2];
            break;
          case "C":
            Y = _(
              B,
              M,
              D[1],
              D[2],
              D[3],
              D[4],
              D[5],
              D[6]
            ), W = S(
              B,
              M,
              D[1],
              D[2],
              D[3],
              D[4],
              D[5],
              D[6]
            ), $.iterator = Y, $.angleFinder = W, $.length = Q(Y, B, M), B = D[5], M = D[6];
            break;
          case "Q":
            Y = N(
              B,
              M,
              D[1],
              D[2],
              D[3],
              D[4]
            ), W = U(
              B,
              M,
              D[1],
              D[2],
              D[3],
              D[4]
            ), $.iterator = Y, $.angleFinder = W, $.length = Q(Y, B, M), B = D[3], M = D[4];
            break;
          case "Z":
          case "z":
            $.destX = E, $.destY = L, $.length = d(B, M, E, L), B = E, M = L;
            break;
        }
        k += $.length, z.push($);
      }
      return z.push({ length: k, x: B, y: M }), z;
    }
    function q(C, k, P) {
      P || (P = J(C));
      for (var D = 0; k - P[D].length > 0 && D < P.length - 2; )
        k -= P[D].length, D++;
      var B = P[D], M = k / B.length, E = B.command, L = C[D], z;
      switch (E) {
        case "M":
          return { x: B.x, y: B.y, angle: 0 };
        case "Z":
        case "z":
          return z = new e.Point(B.x, B.y).lerp(
            new e.Point(B.destX, B.destY),
            M
          ), z.angle = Math.atan2(B.destY - B.y, B.destX - B.x), z;
        case "L":
          return z = new e.Point(B.x, B.y).lerp(
            new e.Point(L[1], L[2]),
            M
          ), z.angle = Math.atan2(L[2] - B.y, L[1] - B.x), z;
        case "C":
          return ee(B, k);
        case "Q":
          return ee(B, k);
      }
    }
    function re(C) {
      var k = [], P = [], D, B, M = e.rePathCommand, E = "[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?\\s*", L = "(" + E + ")" + e.commaWsp, z = "([01])" + e.commaWsp + "?", Y = L + "?" + L + "?" + L + z + z + L + "?(" + E + ")", $ = new RegExp(Y, "g"), W, j, te;
      if (!C || !C.match)
        return k;
      te = C.match(/[mzlhvcsqta][^mzlhvcsqta]*/gi);
      for (var V = 0, F, X = te.length; V < X; V++) {
        D = te[V], j = D.slice(1).trim(), P.length = 0;
        var G = D.charAt(0);
        if (F = [G], G.toLowerCase() === "a")
          for (var H; H = $.exec(j); )
            for (var Z = 1; Z < H.length; Z++)
              P.push(H[Z]);
        else
          for (; W = M.exec(j); )
            P.push(W[0]);
        for (var Z = 0, se = P.length; Z < se; Z++)
          B = parseFloat(P[Z]), isNaN(B) || F.push(B);
        var ye = n[G.toLowerCase()], pe = u[G] || G;
        if (F.length - 1 > ye)
          for (var K = 1, ge = F.length; K < ge; K += ye)
            k.push([G].concat(F.slice(K, K + ye))), G = pe;
        else
          k.push(F);
      }
      return k;
    }
    function le(C, k) {
      var P = [], D, B = new e.Point(C[0].x, C[0].y), M = new e.Point(C[1].x, C[1].y), E = C.length, L = 1, z = 0, Y = E > 2;
      for (k = k || 0, Y && (L = C[2].x < M.x ? -1 : C[2].x === M.x ? 0 : 1, z = C[2].y < M.y ? -1 : C[2].y === M.y ? 0 : 1), P.push(["M", B.x - L * k, B.y - z * k]), D = 1; D < E; D++) {
        if (!B.eq(M)) {
          var $ = B.midPointFrom(M);
          P.push(["Q", B.x, B.y, $.x, $.y]);
        }
        B = C[D], D + 1 < C.length && (M = C[D + 1]);
      }
      return Y && (L = B.x > C[D - 2].x ? 1 : B.x === C[D - 2].x ? 0 : -1, z = B.y > C[D - 2].y ? 1 : B.y === C[D - 2].y ? 0 : -1), P.push(["L", B.x + L * k, B.y + z * k]), P;
    }
    function ne(C, k, P) {
      return P && (k = e.util.multiplyTransformMatrices(
        k,
        [1, 0, 0, 1, -P.x, -P.y]
      )), C.map(function(D) {
        for (var B = D.slice(0), M = {}, E = 1; E < D.length - 1; E += 2)
          M.x = D[E], M.y = D[E + 1], M = e.util.transformPoint(M, k), B[E] = M.x, B[E + 1] = M.y;
        return B;
      });
    }
    e.util.joinPath = function(C) {
      return C.map(function(k) {
        return k.join(" ");
      }).join(" ");
    }, e.util.parsePath = re, e.util.makePathSimpler = m, e.util.getSmoothPathFromPoints = le, e.util.getPathSegmentsInfo = J, e.util.getBoundsOfCurve = c, e.util.getPointOnPath = q, e.util.transformPath = ne;
  }(), function() {
    var a = Array.prototype.slice;
    function n(c, f) {
      for (var m = a.call(arguments, 2), d = [], v = 0, b = c.length; v < b; v++)
        d[v] = m.length ? c[v][f].apply(c[v], m) : c[v][f].call(c[v]);
      return d;
    }
    function u(c, f) {
      return l(c, f, function(m, d) {
        return m >= d;
      });
    }
    function h(c, f) {
      return l(c, f, function(m, d) {
        return m < d;
      });
    }
    function s(c, f) {
      for (var m = c.length; m--; )
        c[m] = f;
      return c;
    }
    function l(c, f, m) {
      if (!(!c || c.length === 0)) {
        var d = c.length - 1, v = f ? c[d][f] : c[d];
        if (f)
          for (; d--; )
            m(c[d][f], v) && (v = c[d][f]);
        else
          for (; d--; )
            m(c[d], v) && (v = c[d]);
        return v;
      }
    }
    e.util.array = {
      fill: s,
      invoke: n,
      min: h,
      max: u
    };
  }(), function() {
    function a(u, h, s) {
      if (s)
        if (!e.isLikelyNode && h instanceof Element)
          u = h;
        else if (h instanceof Array) {
          u = [];
          for (var l = 0, c = h.length; l < c; l++)
            u[l] = a({}, h[l], s);
        } else if (h && typeof h == "object")
          for (var f in h)
            f === "canvas" || f === "group" ? u[f] = null : h.hasOwnProperty(f) && (u[f] = a({}, h[f], s));
        else
          u = h;
      else
        for (var f in h)
          u[f] = h[f];
      return u;
    }
    function n(u, h) {
      return a({}, u, h);
    }
    e.util.object = {
      extend: a,
      clone: n
    }, e.util.object.extend(e.util, e.Observable);
  }(), function() {
    function a(l) {
      return l.replace(/-+(.)?/g, function(c, f) {
        return f ? f.toUpperCase() : "";
      });
    }
    function n(l, c) {
      return l.charAt(0).toUpperCase() + (c ? l.slice(1) : l.slice(1).toLowerCase());
    }
    function u(l) {
      return l.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/'/g, "&apos;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
    }
    function h(l) {
      var c = 0, f, m = [];
      for (c = 0, f; c < l.length; c++)
        (f = s(l, c)) !== !1 && m.push(f);
      return m;
    }
    function s(l, c) {
      var f = l.charCodeAt(c);
      if (isNaN(f))
        return "";
      if (f < 55296 || f > 57343)
        return l.charAt(c);
      if (55296 <= f && f <= 56319) {
        if (l.length <= c + 1)
          throw "High surrogate without following low surrogate";
        var m = l.charCodeAt(c + 1);
        if (56320 > m || m > 57343)
          throw "High surrogate without following low surrogate";
        return l.charAt(c) + l.charAt(c + 1);
      }
      if (c === 0)
        throw "Low surrogate without preceding high surrogate";
      var d = l.charCodeAt(c - 1);
      if (55296 > d || d > 56319)
        throw "Low surrogate without preceding high surrogate";
      return !1;
    }
    e.util.string = {
      camelize: a,
      capitalize: n,
      escapeXml: u,
      graphemeSplit: h
    };
  }(), function() {
    var a = Array.prototype.slice, n = function() {
    }, u = function() {
      for (var f in { toString: 1 })
        if (f === "toString")
          return !1;
      return !0;
    }(), h = function(f, m, d) {
      for (var v in m)
        v in f.prototype && typeof f.prototype[v] == "function" && (m[v] + "").indexOf("callSuper") > -1 ? f.prototype[v] = function(b) {
          return function() {
            var y = this.constructor.superclass;
            this.constructor.superclass = d;
            var w = m[b].apply(this, arguments);
            if (this.constructor.superclass = y, b !== "initialize")
              return w;
          };
        }(v) : f.prototype[v] = m[v], u && (m.toString !== Object.prototype.toString && (f.prototype.toString = m.toString), m.valueOf !== Object.prototype.valueOf && (f.prototype.valueOf = m.valueOf));
    };
    function s() {
    }
    function l(f) {
      for (var m = null, d = this; d.constructor.superclass; ) {
        var v = d.constructor.superclass.prototype[f];
        if (d[f] !== v) {
          m = v;
          break;
        }
        d = d.constructor.superclass.prototype;
      }
      return m ? arguments.length > 1 ? m.apply(this, a.call(arguments, 1)) : m.call(this) : console.log("tried to callSuper " + f + ", method not found in prototype chain", this);
    }
    function c() {
      var f = null, m = a.call(arguments, 0);
      typeof m[0] == "function" && (f = m.shift());
      function d() {
        this.initialize.apply(this, arguments);
      }
      d.superclass = f, d.subclasses = [], f && (s.prototype = f.prototype, d.prototype = new s(), f.subclasses.push(d));
      for (var v = 0, b = m.length; v < b; v++)
        h(d, m[v], f);
      return d.prototype.initialize || (d.prototype.initialize = n), d.prototype.constructor = d, d.prototype.callSuper = l, d;
    }
    e.util.createClass = c;
  }(), function() {
    var a = !!e.document.createElement("div").attachEvent, n = ["touchstart", "touchmove", "touchend"];
    e.util.addListener = function(h, s, l, c) {
      h && h.addEventListener(s, l, a ? !1 : c);
    }, e.util.removeListener = function(h, s, l, c) {
      h && h.removeEventListener(s, l, a ? !1 : c);
    };
    function u(h) {
      var s = h.changedTouches;
      return s && s[0] ? s[0] : h;
    }
    e.util.getPointer = function(h) {
      var s = h.target, l = e.util.getScrollLeftTop(s), c = u(h);
      return {
        x: c.clientX + l.left,
        y: c.clientY + l.top
      };
    }, e.util.isTouchEvent = function(h) {
      return n.indexOf(h.type) > -1 || h.pointerType === "touch";
    };
  }(), function() {
    function a(c, f) {
      var m = c.style;
      if (!m)
        return c;
      if (typeof f == "string")
        return c.style.cssText += ";" + f, f.indexOf("opacity") > -1 ? l(c, f.match(/opacity:\s*(\d?\.?\d*)/)[1]) : c;
      for (var d in f)
        if (d === "opacity")
          l(c, f[d]);
        else {
          var v = d === "float" || d === "cssFloat" ? typeof m.styleFloat > "u" ? "cssFloat" : "styleFloat" : d;
          m.setProperty(v, f[d]);
        }
      return c;
    }
    var n = e.document.createElement("div"), u = typeof n.style.opacity == "string", h = typeof n.style.filter == "string", s = /alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/, l = function(c) {
      return c;
    };
    u ? l = function(c, f) {
      return c.style.opacity = f, c;
    } : h && (l = function(c, f) {
      var m = c.style;
      return c.currentStyle && !c.currentStyle.hasLayout && (m.zoom = 1), s.test(m.filter) ? (f = f >= 0.9999 ? "" : "alpha(opacity=" + f * 100 + ")", m.filter = m.filter.replace(s, f)) : m.filter += " alpha(opacity=" + f * 100 + ")", c;
    }), e.util.setStyle = a;
  }(), function() {
    var a = Array.prototype.slice;
    function n(w) {
      return typeof w == "string" ? e.document.getElementById(w) : w;
    }
    var u, h = function(w) {
      return a.call(w, 0);
    };
    try {
      u = h(e.document.childNodes) instanceof Array;
    } catch {
    }
    u || (h = function(w) {
      for (var _ = new Array(w.length), S = w.length; S--; )
        _[S] = w[S];
      return _;
    });
    function s(w, _) {
      var S = e.document.createElement(w);
      for (var T in _)
        T === "class" ? S.className = _[T] : T === "for" ? S.htmlFor = _[T] : S.setAttribute(T, _[T]);
      return S;
    }
    function l(w, _) {
      w && (" " + w.className + " ").indexOf(" " + _ + " ") === -1 && (w.className += (w.className ? " " : "") + _);
    }
    function c(w, _, S) {
      return typeof _ == "string" && (_ = s(_, S)), w.parentNode && w.parentNode.replaceChild(_, w), _.appendChild(w), _;
    }
    function f(w) {
      for (var _ = 0, S = 0, T = e.document.documentElement, A = e.document.body || {
        scrollLeft: 0,
        scrollTop: 0
      }; w && (w.parentNode || w.host) && (w = w.parentNode || w.host, w === e.document ? (_ = A.scrollLeft || T.scrollLeft || 0, S = A.scrollTop || T.scrollTop || 0) : (_ += w.scrollLeft || 0, S += w.scrollTop || 0), !(w.nodeType === 1 && w.style.position === "fixed")); )
        ;
      return { left: _, top: S };
    }
    function m(w) {
      var _, S = w && w.ownerDocument, T = { left: 0, top: 0 }, A = { left: 0, top: 0 }, R, N = {
        borderLeftWidth: "left",
        borderTopWidth: "top",
        paddingLeft: "left",
        paddingTop: "top"
      };
      if (!S)
        return A;
      for (var U in N)
        A[N[U]] += parseInt(d(w, U), 10) || 0;
      return _ = S.documentElement, typeof w.getBoundingClientRect < "u" && (T = w.getBoundingClientRect()), R = f(w), {
        left: T.left + R.left - (_.clientLeft || 0) + A.left,
        top: T.top + R.top - (_.clientTop || 0) + A.top
      };
    }
    var d;
    e.document.defaultView && e.document.defaultView.getComputedStyle ? d = function(w, _) {
      var S = e.document.defaultView.getComputedStyle(w, null);
      return S ? S[_] : void 0;
    } : d = function(w, _) {
      var S = w.style[_];
      return !S && w.currentStyle && (S = w.currentStyle[_]), S;
    }, function() {
      var w = e.document.documentElement.style, _ = "userSelect" in w ? "userSelect" : "MozUserSelect" in w ? "MozUserSelect" : "WebkitUserSelect" in w ? "WebkitUserSelect" : "KhtmlUserSelect" in w ? "KhtmlUserSelect" : "";
      function S(A) {
        return typeof A.onselectstart < "u" && (A.onselectstart = e.util.falseFunction), _ ? A.style[_] = "none" : typeof A.unselectable == "string" && (A.unselectable = "on"), A;
      }
      function T(A) {
        return typeof A.onselectstart < "u" && (A.onselectstart = null), _ ? A.style[_] = "" : typeof A.unselectable == "string" && (A.unselectable = ""), A;
      }
      e.util.makeElementUnselectable = S, e.util.makeElementSelectable = T;
    }();
    function v(w) {
      var _ = e.jsdomImplForWrapper(w);
      return _._canvas || _._image;
    }
    function b(w) {
      if (!!e.isLikelyNode) {
        var _ = e.jsdomImplForWrapper(w);
        _ && (_._image = null, _._canvas = null, _._currentSrc = null, _._attributes = null, _._classList = null);
      }
    }
    function y(w, _) {
      w.imageSmoothingEnabled = w.imageSmoothingEnabled || w.webkitImageSmoothingEnabled || w.mozImageSmoothingEnabled || w.msImageSmoothingEnabled || w.oImageSmoothingEnabled, w.imageSmoothingEnabled = _;
    }
    e.util.setImageSmoothing = y, e.util.getById = n, e.util.toArray = h, e.util.addClass = l, e.util.makeElement = s, e.util.wrapElement = c, e.util.getScrollLeftTop = f, e.util.getElementOffset = m, e.util.getNodeCanvas = v, e.util.cleanUpJsdomNode = b;
  }(), function() {
    function a(h, s) {
      return h + (/\?/.test(h) ? "&" : "?") + s;
    }
    function n() {
    }
    function u(h, s) {
      s || (s = {});
      var l = s.method ? s.method.toUpperCase() : "GET", c = s.onComplete || function() {
      }, f = new e.window.XMLHttpRequest(), m = s.body || s.parameters;
      return f.onreadystatechange = function() {
        f.readyState === 4 && (c(f), f.onreadystatechange = n);
      }, l === "GET" && (m = null, typeof s.parameters == "string" && (h = a(h, s.parameters))), f.open(l, h, !0), (l === "POST" || l === "PUT") && f.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"), f.send(m), f;
    }
    e.util.request = u;
  }(), e.log = console.log, e.warn = console.warn, function() {
    var a = e.util.object.extend, n = e.util.object.clone, u = [];
    e.util.object.extend(u, {
      cancelAll: function() {
        var v = this.splice(0);
        return v.forEach(function(b) {
          b.cancel();
        }), v;
      },
      cancelByCanvas: function(v) {
        if (!v)
          return [];
        var b = this.filter(function(y) {
          return typeof y.target == "object" && y.target.canvas === v;
        });
        return b.forEach(function(y) {
          y.cancel();
        }), b;
      },
      cancelByTarget: function(v) {
        var b = this.findAnimationsByTarget(v);
        return b.forEach(function(y) {
          y.cancel();
        }), b;
      },
      findAnimationIndex: function(v) {
        return this.indexOf(this.findAnimation(v));
      },
      findAnimation: function(v) {
        return this.find(function(b) {
          return b.cancel === v;
        });
      },
      findAnimationsByTarget: function(v) {
        return v ? this.filter(function(b) {
          return b.target === v;
        }) : [];
      }
    });
    function h() {
      return !1;
    }
    function s(v, b, y, w) {
      return -y * Math.cos(v / w * (Math.PI / 2)) + y + b;
    }
    function l(v) {
      v || (v = {});
      var b = !1, y, w = function() {
        var _ = e.runningAnimations.indexOf(y);
        return _ > -1 && e.runningAnimations.splice(_, 1)[0];
      };
      return y = a(n(v), {
        cancel: function() {
          return b = !0, w();
        },
        currentValue: "startValue" in v ? v.startValue : 0,
        completionRate: 0,
        durationRate: 0
      }), e.runningAnimations.push(y), m(function(_) {
        var S = _ || +new Date(), T = v.duration || 500, A = S + T, R, N = v.onChange || h, U = v.abort || h, Q = v.onComplete || h, ee = v.easing || s, J = "startValue" in v ? v.startValue.length > 0 : !1, q = "startValue" in v ? v.startValue : 0, re = "endValue" in v ? v.endValue : 100, le = v.byValue || (J ? q.map(function(ne, C) {
          return re[C] - q[C];
        }) : re - q);
        v.onStart && v.onStart(), function ne(C) {
          R = C || +new Date();
          var k = R > A ? T : R - S, P = k / T, D = J ? q.map(function(M, E) {
            return ee(k, q[E], le[E], T);
          }) : ee(k, q, le, T), B = Math.abs(J ? (D[0] - q[0]) / le[0] : (D - q) / le);
          if (y.currentValue = J ? D.slice() : D, y.completionRate = B, y.durationRate = P, !b) {
            if (U(D, B, P)) {
              w();
              return;
            }
            if (R > A) {
              y.currentValue = J ? re.slice() : re, y.completionRate = 1, y.durationRate = 1, N(J ? re.slice() : re, 1, 1), Q(re, 1, 1), w();
              return;
            } else
              N(D, B, P), m(ne);
          }
        }(S);
      }), y.cancel;
    }
    var c = e.window.requestAnimationFrame || e.window.webkitRequestAnimationFrame || e.window.mozRequestAnimationFrame || e.window.oRequestAnimationFrame || e.window.msRequestAnimationFrame || function(v) {
      return e.window.setTimeout(v, 1e3 / 60);
    }, f = e.window.cancelAnimationFrame || e.window.clearTimeout;
    function m() {
      return c.apply(e.window, arguments);
    }
    function d() {
      return f.apply(e.window, arguments);
    }
    e.util.animate = l, e.util.requestAnimFrame = m, e.util.cancelAnimFrame = d, e.runningAnimations = u;
  }(), function() {
    function a(u, h, s) {
      var l = "rgba(" + parseInt(u[0] + s * (h[0] - u[0]), 10) + "," + parseInt(u[1] + s * (h[1] - u[1]), 10) + "," + parseInt(u[2] + s * (h[2] - u[2]), 10);
      return l += "," + (u && h ? parseFloat(u[3] + s * (h[3] - u[3])) : 1), l += ")", l;
    }
    function n(u, h, s, l) {
      var c = new e.Color(u).getSource(), f = new e.Color(h).getSource(), m = l.onComplete, d = l.onChange;
      return l = l || {}, e.util.animate(e.util.object.extend(l, {
        duration: s || 500,
        startValue: c,
        endValue: f,
        byValue: f,
        easing: function(v, b, y, w) {
          var _ = l.colorEasing ? l.colorEasing(v, w) : 1 - Math.cos(v / w * (Math.PI / 2));
          return a(b, y, _);
        },
        onComplete: function(v, b, y) {
          if (m)
            return m(
              a(f, f, 0),
              b,
              y
            );
        },
        onChange: function(v, b, y) {
          if (d) {
            if (Array.isArray(v))
              return d(
                a(v, v, 0),
                b,
                y
              );
            d(v, b, y);
          }
        }
      }));
    }
    e.util.animateColor = n;
  }(), function() {
    function a(C, k, P, D) {
      return C < Math.abs(k) ? (C = k, D = P / 4) : k === 0 && C === 0 ? D = P / (2 * Math.PI) * Math.asin(1) : D = P / (2 * Math.PI) * Math.asin(k / C), { a: C, c: k, p: P, s: D };
    }
    function n(C, k, P) {
      return C.a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k * P - C.s) * (2 * Math.PI) / C.p);
    }
    function u(C, k, P, D) {
      return P * ((C = C / D - 1) * C * C + 1) + k;
    }
    function h(C, k, P, D) {
      return C /= D / 2, C < 1 ? P / 2 * C * C * C + k : P / 2 * ((C -= 2) * C * C + 2) + k;
    }
    function s(C, k, P, D) {
      return P * (C /= D) * C * C * C + k;
    }
    function l(C, k, P, D) {
      return -P * ((C = C / D - 1) * C * C * C - 1) + k;
    }
    function c(C, k, P, D) {
      return C /= D / 2, C < 1 ? P / 2 * C * C * C * C + k : -P / 2 * ((C -= 2) * C * C * C - 2) + k;
    }
    function f(C, k, P, D) {
      return P * (C /= D) * C * C * C * C + k;
    }
    function m(C, k, P, D) {
      return P * ((C = C / D - 1) * C * C * C * C + 1) + k;
    }
    function d(C, k, P, D) {
      return C /= D / 2, C < 1 ? P / 2 * C * C * C * C * C + k : P / 2 * ((C -= 2) * C * C * C * C + 2) + k;
    }
    function v(C, k, P, D) {
      return -P * Math.cos(C / D * (Math.PI / 2)) + P + k;
    }
    function b(C, k, P, D) {
      return P * Math.sin(C / D * (Math.PI / 2)) + k;
    }
    function y(C, k, P, D) {
      return -P / 2 * (Math.cos(Math.PI * C / D) - 1) + k;
    }
    function w(C, k, P, D) {
      return C === 0 ? k : P * Math.pow(2, 10 * (C / D - 1)) + k;
    }
    function _(C, k, P, D) {
      return C === D ? k + P : P * (-Math.pow(2, -10 * C / D) + 1) + k;
    }
    function S(C, k, P, D) {
      return C === 0 ? k : C === D ? k + P : (C /= D / 2, C < 1 ? P / 2 * Math.pow(2, 10 * (C - 1)) + k : P / 2 * (-Math.pow(2, -10 * --C) + 2) + k);
    }
    function T(C, k, P, D) {
      return -P * (Math.sqrt(1 - (C /= D) * C) - 1) + k;
    }
    function A(C, k, P, D) {
      return P * Math.sqrt(1 - (C = C / D - 1) * C) + k;
    }
    function R(C, k, P, D) {
      return C /= D / 2, C < 1 ? -P / 2 * (Math.sqrt(1 - C * C) - 1) + k : P / 2 * (Math.sqrt(1 - (C -= 2) * C) + 1) + k;
    }
    function N(C, k, P, D) {
      var B = 1.70158, M = 0, E = P;
      if (C === 0)
        return k;
      if (C /= D, C === 1)
        return k + P;
      M || (M = D * 0.3);
      var L = a(E, P, M, B);
      return -n(L, C, D) + k;
    }
    function U(C, k, P, D) {
      var B = 1.70158, M = 0, E = P;
      if (C === 0)
        return k;
      if (C /= D, C === 1)
        return k + P;
      M || (M = D * 0.3);
      var L = a(E, P, M, B);
      return L.a * Math.pow(2, -10 * C) * Math.sin((C * D - L.s) * (2 * Math.PI) / L.p) + L.c + k;
    }
    function Q(C, k, P, D) {
      var B = 1.70158, M = 0, E = P;
      if (C === 0)
        return k;
      if (C /= D / 2, C === 2)
        return k + P;
      M || (M = D * (0.3 * 1.5));
      var L = a(E, P, M, B);
      return C < 1 ? -0.5 * n(L, C, D) + k : L.a * Math.pow(2, -10 * (C -= 1)) * Math.sin((C * D - L.s) * (2 * Math.PI) / L.p) * 0.5 + L.c + k;
    }
    function ee(C, k, P, D, B) {
      return B === void 0 && (B = 1.70158), P * (C /= D) * C * ((B + 1) * C - B) + k;
    }
    function J(C, k, P, D, B) {
      return B === void 0 && (B = 1.70158), P * ((C = C / D - 1) * C * ((B + 1) * C + B) + 1) + k;
    }
    function q(C, k, P, D, B) {
      return B === void 0 && (B = 1.70158), C /= D / 2, C < 1 ? P / 2 * (C * C * (((B *= 1.525) + 1) * C - B)) + k : P / 2 * ((C -= 2) * C * (((B *= 1.525) + 1) * C + B) + 2) + k;
    }
    function re(C, k, P, D) {
      return P - le(D - C, 0, P, D) + k;
    }
    function le(C, k, P, D) {
      return (C /= D) < 1 / 2.75 ? P * (7.5625 * C * C) + k : C < 2 / 2.75 ? P * (7.5625 * (C -= 1.5 / 2.75) * C + 0.75) + k : C < 2.5 / 2.75 ? P * (7.5625 * (C -= 2.25 / 2.75) * C + 0.9375) + k : P * (7.5625 * (C -= 2.625 / 2.75) * C + 0.984375) + k;
    }
    function ne(C, k, P, D) {
      return C < D / 2 ? re(C * 2, 0, P, D) * 0.5 + k : le(C * 2 - D, 0, P, D) * 0.5 + P * 0.5 + k;
    }
    e.util.ease = {
      easeInQuad: function(C, k, P, D) {
        return P * (C /= D) * C + k;
      },
      easeOutQuad: function(C, k, P, D) {
        return -P * (C /= D) * (C - 2) + k;
      },
      easeInOutQuad: function(C, k, P, D) {
        return C /= D / 2, C < 1 ? P / 2 * C * C + k : -P / 2 * (--C * (C - 2) - 1) + k;
      },
      easeInCubic: function(C, k, P, D) {
        return P * (C /= D) * C * C + k;
      },
      easeOutCubic: u,
      easeInOutCubic: h,
      easeInQuart: s,
      easeOutQuart: l,
      easeInOutQuart: c,
      easeInQuint: f,
      easeOutQuint: m,
      easeInOutQuint: d,
      easeInSine: v,
      easeOutSine: b,
      easeInOutSine: y,
      easeInExpo: w,
      easeOutExpo: _,
      easeInOutExpo: S,
      easeInCirc: T,
      easeOutCirc: A,
      easeInOutCirc: R,
      easeInElastic: N,
      easeOutElastic: U,
      easeInOutElastic: Q,
      easeInBack: ee,
      easeOutBack: J,
      easeInOutBack: q,
      easeInBounce: re,
      easeOutBounce: le,
      easeInOutBounce: ne
    };
  }(), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.util.object.extend, h = n.util.object.clone, s = n.util.toFixed, l = n.util.parseUnit, c = n.util.multiplyTransformMatrices, f = [
      "path",
      "circle",
      "polygon",
      "polyline",
      "ellipse",
      "rect",
      "line",
      "image",
      "text"
    ], m = ["symbol", "image", "marker", "pattern", "view", "svg"], d = ["pattern", "defs", "symbol", "metadata", "clipPath", "mask", "desc"], v = ["symbol", "g", "a", "svg", "clipPath", "defs"], b = {
      cx: "left",
      x: "left",
      r: "radius",
      cy: "top",
      y: "top",
      display: "visible",
      visibility: "visible",
      transform: "transformMatrix",
      "fill-opacity": "fillOpacity",
      "fill-rule": "fillRule",
      "font-family": "fontFamily",
      "font-size": "fontSize",
      "font-style": "fontStyle",
      "font-weight": "fontWeight",
      "letter-spacing": "charSpacing",
      "paint-order": "paintFirst",
      "stroke-dasharray": "strokeDashArray",
      "stroke-dashoffset": "strokeDashOffset",
      "stroke-linecap": "strokeLineCap",
      "stroke-linejoin": "strokeLineJoin",
      "stroke-miterlimit": "strokeMiterLimit",
      "stroke-opacity": "strokeOpacity",
      "stroke-width": "strokeWidth",
      "text-decoration": "textDecoration",
      "text-anchor": "textAnchor",
      opacity: "opacity",
      "clip-path": "clipPath",
      "clip-rule": "clipRule",
      "vector-effect": "strokeUniform",
      "image-rendering": "imageSmoothing"
    }, y = {
      stroke: "strokeOpacity",
      fill: "fillOpacity"
    }, w = "font-size", _ = "clip-path";
    n.svgValidTagNamesRegEx = A(f), n.svgViewBoxElementsRegEx = A(m), n.svgInvalidAncestorsRegEx = A(d), n.svgValidParentsRegEx = A(v), n.cssRules = {}, n.gradientDefs = {}, n.clipPaths = {};
    function S(M) {
      return M in b ? b[M] : M;
    }
    function T(M, E, L, z) {
      var Y = Array.isArray(E), $;
      if ((M === "fill" || M === "stroke") && E === "none")
        E = "";
      else {
        if (M === "strokeUniform")
          return E === "non-scaling-stroke";
        if (M === "strokeDashArray")
          E === "none" ? E = null : E = E.replace(/,/g, " ").split(/\s+/).map(parseFloat);
        else if (M === "transformMatrix")
          L && L.transformMatrix ? E = c(
            L.transformMatrix,
            n.parseTransformAttribute(E)
          ) : E = n.parseTransformAttribute(E);
        else if (M === "visible")
          E = E !== "none" && E !== "hidden", L && L.visible === !1 && (E = !1);
        else if (M === "opacity")
          E = parseFloat(E), L && typeof L.opacity < "u" && (E *= L.opacity);
        else if (M === "textAnchor")
          E = E === "start" ? "left" : E === "end" ? "right" : "center";
        else if (M === "charSpacing")
          $ = l(E, z) / z * 1e3;
        else if (M === "paintFirst") {
          var W = E.indexOf("fill"), j = E.indexOf("stroke"), E = "fill";
          (W > -1 && j > -1 && j < W || W === -1 && j > -1) && (E = "stroke");
        } else {
          if (M === "href" || M === "xlink:href" || M === "font")
            return E;
          if (M === "imageSmoothing")
            return E === "optimizeQuality";
          $ = Y ? E.map(l) : l(E, z);
        }
      }
      return !Y && isNaN($) ? E : $;
    }
    function A(M) {
      return new RegExp("^(" + M.join("|") + ")\\b", "i");
    }
    function R(M) {
      for (var E in y)
        if (!(typeof M[y[E]] > "u" || M[E] === "")) {
          if (typeof M[E] > "u") {
            if (!n.Object.prototype[E])
              continue;
            M[E] = n.Object.prototype[E];
          }
          if (M[E].indexOf("url(") !== 0) {
            var L = new n.Color(M[E]);
            M[E] = L.setAlpha(s(L.getAlpha() * M[y[E]], 2)).toRgba();
          }
        }
      return M;
    }
    function N(M, E) {
      var L, z = [], Y, $, W;
      for ($ = 0, W = E.length; $ < W; $++)
        L = E[$], Y = M.getElementsByTagName(L), z = z.concat(Array.prototype.slice.call(Y));
      return z;
    }
    n.parseTransformAttribute = function() {
      function M(K, ge) {
        var _e = n.util.cos(ge[0]), ke = n.util.sin(ge[0]), Re = 0, Oe = 0;
        ge.length === 3 && (Re = ge[1], Oe = ge[2]), K[0] = _e, K[1] = ke, K[2] = -ke, K[3] = _e, K[4] = Re - (_e * Re - ke * Oe), K[5] = Oe - (ke * Re + _e * Oe);
      }
      function E(K, ge) {
        var _e = ge[0], ke = ge.length === 2 ? ge[1] : ge[0];
        K[0] = _e, K[3] = ke;
      }
      function L(K, ge, _e) {
        K[_e] = Math.tan(n.util.degreesToRadians(ge[0]));
      }
      function z(K, ge) {
        K[4] = ge[0], ge.length === 2 && (K[5] = ge[1]);
      }
      var Y = n.iMatrix, $ = n.reNum, W = n.commaWsp, j = "(?:(skewX)\\s*\\(\\s*(" + $ + ")\\s*\\))", te = "(?:(skewY)\\s*\\(\\s*(" + $ + ")\\s*\\))", V = "(?:(rotate)\\s*\\(\\s*(" + $ + ")(?:" + W + "(" + $ + ")" + W + "(" + $ + "))?\\s*\\))", F = "(?:(scale)\\s*\\(\\s*(" + $ + ")(?:" + W + "(" + $ + "))?\\s*\\))", X = "(?:(translate)\\s*\\(\\s*(" + $ + ")(?:" + W + "(" + $ + "))?\\s*\\))", G = "(?:(matrix)\\s*\\(\\s*(" + $ + ")" + W + "(" + $ + ")" + W + "(" + $ + ")" + W + "(" + $ + ")" + W + "(" + $ + ")" + W + "(" + $ + ")\\s*\\))", H = "(?:" + G + "|" + X + "|" + F + "|" + V + "|" + j + "|" + te + ")", Z = "(?:" + H + "(?:" + W + "*" + H + ")*)", se = "^\\s*(?:" + Z + "?)\\s*$", ye = new RegExp(se), pe = new RegExp(H, "g");
      return function(K) {
        var ge = Y.concat(), _e = [];
        if (!K || K && !ye.test(K))
          return ge;
        K.replace(pe, function(Re) {
          var Oe = new RegExp(H).exec(Re).filter(function(hr) {
            return !!hr;
          }), tt = Oe[1], $e = Oe.slice(2).map(parseFloat);
          switch (tt) {
            case "translate":
              z(ge, $e);
              break;
            case "rotate":
              $e[0] = n.util.degreesToRadians($e[0]), M(ge, $e);
              break;
            case "scale":
              E(ge, $e);
              break;
            case "skewX":
              L(ge, $e, 2);
              break;
            case "skewY":
              L(ge, $e, 1);
              break;
            case "matrix":
              ge = $e;
              break;
          }
          _e.push(ge.concat()), ge = Y.concat();
        });
        for (var ke = _e[0]; _e.length > 1; )
          _e.shift(), ke = n.util.multiplyTransformMatrices(ke, _e[0]);
        return ke;
      };
    }();
    function U(M, E) {
      var L, z;
      M.replace(/;\s*$/, "").split(";").forEach(function(Y) {
        var $ = Y.split(":");
        L = $[0].trim().toLowerCase(), z = $[1].trim(), E[L] = z;
      });
    }
    function Q(M, E) {
      var L, z;
      for (var Y in M)
        typeof M[Y] > "u" || (L = Y.toLowerCase(), z = M[Y], E[L] = z);
    }
    function ee(M, E) {
      var L = {};
      for (var z in n.cssRules[E])
        if (J(M, z.split(" ")))
          for (var Y in n.cssRules[E][z])
            L[Y] = n.cssRules[E][z][Y];
      return L;
    }
    function J(M, E) {
      var L, z = !0;
      return L = re(M, E.pop()), L && E.length && (z = q(M, E)), L && z && E.length === 0;
    }
    function q(M, E) {
      for (var L, z = !0; M.parentNode && M.parentNode.nodeType === 1 && E.length; )
        z && (L = E.pop()), M = M.parentNode, z = re(M, L);
      return E.length === 0;
    }
    function re(M, E) {
      var L = M.nodeName, z = M.getAttribute("class"), Y = M.getAttribute("id"), $, W;
      if ($ = new RegExp("^" + L, "i"), E = E.replace($, ""), Y && E.length && ($ = new RegExp("#" + Y + "(?![a-zA-Z\\-]+)", "i"), E = E.replace($, "")), z && E.length)
        for (z = z.split(" "), W = z.length; W--; )
          $ = new RegExp("\\." + z[W] + "(?![a-zA-Z\\-]+)", "i"), E = E.replace($, "");
      return E.length === 0;
    }
    function le(M, E) {
      var L;
      if (M.getElementById && (L = M.getElementById(E)), L)
        return L;
      var z, Y, $, W = M.getElementsByTagName("*");
      for (Y = 0, $ = W.length; Y < $; Y++)
        if (z = W[Y], E === z.getAttribute("id"))
          return z;
    }
    function ne(M) {
      for (var E = N(M, ["use", "svg:use"]), L = 0; E.length && L < E.length; ) {
        var z = E[L], Y = z.getAttribute("xlink:href") || z.getAttribute("href");
        if (Y === null)
          return;
        var $ = Y.slice(1), W = z.getAttribute("x") || 0, j = z.getAttribute("y") || 0, te = le(M, $).cloneNode(!0), V = (te.getAttribute("transform") || "") + " translate(" + W + ", " + j + ")", F, X = E.length, G, H, Z, se, ye = n.svgNS;
        if (k(te), /^svg$/i.test(te.nodeName)) {
          var pe = te.ownerDocument.createElementNS(ye, "g");
          for (H = 0, Z = te.attributes, se = Z.length; H < se; H++)
            G = Z.item(H), pe.setAttributeNS(ye, G.nodeName, G.nodeValue);
          for (; te.firstChild; )
            pe.appendChild(te.firstChild);
          te = pe;
        }
        for (H = 0, Z = z.attributes, se = Z.length; H < se; H++)
          G = Z.item(H), !(G.nodeName === "x" || G.nodeName === "y" || G.nodeName === "xlink:href" || G.nodeName === "href") && (G.nodeName === "transform" ? V = G.nodeValue + " " + V : te.setAttribute(G.nodeName, G.nodeValue));
        te.setAttribute("transform", V), te.setAttribute("instantiated_by_use", "1"), te.removeAttribute("id"), F = z.parentNode, F.replaceChild(te, z), E.length === X && L++;
      }
    }
    var C = new RegExp(
      "^\\s*(" + n.reNum + "+)\\s*,?\\s*(" + n.reNum + "+)\\s*,?\\s*(" + n.reNum + "+)\\s*,?\\s*(" + n.reNum + "+)\\s*$"
    );
    function k(M) {
      if (!n.svgViewBoxElementsRegEx.test(M.nodeName))
        return {};
      var E = M.getAttribute("viewBox"), L = 1, z = 1, Y = 0, $ = 0, W, j, te, V, F = M.getAttribute("width"), X = M.getAttribute("height"), G = M.getAttribute("x") || 0, H = M.getAttribute("y") || 0, Z = M.getAttribute("preserveAspectRatio") || "", se = !E || !(E = E.match(C)), ye = !F || !X || F === "100%" || X === "100%", pe = se && ye, K = {}, ge = "", _e = 0, ke = 0;
      if (K.width = 0, K.height = 0, K.toBeParsed = pe, se && (G || H) && M.parentNode && M.parentNode.nodeName !== "#document" && (ge = " translate(" + l(G) + " " + l(H) + ") ", te = (M.getAttribute("transform") || "") + ge, M.setAttribute("transform", te), M.removeAttribute("x"), M.removeAttribute("y")), pe)
        return K;
      if (se)
        return K.width = l(F), K.height = l(X), K;
      if (Y = -parseFloat(E[1]), $ = -parseFloat(E[2]), W = parseFloat(E[3]), j = parseFloat(E[4]), K.minX = Y, K.minY = $, K.viewBoxWidth = W, K.viewBoxHeight = j, ye ? (K.width = W, K.height = j) : (K.width = l(F), K.height = l(X), L = K.width / W, z = K.height / j), Z = n.util.parsePreserveAspectRatioAttribute(Z), Z.alignX !== "none" && (Z.meetOrSlice === "meet" && (z = L = L > z ? z : L), Z.meetOrSlice === "slice" && (z = L = L > z ? L : z), _e = K.width - W * L, ke = K.height - j * L, Z.alignX === "Mid" && (_e /= 2), Z.alignY === "Mid" && (ke /= 2), Z.alignX === "Min" && (_e = 0), Z.alignY === "Min" && (ke = 0)), L === 1 && z === 1 && Y === 0 && $ === 0 && G === 0 && H === 0)
        return K;
      if ((G || H) && M.parentNode.nodeName !== "#document" && (ge = " translate(" + l(G) + " " + l(H) + ") "), te = ge + " matrix(" + L + " 0 0 " + z + " " + (Y * L + _e) + " " + ($ * z + ke) + ") ", M.nodeName === "svg") {
        for (V = M.ownerDocument.createElementNS(n.svgNS, "g"); M.firstChild; )
          V.appendChild(M.firstChild);
        M.appendChild(V);
      } else
        V = M, V.removeAttribute("x"), V.removeAttribute("y"), te = V.getAttribute("transform") + te;
      return V.setAttribute("transform", te), K;
    }
    function P(M, E) {
      for (; M && (M = M.parentNode); )
        if (M.nodeName && E.test(M.nodeName.replace("svg:", "")) && !M.getAttribute("instantiated_by_use"))
          return !0;
      return !1;
    }
    n.parseSVGDocument = function(M, E, L, z) {
      if (!!M) {
        ne(M);
        var Y = n.Object.__uid++, $, W, j = k(M), te = n.util.toArray(M.getElementsByTagName("*"));
        if (j.crossOrigin = z && z.crossOrigin, j.svgUid = Y, te.length === 0 && n.isLikelyNode) {
          te = M.selectNodes('//*[name(.)!="svg"]');
          var V = [];
          for ($ = 0, W = te.length; $ < W; $++)
            V[$] = te[$];
          te = V;
        }
        var F = te.filter(function(G) {
          return k(G), n.svgValidTagNamesRegEx.test(G.nodeName.replace("svg:", "")) && !P(G, n.svgInvalidAncestorsRegEx);
        });
        if (!F || F && !F.length) {
          E && E([], {});
          return;
        }
        var X = {};
        te.filter(function(G) {
          return G.nodeName.replace("svg:", "") === "clipPath";
        }).forEach(function(G) {
          var H = G.getAttribute("id");
          X[H] = n.util.toArray(G.getElementsByTagName("*")).filter(function(Z) {
            return n.svgValidTagNamesRegEx.test(Z.nodeName.replace("svg:", ""));
          });
        }), n.gradientDefs[Y] = n.getGradientDefs(M), n.cssRules[Y] = n.getCSSRules(M), n.clipPaths[Y] = X, n.parseElements(F, function(G, H) {
          E && (E(G, j, H, te), delete n.gradientDefs[Y], delete n.cssRules[Y], delete n.clipPaths[Y]);
        }, h(j), L, z);
      }
    };
    function D(M, E) {
      var L = ["gradientTransform", "x1", "x2", "y1", "y2", "gradientUnits", "cx", "cy", "r", "fx", "fy"], z = "xlink:href", Y = E.getAttribute(z).slice(1), $ = le(M, Y);
      if ($ && $.getAttribute(z) && D(M, $), L.forEach(function(j) {
        $ && !E.hasAttribute(j) && $.hasAttribute(j) && E.setAttribute(j, $.getAttribute(j));
      }), !E.children.length)
        for (var W = $.cloneNode(!0); W.firstChild; )
          E.appendChild(W.firstChild);
      E.removeAttribute(z);
    }
    var B = new RegExp(
      "(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*(" + n.reNum + "(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|" + n.reNum + "))?\\s+(.*)"
    );
    u(n, {
      parseFontDeclaration: function(M, E) {
        var L = M.match(B);
        if (!!L) {
          var z = L[1], Y = L[3], $ = L[4], W = L[5], j = L[6];
          z && (E.fontStyle = z), Y && (E.fontWeight = isNaN(parseFloat(Y)) ? Y : parseFloat(Y)), $ && (E.fontSize = l($)), j && (E.fontFamily = j), W && (E.lineHeight = W === "normal" ? 1 : W);
        }
      },
      getGradientDefs: function(M) {
        var E = [
          "linearGradient",
          "radialGradient",
          "svg:linearGradient",
          "svg:radialGradient"
        ], L = N(M, E), z, Y = 0, $ = {};
        for (Y = L.length; Y--; )
          z = L[Y], z.getAttribute("xlink:href") && D(M, z), $[z.getAttribute("id")] = z;
        return $;
      },
      parseAttributes: function(M, E, L) {
        if (!!M) {
          var z, Y = {}, $, W;
          typeof L > "u" && (L = M.getAttribute("svgUid")), M.parentNode && n.svgValidParentsRegEx.test(M.parentNode.nodeName) && (Y = n.parseAttributes(M.parentNode, E, L));
          var j = E.reduce(function(Z, se) {
            return z = M.getAttribute(se), z && (Z[se] = z), Z;
          }, {}), te = u(
            ee(M, L),
            n.parseStyleAttribute(M)
          );
          j = u(
            j,
            te
          ), te[_] && M.setAttribute(_, te[_]), $ = W = Y.fontSize || n.Text.DEFAULT_SVG_FONT_SIZE, j[w] && (j[w] = $ = l(j[w], W));
          var V, F, X = {};
          for (var G in j)
            V = S(G), F = T(V, j[G], Y, $), X[V] = F;
          X && X.font && n.parseFontDeclaration(X.font, X);
          var H = u(Y, X);
          return n.svgValidParentsRegEx.test(M.nodeName) ? H : R(H);
        }
      },
      parseElements: function(M, E, L, z, Y) {
        new n.ElementsParser(M, E, L, z, Y).parse();
      },
      parseStyleAttribute: function(M) {
        var E = {}, L = M.getAttribute("style");
        return L && (typeof L == "string" ? U(L, E) : Q(L, E)), E;
      },
      parsePointsAttribute: function(M) {
        if (!M)
          return null;
        M = M.replace(/,/g, " ").trim(), M = M.split(/\s+/);
        var E = [], L, z;
        for (L = 0, z = M.length; L < z; L += 2)
          E.push({
            x: parseFloat(M[L]),
            y: parseFloat(M[L + 1])
          });
        return E;
      },
      getCSSRules: function(M) {
        var E = M.getElementsByTagName("style"), L, z, Y = {}, $;
        for (L = 0, z = E.length; L < z; L++) {
          var W = E[L].textContent;
          W = W.replace(/\/\*[\s\S]*?\*\//g, ""), W.trim() !== "" && ($ = W.split("}"), $ = $.filter(function(j) {
            return j.trim();
          }), $.forEach(function(j) {
            var te = j.split("{"), V = {}, F = te[1].trim(), X = F.split(";").filter(function(se) {
              return se.trim();
            });
            for (L = 0, z = X.length; L < z; L++) {
              var G = X[L].split(":"), H = G[0].trim(), Z = G[1].trim();
              V[H] = Z;
            }
            j = te[0].trim(), j.split(",").forEach(function(se) {
              se = se.replace(/^svg/i, "").trim(), se !== "" && (Y[se] ? n.util.object.extend(Y[se], V) : Y[se] = n.util.object.clone(V));
            });
          }));
        }
        return Y;
      },
      loadSVGFromURL: function(M, E, L, z) {
        M = M.replace(/^\n\s*/, "").trim(), new n.util.request(M, {
          method: "get",
          onComplete: Y
        });
        function Y($) {
          var W = $.responseXML;
          if (!W || !W.documentElement)
            return E && E(null), !1;
          n.parseSVGDocument(W.documentElement, function(j, te, V, F) {
            E && E(j, te, V, F);
          }, L, z);
        }
      },
      loadSVGFromString: function(M, E, L, z) {
        var Y = new n.window.DOMParser(), $ = Y.parseFromString(M.trim(), "text/xml");
        n.parseSVGDocument($.documentElement, function(W, j, te, V) {
          E(W, j, te, V);
        }, L, z);
      }
    });
  }(t), e.ElementsParser = function(a, n, u, h, s, l) {
    this.elements = a, this.callback = n, this.options = u, this.reviver = h, this.svgUid = u && u.svgUid || 0, this.parsingOptions = s, this.regexUrl = /^url\(['"]?#([^'"]+)['"]?\)/g, this.doc = l;
  }, function(a) {
    a.parse = function() {
      this.instances = new Array(this.elements.length), this.numElements = this.elements.length, this.createObjects();
    }, a.createObjects = function() {
      var n = this;
      this.elements.forEach(function(u, h) {
        u.setAttribute("svgUid", n.svgUid), n.createObject(u, h);
      });
    }, a.findTag = function(n) {
      return e[e.util.string.capitalize(n.tagName.replace("svg:", ""))];
    }, a.createObject = function(n, u) {
      var h = this.findTag(n);
      if (h && h.fromElement)
        try {
          h.fromElement(n, this.createCallback(u, n), this.options);
        } catch (s) {
          e.log(s);
        }
      else
        this.checkIfDone();
    }, a.createCallback = function(n, u) {
      var h = this;
      return function(s) {
        var l;
        h.resolveGradient(s, u, "fill"), h.resolveGradient(s, u, "stroke"), s instanceof e.Image && s._originalElement && (l = s.parsePreserveAspectRatioAttribute(u)), s._removeTransformMatrix(l), h.resolveClipPath(s, u), h.reviver && h.reviver(u, s), h.instances[n] = s, h.checkIfDone();
      };
    }, a.extractPropertyDefinition = function(n, u, h) {
      var s = n[u], l = this.regexUrl;
      if (!!l.test(s)) {
        l.lastIndex = 0;
        var c = l.exec(s)[1];
        return l.lastIndex = 0, e[h][this.svgUid][c];
      }
    }, a.resolveGradient = function(n, u, h) {
      var s = this.extractPropertyDefinition(n, h, "gradientDefs");
      if (s) {
        var l = u.getAttribute(h + "-opacity"), c = e.Gradient.fromElement(s, n, l, this.options);
        n.set(h, c);
      }
    }, a.createClipPathCallback = function(n, u) {
      return function(h) {
        h._removeTransformMatrix(), h.fillRule = h.clipRule, u.push(h);
      };
    }, a.resolveClipPath = function(n, u) {
      var h = this.extractPropertyDefinition(n, "clipPath", "clipPaths"), s, l, c, f, m, d;
      if (h) {
        f = [], c = e.util.invertTransform(n.calcTransformMatrix());
        for (var v = h[0].parentNode, b = u; b.parentNode && b.getAttribute("clip-path") !== n.clipPath; )
          b = b.parentNode;
        b.parentNode.appendChild(v);
        for (var y = 0; y < h.length; y++)
          s = h[y], l = this.findTag(s), l.fromElement(
            s,
            this.createClipPathCallback(n, f),
            this.options
          );
        f.length === 1 ? h = f[0] : h = new e.Group(f), m = e.util.multiplyTransformMatrices(
          c,
          h.calcTransformMatrix()
        ), h.clipPath && this.resolveClipPath(h, b);
        var d = e.util.qrDecompose(m);
        h.flipX = !1, h.flipY = !1, h.set("scaleX", d.scaleX), h.set("scaleY", d.scaleY), h.angle = d.angle, h.skewX = d.skewX, h.skewY = 0, h.setPositionByOrigin({ x: d.translateX, y: d.translateY }, "center", "center"), n.clipPath = h;
      } else
        delete n.clipPath;
    }, a.checkIfDone = function() {
      --this.numElements === 0 && (this.instances = this.instances.filter(function(n) {
        return n != null;
      }), this.callback(this.instances, this.elements));
    };
  }(e.ElementsParser.prototype), function(a) {
    var n = a.fabric || (a.fabric = {});
    if (n.Point) {
      n.warn("fabric.Point is already defined");
      return;
    }
    n.Point = u;
    function u(h, s) {
      this.x = h, this.y = s;
    }
    u.prototype = {
      type: "point",
      constructor: u,
      add: function(h) {
        return new u(this.x + h.x, this.y + h.y);
      },
      addEquals: function(h) {
        return this.x += h.x, this.y += h.y, this;
      },
      scalarAdd: function(h) {
        return new u(this.x + h, this.y + h);
      },
      scalarAddEquals: function(h) {
        return this.x += h, this.y += h, this;
      },
      subtract: function(h) {
        return new u(this.x - h.x, this.y - h.y);
      },
      subtractEquals: function(h) {
        return this.x -= h.x, this.y -= h.y, this;
      },
      scalarSubtract: function(h) {
        return new u(this.x - h, this.y - h);
      },
      scalarSubtractEquals: function(h) {
        return this.x -= h, this.y -= h, this;
      },
      multiply: function(h) {
        return new u(this.x * h, this.y * h);
      },
      multiplyEquals: function(h) {
        return this.x *= h, this.y *= h, this;
      },
      divide: function(h) {
        return new u(this.x / h, this.y / h);
      },
      divideEquals: function(h) {
        return this.x /= h, this.y /= h, this;
      },
      eq: function(h) {
        return this.x === h.x && this.y === h.y;
      },
      lt: function(h) {
        return this.x < h.x && this.y < h.y;
      },
      lte: function(h) {
        return this.x <= h.x && this.y <= h.y;
      },
      gt: function(h) {
        return this.x > h.x && this.y > h.y;
      },
      gte: function(h) {
        return this.x >= h.x && this.y >= h.y;
      },
      lerp: function(h, s) {
        return typeof s > "u" && (s = 0.5), s = Math.max(Math.min(1, s), 0), new u(this.x + (h.x - this.x) * s, this.y + (h.y - this.y) * s);
      },
      distanceFrom: function(h) {
        var s = this.x - h.x, l = this.y - h.y;
        return Math.sqrt(s * s + l * l);
      },
      midPointFrom: function(h) {
        return this.lerp(h);
      },
      min: function(h) {
        return new u(Math.min(this.x, h.x), Math.min(this.y, h.y));
      },
      max: function(h) {
        return new u(Math.max(this.x, h.x), Math.max(this.y, h.y));
      },
      toString: function() {
        return this.x + "," + this.y;
      },
      setXY: function(h, s) {
        return this.x = h, this.y = s, this;
      },
      setX: function(h) {
        return this.x = h, this;
      },
      setY: function(h) {
        return this.y = h, this;
      },
      setFromPoint: function(h) {
        return this.x = h.x, this.y = h.y, this;
      },
      swap: function(h) {
        var s = this.x, l = this.y;
        this.x = h.x, this.y = h.y, h.x = s, h.y = l;
      },
      clone: function() {
        return new u(this.x, this.y);
      }
    };
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {});
    if (n.Intersection) {
      n.warn("fabric.Intersection is already defined");
      return;
    }
    function u(h) {
      this.status = h, this.points = [];
    }
    n.Intersection = u, n.Intersection.prototype = {
      constructor: u,
      appendPoint: function(h) {
        return this.points.push(h), this;
      },
      appendPoints: function(h) {
        return this.points = this.points.concat(h), this;
      }
    }, n.Intersection.intersectLineLine = function(h, s, l, c) {
      var f, m = (c.x - l.x) * (h.y - l.y) - (c.y - l.y) * (h.x - l.x), d = (s.x - h.x) * (h.y - l.y) - (s.y - h.y) * (h.x - l.x), v = (c.y - l.y) * (s.x - h.x) - (c.x - l.x) * (s.y - h.y);
      if (v !== 0) {
        var b = m / v, y = d / v;
        0 <= b && b <= 1 && 0 <= y && y <= 1 ? (f = new u("Intersection"), f.appendPoint(new n.Point(h.x + b * (s.x - h.x), h.y + b * (s.y - h.y)))) : f = new u();
      } else
        m === 0 || d === 0 ? f = new u("Coincident") : f = new u("Parallel");
      return f;
    }, n.Intersection.intersectLinePolygon = function(h, s, l) {
      var c = new u(), f = l.length, m, d, v, b;
      for (b = 0; b < f; b++)
        m = l[b], d = l[(b + 1) % f], v = u.intersectLineLine(h, s, m, d), c.appendPoints(v.points);
      return c.points.length > 0 && (c.status = "Intersection"), c;
    }, n.Intersection.intersectPolygonPolygon = function(h, s) {
      var l = new u(), c = h.length, f;
      for (f = 0; f < c; f++) {
        var m = h[f], d = h[(f + 1) % c], v = u.intersectLinePolygon(m, d, s);
        l.appendPoints(v.points);
      }
      return l.points.length > 0 && (l.status = "Intersection"), l;
    }, n.Intersection.intersectPolygonRectangle = function(h, s, l) {
      var c = s.min(l), f = s.max(l), m = new n.Point(f.x, c.y), d = new n.Point(c.x, f.y), v = u.intersectLinePolygon(c, m, h), b = u.intersectLinePolygon(m, f, h), y = u.intersectLinePolygon(f, d, h), w = u.intersectLinePolygon(d, c, h), _ = new u();
      return _.appendPoints(v.points), _.appendPoints(b.points), _.appendPoints(y.points), _.appendPoints(w.points), _.points.length > 0 && (_.status = "Intersection"), _;
    };
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {});
    if (n.Color) {
      n.warn("fabric.Color is already defined.");
      return;
    }
    function u(s) {
      s ? this._tryParsingColor(s) : this.setSource([0, 0, 0, 1]);
    }
    n.Color = u, n.Color.prototype = {
      _tryParsingColor: function(s) {
        var l;
        s in u.colorNameMap && (s = u.colorNameMap[s]), s === "transparent" && (l = [255, 255, 255, 0]), l || (l = u.sourceFromHex(s)), l || (l = u.sourceFromRgb(s)), l || (l = u.sourceFromHsl(s)), l || (l = [0, 0, 0, 1]), l && this.setSource(l);
      },
      _rgbToHsl: function(s, l, c) {
        s /= 255, l /= 255, c /= 255;
        var f, m, d, v = n.util.array.max([s, l, c]), b = n.util.array.min([s, l, c]);
        if (d = (v + b) / 2, v === b)
          f = m = 0;
        else {
          var y = v - b;
          switch (m = d > 0.5 ? y / (2 - v - b) : y / (v + b), v) {
            case s:
              f = (l - c) / y + (l < c ? 6 : 0);
              break;
            case l:
              f = (c - s) / y + 2;
              break;
            case c:
              f = (s - l) / y + 4;
              break;
          }
          f /= 6;
        }
        return [
          Math.round(f * 360),
          Math.round(m * 100),
          Math.round(d * 100)
        ];
      },
      getSource: function() {
        return this._source;
      },
      setSource: function(s) {
        this._source = s;
      },
      toRgb: function() {
        var s = this.getSource();
        return "rgb(" + s[0] + "," + s[1] + "," + s[2] + ")";
      },
      toRgba: function() {
        var s = this.getSource();
        return "rgba(" + s[0] + "," + s[1] + "," + s[2] + "," + s[3] + ")";
      },
      toHsl: function() {
        var s = this.getSource(), l = this._rgbToHsl(s[0], s[1], s[2]);
        return "hsl(" + l[0] + "," + l[1] + "%," + l[2] + "%)";
      },
      toHsla: function() {
        var s = this.getSource(), l = this._rgbToHsl(s[0], s[1], s[2]);
        return "hsla(" + l[0] + "," + l[1] + "%," + l[2] + "%," + s[3] + ")";
      },
      toHex: function() {
        var s = this.getSource(), l, c, f;
        return l = s[0].toString(16), l = l.length === 1 ? "0" + l : l, c = s[1].toString(16), c = c.length === 1 ? "0" + c : c, f = s[2].toString(16), f = f.length === 1 ? "0" + f : f, l.toUpperCase() + c.toUpperCase() + f.toUpperCase();
      },
      toHexa: function() {
        var s = this.getSource(), l;
        return l = Math.round(s[3] * 255), l = l.toString(16), l = l.length === 1 ? "0" + l : l, this.toHex() + l.toUpperCase();
      },
      getAlpha: function() {
        return this.getSource()[3];
      },
      setAlpha: function(s) {
        var l = this.getSource();
        return l[3] = s, this.setSource(l), this;
      },
      toGrayscale: function() {
        var s = this.getSource(), l = parseInt((s[0] * 0.3 + s[1] * 0.59 + s[2] * 0.11).toFixed(0), 10), c = s[3];
        return this.setSource([l, l, l, c]), this;
      },
      toBlackWhite: function(s) {
        var l = this.getSource(), c = (l[0] * 0.3 + l[1] * 0.59 + l[2] * 0.11).toFixed(0), f = l[3];
        return s = s || 127, c = Number(c) < Number(s) ? 0 : 255, this.setSource([c, c, c, f]), this;
      },
      overlayWith: function(s) {
        s instanceof u || (s = new u(s));
        var l = [], c = this.getAlpha(), f = 0.5, m = this.getSource(), d = s.getSource(), v;
        for (v = 0; v < 3; v++)
          l.push(Math.round(m[v] * (1 - f) + d[v] * f));
        return l[3] = c, this.setSource(l), this;
      }
    }, n.Color.reRGBa = /^rgba?\(\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*(?:\s*,\s*((?:\d*\.?\d+)?)\s*)?\)$/i, n.Color.reHSLa = /^hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3}\%)\s*,\s*(\d{1,3}\%)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/i, n.Color.reHex = /^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i, n.Color.colorNameMap = {
      aliceblue: "#F0F8FF",
      antiquewhite: "#FAEBD7",
      aqua: "#00FFFF",
      aquamarine: "#7FFFD4",
      azure: "#F0FFFF",
      beige: "#F5F5DC",
      bisque: "#FFE4C4",
      black: "#000000",
      blanchedalmond: "#FFEBCD",
      blue: "#0000FF",
      blueviolet: "#8A2BE2",
      brown: "#A52A2A",
      burlywood: "#DEB887",
      cadetblue: "#5F9EA0",
      chartreuse: "#7FFF00",
      chocolate: "#D2691E",
      coral: "#FF7F50",
      cornflowerblue: "#6495ED",
      cornsilk: "#FFF8DC",
      crimson: "#DC143C",
      cyan: "#00FFFF",
      darkblue: "#00008B",
      darkcyan: "#008B8B",
      darkgoldenrod: "#B8860B",
      darkgray: "#A9A9A9",
      darkgrey: "#A9A9A9",
      darkgreen: "#006400",
      darkkhaki: "#BDB76B",
      darkmagenta: "#8B008B",
      darkolivegreen: "#556B2F",
      darkorange: "#FF8C00",
      darkorchid: "#9932CC",
      darkred: "#8B0000",
      darksalmon: "#E9967A",
      darkseagreen: "#8FBC8F",
      darkslateblue: "#483D8B",
      darkslategray: "#2F4F4F",
      darkslategrey: "#2F4F4F",
      darkturquoise: "#00CED1",
      darkviolet: "#9400D3",
      deeppink: "#FF1493",
      deepskyblue: "#00BFFF",
      dimgray: "#696969",
      dimgrey: "#696969",
      dodgerblue: "#1E90FF",
      firebrick: "#B22222",
      floralwhite: "#FFFAF0",
      forestgreen: "#228B22",
      fuchsia: "#FF00FF",
      gainsboro: "#DCDCDC",
      ghostwhite: "#F8F8FF",
      gold: "#FFD700",
      goldenrod: "#DAA520",
      gray: "#808080",
      grey: "#808080",
      green: "#008000",
      greenyellow: "#ADFF2F",
      honeydew: "#F0FFF0",
      hotpink: "#FF69B4",
      indianred: "#CD5C5C",
      indigo: "#4B0082",
      ivory: "#FFFFF0",
      khaki: "#F0E68C",
      lavender: "#E6E6FA",
      lavenderblush: "#FFF0F5",
      lawngreen: "#7CFC00",
      lemonchiffon: "#FFFACD",
      lightblue: "#ADD8E6",
      lightcoral: "#F08080",
      lightcyan: "#E0FFFF",
      lightgoldenrodyellow: "#FAFAD2",
      lightgray: "#D3D3D3",
      lightgrey: "#D3D3D3",
      lightgreen: "#90EE90",
      lightpink: "#FFB6C1",
      lightsalmon: "#FFA07A",
      lightseagreen: "#20B2AA",
      lightskyblue: "#87CEFA",
      lightslategray: "#778899",
      lightslategrey: "#778899",
      lightsteelblue: "#B0C4DE",
      lightyellow: "#FFFFE0",
      lime: "#00FF00",
      limegreen: "#32CD32",
      linen: "#FAF0E6",
      magenta: "#FF00FF",
      maroon: "#800000",
      mediumaquamarine: "#66CDAA",
      mediumblue: "#0000CD",
      mediumorchid: "#BA55D3",
      mediumpurple: "#9370DB",
      mediumseagreen: "#3CB371",
      mediumslateblue: "#7B68EE",
      mediumspringgreen: "#00FA9A",
      mediumturquoise: "#48D1CC",
      mediumvioletred: "#C71585",
      midnightblue: "#191970",
      mintcream: "#F5FFFA",
      mistyrose: "#FFE4E1",
      moccasin: "#FFE4B5",
      navajowhite: "#FFDEAD",
      navy: "#000080",
      oldlace: "#FDF5E6",
      olive: "#808000",
      olivedrab: "#6B8E23",
      orange: "#FFA500",
      orangered: "#FF4500",
      orchid: "#DA70D6",
      palegoldenrod: "#EEE8AA",
      palegreen: "#98FB98",
      paleturquoise: "#AFEEEE",
      palevioletred: "#DB7093",
      papayawhip: "#FFEFD5",
      peachpuff: "#FFDAB9",
      peru: "#CD853F",
      pink: "#FFC0CB",
      plum: "#DDA0DD",
      powderblue: "#B0E0E6",
      purple: "#800080",
      rebeccapurple: "#663399",
      red: "#FF0000",
      rosybrown: "#BC8F8F",
      royalblue: "#4169E1",
      saddlebrown: "#8B4513",
      salmon: "#FA8072",
      sandybrown: "#F4A460",
      seagreen: "#2E8B57",
      seashell: "#FFF5EE",
      sienna: "#A0522D",
      silver: "#C0C0C0",
      skyblue: "#87CEEB",
      slateblue: "#6A5ACD",
      slategray: "#708090",
      slategrey: "#708090",
      snow: "#FFFAFA",
      springgreen: "#00FF7F",
      steelblue: "#4682B4",
      tan: "#D2B48C",
      teal: "#008080",
      thistle: "#D8BFD8",
      tomato: "#FF6347",
      turquoise: "#40E0D0",
      violet: "#EE82EE",
      wheat: "#F5DEB3",
      white: "#FFFFFF",
      whitesmoke: "#F5F5F5",
      yellow: "#FFFF00",
      yellowgreen: "#9ACD32"
    };
    function h(s, l, c) {
      return c < 0 && (c += 1), c > 1 && (c -= 1), c < 1 / 6 ? s + (l - s) * 6 * c : c < 1 / 2 ? l : c < 2 / 3 ? s + (l - s) * (2 / 3 - c) * 6 : s;
    }
    n.Color.fromRgb = function(s) {
      return u.fromSource(u.sourceFromRgb(s));
    }, n.Color.sourceFromRgb = function(s) {
      var l = s.match(u.reRGBa);
      if (l) {
        var c = parseInt(l[1], 10) / (/%$/.test(l[1]) ? 100 : 1) * (/%$/.test(l[1]) ? 255 : 1), f = parseInt(l[2], 10) / (/%$/.test(l[2]) ? 100 : 1) * (/%$/.test(l[2]) ? 255 : 1), m = parseInt(l[3], 10) / (/%$/.test(l[3]) ? 100 : 1) * (/%$/.test(l[3]) ? 255 : 1);
        return [
          parseInt(c, 10),
          parseInt(f, 10),
          parseInt(m, 10),
          l[4] ? parseFloat(l[4]) : 1
        ];
      }
    }, n.Color.fromRgba = u.fromRgb, n.Color.fromHsl = function(s) {
      return u.fromSource(u.sourceFromHsl(s));
    }, n.Color.sourceFromHsl = function(s) {
      var l = s.match(u.reHSLa);
      if (!!l) {
        var c = (parseFloat(l[1]) % 360 + 360) % 360 / 360, f = parseFloat(l[2]) / (/%$/.test(l[2]) ? 100 : 1), m = parseFloat(l[3]) / (/%$/.test(l[3]) ? 100 : 1), d, v, b;
        if (f === 0)
          d = v = b = m;
        else {
          var y = m <= 0.5 ? m * (f + 1) : m + f - m * f, w = m * 2 - y;
          d = h(w, y, c + 1 / 3), v = h(w, y, c), b = h(w, y, c - 1 / 3);
        }
        return [
          Math.round(d * 255),
          Math.round(v * 255),
          Math.round(b * 255),
          l[4] ? parseFloat(l[4]) : 1
        ];
      }
    }, n.Color.fromHsla = u.fromHsl, n.Color.fromHex = function(s) {
      return u.fromSource(u.sourceFromHex(s));
    }, n.Color.sourceFromHex = function(s) {
      if (s.match(u.reHex)) {
        var l = s.slice(s.indexOf("#") + 1), c = l.length === 3 || l.length === 4, f = l.length === 8 || l.length === 4, m = c ? l.charAt(0) + l.charAt(0) : l.substring(0, 2), d = c ? l.charAt(1) + l.charAt(1) : l.substring(2, 4), v = c ? l.charAt(2) + l.charAt(2) : l.substring(4, 6), b = f ? c ? l.charAt(3) + l.charAt(3) : l.substring(6, 8) : "FF";
        return [
          parseInt(m, 16),
          parseInt(d, 16),
          parseInt(v, 16),
          parseFloat((parseInt(b, 16) / 255).toFixed(2))
        ];
      }
    }, n.Color.fromSource = function(s) {
      var l = new u();
      return l.setSource(s), l;
    };
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = ["e", "se", "s", "sw", "w", "nw", "n", "ne", "e"], h = ["ns", "nesw", "ew", "nwse"], s = {}, l = "left", c = "top", f = "right", m = "bottom", d = "center", v = {
      top: m,
      bottom: c,
      left: f,
      right: l,
      center: d
    }, b = n.util.radiansToDegrees, y = Math.sign || function(V) {
      return (V > 0) - (V < 0) || +V;
    };
    function w(V, F) {
      var X = V.angle + b(Math.atan2(F.y, F.x)) + 360;
      return Math.round(X % 360 / 45);
    }
    function _(V, F) {
      var X = F.transform.target, G = X.canvas, H = n.util.object.clone(F);
      H.target = X, G && G.fire("object:" + V, H), X.fire(V, F);
    }
    function S(V, F) {
      var X = F.canvas, G = X.uniScaleKey, H = V[G];
      return X.uniformScaling && !H || !X.uniformScaling && H;
    }
    function T(V) {
      return V.originX === d && V.originY === d;
    }
    function A(V, F, X) {
      var G = V.lockScalingX, H = V.lockScalingY;
      return !!(G && H || !F && (G || H) && X || G && F === "x" || H && F === "y");
    }
    function R(V, F, X) {
      var G = "not-allowed", H = S(V, X), Z = "";
      if (F.x !== 0 && F.y === 0 ? Z = "x" : F.x === 0 && F.y !== 0 && (Z = "y"), A(X, Z, H))
        return G;
      var se = w(X, F);
      return u[se] + "-resize";
    }
    function N(V, F, X) {
      var G = "not-allowed";
      if (F.x !== 0 && X.lockSkewingY || F.y !== 0 && X.lockSkewingX)
        return G;
      var H = w(X, F) % 4;
      return h[H] + "-resize";
    }
    function U(V, F, X) {
      return V[X.canvas.altActionKey] ? s.skewCursorStyleHandler(V, F, X) : s.scaleCursorStyleHandler(V, F, X);
    }
    function Q(V, F, X) {
      var G = V[X.canvas.altActionKey];
      if (F.x === 0)
        return G ? "skewX" : "scaleY";
      if (F.y === 0)
        return G ? "skewY" : "scaleX";
    }
    function ee(V, F, X) {
      return X.lockRotation ? "not-allowed" : F.cursorStyle;
    }
    function J(V, F, X, G) {
      return {
        e: V,
        transform: F,
        pointer: {
          x: X,
          y: G
        }
      };
    }
    function q(V) {
      return function(F, X, G, H) {
        var Z = X.target, se = Z.getCenterPoint(), ye = Z.translateToOriginPoint(se, X.originX, X.originY), pe = V(F, X, G, H);
        return Z.setPositionByOrigin(ye, X.originX, X.originY), pe;
      };
    }
    function re(V, F) {
      return function(X, G, H, Z) {
        var se = F(X, G, H, Z);
        return se && _(V, J(X, G, H, Z)), se;
      };
    }
    function le(V, F, X, G, H) {
      var Z = V.target, se = Z.controls[V.corner], ye = Z.canvas.getZoom(), pe = Z.padding / ye, K = Z.toLocalPoint(new n.Point(G, H), F, X);
      return K.x >= pe && (K.x -= pe), K.x <= -pe && (K.x += pe), K.y >= pe && (K.y -= pe), K.y <= pe && (K.y += pe), K.x -= se.offsetX, K.y -= se.offsetY, K;
    }
    function ne(V) {
      return V.flipX !== V.flipY;
    }
    function C(V, F, X, G, H) {
      if (V[F] !== 0) {
        var Z = V._getTransformedDimensions()[G], se = H / Z * V[X];
        V.set(X, se);
      }
    }
    function k(V, F, X, G) {
      var H = F.target, Z = H._getTransformedDimensions(0, H.skewY), se = le(F, F.originX, F.originY, X, G), ye = Math.abs(se.x * 2) - Z.x, pe = H.skewX, K;
      ye < 2 ? K = 0 : (K = b(
        Math.atan2(ye / H.scaleX, Z.y / H.scaleY)
      ), F.originX === l && F.originY === m && (K = -K), F.originX === f && F.originY === c && (K = -K), ne(H) && (K = -K));
      var ge = pe !== K;
      if (ge) {
        var _e = H._getTransformedDimensions().y;
        H.set("skewX", K), C(H, "skewY", "scaleY", "y", _e);
      }
      return ge;
    }
    function P(V, F, X, G) {
      var H = F.target, Z = H._getTransformedDimensions(H.skewX, 0), se = le(F, F.originX, F.originY, X, G), ye = Math.abs(se.y * 2) - Z.y, pe = H.skewY, K;
      ye < 2 ? K = 0 : (K = b(
        Math.atan2(ye / H.scaleY, Z.x / H.scaleX)
      ), F.originX === l && F.originY === m && (K = -K), F.originX === f && F.originY === c && (K = -K), ne(H) && (K = -K));
      var ge = pe !== K;
      if (ge) {
        var _e = H._getTransformedDimensions().x;
        H.set("skewY", K), C(H, "skewX", "scaleX", "x", _e);
      }
      return ge;
    }
    function D(V, F, X, G) {
      var H = F.target, Z = H.skewX, se, ye = F.originY;
      if (H.lockSkewingX)
        return !1;
      if (Z === 0) {
        var pe = le(F, d, d, X, G);
        pe.x > 0 ? se = l : se = f;
      } else
        Z > 0 && (se = ye === c ? l : f), Z < 0 && (se = ye === c ? f : l), ne(H) && (se = se === l ? f : l);
      F.originX = se;
      var K = re("skewing", q(k));
      return K(V, F, X, G);
    }
    function B(V, F, X, G) {
      var H = F.target, Z = H.skewY, se, ye = F.originX;
      if (H.lockSkewingY)
        return !1;
      if (Z === 0) {
        var pe = le(F, d, d, X, G);
        pe.y > 0 ? se = c : se = m;
      } else
        Z > 0 && (se = ye === l ? c : m), Z < 0 && (se = ye === l ? m : c), ne(H) && (se = se === c ? m : c);
      F.originY = se;
      var K = re("skewing", q(P));
      return K(V, F, X, G);
    }
    function M(V, F, X, G) {
      var H = F, Z = H.target, se = Z.translateToOriginPoint(Z.getCenterPoint(), H.originX, H.originY);
      if (Z.lockRotation)
        return !1;
      var ye = Math.atan2(H.ey - se.y, H.ex - se.x), pe = Math.atan2(G - se.y, X - se.x), K = b(pe - ye + H.theta), ge = !0;
      if (Z.snapAngle > 0) {
        var _e = Z.snapAngle, ke = Z.snapThreshold || _e, Re = Math.ceil(K / _e) * _e, Oe = Math.floor(K / _e) * _e;
        Math.abs(K - Oe) < ke ? K = Oe : Math.abs(K - Re) < ke && (K = Re);
      }
      return K < 0 && (K = 360 + K), K %= 360, ge = Z.angle !== K, Z.angle = K, ge;
    }
    function E(V, F, X, G, H) {
      H = H || {};
      var Z = F.target, se = Z.lockScalingX, ye = Z.lockScalingY, pe = H.by, K, ge, _e, ke, Re = S(V, Z), Oe = A(Z, pe, Re), tt, $e, hr = F.gestureScale;
      if (Oe)
        return !1;
      if (hr)
        ge = F.scaleX * hr, _e = F.scaleY * hr;
      else {
        if (K = le(F, F.originX, F.originY, X, G), tt = pe !== "y" ? y(K.x) : 1, $e = pe !== "x" ? y(K.y) : 1, F.signX || (F.signX = tt), F.signY || (F.signY = $e), Z.lockScalingFlip && (F.signX !== tt || F.signY !== $e))
          return !1;
        if (ke = Z._getTransformedDimensions(), Re && !pe) {
          var wi = Math.abs(K.x) + Math.abs(K.y), wt = F.original, Zg = Math.abs(ke.x * wt.scaleX / Z.scaleX) + Math.abs(ke.y * wt.scaleY / Z.scaleY), Xl = wi / Zg;
          ge = wt.scaleX * Xl, _e = wt.scaleY * Xl;
        } else
          ge = Math.abs(K.x * Z.scaleX / ke.x), _e = Math.abs(K.y * Z.scaleY / ke.y);
        T(F) && (ge *= 2, _e *= 2), F.signX !== tt && pe !== "y" && (F.originX = v[F.originX], ge *= -1, F.signX = tt), F.signY !== $e && pe !== "x" && (F.originY = v[F.originY], _e *= -1, F.signY = $e);
      }
      var Jg = Z.scaleX, Qg = Z.scaleY;
      return pe ? (pe === "x" && Z.set("scaleX", ge), pe === "y" && Z.set("scaleY", _e)) : (!se && Z.set("scaleX", ge), !ye && Z.set("scaleY", _e)), Jg !== Z.scaleX || Qg !== Z.scaleY;
    }
    function L(V, F, X, G) {
      return E(V, F, X, G);
    }
    function z(V, F, X, G) {
      return E(V, F, X, G, { by: "x" });
    }
    function Y(V, F, X, G) {
      return E(V, F, X, G, { by: "y" });
    }
    function $(V, F, X, G) {
      return V[F.target.canvas.altActionKey] ? s.skewHandlerX(V, F, X, G) : s.scalingY(V, F, X, G);
    }
    function W(V, F, X, G) {
      return V[F.target.canvas.altActionKey] ? s.skewHandlerY(V, F, X, G) : s.scalingX(V, F, X, G);
    }
    function j(V, F, X, G) {
      var H = F.target, Z = le(F, F.originX, F.originY, X, G), se = H.strokeWidth / (H.strokeUniform ? H.scaleX : 1), ye = T(F) ? 2 : 1, pe = H.width, K = Math.abs(Z.x * ye / H.scaleX) - se;
      return H.set("width", Math.max(K, 0)), pe !== K;
    }
    function te(V, F, X, G) {
      var H = F.target, Z = X - F.offsetX, se = G - F.offsetY, ye = !H.get("lockMovementX") && H.left !== Z, pe = !H.get("lockMovementY") && H.top !== se;
      return ye && H.set("left", Z), pe && H.set("top", se), (ye || pe) && _("moving", J(V, F, X, G)), ye || pe;
    }
    s.scaleCursorStyleHandler = R, s.skewCursorStyleHandler = N, s.scaleSkewCursorStyleHandler = U, s.rotationWithSnapping = re("rotating", q(M)), s.scalingEqually = re("scaling", q(L)), s.scalingX = re("scaling", q(z)), s.scalingY = re("scaling", q(Y)), s.scalingYOrSkewingX = $, s.scalingXOrSkewingY = W, s.changeWidth = re("resizing", q(j)), s.skewHandlerX = D, s.skewHandlerY = B, s.dragHandler = te, s.scaleOrSkewActionName = Q, s.rotationStyleHandler = ee, s.fireEvent = _, s.wrapWithFixedAnchor = q, s.wrapWithFireEvent = re, s.getLocalPoint = le, n.controlsUtils = s;
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.util.degreesToRadians, h = n.controlsUtils;
    function s(c, f, m, d, v) {
      d = d || {};
      var b = this.sizeX || d.cornerSize || v.cornerSize, y = this.sizeY || d.cornerSize || v.cornerSize, w = typeof d.transparentCorners < "u" ? d.transparentCorners : v.transparentCorners, _ = w ? "stroke" : "fill", S = !w && (d.cornerStrokeColor || v.cornerStrokeColor), T = f, A = m, R;
      c.save(), c.fillStyle = d.cornerColor || v.cornerColor, c.strokeStyle = d.cornerStrokeColor || v.cornerStrokeColor, b > y ? (R = b, c.scale(1, y / b), A = m * b / y) : y > b ? (R = y, c.scale(b / y, 1), T = f * y / b) : R = b, c.lineWidth = 1, c.beginPath(), c.arc(T, A, R / 2, 0, 2 * Math.PI, !1), c[_](), S && c.stroke(), c.restore();
    }
    function l(c, f, m, d, v) {
      d = d || {};
      var b = this.sizeX || d.cornerSize || v.cornerSize, y = this.sizeY || d.cornerSize || v.cornerSize, w = typeof d.transparentCorners < "u" ? d.transparentCorners : v.transparentCorners, _ = w ? "stroke" : "fill", S = !w && (d.cornerStrokeColor || v.cornerStrokeColor), T = b / 2, A = y / 2;
      c.save(), c.fillStyle = d.cornerColor || v.cornerColor, c.strokeStyle = d.cornerStrokeColor || v.cornerStrokeColor, c.lineWidth = 1, c.translate(f, m), c.rotate(u(v.angle)), c[_ + "Rect"](-T, -A, b, y), S && c.strokeRect(-T, -A, b, y), c.restore();
    }
    h.renderCircleControl = s, h.renderSquareControl = l;
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {});
    function u(h) {
      for (var s in h)
        this[s] = h[s];
    }
    n.Control = u, n.Control.prototype = {
      visible: !0,
      actionName: "scale",
      angle: 0,
      x: 0,
      y: 0,
      offsetX: 0,
      offsetY: 0,
      sizeX: null,
      sizeY: null,
      touchSizeX: null,
      touchSizeY: null,
      cursorStyle: "crosshair",
      withConnection: !1,
      actionHandler: function() {
      },
      mouseDownHandler: function() {
      },
      mouseUpHandler: function() {
      },
      getActionHandler: function() {
        return this.actionHandler;
      },
      getMouseDownHandler: function() {
        return this.mouseDownHandler;
      },
      getMouseUpHandler: function() {
        return this.mouseUpHandler;
      },
      cursorStyleHandler: function(h, s) {
        return s.cursorStyle;
      },
      getActionName: function(h, s) {
        return s.actionName;
      },
      getVisibility: function(h, s) {
        var l = h._controlsVisibility;
        return l && typeof l[s] < "u" ? l[s] : this.visible;
      },
      setVisibility: function(h) {
        this.visible = h;
      },
      positionHandler: function(h, s) {
        var l = n.util.transformPoint({
          x: this.x * h.x + this.offsetX,
          y: this.y * h.y + this.offsetY
        }, s);
        return l;
      },
      calcCornerCoords: function(h, s, l, c, f) {
        var m, d, v, b, y = f ? this.touchSizeX : this.sizeX, w = f ? this.touchSizeY : this.sizeY;
        if (y && w && y !== w) {
          var _ = Math.atan2(w, y), S = Math.sqrt(y * y + w * w) / 2, T = _ - n.util.degreesToRadians(h), A = Math.PI / 2 - _ - n.util.degreesToRadians(h);
          m = S * n.util.cos(T), d = S * n.util.sin(T), v = S * n.util.cos(A), b = S * n.util.sin(A);
        } else {
          var R = y && w ? y : s;
          S = R * 0.7071067812;
          var T = n.util.degreesToRadians(45 - h);
          m = v = S * n.util.cos(T), d = b = S * n.util.sin(T);
        }
        return {
          tl: {
            x: l - b,
            y: c - v
          },
          tr: {
            x: l + m,
            y: c - d
          },
          bl: {
            x: l - m,
            y: c + d
          },
          br: {
            x: l + b,
            y: c + v
          }
        };
      },
      render: function(h, s, l, c, f) {
        switch (c = c || {}, c.cornerStyle || f.cornerStyle) {
          case "circle":
            n.controlsUtils.renderCircleControl.call(this, h, s, l, c, f);
            break;
          default:
            n.controlsUtils.renderSquareControl.call(this, h, s, l, c, f);
        }
      }
    };
  }(t), function() {
    function a(l, c) {
      var f = l.getAttribute("style"), m = l.getAttribute("offset") || 0, d, v, b, y;
      if (m = parseFloat(m) / (/%$/.test(m) ? 100 : 1), m = m < 0 ? 0 : m > 1 ? 1 : m, f) {
        var w = f.split(/\s*;\s*/);
        for (w[w.length - 1] === "" && w.pop(), y = w.length; y--; ) {
          var _ = w[y].split(/\s*:\s*/), S = _[0].trim(), T = _[1].trim();
          S === "stop-color" ? d = T : S === "stop-opacity" && (b = T);
        }
      }
      return d || (d = l.getAttribute("stop-color") || "rgb(0,0,0)"), b || (b = l.getAttribute("stop-opacity")), d = new e.Color(d), v = d.getAlpha(), b = isNaN(parseFloat(b)) ? 1 : parseFloat(b), b *= v * c, {
        offset: m,
        color: d.toRgb(),
        opacity: b
      };
    }
    function n(l) {
      return {
        x1: l.getAttribute("x1") || 0,
        y1: l.getAttribute("y1") || 0,
        x2: l.getAttribute("x2") || "100%",
        y2: l.getAttribute("y2") || 0
      };
    }
    function u(l) {
      return {
        x1: l.getAttribute("fx") || l.getAttribute("cx") || "50%",
        y1: l.getAttribute("fy") || l.getAttribute("cy") || "50%",
        r1: 0,
        x2: l.getAttribute("cx") || "50%",
        y2: l.getAttribute("cy") || "50%",
        r2: l.getAttribute("r") || "50%"
      };
    }
    var h = e.util.object.clone;
    e.Gradient = e.util.createClass({
      offsetX: 0,
      offsetY: 0,
      gradientTransform: null,
      gradientUnits: "pixels",
      type: "linear",
      initialize: function(l) {
        l || (l = {}), l.coords || (l.coords = {});
        var c, f = this;
        Object.keys(l).forEach(function(m) {
          f[m] = l[m];
        }), this.id ? this.id += "_" + e.Object.__uid++ : this.id = e.Object.__uid++, c = {
          x1: l.coords.x1 || 0,
          y1: l.coords.y1 || 0,
          x2: l.coords.x2 || 0,
          y2: l.coords.y2 || 0
        }, this.type === "radial" && (c.r1 = l.coords.r1 || 0, c.r2 = l.coords.r2 || 0), this.coords = c, this.colorStops = l.colorStops.slice();
      },
      addColorStop: function(l) {
        for (var c in l) {
          var f = new e.Color(l[c]);
          this.colorStops.push({
            offset: parseFloat(c),
            color: f.toRgb(),
            opacity: f.getAlpha()
          });
        }
        return this;
      },
      toObject: function(l) {
        var c = {
          type: this.type,
          coords: this.coords,
          colorStops: this.colorStops,
          offsetX: this.offsetX,
          offsetY: this.offsetY,
          gradientUnits: this.gradientUnits,
          gradientTransform: this.gradientTransform ? this.gradientTransform.concat() : this.gradientTransform
        };
        return e.util.populateWithProperties(this, c, l), c;
      },
      toSVG: function(l, v) {
        var f = h(this.coords, !0), m, d, v = v || {}, b, y, w = h(this.colorStops, !0), _ = f.r1 > f.r2, S = this.gradientTransform ? this.gradientTransform.concat() : e.iMatrix.concat(), T = -this.offsetX, A = -this.offsetY, R = !!v.additionalTransform, N = this.gradientUnits === "pixels" ? "userSpaceOnUse" : "objectBoundingBox";
        if (w.sort(function(q, re) {
          return q.offset - re.offset;
        }), N === "objectBoundingBox" ? (T /= l.width, A /= l.height) : (T += l.width / 2, A += l.height / 2), l.type === "path" && this.gradientUnits !== "percentage" && (T -= l.pathOffset.x, A -= l.pathOffset.y), S[4] -= T, S[5] -= A, y = 'id="SVGID_' + this.id + '" gradientUnits="' + N + '"', y += ' gradientTransform="' + (R ? v.additionalTransform + " " : "") + e.util.matrixToSVG(S) + '" ', this.type === "linear" ? b = [
          "<linearGradient ",
          y,
          ' x1="',
          f.x1,
          '" y1="',
          f.y1,
          '" x2="',
          f.x2,
          '" y2="',
          f.y2,
          `">
`
        ] : this.type === "radial" && (b = [
          "<radialGradient ",
          y,
          ' cx="',
          _ ? f.x1 : f.x2,
          '" cy="',
          _ ? f.y1 : f.y2,
          '" r="',
          _ ? f.r1 : f.r2,
          '" fx="',
          _ ? f.x2 : f.x1,
          '" fy="',
          _ ? f.y2 : f.y1,
          `">
`
        ]), this.type === "radial") {
          if (_)
            for (w = w.concat(), w.reverse(), m = 0, d = w.length; m < d; m++)
              w[m].offset = 1 - w[m].offset;
          var U = Math.min(f.r1, f.r2);
          if (U > 0) {
            var Q = Math.max(f.r1, f.r2), ee = U / Q;
            for (m = 0, d = w.length; m < d; m++)
              w[m].offset += ee * (1 - w[m].offset);
          }
        }
        for (m = 0, d = w.length; m < d; m++) {
          var J = w[m];
          b.push(
            "<stop ",
            'offset="',
            J.offset * 100 + "%",
            '" style="stop-color:',
            J.color,
            typeof J.opacity < "u" ? ";stop-opacity: " + J.opacity : ";",
            `"/>
`
          );
        }
        return b.push(this.type === "linear" ? `</linearGradient>
` : `</radialGradient>
`), b.join("");
      },
      toLive: function(l) {
        var c, f = e.util.object.clone(this.coords), m, d;
        if (!!this.type) {
          for (this.type === "linear" ? c = l.createLinearGradient(
            f.x1,
            f.y1,
            f.x2,
            f.y2
          ) : this.type === "radial" && (c = l.createRadialGradient(
            f.x1,
            f.y1,
            f.r1,
            f.x2,
            f.y2,
            f.r2
          )), m = 0, d = this.colorStops.length; m < d; m++) {
            var v = this.colorStops[m].color, b = this.colorStops[m].opacity, y = this.colorStops[m].offset;
            typeof b < "u" && (v = new e.Color(v).setAlpha(b).toRgba()), c.addColorStop(y, v);
          }
          return c;
        }
      }
    }), e.util.object.extend(e.Gradient, {
      fromElement: function(l, c, f, m) {
        var d = parseFloat(f) / (/%$/.test(f) ? 100 : 1);
        d = d < 0 ? 0 : d > 1 ? 1 : d, isNaN(d) && (d = 1);
        var v = l.getElementsByTagName("stop"), b, y = l.getAttribute("gradientUnits") === "userSpaceOnUse" ? "pixels" : "percentage", w = l.getAttribute("gradientTransform") || "", _ = [], S, T, A = 0, R = 0, N;
        for (l.nodeName === "linearGradient" || l.nodeName === "LINEARGRADIENT" ? (b = "linear", S = n(l)) : (b = "radial", S = u(l)), T = v.length; T--; )
          _.push(a(v[T], d));
        N = e.parseTransformAttribute(w), s(c, S, m, y), y === "pixels" && (A = -c.left, R = -c.top);
        var U = new e.Gradient({
          id: l.getAttribute("id"),
          type: b,
          coords: S,
          colorStops: _,
          gradientUnits: y,
          gradientTransform: N,
          offsetX: A,
          offsetY: R
        });
        return U;
      }
    });
    function s(l, c, f, m) {
      var d, v;
      Object.keys(c).forEach(function(b) {
        d = c[b], d === "Infinity" ? v = 1 : d === "-Infinity" ? v = 0 : (v = parseFloat(c[b], 10), typeof d == "string" && /^(\d+\.\d+)%|(\d+)%$/.test(d) && (v *= 0.01, m === "pixels" && ((b === "x1" || b === "x2" || b === "r2") && (v *= f.viewBoxWidth || f.width), (b === "y1" || b === "y2") && (v *= f.viewBoxHeight || f.height)))), c[b] = v;
      });
    }
  }(), function() {
    var a = e.util.toFixed;
    e.Pattern = e.util.createClass({
      repeat: "repeat",
      offsetX: 0,
      offsetY: 0,
      crossOrigin: "",
      patternTransform: null,
      initialize: function(n, u) {
        if (n || (n = {}), this.id = e.Object.__uid++, this.setOptions(n), !n.source || n.source && typeof n.source != "string") {
          u && u(this);
          return;
        } else {
          var h = this;
          this.source = e.util.createImage(), e.util.loadImage(n.source, function(s, l) {
            h.source = s, u && u(h, l);
          }, null, this.crossOrigin);
        }
      },
      toObject: function(n) {
        var u = e.Object.NUM_FRACTION_DIGITS, h, s;
        return typeof this.source.src == "string" ? h = this.source.src : typeof this.source == "object" && this.source.toDataURL && (h = this.source.toDataURL()), s = {
          type: "pattern",
          source: h,
          repeat: this.repeat,
          crossOrigin: this.crossOrigin,
          offsetX: a(this.offsetX, u),
          offsetY: a(this.offsetY, u),
          patternTransform: this.patternTransform ? this.patternTransform.concat() : null
        }, e.util.populateWithProperties(this, s, n), s;
      },
      toSVG: function(n) {
        var u = typeof this.source == "function" ? this.source() : this.source, h = u.width / n.width, s = u.height / n.height, l = this.offsetX / n.width, c = this.offsetY / n.height, f = "";
        return (this.repeat === "repeat-x" || this.repeat === "no-repeat") && (s = 1, c && (s += Math.abs(c))), (this.repeat === "repeat-y" || this.repeat === "no-repeat") && (h = 1, l && (h += Math.abs(l))), u.src ? f = u.src : u.toDataURL && (f = u.toDataURL()), '<pattern id="SVGID_' + this.id + '" x="' + l + '" y="' + c + '" width="' + h + '" height="' + s + `">
<image x="0" y="0" width="` + u.width + '" height="' + u.height + '" xlink:href="' + f + `"></image>
</pattern>
`;
      },
      setOptions: function(n) {
        for (var u in n)
          this[u] = n[u];
      },
      toLive: function(n) {
        var u = this.source;
        return !u || typeof u.src < "u" && (!u.complete || u.naturalWidth === 0 || u.naturalHeight === 0) ? "" : n.createPattern(u, this.repeat);
      }
    });
  }(), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.util.toFixed;
    if (n.Shadow) {
      n.warn("fabric.Shadow is already defined.");
      return;
    }
    n.Shadow = n.util.createClass({
      color: "rgb(0,0,0)",
      blur: 0,
      offsetX: 0,
      offsetY: 0,
      affectStroke: !1,
      includeDefaultValues: !0,
      nonScaling: !1,
      initialize: function(h) {
        typeof h == "string" && (h = this._parseShadow(h));
        for (var s in h)
          this[s] = h[s];
        this.id = n.Object.__uid++;
      },
      _parseShadow: function(h) {
        var s = h.trim(), l = n.Shadow.reOffsetsAndBlur.exec(s) || [], c = s.replace(n.Shadow.reOffsetsAndBlur, "") || "rgb(0,0,0)";
        return {
          color: c.trim(),
          offsetX: parseFloat(l[1], 10) || 0,
          offsetY: parseFloat(l[2], 10) || 0,
          blur: parseFloat(l[3], 10) || 0
        };
      },
      toString: function() {
        return [this.offsetX, this.offsetY, this.blur, this.color].join("px ");
      },
      toSVG: function(h) {
        var s = 40, l = 40, c = n.Object.NUM_FRACTION_DIGITS, f = n.util.rotateVector(
          { x: this.offsetX, y: this.offsetY },
          n.util.degreesToRadians(-h.angle)
        ), m = 20, d = new n.Color(this.color);
        return h.width && h.height && (s = u((Math.abs(f.x) + this.blur) / h.width, c) * 100 + m, l = u((Math.abs(f.y) + this.blur) / h.height, c) * 100 + m), h.flipX && (f.x *= -1), h.flipY && (f.y *= -1), '<filter id="SVGID_' + this.id + '" y="-' + l + '%" height="' + (100 + 2 * l) + '%" x="-' + s + '%" width="' + (100 + 2 * s) + `%" >
	<feGaussianBlur in="SourceAlpha" stdDeviation="` + u(this.blur ? this.blur / 2 : 0, c) + `"></feGaussianBlur>
	<feOffset dx="` + u(f.x, c) + '" dy="' + u(f.y, c) + `" result="oBlur" ></feOffset>
	<feFlood flood-color="` + d.toRgb() + '" flood-opacity="' + d.getAlpha() + `"/>
	<feComposite in2="oBlur" operator="in" />
	<feMerge>
		<feMergeNode></feMergeNode>
		<feMergeNode in="SourceGraphic"></feMergeNode>
	</feMerge>
</filter>
`;
      },
      toObject: function() {
        if (this.includeDefaultValues)
          return {
            color: this.color,
            blur: this.blur,
            offsetX: this.offsetX,
            offsetY: this.offsetY,
            affectStroke: this.affectStroke,
            nonScaling: this.nonScaling
          };
        var h = {}, s = n.Shadow.prototype;
        return ["color", "blur", "offsetX", "offsetY", "affectStroke", "nonScaling"].forEach(function(l) {
          this[l] !== s[l] && (h[l] = this[l]);
        }, this), h;
      }
    }), n.Shadow.reOffsetsAndBlur = /(?:\s|^)(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(\d+(?:\.\d*)?(?:px)?)?(?:\s?|$)(?:$|\s)/;
  }(t), function() {
    if (e.StaticCanvas) {
      e.warn("fabric.StaticCanvas is already defined.");
      return;
    }
    var a = e.util.object.extend, n = e.util.getElementOffset, u = e.util.removeFromArray, h = e.util.toFixed, s = e.util.transformPoint, l = e.util.invertTransform, c = e.util.getNodeCanvas, f = e.util.createCanvasElement, m = new Error("Could not initialize `canvas` element");
    e.StaticCanvas = e.util.createClass(e.CommonMethods, {
      initialize: function(d, v) {
        v || (v = {}), this.renderAndResetBound = this.renderAndReset.bind(this), this.requestRenderAllBound = this.requestRenderAll.bind(this), this._initStatic(d, v);
      },
      backgroundColor: "",
      backgroundImage: null,
      overlayColor: "",
      overlayImage: null,
      includeDefaultValues: !0,
      stateful: !1,
      renderOnAddRemove: !0,
      controlsAboveOverlay: !1,
      allowTouchScrolling: !1,
      imageSmoothingEnabled: !0,
      viewportTransform: e.iMatrix.concat(),
      backgroundVpt: !0,
      overlayVpt: !0,
      enableRetinaScaling: !0,
      vptCoords: {},
      skipOffscreen: !0,
      clipPath: void 0,
      _initStatic: function(d, v) {
        var b = this.requestRenderAllBound;
        this._objects = [], this._createLowerCanvas(d), this._initOptions(v), this.interactive || this._initRetinaScaling(), v.overlayImage && this.setOverlayImage(v.overlayImage, b), v.backgroundImage && this.setBackgroundImage(v.backgroundImage, b), v.backgroundColor && this.setBackgroundColor(v.backgroundColor, b), v.overlayColor && this.setOverlayColor(v.overlayColor, b), this.calcOffset();
      },
      _isRetinaScaling: function() {
        return e.devicePixelRatio > 1 && this.enableRetinaScaling;
      },
      getRetinaScaling: function() {
        return this._isRetinaScaling() ? Math.max(1, e.devicePixelRatio) : 1;
      },
      _initRetinaScaling: function() {
        if (!!this._isRetinaScaling()) {
          var d = e.devicePixelRatio;
          this.__initRetinaScaling(d, this.lowerCanvasEl, this.contextContainer), this.upperCanvasEl && this.__initRetinaScaling(d, this.upperCanvasEl, this.contextTop);
        }
      },
      __initRetinaScaling: function(d, v, b) {
        v.setAttribute("width", this.width * d), v.setAttribute("height", this.height * d), b.scale(d, d);
      },
      calcOffset: function() {
        return this._offset = n(this.lowerCanvasEl), this;
      },
      setOverlayImage: function(d, v, b) {
        return this.__setBgOverlayImage("overlayImage", d, v, b);
      },
      setBackgroundImage: function(d, v, b) {
        return this.__setBgOverlayImage("backgroundImage", d, v, b);
      },
      setOverlayColor: function(d, v) {
        return this.__setBgOverlayColor("overlayColor", d, v);
      },
      setBackgroundColor: function(d, v) {
        return this.__setBgOverlayColor("backgroundColor", d, v);
      },
      __setBgOverlayImage: function(d, v, b, y) {
        return typeof v == "string" ? e.util.loadImage(v, function(w, _) {
          if (w) {
            var S = new e.Image(w, y);
            this[d] = S, S.canvas = this;
          }
          b && b(w, _);
        }, this, y && y.crossOrigin) : (y && v.setOptions(y), this[d] = v, v && (v.canvas = this), b && b(v, !1)), this;
      },
      __setBgOverlayColor: function(d, v, b) {
        return this[d] = v, this._initGradient(v, d), this._initPattern(v, d, b), this;
      },
      _createCanvasElement: function() {
        var d = f();
        if (!d || (d.style || (d.style = {}), typeof d.getContext > "u"))
          throw m;
        return d;
      },
      _initOptions: function(d) {
        var v = this.lowerCanvasEl;
        this._setOptions(d), this.width = this.width || parseInt(v.width, 10) || 0, this.height = this.height || parseInt(v.height, 10) || 0, this.lowerCanvasEl.style && (v.width = this.width, v.height = this.height, v.style.width = this.width + "px", v.style.height = this.height + "px", this.viewportTransform = this.viewportTransform.slice());
      },
      _createLowerCanvas: function(d) {
        d && d.getContext ? this.lowerCanvasEl = d : this.lowerCanvasEl = e.util.getById(d) || this._createCanvasElement(), e.util.addClass(this.lowerCanvasEl, "lower-canvas"), this._originalCanvasStyle = this.lowerCanvasEl.style, this.interactive && this._applyCanvasStyle(this.lowerCanvasEl), this.contextContainer = this.lowerCanvasEl.getContext("2d");
      },
      getWidth: function() {
        return this.width;
      },
      getHeight: function() {
        return this.height;
      },
      setWidth: function(d, v) {
        return this.setDimensions({ width: d }, v);
      },
      setHeight: function(d, v) {
        return this.setDimensions({ height: d }, v);
      },
      setDimensions: function(d, v) {
        var b;
        v = v || {};
        for (var y in d)
          b = d[y], v.cssOnly || (this._setBackstoreDimension(y, d[y]), b += "px", this.hasLostContext = !0), v.backstoreOnly || this._setCssDimension(y, b);
        return this._isCurrentlyDrawing && this.freeDrawingBrush && this.freeDrawingBrush._setBrushStyles(this.contextTop), this._initRetinaScaling(), this.calcOffset(), v.cssOnly || this.requestRenderAll(), this;
      },
      _setBackstoreDimension: function(d, v) {
        return this.lowerCanvasEl[d] = v, this.upperCanvasEl && (this.upperCanvasEl[d] = v), this.cacheCanvasEl && (this.cacheCanvasEl[d] = v), this[d] = v, this;
      },
      _setCssDimension: function(d, v) {
        return this.lowerCanvasEl.style[d] = v, this.upperCanvasEl && (this.upperCanvasEl.style[d] = v), this.wrapperEl && (this.wrapperEl.style[d] = v), this;
      },
      getZoom: function() {
        return this.viewportTransform[0];
      },
      setViewportTransform: function(d) {
        var v = this._activeObject, b = this.backgroundImage, y = this.overlayImage, w, _, S;
        for (this.viewportTransform = d, _ = 0, S = this._objects.length; _ < S; _++)
          w = this._objects[_], w.group || w.setCoords(!0);
        return v && v.setCoords(), b && b.setCoords(!0), y && y.setCoords(!0), this.calcViewportBoundaries(), this.renderOnAddRemove && this.requestRenderAll(), this;
      },
      zoomToPoint: function(d, v) {
        var b = d, y = this.viewportTransform.slice(0);
        d = s(d, l(this.viewportTransform)), y[0] = v, y[3] = v;
        var w = s(d, y);
        return y[4] += b.x - w.x, y[5] += b.y - w.y, this.setViewportTransform(y);
      },
      setZoom: function(d) {
        return this.zoomToPoint(new e.Point(0, 0), d), this;
      },
      absolutePan: function(d) {
        var v = this.viewportTransform.slice(0);
        return v[4] = -d.x, v[5] = -d.y, this.setViewportTransform(v);
      },
      relativePan: function(d) {
        return this.absolutePan(new e.Point(
          -d.x - this.viewportTransform[4],
          -d.y - this.viewportTransform[5]
        ));
      },
      getElement: function() {
        return this.lowerCanvasEl;
      },
      _onObjectAdded: function(d) {
        this.stateful && d.setupState(), d._set("canvas", this), d.setCoords(), this.fire("object:added", { target: d }), d.fire("added");
      },
      _onObjectRemoved: function(d) {
        this.fire("object:removed", { target: d }), d.fire("removed"), delete d.canvas;
      },
      clearContext: function(d) {
        return d.clearRect(0, 0, this.width, this.height), this;
      },
      getContext: function() {
        return this.contextContainer;
      },
      clear: function() {
        return this.remove.apply(this, this.getObjects()), this.backgroundImage = null, this.overlayImage = null, this.backgroundColor = "", this.overlayColor = "", this._hasITextHandlers && (this.off("mouse:up", this._mouseUpITextHandler), this._iTextInstances = null, this._hasITextHandlers = !1), this.clearContext(this.contextContainer), this.fire("canvas:cleared"), this.renderOnAddRemove && this.requestRenderAll(), this;
      },
      renderAll: function() {
        var d = this.contextContainer;
        return this.renderCanvas(d, this._objects), this;
      },
      renderAndReset: function() {
        this.isRendering = 0, this.renderAll();
      },
      requestRenderAll: function() {
        return this.isRendering || (this.isRendering = e.util.requestAnimFrame(this.renderAndResetBound)), this;
      },
      calcViewportBoundaries: function() {
        var d = {}, v = this.width, b = this.height, y = l(this.viewportTransform);
        return d.tl = s({ x: 0, y: 0 }, y), d.br = s({ x: v, y: b }, y), d.tr = new e.Point(d.br.x, d.tl.y), d.bl = new e.Point(d.tl.x, d.br.y), this.vptCoords = d, d;
      },
      cancelRequestedRender: function() {
        this.isRendering && (e.util.cancelAnimFrame(this.isRendering), this.isRendering = 0);
      },
      renderCanvas: function(d, v) {
        var b = this.viewportTransform, y = this.clipPath;
        this.cancelRequestedRender(), this.calcViewportBoundaries(), this.clearContext(d), e.util.setImageSmoothing(d, this.imageSmoothingEnabled), this.fire("before:render", { ctx: d }), this._renderBackground(d), d.save(), d.transform(b[0], b[1], b[2], b[3], b[4], b[5]), this._renderObjects(d, v), d.restore(), !this.controlsAboveOverlay && this.interactive && this.drawControls(d), y && (y.canvas = this, y.shouldCache(), y._transformDone = !0, y.renderCache({ forClipping: !0 }), this.drawClipPathOnCanvas(d)), this._renderOverlay(d), this.controlsAboveOverlay && this.interactive && this.drawControls(d), this.fire("after:render", { ctx: d });
      },
      drawClipPathOnCanvas: function(d) {
        var v = this.viewportTransform, b = this.clipPath;
        d.save(), d.transform(v[0], v[1], v[2], v[3], v[4], v[5]), d.globalCompositeOperation = "destination-in", b.transform(d), d.scale(1 / b.zoomX, 1 / b.zoomY), d.drawImage(b._cacheCanvas, -b.cacheTranslationX, -b.cacheTranslationY), d.restore();
      },
      _renderObjects: function(d, v) {
        var b, y;
        for (b = 0, y = v.length; b < y; ++b)
          v[b] && v[b].render(d);
      },
      _renderBackgroundOrOverlay: function(d, v) {
        var b = this[v + "Color"], y = this[v + "Image"], w = this.viewportTransform, _ = this[v + "Vpt"];
        if (!(!b && !y)) {
          if (b) {
            d.save(), d.beginPath(), d.moveTo(0, 0), d.lineTo(this.width, 0), d.lineTo(this.width, this.height), d.lineTo(0, this.height), d.closePath(), d.fillStyle = b.toLive ? b.toLive(d, this) : b, _ && d.transform(w[0], w[1], w[2], w[3], w[4], w[5]), d.transform(1, 0, 0, 1, b.offsetX || 0, b.offsetY || 0);
            var S = b.gradientTransform || b.patternTransform;
            S && d.transform(S[0], S[1], S[2], S[3], S[4], S[5]), d.fill(), d.restore();
          }
          y && (d.save(), _ && d.transform(w[0], w[1], w[2], w[3], w[4], w[5]), y.render(d), d.restore());
        }
      },
      _renderBackground: function(d) {
        this._renderBackgroundOrOverlay(d, "background");
      },
      _renderOverlay: function(d) {
        this._renderBackgroundOrOverlay(d, "overlay");
      },
      getCenter: function() {
        return {
          top: this.height / 2,
          left: this.width / 2
        };
      },
      getCenterPoint: function() {
        return new e.Point(this.width / 2, this.height / 2);
      },
      centerObjectH: function(d) {
        return this._centerObject(d, new e.Point(this.getCenterPoint().x, d.getCenterPoint().y));
      },
      centerObjectV: function(d) {
        return this._centerObject(d, new e.Point(d.getCenterPoint().x, this.getCenterPoint().y));
      },
      centerObject: function(d) {
        var v = this.getCenterPoint();
        return this._centerObject(d, v);
      },
      viewportCenterObject: function(d) {
        var v = this.getVpCenter();
        return this._centerObject(d, v);
      },
      viewportCenterObjectH: function(d) {
        var v = this.getVpCenter();
        return this._centerObject(d, new e.Point(v.x, d.getCenterPoint().y)), this;
      },
      viewportCenterObjectV: function(d) {
        var v = this.getVpCenter();
        return this._centerObject(d, new e.Point(d.getCenterPoint().x, v.y));
      },
      getVpCenter: function() {
        var d = this.getCenterPoint(), v = l(this.viewportTransform);
        return s(d, v);
      },
      _centerObject: function(d, v) {
        return d.setPositionByOrigin(v, "center", "center"), d.setCoords(), this.renderOnAddRemove && this.requestRenderAll(), this;
      },
      toDatalessJSON: function(d) {
        return this.toDatalessObject(d);
      },
      toObject: function(d) {
        return this._toObjectMethod("toObject", d);
      },
      toDatalessObject: function(d) {
        return this._toObjectMethod("toDatalessObject", d);
      },
      _toObjectMethod: function(d, v) {
        var b = this.clipPath, y = {
          version: e.version,
          objects: this._toObjects(d, v)
        };
        return b && !b.excludeFromExport && (y.clipPath = this._toObject(this.clipPath, d, v)), a(y, this.__serializeBgOverlay(d, v)), e.util.populateWithProperties(this, y, v), y;
      },
      _toObjects: function(d, v) {
        return this._objects.filter(function(b) {
          return !b.excludeFromExport;
        }).map(function(b) {
          return this._toObject(b, d, v);
        }, this);
      },
      _toObject: function(d, v, b) {
        var y;
        this.includeDefaultValues || (y = d.includeDefaultValues, d.includeDefaultValues = !1);
        var w = d[v](b);
        return this.includeDefaultValues || (d.includeDefaultValues = y), w;
      },
      __serializeBgOverlay: function(d, v) {
        var b = {}, y = this.backgroundImage, w = this.overlayImage, _ = this.backgroundColor, S = this.overlayColor;
        return _ && _.toObject ? _.excludeFromExport || (b.background = _.toObject(v)) : _ && (b.background = _), S && S.toObject ? S.excludeFromExport || (b.overlay = S.toObject(v)) : S && (b.overlay = S), y && !y.excludeFromExport && (b.backgroundImage = this._toObject(y, d, v)), w && !w.excludeFromExport && (b.overlayImage = this._toObject(w, d, v)), b;
      },
      svgViewportTransformation: !0,
      toSVG: function(d, v) {
        d || (d = {}), d.reviver = v;
        var b = [];
        return this._setSVGPreamble(b, d), this._setSVGHeader(b, d), this.clipPath && b.push('<g clip-path="url(#' + this.clipPath.clipPathId + `)" >
`), this._setSVGBgOverlayColor(b, "background"), this._setSVGBgOverlayImage(b, "backgroundImage", v), this._setSVGObjects(b, v), this.clipPath && b.push(`</g>
`), this._setSVGBgOverlayColor(b, "overlay"), this._setSVGBgOverlayImage(b, "overlayImage", v), b.push("</svg>"), b.join("");
      },
      _setSVGPreamble: function(d, v) {
        v.suppressPreamble || d.push(
          '<?xml version="1.0" encoding="',
          v.encoding || "UTF-8",
          `" standalone="no" ?>
`,
          '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ',
          `"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
`
        );
      },
      _setSVGHeader: function(d, v) {
        var b = v.width || this.width, y = v.height || this.height, w, _ = 'viewBox="0 0 ' + this.width + " " + this.height + '" ', S = e.Object.NUM_FRACTION_DIGITS;
        v.viewBox ? _ = 'viewBox="' + v.viewBox.x + " " + v.viewBox.y + " " + v.viewBox.width + " " + v.viewBox.height + '" ' : this.svgViewportTransformation && (w = this.viewportTransform, _ = 'viewBox="' + h(-w[4] / w[0], S) + " " + h(-w[5] / w[3], S) + " " + h(this.width / w[0], S) + " " + h(this.height / w[3], S) + '" '), d.push(
          "<svg ",
          'xmlns="http://www.w3.org/2000/svg" ',
          'xmlns:xlink="http://www.w3.org/1999/xlink" ',
          'version="1.1" ',
          'width="',
          b,
          '" ',
          'height="',
          y,
          '" ',
          _,
          `xml:space="preserve">
`,
          "<desc>Created with Fabric.js ",
          e.version,
          `</desc>
`,
          `<defs>
`,
          this.createSVGFontFacesMarkup(),
          this.createSVGRefElementsMarkup(),
          this.createSVGClipPathMarkup(v),
          `</defs>
`
        );
      },
      createSVGClipPathMarkup: function(d) {
        var v = this.clipPath;
        return v ? (v.clipPathId = "CLIPPATH_" + e.Object.__uid++, '<clipPath id="' + v.clipPathId + `" >
` + this.clipPath.toClipPathSVG(d.reviver) + `</clipPath>
`) : "";
      },
      createSVGRefElementsMarkup: function() {
        var d = this, v = ["background", "overlay"].map(function(b) {
          var y = d[b + "Color"];
          if (y && y.toLive) {
            var w = d[b + "Vpt"], _ = d.viewportTransform, S = {
              width: d.width / (w ? _[0] : 1),
              height: d.height / (w ? _[3] : 1)
            };
            return y.toSVG(
              S,
              { additionalTransform: w ? e.util.matrixToSVG(_) : "" }
            );
          }
        });
        return v.join("");
      },
      createSVGFontFacesMarkup: function() {
        var d = "", v = {}, b, y, w, _, S, T, A, R, N, U = e.fontPaths, Q = [];
        for (this._objects.forEach(function J(q) {
          Q.push(q), q._objects && q._objects.forEach(J);
        }), R = 0, N = Q.length; R < N; R++)
          if (b = Q[R], y = b.fontFamily, !(b.type.indexOf("text") === -1 || v[y] || !U[y]) && (v[y] = !0, !!b.styles)) {
            w = b.styles;
            for (S in w) {
              _ = w[S];
              for (A in _)
                T = _[A], y = T.fontFamily, !v[y] && U[y] && (v[y] = !0);
            }
          }
        for (var ee in v)
          d += [
            `		@font-face {
`,
            "			font-family: '",
            ee,
            `';
`,
            "			src: url('",
            U[ee],
            `');
`,
            `		}
`
          ].join("");
        return d && (d = [
          '	<style type="text/css">',
          `<![CDATA[
`,
          d,
          "]]>",
          `</style>
`
        ].join("")), d;
      },
      _setSVGObjects: function(d, v) {
        var b, y, w, _ = this._objects;
        for (y = 0, w = _.length; y < w; y++)
          b = _[y], !b.excludeFromExport && this._setSVGObject(d, b, v);
      },
      _setSVGObject: function(d, v, b) {
        d.push(v.toSVG(b));
      },
      _setSVGBgOverlayImage: function(d, v, b) {
        this[v] && !this[v].excludeFromExport && this[v].toSVG && d.push(this[v].toSVG(b));
      },
      _setSVGBgOverlayColor: function(d, v) {
        var b = this[v + "Color"], y = this.viewportTransform, w = this.width, _ = this.height;
        if (!!b)
          if (b.toLive) {
            var S = b.repeat, T = e.util.invertTransform(y), A = this[v + "Vpt"], R = A ? e.util.matrixToSVG(T) : "";
            d.push(
              '<rect transform="' + R + " translate(",
              w / 2,
              ",",
              _ / 2,
              ')"',
              ' x="',
              b.offsetX - w / 2,
              '" y="',
              b.offsetY - _ / 2,
              '" ',
              'width="',
              S === "repeat-y" || S === "no-repeat" ? b.source.width : w,
              '" height="',
              S === "repeat-x" || S === "no-repeat" ? b.source.height : _,
              '" fill="url(#SVGID_' + b.id + ')"',
              `></rect>
`
            );
          } else
            d.push(
              '<rect x="0" y="0" width="100%" height="100%" ',
              'fill="',
              b,
              '"',
              `></rect>
`
            );
      },
      sendToBack: function(d) {
        if (!d)
          return this;
        var v = this._activeObject, b, y, w;
        if (d === v && d.type === "activeSelection")
          for (w = v._objects, b = w.length; b--; )
            y = w[b], u(this._objects, y), this._objects.unshift(y);
        else
          u(this._objects, d), this._objects.unshift(d);
        return this.renderOnAddRemove && this.requestRenderAll(), this;
      },
      bringToFront: function(d) {
        if (!d)
          return this;
        var v = this._activeObject, b, y, w;
        if (d === v && d.type === "activeSelection")
          for (w = v._objects, b = 0; b < w.length; b++)
            y = w[b], u(this._objects, y), this._objects.push(y);
        else
          u(this._objects, d), this._objects.push(d);
        return this.renderOnAddRemove && this.requestRenderAll(), this;
      },
      sendBackwards: function(d, v) {
        if (!d)
          return this;
        var b = this._activeObject, y, w, _, S, T, A = 0;
        if (d === b && d.type === "activeSelection")
          for (T = b._objects, y = 0; y < T.length; y++)
            w = T[y], _ = this._objects.indexOf(w), _ > 0 + A && (S = _ - 1, u(this._objects, w), this._objects.splice(S, 0, w)), A++;
        else
          _ = this._objects.indexOf(d), _ !== 0 && (S = this._findNewLowerIndex(d, _, v), u(this._objects, d), this._objects.splice(S, 0, d));
        return this.renderOnAddRemove && this.requestRenderAll(), this;
      },
      _findNewLowerIndex: function(d, v, b) {
        var y, w;
        if (b)
          for (y = v, w = v - 1; w >= 0; --w) {
            var _ = d.intersectsWithObject(this._objects[w]) || d.isContainedWithinObject(this._objects[w]) || this._objects[w].isContainedWithinObject(d);
            if (_) {
              y = w;
              break;
            }
          }
        else
          y = v - 1;
        return y;
      },
      bringForward: function(d, v) {
        if (!d)
          return this;
        var b = this._activeObject, y, w, _, S, T, A = 0;
        if (d === b && d.type === "activeSelection")
          for (T = b._objects, y = T.length; y--; )
            w = T[y], _ = this._objects.indexOf(w), _ < this._objects.length - 1 - A && (S = _ + 1, u(this._objects, w), this._objects.splice(S, 0, w)), A++;
        else
          _ = this._objects.indexOf(d), _ !== this._objects.length - 1 && (S = this._findNewUpperIndex(d, _, v), u(this._objects, d), this._objects.splice(S, 0, d));
        return this.renderOnAddRemove && this.requestRenderAll(), this;
      },
      _findNewUpperIndex: function(d, v, b) {
        var y, w, _;
        if (b)
          for (y = v, w = v + 1, _ = this._objects.length; w < _; ++w) {
            var S = d.intersectsWithObject(this._objects[w]) || d.isContainedWithinObject(this._objects[w]) || this._objects[w].isContainedWithinObject(d);
            if (S) {
              y = w;
              break;
            }
          }
        else
          y = v + 1;
        return y;
      },
      moveTo: function(d, v) {
        return u(this._objects, d), this._objects.splice(v, 0, d), this.renderOnAddRemove && this.requestRenderAll();
      },
      dispose: function() {
        return this.isRendering && (e.util.cancelAnimFrame(this.isRendering), this.isRendering = 0), this.forEachObject(function(d) {
          d.dispose && d.dispose();
        }), this._objects = [], this.backgroundImage && this.backgroundImage.dispose && this.backgroundImage.dispose(), this.backgroundImage = null, this.overlayImage && this.overlayImage.dispose && this.overlayImage.dispose(), this.overlayImage = null, this._iTextInstances = null, this.contextContainer = null, this.lowerCanvasEl.classList.remove("lower-canvas"), e.util.setStyle(this.lowerCanvasEl, this._originalCanvasStyle), delete this._originalCanvasStyle, this.lowerCanvasEl.setAttribute("width", this.width), this.lowerCanvasEl.setAttribute("height", this.height), e.util.cleanUpJsdomNode(this.lowerCanvasEl), this.lowerCanvasEl = void 0, this;
      },
      toString: function() {
        return "#<fabric.Canvas (" + this.complexity() + "): { objects: " + this._objects.length + " }>";
      }
    }), a(e.StaticCanvas.prototype, e.Observable), a(e.StaticCanvas.prototype, e.Collection), a(e.StaticCanvas.prototype, e.DataURLExporter), a(e.StaticCanvas, {
      EMPTY_JSON: '{"objects": [], "background": "white"}',
      supports: function(d) {
        var v = f();
        if (!v || !v.getContext)
          return null;
        var b = v.getContext("2d");
        if (!b)
          return null;
        switch (d) {
          case "setLineDash":
            return typeof b.setLineDash < "u";
          default:
            return null;
        }
      }
    }), e.StaticCanvas.prototype.toJSON = e.StaticCanvas.prototype.toObject, e.isLikelyNode && (e.StaticCanvas.prototype.createPNGStream = function() {
      var d = c(this.lowerCanvasEl);
      return d && d.createPNGStream();
    }, e.StaticCanvas.prototype.createJPEGStream = function(d) {
      var v = c(this.lowerCanvasEl);
      return v && v.createJPEGStream(d);
    });
  }(), e.BaseBrush = e.util.createClass({
    color: "rgb(0, 0, 0)",
    width: 1,
    shadow: null,
    strokeLineCap: "round",
    strokeLineJoin: "round",
    strokeMiterLimit: 10,
    strokeDashArray: null,
    limitedToCanvasSize: !1,
    _setBrushStyles: function(a) {
      a.strokeStyle = this.color, a.lineWidth = this.width, a.lineCap = this.strokeLineCap, a.miterLimit = this.strokeMiterLimit, a.lineJoin = this.strokeLineJoin, a.setLineDash(this.strokeDashArray || []);
    },
    _saveAndTransform: function(a) {
      var n = this.canvas.viewportTransform;
      a.save(), a.transform(n[0], n[1], n[2], n[3], n[4], n[5]);
    },
    _setShadow: function() {
      if (!!this.shadow) {
        var a = this.canvas, n = this.shadow, u = a.contextTop, h = a.getZoom();
        a && a._isRetinaScaling() && (h *= e.devicePixelRatio), u.shadowColor = n.color, u.shadowBlur = n.blur * h, u.shadowOffsetX = n.offsetX * h, u.shadowOffsetY = n.offsetY * h;
      }
    },
    needsFullRender: function() {
      var a = new e.Color(this.color);
      return a.getAlpha() < 1 || !!this.shadow;
    },
    _resetShadow: function() {
      var a = this.canvas.contextTop;
      a.shadowColor = "", a.shadowBlur = a.shadowOffsetX = a.shadowOffsetY = 0;
    },
    _isOutSideCanvas: function(a) {
      return a.x < 0 || a.x > this.canvas.getWidth() || a.y < 0 || a.y > this.canvas.getHeight();
    }
  }), function() {
    e.PencilBrush = e.util.createClass(e.BaseBrush, {
      decimate: 0.4,
      drawStraightLine: !1,
      straightLineKey: "shiftKey",
      initialize: function(a) {
        this.canvas = a, this._points = [];
      },
      needsFullRender: function() {
        return this.callSuper("needsFullRender") || this._hasStraightLine;
      },
      _drawSegment: function(a, n, u) {
        var h = n.midPointFrom(u);
        return a.quadraticCurveTo(n.x, n.y, h.x, h.y), h;
      },
      onMouseDown: function(a, n) {
        !this.canvas._isMainEvent(n.e) || (this.drawStraightLine = n.e[this.straightLineKey], this._prepareForDrawing(a), this._captureDrawingPath(a), this._render());
      },
      onMouseMove: function(a, n) {
        if (!!this.canvas._isMainEvent(n.e) && (this.drawStraightLine = n.e[this.straightLineKey], !(this.limitedToCanvasSize === !0 && this._isOutSideCanvas(a)) && this._captureDrawingPath(a) && this._points.length > 1))
          if (this.needsFullRender())
            this.canvas.clearContext(this.canvas.contextTop), this._render();
          else {
            var u = this._points, h = u.length, s = this.canvas.contextTop;
            this._saveAndTransform(s), this.oldEnd && (s.beginPath(), s.moveTo(this.oldEnd.x, this.oldEnd.y)), this.oldEnd = this._drawSegment(s, u[h - 2], u[h - 1], !0), s.stroke(), s.restore();
          }
      },
      onMouseUp: function(a) {
        return this.canvas._isMainEvent(a.e) ? (this.drawStraightLine = !1, this.oldEnd = void 0, this._finalizeAndAddPath(), !1) : !0;
      },
      _prepareForDrawing: function(a) {
        var n = new e.Point(a.x, a.y);
        this._reset(), this._addPoint(n), this.canvas.contextTop.moveTo(n.x, n.y);
      },
      _addPoint: function(a) {
        return this._points.length > 1 && a.eq(this._points[this._points.length - 1]) ? !1 : (this.drawStraightLine && this._points.length > 1 && (this._hasStraightLine = !0, this._points.pop()), this._points.push(a), !0);
      },
      _reset: function() {
        this._points = [], this._setBrushStyles(this.canvas.contextTop), this._setShadow(), this._hasStraightLine = !1;
      },
      _captureDrawingPath: function(a) {
        var n = new e.Point(a.x, a.y);
        return this._addPoint(n);
      },
      _render: function(a) {
        var n, u, h = this._points[0], s = this._points[1];
        if (a = a || this.canvas.contextTop, this._saveAndTransform(a), a.beginPath(), this._points.length === 2 && h.x === s.x && h.y === s.y) {
          var l = this.width / 1e3;
          h = new e.Point(h.x, h.y), s = new e.Point(s.x, s.y), h.x -= l, s.x += l;
        }
        for (a.moveTo(h.x, h.y), n = 1, u = this._points.length; n < u; n++)
          this._drawSegment(a, h, s), h = this._points[n], s = this._points[n + 1];
        a.lineTo(h.x, h.y), a.stroke(), a.restore();
      },
      convertPointsToSVGPath: function(a) {
        var n = this.width / 1e3;
        return e.util.getSmoothPathFromPoints(a, n);
      },
      _isEmptySVGPath: function(a) {
        var n = e.util.joinPath(a);
        return n === "M 0 0 Q 0 0 0 0 L 0 0";
      },
      createPath: function(a) {
        var n = new e.Path(a, {
          fill: null,
          stroke: this.color,
          strokeWidth: this.width,
          strokeLineCap: this.strokeLineCap,
          strokeMiterLimit: this.strokeMiterLimit,
          strokeLineJoin: this.strokeLineJoin,
          strokeDashArray: this.strokeDashArray
        });
        return this.shadow && (this.shadow.affectStroke = !0, n.shadow = new e.Shadow(this.shadow)), n;
      },
      decimatePoints: function(a, n) {
        if (a.length <= 2)
          return a;
        var u = this.canvas.getZoom(), h = Math.pow(n / u, 2), s, l = a.length - 1, c = a[0], f = [c], m;
        for (s = 1; s < l - 1; s++)
          m = Math.pow(c.x - a[s].x, 2) + Math.pow(c.y - a[s].y, 2), m >= h && (c = a[s], f.push(c));
        return f.push(a[l]), f;
      },
      _finalizeAndAddPath: function() {
        var a = this.canvas.contextTop;
        a.closePath(), this.decimate && (this._points = this.decimatePoints(this._points, this.decimate));
        var n = this.convertPointsToSVGPath(this._points);
        if (this._isEmptySVGPath(n)) {
          this.canvas.requestRenderAll();
          return;
        }
        var u = this.createPath(n);
        this.canvas.clearContext(this.canvas.contextTop), this.canvas.fire("before:path:created", { path: u }), this.canvas.add(u), this.canvas.requestRenderAll(), u.setCoords(), this._resetShadow(), this.canvas.fire("path:created", { path: u });
      }
    });
  }(), e.CircleBrush = e.util.createClass(e.BaseBrush, {
    width: 10,
    initialize: function(a) {
      this.canvas = a, this.points = [];
    },
    drawDot: function(a) {
      var n = this.addPoint(a), u = this.canvas.contextTop;
      this._saveAndTransform(u), this.dot(u, n), u.restore();
    },
    dot: function(a, n) {
      a.fillStyle = n.fill, a.beginPath(), a.arc(n.x, n.y, n.radius, 0, Math.PI * 2, !1), a.closePath(), a.fill();
    },
    onMouseDown: function(a) {
      this.points.length = 0, this.canvas.clearContext(this.canvas.contextTop), this._setShadow(), this.drawDot(a);
    },
    _render: function() {
      var a = this.canvas.contextTop, n, u, h = this.points;
      for (this._saveAndTransform(a), n = 0, u = h.length; n < u; n++)
        this.dot(a, h[n]);
      a.restore();
    },
    onMouseMove: function(a) {
      this.limitedToCanvasSize === !0 && this._isOutSideCanvas(a) || (this.needsFullRender() ? (this.canvas.clearContext(this.canvas.contextTop), this.addPoint(a), this._render()) : this.drawDot(a));
    },
    onMouseUp: function() {
      var a = this.canvas.renderOnAddRemove, n, u;
      this.canvas.renderOnAddRemove = !1;
      var h = [];
      for (n = 0, u = this.points.length; n < u; n++) {
        var s = this.points[n], l = new e.Circle({
          radius: s.radius,
          left: s.x,
          top: s.y,
          originX: "center",
          originY: "center",
          fill: s.fill
        });
        this.shadow && (l.shadow = new e.Shadow(this.shadow)), h.push(l);
      }
      var c = new e.Group(h);
      c.canvas = this.canvas, this.canvas.fire("before:path:created", { path: c }), this.canvas.add(c), this.canvas.fire("path:created", { path: c }), this.canvas.clearContext(this.canvas.contextTop), this._resetShadow(), this.canvas.renderOnAddRemove = a, this.canvas.requestRenderAll();
    },
    addPoint: function(a) {
      var n = new e.Point(a.x, a.y), u = e.util.getRandomInt(
        Math.max(0, this.width - 20),
        this.width + 20
      ) / 2, h = new e.Color(this.color).setAlpha(e.util.getRandomInt(0, 100) / 100).toRgba();
      return n.radius = u, n.fill = h, this.points.push(n), n;
    }
  }), e.SprayBrush = e.util.createClass(e.BaseBrush, {
    width: 10,
    density: 20,
    dotWidth: 1,
    dotWidthVariance: 1,
    randomOpacity: !1,
    optimizeOverlapping: !0,
    initialize: function(a) {
      this.canvas = a, this.sprayChunks = [];
    },
    onMouseDown: function(a) {
      this.sprayChunks.length = 0, this.canvas.clearContext(this.canvas.contextTop), this._setShadow(), this.addSprayChunk(a), this.render(this.sprayChunkPoints);
    },
    onMouseMove: function(a) {
      this.limitedToCanvasSize === !0 && this._isOutSideCanvas(a) || (this.addSprayChunk(a), this.render(this.sprayChunkPoints));
    },
    onMouseUp: function() {
      var a = this.canvas.renderOnAddRemove;
      this.canvas.renderOnAddRemove = !1;
      for (var n = [], u = 0, h = this.sprayChunks.length; u < h; u++)
        for (var s = this.sprayChunks[u], l = 0, c = s.length; l < c; l++) {
          var f = new e.Rect({
            width: s[l].width,
            height: s[l].width,
            left: s[l].x + 1,
            top: s[l].y + 1,
            originX: "center",
            originY: "center",
            fill: this.color
          });
          n.push(f);
        }
      this.optimizeOverlapping && (n = this._getOptimizedRects(n));
      var m = new e.Group(n);
      this.shadow && m.set("shadow", new e.Shadow(this.shadow)), this.canvas.fire("before:path:created", { path: m }), this.canvas.add(m), this.canvas.fire("path:created", { path: m }), this.canvas.clearContext(this.canvas.contextTop), this._resetShadow(), this.canvas.renderOnAddRemove = a, this.canvas.requestRenderAll();
    },
    _getOptimizedRects: function(a) {
      var n = {}, u, h, s;
      for (h = 0, s = a.length; h < s; h++)
        u = a[h].left + "" + a[h].top, n[u] || (n[u] = a[h]);
      var l = [];
      for (u in n)
        l.push(n[u]);
      return l;
    },
    render: function(a) {
      var n = this.canvas.contextTop, u, h;
      for (n.fillStyle = this.color, this._saveAndTransform(n), u = 0, h = a.length; u < h; u++) {
        var s = a[u];
        typeof s.opacity < "u" && (n.globalAlpha = s.opacity), n.fillRect(s.x, s.y, s.width, s.width);
      }
      n.restore();
    },
    _render: function() {
      var a = this.canvas.contextTop, n, u;
      for (a.fillStyle = this.color, this._saveAndTransform(a), n = 0, u = this.sprayChunks.length; n < u; n++)
        this.render(this.sprayChunks[n]);
      a.restore();
    },
    addSprayChunk: function(a) {
      this.sprayChunkPoints = [];
      var n, u, h, s = this.width / 2, l;
      for (l = 0; l < this.density; l++) {
        n = e.util.getRandomInt(a.x - s, a.x + s), u = e.util.getRandomInt(a.y - s, a.y + s), this.dotWidthVariance ? h = e.util.getRandomInt(
          Math.max(1, this.dotWidth - this.dotWidthVariance),
          this.dotWidth + this.dotWidthVariance
        ) : h = this.dotWidth;
        var c = new e.Point(n, u);
        c.width = h, this.randomOpacity && (c.opacity = e.util.getRandomInt(0, 100) / 100), this.sprayChunkPoints.push(c);
      }
      this.sprayChunks.push(this.sprayChunkPoints);
    }
  }), e.PatternBrush = e.util.createClass(e.PencilBrush, {
    getPatternSrc: function() {
      var a = 20, n = 5, u = e.util.createCanvasElement(), h = u.getContext("2d");
      return u.width = u.height = a + n, h.fillStyle = this.color, h.beginPath(), h.arc(a / 2, a / 2, a / 2, 0, Math.PI * 2, !1), h.closePath(), h.fill(), u;
    },
    getPatternSrcFunction: function() {
      return String(this.getPatternSrc).replace("this.color", '"' + this.color + '"');
    },
    getPattern: function(a) {
      return a.createPattern(this.source || this.getPatternSrc(), "repeat");
    },
    _setBrushStyles: function(a) {
      this.callSuper("_setBrushStyles", a), a.strokeStyle = this.getPattern(a);
    },
    createPath: function(a) {
      var n = this.callSuper("createPath", a), u = n._getLeftTopCoords().scalarAdd(n.strokeWidth / 2);
      return n.stroke = new e.Pattern({
        source: this.source || this.getPatternSrcFunction(),
        offsetX: -u.x,
        offsetY: -u.y
      }), n;
    }
  }), function() {
    var a = e.util.getPointer, n = e.util.degreesToRadians, u = e.util.isTouchEvent;
    e.Canvas = e.util.createClass(e.StaticCanvas, {
      initialize: function(s, l) {
        l || (l = {}), this.renderAndResetBound = this.renderAndReset.bind(this), this.requestRenderAllBound = this.requestRenderAll.bind(this), this._initStatic(s, l), this._initInteractive(), this._createCacheCanvas();
      },
      uniformScaling: !0,
      uniScaleKey: "shiftKey",
      centeredScaling: !1,
      centeredRotation: !1,
      centeredKey: "altKey",
      altActionKey: "shiftKey",
      interactive: !0,
      selection: !0,
      selectionKey: "shiftKey",
      altSelectionKey: null,
      selectionColor: "rgba(100, 100, 255, 0.3)",
      selectionDashArray: [],
      selectionBorderColor: "rgba(255, 255, 255, 0.3)",
      selectionLineWidth: 1,
      selectionFullyContained: !1,
      hoverCursor: "move",
      moveCursor: "move",
      defaultCursor: "default",
      freeDrawingCursor: "crosshair",
      notAllowedCursor: "not-allowed",
      containerClass: "canvas-container",
      perPixelTargetFind: !1,
      targetFindTolerance: 0,
      skipTargetFind: !1,
      isDrawingMode: !1,
      preserveObjectStacking: !1,
      snapAngle: 0,
      snapThreshold: null,
      stopContextMenu: !1,
      fireRightClick: !1,
      fireMiddleClick: !1,
      targets: [],
      enablePointerEvents: !1,
      _hoveredTarget: null,
      _hoveredTargets: [],
      _initInteractive: function() {
        this._currentTransform = null, this._groupSelector = null, this._initWrapperElement(), this._createUpperCanvas(), this._initEventListeners(), this._initRetinaScaling(), this.freeDrawingBrush = e.PencilBrush && new e.PencilBrush(this), this.calcOffset();
      },
      _chooseObjectsToRender: function() {
        var s = this.getActiveObjects(), l, c, f;
        if (s.length > 0 && !this.preserveObjectStacking) {
          c = [], f = [];
          for (var m = 0, d = this._objects.length; m < d; m++)
            l = this._objects[m], s.indexOf(l) === -1 ? c.push(l) : f.push(l);
          s.length > 1 && (this._activeObject._objects = f), c.push.apply(c, f);
        } else
          c = this._objects;
        return c;
      },
      renderAll: function() {
        this.contextTopDirty && !this._groupSelector && !this.isDrawingMode && (this.clearContext(this.contextTop), this.contextTopDirty = !1), this.hasLostContext && (this.renderTopLayer(this.contextTop), this.hasLostContext = !1);
        var s = this.contextContainer;
        return this.renderCanvas(s, this._chooseObjectsToRender()), this;
      },
      renderTopLayer: function(s) {
        s.save(), this.isDrawingMode && this._isCurrentlyDrawing && (this.freeDrawingBrush && this.freeDrawingBrush._render(), this.contextTopDirty = !0), this.selection && this._groupSelector && (this._drawSelection(s), this.contextTopDirty = !0), s.restore();
      },
      renderTop: function() {
        var s = this.contextTop;
        return this.clearContext(s), this.renderTopLayer(s), this.fire("after:render"), this;
      },
      _normalizePointer: function(s, l) {
        var c = s.calcTransformMatrix(), f = e.util.invertTransform(c), m = this.restorePointerVpt(l);
        return e.util.transformPoint(m, f);
      },
      isTargetTransparent: function(s, l, c) {
        if (s.shouldCache() && s._cacheCanvas && s !== this._activeObject) {
          var f = this._normalizePointer(s, { x: l, y: c }), m = Math.max(s.cacheTranslationX + f.x * s.zoomX, 0), d = Math.max(s.cacheTranslationY + f.y * s.zoomY, 0), w = e.util.isTransparent(
            s._cacheContext,
            Math.round(m),
            Math.round(d),
            this.targetFindTolerance
          );
          return w;
        }
        var v = this.contextCache, b = s.selectionBackgroundColor, y = this.viewportTransform;
        s.selectionBackgroundColor = "", this.clearContext(v), v.save(), v.transform(y[0], y[1], y[2], y[3], y[4], y[5]), s.render(v), v.restore(), s.selectionBackgroundColor = b;
        var w = e.util.isTransparent(
          v,
          l,
          c,
          this.targetFindTolerance
        );
        return w;
      },
      _isSelectionKeyPressed: function(s) {
        var l = !1;
        return Array.isArray(this.selectionKey) ? l = !!this.selectionKey.find(function(c) {
          return s[c] === !0;
        }) : l = s[this.selectionKey], l;
      },
      _shouldClearSelection: function(s, l) {
        var c = this.getActiveObjects(), f = this._activeObject;
        return !l || l && f && c.length > 1 && c.indexOf(l) === -1 && f !== l && !this._isSelectionKeyPressed(s) || l && !l.evented || l && !l.selectable && f && f !== l;
      },
      _shouldCenterTransform: function(s, l, c) {
        if (!!s) {
          var f;
          return l === "scale" || l === "scaleX" || l === "scaleY" || l === "resizing" ? f = this.centeredScaling || s.centeredScaling : l === "rotate" && (f = this.centeredRotation || s.centeredRotation), f ? !c : c;
        }
      },
      _getOriginFromCorner: function(s, l) {
        var c = {
          x: s.originX,
          y: s.originY
        };
        return l === "ml" || l === "tl" || l === "bl" ? c.x = "right" : (l === "mr" || l === "tr" || l === "br") && (c.x = "left"), l === "tl" || l === "mt" || l === "tr" ? c.y = "bottom" : (l === "bl" || l === "mb" || l === "br") && (c.y = "top"), c;
      },
      _getActionFromCorner: function(s, l, c, f) {
        if (!l || !s)
          return "drag";
        var m = f.controls[l];
        return m.getActionName(c, m, f);
      },
      _setupCurrentTransform: function(s, l, c) {
        if (!!l) {
          var f = this.getPointer(s), m = l.__corner, d = l.controls[m], v = c && m ? d.getActionHandler(s, l, d) : e.controlsUtils.dragHandler, b = this._getActionFromCorner(c, m, s, l), y = this._getOriginFromCorner(l, m), w = s[this.centeredKey], _ = {
            target: l,
            action: b,
            actionHandler: v,
            corner: m,
            scaleX: l.scaleX,
            scaleY: l.scaleY,
            skewX: l.skewX,
            skewY: l.skewY,
            offsetX: f.x - l.left,
            offsetY: f.y - l.top,
            originX: y.x,
            originY: y.y,
            ex: f.x,
            ey: f.y,
            lastX: f.x,
            lastY: f.y,
            theta: n(l.angle),
            width: l.width * l.scaleX,
            shiftKey: s.shiftKey,
            altKey: w,
            original: e.util.saveObjectTransform(l)
          };
          this._shouldCenterTransform(l, b, w) && (_.originX = "center", _.originY = "center"), _.original.originX = y.x, _.original.originY = y.y, this._currentTransform = _, this._beforeTransform(s);
        }
      },
      setCursor: function(s) {
        this.upperCanvasEl.style.cursor = s;
      },
      _drawSelection: function(s) {
        var l = this._groupSelector, c = new e.Point(l.ex, l.ey), f = e.util.transformPoint(c, this.viewportTransform), m = new e.Point(l.ex + l.left, l.ey + l.top), d = e.util.transformPoint(m, this.viewportTransform), v = Math.min(f.x, d.x), b = Math.min(f.y, d.y), y = Math.max(f.x, d.x), w = Math.max(f.y, d.y), _ = this.selectionLineWidth / 2;
        this.selectionColor && (s.fillStyle = this.selectionColor, s.fillRect(v, b, y - v, w - b)), !(!this.selectionLineWidth || !this.selectionBorderColor) && (s.lineWidth = this.selectionLineWidth, s.strokeStyle = this.selectionBorderColor, v += _, b += _, y -= _, w -= _, e.Object.prototype._setLineDash.call(this, s, this.selectionDashArray), s.strokeRect(v, b, y - v, w - b));
      },
      findTarget: function(s, l) {
        if (!this.skipTargetFind) {
          var c = !0, f = this.getPointer(s, c), m = this._activeObject, d = this.getActiveObjects(), v, b, y = u(s), w = d.length > 1 && !l || d.length === 1;
          if (this.targets = [], w && m._findTargetCorner(f, y) || d.length > 1 && !l && m === this._searchPossibleTargets([m], f))
            return m;
          if (d.length === 1 && m === this._searchPossibleTargets([m], f))
            if (this.preserveObjectStacking)
              v = m, b = this.targets, this.targets = [];
            else
              return m;
          var _ = this._searchPossibleTargets(this._objects, f);
          return s[this.altSelectionKey] && _ && v && _ !== v && (_ = v, this.targets = b), _;
        }
      },
      _checkTarget: function(s, l, c) {
        if (l && l.visible && l.evented && l.containsPoint(s))
          if ((this.perPixelTargetFind || l.perPixelTargetFind) && !l.isEditing) {
            var f = this.isTargetTransparent(l, c.x, c.y);
            if (!f)
              return !0;
          } else
            return !0;
      },
      _searchPossibleTargets: function(s, l) {
        for (var c, f = s.length, m; f--; ) {
          var d = s[f], v = d.group ? this._normalizePointer(d.group, l) : l;
          if (this._checkTarget(v, d, l)) {
            c = s[f], c.subTargetCheck && c instanceof e.Group && (m = this._searchPossibleTargets(c._objects, l), m && this.targets.push(m));
            break;
          }
        }
        return c;
      },
      restorePointerVpt: function(s) {
        return e.util.transformPoint(
          s,
          e.util.invertTransform(this.viewportTransform)
        );
      },
      getPointer: function(s, l) {
        if (this._absolutePointer && !l)
          return this._absolutePointer;
        if (this._pointer && l)
          return this._pointer;
        var c = a(s), f = this.upperCanvasEl, m = f.getBoundingClientRect(), d = m.width || 0, v = m.height || 0, b;
        (!d || !v) && ("top" in m && "bottom" in m && (v = Math.abs(m.top - m.bottom)), "right" in m && "left" in m && (d = Math.abs(m.right - m.left))), this.calcOffset(), c.x = c.x - this._offset.left, c.y = c.y - this._offset.top, l || (c = this.restorePointerVpt(c));
        var y = this.getRetinaScaling();
        return y !== 1 && (c.x /= y, c.y /= y), d === 0 || v === 0 ? b = { width: 1, height: 1 } : b = {
          width: f.width / d,
          height: f.height / v
        }, {
          x: c.x * b.width,
          y: c.y * b.height
        };
      },
      _createUpperCanvas: function() {
        var s = this.lowerCanvasEl.className.replace(/\s*lower-canvas\s*/, ""), l = this.lowerCanvasEl, c = this.upperCanvasEl;
        c ? c.className = "" : (c = this._createCanvasElement(), this.upperCanvasEl = c), e.util.addClass(c, "upper-canvas " + s), this.wrapperEl.appendChild(c), this._copyCanvasStyle(l, c), this._applyCanvasStyle(c), this.contextTop = c.getContext("2d");
      },
      getTopContext: function() {
        return this.contextTop;
      },
      _createCacheCanvas: function() {
        this.cacheCanvasEl = this._createCanvasElement(), this.cacheCanvasEl.setAttribute("width", this.width), this.cacheCanvasEl.setAttribute("height", this.height), this.contextCache = this.cacheCanvasEl.getContext("2d");
      },
      _initWrapperElement: function() {
        this.wrapperEl = e.util.wrapElement(this.lowerCanvasEl, "div", {
          class: this.containerClass
        }), e.util.setStyle(this.wrapperEl, {
          width: this.width + "px",
          height: this.height + "px",
          position: "relative"
        }), e.util.makeElementUnselectable(this.wrapperEl);
      },
      _applyCanvasStyle: function(s) {
        var l = this.width || s.width, c = this.height || s.height;
        e.util.setStyle(s, {
          position: "absolute",
          width: l + "px",
          height: c + "px",
          left: 0,
          top: 0,
          "touch-action": this.allowTouchScrolling ? "manipulation" : "none",
          "-ms-touch-action": this.allowTouchScrolling ? "manipulation" : "none"
        }), s.width = l, s.height = c, e.util.makeElementUnselectable(s);
      },
      _copyCanvasStyle: function(s, l) {
        l.style.cssText = s.style.cssText;
      },
      getSelectionContext: function() {
        return this.contextTop;
      },
      getSelectionElement: function() {
        return this.upperCanvasEl;
      },
      getActiveObject: function() {
        return this._activeObject;
      },
      getActiveObjects: function() {
        var s = this._activeObject;
        return s ? s.type === "activeSelection" && s._objects ? s._objects.slice(0) : [s] : [];
      },
      _onObjectRemoved: function(s) {
        s === this._activeObject && (this.fire("before:selection:cleared", { target: s }), this._discardActiveObject(), this.fire("selection:cleared", { target: s }), s.fire("deselected")), s === this._hoveredTarget && (this._hoveredTarget = null, this._hoveredTargets = []), this.callSuper("_onObjectRemoved", s);
      },
      _fireSelectionEvents: function(s, l) {
        var c = !1, f = this.getActiveObjects(), m = [], d = [];
        s.forEach(function(v) {
          f.indexOf(v) === -1 && (c = !0, v.fire("deselected", {
            e: l,
            target: v
          }), d.push(v));
        }), f.forEach(function(v) {
          s.indexOf(v) === -1 && (c = !0, v.fire("selected", {
            e: l,
            target: v
          }), m.push(v));
        }), s.length > 0 && f.length > 0 ? c && this.fire("selection:updated", {
          e: l,
          selected: m,
          deselected: d
        }) : f.length > 0 ? this.fire("selection:created", {
          e: l,
          selected: m
        }) : s.length > 0 && this.fire("selection:cleared", {
          e: l,
          deselected: d
        });
      },
      setActiveObject: function(s, l) {
        var c = this.getActiveObjects();
        return this._setActiveObject(s, l), this._fireSelectionEvents(c, l), this;
      },
      _setActiveObject: function(s, l) {
        return this._activeObject === s || !this._discardActiveObject(l, s) || s.onSelect({ e: l }) ? !1 : (this._activeObject = s, !0);
      },
      _discardActiveObject: function(s, l) {
        var c = this._activeObject;
        if (c) {
          if (c.onDeselect({ e: s, object: l }))
            return !1;
          this._activeObject = null;
        }
        return !0;
      },
      discardActiveObject: function(s) {
        var l = this.getActiveObjects(), c = this.getActiveObject();
        return l.length && this.fire("before:selection:cleared", { target: c, e: s }), this._discardActiveObject(s), this._fireSelectionEvents(l, s), this;
      },
      dispose: function() {
        var s = this.wrapperEl;
        return this.removeListeners(), s.removeChild(this.upperCanvasEl), s.removeChild(this.lowerCanvasEl), this.contextCache = null, this.contextTop = null, ["upperCanvasEl", "cacheCanvasEl"].forEach(function(l) {
          e.util.cleanUpJsdomNode(this[l]), this[l] = void 0;
        }.bind(this)), s.parentNode && s.parentNode.replaceChild(this.lowerCanvasEl, this.wrapperEl), delete this.wrapperEl, e.StaticCanvas.prototype.dispose.call(this), this;
      },
      clear: function() {
        return this.discardActiveObject(), this.clearContext(this.contextTop), this.callSuper("clear");
      },
      drawControls: function(s) {
        var l = this._activeObject;
        l && l._renderControls(s);
      },
      _toObject: function(s, l, c) {
        var f = this._realizeGroupTransformOnObject(s), m = this.callSuper("_toObject", s, l, c);
        return this._unwindGroupTransformOnObject(s, f), m;
      },
      _realizeGroupTransformOnObject: function(s) {
        if (s.group && s.group.type === "activeSelection" && this._activeObject === s.group) {
          var l = ["angle", "flipX", "flipY", "left", "scaleX", "scaleY", "skewX", "skewY", "top"], c = {};
          return l.forEach(function(f) {
            c[f] = s[f];
          }), e.util.addTransformToObject(s, this._activeObject.calcOwnMatrix()), c;
        } else
          return null;
      },
      _unwindGroupTransformOnObject: function(s, l) {
        l && s.set(l);
      },
      _setSVGObject: function(s, l, c) {
        var f = this._realizeGroupTransformOnObject(l);
        this.callSuper("_setSVGObject", s, l, c), this._unwindGroupTransformOnObject(l, f);
      },
      setViewportTransform: function(s) {
        this.renderOnAddRemove && this._activeObject && this._activeObject.isEditing && this._activeObject.clearContextTop(), e.StaticCanvas.prototype.setViewportTransform.call(this, s);
      }
    });
    for (var h in e.StaticCanvas)
      h !== "prototype" && (e.Canvas[h] = e.StaticCanvas[h]);
  }(), function() {
    var a = e.util.addListener, n = e.util.removeListener, u = 3, h = 2, s = 1, l = { passive: !1 };
    function c(f, m) {
      return f.button && f.button === m - 1;
    }
    e.util.object.extend(e.Canvas.prototype, {
      mainTouchId: null,
      _initEventListeners: function() {
        this.removeListeners(), this._bindEvents(), this.addOrRemove(a, "add");
      },
      _getEventPrefix: function() {
        return this.enablePointerEvents ? "pointer" : "mouse";
      },
      addOrRemove: function(f, m) {
        var d = this.upperCanvasEl, v = this._getEventPrefix();
        f(e.window, "resize", this._onResize), f(d, v + "down", this._onMouseDown), f(d, v + "move", this._onMouseMove, l), f(d, v + "out", this._onMouseOut), f(d, v + "enter", this._onMouseEnter), f(d, "wheel", this._onMouseWheel), f(d, "contextmenu", this._onContextMenu), f(d, "dblclick", this._onDoubleClick), f(d, "dragover", this._onDragOver), f(d, "dragenter", this._onDragEnter), f(d, "dragleave", this._onDragLeave), f(d, "drop", this._onDrop), this.enablePointerEvents || f(d, "touchstart", this._onTouchStart, l), typeof eventjs < "u" && m in eventjs && (eventjs[m](d, "gesture", this._onGesture), eventjs[m](d, "drag", this._onDrag), eventjs[m](d, "orientation", this._onOrientationChange), eventjs[m](d, "shake", this._onShake), eventjs[m](d, "longpress", this._onLongPress));
      },
      removeListeners: function() {
        this.addOrRemove(n, "remove");
        var f = this._getEventPrefix();
        n(e.document, f + "up", this._onMouseUp), n(e.document, "touchend", this._onTouchEnd, l), n(e.document, f + "move", this._onMouseMove, l), n(e.document, "touchmove", this._onMouseMove, l);
      },
      _bindEvents: function() {
        this.eventsBound || (this._onMouseDown = this._onMouseDown.bind(this), this._onTouchStart = this._onTouchStart.bind(this), this._onMouseMove = this._onMouseMove.bind(this), this._onMouseUp = this._onMouseUp.bind(this), this._onTouchEnd = this._onTouchEnd.bind(this), this._onResize = this._onResize.bind(this), this._onGesture = this._onGesture.bind(this), this._onDrag = this._onDrag.bind(this), this._onShake = this._onShake.bind(this), this._onLongPress = this._onLongPress.bind(this), this._onOrientationChange = this._onOrientationChange.bind(this), this._onMouseWheel = this._onMouseWheel.bind(this), this._onMouseOut = this._onMouseOut.bind(this), this._onMouseEnter = this._onMouseEnter.bind(this), this._onContextMenu = this._onContextMenu.bind(this), this._onDoubleClick = this._onDoubleClick.bind(this), this._onDragOver = this._onDragOver.bind(this), this._onDragEnter = this._simpleEventHandler.bind(this, "dragenter"), this._onDragLeave = this._simpleEventHandler.bind(this, "dragleave"), this._onDrop = this._onDrop.bind(this), this.eventsBound = !0);
      },
      _onGesture: function(f, m) {
        this.__onTransformGesture && this.__onTransformGesture(f, m);
      },
      _onDrag: function(f, m) {
        this.__onDrag && this.__onDrag(f, m);
      },
      _onMouseWheel: function(f) {
        this.__onMouseWheel(f);
      },
      _onMouseOut: function(f) {
        var m = this._hoveredTarget;
        this.fire("mouse:out", { target: m, e: f }), this._hoveredTarget = null, m && m.fire("mouseout", { e: f });
        var d = this;
        this._hoveredTargets.forEach(function(v) {
          d.fire("mouse:out", { target: m, e: f }), v && m.fire("mouseout", { e: f });
        }), this._hoveredTargets = [];
      },
      _onMouseEnter: function(f) {
        !this._currentTransform && !this.findTarget(f) && (this.fire("mouse:over", { target: null, e: f }), this._hoveredTarget = null, this._hoveredTargets = []);
      },
      _onOrientationChange: function(f, m) {
        this.__onOrientationChange && this.__onOrientationChange(f, m);
      },
      _onShake: function(f, m) {
        this.__onShake && this.__onShake(f, m);
      },
      _onLongPress: function(f, m) {
        this.__onLongPress && this.__onLongPress(f, m);
      },
      _onDragOver: function(f) {
        f.preventDefault();
        var m = this._simpleEventHandler("dragover", f);
        this._fireEnterLeaveEvents(m, f);
      },
      _onDrop: function(f) {
        return this._simpleEventHandler("drop:before", f), this._simpleEventHandler("drop", f);
      },
      _onContextMenu: function(f) {
        return this.stopContextMenu && (f.stopPropagation(), f.preventDefault()), !1;
      },
      _onDoubleClick: function(f) {
        this._cacheTransformEventData(f), this._handleEvent(f, "dblclick"), this._resetTransformEventData(f);
      },
      getPointerId: function(f) {
        var m = f.changedTouches;
        return m ? m[0] && m[0].identifier : this.enablePointerEvents ? f.pointerId : -1;
      },
      _isMainEvent: function(f) {
        return f.isPrimary === !0 ? !0 : f.isPrimary === !1 ? !1 : f.type === "touchend" && f.touches.length === 0 ? !0 : f.changedTouches ? f.changedTouches[0].identifier === this.mainTouchId : !0;
      },
      _onTouchStart: function(f) {
        f.preventDefault(), this.mainTouchId === null && (this.mainTouchId = this.getPointerId(f)), this.__onMouseDown(f), this._resetTransformEventData();
        var m = this.upperCanvasEl, d = this._getEventPrefix();
        a(e.document, "touchend", this._onTouchEnd, l), a(e.document, "touchmove", this._onMouseMove, l), n(m, d + "down", this._onMouseDown);
      },
      _onMouseDown: function(f) {
        this.__onMouseDown(f), this._resetTransformEventData();
        var m = this.upperCanvasEl, d = this._getEventPrefix();
        n(m, d + "move", this._onMouseMove, l), a(e.document, d + "up", this._onMouseUp), a(e.document, d + "move", this._onMouseMove, l);
      },
      _onTouchEnd: function(f) {
        if (!(f.touches.length > 0)) {
          this.__onMouseUp(f), this._resetTransformEventData(), this.mainTouchId = null;
          var m = this._getEventPrefix();
          n(e.document, "touchend", this._onTouchEnd, l), n(e.document, "touchmove", this._onMouseMove, l);
          var d = this;
          this._willAddMouseDown && clearTimeout(this._willAddMouseDown), this._willAddMouseDown = setTimeout(function() {
            a(d.upperCanvasEl, m + "down", d._onMouseDown), d._willAddMouseDown = 0;
          }, 400);
        }
      },
      _onMouseUp: function(f) {
        this.__onMouseUp(f), this._resetTransformEventData();
        var m = this.upperCanvasEl, d = this._getEventPrefix();
        this._isMainEvent(f) && (n(e.document, d + "up", this._onMouseUp), n(e.document, d + "move", this._onMouseMove, l), a(m, d + "move", this._onMouseMove, l));
      },
      _onMouseMove: function(f) {
        !this.allowTouchScrolling && f.preventDefault && f.preventDefault(), this.__onMouseMove(f);
      },
      _onResize: function() {
        this.calcOffset();
      },
      _shouldRender: function(f) {
        var m = this._activeObject;
        return !!m != !!f || m && f && m !== f ? !0 : (m && m.isEditing, !1);
      },
      __onMouseUp: function(f) {
        var m, d = this._currentTransform, v = this._groupSelector, b = !1, y = !v || v.left === 0 && v.top === 0;
        if (this._cacheTransformEventData(f), m = this._target, this._handleEvent(f, "up:before"), c(f, u)) {
          this.fireRightClick && this._handleEvent(f, "up", u, y);
          return;
        }
        if (c(f, h)) {
          this.fireMiddleClick && this._handleEvent(f, "up", h, y), this._resetTransformEventData();
          return;
        }
        if (this.isDrawingMode && this._isCurrentlyDrawing) {
          this._onMouseUpInDrawingMode(f);
          return;
        }
        if (!!this._isMainEvent(f)) {
          if (d && (this._finalizeCurrentTransform(f), b = d.actionPerformed), !y) {
            var w = m === this._activeObject;
            this._maybeGroupObjects(f), b || (b = this._shouldRender(m) || !w && m === this._activeObject);
          }
          var _, S;
          if (m) {
            if (_ = m._findTargetCorner(
              this.getPointer(f, !0),
              e.util.isTouchEvent(f)
            ), m.selectable && m !== this._activeObject && m.activeOn === "up")
              this.setActiveObject(m, f), b = !0;
            else {
              var T = m.controls[_], A = T && T.getMouseUpHandler(f, m, T);
              A && (S = this.getPointer(f), A(f, d, S.x, S.y));
            }
            m.isMoving = !1;
          }
          if (d && (d.target !== m || d.corner !== _)) {
            var R = d.target && d.target.controls[d.corner], N = R && R.getMouseUpHandler(f, m, T);
            S = S || this.getPointer(f), N && N(f, d, S.x, S.y);
          }
          this._setCursorFromEvent(f, m), this._handleEvent(f, "up", s, y), this._groupSelector = null, this._currentTransform = null, m && (m.__corner = 0), b ? this.requestRenderAll() : y || this.renderTop();
        }
      },
      _simpleEventHandler: function(f, m) {
        var d = this.findTarget(m), v = this.targets, b = {
          e: m,
          target: d,
          subTargets: v
        };
        if (this.fire(f, b), d && d.fire(f, b), !v)
          return d;
        for (var y = 0; y < v.length; y++)
          v[y].fire(f, b);
        return d;
      },
      _handleEvent: function(f, m, d, v) {
        var b = this._target, y = this.targets || [], w = {
          e: f,
          target: b,
          subTargets: y,
          button: d || s,
          isClick: v || !1,
          pointer: this._pointer,
          absolutePointer: this._absolutePointer,
          transform: this._currentTransform
        };
        m === "up" && (w.currentTarget = this.findTarget(f), w.currentSubTargets = this.targets), this.fire("mouse:" + m, w), b && b.fire("mouse" + m, w);
        for (var _ = 0; _ < y.length; _++)
          y[_].fire("mouse" + m, w);
      },
      _finalizeCurrentTransform: function(f) {
        var m = this._currentTransform, d = m.target, v = {
          e: f,
          target: d,
          transform: m,
          action: m.action
        };
        d._scaling && (d._scaling = !1), d.setCoords(), (m.actionPerformed || this.stateful && d.hasStateChanged()) && this._fire("modified", v);
      },
      _onMouseDownInDrawingMode: function(f) {
        this._isCurrentlyDrawing = !0, this.getActiveObject() && this.discardActiveObject(f).requestRenderAll();
        var m = this.getPointer(f);
        this.freeDrawingBrush.onMouseDown(m, { e: f, pointer: m }), this._handleEvent(f, "down");
      },
      _onMouseMoveInDrawingMode: function(f) {
        if (this._isCurrentlyDrawing) {
          var m = this.getPointer(f);
          this.freeDrawingBrush.onMouseMove(m, { e: f, pointer: m });
        }
        this.setCursor(this.freeDrawingCursor), this._handleEvent(f, "move");
      },
      _onMouseUpInDrawingMode: function(f) {
        var m = this.getPointer(f);
        this._isCurrentlyDrawing = this.freeDrawingBrush.onMouseUp({ e: f, pointer: m }), this._handleEvent(f, "up");
      },
      __onMouseDown: function(f) {
        this._cacheTransformEventData(f), this._handleEvent(f, "down:before");
        var m = this._target;
        if (c(f, u)) {
          this.fireRightClick && this._handleEvent(f, "down", u);
          return;
        }
        if (c(f, h)) {
          this.fireMiddleClick && this._handleEvent(f, "down", h);
          return;
        }
        if (this.isDrawingMode) {
          this._onMouseDownInDrawingMode(f);
          return;
        }
        if (!!this._isMainEvent(f) && !this._currentTransform) {
          var d = this._pointer;
          this._previousPointer = d;
          var v = this._shouldRender(m), b = this._shouldGroup(f, m);
          if (this._shouldClearSelection(f, m) ? this.discardActiveObject(f) : b && (this._handleGrouping(f, m), m = this._activeObject), this.selection && (!m || !m.selectable && !m.isEditing && m !== this._activeObject) && (this._groupSelector = {
            ex: this._absolutePointer.x,
            ey: this._absolutePointer.y,
            top: 0,
            left: 0
          }), m) {
            var y = m === this._activeObject;
            m.selectable && m.activeOn === "down" && this.setActiveObject(m, f);
            var w = m._findTargetCorner(
              this.getPointer(f, !0),
              e.util.isTouchEvent(f)
            );
            if (m.__corner = w, m === this._activeObject && (w || !b)) {
              this._setupCurrentTransform(f, m, y);
              var _ = m.controls[w], d = this.getPointer(f), S = _ && _.getMouseDownHandler(f, m, _);
              S && S(f, this._currentTransform, d.x, d.y);
            }
          }
          this._handleEvent(f, "down"), (v || b) && this.requestRenderAll();
        }
      },
      _resetTransformEventData: function() {
        this._target = null, this._pointer = null, this._absolutePointer = null;
      },
      _cacheTransformEventData: function(f) {
        this._resetTransformEventData(), this._pointer = this.getPointer(f, !0), this._absolutePointer = this.restorePointerVpt(this._pointer), this._target = this._currentTransform ? this._currentTransform.target : this.findTarget(f) || null;
      },
      _beforeTransform: function(f) {
        var m = this._currentTransform;
        this.stateful && m.target.saveState(), this.fire("before:transform", {
          e: f,
          transform: m
        });
      },
      __onMouseMove: function(f) {
        this._handleEvent(f, "move:before"), this._cacheTransformEventData(f);
        var m, d;
        if (this.isDrawingMode) {
          this._onMouseMoveInDrawingMode(f);
          return;
        }
        if (!!this._isMainEvent(f)) {
          var v = this._groupSelector;
          v ? (d = this._absolutePointer, v.left = d.x - v.ex, v.top = d.y - v.ey, this.renderTop()) : this._currentTransform ? this._transformObject(f) : (m = this.findTarget(f) || null, this._setCursorFromEvent(f, m), this._fireOverOutEvents(m, f)), this._handleEvent(f, "move"), this._resetTransformEventData();
        }
      },
      _fireOverOutEvents: function(f, m) {
        var d = this._hoveredTarget, v = this._hoveredTargets, b = this.targets, y = Math.max(v.length, b.length);
        this.fireSyntheticInOutEvents(f, m, {
          oldTarget: d,
          evtOut: "mouseout",
          canvasEvtOut: "mouse:out",
          evtIn: "mouseover",
          canvasEvtIn: "mouse:over"
        });
        for (var w = 0; w < y; w++)
          this.fireSyntheticInOutEvents(b[w], m, {
            oldTarget: v[w],
            evtOut: "mouseout",
            evtIn: "mouseover"
          });
        this._hoveredTarget = f, this._hoveredTargets = this.targets.concat();
      },
      _fireEnterLeaveEvents: function(f, m) {
        var d = this._draggedoverTarget, v = this._hoveredTargets, b = this.targets, y = Math.max(v.length, b.length);
        this.fireSyntheticInOutEvents(f, m, {
          oldTarget: d,
          evtOut: "dragleave",
          evtIn: "dragenter"
        });
        for (var w = 0; w < y; w++)
          this.fireSyntheticInOutEvents(b[w], m, {
            oldTarget: v[w],
            evtOut: "dragleave",
            evtIn: "dragenter"
          });
        this._draggedoverTarget = f;
      },
      fireSyntheticInOutEvents: function(f, m, d) {
        var v, b, y = d.oldTarget, w, _, S = y !== f, T = d.canvasEvtIn, A = d.canvasEvtOut;
        S && (v = { e: m, target: f, previousTarget: y }, b = { e: m, target: y, nextTarget: f }), _ = f && S, w = y && S, w && (A && this.fire(A, b), y.fire(d.evtOut, b)), _ && (T && this.fire(T, v), f.fire(d.evtIn, v));
      },
      __onMouseWheel: function(f) {
        this._cacheTransformEventData(f), this._handleEvent(f, "wheel"), this._resetTransformEventData();
      },
      _transformObject: function(f) {
        var m = this.getPointer(f), d = this._currentTransform;
        d.reset = !1, d.shiftKey = f.shiftKey, d.altKey = f[this.centeredKey], this._performTransformAction(f, d, m), d.actionPerformed && this.requestRenderAll();
      },
      _performTransformAction: function(f, m, d) {
        var v = d.x, b = d.y, y = m.action, w = !1, _ = m.actionHandler;
        _ && (w = _(f, m, v, b)), y === "drag" && w && (m.target.isMoving = !0, this.setCursor(m.target.moveCursor || this.moveCursor)), m.actionPerformed = m.actionPerformed || w;
      },
      _fire: e.controlsUtils.fireEvent,
      _setCursorFromEvent: function(f, m) {
        if (!m)
          return this.setCursor(this.defaultCursor), !1;
        var d = m.hoverCursor || this.hoverCursor, v = this._activeObject && this._activeObject.type === "activeSelection" ? this._activeObject : null, b = (!v || !v.contains(m)) && m._findTargetCorner(this.getPointer(f, !0));
        b ? this.setCursor(this.getCornerCursor(b, m, f)) : (m.subTargetCheck && this.targets.concat().reverse().map(function(y) {
          d = y.hoverCursor || d;
        }), this.setCursor(d));
      },
      getCornerCursor: function(f, m, d) {
        var v = m.controls[f];
        return v.cursorStyleHandler(d, v, m);
      }
    });
  }(), function() {
    var a = Math.min, n = Math.max;
    e.util.object.extend(e.Canvas.prototype, {
      _shouldGroup: function(u, h) {
        var s = this._activeObject;
        return s && this._isSelectionKeyPressed(u) && h && h.selectable && this.selection && (s !== h || s.type === "activeSelection") && !h.onSelect({ e: u });
      },
      _handleGrouping: function(u, h) {
        var s = this._activeObject;
        s.__corner || h === s && (h = this.findTarget(u, !0), !h || !h.selectable) || (s && s.type === "activeSelection" ? this._updateActiveSelection(h, u) : this._createActiveSelection(h, u));
      },
      _updateActiveSelection: function(u, h) {
        var s = this._activeObject, l = s._objects.slice(0);
        s.contains(u) ? (s.removeWithUpdate(u), this._hoveredTarget = u, this._hoveredTargets = this.targets.concat(), s.size() === 1 && this._setActiveObject(s.item(0), h)) : (s.addWithUpdate(u), this._hoveredTarget = s, this._hoveredTargets = this.targets.concat()), this._fireSelectionEvents(l, h);
      },
      _createActiveSelection: function(u, h) {
        var s = this.getActiveObjects(), l = this._createGroup(u);
        this._hoveredTarget = l, this._setActiveObject(l, h), this._fireSelectionEvents(s, h);
      },
      _createGroup: function(u) {
        var h = this._objects, s = h.indexOf(this._activeObject) < h.indexOf(u), l = s ? [this._activeObject, u] : [u, this._activeObject];
        return this._activeObject.isEditing && this._activeObject.exitEditing(), new e.ActiveSelection(l, {
          canvas: this
        });
      },
      _groupSelectedObjects: function(u) {
        var h = this._collectObjects(u), s;
        h.length === 1 ? this.setActiveObject(h[0], u) : h.length > 1 && (s = new e.ActiveSelection(h.reverse(), {
          canvas: this
        }), this.setActiveObject(s, u));
      },
      _collectObjects: function(u) {
        for (var h = [], s, l = this._groupSelector.ex, c = this._groupSelector.ey, f = l + this._groupSelector.left, m = c + this._groupSelector.top, d = new e.Point(a(l, f), a(c, m)), v = new e.Point(n(l, f), n(c, m)), b = !this.selectionFullyContained, y = l === f && c === m, w = this._objects.length; w-- && (s = this._objects[w], !(!(!s || !s.selectable || !s.visible) && (b && s.intersectsWithRect(d, v, !0) || s.isContainedWithinRect(d, v, !0) || b && s.containsPoint(d, null, !0) || b && s.containsPoint(v, null, !0)) && (h.push(s), y))); )
          ;
        return h.length > 1 && (h = h.filter(function(_) {
          return !_.onSelect({ e: u });
        })), h;
      },
      _maybeGroupObjects: function(u) {
        this.selection && this._groupSelector && this._groupSelectedObjects(u), this.setCursor(this.defaultCursor), this._groupSelector = null;
      }
    });
  }(), function() {
    e.util.object.extend(e.StaticCanvas.prototype, {
      toDataURL: function(a) {
        a || (a = {});
        var n = a.format || "png", u = a.quality || 1, h = (a.multiplier || 1) * (a.enableRetinaScaling ? this.getRetinaScaling() : 1), s = this.toCanvasElement(h, a);
        return e.util.toDataURL(s, n, u);
      },
      toCanvasElement: function(a, n) {
        a = a || 1, n = n || {};
        var u = (n.width || this.width) * a, h = (n.height || this.height) * a, s = this.getZoom(), l = this.width, c = this.height, f = s * a, m = this.viewportTransform, d = (m[4] - (n.left || 0)) * a, v = (m[5] - (n.top || 0)) * a, b = this.interactive, y = [f, 0, 0, f, d, v], w = this.enableRetinaScaling, _ = e.util.createCanvasElement(), S = this.contextTop;
        return _.width = u, _.height = h, this.contextTop = null, this.enableRetinaScaling = !1, this.interactive = !1, this.viewportTransform = y, this.width = u, this.height = h, this.calcViewportBoundaries(), this.renderCanvas(_.getContext("2d"), this._objects), this.viewportTransform = m, this.width = l, this.height = c, this.calcViewportBoundaries(), this.interactive = b, this.enableRetinaScaling = w, this.contextTop = S, _;
      }
    });
  }(), e.util.object.extend(e.StaticCanvas.prototype, {
    loadFromJSON: function(a, n, u) {
      if (!!a) {
        var h = typeof a == "string" ? JSON.parse(a) : e.util.object.clone(a), s = this, l = h.clipPath, c = this.renderOnAddRemove;
        return this.renderOnAddRemove = !1, delete h.clipPath, this._enlivenObjects(h.objects, function(f) {
          s.clear(), s._setBgOverlay(h, function() {
            l ? s._enlivenObjects([l], function(m) {
              s.clipPath = m[0], s.__setupCanvas.call(s, h, f, c, n);
            }) : s.__setupCanvas.call(s, h, f, c, n);
          });
        }, u), this;
      }
    },
    __setupCanvas: function(a, n, u, h) {
      var s = this;
      n.forEach(function(l, c) {
        s.insertAt(l, c);
      }), this.renderOnAddRemove = u, delete a.objects, delete a.backgroundImage, delete a.overlayImage, delete a.background, delete a.overlay, this._setOptions(a), this.renderAll(), h && h();
    },
    _setBgOverlay: function(a, n) {
      var u = {
        backgroundColor: !1,
        overlayColor: !1,
        backgroundImage: !1,
        overlayImage: !1
      };
      if (!a.backgroundImage && !a.overlayImage && !a.background && !a.overlay) {
        n && n();
        return;
      }
      var h = function() {
        u.backgroundImage && u.overlayImage && u.backgroundColor && u.overlayColor && n && n();
      };
      this.__setBgOverlay("backgroundImage", a.backgroundImage, u, h), this.__setBgOverlay("overlayImage", a.overlayImage, u, h), this.__setBgOverlay("backgroundColor", a.background, u, h), this.__setBgOverlay("overlayColor", a.overlay, u, h);
    },
    __setBgOverlay: function(a, n, u, h) {
      var s = this;
      if (!n) {
        u[a] = !0, h && h();
        return;
      }
      a === "backgroundImage" || a === "overlayImage" ? e.util.enlivenObjects([n], function(l) {
        s[a] = l[0], u[a] = !0, h && h();
      }) : this["set" + e.util.string.capitalize(a, !0)](n, function() {
        u[a] = !0, h && h();
      });
    },
    _enlivenObjects: function(a, n, u) {
      if (!a || a.length === 0) {
        n && n([]);
        return;
      }
      e.util.enlivenObjects(a, function(h) {
        n && n(h);
      }, null, u);
    },
    _toDataURL: function(a, n) {
      this.clone(function(u) {
        n(u.toDataURL(a));
      });
    },
    _toDataURLWithMultiplier: function(a, n, u) {
      this.clone(function(h) {
        u(h.toDataURLWithMultiplier(a, n));
      });
    },
    clone: function(a, n) {
      var u = JSON.stringify(this.toJSON(n));
      this.cloneWithoutData(function(h) {
        h.loadFromJSON(u, function() {
          a && a(h);
        });
      });
    },
    cloneWithoutData: function(a) {
      var n = e.util.createCanvasElement();
      n.width = this.width, n.height = this.height;
      var u = new e.Canvas(n);
      this.backgroundImage ? (u.setBackgroundImage(this.backgroundImage.src, function() {
        u.renderAll(), a && a(u);
      }), u.backgroundImageOpacity = this.backgroundImageOpacity, u.backgroundImageStretch = this.backgroundImageStretch) : a && a(u);
    }
  }), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.util.object.extend, h = n.util.object.clone, s = n.util.toFixed, l = n.util.string.capitalize, c = n.util.degreesToRadians, f = !n.isLikelyNode, m = 2;
    n.Object || (n.Object = n.util.createClass(n.CommonMethods, {
      type: "object",
      originX: "left",
      originY: "top",
      top: 0,
      left: 0,
      width: 0,
      height: 0,
      scaleX: 1,
      scaleY: 1,
      flipX: !1,
      flipY: !1,
      opacity: 1,
      angle: 0,
      skewX: 0,
      skewY: 0,
      cornerSize: 13,
      touchCornerSize: 24,
      transparentCorners: !0,
      hoverCursor: null,
      moveCursor: null,
      padding: 0,
      borderColor: "rgb(178,204,255)",
      borderDashArray: null,
      cornerColor: "rgb(178,204,255)",
      cornerStrokeColor: null,
      cornerStyle: "rect",
      cornerDashArray: null,
      centeredScaling: !1,
      centeredRotation: !0,
      fill: "rgb(0,0,0)",
      fillRule: "nonzero",
      globalCompositeOperation: "source-over",
      backgroundColor: "",
      selectionBackgroundColor: "",
      stroke: null,
      strokeWidth: 1,
      strokeDashArray: null,
      strokeDashOffset: 0,
      strokeLineCap: "butt",
      strokeLineJoin: "miter",
      strokeMiterLimit: 4,
      shadow: null,
      borderOpacityWhenMoving: 0.4,
      borderScaleFactor: 1,
      minScaleLimit: 0,
      selectable: !0,
      evented: !0,
      visible: !0,
      hasControls: !0,
      hasBorders: !0,
      perPixelTargetFind: !1,
      includeDefaultValues: !0,
      lockMovementX: !1,
      lockMovementY: !1,
      lockRotation: !1,
      lockScalingX: !1,
      lockScalingY: !1,
      lockSkewingX: !1,
      lockSkewingY: !1,
      lockScalingFlip: !1,
      excludeFromExport: !1,
      objectCaching: f,
      statefullCache: !1,
      noScaleCache: !0,
      strokeUniform: !1,
      dirty: !0,
      __corner: 0,
      paintFirst: "fill",
      activeOn: "down",
      stateProperties: "top left width height scaleX scaleY flipX flipY originX originY transformMatrix stroke strokeWidth strokeDashArray strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit angle opacity fill globalCompositeOperation shadow visible backgroundColor skewX skewY fillRule paintFirst clipPath strokeUniform".split(" "),
      cacheProperties: "fill stroke strokeWidth strokeDashArray width height paintFirst strokeUniform strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit backgroundColor clipPath".split(" "),
      colorProperties: "fill stroke backgroundColor".split(" "),
      clipPath: void 0,
      inverted: !1,
      absolutePositioned: !1,
      initialize: function(d) {
        d && this.setOptions(d);
      },
      _createCacheCanvas: function() {
        this._cacheProperties = {}, this._cacheCanvas = n.util.createCanvasElement(), this._cacheContext = this._cacheCanvas.getContext("2d"), this._updateCacheCanvas(), this.dirty = !0;
      },
      _limitCacheSize: function(d) {
        var v = n.perfLimitSizeTotal, b = d.width, y = d.height, w = n.maxCacheSideLimit, _ = n.minCacheSideLimit;
        if (b <= w && y <= w && b * y <= v)
          return b < _ && (d.width = _), y < _ && (d.height = _), d;
        var S = b / y, T = n.util.limitDimsByArea(S, v), A = n.util.capValue, R = A(_, T.x, w), N = A(_, T.y, w);
        return b > R && (d.zoomX /= b / R, d.width = R, d.capped = !0), y > N && (d.zoomY /= y / N, d.height = N, d.capped = !0), d;
      },
      _getCacheCanvasDimensions: function() {
        var d = this.getTotalObjectScaling(), v = this._getTransformedDimensions(0, 0), b = v.x * d.scaleX / this.scaleX, y = v.y * d.scaleY / this.scaleY;
        return {
          width: b + m,
          height: y + m,
          zoomX: d.scaleX,
          zoomY: d.scaleY,
          x: b,
          y
        };
      },
      _updateCacheCanvas: function() {
        var d = this.canvas;
        if (this.noScaleCache && d && d._currentTransform) {
          var v = d._currentTransform.target, b = d._currentTransform.action;
          if (this === v && b.slice && b.slice(0, 5) === "scale")
            return !1;
        }
        var y = this._cacheCanvas, w = this._limitCacheSize(this._getCacheCanvasDimensions()), _ = n.minCacheSideLimit, S = w.width, T = w.height, A, R, N = w.zoomX, U = w.zoomY, Q = S !== this.cacheWidth || T !== this.cacheHeight, ee = this.zoomX !== N || this.zoomY !== U, J = Q || ee, q = 0, re = 0, le = !1;
        if (Q) {
          var ne = this._cacheCanvas.width, C = this._cacheCanvas.height, k = S > ne || T > C, P = (S < ne * 0.9 || T < C * 0.9) && ne > _ && C > _;
          le = k || P, k && !w.capped && (S > _ || T > _) && (q = S * 0.1, re = T * 0.1);
        }
        return this instanceof n.Text && this.path && (J = !0, le = !0, q += this.getHeightOfLine(0) * this.zoomX, re += this.getHeightOfLine(0) * this.zoomY), J ? (le ? (y.width = Math.ceil(S + q), y.height = Math.ceil(T + re)) : (this._cacheContext.setTransform(1, 0, 0, 1, 0, 0), this._cacheContext.clearRect(0, 0, y.width, y.height)), A = w.x / 2, R = w.y / 2, this.cacheTranslationX = Math.round(y.width / 2 - A) + A, this.cacheTranslationY = Math.round(y.height / 2 - R) + R, this.cacheWidth = S, this.cacheHeight = T, this._cacheContext.translate(this.cacheTranslationX, this.cacheTranslationY), this._cacheContext.scale(N, U), this.zoomX = N, this.zoomY = U, !0) : !1;
      },
      setOptions: function(d) {
        this._setOptions(d), this._initGradient(d.fill, "fill"), this._initGradient(d.stroke, "stroke"), this._initPattern(d.fill, "fill"), this._initPattern(d.stroke, "stroke");
      },
      transform: function(d) {
        var v = this.group && !this.group._transformDone || this.group && this.canvas && d === this.canvas.contextTop, b = this.calcTransformMatrix(!v);
        d.transform(b[0], b[1], b[2], b[3], b[4], b[5]);
      },
      toObject: function(d) {
        var v = n.Object.NUM_FRACTION_DIGITS, b = {
          type: this.type,
          version: n.version,
          originX: this.originX,
          originY: this.originY,
          left: s(this.left, v),
          top: s(this.top, v),
          width: s(this.width, v),
          height: s(this.height, v),
          fill: this.fill && this.fill.toObject ? this.fill.toObject() : this.fill,
          stroke: this.stroke && this.stroke.toObject ? this.stroke.toObject() : this.stroke,
          strokeWidth: s(this.strokeWidth, v),
          strokeDashArray: this.strokeDashArray ? this.strokeDashArray.concat() : this.strokeDashArray,
          strokeLineCap: this.strokeLineCap,
          strokeDashOffset: this.strokeDashOffset,
          strokeLineJoin: this.strokeLineJoin,
          strokeUniform: this.strokeUniform,
          strokeMiterLimit: s(this.strokeMiterLimit, v),
          scaleX: s(this.scaleX, v),
          scaleY: s(this.scaleY, v),
          angle: s(this.angle, v),
          flipX: this.flipX,
          flipY: this.flipY,
          opacity: s(this.opacity, v),
          shadow: this.shadow && this.shadow.toObject ? this.shadow.toObject() : this.shadow,
          visible: this.visible,
          backgroundColor: this.backgroundColor,
          fillRule: this.fillRule,
          paintFirst: this.paintFirst,
          globalCompositeOperation: this.globalCompositeOperation,
          skewX: s(this.skewX, v),
          skewY: s(this.skewY, v)
        };
        return this.clipPath && !this.clipPath.excludeFromExport && (b.clipPath = this.clipPath.toObject(d), b.clipPath.inverted = this.clipPath.inverted, b.clipPath.absolutePositioned = this.clipPath.absolutePositioned), n.util.populateWithProperties(this, b, d), this.includeDefaultValues || (b = this._removeDefaultValues(b)), b;
      },
      toDatalessObject: function(d) {
        return this.toObject(d);
      },
      _removeDefaultValues: function(d) {
        var v = n.util.getKlass(d.type).prototype, b = v.stateProperties;
        return b.forEach(function(y) {
          y === "left" || y === "top" || (d[y] === v[y] && delete d[y], Array.isArray(d[y]) && Array.isArray(v[y]) && d[y].length === 0 && v[y].length === 0 && delete d[y]);
        }), d;
      },
      toString: function() {
        return "#<fabric." + l(this.type) + ">";
      },
      getObjectScaling: function() {
        if (!this.group)
          return {
            scaleX: this.scaleX,
            scaleY: this.scaleY
          };
        var d = n.util.qrDecompose(this.calcTransformMatrix());
        return { scaleX: Math.abs(d.scaleX), scaleY: Math.abs(d.scaleY) };
      },
      getTotalObjectScaling: function() {
        var d = this.getObjectScaling(), v = d.scaleX, b = d.scaleY;
        if (this.canvas) {
          var y = this.canvas.getZoom(), w = this.canvas.getRetinaScaling();
          v *= y * w, b *= y * w;
        }
        return { scaleX: v, scaleY: b };
      },
      getObjectOpacity: function() {
        var d = this.opacity;
        return this.group && (d *= this.group.getObjectOpacity()), d;
      },
      _set: function(d, v) {
        var b = d === "scaleX" || d === "scaleY", y = this[d] !== v, w = !1;
        return b && (v = this._constrainScale(v)), d === "scaleX" && v < 0 ? (this.flipX = !this.flipX, v *= -1) : d === "scaleY" && v < 0 ? (this.flipY = !this.flipY, v *= -1) : d === "shadow" && v && !(v instanceof n.Shadow) ? v = new n.Shadow(v) : d === "dirty" && this.group && this.group.set("dirty", v), this[d] = v, y && (w = this.group && this.group.isOnACache(), this.cacheProperties.indexOf(d) > -1 ? (this.dirty = !0, w && this.group.set("dirty", !0)) : w && this.stateProperties.indexOf(d) > -1 && this.group.set("dirty", !0)), this;
      },
      setOnGroup: function() {
      },
      getViewportTransform: function() {
        return this.canvas && this.canvas.viewportTransform ? this.canvas.viewportTransform : n.iMatrix.concat();
      },
      isNotVisible: function() {
        return this.opacity === 0 || !this.width && !this.height && this.strokeWidth === 0 || !this.visible;
      },
      render: function(d) {
        this.isNotVisible() || this.canvas && this.canvas.skipOffscreen && !this.group && !this.isOnScreen() || (d.save(), this._setupCompositeOperation(d), this.drawSelectionBackground(d), this.transform(d), this._setOpacity(d), this._setShadow(d, this), this.shouldCache() ? (this.renderCache(), this.drawCacheOnCanvas(d)) : (this._removeCacheCanvas(), this.dirty = !1, this.drawObject(d), this.objectCaching && this.statefullCache && this.saveState({ propertySet: "cacheProperties" })), d.restore());
      },
      renderCache: function(d) {
        d = d || {}, (!this._cacheCanvas || !this._cacheContext) && this._createCacheCanvas(), this.isCacheDirty() && (this.statefullCache && this.saveState({ propertySet: "cacheProperties" }), this.drawObject(this._cacheContext, d.forClipping), this.dirty = !1);
      },
      _removeCacheCanvas: function() {
        this._cacheCanvas = null, this._cacheContext = null, this.cacheWidth = 0, this.cacheHeight = 0;
      },
      hasStroke: function() {
        return this.stroke && this.stroke !== "transparent" && this.strokeWidth !== 0;
      },
      hasFill: function() {
        return this.fill && this.fill !== "transparent";
      },
      needsItsOwnCache: function() {
        return !!(this.paintFirst === "stroke" && this.hasFill() && this.hasStroke() && typeof this.shadow == "object" || this.clipPath);
      },
      shouldCache: function() {
        return this.ownCaching = this.needsItsOwnCache() || this.objectCaching && (!this.group || !this.group.isOnACache()), this.ownCaching;
      },
      willDrawShadow: function() {
        return !!this.shadow && (this.shadow.offsetX !== 0 || this.shadow.offsetY !== 0);
      },
      drawClipPathOnCache: function(d, v) {
        if (d.save(), v.inverted ? d.globalCompositeOperation = "destination-out" : d.globalCompositeOperation = "destination-in", v.absolutePositioned) {
          var b = n.util.invertTransform(this.calcTransformMatrix());
          d.transform(b[0], b[1], b[2], b[3], b[4], b[5]);
        }
        v.transform(d), d.scale(1 / v.zoomX, 1 / v.zoomY), d.drawImage(v._cacheCanvas, -v.cacheTranslationX, -v.cacheTranslationY), d.restore();
      },
      drawObject: function(d, v) {
        var b = this.fill, y = this.stroke;
        v ? (this.fill = "black", this.stroke = "", this._setClippingProperties(d)) : this._renderBackground(d), this._render(d), this._drawClipPath(d, this.clipPath), this.fill = b, this.stroke = y;
      },
      _drawClipPath: function(d, v) {
        !v || (v.canvas = this.canvas, v.shouldCache(), v._transformDone = !0, v.renderCache({ forClipping: !0 }), this.drawClipPathOnCache(d, v));
      },
      drawCacheOnCanvas: function(d) {
        d.scale(1 / this.zoomX, 1 / this.zoomY), d.drawImage(this._cacheCanvas, -this.cacheTranslationX, -this.cacheTranslationY);
      },
      isCacheDirty: function(d) {
        if (this.isNotVisible())
          return !1;
        if (this._cacheCanvas && this._cacheContext && !d && this._updateCacheCanvas())
          return !0;
        if (this.dirty || this.clipPath && this.clipPath.absolutePositioned || this.statefullCache && this.hasStateChanged("cacheProperties")) {
          if (this._cacheCanvas && this._cacheContext && !d) {
            var v = this.cacheWidth / this.zoomX, b = this.cacheHeight / this.zoomY;
            this._cacheContext.clearRect(-v / 2, -b / 2, v, b);
          }
          return !0;
        }
        return !1;
      },
      _renderBackground: function(d) {
        if (!!this.backgroundColor) {
          var v = this._getNonTransformedDimensions();
          d.fillStyle = this.backgroundColor, d.fillRect(
            -v.x / 2,
            -v.y / 2,
            v.x,
            v.y
          ), this._removeShadow(d);
        }
      },
      _setOpacity: function(d) {
        this.group && !this.group._transformDone ? d.globalAlpha = this.getObjectOpacity() : d.globalAlpha *= this.opacity;
      },
      _setStrokeStyles: function(d, v) {
        var b = v.stroke;
        b && (d.lineWidth = v.strokeWidth, d.lineCap = v.strokeLineCap, d.lineDashOffset = v.strokeDashOffset, d.lineJoin = v.strokeLineJoin, d.miterLimit = v.strokeMiterLimit, b.toLive ? b.gradientUnits === "percentage" || b.gradientTransform || b.patternTransform ? this._applyPatternForTransformedGradient(d, b) : (d.strokeStyle = b.toLive(d, this), this._applyPatternGradientTransform(d, b)) : d.strokeStyle = v.stroke);
      },
      _setFillStyles: function(d, v) {
        var b = v.fill;
        b && (b.toLive ? (d.fillStyle = b.toLive(d, this), this._applyPatternGradientTransform(d, v.fill)) : d.fillStyle = b);
      },
      _setClippingProperties: function(d) {
        d.globalAlpha = 1, d.strokeStyle = "transparent", d.fillStyle = "#000000";
      },
      _setLineDash: function(d, v) {
        !v || v.length === 0 || (1 & v.length && v.push.apply(v, v), d.setLineDash(v));
      },
      _renderControls: function(d, v) {
        var b = this.getViewportTransform(), y = this.calcTransformMatrix(), w, _, S;
        v = v || {}, _ = typeof v.hasBorders < "u" ? v.hasBorders : this.hasBorders, S = typeof v.hasControls < "u" ? v.hasControls : this.hasControls, y = n.util.multiplyTransformMatrices(b, y), w = n.util.qrDecompose(y), d.save(), d.translate(w.translateX, w.translateY), d.lineWidth = 1 * this.borderScaleFactor, this.group || (d.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1), this.flipX && (w.angle -= 180), d.rotate(c(this.group ? w.angle : this.angle)), v.forActiveSelection || this.group ? _ && this.drawBordersInGroup(d, w, v) : _ && this.drawBorders(d, v), S && this.drawControls(d, v), d.restore();
      },
      _setShadow: function(d) {
        if (!!this.shadow) {
          var v = this.shadow, b = this.canvas, y, w = b && b.viewportTransform[0] || 1, _ = b && b.viewportTransform[3] || 1;
          v.nonScaling ? y = { scaleX: 1, scaleY: 1 } : y = this.getObjectScaling(), b && b._isRetinaScaling() && (w *= n.devicePixelRatio, _ *= n.devicePixelRatio), d.shadowColor = v.color, d.shadowBlur = v.blur * n.browserShadowBlurConstant * (w + _) * (y.scaleX + y.scaleY) / 4, d.shadowOffsetX = v.offsetX * w * y.scaleX, d.shadowOffsetY = v.offsetY * _ * y.scaleY;
        }
      },
      _removeShadow: function(d) {
        !this.shadow || (d.shadowColor = "", d.shadowBlur = d.shadowOffsetX = d.shadowOffsetY = 0);
      },
      _applyPatternGradientTransform: function(d, v) {
        if (!v || !v.toLive)
          return { offsetX: 0, offsetY: 0 };
        var b = v.gradientTransform || v.patternTransform, y = -this.width / 2 + v.offsetX || 0, w = -this.height / 2 + v.offsetY || 0;
        return v.gradientUnits === "percentage" ? d.transform(this.width, 0, 0, this.height, y, w) : d.transform(1, 0, 0, 1, y, w), b && d.transform(b[0], b[1], b[2], b[3], b[4], b[5]), { offsetX: y, offsetY: w };
      },
      _renderPaintInOrder: function(d) {
        this.paintFirst === "stroke" ? (this._renderStroke(d), this._renderFill(d)) : (this._renderFill(d), this._renderStroke(d));
      },
      _render: function() {
      },
      _renderFill: function(d) {
        !this.fill || (d.save(), this._setFillStyles(d, this), this.fillRule === "evenodd" ? d.fill("evenodd") : d.fill(), d.restore());
      },
      _renderStroke: function(d) {
        if (!(!this.stroke || this.strokeWidth === 0)) {
          if (this.shadow && !this.shadow.affectStroke && this._removeShadow(d), d.save(), this.strokeUniform && this.group) {
            var v = this.getObjectScaling();
            d.scale(1 / v.scaleX, 1 / v.scaleY);
          } else
            this.strokeUniform && d.scale(1 / this.scaleX, 1 / this.scaleY);
          this._setLineDash(d, this.strokeDashArray), this._setStrokeStyles(d, this), d.stroke(), d.restore();
        }
      },
      _applyPatternForTransformedGradient: function(d, v) {
        var b = this._limitCacheSize(this._getCacheCanvasDimensions()), y = n.util.createCanvasElement(), w, _ = this.canvas.getRetinaScaling(), S = b.x / this.scaleX / _, T = b.y / this.scaleY / _;
        y.width = S, y.height = T, w = y.getContext("2d"), w.beginPath(), w.moveTo(0, 0), w.lineTo(S, 0), w.lineTo(S, T), w.lineTo(0, T), w.closePath(), w.translate(S / 2, T / 2), w.scale(
          b.zoomX / this.scaleX / _,
          b.zoomY / this.scaleY / _
        ), this._applyPatternGradientTransform(w, v), w.fillStyle = v.toLive(d), w.fill(), d.translate(-this.width / 2 - this.strokeWidth / 2, -this.height / 2 - this.strokeWidth / 2), d.scale(
          _ * this.scaleX / b.zoomX,
          _ * this.scaleY / b.zoomY
        ), d.strokeStyle = w.createPattern(y, "no-repeat");
      },
      _findCenterFromElement: function() {
        return { x: this.left + this.width / 2, y: this.top + this.height / 2 };
      },
      _assignTransformMatrixProps: function() {
        if (this.transformMatrix) {
          var d = n.util.qrDecompose(this.transformMatrix);
          this.flipX = !1, this.flipY = !1, this.set("scaleX", d.scaleX), this.set("scaleY", d.scaleY), this.angle = d.angle, this.skewX = d.skewX, this.skewY = 0;
        }
      },
      _removeTransformMatrix: function(d) {
        var v = this._findCenterFromElement();
        this.transformMatrix && (this._assignTransformMatrixProps(), v = n.util.transformPoint(v, this.transformMatrix)), this.transformMatrix = null, d && (this.scaleX *= d.scaleX, this.scaleY *= d.scaleY, this.cropX = d.cropX, this.cropY = d.cropY, v.x += d.offsetLeft, v.y += d.offsetTop, this.width = d.width, this.height = d.height), this.setPositionByOrigin(v, "center", "center");
      },
      clone: function(d, v) {
        var b = this.toObject(v);
        this.constructor.fromObject ? this.constructor.fromObject(b, d) : n.Object._fromObject("Object", b, d);
      },
      cloneAsImage: function(d, v) {
        var b = this.toCanvasElement(v);
        return d && d(new n.Image(b)), this;
      },
      toCanvasElement: function(d) {
        d || (d = {});
        var v = n.util, b = v.saveObjectTransform(this), y = this.group, w = this.shadow, _ = Math.abs, S = (d.multiplier || 1) * (d.enableRetinaScaling ? n.devicePixelRatio : 1);
        delete this.group, d.withoutTransform && v.resetObjectTransform(this), d.withoutShadow && (this.shadow = null);
        var T = n.util.createCanvasElement(), A = this.getBoundingRect(!0, !0), R = this.shadow, N, U = { x: 0, y: 0 }, Q, ee, J;
        R && (Q = R.blur, R.nonScaling ? N = { scaleX: 1, scaleY: 1 } : N = this.getObjectScaling(), U.x = 2 * Math.round(_(R.offsetX) + Q) * _(N.scaleX), U.y = 2 * Math.round(_(R.offsetY) + Q) * _(N.scaleY)), ee = A.width + U.x, J = A.height + U.y, T.width = Math.ceil(ee), T.height = Math.ceil(J);
        var q = new n.StaticCanvas(T, {
          enableRetinaScaling: !1,
          renderOnAddRemove: !1,
          skipOffscreen: !1
        });
        d.format === "jpeg" && (q.backgroundColor = "#fff"), this.setPositionByOrigin(new n.Point(q.width / 2, q.height / 2), "center", "center");
        var re = this.canvas;
        q.add(this);
        var le = q.toCanvasElement(S || 1, d);
        return this.shadow = w, this.set("canvas", re), y && (this.group = y), this.set(b).setCoords(), q._objects = [], q.dispose(), q = null, le;
      },
      toDataURL: function(d) {
        return d || (d = {}), n.util.toDataURL(this.toCanvasElement(d), d.format || "png", d.quality || 1);
      },
      isType: function(d) {
        return arguments.length > 1 ? Array.from(arguments).includes(this.type) : this.type === d;
      },
      complexity: function() {
        return 1;
      },
      toJSON: function(d) {
        return this.toObject(d);
      },
      rotate: function(d) {
        var v = (this.originX !== "center" || this.originY !== "center") && this.centeredRotation;
        return v && this._setOriginToCenter(), this.set("angle", d), v && this._resetOrigin(), this;
      },
      centerH: function() {
        return this.canvas && this.canvas.centerObjectH(this), this;
      },
      viewportCenterH: function() {
        return this.canvas && this.canvas.viewportCenterObjectH(this), this;
      },
      centerV: function() {
        return this.canvas && this.canvas.centerObjectV(this), this;
      },
      viewportCenterV: function() {
        return this.canvas && this.canvas.viewportCenterObjectV(this), this;
      },
      center: function() {
        return this.canvas && this.canvas.centerObject(this), this;
      },
      viewportCenter: function() {
        return this.canvas && this.canvas.viewportCenterObject(this), this;
      },
      getLocalPointer: function(d, v) {
        v = v || this.canvas.getPointer(d);
        var b = new n.Point(v.x, v.y), y = this._getLeftTopCoords();
        return this.angle && (b = n.util.rotatePoint(
          b,
          y,
          c(-this.angle)
        )), {
          x: b.x - y.x,
          y: b.y - y.y
        };
      },
      _setupCompositeOperation: function(d) {
        this.globalCompositeOperation && (d.globalCompositeOperation = this.globalCompositeOperation);
      },
      dispose: function() {
        n.runningAnimations && n.runningAnimations.cancelByTarget(this);
      }
    }), n.util.createAccessors && n.util.createAccessors(n.Object), u(n.Object.prototype, n.Observable), n.Object.NUM_FRACTION_DIGITS = 2, n.Object.ENLIVEN_PROPS = ["clipPath"], n.Object._fromObject = function(d, v, b, y) {
      var w = n[d];
      v = h(v, !0), n.util.enlivenPatterns([v.fill, v.stroke], function(_) {
        typeof _[0] < "u" && (v.fill = _[0]), typeof _[1] < "u" && (v.stroke = _[1]), n.util.enlivenObjectEnlivables(v, v, function() {
          var S = y ? new w(v[y], v) : new w(v);
          b && b(S);
        });
      });
    }, n.Object.__uid = 0);
  }(t), function() {
    var a = e.util.degreesToRadians, n = {
      left: -0.5,
      center: 0,
      right: 0.5
    }, u = {
      top: -0.5,
      center: 0,
      bottom: 0.5
    };
    e.util.object.extend(e.Object.prototype, {
      translateToGivenOrigin: function(h, s, l, c, f) {
        var m = h.x, d = h.y, v, b, y;
        return typeof s == "string" ? s = n[s] : s -= 0.5, typeof c == "string" ? c = n[c] : c -= 0.5, v = c - s, typeof l == "string" ? l = u[l] : l -= 0.5, typeof f == "string" ? f = u[f] : f -= 0.5, b = f - l, (v || b) && (y = this._getTransformedDimensions(), m = h.x + v * y.x, d = h.y + b * y.y), new e.Point(m, d);
      },
      translateToCenterPoint: function(h, s, l) {
        var c = this.translateToGivenOrigin(h, s, l, "center", "center");
        return this.angle ? e.util.rotatePoint(c, h, a(this.angle)) : c;
      },
      translateToOriginPoint: function(h, s, l) {
        var c = this.translateToGivenOrigin(h, "center", "center", s, l);
        return this.angle ? e.util.rotatePoint(c, h, a(this.angle)) : c;
      },
      getCenterPoint: function() {
        var h = new e.Point(this.left, this.top);
        return this.translateToCenterPoint(h, this.originX, this.originY);
      },
      getPointByOrigin: function(h, s) {
        var l = this.getCenterPoint();
        return this.translateToOriginPoint(l, h, s);
      },
      toLocalPoint: function(h, s, l) {
        var c = this.getCenterPoint(), f, m;
        return typeof s < "u" && typeof l < "u" ? f = this.translateToGivenOrigin(c, "center", "center", s, l) : f = new e.Point(this.left, this.top), m = new e.Point(h.x, h.y), this.angle && (m = e.util.rotatePoint(m, c, -a(this.angle))), m.subtractEquals(f);
      },
      setPositionByOrigin: function(h, s, l) {
        var c = this.translateToCenterPoint(h, s, l), f = this.translateToOriginPoint(c, this.originX, this.originY);
        this.set("left", f.x), this.set("top", f.y);
      },
      adjustPosition: function(h) {
        var s = a(this.angle), l = this.getScaledWidth(), c = e.util.cos(s) * l, f = e.util.sin(s) * l, m, d;
        typeof this.originX == "string" ? m = n[this.originX] : m = this.originX - 0.5, typeof h == "string" ? d = n[h] : d = h - 0.5, this.left += c * (d - m), this.top += f * (d - m), this.setCoords(), this.originX = h;
      },
      _setOriginToCenter: function() {
        this._originalOriginX = this.originX, this._originalOriginY = this.originY;
        var h = this.getCenterPoint();
        this.originX = "center", this.originY = "center", this.left = h.x, this.top = h.y;
      },
      _resetOrigin: function() {
        var h = this.translateToOriginPoint(
          this.getCenterPoint(),
          this._originalOriginX,
          this._originalOriginY
        );
        this.originX = this._originalOriginX, this.originY = this._originalOriginY, this.left = h.x, this.top = h.y, this._originalOriginX = null, this._originalOriginY = null;
      },
      _getLeftTopCoords: function() {
        return this.translateToOriginPoint(this.getCenterPoint(), "left", "top");
      }
    });
  }(), function() {
    function a(l) {
      return [
        new e.Point(l.tl.x, l.tl.y),
        new e.Point(l.tr.x, l.tr.y),
        new e.Point(l.br.x, l.br.y),
        new e.Point(l.bl.x, l.bl.y)
      ];
    }
    var n = e.util, u = n.degreesToRadians, h = n.multiplyTransformMatrices, s = n.transformPoint;
    n.object.extend(e.Object.prototype, {
      oCoords: null,
      aCoords: null,
      lineCoords: null,
      ownMatrixCache: null,
      matrixCache: null,
      controls: {},
      _getCoords: function(l, c) {
        return c ? l ? this.calcACoords() : this.calcLineCoords() : ((!this.aCoords || !this.lineCoords) && this.setCoords(!0), l ? this.aCoords : this.lineCoords);
      },
      getCoords: function(l, c) {
        return a(this._getCoords(l, c));
      },
      intersectsWithRect: function(l, c, f, m) {
        var d = this.getCoords(f, m), v = e.Intersection.intersectPolygonRectangle(
          d,
          l,
          c
        );
        return v.status === "Intersection";
      },
      intersectsWithObject: function(l, c, f) {
        var m = e.Intersection.intersectPolygonPolygon(
          this.getCoords(c, f),
          l.getCoords(c, f)
        );
        return m.status === "Intersection" || l.isContainedWithinObject(this, c, f) || this.isContainedWithinObject(l, c, f);
      },
      isContainedWithinObject: function(l, c, f) {
        for (var m = this.getCoords(c, f), d = c ? l.aCoords : l.lineCoords, v = 0, b = l._getImageLines(d); v < 4; v++)
          if (!l.containsPoint(m[v], b))
            return !1;
        return !0;
      },
      isContainedWithinRect: function(l, c, f, m) {
        var d = this.getBoundingRect(f, m);
        return d.left >= l.x && d.left + d.width <= c.x && d.top >= l.y && d.top + d.height <= c.y;
      },
      containsPoint: function(l, v, f, m) {
        var d = this._getCoords(f, m), v = v || this._getImageLines(d), b = this._findCrossPoints(l, v);
        return b !== 0 && b % 2 === 1;
      },
      isOnScreen: function(l) {
        if (!this.canvas)
          return !1;
        var c = this.canvas.vptCoords.tl, f = this.canvas.vptCoords.br, m = this.getCoords(!0, l);
        return m.some(function(d) {
          return d.x <= f.x && d.x >= c.x && d.y <= f.y && d.y >= c.y;
        }) || this.intersectsWithRect(c, f, !0, l) ? !0 : this._containsCenterOfCanvas(c, f, l);
      },
      _containsCenterOfCanvas: function(l, c, f) {
        var m = { x: (l.x + c.x) / 2, y: (l.y + c.y) / 2 };
        return !!this.containsPoint(m, null, !0, f);
      },
      isPartiallyOnScreen: function(l) {
        if (!this.canvas)
          return !1;
        var c = this.canvas.vptCoords.tl, f = this.canvas.vptCoords.br;
        if (this.intersectsWithRect(c, f, !0, l))
          return !0;
        var m = this.getCoords(!0, l).every(function(d) {
          return (d.x >= f.x || d.x <= c.x) && (d.y >= f.y || d.y <= c.y);
        });
        return m && this._containsCenterOfCanvas(c, f, l);
      },
      _getImageLines: function(l) {
        var c = {
          topline: {
            o: l.tl,
            d: l.tr
          },
          rightline: {
            o: l.tr,
            d: l.br
          },
          bottomline: {
            o: l.br,
            d: l.bl
          },
          leftline: {
            o: l.bl,
            d: l.tl
          }
        };
        return c;
      },
      _findCrossPoints: function(l, c) {
        var f, m, d, v, b, y = 0, w;
        for (var _ in c)
          if (w = c[_], !(w.o.y < l.y && w.d.y < l.y) && !(w.o.y >= l.y && w.d.y >= l.y) && (w.o.x === w.d.x && w.o.x >= l.x ? b = w.o.x : (f = 0, m = (w.d.y - w.o.y) / (w.d.x - w.o.x), d = l.y - f * l.x, v = w.o.y - m * w.o.x, b = -(d - v) / (f - m)), b >= l.x && (y += 1), y === 2))
            break;
        return y;
      },
      getBoundingRect: function(l, c) {
        var f = this.getCoords(l, c);
        return n.makeBoundingBoxFromPoints(f);
      },
      getScaledWidth: function() {
        return this._getTransformedDimensions().x;
      },
      getScaledHeight: function() {
        return this._getTransformedDimensions().y;
      },
      _constrainScale: function(l) {
        return Math.abs(l) < this.minScaleLimit ? l < 0 ? -this.minScaleLimit : this.minScaleLimit : l === 0 ? 1e-4 : l;
      },
      scale: function(l) {
        return this._set("scaleX", l), this._set("scaleY", l), this.setCoords();
      },
      scaleToWidth: function(l, c) {
        var f = this.getBoundingRect(c).width / this.getScaledWidth();
        return this.scale(l / this.width / f);
      },
      scaleToHeight: function(l, c) {
        var f = this.getBoundingRect(c).height / this.getScaledHeight();
        return this.scale(l / this.height / f);
      },
      calcLineCoords: function() {
        var l = this.getViewportTransform(), c = this.padding, f = u(this.angle), m = n.cos(f), d = n.sin(f), v = m * c, b = d * c, y = v + b, w = v - b, _ = this.calcACoords(), S = {
          tl: s(_.tl, l),
          tr: s(_.tr, l),
          bl: s(_.bl, l),
          br: s(_.br, l)
        };
        return c && (S.tl.x -= w, S.tl.y -= y, S.tr.x += y, S.tr.y -= w, S.bl.x -= y, S.bl.y += w, S.br.x += w, S.br.y += y), S;
      },
      calcOCoords: function() {
        var l = this._calcRotateMatrix(), c = this._calcTranslateMatrix(), f = this.getViewportTransform(), m = h(f, c), d = h(m, l), d = h(d, [1 / f[0], 0, 0, 1 / f[3], 0, 0]), v = this._calculateCurrentDimensions(), b = {};
        return this.forEachControl(function(y, w, _) {
          b[w] = y.positionHandler(v, d, _);
        }), b;
      },
      calcACoords: function() {
        var l = this._calcRotateMatrix(), c = this._calcTranslateMatrix(), f = h(c, l), m = this._getTransformedDimensions(), d = m.x / 2, v = m.y / 2;
        return {
          tl: s({ x: -d, y: -v }, f),
          tr: s({ x: d, y: -v }, f),
          bl: s({ x: -d, y: v }, f),
          br: s({ x: d, y: v }, f)
        };
      },
      setCoords: function(l) {
        return this.aCoords = this.calcACoords(), this.lineCoords = this.group ? this.aCoords : this.calcLineCoords(), l ? this : (this.oCoords = this.calcOCoords(), this._setCornerCoords && this._setCornerCoords(), this);
      },
      _calcRotateMatrix: function() {
        return n.calcRotateMatrix(this);
      },
      _calcTranslateMatrix: function() {
        var l = this.getCenterPoint();
        return [1, 0, 0, 1, l.x, l.y];
      },
      transformMatrixKey: function(l) {
        var c = "_", f = "";
        return !l && this.group && (f = this.group.transformMatrixKey(l) + c), f + this.top + c + this.left + c + this.scaleX + c + this.scaleY + c + this.skewX + c + this.skewY + c + this.angle + c + this.originX + c + this.originY + c + this.width + c + this.height + c + this.strokeWidth + this.flipX + this.flipY;
      },
      calcTransformMatrix: function(l) {
        var c = this.calcOwnMatrix();
        if (l || !this.group)
          return c;
        var f = this.transformMatrixKey(l), m = this.matrixCache || (this.matrixCache = {});
        return m.key === f ? m.value : (this.group && (c = h(this.group.calcTransformMatrix(!1), c)), m.key = f, m.value = c, c);
      },
      calcOwnMatrix: function() {
        var l = this.transformMatrixKey(!0), c = this.ownMatrixCache || (this.ownMatrixCache = {});
        if (c.key === l)
          return c.value;
        var f = this._calcTranslateMatrix(), m = {
          angle: this.angle,
          translateX: f[4],
          translateY: f[5],
          scaleX: this.scaleX,
          scaleY: this.scaleY,
          skewX: this.skewX,
          skewY: this.skewY,
          flipX: this.flipX,
          flipY: this.flipY
        };
        return c.key = l, c.value = n.composeMatrix(m), c.value;
      },
      _getNonTransformedDimensions: function() {
        var l = this.strokeWidth, c = this.width + l, f = this.height + l;
        return { x: c, y: f };
      },
      _getTransformedDimensions: function(l, c) {
        typeof l > "u" && (l = this.skewX), typeof c > "u" && (c = this.skewY);
        var f, m, d, v = l === 0 && c === 0;
        if (this.strokeUniform ? (m = this.width, d = this.height) : (f = this._getNonTransformedDimensions(), m = f.x, d = f.y), v)
          return this._finalizeDimensions(m * this.scaleX, d * this.scaleY);
        var b = n.sizeAfterTransform(m, d, {
          scaleX: this.scaleX,
          scaleY: this.scaleY,
          skewX: l,
          skewY: c
        });
        return this._finalizeDimensions(b.x, b.y);
      },
      _finalizeDimensions: function(l, c) {
        return this.strokeUniform ? { x: l + this.strokeWidth, y: c + this.strokeWidth } : { x: l, y: c };
      },
      _calculateCurrentDimensions: function() {
        var l = this.getViewportTransform(), c = this._getTransformedDimensions(), f = s(c, l, !0);
        return f.scalarAdd(2 * this.padding);
      }
    });
  }(), e.util.object.extend(e.Object.prototype, {
    sendToBack: function() {
      return this.group ? e.StaticCanvas.prototype.sendToBack.call(this.group, this) : this.canvas && this.canvas.sendToBack(this), this;
    },
    bringToFront: function() {
      return this.group ? e.StaticCanvas.prototype.bringToFront.call(this.group, this) : this.canvas && this.canvas.bringToFront(this), this;
    },
    sendBackwards: function(a) {
      return this.group ? e.StaticCanvas.prototype.sendBackwards.call(this.group, this, a) : this.canvas && this.canvas.sendBackwards(this, a), this;
    },
    bringForward: function(a) {
      return this.group ? e.StaticCanvas.prototype.bringForward.call(this.group, this, a) : this.canvas && this.canvas.bringForward(this, a), this;
    },
    moveTo: function(a) {
      return this.group && this.group.type !== "activeSelection" ? e.StaticCanvas.prototype.moveTo.call(this.group, this, a) : this.canvas && this.canvas.moveTo(this, a), this;
    }
  }), function() {
    function a(u, h) {
      if (h) {
        if (h.toLive)
          return u + ": url(#SVGID_" + h.id + "); ";
        var s = new e.Color(h), l = u + ": " + s.toRgb() + "; ", c = s.getAlpha();
        return c !== 1 && (l += u + "-opacity: " + c.toString() + "; "), l;
      } else
        return u + ": none; ";
    }
    var n = e.util.toFixed;
    e.util.object.extend(e.Object.prototype, {
      getSvgStyles: function(u) {
        var h = this.fillRule ? this.fillRule : "nonzero", s = this.strokeWidth ? this.strokeWidth : "0", l = this.strokeDashArray ? this.strokeDashArray.join(" ") : "none", c = this.strokeDashOffset ? this.strokeDashOffset : "0", f = this.strokeLineCap ? this.strokeLineCap : "butt", m = this.strokeLineJoin ? this.strokeLineJoin : "miter", d = this.strokeMiterLimit ? this.strokeMiterLimit : "4", v = typeof this.opacity < "u" ? this.opacity : "1", b = this.visible ? "" : " visibility: hidden;", y = u ? "" : this.getSvgFilter(), w = a("fill", this.fill), _ = a("stroke", this.stroke);
        return [
          _,
          "stroke-width: ",
          s,
          "; ",
          "stroke-dasharray: ",
          l,
          "; ",
          "stroke-linecap: ",
          f,
          "; ",
          "stroke-dashoffset: ",
          c,
          "; ",
          "stroke-linejoin: ",
          m,
          "; ",
          "stroke-miterlimit: ",
          d,
          "; ",
          w,
          "fill-rule: ",
          h,
          "; ",
          "opacity: ",
          v,
          ";",
          y,
          b
        ].join("");
      },
      getSvgSpanStyles: function(u, h) {
        var s = "; ", c = u.fontFamily ? "font-family: " + (u.fontFamily.indexOf("'") === -1 && u.fontFamily.indexOf('"') === -1 ? "'" + u.fontFamily + "'" : u.fontFamily) + s : "", l = u.strokeWidth ? "stroke-width: " + u.strokeWidth + s : "", c = c, f = u.fontSize ? "font-size: " + u.fontSize + "px" + s : "", m = u.fontStyle ? "font-style: " + u.fontStyle + s : "", d = u.fontWeight ? "font-weight: " + u.fontWeight + s : "", v = u.fill ? a("fill", u.fill) : "", b = u.stroke ? a("stroke", u.stroke) : "", y = this.getSvgTextDecoration(u), w = u.deltaY ? "baseline-shift: " + -u.deltaY + "; " : "";
        return y && (y = "text-decoration: " + y + s), [
          b,
          l,
          c,
          f,
          m,
          d,
          y,
          v,
          w,
          h ? "white-space: pre; " : ""
        ].join("");
      },
      getSvgTextDecoration: function(u) {
        return ["overline", "underline", "line-through"].filter(function(h) {
          return u[h.replace("-", "")];
        }).join(" ");
      },
      getSvgFilter: function() {
        return this.shadow ? "filter: url(#SVGID_" + this.shadow.id + ");" : "";
      },
      getSvgCommons: function() {
        return [
          this.id ? 'id="' + this.id + '" ' : "",
          this.clipPath ? 'clip-path="url(#' + this.clipPath.clipPathId + ')" ' : ""
        ].join("");
      },
      getSvgTransform: function(u, h) {
        var s = u ? this.calcTransformMatrix() : this.calcOwnMatrix(), l = 'transform="' + e.util.matrixToSVG(s);
        return l + (h || "") + '" ';
      },
      _setSVGBg: function(u) {
        if (this.backgroundColor) {
          var h = e.Object.NUM_FRACTION_DIGITS;
          u.push(
            "		<rect ",
            this._getFillAttributes(this.backgroundColor),
            ' x="',
            n(-this.width / 2, h),
            '" y="',
            n(-this.height / 2, h),
            '" width="',
            n(this.width, h),
            '" height="',
            n(this.height, h),
            `"></rect>
`
          );
        }
      },
      toSVG: function(u) {
        return this._createBaseSVGMarkup(this._toSVG(u), { reviver: u });
      },
      toClipPathSVG: function(u) {
        return "	" + this._createBaseClipPathSVGMarkup(this._toSVG(u), { reviver: u });
      },
      _createBaseClipPathSVGMarkup: function(u, h) {
        h = h || {};
        var s = h.reviver, l = h.additionalTransform || "", c = [
          this.getSvgTransform(!0, l),
          this.getSvgCommons()
        ].join(""), f = u.indexOf("COMMON_PARTS");
        return u[f] = c, s ? s(u.join("")) : u.join("");
      },
      _createBaseSVGMarkup: function(u, h) {
        h = h || {};
        var s = h.noStyle, l = h.reviver, c = s ? "" : 'style="' + this.getSvgStyles() + '" ', f = h.withShadow ? 'style="' + this.getSvgFilter() + '" ' : "", m = this.clipPath, d = this.strokeUniform ? 'vector-effect="non-scaling-stroke" ' : "", v = m && m.absolutePositioned, b = this.stroke, y = this.fill, w = this.shadow, _, S = [], T, A = u.indexOf("COMMON_PARTS"), R = h.additionalTransform;
        return m && (m.clipPathId = "CLIPPATH_" + e.Object.__uid++, T = '<clipPath id="' + m.clipPathId + `" >
` + m.toClipPathSVG(l) + `</clipPath>
`), v && S.push(
          "<g ",
          f,
          this.getSvgCommons(),
          ` >
`
        ), S.push(
          "<g ",
          this.getSvgTransform(!1),
          v ? "" : f + this.getSvgCommons(),
          ` >
`
        ), _ = [
          c,
          d,
          s ? "" : this.addPaintOrder(),
          " ",
          R ? 'transform="' + R + '" ' : ""
        ].join(""), u[A] = _, y && y.toLive && S.push(y.toSVG(this)), b && b.toLive && S.push(b.toSVG(this)), w && S.push(w.toSVG(this)), m && S.push(T), S.push(u.join("")), S.push(`</g>
`), v && S.push(`</g>
`), l ? l(S.join("")) : S.join("");
      },
      addPaintOrder: function() {
        return this.paintFirst !== "fill" ? ' paint-order="' + this.paintFirst + '" ' : "";
      }
    });
  }(), function() {
    var a = e.util.object.extend, n = "stateProperties";
    function u(s, l, c) {
      var f = {}, m = !0;
      c.forEach(function(d) {
        f[d] = s[d];
      }), a(s[l], f, m);
    }
    function h(s, l, c) {
      if (s === l)
        return !0;
      if (Array.isArray(s)) {
        if (!Array.isArray(l) || s.length !== l.length)
          return !1;
        for (var f = 0, m = s.length; f < m; f++)
          if (!h(s[f], l[f]))
            return !1;
        return !0;
      } else if (s && typeof s == "object") {
        var d = Object.keys(s), v;
        if (!l || typeof l != "object" || !c && d.length !== Object.keys(l).length)
          return !1;
        for (var f = 0, m = d.length; f < m; f++)
          if (v = d[f], !(v === "canvas" || v === "group") && !h(s[v], l[v]))
            return !1;
        return !0;
      }
    }
    e.util.object.extend(e.Object.prototype, {
      hasStateChanged: function(s) {
        s = s || n;
        var l = "_" + s;
        return Object.keys(this[l]).length < this[s].length ? !0 : !h(this[l], this, !0);
      },
      saveState: function(s) {
        var l = s && s.propertySet || n, c = "_" + l;
        return this[c] ? (u(this, c, this[l]), s && s.stateProperties && u(this, c, s.stateProperties), this) : this.setupState(s);
      },
      setupState: function(s) {
        s = s || {};
        var l = s.propertySet || n;
        return s.propertySet = l, this["_" + l] = {}, this.saveState(s), this;
      }
    });
  }(), function() {
    var a = e.util.degreesToRadians;
    e.util.object.extend(e.Object.prototype, {
      _findTargetCorner: function(n, u) {
        if (!this.hasControls || this.group || !this.canvas || this.canvas._activeObject !== this)
          return !1;
        var h = n.x, s = n.y, l, c, f = Object.keys(this.oCoords), m = f.length - 1, d;
        for (this.__corner = 0; m >= 0; m--)
          if (d = f[m], !!this.isControlVisible(d) && (c = this._getImageLines(u ? this.oCoords[d].touchCorner : this.oCoords[d].corner), l = this._findCrossPoints({ x: h, y: s }, c), l !== 0 && l % 2 === 1))
            return this.__corner = d, d;
        return !1;
      },
      forEachControl: function(n) {
        for (var u in this.controls)
          n(this.controls[u], u, this);
      },
      _setCornerCoords: function() {
        var n = this.oCoords;
        for (var u in n) {
          var h = this.controls[u];
          n[u].corner = h.calcCornerCoords(
            this.angle,
            this.cornerSize,
            n[u].x,
            n[u].y,
            !1
          ), n[u].touchCorner = h.calcCornerCoords(
            this.angle,
            this.touchCornerSize,
            n[u].x,
            n[u].y,
            !0
          );
        }
      },
      drawSelectionBackground: function(n) {
        if (!this.selectionBackgroundColor || this.canvas && !this.canvas.interactive || this.canvas && this.canvas._activeObject !== this)
          return this;
        n.save();
        var u = this.getCenterPoint(), h = this._calculateCurrentDimensions(), s = this.canvas.viewportTransform;
        return n.translate(u.x, u.y), n.scale(1 / s[0], 1 / s[3]), n.rotate(a(this.angle)), n.fillStyle = this.selectionBackgroundColor, n.fillRect(-h.x / 2, -h.y / 2, h.x, h.y), n.restore(), this;
      },
      drawBorders: function(n, u) {
        u = u || {};
        var h = this._calculateCurrentDimensions(), s = this.borderScaleFactor, l = h.x + s, c = h.y + s, f = typeof u.hasControls < "u" ? u.hasControls : this.hasControls, m = !1;
        return n.save(), n.strokeStyle = u.borderColor || this.borderColor, this._setLineDash(n, u.borderDashArray || this.borderDashArray), n.strokeRect(
          -l / 2,
          -c / 2,
          l,
          c
        ), f && (n.beginPath(), this.forEachControl(function(d, v, b) {
          d.withConnection && d.getVisibility(b, v) && (m = !0, n.moveTo(d.x * l, d.y * c), n.lineTo(
            d.x * l + d.offsetX,
            d.y * c + d.offsetY
          ));
        }), m && n.stroke()), n.restore(), this;
      },
      drawBordersInGroup: function(n, u, h) {
        h = h || {};
        var s = e.util.sizeAfterTransform(this.width, this.height, u), l = this.strokeWidth, c = this.strokeUniform, f = this.borderScaleFactor, m = s.x + l * (c ? this.canvas.getZoom() : u.scaleX) + f, d = s.y + l * (c ? this.canvas.getZoom() : u.scaleY) + f;
        return n.save(), this._setLineDash(n, h.borderDashArray || this.borderDashArray), n.strokeStyle = h.borderColor || this.borderColor, n.strokeRect(
          -m / 2,
          -d / 2,
          m,
          d
        ), n.restore(), this;
      },
      drawControls: function(n, u) {
        u = u || {}, n.save();
        var h = this.canvas.getRetinaScaling(), s, l;
        return n.setTransform(h, 0, 0, h, 0, 0), n.strokeStyle = n.fillStyle = u.cornerColor || this.cornerColor, this.transparentCorners || (n.strokeStyle = u.cornerStrokeColor || this.cornerStrokeColor), this._setLineDash(n, u.cornerDashArray || this.cornerDashArray), this.setCoords(), this.group && (s = this.group.calcTransformMatrix()), this.forEachControl(function(c, f, m) {
          l = m.oCoords[f], c.getVisibility(m, f) && (s && (l = e.util.transformPoint(l, s)), c.render(n, l.x, l.y, u, m));
        }), n.restore(), this;
      },
      isControlVisible: function(n) {
        return this.controls[n] && this.controls[n].getVisibility(this, n);
      },
      setControlVisible: function(n, u) {
        return this._controlsVisibility || (this._controlsVisibility = {}), this._controlsVisibility[n] = u, this;
      },
      setControlsVisibility: function(n) {
        n || (n = {});
        for (var u in n)
          this.setControlVisible(u, n[u]);
        return this;
      },
      onDeselect: function() {
      },
      onSelect: function() {
      }
    });
  }(), e.util.object.extend(e.StaticCanvas.prototype, {
    FX_DURATION: 500,
    fxCenterObjectH: function(a, n) {
      n = n || {};
      var u = function() {
      }, h = n.onComplete || u, s = n.onChange || u, l = this;
      return e.util.animate({
        target: this,
        startValue: a.left,
        endValue: this.getCenterPoint().x,
        duration: this.FX_DURATION,
        onChange: function(c) {
          a.set("left", c), l.requestRenderAll(), s();
        },
        onComplete: function() {
          a.setCoords(), h();
        }
      });
    },
    fxCenterObjectV: function(a, n) {
      n = n || {};
      var u = function() {
      }, h = n.onComplete || u, s = n.onChange || u, l = this;
      return e.util.animate({
        target: this,
        startValue: a.top,
        endValue: this.getCenterPoint().y,
        duration: this.FX_DURATION,
        onChange: function(c) {
          a.set("top", c), l.requestRenderAll(), s();
        },
        onComplete: function() {
          a.setCoords(), h();
        }
      });
    },
    fxRemove: function(a, n) {
      n = n || {};
      var u = function() {
      }, h = n.onComplete || u, s = n.onChange || u, l = this;
      return e.util.animate({
        target: this,
        startValue: a.opacity,
        endValue: 0,
        duration: this.FX_DURATION,
        onChange: function(c) {
          a.set("opacity", c), l.requestRenderAll(), s();
        },
        onComplete: function() {
          l.remove(a), h();
        }
      });
    }
  }), e.util.object.extend(e.Object.prototype, {
    animate: function() {
      if (arguments[0] && typeof arguments[0] == "object") {
        var a = [], n, u, h = [];
        for (n in arguments[0])
          a.push(n);
        for (var s = 0, l = a.length; s < l; s++)
          n = a[s], u = s !== l - 1, h.push(this._animate(n, arguments[0][n], arguments[1], u));
        return h;
      } else
        return this._animate.apply(this, arguments);
    },
    _animate: function(a, n, u, h) {
      var s = this, l;
      n = n.toString(), u ? u = e.util.object.clone(u) : u = {}, ~a.indexOf(".") && (l = a.split("."));
      var c = s.colorProperties.indexOf(a) > -1 || l && s.colorProperties.indexOf(l[1]) > -1, f = l ? this.get(l[0])[l[1]] : this.get(a);
      "from" in u || (u.from = f), c || (~n.indexOf("=") ? n = f + parseFloat(n.replace("=", "")) : n = parseFloat(n));
      var m = {
        target: this,
        startValue: u.from,
        endValue: n,
        byValue: u.by,
        easing: u.easing,
        duration: u.duration,
        abort: u.abort && function(d, v, b) {
          return u.abort.call(s, d, v, b);
        },
        onChange: function(d, v, b) {
          l ? s[l[0]][l[1]] = d : s.set(a, d), !h && u.onChange && u.onChange(d, v, b);
        },
        onComplete: function(d, v, b) {
          h || (s.setCoords(), u.onComplete && u.onComplete(d, v, b));
        }
      };
      return c ? e.util.animateColor(m.startValue, m.endValue, m.duration, m) : e.util.animate(m);
    }
  }), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.util.object.extend, h = n.util.object.clone, s = { x1: 1, x2: 1, y1: 1, y2: 1 };
    if (n.Line) {
      n.warn("fabric.Line is already defined");
      return;
    }
    n.Line = n.util.createClass(n.Object, {
      type: "line",
      x1: 0,
      y1: 0,
      x2: 0,
      y2: 0,
      cacheProperties: n.Object.prototype.cacheProperties.concat("x1", "x2", "y1", "y2"),
      initialize: function(c, f) {
        c || (c = [0, 0, 0, 0]), this.callSuper("initialize", f), this.set("x1", c[0]), this.set("y1", c[1]), this.set("x2", c[2]), this.set("y2", c[3]), this._setWidthHeight(f);
      },
      _setWidthHeight: function(c) {
        c || (c = {}), this.width = Math.abs(this.x2 - this.x1), this.height = Math.abs(this.y2 - this.y1), this.left = "left" in c ? c.left : this._getLeftToOriginX(), this.top = "top" in c ? c.top : this._getTopToOriginY();
      },
      _set: function(c, f) {
        return this.callSuper("_set", c, f), typeof s[c] < "u" && this._setWidthHeight(), this;
      },
      _getLeftToOriginX: l(
        {
          origin: "originX",
          axis1: "x1",
          axis2: "x2",
          dimension: "width"
        },
        {
          nearest: "left",
          center: "center",
          farthest: "right"
        }
      ),
      _getTopToOriginY: l(
        {
          origin: "originY",
          axis1: "y1",
          axis2: "y2",
          dimension: "height"
        },
        {
          nearest: "top",
          center: "center",
          farthest: "bottom"
        }
      ),
      _render: function(c) {
        c.beginPath();
        var f = this.calcLinePoints();
        c.moveTo(f.x1, f.y1), c.lineTo(f.x2, f.y2), c.lineWidth = this.strokeWidth;
        var m = c.strokeStyle;
        c.strokeStyle = this.stroke || c.fillStyle, this.stroke && this._renderStroke(c), c.strokeStyle = m;
      },
      _findCenterFromElement: function() {
        return {
          x: (this.x1 + this.x2) / 2,
          y: (this.y1 + this.y2) / 2
        };
      },
      toObject: function(c) {
        return u(this.callSuper("toObject", c), this.calcLinePoints());
      },
      _getNonTransformedDimensions: function() {
        var c = this.callSuper("_getNonTransformedDimensions");
        return this.strokeLineCap === "butt" && (this.width === 0 && (c.y -= this.strokeWidth), this.height === 0 && (c.x -= this.strokeWidth)), c;
      },
      calcLinePoints: function() {
        var c = this.x1 <= this.x2 ? -1 : 1, f = this.y1 <= this.y2 ? -1 : 1, m = c * this.width * 0.5, d = f * this.height * 0.5, v = c * this.width * -0.5, b = f * this.height * -0.5;
        return {
          x1: m,
          x2: v,
          y1: d,
          y2: b
        };
      },
      _toSVG: function() {
        var c = this.calcLinePoints();
        return [
          "<line ",
          "COMMON_PARTS",
          'x1="',
          c.x1,
          '" y1="',
          c.y1,
          '" x2="',
          c.x2,
          '" y2="',
          c.y2,
          `" />
`
        ];
      }
    }), n.Line.ATTRIBUTE_NAMES = n.SHARED_ATTRIBUTES.concat("x1 y1 x2 y2".split(" ")), n.Line.fromElement = function(c, f, m) {
      m = m || {};
      var d = n.parseAttributes(c, n.Line.ATTRIBUTE_NAMES), v = [
        d.x1 || 0,
        d.y1 || 0,
        d.x2 || 0,
        d.y2 || 0
      ];
      f(new n.Line(v, u(d, m)));
    }, n.Line.fromObject = function(c, f) {
      function m(v) {
        delete v.points, f && f(v);
      }
      var d = h(c, !0);
      d.points = [c.x1, c.y1, c.x2, c.y2], n.Object._fromObject("Line", d, m, "points");
    };
    function l(c, f) {
      var m = c.origin, d = c.axis1, v = c.axis2, b = c.dimension, y = f.nearest, w = f.center, _ = f.farthest;
      return function() {
        switch (this.get(m)) {
          case y:
            return Math.min(this.get(d), this.get(v));
          case w:
            return Math.min(this.get(d), this.get(v)) + 0.5 * this.get(b);
          case _:
            return Math.max(this.get(d), this.get(v));
        }
      };
    }
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.util.degreesToRadians;
    if (n.Circle) {
      n.warn("fabric.Circle is already defined.");
      return;
    }
    n.Circle = n.util.createClass(n.Object, {
      type: "circle",
      radius: 0,
      startAngle: 0,
      endAngle: 360,
      cacheProperties: n.Object.prototype.cacheProperties.concat("radius", "startAngle", "endAngle"),
      _set: function(s, l) {
        return this.callSuper("_set", s, l), s === "radius" && this.setRadius(l), this;
      },
      toObject: function(s) {
        return this.callSuper("toObject", ["radius", "startAngle", "endAngle"].concat(s));
      },
      _toSVG: function() {
        var s, l = 0, c = 0, f = (this.endAngle - this.startAngle) % 360;
        if (f === 0)
          s = [
            "<circle ",
            "COMMON_PARTS",
            'cx="' + l + '" cy="' + c + '" ',
            'r="',
            this.radius,
            `" />
`
          ];
        else {
          var m = u(this.startAngle), d = u(this.endAngle), v = this.radius, b = n.util.cos(m) * v, y = n.util.sin(m) * v, w = n.util.cos(d) * v, _ = n.util.sin(d) * v, S = f > 180 ? "1" : "0";
          s = [
            '<path d="M ' + b + " " + y,
            " A " + v + " " + v,
            " 0 ",
            +S + " 1",
            " " + w + " " + _,
            '" ',
            "COMMON_PARTS",
            ` />
`
          ];
        }
        return s;
      },
      _render: function(s) {
        s.beginPath(), s.arc(
          0,
          0,
          this.radius,
          u(this.startAngle),
          u(this.endAngle),
          !1
        ), this._renderPaintInOrder(s);
      },
      getRadiusX: function() {
        return this.get("radius") * this.get("scaleX");
      },
      getRadiusY: function() {
        return this.get("radius") * this.get("scaleY");
      },
      setRadius: function(s) {
        return this.radius = s, this.set("width", s * 2).set("height", s * 2);
      }
    }), n.Circle.ATTRIBUTE_NAMES = n.SHARED_ATTRIBUTES.concat("cx cy r".split(" ")), n.Circle.fromElement = function(s, l) {
      var c = n.parseAttributes(s, n.Circle.ATTRIBUTE_NAMES);
      if (!h(c))
        throw new Error("value of `r` attribute is required and can not be negative");
      c.left = (c.left || 0) - c.radius, c.top = (c.top || 0) - c.radius, l(new n.Circle(c));
    };
    function h(s) {
      return "radius" in s && s.radius >= 0;
    }
    n.Circle.fromObject = function(s, l) {
      n.Object._fromObject("Circle", s, l);
    };
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {});
    if (n.Triangle) {
      n.warn("fabric.Triangle is already defined");
      return;
    }
    n.Triangle = n.util.createClass(n.Object, {
      type: "triangle",
      width: 100,
      height: 100,
      _render: function(u) {
        var h = this.width / 2, s = this.height / 2;
        u.beginPath(), u.moveTo(-h, s), u.lineTo(0, -s), u.lineTo(h, s), u.closePath(), this._renderPaintInOrder(u);
      },
      _toSVG: function() {
        var u = this.width / 2, h = this.height / 2, s = [
          -u + " " + h,
          "0 " + -h,
          u + " " + h
        ].join(",");
        return [
          "<polygon ",
          "COMMON_PARTS",
          'points="',
          s,
          '" />'
        ];
      }
    }), n.Triangle.fromObject = function(u, h) {
      return n.Object._fromObject("Triangle", u, h);
    };
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = Math.PI * 2;
    if (n.Ellipse) {
      n.warn("fabric.Ellipse is already defined.");
      return;
    }
    n.Ellipse = n.util.createClass(n.Object, {
      type: "ellipse",
      rx: 0,
      ry: 0,
      cacheProperties: n.Object.prototype.cacheProperties.concat("rx", "ry"),
      initialize: function(h) {
        this.callSuper("initialize", h), this.set("rx", h && h.rx || 0), this.set("ry", h && h.ry || 0);
      },
      _set: function(h, s) {
        switch (this.callSuper("_set", h, s), h) {
          case "rx":
            this.rx = s, this.set("width", s * 2);
            break;
          case "ry":
            this.ry = s, this.set("height", s * 2);
            break;
        }
        return this;
      },
      getRx: function() {
        return this.get("rx") * this.get("scaleX");
      },
      getRy: function() {
        return this.get("ry") * this.get("scaleY");
      },
      toObject: function(h) {
        return this.callSuper("toObject", ["rx", "ry"].concat(h));
      },
      _toSVG: function() {
        return [
          "<ellipse ",
          "COMMON_PARTS",
          'cx="0" cy="0" ',
          'rx="',
          this.rx,
          '" ry="',
          this.ry,
          `" />
`
        ];
      },
      _render: function(h) {
        h.beginPath(), h.save(), h.transform(1, 0, 0, this.ry / this.rx, 0, 0), h.arc(
          0,
          0,
          this.rx,
          0,
          u,
          !1
        ), h.restore(), this._renderPaintInOrder(h);
      }
    }), n.Ellipse.ATTRIBUTE_NAMES = n.SHARED_ATTRIBUTES.concat("cx cy rx ry".split(" ")), n.Ellipse.fromElement = function(h, s) {
      var l = n.parseAttributes(h, n.Ellipse.ATTRIBUTE_NAMES);
      l.left = (l.left || 0) - l.rx, l.top = (l.top || 0) - l.ry, s(new n.Ellipse(l));
    }, n.Ellipse.fromObject = function(h, s) {
      n.Object._fromObject("Ellipse", h, s);
    };
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.util.object.extend;
    if (n.Rect) {
      n.warn("fabric.Rect is already defined");
      return;
    }
    n.Rect = n.util.createClass(n.Object, {
      stateProperties: n.Object.prototype.stateProperties.concat("rx", "ry"),
      type: "rect",
      rx: 0,
      ry: 0,
      cacheProperties: n.Object.prototype.cacheProperties.concat("rx", "ry"),
      initialize: function(h) {
        this.callSuper("initialize", h), this._initRxRy();
      },
      _initRxRy: function() {
        this.rx && !this.ry ? this.ry = this.rx : this.ry && !this.rx && (this.rx = this.ry);
      },
      _render: function(h) {
        var s = this.rx ? Math.min(this.rx, this.width / 2) : 0, l = this.ry ? Math.min(this.ry, this.height / 2) : 0, c = this.width, f = this.height, m = -this.width / 2, d = -this.height / 2, v = s !== 0 || l !== 0, b = 1 - 0.5522847498;
        h.beginPath(), h.moveTo(m + s, d), h.lineTo(m + c - s, d), v && h.bezierCurveTo(m + c - b * s, d, m + c, d + b * l, m + c, d + l), h.lineTo(m + c, d + f - l), v && h.bezierCurveTo(m + c, d + f - b * l, m + c - b * s, d + f, m + c - s, d + f), h.lineTo(m + s, d + f), v && h.bezierCurveTo(m + b * s, d + f, m, d + f - b * l, m, d + f - l), h.lineTo(m, d + l), v && h.bezierCurveTo(m, d + b * l, m + b * s, d, m + s, d), h.closePath(), this._renderPaintInOrder(h);
      },
      toObject: function(h) {
        return this.callSuper("toObject", ["rx", "ry"].concat(h));
      },
      _toSVG: function() {
        var h = -this.width / 2, s = -this.height / 2;
        return [
          "<rect ",
          "COMMON_PARTS",
          'x="',
          h,
          '" y="',
          s,
          '" rx="',
          this.rx,
          '" ry="',
          this.ry,
          '" width="',
          this.width,
          '" height="',
          this.height,
          `" />
`
        ];
      }
    }), n.Rect.ATTRIBUTE_NAMES = n.SHARED_ATTRIBUTES.concat("x y rx ry width height".split(" ")), n.Rect.fromElement = function(h, s, l) {
      if (!h)
        return s(null);
      l = l || {};
      var c = n.parseAttributes(h, n.Rect.ATTRIBUTE_NAMES);
      c.left = c.left || 0, c.top = c.top || 0, c.height = c.height || 0, c.width = c.width || 0;
      var f = new n.Rect(u(l ? n.util.object.clone(l) : {}, c));
      f.visible = f.visible && f.width > 0 && f.height > 0, s(f);
    }, n.Rect.fromObject = function(h, s) {
      return n.Object._fromObject("Rect", h, s);
    };
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.util.object.extend, h = n.util.array.min, s = n.util.array.max, l = n.util.toFixed, c = n.util.projectStrokeOnPoints;
    if (n.Polyline) {
      n.warn("fabric.Polyline is already defined");
      return;
    }
    n.Polyline = n.util.createClass(n.Object, {
      type: "polyline",
      points: null,
      exactBoundingBox: !1,
      cacheProperties: n.Object.prototype.cacheProperties.concat("points"),
      initialize: function(f, m) {
        m = m || {}, this.points = f || [], this.callSuper("initialize", m), this._setPositionDimensions(m);
      },
      _projectStrokeOnPoints: function() {
        return c(this.points, this, !0);
      },
      _setPositionDimensions: function(f) {
        var m = this._calcDimensions(f), d, v = this.exactBoundingBox ? this.strokeWidth : 0;
        this.width = m.width - v, this.height = m.height - v, f.fromSVG || (d = this.translateToGivenOrigin(
          {
            x: m.left - this.strokeWidth / 2 + v / 2,
            y: m.top - this.strokeWidth / 2 + v / 2
          },
          "left",
          "top",
          this.originX,
          this.originY
        )), typeof f.left > "u" && (this.left = f.fromSVG ? m.left : d.x), typeof f.top > "u" && (this.top = f.fromSVG ? m.top : d.y), this.pathOffset = {
          x: m.left + this.width / 2 + v / 2,
          y: m.top + this.height / 2 + v / 2
        };
      },
      _calcDimensions: function() {
        var f = this.exactBoundingBox ? this._projectStrokeOnPoints() : this.points, m = h(f, "x") || 0, d = h(f, "y") || 0, v = s(f, "x") || 0, b = s(f, "y") || 0, y = v - m, w = b - d;
        return {
          left: m,
          top: d,
          width: y,
          height: w
        };
      },
      toObject: function(f) {
        return u(this.callSuper("toObject", f), {
          points: this.points.concat()
        });
      },
      _toSVG: function() {
        for (var f = [], m = this.pathOffset.x, d = this.pathOffset.y, v = n.Object.NUM_FRACTION_DIGITS, b = 0, y = this.points.length; b < y; b++)
          f.push(
            l(this.points[b].x - m, v),
            ",",
            l(this.points[b].y - d, v),
            " "
          );
        return [
          "<" + this.type + " ",
          "COMMON_PARTS",
          'points="',
          f.join(""),
          `" />
`
        ];
      },
      commonRender: function(f) {
        var m, d = this.points.length, v = this.pathOffset.x, b = this.pathOffset.y;
        if (!d || isNaN(this.points[d - 1].y))
          return !1;
        f.beginPath(), f.moveTo(this.points[0].x - v, this.points[0].y - b);
        for (var y = 0; y < d; y++)
          m = this.points[y], f.lineTo(m.x - v, m.y - b);
        return !0;
      },
      _render: function(f) {
        !this.commonRender(f) || this._renderPaintInOrder(f);
      },
      complexity: function() {
        return this.get("points").length;
      }
    }), n.Polyline.ATTRIBUTE_NAMES = n.SHARED_ATTRIBUTES.concat(), n.Polyline.fromElementGenerator = function(f) {
      return function(m, d, v) {
        if (!m)
          return d(null);
        v || (v = {});
        var b = n.parsePointsAttribute(m.getAttribute("points")), y = n.parseAttributes(m, n[f].ATTRIBUTE_NAMES);
        y.fromSVG = !0, d(new n[f](b, u(y, v)));
      };
    }, n.Polyline.fromElement = n.Polyline.fromElementGenerator("Polyline"), n.Polyline.fromObject = function(f, m) {
      return n.Object._fromObject("Polyline", f, m, "points");
    };
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.util.projectStrokeOnPoints;
    if (n.Polygon) {
      n.warn("fabric.Polygon is already defined");
      return;
    }
    n.Polygon = n.util.createClass(n.Polyline, {
      type: "polygon",
      _projectStrokeOnPoints: function() {
        return u(this.points, this);
      },
      _render: function(h) {
        !this.commonRender(h) || (h.closePath(), this._renderPaintInOrder(h));
      }
    }), n.Polygon.ATTRIBUTE_NAMES = n.SHARED_ATTRIBUTES.concat(), n.Polygon.fromElement = n.Polyline.fromElementGenerator("Polygon"), n.Polygon.fromObject = function(h, s) {
      n.Object._fromObject("Polygon", h, s, "points");
    };
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.util.array.min, h = n.util.array.max, s = n.util.object.extend, l = n.util.object.clone, c = n.util.toFixed;
    if (n.Path) {
      n.warn("fabric.Path is already defined");
      return;
    }
    n.Path = n.util.createClass(n.Object, {
      type: "path",
      path: null,
      cacheProperties: n.Object.prototype.cacheProperties.concat("path", "fillRule"),
      stateProperties: n.Object.prototype.stateProperties.concat("path"),
      initialize: function(f, m) {
        m = l(m || {}), delete m.path, this.callSuper("initialize", m), this._setPath(f || [], m);
      },
      _setPath: function(f, m) {
        this.path = n.util.makePathSimpler(
          Array.isArray(f) ? f : n.util.parsePath(f)
        ), n.Polyline.prototype._setPositionDimensions.call(this, m || {});
      },
      _renderPathCommands: function(f) {
        var m, d = 0, v = 0, b = 0, y = 0, w = 0, _ = 0, S = -this.pathOffset.x, T = -this.pathOffset.y;
        f.beginPath();
        for (var A = 0, R = this.path.length; A < R; ++A)
          switch (m = this.path[A], m[0]) {
            case "L":
              b = m[1], y = m[2], f.lineTo(b + S, y + T);
              break;
            case "M":
              b = m[1], y = m[2], d = b, v = y, f.moveTo(b + S, y + T);
              break;
            case "C":
              b = m[5], y = m[6], w = m[3], _ = m[4], f.bezierCurveTo(
                m[1] + S,
                m[2] + T,
                w + S,
                _ + T,
                b + S,
                y + T
              );
              break;
            case "Q":
              f.quadraticCurveTo(
                m[1] + S,
                m[2] + T,
                m[3] + S,
                m[4] + T
              ), b = m[3], y = m[4], w = m[1], _ = m[2];
              break;
            case "z":
            case "Z":
              b = d, y = v, f.closePath();
              break;
          }
      },
      _render: function(f) {
        this._renderPathCommands(f), this._renderPaintInOrder(f);
      },
      toString: function() {
        return "#<fabric.Path (" + this.complexity() + '): { "top": ' + this.top + ', "left": ' + this.left + " }>";
      },
      toObject: function(f) {
        return s(this.callSuper("toObject", f), {
          path: this.path.map(function(m) {
            return m.slice();
          })
        });
      },
      toDatalessObject: function(f) {
        var m = this.toObject(["sourcePath"].concat(f));
        return m.sourcePath && delete m.path, m;
      },
      _toSVG: function() {
        var f = n.util.joinPath(this.path);
        return [
          "<path ",
          "COMMON_PARTS",
          'd="',
          f,
          '" stroke-linecap="round" ',
          `/>
`
        ];
      },
      _getOffsetTransform: function() {
        var f = n.Object.NUM_FRACTION_DIGITS;
        return " translate(" + c(-this.pathOffset.x, f) + ", " + c(-this.pathOffset.y, f) + ")";
      },
      toClipPathSVG: function(f) {
        var m = this._getOffsetTransform();
        return "	" + this._createBaseClipPathSVGMarkup(
          this._toSVG(),
          { reviver: f, additionalTransform: m }
        );
      },
      toSVG: function(f) {
        var m = this._getOffsetTransform();
        return this._createBaseSVGMarkup(this._toSVG(), { reviver: f, additionalTransform: m });
      },
      complexity: function() {
        return this.path.length;
      },
      _calcDimensions: function() {
        for (var f = [], m = [], d, v = 0, b = 0, y = 0, w = 0, _, S = 0, T = this.path.length; S < T; ++S) {
          switch (d = this.path[S], d[0]) {
            case "L":
              y = d[1], w = d[2], _ = [];
              break;
            case "M":
              y = d[1], w = d[2], v = y, b = w, _ = [];
              break;
            case "C":
              _ = n.util.getBoundsOfCurve(
                y,
                w,
                d[1],
                d[2],
                d[3],
                d[4],
                d[5],
                d[6]
              ), y = d[5], w = d[6];
              break;
            case "Q":
              _ = n.util.getBoundsOfCurve(
                y,
                w,
                d[1],
                d[2],
                d[1],
                d[2],
                d[3],
                d[4]
              ), y = d[3], w = d[4];
              break;
            case "z":
            case "Z":
              y = v, w = b;
              break;
          }
          _.forEach(function(J) {
            f.push(J.x), m.push(J.y);
          }), f.push(y), m.push(w);
        }
        var A = u(f) || 0, R = u(m) || 0, N = h(f) || 0, U = h(m) || 0, Q = N - A, ee = U - R;
        return {
          left: A,
          top: R,
          width: Q,
          height: ee
        };
      }
    }), n.Path.fromObject = function(f, m) {
      if (typeof f.sourcePath == "string") {
        var d = f.sourcePath;
        n.loadSVGFromURL(d, function(v) {
          var b = v[0];
          b.setOptions(f), f.clipPath ? n.util.enlivenObjects([f.clipPath], function(y) {
            b.clipPath = y[0], m && m(b);
          }) : m && m(b);
        });
      } else
        n.Object._fromObject("Path", f, m, "path");
    }, n.Path.ATTRIBUTE_NAMES = n.SHARED_ATTRIBUTES.concat(["d"]), n.Path.fromElement = function(f, m, d) {
      var v = n.parseAttributes(f, n.Path.ATTRIBUTE_NAMES);
      v.fromSVG = !0, m(new n.Path(v.d, s(v, d)));
    };
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.util.array.min, h = n.util.array.max;
    n.Group || (n.Group = n.util.createClass(n.Object, n.Collection, {
      type: "group",
      strokeWidth: 0,
      subTargetCheck: !1,
      cacheProperties: [],
      useSetOnGroup: !1,
      initialize: function(s, l, c) {
        l = l || {}, this._objects = [], c && this.callSuper("initialize", l), this._objects = s || [];
        for (var f = this._objects.length; f--; )
          this._objects[f].group = this;
        if (c)
          this._updateObjectsACoords();
        else {
          var m = l && l.centerPoint;
          l.originX !== void 0 && (this.originX = l.originX), l.originY !== void 0 && (this.originY = l.originY), m || this._calcBounds(), this._updateObjectsCoords(m), delete l.centerPoint, this.callSuper("initialize", l);
        }
        this.setCoords();
      },
      _updateObjectsACoords: function() {
        for (var s = !0, l = this._objects.length; l--; )
          this._objects[l].setCoords(s);
      },
      _updateObjectsCoords: function(l) {
        for (var l = l || this.getCenterPoint(), c = this._objects.length; c--; )
          this._updateObjectCoords(this._objects[c], l);
      },
      _updateObjectCoords: function(s, l) {
        var c = s.left, f = s.top, m = !0;
        s.set({
          left: c - l.x,
          top: f - l.y
        }), s.group = this, s.setCoords(m);
      },
      toString: function() {
        return "#<fabric.Group: (" + this.complexity() + ")>";
      },
      addWithUpdate: function(s) {
        var l = !!this.group;
        return this._restoreObjectsState(), n.util.resetObjectTransform(this), s && (l && n.util.removeTransformFromObject(s, this.group.calcTransformMatrix()), this._objects.push(s), s.group = this, s._set("canvas", this.canvas)), this._calcBounds(), this._updateObjectsCoords(), this.dirty = !0, l ? this.group.addWithUpdate() : this.setCoords(), this;
      },
      removeWithUpdate: function(s) {
        return this._restoreObjectsState(), n.util.resetObjectTransform(this), this.remove(s), this._calcBounds(), this._updateObjectsCoords(), this.setCoords(), this.dirty = !0, this;
      },
      _onObjectAdded: function(s) {
        this.dirty = !0, s.group = this, s._set("canvas", this.canvas);
      },
      _onObjectRemoved: function(s) {
        this.dirty = !0, delete s.group;
      },
      _set: function(s, l) {
        var c = this._objects.length;
        if (this.useSetOnGroup)
          for (; c--; )
            this._objects[c].setOnGroup(s, l);
        if (s === "canvas")
          for (; c--; )
            this._objects[c]._set(s, l);
        n.Object.prototype._set.call(this, s, l);
      },
      toObject: function(s) {
        var l = this.includeDefaultValues, c = this._objects.filter(function(m) {
          return !m.excludeFromExport;
        }).map(function(m) {
          var d = m.includeDefaultValues;
          m.includeDefaultValues = l;
          var v = m.toObject(s);
          return m.includeDefaultValues = d, v;
        }), f = n.Object.prototype.toObject.call(this, s);
        return f.objects = c, f;
      },
      toDatalessObject: function(s) {
        var l, c = this.sourcePath;
        if (c)
          l = c;
        else {
          var f = this.includeDefaultValues;
          l = this._objects.map(function(d) {
            var v = d.includeDefaultValues;
            d.includeDefaultValues = f;
            var b = d.toDatalessObject(s);
            return d.includeDefaultValues = v, b;
          });
        }
        var m = n.Object.prototype.toDatalessObject.call(this, s);
        return m.objects = l, m;
      },
      render: function(s) {
        this._transformDone = !0, this.callSuper("render", s), this._transformDone = !1;
      },
      shouldCache: function() {
        var s = n.Object.prototype.shouldCache.call(this);
        if (s) {
          for (var l = 0, c = this._objects.length; l < c; l++)
            if (this._objects[l].willDrawShadow())
              return this.ownCaching = !1, !1;
        }
        return s;
      },
      willDrawShadow: function() {
        if (n.Object.prototype.willDrawShadow.call(this))
          return !0;
        for (var s = 0, l = this._objects.length; s < l; s++)
          if (this._objects[s].willDrawShadow())
            return !0;
        return !1;
      },
      isOnACache: function() {
        return this.ownCaching || this.group && this.group.isOnACache();
      },
      drawObject: function(s) {
        for (var l = 0, c = this._objects.length; l < c; l++)
          this._objects[l].render(s);
        this._drawClipPath(s, this.clipPath);
      },
      isCacheDirty: function(s) {
        if (this.callSuper("isCacheDirty", s))
          return !0;
        if (!this.statefullCache)
          return !1;
        for (var l = 0, c = this._objects.length; l < c; l++)
          if (this._objects[l].isCacheDirty(!0)) {
            if (this._cacheCanvas) {
              var f = this.cacheWidth / this.zoomX, m = this.cacheHeight / this.zoomY;
              this._cacheContext.clearRect(-f / 2, -m / 2, f, m);
            }
            return !0;
          }
        return !1;
      },
      _restoreObjectsState: function() {
        var s = this.calcOwnMatrix();
        return this._objects.forEach(function(l) {
          n.util.addTransformToObject(l, s), delete l.group, l.setCoords();
        }), this;
      },
      destroy: function() {
        return this._objects.forEach(function(s) {
          s.set("dirty", !0);
        }), this._restoreObjectsState();
      },
      dispose: function() {
        this.callSuper("dispose"), this.forEachObject(function(s) {
          s.dispose && s.dispose();
        }), this._objects = [];
      },
      toActiveSelection: function() {
        if (!!this.canvas) {
          var s = this._objects, l = this.canvas;
          this._objects = [];
          var c = this.toObject();
          delete c.objects;
          var f = new n.ActiveSelection([]);
          return f.set(c), f.type = "activeSelection", l.remove(this), s.forEach(function(m) {
            m.group = f, m.dirty = !0, l.add(m);
          }), f.canvas = l, f._objects = s, l._activeObject = f, f.setCoords(), f;
        }
      },
      ungroupOnCanvas: function() {
        return this._restoreObjectsState();
      },
      setObjectsCoords: function() {
        var s = !0;
        return this.forEachObject(function(l) {
          l.setCoords(s);
        }), this;
      },
      _calcBounds: function(s) {
        for (var l = [], c = [], f, m, d, v = ["tr", "br", "bl", "tl"], b = 0, y = this._objects.length, w, _ = v.length; b < y; ++b) {
          for (f = this._objects[b], d = f.calcACoords(), w = 0; w < _; w++)
            m = v[w], l.push(d[m].x), c.push(d[m].y);
          f.aCoords = d;
        }
        this._getBounds(l, c, s);
      },
      _getBounds: function(s, l, c) {
        var f = new n.Point(u(s), u(l)), m = new n.Point(h(s), h(l)), d = f.y || 0, v = f.x || 0, b = m.x - f.x || 0, y = m.y - f.y || 0;
        this.width = b, this.height = y, c || this.setPositionByOrigin({ x: v, y: d }, "left", "top");
      },
      _toSVG: function(s) {
        for (var l = ["<g ", "COMMON_PARTS", ` >
`], c = 0, f = this._objects.length; c < f; c++)
          l.push("		", this._objects[c].toSVG(s));
        return l.push(`</g>
`), l;
      },
      getSvgStyles: function() {
        var s = typeof this.opacity < "u" && this.opacity !== 1 ? "opacity: " + this.opacity + ";" : "", l = this.visible ? "" : " visibility: hidden;";
        return [
          s,
          this.getSvgFilter(),
          l
        ].join("");
      },
      toClipPathSVG: function(s) {
        for (var l = [], c = 0, f = this._objects.length; c < f; c++)
          l.push("	", this._objects[c].toClipPathSVG(s));
        return this._createBaseClipPathSVGMarkup(l, { reviver: s });
      }
    }), n.Group.fromObject = function(s, l) {
      var c = s.objects, f = n.util.object.clone(s, !0);
      if (delete f.objects, typeof c == "string") {
        n.loadSVGFromURL(c, function(m) {
          var d = n.util.groupSVGElements(m, s, c), v = f.clipPath;
          delete f.clipPath, d.set(f), v ? n.util.enlivenObjects([v], function(b) {
            d.clipPath = b[0], l && l(d);
          }) : l && l(d);
        });
        return;
      }
      n.util.enlivenObjects(c, function(m) {
        n.util.enlivenObjectEnlivables(s, f, function() {
          l && l(new n.Group(m, f, !0));
        });
      });
    });
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {});
    n.ActiveSelection || (n.ActiveSelection = n.util.createClass(n.Group, {
      type: "activeSelection",
      initialize: function(u, h) {
        h = h || {}, this._objects = u || [];
        for (var s = this._objects.length; s--; )
          this._objects[s].group = this;
        h.originX && (this.originX = h.originX), h.originY && (this.originY = h.originY), this._calcBounds(), this._updateObjectsCoords(), n.Object.prototype.initialize.call(this, h), this.setCoords();
      },
      toGroup: function() {
        var u = this._objects.concat();
        this._objects = [];
        var h = n.Object.prototype.toObject.call(this), s = new n.Group([]);
        if (delete h.type, s.set(h), u.forEach(function(c) {
          c.canvas.remove(c), c.group = s;
        }), s._objects = u, !this.canvas)
          return s;
        var l = this.canvas;
        return l.add(s), l._activeObject = s, s.setCoords(), s;
      },
      onDeselect: function() {
        return this.destroy(), !1;
      },
      toString: function() {
        return "#<fabric.ActiveSelection: (" + this.complexity() + ")>";
      },
      shouldCache: function() {
        return !1;
      },
      isOnACache: function() {
        return !1;
      },
      _renderControls: function(u, h, s) {
        u.save(), u.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1, this.callSuper("_renderControls", u, h), s = s || {}, typeof s.hasControls > "u" && (s.hasControls = !1), s.forActiveSelection = !0;
        for (var l = 0, c = this._objects.length; l < c; l++)
          this._objects[l]._renderControls(u, s);
        u.restore();
      }
    }), n.ActiveSelection.fromObject = function(u, h) {
      n.util.enlivenObjects(u.objects, function(s) {
        delete u.objects, h && h(new n.ActiveSelection(s, u, !0));
      });
    });
  }(t), function(a) {
    var n = e.util.object.extend;
    if (a.fabric || (a.fabric = {}), a.fabric.Image) {
      e.warn("fabric.Image is already defined.");
      return;
    }
    e.Image = e.util.createClass(e.Object, {
      type: "image",
      strokeWidth: 0,
      srcFromAttribute: !1,
      _lastScaleX: 1,
      _lastScaleY: 1,
      _filterScalingX: 1,
      _filterScalingY: 1,
      minimumScaleTrigger: 0.5,
      stateProperties: e.Object.prototype.stateProperties.concat("cropX", "cropY"),
      cacheProperties: e.Object.prototype.cacheProperties.concat("cropX", "cropY"),
      cacheKey: "",
      cropX: 0,
      cropY: 0,
      imageSmoothing: !0,
      initialize: function(u, h) {
        h || (h = {}), this.filters = [], this.cacheKey = "texture" + e.Object.__uid++, this.callSuper("initialize", h), this._initElement(u, h);
      },
      getElement: function() {
        return this._element || {};
      },
      setElement: function(u, h) {
        return this.removeTexture(this.cacheKey), this.removeTexture(this.cacheKey + "_filtered"), this._element = u, this._originalElement = u, this._initConfig(h), this.filters.length !== 0 && this.applyFilters(), this.resizeFilter && this.applyResizeFilters(), this;
      },
      removeTexture: function(u) {
        var h = e.filterBackend;
        h && h.evictCachesForKey && h.evictCachesForKey(u);
      },
      dispose: function() {
        this.callSuper("dispose"), this.removeTexture(this.cacheKey), this.removeTexture(this.cacheKey + "_filtered"), this._cacheContext = void 0, ["_originalElement", "_element", "_filteredEl", "_cacheCanvas"].forEach(function(u) {
          e.util.cleanUpJsdomNode(this[u]), this[u] = void 0;
        }.bind(this));
      },
      getCrossOrigin: function() {
        return this._originalElement && (this._originalElement.crossOrigin || null);
      },
      getOriginalSize: function() {
        var u = this.getElement();
        return {
          width: u.naturalWidth || u.width,
          height: u.naturalHeight || u.height
        };
      },
      _stroke: function(u) {
        if (!(!this.stroke || this.strokeWidth === 0)) {
          var h = this.width / 2, s = this.height / 2;
          u.beginPath(), u.moveTo(-h, -s), u.lineTo(h, -s), u.lineTo(h, s), u.lineTo(-h, s), u.lineTo(-h, -s), u.closePath();
        }
      },
      toObject: function(u) {
        var h = [];
        this.filters.forEach(function(l) {
          l && h.push(l.toObject());
        });
        var s = n(
          this.callSuper(
            "toObject",
            ["cropX", "cropY"].concat(u)
          ),
          {
            src: this.getSrc(),
            crossOrigin: this.getCrossOrigin(),
            filters: h
          }
        );
        return this.resizeFilter && (s.resizeFilter = this.resizeFilter.toObject()), s;
      },
      hasCrop: function() {
        return this.cropX || this.cropY || this.width < this._element.width || this.height < this._element.height;
      },
      _toSVG: function() {
        var u = [], h = [], s, l = this._element, c = -this.width / 2, f = -this.height / 2, m = "", d = "";
        if (!l)
          return [];
        if (this.hasCrop()) {
          var v = e.Object.__uid++;
          u.push(
            '<clipPath id="imageCrop_' + v + `">
`,
            '	<rect x="' + c + '" y="' + f + '" width="' + this.width + '" height="' + this.height + `" />
`,
            `</clipPath>
`
          ), m = ' clip-path="url(#imageCrop_' + v + ')" ';
        }
        if (this.imageSmoothing || (d = '" image-rendering="optimizeSpeed'), h.push(
          "	<image ",
          "COMMON_PARTS",
          'xlink:href="',
          this.getSvgSrc(!0),
          '" x="',
          c - this.cropX,
          '" y="',
          f - this.cropY,
          '" width="',
          l.width || l.naturalWidth,
          '" height="',
          l.height || l.height,
          d,
          '"',
          m,
          `></image>
`
        ), this.stroke || this.strokeDashArray) {
          var b = this.fill;
          this.fill = null, s = [
            "	<rect ",
            'x="',
            c,
            '" y="',
            f,
            '" width="',
            this.width,
            '" height="',
            this.height,
            '" style="',
            this.getSvgStyles(),
            `"/>
`
          ], this.fill = b;
        }
        return this.paintFirst !== "fill" ? u = u.concat(s, h) : u = u.concat(h, s), u;
      },
      getSrc: function(u) {
        var h = u ? this._element : this._originalElement;
        return h ? h.toDataURL ? h.toDataURL() : this.srcFromAttribute ? h.getAttribute("src") : h.src : this.src || "";
      },
      setSrc: function(u, h, s) {
        return e.util.loadImage(u, function(l, c) {
          this.setElement(l, s), this._setWidthHeight(), h && h(this, c);
        }, this, s && s.crossOrigin), this;
      },
      toString: function() {
        return '#<fabric.Image: { src: "' + this.getSrc() + '" }>';
      },
      applyResizeFilters: function() {
        var u = this.resizeFilter, h = this.minimumScaleTrigger, s = this.getTotalObjectScaling(), l = s.scaleX, c = s.scaleY, f = this._filteredEl || this._originalElement;
        if (this.group && this.set("dirty", !0), !u || l > h && c > h) {
          this._element = f, this._filterScalingX = 1, this._filterScalingY = 1, this._lastScaleX = l, this._lastScaleY = c;
          return;
        }
        e.filterBackend || (e.filterBackend = e.initFilterBackend());
        var m = e.util.createCanvasElement(), d = this._filteredEl ? this.cacheKey + "_filtered" : this.cacheKey, v = f.width, b = f.height;
        m.width = v, m.height = b, this._element = m, this._lastScaleX = u.scaleX = l, this._lastScaleY = u.scaleY = c, e.filterBackend.applyFilters(
          [u],
          f,
          v,
          b,
          this._element,
          d
        ), this._filterScalingX = m.width / this._originalElement.width, this._filterScalingY = m.height / this._originalElement.height;
      },
      applyFilters: function(u) {
        if (u = u || this.filters || [], u = u.filter(function(f) {
          return f && !f.isNeutralState();
        }), this.set("dirty", !0), this.removeTexture(this.cacheKey + "_filtered"), u.length === 0)
          return this._element = this._originalElement, this._filteredEl = null, this._filterScalingX = 1, this._filterScalingY = 1, this;
        var h = this._originalElement, s = h.naturalWidth || h.width, l = h.naturalHeight || h.height;
        if (this._element === this._originalElement) {
          var c = e.util.createCanvasElement();
          c.width = s, c.height = l, this._element = c, this._filteredEl = c;
        } else
          this._element = this._filteredEl, this._filteredEl.getContext("2d").clearRect(0, 0, s, l), this._lastScaleX = 1, this._lastScaleY = 1;
        return e.filterBackend || (e.filterBackend = e.initFilterBackend()), e.filterBackend.applyFilters(
          u,
          this._originalElement,
          s,
          l,
          this._element,
          this.cacheKey
        ), (this._originalElement.width !== this._element.width || this._originalElement.height !== this._element.height) && (this._filterScalingX = this._element.width / this._originalElement.width, this._filterScalingY = this._element.height / this._originalElement.height), this;
      },
      _render: function(u) {
        e.util.setImageSmoothing(u, this.imageSmoothing), this.isMoving !== !0 && this.resizeFilter && this._needsResize() && this.applyResizeFilters(), this._stroke(u), this._renderPaintInOrder(u);
      },
      drawCacheOnCanvas: function(u) {
        e.util.setImageSmoothing(u, this.imageSmoothing), e.Object.prototype.drawCacheOnCanvas.call(this, u);
      },
      shouldCache: function() {
        return this.needsItsOwnCache();
      },
      _renderFill: function(u) {
        var h = this._element;
        if (!!h) {
          var s = this._filterScalingX, l = this._filterScalingY, c = this.width, f = this.height, m = Math.min, d = Math.max, v = d(this.cropX, 0), b = d(this.cropY, 0), y = h.naturalWidth || h.width, w = h.naturalHeight || h.height, _ = v * s, S = b * l, T = m(c * s, y - _), A = m(f * l, w - S), R = -c / 2, N = -f / 2, U = m(c, y / s - v), Q = m(f, w / l - b);
          h && u.drawImage(h, _, S, T, A, R, N, U, Q);
        }
      },
      _needsResize: function() {
        var u = this.getTotalObjectScaling();
        return u.scaleX !== this._lastScaleX || u.scaleY !== this._lastScaleY;
      },
      _resetWidthHeight: function() {
        this.set(this.getOriginalSize());
      },
      _initElement: function(u, h) {
        this.setElement(e.util.getById(u), h), e.util.addClass(this.getElement(), e.Image.CSS_CANVAS);
      },
      _initConfig: function(u) {
        u || (u = {}), this.setOptions(u), this._setWidthHeight(u);
      },
      _initFilters: function(u, h) {
        u && u.length ? e.util.enlivenObjects(u, function(s) {
          h && h(s);
        }, "fabric.Image.filters") : h && h();
      },
      _setWidthHeight: function(u) {
        u || (u = {});
        var h = this.getElement();
        this.width = u.width || h.naturalWidth || h.width || 0, this.height = u.height || h.naturalHeight || h.height || 0;
      },
      parsePreserveAspectRatioAttribute: function() {
        var u = e.util.parsePreserveAspectRatioAttribute(this.preserveAspectRatio || ""), h = this._element.width, s = this._element.height, l = 1, c = 1, f = 0, m = 0, d = 0, v = 0, b, y = this.width, w = this.height, _ = { width: y, height: w };
        return u && (u.alignX !== "none" || u.alignY !== "none") ? (u.meetOrSlice === "meet" && (l = c = e.util.findScaleToFit(this._element, _), b = (y - h * l) / 2, u.alignX === "Min" && (f = -b), u.alignX === "Max" && (f = b), b = (w - s * c) / 2, u.alignY === "Min" && (m = -b), u.alignY === "Max" && (m = b)), u.meetOrSlice === "slice" && (l = c = e.util.findScaleToCover(this._element, _), b = h - y / l, u.alignX === "Mid" && (d = b / 2), u.alignX === "Max" && (d = b), b = s - w / c, u.alignY === "Mid" && (v = b / 2), u.alignY === "Max" && (v = b), h = y / l, s = w / c)) : (l = y / h, c = w / s), {
          width: h,
          height: s,
          scaleX: l,
          scaleY: c,
          offsetLeft: f,
          offsetTop: m,
          cropX: d,
          cropY: v
        };
      }
    }), e.Image.CSS_CANVAS = "canvas-img", e.Image.prototype.getSvgSrc = e.Image.prototype.getSrc, e.Image.fromObject = function(u, h) {
      var s = e.util.object.clone(u);
      e.util.loadImage(s.src, function(l, c) {
        if (c) {
          h && h(null, !0);
          return;
        }
        e.Image.prototype._initFilters.call(s, s.filters, function(f) {
          s.filters = f || [], e.Image.prototype._initFilters.call(s, [s.resizeFilter], function(m) {
            s.resizeFilter = m[0], e.util.enlivenObjectEnlivables(s, s, function() {
              var d = new e.Image(l, s);
              h(d, !1);
            });
          });
        });
      }, null, s.crossOrigin);
    }, e.Image.fromURL = function(u, h, s) {
      e.util.loadImage(u, function(l, c) {
        h && h(new e.Image(l, s), c);
      }, null, s && s.crossOrigin);
    }, e.Image.ATTRIBUTE_NAMES = e.SHARED_ATTRIBUTES.concat(
      "x y width height preserveAspectRatio xlink:href crossOrigin image-rendering".split(" ")
    ), e.Image.fromElement = function(u, h, s) {
      var l = e.parseAttributes(u, e.Image.ATTRIBUTE_NAMES);
      e.Image.fromURL(
        l["xlink:href"],
        h,
        n(s ? e.util.object.clone(s) : {}, l)
      );
    };
  }(t), e.util.object.extend(e.Object.prototype, {
    _getAngleValueForStraighten: function() {
      var a = this.angle % 360;
      return a > 0 ? Math.round((a - 1) / 90) * 90 : Math.round(a / 90) * 90;
    },
    straighten: function() {
      return this.rotate(this._getAngleValueForStraighten());
    },
    fxStraighten: function(a) {
      a = a || {};
      var n = function() {
      }, u = a.onComplete || n, h = a.onChange || n, s = this;
      return e.util.animate({
        target: this,
        startValue: this.get("angle"),
        endValue: this._getAngleValueForStraighten(),
        duration: this.FX_DURATION,
        onChange: function(l) {
          s.rotate(l), h();
        },
        onComplete: function() {
          s.setCoords(), u();
        }
      });
    }
  }), e.util.object.extend(e.StaticCanvas.prototype, {
    straightenObject: function(a) {
      return a.straighten(), this.requestRenderAll(), this;
    },
    fxStraightenObject: function(a) {
      return a.fxStraighten({
        onChange: this.requestRenderAllBound
      });
    }
  }), function() {
    function a(u, h) {
      var s = "precision " + h + ` float;
void main(){}`, l = u.createShader(u.FRAGMENT_SHADER);
      return u.shaderSource(l, s), u.compileShader(l), !!u.getShaderParameter(l, u.COMPILE_STATUS);
    }
    e.isWebglSupported = function(u) {
      if (e.isLikelyNode)
        return !1;
      u = u || e.WebglFilterBackend.prototype.tileSize;
      var h = document.createElement("canvas"), s = h.getContext("webgl") || h.getContext("experimental-webgl"), l = !1;
      if (s) {
        e.maxTextureSize = s.getParameter(s.MAX_TEXTURE_SIZE), l = e.maxTextureSize >= u;
        for (var c = ["highp", "mediump", "lowp"], f = 0; f < 3; f++)
          if (a(s, c[f])) {
            e.webGlPrecision = c[f];
            break;
          }
      }
      return this.isSupported = l, l;
    }, e.WebglFilterBackend = n;
    function n(u) {
      u && u.tileSize && (this.tileSize = u.tileSize), this.setupGLContext(this.tileSize, this.tileSize), this.captureGPUInfo();
    }
    n.prototype = {
      tileSize: 2048,
      resources: {},
      setupGLContext: function(u, h) {
        this.dispose(), this.createWebGLCanvas(u, h), this.aPosition = new Float32Array([0, 0, 0, 1, 1, 0, 1, 1]), this.chooseFastestCopyGLTo2DMethod(u, h);
      },
      chooseFastestCopyGLTo2DMethod: function(u, h) {
        var s = typeof window.performance < "u", l;
        try {
          new ImageData(1, 1), l = !0;
        } catch {
          l = !1;
        }
        var c = typeof ArrayBuffer < "u", f = typeof Uint8ClampedArray < "u";
        if (!!(s && l && c && f)) {
          var m = e.util.createCanvasElement(), d = new ArrayBuffer(u * h * 4);
          if (e.forceGLPutImageData) {
            this.imageBuffer = d, this.copyGLTo2D = g;
            return;
          }
          var v = {
            imageBuffer: d,
            destinationWidth: u,
            destinationHeight: h,
            targetCanvas: m
          }, b, y, w;
          m.width = u, m.height = h, b = window.performance.now(), p.call(v, this.gl, v), y = window.performance.now() - b, b = window.performance.now(), g.call(v, this.gl, v), w = window.performance.now() - b, y > w ? (this.imageBuffer = d, this.copyGLTo2D = g) : this.copyGLTo2D = p;
        }
      },
      createWebGLCanvas: function(u, h) {
        var s = e.util.createCanvasElement();
        s.width = u, s.height = h;
        var l = {
          alpha: !0,
          premultipliedAlpha: !1,
          depth: !1,
          stencil: !1,
          antialias: !1
        }, c = s.getContext("webgl", l);
        c || (c = s.getContext("experimental-webgl", l)), c && (c.clearColor(0, 0, 0, 0), this.canvas = s, this.gl = c);
      },
      applyFilters: function(u, h, s, l, c, f) {
        var m = this.gl, d;
        f && (d = this.getCachedTexture(f, h));
        var v = {
          originalWidth: h.width || h.originalWidth,
          originalHeight: h.height || h.originalHeight,
          sourceWidth: s,
          sourceHeight: l,
          destinationWidth: s,
          destinationHeight: l,
          context: m,
          sourceTexture: this.createTexture(m, s, l, !d && h),
          targetTexture: this.createTexture(m, s, l),
          originalTexture: d || this.createTexture(m, s, l, !d && h),
          passes: u.length,
          webgl: !0,
          aPosition: this.aPosition,
          programCache: this.programCache,
          pass: 0,
          filterBackend: this,
          targetCanvas: c
        }, b = m.createFramebuffer();
        return m.bindFramebuffer(m.FRAMEBUFFER, b), u.forEach(function(y) {
          y && y.applyTo(v);
        }), o(v), this.copyGLTo2D(m, v), m.bindTexture(m.TEXTURE_2D, null), m.deleteTexture(v.sourceTexture), m.deleteTexture(v.targetTexture), m.deleteFramebuffer(b), c.getContext("2d").setTransform(1, 0, 0, 1, 0, 0), v;
      },
      dispose: function() {
        this.canvas && (this.canvas = null, this.gl = null), this.clearWebGLCaches();
      },
      clearWebGLCaches: function() {
        this.programCache = {}, this.textureCache = {};
      },
      createTexture: function(u, h, s, l) {
        var c = u.createTexture();
        return u.bindTexture(u.TEXTURE_2D, c), u.texParameteri(u.TEXTURE_2D, u.TEXTURE_MAG_FILTER, u.NEAREST), u.texParameteri(u.TEXTURE_2D, u.TEXTURE_MIN_FILTER, u.NEAREST), u.texParameteri(u.TEXTURE_2D, u.TEXTURE_WRAP_S, u.CLAMP_TO_EDGE), u.texParameteri(u.TEXTURE_2D, u.TEXTURE_WRAP_T, u.CLAMP_TO_EDGE), l ? u.texImage2D(u.TEXTURE_2D, 0, u.RGBA, u.RGBA, u.UNSIGNED_BYTE, l) : u.texImage2D(u.TEXTURE_2D, 0, u.RGBA, h, s, 0, u.RGBA, u.UNSIGNED_BYTE, null), c;
      },
      getCachedTexture: function(u, h) {
        if (this.textureCache[u])
          return this.textureCache[u];
        var s = this.createTexture(
          this.gl,
          h.width,
          h.height,
          h
        );
        return this.textureCache[u] = s, s;
      },
      evictCachesForKey: function(u) {
        this.textureCache[u] && (this.gl.deleteTexture(this.textureCache[u]), delete this.textureCache[u]);
      },
      copyGLTo2D: p,
      captureGPUInfo: function() {
        if (this.gpuInfo)
          return this.gpuInfo;
        var u = this.gl, h = { renderer: "", vendor: "" };
        if (!u)
          return h;
        var s = u.getExtension("WEBGL_debug_renderer_info");
        if (s) {
          var l = u.getParameter(s.UNMASKED_RENDERER_WEBGL), c = u.getParameter(s.UNMASKED_VENDOR_WEBGL);
          l && (h.renderer = l.toLowerCase()), c && (h.vendor = c.toLowerCase());
        }
        return this.gpuInfo = h, h;
      }
    };
  }();
  function o(a) {
    var n = a.targetCanvas, u = n.width, h = n.height, s = a.destinationWidth, l = a.destinationHeight;
    (u !== s || h !== l) && (n.width = s, n.height = l);
  }
  function p(a, n) {
    var u = a.canvas, h = n.targetCanvas, s = h.getContext("2d");
    s.translate(0, h.height), s.scale(1, -1);
    var l = u.height - h.height;
    s.drawImage(
      u,
      0,
      l,
      h.width,
      h.height,
      0,
      0,
      h.width,
      h.height
    );
  }
  function g(a, n) {
    var u = n.targetCanvas, h = u.getContext("2d"), s = n.destinationWidth, l = n.destinationHeight, c = s * l * 4, f = new Uint8Array(this.imageBuffer, 0, c), m = new Uint8ClampedArray(this.imageBuffer, 0, c);
    a.readPixels(0, 0, s, l, a.RGBA, a.UNSIGNED_BYTE, f);
    var d = new ImageData(m, s, l);
    h.putImageData(d, 0, 0);
  }
  (function() {
    var a = function() {
    };
    e.Canvas2dFilterBackend = n;
    function n() {
    }
    n.prototype = {
      evictCachesForKey: a,
      dispose: a,
      clearWebGLCaches: a,
      resources: {},
      applyFilters: function(u, h, s, l, c) {
        var f = c.getContext("2d");
        f.drawImage(h, 0, 0, s, l);
        var m = f.getImageData(0, 0, s, l), d = f.getImageData(0, 0, s, l), v = {
          sourceWidth: s,
          sourceHeight: l,
          imageData: m,
          originalEl: h,
          originalImageData: d,
          canvasEl: c,
          ctx: f,
          filterBackend: this
        };
        return u.forEach(function(b) {
          b.applyTo(v);
        }), (v.imageData.width !== s || v.imageData.height !== l) && (c.width = v.imageData.width, c.height = v.imageData.height), f.putImageData(v.imageData, 0, 0), v;
      }
    };
  })(), e.Image = e.Image || {}, e.Image.filters = e.Image.filters || {}, e.Image.filters.BaseFilter = e.util.createClass({
    type: "BaseFilter",
    vertexSource: `attribute vec2 aPosition;
varying vec2 vTexCoord;
void main() {
vTexCoord = aPosition;
gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
}`,
    fragmentSource: `precision highp float;
varying vec2 vTexCoord;
uniform sampler2D uTexture;
void main() {
gl_FragColor = texture2D(uTexture, vTexCoord);
}`,
    initialize: function(a) {
      a && this.setOptions(a);
    },
    setOptions: function(a) {
      for (var n in a)
        this[n] = a[n];
    },
    createProgram: function(a, n, u) {
      n = n || this.fragmentSource, u = u || this.vertexSource, e.webGlPrecision !== "highp" && (n = n.replace(
        /precision highp float/g,
        "precision " + e.webGlPrecision + " float"
      ));
      var h = a.createShader(a.VERTEX_SHADER);
      if (a.shaderSource(h, u), a.compileShader(h), !a.getShaderParameter(h, a.COMPILE_STATUS))
        throw new Error(
          "Vertex shader compile error for " + this.type + ": " + a.getShaderInfoLog(h)
        );
      var s = a.createShader(a.FRAGMENT_SHADER);
      if (a.shaderSource(s, n), a.compileShader(s), !a.getShaderParameter(s, a.COMPILE_STATUS))
        throw new Error(
          "Fragment shader compile error for " + this.type + ": " + a.getShaderInfoLog(s)
        );
      var l = a.createProgram();
      if (a.attachShader(l, h), a.attachShader(l, s), a.linkProgram(l), !a.getProgramParameter(l, a.LINK_STATUS))
        throw new Error(
          'Shader link error for "${this.type}" ' + a.getProgramInfoLog(l)
        );
      var c = this.getAttributeLocations(a, l), f = this.getUniformLocations(a, l) || {};
      return f.uStepW = a.getUniformLocation(l, "uStepW"), f.uStepH = a.getUniformLocation(l, "uStepH"), {
        program: l,
        attributeLocations: c,
        uniformLocations: f
      };
    },
    getAttributeLocations: function(a, n) {
      return {
        aPosition: a.getAttribLocation(n, "aPosition")
      };
    },
    getUniformLocations: function() {
      return {};
    },
    sendAttributeData: function(a, n, u) {
      var h = n.aPosition, s = a.createBuffer();
      a.bindBuffer(a.ARRAY_BUFFER, s), a.enableVertexAttribArray(h), a.vertexAttribPointer(h, 2, a.FLOAT, !1, 0, 0), a.bufferData(a.ARRAY_BUFFER, u, a.STATIC_DRAW);
    },
    _setupFrameBuffer: function(a) {
      var n = a.context, u, h;
      a.passes > 1 ? (u = a.destinationWidth, h = a.destinationHeight, (a.sourceWidth !== u || a.sourceHeight !== h) && (n.deleteTexture(a.targetTexture), a.targetTexture = a.filterBackend.createTexture(n, u, h)), n.framebufferTexture2D(
        n.FRAMEBUFFER,
        n.COLOR_ATTACHMENT0,
        n.TEXTURE_2D,
        a.targetTexture,
        0
      )) : (n.bindFramebuffer(n.FRAMEBUFFER, null), n.finish());
    },
    _swapTextures: function(a) {
      a.passes--, a.pass++;
      var n = a.targetTexture;
      a.targetTexture = a.sourceTexture, a.sourceTexture = n;
    },
    isNeutralState: function() {
      var a = this.mainParameter, n = e.Image.filters[this.type].prototype;
      if (a)
        if (Array.isArray(n[a])) {
          for (var u = n[a].length; u--; )
            if (this[a][u] !== n[a][u])
              return !1;
          return !0;
        } else
          return n[a] === this[a];
      else
        return !1;
    },
    applyTo: function(a) {
      a.webgl ? (this._setupFrameBuffer(a), this.applyToWebGL(a), this._swapTextures(a)) : this.applyTo2d(a);
    },
    retrieveShader: function(a) {
      return a.programCache.hasOwnProperty(this.type) || (a.programCache[this.type] = this.createProgram(a.context)), a.programCache[this.type];
    },
    applyToWebGL: function(a) {
      var n = a.context, u = this.retrieveShader(a);
      a.pass === 0 && a.originalTexture ? n.bindTexture(n.TEXTURE_2D, a.originalTexture) : n.bindTexture(n.TEXTURE_2D, a.sourceTexture), n.useProgram(u.program), this.sendAttributeData(n, u.attributeLocations, a.aPosition), n.uniform1f(u.uniformLocations.uStepW, 1 / a.sourceWidth), n.uniform1f(u.uniformLocations.uStepH, 1 / a.sourceHeight), this.sendUniformData(n, u.uniformLocations), n.viewport(0, 0, a.destinationWidth, a.destinationHeight), n.drawArrays(n.TRIANGLE_STRIP, 0, 4);
    },
    bindAdditionalTexture: function(a, n, u) {
      a.activeTexture(u), a.bindTexture(a.TEXTURE_2D, n), a.activeTexture(a.TEXTURE0);
    },
    unbindAdditionalTexture: function(a, n) {
      a.activeTexture(n), a.bindTexture(a.TEXTURE_2D, null), a.activeTexture(a.TEXTURE0);
    },
    getMainParameter: function() {
      return this[this.mainParameter];
    },
    setMainParameter: function(a) {
      this[this.mainParameter] = a;
    },
    sendUniformData: function() {
    },
    createHelpLayer: function(a) {
      if (!a.helpLayer) {
        var n = document.createElement("canvas");
        n.width = a.sourceWidth, n.height = a.sourceHeight, a.helpLayer = n;
      }
    },
    toObject: function() {
      var a = { type: this.type }, n = this.mainParameter;
      return n && (a[n] = this[n]), a;
    },
    toJSON: function() {
      return this.toObject();
    }
  }), e.Image.filters.BaseFilter.fromObject = function(a, n) {
    var u = new e.Image.filters[a.type](a);
    return n && n(u), u;
  }, function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.Image.filters, h = n.util.createClass;
    u.ColorMatrix = h(u.BaseFilter, {
      type: "ColorMatrix",
      fragmentSource: `precision highp float;
uniform sampler2D uTexture;
varying vec2 vTexCoord;
uniform mat4 uColorMatrix;
uniform vec4 uConstants;
void main() {
vec4 color = texture2D(uTexture, vTexCoord);
color *= uColorMatrix;
color += uConstants;
gl_FragColor = color;
}`,
      matrix: [
        1,
        0,
        0,
        0,
        0,
        0,
        1,
        0,
        0,
        0,
        0,
        0,
        1,
        0,
        0,
        0,
        0,
        0,
        1,
        0
      ],
      mainParameter: "matrix",
      colorsOnly: !0,
      initialize: function(s) {
        this.callSuper("initialize", s), this.matrix = this.matrix.slice(0);
      },
      applyTo2d: function(s) {
        var l = s.imageData, c = l.data, f = c.length, m = this.matrix, d, v, b, y, w, _ = this.colorsOnly;
        for (w = 0; w < f; w += 4)
          d = c[w], v = c[w + 1], b = c[w + 2], _ ? (c[w] = d * m[0] + v * m[1] + b * m[2] + m[4] * 255, c[w + 1] = d * m[5] + v * m[6] + b * m[7] + m[9] * 255, c[w + 2] = d * m[10] + v * m[11] + b * m[12] + m[14] * 255) : (y = c[w + 3], c[w] = d * m[0] + v * m[1] + b * m[2] + y * m[3] + m[4] * 255, c[w + 1] = d * m[5] + v * m[6] + b * m[7] + y * m[8] + m[9] * 255, c[w + 2] = d * m[10] + v * m[11] + b * m[12] + y * m[13] + m[14] * 255, c[w + 3] = d * m[15] + v * m[16] + b * m[17] + y * m[18] + m[19] * 255);
      },
      getUniformLocations: function(s, l) {
        return {
          uColorMatrix: s.getUniformLocation(l, "uColorMatrix"),
          uConstants: s.getUniformLocation(l, "uConstants")
        };
      },
      sendUniformData: function(s, l) {
        var c = this.matrix, f = [
          c[0],
          c[1],
          c[2],
          c[3],
          c[5],
          c[6],
          c[7],
          c[8],
          c[10],
          c[11],
          c[12],
          c[13],
          c[15],
          c[16],
          c[17],
          c[18]
        ], m = [c[4], c[9], c[14], c[19]];
        s.uniformMatrix4fv(l.uColorMatrix, !1, f), s.uniform4fv(l.uConstants, m);
      }
    }), n.Image.filters.ColorMatrix.fromObject = n.Image.filters.BaseFilter.fromObject;
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.Image.filters, h = n.util.createClass;
    u.Brightness = h(u.BaseFilter, {
      type: "Brightness",
      fragmentSource: `precision highp float;
uniform sampler2D uTexture;
uniform float uBrightness;
varying vec2 vTexCoord;
void main() {
vec4 color = texture2D(uTexture, vTexCoord);
color.rgb += uBrightness;
gl_FragColor = color;
}`,
      brightness: 0,
      mainParameter: "brightness",
      applyTo2d: function(s) {
        if (this.brightness !== 0) {
          var l = s.imageData, c = l.data, f, m = c.length, d = Math.round(this.brightness * 255);
          for (f = 0; f < m; f += 4)
            c[f] = c[f] + d, c[f + 1] = c[f + 1] + d, c[f + 2] = c[f + 2] + d;
        }
      },
      getUniformLocations: function(s, l) {
        return {
          uBrightness: s.getUniformLocation(l, "uBrightness")
        };
      },
      sendUniformData: function(s, l) {
        s.uniform1f(l.uBrightness, this.brightness);
      }
    }), n.Image.filters.Brightness.fromObject = n.Image.filters.BaseFilter.fromObject;
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.util.object.extend, h = n.Image.filters, s = n.util.createClass;
    h.Convolute = s(h.BaseFilter, {
      type: "Convolute",
      opaque: !1,
      matrix: [0, 0, 0, 0, 1, 0, 0, 0, 0],
      fragmentSource: {
        Convolute_3_1: `precision highp float;
uniform sampler2D uTexture;
uniform float uMatrix[9];
uniform float uStepW;
uniform float uStepH;
varying vec2 vTexCoord;
void main() {
vec4 color = vec4(0, 0, 0, 0);
for (float h = 0.0; h < 3.0; h+=1.0) {
for (float w = 0.0; w < 3.0; w+=1.0) {
vec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1));
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)];
}
}
gl_FragColor = color;
}`,
        Convolute_3_0: `precision highp float;
uniform sampler2D uTexture;
uniform float uMatrix[9];
uniform float uStepW;
uniform float uStepH;
varying vec2 vTexCoord;
void main() {
vec4 color = vec4(0, 0, 0, 1);
for (float h = 0.0; h < 3.0; h+=1.0) {
for (float w = 0.0; w < 3.0; w+=1.0) {
vec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0));
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)];
}
}
float alpha = texture2D(uTexture, vTexCoord).a;
gl_FragColor = color;
gl_FragColor.a = alpha;
}`,
        Convolute_5_1: `precision highp float;
uniform sampler2D uTexture;
uniform float uMatrix[25];
uniform float uStepW;
uniform float uStepH;
varying vec2 vTexCoord;
void main() {
vec4 color = vec4(0, 0, 0, 0);
for (float h = 0.0; h < 5.0; h+=1.0) {
for (float w = 0.0; w < 5.0; w+=1.0) {
vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)];
}
}
gl_FragColor = color;
}`,
        Convolute_5_0: `precision highp float;
uniform sampler2D uTexture;
uniform float uMatrix[25];
uniform float uStepW;
uniform float uStepH;
varying vec2 vTexCoord;
void main() {
vec4 color = vec4(0, 0, 0, 1);
for (float h = 0.0; h < 5.0; h+=1.0) {
for (float w = 0.0; w < 5.0; w+=1.0) {
vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)];
}
}
float alpha = texture2D(uTexture, vTexCoord).a;
gl_FragColor = color;
gl_FragColor.a = alpha;
}`,
        Convolute_7_1: `precision highp float;
uniform sampler2D uTexture;
uniform float uMatrix[49];
uniform float uStepW;
uniform float uStepH;
varying vec2 vTexCoord;
void main() {
vec4 color = vec4(0, 0, 0, 0);
for (float h = 0.0; h < 7.0; h+=1.0) {
for (float w = 0.0; w < 7.0; w+=1.0) {
vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)];
}
}
gl_FragColor = color;
}`,
        Convolute_7_0: `precision highp float;
uniform sampler2D uTexture;
uniform float uMatrix[49];
uniform float uStepW;
uniform float uStepH;
varying vec2 vTexCoord;
void main() {
vec4 color = vec4(0, 0, 0, 1);
for (float h = 0.0; h < 7.0; h+=1.0) {
for (float w = 0.0; w < 7.0; w+=1.0) {
vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)];
}
}
float alpha = texture2D(uTexture, vTexCoord).a;
gl_FragColor = color;
gl_FragColor.a = alpha;
}`,
        Convolute_9_1: `precision highp float;
uniform sampler2D uTexture;
uniform float uMatrix[81];
uniform float uStepW;
uniform float uStepH;
varying vec2 vTexCoord;
void main() {
vec4 color = vec4(0, 0, 0, 0);
for (float h = 0.0; h < 9.0; h+=1.0) {
for (float w = 0.0; w < 9.0; w+=1.0) {
vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)];
}
}
gl_FragColor = color;
}`,
        Convolute_9_0: `precision highp float;
uniform sampler2D uTexture;
uniform float uMatrix[81];
uniform float uStepW;
uniform float uStepH;
varying vec2 vTexCoord;
void main() {
vec4 color = vec4(0, 0, 0, 1);
for (float h = 0.0; h < 9.0; h+=1.0) {
for (float w = 0.0; w < 9.0; w+=1.0) {
vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)];
}
}
float alpha = texture2D(uTexture, vTexCoord).a;
gl_FragColor = color;
gl_FragColor.a = alpha;
}`
      },
      retrieveShader: function(l) {
        var c = Math.sqrt(this.matrix.length), f = this.type + "_" + c + "_" + (this.opaque ? 1 : 0), m = this.fragmentSource[f];
        return l.programCache.hasOwnProperty(f) || (l.programCache[f] = this.createProgram(l.context, m)), l.programCache[f];
      },
      applyTo2d: function(l) {
        var c = l.imageData, f = c.data, m = this.matrix, d = Math.round(Math.sqrt(m.length)), v = Math.floor(d / 2), b = c.width, y = c.height, w = l.ctx.createImageData(b, y), _ = w.data, S = this.opaque ? 1 : 0, T, A, R, N, U, Q, ee, J, q, re, le, ne, C;
        for (le = 0; le < y; le++)
          for (re = 0; re < b; re++) {
            for (U = (le * b + re) * 4, T = 0, A = 0, R = 0, N = 0, C = 0; C < d; C++)
              for (ne = 0; ne < d; ne++)
                ee = le + C - v, Q = re + ne - v, !(ee < 0 || ee >= y || Q < 0 || Q >= b) && (J = (ee * b + Q) * 4, q = m[C * d + ne], T += f[J] * q, A += f[J + 1] * q, R += f[J + 2] * q, S || (N += f[J + 3] * q));
            _[U] = T, _[U + 1] = A, _[U + 2] = R, S ? _[U + 3] = f[U + 3] : _[U + 3] = N;
          }
        l.imageData = w;
      },
      getUniformLocations: function(l, c) {
        return {
          uMatrix: l.getUniformLocation(c, "uMatrix"),
          uOpaque: l.getUniformLocation(c, "uOpaque"),
          uHalfSize: l.getUniformLocation(c, "uHalfSize"),
          uSize: l.getUniformLocation(c, "uSize")
        };
      },
      sendUniformData: function(l, c) {
        l.uniform1fv(c.uMatrix, this.matrix);
      },
      toObject: function() {
        return u(this.callSuper("toObject"), {
          opaque: this.opaque,
          matrix: this.matrix
        });
      }
    }), n.Image.filters.Convolute.fromObject = n.Image.filters.BaseFilter.fromObject;
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.Image.filters, h = n.util.createClass;
    u.Grayscale = h(u.BaseFilter, {
      type: "Grayscale",
      fragmentSource: {
        average: `precision highp float;
uniform sampler2D uTexture;
varying vec2 vTexCoord;
void main() {
vec4 color = texture2D(uTexture, vTexCoord);
float average = (color.r + color.b + color.g) / 3.0;
gl_FragColor = vec4(average, average, average, color.a);
}`,
        lightness: `precision highp float;
uniform sampler2D uTexture;
uniform int uMode;
varying vec2 vTexCoord;
void main() {
vec4 col = texture2D(uTexture, vTexCoord);
float average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;
gl_FragColor = vec4(average, average, average, col.a);
}`,
        luminosity: `precision highp float;
uniform sampler2D uTexture;
uniform int uMode;
varying vec2 vTexCoord;
void main() {
vec4 col = texture2D(uTexture, vTexCoord);
float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;
gl_FragColor = vec4(average, average, average, col.a);
}`
      },
      mode: "average",
      mainParameter: "mode",
      applyTo2d: function(s) {
        var l = s.imageData, c = l.data, f, m = c.length, d, v = this.mode;
        for (f = 0; f < m; f += 4)
          v === "average" ? d = (c[f] + c[f + 1] + c[f + 2]) / 3 : v === "lightness" ? d = (Math.min(c[f], c[f + 1], c[f + 2]) + Math.max(c[f], c[f + 1], c[f + 2])) / 2 : v === "luminosity" && (d = 0.21 * c[f] + 0.72 * c[f + 1] + 0.07 * c[f + 2]), c[f] = d, c[f + 1] = d, c[f + 2] = d;
      },
      retrieveShader: function(s) {
        var l = this.type + "_" + this.mode;
        if (!s.programCache.hasOwnProperty(l)) {
          var c = this.fragmentSource[this.mode];
          s.programCache[l] = this.createProgram(s.context, c);
        }
        return s.programCache[l];
      },
      getUniformLocations: function(s, l) {
        return {
          uMode: s.getUniformLocation(l, "uMode")
        };
      },
      sendUniformData: function(s, l) {
        var c = 1;
        s.uniform1i(l.uMode, c);
      },
      isNeutralState: function() {
        return !1;
      }
    }), n.Image.filters.Grayscale.fromObject = n.Image.filters.BaseFilter.fromObject;
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.Image.filters, h = n.util.createClass;
    u.Invert = h(u.BaseFilter, {
      type: "Invert",
      fragmentSource: `precision highp float;
uniform sampler2D uTexture;
uniform int uInvert;
varying vec2 vTexCoord;
void main() {
vec4 color = texture2D(uTexture, vTexCoord);
if (uInvert == 1) {
gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a);
} else {
gl_FragColor = color;
}
}`,
      invert: !0,
      mainParameter: "invert",
      applyTo2d: function(s) {
        var l = s.imageData, c = l.data, f, m = c.length;
        for (f = 0; f < m; f += 4)
          c[f] = 255 - c[f], c[f + 1] = 255 - c[f + 1], c[f + 2] = 255 - c[f + 2];
      },
      isNeutralState: function() {
        return !this.invert;
      },
      getUniformLocations: function(s, l) {
        return {
          uInvert: s.getUniformLocation(l, "uInvert")
        };
      },
      sendUniformData: function(s, l) {
        s.uniform1i(l.uInvert, this.invert);
      }
    }), n.Image.filters.Invert.fromObject = n.Image.filters.BaseFilter.fromObject;
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.util.object.extend, h = n.Image.filters, s = n.util.createClass;
    h.Noise = s(h.BaseFilter, {
      type: "Noise",
      fragmentSource: `precision highp float;
uniform sampler2D uTexture;
uniform float uStepH;
uniform float uNoise;
uniform float uSeed;
varying vec2 vTexCoord;
float rand(vec2 co, float seed, float vScale) {
return fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);
}
void main() {
vec4 color = texture2D(uTexture, vTexCoord);
color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;
gl_FragColor = color;
}`,
      mainParameter: "noise",
      noise: 0,
      applyTo2d: function(l) {
        if (this.noise !== 0) {
          var c = l.imageData, f = c.data, m, d = f.length, v = this.noise, b;
          for (m = 0, d = f.length; m < d; m += 4)
            b = (0.5 - Math.random()) * v, f[m] += b, f[m + 1] += b, f[m + 2] += b;
        }
      },
      getUniformLocations: function(l, c) {
        return {
          uNoise: l.getUniformLocation(c, "uNoise"),
          uSeed: l.getUniformLocation(c, "uSeed")
        };
      },
      sendUniformData: function(l, c) {
        l.uniform1f(c.uNoise, this.noise / 255), l.uniform1f(c.uSeed, Math.random());
      },
      toObject: function() {
        return u(this.callSuper("toObject"), {
          noise: this.noise
        });
      }
    }), n.Image.filters.Noise.fromObject = n.Image.filters.BaseFilter.fromObject;
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.Image.filters, h = n.util.createClass;
    u.Pixelate = h(u.BaseFilter, {
      type: "Pixelate",
      blocksize: 4,
      mainParameter: "blocksize",
      fragmentSource: `precision highp float;
uniform sampler2D uTexture;
uniform float uBlocksize;
uniform float uStepW;
uniform float uStepH;
varying vec2 vTexCoord;
void main() {
float blockW = uBlocksize * uStepW;
float blockH = uBlocksize * uStepW;
int posX = int(vTexCoord.x / blockW);
int posY = int(vTexCoord.y / blockH);
float fposX = float(posX);
float fposY = float(posY);
vec2 squareCoords = vec2(fposX * blockW, fposY * blockH);
vec4 color = texture2D(uTexture, squareCoords);
gl_FragColor = color;
}`,
      applyTo2d: function(s) {
        var l = s.imageData, c = l.data, f = l.height, m = l.width, d, v, b, y, w, _, S, T, A, R, N;
        for (v = 0; v < f; v += this.blocksize)
          for (b = 0; b < m; b += this.blocksize)
            for (d = v * 4 * m + b * 4, y = c[d], w = c[d + 1], _ = c[d + 2], S = c[d + 3], R = Math.min(v + this.blocksize, f), N = Math.min(b + this.blocksize, m), T = v; T < R; T++)
              for (A = b; A < N; A++)
                d = T * 4 * m + A * 4, c[d] = y, c[d + 1] = w, c[d + 2] = _, c[d + 3] = S;
      },
      isNeutralState: function() {
        return this.blocksize === 1;
      },
      getUniformLocations: function(s, l) {
        return {
          uBlocksize: s.getUniformLocation(l, "uBlocksize"),
          uStepW: s.getUniformLocation(l, "uStepW"),
          uStepH: s.getUniformLocation(l, "uStepH")
        };
      },
      sendUniformData: function(s, l) {
        s.uniform1f(l.uBlocksize, this.blocksize);
      }
    }), n.Image.filters.Pixelate.fromObject = n.Image.filters.BaseFilter.fromObject;
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.util.object.extend, h = n.Image.filters, s = n.util.createClass;
    h.RemoveColor = s(h.BaseFilter, {
      type: "RemoveColor",
      color: "#FFFFFF",
      fragmentSource: `precision highp float;
uniform sampler2D uTexture;
uniform vec4 uLow;
uniform vec4 uHigh;
varying vec2 vTexCoord;
void main() {
gl_FragColor = texture2D(uTexture, vTexCoord);
if(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {
gl_FragColor.a = 0.0;
}
}`,
      distance: 0.02,
      useAlpha: !1,
      applyTo2d: function(l) {
        var c = l.imageData, f = c.data, m, d = this.distance * 255, v, b, y, w = new n.Color(this.color).getSource(), _ = [
          w[0] - d,
          w[1] - d,
          w[2] - d
        ], S = [
          w[0] + d,
          w[1] + d,
          w[2] + d
        ];
        for (m = 0; m < f.length; m += 4)
          v = f[m], b = f[m + 1], y = f[m + 2], v > _[0] && b > _[1] && y > _[2] && v < S[0] && b < S[1] && y < S[2] && (f[m + 3] = 0);
      },
      getUniformLocations: function(l, c) {
        return {
          uLow: l.getUniformLocation(c, "uLow"),
          uHigh: l.getUniformLocation(c, "uHigh")
        };
      },
      sendUniformData: function(l, c) {
        var f = new n.Color(this.color).getSource(), m = parseFloat(this.distance), d = [
          0 + f[0] / 255 - m,
          0 + f[1] / 255 - m,
          0 + f[2] / 255 - m,
          1
        ], v = [
          f[0] / 255 + m,
          f[1] / 255 + m,
          f[2] / 255 + m,
          1
        ];
        l.uniform4fv(c.uLow, d), l.uniform4fv(c.uHigh, v);
      },
      toObject: function() {
        return u(this.callSuper("toObject"), {
          color: this.color,
          distance: this.distance
        });
      }
    }), n.Image.filters.RemoveColor.fromObject = n.Image.filters.BaseFilter.fromObject;
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.Image.filters, h = n.util.createClass, s = {
      Brownie: [
        0.5997,
        0.34553,
        -0.27082,
        0,
        0.186,
        -0.0377,
        0.86095,
        0.15059,
        0,
        -0.1449,
        0.24113,
        -0.07441,
        0.44972,
        0,
        -0.02965,
        0,
        0,
        0,
        1,
        0
      ],
      Vintage: [
        0.62793,
        0.32021,
        -0.03965,
        0,
        0.03784,
        0.02578,
        0.64411,
        0.03259,
        0,
        0.02926,
        0.0466,
        -0.08512,
        0.52416,
        0,
        0.02023,
        0,
        0,
        0,
        1,
        0
      ],
      Kodachrome: [
        1.12855,
        -0.39673,
        -0.03992,
        0,
        0.24991,
        -0.16404,
        1.08352,
        -0.05498,
        0,
        0.09698,
        -0.16786,
        -0.56034,
        1.60148,
        0,
        0.13972,
        0,
        0,
        0,
        1,
        0
      ],
      Technicolor: [
        1.91252,
        -0.85453,
        -0.09155,
        0,
        0.04624,
        -0.30878,
        1.76589,
        -0.10601,
        0,
        -0.27589,
        -0.2311,
        -0.75018,
        1.84759,
        0,
        0.12137,
        0,
        0,
        0,
        1,
        0
      ],
      Polaroid: [
        1.438,
        -0.062,
        -0.062,
        0,
        0,
        -0.122,
        1.378,
        -0.122,
        0,
        0,
        -0.016,
        -0.016,
        1.483,
        0,
        0,
        0,
        0,
        0,
        1,
        0
      ],
      Sepia: [
        0.393,
        0.769,
        0.189,
        0,
        0,
        0.349,
        0.686,
        0.168,
        0,
        0,
        0.272,
        0.534,
        0.131,
        0,
        0,
        0,
        0,
        0,
        1,
        0
      ],
      BlackWhite: [
        1.5,
        1.5,
        1.5,
        0,
        -1,
        1.5,
        1.5,
        1.5,
        0,
        -1,
        1.5,
        1.5,
        1.5,
        0,
        -1,
        0,
        0,
        0,
        1,
        0
      ]
    };
    for (var l in s)
      u[l] = h(u.ColorMatrix, {
        type: l,
        matrix: s[l],
        mainParameter: !1,
        colorsOnly: !0
      }), n.Image.filters[l].fromObject = n.Image.filters.BaseFilter.fromObject;
  }(t), function(a) {
    var n = a.fabric, u = n.Image.filters, h = n.util.createClass;
    u.BlendColor = h(u.BaseFilter, {
      type: "BlendColor",
      color: "#F95C63",
      mode: "multiply",
      alpha: 1,
      fragmentSource: {
        multiply: `gl_FragColor.rgb *= uColor.rgb;
`,
        screen: `gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);
`,
        add: `gl_FragColor.rgb += uColor.rgb;
`,
        diff: `gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);
`,
        subtract: `gl_FragColor.rgb -= uColor.rgb;
`,
        lighten: `gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);
`,
        darken: `gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);
`,
        exclusion: `gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);
`,
        overlay: `if (uColor.r < 0.5) {
gl_FragColor.r *= 2.0 * uColor.r;
} else {
gl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r);
}
if (uColor.g < 0.5) {
gl_FragColor.g *= 2.0 * uColor.g;
} else {
gl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g);
}
if (uColor.b < 0.5) {
gl_FragColor.b *= 2.0 * uColor.b;
} else {
gl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b);
}
`,
        tint: `gl_FragColor.rgb *= (1.0 - uColor.a);
gl_FragColor.rgb += uColor.rgb;
`
      },
      buildSource: function(s) {
        return `precision highp float;
uniform sampler2D uTexture;
uniform vec4 uColor;
varying vec2 vTexCoord;
void main() {
vec4 color = texture2D(uTexture, vTexCoord);
gl_FragColor = color;
if (color.a > 0.0) {
` + this.fragmentSource[s] + `}
}`;
      },
      retrieveShader: function(s) {
        var l = this.type + "_" + this.mode, c;
        return s.programCache.hasOwnProperty(l) || (c = this.buildSource(this.mode), s.programCache[l] = this.createProgram(s.context, c)), s.programCache[l];
      },
      applyTo2d: function(s) {
        var l = s.imageData, c = l.data, f = c.length, m, d, v, b, y, w, _, S = 1 - this.alpha;
        _ = new n.Color(this.color).getSource(), m = _[0] * this.alpha, d = _[1] * this.alpha, v = _[2] * this.alpha;
        for (var T = 0; T < f; T += 4)
          switch (b = c[T], y = c[T + 1], w = c[T + 2], this.mode) {
            case "multiply":
              c[T] = b * m / 255, c[T + 1] = y * d / 255, c[T + 2] = w * v / 255;
              break;
            case "screen":
              c[T] = 255 - (255 - b) * (255 - m) / 255, c[T + 1] = 255 - (255 - y) * (255 - d) / 255, c[T + 2] = 255 - (255 - w) * (255 - v) / 255;
              break;
            case "add":
              c[T] = b + m, c[T + 1] = y + d, c[T + 2] = w + v;
              break;
            case "diff":
            case "difference":
              c[T] = Math.abs(b - m), c[T + 1] = Math.abs(y - d), c[T + 2] = Math.abs(w - v);
              break;
            case "subtract":
              c[T] = b - m, c[T + 1] = y - d, c[T + 2] = w - v;
              break;
            case "darken":
              c[T] = Math.min(b, m), c[T + 1] = Math.min(y, d), c[T + 2] = Math.min(w, v);
              break;
            case "lighten":
              c[T] = Math.max(b, m), c[T + 1] = Math.max(y, d), c[T + 2] = Math.max(w, v);
              break;
            case "overlay":
              c[T] = m < 128 ? 2 * b * m / 255 : 255 - 2 * (255 - b) * (255 - m) / 255, c[T + 1] = d < 128 ? 2 * y * d / 255 : 255 - 2 * (255 - y) * (255 - d) / 255, c[T + 2] = v < 128 ? 2 * w * v / 255 : 255 - 2 * (255 - w) * (255 - v) / 255;
              break;
            case "exclusion":
              c[T] = m + b - 2 * m * b / 255, c[T + 1] = d + y - 2 * d * y / 255, c[T + 2] = v + w - 2 * v * w / 255;
              break;
            case "tint":
              c[T] = m + b * S, c[T + 1] = d + y * S, c[T + 2] = v + w * S;
          }
      },
      getUniformLocations: function(s, l) {
        return {
          uColor: s.getUniformLocation(l, "uColor")
        };
      },
      sendUniformData: function(s, l) {
        var c = new n.Color(this.color).getSource();
        c[0] = this.alpha * c[0] / 255, c[1] = this.alpha * c[1] / 255, c[2] = this.alpha * c[2] / 255, c[3] = this.alpha, s.uniform4fv(l.uColor, c);
      },
      toObject: function() {
        return {
          type: this.type,
          color: this.color,
          mode: this.mode,
          alpha: this.alpha
        };
      }
    }), n.Image.filters.BlendColor.fromObject = n.Image.filters.BaseFilter.fromObject;
  }(t), function(a) {
    var n = a.fabric, u = n.Image.filters, h = n.util.createClass;
    u.BlendImage = h(u.BaseFilter, {
      type: "BlendImage",
      image: null,
      mode: "multiply",
      alpha: 1,
      vertexSource: `attribute vec2 aPosition;
varying vec2 vTexCoord;
varying vec2 vTexCoord2;
uniform mat3 uTransformMatrix;
void main() {
vTexCoord = aPosition;
vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;
gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
}`,
      fragmentSource: {
        multiply: `precision highp float;
uniform sampler2D uTexture;
uniform sampler2D uImage;
uniform vec4 uColor;
varying vec2 vTexCoord;
varying vec2 vTexCoord2;
void main() {
vec4 color = texture2D(uTexture, vTexCoord);
vec4 color2 = texture2D(uImage, vTexCoord2);
color.rgba *= color2.rgba;
gl_FragColor = color;
}`,
        mask: `precision highp float;
uniform sampler2D uTexture;
uniform sampler2D uImage;
uniform vec4 uColor;
varying vec2 vTexCoord;
varying vec2 vTexCoord2;
void main() {
vec4 color = texture2D(uTexture, vTexCoord);
vec4 color2 = texture2D(uImage, vTexCoord2);
color.a = color2.a;
gl_FragColor = color;
}`
      },
      retrieveShader: function(s) {
        var l = this.type + "_" + this.mode, c = this.fragmentSource[this.mode];
        return s.programCache.hasOwnProperty(l) || (s.programCache[l] = this.createProgram(s.context, c)), s.programCache[l];
      },
      applyToWebGL: function(s) {
        var l = s.context, c = this.createTexture(s.filterBackend, this.image);
        this.bindAdditionalTexture(l, c, l.TEXTURE1), this.callSuper("applyToWebGL", s), this.unbindAdditionalTexture(l, l.TEXTURE1);
      },
      createTexture: function(s, l) {
        return s.getCachedTexture(l.cacheKey, l._element);
      },
      calculateMatrix: function() {
        var s = this.image, l = s._element.width, c = s._element.height;
        return [
          1 / s.scaleX,
          0,
          0,
          0,
          1 / s.scaleY,
          0,
          -s.left / l,
          -s.top / c,
          1
        ];
      },
      applyTo2d: function(s) {
        var l = s.imageData, c = s.filterBackend.resources, f = l.data, m = f.length, d = l.width, v = l.height, b, y, w, _, S, T, A, R, N, U, Q = this.image, ee;
        c.blendImage || (c.blendImage = n.util.createCanvasElement()), N = c.blendImage, U = N.getContext("2d"), N.width !== d || N.height !== v ? (N.width = d, N.height = v) : U.clearRect(0, 0, d, v), U.setTransform(Q.scaleX, 0, 0, Q.scaleY, Q.left, Q.top), U.drawImage(Q._element, 0, 0, d, v), ee = U.getImageData(0, 0, d, v).data;
        for (var J = 0; J < m; J += 4)
          switch (S = f[J], T = f[J + 1], A = f[J + 2], R = f[J + 3], b = ee[J], y = ee[J + 1], w = ee[J + 2], _ = ee[J + 3], this.mode) {
            case "multiply":
              f[J] = S * b / 255, f[J + 1] = T * y / 255, f[J + 2] = A * w / 255, f[J + 3] = R * _ / 255;
              break;
            case "mask":
              f[J + 3] = _;
              break;
          }
      },
      getUniformLocations: function(s, l) {
        return {
          uTransformMatrix: s.getUniformLocation(l, "uTransformMatrix"),
          uImage: s.getUniformLocation(l, "uImage")
        };
      },
      sendUniformData: function(s, l) {
        var c = this.calculateMatrix();
        s.uniform1i(l.uImage, 1), s.uniformMatrix3fv(l.uTransformMatrix, !1, c);
      },
      toObject: function() {
        return {
          type: this.type,
          image: this.image && this.image.toObject(),
          mode: this.mode,
          alpha: this.alpha
        };
      }
    }), n.Image.filters.BlendImage.fromObject = function(s, l) {
      n.Image.fromObject(s.image, function(c) {
        var f = n.util.object.clone(s);
        f.image = c, l(new n.Image.filters.BlendImage(f));
      });
    };
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = Math.pow, h = Math.floor, s = Math.sqrt, l = Math.abs, c = Math.round, f = Math.sin, m = Math.ceil, d = n.Image.filters, v = n.util.createClass;
    d.Resize = v(d.BaseFilter, {
      type: "Resize",
      resizeType: "hermite",
      scaleX: 1,
      scaleY: 1,
      lanczosLobes: 3,
      getUniformLocations: function(b, y) {
        return {
          uDelta: b.getUniformLocation(y, "uDelta"),
          uTaps: b.getUniformLocation(y, "uTaps")
        };
      },
      sendUniformData: function(b, y) {
        b.uniform2fv(y.uDelta, this.horizontal ? [1 / this.width, 0] : [0, 1 / this.height]), b.uniform1fv(y.uTaps, this.taps);
      },
      retrieveShader: function(b) {
        var y = this.getFilterWindow(), w = this.type + "_" + y;
        if (!b.programCache.hasOwnProperty(w)) {
          var _ = this.generateShader(y);
          b.programCache[w] = this.createProgram(b.context, _);
        }
        return b.programCache[w];
      },
      getFilterWindow: function() {
        var b = this.tempScale;
        return Math.ceil(this.lanczosLobes / b);
      },
      getTaps: function() {
        for (var b = this.lanczosCreate(this.lanczosLobes), y = this.tempScale, w = this.getFilterWindow(), _ = new Array(w), S = 1; S <= w; S++)
          _[S - 1] = b(S * y);
        return _;
      },
      generateShader: function(_) {
        for (var y = new Array(_), w = this.fragmentSourceTOP, _, S = 1; S <= _; S++)
          y[S - 1] = S + ".0 * uDelta";
        return w += "uniform float uTaps[" + _ + `];
`, w += `void main() {
`, w += `  vec4 color = texture2D(uTexture, vTexCoord);
`, w += `  float sum = 1.0;
`, y.forEach(function(T, A) {
          w += "  color += texture2D(uTexture, vTexCoord + " + T + ") * uTaps[" + A + `];
`, w += "  color += texture2D(uTexture, vTexCoord - " + T + ") * uTaps[" + A + `];
`, w += "  sum += 2.0 * uTaps[" + A + `];
`;
        }), w += `  gl_FragColor = color / sum;
`, w += "}", w;
      },
      fragmentSourceTOP: `precision highp float;
uniform sampler2D uTexture;
uniform vec2 uDelta;
varying vec2 vTexCoord;
`,
      applyTo: function(b) {
        b.webgl ? (b.passes++, this.width = b.sourceWidth, this.horizontal = !0, this.dW = Math.round(this.width * this.scaleX), this.dH = b.sourceHeight, this.tempScale = this.dW / this.width, this.taps = this.getTaps(), b.destinationWidth = this.dW, this._setupFrameBuffer(b), this.applyToWebGL(b), this._swapTextures(b), b.sourceWidth = b.destinationWidth, this.height = b.sourceHeight, this.horizontal = !1, this.dH = Math.round(this.height * this.scaleY), this.tempScale = this.dH / this.height, this.taps = this.getTaps(), b.destinationHeight = this.dH, this._setupFrameBuffer(b), this.applyToWebGL(b), this._swapTextures(b), b.sourceHeight = b.destinationHeight) : this.applyTo2d(b);
      },
      isNeutralState: function() {
        return this.scaleX === 1 && this.scaleY === 1;
      },
      lanczosCreate: function(b) {
        return function(y) {
          if (y >= b || y <= -b)
            return 0;
          if (y < 11920929e-14 && y > -11920929e-14)
            return 1;
          y *= Math.PI;
          var w = y / b;
          return f(y) / y * f(w) / w;
        };
      },
      applyTo2d: function(b) {
        var y = b.imageData, w = this.scaleX, _ = this.scaleY;
        this.rcpScaleX = 1 / w, this.rcpScaleY = 1 / _;
        var S = y.width, T = y.height, A = c(S * w), R = c(T * _), N;
        this.resizeType === "sliceHack" ? N = this.sliceByTwo(b, S, T, A, R) : this.resizeType === "hermite" ? N = this.hermiteFastResize(b, S, T, A, R) : this.resizeType === "bilinear" ? N = this.bilinearFiltering(b, S, T, A, R) : this.resizeType === "lanczos" && (N = this.lanczosResize(b, S, T, A, R)), b.imageData = N;
      },
      sliceByTwo: function(b, y, w, _, S) {
        var T = b.imageData, A = 0.5, R = !1, N = !1, U = y * A, Q = w * A, ee = n.filterBackend.resources, J, q, re = 0, le = 0, ne = y, C = 0;
        for (ee.sliceByTwo || (ee.sliceByTwo = document.createElement("canvas")), J = ee.sliceByTwo, (J.width < y * 1.5 || J.height < w) && (J.width = y * 1.5, J.height = w), q = J.getContext("2d"), q.clearRect(0, 0, y * 1.5, w), q.putImageData(T, 0, 0), _ = h(_), S = h(S); !R || !N; )
          y = U, w = Q, _ < h(U * A) ? U = h(U * A) : (U = _, R = !0), S < h(Q * A) ? Q = h(Q * A) : (Q = S, N = !0), q.drawImage(J, re, le, y, w, ne, C, U, Q), re = ne, le = C, C += Q;
        return q.getImageData(re, le, _, S);
      },
      lanczosResize: function(b, y, w, _, S) {
        function T(P) {
          var D, B, M, E, L, z, Y, $, W, j, te;
          for (C.x = (P + 0.5) * Q, k.x = h(C.x), D = 0; D < S; D++) {
            for (C.y = (D + 0.5) * ee, k.y = h(C.y), L = 0, z = 0, Y = 0, $ = 0, W = 0, B = k.x - re; B <= k.x + re; B++)
              if (!(B < 0 || B >= y)) {
                j = h(1e3 * l(B - C.x)), ne[j] || (ne[j] = {});
                for (var V = k.y - le; V <= k.y + le; V++)
                  V < 0 || V >= w || (te = h(1e3 * l(V - C.y)), ne[j][te] || (ne[j][te] = U(s(u(j * J, 2) + u(te * q, 2)) / 1e3)), M = ne[j][te], M > 0 && (E = (V * y + B) * 4, L += M, z += M * A[E], Y += M * A[E + 1], $ += M * A[E + 2], W += M * A[E + 3]));
              }
            E = (D * _ + P) * 4, N[E] = z / L, N[E + 1] = Y / L, N[E + 2] = $ / L, N[E + 3] = W / L;
          }
          return ++P < _ ? T(P) : R;
        }
        var A = b.imageData.data, R = b.ctx.createImageData(_, S), N = R.data, U = this.lanczosCreate(this.lanczosLobes), Q = this.rcpScaleX, ee = this.rcpScaleY, J = 2 / this.rcpScaleX, q = 2 / this.rcpScaleY, re = m(Q * this.lanczosLobes / 2), le = m(ee * this.lanczosLobes / 2), ne = {}, C = {}, k = {};
        return T(0);
      },
      bilinearFiltering: function(b, y, w, _, S) {
        var T, A, R, N, U, Q, ee, J, q, re, le, ne, C = 0, k, P = this.rcpScaleX, D = this.rcpScaleY, B = 4 * (y - 1), M = b.imageData, E = M.data, L = b.ctx.createImageData(_, S), z = L.data;
        for (ee = 0; ee < S; ee++)
          for (J = 0; J < _; J++)
            for (U = h(P * J), Q = h(D * ee), q = P * J - U, re = D * ee - Q, k = 4 * (Q * y + U), le = 0; le < 4; le++)
              T = E[k + le], A = E[k + 4 + le], R = E[k + B + le], N = E[k + B + 4 + le], ne = T * (1 - q) * (1 - re) + A * q * (1 - re) + R * re * (1 - q) + N * q * re, z[C++] = ne;
        return L;
      },
      hermiteFastResize: function(b, y, w, _, S) {
        for (var T = this.rcpScaleX, A = this.rcpScaleY, R = m(T / 2), N = m(A / 2), U = b.imageData, Q = U.data, ee = b.ctx.createImageData(_, S), J = ee.data, q = 0; q < S; q++)
          for (var re = 0; re < _; re++) {
            for (var le = (re + q * _) * 4, ne = 0, C = 0, k = 0, P = 0, D = 0, B = 0, M = 0, E = (q + 0.5) * A, L = h(q * A); L < (q + 1) * A; L++)
              for (var z = l(E - (L + 0.5)) / N, Y = (re + 0.5) * T, $ = z * z, W = h(re * T); W < (re + 1) * T; W++) {
                var j = l(Y - (W + 0.5)) / R, te = s($ + j * j);
                te > 1 && te < -1 || (ne = 2 * te * te * te - 3 * te * te + 1, ne > 0 && (j = 4 * (W + L * y), M += ne * Q[j + 3], k += ne, Q[j + 3] < 255 && (ne = ne * Q[j + 3] / 250), P += ne * Q[j], D += ne * Q[j + 1], B += ne * Q[j + 2], C += ne));
              }
            J[le] = P / C, J[le + 1] = D / C, J[le + 2] = B / C, J[le + 3] = M / k;
          }
        return ee;
      },
      toObject: function() {
        return {
          type: this.type,
          scaleX: this.scaleX,
          scaleY: this.scaleY,
          resizeType: this.resizeType,
          lanczosLobes: this.lanczosLobes
        };
      }
    }), n.Image.filters.Resize.fromObject = n.Image.filters.BaseFilter.fromObject;
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.Image.filters, h = n.util.createClass;
    u.Contrast = h(u.BaseFilter, {
      type: "Contrast",
      fragmentSource: `precision highp float;
uniform sampler2D uTexture;
uniform float uContrast;
varying vec2 vTexCoord;
void main() {
vec4 color = texture2D(uTexture, vTexCoord);
float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));
color.rgb = contrastF * (color.rgb - 0.5) + 0.5;
gl_FragColor = color;
}`,
      contrast: 0,
      mainParameter: "contrast",
      applyTo2d: function(s) {
        if (this.contrast !== 0) {
          var l = s.imageData, c, m, f = l.data, m = f.length, d = Math.floor(this.contrast * 255), v = 259 * (d + 255) / (255 * (259 - d));
          for (c = 0; c < m; c += 4)
            f[c] = v * (f[c] - 128) + 128, f[c + 1] = v * (f[c + 1] - 128) + 128, f[c + 2] = v * (f[c + 2] - 128) + 128;
        }
      },
      getUniformLocations: function(s, l) {
        return {
          uContrast: s.getUniformLocation(l, "uContrast")
        };
      },
      sendUniformData: function(s, l) {
        s.uniform1f(l.uContrast, this.contrast);
      }
    }), n.Image.filters.Contrast.fromObject = n.Image.filters.BaseFilter.fromObject;
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.Image.filters, h = n.util.createClass;
    u.Saturation = h(u.BaseFilter, {
      type: "Saturation",
      fragmentSource: `precision highp float;
uniform sampler2D uTexture;
uniform float uSaturation;
varying vec2 vTexCoord;
void main() {
vec4 color = texture2D(uTexture, vTexCoord);
float rgMax = max(color.r, color.g);
float rgbMax = max(rgMax, color.b);
color.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;
color.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;
color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;
gl_FragColor = color;
}`,
      saturation: 0,
      mainParameter: "saturation",
      applyTo2d: function(s) {
        if (this.saturation !== 0) {
          var l = s.imageData, c = l.data, f = c.length, m = -this.saturation, d, v;
          for (d = 0; d < f; d += 4)
            v = Math.max(c[d], c[d + 1], c[d + 2]), c[d] += v !== c[d] ? (v - c[d]) * m : 0, c[d + 1] += v !== c[d + 1] ? (v - c[d + 1]) * m : 0, c[d + 2] += v !== c[d + 2] ? (v - c[d + 2]) * m : 0;
        }
      },
      getUniformLocations: function(s, l) {
        return {
          uSaturation: s.getUniformLocation(l, "uSaturation")
        };
      },
      sendUniformData: function(s, l) {
        s.uniform1f(l.uSaturation, -this.saturation);
      }
    }), n.Image.filters.Saturation.fromObject = n.Image.filters.BaseFilter.fromObject;
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.Image.filters, h = n.util.createClass;
    u.Vibrance = h(u.BaseFilter, {
      type: "Vibrance",
      fragmentSource: `precision highp float;
uniform sampler2D uTexture;
uniform float uVibrance;
varying vec2 vTexCoord;
void main() {
vec4 color = texture2D(uTexture, vTexCoord);
float max = max(color.r, max(color.g, color.b));
float avg = (color.r + color.g + color.b) / 3.0;
float amt = (abs(max - avg) * 2.0) * uVibrance;
color.r += max != color.r ? (max - color.r) * amt : 0.00;
color.g += max != color.g ? (max - color.g) * amt : 0.00;
color.b += max != color.b ? (max - color.b) * amt : 0.00;
gl_FragColor = color;
}`,
      vibrance: 0,
      mainParameter: "vibrance",
      applyTo2d: function(s) {
        if (this.vibrance !== 0) {
          var l = s.imageData, c = l.data, f = c.length, m = -this.vibrance, d, v, b, y;
          for (d = 0; d < f; d += 4)
            v = Math.max(c[d], c[d + 1], c[d + 2]), b = (c[d] + c[d + 1] + c[d + 2]) / 3, y = Math.abs(v - b) * 2 / 255 * m, c[d] += v !== c[d] ? (v - c[d]) * y : 0, c[d + 1] += v !== c[d + 1] ? (v - c[d + 1]) * y : 0, c[d + 2] += v !== c[d + 2] ? (v - c[d + 2]) * y : 0;
        }
      },
      getUniformLocations: function(s, l) {
        return {
          uVibrance: s.getUniformLocation(l, "uVibrance")
        };
      },
      sendUniformData: function(s, l) {
        s.uniform1f(l.uVibrance, -this.vibrance);
      }
    }), n.Image.filters.Vibrance.fromObject = n.Image.filters.BaseFilter.fromObject;
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.Image.filters, h = n.util.createClass;
    u.Blur = h(u.BaseFilter, {
      type: "Blur",
      fragmentSource: `precision highp float;
uniform sampler2D uTexture;
uniform vec2 uDelta;
varying vec2 vTexCoord;
const float nSamples = 15.0;
vec3 v3offset = vec3(12.9898, 78.233, 151.7182);
float random(vec3 scale) {
return fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);
}
void main() {
vec4 color = vec4(0.0);
float total = 0.0;
float offset = random(v3offset);
for (float t = -nSamples; t <= nSamples; t++) {
float percent = (t + offset - 0.5) / nSamples;
float weight = 1.0 - abs(percent);
color += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;
total += weight;
}
gl_FragColor = color / total;
}`,
      blur: 0,
      mainParameter: "blur",
      applyTo: function(s) {
        s.webgl ? (this.aspectRatio = s.sourceWidth / s.sourceHeight, s.passes++, this._setupFrameBuffer(s), this.horizontal = !0, this.applyToWebGL(s), this._swapTextures(s), this._setupFrameBuffer(s), this.horizontal = !1, this.applyToWebGL(s), this._swapTextures(s)) : this.applyTo2d(s);
      },
      applyTo2d: function(s) {
        s.imageData = this.simpleBlur(s);
      },
      simpleBlur: function(s) {
        var l = s.filterBackend.resources, c, f, m = s.imageData.width, d = s.imageData.height;
        l.blurLayer1 || (l.blurLayer1 = n.util.createCanvasElement(), l.blurLayer2 = n.util.createCanvasElement()), c = l.blurLayer1, f = l.blurLayer2, (c.width !== m || c.height !== d) && (f.width = c.width = m, f.height = c.height = d);
        var v = c.getContext("2d"), b = f.getContext("2d"), y = 15, w, _, S, T, A = this.blur * 0.06 * 0.5;
        for (v.putImageData(s.imageData, 0, 0), b.clearRect(0, 0, m, d), T = -y; T <= y; T++)
          w = (Math.random() - 0.5) / 4, _ = T / y, S = A * _ * m + w, b.globalAlpha = 1 - Math.abs(_), b.drawImage(c, S, w), v.drawImage(f, 0, 0), b.globalAlpha = 1, b.clearRect(0, 0, f.width, f.height);
        for (T = -y; T <= y; T++)
          w = (Math.random() - 0.5) / 4, _ = T / y, S = A * _ * d + w, b.globalAlpha = 1 - Math.abs(_), b.drawImage(c, w, S), v.drawImage(f, 0, 0), b.globalAlpha = 1, b.clearRect(0, 0, f.width, f.height);
        s.ctx.drawImage(c, 0, 0);
        var R = s.ctx.getImageData(0, 0, c.width, c.height);
        return v.globalAlpha = 1, v.clearRect(0, 0, c.width, c.height), R;
      },
      getUniformLocations: function(s, l) {
        return {
          delta: s.getUniformLocation(l, "uDelta")
        };
      },
      sendUniformData: function(s, l) {
        var c = this.chooseRightDelta();
        s.uniform2fv(l.delta, c);
      },
      chooseRightDelta: function() {
        var s = 1, l = [0, 0], c;
        return this.horizontal ? this.aspectRatio > 1 && (s = 1 / this.aspectRatio) : this.aspectRatio < 1 && (s = this.aspectRatio), c = s * this.blur * 0.12, this.horizontal ? l[0] = c : l[1] = c, l;
      }
    }), u.Blur.fromObject = n.Image.filters.BaseFilter.fromObject;
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.Image.filters, h = n.util.createClass;
    u.Gamma = h(u.BaseFilter, {
      type: "Gamma",
      fragmentSource: `precision highp float;
uniform sampler2D uTexture;
uniform vec3 uGamma;
varying vec2 vTexCoord;
void main() {
vec4 color = texture2D(uTexture, vTexCoord);
vec3 correction = (1.0 / uGamma);
color.r = pow(color.r, correction.r);
color.g = pow(color.g, correction.g);
color.b = pow(color.b, correction.b);
gl_FragColor = color;
gl_FragColor.rgb *= color.a;
}`,
      gamma: [1, 1, 1],
      mainParameter: "gamma",
      initialize: function(s) {
        this.gamma = [1, 1, 1], u.BaseFilter.prototype.initialize.call(this, s);
      },
      applyTo2d: function(s) {
        var l = s.imageData, c = l.data, f = this.gamma, m = c.length, d = 1 / f[0], v = 1 / f[1], b = 1 / f[2], y;
        for (this.rVals || (this.rVals = new Uint8Array(256), this.gVals = new Uint8Array(256), this.bVals = new Uint8Array(256)), y = 0, m = 256; y < m; y++)
          this.rVals[y] = Math.pow(y / 255, d) * 255, this.gVals[y] = Math.pow(y / 255, v) * 255, this.bVals[y] = Math.pow(y / 255, b) * 255;
        for (y = 0, m = c.length; y < m; y += 4)
          c[y] = this.rVals[c[y]], c[y + 1] = this.gVals[c[y + 1]], c[y + 2] = this.bVals[c[y + 2]];
      },
      getUniformLocations: function(s, l) {
        return {
          uGamma: s.getUniformLocation(l, "uGamma")
        };
      },
      sendUniformData: function(s, l) {
        s.uniform3fv(l.uGamma, this.gamma);
      }
    }), n.Image.filters.Gamma.fromObject = n.Image.filters.BaseFilter.fromObject;
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.Image.filters, h = n.util.createClass;
    u.Composed = h(u.BaseFilter, {
      type: "Composed",
      subFilters: [],
      initialize: function(s) {
        this.callSuper("initialize", s), this.subFilters = this.subFilters.slice(0);
      },
      applyTo: function(s) {
        s.passes += this.subFilters.length - 1, this.subFilters.forEach(function(l) {
          l.applyTo(s);
        });
      },
      toObject: function() {
        return n.util.object.extend(this.callSuper("toObject"), {
          subFilters: this.subFilters.map(function(s) {
            return s.toObject();
          })
        });
      },
      isNeutralState: function() {
        return !this.subFilters.some(function(s) {
          return !s.isNeutralState();
        });
      }
    }), n.Image.filters.Composed.fromObject = function(s, l) {
      var c = s.subFilters || [], f = c.map(function(d) {
        return new n.Image.filters[d.type](d);
      }), m = new n.Image.filters.Composed({ subFilters: f });
      return l && l(m), m;
    };
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.Image.filters, h = n.util.createClass;
    u.HueRotation = h(u.ColorMatrix, {
      type: "HueRotation",
      rotation: 0,
      mainParameter: "rotation",
      calculateMatrix: function() {
        var s = this.rotation * Math.PI, l = n.util.cos(s), c = n.util.sin(s), f = 1 / 3, m = Math.sqrt(f) * c, d = 1 - l;
        this.matrix = [
          1,
          0,
          0,
          0,
          0,
          0,
          1,
          0,
          0,
          0,
          0,
          0,
          1,
          0,
          0,
          0,
          0,
          0,
          1,
          0
        ], this.matrix[0] = l + d / 3, this.matrix[1] = f * d - m, this.matrix[2] = f * d + m, this.matrix[5] = f * d + m, this.matrix[6] = l + f * d, this.matrix[7] = f * d - m, this.matrix[10] = f * d - m, this.matrix[11] = f * d + m, this.matrix[12] = l + f * d;
      },
      isNeutralState: function(s) {
        return this.calculateMatrix(), u.BaseFilter.prototype.isNeutralState.call(this, s);
      },
      applyTo: function(s) {
        this.calculateMatrix(), u.BaseFilter.prototype.applyTo.call(this, s);
      }
    }), n.Image.filters.HueRotation.fromObject = n.Image.filters.BaseFilter.fromObject;
  }(t), function(a) {
    var n = a.fabric || (a.fabric = {}), u = n.util.object.clone;
    if (n.Text) {
      n.warn("fabric.Text is already defined");
      return;
    }
    var h = "fontFamily fontWeight fontSize text underline overline linethrough textAlign fontStyle lineHeight textBackgroundColor charSpacing styles direction path pathStartOffset pathSide pathAlign".split(" ");
    n.Text = n.util.createClass(n.Object, {
      _dimensionAffectingProps: [
        "fontSize",
        "fontWeight",
        "fontFamily",
        "fontStyle",
        "lineHeight",
        "text",
        "charSpacing",
        "textAlign",
        "styles",
        "path",
        "pathStartOffset",
        "pathSide",
        "pathAlign"
      ],
      _reNewline: /\r?\n/,
      _reSpacesAndTabs: /[ \t\r]/g,
      _reSpaceAndTab: /[ \t\r]/,
      _reWords: /\S+/g,
      type: "text",
      fontSize: 40,
      fontWeight: "normal",
      fontFamily: "Times New Roman",
      underline: !1,
      overline: !1,
      linethrough: !1,
      textAlign: "left",
      fontStyle: "normal",
      lineHeight: 1.16,
      superscript: {
        size: 0.6,
        baseline: -0.35
      },
      subscript: {
        size: 0.6,
        baseline: 0.11
      },
      textBackgroundColor: "",
      stateProperties: n.Object.prototype.stateProperties.concat(h),
      cacheProperties: n.Object.prototype.cacheProperties.concat(h),
      stroke: null,
      shadow: null,
      path: null,
      pathStartOffset: 0,
      pathSide: "left",
      pathAlign: "baseline",
      _fontSizeFraction: 0.222,
      offsets: {
        underline: 0.1,
        linethrough: -0.315,
        overline: -0.88
      },
      _fontSizeMult: 1.13,
      charSpacing: 0,
      styles: null,
      _measuringContext: null,
      deltaY: 0,
      direction: "ltr",
      _styleProperties: [
        "stroke",
        "strokeWidth",
        "fill",
        "fontFamily",
        "fontSize",
        "fontWeight",
        "fontStyle",
        "underline",
        "overline",
        "linethrough",
        "deltaY",
        "textBackgroundColor"
      ],
      __charBounds: [],
      CACHE_FONT_SIZE: 400,
      MIN_TEXT_WIDTH: 2,
      initialize: function(s, l) {
        this.styles = l ? l.styles || {} : {}, this.text = s, this.__skipDimension = !0, this.callSuper("initialize", l), this.path && this.setPathInfo(), this.__skipDimension = !1, this.initDimensions(), this.setCoords(), this.setupState({ propertySet: "_dimensionAffectingProps" });
      },
      setPathInfo: function() {
        var s = this.path;
        s && (s.segmentsInfo = n.util.getPathSegmentsInfo(s.path));
      },
      getMeasuringContext: function() {
        return n._measuringContext || (n._measuringContext = this.canvas && this.canvas.contextCache || n.util.createCanvasElement().getContext("2d")), n._measuringContext;
      },
      _splitText: function() {
        var s = this._splitTextIntoLines(this.text);
        return this.textLines = s.lines, this._textLines = s.graphemeLines, this._unwrappedTextLines = s._unwrappedLines, this._text = s.graphemeText, s;
      },
      initDimensions: function() {
        this.__skipDimension || (this._splitText(), this._clearCache(), this.path ? (this.width = this.path.width, this.height = this.path.height) : (this.width = this.calcTextWidth() || this.cursorWidth || this.MIN_TEXT_WIDTH, this.height = this.calcTextHeight()), this.textAlign.indexOf("justify") !== -1 && this.enlargeSpaces(), this.saveState({ propertySet: "_dimensionAffectingProps" }));
      },
      enlargeSpaces: function() {
        for (var s, l, c, f, m, d, v, b = 0, y = this._textLines.length; b < y; b++)
          if (!(this.textAlign !== "justify" && (b === y - 1 || this.isEndOfWrapping(b))) && (f = 0, m = this._textLines[b], l = this.getLineWidth(b), l < this.width && (v = this.textLines[b].match(this._reSpacesAndTabs)))) {
            c = v.length, s = (this.width - l) / c;
            for (var w = 0, _ = m.length; w <= _; w++)
              d = this.__charBounds[b][w], this._reSpaceAndTab.test(m[w]) ? (d.width += s, d.kernedWidth += s, d.left += f, f += s) : d.left += f;
          }
      },
      isEndOfWrapping: function(s) {
        return s === this._textLines.length - 1;
      },
      missingNewlineOffset: function() {
        return 1;
      },
      toString: function() {
        return "#<fabric.Text (" + this.complexity() + '): { "text": "' + this.text + '", "fontFamily": "' + this.fontFamily + '" }>';
      },
      _getCacheCanvasDimensions: function() {
        var s = this.callSuper("_getCacheCanvasDimensions"), l = this.fontSize;
        return s.width += l * s.zoomX, s.height += l * s.zoomY, s;
      },
      _render: function(s) {
        var l = this.path;
        l && !l.isNotVisible() && l._render(s), this._setTextStyles(s), this._renderTextLinesBackground(s), this._renderTextDecoration(s, "underline"), this._renderText(s), this._renderTextDecoration(s, "overline"), this._renderTextDecoration(s, "linethrough");
      },
      _renderText: function(s) {
        this.paintFirst === "stroke" ? (this._renderTextStroke(s), this._renderTextFill(s)) : (this._renderTextFill(s), this._renderTextStroke(s));
      },
      _setTextStyles: function(s, l, c) {
        if (s.textBaseline = "alphabetical", this.path)
          switch (this.pathAlign) {
            case "center":
              s.textBaseline = "middle";
              break;
            case "ascender":
              s.textBaseline = "top";
              break;
            case "descender":
              s.textBaseline = "bottom";
              break;
          }
        s.font = this._getFontDeclaration(l, c);
      },
      calcTextWidth: function() {
        for (var s = this.getLineWidth(0), l = 1, c = this._textLines.length; l < c; l++) {
          var f = this.getLineWidth(l);
          f > s && (s = f);
        }
        return s;
      },
      _renderTextLine: function(s, l, c, f, m, d) {
        this._renderChars(s, l, c, f, m, d);
      },
      _renderTextLinesBackground: function(s) {
        if (!(!this.textBackgroundColor && !this.styleHas("textBackgroundColor"))) {
          for (var l, c, f = s.fillStyle, m, d, v = this._getLeftOffset(), b = this._getTopOffset(), y = 0, w = 0, _, S, T = this.path, A, R = 0, N = this._textLines.length; R < N; R++) {
            if (l = this.getHeightOfLine(R), !this.textBackgroundColor && !this.styleHas("textBackgroundColor", R)) {
              b += l;
              continue;
            }
            m = this._textLines[R], c = this._getLineLeftOffset(R), w = 0, y = 0, d = this.getValueOfPropertyAt(R, 0, "textBackgroundColor");
            for (var U = 0, Q = m.length; U < Q; U++)
              _ = this.__charBounds[R][U], S = this.getValueOfPropertyAt(R, U, "textBackgroundColor"), T ? (s.save(), s.translate(_.renderLeft, _.renderTop), s.rotate(_.angle), s.fillStyle = S, S && s.fillRect(
                -_.width / 2,
                -l / this.lineHeight * (1 - this._fontSizeFraction),
                _.width,
                l / this.lineHeight
              ), s.restore()) : S !== d ? (A = v + c + y, this.direction === "rtl" && (A = this.width - A - w), s.fillStyle = d, d && s.fillRect(
                A,
                b,
                w,
                l / this.lineHeight
              ), y = _.left, w = _.width, d = S) : w += _.kernedWidth;
            S && !T && (A = v + c + y, this.direction === "rtl" && (A = this.width - A - w), s.fillStyle = S, s.fillRect(
              A,
              b,
              w,
              l / this.lineHeight
            )), b += l;
          }
          s.fillStyle = f, this._removeShadow(s);
        }
      },
      getFontCache: function(s) {
        var l = s.fontFamily.toLowerCase();
        n.charWidthsCache[l] || (n.charWidthsCache[l] = {});
        var c = n.charWidthsCache[l], f = s.fontStyle.toLowerCase() + "_" + (s.fontWeight + "").toLowerCase();
        return c[f] || (c[f] = {}), c[f];
      },
      _measureChar: function(s, l, c, f) {
        var m = this.getFontCache(l), d = this._getFontDeclaration(l), v = this._getFontDeclaration(f), b = c + s, y = d === v, w, _, S, T = l.fontSize / this.CACHE_FONT_SIZE, A;
        if (c && m[c] !== void 0 && (S = m[c]), m[s] !== void 0 && (A = w = m[s]), y && m[b] !== void 0 && (_ = m[b], A = _ - S), w === void 0 || S === void 0 || _ === void 0) {
          var R = this.getMeasuringContext();
          this._setTextStyles(R, l, !0);
        }
        return w === void 0 && (A = w = R.measureText(s).width, m[s] = w), S === void 0 && y && c && (S = R.measureText(c).width, m[c] = S), y && _ === void 0 && (_ = R.measureText(b).width, m[b] = _, A = _ - S), { width: w * T, kernedWidth: A * T };
      },
      getHeightOfChar: function(s, l) {
        return this.getValueOfPropertyAt(s, l, "fontSize");
      },
      measureLine: function(s) {
        var l = this._measureLine(s);
        return this.charSpacing !== 0 && (l.width -= this._getWidthOfCharSpacing()), l.width < 0 && (l.width = 0), l;
      },
      _measureLine: function(s) {
        var l = 0, c, f, m = this._textLines[s], d, v, b = 0, y = new Array(m.length), w = 0, _, S, T = this.path, A = this.pathSide === "right";
        for (this.__charBounds[s] = y, c = 0; c < m.length; c++)
          f = m[c], v = this._getGraphemeBox(f, s, c, d), y[c] = v, l += v.kernedWidth, d = f;
        if (y[c] = {
          left: v ? v.left + v.width : 0,
          width: 0,
          kernedWidth: 0,
          height: this.fontSize
        }, T) {
          switch (S = T.segmentsInfo[T.segmentsInfo.length - 1].length, _ = n.util.getPointOnPath(T.path, 0, T.segmentsInfo), _.x += T.pathOffset.x, _.y += T.pathOffset.y, this.textAlign) {
            case "left":
              w = A ? S - l : 0;
              break;
            case "center":
              w = (S - l) / 2;
              break;
            case "right":
              w = A ? 0 : S - l;
              break;
          }
          for (w += this.pathStartOffset * (A ? -1 : 1), c = A ? m.length - 1 : 0; A ? c >= 0 : c < m.length; A ? c-- : c++)
            v = y[c], w > S ? w %= S : w < 0 && (w += S), this._setGraphemeOnPath(w, v, _), w += v.kernedWidth;
        }
        return { width: l, numOfSpaces: b };
      },
      _setGraphemeOnPath: function(s, l, c) {
        var f = s + l.kernedWidth / 2, m = this.path, d = n.util.getPointOnPath(m.path, f, m.segmentsInfo);
        l.renderLeft = d.x - c.x, l.renderTop = d.y - c.y, l.angle = d.angle + (this.pathSide === "right" ? Math.PI : 0);
      },
      _getGraphemeBox: function(s, l, c, f, m) {
        var d = this.getCompleteStyleDeclaration(l, c), v = f ? this.getCompleteStyleDeclaration(l, c - 1) : {}, b = this._measureChar(s, d, f, v), y = b.kernedWidth, w = b.width, _;
        this.charSpacing !== 0 && (_ = this._getWidthOfCharSpacing(), w += _, y += _);
        var S = {
          width: w,
          left: 0,
          height: d.fontSize,
          kernedWidth: y,
          deltaY: d.deltaY
        };
        if (c > 0 && !m) {
          var T = this.__charBounds[l][c - 1];
          S.left = T.left + T.width + b.kernedWidth - b.width;
        }
        return S;
      },
      getHeightOfLine: function(s) {
        if (this.__lineHeights[s])
          return this.__lineHeights[s];
        for (var l = this._textLines[s], c = this.getHeightOfChar(s, 0), f = 1, m = l.length; f < m; f++)
          c = Math.max(this.getHeightOfChar(s, f), c);
        return this.__lineHeights[s] = c * this.lineHeight * this._fontSizeMult;
      },
      calcTextHeight: function() {
        for (var s, l = 0, c = 0, f = this._textLines.length; c < f; c++)
          s = this.getHeightOfLine(c), l += c === f - 1 ? s / this.lineHeight : s;
        return l;
      },
      _getLeftOffset: function() {
        return this.direction === "ltr" ? -this.width / 2 : this.width / 2;
      },
      _getTopOffset: function() {
        return -this.height / 2;
      },
      _renderTextCommon: function(s, l) {
        s.save();
        for (var c = 0, f = this._getLeftOffset(), m = this._getTopOffset(), d = 0, v = this._textLines.length; d < v; d++) {
          var b = this.getHeightOfLine(d), y = b / this.lineHeight, w = this._getLineLeftOffset(d);
          this._renderTextLine(
            l,
            s,
            this._textLines[d],
            f + w,
            m + c + y,
            d
          ), c += b;
        }
        s.restore();
      },
      _renderTextFill: function(s) {
        !this.fill && !this.styleHas("fill") || this._renderTextCommon(s, "fillText");
      },
      _renderTextStroke: function(s) {
        (!this.stroke || this.strokeWidth === 0) && this.isEmptyStyles() || (this.shadow && !this.shadow.affectStroke && this._removeShadow(s), s.save(), this._setLineDash(s, this.strokeDashArray), s.beginPath(), this._renderTextCommon(s, "strokeText"), s.closePath(), s.restore());
      },
      _renderChars: function(s, l, c, f, m, d) {
        var v = this.getHeightOfLine(d), b = this.textAlign.indexOf("justify") !== -1, y, w, _ = "", S, T = 0, A, R = this.path, N = !b && this.charSpacing === 0 && this.isEmptyStyles(d) && !R, U = this.direction === "ltr", Q = this.direction === "ltr" ? 1 : -1, ee, J = l.canvas.getAttribute("dir");
        if (l.save(), J !== this.direction && (l.canvas.setAttribute("dir", U ? "ltr" : "rtl"), l.direction = U ? "ltr" : "rtl", l.textAlign = U ? "left" : "right"), m -= v * this._fontSizeFraction / this.lineHeight, N) {
          this._renderChar(s, l, d, 0, c.join(""), f, m, v), l.restore();
          return;
        }
        for (var q = 0, re = c.length - 1; q <= re; q++)
          A = q === re || this.charSpacing || R, _ += c[q], S = this.__charBounds[d][q], T === 0 ? (f += Q * (S.kernedWidth - S.width), T += S.width) : T += S.kernedWidth, b && !A && this._reSpaceAndTab.test(c[q]) && (A = !0), A || (y = y || this.getCompleteStyleDeclaration(d, q), w = this.getCompleteStyleDeclaration(d, q + 1), A = n.util.hasStyleChanged(y, w, !1)), A && (R ? (l.save(), l.translate(S.renderLeft, S.renderTop), l.rotate(S.angle), this._renderChar(s, l, d, q, _, -T / 2, 0, v), l.restore()) : (ee = f, this._renderChar(s, l, d, q, _, ee, m, v)), _ = "", y = w, f += Q * T, T = 0);
        l.restore();
      },
      _applyPatternGradientTransformText: function(s) {
        var l = n.util.createCanvasElement(), c, f = this.width + this.strokeWidth, m = this.height + this.strokeWidth;
        return l.width = f, l.height = m, c = l.getContext("2d"), c.beginPath(), c.moveTo(0, 0), c.lineTo(f, 0), c.lineTo(f, m), c.lineTo(0, m), c.closePath(), c.translate(f / 2, m / 2), c.fillStyle = s.toLive(c), this._applyPatternGradientTransform(c, s), c.fill(), c.createPattern(l, "no-repeat");
      },
      handleFiller: function(s, l, c) {
        var f, m;
        return c.toLive ? c.gradientUnits === "percentage" || c.gradientTransform || c.patternTransform ? (f = -this.width / 2, m = -this.height / 2, s.translate(f, m), s[l] = this._applyPatternGradientTransformText(c), { offsetX: f, offsetY: m }) : (s[l] = c.toLive(s, this), this._applyPatternGradientTransform(s, c)) : (s[l] = c, { offsetX: 0, offsetY: 0 });
      },
      _setStrokeStyles: function(s, l) {
        return s.lineWidth = l.strokeWidth, s.lineCap = this.strokeLineCap, s.lineDashOffset = this.strokeDashOffset, s.lineJoin = this.strokeLineJoin, s.miterLimit = this.strokeMiterLimit, this.handleFiller(s, "strokeStyle", l.stroke);
      },
      _setFillStyles: function(s, l) {
        return this.handleFiller(s, "fillStyle", l.fill);
      },
      _renderChar: function(s, l, c, f, m, d, v) {
        var b = this._getStyleDeclaration(c, f), y = this.getCompleteStyleDeclaration(c, f), w = s === "fillText" && y.fill, _ = s === "strokeText" && y.stroke && y.strokeWidth, S, T;
        !_ && !w || (l.save(), w && (S = this._setFillStyles(l, y)), _ && (T = this._setStrokeStyles(l, y)), l.font = this._getFontDeclaration(y), b && b.textBackgroundColor && this._removeShadow(l), b && b.deltaY && (v += b.deltaY), w && l.fillText(m, d - S.offsetX, v - S.offsetY), _ && l.strokeText(m, d - T.offsetX, v - T.offsetY), l.restore());
      },
      setSuperscript: function(s, l) {
        return this._setScript(s, l, this.superscript);
      },
      setSubscript: function(s, l) {
        return this._setScript(s, l, this.subscript);
      },
      _setScript: function(s, l, c) {
        var f = this.get2DCursorLocation(s, !0), m = this.getValueOfPropertyAt(f.lineIndex, f.charIndex, "fontSize"), d = this.getValueOfPropertyAt(f.lineIndex, f.charIndex, "deltaY"), v = { fontSize: m * c.size, deltaY: d + m * c.baseline };
        return this.setSelectionStyles(v, s, l), this;
      },
      _getLineLeftOffset: function(s) {
        var l = this.getLineWidth(s), c = this.width - l, f = this.textAlign, m = this.direction, v, d = 0, v = this.isEndOfWrapping(s);
        return f === "justify" || f === "justify-center" && !v || f === "justify-right" && !v || f === "justify-left" && !v ? 0 : (f === "center" && (d = c / 2), f === "right" && (d = c), f === "justify-center" && (d = c / 2), f === "justify-right" && (d = c), m === "rtl" && (d -= c), d);
      },
      _clearCache: function() {
        this.__lineWidths = [], this.__lineHeights = [], this.__charBounds = [];
      },
      _shouldClearDimensionCache: function() {
        var s = this._forceClearCache;
        return s || (s = this.hasStateChanged("_dimensionAffectingProps")), s && (this.dirty = !0, this._forceClearCache = !1), s;
      },
      getLineWidth: function(s) {
        if (this.__lineWidths[s] !== void 0)
          return this.__lineWidths[s];
        var l = this.measureLine(s), c = l.width;
        return this.__lineWidths[s] = c, c;
      },
      _getWidthOfCharSpacing: function() {
        return this.charSpacing !== 0 ? this.fontSize * this.charSpacing / 1e3 : 0;
      },
      getValueOfPropertyAt: function(s, l, c) {
        var f = this._getStyleDeclaration(s, l);
        return f && typeof f[c] < "u" ? f[c] : this[c];
      },
      _renderTextDecoration: function(s, l) {
        if (!(!this[l] && !this.styleHas(l))) {
          for (var c, f, m, d, v, b, y, w, _ = this._getLeftOffset(), S = this._getTopOffset(), T, A, R, N, U, Q, ee, J, q = this.path, re = this._getWidthOfCharSpacing(), le = this.offsets[l], ne = 0, C = this._textLines.length; ne < C; ne++) {
            if (c = this.getHeightOfLine(ne), !this[l] && !this.styleHas(l, ne)) {
              S += c;
              continue;
            }
            y = this._textLines[ne], Q = c / this.lineHeight, d = this._getLineLeftOffset(ne), A = 0, R = 0, w = this.getValueOfPropertyAt(ne, 0, l), J = this.getValueOfPropertyAt(ne, 0, "fill"), T = S + Q * (1 - this._fontSizeFraction), f = this.getHeightOfChar(ne, 0), v = this.getValueOfPropertyAt(ne, 0, "deltaY");
            for (var k = 0, P = y.length; k < P; k++)
              if (N = this.__charBounds[ne][k], U = this.getValueOfPropertyAt(ne, k, l), ee = this.getValueOfPropertyAt(ne, k, "fill"), m = this.getHeightOfChar(ne, k), b = this.getValueOfPropertyAt(ne, k, "deltaY"), q && U && ee)
                s.save(), s.fillStyle = J, s.translate(N.renderLeft, N.renderTop), s.rotate(N.angle), s.fillRect(
                  -N.kernedWidth / 2,
                  le * m + b,
                  N.kernedWidth,
                  this.fontSize / 15
                ), s.restore();
              else if ((U !== w || ee !== J || m !== f || b !== v) && R > 0) {
                var D = _ + d + A;
                this.direction === "rtl" && (D = this.width - D - R), w && J && (s.fillStyle = J, s.fillRect(
                  D,
                  T + le * f + v,
                  R,
                  this.fontSize / 15
                )), A = N.left, R = N.width, w = U, J = ee, f = m, v = b;
              } else
                R += N.kernedWidth;
            var D = _ + d + A;
            this.direction === "rtl" && (D = this.width - D - R), s.fillStyle = ee, U && ee && s.fillRect(
              D,
              T + le * f + v,
              R - re,
              this.fontSize / 15
            ), S += c;
          }
          this._removeShadow(s);
        }
      },
      _getFontDeclaration: function(s, l) {
        var c = s || this, f = this.fontFamily, m = n.Text.genericFonts.indexOf(f.toLowerCase()) > -1, d = f === void 0 || f.indexOf("'") > -1 || f.indexOf(",") > -1 || f.indexOf('"') > -1 || m ? c.fontFamily : '"' + c.fontFamily + '"';
        return [
          n.isLikelyNode ? c.fontWeight : c.fontStyle,
          n.isLikelyNode ? c.fontStyle : c.fontWeight,
          l ? this.CACHE_FONT_SIZE + "px" : c.fontSize + "px",
          d
        ].join(" ");
      },
      render: function(s) {
        !this.visible || this.canvas && this.canvas.skipOffscreen && !this.group && !this.isOnScreen() || (this._shouldClearDimensionCache() && this.initDimensions(), this.callSuper("render", s));
      },
      _splitTextIntoLines: function(s) {
        for (var l = s.split(this._reNewline), c = new Array(l.length), f = [`
`], m = [], d = 0; d < l.length; d++)
          c[d] = n.util.string.graphemeSplit(l[d]), m = m.concat(c[d], f);
        return m.pop(), { _unwrappedLines: c, lines: l, graphemeText: m, graphemeLines: c };
      },
      toObject: function(s) {
        var l = h.concat(s), c = this.callSuper("toObject", l);
        return c.styles = n.util.stylesToArray(this.styles, this.text), c.path && (c.path = this.path.toObject()), c;
      },
      set: function(s, l) {
        this.callSuper("set", s, l);
        var c = !1, f = !1;
        if (typeof s == "object")
          for (var m in s)
            m === "path" && this.setPathInfo(), c = c || this._dimensionAffectingProps.indexOf(m) !== -1, f = f || m === "path";
        else
          c = this._dimensionAffectingProps.indexOf(s) !== -1, f = s === "path";
        return f && this.setPathInfo(), c && (this.initDimensions(), this.setCoords()), this;
      },
      complexity: function() {
        return 1;
      }
    }), n.Text.ATTRIBUTE_NAMES = n.SHARED_ATTRIBUTES.concat(
      "x y dx dy font-family font-style font-weight font-size letter-spacing text-decoration text-anchor".split(" ")
    ), n.Text.DEFAULT_SVG_FONT_SIZE = 16, n.Text.fromElement = function(s, l, c) {
      if (!s)
        return l(null);
      var f = n.parseAttributes(s, n.Text.ATTRIBUTE_NAMES), m = f.textAnchor || "left";
      if (c = n.util.object.extend(c ? u(c) : {}, f), c.top = c.top || 0, c.left = c.left || 0, f.textDecoration) {
        var d = f.textDecoration;
        d.indexOf("underline") !== -1 && (c.underline = !0), d.indexOf("overline") !== -1 && (c.overline = !0), d.indexOf("line-through") !== -1 && (c.linethrough = !0), delete c.textDecoration;
      }
      "dx" in f && (c.left += f.dx), "dy" in f && (c.top += f.dy), "fontSize" in c || (c.fontSize = n.Text.DEFAULT_SVG_FONT_SIZE);
      var v = "";
      "textContent" in s ? v = s.textContent : "firstChild" in s && s.firstChild !== null && "data" in s.firstChild && s.firstChild.data !== null && (v = s.firstChild.data), v = v.replace(/^\s+|\s+$|\n+/g, "").replace(/\s+/g, " ");
      var b = c.strokeWidth;
      c.strokeWidth = 0;
      var y = new n.Text(v, c), w = y.getScaledHeight() / y.height, _ = (y.height + y.strokeWidth) * y.lineHeight - y.height, S = _ * w, T = y.getScaledHeight() + S, A = 0;
      m === "center" && (A = y.getScaledWidth() / 2), m === "right" && (A = y.getScaledWidth()), y.set({
        left: y.left - A,
        top: y.top - (T - y.fontSize * (0.07 + y._fontSizeFraction)) / y.lineHeight,
        strokeWidth: typeof b < "u" ? b : 1
      }), l(y);
    }, n.Text.fromObject = function(s, l) {
      var c = u(s), f = s.path;
      return delete c.path, n.Object._fromObject("Text", c, function(m) {
        m.styles = n.util.stylesFromArray(s.styles, s.text), f ? n.Object._fromObject("Path", f, function(d) {
          m.set("path", d), l(m);
        }, "path") : l(m);
      }, "text");
    }, n.Text.genericFonts = ["sans-serif", "serif", "cursive", "fantasy", "monospace"], n.util.createAccessors && n.util.createAccessors(n.Text);
  }(t), function() {
    e.util.object.extend(e.Text.prototype, {
      isEmptyStyles: function(a) {
        if (!this.styles || typeof a < "u" && !this.styles[a])
          return !0;
        var n = typeof a > "u" ? this.styles : { line: this.styles[a] };
        for (var u in n)
          for (var h in n[u])
            for (var s in n[u][h])
              return !1;
        return !0;
      },
      styleHas: function(a, n) {
        if (!this.styles || !a || a === "" || typeof n < "u" && !this.styles[n])
          return !1;
        var u = typeof n > "u" ? this.styles : { 0: this.styles[n] };
        for (var h in u)
          for (var s in u[h])
            if (typeof u[h][s][a] < "u")
              return !0;
        return !1;
      },
      cleanStyle: function(a) {
        if (!this.styles || !a || a === "")
          return !1;
        var n = this.styles, u = 0, h, s, l = !0, c = 0, f;
        for (var m in n) {
          h = 0;
          for (var d in n[m]) {
            var f = n[m][d], v = f.hasOwnProperty(a);
            u++, v ? (s ? f[a] !== s && (l = !1) : s = f[a], f[a] === this[a] && delete f[a]) : l = !1, Object.keys(f).length !== 0 ? h++ : delete n[m][d];
          }
          h === 0 && delete n[m];
        }
        for (var b = 0; b < this._textLines.length; b++)
          c += this._textLines[b].length;
        l && u === c && (this[a] = s, this.removeStyle(a));
      },
      removeStyle: function(a) {
        if (!(!this.styles || !a || a === "")) {
          var n = this.styles, u, h, s;
          for (h in n) {
            u = n[h];
            for (s in u)
              delete u[s][a], Object.keys(u[s]).length === 0 && delete u[s];
            Object.keys(u).length === 0 && delete n[h];
          }
        }
      },
      _extendStyles: function(a, n) {
        var u = this.get2DCursorLocation(a);
        this._getLineStyle(u.lineIndex) || this._setLineStyle(u.lineIndex), this._getStyleDeclaration(u.lineIndex, u.charIndex) || this._setStyleDeclaration(u.lineIndex, u.charIndex, {}), e.util.object.extend(this._getStyleDeclaration(u.lineIndex, u.charIndex), n);
      },
      get2DCursorLocation: function(a, n) {
        typeof a > "u" && (a = this.selectionStart);
        for (var u = n ? this._unwrappedTextLines : this._textLines, h = u.length, s = 0; s < h; s++) {
          if (a <= u[s].length)
            return {
              lineIndex: s,
              charIndex: a
            };
          a -= u[s].length + this.missingNewlineOffset(s);
        }
        return {
          lineIndex: s - 1,
          charIndex: u[s - 1].length < a ? u[s - 1].length : a
        };
      },
      getSelectionStyles: function(a, n, u) {
        typeof a > "u" && (a = this.selectionStart || 0), typeof n > "u" && (n = this.selectionEnd || a);
        for (var h = [], s = a; s < n; s++)
          h.push(this.getStyleAtPosition(s, u));
        return h;
      },
      getStyleAtPosition: function(a, n) {
        var u = this.get2DCursorLocation(a), h = n ? this.getCompleteStyleDeclaration(u.lineIndex, u.charIndex) : this._getStyleDeclaration(u.lineIndex, u.charIndex);
        return h || {};
      },
      setSelectionStyles: function(a, n, u) {
        typeof n > "u" && (n = this.selectionStart || 0), typeof u > "u" && (u = this.selectionEnd || n);
        for (var h = n; h < u; h++)
          this._extendStyles(h, a);
        return this._forceClearCache = !0, this;
      },
      _getStyleDeclaration: function(a, n) {
        var u = this.styles && this.styles[a];
        return u ? u[n] : null;
      },
      getCompleteStyleDeclaration: function(a, n) {
        for (var u = this._getStyleDeclaration(a, n) || {}, h = {}, s, l = 0; l < this._styleProperties.length; l++)
          s = this._styleProperties[l], h[s] = typeof u[s] > "u" ? this[s] : u[s];
        return h;
      },
      _setStyleDeclaration: function(a, n, u) {
        this.styles[a][n] = u;
      },
      _deleteStyleDeclaration: function(a, n) {
        delete this.styles[a][n];
      },
      _getLineStyle: function(a) {
        return !!this.styles[a];
      },
      _setLineStyle: function(a) {
        this.styles[a] = {};
      },
      _deleteLineStyle: function(a) {
        delete this.styles[a];
      }
    });
  }(), function() {
    function a(n) {
      n.textDecoration && (n.textDecoration.indexOf("underline") > -1 && (n.underline = !0), n.textDecoration.indexOf("line-through") > -1 && (n.linethrough = !0), n.textDecoration.indexOf("overline") > -1 && (n.overline = !0), delete n.textDecoration);
    }
    e.IText = e.util.createClass(e.Text, e.Observable, {
      type: "i-text",
      selectionStart: 0,
      selectionEnd: 0,
      selectionColor: "rgba(17,119,255,0.3)",
      isEditing: !1,
      editable: !0,
      editingBorderColor: "rgba(102,153,255,0.25)",
      cursorWidth: 2,
      cursorColor: "",
      cursorDelay: 1e3,
      cursorDuration: 600,
      caching: !0,
      hiddenTextareaContainer: null,
      _reSpace: /\s|\n/,
      _currentCursorOpacity: 0,
      _selectionDirection: null,
      _abortCursorAnimation: !1,
      __widthOfSpace: [],
      inCompositionMode: !1,
      initialize: function(n, u) {
        this.callSuper("initialize", n, u), this.initBehavior();
      },
      setSelectionStart: function(n) {
        n = Math.max(n, 0), this._updateAndFire("selectionStart", n);
      },
      setSelectionEnd: function(n) {
        n = Math.min(n, this.text.length), this._updateAndFire("selectionEnd", n);
      },
      _updateAndFire: function(n, u) {
        this[n] !== u && (this._fireSelectionChanged(), this[n] = u), this._updateTextarea();
      },
      _fireSelectionChanged: function() {
        this.fire("selection:changed"), this.canvas && this.canvas.fire("text:selection:changed", { target: this });
      },
      initDimensions: function() {
        this.isEditing && this.initDelayedCursor(), this.clearContextTop(), this.callSuper("initDimensions");
      },
      render: function(n) {
        this.clearContextTop(), this.callSuper("render", n), this.cursorOffsetCache = {}, this.renderCursorOrSelection();
      },
      _render: function(n) {
        this.callSuper("_render", n);
      },
      clearContextTop: function(n) {
        if (!(!this.isEditing || !this.canvas || !this.canvas.contextTop)) {
          var u = this.canvas.contextTop, h = this.canvas.viewportTransform;
          u.save(), u.transform(h[0], h[1], h[2], h[3], h[4], h[5]), this.transform(u), this._clearTextArea(u), n || u.restore();
        }
      },
      renderCursorOrSelection: function() {
        if (!(!this.isEditing || !this.canvas || !this.canvas.contextTop)) {
          var n = this._getCursorBoundaries(), u = this.canvas.contextTop;
          this.clearContextTop(!0), this.selectionStart === this.selectionEnd ? this.renderCursor(n, u) : this.renderSelection(n, u), u.restore();
        }
      },
      _clearTextArea: function(n) {
        var u = this.width + 4, h = this.height + 4;
        n.clearRect(-u / 2, -h / 2, u, h);
      },
      _getCursorBoundaries: function(n) {
        typeof n > "u" && (n = this.selectionStart);
        var u = this._getLeftOffset(), h = this._getTopOffset(), s = this._getCursorBoundariesOffsets(n);
        return {
          left: u,
          top: h,
          leftOffset: s.left,
          topOffset: s.top
        };
      },
      _getCursorBoundariesOffsets: function(n) {
        if (this.cursorOffsetCache && "top" in this.cursorOffsetCache)
          return this.cursorOffsetCache;
        var u, h, s, l = 0, c = 0, f, m = this.get2DCursorLocation(n);
        s = m.charIndex, h = m.lineIndex;
        for (var d = 0; d < h; d++)
          l += this.getHeightOfLine(d);
        u = this._getLineLeftOffset(h);
        var v = this.__charBounds[h][s];
        return v && (c = v.left), this.charSpacing !== 0 && s === this._textLines[h].length && (c -= this._getWidthOfCharSpacing()), f = {
          top: l,
          left: u + (c > 0 ? c : 0)
        }, this.direction === "rtl" && (f.left *= -1), this.cursorOffsetCache = f, this.cursorOffsetCache;
      },
      renderCursor: function(n, u) {
        var h = this.get2DCursorLocation(), s = h.lineIndex, l = h.charIndex > 0 ? h.charIndex - 1 : 0, c = this.getValueOfPropertyAt(s, l, "fontSize"), f = this.scaleX * this.canvas.getZoom(), m = this.cursorWidth / f, d = n.topOffset, v = this.getValueOfPropertyAt(s, l, "deltaY");
        d += (1 - this._fontSizeFraction) * this.getHeightOfLine(s) / this.lineHeight - c * (1 - this._fontSizeFraction), this.inCompositionMode && this.renderSelection(n, u), u.fillStyle = this.cursorColor || this.getValueOfPropertyAt(s, l, "fill"), u.globalAlpha = this.__isMousedown ? 1 : this._currentCursorOpacity, u.fillRect(
          n.left + n.leftOffset - m / 2,
          d + n.top + v,
          m,
          c
        );
      },
      renderSelection: function(n, u) {
        for (var h = this.inCompositionMode ? this.hiddenTextarea.selectionStart : this.selectionStart, s = this.inCompositionMode ? this.hiddenTextarea.selectionEnd : this.selectionEnd, l = this.textAlign.indexOf("justify") !== -1, c = this.get2DCursorLocation(h), f = this.get2DCursorLocation(s), m = c.lineIndex, d = f.lineIndex, v = c.charIndex < 0 ? 0 : c.charIndex, b = f.charIndex < 0 ? 0 : f.charIndex, y = m; y <= d; y++) {
          var w = this._getLineLeftOffset(y) || 0, _ = this.getHeightOfLine(y), S = 0, T = 0, A = 0;
          if (y === m && (T = this.__charBounds[m][v].left), y >= m && y < d)
            A = l && !this.isEndOfWrapping(y) ? this.width : this.getLineWidth(y) || 5;
          else if (y === d)
            if (b === 0)
              A = this.__charBounds[d][b].left;
            else {
              var R = this._getWidthOfCharSpacing();
              A = this.__charBounds[d][b - 1].left + this.__charBounds[d][b - 1].width - R;
            }
          S = _, (this.lineHeight < 1 || y === d && this.lineHeight > 1) && (_ /= this.lineHeight);
          var N = n.left + w + T, U = A - T, Q = _, ee = 0;
          this.inCompositionMode ? (u.fillStyle = this.compositionColor || "black", Q = 1, ee = _) : u.fillStyle = this.selectionColor, this.direction === "rtl" && (N = this.width - N - U), u.fillRect(
            N,
            n.top + n.topOffset + ee,
            U,
            Q
          ), n.topOffset += S;
        }
      },
      getCurrentCharFontSize: function() {
        var n = this._getCurrentCharIndex();
        return this.getValueOfPropertyAt(n.l, n.c, "fontSize");
      },
      getCurrentCharColor: function() {
        var n = this._getCurrentCharIndex();
        return this.getValueOfPropertyAt(n.l, n.c, "fill");
      },
      _getCurrentCharIndex: function() {
        var n = this.get2DCursorLocation(this.selectionStart, !0), u = n.charIndex > 0 ? n.charIndex - 1 : 0;
        return { l: n.lineIndex, c: u };
      }
    }), e.IText.fromObject = function(n, u) {
      var h = e.util.stylesFromArray(n.styles, n.text), s = Object.assign({}, n, { styles: h });
      if (a(s), s.styles)
        for (var l in s.styles)
          for (var c in s.styles[l])
            a(s.styles[l][c]);
      e.Object._fromObject("IText", s, u, "text");
    };
  }(), function() {
    var a = e.util.object.clone;
    e.util.object.extend(e.IText.prototype, {
      initBehavior: function() {
        this.initAddedHandler(), this.initRemovedHandler(), this.initCursorSelectionHandlers(), this.initDoubleClickSimulation(), this.mouseMoveHandler = this.mouseMoveHandler.bind(this);
      },
      onDeselect: function() {
        this.isEditing && this.exitEditing(), this.selected = !1;
      },
      initAddedHandler: function() {
        var n = this;
        this.on("added", function() {
          var u = n.canvas;
          u && (u._hasITextHandlers || (u._hasITextHandlers = !0, n._initCanvasHandlers(u)), u._iTextInstances = u._iTextInstances || [], u._iTextInstances.push(n));
        });
      },
      initRemovedHandler: function() {
        var n = this;
        this.on("removed", function() {
          var u = n.canvas;
          u && (u._iTextInstances = u._iTextInstances || [], e.util.removeFromArray(u._iTextInstances, n), u._iTextInstances.length === 0 && (u._hasITextHandlers = !1, n._removeCanvasHandlers(u)));
        });
      },
      _initCanvasHandlers: function(n) {
        n._mouseUpITextHandler = function() {
          n._iTextInstances && n._iTextInstances.forEach(function(u) {
            u.__isMousedown = !1;
          });
        }, n.on("mouse:up", n._mouseUpITextHandler);
      },
      _removeCanvasHandlers: function(n) {
        n.off("mouse:up", n._mouseUpITextHandler);
      },
      _tick: function() {
        this._currentTickState = this._animateCursor(this, 1, this.cursorDuration, "_onTickComplete");
      },
      _animateCursor: function(n, u, h, s) {
        var l;
        return l = {
          isAborted: !1,
          abort: function() {
            this.isAborted = !0;
          }
        }, n.animate("_currentCursorOpacity", u, {
          duration: h,
          onComplete: function() {
            l.isAborted || n[s]();
          },
          onChange: function() {
            n.canvas && n.selectionStart === n.selectionEnd && n.renderCursorOrSelection();
          },
          abort: function() {
            return l.isAborted;
          }
        }), l;
      },
      _onTickComplete: function() {
        var n = this;
        this._cursorTimeout1 && clearTimeout(this._cursorTimeout1), this._cursorTimeout1 = setTimeout(function() {
          n._currentTickCompleteState = n._animateCursor(n, 0, this.cursorDuration / 2, "_tick");
        }, 100);
      },
      initDelayedCursor: function(n) {
        var u = this, h = n ? 0 : this.cursorDelay;
        this.abortCursorAnimation(), this._currentCursorOpacity = 1, this._cursorTimeout2 = setTimeout(function() {
          u._tick();
        }, h);
      },
      abortCursorAnimation: function() {
        var n = this._currentTickState || this._currentTickCompleteState, u = this.canvas;
        this._currentTickState && this._currentTickState.abort(), this._currentTickCompleteState && this._currentTickCompleteState.abort(), clearTimeout(this._cursorTimeout1), clearTimeout(this._cursorTimeout2), this._currentCursorOpacity = 0, n && u && u.clearContext(u.contextTop || u.contextContainer);
      },
      selectAll: function() {
        return this.selectionStart = 0, this.selectionEnd = this._text.length, this._fireSelectionChanged(), this._updateTextarea(), this;
      },
      getSelectedText: function() {
        return this._text.slice(this.selectionStart, this.selectionEnd).join("");
      },
      findWordBoundaryLeft: function(n) {
        var u = 0, h = n - 1;
        if (this._reSpace.test(this._text[h]))
          for (; this._reSpace.test(this._text[h]); )
            u++, h--;
        for (; /\S/.test(this._text[h]) && h > -1; )
          u++, h--;
        return n - u;
      },
      findWordBoundaryRight: function(n) {
        var u = 0, h = n;
        if (this._reSpace.test(this._text[h]))
          for (; this._reSpace.test(this._text[h]); )
            u++, h++;
        for (; /\S/.test(this._text[h]) && h < this._text.length; )
          u++, h++;
        return n + u;
      },
      findLineBoundaryLeft: function(n) {
        for (var u = 0, h = n - 1; !/\n/.test(this._text[h]) && h > -1; )
          u++, h--;
        return n - u;
      },
      findLineBoundaryRight: function(n) {
        for (var u = 0, h = n; !/\n/.test(this._text[h]) && h < this._text.length; )
          u++, h++;
        return n + u;
      },
      searchWordBoundary: function(n, u) {
        for (var h = this._text, s = this._reSpace.test(h[n]) ? n - 1 : n, l = h[s], c = e.reNonWord; !c.test(l) && s > 0 && s < h.length; )
          s += u, l = h[s];
        return c.test(l) && (s += u === 1 ? 0 : 1), s;
      },
      selectWord: function(n) {
        n = n || this.selectionStart;
        var u = this.searchWordBoundary(n, -1), h = this.searchWordBoundary(n, 1);
        this.selectionStart = u, this.selectionEnd = h, this._fireSelectionChanged(), this._updateTextarea(), this.renderCursorOrSelection();
      },
      selectLine: function(n) {
        n = n || this.selectionStart;
        var u = this.findLineBoundaryLeft(n), h = this.findLineBoundaryRight(n);
        return this.selectionStart = u, this.selectionEnd = h, this._fireSelectionChanged(), this._updateTextarea(), this;
      },
      enterEditing: function(n) {
        if (!(this.isEditing || !this.editable))
          return this.canvas && (this.canvas.calcOffset(), this.exitEditingOnOthers(this.canvas)), this.isEditing = !0, this.initHiddenTextarea(n), this.hiddenTextarea.focus(), this.hiddenTextarea.value = this.text, this._updateTextarea(), this._saveEditingProps(), this._setEditingProps(), this._textBeforeEdit = this.text, this._tick(), this.fire("editing:entered"), this._fireSelectionChanged(), this.canvas ? (this.canvas.fire("text:editing:entered", { target: this }), this.initMouseMoveHandler(), this.canvas.requestRenderAll(), this) : this;
      },
      exitEditingOnOthers: function(n) {
        n._iTextInstances && n._iTextInstances.forEach(function(u) {
          u.selected = !1, u.isEditing && u.exitEditing();
        });
      },
      initMouseMoveHandler: function() {
        this.canvas.on("mouse:move", this.mouseMoveHandler);
      },
      mouseMoveHandler: function(n) {
        if (!(!this.__isMousedown || !this.isEditing)) {
          document.activeElement !== this.hiddenTextarea && this.hiddenTextarea.focus();
          var u = this.getSelectionStartFromPointer(n.e), h = this.selectionStart, s = this.selectionEnd;
          (u !== this.__selectionStartOnMouseDown || h === s) && (h === u || s === u) || (u > this.__selectionStartOnMouseDown ? (this.selectionStart = this.__selectionStartOnMouseDown, this.selectionEnd = u) : (this.selectionStart = u, this.selectionEnd = this.__selectionStartOnMouseDown), (this.selectionStart !== h || this.selectionEnd !== s) && (this.restartCursorIfNeeded(), this._fireSelectionChanged(), this._updateTextarea(), this.renderCursorOrSelection()));
        }
      },
      _setEditingProps: function() {
        this.hoverCursor = "text", this.canvas && (this.canvas.defaultCursor = this.canvas.moveCursor = "text"), this.borderColor = this.editingBorderColor, this.hasControls = this.selectable = !1, this.lockMovementX = this.lockMovementY = !0;
      },
      fromStringToGraphemeSelection: function(n, u, h) {
        var s = h.slice(0, n), l = e.util.string.graphemeSplit(s).length;
        if (n === u)
          return { selectionStart: l, selectionEnd: l };
        var c = h.slice(n, u), f = e.util.string.graphemeSplit(c).length;
        return { selectionStart: l, selectionEnd: l + f };
      },
      fromGraphemeToStringSelection: function(n, u, h) {
        var s = h.slice(0, n), l = s.join("").length;
        if (n === u)
          return { selectionStart: l, selectionEnd: l };
        var c = h.slice(n, u), f = c.join("").length;
        return { selectionStart: l, selectionEnd: l + f };
      },
      _updateTextarea: function() {
        if (this.cursorOffsetCache = {}, !!this.hiddenTextarea) {
          if (!this.inCompositionMode) {
            var n = this.fromGraphemeToStringSelection(this.selectionStart, this.selectionEnd, this._text);
            this.hiddenTextarea.selectionStart = n.selectionStart, this.hiddenTextarea.selectionEnd = n.selectionEnd;
          }
          this.updateTextareaPosition();
        }
      },
      updateFromTextArea: function() {
        if (!!this.hiddenTextarea) {
          this.cursorOffsetCache = {}, this.text = this.hiddenTextarea.value, this._shouldClearDimensionCache() && (this.initDimensions(), this.setCoords());
          var n = this.fromStringToGraphemeSelection(
            this.hiddenTextarea.selectionStart,
            this.hiddenTextarea.selectionEnd,
            this.hiddenTextarea.value
          );
          this.selectionEnd = this.selectionStart = n.selectionEnd, this.inCompositionMode || (this.selectionStart = n.selectionStart), this.updateTextareaPosition();
        }
      },
      updateTextareaPosition: function() {
        if (this.selectionStart === this.selectionEnd) {
          var n = this._calcTextareaPosition();
          this.hiddenTextarea.style.left = n.left, this.hiddenTextarea.style.top = n.top;
        }
      },
      _calcTextareaPosition: function() {
        if (!this.canvas)
          return { x: 1, y: 1 };
        var n = this.inCompositionMode ? this.compositionStart : this.selectionStart, u = this._getCursorBoundaries(n), h = this.get2DCursorLocation(n), s = h.lineIndex, l = h.charIndex, c = this.getValueOfPropertyAt(s, l, "fontSize") * this.lineHeight, f = u.leftOffset, m = this.calcTransformMatrix(), d = {
          x: u.left + f,
          y: u.top + u.topOffset + c
        }, v = this.canvas.getRetinaScaling(), b = this.canvas.upperCanvasEl, y = b.width / v, w = b.height / v, _ = y - c, S = w - c, T = b.clientWidth / y, A = b.clientHeight / w;
        return d = e.util.transformPoint(d, m), d = e.util.transformPoint(d, this.canvas.viewportTransform), d.x *= T, d.y *= A, d.x < 0 && (d.x = 0), d.x > _ && (d.x = _), d.y < 0 && (d.y = 0), d.y > S && (d.y = S), d.x += this.canvas._offset.left, d.y += this.canvas._offset.top, { left: d.x + "px", top: d.y + "px", fontSize: c + "px", charHeight: c };
      },
      _saveEditingProps: function() {
        this._savedProps = {
          hasControls: this.hasControls,
          borderColor: this.borderColor,
          lockMovementX: this.lockMovementX,
          lockMovementY: this.lockMovementY,
          hoverCursor: this.hoverCursor,
          selectable: this.selectable,
          defaultCursor: this.canvas && this.canvas.defaultCursor,
          moveCursor: this.canvas && this.canvas.moveCursor
        };
      },
      _restoreEditingProps: function() {
        !this._savedProps || (this.hoverCursor = this._savedProps.hoverCursor, this.hasControls = this._savedProps.hasControls, this.borderColor = this._savedProps.borderColor, this.selectable = this._savedProps.selectable, this.lockMovementX = this._savedProps.lockMovementX, this.lockMovementY = this._savedProps.lockMovementY, this.canvas && (this.canvas.defaultCursor = this._savedProps.defaultCursor, this.canvas.moveCursor = this._savedProps.moveCursor));
      },
      exitEditing: function() {
        var n = this._textBeforeEdit !== this.text, u = this.hiddenTextarea;
        return this.selected = !1, this.isEditing = !1, this.selectionEnd = this.selectionStart, u && (u.blur && u.blur(), u.parentNode && u.parentNode.removeChild(u)), this.hiddenTextarea = null, this.abortCursorAnimation(), this._restoreEditingProps(), this._currentCursorOpacity = 0, this._shouldClearDimensionCache() && (this.initDimensions(), this.setCoords()), this.fire("editing:exited"), n && this.fire("modified"), this.canvas && (this.canvas.off("mouse:move", this.mouseMoveHandler), this.canvas.fire("text:editing:exited", { target: this }), n && this.canvas.fire("object:modified", { target: this })), this;
      },
      _removeExtraneousStyles: function() {
        for (var n in this.styles)
          this._textLines[n] || delete this.styles[n];
      },
      removeStyleFromTo: function(n, u) {
        var h = this.get2DCursorLocation(n, !0), s = this.get2DCursorLocation(u, !0), l = h.lineIndex, c = h.charIndex, f = s.lineIndex, m = s.charIndex, d, v;
        if (l !== f) {
          if (this.styles[l])
            for (d = c; d < this._unwrappedTextLines[l].length; d++)
              delete this.styles[l][d];
          if (this.styles[f])
            for (d = m; d < this._unwrappedTextLines[f].length; d++)
              v = this.styles[f][d], v && (this.styles[l] || (this.styles[l] = {}), this.styles[l][c + d - m] = v);
          for (d = l + 1; d <= f; d++)
            delete this.styles[d];
          this.shiftLineStyles(f, l - f);
        } else if (this.styles[l]) {
          v = this.styles[l];
          var b = m - c, y, w;
          for (d = c; d < m; d++)
            delete v[d];
          for (w in this.styles[l])
            y = parseInt(w, 10), y >= m && (v[y - b] = v[w], delete v[w]);
        }
      },
      shiftLineStyles: function(n, u) {
        var h = a(this.styles);
        for (var s in this.styles) {
          var l = parseInt(s, 10);
          l > n && (this.styles[l + u] = h[l], h[l - u] || delete this.styles[l]);
        }
      },
      restartCursorIfNeeded: function() {
        (!this._currentTickState || this._currentTickState.isAborted || !this._currentTickCompleteState || this._currentTickCompleteState.isAborted) && this.initDelayedCursor();
      },
      insertNewlineStyleObject: function(n, u, h, s) {
        var l, c = {}, f = !1, m = this._unwrappedTextLines[n].length === u;
        h || (h = 1), this.shiftLineStyles(n, h), this.styles[n] && (l = this.styles[n][u === 0 ? u : u - 1]);
        for (var d in this.styles[n]) {
          var v = parseInt(d, 10);
          v >= u && (f = !0, c[v - u] = this.styles[n][d], m && u === 0 || delete this.styles[n][d]);
        }
        var b = !1;
        for (f && !m && (this.styles[n + h] = c, b = !0), b && h--; h > 0; )
          s && s[h - 1] ? this.styles[n + h] = { 0: a(s[h - 1]) } : l ? this.styles[n + h] = { 0: a(l) } : delete this.styles[n + h], h--;
        this._forceClearCache = !0;
      },
      insertCharStyleObject: function(n, u, h, s) {
        this.styles || (this.styles = {});
        var l = this.styles[n], c = l ? a(l) : {};
        h || (h = 1);
        for (var f in c) {
          var m = parseInt(f, 10);
          m >= u && (l[m + h] = c[m], c[m - h] || delete l[m]);
        }
        if (this._forceClearCache = !0, s) {
          for (; h--; )
            !Object.keys(s[h]).length || (this.styles[n] || (this.styles[n] = {}), this.styles[n][u + h] = a(s[h]));
          return;
        }
        if (!!l)
          for (var d = l[u ? u - 1 : 1]; d && h--; )
            this.styles[n][u + h] = a(d);
      },
      insertNewStyleBlock: function(n, u, h) {
        for (var s = this.get2DCursorLocation(u, !0), l = [0], c = 0, f = 0; f < n.length; f++)
          n[f] === `
` ? (c++, l[c] = 0) : l[c]++;
        l[0] > 0 && (this.insertCharStyleObject(s.lineIndex, s.charIndex, l[0], h), h = h && h.slice(l[0] + 1)), c && this.insertNewlineStyleObject(
          s.lineIndex,
          s.charIndex + l[0],
          c
        );
        for (var f = 1; f < c; f++)
          l[f] > 0 ? this.insertCharStyleObject(s.lineIndex + f, 0, l[f], h) : h && this.styles[s.lineIndex + f] && h[0] && (this.styles[s.lineIndex + f][0] = h[0]), h = h && h.slice(l[f] + 1);
        l[f] > 0 && this.insertCharStyleObject(s.lineIndex + f, 0, l[f], h);
      },
      setSelectionStartEndWithShift: function(n, u, h) {
        h <= n ? (u === n ? this._selectionDirection = "left" : this._selectionDirection === "right" && (this._selectionDirection = "left", this.selectionEnd = n), this.selectionStart = h) : h > n && h < u ? this._selectionDirection === "right" ? this.selectionEnd = h : this.selectionStart = h : (u === n ? this._selectionDirection = "right" : this._selectionDirection === "left" && (this._selectionDirection = "right", this.selectionStart = u), this.selectionEnd = h);
      },
      setSelectionInBoundaries: function() {
        var n = this.text.length;
        this.selectionStart > n ? this.selectionStart = n : this.selectionStart < 0 && (this.selectionStart = 0), this.selectionEnd > n ? this.selectionEnd = n : this.selectionEnd < 0 && (this.selectionEnd = 0);
      }
    });
  }(), e.util.object.extend(e.IText.prototype, {
    initDoubleClickSimulation: function() {
      this.__lastClickTime = +new Date(), this.__lastLastClickTime = +new Date(), this.__lastPointer = {}, this.on("mousedown", this.onMouseDown);
    },
    onMouseDown: function(a) {
      if (!!this.canvas) {
        this.__newClickTime = +new Date();
        var n = a.pointer;
        this.isTripleClick(n) && (this.fire("tripleclick", a), this._stopEvent(a.e)), this.__lastLastClickTime = this.__lastClickTime, this.__lastClickTime = this.__newClickTime, this.__lastPointer = n, this.__lastIsEditing = this.isEditing, this.__lastSelected = this.selected;
      }
    },
    isTripleClick: function(a) {
      return this.__newClickTime - this.__lastClickTime < 500 && this.__lastClickTime - this.__lastLastClickTime < 500 && this.__lastPointer.x === a.x && this.__lastPointer.y === a.y;
    },
    _stopEvent: function(a) {
      a.preventDefault && a.preventDefault(), a.stopPropagation && a.stopPropagation();
    },
    initCursorSelectionHandlers: function() {
      this.initMousedownHandler(), this.initMouseupHandler(), this.initClicks();
    },
    doubleClickHandler: function(a) {
      !this.isEditing || this.selectWord(this.getSelectionStartFromPointer(a.e));
    },
    tripleClickHandler: function(a) {
      !this.isEditing || this.selectLine(this.getSelectionStartFromPointer(a.e));
    },
    initClicks: function() {
      this.on("mousedblclick", this.doubleClickHandler), this.on("tripleclick", this.tripleClickHandler);
    },
    _mouseDownHandler: function(a) {
      !this.canvas || !this.editable || a.e.button && a.e.button !== 1 || (this.__isMousedown = !0, this.selected && (this.inCompositionMode = !1, this.setCursorByClick(a.e)), this.isEditing && (this.__selectionStartOnMouseDown = this.selectionStart, this.selectionStart === this.selectionEnd && this.abortCursorAnimation(), this.renderCursorOrSelection()));
    },
    _mouseDownHandlerBefore: function(a) {
      !this.canvas || !this.editable || a.e.button && a.e.button !== 1 || (this.selected = this === this.canvas._activeObject);
    },
    initMousedownHandler: function() {
      this.on("mousedown", this._mouseDownHandler), this.on("mousedown:before", this._mouseDownHandlerBefore);
    },
    initMouseupHandler: function() {
      this.on("mouseup", this.mouseUpHandler);
    },
    mouseUpHandler: function(a) {
      if (this.__isMousedown = !1, !(!this.editable || this.group || a.transform && a.transform.actionPerformed || a.e.button && a.e.button !== 1)) {
        if (this.canvas) {
          var n = this.canvas._activeObject;
          if (n && n !== this)
            return;
        }
        this.__lastSelected && !this.__corner ? (this.selected = !1, this.__lastSelected = !1, this.enterEditing(a.e), this.selectionStart === this.selectionEnd ? this.initDelayedCursor(!0) : this.renderCursorOrSelection()) : this.selected = !0;
      }
    },
    setCursorByClick: function(a) {
      var n = this.getSelectionStartFromPointer(a), u = this.selectionStart, h = this.selectionEnd;
      a.shiftKey ? this.setSelectionStartEndWithShift(u, h, n) : (this.selectionStart = n, this.selectionEnd = n), this.isEditing && (this._fireSelectionChanged(), this._updateTextarea());
    },
    getSelectionStartFromPointer: function(a) {
      for (var n = this.getLocalPointer(a), u = 0, h = 0, s = 0, l = 0, c = 0, f, m, d = 0, v = this._textLines.length; d < v && s <= n.y; d++)
        s += this.getHeightOfLine(d) * this.scaleY, c = d, d > 0 && (l += this._textLines[d - 1].length + this.missingNewlineOffset(d - 1));
      f = this._getLineLeftOffset(c), h = f * this.scaleX, m = this._textLines[c], this.direction === "rtl" && (n.x = this.width * this.scaleX - n.x + h);
      for (var b = 0, y = m.length; b < y && (u = h, h += this.__charBounds[c][b].kernedWidth * this.scaleX, h <= n.x); b++)
        l++;
      return this._getNewSelectionStartFromOffset(n, u, h, l, y);
    },
    _getNewSelectionStartFromOffset: function(a, n, u, h, s) {
      var l = a.x - n, c = u - a.x, f = c > l || c < 0 ? 0 : 1, m = h + f;
      return this.flipX && (m = s - m), m > this._text.length && (m = this._text.length), m;
    }
  }), e.util.object.extend(e.IText.prototype, {
    initHiddenTextarea: function() {
      this.hiddenTextarea = e.document.createElement("textarea"), this.hiddenTextarea.setAttribute("autocapitalize", "off"), this.hiddenTextarea.setAttribute("autocorrect", "off"), this.hiddenTextarea.setAttribute("autocomplete", "off"), this.hiddenTextarea.setAttribute("spellcheck", "false"), this.hiddenTextarea.setAttribute("data-fabric-hiddentextarea", ""), this.hiddenTextarea.setAttribute("wrap", "off");
      var a = this._calcTextareaPosition();
      this.hiddenTextarea.style.cssText = "position: absolute; top: " + a.top + "; left: " + a.left + "; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding\uFF70top: " + a.fontSize + ";", this.hiddenTextareaContainer ? this.hiddenTextareaContainer.appendChild(this.hiddenTextarea) : e.document.body.appendChild(this.hiddenTextarea), e.util.addListener(this.hiddenTextarea, "keydown", this.onKeyDown.bind(this)), e.util.addListener(this.hiddenTextarea, "keyup", this.onKeyUp.bind(this)), e.util.addListener(this.hiddenTextarea, "input", this.onInput.bind(this)), e.util.addListener(this.hiddenTextarea, "copy", this.copy.bind(this)), e.util.addListener(this.hiddenTextarea, "cut", this.copy.bind(this)), e.util.addListener(this.hiddenTextarea, "paste", this.paste.bind(this)), e.util.addListener(this.hiddenTextarea, "compositionstart", this.onCompositionStart.bind(this)), e.util.addListener(this.hiddenTextarea, "compositionupdate", this.onCompositionUpdate.bind(this)), e.util.addListener(this.hiddenTextarea, "compositionend", this.onCompositionEnd.bind(this)), !this._clickHandlerInitialized && this.canvas && (e.util.addListener(this.canvas.upperCanvasEl, "click", this.onClick.bind(this)), this._clickHandlerInitialized = !0);
    },
    keysMap: {
      9: "exitEditing",
      27: "exitEditing",
      33: "moveCursorUp",
      34: "moveCursorDown",
      35: "moveCursorRight",
      36: "moveCursorLeft",
      37: "moveCursorLeft",
      38: "moveCursorUp",
      39: "moveCursorRight",
      40: "moveCursorDown"
    },
    keysMapRtl: {
      9: "exitEditing",
      27: "exitEditing",
      33: "moveCursorUp",
      34: "moveCursorDown",
      35: "moveCursorLeft",
      36: "moveCursorRight",
      37: "moveCursorRight",
      38: "moveCursorUp",
      39: "moveCursorLeft",
      40: "moveCursorDown"
    },
    ctrlKeysMapUp: {
      67: "copy",
      88: "cut"
    },
    ctrlKeysMapDown: {
      65: "selectAll"
    },
    onClick: function() {
      this.hiddenTextarea && this.hiddenTextarea.focus();
    },
    onKeyDown: function(a) {
      if (!!this.isEditing) {
        var n = this.direction === "rtl" ? this.keysMapRtl : this.keysMap;
        if (a.keyCode in n)
          this[n[a.keyCode]](a);
        else if (a.keyCode in this.ctrlKeysMapDown && (a.ctrlKey || a.metaKey))
          this[this.ctrlKeysMapDown[a.keyCode]](a);
        else
          return;
        a.stopImmediatePropagation(), a.preventDefault(), a.keyCode >= 33 && a.keyCode <= 40 ? (this.inCompositionMode = !1, this.clearContextTop(), this.renderCursorOrSelection()) : this.canvas && this.canvas.requestRenderAll();
      }
    },
    onKeyUp: function(a) {
      if (!this.isEditing || this._copyDone || this.inCompositionMode) {
        this._copyDone = !1;
        return;
      }
      if (a.keyCode in this.ctrlKeysMapUp && (a.ctrlKey || a.metaKey))
        this[this.ctrlKeysMapUp[a.keyCode]](a);
      else
        return;
      a.stopImmediatePropagation(), a.preventDefault(), this.canvas && this.canvas.requestRenderAll();
    },
    onInput: function(a) {
      var n = this.fromPaste;
      if (this.fromPaste = !1, a && a.stopPropagation(), !!this.isEditing) {
        var u = this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText, h = this._text.length, s = u.length, l, c, f = s - h, m = this.selectionStart, d = this.selectionEnd, v = m !== d, b, y, w;
        if (this.hiddenTextarea.value === "") {
          this.styles = {}, this.updateFromTextArea(), this.fire("changed"), this.canvas && (this.canvas.fire("text:changed", { target: this }), this.canvas.requestRenderAll());
          return;
        }
        var _ = this.fromStringToGraphemeSelection(
          this.hiddenTextarea.selectionStart,
          this.hiddenTextarea.selectionEnd,
          this.hiddenTextarea.value
        ), S = m > _.selectionStart;
        v ? (l = this._text.slice(m, d), f += d - m) : s < h && (S ? l = this._text.slice(d + f, d) : l = this._text.slice(m, m - f)), c = u.slice(_.selectionEnd - f, _.selectionEnd), l && l.length && (c.length && (b = this.getSelectionStyles(m, m + 1, !1), b = c.map(function() {
          return b[0];
        })), v ? (y = m, w = d) : S ? (y = d - l.length, w = d) : (y = d, w = d + l.length), this.removeStyleFromTo(y, w)), c.length && (n && c.join("") === e.copiedText && !e.disableStyleCopyPaste && (b = e.copiedTextStyle), this.insertNewStyleBlock(c, m, b)), this.updateFromTextArea(), this.fire("changed"), this.canvas && (this.canvas.fire("text:changed", { target: this }), this.canvas.requestRenderAll());
      }
    },
    onCompositionStart: function() {
      this.inCompositionMode = !0;
    },
    onCompositionEnd: function() {
      this.inCompositionMode = !1;
    },
    onCompositionUpdate: function(a) {
      this.compositionStart = a.target.selectionStart, this.compositionEnd = a.target.selectionEnd, this.updateTextareaPosition();
    },
    copy: function() {
      this.selectionStart !== this.selectionEnd && (e.copiedText = this.getSelectedText(), e.disableStyleCopyPaste ? e.copiedTextStyle = null : e.copiedTextStyle = this.getSelectionStyles(this.selectionStart, this.selectionEnd, !0), this._copyDone = !0);
    },
    paste: function() {
      this.fromPaste = !0;
    },
    _getClipboardData: function(a) {
      return a && a.clipboardData || e.window.clipboardData;
    },
    _getWidthBeforeCursor: function(a, n) {
      var u = this._getLineLeftOffset(a), h;
      return n > 0 && (h = this.__charBounds[a][n - 1], u += h.left + h.width), u;
    },
    getDownCursorOffset: function(a, n) {
      var u = this._getSelectionForOffset(a, n), h = this.get2DCursorLocation(u), s = h.lineIndex;
      if (s === this._textLines.length - 1 || a.metaKey || a.keyCode === 34)
        return this._text.length - u;
      var l = h.charIndex, c = this._getWidthBeforeCursor(s, l), f = this._getIndexOnLine(s + 1, c), m = this._textLines[s].slice(l);
      return m.length + f + 1 + this.missingNewlineOffset(s);
    },
    _getSelectionForOffset: function(a, n) {
      return a.shiftKey && this.selectionStart !== this.selectionEnd && n ? this.selectionEnd : this.selectionStart;
    },
    getUpCursorOffset: function(a, n) {
      var u = this._getSelectionForOffset(a, n), h = this.get2DCursorLocation(u), s = h.lineIndex;
      if (s === 0 || a.metaKey || a.keyCode === 33)
        return -u;
      var l = h.charIndex, c = this._getWidthBeforeCursor(s, l), f = this._getIndexOnLine(s - 1, c), m = this._textLines[s].slice(0, l), d = this.missingNewlineOffset(s - 1);
      return -this._textLines[s - 1].length + f - m.length + (1 - d);
    },
    _getIndexOnLine: function(a, n) {
      for (var u = this._textLines[a], h = this._getLineLeftOffset(a), s = h, l = 0, c, f, m = 0, d = u.length; m < d; m++)
        if (c = this.__charBounds[a][m].width, s += c, s > n) {
          f = !0;
          var v = s - c, b = s, y = Math.abs(v - n), w = Math.abs(b - n);
          l = w < y ? m : m - 1;
          break;
        }
      return f || (l = u.length - 1), l;
    },
    moveCursorDown: function(a) {
      this.selectionStart >= this._text.length && this.selectionEnd >= this._text.length || this._moveCursorUpOrDown("Down", a);
    },
    moveCursorUp: function(a) {
      this.selectionStart === 0 && this.selectionEnd === 0 || this._moveCursorUpOrDown("Up", a);
    },
    _moveCursorUpOrDown: function(a, n) {
      var u = "get" + a + "CursorOffset", h = this[u](n, this._selectionDirection === "right");
      n.shiftKey ? this.moveCursorWithShift(h) : this.moveCursorWithoutShift(h), h !== 0 && (this.setSelectionInBoundaries(), this.abortCursorAnimation(), this._currentCursorOpacity = 1, this.initDelayedCursor(), this._fireSelectionChanged(), this._updateTextarea());
    },
    moveCursorWithShift: function(a) {
      var n = this._selectionDirection === "left" ? this.selectionStart + a : this.selectionEnd + a;
      return this.setSelectionStartEndWithShift(this.selectionStart, this.selectionEnd, n), a !== 0;
    },
    moveCursorWithoutShift: function(a) {
      return a < 0 ? (this.selectionStart += a, this.selectionEnd = this.selectionStart) : (this.selectionEnd += a, this.selectionStart = this.selectionEnd), a !== 0;
    },
    moveCursorLeft: function(a) {
      this.selectionStart === 0 && this.selectionEnd === 0 || this._moveCursorLeftOrRight("Left", a);
    },
    _move: function(a, n, u) {
      var h;
      if (a.altKey)
        h = this["findWordBoundary" + u](this[n]);
      else if (a.metaKey || a.keyCode === 35 || a.keyCode === 36)
        h = this["findLineBoundary" + u](this[n]);
      else
        return this[n] += u === "Left" ? -1 : 1, !0;
      if (typeof h < "u" && this[n] !== h)
        return this[n] = h, !0;
    },
    _moveLeft: function(a, n) {
      return this._move(a, n, "Left");
    },
    _moveRight: function(a, n) {
      return this._move(a, n, "Right");
    },
    moveCursorLeftWithoutShift: function(a) {
      var n = !0;
      return this._selectionDirection = "left", this.selectionEnd === this.selectionStart && this.selectionStart !== 0 && (n = this._moveLeft(a, "selectionStart")), this.selectionEnd = this.selectionStart, n;
    },
    moveCursorLeftWithShift: function(a) {
      if (this._selectionDirection === "right" && this.selectionStart !== this.selectionEnd)
        return this._moveLeft(a, "selectionEnd");
      if (this.selectionStart !== 0)
        return this._selectionDirection = "left", this._moveLeft(a, "selectionStart");
    },
    moveCursorRight: function(a) {
      this.selectionStart >= this._text.length && this.selectionEnd >= this._text.length || this._moveCursorLeftOrRight("Right", a);
    },
    _moveCursorLeftOrRight: function(a, n) {
      var u = "moveCursor" + a + "With";
      this._currentCursorOpacity = 1, n.shiftKey ? u += "Shift" : u += "outShift", this[u](n) && (this.abortCursorAnimation(), this.initDelayedCursor(), this._fireSelectionChanged(), this._updateTextarea());
    },
    moveCursorRightWithShift: function(a) {
      if (this._selectionDirection === "left" && this.selectionStart !== this.selectionEnd)
        return this._moveRight(a, "selectionStart");
      if (this.selectionEnd !== this._text.length)
        return this._selectionDirection = "right", this._moveRight(a, "selectionEnd");
    },
    moveCursorRightWithoutShift: function(a) {
      var n = !0;
      return this._selectionDirection = "right", this.selectionStart === this.selectionEnd ? (n = this._moveRight(a, "selectionStart"), this.selectionEnd = this.selectionStart) : this.selectionStart = this.selectionEnd, n;
    },
    removeChars: function(a, n) {
      typeof n > "u" && (n = a + 1), this.removeStyleFromTo(a, n), this._text.splice(a, n - a), this.text = this._text.join(""), this.set("dirty", !0), this._shouldClearDimensionCache() && (this.initDimensions(), this.setCoords()), this._removeExtraneousStyles();
    },
    insertChars: function(a, n, u, h) {
      typeof h > "u" && (h = u), h > u && this.removeStyleFromTo(u, h);
      var s = e.util.string.graphemeSplit(a);
      this.insertNewStyleBlock(s, u, n), this._text = [].concat(this._text.slice(0, u), s, this._text.slice(h)), this.text = this._text.join(""), this.set("dirty", !0), this._shouldClearDimensionCache() && (this.initDimensions(), this.setCoords()), this._removeExtraneousStyles();
    }
  }), function() {
    var a = e.util.toFixed, n = /  +/g;
    e.util.object.extend(e.Text.prototype, {
      _toSVG: function() {
        var u = this._getSVGLeftTopOffsets(), h = this._getSVGTextAndBg(u.textTop, u.textLeft);
        return this._wrapSVGTextAndBg(h);
      },
      toSVG: function(u) {
        return this._createBaseSVGMarkup(
          this._toSVG(),
          { reviver: u, noStyle: !0, withShadow: !0 }
        );
      },
      _getSVGLeftTopOffsets: function() {
        return {
          textLeft: -this.width / 2,
          textTop: -this.height / 2,
          lineTop: this.getHeightOfLine(0)
        };
      },
      _wrapSVGTextAndBg: function(u) {
        var h = !0, s = this.getSvgTextDecoration(this);
        return [
          u.textBgRects.join(""),
          '		<text xml:space="preserve" ',
          this.fontFamily ? 'font-family="' + this.fontFamily.replace(/"/g, "'") + '" ' : "",
          this.fontSize ? 'font-size="' + this.fontSize + '" ' : "",
          this.fontStyle ? 'font-style="' + this.fontStyle + '" ' : "",
          this.fontWeight ? 'font-weight="' + this.fontWeight + '" ' : "",
          s ? 'text-decoration="' + s + '" ' : "",
          'style="',
          this.getSvgStyles(h),
          '"',
          this.addPaintOrder(),
          " >",
          u.textSpans.join(""),
          `</text>
`
        ];
      },
      _getSVGTextAndBg: function(u, h) {
        var s = [], l = [], c = u, f;
        this._setSVGBg(l);
        for (var m = 0, d = this._textLines.length; m < d; m++)
          f = this._getLineLeftOffset(m), (this.textBackgroundColor || this.styleHas("textBackgroundColor", m)) && this._setSVGTextLineBg(l, m, h + f, c), this._setSVGTextLineText(s, m, h + f, c), c += this.getHeightOfLine(m);
        return {
          textSpans: s,
          textBgRects: l
        };
      },
      _createTextCharSpan: function(u, h, s, l) {
        var c = u !== u.trim() || u.match(n), f = this.getSvgSpanStyles(h, c), m = f ? 'style="' + f + '"' : "", d = h.deltaY, v = "", b = e.Object.NUM_FRACTION_DIGITS;
        return d && (v = ' dy="' + a(d, b) + '" '), [
          '<tspan x="',
          a(s, b),
          '" y="',
          a(l, b),
          '" ',
          v,
          m,
          ">",
          e.util.string.escapeXml(u),
          "</tspan>"
        ].join("");
      },
      _setSVGTextLineText: function(u, h, s, l) {
        var c = this.getHeightOfLine(h), f = this.textAlign.indexOf("justify") !== -1, m, d, v = "", b, y, w = 0, _ = this._textLines[h], S;
        l += c * (1 - this._fontSizeFraction) / this.lineHeight;
        for (var T = 0, A = _.length - 1; T <= A; T++)
          S = T === A || this.charSpacing, v += _[T], b = this.__charBounds[h][T], w === 0 ? (s += b.kernedWidth - b.width, w += b.width) : w += b.kernedWidth, f && !S && this._reSpaceAndTab.test(_[T]) && (S = !0), S || (m = m || this.getCompleteStyleDeclaration(h, T), d = this.getCompleteStyleDeclaration(h, T + 1), S = e.util.hasStyleChanged(m, d, !0)), S && (y = this._getStyleDeclaration(h, T) || {}, u.push(this._createTextCharSpan(v, y, s, l)), v = "", m = d, s += w, w = 0);
      },
      _pushTextBgRect: function(u, h, s, l, c, f) {
        var m = e.Object.NUM_FRACTION_DIGITS;
        u.push(
          "		<rect ",
          this._getFillAttributes(h),
          ' x="',
          a(s, m),
          '" y="',
          a(l, m),
          '" width="',
          a(c, m),
          '" height="',
          a(f, m),
          `"></rect>
`
        );
      },
      _setSVGTextLineBg: function(u, h, s, l) {
        for (var c = this._textLines[h], f = this.getHeightOfLine(h) / this.lineHeight, m = 0, d = 0, v, b, y = this.getValueOfPropertyAt(h, 0, "textBackgroundColor"), w = 0, _ = c.length; w < _; w++)
          v = this.__charBounds[h][w], b = this.getValueOfPropertyAt(h, w, "textBackgroundColor"), b !== y ? (y && this._pushTextBgRect(
            u,
            y,
            s + d,
            l,
            m,
            f
          ), d = v.left, m = v.width, y = b) : m += v.kernedWidth;
        b && this._pushTextBgRect(
          u,
          b,
          s + d,
          l,
          m,
          f
        );
      },
      _getFillAttributes: function(u) {
        var h = u && typeof u == "string" ? new e.Color(u) : "";
        return !h || !h.getSource() || h.getAlpha() === 1 ? 'fill="' + u + '"' : 'opacity="' + h.getAlpha() + '" fill="' + h.setAlpha(1).toRgb() + '"';
      },
      _getSVGLineTopOffset: function(u) {
        for (var h = 0, s = 0, l = 0; l < u; l++)
          h += this.getHeightOfLine(l);
        return s = this.getHeightOfLine(l), {
          lineTop: h,
          offset: (this._fontSizeMult - this._fontSizeFraction) * s / (this.lineHeight * this._fontSizeMult)
        };
      },
      getSvgStyles: function(u) {
        var h = e.Object.prototype.getSvgStyles.call(this, u);
        return h + " white-space: pre;";
      }
    });
  }(), function(a) {
    var n = a.fabric || (a.fabric = {});
    n.Textbox = n.util.createClass(n.IText, n.Observable, {
      type: "textbox",
      minWidth: 20,
      dynamicMinWidth: 2,
      __cachedLines: null,
      lockScalingFlip: !0,
      noScaleCache: !1,
      _dimensionAffectingProps: n.Text.prototype._dimensionAffectingProps.concat("width"),
      _wordJoiners: /[ \t\r]/,
      splitByGrapheme: !1,
      initDimensions: function() {
        this.__skipDimension || (this.isEditing && this.initDelayedCursor(), this.clearContextTop(), this._clearCache(), this.dynamicMinWidth = 0, this._styleMap = this._generateStyleMap(this._splitText()), this.dynamicMinWidth > this.width && this._set("width", this.dynamicMinWidth), this.textAlign.indexOf("justify") !== -1 && this.enlargeSpaces(), this.height = this.calcTextHeight(), this.saveState({ propertySet: "_dimensionAffectingProps" }));
      },
      _generateStyleMap: function(u) {
        for (var h = 0, s = 0, l = 0, c = {}, f = 0; f < u.graphemeLines.length; f++)
          u.graphemeText[l] === `
` && f > 0 ? (s = 0, l++, h++) : !this.splitByGrapheme && this._reSpaceAndTab.test(u.graphemeText[l]) && f > 0 && (s++, l++), c[f] = { line: h, offset: s }, l += u.graphemeLines[f].length, s += u.graphemeLines[f].length;
        return c;
      },
      styleHas: function(u, h) {
        if (this._styleMap && !this.isWrapping) {
          var s = this._styleMap[h];
          s && (h = s.line);
        }
        return n.Text.prototype.styleHas.call(this, u, h);
      },
      isEmptyStyles: function(u) {
        if (!this.styles)
          return !0;
        var h = 0, s = u + 1, l, c, f = !1, m = this._styleMap[u], d = this._styleMap[u + 1];
        m && (u = m.line, h = m.offset), d && (s = d.line, f = s === u, l = d.offset), c = typeof u > "u" ? this.styles : { line: this.styles[u] };
        for (var v in c)
          for (var b in c[v])
            if (b >= h && (!f || b < l))
              for (var y in c[v][b])
                return !1;
        return !0;
      },
      _getStyleDeclaration: function(u, h) {
        if (this._styleMap && !this.isWrapping) {
          var s = this._styleMap[u];
          if (!s)
            return null;
          u = s.line, h = s.offset + h;
        }
        return this.callSuper("_getStyleDeclaration", u, h);
      },
      _setStyleDeclaration: function(u, h, s) {
        var l = this._styleMap[u];
        u = l.line, h = l.offset + h, this.styles[u][h] = s;
      },
      _deleteStyleDeclaration: function(u, h) {
        var s = this._styleMap[u];
        u = s.line, h = s.offset + h, delete this.styles[u][h];
      },
      _getLineStyle: function(u) {
        var h = this._styleMap[u];
        return !!this.styles[h.line];
      },
      _setLineStyle: function(u) {
        var h = this._styleMap[u];
        this.styles[h.line] = {};
      },
      _wrapText: function(u, h) {
        var s = [], l;
        for (this.isWrapping = !0, l = 0; l < u.length; l++)
          s = s.concat(this._wrapLine(u[l], l, h));
        return this.isWrapping = !1, s;
      },
      _measureWord: function(u, h, s) {
        var l = 0, c, f = !0;
        s = s || 0;
        for (var m = 0, d = u.length; m < d; m++) {
          var v = this._getGraphemeBox(u[m], h, m + s, c, f);
          l += v.kernedWidth, c = u[m];
        }
        return l;
      },
      _wrapLine: function(u, h, s, N) {
        var c = 0, f = this.splitByGrapheme, m = [], d = [], v = f ? n.util.string.graphemeSplit(u) : u.split(this._wordJoiners), b = "", y = 0, w = f ? "" : " ", _ = 0, S = 0, T = 0, A = !0, R = this._getWidthOfCharSpacing(), N = N || 0;
        v.length === 0 && v.push([]), s -= N;
        for (var U = 0; U < v.length; U++)
          b = f ? v[U] : n.util.string.graphemeSplit(v[U]), _ = this._measureWord(b, h, y), y += b.length, c += S + _ - R, c > s && !A ? (m.push(d), d = [], c = _, A = !0) : c += R, !A && !f && d.push(w), d = d.concat(b), S = f ? 0 : this._measureWord([w], h, y), y++, A = !1, _ > T && (T = _);
        return U && m.push(d), T + N > this.dynamicMinWidth && (this.dynamicMinWidth = T - R + N), m;
      },
      isEndOfWrapping: function(u) {
        return !this._styleMap[u + 1] || this._styleMap[u + 1].line !== this._styleMap[u].line;
      },
      missingNewlineOffset: function(u) {
        return this.splitByGrapheme ? this.isEndOfWrapping(u) ? 1 : 0 : 1;
      },
      _splitTextIntoLines: function(u) {
        for (var h = n.Text.prototype._splitTextIntoLines.call(this, u), s = this._wrapText(h.lines, this.width), l = new Array(s.length), c = 0; c < s.length; c++)
          l[c] = s[c].join("");
        return h.lines = l, h.graphemeLines = s, h;
      },
      getMinWidth: function() {
        return Math.max(this.minWidth, this.dynamicMinWidth);
      },
      _removeExtraneousStyles: function() {
        var u = {};
        for (var h in this._styleMap)
          this._textLines[h] && (u[this._styleMap[h].line] = 1);
        for (var h in this.styles)
          u[h] || delete this.styles[h];
      },
      toObject: function(u) {
        return this.callSuper("toObject", ["minWidth", "splitByGrapheme"].concat(u));
      }
    }), n.Textbox.fromObject = function(u, h) {
      var s = n.util.stylesFromArray(u.styles, u.text), l = Object.assign({}, u, { styles: s });
      return n.Object._fromObject("Textbox", l, h, "text");
    };
  }(t), function() {
    var a = e.controlsUtils, n = a.scaleSkewCursorStyleHandler, u = a.scaleCursorStyleHandler, h = a.scalingEqually, s = a.scalingYOrSkewingX, l = a.scalingXOrSkewingY, c = a.scaleOrSkewActionName, f = e.Object.prototype.controls;
    if (f.ml = new e.Control({
      x: -0.5,
      y: 0,
      cursorStyleHandler: n,
      actionHandler: l,
      getActionName: c
    }), f.mr = new e.Control({
      x: 0.5,
      y: 0,
      cursorStyleHandler: n,
      actionHandler: l,
      getActionName: c
    }), f.mb = new e.Control({
      x: 0,
      y: 0.5,
      cursorStyleHandler: n,
      actionHandler: s,
      getActionName: c
    }), f.mt = new e.Control({
      x: 0,
      y: -0.5,
      cursorStyleHandler: n,
      actionHandler: s,
      getActionName: c
    }), f.tl = new e.Control({
      x: -0.5,
      y: -0.5,
      cursorStyleHandler: u,
      actionHandler: h
    }), f.tr = new e.Control({
      x: 0.5,
      y: -0.5,
      cursorStyleHandler: u,
      actionHandler: h
    }), f.bl = new e.Control({
      x: -0.5,
      y: 0.5,
      cursorStyleHandler: u,
      actionHandler: h
    }), f.br = new e.Control({
      x: 0.5,
      y: 0.5,
      cursorStyleHandler: u,
      actionHandler: h
    }), f.mtr = new e.Control({
      x: 0,
      y: -0.5,
      actionHandler: a.rotationWithSnapping,
      cursorStyleHandler: a.rotationStyleHandler,
      offsetY: -40,
      withConnection: !0,
      actionName: "rotate"
    }), e.Textbox) {
      var m = e.Textbox.prototype.controls = {};
      m.mtr = f.mtr, m.tr = f.tr, m.br = f.br, m.tl = f.tl, m.bl = f.bl, m.mt = f.mt, m.mb = f.mb, m.mr = new e.Control({
        x: 0.5,
        y: 0,
        actionHandler: a.changeWidth,
        cursorStyleHandler: n,
        actionName: "resizing"
      }), m.ml = new e.Control({
        x: -0.5,
        y: 0,
        actionHandler: a.changeWidth,
        cursorStyleHandler: n,
        actionName: "resizing"
      });
    }
  }();
})(ve);
const np = {
  lockScalingFlip: !0,
  originY: "center",
  originX: "center",
  lockMovementX: !0,
  lockMovementY: !0,
  borderColor: "transparent"
};
function xl(t = 36) {
  let e = "";
  const r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  for (let i = 0; i < t; i += 1)
    e += r.charAt(Math.floor(Math.random() * r.length));
  return e;
}
function x_(t) {
  var g;
  const e = new ve.fabric.Canvas(t, { width: 1, height: 1 });
  e.preserveObjectStacking = !0, e.selection = !1, e.renderOnAddRemove = !1;
  const r = O().config.textureSize;
  r && (ve.fabric.textureSize = r);
  const o = {
    ...(g = O().config.objectDefaults) == null ? void 0 : g.global,
    ...np
  };
  Object.keys(o).forEach((a) => {
    ve.fabric.Object.prototype[a] = o[a];
  }), e.on("object:added", (a) => {
    var n, u;
    a.target && !((u = (n = a.target) == null ? void 0 : n.data) != null && u.id) && (a.target.data || (a.target.data = {}), a.target.data.id = xl(10));
  });
  const p = ve.fabric.Object.prototype.controls;
  return Object.keys(p).forEach((a) => {
    delete p[a];
  }), e;
}
let _l = null;
function di(t) {
  _l = t;
}
class __ {
  constructor() {
    Ce(this, "maxZoom", 2);
    Ce(this, "minZoom", 1);
    Ce(this, "step", 0.05);
    this.allowUserZoom && this.bindMouseWheel(), oe.subscribe(
      (e) => e.stageSize,
      () => {
        setTimeout(() => {
          this.fitToScreen();
        }, 1);
      }
    );
  }
  get allowUserZoom() {
    var e, r, i, o;
    return (o = (i = (r = (e = O().config) == null ? void 0 : e.tools) == null ? void 0 : r.zoom) == null ? void 0 : i.allowUserZoom) != null ? o : !0;
  }
  get currentZoom() {
    return O().zoom;
  }
  zoomIn(e = this.step) {
    this.set(this.currentZoom + e);
  }
  canZoomIn(e = this.step) {
    return this.currentZoom + e <= this.maxZoom;
  }
  canZoomOut(e = this.step) {
    return this.currentZoom - e >= this.minZoom;
  }
  zoomOut(e = this.step) {
    this.set(this.currentZoom - e);
  }
  set(e, r = !0) {
    if (e < this.minZoom || e > this.maxZoom)
      return;
    const i = Ts.round(O().original.width * e, 0), o = Ts.round(O().original.height * e, 0);
    he().setZoom(e), r && he().setDimensions({ width: i, height: o }), O().setZoom(e);
  }
  fitToScreen() {
    var p, g;
    if (!((g = (p = O().config.tools) == null ? void 0 : p.zoom) != null && g.fitImageToScreen))
      return;
    const { width: e, height: r } = O().stageSize, i = Math.max(r, 1), o = Math.max(e, 1);
    if (O().original.height > i || O().original.width > o) {
      const a = Math.min(
        i / O().original.height,
        o / O().original.width
      );
      this.minZoom = Math.min(a, 1);
    } else
      this.minZoom = 1;
    this.set(this.minZoom);
  }
  bindMouseWheel() {
    he().on("mouse:wheel", (e) => {
      e.e.preventDefault(), e.e.stopPropagation(), _l == null && (e.e.deltaY < 0 ? this.zoomIn() : this.zoomOut());
    });
  }
}
function op(t) {
  return new Promise((e) => {
    ve.fabric.util.loadImage(
      t,
      (r) => e(new ve.fabric.Image(r)),
      null,
      O().config.crossOrigin ? "anonymous" : void 0
    );
  });
}
class S_ {
  constructor() {
    Ce(this, "minWidth", 50);
    Ce(this, "minHeight", 50);
  }
  resize(e, r, {
    applyZoom: i = !1,
    resizeHelper: o = !0
  } = {}) {
    const p = O().zoom;
    he().setWidth(e * (i ? p : 1)), he().setHeight(r * (i ? p : 1)), O().setOriginal(e, r), o && I().transform.resetStraightenAnchor();
  }
  async addMainImage(e, r = "mainImage") {
    var o, p;
    O().toggleLoading(r);
    const i = await op(e);
    if (!!i)
      return this.clear(), i.set(Pr), i.name = Ne.MainImage, he().add(i), this.resize(i.width, i.height), i.center(), i.setCoords(), I().zoom.fitToScreen(), O().toggleLoading(!1), (p = (o = O().config).onMainImageLoaded) == null || p.call(o, i), i;
  }
  openNew(e, r, i) {
    return e = Math.max(this.minWidth, e), r = Math.max(this.minHeight, r), this.clear(), this.resize(e, r), he().backgroundColor = i, I().zoom.fitToScreen(), O().toggleLoading("newCanvas"), requestAnimationFrame(() => {
      O().toggleLoading(!1);
    }), Promise.resolve({ width: e, height: r });
  }
  getMainImage() {
    return he().getObjects().find((e) => e.name === Ne.MainImage);
  }
  render() {
    he().requestRenderAll();
  }
  async loadInitialContent() {
    var o, p;
    const e = O().config.image, r = O().config.blankCanvasSize, i = O().config.state;
    if (e && e.endsWith("json")) {
      const g = await Co(e);
      await I().import.loadState(g);
    } else
      e && e.startsWith('{"canvas') ? await I().import.loadState(e) : e ? await this.addMainImage(e) : i ? await I().import.loadState(i) : r && await this.openNew(r.width, r.height);
    return rl() && ((p = (o = O().config.ui) == null ? void 0 : o.openImageDialog) == null ? void 0 : p.show) && O().togglePanel("newImage", !0), new Promise((g) => {
      setTimeout(() => {
        I().history.addInitial(), g();
      }, 10);
    });
  }
  clear() {
    he().clear(), I().frame.remove(), I().transform.resetStraightenAnchor();
  }
}
function C_(t) {
  return t.name === Ne.Sticker && "forEachObject" in t;
}
const T_ = [
  "fontSize",
  "fontFamily",
  "left",
  "top",
  "width",
  "height",
  "scaleX",
  "scaleY",
  "flipX",
  "flipY",
  "angle",
  "src",
  "strokeWidth"
];
function sp(t = {}) {
  he().fire("object:modified", k_(t));
}
function k_(t) {
  return {
    values: t,
    sizeOrPositionChanged: E_(t)
  };
}
function E_(t) {
  return Object.keys(t).some(
    (e) => T_.includes(e)
  );
}
function O_() {
  O().fabric.on("selection:created", (t) => {
    var e;
    ((e = t.selected) == null ? void 0 : e[0]) && !fu(t) && gs(t.selected[0]);
  }), O().fabric.on("selection:updated", (t) => {
    var e;
    fu(t) || gs((e = t.selected) == null ? void 0 : e[0]);
  }), O().fabric.on("selection:cleared", () => {
    gs();
  });
}
function fu(t) {
  var i, o;
  const [e] = Lf((i = t.selected) == null ? void 0 : i[0]), r = e === O().activeTool;
  return O().dirty && (!((o = t.selected) != null && o[0]) || !r) ? (t.deselected && I().objects.select(t.deselected[0]), !0) : !1;
}
function gs(t) {
  (t == null ? void 0 : t.data.id) !== O().objects.active.id && (O().objects.setActive(t != null ? t : null), O().activeTool !== Pe.DRAW && tl());
}
class P_ {
  constructor() {
    this.syncObjects(), O_(), O().fabric.on("text:editing:entered", () => {
      O().objects.setIsEditingText(!0);
    }), O().fabric.on("text:editing:exited", () => {
      O().objects.setIsEditingText(!1);
    }), O().fabric.on("object:added", () => {
      this.syncObjects();
    }), O().fabric.on("object:removed", () => {
      this.syncObjects();
    });
  }
  getAll() {
    return he().getObjects().filter((e) => {
      var r;
      return !((r = e == null ? void 0 : e.data) != null && r.pixieInternal);
    });
  }
  get(e) {
    return this.getAll().find((r) => r.name === e);
  }
  getById(e) {
    return this.getAll().find((r) => r.data.id === e);
  }
  isActive(e) {
    var i;
    const r = typeof e == "string" ? e : e.data.id;
    return ((i = O().objects.active) == null ? void 0 : i.id) === r;
  }
  getActive() {
    return he().getActiveObject();
  }
  has(e) {
    return this.getAll().findIndex((r) => r.name === e) > -1;
  }
  select(e) {
    const r = typeof e == "string" ? this.getById(e) : e;
    !r || (he().setActiveObject(r), he().requestRenderAll());
  }
  deselectActive() {
    he().discardActiveObject(), he().requestRenderAll();
  }
  setValues(e, r) {
    if (r = r || this.getActive(), !r)
      return;
    let i = !1;
    C_(r) && e.fill !== r.fill && r.forEachObject((o) => o.set("fill", e.fill)), lr(r) ? ((e.fontFamily !== r.fontFamily || e.fontSize !== r.fontSize) && (i = !0), r.selectionStart !== r.selectionEnd ? r.setSelectionStyles(e) : r.set(e)) : r.set(e), i ? setTimeout(() => {
      he().requestRenderAll();
    }, 50) : he().requestRenderAll(), O().objects.setActive(r), sp(e);
  }
  move(e, r = 1, i) {
    i = i || this.getActive(), i && (e === "up" ? this.setValues({ top: i.top - r }) : e === "down" ? this.setValues({ top: i.top + r }) : e === "left" ? this.setValues({ left: i.left - r }) : e === "right" && this.setValues({ left: i.left + r }), I().canvas.render());
  }
  bringToFront(e) {
    e = e || this.getActive(), e && (e.bringToFront(), I().canvas.render());
  }
  sendToBack(e) {
    e = e || this.getActive(), e && (e.sendToBack(), I().canvas.render());
  }
  flipHorizontally(e) {
    e = e || this.getActive(), e && (this.setValues({ flipX: !e.flipX }), I().canvas.render());
  }
  duplicate(e) {
    const r = e || this.getActive();
    !r || (this.deselectActive(), r.clone((i) => {
      i.set({
        left: r.left + 40,
        top: r.top + 40,
        data: { ...r.data, id: xl(10) },
        name: r.name
      }), he().add(i), this.select(i), I().canvas.render();
    }));
  }
  delete(e) {
    e = e || this.getActive(), e && (this.deselectActive(), he().remove(e), he().requestRenderAll(), I().history.addHistoryItem({ name: "deletedObject" }));
  }
  syncObjects() {
    const e = this.getAll().map((r) => {
      var i;
      return {
        name: r.name,
        selectable: (i = r.selectable) != null ? i : !1,
        id: r.data.id
      };
    });
    oe.setState({
      objects: {
        ...O().objects,
        all: e
      }
    });
  }
}
const M_ = {
  frame: null,
  fonts: []
};
function du(t) {
  return t.state || (t.state = Zn()), {
    ...t.state || Zn(),
    name: t.name,
    id: xl(15)
  };
}
const ap = 15;
class A_ {
  constructor() {
    Ce(this, "minWidth", 250);
  }
  add(e, r = {}) {
    var p, g, a;
    if (e = e || ((g = (p = O().config.tools) == null ? void 0 : p.text) == null ? void 0 : g.defaultText), !e)
      return;
    const i = {
      ...(a = O().config.objectDefaults) == null ? void 0 : a.text,
      ...r,
      name: Ne.Text,
      padding: ap,
      editingBorderColor: Xa.fill
    }, o = new ve.fabric.IText(e, i);
    he().add(o), this.autoPositionText(o), I().objects.select(o);
  }
  autoPositionText(e) {
    const r = he().getWidth(), i = he().getHeight(), o = Math.min(he().getWidth(), this.minWidth);
    e.scaleToWidth(Math.max(r / 3, o)), e.getScaledHeight() > i && e.scaleToHeight(i - e.getScaledHeight() - 20), e.viewportCenter(), he().getObjects("i-text").forEach((p) => {
      if (p !== e && p.intersectsWithObject(e)) {
        const g = p.top - e.top + p.getScaledHeight();
        let a = e.top + g;
        a > O().original.height - p.getScaledHeight() && (a = 0), e.set("top", a), e.setCoords();
      }
    });
  }
  selectOrAddText(e, r = {}) {
    if (O().objects.active.isText)
      return !1;
    const i = I().objects.getAll().find((o) => lr(o));
    return i ? (I().objects.select(i), !1) : (this.add(e, r), !0);
  }
}
function lp(t, e) {
  const r = t.map(async (i) => {
    const o = Array.from(document.fonts.values()).find((g) => g.family === i.family);
    if (o)
      return o.loaded;
    const p = new FontFace(
      i.family,
      `url(${e ? e(i.src) : i.src})`,
      i.descriptors
    );
    return document.fonts.add(p), p.load();
  });
  return Promise.all(r);
}
function D_(t) {
  return t ? /^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(t) : !1;
}
function ct(t) {
  return t ? D_(t) ? t : `${O().config.baseUrl ? `${O().config.baseUrl}/` : ""}${t}` : "";
}
class I_ {
  async undo() {
    if (this.canUndo()) {
      const e = O().history.items[O().history.pointer - 1];
      await this.load(e);
    }
  }
  async redo() {
    if (this.canRedo()) {
      const e = O().history.items[O().history.pointer + 1];
      await this.load(e);
    }
  }
  canUndo() {
    return O().history.canUndo;
  }
  canRedo() {
    return O().history.canRedo;
  }
  reload() {
    return this.load(O().history.items[O().history.pointer]);
  }
  replaceCurrent() {
    const e = O().history.items[O().history.pointer], r = [...O().history.items];
    r[O().history.pointer] = du({
      name: e.name,
      state: e
    });
  }
  addHistoryItem(e) {
    const r = du(e), o = [...O().history.items.slice(
      0,
      O().history.pointer + 1
    ), r];
    O().history.update(o.length - 1, o);
  }
  load(e) {
    return e = { ...e, editor: e.editor || M_ }, new Promise((r) => {
      lp(R_(e.canvas.objects), ct).finally(() => {
        he().loadFromJSON(e.canvas, () => {
          I().zoom.set(1), e.canvasWidth && e.canvasHeight && I().canvas.resize(e.canvasWidth, e.canvasHeight, {
            resizeHelper: !1,
            applyZoom: !1
          }), I().frame.remove(), e.editor.frame && I().frame.add(
            e.editor.frame.name,
            e.editor.frame.sizePercent
          ), I().objects.syncObjects(), I().objects.getAll().forEach((i) => {
            if (!i.data.pixieInternal && i.originX === "left" && i.originY === "top") {
              const o = i.getPointByOrigin("center", "center");
              i.set("left", o.x), i.set("top", o.y);
            }
            i.set({ ...np }), i.type === "i-text" && (i.padding = ap);
          }), I().canvas.render(), he().calcOffset(), I().zoom.fitToScreen(), O().history.updatePointerById(e.id), I().transform.resetStraightenAnchor(), r();
        });
      });
    });
  }
  addInitial(e) {
    !O().history.items.find((i) => i.name === "initial") && (e || !rl()) && this.addHistoryItem({ name: "initial", state: e });
  }
}
function R_(t) {
  const e = [];
  return t.forEach((r) => {
    var o, p, g;
    if (!lr(r))
      return;
    const i = (g = (p = (o = O().config.tools) == null ? void 0 : o.text) == null ? void 0 : p.items) == null ? void 0 : g.find(
      (a) => a.family === r.fontFamily
    );
    i && e.push(i);
  }), e;
}
class L_ {
  canMerge() {
    return I().objects.getAll().filter((e) => e.name !== Ne.MainImage).length > 0;
  }
  async apply() {
    O().toggleLoading("merge");
    const e = I().export.getDataUrl();
    e && await I().canvas.addMainImage(e, "merge");
  }
}
const En = [
  { name: "grayscale" },
  { name: "blackWhite", fabricType: "blackwhite" },
  {
    name: "sharpen",
    uses: "Convolute",
    matrix: [0, -1, 0, -1, 5, -1, 0, -1, 0]
  },
  { name: "invert" },
  { name: "vintage" },
  { name: "polaroid" },
  { name: "kodachrome" },
  { name: "technicolor" },
  { name: "brownie" },
  { name: "sepia" },
  {
    name: "removeColor",
    fabricType: "removecolor",
    options: {
      distance: { type: "slider", current: 0.1, min: 0, max: 1, step: 0.01 },
      color: { current: "#fff", type: "colorPicker" }
    }
  },
  {
    name: "brightness",
    options: {
      brightness: { type: "slider", current: 0.1, min: -1, max: 1, step: 0.1 }
    }
  },
  {
    name: "gamma",
    options: {
      red: { type: "slider", current: 0.1, min: 0.2, max: 2.2, step: 3921e-6 },
      green: { type: "slider", current: 0.1, min: 0.2, max: 2.2, step: 3921e-6 },
      blue: { type: "slider", current: 0.1, min: 0.2, max: 2.2, step: 3921e-6 }
    },
    apply: (t) => {
      t.gamma = [t.red, t.green, t.blue];
    }
  },
  {
    name: "noise",
    options: {
      noise: { type: "slider", current: 40, min: 1, max: 600 }
    }
  },
  {
    name: "pixelate",
    options: {
      blocksize: { type: "slider", min: 1, max: 40, current: 6 }
    }
  },
  {
    name: "blur",
    uses: "Convolute",
    matrix: [1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9]
  },
  {
    name: "emboss",
    uses: "Convolute",
    matrix: [1, 1, 1, 1, 0.7, -1, -1, -1, -1]
  },
  {
    name: "blendColor",
    fabricType: "blendcolor",
    options: {
      alpha: { type: "slider", current: 0.5, min: 0.1, max: 1, step: 0.1 },
      mode: {
        current: "add",
        type: "select",
        available: [
          { key: "add" },
          { key: "multiply" },
          { key: "subtract" },
          { key: "diff" },
          { key: "screen" },
          { key: "lighten" },
          { key: "darken" }
        ]
      },
      color: { type: "colorPicker", current: "#FF4081" }
    }
  }
], F_ = {
  grayscale: ce("grayscale"),
  blackWhite: ce("Black & White"),
  sharpen: ce("Sharpen"),
  invert: ce("Invert"),
  vintage: ce("Vintage"),
  polaroid: ce("Polaroid"),
  kodachrome: ce("Kodachrome"),
  technicolor: ce("Technicolor"),
  brownie: ce("Brownie"),
  sepia: ce("Sepia"),
  removeColor: ce("Remove Color"),
  brightness: ce("Brightness"),
  gamma: ce("Gamma"),
  noise: ce("Noise"),
  pixelate: ce("Pixelate"),
  blur: ce("Blur"),
  emboss: ce("Emboss"),
  blendColor: ce("Blend Color")
}, ms = {
  distance: ce("distance"),
  color: ce("color"),
  brightness: ce("brightness"),
  red: ce("red"),
  green: ce("green"),
  blue: ce("blue"),
  noise: ce("noise"),
  blocksize: ce("blocksize"),
  mode: ce("mode"),
  alpha: ce("alpha")
};
function On(t) {
  return t && t.charAt(0).toUpperCase() + t.slice(1);
}
class z_ {
  constructor() {
    oe.subscribe(
      (e) => e.history.pointer,
      () => {
        this.syncState();
      }
    );
  }
  apply(e) {
    O().filter.select(e, this.hasOptions(e));
    const r = this.getByName(e);
    if (this.isApplied(r.name)) {
      this.remove(r.name);
      return;
    }
    const i = this.create(r);
    this.getImages().forEach((o) => {
      var p;
      (p = o.filters) == null || p.push(i), o.applyFilters();
    }), this.syncState(), I().canvas.render();
  }
  remove(e) {
    O().filter.deselect(e);
    const r = this.getByName(e);
    this.getImages().forEach((i) => {
      var p;
      const o = this.findFilterIndex(
        r.name,
        i.filters
      );
      (p = i.filters) == null || p.splice(o, 1), i.applyFilters();
    }), this.syncState(), I().canvas.render();
  }
  getAll() {
    return En;
  }
  getByName(e) {
    return En.find((r) => r.name === e);
  }
  isApplied(e) {
    const r = I().canvas.getMainImage();
    return r ? this.findFilterIndex(e, r.filters) > -1 : !1;
  }
  applyValue(e, r, i) {
    const o = this.getByName(e);
    this.getImages().forEach((p) => {
      const g = (p.filters || []).find(
        (a) => a.type.toLowerCase() === o.name.toLowerCase()
      );
      !g || (g[r] = i, o.apply && o.apply(g, r, i), p.applyFilters());
    }), I().canvas.render();
  }
  addCustom(e, r, i, o) {
    const p = ve.fabric.Image.filters;
    p[On(e)] = ve.fabric.util.createClass(
      p.BaseFilter,
      r
    ), p[On(e)].fromObject = p.BaseFilter.fromObject, En.push({
      name: e,
      options: i,
      initialConfig: o
    });
  }
  create(e) {
    const r = e.initialConfig || {};
    let i;
    return e.uses ? (r.matrix = e.matrix, i = new ve.fabric.Image.filters[On(e.uses)](r)) : (Object.entries(e.options || {}).forEach(([o, p]) => {
      r[o] = p.current;
    }), i = new ve.fabric.Image.filters[On(e.name)](r)), i.name = e.name, i;
  }
  hasOptions(e) {
    return !!this.getByName(e).options;
  }
  findFilterIndex(e, r) {
    if (!(r != null && r.length))
      return -1;
    const i = this.getByName(e);
    return r.findIndex((o) => this.configMatchesFabricFilter(i, o));
  }
  syncState() {
    var i;
    const e = [];
    (((i = this.getImages()[0]) == null ? void 0 : i.filters) || []).forEach((o) => {
      const p = this.getByFabricFilter(o);
      p && e.push(p.name);
    }), oe.setState({
      filter: {
        ...O().filter,
        applied: e
      }
    });
  }
  getByFabricFilter(e) {
    return En.find((r) => this.configMatchesFabricFilter(r, e));
  }
  configMatchesFabricFilter(e, r) {
    const i = r.type.toLowerCase().replace(" ", "");
    return i === e.fabricType || i === e.name ? !0 : i === "convolute" && this.matrixAreEqual(e.matrix, r.matrix);
  }
  matrixAreEqual(e, r) {
    if (!e || !r || e.length !== r.length)
      return !1;
    for (let i = e.length; i--; )
      if (e[i] !== r[i])
        return !1;
    return !0;
  }
  getImages() {
    return I().objects.getAll().filter((e) => e.name === Ne.Image || Ne.MainImage);
  }
}
function j_(t) {
  return t.width < pu(t.usePercentages) && (t.width = pu(t.usePercentages), t.maintainAspect && (t.height = oo(t.width, t.usePercentages))), t.width > gu(t.usePercentages) && (t.width = gu(t.usePercentages), t.maintainAspect && (t.height = oo(t.width, t.usePercentages))), t.height < mu(t.usePercentages) && (t.height = mu(t.usePercentages), t.maintainAspect && (t.width = ua(t.height, t.usePercentages))), t.height > vu(t.usePercentages) && (t.height = vu(t.usePercentages), t.maintainAspect && (t.width = ua(t.height, t.usePercentages))), t;
}
function pu(t) {
  var r, i;
  const e = ((i = (r = O().config.tools) == null ? void 0 : r.resize) == null ? void 0 : i.minWidth) || 50;
  return t ? Math.ceil(e * 100 / O().original.width) : e;
}
function gu(t) {
  var r, i;
  const e = ((i = (r = O().config.tools) == null ? void 0 : r.resize) == null ? void 0 : i.maxWidth) || 2400;
  return t ? Math.ceil(e * 100 / O().original.width) : e;
}
function mu(t) {
  var r, i;
  const e = ((i = (r = O().config.tools) == null ? void 0 : r.resize) == null ? void 0 : i.minHeight) || 50;
  return t ? Math.ceil(e * 100 / O().original.height) : e;
}
function vu(t) {
  var r, i;
  const e = ((i = (r = O().config.tools) == null ? void 0 : r.resize) == null ? void 0 : i.maxHeight) || 2400;
  return t ? Math.ceil(e * 100 / O().original.height) : e;
}
function ua(t, e) {
  if (e)
    return t;
  const r = O().original.height / t;
  return Math.floor(O().original.width / r);
}
function oo(t, e) {
  if (e)
    return t;
  const r = O().original.width / t;
  return Math.floor(O().original.height / r);
}
class B_ {
  apply(e) {
    const { width: r, height: i, usePercentages: o } = j_(e), p = Math.ceil(O().original.width), g = Math.ceil(O().original.height), a = Math.ceil(r), n = Math.ceil(i);
    let u, h;
    o ? (u = r / 100, h = i / 100) : (u = r / O().original.width, h = i / O().original.height), !(p === a && g === n) && this.resize(u, h);
  }
  resize(e, r) {
    I().zoom.set(1, !1);
    const i = Math.round(O().original.height * r), o = Math.round(O().original.width * e);
    I().canvas.resize(o, i, {
      applyZoom: !1,
      resizeHelper: !0
    }), I().objects.getAll().forEach((p) => {
      const g = p.scaleX || 1, a = p.scaleY || 1, n = p.left || 0, u = p.top || 0, h = g * e, s = a * r, l = n * e, c = u * r;
      p.scaleX = h, p.scaleY = s, p.left = l, p.top = c, p.setCoords();
    }), I().zoom.fitToScreen(), he().requestRenderAll();
  }
}
function N_(t, e) {
  e.innerZone !== null && (e = e, V_(t, e), $_(t, e), H_(t, e));
}
function V_(t, e) {
  e.innerZone.style.width = `${t.width}px`, e.innerZone.style.height = `${t.height}px`, e.innerZone.style.transform = `translate(${t.left}px, ${t.top}px)`;
}
function $_(t, e) {
  const r = O().canvasSize.width, i = O().canvasSize.height;
  e.maskTop.style.height = `${t.top}px`, e.maskTop.style.width = `${r}px`, e.maskLeft.style.top = `${t.top}px`, e.maskLeft.style.height = `${t.height}px`, e.maskLeft.style.width = `${t.left}px`;
  const o = t.left + t.width;
  e.maskRight.style.left = `${o}px`, e.maskRight.style.top = `${t.top}px`, e.maskRight.style.height = `${t.height}px`, e.maskRight.style.width = `${r - o}px`, e.maskBottom.style.height = `${i - (t.top + t.height)}px`, e.maskBottom.style.width = `${r}px`;
}
function H_(t, e) {
  const r = (t.width - 2) / 3;
  e.lineVer1.style.height = `${t.height}px`, e.lineVer1.style.transform = `translate(${r}px, 0)`, e.lineVer2.style.height = `${t.height}px`, e.lineVer2.style.transform = `translate(${r * 2}px, 0)`;
  const i = (t.height - 2) / 3;
  e.lineHor1.style.width = `${t.width}px`, e.lineHor1.style.transform = `translate(0, ${i}px)`, e.lineHor2.style.width = `${t.width}px`, e.lineHor2.style.transform = `translate(0, ${i * 2}px)`;
}
function Sl(t, e, r) {
  let i = e, o = r;
  return t && (r * t > e ? o = e / t : i = r * t), { width: Math.floor(i), height: Math.floor(o) };
}
function Cl(t) {
  if (!t)
    return null;
  const e = t.split(":");
  return parseInt(e[0]) / parseInt(e[1]);
}
function U_(t, e = null) {
  const r = {
    width: t.width,
    height: t.height,
    top: 0,
    left: 0,
    angle: 0
  };
  if (e) {
    const i = Sl(
      e,
      r.width,
      r.height
    );
    r.width = i.width, r.height = i.height;
  }
  return r.left = (t.width - r.width) / 2, r.top = (t.height - r.height) / 2, r;
}
class W_ {
  constructor() {
    Ce(this, "refs", null);
  }
  apply(e) {
    var o;
    const r = (o = I().frame.active.config) == null ? void 0 : o.name, i = I().frame.active.currentSizeInPercent;
    return I().frame.active.hide(), I().merge.apply().then(() => {
      I().canvas.resize(Math.round(e.width), Math.round(e.height), {
        applyZoom: !0,
        resizeHelper: !0
      });
      const p = I().canvas.getMainImage();
      p.cropX = Math.round(e.left), p.cropY = Math.round(e.top), p.width = Math.round(e.width), p.height = Math.round(e.height), p.viewportCenter(), r && I().frame.add(r, i), I().zoom.fitToScreen(), I().canvas.render();
    });
  }
  drawZone(e) {
    var r;
    (r = this.refs) != null && r.current && (O().crop.setCropzoneRect(e), N_(e, this.refs.current));
  }
  resetCropzone(e) {
    const r = O().canvasSize, i = Cl(e);
    if (!r)
      return;
    O().crop.setAspectRatio(e);
    const o = U_(r, i);
    this.drawZone(o);
  }
  registerRefs(e) {
    this.refs = e;
  }
}
class Y_ {
  getShapeByName(e) {
    var i, o;
    const r = (o = (i = O().config.tools) == null ? void 0 : i.shapes) == null ? void 0 : o.items;
    return (r == null ? void 0 : r.find((p) => p.name === e)) || null;
  }
  addBasicShape(e) {
    var n;
    const r = this.getShapeByName(e);
    if (!r)
      return null;
    const { width: i, height: o, ...p } = ((n = O().config.objectDefaults) == null ? void 0 : n.shape) || {}, g = {
      ...p,
      ...r.options
    };
    let a;
    if (r.name === "circle")
      a = new ve.fabric.Circle({
        ...g,
        radius: 100
      });
    else if (r.name === "ellipse")
      a = new ve.fabric.Ellipse({
        ...g,
        rx: 100,
        ry: 50
      });
    else if (r.type === "Path")
      a = new ve.fabric.Path(g.path, {
        displayName: r.name,
        ...g
      });
    else {
      const u = r.type;
      a = new ve.fabric[u]({
        ...g,
        width: 150,
        height: 150
      });
    }
    return this.addAndPositionShape(a, Ne.Shape, { width: i, height: o }), a;
  }
  addSticker(e, r) {
    var o, p, g;
    const i = (g = (p = (o = O().config.tools) == null ? void 0 : o.stickers) == null ? void 0 : p.items) == null ? void 0 : g.find(
      (a) => a.name === e
    );
    if (!i)
      return Promise.resolve();
    if (i.type === "svg") {
      const a = ha(i, r);
      return this.addSvgSticker(a);
    }
    return this.addRegularSticker(i, r);
  }
  addRegularSticker(e, r) {
    return new Promise((i) => {
      ve.fabric.util.loadImage(ha(e, r), (o) => {
        var u;
        const { width: p, height: g, ...a } = ((u = O().config.objectDefaults) == null ? void 0 : u.sticker) || {}, n = new ve.fabric.Image(o, a);
        this.addAndPositionShape(n, Ne.Sticker, { width: p, height: g }), i();
      });
    });
  }
  addSvgSticker(e, r = Ne.Sticker) {
    return new Promise((i) => {
      ve.fabric.loadSVGFromURL(e, (o, p) => {
        var h;
        const { width: g, height: a, ...n } = ((h = O().config.objectDefaults) == null ? void 0 : h.sticker) || {}, u = ve.fabric.util.groupSVGElements(o, p);
        u.set(n), this.addAndPositionShape(u, r, { width: g, height: a }), i();
      });
    });
  }
  addAndPositionShape(e, r, { width: i }) {
    e.name = r, e.scaleX = 1, e.scaleY = 1, he().add(e);
    const o = i || O().original.width * O().zoom / 4;
    e.scaleToWidth(Math.min(150, o)), e.viewportCenter(), e.setCoords(), I().canvas.render(), he().setActiveObject(e);
  }
}
function ha(t, e) {
  return ct(
    `images/stickers/${t.name}/${e}.${t.type}`
  );
}
class X_ {
  constructor(e) {
    Ce(this, "patternCache", []);
    this.activeFrame = e;
  }
  fillParts(e) {
    this.patternCache.forEach((r) => {
      this.fillPartWithPattern(r, e);
    });
  }
  fillPartWithPattern(e, r) {
    if (!this.activeFrame.parts)
      return;
    e.canvas = new ve.fabric.StaticCanvas(null), e.canvas.add(e.img);
    const i = new ve.fabric.Pattern({
      source: e.canvas.getElement(),
      repeat: r === "repeat" ? "repeat" : "no-repeat"
    });
    this.activeFrame.parts[e.name] && this.activeFrame.parts[e.name].set("fill", i);
  }
  scale(e) {
    if (!this.activeFrame.config || !this.patternCache)
      return;
    const r = this.activeFrame.config.mode;
    e /= he().getRetinaScaling(), this.patternCache.forEach((i) => {
      !this.activeFrame.parts || (i.name === "top" || i.name === "bottom" ? r === "stretch" ? (this.scalePatternToWidth(
        i.img,
        this.activeFrame.parts.top.getScaledWidth()
      ), this.scalePatternToHeight(i.img, e)) : i.img.scaleToHeight(e) : i.name === "left" || i.name === "right" ? r === "stretch" ? (this.scalePatternToWidth(i.img, e), this.scalePatternToHeight(
        i.img,
        this.activeFrame.parts.left.getScaledHeight()
      )) : i.img.scaleToWidth(e) : r === "stretch" ? (this.scalePatternToWidth(i.img, e), this.scalePatternToHeight(i.img, e)) : i.img.scaleToWidth(e), i.canvas.setDimensions({
        width: i.img.getScaledWidth(),
        height: i.img.getScaledHeight()
      }));
    }), I().canvas.render();
  }
  scalePatternToWidth(e, r) {
    if (!e.width)
      return;
    const i = e.getBoundingRect().width / e.getScaledWidth();
    e.set("scaleX", r / e.width / i), e.setCoords();
  }
  scalePatternToHeight(e, r) {
    if (!e.height)
      return;
    const i = e.getBoundingRect().height / e.getScaledHeight();
    e.set("scaleY", r / e.height / i), e.setCoords();
  }
  load(e) {
    const r = this.activeFrame.getPartNames().map((i) => new Promise((o) => {
      const p = {
        ...Pr,
        originX: "left",
        originY: "top"
      };
      O().config.crossOrigin && (p.crossOrigin = "anonymous"), ve.fabric.Image.fromURL(
        this.getPartUrl(e, i),
        (g) => {
          o({ name: i, img: g });
        },
        p
      );
    }));
    return Promise.all(r).then((i) => {
      this.patternCache = i, this.fillParts(e.mode);
    });
  }
  getPartUrl(e, r) {
    return ct(`images/frames/${e.name}/${r}.png`);
  }
}
class G_ {
  constructor(e, r) {
    this.activeFrame = e, this.patterns = r;
  }
  get defaultColor() {
    var e, r;
    return (r = (e = O().config.objectDefaults) == null ? void 0 : e.global) == null ? void 0 : r.fill;
  }
  build(e, r) {
    if (this.createParts(e), this.resize(r), this.activeFrame.config = e, e.mode === "basic") {
      I().canvas.render();
      return;
    }
    this.patterns.load(e).then(() => {
      this.patterns.scale(r), I().canvas.render();
    });
  }
  createParts(e) {
    const r = {};
    this.activeFrame.getPartNames().forEach((i) => {
      const o = e.mode === "basic" ? this.defaultColor : void 0;
      r[i] = new ve.fabric.Rect({
        ...Pr,
        fill: o,
        originX: "left",
        originY: "top",
        name: `frame.rect.${i}`,
        objectCaching: !1,
        data: { pixieInternal: !0 }
      }), he().add(r[i]);
    }), this.activeFrame.parts = r;
  }
  resize(e) {
    const r = O().original.width, i = O().original.height, o = this.activeFrame, p = e;
    !o.parts || (o.parts.topLeft.set({
      width: p,
      height: p
    }), o.parts.topRight.set({
      left: r - o.parts.topLeft.getScaledWidth(),
      width: p,
      height: p
    }), o.parts.top.set({
      left: o.parts.topLeft.getScaledWidth() - 1,
      width: r - o.parts.topLeft.getScaledWidth() - o.parts.topRight.getScaledWidth() + 3,
      height: p
    }), o.parts.bottomLeft.set({
      top: i - o.parts.topLeft.getScaledHeight(),
      width: p,
      height: p
    }), o.parts.left.set({
      top: o.parts.topLeft.getScaledHeight() - 1,
      width: p,
      height: i - o.parts.topLeft.getScaledHeight() - o.parts.bottomLeft.getScaledHeight() + 3
    }), o.parts.bottomRight.set({
      left: r - o.parts.bottomLeft.getScaledWidth(),
      top: i - o.parts.topRight.getScaledWidth(),
      width: p,
      height: p
    }), o.parts.bottom.set({
      left: o.parts.top.left,
      top: i - o.parts.top.getScaledHeight(),
      width: o.parts.top.getScaledWidth(),
      height: p
    }), o.parts.right.set({
      left: r - o.parts.left.getScaledWidth(),
      top: o.parts.left.top,
      width: o.parts.left.width,
      height: o.parts.left.getScaledHeight()
    }));
  }
}
class q_ {
  constructor() {
    Ce(this, "corners", [
      "topLeft",
      "topRight",
      "bottomLeft",
      "bottomRight"
    ]);
    Ce(this, "sides", ["top", "right", "bottom", "left"]);
    Ce(this, "parts", null);
    Ce(this, "config", null);
    Ce(this, "currentSizeInPercent", 100);
  }
  getPartNames() {
    return [...this.corners, ...this.sides];
  }
  hide() {
    !this.parts || (Object.values(this.parts).forEach((e) => e.set({ visible: !1 })), I().canvas.render());
  }
  show() {
    !this.parts || (Object.values(this.parts).forEach((e) => e.set({ visible: !0 })), I().canvas.render());
  }
  remove() {
    !this.parts || (this.config = null, Object.values(this.parts).forEach((e) => {
      he().remove(e);
    }), this.parts = null, I().canvas.render());
  }
  is(e) {
    return this.config ? this.config.name === e.name : !1;
  }
  changeColor(e) {
    var r;
    ((r = this.config) == null ? void 0 : r.mode) !== "basic" || !this.parts || (Object.values(this.parts).forEach((i) => {
      i.set("fill", e);
    }), I().canvas.render());
  }
  getMinSize() {
    var e, r;
    return (r = (e = this.config) == null ? void 0 : e.size.min) != null ? r : 1;
  }
  getMaxSize() {
    var e, r;
    return (r = (e = this.config) == null ? void 0 : e.size.max) != null ? r : 35;
  }
}
class K_ {
  constructor() {
    Ce(this, "patterns");
    Ce(this, "builder");
    Ce(this, "active");
    this.active = new q_(), this.patterns = new X_(this.active), this.builder = new G_(this.active, this.patterns), he().on("object:added", () => {
      Object.values(this.active.parts || []).forEach((e) => e.moveTo(98));
    });
  }
  add(e, r) {
    const i = this.getByName(e);
    if (!i || this.active.is(i))
      return;
    this.active.remove(), this.active.currentSizeInPercent = r != null ? r : i.size.default;
    const o = this.calcFrameSizeInPixels(this.active.currentSizeInPercent);
    this.builder.build(i, o), O().frame.select(i);
  }
  resize(e) {
    if (!this.active.parts || !this.active.config)
      return;
    e ? this.active.currentSizeInPercent = e : e = this.active.currentSizeInPercent;
    const r = this.calcFrameSizeInPixels(e);
    this.builder.resize(r), this.patterns.scale(r), I().canvas.render();
  }
  changeColor(e) {
    this.active.changeColor(e);
  }
  remove() {
    this.active.remove(), O().frame.deselect();
  }
  getByName(e) {
    var i, o;
    const r = (o = (i = O().config.tools) == null ? void 0 : i.frame) == null ? void 0 : o.items;
    if (r)
      return r.find((p) => p.name === e);
  }
  getActiveFrameConfig() {
    return this.active.config;
  }
  calcFrameSizeInPixels(e) {
    const r = Math.min(O().original.width, O().original.height);
    return Math.ceil(e / 100 * r);
  }
}
const Z_ = (t) => {
  const e = new ve.fabric.PatternBrush(t);
  return e.getPatternSrc = function() {
    const i = ve.fabric.document.createElement("canvas");
    i.width = 10, i.height = 10;
    const o = i.getContext("2d");
    return o.strokeStyle = this.color, o.lineWidth = 5, o.beginPath(), o.moveTo(0, 5), o.lineTo(10, 5), o.closePath(), o.stroke(), i;
  }, e;
}, J_ = (t) => {
  const e = new ve.fabric.PatternBrush(t);
  return e.getPatternSrc = function() {
    const i = document.createElement("canvas");
    i.width = 10, i.height = 10;
    const o = i.getContext("2d");
    return o.strokeStyle = this.color, o.lineWidth = 5, o.beginPath(), o.moveTo(5, 0), o.lineTo(5, 10), o.closePath(), o.stroke(), i;
  }, e;
}, Q_ = (t) => {
  const e = new ve.fabric.PatternBrush(t);
  return e.getPatternSrc = function() {
    const i = this.width / 2, o = 5, p = document.createElement("canvas"), g = new ve.fabric.Rect({
      width: i,
      height: i,
      angle: 45,
      fill: this.color
    }), a = g.getBoundingRect().width;
    p.width = a + o, p.height = a + o, g.set({ left: a / 2, top: a / 2 });
    const n = p.getContext("2d");
    return g.render(n), p;
  }, e;
}, eS = (t) => {
  const e = new ve.fabric.PatternBrush(t);
  return e.getPatternSrc = function() {
    const p = document.createElement("canvas");
    p.width = 10 + 2, p.height = 10 + 2;
    const g = p.getContext("2d");
    return g.fillStyle = this.color, g.fillRect(0, 0, 10, 10), p;
  }, e;
};
var _h, Sh;
class tS {
  constructor() {
    Ce(this, "customBrushes", {
      VLineBrush: Z_,
      HLineBrush: J_,
      DiamondBrush: Q_,
      SquareBrush: eS
    });
    Ce(this, "currentBrush", {
      type: "PencilBrush",
      color: (Sh = (_h = O().config.objectDefaults) == null ? void 0 : _h.global) == null ? void 0 : Sh.fill,
      width: ff[1]
    });
    Ce(this, "onPathCreated", (e) => {
      e.path.name = Ne.Drawing, e.path.set(rS()), O().setDirty(!0);
    });
  }
  enable() {
    he().on("path:created", this.onPathCreated), he().isDrawingMode = !0, this.setBrushType(this.currentBrush.type), this.setBrushSize(this.currentBrush.width);
  }
  disable() {
    he().off("path:created", this.onPathCreated), he().isDrawingMode = !1;
  }
  getBrushType() {
    return this.currentBrush.type;
  }
  setBrushType(e) {
    this.currentBrush.type = e, he().freeDrawingBrush = e in ve.fabric ? new ve.fabric[e](he()) : this.customBrushes[e](he()), this.applyBrushStyles();
  }
  applyBrushStyles() {
    Object.keys(this.currentBrush).forEach((r) => {
      he().freeDrawingBrush[r] = this.currentBrush[r];
    });
    const e = he().freeDrawingBrush;
    e.getPatternSrc && (e.source = e.getPatternSrc.call(e));
  }
  setBrushSize(e) {
    this.currentBrush.width = e, this.applyBrushStyles();
  }
  getBrushSize() {
    return this.currentBrush.width;
  }
  setBrushColor(e) {
    this.currentBrush.color = e, this.applyBrushStyles();
  }
  getBrushColor() {
    return this.currentBrush.color;
  }
}
function rS() {
  const t = { ...Pr };
  return delete t.strokeWidth, t;
}
function cp(t) {
  var r;
  return ((r = /(?:\.([^.]+))?$/.exec(t)) == null ? void 0 : r[1]) || "";
}
function iS(t) {
  const e = {
    md: "text/markdown",
    markdown: "text/markdown",
    mp4: "video/mp4",
    mp3: "audio/mp3",
    svg: "image/svg+xml",
    jpg: "image/jpeg",
    png: "image/png",
    gif: "image/gif",
    yaml: "text/yaml",
    yml: "text/yaml"
  }, r = t.name ? cp(t.name) : null;
  return t.type ? t.type : r && r in e ? e[r] : "application/octet-stream";
}
let nS = 0;
function oS() {
  return nS;
}
class qi {
  constructor(e, r) {
    Ce(this, "id");
    Ce(this, "fingerprint");
    Ce(this, "name");
    Ce(this, "relativePath", "");
    Ce(this, "size");
    Ce(this, "mime", "");
    Ce(this, "extension", "");
    Ce(this, "native");
    Ce(this, "lastModified");
    Ce(this, "cachedData");
    this.id = Ff(), this.name = e.name, this.size = e.size, this.mime = iS(e), this.lastModified = e.lastModified, this.extension = cp(e.name) || "bin", this.native = e, r = r || e.webkitRelativePath || "", r = r.replace(/^\/+/g, ""), r && r.split("/").length > 1 && (this.relativePath = r), this.fingerprint = sS({
      name: this.name,
      size: this.size,
      mime: this.mime,
      lastModified: this.lastModified
    });
  }
  get data() {
    return new Promise((e) => {
      this.cachedData && e(this.cachedData);
      const r = new FileReader();
      r.addEventListener("load", () => {
        this.cachedData = r.result, e(this.cachedData);
      }), this.extension === "json" ? r.readAsText(this.native) : r.readAsDataURL(this.native);
    });
  }
}
function sS({ name: t, mime: e, size: r, relativePath: i, lastModified: o }) {
  let p = "be";
  return typeof t == "string" && (p += `-${bu(t.toLowerCase())}`), e && (p += `-${e}`), typeof i == "string" && (p += `-${bu(i.toLowerCase())}`), r !== void 0 && (p += `-${r}`), o !== void 0 && (p += `-${o}`), p += `${oS()}`, `${p}-v1`;
}
function aS(t) {
  return t.charCodeAt(0).toString(32);
}
function bu(t) {
  let e = "";
  return t.replace(/[^A-Z0-9]/gi, (r) => (e += `-${aS(r)}`, "/")) + e;
}
function lS(t = {}) {
  var i;
  const e = document.querySelector("#hidden-file-upload-input");
  e && e.remove();
  const r = document.createElement("input");
  return r.type = "file", r.multiple = (i = t.multiple) != null ? i : !1, r.classList.add("hidden"), r.style.display = "none", r.style.visibility = "hidden", r.id = "hidden-file-upload-input", r.accept = cS(t), t.directory && (r.webkitdirectory = !0), document.body.appendChild(r), r;
}
function cS({
  extensions: t = [],
  types: e = []
}) {
  const r = [];
  return t != null && t.length && (t = t.map((i) => i.startsWith(".") ? i : `.${i}`), r.push(t.join(","))), e != null && e.length && r.push(e.join(",")), r.join(",");
}
function uS(t = {}) {
  return new Promise((e) => {
    const r = lS(t);
    r.onchange = (i) => {
      const o = i.target.files;
      if (!o)
        return e([]);
      const p = Array.from(o).filter((g) => g.name !== ".DS_Store").map((g) => new qi(g));
      e(p), r.remove();
    }, document.body.appendChild(r), r.click();
  });
}
async function hS(t, e = !0) {
  const r = await op(t);
  if (!!r)
    return new Promise((i) => {
      r.name = Ne.Image, r.opacity = 0;
      const o = O().original.width, p = O().original.height;
      if (e && (r.width >= o || r.height >= p)) {
        const g = o - 0.1 * o, a = p - 0.1 * p, n = 1 / Math.min(
          a / r.getScaledHeight(),
          g / r.getScaledWidth()
        );
        r.scaleX *= 1 / n, r.scaleY *= 1 / n;
      }
      O().fabric.add(r), O().fabric.setActiveObject(r), r.viewportCenter(), r.setCoords(), O().fabric.requestRenderAll(), I().zoom.fitToScreen(), r.animate("opacity", "1", {
        duration: 425,
        onChange: () => {
          O().fabric.requestRenderAll();
        },
        onComplete: () => {
          i(r);
        }
      });
    });
}
var Tl = /* @__PURE__ */ ((t) => (t.image = "image/*", t.audio = "audio/*", t.json = "application/json", t.video = "video/mp4,video/mpeg,video/x-m4v,video/*", t))(Tl || {});
function fS(t) {
  if (t == null || Number.isNaN(t))
    return "";
  const e = t < 0, r = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
  if (e && (t = -t), t < 1)
    return `${(e ? "-" : "") + t} B`;
  const i = Math.min(
    Math.floor(Math.log(t) / Math.log(1024)),
    r.length - 1
  );
  t = Number(t / Math.pow(1024, i));
  const o = r[i];
  return t >= 10 || t % 1 === 0 ? `${(e ? "-" : "") + t.toFixed(0)} ${o}` : `${(e ? "-" : "") + t.toFixed(1)} ${o}`;
}
function up(t, e) {
  this.text = t = t || "", this.hasWild = ~t.indexOf("*"), this.separator = e, this.parts = t.split(e);
}
up.prototype.match = function(t) {
  var e = !0, r = this.parts, i, o = r.length, p;
  if (typeof t == "string" || t instanceof String)
    if (!this.hasWild && this.text != t)
      e = !1;
    else {
      for (p = (t || "").split(this.separator), i = 0; e && i < o; i++)
        r[i] !== "*" && (i < p.length ? e = r[i] === p[i] : e = !1);
      e = e && p;
    }
  else if (typeof t.splice == "function")
    for (e = [], i = t.length; i--; )
      this.match(t[i]) && (e[e.length] = t[i]);
  else if (typeof t == "object") {
    e = {};
    for (var g in t)
      this.match(g) && (e[g] = t[g]);
  }
  return e;
};
var dS = function(t, e, r) {
  var i = new up(t, r || /[\/\.]/);
  return typeof e < "u" ? i.match(e) : i;
}, pS = dS, gS = /[\/\+\.]/, mS = function(t, e) {
  function r(i) {
    var o = pS(i, t, gS);
    return o && o.length >= 2;
  }
  return e ? r(e.split(";")[0]) : r;
};
function vS(t, e) {
  if (!e)
    return;
  const { maxFileSize: r, allowedFileTypes: i, blockedFileTypes: o } = e;
  if (r && t.size != null && t.size > r)
    return ce("`:file` exceeds maximum allowed size of :size", {
      values: { file: t.name, size: fS(r) }
    });
  if (i != null && i.length && !yu(t, i) || o != null && o.length && yu(t, o))
    return ce("This file type is not allowed");
}
function yu(t, e) {
  return e.some((r) => r.includes("/") ? t.mime ? mS(t.mime.replace(/;.*?$/, ""), r) : !1 : r.replace(".", "") && t.extension ? t.extension.toLowerCase() === r.toLowerCase() : !1);
}
function bS(t, e) {
  if (t == null)
    return 0;
  switch (e) {
    case "KB":
      return t * 1024;
    case "MB":
      return t * 1024 ** 2;
    case "GB":
      return t * 1024 ** 3;
    case "TB":
      return t * 1024 ** 4;
    case "PB":
      return t * 1024 ** 5;
    default:
      return t;
  }
}
class yS {
  async uploadAndAddImage() {
    const e = await this.openUploadWindow();
    await this.openUploadedFile(e);
  }
  async uploadAndReplaceMainImage() {
    const e = await this.openUploadWindow();
    e && await this.openBackgroundImage(e);
  }
  async uploadAndOpenStateFile() {
    const e = await this.openUploadWindow(xS);
    e && await this.loadState(await e.data);
  }
  async openUploadedFile(e) {
    var i, o, p;
    if (!e)
      return;
    const r = await e.data;
    switch (e.extension) {
      case "json":
        await this.loadState(r);
        break;
      case "svg":
        await I().shape.addSvgSticker(r, Ne.Image), I().history.addHistoryItem({ name: "overlayImage" });
        break;
      default:
        await hS(
          r,
          (p = (o = (i = O().config.tools) == null ? void 0 : i.import) == null ? void 0 : o.fitOverlayToScreen) != null ? p : !0
        ), I().history.addHistoryItem({ name: "overlayImage" });
    }
  }
  async loadState(e) {
    O().toggleLoading("state"), await Ws();
    let r;
    typeof e == "string" ? e.endsWith(".json") ? r = await Co(e) : r = JSON.parse(e) : r = e, await I().history.addInitial(r), await I().history.reload(), O().toggleLoading(!1);
  }
  async openUploadWindow(e) {
    var i, o;
    e = e || wS();
    const r = (await uS(e))[0];
    return this.fileIsValid(r) ? ((o = (i = O().config).onFileOpen) == null || o.call(i, r), r) : null;
  }
  async openBackgroundImage(e) {
    await Ws();
    let r;
    e instanceof HTMLImageElement ? r = e.src : e instanceof qi ? r = await e.data : r = e;
    const i = await I().canvas.addMainImage(r);
    return await I().history.addInitial(), i;
  }
  fileIsValid(e) {
    var p, g, a, n, u, h;
    const r = (a = (g = (p = O().config.tools) == null ? void 0 : p.import) == null ? void 0 : g.maxFileSize) != null ? a : bS(10, "MB"), i = [
      ...(h = (u = (n = O().config.tools) == null ? void 0 : n.import) == null ? void 0 : u.validImgExtensions) != null ? h : [],
      "json"
    ], o = vS(e, { maxFileSize: r, allowedFileTypes: i });
    return o ? (tn.danger(o), !1) : !0;
  }
}
function wS() {
  var e, r;
  const t = (r = (e = O().config.tools) == null ? void 0 : e.import) == null ? void 0 : r.validImgExtensions;
  return t ? { extensions: t } : { types: [Tl.image] };
}
const xS = {
  types: [".json", Tl.json]
};
class _S {
  constructor() {
    Ce(this, "watermark", null);
    Ce(this, "lineStyle", {
      stroke: "rgba(255,255,255,0.3)",
      strokeWidth: 5,
      strokeLineCap: "round",
      strokeLineJoin: "round"
    });
  }
  add(e) {
    this.createGroup(), this.addText(e), this.addLines(), he().add(this.watermark), I().canvas.render();
  }
  remove() {
    !this.watermark || (he().remove(this.watermark), this.watermark = null, I().canvas.render());
  }
  createGroup() {
    this.watermark = new ve.fabric.Group(void 0, {
      ...Pr,
      width: O().original.width,
      height: O().original.height,
      excludeFromExport: !0,
      top: 0,
      left: 0,
      originX: "left",
      originY: "top"
    });
  }
  addText(e) {
    var i;
    const r = new ve.fabric.Text(e, {
      fill: "rgba(255,255,255,0.3)",
      strokeWidth: 2,
      stroke: "rgba(255,255,255,0.4)",
      originX: "center",
      originY: "center",
      fontWeight: 600,
      fontSize: 150,
      fontFamily: "Courier New"
    });
    r.scaleToWidth(O().original.width / 2), (i = this.watermark) == null || i.add(r);
  }
  addLines() {
    var h;
    if (!this.watermark)
      return;
    const e = (h = this.watermark) == null ? void 0 : h.getObjects("text")[0], r = O().original.width / 2, i = O().original.height / 2, o = 100, p = e.width / 4, g = new ve.fabric.Line(void 0, this.lineStyle), a = new ve.fabric.Line(void 0, this.lineStyle), n = new ve.fabric.Line(void 0, this.lineStyle), u = new ve.fabric.Line(void 0, this.lineStyle);
    this.watermark.add(g, a, n, u), g.set({
      x1: p,
      y1: -o,
      x2: r,
      y2: -i
    }), a.set({
      x1: p,
      y1: o,
      x2: r,
      y2: i
    }), n.set({
      x1: -p,
      y1: -o,
      x2: -r,
      y2: -i
    }), u.set({
      x1: -p,
      y1: o,
      x2: -r,
      y2: i
    });
  }
}
var hp = { exports: {} };
(function(t, e) {
  (function(r, i) {
    i();
  })(Hr, function() {
    function r(u, h) {
      return typeof h > "u" ? h = { autoBom: !1 } : typeof h != "object" && (console.warn("Deprecated: Expected third argument to be a object"), h = { autoBom: !h }), h.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(u.type) ? new Blob(["\uFEFF", u], { type: u.type }) : u;
    }
    function i(u, h, s) {
      var l = new XMLHttpRequest();
      l.open("GET", u), l.responseType = "blob", l.onload = function() {
        n(l.response, h, s);
      }, l.onerror = function() {
        console.error("could not download file");
      }, l.send();
    }
    function o(u) {
      var h = new XMLHttpRequest();
      h.open("HEAD", u, !1);
      try {
        h.send();
      } catch {
      }
      return 200 <= h.status && 299 >= h.status;
    }
    function p(u) {
      try {
        u.dispatchEvent(new MouseEvent("click"));
      } catch {
        var h = document.createEvent("MouseEvents");
        h.initMouseEvent("click", !0, !0, window, 0, 0, 0, 80, 20, !1, !1, !1, !1, 0, null), u.dispatchEvent(h);
      }
    }
    var g = typeof window == "object" && window.window === window ? window : typeof self == "object" && self.self === self ? self : typeof Hr == "object" && Hr.global === Hr ? Hr : void 0, a = g.navigator && /Macintosh/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent) && !/Safari/.test(navigator.userAgent), n = g.saveAs || (typeof window != "object" || window !== g ? function() {
    } : "download" in HTMLAnchorElement.prototype && !a ? function(u, h, s) {
      var l = g.URL || g.webkitURL, c = document.createElement("a");
      h = h || u.name || "download", c.download = h, c.rel = "noopener", typeof u == "string" ? (c.href = u, c.origin === location.origin ? p(c) : o(c.href) ? i(u, h, s) : p(c, c.target = "_blank")) : (c.href = l.createObjectURL(u), setTimeout(function() {
        l.revokeObjectURL(c.href);
      }, 4e4), setTimeout(function() {
        p(c);
      }, 0));
    } : "msSaveOrOpenBlob" in navigator ? function(u, h, s) {
      if (h = h || u.name || "download", typeof u != "string")
        navigator.msSaveOrOpenBlob(r(u, s), h);
      else if (o(u))
        i(u, h, s);
      else {
        var l = document.createElement("a");
        l.href = u, l.target = "_blank", setTimeout(function() {
          p(l);
        });
      }
    } : function(u, h, s, l) {
      if (l = l || open("", "_blank"), l && (l.document.title = l.document.body.innerText = "downloading..."), typeof u == "string")
        return i(u, h, s);
      var c = u.type === "application/octet-stream", f = /constructor/i.test(g.HTMLElement) || g.safari, m = /CriOS\/[\d]+/.test(navigator.userAgent);
      if ((m || c && f || a) && typeof FileReader < "u") {
        var d = new FileReader();
        d.onloadend = function() {
          var y = d.result;
          y = m ? y : y.replace(/^data:[^;]*;/, "data:attachment/file;"), l ? l.location.href = y : location = y, l = null;
        }, d.readAsDataURL(u);
      } else {
        var v = g.URL || g.webkitURL, b = v.createObjectURL(u);
        l ? l.location = b : location.href = b, l = null, setTimeout(function() {
          v.revokeObjectURL(b);
        }, 4e4);
      }
    });
    g.saveAs = n.saveAs = n, t.exports = n;
  });
})(hp);
function SS(t, e, r) {
  e = e || "", r = r || 512;
  const i = atob(t), o = [];
  for (let p = 0; p < i.length; p += r) {
    const g = i.slice(p, p + r), a = new Array(g.length);
    for (let u = 0; u < g.length; u++)
      a[u] = g.charCodeAt(u);
    const n = new Uint8Array(a);
    o.push(n);
  }
  return new Blob(o, { type: e });
}
class CS {
  save(e, r, i) {
    var a, n, u;
    const o = (a = O().config.tools) == null ? void 0 : a.export;
    e = e || (o == null ? void 0 : o.defaultName), r = this.getFormat(r), i = this.getQuality(i);
    const p = `${e}.${r}`;
    this.applyWaterMark();
    const g = r === "json" ? this.getJsonState() : this.getDataUrl(r, i);
    if (I().watermark.remove(), !!g)
      if (O().config.saveUrl)
        fetch(O().config.saveUrl, {
          method: "POST",
          body: JSON.stringify({ data: g, filename: p, format: r })
        });
      else if (O().config.onSave)
        (u = (n = O().config).onSave) == null || u.call(n, g, p, r);
      else {
        const h = this.getCanvasBlob(r, g);
        hp.exports.saveAs(h, p);
      }
  }
  getDataUrl(e, r) {
    this.prepareCanvas();
    try {
      return e === "svg" ? he().toSVG() : he().toDataURL({
        format: this.getFormat(e),
        quality: this.getQuality(r),
        multiplier: Math.max(
          O().original.width / he().width,
          O().original.height / he().height
        )
      });
    } catch (i) {
      i.message.toLowerCase().includes("tainted") && tn.danger(ce("Could not export canvas with external image."));
    }
    return null;
  }
  getCanvasBlob(e, r) {
    if (e === "json")
      return new Blob([r], { type: "application/json" });
    if (e === "svg")
      return new Blob([r], { type: "image/svg+xml" });
    const i = `image/${e}`;
    return r = r.replace(/data:image\/([a-z]*)?;base64,/, ""), SS(r, i);
  }
  getJsonState() {
    return JSON.stringify(Zn());
  }
  prepareCanvas() {
    he().discardActiveObject();
  }
  applyWaterMark() {
    const e = O().config.watermarkText;
    e && I().watermark.add(e);
  }
  getFormat(e) {
    var i;
    const r = (i = O().config.tools) == null ? void 0 : i.export;
    return e = e || (r == null ? void 0 : r.defaultFormat) || "png", e === "jpg" && (e = "jpeg"), e;
  }
  getQuality(e) {
    var i;
    const r = (i = O().config.tools) == null ? void 0 : i.export;
    return e = e || (r == null ? void 0 : r.defaultQuality) || 0.8, e;
  }
}
class TS {
  constructor() {
    Ce(this, "previewRect", null);
  }
  async apply(e) {
    this.previewRect || this.showPreview(), this.updatePreview(e), he().remove(this.previewRect), he().clipPath = this.previewRect;
    const r = I().export.getDataUrl();
    r && I().canvas.clear(), this.hidePreview(), r && await I().canvas.addMainImage(r), he().clipPath = void 0;
  }
  getPreviewRadius() {
    var e;
    return ((e = this.previewRect) == null ? void 0 : e.rx) || 0;
  }
  updatePreview(e) {
    !this.previewRect || (this.previewRect.set({
      rx: e,
      ry: e
    }), I().canvas.render());
  }
  showPreview() {
    this.previewRect = new ve.fabric.Rect({
      width: O().original.width,
      height: O().original.height,
      rx: 50,
      ry: 50,
      objectCaching: !1,
      fill: "transparent",
      name: "round.rect",
      data: { pixieInternal: !0 },
      stroke: "rgba(255,255,255,0.8)",
      strokeWidth: 3,
      strokeDashArray: [4, 4],
      selectable: !1,
      evented: !1
    }), he().add(this.previewRect), this.previewRect.moveTo(99), this.previewRect.viewportCenter(), I().canvas.render();
  }
  hidePreview() {
    !this.previewRect || (he().remove(this.previewRect), I().canvas.render(), this.previewRect = null);
  }
}
class kS {
  get straightenAnchor() {
    return he().getObjects().find(
      (e) => e.name === Ne.StraightenAnchor
    );
  }
  rotateLeft() {
    this.rotateFixed(-90);
  }
  rotateRight() {
    this.rotateFixed(90);
  }
  straighten(e) {
    this.storeObjectsRelationToHelper(), I().objects.deselectActive();
    const r = (this.straightenAnchor.data.rotateAngle || 0) + e, i = this.getImageScale(r, this.straightenAnchor);
    this.straightenAnchor.angle = r, this.straightenAnchor.scaleX = i, this.straightenAnchor.scaleY = i, this.straightenAnchor.data.straightenAngle = e, this.transformObjectsBasedOnHelper();
  }
  flip(e) {
    const r = e === "horizontal" ? "flipY" : "flipX";
    I().objects.getAll().forEach((i) => {
      i[r] = !i[r];
    }), I().canvas.render();
  }
  rotateFixed(e) {
    I().zoom.set(1, !1), I().objects.deselectActive();
    const r = this.straightenAnchor.data.rotateAngle || 0;
    e = Math.round(e / 90) * 90;
    const i = r + (this.straightenAnchor.data.straightenAngle || 0) + e;
    I().canvas.resize(O().original.height, O().original.width, {
      applyZoom: !1,
      resizeHelper: !1
    }), this.storeObjectsRelationToHelper(), this.straightenAnchor.rotate(i), this.straightenAnchor.data.rotateAngle = r + e, this.straightenAnchor.center(), this.transformObjectsBasedOnHelper(), I().frame.resize(I().frame.active.currentSizeInPercent), requestAnimationFrame(() => {
      I().zoom.fitToScreen();
    });
  }
  getImageScale(e, r) {
    e = ve.fabric.util.degreesToRadians(e);
    const i = O().original.width, o = O().original.height, p = i / 2, g = o / 2, a = r.width / 2, n = r.height / 2, u = Math.sqrt(p ** 2 + g ** 2), h = Math.asin(g / u);
    let s = (e % (Math.PI * 2) + Math.PI * 4) % (Math.PI * 2);
    s > Math.PI && (s -= Math.PI), s > Math.PI / 2 && s <= Math.PI && (s = Math.PI / 2 - (s - Math.PI / 2));
    const l = Math.PI / 2 - h - Math.abs(s), c = Math.abs(h - Math.abs(s)), f = Math.cos(l) * u, m = Math.cos(c) * u;
    return Math.max(m / a, f / n);
  }
  storeObjectsRelationToHelper() {
    I().objects.getAll().forEach((e) => {
      if (e !== this.straightenAnchor) {
        const r = ve.fabric.util.multiplyTransformMatrices(
          ve.fabric.util.invertTransform(
            this.straightenAnchor.calcTransformMatrix()
          ),
          e.calcTransformMatrix()
        );
        e.data = { ...e.data, relationToCanvas: r };
      }
    });
  }
  transformObjectsBasedOnHelper() {
    I().objects.getAll().forEach((e) => {
      if (e.data.relationToCanvas) {
        const r = ve.fabric.util.multiplyTransformMatrices(
          this.straightenAnchor.calcTransformMatrix(),
          e.data.relationToCanvas
        ), i = ve.fabric.util.qrDecompose(r);
        e.set({ flipX: !1, flipY: !1 }), e.setPositionByOrigin(
          { x: i.translateX, y: i.translateY },
          "center",
          "center"
        ), e.set(i), e.setCoords(), e.data.relationToCanvas = null;
      }
    });
  }
  resetStraightenAnchor() {
    const e = this.straightenAnchor;
    e && he().remove(e);
    const r = new ve.fabric.Rect({
      ...Pr,
      name: Ne.StraightenAnchor,
      visible: !1,
      width: O().original.width,
      height: O().original.height,
      data: {
        pixieInternal: !0,
        straightenAngle: 0,
        rotateAngle: 0
      }
    });
    he().add(r), r.viewportCenter();
  }
}
function ES(t) {
  const e = x_(t);
  O().editor.fabric = e, oe.setState({ fabric: e }), O().editor.tools = {
    canvas: new S_(),
    objects: new P_(),
    zoom: new __(),
    history: new I_(),
    filter: new z_(),
    resize: new B_(),
    crop: new W_(),
    merge: new L_(),
    shape: new Y_(),
    frame: new K_(),
    text: new A_(),
    draw: new tS(),
    transform: new kS(),
    import: new yS(),
    watermark: new _S(),
    export: new CS(),
    corners: new TS()
  };
}
function wu(t, e) {
  const r = new ResizeObserver((i) => {
    const o = i[0].contentRect;
    e({ width: o.width, height: o.height });
  });
  return t.current && r.observe(t.current), () => {
    t.current && r.unobserve(t.current);
  };
}
function xu(t) {
  const e = t.getBoundingClientRect();
  return {
    top: e.top,
    right: e.right,
    bottom: e.bottom,
    left: e.left,
    width: e.width,
    height: e.height
  };
}
const fp = "flex flex-shrink-0 items-center justify-between px-12 py-[9px] w-full h-[54px]", dp = {
  initial: {
    opacity: 0
  },
  animate: {
    opacity: 1
  },
  exit: {
    opacity: 0,
    position: "absolute"
  },
  transition: {
    type: "tween",
    duration: 0.15
  }
};
function kl(t, { padding: e, equalWidth: r, variant: i } = {}) {
  switch (t) {
    case "xs":
      return i === "link" ? "text-xs" : `text-xs h-30 ${r ? "w-30" : e || "px-14"}`;
    case "sm":
      return i === "link" ? "text-sm" : `text-sm h-36 ${r ? "w-36" : e || "px-18"}`;
    case "md":
      return i === "link" ? "text-base" : `text-base h-42 ${r ? "w-42" : e || "px-22"}`;
    case "lg":
      return i === "link" ? "text-lg" : `text-base h-50 ${r ? "w-50" : e || "px-26"}`;
    case "xl":
      return i === "link" ? "text-xl" : `text-lg h-60 ${r ? "w-60" : e || "px-32"}`;
    default:
      return t || "";
  }
}
function OS(t) {
  switch (t) {
    case "xs":
      return "icon-xs";
    case "sm":
      return "icon-sm";
    case "md":
      return "icon-sm";
    case "lg":
      return "icon-lg";
    case "xl":
      return "icon-xl";
    default:
      return "";
  }
}
function PS(t) {
  const { variant: e } = t, r = { ...t, border: t.border || "border" };
  let i = [];
  return e === "outline" ? i = MS(r) : e === "text" ? i = AS(r) : e === "flat" || e === "raised" ? i = IS(r) : e === "link" && (i = DS(r)), [
    ...i,
    e === "raised" && "shadow-md",
    e && "align-middle whitespace-nowrap inline-flex items-center transition-button duration-200",
    "select-none appearance-none no-underline outline-none disabled:pointer-events-none disabled:cursor-default"
  ];
}
function MS({ color: t, border: e }) {
  const r = "disabled:text-disabled disabled:bg-transparent disabled:border-disabled-bg";
  switch (t) {
    case "primary":
      return [
        `text-primary bg-transparent ${e} border-primary/50`,
        "hover:bg-primary/hover hover:border-primary",
        r
      ];
    case "danger":
      return [
        `text-danger bg-transparent ${e} border-danger/50`,
        "hover:bg-danger/4 hover:border-danger",
        r
      ];
    case "paper":
      return [`text bg-paper ${e}`, "hover:bg-hover", r];
    default:
      return [`bg-transparent ${e}`, "hover:bg-hover", r];
  }
}
function AS({ color: t }) {
  const e = "disabled:text-disabled disabled:bg-transparent";
  switch (t) {
    case "primary":
      return [
        "text-primary bg-transparent border-transparent",
        "hover:bg-primary/4",
        e
      ];
    case "danger":
      return [
        "text-danger bg-transparent border-transparent",
        "hover:bg-danger/4",
        e
      ];
    default:
      return ["bg-transparent border-transparent", "hover:bg-hover", e];
  }
}
function DS({ color: t }) {
  switch (t) {
    case "primary":
      return ["text-primary", "hover:underline", "disabled:text-disabled"];
    case "danger":
      return ["text-danger", "hover:underline", "disabled:text-disabled"];
    default:
      return ["text-main", "hover:underline", "disabled:text-disabled"];
  }
}
function IS({ color: t, border: e }) {
  const r = "disabled:text-disabled disabled:bg-disabled disabled:border-transparent disabled:shadow-none";
  switch (t) {
    case "primary":
      return [
        `text-on-primary bg-primary ${e} border-primary`,
        "hover:bg-primary-dark hover:border-primary-dark",
        r
      ];
    case "danger":
      return [
        `text-white bg-danger ${e} border-danger`,
        "hover:bg-danger/90 hover:border-danger/90",
        r
      ];
    case "chip":
      return [
        `text-main bg-chip ${e} border-chip`,
        "hover:bg-chip/90 hover:border-chip/90",
        r
      ];
    case "paper":
      return [
        `text-main bg-paper ${e} border-paper`,
        "hover:bg-paper/90 hover:bg-paper-90",
        r
      ];
    default:
      return [`bg ${e} border-background`, "hover:bg-hover", r];
  }
}
function Mt(t) {
  if (!!t)
    return (e) => {
      e.currentTarget.contains(e.target) && t(e);
    };
}
const Bt = et((t, e) => {
  const {
    children: r,
    color: i = null,
    variant: o,
    radius: p,
    justify: g = "justify-center",
    className: a,
    href: n,
    form: u,
    border: h,
    elementType: s,
    to: l,
    replace: c,
    end: f,
    type: m = "button",
    onClick: d,
    onPointerDown: v,
    onPointerUp: b,
    onKeyDown: y,
    ...w
  } = t, _ = s || (n ? "a" : "button"), S = _ === "a";
  return /* @__PURE__ */ x(_, {
    ref: e,
    form: S ? void 0 : u,
    href: n,
    to: l,
    type: S ? void 0 : m,
    replace: c,
    end: f,
    onPointerDown: Mt(v),
    onPointerUp: Mt(b),
    onClick: Mt(d),
    onKeyDown: Mt(y),
    className: ue("focus-visible:ring", PS({
      variant: o,
      color: i,
      border: h
    }), p, g, a),
    ...w,
    children: r
  });
}), Qe = ae.forwardRef(({
  children: t,
  startIcon: e,
  endIcon: r,
  size: i = "sm",
  className: o,
  equalWidth: p = !1,
  radius: g = "rounded",
  variant: a = "text",
  ...n
}, u) => {
  const h = ue("font-semibold", kl(i, {
    equalWidth: p,
    variant: a
  }), o);
  return /* @__PURE__ */ ie(Bt, {
    className: h,
    ref: u,
    radius: g,
    variant: a,
    ...n,
    children: [e && /* @__PURE__ */ x(_u, {
      position: "start",
      icon: e,
      size: i
    }), t, r && /* @__PURE__ */ x(_u, {
      position: "end",
      icon: r,
      size: i
    })]
  });
});
function _u({
  icon: t,
  position: e,
  size: r
}) {
  const i = ue("m-auto", {
    "-ml-4 mr-8": e === "start",
    "-mr-4 ml-8": e === "end"
  }, t.props.className);
  return ae.cloneElement(t, {
    className: i,
    size: r
  });
}
var pp = { exports: {} };
(function(t) {
  (function() {
    var e = Object.assign;
    typeof e != "function" && (e = function() {
      var o = arguments, p = arguments[0];
      if (p == null)
        throw new TypeError("Cannot convert undefined or null to object");
      p = Object(p);
      for (var g = 1; g < o.length; g++)
        if (o[g] && typeof o[g] == "object")
          for (var a in o[g])
            p[a] = o[g][a];
      return p;
    });
    function r(o) {
      var p = o + "", g = p.indexOf("...");
      return g >= 0 && (g < p.indexOf(")") || p.indexOf("arguments") >= 0);
    }
    function i(o, p) {
      p || (p = {});
      var g = p.vargs || r(o), a = /* @__PURE__ */ Object.create(null), n = [], u = [], h = /* @__PURE__ */ new WeakMap(), s = function(b, y, w) {
        return setTimeout(function() {
          if (w) {
            y.splice(b, 1), w.splice(b, 1);
            return;
          }
          y instanceof WeakMap ? y.delete(b) : delete y[b];
        }, p.maxAge);
      }, l = p.maxAge > 0 && p.maxAge < 1 / 0 ? s : 0, c = p.equals ? p.equals : function(b, y) {
        return b === y;
      }, f = p.maxArgs, m = p.serializer, d, v;
      return o.length === 1 && !p.equals && !g ? (d = function(b) {
        var y = typeof b;
        if (!m && (y === "object" && b || y === "function")) {
          var w;
          return h.get(b) || (!l || l(b, h), h.set(b, w = o.call(this, b)), w);
        }
        var _ = y === "number" || y === "boolean" || b == null ? b : y === "string" ? JSON.stringify(b) : m(b);
        return a[_] || (!l || l(_, a), a[_] = o.call(this, b));
      }.bind(this), v = 1) : d = function() {
        var b = f || arguments.length, y;
        for (y = n.length - 1; y >= 0; y--)
          if (!(!f && n[y].length !== b)) {
            for (var w = b - 1; w >= 0 && c(n[y][w], arguments[w]); w--)
              if (w === 0)
                return u[y];
          }
        return y = n.length - (y + 1), !l || l(y, u, n), u[y] = o.apply(this, n[y] = arguments);
      }.bind(this), d.clear = function() {
        h = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ Object.create(null), n = [], u = [];
      }, d.keys = function() {
        return v ? null : n.slice();
      }, d.values = function() {
        return v ? null : u.slice();
      }, d.keyValues = function() {
        return v ? { primitives: e({}, a), objects: h } : null;
      }, d;
    }
    t.exports = i, typeof window < "u" && (window.nanomemoize = i);
  }).call(Hr);
})(pp);
const ln = pp.exports;
function RS({
  children: t,
  label: e,
  index: r
}) {
  const i = yt();
  return /* @__PURE__ */ ie("div", {
    role: "group",
    className: ue(r !== 0 && "border-t my-4"),
    "aria-labelledby": e ? `be-select-${i}` : void 0,
    children: [e && /* @__PURE__ */ x("div", {
      className: "block uppercase text-muted text-xs px-16 py-10",
      role: "presentation",
      id: `be-select-${i}`,
      "aria-hidden": "true",
      children: e
    }), t]
  });
}
const LS = ln(
  ({ maxItems: t, children: e, items: r, inputValue: i }) => {
    let o = zS({ children: e, items: r }), p = FS({ collection: o, inputValue: i });
    return t && (o = new Map([...o.entries()].slice(0, t)), p = new Map(
      [...p.entries()].slice(0, t)
    )), { collection: o, filteredCollection: p };
  }
), FS = ln(
  ({ collection: t, inputValue: e }) => {
    let r = /* @__PURE__ */ new Map();
    const i = e ? `${e}`.toLowerCase().trim() : "";
    if (!i)
      r = t;
    else {
      let o = 0;
      t.forEach((p, g) => {
        (p.item ? JSON.stringify(p.item) : p.textLabel).toLowerCase().trim().includes(i) && r.set(g, { ...p, index: o++ });
      });
    }
    return r;
  }
), zS = ln(
  ({ children: t, items: e }) => {
    let r;
    e && typeof t == "function" ? r = e.map((g) => t(g)) : r = t;
    const i = /* @__PURE__ */ new Map();
    let o = 0;
    const p = (g, a, n, u) => {
      const h = o++, s = a ? e == null ? void 0 : e[n].items[u] : e == null ? void 0 : e[h];
      i.set(g.props.value, {
        index: h,
        element: g,
        textLabel: jS(g),
        item: s,
        section: a,
        isDisabled: g.props.isDisabled,
        value: g.props.value
      });
    };
    return Sr.forEach(r, (g, a) => {
      !tr(g) || (g.type === RS ? Sr.forEach(
        g.props.children,
        (n, u) => {
          p(n, g, a, u);
        }
      ) : p(g));
    }), i;
  }
);
function jS(t) {
  var r;
  const e = t.props.children;
  return t.props.textLabel ? t.props.textLabel : e && ((r = e.props) == null ? void 0 : r.defaultMessage) ? e.props.defaultMessage[0].value : `${e}` || "";
}
function bi(t) {
  return t.split("-")[0];
}
function cn(t) {
  return t.split("-")[1];
}
function un(t) {
  return ["top", "bottom"].includes(bi(t)) ? "x" : "y";
}
function El(t) {
  return t === "y" ? "height" : "width";
}
function Su(t, e, r) {
  let {
    reference: i,
    floating: o
  } = t;
  const p = i.x + i.width / 2 - o.width / 2, g = i.y + i.height / 2 - o.height / 2, a = un(e), n = El(a), u = i[n] / 2 - o[n] / 2, h = bi(e), s = a === "x";
  let l;
  switch (h) {
    case "top":
      l = {
        x: p,
        y: i.y - o.height
      };
      break;
    case "bottom":
      l = {
        x: p,
        y: i.y + i.height
      };
      break;
    case "right":
      l = {
        x: i.x + i.width,
        y: g
      };
      break;
    case "left":
      l = {
        x: i.x - o.width,
        y: g
      };
      break;
    default:
      l = {
        x: i.x,
        y: i.y
      };
  }
  switch (cn(e)) {
    case "start":
      l[a] -= u * (r && s ? -1 : 1);
      break;
    case "end":
      l[a] += u * (r && s ? -1 : 1);
      break;
  }
  return l;
}
const BS = async (t, e, r) => {
  const {
    placement: i = "bottom",
    strategy: o = "absolute",
    middleware: p = [],
    platform: g
  } = r, a = await (g.isRTL == null ? void 0 : g.isRTL(e));
  let n = await g.getElementRects({
    reference: t,
    floating: e,
    strategy: o
  }), {
    x: u,
    y: h
  } = Su(n, i, a), s = i, l = {}, c = 0;
  for (let f = 0; f < p.length; f++) {
    const {
      name: m,
      fn: d
    } = p[f], {
      x: v,
      y: b,
      data: y,
      reset: w
    } = await d({
      x: u,
      y: h,
      initialPlacement: i,
      placement: s,
      strategy: o,
      middlewareData: l,
      rects: n,
      platform: g,
      elements: {
        reference: t,
        floating: e
      }
    });
    if (u = v != null ? v : u, h = b != null ? b : h, l = {
      ...l,
      [m]: {
        ...l[m],
        ...y
      }
    }, w && c <= 50) {
      c++, typeof w == "object" && (w.placement && (s = w.placement), w.rects && (n = w.rects === !0 ? await g.getElementRects({
        reference: t,
        floating: e,
        strategy: o
      }) : w.rects), {
        x: u,
        y: h
      } = Su(n, s, a)), f = -1;
      continue;
    }
  }
  return {
    x: u,
    y: h,
    placement: s,
    strategy: o,
    middlewareData: l
  };
};
function NS(t) {
  return {
    top: 0,
    right: 0,
    bottom: 0,
    left: 0,
    ...t
  };
}
function gp(t) {
  return typeof t != "number" ? NS(t) : {
    top: t,
    right: t,
    bottom: t,
    left: t
  };
}
function so(t) {
  return {
    ...t,
    top: t.y,
    left: t.x,
    right: t.x + t.width,
    bottom: t.y + t.height
  };
}
async function Ol(t, e) {
  var r;
  e === void 0 && (e = {});
  const {
    x: i,
    y: o,
    platform: p,
    rects: g,
    elements: a,
    strategy: n
  } = t, {
    boundary: u = "clippingAncestors",
    rootBoundary: h = "viewport",
    elementContext: s = "floating",
    altBoundary: l = !1,
    padding: c = 0
  } = e, f = gp(c), d = a[l ? s === "floating" ? "reference" : "floating" : s], v = so(await p.getClippingRect({
    element: (r = await (p.isElement == null ? void 0 : p.isElement(d))) == null || r ? d : d.contextElement || await (p.getDocumentElement == null ? void 0 : p.getDocumentElement(a.floating)),
    boundary: u,
    rootBoundary: h,
    strategy: n
  })), b = so(p.convertOffsetParentRelativeRectToViewportRelativeRect ? await p.convertOffsetParentRelativeRectToViewportRelativeRect({
    rect: s === "floating" ? {
      ...g.floating,
      x: i,
      y: o
    } : g.reference,
    offsetParent: await (p.getOffsetParent == null ? void 0 : p.getOffsetParent(a.floating)),
    strategy: n
  }) : g[s]);
  return {
    top: v.top - b.top + f.top,
    bottom: b.bottom - v.bottom + f.bottom,
    left: v.left - b.left + f.left,
    right: b.right - v.right + f.right
  };
}
const VS = Math.min, yr = Math.max;
function fa(t, e, r) {
  return yr(t, VS(e, r));
}
const Cu = (t) => ({
  name: "arrow",
  options: t,
  async fn(e) {
    const {
      element: r,
      padding: i = 0
    } = t != null ? t : {}, {
      x: o,
      y: p,
      placement: g,
      rects: a,
      platform: n
    } = e;
    if (r == null)
      return {};
    const u = gp(i), h = {
      x: o,
      y: p
    }, s = un(g), l = cn(g), c = El(s), f = await n.getDimensions(r), m = s === "y" ? "top" : "left", d = s === "y" ? "bottom" : "right", v = a.reference[c] + a.reference[s] - h[s] - a.floating[c], b = h[s] - a.reference[s], y = await (n.getOffsetParent == null ? void 0 : n.getOffsetParent(r));
    let w = y ? s === "y" ? y.clientHeight || 0 : y.clientWidth || 0 : 0;
    w === 0 && (w = a.floating[c]);
    const _ = v / 2 - b / 2, S = u[m], T = w - f[c] - u[d], A = w / 2 - f[c] / 2 + _, R = fa(S, A, T), Q = (l === "start" ? u[m] : u[d]) > 0 && A !== R && a.reference[c] <= a.floating[c] ? A < S ? S - A : T - A : 0;
    return {
      [s]: h[s] - Q,
      data: {
        [s]: R,
        centerOffset: A - R
      }
    };
  }
}), $S = {
  left: "right",
  right: "left",
  bottom: "top",
  top: "bottom"
};
function ao(t) {
  return t.replace(/left|right|bottom|top/g, (e) => $S[e]);
}
function HS(t, e, r) {
  r === void 0 && (r = !1);
  const i = cn(t), o = un(t), p = El(o);
  let g = o === "x" ? i === (r ? "end" : "start") ? "right" : "left" : i === "start" ? "bottom" : "top";
  return e.reference[p] > e.floating[p] && (g = ao(g)), {
    main: g,
    cross: ao(g)
  };
}
const US = {
  start: "end",
  end: "start"
};
function Tu(t) {
  return t.replace(/start|end/g, (e) => US[e]);
}
function WS(t) {
  const e = ao(t);
  return [Tu(t), e, Tu(e)];
}
const YS = function(t) {
  return t === void 0 && (t = {}), {
    name: "flip",
    options: t,
    async fn(e) {
      var r;
      const {
        placement: i,
        middlewareData: o,
        rects: p,
        initialPlacement: g,
        platform: a,
        elements: n
      } = e, {
        mainAxis: u = !0,
        crossAxis: h = !0,
        fallbackPlacements: s,
        fallbackStrategy: l = "bestFit",
        flipAlignment: c = !0,
        ...f
      } = t, m = bi(i), v = s || (m === g || !c ? [ao(g)] : WS(g)), b = [g, ...v], y = await Ol(e, f), w = [];
      let _ = ((r = o.flip) == null ? void 0 : r.overflows) || [];
      if (u && w.push(y[m]), h) {
        const {
          main: R,
          cross: N
        } = HS(i, p, await (a.isRTL == null ? void 0 : a.isRTL(n.floating)));
        w.push(y[R], y[N]);
      }
      if (_ = [..._, {
        placement: i,
        overflows: w
      }], !w.every((R) => R <= 0)) {
        var S, T;
        const R = ((S = (T = o.flip) == null ? void 0 : T.index) != null ? S : 0) + 1, N = b[R];
        if (N)
          return {
            data: {
              index: R,
              overflows: _
            },
            reset: {
              placement: N
            }
          };
        let U = "bottom";
        switch (l) {
          case "bestFit": {
            var A;
            const Q = (A = _.map((ee) => [ee, ee.overflows.filter((J) => J > 0).reduce((J, q) => J + q, 0)]).sort((ee, J) => ee[1] - J[1])[0]) == null ? void 0 : A[0].placement;
            Q && (U = Q);
            break;
          }
          case "initialPlacement":
            U = g;
            break;
        }
        if (i !== U)
          return {
            reset: {
              placement: U
            }
          };
      }
      return {};
    }
  };
};
async function XS(t, e) {
  const {
    placement: r,
    platform: i,
    elements: o
  } = t, p = await (i.isRTL == null ? void 0 : i.isRTL(o.floating)), g = bi(r), a = cn(r), n = un(r) === "x", u = ["left", "top"].includes(g) ? -1 : 1, h = p && n ? -1 : 1, s = typeof e == "function" ? e(t) : e;
  let {
    mainAxis: l,
    crossAxis: c,
    alignmentAxis: f
  } = typeof s == "number" ? {
    mainAxis: s,
    crossAxis: 0,
    alignmentAxis: null
  } : {
    mainAxis: 0,
    crossAxis: 0,
    alignmentAxis: null,
    ...s
  };
  return a && typeof f == "number" && (c = a === "end" ? f * -1 : f), n ? {
    x: c * h,
    y: l * u
  } : {
    x: l * u,
    y: c * h
  };
}
const GS = function(t) {
  return t === void 0 && (t = 0), {
    name: "offset",
    options: t,
    async fn(e) {
      const {
        x: r,
        y: i
      } = e, o = await XS(e, t);
      return {
        x: r + o.x,
        y: i + o.y,
        data: o
      };
    }
  };
};
function qS(t) {
  return t === "x" ? "y" : "x";
}
const KS = function(t) {
  return t === void 0 && (t = {}), {
    name: "shift",
    options: t,
    async fn(e) {
      const {
        x: r,
        y: i,
        placement: o
      } = e, {
        mainAxis: p = !0,
        crossAxis: g = !1,
        limiter: a = {
          fn: (d) => {
            let {
              x: v,
              y: b
            } = d;
            return {
              x: v,
              y: b
            };
          }
        },
        ...n
      } = t, u = {
        x: r,
        y: i
      }, h = await Ol(e, n), s = un(bi(o)), l = qS(s);
      let c = u[s], f = u[l];
      if (p) {
        const d = s === "y" ? "top" : "left", v = s === "y" ? "bottom" : "right", b = c + h[d], y = c - h[v];
        c = fa(b, c, y);
      }
      if (g) {
        const d = l === "y" ? "top" : "left", v = l === "y" ? "bottom" : "right", b = f + h[d], y = f - h[v];
        f = fa(b, f, y);
      }
      const m = a.fn({
        ...e,
        [s]: c,
        [l]: f
      });
      return {
        ...m,
        data: {
          x: m.x - r,
          y: m.y - i
        }
      };
    }
  };
}, ZS = function(t) {
  return t === void 0 && (t = {}), {
    name: "size",
    options: t,
    async fn(e) {
      const {
        placement: r,
        rects: i,
        platform: o,
        elements: p
      } = e, {
        apply: g = () => {
        },
        ...a
      } = t, n = await Ol(e, a), u = bi(r), h = cn(r);
      let s, l;
      u === "top" || u === "bottom" ? (s = u, l = h === (await (o.isRTL == null ? void 0 : o.isRTL(p.floating)) ? "start" : "end") ? "left" : "right") : (l = u, s = h === "end" ? "top" : "bottom");
      const c = yr(n.left, 0), f = yr(n.right, 0), m = yr(n.top, 0), d = yr(n.bottom, 0), v = {
        availableHeight: i.floating.height - (["left", "right"].includes(r) ? 2 * (m !== 0 || d !== 0 ? m + d : yr(n.top, n.bottom)) : n[s]),
        availableWidth: i.floating.width - (["top", "bottom"].includes(r) ? 2 * (c !== 0 || f !== 0 ? c + f : yr(n.left, n.right)) : n[l])
      };
      await g({
        ...e,
        ...v
      });
      const b = await o.getDimensions(p.floating);
      return i.floating.width !== b.width || i.floating.height !== b.height ? {
        reset: {
          rects: !0
        }
      } : {};
    }
  };
};
function mp(t) {
  return t && t.document && t.location && t.alert && t.setInterval;
}
function Nt(t) {
  if (t == null)
    return window;
  if (!mp(t)) {
    const e = t.ownerDocument;
    return e && e.defaultView || window;
  }
  return t;
}
function ir(t) {
  return Nt(t).getComputedStyle(t);
}
function zt(t) {
  return mp(t) ? "" : t ? (t.nodeName || "").toLowerCase() : "";
}
function vp() {
  const t = navigator.userAgentData;
  return t != null && t.brands ? t.brands.map((e) => e.brand + "/" + e.version).join(" ") : navigator.userAgent;
}
function kt(t) {
  return t instanceof Nt(t).HTMLElement;
}
function nr(t) {
  return t instanceof Nt(t).Element;
}
function JS(t) {
  return t instanceof Nt(t).Node;
}
function lo(t) {
  if (typeof ShadowRoot > "u")
    return !1;
  const e = Nt(t).ShadowRoot;
  return t instanceof e || t instanceof ShadowRoot;
}
function Ao(t) {
  const {
    overflow: e,
    overflowX: r,
    overflowY: i
  } = ir(t);
  return /auto|scroll|overlay|hidden/.test(e + i + r);
}
function QS(t) {
  return ["table", "td", "th"].includes(zt(t));
}
function bp(t) {
  const e = /firefox/i.test(vp()), r = ir(t);
  return r.transform !== "none" || r.perspective !== "none" || r.contain === "paint" || ["transform", "perspective"].includes(r.willChange) || e && r.willChange === "filter" || e && (r.filter ? r.filter !== "none" : !1);
}
function yp() {
  return !/^((?!chrome|android).)*safari/i.test(vp());
}
const ku = Math.min, Pi = Math.max, co = Math.round;
function jt(t, e, r) {
  var i, o, p, g;
  e === void 0 && (e = !1), r === void 0 && (r = !1);
  const a = t.getBoundingClientRect();
  let n = 1, u = 1;
  e && kt(t) && (n = t.offsetWidth > 0 && co(a.width) / t.offsetWidth || 1, u = t.offsetHeight > 0 && co(a.height) / t.offsetHeight || 1);
  const h = nr(t) ? Nt(t) : window, s = !yp() && r, l = (a.left + (s && (i = (o = h.visualViewport) == null ? void 0 : o.offsetLeft) != null ? i : 0)) / n, c = (a.top + (s && (p = (g = h.visualViewport) == null ? void 0 : g.offsetTop) != null ? p : 0)) / u, f = a.width / n, m = a.height / u;
  return {
    width: f,
    height: m,
    top: c,
    right: l + f,
    bottom: c + m,
    left: l,
    x: l,
    y: c
  };
}
function ur(t) {
  return ((JS(t) ? t.ownerDocument : t.document) || window.document).documentElement;
}
function Do(t) {
  return nr(t) ? {
    scrollLeft: t.scrollLeft,
    scrollTop: t.scrollTop
  } : {
    scrollLeft: t.pageXOffset,
    scrollTop: t.pageYOffset
  };
}
function wp(t) {
  return jt(ur(t)).left + Do(t).scrollLeft;
}
function eC(t) {
  const e = jt(t);
  return co(e.width) !== t.offsetWidth || co(e.height) !== t.offsetHeight;
}
function tC(t, e, r) {
  const i = kt(e), o = ur(e), p = jt(
    t,
    i && eC(e),
    r === "fixed"
  );
  let g = {
    scrollLeft: 0,
    scrollTop: 0
  };
  const a = {
    x: 0,
    y: 0
  };
  if (i || !i && r !== "fixed")
    if ((zt(e) !== "body" || Ao(o)) && (g = Do(e)), kt(e)) {
      const n = jt(e, !0);
      a.x = n.x + e.clientLeft, a.y = n.y + e.clientTop;
    } else
      o && (a.x = wp(o));
  return {
    x: p.left + g.scrollLeft - a.x,
    y: p.top + g.scrollTop - a.y,
    width: p.width,
    height: p.height
  };
}
function xp(t) {
  return zt(t) === "html" ? t : t.assignedSlot || t.parentNode || (lo(t) ? t.host : null) || ur(t);
}
function Eu(t) {
  return !kt(t) || ir(t).position === "fixed" ? null : t.offsetParent;
}
function rC(t) {
  let e = xp(t);
  for (lo(e) && (e = e.host); kt(e) && !["html", "body"].includes(zt(e)); ) {
    if (bp(e))
      return e;
    {
      const r = e.parentNode;
      e = lo(r) ? r.host : r;
    }
  }
  return null;
}
function da(t) {
  const e = Nt(t);
  let r = Eu(t);
  for (; r && QS(r) && ir(r).position === "static"; )
    r = Eu(r);
  return r && (zt(r) === "html" || zt(r) === "body" && ir(r).position === "static" && !bp(r)) ? e : r || rC(t) || e;
}
function Ou(t) {
  if (kt(t))
    return {
      width: t.offsetWidth,
      height: t.offsetHeight
    };
  const e = jt(t);
  return {
    width: e.width,
    height: e.height
  };
}
function iC(t) {
  let {
    rect: e,
    offsetParent: r,
    strategy: i
  } = t;
  const o = kt(r), p = ur(r);
  if (r === p)
    return e;
  let g = {
    scrollLeft: 0,
    scrollTop: 0
  };
  const a = {
    x: 0,
    y: 0
  };
  if ((o || !o && i !== "fixed") && ((zt(r) !== "body" || Ao(p)) && (g = Do(r)), kt(r))) {
    const n = jt(r, !0);
    a.x = n.x + r.clientLeft, a.y = n.y + r.clientTop;
  }
  return {
    ...e,
    x: e.x - g.scrollLeft + a.x,
    y: e.y - g.scrollTop + a.y
  };
}
function nC(t, e) {
  const r = Nt(t), i = ur(t), o = r.visualViewport;
  let p = i.clientWidth, g = i.clientHeight, a = 0, n = 0;
  if (o) {
    p = o.width, g = o.height;
    const u = yp();
    (u || !u && e === "fixed") && (a = o.offsetLeft, n = o.offsetTop);
  }
  return {
    width: p,
    height: g,
    x: a,
    y: n
  };
}
function oC(t) {
  var e;
  const r = ur(t), i = Do(t), o = (e = t.ownerDocument) == null ? void 0 : e.body, p = Pi(r.scrollWidth, r.clientWidth, o ? o.scrollWidth : 0, o ? o.clientWidth : 0), g = Pi(r.scrollHeight, r.clientHeight, o ? o.scrollHeight : 0, o ? o.clientHeight : 0);
  let a = -i.scrollLeft + wp(t);
  const n = -i.scrollTop;
  return ir(o || r).direction === "rtl" && (a += Pi(r.clientWidth, o ? o.clientWidth : 0) - p), {
    width: p,
    height: g,
    x: a,
    y: n
  };
}
function _p(t) {
  const e = xp(t);
  return ["html", "body", "#document"].includes(zt(e)) ? t.ownerDocument.body : kt(e) && Ao(e) ? e : _p(e);
}
function uo(t, e) {
  var r;
  e === void 0 && (e = []);
  const i = _p(t), o = i === ((r = t.ownerDocument) == null ? void 0 : r.body), p = Nt(i), g = o ? [p].concat(p.visualViewport || [], Ao(i) ? i : []) : i, a = e.concat(g);
  return o ? a : a.concat(uo(g));
}
function sC(t, e) {
  const r = e.getRootNode == null ? void 0 : e.getRootNode();
  if (t.contains(e))
    return !0;
  if (r && lo(r)) {
    let i = e;
    do {
      if (i && t === i)
        return !0;
      i = i.parentNode || i.host;
    } while (i);
  }
  return !1;
}
function aC(t, e) {
  const r = jt(t, !1, e === "fixed"), i = r.top + t.clientTop, o = r.left + t.clientLeft;
  return {
    top: i,
    left: o,
    x: o,
    y: i,
    right: o + t.clientWidth,
    bottom: i + t.clientHeight,
    width: t.clientWidth,
    height: t.clientHeight
  };
}
function Pu(t, e, r) {
  return e === "viewport" ? so(nC(t, r)) : nr(e) ? aC(e, r) : so(oC(ur(t)));
}
function lC(t) {
  const e = uo(t), i = ["absolute", "fixed"].includes(ir(t).position) && kt(t) ? da(t) : t;
  return nr(i) ? e.filter((o) => nr(o) && sC(o, i) && zt(o) !== "body") : [];
}
function cC(t) {
  let {
    element: e,
    boundary: r,
    rootBoundary: i,
    strategy: o
  } = t;
  const g = [...r === "clippingAncestors" ? lC(e) : [].concat(r), i], a = g[0], n = g.reduce((u, h) => {
    const s = Pu(e, h, o);
    return u.top = Pi(s.top, u.top), u.right = ku(s.right, u.right), u.bottom = ku(s.bottom, u.bottom), u.left = Pi(s.left, u.left), u;
  }, Pu(e, a, o));
  return {
    width: n.right - n.left,
    height: n.bottom - n.top,
    x: n.left,
    y: n.top
  };
}
const uC = {
  getClippingRect: cC,
  convertOffsetParentRelativeRectToViewportRelativeRect: iC,
  isElement: nr,
  getDimensions: Ou,
  getOffsetParent: da,
  getDocumentElement: ur,
  getElementRects: (t) => {
    let {
      reference: e,
      floating: r,
      strategy: i
    } = t;
    return {
      reference: tC(e, da(r), i),
      floating: {
        ...Ou(r),
        x: 0,
        y: 0
      }
    };
  },
  getClientRects: (t) => Array.from(t.getClientRects()),
  isRTL: (t) => ir(t).direction === "rtl"
};
function hC(t, e, r, i) {
  i === void 0 && (i = {});
  const {
    ancestorScroll: o = !0,
    ancestorResize: p = !0,
    elementResize: g = !0,
    animationFrame: a = !1
  } = i, n = o && !a, u = p && !a, h = n || u ? [...nr(t) ? uo(t) : [], ...uo(e)] : [];
  h.forEach((m) => {
    n && m.addEventListener("scroll", r, {
      passive: !0
    }), u && m.addEventListener("resize", r);
  });
  let s = null;
  if (g) {
    let m = !0;
    s = new ResizeObserver(() => {
      m || r(), m = !1;
    }), nr(t) && !a && s.observe(t), s.observe(e);
  }
  let l, c = a ? jt(t) : null;
  a && f();
  function f() {
    const m = jt(t);
    c && (m.x !== c.x || m.y !== c.y || m.width !== c.width || m.height !== c.height) && r(), c = m, l = requestAnimationFrame(f);
  }
  return r(), () => {
    var m;
    h.forEach((d) => {
      n && d.removeEventListener("scroll", r), u && d.removeEventListener("resize", r);
    }), (m = s) == null || m.disconnect(), s = null, a && cancelAnimationFrame(l);
  };
}
const fC = (t, e, r) => BS(t, e, {
  platform: uC,
  ...r
});
var pa = typeof document < "u" ? pi : xe;
function ho(t, e) {
  if (t === e)
    return !0;
  if (typeof t != typeof e)
    return !1;
  if (typeof t == "function" && t.toString() === e.toString())
    return !0;
  let r, i, o;
  if (t && e && typeof t == "object") {
    if (Array.isArray(t)) {
      if (r = t.length, r != e.length)
        return !1;
      for (i = r; i-- !== 0; )
        if (!ho(t[i], e[i]))
          return !1;
      return !0;
    }
    if (o = Object.keys(t), r = o.length, r !== Object.keys(e).length)
      return !1;
    for (i = r; i-- !== 0; )
      if (!Object.prototype.hasOwnProperty.call(e, o[i]))
        return !1;
    for (i = r; i-- !== 0; ) {
      const p = o[i];
      if (!(p === "_owner" && t.$$typeof) && !ho(t[p], e[p]))
        return !1;
    }
    return !0;
  }
  return t !== t && e !== e;
}
function dC(t) {
  const e = Se.useRef(t);
  return pa(() => {
    e.current = t;
  }), e;
}
function pC(t) {
  let {
    middleware: e,
    placement: r = "bottom",
    strategy: i = "absolute",
    whileElementsMounted: o
  } = t === void 0 ? {} : t;
  const [p, g] = Se.useState({
    x: null,
    y: null,
    strategy: i,
    placement: r,
    middlewareData: {}
  }), [a, n] = Se.useState(e);
  ho(a == null ? void 0 : a.map((w) => {
    let {
      name: _,
      options: S
    } = w;
    return {
      name: _,
      options: S
    };
  }), e == null ? void 0 : e.map((w) => {
    let {
      name: _,
      options: S
    } = w;
    return {
      name: _,
      options: S
    };
  })) || n(e);
  const u = Se.useRef(null), h = Se.useRef(null), s = Se.useRef(null), l = Se.useRef(p), c = dC(o), f = Se.useCallback(() => {
    !u.current || !h.current || fC(u.current, h.current, {
      middleware: a,
      placement: r,
      strategy: i
    }).then((w) => {
      m.current && !ho(l.current, w) && (l.current = w, om.flushSync(() => {
        g(w);
      }));
    });
  }, [a, r, i]);
  pa(() => {
    m.current && f();
  }, [f]);
  const m = Se.useRef(!1);
  pa(() => (m.current = !0, () => {
    m.current = !1;
  }), []);
  const d = Se.useCallback(() => {
    if (typeof s.current == "function" && (s.current(), s.current = null), u.current && h.current)
      if (c.current) {
        const w = c.current(u.current, h.current, f);
        s.current = w;
      } else
        f();
  }, [f, c]), v = Se.useCallback((w) => {
    u.current = w, d();
  }, [d]), b = Se.useCallback((w) => {
    h.current = w, d();
  }, [d]), y = Se.useMemo(() => ({
    reference: u,
    floating: h
  }), []);
  return Se.useMemo(() => ({
    ...p,
    update: f,
    refs: y,
    reference: v,
    floating: b
  }), [p, f, y, v, b]);
}
const gC = (t) => {
  const {
    element: e,
    padding: r
  } = t;
  function i(o) {
    return Object.prototype.hasOwnProperty.call(o, "current");
  }
  return {
    name: "arrow",
    options: t,
    fn(o) {
      return i(e) ? e.current != null ? Cu({
        element: e.current,
        padding: r
      }).fn(o) : {} : e ? Cu({
        element: e,
        padding: r
      }).fn(o) : {};
    }
  };
};
function mC(t) {
  return (e) => {
    t.forEach((r) => {
      typeof r == "function" ? r(e) : r != null && (r.current = e);
    });
  };
}
function Sp({
  floatingWidth: t,
  ref: e,
  disablePositioning: r = !1,
  placement: i = "bottom",
  offset: o = 2,
  showArrow: p = !1
}) {
  const g = de(null), a = { placement: i };
  r || (a.whileElementsMounted = hC, a.middleware = [
    GS(o),
    YS({ padding: 16 }),
    KS({ padding: 16 }),
    ZS({
      apply({ rects: f, availableHeight: m, availableWidth: d, elements: v }) {
        t === "matchTrigger" && Object.assign(v.floating.style, {
          width: `${f.reference.width}px`,
          maxWidth: `${d}`,
          maxHeight: `${Math.min(m, 420)}px`
        });
      },
      padding: 16
    })
  ], p && a.middleware.push(gC({ element: g })));
  const n = pC(a), u = Je(
    () => mC([e, n.reference]),
    [n.reference, e]
  ), { x: h, y: s } = n.middlewareData.arrow || {}, l = {
    top: "bottom",
    right: "left",
    bottom: "top",
    left: "right"
  }[n.placement.split("-")[0]], c = {
    left: h,
    top: s,
    right: "",
    bottom: "",
    [l]: "-4px"
  };
  return {
    ...n,
    reference: u,
    arrowRef: g,
    arrowStyle: c
  };
}
function Cp(t, e) {
  const {
    children: r,
    items: i,
    role: o = "listbox",
    virtualFocus: p,
    loopFocus: g = !1,
    onItemSelected: a,
    clearInputOnItemSelection: n,
    floatingWidth: u = "matchTrigger",
    floatingMinWidth: h,
    offset: s,
    placement: l,
    showCheckmark: c,
    showEmptyMessage: f,
    maxItems: m,
    isAsync: d
  } = t, v = t.selectionMode || "none", y = `${yt()}-listbox`, [w, _] = kr(
    t.inputValue,
    t.defaultInputValue || "",
    t.onInputValueChange
  ), [S, T] = Ae(
    "all"
  ), A = LS({
    children: r,
    items: i,
    inputValue: w,
    maxItems: m
  }), R = S === "all" ? A.collection : A.filteredCollection, N = de([]), U = Je(() => [...R.values()].map(
    (W) => W.isDisabled ? null : W.textLabel
  ), [R]), { selectedValues: Q, selectValues: ee } = bC(t), [J, q] = kr(
    t.isOpen,
    t.defaultIsOpen,
    t.onOpenChange
  ), [re, le] = Ae(null), ne = Sp({
    floatingWidth: u,
    ref: e,
    placement: l,
    offset: s
  }), { refs: C, floating: k, strategy: P, x: D, y: B } = ne, M = v === "none" ? void 0 : R.get(Q[0]), E = v === "none" || M == null ? void 0 : M.index, L = (W) => {
    if (v !== "none") {
      const j = [...R.values()][W];
      j && ee(j.value);
    }
  }, z = Ie(
    (W, j) => {
      var X, G;
      const te = [...R.values()], V = !te.find((H) => !H.isDisabled), F = R.size - 1;
      if (j == null || !R.size || j > F || j < 0 || V) {
        le(null);
        return;
      }
      j = vC(
        te,
        j,
        g,
        W
      ), le(j), p ? (X = N.current[j]) == null || X.scrollIntoView({
        block: "nearest"
      }) : (G = N.current[j]) == null || G.focus();
    },
    [R, p, g]
  ), Y = Ie(
    (W) => {
      _(W.target.value), d || T(W.target.value.trim() ? "filtered" : "all"), W.target.value ? q(!0) : ee("");
    },
    [_, q, T, ee, d]
  );
  return {
    handleItemSelection: (W) => {
      if (v !== "none")
        ee(W);
      else {
        const j = C.reference.current;
        j && "focus" in j && j.focus();
      }
      p && _(n ? "" : `${W}`), q(!1), le(null), a == null || a(W);
    },
    onInputChange: Y,
    loopFocus: g,
    floatingWidth: u,
    floatingMinWidth: h,
    showCheckmark: c,
    collection: R,
    virtualFocus: p,
    focusItem: z,
    showEmptyMessage: f,
    refs: C,
    reference: ne.reference,
    floating: k,
    positionStyle: {
      position: P,
      top: B != null ? B : "",
      left: D != null ? D : ""
    },
    listContent: U,
    listItemsRef: N,
    listboxId: y,
    role: o,
    state: {
      activeIndex: re,
      setActiveIndex: le,
      selectedIndex: E,
      setSelectedIndex: L,
      selectionMode: v,
      selectedValues: Q,
      selectValues: ee,
      inputValue: w,
      setInputValue: _,
      isOpen: J,
      setIsOpen: q,
      setActiveCollection: T
    }
  };
}
function vC(t, e, r, i) {
  var p;
  const o = t.length - 1;
  for (; (p = t[e]) != null && p.isDisabled; )
    if (i === "increment") {
      if (e++, e >= o)
        if (r)
          e = 0;
        else
          return e - 1;
    } else if (e--, e < 0)
      if (r)
        e = o;
      else
        return e + 1;
  return e;
}
function bC(t) {
  const { selectionMode: e, allowEmptySelection: r } = t, i = e === "single" || e === "multiple", [o, p] = kr(
    i ? t.selectedValue : void 0,
    i ? t.defaultSelectedValue : void 0,
    i ? t.onSelectionChange : void 0
  ), g = Je(() => o == null || o === "" ? [] : Array.isArray(o) ? o : [o], [o]), a = Ie(
    (n) => {
      const u = Array.isArray(n) ? n : [n];
      e === "single" ? p(u[0]) : u.forEach((h) => {
        const s = g.indexOf(h);
        s === -1 ? (g.push(h), p([...g])) : (g.length > 1 || r) && (g.splice(s, 1), p([...g]));
      });
    },
    [r, g, e, p]
  );
  return {
    selectedValues: g,
    selectValues: a
  };
}
const Tp = sr(null);
function kp() {
  return De(Tp);
}
const ga = me(/* @__PURE__ */ x("path", {
  d: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z"
}), "CheckOutlined"), yC = ae.forwardRef((t, e) => {
  let {
    startIcon: r,
    capitalizeFirst: i,
    children: o,
    description: p,
    endIcon: g,
    endSection: a,
    isDisabled: n,
    isActive: u,
    isSelected: h,
    showCheckmark: s,
    ...l
  } = t;
  !r && s && (r = /* @__PURE__ */ x(ga, {
    size: "sm",
    className: ue("text-primary", !h && "invisible")
  }));
  const c = ue("icon-sm rounded overflow-hidden flex-shrink-0", !n && "text-muted");
  return /* @__PURE__ */ ie("div", {
    ...l,
    "aria-disabled": n,
    className: wC(t),
    ref: e,
    children: [r && /* @__PURE__ */ x("div", {
      className: c,
      children: r
    }), /* @__PURE__ */ ie("div", {
      className: ue("mr-auto", i && "first-letter:capitalize"),
      children: [o, p && /* @__PURE__ */ x("div", {
        className: ue("text-xs mt-4 whitespace-normal", n ? "text-disabled" : "text-muted"),
        children: p
      })]
    }), (g || a) && /* @__PURE__ */ x("div", {
      className: g ? c : "text-muted",
      children: g || a
    })]
  });
});
function wC({
  className: t,
  isSelected: e,
  isActive: r,
  isDisabled: i,
  showCheckmark: o
}) {
  let p = "";
  return i ? p = "text-disabled pointer-events-none" : e ? r ? p = "bg-primary/focus" : p = "bg-primary/selected hover:bg-primary/focus" : r ? p = "hover:bg-fg-base/15 bg-focus" : p = "hover:bg-hover", ue("w-full select-none outline-none cursor-pointer", "py-8 text-sm truncate flex items-center gap-10 text-main", o ? "px-8" : "px-20", p, t);
}
function Io({
  children: t,
  value: e,
  startIcon: r,
  endIcon: i,
  endSection: o,
  description: p,
  capitalizeFirst: g,
  textLabel: a,
  isDisabled: n,
  onSelected: u,
  onClick: h,
  ...s
}) {
  var N;
  const {
    collection: l,
    showCheckmark: c,
    virtualFocus: f,
    listboxId: m,
    role: d,
    listItemsRef: v,
    handleItemSelection: b,
    state: {
      selectedValues: y,
      activeIndex: w,
      setActiveIndex: _
    }
  } = kp(), S = y.includes(e), T = (N = l.get(e)) == null ? void 0 : N.index, A = w === T;
  if (T == null)
    return null;
  const R = A && !n ? -1 : 0;
  return /* @__PURE__ */ x(yC, {
    ...s,
    onFocus: () => {
      f || _(T);
    },
    onPointerEnter: (U) => {
      _(T), f || U.currentTarget.focus();
    },
    onPointerDown: (U) => {
      f && U.preventDefault();
    },
    onKeyDown: (U) => {
      (U.key === "Enter" || U.key === " ") && (U.preventDefault(), b(e), u == null || u());
    },
    onClick: (U) => {
      b(e), u == null || u(), h == null || h(U);
    },
    ref: (U) => v.current[T] = U,
    id: `${m}-${T}`,
    role: d === "menu" ? "menuitem" : "option",
    tabIndex: f ? void 0 : R,
    "aria-selected": A && S,
    showCheckmark: c,
    isDisabled: n,
    isActive: A,
    isSelected: S,
    startIcon: r,
    description: p,
    endIcon: i,
    endSection: o,
    capitalizeFirst: g,
    children: t
  });
}
const xC = 768;
function _C() {
  return u_() || typeof window > "u" ? !1 : window.screen.width <= xC;
}
const Pl = {
  initial: { opacity: 0, y: 5 },
  animate: { opacity: 1, y: 0 },
  exit: { opacity: 0, y: 5 },
  transition: { type: "tween", duration: 0.125 }
};
function Ml() {
  const { width: t, height: e } = v_();
  return {
    "--be-viewport-height": `${e}px`,
    "--be-viewport-width": `${t}px`
  };
}
function SC(t) {
  return t.mozInputSource === 0 && t.isTrusted ? !0 : t.detail === 0 && !t.pointerType;
}
class CC {
  isDefaultPrevented() {
    return this.nativeEvent.defaultPrevented;
  }
  preventDefault() {
    this.defaultPrevented = !0, this.nativeEvent.preventDefault();
  }
  stopPropagation() {
    this.nativeEvent.stopPropagation(), this.isPropagationStopped = () => !0;
  }
  isPropagationStopped() {
    return !1;
  }
  persist() {
  }
  constructor(e, r) {
    this.nativeEvent = r, this.target = r.target, this.currentTarget = r.currentTarget, this.relatedTarget = r.relatedTarget, this.bubbles = r.bubbles, this.cancelable = r.cancelable, this.defaultPrevented = r.defaultPrevented, this.eventPhase = r.eventPhase, this.isTrusted = r.isTrusted, this.timeStamp = r.timeStamp, this.type = e;
  }
}
function TC(t) {
  let e = de({
    isFocused: !1,
    onBlur: t,
    observer: null
  });
  return e.current.onBlur = t, Ft(() => {
    const r = e.current;
    return () => {
      r.observer && (r.observer.disconnect(), r.observer = null);
    };
  }, []), Ie((r) => {
    if (r.target instanceof HTMLButtonElement || r.target instanceof HTMLInputElement || r.target instanceof HTMLTextAreaElement || r.target instanceof HTMLSelectElement) {
      e.current.isFocused = !0;
      let i = r.target, o = (p) => {
        var g, a;
        e.current.isFocused = !1, i.disabled && ((a = (g = e.current).onBlur) === null || a === void 0 || a.call(g, new CC("blur", p))), e.current.observer && (e.current.observer.disconnect(), e.current.observer = null);
      };
      i.addEventListener("focusout", o, {
        once: !0
      }), e.current.observer = new MutationObserver(() => {
        e.current.isFocused && i.disabled && (e.current.observer.disconnect(), i.dispatchEvent(new FocusEvent("blur")), i.dispatchEvent(new FocusEvent("focusout", {
          bubbles: !0
        })));
      }), e.current.observer.observe(i, {
        attributes: !0,
        attributeFilter: [
          "disabled"
        ]
      });
    }
  }, []);
}
const kC = ae.createContext(null);
kC.displayName = "PressResponderContext";
let hn = null, EC = /* @__PURE__ */ new Set(), Mu = !1, Er = !1, ma = !1;
function Al(t, e) {
  for (let r of EC)
    r(t, e);
}
function OC(t) {
  return !(t.metaKey || !ip() && t.altKey || t.ctrlKey || t.key === "Control" || t.key === "Shift" || t.key === "Meta");
}
function Au(t) {
  Er = !0, OC(t) && (hn = "keyboard", Al("keyboard", t));
}
function Nr(t) {
  hn = "pointer", (t.type === "mousedown" || t.type === "pointerdown") && (Er = !0, Al("pointer", t));
}
function PC(t) {
  SC(t) && (Er = !0, hn = "virtual");
}
function MC(t) {
  t.target === window || t.target === document || (!Er && !ma && (hn = "virtual", Al("virtual", t)), Er = !1, ma = !1);
}
function AC() {
  Er = !1, ma = !0;
}
function Du() {
  if (typeof window > "u" || Mu)
    return;
  let t = HTMLElement.prototype.focus;
  HTMLElement.prototype.focus = function() {
    Er = !0, t.apply(this, arguments);
  }, document.addEventListener("keydown", Au, !0), document.addEventListener("keyup", Au, !0), document.addEventListener("click", PC, !0), window.addEventListener("focus", MC, !0), window.addEventListener("blur", AC, !1), typeof PointerEvent < "u" ? (document.addEventListener("pointerdown", Nr, !0), document.addEventListener("pointermove", Nr, !0), document.addEventListener("pointerup", Nr, !0)) : (document.addEventListener("mousedown", Nr, !0), document.addEventListener("mousemove", Nr, !0), document.addEventListener("mouseup", Nr, !0)), Mu = !0;
}
typeof document < "u" && (document.readyState !== "loading" ? Du() : document.addEventListener("DOMContentLoaded", Du));
function DC() {
  return hn;
}
function IC(t) {
  let { isDisabled: e, onBlurWithin: r, onFocusWithin: i, onFocusWithinChange: o } = t, p = de({
    isFocusWithin: !1
  }), g = Ie((u) => {
    p.current.isFocusWithin && !u.currentTarget.contains(u.relatedTarget) && (p.current.isFocusWithin = !1, r && r(u), o && o(!1));
  }, [
    r,
    o,
    p
  ]), a = TC(g), n = Ie((u) => {
    p.current.isFocusWithin || (i && i(u), o && o(!0), p.current.isFocusWithin = !0, a(u));
  }, [
    i,
    o,
    a
  ]);
  return e ? {
    focusWithinProps: {
      onFocus: null,
      onBlur: null
    }
  } : {
    focusWithinProps: {
      onFocus: n,
      onBlur: g
    }
  };
}
function RC(t) {
  let { ref: e, onInteractOutside: r, isDisabled: i, onInteractOutsideStart: o } = t, g = de({
    isPointerDown: !1,
    ignoreEmulatedMouseEvents: !1,
    onInteractOutside: r,
    onInteractOutsideStart: o
  }).current;
  g.onInteractOutside = r, g.onInteractOutsideStart = o, xe(() => {
    if (i)
      return;
    let a = (n) => {
      Pn(n, e) && g.onInteractOutside && (g.onInteractOutsideStart && g.onInteractOutsideStart(n), g.isPointerDown = !0);
    };
    if (typeof PointerEvent < "u") {
      let n = (u) => {
        g.isPointerDown && g.onInteractOutside && Pn(u, e) && (g.isPointerDown = !1, g.onInteractOutside(u));
      };
      return document.addEventListener("pointerdown", a, !0), document.addEventListener("pointerup", n, !0), () => {
        document.removeEventListener("pointerdown", a, !0), document.removeEventListener("pointerup", n, !0);
      };
    } else {
      let n = (h) => {
        g.ignoreEmulatedMouseEvents ? g.ignoreEmulatedMouseEvents = !1 : g.isPointerDown && g.onInteractOutside && Pn(h, e) && (g.isPointerDown = !1, g.onInteractOutside(h));
      }, u = (h) => {
        g.ignoreEmulatedMouseEvents = !0, g.onInteractOutside && g.isPointerDown && Pn(h, e) && (g.isPointerDown = !1, g.onInteractOutside(h));
      };
      return document.addEventListener("mousedown", a, !0), document.addEventListener("mouseup", n, !0), document.addEventListener("touchstart", a, !0), document.addEventListener("touchend", u, !0), () => {
        document.removeEventListener("mousedown", a, !0), document.removeEventListener("mouseup", n, !0), document.removeEventListener("touchstart", a, !0), document.removeEventListener("touchend", u, !0);
      };
    }
  }, [
    e,
    g,
    i
  ]);
}
function Pn(t, e) {
  if (t.button > 0)
    return !1;
  if (t.target) {
    const r = t.target.ownerDocument;
    if (!r || !r.documentElement.contains(t.target))
      return !1;
  }
  return e.current && !e.current.contains(t.target);
}
function LC(t) {
  if (DC() === "virtual") {
    let e = document.activeElement;
    m_(() => {
      document.activeElement === e && document.contains(t) && cu(t);
    });
  } else
    cu(t);
}
function FC(t) {
  if (!(t instanceof HTMLElement) && !(t instanceof SVGElement))
    return !1;
  let { display: e, visibility: r } = t.style, i = e !== "none" && r !== "hidden" && r !== "collapse";
  if (i) {
    const { getComputedStyle: o } = t.ownerDocument.defaultView;
    let { display: p, visibility: g } = o(t);
    i = p !== "none" && g !== "hidden" && g !== "collapse";
  }
  return i;
}
function zC(t, e) {
  return !t.hasAttribute("hidden") && (t.nodeName === "DETAILS" && e && e.nodeName !== "SUMMARY" ? t.hasAttribute("open") : !0);
}
function Ep(t, e) {
  return t.nodeName !== "#comment" && FC(t) && zC(t, e) && (!t.parentElement || Ep(t.parentElement, t));
}
const va = /* @__PURE__ */ ae.createContext(null);
let it = null, ni = /* @__PURE__ */ new Map();
function Ro(t) {
  let { children: e, contain: r, restoreFocus: i, autoFocus: o } = t, p = de(), g = de(), a = de([]), n = De(va), u = n == null ? void 0 : n.scopeRef;
  Ft(() => {
    let s = p.current.nextSibling, l = [];
    for (; s && s !== g.current; )
      l.push(s), s = s.nextSibling;
    a.current = l;
  }, [
    e,
    u
  ]), Ft(() => (ni.set(a, u), () => {
    (a === it || Lo(a, it)) && (!u || ni.has(u)) && (it = u), ni.delete(a);
  }), [
    a,
    u
  ]), $C(a, r), WC(a, i, r), UC(a, o);
  let h = BC(a);
  return /* @__PURE__ */ ae.createElement(va.Provider, {
    value: {
      scopeRef: a,
      focusManager: h
    }
  }, /* @__PURE__ */ ae.createElement("span", {
    "data-focus-scope-start": !0,
    hidden: !0,
    ref: p
  }), e, /* @__PURE__ */ ae.createElement("span", {
    "data-focus-scope-end": !0,
    hidden: !0,
    ref: g
  }));
}
function jC() {
  var t;
  return (t = De(va)) === null || t === void 0 ? void 0 : t.focusManager;
}
function BC(t) {
  return {
    focusNext(e = {}) {
      let r = t.current, { from: i, tabbable: o, wrap: p, accept: g } = e, a = i || document.activeElement, n = r[0].previousElementSibling, u = Yt(Kr(r), {
        tabbable: o,
        accept: g
      }, r);
      u.currentNode = vt(a, r) ? a : n;
      let h = u.nextNode();
      return !h && p && (u.currentNode = n, h = u.nextNode()), h && At(h, !0), h;
    },
    focusPrevious(e = {}) {
      let r = t.current, { from: i, tabbable: o, wrap: p, accept: g } = e, a = i || document.activeElement, n = r[r.length - 1].nextElementSibling, u = Yt(Kr(r), {
        tabbable: o,
        accept: g
      }, r);
      u.currentNode = vt(a, r) ? a : n;
      let h = u.previousNode();
      return !h && p && (u.currentNode = n, h = u.previousNode()), h && At(h, !0), h;
    },
    focusFirst(e = {}) {
      let r = t.current, { tabbable: i, accept: o } = e, p = Yt(Kr(r), {
        tabbable: i,
        accept: o
      }, r);
      p.currentNode = r[0].previousElementSibling;
      let g = p.nextNode();
      return g && At(g, !0), g;
    },
    focusLast(e = {}) {
      let r = t.current, { tabbable: i, accept: o } = e, p = Yt(Kr(r), {
        tabbable: i,
        accept: o
      }, r);
      p.currentNode = r[r.length - 1].nextElementSibling;
      let g = p.previousNode();
      return g && At(g, !0), g;
    }
  };
}
const Dl = [
  "input:not([disabled]):not([type=hidden])",
  "select:not([disabled])",
  "textarea:not([disabled])",
  "button:not([disabled])",
  "a[href]",
  "area[href]",
  "summary",
  "iframe",
  "object",
  "embed",
  "audio[controls]",
  "video[controls]",
  "[contenteditable]"
], NC = Dl.join(":not([hidden]),") + ",[tabindex]:not([disabled]):not([hidden])";
Dl.push('[tabindex]:not([tabindex="-1"]):not([disabled])');
const VC = Dl.join(':not([hidden]):not([tabindex="-1"]),');
function Kr(t) {
  return t[0].parentElement;
}
function $C(t, e) {
  let r = de(), i = de(null);
  Ft(() => {
    let o = t.current;
    if (!e) {
      i.current && (cancelAnimationFrame(i.current), i.current = null);
      return;
    }
    let p = (n) => {
      if (n.key !== "Tab" || n.altKey || n.ctrlKey || n.metaKey || t !== it)
        return;
      let u = document.activeElement, h = t.current;
      if (!vt(u, h))
        return;
      let s = Yt(Kr(h), {
        tabbable: !0
      }, h);
      s.currentNode = u;
      let l = n.shiftKey ? s.previousNode() : s.nextNode();
      l || (s.currentNode = n.shiftKey ? h[h.length - 1].nextElementSibling : h[0].previousElementSibling, l = n.shiftKey ? s.previousNode() : s.nextNode()), n.preventDefault(), l && At(l, !0);
    }, g = (n) => {
      !it || Lo(it, t) ? (it = t, r.current = n.target) : t === it && !Iu(n.target, t) ? r.current ? r.current.focus() : it && Op(it.current) : t === it && (r.current = n.target);
    }, a = (n) => {
      i.current = requestAnimationFrame(() => {
        t === it && !Iu(document.activeElement, t) && (it = t, r.current = n.target, r.current.focus());
      });
    };
    return document.addEventListener("keydown", p, !1), document.addEventListener("focusin", g, !1), o.forEach(
      (n) => n.addEventListener("focusin", g, !1)
    ), o.forEach(
      (n) => n.addEventListener("focusout", a, !1)
    ), () => {
      document.removeEventListener("keydown", p, !1), document.removeEventListener("focusin", g, !1), o.forEach(
        (n) => n.removeEventListener("focusin", g, !1)
      ), o.forEach(
        (n) => n.removeEventListener("focusout", a, !1)
      );
    };
  }, [
    t,
    e
  ]), xe(() => () => {
    i.current && cancelAnimationFrame(i.current);
  }, [
    i
  ]);
}
function HC(t) {
  for (let e of ni.keys())
    if (vt(t, e.current))
      return !0;
  return !1;
}
function vt(t, e) {
  return e.some(
    (r) => r.contains(t)
  );
}
function Iu(t, e) {
  for (let r of ni.keys())
    if ((r === e || Lo(e, r)) && vt(t, r.current))
      return !0;
  return !1;
}
function Lo(t, e) {
  let r = ni.get(e);
  return r ? r === t ? !0 : Lo(t, r) : !1;
}
function At(t, e = !1) {
  if (t != null && !e)
    try {
      LC(t);
    } catch {
    }
  else if (t != null)
    try {
      t.focus();
    } catch {
    }
}
function Op(t) {
  let e = t[0].previousElementSibling, r = Yt(Kr(t), {
    tabbable: !0
  }, t);
  r.currentNode = e, At(r.nextNode());
}
function UC(t, e) {
  const r = ae.useRef(e);
  xe(() => {
    r.current && (it = t, vt(document.activeElement, it.current) || Op(t.current)), r.current = !1;
  }, []);
}
function WC(t, e, r) {
  const i = de(typeof document < "u" ? document.activeElement : null);
  Ft(() => {
    let o = i.current;
    if (!e)
      return;
    let p = (g) => {
      if (g.key !== "Tab" || g.altKey || g.ctrlKey || g.metaKey)
        return;
      let a = document.activeElement;
      if (!vt(a, t.current))
        return;
      let n = Yt(document.body, {
        tabbable: !0
      });
      n.currentNode = a;
      let u = g.shiftKey ? n.previousNode() : n.nextNode();
      if ((!document.body.contains(o) || o === document.body) && (o = null), (!u || !vt(u, t.current)) && o) {
        n.currentNode = o;
        do
          u = g.shiftKey ? n.previousNode() : n.nextNode();
        while (vt(u, t.current));
        g.preventDefault(), g.stopPropagation(), u ? At(u, !0) : HC(o) ? At(o, !0) : a.blur();
      }
    };
    return r || document.addEventListener("keydown", p, !0), () => {
      r || document.removeEventListener("keydown", p, !0), e && o && vt(document.activeElement, t.current) && requestAnimationFrame(() => {
        document.body.contains(o) && document.activeElement === document.body && At(o);
      });
    };
  }, [
    t,
    e,
    r
  ]);
}
function Yt(t, e, r) {
  let i = e != null && e.tabbable ? VC : NC, o = document.createTreeWalker(t, NodeFilter.SHOW_ELEMENT, {
    acceptNode(p) {
      var g;
      return !(e == null || (g = e.from) === null || g === void 0) && g.contains(p) ? NodeFilter.FILTER_REJECT : p.matches(i) && Ep(p) && (!r || vt(p, r)) && (!(e != null && e.accept) || e.accept(p)) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
    }
  });
  return e != null && e.from && (o.currentNode = e.from), o;
}
class YC {
  getStringForLocale(e, r) {
    let i = this.strings[r];
    i || (i = XC(r, this.strings, this.defaultLocale), this.strings[r] = i);
    let o = i[e];
    if (!o)
      throw new Error(`Could not find intl message ${e} in ${r} locale`);
    return o;
  }
  constructor(e, r = "en-US") {
    this.strings = {
      ...e
    }, this.defaultLocale = r;
  }
}
function XC(t, e, r = "en-US") {
  if (e[t])
    return e[t];
  let i = GC(t);
  if (e[i])
    return e[i];
  for (let o in e)
    if (o.startsWith(i + "-"))
      return e[o];
  return e[r];
}
function GC(t) {
  return Intl.Locale ? new Intl.Locale(t).language : t.split("-")[0];
}
let vs = /* @__PURE__ */ new Map(), ba = !1;
try {
  ba = new Intl.NumberFormat("de-DE", {
    signDisplay: "exceptZero"
  }).resolvedOptions().signDisplay === "exceptZero";
} catch {
}
let fo = !1;
try {
  fo = new Intl.NumberFormat("de-DE", {
    style: "unit",
    unit: "degree"
  }).resolvedOptions().style === "unit";
} catch {
}
const Pp = {
  degree: {
    narrow: {
      default: "\xB0",
      "ja-JP": " \u5EA6",
      "zh-TW": "\u5EA6",
      "sl-SI": " \xB0"
    }
  }
};
class Fo {
  format(e) {
    let r = "";
    if (!ba && this.options.signDisplay != null ? r = KC(this.numberFormatter, this.options.signDisplay, e) : r = this.numberFormatter.format(e), this.options.style === "unit" && !fo) {
      var i;
      let { unit: o, unitDisplay: p = "short", locale: g } = this.resolvedOptions(), a = (i = Pp[o]) === null || i === void 0 ? void 0 : i[p];
      r += a[g] || a.default;
    }
    return r;
  }
  formatToParts(e) {
    return this.numberFormatter.formatToParts(e);
  }
  formatRange(e, r) {
    if (typeof this.numberFormatter.formatRange == "function")
      return this.numberFormatter.formatRange(e, r);
    if (r < e)
      throw new RangeError("End date must be >= start date");
    return `${this.format(e)} \u2013 ${this.format(r)}`;
  }
  formatRangeToParts(e, r) {
    if (typeof this.numberFormatter.formatRangeToParts == "function")
      return this.numberFormatter.formatRangeToParts(e, r);
    if (r < e)
      throw new RangeError("End date must be >= start date");
    let i = this.numberFormatter.formatToParts(e), o = this.numberFormatter.formatToParts(r);
    return [
      ...i.map(
        (p) => ({
          ...p,
          source: "startRange"
        })
      ),
      {
        type: "literal",
        value: " \u2013 ",
        source: "shared"
      },
      ...o.map(
        (p) => ({
          ...p,
          source: "endRange"
        })
      )
    ];
  }
  resolvedOptions() {
    let e = this.numberFormatter.resolvedOptions();
    return !ba && this.options.signDisplay != null && (e = {
      ...e,
      signDisplay: this.options.signDisplay
    }), !fo && this.options.style === "unit" && (e = {
      ...e,
      style: "unit",
      unit: this.options.unit,
      unitDisplay: this.options.unitDisplay
    }), e;
  }
  constructor(e, r = {}) {
    this.numberFormatter = qC(e, r), this.options = r;
  }
}
function qC(t, e = {}) {
  let { numberingSystem: r } = e;
  if (r && t.indexOf("-u-nu-") === -1 && (t = `${t}-u-nu-${r}`), e.style === "unit" && !fo) {
    var i;
    let { unit: g, unitDisplay: a = "short" } = e;
    if (!g)
      throw new Error('unit option must be provided with style: "unit"');
    if (!(!((i = Pp[g]) === null || i === void 0) && i[a]))
      throw new Error(`Unsupported unit ${g} with unitDisplay = ${a}`);
    e = {
      ...e,
      style: "decimal"
    };
  }
  let o = t + (e ? Object.entries(e).sort(
    (g, a) => g[0] < a[0] ? -1 : 1
  ).join() : "");
  if (vs.has(o))
    return vs.get(o);
  let p = new Intl.NumberFormat(t, e);
  return vs.set(o, p), p;
}
function KC(t, e, r) {
  if (e === "auto")
    return t.format(r);
  if (e === "never")
    return t.format(Math.abs(r));
  {
    let i = !1;
    if (e === "always" ? i = r > 0 || Object.is(r, 0) : e === "exceptZero" && (Object.is(r, -0) || Object.is(r, 0) ? r = Math.abs(r) : i = r > 0), i) {
      let o = t.format(-r), p = t.format(r), g = o.replace(p, "").replace(/\u200e|\u061C/, "");
      return [
        ...g
      ].length !== 1 && console.warn("@react-aria/i18n polyfill for NumberFormat signDisplay: Unsupported case"), o.replace(p, "!!!").replace(g, "+").replace("!!!", p);
    } else
      return t.format(r);
  }
}
const Ot = [];
function ZC(t, e) {
  let { onClose: r, shouldCloseOnBlur: i, isOpen: o, isDismissable: p = !1, isKeyboardDismissDisabled: g = !1, shouldCloseOnInteractOutside: a } = t;
  xe(() => (o && Ot.push(e), () => {
    let f = Ot.indexOf(e);
    f >= 0 && Ot.splice(f, 1);
  }), [
    o,
    e
  ]);
  let n = () => {
    Ot[Ot.length - 1] === e && r && r();
  }, u = (f) => {
    (!a || a(f.target)) && Ot[Ot.length - 1] === e && (f.stopPropagation(), f.preventDefault());
  }, h = (f) => {
    (!a || a(f.target)) && (Ot[Ot.length - 1] === e && (f.stopPropagation(), f.preventDefault()), n());
  }, s = (f) => {
    f.key === "Escape" && !g && (f.stopPropagation(), f.preventDefault(), n());
  };
  RC({
    ref: e,
    onInteractOutside: p ? h : null,
    onInteractOutsideStart: u
  });
  let { focusWithinProps: l } = IC({
    isDisabled: !i,
    onBlurWithin: (f) => {
      (!a || a(f.relatedTarget)) && r();
    }
  }), c = (f) => {
    f.target === f.currentTarget && f.preventDefault();
  };
  return {
    overlayProps: {
      onKeyDown: s,
      ...l
    },
    underlayProps: {
      onPointerDown: c
    }
  };
}
const Nn = et(({
  children: t,
  style: e,
  autoFocus: r = !1,
  restoreFocus: i = !0,
  isDismissable: o,
  isOpen: p,
  onClose: g,
  triggerRef: a,
  arrowRef: n,
  arrowStyle: u
}, h) => {
  const s = Ml(), l = Ir(h), {
    overlayProps: c
  } = ZC({
    isDismissable: o,
    isOpen: p,
    onClose: g,
    shouldCloseOnInteractOutside: (f) => {
      var m, d;
      return a.current ? !((d = (m = a.current).contains) != null && d.call(m, f)) : !0;
    }
  }, l);
  return xe(() => {
    if (!p)
      return;
    const f = (m) => {
      const d = m.target;
      if (!!a.current) {
        if (!(a.current instanceof Node)) {
          g();
          return;
        }
        (!(d instanceof Node) || d.contains(a.current)) && g();
      }
    };
    return requestAnimationFrame(() => {
      window.addEventListener("scroll", f, !0);
    }), () => {
      window.removeEventListener("scroll", f, !0);
    };
  }, [p, g, a]), /* @__PURE__ */ x(ot.div, {
    className: "z-popover isolate",
    role: "presentation",
    ref: l,
    style: vi(s, e),
    ...Pl,
    ...c,
    children: /* @__PURE__ */ x(Ro, {
      restoreFocus: i,
      autoFocus: r,
      contain: !1,
      children: t
    })
  });
}), JC = {
  initial: { opacity: 0 },
  animate: { opacity: 1 },
  exit: { opacity: 0 }
};
function Il({
  position: t = "absolute",
  className: e,
  isTransparent: r = !1,
  disableInitialTransition: i,
  ...o
}) {
  return /* @__PURE__ */ x(ot.div, {
    ...o,
    className: ue(e, !r && "bg-black/30", "w-full h-full inset-0 z-10", t),
    "aria-hidden": !0,
    initial: i ? void 0 : {
      opacity: 0
    },
    animate: {
      opacity: 1
    },
    exit: {
      opacity: 0
    },
    ...JC,
    transition: {
      duration: 0.3
    }
  });
}
const Mp = et(({
  children: t,
  autoFocus: e = !1,
  restoreFocus: r = !0,
  isDismissable: i,
  isOpen: o,
  onClose: p
}, g) => {
  const a = Ml(), n = Ir(g);
  return /* @__PURE__ */ ie("div", {
    className: "isolate z-tray fixed inset-0",
    style: a,
    children: [/* @__PURE__ */ x(Il, {
      onClick: () => {
        i && p();
      }
    }, "tray-underlay"), /* @__PURE__ */ x(ot.div, {
      ref: n,
      className: "absolute bottom-0 left-0 right-0 w-full z-20 rounded-t overflow-hidden max-w-375 max-h-tray mx-auto pb-safe-area",
      role: "presentation",
      initial: {
        opacity: 0,
        y: "100%"
      },
      animate: {
        opacity: 1,
        y: 0
      },
      exit: {
        opacity: 0,
        y: "100%"
      },
      transition: {
        type: "tween",
        duration: 0.2
      },
      children: /* @__PURE__ */ x(Ro, {
        restoreFocus: r,
        autoFocus: e,
        contain: !0,
        children: t
      })
    })]
  });
});
function ya(t, e) {
  if (t === e)
    return !0;
  if (!t || !e)
    return !1;
  const r = Object.keys(t), i = Object.keys(e), o = r.length;
  if (i.length !== o)
    return !1;
  for (let p = 0; p < o; p++) {
    const g = r[p];
    if (t[g] !== e[g] || !Object.prototype.hasOwnProperty.call(e, g))
      return !1;
  }
  return !0;
}
const Ap = sr(
  null
);
function QC() {
  return De(Ap);
}
function zo() {
  const {
    data: { i18n: t }
  } = QC();
  return {
    locale: t,
    localeCode: (t == null ? void 0 : t.language) || "en",
    lines: t == null ? void 0 : t.lines
  };
}
function Dp(t, {
  message: e,
  values: r
}) {
  const i = e.match(/\[(.+?)]/), o = r == null ? void 0 : r.count;
  if (i && i[1] && !Number.isNaN(o)) {
    const [p, g] = i, a = g.split("|");
    if (!a.length)
      return e;
    const u = eT(t).select(o);
    let h = a.find((l) => l.startsWith(u));
    h || (h = a[0]);
    const s = h.substring(h.indexOf(" ") + 1);
    return e.replace(p, s);
  }
  return e;
}
const eT = ln((t) => new Intl.PluralRules(t)), we = nm((t) => {
  const {
    message: e,
    values: r
  } = t, {
    lines: i,
    localeCode: o
  } = zo();
  let p = (i == null ? void 0 : i[e]) || e;
  if (!r)
    return /* @__PURE__ */ x(Gt, {
      children: p
    });
  p = Dp(o, {
    message: p,
    values: r
  });
  const g = [], a = [];
  if (Object.entries(r).forEach(([n, u]) => {
    typeof u == "function" ? a.push(n) : tr(u) ? g.push(n) : u != null && (p = p.replace(`:${n}`, `${u}`));
  }), a.length || g.length) {
    const n = [];
    if (a.length) {
      const l = a.join("");
      n.push(`(<[${l}]>.+?<\\/[${l}]>)`);
    }
    if (g.length) {
      const l = g.join("|");
      n.push(`(:(?:${l}))`);
    }
    const u = new RegExp(n.join("|"), "gm"), s = p.split(u).filter(Boolean).map((l, c) => {
      if (l.startsWith("<") && l.endsWith(">")) {
        const f = l.match(/<([a-z]+)>(.+?)<\/([a-z]+)>/);
        if (f) {
          const [, m, d] = f, v = r == null ? void 0 : r[m];
          if (typeof v == "function") {
            const b = v(d);
            return dt(b, {
              key: c
            });
          }
        }
      }
      if (l.startsWith(":")) {
        const f = l.replace(":", ""), m = r == null ? void 0 : r[f];
        if (tr(m))
          return dt(m, {
            key: c
          });
      }
      return l;
    });
    return /* @__PURE__ */ x(Gt, {
      children: s
    });
  }
  return /* @__PURE__ */ x(Gt, {
    children: p
  });
}, tT);
function tT(t, e) {
  const {
    values: r,
    ...i
  } = t, {
    values: o,
    ...p
  } = e;
  return ya(o, r) && ya(i, p);
}
function Ip({
  listbox: t,
  children: e,
  isLoading: r,
  mobileOverlay: i = Mp,
  ...o
}) {
  const p = _C(), {
    floatingWidth: g,
    floatingMinWidth: a = "min-w-180",
    collection: n,
    showEmptyMessage: u,
    state: {
      isOpen: h,
      setIsOpen: s
    },
    positionStyle: l,
    floating: c,
    refs: f
  } = t, m = p ? i : Nn, d = ue(
    "py-4 text-base sm:text-sm outline-none bg-paper shadow-xl border max-h-inherit overflow-x-auto",
    m === Nn && "rounded",
    m === Nn && g === "auto" ? `max-w-288 ${a}` : ""
  ), v = Je(() => {
    let b = 0;
    const y = [];
    return [...n.values()].reduce((w, _) => {
      if (!_.section)
        w.push(dt(_.element, {
          key: _.element.key || _.element.props.value
        }));
      else if (!y.includes(_.section)) {
        const S = dt(_.section, {
          key: _.section.key || b,
          index: b
        });
        w.push(S), y.push(_.section), b++;
      }
      return w;
    }, []);
  }, [n]);
  return /* @__PURE__ */ ie(Tp.Provider, {
    value: t,
    children: [e, Ct && Th(/* @__PURE__ */ x(cr, {
      children: h && (v.length > 0 || u) && /* @__PURE__ */ x(m, {
        triggerRef: f.reference,
        restoreFocus: !0,
        isOpen: h,
        onClose: () => {
          s(!1);
        },
        isDismissable: !0,
        style: l,
        ref: c,
        children: /* @__PURE__ */ x(rT, {
          isLoading: r,
          className: d,
          ...o,
          children: v
        })
      })
    }), Ct)]
  });
}
function rT({
  className: t,
  children: e,
  isLoading: r,
  ...i
}) {
  const {
    role: o,
    listboxId: p,
    virtualFocus: g,
    focusItem: a,
    state: {
      activeIndex: n,
      setActiveIndex: u
    }
  } = kp(), h = de(!0), s = de(null);
  return xe(() => () => u(null), [u]), xe(() => {
    h.current && (n == null && !g ? requestAnimationFrame(() => {
      var l;
      (l = s.current) == null || l.focus({
        preventScroll: !0
      });
    }) : n != null && requestAnimationFrame(() => {
      a("increment", n);
    })), h.current = !1;
  }, [n, a, g]), /* @__PURE__ */ x("div", {
    tabIndex: -1,
    role: o,
    id: p,
    className: t,
    ref: s,
    ...i,
    children: e.length ? e : /* @__PURE__ */ x(iT, {
      isLoading: r
    })
  });
}
function iT({
  isLoading: t
}) {
  return /* @__PURE__ */ x("div", {
    className: "italic px-8 py-4 text-sm text-muted",
    children: t ? /* @__PURE__ */ x(we, {
      message: "Loading..."
    }) : /* @__PURE__ */ x(we, {
      message: "There are no items matching your query"
    })
  });
}
function Rp({
  state: { isOpen: t, setIsOpen: e, selectedIndex: r, activeIndex: i },
  loopFocus: o,
  collection: p,
  focusItem: g
}) {
  return { handleTriggerKeyDown: (u) => {
    if (!(t || !u.currentTarget.contains(u.target))) {
      if (u.key === "ArrowDown")
        return u.preventDefault(), e(!0), g("increment", r != null ? r : 0), !0;
      if (u.key === "ArrowUp")
        return u.preventDefault(), e(!0), g(
          "decrement",
          r != null ? r : p.size - 1
        ), !0;
      if (u.key === "Enter" || u.key === "Space")
        return u.preventDefault(), e(!0), g("increment", r != null ? r : 0), !0;
    }
  }, handleListboxKeyboardNavigation: (u) => {
    const h = Math.max(0, p.size - 1);
    if (!(!t || !u.currentTarget.contains(u.target)))
      switch (u.key) {
        case "ArrowDown":
          return u.preventDefault(), i == null ? g("increment", 0) : i >= h ? o && g("increment", 0) : g("increment", i + 1), !0;
        case "ArrowUp":
          return u.preventDefault(), i == null ? g("decrement", h) : i <= 0 ? o && g("decrement", h) : g("decrement", i - 1), !0;
        case "Home":
          return u.preventDefault(), g("increment", 0), !0;
        case "End":
          return u.preventDefault(), g("decrement", h), !0;
        case "Tab":
          return e(!1), !0;
      }
  } };
}
const bs = /* @__PURE__ */ new Map();
function nT(t) {
  const { localeCode: e } = zo(), r = e + (t ? Object.entries(t).sort((o, p) => o[0] < p[0] ? -1 : 1).join() : "");
  if (bs.has(r))
    return bs.get(r);
  const i = new Intl.Collator(e, t);
  return bs.set(r, i), i;
}
function Lp() {
  const t = nT({ usage: "search", sensitivity: "base" }), e = de({
    search: "",
    timeout: void 0
  }).current, r = (o, p) => {
    let g = p != null ? p : 0;
    for (; g != null; ) {
      const a = o[g], n = a == null ? void 0 : a.slice(0, e.search.length);
      if (n && t.compare(n, e.search) === 0)
        return g;
      if (g < o.length - 1)
        g++;
      else
        return null;
    }
    return null;
  };
  return { findMatchingItem: (o, p, g = 0) => {
    const a = oT(o.key);
    if (!a || o.ctrlKey || o.metaKey)
      return null;
    a === " " && e.search.trim().length > 0 && (o.preventDefault(), o.stopPropagation()), e.search += a;
    let n = r(p, g);
    return n == null && (n = r(p, 0)), clearTimeout(e.timeout), e.timeout = setTimeout(() => {
      e.search = "";
    }, 500), n != null ? n : null;
  } };
}
function oT(t) {
  return t.length === 1 || !/^[A-Z]/i.test(t) ? t : "";
}
function sT(t, { noSSR: e } = { noSSR: !0 }) {
  const r = typeof window < "u" && typeof window.matchMedia == "function", [i, o] = Ae(
    e ? () => r ? window.matchMedia(t).matches : !1 : null
  );
  return xe(() => {
    if (!r)
      return;
    const p = window.matchMedia(t), g = () => {
      o(p.matches);
    };
    return p.addEventListener("change", g), e || g(), () => {
      p.removeEventListener("change", g);
    };
  }, [r, t, e]), typeof window > "u" ? null : i;
}
function jo(t) {
  return sT("(max-width: 768px)", t);
}
const aT = et((t, e) => {
  const {
    children: [r, i],
    floatingWidth: o = "auto"
  } = t, p = yt(), g = jo(), a = Cp({
    ...t,
    floatingWidth: g ? o : "auto",
    role: "menu",
    loopFocus: !0,
    children: i.props.children
  }, e), {
    state: {
      isOpen: n,
      setIsOpen: u,
      activeIndex: h
    },
    listboxId: s,
    focusItem: l,
    listContent: c,
    reference: f
  } = a, {
    handleTriggerKeyDown: m,
    handleListboxKeyboardNavigation: d
  } = Rp(a), {
    findMatchingItem: v
  } = Lp();
  return /* @__PURE__ */ x(Ip, {
    listbox: a,
    "aria-labelledby": p,
    onKeyDownCapture: (b) => {
      if (!n)
        return;
      const y = v(b, c, h);
      y && l("increment", y);
    },
    onKeyDown: d,
    children: dt(r, {
      id: p,
      "aria-expanded": n ? "true" : "false",
      "aria-haspopup": "menu",
      "aria-controls": n ? s : void 0,
      ref: f,
      onKeyDown: m,
      onClick: Mt((b) => {
        var y, w;
        (w = (y = r.props) == null ? void 0 : y.onClick) == null || w.call(y, b), u(!n);
      })
    })
  });
});
function lT({
  children: t
}) {
  return t;
}
function cT({
  item: t,
  button: e
}) {
  return /* @__PURE__ */ ie(aT, {
    children: [e, /* @__PURE__ */ x(lT, {
      children: (t.menuItems || []).map((r) => /* @__PURE__ */ x(Io, {
        value: r.label,
        onSelected: () => {
          r.action(O().editor);
        },
        children: r.label
      }, r.label))
    })]
  });
}
const Me = et(({
  children: t,
  size: e = "md",
  iconSize: r = e || "md",
  variant: i = "text",
  radius: o = "rounded-full",
  className: p,
  padding: g,
  equalWidth: a = !0,
  ...n
}, u) => {
  const h = ue(kl(e, {
    padding: g,
    equalWidth: a,
    variant: i
  }), p);
  return /* @__PURE__ */ x(Bt, {
    ...n,
    ref: u,
    radius: o,
    variant: i,
    className: h,
    children: ae.cloneElement(t, {
      size: r
    })
  });
});
function uT({
  icon: t,
  className: e,
  size: r
}) {
  let i;
  return ae.isValidElement(t) ? i = ae.cloneElement(t, {
    className: "svg-iconEl"
  }) : typeof t == "string" ? i = /* @__PURE__ */ x("img", {
    className: "w-font h-font",
    src: t,
    alt: ""
  }) : Array.isArray(t) ? i = ae.createElement(db(t), {
    size: r
  }) : i = ae.createElement(t, {
    size: r
  }), /* @__PURE__ */ x("span", {
    className: ue(e, "leading-none"),
    children: i
  });
}
const Rl = ae.memo(uT);
function wa({
  value: t
}) {
  return t ? typeof t == "string" ? /* @__PURE__ */ x(Gt, {
    children: t
  }) : /* @__PURE__ */ x(we, {
    ...t
  }) : null;
}
function hT({
  item: t
}) {
  const e = t.label ? /* @__PURE__ */ x(dT, {
    item: t
  }) : /* @__PURE__ */ x(fT, {
    item: t
  });
  return t.menuItems ? /* @__PURE__ */ x(cT, {
    item: t,
    button: e
  }) : ae.cloneElement(e, {
    onClick: () => {
      var r;
      (r = t.action) == null || r.call(t, O().editor);
    }
  });
}
const fT = et(({
  item: t,
  ...e
}, r) => /* @__PURE__ */ x(Me, {
  ref: r,
  radius: "rounded-full",
  size: "sm",
  ...e,
  children: /* @__PURE__ */ x(Rl, {
    icon: t.icon
  })
})), dT = et(({
  item: t,
  ...e
}, r) => /* @__PURE__ */ x(Qe, {
  ref: r,
  radius: "rounded-full",
  size: "xs",
  color: t.buttonColor || "primary",
  variant: t.buttonVariant || "flat",
  startIcon: t.icon && /* @__PURE__ */ x(Rl, {
    icon: t.icon
  }),
  ...e,
  children: /* @__PURE__ */ x(wa, {
    value: t.label
  })
}));
function Bo({
  children: t,
  color: e,
  variant: r,
  radius: i,
  size: o,
  className: p,
  value: g,
  onChange: a,
  multiple: n,
  disabled: u
}) {
  const h = (c) => g === void 0 ? !1 : n ? g.includes(c) : c === g, s = (c) => {
    const f = [...g], m = g.indexOf(c);
    return m > -1 ? f.splice(m, 1) : f.push(c), f;
  }, l = ae.Children.map(t, (c, f) => {
    if (ae.isValidElement(c)) {
      const m = h(c.props.value), d = m ? "primary" : e;
      return ae.cloneElement(c, {
        color: m ? "primary" : e,
        variant: r,
        size: o,
        radius: null,
        disabled: c.props.disabled || u,
        ...c.props,
        onClick: (v) => {
          c.props.onClick && c.props.onClick(v), a && (n ? a == null || a(s(c.props.value)) : a == null || a(c.props.value));
        },
        className: ue(
          c.props.className,
          m ? "z-20" : "z-10",
          pT(f, t, i, d)
        )
      });
    }
  });
  return /* @__PURE__ */ x("div", {
    className: ue(i, "inline-flex isolate", p),
    children: l
  });
}
function pT(t, e, r, i) {
  return t === 0 ? ue(r, "rounded-tr-none rounded-br-none", !i && "border-r-transparent disabled:border-r-transparent") : t === e.length - 1 ? ue(r, "rounded-tl-none rounded-bl-none -ml-1") : ue("rounded-none -ml-1", !i && "border-r-transparent disabled:border-r-transparent");
}
const gT = me(/* @__PURE__ */ x("path", {
  d: "M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z"
}), "UndoOutlined"), mT = me(/* @__PURE__ */ x("path", {
  d: "M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z"
}), "RedoOutlined");
function vT() {
  const t = oe((r) => r.history.canUndo), e = oe((r) => r.history.canRedo);
  return /* @__PURE__ */ ie(Bo, {
    variant: "outline",
    children: [/* @__PURE__ */ x(Me, {
      equalWidth: !1,
      size: "xs",
      padding: "pl-12 pr-10",
      radius: "rounded-full",
      disabled: !t,
      onClick: () => {
        I().history.undo();
      },
      children: /* @__PURE__ */ x(gT, {})
    }), /* @__PURE__ */ x(Me, {
      equalWidth: !1,
      padding: "pl-10 pr-12",
      size: "xs",
      radius: "rounded-full",
      disabled: !e,
      onClick: () => {
        I().history.redo();
      },
      children: /* @__PURE__ */ x(mT, {})
    })]
  });
}
const bT = me(/* @__PURE__ */ x("path", {
  d: "M19 13H5v-2h14v2z"
}), "RemoveOutlined"), yT = me(/* @__PURE__ */ x("path", {
  d: "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"
}), "AddOutlined");
function wT() {
  var r, i, o;
  const t = oe((p) => p.zoom) || 1;
  return ((r = oe((p) => {
    var g, a;
    return (a = (g = p.config.tools) == null ? void 0 : g.zoom) == null ? void 0 : a.allowUserZoom;
  })) != null ? r : !0) ? /* @__PURE__ */ ie("div", {
    className: "flex items-center select-none",
    children: [/* @__PURE__ */ x(Me, {
      size: "sm",
      disabled: !((i = I().zoom) != null && i.canZoomOut()),
      onClick: () => {
        I().zoom.zoomOut(I().zoom.step);
      },
      children: /* @__PURE__ */ x(bT, {})
    }), /* @__PURE__ */ ie("div", {
      className: "w-[4ch] text-sm text-center",
      children: [Math.round(t * 100), "%"]
    }), /* @__PURE__ */ x(Me, {
      size: "sm",
      disabled: !((o = I().zoom) != null && o.canZoomIn()),
      onClick: () => {
        I().zoom.zoomIn(I().zoom.step);
      },
      children: /* @__PURE__ */ x(yT, {})
    })]
  }) : null;
}
function ys({
  item: t
}) {
  switch (t.type) {
    case "undoWidget":
      return /* @__PURE__ */ x(vT, {});
    case "zoomWidget":
      return /* @__PURE__ */ x(wT, {});
    case "button":
      return /* @__PURE__ */ x(hT, {
        item: t
      });
    case "image":
      return /* @__PURE__ */ x("img", {
        className: "h-30 object-cover",
        src: ct(t.src),
        alt: ""
      });
    default:
      return null;
  }
}
const or = me(/* @__PURE__ */ x("path", {
  d: "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"
}), "CloseOutlined");
function No() {
  var i;
  let t = oe((o) => {
    var p;
    return ((p = o.config.ui) == null ? void 0 : p.mode) === Ya.OVERLAY;
  });
  const { width: e } = oe((o) => o.stageSize), r = e <= 700;
  return r && ((i = O().config.ui) == null ? void 0 : i.forceOverlayModeOnMobile) && (t = !0), { isModal: t, isMobile: r };
}
function xT() {
  var n;
  const {
    isModal: t,
    isMobile: e
  } = No(), r = (n = oe((u) => {
    var h;
    return (h = u.config.ui) == null ? void 0 : h.allowEditorClose;
  })) != null ? n : !0, i = oe((u) => {
    var h, s;
    return (s = (h = u.config.ui) == null ? void 0 : h.menubar) == null ? void 0 : s.items;
  }), {
    left: o,
    center: p,
    right: g
  } = Je(() => _T(i || [], e), [i, e]), a = t && e && r && /* @__PURE__ */ x(Me, {
    size: "sm",
    className: "ml-10",
    onClick: () => {
      O().editor.close();
    },
    children: /* @__PURE__ */ x(or, {})
  });
  return /* @__PURE__ */ ie(ot.div, {
    className: fp,
    ...dp,
    children: [/* @__PURE__ */ x("div", {
      className: "mr-auto flex items-center gap-8",
      children: o.map((u, h) => /* @__PURE__ */ x(ys, {
        item: u
      }, h))
    }), /* @__PURE__ */ x("div", {
      className: "flex items-center gap-10",
      children: p.map((u, h) => /* @__PURE__ */ x(ys, {
        item: u
      }, h))
    }), /* @__PURE__ */ x("div", {
      className: "ml-auto flex items-center gap-8",
      children: g.map((u, h) => /* @__PURE__ */ x(ys, {
        item: u
      }, h))
    }), a]
  });
}
function _T(t, e) {
  const r = {
    left: [],
    center: [],
    right: []
  };
  (t || []).filter((o) => !e && !o.mobileOnly || e && !o.desktopOnly).forEach((o) => {
    var p, g, a;
    o.align === "left" ? r.left.push({
      ...o,
      position: (p = o.position) != null ? p : 1
    }) : o.align === "right" ? r.right.push({
      ...o,
      position: (g = o.position) != null ? g : 1
    }) : r.center.push({
      ...o,
      position: (a = o.position) != null ? a : 1
    });
  });
  const i = Object.entries(r).map(([o, p]) => [o, p.sort((g, a) => {
    var n, u;
    return ((n = g.position) != null ? n : 0) - ((u = a.position) != null ? u : 0);
  })]);
  return Object.fromEntries(i);
}
function ST() {
  const t = oe((r) => {
    var i;
    return (i = r.crop.zoneRect) == null ? void 0 : i.width;
  }) || 1, e = oe((r) => {
    var i;
    return (i = r.crop.zoneRect) == null ? void 0 : i.height;
  }) || 1;
  return /* @__PURE__ */ x("div", {
    className: "text-sm",
    children: `${t}x${e}`
  });
}
function CT() {
  const t = oe((e) => e.activeTool);
  return /* @__PURE__ */ ie(ot.div, {
    className: fp,
    ...dp,
    children: [/* @__PURE__ */ x(TT, {}), kT(t), /* @__PURE__ */ x(ET, {})]
  });
}
function TT() {
  const {
    isMobile: t
  } = No(), e = oe((r) => r.dirty);
  return t ? /* @__PURE__ */ x(Me, {
    size: "sm",
    onClick: () => {
      O().cancelChanges();
    },
    children: /* @__PURE__ */ x(or, {})
  }) : /* @__PURE__ */ x(Qe, {
    variant: "outline",
    size: "xs",
    startIcon: /* @__PURE__ */ x(or, {}),
    radius: "rounded-full",
    onClick: () => {
      O().cancelChanges();
    },
    children: e ? /* @__PURE__ */ x(we, {
      message: "Cancel"
    }) : /* @__PURE__ */ x(we, {
      message: "Close"
    })
  });
}
function kT(t) {
  var r, i, o;
  const e = /* @__PURE__ */ x("div", {
    className: "capitalize text-sm",
    children: t
  });
  switch (t) {
    case Pe.CROP:
      return ((o = (i = (r = O().config.tools) == null ? void 0 : r.crop) == null ? void 0 : i.allowCustomRatio) != null ? o : !0) ? /* @__PURE__ */ x(ST, {}) : e;
    default:
      return e;
  }
}
function ET() {
  const {
    isMobile: t
  } = No(), e = oe((r) => r.dirty);
  return t ? /* @__PURE__ */ x(Me, {
    size: "sm",
    disabled: !e,
    onClick: () => {
      O().applyChanges();
    },
    children: /* @__PURE__ */ x(ga, {})
  }) : /* @__PURE__ */ x(Qe, {
    variant: "flat",
    color: "primary",
    size: "xs",
    disabled: !e,
    startIcon: /* @__PURE__ */ x(ga, {}),
    radius: "rounded-full",
    onClick: () => {
      O().applyChanges();
    },
    children: /* @__PURE__ */ x(we, {
      message: "Apply"
    })
  });
}
function Ru() {
  const t = oe((e) => e.activeTool);
  return /* @__PURE__ */ x(cr, {
    initial: !1,
    children: t ? /* @__PURE__ */ x(CT, {}, "activeToolbar") : /* @__PURE__ */ x(xT, {}, "mainToolbar")
  });
}
const OT = {
  newCanvas: ce("Loading Canvas"),
  mainImage: ce("Loading Image"),
  state: ce("Loading State"),
  merge: ce("Processing Image")
};
function PT() {
  const [t, e] = Ae(!1);
  return xe(() => {
    oe.subscribe((r) => r.loading, (r) => {
      r && e(r);
    });
  }, []), /* @__PURE__ */ x(cr, {
    children: t && /* @__PURE__ */ x(ot.div, {
      initial: {
        y: "60%",
        opacity: 0
      },
      animate: {
        y: 0,
        opacity: 1
      },
      exit: {
        y: "-60%",
        opacity: 0
      },
      transition: {
        type: "tween",
        duration: 0.3
      },
      onAnimationComplete: () => {
        setTimeout(() => {
          e(!1);
        }, 400);
      },
      className: "absolute z-loading-indicator inset-0 m-auto p-6 w-144 h-32 text-center text-sm bg-paper rounded-full shadow-lg",
      children: /* @__PURE__ */ x(we, {
        ...OT[t]
      })
    })
  });
}
function MT(t, e, r) {
  return Math.max(e, Math.min(t, r));
}
const We = {
  toVector(t, e) {
    return t === void 0 && (t = e), Array.isArray(t) ? t : [t, t];
  },
  add(t, e) {
    return [t[0] + e[0], t[1] + e[1]];
  },
  sub(t, e) {
    return [t[0] - e[0], t[1] - e[1]];
  },
  addTo(t, e) {
    t[0] += e[0], t[1] += e[1];
  },
  subTo(t, e) {
    t[0] -= e[0], t[1] -= e[1];
  }
};
function Lu(t, e, r) {
  return e === 0 || Math.abs(e) === 1 / 0 ? Math.pow(t, r * 5) : t * e * r / (e + r * t);
}
function Fu(t, e, r, i = 0.15) {
  return i === 0 ? MT(t, e, r) : t < e ? -Lu(e - t, r - e, i) + e : t > r ? +Lu(t - r, r - e, i) + r : t;
}
function AT(t, [e, r], [i, o]) {
  const [[p, g], [a, n]] = t;
  return [Fu(e, p, g, i), Fu(r, a, n, o)];
}
function qe(t, e, r) {
  return e in t ? Object.defineProperty(t, e, {
    value: r,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : t[e] = r, t;
}
function zu(t, e) {
  var r = Object.keys(t);
  if (Object.getOwnPropertySymbols) {
    var i = Object.getOwnPropertySymbols(t);
    e && (i = i.filter(function(o) {
      return Object.getOwnPropertyDescriptor(t, o).enumerable;
    })), r.push.apply(r, i);
  }
  return r;
}
function ze(t) {
  for (var e = 1; e < arguments.length; e++) {
    var r = arguments[e] != null ? arguments[e] : {};
    e % 2 ? zu(Object(r), !0).forEach(function(i) {
      qe(t, i, r[i]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(r)) : zu(Object(r)).forEach(function(i) {
      Object.defineProperty(t, i, Object.getOwnPropertyDescriptor(r, i));
    });
  }
  return t;
}
const Fp = {
  pointer: {
    start: "down",
    change: "move",
    end: "up"
  },
  mouse: {
    start: "down",
    change: "move",
    end: "up"
  },
  touch: {
    start: "start",
    change: "move",
    end: "end"
  },
  gesture: {
    start: "start",
    change: "change",
    end: "end"
  }
};
function ju(t) {
  return t ? t[0].toUpperCase() + t.slice(1) : "";
}
const DT = ["enter", "leave"];
function IT(t = !1, e) {
  return t && !DT.includes(e);
}
function RT(t, e = "", r = !1) {
  const i = Fp[t], o = i && i[e] || e;
  return "on" + ju(t) + ju(o) + (IT(r, o) ? "Capture" : "");
}
const LT = ["gotpointercapture", "lostpointercapture"];
function FT(t) {
  let e = t.substring(2).toLowerCase();
  const r = !!~e.indexOf("passive");
  r && (e = e.replace("passive", ""));
  const i = LT.includes(e) ? "capturecapture" : "capture", o = !!~e.indexOf(i);
  return o && (e = e.replace("capture", "")), {
    device: e,
    capture: o,
    passive: r
  };
}
function zT(t, e = "") {
  const r = Fp[t], i = r && r[e] || e;
  return t + i;
}
function Vo(t) {
  return "touches" in t;
}
function zp(t) {
  return Vo(t) ? "touch" : "pointerType" in t ? t.pointerType : "mouse";
}
function jT(t) {
  return Array.from(t.touches).filter((e) => {
    var r, i;
    return e.target === t.currentTarget || ((r = t.currentTarget) === null || r === void 0 || (i = r.contains) === null || i === void 0 ? void 0 : i.call(r, e.target));
  });
}
function BT(t) {
  return t.type === "touchend" || t.type === "touchcancel" ? t.changedTouches : t.targetTouches;
}
function jp(t) {
  return Vo(t) ? BT(t)[0] : t;
}
function xa(t, e) {
  const r = e.clientX - t.clientX, i = e.clientY - t.clientY, o = (e.clientX + t.clientX) / 2, p = (e.clientY + t.clientY) / 2, g = Math.hypot(r, i);
  return {
    angle: -(Math.atan2(r, i) * 180) / Math.PI,
    distance: g,
    origin: [o, p]
  };
}
function NT(t) {
  return jT(t).map((e) => e.identifier);
}
function Bu(t, e) {
  const [r, i] = Array.from(t.touches).filter((o) => e.includes(o.identifier));
  return xa(r, i);
}
function ws(t) {
  const e = jp(t);
  return Vo(t) ? e.identifier : e.pointerId;
}
function Nu(t) {
  const e = jp(t);
  return [e.clientX, e.clientY];
}
const Vu = 40, $u = 800;
function VT(t) {
  let {
    deltaX: e,
    deltaY: r,
    deltaMode: i
  } = t;
  return i === 1 ? (e *= Vu, r *= Vu) : i === 2 && (e *= $u, r *= $u), [e, r];
}
function $T(t) {
  const e = {};
  if ("buttons" in t && (e.buttons = t.buttons), "shiftKey" in t) {
    const {
      shiftKey: r,
      altKey: i,
      metaKey: o,
      ctrlKey: p
    } = t;
    Object.assign(e, {
      shiftKey: r,
      altKey: i,
      metaKey: o,
      ctrlKey: p
    });
  }
  return e;
}
function po(t, ...e) {
  return typeof t == "function" ? t(...e) : t;
}
function HT() {
}
function UT(...t) {
  return t.length === 0 ? HT : t.length === 1 ? t[0] : function() {
    let e;
    for (const r of t)
      e = r.apply(this, arguments) || e;
    return e;
  };
}
function Hu(t, e) {
  return Object.assign({}, e, t || {});
}
const WT = 32;
class Bp {
  constructor(e, r, i) {
    this.ctrl = e, this.args = r, this.key = i, this.state || (this.state = {}, this.computeValues([0, 0]), this.computeInitial(), this.init && this.init(), this.reset());
  }
  get state() {
    return this.ctrl.state[this.key];
  }
  set state(e) {
    this.ctrl.state[this.key] = e;
  }
  get shared() {
    return this.ctrl.state.shared;
  }
  get eventStore() {
    return this.ctrl.gestureEventStores[this.key];
  }
  get timeoutStore() {
    return this.ctrl.gestureTimeoutStores[this.key];
  }
  get config() {
    return this.ctrl.config[this.key];
  }
  get sharedConfig() {
    return this.ctrl.config.shared;
  }
  get handler() {
    return this.ctrl.handlers[this.key];
  }
  reset() {
    const {
      state: e,
      shared: r,
      ingKey: i,
      args: o
    } = this;
    r[i] = e._active = e.active = e._blocked = e._force = !1, e._step = [!1, !1], e.intentional = !1, e._movement = [0, 0], e._distance = [0, 0], e._direction = [0, 0], e._delta = [0, 0], e._bounds = [[-1 / 0, 1 / 0], [-1 / 0, 1 / 0]], e.args = o, e.axis = void 0, e.memo = void 0, e.elapsedTime = 0, e.direction = [0, 0], e.distance = [0, 0], e.overflow = [0, 0], e._movementBound = [!1, !1], e.velocity = [0, 0], e.movement = [0, 0], e.delta = [0, 0], e.timeStamp = 0;
  }
  start(e) {
    const r = this.state, i = this.config;
    r._active || (this.reset(), this.computeInitial(), r._active = !0, r.target = e.target, r.currentTarget = e.currentTarget, r.lastOffset = i.from ? po(i.from, r) : r.offset, r.offset = r.lastOffset), r.startTime = r.timeStamp = e.timeStamp;
  }
  computeValues(e) {
    const r = this.state;
    r._values = e, r.values = this.config.transform(e);
  }
  computeInitial() {
    const e = this.state;
    e._initial = e._values, e.initial = e.values;
  }
  compute(e) {
    const {
      state: r,
      config: i,
      shared: o
    } = this;
    r.args = this.args;
    let p = 0;
    if (e && (r.event = e, i.preventDefault && e.cancelable && r.event.preventDefault(), r.type = e.type, o.touches = this.ctrl.pointerIds.size || this.ctrl.touchIds.size, o.locked = !!document.pointerLockElement, Object.assign(o, $T(e)), o.down = o.pressed = o.buttons % 2 === 1 || o.touches > 0, p = e.timeStamp - r.timeStamp, r.timeStamp = e.timeStamp, r.elapsedTime = r.timeStamp - r.startTime), r._active) {
      const S = r._delta.map(Math.abs);
      We.addTo(r._distance, S);
    }
    this.axisIntent && this.axisIntent(e);
    const [g, a] = r._movement, [n, u] = i.threshold, {
      _step: h,
      values: s
    } = r;
    if (i.hasCustomTransform ? (h[0] === !1 && (h[0] = Math.abs(g) >= n && s[0]), h[1] === !1 && (h[1] = Math.abs(a) >= u && s[1])) : (h[0] === !1 && (h[0] = Math.abs(g) >= n && Math.sign(g) * n), h[1] === !1 && (h[1] = Math.abs(a) >= u && Math.sign(a) * u)), r.intentional = h[0] !== !1 || h[1] !== !1, !r.intentional)
      return;
    const l = [0, 0];
    if (i.hasCustomTransform) {
      const [S, T] = s;
      l[0] = h[0] !== !1 ? S - h[0] : 0, l[1] = h[1] !== !1 ? T - h[1] : 0;
    } else
      l[0] = h[0] !== !1 ? g - h[0] : 0, l[1] = h[1] !== !1 ? a - h[1] : 0;
    this.restrictToAxis && !r._blocked && this.restrictToAxis(l);
    const c = r.offset, f = r._active && !r._blocked || r.active;
    f && (r.first = r._active && !r.active, r.last = !r._active && r.active, r.active = o[this.ingKey] = r._active, e && (r.first && ("bounds" in i && (r._bounds = po(i.bounds, r)), this.setup && this.setup()), r.movement = l, this.computeOffset()));
    const [m, d] = r.offset, [[v, b], [y, w]] = r._bounds;
    r.overflow = [m < v ? -1 : m > b ? 1 : 0, d < y ? -1 : d > w ? 1 : 0], r._movementBound[0] = r.overflow[0] ? r._movementBound[0] === !1 ? r._movement[0] : r._movementBound[0] : !1, r._movementBound[1] = r.overflow[1] ? r._movementBound[1] === !1 ? r._movement[1] : r._movementBound[1] : !1;
    const _ = r._active ? i.rubberband || [0, 0] : [0, 0];
    if (r.offset = AT(r._bounds, r.offset, _), r.delta = We.sub(r.offset, c), this.computeMovement(), f && (!r.last || p > WT)) {
      r.delta = We.sub(r.offset, c);
      const S = r.delta.map(Math.abs);
      We.addTo(r.distance, S), r.direction = r.delta.map(Math.sign), r._direction = r._delta.map(Math.sign), !r.first && p > 0 && (r.velocity = [S[0] / p, S[1] / p]);
    }
  }
  emit() {
    const e = this.state, r = this.shared, i = this.config;
    if (e._active || this.clean(), (e._blocked || !e.intentional) && !e._force && !i.triggerAllEvents)
      return;
    const o = this.handler(ze(ze(ze({}, r), e), {}, {
      [this.aliasKey]: e.values
    }));
    o !== void 0 && (e.memo = o);
  }
  clean() {
    this.eventStore.clean(), this.timeoutStore.clean();
  }
}
function YT([t, e], r) {
  const i = Math.abs(t), o = Math.abs(e);
  if (i > o && i > r)
    return "x";
  if (o > i && o > r)
    return "y";
}
class XT extends Bp {
  constructor(...e) {
    super(...e), qe(this, "aliasKey", "xy");
  }
  reset() {
    super.reset(), this.state.axis = void 0;
  }
  init() {
    this.state.offset = [0, 0], this.state.lastOffset = [0, 0];
  }
  computeOffset() {
    this.state.offset = We.add(this.state.lastOffset, this.state.movement);
  }
  computeMovement() {
    this.state.movement = We.sub(this.state.offset, this.state.lastOffset);
  }
  axisIntent(e) {
    const r = this.state, i = this.config;
    if (!r.axis && e) {
      const o = typeof i.axisThreshold == "object" ? i.axisThreshold[zp(e)] : i.axisThreshold;
      r.axis = YT(r._movement, o);
    }
    r._blocked = (i.lockDirection || !!i.axis) && !r.axis || !!i.axis && i.axis !== r.axis;
  }
  restrictToAxis(e) {
    if (this.config.axis || this.config.lockDirection)
      switch (this.state.axis) {
        case "x":
          e[1] = 0;
          break;
        case "y":
          e[0] = 0;
          break;
      }
  }
}
const GT = (t) => t, Uu = 0.15, Np = {
  enabled(t = !0) {
    return t;
  },
  eventOptions(t, e, r) {
    return ze(ze({}, r.shared.eventOptions), t);
  },
  preventDefault(t = !1) {
    return t;
  },
  triggerAllEvents(t = !1) {
    return t;
  },
  rubberband(t = 0) {
    switch (t) {
      case !0:
        return [Uu, Uu];
      case !1:
        return [0, 0];
      default:
        return We.toVector(t);
    }
  },
  from(t) {
    if (typeof t == "function")
      return t;
    if (t != null)
      return We.toVector(t);
  },
  transform(t, e, r) {
    const i = t || r.shared.transform;
    return this.hasCustomTransform = !!i, i || GT;
  },
  threshold(t) {
    return We.toVector(t, 0);
  }
}, qT = 0, fn = ze(ze({}, Np), {}, {
  axis(t, e, {
    axis: r
  }) {
    if (this.lockDirection = r === "lock", !this.lockDirection)
      return r;
  },
  axisThreshold(t = qT) {
    return t;
  },
  bounds(t = {}) {
    if (typeof t == "function")
      return (p) => fn.bounds(t(p));
    if ("current" in t)
      return () => t.current;
    if (typeof HTMLElement == "function" && t instanceof HTMLElement)
      return t;
    const {
      left: e = -1 / 0,
      right: r = 1 / 0,
      top: i = -1 / 0,
      bottom: o = 1 / 0
    } = t;
    return [[e, r], [i, o]];
  }
}), Mn = 10, Wu = {
  ArrowRight: (t = 1) => [Mn * t, 0],
  ArrowLeft: (t = 1) => [-Mn * t, 0],
  ArrowUp: (t = 1) => [0, -Mn * t],
  ArrowDown: (t = 1) => [0, Mn * t]
};
class KT extends XT {
  constructor(...e) {
    super(...e), qe(this, "ingKey", "dragging");
  }
  reset() {
    super.reset();
    const e = this.state;
    e._pointerId = void 0, e._pointerActive = !1, e._keyboardActive = !1, e._preventScroll = !1, e._delayed = !1, e.swipe = [0, 0], e.tap = !1, e.canceled = !1, e.cancel = this.cancel.bind(this);
  }
  setup() {
    const e = this.state;
    if (e._bounds instanceof HTMLElement) {
      const r = e._bounds.getBoundingClientRect(), i = e.currentTarget.getBoundingClientRect(), o = {
        left: r.left - i.left + e.offset[0],
        right: r.right - i.right + e.offset[0],
        top: r.top - i.top + e.offset[1],
        bottom: r.bottom - i.bottom + e.offset[1]
      };
      e._bounds = fn.bounds(o);
    }
  }
  cancel() {
    const e = this.state;
    e.canceled || (e.canceled = !0, e._active = !1, setTimeout(() => {
      this.compute(), this.emit();
    }, 0));
  }
  setActive() {
    this.state._active = this.state._pointerActive || this.state._keyboardActive;
  }
  clean() {
    this.pointerClean(), this.state._pointerActive = !1, this.state._keyboardActive = !1, super.clean();
  }
  pointerDown(e) {
    const r = this.config, i = this.state;
    if (e.buttons != null && (Array.isArray(r.pointerButtons) ? !r.pointerButtons.includes(e.buttons) : r.pointerButtons !== -1 && r.pointerButtons !== e.buttons))
      return;
    const o = this.ctrl.setEventIds(e);
    r.pointerCapture && e.target.setPointerCapture(e.pointerId), !(o && o.size > 1 && i._pointerActive) && (this.start(e), this.setupPointer(e), i._pointerId = ws(e), i._pointerActive = !0, this.computeValues(Nu(e)), this.computeInitial(), r.preventScrollAxis && zp(e) !== "mouse" ? (i._active = !1, this.setupScrollPrevention(e)) : r.delay > 0 ? (this.setupDelayTrigger(e), r.triggerAllEvents && (this.compute(e), this.emit())) : this.startPointerDrag(e));
  }
  startPointerDrag(e) {
    const r = this.state;
    r._active = !0, r._preventScroll = !0, r._delayed = !1, this.compute(e), this.emit();
  }
  pointerMove(e) {
    const r = this.state, i = this.config;
    if (!r._pointerActive || r.type === e.type && e.timeStamp === r.timeStamp)
      return;
    const o = ws(e);
    if (r._pointerId !== void 0 && o !== r._pointerId)
      return;
    const p = Nu(e);
    if (document.pointerLockElement === e.target ? r._delta = [e.movementX, e.movementY] : (r._delta = We.sub(p, r._values), this.computeValues(p)), We.addTo(r._movement, r._delta), this.compute(e), r._delayed && r.intentional) {
      this.timeoutStore.remove("dragDelay"), r.active = !1, this.startPointerDrag(e);
      return;
    }
    if (i.preventScrollAxis && !r._preventScroll)
      if (r.axis)
        if (r.axis === i.preventScrollAxis || i.preventScrollAxis === "xy") {
          r._active = !1, this.clean();
          return;
        } else {
          this.timeoutStore.remove("startPointerDrag"), this.startPointerDrag(e);
          return;
        }
      else
        return;
    this.emit();
  }
  pointerUp(e) {
    this.ctrl.setEventIds(e);
    try {
      this.config.pointerCapture && e.target.hasPointerCapture(e.pointerId) && e.target.releasePointerCapture(e.pointerId);
    } catch {
    }
    const r = this.state, i = this.config;
    if (!r._active || !r._pointerActive)
      return;
    const o = ws(e);
    if (r._pointerId !== void 0 && o !== r._pointerId)
      return;
    this.state._pointerActive = !1, this.setActive(), this.compute(e);
    const [p, g] = r._distance;
    if (r.tap = p <= i.tapsThreshold && g <= i.tapsThreshold, r.tap && i.filterTaps)
      r._force = !0;
    else {
      const [a, n] = r.direction, [u, h] = r.velocity, [s, l] = r.movement, [c, f] = i.swipe.velocity, [m, d] = i.swipe.distance, v = i.swipe.duration;
      r.elapsedTime < v && (Math.abs(u) > c && Math.abs(s) > m && (r.swipe[0] = a), Math.abs(h) > f && Math.abs(l) > d && (r.swipe[1] = n));
    }
    this.emit();
  }
  pointerClick(e) {
    !this.state.tap && e.detail > 0 && (e.preventDefault(), e.stopPropagation());
  }
  setupPointer(e) {
    const r = this.config, i = r.device;
    r.pointerLock && e.currentTarget.requestPointerLock(), r.pointerCapture || (this.eventStore.add(this.sharedConfig.window, i, "change", this.pointerMove.bind(this)), this.eventStore.add(this.sharedConfig.window, i, "end", this.pointerUp.bind(this)), this.eventStore.add(this.sharedConfig.window, i, "cancel", this.pointerUp.bind(this)));
  }
  pointerClean() {
    this.config.pointerLock && document.pointerLockElement === this.state.currentTarget && document.exitPointerLock();
  }
  preventScroll(e) {
    this.state._preventScroll && e.cancelable && e.preventDefault();
  }
  setupScrollPrevention(e) {
    this.state._preventScroll = !1, ZT(e);
    const r = this.eventStore.add(this.sharedConfig.window, "touch", "change", this.preventScroll.bind(this), {
      passive: !1
    });
    this.eventStore.add(this.sharedConfig.window, "touch", "end", r), this.eventStore.add(this.sharedConfig.window, "touch", "cancel", r), this.timeoutStore.add("startPointerDrag", this.startPointerDrag.bind(this), this.config.preventScrollDelay, e);
  }
  setupDelayTrigger(e) {
    this.state._delayed = !0, this.timeoutStore.add("dragDelay", () => {
      this.state._step = [0, 0], this.startPointerDrag(e);
    }, this.config.delay);
  }
  keyDown(e) {
    const r = Wu[e.key];
    if (r) {
      const i = this.state, o = e.shiftKey ? 10 : e.altKey ? 0.1 : 1;
      this.start(e), i._delta = r(o), i._keyboardActive = !0, We.addTo(i._movement, i._delta), this.compute(e), this.emit();
    }
  }
  keyUp(e) {
    e.key in Wu && (this.state._keyboardActive = !1, this.setActive(), this.compute(e), this.emit());
  }
  bind(e) {
    const r = this.config.device;
    e(r, "start", this.pointerDown.bind(this)), this.config.pointerCapture && (e(r, "change", this.pointerMove.bind(this)), e(r, "end", this.pointerUp.bind(this)), e(r, "cancel", this.pointerUp.bind(this)), e("lostPointerCapture", "", this.pointerUp.bind(this))), this.config.keys && (e("key", "down", this.keyDown.bind(this)), e("key", "up", this.keyUp.bind(this))), this.config.filterTaps && e("click", "", this.pointerClick.bind(this), {
      capture: !0,
      passive: !1
    });
  }
}
function ZT(t) {
  "persist" in t && typeof t.persist == "function" && t.persist();
}
const dn = typeof window < "u" && window.document && window.document.createElement;
function JT() {
  return dn && "ontouchstart" in window;
}
function Yu() {
  return JT() || dn && window.navigator.maxTouchPoints > 1;
}
function QT() {
  return dn && "onpointerdown" in window;
}
function e5() {
  return dn && "exitPointerLock" in window.document;
}
function t5() {
  try {
    return "constructor" in GestureEvent;
  } catch {
    return !1;
  }
}
const ft = {
  isBrowser: dn,
  gesture: t5(),
  touch: Yu(),
  touchscreen: Yu(),
  pointer: QT(),
  pointerLock: e5()
}, r5 = 250, i5 = 180, n5 = 0.5, o5 = 50, s5 = 250, Xu = {
  mouse: 0,
  touch: 0,
  pen: 8
}, a5 = ze(ze({}, fn), {}, {
  device(t, e, {
    pointer: {
      touch: r = !1,
      lock: i = !1,
      mouse: o = !1
    } = {}
  }) {
    return this.pointerLock = i && ft.pointerLock, ft.touch && r ? "touch" : this.pointerLock ? "mouse" : ft.pointer && !o ? "pointer" : ft.touch ? "touch" : "mouse";
  },
  preventScrollAxis(t, e, {
    preventScroll: r
  }) {
    if (this.preventScrollDelay = typeof r == "number" ? r : r || r === void 0 && t ? r5 : void 0, !(!ft.touchscreen || r === !1))
      return t || (r !== void 0 ? "y" : void 0);
  },
  pointerCapture(t, e, {
    pointer: {
      capture: r = !0,
      buttons: i = 1
    } = {}
  }) {
    return this.pointerButtons = i, !this.pointerLock && this.device === "pointer" && r;
  },
  keys(t = !0) {
    return t;
  },
  threshold(t, e, {
    filterTaps: r = !1,
    tapsThreshold: i = 3,
    axis: o = void 0
  }) {
    const p = We.toVector(t, r ? i : o ? 1 : 0);
    return this.filterTaps = r, this.tapsThreshold = i, p;
  },
  swipe({
    velocity: t = n5,
    distance: e = o5,
    duration: r = s5
  } = {}) {
    return {
      velocity: this.transform(We.toVector(t)),
      distance: this.transform(We.toVector(e)),
      duration: r
    };
  },
  delay(t = 0) {
    switch (t) {
      case !0:
        return i5;
      case !1:
        return 0;
      default:
        return t;
    }
  },
  axisThreshold(t) {
    return t ? ze(ze({}, Xu), t) : Xu;
  }
}), l5 = 30, c5 = 100;
class u5 extends Bp {
  constructor(...e) {
    super(...e), qe(this, "ingKey", "pinching"), qe(this, "aliasKey", "da");
  }
  init() {
    this.state.offset = [1, 0], this.state.lastOffset = [1, 0], this.state._pointerEvents = /* @__PURE__ */ new Map();
  }
  reset() {
    super.reset();
    const e = this.state;
    e._touchIds = [], e.canceled = !1, e.cancel = this.cancel.bind(this), e.turns = 0;
  }
  computeOffset() {
    const {
      type: e,
      movement: r,
      lastOffset: i
    } = this.state;
    e === "wheel" ? this.state.offset = We.add(r, i) : this.state.offset = [(1 + r[0]) * i[0], r[1] + i[1]];
  }
  computeMovement() {
    const {
      offset: e,
      lastOffset: r
    } = this.state;
    this.state.movement = [e[0] / r[0], e[1] - r[1]];
  }
  axisIntent() {
    const e = this.state, [r, i] = e._movement;
    if (!e.axis) {
      const o = Math.abs(r) * l5 - Math.abs(i);
      o < 0 ? e.axis = "angle" : o > 0 && (e.axis = "scale");
    }
  }
  restrictToAxis(e) {
    this.config.lockDirection && (this.state.axis === "scale" ? e[1] = 0 : this.state.axis === "angle" && (e[0] = 0));
  }
  cancel() {
    const e = this.state;
    e.canceled || setTimeout(() => {
      e.canceled = !0, e._active = !1, this.compute(), this.emit();
    }, 0);
  }
  touchStart(e) {
    this.ctrl.setEventIds(e);
    const r = this.state, i = this.ctrl.touchIds;
    if (r._active && r._touchIds.every((p) => i.has(p)) || i.size < 2)
      return;
    this.start(e), r._touchIds = Array.from(i).slice(0, 2);
    const o = Bu(e, r._touchIds);
    this.pinchStart(e, o);
  }
  pointerStart(e) {
    if (e.buttons != null && e.buttons % 2 !== 1)
      return;
    this.ctrl.setEventIds(e), e.target.setPointerCapture(e.pointerId);
    const r = this.state, i = r._pointerEvents, o = this.ctrl.pointerIds;
    if (r._active && Array.from(i.keys()).every((g) => o.has(g)) || (i.size < 2 && i.set(e.pointerId, e), r._pointerEvents.size < 2))
      return;
    this.start(e);
    const p = xa(...Array.from(i.values()));
    this.pinchStart(e, p);
  }
  pinchStart(e, r) {
    const i = this.state;
    i.origin = r.origin, this.computeValues([r.distance, r.angle]), this.computeInitial(), this.compute(e), this.emit();
  }
  touchMove(e) {
    if (!this.state._active)
      return;
    const r = Bu(e, this.state._touchIds);
    this.pinchMove(e, r);
  }
  pointerMove(e) {
    const r = this.state._pointerEvents;
    if (r.has(e.pointerId) && r.set(e.pointerId, e), !this.state._active)
      return;
    const i = xa(...Array.from(r.values()));
    this.pinchMove(e, i);
  }
  pinchMove(e, r) {
    const i = this.state, o = i._values[1], p = r.angle - o;
    let g = 0;
    Math.abs(p) > 270 && (g += Math.sign(p)), this.computeValues([r.distance, r.angle - 360 * g]), i.origin = r.origin, i.turns = g, i._movement = [i._values[0] / i._initial[0] - 1, i._values[1] - i._initial[1]], this.compute(e), this.emit();
  }
  touchEnd(e) {
    this.ctrl.setEventIds(e), !!this.state._active && this.state._touchIds.some((r) => !this.ctrl.touchIds.has(r)) && (this.state._active = !1, this.compute(e), this.emit());
  }
  pointerEnd(e) {
    const r = this.state;
    this.ctrl.setEventIds(e);
    try {
      e.target.releasePointerCapture(e.pointerId);
    } catch {
    }
    r._pointerEvents.has(e.pointerId) && r._pointerEvents.delete(e.pointerId), !!r._active && r._pointerEvents.size < 2 && (r._active = !1, this.compute(e), this.emit());
  }
  gestureStart(e) {
    e.cancelable && e.preventDefault();
    const r = this.state;
    r._active || (this.start(e), this.computeValues([e.scale, e.rotation]), r.origin = [e.clientX, e.clientY], this.compute(e), this.emit());
  }
  gestureMove(e) {
    if (e.cancelable && e.preventDefault(), !this.state._active)
      return;
    const r = this.state;
    this.computeValues([e.scale, e.rotation]), r.origin = [e.clientX, e.clientY];
    const i = r._movement;
    r._movement = [e.scale - 1, e.rotation], r._delta = We.sub(r._movement, i), this.compute(e), this.emit();
  }
  gestureEnd(e) {
    !this.state._active || (this.state._active = !1, this.compute(e), this.emit());
  }
  wheel(e) {
    const r = this.config.modifierKey;
    r && !e[r] || (this.state._active ? this.wheelChange(e) : this.wheelStart(e), this.timeoutStore.add("wheelEnd", this.wheelEnd.bind(this)));
  }
  wheelStart(e) {
    this.start(e), this.wheelChange(e);
  }
  wheelChange(e) {
    "uv" in e || e.cancelable && e.preventDefault();
    const i = this.state;
    i._delta = [-VT(e)[1] / c5 * i.offset[0], 0], We.addTo(i._movement, i._delta), this.state.origin = [e.clientX, e.clientY], this.compute(e), this.emit();
  }
  wheelEnd() {
    !this.state._active || (this.state._active = !1, this.compute(), this.emit());
  }
  bind(e) {
    const r = this.config.device;
    r && (e(r, "start", this[r + "Start"].bind(this)), e(r, "change", this[r + "Move"].bind(this)), e(r, "end", this[r + "End"].bind(this)), e(r, "cancel", this[r + "End"].bind(this))), e("wheel", "", this.wheel.bind(this), {
      passive: !1
    });
  }
}
const h5 = ze(ze({}, Np), {}, {
  device(t, e, {
    shared: r,
    pointer: {
      touch: i = !1
    } = {}
  }) {
    if (r.target && !ft.touch && ft.gesture)
      return "gesture";
    if (ft.touch && i)
      return "touch";
    if (ft.touchscreen) {
      if (ft.pointer)
        return "pointer";
      if (ft.touch)
        return "touch";
    }
  },
  bounds(t, e, {
    scaleBounds: r = {},
    angleBounds: i = {}
  }) {
    const o = (g) => {
      const a = Hu(po(r, g), {
        min: -1 / 0,
        max: 1 / 0
      });
      return [a.min, a.max];
    }, p = (g) => {
      const a = Hu(po(i, g), {
        min: -1 / 0,
        max: 1 / 0
      });
      return [a.min, a.max];
    };
    return typeof r != "function" && typeof i != "function" ? [o(), p()] : (g) => [o(g), p(g)];
  },
  threshold(t, e, r) {
    return this.lockDirection = r.axis === "lock", We.toVector(t, this.lockDirection ? [0.1, 3] : 0);
  },
  modifierKey(t) {
    return t === void 0 ? "ctrlKey" : t;
  }
});
ze(ze({}, fn), {}, {
  mouseOnly: (t = !0) => t
});
ze(ze({}, fn), {}, {
  mouseOnly: (t = !0) => t
});
const Ll = /* @__PURE__ */ new Map(), _a = /* @__PURE__ */ new Map();
function f5(t) {
  Ll.set(t.key, t.engine), _a.set(t.key, t.resolver);
}
const d5 = {
  key: "drag",
  engine: KT,
  resolver: a5
}, p5 = {
  key: "pinch",
  engine: u5,
  resolver: h5
};
function g5(t, e) {
  if (t == null)
    return {};
  var r = {}, i = Object.keys(t), o, p;
  for (p = 0; p < i.length; p++)
    o = i[p], !(e.indexOf(o) >= 0) && (r[o] = t[o]);
  return r;
}
function m5(t, e) {
  if (t == null)
    return {};
  var r = g5(t, e), i, o;
  if (Object.getOwnPropertySymbols) {
    var p = Object.getOwnPropertySymbols(t);
    for (o = 0; o < p.length; o++)
      i = p[o], !(e.indexOf(i) >= 0) && (!Object.prototype.propertyIsEnumerable.call(t, i) || (r[i] = t[i]));
  }
  return r;
}
const v5 = {
  target(t) {
    if (t)
      return () => "current" in t ? t.current : t;
  },
  enabled(t = !0) {
    return t;
  },
  window(t = ft.isBrowser ? window : void 0) {
    return t;
  },
  eventOptions({
    passive: t = !0,
    capture: e = !1
  } = {}) {
    return {
      passive: t,
      capture: e
    };
  },
  transform(t) {
    return t;
  }
}, b5 = ["target", "eventOptions", "window", "enabled", "transform"];
function Vn(t = {}, e) {
  const r = {};
  for (const [i, o] of Object.entries(e))
    switch (typeof o) {
      case "function":
        r[i] = o.call(r, t[i], i, t);
        break;
      case "object":
        r[i] = Vn(t[i], o);
        break;
      case "boolean":
        o && (r[i] = t[i]);
        break;
    }
  return r;
}
function y5(t, e, r = {}) {
  const i = t, {
    target: o,
    eventOptions: p,
    window: g,
    enabled: a,
    transform: n
  } = i, u = m5(i, b5);
  if (r.shared = Vn({
    target: o,
    eventOptions: p,
    window: g,
    enabled: a,
    transform: n
  }, v5), e) {
    const h = _a.get(e);
    r[e] = Vn(ze({
      shared: r.shared
    }, u), h);
  } else
    for (const h in u) {
      const s = _a.get(h);
      s && (r[h] = Vn(ze({
        shared: r.shared
      }, u[h]), s));
    }
  return r;
}
class Vp {
  constructor(e, r) {
    qe(this, "_listeners", /* @__PURE__ */ new Set()), this._ctrl = e, this._gestureKey = r;
  }
  add(e, r, i, o, p) {
    const g = this._listeners, a = zT(r, i), n = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}, u = ze(ze({}, n), p);
    e.addEventListener(a, o, u);
    const h = () => {
      e.removeEventListener(a, o, u), g.delete(h);
    };
    return g.add(h), h;
  }
  clean() {
    this._listeners.forEach((e) => e()), this._listeners.clear();
  }
}
class w5 {
  constructor() {
    qe(this, "_timeouts", /* @__PURE__ */ new Map());
  }
  add(e, r, i = 140, ...o) {
    this.remove(e), this._timeouts.set(e, window.setTimeout(r, i, ...o));
  }
  remove(e) {
    const r = this._timeouts.get(e);
    r && window.clearTimeout(r);
  }
  clean() {
    this._timeouts.forEach((e) => void window.clearTimeout(e)), this._timeouts.clear();
  }
}
class x5 {
  constructor(e) {
    qe(this, "gestures", /* @__PURE__ */ new Set()), qe(this, "_targetEventStore", new Vp(this)), qe(this, "gestureEventStores", {}), qe(this, "gestureTimeoutStores", {}), qe(this, "handlers", {}), qe(this, "config", {}), qe(this, "pointerIds", /* @__PURE__ */ new Set()), qe(this, "touchIds", /* @__PURE__ */ new Set()), qe(this, "state", {
      shared: {
        shiftKey: !1,
        metaKey: !1,
        ctrlKey: !1,
        altKey: !1
      }
    }), _5(this, e);
  }
  setEventIds(e) {
    if (Vo(e))
      return this.touchIds = new Set(NT(e)), this.touchIds;
    if ("pointerId" in e)
      return e.type === "pointerup" || e.type === "pointercancel" ? this.pointerIds.delete(e.pointerId) : e.type === "pointerdown" && this.pointerIds.add(e.pointerId), this.pointerIds;
  }
  applyHandlers(e, r) {
    this.handlers = e, this.nativeHandlers = r;
  }
  applyConfig(e, r) {
    this.config = y5(e, r, this.config);
  }
  clean() {
    this._targetEventStore.clean();
    for (const e of this.gestures)
      this.gestureEventStores[e].clean(), this.gestureTimeoutStores[e].clean();
  }
  effect() {
    return this.config.shared.target && this.bind(), () => this._targetEventStore.clean();
  }
  bind(...e) {
    const r = this.config.shared, i = {};
    let o;
    if (!(r.target && (o = r.target(), !o))) {
      if (r.enabled) {
        for (const g of this.gestures) {
          const a = this.config[g], n = Gu(i, a.eventOptions, !!o);
          if (a.enabled) {
            const u = Ll.get(g);
            new u(this, e, g).bind(n);
          }
        }
        const p = Gu(i, r.eventOptions, !!o);
        for (const g in this.nativeHandlers)
          p(g, "", (a) => this.nativeHandlers[g](ze(ze({}, this.state.shared), {}, {
            event: a,
            args: e
          })), void 0, !0);
      }
      for (const p in i)
        i[p] = UT(...i[p]);
      if (!o)
        return i;
      for (const p in i) {
        const {
          device: g,
          capture: a,
          passive: n
        } = FT(p);
        this._targetEventStore.add(o, g, "", i[p], {
          capture: a,
          passive: n
        });
      }
    }
  }
}
function Vr(t, e) {
  t.gestures.add(e), t.gestureEventStores[e] = new Vp(t, e), t.gestureTimeoutStores[e] = new w5();
}
function _5(t, e) {
  e.drag && Vr(t, "drag"), e.wheel && Vr(t, "wheel"), e.scroll && Vr(t, "scroll"), e.move && Vr(t, "move"), e.pinch && Vr(t, "pinch"), e.hover && Vr(t, "hover");
}
const Gu = (t, e, r) => (i, o, p, g = {}, a = !1) => {
  var n, u;
  const h = (n = g.capture) !== null && n !== void 0 ? n : e.capture, s = (u = g.passive) !== null && u !== void 0 ? u : e.passive;
  let l = a ? i : RT(i, o, h);
  r && s && (l += "Passive"), t[l] = t[l] || [], t[l].push(p);
}, S5 = /^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;
function C5(t) {
  const e = {}, r = {}, i = /* @__PURE__ */ new Set();
  for (let o in t)
    S5.test(o) ? (i.add(RegExp.lastMatch), r[o] = t[o]) : e[o] = t[o];
  return [r, e, i];
}
function $r(t, e, r, i, o, p) {
  if (!t.has(r) || !Ll.has(i))
    return;
  const g = r + "Start", a = r + "End", n = (u) => {
    let h;
    return u.first && g in e && e[g](u), r in e && (h = e[r](u)), u.last && a in e && e[a](u), h;
  };
  o[i] = n, p[i] = p[i] || {};
}
function T5(t, e) {
  const [r, i, o] = C5(t), p = {};
  return $r(o, r, "onDrag", "drag", p, e), $r(o, r, "onWheel", "wheel", p, e), $r(o, r, "onScroll", "scroll", p, e), $r(o, r, "onPinch", "pinch", p, e), $r(o, r, "onMove", "move", p, e), $r(o, r, "onHover", "hover", p, e), {
    handlers: p,
    config: e,
    nativeHandlers: i
  };
}
function k5(t, e = {}, r, i) {
  const o = ae.useMemo(() => new x5(t), []);
  if (o.applyHandlers(t, i), o.applyConfig(e, r), ae.useEffect(o.effect.bind(o)), ae.useEffect(() => o.clean.bind(o), []), e.target === void 0)
    return o.bind.bind(o);
}
function E5(t) {
  return t.forEach(f5), function(r, i) {
    const {
      handlers: o,
      nativeHandlers: p,
      config: g
    } = T5(r, i || {});
    return k5(o, g, void 0, p);
  };
}
function Dt({
  e: t,
  rect: e,
  deltaX: r,
  deltaY: i
}) {
  return {
    rect: e,
    x: t.clientX,
    y: t.clientY,
    deltaX: r != null ? r : 0,
    deltaY: i != null ? i : 0,
    nativeEvent: t
  };
}
function $o({
  onMoveStart: t,
  onMove: e,
  onMoveEnd: r,
  minimumMovement: i = 0,
  preventDefault: o,
  stopPropagation: p = !0,
  onPress: g,
  onLongPress: a,
  ...n
}) {
  const h = de({
    lastPosition: { x: 0, y: 0 },
    started: !1,
    longPressTriggered: !1
  }).current, { addGlobalListener: s, removeGlobalListener: l } = wl(), c = (v) => {
    !h.el || (t == null ? void 0 : t(v, h.el)) === !1 || (h.originalTouchAction = h.el.style.touchAction, h.el.style.touchAction = "none", h.originalUserSelect = document.documentElement.style.userSelect, document.documentElement.style.userSelect = "none", h.started = !0);
  }, f = (v) => {
    var b;
    if (v.button === 0 && h.id == null) {
      if (h.started = !1, ((b = n.onPointerDown) == null ? void 0 : b.call(n, v)) === !1)
        return;
      p && v.stopPropagation(), o && v.preventDefault(), h.id = v.pointerId, h.el = v.currentTarget, h.lastPosition = { x: v.clientX, y: v.clientY }, a && (h.longPressTimer = setTimeout(() => {
        a(v, h.el), h.longPressTriggered = !0;
      }, 400)), (t || e) && s(window, "pointermove", m, !1), s(window, "pointerup", d, !1), s(window, "pointercancel", d, !1);
    }
  }, m = (v) => {
    if (v.pointerId === h.id) {
      const b = v.clientX - h.lastPosition.x, y = v.clientY - h.lastPosition.y;
      (Math.abs(b) >= i || Math.abs(y) >= i) && !h.started && c(v), h.started && (e == null || e(v, b, y), h.lastPosition = { x: v.clientX, y: v.clientY });
    }
  }, d = (v) => {
    var b;
    if (v.pointerId === h.id) {
      h.longPressTimer && clearTimeout(h.longPressTimer);
      const y = h.longPressTriggered;
      h.longPressTriggered = !1, h.started && (r == null || r(v)), h.el && (v.type !== "pointercancel" && ((b = n.onPointerUp) == null || b.call(n, v, h.el), v.target && h.el.contains(v.target) && (y ? a == null || a(v, h.el) : g == null || g(v, h.el))), document.documentElement.style.userSelect = h.originalUserSelect || "", h.el.style.touchAction = h.originalTouchAction || ""), h.id = void 0, h.started = !1, l(window, "pointermove", m, !1), l(window, "pointerup", d, !1), l(window, "pointercancel", d, !1);
    }
  };
  return {
    domProps: {
      onPointerDown: Mt(f)
    }
  };
}
function O5(t, e) {
  const r = { ...t };
  r.left = Math.max(0, r.left);
  const i = r.left - t.left;
  i > 0 && (r.width -= i), r.top = Math.max(0, r.top);
  const o = r.top - t.top;
  return o > 0 && (r.height -= o), r.width = Math.min(
    r.width,
    e.width - r.left
  ), r.height = Math.min(
    r.height,
    e.height - r.top
  ), r;
}
function Ki(t) {
  return {
    left: t.left,
    top: t.top,
    width: t.width,
    height: t.height
  };
}
var lt = /* @__PURE__ */ ((t) => (t.topLeft = "topLeft", t.topRight = "topRight", t.bottomLeft = "bottomLeft", t.bottomRight = "bottomRight", t))(lt || {});
let Ee = {};
const qu = (t = {}) => {
  di(null), Ee = t;
};
function $p({
  aspectRatio: t,
  boundaryRef: e,
  boundaryRect: r,
  restrictWithinBoundary: i = !0,
  minWidth: o = 50,
  minHeight: p = 50,
  ...g
}) {
  const a = {
    onMoveStart: (u, h) => {
      var l;
      const s = u.target;
      if (!s.dataset.resizeHandle || (qu({
        currentRect: Ki(h.getBoundingClientRect()),
        resizeDir: s.dataset.resizeHandle
      }), !Ee.currentRect))
        return !1;
      di("resize"), r ? Ee.boundaryRect = r : e != null && e.current && (Ee.boundaryRect = Ki(
        e.current.getBoundingClientRect()
      )), Ee.currentRect && Ee.boundaryRect && (Ee.currentRect.left -= Ee.boundaryRect.left, Ee.currentRect.top -= Ee.boundaryRect.top), Ee.initialAspectRatio = Ee.currentRect.width / Ee.currentRect.height, (l = g.onResizeStart) == null || l.call(g, Dt({ rect: Ee.currentRect, e: u }));
    },
    onMove: (u, h, s) => {
      var m;
      if (!Ee.resizeDir || !Ee.currentRect)
        return;
      const l = t === "initial" ? Ee.initialAspectRatio : t, c = P5(Ee.currentRect, h, s, l), f = M5(c, o, p, l);
      (m = g.onResize) == null || m.call(
        g,
        Dt({ rect: f, e: u, deltaX: h, deltaY: s })
      ), Ee.currentRect = c;
    },
    onMoveEnd: (u) => {
      var h;
      Ee.currentRect && ((h = g.onResizeEnd) == null || h.call(g, Dt({ rect: Ee.currentRect, e: u }))), qu();
    }
  }, { domProps: n } = $o(a);
  return { resizeProps: n };
}
function P5(t, e, r, i) {
  const o = { ...t }, p = { ...t };
  return Ee.resizeDir === "topRight" ? (p.width = Math.floor(p.width + e), i ? p.height = Math.floor(p.width / i) : p.height = Math.floor(p.height - r), p.top = Math.floor(p.top + (o.height - p.height))) : Ee.resizeDir === "bottomRight" ? (p.width = Math.floor(p.width + e), i ? p.height = Math.floor(p.width / i) : p.height = Math.floor(p.height + r)) : Ee.resizeDir === "topLeft" ? (p.width = Math.floor(p.width - e), i ? p.height = Math.floor(p.width / i) : p.height = Math.floor(p.height - r), p.left = Math.floor(p.left + (o.width - p.width)), p.top = Math.floor(p.top + (o.height - p.height))) : Ee.resizeDir === "bottomLeft" && (p.width = Math.floor(p.width - e), i ? p.height = Math.floor(p.width / i) : p.height = Math.floor(p.height + r), p.left = Math.floor(p.left + e)), p;
}
function M5(t, e, r, i) {
  const o = Ee.resizeDir === "bottomLeft" || Ee.resizeDir === "topLeft", p = Ee.resizeDir === "topRight" || Ee.resizeDir === "topLeft";
  let g = { ...t };
  g.width = Math.max(e, t.width), g.height = Math.max(r, t.height);
  const a = g.width - t.width;
  o && a > 0 && (g.left -= a);
  const n = g.height - t.height;
  if (p && n > 0 && (g.top -= n), Ee.boundaryRect && (g = O5(
    g,
    Ee.boundaryRect
  )), i) {
    const u = g.width, h = g.height, s = Sl(
      i,
      g.width,
      g.height
    );
    g.width = s.width, g.height = s.height, p && (g.top += h - g.height), o && (g.left += u - g.width);
  }
  return g;
}
function Xt({
  position: t,
  inset: e = !1
}) {
  const r = A5(t, e);
  return /* @__PURE__ */ x("div", {
    "data-resize-handle": t,
    className: `border-white absolute w-20 h-20 ${r}`
  });
}
function A5(t, e) {
  const r = e ? "left-0" : "-left-5", i = e ? "top-0" : "-top-5", o = e ? "bottom-0" : "-bottom-5", p = e ? "right-0" : "-right-5";
  switch (t) {
    case lt.topLeft:
      return `${r} ${i} border-l-4 border-t-4 cursor-nwse-resize`;
    case lt.topRight:
      return `${p} ${i} border-r-4 border-t-4 cursor-nesw-resize`;
    case lt.bottomRight:
      return `${p} ${o} border-r-4 border-b-4 cursor-se-resize`;
    case lt.bottomLeft:
      return `${r} ${o} border-l-4 border-b-4 cursor-sw-resize`;
    default:
      return "";
  }
}
var Si = /* @__PURE__ */ ((t) => (t.top = "maskTop", t.right = "maskRight", t.bottom = "maskBottom", t.left = "maskLeft", t))(Si || {});
function An({
  position: t,
  refs: e
}) {
  const r = D5(t);
  return /* @__PURE__ */ x("div", {
    className: `cropzone-transition bg-black/50 bottom absolute ${r}`,
    ref: (i) => e.current[t] = i
  });
}
function D5(t) {
  switch (t) {
    case "maskTop":
      return "left-0 top-0";
    case "maskBottom":
      return "bottom-0 left-0";
    default:
      return "";
  }
}
function Dn({
  name: t,
  refs: e
}) {
  const r = ue("cropzone-transition pointer-events-none absolute left-0 top-0 bg-white/50", t.startsWith("lineHor") ? "h-px" : "w-px");
  return /* @__PURE__ */ x("div", {
    className: r,
    ref: (i) => {
      e.current[t] = i;
    }
  });
}
function go(t, e, r) {
  return Math.min(Math.max(t, e), r);
}
let Be = {};
function Hp({
  boundaryRef: t,
  boundaryRect: e,
  minimumMovement: r,
  restrictWithinBoundary: i = !0,
  ...o
}) {
  const p = {
    minimumMovement: r,
    onMoveStart: (a, n) => {
      var u;
      if (_l)
        return !1;
      Be = {
        currentRect: Ki(n.getBoundingClientRect())
      }, di("move"), e ? Be.boundaryRect = e : t != null && t.current && (Be.boundaryRect = Ki(
        t.current.getBoundingClientRect()
      )), Be.currentRect && Be.boundaryRect && (Be.currentRect.left -= Be.boundaryRect.left, Be.currentRect.top -= Be.boundaryRect.top), (u = o.onMoveStart) == null || u.call(o, Dt({ rect: Be.currentRect, e: a }));
    },
    onMove: (a, n, u) => {
      var l;
      if (!Be.currentRect)
        return;
      const h = {
        ...Be.currentRect,
        left: Be.currentRect.left + n,
        top: Be.currentRect.top + u
      }, s = { ...h };
      Be.boundaryRect && i && (s.left = go(
        h.left,
        0,
        Be.boundaryRect.width - h.width
      ), s.top = go(
        h.top,
        0,
        Be.boundaryRect.height - h.height
      )), (l = o.onMove) == null || l.call(o, Dt({ rect: s, e: a, deltaX: n, deltaY: u })), Be.currentRect = h;
    },
    onMoveEnd: (a) => {
      var n;
      !Be.currentRect || ((n = o.onMoveEnd) == null || n.call(o, Dt({ rect: Be.currentRect, e: a })), di(null), Be = {});
    }
  }, { domProps: g } = $o(p);
  return { moveProps: g };
}
function I5() {
  const t = de({}), [e, r] = Ae(!0), i = oe((h) => h.canvasSize), o = oe((h) => {
    var s, l;
    return (l = (s = h.config.tools) == null ? void 0 : s.crop) == null ? void 0 : l.cropzone;
  }), p = oe((h) => {
    var s, l;
    return (l = (s = h.config.tools) == null ? void 0 : s.crop) == null ? void 0 : l.defaultRatio;
  }) || null, g = oe((h) => h.crop.selectedAspectRatio) || null, {
    moveProps: a
  } = Hp({
    boundaryRect: i,
    onMoveStart: () => r(!0),
    onMove: (h) => I().crop.drawZone(h.rect),
    onMoveEnd: () => r(!1)
  }), {
    resizeProps: n
  } = $p({
    boundaryRect: i,
    minHeight: 50,
    minWidth: 50,
    aspectRatio: Cl(g),
    onResizeStart: () => r(!0),
    onResize: (h) => I().crop.drawZone(h.rect),
    onResizeEnd: () => r(!1)
  });
  pi(() => {
    I().crop.registerRefs(t), I().crop.resetCropzone(p);
  }, [p, i]);
  const u = ue("cropzone absolute z-cropzone isolate left-0 top-0 w-full h-full overflow-hidden", e && "moving");
  return /* @__PURE__ */ ie("div", {
    className: u,
    onPointerDown: (h) => {
      h.stopPropagation(), h.preventDefault();
    },
    children: [/* @__PURE__ */ ie("div", {
      className: "cropzone-transition border-white/50 absolute z-10 left-0 top-0 border",
      ...vi(n, a),
      ref: (h) => t.current.innerZone = h,
      children: [!(o != null && o.hideTopLeft) && /* @__PURE__ */ x(Xt, {
        position: lt.topLeft,
        inset: !0
      }), !(o != null && o.hideTopRight) && /* @__PURE__ */ x(Xt, {
        position: lt.topRight,
        inset: !0
      }), !(o != null && o.hideBottomLeft) && /* @__PURE__ */ x(Xt, {
        position: lt.bottomLeft,
        inset: !0
      }), !(o != null && o.hideBottomRight) && /* @__PURE__ */ x(Xt, {
        position: lt.bottomRight,
        inset: !0
      }), /* @__PURE__ */ x(Dn, {
        name: "lineVer1",
        refs: t
      }), /* @__PURE__ */ x(Dn, {
        name: "lineVer2",
        refs: t
      }), /* @__PURE__ */ x(Dn, {
        name: "lineHor1",
        refs: t
      }), /* @__PURE__ */ x(Dn, {
        name: "lineHor2",
        refs: t
      })]
    }), /* @__PURE__ */ x(An, {
      refs: t,
      position: Si.top
    }), /* @__PURE__ */ x(An, {
      refs: t,
      position: Si.left
    }), /* @__PURE__ */ x(An, {
      refs: t,
      position: Si.right
    }), /* @__PURE__ */ x(An, {
      refs: t,
      position: Si.bottom
    })]
  });
}
const R5 = me(/* @__PURE__ */ x("path", {
  d: "M 7 2 C 6.448 2 6 2.448 6 3 C 6 3.552 6.448 4 7 4 L 20 4 L 20 17 C 20 17.552 20.448 18 21 18 C 21.552 18 22 17.552 22 17 L 22 4 C 22 2.895 21.105 2 20 2 L 7 2 z M 4 6 C 2.895 6 2 6.895 2 8 L 2 20 C 2 21.105 2.895 22 4 22 L 16 22 C 17.105 22 18 21.105 18 20 L 18 8 C 18 6.895 17.105 6 16 6 L 4 6 z M 10 10 C 10.552 10 11 10.448 11 11 L 11 13 L 13 13 C 13.552 13 14 13.448 14 14 C 14 14.552 13.552 15 13 15 L 11 15 L 11 17 C 11 17.552 10.552 18 10 18 C 9.448 18 9 17.552 9 17 L 9 15 L 7 15 C 6.448 15 6 14.552 6 14 C 6 13.448 6.448 13 7 13 L 9 13 L 9 11 C 9 10.448 9.448 10 10 10 z"
})), L5 = me(/* @__PURE__ */ x("path", {
  d: "M 11 3 L 2 21 L 11 21 L 11 3 z M 13 3 L 13 21 L 22 21 L 13 3 z M 9 11.472656 L 9 19 L 5.2363281 19 L 9 11.472656 z"
})), F5 = me(/* @__PURE__ */ x("path", {
  d: "M 16.476562 2.4511719 C 16.392047 2.4657656 16.308531 2.5061719 16.238281 2.5761719 L 14.130859 4.6835938 C 13.956859 4.8575938 13.956859 5.1394531 14.130859 5.3144531 L 16.238281 7.4238281 C 16.519281 7.7048281 17 7.5054219 17 7.1074219 L 17 6 L 20 6 L 20 9 A 1.0001 1.0001 0 1 0 22 9 L 22 6 C 22 4.9069372 21.093063 4 20 4 L 17 4 L 17 2.8925781 C 17 2.5940781 16.730109 2.4073906 16.476562 2.4511719 z M 4 5 C 2.9069372 5 2 5.9069372 2 7 L 2 14 C 2 15.093063 2.9069372 16 4 16 L 7 16 L 7 19 C 7 20.105 7.895 21 9 21 L 16 21 C 17.105 21 18 20.105 18 19 L 18 12 C 18 10.895 17.105 10 16 10 L 13 10 L 13 7 C 13 5.9069372 12.093063 5 11 5 L 4 5 z M 4 7 L 11 7 L 11 14 L 4 14 L 4 7 z"
})), z5 = me(/* @__PURE__ */ x("path", {
  d: "M 10 2 L 9 3 L 3 3 L 3 5 L 21 5 L 21 3 L 15 3 L 14 2 L 10 2 z M 4.3652344 7 L 5.8925781 20.263672 C 6.0245781 21.253672 6.877 22 7.875 22 L 16.123047 22 C 17.121047 22 17.974422 21.254859 18.107422 20.255859 L 19.634766 7 L 4.3652344 7 z"
})), j5 = {
  width: 120,
  height: 30
}, B5 = [{
  name: "Duplicate",
  icon: R5,
  onClick: () => {
    I().objects.duplicate();
  }
}, {
  name: "Flip",
  icon: L5,
  onClick: () => {
    I().objects.flipHorizontally();
  }
}, {
  name: "Bring to front",
  icon: F5,
  onClick: () => {
    I().objects.bringToFront();
  }
}, {
  name: "Delete",
  icon: z5,
  onClick: () => {
    I().objects.delete();
  }
}], N5 = ae.forwardRef((t, e) => {
  const i = oe((o) => o.objects.active.isMoving) ? "opacity-0" : "opacity-100";
  return /* @__PURE__ */ x("div", {
    ref: e,
    className: `${i} absolute z-obj-box left-0 top-0 flex items-center text-white bg-controls rounded shadow transition-opacity overflow-hidden`,
    children: B5.map((o) => {
      const p = o.icon;
      return /* @__PURE__ */ x(Me, {
        size: "sm",
        className: "w-30 h-30 hover:bg-white/hover",
        radius: "rounded-none",
        onClick: o.onClick,
        children: /* @__PURE__ */ x(p, {})
      }, o.name);
    })
  });
});
function V5(t, e) {
  if (!e)
    return;
  const r = t.angle || 0, i = r > 168 && r < 188 ? -30 : -15, o = O().canvasSize, p = O().stageSize, g = j5, a = o.top - p.top, n = o.left - p.left, u = p.width - (n + o.width), h = p.height - (a + o.height), s = -a, l = -(o.left - p.left), c = o.width - g.width + u, f = o.height - g.height + h, m = t.getBoundingRect();
  let d = m.top - g.height + i, v = m.left + m.width / 2 - g.width / 2;
  d = Math.min(f, Math.max(s, d)), v = Math.min(c, Math.max(l, v)), e.style.transform = `translate(${v}px, ${d}px) rotate(0deg)`;
}
function $5(t) {
  const e = I().objects.getActive();
  if (!e || !t.rect.angle)
    return;
  const r = ve.fabric.util.radiansToDegrees(t.rect.angle);
  r !== e.angle && I().objects.setValues({ angle: r });
}
function H5(t) {
  const e = t.rect.width / 2, r = t.rect.height / 2;
  I().objects.setValues({
    left: (t.rect.left + e) / O().zoom,
    top: (t.rect.top + r) / O().zoom
  });
}
function U5(t) {
  const e = I().objects.getActive();
  if (!e)
    return;
  const r = {};
  lr(e) ? (t.deltaX > 0 || e.getScaledHeight() >= 20 && e.getScaledWidth() >= 20) && (r.fontSize = (e.fontSize || 1) + t.deltaX) : (e.width && (r.scaleX = t.rect.width / O().zoom / e.width), e.height && (r.scaleY = t.rect.height / O().zoom / e.height)), I().objects.setValues(r);
}
function Ku(t, e) {
  var s, l, c;
  const r = I().objects.getActive();
  if (!r || !t.current)
    return;
  const i = t.current, o = ve.fabric.util.degreesToRadians((s = r.angle) != null ? s : 0);
  let p = Math.round(r.getScaledWidth() * O().zoom), g = Math.round(r.getScaledHeight() * O().zoom), a = Math.round(((l = r.left) != null ? l : 0) * O().zoom), n = Math.round(((c = r.top) != null ? c : 0) * O().zoom);
  const u = r.originX === "center" ? p / 2 : 0, h = r.originY === "center" ? g / 2 : 0;
  r.padding && (p += r.padding * 2, g += r.padding * 2, a -= r.padding, n -= r.padding), i.style.width = `${p}px`, i.style.height = `${g}px`, i.style.transform = `translate(${a - u}px, ${n - h}px) rotate(${o}rad)`, I().canvas.render(), V5(r, e.current);
}
function W5() {
  var e;
  const t = I().objects.getActive();
  lr(t) && (t.enterEditing(), (e = t.hiddenTextarea) == null || e.focus());
}
function Y5() {
  return /* @__PURE__ */ x("div", {
    className: "absolute -bottom-20 left-1/2 w-2 h-20 bg-white cursor-default -translate-x-1/2",
    children: /* @__PURE__ */ x("div", {
      "data-rotate-handle": !0,
      className: "w-18 h-18 absolute -bottom-10 -left-8 bg-white rounded-full cursor-move"
    })
  });
}
let _t = {};
function X5(t) {
  const e = {
    onMoveStart: (i, o) => {
      var u, h;
      if (!i.target.dataset.rotateHandle)
        return !1;
      const g = Ki(o.getBoundingClientRect());
      if (!g)
        return !1;
      const a = (u = o.style.transform.match(/rotate\((.+?)\)/)) == null ? void 0 : u[1], [n = "0"] = a ? a.split(",") : [];
      Ju({
        currentRect: g,
        centerX: g.left + g.width / 2,
        centerY: g.top + g.height / 2,
        startAngle: parseFloat(n)
      }), di("rotate"), _t.startAngle = Zu(i), (h = t.onRotateStart) == null || h.call(t, Dt({ rect: g, e: i }));
    },
    onMove: (i, o, p) => {
      var a;
      if (!_t.currentRect)
        return;
      const g = { ..._t.currentRect };
      g.angle = Zu(i), g.left += o, g.top += p, (a = t.onRotate) == null || a.call(t, Dt({ rect: g, e: i, deltaX: o, deltaY: p })), _t.currentRect = g;
    },
    onMoveEnd: (i) => {
      var o;
      _t.currentRect && ((o = t.onRotateEnd) == null || o.call(t, Dt({ rect: _t.currentRect, e: i }))), Ju();
    }
  }, { domProps: r } = $o(e);
  return { rotateProps: r };
}
function Zu(t) {
  const e = {
    x: _t.centerX || 0,
    y: _t.centerY || 0
  };
  return Math.atan2(e.y - t.pageY, e.x - t.pageX) - (_t.startAngle || 0);
}
const Ju = (t = {}) => {
  di(null), _t = t;
};
function G5() {
  const t = de(null), e = de(null), r = oe((l) => l.objects.active.id), i = oe((l) => l.objects.isEditingText), o = oe((l) => l.zoom), p = q5(), g = de(null), a = Ie(() => {
    g.current ? (clearTimeout(g.current), g.current = null, W5()) : g.current = setTimeout(() => {
      g.current = null;
    }, 300);
  }, []);
  let {
    moveProps: n
  } = Hp({
    boundaryRef: O().canvasRef,
    restrictWithinBoundary: !1,
    onMoveEnd: () => {
      O().objects.setActiveIsMoving(!1);
    },
    onMove: (l) => {
      O().objects.setActiveIsMoving(!0), H5(l);
    }
  });
  p.lockMovement && (n = {});
  const {
    resizeProps: u
  } = $p({
    minWidth: 50,
    minHeight: 50,
    aspectRatio: p.unlockAspectRatio ? null : "initial",
    boundaryRef: O().canvasRef,
    restrictWithinBoundary: !1,
    onResizeEnd: () => {
      O().objects.setActiveIsMoving(!1);
    },
    onResize: (l) => {
      O().objects.setActiveIsMoving(!0), U5(l);
    }
  }), {
    rotateProps: h
  } = X5({
    boundaryRef: O().canvasRef,
    onRotateEnd: () => {
      O().objects.setActiveIsMoving(!1);
    },
    onRotate: (l) => {
      O().objects.setActiveIsMoving(!0), $5(l);
    }
  });
  return xe(() => {
    !he() || O().editor.on("object:modified", (l) => {
      l.sizeOrPositionChanged && Ku(t, e);
    });
  }, []), xe(() => {
    Ku(t, e);
  }, [r, o, i]), /* @__PURE__ */ ie("div", {
    className: r && !i ? "block" : "hidden",
    children: [/* @__PURE__ */ ie("div", {
      ref: t,
      ...vi(h, u, n),
      onClick: a,
      className: "absolute z-obj-box border-2 border-white shadow-md cursor-move",
      children: [!p.hideTopLeft && /* @__PURE__ */ x(Xt, {
        position: lt.topLeft
      }), !p.hideTopRight && /* @__PURE__ */ x(Xt, {
        position: lt.topRight
      }), !p.hideBottomLeft && /* @__PURE__ */ x(Xt, {
        position: lt.bottomLeft
      }), !p.hideBottomRight && /* @__PURE__ */ x(Xt, {
        position: lt.bottomRight
      }), !p.hideRotatingPoint && /* @__PURE__ */ x(Y5, {})]
    }), /* @__PURE__ */ x(N5, {
      ref: e
    })]
  });
}
function q5() {
  const t = I().objects.getActive();
  if (!t || !t.name)
    return {};
  const e = O().config.objectControls || {}, r = t.name;
  return {
    ...e.global,
    ...e[r]
  };
}
function K5() {
  const t = oe((r) => r.activeTool === Pe.CROP), e = oe((r) => r.objects.active.id);
  return /* @__PURE__ */ ie("div", {
    children: [t && /* @__PURE__ */ x(I5, {}), e && /* @__PURE__ */ x(G5, {})]
  });
}
const Z5 = E5([d5, p5]), J5 = ae.forwardRef((t, e) => {
  const [r, i] = Ae(!1);
  xe(() => oe.subscribe((p) => p.loading, (p) => {
    i(!p);
  }), []);
  const o = {
    visible: {
      opacity: 1,
      transition: {
        duration: 0.35,
        delay: 0.5
      }
    },
    hidden: {
      opacity: 0,
      transition: {
        duration: 0
      }
    }
  };
  return /* @__PURE__ */ x(Q5, {
    children: /* @__PURE__ */ ie(ot.div, {
      initial: {
        opacity: 0
      },
      variants: o,
      animate: r ? "visible" : "hidden",
      className: "relative m-auto",
      style: {
        backgroundImage: `url(${ct("images/empty-canvas-bg.png")})`
      },
      children: [/* @__PURE__ */ x(K5, {}), /* @__PURE__ */ x("canvas", {
        ref: e
      })]
    })
  });
});
function Q5({
  children: t
}) {
  const e = de(null), r = Z5({
    onPinch: (i) => {
      if (!I().zoom.allowUserZoom || !Qu(i))
        return i.cancel();
      i.direction[0] === 1 ? I().zoom.zoomIn(0.01) : I().zoom.zoomOut(0.01), i.event.stopPropagation(), i.event.preventDefault();
    },
    onDrag: (i) => {
      if (i.pinching || !Qu(i))
        return i.cancel();
      e.current.scrollLeft -= i.delta[0], e.current.scrollTop -= i.delta[1];
    }
  });
  return /* @__PURE__ */ x("div", {
    ref: e,
    className: "flex items-center justify-center w-full h-full overflow-hidden touch-none",
    ...r(),
    children: t
  });
}
function Qu(t) {
  return !(he().findTarget(t.event, !1) || he().isDrawingMode);
}
function Fl({
  actionBtn: t,
  children: e,
  className: r
}) {
  return /* @__PURE__ */ ie("div", {
    className: ue(r, "flex gap-16 items-center h-full"),
    children: [t && /* @__PURE__ */ x("div", {
      className: "flex-shrink-0",
      children: t
    }), /* @__PURE__ */ x("div", {
      className: "w-full flex-auto",
      children: e
    }), t && /* @__PURE__ */ x("div", {
      className: "w-96"
    })]
  });
}
function yi() {
  return (yi = Object.assign || function(t) {
    for (var e = 1; e < arguments.length; e++) {
      var r = arguments[e];
      for (var i in r)
        Object.prototype.hasOwnProperty.call(r, i) && (t[i] = r[i]);
    }
    return t;
  }).apply(this, arguments);
}
function Ho(t, e) {
  if (t == null)
    return {};
  var r, i, o = {}, p = Object.keys(t);
  for (i = 0; i < p.length; i++)
    e.indexOf(r = p[i]) >= 0 || (o[r] = t[r]);
  return o;
}
function Zi(t) {
  var e = de(t), r = de(function(i) {
    e.current && e.current(i);
  });
  return e.current = t, r.current;
}
var Ji = function(t, e, r) {
  return e === void 0 && (e = 0), r === void 0 && (r = 1), t > r ? r : t < e ? e : t;
}, Mi = function(t) {
  return "touches" in t;
}, Sa = function(t) {
  return t && t.ownerDocument.defaultView || self;
}, eh = function(t, e, r) {
  var i = t.getBoundingClientRect(), o = Mi(e) ? function(p, g) {
    for (var a = 0; a < p.length; a++)
      if (p[a].identifier === g)
        return p[a];
    return p[0];
  }(e.touches, r) : e;
  return {
    left: Ji((o.pageX - (i.left + Sa(t).pageXOffset)) / i.width),
    top: Ji((o.pageY - (i.top + Sa(t).pageYOffset)) / i.height)
  };
}, th = function(t) {
  !Mi(t) && t.preventDefault();
}, Up = ae.memo(function(t) {
  var e = t.onMove, r = t.onKey, i = Ho(t, ["onMove", "onKey"]), o = de(null), p = Zi(e), g = Zi(r), a = de(null), n = de(!1), u = Je(function() {
    var c = function(d) {
      th(d), (Mi(d) ? d.touches.length > 0 : d.buttons > 0) && o.current ? p(eh(o.current, d, a.current)) : m(!1);
    }, f = function() {
      return m(!1);
    };
    function m(d) {
      var v = n.current, b = Sa(o.current), y = d ? b.addEventListener : b.removeEventListener;
      y(v ? "touchmove" : "mousemove", c), y(v ? "touchend" : "mouseup", f);
    }
    return [function(d) {
      var v = d.nativeEvent, b = o.current;
      if (b && (th(v), !function(w, _) {
        return _ && !Mi(w);
      }(v, n.current) && b)) {
        if (Mi(v)) {
          n.current = !0;
          var y = v.changedTouches || [];
          y.length && (a.current = y[0].identifier);
        }
        b.focus(), p(eh(b, v, a.current)), m(!0);
      }
    }, function(d) {
      var v = d.which || d.keyCode;
      v < 37 || v > 40 || (d.preventDefault(), g({
        left: v === 39 ? 0.05 : v === 37 ? -0.05 : 0,
        top: v === 40 ? 0.05 : v === 38 ? -0.05 : 0
      }));
    }, m];
  }, [g, p]), h = u[0], s = u[1], l = u[2];
  return xe(function() {
    return l;
  }, [l]), /* @__PURE__ */ x("div", {
    ...yi({}, i, {
      onTouchStart: h,
      onMouseDown: h,
      className: "react-colorful__interactive",
      ref: o,
      onKeyDown: s,
      tabIndex: 0,
      role: "slider"
    })
  });
}), zl = function(t) {
  return t.filter(Boolean).join(" ");
}, Wp = function(t) {
  var e = t.color, r = t.left, i = t.top, o = i === void 0 ? 0.5 : i, p = zl(["react-colorful__pointer", t.className]);
  return /* @__PURE__ */ x("div", {
    className: p,
    style: {
      top: 100 * o + "%",
      left: 100 * r + "%"
    },
    children: /* @__PURE__ */ x("div", {
      className: "react-colorful__pointer-fill",
      style: {
        backgroundColor: e
      }
    })
  });
}, Ge = function(t, e, r) {
  return e === void 0 && (e = 0), r === void 0 && (r = Math.pow(10, e)), Math.round(r * t) / r;
}, ek = function(t) {
  return ok(Ca(t));
}, Ca = function(t) {
  return t[0] === "#" && (t = t.substring(1)), t.length < 6 ? {
    r: parseInt(t[0] + t[0], 16),
    g: parseInt(t[1] + t[1], 16),
    b: parseInt(t[2] + t[2], 16),
    a: t.length === 4 ? Ge(parseInt(t[3] + t[3], 16) / 255, 2) : 1
  } : {
    r: parseInt(t.substring(0, 2), 16),
    g: parseInt(t.substring(2, 4), 16),
    b: parseInt(t.substring(4, 6), 16),
    a: t.length === 8 ? Ge(parseInt(t.substring(6, 8), 16) / 255, 2) : 1
  };
}, tk = function(t) {
  return nk(ik(t));
}, rk = function(t) {
  var e = t.s, r = t.v, i = t.a, o = (200 - e) * r / 100;
  return {
    h: Ge(t.h),
    s: Ge(o > 0 && o < 200 ? e * r / 100 / (o <= 100 ? o : 200 - o) * 100 : 0),
    l: Ge(o / 2),
    a: Ge(i, 2)
  };
}, Ta = function(t) {
  var e = rk(t);
  return "hsl(" + e.h + ", " + e.s + "%, " + e.l + "%)";
}, ik = function(t) {
  var e = t.h, r = t.s, i = t.v, o = t.a;
  e = e / 360 * 6, r /= 100, i /= 100;
  var p = Math.floor(e), g = i * (1 - r), a = i * (1 - (e - p) * r), n = i * (1 - (1 - e + p) * r), u = p % 6;
  return {
    r: Ge(255 * [i, a, g, g, n, i][u]),
    g: Ge(255 * [n, i, i, a, g, g][u]),
    b: Ge(255 * [g, g, n, i, i, a][u]),
    a: Ge(o, 2)
  };
}, In = function(t) {
  var e = t.toString(16);
  return e.length < 2 ? "0" + e : e;
}, nk = function(t) {
  var e = t.r, r = t.g, i = t.b, o = t.a, p = o < 1 ? In(Ge(255 * o)) : "";
  return "#" + In(e) + In(r) + In(i) + p;
}, ok = function(t) {
  var e = t.r, r = t.g, i = t.b, o = t.a, p = Math.max(e, r, i), g = p - Math.min(e, r, i), a = g ? p === e ? (r - i) / g : p === r ? 2 + (i - e) / g : 4 + (e - r) / g : 0;
  return {
    h: Ge(60 * (a < 0 ? a + 6 : a)),
    s: Ge(p ? g / p * 100 : 0),
    v: Ge(p / 255 * 100),
    a: o
  };
}, sk = ae.memo(function(t) {
  var e = t.hue, r = t.onChange, i = zl(["react-colorful__hue", t.className]);
  return ae.createElement("div", {
    className: i
  }, ae.createElement(Up, {
    onMove: function(o) {
      r({
        h: 360 * o.left
      });
    },
    onKey: function(o) {
      r({
        h: Ji(e + 360 * o.left, 0, 360)
      });
    },
    "aria-label": "Hue",
    "aria-valuenow": Ge(e),
    "aria-valuemax": "360",
    "aria-valuemin": "0"
  }, ae.createElement(Wp, {
    className: "react-colorful__hue-pointer",
    left: e / 360,
    color: Ta({
      h: e,
      s: 100,
      v: 100,
      a: 1
    })
  })));
}), ak = ae.memo(function(t) {
  var e = t.hsva, r = t.onChange, i = {
    backgroundColor: Ta({
      h: e.h,
      s: 100,
      v: 100,
      a: 1
    })
  };
  return ae.createElement("div", {
    className: "react-colorful__saturation",
    style: i
  }, ae.createElement(Up, {
    onMove: function(o) {
      r({
        s: 100 * o.left,
        v: 100 - 100 * o.top
      });
    },
    onKey: function(o) {
      r({
        s: Ji(e.s + 100 * o.left, 0, 100),
        v: Ji(e.v - 100 * o.top, 0, 100)
      });
    },
    "aria-label": "Color",
    "aria-valuetext": "Saturation " + Ge(e.s) + "%, Brightness " + Ge(e.v) + "%"
  }, ae.createElement(Wp, {
    className: "react-colorful__saturation-pointer",
    top: 1 - e.v / 100,
    left: e.s / 100,
    color: Ta(e)
  })));
}), Yp = function(t, e) {
  if (t === e)
    return !0;
  for (var r in t)
    if (t[r] !== e[r])
      return !1;
  return !0;
}, lk = function(t, e) {
  return t.toLowerCase() === e.toLowerCase() || Yp(Ca(t), Ca(e));
};
function ck(t, e, r) {
  var i = Zi(r), o = Ae(function() {
    return t.toHsva(e);
  }), p = o[0], g = o[1], a = de({
    color: e,
    hsva: p
  });
  xe(function() {
    if (!t.equal(e, a.current.color)) {
      var u = t.toHsva(e);
      a.current = {
        hsva: u,
        color: e
      }, g(u);
    }
  }, [e, t]), xe(function() {
    var u;
    Yp(p, a.current.hsva) || t.equal(u = t.fromHsva(p), a.current.color) || (a.current = {
      hsva: p,
      color: u
    }, i(u));
  }, [p, t, i]);
  var n = Ie(function(u) {
    g(function(h) {
      return Object.assign({}, h, u);
    });
  }, []);
  return [p, n];
}
var uk = typeof window < "u" ? pi : xe, hk = function() {
  return typeof __webpack_nonce__ < "u" ? __webpack_nonce__ : void 0;
}, rh = /* @__PURE__ */ new Map(), fk = function(t) {
  uk(function() {
    var e = t.current ? t.current.ownerDocument : document;
    if (e !== void 0 && !rh.has(e)) {
      var r = e.createElement("style");
      r.innerHTML = `.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`, rh.set(e, r);
      var i = hk();
      i && r.setAttribute("nonce", i), e.head.appendChild(r);
    }
  }, []);
}, dk = function(t) {
  var e = t.className, r = t.colorModel, i = t.color, o = i === void 0 ? r.defaultColor : i, p = t.onChange, g = Ho(t, ["className", "colorModel", "color", "onChange"]), a = de(null);
  fk(a);
  var n = ck(r, o, p), u = n[0], h = n[1], s = zl(["react-colorful", e]);
  return /* @__PURE__ */ ie("div", {
    ...yi({}, g, {
      ref: a,
      className: s
    }),
    children: [/* @__PURE__ */ x(ak, {
      hsva: u,
      onChange: h
    }), /* @__PURE__ */ x(sk, {
      hue: u.h,
      onChange: h,
      className: "react-colorful__last-control"
    })]
  });
}, pk = {
  defaultColor: "000",
  toHsva: ek,
  fromHsva: function(t) {
    return tk({
      h: t.h,
      s: t.s,
      v: t.v,
      a: 1
    });
  },
  equal: lk
}, gk = function(t) {
  return /* @__PURE__ */ x(dk, {
    ...yi({}, t, {
      colorModel: pk
    })
  });
}, mk = /^#?([0-9A-F]{3,8})$/i, vk = function(t) {
  var e = t.color, r = e === void 0 ? "" : e, i = t.onChange, o = t.onBlur, p = t.escape, g = t.validate, a = t.format, n = t.process, u = Ho(t, ["color", "onChange", "onBlur", "escape", "validate", "format", "process"]), h = Ae(function() {
    return p(r);
  }), s = h[0], l = h[1], c = Zi(i), f = Zi(o), m = Ie(function(v) {
    var b = p(v.target.value);
    l(b), g(b) && c(n ? n(b) : b);
  }, [p, n, g, c]), d = Ie(function(v) {
    g(v.target.value) || l(p(r)), f(v);
  }, [r, p, g, f]);
  return xe(function() {
    l(p(r));
  }, [r, p]), /* @__PURE__ */ x("input", {
    ...yi({}, u, {
      value: a ? a(s) : s,
      spellCheck: "false",
      onChange: m,
      onBlur: d
    })
  });
}, ih = function(t) {
  return "#" + t;
}, bk = function(t) {
  var e = t.prefixed, r = t.alpha, i = Ho(t, ["prefixed", "alpha"]), o = Ie(function(g) {
    return g.replace(/([^0-9A-F]+)/gi, "").substring(0, r ? 8 : 6);
  }, [r]), p = Ie(function(g) {
    return function(a, n) {
      var u = mk.exec(a), h = u ? u[1].length : 0;
      return h === 3 || h === 6 || !!n && h === 4 || !!n && h === 8;
    }(g, r);
  }, [r]);
  return ae.createElement(vk, yi({}, i, {
    escape: o,
    format: e ? ih : void 0,
    process: ih,
    validate: p
  }));
};
function yk(t) {
  return t && t.__esModule ? t.default : t;
}
var Xp = {}, Gp = {};
Gp = {
  alpha: "\u0623\u0644\u0641\u0627",
  blue: "\u0623\u0632\u0631\u0642",
  brightness: "\u0627\u0644\u0633\u0637\u0648\u0639",
  green: "\u0623\u062E\u0636\u0631",
  hue: "\u062F\u0631\u062C\u0629 \u0627\u0644\u0644\u0648\u0646",
  lightness: "\u0627\u0644\u0625\u0636\u0627\u0621\u0629",
  red: "\u0623\u062D\u0645\u0631",
  saturation: "\u0627\u0644\u062A\u0634\u0628\u0639"
};
var qp = {};
qp = {
  alpha: "\u0410\u043B\u0444\u0430",
  blue: "\u0421\u0438\u043D\u044C\u043E",
  brightness: "\u042F\u0440\u043A\u043E\u0441\u0442",
  green: "\u0417\u0435\u043B\u0435\u043D\u043E",
  hue: "\u041E\u0442\u0442\u0435\u043D\u044A\u043A",
  lightness: "\u041B\u0435\u043A\u043E\u0442\u0430",
  red: "\u0427\u0435\u0440\u0432\u0435\u043D\u043E",
  saturation: "\u041D\u0430\u0441\u0438\u0442\u0435\u043D\u043E\u0441\u0442"
};
var Kp = {};
Kp = {
  alpha: "Alfa",
  blue: "Modr\xE1",
  brightness: "Jas",
  green: "Zelen\xE1",
  hue: "Odst\xEDn",
  lightness: "Sv\u011Btlost",
  red: "\u010Cerven\xE1",
  saturation: "Sytost"
};
var Zp = {};
Zp = {
  alpha: "Alfa",
  blue: "Bl\xE5",
  brightness: "Lysstyrke",
  green: "Gr\xF8n",
  hue: "Tone",
  lightness: "Lyshed",
  red: "R\xF8d",
  saturation: "Farvem\xE6tning"
};
var Jp = {};
Jp = {
  alpha: "Alpha",
  blue: "Blau",
  brightness: "Helligkeit",
  green: "Gr\xFCn",
  hue: "Farbton",
  lightness: "Leuchtkraft",
  red: "Rot",
  saturation: "S\xE4ttigung"
};
var Qp = {};
Qp = {
  alpha: "\u0386\u03BB\u03C6\u03B1",
  blue: "\u039C\u03C0\u03BB\u03B5",
  brightness: "\u03A6\u03C9\u03C4\u03B5\u03B9\u03BD\u03CC\u03C4\u03B7\u03C4\u03B1",
  green: "\u03A0\u03C1\u03AC\u03C3\u03B9\u03BD\u03BF",
  hue: "\u03A4\u03CC\u03BD\u03BF\u03C2",
  lightness: "\u03A6\u03C9\u03C4\u03B5\u03B9\u03BD\u03CC\u03C4\u03B7\u03C4\u03B1",
  red: "\u039A\u03CC\u03BA\u03BA\u03B9\u03BD\u03BF",
  saturation: "\u039A\u03BF\u03C1\u03B5\u03C3\u03BC\u03CC\u03C2"
};
var eg = {};
eg = {
  hue: "Hue",
  saturation: "Saturation",
  lightness: "Lightness",
  brightness: "Brightness",
  red: "Red",
  green: "Green",
  blue: "Blue",
  alpha: "Alpha"
};
var tg = {};
tg = {
  alpha: "Alpha",
  blue: "Azul",
  brightness: "Brillo",
  green: "Verde",
  hue: "Tono",
  lightness: "Luminosidad",
  red: "Rojo",
  saturation: "Saturaci\xF3n"
};
var rg = {};
rg = {
  alpha: "Alfa",
  blue: "Sinine",
  brightness: "Heledus",
  green: "Roheline",
  hue: "V\xE4rv",
  lightness: "Valgus",
  red: "Punane",
  saturation: "K\xFCllastus"
};
var ig = {};
ig = {
  alpha: "Alpha",
  blue: "Sininen",
  brightness: "Kirkkaus",
  green: "Vihre\xE4",
  hue: "S\xE4vy",
  lightness: "Valom\xE4\xE4r\xE4",
  red: "Punainen",
  saturation: "V\xE4rikyll\xE4isyys"
};
var ng = {};
ng = {
  alpha: "Alpha",
  blue: "Bleu",
  brightness: "Luminosit\xE9",
  green: "Vert",
  hue: "Teinte",
  lightness: "Luminosit\xE9",
  red: "Rouge",
  saturation: "Saturation"
};
var og = {};
og = {
  alpha: "\u05D0\u05DC\u05E4\u05D0",
  blue: "\u05DB\u05D7\u05D5\u05DC",
  brightness: "\u05D1\u05D4\u05D9\u05E8\u05D5\u05EA",
  green: "\u05D9\u05E8\u05D5\u05E7",
  hue: "\u05D2\u05D5\u05D5\u05DF",
  lightness: "\u05DB\u05DE\u05D5\u05EA \u05D0\u05D5\u05E8",
  red: "\u05D0\u05D3\u05D5\u05DD",
  saturation: "\u05E8\u05D5\u05D5\u05D9\u05D4"
};
var sg = {};
sg = {
  alpha: "Alfa",
  blue: "Plava",
  brightness: "Svjetlina",
  green: "Zelena",
  hue: "Nijansa",
  lightness: "Osvijetljenost",
  red: "Crvena",
  saturation: "Zasi\u0107enost"
};
var ag = {};
ag = {
  alpha: "Alfa",
  blue: "K\xE9k",
  brightness: "F\xE9nyess\xE9g",
  green: "Z\xF6ld",
  hue: "Sz\xEDn\xE1rnyalat",
  lightness: "Vil\xE1goss\xE1g",
  red: "Piros",
  saturation: "Tel\xEDtetts\xE9g"
};
var lg = {};
lg = {
  alpha: "Alfa",
  blue: "Blu",
  brightness: "Luminosit\xE0",
  green: "Verde",
  hue: "Tonalit\xE0",
  lightness: "Luminosit\xE0",
  red: "Rosso",
  saturation: "Saturazione"
};
var cg = {};
cg = {
  alpha: "\u30A2\u30EB\u30D5\u30A1",
  blue: "\u9752",
  brightness: "\u660E\u308B\u3055",
  green: "\u7DD1",
  hue: "\u8272\u76F8",
  lightness: "\u660E\u5EA6",
  red: "\u8D64",
  saturation: "\u5F69\u5EA6"
};
var ug = {};
ug = {
  alpha: "\uC54C\uD30C",
  blue: "\uD30C\uB791",
  brightness: "\uBA85\uB3C4",
  green: "\uCD08\uB85D",
  hue: "\uC0C9\uC870",
  lightness: "\uBC1D\uAE30",
  red: "\uBE68\uAC15",
  saturation: "\uCC44\uB3C4"
};
var hg = {};
hg = {
  alpha: "Alfa",
  blue: "M\u0117lyna",
  brightness: "Ry\u0161kumas",
  green: "\u017Dalia",
  hue: "Atspalvis",
  lightness: "\u0160viesumas",
  red: "Raudona",
  saturation: "\u012Esotinimas"
};
var fg = {};
fg = {
  alpha: "Alfa",
  blue: "Zila",
  brightness: "Spilgtums",
  green: "Za\u013Ca",
  hue: "Nokr\u0101sa",
  lightness: "Gai\u0161ums",
  red: "Sarkana",
  saturation: "Pies\u0101tin\u0101jums"
};
var dg = {};
dg = {
  alpha: "Alfa",
  blue: "Bl\xE5",
  brightness: "Lysstyrke",
  green: "Gr\xF8nn",
  hue: "Fargetone",
  lightness: "Lyshet",
  red: "R\xF8d",
  saturation: "Metning"
};
var pg = {};
pg = {
  alpha: "Alfa",
  blue: "Blauw",
  brightness: "Helderheid",
  green: "Groen",
  hue: "Kleurtoon",
  lightness: "Lichtsterkte",
  red: "Rood",
  saturation: "Verzadiging"
};
var gg = {};
gg = {
  alpha: "Alfa",
  blue: "Niebieski",
  brightness: "Jasno\u015B\u0107",
  green: "Zielony",
  hue: "Odcie\u0144",
  lightness: "Jaskrawo\u015B\u0107",
  red: "Czerwony",
  saturation: "Nasycenie"
};
var mg = {};
mg = {
  alpha: "Alfa",
  blue: "Azul",
  brightness: "Brilho",
  green: "Verde",
  hue: "Matiz",
  lightness: "Luminosidade",
  red: "Vermelho",
  saturation: "Satura\xE7\xE3o"
};
var vg = {};
vg = {
  alpha: "Alfa",
  blue: "Azul",
  brightness: "Luminosidade",
  green: "Verde",
  hue: "Tonalidade",
  lightness: "Claridade",
  red: "Vermelho",
  saturation: "Satura\xE7\xE3o"
};
var bg = {};
bg = {
  alpha: "Alfa",
  blue: "Albastru",
  brightness: "Luminozitate",
  green: "Verde",
  hue: "Nuan\u021B\u0103",
  lightness: "Luminozitate",
  red: "Ro\u0219u",
  saturation: "Satura\u021Bie"
};
var yg = {};
yg = {
  alpha: "\u0410\u043B\u044C\u0444\u0430",
  blue: "\u0421\u0438\u043D\u0438\u0439",
  brightness: "\u042F\u0440\u043A\u043E\u0441\u0442\u044C",
  green: "\u0417\u0435\u043B\u0435\u043D\u044B\u0439",
  hue: "\u041E\u0442\u0442\u0435\u043D\u043E\u043A",
  lightness: "\u041E\u0441\u0432\u0435\u0449\u0435\u043D\u043D\u043E\u0441\u0442\u044C",
  red: "\u041A\u0440\u0430\u0441\u043D\u044B\u0439",
  saturation: "\u041D\u0430\u0441\u044B\u0449\u0435\u043D\u043D\u043E\u0441\u0442\u044C"
};
var wg = {};
wg = {
  alpha: "Alfa",
  blue: "Modr\xE1",
  brightness: "Jas",
  green: "Zelen\xE1",
  hue: "Odtie\u0148",
  lightness: "Svetlos\u0165",
  red: "\u010Cerven\xE1",
  saturation: "S\xFDtos\u0165"
};
var xg = {};
xg = {
  alpha: "Alfa",
  blue: "Modra",
  brightness: "Svetlost",
  green: "Zelena",
  hue: "Barva",
  lightness: "Lahkost",
  red: "Rde\u010Da",
  saturation: "Nasi\u010Denost"
};
var _g = {};
_g = {
  alpha: "Alfa",
  blue: "Plava",
  brightness: "Osvetljenost",
  green: "Zelena",
  hue: "Nijansa",
  lightness: "Osvetljenje",
  red: "Crvena",
  saturation: "Zasi\u0107enje"
};
var Sg = {};
Sg = {
  alpha: "Alfa",
  blue: "Bl\xE5tt",
  brightness: "Ljusstyrka",
  green: "Gr\xF6nt",
  hue: "Nyans",
  lightness: "Ljushet",
  red: "R\xF6tt",
  saturation: "M\xE4ttnad"
};
var Cg = {};
Cg = {
  alpha: "Alfa",
  blue: "Mavi",
  brightness: "Parlakl\u0131k",
  green: "Ye\u015Fil",
  hue: "Ton",
  lightness: "Canl\u0131l\u0131k",
  red: "K\u0131rm\u0131z\u0131",
  saturation: "Doygunluk"
};
var Tg = {};
Tg = {
  alpha: "\u0410\u043B\u044C\u0444\u0430",
  blue: "\u0421\u0438\u043D\u0456\u0439",
  brightness: "\u042F\u0441\u043A\u0440\u0430\u0432\u0456\u0441\u0442\u044C",
  green: "\u0417\u0435\u043B\u0435\u043D\u0438\u0439",
  hue: "\u0422\u043E\u043D",
  lightness: "\u041E\u0441\u0432\u0456\u0442\u043B\u0435\u043D\u0456\u0441\u0442\u044C",
  red: "\u0427\u0435\u0440\u0432\u043E\u043D\u0438\u0439",
  saturation: "\u041D\u0430\u0441\u0438\u0447\u0435\u043D\u0456\u0441\u0442\u044C"
};
var kg = {};
kg = {
  alpha: "Alpha",
  blue: "\u84DD\u8272",
  brightness: "\u4EAE\u5EA6",
  green: "\u7EFF\u8272",
  hue: "\u8272\u76F8",
  lightness: "\u660E\u4EAE\u5EA6",
  red: "\u7EA2\u8272",
  saturation: "\u9971\u548C\u5EA6"
};
var Eg = {};
Eg = {
  alpha: "Alpha",
  blue: "\u85CD\u8272",
  brightness: "\u4EAE\u5EA6",
  green: "\u7DA0\u8272",
  hue: "\u8272\u76F8",
  lightness: "\u660E\u4EAE",
  red: "\u7D05\u8272",
  saturation: "\u98FD\u548C\u5EA6"
};
Xp = {
  "ar-AE": Gp,
  "bg-BG": qp,
  "cs-CZ": Kp,
  "da-DK": Zp,
  "de-DE": Jp,
  "el-GR": Qp,
  "en-US": eg,
  "es-ES": tg,
  "et-EE": rg,
  "fi-FI": ig,
  "fr-FR": ng,
  "he-IL": og,
  "hr-HR": sg,
  "hu-HU": ag,
  "it-IT": lg,
  "ja-JP": cg,
  "ko-KR": ug,
  "lt-LT": hg,
  "lv-LV": fg,
  "nb-NO": dg,
  "nl-NL": pg,
  "pl-PL": gg,
  "pt-BR": mg,
  "pt-PT": vg,
  "ro-RO": bg,
  "ru-RU": yg,
  "sk-SK": wg,
  "sl-SI": xg,
  "sr-SP": _g,
  "sv-SE": Sg,
  "tr-TR": Cg,
  "uk-UA": Tg,
  "zh-CN": kg,
  "zh-TW": Eg
};
const wk = new YC(/* @__PURE__ */ yk(Xp));
function pn(t) {
  let e = Jt.parse(t) || Qt.parse(t) || er.parse(t);
  if (e)
    return e;
  throw new Error("Invalid color value: " + t);
}
class jl {
  toHexInt() {
    return this.toFormat("rgb").toHexInt();
  }
  getChannelValue(e) {
    if (e in this)
      return this[e];
    throw new Error("Unsupported color channel: " + e);
  }
  withChannelValue(e, r) {
    if (e in this) {
      let i = this.clone();
      return i[e] = r, i;
    }
    throw new Error("Unsupported color channel: " + e);
  }
  getChannelName(e, r) {
    return wk.getStringForLocale(e, r);
  }
  getColorSpaceAxes(e) {
    let { xChannel: r, yChannel: i } = e, o = r || this.getColorChannels().find(
      (a) => a !== i
    ), p = i || this.getColorChannels().find(
      (a) => a !== o
    ), g = this.getColorChannels().find(
      (a) => a !== o && a !== p
    );
    return {
      xChannel: o,
      yChannel: p,
      zChannel: g
    };
  }
}
class Jt extends jl {
  static parse(e) {
    let r = [];
    if (/^#[\da-f]+$/i.test(e) && [
      4,
      5,
      7,
      9
    ].includes(e.length)) {
      const p = (e.length < 6 ? e.replace(/[^#]/gi, "$&$&") : e).slice(1).split("");
      for (; p.length > 0; )
        r.push(parseInt(p.splice(0, 2).join(""), 16));
      r[3] = r[3] !== void 0 ? r[3] / 255 : void 0;
    }
    const i = e.match(/^rgba?\((.*)\)$/);
    i != null && i[1] && (r = i[1].split(",").map(
      (p) => Number(p.trim())
    ), r = r.map(
      (p, g) => _r(p, 0, g < 3 ? 255 : 1)
    ));
    var o;
    return r.length < 3 ? void 0 : new Jt(r[0], r[1], r[2], (o = r[3]) !== null && o !== void 0 ? o : 1);
  }
  toString(e) {
    switch (e) {
      case "hex":
        return "#" + (this.red.toString(16).padStart(2, "0") + this.green.toString(16).padStart(2, "0") + this.blue.toString(16).padStart(2, "0")).toUpperCase();
      case "hexa":
        return "#" + (this.red.toString(16).padStart(2, "0") + this.green.toString(16).padStart(2, "0") + this.blue.toString(16).padStart(2, "0") + Math.round(this.alpha * 255).toString(16).padStart(2, "0")).toUpperCase();
      case "rgb":
        return `rgb(${this.red}, ${this.green}, ${this.blue})`;
      case "css":
      case "rgba":
        return `rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`;
      default:
        return this.toFormat(e).toString(e);
    }
  }
  toFormat(e) {
    switch (e) {
      case "hex":
      case "hexa":
      case "rgb":
      case "rgba":
        return this;
      case "hsb":
      case "hsba":
        return this.toHSB();
      case "hsl":
      case "hsla":
        return this.toHSL();
      default:
        throw new Error("Unsupported color conversion: rgb -> " + e);
    }
  }
  toHexInt() {
    return this.red << 16 | this.green << 8 | this.blue;
  }
  toHSB() {
    const e = this.red / 255, r = this.green / 255, i = this.blue / 255, o = Math.min(e, r, i), p = Math.max(e, r, i), g = p - o, a = p === 0 ? 0 : g / p;
    let n = 0;
    if (g !== 0) {
      switch (p) {
        case e:
          n = (r - i) / g + (r < i ? 6 : 0);
          break;
        case r:
          n = (i - e) / g + 2;
          break;
        case i:
          n = (e - r) / g + 4;
          break;
      }
      n /= 6;
    }
    return new Qt(He(n * 360, 2), He(a * 100, 2), He(p * 100, 2), this.alpha);
  }
  toHSL() {
    const e = this.red / 255, r = this.green / 255, i = this.blue / 255, o = Math.min(e, r, i), p = Math.max(e, r, i), g = (p + o) / 2, a = p - o;
    let n, u;
    if (a === 0)
      n = u = 0;
    else {
      switch (u = a / (g < 0.5 ? p + o : 2 - p - o), p) {
        case e:
          n = (r - i) / a + (r < i ? 6 : 0);
          break;
        case r:
          n = (i - e) / a + 2;
          break;
        case i:
          n = (e - r) / a + 4;
          break;
      }
      n /= 6;
    }
    return new er(He(n * 360, 2), He(u * 100, 2), He(g * 100, 2), this.alpha);
  }
  clone() {
    return new Jt(this.red, this.green, this.blue, this.alpha);
  }
  getChannelRange(e) {
    switch (e) {
      case "red":
      case "green":
      case "blue":
        return {
          minValue: 0,
          maxValue: 255,
          step: 1,
          pageSize: 17
        };
      case "alpha":
        return {
          minValue: 0,
          maxValue: 1,
          step: 0.01,
          pageSize: 0.1
        };
      default:
        throw new Error("Unknown color channel: " + e);
    }
  }
  formatChannelValue(e, r) {
    let i, o = this.getChannelValue(e);
    switch (e) {
      case "red":
      case "green":
      case "blue":
        i = {
          style: "decimal"
        };
        break;
      case "alpha":
        i = {
          style: "percent"
        };
        break;
      default:
        throw new Error("Unknown color channel: " + e);
    }
    return new Fo(r, i).format(o);
  }
  getColorSpace() {
    return "rgb";
  }
  getColorChannels() {
    return Jt.colorChannels;
  }
  constructor(e, r, i, o) {
    super(), this.red = e, this.green = r, this.blue = i, this.alpha = o;
  }
}
Jt.colorChannels = [
  "red",
  "green",
  "blue"
];
const xk = /hsb\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%)\)|hsba\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d(.\d+)?)\)/;
class Qt extends jl {
  static parse(e) {
    let r;
    if (r = e.match(xk)) {
      var i;
      const [o, p, g, a] = ((i = r[1]) !== null && i !== void 0 ? i : r[2]).split(",").map(
        (n) => Number(n.trim().replace("%", ""))
      );
      return new Qt(Og(o, 360), _r(p, 0, 100), _r(g, 0, 100), _r(a != null ? a : 1, 0, 1));
    }
  }
  toString(e) {
    switch (e) {
      case "css":
        return this.toHSL().toString("css");
      case "hex":
        return this.toRGB().toString("hex");
      case "hexa":
        return this.toRGB().toString("hexa");
      case "hsb":
        return `hsb(${this.hue}, ${He(this.saturation, 2)}%, ${He(this.brightness, 2)}%)`;
      case "hsba":
        return `hsba(${this.hue}, ${He(this.saturation, 2)}%, ${He(this.brightness, 2)}%, ${this.alpha})`;
      default:
        return this.toFormat(e).toString(e);
    }
  }
  toFormat(e) {
    switch (e) {
      case "hsb":
      case "hsba":
        return this;
      case "hsl":
      case "hsla":
        return this.toHSL();
      case "rgb":
      case "rgba":
        return this.toRGB();
      default:
        throw new Error("Unsupported color conversion: hsb -> " + e);
    }
  }
  toHSL() {
    let e = this.saturation / 100, r = this.brightness / 100, i = r * (1 - e / 2);
    return e = i === 0 || i === 1 ? 0 : (r - i) / Math.min(i, 1 - i), new er(He(this.hue, 2), He(e * 100, 2), He(i * 100, 2), this.alpha);
  }
  toRGB() {
    let e = this.hue, r = this.saturation / 100, i = this.brightness / 100, o = (p, g = (p + e / 60) % 6) => i - r * i * Math.max(Math.min(g, 4 - g, 1), 0);
    return new Jt(Math.round(o(5) * 255), Math.round(o(3) * 255), Math.round(o(1) * 255), this.alpha);
  }
  clone() {
    return new Qt(this.hue, this.saturation, this.brightness, this.alpha);
  }
  getChannelRange(e) {
    switch (e) {
      case "hue":
        return {
          minValue: 0,
          maxValue: 360,
          step: 1,
          pageSize: 15
        };
      case "saturation":
      case "brightness":
        return {
          minValue: 0,
          maxValue: 100,
          step: 1,
          pageSize: 10
        };
      case "alpha":
        return {
          minValue: 0,
          maxValue: 1,
          step: 0.01,
          pageSize: 0.1
        };
      default:
        throw new Error("Unknown color channel: " + e);
    }
  }
  formatChannelValue(e, r) {
    let i, o = this.getChannelValue(e);
    switch (e) {
      case "hue":
        i = {
          style: "unit",
          unit: "degree",
          unitDisplay: "narrow"
        };
        break;
      case "saturation":
      case "brightness":
        i = {
          style: "percent"
        }, o /= 100;
        break;
      case "alpha":
        i = {
          style: "percent"
        };
        break;
      default:
        throw new Error("Unknown color channel: " + e);
    }
    return new Fo(r, i).format(o);
  }
  getColorSpace() {
    return "hsb";
  }
  getColorChannels() {
    return Qt.colorChannels;
  }
  constructor(e, r, i, o) {
    super(), this.hue = e, this.saturation = r, this.brightness = i, this.alpha = o;
  }
}
Qt.colorChannels = [
  "hue",
  "saturation",
  "brightness"
];
const _k = /hsl\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%)\)|hsla\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d(.\d+)?)\)/;
function Og(t, e) {
  return (t % e + e) % e;
}
class er extends jl {
  static parse(e) {
    let r;
    if (r = e.match(_k)) {
      var i;
      const [o, p, g, a] = ((i = r[1]) !== null && i !== void 0 ? i : r[2]).split(",").map(
        (n) => Number(n.trim().replace("%", ""))
      );
      return new er(Og(o, 360), _r(p, 0, 100), _r(g, 0, 100), _r(a != null ? a : 1, 0, 1));
    }
  }
  toString(e) {
    switch (e) {
      case "hex":
        return this.toRGB().toString("hex");
      case "hexa":
        return this.toRGB().toString("hexa");
      case "hsl":
        return `hsl(${this.hue}, ${He(this.saturation, 2)}%, ${He(this.lightness, 2)}%)`;
      case "css":
      case "hsla":
        return `hsla(${this.hue}, ${He(this.saturation, 2)}%, ${He(this.lightness, 2)}%, ${this.alpha})`;
      default:
        return this.toFormat(e).toString(e);
    }
  }
  toFormat(e) {
    switch (e) {
      case "hsl":
      case "hsla":
        return this;
      case "hsb":
      case "hsba":
        return this.toHSB();
      case "rgb":
      case "rgba":
        return this.toRGB();
      default:
        throw new Error("Unsupported color conversion: hsl -> " + e);
    }
  }
  toHSB() {
    let e = this.saturation / 100, r = this.lightness / 100, i = r + e * Math.min(r, 1 - r);
    return e = i === 0 ? 0 : 2 * (1 - r / i), new Qt(He(this.hue, 2), He(e * 100, 2), He(i * 100, 2), this.alpha);
  }
  toRGB() {
    let e = this.hue, r = this.saturation / 100, i = this.lightness / 100, o = r * Math.min(i, 1 - i), p = (g, a = (g + e / 30) % 12) => i - o * Math.max(Math.min(a - 3, 9 - a, 1), -1);
    return new Jt(Math.round(p(0) * 255), Math.round(p(8) * 255), Math.round(p(4) * 255), this.alpha);
  }
  clone() {
    return new er(this.hue, this.saturation, this.lightness, this.alpha);
  }
  getChannelRange(e) {
    switch (e) {
      case "hue":
        return {
          minValue: 0,
          maxValue: 360,
          step: 1,
          pageSize: 15
        };
      case "saturation":
      case "lightness":
        return {
          minValue: 0,
          maxValue: 100,
          step: 1,
          pageSize: 10
        };
      case "alpha":
        return {
          minValue: 0,
          maxValue: 1,
          step: 0.01,
          pageSize: 0.1
        };
      default:
        throw new Error("Unknown color channel: " + e);
    }
  }
  formatChannelValue(e, r) {
    let i, o = this.getChannelValue(e);
    switch (e) {
      case "hue":
        i = {
          style: "unit",
          unit: "degree",
          unitDisplay: "narrow"
        };
        break;
      case "saturation":
      case "lightness":
        i = {
          style: "percent"
        }, o /= 100;
        break;
      case "alpha":
        i = {
          style: "percent"
        };
        break;
      default:
        throw new Error("Unknown color channel: " + e);
    }
    return new Fo(r, i).format(o);
  }
  getColorSpace() {
    return "hsl";
  }
  getColorChannels() {
    return er.colorChannels;
  }
  constructor(e, r, i, o) {
    super(), this.hue = e, this.saturation = r, this.lightness = i, this.alpha = o;
  }
}
er.colorChannels = [
  "hue",
  "saturation",
  "lightness"
];
pn("#ffffff");
pn("hsl(0, 100%, 50%)");
const Sk = pn("#000000"), Ck = pn("#FFFFFF");
Sk.toHexInt();
Ck.toHexInt();
function Tk({
  onChange: t,
  value: e,
  colors: r
}) {
  const i = r.map((o) => {
    const p = e === o;
    return /* @__PURE__ */ x(Bt, {
      onClick: () => {
        t == null || t(o);
      },
      className: ue("relative block flex-shrink-0 w-26 h-26 border rounded", p && "shadow-md"),
      style: {
        backgroundColor: o
      },
      children: p && /* @__PURE__ */ x("span", {
        className: "absolute inset-0 m-auto rounded-full w-8 h-8 bg-white"
      })
    }, o);
  });
  return /* @__PURE__ */ x("div", {
    className: "flex gap-6",
    children: i
  });
}
function Rr(t = {}) {
  const {
    size: e = "md",
    startAdornment: r,
    endAdornment: i,
    startAppend: o,
    endAppend: p,
    className: g,
    labelPosition: a,
    labelDisplay: n = "block",
    inputClassName: u,
    inputWrapperClassName: h,
    unstyled: s,
    invalid: l,
    disabled: c,
    background: f = "transparent",
    flexibleHeight: m
  } = { ...t };
  if (s)
    return {
      label: "",
      input: u || "",
      wrapper: g || "",
      inputWrapper: h || "",
      adornment: "",
      append: { size: "", radius: "" },
      size: { font: "", height: "" },
      description: "",
      error: ""
    };
  const d = kk({
    size: t.size,
    flexibleHeight: m
  }), v = o || p, b = l ? "border-danger" : "border-divider", y = l ? "focus:ring-danger/focus focus:border-danger/60" : "focus:ring-primary/focus focus:border-primary/60";
  return {
    label: ue(
      n,
      "first-letter:capitalize text-left",
      c && "text-disabled",
      d.font,
      a === "side" ? "mr-16" : "mb-4"
    ),
    input: ue(
      "block text-left relative w-full appearance-none transition-shadow text",
      f === "transparent" && "bg-transparent",
      f === "bg-alt" && "bg-alt",
      f === "bg-paper" && "bg-paper",
      !v && "rounded",
      o && "rounded-r rounded-l-none",
      p && "rounded-l rounded-r-none",
      !v && `${b} border`,
      o && `${b} border-y border-r`,
      p && `${b} border-y border-l`,
      !c && `focus:ring ${y} focus:outline-none shadow-sm`,
      c && "text-disabled cursor-not-allowed",
      u,
      d.font,
      d.height,
      r ? "pl-46" : "pl-12",
      i ? "pr-46" : "pr-12"
    ),
    adornment: OS(e),
    append: {
      size: kl(e),
      radius: o ? "rounded-l" : "rounded-r"
    },
    wrapper: ue(g, d.font, {
      "flex items-center": a === "side"
    }),
    inputWrapper: ue(
      "relative",
      h,
      v && "flex items-stretch"
    ),
    size: d,
    description: "text-muted pt-10 text-xs",
    error: "text-danger pt-10 text-xs"
  };
}
function kk({ size: t, flexibleHeight: e }) {
  switch (t) {
    case "xs":
      return { font: "text-xs", height: e ? "min-h-30" : "h-30" };
    case "sm":
      return { font: "text-sm", height: e ? "min-h-36" : "h-36" };
    case "lg":
      return { font: "text-lg", height: e ? "min-h-50" : "h-50" };
    case "xl":
      return { font: "text-xl", height: e ? "min-h-60" : "h-60" };
    default:
      return { font: "text-sm", height: e ? "min-h-42" : "h-42" };
  }
}
const Ek = ["rgb(0,0,0)", "rgb(255, 255, 255)", "rgb(242, 38, 19)", "rgb(249, 105, 14)", "rgb(253, 227, 167)", "rgb(4, 147, 114)", "rgb(30, 139, 195)", "rgb(142, 68, 173)"];
function Ok({
  defaultValue: t,
  onChange: e,
  colorPresets: r,
  showInput: i
}) {
  const [o, p] = Ae(t), g = r || Ek, a = Rr({
    size: "sm"
  });
  return /* @__PURE__ */ ie("div", {
    children: [/* @__PURE__ */ x(gk, {
      className: "!w-auto",
      color: o,
      onChange: (n) => {
        e == null || e(n), p(n);
      }
    }), /* @__PURE__ */ ie("div", {
      className: "py-20 px-12",
      children: [g && /* @__PURE__ */ x(Tk, {
        colors: g,
        onChange: (n) => {
          if (n) {
            const u = pn(n).toString("hex");
            e == null || e(u), p(u);
          }
        },
        value: o
      }), i && /* @__PURE__ */ x("div", {
        className: "pt-20",
        children: /* @__PURE__ */ x(bk, {
          autoComplete: "off",
          role: "textbox",
          autoCorrect: "off",
          spellCheck: "false",
          required: !0,
          "aria-label": "Hex color",
          prefixed: !0,
          className: a.input,
          color: o,
          onChange: (n) => {
            e == null || e(n), p(n);
          }
        })
      })]
    })]
  });
}
const Uo = ae.createContext(null);
function Pg() {
  return De(Uo);
}
function Lr() {
  const { lines: t, localeCode: e } = zo();
  return { trans: Ie(
    (i) => Pk({ ...i, lines: t, localeCode: e }),
    [t, e]
  ) };
}
const Pk = ln(
  (t) => {
    let { lines: e, message: r, values: i, localeCode: o } = t;
    return r = (e == null ? void 0 : e[r]) || r, i && (r = Dp(o, t), Object.entries(i).forEach(([p, g]) => {
      r = r.replace(`:${p}`, `${g}`);
    })), r;
  },
  { equals: ya, callTimeout: 0 }
);
function Mk({
  onDismiss: t
}) {
  const {
    trans: e
  } = Lr(), r = () => {
    t && t();
  };
  return /* @__PURE__ */ x("button", {
    className: "sr-only",
    "aria-label": e(ce("Dismiss")),
    tabIndex: -1,
    onClick: r
  });
}
function Wo(t) {
  const {
    type: e = "modal",
    dialogProps: r,
    ...i
  } = De(Uo), {
    children: o,
    className: p,
    size: g = "md",
    background: a,
    radius: n = "rounded",
    maxWidth: u = "max-w-dialog",
    ...h
  } = t;
  let s = null;
  (e === "popover" || e === "tray") && (s = /* @__PURE__ */ x(Mk, {
    onDismiss: i.close
  }));
  const l = g === "fullscreenTakeover" || e === "tray", c = ue("mx-auto pointer-events-auto outline-none flex flex-col overflow-hidden", a || "bg-paper", e !== "tray" && Ak(g), e === "tray" && "rounded-t", g !== "fullscreenTakeover" && "shadow-2xl border max-h-dialog", !l && `${n} ${u}`, p);
  return /* @__PURE__ */ ie("div", {
    ...vi({
      role: "dialog",
      tabIndex: -1
    }, r, h),
    style: {
      "--be-dialog-padding": "24px"
    },
    "aria-modal": !0,
    className: c,
    children: [Sr.toArray(o).map((f) => {
      var m;
      return tr(f) ? dt(f, {
        size: (m = f.props.size) != null ? m : g
      }) : f;
    }), s]
  });
}
function Ak(t) {
  switch (t) {
    case "xs":
      return "w-320";
    case "sm":
      return "w-384";
    case "md":
      return "w-440";
    case "lg":
      return "w-620";
    case "xl":
      return "w-780";
    case "2xl":
      return "w-850";
    case "fullscreenTakeover":
      return "w-full h-full";
    default:
      return t;
  }
}
const Bl = me(/* @__PURE__ */ x("path", {
  d: "M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z"
}), "KeyboardArrowDownOutlined"), Dk = et(({
  children: t,
  autoFocus: e = !1,
  restoreFocus: r = !0,
  isDismissable: i = !0,
  isOpen: o = !1,
  onClose: p
}, g) => {
  const a = Ml(), n = Ir(g);
  return /* @__PURE__ */ ie("div", {
    className: "isolate z-modal fixed inset-0",
    style: a,
    children: [/* @__PURE__ */ x(Il, {
      onClick: () => {
        i && p();
      }
    }, "modal-underlay"), /* @__PURE__ */ x(ot.div, {
      ref: n,
      className: "absolute inset-0 w-full h-full z-20 flex items-center justify-center pointer-events-none",
      role: "presentation",
      initial: {
        opacity: 0,
        scale: 0.7
      },
      animate: {
        opacity: 1,
        scale: 1
      },
      exit: {
        opacity: 0,
        scale: 1
      },
      children: /* @__PURE__ */ x(Ro, {
        restoreFocus: r,
        autoFocus: e,
        contain: !0,
        children: t
      })
    })]
  });
});
function Yo(t) {
  let {
    children: e,
    type: r,
    disableInitialTransition: i,
    onClose: o,
    isDismissable: p = !0,
    triggerRef: g,
    moveFocusToDialog: a = !0,
    returnFocusToTrigger: n = !0
  } = t;
  const [u, h] = kr(t.isOpen, t.defaultIsOpen, t.onOpenChange), {
    dialogTrigger: s,
    dialog: l
  } = Ik(e);
  jo() && r === "popover" && (r = "modal");
  const {
    x: f,
    y: m,
    reference: d,
    floating: v,
    strategy: b,
    refs: y
  } = Sp({
    ...t,
    disablePositioning: r === "modal"
  }), w = r === "popover" ? {
    position: b,
    top: m != null ? m : "",
    left: f != null ? f : ""
  } : {}, _ = yt(), S = `${_}-label`, T = `${_}-description`, A = `${_}-form`, R = Ie((ee) => {
    o == null || o(ee), h(!1);
  }, [o, h]);
  Ft(() => {
    (g == null ? void 0 : g.current) && y.reference.current !== g.current && d(g.current);
  }, [d, g, y]);
  const N = Je(() => ({
    "aria-labelledby": S,
    "aria-describedby": T
  }), [S, T]);
  let U;
  r === "modal" ? U = Dk : r === "tray" ? U = Mp : U = Nn;
  const Q = Je(() => ({
    dialogProps: N,
    type: r,
    labelId: S,
    descriptionId: T,
    isDismissable: p,
    close: R,
    formId: A
  }), [R, T, N, A, S, r, p]);
  return /* @__PURE__ */ ie(Gt, {
    children: [s && dt(s, {
      onClick: Mt((ee) => {
        ee.stopPropagation(), h(!u);
      }),
      ref: g ? null : d,
      ...s.props
    }), Ct && Th(/* @__PURE__ */ x(cr, {
      initial: !i,
      children: u && /* @__PURE__ */ x(Uo.Provider, {
        value: Q,
        children: /* @__PURE__ */ x(U, {
          ref: v,
          triggerRef: y.reference,
          style: w,
          restoreFocus: n,
          autoFocus: a,
          isOpen: u,
          onClose: R,
          isDismissable: p,
          children: l
        })
      })
    }), Ct)]
  });
}
function Ik(t) {
  const e = ae.Children.toArray(t);
  return e && e.length === 2 ? {
    dialogTrigger: e[0],
    dialog: e[1]
  } : {
    dialog: e[0]
  };
}
function Fr(t) {
  const {
    label: e,
    className: r,
    value: i,
    onChange: o,
    size: p
  } = t, g = oe((c) => {
    var f, m;
    return (m = (f = c.config.ui) == null ? void 0 : f.colorPresets) == null ? void 0 : m.items;
  }) || [], a = Rr({
    size: p
  }), [n, u] = Ae(i), [h, s] = Ae(!1), l = (c) => {
    u(c), o == null || o(c);
  };
  return /* @__PURE__ */ ie("div", {
    className: ue(r, "w-max"),
    children: [e && /* @__PURE__ */ x("span", {
      className: a.label,
      children: e
    }), /* @__PURE__ */ ie(Yo, {
      type: "popover",
      isOpen: h,
      onOpenChange: s,
      children: [/* @__PURE__ */ ie(Bt, {
        className: ue(a.input, "inline-flex items-center"),
        "aria-label": t["aria-label"],
        children: [/* @__PURE__ */ x("span", {
          className: "block flex-shrink-0 mr-5 border rounded h-2/4 aspect-square",
          style: {
            backgroundColor: n
          }
        }), /* @__PURE__ */ x(Rk, {
          isActive: h,
          className: a.adornment
        })]
      }), /* @__PURE__ */ x(Wo, {
        size: "auto",
        children: /* @__PURE__ */ x(Ok, {
          onChange: l,
          defaultValue: n,
          colorPresets: g
        })
      })]
    })]
  });
}
function Rk({
  isActive: t,
  className: e
}) {
  return /* @__PURE__ */ x(Bl, {
    size: "sm",
    className: `transition-transform ml-auto flex-shrink-0 ${t ? "rotate-180" : "rotate-0"} ${e}`
  });
}
function Lk(t) {
  const {
    size: e = "md",
    inline: r,
    label: i,
    showValueLabel: o = !!i,
    className: p,
    slider: g,
    children: a
  } = t, {
    domProps: n,
    trackRef: u,
    getThumbPercent: h,
    getThumbValueLabel: s,
    labelId: l,
    groupId: c,
    thumbIds: f,
    isDisabled: m,
    numberFormatter: d,
    minValue: v,
    maxValue: b,
    step: y,
    values: w,
    getValueLabel: _
  } = g;
  let S = "", T = Math.max([...d.format(v)].length, [...d.format(b)].length, [...d.format(y)].length);
  _ ? S = _(w[0]) : w.length === 1 ? S = s(0) : w.length === 2 && (S = `${s(0)} \u2013 ${s(1)}`, T = 3 + 2 * Math.max(T, [...d.format(v)].length, [...d.format(b)].length));
  const A = Rr({
    size: e,
    disabled: m,
    labelDisplay: "flex"
  }), R = ue("w-full flex-shrink-0 touch-none", p, {
    "flex items-center": r
  });
  return /* @__PURE__ */ ie("div", {
    className: R,
    role: "group",
    id: c,
    children: [/* @__PURE__ */ ie("div", {
      className: ue(A.label, "select-none"),
      children: [i && /* @__PURE__ */ x("label", {
        onClick: () => {
          var N;
          (N = document.getElementById(f[0])) == null || N.focus();
        },
        id: l,
        htmlFor: c,
        children: i
      }), o && /* @__PURE__ */ x("output", {
        htmlFor: f[0],
        className: "ml-auto text-right",
        "aria-live": "off",
        style: T ? {
          width: `${T}ch`,
          minWidth: `${T}ch`
        } : void 0,
        children: S
      })]
    }), /* @__PURE__ */ ie("div", {
      ref: u,
      className: "h-30 relative",
      ...n,
      role: "presentation",
      children: [/* @__PURE__ */ x("div", {
        className: `absolute inset-0 m-auto h-4 rounded ${m ? "bg-disabled" : "bg-primary-light"}`
      }), /* @__PURE__ */ x("div", {
        className: `absolute inset-0 my-auto h-4 rounded ${m ? "bg-disabled-fg" : "bg-primary"}`,
        style: {
          width: `${h(0) * 100}%`
        }
      }), a]
    })]
  });
}
function Fk(t = {}) {
  const { localeCode: e } = zo();
  return Je(
    () => new Fo(e, t),
    [e, t]
  );
}
function Mg({
  minValue: t = 0,
  maxValue: e = 100,
  isDisabled: r = !1,
  step: i = 1,
  formatOptions: o,
  onChangeEnd: p,
  label: g,
  getValueLabel: a,
  ...n
}) {
  var W;
  const u = Fk(o), { addGlobalListener: h, removeGlobalListener: s } = wl(), l = de(null), [c, f] = kr(
    n.value ? n.value : void 0,
    (W = n.defaultValue) != null ? W : [t],
    n.onChange
  ), m = de(null);
  m.current = c;
  const [d, v] = Ae(
    new Array(c.length).fill(!1)
  ), b = de(null);
  b.current = d;
  function y(j) {
    return u.format(j);
  }
  const w = (j) => {
    var te;
    return ((te = b.current) == null ? void 0 : te[j]) || !1;
  }, _ = (j) => y(c[j]), S = (j) => j === 0 ? t : c[j - 1], T = (j) => j === c.length - 1 ? e : c[j + 1], A = (j, te) => {
    if (r || !ne(j) || !m.current)
      return;
    const V = S(j), F = T(j);
    te = l_(te, V, F, i), m.current = nh(m.current, j, te), f(m.current);
  }, R = (j, te) => {
    var F;
    if (r || !ne(j))
      return;
    const V = (F = b.current) == null ? void 0 : F[j];
    b.current = nh(
      b.current || [],
      j,
      te
    ), v(b.current), p && V && !b.current.some(Boolean) && p(m.current || []);
  }, [N, U] = Ae(
    void 0
  ), Q = (j) => (j - t) / (e - t), ee = (j) => Q(m.current[j]), J = (j, te) => {
    A(j, re(te));
  }, q = (j) => Math.round((j - t) / i) * i + t, re = (j) => {
    const te = j * (e - t) + t;
    return go(q(te), t, e);
  }, le = de(
    new Array(c.length).fill(!0)
  ), ne = (j) => le.current[j], C = (j, te) => {
    le.current[j] = te;
  }, k = de(null), P = de(void 0), D = (j) => {
    if (!(j.pointerType === "mouse" && (j.button !== 0 || j.altKey || j.ctrlKey || j.metaKey)) && l.current && !r && c.every((te, V) => !d[V])) {
      const te = l.current.offsetWidth, V = l.current.getBoundingClientRect().left, X = (j.clientX - V) / te, G = re(X);
      let H;
      const Z = c.findIndex((se) => G - se < 0);
      if (Z === 0)
        H = Z;
      else if (Z === -1)
        H = c.length - 1;
      else {
        const se = c[Z - 1], ye = c[Z];
        Math.abs(se - G) < Math.abs(ye - G) ? H = Z - 1 : H = Z;
      }
      H >= 0 && ne(H) ? (j.preventDefault(), k.current = H, U(H), P.current = j.pointerId, R(k.current, !0), A(H, G), h(window, "pointerup", E, !1)) : k.current = null;
    }
  }, B = de(null), { domProps: M } = $o({
    onPointerDown: D,
    onMoveStart() {
      B.current = null;
    },
    onMove(j, te) {
      var F;
      const V = ((F = l.current) == null ? void 0 : F.offsetWidth) || 0;
      if (B.current == null && (B.current = ee(k.current || 0) * V), B.current += te, k.current != null && l.current) {
        const X = go(B.current / V, 0, 1);
        J(k.current, X);
      }
    },
    onMoveEnd() {
      k.current != null && (R(k.current, !1), k.current = null);
    }
  }), E = (j) => {
    j.pointerId === P.current && (k.current != null && (R(k.current, !1), k.current = null), s(window, "pointerup", E, !1));
  }, L = yt(), z = g ? `${L}-label` : void 0, Y = `${L}-group`, $ = [...Array(c.length)].map((j, te) => `${L}-thumb-${te}`);
  return {
    domProps: M,
    trackRef: l,
    isDisabled: r,
    step: i,
    values: c,
    minValue: t,
    maxValue: e,
    focusedThumb: N,
    labelId: z,
    groupId: Y,
    thumbIds: $,
    numberFormatter: u,
    getThumbPercent: ee,
    getThumbMinValue: S,
    getThumbMaxValue: T,
    getThumbValueLabel: _,
    isThumbDragging: w,
    setThumbValue: A,
    updateDraggedThumbs: R,
    setThumbEditable: C,
    setFocusedThumb: U,
    getValueLabel: a
  };
}
function nh(t, e, r) {
  return t[e] === r ? t : [...t.slice(0, e), r, ...t.slice(e + 1)];
}
function zk({
  index: t,
  slider: e,
  isDisabled: r,
  ariaLabel: i,
  inputRef: o,
  onBlur: p
}) {
  const g = Ir(o), {
    addGlobalListener: a,
    removeGlobalListener: n
  } = wl(), {
    step: u,
    values: h,
    focusedThumb: s,
    labelId: l,
    thumbIds: c,
    isDisabled: f,
    getThumbPercent: m,
    getThumbMinValue: d,
    getThumbMaxValue: v,
    getThumbValueLabel: b,
    setThumbValue: y,
    updateDraggedThumbs: w,
    isThumbDragging: _,
    setThumbEditable: S,
    setFocusedThumb: T
  } = e, A = h[t];
  S(t, !r);
  const R = r || f, N = Ie(() => {
    g.current && g.current.focus({
      preventScroll: !0
    });
  }, [g]), U = s === t;
  xe(() => {
    U && N();
  }, [U, N]);
  const Q = de(void 0), ee = (q) => {
    q.pointerId === Q.current && (N(), w(t, !1), n(window, "pointerup", ee, !1));
  }, J = ue("outline-none rounded-full w-18 h-18 top-1/2 -translate-y-1/2 -translate-x-1/2 absolute inset-0 transition-button duration-200", !R && "focus-within:ring focus-within:ring-primary-light shadow-md", jk({
    isDisabled: R,
    isDragging: _(t)
  }));
  return /* @__PURE__ */ x("div", {
    role: "presentation",
    className: J,
    style: {
      left: `${Math.max(m(t) * 100, 0)}%`
    },
    onPointerDown: (q) => {
      q.button !== 0 || q.altKey || q.ctrlKey || q.metaKey || (N(), Q.current = q.pointerId, w(t, !0), a(window, "pointerup", ee, !1));
    },
    children: /* @__PURE__ */ x("input", {
      id: c[t],
      onKeyDown: Mt(() => {
        w(t, !0);
      }),
      onKeyUp: Mt(() => {
        w(t, !1);
      }),
      ref: g,
      tabIndex: R ? void 0 : 0,
      min: d(t),
      max: v(t),
      step: u,
      value: A,
      disabled: R,
      "aria-label": i,
      "aria-labelledby": l,
      "aria-orientation": "horizontal",
      "aria-valuetext": b(t),
      onFocus: () => {
        T(t);
      },
      onBlur: (q) => {
        T(void 0), w(t, !1), p == null || p(q);
      },
      onChange: (q) => {
        y(t, parseFloat(q.target.value));
      },
      type: "range",
      className: "sr-only"
    })
  });
}
function jk({
  isDisabled: t,
  isDragging: e
}) {
  return t ? "bg-slider-disabled cursor-default" : ue("hover:bg-primary-dark", e ? "bg-primary-dark" : "bg-primary");
}
var Bk = (t) => t.type === "checkbox", Nk = (t) => t instanceof Date, Ag = (t) => t == null;
const Vk = (t) => typeof t == "object";
var Xo = (t) => !Ag(t) && !Array.isArray(t) && Vk(t) && !Nk(t), $k = (t) => Xo(t) && t.target ? Bk(t.target) ? t.target.checked : t.target.value : t, Hk = (t) => t.substring(0, t.search(/\.\d+(\.|$)/)) || t, Uk = (t, e) => t.has(Hk(e)), Wk = (t) => Array.isArray(t) ? t.filter(Boolean) : [], Ai = (t) => t === void 0, pt = (t, e, r) => {
  if (!e || !Xo(t))
    return r;
  const i = Wk(e.split(/[,[\].]+?/)).reduce((o, p) => Ag(o) ? o : o[p], t);
  return Ai(i) || i === t ? Ai(t[e]) ? r : t[e] : i;
};
const oh = {
  BLUR: "blur",
  FOCUS_OUT: "focusout",
  CHANGE: "change"
}, ka = {
  onBlur: "onBlur",
  onChange: "onChange",
  onSubmit: "onSubmit",
  onTouched: "onTouched",
  all: "all"
}, Yk = ae.createContext(null), Nl = () => ae.useContext(Yk);
var Xk = (t, e, r, i = !0) => {
  const o = {};
  for (const p in t)
    Object.defineProperty(o, p, {
      get: () => {
        const g = p;
        return e[g] !== ka.all && (e[g] = !i || ka.all), r && (r[g] = !0), t[g];
      }
    });
  return o;
}, Gk = (t) => Xo(t) && !Object.keys(t).length, qk = (t, e, r) => {
  const {
    name: i,
    ...o
  } = t;
  return Gk(o) || Object.keys(o).length >= Object.keys(e).length || Object.keys(o).find((p) => e[p] === (!r || ka.all));
}, Kk = (t) => Array.isArray(t) ? t : [t], Dg = (t, e, r) => r && e ? t === e : !t || !e || t === e || Kk(t).some((i) => i && (i.startsWith(e) || e.startsWith(i)));
function Ig(t) {
  const e = ae.useRef(t);
  e.current = t, ae.useEffect(() => {
    const r = (o) => {
      o && o.unsubscribe();
    }, i = !t.disabled && e.current.subject.subscribe({
      next: e.current.callback
    });
    return () => r(i);
  }, [t.disabled]);
}
function Zk(t) {
  const e = Nl(), {
    control: r = e.control,
    disabled: i,
    name: o,
    exact: p
  } = t || {}, [g, a] = ae.useState(r._formState), n = ae.useRef({
    isDirty: !1,
    dirtyFields: !1,
    touchedFields: !1,
    isValidating: !1,
    isValid: !1,
    errors: !1
  }), u = ae.useRef(o), h = ae.useRef(!0);
  u.current = o;
  const s = ae.useCallback((l) => h.current && Dg(u.current, l.name, p) && qk(l, n.current) && a({
    ...r._formState,
    ...l
  }), [r, p]);
  return Ig({
    disabled: i,
    callback: s,
    subject: r._subjects.state
  }), ae.useEffect(() => (h.current = !0, () => {
    h.current = !1;
  }), []), Xk(g, r._proxyFormState, n.current, !1);
}
var Jk = (t) => typeof t == "string", Qk = (t, e, r, i) => {
  const o = Array.isArray(t);
  return Jk(t) ? (i && e.watch.add(t), pt(r, t)) : o ? t.map((p) => (i && e.watch.add(p), pt(r, p))) : (i && (e.watchAll = !0), r);
}, eE = (t) => typeof t == "function", tE = (t) => {
  for (const e in t)
    if (eE(t[e]))
      return !0;
  return !1;
};
function rE(t) {
  const e = Nl(), {
    control: r = e.control,
    name: i,
    defaultValue: o,
    disabled: p,
    exact: g
  } = t || {}, a = ae.useRef(i);
  a.current = i;
  const n = ae.useCallback((s) => {
    if (Dg(a.current, s.name, g)) {
      const l = Qk(a.current, r._names, s.values || r._formValues);
      h(Ai(a.current) || Xo(l) && !tE(l) ? {
        ...l
      } : Array.isArray(l) ? [...l] : Ai(l) ? o : l);
    }
  }, [r, g, o]);
  Ig({
    disabled: p,
    subject: r._subjects.watch,
    callback: n
  });
  const [u, h] = ae.useState(Ai(o) ? r._getWatch(i) : o);
  return ae.useEffect(() => {
    r._removeUnmounted();
  }), u;
}
function iE(t) {
  const e = Nl(), {
    name: r,
    control: i = e.control,
    shouldUnregister: o
  } = t, p = Uk(i._names.array, r), g = rE({
    control: i,
    name: r,
    defaultValue: pt(i._formValues, r, pt(i._defaultValues, r, t.defaultValue)),
    exact: !0
  }), a = Zk({
    control: i,
    name: r
  }), n = ae.useRef(i.register(r, {
    ...t.rules,
    value: g
  }));
  return ae.useEffect(() => {
    const u = (h, s) => {
      const l = pt(i._fields, h);
      l && (l._f.mount = s);
    };
    return u(r, !0), () => {
      const h = i._options.shouldUnregister || o;
      (p ? h && !i._stateFlags.action : h) ? i.unregister(r) : u(r, !1);
    };
  }, [r, i, p, o]), {
    field: {
      name: r,
      value: g,
      onChange: ae.useCallback((u) => {
        n.current.onChange({
          target: {
            value: $k(u),
            name: r
          },
          type: oh.CHANGE
        });
      }, [r]),
      onBlur: ae.useCallback(() => {
        n.current.onBlur({
          target: {
            value: pt(i._formValues, r),
            name: r
          },
          type: oh.BLUR
        });
      }, [r, i]),
      ref: ae.useCallback((u) => {
        const h = pt(i._fields, r);
        u && h && u.focus && (h._f.ref = {
          focus: () => u.focus(),
          select: () => u.select(),
          setCustomValidity: (s) => u.setCustomValidity(s),
          reportValidity: () => u.reportValidity()
        });
      }, [r, i._fields])
    },
    formState: a,
    fieldState: Object.defineProperties({}, {
      invalid: {
        enumerable: !0,
        get: () => !!pt(a.errors, r)
      },
      isDirty: {
        enumerable: !0,
        get: () => !!pt(a.dirtyFields, r)
      },
      isTouched: {
        enumerable: !0,
        get: () => !!pt(a.touchedFields, r)
      },
      error: {
        enumerable: !0,
        get: () => pt(a.errors, r)
      }
    })
  };
}
function zr({
  inputRef: t,
  onBlur: e,
  ...r
}) {
  const {
    onChange: i,
    onChangeEnd: o,
    value: p,
    defaultValue: g,
    ...a
  } = r, n = {
    ...a,
    value: p != null ? [p] : void 0,
    defaultValue: g != null ? [g] : void 0,
    onChange: (h) => {
      i == null || i(h[0]);
    },
    onChangeEnd: (h) => {
      o == null || o(h[0]);
    }
  }, u = Mg(n);
  return /* @__PURE__ */ x(Lk, {
    ...n,
    slider: u,
    children: /* @__PURE__ */ x(zk, {
      index: 0,
      slider: u,
      inputRef: t,
      onBlur: e
    })
  });
}
function Ea({
  children: t,
  direction: e,
  className: r
}) {
  const i = e === "start" ? "left-0" : "right-0";
  return t ? /* @__PURE__ */ x("div", {
    className: ue("absolute h-full min-w-42 flex items-center justify-center top-0 text-muted z-10", i, r),
    children: t
  }) : null;
}
const Rg = ae.forwardRef((t, e) => {
  const {
    children: r,
    description: i,
    errorMessage: o,
    descriptionProps: p = {},
    errorMessageProps: g = {},
    startAdornment: a,
    endAdornment: n,
    startAppend: u,
    endAppend: h,
    fieldClassNames: s,
    disabled: l,
    wrapperProps: c
  } = t;
  return /* @__PURE__ */ ie("div", {
    className: s.wrapper,
    ref: e,
    ...c,
    children: [/* @__PURE__ */ x(nE, {
      ...t
    }), /* @__PURE__ */ ie("div", {
      className: s.inputWrapper,
      children: [/* @__PURE__ */ x(Ea, {
        direction: "start",
        className: s.adornment,
        children: a
      }), u && /* @__PURE__ */ x(sh, {
        style: s.append,
        disabled: l,
        children: u
      }), r, h && /* @__PURE__ */ x(sh, {
        style: s.append,
        disabled: l,
        children: h
      }), /* @__PURE__ */ x(Ea, {
        direction: "end",
        className: s.adornment,
        children: n
      })]
    }), i && !o && /* @__PURE__ */ x("div", {
      className: s.description,
      ...p,
      children: i
    }), o && /* @__PURE__ */ x("div", {
      className: s.error,
      ...g,
      children: o
    })]
  });
});
function nE({
  labelElementType: t,
  fieldClassNames: e,
  labelProps: r,
  label: i,
  labelSuffix: o,
  required: p
}) {
  if (!i)
    return null;
  const a = /* @__PURE__ */ ie(t || "label", {
    className: e.label,
    ...r,
    children: [i, p && /* @__PURE__ */ x("span", {
      className: "text-danger",
      children: " *"
    })]
  });
  return o ? /* @__PURE__ */ ie("div", {
    className: "flex items-center gap-14 w-full",
    children: [a, /* @__PURE__ */ x("div", {
      className: "ml-auto mb-4 text-muted text-xs",
      children: o
    })]
  }) : a;
}
function sh({
  children: t,
  style: e,
  disabled: r
}) {
  return ae.cloneElement(t, {
    ...t.props,
    disabled: t.props.disabled || r,
    ...e
  });
}
function Vl({ autoFocus: t, autoSelectText: e }, r) {
  const i = de(t);
  xe(() => {
    var o;
    i.current && r.current && ((o = r.current) == null || o.focus(), e && r.current.nodeName.toLowerCase() === "input" && requestAnimationFrame(() => {
      r.current.select();
    })), i.current = !1;
  }, [r, e]);
}
function Lg(t) {
  const {
    focusRef: e,
    labelElementType: r = "label",
    label: i,
    labelSuffix: o,
    autoFocus: p,
    autoSelectText: g,
    labelPosition: a,
    size: n,
    errorMessage: u,
    description: h,
    flexibleHeight: s,
    startAdornment: l,
    endAdornment: c,
    startAppend: f,
    endAppend: m,
    className: d,
    inputClassName: v,
    inputWrapperClassName: b,
    unstyled: y,
    background: w,
    invalid: _,
    disabled: S,
    id: T,
    ...A
  } = t;
  Vl(t, e);
  const R = yt(), N = T || R, U = `${N}-label`, Q = `${N}-description`, ee = `${N}-error`, J = {
    id: U,
    htmlFor: r === "label" ? N : void 0
  }, q = {
    id: Q
  }, re = {
    id: ee
  }, ne = {
    "aria-label": !t.label && !t["aria-label"] && t.placeholder ? t.placeholder : t["aria-label"],
    "aria-invalid": _ || void 0,
    id: N,
    disabled: S,
    ...A
  }, C = [];
  i && C.push(J.id), ne["aria-labelledby"] && C.push(ne["aria-labelledby"]), ne["aria-labelledby"] = C.length ? C.join(" ") : void 0;
  const k = [];
  return h && k.push(q.id), u && k.push(re.id), ne["aria-describedby"] && k.push(ne["aria-describedby"]), ne["aria-describedby"] = k.length ? k.join(" ") : void 0, {
    fieldProps: {
      errorMessageProps: re,
      descriptionProps: q,
      labelProps: J,
      disabled: S,
      label: i,
      labelSuffix: o,
      autoFocus: p,
      autoSelectText: g,
      labelPosition: a,
      size: n,
      errorMessage: u,
      description: h,
      flexibleHeight: s,
      startAdornment: l,
      endAdornment: c,
      startAppend: f,
      endAppend: m,
      className: d,
      inputClassName: v,
      inputWrapperClassName: b,
      unstyled: y,
      background: w,
      invalid: _
    },
    inputProps: ne
  };
}
const $l = ae.forwardRef((t, e) => {
  const {
    hideCaret: r,
    placeholder: i = /* @__PURE__ */ x(we, {
      message: "Select an option..."
    }),
    selectedValue: o,
    onItemSelected: p,
    onOpenChange: g,
    onInputValueChange: a,
    onSelectionChange: n,
    selectionMode: u,
    minWidth: h = "min-w-128",
    children: s,
    ...l
  } = t, c = jo(), f = Cp({
    ...t,
    floatingWidth: c ? "auto" : "matchTrigger",
    selectionMode: "single",
    role: "listbox"
  }, e), {
    state: {
      selectedValues: m,
      isOpen: d,
      setIsOpen: v,
      activeIndex: b,
      setSelectedIndex: y
    },
    focusItem: w,
    listboxId: _,
    reference: S,
    refs: T,
    listContent: A
  } = f, {
    fieldProps: R,
    inputProps: N
  } = Lg({
    ...l,
    focusRef: T.reference
  }), U = f.collection.get(m[0]), Q = U ? /* @__PURE__ */ ie("span", {
    className: "flex items-center gap-10",
    children: [U.element.props.startIcon, U.element.props.children]
  }) : /* @__PURE__ */ x("span", {
    className: "italic",
    children: i
  }), ee = Rr({
    ...t,
    endAdornment: !0
  }), {
    handleTriggerKeyDown: J,
    handleListboxKeyboardNavigation: q
  } = Rp(f), {
    findMatchingItem: re
  } = Lp();
  return /* @__PURE__ */ x(Ip, {
    listbox: f,
    onKeyDownCapture: (C) => {
      if (!d)
        return;
      const k = re(C, A, b);
      k != null && w("increment", k);
    },
    onKeyDown: q,
    children: /* @__PURE__ */ x(Rg, {
      fieldClassNames: ee,
      ...R,
      children: /* @__PURE__ */ ie("button", {
        ...N,
        type: "button",
        "aria-expanded": d ? "true" : "false",
        "aria-haspopup": "listbox",
        "aria-controls": d ? _ : void 0,
        ref: S,
        onKeyDown: J,
        onKeyDownCapture: (C) => {
          if (d)
            return;
          const k = re(C, A, b);
          k != null && y(k);
        },
        disabled: l.disabled,
        onClick: () => {
          v(!d);
        },
        className: ue(ee.input, !R.unstyled && h),
        children: [Q, !r && /* @__PURE__ */ x(Ea, {
          direction: "end",
          children: /* @__PURE__ */ x(Bl, {
            className: ee.adornment
          })
        })]
      })
    })
  });
});
function oE() {
  const t = oe((g) => g.filter.selected);
  if (!t)
    return null;
  const e = I().filter.getByName(t).options, r = (g, a) => {
    var n;
    (n = I().filter) == null || n.applyValue(t, g, a), O().setDirty(!0);
  }, i = I().canvas.getMainImage().filters, o = I().filter.findFilterIndex(t, i), p = i == null ? void 0 : i[o];
  if (e) {
    const g = Object.entries(e).map(([a, n]) => {
      let u;
      const h = p ? p[a] : n.current;
      return n.type === "slider" ? u = /* @__PURE__ */ x(zr, {
        label: /* @__PURE__ */ x(we, {
          ...ms[a]
        }),
        minValue: n.min,
        maxValue: n.max,
        step: n.step,
        defaultValue: h,
        formatOptions: {
          style: "percent"
        },
        size: "sm",
        onChange: (s) => {
          r(a, s);
        }
      }) : n.type === "colorPicker" ? u = /* @__PURE__ */ x(Fr, {
        label: /* @__PURE__ */ x(we, {
          ...ms[a]
        }),
        size: "sm",
        className: "w-full",
        value: h,
        onChange: (s) => {
          r(a, s);
        }
      }) : n.type === "select" && (u = /* @__PURE__ */ x($l, {
        selectionMode: "single",
        size: "sm",
        label: /* @__PURE__ */ x(we, {
          ...ms[a]
        }),
        defaultValue: h,
        onSelectionChange: (s) => {
          r(a, s);
        },
        children: n.available.map((s) => /* @__PURE__ */ x(Io, {
          value: s.key,
          children: /* @__PURE__ */ x("span", {
            className: "capitalize",
            children: s.key
          })
        }, s.key))
      })), /* @__PURE__ */ x("div", {
        className: "pb-10",
        children: u
      }, a);
    });
    return /* @__PURE__ */ x(Fl, {
      children: /* @__PURE__ */ x("div", {
        className: "max-w-240 pt-10 mx-auto",
        children: g
      })
    });
  }
  return null;
}
function sE() {
  const t = oe((i) => i.frame.active), e = (t == null ? void 0 : t.mode) === "basic", r = Ie((i) => `${i}%`, []);
  return /* @__PURE__ */ x(Fl, {
    className: "pb-18 pt-6",
    children: /* @__PURE__ */ ie("div", {
      className: "max-w-288 m-auto",
      children: [e && /* @__PURE__ */ x(Fr, {
        className: "w-full mb-20",
        size: "sm",
        label: /* @__PURE__ */ x(we, {
          message: "Color"
        }),
        value: I().frame.builder.defaultColor,
        onChange: (i) => {
          I().frame.active.changeColor(i);
        }
      }), /* @__PURE__ */ x(zr, {
        size: "sm",
        label: /* @__PURE__ */ x(we, {
          message: "Size"
        }),
        step: 1,
        minValue: I().frame.active.getMinSize(),
        maxValue: I().frame.active.getMaxSize(),
        defaultValue: I().frame.active.currentSizeInPercent,
        getValueLabel: r,
        onChange: (i) => {
          I().frame.resize(i);
        }
      })]
    })
  });
}
const gn = ae.createContext(null);
function aE() {
  const {
    tabsRef: t,
    selectedTab: e
  } = De(gn), [r, i] = Ae({
    width: void 0,
    transform: void 0,
    className: void 0
  });
  return Ft(() => {
    if (e != null && t.current) {
      const o = t.current[e];
      i((p) => ({
        width: `${o.offsetWidth}px`,
        transform: `translateX(${o.offsetLeft}px)`,
        className: p.width === void 0 ? "" : "transition-all"
      }));
    }
  }, [i, e, t]), /* @__PURE__ */ x("div", {
    className: ue("absolute bottom-0 left-0 h-2 bg-primary", r.className),
    role: "presentation",
    style: {
      width: r.width,
      transform: r.transform
    }
  });
}
function lE({
  children: t,
  center: e
}) {
  const r = Sr.toArray(t);
  return /* @__PURE__ */ x(Ro, {
    children: /* @__PURE__ */ ie("div", {
      className: "flex relative max-w-full overflow-auto border-b",
      role: "tablist",
      "aria-orientation": "horizontal",
      children: [r.map((i, o) => tr(i) ? dt(i, {
        index: o,
        className: ue(i.props.className, e && o === 0 && "ml-auto", e && o === r.length - 1 && "mr-auto")
      }) : null), /* @__PURE__ */ x(aE, {})]
    })
  });
}
function cE(t) {
  const {
    size: e = "md",
    children: r,
    className: i,
    isLazy: o
  } = t, p = de([]), g = yt(), [a, n] = kr(t.selectedTab, t.defaultSelectedTab || 0, t.onTabChange), u = Je(() => ({
    selectedTab: a,
    setSelectedTab: n,
    tabsRef: p,
    size: e,
    isLazy: o,
    id: g
  }), [a, g, o, n, e]);
  return /* @__PURE__ */ x(gn.Provider, {
    value: u,
    children: /* @__PURE__ */ x("div", {
      className: ue(i, "max-w-full overflow-hidden"),
      children: r
    })
  });
}
const uE = me(/* @__PURE__ */ x("path", {
  d: "M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z"
}), "FormatUnderlinedOutlined"), hE = me(/* @__PURE__ */ x("path", {
  d: "M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z"
}), "FormatStrikethroughOutlined"), fE = me(/* @__PURE__ */ x("path", {
  d: "M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4h-8z"
}), "FormatItalicOutlined"), dE = me(/* @__PURE__ */ x("path", {
  d: "M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z"
}), "FormatAlignRightOutlined"), pE = me(/* @__PURE__ */ x("path", {
  d: "M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zm0 8h18v-2H3v2zM3 3v2h18V3H3z"
}), "FormatAlignLeftOutlined"), gE = me(/* @__PURE__ */ x("path", {
  d: "M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z"
}), "FormatAlignCenterOutlined"), Or = et(({
  inputElementType: t = "input",
  flexibleHeight: e,
  inputRef: r,
  ...i
}, o) => {
  const p = Ir(r), {
    fieldProps: g,
    inputProps: a
  } = Lg({
    ...i,
    focusRef: p
  }), n = t === "textarea", u = n ? "textarea" : "input", h = Rr({
    ...i,
    flexibleHeight: e || t === "textarea"
  });
  return t === "textarea" && !i.unstyled && (h.input = `${h.input} py-12`), /* @__PURE__ */ x(Rg, {
    ref: o,
    fieldClassNames: h,
    ...g,
    children: /* @__PURE__ */ x(u, {
      ref: p,
      ...a,
      rows: n ? a.rows || 4 : void 0,
      className: h.input
    })
  });
});
ae.forwardRef(({
  name: t,
  ...e
}, r) => {
  const {
    field: {
      onChange: i,
      onBlur: o,
      value: p = "",
      ref: g
    },
    fieldState: {
      invalid: a,
      error: n
    }
  } = iE({
    name: t
  }), u = {
    onChange: i,
    onBlur: o,
    value: p == null ? "" : p,
    invalid: a,
    errorMessage: n == null ? void 0 : n.message,
    inputRef: g
  };
  return /* @__PURE__ */ x(Or, {
    ref: r,
    ...vi(u, e)
  });
});
function mE() {
  return /* @__PURE__ */ ie("div", {
    className: "flex gap-20 justify-center",
    children: [/* @__PURE__ */ x(vE, {}), /* @__PURE__ */ x(bE, {}), /* @__PURE__ */ x(yE, {})]
  });
}
function vE() {
  var r;
  const t = (r = oe((i) => i.objects.active.editableProps.fontSize)) != null ? r : 40, {
    trans: e
  } = Lr();
  return /* @__PURE__ */ x(Or, {
    type: "number",
    size: "xs",
    "aria-label": e({
      message: "Font Size"
    }),
    min: 1,
    max: 300,
    className: "w-64 flex-shrink-0",
    value: t,
    onChange: (i) => {
      I().objects.setValues({
        fontSize: i.target.valueAsNumber
      }), O().setDirty(!0);
    }
  });
}
function bE() {
  const t = oe((p) => p.objects.active.editableProps.fontStyle), e = oe((p) => p.objects.active.editableProps.underline), r = oe((p) => p.objects.active.editableProps.linethrough), [i, o] = Ae([t, e && "underline", r && "linethrough"]);
  return /* @__PURE__ */ ie(Bo, {
    size: "xs",
    variant: "outline",
    radius: "rounded",
    value: i,
    multiple: !0,
    onChange: (p) => {
      o(p), I().objects.setValues({
        underline: p.includes("underline"),
        linethrough: p.includes("linethrough"),
        fontStyle: p.includes("italic") ? "italic" : ""
      }), O().setDirty(!0);
    },
    children: [/* @__PURE__ */ x(Me, {
      value: "underline",
      children: /* @__PURE__ */ x(uE, {})
    }), /* @__PURE__ */ x(Me, {
      value: "linethrough",
      children: /* @__PURE__ */ x(hE, {})
    }), /* @__PURE__ */ x(Me, {
      value: "italic",
      children: /* @__PURE__ */ x(fE, {})
    })]
  });
}
function yE() {
  const t = oe((e) => e.objects.active.editableProps.textAlign);
  return /* @__PURE__ */ ie(Bo, {
    size: "xs",
    variant: "outline",
    radius: "rounded",
    value: t,
    onChange: (e) => {
      I().objects.setValues({
        textAlign: e
      }), O().setDirty(!0);
    },
    children: [/* @__PURE__ */ x(Me, {
      value: "left",
      children: /* @__PURE__ */ x(pE, {})
    }), /* @__PURE__ */ x(Me, {
      value: "center",
      children: /* @__PURE__ */ x(gE, {})
    }), /* @__PURE__ */ x(Me, {
      value: "right",
      children: /* @__PURE__ */ x(dE, {})
    })]
  });
}
function wE({
  children: t,
  className: e
}) {
  const {
    selectedTab: r,
    isLazy: i
  } = De(gn), o = Sr.toArray(t);
  let p;
  return i ? p = dt(o[r], {
    index: r
  }) : p = o.map((g, a) => {
    if (tr(g)) {
      const n = a === r;
      return dt(g, {
        index: a,
        "aria-hidden": !n,
        className: n ? g.props.className : ue(g.props.className, "hidden")
      });
    }
    return null;
  }), /* @__PURE__ */ x("div", {
    className: e,
    children: p
  });
}
function gr({
  className: t,
  children: e,
  index: r,
  ...i
}) {
  const {
    id: o
  } = De(gn), [p, g] = Ae(0), a = de(null);
  return Ft(() => {
    if (a != null && a.current) {
      const n = () => {
        const h = Yt(a.current, {
          tabbable: !0
        });
        g(h.nextNode() ? void 0 : 0);
      };
      n();
      const u = new MutationObserver(n);
      return u.observe(a.current, {
        subtree: !0,
        childList: !0,
        attributes: !0,
        attributeFilter: ["tabIndex", "disabled"]
      }), () => {
        u.disconnect();
      };
    }
  }, [a]), /* @__PURE__ */ x("div", {
    tabIndex: p,
    ref: a,
    id: `${o}-${r}-tabpanel`,
    "aria-labelledby": `${o}-${r}-tab`,
    className: ue(t, "focus-visible:outline-primary-light"),
    role: "tabpanel",
    ...i,
    children: e
  });
}
const ah = [
  {
    type: "linear",
    coords: {
      x1: -80,
      y1: 0,
      x2: 80,
      y2: 0
    },
    colorStops: [
      { color: "#ffe47b", offset: 0 },
      { color: "rgb(111,154,211)", offset: 1 }
    ]
  },
  {
    type: "linear",
    coords: {
      x1: 0,
      y1: -120,
      x2: 0,
      y2: 120
    },
    colorStops: [
      { color: "#ff4040", offset: 0 },
      { color: "#e6399b", offset: 1 }
    ]
  },
  {
    type: "linear",
    coords: {
      x1: -90,
      y1: -90,
      x2: 90,
      y2: 90
    },
    colorStops: [
      { offset: 0, color: "rgb(166,111,213)" },
      { offset: 0.5, color: "rgba(106, 72, 215, 0.5)" },
      { offset: 1, color: "#200772" }
    ]
  },
  {
    type: "radial",
    coords: {
      r1: 100,
      r2: 10,
      x1: 0,
      y1: 0,
      x2: 0,
      y2: 0
    },
    colorStops: [
      { offset: 0, color: "#FF4F4F" },
      { offset: 1, color: "rgb(255, 239, 64)" }
    ]
  },
  {
    type: "radial",
    coords: {
      r1: 100,
      r2: 10,
      x1: 0,
      y1: 0,
      x2: 20,
      y2: 20
    },
    colorStops: [
      { offset: 0, color: "#ffe47b" },
      { offset: 0.5, color: "rgb(111,154,211)" },
      { offset: 1, color: "rgb(166,111,213)" }
    ]
  },
  {
    type: "radial",
    coords: {
      r1: 50,
      r2: 80,
      x1: 45,
      y1: 45,
      x2: 52,
      y2: 50
    },
    colorStops: [
      { offset: 0, color: "rgb(155, 237, 0)" },
      { offset: 1, color: "rgba(0, 164, 128,0.4)" }
    ]
  },
  {
    type: "linear",
    coords: {
      x1: -90,
      y1: -90,
      x2: 90,
      y2: 90
    },
    colorStops: [
      { offset: 0, color: "#9ecb2d" },
      { offset: 0.5, color: "#72aa00" },
      { offset: 1, color: "#bfd255" }
    ]
  },
  {
    type: "radial",
    coords: {
      r1: 100,
      r2: 50,
      x1: 30,
      y1: 0,
      x2: 0,
      y2: 0
    },
    colorStops: [
      { offset: 0, color: "#aebcbf" },
      { offset: 1, color: "#0a0809" }
    ]
  },
  {
    type: "linear",
    coords: {
      x1: -80,
      y1: 0,
      x2: 80,
      y2: 0
    },
    colorStops: [
      { offset: 0, color: "#ffffff" },
      { offset: 1, color: "#f6f6f6" }
    ]
  },
  {
    type: "linear",
    coords: {
      x1: 0,
      y1: -120,
      x2: 0,
      y2: 120
    },
    colorStops: [
      { offset: 0, color: "#fefcea" },
      { offset: 1, color: "#f1da36" }
    ]
  },
  {
    type: "linear",
    coords: {
      x1: -90,
      y1: -90,
      x2: 90,
      y2: 90
    },
    colorStops: [
      { offset: 0, color: "rgb(166,111,213)" },
      { offset: 0.5, color: "rgba(106, 72, 215, 0.5)" },
      { offset: 1, color: "#ff1a00" }
    ]
  },
  {
    type: "linear",
    coords: {
      x1: 0,
      y1: -120,
      x2: 0,
      y2: 120
    },
    colorStops: [
      { offset: 0, color: "#b7deed" },
      { offset: 1, color: "#21b4e2" }
    ]
  },
  {
    type: "linear",
    coords: {
      x1: -80,
      y1: 100,
      x2: 80,
      y2: -100
    },
    colorStops: [
      { offset: 0, color: "#ffe47b" },
      { offset: 1, color: "rgb(111,154,211)" }
    ]
  }
], xE = me(/* @__PURE__ */ x("path", {
  d: "M19.51 3.08 3.08 19.51c.09.34.27.65.51.9.25.24.56.42.9.51L20.93 4.49c-.19-.69-.73-1.23-1.42-1.41zM11.88 3 3 11.88v2.83L14.71 3h-2.83zM5 3c-1.1 0-2 .9-2 2v2l4-4H5zm14 18c.55 0 1.05-.22 1.41-.59.37-.36.59-.86.59-1.41v-2l-4 4h2zm-9.71 0h2.83L21 12.12V9.29L9.29 21z"
}), "TextureOutlined"), _E = me(/* @__PURE__ */ x("path", {
  d: "M11 9h2v2h-2V9zm-2 2h2v2H9v-2zm4 0h2v2h-2v-2zm2-2h2v2h-2V9zM7 9h2v2H7V9zm12-6H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 18H7v-2h2v2zm4 0h-2v-2h2v2zm4 0h-2v-2h2v2zm2-7h-2v2h2v2h-2v-2h-2v2h-2v-2h-2v2H9v-2H7v2H5v-2h2v-2H5V5h14v6z"
}), "GradientOutlined"), SE = me(/* @__PURE__ */ x("path", {
  d: "M18 20H4V6h9V4H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-9h-2v9zm-7.79-3.17-1.96-2.36L5.5 18h11l-3.54-4.71zM20 4V1h-2v3h-3c.01.01 0 2 0 2h3v2.99c.01.01 2 0 2 0V6h3V4h-3z"
}), "AddPhotoAlternateOutlined");
function lh({
  property: t
}) {
  const {
    trans: e
  } = Lr(), r = oe((i) => i.objects.active.editableProps[t]);
  return /* @__PURE__ */ ie("div", {
    className: "flex items-center justify-center gap-14",
    children: [/* @__PURE__ */ x(Fr, {
      className: "flex-shrink-0",
      size: "xs",
      "aria-label": e({
        message: "Color"
      }),
      value: typeof r == "string" ? r : Xa.fill,
      onChange: (i) => {
        I().objects.setValues({
          [t]: i
        }), O().setDirty(!0);
      }
    }), /* @__PURE__ */ x(ch, {
      type: "gradient",
      property: t
    }), /* @__PURE__ */ x(ch, {
      type: "texture",
      property: t
    })]
  });
}
function ch({
  type: t,
  property: e
}) {
  const r = t === "texture" ? /* @__PURE__ */ x(xE, {}) : /* @__PURE__ */ x(_E, {});
  return /* @__PURE__ */ x(Gt, {
    children: /* @__PURE__ */ ie(Yo, {
      type: "popover",
      children: [/* @__PURE__ */ x(Qe, {
        className: "flex-shrink-0",
        id: `${t}-panel-trigger`,
        variant: "outline",
        size: "xs",
        startIcon: r,
        endIcon: /* @__PURE__ */ x(Bl, {}),
        children: /* @__PURE__ */ x("span", {
          className: "capitalize",
          children: t === "gradient" ? /* @__PURE__ */ x(we, {
            message: "Gradient"
          }) : /* @__PURE__ */ x(we, {
            message: "Texture"
          })
        })
      }), /* @__PURE__ */ x(Wo, {
        size: "auto",
        children: /* @__PURE__ */ x("div", {
          className: "grid gap-8 grid-cols-5-min-content p-10 bg-paper rounded shadow-md",
          children: /* @__PURE__ */ x(CE, {
            property: e,
            type: t
          })
        })
      })]
    })
  });
}
function CE({
  type: t,
  property: e
}) {
  const {
    close: r
  } = Pg(), i = Array.from(Array(t === "gradient" ? ah.length : 28).keys()), o = "w-56 h-56 bg border shadow-sm hover:scale-110", p = i.map((g) => {
    const a = ct(`images/${t}s/${g}.png`);
    return /* @__PURE__ */ x(Bt, {
      radius: "rounded",
      className: o,
      style: {
        backgroundImage: `url(${a})`
      },
      "aria-label": `Select ${t} #${g}`,
      onClick: async () => {
        r();
        const n = t === "gradient" ? new ve.fabric.Gradient(ah[g]) : await Fg(a);
        I().objects.setValues({
          [e]: n
        }), O().setDirty(!0);
      }
    }, g);
  });
  return t === "texture" && p.unshift(/* @__PURE__ */ x(TE, {
    property: e,
    className: o
  }, "upload-btn")), /* @__PURE__ */ x(Gt, {
    children: p
  });
}
function TE({
  className: t,
  property: e
}) {
  const {
    close: r
  } = Pg();
  return /* @__PURE__ */ x(Bt, {
    radius: "rounded",
    className: t,
    "aria-label": "Upload an image",
    onClick: async () => {
      const i = await I().import.openUploadWindow();
      if (r(), i) {
        const o = await Fg(await i.data);
        I().objects.setValues({
          [e]: o
        });
      }
    },
    children: /* @__PURE__ */ x(SE, {
      className: "icon-md"
    })
  });
}
function Fg(t) {
  return new Promise((e) => {
    ve.fabric.util.loadImage(t, (r) => {
      const i = new ve.fabric.Pattern({
        source: r,
        repeat: "repeat"
      });
      e(i);
    });
  });
}
function kE() {
  const t = oe((e) => e.objects.active.editableProps.opacity);
  return /* @__PURE__ */ x(zr, {
    className: "max-w-240 w-full mx-auto",
    "aria-label": "Opacity",
    value: t,
    minValue: 0.1,
    step: 0.1,
    maxValue: 1,
    onChange: (e) => {
      I().objects.setValues({
        opacity: e
      }), O().setDirty(!0);
    }
  });
}
function EE() {
  const {
    trans: t
  } = Lr(), e = oe((i) => i.objects.active.editableProps.stroke), r = oe((i) => i.objects.active.editableProps.strokeWidth);
  return /* @__PURE__ */ ie("div", {
    className: "flex items-center gap-40",
    children: [/* @__PURE__ */ x(Fr, {
      className: "ml-auto flex-shrink-0",
      size: "xs",
      value: e,
      "aria-label": t({
        message: "Outline Color"
      }),
      onChange: (i) => {
        I().objects.setValues({
          stroke: i
        }), O().setDirty(!0);
      }
    }), /* @__PURE__ */ x(zr, {
      "aria-label": "Outline Width",
      className: "max-w-240 mr-auto flex-shrink-0",
      value: r,
      onChange: (i) => {
        I().objects.setValues({
          strokeWidth: i
        }), O().setDirty(!0);
      }
    })]
  });
}
const OE = me(/* @__PURE__ */ x("path", {
  d: "M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-4.86 8.86-3 3.87L9 13.14 6 17h12l-3.86-5.14z"
}), "ImageOutlined");
function PE() {
  return /* @__PURE__ */ x("div", {
    children: /* @__PURE__ */ x(Qe, {
      type: "button",
      variant: "outline",
      size: "xs",
      startIcon: /* @__PURE__ */ x(OE, {}),
      radius: "rounded-full",
      onClick: async () => {
        const t = await I().import.openUploadWindow();
        if (t) {
          const e = I().objects.getActive();
          if (e && "setSrc" in e) {
            const r = await t.data;
            e.setSrc(r, () => {
              sp({
                src: r
              }), I().canvas.render();
            });
          }
        }
      },
      children: /* @__PURE__ */ x(we, {
        message: "Replace Image"
      })
    })
  });
}
const zg = {
  color: "rgba(0, 0, 0, 0.6)",
  blur: 3,
  offsetX: -1,
  offsetY: 0
};
function ME() {
  const {
    trans: t
  } = Lr(), e = oe((r) => r.objects.active.editableProps.shadow) || zg;
  return /* @__PURE__ */ ie("div", {
    className: "flex items-center gap-40",
    children: [/* @__PURE__ */ x(Fr, {
      className: "ml-auto flex-shrink-0",
      value: e.color,
      size: "xs",
      "aria-label": t({
        message: "Shadow Color"
      }),
      onChange: (r) => {
        I().objects.setValues({
          shadow: uh({
            color: r
          })
        }), O().setDirty(!0);
      }
    }), /* @__PURE__ */ x(zr, {
      "aria-label": "Shadow Blur",
      className: "max-w-240 mr-auto flex-shrink-0",
      defaultValue: e.blur,
      onChange: (r) => {
        I().objects.setValues({
          shadow: uh({
            blur: r
          })
        }), O().setDirty(!0);
      }
    })]
  });
}
function uh(t) {
  var r;
  const e = (r = I().objects.getActive()) == null ? void 0 : r.shadow;
  return e ? (Object.entries(t).forEach(([i, o]) => {
    e[i] = o;
  }), e) : new ve.fabric.Shadow({
    ...zg,
    ...t
  });
}
function mr({
  index: t,
  className: e,
  isDisabled: r,
  children: i
}) {
  const {
    selectedTab: o,
    setSelectedTab: p,
    tabsRef: g,
    size: a,
    id: n
  } = De(gn), u = t === o, h = jC(), s = ue("tracking-wide overflow-hidden capitalize text-sm flex-shrink-0 flex items-center justify-center outline-none transition-colors", "focus-visible:ring focus-visible:ring-2 ring-inset rounded", AE({
    isDisabled: r,
    isSelected: u
  }), e, {
    "px-18 h-48": !a || a === "md",
    "px-12 h-32": a === "sm",
    "cursor-pointer": !r
  }), l = (f) => {
    switch (f.key) {
      case "ArrowLeft":
        h.focusPrevious();
        break;
      case "ArrowRight":
        h.focusNext();
        break;
      case "Home":
        h.focusFirst();
        break;
      case "End":
        h.focusLast();
        break;
    }
  }, c = u ? 0 : -1;
  return /* @__PURE__ */ x("button", {
    disabled: r,
    id: `${n}-${t}-tab`,
    "aria-controls": `${n}-${t}-tabpanel`,
    type: "button",
    role: "tab",
    "aria-selected": u,
    tabIndex: r ? void 0 : c,
    onKeyDown: l,
    onClick: () => {
      p(t);
    },
    className: s,
    ref: (f) => {
      g.current && f && (g.current[t] = f);
    },
    children: i
  });
}
function AE({
  isDisabled: t,
  isSelected: e
}) {
  return t ? "text-disabled cursor-default" : e ? "text-primary" : "text-muted hover:text-main";
}
function jg() {
  const t = oe((e) => e.objects.active);
  return /* @__PURE__ */ ie(cE, {
    size: "sm",
    className: "pb-18 pt-6",
    children: [/* @__PURE__ */ ie(lE, {
      center: !0,
      children: [t.isText && /* @__PURE__ */ x(mr, {
        children: /* @__PURE__ */ x(we, {
          message: "Font"
        })
      }), !t.isImage && /* @__PURE__ */ x(mr, {
        children: /* @__PURE__ */ x(we, {
          message: "Color"
        })
      }), !t.isImage && /* @__PURE__ */ x(mr, {
        children: /* @__PURE__ */ x(we, {
          message: "Background"
        })
      }), t.isImage && /* @__PURE__ */ x(mr, {
        children: /* @__PURE__ */ x(we, {
          message: "Image"
        })
      }), /* @__PURE__ */ x(mr, {
        children: /* @__PURE__ */ x(we, {
          message: "Opacity"
        })
      }), /* @__PURE__ */ x(mr, {
        children: /* @__PURE__ */ x(we, {
          message: "Outline"
        })
      }), /* @__PURE__ */ x(mr, {
        children: /* @__PURE__ */ x(we, {
          message: "Shadow"
        })
      })]
    }), /* @__PURE__ */ ie(wE, {
      className: "pt-16 h-50",
      children: [t.isText && /* @__PURE__ */ x(gr, {
        children: /* @__PURE__ */ x(mE, {})
      }, "font"), !t.isImage && /* @__PURE__ */ x(gr, {
        children: /* @__PURE__ */ x(lh, {
          property: "fill"
        })
      }), !t.isImage && /* @__PURE__ */ x(gr, {
        children: /* @__PURE__ */ x(lh, {
          property: "backgroundColor"
        })
      }), t.isImage && /* @__PURE__ */ x(gr, {
        children: /* @__PURE__ */ x(PE, {})
      }), /* @__PURE__ */ x(gr, {
        children: /* @__PURE__ */ x(kE, {})
      }), /* @__PURE__ */ x(gr, {
        children: /* @__PURE__ */ x(EE, {})
      }), /* @__PURE__ */ x(gr, {
        children: /* @__PURE__ */ x(ME, {})
      })]
    })]
  });
}
function DE() {
  const e = !jo() && /* @__PURE__ */ x(Qe, {
    size: "sm",
    color: "primary",
    variant: "outline",
    onClick: () => {
      I().text.add(), O().setDirty(!0);
    },
    children: /* @__PURE__ */ x(we, {
      message: "New Text"
    })
  });
  return /* @__PURE__ */ x(Fl, {
    actionBtn: e,
    children: /* @__PURE__ */ x(jg, {})
  });
}
function IE() {
  const t = oe((i) => i.activeToolOverlay), e = oe((i) => i.objects.active.id), r = RE(t, e);
  return /* @__PURE__ */ x("div", {
    className: "relative z-tool-overlay text-sm",
    children: /* @__PURE__ */ x(cr, {
      children: r && /* @__PURE__ */ x(ot.div, {
        initial: {
          y: 0,
          opacity: 0
        },
        animate: {
          y: "-100%",
          opacity: 1
        },
        exit: {
          y: 0,
          opacity: 0
        },
        transition: {
          type: "tween",
          duration: 0.15
        },
        className: "absolute inset-x-0 gap-16 px-5vw bg bg-opacity-95 border-t",
        children: r
      }, "tool-controls-overlay")
    })
  });
}
function RE(t, e) {
  switch (t) {
    case mt.Filter:
      return /* @__PURE__ */ x(oE, {});
    case mt.Frame:
      return /* @__PURE__ */ x(sE, {});
    case mt.Text:
      return e && /* @__PURE__ */ x(DE, {});
    case mt.ActiveObject:
      return e && /* @__PURE__ */ x(jg, {});
    default:
      return null;
  }
}
const Oa = me(/* @__PURE__ */ x("path", {
  d: "M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm3.59-13L12 10.59 8.41 7 7 8.41 10.59 12 7 15.59 8.41 17 12 13.41 15.59 17 17 15.59 13.41 12 17 8.41z"
}), "CancelOutlined");
function LE({
  filter: t
}) {
  const e = oe((g) => g.filter.applied.includes(t)), r = I().filter.hasOptions(t), i = ue("block flex-shrink-0 rounded", {
    "text-primary border-primary": e
  }), o = F_[t], p = /* @__PURE__ */ ie(ji, {
    children: [/* @__PURE__ */ ie("div", {
      className: "relative",
      children: [/* @__PURE__ */ x(FE, {
        filter: t
      }), e && /* @__PURE__ */ x(zE, {
        filter: t,
        hasOptions: r
      })]
    }), /* @__PURE__ */ x("div", {
      className: "mt-4 text-center text-xs capitalize",
      children: o ? /* @__PURE__ */ x(we, {
        ...o
      }) : t
    })]
  });
  return e && r ? /* @__PURE__ */ x("div", {
    className: i,
    children: p
  }) : /* @__PURE__ */ x(Bt, {
    className: i,
    onClick: () => {
      e ? I().filter.remove(t) : I().filter.apply(t);
    },
    children: p
  });
}
function FE({
  filter: t
}) {
  const e = oe((i) => i.filter.selected === t), r = ue("m-auto w-96 h-56 border rounded object-cover", {
    shadow: e
  });
  return /* @__PURE__ */ x("img", {
    src: ct(`images/filter/${t}.jpg`),
    className: r,
    alt: ""
  });
}
function zE({
  filter: t,
  hasOptions: e
}) {
  return /* @__PURE__ */ ie("div", {
    className: "flex items-center justify-center bg-background/70 absolute inset-0 border-2 border-primary rounded",
    children: [e ? /* @__PURE__ */ x(Me, {
      color: "primary",
      size: "md",
      onClick: () => {
        I().filter.remove(t);
      },
      children: /* @__PURE__ */ x(Oa, {})
    }) : /* @__PURE__ */ x(Oa, {
      className: "svg-icon icon-md"
    }), e && /* @__PURE__ */ x(jE, {
      filter: t,
      hasOptions: e
    })]
  });
}
function jE({
  filter: t,
  hasOptions: e
}) {
  return /* @__PURE__ */ x(Me, {
    color: "primary",
    size: "md",
    onClick: () => {
      O().activeToolOverlay === mt.Filter && O().filter.selected === t ? O().setActiveTool(O().activeTool, null) : O().filter.select(t, e);
    },
    children: /* @__PURE__ */ x(gf, {})
  });
}
const jr = et(({
  children: t,
  className: e,
  gap: r
}, i) => {
  const o = ae.Children.map(t, (p, g) => ae.isValidElement(p) ? ae.cloneElement(p, {
    isFirst: g === 0,
    isLast: ae.Children.count(t) === g + 1
  }) : p);
  return /* @__PURE__ */ x("div", {
    ref: i,
    className: `tiny-scrollbar pb-4 overflow-x-auto relative flex items-center ${r || "gap-10"} ${e}`,
    children: o
  });
});
function It({
  isFirst: t,
  isLast: e,
  children: r,
  className: i
}) {
  const o = ue(i, "flex-shrink-0", {
    "ml-auto": t,
    "mr-auto": e
  });
  return /* @__PURE__ */ x("div", {
    className: o,
    children: r
  });
}
function BE() {
  const t = oe((r) => {
    var i, o;
    return (o = (i = r.config.tools) == null ? void 0 : i.filter) == null ? void 0 : o.items;
  }) || [];
  xe(() => {
    I().filter.syncState();
  }, []);
  const e = t.map((r) => /* @__PURE__ */ x(It, {
    children: /* @__PURE__ */ x(LE, {
      filter: r
    })
  }, r));
  return /* @__PURE__ */ x(jr, {
    children: e
  });
}
const NE = me(/* @__PURE__ */ x("path", {
  d: "M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zM9 6c0-1.66 1.34-3 3-3s3 1.34 3 3v2H9V6zm9 14H6V10h12v10zm-6-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z"
}), "LockOutlined"), VE = me(/* @__PURE__ */ x("path", {
  d: "M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6h2c0-1.66 1.34-3 3-3s3 1.34 3 3v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm0 12H6V10h12v10zm-6-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z"
}), "LockOpenOutlined"), $E = me(/* @__PURE__ */ x("path", {
  d: "M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"
}), "CheckBoxOutlineBlankOutlined"), HE = me(/* @__PURE__ */ x("path", {
  d: "M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"
}), "CheckBox"), hh = me(/* @__PURE__ */ x("path", {
  d: "M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M17,13H7v-2h10V13z"
}), "CheckBox"), UE = et((t, e) => {
  const {
    size: r = "md",
    children: i,
    className: o,
    icon: p,
    checkedIcon: g,
    disabled: a,
    isIndeterminate: n,
    errorMessage: u,
    invalid: h,
    orientation: s = "horizontal",
    onChange: l,
    autoFocus: c,
    required: f,
    value: m
  } = t, d = Rr({
    ...t,
    label: i
  }), v = p || $E, b = g || (n ? hh : HE), y = Ir(e);
  Vl({
    autoFocus: c
  }, y), xe(() => {
    y.current && (y.current.indeterminate = n || !1);
  });
  const [w, _] = kr(t.checked, t.defaultChecked || !1), S = Ie((N) => {
    l == null || l(N), _(N.target.checked);
  }, [l, _]), T = ue("select-none", o, h && "text-danger", !h && a && "text-disabled");
  let A, R = h ? "text-danger" : null;
  return n ? (A = hh, R = R || "text-primary") : w ? (A = b, R = R || "text-primary") : (A = v, R = R || "text-muted"), /* @__PURE__ */ ie("div", {
    children: [/* @__PURE__ */ x("label", {
      className: T,
      children: /* @__PURE__ */ ie("div", {
        className: ue("relative flex items-center", s === "vertical" && "flex-col flex-col-reverse"),
        children: [/* @__PURE__ */ x("input", {
          className: "focus-visible:ring ring-inset transition-shadow outline-none absolute left-0 top-0 w-24 h-24 rounded appearance-none",
          type: "checkbox",
          "aria-checked": n ? "mixed" : w,
          "aria-invalid": h || void 0,
          onChange: S,
          ref: y,
          required: f,
          disabled: a,
          value: m
        }), /* @__PURE__ */ x(A, {
          size: r,
          className: ue("pointer-events-none", a ? "text-disabled" : R)
        }), i && /* @__PURE__ */ x("div", {
          className: ue("first-letter:capitalize", d.size.font, s === "vertical" ? "mb-6" : "ml-6"),
          children: i
        })]
      })
    }), u && /* @__PURE__ */ x("div", {
      className: d.error,
      children: u
    })]
  });
});
function WE() {
  const {
    trans: t
  } = Lr(), {
    minWidth: e = 50,
    minHeight: r = 50,
    maxHeight: i = 2400,
    maxWidth: o = 2400
  } = oe((s) => {
    var l;
    return (l = s.config.tools) == null ? void 0 : l.resize;
  }) || {}, p = oe((s) => s.original), g = oe((s) => s.resize.formValue);
  xe(() => {
    O().resize.setFormValue({
      ...p
    });
  }, [p]), xe(() => {
    O().setDirty(!0);
  }, []);
  const a = (s) => {
    const l = {
      ...g,
      width: s
    };
    g.maintainAspect && (l.height = oo(s, g.usePercentages)), O().resize.setFormValue(l);
  }, n = (s) => {
    const l = {
      ...g,
      height: s
    };
    s && g.maintainAspect && (l.width = ua(s, g.usePercentages)), O().resize.setFormValue(l);
  }, u = (s) => {
    const l = {
      ...g,
      maintainAspect: s
    };
    s && (l.height = oo(l.width, l.usePercentages)), O().resize.setFormValue(l);
  };
  return /* @__PURE__ */ ie("form", {
    className: "flex items-center justify-center gap-16 w-full",
    onSubmit: (s) => {
      s.preventDefault(), O().applyChanges();
    },
    children: [/* @__PURE__ */ x(Or, {
      type: "number",
      min: e,
      max: o,
      size: "sm",
      className: "w-full max-w-112",
      label: "Width",
      value: g.width,
      onChange: (s) => {
        a(s.target.valueAsNumber);
      }
    }), /* @__PURE__ */ x("div", {
      className: "mt-24",
      children: /* @__PURE__ */ x(UE, {
        size: "md",
        checked: g.maintainAspect,
        onChange: (s) => {
          u(!g.maintainAspect);
        },
        "aria-label": t({
          message: "Maintain aspect ratio"
        }),
        checkedIcon: NE,
        icon: VE
      })
    }), /* @__PURE__ */ x(Or, {
      type: "number",
      min: r,
      max: i,
      size: "sm",
      className: "w-full max-w-112",
      label: "Height",
      value: g.height,
      onChange: (s) => {
        n(s.target.valueAsNumber);
      }
    }), /* @__PURE__ */ x("button", {
      type: "submit",
      className: "hidden",
      children: /* @__PURE__ */ x(we, {
        message: "Resize"
      })
    })]
  });
}
function YE() {
  var o;
  const t = oe((p) => {
    var g, a;
    return (a = (g = p.config.tools) == null ? void 0 : g.crop) == null ? void 0 : a.presets;
  }) || [], e = oe((p) => p.crop.selectedAspectRatio), r = (o = oe((p) => {
    var g, a;
    return (a = (g = p.config.tools) == null ? void 0 : g.crop) == null ? void 0 : a.allowCustomRatio;
  })) != null ? o : !0, i = t.filter((p) => p.ratio || !p.ratio && r).map((p) => /* @__PURE__ */ x(It, {
    children: /* @__PURE__ */ ie(Bt, {
      onClick: () => I().crop.resetCropzone(p.ratio),
      className: "flex flex-col items-center justify-between cursor-pointer h-56",
      children: [/* @__PURE__ */ x(XE, {
        preset: p,
        selectedRatio: e
      }), /* @__PURE__ */ x(GE, {
        preset: p,
        selectedRatio: e
      })]
    })
  }, p.ratio || p.name));
  return /* @__PURE__ */ x(jr, {
    gap: "gap-18",
    children: i
  });
}
function XE({
  preset: t,
  selectedRatio: e
}) {
  let r = 40, i = 30;
  if (t.ratio) {
    const p = Cl(t.ratio);
    ({
      width: r,
      height: i
    } = Sl(p, r, i));
  }
  const o = ue("border-2", {
    "border-dotted": t.ratio === null,
    "border-primary": e === t.ratio
  });
  return /* @__PURE__ */ x("div", {
    style: {
      width: `${r}px`,
      height: `${i}px`
    },
    className: o
  });
}
function GE({
  preset: t,
  selectedRatio: e
}) {
  const r = ue("mt-4 text-center text-xs", {
    "text-primary": e === t.ratio
  });
  return /* @__PURE__ */ x("div", {
    className: r,
    children: t.name || t.ratio
  });
}
const fh = me(/* @__PURE__ */ x("path", {
  d: "M15 21h2v-2h-2v2zm4-12h2V7h-2v2zM3 5v14c0 1.1.9 2 2 2h4v-2H5V5h4V3H5c-1.1 0-2 .9-2 2zm16-2v2h2c0-1.1-.9-2-2-2zm-8 20h2V1h-2v22zm8-6h2v-2h-2v2zM15 5h2V3h-2v2zm4 8h2v-2h-2v2zm0 8c1.1 0 2-.9 2-2h-2v2z"
}), "FlipOutlined");
function qE() {
  return /* @__PURE__ */ ie("div", {
    children: [/* @__PURE__ */ x(Me, {
      size: "sm",
      onClick: () => {
        I().transform.flip("vertical"), O().setDirty(!0);
      },
      children: /* @__PURE__ */ x(fh, {})
    }), /* @__PURE__ */ x(Me, {
      size: "sm",
      onClick: () => {
        I().transform.flip("horizontal"), O().setDirty(!0);
      },
      children: /* @__PURE__ */ x(fh, {
        className: "rotate-90"
      })
    })]
  });
}
const KE = me(/* @__PURE__ */ x("path", {
  d: "M7.11 8.53 5.7 7.11C4.8 8.27 4.24 9.61 4.07 11h2.02c.14-.87.49-1.72 1.02-2.47zM6.09 13H4.07c.17 1.39.72 2.73 1.62 3.89l1.41-1.42c-.52-.75-.87-1.59-1.01-2.47zm1.01 5.32c1.16.9 2.51 1.44 3.9 1.61V17.9c-.87-.15-1.71-.49-2.46-1.03L7.1 18.32zM13 4.07V1L8.45 5.55 13 10V6.09c2.84.48 5 2.94 5 5.91s-2.16 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93s-3.05-7.44-7-7.93z"
}), "RotateLeftOutlined"), ZE = me(/* @__PURE__ */ x("path", {
  d: "M15.55 5.55 11 1v3.07C7.06 4.56 4 7.92 4 12s3.05 7.44 7 7.93v-2.02c-2.84-.48-5-2.94-5-5.91s2.16-5.43 5-5.91V10l4.55-4.45zM19.93 11c-.17-1.39-.72-2.73-1.62-3.89l-1.42 1.42c.54.75.88 1.6 1.02 2.47h2.02zM13 17.9v2.02c1.39-.17 2.74-.71 3.9-1.61l-1.44-1.44c-.75.54-1.59.89-2.46 1.03zm3.89-2.42 1.42 1.41c.9-1.16 1.45-2.5 1.62-3.89h-2.02c-.14.87-.48 1.72-1.02 2.48z"
}), "RotateRightOutlined");
function JE() {
  return /* @__PURE__ */ ie("div", {
    children: [/* @__PURE__ */ x(Me, {
      size: "sm",
      onClick: () => {
        I().transform.rotateLeft(), O().setDirty(!0);
      },
      children: /* @__PURE__ */ x(KE, {})
    }), /* @__PURE__ */ x(Me, {
      size: "sm",
      onClick: () => {
        I().transform.rotateRight(), O().setDirty(!0);
      },
      children: /* @__PURE__ */ x(ZE, {})
    })]
  });
}
function QE() {
  return /* @__PURE__ */ ie("div", {
    className: "flex items-center justify-center gap-16",
    children: [/* @__PURE__ */ x(qE, {}), /* @__PURE__ */ x(eO, {}), /* @__PURE__ */ x(JE, {})]
  });
}
function eO() {
  const t = de(null), {
    domProps: e,
    groupId: r,
    thumbIds: i,
    trackRef: o,
    getThumbValueLabel: p
  } = Mg({
    minValue: -45,
    maxValue: 45,
    step: 1,
    defaultValue: [O().crop.straightenAngle],
    onChange: (g) => {
      const a = g[0];
      I().transform.straighten(a), O().crop.setTransformAngle(a), O().setDirty(!0), t.current.style.transform = `translateX(${a}px)`;
    }
  });
  return /* @__PURE__ */ x("div", {
    id: r,
    role: "group",
    className: "flex-auto flex-shrink-0 max-w-320 touch-none isolate",
    children: /* @__PURE__ */ ie("div", {
      ...e,
      ref: o,
      className: "h-36 relative",
      children: [/* @__PURE__ */ ie("output", {
        htmlFor: i[0],
        "aria-live": "off",
        className: "absolute left-1/2 top-1/2 w-40 text-center bg -translate-x-1/2 -translate-y-1/2 z-10",
        children: [p(0), "\xB0"]
      }), /* @__PURE__ */ x(tO, {
        ref: t
      })]
    })
  });
}
const tO = ae.forwardRef((t, e) => {
  const r = [...Array(80).keys()], i = r.map((o) => /* @__PURE__ */ x("circle", {
    cx: 2 + o * 10,
    cy: "20",
    r: o % 5 ? 0.75 : 2
  }, o));
  return /* @__PURE__ */ x("div", {
    className: "relative h-full cursor-pointer overflow-hidden",
    children: /* @__PURE__ */ x("svg", {
      ref: e,
      style: {
        width: r.length * 10
      },
      className: "absolute -left-80 h-full fill-current",
      xmlns: "http://www.w3.org/2000/svg",
      "aria-hidden": "true",
      focusable: "false",
      children: i
    })
  });
});
function rO() {
  return xe(() => (O().setDirty(!0), I().frame.active.hide(), () => {
    I().frame.active.show();
  }), []), /* @__PURE__ */ ie("div", {
    className: "pb-16",
    children: [/* @__PURE__ */ x("div", {
      className: "mb-10",
      children: /* @__PURE__ */ x(QE, {})
    }), /* @__PURE__ */ x(YE, {})]
  });
}
const iO = me(/* @__PURE__ */ x("path", {
  d: "M 16 6 C 12.484375 6 9.273438 7.070313 6.90625 8.84375 C 4.539063 10.617188 3 13.15625 3 16 C 3 18.84375 4.539063 21.382813 6.90625 23.15625 C 9.273438 24.929688 12.484375 26 16 26 C 19.515625 26 22.726563 24.929688 25.09375 23.15625 C 27.460938 21.382813 29 18.84375 29 16 C 29 13.15625 27.460938 10.617188 25.09375 8.84375 C 22.726563 7.070313 19.515625 6 16 6 Z M 16 8 C 19.109375 8 21.898438 8.957031 23.875 10.4375 C 25.851563 11.917969 27 13.875 27 16 C 27 18.125 25.851563 20.082031 23.875 21.5625 C 21.898438 23.042969 19.109375 24 16 24 C 12.890625 24 10.101563 23.042969 8.125 21.5625 C 6.148438 20.082031 5 18.125 5 16 C 5 13.875 6.148438 11.917969 8.125 10.4375 C 10.101563 8.957031 12.890625 8 16 8 Z "
})), nO = me(/* @__PURE__ */ x("path", {
  d: "M 16 4 C 9.382813 4 4 9.382813 4 16 C 4 22.617188 9.382813 28 16 28 C 22.617188 28 28 22.617188 28 16 C 28 9.382813 22.617188 4 16 4 Z M 16 6 C 21.535156 6 26 10.464844 26 16 C 26 21.535156 21.535156 26 16 26 C 10.464844 26 6 21.535156 6 16 C 6 10.464844 10.464844 6 16 6 Z "
})), oO = me(/* @__PURE__ */ x("path", {
  d: "M 3 6 L 3 26 L 29 26 L 29 6 Z M 5 8 L 27 8 L 27 24 L 5 24 Z "
})), sO = me(/* @__PURE__ */ x("path", {
  d: "M 16 4.90625 L 15.125 6.40625 L 4.71875 24.5 L 3.875 26 L 28.125 26 L 27.28125 24.5 L 16.875 6.40625 Z M 16 8.9375 L 24.65625 24 L 7.34375 24 Z "
}));
function aO() {
  const e = (oe((r) => {
    var i, o;
    return (o = (i = r.config.tools) == null ? void 0 : i.shapes) == null ? void 0 : o.items;
  }) || []).map((r) => /* @__PURE__ */ x(It, {
    children: /* @__PURE__ */ x(Me, {
      variant: "outline",
      radius: "rounded-2xl",
      size: "xl",
      onClick: () => {
        I().shape.addBasicShape(r.name), O().setDirty(!0);
      },
      children: /* @__PURE__ */ x(lO, {
        shape: r
      })
    })
  }, r.name));
  return /* @__PURE__ */ x(jr, {
    children: e
  });
}
function lO({
  shape: t
}) {
  var e;
  return t.type === "Path" ? /* @__PURE__ */ x("svg", {
    className: "m-auto w-36 h-36",
    xmlns: "http://www.w3.org/2000/svg",
    viewBox: "0 -100 512 700",
    children: /* @__PURE__ */ x("path", {
      className: "fill-transparent stroke-current",
      d: (e = t.options) == null ? void 0 : e.path,
      strokeWidth: 25
    })
  }) : ae.cloneElement(cO[t.name], {
    className: "w-30 h-30"
  });
}
const cO = {
  circle: /* @__PURE__ */ x(nO, {
    viewBox: "0 0 32 32"
  }),
  square: /* @__PURE__ */ x(oO, {
    viewBox: "0 0 32 32"
  }),
  triangle: /* @__PURE__ */ x(sO, {
    viewBox: "0 0 32 32"
  }),
  ellipse: /* @__PURE__ */ x(iO, {
    viewBox: "0 0 32 32"
  })
};
/**
 * react-virtual
 *
 * Copyright (c) TanStack
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.md file in the root directory of this source tree.
 *
 * @license MIT
 */
/**
 * virtual-core
 *
 * Copyright (c) TanStack
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.md file in the root directory of this source tree.
 *
 * @license MIT
 */
function Rn(t, e, r) {
  let i = [], o;
  return () => {
    let p;
    r.key && r.debug != null && r.debug() && (p = Date.now());
    const g = t();
    if (!(g.length !== i.length || g.some((u, h) => i[h] !== u)))
      return o;
    i = g;
    let n;
    if (r.key && r.debug != null && r.debug() && (n = Date.now()), o = e(...g), r == null || r.onChange == null || r.onChange(o), r.key && r.debug != null && r.debug()) {
      const u = Math.round((Date.now() - p) * 100) / 100, h = Math.round((Date.now() - n) * 100) / 100, s = h / 16, l = (c, f) => {
        for (c = String(c); c.length < f; )
          c = " " + c;
        return c;
      };
      console.info("%c\u23F1 " + l(h, 5) + " /" + l(u, 5) + " ms", `
            font-size: .6rem;
            font-weight: bold;
            color: hsl(` + Math.max(0, Math.min(120 - 120 * s, 120)) + "deg 100% 31%);", r == null ? void 0 : r.key);
    }
    return o;
  };
}
const uO = (t) => t, hO = (t) => {
  const e = Math.max(t.startIndex - t.overscan, 0), r = Math.min(t.endIndex + t.overscan, t.count - 1), i = [];
  for (let o = e; o <= r; o++)
    i.push(o);
  return i;
}, fO = (t, e) => {
  const r = new ResizeObserver((i) => {
    var o, p;
    e({
      width: (o = i[0]) == null ? void 0 : o.contentRect.width,
      height: (p = i[0]) == null ? void 0 : p.contentRect.height
    });
  });
  if (!!t.scrollElement)
    return e(t.scrollElement.getBoundingClientRect()), r.observe(t.scrollElement), () => {
      r.unobserve(t.scrollElement);
    };
}, dh = {
  element: ["scrollLeft", "scrollTop"],
  window: ["scrollX", "scrollY"]
}, dO = (t) => (e, r) => {
  if (!e.scrollElement)
    return;
  const i = dh[t][0], o = dh[t][1];
  let p = e.scrollElement[i], g = e.scrollElement[o];
  const a = () => {
    r(e.scrollElement[e.options.horizontal ? i : o]);
  };
  a();
  const n = (u) => {
    const h = u.currentTarget, s = h[i], l = h[o];
    (e.options.horizontal ? p - s : g - l) && a(), p = s, g = l;
  };
  return e.scrollElement.addEventListener("scroll", n, {
    capture: !1,
    passive: !0
  }), () => {
    e.scrollElement.removeEventListener("scroll", n);
  };
}, pO = dO("element"), gO = (t, e) => t.getBoundingClientRect()[e.options.horizontal ? "width" : "height"], mO = (t, e, r) => {
  var i;
  (i = r.scrollElement) == null || i.scrollTo == null || i.scrollTo({
    [r.options.horizontal ? "left" : "top"]: t,
    behavior: e ? "smooth" : void 0
  });
};
class vO {
  constructor(e) {
    var r = this;
    this.unsubs = [], this.scrollElement = null, this.measurementsCache = [], this.itemMeasurementsCache = {}, this.pendingMeasuredCacheIndexes = [], this.measureElementCache = {}, this.range = {
      startIndex: 0,
      endIndex: 0
    }, this.setOptions = (i) => {
      Object.entries(i).forEach((o) => {
        let [p, g] = o;
        typeof g > "u" && delete i[p];
      }), this.options = {
        debug: !1,
        initialOffset: 0,
        overscan: 1,
        paddingStart: 0,
        paddingEnd: 0,
        scrollPaddingStart: 0,
        scrollPaddingEnd: 0,
        horizontal: !1,
        getItemKey: uO,
        rangeExtractor: hO,
        enableSmoothScroll: !0,
        onChange: () => {
        },
        measureElement: gO,
        initialRect: {
          width: 0,
          height: 0
        },
        ...i
      };
    }, this.notify = () => {
      var i, o;
      (i = (o = this.options).onChange) == null || i.call(o, this);
    }, this.cleanup = () => {
      this.unsubs.filter(Boolean).forEach((i) => i()), this.unsubs = [], this.scrollElement = null;
    }, this._didMount = () => () => {
      this.cleanup();
    }, this._willUpdate = () => {
      const i = this.options.getScrollElement();
      this.scrollElement !== i && (this.cleanup(), this.scrollElement = i, this._scrollToOffset(this.scrollOffset, !1), this.unsubs.push(this.options.observeElementRect(this, (o) => {
        this.scrollRect = o, this.calculateRange();
      })), this.unsubs.push(this.options.observeElementOffset(this, (o) => {
        this.scrollOffset = o, this.calculateRange();
      })));
    }, this.getSize = () => this.scrollRect[this.options.horizontal ? "width" : "height"], this.getMeasurements = Rn(() => [this.options.count, this.options.paddingStart, this.options.getItemKey, this.itemMeasurementsCache], (i, o, p, g) => {
      const a = this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
      this.pendingMeasuredCacheIndexes = [];
      const n = this.measurementsCache.slice(0, a);
      for (let u = a; u < i; u++) {
        const h = p(u), s = g[h], l = n[u - 1] ? n[u - 1].end : o, c = typeof s == "number" ? s : this.options.estimateSize(u), f = l + c;
        n[u] = {
          index: u,
          start: l,
          size: c,
          end: f,
          key: h
        };
      }
      return this.measurementsCache = n, n;
    }, {
      key: !1,
      debug: () => this.options.debug
    }), this.calculateRange = Rn(() => [this.getMeasurements(), this.getSize(), this.scrollOffset], (i, o, p) => {
      const g = yO({
        measurements: i,
        outerSize: o,
        scrollOffset: p
      });
      return (g.startIndex !== this.range.startIndex || g.endIndex !== this.range.endIndex) && (this.range = g, this.notify()), this.range;
    }, {
      key: !1,
      debug: () => this.options.debug
    }), this.getIndexes = Rn(() => [this.options.rangeExtractor, this.range, this.options.overscan, this.options.count], (i, o, p, g) => i({
      ...o,
      overscan: p,
      count: g
    }), {
      key: !1,
      debug: () => this.options.debug
    }), this.getVirtualItems = Rn(() => [this.getIndexes(), this.getMeasurements(), this.options.measureElement], (i, o, p) => {
      const g = (h) => (s) => {
        var l;
        const c = this.measurementsCache[h];
        if (!s)
          return;
        const f = p(s, this), m = (l = this.itemMeasurementsCache[c.key]) != null ? l : c.size;
        f !== m && (c.start < this.scrollOffset && (this.destinationOffset || this._scrollToOffset(this.scrollOffset + (f - m), !1)), this.pendingMeasuredCacheIndexes.push(h), this.itemMeasurementsCache = {
          ...this.itemMeasurementsCache,
          [c.key]: f
        }, this.notify());
      }, a = [], n = {};
      for (let h = 0, s = i.length; h < s; h++) {
        var u;
        const l = i[h], f = {
          ...o[l],
          measureElement: n[l] = (u = this.measureElementCache[l]) != null ? u : g(l)
        };
        a.push(f);
      }
      return this.measureElementCache = n, a;
    }, {
      key: !1,
      debug: () => this.options.debug
    }), this.scrollToOffset = function(i, o) {
      let {
        align: p = "start",
        smoothScroll: g = r.options.enableSmoothScroll
      } = o === void 0 ? {} : o;
      const a = r.scrollOffset, n = r.getSize();
      p === "auto" && (i <= a ? p = "start" : i >= a + n ? p = "end" : p = "start"), p === "start" ? r._scrollToOffset(i, g) : p === "end" ? r._scrollToOffset(i - n, g) : p === "center" && r._scrollToOffset(i - n / 2, g);
    }, this.scrollToIndex = function(i, o) {
      let {
        align: p = "auto",
        smoothScroll: g = r.options.enableSmoothScroll,
        ...a
      } = o === void 0 ? {} : o;
      const n = r.getMeasurements(), u = r.scrollOffset, h = r.getSize(), {
        count: s
      } = r.options, l = n[Math.max(0, Math.min(i, s - 1))];
      if (!l)
        return;
      if (p === "auto")
        if (l.end >= u + h - r.options.scrollPaddingEnd)
          p = "end";
        else if (l.start <= u + r.options.scrollPaddingStart)
          p = "start";
        else
          return;
      const c = p === "end" ? l.end + r.options.scrollPaddingEnd : l.start - r.options.scrollPaddingStart;
      r.scrollToOffset(c, {
        align: p,
        smoothScroll: g,
        ...a
      });
    }, this.getTotalSize = () => {
      var i;
      return (((i = this.getMeasurements()[this.options.count - 1]) == null ? void 0 : i.end) || this.options.paddingStart) + this.options.paddingEnd;
    }, this._scrollToOffset = (i, o) => {
      clearTimeout(this.scrollCheckFrame), this.destinationOffset = i, this.options.scrollToFn(i, o, this);
      let p;
      const g = () => {
        let a = this.scrollOffset;
        this.scrollCheckFrame = p = setTimeout(() => {
          if (this.scrollCheckFrame === p) {
            if (this.scrollOffset === a) {
              this.destinationOffset = void 0;
              return;
            }
            a = this.scrollOffset, g();
          }
        }, 100);
      };
      g();
    }, this.measure = () => {
      this.itemMeasurementsCache = {}, this.notify();
    }, this.setOptions(e), this.scrollRect = this.options.initialRect, this.scrollOffset = this.options.initialOffset, this.calculateRange();
  }
}
const bO = (t, e, r, i) => {
  for (; t <= e; ) {
    const o = (t + e) / 2 | 0, p = r(o);
    if (p < i)
      t = o + 1;
    else if (p > i)
      e = o - 1;
    else
      return o;
  }
  return t > 0 ? t - 1 : 0;
};
function yO(t) {
  let {
    measurements: e,
    outerSize: r,
    scrollOffset: i
  } = t;
  const o = e.length - 1, g = bO(0, o, (n) => e[n].start, i);
  let a = g;
  for (; a < o && e[a].end < i + r; )
    a++;
  return {
    startIndex: g,
    endIndex: a
  };
}
const wO = typeof window < "u" ? Se.useLayoutEffect : Se.useEffect;
function xO(t) {
  const e = Se.useReducer(() => ({}), {})[1], r = {
    ...t,
    onChange: (o) => {
      e(), t.onChange == null || t.onChange(o);
    }
  }, [i] = Se.useState(() => new vO(r));
  return i.setOptions(r), Se.useEffect(() => i._didMount(), []), wO(() => i._willUpdate()), i;
}
function _O(t) {
  return xO({
    observeElementRect: fO,
    observeElementOffset: pO,
    scrollToFn: mO,
    ...t
  });
}
function Bg() {
  const t = oe((e) => {
    var r;
    return (r = e.config.ui) == null ? void 0 : r.activeTheme;
  });
  return oe(
    (e) => {
      var r;
      return (((r = e.config.ui) == null ? void 0 : r.themes) || []).find((i) => i.name === t);
    }
  );
}
function SO({
  category: t
}) {
  const e = Bg(), r = t.name, i = t.list ? t.list : Array.from(Array(t.items).keys()), o = de(null), p = _O({
    horizontal: !0,
    count: i.length,
    getScrollElement: () => o.current,
    estimateSize: Ie(() => 52, []),
    overscan: 5
  });
  return xe(() => {
    p.scrollToIndex(0);
  }, [r]), /* @__PURE__ */ x(Gt, {
    children: /* @__PURE__ */ x("div", {
      ref: o,
      className: "tiny-scrollbar overflow-x-auto overflow-y-hidden",
      style: {
        height: "52px"
      },
      children: /* @__PURE__ */ x("div", {
        className: "h-full relative mx-auto",
        style: {
          width: `${p.getTotalSize()}px`
        },
        children: p.getVirtualItems().map((g) => {
          const a = `${i[g.index]}`;
          return /* @__PURE__ */ x("div", {
            className: "absolute top-0 left-0 h-full",
            style: {
              width: `${g.size}px`,
              transform: `translateX(${g.start}px)`
            },
            children: /* @__PURE__ */ x(Qe, {
              variant: "outline",
              radius: "rounded-xl",
              size: "md",
              equalWidth: !0,
              onClick: async () => {
                await I().shape.addSticker(t.name, a), O().setDirty(!0);
              },
              children: /* @__PURE__ */ x("img", {
                className: ue("m-auto m-auto w-28 h-28", t.invertPreview && (e == null ? void 0 : e.isDark) && "invert"),
                src: ha(t, a),
                alt: a
              })
            })
          }, g.index);
        })
      })
    })
  });
}
function CO() {
  const t = oe((o) => {
    var p, g;
    return (g = (p = o.config.tools) == null ? void 0 : p.stickers) == null ? void 0 : g.items;
  }) || [], [e, r] = Ae(t[0]), i = t.map((o) => {
    const p = e === o, g = cb[o.name];
    return /* @__PURE__ */ x(Qe, {
      size: "xs",
      color: p ? "primary" : null,
      value: o,
      children: /* @__PURE__ */ x("span", {
        className: "capitalize",
        children: g ? /* @__PURE__ */ x(we, {
          ...g
        }) : o.name
      })
    }, o.name);
  });
  return /* @__PURE__ */ ie("div", {
    className: "h-92",
    children: [/* @__PURE__ */ x(Bo, {
      value: e,
      onChange: (o) => r(o),
      className: "mb-10 w-full justify-center",
      variant: "outline",
      radius: "rounded-full",
      children: i
    }), e && /* @__PURE__ */ x(SO, {
      category: e
    })]
  });
}
function TO() {
  const t = oe((i) => {
    var o, p;
    return (p = (o = i.config.tools) == null ? void 0 : o.frame) == null ? void 0 : p.items;
  }) || [], e = oe((i) => i.frame.active);
  xe(() => {
    O().frame.active && O().frame.showOptionsPanel();
  }, []);
  const r = t.map((i) => {
    const o = ct(`images/frames/${i.name}/thumbnail.png`), p = (e == null ? void 0 : e.name) === i.name;
    return /* @__PURE__ */ x(It, {
      children: /* @__PURE__ */ ie("button", {
        type: "button",
        className: `border-2 overflow-hidden relative rounded border cursor-pointer ${p ? "border-primary" : ""}`,
        onClick: () => {
          O().setDirty(!0), p ? I().frame.remove() : I().frame.add(i.name);
        },
        children: [p && /* @__PURE__ */ x(kO, {}), /* @__PURE__ */ x("img", {
          draggable: "false",
          className: "w-64 h-64",
          src: o,
          alt: i.name
        })]
      })
    }, i.name);
  });
  return /* @__PURE__ */ x(jr, {
    children: r
  });
}
function kO() {
  return /* @__PURE__ */ x("span", {
    className: "bg-background/70 absolute inset-0 text-primary",
    children: /* @__PURE__ */ x(Oa, {
      className: "svg-icon icon-md absolute inset-0 block m-auto"
    })
  });
}
function EO() {
  const t = oe((r) => {
    var i, o;
    return (o = (i = r.config.tools) == null ? void 0 : i.text) == null ? void 0 : o.items;
  });
  xe(() => {
    t && lp(t, ct).catch(() => {
    });
  }, [t]), xe(() => {
    I().text.selectOrAddText() && O().setDirty(!0);
  }, []);
  const e = (t || []).map((r) => /* @__PURE__ */ x(It, {
    children: /* @__PURE__ */ x(OO, {
      fontConfig: r
    })
  }, r.family));
  return /* @__PURE__ */ x(jr, {
    className: "pt-6",
    children: e
  });
}
function OO({
  fontConfig: t
}) {
  var i;
  const e = oe((o) => o.objects.active.editableProps.fontFamily), r = ue("block px-6 w-110 h-68 text-sm bg border rounded-2xl", {
    "border-primary": e === t.family,
    "text-primary": e === t.family
  });
  return /* @__PURE__ */ x("button", {
    type: "button",
    className: r,
    style: {
      fontFamily: t.family,
      fontWeight: ((i = t.descriptors) == null ? void 0 : i.weight) || "normal"
    },
    onClick: async () => {
      I().text.selectOrAddText(), O().setDirty(!0), I().objects.setValues({
        fontFamily: t.family
      });
    },
    children: t.family
  });
}
function PO() {
  return xe(() => (I().draw.enable(), () => {
    I().draw.disable();
  }), []), /* @__PURE__ */ ie(jr, {
    gap: "gap-16",
    className: "justify-center",
    children: [/* @__PURE__ */ x(It, {
      children: /* @__PURE__ */ x(Fr, {
        size: "sm",
        label: /* @__PURE__ */ x(we, {
          message: "Brush Color"
        }),
        value: I().draw.currentBrush.color,
        onChange: (t) => {
          I().draw.setBrushColor(t);
        }
      })
    }), /* @__PURE__ */ x(It, {
      children: /* @__PURE__ */ x(AO, {})
    }), /* @__PURE__ */ x(It, {
      children: /* @__PURE__ */ x(MO, {})
    })]
  });
}
function MO() {
  const t = oe((i) => {
    var o, p;
    return (p = (o = i.config.tools) == null ? void 0 : o.draw) == null ? void 0 : p.brushSizes;
  }) || [], [e, r] = Ae(I().draw.currentBrush.width);
  return /* @__PURE__ */ x($l, {
    selectionMode: "single",
    selectedValue: e,
    onSelectionChange: (i) => {
      r(i), I().draw.setBrushSize(i);
    },
    size: "sm",
    label: "Brush Size",
    children: t.map((i) => /* @__PURE__ */ x(Io, {
      value: i,
      children: /* @__PURE__ */ ie("div", {
        className: "flex items-center",
        children: [/* @__PURE__ */ x("div", {
          className: "flex-shrink-0 mr-8 border-[3px] rounded-full",
          style: {
            width: `${i}px`,
            height: `${i}px`
          }
        }), i]
      })
    }, i))
  });
}
function AO() {
  const t = oe((o) => {
    var p, g;
    return (g = (p = o.config.tools) == null ? void 0 : p.draw) == null ? void 0 : g.brushTypes;
  }) || [], e = Bg(), [r, i] = Ae(I().draw.currentBrush.type);
  return /* @__PURE__ */ x($l, {
    selectionMode: "single",
    selectedValue: r,
    onSelectionChange: (o) => {
      i(o), I().draw.setBrushType(o);
    },
    size: "sm",
    label: "Brush Type",
    children: t.map((o) => /* @__PURE__ */ x(Io, {
      value: o,
      children: /* @__PURE__ */ ie("div", {
        className: "flex items-center",
        children: [/* @__PURE__ */ x("img", {
          className: "flex-shrink-0 mr-8 w-24 h-24",
          src: DO(o, e == null ? void 0 : e.isDark),
          alt: ""
        }), o]
      })
    }, o))
  });
}
function DO(t, e = !1) {
  const r = t.replace("Brush", "").toLowerCase();
  return ct(`images/brushes/${e ? "white" : "black"}/${r}.png`);
}
function IO() {
  const {
    trans: t
  } = Lr(), e = oe((r) => r.corners.radius);
  return xe(() => (O().setDirty(!0), I().corners.showPreview(), () => I().corners.hidePreview()), []), /* @__PURE__ */ x("div", {
    className: "max-w-320 mx-auto",
    children: /* @__PURE__ */ x(zr, {
      minValue: 1,
      maxValue: 300,
      label: t({
        message: "Radius"
      }),
      getValueLabel: (r) => `${r}px`,
      onChange: (r) => {
        I().corners.updatePreview(r), O().corners.setRadius(r);
      },
      value: e
    })
  });
}
const Ng = {
  initial: { y: "130%", opacity: 0 },
  animate: { y: 0, opacity: 1 },
  exit: {
    y: "130%",
    opacity: 0,
    left: 0,
    position: "absolute",
    overflowY: "hidden"
  },
  transition: { type: "tween", duration: 0.15 }
};
function RO({
  activeTool: t
}) {
  const e = LO(t);
  return /* @__PURE__ */ x(ot.div, {
    className: "relative h-full w-full text-sm bg select-none overflow-hidden",
    ...Ng,
    children: e
  });
}
function LO(t) {
  switch (t) {
    case Pe.FILTER:
      return /* @__PURE__ */ x(BE, {});
    case Pe.RESIZE:
      return /* @__PURE__ */ x(WE, {});
    case Pe.CROP:
      return /* @__PURE__ */ x(rO, {});
    case Pe.DRAW:
      return /* @__PURE__ */ x(PO, {});
    case Pe.TEXT:
      return /* @__PURE__ */ x(EO, {});
    case Pe.SHAPES:
      return /* @__PURE__ */ x(aO, {});
    case Pe.STICKERS:
      return /* @__PURE__ */ x(CO, {});
    case Pe.FRAME:
      return /* @__PURE__ */ x(TO, {});
    case Pe.CORNERS:
      return /* @__PURE__ */ x(IO, {});
    default:
      return null;
  }
}
function ph({
  className: t
}) {
  const e = oe((r) => r.activeTool);
  return /* @__PURE__ */ x("nav", {
    className: ue("z-navbar min-h-86 flex-shrink-0 px-16 relative overflow-hidden", t),
    children: /* @__PURE__ */ x(cr, {
      initial: !1,
      children: e ? /* @__PURE__ */ x(RO, {
        activeTool: e
      }, "tool-controls") : /* @__PURE__ */ x(FO, {}, "nav-items")
    })
  });
}
function FO() {
  const t = oe((e) => {
    var r, i;
    return (i = (r = e.config.ui) == null ? void 0 : r.nav) == null ? void 0 : i.items;
  }) || [];
  return /* @__PURE__ */ x(ot.div, {
    className: "w-full h-full",
    ...Ng,
    children: /* @__PURE__ */ x(jr, {
      children: t.map((e) => /* @__PURE__ */ x(It, {
        children: /* @__PURE__ */ x(zO, {
          item: e
        })
      }, e.name))
    })
  });
}
function zO({
  item: t
}) {
  const e = () => {
    typeof t.action == "string" ? tl(t.action) : typeof t.action == "function" && t.action(O().editor);
  }, r = Eb[t.name];
  return /* @__PURE__ */ ie(Bt, {
    variant: "outline",
    color: "paper",
    className: "flex-col flex-shrink-0 w-68 h-68",
    radius: "rounded-2xl",
    onClick: e,
    children: [/* @__PURE__ */ x("div", {
      className: "mb-1",
      children: /* @__PURE__ */ x(Rl, {
        className: "icon-md",
        icon: t.icon
      })
    }), /* @__PURE__ */ x("div", {
      className: "mt-6 text-xs capitalize max-w-[90%] overflow-hidden overflow-ellipsis",
      children: r ? /* @__PURE__ */ x(we, {
        ...r
      }) : t.name
    })]
  });
}
function jO() {
  const t = oe((r) => r.history.items), e = oe((r) => r.history.pointer);
  return /* @__PURE__ */ ie(ot.div, {
    ...Pl,
    className: "absolute bottom-20 right-20 w-224 max-w-[calc(100%-40px)] max-h-[calc(100%-40px)] bg-paper shadow-xl border focus:outline-none rounded overflow-hidden",
    children: [/* @__PURE__ */ ie("div", {
      className: "px-10 py-2 mb-4 font-medium text-sm border-b flex items-center",
      children: [/* @__PURE__ */ x(we, {
        message: "History"
      }), /* @__PURE__ */ x(Me, {
        size: "xs",
        className: "ml-auto flex-shrink-0",
        onClick: () => {
          O().togglePanel("history", !1);
        },
        children: /* @__PURE__ */ x(or, {})
      })]
    }), /* @__PURE__ */ x("div", {
      className: "p-10",
      children: t.map((r) => {
        const i = r.id === t[e].id, o = $t[r.name], p = o.icon && ae.createElement(o.icon, {
          className: "icon-sm"
        });
        return /* @__PURE__ */ x(Qe, {
          onClick: () => {
            i || I().history.load(r);
          },
          variant: "outline",
          color: i ? "primary" : null,
          size: "sm",
          className: ue("w-full mb-8", i && "pointer-events-none"),
          justify: "justify-start",
          startIcon: p,
          children: /* @__PURE__ */ x(we, {
            ...o.name
          })
        }, r.id);
      })
    })]
  });
}
function BO(t) {
  const {
    children: e,
    className: r,
    color: i,
    onDismiss: o,
    leftAdornment: p,
    rightAdornment: g,
    hideDismissButton: a = !1,
    size: n,
    showDivider: u
  } = t, {
    labelId: h,
    isDismissable: s,
    close: l
  } = De(Uo);
  return /* @__PURE__ */ ie("div", {
    className: ue(r, "flex items-center justify-between gap-10 flex-shrink-0", u && "border-b", NO(t), i || "text-main"),
    children: [p, /* @__PURE__ */ x("h3", {
      id: h,
      className: ue(r, n === "xs" ? "text-xs" : "text-sm", "font-semibold leading-5 opacity-90"),
      children: e
    }), g, s && !a && /* @__PURE__ */ x(Me, {
      "aria-label": "Dismiss",
      onClick: () => {
        o ? o() : l();
      },
      size: n === "xs" ? "xs" : "sm",
      className: ue("text-muted ml-auto", g && "sr-only"),
      children: /* @__PURE__ */ x(or, {})
    })]
  });
}
function NO({
  size: t,
  padding: e
}) {
  if (e)
    return e;
  switch (t) {
    case "xs":
      return "px-14 py-4";
    case "sm":
      return "px-18 py-4";
    default:
      return "px-24 py-6";
  }
}
const Vg = et((t, e) => {
  const {
    children: r,
    className: i
  } = t;
  return /* @__PURE__ */ x("div", {
    ref: e,
    className: ue(i, VO(t), "overflow-y-auto overflow-x-hidden text-sm"),
    children: r
  });
});
function VO({
  size: t,
  padding: e
}) {
  if (e)
    return e;
  switch (t) {
    case "xs":
      return "p-14";
    case "sm":
      return "p-18";
    default:
      return "px-24 py-20";
  }
}
function $O() {
  const t = oe((e) => e.openPanels.newImage);
  return /* @__PURE__ */ x(Yo, {
    isOpen: t,
    disableInitialTransition: !0,
    type: "modal",
    isDismissable: !1,
    children: /* @__PURE__ */ x(HO, {})
  });
}
function HO() {
  const [t, e] = Ae("default");
  return /* @__PURE__ */ ie(Wo, {
    className: "text-center max-w-max",
    size: "auto",
    children: [/* @__PURE__ */ x(BO, {
      padding: "px-24 pt-24 pb-12",
      showDivider: !1,
      children: /* @__PURE__ */ x(we, {
        message: "Open a photo or design to get started"
      })
    }), /* @__PURE__ */ x(Vg, {
      children: t === "default" ? /* @__PURE__ */ x(UO, {
        setActivePanel: e
      }) : /* @__PURE__ */ x(YO, {
        setActivePanel: e
      })
    })]
  });
}
function UO({
  setActivePanel: t
}) {
  return /* @__PURE__ */ ie(ji, {
    children: [/* @__PURE__ */ x(Qe, {
      className: "mr-20",
      size: "sm",
      variant: "raised",
      color: "primary",
      onClick: () => {
        I().import.uploadAndReplaceMainImage();
      },
      children: /* @__PURE__ */ x(we, {
        message: "Open Photo"
      })
    }), /* @__PURE__ */ x(Qe, {
      variant: "outline",
      size: "sm",
      color: "primary",
      onClick: () => {
        t("newCanvas");
      },
      children: /* @__PURE__ */ x(we, {
        message: "Create New"
      })
    }), /* @__PURE__ */ x(WO, {})]
  });
}
function WO() {
  const t = oe((e) => {
    var r, i;
    return (i = (r = e.config.ui) == null ? void 0 : r.openImageDialog) == null ? void 0 : i.sampleImages;
  });
  return t != null && t.length ? /* @__PURE__ */ ie(ji, {
    children: [/* @__PURE__ */ ie("div", {
      className: "relative py-20",
      children: [/* @__PURE__ */ x("hr", {
        className: "absolute h-1 border-none bg-divider w-full top inset-0 m-auto"
      }), /* @__PURE__ */ x("span", {
        className: "text-sm bg-paper px-6 relative",
        children: /* @__PURE__ */ x(we, {
          message: "or use sample"
        })
      })]
    }), /* @__PURE__ */ x("ul", {
      className: "flex items-center gap-16",
      children: t.map((e) => /* @__PURE__ */ x("li", {
        className: "shrink-0",
        children: /* @__PURE__ */ x("button", {
          type: "button",
          onClick: async () => {
            typeof e.action == "function" ? e.action() : e.url.endsWith(".json") ? (await Co(ct(e.url)), O().togglePanel("newImage", !1)) : (await I().import.openBackgroundImage(ct(e.url)), O().togglePanel("newImage", !1));
          },
          children: /* @__PURE__ */ x("img", {
            className: "w-80 h-80 rounded overflow-hidden transition-shadow hover:shadow-md",
            src: ct(e.thumbnail),
            alt: ""
          })
        })
      }, e.url || e.thumbnail))
    })]
  }) : null;
}
function YO({
  setActivePanel: t
}) {
  const [e, r] = Ae({
    width: 800,
    height: 600,
    bgColor: "transparent"
  });
  return /* @__PURE__ */ ie("form", {
    onSubmit: (i) => {
      i.preventDefault();
      const {
        width: o,
        height: p,
        bgColor: g
      } = e;
      o && p && (O().setConfig({
        blankCanvasSize: {
          width: o,
          height: p
        }
      }), I().canvas.openNew(o, p, g), O().togglePanel("newImage", !1), I().history.addInitial());
    },
    children: [/* @__PURE__ */ x(Or, {
      type: "number",
      label: /* @__PURE__ */ x(we, {
        message: "Width"
      }),
      value: e.width,
      min: 1,
      required: !0,
      className: "mb-16",
      onChange: (i) => {
        r({
          ...e,
          width: i.target.valueAsNumber
        });
      }
    }), /* @__PURE__ */ x(Or, {
      type: "number",
      label: /* @__PURE__ */ x(we, {
        message: "Height"
      }),
      value: e.height,
      min: 1,
      required: !0,
      className: "mb-16",
      onChange: (i) => {
        r({
          ...e,
          height: i.target.valueAsNumber
        });
      }
    }), /* @__PURE__ */ x(Fr, {
      onChange: (i) => {
        r({
          ...e,
          bgColor: i
        });
      },
      className: "mb-16",
      value: e.bgColor,
      label: /* @__PURE__ */ x(we, {
        message: "Background color"
      })
    }), /* @__PURE__ */ ie("div", {
      className: "text-right",
      children: [/* @__PURE__ */ x(Qe, {
        size: "sm",
        variant: "text",
        className: "mr-10",
        onClick: () => {
          t("default");
        },
        children: /* @__PURE__ */ x(we, {
          message: "Cancel"
        })
      }), /* @__PURE__ */ x(Qe, {
        size: "sm",
        type: "submit",
        variant: "raised",
        color: "primary",
        children: /* @__PURE__ */ x(we, {
          message: "Create"
        })
      })]
    })]
  });
}
const XO = et((t, e) => {
  const r = Rr(t), {
    label: i,
    children: o,
    size: p,
    className: g,
    orientation: a = "horizontal",
    disabled: n,
    required: u,
    invalid: h,
    errorMessage: s,
    description: l
  } = t, c = {}, f = yt(), m = t.name || f;
  return /* @__PURE__ */ ie("fieldset", {
    "aria-describedby": l ? `${f}-description` : void 0,
    ref: e,
    className: ue("text-left", g),
    children: [i && /* @__PURE__ */ x("legend", {
      className: r.label,
      ...c,
      children: i
    }), /* @__PURE__ */ x("div", {
      className: ue("flex", a === "vertical" ? "flex-col gap-10" : "flex-row gap-16"),
      children: Sr.map(o, (d) => {
        if (tr(d))
          return dt(d, {
            name: m,
            size: p,
            invalid: d.props.invalid || h || void 0,
            disabled: d.props.disabled || n,
            required: d.props.required || u
          });
      })
    }), l && !s && /* @__PURE__ */ x("div", {
      className: r.description,
      id: `${f}-description`,
      children: l
    }), s && /* @__PURE__ */ x("div", {
      className: r.error,
      children: s
    })]
  });
}), xs = et((t, e) => {
  const {
    children: r,
    autoFocus: i,
    size: o,
    invalid: p,
    isFirst: g,
    ...a
  } = t, n = Ir(e);
  Vl({
    autoFocus: i
  }, n);
  const u = GO(o);
  return /* @__PURE__ */ ie("label", {
    className: ue("inline-flex gap-8 select-none items-center whitespace-nowrap align-middle", u.label, t.disabled && "text-disabled pointer-events-none", t.invalid && "text-danger"),
    children: [/* @__PURE__ */ x("input", {
      type: "radio",
      className: ue("focus-visible:ring outline-none", "rounded-full transition-button border-2 appearance-none", "border-text-muted disabled:border-disabled-fg checked:border-primary checked:hover:border-primary-dark", "before:bg-primary disabled:before:bg-disabled-fg before:hover:bg-primary-dark", "before:h-full before:w-full before:block before:rounded-full before:scale-10 before:opacity-0 before:transition before:duration-200", "checked:before:scale-[.65] checked:before:opacity-100", u.circle),
      ref: n,
      ...a
    }), r && /* @__PURE__ */ x("span", {
      children: r
    })]
  });
});
function GO(t) {
  switch (t) {
    case "xs":
      return {
        circle: "h-12 w-12",
        label: "text-xs"
      };
    case "sm":
      return {
        circle: "h-16 w-16",
        label: "text-sm"
      };
    case "lg":
      return {
        circle: "h-24 w-24",
        label: "text-lg"
      };
    default:
      return {
        circle: "h-20 w-20",
        label: "text-base"
      };
  }
}
function qO() {
  const t = oe((e) => e.openPanels.export);
  return /* @__PURE__ */ x(Yo, {
    isOpen: t,
    onOpenChange: (e) => {
      e || O().togglePanel("export", !1);
    },
    type: "modal",
    children: /* @__PURE__ */ x(KO, {})
  });
}
function KO() {
  const [t, e] = Ae(() => {
    var r, i, o, p, g, a;
    return {
      filename: ((i = (r = O().config.tools) == null ? void 0 : r.export) == null ? void 0 : i.defaultName) || "image",
      format: ((p = (o = O().config.tools) == null ? void 0 : o.export) == null ? void 0 : p.defaultFormat) || "jpeg",
      quality: ((a = (g = O().config.tools) == null ? void 0 : g.export) == null ? void 0 : a.defaultQuality) || 0.8
    };
  });
  return /* @__PURE__ */ x(Wo, {
    className: "text-center max-w-max",
    size: "auto",
    children: /* @__PURE__ */ x(Vg, {
      children: /* @__PURE__ */ ie("form", {
        onSubmit: (r) => {
          r.preventDefault(), I().export.save(t.filename, t.format, t.quality), O().togglePanel("export", !1);
        },
        children: [/* @__PURE__ */ x(Or, {
          required: !0,
          size: "sm",
          label: /* @__PURE__ */ x(we, {
            message: "Save As"
          }),
          value: t.filename,
          onChange: (r) => {
            e({
              ...t,
              filename: r.target.value
            });
          }
        }), /* @__PURE__ */ ie(XO, {
          size: "sm",
          className: "my-20",
          "aria-label": "Image format",
          children: [/* @__PURE__ */ x(xs, {
            value: "jpeg",
            checked: t.format === "jpeg",
            onChange: (r) => {
              e({
                ...t,
                format: r.target.value
              });
            },
            children: "JPEG"
          }), /* @__PURE__ */ x(xs, {
            value: "png",
            checked: t.format === "png",
            onChange: (r) => {
              e({
                ...t,
                format: r.target.value
              });
            },
            children: "PNG"
          }), /* @__PURE__ */ x(xs, {
            value: "json",
            checked: t.format === "json",
            onChange: (r) => {
              e({
                ...t,
                format: r.target.value
              });
            },
            children: "JSON"
          })]
        }), /* @__PURE__ */ x(zr, {
          size: "sm",
          minValue: 0.1,
          step: 0.1,
          maxValue: 1,
          value: t.quality,
          onChange: (r) => {
            e({
              ...t,
              quality: r
            });
          },
          formatOptions: {
            style: "percent"
          },
          label: /* @__PURE__ */ x(we, {
            message: "Quality"
          })
        }), /* @__PURE__ */ x(Qe, {
          variant: "raised",
          color: "primary",
          type: "submit",
          className: "mt-20 w-full",
          size: "sm",
          children: /* @__PURE__ */ x(we, {
            message: "Save"
          })
        })]
      })
    })
  });
}
function ZO() {
  const t = oe((r) => r.objects.all), e = oe((r) => r.objects.active.id);
  return /* @__PURE__ */ ie(ot.div, {
    ...Pl,
    className: "absolute bottom-20 right-20 w-224 max-w-[calc(100%-40px)] max-h-[calc(100%-40px)] bg-paper shadow-xl border focus:outline-none rounded overflow-hidden",
    children: [/* @__PURE__ */ ie("div", {
      className: "px-10 py-2 mb-4 font-medium text-sm border-b flex items-center",
      children: [/* @__PURE__ */ x(we, {
        message: "Objects"
      }), /* @__PURE__ */ x(Me, {
        size: "xs",
        className: "ml-auto flex-shrink-0",
        onClick: () => {
          O().togglePanel("objects", !1);
        },
        children: /* @__PURE__ */ x(or, {})
      })]
    }), /* @__PURE__ */ x("div", {
      className: "p-8",
      children: t.map((r) => {
        const i = r.id === e, o = r.name, p = P1[o], g = p.icon && ae.createElement(p.icon, {
          className: "icon-sm"
        });
        return /* @__PURE__ */ x(Qe, {
          onClick: () => {
            i || !r.selectable || I().objects.select(r.id);
          },
          variant: "outline",
          color: i ? "primary" : null,
          size: "sm",
          className: ue("w-full mb-8", (i || !r.selectable) && "pointer-events-none"),
          justify: "justify-start",
          startIcon: g,
          children: /* @__PURE__ */ x(we, {
            ...p.name
          })
        }, r.id);
      })
    })]
  });
}
function JO() {
  const t = oe((r) => r.openPanels.history), e = oe((r) => r.openPanels.objects);
  return /* @__PURE__ */ ie("div", {
    className: "z-modal",
    children: [/* @__PURE__ */ ie(cr, {
      children: [t && /* @__PURE__ */ x(jO, {}, "historyPanel"), e && /* @__PURE__ */ x(ZO, {}, "objListPanel")]
    }), /* @__PURE__ */ x($O, {}), /* @__PURE__ */ x(qO, {})]
  });
}
/**
 * @remix-run/router v1.0.1
 *
 * Copyright (c) Remix Software Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.md file in the root directory of this source tree.
 *
 * @license MIT
 */
function Pa() {
  return Pa = Object.assign ? Object.assign.bind() : function(t) {
    for (var e = 1; e < arguments.length; e++) {
      var r = arguments[e];
      for (var i in r)
        Object.prototype.hasOwnProperty.call(r, i) && (t[i] = r[i]);
    }
    return t;
  }, Pa.apply(this, arguments);
}
var gh;
(function(t) {
  t.Pop = "POP", t.Push = "PUSH", t.Replace = "REPLACE";
})(gh || (gh = {}));
function mh(t) {
  let {
    pathname: e = "/",
    search: r = "",
    hash: i = ""
  } = t;
  return r && r !== "?" && (e += r.charAt(0) === "?" ? r : "?" + r), i && i !== "#" && (e += i.charAt(0) === "#" ? i : "#" + i), e;
}
function $g(t) {
  let e = {};
  if (t) {
    let r = t.indexOf("#");
    r >= 0 && (e.hash = t.substr(r), t = t.substr(0, r));
    let i = t.indexOf("?");
    i >= 0 && (e.search = t.substr(i), t = t.substr(0, i)), t && (e.pathname = t);
  }
  return e;
}
var vh;
(function(t) {
  t.data = "data", t.deferred = "deferred", t.redirect = "redirect", t.error = "error";
})(vh || (vh = {}));
function Hl(t, e) {
  if (t === !1 || t === null || typeof t > "u")
    throw new Error(e);
}
function QO(t, e) {
  e === void 0 && (e = "/");
  let {
    pathname: r,
    search: i = "",
    hash: o = ""
  } = typeof t == "string" ? $g(t) : t;
  return {
    pathname: r ? r.startsWith("/") ? r : eP(r, e) : e,
    search: tP(i),
    hash: rP(o)
  };
}
function eP(t, e) {
  let r = e.replace(/\/+$/, "").split("/");
  return t.split("/").forEach((o) => {
    o === ".." ? r.length > 1 && r.pop() : o !== "." && r.push(o);
  }), r.length > 1 ? r.join("/") : "/";
}
function Hg(t, e, r, i) {
  i === void 0 && (i = !1);
  let o = typeof t == "string" ? $g(t) : Pa({}, t), p = t === "" || o.pathname === "", g = p ? "/" : o.pathname, a;
  if (i || g == null)
    a = r;
  else {
    let s = e.length - 1;
    if (g.startsWith("..")) {
      let l = g.split("/");
      for (; l[0] === ".."; )
        l.shift(), s -= 1;
      o.pathname = l.join("/");
    }
    a = s >= 0 ? e[s] : "/";
  }
  let n = QO(o, a), u = g && g !== "/" && g.endsWith("/"), h = (p || g === ".") && r.endsWith("/");
  return !n.pathname.endsWith("/") && (u || h) && (n.pathname += "/"), n;
}
const Ug = (t) => t.join("/").replace(/\/\/+/g, "/"), tP = (t) => !t || t === "?" ? "" : t.startsWith("?") ? t : "?" + t, rP = (t) => !t || t === "#" ? "" : t.startsWith("#") ? t : "#" + t;
/**
 * React Router v6.4.1
 *
 * Copyright (c) Remix Software Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.md file in the root directory of this source tree.
 *
 * @license MIT
 */
function iP(t, e) {
  return t === e && (t !== 0 || 1 / t === 1 / e) || t !== t && e !== e;
}
const nP = typeof Object.is == "function" ? Object.is : iP, {
  useState: oP,
  useEffect: sP,
  useLayoutEffect: aP,
  useDebugValue: lP
} = Se;
function cP(t, e, r) {
  const i = e(), [{
    inst: o
  }, p] = oP({
    inst: {
      value: i,
      getSnapshot: e
    }
  });
  return aP(() => {
    o.value = i, o.getSnapshot = e, _s(o) && p({
      inst: o
    });
  }, [t, i, e]), sP(() => (_s(o) && p({
    inst: o
  }), t(() => {
    _s(o) && p({
      inst: o
    });
  })), [t]), lP(i), i;
}
function _s(t) {
  const e = t.getSnapshot, r = t.value;
  try {
    const i = e();
    return !nP(r, i);
  } catch {
    return !0;
  }
}
function uP(t, e, r) {
  return e();
}
const hP = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", fP = !hP, dP = fP ? uP : cP;
"useSyncExternalStore" in Se && ((t) => t.useSyncExternalStore)(Se);
const Wg = /* @__PURE__ */ Se.createContext(null), Yg = /* @__PURE__ */ Se.createContext(null), Xg = /* @__PURE__ */ Se.createContext({
  outlet: null,
  matches: []
});
function pP(t, e) {
  let {
    relative: r
  } = e === void 0 ? {} : e;
  Ul() || Hl(!1);
  let {
    basename: i,
    navigator: o
  } = Se.useContext(Wg), {
    hash: p,
    pathname: g,
    search: a
  } = qg(t, {
    relative: r
  }), n = g;
  return i !== "/" && (n = g === "/" ? i : Ug([i, g])), o.createHref({
    pathname: n,
    search: a,
    hash: p
  });
}
function Ul() {
  return Se.useContext(Yg) != null;
}
function Wl() {
  return Ul() || Hl(!1), Se.useContext(Yg).location;
}
function Gg(t) {
  return t.filter((e, r) => r === 0 || !e.route.index && e.pathnameBase !== t[r - 1].pathnameBase);
}
function gP() {
  Ul() || Hl(!1);
  let {
    basename: t,
    navigator: e
  } = Se.useContext(Wg), {
    matches: r
  } = Se.useContext(Xg), {
    pathname: i
  } = Wl(), o = JSON.stringify(Gg(r).map((a) => a.pathnameBase)), p = Se.useRef(!1);
  return Se.useEffect(() => {
    p.current = !0;
  }), Se.useCallback(function(a, n) {
    if (n === void 0 && (n = {}), !p.current)
      return;
    if (typeof a == "number") {
      e.go(a);
      return;
    }
    let u = Hg(a, JSON.parse(o), i, n.relative === "path");
    t !== "/" && (u.pathname = u.pathname === "/" ? t : Ug([t, u.pathname])), (n.replace ? e.replace : e.push)(u, n.state, n);
  }, [t, e, o, i]);
}
function qg(t, e) {
  let {
    relative: r
  } = e === void 0 ? {} : e, {
    matches: i
  } = Se.useContext(Xg), {
    pathname: o
  } = Wl(), p = JSON.stringify(Gg(i).map((g) => g.pathnameBase));
  return Se.useMemo(() => Hg(t, JSON.parse(p), o, r === "path"), [t, p, o, r]);
}
var bh;
(function(t) {
  t.UseLoaderData = "useLoaderData", t.UseActionData = "useActionData", t.UseRouteError = "useRouteError", t.UseNavigation = "useNavigation", t.UseRouteLoaderData = "useRouteLoaderData", t.UseMatches = "useMatches", t.UseRevalidator = "useRevalidator";
})(bh || (bh = {}));
var yh;
(function(t) {
  t[t.pending = 0] = "pending", t[t.success = 1] = "success", t[t.error = 2] = "error";
})(yh || (yh = {}));
new Promise(() => {
});
/**
 * React Router DOM v6.4.1
 *
 * Copyright (c) Remix Software Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.md file in the root directory of this source tree.
 *
 * @license MIT
 */
function mP(t, e) {
  if (t == null)
    return {};
  var r = {}, i = Object.keys(t), o, p;
  for (p = 0; p < i.length; p++)
    o = i[p], !(e.indexOf(o) >= 0) && (r[o] = t[o]);
  return r;
}
function vP(t) {
  return !!(t.metaKey || t.altKey || t.ctrlKey || t.shiftKey);
}
function bP(t, e) {
  return t.button === 0 && (!e || e === "_self") && !vP(t);
}
const yP = ["onClick", "relative", "reloadDocument", "replace", "state", "target", "to", "preventScrollReset"], wP = /* @__PURE__ */ Se.forwardRef(function(e, r) {
  let {
    onClick: i,
    relative: o,
    reloadDocument: p,
    replace: g,
    state: a,
    target: n,
    to: u,
    preventScrollReset: h
  } = e, s = mP(e, yP), l = pP(u, {
    relative: o
  }), c = xP(u, {
    replace: g,
    state: a,
    target: n,
    preventScrollReset: h,
    relative: o
  });
  function f(m) {
    i && i(m), m.defaultPrevented || c(m);
  }
  return /* @__PURE__ */ x("a", {
    ...s,
    href: l,
    onClick: p ? i : f,
    ref: r,
    target: n
  });
});
function xP(t, e) {
  let {
    target: r,
    replace: i,
    state: o,
    preventScrollReset: p,
    relative: g
  } = e === void 0 ? {} : e, a = gP(), n = Wl(), u = qg(t, {
    relative: g
  });
  return Se.useCallback((h) => {
    if (bP(h, r)) {
      h.preventDefault();
      let s = i !== void 0 ? i : mh(n) === mh(u);
      a(t, {
        replace: s,
        state: o,
        preventScrollReset: p,
        relative: g
      });
    }
  }, [n, a, u, i, o, r, t, p, g]);
}
const _P = me(/* @__PURE__ */ x("path", {
  d: "M11 15h2v2h-2v-2zm0-8h2v6h-2V7zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
}), "ErrorOutlineOutlined"), SP = me(/* @__PURE__ */ x("path", {
  d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm4.59-12.42L10 14.17l-2.59-2.58L6 13l4 4 8-8z"
}), "CheckCircleOutlined");
function CP() {
  const t = zf((e) => e.toasts);
  return /* @__PURE__ */ x("div", {
    className: "relative pointer-events-none",
    children: /* @__PURE__ */ x(cr, {
      initial: !1,
      children: t.map((e) => /* @__PURE__ */ x("div", {
        "data-toast": !0,
        className: ue("fixed mx-auto p-20 z-toast", e.position === "bottom-center" ? "left-0 right-0 bottom-0" : "right-0 bottom-0"),
        children: /* @__PURE__ */ ie(ot.div, {
          initial: {
            opacity: 0,
            y: 50,
            scale: 0.3
          },
          animate: {
            opacity: 1,
            y: 0,
            scale: 1
          },
          exit: {
            opacity: 0,
            scale: 0.5,
            transition: {
              duration: 0.2
            }
          },
          className: ue("flex items-center gap-10 min-w-288 max-w-500 shadow-lg w-min rounded-lg pl-16 pr-6 py-6 text-sm pointer-events-auto max-h-100 bg-paper text-main bg-paper border mx-auto"),
          onPointerEnter: () => {
            var r;
            return (r = e.timer) == null ? void 0 : r.pause();
          },
          onPointerLeave: () => {
            var r;
            return (r = e.timer) == null ? void 0 : r.resume();
          },
          role: "alert",
          "aria-live": e.type === "danger" ? "assertive" : "polite",
          children: [e.type === "danger" && /* @__PURE__ */ x(_P, {
            className: "text-danger flex-shrink-0",
            size: "md"
          }), e.type === "positive" && /* @__PURE__ */ x(SP, {
            className: "text-positive flex-shrink-0",
            size: "md"
          }), /* @__PURE__ */ x("div", {
            className: "overflow-hidden overflow-ellipsis w-max mr-auto",
            children: /* @__PURE__ */ x(wa, {
              value: e.message
            })
          }), e.action && /* @__PURE__ */ x(Qe, {
            variant: "text",
            color: "primary",
            size: "sm",
            className: "flex-shrink-0",
            onFocus: () => {
              var r;
              return (r = e.timer) == null ? void 0 : r.pause();
            },
            onBlur: () => {
              var r;
              return (r = e.timer) == null ? void 0 : r.resume();
            },
            onClick: () => $i().remove(e.id),
            elementType: wP,
            to: e.action.action,
            children: /* @__PURE__ */ x(wa, {
              value: e.action.label
            })
          }), /* @__PURE__ */ x(Me, {
            onFocus: () => {
              var r;
              return (r = e.timer) == null ? void 0 : r.pause();
            },
            onBlur: () => {
              var r;
              return (r = e.timer) == null ? void 0 : r.resume();
            },
            type: "button",
            className: "flex-shrink-0",
            onClick: () => {
              $i().remove(e.id);
            },
            size: "sm",
            children: /* @__PURE__ */ x(or, {})
          })]
        })
      }, e.id))
    })
  });
}
function TP(t) {
  return ip() ? t.metaKey : t.ctrlKey;
}
function kP(t) {
  switch (t.key) {
    case "z":
      TP(t) && (t.preventDefault(), t.stopPropagation(), t.shiftKey ? I().history.redo() : I().history.undo());
      break;
    case "ArrowUp":
      t.preventDefault(), t.stopPropagation(), I().objects.move("up");
      break;
    case "ArrowRight":
      t.preventDefault(), t.stopPropagation(), I().objects.move("right");
      break;
    case "ArrowDown":
      t.preventDefault(), t.stopPropagation(), I().objects.move("down");
      break;
    case "ArrowLeft":
      t.preventDefault(), t.stopPropagation(), I().objects.move("left");
      break;
    case "Delete":
      t.preventDefault(), t.stopPropagation(), I().objects.delete();
      break;
  }
}
const EP = /* @__PURE__ */ new Map(), Ss = /* @__PURE__ */ new Map(), wh = {
  status: "inactive"
};
async function* OP(t) {
  for (const e of t.items)
    if (e.kind === "file")
      if (typeof e.webkitGetAsEntry == "function") {
        const r = e.webkitGetAsEntry();
        if (!r)
          continue;
        if (r.isFile) {
          if (r.name === ".DS_Store")
            continue;
          yield new qi(e.getAsFile(), r.fullPath);
        } else
          r.isDirectory && (yield* Kg(r));
      } else {
        const r = e.getAsFile();
        if (!r || r.name === ".DS_Store")
          continue;
        yield new qi(r, e.fullPath);
      }
}
async function* Kg(t) {
  const e = t.createReader();
  let r;
  do {
    r = await new Promise((i, o) => {
      e.readEntries(i, o);
    });
    for (const i of r)
      if (i.isFile) {
        if (i.name === ".DS_Store")
          continue;
        const o = await PP(i);
        yield new qi(o, i.fullPath);
      } else
        i.isDirectory && (yield* Kg(i));
  } while (r.length > 0);
}
function PP(t) {
  return new Promise((e, r) => t.file(e, r));
}
async function MP(t) {
  const e = [];
  for await (const r of t)
    e.push(r);
  return e;
}
const AP = 400;
function DP({
  id: t,
  disabled: e,
  ref: r,
  ...i
}) {
  const o = de({
    dragOverElements: /* @__PURE__ */ new Set(),
    dropActivateTimer: void 0
  }).current, p = de(i);
  p.current = i, pi(() => (Ss.set(t, {
    ...Ss.get(t),
    disabled: e,
    id: t,
    ref: r
  }), () => {
    Ss.delete(t);
  }), [t, p, e, r]);
  const g = (l) => {
    var f;
    const c = p.current;
    return !!((l == null ? void 0 : l.type) && r.current !== ((f = l.ref) == null ? void 0 : f.current) && c.types.includes(l.type) && (!c.acceptsDrop || c.acceptsDrop(l)));
  }, a = (l) => {
    var f, m;
    const c = Ln(l);
    c && ((m = (f = p.current).onDragLeave) == null || m.call(f, c));
  };
  return {
    droppableProps: e ? {} : {
      onDragOver: (l) => {
        l.preventDefault(), l.stopPropagation();
      },
      onDragEnter: (l) => {
        var f, m;
        if (l.stopPropagation(), o.dragOverElements.add(l.target), o.dragOverElements.size > 1)
          return;
        const c = Ln(l);
        c && g(c) && ((m = (f = p.current).onDragEnter) == null || m.call(f, c), clearTimeout(o.dropActivateTimer), typeof p.current.onDropActivate == "function" && (o.dropActivateTimer = setTimeout(() => {
          var d, v;
          c && ((v = (d = p.current).onDropActivate) == null || v.call(d, c));
        }, AP)));
      },
      onDragLeave: (l) => {
        l.stopPropagation(), o.dragOverElements.delete(l.target);
        for (const f of o.dragOverElements)
          l.currentTarget.contains(f) || o.dragOverElements.delete(f);
        if (o.dragOverElements.size > 0)
          return;
        const c = Ln(l);
        c && g(c) && (a(l), clearTimeout(o.dropActivateTimer));
      },
      onDrop: async (l) => {
        var f, m, d, v;
        l.preventDefault(), l.stopPropagation(), o.dragOverElements.clear(), a(l), clearTimeout(o.dropActivateTimer);
        const c = Ln(l);
        c && ((m = (f = p.current).onDragLeave) == null || m.call(f, c), g(c) && ((v = (d = p.current).onDrop) == null || v.call(d, c)));
      }
    }
  };
}
function Ln(t) {
  if (wh.dragTargetId != null)
    return EP.get(wh.dragTargetId);
  if (t.dataTransfer.types.includes("Files"))
    return {
      type: "nativeFile",
      el: null,
      ref: null,
      getData: () => MP(OP(t.dataTransfer))
    };
}
function IP({
  children: t
}) {
  const e = oe((i) => i.bootstrapData), r = Je(() => ({
    data: e,
    setBootstrapData: () => {
    },
    mergeBootstrapData: () => {
    },
    invalidateBootstrapData: () => {
    }
  }), [e]);
  return /* @__PURE__ */ x(Ap.Provider, {
    value: r,
    children: t
  });
}
function RP() {
  var f, m, d, v;
  const t = (f = oe((b) => {
    var y;
    return (y = b.config.ui) == null ? void 0 : y.visible;
  })) != null ? f : !0, e = (m = oe((b) => {
    var y, w;
    return (w = (y = b.config.ui) == null ? void 0 : y.nav) == null ? void 0 : w.position;
  })) != null ? m : "bottom", r = (d = oe((b) => {
    var y, w;
    return (w = (y = b.config.ui) == null ? void 0 : y.menubar) == null ? void 0 : w.position;
  })) != null ? d : "top", i = (v = oe((b) => {
    var y;
    return (y = b.config.ui) == null ? void 0 : y.allowEditorClose;
  })) != null ? v : !0, o = de(null), p = de(null), {
    isModal: g,
    isMobile: a
  } = No(), n = Ie(async (b) => {
    var w, _, S;
    if (O().activeTool || O().dirty || b.type !== "nativeFile")
      return;
    const y = await b.getData();
    !I().import.fileIsValid(y[0]) || ((S = (_ = (w = O().config.tools) == null ? void 0 : w.import) == null ? void 0 : _.openDroppedImageAsBackground) != null && S ? await I().import.openBackgroundImage(y[0]) : await I().import.openUploadedFile(y[0]));
  }, []), {
    droppableProps: u
  } = DP({
    id: "pixie-root",
    ref: p,
    types: ["nativeFile"],
    onDrop: n
  });
  xe(() => {
    var w, _;
    O().fabric || (oe.setState({
      canvasRef: o
    }), ES(o.current), (w = O().config.ui) != null && w.defaultTool && O().setActiveTool((_ = O().config.ui) == null ? void 0 : _.defaultTool, null), I().canvas.loadInitialContent().then(() => {
      var S, T;
      (T = (S = O().config).onLoad) == null || T.call(S, O().editor);
    }));
    const b = wu(p, () => {
      O().setStageSize(xu(p.current));
    }), y = wu(o, () => {
      O().setCanvasSize(xu(o.current));
    });
    return () => {
      b(), y();
    };
  }, [p]);
  const h = {
    visible: {
      opacity: 1,
      scale: 1,
      display: "flex"
    },
    hidden: {
      opacity: 0,
      transitionEnd: {
        display: "none"
      }
    }
  }, s = ue("pixie-root flex flex-col overflow-hidden bg-background text-main no-tap-highlight w-full h-full", {
    relative: !g,
    "fixed inset-0 w-full h-full z-20": g,
    "shadow-lg border rounded-md m-auto max-h-[calc(100vh-90px)] max-w-[calc(100vw-90px)]": g && !a
  });
  return /* @__PURE__ */ x(s_, {
    features: a_,
    strict: !0,
    children: /* @__PURE__ */ ie(IP, {
      children: [g && t && !a && i && /* @__PURE__ */ x(Me, {
        className: "z-20 fixed right-2 top-2 text-white",
        size: "lg",
        onClick: () => {
          O().editor.close();
        },
        children: /* @__PURE__ */ x(or, {})
      }), g && t && /* @__PURE__ */ x(Il, {
        position: "fixed",
        disableInitialTransition: !0
      }), /* @__PURE__ */ ie(ot.div, {
        initial: !1,
        variants: h,
        animate: t ? "visible" : "hidden",
        className: s,
        children: [r === "top" && /* @__PURE__ */ x(Ru, {}), e === "top" && /* @__PURE__ */ x(ph, {
          className: "pt-14"
        }), /* @__PURE__ */ ie("main", {
          className: "relative flex-auto my-20 overflow-hidden outline-none",
          tabIndex: -1,
          ...vi(u, {
            onKeyDownCapture: kP
          }),
          ref: p,
          children: [/* @__PURE__ */ x(PT, {}), /* @__PURE__ */ x(J5, {
            ref: o
          })]
        }), /* @__PURE__ */ x(IE, {}), e === "bottom" && /* @__PURE__ */ x(ph, {}), r === "bottom" && /* @__PURE__ */ x(Ru, {}), /* @__PURE__ */ x(JO, {}), /* @__PURE__ */ x(CP, {})]
      })]
    })
  });
}
Ts.enableBoundaryChecking(!1);
const Yl = class {
  constructor(e) {
    Ce(this, "tools", {});
    Ce(this, "fabric", null);
    if (e.sentryDsn && Q0({
      dsn: e.sentryDsn
    }), _m(uy), !e.selector)
      throw new Error('Pixie required "selector" option.');
    const r = document.querySelector(e.selector);
    if (!r)
      return;
    r.classList.add("pi"), ay(r), this.setConfig(e), oe.setState({
      editor: this
    }), jf(r).render(/* @__PURE__ */ x(ae.StrictMode, {
      children: /* @__PURE__ */ x(RP, {})
    }));
  }
  get state() {
    return O();
  }
  get defaultConfig() {
    return Yl.defaultConfig;
  }
  open(e = {}) {
    var r;
    (r = O().config.ui) != null && r.visible || (this.setConfig(Eh(e, {
      ui: {
        visible: !0
      }
    })), requestAnimationFrame(() => {
      var i, o, p, g;
      I().zoom.fitToScreen(), I().history.addInitial(), rl() && ((o = (i = O().config.ui) == null ? void 0 : i.openImageDialog) == null ? void 0 : o.show) && this.togglePanel("newImage", !0), (g = (p = O().config).onOpen) == null || g.call(p);
    }));
  }
  close() {
    var e, r, i;
    !((e = O().config.ui) != null && e.visible) || (this.setConfig({
      ui: {
        visible: !1
      }
    }), (i = (r = O().config).onClose) == null || i.call(r));
  }
  setConfig(e) {
    O().setConfig(e);
  }
  uploadAndAddImage() {
    return I().import.uploadAndAddImage();
  }
  uploadAndReplaceMainImage() {
    return I().import.uploadAndReplaceMainImage();
  }
  uploadAndOpenStateFile() {
    return I().import.uploadAndOpenStateFile();
  }
  newCanvas(e, r, i) {
    return I().canvas.openNew(e, r, i);
  }
  getState(e) {
    return JSON.stringify(Zn(e));
  }
  setState(e) {
    return I().import.loadState(e);
  }
  async setStateFromUrl(e) {
    const r = await Co(e);
    return I().import.loadState(r);
  }
  openTool(e) {
    tl(e);
  }
  applyChanges() {
    O().applyChanges();
  }
  cancelChanges() {
    O().cancelChanges();
  }
  async resetEditor(e) {
    await Ws(e), await I().canvas.loadInitialContent();
  }
  togglePanel(e, r) {
    e === "objects" && O().togglePanel("history", !1), e === "history" && O().togglePanel("objects", !1), O().togglePanel(e, r);
  }
  on(e, r) {
    var i;
    (i = this.fabric) == null || i.on(e, r);
  }
  isDirty() {
    return O().dirty;
  }
  get(e) {
    return this.tools[e];
  }
  notify(e) {
    return tn(e);
  }
  static init(e) {
    return new Promise((r) => {
      const i = e.onLoad;
      e.onLoad = (o) => {
        i == null || i(o), r(o);
      }, new this(e);
    });
  }
};
let Fn = Yl;
Ce(Fn, "defaultConfig", vf), Ce(Fn, "version", Vb);
export {
  Fn as Pixie
};
//# sourceMappingURL=pixie.es.js.map
