@villagehq/extension-sdk
Version:
Village Chrome Extension SDK for Partner Integrations
1,734 lines • 83 kB
JavaScript
import R from "axios";
const ot = R.create({ baseURL: "https://app.posthog.com" });
ot.interceptors.request.use((e) => (e.data = {
...e.data,
api_key: "phc_cWZiUS6cHGvUDyCMDRK8Cvoayv5m6x6YOT02RW91vOX"
}, e));
const Le = "isPathsEverywhereActive", re = "village.paths-everywhere.is-active";
function it(e) {
const t = { VITE_VILLAGE_API_URL: "https://api.village.do/", VITE_VILLAGE_FRONTEND_URL: "https://village.do/", VITE_POSTHOG_KEY: "phc_cWZiUS6cHGvUDyCMDRK8Cvoayv5m6x6YOT02RW91vOX", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 }[e];
if (!t)
throw console.error(`Missing required environment variable: ${e}`), new Error(`Env var ${e} is not defined`);
return t;
}
const M = it("VITE_VILLAGE_API_URL"), Ie = it("VITE_VILLAGE_FRONTEND_URL");
function xt(e) {
for (var t = "", n = 0; n < e.length; n++) {
var o = e.charCodeAt(n), i = o + 1;
t += String.fromCharCode(i);
}
return t;
}
const ue = (e) => Object.keys(e).length === 0, kt = () => Math.random().toString(36).substring(2, 9) + (/* @__PURE__ */ new Date()).getTime();
function ge(e) {
if (!e)
return "";
const { rootUrl: t, artifacts: n } = e;
if (!t || !n || !n.length)
return "";
const o = n[n.length - 1];
return `${t}${o.fileIdentifyingUrlPathSegment}`;
}
function Lt(e, ...t) {
return t.reduce((n, o) => n && n[o], e);
}
const St = (e) => {
var t = {};
const { miniProfile: n } = e.profile;
t.linkedin_id = e.entityUrn || "", t.firstname = e.profile.firstName || "", t.lastname = e.profile.lastName || "", t.profile_url = "https://www.linkedin.com/in/" + n.publicIdentifier, t.avatar_url = n.picture && ge(n.picture["com.linkedin.common.VectorImage"]), t.country = e.profile.geoCountryName || "", t.location = e.profile.geoLocationName || "", t.number_of_connections = "", t.about = e.profile.summary || "", t.headline = e.profile.headline || "", t.industryName = e.profile.industryName || "", t.job_history = [];
var o = e.positionGroupView;
if (o && o.elements && o.elements.length > 0)
for (var i = o.elements, r = 0; r < i.length; r++) {
var s = i[r].positions;
for (const _ of s) {
var c = {};
c.position = _.title, c.company_name = _.companyName;
var d = _.timePeriod || {};
typeof d.startDate < "u" && (c.date_from = d.startDate), typeof d.endDate < "u" && (c.date_to = d.endDate);
var g = "", l = "", u = i[r].miniCompany || {}, y = u.logo, h = u.universalName;
y && typeof y["com.linkedin.common.VectorImage"] < "u" && (g = ge(y["com.linkedin.common.VectorImage"])), h && (l = "https://www.linkedin.com/company/" + h), c.logo_url = g, c.linkedin_url = l, t.job_history.push(c);
}
}
t.education_history = [];
var p = e.educationView;
if (p && p.elements && p.elements.length > 0)
for (var v = p.elements, E = 0; E < v.length; E++) {
var w = {};
w.major_program_certificate = v[E].degreeName || "", w.field_of_study = v[E].fieldOfStudy || "", w.school_name = v[E].schoolName || "";
var d = v[E].timePeriod || {};
typeof d.startDate < "u" && (w.date_from = d.startDate), typeof d.endDate < "u" && (w.date_to = d.endDate);
var g = "", l = "", b = v[E].school || {}, y = b.logo || {}, L = b.entityUrn || "";
y && typeof y["com.linkedin.common.VectorImage"] < "u" && (g = ge(y["com.linkedin.common.VectorImage"])), L = L.replace("urn:li:fs_miniSchool:", ""), L && (l = "https://www.linkedin.com/school/" + L), w.logo_url = g, w.linkedin_url = l, t.education_history.push(w);
}
return t;
}, Ct = (e) => {
const {
connectedMemberResolutionResult: t,
entityUrn: n,
createdAt: o
} = e, i = Lt(
t,
"profilePicture",
"displayImageReference",
"vectorImage"
);
return {
avatar_url: ge(i),
full_name: `${t.firstName} ${t.lastName}`,
profile_id: t.publicIdentifier,
linkedin_id: n.replace("urn:li:fsd_connection:", ""),
created_at: new Date(o)
};
};
function P(e) {
return new Promise((t) => {
chrome.storage.sync.get([e], (n) => {
t(n[e]);
});
});
}
function O(e, t) {
return new Promise((n) => {
chrome.storage.sync.set({ [e]: t }, () => {
n();
});
});
}
function ze(e) {
return new Promise((t, n) => {
var o = {};
J().then((i) => {
R.get(
"https://www.linkedin.com/voyager/api/identity/profiles/" + e + "/profileContactInfo",
{ headers: { "csrf-token": i }, withCredentials: !0 }
).then(({ data: r }) => {
r && r.emailAddress && (o.emailAddress = r.emailAddress), r && r.websites && (o.websites = r.websites), r && r.twitterHandles && (o.twitterHandles = r.twitterHandles), r && r.phoneNumbers && (o.phoneNumbers = r.phoneNumbers), t(o);
}).catch(() => {
t(o);
});
});
});
}
function _e(e) {
return new Promise((t, n) => {
var o = {};
J().then((i) => {
R.get(
"https://www.linkedin.com/voyager/api/identity/profiles/" + e + "/profileView",
{
headers: { "csrf-token": i, accept: "*" },
withCredentials: !0
}
).then(({ data: r }) => {
r && r.entityUrn && (o = r), t(o);
}).catch(() => {
t(o);
});
});
});
}
function It(e) {
var n, o, i;
const t = e == null ? void 0 : e.data;
try {
return !t || !((i = (o = (n = t == null ? void 0 : t.searchDashClustersByAll) == null ? void 0 : n.elements) == null ? void 0 : o[0]) != null && i.items) ? [] : t.searchDashClustersByAll.elements[0].items.filter((r) => {
var s;
return (s = r == null ? void 0 : r.item) == null ? void 0 : s.entityResult;
}).map((r) => {
var l, u, y, h, p, v, E;
const s = r.item.entityResult, c = s.navigationUrl || "", d = ((y = (u = (l = c.split("/in/")) == null ? void 0 : l[1]) == null ? void 0 : u.split("?")) == null ? void 0 : y[0]) || "", g = new URL(c);
return {
name: ((h = s.title) == null ? void 0 : h.text) || "",
slug: d,
headline: ((p = s.primarySubtitle) == null ? void 0 : p.text) || "",
location: ((v = s.secondarySubtitle) == null ? void 0 : v.text) || "",
profileUrl: g.origin + g.pathname,
distance: ((E = s.entityCustomTrackingInfo) == null ? void 0 : E.memberDistance) || ""
};
});
} catch (r) {
return console.error("Error parsing mutual connections:", r), [];
}
}
function _t(e) {
return new Promise((t, n) => {
_e(e).then((o) => {
if (!o.entityUrn)
throw new Error("Could not get profile details");
const i = o.entityUrn.replace(
"urn:li:fs_profileView:",
""
);
return J().then(async (r) => {
const s = [], g = (l) => new Promise((u) => setTimeout(u, l));
for (let l = 0; l < 5; l++) {
const y = `https://www.linkedin.com/voyager/api/graphql?variables=(start:${l * 50},count:50,origin:MEMBER_PROFILE_CANNED_SEARCH,query:(flagshipSearchIntent:SEARCH_SRP,queryParameters:List((key:connectionOf,value:List(${i})),(key:network,value:List(F)),(key:resultType,value:List(PEOPLE))),includeFiltersInResponse:false))&queryId=voyagerSearchDashClusters.92cc53470cef3c578ab1d34676d5320c`;
try {
const h = await R.get(y, {
headers: {
"csrf-token": r,
accept: "*/*"
},
withCredentials: !0
}), p = It(h.data);
if (!p || p.length === 0)
break;
if (s.push(...p), l < 5 - 1) {
const v = Math.floor(Math.random() * 501) + 500;
await g(v);
}
} catch {
}
}
return s;
});
}).then((o) => {
t(o);
}).catch((o) => {
console.error("Error fetching mutual connections:", o), n(o);
});
});
}
function J() {
return new Promise((e, t) => {
chrome.cookies.get(
{
url: "https://www.linkedin.com",
name: "JSESSIONID"
},
function(o) {
e((o || {}).value.replace(/"/g, ""));
}
);
});
}
function At(e) {
var le, We, He;
const t = "sdk_debug_mode";
var o = [];
const i = async (a, f, m = {}, k = !1) => {
const S = {
ts: (/* @__PURE__ */ new Date()).toISOString(),
// Use ISO string for readability
lvl: a,
msg: f,
ctx: m
};
try {
((await chrome.storage.local.get([t]))[t] || k) && (console[a] || console.log)(
`[village-extension-sdk] ${f}`,
m && Object.keys(m).length > 0 ? m : ""
), o.push(S), o.length > 500 && (o = o.slice(o.length - 500));
} catch (C) {
console.error(
"[village-extension-sdk] Failed to write SDK log:",
C,
S
);
}
}, r = async () => {
try {
console.log(`--- Village Extension SDK Logs (Last ${o.length}) ---`), console.table(o);
} catch (a) {
console.error("[village-extension-sdk] Failed to retrieve logs:", a);
}
}, s = async () => {
try {
await chrome.storage.local.set({ [t]: !0 }), i(
"warn",
"Village Extension SDK Debug Mode ENABLED. Verbose logs will now appear in the console."
), console.log("[village-extension-sdk] Debug mode enabled.");
} catch (a) {
console.error(
"[village-extension-sdk] Failed to enable debug mode:",
a
);
}
}, c = async () => {
try {
await chrome.storage.local.set({ [t]: !1 }), i("warn", "Village Extension SDK Debug Mode DISABLED."), console.log("[village-extension-sdk] Debug mode disabled.");
} catch (a) {
console.error(
"[village-extension-sdk] Failed to disable debug mode:",
a
);
}
}, d = () => {
try {
o = [], i("warn", "Village Extension SDK logs cleared."), console.log("[village-extension-sdk] Logs cleared.");
} catch (a) {
console.error("[village-extension-sdk] Failed to clear logs:", a);
}
};
self.villageExtension = {
getLogs: r,
enableDebug: s,
// Renamed for consistency
disableDebug: c,
// Renamed for consistency
clearLogs: d
}, (() => {
const a = {
runtime: chrome == null ? void 0 : chrome.runtime,
storage: chrome == null ? void 0 : chrome.storage,
alarms: chrome == null ? void 0 : chrome.alarms,
webRequest: chrome == null ? void 0 : chrome.webRequest,
webNavigation: chrome == null ? void 0 : chrome.webNavigation,
cookies: chrome == null ? void 0 : chrome.cookies,
tabs: chrome == null ? void 0 : chrome.tabs,
// Less critical for init, but good to check
permissions: chrome == null ? void 0 : chrome.permissions
// Needed for permission check itself
};
let f = !0;
for (const [m, k] of Object.entries(a))
k || (i(
"error",
`Critical Chrome API missing for Village Extension SDK: chrome.${m}. Check manifest.json or browser compatibility.`,
{},
!0
), f = !1);
return f && i(
"info",
"All critical Chrome APIs for Village Extension SDK seem present."
), f;
})(), i("info", "ServiceWorker initializing...", {
CONFIG: e,
manifestVersion: (He = (We = (le = chrome == null ? void 0 : chrome.runtime) == null ? void 0 : le.getManifest) == null ? void 0 : We.call(le)) == null ? void 0 : He.version
}), i("info", "Checking permissions...");
const l = [
"cookies",
"storage",
"webRequest",
"alarms",
"webNavigation"
// Add this
];
chrome && chrome.permissions ? chrome.permissions.contains(
{ permissions: l },
(a) => {
a ? i(
"info",
"All required permissions for Village Extension SDK granted."
) : (i(
"warn",
`Missing required permissions for Village Extension SDK. Ensure these are granted: ${l.join(", ")}`
), console.error(
`[village-extension-sdk] Missing required permissions. Ensure these are granted: ${l.join(", ")}`
));
}
) : i(
"warn",
"Cannot check permissions for Village Extension SDK (chrome.permissions API not available)."
);
async function u() {
const [
a,
f,
m,
k
] = await Promise.allSettled([
P("linkedin_login"),
P("linkedin_loggedin_email"),
P("frontend_login"),
P("user_logged_obj")
]).then(
(A) => A.map(
(H) => H.status === "fulfilled" ? H.value : null
)
), S = chrome.runtime.getManifest().version;
return {
linkedin_login: a,
linkedin_loggedin_email: f,
frontend_login: m,
user_logged_obj: k,
version: S
};
}
async function y({ url: a }) {
var f;
try {
const m = await b(), k = await u();
if (!m)
return {
message: "Login on Village to find the best possible paths",
redirect: !0
};
const { data: S } = await R.post(
`${M}paths-check`,
{
url: a
},
{ headers: { "x-access-token": m } }
);
return {
...S,
token: m,
userReference: (f = k == null ? void 0 : k.user_logged_obj) == null ? void 0 : f.id
};
} catch {
}
}
async function h() {
if (!await v())
return {};
const f = await J();
let m = await P(
"linkedin_loggedin_email"
);
if (m)
return { email: m };
try {
const { data: k } = await R.get(
"https://www.linkedin.com/voyager/api/identity/profiles/me/profileContactInfo",
{ headers: { "csrf-token": f }, withCredentials: !0 }
);
if (k && k.emailAddress) {
let S = k.emailAddress;
return S.indexOf("phishing") >= 0 && (S = decodeURIComponent(S).replace(
/(.*?)https:.*?=(.*)/,
"$1$2"
)), await O("linkedin_loggedin_email", S), { email: S };
}
} catch {
return {};
}
return {};
}
async function p({ message: a, data: f }) {
try {
const m = await P("user_logged_obj");
return await R.post(M + "extension/logger", {
message: a,
data: f,
user: !m || ue(m) ? null : m
}), "ok";
} catch {
return "error";
}
}
function v() {
return new Promise((a, f) => {
chrome.cookies.get(
{ url: "https://www.linkedin.com/", name: "li_at" },
async function(m) {
m != null ? (await O("linkedin_login", !0), a(!0)) : (await O("linkedin_login", !1), vt(), a(!1));
}
);
});
}
function E({ token: a }) {
return new Promise((f, m) => {
chrome.cookies.set(
{
url: `${Ie}`,
name: "village.token",
value: a
},
() => f(!0)
);
});
}
var w = null;
function b() {
return new Promise((a, f) => {
chrome.cookies.get(
{ url: `${Ie}`, name: "village.token" },
async function(m) {
const k = m !== null;
w !== k && (await O("frontend_login", k), w = k), a(k ? m.value : !1);
}
);
});
}
chrome.runtime.onMessageExternal.addListener(
function(a, f, m) {
setTimeout(
() => i("info", "Received external message", {
type: a == null ? void 0 : a.message,
hasCallback: !!m,
senderId: f == null ? void 0 : f.id,
senderUrl: f == null ? void 0 : f.url
}),
0
);
const k = [
"getExtensionStatus",
"livelinessCheck",
"fillUpEmail",
"GET_MUTUAL_CONNECTIONS"
];
return a && a.message && k.includes(a.message) ? ((async () => {
try {
if (a.message === "getExtensionStatus") {
const C = await u();
m(C), a.shouldTriggerReset && x();
} else if (a.message === "livelinessCheck") {
const C = await yt();
m(C);
} else if (a.message === "fillUpEmail")
chrome.tabs.create(
{
url: "https://mail.google.com",
active: !0
},
(C) => {
const A = setInterval(() => {
chrome.tabs.sendMessage(
C.id,
{
type: "fillUpEmail",
email: a.email
},
function(H) {
if (!chrome.runtime.lastError && H)
return clearInterval(A);
}
);
}, 500);
}
);
else if (a.message === "GET_MUTUAL_CONNECTIONS") {
const { profileSlug: C } = a;
if (!C) {
m({
error: !0,
message: "Profile slug is required"
});
return;
}
try {
const A = await _t(C);
m(A);
} catch (A) {
m({ error: !0, message: A == null ? void 0 : A.message });
}
}
} catch (C) {
try {
m({
error: !0,
message: (C == null ? void 0 : C.message) || "Unknown error"
});
} catch {
}
}
})().catch((C) => {
}), !0) : !1;
}
);
async function L() {
const a = await u(), f = {
is_loggedin_on_linkedin: a.linkedin_login,
linkedin_email: a.linkedin_loggedin_email
}, m = await b();
f.is_loggedin_on_frontend = !!m;
const k = await P(
Le
);
f.is_paths_everywhere_settings_enabled = !!k;
const S = await P(
re
);
f.is_paths_everywhere_floating_enabled = S !== "DISABLED", Ge({
eventName: "Extension daily report",
properties: f,
force: !0
});
}
async function _(a) {
p({
message: "✅ STARTED saveLinkedinConnectionsIds",
data: null
});
try {
const f = await b();
if (await v() == !0) {
const k = await J();
let S = !0, C = a || 0;
for (; S; ) {
p({ message: "⏱ TIMEOUT...", data: null }), p({
message: `ℹ️ START FROM: ${C}`,
data: null
});
try {
const { data: A } = await R.get(
"https://www.linkedin.com/voyager/api/relationships/dash/connections?decorationId=com.linkedin.voyager.dash.deco.web.mynetwork.ConnectionListWithProfile-15&count=500&q=search&sortType=RECENTLY_ADDED&start=" + C,
{ headers: { "csrf-token": k }, withCredentials: !0 }
);
p({ message: "🗣 RESPONSE DATA", data: A });
const { elements: H } = A, U = H.filter((de) => de.connectedMemberResolutionResult).map((de) => Ct(de)), ce = H.length < 500;
await R.post(
M + "extension/saveids",
{
connections: U,
isFinished: ce,
startFrom: ce ? C : C + 500
},
{ headers: { "x-access-token": f } }
), p({
message: `📥 SAVING ${U.length} IDs`,
data: null
}), ce ? (p({
message: "✅ isFinished -> Number of IDs < 500",
data: null
}), S = !1, await O("fetched_connections", !0)) : (p({
message: "🔁 Continue looping -> Number of IDs = 500",
data: null
}), C += 500);
} catch (A) {
p({
message: "🚫 FAILED saveLinkedinConnectionsIds (while fetching from Linkedin)",
data: A.response && A.response.data ? A.response.data : A.response
});
}
}
} else
p({
message: "🚫 NOT LOGGED ON LINKEDIN",
data: null
});
} catch (f) {
p({
message: "🚫 FAILED saveLinkedinConnectionsIds",
data: f
});
}
}
async function x() {
const a = await P("user_logged_obj");
if (a && !ue(a) && (a != null && a.name))
if (await v() == !0) {
const { email: m } = await h(), k = await b();
if (!k)
return p({
message: "🚫 FAILED getUserIntegration -> Not logged in on App",
data: null
});
try {
const { data: S } = await R.post(
M + "extension/integration",
{ linkedinEmail: m, extensionId: chrome.runtime.id },
{
headers: { "x-access-token": k }
}
);
await O("user_integration", S), ne(S);
} catch (S) {
return S && S.response && S.response.status && Number(S.response.status) === 400 && Et(), p({
message: "🚫 FAILED getUserIntegration",
data: S
}), S;
}
} else
p({
message: "🚫 FAILED getUserIntegration -> Not logged in on Linkedin",
data: null
});
else
I();
}
async function D() {
if (!await v())
return p({
message: "🚫 [extensionLogin]: Not logged in on Linkedin"
});
const { email: f } = await h(), { data: m } = await R.get(
`${M}lilo?e=${encodeURIComponent(xt(f))}`
);
m.t && (await E({ token: m.t }), I());
}
async function I() {
const a = await b();
if (!a)
return D(), p({
message: "⚠️ [extensionLogin] -> Not logged in on App 👉 attempting Loging in the user via Linkedin",
data: null
});
try {
const { data: f } = await R.get(M + "user", {
headers: { "x-access-token": a }
});
await O("user_logged_obj", f), x();
} catch (f) {
return p({
message: "⚠️ [extensionLogin] -> Error on try/catch block",
data: f
}), f;
}
}
var T = !1;
async function ne(a) {
if (!T) {
T = !0;
try {
const f = a.sync_data || !1;
(!f || !f.user_profile) && await wt(), (!f.connection_ids || !f.connection_ids.is_finished) && await _(
f.connection_ids && f.connection_ids.start_from ? f.connection_ids.start_from : void 0
);
} catch (f) {
p({
message: "🚫 FAILED handleUserIntegration",
data: f
});
}
T = !1;
}
}
async function yt() {
const a = {
getProfileUserDetails: !1,
getContactInfo: !1,
getLinkedinLoggedinUserInfo: !1,
getProfileConnections: !1
};
try {
await _e("me"), a.getProfileUserDetails = !0;
} catch {
a.getProfileUserDetails = !1;
}
try {
await ze("me"), a.getContactInfo = !0;
} catch {
a.getContactInfo = !1;
}
try {
await h(), a.getLinkedinLoggedinUserInfo = !0;
} catch {
a.getLinkedinLoggedinUserInfo = !1;
}
try {
const f = await J();
await R.get(
"https://www.linkedin.com/voyager/api/relationships/dash/connections?decorationId=com.linkedin.voyager.dash.deco.web.mynetwork.ConnectionListWithProfile-15&count=500&q=search&sortType=RECENTLY_ADDED&start=0",
{ headers: { "csrf-token": f }, withCredentials: !0 }
), a.getProfileConnections = !0;
} catch {
a.getProfileConnections = !1;
}
return a;
}
async function wt() {
p({
message: "✅ STARTED getAndSendUsersProfileData",
data: null
});
try {
const m = await ze("me"), k = await _e("me");
var a = St(k);
a.contact_info = m, a.public_identifier = k.profile.miniProfile.publicIdentifier;
} catch (m) {
p({
message: `🚫 FAILED parsing user profile data - error: ${m.message}`,
data: m
});
}
const f = await b();
if (!f)
return p({
message: "🚫 FAILED getAndSendUsersProfileData -> Not logged in on App",
data: null
});
try {
const m = await R.post(
M + "extension/saveuserprofile",
{ userProfileData: a },
{
headers: { "x-access-token": f }
}
);
await O("saved_profile", !0);
return;
} catch (m) {
throw p({
message: "🚫 FAILED getAndSendUsersProfileData",
data: m
}), new Error("Failed to save user profile data");
}
}
async function vt() {
const a = await b();
if (!a)
return p({
message: "🚫 FAILED notifyUserLinkedinLogin -> Not logged in on App",
data: null
});
try {
await R.get(M + "notify-linkedin", {
headers: { "x-access-token": a }
});
} catch (f) {
return p({
message: "🚫 FAILED notifyUserLinkedinLogin",
data: f
}), f;
}
}
async function Et() {
const a = await P("user_logged_obj");
if (a && !ue(a))
try {
await R.get(`${M}notify-app/${a.id}`);
} catch (f) {
return p({
message: "🚫 FAILED notifyUserAppLogin",
data: f
}), f;
}
else
p({
message: "🚫 FAILED notifyUserAppLogin",
data: "Empty user_logged_obj"
});
}
async function Ge({ eventName: a, properties: f, force: m }) {
const k = await P("user_logged_obj");
try {
if (!k || ue(k) && !m)
return;
const S = k.id || kt(), C = {
event: a,
properties: {
...f,
distinct_id: S
}
}, [A] = await Promise.allSettled([
ot.post("/capture", C)
]);
} catch {
}
}
async function Ve(a, f) {
var m, k, S, C, A;
if (f) {
if (!await b())
return;
new URL(f);
const U = await P("user_logged_obj");
if (!!!(U != null && U.last_cache_date) || !((C = (S = (k = (m = U == null ? void 0 : U.app) == null ? void 0 : m.config) == null ? void 0 : k.features) == null ? void 0 : S.pathsEverywhere) == null ? void 0 : C.enabled) || f.includes(
(A = U == null ? void 0 : U.app) == null ? void 0 : A.domain_name
) || f.includes("village.do"))
return;
P(Le).then((ke) => {
const je = typeof ke > "u";
if (je && O(Le, !0), ke || je)
try {
chrome.tabs.sendMessage(
a,
{
type: "pathsEverywhere"
},
(bt) => {
chrome.runtime.lastError;
}
);
} catch {
}
}).catch((ke) => {
});
}
}
chrome.runtime.onMessage.addListener((a, f, m) => (console.log("[EXT] Received message:", a), [
"village:bind:extension",
"saveUISettings",
"getUserIntegration",
"getSettings",
"checkPaths",
"tracking"
].includes(a.command) ? (console.log(`[EXT] Handling known command: ${a.command}`), (async () => {
try {
switch (console.log("[EXT] getUserIntegration switch ", a.command), a.command) {
case "village:bind:extension":
await O("village:bind:extension", a.data), m({ success: !0 });
break;
case "saveUISettings":
await O("user_logged_obj", a.data), m({ success: !0 });
break;
case "getUserIntegration":
await x(), m({ success: !0 });
break;
case "getSettings":
const C = await u();
m({ uiSettings: C });
break;
case "checkPaths":
const A = await y({
url: a.url
});
m(A);
break;
case "tracking":
await Ge({
eventName: a.eventName,
properties: a.properties
}), m({ success: !0 });
break;
}
} catch (C) {
console.error("[EXT] Error handling command:", C), m({ error: C.message });
}
})().catch((C) => {
console.error("[EXT] Async operation error:", C);
}), console.log("[EXT] Unknown command received, ignoring:", a.command), !0) : !1)), i("info", "Setting up alarms...");
try {
chrome && chrome.alarms && (i("info", "Attempting to clear/create getUserIntegration alarm."), chrome.alarms.clear("getUserIntegration", (a) => {
chrome.runtime.lastError ? i("error", "Error clearing getUserIntegration alarm", {
error: chrome.runtime.lastError.message
}) : (i(
"info",
`getUserIntegration alarm cleared (existed: ${a})`
), chrome.alarms.create("getUserIntegration", {
delayInMinutes: 60,
periodInMinutes: 60
}), i("info", "Created getUserIntegration alarm (60 min period)."));
}), i("info", "Attempting to clear/create dailyReport alarm."), chrome.alarms.clear("dailyReport", (a) => {
chrome.runtime.lastError ? i("error", "Error clearing dailyReport alarm", {
error: chrome.runtime.lastError.message
}) : (i("info", `dailyReport alarm cleared (existed: ${a})`), chrome.alarms.create("dailyReport", {
delayInMinutes: 5,
// Start 5 minutes after the extension is loaded/installed
periodInMinutes: 1440
// Set to run every 1440 minutes (24 hours)
}), i("info", "Created dailyReport alarm (24 hour period)."));
}));
} catch (a) {
i("error", "Unexpected error during alarm setup", {
error: a == null ? void 0 : a.message,
stack: a == null ? void 0 : a.stack
});
}
i("info", "Alarm setup phase complete."), i("info", "Attaching webRequest listeners...");
try {
chrome.webRequest.onBeforeSendHeaders.addListener(
async function(a) {
return a.url.indexOf("signin") > 0 || a.url.indexOf("login-submit") > 0 ? (await O("linkedin_login", !0), await new Promise((f) => setTimeout(f, 7500)), x()) : a.url.indexOf("/logout") > 0 && await O("linkedin_login", !1), {
requestHeaders: a.requestHeaders
};
},
{
urls: ["*://*.linkedin.com/*/*"]
},
["requestHeaders"]
);
} catch (a) {
i(
"error",
"Failed to attach LinkedIn webRequest listener",
{ error: a == null ? void 0 : a.message },
!0
);
}
try {
chrome.webRequest.onBeforeSendHeaders.addListener(
async function(a) {
return a.url.indexOf("/callback") > 0 ? (await O("frontend_login", !0), await new Promise((f) => setTimeout(f, 7500)), x()) : a.url.indexOf("/logout") > 0 && await O("frontend_login", !1), {
requestHeaders: a.requestHeaders
};
},
{
urls: [`${M}*`, `${M}*/*/*`]
},
["requestHeaders"]
);
} catch (a) {
i(
"error",
"Failed to attach Frontend webRequest listener",
{ error: a == null ? void 0 : a.message },
!0
);
}
chrome.alarms.onAlarm.addListener(function(a) {
i("info", `Alarm triggered: ${a.name}`), a.name == "getUserIntegration" && x().catch((f) => {
}), a.name === "dailyReport" && L().catch((f) => {
});
}), chrome.runtime.onInstalled.addListener((a) => {
I().catch((f) => {
});
}), chrome.runtime.onStartup.addListener(() => {
I().catch((a) => {
});
}), chrome.tabs.onUpdated.addListener((a, f) => {
Ve(a, f.url).catch((m) => {
});
}), chrome.webNavigation.onCompleted.addListener((a) => {
const { tabId: f, url: m } = a;
Ve(f, m).catch((k) => {
});
});
}
const Tt = ["top", "right", "bottom", "left"], he = Math.min, Y = Math.max, pe = Math.round, fe = Math.floor, B = (e) => ({
x: e,
y: e
});
function Ke(e, t, n) {
return Y(e, he(t, n));
}
function Re(e, t) {
return typeof e == "function" ? e(t) : e;
}
function De(e) {
return e.split("-")[0];
}
function Ot(e) {
return e.split("-")[1];
}
function rt(e) {
return e === "x" ? "y" : "x";
}
function Pt(e) {
return e === "y" ? "height" : "width";
}
function Ne(e) {
return ["top", "bottom"].includes(De(e)) ? "y" : "x";
}
function Rt(e) {
return rt(Ne(e));
}
function Dt(e) {
return {
top: 0,
right: 0,
bottom: 0,
left: 0,
...e
};
}
function Nt(e) {
return typeof e != "number" ? Dt(e) : {
top: e,
right: e,
bottom: e,
left: e
};
}
function me(e) {
const {
x: t,
y: n,
width: o,
height: i
} = e;
return {
width: o,
height: i,
top: n,
left: t,
right: t + o,
bottom: n + i,
x: t,
y: n
};
}
function qe(e, t, n) {
let {
reference: o,
floating: i
} = e;
const r = Ne(t), s = Rt(t), c = Pt(s), d = De(t), g = r === "y", l = o.x + o.width / 2 - i.width / 2, u = o.y + o.height / 2 - i.height / 2, y = o[c] / 2 - i[c] / 2;
let h;
switch (d) {
case "top":
h = {
x: l,
y: o.y - i.height
};
break;
case "bottom":
h = {
x: l,
y: o.y + o.height
};
break;
case "right":
h = {
x: o.x + o.width,
y: u
};
break;
case "left":
h = {
x: o.x - i.width,
y: u
};
break;
default:
h = {
x: o.x,
y: o.y
};
}
switch (Ot(t)) {
case "start":
h[s] -= y * (n && g ? -1 : 1);
break;
case "end":
h[s] += y * (n && g ? -1 : 1);
break;
}
return h;
}
const Ut = async (e, t, n) => {
const {
placement: o = "bottom",
strategy: i = "absolute",
middleware: r = [],
platform: s
} = n, c = r.filter(Boolean), d = await (s.isRTL == null ? void 0 : s.isRTL(t));
let g = await s.getElementRects({
reference: e,
floating: t,
strategy: i
}), {
x: l,
y: u
} = qe(g, o, d), y = o, h = {}, p = 0;
for (let v = 0; v < c.length; v++) {
const {
name: E,
fn: w
} = c[v], {
x: b,
y: L,
data: _,
reset: x
} = await w({
x: l,
y: u,
initialPlacement: o,
placement: y,
strategy: i,
middlewareData: h,
rects: g,
platform: s,
elements: {
reference: e,
floating: t
}
});
l = b ?? l, u = L ?? u, h = {
...h,
[E]: {
...h[E],
..._
}
}, x && p <= 50 && (p++, typeof x == "object" && (x.placement && (y = x.placement), x.rects && (g = x.rects === !0 ? await s.getElementRects({
reference: e,
floating: t,
strategy: i
}) : x.rects), {
x: l,
y: u
} = qe(g, y, d)), v = -1);
}
return {
x: l,
y: u,
placement: y,
strategy: i,
middlewareData: h
};
};
async function Ae(e, t) {
var n;
t === void 0 && (t = {});
const {
x: o,
y: i,
platform: r,
rects: s,
elements: c,
strategy: d
} = e, {
boundary: g = "clippingAncestors",
rootBoundary: l = "viewport",
elementContext: u = "floating",
altBoundary: y = !1,
padding: h = 0
} = Re(t, e), p = Nt(h), E = c[y ? u === "floating" ? "reference" : "floating" : u], w = me(await r.getClippingRect({
element: (n = await (r.isElement == null ? void 0 : r.isElement(E))) == null || n ? E : E.contextElement || await (r.getDocumentElement == null ? void 0 : r.getDocumentElement(c.floating)),
boundary: g,
rootBoundary: l,
strategy: d
})), b = u === "floating" ? {
x: o,
y: i,
width: s.floating.width,
height: s.floating.height
} : s.reference, L = await (r.getOffsetParent == null ? void 0 : r.getOffsetParent(c.floating)), _ = await (r.isElement == null ? void 0 : r.isElement(L)) ? await (r.getScale == null ? void 0 : r.getScale(L)) || {
x: 1,
y: 1
} : {
x: 1,
y: 1
}, x = me(r.convertOffsetParentRelativeRectToViewportRelativeRect ? await r.convertOffsetParentRelativeRectToViewportRelativeRect({
elements: c,
rect: b,
offsetParent: L,
strategy: d
}) : b);
return {
top: (w.top - x.top + p.top) / _.y,
bottom: (x.bottom - w.bottom + p.bottom) / _.y,
left: (w.left - x.left + p.left) / _.x,
right: (x.right - w.right + p.right) / _.x
};
}
function Xe(e, t) {
return {
top: e.top - t.height,
right: e.right - t.width,
bottom: e.bottom - t.height,
left: e.left - t.width
};
}
function Ye(e) {
return Tt.some((t) => e[t] >= 0);
}
const Mt = function(e) {
return e === void 0 && (e = {}), {
name: "hide",
options: e,
async fn(t) {
const {
rects: n
} = t, {
strategy: o = "referenceHidden",
...i
} = Re(e, t);
switch (o) {
case "referenceHidden": {
const r = await Ae(t, {
...i,
elementContext: "reference"
}), s = Xe(r, n.reference);
return {
data: {
referenceHiddenOffsets: s,
referenceHidden: Ye(s)
}
};
}
case "escaped": {
const r = await Ae(t, {
...i,
altBoundary: !0
}), s = Xe(r, n.floating);
return {
data: {
escapedOffsets: s,
escaped: Ye(s)
}
};
}
default:
return {};
}
}
};
}, Ft = function(e) {
return e === void 0 && (e = {}), {
name: "shift",
options: e,
async fn(t) {
const {
x: n,
y: o,
placement: i
} = t, {
mainAxis: r = !0,
crossAxis: s = !1,
limiter: c = {
fn: (E) => {
let {
x: w,
y: b
} = E;
return {
x: w,
y: b
};
}
},
...d
} = Re(e, t), g = {
x: n,
y: o
}, l = await Ae(t, d), u = Ne(De(i)), y = rt(u);
let h = g[y], p = g[u];
if (r) {
const E = y === "y" ? "top" : "left", w = y === "y" ? "bottom" : "right", b = h + l[E], L = h - l[w];
h = Ke(b, h, L);
}
if (s) {
const E = u === "y" ? "top" : "left", w = u === "y" ? "bottom" : "right", b = p + l[E], L = p - l[w];
p = Ke(b, p, L);
}
const v = c.fn({
...t,
[y]: h,
[u]: p
});
return {
...v,
data: {
x: v.x - n,
y: v.y - o,
enabled: {
[y]: r,
[u]: s
}
}
};
}
};
};
function ve() {
return typeof window < "u";
}
function te(e) {
return st(e) ? (e.nodeName || "").toLowerCase() : "#document";
}
function N(e) {
var t;
return (e == null || (t = e.ownerDocument) == null ? void 0 : t.defaultView) || window;
}
function W(e) {
var t;
return (t = (st(e) ? e.ownerDocument : e.document) || window.document) == null ? void 0 : t.documentElement;
}
function st(e) {
return ve() ? e instanceof Node || e instanceof N(e).Node : !1;
}
function F(e) {
return ve() ? e instanceof Element || e instanceof N(e).Element : !1;
}
function V(e) {
return ve() ? e instanceof HTMLElement || e instanceof N(e).HTMLElement : !1;
}
function Ze(e) {
return !ve() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof N(e).ShadowRoot;
}
function ae(e) {
const {
overflow: t,
overflowX: n,
overflowY: o,
display: i
} = $(e);
return /auto|scroll|overlay|hidden|clip/.test(t + o + n) && !["inline", "contents"].includes(i);
}
function $t(e) {
return ["table", "td", "th"].includes(te(e));
}
function Ee(e) {
return [":popover-open", ":modal"].some((t) => {
try {
return e.matches(t);
} catch {
return !1;
}
});
}
function Ue(e) {
const t = Me(), n = F(e) ? $(e) : e;
return ["transform", "translate", "scale", "rotate", "perspective"].some((o) => n[o] ? n[o] !== "none" : !1) || (n.containerType ? n.containerType !== "normal" : !1) || !t && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !t && (n.filter ? n.filter !== "none" : !1) || ["transform", "translate", "scale", "rotate", "perspective", "filter"].some((o) => (n.willChange || "").includes(o)) || ["paint", "layout", "strict", "content"].some((o) => (n.contain || "").includes(o));
}
function Bt(e) {
let t = z(e);
for (; V(t) && !ee(t); ) {
if (Ue(t))
return t;
if (Ee(t))
return null;
t = z(t);
}
return null;
}
function Me() {
return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
}
function ee(e) {
return ["html", "body", "#document"].includes(te(e));
}
function $(e) {
return N(e).getComputedStyle(e);
}
function be(e) {
return F(e) ? {
scrollLeft: e.scrollLeft,
scrollTop: e.scrollTop
} : {
scrollLeft: e.scrollX,
scrollTop: e.scrollY
};
}
function z(e) {
if (te(e) === "html")
return e;
const t = (
// Step into the shadow DOM of the parent of a slotted node.
e.assignedSlot || // DOM Element detected.
e.parentNode || // ShadowRoot detected.
Ze(e) && e.host || // Fallback.
W(e)
);
return Ze(t) ? t.host : t;
}
function at(e) {
const t = z(e);
return ee(t) ? e.ownerDocument ? e.ownerDocument.body : e.body : V(t) && ae(t) ? t : at(t);
}
function se(e, t, n) {
var o;
t === void 0 && (t = []), n === void 0 && (n = !0);
const i = at(e), r = i === ((o = e.ownerDocument) == null ? void 0 : o.body), s = N(i);
if (r) {
const c = Te(s);
return t.concat(s, s.visualViewport || [], ae(i) ? i : [], c && n ? se(c) : []);
}
return t.concat(i, se(i, [], n));
}
function Te(e) {
return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
}
function lt(e) {
const t = $(e);
let n = parseFloat(t.width) || 0, o = parseFloat(t.height) || 0;
const i = V(e), r = i ? e.offsetWidth : n, s = i ? e.offsetHeight : o, c = pe(n) !== r || pe(o) !== s;
return c && (n = r, o = s), {
width: n,
height: o,
$: c
};
}
function Fe(e) {
return F(e) ? e : e.contextElement;
}
function Q(e) {
const t = Fe(e);
if (!V(t))
return B(1);
const n = t.getBoundingClientRect(), {
width: o,
height: i,
$: r
} = lt(t);
let s = (r ? pe(n.width) : n.width) / o, c = (r ? pe(n.height) : n.height) / i;
return (!s || !Number.isFinite(s)) && (s = 1), (!c || !Number.isFinite(c)) && (c = 1), {
x: s,
y: c
};
}
const Gt = /* @__PURE__ */ B(0);
function ct(e) {
const t = N(e);
return !Me() || !t.visualViewport ? Gt : {
x: t.visualViewport.offsetLeft,
y: t.visualViewport.offsetTop
};
}
function Vt(e, t, n) {
return t === void 0 && (t = !1), !n || t && n !== N(e) ? !1 : t;
}
function Z(e, t, n, o) {
t === void 0 && (t = !1), n === void 0 && (n = !1);
const i = e.getBoundingClientRect(), r = Fe(e);
let s = B(1);
t && (o ? F(o) && (s = Q(o)) : s = Q(e));
const c = Vt(r, n, o) ? ct(r) : B(0);
let d = (i.left + c.x) / s.x, g = (i.top + c.y) / s.y, l = i.width / s.x, u = i.height / s.y;
if (r) {
const y = N(r), h = o && F(o) ? N(o) : o;
let p = y, v = Te(p);
for (; v && o && h !== p; ) {
const E = Q(v), w = v.getBoundingClientRect(), b = $(v), L = w.left + (v.clientLeft + parseFloat(b.paddingLeft)) * E.x, _ = w.top + (v.clientTop + parseFloat(b.paddingTop)) * E.y;
d *= E.x, g *= E.y, l *= E.x, u *= E.y, d += L, g += _, p = N(v), v = Te(p);
}
}
return me({
width: l,
height: u,
x: d,
y: g
});
}
function $e(e, t) {
const n = be(e).scrollLeft;
return t ? t.left + n : Z(W(e)).left + n;
}
function dt(e, t, n) {
n === void 0 && (n = !1);
const o = e.getBoundingClientRect(), i = o.left + t.scrollLeft - (n ? 0 : (
// RTL <body> scrollbar.
$e(e, o)
)), r = o.top + t.scrollTop;
return {
x: i,
y: r
};
}
function Wt(e) {
let {
elements: t,
rect: n,
offsetParent: o,
strategy: i
} = e;
const r = i === "fixed", s = W(o), c = t ? Ee(t.floating) : !1;
if (o === s || c && r)
return n;
let d = {
scrollLeft: 0,
scrollTop: 0
}, g = B(1);
const l = B(0), u = V(o);
if ((u || !u && !r) && ((te(o) !== "body" || ae(s)) && (d = be(o)), V(o))) {
const h = Z(o);
g = Q(o), l.x = h.x + o.clientLeft, l.y = h.y + o.clientTop;
}
const y = s && !u && !r ? dt(s, d, !0) : B(0);
return {
width: n.width * g.x,
height: n.height * g.y,
x: n.x * g.x - d.scrollLeft * g.x + l.x + y.x,
y: n.y * g.y - d.scrollTop * g.y + l.y + y.y
};
}
function Ht(e) {
return Array.from(e.getClientRects());
}
function jt(e) {
const t = W(e), n = be(e), o = e.ownerDocument.body, i = Y(t.scrollWidth, t.clientWidth, o.scrollWidth, o.clientWidth), r = Y(t.scrollHeight, t.clientHeight, o.scrollHeight, o.clientHeight);
let s = -n.scrollLeft + $e(e);
const c = -n.scrollTop;
return $(o).direction === "rtl" && (s += Y(t.clientWidth, o.clientWidth) - i), {
width: i,
height: r,
x: s,
y: c
};
}
function zt(e, t) {
const n = N(e), o = W(e), i = n.visualViewport;
let r = o.clientWidth, s = o.clientHeight, c = 0, d = 0;
if (i) {
r = i.width, s = i.height;
const g = Me();
(!g || g && t === "fixed") && (c = i.offsetLeft, d = i.offsetTop);
}
return {
width: r,
height: s,
x: c,
y: d
};
}
function Kt(e, t) {
const n = Z(e, !0, t === "fixed"), o = n.top + e.clientTop, i = n.left + e.clientLeft, r = V(e) ? Q(e) : B(1), s = e.clientWidth * r.x, c = e.clientHeight * r.y, d = i * r.x, g = o * r.y;
return {
width: s,
height: c,
x: d,
y: g
};
}
function Je(e, t, n) {
let o;
if (t === "viewport")
o = zt(e, n);
else if (t === "document")
o = jt(W(e));
else if (F(t))
o = Kt(t, n);
else {
const i = ct(e);
o = {
x: t.x - i.x,
y: t.y - i.y,
width: t.width,
height: t.height
};
}
return me(o);
}
function ut(e, t) {
const n = z(e);
return n === t || !F(n) || ee(n) ? !1 : $(n).position === "fixed" || ut(n, t);
}
function qt(e, t) {
const n = t.get(e);
if (n)
return n;
let o = se(e, [], !1).filter((c) => F(c) && te(c) !== "body"), i = null;
const r = $(e).position === "fixed";
let s = r ? z(e) : e;
for (; F(s) && !ee(s); ) {
const c = $(s), d = Ue(s);
!d && c.position === "fixed" && (i = null), (r ? !d && !i : !d && c.position === "static" && !!i && ["absolute", "fixed"].includes(i.position) || ae(s) && !d && ut(e, s)) ? o = o.filter((l) => l !== s) : i = c, s = z(s);
}
return t.set(e, o), o;
}
function Xt(e) {
let {
element: t,
boundary: n,
rootBoundary: o,
strategy: i
} = e;
const s = [...n === "clippingAncestors" ? Ee(t) ? [] : qt(t, this._c) : [].concat(n), o], c = s[0], d = s.reduce((g, l) => {
const u = Je(t, l, i);
return g.top = Y(u.top, g.top), g.right = he(u.right, g.right), g.bottom = he(u.bottom, g.bottom), g.left = Y(u.left, g.left), g;
}, Je(t, c, i));
return {
width: d.right - d.left,
height: d.bottom - d.top,
x: d.left,
y: d.top
};
}
function Yt(e) {
const {
width: t,
height: n
} = lt(e);
return {
width: t,
height: n
};
}
function Zt(e, t, n) {
const o = V(t), i = W(t), r = n === "fixed", s = Z(e, !0, r, t);
let c = {
scrollLeft: 0,
scrollTop: 0
};
const d = B(0);
if (o || !o && !r)
if ((te(t) !== "body" || ae(i)) && (c = be(t)), o) {
const y = Z(t, !0, r, t);
d.x = y.x + t.clientLeft, d.y = y.y + t.clientTop;
} else
i && (d.x = $e(i));
const g = i && !o && !r ? dt(i, c) : B(0), l = s.left + c.scrollLeft - d.x - g.x, u = s.top + c.scrollTop - d.y - g.y;
return {
x: l,
y: u,
width: s.width,
height: s.height
};
}
function Se(e) {
return $(e).position === "static";
}
function Qe(e, t) {
if (!V(e) || $(e).position === "fixed")
return null;
if (t)
return t(e);
let n = e.offsetParent;
return W(e) === n && (n = n.ownerDocument.body), n;
}
function ft(e, t) {
const n = N(e);
if (Ee(e))
return n;
if (!V(e)) {
let i = z(e);
for (; i && !ee(i); ) {
if (F(i) && !Se(i))
return i;
i = z(i);
}
return n;
}
let o = Qe(e, t);
for (; o && $t(o) && Se(o); )
o = Qe(o, t);
return o && ee(o) && Se(o) && !Ue(o) ? n : o || Bt(e) || n;
}
const Jt = async function(e) {
const t = this.getOffsetParent || ft, n = this.getDimensions, o = await n(e.floating);
return {
reference: Zt(e.reference, await t(e.floating), e.strategy),
floating: {
x: 0,
y: 0,
width: o.width,
height: o.height
}
};
};
function Qt(e) {
return $(e).direction === "rtl";
}
const en = {
convertOffsetParentRelativeRectToViewportRelativeRect: Wt,
getDocumentElement: W,
getClippingRect: Xt,
getOffsetParent: ft,
getElementRects: Jt,
getClientRects: Ht,
getDimensions: Yt,
getScale: Q,
isElement: F,
isRTL: Qt
};
function gt(e, t) {
return e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height;
}
function tn(e, t) {
let n = null, o;
const i = W(e);
function r() {
var c;
clearTimeout(o), (c = n) == null || c.disconnect(), n = null;
}
function s(c, d) {
c === void 0 && (c = !1), d === void 0 && (d = 1), r();
const g = e.getBoundingClientRect(), {
left: l,
top: u,
width: y,
height: h
} = g;
if (c || t(), !y || !h)
return;
const p = fe(u), v = fe(i.clientWidth - (l + y)), E = fe(i.clientHeight - (u + h)), w = fe(l), L = {
rootMargin: -p + "px " + -v + "px " + -E + "px " + -w + "px",
threshold: Y(0, he(1, d)) || 1
};
let _ = !0;
function x(D) {
const I = D[0].intersectionRatio;
if (I !== d) {
if (!_)
return s();
I ? s(!1, I) : o = setTimeout(() => {
s(!1, 1e-7);
}, 1e3);
}
I === 1 && !gt(g, e.getBoundingClientRect()) && s(), _ = !1;
}
try {
n = new IntersectionObserver(x, {
...L,
// Handle <iframe>s
root: i.ownerDocument
});
} catch {
n = new IntersectionObserver(x, L);
}
n.observe(e);
}
return s(!0), r;
}
function nn(e, t, n, o) {
o === void 0 && (o = {});
const {
ancestorScroll: i = !0,
ancestorResize: r = !0,
elementResize: s = typeof ResizeObserver == "function",
layoutShift: c = typeof IntersectionObserver == "function",
animationFrame: d = !1
} = o, g = Fe(e), l = i || r ? [...g ? se(g) : [], ..