docx
Version:
Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.
1,430 lines • 1.07 MB
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
//#region \0rolldown/runtime.js
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
key = keys[i];
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: ((k) => from[k]).bind(null, key),
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
//#endregion
//#region \0@oxc-project+runtime@0.121.0/helpers/typeof.js
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
return typeof o;
} : function(o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}
//#endregion
//#region \0@oxc-project+runtime@0.121.0/helpers/toPrimitive.js
function toPrimitive(t, r) {
if ("object" != _typeof(t) || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != _typeof(i)) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
//#endregion
//#region \0@oxc-project+runtime@0.121.0/helpers/toPropertyKey.js
function toPropertyKey(t) {
var i = toPrimitive(t, "string");
return "symbol" == _typeof(i) ? i : i + "";
}
//#endregion
//#region \0@oxc-project+runtime@0.121.0/helpers/defineProperty.js
function _defineProperty(e, r, t) {
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
value: t,
enumerable: !0,
configurable: !0,
writable: !0
}) : e[r] = t, e;
}
//#endregion
//#region src/file/xml-components/base.ts
/**
* Abstract base class for all XML components in the library.
*
* BaseXmlComponent defines the minimal interface that all XML components must implement.
* It stores the XML element name (rootKey) and requires subclasses to implement
* the prepForXml method for serialization.
*
* @example
* ```typescript
* class MyElement extends BaseXmlComponent {
* constructor() {
* super("w:myElement");
* }
*
* prepForXml(context: IContext): IXmlableObject {
* return { "w:myElement": {} };
* }
* }
* ```
*/
var BaseXmlComponent = class {
/**
* Creates a new BaseXmlComponent with the specified XML element name.
*
* @param rootKey - The XML element name (e.g., "w:p", "w:r", "w:t")
*/
constructor(rootKey) {
_defineProperty(
this,
/** The XML element name for this component (e.g., "w:p" for paragraph). */
"rootKey",
void 0
);
this.rootKey = rootKey;
}
};
//#endregion
//#region src/file/xml-components/xml-component.ts
/**
* XML Component module for the docx library.
*
* This module provides the core XmlComponent class that all WordprocessingML elements
* extend from. XmlComponent manages the conversion of component trees into XML structures
* that can be serialized into DOCX files.
*
* @module
*/
/**
* Empty object singleton used for empty XML elements.
*
* This sealed object is used to generate self-closing XML tags when an element
* has no children or attributes.
*
* @internal
*/
var EMPTY_OBJECT = Object.seal({});
/**
* Base class for all XML components in WordprocessingML documents.
*
* XmlComponent provides the infrastructure for building XML element trees
* that are serialized into document.xml and other parts of the DOCX package.
* It manages a collection of child components and handles the conversion to
* the intermediate object format used by the xml serialization library.
*
* @example
* ```typescript
* // Creating a custom XML component
* class MyElement extends XmlComponent {
* constructor(text: string) {
* super("w:myElement");
* this.root.push(new Attributes({ val: text }));
* }
* }
*
* const element = new MyElement("Hello");
* // When serialized: <w:myElement w:val="Hello"/>
* ```
*/
var XmlComponent = class extends BaseXmlComponent {
/**
* Creates a new XmlComponent.
*
* @param rootKey - The XML element name (e.g., "w:p", "w:r", "w:t")
*/
constructor(rootKey) {
super(rootKey);
_defineProperty(
this,
/**
* Array of child components, text nodes, and attributes.
*
* This array forms the content of the XML element. It can contain other
* XmlComponents, string values (text nodes), or attribute components.
*/
"root",
void 0
);
this.root = new Array();
}
/**
* Prepares this component and its children for XML serialization.
*
* This method is called by the Formatter to convert the component tree into
* an object structure compatible with the xml library (https://www.npmjs.com/package/xml).
* It recursively processes all children and handles special cases like
* attribute-only elements and empty elements.
*
* The method can be overridden by subclasses to customize XML representation
* or execute side effects during serialization (e.g., creating relationships).
*
* @param context - The serialization context containing document state
* @returns The XML-serializable object, or undefined to exclude from output
*
* @example
* ```typescript
* // Override to add custom serialization logic
* prepForXml(context: IContext): IXmlableObject | undefined {
* // Custom logic here
* return super.prepForXml(context);
* }
* ```
*/
prepForXml(context) {
var _children$;
context.stack.push(this);
const children = this.root.map((comp) => {
if (comp instanceof BaseXmlComponent) return comp.prepForXml(context);
return comp;
}).filter((comp) => comp !== void 0);
context.stack.pop();
return { [this.rootKey]: children.length ? children.length === 1 && ((_children$ = children[0]) === null || _children$ === void 0 ? void 0 : _children$._attr) ? children[0] : children : EMPTY_OBJECT };
}
/**
* Adds a child element to this component.
*
* @deprecated Do not use this method. It is only used internally by the library. It will be removed in a future version.
* @param child - The child component or text string to add
* @returns This component (for chaining)
*/
addChildElement(child) {
this.root.push(child);
return this;
}
};
/**
* XML component that is excluded from output if it has no meaningful content.
*
* IgnoreIfEmptyXmlComponent is useful for optional container elements that
* should only appear in the XML if they contain children or attributes.
* If the element would be empty, it returns undefined instead, causing it
* to be excluded from the output.
*
* @example
* ```typescript
* class OptionalContainer extends IgnoreIfEmptyXmlComponent {
* constructor(items?: Item[]) {
* super("w:container");
* if (items) {
* items.forEach(item => this.root.push(item));
* }
* }
* }
*
* const container1 = new OptionalContainer([item1, item2]);
* // Renders: <w:container>...</w:container>
*
* const container2 = new OptionalContainer();
* // Renders: nothing (excluded from output)
* ```
*/
var IgnoreIfEmptyXmlComponent = class extends XmlComponent {
constructor(rootKey, includeIfEmpty) {
super(rootKey);
_defineProperty(this, "includeIfEmpty", void 0);
this.includeIfEmpty = includeIfEmpty;
}
/**
* Prepares the component for XML serialization, excluding it if empty.
*
* @param context - The serialization context
* @returns The XML-serializable object, or undefined if empty
*/
prepForXml(context) {
const result = super.prepForXml(context);
if (this.includeIfEmpty) return result;
if (result && (typeof result[this.rootKey] !== "object" || Object.keys(result[this.rootKey]).length)) return result;
}
};
//#endregion
//#region \0@oxc-project+runtime@0.121.0/helpers/objectSpread2.js
function ownKeys(e, r) {
var t = Object.keys(e);
if (Object.getOwnPropertySymbols) {
var o = Object.getOwnPropertySymbols(e);
r && (o = o.filter(function(r) {
return Object.getOwnPropertyDescriptor(e, r).enumerable;
})), t.push.apply(t, o);
}
return t;
}
function _objectSpread2(e) {
for (var r = 1; r < arguments.length; r++) {
var t = null != arguments[r] ? arguments[r] : {};
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
_defineProperty(e, r, t[r]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
});
}
return e;
}
//#endregion
//#region src/file/xml-components/default-attributes.ts
/**
* XML attribute components for the docx library.
*
* This module provides base classes for creating XML element attributes.
* Attributes are represented as special components with the "_attr" key.
*
* @module
*/
/**
* Base class for creating XML attributes with automatic name mapping.
*
* XmlAttributeComponent allows you to define attributes using JavaScript-friendly
* property names that are automatically mapped to XML attribute names. Subclasses
* can define an xmlKeys map to specify the transformation.
*
* @example
* ```typescript
* class MyAttributes extends XmlAttributeComponent<{ fontSize: number }> {
* protected readonly xmlKeys = { fontSize: "w:sz" };
* }
*
* new MyAttributes({ fontSize: 24 });
* // Generates: _attr: { "w:sz": 24 }
* ```
*/
var XmlAttributeComponent = class extends BaseXmlComponent {
/**
* Creates a new attribute component.
*
* @param root - The attribute data object
*/
constructor(root) {
super("_attr");
_defineProperty(
this,
/** Optional mapping from property names to XML attribute names. */
"xmlKeys",
void 0
);
this.root = root;
}
/**
* Converts the attribute data to an XML-serializable object.
*
* This method transforms the property names using xmlKeys (if defined)
* and filters out undefined values.
*
* @param _ - Context (unused for attributes)
* @returns Object with _attr key containing the mapped attributes
*/
prepForXml(_) {
const attrs = {};
Object.entries(this.root).forEach(([key, value]) => {
if (value !== void 0) {
const newKey = this.xmlKeys && this.xmlKeys[key] || key;
attrs[newKey] = value;
}
});
return { _attr: attrs };
}
};
/**
* Next-generation attribute component with explicit key-value pairs.
*
* NextAttributeComponent provides an alternative approach to attributes where
* each property explicitly specifies both its XML attribute name and value.
* This gives more control but is more verbose than XmlAttributeComponent.
*
* @example
* ```typescript
* new NextAttributeComponent({
* fontSize: { key: "w:sz", value: 24 },
* bold: { key: "w:b", value: true }
* });
* // Generates: _attr: { "w:sz": 24, "w:b": true }
* ```
*/
var NextAttributeComponent = class extends BaseXmlComponent {
/**
* Creates a new NextAttributeComponent.
*
* @param root - Attribute payload with explicit key-value mappings
*/
constructor(root) {
super("_attr");
this.root = root;
}
/**
* Converts the attribute payload to an XML-serializable object.
*
* Extracts the key and value from each property and filters out
* undefined values.
*
* @param _ - Context (unused for attributes)
* @returns Object with _attr key containing the attributes
*/
prepForXml(_) {
return { _attr: Object.values(this.root).filter(({ value }) => value !== void 0).reduce((acc, { key, value }) => _objectSpread2(_objectSpread2({}, acc), {}, { [key]: value }), {}) };
}
};
//#endregion
//#region src/file/xml-components/attributes.ts
/**
* Common XML attributes module for WordprocessingML elements.
*
* This module provides a reusable Attributes class with commonly used
* WordprocessingML attribute mappings.
*
* @module
*/
/**
* Common XML attributes used across WordprocessingML elements.
*
* This class provides a convenient way to add common attributes to XML elements.
* It automatically maps JavaScript-friendly property names to their corresponding
* w: (WordprocessingML) namespace prefixed XML attribute names.
*
* @example
* ```typescript
* // Create an element with a value attribute
* new Attributes({ val: "someValue" });
* // Generates: <element w:val="someValue"/>
*
* // Multiple attributes
* new Attributes({ color: "FF0000", sz: "24" });
* // Generates: <element w:color="FF0000" w:sz="24"/>
* ```
*/
var Attributes = class extends XmlAttributeComponent {
constructor(..._args) {
super(..._args);
_defineProperty(this, "xmlKeys", {
val: "w:val",
color: "w:color",
fill: "w:fill",
space: "w:space",
sz: "w:sz",
type: "w:type",
rsidR: "w:rsidR",
rsidRPr: "w:rsidRPr",
rsidSect: "w:rsidSect",
w: "w:w",
h: "w:h",
top: "w:top",
right: "w:right",
bottom: "w:bottom",
left: "w:left",
header: "w:header",
footer: "w:footer",
gutter: "w:gutter",
linePitch: "w:linePitch",
pos: "w:pos"
});
}
};
//#endregion
//#region node_modules/events/events.js
var require_events = /* @__PURE__ */ __commonJSMin(((exports, module) => {
var R = typeof Reflect === "object" ? Reflect : null;
var ReflectApply = R && typeof R.apply === "function" ? R.apply : function ReflectApply(target, receiver, args) {
return Function.prototype.apply.call(target, receiver, args);
};
var ReflectOwnKeys;
if (R && typeof R.ownKeys === "function") ReflectOwnKeys = R.ownKeys;
else if (Object.getOwnPropertySymbols) ReflectOwnKeys = function ReflectOwnKeys(target) {
return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target));
};
else ReflectOwnKeys = function ReflectOwnKeys(target) {
return Object.getOwnPropertyNames(target);
};
function ProcessEmitWarning(warning) {
if (console && console.warn) console.warn(warning);
}
var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
return value !== value;
};
function EventEmitter() {
EventEmitter.init.call(this);
}
module.exports = EventEmitter;
module.exports.once = once;
EventEmitter.EventEmitter = EventEmitter;
EventEmitter.prototype._events = void 0;
EventEmitter.prototype._eventsCount = 0;
EventEmitter.prototype._maxListeners = void 0;
var defaultMaxListeners = 10;
function checkListener(listener) {
if (typeof listener !== "function") throw new TypeError("The \"listener\" argument must be of type Function. Received type " + typeof listener);
}
Object.defineProperty(EventEmitter, "defaultMaxListeners", {
enumerable: true,
get: function() {
return defaultMaxListeners;
},
set: function(arg) {
if (typeof arg !== "number" || arg < 0 || NumberIsNaN(arg)) throw new RangeError("The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received " + arg + ".");
defaultMaxListeners = arg;
}
});
EventEmitter.init = function() {
if (this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) {
this._events = Object.create(null);
this._eventsCount = 0;
}
this._maxListeners = this._maxListeners || void 0;
};
EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
if (typeof n !== "number" || n < 0 || NumberIsNaN(n)) throw new RangeError("The value of \"n\" is out of range. It must be a non-negative number. Received " + n + ".");
this._maxListeners = n;
return this;
};
function _getMaxListeners(that) {
if (that._maxListeners === void 0) return EventEmitter.defaultMaxListeners;
return that._maxListeners;
}
EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
return _getMaxListeners(this);
};
EventEmitter.prototype.emit = function emit(type) {
var args = [];
for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
var doError = type === "error";
var events = this._events;
if (events !== void 0) doError = doError && events.error === void 0;
else if (!doError) return false;
if (doError) {
var er;
if (args.length > 0) er = args[0];
if (er instanceof Error) throw er;
var err = /* @__PURE__ */ new Error("Unhandled error." + (er ? " (" + er.message + ")" : ""));
err.context = er;
throw err;
}
var handler = events[type];
if (handler === void 0) return false;
if (typeof handler === "function") ReflectApply(handler, this, args);
else {
var len = handler.length;
var listeners = arrayClone(handler, len);
for (var i = 0; i < len; ++i) ReflectApply(listeners[i], this, args);
}
return true;
};
function _addListener(target, type, listener, prepend) {
var m;
var events;
var existing;
checkListener(listener);
events = target._events;
if (events === void 0) {
events = target._events = Object.create(null);
target._eventsCount = 0;
} else {
if (events.newListener !== void 0) {
target.emit("newListener", type, listener.listener ? listener.listener : listener);
events = target._events;
}
existing = events[type];
}
if (existing === void 0) {
existing = events[type] = listener;
++target._eventsCount;
} else {
if (typeof existing === "function") existing = events[type] = prepend ? [listener, existing] : [existing, listener];
else if (prepend) existing.unshift(listener);
else existing.push(listener);
m = _getMaxListeners(target);
if (m > 0 && existing.length > m && !existing.warned) {
existing.warned = true;
var w = /* @__PURE__ */ new Error("Possible EventEmitter memory leak detected. " + existing.length + " " + String(type) + " listeners added. Use emitter.setMaxListeners() to increase limit");
w.name = "MaxListenersExceededWarning";
w.emitter = target;
w.type = type;
w.count = existing.length;
ProcessEmitWarning(w);
}
}
return target;
}
EventEmitter.prototype.addListener = function addListener(type, listener) {
return _addListener(this, type, listener, false);
};
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
EventEmitter.prototype.prependListener = function prependListener(type, listener) {
return _addListener(this, type, listener, true);
};
function onceWrapper() {
if (!this.fired) {
this.target.removeListener(this.type, this.wrapFn);
this.fired = true;
if (arguments.length === 0) return this.listener.call(this.target);
return this.listener.apply(this.target, arguments);
}
}
function _onceWrap(target, type, listener) {
var state = {
fired: false,
wrapFn: void 0,
target,
type,
listener
};
var wrapped = onceWrapper.bind(state);
wrapped.listener = listener;
state.wrapFn = wrapped;
return wrapped;
}
EventEmitter.prototype.once = function once(type, listener) {
checkListener(listener);
this.on(type, _onceWrap(this, type, listener));
return this;
};
EventEmitter.prototype.prependOnceListener = function prependOnceListener(type, listener) {
checkListener(listener);
this.prependListener(type, _onceWrap(this, type, listener));
return this;
};
EventEmitter.prototype.removeListener = function removeListener(type, listener) {
var list, events, position, i, originalListener;
checkListener(listener);
events = this._events;
if (events === void 0) return this;
list = events[type];
if (list === void 0) return this;
if (list === listener || list.listener === listener) if (--this._eventsCount === 0) this._events = Object.create(null);
else {
delete events[type];
if (events.removeListener) this.emit("removeListener", type, list.listener || listener);
}
else if (typeof list !== "function") {
position = -1;
for (i = list.length - 1; i >= 0; i--) if (list[i] === listener || list[i].listener === listener) {
originalListener = list[i].listener;
position = i;
break;
}
if (position < 0) return this;
if (position === 0) list.shift();
else spliceOne(list, position);
if (list.length === 1) events[type] = list[0];
if (events.removeListener !== void 0) this.emit("removeListener", type, originalListener || listener);
}
return this;
};
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
EventEmitter.prototype.removeAllListeners = function removeAllListeners(type) {
var listeners, events = this._events, i;
if (events === void 0) return this;
if (events.removeListener === void 0) {
if (arguments.length === 0) {
this._events = Object.create(null);
this._eventsCount = 0;
} else if (events[type] !== void 0) if (--this._eventsCount === 0) this._events = Object.create(null);
else delete events[type];
return this;
}
if (arguments.length === 0) {
var keys = Object.keys(events);
var key;
for (i = 0; i < keys.length; ++i) {
key = keys[i];
if (key === "removeListener") continue;
this.removeAllListeners(key);
}
this.removeAllListeners("removeListener");
this._events = Object.create(null);
this._eventsCount = 0;
return this;
}
listeners = events[type];
if (typeof listeners === "function") this.removeListener(type, listeners);
else if (listeners !== void 0) for (i = listeners.length - 1; i >= 0; i--) this.removeListener(type, listeners[i]);
return this;
};
function _listeners(target, type, unwrap) {
var events = target._events;
if (events === void 0) return [];
var evlistener = events[type];
if (evlistener === void 0) return [];
if (typeof evlistener === "function") return unwrap ? [evlistener.listener || evlistener] : [evlistener];
return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
}
EventEmitter.prototype.listeners = function listeners(type) {
return _listeners(this, type, true);
};
EventEmitter.prototype.rawListeners = function rawListeners(type) {
return _listeners(this, type, false);
};
EventEmitter.listenerCount = function(emitter, type) {
if (typeof emitter.listenerCount === "function") return emitter.listenerCount(type);
else return listenerCount.call(emitter, type);
};
EventEmitter.prototype.listenerCount = listenerCount;
function listenerCount(type) {
var events = this._events;
if (events !== void 0) {
var evlistener = events[type];
if (typeof evlistener === "function") return 1;
else if (evlistener !== void 0) return evlistener.length;
}
return 0;
}
EventEmitter.prototype.eventNames = function eventNames() {
return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
};
function arrayClone(arr, n) {
var copy = new Array(n);
for (var i = 0; i < n; ++i) copy[i] = arr[i];
return copy;
}
function spliceOne(list, index) {
for (; index + 1 < list.length; index++) list[index] = list[index + 1];
list.pop();
}
function unwrapListeners(arr) {
var ret = new Array(arr.length);
for (var i = 0; i < ret.length; ++i) ret[i] = arr[i].listener || arr[i];
return ret;
}
function once(emitter, name) {
return new Promise(function(resolve, reject) {
function errorListener(err) {
emitter.removeListener(name, resolver);
reject(err);
}
function resolver() {
if (typeof emitter.removeListener === "function") emitter.removeListener("error", errorListener);
resolve([].slice.call(arguments));
}
eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
if (name !== "error") addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
});
}
function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
if (typeof emitter.on === "function") eventTargetAgnosticAddListener(emitter, "error", handler, flags);
}
function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
if (typeof emitter.on === "function") if (flags.once) emitter.once(name, listener);
else emitter.on(name, listener);
else if (typeof emitter.addEventListener === "function") emitter.addEventListener(name, function wrapListener(arg) {
if (flags.once) emitter.removeEventListener(name, wrapListener);
listener(arg);
});
else throw new TypeError("The \"emitter\" argument must be of type EventEmitter. Received type " + typeof emitter);
}
}));
//#endregion
//#region node_modules/inherits/inherits_browser.js
var require_inherits_browser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
if (typeof Object.create === "function") module.exports = function inherits(ctor, superCtor) {
if (superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, { constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
} });
}
};
else module.exports = function inherits(ctor, superCtor) {
if (superCtor) {
ctor.super_ = superCtor;
var TempCtor = function() {};
TempCtor.prototype = superCtor.prototype;
ctor.prototype = new TempCtor();
ctor.prototype.constructor = ctor;
}
};
}));
//#endregion
//#region node_modules/vite-plugin-node-polyfills/shims/global/dist/index.js
var global;
var init_dist$1 = __esmMin((() => {
global = globalThis || self;
}));
//#endregion
//#region node_modules/vite-plugin-node-polyfills/shims/process/dist/index.js
function getDefaultExportFromCjs(x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
}
function defaultSetTimout() {
throw new Error("setTimeout has not been defined");
}
function defaultClearTimeout() {
throw new Error("clearTimeout has not been defined");
}
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) return setTimeout(fun, 0);
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
return cachedSetTimeout(fun, 0);
} catch (e) {
try {
return cachedSetTimeout.call(null, fun, 0);
} catch (e) {
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) return clearTimeout(marker);
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
return cachedClearTimeout(marker);
} catch (e) {
try {
return cachedClearTimeout.call(null, marker);
} catch (e) {
return cachedClearTimeout.call(this, marker);
}
}
}
function cleanUpNextTick() {
if (!draining || !currentQueue) return;
draining = false;
if (currentQueue.length) queue = currentQueue.concat(queue);
else queueIndex = -1;
if (queue.length) drainQueue();
}
function drainQueue() {
if (draining) return;
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while (len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) if (currentQueue) currentQueue[queueIndex].run();
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
function noop() {}
var browser, process, cachedSetTimeout, cachedClearTimeout, queue, draining, currentQueue, queueIndex, browserExports, process$1;
var init_dist = __esmMin((() => {
browser = { exports: {} };
process = browser.exports = {};
(function() {
try {
if (typeof setTimeout === "function") cachedSetTimeout = setTimeout;
else cachedSetTimeout = defaultSetTimout;
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === "function") cachedClearTimeout = clearTimeout;
else cachedClearTimeout = defaultClearTimeout;
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
})();
queue = [];
draining = false;
queueIndex = -1;
process.nextTick = function(fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) for (var i = 1; i < arguments.length; i++) args[i - 1] = arguments[i];
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) runTimeout(drainQueue);
};
Item.prototype.run = function() {
this.fun.apply(null, this.array);
};
process.title = "browser";
process.browser = true;
process.env = {};
process.argv = [];
process.version = "";
process.versions = {};
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.prependListener = noop;
process.prependOnceListener = noop;
process.listeners = function(name) {
return [];
};
process.binding = function(name) {
throw new Error("process.binding is not supported");
};
process.cwd = function() {
return "/";
};
process.chdir = function(dir) {
throw new Error("process.chdir is not supported");
};
process.umask = function() {
return 0;
};
browserExports = browser.exports;
process$1 = /* @__PURE__ */ getDefaultExportFromCjs(browserExports);
}));
//#endregion
//#region node_modules/stream-browserify/node_modules/readable-stream/lib/internal/streams/stream-browser.js
var require_stream_browser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
module.exports = require_events().EventEmitter;
}));
//#endregion
//#region node_modules/base64-js/index.js
var require_base64_js = /* @__PURE__ */ __commonJSMin(((exports) => {
exports.byteLength = byteLength;
exports.toByteArray = toByteArray;
exports.fromByteArray = fromByteArray;
var lookup = [];
var revLookup = [];
var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
for (var i = 0, len = code.length; i < len; ++i) {
lookup[i] = code[i];
revLookup[code.charCodeAt(i)] = i;
}
revLookup["-".charCodeAt(0)] = 62;
revLookup["_".charCodeAt(0)] = 63;
function getLens(b64) {
var len = b64.length;
if (len % 4 > 0) throw new Error("Invalid string. Length must be a multiple of 4");
var validLen = b64.indexOf("=");
if (validLen === -1) validLen = len;
var placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4;
return [validLen, placeHoldersLen];
}
function byteLength(b64) {
var lens = getLens(b64);
var validLen = lens[0];
var placeHoldersLen = lens[1];
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
}
function _byteLength(b64, validLen, placeHoldersLen) {
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
}
function toByteArray(b64) {
var tmp;
var lens = getLens(b64);
var validLen = lens[0];
var placeHoldersLen = lens[1];
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
var curByte = 0;
var len = placeHoldersLen > 0 ? validLen - 4 : validLen;
var i;
for (i = 0; i < len; i += 4) {
tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
arr[curByte++] = tmp >> 16 & 255;
arr[curByte++] = tmp >> 8 & 255;
arr[curByte++] = tmp & 255;
}
if (placeHoldersLen === 2) {
tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4;
arr[curByte++] = tmp & 255;
}
if (placeHoldersLen === 1) {
tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2;
arr[curByte++] = tmp >> 8 & 255;
arr[curByte++] = tmp & 255;
}
return arr;
}
function tripletToBase64(num) {
return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
}
function encodeChunk(uint8, start, end) {
var tmp;
var output = [];
for (var i = start; i < end; i += 3) {
tmp = (uint8[i] << 16 & 16711680) + (uint8[i + 1] << 8 & 65280) + (uint8[i + 2] & 255);
output.push(tripletToBase64(tmp));
}
return output.join("");
}
function fromByteArray(uint8) {
var tmp;
var len = uint8.length;
var extraBytes = len % 3;
var parts = [];
var maxChunkLength = 16383;
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
if (extraBytes === 1) {
tmp = uint8[len - 1];
parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "==");
} else if (extraBytes === 2) {
tmp = (uint8[len - 2] << 8) + uint8[len - 1];
parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "=");
}
return parts.join("");
}
}));
//#endregion
//#region node_modules/ieee754/index.js
var require_ieee754 = /* @__PURE__ */ __commonJSMin(((exports) => {
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
exports.read = function(buffer, offset, isLE, mLen, nBytes) {
var e, m;
var eLen = nBytes * 8 - mLen - 1;
var eMax = (1 << eLen) - 1;
var eBias = eMax >> 1;
var nBits = -7;
var i = isLE ? nBytes - 1 : 0;
var d = isLE ? -1 : 1;
var s = buffer[offset + i];
i += d;
e = s & (1 << -nBits) - 1;
s >>= -nBits;
nBits += eLen;
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8);
m = e & (1 << -nBits) - 1;
e >>= -nBits;
nBits += mLen;
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8);
if (e === 0) e = 1 - eBias;
else if (e === eMax) return m ? NaN : (s ? -1 : 1) * Infinity;
else {
m = m + Math.pow(2, mLen);
e = e - eBias;
}
return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
};
exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
var e, m, c;
var eLen = nBytes * 8 - mLen - 1;
var eMax = (1 << eLen) - 1;
var eBias = eMax >> 1;
var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
var i = isLE ? 0 : nBytes - 1;
var d = isLE ? 1 : -1;
var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
value = Math.abs(value);
if (isNaN(value) || value === Infinity) {
m = isNaN(value) ? 1 : 0;
e = eMax;
} else {
e = Math.floor(Math.log(value) / Math.LN2);
if (value * (c = Math.pow(2, -e)) < 1) {
e--;
c *= 2;
}
if (e + eBias >= 1) value += rt / c;
else value += rt * Math.pow(2, 1 - eBias);
if (value * c >= 2) {
e++;
c /= 2;
}
if (e + eBias >= eMax) {
m = 0;
e = eMax;
} else if (e + eBias >= 1) {
m = (value * c - 1) * Math.pow(2, mLen);
e = e + eBias;
} else {
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
e = 0;
}
}
for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8);
e = e << mLen | m;
eLen += mLen;
for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8);
buffer[offset + i - d] |= s * 128;
};
}));
//#endregion
//#region node_modules/buffer/index.js
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/
var require_buffer = /* @__PURE__ */ __commonJSMin(((exports) => {
var base64 = require_base64_js();
var ieee754 = require_ieee754();
var customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
exports.Buffer = Buffer;
exports.SlowBuffer = SlowBuffer;
exports.INSPECT_MAX_BYTES = 50;
var K_MAX_LENGTH = 2147483647;
exports.kMaxLength = K_MAX_LENGTH;
/**
* If `Buffer.TYPED_ARRAY_SUPPORT`:
* === true Use Uint8Array implementation (fastest)
* === false Print warning and recommend using `buffer` v4.x which has an Object
* implementation (most compatible, even IE6)
*
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
* Opera 11.6+, iOS 4.2+.
*
* We report that the browser does not support typed arrays if the are not subclassable
* using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
* (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
* for __proto__ and has a buggy typed array implementation.
*/
Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport();
if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && 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 typedArraySupport() {
try {
var arr = new Uint8Array(1);
var proto = { foo: function() {
return 42;
} };
Object.setPrototypeOf(proto, Uint8Array.prototype);
Object.setPrototypeOf(arr, proto);
return arr.foo() === 42;
} catch (e) {
return false;
}
}
Object.defineProperty(Buffer.prototype, "parent", {
enumerable: true,
get: function() {
if (!Buffer.isBuffer(this)) return void 0;
return this.buffer;
}
});
Object.defineProperty(Buffer.prototype, "offset", {
enumerable: true,
get: function() {
if (!Buffer.isBuffer(this)) return void 0;
return this.byteOffset;
}
});
function createBuffer(length) {
if (length > K_MAX_LENGTH) throw new RangeError("The value \"" + length + "\" is invalid for option \"size\"");
var buf = new Uint8Array(length);
Object.setPrototypeOf(buf, Buffer.prototype);
return buf;
}
/**
* The Buffer constructor returns instances of `Uint8Array` that have their
* prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
* `Uint8Array`, so the returned instances will have all the node `Buffer` methods
* and the `Uint8Array` methods. Square bracket notation works as expected -- it
* returns a single octet.
*
* The `Uint8Array` prototype remains unmodified.
*/
function Buffer(arg, encodingOrOffset, length) {
if (typeof arg === "number") {
if (typeof encodingOrOffset === "string") throw new TypeError("The \"string\" argument must be of type string. Received type number");
return allocUnsafe(arg);
}
return from(arg, encodingOrOffset, length);
}
Buffer.poolSize = 8192;
function from(value, encodingOrOffset, length) {
if (typeof value === "string") return fromString(value, encodingOrOffset);
if (ArrayBuffer.isView(value)) return fromArrayView(value);
if (value == null) throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value);
if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) return fromArrayBuffer(value, encodingOrOffset, length);
if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) return fromArrayBuffer(value, encodingOrOffset, length);
if (typeof value === "number") throw new TypeError("The \"value\" argument must not be of type number. Received type number");
var valueOf = value.valueOf && value.valueOf();
if (valueOf != null && valueOf !== value) return Buffer.from(valueOf, encodingOrOffset, length);
var b = fromObject(value);
if (b) return b;
if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") return Buffer.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length);
throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value);
}
/**
* Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
* if value is a number.
* Buffer.from(str[, encoding])
* Buffer.from(array)
* Buffer.from(buffer)
* Buffer.from(arrayBuffer[, byteOffset[, length]])
**/
Buffer.from = function(value, encodingOrOffset, length) {
return from(value, encodingOrOffset, length);
};
Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype);
Object.setPrototypeOf(Buffer, Uint8Array);
function assertSize(size) {
if (typeof size !== "number") throw new TypeError("\"size\" argument must be of type number");
else if (size < 0) throw new RangeError("The value \"" + size + "\" is invalid for option \"size\"");
}
function alloc(size, fill, encoding) {
assertSize(size);
if (size <= 0) return createBuffer(size);
if (fill !== void 0) return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill);
return createBuffer(size);
}
/**
* Creates a new filled Buffer instance.
* alloc(size[, fill[, encoding]])
**/
Buffer.alloc = function(size, fill, encoding) {
return alloc(size, fill, encoding);
};
function allocUnsafe(size) {
assertSize(size);
return createBuffer(size < 0 ? 0 : checked(size) | 0);
}
/**
* Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
* */
Buffer.allocUnsafe = function(size) {
return allocUnsafe(size);
};
/**
* Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
*/
Buffer.allocUnsafeSlow = function(size) {
return allocUnsafe(size);
};
function fromString(string, encoding) {
if (typeof encoding !== "string" || encoding === "") encoding = "utf8";
if (!Buffer.isEncoding(encoding)) throw new TypeError("Unknown encoding: " + encoding);
var length = byteLength(string, encoding) | 0;
var buf = createBuffer(length);
var actual = buf.write(string, encoding);
if (actual !== length) buf = buf.slice(0, actual);
return buf;
}
function fromArrayLike(array) {
var length = array.length < 0 ? 0 : checked(array.length) | 0;
var buf = createBuffer(length);
for (var i = 0; i < length; i += 1) buf[i] = array[i] & 255;
return buf;
}
function fromArrayView(arrayView) {
if (isInstance(arrayView, Uint8Array)) {
var copy = new Uint8Array(arrayView);
return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength);
}
return fromArrayLike(arrayView);
}
function fromArrayBuffer(array, byteOffset, length) {
if (byteOffset < 0 || array.byteLength < byteOffset) throw new RangeError("\"offset\" is outside of buffer bounds");
if (array.byteLength < byteOffset + (length || 0)) throw new RangeError("\"length\" is outside of buffer bounds");
var buf;
if (byteOffset === void 0 && length === void 0) buf = new Uint8Array(array);
else if (length === void 0) buf = new Uint8Array(array, byteOffset);
else buf = new Uint8Array(array, byteOffset, length);
Object.setPrototypeOf(buf, Buffer.prototype);
return buf;
}
function fromObject(obj) {
if (Buffer.isBuffer(obj)) {
var len = checked(obj.length) | 0;
var buf = createBuffer(len);
if (buf.length === 0) return buf;
obj.copy(buf, 0, 0, len);
return buf;
}
if (obj.length !== void 0) {
if (typeof obj.length !== "number" || numberIsNaN(obj.length)) return createBuffer(0);
return fromArrayLike(obj);
}
if (obj.type === "Buffer" && Array.isArray(obj.data)) return fromArrayLike(obj.data);
}
function checked(length) {
if (length >= K_MAX_LENGTH) throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes");
return length | 0;
}
function SlowBuffer(length) {
if (+length != length) length = 0;
return Buffer.alloc(+length);
}
Buffer.isBuffer = function isBuffer(b) {
return b != null && b._isBuffer === true && b !== Buffer.prototype;
};
Buffer.compare = function compare(a, b) {
if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength);
if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength);
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) throw new TypeError("The \"buf1\", \"buf2\" arguments must be one of type Buffer or Uint8Array");
if (a === b) return 0;
var x = a.length;
var y = b.length;
for (var i = 0, len = Math.min(x, y); i < len; ++i) if (a[i] !== b[i]) {
x = a[i];
y = b[i];
break;
}
if (x < y) return -1;
if (y < x) return 1;
return 0;
};
Buffer.isEncoding = function isEncoding(encoding) {
switch (String(encoding).toLowerCase()) {
case "hex":
case "utf8":
case "utf-8":
case "ascii":
case "latin1":
case "binary":
case "base64":
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le": return true;
default: return false;
}
};
Buffer.concat = function concat(list, length) {
if (!Array.isArray(list)) throw new TypeError("\"list\" argument must be an Array of Buffers");
if (list.length === 0) return Buffer.alloc(0);
var i;
if (length === void 0) {
length = 0;
for (i = 0; i < list.length; ++i) length += list[i].length;
}
var buffer = Buffer.allocUnsafe(length);
var pos = 0;
for (i = 0; i < list.length; ++i) {
var buf = list[i];
if (isInstance(buf, Uint8Array)) if (pos + buf.length > buffer.length) Buffer.from(buf).copy(buffer, pos);
else Uint8Array.prototype.set.call(buffer, buf, pos);
else if (!Buffer.isBuffer(buf)) throw new TypeError("\"list\" argument must be an Array of Buffers");
else buf.copy(buffer, pos);
pos += buf.length;
}
return buffer;
};
function byteLength(string, encoding) {
if (Buffer.isBuffer(string)) return string.length;
if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) return string.byteLength;
if (typeof string !== "string") throw new TypeError("The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. Received type " + typeof string);
var len = string.length;
var mustMatch = arguments.length > 2 && arguments[2] === true;
if (!mustMatch && len === 0) return 0;
var loweredCase = false;
for (;;) switch (encoding) {
case "ascii":
case "latin1":
case "binary": return len;
case "utf8":
case "utf-8": return utf8ToBytes(string).length;
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le": return len * 2;
case "hex": return len >>> 1;
case "base64": return base64ToBytes(string).length;
default:
if (loweredCase) return mustMatch ? -1 : utf8ToBytes(string).length;
encoding = ("" + encoding).toLowerCase();
loweredCase = true;
}
}
Buffer.byteLength = byteLength;
function slowToString(encoding, start, end) {
var loweredCase = false;
if (start === void 0 || start < 0) start = 0;
if (start > this.length) return "";
if (end === void 0 || end > this.length) end = this.length;
if (end <= 0) return "";
end >>>= 0;
start >>>= 0;
if (end <= start) return "";
if (!encoding) encoding = "utf8";
while (true) switch (encoding) {
case "hex": return hexSlice(this, start, end);
case "utf8":
case "utf-8": return utf8Slice(this, start, end);
case "ascii": return asciiSlice(this, start, end);
case "latin1":
case "binary": return latin1Slice(this, start, end);
case "base64": return base64Slice(this, start, end);
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le": return utf16leSlice(this, start, end);
default:
if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
encoding = (encoding + "").toLowerCase();
loweredCase = true;
}
}
Buffer.prototype._isBuffer = true;
function swap(b, n, m) {
var i = b[n];
b[n] = b[m];
b[m] = i;
}
Buffer.prototype.swap16 = function swap16() {
var len = this.length;
if (len % 2 !== 0) throw new RangeError("Buffer size must be a multiple of 16-bits");
for (var i = 0; i < len; i += 2) swap(this, i, i + 1);
return this;
};
Buffer.prototype.swap32 = function swap32() {
var len = this.length;
if (len % 4 !== 0) throw new RangeError("Buffer size must be a multiple of 32-bits");
for (var i = 0; i < len; i += 4) {
swap(this, i, i + 3);
swap(this, i + 1, i + 2);
}
return this;
};
Buffer.prototype.swap64 = function swap64() {
var len = this.length;
if (len % 8 !== 0) throw new RangeError("Buffer size must be a multiple of 64-bits");
for (var i = 0; i < len; i += 8) {
swap(this, i, i + 7);
swap(this, i + 1, i + 6);
swap(this, i + 2, i + 5);
swap(this, i + 3, i + 4);
}
return this;
};
Buffer.prototype.toString = function toString() {
var length = this.length;
if (length === 0) return "";
if (arguments.length === 0) return utf8Slice(this, 0, length);
return slowToString.apply(this, arguments);
};
Buffer.prototype.toLocaleString = Buffer.prototype.toString;
Buffer.prototype.equals = function equals(b) {
if (!Buffer.isBuffer(b)) throw new TypeError("Argument must be a Buffer");
if (this === b) return true;
return Buffer.compare(this, b) === 0;
};
Buffer.prototype.inspect = function inspect() {
var str = "";
var max = exports.INSPECT_MAX_BYTES;
str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim();
if (this.length > max) str += " ... ";
return "<Buffer " + str + ">";
};
if (customInspectSymbol) Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect;
Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
if (isInstance(target, Uint8Array)) target = Buffer.from(target, target.offset, target.byteLength);
if (!Buffer.isBuffer(target)) throw new TypeError("The \"target\" argument must be one of type Buffer or Uint8Array. Received type " + typeof target);
if (start === void 0) start = 0;
if (end === void 0) end = target ? target.length : 0;
if (thisStart === void 0) thisStart = 0;
if (thisEnd === void 0) thisEnd = this.length;
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) throw new RangeError("out of range index");
if (thisStart >= thisEnd && start >= end) return 0;
if (thisStart >= thisEnd) return -1;
if (start >= end) return 1;
start >>>= 0;
end >>>= 0;
thisStart >>>= 0;
thisEnd >>>= 0;
if (this === target) return 0;
var x = thisEnd - thisStart;
var y = end