chat-widget-sdk_new
Version:
Neubinary chat skd
1,911 lines • 308 kB
JavaScript
import { jsxs as R, Fragment as $e, jsx as A } from "react/jsx-runtime";
import { forwardRef as xe, createElement as te, useState as x, useRef as ge, useEffect as q } from "react";
const Je = 6048e5, et = 864e5, Ee = Symbol.for("constructDateFrom");
function B(n, e) {
return typeof n == "function" ? n(e) : n && typeof n == "object" && Ee in n ? n[Ee](e) : n instanceof Date ? new n.constructor(e) : new Date(e);
}
function k(n, e) {
return B(e || n, n);
}
let tt = {};
function K() {
return tt;
}
function X(n, e) {
const t = K(), r = e?.weekStartsOn ?? e?.locale?.options?.weekStartsOn ?? t.weekStartsOn ?? t.locale?.options?.weekStartsOn ?? 0, s = k(n, e?.in), i = s.getDay(), o = (i < r ? 7 : 0) + i - r;
return s.setDate(s.getDate() - o), s.setHours(0, 0, 0, 0), s;
}
function Y(n, e) {
return X(n, { ...e, weekStartsOn: 1 });
}
function Me(n, e) {
const t = k(n, e?.in), r = t.getFullYear(), s = B(t, 0);
s.setFullYear(r + 1, 0, 4), s.setHours(0, 0, 0, 0);
const i = Y(s), o = B(t, 0);
o.setFullYear(r, 0, 4), o.setHours(0, 0, 0, 0);
const a = Y(o);
return t.getTime() >= i.getTime() ? r + 1 : t.getTime() >= a.getTime() ? r : r - 1;
}
function ye(n) {
const e = k(n), t = new Date(
Date.UTC(
e.getFullYear(),
e.getMonth(),
e.getDate(),
e.getHours(),
e.getMinutes(),
e.getSeconds(),
e.getMilliseconds()
)
);
return t.setUTCFullYear(e.getFullYear()), +n - +t;
}
function nt(n, ...e) {
const t = B.bind(
null,
e.find((r) => typeof r == "object")
);
return e.map(t);
}
function Ie(n, e) {
const t = k(n, e?.in);
return t.setHours(0, 0, 0, 0), t;
}
function rt(n, e, t) {
const [r, s] = nt(
t?.in,
n,
e
), i = Ie(r), o = Ie(s), a = +i - ye(i), c = +o - ye(o);
return Math.round((a - c) / et);
}
function st(n, e) {
const t = Me(n, e), r = B(n, 0);
return r.setFullYear(t, 0, 4), r.setHours(0, 0, 0, 0), Y(r);
}
function it(n) {
return n instanceof Date || typeof n == "object" && Object.prototype.toString.call(n) === "[object Date]";
}
function ot(n) {
return !(!it(n) && typeof n != "number" || isNaN(+k(n)));
}
function at(n, e) {
const t = k(n, e?.in);
return t.setFullYear(t.getFullYear(), 0, 1), t.setHours(0, 0, 0, 0), t;
}
const ct = {
lessThanXSeconds: {
one: "less than a second",
other: "less than {{count}} seconds"
},
xSeconds: {
one: "1 second",
other: "{{count}} seconds"
},
halfAMinute: "half a minute",
lessThanXMinutes: {
one: "less than a minute",
other: "less than {{count}} minutes"
},
xMinutes: {
one: "1 minute",
other: "{{count}} minutes"
},
aboutXHours: {
one: "about 1 hour",
other: "about {{count}} hours"
},
xHours: {
one: "1 hour",
other: "{{count}} hours"
},
xDays: {
one: "1 day",
other: "{{count}} days"
},
aboutXWeeks: {
one: "about 1 week",
other: "about {{count}} weeks"
},
xWeeks: {
one: "1 week",
other: "{{count}} weeks"
},
aboutXMonths: {
one: "about 1 month",
other: "about {{count}} months"
},
xMonths: {
one: "1 month",
other: "{{count}} months"
},
aboutXYears: {
one: "about 1 year",
other: "about {{count}} years"
},
xYears: {
one: "1 year",
other: "{{count}} years"
},
overXYears: {
one: "over 1 year",
other: "over {{count}} years"
},
almostXYears: {
one: "almost 1 year",
other: "almost {{count}} years"
}
}, ht = (n, e, t) => {
let r;
const s = ct[n];
return typeof s == "string" ? r = s : e === 1 ? r = s.one : r = s.other.replace("{{count}}", e.toString()), t?.addSuffix ? t.comparison && t.comparison > 0 ? "in " + r : r + " ago" : r;
};
function j(n) {
return (e = {}) => {
const t = e.width ? String(e.width) : n.defaultWidth;
return n.formats[t] || n.formats[n.defaultWidth];
};
}
const ut = {
full: "EEEE, MMMM do, y",
long: "MMMM do, y",
medium: "MMM d, y",
short: "MM/dd/yyyy"
}, ft = {
full: "h:mm:ss a zzzz",
long: "h:mm:ss a z",
medium: "h:mm:ss a",
short: "h:mm a"
}, dt = {
full: "{{date}} 'at' {{time}}",
long: "{{date}} 'at' {{time}}",
medium: "{{date}}, {{time}}",
short: "{{date}}, {{time}}"
}, lt = {
date: j({
formats: ut,
defaultWidth: "full"
}),
time: j({
formats: ft,
defaultWidth: "full"
}),
dateTime: j({
formats: dt,
defaultWidth: "full"
})
}, pt = {
lastWeek: "'last' eeee 'at' p",
yesterday: "'yesterday at' p",
today: "'today at' p",
tomorrow: "'tomorrow at' p",
nextWeek: "eeee 'at' p",
other: "P"
}, At = (n, e, t, r) => pt[n];
function Z(n) {
return (e, t) => {
const r = t?.context ? String(t.context) : "standalone";
let s;
if (r === "formatting" && n.formattingValues) {
const o = n.defaultFormattingWidth || n.defaultWidth, a = t?.width ? String(t.width) : o;
s = n.formattingValues[a] || n.formattingValues[o];
} else {
const o = n.defaultWidth, a = t?.width ? String(t.width) : n.defaultWidth;
s = n.values[a] || n.values[o];
}
const i = n.argumentCallback ? n.argumentCallback(e) : e;
return s[i];
};
}
const mt = {
narrow: ["B", "A"],
abbreviated: ["BC", "AD"],
wide: ["Before Christ", "Anno Domini"]
}, gt = {
narrow: ["1", "2", "3", "4"],
abbreviated: ["Q1", "Q2", "Q3", "Q4"],
wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
}, Et = {
narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
abbreviated: [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
],
wide: [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
]
}, yt = {
narrow: ["S", "M", "T", "W", "T", "F", "S"],
short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
wide: [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
]
}, It = {
narrow: {
am: "a",
pm: "p",
midnight: "mi",
noon: "n",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night"
},
abbreviated: {
am: "AM",
pm: "PM",
midnight: "midnight",
noon: "noon",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night"
},
wide: {
am: "a.m.",
pm: "p.m.",
midnight: "midnight",
noon: "noon",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night"
}
}, kt = {
narrow: {
am: "a",
pm: "p",
midnight: "mi",
noon: "n",
morning: "in the morning",
afternoon: "in the afternoon",
evening: "in the evening",
night: "at night"
},
abbreviated: {
am: "AM",
pm: "PM",
midnight: "midnight",
noon: "noon",
morning: "in the morning",
afternoon: "in the afternoon",
evening: "in the evening",
night: "at night"
},
wide: {
am: "a.m.",
pm: "p.m.",
midnight: "midnight",
noon: "noon",
morning: "in the morning",
afternoon: "in the afternoon",
evening: "in the evening",
night: "at night"
}
}, bt = (n, e) => {
const t = Number(n), r = t % 100;
if (r > 20 || r < 10)
switch (r % 10) {
case 1:
return t + "st";
case 2:
return t + "nd";
case 3:
return t + "rd";
}
return t + "th";
}, Ct = {
ordinalNumber: bt,
era: Z({
values: mt,
defaultWidth: "wide"
}),
quarter: Z({
values: gt,
defaultWidth: "wide",
argumentCallback: (n) => n - 1
}),
month: Z({
values: Et,
defaultWidth: "wide"
}),
day: Z({
values: yt,
defaultWidth: "wide"
}),
dayPeriod: Z({
values: It,
defaultWidth: "wide",
formattingValues: kt,
defaultFormattingWidth: "wide"
})
};
function z(n) {
return (e, t = {}) => {
const r = t.width, s = r && n.matchPatterns[r] || n.matchPatterns[n.defaultMatchWidth], i = e.match(s);
if (!i)
return null;
const o = i[0], a = r && n.parsePatterns[r] || n.parsePatterns[n.defaultParseWidth], c = Array.isArray(a) ? vt(a, (d) => d.test(o)) : (
// [TODO] -- I challenge you to fix the type
St(a, (d) => d.test(o))
);
let f;
f = n.valueCallback ? n.valueCallback(c) : c, f = t.valueCallback ? (
// [TODO] -- I challenge you to fix the type
t.valueCallback(f)
) : f;
const h = e.slice(o.length);
return { value: f, rest: h };
};
}
function St(n, e) {
for (const t in n)
if (Object.prototype.hasOwnProperty.call(n, t) && e(n[t]))
return t;
}
function vt(n, e) {
for (let t = 0; t < n.length; t++)
if (e(n[t]))
return t;
}
function Rt(n) {
return (e, t = {}) => {
const r = e.match(n.matchPattern);
if (!r) return null;
const s = r[0], i = e.match(n.parsePattern);
if (!i) return null;
let o = n.valueCallback ? n.valueCallback(i[0]) : i[0];
o = t.valueCallback ? t.valueCallback(o) : o;
const a = e.slice(s.length);
return { value: o, rest: a };
};
}
const Qt = /^(\d+)(th|st|nd|rd)?/i, wt = /\d+/i, Tt = {
narrow: /^(b|a)/i,
abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
wide: /^(before christ|before common era|anno domini|common era)/i
}, Bt = {
any: [/^b/i, /^(a|c)/i]
}, Pt = {
narrow: /^[1234]/i,
abbreviated: /^q[1234]/i,
wide: /^[1234](th|st|nd|rd)? quarter/i
}, xt = {
any: [/1/i, /2/i, /3/i, /4/i]
}, Jt = {
narrow: /^[jfmasond]/i,
abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
}, Mt = {
narrow: [
/^j/i,
/^f/i,
/^m/i,
/^a/i,
/^m/i,
/^j/i,
/^j/i,
/^a/i,
/^s/i,
/^o/i,
/^n/i,
/^d/i
],
any: [
/^ja/i,
/^f/i,
/^mar/i,
/^ap/i,
/^may/i,
/^jun/i,
/^jul/i,
/^au/i,
/^s/i,
/^o/i,
/^n/i,
/^d/i
]
}, Zt = {
narrow: /^[smtwf]/i,
short: /^(su|mo|tu|we|th|fr|sa)/i,
abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
}, zt = {
narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
}, Lt = {
narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
}, Ot = {
any: {
am: /^a/i,
pm: /^p/i,
midnight: /^mi/i,
noon: /^no/i,
morning: /morning/i,
afternoon: /afternoon/i,
evening: /evening/i,
night: /night/i
}
}, Xt = {
ordinalNumber: Rt({
matchPattern: Qt,
parsePattern: wt,
valueCallback: (n) => parseInt(n, 10)
}),
era: z({
matchPatterns: Tt,
defaultMatchWidth: "wide",
parsePatterns: Bt,
defaultParseWidth: "any"
}),
quarter: z({
matchPatterns: Pt,
defaultMatchWidth: "wide",
parsePatterns: xt,
defaultParseWidth: "any",
valueCallback: (n) => n + 1
}),
month: z({
matchPatterns: Jt,
defaultMatchWidth: "wide",
parsePatterns: Mt,
defaultParseWidth: "any"
}),
day: z({
matchPatterns: Zt,
defaultMatchWidth: "wide",
parsePatterns: zt,
defaultParseWidth: "any"
}),
dayPeriod: z({
matchPatterns: Lt,
defaultMatchWidth: "any",
parsePatterns: Ot,
defaultParseWidth: "any"
})
}, Nt = {
code: "en-US",
formatDistance: ht,
formatLong: lt,
formatRelative: At,
localize: Ct,
match: Xt,
options: {
weekStartsOn: 0,
firstWeekContainsDate: 1
}
};
function Ut(n, e) {
const t = k(n, e?.in);
return rt(t, at(t)) + 1;
}
function Ft(n, e) {
const t = k(n, e?.in), r = +Y(t) - +st(t);
return Math.round(r / Je) + 1;
}
function Ze(n, e) {
const t = k(n, e?.in), r = t.getFullYear(), s = K(), i = e?.firstWeekContainsDate ?? e?.locale?.options?.firstWeekContainsDate ?? s.firstWeekContainsDate ?? s.locale?.options?.firstWeekContainsDate ?? 1, o = B(e?.in || n, 0);
o.setFullYear(r + 1, 0, i), o.setHours(0, 0, 0, 0);
const a = X(o, e), c = B(e?.in || n, 0);
c.setFullYear(r, 0, i), c.setHours(0, 0, 0, 0);
const f = X(c, e);
return +t >= +a ? r + 1 : +t >= +f ? r : r - 1;
}
function Wt(n, e) {
const t = K(), r = e?.firstWeekContainsDate ?? e?.locale?.options?.firstWeekContainsDate ?? t.firstWeekContainsDate ?? t.locale?.options?.firstWeekContainsDate ?? 1, s = Ze(n, e), i = B(e?.in || n, 0);
return i.setFullYear(s, 0, r), i.setHours(0, 0, 0, 0), X(i, e);
}
function Vt(n, e) {
const t = k(n, e?.in), r = +X(t, e) - +Wt(t, e);
return Math.round(r / Je) + 1;
}
function l(n, e) {
const t = n < 0 ? "-" : "", r = Math.abs(n).toString().padStart(e, "0");
return t + r;
}
const Q = {
// Year
y(n, e) {
const t = n.getFullYear(), r = t > 0 ? t : 1 - t;
return l(e === "yy" ? r % 100 : r, e.length);
},
// Month
M(n, e) {
const t = n.getMonth();
return e === "M" ? String(t + 1) : l(t + 1, 2);
},
// Day of the month
d(n, e) {
return l(n.getDate(), e.length);
},
// AM or PM
a(n, e) {
const t = n.getHours() / 12 >= 1 ? "pm" : "am";
switch (e) {
case "a":
case "aa":
return t.toUpperCase();
case "aaa":
return t;
case "aaaaa":
return t[0];
case "aaaa":
default:
return t === "am" ? "a.m." : "p.m.";
}
},
// Hour [1-12]
h(n, e) {
return l(n.getHours() % 12 || 12, e.length);
},
// Hour [0-23]
H(n, e) {
return l(n.getHours(), e.length);
},
// Minute
m(n, e) {
return l(n.getMinutes(), e.length);
},
// Second
s(n, e) {
return l(n.getSeconds(), e.length);
},
// Fraction of second
S(n, e) {
const t = e.length, r = n.getMilliseconds(), s = Math.trunc(
r * Math.pow(10, t - 3)
);
return l(s, e.length);
}
}, J = {
midnight: "midnight",
noon: "noon",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night"
}, ke = {
// Era
G: function(n, e, t) {
const r = n.getFullYear() > 0 ? 1 : 0;
switch (e) {
// AD, BC
case "G":
case "GG":
case "GGG":
return t.era(r, { width: "abbreviated" });
// A, B
case "GGGGG":
return t.era(r, { width: "narrow" });
// Anno Domini, Before Christ
case "GGGG":
default:
return t.era(r, { width: "wide" });
}
},
// Year
y: function(n, e, t) {
if (e === "yo") {
const r = n.getFullYear(), s = r > 0 ? r : 1 - r;
return t.ordinalNumber(s, { unit: "year" });
}
return Q.y(n, e);
},
// Local week-numbering year
Y: function(n, e, t, r) {
const s = Ze(n, r), i = s > 0 ? s : 1 - s;
if (e === "YY") {
const o = i % 100;
return l(o, 2);
}
return e === "Yo" ? t.ordinalNumber(i, { unit: "year" }) : l(i, e.length);
},
// ISO week-numbering year
R: function(n, e) {
const t = Me(n);
return l(t, e.length);
},
// Extended year. This is a single number designating the year of this calendar system.
// The main difference between `y` and `u` localizers are B.C. years:
// | Year | `y` | `u` |
// |------|-----|-----|
// | AC 1 | 1 | 1 |
// | BC 1 | 1 | 0 |
// | BC 2 | 2 | -1 |
// Also `yy` always returns the last two digits of a year,
// while `uu` pads single digit years to 2 characters and returns other years unchanged.
u: function(n, e) {
const t = n.getFullYear();
return l(t, e.length);
},
// Quarter
Q: function(n, e, t) {
const r = Math.ceil((n.getMonth() + 1) / 3);
switch (e) {
// 1, 2, 3, 4
case "Q":
return String(r);
// 01, 02, 03, 04
case "QQ":
return l(r, 2);
// 1st, 2nd, 3rd, 4th
case "Qo":
return t.ordinalNumber(r, { unit: "quarter" });
// Q1, Q2, Q3, Q4
case "QQQ":
return t.quarter(r, {
width: "abbreviated",
context: "formatting"
});
// 1, 2, 3, 4 (narrow quarter; could be not numerical)
case "QQQQQ":
return t.quarter(r, {
width: "narrow",
context: "formatting"
});
// 1st quarter, 2nd quarter, ...
case "QQQQ":
default:
return t.quarter(r, {
width: "wide",
context: "formatting"
});
}
},
// Stand-alone quarter
q: function(n, e, t) {
const r = Math.ceil((n.getMonth() + 1) / 3);
switch (e) {
// 1, 2, 3, 4
case "q":
return String(r);
// 01, 02, 03, 04
case "qq":
return l(r, 2);
// 1st, 2nd, 3rd, 4th
case "qo":
return t.ordinalNumber(r, { unit: "quarter" });
// Q1, Q2, Q3, Q4
case "qqq":
return t.quarter(r, {
width: "abbreviated",
context: "standalone"
});
// 1, 2, 3, 4 (narrow quarter; could be not numerical)
case "qqqqq":
return t.quarter(r, {
width: "narrow",
context: "standalone"
});
// 1st quarter, 2nd quarter, ...
case "qqqq":
default:
return t.quarter(r, {
width: "wide",
context: "standalone"
});
}
},
// Month
M: function(n, e, t) {
const r = n.getMonth();
switch (e) {
case "M":
case "MM":
return Q.M(n, e);
// 1st, 2nd, ..., 12th
case "Mo":
return t.ordinalNumber(r + 1, { unit: "month" });
// Jan, Feb, ..., Dec
case "MMM":
return t.month(r, {
width: "abbreviated",
context: "formatting"
});
// J, F, ..., D
case "MMMMM":
return t.month(r, {
width: "narrow",
context: "formatting"
});
// January, February, ..., December
case "MMMM":
default:
return t.month(r, { width: "wide", context: "formatting" });
}
},
// Stand-alone month
L: function(n, e, t) {
const r = n.getMonth();
switch (e) {
// 1, 2, ..., 12
case "L":
return String(r + 1);
// 01, 02, ..., 12
case "LL":
return l(r + 1, 2);
// 1st, 2nd, ..., 12th
case "Lo":
return t.ordinalNumber(r + 1, { unit: "month" });
// Jan, Feb, ..., Dec
case "LLL":
return t.month(r, {
width: "abbreviated",
context: "standalone"
});
// J, F, ..., D
case "LLLLL":
return t.month(r, {
width: "narrow",
context: "standalone"
});
// January, February, ..., December
case "LLLL":
default:
return t.month(r, { width: "wide", context: "standalone" });
}
},
// Local week of year
w: function(n, e, t, r) {
const s = Vt(n, r);
return e === "wo" ? t.ordinalNumber(s, { unit: "week" }) : l(s, e.length);
},
// ISO week of year
I: function(n, e, t) {
const r = Ft(n);
return e === "Io" ? t.ordinalNumber(r, { unit: "week" }) : l(r, e.length);
},
// Day of the month
d: function(n, e, t) {
return e === "do" ? t.ordinalNumber(n.getDate(), { unit: "date" }) : Q.d(n, e);
},
// Day of year
D: function(n, e, t) {
const r = Ut(n);
return e === "Do" ? t.ordinalNumber(r, { unit: "dayOfYear" }) : l(r, e.length);
},
// Day of week
E: function(n, e, t) {
const r = n.getDay();
switch (e) {
// Tue
case "E":
case "EE":
case "EEE":
return t.day(r, {
width: "abbreviated",
context: "formatting"
});
// T
case "EEEEE":
return t.day(r, {
width: "narrow",
context: "formatting"
});
// Tu
case "EEEEEE":
return t.day(r, {
width: "short",
context: "formatting"
});
// Tuesday
case "EEEE":
default:
return t.day(r, {
width: "wide",
context: "formatting"
});
}
},
// Local day of week
e: function(n, e, t, r) {
const s = n.getDay(), i = (s - r.weekStartsOn + 8) % 7 || 7;
switch (e) {
// Numerical value (Nth day of week with current locale or weekStartsOn)
case "e":
return String(i);
// Padded numerical value
case "ee":
return l(i, 2);
// 1st, 2nd, ..., 7th
case "eo":
return t.ordinalNumber(i, { unit: "day" });
case "eee":
return t.day(s, {
width: "abbreviated",
context: "formatting"
});
// T
case "eeeee":
return t.day(s, {
width: "narrow",
context: "formatting"
});
// Tu
case "eeeeee":
return t.day(s, {
width: "short",
context: "formatting"
});
// Tuesday
case "eeee":
default:
return t.day(s, {
width: "wide",
context: "formatting"
});
}
},
// Stand-alone local day of week
c: function(n, e, t, r) {
const s = n.getDay(), i = (s - r.weekStartsOn + 8) % 7 || 7;
switch (e) {
// Numerical value (same as in `e`)
case "c":
return String(i);
// Padded numerical value
case "cc":
return l(i, e.length);
// 1st, 2nd, ..., 7th
case "co":
return t.ordinalNumber(i, { unit: "day" });
case "ccc":
return t.day(s, {
width: "abbreviated",
context: "standalone"
});
// T
case "ccccc":
return t.day(s, {
width: "narrow",
context: "standalone"
});
// Tu
case "cccccc":
return t.day(s, {
width: "short",
context: "standalone"
});
// Tuesday
case "cccc":
default:
return t.day(s, {
width: "wide",
context: "standalone"
});
}
},
// ISO day of week
i: function(n, e, t) {
const r = n.getDay(), s = r === 0 ? 7 : r;
switch (e) {
// 2
case "i":
return String(s);
// 02
case "ii":
return l(s, e.length);
// 2nd
case "io":
return t.ordinalNumber(s, { unit: "day" });
// Tue
case "iii":
return t.day(r, {
width: "abbreviated",
context: "formatting"
});
// T
case "iiiii":
return t.day(r, {
width: "narrow",
context: "formatting"
});
// Tu
case "iiiiii":
return t.day(r, {
width: "short",
context: "formatting"
});
// Tuesday
case "iiii":
default:
return t.day(r, {
width: "wide",
context: "formatting"
});
}
},
// AM or PM
a: function(n, e, t) {
const s = n.getHours() / 12 >= 1 ? "pm" : "am";
switch (e) {
case "a":
case "aa":
return t.dayPeriod(s, {
width: "abbreviated",
context: "formatting"
});
case "aaa":
return t.dayPeriod(s, {
width: "abbreviated",
context: "formatting"
}).toLowerCase();
case "aaaaa":
return t.dayPeriod(s, {
width: "narrow",
context: "formatting"
});
case "aaaa":
default:
return t.dayPeriod(s, {
width: "wide",
context: "formatting"
});
}
},
// AM, PM, midnight, noon
b: function(n, e, t) {
const r = n.getHours();
let s;
switch (r === 12 ? s = J.noon : r === 0 ? s = J.midnight : s = r / 12 >= 1 ? "pm" : "am", e) {
case "b":
case "bb":
return t.dayPeriod(s, {
width: "abbreviated",
context: "formatting"
});
case "bbb":
return t.dayPeriod(s, {
width: "abbreviated",
context: "formatting"
}).toLowerCase();
case "bbbbb":
return t.dayPeriod(s, {
width: "narrow",
context: "formatting"
});
case "bbbb":
default:
return t.dayPeriod(s, {
width: "wide",
context: "formatting"
});
}
},
// in the morning, in the afternoon, in the evening, at night
B: function(n, e, t) {
const r = n.getHours();
let s;
switch (r >= 17 ? s = J.evening : r >= 12 ? s = J.afternoon : r >= 4 ? s = J.morning : s = J.night, e) {
case "B":
case "BB":
case "BBB":
return t.dayPeriod(s, {
width: "abbreviated",
context: "formatting"
});
case "BBBBB":
return t.dayPeriod(s, {
width: "narrow",
context: "formatting"
});
case "BBBB":
default:
return t.dayPeriod(s, {
width: "wide",
context: "formatting"
});
}
},
// Hour [1-12]
h: function(n, e, t) {
if (e === "ho") {
let r = n.getHours() % 12;
return r === 0 && (r = 12), t.ordinalNumber(r, { unit: "hour" });
}
return Q.h(n, e);
},
// Hour [0-23]
H: function(n, e, t) {
return e === "Ho" ? t.ordinalNumber(n.getHours(), { unit: "hour" }) : Q.H(n, e);
},
// Hour [0-11]
K: function(n, e, t) {
const r = n.getHours() % 12;
return e === "Ko" ? t.ordinalNumber(r, { unit: "hour" }) : l(r, e.length);
},
// Hour [1-24]
k: function(n, e, t) {
let r = n.getHours();
return r === 0 && (r = 24), e === "ko" ? t.ordinalNumber(r, { unit: "hour" }) : l(r, e.length);
},
// Minute
m: function(n, e, t) {
return e === "mo" ? t.ordinalNumber(n.getMinutes(), { unit: "minute" }) : Q.m(n, e);
},
// Second
s: function(n, e, t) {
return e === "so" ? t.ordinalNumber(n.getSeconds(), { unit: "second" }) : Q.s(n, e);
},
// Fraction of second
S: function(n, e) {
return Q.S(n, e);
},
// Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
X: function(n, e, t) {
const r = n.getTimezoneOffset();
if (r === 0)
return "Z";
switch (e) {
// Hours and optional minutes
case "X":
return Ce(r);
// Hours, minutes and optional seconds without `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `XX`
case "XXXX":
case "XX":
return P(r);
// Hours, minutes and optional seconds with `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `XXX`
case "XXXXX":
case "XXX":
// Hours and minutes with `:` delimiter
default:
return P(r, ":");
}
},
// Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
x: function(n, e, t) {
const r = n.getTimezoneOffset();
switch (e) {
// Hours and optional minutes
case "x":
return Ce(r);
// Hours, minutes and optional seconds without `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `xx`
case "xxxx":
case "xx":
return P(r);
// Hours, minutes and optional seconds with `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `xxx`
case "xxxxx":
case "xxx":
// Hours and minutes with `:` delimiter
default:
return P(r, ":");
}
},
// Timezone (GMT)
O: function(n, e, t) {
const r = n.getTimezoneOffset();
switch (e) {
// Short
case "O":
case "OO":
case "OOO":
return "GMT" + be(r, ":");
// Long
case "OOOO":
default:
return "GMT" + P(r, ":");
}
},
// Timezone (specific non-location)
z: function(n, e, t) {
const r = n.getTimezoneOffset();
switch (e) {
// Short
case "z":
case "zz":
case "zzz":
return "GMT" + be(r, ":");
// Long
case "zzzz":
default:
return "GMT" + P(r, ":");
}
},
// Seconds timestamp
t: function(n, e, t) {
const r = Math.trunc(+n / 1e3);
return l(r, e.length);
},
// Milliseconds timestamp
T: function(n, e, t) {
return l(+n, e.length);
}
};
function be(n, e = "") {
const t = n > 0 ? "-" : "+", r = Math.abs(n), s = Math.trunc(r / 60), i = r % 60;
return i === 0 ? t + String(s) : t + String(s) + e + l(i, 2);
}
function Ce(n, e) {
return n % 60 === 0 ? (n > 0 ? "-" : "+") + l(Math.abs(n) / 60, 2) : P(n, e);
}
function P(n, e = "") {
const t = n > 0 ? "-" : "+", r = Math.abs(n), s = l(Math.trunc(r / 60), 2), i = l(r % 60, 2);
return t + s + e + i;
}
const Se = (n, e) => {
switch (n) {
case "P":
return e.date({ width: "short" });
case "PP":
return e.date({ width: "medium" });
case "PPP":
return e.date({ width: "long" });
case "PPPP":
default:
return e.date({ width: "full" });
}
}, ze = (n, e) => {
switch (n) {
case "p":
return e.time({ width: "short" });
case "pp":
return e.time({ width: "medium" });
case "ppp":
return e.time({ width: "long" });
case "pppp":
default:
return e.time({ width: "full" });
}
}, Gt = (n, e) => {
const t = n.match(/(P+)(p+)?/) || [], r = t[1], s = t[2];
if (!s)
return Se(n, e);
let i;
switch (r) {
case "P":
i = e.dateTime({ width: "short" });
break;
case "PP":
i = e.dateTime({ width: "medium" });
break;
case "PPP":
i = e.dateTime({ width: "long" });
break;
case "PPPP":
default:
i = e.dateTime({ width: "full" });
break;
}
return i.replace("{{date}}", Se(r, e)).replace("{{time}}", ze(s, e));
}, Yt = {
p: ze,
P: Gt
}, Kt = /^D+$/, Dt = /^Y+$/, Ht = ["D", "DD", "YY", "YYYY"];
function qt(n) {
return Kt.test(n);
}
function jt(n) {
return Dt.test(n);
}
function _t(n, e, t) {
const r = $t(n, e, t);
if (console.warn(r), Ht.includes(n)) throw new RangeError(r);
}
function $t(n, e, t) {
const r = n[0] === "Y" ? "years" : "days of the month";
return `Use \`${n.toLowerCase()}\` instead of \`${n}\` (in \`${e}\`) for formatting ${r} to the input \`${t}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
}
const en = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g, tn = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g, nn = /^'([^]*?)'?$/, rn = /''/g, sn = /[a-zA-Z]/;
function on(n, e, t) {
const r = K(), s = r.locale ?? Nt, i = r.firstWeekContainsDate ?? r.locale?.options?.firstWeekContainsDate ?? 1, o = r.weekStartsOn ?? r.locale?.options?.weekStartsOn ?? 0, a = k(n, t?.in);
if (!ot(a))
throw new RangeError("Invalid time value");
let c = e.match(tn).map((h) => {
const d = h[0];
if (d === "p" || d === "P") {
const E = Yt[d];
return E(h, s.formatLong);
}
return h;
}).join("").match(en).map((h) => {
if (h === "''")
return { isToken: !1, value: "'" };
const d = h[0];
if (d === "'")
return { isToken: !1, value: an(h) };
if (ke[d])
return { isToken: !0, value: h };
if (d.match(sn))
throw new RangeError(
"Format string contains an unescaped latin alphabet character `" + d + "`"
);
return { isToken: !1, value: h };
});
s.localize.preprocessor && (c = s.localize.preprocessor(a, c));
const f = {
firstWeekContainsDate: i,
weekStartsOn: o,
locale: s
};
return c.map((h) => {
if (!h.isToken) return h.value;
const d = h.value;
(jt(d) || qt(d)) && _t(d, e, String(n));
const E = ke[d[0]];
return E(a, d, s.localize, f);
}).join("");
}
function an(n) {
const e = n.match(nn);
return e ? e[1].replace(rn, "'") : n;
}
/**
* @license lucide-react v0.525.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const cn = (n) => n.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), hn = (n) => n.replace(
/^([A-Z])|[\s-_]+(\w)/g,
(e, t, r) => r ? r.toUpperCase() : t.toLowerCase()
), ve = (n) => {
const e = hn(n);
return e.charAt(0).toUpperCase() + e.slice(1);
}, Le = (...n) => n.filter((e, t, r) => !!e && e.trim() !== "" && r.indexOf(e) === t).join(" ").trim(), un = (n) => {
for (const e in n)
if (e.startsWith("aria-") || e === "role" || e === "title")
return !0;
};
/**
* @license lucide-react v0.525.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
var fn = {
xmlns: "http://www.w3.org/2000/svg",
width: 24,
height: 24,
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
strokeWidth: 2,
strokeLinecap: "round",
strokeLinejoin: "round"
};
/**
* @license lucide-react v0.525.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const dn = xe(
({
color: n = "currentColor",
size: e = 24,
strokeWidth: t = 2,
absoluteStrokeWidth: r,
className: s = "",
children: i,
iconNode: o,
...a
}, c) => te(
"svg",
{
ref: c,
...fn,
width: e,
height: e,
stroke: n,
strokeWidth: r ? Number(t) * 24 / Number(e) : t,
className: Le("lucide", s),
...!i && !un(a) && { "aria-hidden": "true" },
...a
},
[
...o.map(([f, h]) => te(f, h)),
...Array.isArray(i) ? i : [i]
]
)
);
/**
* @license lucide-react v0.525.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const ce = (n, e) => {
const t = xe(
({ className: r, ...s }, i) => te(dn, {
ref: i,
iconNode: e,
className: Le(
`lucide-${cn(ve(n))}`,
`lucide-${n}`,
r
),
...s
})
);
return t.displayName = ve(n), t;
};
/**
* @license lucide-react v0.525.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const ln = [
["path", { d: "M7.9 20A9 9 0 1 0 4 16.1L2 22Z", key: "vv11sd" }]
], pn = ce("message-circle", ln);
/**
* @license lucide-react v0.525.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const An = [
[
"path",
{
d: "M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",
key: "1ffxy3"
}
],
["path", { d: "m21.854 2.147-10.94 10.939", key: "12cjpa" }]
], mn = ce("send", An);
/**
* @license lucide-react v0.525.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const gn = [
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
], Re = ce("x", gn), C = /* @__PURE__ */ Object.create(null);
C.open = "0";
C.close = "1";
C.ping = "2";
C.pong = "3";
C.message = "4";
C.upgrade = "5";
C.noop = "6";
const F = /* @__PURE__ */ Object.create(null);
Object.keys(C).forEach((n) => {
F[C[n]] = n;
});
const ne = { type: "error", data: "parser error" }, Oe = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Xe = typeof ArrayBuffer == "function", Ne = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n && n.buffer instanceof ArrayBuffer, he = ({ type: n, data: e }, t, r) => Oe && e instanceof Blob ? t ? r(e) : Qe(e, r) : Xe && (e instanceof ArrayBuffer || Ne(e)) ? t ? r(e) : Qe(new Blob([e]), r) : r(C[n] + (e || "")), Qe = (n, e) => {
const t = new FileReader();
return t.onload = function() {
const r = t.result.split(",")[1];
e("b" + (r || ""));
}, t.readAsDataURL(n);
};
function we(n) {
return n instanceof Uint8Array ? n : n instanceof ArrayBuffer ? new Uint8Array(n) : new Uint8Array(n.buffer, n.byteOffset, n.byteLength);
}
let _;
function En(n, e) {
if (Oe && n.data instanceof Blob)
return n.data.arrayBuffer().then(we).then(e);
if (Xe && (n.data instanceof ArrayBuffer || Ne(n.data)))
return e(we(n.data));
he(n, !1, (t) => {
_ || (_ = new TextEncoder()), e(_.encode(t));
});
}
const Te = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", O = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
for (let n = 0; n < Te.length; n++)
O[Te.charCodeAt(n)] = n;
const yn = (n) => {
let e = n.length * 0.75, t = n.length, r, s = 0, i, o, a, c;
n[n.length - 1] === "=" && (e--, n[n.length - 2] === "=" && e--);
const f = new ArrayBuffer(e), h = new Uint8Array(f);
for (r = 0; r < t; r += 4)
i = O[n.charCodeAt(r)], o = O[n.charCodeAt(r + 1)], a = O[n.charCodeAt(r + 2)], c = O[n.charCodeAt(r + 3)], h[s++] = i << 2 | o >> 4, h[s++] = (o & 15) << 4 | a >> 2, h[s++] = (a & 3) << 6 | c & 63;
return f;
}, In = typeof ArrayBuffer == "function", ue = (n, e) => {
if (typeof n != "string")
return {
type: "message",
data: Ue(n, e)
};
const t = n.charAt(0);
return t === "b" ? {
type: "message",
data: kn(n.substring(1), e)
} : F[t] ? n.length > 1 ? {
type: F[t],
data: n.substring(1)
} : {
type: F[t]
} : ne;
}, kn = (n, e) => {
if (In) {
const t = yn(n);
return Ue(t, e);
} else
return { base64: !0, data: n };
}, Ue = (n, e) => {
switch (e) {
case "blob":
return n instanceof Blob ? n : new Blob([n]);
case "arraybuffer":
default:
return n instanceof ArrayBuffer ? n : n.buffer;
}
}, Fe = "", bn = (n, e) => {
const t = n.length, r = new Array(t);
let s = 0;
n.forEach((i, o) => {
he(i, !1, (a) => {
r[o] = a, ++s === t && e(r.join(Fe));
});
});
}, Cn = (n, e) => {
const t = n.split(Fe), r = [];
for (let s = 0; s < t.length; s++) {
const i = ue(t[s], e);
if (r.push(i), i.type === "error")
break;
}
return r;
};
function Sn() {
return new TransformStream({
transform(n, e) {
En(n, (t) => {
const r = t.length;
let s;
if (r < 126)
s = new Uint8Array(1), new DataView(s.buffer).setUint8(0, r);
else if (r < 65536) {
s = new Uint8Array(3);
const i = new DataView(s.buffer);
i.setUint8(0, 126), i.setUint16(1, r);
} else {
s = new Uint8Array(9);
const i = new DataView(s.buffer);
i.setUint8(0, 127), i.setBigUint64(1, BigInt(r));
}
n.data && typeof n.data != "string" && (s[0] |= 128), e.enqueue(s), e.enqueue(t);
});
}
});
}
let $;
function N(n) {
return n.reduce((e, t) => e + t.length, 0);
}
function U(n, e) {
if (n[0].length === e)
return n.shift();
const t = new Uint8Array(e);
let r = 0;
for (let s = 0; s < e; s++)
t[s] = n[0][r++], r === n[0].length && (n.shift(), r = 0);
return n.length && r < n[0].length && (n[0] = n[0].slice(r)), t;
}
function vn(n, e) {
$ || ($ = new TextDecoder());
const t = [];
let r = 0, s = -1, i = !1;
return new TransformStream({
transform(o, a) {
for (t.push(o); ; ) {
if (r === 0) {
if (N(t) < 1)
break;
const c = U(t, 1);
i = (c[0] & 128) === 128, s = c[0] & 127, s < 126 ? r = 3 : s === 126 ? r = 1 : r = 2;
} else if (r === 1) {
if (N(t) < 2)
break;
const c = U(t, 2);
s = new DataView(c.buffer, c.byteOffset, c.length).getUint16(0), r = 3;
} else if (r === 2) {
if (N(t) < 8)
break;
const c = U(t, 8), f = new DataView(c.buffer, c.byteOffset, c.length), h = f.getUint32(0);
if (h > Math.pow(2, 21) - 1) {
a.enqueue(ne);
break;
}
s = h * Math.pow(2, 32) + f.getUint32(4), r = 3;
} else {
if (N(t) < s)
break;
const c = U(t, s);
a.enqueue(ue(i ? c : $.decode(c), e)), r = 0;
}
if (s === 0 || s > n) {
a.enqueue(ne);
break;
}
}
}
});
}
const We = 4;
function m(n) {
if (n) return Rn(n);
}
function Rn(n) {
for (var e in m.prototype)
n[e] = m.prototype[e];
return n;
}
m.prototype.on = m.prototype.addEventListener = function(n, e) {
return this._callbacks = this._callbacks || {}, (this._callbacks["$" + n] = this._callbacks["$" + n] || []).push(e), this;
};
m.prototype.once = function(n, e) {
function t() {
this.off(n, t), e.apply(this, arguments);
}
return t.fn = e, this.on(n, t), this;
};
m.prototype.off = m.prototype.removeListener = m.prototype.removeAllListeners = m.prototype.removeEventListener = function(n, e) {
if (this._callbacks = this._callbacks || {}, arguments.length == 0)
return this._callbacks = {}, this;
var t = this._callbacks["$" + n];
if (!t) return this;
if (arguments.length == 1)
return delete this._callbacks["$" + n], this;
for (var r, s = 0; s < t.length; s++)
if (r = t[s], r === e || r.fn === e) {
t.splice(s, 1);
break;
}
return t.length === 0 && delete this._callbacks["$" + n], this;
};
m.prototype.emit = function(n) {
this._callbacks = this._callbacks || {};
for (var e = new Array(arguments.length - 1), t = this._callbacks["$" + n], r = 1; r < arguments.length; r++)
e[r - 1] = arguments[r];
if (t) {
t = t.slice(0);
for (var r = 0, s = t.length; r < s; ++r)
t[r].apply(this, e);
}
return this;
};
m.prototype.emitReserved = m.prototype.emit;
m.prototype.listeners = function(n) {
return this._callbacks = this._callbacks || {}, this._callbacks["$" + n] || [];
};
m.prototype.hasListeners = function(n) {
return !!this.listeners(n).length;
};
const D = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), y = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), Qn = "arraybuffer";
function Ve(n, ...e) {
return e.reduce((t, r) => (n.hasOwnProperty(r) && (t[r] = n[r]), t), {});
}
const wn = y.setTimeout, Tn = y.clearTimeout;
function H(n, e) {
e.useNativeTimers ? (n.setTimeoutFn = wn.bind(y), n.clearTimeoutFn = Tn.bind(y)) : (n.setTimeoutFn = y.setTimeout.bind(y), n.clearTimeoutFn = y.clearTimeout.bind(y));
}
const Bn = 1.33;
function Pn(n) {
return typeof n == "string" ? xn(n) : Math.ceil((n.byteLength || n.size) * Bn);
}
function xn(n) {
let e = 0, t = 0;
for (let r = 0, s = n.length; r < s; r++)
e = n.charCodeAt(r), e < 128 ? t += 1 : e < 2048 ? t += 2 : e < 55296 || e >= 57344 ? t += 3 : (r++, t += 4);
return t;
}
function Ge() {
return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
}
function Jn(n) {
let e = "";
for (let t in n)
n.hasOwnProperty(t) && (e.length && (e += "&"), e += encodeURIComponent(t) + "=" + encodeURIComponent(n[t]));
return e;
}
function Mn(n) {
let e = {}, t = n.split("&");
for (let r = 0, s = t.length; r < s; r++) {
let i = t[r].split("=");
e[decodeURIComponent(i[0])] = decodeURIComponent(i[1]);
}
return e;
}
class Zn extends Error {
constructor(e, t, r) {
super(e), this.description = t, this.context = r, this.type = "TransportError";
}
}
class fe extends m {
/**
* Transport abstract constructor.
*
* @param {Object} opts - options
* @protected
*/
constructor(e) {
super(), this.writable = !1, H(this, e), this.opts = e, this.query = e.query, this.socket = e.socket, this.supportsBinary = !e.forceBase64;
}
/**
* Emits an error.
*
* @param {String} reason
* @param description
* @param context - the error context
* @return {Transport} for chaining
* @protected
*/
onError(e, t, r) {
return super.emitReserved("error", new Zn(e, t, r)), this;
}
/**
* Opens the transport.
*/
open() {
return this.readyState = "opening", this.doOpen(), this;
}
/**
* Closes the transport.
*/
close() {
return (this.readyState === "opening" || this.readyState === "open") && (this.doClose(), this.onClose()), this;
}
/**
* Sends multiple packets.
*
* @param {Array} packets
*/
send(e) {
this.readyState === "open" && this.write(e);
}
/**
* Called upon open
*
* @protected
*/
onOpen() {
this.readyState = "open", this.writable = !0, super.emitReserved("open");
}
/**
* Called with data.
*
* @param {String} data
* @protected
*/
onData(e) {
const t = ue(e, this.socket.binaryType);
this.onPacket(t);
}
/**
* Called with a decoded packet.
*
* @protected
*/
onPacket(e) {
super.emitReserved("packet", e);
}
/**
* Called upon close.
*
* @protected
*/
onClose(e) {
this.readyState = "closed", super.emitReserved("close", e);
}
/**
* Pauses the transport, in order not to lose packets during an upgrade.
*
* @param onPause
*/
pause(e) {
}
createUri(e, t = {}) {
return e + "://" + this._hostname() + this._port() + this.opts.path + this._query(t);
}
_hostname() {
const e = this.opts.hostname;
return e.indexOf(":") === -1 ? e : "[" + e + "]";
}
_port() {
return this.opts.port && (this.opts.secure && +(this.opts.port !== 443) || !this.opts.secure && Number(this.opts.port) !== 80) ? ":" + this.opts.port : "";
}
_query(e) {
const t = Jn(e);
return t.length ? "?" + t : "";
}
}
class zn extends fe {
constructor() {
super(...arguments), this._polling = !1;
}
get name() {
return "polling";
}
/**
* Opens the socket (triggers polling). We write a PING message to determine
* when the transport is open.
*
* @protected
*/
doOpen() {
this._poll();
}
/**
* Pauses polling.
*
* @param {Function} onPause - callback upon buffers are flushed and transport is paused
* @package
*/
pause(e) {
this.readyState = "pausing";
const t = () => {
this.readyState = "paused", e();
};
if (this._polling || !this.writable) {
let r = 0;
this._polling && (r++, this.once("pollComplete", function() {
--r || t();
})), this.writable || (r++, this.once("drain", function() {
--r || t();
}));
} else
t();
}
/**
* Starts polling cycle.
*
* @private
*/
_poll() {
this._polling = !0, this.doPoll(), this.emitReserved("poll");
}
/**
* Overloads onData to detect payloads.
*
* @protected
*/
onData(e) {
const t = (r) => {
if (this.readyState === "opening" && r.type === "open" && this.onOpen(), r.type === "close")
return this.onClose({ description: "transport closed by the server" }), !1;
this.onPacket(r);
};
Cn(e, this.socket.binaryType).forEach(t), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
}
/**
* For polling, send a close packet.
*
* @protected
*/
doClose() {
const e = () => {
this.write([{ type: "close" }]);
};
this.readyState === "open" ? e() : this.once("open", e);
}
/**
* Writes a packets payload.
*
* @param {Array} packets - data packets
* @protected
*/
write(e) {
this.writable = !1, bn(e, (t) => {
this.doWrite(t, () => {
this.writable = !0, this.emitReserved("drain");
});
});
}
/**
* Generates uri for connection.
*
* @private
*/
uri() {
const e = this.opts.secure ? "https" : "http", t = this.query || {};
return this.opts.timestampRequests !== !1 && (t[this.opts.timestampParam] = Ge()), !this.supportsBinary && !t.sid && (t.b64 = 1), this.createUri(e, t);
}
}
let Ye = !1;
try {
Ye = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
} catch {
}
const Ln = Ye;
function On() {
}
class Xn extends zn {
/**
* XHR Polling constructor.
*
* @param {Object} opts
* @package
*/
constructor(e) {
if (super(e), typeof location < "u") {
const t = location.protocol === "https:";
let r = location.port;
r || (r = t ? "443" : "80"), this.xd = typeof location < "u" && e.hostname !== location.hostname || r !== e.port;
}
}
/**
* Sends data.
*
* @param {String} data to send.
* @param {Function} called upon flush.
* @private
*/
doWrite(e, t) {
const r = this.request({
method: "POST",
data: e
});
r.on("success", t), r.on("error", (s, i) => {
this.onError("xhr post error", s, i);
});
}
/**
* Starts a poll cycle.
*
* @private
*/
doPoll() {
const e = this.request();
e.on("data", this.onData.bind(this)), e.on("error", (t, r) => {
this.onError("xhr poll error", t, r);
}), this.pollXhr = e;
}
}
class b extends m {
/**
* Request constructor
*
* @param {Object} options
* @package
*/
constructor(e, t, r) {
super(), this.createRequest = e, H(this, r), this._opts = r, this._method = r.method || "GET", this._uri = t, this._data = r.data !== void 0 ? r.data : null, this._create();
}
/**
* Creates the XHR object and sends the request.
*
* @private
*/
_create() {
var e;
const t = Ve(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
t.xdomain = !!this._opts.xd;
const r = this._xhr = this.createRequest(t);
try {
r.open(this._method, this._uri, !0);
try {
if (this._opts.extraHeaders) {
r.setDisableHeaderCheck && r.setDisableHeaderCheck(!0