UNPKG

@sprig-technologies/sprig-bundled

Version:

npm package for the sprig web sdk with bundled dependencies

1,057 lines (1,056 loc) 373 kB
var vd = Object.defineProperty; var Sd = (e, t, r) => t in e ? vd(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r; var de = (e, t, r) => Sd(e, typeof t != "symbol" ? t + "" : t, r); var Id = Object.create, uo = Object.defineProperty, Cd = Object.getOwnPropertyDescriptor, kd = Object.getOwnPropertyNames, Ed = Object.getPrototypeOf, xd = Object.prototype.hasOwnProperty, fr = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), Td = fr((e, t) => { var r; r = typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, t.exports = r; }), Rd = fr((e, t) => { t.exports = function(s) { if (!s) return !1; var n = r.call(s); return n === "[object Function]" || typeof s == "function" && n !== "[object RegExp]" || typeof window < "u" && (s === window.setTimeout || s === window.alert || s === window.confirm || s === window.prompt); }; var r = Object.prototype.toString; }), Ld = fr((e, t) => { var r = function(n) { return n.replace(/^\s+|\s+$/g, ""); }, s = function(n) { return Object.prototype.toString.call(n) === "[object Array]"; }; t.exports = function(n) { if (!n) return {}; for (var i = {}, a = r(n).split(` `), o = 0; o < a.length; o++) { var l = a[o], c = l.indexOf(":"), u = r(l.slice(0, c)).toLowerCase(), d = r(l.slice(c + 1)); i[u] === void 0 ? i[u] = d : s(i[u]) ? i[u].push(d) : i[u] = [i[u], d]; } return i; }; }), Od = fr((e, t) => { t.exports = function() { for (var s = {}, n = 0; n < arguments.length; n++) { var i = arguments[n]; for (var a in i) r.call(i, a) && (s[a] = i[a]); } return s; }; var r = Object.prototype.hasOwnProperty; }), Ad = fr((e, t) => { var r = Td(), s = Rd(), n = Ld(), i = Od(); function a(c, u, d) { var h = c; return s(u) ? (d = u, typeof c == "string" && (h = { uri: c })) : h = i(u, { uri: c }), h.callback = d, h; } function o(c, u, d) { return l(u = a(c, u, d)); } function l(c) { if (c.callback === void 0) throw new Error("callback argument missing"); var u = !1, d = function(T, R, S) { u || (u = !0, c.callback(T, R, S)); }; function h() { var T = void 0; if (T = p.response ? p.response : p.responseText || function(R) { try { if (R.responseType === "document") return R.responseXML; var S = R.responseXML && R.responseXML.documentElement.nodeName === "parsererror"; if (R.responseType === "" && !S) return R.responseXML; } catch { } return null; }(p), M) try { T = JSON.parse(T); } catch { } return T; } function f(T) { return clearTimeout(g), T instanceof Error || (T = new Error("" + (T || "Unknown XMLHttpRequest Error"))), T.statusCode = 0, d(T, k); } function w() { if (!m) { var T; clearTimeout(g), T = c.useXDR && p.status === void 0 ? 200 : p.status === 1223 ? 204 : p.status; var R = k, S = null; return T !== 0 ? (R = { body: h(), statusCode: T, method: I, headers: {}, url: v, rawRequest: p }, p.getAllResponseHeaders && (R.headers = n(p.getAllResponseHeaders()))) : S = new Error("Internal XMLHttpRequest Error"), d(S, R, R.body); } } var p = c.xhr || null; p || (p = c.cors || c.useXDR ? new o.XDomainRequest() : new o.XMLHttpRequest()); var C, m, g, v = p.url = c.uri || c.url, I = p.method = c.method || "GET", O = c.body || c.data, E = p.headers = c.headers || {}, A = !!c.sync, M = !1, k = { body: void 0, headers: {}, statusCode: 0, method: I, url: v, rawRequest: p }; if ("json" in c && c.json !== !1 && (M = !0, E.accept || E.Accept || (E.Accept = "application/json"), I !== "GET" && I !== "HEAD" && (E["content-type"] || E["Content-Type"] || (E["Content-Type"] = "application/json"), O = JSON.stringify(c.json === !0 ? O : c.json))), p.onreadystatechange = function() { p.readyState === 4 && setTimeout(w, 0); }, p.onload = w, p.onerror = f, p.onprogress = function() { }, p.onabort = function() { m = !0; }, p.ontimeout = f, p.open(I, v, !A, c.username, c.password), A || (p.withCredentials = !!c.withCredentials), !A && c.timeout > 0 && (g = setTimeout(function() { if (!m) { m = !0, p.abort("timeout"); var T = new Error("XMLHttpRequest timeout"); T.code = "ETIMEDOUT", f(T); } }, c.timeout)), p.setRequestHeader) for (C in E) E.hasOwnProperty(C) && p.setRequestHeader(C, E[C]); else if (c.headers && !function(T) { for (var R in T) if (T.hasOwnProperty(R)) return !1; return !0; }(c.headers)) throw new Error("Headers cannot be set on an XDomainRequest object"); return "responseType" in c && (p.responseType = c.responseType), "beforeSend" in c && typeof c.beforeSend == "function" && c.beforeSend(p), p.send(O || null), p; } t.exports = o, t.exports.default = o, o.XMLHttpRequest = r.XMLHttpRequest || function() { }, o.XDomainRequest = "withCredentials" in new o.XMLHttpRequest() ? o.XMLHttpRequest : r.XDomainRequest, function(c, u) { for (var d = 0; d < c.length; d++) u(c[d]); }(["get", "put", "post", "patch", "head", "delete"], function(c) { o[c === "delete" ? "del" : c] = function(u, d, h) { return (d = a(u, d, h)).method = c.toUpperCase(), l(d); }; }); }); function Ai(e, t, ...r) { if (!e) throw new TypeError(hl(t, r)); } function hl(e, t) { let r = 0; return e.replace(/%[os]/gu, () => ml(t[r++])); } function ml(e) { return typeof e != "object" || e === null ? String(e) : Object.prototype.toString.call(e); } var Me = typeof window < "u" ? window : typeof self < "u" ? self : typeof global < "u" ? global : typeof globalThis < "u" ? globalThis : void 0, dt = class { constructor(e, t) { this.code = e, this.message = t; } warn(...e) { var t; try { let r = ((t = new Error().stack) !== null && t !== void 0 ? t : "").replace(/^(?:.+?\n){2}/gu, ` `); console.warn(this.message, ...e, r); } catch { } } }, Md = new dt("W01", "Unable to initialize event under dispatching."), Ud = new dt("W02", "Assigning any falsy value to 'cancelBubble' property has no effect."), Dd = new dt("W03", "Assigning any truthy value to 'returnValue' property has no effect."), Pd = new dt("W04", "Unable to preventDefault on non-cancelable events."), _d = new dt("W05", "Unable to preventDefault inside passive event listener invocation."), Nd = new dt("W06", "An event listener wasn't added because it has been added already: %o, %o"), Js = new dt("W07", "The %o option value was abandoned because the event listener wasn't added as duplicated."), po = new dt("W08", "The 'callback' argument must be a function or an object that has 'handleEvent' method: %o"), qe = class { static get NONE() { return ho; } static get CAPTURING_PHASE() { return mo; } static get AT_TARGET() { return fo; } static get BUBBLING_PHASE() { return go; } constructor(e, t) { Object.defineProperty(this, "isTrusted", { value: !1, enumerable: !0 }); let r = t ?? {}; Cn.set(this, { type: String(e), bubbles: !!r.bubbles, cancelable: !!r.cancelable, composed: !!r.composed, target: null, currentTarget: null, stopPropagationFlag: !1, stopImmediatePropagationFlag: !1, canceledFlag: !1, inPassiveListenerFlag: !1, dispatchFlag: !1, timeStamp: Date.now() }); } get type() { return he(this).type; } get target() { return he(this).target; } get srcElement() { return he(this).target; } get currentTarget() { return he(this).currentTarget; } composedPath() { let e = he(this).currentTarget; return e ? [e] : []; } get NONE() { return ho; } get CAPTURING_PHASE() { return mo; } get AT_TARGET() { return fo; } get BUBBLING_PHASE() { return go; } get eventPhase() { return he(this).dispatchFlag ? 2 : 0; } stopPropagation() { he(this).stopPropagationFlag = !0; } get cancelBubble() { return he(this).stopPropagationFlag; } set cancelBubble(e) { e ? he(this).stopPropagationFlag = !0 : Ud.warn(); } stopImmediatePropagation() { let e = he(this); e.stopPropagationFlag = e.stopImmediatePropagationFlag = !0; } get bubbles() { return he(this).bubbles; } get cancelable() { return he(this).cancelable; } get returnValue() { return !he(this).canceledFlag; } set returnValue(e) { e ? Dd.warn() : yo(he(this)); } preventDefault() { yo(he(this)); } get defaultPrevented() { return he(this).canceledFlag; } get composed() { return he(this).composed; } get isTrusted() { return !1; } get timeStamp() { return he(this).timeStamp; } initEvent(e, t = !1, r = !1) { let s = he(this); s.dispatchFlag ? Md.warn() : Cn.set(this, { ...s, type: String(e), bubbles: !!t, cancelable: !!r, target: null, currentTarget: null, stopPropagationFlag: !1, stopImmediatePropagationFlag: !1, canceledFlag: !1 }); } }, ho = 0, mo = 1, fo = 2, go = 3, Cn = /* @__PURE__ */ new WeakMap(); function he(e, t = "this") { let r = Cn.get(e); return Ai(r != null, "'%s' must be an object that Event constructor created, but got another one: %o", t, e), r; } function yo(e) { e.inPassiveListenerFlag ? _d.warn() : e.cancelable ? e.canceledFlag = !0 : Pd.warn(); } Object.defineProperty(qe, "NONE", { enumerable: !0 }), Object.defineProperty(qe, "CAPTURING_PHASE", { enumerable: !0 }), Object.defineProperty(qe, "AT_TARGET", { enumerable: !0 }), Object.defineProperty(qe, "BUBBLING_PHASE", { enumerable: !0 }); var Ks = Object.getOwnPropertyNames(qe.prototype); for (let e = 0; e < Ks.length; ++e) Ks[e] !== "constructor" && Object.defineProperty(qe.prototype, Ks[e], { enumerable: !0 }); Me !== void 0 && Me.Event !== void 0 && Object.setPrototypeOf(qe.prototype, Me.Event.prototype); var bt, wo = { INDEX_SIZE_ERR: 1, DOMSTRING_SIZE_ERR: 2, HIERARCHY_REQUEST_ERR: 3, WRONG_DOCUMENT_ERR: 4, INVALID_CHARACTER_ERR: 5, NO_DATA_ALLOWED_ERR: 6, NO_MODIFICATION_ALLOWED_ERR: 7, NOT_FOUND_ERR: 8, NOT_SUPPORTED_ERR: 9, INUSE_ATTRIBUTE_ERR: 10, INVALID_STATE_ERR: 11, SYNTAX_ERR: 12, INVALID_MODIFICATION_ERR: 13, NAMESPACE_ERR: 14, INVALID_ACCESS_ERR: 15, VALIDATION_ERR: 16, TYPE_MISMATCH_ERR: 17, SECURITY_ERR: 18, NETWORK_ERR: 19, ABORT_ERR: 20, URL_MISMATCH_ERR: 21, QUOTA_EXCEEDED_ERR: 22, TIMEOUT_ERR: 23, INVALID_NODE_TYPE_ERR: 24, DATA_CLONE_ERR: 25 }; function bo(e) { let t = Object.keys(wo); for (let r = 0; r < t.length; ++r) { let s = t[r], n = wo[s]; Object.defineProperty(e, s, { get: () => n, configurable: !0, enumerable: !0 }); } } var ms = class extends qe { static wrap(e) { return new (gl(e))(e); } constructor(e) { super(e.type, { bubbles: e.bubbles, cancelable: e.cancelable, composed: e.composed }), e.cancelBubble && super.stopPropagation(), e.defaultPrevented && super.preventDefault(), fl.set(this, { original: e }); let t = Object.keys(e); for (let r = 0; r < t.length; ++r) { let s = t[r]; s in this || Object.defineProperty(this, s, yl(e, s)); } } stopPropagation() { super.stopPropagation(); let { original: e } = nt(this); "stopPropagation" in e && e.stopPropagation(); } get cancelBubble() { return super.cancelBubble; } set cancelBubble(e) { super.cancelBubble = e; let { original: t } = nt(this); "cancelBubble" in t && (t.cancelBubble = e); } stopImmediatePropagation() { super.stopImmediatePropagation(); let { original: e } = nt(this); "stopImmediatePropagation" in e && e.stopImmediatePropagation(); } get returnValue() { return super.returnValue; } set returnValue(e) { super.returnValue = e; let { original: t } = nt(this); "returnValue" in t && (t.returnValue = e); } preventDefault() { super.preventDefault(); let { original: e } = nt(this); "preventDefault" in e && e.preventDefault(); } get timeStamp() { let { original: e } = nt(this); return "timeStamp" in e ? e.timeStamp : super.timeStamp; } }, fl = /* @__PURE__ */ new WeakMap(); function nt(e) { let t = fl.get(e); return Ai(t != null, "'this' is expected an Event object, but got", e), t; } var fs = /* @__PURE__ */ new WeakMap(); function gl(e) { let t = Object.getPrototypeOf(e); if (t == null) return ms; let r = fs.get(t); return r == null && (r = function(s, n) { class i extends s { } let a = Object.keys(n); for (let o = 0; o < a.length; ++o) Object.defineProperty(i.prototype, a[o], yl(n, a[o])); return i; }(gl(t), t), fs.set(t, r)), r; } function yl(e, t) { let r = Object.getOwnPropertyDescriptor(e, t); return { get() { let s = nt(this).original, n = s[t]; return typeof n == "function" ? n.bind(s) : n; }, set(s) { nt(this).original[t] = s; }, configurable: r.configurable, enumerable: r.enumerable }; } function wl(e) { return !(1 & ~e.flags); } function vo(e) { return !(2 & ~e.flags); } function So(e) { return !(4 & ~e.flags); } function Fd(e) { return !(8 & ~e.flags); } function Bd({ callback: e }, t, r) { try { typeof e == "function" ? e.call(t, r) : typeof e.handleEvent == "function" && e.handleEvent(r); } catch (s) { (function(n) { try { let i = n instanceof Error ? n : new Error(ml(n)); if (typeof dispatchEvent == "function" && typeof ErrorEvent == "function") dispatchEvent(new ErrorEvent("error", { error: i, message: i.message })); else if (typeof process < "u" && typeof process.emit == "function") return void process.emit("uncaughtException", i); console.error(i); } catch { } })(s); } } function bl({ listeners: e }, t, r) { for (let s = 0; s < e.length; ++s) if (e[s].callback === t && wl(e[s]) === r) return s; return -1; } function Io(e, t, r) { let s = bl(e, t, r); return s !== -1 && vl(e, s); } function vl(e, t, r = !1) { let s = e.listeners[t]; return function(n) { n.flags |= 8; }(s), s.signal && s.signal.removeEventListener("abort", s.signalListener), e.cow && !r ? (e.cow = !1, e.listeners = e.listeners.filter((n, i) => i !== t), !1) : (e.listeners.splice(t, 1), !0); } fs.set(Object.prototype, ms), Me !== void 0 && Me.Event !== void 0 && fs.set(Me.Event.prototype, ms); var Us = class { constructor() { Il.set(this, /* @__PURE__ */ Object.create(null)); } addEventListener(e, t, r) { let s = Zs(this), { callback: n, capture: i, once: a, passive: o, signal: l, type: c } = function(h, f, w) { var p; return Co(f), typeof w == "object" && w !== null ? { type: String(h), callback: f ?? void 0, capture: !!w.capture, passive: !!w.passive, once: !!w.once, signal: (p = w.signal) !== null && p !== void 0 ? p : void 0 } : { type: String(h), callback: f ?? void 0, capture: !!w, passive: !1, once: !1, signal: void 0 }; }(e, t, r); if (n == null || l != null && l.aborted) return; let u = function(h, f) { var w; return (w = h[f]) !== null && w !== void 0 ? w : h[f] = { attrCallback: void 0, attrListener: void 0, cow: !1, listeners: [] }; }(s, c), d = bl(u, n, i); d === -1 ? function(h, f, w, p, C, m) { let g; m && (g = Io.bind(null, h, f, w), m.addEventListener("abort", g)); let v = function(I, O, E, A, M, k) { return { callback: I, flags: (O ? 1 : 0) | (E ? 2 : 0) | (A ? 4 : 0), signal: M, signalListener: k }; }(f, w, p, C, m, g); h.cow ? (h.cow = !1, h.listeners = [...h.listeners, v]) : h.listeners.push(v); }(u, n, i, o, a, l) : function(h, f, w, p) { Nd.warn(wl(h) ? "capture" : "bubble", h.callback), vo(h) !== f && Js.warn("passive"), So(h) !== w && Js.warn("once"), h.signal !== p && Js.warn("signal"); }(u.listeners[d], o, a, l); } removeEventListener(e, t, r) { let s = Zs(this), { callback: n, capture: i, type: a } = function(l, c, u) { return Co(c), typeof u == "object" && u !== null ? { type: String(l), callback: c ?? void 0, capture: !!u.capture } : { type: String(l), callback: c ?? void 0, capture: !!u }; }(e, t, r), o = s[a]; n != null && o && Io(o, n, i); } dispatchEvent(e) { let t = Zs(this)[String(e.type)]; if (t == null) return !0; let r = e instanceof qe ? e : ms.wrap(e), s = he(r, "event"); if (s.dispatchFlag) throw n = "This event has been in dispatching.", Me.DOMException ? new Me.DOMException(n, "InvalidStateError") : (bt == null && (bt = class Sl extends Error { constructor(a) { super(a), Error.captureStackTrace && Error.captureStackTrace(this, Sl); } get code() { return 11; } get name() { return "InvalidStateError"; } }, Object.defineProperties(bt.prototype, { code: { enumerable: !0 }, name: { enumerable: !0 } }), bo(bt), bo(bt.prototype)), new bt(n)); var n; if (s.dispatchFlag = !0, s.target = s.currentTarget = this, !s.stopPropagationFlag) { let { cow: i, listeners: a } = t; t.cow = !0; for (let o = 0; o < a.length; ++o) { let l = a[o]; if (!Fd(l) && (So(l) && vl(t, o, !i) && (o -= 1), s.inPassiveListenerFlag = vo(l), Bd(l, this, r), s.inPassiveListenerFlag = !1, s.stopImmediatePropagationFlag)) break; } i || (t.cow = !1); } return s.target = null, s.currentTarget = null, s.stopImmediatePropagationFlag = !1, s.stopPropagationFlag = !1, s.dispatchFlag = !1, !s.canceledFlag; } }, Il = /* @__PURE__ */ new WeakMap(); function Zs(e, t = "this") { let r = Il.get(e); return Ai(r != null, "'%s' must be an object that EventTarget constructor created, but got another one: %o", t, e), r; } function Co(e) { if (typeof e != "function" && (typeof e != "object" || e === null || typeof e.handleEvent != "function")) { if (e == null || typeof e == "object") return void po.warn(e); throw new TypeError(hl(po.message, [e])); } } var Xs = Object.getOwnPropertyNames(Us.prototype); for (let e = 0; e < Xs.length; ++e) Xs[e] !== "constructor" && Object.defineProperty(Us.prototype, Xs[e], { enumerable: !0 }); Me !== void 0 && Me.EventTarget !== void 0 && Object.setPrototypeOf(Us.prototype, Me.EventTarget.prototype); var ko, zd = ((e, t, r) => (r = e != null ? Id(Ed(e)) : {}, ((s, n, i, a) => { if (n && typeof n == "object" || typeof n == "function") for (let o of kd(n)) !xd.call(s, o) && o !== i && uo(s, o, { get: () => n[o], enumerable: !(a = Cd(n, o)) || a.enumerable }); return s; })(e && e.__esModule ? r : uo(r, "default", { value: e, enumerable: !0 }), e)))(Ad()), Ds = 512e3, Ps = 256, kn = (e, { minChunkSize: t = Ps, maxChunkSize: r = Ds } = {}) => e == null || typeof e == "number" && e >= 256 && e % 256 == 0 && e >= t && e <= r, En = (e, { minChunkSize: t = Ps, maxChunkSize: r = Ds } = {}) => new TypeError(`chunkSize ${e} must be a positive number in multiples of 256, between ${t} and ${r}`), jd = class { constructor(e, t = {}) { var r, s, n; if (this.readableStream = e, !kn(t.defaultChunkSize, t)) throw En(t.defaultChunkSize, t); this.defaultChunkSize = (r = t.defaultChunkSize) != null ? r : 30720, this.minChunkSize = (s = t.minChunkSize) != null ? s : Ps, this.maxChunkSize = (n = t.maxChunkSize) != null ? n : Ds; } get chunkSize() { var e; return (e = this._chunkSize) != null ? e : this.defaultChunkSize; } set chunkSize(e) { if (!kn(e, this)) throw En(e, this); this._chunkSize = e; } get chunkByteSize() { return 1024 * this.chunkSize; } async *[Symbol.asyncIterator]() { let e, t = this.readableStream.getReader(); try { for (; ; ) { let { done: r, value: s } = await t.read(); if (r) { if (e) { let i = e; e = void 0, yield i; } break; } let n = s instanceof Uint8Array ? new Blob([s], { type: "application/octet-stream" }) : s; for (e = e ? new Blob([e, n]) : n; e; ) { if (e.size === this.chunkByteSize) { let i = e; e = void 0, yield i; break; } if (e.size < this.chunkByteSize) break; { let i = e.slice(0, this.chunkByteSize); e = e.slice(this.chunkByteSize), yield i; } } } } finally { if (e) { let r = e; e = void 0, yield r; } return void t.releaseLock(); } } }, Wd = [200, 201, 202, 204, 308], Cl = [408, 502, 503, 504], kl = (e, t) => !!e && Wd.includes(e.statusCode), Vd = (e, t) => t.attemptCount >= t.attempts || !(kl(e) || ((r, { retryCodes: s = Cl }) => !r || s.includes(r.statusCode))(e, t)), El = class { static createUpload(e) { return new El(e); } constructor(e) { this.endpoint = e.endpoint, this.file = e.file, this.headers = e.headers || {}, this.method = e.method || "PUT", this.attempts = e.attempts || 5, this.delayBeforeAttempt = e.delayBeforeAttempt || 1, this.retryCodes = e.retryCodes || Cl, this.dynamicChunkSize = e.dynamicChunkSize || !1, this.maxFileBytes = 1024 * (e.maxFileSize || 0), this.chunkCount = 0, this.attemptCount = 0, this.offline = !1, this._paused = !1, this.success = !1, this.nextChunkRangeStart = 0, this.chunkedStreamIterable = new jd(this.file.stream(), { ...e, defaultChunkSize: e.chunkSize }), this.chunkedStreamIterator = this.chunkedStreamIterable[Symbol.asyncIterator](), this.totalChunks = Math.ceil(this.file.size / this.chunkByteSize), this.eventTarget = new Us(), this.validateOptions(), this.getEndpoint().then(() => this.sendChunks()), typeof window < "u" && (window.addEventListener("online", () => { !this.offline || (this.offline = !1, this.dispatch("online"), this.sendChunks()); }), window.addEventListener("offline", () => { this.offline = !0, this.dispatch("offline"); })); } get maxChunkSize() { var e, t; return (t = (e = this.chunkedStreamIterable) == null ? void 0 : e.maxChunkSize) != null ? t : Ds; } get minChunkSize() { var e, t; return (t = (e = this.chunkedStreamIterable) == null ? void 0 : e.minChunkSize) != null ? t : Ps; } get chunkSize() { var e, t; return (t = (e = this.chunkedStreamIterable) == null ? void 0 : e.chunkSize) != null ? t : 30720; } set chunkSize(e) { this.chunkedStreamIterable.chunkSize = e; } get chunkByteSize() { return this.chunkedStreamIterable.chunkByteSize; } get totalChunkSize() { return Math.ceil(this.file.size / this.chunkByteSize); } on(e, t) { this.eventTarget.addEventListener(e, t); } once(e, t) { this.eventTarget.addEventListener(e, t, { once: !0 }); } off(e, t) { this.eventTarget.removeEventListener(e, t); } get paused() { return this._paused; } abort() { var e; this.pause(), (e = this.currentXhr) == null || e.abort(); } pause() { this._paused = !0; } resume() { this._paused && (this._paused = !1, this.sendChunks()); } dispatch(e, t) { let r = new CustomEvent(e, { detail: t }); this.eventTarget.dispatchEvent(r); } validateOptions() { if (!this.endpoint || typeof this.endpoint != "function" && typeof this.endpoint != "string") throw new TypeError("endpoint must be defined as a string or a function that returns a promise"); if (!(this.file instanceof File)) throw new TypeError("file must be a File object"); if (this.headers && typeof this.headers != "function" && typeof this.headers != "object") throw new TypeError("headers must be null, an object, or a function that returns an object or a promise"); if (!kn(this.chunkSize, { maxChunkSize: this.maxChunkSize, minChunkSize: this.minChunkSize })) throw En(this.chunkSize, { maxChunkSize: this.maxChunkSize, minChunkSize: this.minChunkSize }); if (this.maxChunkSize && (typeof this.maxChunkSize != "number" || this.maxChunkSize < 256 || this.maxChunkSize % 256 != 0 || this.maxChunkSize < this.chunkSize || this.maxChunkSize < this.minChunkSize)) throw new TypeError(`maxChunkSize must be a positive number in multiples of 256, and larger than or equal to both ${this.minChunkSize} and ${this.chunkSize}`); if (this.minChunkSize && (typeof this.minChunkSize != "number" || this.minChunkSize < 256 || this.minChunkSize % 256 != 0 || this.minChunkSize > this.chunkSize || this.minChunkSize > this.maxChunkSize)) throw new TypeError(`minChunkSize must be a positive number in multiples of 256, and smaller than ${this.chunkSize} and ${this.maxChunkSize}`); if (this.maxFileBytes > 0 && this.maxFileBytes < this.file.size) throw new Error(`file size exceeds maximum (${this.file.size} > ${this.maxFileBytes})`); if (this.attempts && (typeof this.attempts != "number" || this.attempts <= 0)) throw new TypeError("retries must be a positive number"); if (this.delayBeforeAttempt && (typeof this.delayBeforeAttempt != "number" || this.delayBeforeAttempt < 0)) throw new TypeError("delayBeforeAttempt must be a positive number"); } getEndpoint() { return typeof this.endpoint == "string" ? (this.endpointValue = this.endpoint, Promise.resolve(this.endpoint)) : this.endpoint(this.file).then((e) => (this.endpointValue = e, this.endpointValue)); } xhrPromise(e) { let t = (r) => { r.upload.onprogress = (s) => { var n; let i = this.totalChunks - this.chunkCount, a = (this.file.size - this.nextChunkRangeStart) / this.file.size / i, o = this.nextChunkRangeStart / this.file.size, l = s.loaded / ((n = s.total) != null ? n : this.chunkByteSize) * a; this.dispatch("progress", Math.min(100 * (o + l), 100)); }; }; return new Promise((r, s) => { this.currentXhr = (0, zd.default)({ ...e, beforeSend: t }, (n, i) => (this.currentXhr = void 0, n ? s(n) : r(i))); }); } async sendChunk(e) { let t = this.nextChunkRangeStart, r = t + e.size - 1, s = { ...await (typeof this.headers == "function" ? this.headers() : this.headers), "Content-Type": this.file.type, "Content-Range": `bytes ${t}-${r}/${this.file.size}` }; return this.dispatch("attempt", { chunkNumber: this.chunkCount, totalChunks: this.totalChunks, chunkSize: this.chunkSize }), this.xhrPromise({ headers: s, url: this.endpointValue, method: this.method, body: e }); } async sendChunkWithRetries(e) { let t; try { this.attemptCount = this.attemptCount + 1, this.lastChunkStart = /* @__PURE__ */ new Date(), t = await this.sendChunk(e); } catch { } let r = { retryCodes: this.retryCodes, attemptCount: this.attemptCount, attempts: this.attempts }; return kl(t) ? (async (s) => { var n; let i = ((/* @__PURE__ */ new Date()).getTime() - this.lastChunkStart.getTime()) / 1e3; if (this.dispatch("chunkSuccess", { chunk: this.chunkCount, chunkSize: this.chunkSize, attempts: this.attemptCount, timeInterval: i, response: s }), this.attemptCount = 0, this.chunkCount = ((n = this.chunkCount) != null ? n : 0) + 1, this.nextChunkRangeStart = this.nextChunkRangeStart + this.chunkByteSize, this.dynamicChunkSize) { let a = this.chunkSize; i < 10 ? a = Math.min(2 * this.chunkSize, this.maxChunkSize) : i > 30 && (a = Math.max(this.chunkSize / 2, this.minChunkSize)), this.chunkSize = 256 * Math.ceil(a / 256); let o = (this.file.size - this.nextChunkRangeStart) / this.chunkByteSize; this.totalChunks = Math.ceil(this.chunkCount + o); } return !0; })(t) : Vd(t, r) ? (async (s) => (this.dispatch("error", { message: `Server responded with ${s.statusCode}. Stopping upload.`, chunk: this.chunkCount, attempts: this.attemptCount }), !1))(t) : (async () => (this.dispatch("attemptFailure", { message: `An error occured uploading chunk ${this.chunkCount}. ${this.attempts - this.attemptCount} retries left.`, chunkNumber: this.chunkCount, attemptsLeft: this.attempts - this.attemptCount }), new Promise((s) => { setTimeout(async () => { if (this._paused || this.offline) return this.pendingChunk = e, void s(!1); let n = await this.sendChunkWithRetries(e); s(n); }, 1e3 * this.delayBeforeAttempt); })))(); } async sendChunks() { if (this.pendingChunk && !this._paused && !this.offline) { let e = this.pendingChunk; this.pendingChunk = void 0; let t = await this.sendChunkWithRetries(e); this.success && t && this.dispatch("success"); } for (; !(this.success || this._paused || this.offline); ) { let { value: e, done: t } = await this.chunkedStreamIterator.next(), r = !e && t; if (e && (r = await this.sendChunkWithRetries(e)), this.success = !!t, this.success && r && this.dispatch("success"), !r) return; } } }, Hd = El.createUpload, Gd = Object.defineProperty, x = (e, t, r) => ((s, n, i) => n in s ? Gd(s, n, { enumerable: !0, configurable: !0, writable: !0, value: i }) : s[n] = i)(e, typeof t != "symbol" ? t + "" : t, r), $d = Object.defineProperty, Eo = (e, t, r) => ((s, n, i) => n in s ? $d(s, n, { enumerable: !0, configurable: !0, writable: !0, value: i }) : s[n] = i)(e, typeof t != "symbol" ? t + "" : t, r), fe = ((e) => (e[e.Document = 0] = "Document", e[e.DocumentType = 1] = "DocumentType", e[e.Element = 2] = "Element", e[e.Text = 3] = "Text", e[e.CDATA = 4] = "CDATA", e[e.Comment = 5] = "Comment", e))(fe || {}); const xo = { Node: ["childNodes", "parentNode", "parentElement", "textContent"], ShadowRoot: ["host", "styleSheets"], Element: ["shadowRoot", "querySelector", "querySelectorAll"], MutationObserver: [] }, To = { Node: ["contains", "getRootNode"], ShadowRoot: ["getSelection"], Element: [], MutationObserver: ["constructor"] }, Sr = {}; function Mi(e) { if (Sr[e]) return Sr[e]; const t = globalThis[e], r = t.prototype, s = e in xo ? xo[e] : void 0, n = !!(s && s.every((o) => { var l, c; return !!((c = (l = Object.getOwnPropertyDescriptor(r, o)) == null ? void 0 : l.get) != null && c.toString().includes("[native code]")); })), i = e in To ? To[e] : void 0, a = !!(i && i.every((o) => { var l; return typeof r[o] == "function" && ((l = r[o]) == null ? void 0 : l.toString().includes("[native code]")); })); if (n && a) return Sr[e] = t.prototype, t.prototype; try { const o = document.createElement("iframe"); document.body.appendChild(o); const l = o.contentWindow; if (!l) return t.prototype; const c = l[e].prototype; return document.body.removeChild(o), c ? Sr[e] = c : r; } catch { return r; } } const Qs = {}; function et(e, t, r) { var s; const n = `${e}.${String(r)}`; if (Qs[n]) return Qs[n].call(t); const i = Mi(e), a = (s = Object.getOwnPropertyDescriptor(i, r)) == null ? void 0 : s.get; return a ? (Qs[n] = a, a.call(t)) : t[r]; } const en = {}; function Ro(e, t, r) { const s = `${e}.${String(r)}`; if (en[s]) return en[s].bind(t); const n = Mi(e)[r]; return typeof n != "function" ? t[r] : (en[s] = n, n.bind(t)); } const ye = { childNodes: function(e) { return et("Node", e, "childNodes"); }, parentNode: function(e) { return et("Node", e, "parentNode"); }, parentElement: function(e) { return et("Node", e, "parentElement"); }, textContent: function(e) { return et("Node", e, "textContent"); }, contains: function(e, t) { return Ro("Node", e, "contains")(t); }, getRootNode: function(e) { return Ro("Node", e, "getRootNode")(); }, host: function(e) { return e && "host" in e ? et("ShadowRoot", e, "host") : null; }, styleSheets: function(e) { return e.styleSheets; }, shadowRoot: function(e) { return e && "shadowRoot" in e ? et("Element", e, "shadowRoot") : null; }, querySelector: function(e, t) { return et("Element", e, "querySelector")(t); }, querySelectorAll: function(e, t) { return et("Element", e, "querySelectorAll")(t); }, mutationObserver: function() { return Mi("MutationObserver").constructor; } }; function xl(e) { return e.nodeType === e.ELEMENT_NODE; } function Zt(e) { const t = e && "host" in e && "mode" in e && ye.host(e) || null; return !!(t && "shadowRoot" in t && ye.shadowRoot(t) === e); } function Xt(e) { return Object.prototype.toString.call(e) === "[object ShadowRoot]"; } function qr(e) { try { const r = e.rules || e.cssRules; return r ? ((t = Array.from(r, (n) => Tl(n, e.href)).join("")).includes(" background-clip: text;") && !t.includes(" -webkit-background-clip: text;") && (t = t.replace(/\sbackground-clip:\s*text;/g, " -webkit-background-clip: text; background-clip: text;")), t) : null; } catch { return null; } var t; } function Tl(e, t) { if (function(r) { return "styleSheet" in r; }(e)) { let r; try { r = qr(e.styleSheet) || function(s) { const { cssText: n } = s; if (n.split('"').length < 3) return n; const i = ["@import", `url(${JSON.stringify(s.href)})`]; return s.layerName === "" ? i.push("layer") : s.layerName && i.push(`layer(${s.layerName})`), s.supportsText && i.push(`supports(${s.supportsText})`), s.media.length && i.push(s.media.mediaText), i.join(" ") + ";"; }(e); } catch { r = e.cssText; } return e.styleSheet.href ? gs(r, e.styleSheet.href) : r; } { let r = e.cssText; return function(s) { return "selectorText" in s; }(e) && e.selectorText.includes(":") && (r = function(s) { const n = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm; return s.replace(n, "$1\\$2"); }(r)), t ? gs(r, t) : r; } } class Rl { constructor() { Eo(this, "idNodeMap", /* @__PURE__ */ new Map()), Eo(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap()); } getId(t) { var r; return t ? ((r = this.getMeta(t)) == null ? void 0 : r.id) ?? -1 : -1; } getNode(t) { return this.idNodeMap.get(t) || null; } getIds() { return Array.from(this.idNodeMap.keys()); } getMeta(t) { return this.nodeMetaMap.get(t) || null; } removeNodeFromMap(t) { const r = this.getId(t); this.idNodeMap.delete(r), t.childNodes && t.childNodes.forEach((s) => this.removeNodeFromMap(s)); } has(t) { return this.idNodeMap.has(t); } hasNode(t) { return this.nodeMetaMap.has(t); } add(t, r) { const s = r.id; this.idNodeMap.set(s, t), this.nodeMetaMap.set(t, r); } replace(t, r) { const s = this.getNode(t); if (s) { const n = this.nodeMetaMap.get(s); n && this.nodeMetaMap.set(r, n); } this.idNodeMap.set(t, r); } reset() { this.idNodeMap = /* @__PURE__ */ new Map(), this.nodeMetaMap = /* @__PURE__ */ new WeakMap(); } } function Ui({ element: e, maskInputOptions: t, tagName: r, type: s, value: n, maskInputFn: i }) { let a = n || ""; const o = s && ft(s); return (t[r.toLowerCase()] || o && t[o]) && (a = i ? i(a, e) : "*".repeat(a.length)), a; } function ft(e) { return e.toLowerCase(); } const Lo = "__rrweb_original__"; function Di(e) { const t = e.type; return e.hasAttribute("data-rr-is-password") ? "password" : t ? ft(t) : null; } function Oo(e, t) { let r; try { r = new URL(e, t ?? window.location.href); } catch { return null; } const s = r.pathname.match(/\.([0-9a-z]+)(?:$)/i); return (s == null ? void 0 : s[1]) ?? null; } const Yd = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm, qd = /^(?:[a-z+]+:)?\/\//i, Jd = /^www\..*/i, Kd = /^(data:)([^,]*),(.*)/i; function gs(e, t) { return (e || "").replace(Yd, (r, s, n, i, a, o) => { const l = n || a || o, c = s || i || ""; if (!l) return r; if (qd.test(l) || Jd.test(l)) return `url(${c}${l}${c})`; if (Kd.test(l)) return `url(${c}${l}${c})`; if (l[0] === "/") return `url(${c}${function(h) { let f = ""; return f = h.indexOf("//") > -1 ? h.split("/").slice(0, 3).join("/") : h.split("/")[0], f = f.split("?")[0], f; }(t) + l}${c})`; const u = t.split("/"), d = l.split("/"); u.pop(); for (const h of d) h !== "." && (h === ".." ? u.pop() : u.push(h)); return `url(${c}${u.join("/")}${c})`; }); } let Zd = 1; const Xd = new RegExp("[^a-z0-9-_:]"); function Ll() { return Zd++; } let vt, Ao; const Qd = /^[^ \t\n\r\u000c]+/, ep = /^[, \t\n\r\u000c]+/, Mo = /* @__PURE__ */ new WeakMap(); function Ft(e, t) { return t && t.trim() !== "" ? Pi(e, t) : t; } function tp(e) { return !!(e.tagName === "svg" || e.ownerSVGElement); } function Pi(e, t) { let r = Mo.get(e); if (r || (r = e.createElement("a"), Mo.set(e, r)), t) { if (t.startsWith("blob:") || t.startsWith("data:")) return t; } else t = ""; return r.setAttribute("href", t), r.href; } function Ol(e, t, r, s) { return s && (r === "src" || r === "href" && (t !== "use" || s[0] !== "#") || r === "xlink:href" && s[0] !== "#" ? Ft(e, s) : r !== "background" || t !== "table" && t !== "td" && t !== "th" ? r === "srcset" ? function(n, i) { if (i.trim() === "") return i; let a = 0; function o(c) { let u; const d = c.exec(i.substring(a)); return d ? (u = d[0], a += u.length, u) : ""; } const l = []; for (; o(ep), !(a >= i.length); ) { let c = o(Qd); if (c.slice(-1) === ",") c = Ft(n, c.substring(0, c.length - 1)), l.push(c); else { let u = ""; c = Ft(n, c); let d = !1; for (; ; ) { const h = i.charAt(a); if (h === "") { l.push((c + u).trim()); break; } if (d) h === ")" && (d = !1); else { if (h === ",") { a += 1, l.push((c + u).trim()); break; } h === "(" && (d = !0); } u += h, a += 1; } } } return l.join(", "); }(e, s) : r === "style" ? gs(s, Pi(e)) : t === "object" && r === "data" ? Ft(e, s) : s : Ft(e, s)); } function Al(e, t, r) { return (e === "video" || e === "audio") && t === "autoplay"; } function ys(e, t, r) { if (!e) return !1; if (e.nodeType !== e.ELEMENT_NODE) return !!r && ys(ye.parentNode(e), t, r); for (let s = e.classList.length; s--; ) { const n = e.classList[s]; if (t.test(n)) return !0; } return !!r && ys(ye.parentNode(e), t, r); } function Ml(e, t, r, s) { let n; if (xl(e)) { if (n = e, !ye.childNodes(n).length) return !1; } else { if (ye.parentElement(e) === null) return !1; n = ye.parentElement(e); } try { if (typeof t == "string") { if (s) { if (n.closest(`.${t}`)) return !0; } else if (n.classList.contains(t)) return !0; } else if (ys(n, t, s)) return !0; if (r) { if (s) { if (n.closest(r)) return !0; } else if (n.matches(r)) return !0; } } catch { } return !1; } function rp(e, t) { const { doc: r, mirror: s, blockClass: n, blockSelector: i, needsMask: a, inlineStylesheet: o, maskInputOptions: l = {}, maskTextFn: c, maskInputFn: u, dataURLOptions: d = {}, inlineImages: h, recordCanvas: f, keepIframeSrcFn: w, newlyAddedElement: p = !1 } = t, C = function(m, g) { if (!g.hasNode(m)) return; const v = g.getId(m); return v === 1 ? void 0 : v; }(r, s); switch (e.nodeType) { case e.DOCUMENT_NODE: return e.compatMode !== "CSS1Compat" ? { type: fe.Document, childNodes: [], compatMode: e.compatMode } : { type: fe.Document, childNodes: [] }; case e.DOCUMENT_TYPE_NODE: return { type: fe.DocumentType, name: e.name, publicId: e.publicId, systemId: e.systemId, rootId: C }; case e.ELEMENT_NODE: return function(m, g) { const { doc: v, blockClass: I, blockSelector: O, inlineStylesheet: E, maskInputOptions: A = {}, maskInputFn: M, dataURLOptions: k = {}, inlineImages: T, recordCanvas: R, keepIframeSrcFn: S, newlyAddedElement: P = !1, rootId: D } = g, b = function(L, _, ee) { try { if (typeof _ == "string") { if (L.classList.contains(_)) return !0; } else for (let q = L.classList.length; q--; ) { const me = L.classList[q]; if (_.test(me)) return !0; } if (ee) return L.matches(ee); } catch { } return !1; }(m, I, O), y = function(L) { if (L instanceof HTMLFormElement) return "form"; const _ = ft(L.tagName); return Xd.test(_) ? "div" : _; }(m); let U = {}; const F = m.attributes.length; for (let L = 0; L < F; L++) { const _ = m.attributes[L]; Al(y, _.name, _.value) || (U[_.name] = Ol(v, y, ft(_.name), _.value)); } if (y === "link" && E) { const L = Array.from(v.styleSheets).find((ee) => ee.href === m.href); let _ = null; L && (_ = qr(L)), _ && (delete U.rel, delete U.href, U._cssText = _); } if (y === "style" && m.sheet && !(m.innerText || ye.textContent(m) || "").trim().length) { const L = qr(m.sheet); L && (U._cssText = L); } if (y === "input" || y === "textarea" || y === "select") { const L = m.value, _ = m.checked; U.type !== "radio" && U.type !== "checkbox" && U.type !== "submit" && U.type !== "button" && L ? U.value = Ui({ element: m, type: Di(m), tagName: y, value: L, maskInputOptions: A, maskInputFn: M }) : _ && (U.checked = _); } if (y === "option" && (m.selected && !A.select ? U.selected = !0 : delete U.selected), y === "dialog" && m.open && (U.rr_open_mode = m.matches("dialog:modal") ? "modal" : "non-modal"), y === "canvas" && R) { if (m.__context === "2d") (function(L) { const _ = L.getContext("2d"); if (!_) return !0; for (let ee = 0; ee < L.width; ee += 50) for (let q = 0; q < L.height; q += 50) { const me = _.getImageData, _e = Lo in me ? me[Lo] : me; if (new Uint32Array(_e.call(_, ee, q, Math.min(50, L.width - ee), Math.min(50, L.height - q)).data.buffer).some((we) => we !== 0)) return !1; } return !0; })(m) || (U.rr_dataURL = m.toDataURL(k.type, k.quality)); else if (!("__context" in m)) { const L = m.toDataURL(k.type, k.quality), _ = v.createElement("canvas"); _.width = m.width, _.height = m.height, L !== _.toDataURL(k.type, k.quality) && (U.rr_dataURL = L); } } if (y === "img" && T) { vt || (vt = v.createElement("canvas"), Ao = vt.getContext("2d")); const L = m, _ = L.currentSrc || L.getAttribute("src") || "<unknown-src>", ee = L.crossOrigin, q = () => { L.removeEventListener("load", q); try { vt.width = L.naturalWidth, vt.height = L.naturalHeight, Ao.drawImage(L, 0, 0), U.rr_dataURL = vt.toDataURL(k.type, k.quality); } catch (me) { if (L.crossOrigin !== "anonymous") return L.crossOrigin = "anonymous", void (L.complete && L.naturalWidth !== 0 ? q() : L.addEventListener("load", q)); console.warn(`Cannot inline img src=${_}! Error: ${me}`); } L.crossOrigin === "anonymous" && (ee ? U.crossOrigin = ee : L.removeAttribute("crossorigin")); }; L.complete && L.naturalWidth !== 0 ? q() : L.addEventListener("load", q); } if (y === "audio" || y === "video") { const L = U; L.rr_mediaState = m.paused ? "paused" : "played", L.rr_mediaCurrentTime = m.currentTime, L.rr_mediaPlaybackRate = m.playbackRate, L.rr_mediaMuted = m.muted, L.rr_mediaLoop = m.loop, L.rr_mediaVolume = m.volume; } if (P || (m.scrollLeft && (U.rr_scrollLeft = m.scrollLeft), m.scrollTop && (U.rr_scrollTop = m.scrollTop)), b) { const { width: L, height: _ } = m.getBoundingClientRect(); U = { class: U.class, rr_width: `${L}px`, rr_height: `${_}px` }; } y !== "iframe" || S(U.src) || (m.contentDocument || (U.rr_src = U.src), delete U.src); let j; try { customElements.get(y) && (j = !0); } catch { } return { type: fe.Element, tagName: y, attributes: U, childNodes: [], isSVG: tp(m) || void 0, needBlock: b, rootId: D, isCustom: j }; }(e, { doc: r, blockClass: n, blockSelector: i, inlineStylesheet: o, maskInputOptions: l, maskInputFn: u, dataURLOptions: d, inlineImages: h, recordCanvas: f, keepIframeSrcFn: w, newlyAddedElement: p, rootId: C }); case e.TEXT_NODE: return function(m, g) { var v; const { needsMask: I, maskTextFn: O, rootId: E } = g, A = ye.parentNode(m), M = A && A.tagName; let k = ye.textContent(m); const T = M === "STYLE" || void 0, R = M === "SCRIPT" || void 0; if (T && k) { try { m.nextSibling || m.previousSibling || (v = A.sheet) != null && v.cssRules && (k = qr(A.sheet)); } catch (S) { console.warn(`Cannot get CSS styles from text's parentNode. Error: ${S}`, m); } k = gs(k, Pi(g.doc)); } return R && (k = "SCRIPT_PLACEHOLDER"), !T && !R && k && I && (k = O ? O(k, ye.parentElement(m)) : k.replace(/[\S]/g, "*")), { type: fe.Text, textContent: k || "", isStyle: T, rootId: E }; }(e, { doc: r, needsMask: a, maskTextFn: c, rootId: C }); case e.CDATA_SECTION_NODE: return { type: fe.CDATA, textContent: "", rootId: C }; case e.COMMENT_NODE: return { type: fe.Comment, textContent: ye.textContent(e) || "", rootId: C }; default: return !1; } } function te(e) { return e == null ? "" : e.toLowerCase(); } function Et(e, t) { const { doc: r, mirror: s, blockClass: n, blockSelector: i, maskTextClass: a, maskTextSelector: o, skipChild: l = !1, inlineStylesheet: c = !0, maskInputOptions: u = {}, maskTextFn: d, maskInputFn: h, slimDOMOptions: f, dataURLOptions: w = {}, inlineImages: p = !1, recordCanvas: C = !1, onSerialize: m, onIframeLoad: g, iframeLoadTimeout: v = 5e3, onStylesheetLoad: I, stylesheetLoadTimeout: O = 5e3, keepIframeSrcFn: E = () => !1, newlyAddedElement: A = !1 } = t; let { needsMask: M } = t, { preserveWhiteSpace: k = !0 } = t; M || (M = Ml(e, a, o, M === void 0)); const T = rp(e, { doc: r, mirror: s, blockClass: n, blockSelector: i, needsMask: M, inlineStylesheet: c, maskInputOptions: u, maskTextFn: d, maskInputFn: h, dataURLOptions: w, inlineImages: p, recordCanvas: C, keepIframeSrcFn: E, newlyAddedElement: A }); if (!T) return console.warn(e, "not serialized"), null; let R; R = s.hasNode(e) ? s.getId(e) : !function(b, y) { return !!(y.comment && b.type === fe.Comment || b.type === fe.Element && (y.script && (b.tagName === "script" || b.tagName === "link" && (b.attributes.rel === "preload" || b.attributes.rel === "modulepreload") && b.attributes.as === "script" || b.tagName === "link" && b.attributes.rel === "prefetch" && typeof b.attributes.href == "string" && Oo(b.attributes.href) === "js") || y.headFavicon && (b.tagName === "link" && b.attributes.rel === "shortcut icon" || b.tagName === "meta" && (te(b.attributes.name).match(/^msapplication-tile(image|color)$/) || te(b.attributes.name) === "application-name" || te(b.attributes.rel) === "icon" || te(b.attributes.rel) === "apple-touch-icon" || te(b.attributes.rel) === "shortcut icon")) || b.tagName === "meta" && (y.headMetaDescKeywords && te(b.attributes.name).match(/^description|keywords$/) || y.headMetaSocial && (te(b.attributes.property).match(/^(og|twitter|fb):/) || te(b.attributes.name).match(/^(og|twitter):/) || te(b.attributes.name) === "pinterest") || y.headMetaRobots && (te(b.attributes.name) === "robots" || te(b.attributes.name) === "googlebot" || te(b.attributes.name) === "bingbot") || y.headMetaHttpEquiv && b.attributes["http-equiv"] !== void 0 || y.headMetaAuthorship && (te(b.attributes.name) === "author" || te(b.attributes.name) === "generator" || te(b.attributes.name) === "framework" || te(b.attributes.name) === "publisher" || te(b.attributes.name) === "progid" || te(b.attributes.property).match(/^article:/) || te(b.attributes.property).match(/^product:/)) || y.headMetaVerification && (te(b.attributes.name) === "google-site-verification" || te(b.attributes.name) === "yandex-verification" || te(b.attributes.name) === "csrf-token" || te(b.attributes.name) === "p:domain_verify" || te(b.attributes.name) === "verify-v1" || te(b.attributes.name) === "verification" || te(b.attributes.name) === "shopify-checkout-api-token")))); }(T, f) && (k || T.type !== fe.Text || T.isStyle || T.textContent.replace(/^\s+|\s+$/gm, "").length) ? Ll() : -2; const S = Object.assign(T, { id: R }); if (s.add(e, S), R === -2) return null; m && m(e); let P = !l; if (S.type === fe.Element) { P = P && !S.needBlock, delete S.needBlock; const b = ye.shadowRoot(e); b && Xt(b) && (S.isShadowHost = !0); } if ((S.type === fe.Document || S.type === fe.Element) && P) { f.headWhitespace && S.type === fe.Element && S.tagName === "head" && (k = !1); const b = { doc: r, mirror: s, blockClass: n, blockSelector: i, needsMask: M, maskTextClass: a, maskTextSelector: o, skipChild: l, inlineStylesheet: c, maskInputOptions: u, maskTextFn: d, maskInputFn: h, slimDOMOptions: f, dataURLOptions: w, inlineImages: p, recordCanvas: C, preserveWhiteSpace: k, onSerialize: m, onIframeLoad: g, iframeLoadTimeout: v, onStylesheetLoad: I, stylesheetLoadTimeout: O, keepIframeSrcFn: E }; if (!(S.type === fe.Element && S.tagName === "textarea" && S.attributes.value !== void 0)) for (const U of Array.from(ye.childNodes(e))) { const F = Et(U, b); F && S.childNodes.push(F); } let y = null; if (xl(e) && (y = ye.shadowRoot(e))) for (const U of Array.from(ye.childNodes(y))) { const F = Et(U, b); F && (Xt(y) && (F.isShadow = !0), S.childNodes.push(F)); } } const D = ye.parentNode(e); return D && Zt(D) && Xt(D) && (S.isShadow = !0), S.type === fe.Element && S.tagName === "iframe" && function(b, y, U) { const F = b.contentWindow; if (!F) return; let j, L = !1; try { j = F.document.readyState;