@i.un/libs 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- const e=Symbol("undefined");function t(e){return"function"==typeof(null==e?void 0:e.clone)}function n(e){const t=typeof e;return null===e||"string"===t||"number"===t||"boolean"===t||"undefined"===t}function i(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this}function o(e){return n(e)?String(e):JSON.stringify(e,function(e,t){return"object"!=typeof t||null===t||Array.isArray(t)?t:Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{})})}function r(e){if(null===e||"object"!=typeof e)return e;if(t(e))return e.clone();if(Array.isArray(e))return e.map(e=>r(e));const n={};for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[t]=r(e[t]));return n}function s(e,t){let n=null;return function(...i){const o=this;null!==n&&clearTimeout(n),n=setTimeout(()=>{e.apply(o,i),n=null},t)}}function a(e,t=0,...n){return new Promise(i=>{0===t?i(e(...n)):setTimeout(()=>{i(e(...n))},t)})}function c(e){return new Proxy({},{get:(t,n)=>t.hasOwnProperty(n)?t[n]:e})}const l=c(e),h=c(!1);function d(e){return l[e]}function u(t){return l[t]!==e}const p={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"},identifier:""};function m(e,t=p){const n=function(...n){const i=o(n)+e.name+(t.identifier||"");if(u(i))return Promise.resolve(r(d(i)));if(h[i]){const e=Object.assign({},p,t);return new Promise(t=>{const n=Date.now(),o=setInterval(()=>{u(i)?(clearInterval(o),t(r(d(i)))):Date.now()-n>e.timeout&&(h[i]=!1,clearInterval(o),t(r(e.timeoutResult)))},100)})}return h[i]=!0,e.apply(this,n).then(e=>(l[i]=e,r(l[i]))).catch(e=>{throw e}).finally(()=>{h[i]=!1})};return Object.defineProperty(n,"name",{value:`cacheWrapper_${e.name}`,configurable:!0}),n}function g(t,n=0){const i=function i(...o){if(i.isExecuting)return Promise.resolve(e);i.isExecuting=!0;const r=performance.now(),s=t.apply(this,o);return s.finally(()=>{const e=performance.now()-r;n&&n>e?setTimeout(()=>{i.isExecuting=!1},n-e):i.isExecuting=!1}),s};return i.isExecuting=!1,i}function y(){return y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},y.apply(null,arguments)}class f{constructor(e){this.storageKey=void 0,this.data={},this.changeCallbacks=[],this.storageKey=e}static getInstanceKey(e){return`memory:${e}`}static getInstance(e){const t=this.getInstanceKey(e);return this.instances.has(t)||this.instances.set(t,new f(e)),this.instances.get(t)}static create(e){return this.getInstance(e)}static clearInstance(e){const t=this.getInstanceKey(e),n=this.instances.get(t);n&&n.clearChangeCallbacks(),this.instances.delete(t)}static clearAllInstances(){this.instances.forEach(e=>{e.clearChangeCallbacks()}),this.instances.clear()}set(e,t){try{const n=this.data[e];this.data=y({},this.data,{[e]:t}),this.triggerChange(n,t)}catch(e){throw console.error("MemoryStore.set 失败:",e),e}}get(e){try{return this.data[e]}catch(e){throw console.error("MemoryStore.get 失败:",e),e}}getAll(){return y({},this.data)}remove(e){try{if(e in this.data){const t=this.data[e],n=y({},this.data);delete n[e],this.data=n,this.triggerChange(t,void 0)}}catch(e){throw console.error("MemoryStore.remove 失败:",e),e}}clear(){try{const e=y({},this.data);this.data={},this.triggerChange(e,{})}catch(e){throw console.error("MemoryStore.clear 失败:",e),e}}setMultiple(e){try{const t=y({},this.data);this.data=y({},this.data,e),this.triggerChange(t,this.data)}catch(e){throw console.error("MemoryStore.setMultiple 失败:",e),e}}onChanged(e){this.changeCallbacks.push(e)}triggerChange(e,t){if(this.changeCallbacks.length>0){const n={[this.storageKey]:{oldValue:e,newValue:t}};this.changeCallbacks.forEach(e=>{try{e(n)}catch(e){console.error("MemoryStore 变化回调执行失败:",e)}})}}clearChangeCallbacks(){this.changeCallbacks=[]}has(e){try{return e in this.data}catch(e){return console.error("MemoryStore.has 失败:",e),!1}}getSize(){try{const e=JSON.stringify(this.data);return new Blob([e]).size}catch(e){return console.error("MemoryStore.getSize 失败:",e),0}}getStoreKey(){return this.storageKey}getStoreType(){return"memory"}}function v(e,t,n,i=!1){if(t in e.style)e.style[t]=n;else{const o=i?"important":"";e.style.setProperty(t,String(n),o)}}function w({tag:e="div",children:t=[],props:n={},attrs:i={},styles:o={}}={}){const r=document.createElement(e);Object.assign(r,n);for(const[e,t]of Object.entries(i))!1!==t&&r.setAttribute(e,t);for(const[e,t]of Object.entries(o))v(r,e,t);const s=Array.isArray(t)?t:[t];for(const e of s)e&&("object"==typeof e?e instanceof Element?r.appendChild(e):r.appendChild(w(e)):r.appendChild(document.createTextNode(e)));return r}function b(e){const t=document.createElementNS("http://www.w3.org/2000/svg",e.type);if(e.props)for(const[n,i]of Object.entries(e.props))t.setAttribute(n,i);if("string"==typeof e.children){const n=document.createTextNode(e.children);t.appendChild(n)}else Array.isArray(e.children)&&e.children.forEach(e=>{const n=b(e);t.appendChild(n)});return t}function S(e){const t=(new DOMParser).parseFromString(e,"image/svg+xml").documentElement;if(!(t instanceof SVGElement))throw new Error("解析失败,结果不是有效的 SVG 元素");return t}function k(e){return"string"==typeof e?S(e):b(e)}async function C(e){try{const t=await fetch(e);if(!t.ok)throw new Error(`网络请求失败: ${t.status} ${t.statusText}`);return S(await t.text())}catch(e){const t=e instanceof Error?e.message:"未知错误";throw new Error(`无法创建 SVG 元素: ${t}`)}}function M(e){e&&setTimeout(()=>{e.scrollTop=e.scrollHeight},0)}function x(e){e&&("true"!==e.dataset.isListeningForUserScroll&&(function(e){e&&e.addEventListener("scroll",()=>{!function(e,t){e.dataset.userInteracted=t?"true":"false"}(e,e.scrollTop+e.clientHeight<e.scrollHeight-5)})}(e),e.dataset.isListeningForUserScroll="true"),"true"!==e.dataset.userInteracted&&M(e))}f.instances=new Map;class _{constructor(e,t={}){this.element=void 0,this.options=void 0,this.isDragging=!1,this.startX=0,this.startY=0,this.initialX=0,this.initialY=0,this.threshold=5,this.onMouseMoveHandler=void 0,this.onMouseUpHandler=void 0,this.element=e,this.options=y({coordinate:"tl"},t);let n=getComputedStyle(this.element).position;n&&"static"!==n||(this.element.style.position="absolute"),this.options.position&&(this.element.style.position=this.options.position),this.onMouseMoveHandler=this.onMouseMove.bind(this),this.onMouseUpHandler=this.onMouseUp.bind(this),this.element.addEventListener("mousedown",this.onMouseDown.bind(this))}onMouseDown(e){e.preventDefault(),this.startX=e.clientX,this.startY=e.clientY,this.initialX=parseInt(window.getComputedStyle(this.element).left,10)||0,this.initialY=parseInt(window.getComputedStyle(this.element).top,10)||0,document.addEventListener("mousemove",this.onMouseMoveHandler),document.addEventListener("mouseup",this.onMouseUpHandler)}getBoundedPosition(e,t){const n=this.element.getBoundingClientRect();let i,o;if("fixed"===getComputedStyle(this.element).position)i=window.innerWidth-n.width,o=window.innerHeight-n.height;else{const e=(this.element.offsetParent||document.documentElement).getBoundingClientRect();i=e.width-n.width,o=e.height-n.height}return{x:Math.min(Math.max(0,e),i),y:Math.min(Math.max(0,t),o)}}onMouseMove(e){if(!this.isDragging){const t=e.clientY-this.startY;(Math.abs(e.clientX-this.startX)>this.threshold||Math.abs(t)>this.threshold)&&(this.isDragging=!0,this.options.onDragStart&&this.options.onDragStart(e))}if(this.isDragging){const t=this.getBoundedPosition(this.initialX+(e.clientX-this.startX),this.initialY+(e.clientY-this.startY));this.element.style.right="auto",this.element.style.bottom="auto",this.element.style.left=t.x+"px",this.element.style.top=t.y+"px",this.options.onDrag&&this.options.onDrag(e)}}convertCoordinate(){const e=this.element.getBoundingClientRect(),t=getComputedStyle(this.element).position;let n,i,o=null,r=null;if("fixed"===t?(o=null,r=new DOMRect(0,0,window.innerWidth,window.innerHeight)):(o=this.element.offsetParent,o||(o=document.documentElement),"static"===getComputedStyle(o).position?(o=null,r=new DOMRect(0,0,window.innerWidth,window.innerHeight)):r=o.getBoundingClientRect()),r){if("fixed"===t)n=e.left,i=e.top;else if(n=e.left-r.left,i=e.top-r.top,o instanceof HTMLElement){const e=getComputedStyle(o);n-=parseFloat(e.borderLeftWidth)||0,i-=parseFloat(e.borderTopWidth)||0}else n+=window.scrollX,i+=window.scrollY;switch(this.options.coordinate){case"tr":const t=r.width-n-e.width;this.element.style.left="auto",this.element.style.right=`${t}px`,this.element.style.top=`${i}px`,this.element.style.bottom="auto";break;case"bl":const o=r.height-i-e.height;this.element.style.left=`${n}px`,this.element.style.right="auto",this.element.style.top="auto",this.element.style.bottom=`${o}px`;break;case"br":const s=r.width-n-e.width,a=r.height-i-e.height;this.element.style.left="auto",this.element.style.right=`${s}px`,this.element.style.top="auto",this.element.style.bottom=`${a}px`;break;default:this.element.style.left=`${n}px`,this.element.style.right="auto",this.element.style.top=`${i}px`,this.element.style.bottom="auto"}}}onMouseUp(e){this.isDragging&&(this.options.coordinate&&"tl"!==this.options.coordinate&&this.convertCoordinate(),this.options.onDragEnd&&this.options.onDragEnd(e)),this.isDragging=!1,document.removeEventListener("mousemove",this.onMouseMoveHandler),document.removeEventListener("mouseup",this.onMouseUpHandler)}}class I{constructor(e,t="local"){this.storageKey=void 0,this.storeType=void 0,this.store=void 0,this.storageKey=e,this.storeType=t}static getInstanceKey(e,t="local"){return`${t}:${e}`}static getInstance(e,t="local"){const n=this.getInstanceKey(e,t);return this.instances.has(n)||this.instances.set(n,new I(e,t)),this.instances.get(n)}static local(e){return this.getInstance(e,"local")}static session(e){return this.getInstance(e,"session")}static clearInstance(e,t="local"){const n=this.getInstanceKey(e,t);this.instances.delete(n)}static clearAllInstances(){this.instances.clear()}getStore(){return this.store||(this.store="local"===this.storeType?localStorage:sessionStorage),this.store}set(e,t){try{const n=y({},this.getAll(),{[e]:t});this.getStore().setItem(this.storageKey,JSON.stringify(n))}catch(e){throw console.error("WebStore.set 失败:",e),e}}get(e){try{const t=this.getAll();return null==t?void 0:t[e]}catch(e){throw console.error("WebStore.get 失败:",e),e}}getAll(){try{const e=this.getStore().getItem(this.storageKey);return e?JSON.parse(e):{}}catch(e){return console.error("WebStore.getAll 失败:",e),{}}}remove(e){try{const t=this.getAll();t&&e in t&&(delete t[e],this.getStore().setItem(this.storageKey,JSON.stringify(t)))}catch(e){throw console.error("WebStore.remove 失败:",e),e}}clear(){try{this.getStore().removeItem(this.storageKey)}catch(e){throw console.error("WebStore.clear 失败:",e),e}}setMultiple(e){try{const t=y({},this.getAll(),e);this.getStore().setItem(this.storageKey,JSON.stringify(t))}catch(e){throw console.error("WebStore.setMultiple 失败:",e),e}}onChanged(e){window.addEventListener("storage",t=>{if(t.key===this.storageKey&&t.storageArea===this.getStore()){const n={[this.storageKey]:{oldValue:t.oldValue?JSON.parse(t.oldValue):void 0,newValue:t.newValue?JSON.parse(t.newValue):void 0}};e(n)}})}has(e){try{return void 0!==this.get(e)}catch(e){return console.error("WebStore.has 失败:",e),!1}}getSize(){try{const e=this.getStore().getItem(this.storageKey)||"";return new Blob([e]).size}catch(e){return console.error("WebStore.getSize 失败:",e),0}}getStoreKey(){return this.storageKey}}I.instances=new Map;class L{constructor(e,t="local"){this.storageKey=void 0,this.storeType=void 0,this.store=void 0,this.storageKey=e,this.storeType=t}static getInstanceKey(e,t="local"){return`${t}:${e}`}static getInstance(e,t="local"){const n=this.getInstanceKey(e,t);return this.instances.has(n)||this.instances.set(n,new L(e,t)),this.instances.get(n)}static local(e){return this.getInstance(e,"local")}static sync(e){return this.getInstance(e,"sync")}static clearInstance(e,t="local"){const n=this.getInstanceKey(e,t);this.instances.delete(n)}static clearAllInstances(){this.instances.clear()}getStore(){return this.store||(this.store=chrome.storage[this.storeType]),this.store}async set(e,t){try{const n=y({},await this.getAll(),{[e]:t});await this.getStore().set({[this.storageKey]:n})}catch(e){throw console.error("ChromeStore.set 失败:",e),e}}async get(e){try{const t=await this.getAll();return null==t?void 0:t[e]}catch(e){throw console.error("ChromeStore.get 失败:",e),e}}async getAll(){try{return(await this.getStore().get(this.storageKey))[this.storageKey]||{}}catch(e){throw console.error("ChromeStore.getAll 失败:",e),e}}async remove(e){try{const t=await this.getAll();t&&e in t&&(delete t[e],await this.getStore().set({[this.storageKey]:t}))}catch(e){throw console.error("ChromeStore.remove 失败:",e),e}}async clear(){try{await this.getStore().remove(this.storageKey)}catch(e){throw console.error("ChromeStore.clear 失败:",e),e}}async setMultiple(e){try{const t=y({},await this.getAll(),e);await this.getStore().set({[this.storageKey]:t})}catch(e){throw console.error("ChromeStore.setMultiple 失败:",e),e}}onChanged(e){chrome.storage.onChanged.addListener((t,n)=>{n===this.storeType&&t[this.storageKey]&&e(t)})}async has(e){try{return void 0!==await this.get(e)}catch(e){return console.error("ChromeStore.has 失败:",e),!1}}async getSize(){try{const e=await this.getAll(),t=JSON.stringify(e);return new Blob([t]).size}catch(e){return console.error("ChromeStore.getSize 失败:",e),0}}getStoreKey(){return this.storageKey}}async function E({clientId:e,responseType:t="code",state:n,nonce:i,interactive:o=!0}){const r=chrome.identity.getRedirectURL(),s=Array.isArray(t)?t:[t],a=new URL("https://accounts.google.com/o/oauth2/v2/auth");return a.searchParams.set("client_id",e),a.searchParams.set("redirect_uri",r),a.searchParams.set("response_type",s.join(" ")),a.searchParams.set("scope","openid email profile"),i&&a.searchParams.set("nonce",i),n&&a.searchParams.set("state",n),chrome.identity.launchWebAuthFlow({url:a.toString(),interactive:o}).then(e=>{if(!e)return Promise.reject(new Error("redirectUrl is null"));const t=e.includes("?")?"?":"#",n=new URLSearchParams(e.split(t)[1]),i={};return n.forEach((e,t)=>{i[t]=e}),i}).catch(e=>(console.log("error",e),Promise.reject(e)))}function P(e){let t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(atob(t).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(n)}function T(e,t,n=!1){return chrome.cookies.get({url:e,name:t}).then(e=>{var t;return n?(null==e||null==(t=e.value)?void 0:t.replace(/"/g,""))||"":null!=e?e:void 0})}function A(e,t=!1){return chrome.cookies.getAll({url:e}).then(e=>t?function(e){return e.map(e=>`${e.name}=${e.value}`).join("; ")}(e):e)}function O(){var e,t,n;return{locale:null==(e=chrome.i18n)?void 0:e.getUILanguage(),extId:null==(t=chrome.runtime)?void 0:t.id,version:null==(n=chrome.runtime)?void 0:n.getManifest().version}}function K(e){return"object"==typeof e&&null!==e&&"__error"in e&&!0===e.__error}function $(e={}){const{debug:t=!1,logPrefix:n="[MessageBus]"}=e,i=new Map;let o=!1;function r(e,...i){t&&console.error(`${n} ${e}`,...i)}function s(){o||(chrome.runtime.onMessage.addListener((e,t,n)=>{if(!e||"string"!=typeof e.type)return;const o=i.get(e.type);if(o)try{const i=o(e.payload,t);return i instanceof Promise?(i.then(n).catch(t=>{r(`Error handling "${String(e.type)}":`,t),n({__error:!0,message:t instanceof Error?t.message:String(t)})}),!0):(n(i),!1)}catch(t){return r(`Error handling "${String(e.type)}":`,t),n({__error:!0,message:t instanceof Error?t.message:String(t)}),!1}}),o=!0)}return{send:(e,t)=>chrome.runtime.sendMessage({type:e,payload:t}),sendToTab:(e,t,n)=>chrome.tabs.sendMessage(e,{type:t,payload:n}),on:(e,t)=>(s(),i.set(e,t),()=>{i.delete(e)}),onMany(e){s();const t=[];for(const[n,o]of Object.entries(e))o&&(i.set(n,o),t.push(n));return()=>{for(const e of t)i.delete(e)}},hasHandler:e=>i.has(e),getRegisteredTypes:()=>Array.from(i.keys()),clearAllHandlers(){i.clear()}}}L.instances=new Map;const N="https://www.linkedin.com/voyager/api";async function j({csrfToken:e,cookies:t}){const n=`${N}/me`,i=U(e,t);return fetch(n,{method:"GET",headers:i}).then(async e=>e.ok?e.json():null).catch(e=>(console.error(e),null))}function U(e,t){const n={"csrf-token":e};if(t){let e="";e="string"==typeof t?t:Object.entries(t).map(([e,t])=>`${e}=${t}`).join("; "),e&&(n.Cookie=e)}return n}async function R(e,{csrfToken:t,cookies:n}){const i=`${N}/identity/dash/profiles?q=memberIdentity&memberIdentity=${e}&decorationId=com.linkedin.voyager.dash.deco.identity.profile.FullProfileWithEntities-26`,o=U(t,n);return fetch(i,{method:"GET",headers:o}).then(async e=>{var t;return e.ok&&(null==(t=(await e.json()).elements)?void 0:t[0])||null}).catch(e=>(console.error(e),null))}async function D(e,{csrfToken:t,cookies:n}){let i="";const o="string"==typeof e?{universalName:e}:e,r="universalName"in o;i=r?`?q=universalName&universalName=${o.universalName}`:`/${o.urn}`;const s=`${N}/organization/companies${i}`,a=U(t,n);return fetch(s,{method:"GET",headers:a}).then(async e=>{if(e.ok){const n=await e.json();var t;return r?(null==(t=n.elements)?void 0:t[0])||null:n}return null}).catch(e=>(console.error(e),null))}const z={profilePage:{userPicture:[".pv-top-card__non-self-photo-wrapper img","#recent-activity-top-card img",".pv-top-card__photo-wrapper img",'div[componentkey^="com.linkedin.sdui.profile.card"] div[data-view-name="profile-top-card-member-photo"] img'],userName:['a[href^="/in"] h1',"#recent-activity-top-card h3",'div[data-view-name="profile-top-card-verified-badge"] div[role="button"]'],userOccupation:[".artdeco-entity-lockup .artdeco-entity-lockup__subtitle","#recent-activity-top-card h4"],linkedinProfileCard:[".scaffold-layout__main .artdeco-card:first-child",'div[componentkey^="com.linkedin.sdui.profile.card"]'],privateProfileInfoSection:[".pv-profile-info-section"],howToContainer:["#profile-content, header#global-nav"],companyName:[".top-card-background-hero-image+div .mt2 ul>li span",'div[componentkey^="com.linkedin.sdui.profile.card"] div:has(div[data-view-name="profile-top-card-verified-badge"]) + div div[role="button"] p'],companyLogo:[".top-card-background-hero-image+div .mt2 ul>li img"],campaignsListContainer:[".ui-row.sm.campaigns-list-container"],contactListContainer:[".ui-row.sm.contact-list-container"],location:["#profile-content .artdeco-card .top-card-background-hero-image+div .text-body-small.inline.t-black--light"],campaignsListContainerDisplay:[".ui-col.sm.campaigns-list-container-display"],contactListContainerDisplay:[".ui-col.sm.contact-list-container-display"],mainExperienceContainer:[".artdeco-card:has(#experience) li:first-child",'div[componentkey^="com.linkedin.sdui.profile.card"][componentkey$="ExperienceTopLevelSection"] div:has(h2) + div > div'],experienceCompanyLogo:['[data-field="experience_company_logo"] img','div[componentkey^="com.linkedin.sdui.profile.card"][componentkey$="ExperienceTopLevelSection"] div:has(h2) + div figure[data-view-name="image"] img'],experienceCompanyName:['div:has([data-field="experience_company_logo"])+div .t-normal span:not(.visually-hidden)'],experienceOccupation:['div:has([data-field="experience_company_logo"])+div .t-bold span:not(.visually-hidden)'],experienceMultipleCompany:["li:has([data-view-name=profile-component-entity] .pvs-entity__sub-components .pvs-entity__sub-components) .t-bold span:not(.visually-hidden)"],experienceMultipleOccupation:['[data-view-name="profile-component-entity"] li:first-child .t-bold span:not(.visually-hidden)']},salesNavProfilePage:{profileCardSection:["#profile-card-section"],userName:['#profile-card-section [data-anonymize="person-name"]'],userPicture:['#profile-card-section img[data-anonymize="headshot-photo"]'],userOccupation:['#profile-card-section [data-anonymize="headline"]'],profileUrl:['#profile-card-section a[href^="/sales/lead"]'],linkedinProfileCard:["#profile-card-section"],campaignsListContainer:[".ui-row.sm.campaigns-list-container"],contactListContainer:[".ui-row.sm.contact-list-container"],campaignsListContainerDisplay:[".ui-col.sm.campaigns-list-container-display"],contactListContainerDisplay:[".ui-col.sm.contact-list-container-display"],location:["#profile-card-section>section>div>div:last-child div:has(svg)"],companyName:['#profile-card-section a[data-anonymize="company-name"]'],companyLogo:['#profile-card-section img[data-anonymize="company-logo"]'],moreInfoButton:["#profile-card-section section[data-x--lead-actions-bar] button[data-x--lead-actions-bar-overflow-menu]",'#profile-card-section button[aria-label="Open actions overflow menu"]'],linkedinProfileLinkButton:['#hue-web-menu-outlet a[href^="https://www.linkedin.com/in/"]'],mainExperienceContainer:['[data-sn-view-name="feature-lead-experience"]'],experienceCompanyLogo:['li:first-child img[data-anonymize="company-logo"]'],experienceCompanyName:['li:first-child [data-anonymize="company-name"]'],experienceOccupation:['li:first-child [data-anonymize="job-title"]'],experienceMultipleOccupation:['ul li ul li:first-child [data-anonymize="job-title"]','ul li [data-anonymize="job-title"]'],experienceMultipleCompany:['li:first-child [data-anonymize="company-name"]']},searchPeoplePage:{searchEntityResult:['[data-view-name="search-entity-result-universal-template"]'],linkedinUrl:['a[data-test-app-aware-link][href^="https://www.linkedin.com/in/"]','a[data-view-name="search-result-lockup-title"]'],image:[".presence-entity img","a>div>div>figure>img"],userOccupation:['p:has(a[data-view-name="search-result-lockup-title"]) + p',".entity-result__primary-subtitle",".entity-result__divider > div div:nth-child(2)","div>div>div:nth-child(2)>div>div:nth-child(2)","figure + div p:nth-child(2)"],fullName:[".entity-result__title-text a span>span",".entity-result__title-line a span>span",".entity-result__title-line span>a>span>span","a:has(+.entity-result__badge)>span>span",".linked-area div:nth-child(2) > div:first-child > div.t-roman.t-sans a",'a[data-view-name="search-result-lockup-title"]'],resultList:[".search-results-container>div:has(.reusable-search__result-container)"],actionsDiv:[".entity-result__actions",".linked-area > div > div:last-child","div:has(figure) > div:last-child"],validResult:["[data-chameleon-result-urn] , .reusable-search__result-container"],searchResult:[".search-results-container li:has(>[data-chameleon-result-urn])",'[data-view-name="people-search-result"]'],searchResultsContainer:[".search-results-container",'[role="main"] div:has(>hr[role="presentation"])'],mainLayoutLeft:[".search-marvel-srp",'[role="main"] div:has(hr)>div>div'],howToContainer:[".hasLegacyFeedLineHeight div:has(main)",".authentication-outlet"]},searchAllPage:{peopleButton:["nav ul.search-reusables__filter-list>li>button"],toolbar:[".scaffold-layout-toolbar"]}};function H(e,t,n){switch(n){case"all":const n=e.querySelectorAll(t);return n.length>0?Array.from(n):null;case"closest":return e instanceof HTMLElement?e.closest(t):null;default:return e.querySelector(t)}}function W({page:e,key:t,selector:n,container:i,mode:o}){null!=i||(i=document);const r=e&&t?function({page:e,key:t}){return z[e][t]}({page:e,key:t}):[n];for(const e of r){const t=H(i,e,o);if(t)return t}return null}function B(e){if(!e)return"";const t=document.createElement("textarea");return t.innerHTML=e,t.value.trim()}function V(){var e,t,n,i,o,r,s;const a=window.location.href.includes("linkedin.com/sales")?"salesNavProfilePage":"profilePage";function c(e){return W({page:a,key:e,container:document})}const l=null==(e=c("userName"))?void 0:e.innerText;if(!l)return console.error("extractUserInfos: no userName found"),{};const h=null==(t=c("userPicture"))?void 0:t.src,d=null==(n=c("userOccupation"))?void 0:n.innerHTML,u=null==(i=c("companyName"))?void 0:i.innerText,p=null==(o=c("companyLogo"))?void 0:o.src,m=null==(r=c("location"))?void 0:r.innerText;let g;return"salesNavProfilePage"===a&&(g=/linkedin\.com\/sales\/lead/i.test(window.location.href)?window.location.href:null==(s=c("profileUrl"))?void 0:s.href),{name:B(l),profileUrl:g,picture:h,occupation:B(d),companyName:u,companyPicture:p,location:m}}function X(e){return/^https?:\/\/(www|.{2})\.linkedin\.com/.test(e)}const Y={"":0,chrome:1,"chrome-extension":2,"view-source":3,ftp:4,file:5,data:6,blob:7,about:8};function J(e=""){let t="";const n=e.split("#")[0].toLocaleLowerCase();return/^https\:\/\/(www|.{2})\.linkedin\.com\/in\/[^/?]+(\/recent-activity\/|\/details\/|\/overlay\/|\/?\?[^/]*|\/?$)/.test(n)||/^https\:\/\/(www|.{2})\.linkedin\.com\/sales\/people\/(.+?),/.test(n)||/^https\:\/\/(www|.{2})\.linkedin\.com\/sales\/(profile|lead)\/([^,]{39}),/.test(n)?t="profile":n.includes("linkedin.com/feed")?t="feed":n.includes("linkedin.com/posts/")?t="post":n.includes("linkedin.com/login")||n.includes("linkedin.com/checkpoint")||n.includes("linkedin.com/authwall")?t="login":n.includes("linkedin.com/company/")?t="company":n.includes("linkedin.com/messaging/thread/")?t="messages":n.includes("linkedin.com/search/results/people/?")||n.includes("linkedin.com/sales/search/people")?t="search-people":n.includes("linkedin.com/search/results/all")?t="search-all":n.includes("linkedin.com/mynetwork/")&&(t="connections"),t}function F(e=""){var t;const n=((e=e||(null==(t=window.top)?void 0:t.location.href)||document.URL).match(/linkedin\.com\/in\/([^?/]+)/)||[])[1]||(e.match(/linkedin\.com\/sales\/people\/(.+?),/)||[])[1]||(e.match(/linkedin\.com\/sales\/(?:profile|lead)\/([^,]{39}),/)||[])[1]||"";return decodeURIComponent(n)}function G(e=""){var t;const n=((e=e||(null==(t=window.top)?void 0:t.location.href)||document.URL).match(/linkedin\.com\/posts\/([^\/]+)\//)||[])[1]||"";return decodeURIComponent(n)}function q(e=""){var t;const n=((e=e||(null==(t=window.top)?void 0:t.location.href)||document.URL).match(/linkedin\.com\/company\/([^?/]+)/)||[])[1]||"";return decodeURIComponent(n)}function Q(e=""){var t;return F(e=e||(null==(t=window.top)?void 0:t.location.href)||document.URL)||q(e)||""}function Z(e=""){if(!e)return"";const t=Object.keys(Y),n=new URL(e).protocol.replace(":","");return t.includes(n)?n:J(e)}export{L as ChromeStore,_ as Draggable,f as MemoryStore,e as RealUndefined,I as WebStore,m as cacheWrapper,r as cloneDeep,c as createDefaultObject,w as createElement,$ as createMessageBus,k as createSvg,C as createSvgFromUrl,s as debounce,P as decodeJWT,a as delayExecution,o as generateStableUniqueKey,q as getCompanyPublicId,V as getContactInfo,T as getCookie,A as getCookies,W as getElement,O as getExtensionInfo,i as getGlobal,D as getLinkedinCompany,j as getLinkedinMe,J as getLinkedinPageType,R as getLinkedinProfile,Q as getLinkedinPublicId,Z as getPageType,G as getPostPublicId,F as getProfilePublicId,t as isCloneable,K as isErrorResponse,X as isLinkedInUrl,n as isPrimitive,E as launchWebAuthFlow,Y as pageTypeMap,M as scrollToBottom,x as scrollToBottomIfNeeded,g as singleExecutionWrapper};
1
+ const e=Symbol("undefined");function t(e){return"function"==typeof(null==e?void 0:e.clone)}function n(e){const t=typeof e;return null===e||"string"===t||"number"===t||"boolean"===t||"undefined"===t}function o(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this}function i(e){return n(e)?String(e):JSON.stringify(e,function(e,t){return"object"!=typeof t||null===t||Array.isArray(t)?t:Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{})})}function r(e){if(null===e||"object"!=typeof e)return e;if(t(e))return e.clone();if(Array.isArray(e))return e.map(e=>r(e));const n={};for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[t]=r(e[t]));return n}function a(e,t){let n=null;return function(...o){const i=this;null!==n&&clearTimeout(n),n=setTimeout(()=>{e.apply(i,o),n=null},t)}}function s(e,t=0,...n){return new Promise(o=>{0===t?o(e(...n)):setTimeout(()=>{o(e(...n))},t)})}function l(e){return new Proxy({},{get:(t,n)=>t.hasOwnProperty(n)?t[n]:e})}const c=l(e),u=l(!1);function d(e){return c[e]}function h(t){return c[t]!==e}const m={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"},identifier:""};function p(e,t=m){const n=function(...n){const o=i(n)+e.name+(t.identifier||"");if(h(o))return Promise.resolve(r(d(o)));if(u[o]){const e=Object.assign({},m,t);return new Promise(t=>{const n=Date.now(),i=setInterval(()=>{h(o)?(clearInterval(i),t(r(d(o)))):Date.now()-n>e.timeout&&(u[o]=!1,clearInterval(i),t(r(e.timeoutResult)))},100)})}return u[o]=!0,e.apply(this,n).then(e=>(c[o]=e,r(c[o]))).catch(e=>{throw e}).finally(()=>{u[o]=!1})};return Object.defineProperty(n,"name",{value:`cacheWrapper_${e.name}`,configurable:!0}),n}function g(t,n=0){const o=function o(...i){if(o.isExecuting)return Promise.resolve(e);o.isExecuting=!0;const r=performance.now(),a=t.apply(this,i);return a.finally(()=>{const e=performance.now()-r;n&&n>e?setTimeout(()=>{o.isExecuting=!1},n-e):o.isExecuting=!1}),a};return o.isExecuting=!1,o}function y(){return y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},y.apply(null,arguments)}class f{constructor(e){this.storageKey=void 0,this.data={},this.changeCallbacks=[],this.storageKey=e}static getInstanceKey(e){return`memory:${e}`}static getInstance(e){const t=this.getInstanceKey(e);return this.instances.has(t)||this.instances.set(t,new f(e)),this.instances.get(t)}static create(e){return this.getInstance(e)}static clearInstance(e){const t=this.getInstanceKey(e),n=this.instances.get(t);n&&n.clearChangeCallbacks(),this.instances.delete(t)}static clearAllInstances(){this.instances.forEach(e=>{e.clearChangeCallbacks()}),this.instances.clear()}set(e,t){try{const n=this.data[e];this.data=y({},this.data,{[e]:t}),this.triggerChange(n,t)}catch(e){throw console.error("MemoryStore.set 失败:",e),e}}get(e){try{return this.data[e]}catch(e){throw console.error("MemoryStore.get 失败:",e),e}}getAll(){return y({},this.data)}remove(e){try{if(e in this.data){const t=this.data[e],n=y({},this.data);delete n[e],this.data=n,this.triggerChange(t,void 0)}}catch(e){throw console.error("MemoryStore.remove 失败:",e),e}}clear(){try{const e=y({},this.data);this.data={},this.triggerChange(e,{})}catch(e){throw console.error("MemoryStore.clear 失败:",e),e}}setMultiple(e){try{const t=y({},this.data);this.data=y({},this.data,e),this.triggerChange(t,this.data)}catch(e){throw console.error("MemoryStore.setMultiple 失败:",e),e}}onChanged(e){this.changeCallbacks.push(e)}triggerChange(e,t){if(this.changeCallbacks.length>0){const n={[this.storageKey]:{oldValue:e,newValue:t}};this.changeCallbacks.forEach(e=>{try{e(n)}catch(e){console.error("MemoryStore 变化回调执行失败:",e)}})}}clearChangeCallbacks(){this.changeCallbacks=[]}has(e){try{return e in this.data}catch(e){return console.error("MemoryStore.has 失败:",e),!1}}getSize(){try{const e=JSON.stringify(this.data);return new Blob([e]).size}catch(e){return console.error("MemoryStore.getSize 失败:",e),0}}getStoreKey(){return this.storageKey}getStoreType(){return"memory"}}function v(e,t,n,o=!1){if(t in e.style)e.style[t]=n;else{const i=o?"important":"";e.style.setProperty(t,String(n),i)}}function w({tag:e="div",children:t=[],props:n={},attrs:o={},styles:i={}}={}){const r=document.createElement(e);Object.assign(r,n);for(const[e,t]of Object.entries(o))!1!==t&&r.setAttribute(e,t);for(const[e,t]of Object.entries(i))v(r,e,t);const a=Array.isArray(t)?t:[t];for(const e of a)e&&("object"==typeof e?e instanceof Element?r.appendChild(e):r.appendChild(w(e)):r.appendChild(document.createTextNode(e)));return r}function b(e){const t=document.createElementNS("http://www.w3.org/2000/svg",e.type);if(e.props)for(const[n,o]of Object.entries(e.props))t.setAttribute(n,o);if("string"==typeof e.children){const n=document.createTextNode(e.children);t.appendChild(n)}else Array.isArray(e.children)&&e.children.forEach(e=>{const n=b(e);t.appendChild(n)});return t}function k(e){const t=(new DOMParser).parseFromString(e,"image/svg+xml").documentElement;if(!(t instanceof SVGElement))throw new Error("解析失败,结果不是有效的 SVG 元素");return t}function S(e){return"string"==typeof e?k(e):b(e)}async function C(e){try{const t=await fetch(e);if(!t.ok)throw new Error(`网络请求失败: ${t.status} ${t.statusText}`);return k(await t.text())}catch(e){const t=e instanceof Error?e.message:"未知错误";throw new Error(`无法创建 SVG 元素: ${t}`)}}function L(e){e&&setTimeout(()=>{e.scrollTop=e.scrollHeight},0)}function I(e){e&&("true"!==e.dataset.isListeningForUserScroll&&(function(e){e&&e.addEventListener("scroll",()=>{!function(e,t){e.dataset.userInteracted=t?"true":"false"}(e,e.scrollTop+e.clientHeight<e.scrollHeight-5)})}(e),e.dataset.isListeningForUserScroll="true"),"true"!==e.dataset.userInteracted&&L(e))}f.instances=new Map;class N{constructor(e,t={}){this.element=void 0,this.options=void 0,this.isDragging=!1,this.startX=0,this.startY=0,this.initialX=0,this.initialY=0,this.threshold=5,this.onMouseMoveHandler=void 0,this.onMouseUpHandler=void 0,this.element=e,this.options=y({coordinate:"tl"},t);let n=getComputedStyle(this.element).position;n&&"static"!==n||(this.element.style.position="absolute"),this.options.position&&(this.element.style.position=this.options.position),this.onMouseMoveHandler=this.onMouseMove.bind(this),this.onMouseUpHandler=this.onMouseUp.bind(this),this.element.addEventListener("mousedown",this.onMouseDown.bind(this))}onMouseDown(e){e.preventDefault(),this.startX=e.clientX,this.startY=e.clientY,this.initialX=parseInt(window.getComputedStyle(this.element).left,10)||0,this.initialY=parseInt(window.getComputedStyle(this.element).top,10)||0,document.addEventListener("mousemove",this.onMouseMoveHandler),document.addEventListener("mouseup",this.onMouseUpHandler)}getBoundedPosition(e,t){const n=this.element.getBoundingClientRect();let o,i;if("fixed"===getComputedStyle(this.element).position)o=window.innerWidth-n.width,i=window.innerHeight-n.height;else{const e=(this.element.offsetParent||document.documentElement).getBoundingClientRect();o=e.width-n.width,i=e.height-n.height}return{x:Math.min(Math.max(0,e),o),y:Math.min(Math.max(0,t),i)}}onMouseMove(e){if(!this.isDragging){const t=e.clientY-this.startY;(Math.abs(e.clientX-this.startX)>this.threshold||Math.abs(t)>this.threshold)&&(this.isDragging=!0,this.options.onDragStart&&this.options.onDragStart(e))}if(this.isDragging){const t=this.getBoundedPosition(this.initialX+(e.clientX-this.startX),this.initialY+(e.clientY-this.startY));this.element.style.right="auto",this.element.style.bottom="auto",this.element.style.left=t.x+"px",this.element.style.top=t.y+"px",this.options.onDrag&&this.options.onDrag(e)}}convertCoordinate(){const e=this.element.getBoundingClientRect(),t=getComputedStyle(this.element).position;let n,o,i=null,r=null;if("fixed"===t?(i=null,r=new DOMRect(0,0,window.innerWidth,window.innerHeight)):(i=this.element.offsetParent,i||(i=document.documentElement),"static"===getComputedStyle(i).position?(i=null,r=new DOMRect(0,0,window.innerWidth,window.innerHeight)):r=i.getBoundingClientRect()),r){if("fixed"===t)n=e.left,o=e.top;else if(n=e.left-r.left,o=e.top-r.top,i instanceof HTMLElement){const e=getComputedStyle(i);n-=parseFloat(e.borderLeftWidth)||0,o-=parseFloat(e.borderTopWidth)||0}else n+=window.scrollX,o+=window.scrollY;switch(this.options.coordinate){case"tr":const t=r.width-n-e.width;this.element.style.left="auto",this.element.style.right=`${t}px`,this.element.style.top=`${o}px`,this.element.style.bottom="auto";break;case"bl":const i=r.height-o-e.height;this.element.style.left=`${n}px`,this.element.style.right="auto",this.element.style.top="auto",this.element.style.bottom=`${i}px`;break;case"br":const a=r.width-n-e.width,s=r.height-o-e.height;this.element.style.left="auto",this.element.style.right=`${a}px`,this.element.style.top="auto",this.element.style.bottom=`${s}px`;break;default:this.element.style.left=`${n}px`,this.element.style.right="auto",this.element.style.top=`${o}px`,this.element.style.bottom="auto"}}}onMouseUp(e){this.isDragging&&(this.options.coordinate&&"tl"!==this.options.coordinate&&this.convertCoordinate(),this.options.onDragEnd&&this.options.onDragEnd(e)),this.isDragging=!1,document.removeEventListener("mousemove",this.onMouseMoveHandler),document.removeEventListener("mouseup",this.onMouseUpHandler)}}class P{constructor(e,t="local"){this.storageKey=void 0,this.storeType=void 0,this.store=void 0,this.storageKey=e,this.storeType=t}static getInstanceKey(e,t="local"){return`${t}:${e}`}static getInstance(e,t="local"){const n=this.getInstanceKey(e,t);return this.instances.has(n)||this.instances.set(n,new P(e,t)),this.instances.get(n)}static local(e){return this.getInstance(e,"local")}static session(e){return this.getInstance(e,"session")}static clearInstance(e,t="local"){const n=this.getInstanceKey(e,t);this.instances.delete(n)}static clearAllInstances(){this.instances.clear()}getStore(){return this.store||(this.store="local"===this.storeType?localStorage:sessionStorage),this.store}set(e,t){try{const n=y({},this.getAll(),{[e]:t});this.getStore().setItem(this.storageKey,JSON.stringify(n))}catch(e){throw console.error("WebStore.set 失败:",e),e}}get(e){try{const t=this.getAll();return null==t?void 0:t[e]}catch(e){throw console.error("WebStore.get 失败:",e),e}}getAll(){try{const e=this.getStore().getItem(this.storageKey);return e?JSON.parse(e):{}}catch(e){return console.error("WebStore.getAll 失败:",e),{}}}remove(e){try{const t=this.getAll();t&&e in t&&(delete t[e],this.getStore().setItem(this.storageKey,JSON.stringify(t)))}catch(e){throw console.error("WebStore.remove 失败:",e),e}}clear(){try{this.getStore().removeItem(this.storageKey)}catch(e){throw console.error("WebStore.clear 失败:",e),e}}setMultiple(e){try{const t=y({},this.getAll(),e);this.getStore().setItem(this.storageKey,JSON.stringify(t))}catch(e){throw console.error("WebStore.setMultiple 失败:",e),e}}onChanged(e){window.addEventListener("storage",t=>{if(t.key===this.storageKey&&t.storageArea===this.getStore()){const n={[this.storageKey]:{oldValue:t.oldValue?JSON.parse(t.oldValue):void 0,newValue:t.newValue?JSON.parse(t.newValue):void 0}};e(n)}})}has(e){try{return void 0!==this.get(e)}catch(e){return console.error("WebStore.has 失败:",e),!1}}getSize(){try{const e=this.getStore().getItem(this.storageKey)||"";return new Blob([e]).size}catch(e){return console.error("WebStore.getSize 失败:",e),0}}getStoreKey(){return this.storageKey}}P.instances=new Map;class M{constructor(e,t="local"){this.storageKey=void 0,this.storeType=void 0,this.store=void 0,this.storageKey=e,this.storeType=t}static getInstanceKey(e,t="local"){return`${t}:${e}`}static getInstance(e,t="local"){const n=this.getInstanceKey(e,t);return this.instances.has(n)||this.instances.set(n,new M(e,t)),this.instances.get(n)}static local(e){return this.getInstance(e,"local")}static sync(e){return this.getInstance(e,"sync")}static clearInstance(e,t="local"){const n=this.getInstanceKey(e,t);this.instances.delete(n)}static clearAllInstances(){this.instances.clear()}getStore(){return this.store||(this.store=chrome.storage[this.storeType]),this.store}async set(e,t){try{const n=y({},await this.getAll(),{[e]:t});await this.getStore().set({[this.storageKey]:n})}catch(e){throw console.error("ChromeStore.set 失败:",e),e}}async get(e){try{const t=await this.getAll();return null==t?void 0:t[e]}catch(e){throw console.error("ChromeStore.get 失败:",e),e}}async getAll(){try{return(await this.getStore().get(this.storageKey))[this.storageKey]||{}}catch(e){throw console.error("ChromeStore.getAll 失败:",e),e}}async remove(e){try{const t=await this.getAll();t&&e in t&&(delete t[e],await this.getStore().set({[this.storageKey]:t}))}catch(e){throw console.error("ChromeStore.remove 失败:",e),e}}async clear(){try{await this.getStore().remove(this.storageKey)}catch(e){throw console.error("ChromeStore.clear 失败:",e),e}}async setMultiple(e){try{const t=y({},await this.getAll(),e);await this.getStore().set({[this.storageKey]:t})}catch(e){throw console.error("ChromeStore.setMultiple 失败:",e),e}}onChanged(e){chrome.storage.onChanged.addListener((t,n)=>{n===this.storeType&&t[this.storageKey]&&e(t)})}async has(e){try{return void 0!==await this.get(e)}catch(e){return console.error("ChromeStore.has 失败:",e),!1}}async getSize(){try{const e=await this.getAll(),t=JSON.stringify(e);return new Blob([t]).size}catch(e){return console.error("ChromeStore.getSize 失败:",e),0}}getStoreKey(){return this.storageKey}}async function x({clientId:e,responseType:t="code",state:n,nonce:o,interactive:i=!0}){const r=chrome.identity.getRedirectURL(),a=Array.isArray(t)?t:[t],s=new URL("https://accounts.google.com/o/oauth2/v2/auth");return s.searchParams.set("client_id",e),s.searchParams.set("redirect_uri",r),s.searchParams.set("response_type",a.join(" ")),s.searchParams.set("scope","openid email profile"),o&&s.searchParams.set("nonce",o),n&&s.searchParams.set("state",n),chrome.identity.launchWebAuthFlow({url:s.toString(),interactive:i}).then(e=>{if(!e)return Promise.reject(new Error("redirectUrl is null"));const t=e.includes("?")?"?":"#",n=new URLSearchParams(e.split(t)[1]),o={};return n.forEach((e,t)=>{o[t]=e}),o}).catch(e=>(console.log("error",e),Promise.reject(e)))}function O(e){let t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(atob(t).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(n)}function E(e,t,n=!1){return chrome.cookies.get({url:e,name:t}).then(e=>{var t;return n?(null==e||null==(t=e.value)?void 0:t.replace(/"/g,""))||"":null!=e?e:void 0})}function U(e,t=!1){return chrome.cookies.getAll({url:e}).then(e=>t?function(e){return e.map(e=>`${e.name}=${e.value}`).join("; ")}(e):e)}function _(){var e,t,n;return{locale:null==(e=chrome.i18n)?void 0:e.getUILanguage(),extId:null==(t=chrome.runtime)?void 0:t.id,version:null==(n=chrome.runtime)?void 0:n.getManifest().version}}function A(e){return"object"==typeof e&&null!==e&&"__error"in e&&!0===e.__error}function R(e={}){const{debug:t=!1,logPrefix:n="[MessageBus]"}=e,o=new Map;let i=!1;function r(e,...o){t&&console.error(`${n} ${e}`,...o)}function a(){i||(chrome.runtime.onMessage.addListener((e,t,n)=>{if(!e||"string"!=typeof e.type)return;const i=o.get(e.type);if(i)try{const o=i(e.payload,t);return o instanceof Promise?(o.then(n).catch(t=>{r(`Error handling "${String(e.type)}":`,t),n({__error:!0,message:t instanceof Error?t.message:String(t)})}),!0):(n(o),!1)}catch(t){return r(`Error handling "${String(e.type)}":`,t),n({__error:!0,message:t instanceof Error?t.message:String(t)}),!1}}),i=!0)}return{send:(e,...t)=>chrome.runtime.sendMessage({type:e,payload:t[0]}),sendToTab:(e,t,...n)=>chrome.tabs.sendMessage(e,{type:t,payload:n[0]}),on:(e,t)=>(a(),o.set(e,t),()=>{o.delete(e)}),onMany(e){a();const t=[];for(const[n,i]of Object.entries(e))i&&(o.set(n,i),t.push(n));return()=>{for(const e of t)o.delete(e)}},hasHandler:e=>o.has(e),getRegisteredTypes:()=>Array.from(o.keys()),clearAllHandlers(){o.clear()}}}M.instances=new Map;const T="https://www.linkedin.com/voyager/api";async function j({csrfToken:e,cookies:t}){const n=`${T}/me`,o=$(e,t);return fetch(n,{method:"GET",headers:o}).then(async e=>e.ok?e.json():null).catch(e=>(console.error(e),null))}function $(e,t){const n={"csrf-token":e};if(t){let e="";e="string"==typeof t?t:Object.entries(t).map(([e,t])=>`${e}=${t}`).join("; "),e&&(n.Cookie=e)}return n}async function K(e,{csrfToken:t,cookies:n}){const o=`${T}/identity/dash/profiles?q=memberIdentity&memberIdentity=${e}&decorationId=com.linkedin.voyager.dash.deco.identity.profile.FullProfileWithEntities-26`,i=$(t,n);return fetch(o,{method:"GET",headers:i}).then(async e=>{var t;return e.ok&&(null==(t=(await e.json()).elements)?void 0:t[0])||null}).catch(e=>(console.error(e),null))}async function D(e,{csrfToken:t,cookies:n}){let o="";const i="string"==typeof e?{universalName:e}:e,r="universalName"in i;o=r?`?q=universalName&universalName=${i.universalName}`:`/${i.urn}`;const a=`${T}/organization/companies${o}`,s=$(t,n);return fetch(a,{method:"GET",headers:s}).then(async e=>{if(e.ok){const n=await e.json();var t;return r?(null==(t=n.elements)?void 0:t[0])||null:n}return null}).catch(e=>(console.error(e),null))}const H={profilePage:{userPicture:[".pv-top-card__non-self-photo-wrapper img","#recent-activity-top-card img",".pv-top-card__photo-wrapper img",'div[componentkey^="com.linkedin.sdui.profile.card"] div[data-view-name="profile-top-card-member-photo"] img'],userName:['a[href^="/in"] h1',"#recent-activity-top-card h3",'div[data-view-name="profile-top-card-verified-badge"] div[role="button"]'],userOccupation:[".artdeco-entity-lockup .artdeco-entity-lockup__subtitle","#recent-activity-top-card h4"],linkedinProfileCard:[".scaffold-layout__main .artdeco-card:first-child",'div[componentkey^="com.linkedin.sdui.profile.card"]'],privateProfileInfoSection:[".pv-profile-info-section"],howToContainer:["#profile-content, header#global-nav"],companyName:[".top-card-background-hero-image+div .mt2 ul>li span",'div[componentkey^="com.linkedin.sdui.profile.card"] div:has(div[data-view-name="profile-top-card-verified-badge"]) + div div[role="button"] p'],companyLogo:[".top-card-background-hero-image+div .mt2 ul>li img"],campaignsListContainer:[".ui-row.sm.campaigns-list-container"],contactListContainer:[".ui-row.sm.contact-list-container"],location:["#profile-content .artdeco-card .top-card-background-hero-image+div .text-body-small.inline.t-black--light"],campaignsListContainerDisplay:[".ui-col.sm.campaigns-list-container-display"],contactListContainerDisplay:[".ui-col.sm.contact-list-container-display"],mainExperienceContainer:[".artdeco-card:has(#experience) li:first-child",'div[componentkey^="com.linkedin.sdui.profile.card"][componentkey$="ExperienceTopLevelSection"] div:has(h2) + div > div'],experienceCompanyLogo:['[data-field="experience_company_logo"] img','div[componentkey^="com.linkedin.sdui.profile.card"][componentkey$="ExperienceTopLevelSection"] div:has(h2) + div figure[data-view-name="image"] img'],experienceCompanyName:['div:has([data-field="experience_company_logo"])+div .t-normal span:not(.visually-hidden)'],experienceOccupation:['div:has([data-field="experience_company_logo"])+div .t-bold span:not(.visually-hidden)'],experienceMultipleCompany:["li:has([data-view-name=profile-component-entity] .pvs-entity__sub-components .pvs-entity__sub-components) .t-bold span:not(.visually-hidden)"],experienceMultipleOccupation:['[data-view-name="profile-component-entity"] li:first-child .t-bold span:not(.visually-hidden)']},salesNavProfilePage:{profileCardSection:["#profile-card-section"],userName:['#profile-card-section [data-anonymize="person-name"]'],userPicture:['#profile-card-section img[data-anonymize="headshot-photo"]'],userOccupation:['#profile-card-section [data-anonymize="headline"]'],profileUrl:['#profile-card-section a[href^="/sales/lead"]'],linkedinProfileCard:["#profile-card-section"],campaignsListContainer:[".ui-row.sm.campaigns-list-container"],contactListContainer:[".ui-row.sm.contact-list-container"],campaignsListContainerDisplay:[".ui-col.sm.campaigns-list-container-display"],contactListContainerDisplay:[".ui-col.sm.contact-list-container-display"],location:["#profile-card-section>section>div>div:last-child div:has(svg)"],companyName:['#profile-card-section a[data-anonymize="company-name"]'],companyLogo:['#profile-card-section img[data-anonymize="company-logo"]'],moreInfoButton:["#profile-card-section section[data-x--lead-actions-bar] button[data-x--lead-actions-bar-overflow-menu]",'#profile-card-section button[aria-label="Open actions overflow menu"]'],linkedinProfileLinkButton:['#hue-web-menu-outlet a[href^="https://www.linkedin.com/in/"]'],mainExperienceContainer:['[data-sn-view-name="feature-lead-experience"]'],experienceCompanyLogo:['li:first-child img[data-anonymize="company-logo"]'],experienceCompanyName:['li:first-child [data-anonymize="company-name"]'],experienceOccupation:['li:first-child [data-anonymize="job-title"]'],experienceMultipleOccupation:['ul li ul li:first-child [data-anonymize="job-title"]','ul li [data-anonymize="job-title"]'],experienceMultipleCompany:['li:first-child [data-anonymize="company-name"]']},searchPeoplePage:{searchEntityResult:['[data-view-name="search-entity-result-universal-template"]'],linkedinUrl:['a[data-test-app-aware-link][href^="https://www.linkedin.com/in/"]','a[data-view-name="search-result-lockup-title"]'],image:[".presence-entity img","a>div>div>figure>img"],userOccupation:['p:has(a[data-view-name="search-result-lockup-title"]) + p',".entity-result__primary-subtitle",".entity-result__divider > div div:nth-child(2)","div>div>div:nth-child(2)>div>div:nth-child(2)","figure + div p:nth-child(2)"],fullName:[".entity-result__title-text a span>span",".entity-result__title-line a span>span",".entity-result__title-line span>a>span>span","a:has(+.entity-result__badge)>span>span",".linked-area div:nth-child(2) > div:first-child > div.t-roman.t-sans a",'a[data-view-name="search-result-lockup-title"]'],resultList:[".search-results-container>div:has(.reusable-search__result-container)"],actionsDiv:[".entity-result__actions",".linked-area > div > div:last-child","div:has(figure) > div:last-child"],validResult:["[data-chameleon-result-urn] , .reusable-search__result-container"],searchResult:[".search-results-container li:has(>[data-chameleon-result-urn])",'[data-view-name="people-search-result"]'],searchResultsContainer:[".search-results-container",'[role="main"] div:has(>hr[role="presentation"])'],mainLayoutLeft:[".search-marvel-srp",'[role="main"] div:has(hr)>div>div'],howToContainer:[".hasLegacyFeedLineHeight div:has(main)",".authentication-outlet"]},searchAllPage:{peopleButton:["nav ul.search-reusables__filter-list>li>button"],toolbar:[".scaffold-layout-toolbar"]}};function z(e,t,n){switch(n){case"all":const n=e.querySelectorAll(t);return n.length>0?Array.from(n):null;case"closest":return e instanceof HTMLElement?e.closest(t):null;default:return e.querySelector(t)}}function B({page:e,key:t,selector:n,container:o,mode:i}){null!=o||(o=document);const r=e&&t?function({page:e,key:t}){return H[e][t]}({page:e,key:t}):[n];for(const e of r){const t=z(o,e,i);if(t)return t}return null}function W(e){if(!e)return"";const t=document.createElement("textarea");return t.innerHTML=e,t.value.trim()}function V(){var e,t,n,o,i,r,a;const s=window.location.href.includes("linkedin.com/sales")?"salesNavProfilePage":"profilePage";function l(e){return B({page:s,key:e,container:document})}const c=null==(e=l("userName"))?void 0:e.innerText;if(!c)return console.error("extractUserInfos: no userName found"),{};const u=null==(t=l("userPicture"))?void 0:t.src,d=null==(n=l("userOccupation"))?void 0:n.innerHTML,h=null==(o=l("companyName"))?void 0:o.innerText,m=null==(i=l("companyLogo"))?void 0:i.src,p=null==(r=l("location"))?void 0:r.innerText;let g;return"salesNavProfilePage"===s&&(g=/linkedin\.com\/sales\/lead/i.test(window.location.href)?window.location.href:null==(a=l("profileUrl"))?void 0:a.href),{name:W(c),profileUrl:g,picture:u,occupation:W(d),companyName:h,companyPicture:m,location:p}}function Y(e){return/^https?:\/\/(www|.{2})\.linkedin\.com/.test(e)}const F={"":0,chrome:1,"chrome-extension":2,"view-source":3,ftp:4,file:5,data:6,blob:7,about:8};function X(e=""){let t="";const n=e.split("#")[0].toLocaleLowerCase();return/^https\:\/\/(www|.{2})\.linkedin\.com\/in\/[^/?]+(\/recent-activity\/|\/details\/|\/overlay\/|\/?\?[^/]*|\/?$)/.test(n)||/^https\:\/\/(www|.{2})\.linkedin\.com\/sales\/people\/(.+?),/.test(n)||/^https\:\/\/(www|.{2})\.linkedin\.com\/sales\/(profile|lead)\/([^,]{39}),/.test(n)?t="profile":n.includes("linkedin.com/feed")?t="feed":n.includes("linkedin.com/posts/")?t="post":n.includes("linkedin.com/login")||n.includes("linkedin.com/checkpoint")||n.includes("linkedin.com/authwall")?t="login":n.includes("linkedin.com/company/")?t="company":n.includes("linkedin.com/messaging/thread/")?t="messages":n.includes("linkedin.com/search/results/people/?")||n.includes("linkedin.com/sales/search/people")?t="search-people":n.includes("linkedin.com/search/results/all")?t="search-all":n.includes("linkedin.com/mynetwork/")&&(t="connections"),t}function G(e=""){var t;const n=((e=e||(null==(t=window.top)?void 0:t.location.href)||document.URL).match(/linkedin\.com\/in\/([^?/]+)/)||[])[1]||(e.match(/linkedin\.com\/sales\/people\/(.+?),/)||[])[1]||(e.match(/linkedin\.com\/sales\/(?:profile|lead)\/([^,]{39}),/)||[])[1]||"";return decodeURIComponent(n)}function J(e=""){var t;const n=((e=e||(null==(t=window.top)?void 0:t.location.href)||document.URL).match(/linkedin\.com\/posts\/([^\/]+)\//)||[])[1]||"";return decodeURIComponent(n)}function q(e=""){var t;const n=((e=e||(null==(t=window.top)?void 0:t.location.href)||document.URL).match(/linkedin\.com\/company\/([^?/]+)/)||[])[1]||"";return decodeURIComponent(n)}function Q(e=""){var t;return G(e=e||(null==(t=window.top)?void 0:t.location.href)||document.URL)||q(e)||""}function Z(e=""){if(!e)return"";const t=Object.keys(F),n=new URL(e).protocol.replace(":","");return t.includes(n)?n:X(e)}var ee,te;function ne(e){if(!e)return;const t=e.match(/:(\d+)$/);return t?t[1]:void 0}function oe(e){if(!e)return;const t=e.match(/,(\d+)\)$/);return t?t[1]:void 0}function ie(e){if(null!=e&&e.year)return{year:e.year,month:e.month}}function re(e,t,n){if(!e||0===Object.keys(e).length)return n||"";if(t&&e[t])return e[t];const o=Object.keys(e),i=o.find(e=>e.startsWith("en"));return i?e[i]:e[o[0]]||n||""}function ae(e,t){if(!e||!t)return{};const n={};for(const[o,i]of Object.entries(e))o!==t&&i&&(n[o]=i);return n}function se(e){return le(e)}function le(e){var t,n,o;if(!e)return;const i=(e.rootUrl&&e.artifacts?e:null)||e.vectorImage||(null==(t=e.image)?void 0:t["com.linkedin.common.VectorImage"])||e["com.linkedin.common.VectorImage"]||(null==(n=e.displayImageReference)?void 0:n.vectorImage);if(null==i||!i.rootUrl||null==i||null==(o=i.artifacts)||!o.length)return;const r=i.artifacts,a=r.reduce((e,t)=>((null==t?void 0:t.width)||0)>((null==e?void 0:e.width)||0)?t:e,r[0]);return null!=a&&a.fileIdentifyingUrlPathSegment?i.rootUrl+a.fileIdentifyingUrlPathSegment:void 0}function ce(e){var t,n,o,i,r,a,s,l;const c=ne(e.objectUrn);if(!c)throw new Error("Cannot extract memberId from rawProfile");const u=function(e){if(e)return`${e.language}_${e.country}`}(e.primaryLocale),d=function(e){if(null!=e&&e.length)return e.map(e=>`${e.language}_${e.country}`)}(e.supportedLocales),h=re(e.multiLocaleFirstName,u,e.firstName),m=re(e.multiLocaleLastName,u,e.lastName),p=re(e.multiLocaleHeadline,u,e.headline),g=re(e.multiLocaleSummary,u,e.summary),y={},f=(null==d?void 0:d.filter(e=>e!==u))||[];for(const t of f){var v,w,b,k;const n={},o=null==(v=e.multiLocaleFirstName)?void 0:v[t],i=null==(w=e.multiLocaleLastName)?void 0:w[t],r=null==(b=e.multiLocaleHeadline)?void 0:b[t],a=null==(k=e.multiLocaleSummary)?void 0:k[t];o&&(n.firstName=o),i&&(n.lastName=i),r&&(n.headline=r),a&&(n.summary=a),Object.keys(n).length>0&&(y[t]=n)}const S=(null==(t=e.profileSkills)||null==(t=t.elements)?void 0:t.map(e=>e.name))||[],C=(null==(n=e.profileLanguages)||null==(n=n.elements)?void 0:n.map(e=>({name:e.name,proficiency:e.proficiency})))||[],L=(null==(o=e.profileHonors)||null==(o=o.elements)?void 0:o.map(e=>({title:e.title,issuer:e.issuer,issuedOn:ie(e.issuedOn)})))||[],I=(null==(i=e.profileEducations)||null==(i=i.elements)?void 0:i.map(e=>{var t,n,o;return{school:re(e.multiLocaleSchoolName,u,e.schoolName||(null==(t=e.school)?void 0:t.name)),degree:re(e.multiLocaleDegreeName,u,e.degreeName)||void 0,fieldOfStudy:re(e.multiLocaleFieldOfStudy,u,e.fieldOfStudy)||void 0,startDate:ie(null==(n=e.dateRange)?void 0:n.start),endDate:ie(null==(o=e.dateRange)?void 0:o.end)}}))||[],N=(null==(r=e.profileCertifications)||null==(r=r.elements)?void 0:r.map(e=>{var t,n;return{name:re(e.multiLocaleName,u,e.name),authority:re(e.multiLocaleAuthority,u,e.authority)||void 0,startDate:ie(null==(t=e.dateRange)?void 0:t.start),endDate:ie(null==(n=e.dateRange)?void 0:n.end),licenseNumber:e.licenseNumber,url:e.url}}))||[],P=[];null==(a=e.profilePositionGroups)||null==(a=a.elements)||a.forEach(e=>{var t;((null==(t=e.profilePositionInPositionGroup)?void 0:t.elements)||[]).forEach(t=>{var n,o,i,r;const a=t.company||e.company,s=ne(t.companyUrn||(null==a?void 0:a.entityUrn)),l=re(t.multiLocaleTitle,u,t.title),c=re(t.multiLocaleCompanyName,u,t.companyName||(null==a?void 0:a.name)),d=re(t.multiLocaleDescription,u,t.description)||void 0,h={};for(const e of f){var m,p,g;const n={},o=null==(m=t.multiLocaleTitle)?void 0:m[e],i=null==(p=t.multiLocaleDescription)?void 0:p[e],r=null==(g=t.multiLocaleCompanyName)?void 0:g[e];o&&(n.title=o),i&&(n.description=i),r&&(n.companyName=r),Object.keys(n).length>0&&(h[e]=n)}let y;if(null!=a&&a.industry&&null!=a&&null!=(n=a.industryUrns)&&n.length){const e=a.industry[a.industryUrns[0]];y=null==e?void 0:e.name}P.push({linkedinPositionId:oe(t.entityUrn),companyName:c,companyLinkedinId:s,companyUniversalName:null==a?void 0:a.universalName,title:l,description:d,startDate:ie(null==(o=t.dateRange)?void 0:o.start),endDate:ie(null==(i=t.dateRange)?void 0:i.end),isCurrent:!(null!=(r=t.dateRange)&&r.end),companyLogoUrl:se(null==a?void 0:a.logo),companyIndustry:y,companyEmployeeCountRange:null!=a&&a.employeeCountRange?{start:a.employeeCountRange.start,end:a.employeeCountRange.end}:void 0,translations:Object.keys(h).length>0?h:void 0})})});const M=(null==(s=e.geoLocation)||null==(s=s.geo)?void 0:s.defaultLocalizedName)||void 0,x=null==(l=e.industry)?void 0:l.name;return{memberId:c,publicIdentifier:e.publicIdentifier,firstName:h,lastName:m,headline:p||void 0,summary:g||void 0,location:M,pictureUrl:(E=e.profilePicture,le(E)),backgroundPictureUrl:(O=e.backgroundPicture,le(O)),isPremium:!0===e.premium,industry:x,primaryLocale:u,supportedLocales:d,skills:S,languages:C.length>0?C:void 0,honors:L.length>0?L:void 0,educations:I.length>0?I:void 0,certifications:N.length>0?N:void 0,positions:P.length>0?P:void 0,translations:Object.keys(y).length>0?y:void 0};var O,E}function ue(e){var t;const n=new Map;return null==(t=e.profilePositionGroups)||null==(t=t.elements)||t.forEach(e=>{var t;[e.company,...(null==(t=e.profilePositionInPositionGroup)||null==(t=t.elements)?void 0:t.map(e=>e.company))||[]].filter(Boolean).forEach(e=>{var t;const o=ne(e.entityUrn);if(!o||n.has(o))return;let i;if(e.industry&&null!=(t=e.industryUrns)&&t.length){const t=e.industry[e.industryUrns[0]];i=null==t?void 0:t.name}n.set(o,{linkedinId:o,universalName:e.universalName,name:e.name||"",industry:i,employeeCountRange:e.employeeCountRange?{start:e.employeeCountRange.start,end:e.employeeCountRange.end}:void 0,logoUrl:se(e.logo)})})}),Array.from(n.values())}function de(e){var t,n,o,i,r,a,s,l,c,u;const d=(null==(t=e.elements)?void 0:t[0])||e,h=ne(d.entityUrn);if(!h)throw new Error("Cannot extract linkedinId from company data");const m=(null!=(n=d.defaultLocale)&&n.language&&null!=(o=d.defaultLocale)&&o.country?`${d.defaultLocale.language}_${d.defaultLocale.country}`:null)||(null!=(i=d.multiLocaleNames)&&i.localized?Object.keys(d.multiLocaleNames.localized)[0]:null)||"en_US",p=null==(r=d.multiLocaleNames)?void 0:r.localized,g=re(p,m,d.name),y=null==(a=d.multiLocaleDescriptions)?void 0:a.localized,f=re(y,m,"string"==typeof d.description?d.description:void 0)||void 0,v={},w=ae(p,m),b=ae(y,m),k=new Set([...Object.keys(w),...Object.keys(b)]);for(const e of k){const t={};w[e]&&(t.name=w[e]),b[e]&&(t.description=b[e]),Object.keys(t).length>0&&(v[e]=t)}const S=d.headquarter||(null==(s=d.confirmedLocations)?void 0:s.find(e=>e.headquarter)),C=le(d.logo)||le(null==(l=d.logos)?void 0:l.logo),L=le(d.backgroundCoverImage),I=d.jobSearchPageUrl||void 0,N=null==(c=d.companyIndustries)||null==(c=c[0])?void 0:c.localizedName,P=k.size>0?[m,...Array.from(k)]:void 0;return{linkedinId:h,universalName:d.universalName,name:g,description:f,industry:N,employeeCountRange:d.staffCount?{start:d.staffCount,end:d.staffCount}:d.staffCountRange?{start:d.staffCountRange.start,end:d.staffCountRange.end}:void 0,headquarters:S?{country:S.country,city:S.city,geographicArea:S.geographicArea,postalCode:S.postalCode,line1:S.line1}:void 0,logoUrl:C,backgroundCoverUrl:L,specialities:d.specialities,companyType:d.type,foundedYear:null==(u=d.foundedOn)?void 0:u.year,websiteUrl:d.companyPageUrl,jobSearchPageUrl:I,primaryLocale:m,supportedLocales:P,translations:Object.keys(v).length>0?v:void 0}}!function(e){e.PUBLIC="public",e.MANUAL="manual",e.APOLLO="apollo",e.LUSHA="lusha",e.HUNTER="hunter",e.ROCKETREACH="rocketreach",e.SNOV="snov",e.CLEARBIT="clearbit"}(ee||(ee={})),function(e){e.EMAIL="email",e.PHONE="phone",e.BOTH="both"}(te||(te={}));export{M as ChromeStore,ee as ContactInfoSource,N as Draggable,f as MemoryStore,te as QueryType,e as RealUndefined,P as WebStore,p as cacheWrapper,r as cloneDeep,l as createDefaultObject,w as createElement,R as createMessageBus,S as createSvg,C as createSvgFromUrl,a as debounce,O as decodeJWT,s as delayExecution,ue as extractCompaniesFromRawProfile,i as generateStableUniqueKey,q as getCompanyPublicId,V as getContactInfo,E as getCookie,U as getCookies,B as getElement,_ as getExtensionInfo,o as getGlobal,D as getLinkedinCompany,j as getLinkedinMe,X as getLinkedinPageType,K as getLinkedinProfile,Q as getLinkedinPublicId,Z as getPageType,J as getPostPublicId,G as getProfilePublicId,t as isCloneable,A as isErrorResponse,Y as isLinkedInUrl,n as isPrimitive,x as launchWebAuthFlow,F as pageTypeMap,L as scrollToBottom,I as scrollToBottomIfNeeded,g as singleExecutionWrapper,de as transformRawCompany,ce as transformRawProfile};
2
2
  //# sourceMappingURL=index.modern.js.map