@getopenpay/openpay-js
Version:
Accept payments through OpenPay, right on your site
1,766 lines • 1.06 MB
JavaScript
import { connectToChild as Gr } from "penpal";
import { z as a } from "zod";
import it from "chalk";
import { v4 as De } from "uuid";
function uo(e, t) {
var r = Object.setPrototypeOf;
r ? r(e, t) : e.__proto__ = t;
}
function po(e, t) {
t === void 0 && (t = e.constructor);
var r = Error.captureStackTrace;
r && r(e, t);
}
var mo = /* @__PURE__ */ (function() {
var e = function(r, n) {
return e = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function(o, i) {
o.__proto__ = i;
} || function(o, i) {
for (var s in i)
Object.prototype.hasOwnProperty.call(i, s) && (o[s] = i[s]);
}, e(r, n);
};
return function(t, r) {
if (typeof r != "function" && r !== null) throw new TypeError("Class extends value " + String(r) + " is not a constructor or null");
e(t, r);
function n() {
this.constructor = t;
}
t.prototype = r === null ? Object.create(r) : (n.prototype = r.prototype, new n());
};
})(), _o = (function(e) {
mo(t, e);
function t(r, n) {
var o = this.constructor, i = e.call(this, r, n) || this;
return Object.defineProperty(i, "name", {
value: o.name,
enumerable: !1,
configurable: !0
}), uo(i, o.prototype), po(i), i;
}
return t;
})(Error);
const A = a.string().trim().min(1, { message: "Please fill in this field" }), b = a.string().trim().optional(), x = (e) => a.nullable(e.optional());
var p = /* @__PURE__ */ ((e) => (e.FIRST_NAME = "firstName", e.LAST_NAME = "lastName", e.PHONE = "phone", e.EMAIL = "email", e.LINE1 = "line1", e.LINE2 = "line2", e.LINE3 = "line3", e.CITY = "city", e.STATE = "state", e.COUNTRY = "country", e.ZIP_CODE = "zipCode", e.SHIPPING_LINE1 = "shippingAddressLine1", e.SHIPPING_LINE2 = "shippingAddressLine2", e.SHIPPING_LINE3 = "shippingAddressLine3", e.SHIPPING_CITY = "shippingAddressCity", e.SHIPPING_STATE = "shippingAddressState", e.SHIPPING_COUNTRY = "shippingAddressCountry", e.SHIPPING_ZIP_CODE = "shippingAddressZipCode", e.IS_SHIPPING_SAME_AS_BILLING = "isShippingSameAsBilling", e.PROMOTION_CODE = "promotionCode", e.IS_BUSINESS_PURCHASE = "isBusinessPurchase", e.BUSINESS_NAME = "businessName", e.TAX_ID = "taxId", e.TAX_ID_TYPE = "taxIdType", e))(p || {});
const Vr = a.nativeEnum(p);
var qr = /* @__PURE__ */ ((e) => (e.CARD_NUMBER = "cardNumber", e.CARD_EXPIRY = "cardExpiry", e.CARD_CVC = "cardCvc", e))(qr || {});
const zr = a.nativeEnum(qr), Br = a.union([Vr, zr]);
var de = /* @__PURE__ */ ((e) => (e.CARD = "card", e.CARD_NUMBER = "card-number", e.CARD_EXPIRY = "card-expiry", e.CARD_CVC = "card-cvc", e.CDE_BRIDGE = "cde-bridge", e))(de || {});
const fo = a.enum(["card", "card-number", "card-expiry", "card-cvc", "cde-bridge"]), Et = a.object({
provider: a.string(),
processor_name: x(a.string()),
metadata: x(a.record(a.string(), a.any()))
}), yo = a.object({
id: a.string()
}), Ct = a.object({
backgroundColor: b,
color: b,
fontFamily: b,
fontSize: b,
fontWeight: b,
margin: b,
padding: b,
letterSpacing: b,
lineHeight: b,
hideIcon: b,
placeholderStyle: a.object({
color: b,
fontSize: b,
fontWeight: b,
fontFamily: b,
letterSpacing: b,
lineHeight: b
}).optional()
});
Ct.extend({
disableAutoFill: b,
placeholder: a.object({
cardNumber: b,
expiry: b,
cvc: b
}).optional()
});
Ct.extend({
disableAutoFill: b,
placeholder: a.string().optional(),
/**
* The card icon at the start of the card number input field
* It won't affect after the icon changed to card brand after the user input the card number
*/
icon: a.object({
color: a.string().optional()
}).optional()
});
Ct.extend({
disableAutoFill: b,
placeholder: a.string().optional()
});
Ct.extend({
disableAutoFill: b,
placeholder: a.string().optional()
});
const ne = a.enum([
// Element -> Form
"LAYOUT",
"LOADED",
"BLUR",
"FOCUS",
"CHANGE",
"TOKENIZE_STARTED",
"CHECKOUT_STARTED",
"PAYMENT_FLOW_STARTED",
"TOKENIZE_SUCCESS",
"CHECKOUT_SUCCESS",
"LOAD_ERROR",
"VALIDATION_ERROR",
"TOKENIZE_ERROR",
"CHECKOUT_ERROR",
"SETUP_PAYMENT_METHOD_SUCCESS",
// Form -> Element
"TOKENIZE",
"CHECKOUT",
"START_PAYMENT_FLOW"
]), ho = ne.extract(["TOKENIZE_STARTED", "CHECKOUT_STARTED"]), go = a.object({ type: ho }), wo = ne.extract(["BLUR", "FOCUS", "CHANGE"]), vo = a.object({
type: wo,
elementType: zr,
errors: a.array(a.string()).optional(),
obfuscatedValue: a.string().optional()
}), bo = ne.extract(["LOAD_ERROR", "TOKENIZE_ERROR", "CHECKOUT_ERROR"]), Po = a.object({
type: bo,
message: A,
headers: a.record(a.string(), a.string()).optional()
}), Eo = ne.extract(["VALIDATION_ERROR"]), Co = a.object({
type: Eo,
elementType: Br,
errors: a.array(a.string())
}), So = a.object({
type: a.literal(ne.enum.LAYOUT),
height: A
}), ko = a.object({
type: a.literal(ne.enum.LOADED),
sessionId: A,
totalAmountAtoms: a.number(),
currency: b,
checkoutPaymentMethods: a.array(Et)
}), Ao = a.object({
type: a.literal(ne.enum.PAYMENT_FLOW_STARTED),
nextActionMetadata: a.record(a.string(), a.any()),
paymentFlowMetadata: a.any().optional(),
startPFMetadata: a.optional(a.record(a.string(), a.any()))
}), Io = a.object({
type: a.literal(ne.enum.SETUP_PAYMENT_METHOD_SUCCESS),
paymentMethodId: a.string()
}), Fe = a.object({
email: A.email({ message: "Please enter a valid email address" }),
firstName: A,
lastName: A,
promotionCode: b,
line1: b,
line2: b,
line3: b,
city: b,
state: b,
country: A,
zipCode: b,
isShippingSameAsBilling: a.custom().optional().default(!0),
shippingAddressLine1: b,
shippingAddressLine2: b,
shippingAddressLine3: b,
shippingAddressCity: b,
shippingAddressState: b,
shippingAddressCountry: b,
shippingAddressZipCode: b,
businessName: b,
taxId: b,
taxIdType: b
}), Ro = a.object({
email: A.email({ message: "Please enter a valid email address" }),
firstName: b,
lastName: b,
promotionCode: b,
line1: b,
line2: b,
line3: b,
city: b,
state: b,
country: A,
zipCode: b,
isShippingSameAsBilling: a.custom().optional().default(!0),
shippingAddressLine1: b,
shippingAddressLine2: b,
shippingAddressLine3: b,
shippingAddressCity: b,
shippingAddressState: b,
shippingAddressCountry: b,
shippingAddressZipCode: b,
businessName: b,
taxId: b,
taxIdType: b
});
a.object({
line1: A,
city: A,
state: A,
country: A
});
a.object({
shippingAddressCountry: A,
shippingAddressZipCode: A
});
a.object({
shippingAddressLine1: A,
shippingAddressCity: A,
shippingAddressState: A,
shippingAddressCountry: A,
shippingAddressZipCode: A
});
const To = ne.extract(["TOKENIZE", "CHECKOUT", "START_PAYMENT_FLOW"]), No = a.object({
type: To,
sessionId: A,
checkoutPaymentMethod: Et,
paymentFlowMetadata: a.any().optional(),
doNotUseLegacyCCFlow: a.boolean().optional(),
existingCCPMId: b,
paymentRouteId: b
}).extend(Fe.shape), Fo = a.object({
type: a.literal(ne.enum.TOKENIZE_SUCCESS),
isReadyForCheckout: a.boolean()
}), Lo = a.object({
type: a.literal(ne.enum.CHECKOUT_SUCCESS),
invoiceUrls: a.array(a.string()),
subscriptionIds: a.array(a.string()),
customerId: a.string(),
paymentMethodId: b
}), Mo = a.discriminatedUnion("type", [
go,
vo,
Po,
Co,
So,
ko,
No,
Fo,
Lo,
Ao,
Io
]), xo = a.object({
payload: Mo,
nonce: A,
formId: A,
elementId: A
});
a.object({
amountAtom: a.number(),
/**
* The three-letter ISO 4217 currency code for the payment.
*/
currency: A
});
a.enum(["apple_pay", "google_pay"]);
a.object({
secure_token: a.string(),
promotion_code: a.string().optional()
});
a.object({
secure_token: a.string(),
existing_cc_pm_id: x(a.string()),
their_pm_id: x(a.string()),
checkout_attempt_id: x(a.string()),
processor_specific_metadata: x(a.record(a.string(), a.any()))
});
const Ze = a.object({
invoice_urls: a.array(a.string()),
subscription_ids: a.array(a.string()),
customer_id: a.string(),
payment_method_id: x(a.string()),
processors_used: x(a.array(a.string()))
}), Do = a.object({
elementType: a.string(),
errors: a.array(a.string())
});
a.object({
session_id: a.string()
});
const Oo = a.object({
success: a.literal(!1),
error_type: a.literal("validation_error"),
errors: a.array(Do)
}), Uo = a.discriminatedUnion("success", [
a.object({ success: a.literal(!0) }),
Oo
]);
a.object({
session_id: a.string(),
checkout_payment_method: Et,
non_cde_form_fields: Fe,
do_not_use_legacy_cc_flow: a.boolean().optional(),
existing_cc_pm_id: x(a.string()),
extra_metadata: a.record(a.string(), a.any()),
payment_route_id: x(a.string()),
customer_language: x(a.string())
});
a.object({
session_id: a.string(),
checkout_payment_method: Et,
non_cde_form_fields: Fe,
extra_metadata: a.record(a.string(), a.any()).optional(),
payment_route_id: x(a.string()),
customer_language: x(a.string())
});
var N = /* @__PURE__ */ ((e) => (e.SUCCESS = "success", e.FAILURE = "failure", e.CANCELLED = "cancelled", e))(N || {});
const Hr = a.object({
status: a.enum([
"success",
"failure",
"cancelled"
/* CANCELLED */
]),
href: a.string().optional().nullable()
});
a.object({
href: a.string().optional().nullable()
});
const jo = a.object({
type: a.string(),
redirect_url: a.string(),
initial_intent_id: a.string(),
consent_id: a.string(),
their_pm_id: a.string().optional()
}), $o = a.object({
bank_name: a.string(),
display_name: a.string(),
resources: a.object({
logo_url: a.string().optional()
})
}), Yr = a.object({
type: a.string(),
redirect_url: x(a.string()),
initial_intent_id: x(a.string()),
consent_id: x(a.string()),
their_pm_id: x(a.string()),
payment_session: x(a.record(a.string(), a.any())),
available_banks: x(a.array($o))
}), Go = a.discriminatedUnion("present", [
a.object({ present: a.literal(!0), href: a.string() }),
a.object({ present: a.literal(!1) })
]), Vo = a.object({
payment_methods: a.array(yo),
pay_first_success_response: x(Ze),
required_user_actions: x(a.array(Yr)),
post_checkout_redirect_to: x(a.string()),
checkout_success_response: x(Ze)
}), qo = a.object({
institutionNumber: a.string(),
transitNumber: a.string(),
accountNumber: a.string(),
accountType: a.enum(["personal", "business"])
});
a.object({
status: a.enum(["success", "failure"]),
payload: qo.optional()
});
const zo = a.object({
sortCode: a.string(),
accountNumber: a.string(),
accountType: a.enum(["personal", "business"])
});
a.object({
status: a.enum(["success", "failure"]),
payload: zo.optional()
});
const Bo = a.object({
iban: a.string(),
accountType: a.enum(["personal", "business"])
});
a.object({
status: a.enum(["success", "failure"]),
payload: Bo.optional()
});
const Ho = a.object({
account_number: a.string(),
aba_routing_number: a.string()
}), Yo = a.object({
institution_number: a.string(),
transit_number: a.string(),
account_number: a.string()
}), Wo = a.object({
account_number: a.string(),
sort_code: a.string()
}), Jo = a.object({
iban: a.string()
}), Zo = a.object({
status: a.enum(["success", "failure"]),
payload: a.union([
Ho,
Yo,
Wo,
Jo,
a.object({ error: a.string() })
]).optional()
}), P = (e) => a.nullable(e.optional());
a.string().trim().min(1, { message: "Cannot be blank" });
const Ko = a.object({
cde_response_type: a.literal("error"),
message: a.string(),
headers: a.record(a.string(), a.string()).optional()
});
a.enum(["usd", "brl"]);
const Wr = a.object({
name: a.string(),
amount_atom_off: P(a.number()),
percent_off: P(a.number()),
currency: P(a.string()),
duration: a.string(),
duration_in_months: P(a.number())
}), Jr = a.object({
amount_subtotal_atom: a.number().int(),
amount_total_atom: a.number().int(),
currency: a.string(),
description: P(a.string()),
price_id: a.string(),
billing_interval: P(a.string()),
billing_interval_count: P(a.number().int()),
quantity: a.number().int()
}), Qo = a.record(a.string(), a.any()), Xo = a.object({
name: a.string(),
settings: P(Qo)
}), Oe = a.object({
provider: a.string(),
processor_name: P(a.string()),
metadata: P(a.record(a.string(), a.any()))
}), ea = a.object({
quantity: a.number()
}), ta = a.object({
id: P(a.string()),
billing_interval: P(a.string()),
billing_interval_count: P(a.number().int()),
subscription_items: a.array(ea),
trial_start: P(a.string()),
trial_end: P(a.string())
}), Zr = a.object({
amount_atom: a.number()
}), ra = a.object({
amount_atom: a.number(),
amount_atom_considering_discount_applied: a.number(),
currency: a.string(),
discount_amount_atoms: a.array(Zr),
subscription_item_id: a.string()
}), na = a.object({
coupon: Wr
}), oa = a.object({
currency: a.string(),
discounts: a.array(na),
hosted_invoice_url: P(a.string()),
lines: a.array(ra),
remaining_amount_atom: a.number(),
tax_amount_atom: a.number(),
total_amount_atom: a.number(),
total_discount_amount_atoms: a.array(Zr)
}), mr = a.object({
created: a.array(ta),
invoices: a.array(oa),
processors_used: P(a.array(a.string())),
payment_method_id: P(a.string())
}), Kr = a.object({
preview: mr,
preview_post_trial: P(mr),
coupons: a.array(Wr)
}), _r = a.object({
status: a.literal("open"),
locale: P(a.string()),
token: a.string(),
email: P(a.string()),
checkout_settings: a.record(a.string(), a.any()),
line_items: a.array(Jr),
amount_subtotal_atom: a.number().int(),
amount_total_atom: a.number().int(),
brand: Xo,
subs_preview: P(Kr),
// Null in setup mode
methods_available: a.array(Oe),
return_url: P(a.string()),
success_url: P(a.string()),
final_feature_rollout_settings: P(a.record(a.string(), a.any()))
}), Qr = a.discriminatedUnion("mode", [
a.object({
mode: a.literal("setup"),
currency: a.nullable(a.undefined())
}).extend(_r.shape),
a.object({
mode: a.enum(["payment", "subscription"]),
currency: a.string()
}).extend(_r.shape)
]), aa = a.object({
status: a.literal("complete")
}), ia = a.object({
status: a.literal("expired")
});
a.union([Qr, aa, ia]);
a.object({
logo: a.string(),
icon: a.string(),
primary_color: a.string(),
secondary_color: a.string()
});
a.object({
secure_token: a.string(),
pm_id: a.string()
});
const ft = a.object({
line1: a.string().optional(),
line2: a.string().optional(),
line3: a.string().optional(),
city: a.string().optional(),
state: a.string().optional(),
country: a.string(),
zip_code: a.string().optional()
});
a.object({
secure_token: a.string(),
payment_input: a.any(),
// Should follow AnyPaymentInput from CDE
customer_email: a.string(),
customer_last_name: a.string().optional(),
customer_first_name: a.string().optional(),
customer_address: ft,
customer_shipping_address: ft.optional(),
line_items: a.array(Jr),
total_amount_atom: a.number().int(),
cancel_at_end: a.boolean(),
checkout_payment_method: Oe,
promotion_code: a.string().optional(),
do_not_use_legacy_cc_flow: a.boolean().optional(),
use_confirmed_pm_id: P(a.string()),
payment_route_id: P(a.string())
});
const Xr = a.object({
payment_method_id: a.string()
});
a.object({
id: a.string(),
return_url: a.string()
});
const sa = a.object({
type: a.string(),
loc: a.array(a.string()),
msg: a.string(),
url: a.string()
});
a.array(sa);
const ca = a.object({
new_customer_email: a.string().optional(),
new_customer_last_name: a.string().optional(),
new_customer_first_name: a.string().optional(),
customer_business_name: a.string().optional(),
customer_tax_id: a.string().optional(),
customer_tax_id_type: a.string().optional(),
new_customer_address: ft,
new_customer_shipping_address: ft.optional()
}), la = a.object({
price_id: a.string(),
quantity: a.number().int()
}), en = a.object({
line_items: a.array(la),
promotion_code: a.string().optional(),
displayed_total_amount_atom: a.number().int()
}), ua = a.object({
processor_specific_metadata: P(a.record(a.string(), a.any()))
});
a.object({
payment_provider: a.string(),
checkout_payment_method: Oe,
existing_cc_pm_id: a.string().optional(),
their_existing_pm_id: a.string().optional(),
use_pay_first_flow: a.boolean().optional(),
pay_first_flow_cart_info: en.optional(),
customer_language: a.string().optional()
}).extend(ca.shape).extend(ua.shape);
const tn = a.object({
required_user_actions: a.array(a.record(a.string(), a.any())),
checkout_attempt_id: P(a.string())
});
a.object({
fields: Ro,
checkoutPaymentMethod: Oe,
payment_route_id: P(a.string())
});
a.object({
session_id: a.string(),
non_cde_form_fields: Fe,
checkout_payment_method: Oe,
extra_metadata: a.record(a.string(), a.any()),
// This is optional in CDE, but not in OJS moving forward
use_unified_cc_flow: P(a.boolean()),
pay_first_flow_cart_info: en.optional(),
payment_route_id: P(a.string()),
customer_language: a.string().optional(),
existing_cc_pm_id: P(a.string())
});
const da = a.object({
required_user_actions: a.array(a.record(a.string(), a.any())),
cc_pm_id: a.string(),
checkout_success_response: P(Ze),
checkout_attempt_id: P(a.string())
});
a.record(a.any());
a.object({
first_name: P(a.string()),
last_name: P(a.string()),
line1: P(a.string()),
line2: P(a.string()),
line3: P(a.string()),
city: P(a.string()),
state: P(a.string()),
country: P(a.string()),
zip_code: P(a.string()),
email: P(a.string()),
billing_email: P(a.string()),
phone_number: P(a.string()),
business_name: P(a.string()),
tax_id: P(a.string()),
tax_id_type: P(a.string()),
update_processor_customer: P(a.boolean())
});
a.object({
id: a.string(),
email: P(a.string()),
first_name: P(a.string()),
last_name: P(a.string()),
phone_number: P(a.string()),
billing_email: P(a.string()),
address: P(a.record(a.string(), a.any()))
});
a.object({
message: a.string()
});
const pa = a.object({
error_code: a.string()
});
a.object({
checkout_payment_method: Oe,
processor_specific_metadata: a.record(a.any()).optional(),
payment_route_id: P(a.string())
});
const ma = a.object({
next_action_metadata: P(a.record(a.any()))
});
a.object({
events: a.array(
a.object({
event_name: a.string(),
device_token: a.string(),
properties: a.record(a.any()).optional(),
context_properties: a.record(a.any()).optional()
})
)
});
a.any().optional();
a.object({
device_token: a.string()
});
const _a = a.object({}), fa = a.object({
_unified_cc_action_name: a.string(),
_unified_cc_pccs_id: a.string()
}).catchall(a.any()), ya = a.object({
type: a.string(),
loc: a.array(a.string()),
msg: a.string(),
url: a.string()
}), ha = a.array(ya), ga = a.object({
code: a.string(),
message: a.string(),
path: a.array(a.string())
}), wa = a.array(ga), va = {
"failed to fetch": "Connection error: please double check if you are connected to the internet, then try again"
}, Vt = (e) => {
const t = e.toLowerCase().trim();
return va[t] ?? e;
}, ba = (e) => {
try {
return typeof JSON.parse(e) == "object";
} catch {
return !1;
}
}, Pa = (e) => e.length === 1 ? Vt(e[0].msg) : `Please fix the following errors:
${e.map((r) => `• ${Vt(r.msg)}`).join(`
`)}`, Ea = (e) => `Encountered the following errors:
${e.map((r) => `- ${r.path.join("/")}: ${r.message}`).join(`
`)}`, K = (e) => {
if (e instanceof Error)
if (ba(e.message)) {
const t = JSON.parse(e.message);
return ha.safeParse(t).success ? Pa(t) : wa.safeParse(t).success ? Ea(t) : (console.warn(`Encountered unknown stringified JSON object:
${e.message}`), e.message);
} else
return Vt(e.message);
if (typeof e == "object")
try {
return JSON.stringify(e);
} catch (t) {
return t + "";
}
else
return e + "";
}, Ca = (e, t, r) => ((...n) => {
try {
return t(...n);
} catch (o) {
r(`[form] Error running callback (${e}):`, o);
return;
}
}), Sa = (e) => e.reduce((t, r) => t + r, 0), rn = (e) => {
e.preventDefault(), e.returnValue = !0;
}, ka = () => {
window.addEventListener("beforeunload", rn);
}, Aa = () => {
window.removeEventListener("beforeunload", rn);
}, z = (e) => {
let t = !1;
return async (r) => {
if (t) {
console.warn("Skipping submission because it is already in progress");
return;
}
t = !0;
try {
r.context.preventNavigationDuringSubmission && ka(), r.formCallbacks.get.onCheckoutStarted?.(), g("checkout_started", {
cpm: r.checkoutPaymentMethod
});
const n = await e(r);
if (g("checkout_success", {
cpm: r.checkoutPaymentMethod,
...n
}), Ai(), n.mode === "setup")
r.formCallbacks.get.onSetupPaymentMethodSuccess(n.result.payment_method_id);
else if (n.mode === "checkout")
r.formCallbacks.get.onCheckoutSuccess(
n.result.invoice_urls,
n.result.subscription_ids,
n.result.customer_id,
n.result.processors_used ?? [],
n.result.payment_method_id ?? ""
);
else
throw new Error(`Unhandled mode: ${n}`);
} catch (n) {
t = !1;
const o = K(n), i = await En(r.context.anyCdeConnection, o);
r.formCallbacks.get.onCheckoutError(o, i), g("checkout_error", { cpm: r.checkoutPaymentMethod, errorMessage: o, errorCode: i, error: n });
} finally {
t = !1, r.context.preventNavigationDuringSubmission && Aa();
}
};
}, me = (e) => async (t) => {
try {
return await e(t);
} catch (r) {
const { err__: n } = I("init-error-catcher"), o = K(r), i = await En(t.context.anyCdeConnection, o);
return n(i, o, r), g("init_flow_error", { errorMessage: o, errorCode: i, error: r }), { isAvailable: !1, reason: o, errorCode: i, isLoading: !1 };
}
}, I = (e) => {
const t = (...n) => {
window.console.log(`${it.green.bold("ojs/")}${it.bold.gray(`${e}`)} `, ...n);
}, r = (...n) => {
window.console.warn(`${it.red.bold("ojs/")}${it.bold.gray(`${e}`)} `, ...n);
};
return {
log: t,
err: r,
log__: t,
err__: r
};
};
var qt = function(e, t) {
return qt = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(r, n) {
r.__proto__ = n;
} || function(r, n) {
for (var o in n) Object.prototype.hasOwnProperty.call(n, o) && (r[o] = n[o]);
}, qt(e, t);
};
function ve(e, t) {
if (typeof t != "function" && t !== null)
throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
qt(e, t);
function r() {
this.constructor = e;
}
e.prototype = t === null ? Object.create(t) : (r.prototype = t.prototype, new r());
}
function Ia(e, t, r, n) {
function o(i) {
return i instanceof r ? i : new r(function(s) {
s(i);
});
}
return new (r || (r = Promise))(function(i, s) {
function c(d) {
try {
u(n.next(d));
} catch (f) {
s(f);
}
}
function l(d) {
try {
u(n.throw(d));
} catch (f) {
s(f);
}
}
function u(d) {
d.done ? i(d.value) : o(d.value).then(c, l);
}
u((n = n.apply(e, t || [])).next());
});
}
function nn(e, t) {
var r = { label: 0, sent: function() {
if (i[0] & 1) throw i[1];
return i[1];
}, trys: [], ops: [] }, n, o, i, s = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
return s.next = c(0), s.throw = c(1), s.return = c(2), typeof Symbol == "function" && (s[Symbol.iterator] = function() {
return this;
}), s;
function c(u) {
return function(d) {
return l([u, d]);
};
}
function l(u) {
if (n) throw new TypeError("Generator is already executing.");
for (; s && (s = 0, u[0] && (r = 0)), r; ) try {
if (n = 1, o && (i = u[0] & 2 ? o.return : u[0] ? o.throw || ((i = o.return) && i.call(o), 0) : o.next) && !(i = i.call(o, u[1])).done) return i;
switch (o = 0, i && (u = [u[0] & 2, i.value]), u[0]) {
case 0:
case 1:
i = u;
break;
case 4:
return r.label++, { value: u[1], done: !1 };
case 5:
r.label++, o = u[1], u = [0];
continue;
case 7:
u = r.ops.pop(), r.trys.pop();
continue;
default:
if (i = r.trys, !(i = i.length > 0 && i[i.length - 1]) && (u[0] === 6 || u[0] === 2)) {
r = 0;
continue;
}
if (u[0] === 3 && (!i || u[1] > i[0] && u[1] < i[3])) {
r.label = u[1];
break;
}
if (u[0] === 6 && r.label < i[1]) {
r.label = i[1], i = u;
break;
}
if (i && r.label < i[2]) {
r.label = i[2], r.ops.push(u);
break;
}
i[2] && r.ops.pop(), r.trys.pop();
continue;
}
u = t.call(e, r);
} catch (d) {
u = [6, d], o = 0;
} finally {
n = i = 0;
}
if (u[0] & 5) throw u[1];
return { value: u[0] ? u[1] : void 0, done: !0 };
}
}
function Le(e) {
var t = typeof Symbol == "function" && Symbol.iterator, r = t && e[t], n = 0;
if (r) return r.call(e);
if (e && typeof e.length == "number") return {
next: function() {
return e && n >= e.length && (e = void 0), { value: e && e[n++], done: !e };
}
};
throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function yt(e, t) {
var r = typeof Symbol == "function" && e[Symbol.iterator];
if (!r) return e;
var n = r.call(e), o, i = [], s;
try {
for (; (t === void 0 || t-- > 0) && !(o = n.next()).done; ) i.push(o.value);
} catch (c) {
s = { error: c };
} finally {
try {
o && !o.done && (r = n.return) && r.call(n);
} finally {
if (s) throw s.error;
}
}
return i;
}
function ht(e, t, r) {
if (r || arguments.length === 2) for (var n = 0, o = t.length, i; n < o; n++)
(i || !(n in t)) && (i || (i = Array.prototype.slice.call(t, 0, n)), i[n] = t[n]);
return e.concat(i || Array.prototype.slice.call(t));
}
function Re(e) {
return this instanceof Re ? (this.v = e, this) : new Re(e);
}
function Ra(e, t, r) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var n = r.apply(e, t || []), o, i = [];
return o = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), c("next"), c("throw"), c("return", s), o[Symbol.asyncIterator] = function() {
return this;
}, o;
function s(m) {
return function(y) {
return Promise.resolve(y).then(m, f);
};
}
function c(m, y) {
n[m] && (o[m] = function(h) {
return new Promise(function(w, E) {
i.push([m, h, w, E]) > 1 || l(m, h);
});
}, y && (o[m] = y(o[m])));
}
function l(m, y) {
try {
u(n[m](y));
} catch (h) {
_(i[0][3], h);
}
}
function u(m) {
m.value instanceof Re ? Promise.resolve(m.value.v).then(d, f) : _(i[0][2], m);
}
function d(m) {
l("next", m);
}
function f(m) {
l("throw", m);
}
function _(m, y) {
m(y), i.shift(), i.length && l(i[0][0], i[0][1]);
}
}
function Ta(e) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var t = e[Symbol.asyncIterator], r;
return t ? t.call(e) : (e = typeof Le == "function" ? Le(e) : e[Symbol.iterator](), r = {}, n("next"), n("throw"), n("return"), r[Symbol.asyncIterator] = function() {
return this;
}, r);
function n(i) {
r[i] = e[i] && function(s) {
return new Promise(function(c, l) {
s = e[i](s), o(c, l, s.done, s.value);
});
};
}
function o(i, s, c, l) {
Promise.resolve(l).then(function(u) {
i({ value: u, done: c });
}, s);
}
}
function G(e) {
return typeof e == "function";
}
function St(e) {
var t = function(n) {
Error.call(n), n.stack = new Error().stack;
}, r = e(t);
return r.prototype = Object.create(Error.prototype), r.prototype.constructor = r, r;
}
var xt = St(function(e) {
return function(r) {
e(this), this.message = r ? r.length + ` errors occurred during unsubscription:
` + r.map(function(n, o) {
return o + 1 + ") " + n.toString();
}).join(`
`) : "", this.name = "UnsubscriptionError", this.errors = r;
};
});
function gt(e, t) {
if (e) {
var r = e.indexOf(t);
0 <= r && e.splice(r, 1);
}
}
var rt = (function() {
function e(t) {
this.initialTeardown = t, this.closed = !1, this._parentage = null, this._finalizers = null;
}
return e.prototype.unsubscribe = function() {
var t, r, n, o, i;
if (!this.closed) {
this.closed = !0;
var s = this._parentage;
if (s)
if (this._parentage = null, Array.isArray(s))
try {
for (var c = Le(s), l = c.next(); !l.done; l = c.next()) {
var u = l.value;
u.remove(this);
}
} catch (h) {
t = { error: h };
} finally {
try {
l && !l.done && (r = c.return) && r.call(c);
} finally {
if (t) throw t.error;
}
}
else
s.remove(this);
var d = this.initialTeardown;
if (G(d))
try {
d();
} catch (h) {
i = h instanceof xt ? h.errors : [h];
}
var f = this._finalizers;
if (f) {
this._finalizers = null;
try {
for (var _ = Le(f), m = _.next(); !m.done; m = _.next()) {
var y = m.value;
try {
fr(y);
} catch (h) {
i = i ?? [], h instanceof xt ? i = ht(ht([], yt(i)), yt(h.errors)) : i.push(h);
}
}
} catch (h) {
n = { error: h };
} finally {
try {
m && !m.done && (o = _.return) && o.call(_);
} finally {
if (n) throw n.error;
}
}
}
if (i)
throw new xt(i);
}
}, e.prototype.add = function(t) {
var r;
if (t && t !== this)
if (this.closed)
fr(t);
else {
if (t instanceof e) {
if (t.closed || t._hasParent(this))
return;
t._addParent(this);
}
(this._finalizers = (r = this._finalizers) !== null && r !== void 0 ? r : []).push(t);
}
}, e.prototype._hasParent = function(t) {
var r = this._parentage;
return r === t || Array.isArray(r) && r.includes(t);
}, e.prototype._addParent = function(t) {
var r = this._parentage;
this._parentage = Array.isArray(r) ? (r.push(t), r) : r ? [r, t] : t;
}, e.prototype._removeParent = function(t) {
var r = this._parentage;
r === t ? this._parentage = null : Array.isArray(r) && gt(r, t);
}, e.prototype.remove = function(t) {
var r = this._finalizers;
r && gt(r, t), t instanceof e && t._removeParent(this);
}, e.EMPTY = (function() {
var t = new e();
return t.closed = !0, t;
})(), e;
})(), on = rt.EMPTY;
function an(e) {
return e instanceof rt || e && "closed" in e && G(e.remove) && G(e.add) && G(e.unsubscribe);
}
function fr(e) {
G(e) ? e() : e.unsubscribe();
}
var Na = {
Promise: void 0
}, Fa = {
setTimeout: function(e, t) {
for (var r = [], n = 2; n < arguments.length; n++)
r[n - 2] = arguments[n];
return setTimeout.apply(void 0, ht([e, t], yt(r)));
},
clearTimeout: function(e) {
return clearTimeout(e);
},
delegate: void 0
};
function sn(e) {
Fa.setTimeout(function() {
throw e;
});
}
function yr() {
}
function pt(e) {
e();
}
var Jt = (function(e) {
ve(t, e);
function t(r) {
var n = e.call(this) || this;
return n.isStopped = !1, r ? (n.destination = r, an(r) && r.add(n)) : n.destination = xa, n;
}
return t.create = function(r, n, o) {
return new zt(r, n, o);
}, t.prototype.next = function(r) {
this.isStopped || this._next(r);
}, t.prototype.error = function(r) {
this.isStopped || (this.isStopped = !0, this._error(r));
}, t.prototype.complete = function() {
this.isStopped || (this.isStopped = !0, this._complete());
}, t.prototype.unsubscribe = function() {
this.closed || (this.isStopped = !0, e.prototype.unsubscribe.call(this), this.destination = null);
}, t.prototype._next = function(r) {
this.destination.next(r);
}, t.prototype._error = function(r) {
try {
this.destination.error(r);
} finally {
this.unsubscribe();
}
}, t.prototype._complete = function() {
try {
this.destination.complete();
} finally {
this.unsubscribe();
}
}, t;
})(rt), La = (function() {
function e(t) {
this.partialObserver = t;
}
return e.prototype.next = function(t) {
var r = this.partialObserver;
if (r.next)
try {
r.next(t);
} catch (n) {
st(n);
}
}, e.prototype.error = function(t) {
var r = this.partialObserver;
if (r.error)
try {
r.error(t);
} catch (n) {
st(n);
}
else
st(t);
}, e.prototype.complete = function() {
var t = this.partialObserver;
if (t.complete)
try {
t.complete();
} catch (r) {
st(r);
}
}, e;
})(), zt = (function(e) {
ve(t, e);
function t(r, n, o) {
var i = e.call(this) || this, s;
return G(r) || !r ? s = {
next: r ?? void 0,
error: n ?? void 0,
complete: o ?? void 0
} : s = r, i.destination = new La(s), i;
}
return t;
})(Jt);
function st(e) {
sn(e);
}
function Ma(e) {
throw e;
}
var xa = {
closed: !0,
next: yr,
error: Ma,
complete: yr
}, Zt = (function() {
return typeof Symbol == "function" && Symbol.observable || "@@observable";
})();
function Da(e) {
return e;
}
function Oa(e) {
return e.length === 0 ? Da : e.length === 1 ? e[0] : function(r) {
return e.reduce(function(n, o) {
return o(n);
}, r);
};
}
var pe = (function() {
function e(t) {
t && (this._subscribe = t);
}
return e.prototype.lift = function(t) {
var r = new e();
return r.source = this, r.operator = t, r;
}, e.prototype.subscribe = function(t, r, n) {
var o = this, i = ja(t) ? t : new zt(t, r, n);
return pt(function() {
var s = o, c = s.operator, l = s.source;
i.add(c ? c.call(i, l) : l ? o._subscribe(i) : o._trySubscribe(i));
}), i;
}, e.prototype._trySubscribe = function(t) {
try {
return this._subscribe(t);
} catch (r) {
t.error(r);
}
}, e.prototype.forEach = function(t, r) {
var n = this;
return r = hr(r), new r(function(o, i) {
var s = new zt({
next: function(c) {
try {
t(c);
} catch (l) {
i(l), s.unsubscribe();
}
},
error: i,
complete: o
});
n.subscribe(s);
});
}, e.prototype._subscribe = function(t) {
var r;
return (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(t);
}, e.prototype[Zt] = function() {
return this;
}, e.prototype.pipe = function() {
for (var t = [], r = 0; r < arguments.length; r++)
t[r] = arguments[r];
return Oa(t)(this);
}, e.prototype.toPromise = function(t) {
var r = this;
return t = hr(t), new t(function(n, o) {
var i;
r.subscribe(function(s) {
return i = s;
}, function(s) {
return o(s);
}, function() {
return n(i);
});
});
}, e.create = function(t) {
return new e(t);
}, e;
})();
function hr(e) {
var t;
return (t = e ?? Na.Promise) !== null && t !== void 0 ? t : Promise;
}
function Ua(e) {
return e && G(e.next) && G(e.error) && G(e.complete);
}
function ja(e) {
return e && e instanceof Jt || Ua(e) && an(e);
}
function $a(e) {
return G(e?.lift);
}
function Ga(e) {
return function(t) {
if ($a(t))
return t.lift(function(r) {
try {
return e(r, this);
} catch (n) {
this.error(n);
}
});
throw new TypeError("Unable to lift unknown Observable type");
};
}
function Va(e, t, r, n, o) {
return new qa(e, t, r, n, o);
}
var qa = (function(e) {
ve(t, e);
function t(r, n, o, i, s, c) {
var l = e.call(this, r) || this;
return l.onFinalize = s, l.shouldUnsubscribe = c, l._next = n ? function(u) {
try {
n(u);
} catch (d) {
r.error(d);
}
} : e.prototype._next, l._error = i ? function(u) {
try {
i(u);
} catch (d) {
r.error(d);
} finally {
this.unsubscribe();
}
} : e.prototype._error, l._complete = o ? function() {
try {
o();
} catch (u) {
r.error(u);
} finally {
this.unsubscribe();
}
} : e.prototype._complete, l;
}
return t.prototype.unsubscribe = function() {
var r;
if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
var n = this.closed;
e.prototype.unsubscribe.call(this), !n && ((r = this.onFinalize) === null || r === void 0 || r.call(this));
}
}, t;
})(Jt), za = St(function(e) {
return function() {
e(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
};
}), cn = (function(e) {
ve(t, e);
function t() {
var r = e.call(this) || this;
return r.closed = !1, r.currentObservers = null, r.observers = [], r.isStopped = !1, r.hasError = !1, r.thrownError = null, r;
}
return t.prototype.lift = function(r) {
var n = new gr(this, this);
return n.operator = r, n;
}, t.prototype._throwIfClosed = function() {
if (this.closed)
throw new za();
}, t.prototype.next = function(r) {
var n = this;
pt(function() {
var o, i;
if (n._throwIfClosed(), !n.isStopped) {
n.currentObservers || (n.currentObservers = Array.from(n.observers));
try {
for (var s = Le(n.currentObservers), c = s.next(); !c.done; c = s.next()) {
var l = c.value;
l.next(r);
}
} catch (u) {
o = { error: u };
} finally {
try {
c && !c.done && (i = s.return) && i.call(s);
} finally {
if (o) throw o.error;
}
}
}
});
}, t.prototype.error = function(r) {
var n = this;
pt(function() {
if (n._throwIfClosed(), !n.isStopped) {
n.hasError = n.isStopped = !0, n.thrownError = r;
for (var o = n.observers; o.length; )
o.shift().error(r);
}
});
}, t.prototype.complete = function() {
var r = this;
pt(function() {
if (r._throwIfClosed(), !r.isStopped) {
r.isStopped = !0;
for (var n = r.observers; n.length; )
n.shift().complete();
}
});
}, t.prototype.unsubscribe = function() {
this.isStopped = this.closed = !0, this.observers = this.currentObservers = null;
}, Object.defineProperty(t.prototype, "observed", {
get: function() {
var r;
return ((r = this.observers) === null || r === void 0 ? void 0 : r.length) > 0;
},
enumerable: !1,
configurable: !0
}), t.prototype._trySubscribe = function(r) {
return this._throwIfClosed(), e.prototype._trySubscribe.call(this, r);
}, t.prototype._subscribe = function(r) {
return this._throwIfClosed(), this._checkFinalizedStatuses(r), this._innerSubscribe(r);
}, t.prototype._innerSubscribe = function(r) {
var n = this, o = this, i = o.hasError, s = o.isStopped, c = o.observers;
return i || s ? on : (this.currentObservers = null, c.push(r), new rt(function() {
n.currentObservers = null, gt(c, r);
}));
}, t.prototype._checkFinalizedStatuses = function(r) {
var n = this, o = n.hasError, i = n.thrownError, s = n.isStopped;
o ? r.error(i) : s && r.complete();
}, t.prototype.asObservable = function() {
var r = new pe();
return r.source = this, r;
}, t.create = function(r, n) {
return new gr(r, n);
}, t;
})(pe), gr = (function(e) {
ve(t, e);
function t(r, n) {
var o = e.call(this) || this;
return o.destination = r, o.source = n, o;
}
return t.prototype.next = function(r) {
var n, o;
(o = (n = this.destination) === null || n === void 0 ? void 0 : n.next) === null || o === void 0 || o.call(n, r);
}, t.prototype.error = function(r) {
var n, o;
(o = (n = this.destination) === null || n === void 0 ? void 0 : n.error) === null || o === void 0 || o.call(n, r);
}, t.prototype.complete = function() {
var r, n;
(n = (r = this.destination) === null || r === void 0 ? void 0 : r.complete) === null || n === void 0 || n.call(r);
}, t.prototype._subscribe = function(r) {
var n, o;
return (o = (n = this.source) === null || n === void 0 ? void 0 : n.subscribe(r)) !== null && o !== void 0 ? o : on;
}, t;
})(cn), Ba = {
now: function() {
return Date.now();
}
}, Ha = (function(e) {
ve(t, e);
function t(r, n) {
return e.call(this) || this;
}
return t.prototype.schedule = function(r, n) {
return this;
}, t;
})(rt), wr = {
setInterval: function(e, t) {
for (var r = [], n = 2; n < arguments.length; n++)
r[n - 2] = arguments[n];
return setInterval.apply(void 0, ht([e, t], yt(r)));
},
clearInterval: function(e) {
return clearInterval(e);
},
delegate: void 0
}, Ya = (function(e) {
ve(t, e);
function t(r, n) {
var o = e.call(this, r, n) || this;
return o.scheduler = r, o.work = n, o.pending = !1, o;
}
return t.prototype.schedule = function(r, n) {
var o;
if (n === void 0 && (n = 0), this.closed)
return this;
this.state = r;
var i = this.id, s = this.scheduler;
return i != null && (this.id = this.recycleAsyncId(s, i, n)), this.pending = !0, this.delay = n, this.id = (o = this.id) !== null && o !== void 0 ? o : this.requestAsyncId(s, this.id, n), this;
}, t.prototype.requestAsyncId = function(r, n, o) {
return o === void 0 && (o = 0), wr.setInterval(r.flush.bind(r, this), o);
}, t.prototype.recycleAsyncId = function(r, n, o) {
if (o === void 0 && (o = 0), o != null && this.delay === o && this.pending === !1)
return n;
n != null && wr.clearInterval(n);
}, t.prototype.execute = function(r, n) {
if (this.closed)
return new Error("executing a cancelled action");
this.pending = !1;
var o = this._execute(r, n);
if (o)
return o;
this.pending === !1 && this.id != null && (this.id = this.recycleAsyncId(this.scheduler, this.id, null));
}, t.prototype._execute = function(r, n) {
var o = !1, i;
try {
this.work(r);
} catch (s) {
o = !0, i = s || new Error("Scheduled action threw falsy error");
}
if (o)
return this.unsubscribe(), i;
}, t.prototype.unsubscribe = function() {
if (!this.closed) {
var r = this, n = r.id, o = r.scheduler, i = o.actions;
this.work = this.state = this.scheduler = null, this.pending = !1, gt(i, this), n != null && (this.id = this.recycleAsyncId(o, n, null)), this.delay = null, e.prototype.unsubscribe.call(this);
}
}, t;
})(Ha), vr = (function() {
function e(t, r) {
r === void 0 && (r = e.now), this.schedulerActionCtor = t, this.now = r;
}
return e.prototype.schedule = function(t, r, n) {
return r === void 0 && (r = 0), new this.schedulerActionCtor(this, t).schedule(n, r);
}, e.now = Ba.now, e;
})(), Wa = (function(e) {
ve(t, e);
function t(r, n) {
n === void 0 && (n = vr.now);
var o = e.call(this, r, n) || this;
return o.actions = [], o._active = !1, o;
}
return t.prototype.flush = function(r) {
var n = this.actions;
if (this._active) {
n.push(r);
return;
}
var o;
this._active = !0;
do
if (o = r.execute(r.state, r.delay))
break;
while (r = n.shift());
if (this._active = !1, o) {
for (; r = n.shift(); )
r.unsubscribe();
throw o;
}
}, t;
})(vr), Ja = new Wa(Ya), Za = (function(e) {
return e && typeof e.length == "number" && typeof e != "function";
});
function Ka(e) {
return G(e?.then);
}
function Qa(e) {
return G(e[Zt]);
}
function Xa(e) {
return Symbol.asyncIterator && G(e?.[Symbol.asyncIterator]);
}
function ei(e) {
return new TypeError("You provided " + (e !== null && typeof e == "object" ? "an invalid object" : "'" + e + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.");
}
function ti() {
return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
}
var ri = ti();
function ni(e) {
return G(e?.[ri]);
}
function oi(e) {
return Ra(this, arguments, function() {
var r, n, o, i;
return nn(this, function(s) {
switch (s.label) {
case 0:
r = e.getReader(), s.label = 1;
case 1:
s.trys.push([1, , 9, 10]), s.label = 2;
case 2:
return [4, Re(r.read())];
case 3:
return n = s.sent(), o = n.value, i = n.done, i ? [4, Re(void 0)] : [3, 5];
case 4:
return [2, s.sent()];
case 5:
return [4, Re(o)];
case 6:
return [4, s.sent()];
case 7:
return s.sent(), [3, 2];
case 8:
return [3, 10];
case 9:
return r.releaseLock(), [7];
case 10:
return [2];
}
});
});
}
function ai(e) {
return G(e?.getReader);
}
function ii(e) {
if (e instanceof pe)
return e;
if (e != null) {
if (Qa(e))
return si(e);
if (Za(e))
return ci(e);
if (Ka(e))
return li(e);
if (Xa(e))
return ln(e);
if (ni(e))
return ui(e);
if (ai(e))
return di(e);
}
throw ei(e);
}
function si(e) {
return new pe(function(t) {
var r = e[Zt]();
if (G(r.subscribe))
return r.subscribe(t);
throw new TypeError("Provided object does not correctly implement Symbol.observable");
});
}
function ci(e) {
return new pe(function(t) {
for (var r = 0; r < e.length && !t.closed; r++)
t.next(e[r]);
t.complete();
});
}
function li(e) {
return new pe(function(t) {
e.then(function(r) {
t.closed || (t.next(r), t.complete());
}, function(r) {
return t.error(r);
}).then(null, sn);
});
}
function ui(e) {
return new pe(function(t) {
var r, n;
try {
for (var o = Le(e), i = o.next(); !i.done; i = o.next()) {
var s = i.value;
if (t.next(s), t.closed)
return;
}
} catch (c) {
r = { error: c };
} finally {
try {
i && !i.done && (n = o.return) && n.call(o);
} finally {
if (r) throw r.error;
}
}
t.complete();
});
}
function ln(e) {
return new pe(function(t) {
pi(e, t).catch(function(r) {
return t.error(r);
});
});
}
function di(e) {
return ln(oi(e));
}
function pi(e, t) {
var r, n, o, i;
return Ia(this, void 0, void 0, function() {
var s, c;
return nn(this, function(l) {
switch (l.label) {
case 0:
l.trys.push([0, 5, 6, 11]), r = Ta(e), l.label = 1;
case 1:
return [4, r.next()];
case 2:
if (n = l.sent(), !!n.done) return [3, 4];
if (s = n.value, t.next(s), t.closed)
return [2];
l.label = 3;
case 3:
return [3, 1];
case 4:
return [3, 11];
case 5:
return c = l.sent(), o = { error: c }, [3, 11];
case 6:
return l.trys.push([6, , 9, 10]), n && !n.done && (i = r.return) ? [4, i.call(r)] : [3, 8];
case 7:
l.sent(), l.label = 8;
case 8:
return [3, 10];
case 9:
if (o) throw o.error;
return [7];
case 10:
return [7];
case 11:
return t.complete(), [2];
}
});
});
}
function mi(e, t, r, n, o) {
n === void 0 && (n = 0), o === void 0 && (o = !1);
var i = t.schedule(function() {
r(), o ? e.add(this.schedule(null, n)) : this.unsubscribe();
}, n);
if (e.add(i), !o)
return i;
}
function _i(e, t) {
var r = G(e) ? e : function() {
return e;
}, n = function(o) {
return o.error(r());
};
return new pe(n);
}
var fi = St(function(e) {
return function() {
e(this), this.name = "EmptyError", this.message = "no elements in sequence";
};
});
function yi(e, t) {
return new Promise(function(r, n) {
var o = !1, i;
e.subscribe({
next: function(s) {
i = s, o = !0;
},
error: n,
complete: function() {
o ? r(i) : n(new fi());
}
});
});
}
function hi(e) {
return e instanceof Date && !isNaN(e);
}
var gi = St(function(e) {
return function(r) {
r === void 0 && (r = null), e(this), this.message = "Timeout has occurred", this.name = "TimeoutError", this.info = r;
};
});
function wi(e, t) {
var r = hi(e) ? { first: e } : typeof e == "number" ? { each: e } : e, n = r.first, o = r.each, i = r.with, s = i === void 0 ? vi : i, c = r.scheduler, l = c === void 0 ? Ja : c, u = r.meta, d = u === void 0 ? null : u;
if (n == null && o == null)
throw new TypeError("No timeout provided.");
return Ga(function(f, _) {
var m, y, h = null, w = 0, E = function(v) {
y = mi(_, l, function() {
try {
m.unsubscribe(), ii(s({
meta: d,
lastValue: h,
seen: w
})).subscribe(_);
} catch (C) {
_.error(C);
}
}, v);
};
m = f.subscribe(Va(_, function(v) {
y?.unsubscribe(), w++, _.next(h = v), o > 0 && E(o);
}, void 0, void 0, function() {
y?.closed || y?.unsubscribe(), h = null;
})), !w && E(n != null ? typeof n == "number" ? n : +n - l.now() : o);
});