import { u as C } from "./ImportProductDialog.vue_vue_type_script_setup_true_lang-loNz40wt.js";
import "./index.vue_vue_type_script_setup_true_lang-BMVa5UfU.js";
var Z = {
  defaultAmount: 0,
  defaultCurrency: "USD",
  defaultPrecision: 2
}, J = {
  globalLocale: "en-US",
  globalFormat: "$0,0.00",
  globalRoundingMode: "HALF_EVEN",
  globalFormatRoundingMode: "HALF_AWAY_FROM_ZERO",
  globalExchangeRatesApi: {
    endpoint: void 0,
    headers: void 0,
    propertyPath: void 0
  }
};
function U(t) {
  "@babel/helpers - typeof";
  return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? U = function(i) {
    return typeof i;
  } : U = function(i) {
    return i && typeof Symbol == "function" && i.constructor === Symbol && i !== Symbol.prototype ? "symbol" : typeof i;
  }, U(t);
}
function w(t) {
  return k(t) || B(t) || Q(t) || Y();
}
function k(t) {
  if (Array.isArray(t)) return t;
}
function B(t) {
  if (typeof Symbol < "u" && Symbol.iterator in Object(t)) return Array.from(t);
}
function Q(t, i) {
  if (t) {
    if (typeof t == "string") return H(t, i);
    var n = Object.prototype.toString.call(t).slice(8, -1);
    if (n === "Object" && t.constructor && (n = t.constructor.name), n === "Map" || n === "Set") return Array.from(t);
    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return H(t, i);
  }
}
function H(t, i) {
  (i == null || i > t.length) && (i = t.length);
  for (var n = 0, e = new Array(i); n < i; n++) e[n] = t[n];
  return e;
}
function Y() {
  throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
var tt = {
  /**
   * Returns an array of Dinero objects, normalized to the same precision (the highest).
   *
   * @memberof module:Dinero
   * @method
   *
   * @param {Dinero[]} objects - An array of Dinero objects
   *
   * @example
   * // returns an array of Dinero objects
   * // both with a precision of 3
   * // and an amount of 1000
   * Dinero.normalizePrecision([
   *   Dinero({ amount: 100, precision: 2 }),
   *   Dinero({ amount: 1000, precision: 3 })
   * ])
   *
   * @return {Dinero[]}
   */
  normalizePrecision: function(i) {
    var n = i.reduce(function(e, r) {
      return Math.max(e.getPrecision(), r.getPrecision());
    });
    return i.map(function(e) {
      return e.getPrecision() !== n ? e.convertPrecision(n) : e;
    });
  },
  /**
   * Returns the smallest Dinero object from an array of Dinero objects
   *
   * @memberof module:Dinero
   * @method
   *
   * @param {Dinero[]} objects - An array of Dinero objects
   *
   * @example
   * // returns the smallest Dinero object with amount of 500 from an array of Dinero objects with different precisions
   * Dinero.minimum([
   *   Dinero({ amount: 500, precision: 3 }),
   *   Dinero({ amount: 100, precision: 2 })
   * ])
   * @example
   * // returns the smallest Dinero object with amount of 50 from an array of Dinero objects
   * Dinero.minimum([
   *   Dinero({ amount: 50 }),
   *   Dinero({ amount: 100 })
   * ])
   *
   * @return {Dinero[]}
   */
  minimum: function(i) {
    var n = w(i), e = n[0], r = n.slice(1), a = e;
    return r.forEach(function(u) {
      a = a.lessThan(u) ? a : u;
    }), a;
  },
  /**
   * Returns the biggest Dinero object from an array of Dinero objects
   *
   * @memberof module:Dinero
   * @method
   *
   * @param {Dinero[]} objects - An array of Dinero objects
   *
   * @example
   * // returns the biggest Dinero object with amount of 20, from an array of Dinero objects with different precisions
   * Dinero.maximum([
   *   Dinero({ amount: 20, precision: 2 }),
   *   Dinero({ amount: 150, precision: 3 })
   * ])
   * @example
   * // returns the biggest Dinero object with amount of 100, from an array of Dinero objects
   * Dinero.maximum([
   *   Dinero({ amount: 100 }),
   *   Dinero({ amount: 50 })
   * ])
   *
   * @return {Dinero[]}
   */
  maximum: function(i) {
    var n = w(i), e = n[0], r = n.slice(1), a = e;
    return r.forEach(function(u) {
      a = a.greaterThan(u) ? a : u;
    }), a;
  }
};
function W(t) {
  return !isNaN(parseInt(t)) && isFinite(t);
}
function et(t) {
  return W(t) && t <= 100 && t >= 0;
}
function nt(t) {
  return t.length > 0 && t.every(function(i) {
    return i >= 0;
  }) && t.some(function(i) {
    return i > 0;
  });
}
function x(t) {
  return t % 2 === 0;
}
function G(t) {
  return W(t) && !Number.isInteger(t);
}
function rt() {
  var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0, i = t.toString();
  if (i.indexOf("e-") > 0)
    return parseInt(i.split("e-")[1]);
  var n = i.split(".")[1];
  return n ? n.length : 0;
}
function R(t) {
  return Math.abs(t) % 1 === 0.5;
}
function it(t) {
  var i = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
  return new Promise(function(n, e) {
    var r = Object.assign(new XMLHttpRequest(), {
      onreadystatechange: function() {
        r.readyState === 4 && (r.status >= 200 && r.status < 400 ? n(JSON.parse(r.responseText)) : e(new Error(r.statusText)));
      },
      onerror: function() {
        e(new Error("Network error"));
      }
    });
    r.open("GET", t, !0), ot(r, i.headers), r.send();
  });
}
function ot(t) {
  var i = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
  for (var n in i)
    t.setRequestHeader(n, i[n]);
  return t;
}
function P(t) {
  return typeof t > "u";
}
function z(t) {
  var i = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ".", n = {};
  return Object.entries(t).forEach(function(e) {
    if (U(e[1]) === "object") {
      var r = z(e[1]);
      Object.entries(r).forEach(function(a) {
        n[e[0] + i + a[0]] = a[1];
      });
    } else
      n[e[0]] = e[1];
  }), n;
}
function at(t) {
  return !!t && (U(t) === "object" || typeof t == "function") && typeof t.then == "function";
}
function q() {
  var t = function(e, r) {
    var a = function(g) {
      return Math.pow(10, rt(g));
    }, u = Math.max(a(e), a(r));
    return Math.round(e * u) * Math.round(r * u) / (u * u);
  }, i = {
    HALF_ODD: function(e) {
      var r = Math.round(e);
      return R(e) && x(r) ? r - 1 : r;
    },
    HALF_EVEN: function(e) {
      var r = Math.round(e);
      return R(e) ? x(r) ? r : r - 1 : r;
    },
    HALF_UP: function(e) {
      return Math.round(e);
    },
    HALF_DOWN: function(e) {
      return R(e) ? Math.floor(e) : Math.round(e);
    },
    HALF_TOWARDS_ZERO: function(e) {
      return R(e) ? Math.sign(e) * Math.floor(Math.abs(e)) : Math.round(e);
    },
    HALF_AWAY_FROM_ZERO: function(e) {
      return R(e) ? Math.sign(e) * Math.ceil(Math.abs(e)) : Math.round(e);
    },
    DOWN: function(e) {
      return Math.floor(e);
    }
  };
  return {
    /**
     * Returns the sum of two numbers.
     * @ignore
     *
     * @param {Number} a - The first number to add.
     * @param {Number} b - The second number to add.
     *
     * @return {Number}
     */
    add: function(e, r) {
      return e + r;
    },
    /**
     * Returns the difference of two numbers.
     * @ignore
     *
     * @param {Number} a - The first number to subtract.
     * @param {Number} b - The second number to subtract.
     *
     * @return {Number}
     */
    subtract: function(e, r) {
      return e - r;
    },
    /**
     * Returns the product of two numbers.
     * @ignore
     *
     * @param {Number} a - The first number to multiply.
     * @param {Number} b - The second number to multiply.
     *
     * @return {Number}
     */
    multiply: function(e, r) {
      return G(e) || G(r) ? t(e, r) : e * r;
    },
    /**
     * Returns the quotient of two numbers.
     * @ignore
     *
     * @param {Number} a - The first number to divide.
     * @param {Number} b - The second number to divide.
     *
     * @return {Number}
     */
    divide: function(e, r) {
      return e / r;
    },
    /**
     * Returns the remainder of two numbers.
     * @ignore
     *
     * @param  {Number} a - The first number to divide.
     * @param  {Number} b - The second number to divide.
     *
     * @return {Number}
     */
    modulo: function(e, r) {
      return e % r;
    },
    /**
     * Returns a rounded number based off a specific rounding mode.
     * @ignore
     *
     * @param {Number} number - The number to round.
     * @param {String} [roundingMode='HALF_EVEN'] - The rounding mode to use.
     *
     * @returns {Number}
     */
    round: function(e) {
      var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "HALF_EVEN";
      return i[r](e);
    }
  };
}
var ut = q();
function st(t) {
  var i = /^(?:(\$|USD)?0(?:(,)0)?(\.)?(0+)?|0(?:(,)0)?(\.)?(0+)?\s?(dollar)?)$/gm.exec(t);
  return {
    /**
     * Returns the matches.
     * @ignore
     *
     * @return {Array}
     */
    getMatches: function() {
      return i !== null ? i.slice(1).filter(function(e) {
        return !P(e);
      }) : [];
    },
    /**
     * Returns the amount of fraction digits to display.
     * @ignore
     *
     * @return {Number}
     */
    getMinimumFractionDigits: function() {
      var e = function(a) {
        return a === ".";
      };
      return P(this.getMatches().find(e)) ? 0 : this.getMatches()[ut.add(this.getMatches().findIndex(e), 1)].split("").length;
    },
    /**
     * Returns the currency display mode.
     * @ignore
     *
     * @return {String}
     */
    getCurrencyDisplay: function() {
      var e = {
        USD: "code",
        dollar: "name",
        $: "symbol"
      };
      return e[this.getMatches().find(function(r) {
        return r === "USD" || r === "dollar" || r === "$";
      })];
    },
    /**
     * Returns the formatting style.
     * @ignore
     *
     * @return {String}
     */
    getStyle: function() {
      return P(this.getCurrencyDisplay(this.getMatches())) ? "decimal" : "currency";
    },
    /**
     * Returns whether grouping should be used or not.
     * @ignore
     *
     * @return {Boolean}
     */
    getUseGrouping: function() {
      return !P(this.getMatches().find(function(e) {
        return e === ",";
      }));
    }
  };
}
function ct(t) {
  var i = function() {
    var r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "", a = arguments.length > 1 ? arguments[1] : void 0;
    for (var u in a)
      r = r.replace("{{".concat(u, "}}"), a[u]);
    return r;
  }, n = function(r, a) {
    return it(i(t.endpoint, {
      from: r,
      to: a
    }), {
      headers: t.headers
    });
  };
  return {
    /**
     * Returns the exchange rate.
     * @ignore
     *
     * @param  {String} from - The base currency.
     * @param  {String} to   - The destination currency.
     *
     * @return {Promise}
     */
    getExchangeRate: function(r, a) {
      return (at(t.endpoint) ? t.endpoint : n(r, a)).then(function(u) {
        return z(u)[i(t.propertyPath, {
          from: r,
          to: a
        })];
      });
    }
  };
}
function N(t, i) {
  var n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : Error;
  if (!t) throw new n(i);
}
function lt(t) {
  N(et(t), "You must provide a numeric value between 0 and 100.", RangeError);
}
function dt(t) {
  N(nt(t), "You must provide a non-empty array of numeric values greater than 0.", TypeError);
}
function F(t) {
  N(Number.isInteger(t), "You must provide an integer.", TypeError);
}
var d = q(), mt = function t(i) {
  var n = Object.assign({}, {
    amount: t.defaultAmount,
    currency: t.defaultCurrency,
    precision: t.defaultPrecision
  }, i), e = n.amount, r = n.currency, a = n.precision;
  F(e), F(a);
  var u = t.globalLocale, p = t.globalFormat, g = t.globalRoundingMode, _ = t.globalFormatRoundingMode, M = Object.assign({}, t.globalExchangeRatesApi), f = function(o) {
    var s = Object.assign({}, Object.assign({}, {
      amount: e,
      currency: r,
      precision: a
    }, o), Object.assign({}, {
      locale: this.locale
    }, o));
    return Object.assign(t({
      amount: s.amount,
      currency: s.currency,
      precision: s.precision
    }), {
      locale: s.locale
    });
  }, v = function(o) {
    N(this.hasSameCurrency(o), "You must provide a Dinero instance with the same currency.", TypeError);
  };
  return {
    /**
     * Returns the amount.
     *
     * @example
     * // returns 500
     * Dinero({ amount: 500 }).getAmount()
     *
     * @return {Number}
     */
    getAmount: function() {
      return e;
    },
    /**
     * Returns the currency.
     *
     * @example
     * // returns 'EUR'
     * Dinero({ currency: 'EUR' }).getCurrency()
     *
     * @return {String}
     */
    getCurrency: function() {
      return r;
    },
    /**
     * Returns the locale.
     *
     * @example
     * // returns 'fr-FR'
     * Dinero().setLocale('fr-FR').getLocale()
     *
     * @return {String}
     */
    getLocale: function() {
      return this.locale || u;
    },
    /**
     * Returns a new Dinero object with an embedded locale.
     *
     * @param {String} newLocale - The new locale as an {@link http://tools.ietf.org/html/rfc5646 BCP 47 language tag}.
     *
     * @example
     * // Returns a Dinero object with locale 'ja-JP'
     * Dinero().setLocale('ja-JP')
     *
     * @return {Dinero}
     */
    setLocale: function(o) {
      return f.call(this, {
        locale: o
      });
    },
    /**
     * Returns the precision.
     *
     * @example
     * // returns 3
     * Dinero({ precision: 3 }).getPrecision()
     *
     * @return {Number}
     */
    getPrecision: function() {
      return a;
    },
    /**
     * Returns a new Dinero object with a new precision and a converted amount.
     *
     * By default, fractional minor currency units are rounded using the **half to even** rule ([banker's rounding](http://wiki.c2.com/?BankersRounding)).
     * This can be necessary when you need to convert objects to a smaller precision.
     *
     * Rounding *can* lead to accuracy issues as you chain many times. Consider a minimal amount of subsequent conversions for safer results.
     * You can also specify a different `roundingMode` to better fit your needs.
     *
     * @param {Number} newPrecision - The new precision.
     * @param {String} [roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
     *
     * @example
     * // Returns a Dinero object with precision 3 and amount 1000
     * Dinero({ amount: 100, precision: 2 }).convertPrecision(3)
     *
     * @throws {TypeError} If `newPrecision` is invalid.
     *
     * @return {Dinero}
     */
    convertPrecision: function(o) {
      var s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : _;
      F(o);
      var l = this.getPrecision(), m = o > l, A = m ? d.multiply : d.divide, y = m ? [o, l] : [l, o], O = Math.pow(10, d.subtract.apply(d, y));
      return f.call(this, {
        amount: d.round(A(this.getAmount(), O), s),
        precision: o
      });
    },
    /**
     * Returns a new Dinero object that represents the sum of this and an other Dinero object.
     *
     * If Dinero objects have a different `precision`, they will be first converted to the highest.
     *
     * @param {Dinero} addend - The Dinero object to add.
     *
     * @example
     * // returns a Dinero object with amount 600
     * Dinero({ amount: 400 }).add(Dinero({ amount: 200 }))
     * @example
     * // returns a Dinero object with amount 144545 and precision 4
     * Dinero({ amount: 400 }).add(Dinero({ amount: 104545, precision: 4 }))
     *
     * @throws {TypeError} If `addend` has a different currency.
     *
     * @return {Dinero}
     */
    add: function(o) {
      v.call(this, o);
      var s = t.normalizePrecision([this, o]);
      return f.call(this, {
        amount: d.add(s[0].getAmount(), s[1].getAmount()),
        precision: s[0].getPrecision()
      });
    },
    /**
     * Returns a new Dinero object that represents the difference of this and an other Dinero object.
     *
     * If Dinero objects have a different `precision`, they will be first converted to the highest.
     *
     * @param  {Dinero} subtrahend - The Dinero object to subtract.
     *
     * @example
     * // returns a Dinero object with amount 200
     * Dinero({ amount: 400 }).subtract(Dinero({ amount: 200 }))
     * @example
     * // returns a Dinero object with amount 64545 and precision 4
     * Dinero({ amount: 104545, precision: 4 }).subtract(Dinero({ amount: 400 }))
     *
     * @throws {TypeError} If `subtrahend` has a different currency.
     *
     * @return {Dinero}
     */
    subtract: function(o) {
      v.call(this, o);
      var s = t.normalizePrecision([this, o]);
      return f.call(this, {
        amount: d.subtract(s[0].getAmount(), s[1].getAmount()),
        precision: s[0].getPrecision()
      });
    },
    /**
     * Returns a new Dinero object that represents the multiplied value by the given factor.
     *
     * By default, fractional minor currency units are rounded using the **half to even** rule ([banker's rounding](http://wiki.c2.com/?BankersRounding)).
     *
     * Rounding *can* lead to accuracy issues as you chain many times. Consider a minimal amount of subsequent calculations for safer results.
     * You can also specify a different `roundingMode` to better fit your needs.
     *
     * @param  {Number} multiplier - The factor to multiply by.
     * @param  {String} [roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
     *
     * @example
     * // returns a Dinero object with amount 1600
     * Dinero({ amount: 400 }).multiply(4)
     * @example
     * // returns a Dinero object with amount 800
     * Dinero({ amount: 400 }).multiply(2.001)
     * @example
     * // returns a Dinero object with amount 801
     * Dinero({ amount: 400 }).multiply(2.00125, 'HALF_UP')
     *
     * @return {Dinero}
     */
    multiply: function(o) {
      var s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : g;
      return f.call(this, {
        amount: d.round(d.multiply(this.getAmount(), o), s)
      });
    },
    /**
     * Returns a new Dinero object that represents the divided value by the given factor.
     *
     * By default, fractional minor currency units are rounded using the **half to even** rule ([banker's rounding](http://wiki.c2.com/?BankersRounding)).
     *
     * Rounding *can* lead to accuracy issues as you chain many times. Consider a minimal amount of subsequent calculations for safer results.
     * You can also specify a different `roundingMode` to better fit your needs.
     *
     * As rounding is applied, precision may be lost in the process. If you want to accurately split a Dinero object, use {@link module:Dinero~allocate allocate} instead.
     *
     * @param  {Number} divisor - The factor to divide by.
     * @param  {String} [roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
     *
     * @example
     * // returns a Dinero object with amount 100
     * Dinero({ amount: 400 }).divide(4)
     * @example
     * // returns a Dinero object with amount 52
     * Dinero({ amount: 105 }).divide(2)
     * @example
     * // returns a Dinero object with amount 53
     * Dinero({ amount: 105 }).divide(2, 'HALF_UP')
     *
     * @return {Dinero}
     */
    divide: function(o) {
      var s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : g;
      return f.call(this, {
        amount: d.round(d.divide(this.getAmount(), o), s)
      });
    },
    /**
     * Returns a new Dinero object that represents a percentage of this.
     *
     * As rounding is applied, precision may be lost in the process. If you want to accurately split a Dinero object, use {@link module:Dinero~allocate allocate} instead.
     *
     * @param  {Number} percentage - The percentage to extract (between 0 and 100).
     * @param  {String} [roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
     *
     * @example
     * // returns a Dinero object with amount 5000
     * Dinero({ amount: 10000 }).percentage(50)
     * @example
     * // returns a Dinero object with amount 29
     * Dinero({ amount: 57 }).percentage(50, "HALF_ODD")
     *
     * @throws {RangeError} If `percentage` is out of range.
     *
     * @return {Dinero}
     */
    percentage: function(o) {
      var s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : g;
      return lt(o), this.multiply(d.divide(o, 100), s);
    },
    /**
     * Allocates the amount of a Dinero object according to a list of ratios.
     *
     * Sometimes you need to split monetary values but percentages can't cut it without adding or losing pennies.
     * A good example is invoicing: let's say you need to bill $1,000.03 and you want a 50% downpayment.
     * If you use {@link module:Dinero~percentage percentage}, you'll get an accurate Dinero object but the amount won't be billable: you can't split a penny.
     * If you round it, you'll bill a penny extra.
     * With {@link module:Dinero~allocate allocate}, you can split a monetary amount then distribute the remainder as evenly as possible.
     *
     * You can use percentage style or ratio style for `ratios`: `[25, 75]` and `[1, 3]` will do the same thing.
     *
     * Since v1.8.0, you can use zero ratios (such as [0, 50, 50]). If there's a remainder to distribute, zero ratios are skipped and return a Dinero object with amount zero.
     *
     * @param  {Number[]} ratios - The ratios to allocate the money to.
     *
     * @example
     * // returns an array of two Dinero objects
     * // the first one with an amount of 502
     * // the second one with an amount of 501
     * Dinero({ amount: 1003 }).allocate([50, 50])
     * @example
     * // returns an array of two Dinero objects
     * // the first one with an amount of 25
     * // the second one with an amount of 75
     * Dinero({ amount: 100 }).allocate([1, 3])
     * @example
     * // since version 1.8.0
     * // returns an array of three Dinero objects
     * // the first one with an amount of 0
     * // the second one with an amount of 502
     * // the third one with an amount of 501
     * Dinero({ amount: 1003 }).allocate([0, 50, 50])
     *
     * @throws {TypeError} If ratios are invalid.
     *
     * @return {Dinero[]}
     */
    allocate: function(o) {
      var s = this;
      dt(o);
      for (var l = o.reduce(function(O, D) {
        return d.add(O, D);
      }), m = this.getAmount(), A = o.map(function(O) {
        var D = Math.floor(d.divide(d.multiply(s.getAmount(), O), l));
        return m = d.subtract(m, D), f.call(s, {
          amount: D
        });
      }), y = 0; m > 0; )
        o[y] > 0 && (A[y] = A[y].add(f.call(this, {
          amount: 1
        })), m = d.subtract(m, 1)), y += 1;
      return A;
    },
    /**
     * Returns a Promise containing a new Dinero object converted to another currency.
     *
     * You have two options to provide the exchange rates:
     *
     * 1. **Use an exchange rate REST API, and let Dinero handle the fetching and conversion.**
     *   This is a simple option if you have access to an exchange rate REST API and want Dinero to do the rest.
     * 2. **Fetch the exchange rates on your own and provide them directly.**
     *   This is useful if you're fetching your rates from somewhere else (a file, a database), use a different protocol or query language than REST (SOAP, GraphQL) or want to fetch rates once and cache them instead of making new requests every time.
     *
     * **If you want to use a REST API**, you must provide a third-party endpoint yourself. Dinero doesn't come bundled with an exchange rates endpoint.
     *
     * Here are some exchange rate APIs you can use:
     *
     * * [Fixer](https://fixer.io)
     * * [Open Exchange Rates](https://openexchangerates.org)
     * * [Coinbase](https://api.coinbase.com/v2/exchange-rates)
     * * More [foreign](https://github.com/toddmotto/public-apis#currency-exchange) and [crypto](https://github.com/toddmotto/public-apis#cryptocurrency) exchange rate APIs.
     *
     * **If you want to fetch your own rates and provide them directly**, you need to pass a promise that resolves to the exchanges rates.
     *
     * In both cases, you need to specify at least:
     *
     * * a **destination currency**: the currency in which you want to convert your Dinero object. You can specify it with `currency`.
     * * an **endpoint**: the API URL to query exchange rates, with parameters, or a promise that resolves to the exchange rates. You can specify it with `options.endpoint`.
     * * a **property path**: the path to access the wanted rate in your API's JSON response (or the custom promise's payload). For example, with a response of:
     * ```json
     * {
     *     "data": {
     *       "base": "USD",
     *       "destination": "EUR",
     *       "rate": "0.827728919"
     *     }
     * }
     * ```
     * Then the property path is `'data.rate'`. You can specify it with `options.propertyPath`.
     *
     * The base currency (the one of your Dinero object) and the destination currency can be used as "merge tags" with the mustache syntax, respectively `{{from}}` and `{{to}}`.
     * You can use these tags to refer to these values in `options.endpoint` and `options.propertyPath`.
     *
     * For example, if you need to specify the base currency as a query parameter, you can do the following:
     *
     * ```js
     * {
     *   endpoint: 'https://yourexchangerates.api/latest?base={{from}}'
     * }
     * ```
     *
     * @param  {String} currency - The destination currency, expressed as an {@link https://en.wikipedia.org/wiki/ISO_4217#Active_codes ISO 4217 currency code}.
     * @param  {(String|Promise)} options.endpoint - The API endpoint to retrieve exchange rates. You can substitute this with a promise that resolves to the exchanges rates if you already have them.
     * @param  {String} [options.propertyPath='rates.{{to}}'] - The property path to the rate.
     * @param  {Object} [options.headers] - The HTTP headers to provide, if needed.
     * @param  {String} [options.roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
     *
     * @example
     * // your global API parameters
     * Dinero.globalExchangeRatesApi = { ... }
     *
     * // returns a Promise containing a Dinero object with the destination currency
     * // and the initial amount converted to the new currency.
     * Dinero({ amount: 500 }).convert('EUR')
     * @example
     * // returns a Promise containing a Dinero object,
     * // with specific API parameters and rounding mode for this specific instance.
     * Dinero({ amount: 500 })
     *   .convert('XBT', {
     *     endpoint: 'https://yourexchangerates.api/latest?base={{from}}',
     *     propertyPath: 'data.rates.{{to}}',
     *     headers: {
     *       'user-key': 'xxxxxxxxx'
     *     },
     *     roundingMode: 'HALF_UP'
     *   })
     * @example
     * // usage with exchange rates provided as a custom promise
     * // using the default `propertyPath` format (so it doesn't have to be specified)
     * const rates = {
     *   rates: {
     *     EUR: 0.81162
     *   }
     * }
     *
     * Dinero({ amount: 500 })
     *   .convert('EUR', {
     *     endpoint: new Promise(resolve => resolve(rates))
     *   })
     * @example
     * // usage with Promise.prototype.then and Promise.prototype.catch
     * Dinero({ amount: 500 })
     *   .convert('EUR')
     *   .then(dinero => {
     *     dinero.getCurrency() // returns 'EUR'
     *   })
     *   .catch(err => {
     *     // handle errors
     *   })
     * @example
     * // usage with async/await
     * (async () => {
     *   const price = await Dinero({ amount: 500 }).convert('EUR')
     *   price.getCurrency() // returns 'EUR'
     * })()
     *
     * @return {Promise}
     */
    convert: function(o) {
      var s = this, l = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, m = l.endpoint, A = m === void 0 ? M.endpoint : m, y = l.propertyPath, O = y === void 0 ? M.propertyPath || "rates.{{to}}" : y, D = l.headers, V = D === void 0 ? M.headers : D, L = l.roundingMode, X = L === void 0 ? g : L, j = Object.assign({}, {
        endpoint: A,
        propertyPath: O,
        headers: V,
        roundingMode: X
      });
      return ct(j).getExchangeRate(this.getCurrency(), o).then(function(I) {
        return N(!P(I), 'No rate was found for the destination currency "'.concat(o, '".'), TypeError), f.call(s, {
          amount: d.round(d.multiply(s.getAmount(), parseFloat(I)), j.roundingMode),
          currency: o
        });
      });
    },
    /**
     * Checks whether the value represented by this object equals to the other.
     *
     * @param  {Dinero} comparator - The Dinero object to compare to.
     *
     * @example
     * // returns true
     * Dinero({ amount: 500, currency: 'EUR' }).equalsTo(Dinero({ amount: 500, currency: 'EUR' }))
     * @example
     * // returns false
     * Dinero({ amount: 500, currency: 'EUR' }).equalsTo(Dinero({ amount: 800, currency: 'EUR' }))
     * @example
     * // returns false
     * Dinero({ amount: 500, currency: 'USD' }).equalsTo(Dinero({ amount: 500, currency: 'EUR' }))
     * @example
     * // returns false
     * Dinero({ amount: 500, currency: 'USD' }).equalsTo(Dinero({ amount: 800, currency: 'EUR' }))
     * @example
     * // returns true
     * Dinero({ amount: 1000, currency: 'EUR', precision: 2 }).equalsTo(Dinero({ amount: 10000, currency: 'EUR', precision: 3 }))
     * @example
     * // returns false
     * Dinero({ amount: 10000, currency: 'EUR', precision: 2 }).equalsTo(Dinero({ amount: 10000, currency: 'EUR', precision: 3 }))
     *
     * @return {Boolean}
     */
    equalsTo: function(o) {
      return this.hasSameAmount(o) && this.hasSameCurrency(o);
    },
    /**
     * Checks whether the value represented by this object is less than the other.
     *
     * @param  {Dinero} comparator - The Dinero object to compare to.
     *
     * @example
     * // returns true
     * Dinero({ amount: 500 }).lessThan(Dinero({ amount: 800 }))
     * @example
     * // returns false
     * Dinero({ amount: 800 }).lessThan(Dinero({ amount: 500 }))
     * @example
     * // returns true
     * Dinero({ amount: 5000, precision: 3 }).lessThan(Dinero({ amount: 800 }))
     * @example
     * // returns false
     * Dinero({ amount: 800 }).lessThan(Dinero({ amount: 5000, precision: 3 }))
     *
     * @throws {TypeError} If `comparator` has a different currency.
     *
     * @return {Boolean}
     */
    lessThan: function(o) {
      v.call(this, o);
      var s = t.normalizePrecision([this, o]);
      return s[0].getAmount() < s[1].getAmount();
    },
    /**
     * Checks whether the value represented by this object is less than or equal to the other.
     *
     * @param  {Dinero} comparator - The Dinero object to compare to.
     *
     * @example
     * // returns true
     * Dinero({ amount: 500 }).lessThanOrEqual(Dinero({ amount: 800 }))
     * @example
     * // returns true
     * Dinero({ amount: 500 }).lessThanOrEqual(Dinero({ amount: 500 }))
     * @example
     * // returns false
     * Dinero({ amount: 500 }).lessThanOrEqual(Dinero({ amount: 300 }))
     * @example
     * // returns true
     * Dinero({ amount: 5000, precision: 3 }).lessThanOrEqual(Dinero({ amount: 800 }))
     * @example
     * // returns true
     * Dinero({ amount: 5000, precision: 3 }).lessThanOrEqual(Dinero({ amount: 500 }))
     * @example
     * // returns false
     * Dinero({ amount: 800 }).lessThanOrEqual(Dinero({ amount: 5000, precision: 3 }))
     *
     * @throws {TypeError} If `comparator` has a different currency.
     *
     * @return {Boolean}
     */
    lessThanOrEqual: function(o) {
      v.call(this, o);
      var s = t.normalizePrecision([this, o]);
      return s[0].getAmount() <= s[1].getAmount();
    },
    /**
     * Checks whether the value represented by this object is greater than the other.
     *
     * @param  {Dinero} comparator - The Dinero object to compare to.
     *
     * @example
     * // returns false
     * Dinero({ amount: 500 }).greaterThan(Dinero({ amount: 800 }))
     * @example
     * // returns true
     * Dinero({ amount: 800 }).greaterThan(Dinero({ amount: 500 }))
     * @example
     * // returns true
     * Dinero({ amount: 800 }).greaterThan(Dinero({ amount: 5000, precision: 3 }))
     * @example
     * // returns false
     * Dinero({ amount: 5000, precision: 3 }).greaterThan(Dinero({ amount: 800 }))
     *
     * @throws {TypeError} If `comparator` has a different currency.
     *
     * @return {Boolean}
     */
    greaterThan: function(o) {
      v.call(this, o);
      var s = t.normalizePrecision([this, o]);
      return s[0].getAmount() > s[1].getAmount();
    },
    /**
     * Checks whether the value represented by this object is greater than or equal to the other.
     *
     * @param  {Dinero} comparator - The Dinero object to compare to.
     *
     * @example
     * // returns true
     * Dinero({ amount: 500 }).greaterThanOrEqual(Dinero({ amount: 300 }))
     * @example
     * // returns true
     * Dinero({ amount: 500 }).greaterThanOrEqual(Dinero({ amount: 500 }))
     * @example
     * // returns false
     * Dinero({ amount: 500 }).greaterThanOrEqual(Dinero({ amount: 800 }))
     * @example
     * // returns true
     * Dinero({ amount: 800 }).greaterThanOrEqual(Dinero({ amount: 5000, precision: 3 }))
     * @example
     * // returns true
     * Dinero({ amount: 500 }).greaterThanOrEqual(Dinero({ amount: 5000, precision: 3 }))
     * @example
     * // returns false
     * Dinero({ amount: 5000, precision: 3 }).greaterThanOrEqual(Dinero({ amount: 800 }))
     *
     * @throws {TypeError} If `comparator` has a different currency.
     *
     * @return {Boolean}
     */
    greaterThanOrEqual: function(o) {
      v.call(this, o);
      var s = t.normalizePrecision([this, o]);
      return s[0].getAmount() >= s[1].getAmount();
    },
    /**
     * Checks if the value represented by this object is zero.
     *
     * @example
     * // returns true
     * Dinero({ amount: 0 }).isZero()
     * @example
     * // returns false
     * Dinero({ amount: 100 }).isZero()
     *
     * @return {Boolean}
     */
    isZero: function() {
      return this.getAmount() === 0;
    },
    /**
     * Checks if the value represented by this object is positive.
     *
     * @example
     * // returns false
     * Dinero({ amount: -10 }).isPositive()
     * @example
     * // returns true
     * Dinero({ amount: 10 }).isPositive()
     * @example
     * // returns true
     * Dinero({ amount: 0 }).isPositive()
     *
     * @return {Boolean}
     */
    isPositive: function() {
      return this.getAmount() >= 0;
    },
    /**
     * Checks if the value represented by this object is negative.
     *
     * @example
     * // returns true
     * Dinero({ amount: -10 }).isNegative()
     * @example
     * // returns false
     * Dinero({ amount: 10 }).isNegative()
     * @example
     * // returns false
     * Dinero({ amount: 0 }).isNegative()
     *
     * @return {Boolean}
     */
    isNegative: function() {
      return this.getAmount() < 0;
    },
    /**
     * Checks if this has minor currency units.
     * Deprecates {@link module:Dinero~hasCents hasCents}.
     *
     * @example
     * // returns false
     * Dinero({ amount: 1100 }).hasSubUnits()
     * @example
     * // returns true
     * Dinero({ amount: 1150 }).hasSubUnits()
     *
     * @return {Boolean}
     */
    hasSubUnits: function() {
      return d.modulo(this.getAmount(), Math.pow(10, a)) !== 0;
    },
    /**
     * Checks if this has minor currency units.
     *
     * @deprecated since version 1.4.0, will be removed in 2.0.0
     * Use {@link module:Dinero~hasSubUnits hasSubUnits} instead.
     *
     * @example
     * // returns false
     * Dinero({ amount: 1100 }).hasCents()
     * @example
     * // returns true
     * Dinero({ amount: 1150 }).hasCents()
     *
     * @return {Boolean}
     */
    hasCents: function() {
      return d.modulo(this.getAmount(), Math.pow(10, a)) !== 0;
    },
    /**
     * Checks whether the currency represented by this object equals to the other.
     *
     * @param  {Dinero}  comparator - The Dinero object to compare to.
     *
     * @example
     * // returns true
     * Dinero({ amount: 2000, currency: 'EUR' }).hasSameCurrency(Dinero({ amount: 1000, currency: 'EUR' }))
     * @example
     * // returns false
     * Dinero({ amount: 1000, currency: 'EUR' }).hasSameCurrency(Dinero({ amount: 1000, currency: 'USD' }))
     *
     * @return {Boolean}
     */
    hasSameCurrency: function(o) {
      return this.getCurrency() === o.getCurrency();
    },
    /**
     * Checks whether the amount represented by this object equals to the other.
     *
     * @param  {Dinero}  comparator - The Dinero object to compare to.
     *
     * @example
     * // returns true
     * Dinero({ amount: 1000, currency: 'EUR' }).hasSameAmount(Dinero({ amount: 1000 }))
     * @example
     * // returns false
     * Dinero({ amount: 2000, currency: 'EUR' }).hasSameAmount(Dinero({ amount: 1000, currency: 'EUR' }))
     * @example
     * // returns true
     * Dinero({ amount: 1000, currency: 'EUR', precision: 2 }).hasSameAmount(Dinero({ amount: 10000, precision: 3 }))
     * @example
     * // returns false
     * Dinero({ amount: 10000, currency: 'EUR', precision: 2 }).hasSameAmount(Dinero({ amount: 10000, precision: 3 }))
     *
     * @return {Boolean}
     */
    hasSameAmount: function(o) {
      var s = t.normalizePrecision([this, o]);
      return s[0].getAmount() === s[1].getAmount();
    },
    /**
     * Returns this object formatted as a string.
     *
     * The format is a mask which defines how the output string will be formatted.
     * It defines whether to display a currency, in what format, how many fraction digits to display and whether to use grouping separators.
     * The output is formatted according to the applying locale.
     *
     * Object                       | Format            | String
     * :--------------------------- | :---------------- | :---
     * `Dinero({ amount: 500050 })` | `'$0,0.00'`       | $5,000.50
     * `Dinero({ amount: 500050 })` | `'$0,0'`          | $5,001
     * `Dinero({ amount: 500050 })` | `'$0'`            | $5001
     * `Dinero({ amount: 500050 })` | `'$0.0'`          | $5000.5
     * `Dinero({ amount: 500050 })` | `'USD0,0.0'`      | USD5,000.5
     * `Dinero({ amount: 500050 })` | `'0,0.0 dollar'`  | 5,000.5 dollars
     *
     * Don't try to substitute the `$` sign or the `USD` code with your target currency, nor adapt the format string to the exact format you want.
     * The format is a mask which defines a pattern and returns a valid, localized currency string.
     * If you want to display the object in a custom way, either use {@link module:Dinero~getAmount getAmount}, {@link module:Dinero~toUnit toUnit} or {@link module:Dinero~toRoundedUnit toRoundedUnit} and manipulate the output string as you wish.
     *
     * {@link module:Dinero~toFormat toFormat} wraps around `Number.prototype.toLocaleString`. For that reason, **format will vary depending on how it's implemented in the end user's environment**.
     *
     * You can also use `toLocaleString` directly:
     * `Dinero().toRoundedUnit(digits, roundingMode).toLocaleString(locale, options)`.
     *
     * By default, amounts are rounded using the **half away from zero** rule ([commercial rounding](https://en.wikipedia.org/wiki/Rounding#Round_half_away_from_zero)).
     * You can also specify a different `roundingMode` to better fit your needs.
     *
     * @param  {String} [format='$0,0.00'] - The format mask to format to.
     * @param  {String} [roundingMode='HALF_AWAY_FROM_ZERO'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
     *
     * @example
     * // returns $2,000
     * Dinero({ amount: 200000 }).toFormat('$0,0')
     * @example
     * // returns €50.5
     * Dinero({ amount: 5050, currency: 'EUR' }).toFormat('$0,0.0')
     * @example
     * // returns 100 euros
     * Dinero({ amount: 10000, currency: 'EUR' }).setLocale('fr-FR').toFormat('0,0 dollar')
     * @example
     * // returns 2000
     * Dinero({ amount: 200000, currency: 'EUR' }).toFormat()
     * @example
     * // returns $10
     * Dinero({ amount: 1050 }).toFormat('$0', 'HALF_EVEN')
     *
     * @return {String}
     */
    toFormat: function() {
      var o = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : p, s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : _, l = st(o);
      return this.toRoundedUnit(l.getMinimumFractionDigits(), s).toLocaleString(this.getLocale(), {
        currencyDisplay: l.getCurrencyDisplay(),
        useGrouping: l.getUseGrouping(),
        minimumFractionDigits: l.getMinimumFractionDigits(),
        style: l.getStyle(),
        currency: this.getCurrency()
      });
    },
    /**
     * Returns the amount represented by this object in units.
     *
     * @example
     * // returns 10.5
     * Dinero({ amount: 1050 }).toUnit()
     * @example
     * // returns 10.545
     * Dinero({ amount: 10545, precision: 3 }).toUnit()
     *
     * @return {Number}
     */
    toUnit: function() {
      return d.divide(this.getAmount(), Math.pow(10, a));
    },
    /**
     * Returns the amount represented by this object in rounded units.
     *
     * By default, the method uses the **half away from zero** rule ([commercial rounding](https://en.wikipedia.org/wiki/Rounding#Round_half_away_from_zero)).
     * You can also specify a different `roundingMode` to better fit your needs.
     *
     * @example
     * // returns 10.6
     * Dinero({ amount: 1055 }).toRoundedUnit(1)
     * @example
     * // returns 10
     * Dinero({ amount: 1050 }).toRoundedUnit(0, 'HALF_EVEN')
     *
     * @param  {Number} digits - The number of fraction digits to round to.
     * @param  {String} [roundingMode='HALF_AWAY_FROM_ZERO'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
     *
     * @return {Number}
     */
    toRoundedUnit: function(o) {
      var s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : _, l = Math.pow(10, o);
      return d.divide(d.round(d.multiply(this.toUnit(), l), s), l);
    },
    /**
     * Returns the object's data as an object literal.
     *
     * @example
     * // returns { amount: 500, currency: 'EUR', precision: 2 }
     * Dinero({ amount: 500, currency: 'EUR', precision: 2 }).toObject()
     *
     * @return {Object}
     */
    toObject: function() {
      return {
        amount: e,
        currency: r,
        precision: a
      };
    },
    /**
     * Returns the object's data as an object literal.
     *
     * Alias of {@link module:Dinero~toObject toObject}.
     * It is defined so that calling `JSON.stringify` on a Dinero object will automatically extract the relevant data.
     *
     * @example
     * // returns '{"amount":500,"currency":"EUR","precision":2}'
     * JSON.stringify(Dinero({ amount: 500, currency: 'EUR', precision: 2 }))
     *
     * @return {Object}
     */
    toJSON: function() {
      return this.toObject();
    }
  };
}, b = Object.assign(mt, Z, J, tt), S = /* @__PURE__ */ ((t) => (t.PRODUCT_PRICE = "PRODUCT_PRICE", t.PRODUCT_VARIANT_PRICE = "PRODUCT_VARIANT_PRICE", t.PRODUCT_ORDER_FROM = "PRODUCT_ORDER_FROM", t.PRODUCT_NAME = "PRODUCT_NAME", t.PRODUCT_SCHEDULE = "PRODUCT_SCHEDULE", t.PRODUCT_SCHEDULE_PRICE = "PRODUCT_SCHEDULE_PRICE", t.PRODUCT_CODE = "PRODUCT_CODE", t.PRODUCT_VARIANT_CODE = "PRODUCT_VARIANT_CODE", t.PRODUCT_VARIANT_SCHEDULE_PRICE = "PRODUCT_VARIANT_SCHEDULE_PRICE", t.ADDON_AVAILABLE = "ADDON_AVAILABLE", t.ADDON_NAME = "ADDON_NAME", t.ADDON_PRICE = "ADDON_PRICE", t.ADDON_VARIANT_PRICE = "ADDON_VARIANT_PRICE", t.ADDON_ORDER_FROM = "ADDON_ORDER_FROM", t))(S || {});
function h(t) {
  return t = t.split("/").map((i) => {
    const n = i.split("_");
    return n.length === 1 ? $(n[0]) : n.length === 2 ? (n[0] = $(n[0]), n.join("_")) : (n[1] = $(n[1]), n.join("_"));
  }).join("/"), t;
}
function T(t) {
  return t ? (t = t.split("/").map((i) => {
    const n = i.split("_");
    return n.length === 1 ? E(n[0]) : n.length === 2 ? (n[0] = E(n[0]), n.join("_")) : (n[1] = E(n[1]), n.join("_"));
  }).join("/"), t) : "";
}
function $(t) {
  return parseInt(`${new Date(t).getTime()}`).toString(36);
}
function E(t) {
  return new Date(parseInt(t, 36)).toISOString();
}
function gt(t, i = !1) {
  let n = [];
  return t.subModule.product.forEach((e) => {
    var u;
    const r = t.subModule.category.find((p) => p._id === e.category), a = [];
    e.addonGroupUsed.forEach((p) => {
      const g = t.subModule.addonGroup.find((_) => _._id === p);
      a.push(`${g == null ? void 0 : g.name} (${h((g == null ? void 0 : g._id) ?? "")})`);
    }), n.push({
      _id: h(e._id),
      code: e.code || "",
      name: e.name,
      variantKey: "",
      variant: "",
      vcStatus: "",
      price: b(e.price).toFormat("0.00"),
      perXUnit: e.unit ? ((u = e.perXUnit) == null ? void 0 : u.toString()) ?? "" : "",
      unit: e.unit || "",
      categoryName: (r == null ? void 0 : r.name) ?? "",
      description: e.description || "",
      addonGroup: a.join(" || ")
    }), e.variantCombination.length > 0 && e.variantCombination.forEach((p) => {
      var g;
      n.push({
        _id: h(e._id),
        code: p.code || "",
        name: e.name,
        variantKey: h(p.combinationKey),
        variant: p.selectionName.join("/"),
        vcStatus: p.active ? "active" : "inactive",
        price: p.price ? b(p.price).toFormat("0.00") : b(e.price).toFormat("0.00"),
        perXUnit: e.unit ? ((g = e.perXUnit) == null ? void 0 : g.toString()) ?? "" : "",
        unit: e.unit || "",
        categoryName: (r == null ? void 0 : r.name) ?? "",
        description: e.description || "",
        addonGroup: a.join(" || ")
      });
    });
  }), n = n.map((e) => {
    let r = {};
    const a = t.subModule.product.find((u) => h(u._id) === e._id);
    return (t.subModule.catalog || []).forEach((u) => {
      var p, g, _, M;
      if (u.productAvailable.includes((a == null ? void 0 : a._id) ?? "")) {
        const f = e.variantKey, v = f ? (p = u.override.product[(a == null ? void 0 : a._id) ?? ""]) == null ? void 0 : p.find(
          (m) => m.combinationKey === T(e.variantKey) && m.type == S.PRODUCT_VARIANT_PRICE
        ) : null, c = (g = u.override.product[(a == null ? void 0 : a._id) ?? ""]) == null ? void 0 : g.find(
          (m) => m.type === S.PRODUCT_PRICE
        ), o = f ? (_ = u.override.product[(a == null ? void 0 : a._id) ?? ""]) == null ? void 0 : _.find(
          (m) => m.combinationKey === T(e.variantKey) && m.type == S.PRODUCT_VARIANT_CODE
        ) : null, s = (M = u.override.product[(a == null ? void 0 : a._id) ?? ""]) == null ? void 0 : M.find(
          (m) => m.type === S.PRODUCT_CODE
        ), l = f ? a == null ? void 0 : a.variantCombination.find(
          (m) => m.combinationKey === T(e.variantKey)
        ) : null;
        f && v ? r = {
          ...r,
          [`${u.name} (${h(u._id)})`]: b(
            v.value
          ).toFormat("0.00")
        } : f && !v && (l != null && l.price) ? r = {
          ...r,
          [`${u.name} (${h(u._id)})`]: b(
            l.price
          ).toFormat("0.00")
        } : f && !v && !(l != null && l.price) && c ? r = {
          ...r,
          [`${u.name} (${h(u._id)})`]: b(
            c.value
          ).toFormat("0.00")
        } : f && !v && !(l != null && l.price) && !c ? r = {
          ...r,
          [`${u.name} (${h(u._id)})`]: e.price
        } : !f && c ? r = {
          ...r,
          [`${u.name} (${h(u._id)})`]: b(
            c.value
          ).toFormat("0.00")
        } : r = {
          ...r,
          [`${u.name} (${h(u._id)})`]: e.price
        }, o ? r = {
          ...r,
          [`${u.name} (${h(u._id)})`]: `${r[`${u.name} (${h(u._id)})`]} , ${o.value}`
        } : s ? r = {
          ...r,
          [`${u.name} (${h(u._id)})`]: `${r[`${u.name} (${h(u._id)})`]} , ${s.value}`
        } : r = {
          ...r,
          [`${u.name} (${h(u._id)})`]: `${r[`${u.name} (${h(u._id)})`]} , ${e.code}`
        };
      } else
        r = {
          ...r,
          [`${u.name} (${h(u._id)})`]: "N/A"
        };
    }), { ...e, ...r };
  }), n;
}
function yt(t) {
  const i = gt(t);
  let n = C.json_to_sheet(i, {
    header: [
      "_id",
      "code",
      "name",
      "variantKey",
      "variant",
      "vcStatus",
      "price",
      "perXUnit",
      "unit",
      "categoryName",
      "description",
      "addonGroup"
    ]
  });
  if (i.length > 0) {
    const r = ft(n);
    n = K(n, i), n["!merges"] = [C.decode_range(`M1:${r}1`)];
  } else
    n = K(n);
  let e = C.book_new();
  return C.book_append_sheet(e, n, "sheet 1"), e = ht(e), e;
}
function ft(t) {
  const i = Object.keys(t).filter((e) => {
    if (e.length === 2 && e.endsWith("2"))
      return e;
    if (e.length === 3 && !Number(e[1]) && e.endsWith("2"))
      return e;
  }), n = i[i.length - 1];
  return n.substring(0, n.length - 1);
}
function K(t, i) {
  const n = C.sheet_to_json(t, {
    header: 1
  });
  if (n.splice(0, 0, [
    "System ID for product (Do not modify!)",
    "Order code for customer and kitchen display purpose ",
    "Product name for display purpose",
    "System ID for product variant (Do not modify!)",
    "Variant for display purpose, empty mean no variant (Do not modify, will be ignored when import)",
    "Status for product variant (active/inactive)",
    "Price for product with variant",
    "Price of product per unit, should not empty if unit is not empty (Do not modify, will be ignored when import)",
    "If product can be sold by other measurement, eg: Gram (Do not modify, will be ignored when import)",
    "Category product belong to ",
    "Product description for display purpose",
    "(Do not modify, will be ignored when import)"
  ]), i) {
    const e = Object.keys(i[0]);
    n.splice(1, 1, [...e]);
  }
  return C.aoa_to_sheet(n);
}
function ht(t) {
  for (const i of Object.keys(t.Sheets["sheet 1"])) {
    const n = t.Sheets["sheet 1"][i];
    n.t === "n" && (n.z = "0.00");
  }
  return t;
}
export {
  yt as m
};
