@i.un/libs 0.0.55 → 0.0.57

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.
package/README.md ADDED
@@ -0,0 +1,249 @@
1
+ # @i.un/libs
2
+
3
+ 一个实用的 TypeScript 函数库,提供跨平台的工具函数和实用程序。
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@i.un/libs.svg)](https://www.npmjs.com/package/@i.un/libs)
6
+ [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)
7
+
8
+ ## 📦 安装
9
+
10
+ ```bash
11
+ npm install @i.un/libs
12
+ # 或
13
+ yarn add @i.un/libs
14
+ # 或
15
+ pnpm add @i.un/libs
16
+ ```
17
+
18
+ ## 🚀 快速开始
19
+
20
+ ```typescript
21
+ import { debounce, createElement, cloneDeep } from '@i.un/libs';
22
+
23
+ // 防抖函数
24
+ const debouncedFn = debounce(() => {
25
+ console.log('防抖执行');
26
+ }, 300);
27
+
28
+ // 创建DOM元素
29
+ const button = createElement({
30
+ tag: 'button',
31
+ children: '点击我',
32
+ attrs: { id: 'myButton' },
33
+ styles: { color: 'red' }
34
+ });
35
+
36
+ // 深度克隆
37
+ const cloned = cloneDeep({ name: 'test', items: [1, 2, 3] });
38
+ ```
39
+
40
+ ## 📚 功能模块
41
+
42
+ ### 🔧 通用工具 (Common)
43
+
44
+ #### 防抖和节流
45
+ - `debounce(func, wait)` - 防抖函数
46
+ - `delayExecution(callback, delay, ...args)` - 延迟执行函数
47
+
48
+ #### 对象操作
49
+ - `cloneDeep(obj)` - 深度克隆对象
50
+ - `createDefaultObject(defaultValue)` - 创建带默认值的代理对象
51
+ - `isCloneable(obj)` - 检查对象是否可克隆
52
+ - `isPrimitive(value)` - 检查值是否为原始类型
53
+
54
+ #### 缓存和性能
55
+ - `cacheWrapper(func, setting)` - 为异步函数添加缓存功能
56
+ - `singleExecutionWrapper(func)` - 单次执行包装器
57
+ - `generateStableUniqueKey(args)` - 生成稳定的唯一键
58
+
59
+ #### 存储
60
+ - `MemoryStore` - 内存存储类
61
+
62
+ ### 🌐 浏览器工具 (Browser)
63
+
64
+ #### DOM 操作
65
+ - `createElement(options)` - 创建DOM元素
66
+ - `createSvg(params)` - 创建SVG元素
67
+ - `createSvgFromUrl(url)` - 从URL加载SVG
68
+
69
+ #### 滚动控制
70
+ - `scrollToBottom(dom)` - 滚动到底部
71
+ - `scrollToBottomIfNeeded(dom)` - 智能滚动到底部
72
+
73
+ #### 拖拽功能
74
+ - `draggable` - 拖拽相关功能
75
+
76
+ #### 存储
77
+ - `WebStore` - 浏览器存储封装
78
+
79
+ ### 🖥️ Node.js 工具 (Node)
80
+
81
+ - `node` - Node.js 环境相关工具
82
+
83
+ ### 🔌 Chrome 扩展工具 (Chrome)
84
+
85
+ - `ChromeStore` - Chrome 扩展存储
86
+ - `identity` - Chrome 身份验证相关
87
+
88
+ ## 📖 详细文档
89
+
90
+ ### 防抖函数
91
+
92
+ ```typescript
93
+ import { debounce } from '@i.un/libs';
94
+
95
+ const debouncedSearch = debounce((query: string) => {
96
+ console.log('搜索:', query);
97
+ }, 300);
98
+
99
+ // 快速连续调用只会执行最后一次
100
+ debouncedSearch('a');
101
+ debouncedSearch('ab');
102
+ debouncedSearch('abc'); // 只有这次会执行
103
+ ```
104
+
105
+ ### DOM 元素创建
106
+
107
+ ```typescript
108
+ import { createElement } from '@i.un/libs';
109
+
110
+ // 创建简单元素
111
+ const div = createElement({
112
+ tag: 'div',
113
+ children: 'Hello World',
114
+ styles: { color: 'blue', fontSize: '16px' }
115
+ });
116
+
117
+ // 创建复杂嵌套元素
118
+ const card = createElement({
119
+ tag: 'div',
120
+ attrs: { class: 'card' },
121
+ children: [
122
+ {
123
+ tag: 'h2',
124
+ children: '标题',
125
+ styles: { margin: 0 }
126
+ },
127
+ {
128
+ tag: 'p',
129
+ children: '内容描述',
130
+ styles: { color: '#666' }
131
+ }
132
+ ]
133
+ });
134
+ ```
135
+
136
+ ### SVG 创建
137
+
138
+ ```typescript
139
+ import { createSvg, createSvgFromUrl } from '@i.un/libs';
140
+
141
+ // 从字符串创建SVG
142
+ const svgString = `
143
+ <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
144
+ <circle cx="50" cy="50" r="40" fill="red" />
145
+ </svg>
146
+ `;
147
+ const svgElement = createSvg(svgString);
148
+
149
+ // 从VNode创建SVG
150
+ const vnode = {
151
+ type: 'svg',
152
+ props: { width: '100', height: '100' },
153
+ children: [{
154
+ type: 'circle',
155
+ props: { cx: '50', cy: '50', r: '40', fill: 'red' },
156
+ children: null
157
+ }]
158
+ };
159
+ const svgFromVNode = createSvg(vnode);
160
+
161
+ // 从URL加载SVG
162
+ const svgFromUrl = await createSvgFromUrl('https://example.com/icon.svg');
163
+ ```
164
+
165
+ ### 缓存包装器
166
+
167
+ ```typescript
168
+ import { cacheWrapper } from '@i.un/libs';
169
+
170
+ // 包装异步函数添加缓存
171
+ const fetchUserData = cacheWrapper(async (userId: string) => {
172
+ const response = await fetch(`/api/users/${userId}`);
173
+ return response.json();
174
+ }, {
175
+ timeout: 10000,
176
+ timeoutResult: { error: '请求超时' },
177
+ identifier: 'userData'
178
+ });
179
+
180
+ // 第一次调用会执行请求
181
+ const user1 = await fetchUserData('123');
182
+
183
+ // 第二次调用会返回缓存结果
184
+ const user2 = await fetchUserData('123'); // 从缓存返回
185
+ ```
186
+
187
+ ### 深度克隆
188
+
189
+ ```typescript
190
+ import { cloneDeep } from '@i.un/libs';
191
+
192
+ const original = {
193
+ name: 'test',
194
+ items: [1, 2, { nested: true }],
195
+ date: new Date()
196
+ };
197
+
198
+ const cloned = cloneDeep(original);
199
+ cloned.items.push(4); // 不会影响原对象
200
+ ```
201
+
202
+ ### 滚动控制
203
+
204
+ ```typescript
205
+ import { scrollToBottom, scrollToBottomIfNeeded } from '@i.un/libs';
206
+
207
+ const chatContainer = document.getElementById('chat');
208
+
209
+ // 强制滚动到底部
210
+ scrollToBottom(chatContainer);
211
+
212
+ // 智能滚动(只在用户未手动滚动时自动滚动)
213
+ scrollToBottomIfNeeded(chatContainer);
214
+ ```
215
+
216
+ ## 🧪 测试
217
+
218
+ ```bash
219
+ npm test
220
+ ```
221
+
222
+ ## 📝 开发
223
+
224
+ ```bash
225
+ # 安装依赖
226
+ npm install
227
+
228
+ # 开发模式
229
+ npm run dev
230
+
231
+ # 构建
232
+ npm run build
233
+
234
+ # 生成文档
235
+ npm run doc
236
+ ```
237
+
238
+ ## 📄 许可证
239
+
240
+ ISC
241
+
242
+ ## 👨‍💻 作者
243
+
244
+ zhyswan
245
+
246
+ ## 🔗 相关链接
247
+
248
+ - [GitHub Repository](https://github.com/zhyswan/libs)
249
+ - [NPM Package](https://www.npmjs.com/package/@i.un/libs)
@@ -5,6 +5,7 @@ type TLaunchWebAuthFlowParams = {
5
5
  responseType: TResponseType | readonly TResponseType[];
6
6
  state?: string;
7
7
  nonce?: string;
8
+ interactive?: boolean;
8
9
  };
9
10
  type TMapping = {
10
11
  id_token: {
@@ -30,7 +31,7 @@ type TResult<T extends TResponseType | readonly TResponseType[]> = T extends TRe
30
31
  * @param responseType - 响应类型,默认: "code"
31
32
  * @returns Promise<string> - 返回 id_token 或 code
32
33
  */
33
- export declare function launchWebAuthFlow<P extends TLaunchWebAuthFlowParams>({ clientId, responseType, state, nonce, }: P): Promise<TResult<P["responseType"]> & (P extends {
34
+ export declare function launchWebAuthFlow<P extends TLaunchWebAuthFlowParams>({ clientId, responseType, state, nonce, interactive, }: P): Promise<TResult<P["responseType"]> & (P extends {
34
35
  state: string;
35
36
  } ? {
36
37
  state: string;
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- var e=Symbol("undefined");function t(e){return"function"==typeof(null==e?void 0:e.clone)}function r(e){var t=typeof e;return null===e||"string"===t||"number"===t||"boolean"===t||"undefined"===t}function n(e){return r(e)?String(e):JSON.stringify(e,function(e,t){return"object"!=typeof t||null===t||Array.isArray(t)?t:Object.keys(t).sort().reduce(function(e,r){return e[r]=t[r],e},{})})}function o(e){if(null===e||"object"!=typeof e)return e;if(t(e))return e.clone();if(Array.isArray(e))return e.map(function(e){return o(e)});var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=o(e[n]));return r}function i(e){return new Proxy({},{get:function(t,r){return t.hasOwnProperty(r)?t[r]:e}})}var s=i(e),a=i(!1);function c(e){return s[e]}function l(t){return s[t]!==e}var u={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"},identifier:""};function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},f.apply(null,arguments)}var g=/*#__PURE__*/function(){function e(e){this.storageKey=void 0,this.data={},this.changeCallbacks=[],this.storageKey=e}e.getInstanceKey=function(e){return"memory:"+e},e.getInstance=function(t){var r=this.getInstanceKey(t);return this.instances.has(r)||this.instances.set(r,new e(t)),this.instances.get(r)},e.create=function(e){return this.getInstance(e)},e.clearInstance=function(e){var t=this.getInstanceKey(e),r=this.instances.get(t);r&&r.clearChangeCallbacks(),this.instances.delete(t)},e.clearAllInstances=function(){this.instances.forEach(function(e){e.clearChangeCallbacks()}),this.instances.clear()};var t=e.prototype;return t.set=function(e,t){try{var r,n=this.data[e];this.data=f({},this.data,((r={})[e]=t,r)),this.triggerChange(n,t)}catch(e){throw console.error("MemoryStore.set 失败:",e),e}},t.get=function(e){try{return this.data[e]}catch(e){throw console.error("MemoryStore.get 失败:",e),e}},t.getAll=function(){return f({},this.data)},t.remove=function(e){try{if(e in this.data){var t=this.data[e],r=f({},this.data);delete r[e],this.data=r,this.triggerChange(t,void 0)}}catch(e){throw console.error("MemoryStore.remove 失败:",e),e}},t.clear=function(){try{var e=f({},this.data);this.data={},this.triggerChange(e,{})}catch(e){throw console.error("MemoryStore.clear 失败:",e),e}},t.setMultiple=function(e){try{var t=f({},this.data);this.data=f({},this.data,e),this.triggerChange(t,this.data)}catch(e){throw console.error("MemoryStore.setMultiple 失败:",e),e}},t.onChanged=function(e){this.changeCallbacks.push(e)},t.triggerChange=function(e,t){if(this.changeCallbacks.length>0){var r,n=((r={})[this.storageKey]={oldValue:e,newValue:t},r);this.changeCallbacks.forEach(function(e){try{e(n)}catch(e){console.error("MemoryStore 变化回调执行失败:",e)}})}},t.clearChangeCallbacks=function(){this.changeCallbacks=[]},t.has=function(e){try{return e in this.data}catch(e){return console.error("MemoryStore.has 失败:",e),!1}},t.getSize=function(){try{var e=JSON.stringify(this.data);return new Blob([e]).size}catch(e){return console.error("MemoryStore.getSize 失败:",e),0}},t.getStoreKey=function(){return this.storageKey},t.getStoreType=function(){return"memory"},e}();function d(e,t,r,n){if(void 0===n&&(n=!1),t in e.style)e.style[t]=r;else{var o=n?"important":"";e.style.setProperty(t,String(r),o)}}function v(e){var t=document.createElementNS("http://www.w3.org/2000/svg",e.type);if(e.props)for(var r=0,n=Object.entries(e.props);r<n.length;r++){var o=n[r];t.setAttribute(o[0],o[1])}if("string"==typeof e.children){var i=document.createTextNode(e.children);t.appendChild(i)}else Array.isArray(e.children)&&e.children.forEach(function(e){var r=v(e);t.appendChild(r)});return t}function m(e){var t=(new DOMParser).parseFromString(e,"image/svg+xml").documentElement;if(!(t instanceof SVGElement))throw new Error("解析失败,结果不是有效的 SVG 元素");return t}function p(e){e&&setTimeout(function(){e.scrollTop=e.scrollHeight},0)}g.instances=new Map;var y=/*#__PURE__*/function(){function e(e,t){void 0===t&&(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=f({coordinate:"tl"},t);var r=getComputedStyle(this.element).position;r&&"static"!==r||(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))}var t=e.prototype;return t.onMouseDown=function(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)},t.getBoundedPosition=function(e,t){var r,n,o=this.element.getBoundingClientRect();if("fixed"===getComputedStyle(this.element).position)r=window.innerWidth-o.width,n=window.innerHeight-o.height;else{var i=(this.element.offsetParent||document.documentElement).getBoundingClientRect();r=i.width-o.width,n=i.height-o.height}return{x:Math.min(Math.max(0,e),r),y:Math.min(Math.max(0,t),n)}},t.onMouseMove=function(e){if(!this.isDragging){var 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){var r=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=r.x+"px",this.element.style.top=r.y+"px",this.options.onDrag&&this.options.onDrag(e)}},t.convertCoordinate=function(){var e=this.element.getBoundingClientRect(),t=getComputedStyle(this.element).position,r=null,n=null;if("fixed"===t?(r=null,n=new DOMRect(0,0,window.innerWidth,window.innerHeight)):((r=this.element.offsetParent)||(r=document.documentElement),"static"===getComputedStyle(r).position?(r=null,n=new DOMRect(0,0,window.innerWidth,window.innerHeight)):n=r.getBoundingClientRect()),n){var o,i;if("fixed"===t)o=e.left,i=e.top;else if(o=e.left-n.left,i=e.top-n.top,r instanceof HTMLElement){var s=getComputedStyle(r);o-=parseFloat(s.borderLeftWidth)||0,i-=parseFloat(s.borderTopWidth)||0}else o+=window.scrollX,i+=window.scrollY;switch(this.options.coordinate){case"tr":var a=n.width-o-e.width;this.element.style.left="auto",this.element.style.right=a+"px",this.element.style.top=i+"px",this.element.style.bottom="auto";break;case"bl":var c=n.height-i-e.height;this.element.style.left=o+"px",this.element.style.right="auto",this.element.style.top="auto",this.element.style.bottom=c+"px";break;case"br":var l=n.width-o-e.width,u=n.height-i-e.height;this.element.style.left="auto",this.element.style.right=l+"px",this.element.style.top="auto",this.element.style.bottom=u+"px";break;default:this.element.style.left=o+"px",this.element.style.right="auto",this.element.style.top=i+"px",this.element.style.bottom="auto"}}},t.onMouseUp=function(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)},e}(),w=/*#__PURE__*/function(){function e(e,t){void 0===t&&(t="local"),this.storageKey=void 0,this.storeType=void 0,this.store=void 0,this.storageKey=e,this.storeType=t}e.getInstanceKey=function(e,t){return void 0===t&&(t="local"),t+":"+e},e.getInstance=function(t,r){void 0===r&&(r="local");var n=this.getInstanceKey(t,r);return this.instances.has(n)||this.instances.set(n,new e(t,r)),this.instances.get(n)},e.local=function(e){return this.getInstance(e,"local")},e.session=function(e){return this.getInstance(e,"session")},e.clearInstance=function(e,t){void 0===t&&(t="local");var r=this.getInstanceKey(e,t);this.instances.delete(r)},e.clearAllInstances=function(){this.instances.clear()};var t=e.prototype;return t.getStore=function(){return this.store||(this.store="local"===this.storeType?localStorage:sessionStorage),this.store},t.set=function(e,t){try{var r,n=f({},this.getAll(),((r={})[e]=t,r));this.getStore().setItem(this.storageKey,JSON.stringify(n))}catch(e){throw console.error("WebStore.set 失败:",e),e}},t.get=function(e){try{var t=this.getAll();return null==t?void 0:t[e]}catch(e){throw console.error("WebStore.get 失败:",e),e}},t.getAll=function(){try{var e=this.getStore().getItem(this.storageKey);return e?JSON.parse(e):{}}catch(e){return console.error("WebStore.getAll 失败:",e),{}}},t.remove=function(e){try{var 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}},t.clear=function(){try{this.getStore().removeItem(this.storageKey)}catch(e){throw console.error("WebStore.clear 失败:",e),e}},t.setMultiple=function(e){try{var t=f({},this.getAll(),e);this.getStore().setItem(this.storageKey,JSON.stringify(t))}catch(e){throw console.error("WebStore.setMultiple 失败:",e),e}},t.onChanged=function(e){var t=this;window.addEventListener("storage",function(r){if(r.key===t.storageKey&&r.storageArea===t.getStore()){var n,o=((n={})[t.storageKey]={oldValue:r.oldValue?JSON.parse(r.oldValue):void 0,newValue:r.newValue?JSON.parse(r.newValue):void 0},n);e(o)}})},t.has=function(e){try{return void 0!==this.get(e)}catch(e){return console.error("WebStore.has 失败:",e),!1}},t.getSize=function(){try{var e=this.getStore().getItem(this.storageKey)||"";return new Blob([e]).size}catch(e){return console.error("WebStore.getSize 失败:",e),0}},t.getStoreKey=function(){return this.storageKey},e}();function S(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}w.instances=new Map;var b=/*#__PURE__*/function(){function e(e,t){void 0===t&&(t="local"),this.storageKey=void 0,this.storeType=void 0,this.store=void 0,this.storageKey=e,this.storeType=t}e.getInstanceKey=function(e,t){return void 0===t&&(t="local"),t+":"+e},e.getInstance=function(t,r){void 0===r&&(r="local");var n=this.getInstanceKey(t,r);return this.instances.has(n)||this.instances.set(n,new e(t,r)),this.instances.get(n)},e.local=function(e){return this.getInstance(e,"local")},e.sync=function(e){return this.getInstance(e,"sync")},e.clearInstance=function(e,t){void 0===t&&(t="local");var r=this.getInstanceKey(e,t);this.instances.delete(r)},e.clearAllInstances=function(){this.instances.clear()};var t=e.prototype;return t.getStore=function(){return this.store||(this.store=chrome.storage[this.storeType]),this.store},t.set=function(e,t){try{var r=this;return Promise.resolve(S(function(){return Promise.resolve(r.getAll()).then(function(n){var o,i,s=f({},n,((o={})[e]=t,o));return Promise.resolve(r.getStore().set((i={},i[r.storageKey]=s,i))).then(function(){})})},function(e){throw console.error("ChromeStore.set 失败:",e),e}))}catch(e){return Promise.reject(e)}},t.get=function(e){try{var t=this;return Promise.resolve(S(function(){return Promise.resolve(t.getAll()).then(function(t){return null==t?void 0:t[e]})},function(e){throw console.error("ChromeStore.get 失败:",e),e}))}catch(e){return Promise.reject(e)}},t.getAll=function(){try{var e=this;return Promise.resolve(S(function(){return Promise.resolve(e.getStore().get(e.storageKey)).then(function(t){return t[e.storageKey]||{}})},function(e){throw console.error("ChromeStore.getAll 失败:",e),e}))}catch(e){return Promise.reject(e)}},t.remove=function(e){try{var t=this;return Promise.resolve(S(function(){return Promise.resolve(t.getAll()).then(function(r){var n=function(){var n;if(r&&e in r)return delete r[e],Promise.resolve(t.getStore().set((n={},n[t.storageKey]=r,n))).then(function(){})}();if(n&&n.then)return n.then(function(){})})},function(e){throw console.error("ChromeStore.remove 失败:",e),e}))}catch(e){return Promise.reject(e)}},t.clear=function(){try{var e=this;return Promise.resolve(S(function(){return Promise.resolve(e.getStore().remove(e.storageKey)).then(function(){})},function(e){throw console.error("ChromeStore.clear 失败:",e),e}))}catch(e){return Promise.reject(e)}},t.setMultiple=function(e){try{var t=this;return Promise.resolve(S(function(){return Promise.resolve(t.getAll()).then(function(r){var n,o=f({},r,e);return Promise.resolve(t.getStore().set((n={},n[t.storageKey]=o,n))).then(function(){})})},function(e){throw console.error("ChromeStore.setMultiple 失败:",e),e}))}catch(e){return Promise.reject(e)}},t.onChanged=function(e){var t=this;chrome.storage.onChanged.addListener(function(r,n){n===t.storeType&&r[t.storageKey]&&e(r)})},t.has=function(e){try{var t=this;return Promise.resolve(S(function(){return Promise.resolve(t.get(e)).then(function(e){return void 0!==e})},function(e){return console.error("ChromeStore.has 失败:",e),!1}))}catch(e){return Promise.reject(e)}},t.getSize=function(){try{var e=this;return Promise.resolve(S(function(){return Promise.resolve(e.getAll()).then(function(e){var t=JSON.stringify(e);return new Blob([t]).size})},function(e){return console.error("ChromeStore.getSize 失败:",e),0}))}catch(e){return Promise.reject(e)}},t.getStoreKey=function(){return this.storageKey},e}();b.instances=new Map,exports.ChromeStore=b,exports.Draggable=y,exports.MemoryStore=g,exports.RealUndefined=e,exports.WebStore=w,exports.cacheWrapper=function(e,t){void 0===t&&(t=u);var r=function(){var r=[].slice.call(arguments),i=n(r)+e.name+(t.identifier||"");if(l(i))return Promise.resolve(o(c(i)));if(a[i]){var h=Object.assign({},u,t);return new Promise(function(e){var t=Date.now(),r=setInterval(function(){l(i)?(clearInterval(r),e(o(c(i)))):Date.now()-t>h.timeout&&(a[i]=!1,clearInterval(r),e(o(h.timeoutResult)))},100)})}return a[i]=!0,e.apply(this,r).then(function(e){return s[i]=e,o(s[i])}).catch(function(e){throw e}).finally(function(){a[i]=!1})};return Object.defineProperty(r,"name",{value:"cacheWrapper_"+e.name,configurable:!0}),r},exports.cloneDeep=o,exports.createDefaultObject=i,exports.createElement=function e(t){var r=void 0===t?{}:t,n=r.tag,o=r.children,i=void 0===o?[]:o,s=r.props,a=void 0===s?{}:s,c=r.attrs,l=void 0===c?{}:c,u=r.styles,f=void 0===u?{}:u,g=document.createElement(void 0===n?"div":n);Object.assign(g,a);for(var v=0,m=Object.entries(l);v<m.length;v++){var p=m[v],y=p[1];!1!==y&&g.setAttribute(p[0],y)}for(var w=0,S=Object.entries(f);w<S.length;w++){var b=S[w];d(g,b[0],b[1])}for(var P,x=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,t){if(e){if("string"==typeof e)return h(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?h(e,t):void 0}}(e))){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(Array.isArray(i)?i:[i]);!(P=x()).done;){var C=P.value;C&&("object"==typeof C?C instanceof Element?g.appendChild(C):g.appendChild(e(C)):g.appendChild(document.createTextNode(C)))}return g},exports.createSvg=function(e){return"string"==typeof e?m(e):v(e)},exports.createSvgFromUrl=function(e){try{return Promise.resolve(function(t,r){try{var n=Promise.resolve(fetch(e)).then(function(e){if(!e.ok)throw new Error("网络请求失败: "+e.status+" "+e.statusText);return Promise.resolve(e.text()).then(m)})}catch(e){return r(e)}return n&&n.then?n.then(void 0,r):n}(0,function(e){var t=e instanceof Error?e.message:"未知错误";throw new Error("无法创建 SVG 元素: "+t)}))}catch(e){return Promise.reject(e)}},exports.debounce=function(e,t){var r=null;return function(){var n=arguments,o=this;null!==r&&clearTimeout(r),r=setTimeout(function(){e.apply(o,[].slice.call(n)),r=null},t)}},exports.decodeJWT=function(e){var t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),r=decodeURIComponent(atob(t).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(r)},exports.delayExecution=function(e,t){void 0===t&&(t=0);var r=[].slice.call(arguments,2);return new Promise(function(n){0===t?n(e.apply(void 0,r)):setTimeout(function(){n(e.apply(void 0,r))},t)})},exports.generateStableUniqueKey=n,exports.getGlobal=function(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this},exports.isCloneable=t,exports.isPrimitive=r,exports.launchWebAuthFlow=function(e){var t=e.clientId,r=e.responseType,n=void 0===r?"code":r,o=e.state,i=e.nonce;try{var s=chrome.identity.getRedirectURL(),a=Array.isArray(n)?n:[n],c=new URL("https://accounts.google.com/o/oauth2/v2/auth");return c.searchParams.set("client_id",t),c.searchParams.set("redirect_uri",s),c.searchParams.set("response_type",a.join(" ")),c.searchParams.set("scope","openid email profile"),i&&c.searchParams.set("nonce",i),o&&c.searchParams.set("state",o),Promise.resolve(chrome.identity.launchWebAuthFlow({url:c.toString(),interactive:!0}).then(function(e){if(!e)return Promise.reject(new Error("redirectUrl is null"));var t=e.includes("?")?"?":"#",r=new URLSearchParams(e.split(t)[1]),n={};return r.forEach(function(e,t){n[t]=e}),n}).catch(function(e){return console.log("error",e),Promise.reject(e)}))}catch(e){return Promise.reject(e)}},exports.scrollToBottom=p,exports.scrollToBottomIfNeeded=function(e){e&&("true"!==e.dataset.isListeningForUserScroll&&(function(e){e&&e.addEventListener("scroll",function(){!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&&p(e))},exports.singleExecutionWrapper=function(t,r){void 0===r&&(r=0);var n=function(){if(n.isExecuting)return Promise.resolve(e);n.isExecuting=!0;var o=performance.now(),i=t.apply(this,[].slice.call(arguments));return i.finally(function(){var e=performance.now()-o;r&&r>e?setTimeout(function(){n.isExecuting=!1},r-e):n.isExecuting=!1}),i};return n.isExecuting=!1,n};
1
+ var e=Symbol("undefined");function t(e){return"function"==typeof(null==e?void 0:e.clone)}function r(e){var t=typeof e;return null===e||"string"===t||"number"===t||"boolean"===t||"undefined"===t}function n(e){return r(e)?String(e):JSON.stringify(e,function(e,t){return"object"!=typeof t||null===t||Array.isArray(t)?t:Object.keys(t).sort().reduce(function(e,r){return e[r]=t[r],e},{})})}function o(e){if(null===e||"object"!=typeof e)return e;if(t(e))return e.clone();if(Array.isArray(e))return e.map(function(e){return o(e)});var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=o(e[n]));return r}function i(e){return new Proxy({},{get:function(t,r){return t.hasOwnProperty(r)?t[r]:e}})}var s=i(e),a=i(!1);function c(e){return s[e]}function l(t){return s[t]!==e}var u={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"},identifier:""};function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},f.apply(null,arguments)}var d=/*#__PURE__*/function(){function e(e){this.storageKey=void 0,this.data={},this.changeCallbacks=[],this.storageKey=e}e.getInstanceKey=function(e){return"memory:"+e},e.getInstance=function(t){var r=this.getInstanceKey(t);return this.instances.has(r)||this.instances.set(r,new e(t)),this.instances.get(r)},e.create=function(e){return this.getInstance(e)},e.clearInstance=function(e){var t=this.getInstanceKey(e),r=this.instances.get(t);r&&r.clearChangeCallbacks(),this.instances.delete(t)},e.clearAllInstances=function(){this.instances.forEach(function(e){e.clearChangeCallbacks()}),this.instances.clear()};var t=e.prototype;return t.set=function(e,t){try{var r,n=this.data[e];this.data=f({},this.data,((r={})[e]=t,r)),this.triggerChange(n,t)}catch(e){throw console.error("MemoryStore.set 失败:",e),e}},t.get=function(e){try{return this.data[e]}catch(e){throw console.error("MemoryStore.get 失败:",e),e}},t.getAll=function(){return f({},this.data)},t.remove=function(e){try{if(e in this.data){var t=this.data[e],r=f({},this.data);delete r[e],this.data=r,this.triggerChange(t,void 0)}}catch(e){throw console.error("MemoryStore.remove 失败:",e),e}},t.clear=function(){try{var e=f({},this.data);this.data={},this.triggerChange(e,{})}catch(e){throw console.error("MemoryStore.clear 失败:",e),e}},t.setMultiple=function(e){try{var t=f({},this.data);this.data=f({},this.data,e),this.triggerChange(t,this.data)}catch(e){throw console.error("MemoryStore.setMultiple 失败:",e),e}},t.onChanged=function(e){this.changeCallbacks.push(e)},t.triggerChange=function(e,t){if(this.changeCallbacks.length>0){var r,n=((r={})[this.storageKey]={oldValue:e,newValue:t},r);this.changeCallbacks.forEach(function(e){try{e(n)}catch(e){console.error("MemoryStore 变化回调执行失败:",e)}})}},t.clearChangeCallbacks=function(){this.changeCallbacks=[]},t.has=function(e){try{return e in this.data}catch(e){return console.error("MemoryStore.has 失败:",e),!1}},t.getSize=function(){try{var e=JSON.stringify(this.data);return new Blob([e]).size}catch(e){return console.error("MemoryStore.getSize 失败:",e),0}},t.getStoreKey=function(){return this.storageKey},t.getStoreType=function(){return"memory"},e}();function g(e,t,r,n){if(void 0===n&&(n=!1),t in e.style)e.style[t]=r;else{var o=n?"important":"";e.style.setProperty(t,String(r),o)}}function v(e){var t=document.createElementNS("http://www.w3.org/2000/svg",e.type);if(e.props)for(var r=0,n=Object.entries(e.props);r<n.length;r++){var o=n[r];t.setAttribute(o[0],o[1])}if("string"==typeof e.children){var i=document.createTextNode(e.children);t.appendChild(i)}else Array.isArray(e.children)&&e.children.forEach(function(e){var r=v(e);t.appendChild(r)});return t}function m(e){var t=(new DOMParser).parseFromString(e,"image/svg+xml").documentElement;if(!(t instanceof SVGElement))throw new Error("解析失败,结果不是有效的 SVG 元素");return t}function p(e){e&&setTimeout(function(){e.scrollTop=e.scrollHeight},0)}d.instances=new Map;var y=/*#__PURE__*/function(){function e(e,t){void 0===t&&(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=f({coordinate:"tl"},t);var r=getComputedStyle(this.element).position;r&&"static"!==r||(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))}var t=e.prototype;return t.onMouseDown=function(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)},t.getBoundedPosition=function(e,t){var r,n,o=this.element.getBoundingClientRect();if("fixed"===getComputedStyle(this.element).position)r=window.innerWidth-o.width,n=window.innerHeight-o.height;else{var i=(this.element.offsetParent||document.documentElement).getBoundingClientRect();r=i.width-o.width,n=i.height-o.height}return{x:Math.min(Math.max(0,e),r),y:Math.min(Math.max(0,t),n)}},t.onMouseMove=function(e){if(!this.isDragging){var 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){var r=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=r.x+"px",this.element.style.top=r.y+"px",this.options.onDrag&&this.options.onDrag(e)}},t.convertCoordinate=function(){var e=this.element.getBoundingClientRect(),t=getComputedStyle(this.element).position,r=null,n=null;if("fixed"===t?(r=null,n=new DOMRect(0,0,window.innerWidth,window.innerHeight)):((r=this.element.offsetParent)||(r=document.documentElement),"static"===getComputedStyle(r).position?(r=null,n=new DOMRect(0,0,window.innerWidth,window.innerHeight)):n=r.getBoundingClientRect()),n){var o,i;if("fixed"===t)o=e.left,i=e.top;else if(o=e.left-n.left,i=e.top-n.top,r instanceof HTMLElement){var s=getComputedStyle(r);o-=parseFloat(s.borderLeftWidth)||0,i-=parseFloat(s.borderTopWidth)||0}else o+=window.scrollX,i+=window.scrollY;switch(this.options.coordinate){case"tr":var a=n.width-o-e.width;this.element.style.left="auto",this.element.style.right=a+"px",this.element.style.top=i+"px",this.element.style.bottom="auto";break;case"bl":var c=n.height-i-e.height;this.element.style.left=o+"px",this.element.style.right="auto",this.element.style.top="auto",this.element.style.bottom=c+"px";break;case"br":var l=n.width-o-e.width,u=n.height-i-e.height;this.element.style.left="auto",this.element.style.right=l+"px",this.element.style.top="auto",this.element.style.bottom=u+"px";break;default:this.element.style.left=o+"px",this.element.style.right="auto",this.element.style.top=i+"px",this.element.style.bottom="auto"}}},t.onMouseUp=function(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)},e}(),w=/*#__PURE__*/function(){function e(e,t){void 0===t&&(t="local"),this.storageKey=void 0,this.storeType=void 0,this.store=void 0,this.storageKey=e,this.storeType=t}e.getInstanceKey=function(e,t){return void 0===t&&(t="local"),t+":"+e},e.getInstance=function(t,r){void 0===r&&(r="local");var n=this.getInstanceKey(t,r);return this.instances.has(n)||this.instances.set(n,new e(t,r)),this.instances.get(n)},e.local=function(e){return this.getInstance(e,"local")},e.session=function(e){return this.getInstance(e,"session")},e.clearInstance=function(e,t){void 0===t&&(t="local");var r=this.getInstanceKey(e,t);this.instances.delete(r)},e.clearAllInstances=function(){this.instances.clear()};var t=e.prototype;return t.getStore=function(){return this.store||(this.store="local"===this.storeType?localStorage:sessionStorage),this.store},t.set=function(e,t){try{var r,n=f({},this.getAll(),((r={})[e]=t,r));this.getStore().setItem(this.storageKey,JSON.stringify(n))}catch(e){throw console.error("WebStore.set 失败:",e),e}},t.get=function(e){try{var t=this.getAll();return null==t?void 0:t[e]}catch(e){throw console.error("WebStore.get 失败:",e),e}},t.getAll=function(){try{var e=this.getStore().getItem(this.storageKey);return e?JSON.parse(e):{}}catch(e){return console.error("WebStore.getAll 失败:",e),{}}},t.remove=function(e){try{var 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}},t.clear=function(){try{this.getStore().removeItem(this.storageKey)}catch(e){throw console.error("WebStore.clear 失败:",e),e}},t.setMultiple=function(e){try{var t=f({},this.getAll(),e);this.getStore().setItem(this.storageKey,JSON.stringify(t))}catch(e){throw console.error("WebStore.setMultiple 失败:",e),e}},t.onChanged=function(e){var t=this;window.addEventListener("storage",function(r){if(r.key===t.storageKey&&r.storageArea===t.getStore()){var n,o=((n={})[t.storageKey]={oldValue:r.oldValue?JSON.parse(r.oldValue):void 0,newValue:r.newValue?JSON.parse(r.newValue):void 0},n);e(o)}})},t.has=function(e){try{return void 0!==this.get(e)}catch(e){return console.error("WebStore.has 失败:",e),!1}},t.getSize=function(){try{var e=this.getStore().getItem(this.storageKey)||"";return new Blob([e]).size}catch(e){return console.error("WebStore.getSize 失败:",e),0}},t.getStoreKey=function(){return this.storageKey},e}();function S(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}w.instances=new Map;var b=/*#__PURE__*/function(){function e(e,t){void 0===t&&(t="local"),this.storageKey=void 0,this.storeType=void 0,this.store=void 0,this.storageKey=e,this.storeType=t}e.getInstanceKey=function(e,t){return void 0===t&&(t="local"),t+":"+e},e.getInstance=function(t,r){void 0===r&&(r="local");var n=this.getInstanceKey(t,r);return this.instances.has(n)||this.instances.set(n,new e(t,r)),this.instances.get(n)},e.local=function(e){return this.getInstance(e,"local")},e.sync=function(e){return this.getInstance(e,"sync")},e.clearInstance=function(e,t){void 0===t&&(t="local");var r=this.getInstanceKey(e,t);this.instances.delete(r)},e.clearAllInstances=function(){this.instances.clear()};var t=e.prototype;return t.getStore=function(){return this.store||(this.store=chrome.storage[this.storeType]),this.store},t.set=function(e,t){try{var r=this;return Promise.resolve(S(function(){return Promise.resolve(r.getAll()).then(function(n){var o,i,s=f({},n,((o={})[e]=t,o));return Promise.resolve(r.getStore().set((i={},i[r.storageKey]=s,i))).then(function(){})})},function(e){throw console.error("ChromeStore.set 失败:",e),e}))}catch(e){return Promise.reject(e)}},t.get=function(e){try{var t=this;return Promise.resolve(S(function(){return Promise.resolve(t.getAll()).then(function(t){return null==t?void 0:t[e]})},function(e){throw console.error("ChromeStore.get 失败:",e),e}))}catch(e){return Promise.reject(e)}},t.getAll=function(){try{var e=this;return Promise.resolve(S(function(){return Promise.resolve(e.getStore().get(e.storageKey)).then(function(t){return t[e.storageKey]||{}})},function(e){throw console.error("ChromeStore.getAll 失败:",e),e}))}catch(e){return Promise.reject(e)}},t.remove=function(e){try{var t=this;return Promise.resolve(S(function(){return Promise.resolve(t.getAll()).then(function(r){var n=function(){var n;if(r&&e in r)return delete r[e],Promise.resolve(t.getStore().set((n={},n[t.storageKey]=r,n))).then(function(){})}();if(n&&n.then)return n.then(function(){})})},function(e){throw console.error("ChromeStore.remove 失败:",e),e}))}catch(e){return Promise.reject(e)}},t.clear=function(){try{var e=this;return Promise.resolve(S(function(){return Promise.resolve(e.getStore().remove(e.storageKey)).then(function(){})},function(e){throw console.error("ChromeStore.clear 失败:",e),e}))}catch(e){return Promise.reject(e)}},t.setMultiple=function(e){try{var t=this;return Promise.resolve(S(function(){return Promise.resolve(t.getAll()).then(function(r){var n,o=f({},r,e);return Promise.resolve(t.getStore().set((n={},n[t.storageKey]=o,n))).then(function(){})})},function(e){throw console.error("ChromeStore.setMultiple 失败:",e),e}))}catch(e){return Promise.reject(e)}},t.onChanged=function(e){var t=this;chrome.storage.onChanged.addListener(function(r,n){n===t.storeType&&r[t.storageKey]&&e(r)})},t.has=function(e){try{var t=this;return Promise.resolve(S(function(){return Promise.resolve(t.get(e)).then(function(e){return void 0!==e})},function(e){return console.error("ChromeStore.has 失败:",e),!1}))}catch(e){return Promise.reject(e)}},t.getSize=function(){try{var e=this;return Promise.resolve(S(function(){return Promise.resolve(e.getAll()).then(function(e){var t=JSON.stringify(e);return new Blob([t]).size})},function(e){return console.error("ChromeStore.getSize 失败:",e),0}))}catch(e){return Promise.reject(e)}},t.getStoreKey=function(){return this.storageKey},e}();b.instances=new Map;var P="https://www.linkedin.com/voyager/api";function x(e,t){var r={"csrf-token":e};return t&&"string"==typeof t&&(r.Cookie=t),r}exports.ChromeStore=b,exports.Draggable=y,exports.MemoryStore=d,exports.RealUndefined=e,exports.WebStore=w,exports.cacheWrapper=function(e,t){void 0===t&&(t=u);var r=function(){var r=[].slice.call(arguments),i=n(r)+e.name+(t.identifier||"");if(l(i))return Promise.resolve(o(c(i)));if(a[i]){var h=Object.assign({},u,t);return new Promise(function(e){var t=Date.now(),r=setInterval(function(){l(i)?(clearInterval(r),e(o(c(i)))):Date.now()-t>h.timeout&&(a[i]=!1,clearInterval(r),e(o(h.timeoutResult)))},100)})}return a[i]=!0,e.apply(this,r).then(function(e){return s[i]=e,o(s[i])}).catch(function(e){throw e}).finally(function(){a[i]=!1})};return Object.defineProperty(r,"name",{value:"cacheWrapper_"+e.name,configurable:!0}),r},exports.cloneDeep=o,exports.createDefaultObject=i,exports.createElement=function e(t){var r=void 0===t?{}:t,n=r.tag,o=r.children,i=void 0===o?[]:o,s=r.props,a=void 0===s?{}:s,c=r.attrs,l=void 0===c?{}:c,u=r.styles,f=void 0===u?{}:u,d=document.createElement(void 0===n?"div":n);Object.assign(d,a);for(var v=0,m=Object.entries(l);v<m.length;v++){var p=m[v],y=p[1];!1!==y&&d.setAttribute(p[0],y)}for(var w=0,S=Object.entries(f);w<S.length;w++){var b=S[w];g(d,b[0],b[1])}for(var P,x=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,t){if(e){if("string"==typeof e)return h(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?h(e,t):void 0}}(e))){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(Array.isArray(i)?i:[i]);!(P=x()).done;){var C=P.value;C&&("object"==typeof C?C instanceof Element?d.appendChild(C):d.appendChild(e(C)):d.appendChild(document.createTextNode(C)))}return d},exports.createSvg=function(e){return"string"==typeof e?m(e):v(e)},exports.createSvgFromUrl=function(e){try{return Promise.resolve(function(t,r){try{var n=Promise.resolve(fetch(e)).then(function(e){if(!e.ok)throw new Error("网络请求失败: "+e.status+" "+e.statusText);return Promise.resolve(e.text()).then(m)})}catch(e){return r(e)}return n&&n.then?n.then(void 0,r):n}(0,function(e){var t=e instanceof Error?e.message:"未知错误";throw new Error("无法创建 SVG 元素: "+t)}))}catch(e){return Promise.reject(e)}},exports.debounce=function(e,t){var r=null;return function(){var n=arguments,o=this;null!==r&&clearTimeout(r),r=setTimeout(function(){e.apply(o,[].slice.call(n)),r=null},t)}},exports.decodeJWT=function(e){var t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),r=decodeURIComponent(atob(t).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(r)},exports.delayExecution=function(e,t){void 0===t&&(t=0);var r=[].slice.call(arguments,2);return new Promise(function(n){0===t?n(e.apply(void 0,r)):setTimeout(function(){n(e.apply(void 0,r))},t)})},exports.generateStableUniqueKey=n,exports.getGlobal=function(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this},exports.getLinkedinCompany=function(e,t){var r=t.csrfToken,n=t.cookies;try{var o="urn"in e,i=P+"/organization/companies";i+=o?"/"+e.urn:"?q=universalName&universalName="+e.universalName;var s=x(r,n);return Promise.resolve(fetch(i,{method:"GET",headers:s}).then(function(e){try{var t,r=function(){if(e.ok)return Promise.resolve(e.json()).then(function(e){if(o)return t=1,e;var r,n=(null==(r=e.elements)?void 0:r[0])||null;return t=1,n})}();return Promise.resolve(r&&r.then?r.then(function(e){return t?e:null}):t?r:null)}catch(e){return Promise.reject(e)}}).catch(function(e){return console.error(e),null}))}catch(e){return Promise.reject(e)}},exports.getLinkedinProfile=function(e,t){var r=t.csrfToken,n=t.cookies;try{var o=P+"/identity/dash/profiles?q=memberIdentity&memberIdentity="+e+"&decorationId=com.linkedin.voyager.dash.deco.identity.profile.FullProfileWithEntities-26",i=x(r,n);return Promise.resolve(fetch(o,{method:"GET",headers:i}).then(function(e){try{var t,r=function(){if(e.ok)return Promise.resolve(e.json()).then(function(e){var r,n=(null==(r=e.elements)?void 0:r[0])||null;return t=1,n})}();return Promise.resolve(r&&r.then?r.then(function(e){return t?e:null}):t?r:null)}catch(e){return Promise.reject(e)}}).catch(function(e){return console.error(e),null}))}catch(e){return Promise.reject(e)}},exports.isCloneable=t,exports.isPrimitive=r,exports.launchWebAuthFlow=function(e){var t=e.clientId,r=e.responseType,n=void 0===r?"code":r,o=e.state,i=e.nonce,s=e.interactive,a=void 0===s||s;try{var c=chrome.identity.getRedirectURL(),l=Array.isArray(n)?n:[n],u=new URL("https://accounts.google.com/o/oauth2/v2/auth");return u.searchParams.set("client_id",t),u.searchParams.set("redirect_uri",c),u.searchParams.set("response_type",l.join(" ")),u.searchParams.set("scope","openid email profile"),i&&u.searchParams.set("nonce",i),o&&u.searchParams.set("state",o),Promise.resolve(chrome.identity.launchWebAuthFlow({url:u.toString(),interactive:a}).then(function(e){if(!e)return Promise.reject(new Error("redirectUrl is null"));var t=e.includes("?")?"?":"#",r=new URLSearchParams(e.split(t)[1]),n={};return r.forEach(function(e,t){n[t]=e}),n}).catch(function(e){return console.log("error",e),Promise.reject(e)}))}catch(e){return Promise.reject(e)}},exports.scrollToBottom=p,exports.scrollToBottomIfNeeded=function(e){e&&("true"!==e.dataset.isListeningForUserScroll&&(function(e){e&&e.addEventListener("scroll",function(){!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&&p(e))},exports.singleExecutionWrapper=function(t,r){void 0===r&&(r=0);var n=function(){if(n.isExecuting)return Promise.resolve(e);n.isExecuting=!0;var o=performance.now(),i=t.apply(this,[].slice.call(arguments));return i.finally(function(){var e=performance.now()-o;r&&r>e?setTimeout(function(){n.isExecuting=!1},r-e):n.isExecuting=!1}),i};return n.isExecuting=!1,n};
2
2
  //# sourceMappingURL=index.cjs.map