UNPKG

@ordercloud/react-sdk

Version:

This is a developer library for OrderCloud developers utilizing React for their frontend development. It is essentially a wrapper for Tanstack query, which provides a lot of good functionality out of the box for background refreshes, request de-duplicatio

1,510 lines (1,508 loc) 963 kB
import * as To from "react"; import gr, { createContext as ZR, useRef as eP, useCallback as er, useMemo as ct, useState as to, useEffect as cu, useContext as tP } from "react"; import { Configuration as rP, Tokens as Zt, Auth as fl, Cart as Lr, Orders as Km, IntegrationEvents as ll } from "ordercloud-javascript-sdk"; import { QueryClientProvider as nP, IsRestoringProvider as iP, QueryClient as oP, keepPreviousData as sP, useQuery as Mb, useMutation as aP } from "@tanstack/react-query"; import { createColumnHelper as uP } from "@tanstack/react-table"; var vt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; function Ou(e) { return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e; } function Bb(e) { if (Object.prototype.hasOwnProperty.call(e, "__esModule")) return e; var t = e.default; if (typeof t == "function") { var r = function i() { return this instanceof i ? Reflect.construct(t, arguments, this.constructor) : t.apply(this, arguments); }; r.prototype = t.prototype; } else r = {}; return Object.defineProperty(r, "__esModule", { value: !0 }), Object.keys(e).forEach(function(i) { var a = Object.getOwnPropertyDescriptor(e, i); Object.defineProperty(r, i, a.get ? a : { enumerable: !0, get: function() { return e[i]; } }); }), r; } function fP(e) { return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e; } var Ub = { exports: {} }, Lt = Ub.exports = {}, cn, dn; function qd() { throw new Error("setTimeout has not been defined"); } function Nd() { throw new Error("clearTimeout has not been defined"); } (function() { try { typeof setTimeout == "function" ? cn = setTimeout : cn = qd; } catch { cn = qd; } try { typeof clearTimeout == "function" ? dn = clearTimeout : dn = Nd; } catch { dn = Nd; } })(); function Vb(e) { if (cn === setTimeout) return setTimeout(e, 0); if ((cn === qd || !cn) && setTimeout) return cn = setTimeout, setTimeout(e, 0); try { return cn(e, 0); } catch { try { return cn.call(null, e, 0); } catch { return cn.call(this, e, 0); } } } function lP(e) { if (dn === clearTimeout) return clearTimeout(e); if ((dn === Nd || !dn) && clearTimeout) return dn = clearTimeout, clearTimeout(e); try { return dn(e); } catch { try { return dn.call(null, e); } catch { return dn.call(this, e); } } } var Nn = [], io = !1, _i, tu = -1; function cP() { !io || !_i || (io = !1, _i.length ? Nn = _i.concat(Nn) : tu = -1, Nn.length && Hb()); } function Hb() { if (!io) { var e = Vb(cP); io = !0; for (var t = Nn.length; t; ) { for (_i = Nn, Nn = []; ++tu < t; ) _i && _i[tu].run(); tu = -1, t = Nn.length; } _i = null, io = !1, lP(e); } } Lt.nextTick = function(e) { var t = new Array(arguments.length - 1); if (arguments.length > 1) for (var r = 1; r < arguments.length; r++) t[r - 1] = arguments[r]; Nn.push(new Wb(e, t)), Nn.length === 1 && !io && Vb(Hb); }; function Wb(e, t) { this.fun = e, this.array = t; } Wb.prototype.run = function() { this.fun.apply(null, this.array); }; Lt.title = "browser"; Lt.browser = !0; Lt.env = {}; Lt.argv = []; Lt.version = ""; Lt.versions = {}; function Ln() { } Lt.on = Ln; Lt.addListener = Ln; Lt.once = Ln; Lt.off = Ln; Lt.removeListener = Ln; Lt.removeAllListeners = Ln; Lt.emit = Ln; Lt.prependListener = Ln; Lt.prependOnceListener = Ln; Lt.listeners = function(e) { return []; }; Lt.binding = function(e) { throw new Error("process.binding is not supported"); }; Lt.cwd = function() { return "/"; }; Lt.chdir = function(e) { throw new Error("process.chdir is not supported"); }; Lt.umask = function() { return 0; }; var dP = Ub.exports; const Ke = /* @__PURE__ */ fP(dP); var Us = { exports: {} }, Io = {}; /** * @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 Gm; function pP() { if (Gm) return Io; Gm = 1; var e = gr, t = Symbol.for("react.element"), r = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, a = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 }; function u(f, c, d) { var l, g = {}, $ = null, w = null; d !== void 0 && ($ = "" + d), c.key !== void 0 && ($ = "" + c.key), c.ref !== void 0 && (w = c.ref); for (l in c) i.call(c, l) && !s.hasOwnProperty(l) && (g[l] = c[l]); if (f && f.defaultProps) for (l in c = f.defaultProps, c) g[l] === void 0 && (g[l] = c[l]); return { $$typeof: t, type: f, key: $, ref: w, props: g, _owner: a.current }; } return Io.Fragment = r, Io.jsx = u, Io.jsxs = u, Io; } var Co = {}, Jm; function hP() { return Jm || (Jm = 1, Ke.env.NODE_ENV !== "production" && function() { var e = gr, t = Symbol.for("react.element"), r = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), a = Symbol.for("react.strict_mode"), s = Symbol.for("react.profiler"), u = Symbol.for("react.provider"), f = Symbol.for("react.context"), c = Symbol.for("react.forward_ref"), d = Symbol.for("react.suspense"), l = Symbol.for("react.suspense_list"), g = Symbol.for("react.memo"), $ = Symbol.for("react.lazy"), w = Symbol.for("react.offscreen"), v = Symbol.iterator, x = "@@iterator"; function y(ae) { if (ae === null || typeof ae != "object") return null; var je = v && ae[v] || ae[x]; return typeof je == "function" ? je : null; } var h = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; function p(ae) { { for (var je = arguments.length, Ve = new Array(je > 1 ? je - 1 : 0), Je = 1; Je < je; Je++) Ve[Je - 1] = arguments[Je]; b("error", ae, Ve); } } function b(ae, je, Ve) { { var Je = h.ReactDebugCurrentFrame, pt = Je.getStackAddendum(); pt !== "" && (je += "%s", Ve = Ve.concat([pt])); var mt = Ve.map(function(ot) { return String(ot); }); mt.unshift("Warning: " + je), Function.prototype.apply.call(console[ae], console, mt); } } var P = !1, _ = !1, I = !1, C = !1, U = !1, Y; Y = Symbol.for("react.module.reference"); function te(ae) { return !!(typeof ae == "string" || typeof ae == "function" || ae === i || ae === s || U || ae === a || ae === d || ae === l || C || ae === w || P || _ || I || typeof ae == "object" && ae !== null && (ae.$$typeof === $ || ae.$$typeof === g || ae.$$typeof === u || ae.$$typeof === f || ae.$$typeof === c || // This needs to include all possible module reference object // types supported by any Flight configuration anywhere since // we don't know which Flight build this will end up being used // with. ae.$$typeof === Y || ae.getModuleId !== void 0)); } function pe(ae, je, Ve) { var Je = ae.displayName; if (Je) return Je; var pt = je.displayName || je.name || ""; return pt !== "" ? Ve + "(" + pt + ")" : Ve; } function se(ae) { return ae.displayName || "Context"; } function _e(ae) { if (ae == null) return null; if (typeof ae.tag == "number" && p("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof ae == "function") return ae.displayName || ae.name || null; if (typeof ae == "string") return ae; switch (ae) { case i: return "Fragment"; case r: return "Portal"; case s: return "Profiler"; case a: return "StrictMode"; case d: return "Suspense"; case l: return "SuspenseList"; } if (typeof ae == "object") switch (ae.$$typeof) { case f: var je = ae; return se(je) + ".Consumer"; case u: var Ve = ae; return se(Ve._context) + ".Provider"; case c: return pe(ae, ae.render, "ForwardRef"); case g: var Je = ae.displayName || null; return Je !== null ? Je : _e(ae.type) || "Memo"; case $: { var pt = ae, mt = pt._payload, ot = pt._init; try { return _e(ot(mt)); } catch { return null; } } } return null; } var ge = Object.assign, Ce = 0, Be, $e, we, Me, ue, ee, K; function V() { } V.__reactDisabledLog = !0; function q() { { if (Ce === 0) { Be = console.log, $e = console.info, we = console.warn, Me = console.error, ue = console.group, ee = console.groupCollapsed, K = console.groupEnd; var ae = { configurable: !0, enumerable: !0, value: V, writable: !0 }; Object.defineProperties(console, { info: ae, log: ae, warn: ae, error: ae, group: ae, groupCollapsed: ae, groupEnd: ae }); } Ce++; } } function G() { { if (Ce--, Ce === 0) { var ae = { configurable: !0, enumerable: !0, writable: !0 }; Object.defineProperties(console, { log: ge({}, ae, { value: Be }), info: ge({}, ae, { value: $e }), warn: ge({}, ae, { value: we }), error: ge({}, ae, { value: Me }), group: ge({}, ae, { value: ue }), groupCollapsed: ge({}, ae, { value: ee }), groupEnd: ge({}, ae, { value: K }) }); } Ce < 0 && p("disabledDepth fell below zero. This is a bug in React. Please file an issue."); } } var H = h.ReactCurrentDispatcher, Z; function oe(ae, je, Ve) { { if (Z === void 0) try { throw Error(); } catch (pt) { var Je = pt.stack.trim().match(/\n( *(at )?)/); Z = Je && Je[1] || ""; } return ` ` + Z + ae; } } var ve = !1, Ee; { var D = typeof WeakMap == "function" ? WeakMap : Map; Ee = new D(); } function N(ae, je) { if (!ae || ve) return ""; { var Ve = Ee.get(ae); if (Ve !== void 0) return Ve; } var Je; ve = !0; var pt = Error.prepareStackTrace; Error.prepareStackTrace = void 0; var mt; mt = H.current, H.current = null, q(); try { if (je) { var ot = function() { throw Error(); }; if (Object.defineProperty(ot.prototype, "props", { set: function() { throw Error(); } }), typeof Reflect == "object" && Reflect.construct) { try { Reflect.construct(ot, []); } catch (Ut) { Je = Ut; } Reflect.construct(ae, [], ot); } else { try { ot.call(); } catch (Ut) { Je = Ut; } ae.call(ot.prototype); } } else { try { throw Error(); } catch (Ut) { Je = Ut; } ae(); } } catch (Ut) { if (Ut && Je && typeof Ut.stack == "string") { for (var Ze = Ut.stack.split(` `), Ct = Je.stack.split(` `), At = Ze.length - 1, Rt = Ct.length - 1; At >= 1 && Rt >= 0 && Ze[At] !== Ct[Rt]; ) Rt--; for (; At >= 1 && Rt >= 0; At--, Rt--) if (Ze[At] !== Ct[Rt]) { if (At !== 1 || Rt !== 1) do if (At--, Rt--, Rt < 0 || Ze[At] !== Ct[Rt]) { var lr = ` ` + Ze[At].replace(" at new ", " at "); return ae.displayName && lr.includes("<anonymous>") && (lr = lr.replace("<anonymous>", ae.displayName)), typeof ae == "function" && Ee.set(ae, lr), lr; } while (At >= 1 && Rt >= 0); break; } } } finally { ve = !1, H.current = mt, G(), Error.prepareStackTrace = pt; } var Hr = ae ? ae.displayName || ae.name : "", $n = Hr ? oe(Hr) : ""; return typeof ae == "function" && Ee.set(ae, $n), $n; } function re(ae, je, Ve) { return N(ae, !1); } function ce(ae) { var je = ae.prototype; return !!(je && je.isReactComponent); } function Oe(ae, je, Ve) { if (ae == null) return ""; if (typeof ae == "function") return N(ae, ce(ae)); if (typeof ae == "string") return oe(ae); switch (ae) { case d: return oe("Suspense"); case l: return oe("SuspenseList"); } if (typeof ae == "object") switch (ae.$$typeof) { case c: return re(ae.render); case g: return Oe(ae.type, je, Ve); case $: { var Je = ae, pt = Je._payload, mt = Je._init; try { return Oe(mt(pt), je, Ve); } catch { } } } return ""; } var M = Object.prototype.hasOwnProperty, F = {}, R = h.ReactDebugCurrentFrame; function k(ae) { if (ae) { var je = ae._owner, Ve = Oe(ae.type, ae._source, je ? je.type : null); R.setExtraStackFrame(Ve); } else R.setExtraStackFrame(null); } function J(ae, je, Ve, Je, pt) { { var mt = Function.call.bind(M); for (var ot in ae) if (mt(ae, ot)) { var Ze = void 0; try { if (typeof ae[ot] != "function") { var Ct = Error((Je || "React class") + ": " + Ve + " type `" + ot + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof ae[ot] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."); throw Ct.name = "Invariant Violation", Ct; } Ze = ae[ot](je, ot, Je, Ve, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); } catch (At) { Ze = At; } Ze && !(Ze instanceof Error) && (k(pt), p("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", Je || "React class", Ve, ot, typeof Ze), k(null)), Ze instanceof Error && !(Ze.message in F) && (F[Ze.message] = !0, k(pt), p("Failed %s type: %s", Ve, Ze.message), k(null)); } } } var fe = Array.isArray; function de(ae) { return fe(ae); } function Se(ae) { { var je = typeof Symbol == "function" && Symbol.toStringTag, Ve = je && ae[Symbol.toStringTag] || ae.constructor.name || "Object"; return Ve; } } function S(ae) { try { return ie(ae), !1; } catch { return !0; } } function ie(ae) { return "" + ae; } function be(ae) { if (S(ae)) return p("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Se(ae)), ie(ae); } var Ae = h.ReactCurrentOwner, xe = { key: !0, ref: !0, __self: !0, __source: !0 }, Le, A; function E(ae) { if (M.call(ae, "ref")) { var je = Object.getOwnPropertyDescriptor(ae, "ref").get; if (je && je.isReactWarning) return !1; } return ae.ref !== void 0; } function O(ae) { if (M.call(ae, "key")) { var je = Object.getOwnPropertyDescriptor(ae, "key").get; if (je && je.isReactWarning) return !1; } return ae.key !== void 0; } function B(ae, je) { typeof ae.ref == "string" && Ae.current; } function Q(ae, je) { { var Ve = function() { Le || (Le = !0, p("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", je)); }; Ve.isReactWarning = !0, Object.defineProperty(ae, "key", { get: Ve, configurable: !0 }); } } function j(ae, je) { { var Ve = function() { A || (A = !0, p("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", je)); }; Ve.isReactWarning = !0, Object.defineProperty(ae, "ref", { get: Ve, configurable: !0 }); } } var W = function(ae, je, Ve, Je, pt, mt, ot) { var Ze = { // This tag allows us to uniquely identify this as a React Element $$typeof: t, // Built-in properties that belong on the element type: ae, key: je, ref: Ve, props: ot, // Record the component responsible for creating this element. _owner: mt }; return Ze._store = {}, Object.defineProperty(Ze._store, "validated", { configurable: !1, enumerable: !1, writable: !0, value: !1 }), Object.defineProperty(Ze, "_self", { configurable: !1, enumerable: !1, writable: !1, value: Je }), Object.defineProperty(Ze, "_source", { configurable: !1, enumerable: !1, writable: !1, value: pt }), Object.freeze && (Object.freeze(Ze.props), Object.freeze(Ze)), Ze; }; function me(ae, je, Ve, Je, pt) { { var mt, ot = {}, Ze = null, Ct = null; Ve !== void 0 && (be(Ve), Ze = "" + Ve), O(je) && (be(je.key), Ze = "" + je.key), E(je) && (Ct = je.ref, B(je, pt)); for (mt in je) M.call(je, mt) && !xe.hasOwnProperty(mt) && (ot[mt] = je[mt]); if (ae && ae.defaultProps) { var At = ae.defaultProps; for (mt in At) ot[mt] === void 0 && (ot[mt] = At[mt]); } if (Ze || Ct) { var Rt = typeof ae == "function" ? ae.displayName || ae.name || "Unknown" : ae; Ze && Q(ot, Rt), Ct && j(ot, Rt); } return W(ae, Ze, Ct, pt, Je, Ae.current, ot); } } var Te = h.ReactCurrentOwner, Ne = h.ReactDebugCurrentFrame; function Fe(ae) { if (ae) { var je = ae._owner, Ve = Oe(ae.type, ae._source, je ? je.type : null); Ne.setExtraStackFrame(Ve); } else Ne.setExtraStackFrame(null); } var Ge; Ge = !1; function yt(ae) { return typeof ae == "object" && ae !== null && ae.$$typeof === t; } function zt() { { if (Te.current) { var ae = _e(Te.current.type); if (ae) return ` Check the render method of \`` + ae + "`."; } return ""; } } function Or(ae) { return ""; } var Mn = {}; function on(ae) { { var je = zt(); if (!je) { var Ve = typeof ae == "string" ? ae : ae.displayName || ae.name; Ve && (je = ` Check the top-level render call using <` + Ve + ">."); } return je; } } function Jt(ae, je) { { if (!ae._store || ae._store.validated || ae.key != null) return; ae._store.validated = !0; var Ve = on(je); if (Mn[Ve]) return; Mn[Ve] = !0; var Je = ""; ae && ae._owner && ae._owner !== Te.current && (Je = " It was passed a child from " + _e(ae._owner.type) + "."), Fe(ae), p('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', Ve, Je), Fe(null); } } function oi(ae, je) { { if (typeof ae != "object") return; if (de(ae)) for (var Ve = 0; Ve < ae.length; Ve++) { var Je = ae[Ve]; yt(Je) && Jt(Je, je); } else if (yt(ae)) ae._store && (ae._store.validated = !0); else if (ae) { var pt = y(ae); if (typeof pt == "function" && pt !== ae.entries) for (var mt = pt.call(ae), ot; !(ot = mt.next()).done; ) yt(ot.value) && Jt(ot.value, je); } } } function Pi(ae) { { var je = ae.type; if (je == null || typeof je == "string") return; var Ve; if (typeof je == "function") Ve = je.propTypes; else if (typeof je == "object" && (je.$$typeof === c || // Note: Memo only checks outer props here. // Inner props are checked in the reconciler. je.$$typeof === g)) Ve = je.propTypes; else return; if (Ve) { var Je = _e(je); J(Ve, ae.props, "prop", Je, ae); } else if (je.PropTypes !== void 0 && !Ge) { Ge = !0; var pt = _e(je); p("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", pt || "Unknown"); } typeof je.getDefaultProps == "function" && !je.getDefaultProps.isReactClassApproved && p("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead."); } } function Oi(ae) { { for (var je = Object.keys(ae.props), Ve = 0; Ve < je.length; Ve++) { var Je = je[Ve]; if (Je !== "children" && Je !== "key") { Fe(ae), p("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", Je), Fe(null); break; } } ae.ref !== null && (Fe(ae), p("Invalid attribute `ref` supplied to `React.Fragment`."), Fe(null)); } } var Tr = {}; function Bn(ae, je, Ve, Je, pt, mt) { { var ot = te(ae); if (!ot) { var Ze = ""; (ae === void 0 || typeof ae == "object" && ae !== null && Object.keys(ae).length === 0) && (Ze += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."); var Ct = Or(); Ct ? Ze += Ct : Ze += zt(); var At; ae === null ? At = "null" : de(ae) ? At = "array" : ae !== void 0 && ae.$$typeof === t ? (At = "<" + (_e(ae.type) || "Unknown") + " />", Ze = " Did you accidentally export a JSX literal instead of a component?") : At = typeof ae, p("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", At, Ze); } var Rt = me(ae, je, Ve, pt, mt); if (Rt == null) return Rt; if (ot) { var lr = je.children; if (lr !== void 0) if (Je) if (de(lr)) { for (var Hr = 0; Hr < lr.length; Hr++) oi(lr[Hr], ae); Object.freeze && Object.freeze(lr); } else p("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."); else oi(lr, ae); } if (M.call(je, "key")) { var $n = _e(ae), Ut = Object.keys(je).filter(function(Xu) { return Xu !== "key"; }), ho = Ut.length > 0 ? "{key: someKey, " + Ut.join(": ..., ") + ": ...}" : "{key: someKey}"; if (!Tr[$n + ho]) { var Yu = Ut.length > 0 ? "{" + Ut.join(": ..., ") + ": ...}" : "{}"; p(`A props object containing a "key" prop is being spread into JSX: let props = %s; <%s {...props} /> React keys must be passed directly to JSX without using spread: let props = %s; <%s key={someKey} {...props} />`, ho, $n, Yu, $n), Tr[$n + ho] = !0; } } return ae === i ? Oi(Rt) : Pi(Rt), Rt; } } function sn(ae, je, Ve) { return Bn(ae, je, Ve, !0); } function si(ae, je, Ve) { return Bn(ae, je, Ve, !1); } var ai = si, Ti = sn; Co.Fragment = i, Co.jsx = ai, Co.jsxs = Ti; }()), Co; } var Ym; function mP() { return Ym || (Ym = 1, Ke.env.NODE_ENV === "production" ? Us.exports = pP() : Us.exports = hP()), Us.exports; } var du = mP(); function zb(e) { return e; } function yP(e) { return { mutationKey: e.options.mutationKey, state: e.state, ...e.options.scope && { scope: e.options.scope }, ...e.meta && { meta: e.meta } }; } function gP(e, t) { var r; return { state: { ...e.state, ...e.state.data !== void 0 && { data: t(e.state.data) } }, queryKey: e.queryKey, queryHash: e.queryHash, ...e.state.status === "pending" && { promise: (r = e.promise) == null ? void 0 : r.then(t).catch((i) => (Ke.env.NODE_ENV !== "production" && console.error( `A query that was dehydrated as pending ended up rejecting. [${e.queryHash}]: ${i}; The error will be redacted in production builds` ), Promise.reject(new Error("redacted")))) }, ...e.meta && { meta: e.meta } }; } function vP(e) { return e.state.isPaused; } function bP(e) { return e.state.status === "success"; } function wP(e, t = {}) { var f, c, d; const r = t.shouldDehydrateMutation ?? ((f = e.getDefaultOptions().dehydrate) == null ? void 0 : f.shouldDehydrateMutation) ?? vP, i = e.getMutationCache().getAll().flatMap( (l) => r(l) ? [yP(l)] : [] ), a = t.shouldDehydrateQuery ?? ((c = e.getDefaultOptions().dehydrate) == null ? void 0 : c.shouldDehydrateQuery) ?? bP, s = t.serializeData ?? ((d = e.getDefaultOptions().dehydrate) == null ? void 0 : d.serializeData) ?? zb, u = e.getQueryCache().getAll().flatMap( (l) => a(l) ? [gP(l, s)] : [] ); return { mutations: i, queries: u }; } function _P(e, t, r) { var c, d; if (typeof t != "object" || t === null) return; const i = e.getMutationCache(), a = e.getQueryCache(), s = ((c = r == null ? void 0 : r.defaultOptions) == null ? void 0 : c.deserializeData) ?? ((d = e.getDefaultOptions().hydrate) == null ? void 0 : d.deserializeData) ?? zb, u = t.mutations || [], f = t.queries || []; u.forEach(({ state: l, ...g }) => { var $, w; i.build( e, { ...($ = e.getDefaultOptions().hydrate) == null ? void 0 : $.mutations, ...(w = r == null ? void 0 : r.defaultOptions) == null ? void 0 : w.mutations, ...g }, l ); }), f.forEach(({ queryKey: l, state: g, queryHash: $, meta: w, promise: v }) => { var h, p; let x = a.get($); const y = g.data === void 0 ? g.data : s(g.data); if (x) { if (x.state.dataUpdatedAt < g.dataUpdatedAt) { const { fetchStatus: b, ...P } = g; x.setState({ ...P, data: y }); } } else x = a.build( e, { ...(h = e.getDefaultOptions().hydrate) == null ? void 0 : h.queries, ...(p = r == null ? void 0 : r.defaultOptions) == null ? void 0 : p.queries, queryKey: l, queryHash: $, meta: w }, // Reset fetch status to idle to avoid // query being stuck in fetching state upon hydration { ...g, data: y, fetchStatus: "idle" } ); if (v) { const b = Promise.resolve(v).then(s); x.fetch(void 0, { initialPromise: b }); } }); } var $P = ["added", "removed", "updated"]; function Xm(e) { return $P.includes(e); } async function EP({ queryClient: e, persister: t, maxAge: r = 1e3 * 60 * 60 * 24, buster: i = "", hydrateOptions: a }) { try { const s = await t.restoreClient(); if (s) if (s.timestamp) { const u = Date.now() - s.timestamp > r, f = s.buster !== i; u || f ? t.removeClient() : _P(e, s.clientState, a); } else t.removeClient(); } catch (s) { Ke.env.NODE_ENV !== "production" && (console.error(s), console.warn( "Encountered an error attempting to restore client cache from persisted location. As a precaution, the persisted cache will be discarded." )), t.removeClient(); } } async function Qm({ queryClient: e, persister: t, buster: r = "", dehydrateOptions: i }) { const a = { buster: r, timestamp: Date.now(), clientState: wP(e, i) }; await t.persistClient(a); } function SP(e) { const t = e.queryClient.getQueryCache().subscribe((i) => { Xm(i.type) && Qm(e); }), r = e.queryClient.getMutationCache().subscribe((i) => { Xm(i.type) && Qm(e); }); return () => { t(), r(); }; } var xP = ({ client: e, children: t, persistOptions: r, onSuccess: i, ...a }) => { const [s, u] = To.useState(!0), f = To.useRef({ persistOptions: r, onSuccess: i }), c = To.useRef(!1); return To.useEffect(() => { f.current = { persistOptions: r, onSuccess: i }; }), To.useEffect(() => { const d = { ...f.current.persistOptions, queryClient: e }; return c.current || (c.current = !0, EP(d).then(async () => { var l, g; try { await ((g = (l = f.current).onSuccess) == null ? void 0 : g.call(l)); } finally { u(!1); } })), s ? void 0 : SP(d); }, [e, s]), /* @__PURE__ */ du.jsx(nP, { client: e, ...a, children: /* @__PURE__ */ du.jsx(iP, { value: s, children: t }) }); }; const AP = { isAuthenticated: !1, isLoggedIn: !1, logout: () => { }, login: async (e, t, r) => Promise.reject({ username: e, password: t, rememberMe: r }), loginWithOpenIdConnect: (e) => { throw new Error( `loginWithOpenIdConnect is not implemented. ${e}` ); }, setToken: async (e) => Promise.reject({ accessToken: e }), newAnonSession: async () => Promise.reject(), baseApiUrl: "https://api.ordercloud.io/v1", clientId: "", allowAnonymous: !1, token: void 0, autoApplyPromotions: !1, xpSchemas: {}, authLoading: !0, currencyDefaults: {} }, Kb = ZR( AP ); function jd() { } function RP(e, { interval: t = 1e3, onError: r = jd } = {}) { if (typeof e != "function") throw new Error("argument is not function."); let i = 0, a = null, s = !1, u = !1; return async (...f) => { if (a = f, !u) { for (u = !0; s; ) await new Promise((c) => setTimeout(c, t)); for (; Date.now() < i; ) await new Promise( (c) => setTimeout(c, i - Date.now()) ); u = !1, s = !0; try { await e(...a); } catch (c) { try { r(c); } catch { } } i = Date.now() + t, s = !1; } }; } var PP = ({ storage: e, key: t = "REACT_QUERY_OFFLINE_CACHE", throttleTime: r = 1e3, serialize: i = JSON.stringify, deserialize: a = JSON.parse, retry: s }) => { if (e) { const u = async (f) => { try { const c = await i(f); await e.setItem(t, c); return; } catch (c) { return c; } }; return { persistClient: RP( async (f) => { let c = f, d = await u(c), l = 0; for (; d && c; ) l++, c = await (s == null ? void 0 : s({ persistedClient: c, error: d, errorCount: l })), c && (d = await u(c)); }, { interval: r } ), restoreClient: async () => { const f = await e.getItem(t); if (f) return await a(f); }, removeClient: () => e.removeItem(t) }; } return { persistClient: jd, restoreClient: () => Promise.resolve(void 0), removeClient: jd }; }; class Mo extends Error { } Mo.prototype.name = "InvalidTokenError"; function OP(e) { return decodeURIComponent(atob(e).replace(/(.)/g, (t, r) => { let i = r.charCodeAt(0).toString(16).toUpperCase(); return i.length < 2 && (i = "0" + i), "%" + i; })); } function TP(e) { let t = e.replace(/-/g, "+").replace(/_/g, "/"); switch (t.length % 4) { case 0: break; case 2: t += "=="; break; case 3: t += "="; break; default: throw new Error("base64 string is not of the correct length"); } try { return OP(t); } catch { return atob(t); } } function Zd(e, t) { if (typeof e != "string") throw new Mo("Invalid token specified: must be a string"); t || (t = {}); const r = t.header === !0 ? 0 : 1, i = e.split(".")[r]; if (typeof i != "string") throw new Mo(`Invalid token specified: missing part #${r + 1}`); let a; try { a = TP(i); } catch (s) { throw new Mo(`Invalid token specified: invalid base64 for part #${r + 1} (${s.message})`); } try { return JSON.parse(a); } catch (s) { throw new Mo(`Invalid token specified: invalid json for part #${r + 1} (${s.message})`); } } const QD = (e) => Zd(e), Ld = (e) => !!Zd(e).orderid, IP = (e) => e ? Zd(e).role : void 0, CP = (e, t) => { const { status: r } = t; switch (r) { case 401: case 403: return !1; } return e < 3; }, Gb = (e, t) => e.parameters && e.parameters.filter((r) => r.in === "path").map((r) => r.name).includes(t), ti = (e, t) => { let r = e == null ? void 0 : e.path; if (!r) return ""; const i = t; return r.indexOf("{") > -1 && Object.entries(i).filter(([a]) => Gb(e, a)).forEach(([a, s]) => { s && (r = r.replace(`{${a}}`, s)); }), r; }, Tu = (e) => { if (e) return `${Object.entries(e).filter(([, t]) => typeof t == "object" ? !!t.length || !!Object.values(t).length : !!t).map(([t, r]) => t === "filters" ? Object.entries(r).filter(([i, a]) => i.length && a.length).map(([i, a]) => `${i}=${encodeURIComponent(a)}`).join("&") : typeof r == "object" && (t === "searchOn" || t === "sortBy") ? `${t}=${r.map(encodeURIComponent).join(",")}` : typeof r == "object" ? `${t}=${r.map((i) => encodeURIComponent(i)).join("|")}` : `${t}=${encodeURIComponent(r)}`).join("&")}`; }, FP = (e) => e && (e != null && e.parameters) ? e.parameters.filter((r) => r.in === "path" && r.required).map((r) => r.name) : [], Zr = new oP({ defaultOptions: { queries: { retry: CP } } }), kP = PP({ storage: window.localStorage }), DP = globalThis || void 0 || self; function Jb(e, t) { return function() { return e.apply(t, arguments); }; } const { toString: qP } = Object.prototype, { getPrototypeOf: ep } = Object, { iterator: Iu, toStringTag: Yb } = Symbol, Cu = /* @__PURE__ */ ((e) => (t) => { const r = qP.call(t); return e[r] || (e[r] = r.slice(8, -1).toLowerCase()); })(/* @__PURE__ */ Object.create(null)), en = (e) => (e = e.toLowerCase(), (t) => Cu(t) === e), Fu = (e) => (t) => typeof t === e, { isArray: ao } = Array, Wo = Fu("undefined"); function NP(e) { return e !== null && !Wo(e) && e.constructor !== null && !Wo(e.constructor) && br(e.constructor.isBuffer) && e.constructor.isBuffer(e); } const Xb = en("ArrayBuffer"); function jP(e) { let t; return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? t = ArrayBuffer.isView(e) : t = e && e.buffer && Xb(e.buffer), t; } const LP = Fu("string"), br = Fu("function"), Qb = Fu("number"), ku = (e) => e !== null && typeof e == "object", MP = (e) => e === !0 || e === !1, ru = (e) => { if (Cu(e) !== "object") return !1; const t = ep(e); return (t === null || t === Object.prototype || Object.getPrototypeOf(t) === null) && !(Yb in e) && !(Iu in e); }, BP = en("Date"), UP = en("File"), VP = en("Blob"), HP = en("FileList"), WP = (e) => ku(e) && br(e.pipe), zP = (e) => { let t; return e && (typeof FormData == "function" && e instanceof FormData || br(e.append) && ((t = Cu(e)) === "formdata" || // detect form-data instance t === "object" && br(e.toString) && e.toString() === "[object FormData]")); }, KP = en("URLSearchParams"), [GP, JP, YP, XP] = ["ReadableStream", "Request", "Response", "Headers"].map(en), QP = (e) => e.trim ? e.trim() : e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""); function Ko(e, t, { allOwnKeys: r = !1 } = {}) { if (e === null || typeof e > "u") return; let i, a; if (typeof e != "object" && (e = [e]), ao(e)) for (i = 0, a = e.length; i < a; i++) t.call(null, e[i], i, e); else { const s = r ? Object.getOwnPropertyNames(e) : Object.keys(e), u = s.length; let f; for (i = 0; i < u; i++) f = s[i], t.call(null, e[f], f, e); } } function Zb(e, t) { t = t.toLowerCase(); const r = Object.keys(e); let i = r.length, a; for (; i-- > 0; ) if (a = r[i], t === a.toLowerCase()) return a; return null; } const $i = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : DP, ew = (e) => !Wo(e) && e !== $i; function Md() { const { caseless: e } = ew(this) && this || {}, t = {}, r = (i, a) => { const s = e && Zb(t, a) || a; ru(t[s]) && ru(i) ? t[s] = Md(t[s], i) : ru(i) ? t[s] = Md({}, i) : ao(i) ? t[s] = i.slice() : t[s] = i; }; for (let i = 0, a = arguments.length; i < a; i++) arguments[i] && Ko(arguments[i], r); return t; } const ZP = (e, t, r, { allOwnKeys: i } = {}) => (Ko(t, (a, s) => { r && br(a) ? e[s] = Jb(a, r) : e[s] = a; }, { allOwnKeys: i }), e), eO = (e) => (e.charCodeAt(0) === 65279 && (e = e.slice(1)), e), tO = (e, t, r, i) => { e.prototype = Object.create(t.prototype, i), e.prototype.constructor = e, Object.defineProperty(e, "super", { value: t.prototype }), r && Object.assign(e.prototype, r); }, rO = (e, t, r, i) => { let a, s, u; const f = {}; if (t = t || {}, e == null) return t; do { for (a = Object.getOwnPropertyNames(e), s = a.length; s-- > 0; ) u = a[s], (!i || i(u, e, t)) && !f[u] && (t[u] = e[u], f[u] = !0); e = r !== !1 && ep(e); } while (e && (!r || r(e, t)) && e !== Object.prototype); return t; }, nO = (e, t, r) => { e = String(e), (r === void 0 || r > e.length) && (r = e.length), r -= t.length; const i = e.indexOf(t, r); return i !== -1 && i === r; }, iO = (e) => { if (!e) return null; if (ao(e)) return e; let t = e.length; if (!Qb(t)) return null; const r = new Array(t); for (; t-- > 0; ) r[t] = e[t]; return r; }, oO = /* @__PURE__ */ ((e) => (t) => e && t instanceof e)(typeof Uint8Array < "u" && ep(Uint8Array)), sO = (e, t) => { const i = (e && e[Iu]).call(e); let a; for (; (a = i.next()) && !a.done; ) { const s = a.value; t.call(e, s[0], s[1]); } }, aO = (e, t) => { let r; const i = []; for (; (r = e.exec(t)) !== null; ) i.push(r); return i; }, uO = en("HTMLFormElement"), fO = (e) => e.toLowerCase().replace( /[-_\s]([a-z\d])(\w*)/g, function(r, i, a) { return i.toUpperCase() + a; } ), Zm = (({ hasOwnProperty: e }) => (t, r) => e.call(t, r))(Object.prototype), lO = en("RegExp"), tw = (e, t) => { const r = Object.getOwnPropertyDescriptors(e), i = {}; Ko(r, (a, s) => { let u; (u = t(a, s, e)) !== !1 && (i[s] = u || a); }), Object.defineProperties(e, i); }, cO = (e) => { tw(e, (t, r) => { if (br(e) && ["arguments", "caller", "callee"].indexOf(r) !== -1) return !1; const i = e[r]; if (br(i)) { if (t.enumerable = !1, "writable" in t) { t.writable = !1; return; } t.set || (t.set = () => { throw Error("Can not rewrite read-only method '" + r + "'"); }); } }); }, dO = (e, t) => { const r = {}, i = (a) => { a.forEach((s) => { r[s] = !0; }); }; return ao(e) ? i(e) : i(String(e).split(t)), r; }, pO = () => { }, hO = (e, t) => e != null && Number.isFinite(e = +e) ? e : t; function mO(e) { return !!(e && br(e.append) && e[Yb] === "FormData" && e[Iu]); } const yO = (e) => { const t = new Array(10), r = (i, a) => { if (ku(i)) { if (t.indexOf(i) >= 0) return; if (!("toJSON" in i)) { t[a] = i; const s = ao(i) ? [] : {}; return Ko(i, (u, f) => { const c = r(u, a + 1); !Wo(c) && (s[f] = c); }), t[a] = void 0, s; } } return i; }; return r(e, 0); }, gO = en("AsyncFunction"), vO = (e) => e && (ku(e) || br(e)) && br(e.then) && br(e.catch), rw = ((e, t) => e ? setImmediate : t ? ((r, i) => ($i.addEventListener("message", ({ source: a, data: s }) => { a === $i && s === r && i.length && i.shift()(); }, !1), (a) => { i.push(a), $i.postMessage(r, "*"); }))(`axios@${Math.random()}`, []) : (r) => setTimeout(r))( typeof setImmediate == "function", br($i.postMessage) ), bO = typeof queueMicrotask < "u" ? queueMicrotask.bind($i) : typeof Ke < "u" && Ke.nextTick || rw, wO = (e) => e != null && br(e[Iu]), Pe = { isArray: ao, isArrayBuffer: Xb, isBuffer: NP, isFormData: zP, isArrayBufferView: jP, isString: LP, isNumber: Qb, isBoolean: MP, isObject: ku, isPlainObject: ru, isReadableStream: GP, isRequest: JP, isResponse: YP, isHeaders: XP, isUndefined: Wo, isDate: BP, isFile: UP, isBlob: VP, isRegExp: lO, isFunction: br, isStream: WP, isURLSearchParams: KP, isTypedArray: oO, isFileList: HP, forEach: Ko, merge: Md, extend: ZP, trim: QP, stripBOM: eO, inherits: tO, toFlatObject: rO, kindOf: Cu, kindOfTest: en, endsWith: nO, toArray: iO, forEachEntry: sO, matchAll: aO, isHTMLForm: uO, hasOwnProperty: Zm, hasOwnProp: Zm, // an alias to avoid ESLint no-prototype-builtins detection reduceDescriptors: tw, freezeMethods: cO, toObjectSet: dO, toCamelCase: fO, noop: pO, toFiniteNumber: hO, findKey: Zb, global: $i, isContextDefined: ew, isSpecCompliantForm: mO, toJSONObject: yO, isAsyncFn: gO, isThenable: vO, setImmediate: rw, asap: bO, isIterable: wO }; var nw = {}, Du = {}; Du.byteLength = EO; Du.toByteArray = xO; Du.fromByteArray = PO; var mn = [], Ur = [], _O = typeof Uint8Array < "u" ? Uint8Array : Array, cl = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; for (var Wi = 0, $O = cl.length; Wi < $O; ++Wi) mn[Wi] = cl[Wi], Ur[cl.charCodeAt(Wi)] = Wi; Ur[45] = 62; Ur[95] = 63; function iw(e) { var t = e.length; if (t % 4 > 0) throw new Error("Invalid string. Length must be a multiple of 4"); var r = e.indexOf("="); r === -1 && (r = t); var i = r === t ? 0 : 4 - r % 4; return [r, i]; } function EO(e) { var t = iw(e), r = t[0], i = t[1]; return (r + i) * 3 / 4 - i; } function SO(e, t, r) { return (t + r) * 3 / 4 - r; } function xO(e) { var t, r = iw(e), i = r[0], a = r[1], s = new _O(SO(e, i, a)), u = 0, f = a > 0 ? i - 4 : i, c; for (c = 0; c < f; c += 4) t = Ur[e.charCodeAt(c)] << 18 | Ur[e.charCodeAt(c + 1)] << 12 | Ur[e.charCodeAt(c + 2)] << 6 | Ur[e.charCodeAt(c + 3)], s[u++] = t >> 16 & 255, s[u++] = t >> 8 & 255, s[u++] = t & 255; return a === 2 && (t = Ur[e.charCodeAt(c)] << 2 | Ur[e.charCodeAt(c + 1)] >> 4, s[u++] = t & 255), a === 1 && (t = Ur[e.charCodeAt(c)] << 10 | Ur[e.charCodeAt(c + 1)] << 4 | Ur[e.charCodeAt(c + 2)] >> 2, s[u++] = t >> 8 & 255, s[u++] = t & 255), s; } function AO(e) { return mn[e >> 18 & 63] + mn[e >> 12 & 63] + mn[e >> 6 & 63] + mn[e & 63]; } function RO(e, t, r) { for (var i, a = [], s = t; s < r; s += 3) i = (e[s] << 16 & 16711680) + (e[s + 1] << 8 & 65280) + (e[s + 2] & 255), a.push(AO(i)); return a.join(""); } function PO(e) { for (var t, r = e.length, i = r % 3, a = [], s = 16383, u = 0, f = r - i; u < f; u += s) a.push(RO(e, u, u + s > f ? f : u + s)); return i === 1 ? (t = e[r - 1], a.push( mn[t >> 2] + mn[t << 4 & 63] + "==" )) : i === 2 && (t = (e[r - 2] << 8) + e[r - 1], a.push( mn[t >> 10] + mn[t >> 4 & 63] + mn[t << 2 & 63] + "=" )), a.join(""); } var tp = {}; /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ tp.read = function(e, t, r, i, a) { var s, u, f = a * 8 - i - 1, c = (1 << f) - 1, d = c >> 1, l = -7, g = r ? a - 1 : 0, $ = r ? -1 : 1, w = e[t + g]; for (g += $, s = w & (1 << -l) - 1, w >>= -l, l += f; l > 0; s = s * 256 + e[t + g], g += $, l -= 8) ; for (u = s & (1 << -l) - 1, s >>= -l, l += i; l > 0; u = u * 256 + e[t + g], g += $, l -= 8) ; if (s === 0) s = 1 - d; else { if (s === c) return u ? NaN : (w ? -1 : 1) * (1 / 0); u = u + Math.pow(2, i), s = s - d; } return (w ? -1 : 1) * u * Math.pow(2, s - i); }; tp.write = function(e, t, r, i, a, s) { var u, f, c, d = s * 8 - a - 1, l = (1 << d) - 1, g = l >> 1, $ = a === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, w = i ? 0 : s - 1, v = i ? 1 : -1, x = t < 0 || t === 0 && 1 / t < 0 ? 1 : 0; for (t = Math.abs(t), isNaN(t) || t === 1 / 0 ? (f = isNaN(t) ? 1 : 0, u = l) : (u = Math.floor(Math.log(t) / Math.LN2), t * (c = Math.pow(2, -u)) < 1 && (u--, c *= 2), u + g >= 1 ? t += $ / c : t += $ * Math.pow(2, 1 - g), t * c >= 2 && (u++, c /= 2), u + g >= l ? (f = 0, u = l) : u + g >= 1 ? (f = (t * c - 1) * Math.pow(2, a), u = u + g) : (f = t * Math.pow(2, g - 1) * Math.pow(2, a), u = 0)); a >= 8; e[r + w] = f & 255, w += v, f /= 256, a -= 8) ; for (u = u << a | f, d += a; d > 0; e[r + w] = u & 255, w += v, u /= 256, d -= 8) ; e[r + w - v] |= x * 128; }; /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh <https://feross.org> * @license MIT */ (function(e) { const t = Du, r = tp, i = typeof Symbol == "function" && typeof Symbol.for == "function" ? Symbol.for("nodejs.util.inspect.custom") : null; e.Buffer = l, e.SlowBuffer = _, e.INSPECT_MAX_BYTES = 50; const a = 2147483647; e.kMaxLength = a; const { Uint8Array: s, ArrayBuffer: u, SharedArrayBuffer: f } = globalThis; l.TYPED_ARRAY_SUPPORT = c(), !l.TYPED_ARRAY_SUPPORT && typeof console < "u" && typeof console.error == "function" && console.error( "This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support." ); function c() { try { const A = new s(1), E = { foo: function() { return 42; } }; return Object.setPrototypeOf(E, s.prototype), Object.setPrototypeOf(A, E), A.foo() === 42; } catch { return !1; } } Object.defineProperty(l.prototype, "parent", { enumerable: !0, get: function() { if (l.isBuffer(this)) return this.buffer; } }), Object.defineProperty(l.prototype, "offset", { enumerable: !0, get: function() { if (l.isBuffer(this)) return this.byteOffset; } }); function d(A) { if (A > a) throw new RangeError('The value "' + A + '" is invalid for option "size"'); const E = new s(A); return Object.setPrototypeOf(E, l.prototype), E; } function l(A, E, O) { if (typeof A == "number") { if (typeof E == "string") throw new TypeError( 'The "string" argument must be of type string. Received type number' ); return v(A); } return g(A, E, O); } l.poolSize = 8192; function g(A, E, O) { if (typeof A == "string") return x(A, E); if (u.isView(A)) return h(A); if (A == null) throw new TypeError( "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof A ); if (ie(A, u) || A && ie(A.buffer, u) || typeof f < "u" && (ie(A, f) || A && ie(A.buffer, f))) return p(A, E, O); if (typeof A == "number") throw new TypeError( 'The "value" argument must not be of type number. Received type number' ); const B = A.valueOf && A.valueOf(); if (B != null && B !== A) return l.from(B, E, O); const Q = b(A); if (Q) return Q; if (typeof Symbol < "u" && Symbol.toPrimitive != null && typeof A[Symbol.toPrimitive] == "function") return l.from(A[Symbol.toPrimitive]("string"), E, O); throw new TypeError( "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof A ); } l.from = function(A, E, O) { return g(A, E, O); }, Object.setPrototypeOf(l.prototype, s.prototype), Object.setPrototypeOf(l, s); function $(A) { if (typeof A != "number") throw new TypeError('"size" argument must be of type number'); if (A < 0) throw new RangeError('The value "' + A + '" is invalid for option "size"'); } function w(A, E, O) { return $(A), A <= 0 ? d(A) : E !== void 0 ? typeof O == "string" ? d(A).fill(E, O) : d(A).fill(E) : d(A); } l.alloc = function(A, E, O) { return w(A, E, O); }; function v(A) { return $(A), d(A < 0 ? 0 : P(A) | 0); } l.allocUnsafe = function(A) { return v(A); }, l.allocUnsafeSlow = function(A) { return v(A); }; function x(A, E) { if ((typeof E != "string" || E === "") && (E = "utf8"), !l.isEncoding(E)) throw new TypeError("Unknown encoding: " + E); const O = I(A, E) | 0; let B = d(O); const Q = B.write(A, E); return Q !== O &