@glodon-aiot/chat-app-sdk 0.0.18 → 0.0.19
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/es/index.esm.js +468 -355
- package/libs/cn/index.js +15 -15
- package/package.json +2 -2
package/es/index.esm.js
CHANGED
|
@@ -121196,229 +121196,6 @@ const getApiUrl = function(customApiUrl) {
|
|
|
121196
121196
|
return customApiUrl || chat_ApiUrl[env] || defaultApiUrl;
|
|
121197
121197
|
};
|
|
121198
121198
|
|
|
121199
|
-
// EXTERNAL MODULE: ../../../../../common/temp/default/node_modules/.pnpm/react@18.2.0/node_modules/react/index.js
|
|
121200
|
-
var react = __webpack_require__(12957);
|
|
121201
|
-
;// CONCATENATED MODULE: ./src/util/webcomponent-adapter.tsx
|
|
121202
|
-
/*
|
|
121203
|
-
* Copyright 2025 coze-dev Authors
|
|
121204
|
-
*
|
|
121205
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
121206
|
-
* you may not use this file except in compliance with the License.
|
|
121207
|
-
* You may obtain a copy of the License at
|
|
121208
|
-
*
|
|
121209
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
121210
|
-
*
|
|
121211
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
121212
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
121213
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
121214
|
-
* See the License for the specific language governing permissions and
|
|
121215
|
-
* limitations under the License.
|
|
121216
|
-
*/
|
|
121217
|
-
|
|
121218
|
-
/**
|
|
121219
|
-
* 组件包装器缓存
|
|
121220
|
-
* 改进:避免重复创建相同 tagName 的包装器组件
|
|
121221
|
-
*/ const wrapperCache = new Map();
|
|
121222
|
-
/**
|
|
121223
|
-
* 将对象转换为 Web Component 的属性
|
|
121224
|
-
* 改进:处理 null、undefined、数组等特殊情况,添加错误处理
|
|
121225
|
-
*/ function setWebComponentProps(element, props) {
|
|
121226
|
-
Object.entries(props).forEach((param)=>{
|
|
121227
|
-
let [key, value] = param;
|
|
121228
|
-
try {
|
|
121229
|
-
// 跳过 undefined
|
|
121230
|
-
if (value === undefined) {
|
|
121231
|
-
return;
|
|
121232
|
-
}
|
|
121233
|
-
// null 设置为空字符串
|
|
121234
|
-
if (value === null) {
|
|
121235
|
-
element.setAttribute(key, '');
|
|
121236
|
-
return;
|
|
121237
|
-
}
|
|
121238
|
-
// 复杂对象(包括数组)设置为属性
|
|
121239
|
-
if (typeof value === 'object' || Array.isArray(value)) {
|
|
121240
|
-
element[key] = value;
|
|
121241
|
-
} else if (typeof value === 'function') {
|
|
121242
|
-
// 函数类型设置为属性(事件处理器等)
|
|
121243
|
-
element[key] = value;
|
|
121244
|
-
} else {
|
|
121245
|
-
// 基本类型设置为 attribute
|
|
121246
|
-
element.setAttribute(key, String(value));
|
|
121247
|
-
}
|
|
121248
|
-
} catch (error) {
|
|
121249
|
-
console.warn(`[WebComponent] Failed to set property "${key}" on ${element.tagName}:`, error);
|
|
121250
|
-
}
|
|
121251
|
-
});
|
|
121252
|
-
}
|
|
121253
|
-
/**
|
|
121254
|
-
* 创建一个 React 组件包装器,用于渲染 Web Component
|
|
121255
|
-
* 改进:
|
|
121256
|
-
* 1. 使用 React.memo 避免不必要的重渲染
|
|
121257
|
-
* 2. 优化 props 比较,避免无限循环
|
|
121258
|
-
* 3. 添加清理逻辑,防止内存泄漏
|
|
121259
|
-
* 4. 添加缓存机制,提升性能
|
|
121260
|
-
*/ function createWebComponentWrapper(tagName) {
|
|
121261
|
-
// 检查缓存
|
|
121262
|
-
const cachedWrapper = wrapperCache.get(tagName);
|
|
121263
|
-
if (cachedWrapper) {
|
|
121264
|
-
return cachedWrapper;
|
|
121265
|
-
}
|
|
121266
|
-
const WrapperComponent = /*#__PURE__*/ react.memo((props)=>{
|
|
121267
|
-
const elementRef = (0,react.useRef)(null);
|
|
121268
|
-
const propsRef = (0,react.useRef)(props);
|
|
121269
|
-
const cleanupRef = (0,react.useRef)(null);
|
|
121270
|
-
const isInitialMountRef = (0,react.useRef)(true);
|
|
121271
|
-
// 使用 useMemo 进行深度比较,避免每次都触发更新
|
|
121272
|
-
const propsChanged = (0,react.useMemo)(()=>{
|
|
121273
|
-
try {
|
|
121274
|
-
return JSON.stringify(propsRef.current) !== JSON.stringify(props);
|
|
121275
|
-
} catch (error) {
|
|
121276
|
-
// JSON.stringify 可能失败(循环引用等),降级为浅比较
|
|
121277
|
-
console.warn('[WebComponent] Failed to compare props:', error);
|
|
121278
|
-
return propsRef.current !== props;
|
|
121279
|
-
}
|
|
121280
|
-
}, [
|
|
121281
|
-
props
|
|
121282
|
-
]);
|
|
121283
|
-
(0,react.useEffect)(()=>{
|
|
121284
|
-
// 首次挂载或 props 变化时,都需要调用 updateProps
|
|
121285
|
-
const shouldUpdate = isInitialMountRef.current || propsChanged && elementRef.current;
|
|
121286
|
-
if (shouldUpdate && elementRef.current) {
|
|
121287
|
-
if (isInitialMountRef.current) {
|
|
121288
|
-
isInitialMountRef.current = false;
|
|
121289
|
-
}
|
|
121290
|
-
propsRef.current = props;
|
|
121291
|
-
// 设置属性
|
|
121292
|
-
setWebComponentProps(elementRef.current, props);
|
|
121293
|
-
// 如果 Web Component 定义了更新方法,调用它
|
|
121294
|
-
const customElement = elementRef.current;
|
|
121295
|
-
if (typeof customElement.updateProps === 'function') {
|
|
121296
|
-
try {
|
|
121297
|
-
customElement.updateProps(props);
|
|
121298
|
-
} catch (error) {
|
|
121299
|
-
console.error(`[WebComponent] Error calling updateProps on ${tagName}:`, error);
|
|
121300
|
-
}
|
|
121301
|
-
}
|
|
121302
|
-
// 保存清理函数
|
|
121303
|
-
if (typeof customElement.cleanup === 'function') {
|
|
121304
|
-
cleanupRef.current = ()=>{
|
|
121305
|
-
try {
|
|
121306
|
-
var _customElement_cleanup;
|
|
121307
|
-
(_customElement_cleanup = customElement.cleanup) === null || _customElement_cleanup === void 0 ? void 0 : _customElement_cleanup.call(customElement);
|
|
121308
|
-
} catch (error) {
|
|
121309
|
-
console.error(`[WebComponent] Error during cleanup of ${tagName}:`, error);
|
|
121310
|
-
}
|
|
121311
|
-
};
|
|
121312
|
-
}
|
|
121313
|
-
}
|
|
121314
|
-
// 返回清理函数
|
|
121315
|
-
return ()=>{
|
|
121316
|
-
if (cleanupRef.current) {
|
|
121317
|
-
cleanupRef.current();
|
|
121318
|
-
cleanupRef.current = null;
|
|
121319
|
-
}
|
|
121320
|
-
};
|
|
121321
|
-
// tagName 是外部作用域的值,不需要作为依赖项
|
|
121322
|
-
}, [
|
|
121323
|
-
propsChanged,
|
|
121324
|
-
props
|
|
121325
|
-
]);
|
|
121326
|
-
// 使用 React.createElement 创建自定义元素
|
|
121327
|
-
return /*#__PURE__*/ react.createElement(tagName, {
|
|
121328
|
-
ref: elementRef
|
|
121329
|
-
});
|
|
121330
|
-
}, // 自定义比较函数,使用深度比较
|
|
121331
|
-
(prevProps, nextProps)=>{
|
|
121332
|
-
try {
|
|
121333
|
-
return JSON.stringify(prevProps) === JSON.stringify(nextProps);
|
|
121334
|
-
} catch (error) {
|
|
121335
|
-
// JSON.stringify 可能失败(循环引用等),降级为浅比较
|
|
121336
|
-
console.warn('[WebComponent] Failed to compare props in memo:', error);
|
|
121337
|
-
return prevProps === nextProps;
|
|
121338
|
-
}
|
|
121339
|
-
});
|
|
121340
|
-
// 缓存组件(类型安全的 cast)
|
|
121341
|
-
wrapperCache.set(tagName, WrapperComponent);
|
|
121342
|
-
return WrapperComponent;
|
|
121343
|
-
}
|
|
121344
|
-
/**
|
|
121345
|
-
* 支持的 UIKit 组件类型
|
|
121346
|
-
* 改进:使用常量定义,便于扩展和维护
|
|
121347
|
-
* 与 UIKitCustomComponentsMap 保持对齐
|
|
121348
|
-
*/ const SUPPORTED_COMPONENTS = [
|
|
121349
|
-
'JsonItem',
|
|
121350
|
-
'MentionOperateTool',
|
|
121351
|
-
'SendButton',
|
|
121352
|
-
'AvatarWrap'
|
|
121353
|
-
];
|
|
121354
|
-
/**
|
|
121355
|
-
* 将 Web Component 配置转换为 React 组件映射
|
|
121356
|
-
* 改进:
|
|
121357
|
-
* 1. 使用循环处理,避免重复代码
|
|
121358
|
-
* 2. 添加错误处理
|
|
121359
|
-
* 3. 返回类型更明确
|
|
121360
|
-
*/ function adaptWebComponentsToReact(webComponents) {
|
|
121361
|
-
if (!webComponents) {
|
|
121362
|
-
return undefined;
|
|
121363
|
-
}
|
|
121364
|
-
try {
|
|
121365
|
-
const reactComponents = {};
|
|
121366
|
-
// 动态处理所有支持的组件
|
|
121367
|
-
SUPPORTED_COMPONENTS.forEach((componentName)=>{
|
|
121368
|
-
const tagName = webComponents[componentName];
|
|
121369
|
-
if (tagName) {
|
|
121370
|
-
// 验证 Web Component 是否已注册
|
|
121371
|
-
if (!customElements.get(tagName)) {
|
|
121372
|
-
console.warn(`[WebChatClient] Web Component "${tagName}" for ${componentName} is not registered. ` + 'Please register it using customElements.define() before initializing the chat client.');
|
|
121373
|
-
}
|
|
121374
|
-
// 创建包装器组件
|
|
121375
|
-
// 使用类型断言,因为每个组件的 props 类型不同
|
|
121376
|
-
reactComponents[componentName] = createWebComponentWrapper(tagName);
|
|
121377
|
-
}
|
|
121378
|
-
});
|
|
121379
|
-
return Object.keys(reactComponents).length > 0 ? reactComponents : undefined;
|
|
121380
|
-
} catch (error) {
|
|
121381
|
-
console.error('[WebChatClient] Failed to adapt Web Components:', error);
|
|
121382
|
-
return undefined;
|
|
121383
|
-
}
|
|
121384
|
-
}
|
|
121385
|
-
/**
|
|
121386
|
-
* 适配 contentBox Web Component
|
|
121387
|
-
* 改进:添加错误处理和类型安全
|
|
121388
|
-
*/ function adaptContentBoxWebComponent(tagName) {
|
|
121389
|
-
if (!tagName) {
|
|
121390
|
-
return undefined;
|
|
121391
|
-
}
|
|
121392
|
-
try {
|
|
121393
|
-
// 验证 Web Component 是否已注册
|
|
121394
|
-
if (!customElements.get(tagName)) {
|
|
121395
|
-
console.warn(`[WebChatClient] Web Component "${tagName}" is not registered. ` + 'Please register it using customElements.define() before initializing the chat client.');
|
|
121396
|
-
}
|
|
121397
|
-
return createWebComponentWrapper(tagName);
|
|
121398
|
-
} catch (error) {
|
|
121399
|
-
console.error(`[WebChatClient] Failed to adapt contentBox Web Component "${tagName}":`, error);
|
|
121400
|
-
return undefined;
|
|
121401
|
-
}
|
|
121402
|
-
}
|
|
121403
|
-
/**
|
|
121404
|
-
* 检查浏览器是否支持 Web Components
|
|
121405
|
-
*/ function checkWebComponentsSupport() {
|
|
121406
|
-
const missing = [];
|
|
121407
|
-
if (!window.customElements) {
|
|
121408
|
-
missing.push('Custom Elements');
|
|
121409
|
-
}
|
|
121410
|
-
if (!('attachShadow' in Element.prototype)) {
|
|
121411
|
-
missing.push('Shadow DOM');
|
|
121412
|
-
}
|
|
121413
|
-
if (!('content' in document.createElement('template'))) {
|
|
121414
|
-
missing.push('HTML Templates');
|
|
121415
|
-
}
|
|
121416
|
-
return {
|
|
121417
|
-
supported: missing.length === 0,
|
|
121418
|
-
missing
|
|
121419
|
-
};
|
|
121420
|
-
}
|
|
121421
|
-
|
|
121422
121199
|
;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/zustand@4.5.7_@types+react@18.2.37_immer@10.1.3_react@18.2.0/node_modules/zustand/esm/middleware.mjs
|
|
121423
121200
|
const reduxImpl = (reducer, initial) => (set, _get, api) => {
|
|
121424
121201
|
api.dispatch = (action) => {
|
|
@@ -122046,6 +121823,8 @@ var vanilla = (createState) => {
|
|
|
122046
121823
|
|
|
122047
121824
|
|
|
122048
121825
|
|
|
121826
|
+
// EXTERNAL MODULE: ../../../../../common/temp/default/node_modules/.pnpm/react@18.2.0/node_modules/react/index.js
|
|
121827
|
+
var react = __webpack_require__(12957);
|
|
122049
121828
|
// EXTERNAL MODULE: ../../../../../common/temp/default/node_modules/.pnpm/use-sync-external-store@1.6.0_react@18.2.0/node_modules/use-sync-external-store/shim/with-selector.js
|
|
122050
121829
|
var with_selector = __webpack_require__(28394);
|
|
122051
121830
|
;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/zustand@4.5.7_@types+react@18.2.37_immer@10.1.3_react@18.2.0/node_modules/zustand/esm/index.mjs
|
|
@@ -133156,11 +132935,11 @@ function flatRest(func) {
|
|
|
133156
132935
|
* _.pick(object, ['a', 'c']);
|
|
133157
132936
|
* // => { 'a': 1, 'c': 3 }
|
|
133158
132937
|
*/
|
|
133159
|
-
var
|
|
132938
|
+
var pick_pick = _flatRest(function(object, paths) {
|
|
133160
132939
|
return object == null ? {} : _basePick(object, paths);
|
|
133161
132940
|
});
|
|
133162
132941
|
|
|
133163
|
-
/* ESM default export */ const
|
|
132942
|
+
/* ESM default export */ const pick = (pick_pick);
|
|
133164
132943
|
|
|
133165
132944
|
;// CONCATENATED MODULE: ../open-chat/src/types/open.ts
|
|
133166
132945
|
/*
|
|
@@ -133216,12 +132995,12 @@ const getChatConfig = (chatClientId, cozeChatOption)=>{
|
|
|
133216
132995
|
conversation_id: index_browser_nanoid(),
|
|
133217
132996
|
extra,
|
|
133218
132997
|
ui: {
|
|
133219
|
-
base:
|
|
132998
|
+
base: pick((ui === null || ui === void 0 ? void 0 : ui.base) || {}, [
|
|
133220
132999
|
'icon',
|
|
133221
133000
|
'lang',
|
|
133222
133001
|
'layout'
|
|
133223
133002
|
]),
|
|
133224
|
-
chatBot:
|
|
133003
|
+
chatBot: pick((ui === null || ui === void 0 ? void 0 : ui.chatBot) || {}, [
|
|
133225
133004
|
'title',
|
|
133226
133005
|
'uploadable',
|
|
133227
133006
|
'isNeedClearContext',
|
|
@@ -133237,7 +133016,7 @@ const getChatConfig = (chatClientId, cozeChatOption)=>{
|
|
|
133237
133016
|
conversations: ui === null || ui === void 0 ? void 0 : ui.conversations,
|
|
133238
133017
|
showUserInfo: ui === null || ui === void 0 ? void 0 : ui.showUserInfo
|
|
133239
133018
|
},
|
|
133240
|
-
auth:
|
|
133019
|
+
auth: pick(auth || {}, [
|
|
133241
133020
|
'type',
|
|
133242
133021
|
'token'
|
|
133243
133022
|
]),
|
|
@@ -152234,7 +152013,7 @@ var CarouselIndicator_rest = undefined && undefined.__rest || function (s, e) {
|
|
|
152234
152013
|
|
|
152235
152014
|
|
|
152236
152015
|
|
|
152237
|
-
class
|
|
152016
|
+
class CarouselIndicator_CarouselIndicator extends react.PureComponent {
|
|
152238
152017
|
constructor() {
|
|
152239
152018
|
super(...arguments);
|
|
152240
152019
|
this.onIndicatorChange = activeIndex => {
|
|
@@ -152304,7 +152083,7 @@ class CarouselIndicator extends react.PureComponent {
|
|
|
152304
152083
|
}, getDataAttr(restProps)), indicatorContent);
|
|
152305
152084
|
}
|
|
152306
152085
|
}
|
|
152307
|
-
|
|
152086
|
+
CarouselIndicator_CarouselIndicator.propTypes = {
|
|
152308
152087
|
activeKey: (prop_types_default()).number,
|
|
152309
152088
|
className: (prop_types_default()).string,
|
|
152310
152089
|
position: prop_types_default().oneOf(carousel_constants_strings.POSITION_MAP),
|
|
@@ -152316,7 +152095,7 @@ CarouselIndicator.propTypes = {
|
|
|
152316
152095
|
type: prop_types_default().oneOf(carousel_constants_strings.TYPE_MAP),
|
|
152317
152096
|
trigger: prop_types_default().oneOf(carousel_constants_strings.TRIGGER)
|
|
152318
152097
|
};
|
|
152319
|
-
/* ESM default export */ const
|
|
152098
|
+
/* ESM default export */ const CarouselIndicator = (CarouselIndicator_CarouselIndicator);
|
|
152320
152099
|
;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/@douyinfe+semi-icons@2.72.3_react@18.2.0/node_modules/@douyinfe/semi-icons/lib/es/icons/IconChevronLeft.js
|
|
152321
152100
|
|
|
152322
152101
|
|
|
@@ -152574,7 +152353,7 @@ class Carousel extends BaseComponent {
|
|
|
152574
152353
|
if (showIndicator && children.length > 1) {
|
|
152575
152354
|
return /*#__PURE__*/react.createElement("div", {
|
|
152576
152355
|
className: carouselIndicatorCls
|
|
152577
|
-
}, /*#__PURE__*/react.createElement(
|
|
152356
|
+
}, /*#__PURE__*/react.createElement(CarouselIndicator, {
|
|
152578
152357
|
type: indicatorType,
|
|
152579
152358
|
total: children.length,
|
|
152580
152359
|
activeIndex: activeIndex,
|
|
@@ -198123,7 +197902,7 @@ const TableContext = /*#__PURE__*/react.createContext({
|
|
|
198123
197902
|
;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/@douyinfe+semi-ui@2.72.3_react-dom@18.2.0_react@18.2.0/node_modules/@douyinfe/semi-ui/lib/es/table/TableContextProvider.js
|
|
198124
197903
|
|
|
198125
197904
|
|
|
198126
|
-
const
|
|
197905
|
+
const TableContextProvider = _ref => {
|
|
198127
197906
|
let {
|
|
198128
197907
|
children,
|
|
198129
197908
|
anyColumnFixed,
|
|
@@ -198159,7 +197938,7 @@ const TableContextProvider_TableContextProvider = _ref => {
|
|
|
198159
197938
|
value: tableContextValue
|
|
198160
197939
|
}, children);
|
|
198161
197940
|
};
|
|
198162
|
-
/* ESM default export */ const
|
|
197941
|
+
/* ESM default export */ const table_TableContextProvider = (TableContextProvider);
|
|
198163
197942
|
;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/@douyinfe+semi-foundation@2.72.3/node_modules/@douyinfe/semi-foundation/lib/es/table/tableSelectionCellFoundation.js
|
|
198164
197943
|
|
|
198165
197944
|
class TableSelectionCellFoundation extends foundation {
|
|
@@ -202660,7 +202439,7 @@ class Table_Table extends BaseComponent {
|
|
|
202660
202439
|
"data-column-fixed": anyColumnFixed,
|
|
202661
202440
|
style: wrapStyle,
|
|
202662
202441
|
id: id
|
|
202663
|
-
}, dataAttr), /*#__PURE__*/react.createElement(
|
|
202442
|
+
}, dataAttr), /*#__PURE__*/react.createElement(table_TableContextProvider, Object.assign({}, tableContextValue, {
|
|
202664
202443
|
direction: props.direction
|
|
202665
202444
|
}), /*#__PURE__*/react.createElement(es_spin, {
|
|
202666
202445
|
spinning: loading,
|
|
@@ -223811,9 +223590,9 @@ var nativeIsBuffer = isBuffer_Buffer ? isBuffer_Buffer.isBuffer : undefined;
|
|
|
223811
223590
|
* _.isBuffer(new Uint8Array(2));
|
|
223812
223591
|
* // => false
|
|
223813
223592
|
*/
|
|
223814
|
-
var
|
|
223593
|
+
var isBuffer = nativeIsBuffer || lodash_es_stubFalse;
|
|
223815
223594
|
|
|
223816
|
-
/* ESM default export */ const
|
|
223595
|
+
/* ESM default export */ const lodash_es_isBuffer = (isBuffer);
|
|
223817
223596
|
|
|
223818
223597
|
;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isPlainObject.js
|
|
223819
223598
|
|
|
@@ -224014,9 +223793,9 @@ var nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray;
|
|
|
224014
223793
|
* _.isTypedArray([]);
|
|
224015
223794
|
* // => false
|
|
224016
223795
|
*/
|
|
224017
|
-
var
|
|
223796
|
+
var isTypedArray_isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray;
|
|
224018
223797
|
|
|
224019
|
-
/* ESM default export */ const
|
|
223798
|
+
/* ESM default export */ const isTypedArray = (isTypedArray_isTypedArray);
|
|
224020
223799
|
|
|
224021
223800
|
;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_safeGet.js
|
|
224022
223801
|
/**
|
|
@@ -224130,8 +223909,8 @@ var _arrayLikeKeys_hasOwnProperty = _arrayLikeKeys_objectProto.hasOwnProperty;
|
|
|
224130
223909
|
function arrayLikeKeys(value, inherited) {
|
|
224131
223910
|
var isArr = lodash_es_isArray(value),
|
|
224132
223911
|
isArg = !isArr && isArguments(value),
|
|
224133
|
-
isBuff = !isArr && !isArg &&
|
|
224134
|
-
isType = !isArr && !isArg && !isBuff &&
|
|
223912
|
+
isBuff = !isArr && !isArg && lodash_es_isBuffer(value),
|
|
223913
|
+
isType = !isArr && !isArg && !isBuff && isTypedArray(value),
|
|
224135
223914
|
skipIndexes = isArr || isArg || isBuff || isType,
|
|
224136
223915
|
result = skipIndexes ? _baseTimes(value.length, String) : [],
|
|
224137
223916
|
length = result.length;
|
|
@@ -224330,8 +224109,8 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
|
|
|
224330
224109
|
|
|
224331
224110
|
if (isCommon) {
|
|
224332
224111
|
var isArr = lodash_es_isArray(srcValue),
|
|
224333
|
-
isBuff = !isArr &&
|
|
224334
|
-
isTyped = !isArr && !isBuff &&
|
|
224112
|
+
isBuff = !isArr && lodash_es_isBuffer(srcValue),
|
|
224113
|
+
isTyped = !isArr && !isBuff && isTypedArray(srcValue);
|
|
224335
224114
|
|
|
224336
224115
|
newValue = srcValue;
|
|
224337
224116
|
if (isArr || isBuff || isTyped) {
|
|
@@ -224606,14 +224385,14 @@ function useMemoizedFn_useMemoizedFn(fn) {
|
|
|
224606
224385
|
;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/ahooks@3.7.8_patch_hash=sa4ddrxdk2yhjzudeck6u5ww3i_react@18.2.0/node_modules/ahooks/es/useUpdate/index.js
|
|
224607
224386
|
|
|
224608
224387
|
|
|
224609
|
-
var
|
|
224388
|
+
var useUpdate = function () {
|
|
224610
224389
|
var _a = __read((0,react.useState)({}), 2),
|
|
224611
224390
|
setState = _a[1];
|
|
224612
224391
|
return (0,react.useCallback)(function () {
|
|
224613
224392
|
return setState({});
|
|
224614
224393
|
}, []);
|
|
224615
224394
|
};
|
|
224616
|
-
/* ESM default export */ const
|
|
224395
|
+
/* ESM default export */ const es_useUpdate = (useUpdate);
|
|
224617
224396
|
;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/ahooks@3.7.8_patch_hash=sa4ddrxdk2yhjzudeck6u5ww3i_react@18.2.0/node_modules/ahooks/es/useControllableValue/index.js
|
|
224618
224397
|
|
|
224619
224398
|
|
|
@@ -224649,7 +224428,7 @@ function useControllableValue_useControllableValue(props, options) {
|
|
|
224649
224428
|
if (isControlled) {
|
|
224650
224429
|
stateRef.current = value;
|
|
224651
224430
|
}
|
|
224652
|
-
var update =
|
|
224431
|
+
var update = es_useUpdate();
|
|
224653
224432
|
function setState(v) {
|
|
224654
224433
|
var args = [];
|
|
224655
224434
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
@@ -245967,8 +245746,8 @@ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
|
|
|
245967
245746
|
othIsObj = othTag == _baseIsEqualDeep_objectTag,
|
|
245968
245747
|
isSameTag = objTag == othTag;
|
|
245969
245748
|
|
|
245970
|
-
if (isSameTag &&
|
|
245971
|
-
if (!
|
|
245749
|
+
if (isSameTag && lodash_es_isBuffer(object)) {
|
|
245750
|
+
if (!lodash_es_isBuffer(other)) {
|
|
245972
245751
|
return false;
|
|
245973
245752
|
}
|
|
245974
245753
|
objIsArr = true;
|
|
@@ -245976,7 +245755,7 @@ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
|
|
|
245976
245755
|
}
|
|
245977
245756
|
if (isSameTag && !objIsObj) {
|
|
245978
245757
|
stack || (stack = new _Stack);
|
|
245979
|
-
return (objIsArr ||
|
|
245758
|
+
return (objIsArr || isTypedArray(object))
|
|
245980
245759
|
? _equalArrays(object, other, bitmask, customizer, equalFunc, stack)
|
|
245981
245760
|
: _equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
|
|
245982
245761
|
}
|
|
@@ -251224,7 +251003,7 @@ function baseClone(value, bitmask, customizer, key, object, stack) {
|
|
|
251224
251003
|
var tag = _getTag(value),
|
|
251225
251004
|
isFunc = tag == _baseClone_funcTag || tag == _baseClone_genTag;
|
|
251226
251005
|
|
|
251227
|
-
if (
|
|
251006
|
+
if (lodash_es_isBuffer(value)) {
|
|
251228
251007
|
return _cloneBuffer(value, isDeep);
|
|
251229
251008
|
}
|
|
251230
251009
|
if (tag == _baseClone_objectTag || tag == _baseClone_argsTag || (isFunc && !object)) {
|
|
@@ -251451,12 +251230,12 @@ var omit_omit = _flatRest(function(object, paths) {
|
|
|
251451
251230
|
|
|
251452
251231
|
;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/ahooks@3.7.8_patch_hash=sa4ddrxdk2yhjzudeck6u5ww3i_react@18.2.0/node_modules/ahooks/es/useLatest/index.js
|
|
251453
251232
|
|
|
251454
|
-
function
|
|
251233
|
+
function useLatest(value) {
|
|
251455
251234
|
var ref = (0,react.useRef)(value);
|
|
251456
251235
|
ref.current = value;
|
|
251457
251236
|
return ref;
|
|
251458
251237
|
}
|
|
251459
|
-
/* ESM default export */ const
|
|
251238
|
+
/* ESM default export */ const es_useLatest = (useLatest);
|
|
251460
251239
|
;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/ahooks@3.7.8_patch_hash=sa4ddrxdk2yhjzudeck6u5ww3i_react@18.2.0/node_modules/ahooks/es/useUnmount/index.js
|
|
251461
251240
|
|
|
251462
251241
|
|
|
@@ -251468,7 +251247,7 @@ var useUnmount_useUnmount = function (fn) {
|
|
|
251468
251247
|
console.error("useUnmount expected parameter is a function, got ".concat(typeof fn));
|
|
251469
251248
|
}
|
|
251470
251249
|
}
|
|
251471
|
-
var fnRef =
|
|
251250
|
+
var fnRef = es_useLatest(fn);
|
|
251472
251251
|
(0,react.useEffect)(function () {
|
|
251473
251252
|
return function () {
|
|
251474
251253
|
fnRef.current();
|
|
@@ -251582,8 +251361,8 @@ var useLayoutEffectWithTarget_useEffectWithTarget = utils_createEffectWithTarget
|
|
|
251582
251361
|
|
|
251583
251362
|
|
|
251584
251363
|
|
|
251585
|
-
var
|
|
251586
|
-
/* ESM default export */ const
|
|
251364
|
+
var useIsomorphicLayoutEffectWithTarget_useIsomorphicLayoutEffectWithTarget = utils_isBrowser ? useLayoutEffectWithTarget : utils_useEffectWithTarget;
|
|
251365
|
+
/* ESM default export */ const useIsomorphicLayoutEffectWithTarget = (useIsomorphicLayoutEffectWithTarget_useIsomorphicLayoutEffectWithTarget);
|
|
251587
251366
|
;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/ahooks@3.7.8_patch_hash=sa4ddrxdk2yhjzudeck6u5ww3i_react@18.2.0/node_modules/ahooks/es/useSize/index.js
|
|
251588
251367
|
|
|
251589
251368
|
|
|
@@ -251600,7 +251379,7 @@ function useSize(target) {
|
|
|
251600
251379
|
}), 2),
|
|
251601
251380
|
state = _a[0],
|
|
251602
251381
|
setState = _a[1];
|
|
251603
|
-
|
|
251382
|
+
useIsomorphicLayoutEffectWithTarget(function () {
|
|
251604
251383
|
var el = getTargetElement(target);
|
|
251605
251384
|
if (!el) {
|
|
251606
251385
|
return;
|
|
@@ -253304,7 +253083,7 @@ function withFormApi_withFormApi(Component) {
|
|
|
253304
253083
|
;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/@douyinfe+semi-ui@2.72.3_react-dom@18.2.0_react@18.2.0/node_modules/@douyinfe/semi-ui/lib/es/form/hoc/withFormState.js
|
|
253305
253084
|
|
|
253306
253085
|
|
|
253307
|
-
function
|
|
253086
|
+
function withFormState(Component) {
|
|
253308
253087
|
let WithStateCom = (props, ref) => {
|
|
253309
253088
|
return /*#__PURE__*/react.createElement(FormStateContext.Consumer, null, formState => /*#__PURE__*/react.createElement(Component, Object.assign({
|
|
253310
253089
|
formState: formState,
|
|
@@ -253314,7 +253093,7 @@ function withFormState_withFormState(Component) {
|
|
|
253314
253093
|
WithStateCom = /*#__PURE__*/(0,react.forwardRef)(WithStateCom);
|
|
253315
253094
|
return WithStateCom;
|
|
253316
253095
|
}
|
|
253317
|
-
/* ESM default export */ const
|
|
253096
|
+
/* ESM default export */ const hoc_withFormState = (withFormState);
|
|
253318
253097
|
;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/@coze-arch+coze-design@0.0.6-alpha.eec92c_@types+react@18.2.37_react-dom@18.2.0_react@18.2.0/node_modules/@coze-arch/coze-design/dist/esm/components/semi/index.mjs
|
|
253319
253098
|
|
|
253320
253099
|
|
|
@@ -253410,7 +253189,7 @@ var __webpack_exports__useFormApi = useFormApi;
|
|
|
253410
253189
|
var __webpack_exports__useFormState = useFormState;
|
|
253411
253190
|
var __webpack_exports__withField = hoc_withField;
|
|
253412
253191
|
var __webpack_exports__withFormApi = withFormApi;
|
|
253413
|
-
var __webpack_exports__withFormState =
|
|
253192
|
+
var __webpack_exports__withFormState = hoc_withFormState;
|
|
253414
253193
|
|
|
253415
253194
|
|
|
253416
253195
|
// EXTERNAL MODULE: ../../../../../common/temp/default/node_modules/.pnpm/css-loader@6.11.0_@rspack+core@1.5.8_webpack@5.91.0/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[9].use[1]!../../../../../common/temp/default/node_modules/.pnpm/postcss-loader@7.3.4_postcss@8.5.6_typescript@5.8.2_webpack@5.91.0/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[9].use[2]!../../../../../common/temp/default/node_modules/.pnpm/@coze-arch+coze-design@0.0.6-alpha.eec92c_@types+react@18.2.37_react-dom@18.2.0_react@18.2.0/node_modules/@coze-arch/coze-design/dist/esm/components/table/index.css
|
|
@@ -254284,7 +254063,7 @@ var toFinite_INFINITY = 1 / 0,
|
|
|
254284
254063
|
* _.toFinite('3.2');
|
|
254285
254064
|
* // => 3.2
|
|
254286
254065
|
*/
|
|
254287
|
-
function
|
|
254066
|
+
function toFinite_toFinite(value) {
|
|
254288
254067
|
if (!value) {
|
|
254289
254068
|
return value === 0 ? value : 0;
|
|
254290
254069
|
}
|
|
@@ -254296,7 +254075,7 @@ function toFinite(value) {
|
|
|
254296
254075
|
return value === value ? value : 0;
|
|
254297
254076
|
}
|
|
254298
254077
|
|
|
254299
|
-
/* ESM default export */ const
|
|
254078
|
+
/* ESM default export */ const toFinite = (toFinite_toFinite);
|
|
254300
254079
|
|
|
254301
254080
|
;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_createRange.js
|
|
254302
254081
|
|
|
@@ -254316,14 +254095,14 @@ function createRange(fromRight) {
|
|
|
254316
254095
|
end = step = undefined;
|
|
254317
254096
|
}
|
|
254318
254097
|
// Ensure the sign of `-0` is preserved.
|
|
254319
|
-
start =
|
|
254098
|
+
start = toFinite(start);
|
|
254320
254099
|
if (end === undefined) {
|
|
254321
254100
|
end = start;
|
|
254322
254101
|
start = 0;
|
|
254323
254102
|
} else {
|
|
254324
|
-
end =
|
|
254103
|
+
end = toFinite(end);
|
|
254325
254104
|
}
|
|
254326
|
-
step = step === undefined ? (start < end ? 1 : -1) :
|
|
254105
|
+
step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
|
|
254327
254106
|
return _baseRange(start, end, step, fromRight);
|
|
254328
254107
|
};
|
|
254329
254108
|
}
|
|
@@ -259469,14 +259248,14 @@ var esm_webpack_exports_zhCN = __webpack_exports__zhCN;
|
|
|
259469
259248
|
|
|
259470
259249
|
|
|
259471
259250
|
|
|
259472
|
-
function
|
|
259251
|
+
function useThrottleFn(fn, options) {
|
|
259473
259252
|
var _a;
|
|
259474
259253
|
if (isDev) {
|
|
259475
259254
|
if (!utils_isFunction(fn)) {
|
|
259476
259255
|
console.error("useThrottleFn expected parameter is a function, got ".concat(typeof fn));
|
|
259477
259256
|
}
|
|
259478
259257
|
}
|
|
259479
|
-
var fnRef =
|
|
259258
|
+
var fnRef = es_useLatest(fn);
|
|
259480
259259
|
var wait = (_a = options === null || options === void 0 ? void 0 : options.wait) !== null && _a !== void 0 ? _a : 1000;
|
|
259481
259260
|
var throttled = (0,react.useMemo)(function () {
|
|
259482
259261
|
return throttle_default()(function () {
|
|
@@ -259496,7 +259275,7 @@ function useThrottleFn_useThrottleFn(fn, options) {
|
|
|
259496
259275
|
flush: throttled.flush
|
|
259497
259276
|
};
|
|
259498
259277
|
}
|
|
259499
|
-
/* ESM default export */ const
|
|
259278
|
+
/* ESM default export */ const es_useThrottleFn = (useThrottleFn);
|
|
259500
259279
|
;// CONCATENATED MODULE: ../../../common/chat-area/chat-uikit/src/components/chat/audio-record/audio-wave/utils.ts
|
|
259501
259280
|
/*
|
|
259502
259281
|
* Copyright 2025 coze-dev Authors
|
|
@@ -259711,7 +259490,7 @@ const AudioRecord = /*#__PURE__*/ (0,react.forwardRef)((param, ref)=>{
|
|
|
259711
259490
|
let { isRecording, getVolume, isPointerMoveOut, layout, text } = param;
|
|
259712
259491
|
const [volumeNumber, setVolumeNumber] = (0,react.useState)(0);
|
|
259713
259492
|
const animationIdRef = (0,react.useRef)(null);
|
|
259714
|
-
const { run, flush } =
|
|
259493
|
+
const { run, flush } = es_useThrottleFn(()=>{
|
|
259715
259494
|
setVolumeNumber((getVolume === null || getVolume === void 0 ? void 0 : getVolume()) ?? 0);
|
|
259716
259495
|
animationIdRef.current = requestAnimationFrame(run);
|
|
259717
259496
|
}, {
|
|
@@ -260573,7 +260352,7 @@ const isIterable = (thing) => thing != null && lib_utils_isFunction(thing[utils_
|
|
|
260573
260352
|
*
|
|
260574
260353
|
* @returns {Error} The created error.
|
|
260575
260354
|
*/
|
|
260576
|
-
function
|
|
260355
|
+
function AxiosError(message, code, config, request, response) {
|
|
260577
260356
|
Error.call(this);
|
|
260578
260357
|
|
|
260579
260358
|
if (Error.captureStackTrace) {
|
|
@@ -260593,7 +260372,7 @@ function AxiosError_AxiosError(message, code, config, request, response) {
|
|
|
260593
260372
|
}
|
|
260594
260373
|
}
|
|
260595
260374
|
|
|
260596
|
-
utils.inherits(
|
|
260375
|
+
utils.inherits(AxiosError, Error, {
|
|
260597
260376
|
toJSON: function toJSON() {
|
|
260598
260377
|
return {
|
|
260599
260378
|
// Standard
|
|
@@ -260615,7 +260394,7 @@ utils.inherits(AxiosError_AxiosError, Error, {
|
|
|
260615
260394
|
}
|
|
260616
260395
|
});
|
|
260617
260396
|
|
|
260618
|
-
const AxiosError_prototype =
|
|
260397
|
+
const AxiosError_prototype = AxiosError.prototype;
|
|
260619
260398
|
const AxiosError_descriptors = {};
|
|
260620
260399
|
|
|
260621
260400
|
[
|
|
@@ -260636,11 +260415,11 @@ const AxiosError_descriptors = {};
|
|
|
260636
260415
|
AxiosError_descriptors[code] = {value: code};
|
|
260637
260416
|
});
|
|
260638
260417
|
|
|
260639
|
-
Object.defineProperties(
|
|
260418
|
+
Object.defineProperties(AxiosError, AxiosError_descriptors);
|
|
260640
260419
|
Object.defineProperty(AxiosError_prototype, 'isAxiosError', {value: true});
|
|
260641
260420
|
|
|
260642
260421
|
// eslint-disable-next-line func-names
|
|
260643
|
-
|
|
260422
|
+
AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
260644
260423
|
const axiosError = Object.create(AxiosError_prototype);
|
|
260645
260424
|
|
|
260646
260425
|
utils.toFlatObject(error, axiosError, function filter(obj) {
|
|
@@ -260653,7 +260432,7 @@ AxiosError_AxiosError.from = (error, code, config, request, response, customProp
|
|
|
260653
260432
|
|
|
260654
260433
|
// Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
|
|
260655
260434
|
const errCode = code == null && error ? error.code : code;
|
|
260656
|
-
|
|
260435
|
+
AxiosError.call(axiosError, msg, errCode, config, request, response);
|
|
260657
260436
|
|
|
260658
260437
|
// Chain the original error on the standard field; non-enumerable to avoid JSON noise
|
|
260659
260438
|
if (error && axiosError.cause == null) {
|
|
@@ -260667,7 +260446,7 @@ AxiosError_AxiosError.from = (error, code, config, request, response, customProp
|
|
|
260667
260446
|
return axiosError;
|
|
260668
260447
|
};
|
|
260669
260448
|
|
|
260670
|
-
/* ESM default export */ const
|
|
260449
|
+
/* ESM default export */ const core_AxiosError = (AxiosError);
|
|
260671
260450
|
|
|
260672
260451
|
;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/axios@1.12.2_debug@4.3.3/node_modules/axios/lib/helpers/null.js
|
|
260673
260452
|
// eslint-disable-next-line strict
|
|
@@ -260801,7 +260580,7 @@ function toFormData(obj, formData, options) {
|
|
|
260801
260580
|
}
|
|
260802
260581
|
|
|
260803
260582
|
if (!useBlob && utils.isBlob(value)) {
|
|
260804
|
-
throw new
|
|
260583
|
+
throw new core_AxiosError('Blob is not supported. Use a Buffer instead.');
|
|
260805
260584
|
}
|
|
260806
260585
|
|
|
260807
260586
|
if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
|
|
@@ -261432,7 +261211,7 @@ const defaults_defaults = {
|
|
|
261432
261211
|
} catch (e) {
|
|
261433
261212
|
if (strictJSONParsing) {
|
|
261434
261213
|
if (e.name === 'SyntaxError') {
|
|
261435
|
-
throw
|
|
261214
|
+
throw core_AxiosError.from(e, core_AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
|
261436
261215
|
}
|
|
261437
261216
|
throw e;
|
|
261438
261217
|
}
|
|
@@ -261904,11 +261683,11 @@ function isCancel(value) {
|
|
|
261904
261683
|
*/
|
|
261905
261684
|
function CanceledError(message, config, request) {
|
|
261906
261685
|
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
261907
|
-
|
|
261686
|
+
core_AxiosError.call(this, message == null ? 'canceled' : message, core_AxiosError.ERR_CANCELED, config, request);
|
|
261908
261687
|
this.name = 'CanceledError';
|
|
261909
261688
|
}
|
|
261910
261689
|
|
|
261911
|
-
utils.inherits(CanceledError,
|
|
261690
|
+
utils.inherits(CanceledError, core_AxiosError, {
|
|
261912
261691
|
__CANCEL__: true
|
|
261913
261692
|
});
|
|
261914
261693
|
|
|
@@ -261933,9 +261712,9 @@ function settle_settle(resolve, reject, response) {
|
|
|
261933
261712
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
261934
261713
|
resolve(response);
|
|
261935
261714
|
} else {
|
|
261936
|
-
reject(new
|
|
261715
|
+
reject(new core_AxiosError(
|
|
261937
261716
|
'Request failed with status code ' + response.status,
|
|
261938
|
-
[
|
|
261717
|
+
[core_AxiosError.ERR_BAD_REQUEST, core_AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
|
261939
261718
|
response.config,
|
|
261940
261719
|
response.request,
|
|
261941
261720
|
response
|
|
@@ -262489,7 +262268,7 @@ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
|
|
262489
262268
|
return;
|
|
262490
262269
|
}
|
|
262491
262270
|
|
|
262492
|
-
reject(new
|
|
262271
|
+
reject(new core_AxiosError('Request aborted', core_AxiosError.ECONNABORTED, config, request));
|
|
262493
262272
|
|
|
262494
262273
|
// Clean up request
|
|
262495
262274
|
request = null;
|
|
@@ -262501,7 +262280,7 @@ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
|
|
262501
262280
|
// (message may be empty; when present, surface it)
|
|
262502
262281
|
// See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
|
262503
262282
|
const msg = event && event.message ? event.message : 'Network Error';
|
|
262504
|
-
const err = new
|
|
262283
|
+
const err = new core_AxiosError(msg, core_AxiosError.ERR_NETWORK, config, request);
|
|
262505
262284
|
// attach the underlying event for consumers who want details
|
|
262506
262285
|
err.event = event || null;
|
|
262507
262286
|
reject(err);
|
|
@@ -262515,9 +262294,9 @@ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
|
|
262515
262294
|
if (_config.timeoutErrorMessage) {
|
|
262516
262295
|
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
262517
262296
|
}
|
|
262518
|
-
reject(new
|
|
262297
|
+
reject(new core_AxiosError(
|
|
262519
262298
|
timeoutErrorMessage,
|
|
262520
|
-
transitional.clarifyTimeoutError ?
|
|
262299
|
+
transitional.clarifyTimeoutError ? core_AxiosError.ETIMEDOUT : core_AxiosError.ECONNABORTED,
|
|
262521
262300
|
config,
|
|
262522
262301
|
request));
|
|
262523
262302
|
|
|
@@ -262581,7 +262360,7 @@ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
|
|
262581
262360
|
const protocol = parseProtocol(_config.url);
|
|
262582
262361
|
|
|
262583
262362
|
if (protocol && lib_platform.protocols.indexOf(protocol) === -1) {
|
|
262584
|
-
reject(new
|
|
262363
|
+
reject(new core_AxiosError('Unsupported protocol ' + protocol + ':', core_AxiosError.ERR_BAD_REQUEST, config));
|
|
262585
262364
|
return;
|
|
262586
262365
|
}
|
|
262587
262366
|
|
|
@@ -262609,13 +262388,13 @@ const composeSignals = (signals, timeout) => {
|
|
|
262609
262388
|
aborted = true;
|
|
262610
262389
|
unsubscribe();
|
|
262611
262390
|
const err = reason instanceof Error ? reason : this.reason;
|
|
262612
|
-
controller.abort(err instanceof
|
|
262391
|
+
controller.abort(err instanceof core_AxiosError ? err : new cancel_CanceledError(err instanceof Error ? err.message : err));
|
|
262613
262392
|
}
|
|
262614
262393
|
}
|
|
262615
262394
|
|
|
262616
262395
|
let timer = timeout && setTimeout(() => {
|
|
262617
262396
|
timer = null;
|
|
262618
|
-
onabort(new
|
|
262397
|
+
onabort(new core_AxiosError(`timeout ${timeout} of ms exceeded`, core_AxiosError.ETIMEDOUT))
|
|
262619
262398
|
}, timeout)
|
|
262620
262399
|
|
|
262621
262400
|
const unsubscribe = () => {
|
|
@@ -262814,7 +262593,7 @@ const fetch_factory = (env) => {
|
|
|
262814
262593
|
return method.call(res);
|
|
262815
262594
|
}
|
|
262816
262595
|
|
|
262817
|
-
throw new
|
|
262596
|
+
throw new core_AxiosError(`Response type '${type}' is not supported`, core_AxiosError.ERR_NOT_SUPPORT, config);
|
|
262818
262597
|
})
|
|
262819
262598
|
});
|
|
262820
262599
|
})());
|
|
@@ -262980,14 +262759,14 @@ const fetch_factory = (env) => {
|
|
|
262980
262759
|
|
|
262981
262760
|
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
262982
262761
|
throw Object.assign(
|
|
262983
|
-
new
|
|
262762
|
+
new core_AxiosError('Network Error', core_AxiosError.ERR_NETWORK, config, request),
|
|
262984
262763
|
{
|
|
262985
262764
|
cause: err.cause || err
|
|
262986
262765
|
}
|
|
262987
262766
|
)
|
|
262988
262767
|
}
|
|
262989
262768
|
|
|
262990
|
-
throw
|
|
262769
|
+
throw core_AxiosError.from(err, err && err.code, config, request);
|
|
262991
262770
|
}
|
|
262992
262771
|
}
|
|
262993
262772
|
}
|
|
@@ -263070,7 +262849,7 @@ const isResolvedHandle = (adapter) => utils.isFunction(adapter) || adapter === n
|
|
|
263070
262849
|
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
|
263071
262850
|
|
|
263072
262851
|
if (adapter === undefined) {
|
|
263073
|
-
throw new
|
|
262852
|
+
throw new core_AxiosError(`Unknown adapter '${id}'`);
|
|
263074
262853
|
}
|
|
263075
262854
|
}
|
|
263076
262855
|
|
|
@@ -263092,7 +262871,7 @@ const isResolvedHandle = (adapter) => utils.isFunction(adapter) || adapter === n
|
|
|
263092
262871
|
(reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
|
|
263093
262872
|
'as no adapter specified';
|
|
263094
262873
|
|
|
263095
|
-
throw new
|
|
262874
|
+
throw new core_AxiosError(
|
|
263096
262875
|
`There is no suitable adapter to dispatch the request ` + s,
|
|
263097
262876
|
'ERR_NOT_SUPPORT'
|
|
263098
262877
|
);
|
|
@@ -263222,9 +263001,9 @@ validator_validators.transitional = function transitional(validator, version, me
|
|
|
263222
263001
|
// eslint-disable-next-line func-names
|
|
263223
263002
|
return (value, opt, opts) => {
|
|
263224
263003
|
if (validator === false) {
|
|
263225
|
-
throw new
|
|
263004
|
+
throw new core_AxiosError(
|
|
263226
263005
|
formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
|
|
263227
|
-
|
|
263006
|
+
core_AxiosError.ERR_DEPRECATED
|
|
263228
263007
|
);
|
|
263229
263008
|
}
|
|
263230
263009
|
|
|
@@ -263263,7 +263042,7 @@ validator_validators.spelling = function spelling(correctSpelling) {
|
|
|
263263
263042
|
|
|
263264
263043
|
function assertOptions(options, schema, allowUnknown) {
|
|
263265
263044
|
if (typeof options !== 'object') {
|
|
263266
|
-
throw new
|
|
263045
|
+
throw new core_AxiosError('options must be an object', core_AxiosError.ERR_BAD_OPTION_VALUE);
|
|
263267
263046
|
}
|
|
263268
263047
|
const keys = Object.keys(options);
|
|
263269
263048
|
let i = keys.length;
|
|
@@ -263274,12 +263053,12 @@ function assertOptions(options, schema, allowUnknown) {
|
|
|
263274
263053
|
const value = options[opt];
|
|
263275
263054
|
const result = value === undefined || validator(value, opt, options);
|
|
263276
263055
|
if (result !== true) {
|
|
263277
|
-
throw new
|
|
263056
|
+
throw new core_AxiosError('option ' + opt + ' must be ' + result, core_AxiosError.ERR_BAD_OPTION_VALUE);
|
|
263278
263057
|
}
|
|
263279
263058
|
continue;
|
|
263280
263059
|
}
|
|
263281
263060
|
if (allowUnknown !== true) {
|
|
263282
|
-
throw new
|
|
263061
|
+
throw new core_AxiosError('Unknown option ' + opt, core_AxiosError.ERR_BAD_OPTION);
|
|
263283
263062
|
}
|
|
263284
263063
|
}
|
|
263285
263064
|
}
|
|
@@ -263847,7 +263626,7 @@ axios.VERSION = VERSION;
|
|
|
263847
263626
|
axios.toFormData = helpers_toFormData;
|
|
263848
263627
|
|
|
263849
263628
|
// Expose AxiosError class
|
|
263850
|
-
axios.AxiosError =
|
|
263629
|
+
axios.AxiosError = core_AxiosError;
|
|
263851
263630
|
|
|
263852
263631
|
// alias for CanceledError for backward compatibility
|
|
263853
263632
|
axios.Cancel = axios.CanceledError;
|
|
@@ -264345,7 +264124,7 @@ function baseForOwn(object, iteratee) {
|
|
|
264345
264124
|
* _.mapValues(users, 'age');
|
|
264346
264125
|
* // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
|
|
264347
264126
|
*/
|
|
264348
|
-
function
|
|
264127
|
+
function mapValues_mapValues(object, iteratee) {
|
|
264349
264128
|
var result = {};
|
|
264350
264129
|
iteratee = _baseIteratee(iteratee, 3);
|
|
264351
264130
|
|
|
@@ -264355,7 +264134,7 @@ function mapValues(object, iteratee) {
|
|
|
264355
264134
|
return result;
|
|
264356
264135
|
}
|
|
264357
264136
|
|
|
264358
|
-
/* ESM default export */ const
|
|
264137
|
+
/* ESM default export */ const mapValues = (mapValues_mapValues);
|
|
264359
264138
|
|
|
264360
264139
|
;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isNil.js
|
|
264361
264140
|
/**
|
|
@@ -264624,7 +264403,7 @@ class SlardarReportClient {
|
|
|
264624
264403
|
message,
|
|
264625
264404
|
eventName
|
|
264626
264405
|
});
|
|
264627
|
-
(_this_slardarInstance = (_this = this).slardarInstance) === null || _this_slardarInstance === void 0 ? void 0 : _this_slardarInstance.call(_this, 'captureException', error, lodash_es_omitBy(
|
|
264406
|
+
(_this_slardarInstance = (_this = this).slardarInstance) === null || _this_slardarInstance === void 0 ? void 0 : _this_slardarInstance.call(_this, 'captureException', error, lodash_es_omitBy(mapValues(resolvedMeta, (v)=>lodash_es_isString(v) ? v : safeJson.stringify(v)), lodash_es_isNil), reactInfo);
|
|
264628
264407
|
} else if (eventName) {
|
|
264629
264408
|
var // Report an independent incident
|
|
264630
264409
|
_this_slardarInstance1, _this1;
|
|
@@ -264752,7 +264531,7 @@ function isEmpty_isEmpty(value) {
|
|
|
264752
264531
|
}
|
|
264753
264532
|
if (lodash_es_isArrayLike(value) &&
|
|
264754
264533
|
(lodash_es_isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
|
|
264755
|
-
|
|
264534
|
+
lodash_es_isBuffer(value) || isTypedArray(value) || isArguments(value))) {
|
|
264756
264535
|
return !value.length;
|
|
264757
264536
|
}
|
|
264758
264537
|
var tag = _getTag(value);
|
|
@@ -272779,7 +272558,7 @@ function baseOrderBy(collection, iteratees, orders) {
|
|
|
272779
272558
|
* _.sortBy(users, ['user', 'age']);
|
|
272780
272559
|
* // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]]
|
|
272781
272560
|
*/
|
|
272782
|
-
var
|
|
272561
|
+
var sortBy_sortBy = _baseRest(function(collection, iteratees) {
|
|
272783
272562
|
if (collection == null) {
|
|
272784
272563
|
return [];
|
|
272785
272564
|
}
|
|
@@ -272792,7 +272571,7 @@ var sortBy = _baseRest(function(collection, iteratees) {
|
|
|
272792
272571
|
return _baseOrderBy(collection, _baseFlatten(iteratees, 1), []);
|
|
272793
272572
|
});
|
|
272794
272573
|
|
|
272795
|
-
/* ESM default export */ const
|
|
272574
|
+
/* ESM default export */ const sortBy = (sortBy_sortBy);
|
|
272796
272575
|
|
|
272797
272576
|
;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_createFind.js
|
|
272798
272577
|
|
|
@@ -272877,7 +272656,7 @@ function baseFindIndex(array, predicate, fromIndex, fromRight) {
|
|
|
272877
272656
|
* // => 3
|
|
272878
272657
|
*/
|
|
272879
272658
|
function toInteger_toInteger(value) {
|
|
272880
|
-
var result =
|
|
272659
|
+
var result = toFinite(value),
|
|
272881
272660
|
remainder = result % 1;
|
|
272882
272661
|
|
|
272883
272662
|
return result === result ? (remainder ? result - remainder : result) : 0;
|
|
@@ -272969,9 +272748,9 @@ function findLastIndex_findLastIndex(array, predicate, fromIndex) {
|
|
|
272969
272748
|
* });
|
|
272970
272749
|
* // => 3
|
|
272971
272750
|
*/
|
|
272972
|
-
var
|
|
272751
|
+
var findLast_findLast = _createFind(lodash_es_findLastIndex);
|
|
272973
272752
|
|
|
272974
|
-
/* ESM default export */ const
|
|
272753
|
+
/* ESM default export */ const findLast = (findLast_findLast);
|
|
272975
272754
|
|
|
272976
272755
|
;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/concat.js
|
|
272977
272756
|
|
|
@@ -296433,7 +296212,7 @@ function mathText(e){let t={}.singleDollarTextMath;return null==t&&(t=!0),{token
|
|
|
296433
296212
|
* Copyright (c) 2020 Titus Wormer <tituswormer@gmail.com>
|
|
296434
296213
|
* Licensed under the MIT License
|
|
296435
296214
|
* https://github.com/micromark/micromark-extension-math
|
|
296436
|
-
*/const mathFlow={tokenize:tokenizeMathFenced,concrete:!0},all_in_one_index_nonLazyContinuation={tokenize:all_in_one_index_tokenizeNonLazyContinuation,partial:!0};function tokenizeMathFenced(e,t,n){const r=this,s=r.events[r.events.length-1],i=s&&s[1].type===types_types.linePrefix?s[2].sliceSerialize(s[1],!0).length:0;let a=0;return function(t){return default_ok(t===codes_codes.dollarSign,"expected `$`"),e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),o(t)};function o(t){return t===codes_codes.dollarSign?(e.consume(t),a++,o):a<2?n(t):(e.exit("mathFlowFenceSequence"),factorySpace(e,l,types_types.whitespace)(t))}function l(t){return t===codes_codes.eof||markdownLineEnding(t)?u(t):(e.enter("mathFlowFenceMeta"),e.enter(types_types.chunkString,{contentType:constants.contentTypeString}),c(t))}function c(t){return t===codes_codes.eof||markdownLineEnding(t)?(e.exit(types_types.chunkString),e.exit("mathFlowFenceMeta"),u(t)):t===codes_codes.dollarSign?n(t):(e.consume(t),c)}function u(n){return e.exit("mathFlowFence"),r.interrupt?t(n):e.attempt(all_in_one_index_nonLazyContinuation,d,h)(n)}function d(t){return e.attempt({tokenize:f,partial:!0},h,p)(t)}function p(t){return(i?factorySpace(e,m,types_types.linePrefix,i+1):m)(t)}function m(t){return t===codes_codes.eof?h(t):markdownLineEnding(t)?e.attempt(all_in_one_index_nonLazyContinuation,d,h)(t):(e.enter("mathFlowValue"),g(t))}function g(t){return t===codes_codes.eof||markdownLineEnding(t)?(e.exit("mathFlowValue"),m(t)):(e.consume(t),g)}function h(n){return e.exit("mathFlow"),t(n)}function f(e,t,n){let s=0;return default_ok(r.parser.constructs.disable.null,"expected `disable.null`"),factorySpace(e,(function(t){return e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),i(t)}),types_types.linePrefix,r.parser.constructs.disable.null.includes("codeIndented")?void 0:constants.tabSize);function i(t){return t===codes_codes.dollarSign?(s++,e.consume(t),i):s<a?n(t):(e.exit("mathFlowFenceSequence"),factorySpace(e,o,types_types.whitespace)(t))}function o(r){return r===codes_codes.eof||markdownLineEnding(r)?(e.exit("mathFlowFence"),t(r)):n(r)}}}function all_in_one_index_tokenizeNonLazyContinuation(e,t,n){const r=this;return function(n){if(null===n)return t(n);return default_ok(markdownLineEnding(n),"expected eol"),e.enter(types_types.lineEnding),e.consume(n),e.exit(types_types.lineEnding),s};function s(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}const dollarSign=36;function all_in_one_index_math(e){return{flow:{[dollarSign]:mathFlow},text:{[dollarSign]:mathText()}}}const parseJSONWithNull=e=>{try{return e?JSON.parse(e):null}catch(e){return null}},getByIndex=(e,t)=>{if(!lodash_es_isUndefined(t))return null==e?void 0:e[t]};class AssertError extends Error{constructor(){super(...arguments),this.name="assert_error"}}const assert=(e,t)=>{if(!e){if(lodash_es_isError(t))throw t;throw new AssertError(t)}};let _isSafari;function all_in_one_index_isSafari(){return"undefined"!=typeof navigator&&(void 0===_isSafari&&(_isSafari=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)),_isSafari)}const pipe=(...e)=>t=>e.reduce(((e,t)=>t(e)),t),isNumeric=e=>{const t=e.replace(/,/g,"");return!isNaN(t)&&!isNaN(parseFloat(t))},firstMatch=(e,t)=>{for(const n of e){const e=t(n);if(e)return e}},timeoutPromise=e=>new Promise((t=>setTimeout(t,e))),elementAt=(e,t)=>e[t],splitStringByPattern=(e,t)=>{const n=[],{flags:r}=t,s=new RegExp(t.source,r.includes("g")?r:`${r}g`);let i,a=0;for(;i=s.exec(e);){const t=i[0];i.index>a&&n.push(e.slice(a,i.index)),n.push(t),a=i.index+t.length}return e.length>a&&n.push(e.slice(a,e.length)),n},safeParseUrl=e=>{try{return new URL(e)}catch(e){return null}},useCustomMemoValue=(e,t)=>{const n=(0,react.useRef)(e);return t(e,n.current)||(n.current=e),n.current},useDeepCompareMemo=(e,t)=>{const n=(0,react.useRef)();return!lodash_es_isUndefined(n.current)&&lodash_es_isEqual(n.current,t)||(n.current=t),(0,react.useMemo)(e,n.current)},useComputeValue=e=>e(),purifyHtml=(e,t)=>isomorphic_dompurify_browser.sanitize?isomorphic_dompurify_browser.sanitize(e,t):(console.error("[Calypso] Cannot load isomorphic-dompurify"),e),voidTags=["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"],transformSelfClosing=e=>e.replace(/<([\w\-]+)([^>/]*)\/\s*>/g,((e,t,n)=>voidTags.includes(t.toLowerCase())?e:`<${t}${n}></${t}>`)),retryAsync=async(e,{tryTimes:t=5,interval:n=100,fallback:r,onRetryError:s})=>{for(let i=0;i<t;i++){const a=i+1;try{return await e()}catch(e){if(a>=t){if(!lodash_es_isUndefined(r))return r;throw e}null==s||s(e,i)}const o="number"==typeof n?n:n(a);await timeoutPromise(o)}throw Error("retry times out of limit")},withRetry=(e,t)=>(...n)=>retryAsync((()=>e(...n)),t),resizeImage=({width:e,height:t,minHeight:n,minWidth:r,maxHeight:s,maxWidth:i})=>{const a={width:e,height:t},o=e/t,l=e=>{a.height=e,a.width=e*o},c=e=>{a.width=e,a.height=e/o};return a.width<r&&c(r),a.height<n&&l(n),a.width>i&&c(i),a.height>s&&l(s),(a.width<r||a.width>i||a.height<n||a.height>s)&&console.warn(`[Calypso] Image cannot be resized to the specified size: Natural size: {${e},${t}} Resized size: {${a.width},${a.height}} Min size: {${r},${n}} Max size: {${i},${s}}`),a},createShallowedProvider$1=e=>{const t=e.Provider;return({value:e,afterMemoedProcess:n,children:r})=>{const s=useCustomMemoValue(e,shallowEqual),i=(0,react.useMemo)((()=>n?n(s):s),[s]);return (0,jsx_runtime.jsx)(t,{value:i,children:r})}};var LinkTermination=(e=>(e.Include="Include",e.Hard="Hard",e.Soft="Soft",e.Close="Close",e.Open="Open",e))(LinkTermination||{});const DEFAULT_CONFIG={characterMap:new Map,cjkIsHard:!0,hardPattern:/[\s\p{C}]/u,softPattern:/[.,!?;:'"。,!?;:]/u,pairedOpenerMap:new Map([[")","("],["]","["],["}","{"],[">","<"],["』","『"],["」","「"],["〉","〈"],["》","《"]])},CJK_PATTERN=/[\u4E00-\u9FFF\u3400-\u4DBF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF]/u;class UnicodeURLDetector{constructor(e={}){this.config={...DEFAULT_CONFIG,...e}}getLinkTermination(e){if(this.config.characterMap.has(e))return this.config.characterMap.get(e)??"Include";if(this.config.cjkIsHard&&CJK_PATTERN.test(e))return"Hard";if(this.config.pairedOpenerMap.has(e))return"Close";for(const t of this.config.pairedOpenerMap.values())if(e===t)return"Open";return this.config.hardPattern.test(e)?"Hard":this.config.softPattern.test(e)?"Soft":"Include"}getPairedOpener(e){return this.config.pairedOpenerMap.get(e)||null}detectLink(e,t=0){let n=t;const r=[];for(let s=t;s<e.length;s++){const t=e[s];switch(this.getLinkTermination(t)){case"Include":default:n=s+1;break;case"Soft":{let t=s+1;for(;t<e.length&&"Soft"===this.getLinkTermination(e[t]);)t++;if(t>=e.length||"Hard"===this.getLinkTermination(e[t]))return n;n=s+1;break}case"Hard":return n;case"Open":r.push(t),n=s+1;break;case"Close":{if(0===r.length)return n;const e=r.pop();if(this.getPairedOpener(t)!==e)return n;n=s+1;break}}}return n}findAllLinks(e){const t=[],n=[/https?:\/\/[^\s\u4E00-\u9FFF\u3400-\u4DBF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF]+/gi,/(^|[^a-zA-Z0-9.-])(www\.[a-zA-Z0-9][-a-zA-Z0-9]*\.[a-zA-Z]{2,}(?:[^\s\u4E00-\u9FFF\u3400-\u4DBF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF]*)?)/gi,/(^|[^a-zA-Z0-9.-@])([a-zA-Z0-9][-a-zA-Z0-9]*\.[a-zA-Z]{2,}(?:[^\s\u4E00-\u9FFF\u3400-\u4DBF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF@]*)?)/gi];for(const r of n){let n=r.exec(e);for(;null!==n;){let s=n.index;if(n.length>2&&n[2]){if(s=n.index+(n[0].length-n[2].length),s>0&&"@"===e[s-1]){n=r.exec(e);continue}}else if(n.length>1&&n[1]&&n[1]!==n[0]){if(s=n.index+(n[0].length-n[1].length),s>0&&"@"===e[s-1]){n=r.exec(e);continue}}else if(s>0&&"@"===e[s-1]){n=r.exec(e);continue}const i=this.detectLink(e,s),a=e.substring(s,i);if(i>s&&this.isValidURL(a)){t.some((e=>s>=e.start&&s<e.end||i>e.start&&i<=e.end))||t.push({start:s,end:i,url:a})}n=r.exec(e)}}return t.sort(((e,t)=>e.start-t.start))}isValidURL(e){if(e.length<4)return!1;if(e.startsWith("http://")||e.startsWith("https://"))return e.length>10;return/^[a-zA-Z0-9][-a-zA-Z0-9]*\.[a-zA-Z]{2,}/.test(e)}}const defaultDetector=new UnicodeURLDetector;function createDetector(e){return new UnicodeURLDetector(e)}var HyperNodeType=(e=>(e[e.text=0]="text",e[e.link=1]="link",e))(HyperNodeType||{});const extractAutolinkDetector=createDetector({}),getHyperLinkNodes$1=e=>{const t=[],n=extractAutolinkDetector.findAllLinks(e);let r=0;for(const s of n){if(r<s.start){const n=e.slice(r,s.start);n&&t.push({type:0,text:n})}const n=e.slice(s.start,s.end);t.push({type:1,url:n}),r=s.end}if(r<e.length){const n=e.slice(r);n&&t.push({type:0,text:n})}return t},completeProtocol$1=e=>e.match(/https?:\/\//)?e:`https://${e}`,isValidEmail=e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);class UnicodeHyperLinkParser{constructor(e={}){this.config={enableEmail:!1,autoAddProtocol:!0,...e},this.detector=e.characterMap||void 0!==e.cjkIsHard?createDetector(e):defaultDetector}findEmailAddresses(e){if(!this.config.enableEmail)return[];const t=[],n=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;let r=n.exec(e);for(;null!==r;){const s=r[0];isValidEmail(s)&&t.push({start:r.index,end:r.index+s.length,email:s}),r=n.exec(e)}return t}getHyperLinkNodes(e){const t=[],n=this.detector.findAllLinks(e),r=this.findEmailAddresses(e),s=[...n.map((e=>({...e,type:"link"}))),...r.map((e=>({...e,url:e.email,type:"email"})))].sort(((e,t)=>e.start-t.start));let i=0;for(const n of s){if(i<n.start){const r=e.slice(i,n.start);r&&t.push({type:HyperNodeType.text,text:r})}if("email"===n.type)t.push({type:HyperNodeType.text,text:n.url});else{const e=this.config.autoAddProtocol?completeProtocol$1(n.url):n.url;t.push({type:HyperNodeType.link,url:e})}i=n.end}if(i<e.length){const n=e.slice(i);n&&t.push({type:HyperNodeType.text,text:n})}return t}}const createUnicodeParser=e=>new UnicodeHyperLinkParser(e),defaultUnicodeParser=new UnicodeHyperLinkParser,getHyperLinkNodes=e=>defaultUnicodeParser.getHyperLinkNodes(e),escapeRegExp=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),escapeChars=(e,t)=>{if(t.filter((e=>1!==e.length)).length)throw Error(`illegal chars length: ${t.join(", ")}`);return t.reduce(((e,t)=>{const n=new RegExp(String.raw`([^\\]|^)(${escapeRegExp(t)})`,"g");return e.replace(n,((e,t,n)=>`${t}\\${n}`))}),e)},escapeCharsInLatex=e=>escapeChars(e,["#"]),texPreProcessor=pipe(escapeCharsInLatex),texMathExtract=e=>{let t=0;if(36!==e.charCodeAt(t))return;let n="$";t+=1;const r=e.charCodeAt(t);if(36===r){if(n="$$",t+=1,36===e.charCodeAt(t))return}else if(32===r||9===r||10===r)return;const s=e.indexOf(n,t);if(-1===s)return;if(92===e.charCodeAt(s-1))return;const i=s+n.length;if(1===n.length){const t=e.charCodeAt(s-1);if(32===t||9===t||10===t)return;const n=e.charCodeAt(i);if(n>=48&&n<58)return}return{type:1===n.length?"inline":"block",mathText:e.slice(t,s),endIndex:i}},katexTryParseOptions={throwOnError:!0,strict:!0,output:"mathml",trust:!1},katexCheckTex=(e,t)=>{try{return e.renderToString(texPreProcessor(t),katexTryParseOptions),!0}catch(t){if(t instanceof e.ParseError)return!1;throw t}},katexParseErrorIndex=(e,t)=>{try{e.renderToString(texPreProcessor(t),katexTryParseOptions)}catch(t){if(t instanceof e.ParseError)return t.position}},customCheckTex=e=>![/\([^\)]*$/].some((t=>t.test(e))),checkTex=({tex:e,katex:t})=>katexCheckTex(t,e)&&customCheckTex(e),findMaxLegalPrefixEndIndex=({src:e,katex:t})=>{let n=katexParseErrorIndex(t,e)??e.length;for(;n>=0;){const r=e.slice(0,n);if(checkTex({tex:r,katex:t}))return n;n-=1}return n},INSERT_ELEMENT_SLOT_NAME="insert_element",getTextSlotString=e=>`{${e}}`,getInsertElementSlotString=({data:e,index:t,wrapWith:n=""})=>`${n}${getTextSlotString(`insert_element_${t}_${node_modules_buffer.Buffer.from(e).toString("base64")}`.replace(/_/g,"\\_"))}${n}`,insertElementSlotRegex=`\\{${"insert_element".replace(/_/g,"\\\\_")}\\\\_(?<index>[0-9]+)\\\\_(?<b64_data>.*?)\\}`,startOfInsertElementSlot=e=>{var t;return null==(t=new RegExp(insertElementSlotRegex).exec(e))?void 0:t.index},matchInsertElementSlot=e=>{const t=new RegExp(`^${insertElementSlotRegex}`).exec(e);return null==t?void 0:t[0]},extractDataFromInsertElementSlot=e=>{const t=new RegExp(`^${insertElementSlotRegex}$`).exec(e),{index:n,b64_data:r}=(null==t?void 0:t.groups)||{};if(!lodash_es_isUndefined(n)&&!lodash_es_isUndefined(r))return{index:parseInt(n),b64Text:r,text:r&&node_modules_buffer.Buffer.from(r,"base64").toString("utf8")}},convertToOperation=(e,t)=>{const n=[],r={inline:"",newline:"\n",block:"\n\n"};return t.forEach((({range:t,type:s="inline"},i)=>{const a=lodash_es_isNumber(t)?[t,t]:t,[o,l]=a;o>l||o>e.length||n.push({replaceRange:lodash_es_isNumber(t)?[t,t]:t,insert:getInsertElementSlotString({index:i,data:e.slice(...a),wrapWith:r[s]}),index:n.length})})),n},transformOperationInOrder=(e,t)=>{const[n,r]=e.replaceRange,[s,i]=t.replaceRange,a=t.insert.length-(i-s);if(n<s)return e;if(n===s&&e.index<t.index)return e;const o=Math.min(Math.max(0,i-n),r-n);return{...e,replaceRange:[n+a+o,r+a]}},transformEach=e=>{const t=[];for(let n=0;n<e.length;n+=1){let r=e[n];for(let e=0;e<t.length;e+=1)r=transformOperationInOrder(r,t[e]);t.push(r)}return t},applyOperationToString=(e,t)=>{const{replaceRange:[n,r],insert:s}=t;return`${e.slice(0,n)}${s}${e.slice(r)}`},applyInsertListToString=(e,t)=>{const n=transformEach(convertToOperation(e,t));return pipe(...n.map((e=>t=>applyOperationToString(t,e))))(e)},addInsertElementSlotToString=(e,t)=>applyInsertListToString(e,t),removeInsertElementSlotInString=e=>e.replace(new RegExp(insertElementSlotRegex,"g"),(e=>{const t=extractDataFromInsertElementSlot(e);return t?t.text:""})),INLINE_MATH_SPAN_DATA_TYPE="inline-math",BLOCK_MATH_SPAN_DATA_TYPE="block-math",renderSpanString=(e,t)=>`<span data-type="${e}" data-value="${node_modules_buffer.Buffer.from(t).toString("base64")}"></span>`,renderInlineMathSpanString=e=>renderSpanString("inline-math",texPreProcessor(removeInsertElementSlotInString(e))),renderBlockMathSpanString=e=>renderSpanString("block-math",texPreProcessor(removeInsertElementSlotInString(e))),restoreMathPandocLatex=e=>e.replace(new RegExp('<span data-type="inline-math" data-value="(.*?)"></span>',"g"),((e,t)=>String.raw`\(${node_modules_buffer.Buffer.from(t,"base64").toString("utf8")}\)`)).replace(new RegExp('<span data-type="block-math" data-value="(.*?)"></span>',"g"),((e,t)=>String.raw`\[${node_modules_buffer.Buffer.from(t,"base64").toString("utf8")}\]`)),parseMarkdown=(e,t={})=>fromMarkdown(e,{extensions:[all_in_one_index_math(),syntax_gfmTable,disableSetextHeading(),...t.enableIndentedCode?[]:[disableIndentedCode()],gfmStrikethrough({singleTilde:!1}),gfmTaskListItem],mdastExtensions:[mathFromMarkdown(),gfmTableFromMarkdown,gfmStrikethroughFromMarkdown,gfmTaskListItemFromMarkdown]}),stringifyMarkdown=(e,t=!1)=>{const n=toMarkdown(e,{extensions:[mathToMarkdown(),gfmTableToMarkdown(),gfmStrikethroughToMarkdown,gfmTaskListItemToMarkdown],resourceLink:!0,fences:!0});return t?n.trim():n},stringifyChildren=(e,t=!1)=>{if(!e.length)return"";const n=stringifyMarkdown({type:"root",children:e},!0);return t?n.replace(/\n/g,""):n},isParentOfContent=e=>!lodash_es_isUndefined(null==e?void 0:e.children),all_in_one_index_isParent=e=>!lodash_es_isUndefined(null==e?void 0:e.children),isLiteralOfContent=e=>!lodash_es_isUndefined(null==e?void 0:e.value),all_in_one_index_isImage=e=>"image"===(null==e?void 0:e.type),isRoot=e=>"root"===(null==e?void 0:e.type),isTypeOfContent=(e,...t)=>t.some((t=>(null==e?void 0:e.type)===t)),isHeading=e=>isParentOfContent(e)&&"heading"===e.type,getTextOfAst=(e,t={})=>{const{filter:n}=t;return n&&!n(e)?"":isParentOfContent(e)?`${e.children.map((e=>getTextOfAst(e,t))).join("")}\n`:isLiteralOfContent(e)?e.value:""},DEFAULT_ENABLED_ROOT_TAGS=["span","u","br"],matchTagNameOfHtmlTag=e=>{var t,n;const r=[/<(?<tag>[a-zA-Z]+)(\s+([a-zA-Z]+=(("[^"]*")|('[^']*'))))*\s*\/?>/,/<\/(?<tag>[a-zA-Z]+)>/];for(const s of r){const r=s.exec(e);if(r)return null==(n=null==(t=r.groups)?void 0:t.tag)?void 0:n.toLowerCase()}},getTagNameOfHtml=e=>{var t;const n=matchTagNameOfHtmlTag(e);if("undefined"==typeof DOMParser)return n;const r=new DOMParser,s=elementAt([...r.parseFromString(e,"text/html").body.children],0);return(null==(t=null==s?void 0:s.tagName)?void 0:t.toLowerCase())||n},autoDisableHtmlTag=(e,t=[])=>{const n=getTagNameOfHtml(e);if(!0===t)return e;const r=[...DEFAULT_ENABLED_ROOT_TAGS,...t||[]];return n&&!r.includes(n)?he.encode(e,{strict:!1}):e},stringifyDomNode=e=>esm(e,{encodeEntities:!1,decodeEntities:!0}),INSERT_ELEMENT_SLOT_EXTENSION_NAME="insert_element_extension",insertElementSlotExtension=()=>({name:"insert_element_extension",level:"inline",start:e=>startOfInsertElementSlot(e),tokenizer(e){const t=matchInsertElementSlot(e);if(t)return{type:"insert_element_extension",raw:t}},renderer({raw:e}){if(!e)return!1;const t=extractDataFromInsertElementSlot(e);if(!t)return!1;const{index:n,b64Text:r}=t;return`<span data-index="${n}" data-raw="${r}" data-type="insert_element_extension"></span>`}}),inlineTex=()=>({name:"inlineTex",level:"inline",start(e){var t;return null==(t=/\$([^\$]|$)/.exec(e))?void 0:t.index},tokenizer(e){const t=texMathExtract(e);if(!t)return;const{type:n,endIndex:r,mathText:s}=t;return"inline"===n?{type:"inlineTex",raw:e.slice(0,r),mathText:s}:void 0},renderer:e=>renderInlineMathSpanString(e.mathText)}),displayTex=()=>({name:"displayTex",level:"block",start(e){var t;return null==(t=/\$\$[^\$]+\$\$/.exec(e))?void 0:t.index},tokenizer(e){const t=texMathExtract(e);if(!t)return;const{type:n,endIndex:r,mathText:s}=t;return"block"===n?{type:"displayTex",raw:e.slice(0,r),mathText:s}:void 0},renderer:e=>renderBlockMathSpanString(e.mathText)}),escapeTest=/[&<>"']/,escapeReplace=new RegExp(escapeTest.source,"g"),escapeTestNoEncode=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode=new RegExp(escapeTestNoEncode.source,"g"),all_in_one_index_escapeReplacements={"&":"&","<":"<",">":">",'"':""","'":"'"},escapeMarkdownText=(e,t=!1)=>{const n=e=>all_in_one_index_escapeReplacements[e];if(t){if(escapeTest.test(e))return e.replace(escapeReplace,n)}else if(escapeTestNoEncode.test(e))return e.replace(escapeReplaceNoEncode,n);return e},getCalypsoRenderer=(e={})=>{const{enabledHtmlTags:t}=e;return new class extends _Renderer{html({text:e}){return autoDisableHtmlTag(e,t)}code({text:e,lang:t="",escaped:n}){const r=t.match(/^\s*(?<language>\S+)\s*(?<meta>[\S\s]*?)\s*$/),s=`${e.replace(/\n$/,"")}\n`;if(!r)return`<pre><code>${n?s:escapeMarkdownText(s,!0)}</code></pre>\n`;const{groups:i={}}=r,{language:a,meta:o}=i;return`<pre><code type="test" class="language-${escapeMarkdownText(a)}"${o?` data-meta="${escapeMarkdownText(o)}"`:""}>${n?s:escapeMarkdownText(s,!0)}</code></pre>\n`}}(e)},gfmDelRegex=/^(~~)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/;class CalypsoTokenizer extends _Tokenizer{autolink(e){}del(e){const t=gfmDelRegex.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}url(){}}const getHopDiff=(e,t)=>{if(e.type!==t.type)return isParentOfContent(e)&&isParentOfContent(t)?{prevEndNode:e,endNode:t}:null;if(!lodash_es_isEqual(e.children.map((e=>e.type)),t.children.map((e=>e.type))))return{prevEndNode:elementAt(e.children,e.children.length-1),endNode:elementAt(t.children,t.children.length-1)};for(let n=0;n<e.children.length;n++){const r=e.children[n],s=t.children[n];if(all_in_one_index_isParent(r)&&all_in_one_index_isParent(s)){const e=getHopDiff(r,s);if(e)return e}else{if(all_in_one_index_isParent(r)||all_in_one_index_isParent(s))return{prevEndNode:r,endNode:s};if(r.type!==s.type)return{prevEndNode:r,endNode:s}}}return null},standardNodeTypeMapping={thematicBreak:"thematic",heading:"heading",code:"code_block",html:"html",linkReference:"link_def_ref",paragraph:"paragraph",table:"table",blockquote:"block_quote",list:"list",listItem:"list_item",inlineCode:"inline_code",emphasis:"emphasis",strong:"strong",link:"link",image:"image",delete:"strike_through",text:"text",math:"math_block",inlineMath:"inline_math"},convertToStanardNodeTypeEnum=e=>e?standardNodeTypeMapping[e]??"unknown":"empty",updateAst=(e,t,n={})=>{const{order:r="pre_order",isReverse:s=!1}=n;let i=!1,a=!1,o=!1;const l=[[[],e]],c=[];for(;l.length;){const e=l.pop();assert(e,"current must not be undefined");const[n,u]=e,d=lodash_es_head(n),p=all_in_one_index_isParent(u)?u.children.slice():[],m=s?p:p.reverse(),g=all_in_one_index_isParent(u)?m.map((e=>[[u,...n],e])):[],h=(e,t=!1)=>{if(!d)return;const n=d.children.findIndex((e=>e===u));assert(lodash_es_isNumber(n),"Invoke insertAfter error in updateAst: parent is not parent of current"),t?d.children.splice(n,1,...e):d.children.splice(n+1,0,...e)},f=()=>{if(o)throw Error("You have to call stop synchronously");i=!0},x=()=>{if(o)throw Error("You have to call skip synchronously");a=!0},y=()=>{const e=null==d?void 0:d.children.findIndex((e=>e===u));assert(-1!==e,"Current must be child of it's parent"),t(u,{stop:f,skip:x,insertAfter:h,parent:d,parents:n,index:e})};if("pre_order"===r)y(),a||l.push(...g);else if("post_order"===r){const t=g.filter((([,e])=>!c.includes(e)));t.length?(l.push(e),l.push(...t)):(y(),c.push(u))}else"in_order"===r&&(all_in_one_index_isParent(u)&&g.length&&g.every((([,e])=>!c.includes(e)))?(l.push(...g.slice(0,g.length-1)),l.push(e),l.push(g[g.length-1])):(y(),c.push(u)));if(i)break;i=!1,a=!1}o=!0};var AstPluginPriority=(e=>(e[e.BeforeAll=-2]="BeforeAll",e[e.Before=-1]="Before",e[e.Normal=0]="Normal",e[e.After=1]="After",e[e.AfterAll=2]="AfterAll",e))(AstPluginPriority||{});class BaseAstPlugin{constructor(){this.config={},this.before=lodash_es_noop,this.after=lodash_es_noop,this.beforeEach=lodash_es_noop,this.afterEach=lodash_es_noop}}const modifyByCurrentPlugin=({plugin:e,ast:t,skipWhenError:n=!0,...r})=>{const s=lodash_es_isFunction(e.modifier)?[e.modifier.bind(e)]:e.modifier.map((t=>t.bind(e)));e.before(t);for(const i of s){e.beforeEach(t);try{updateAst(t,((t,n)=>i(t,{...n,recursiveModifier(t){modifyByCurrentPlugin({plugin:e,ast:t,...r})},...r})),e.config)}catch(t){if(!n)throw t;console.error(`[Calypso source plugin error: ${e.name}]`,t)}e.afterEach(t)}e.after(t)},processAstByPlugins=({ast:e,plugins:t,fixEnding:n=!1,skipWhenError:r,...s})=>{const i=lodash_es_sortBy(t,(e=>{var t;return(null==(t=e.config)?void 0:t.priority)??AstPluginPriority.Normal})).filter((e=>{const{fixEndingOnly:t=!1}=e.config??{};return!t||n})),a=lodash_es_cloneDeep(e);for(const e of i)modifyByCurrentPlugin({plugin:e,ast:a,skipWhenError:r,...s});return a};var SourcePluginPriority=(e=>(e[e.BeforeAll=-1]="BeforeAll",e[e.Normal=0]="Normal",e[e.AfterAll=1]="AfterAll",e))(SourcePluginPriority||{});class BaseSourcePlugin{constructor(){this.config={},this.before=lodash_es_noop,this.after=lodash_es_noop,this.beforeEach=lodash_es_noop,this.afterEach=lodash_es_noop}}const processSourceByPlugins=({source:e,plugins:t,fixEnding:n=!1,katex:r,skipWhenError:s=!0})=>lodash_es_sortBy(t,(e=>{var t;return(null==(t=e.config)?void 0:t.priority)??SourcePluginPriority.Normal})).filter((e=>{const{fixEndingOnly:t=!1}=e.config??{};return!t||n})).reduce(((e,t)=>{t.before(e);const n=(lodash_es_isFunction(t.modifier)?[t.modifier.bind(t)]:t.modifier.map((e=>e.bind(t)))).reduce(((e,n)=>{try{t.beforeEach(e);const s=n({source:e,katex:r});return t.afterEach(s),s}catch(n){if(!s)throw n;return console.error(`[Calypso source plugin error: ${t.name}]`,n),e}}),e);return t.after(n),n}),e);class AutofixLastCodeBlockAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_last_code_block",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n})=>{var r,s;if(isLiteralOfContent(e))if(n(),"code"===e.type){const{content:n}=(null==(r=e.value.match(/^(?<content>[\S\s]*?)\n`+$/))?void 0:r.groups)||{};if(!lodash_es_isString(n))return;t([{...e,value:n}],!0)}else if("text"===e.type){const{prefix:n}=(null==(s=e.value.match(/^(?<prefix>[\s\S]*?)`{1,2}$/))?void 0:s.groups)||{};if(!lodash_es_isString(n))return;t(n?[{type:"text",value:n}]:[],!0)}}}}const getLastTextNodeByRegex=(e,t)=>{const n=lodash_es_findLast(e.children,(e=>Boolean("text"===e.type&&e.value.match(t))));if(!n)return;assert("text"===n.type,"lastUnPaired.type must be text");const r=e.children.findIndex((e=>e===n));return assert(r>=0,"lastUnPairedIndex must >= 0"),{target:n,index:r}},UNPAIRED_REGEX=/^(?<prefix>.*([^\\`]|^))`(?!`)(?<suffix>.*?)$/;class AutofixLastInlineCodeBlockAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_last_inline_code_block",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{stop:t})=>{var n;if(!all_in_one_index_isParent(e))return;t();const r=getLastTextNodeByRegex(e,UNPAIRED_REGEX);if(!r)return;const{target:s,index:i}=r;if(e.children.slice(i+1).find((e=>"inlineCode"===e.type)))return;const{prefix:a,suffix:o}=(null==(n=s.value.match(UNPAIRED_REGEX))?void 0:n.groups)||{};if(!lodash_es_isString(o)||!lodash_es_isString(a))return;const l=[];a&&l.push({type:"text",value:a});const c=`${o}${stringifyChildren(e.children.slice(i+1),!0)}`;c&&l.push({type:"inlineCode",value:c}),e.children.splice(i,e.children.length-i,...l)}}}const truncatedHtmlRegexList=[/<([a-zA-Z\-]+((\s+([a-zA-Z\-]+=(("[^"]*")|('[^']*'))))*(\s*\/?|(\s+[a-zA-Z\-]+(=(("[^"]*)|('[^']*))?)?)))?)?$/,/<\/([a-zA-Z\-]+)?$/],truncatedDataSlotRegexList=[/<data-(inline|block)(\s.*)?$/],truncateTruncatedHtmlSuffix=(e,t={})=>{const{looseTruncateDataSlot:n=!1}=t,r=firstMatch(lodash_es_concat(truncatedHtmlRegexList,n?truncatedDataSlotRegexList:[]),(t=>t.exec(e)));return r?e.slice(0,r.index):e};class AutofixTruncatedHtmlTagAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_html_tag",this.config={isReverse:!0},this.modifier=(e,{insertAfter:t,stop:n,looseTruncateDataSlot:r=!1})=>{if(!isTypeOfContent(e,"text","html"))return;n();const s=truncateTruncatedHtmlSuffix(e.value,{looseTruncateDataSlot:r});t(s?[{type:e.type,value:s}]:[],!0)}}}class AutofixTruncatedLinkAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_link",this.config={isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n})=>{var r;if(isTypeOfContent(e,"link"))return void n();if(all_in_one_index_isParent(e)||"text"!==e.type&&"html"!==e.type)return;n();const s=[/\[(?<text>\[[^\]\n]*)$/,/\[(?<text>\[[^\]\n]+\])$/,/\[(?<text>\[[^\]\n]+\])\]$/,/\[(?<text>\[[^\]\n]+\])\]\([^\)\n]*$/,/\[(?<text>[^\]\n]*)$/,/\[(?<text>[^\]\n]+)\]$/,/\[(?<text>[^\]\n]+)\]\([^\)\n]*$/].find((t=>t.exec(e.value)));if(!s)return;const i=s.exec(e.value);if(!i)return;const a=null==(r=i.groups)?void 0:r.text,o=i.index;t(a?[{type:e.type,value:e.value.slice(0,o)},{type:"link",title:null,url:"#",children:[{type:"text",value:a}]}]:[{type:e.type,value:e.value.slice(0,o)}],!0)}}}class AutofixTruncatedImageAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_image",this.config={isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n,removeTruncatedImage:r=!1})=>{var s;const i=[/!$/,/!\[$/,/!\[(?<text>[^\]]*)$/,/!\[(?<text>[^\]]*)\]$/,/!\[(?<text>[^\]]*)\]\([^\)]*$/],a=r?i:i.slice(0,1),o=r?[]:i.slice(1);if(!isLiteralOfContent(e))return;if(n(),"text"!==e.type)return;const l=o.find((t=>t.exec(e.value))),c=a.find((t=>t.exec(e.value)));if(!c&&!l)return;const u=c??l;if(!u)return;const d=u.exec(e.value);d&&t(lodash_es_concat({type:"text",value:e.value.slice(0,d.index)},l?{type:"image",url:"",alt:(null==(s=d.groups)?void 0:s.text)||"image"}:[]),!0)}}}class AutofixTruncatedEscapePlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_escape",this.config={isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n})=>{var r;if(all_in_one_index_isParent(e)||"text"!==e.type)return;n();const s=e.value.match(/^(?<text>[\s\S]*)\\$/);if(!s)return;t([{type:"text",value:(null==(r=s.groups)?void 0:r.text)??""}],!0)}}}const completeProtocol=e=>e.match(/https?:\/\//)?e:`https://${e}`;class ExtractCustomAutolinkAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="extract_custom_autolink",this.config={priority:AstPluginPriority.After},this.modifier=(e,{insertAfter:t,skip:n})=>{if(all_in_one_index_isParent(e))return void(isParentOfContent(e)&&"link"===e.type&&n());if("text"!==e.type)return;t(getHyperLinkNodes$1(e.value).map((e=>{if(e.type===HyperNodeType.link){const t=e;return{type:"link",url:completeProtocol(t.url),title:"autolink",children:[{type:"text",value:t.url}]}}if(e.type===HyperNodeType.text){return{type:"text",value:e.text}}return null})).filter((e=>Boolean(e))),!0)}}}const indicatorItem={type:"html",value:'<span class="indicator" />'};class InsertIndicatorAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="insert_indicator",this.config={isReverse:!0,priority:AstPluginPriority.After},this.modifier=(e,{insertAfter:t,stop:n})=>{if(all_in_one_index_isImage(e))n();else{if(isParentOfContent(e)&&"listItem"===e.type&&!stringifyChildren(e.children,!0).trim())return n(),void t([{...e,children:[indicatorItem]}],!0);if(isLiteralOfContent(e)){if(n(),"code"===e.type)return;t([indicatorItem])}}}}}const mergeTextChildren=e=>{const{children:t}=e,n=[];let r="";for(let e=0;e<t.length;e++){const s=t[e];"text"===s.type&&(r+=s.value),"text"===s.type&&e!==t.length-1||(r&&n.push({type:"text",value:r}),r=""),"text"!==s.type&&n.push(s)}e.children=n};class AutoMergeSiblingTextAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="extract_custom_autolink",this.config={priority:AstPluginPriority.AfterAll},this.modifier=(e,{skip:t,recursiveModifier:n})=>{if(isParentOfContent(e)){mergeTextChildren(e),t();for(const t of e.children)all_in_one_index_isParent(t)&&n(t)}}}}const indexOfFirstLegalDollar=e=>{var t;const n=e.match(/(?<prefix>[^\$\\]|^)(\$|\$\$)(?!\$)/);if(!n)return-1;const{index:r=0}=n,s=null==(t=null==n?void 0:n.groups)?void 0:t.prefix;return lodash_es_isString(s)?r+s.length:-1},lengthOfDollorPrefix=e=>{const t=e.match(/^\$*/);return t?t[0].length:0},findStartIndexOfNoneTexSuffix=e=>{let t=indexOfFirstLegalDollar(e),n=0,r=!0;for(;-1!==t;){const s=texMathExtract(e.slice(t));if(s){const{endIndex:e}=s;t+=e,r=!1,n=t}else{const n=indexOfFirstLegalDollar(e.slice(t));if(-1===n)break;t+=r?Math.max(n,lengthOfDollorPrefix(e.slice(t))):n,r=!0}}return n},RAW_NUMBER_REST_STRING_LENGTH_THRESHOLD=10,enSentenceRegexFullMatch=/^[0-9a-zA-Z\s"'\.,\-\(\)]$/,enSentenceRegexWithCountOfPrefixMatch=/^[0-9a-zA-Z\s"'\.,\-\(\)]{15}/,unpairedLongMathRegex=/^\s*(\\begin)/,shouldStopAutofix=(e,t)=>{const n=e.trim(),r=n.slice(0,t),s=n.length;return!unpairedLongMathRegex.exec(n)&&(!r||isNumeric(r)?s-t>10:!!(enSentenceRegexFullMatch.exec(r)&&s-t>10)||!!enSentenceRegexWithCountOfPrefixMatch.exec(r))};class AutofixTruncatedTexMathDollarAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_tex_math_dollar",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n,katex:r})=>{if(r&&!all_in_one_index_isParent(e))if(isLiteralOfContent(e)&&n(),"text"===e.type){const n=findStartIndexOfNoneTexSuffix(e.value),s=e.value.slice(n).match(/^(?<prefix>[\s\S]*?([^\$\\]|^))(?<inter>\$|\$\$)(?!\$)(?<value>[^\$]*?)(?<suffix>\$*)$/),i=null==s?void 0:s.groups;if(!i)return;const{prefix:a,value:o}=i,l=findMaxLegalPrefixEndIndex({src:o,katex:r});if(shouldStopAutofix(o,l))return;const c=o.slice(0,l).trim(),u=`${e.value.slice(0,n)}${a}`;t(lodash_es_concat(u?{type:"text",value:u}:[],c?{type:"inlineMath",value:c}:[]),!0)}else if("inlineMath"===e.type||"math"===e.type){const n="math"===e.type?e.meta??e.value:e.value,s=findMaxLegalPrefixEndIndex({src:n,katex:r});if(shouldStopAutofix(n,s)){return void t(["inlineMath"===e.type?{type:"text",value:`$${n}$`}:{type:"paragraph",children:[{type:"text",value:`$$${n}$$`}]}],!0)}const i=n.slice(0,s).trim(),a="inlineMath"===e.type?{type:"inlineMath",value:i}:{type:"paragraph",children:[{type:"inlineMath",value:i}]};t(i?[a]:[],!0)}}}}class AutofixHeadingAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_heading",this.config={order:"pre_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n})=>{all_in_one_index_isParent(e)?isHeading(e)&&(1!==e.depth||stringifyChildren(e.children).trim()||t([],!0),n()):n()}}}const all_in_one_index_ellipsisContent="...";class InsertEllipsisAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="insert_ellipsis",this.config={isReverse:!0,priority:AstPluginPriority.After},this.modifier=(e,{insertAfter:t,stop:n})=>{isParentOfContent(e)&&!isTypeOfContent(e,"link")||(n(),isTypeOfContent(e,"text")&&t([{type:"text",value:`${e.value}...`}],!0),isTypeOfContent(e,"link","inlineCode")&&t([{type:"text",value:"..."}],!1))}}}class RemoveBreakBeforeHtmlAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="remove_break_before_html",this.modifier=(e,{parent:t,index:n})=>{if(!isLiteralOfContent(e)||"html"!==e.type||!t||lodash_es_isUndefined(n))return;const r=getByIndex(null==t?void 0:t.children,n-1);r&&"break"===r.type&&t.children.splice(n-1,1)}}}class TransformEndlineBeforeHtmlAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="transform_endline_before_html",this.config={order:"pre_order"},this.modifier=(e,{index:t,parent:n})=>{if(!isLiteralOfContent(e)||"html"!==e.type||!n||!t)return;const r=n.children[t-1];if("text"!==r.type)return;const s=/(\r?\n|\r)$/;s.test(r.value)&&n.children.splice(t-1,1,{type:"text",value:r.value.replace(s,"")},{type:"html",value:"<br />"})}}}class DisableIllegalHtmlAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="disable_illegal_html",this.config={order:"pre_order",isReverse:!0},this.modifier=(e,{insertAfter:t,enabledHtmlTags:n})=>{isLiteralOfContent(e)&&"html"===e.type&&t([{type:"html",value:autoDisableHtmlTag(e.value,n)}],!0)}}}class RestoreMathPandocLatexInContentAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="restore_math_pandoc_latex_in_content",this.config={order:"pre_order"},this.modifier=(e,{insertAfter:t})=>{isLiteralOfContent(e)&&isTypeOfContent(e,"code","inlineCode","math","inlineMath")&&t([{...e,value:restoreMathPandocLatex(e.value)}],!0)}}}const autoSpacingGroupPatterns=[String.raw`\{${"insert_element"}_[0-9]+_.*?\}`];class AutoSpacingAllTextAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="auto_spacing_all_text",this.config={priority:AstPluginPriority.AfterAll,order:"pre_order",isReverse:!0},this.modifier=(e,{insertAfter:t})=>{if(!isTypeOfContent(e,"text"))return;const{value:n}=e;t([{type:"text",value:splitStringByPattern(n,new RegExp(`(${autoSpacingGroupPatterns.map((e=>`(${e})`)).join("|")})`,"g")).map((e=>pangu.spacing(e))).join("")}],!0)}}}class AutofixTruncatedStrongAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_strong",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=[(e,{insertAfter:t,stop:n,parent:r})=>{var s;if(!isTypeOfContent(e,"text")||!r||!isTypeOfContent(r,"paragraph"))return void n();const i=null==(s=e.value.match(/^(?<prefix>[\s\S]*?)(_{2}|\*{2})(?<suffix>[\s\S]*?)\*?$/))?void 0:s.groups;if(!i)return;const{prefix:a,suffix:o}=i,l=[];a&&l.push({type:"text",value:a}),o&&l.push({type:"strong",children:[{type:"text",value:o}]}),t(l,!0)},(e,{stop:t,parent:n,index:r})=>{if(!isParentOfContent(e))return;if(!isTypeOfContent(e,"emphasis")||!n||lodash_es_isUndefined(r))return void t();const s=n.children[r-1];if(!s||!isTypeOfContent(s,"text"))return void t();const i=/(?<prefix>(.*[^\*])|^)\*$/.exec(s.value);if(!i)return void t();const{prefix:a}=i.groups??{},o=[];a&&o.push({type:"text",value:a}),o.push({type:"strong",children:e.children}),n.children.splice(r-1,2,...o)},(e,{stop:t,insertAfter:n})=>{if(isParentOfContent(e)&&"listItem"!==e.type){if("list"===e.type)return!e.children.length||1===e.children.length&&!e.children[0].children.length?(n([],!0),void t()):void 0;t()}}]}}const splitByLastSingleAsterisk=e=>{if(e.includes("*"))for(let t=e.length-1;t>=0;t--){const n=e[t],r=e[t-1],s=e[t+1];if("*"===n&&"*"!==r&&"*"!==s)return[e.slice(0,t),e.slice(t+1)]}};class AutofixTruncatedEmphasisAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_emphasis",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n,parent:r})=>{if(isLiteralOfContent(e)&&r&&isTypeOfContent(r,"paragraph")){if("text"===e.type){const n=splitByLastSingleAsterisk(e.value);if(!n)return;const[r,s]=n,i=[];r&&i.push({type:"text",value:r}),s&&i.push({type:"emphasis",children:[{type:"text",value:s}]}),t(i,!0)}}else n()}}}class AutofixTruncatedListAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_list",this.config={isReverse:!0,fixEndingOnly:!0},this.modifier=[(e,{insertAfter:t,stop:n,index:r,parent:s})=>{if(all_in_one_index_isParent(e))return void(isTypeOfContent(e,"paragraph")||isRoot(e)||n());if(!isTypeOfContent(e,"text"))return void n();if(lodash_es_isUndefined(r)||0!==r||!s||s.children.length>1)return void n();const i=/^(?<prefix>.*)\n\s*(?<value>([0-9]+?\.?)|(\-\s*))$/.exec(e.value);if(i){const{prefix:e}=i.groups??{};t([{type:"text",value:e}],!0)}else/^\s*[0-9]+$/.exec(e.value)&&t([],!0);n()},(e,{insertAfter:t,stop:n,index:r,parent:s,parents:i})=>{if(all_in_one_index_isParent(e))return void(isTypeOfContent(e,"list","listItem","paragraph")||isRoot(e)||n());if(!isTypeOfContent(e,"text"))return void n();if(!(s&&isTypeOfContent(i[0],"paragraph")&&isTypeOfContent(i[1],"listItem")&&isTypeOfContent(i[2],"list")))return void n();if(r!==s.children.length-1)return void n();const a=/^(?<prefix>.*)\n\s*(?<value>[0-9]+?)$/.exec(e.value);if(a){const{prefix:e}=a.groups??{};t([{type:"text",value:e}],!0)}n()}]}}class SetEmphasisAsImageTitleAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="set_emphasis_as_image_title",this.config={order:"pre_order",isReverse:!0},this.modifier=(e,{parent:t,index:n})=>{if(!t||lodash_es_isUndefined(n)||!all_in_one_index_isImage(e))return;const r=getByIndex(t.children,n+1),s=getByIndex(t.children,n+2);if(!r||!s)return;if(!isTypeOfContent(r,"text")||"\n"!==r.value)return;if(!isTypeOfContent(s,"emphasis"))return;const{children:i}=s,{url:a}=e,o=stringifyChildren(i,!0);t.children.splice(n,3,{type:"image",url:a,alt:o})}}}const getStartIndexOfCodeBlockFirstLine=e=>{var t;const n=e.match(/^(?<prefix>[\s]+)```/);return n?(null==(t=n.groups)?void 0:t.prefix.length)??null:null};class SetCodeBlockIndentAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="set_code_block_indent",this.modifier=(e,{source:t,parent:n,insertAfter:r,skip:s})=>{if(all_in_one_index_isParent(e)&&n)return void s();if(!isLiteralOfContent(e))return;if("code"!==e.type)return;const{start:i}=e.position??{};if(!i)return;const{line:a}=i,o=getByIndex(t.split("\n"),a-1),{meta:l,lang:c}=e;if(lodash_es_isUndefined(o))return;const u=getStartIndexOfCodeBlockFirstLine(o);if(null===u)return;const d=`__indent=${u}`,p=l?`${d} ${l}`:d;r([{...e,meta:p,lang:c??"plaintext"}],!0)}}}class RemoveLastEmptyCodeBlockAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="remove_last_empty_code_block",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n})=>{if(!isLiteralOfContent(e))return;if(n(),"code"!==e.type)return;const{value:r,lang:s,meta:i}=e;r||s||i||t([],!0)}}}class CompleteTruncatedLinkSourcePlugin extends BaseSourcePlugin{constructor(){super(...arguments),this.name="complete_truncated_link",this.modifier=({source:e})=>e.replace(/(^|[^!])\[(?<text>[^\]\n]+)\]\([^\)\n]*$/,"$1[$2](#)")}}class CompleteUnpairedCodeBlockSourcePlugin extends BaseSourcePlugin{constructor(){super(...arguments),this.name="complete_unpaired_code_block",this.modifier=({source:e})=>{const t=e.match(/(^|\n)[\s]*?```/g);return t?t.length%2==0?e:`${e.trimEnd()}\n\`\`\``:e}}}class ConvertFullMathPandocLatexSourcePlugin extends BaseSourcePlugin{constructor(){super(...arguments),this.name="convert_full_math_pandoc_latex",this.modifier=({source:e})=>e.replace(/\\\(([\s\S]*?)\\\)/g,((e,t)=>renderInlineMathSpanString(t))).replace(/\\\[([\s\S]*?)\\\]/g,((e,t)=>renderBlockMathSpanString(t)))}}class ConvertEndingMathPandocLatexSourcePlugin extends BaseSourcePlugin{constructor(){super(...arguments),this.name="convert_ending_math_pandoc_latex",this.config={fixEndingOnly:!0},this.modifier=[({source:e,katex:t})=>{if(!t)return e;const n=e.match(/(?<prefix>.*?)\\\((?<ending>[\s\S]*?)$/);if(!(null==n?void 0:n.groups)||lodash_es_isUndefined(n.index))return e;const r=n.groups.ending??"",s=n.groups.prefix??"";if(r.match(/((\\\()|(\\\)))/))return e;const i=r.slice(0,findMaxLegalPrefixEndIndex({src:r,katex:t})).trim();return i?`${s}${renderInlineMathSpanString(i)}`:s},({source:e,katex:t})=>{if(!t)return e;const n=e.match(/(?<prefix>.*?)\\\[(?<ending>[\s\S]*?)$/);if(!(null==n?void 0:n.groups)||lodash_es_isUndefined(n.index))return e;const r=n.groups.ending??"",s=n.groups.prefix??"";if(r.match(/((\\\[)|(\\\]))/))return e;const i=r.slice(0,findMaxLegalPrefixEndIndex({src:r,katex:t})).trim();return i?`${s}${renderBlockMathSpanString(i)}`:s}]}}class RemoveLongSpacesSourcePlugin extends BaseSourcePlugin{constructor(){super(...arguments),this.name="remove_long_spaces",this.modifier=({source:e})=>e.replace(/[ ]{500,}/g,(e=>e.slice(0,500)))}}const getAstPlugins=({astPlugins:e,autoSpacing:t=!0,autolink:n=!0,imageEmphasisTitle:r=!1,indentFencedCode:s=!0,showIndicator:i=!1,showEllipsis:a=!1})=>{let o=[new AutofixTruncatedEscapePlugin,new RemoveLastEmptyCodeBlockAstPlugin,new AutofixLastCodeBlockAstPlugin,new AutofixLastInlineCodeBlockAstPlugin,new AutofixTruncatedTexMathDollarAstPlugin,new AutofixTruncatedImageAstPlugin,new AutofixTruncatedLinkAstPlugin,new AutofixHeadingAstPlugin,new AutofixTruncatedHtmlTagAstPlugin,new AutofixTruncatedStrongAstPlugin,new AutofixTruncatedEmphasisAstPlugin,new AutofixTruncatedListAstPlugin,new RestoreMathPandocLatexInContentAstPlugin,new DisableIllegalHtmlAstPlugin,new RemoveBreakBeforeHtmlAstPlugin,new TransformEndlineBeforeHtmlAstPlugin,new AutoMergeSiblingTextAstPlugin];return n&&o.push(new ExtractCustomAutolinkAstPlugin),t&&o.push(new AutoSpacingAllTextAstPlugin),r&&o.push(new SetEmphasisAsImageTitleAstPlugin),s&&o.push(new SetCodeBlockIndentAstPlugin),a&&o.push(new InsertEllipsisAstPlugin),i&&o.push(new InsertIndicatorAstPlugin),lodash_es_isArray(e)&&o.push(...e),lodash_es_isFunction(e)&&(o=e(o)),o},getSourcePlugins=({sourcePlugins:e})=>{let t=[new RemoveLongSpacesSourcePlugin,new CompleteUnpairedCodeBlockSourcePlugin,new CompleteTruncatedLinkSourcePlugin,new ConvertFullMathPandocLatexSourcePlugin,new ConvertEndingMathPandocLatexSourcePlugin];return lodash_es_isArray(e)&&t.push(...e),lodash_es_isFunction(e)&&(t=e(t)),t},parseMarkdownAndProcessByPlugins=({source:e,astPlugins:t,sourcePlugins:n,parseAst:r=!0,indentedCode:s=!1,insertedElements:i,fixEnding:a,enabledHtmlTags:o,looseTruncateDataSlot:l,removeTruncatedImage:c,katex:u})=>{try{let d,p=e;return i&&(p=addInsertElementSlotToString(p,i)),n&&(p=processSourceByPlugins({source:p,plugins:n,fixEnding:a,katex:u})),r&&(d=parseMarkdown(p,{enableIndentedCode:s})),t&&d&&(d=processAstByPlugins({ast:d,plugins:t,source:p,fixEnding:a,enabledHtmlTags:o,looseTruncateDataSlot:l,removeTruncatedImage:c,katex:u})),{ast:d,source:d?stringifyMarkdown(d):p}}catch(t){return console.error("[Calypso] Process markdown error: ",t),{source:e}}},parseMarkdownAndProcess=({source:e,processAst:t=!0,processSource:n=!0,showEllipsis:r,showIndicator:s,imageEmphasisTitle:i,indentFencedCode:a,indentedCode:o=!1,insertedElements:l,autolink:c,autoSpacing:u,astPlugins:d,sourcePlugins:p,fixEnding:m=!1,enabledHtmlTags:g=!1,looseTruncateDataSlot:h=!1,removeTruncatedImage:f=!1,katex:x})=>{const y=getAstPlugins({autolink:c,autoSpacing:u,imageEmphasisTitle:i,indentFencedCode:a,showEllipsis:r,showIndicator:s,astPlugins:d}),k=getSourcePlugins({sourcePlugins:p});return parseMarkdownAndProcessByPlugins({source:e,astPlugins:t?y:void 0,sourcePlugins:n?k:void 0,parseAst:t,indentedCode:o,insertedElements:l,fixEnding:m,enabledHtmlTags:g,looseTruncateDataSlot:h,removeTruncatedImage:f,katex:x})},useProcessMarkdown=e=>{const{insertedElements:t}=e,n=lodash_es_values(lodash_es_omit(e,["insertedElements","astPlugins","sourcePlugins"]));return (0,react.useMemo)((()=>parseMarkdownAndProcess(e)),[...n,null==t?void 0:t.length])},useEstablished=e=>{const t=(0,react.useRef)(e);return t.current=t.current||e,t.current},usePreviousRef=e=>{const t=(0,react.useRef)(),n=(0,react.useRef)(e);return n.current!==e&&(t.current=n.current,n.current=e),t},useForceUpdate=()=>{const[,e]=(0,react.useReducer)((e=>e+1),0);return e};function useLatestFunction(e){const t=useLatest(e),n=(0,react.useCallback)(((...e)=>{var n;return null==(n=t.current)?void 0:n.call(t,...e)}),[]);return e&&n}const INITIAL_SPEED=.02,EXPECTED_BUFFER_SIZE=15,ELASTIC_COEFFICIENT=1/700/1e3,TICK_DURATION=1e3/60*2,findCommonPrefixLength=(e,t)=>{let n=0,r=Math.max(e.length,t.length);for(;n!==r&&n!==r-1;){const s=Math.floor((n+r)/2);e.slice(0,s)===t.slice(0,s)?n=s:r=s}return n},useSmoothText=(e,t={})=>{const{maxFirstTextSmoothSize:n,trailingSmooth:r,enable:s,pause:i,onSmoothFinished:a,onUpdate:o,onTextBreak:l,maxSpeed:c,expectedBufferSize:u,elasticCoefficient:d,tickDuration:p,initialSpeed:m,breakMode:g}=lodash_es_defaults(lodash_es_isBoolean(t)?{}:{...t},{maxFirstTextSmoothSize:1/0,trailingSmooth:!1,pause:!1,enable:Boolean(t),expectedBufferSize:15,elasticCoefficient:ELASTIC_COEFFICIENT,tickDuration:TICK_DURATION,initialSpeed:.02,breakMode:"prefix"}),h=lodash_es_isNumber(c)&&c>0?c:1/0,f=usePreviousRef(e),x=(0,react.useRef)(e.length<=n?1:e.length),y=(0,react.useRef)(x.current),k=useEstablished(s),T=s||k&&r&&x.current<e.length,[C,v]=(0,react.useState)(!1),E=(0,react.useRef)(m),P=()=>lodash_es_isString(f.current)&&!e.startsWith(f.current);if(P()){let t=0;"start"===g?t=0:"end"===g?t=Math.max(e.length-1,0):"prefix"===g&&(t=Math.max(1,findCommonPrefixLength(f.current??"",e))),x.current=t,y.current=Math.floor(x.current)}const S=y.current,w=T&&!C?e.slice(0,S):e,_=useForceUpdate(),b=e=>{e!==y.current&&(y.current=e,_())},A=useLatestFunction((()=>{v(!0)}));return (0,react.useEffect)((()=>{C&&(b(e.length),v(!1),x.current=e.length)}),[C]),(0,react.useEffect)((()=>{T||null==a||a()}),[T]),es_useInterval((()=>{if(P())null==l||l({prevText:f.current??"",currentText:e}),E.current=m,f.current=void 0;else{const t=Math.max(e.length+(!s&&r?2*u:0),2*u)-x.current,n=d*(t-u);E.current=Math.min(Math.max(0,E.current+p*n),h/1e3);const i=p*E.current;x.current=Math.min(e.length,x.current+i),b(Math.floor(x.current))}}),T&&!i?p:void 0),(0,react.useEffect)((()=>{null==o||o({text:w,speed:1e3*E.current})}),[S]),{text:w,flushCursor:A}},rtlLocaleList=["ae","aeb","ajt","apc","apd","ar","ara","arb","arc","arq","ars","ary","arz","ave","avl","bal","bcc","bej","bft","bgn","bqi","brh","cja","ckb","cld","dcc","dgl","div","drw","dv","fa","fas","fia","fub","gbz","gjk","gju","glk","grc","gwc","gwt","haz","he","heb","hnd","hno","iw","ji","kas","kby","khw","ks","kvx","kxp","kzh","lad","lah","lki","lrc","luz","mde","mfa","mki","mvy","myz","mzn","nqo","oru","ota","otk","oui","pal","pbu","per","pes","phl","phn","pnb","pra","prd","prs","ps","pus","rhg","rmt","scl","sd","sdh","shu","skr","smp","snd","sog","swb","syr","tnf","trw","ug","uig","ur","urd","wni","xco","xld","xmn","xmr","xna","xpr","xsa","ydd","yi","yid","zdj"],retryLoad=(e,t=3,n=1e3)=>new Promise(((r,s)=>{e().then(r).catch((i=>{setTimeout((()=>{1!==t?retryLoad(e,t-1,n).then(r,s):s(i)}),n)}))})),notStringifiedAstType=["code","inlineCode","math","inlineMath"],DETECT_MIN_LENGTH=20,isRTLChar=e=>new RegExp("^[^A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-﷾--]*[֑-߿יִ-﷽ﹰ-ﻼ]").test(e),isRTLOfAstLanguage=async e=>{try{const t=getTextOfAst(e,{filter:e=>!isLiteralOfContent(e)||!notStringifiedAstType.includes(e.type)}).trim(),n=elementAt(t.split("\n"),0);if(!n)return!1;const{franc:r}=await retryLoad((()=>__webpack_require__.e(/* import() */ "691").then(__webpack_require__.bind(__webpack_require__, 51854)))),s=r(n,{minLength:20});return"und"===s?isRTLChar(n.charAt(0)):rtlLocaleList.includes(s)}catch(e){return!1}},useIsRTL=e=>{const[t,n]=(0,react.useState)(!1);return (0,react.useEffect)((()=>{e?(async()=>{const t=await isRTLOfAstLanguage(e);n(t)})():n(!1)}),[e]),t},useHop=({onHop:e,ast:t,text:n,getRenderedText:r})=>{const s=(0,react.useRef)(""),i=es_usePrevious(n),a=es_usePrevious(t);(0,react.useEffect)((()=>{const o=s.current,l=r().trim();if(!lodash_es_isUndefined(o)&&!lodash_es_isUndefined(i)&&!lodash_es_isUndefined(a)&&!lodash_es_isUndefined(t)&&e&&n.length>i.length&&l.length<o.length){const n=getHopDiff(a,t);if(n){const{prevEndNode:r,endNode:s}=n;e({renderedText:l,prevRenderedText:o,ast:t,prevAst:a,prevEndNode:r,endNode:s,prevEndNodeType:convertToStanardNodeTypeEnum(null==r?void 0:r.type),endNodeType:convertToStanardNodeTypeEnum(null==s?void 0:s.type)})}}s.current=l}),[n])},isHTMLElementNode=e=>"undefined"==typeof HTMLElement?e.nodeType===Node.ELEMENT_NODE:e instanceof HTMLElement,replaceToText=e=>{for(const t of e.childNodes)replaceToText(t);if(!isHTMLElementNode(e))return;const{customCopyText:t}=e.dataset;if(!lodash_es_isUndefined(t))return void(e.textContent=t);if("br"===e.tagName.toLowerCase()){const t=document.createElement("span");return t.textContent="\n",void(e.parentElement&&e.parentElement.replaceChild(t,e))}},hasCustomCopyTextElement=e=>Boolean(e.querySelector("[data-custom-copy-text]")),supportClipboard=()=>"undefined"!=typeof navigator&&!lodash_es_isUndefined(navigator.clipboard)&&!lodash_es_isUndefined(navigator.clipboard.read)&&!lodash_es_isUndefined(navigator.clipboard.write)&&"undefined"!=typeof ClipboardItem,parseHtmlToDocumentFragment=e=>{const t=document.createDocumentFragment(),n=document.createElement("div");return n.innerHTML=e,t.append(...n.childNodes),t},useCopy=()=>async()=>{try{const e=window.getSelection();if(!(null==e?void 0:e.rangeCount))return;const t=e.getRangeAt(0).cloneContents();if(!hasCustomCopyTextElement(t)||!supportClipboard())return;const n=await navigator.clipboard.read(),r=lodash_es_head(n);if(assert(r),!r.types.includes("text/html"))return;const s=await r.getType("text/html"),i=await s.text(),a=parseHtmlToDocumentFragment(i);replaceToText(a);const o=a.textContent??"",l=(new XMLSerializer).serializeToString(a);await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([l],{type:"text/html"}),"text/plain":new Blob([o],{type:"text/plain"})})])}catch(e){console.warn("[Calypso] Enhanced replication failed, possibly due to the user's refusal of replication permission. The default replication behavior takes effect, and the original error is:",e)}},isTextType=e=>"text"===e.type,isEndlineText=e=>isTextType(e)&&/^\n+$/.test(getInnerText(e)),isElementType=(e,...t)=>"attribs"in e&&"object"==typeof e.attribs&&("tag"===e.type&&(!(null==t?void 0:t.length)||t.some((t=>lodash_es_isRegExp(t)?t.test(e.name):t===e.name)))),getInnerText=e=>isTextType(e)?e.data:isElementType(e)?e.children.map(getInnerText).join(""):"",detectIsChinese=e=>/[\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u3005\u3007\u3021-\u3029\u3038-\u303B\u3400-\u4DB5\u4E00-\u9FD5\uF900-\uFA6D\uFA70-\uFAD9]/.test(e),renderDom=e=>(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:domToReact([e])}),renderReactElement=(e,t,n)=>"markdown-root"===t.className?(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:n}):(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:(0,react.createElement)(e,t,(null==n?void 0:n.length)?n:void 0)}),createShallowedProvider=e=>{const t=e.Provider;return({value:e,afterMemoedProcess:n,children:r})=>{const s=useCustomMemoValue(e,shallowEqual),i=(0,react.useMemo)((()=>n?n(s):s),[s]);return (0,jsx_runtime.jsx)(t,{value:i,children:r})}},CalypsoConfigContext=(0,react.createContext)({theme:"default",mode:"light"}),CalypsoConfigProvider=createShallowedProvider(CalypsoConfigContext),useCalypsoConfig=()=>(0,react.useContext)(CalypsoConfigContext),CalypsoSlotsInnerContext=(0,react.createContext)(null),CalypsoSlotsInnerProvider=createShallowedProvider$1(CalypsoSlotsInnerContext),useCalypsoSlots=()=>{const e=(0,react.useContext)(CalypsoSlotsInnerContext);if(!e)throw Error("[Calypso Internal Bugs] CalypsoSlotsInnerContext Required");return e},createSlotConsumer=(e,t)=>{const n=n=>{const r=useCalypsoSlots()[e]??t;return r?(0,jsx_runtime.jsx)(r,{...n}):null};return n.displayName=e,n},CalypsoI18nContext=(0,react.createContext)(null),CalypsoI18nProvider=createShallowedProvider(CalypsoI18nContext),AUTO_HIDE_LAST_SIBLING_BR_CLASS="auto-hide-last-sibling-br",BlockElement=({node:e,renderRest:t,style:n,className:r,children:s})=>{const{BreakLine:i}=useCalypsoSlots(),{style:a,className:o,...l}=attributesToProps((null==e?void 0:e.attribs)??{});return (0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[e&&(0,react.createElement)(e.name,{...l,style:{...a,...n},className:classnames(o,r,"auto-hide-last-sibling-br")},...e.children.map(((e,n)=>(0,jsx_runtime.jsx)(react.Fragment,{children:null==t?void 0:t(e)},n)))),lodash_es_isFunction(s)?s({className:classnames("auto-hide-last-sibling-br")}):s,i&&(0,jsx_runtime.jsx)(i,{})]})},ComposedTable=createSlotConsumer("Table"),renderTable=(e,{renderRest:t,parents:n})=>{if(!isElementType(e,"table"))return;const{className:r,...s}=attributesToProps(e.attribs);return (0,jsx_runtime.jsx)(BlockElement,{children:({className:i})=>(0,jsx_runtime.jsx)(ComposedTable,{...s,raw:e,parents:n,className:classnames(r,i),children:domToReact(e.children,{replace:t})})})},ComposedStrong=createSlotConsumer("Strong"),renderStrong=(e,{renderRest:t,parents:n})=>{if(isElementType(e,"strong"))return (0,jsx_runtime.jsx)(ComposedStrong,{node:e,raw:e,parents:n,children:domToReact(e.children,{replace:t})})},ComposedBreakLine=createSlotConsumer("BreakLine"),ComposedBlockquote=createSlotConsumer("Blockquote"),renderSimpleHtml=(e,{renderRest:t,renderHtml:n,renderDataSlot:r,parents:s})=>{if(!isElementType(e))return;const i=e.name.toLowerCase(),a=attributesToProps(e.attribs),o=e.children.length?e.children.map(((e,n)=>(0,jsx_runtime.jsx)(react.Fragment,{children:t(e)},n))):void 0;if(r&&["data-inline","data-block"].includes(i)){const{type:e,value:t,alt:n}=a;return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:r({display:"data-inline"===i?"inline":"block",type:e,value:parseJSONWithNull(he.decode(t,{strict:!1})),alt:n,children:o})??n})}let l;if(n&&(l=null==n?void 0:n({tagName:i,props:a,children:o,node:e,currentHTML:stringifyDomNode(e),childrenHTML:stringifyDomNode(e.childNodes)})),!lodash_es_isUndefined(l))return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:l});if("br"===i)return (0,jsx_runtime.jsx)(ComposedBreakLine,{raw:e,parents:s});if("blockquote"===i)return (0,jsx_runtime.jsx)(ComposedBlockquote,{raw:e,node:e,parents:s,renderRest:t});if("hr"===i)return (0,jsx_runtime.jsx)(BlockElement,{node:e,renderRest:t});if(1===e.children.length){const t=e.children[0];if(isTextType(t)&&!t.data.trim())return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{})}return renderReactElement(i,a,o)},ComposedParagraph=createSlotConsumer("Paragraph"),renderParagraph=(e,{renderRest:t,forceBrInterSpacing:n,parents:r})=>{if(!isElementType(e,"p"))return;const{className:s,...i}=attributesToProps(e.attribs);return (0,jsx_runtime.jsx)(BlockElement,{children:({className:a})=>(0,jsx_runtime.jsx)(ComposedParagraph,{...i,raw:e,parents:r,className:classnames(s,a),forceBrInterSpacing:n,children:domToReact(e.children,{replace:t})})})},ComposedTex=createSlotConsumer("Tex"),renderMath=(e,t={})=>{const{parents:n}=t;if(!isElementType(e,"span"))return;const r=e.attribs["data-type"],s=e.attribs["data-value"];if(s)try{const t=node_modules_buffer.Buffer.from(s,"base64").toString("utf8").trim();if("block-math"===r)return (0,jsx_runtime.jsx)(ComposedTex,{raw:e,parents:n,tex:t,mode:"display"});if("inline-math"===r)return (0,jsx_runtime.jsx)(ComposedTex,{raw:e,parents:n,tex:t,mode:"inline"})}catch(e){return void console.error("[Math Render Error]",e)}},ComposedList=createSlotConsumer("List"),all_in_one_index_renderList=(e,{renderRest:t,parents:n})=>{if(!isElementType(e,"ol","ul"))return;const r=e.children.every((e=>isTextType(e)||isElementType(e,"li")&&!lodash_es_isUndefined(e.children[0])&&isElementType(e.children[0],"input")&&"checkbox"===e.children[0].attribs.type))?"tasklist":void 0;return (0,jsx_runtime.jsx)(ComposedList,{className:r,node:e,raw:e,parents:n,renderRest:t})},ComposedLink=createSlotConsumer("Link"),renderLink=(e,{renderRest:t,customLink:n,callbacks:r={},parents:s})=>{if(!isElementType(e,"a"))return;const{href:i,title:a,...o}=e.attribs,l="autolink"===a;return (0,jsx_runtime.jsx)(ComposedLink,{...attributesToProps(o),raw:e,parents:s,href:i,customLink:n,type:l?"autolink":"markdown",title:l?void 0:a,...lodash_es_pick(r,"onLinkRender","onLinkClick","onSendMessage"),children:domToReact(e.children,{replace:t})})},renderInsertElement=(e,t)=>{var n;const{insertedElements:r=[]}=t;if(!isElementType(e,"span"))return;if("insert_element_extension"!==e.attribs["data-type"])return;const s=e.attribs["data-index"],i=e.attribs["data-raw"];if(lodash_es_isUndefined(s))return;const a=parseInt(s);return a>r.length||null==(n=r[a])?void 0:n.render(i&&node_modules_buffer.Buffer.from(i,"base64").toString("utf-8"))},ComposedIndicator=createSlotConsumer("Indicator"),renderIndicator=(e,t={})=>{var n;const{parents:r}=t;if(isElementType(e,"span")&&"indicator"===(null==(n=e.attribs)?void 0:n.class))return (0,jsx_runtime.jsx)(ComposedIndicator,{raw:e,parents:r})},ComposedImage=createSlotConsumer("Image"),hasSiblingText=(e,t={})=>{const{regardSiblingBrAsText:n=!0}=t,r={hasLeftText:!1,hasRightText:!1};if(!e.parent)return r;const{children:s}=e.parent,i=s.indexOf(e);if(i<0)return r;const a=e=>e<s.length&&e>=0&&(isTextType(s[e])||!!n&&isElementType(s[e],"br"));return{hasLeftText:a(i-1),hasRightText:a(i+1)}},renderImage=(e,t={})=>{const{callbacks:n={},imageOptions:r,marginWithSiblingBr:s=!0,parents:i}=t,{onImageRender:a,onImageClick:o}=n;if(!isElementType(e,"img"))return;const{src:l,alt:c,width:u,height:d}=e.attribs,p=Number(u),m=Number(d),{hasLeftText:g,hasRightText:h}=hasSiblingText(e,{regardSiblingBrAsText:s});return (0,jsx_runtime.jsx)(ComposedImage,{...attributesToProps(e.attribs),raw:e,parents:i,src:safeParseUrl(l)&&l,onImageClick:o,onImageRender:a,imageOptions:{alt:c,objectFit:"cover",objectPosition:"center",height:isNaN(m)?256:m,width:isNaN(p)?400:p,...r},style:{borderRadius:12,overflow:"hidden"},wrapperStyle:{marginTop:g?12:void 0,marginBottom:h?12:void 0},...n})},header$1="_header_1rhdj_1",styles$d={header:header$1},ComposedHeader=createSlotConsumer("Header"),all_in_one_index_renderHeader=(e,{renderRest:t,parents:n})=>{if(isElementType(e,/^h[0-9]+$/))return (0,jsx_runtime.jsx)(ComposedHeader,{className:styles$d.header,node:e,raw:e,parents:n,renderRest:t})},ComposedEmphasis=createSlotConsumer("Emphasis"),renderEm=(e,{renderRest:t,spacingAfterChineseEm:n,parents:r})=>{if(!isElementType(e,"em"))return;const s=void 0!==n&&!1!==n&&detectIsChinese(getInnerText(e).slice(-1)??"")&&!lodash_es_isNull(e.nextSibling)&&(isElementType(e.nextSibling)||isTextType(e.nextSibling))&&detectIsChinese(getInnerText(e.nextSibling).slice(0,1)??"");return (0,jsx_runtime.jsx)(ComposedEmphasis,{style:{marginRight:s?"boolean"==typeof n?2:n:void 0},node:e,raw:e,parents:r,children:domToReact(e.children,{replace:t})})},renderDanger=e=>{if("tag"!==e.type&&"text"!==e.type&&"root"!==e.type)return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{})},DEFAULT_LANGUAGE="plaintext",getCodeElement=e=>isElementType(e,"code")?e:isElementType(e,"pre")?e.childNodes.find((e=>isElementType(e,"code"))):void 0,getLanguageFromElement=(e,t="plaintext")=>{var n,r,s;const i=getCodeElement(e);return i&&(null==(s=null==(r=null==(n=i.attribs)?void 0:n.class)?void 0:r.match(/language-(.*)/))?void 0:s[1])||t},getMetaFromElement=(e,t=!0)=>{const n=getCodeElement(e),r=null==n?void 0:n.attribs["data-meta"];if(r)return t?r.split(/\s+/).filter((e=>!e.match(/^__[^_].*/))).join(" ")||void 0:r},getIndentFromCodeElememt=e=>{var t;const n=getMetaFromElement(e,!1);if(!n)return 0;const r=n.match(/(\s|^)__indent=(?<indent>[0-9]+)(\s|$)/);if(!r)return 0;const s=Number(null==(t=r.groups)?void 0:t.indent);return isNaN(s)?0:s},HIDE_HEADER_LANGUAGES=["result","stderr","stdout"],styles$c={"code-group-item--begin":"_code-group-item--begin_1wdrc_1","code-group-item--center":"_code-group-item--center_1wdrc_5","code-group-item--end":"_code-group-item--end_1wdrc_8"},INDENT_WIDTH=18,ComposedCodeBlock=createSlotConsumer("CodeBlock"),isCodeBlockElement=e=>{if(!isElementType(e,"pre"))return!1;const{childNodes:t}=e;return!!t.find((e=>isElementType(e,"code")))},EmptyWrapperElement=({children:e})=>(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:e()}),renderCodeBlocks=(e,t)=>{const{autoHideCodeHeaderLanguage:n=HIDE_HEADER_LANGUAGES,renderRest:r,parents:s,callbacks:i={},indentTabs:a=0,loading:o}=t,{onCopyCodeBlock:l}=i,c=Array.isArray(n)?n:[n],u=BlockElement;return (0,jsx_runtime.jsx)(EmptyWrapperElement,{children:({className:t}={className:""})=>e.map((({target:n},i)=>{if(!isCodeBlockElement(n))return null;const d=styles$c["code-group-item--"+(e.length,"normal")],{childNodes:p=[]}=n;return p.map(((e,n)=>(0,jsx_runtime.jsx)(u,{children:()=>{if(isElementType(e,"code")){const t=getLanguageFromElement(e),r=getMetaFromElement(e);return (0,jsx_runtime.jsx)(ComposedCodeBlock,{parents:s,code:getInnerText(e),language:t,meta:r,showHeader:!c.includes(t.toLowerCase()),className:d,onCopyCode:l,style:{marginLeft:a?18*a+"px":void 0},loading:o},n)}return isElementType(e)?(0,jsx_runtime.jsx)("pre",{className:t,children:r(e)},n):(0,jsx_runtime.jsx)("pre",{className:t,children:domToReact([e])},n)}})))}))})},splitToCodeBlockGroup=({children:e,adjacentCodeAsGroup:t=!0})=>{const n=[];let r=null;for(const s of e)if(isCodeBlockElement(s)){const e=elementAt(n,n.length-1),r={target:s,language:getLanguageFromElement(s,""),code:innerText(s)};(null==e?void 0:e.isCodeBlockGroup)&&t?e.codeBlocks.push(r):n.push({isCodeBlockGroup:!0,codeBlocks:[r]})}else isEndlineText(s)?r=s:(r&&(n.push({isCodeBlockGroup:!1,target:r,code:innerText(r)}),r=null),n.push({isCodeBlockGroup:!1,target:s,code:isElementType(s)||isTextType(s)?innerText(s):""}));return n},renderCodeBlock=(e,{renderRest:t,adjacentCodeAsGroup:n,callbacks:r={}})=>{if(!isElementType(e))return;const{childNodes:s}=e;if(s.every((e=>!isCodeBlockElement(e))))return;const i=splitToCodeBlockGroup({children:s,adjacentCodeAsGroup:n});return renderReactElement(e.name,attributesToProps(e.attribs),i.map(((e,n)=>{if(e.isCodeBlockGroup){const{codeBlocks:s}=e,a=n===i.length-1,o=Math.min(8,...s.map((e=>Math.floor(getIndentFromCodeElememt(e.target)/2))));return renderCodeBlocks(s,{renderRest:t,callbacks:r,indentTabs:o,loading:a,autoHideCodeHeaderLanguage:[]})}return (0,jsx_runtime.jsx)(react.Fragment,{children:t(e.target)},n)})))},renderCustomNode=(e,t={})=>{const{parents:n=[],callbacks:r={},insertedElements:s,imageOptions:i,adjacentCodeAsGroup:a,forceBrInterSpacing:o,spacingAfterChineseEm:l,customLink:c,renderHtml:u,renderRawHtml:d,renderDataSlot:p}=t,m=r=>renderCustomNode(r,{...t,parents:[e,...n]}),g=isElementType(e)?e.name.toLowerCase():"",h=isElementType(e)?attributesToProps(e.attribs):{};return(()=>{if(d&&isElementType(e))return d({tagName:g,props:h,parents:n,renderRest:m,node:e,currentHTML:stringifyDomNode(e),childrenHTML:stringifyDomNode(e.children)})})()??renderMath(e,{parents:n})??(s&&renderInsertElement(e,{insertedElements:s}))??renderDanger(e)??renderLink(e,{callbacks:r,customLink:c,parents:n,renderRest:m})??renderImage(e,{callbacks:r,imageOptions:i,marginWithSiblingBr:!o,parents:n})??renderCodeBlock(e,{adjacentCodeAsGroup:a,callbacks:r,renderRest:m})??renderIndicator(e,{parents:n})??renderParagraph(e,{forceBrInterSpacing:o,parents:n,renderRest:m})??renderTable(e,{parents:n,renderRest:m})??all_in_one_index_renderList(e,{parents:n,renderRest:m})??all_in_one_index_renderHeader(e,{parents:n,renderRest:m})??renderEm(e,{parents:n,renderRest:m,spacingAfterChineseEm:l})??renderStrong(e,{parents:n,renderRest:m})??renderSimpleHtml(e,{parents:n,renderRest:m,renderDataSlot:p,renderHtml:u})??renderDom(e)},wrapHtmlByMarkdownRoot=e=>`<div class="markdown-root">${e}</div>`,Markdown=({markDown:e,smartypants:t=!1,enabledHtmlTags:n,purifyHtml:r=!0,purifyHtmlConfig:s,modifyHtmlNode:i,...a})=>{const o=(0,react.useMemo)((()=>new CalypsoTokenizer),[]),l=useDeepCompareMemo((()=>getCalypsoRenderer({enabledHtmlTags:n})),[n]),c=useDeepCompareMemo((()=>{const e=new Marked({extensions:[insertElementSlotExtension(),inlineTex(),displayTex()]});return e.setOptions({gfm:!0,silent:!0,breaks:!0}),e.use({extensions:[insertElementSlotExtension(),inlineTex(),displayTex()]}),e.use(mangle()),t&&e.use(markedSmartypants()),e}),[t,n]),u=pipe((e=>c.parse(e,{tokenizer:o,renderer:l})),transformSelfClosing,(e=>{const t=(()=>{const e=lodash_es_isArray(n)?n:void 0,t={ALLOW_UNKNOWN_PROTOCOLS:!0,RETURN_DOM:!1};e&&(t.ADD_TAGS=e);const r=lodash_es_isFunction(s)?s(t):s;if(r){const{ALLOW_UNKNOWN_PROTOCOLS:e,RETURN_DOM:n,...s}=r;lodash_es_isUndefined(e)||(t.ALLOW_UNKNOWN_PROTOCOLS=e),lodash_es_isUndefined(n)||(t.RETURN_DOM=n),lodash_es_assign(t,s)}return t})();return lodash_es_isFunction(r)?r(e,t):r?purifyHtml(e,t):e}),wrapHtmlByMarkdownRoot),d=(0,react.useMemo)((()=>u(e)),[e,c]),p=(0,react.useMemo)((()=>{const e=htmlToDOM(d);return(null==i?void 0:i(e))??e}),[d]);return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:domToReact(p,{replace:e=>renderCustomNode(e,a)})})},container$6="_container_7mgzw_1",all_in_one_index_active="_active_7mgzw_7",blink="_blink_7mgzw_35",all_in_one_index_frame="_frame_7mgzw_631",all_in_one_index_enabled="_enabled_7mgzw_792",cursorAnimation="_cursorAnimation_7mgzw_1",styles$b={container:container$6,active:all_in_one_index_active,blink:blink,"no-list":"_no-list_7mgzw_553",frame:all_in_one_index_frame,"align-center":"_align-center_7mgzw_654","align-right":"_align-right_7mgzw_669","float-left":"_float-left_7mgzw_684","float-right":"_float-right_7mgzw_693",enabled:all_in_one_index_enabled,cursorAnimation:cursorAnimation},CalypsoSlotsContext=(0,react.createContext)(null);createShallowedProvider$1(CalypsoSlotsContext);const emptySlots={BreakLine:null,Tex:null,CodeBlockHighlighter:null,CodeBlock:null,Table:null,Image:null,Indicator:null,Paragraph:null,Link:null,Emphasis:null,Strong:null,Header:null,List:null,Blockquote:null},MarkdownEngine=(0,react.forwardRef)((function({className:e,style:t,mode:n="light",markDown:r,eventCallbacks:s,showIndicator:i=!1,autoFixSyntax:a=!0,smooth:o=!1,insertedElements:l=[],showEllipsis:c=!1,imageOptions:u,autoFitRTL:d=!1,forceBrInterSpacing:p,spacingAfterChineseEm:m=2,indentFencedCode:g,indentedCode:h,smartypants:f,enhancedCopy:x=!1,autolink:y,customLink:k,autoSpacing:T,slots:C={},translate:v={},enabledHtmlTags:E,purifyHtml:P,purifyHtmlConfig:S,astPlugins:w,sourcePlugins:_,modifyHtmlNode:b,renderHtml:A,renderRawHtml:L,renderDataSlot:R,onAstChange:N,onHop:I,...M},$){const H=(0,react.useContext)(CalypsoSlotsContext),B={...emptySlots,...H,...C},j={theme:"default",mode:n},{Indicator:O}=B,{text:F,flushCursor:D}=useSmoothText(r,o),{katex:z,autoFixEnding:U,imageEmphasisTitle:q}=lodash_es_defaults(lodash_es_isBoolean(a)?{}:a,{autoFixEnding:!1}),Z=(0,react.useMemo)((()=>R&&!0!==E?[...E||[],"data-block","data-inline"]:E),[E,Boolean(R)]),{source:W,ast:V}=useProcessMarkdown({source:F,processAst:Boolean(a),showEllipsis:c,showIndicator:i,imageEmphasisTitle:q,indentFencedCode:g,indentedCode:h,insertedElements:l,autolink:y,autoSpacing:T,astPlugins:w,sourcePlugins:_,fixEnding:U,enabledHtmlTags:Z,looseTruncateDataSlot:Boolean(R),katex:z}),G=useIsRTL(d?V:void 0),K=useCopy(),X=(0,react.useRef)(null);useHop({onHop:I,ast:V,text:F,getRenderedText:()=>{var e;return(null==(e=X.current)?void 0:e.textContent)??""}}),(0,react.useEffect)((()=>{null==N||N(V)}),[V]),(0,react.useImperativeHandle)($,(()=>({getRootElement:()=>X.current,flushSmoothCursor:D})),[]);return W.trim()?(0,jsx_runtime.jsx)(CalypsoConfigProvider,{value:j,children:(0,jsx_runtime.jsx)(CalypsoSlotsInnerProvider,{value:B,afterMemoedProcess:e=>e?{...e}:e,children:(0,jsx_runtime.jsx)(CalypsoI18nProvider,{value:v,children:(0,jsx_runtime.jsx)("div",{...M,ref:X,"theme-mode":n,className:classnames(styles$b.container,"flow-markdown-body",styles$b[`theme-${j.theme}`],e),style:t,dir:G?"rtl":"ltr","data-show-indicator":i,onCopy:x?K:void 0,children:(0,jsx_runtime.jsx)(Markdown,{markDown:W,callbacks:s,insertedElements:l,imageOptions:u,forceBrInterSpacing:p,spacingAfterChineseEm:m,smartypants:f,customLink:k,enabledHtmlTags:Z,purifyHtml:P,purifyHtmlConfig:S,modifyHtmlNode:b,renderHtml:A,renderRawHtml:L,renderDataSlot:R})})})})}):(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[c&&"...",i&&O&&(0,jsx_runtime.jsx)(O,{})]})})),CalypsoCore=(0,react.forwardRef)((function({plugins:e=[],slots:t={},astPlugins:n=[],sourcePlugins:r=[],modifyHtmlNode:s,renderHtml:i,renderRawHtml:a,...o},l){const c=(0,react.useMemo)((()=>aggregatePlugins(e)),[e]),u=(0,react.useMemo)((()=>({...c.slots,...t})),[t,c.slots]);function d(e){return e?"function"==typeof e?e([]):e:[]}const p=[...d(n),...c.astPlugins],m=[...d(r),...c.sourcePlugins],g=c.modifyHtmlNode||s,h=c.renderHtml||i,f=c.renderRawHtml||a;return (0,jsx_runtime.jsx)(MarkdownEngine,{ref:l,slots:u,astPlugins:p,sourcePlugins:m,modifyHtmlNode:g,renderHtml:h,renderRawHtml:f,...o})}));function composeModifyHtmlNode(e){if(e.length)return t=>{let n=t;return e.forEach((e=>{const t=e(n);t&&(n=t)})),n}}function composeRenderer(e){if(e.length)return t=>{for(const n of e){const e=n(t);if(null!=e)return e}}}function aggregatePlugins(e){let t={};const n=[],r=[],s=[],i=[],a=[];return e.forEach((e=>{var o,l;e.slots&&(t={...t,...e.slots}),(null==(o=e.astPlugins)?void 0:o.length)&&n.push(...e.astPlugins),(null==(l=e.sourcePlugins)?void 0:l.length)&&r.push(...e.sourcePlugins),e.modifyHtmlNode&&s.push(e.modifyHtmlNode),e.renderHtml&&i.push(e.renderHtml),e.renderRawHtml&&a.push(e.renderRawHtml)})),{slots:t,astPlugins:n,sourcePlugins:r,modifyHtmlNode:composeModifyHtmlNode(s),renderHtml:composeRenderer(i),renderRawHtml:composeRenderer(a)}}const LightTex=({tex:e,mode:t,className:n,style:r})=>(0,jsx_runtime.jsx)("span",{className:classnames("math-inline",n),style:r,children:e}),texLightPlugin={name:"tex-light",slots:{Tex:LightTex}},styles$a={"table-container":"_table-container_18bux_1"},all_in_one_index_Table=({children:e,className:t,raw:n,parents:r,...s})=>(0,jsx_runtime.jsx)("div",{className:classnames(t,styles$a["table-container"]),...s,children:(0,jsx_runtime.jsx)("table",{children:e})}),tablePlugin={name:"table",slots:{Table:all_in_one_index_Table}},Strong=({className:e,style:t,children:n})=>(0,jsx_runtime.jsx)("strong",{className:e,style:t,children:n}),strongPlugin={name:"strong",slots:{Strong:Strong}},all_in_one_index_paragraph="_paragraph_1b2re_1",styles$9={paragraph:all_in_one_index_paragraph},all_in_one_index_Paragraph=({children:e,className:t,forceBrInterSpacing:n=!1,raw:r,parents:s,...i})=>(0,jsx_runtime.jsx)("div",{className:classnames(t,styles$9.paragraph,"paragraph-element",{"br-paragraph-space":n}),...i,children:(0,react.isValidElement)(e)?(0,react.cloneElement)(e,{key:"0"}):e}),paragraphPlugin={name:"paragraph",slots:{Paragraph:all_in_one_index_Paragraph}},all_in_one_index_List=({className:e,style:t,node:n,children:r,renderRest:s})=>(0,jsx_runtime.jsx)(BlockElement,{className:e,style:t,node:n,renderRest:s,children:r}),listPlugin={name:"list",slots:{List:all_in_one_index_List}},all_in_one_index_link="_link_eyymc_1",styles$8={link:all_in_one_index_link},isHttpLink=e=>{const t=safeParseUrl(e);return!!t&&("http:"===t.protocol||"https:"===t.protocol)},all_in_one_index_Link=({className:e,style:t,href:n,children:r,customLink:s=!0,onLinkClick:i,onLinkRender:a,onOpenLink:o,type:l,raw:c,parents:u,...d})=>{const p=n?safeParseUrl(n):null,m=useComputeValue((()=>!!n&&(!!isHttpLink(n)||(lodash_es_isFunction(s)?s(n):s)))),g=e=>{o?null==o||o(e):window.open(e)};return (0,react.useEffect)((()=>{n&&p&&(null==a||a({url:n,parsedUrl:p}))}),[n]),m?(0,jsx_runtime.jsx)("a",{...lodash_es_omit(d,"href"),className:classnames(styles$8.link,e),style:t,onClick:e=>{n&&p?isHttpLink(n)&&(i?i(e,{url:n,parsedUrl:p,exts:{type:LinkType.normal},openLink:g}):(e.preventDefault(),e.stopPropagation(),g(n))):e.preventDefault()},href:p?n:void 0,target:"_blank",children:r}):(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:r})},linkPlugin={name:"link",slots:{Link:all_in_one_index_Link}},styles$7={},all_in_one_index_Indicator=({className:e,style:t})=>(0,jsx_runtime.jsx)("span",{className:styles$7.container,children:(0,jsx_runtime.jsx)("span",{className:classnames(styles$7.indicator,styles$7.flashing,e),style:t,"data-testid":"indicator"})}),indicatorPlugin={name:"indicator",slots:{Indicator:all_in_one_index_Indicator}},all_in_one_index_SvgIconError=e=>react.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},react.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 21.375C6.82233 21.375 2.625 17.1777 2.625 12C2.625 6.82233 6.82233 2.625 12 2.625C17.1777 2.625 21.375 6.82233 21.375 12C21.375 17.1777 17.1777 21.375 12 21.375ZM0.75 12C0.75 5.7868 5.7868 0.75 12 0.75C18.2132 0.75 23.25 5.7868 23.25 12C23.25 18.2132 18.2132 23.25 12 23.25C5.7868 23.25 0.75 18.2132 0.75 12ZM11.9911 13.6761C11.3638 13.6761 11.0393 13.3623 11.0174 12.7348L10.8752 7.87488C10.8606 7.55381 10.9591 7.29476 11.1706 7.09774C11.3821 6.89342 11.6519 6.79126 11.9801 6.79126C12.3083 6.79126 12.5818 6.89342 12.8006 7.09774C13.0194 7.30206 13.1215 7.56475 13.107 7.88583L12.9429 12.7238C12.921 13.3587 12.6037 13.6761 11.9911 13.6761ZM11.9911 17.1349C11.6483 17.1349 11.3529 17.0255 11.1049 16.8066C10.8642 16.5877 10.7439 16.3104 10.7439 15.9747C10.7439 15.639 10.8642 15.3617 11.1049 15.1428C11.3456 14.9239 11.641 14.8144 11.9911 14.8144C12.3412 14.8144 12.6365 14.9239 12.8772 15.1428C13.1252 15.3617 13.2492 15.639 13.2492 15.9747C13.2492 16.3177 13.1252 16.5986 12.8772 16.8175C12.6365 17.0291 12.3412 17.1349 11.9911 17.1349Z",fill:"#999999"})),container$5="_container_hux85_1",centered="_centered_hux85_8",all_in_one_index_image="_image_hux85_11",fallbackIcon="_fallbackIcon_hux85_30",square="_square_hux85_40",all_in_one_index_clickable="_clickable_hux85_45",all_in_one_index_title="_title_hux85_48",styles$6={container:container$5,centered:centered,image:all_in_one_index_image,"loading-image":"_loading-image_hux85_16","error-wrapper":"_error-wrapper_hux85_21",fallbackIcon:fallbackIcon,"image-wrapper":"_image-wrapper_hux85_35",square:square,clickable:all_in_one_index_clickable,title:all_in_one_index_title},convertHttpToHttps=e=>{const t=new URL(e);return"http:"===t.protocol&&(t.protocol="https:"),t.toString()},all_in_one_index_Image=({className:e,style:t,raw:n,parents:r,wrapperClassName:s,wrapperStyle:i,src:a=null,otherFormatSrc:o,onImageClick:l,onImageRender:c,imageOptions:u={layout:"intrinsic",objectFit:"contain"},errorClassName:d,children:p,onImageLoadComplete:m,useCustomPlaceHolder:g=!1,customPlaceHolder:h,onImageContextMenu:f,onImageMouseEnter:x,...y})=>{const{squareContainer:k=!1,forceHttps:T=!1,responsiveNaturalSize:C=!1,width:v=400,height:E=256,showTitle:P=!1,centered:S=!1,...w}=u,{alt:_}=u,[b,A]=(0,react.useState)(v),[L,R]=(0,react.useState)(E);(0,react.useEffect)((()=>{(v||E)&&(A(v),R(E))}),[v,E]);const{minHeight:N,minWidth:I,maxHeight:M,maxWidth:$}=lodash_es_defaults(lodash_es_isBoolean(C)?{}:{...C},{minHeight:0,minWidth:0,maxWidth:v??400,maxHeight:E??256}),H=a&&(T?convertHttpToHttps(a):a),[B,j]=(0,react.useState)(ImageStatus.Loading),O=B!==ImageStatus.Loading,F={src:H,status:B},D=(C||g)&&!O;(0,react.useEffect)((()=>{H&&(null==c||c(F))}),[H]);const z=lodash_es_isNumber(b)&&lodash_es_isNumber(L)&&{width:"100%",height:0,paddingBottom:`min(${L/b*100}%, ${L}px)`,maxWidth:b};return (0,jsx_runtime.jsxs)("div",{className:classnames(styles$6.container,{[styles$6.centered]:S}),style:i,children:[(0,jsx_runtime.jsx)("div",{onClick:e=>{l&&F&&(l(e,F),e.stopPropagation())},className:classnames(styles$6["image-wrapper"],{[styles$6.clickable]:Boolean(l),[styles$6.square]:k},s),style:{...z},"data-testid":"calypso_image",children:p||(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[C&&!O&&!g&&(0,jsx_runtime.jsx)("span",{className:styles$6["loading-image"],children:(0,jsx_runtime.jsx)(Viewer,{...y,...w,height:L,width:b,placeholder:"skeleton",src:""})}),(0,jsx_runtime.jsx)("span",{style:{display:"inline-block",...D?{width:0,height:0}:{}},children:(0,jsx_runtime.jsx)(Viewer,{...y,...w,onContextMenu:f,onMouseEnter:x,height:L,width:b,alt:"image",src:H??"",formats:["avif","webp"],placeholder:"skeleton",loader:({extra:{origin:e},format:t})=>(null==o?void 0:o.avifSrc)&&"avis"===t?null==o?void 0:o.avifSrc:(null==o?void 0:o.webpSrc)&&"awebp"===t?null==o?void 0:o.webpSrc:H??e,error:(0,jsx_runtime.jsx)("div",{className:classnames(styles$6["error-wrapper"],d,"error-wrapper"),ref:()=>{j(ImageStatus.Failed),null==m||m()},children:(0,jsx_runtime.jsx)(all_in_one_index_SvgIconError,{className:styles$6.fallbackIcon})}),onLoadingComplete:e=>{var t;j(ImageStatus.Success),null==m||m();const{naturalWidth:n,naturalHeight:r}=e;if(C&&n&&r){const e=resizeImage({width:n,height:r,minHeight:N,minWidth:I,maxHeight:M,maxWidth:$});A(e.width),R(e.height)}null==(t=w.onLoadingComplete)||t.call(w,e)},className:classnames(e,styles$6.image),style:t})}),g&&!O&&h]})}),P&&_&&(0,jsx_runtime.jsx)("div",{className:styles$6.title,children:_})]})},imagePlugin={name:"samantha-image",slots:{Image:all_in_one_index_Image}},all_in_one_index_Header=({className:e,style:t,node:n,children:r,renderRest:s})=>(0,jsx_runtime.jsx)(BlockElement,{className:e,style:t,node:n,renderRest:s,children:r}),headerPlugin={name:"header",slots:{Header:all_in_one_index_Header}},Emphasis=({className:e,style:t,children:n})=>(0,jsx_runtime.jsx)("em",{className:e,style:t,children:n}),emphasisPlugin={name:"emphasis",slots:{Emphasis:Emphasis}};let fullLanguages=null;const fetchFullLanguagePacks=async()=>{if(!fullLanguages){const{languages:e=null}=await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 847, 19));fullLanguages=e}return fullLanguages},useLanguagePack=e=>{const[t,n]=(0,react.useState)(fullLanguages||prism.languages);return (0,react.useEffect)((()=>{t[e]||(async()=>{const e=await fetchFullLanguagePacks();e&&e!==t&&n(e)})()}),[t,e]),t[e]||t.plaintext},useHighLight=(e,t)=>{const n=t.toLowerCase(),r=useLanguagePack(n);return (0,react.useMemo)((()=>{try{return (0,prism.highlight)(e,r,n)}catch(t){return console.error("Fail to highlight code by prism",t),e}}),[n,e,r])},container$4="_container_g7n3b_57",dark$1="_dark_g7n3b_176",styles$5={container:container$4,dark:dark$1},PrismCodeBlockHighlighter=({code:e,language:t="",className:n,style:r,dark:s=!1})=>{const i=useHighLight(e,t);return (0,jsx_runtime.jsx)("pre",{className:classnames(styles$5.container,n,t&&`language-${t}`,{[styles$5.dark]:s}),style:r,children:(0,jsx_runtime.jsx)("code",{className:t&&`language-${t}`,dangerouslySetInnerHTML:{__html:purifyHtml(i)}})})},index$2=Object.freeze(Object.defineProperty({__proto__:null,PrismCodeBlockHighlighter:PrismCodeBlockHighlighter,default:PrismCodeBlockHighlighter},Symbol.toStringTag,{value:"Module"})),codeHighlighterPrismPlugin={name:"code-highlighter-prism",slots:{CodeBlockHighlighter:PrismCodeBlockHighlighter}},detectLanguage=e=>{},PLAIN_TEXT="plaintext",useAutoDetectLanguage=(e,t=PLAIN_TEXT)=>{const[n,r]=(0,react.useState)(t);return (0,react.useEffect)((()=>{r(t)}),[t]),(0,react.useEffect)((()=>{(async()=>{if(n===PLAIN_TEXT){const e=await detectLanguage();e&&r(e)}})()}),[e,n]),n},SvgDoneIcon=e=>react.createElement("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},react.createElement("path",{d:"M9.2267 16.1272L19.9535 5.40038C20.4274 4.92644 21.1958 4.92644 21.6698 5.40038C22.1437 5.87432 22.1437 6.64272 21.6698 7.11666L10.0848 18.7016C9.61091 19.1755 8.8425 19.1755 8.36856 18.7016L2.36156 12.6946C1.88762 12.2207 1.88762 11.4522 2.36156 10.9783C2.8355 10.5044 3.6039 10.5044 4.07784 10.9783L9.2267 16.1272Z",fill:"currentColor"})),SvgCopyIcon=e=>react.createElement("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},react.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21.5 3.5V17C21.5 18.1046 20.6046 19 19.5 19H17.5V21C17.5 22.1046 16.5406 23 15.3571 23H4.64286C3.45939 23 2.5 22.1046 2.5 21V7.5C2.5 6.39543 3.45939 5.5 4.64286 5.5H6.5V3.5C6.5 2.39543 7.39543 1.5 8.5 1.5H19.5C20.6046 1.5 21.5 2.39543 21.5 3.5ZM8.5 5.5H15.3571C16.5406 5.5 17.5 6.39543 17.5 7.5V17H19.5V3.5H8.5V5.5ZM15.3571 7.5H4.64286L4.64286 21H15.3571V7.5Z",fill:"currentColor"})),SvgCodeIcon=e=>react.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},react.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 9V15H5.2V9H7ZM7 8V16H5C4.44771 16 4 15.7015 4 15.3333V8.66667C4 8.29848 4.44771 8 5 8H7Z",fill:"currentColor"}),react.createElement("path",{d:"M8.5 10L11.5 12L8.5 14",stroke:"currentColor",strokeLinejoin:"bevel"}),react.createElement("path",{d:"M15.5 15H11.5",stroke:"currentColor",strokeLinejoin:"bevel"}),react.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17 9V15H18.8V9H17ZM17 8V16H19C19.5523 16 20 15.7015 20 15.3333V8.66667C20 8.29848 19.5523 8 19 8H17Z",fill:"currentColor"})),container$3="_container_vmcsy_1",dark="_dark_vmcsy_13",all_in_one_index_header="_header_vmcsy_32",all_in_one_index_text="_text_vmcsy_44",all_in_one_index_icon="_icon_vmcsy_53",all_in_one_index_actions="_actions_vmcsy_56",all_in_one_index_item="_item_vmcsy_61",all_in_one_index_img="_img_vmcsy_82",all_in_one_index_content="_content_vmcsy_85",hoverable="_hoverable_vmcsy_98",styles$4={container:container$3,dark:dark,"code-area":"_code-area_vmcsy_20",header:all_in_one_index_header,text:all_in_one_index_text,icon:all_in_one_index_icon,actions:all_in_one_index_actions,item:all_in_one_index_item,img:all_in_one_index_img,content:all_in_one_index_content,hoverable:hoverable,"light-scrollbar":"_light-scrollbar_vmcsy_121"},CodeBlock=({className:e,style:t,code:n,language:r,onCopyCode:s,showHeader:i=!0,raw:a,parents:o})=>{const{mode:l}=useCalypsoConfig(),c="dark"===l,{CodeBlockHighlighter:u}=useCalypsoSlots(),[d,p]=(0,react.useState)(!1),m=useAutoDetectLanguage(n,r);return (0,jsx_runtime.jsx)("div",{"data-testid":"code_block",className:classnames(styles$4.container,e,"hide-indicator",{[styles$4.dark]:c}),style:t,children:(0,jsx_runtime.jsxs)("div",{className:classnames(styles$4["code-area"]),dir:"ltr",children:[i&&(0,jsx_runtime.jsxs)("div",{className:styles$4.header,children:[(0,jsx_runtime.jsxs)("div",{className:styles$4.text,children:[(0,jsx_runtime.jsx)(SvgCodeIcon,{className:styles$4.icon}),m]}),(0,jsx_runtime.jsx)("div",{className:styles$4.actions,children:(0,jsx_runtime.jsx)("div",{className:styles$4.item,onClick:()=>{d||(copy_to_clipboard(n),null==s||s(n),p(!0),setTimeout((()=>{p(!1)}),3e3))},children:(0,jsx_runtime.jsx)("div",{className:classnames(styles$4.icon,styles$4.hoverable),"data-testid":"code_block_copy",children:(0,jsx_runtime.jsx)(d?SvgDoneIcon:SvgCopyIcon,{className:styles$4.img})})})})]}),(0,jsx_runtime.jsx)("div",{className:classnames(styles$4.content,styles$4[`content--${m.toLowerCase()}`]),children:u&&(0,jsx_runtime.jsx)(u,{code:n,language:r,raw:a,parents:o,dark:c})})]})})},codeBlockPlugin={name:"code-block",slots:{CodeBlock:CodeBlock}},all_in_one_index_wrapper="_wrapper_aaa8t_1",wrapperStyles={wrapper:all_in_one_index_wrapper},container$2="_container_1lt86_9",styles$3={container:container$2},BreakLine=({className:e,style:t})=>(0,jsx_runtime.jsx)("br",{className:classnames(styles$3.container,e),style:t}),withCalypsoBreakLine=e=>function({className:t,...n}){return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:e&&(0,jsx_runtime.jsx)(e,{className:classnames(wrapperStyles.wrapper,t,{[styles$3["non-select"]]:!all_in_one_index_isSafari()}),...n})})},WrappedBreakLine=withCalypsoBreakLine(BreakLine),breakLinePlugin={name:"break-line",slots:{BreakLine:WrappedBreakLine}},Blockquote=({className:e,style:t,node:n,children:r,renderRest:s})=>(0,jsx_runtime.jsx)(BlockElement,{className:e,style:t,node:n,renderRest:s,children:r}),blockquotePlugin={name:"blockquote",slots:{Blockquote:Blockquote}},defaultPlugins=[breakLinePlugin,texLightPlugin,codeHighlighterPrismPlugin,codeBlockPlugin,tablePlugin,imagePlugin,indicatorPlugin,paragraphPlugin,linkPlugin,emphasisPlugin,strongPlugin,headerPlugin,listPlugin,blockquotePlugin],CalypsoLite=(0,react.forwardRef)((function(e,t){return (0,jsx_runtime.jsx)(CalypsoCore,{ref:t,plugins:defaultPlugins,...e})})),safeKatexTexToHtml=(e,t={})=>{try{return katex["default"].renderToString(e,{throwOnError:!1,strict:!1,output:"html",trust:!1,...t})}catch(e){return null}},adaptor=(0,liteAdaptor.liteAdaptor)();(0,handlers_html.RegisterHTMLHandler)(adaptor);const all_in_one_index_tex=new tex.TeX({packages:[...AllPackages.AllPackages.sort().join(", ").split(/\s*,\s*/),"physics","mhchem"],macros:{equalparallel:"{\\lower{2.6pt}{\\arrowvert\\hspace{-4.2pt}\\arrowvert}\\above{-2pt}\\raise{7.5pt}{=}}",number:["{#1}",1],unit:["{#1}",1],div:"{÷}"}}),all_in_one_index_svg=new output_svg.SVG({fontCache:"none"}),all_in_one_index_html=mathjax.mathjax.document("",{InputJax:all_in_one_index_tex,OutputJax:all_in_one_index_svg}),texToSvg=e=>{var t;const n=xregexp_lib.replace(e,xregexp_lib(String.raw`[^\P{C}\n\t]+`,"ug"),"");try{const e=all_in_one_index_html.convert(n,{display:!0,em:16,ex:8,containerWidth:1280});return adaptor.outerHTML(null==(t=null==e?void 0:e.children)?void 0:t[0])}catch(t){return safeKatexTexToHtml(e)??e}},container$1="_container_1dcs1_1",single$1="_single_1dcs1_16",all_in_one_index_error="_error_1dcs1_44",styles$2={container:container$1,single:single$1,error:all_in_one_index_error},RawMathjaxTex=(0,react.forwardRef)((function({className:e,style:t,tex:n,html:r},s){const i=(0,react.useMemo)((()=>/^[a-zA-Z0-9\s]+$/.test(n.trim())),[n]),a=Boolean(null==r?void 0:r.includes("data-mjx-error")),o=!lodash_es_isUndefined(r)&&!a;return (0,jsx_runtime.jsx)("span",{ref:s,className:classnames(styles$2.container,e,"math-inline",{[styles$2.single]:i,[styles$2.error]:a}),style:t,dangerouslySetInnerHTML:o?{__html:r}:void 0,"data-custom-copy-text":`\\(${n}\\)`,children:o?null:n})})),MathJaxTex=({className:e,style:t,tex:n,mode:r})=>{const s=(0,react.useMemo)((()=>purifyHtml(texToSvg(n))),[n]);return (0,jsx_runtime.jsx)(RawMathjaxTex,{className:e,style:t,tex:n,html:s})},Calypso=(0,react.forwardRef)((function({slots:e={},autoFixSyntax:t=!0,...n},r){return (0,jsx_runtime.jsx)(CalypsoLite,{ref:r,slots:lodash_es_defaults(e,{Tex:MathJaxTex,CodeBlockHighlighter:PrismCodeBlockHighlighter}),autoFixSyntax:t&&{katex:katex["default"],...lodash_es_isBoolean(t)?{}:t},...n})}));class DefaultParseError extends Error{constructor(e,t,n){super(),this.message=e,this.lexer=t,this.position=n}}const useLazyKatex=()=>{const[e,t]=(0,react.useState)(),n=(0,react.useCallback)((async()=>{if(e)return;const{default:n}=await retryLoad((()=>Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 97234))));t(n)}),[e]),r=(0,react.useMemo)((()=>{var e;return(e=class{static render(){throw n(),new DefaultParseError("DefaultKatex.render has called",{},0)}static renderToString(){throw n(),new DefaultParseError("DefaultKatex.renderToString has called",{},0)}}).ParseError=DefaultParseError,e}),[n]);return e??r},withSuspense=(e,t)=>{const n=n=>(0,jsx_runtime.jsx)(react.Suspense,{fallback:t&&(0,jsx_runtime.jsx)(t,{...n}),children:(0,jsx_runtime.jsx)(e,{...n})});return n.displayName=e.displayName??(null==t?void 0:t.displayName),n},useLazyComponent=(e,t,n={})=>{const{retryTimes:r=5,retryInterval:s=100}=n;return (0,react.useMemo)((()=>withSuspense(react.lazy(withRetry(e,{tryTimes:r,interval:s,fallback:{default:t}})),t)),[r,s])},styles$1={"light-scrollbar":"_light-scrollbar_1ks9r_1"},LightCodeBlockHighlighter=({language:e,code:t,className:n,style:r})=>(0,jsx_runtime.jsx)("pre",{className:classnames(e&&`language-${e}`,styles$1["light-scrollbar"],n),style:r,children:(0,jsx_runtime.jsx)("code",{children:t})}),CalypsoLazy=(0,react.forwardRef)((function({slots:e={},autoFixSyntax:t=!0,retryTimes:n=5,retryInterval:r=100,...s},i){const a=useLazyKatex(),o=useLazyComponent((()=>Promise.resolve().then((()=>index$1))),LightTex,{retryTimes:n,retryInterval:r}),l=useLazyComponent((()=>Promise.resolve().then((()=>all_in_one_index_index))),o,{retryTimes:n,retryInterval:r}),c=useLazyComponent((()=>Promise.resolve().then((()=>index$2))),LightCodeBlockHighlighter,{retryTimes:n,retryInterval:r});return (0,jsx_runtime.jsx)(CalypsoLite,{ref:i,slots:lodash_es_defaults(e,{Tex:l,CodeBlockHighlighter:c}),autoFixSyntax:t&&{katex:a,...lodash_es_isBoolean(t)?{}:t},...s})})),AsyncLazyMathJaxTex=({className:e,style:t,tex:n})=>{const[r,s]=useState(),[i,a]=useState(!1),o=useRef(null);return useEffect((()=>{i&&s(texToSvg(n))}),[n,i]),useEffect((()=>{const e=new IntersectionObserver((t=>{if(!(null==t?void 0:t[0]))return;const{intersectionRatio:n}=t[0];n>0&&(a(!0),e.disconnect())}));return o.current&&e.observe(o.current),()=>{e.disconnect()}}),[]),jsx(RawMathjaxTex,{ref:o,className:e,style:t,tex:n,html:r})},asyncLazyMathjaxTexPlugin=(/* unused pure expression or super */ null && ({name:"async-lazy-mathjax-tex",slots:{Tex:AsyncLazyMathJaxTex}})),codeHighlighterLightPlugin=(/* unused pure expression or super */ null && ({name:"code-highlighter-light",slots:{CodeBlockHighlighter:LightCodeBlockHighlighter}})),all_in_one_index_container="_container_imek1_1",all_in_one_index_single="_single_imek1_6",all_in_one_index_block="_block_imek1_9",all_in_one_index_styles={container:all_in_one_index_container,single:all_in_one_index_single,block:all_in_one_index_block},KatexTex=({tex:e,mode:t,className:n,style:r,fallback:s,katexOptions:i})=>{const a=useDeepCompareMemo((()=>safeKatexTexToHtml(e,i)),[e,i]),o=useDeepCompareMemo((()=>a?null:safeKatexTexToHtml(e,{...i,displayMode:!0})),[e,i,Boolean(a)]),l=(0,react.useMemo)((()=>/^[a-zA-Z0-9\s]+$/.test(e.trim())),[e]);return!s||a||o?(0,jsx_runtime.jsx)("span",{className:classnames(all_in_one_index_styles.container,n,"math-inline",{[all_in_one_index_styles.single]:l,[all_in_one_index_styles.block]:Boolean(o)}),style:r,dangerouslySetInnerHTML:{__html:purifyHtml((a||o)??e)},"data-custom-copy-text":l?e:`\\(${e}\\)`}):(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:s})},index$1=Object.freeze(Object.defineProperty({__proto__:null,KatexTex:KatexTex,default:KatexTex},Symbol.toStringTag,{value:"Module"})),katexTexPlugin=(/* unused pure expression or super */ null && ({name:"katex-tex",slots:{Tex:KatexTex}})),KatexMathjaxTex=e=>(0,jsx_runtime.jsx)(KatexTex,{...e,katexOptions:{strict:!0,throwOnError:!0},fallback:(0,jsx_runtime.jsx)(MathJaxTex,{...e})}),all_in_one_index_index=Object.freeze(Object.defineProperty({__proto__:null,KatexMathjaxTex:KatexMathjaxTex,default:KatexMathjaxTex},Symbol.toStringTag,{value:"Module"})),katexMathjaxTexPlugin=(/* unused pure expression or super */ null && ({name:"katex-mathjax-tex",slots:{Tex:KatexMathjaxTex}})),mathjaxTexPlugin=(/* unused pure expression or super */ null && ({name:"mathjax-tex",slots:{Tex:MathJaxTex}}));
|
|
296215
|
+
*/const mathFlow={tokenize:tokenizeMathFenced,concrete:!0},all_in_one_index_nonLazyContinuation={tokenize:all_in_one_index_tokenizeNonLazyContinuation,partial:!0};function tokenizeMathFenced(e,t,n){const r=this,s=r.events[r.events.length-1],i=s&&s[1].type===types_types.linePrefix?s[2].sliceSerialize(s[1],!0).length:0;let a=0;return function(t){return default_ok(t===codes_codes.dollarSign,"expected `$`"),e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),o(t)};function o(t){return t===codes_codes.dollarSign?(e.consume(t),a++,o):a<2?n(t):(e.exit("mathFlowFenceSequence"),factorySpace(e,l,types_types.whitespace)(t))}function l(t){return t===codes_codes.eof||markdownLineEnding(t)?u(t):(e.enter("mathFlowFenceMeta"),e.enter(types_types.chunkString,{contentType:constants.contentTypeString}),c(t))}function c(t){return t===codes_codes.eof||markdownLineEnding(t)?(e.exit(types_types.chunkString),e.exit("mathFlowFenceMeta"),u(t)):t===codes_codes.dollarSign?n(t):(e.consume(t),c)}function u(n){return e.exit("mathFlowFence"),r.interrupt?t(n):e.attempt(all_in_one_index_nonLazyContinuation,d,h)(n)}function d(t){return e.attempt({tokenize:f,partial:!0},h,p)(t)}function p(t){return(i?factorySpace(e,m,types_types.linePrefix,i+1):m)(t)}function m(t){return t===codes_codes.eof?h(t):markdownLineEnding(t)?e.attempt(all_in_one_index_nonLazyContinuation,d,h)(t):(e.enter("mathFlowValue"),g(t))}function g(t){return t===codes_codes.eof||markdownLineEnding(t)?(e.exit("mathFlowValue"),m(t)):(e.consume(t),g)}function h(n){return e.exit("mathFlow"),t(n)}function f(e,t,n){let s=0;return default_ok(r.parser.constructs.disable.null,"expected `disable.null`"),factorySpace(e,(function(t){return e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),i(t)}),types_types.linePrefix,r.parser.constructs.disable.null.includes("codeIndented")?void 0:constants.tabSize);function i(t){return t===codes_codes.dollarSign?(s++,e.consume(t),i):s<a?n(t):(e.exit("mathFlowFenceSequence"),factorySpace(e,o,types_types.whitespace)(t))}function o(r){return r===codes_codes.eof||markdownLineEnding(r)?(e.exit("mathFlowFence"),t(r)):n(r)}}}function all_in_one_index_tokenizeNonLazyContinuation(e,t,n){const r=this;return function(n){if(null===n)return t(n);return default_ok(markdownLineEnding(n),"expected eol"),e.enter(types_types.lineEnding),e.consume(n),e.exit(types_types.lineEnding),s};function s(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}const dollarSign=36;function all_in_one_index_math(e){return{flow:{[dollarSign]:mathFlow},text:{[dollarSign]:mathText()}}}const parseJSONWithNull=e=>{try{return e?JSON.parse(e):null}catch(e){return null}},getByIndex=(e,t)=>{if(!lodash_es_isUndefined(t))return null==e?void 0:e[t]};class AssertError extends Error{constructor(){super(...arguments),this.name="assert_error"}}const assert=(e,t)=>{if(!e){if(lodash_es_isError(t))throw t;throw new AssertError(t)}};let _isSafari;function all_in_one_index_isSafari(){return"undefined"!=typeof navigator&&(void 0===_isSafari&&(_isSafari=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)),_isSafari)}const pipe=(...e)=>t=>e.reduce(((e,t)=>t(e)),t),isNumeric=e=>{const t=e.replace(/,/g,"");return!isNaN(t)&&!isNaN(parseFloat(t))},firstMatch=(e,t)=>{for(const n of e){const e=t(n);if(e)return e}},timeoutPromise=e=>new Promise((t=>setTimeout(t,e))),elementAt=(e,t)=>e[t],splitStringByPattern=(e,t)=>{const n=[],{flags:r}=t,s=new RegExp(t.source,r.includes("g")?r:`${r}g`);let i,a=0;for(;i=s.exec(e);){const t=i[0];i.index>a&&n.push(e.slice(a,i.index)),n.push(t),a=i.index+t.length}return e.length>a&&n.push(e.slice(a,e.length)),n},safeParseUrl=e=>{try{return new URL(e)}catch(e){return null}},useCustomMemoValue=(e,t)=>{const n=(0,react.useRef)(e);return t(e,n.current)||(n.current=e),n.current},useDeepCompareMemo=(e,t)=>{const n=(0,react.useRef)();return!lodash_es_isUndefined(n.current)&&lodash_es_isEqual(n.current,t)||(n.current=t),(0,react.useMemo)(e,n.current)},useComputeValue=e=>e(),purifyHtml=(e,t)=>isomorphic_dompurify_browser.sanitize?isomorphic_dompurify_browser.sanitize(e,t):(console.error("[Calypso] Cannot load isomorphic-dompurify"),e),voidTags=["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"],transformSelfClosing=e=>e.replace(/<([\w\-]+)([^>/]*)\/\s*>/g,((e,t,n)=>voidTags.includes(t.toLowerCase())?e:`<${t}${n}></${t}>`)),retryAsync=async(e,{tryTimes:t=5,interval:n=100,fallback:r,onRetryError:s})=>{for(let i=0;i<t;i++){const a=i+1;try{return await e()}catch(e){if(a>=t){if(!lodash_es_isUndefined(r))return r;throw e}null==s||s(e,i)}const o="number"==typeof n?n:n(a);await timeoutPromise(o)}throw Error("retry times out of limit")},withRetry=(e,t)=>(...n)=>retryAsync((()=>e(...n)),t),resizeImage=({width:e,height:t,minHeight:n,minWidth:r,maxHeight:s,maxWidth:i})=>{const a={width:e,height:t},o=e/t,l=e=>{a.height=e,a.width=e*o},c=e=>{a.width=e,a.height=e/o};return a.width<r&&c(r),a.height<n&&l(n),a.width>i&&c(i),a.height>s&&l(s),(a.width<r||a.width>i||a.height<n||a.height>s)&&console.warn(`[Calypso] Image cannot be resized to the specified size: Natural size: {${e},${t}} Resized size: {${a.width},${a.height}} Min size: {${r},${n}} Max size: {${i},${s}}`),a},createShallowedProvider$1=e=>{const t=e.Provider;return({value:e,afterMemoedProcess:n,children:r})=>{const s=useCustomMemoValue(e,shallowEqual),i=(0,react.useMemo)((()=>n?n(s):s),[s]);return (0,jsx_runtime.jsx)(t,{value:i,children:r})}};var LinkTermination=(e=>(e.Include="Include",e.Hard="Hard",e.Soft="Soft",e.Close="Close",e.Open="Open",e))(LinkTermination||{});const DEFAULT_CONFIG={characterMap:new Map,cjkIsHard:!0,hardPattern:/[\s\p{C}]/u,softPattern:/[.,!?;:'"。,!?;:]/u,pairedOpenerMap:new Map([[")","("],["]","["],["}","{"],[">","<"],["』","『"],["」","「"],["〉","〈"],["》","《"]])},CJK_PATTERN=/[\u4E00-\u9FFF\u3400-\u4DBF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF]/u;class UnicodeURLDetector{constructor(e={}){this.config={...DEFAULT_CONFIG,...e}}getLinkTermination(e){if(this.config.characterMap.has(e))return this.config.characterMap.get(e)??"Include";if(this.config.cjkIsHard&&CJK_PATTERN.test(e))return"Hard";if(this.config.pairedOpenerMap.has(e))return"Close";for(const t of this.config.pairedOpenerMap.values())if(e===t)return"Open";return this.config.hardPattern.test(e)?"Hard":this.config.softPattern.test(e)?"Soft":"Include"}getPairedOpener(e){return this.config.pairedOpenerMap.get(e)||null}detectLink(e,t=0){let n=t;const r=[];for(let s=t;s<e.length;s++){const t=e[s];switch(this.getLinkTermination(t)){case"Include":default:n=s+1;break;case"Soft":{let t=s+1;for(;t<e.length&&"Soft"===this.getLinkTermination(e[t]);)t++;if(t>=e.length||"Hard"===this.getLinkTermination(e[t]))return n;n=s+1;break}case"Hard":return n;case"Open":r.push(t),n=s+1;break;case"Close":{if(0===r.length)return n;const e=r.pop();if(this.getPairedOpener(t)!==e)return n;n=s+1;break}}}return n}findAllLinks(e){const t=[],n=[/https?:\/\/[^\s\u4E00-\u9FFF\u3400-\u4DBF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF]+/gi,/(^|[^a-zA-Z0-9.-])(www\.[a-zA-Z0-9][-a-zA-Z0-9]*\.[a-zA-Z]{2,}(?:[^\s\u4E00-\u9FFF\u3400-\u4DBF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF]*)?)/gi,/(^|[^a-zA-Z0-9.-@])([a-zA-Z0-9][-a-zA-Z0-9]*\.[a-zA-Z]{2,}(?:[^\s\u4E00-\u9FFF\u3400-\u4DBF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF@]*)?)/gi];for(const r of n){let n=r.exec(e);for(;null!==n;){let s=n.index;if(n.length>2&&n[2]){if(s=n.index+(n[0].length-n[2].length),s>0&&"@"===e[s-1]){n=r.exec(e);continue}}else if(n.length>1&&n[1]&&n[1]!==n[0]){if(s=n.index+(n[0].length-n[1].length),s>0&&"@"===e[s-1]){n=r.exec(e);continue}}else if(s>0&&"@"===e[s-1]){n=r.exec(e);continue}const i=this.detectLink(e,s),a=e.substring(s,i);if(i>s&&this.isValidURL(a)){t.some((e=>s>=e.start&&s<e.end||i>e.start&&i<=e.end))||t.push({start:s,end:i,url:a})}n=r.exec(e)}}return t.sort(((e,t)=>e.start-t.start))}isValidURL(e){if(e.length<4)return!1;if(e.startsWith("http://")||e.startsWith("https://"))return e.length>10;return/^[a-zA-Z0-9][-a-zA-Z0-9]*\.[a-zA-Z]{2,}/.test(e)}}const defaultDetector=new UnicodeURLDetector;function createDetector(e){return new UnicodeURLDetector(e)}var HyperNodeType=(e=>(e[e.text=0]="text",e[e.link=1]="link",e))(HyperNodeType||{});const extractAutolinkDetector=createDetector({}),getHyperLinkNodes$1=e=>{const t=[],n=extractAutolinkDetector.findAllLinks(e);let r=0;for(const s of n){if(r<s.start){const n=e.slice(r,s.start);n&&t.push({type:0,text:n})}const n=e.slice(s.start,s.end);t.push({type:1,url:n}),r=s.end}if(r<e.length){const n=e.slice(r);n&&t.push({type:0,text:n})}return t},completeProtocol$1=e=>e.match(/https?:\/\//)?e:`https://${e}`,isValidEmail=e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);class UnicodeHyperLinkParser{constructor(e={}){this.config={enableEmail:!1,autoAddProtocol:!0,...e},this.detector=e.characterMap||void 0!==e.cjkIsHard?createDetector(e):defaultDetector}findEmailAddresses(e){if(!this.config.enableEmail)return[];const t=[],n=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;let r=n.exec(e);for(;null!==r;){const s=r[0];isValidEmail(s)&&t.push({start:r.index,end:r.index+s.length,email:s}),r=n.exec(e)}return t}getHyperLinkNodes(e){const t=[],n=this.detector.findAllLinks(e),r=this.findEmailAddresses(e),s=[...n.map((e=>({...e,type:"link"}))),...r.map((e=>({...e,url:e.email,type:"email"})))].sort(((e,t)=>e.start-t.start));let i=0;for(const n of s){if(i<n.start){const r=e.slice(i,n.start);r&&t.push({type:HyperNodeType.text,text:r})}if("email"===n.type)t.push({type:HyperNodeType.text,text:n.url});else{const e=this.config.autoAddProtocol?completeProtocol$1(n.url):n.url;t.push({type:HyperNodeType.link,url:e})}i=n.end}if(i<e.length){const n=e.slice(i);n&&t.push({type:HyperNodeType.text,text:n})}return t}}const createUnicodeParser=e=>new UnicodeHyperLinkParser(e),defaultUnicodeParser=new UnicodeHyperLinkParser,getHyperLinkNodes=e=>defaultUnicodeParser.getHyperLinkNodes(e),escapeRegExp=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),escapeChars=(e,t)=>{if(t.filter((e=>1!==e.length)).length)throw Error(`illegal chars length: ${t.join(", ")}`);return t.reduce(((e,t)=>{const n=new RegExp(String.raw`([^\\]|^)(${escapeRegExp(t)})`,"g");return e.replace(n,((e,t,n)=>`${t}\\${n}`))}),e)},escapeCharsInLatex=e=>escapeChars(e,["#"]),texPreProcessor=pipe(escapeCharsInLatex),texMathExtract=e=>{let t=0;if(36!==e.charCodeAt(t))return;let n="$";t+=1;const r=e.charCodeAt(t);if(36===r){if(n="$$",t+=1,36===e.charCodeAt(t))return}else if(32===r||9===r||10===r)return;const s=e.indexOf(n,t);if(-1===s)return;if(92===e.charCodeAt(s-1))return;const i=s+n.length;if(1===n.length){const t=e.charCodeAt(s-1);if(32===t||9===t||10===t)return;const n=e.charCodeAt(i);if(n>=48&&n<58)return}return{type:1===n.length?"inline":"block",mathText:e.slice(t,s),endIndex:i}},katexTryParseOptions={throwOnError:!0,strict:!0,output:"mathml",trust:!1},katexCheckTex=(e,t)=>{try{return e.renderToString(texPreProcessor(t),katexTryParseOptions),!0}catch(t){if(t instanceof e.ParseError)return!1;throw t}},katexParseErrorIndex=(e,t)=>{try{e.renderToString(texPreProcessor(t),katexTryParseOptions)}catch(t){if(t instanceof e.ParseError)return t.position}},customCheckTex=e=>![/\([^\)]*$/].some((t=>t.test(e))),checkTex=({tex:e,katex:t})=>katexCheckTex(t,e)&&customCheckTex(e),findMaxLegalPrefixEndIndex=({src:e,katex:t})=>{let n=katexParseErrorIndex(t,e)??e.length;for(;n>=0;){const r=e.slice(0,n);if(checkTex({tex:r,katex:t}))return n;n-=1}return n},INSERT_ELEMENT_SLOT_NAME="insert_element",getTextSlotString=e=>`{${e}}`,getInsertElementSlotString=({data:e,index:t,wrapWith:n=""})=>`${n}${getTextSlotString(`insert_element_${t}_${node_modules_buffer.Buffer.from(e).toString("base64")}`.replace(/_/g,"\\_"))}${n}`,insertElementSlotRegex=`\\{${"insert_element".replace(/_/g,"\\\\_")}\\\\_(?<index>[0-9]+)\\\\_(?<b64_data>.*?)\\}`,startOfInsertElementSlot=e=>{var t;return null==(t=new RegExp(insertElementSlotRegex).exec(e))?void 0:t.index},matchInsertElementSlot=e=>{const t=new RegExp(`^${insertElementSlotRegex}`).exec(e);return null==t?void 0:t[0]},extractDataFromInsertElementSlot=e=>{const t=new RegExp(`^${insertElementSlotRegex}$`).exec(e),{index:n,b64_data:r}=(null==t?void 0:t.groups)||{};if(!lodash_es_isUndefined(n)&&!lodash_es_isUndefined(r))return{index:parseInt(n),b64Text:r,text:r&&node_modules_buffer.Buffer.from(r,"base64").toString("utf8")}},convertToOperation=(e,t)=>{const n=[],r={inline:"",newline:"\n",block:"\n\n"};return t.forEach((({range:t,type:s="inline"},i)=>{const a=lodash_es_isNumber(t)?[t,t]:t,[o,l]=a;o>l||o>e.length||n.push({replaceRange:lodash_es_isNumber(t)?[t,t]:t,insert:getInsertElementSlotString({index:i,data:e.slice(...a),wrapWith:r[s]}),index:n.length})})),n},transformOperationInOrder=(e,t)=>{const[n,r]=e.replaceRange,[s,i]=t.replaceRange,a=t.insert.length-(i-s);if(n<s)return e;if(n===s&&e.index<t.index)return e;const o=Math.min(Math.max(0,i-n),r-n);return{...e,replaceRange:[n+a+o,r+a]}},transformEach=e=>{const t=[];for(let n=0;n<e.length;n+=1){let r=e[n];for(let e=0;e<t.length;e+=1)r=transformOperationInOrder(r,t[e]);t.push(r)}return t},applyOperationToString=(e,t)=>{const{replaceRange:[n,r],insert:s}=t;return`${e.slice(0,n)}${s}${e.slice(r)}`},applyInsertListToString=(e,t)=>{const n=transformEach(convertToOperation(e,t));return pipe(...n.map((e=>t=>applyOperationToString(t,e))))(e)},addInsertElementSlotToString=(e,t)=>applyInsertListToString(e,t),removeInsertElementSlotInString=e=>e.replace(new RegExp(insertElementSlotRegex,"g"),(e=>{const t=extractDataFromInsertElementSlot(e);return t?t.text:""})),INLINE_MATH_SPAN_DATA_TYPE="inline-math",BLOCK_MATH_SPAN_DATA_TYPE="block-math",renderSpanString=(e,t)=>`<span data-type="${e}" data-value="${node_modules_buffer.Buffer.from(t).toString("base64")}"></span>`,renderInlineMathSpanString=e=>renderSpanString("inline-math",texPreProcessor(removeInsertElementSlotInString(e))),renderBlockMathSpanString=e=>renderSpanString("block-math",texPreProcessor(removeInsertElementSlotInString(e))),restoreMathPandocLatex=e=>e.replace(new RegExp('<span data-type="inline-math" data-value="(.*?)"></span>',"g"),((e,t)=>String.raw`\(${node_modules_buffer.Buffer.from(t,"base64").toString("utf8")}\)`)).replace(new RegExp('<span data-type="block-math" data-value="(.*?)"></span>',"g"),((e,t)=>String.raw`\[${node_modules_buffer.Buffer.from(t,"base64").toString("utf8")}\]`)),parseMarkdown=(e,t={})=>fromMarkdown(e,{extensions:[all_in_one_index_math(),syntax_gfmTable,disableSetextHeading(),...t.enableIndentedCode?[]:[disableIndentedCode()],gfmStrikethrough({singleTilde:!1}),gfmTaskListItem],mdastExtensions:[mathFromMarkdown(),gfmTableFromMarkdown,gfmStrikethroughFromMarkdown,gfmTaskListItemFromMarkdown]}),stringifyMarkdown=(e,t=!1)=>{const n=toMarkdown(e,{extensions:[mathToMarkdown(),gfmTableToMarkdown(),gfmStrikethroughToMarkdown,gfmTaskListItemToMarkdown],resourceLink:!0,fences:!0});return t?n.trim():n},stringifyChildren=(e,t=!1)=>{if(!e.length)return"";const n=stringifyMarkdown({type:"root",children:e},!0);return t?n.replace(/\n/g,""):n},isParentOfContent=e=>!lodash_es_isUndefined(null==e?void 0:e.children),all_in_one_index_isParent=e=>!lodash_es_isUndefined(null==e?void 0:e.children),isLiteralOfContent=e=>!lodash_es_isUndefined(null==e?void 0:e.value),all_in_one_index_isImage=e=>"image"===(null==e?void 0:e.type),isRoot=e=>"root"===(null==e?void 0:e.type),isTypeOfContent=(e,...t)=>t.some((t=>(null==e?void 0:e.type)===t)),isHeading=e=>isParentOfContent(e)&&"heading"===e.type,getTextOfAst=(e,t={})=>{const{filter:n}=t;return n&&!n(e)?"":isParentOfContent(e)?`${e.children.map((e=>getTextOfAst(e,t))).join("")}\n`:isLiteralOfContent(e)?e.value:""},DEFAULT_ENABLED_ROOT_TAGS=["span","u","br"],matchTagNameOfHtmlTag=e=>{var t,n;const r=[/<(?<tag>[a-zA-Z]+)(\s+([a-zA-Z]+=(("[^"]*")|('[^']*'))))*\s*\/?>/,/<\/(?<tag>[a-zA-Z]+)>/];for(const s of r){const r=s.exec(e);if(r)return null==(n=null==(t=r.groups)?void 0:t.tag)?void 0:n.toLowerCase()}},getTagNameOfHtml=e=>{var t;const n=matchTagNameOfHtmlTag(e);if("undefined"==typeof DOMParser)return n;const r=new DOMParser,s=elementAt([...r.parseFromString(e,"text/html").body.children],0);return(null==(t=null==s?void 0:s.tagName)?void 0:t.toLowerCase())||n},autoDisableHtmlTag=(e,t=[])=>{const n=getTagNameOfHtml(e);if(!0===t)return e;const r=[...DEFAULT_ENABLED_ROOT_TAGS,...t||[]];return n&&!r.includes(n)?he.encode(e,{strict:!1}):e},stringifyDomNode=e=>esm(e,{encodeEntities:!1,decodeEntities:!0}),INSERT_ELEMENT_SLOT_EXTENSION_NAME="insert_element_extension",insertElementSlotExtension=()=>({name:"insert_element_extension",level:"inline",start:e=>startOfInsertElementSlot(e),tokenizer(e){const t=matchInsertElementSlot(e);if(t)return{type:"insert_element_extension",raw:t}},renderer({raw:e}){if(!e)return!1;const t=extractDataFromInsertElementSlot(e);if(!t)return!1;const{index:n,b64Text:r}=t;return`<span data-index="${n}" data-raw="${r}" data-type="insert_element_extension"></span>`}}),inlineTex=()=>({name:"inlineTex",level:"inline",start(e){var t;return null==(t=/\$([^\$]|$)/.exec(e))?void 0:t.index},tokenizer(e){const t=texMathExtract(e);if(!t)return;const{type:n,endIndex:r,mathText:s}=t;return"inline"===n?{type:"inlineTex",raw:e.slice(0,r),mathText:s}:void 0},renderer:e=>renderInlineMathSpanString(e.mathText)}),displayTex=()=>({name:"displayTex",level:"block",start(e){var t;return null==(t=/\$\$[^\$]+\$\$/.exec(e))?void 0:t.index},tokenizer(e){const t=texMathExtract(e);if(!t)return;const{type:n,endIndex:r,mathText:s}=t;return"block"===n?{type:"displayTex",raw:e.slice(0,r),mathText:s}:void 0},renderer:e=>renderBlockMathSpanString(e.mathText)}),escapeTest=/[&<>"']/,escapeReplace=new RegExp(escapeTest.source,"g"),escapeTestNoEncode=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode=new RegExp(escapeTestNoEncode.source,"g"),all_in_one_index_escapeReplacements={"&":"&","<":"<",">":">",'"':""","'":"'"},escapeMarkdownText=(e,t=!1)=>{const n=e=>all_in_one_index_escapeReplacements[e];if(t){if(escapeTest.test(e))return e.replace(escapeReplace,n)}else if(escapeTestNoEncode.test(e))return e.replace(escapeReplaceNoEncode,n);return e},getCalypsoRenderer=(e={})=>{const{enabledHtmlTags:t}=e;return new class extends _Renderer{html({text:e}){return autoDisableHtmlTag(e,t)}code({text:e,lang:t="",escaped:n}){const r=t.match(/^\s*(?<language>\S+)\s*(?<meta>[\S\s]*?)\s*$/),s=`${e.replace(/\n$/,"")}\n`;if(!r)return`<pre><code>${n?s:escapeMarkdownText(s,!0)}</code></pre>\n`;const{groups:i={}}=r,{language:a,meta:o}=i;return`<pre><code type="test" class="language-${escapeMarkdownText(a)}"${o?` data-meta="${escapeMarkdownText(o)}"`:""}>${n?s:escapeMarkdownText(s,!0)}</code></pre>\n`}}(e)},gfmDelRegex=/^(~~)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/;class CalypsoTokenizer extends _Tokenizer{autolink(e){}del(e){const t=gfmDelRegex.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}url(){}}const getHopDiff=(e,t)=>{if(e.type!==t.type)return isParentOfContent(e)&&isParentOfContent(t)?{prevEndNode:e,endNode:t}:null;if(!lodash_es_isEqual(e.children.map((e=>e.type)),t.children.map((e=>e.type))))return{prevEndNode:elementAt(e.children,e.children.length-1),endNode:elementAt(t.children,t.children.length-1)};for(let n=0;n<e.children.length;n++){const r=e.children[n],s=t.children[n];if(all_in_one_index_isParent(r)&&all_in_one_index_isParent(s)){const e=getHopDiff(r,s);if(e)return e}else{if(all_in_one_index_isParent(r)||all_in_one_index_isParent(s))return{prevEndNode:r,endNode:s};if(r.type!==s.type)return{prevEndNode:r,endNode:s}}}return null},standardNodeTypeMapping={thematicBreak:"thematic",heading:"heading",code:"code_block",html:"html",linkReference:"link_def_ref",paragraph:"paragraph",table:"table",blockquote:"block_quote",list:"list",listItem:"list_item",inlineCode:"inline_code",emphasis:"emphasis",strong:"strong",link:"link",image:"image",delete:"strike_through",text:"text",math:"math_block",inlineMath:"inline_math"},convertToStanardNodeTypeEnum=e=>e?standardNodeTypeMapping[e]??"unknown":"empty",updateAst=(e,t,n={})=>{const{order:r="pre_order",isReverse:s=!1}=n;let i=!1,a=!1,o=!1;const l=[[[],e]],c=[];for(;l.length;){const e=l.pop();assert(e,"current must not be undefined");const[n,u]=e,d=lodash_es_head(n),p=all_in_one_index_isParent(u)?u.children.slice():[],m=s?p:p.reverse(),g=all_in_one_index_isParent(u)?m.map((e=>[[u,...n],e])):[],h=(e,t=!1)=>{if(!d)return;const n=d.children.findIndex((e=>e===u));assert(lodash_es_isNumber(n),"Invoke insertAfter error in updateAst: parent is not parent of current"),t?d.children.splice(n,1,...e):d.children.splice(n+1,0,...e)},f=()=>{if(o)throw Error("You have to call stop synchronously");i=!0},x=()=>{if(o)throw Error("You have to call skip synchronously");a=!0},y=()=>{const e=null==d?void 0:d.children.findIndex((e=>e===u));assert(-1!==e,"Current must be child of it's parent"),t(u,{stop:f,skip:x,insertAfter:h,parent:d,parents:n,index:e})};if("pre_order"===r)y(),a||l.push(...g);else if("post_order"===r){const t=g.filter((([,e])=>!c.includes(e)));t.length?(l.push(e),l.push(...t)):(y(),c.push(u))}else"in_order"===r&&(all_in_one_index_isParent(u)&&g.length&&g.every((([,e])=>!c.includes(e)))?(l.push(...g.slice(0,g.length-1)),l.push(e),l.push(g[g.length-1])):(y(),c.push(u)));if(i)break;i=!1,a=!1}o=!0};var AstPluginPriority=(e=>(e[e.BeforeAll=-2]="BeforeAll",e[e.Before=-1]="Before",e[e.Normal=0]="Normal",e[e.After=1]="After",e[e.AfterAll=2]="AfterAll",e))(AstPluginPriority||{});class BaseAstPlugin{constructor(){this.config={},this.before=lodash_es_noop,this.after=lodash_es_noop,this.beforeEach=lodash_es_noop,this.afterEach=lodash_es_noop}}const modifyByCurrentPlugin=({plugin:e,ast:t,skipWhenError:n=!0,...r})=>{const s=lodash_es_isFunction(e.modifier)?[e.modifier.bind(e)]:e.modifier.map((t=>t.bind(e)));e.before(t);for(const i of s){e.beforeEach(t);try{updateAst(t,((t,n)=>i(t,{...n,recursiveModifier(t){modifyByCurrentPlugin({plugin:e,ast:t,...r})},...r})),e.config)}catch(t){if(!n)throw t;console.error(`[Calypso source plugin error: ${e.name}]`,t)}e.afterEach(t)}e.after(t)},processAstByPlugins=({ast:e,plugins:t,fixEnding:n=!1,skipWhenError:r,...s})=>{const i=sortBy(t,(e=>{var t;return(null==(t=e.config)?void 0:t.priority)??AstPluginPriority.Normal})).filter((e=>{const{fixEndingOnly:t=!1}=e.config??{};return!t||n})),a=lodash_es_cloneDeep(e);for(const e of i)modifyByCurrentPlugin({plugin:e,ast:a,skipWhenError:r,...s});return a};var SourcePluginPriority=(e=>(e[e.BeforeAll=-1]="BeforeAll",e[e.Normal=0]="Normal",e[e.AfterAll=1]="AfterAll",e))(SourcePluginPriority||{});class BaseSourcePlugin{constructor(){this.config={},this.before=lodash_es_noop,this.after=lodash_es_noop,this.beforeEach=lodash_es_noop,this.afterEach=lodash_es_noop}}const processSourceByPlugins=({source:e,plugins:t,fixEnding:n=!1,katex:r,skipWhenError:s=!0})=>sortBy(t,(e=>{var t;return(null==(t=e.config)?void 0:t.priority)??SourcePluginPriority.Normal})).filter((e=>{const{fixEndingOnly:t=!1}=e.config??{};return!t||n})).reduce(((e,t)=>{t.before(e);const n=(lodash_es_isFunction(t.modifier)?[t.modifier.bind(t)]:t.modifier.map((e=>e.bind(t)))).reduce(((e,n)=>{try{t.beforeEach(e);const s=n({source:e,katex:r});return t.afterEach(s),s}catch(n){if(!s)throw n;return console.error(`[Calypso source plugin error: ${t.name}]`,n),e}}),e);return t.after(n),n}),e);class AutofixLastCodeBlockAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_last_code_block",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n})=>{var r,s;if(isLiteralOfContent(e))if(n(),"code"===e.type){const{content:n}=(null==(r=e.value.match(/^(?<content>[\S\s]*?)\n`+$/))?void 0:r.groups)||{};if(!lodash_es_isString(n))return;t([{...e,value:n}],!0)}else if("text"===e.type){const{prefix:n}=(null==(s=e.value.match(/^(?<prefix>[\s\S]*?)`{1,2}$/))?void 0:s.groups)||{};if(!lodash_es_isString(n))return;t(n?[{type:"text",value:n}]:[],!0)}}}}const getLastTextNodeByRegex=(e,t)=>{const n=findLast(e.children,(e=>Boolean("text"===e.type&&e.value.match(t))));if(!n)return;assert("text"===n.type,"lastUnPaired.type must be text");const r=e.children.findIndex((e=>e===n));return assert(r>=0,"lastUnPairedIndex must >= 0"),{target:n,index:r}},UNPAIRED_REGEX=/^(?<prefix>.*([^\\`]|^))`(?!`)(?<suffix>.*?)$/;class AutofixLastInlineCodeBlockAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_last_inline_code_block",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{stop:t})=>{var n;if(!all_in_one_index_isParent(e))return;t();const r=getLastTextNodeByRegex(e,UNPAIRED_REGEX);if(!r)return;const{target:s,index:i}=r;if(e.children.slice(i+1).find((e=>"inlineCode"===e.type)))return;const{prefix:a,suffix:o}=(null==(n=s.value.match(UNPAIRED_REGEX))?void 0:n.groups)||{};if(!lodash_es_isString(o)||!lodash_es_isString(a))return;const l=[];a&&l.push({type:"text",value:a});const c=`${o}${stringifyChildren(e.children.slice(i+1),!0)}`;c&&l.push({type:"inlineCode",value:c}),e.children.splice(i,e.children.length-i,...l)}}}const truncatedHtmlRegexList=[/<([a-zA-Z\-]+((\s+([a-zA-Z\-]+=(("[^"]*")|('[^']*'))))*(\s*\/?|(\s+[a-zA-Z\-]+(=(("[^"]*)|('[^']*))?)?)))?)?$/,/<\/([a-zA-Z\-]+)?$/],truncatedDataSlotRegexList=[/<data-(inline|block)(\s.*)?$/],truncateTruncatedHtmlSuffix=(e,t={})=>{const{looseTruncateDataSlot:n=!1}=t,r=firstMatch(lodash_es_concat(truncatedHtmlRegexList,n?truncatedDataSlotRegexList:[]),(t=>t.exec(e)));return r?e.slice(0,r.index):e};class AutofixTruncatedHtmlTagAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_html_tag",this.config={isReverse:!0},this.modifier=(e,{insertAfter:t,stop:n,looseTruncateDataSlot:r=!1})=>{if(!isTypeOfContent(e,"text","html"))return;n();const s=truncateTruncatedHtmlSuffix(e.value,{looseTruncateDataSlot:r});t(s?[{type:e.type,value:s}]:[],!0)}}}class AutofixTruncatedLinkAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_link",this.config={isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n})=>{var r;if(isTypeOfContent(e,"link"))return void n();if(all_in_one_index_isParent(e)||"text"!==e.type&&"html"!==e.type)return;n();const s=[/\[(?<text>\[[^\]\n]*)$/,/\[(?<text>\[[^\]\n]+\])$/,/\[(?<text>\[[^\]\n]+\])\]$/,/\[(?<text>\[[^\]\n]+\])\]\([^\)\n]*$/,/\[(?<text>[^\]\n]*)$/,/\[(?<text>[^\]\n]+)\]$/,/\[(?<text>[^\]\n]+)\]\([^\)\n]*$/].find((t=>t.exec(e.value)));if(!s)return;const i=s.exec(e.value);if(!i)return;const a=null==(r=i.groups)?void 0:r.text,o=i.index;t(a?[{type:e.type,value:e.value.slice(0,o)},{type:"link",title:null,url:"#",children:[{type:"text",value:a}]}]:[{type:e.type,value:e.value.slice(0,o)}],!0)}}}class AutofixTruncatedImageAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_image",this.config={isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n,removeTruncatedImage:r=!1})=>{var s;const i=[/!$/,/!\[$/,/!\[(?<text>[^\]]*)$/,/!\[(?<text>[^\]]*)\]$/,/!\[(?<text>[^\]]*)\]\([^\)]*$/],a=r?i:i.slice(0,1),o=r?[]:i.slice(1);if(!isLiteralOfContent(e))return;if(n(),"text"!==e.type)return;const l=o.find((t=>t.exec(e.value))),c=a.find((t=>t.exec(e.value)));if(!c&&!l)return;const u=c??l;if(!u)return;const d=u.exec(e.value);d&&t(lodash_es_concat({type:"text",value:e.value.slice(0,d.index)},l?{type:"image",url:"",alt:(null==(s=d.groups)?void 0:s.text)||"image"}:[]),!0)}}}class AutofixTruncatedEscapePlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_escape",this.config={isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n})=>{var r;if(all_in_one_index_isParent(e)||"text"!==e.type)return;n();const s=e.value.match(/^(?<text>[\s\S]*)\\$/);if(!s)return;t([{type:"text",value:(null==(r=s.groups)?void 0:r.text)??""}],!0)}}}const completeProtocol=e=>e.match(/https?:\/\//)?e:`https://${e}`;class ExtractCustomAutolinkAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="extract_custom_autolink",this.config={priority:AstPluginPriority.After},this.modifier=(e,{insertAfter:t,skip:n})=>{if(all_in_one_index_isParent(e))return void(isParentOfContent(e)&&"link"===e.type&&n());if("text"!==e.type)return;t(getHyperLinkNodes$1(e.value).map((e=>{if(e.type===HyperNodeType.link){const t=e;return{type:"link",url:completeProtocol(t.url),title:"autolink",children:[{type:"text",value:t.url}]}}if(e.type===HyperNodeType.text){return{type:"text",value:e.text}}return null})).filter((e=>Boolean(e))),!0)}}}const indicatorItem={type:"html",value:'<span class="indicator" />'};class InsertIndicatorAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="insert_indicator",this.config={isReverse:!0,priority:AstPluginPriority.After},this.modifier=(e,{insertAfter:t,stop:n})=>{if(all_in_one_index_isImage(e))n();else{if(isParentOfContent(e)&&"listItem"===e.type&&!stringifyChildren(e.children,!0).trim())return n(),void t([{...e,children:[indicatorItem]}],!0);if(isLiteralOfContent(e)){if(n(),"code"===e.type)return;t([indicatorItem])}}}}}const mergeTextChildren=e=>{const{children:t}=e,n=[];let r="";for(let e=0;e<t.length;e++){const s=t[e];"text"===s.type&&(r+=s.value),"text"===s.type&&e!==t.length-1||(r&&n.push({type:"text",value:r}),r=""),"text"!==s.type&&n.push(s)}e.children=n};class AutoMergeSiblingTextAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="extract_custom_autolink",this.config={priority:AstPluginPriority.AfterAll},this.modifier=(e,{skip:t,recursiveModifier:n})=>{if(isParentOfContent(e)){mergeTextChildren(e),t();for(const t of e.children)all_in_one_index_isParent(t)&&n(t)}}}}const indexOfFirstLegalDollar=e=>{var t;const n=e.match(/(?<prefix>[^\$\\]|^)(\$|\$\$)(?!\$)/);if(!n)return-1;const{index:r=0}=n,s=null==(t=null==n?void 0:n.groups)?void 0:t.prefix;return lodash_es_isString(s)?r+s.length:-1},lengthOfDollorPrefix=e=>{const t=e.match(/^\$*/);return t?t[0].length:0},findStartIndexOfNoneTexSuffix=e=>{let t=indexOfFirstLegalDollar(e),n=0,r=!0;for(;-1!==t;){const s=texMathExtract(e.slice(t));if(s){const{endIndex:e}=s;t+=e,r=!1,n=t}else{const n=indexOfFirstLegalDollar(e.slice(t));if(-1===n)break;t+=r?Math.max(n,lengthOfDollorPrefix(e.slice(t))):n,r=!0}}return n},RAW_NUMBER_REST_STRING_LENGTH_THRESHOLD=10,enSentenceRegexFullMatch=/^[0-9a-zA-Z\s"'\.,\-\(\)]$/,enSentenceRegexWithCountOfPrefixMatch=/^[0-9a-zA-Z\s"'\.,\-\(\)]{15}/,unpairedLongMathRegex=/^\s*(\\begin)/,shouldStopAutofix=(e,t)=>{const n=e.trim(),r=n.slice(0,t),s=n.length;return!unpairedLongMathRegex.exec(n)&&(!r||isNumeric(r)?s-t>10:!!(enSentenceRegexFullMatch.exec(r)&&s-t>10)||!!enSentenceRegexWithCountOfPrefixMatch.exec(r))};class AutofixTruncatedTexMathDollarAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_tex_math_dollar",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n,katex:r})=>{if(r&&!all_in_one_index_isParent(e))if(isLiteralOfContent(e)&&n(),"text"===e.type){const n=findStartIndexOfNoneTexSuffix(e.value),s=e.value.slice(n).match(/^(?<prefix>[\s\S]*?([^\$\\]|^))(?<inter>\$|\$\$)(?!\$)(?<value>[^\$]*?)(?<suffix>\$*)$/),i=null==s?void 0:s.groups;if(!i)return;const{prefix:a,value:o}=i,l=findMaxLegalPrefixEndIndex({src:o,katex:r});if(shouldStopAutofix(o,l))return;const c=o.slice(0,l).trim(),u=`${e.value.slice(0,n)}${a}`;t(lodash_es_concat(u?{type:"text",value:u}:[],c?{type:"inlineMath",value:c}:[]),!0)}else if("inlineMath"===e.type||"math"===e.type){const n="math"===e.type?e.meta??e.value:e.value,s=findMaxLegalPrefixEndIndex({src:n,katex:r});if(shouldStopAutofix(n,s)){return void t(["inlineMath"===e.type?{type:"text",value:`$${n}$`}:{type:"paragraph",children:[{type:"text",value:`$$${n}$$`}]}],!0)}const i=n.slice(0,s).trim(),a="inlineMath"===e.type?{type:"inlineMath",value:i}:{type:"paragraph",children:[{type:"inlineMath",value:i}]};t(i?[a]:[],!0)}}}}class AutofixHeadingAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_heading",this.config={order:"pre_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n})=>{all_in_one_index_isParent(e)?isHeading(e)&&(1!==e.depth||stringifyChildren(e.children).trim()||t([],!0),n()):n()}}}const all_in_one_index_ellipsisContent="...";class InsertEllipsisAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="insert_ellipsis",this.config={isReverse:!0,priority:AstPluginPriority.After},this.modifier=(e,{insertAfter:t,stop:n})=>{isParentOfContent(e)&&!isTypeOfContent(e,"link")||(n(),isTypeOfContent(e,"text")&&t([{type:"text",value:`${e.value}...`}],!0),isTypeOfContent(e,"link","inlineCode")&&t([{type:"text",value:"..."}],!1))}}}class RemoveBreakBeforeHtmlAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="remove_break_before_html",this.modifier=(e,{parent:t,index:n})=>{if(!isLiteralOfContent(e)||"html"!==e.type||!t||lodash_es_isUndefined(n))return;const r=getByIndex(null==t?void 0:t.children,n-1);r&&"break"===r.type&&t.children.splice(n-1,1)}}}class TransformEndlineBeforeHtmlAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="transform_endline_before_html",this.config={order:"pre_order"},this.modifier=(e,{index:t,parent:n})=>{if(!isLiteralOfContent(e)||"html"!==e.type||!n||!t)return;const r=n.children[t-1];if("text"!==r.type)return;const s=/(\r?\n|\r)$/;s.test(r.value)&&n.children.splice(t-1,1,{type:"text",value:r.value.replace(s,"")},{type:"html",value:"<br />"})}}}class DisableIllegalHtmlAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="disable_illegal_html",this.config={order:"pre_order",isReverse:!0},this.modifier=(e,{insertAfter:t,enabledHtmlTags:n})=>{isLiteralOfContent(e)&&"html"===e.type&&t([{type:"html",value:autoDisableHtmlTag(e.value,n)}],!0)}}}class RestoreMathPandocLatexInContentAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="restore_math_pandoc_latex_in_content",this.config={order:"pre_order"},this.modifier=(e,{insertAfter:t})=>{isLiteralOfContent(e)&&isTypeOfContent(e,"code","inlineCode","math","inlineMath")&&t([{...e,value:restoreMathPandocLatex(e.value)}],!0)}}}const autoSpacingGroupPatterns=[String.raw`\{${"insert_element"}_[0-9]+_.*?\}`];class AutoSpacingAllTextAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="auto_spacing_all_text",this.config={priority:AstPluginPriority.AfterAll,order:"pre_order",isReverse:!0},this.modifier=(e,{insertAfter:t})=>{if(!isTypeOfContent(e,"text"))return;const{value:n}=e;t([{type:"text",value:splitStringByPattern(n,new RegExp(`(${autoSpacingGroupPatterns.map((e=>`(${e})`)).join("|")})`,"g")).map((e=>pangu.spacing(e))).join("")}],!0)}}}class AutofixTruncatedStrongAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_strong",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=[(e,{insertAfter:t,stop:n,parent:r})=>{var s;if(!isTypeOfContent(e,"text")||!r||!isTypeOfContent(r,"paragraph"))return void n();const i=null==(s=e.value.match(/^(?<prefix>[\s\S]*?)(_{2}|\*{2})(?<suffix>[\s\S]*?)\*?$/))?void 0:s.groups;if(!i)return;const{prefix:a,suffix:o}=i,l=[];a&&l.push({type:"text",value:a}),o&&l.push({type:"strong",children:[{type:"text",value:o}]}),t(l,!0)},(e,{stop:t,parent:n,index:r})=>{if(!isParentOfContent(e))return;if(!isTypeOfContent(e,"emphasis")||!n||lodash_es_isUndefined(r))return void t();const s=n.children[r-1];if(!s||!isTypeOfContent(s,"text"))return void t();const i=/(?<prefix>(.*[^\*])|^)\*$/.exec(s.value);if(!i)return void t();const{prefix:a}=i.groups??{},o=[];a&&o.push({type:"text",value:a}),o.push({type:"strong",children:e.children}),n.children.splice(r-1,2,...o)},(e,{stop:t,insertAfter:n})=>{if(isParentOfContent(e)&&"listItem"!==e.type){if("list"===e.type)return!e.children.length||1===e.children.length&&!e.children[0].children.length?(n([],!0),void t()):void 0;t()}}]}}const splitByLastSingleAsterisk=e=>{if(e.includes("*"))for(let t=e.length-1;t>=0;t--){const n=e[t],r=e[t-1],s=e[t+1];if("*"===n&&"*"!==r&&"*"!==s)return[e.slice(0,t),e.slice(t+1)]}};class AutofixTruncatedEmphasisAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_emphasis",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n,parent:r})=>{if(isLiteralOfContent(e)&&r&&isTypeOfContent(r,"paragraph")){if("text"===e.type){const n=splitByLastSingleAsterisk(e.value);if(!n)return;const[r,s]=n,i=[];r&&i.push({type:"text",value:r}),s&&i.push({type:"emphasis",children:[{type:"text",value:s}]}),t(i,!0)}}else n()}}}class AutofixTruncatedListAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_list",this.config={isReverse:!0,fixEndingOnly:!0},this.modifier=[(e,{insertAfter:t,stop:n,index:r,parent:s})=>{if(all_in_one_index_isParent(e))return void(isTypeOfContent(e,"paragraph")||isRoot(e)||n());if(!isTypeOfContent(e,"text"))return void n();if(lodash_es_isUndefined(r)||0!==r||!s||s.children.length>1)return void n();const i=/^(?<prefix>.*)\n\s*(?<value>([0-9]+?\.?)|(\-\s*))$/.exec(e.value);if(i){const{prefix:e}=i.groups??{};t([{type:"text",value:e}],!0)}else/^\s*[0-9]+$/.exec(e.value)&&t([],!0);n()},(e,{insertAfter:t,stop:n,index:r,parent:s,parents:i})=>{if(all_in_one_index_isParent(e))return void(isTypeOfContent(e,"list","listItem","paragraph")||isRoot(e)||n());if(!isTypeOfContent(e,"text"))return void n();if(!(s&&isTypeOfContent(i[0],"paragraph")&&isTypeOfContent(i[1],"listItem")&&isTypeOfContent(i[2],"list")))return void n();if(r!==s.children.length-1)return void n();const a=/^(?<prefix>.*)\n\s*(?<value>[0-9]+?)$/.exec(e.value);if(a){const{prefix:e}=a.groups??{};t([{type:"text",value:e}],!0)}n()}]}}class SetEmphasisAsImageTitleAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="set_emphasis_as_image_title",this.config={order:"pre_order",isReverse:!0},this.modifier=(e,{parent:t,index:n})=>{if(!t||lodash_es_isUndefined(n)||!all_in_one_index_isImage(e))return;const r=getByIndex(t.children,n+1),s=getByIndex(t.children,n+2);if(!r||!s)return;if(!isTypeOfContent(r,"text")||"\n"!==r.value)return;if(!isTypeOfContent(s,"emphasis"))return;const{children:i}=s,{url:a}=e,o=stringifyChildren(i,!0);t.children.splice(n,3,{type:"image",url:a,alt:o})}}}const getStartIndexOfCodeBlockFirstLine=e=>{var t;const n=e.match(/^(?<prefix>[\s]+)```/);return n?(null==(t=n.groups)?void 0:t.prefix.length)??null:null};class SetCodeBlockIndentAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="set_code_block_indent",this.modifier=(e,{source:t,parent:n,insertAfter:r,skip:s})=>{if(all_in_one_index_isParent(e)&&n)return void s();if(!isLiteralOfContent(e))return;if("code"!==e.type)return;const{start:i}=e.position??{};if(!i)return;const{line:a}=i,o=getByIndex(t.split("\n"),a-1),{meta:l,lang:c}=e;if(lodash_es_isUndefined(o))return;const u=getStartIndexOfCodeBlockFirstLine(o);if(null===u)return;const d=`__indent=${u}`,p=l?`${d} ${l}`:d;r([{...e,meta:p,lang:c??"plaintext"}],!0)}}}class RemoveLastEmptyCodeBlockAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="remove_last_empty_code_block",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n})=>{if(!isLiteralOfContent(e))return;if(n(),"code"!==e.type)return;const{value:r,lang:s,meta:i}=e;r||s||i||t([],!0)}}}class CompleteTruncatedLinkSourcePlugin extends BaseSourcePlugin{constructor(){super(...arguments),this.name="complete_truncated_link",this.modifier=({source:e})=>e.replace(/(^|[^!])\[(?<text>[^\]\n]+)\]\([^\)\n]*$/,"$1[$2](#)")}}class CompleteUnpairedCodeBlockSourcePlugin extends BaseSourcePlugin{constructor(){super(...arguments),this.name="complete_unpaired_code_block",this.modifier=({source:e})=>{const t=e.match(/(^|\n)[\s]*?```/g);return t?t.length%2==0?e:`${e.trimEnd()}\n\`\`\``:e}}}class ConvertFullMathPandocLatexSourcePlugin extends BaseSourcePlugin{constructor(){super(...arguments),this.name="convert_full_math_pandoc_latex",this.modifier=({source:e})=>e.replace(/\\\(([\s\S]*?)\\\)/g,((e,t)=>renderInlineMathSpanString(t))).replace(/\\\[([\s\S]*?)\\\]/g,((e,t)=>renderBlockMathSpanString(t)))}}class ConvertEndingMathPandocLatexSourcePlugin extends BaseSourcePlugin{constructor(){super(...arguments),this.name="convert_ending_math_pandoc_latex",this.config={fixEndingOnly:!0},this.modifier=[({source:e,katex:t})=>{if(!t)return e;const n=e.match(/(?<prefix>.*?)\\\((?<ending>[\s\S]*?)$/);if(!(null==n?void 0:n.groups)||lodash_es_isUndefined(n.index))return e;const r=n.groups.ending??"",s=n.groups.prefix??"";if(r.match(/((\\\()|(\\\)))/))return e;const i=r.slice(0,findMaxLegalPrefixEndIndex({src:r,katex:t})).trim();return i?`${s}${renderInlineMathSpanString(i)}`:s},({source:e,katex:t})=>{if(!t)return e;const n=e.match(/(?<prefix>.*?)\\\[(?<ending>[\s\S]*?)$/);if(!(null==n?void 0:n.groups)||lodash_es_isUndefined(n.index))return e;const r=n.groups.ending??"",s=n.groups.prefix??"";if(r.match(/((\\\[)|(\\\]))/))return e;const i=r.slice(0,findMaxLegalPrefixEndIndex({src:r,katex:t})).trim();return i?`${s}${renderBlockMathSpanString(i)}`:s}]}}class RemoveLongSpacesSourcePlugin extends BaseSourcePlugin{constructor(){super(...arguments),this.name="remove_long_spaces",this.modifier=({source:e})=>e.replace(/[ ]{500,}/g,(e=>e.slice(0,500)))}}const getAstPlugins=({astPlugins:e,autoSpacing:t=!0,autolink:n=!0,imageEmphasisTitle:r=!1,indentFencedCode:s=!0,showIndicator:i=!1,showEllipsis:a=!1})=>{let o=[new AutofixTruncatedEscapePlugin,new RemoveLastEmptyCodeBlockAstPlugin,new AutofixLastCodeBlockAstPlugin,new AutofixLastInlineCodeBlockAstPlugin,new AutofixTruncatedTexMathDollarAstPlugin,new AutofixTruncatedImageAstPlugin,new AutofixTruncatedLinkAstPlugin,new AutofixHeadingAstPlugin,new AutofixTruncatedHtmlTagAstPlugin,new AutofixTruncatedStrongAstPlugin,new AutofixTruncatedEmphasisAstPlugin,new AutofixTruncatedListAstPlugin,new RestoreMathPandocLatexInContentAstPlugin,new DisableIllegalHtmlAstPlugin,new RemoveBreakBeforeHtmlAstPlugin,new TransformEndlineBeforeHtmlAstPlugin,new AutoMergeSiblingTextAstPlugin];return n&&o.push(new ExtractCustomAutolinkAstPlugin),t&&o.push(new AutoSpacingAllTextAstPlugin),r&&o.push(new SetEmphasisAsImageTitleAstPlugin),s&&o.push(new SetCodeBlockIndentAstPlugin),a&&o.push(new InsertEllipsisAstPlugin),i&&o.push(new InsertIndicatorAstPlugin),lodash_es_isArray(e)&&o.push(...e),lodash_es_isFunction(e)&&(o=e(o)),o},getSourcePlugins=({sourcePlugins:e})=>{let t=[new RemoveLongSpacesSourcePlugin,new CompleteUnpairedCodeBlockSourcePlugin,new CompleteTruncatedLinkSourcePlugin,new ConvertFullMathPandocLatexSourcePlugin,new ConvertEndingMathPandocLatexSourcePlugin];return lodash_es_isArray(e)&&t.push(...e),lodash_es_isFunction(e)&&(t=e(t)),t},parseMarkdownAndProcessByPlugins=({source:e,astPlugins:t,sourcePlugins:n,parseAst:r=!0,indentedCode:s=!1,insertedElements:i,fixEnding:a,enabledHtmlTags:o,looseTruncateDataSlot:l,removeTruncatedImage:c,katex:u})=>{try{let d,p=e;return i&&(p=addInsertElementSlotToString(p,i)),n&&(p=processSourceByPlugins({source:p,plugins:n,fixEnding:a,katex:u})),r&&(d=parseMarkdown(p,{enableIndentedCode:s})),t&&d&&(d=processAstByPlugins({ast:d,plugins:t,source:p,fixEnding:a,enabledHtmlTags:o,looseTruncateDataSlot:l,removeTruncatedImage:c,katex:u})),{ast:d,source:d?stringifyMarkdown(d):p}}catch(t){return console.error("[Calypso] Process markdown error: ",t),{source:e}}},parseMarkdownAndProcess=({source:e,processAst:t=!0,processSource:n=!0,showEllipsis:r,showIndicator:s,imageEmphasisTitle:i,indentFencedCode:a,indentedCode:o=!1,insertedElements:l,autolink:c,autoSpacing:u,astPlugins:d,sourcePlugins:p,fixEnding:m=!1,enabledHtmlTags:g=!1,looseTruncateDataSlot:h=!1,removeTruncatedImage:f=!1,katex:x})=>{const y=getAstPlugins({autolink:c,autoSpacing:u,imageEmphasisTitle:i,indentFencedCode:a,showEllipsis:r,showIndicator:s,astPlugins:d}),k=getSourcePlugins({sourcePlugins:p});return parseMarkdownAndProcessByPlugins({source:e,astPlugins:t?y:void 0,sourcePlugins:n?k:void 0,parseAst:t,indentedCode:o,insertedElements:l,fixEnding:m,enabledHtmlTags:g,looseTruncateDataSlot:h,removeTruncatedImage:f,katex:x})},useProcessMarkdown=e=>{const{insertedElements:t}=e,n=lodash_es_values(lodash_es_omit(e,["insertedElements","astPlugins","sourcePlugins"]));return (0,react.useMemo)((()=>parseMarkdownAndProcess(e)),[...n,null==t?void 0:t.length])},useEstablished=e=>{const t=(0,react.useRef)(e);return t.current=t.current||e,t.current},usePreviousRef=e=>{const t=(0,react.useRef)(),n=(0,react.useRef)(e);return n.current!==e&&(t.current=n.current,n.current=e),t},useForceUpdate=()=>{const[,e]=(0,react.useReducer)((e=>e+1),0);return e};function useLatestFunction(e){const t=es_useLatest(e),n=(0,react.useCallback)(((...e)=>{var n;return null==(n=t.current)?void 0:n.call(t,...e)}),[]);return e&&n}const INITIAL_SPEED=.02,EXPECTED_BUFFER_SIZE=15,ELASTIC_COEFFICIENT=1/700/1e3,TICK_DURATION=1e3/60*2,findCommonPrefixLength=(e,t)=>{let n=0,r=Math.max(e.length,t.length);for(;n!==r&&n!==r-1;){const s=Math.floor((n+r)/2);e.slice(0,s)===t.slice(0,s)?n=s:r=s}return n},useSmoothText=(e,t={})=>{const{maxFirstTextSmoothSize:n,trailingSmooth:r,enable:s,pause:i,onSmoothFinished:a,onUpdate:o,onTextBreak:l,maxSpeed:c,expectedBufferSize:u,elasticCoefficient:d,tickDuration:p,initialSpeed:m,breakMode:g}=lodash_es_defaults(lodash_es_isBoolean(t)?{}:{...t},{maxFirstTextSmoothSize:1/0,trailingSmooth:!1,pause:!1,enable:Boolean(t),expectedBufferSize:15,elasticCoefficient:ELASTIC_COEFFICIENT,tickDuration:TICK_DURATION,initialSpeed:.02,breakMode:"prefix"}),h=lodash_es_isNumber(c)&&c>0?c:1/0,f=usePreviousRef(e),x=(0,react.useRef)(e.length<=n?1:e.length),y=(0,react.useRef)(x.current),k=useEstablished(s),T=s||k&&r&&x.current<e.length,[C,v]=(0,react.useState)(!1),E=(0,react.useRef)(m),P=()=>lodash_es_isString(f.current)&&!e.startsWith(f.current);if(P()){let t=0;"start"===g?t=0:"end"===g?t=Math.max(e.length-1,0):"prefix"===g&&(t=Math.max(1,findCommonPrefixLength(f.current??"",e))),x.current=t,y.current=Math.floor(x.current)}const S=y.current,w=T&&!C?e.slice(0,S):e,_=useForceUpdate(),b=e=>{e!==y.current&&(y.current=e,_())},A=useLatestFunction((()=>{v(!0)}));return (0,react.useEffect)((()=>{C&&(b(e.length),v(!1),x.current=e.length)}),[C]),(0,react.useEffect)((()=>{T||null==a||a()}),[T]),es_useInterval((()=>{if(P())null==l||l({prevText:f.current??"",currentText:e}),E.current=m,f.current=void 0;else{const t=Math.max(e.length+(!s&&r?2*u:0),2*u)-x.current,n=d*(t-u);E.current=Math.min(Math.max(0,E.current+p*n),h/1e3);const i=p*E.current;x.current=Math.min(e.length,x.current+i),b(Math.floor(x.current))}}),T&&!i?p:void 0),(0,react.useEffect)((()=>{null==o||o({text:w,speed:1e3*E.current})}),[S]),{text:w,flushCursor:A}},rtlLocaleList=["ae","aeb","ajt","apc","apd","ar","ara","arb","arc","arq","ars","ary","arz","ave","avl","bal","bcc","bej","bft","bgn","bqi","brh","cja","ckb","cld","dcc","dgl","div","drw","dv","fa","fas","fia","fub","gbz","gjk","gju","glk","grc","gwc","gwt","haz","he","heb","hnd","hno","iw","ji","kas","kby","khw","ks","kvx","kxp","kzh","lad","lah","lki","lrc","luz","mde","mfa","mki","mvy","myz","mzn","nqo","oru","ota","otk","oui","pal","pbu","per","pes","phl","phn","pnb","pra","prd","prs","ps","pus","rhg","rmt","scl","sd","sdh","shu","skr","smp","snd","sog","swb","syr","tnf","trw","ug","uig","ur","urd","wni","xco","xld","xmn","xmr","xna","xpr","xsa","ydd","yi","yid","zdj"],retryLoad=(e,t=3,n=1e3)=>new Promise(((r,s)=>{e().then(r).catch((i=>{setTimeout((()=>{1!==t?retryLoad(e,t-1,n).then(r,s):s(i)}),n)}))})),notStringifiedAstType=["code","inlineCode","math","inlineMath"],DETECT_MIN_LENGTH=20,isRTLChar=e=>new RegExp("^[^A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-﷾--]*[֑-߿יִ-﷽ﹰ-ﻼ]").test(e),isRTLOfAstLanguage=async e=>{try{const t=getTextOfAst(e,{filter:e=>!isLiteralOfContent(e)||!notStringifiedAstType.includes(e.type)}).trim(),n=elementAt(t.split("\n"),0);if(!n)return!1;const{franc:r}=await retryLoad((()=>__webpack_require__.e(/* import() */ "691").then(__webpack_require__.bind(__webpack_require__, 51854)))),s=r(n,{minLength:20});return"und"===s?isRTLChar(n.charAt(0)):rtlLocaleList.includes(s)}catch(e){return!1}},useIsRTL=e=>{const[t,n]=(0,react.useState)(!1);return (0,react.useEffect)((()=>{e?(async()=>{const t=await isRTLOfAstLanguage(e);n(t)})():n(!1)}),[e]),t},useHop=({onHop:e,ast:t,text:n,getRenderedText:r})=>{const s=(0,react.useRef)(""),i=es_usePrevious(n),a=es_usePrevious(t);(0,react.useEffect)((()=>{const o=s.current,l=r().trim();if(!lodash_es_isUndefined(o)&&!lodash_es_isUndefined(i)&&!lodash_es_isUndefined(a)&&!lodash_es_isUndefined(t)&&e&&n.length>i.length&&l.length<o.length){const n=getHopDiff(a,t);if(n){const{prevEndNode:r,endNode:s}=n;e({renderedText:l,prevRenderedText:o,ast:t,prevAst:a,prevEndNode:r,endNode:s,prevEndNodeType:convertToStanardNodeTypeEnum(null==r?void 0:r.type),endNodeType:convertToStanardNodeTypeEnum(null==s?void 0:s.type)})}}s.current=l}),[n])},isHTMLElementNode=e=>"undefined"==typeof HTMLElement?e.nodeType===Node.ELEMENT_NODE:e instanceof HTMLElement,replaceToText=e=>{for(const t of e.childNodes)replaceToText(t);if(!isHTMLElementNode(e))return;const{customCopyText:t}=e.dataset;if(!lodash_es_isUndefined(t))return void(e.textContent=t);if("br"===e.tagName.toLowerCase()){const t=document.createElement("span");return t.textContent="\n",void(e.parentElement&&e.parentElement.replaceChild(t,e))}},hasCustomCopyTextElement=e=>Boolean(e.querySelector("[data-custom-copy-text]")),supportClipboard=()=>"undefined"!=typeof navigator&&!lodash_es_isUndefined(navigator.clipboard)&&!lodash_es_isUndefined(navigator.clipboard.read)&&!lodash_es_isUndefined(navigator.clipboard.write)&&"undefined"!=typeof ClipboardItem,parseHtmlToDocumentFragment=e=>{const t=document.createDocumentFragment(),n=document.createElement("div");return n.innerHTML=e,t.append(...n.childNodes),t},useCopy=()=>async()=>{try{const e=window.getSelection();if(!(null==e?void 0:e.rangeCount))return;const t=e.getRangeAt(0).cloneContents();if(!hasCustomCopyTextElement(t)||!supportClipboard())return;const n=await navigator.clipboard.read(),r=lodash_es_head(n);if(assert(r),!r.types.includes("text/html"))return;const s=await r.getType("text/html"),i=await s.text(),a=parseHtmlToDocumentFragment(i);replaceToText(a);const o=a.textContent??"",l=(new XMLSerializer).serializeToString(a);await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([l],{type:"text/html"}),"text/plain":new Blob([o],{type:"text/plain"})})])}catch(e){console.warn("[Calypso] Enhanced replication failed, possibly due to the user's refusal of replication permission. The default replication behavior takes effect, and the original error is:",e)}},isTextType=e=>"text"===e.type,isEndlineText=e=>isTextType(e)&&/^\n+$/.test(getInnerText(e)),isElementType=(e,...t)=>"attribs"in e&&"object"==typeof e.attribs&&("tag"===e.type&&(!(null==t?void 0:t.length)||t.some((t=>lodash_es_isRegExp(t)?t.test(e.name):t===e.name)))),getInnerText=e=>isTextType(e)?e.data:isElementType(e)?e.children.map(getInnerText).join(""):"",detectIsChinese=e=>/[\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u3005\u3007\u3021-\u3029\u3038-\u303B\u3400-\u4DB5\u4E00-\u9FD5\uF900-\uFA6D\uFA70-\uFAD9]/.test(e),renderDom=e=>(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:domToReact([e])}),renderReactElement=(e,t,n)=>"markdown-root"===t.className?(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:n}):(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:(0,react.createElement)(e,t,(null==n?void 0:n.length)?n:void 0)}),createShallowedProvider=e=>{const t=e.Provider;return({value:e,afterMemoedProcess:n,children:r})=>{const s=useCustomMemoValue(e,shallowEqual),i=(0,react.useMemo)((()=>n?n(s):s),[s]);return (0,jsx_runtime.jsx)(t,{value:i,children:r})}},CalypsoConfigContext=(0,react.createContext)({theme:"default",mode:"light"}),CalypsoConfigProvider=createShallowedProvider(CalypsoConfigContext),useCalypsoConfig=()=>(0,react.useContext)(CalypsoConfigContext),CalypsoSlotsInnerContext=(0,react.createContext)(null),CalypsoSlotsInnerProvider=createShallowedProvider$1(CalypsoSlotsInnerContext),useCalypsoSlots=()=>{const e=(0,react.useContext)(CalypsoSlotsInnerContext);if(!e)throw Error("[Calypso Internal Bugs] CalypsoSlotsInnerContext Required");return e},createSlotConsumer=(e,t)=>{const n=n=>{const r=useCalypsoSlots()[e]??t;return r?(0,jsx_runtime.jsx)(r,{...n}):null};return n.displayName=e,n},CalypsoI18nContext=(0,react.createContext)(null),CalypsoI18nProvider=createShallowedProvider(CalypsoI18nContext),AUTO_HIDE_LAST_SIBLING_BR_CLASS="auto-hide-last-sibling-br",BlockElement=({node:e,renderRest:t,style:n,className:r,children:s})=>{const{BreakLine:i}=useCalypsoSlots(),{style:a,className:o,...l}=attributesToProps((null==e?void 0:e.attribs)??{});return (0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[e&&(0,react.createElement)(e.name,{...l,style:{...a,...n},className:classnames(o,r,"auto-hide-last-sibling-br")},...e.children.map(((e,n)=>(0,jsx_runtime.jsx)(react.Fragment,{children:null==t?void 0:t(e)},n)))),lodash_es_isFunction(s)?s({className:classnames("auto-hide-last-sibling-br")}):s,i&&(0,jsx_runtime.jsx)(i,{})]})},ComposedTable=createSlotConsumer("Table"),renderTable=(e,{renderRest:t,parents:n})=>{if(!isElementType(e,"table"))return;const{className:r,...s}=attributesToProps(e.attribs);return (0,jsx_runtime.jsx)(BlockElement,{children:({className:i})=>(0,jsx_runtime.jsx)(ComposedTable,{...s,raw:e,parents:n,className:classnames(r,i),children:domToReact(e.children,{replace:t})})})},ComposedStrong=createSlotConsumer("Strong"),renderStrong=(e,{renderRest:t,parents:n})=>{if(isElementType(e,"strong"))return (0,jsx_runtime.jsx)(ComposedStrong,{node:e,raw:e,parents:n,children:domToReact(e.children,{replace:t})})},ComposedBreakLine=createSlotConsumer("BreakLine"),ComposedBlockquote=createSlotConsumer("Blockquote"),renderSimpleHtml=(e,{renderRest:t,renderHtml:n,renderDataSlot:r,parents:s})=>{if(!isElementType(e))return;const i=e.name.toLowerCase(),a=attributesToProps(e.attribs),o=e.children.length?e.children.map(((e,n)=>(0,jsx_runtime.jsx)(react.Fragment,{children:t(e)},n))):void 0;if(r&&["data-inline","data-block"].includes(i)){const{type:e,value:t,alt:n}=a;return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:r({display:"data-inline"===i?"inline":"block",type:e,value:parseJSONWithNull(he.decode(t,{strict:!1})),alt:n,children:o})??n})}let l;if(n&&(l=null==n?void 0:n({tagName:i,props:a,children:o,node:e,currentHTML:stringifyDomNode(e),childrenHTML:stringifyDomNode(e.childNodes)})),!lodash_es_isUndefined(l))return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:l});if("br"===i)return (0,jsx_runtime.jsx)(ComposedBreakLine,{raw:e,parents:s});if("blockquote"===i)return (0,jsx_runtime.jsx)(ComposedBlockquote,{raw:e,node:e,parents:s,renderRest:t});if("hr"===i)return (0,jsx_runtime.jsx)(BlockElement,{node:e,renderRest:t});if(1===e.children.length){const t=e.children[0];if(isTextType(t)&&!t.data.trim())return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{})}return renderReactElement(i,a,o)},ComposedParagraph=createSlotConsumer("Paragraph"),renderParagraph=(e,{renderRest:t,forceBrInterSpacing:n,parents:r})=>{if(!isElementType(e,"p"))return;const{className:s,...i}=attributesToProps(e.attribs);return (0,jsx_runtime.jsx)(BlockElement,{children:({className:a})=>(0,jsx_runtime.jsx)(ComposedParagraph,{...i,raw:e,parents:r,className:classnames(s,a),forceBrInterSpacing:n,children:domToReact(e.children,{replace:t})})})},ComposedTex=createSlotConsumer("Tex"),renderMath=(e,t={})=>{const{parents:n}=t;if(!isElementType(e,"span"))return;const r=e.attribs["data-type"],s=e.attribs["data-value"];if(s)try{const t=node_modules_buffer.Buffer.from(s,"base64").toString("utf8").trim();if("block-math"===r)return (0,jsx_runtime.jsx)(ComposedTex,{raw:e,parents:n,tex:t,mode:"display"});if("inline-math"===r)return (0,jsx_runtime.jsx)(ComposedTex,{raw:e,parents:n,tex:t,mode:"inline"})}catch(e){return void console.error("[Math Render Error]",e)}},ComposedList=createSlotConsumer("List"),all_in_one_index_renderList=(e,{renderRest:t,parents:n})=>{if(!isElementType(e,"ol","ul"))return;const r=e.children.every((e=>isTextType(e)||isElementType(e,"li")&&!lodash_es_isUndefined(e.children[0])&&isElementType(e.children[0],"input")&&"checkbox"===e.children[0].attribs.type))?"tasklist":void 0;return (0,jsx_runtime.jsx)(ComposedList,{className:r,node:e,raw:e,parents:n,renderRest:t})},ComposedLink=createSlotConsumer("Link"),renderLink=(e,{renderRest:t,customLink:n,callbacks:r={},parents:s})=>{if(!isElementType(e,"a"))return;const{href:i,title:a,...o}=e.attribs,l="autolink"===a;return (0,jsx_runtime.jsx)(ComposedLink,{...attributesToProps(o),raw:e,parents:s,href:i,customLink:n,type:l?"autolink":"markdown",title:l?void 0:a,...pick(r,"onLinkRender","onLinkClick","onSendMessage"),children:domToReact(e.children,{replace:t})})},renderInsertElement=(e,t)=>{var n;const{insertedElements:r=[]}=t;if(!isElementType(e,"span"))return;if("insert_element_extension"!==e.attribs["data-type"])return;const s=e.attribs["data-index"],i=e.attribs["data-raw"];if(lodash_es_isUndefined(s))return;const a=parseInt(s);return a>r.length||null==(n=r[a])?void 0:n.render(i&&node_modules_buffer.Buffer.from(i,"base64").toString("utf-8"))},ComposedIndicator=createSlotConsumer("Indicator"),renderIndicator=(e,t={})=>{var n;const{parents:r}=t;if(isElementType(e,"span")&&"indicator"===(null==(n=e.attribs)?void 0:n.class))return (0,jsx_runtime.jsx)(ComposedIndicator,{raw:e,parents:r})},ComposedImage=createSlotConsumer("Image"),hasSiblingText=(e,t={})=>{const{regardSiblingBrAsText:n=!0}=t,r={hasLeftText:!1,hasRightText:!1};if(!e.parent)return r;const{children:s}=e.parent,i=s.indexOf(e);if(i<0)return r;const a=e=>e<s.length&&e>=0&&(isTextType(s[e])||!!n&&isElementType(s[e],"br"));return{hasLeftText:a(i-1),hasRightText:a(i+1)}},renderImage=(e,t={})=>{const{callbacks:n={},imageOptions:r,marginWithSiblingBr:s=!0,parents:i}=t,{onImageRender:a,onImageClick:o}=n;if(!isElementType(e,"img"))return;const{src:l,alt:c,width:u,height:d}=e.attribs,p=Number(u),m=Number(d),{hasLeftText:g,hasRightText:h}=hasSiblingText(e,{regardSiblingBrAsText:s});return (0,jsx_runtime.jsx)(ComposedImage,{...attributesToProps(e.attribs),raw:e,parents:i,src:safeParseUrl(l)&&l,onImageClick:o,onImageRender:a,imageOptions:{alt:c,objectFit:"cover",objectPosition:"center",height:isNaN(m)?256:m,width:isNaN(p)?400:p,...r},style:{borderRadius:12,overflow:"hidden"},wrapperStyle:{marginTop:g?12:void 0,marginBottom:h?12:void 0},...n})},header$1="_header_1rhdj_1",styles$d={header:header$1},ComposedHeader=createSlotConsumer("Header"),all_in_one_index_renderHeader=(e,{renderRest:t,parents:n})=>{if(isElementType(e,/^h[0-9]+$/))return (0,jsx_runtime.jsx)(ComposedHeader,{className:styles$d.header,node:e,raw:e,parents:n,renderRest:t})},ComposedEmphasis=createSlotConsumer("Emphasis"),renderEm=(e,{renderRest:t,spacingAfterChineseEm:n,parents:r})=>{if(!isElementType(e,"em"))return;const s=void 0!==n&&!1!==n&&detectIsChinese(getInnerText(e).slice(-1)??"")&&!lodash_es_isNull(e.nextSibling)&&(isElementType(e.nextSibling)||isTextType(e.nextSibling))&&detectIsChinese(getInnerText(e.nextSibling).slice(0,1)??"");return (0,jsx_runtime.jsx)(ComposedEmphasis,{style:{marginRight:s?"boolean"==typeof n?2:n:void 0},node:e,raw:e,parents:r,children:domToReact(e.children,{replace:t})})},renderDanger=e=>{if("tag"!==e.type&&"text"!==e.type&&"root"!==e.type)return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{})},DEFAULT_LANGUAGE="plaintext",getCodeElement=e=>isElementType(e,"code")?e:isElementType(e,"pre")?e.childNodes.find((e=>isElementType(e,"code"))):void 0,getLanguageFromElement=(e,t="plaintext")=>{var n,r,s;const i=getCodeElement(e);return i&&(null==(s=null==(r=null==(n=i.attribs)?void 0:n.class)?void 0:r.match(/language-(.*)/))?void 0:s[1])||t},getMetaFromElement=(e,t=!0)=>{const n=getCodeElement(e),r=null==n?void 0:n.attribs["data-meta"];if(r)return t?r.split(/\s+/).filter((e=>!e.match(/^__[^_].*/))).join(" ")||void 0:r},getIndentFromCodeElememt=e=>{var t;const n=getMetaFromElement(e,!1);if(!n)return 0;const r=n.match(/(\s|^)__indent=(?<indent>[0-9]+)(\s|$)/);if(!r)return 0;const s=Number(null==(t=r.groups)?void 0:t.indent);return isNaN(s)?0:s},HIDE_HEADER_LANGUAGES=["result","stderr","stdout"],styles$c={"code-group-item--begin":"_code-group-item--begin_1wdrc_1","code-group-item--center":"_code-group-item--center_1wdrc_5","code-group-item--end":"_code-group-item--end_1wdrc_8"},INDENT_WIDTH=18,ComposedCodeBlock=createSlotConsumer("CodeBlock"),isCodeBlockElement=e=>{if(!isElementType(e,"pre"))return!1;const{childNodes:t}=e;return!!t.find((e=>isElementType(e,"code")))},EmptyWrapperElement=({children:e})=>(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:e()}),renderCodeBlocks=(e,t)=>{const{autoHideCodeHeaderLanguage:n=HIDE_HEADER_LANGUAGES,renderRest:r,parents:s,callbacks:i={},indentTabs:a=0,loading:o}=t,{onCopyCodeBlock:l}=i,c=Array.isArray(n)?n:[n],u=BlockElement;return (0,jsx_runtime.jsx)(EmptyWrapperElement,{children:({className:t}={className:""})=>e.map((({target:n},i)=>{if(!isCodeBlockElement(n))return null;const d=styles$c["code-group-item--"+(e.length,"normal")],{childNodes:p=[]}=n;return p.map(((e,n)=>(0,jsx_runtime.jsx)(u,{children:()=>{if(isElementType(e,"code")){const t=getLanguageFromElement(e),r=getMetaFromElement(e);return (0,jsx_runtime.jsx)(ComposedCodeBlock,{parents:s,code:getInnerText(e),language:t,meta:r,showHeader:!c.includes(t.toLowerCase()),className:d,onCopyCode:l,style:{marginLeft:a?18*a+"px":void 0},loading:o},n)}return isElementType(e)?(0,jsx_runtime.jsx)("pre",{className:t,children:r(e)},n):(0,jsx_runtime.jsx)("pre",{className:t,children:domToReact([e])},n)}})))}))})},splitToCodeBlockGroup=({children:e,adjacentCodeAsGroup:t=!0})=>{const n=[];let r=null;for(const s of e)if(isCodeBlockElement(s)){const e=elementAt(n,n.length-1),r={target:s,language:getLanguageFromElement(s,""),code:innerText(s)};(null==e?void 0:e.isCodeBlockGroup)&&t?e.codeBlocks.push(r):n.push({isCodeBlockGroup:!0,codeBlocks:[r]})}else isEndlineText(s)?r=s:(r&&(n.push({isCodeBlockGroup:!1,target:r,code:innerText(r)}),r=null),n.push({isCodeBlockGroup:!1,target:s,code:isElementType(s)||isTextType(s)?innerText(s):""}));return n},renderCodeBlock=(e,{renderRest:t,adjacentCodeAsGroup:n,callbacks:r={}})=>{if(!isElementType(e))return;const{childNodes:s}=e;if(s.every((e=>!isCodeBlockElement(e))))return;const i=splitToCodeBlockGroup({children:s,adjacentCodeAsGroup:n});return renderReactElement(e.name,attributesToProps(e.attribs),i.map(((e,n)=>{if(e.isCodeBlockGroup){const{codeBlocks:s}=e,a=n===i.length-1,o=Math.min(8,...s.map((e=>Math.floor(getIndentFromCodeElememt(e.target)/2))));return renderCodeBlocks(s,{renderRest:t,callbacks:r,indentTabs:o,loading:a,autoHideCodeHeaderLanguage:[]})}return (0,jsx_runtime.jsx)(react.Fragment,{children:t(e.target)},n)})))},renderCustomNode=(e,t={})=>{const{parents:n=[],callbacks:r={},insertedElements:s,imageOptions:i,adjacentCodeAsGroup:a,forceBrInterSpacing:o,spacingAfterChineseEm:l,customLink:c,renderHtml:u,renderRawHtml:d,renderDataSlot:p}=t,m=r=>renderCustomNode(r,{...t,parents:[e,...n]}),g=isElementType(e)?e.name.toLowerCase():"",h=isElementType(e)?attributesToProps(e.attribs):{};return(()=>{if(d&&isElementType(e))return d({tagName:g,props:h,parents:n,renderRest:m,node:e,currentHTML:stringifyDomNode(e),childrenHTML:stringifyDomNode(e.children)})})()??renderMath(e,{parents:n})??(s&&renderInsertElement(e,{insertedElements:s}))??renderDanger(e)??renderLink(e,{callbacks:r,customLink:c,parents:n,renderRest:m})??renderImage(e,{callbacks:r,imageOptions:i,marginWithSiblingBr:!o,parents:n})??renderCodeBlock(e,{adjacentCodeAsGroup:a,callbacks:r,renderRest:m})??renderIndicator(e,{parents:n})??renderParagraph(e,{forceBrInterSpacing:o,parents:n,renderRest:m})??renderTable(e,{parents:n,renderRest:m})??all_in_one_index_renderList(e,{parents:n,renderRest:m})??all_in_one_index_renderHeader(e,{parents:n,renderRest:m})??renderEm(e,{parents:n,renderRest:m,spacingAfterChineseEm:l})??renderStrong(e,{parents:n,renderRest:m})??renderSimpleHtml(e,{parents:n,renderRest:m,renderDataSlot:p,renderHtml:u})??renderDom(e)},wrapHtmlByMarkdownRoot=e=>`<div class="markdown-root">${e}</div>`,Markdown=({markDown:e,smartypants:t=!1,enabledHtmlTags:n,purifyHtml:r=!0,purifyHtmlConfig:s,modifyHtmlNode:i,...a})=>{const o=(0,react.useMemo)((()=>new CalypsoTokenizer),[]),l=useDeepCompareMemo((()=>getCalypsoRenderer({enabledHtmlTags:n})),[n]),c=useDeepCompareMemo((()=>{const e=new Marked({extensions:[insertElementSlotExtension(),inlineTex(),displayTex()]});return e.setOptions({gfm:!0,silent:!0,breaks:!0}),e.use({extensions:[insertElementSlotExtension(),inlineTex(),displayTex()]}),e.use(mangle()),t&&e.use(markedSmartypants()),e}),[t,n]),u=pipe((e=>c.parse(e,{tokenizer:o,renderer:l})),transformSelfClosing,(e=>{const t=(()=>{const e=lodash_es_isArray(n)?n:void 0,t={ALLOW_UNKNOWN_PROTOCOLS:!0,RETURN_DOM:!1};e&&(t.ADD_TAGS=e);const r=lodash_es_isFunction(s)?s(t):s;if(r){const{ALLOW_UNKNOWN_PROTOCOLS:e,RETURN_DOM:n,...s}=r;lodash_es_isUndefined(e)||(t.ALLOW_UNKNOWN_PROTOCOLS=e),lodash_es_isUndefined(n)||(t.RETURN_DOM=n),lodash_es_assign(t,s)}return t})();return lodash_es_isFunction(r)?r(e,t):r?purifyHtml(e,t):e}),wrapHtmlByMarkdownRoot),d=(0,react.useMemo)((()=>u(e)),[e,c]),p=(0,react.useMemo)((()=>{const e=htmlToDOM(d);return(null==i?void 0:i(e))??e}),[d]);return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:domToReact(p,{replace:e=>renderCustomNode(e,a)})})},container$6="_container_7mgzw_1",all_in_one_index_active="_active_7mgzw_7",blink="_blink_7mgzw_35",all_in_one_index_frame="_frame_7mgzw_631",all_in_one_index_enabled="_enabled_7mgzw_792",cursorAnimation="_cursorAnimation_7mgzw_1",styles$b={container:container$6,active:all_in_one_index_active,blink:blink,"no-list":"_no-list_7mgzw_553",frame:all_in_one_index_frame,"align-center":"_align-center_7mgzw_654","align-right":"_align-right_7mgzw_669","float-left":"_float-left_7mgzw_684","float-right":"_float-right_7mgzw_693",enabled:all_in_one_index_enabled,cursorAnimation:cursorAnimation},CalypsoSlotsContext=(0,react.createContext)(null);createShallowedProvider$1(CalypsoSlotsContext);const emptySlots={BreakLine:null,Tex:null,CodeBlockHighlighter:null,CodeBlock:null,Table:null,Image:null,Indicator:null,Paragraph:null,Link:null,Emphasis:null,Strong:null,Header:null,List:null,Blockquote:null},MarkdownEngine=(0,react.forwardRef)((function({className:e,style:t,mode:n="light",markDown:r,eventCallbacks:s,showIndicator:i=!1,autoFixSyntax:a=!0,smooth:o=!1,insertedElements:l=[],showEllipsis:c=!1,imageOptions:u,autoFitRTL:d=!1,forceBrInterSpacing:p,spacingAfterChineseEm:m=2,indentFencedCode:g,indentedCode:h,smartypants:f,enhancedCopy:x=!1,autolink:y,customLink:k,autoSpacing:T,slots:C={},translate:v={},enabledHtmlTags:E,purifyHtml:P,purifyHtmlConfig:S,astPlugins:w,sourcePlugins:_,modifyHtmlNode:b,renderHtml:A,renderRawHtml:L,renderDataSlot:R,onAstChange:N,onHop:I,...M},$){const H=(0,react.useContext)(CalypsoSlotsContext),B={...emptySlots,...H,...C},j={theme:"default",mode:n},{Indicator:O}=B,{text:F,flushCursor:D}=useSmoothText(r,o),{katex:z,autoFixEnding:U,imageEmphasisTitle:q}=lodash_es_defaults(lodash_es_isBoolean(a)?{}:a,{autoFixEnding:!1}),Z=(0,react.useMemo)((()=>R&&!0!==E?[...E||[],"data-block","data-inline"]:E),[E,Boolean(R)]),{source:W,ast:V}=useProcessMarkdown({source:F,processAst:Boolean(a),showEllipsis:c,showIndicator:i,imageEmphasisTitle:q,indentFencedCode:g,indentedCode:h,insertedElements:l,autolink:y,autoSpacing:T,astPlugins:w,sourcePlugins:_,fixEnding:U,enabledHtmlTags:Z,looseTruncateDataSlot:Boolean(R),katex:z}),G=useIsRTL(d?V:void 0),K=useCopy(),X=(0,react.useRef)(null);useHop({onHop:I,ast:V,text:F,getRenderedText:()=>{var e;return(null==(e=X.current)?void 0:e.textContent)??""}}),(0,react.useEffect)((()=>{null==N||N(V)}),[V]),(0,react.useImperativeHandle)($,(()=>({getRootElement:()=>X.current,flushSmoothCursor:D})),[]);return W.trim()?(0,jsx_runtime.jsx)(CalypsoConfigProvider,{value:j,children:(0,jsx_runtime.jsx)(CalypsoSlotsInnerProvider,{value:B,afterMemoedProcess:e=>e?{...e}:e,children:(0,jsx_runtime.jsx)(CalypsoI18nProvider,{value:v,children:(0,jsx_runtime.jsx)("div",{...M,ref:X,"theme-mode":n,className:classnames(styles$b.container,"flow-markdown-body",styles$b[`theme-${j.theme}`],e),style:t,dir:G?"rtl":"ltr","data-show-indicator":i,onCopy:x?K:void 0,children:(0,jsx_runtime.jsx)(Markdown,{markDown:W,callbacks:s,insertedElements:l,imageOptions:u,forceBrInterSpacing:p,spacingAfterChineseEm:m,smartypants:f,customLink:k,enabledHtmlTags:Z,purifyHtml:P,purifyHtmlConfig:S,modifyHtmlNode:b,renderHtml:A,renderRawHtml:L,renderDataSlot:R})})})})}):(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[c&&"...",i&&O&&(0,jsx_runtime.jsx)(O,{})]})})),CalypsoCore=(0,react.forwardRef)((function({plugins:e=[],slots:t={},astPlugins:n=[],sourcePlugins:r=[],modifyHtmlNode:s,renderHtml:i,renderRawHtml:a,...o},l){const c=(0,react.useMemo)((()=>aggregatePlugins(e)),[e]),u=(0,react.useMemo)((()=>({...c.slots,...t})),[t,c.slots]);function d(e){return e?"function"==typeof e?e([]):e:[]}const p=[...d(n),...c.astPlugins],m=[...d(r),...c.sourcePlugins],g=c.modifyHtmlNode||s,h=c.renderHtml||i,f=c.renderRawHtml||a;return (0,jsx_runtime.jsx)(MarkdownEngine,{ref:l,slots:u,astPlugins:p,sourcePlugins:m,modifyHtmlNode:g,renderHtml:h,renderRawHtml:f,...o})}));function composeModifyHtmlNode(e){if(e.length)return t=>{let n=t;return e.forEach((e=>{const t=e(n);t&&(n=t)})),n}}function composeRenderer(e){if(e.length)return t=>{for(const n of e){const e=n(t);if(null!=e)return e}}}function aggregatePlugins(e){let t={};const n=[],r=[],s=[],i=[],a=[];return e.forEach((e=>{var o,l;e.slots&&(t={...t,...e.slots}),(null==(o=e.astPlugins)?void 0:o.length)&&n.push(...e.astPlugins),(null==(l=e.sourcePlugins)?void 0:l.length)&&r.push(...e.sourcePlugins),e.modifyHtmlNode&&s.push(e.modifyHtmlNode),e.renderHtml&&i.push(e.renderHtml),e.renderRawHtml&&a.push(e.renderRawHtml)})),{slots:t,astPlugins:n,sourcePlugins:r,modifyHtmlNode:composeModifyHtmlNode(s),renderHtml:composeRenderer(i),renderRawHtml:composeRenderer(a)}}const LightTex=({tex:e,mode:t,className:n,style:r})=>(0,jsx_runtime.jsx)("span",{className:classnames("math-inline",n),style:r,children:e}),texLightPlugin={name:"tex-light",slots:{Tex:LightTex}},styles$a={"table-container":"_table-container_18bux_1"},all_in_one_index_Table=({children:e,className:t,raw:n,parents:r,...s})=>(0,jsx_runtime.jsx)("div",{className:classnames(t,styles$a["table-container"]),...s,children:(0,jsx_runtime.jsx)("table",{children:e})}),tablePlugin={name:"table",slots:{Table:all_in_one_index_Table}},Strong=({className:e,style:t,children:n})=>(0,jsx_runtime.jsx)("strong",{className:e,style:t,children:n}),strongPlugin={name:"strong",slots:{Strong:Strong}},all_in_one_index_paragraph="_paragraph_1b2re_1",styles$9={paragraph:all_in_one_index_paragraph},all_in_one_index_Paragraph=({children:e,className:t,forceBrInterSpacing:n=!1,raw:r,parents:s,...i})=>(0,jsx_runtime.jsx)("div",{className:classnames(t,styles$9.paragraph,"paragraph-element",{"br-paragraph-space":n}),...i,children:(0,react.isValidElement)(e)?(0,react.cloneElement)(e,{key:"0"}):e}),paragraphPlugin={name:"paragraph",slots:{Paragraph:all_in_one_index_Paragraph}},all_in_one_index_List=({className:e,style:t,node:n,children:r,renderRest:s})=>(0,jsx_runtime.jsx)(BlockElement,{className:e,style:t,node:n,renderRest:s,children:r}),listPlugin={name:"list",slots:{List:all_in_one_index_List}},all_in_one_index_link="_link_eyymc_1",styles$8={link:all_in_one_index_link},isHttpLink=e=>{const t=safeParseUrl(e);return!!t&&("http:"===t.protocol||"https:"===t.protocol)},all_in_one_index_Link=({className:e,style:t,href:n,children:r,customLink:s=!0,onLinkClick:i,onLinkRender:a,onOpenLink:o,type:l,raw:c,parents:u,...d})=>{const p=n?safeParseUrl(n):null,m=useComputeValue((()=>!!n&&(!!isHttpLink(n)||(lodash_es_isFunction(s)?s(n):s)))),g=e=>{o?null==o||o(e):window.open(e)};return (0,react.useEffect)((()=>{n&&p&&(null==a||a({url:n,parsedUrl:p}))}),[n]),m?(0,jsx_runtime.jsx)("a",{...lodash_es_omit(d,"href"),className:classnames(styles$8.link,e),style:t,onClick:e=>{n&&p?isHttpLink(n)&&(i?i(e,{url:n,parsedUrl:p,exts:{type:LinkType.normal},openLink:g}):(e.preventDefault(),e.stopPropagation(),g(n))):e.preventDefault()},href:p?n:void 0,target:"_blank",children:r}):(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:r})},linkPlugin={name:"link",slots:{Link:all_in_one_index_Link}},styles$7={},all_in_one_index_Indicator=({className:e,style:t})=>(0,jsx_runtime.jsx)("span",{className:styles$7.container,children:(0,jsx_runtime.jsx)("span",{className:classnames(styles$7.indicator,styles$7.flashing,e),style:t,"data-testid":"indicator"})}),indicatorPlugin={name:"indicator",slots:{Indicator:all_in_one_index_Indicator}},all_in_one_index_SvgIconError=e=>react.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},react.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 21.375C6.82233 21.375 2.625 17.1777 2.625 12C2.625 6.82233 6.82233 2.625 12 2.625C17.1777 2.625 21.375 6.82233 21.375 12C21.375 17.1777 17.1777 21.375 12 21.375ZM0.75 12C0.75 5.7868 5.7868 0.75 12 0.75C18.2132 0.75 23.25 5.7868 23.25 12C23.25 18.2132 18.2132 23.25 12 23.25C5.7868 23.25 0.75 18.2132 0.75 12ZM11.9911 13.6761C11.3638 13.6761 11.0393 13.3623 11.0174 12.7348L10.8752 7.87488C10.8606 7.55381 10.9591 7.29476 11.1706 7.09774C11.3821 6.89342 11.6519 6.79126 11.9801 6.79126C12.3083 6.79126 12.5818 6.89342 12.8006 7.09774C13.0194 7.30206 13.1215 7.56475 13.107 7.88583L12.9429 12.7238C12.921 13.3587 12.6037 13.6761 11.9911 13.6761ZM11.9911 17.1349C11.6483 17.1349 11.3529 17.0255 11.1049 16.8066C10.8642 16.5877 10.7439 16.3104 10.7439 15.9747C10.7439 15.639 10.8642 15.3617 11.1049 15.1428C11.3456 14.9239 11.641 14.8144 11.9911 14.8144C12.3412 14.8144 12.6365 14.9239 12.8772 15.1428C13.1252 15.3617 13.2492 15.639 13.2492 15.9747C13.2492 16.3177 13.1252 16.5986 12.8772 16.8175C12.6365 17.0291 12.3412 17.1349 11.9911 17.1349Z",fill:"#999999"})),container$5="_container_hux85_1",centered="_centered_hux85_8",all_in_one_index_image="_image_hux85_11",fallbackIcon="_fallbackIcon_hux85_30",square="_square_hux85_40",all_in_one_index_clickable="_clickable_hux85_45",all_in_one_index_title="_title_hux85_48",styles$6={container:container$5,centered:centered,image:all_in_one_index_image,"loading-image":"_loading-image_hux85_16","error-wrapper":"_error-wrapper_hux85_21",fallbackIcon:fallbackIcon,"image-wrapper":"_image-wrapper_hux85_35",square:square,clickable:all_in_one_index_clickable,title:all_in_one_index_title},convertHttpToHttps=e=>{const t=new URL(e);return"http:"===t.protocol&&(t.protocol="https:"),t.toString()},all_in_one_index_Image=({className:e,style:t,raw:n,parents:r,wrapperClassName:s,wrapperStyle:i,src:a=null,otherFormatSrc:o,onImageClick:l,onImageRender:c,imageOptions:u={layout:"intrinsic",objectFit:"contain"},errorClassName:d,children:p,onImageLoadComplete:m,useCustomPlaceHolder:g=!1,customPlaceHolder:h,onImageContextMenu:f,onImageMouseEnter:x,...y})=>{const{squareContainer:k=!1,forceHttps:T=!1,responsiveNaturalSize:C=!1,width:v=400,height:E=256,showTitle:P=!1,centered:S=!1,...w}=u,{alt:_}=u,[b,A]=(0,react.useState)(v),[L,R]=(0,react.useState)(E);(0,react.useEffect)((()=>{(v||E)&&(A(v),R(E))}),[v,E]);const{minHeight:N,minWidth:I,maxHeight:M,maxWidth:$}=lodash_es_defaults(lodash_es_isBoolean(C)?{}:{...C},{minHeight:0,minWidth:0,maxWidth:v??400,maxHeight:E??256}),H=a&&(T?convertHttpToHttps(a):a),[B,j]=(0,react.useState)(ImageStatus.Loading),O=B!==ImageStatus.Loading,F={src:H,status:B},D=(C||g)&&!O;(0,react.useEffect)((()=>{H&&(null==c||c(F))}),[H]);const z=lodash_es_isNumber(b)&&lodash_es_isNumber(L)&&{width:"100%",height:0,paddingBottom:`min(${L/b*100}%, ${L}px)`,maxWidth:b};return (0,jsx_runtime.jsxs)("div",{className:classnames(styles$6.container,{[styles$6.centered]:S}),style:i,children:[(0,jsx_runtime.jsx)("div",{onClick:e=>{l&&F&&(l(e,F),e.stopPropagation())},className:classnames(styles$6["image-wrapper"],{[styles$6.clickable]:Boolean(l),[styles$6.square]:k},s),style:{...z},"data-testid":"calypso_image",children:p||(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[C&&!O&&!g&&(0,jsx_runtime.jsx)("span",{className:styles$6["loading-image"],children:(0,jsx_runtime.jsx)(Viewer,{...y,...w,height:L,width:b,placeholder:"skeleton",src:""})}),(0,jsx_runtime.jsx)("span",{style:{display:"inline-block",...D?{width:0,height:0}:{}},children:(0,jsx_runtime.jsx)(Viewer,{...y,...w,onContextMenu:f,onMouseEnter:x,height:L,width:b,alt:"image",src:H??"",formats:["avif","webp"],placeholder:"skeleton",loader:({extra:{origin:e},format:t})=>(null==o?void 0:o.avifSrc)&&"avis"===t?null==o?void 0:o.avifSrc:(null==o?void 0:o.webpSrc)&&"awebp"===t?null==o?void 0:o.webpSrc:H??e,error:(0,jsx_runtime.jsx)("div",{className:classnames(styles$6["error-wrapper"],d,"error-wrapper"),ref:()=>{j(ImageStatus.Failed),null==m||m()},children:(0,jsx_runtime.jsx)(all_in_one_index_SvgIconError,{className:styles$6.fallbackIcon})}),onLoadingComplete:e=>{var t;j(ImageStatus.Success),null==m||m();const{naturalWidth:n,naturalHeight:r}=e;if(C&&n&&r){const e=resizeImage({width:n,height:r,minHeight:N,minWidth:I,maxHeight:M,maxWidth:$});A(e.width),R(e.height)}null==(t=w.onLoadingComplete)||t.call(w,e)},className:classnames(e,styles$6.image),style:t})}),g&&!O&&h]})}),P&&_&&(0,jsx_runtime.jsx)("div",{className:styles$6.title,children:_})]})},imagePlugin={name:"samantha-image",slots:{Image:all_in_one_index_Image}},all_in_one_index_Header=({className:e,style:t,node:n,children:r,renderRest:s})=>(0,jsx_runtime.jsx)(BlockElement,{className:e,style:t,node:n,renderRest:s,children:r}),headerPlugin={name:"header",slots:{Header:all_in_one_index_Header}},Emphasis=({className:e,style:t,children:n})=>(0,jsx_runtime.jsx)("em",{className:e,style:t,children:n}),emphasisPlugin={name:"emphasis",slots:{Emphasis:Emphasis}};let fullLanguages=null;const fetchFullLanguagePacks=async()=>{if(!fullLanguages){const{languages:e=null}=await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 847, 19));fullLanguages=e}return fullLanguages},useLanguagePack=e=>{const[t,n]=(0,react.useState)(fullLanguages||prism.languages);return (0,react.useEffect)((()=>{t[e]||(async()=>{const e=await fetchFullLanguagePacks();e&&e!==t&&n(e)})()}),[t,e]),t[e]||t.plaintext},useHighLight=(e,t)=>{const n=t.toLowerCase(),r=useLanguagePack(n);return (0,react.useMemo)((()=>{try{return (0,prism.highlight)(e,r,n)}catch(t){return console.error("Fail to highlight code by prism",t),e}}),[n,e,r])},container$4="_container_g7n3b_57",dark$1="_dark_g7n3b_176",styles$5={container:container$4,dark:dark$1},PrismCodeBlockHighlighter=({code:e,language:t="",className:n,style:r,dark:s=!1})=>{const i=useHighLight(e,t);return (0,jsx_runtime.jsx)("pre",{className:classnames(styles$5.container,n,t&&`language-${t}`,{[styles$5.dark]:s}),style:r,children:(0,jsx_runtime.jsx)("code",{className:t&&`language-${t}`,dangerouslySetInnerHTML:{__html:purifyHtml(i)}})})},index$2=Object.freeze(Object.defineProperty({__proto__:null,PrismCodeBlockHighlighter:PrismCodeBlockHighlighter,default:PrismCodeBlockHighlighter},Symbol.toStringTag,{value:"Module"})),codeHighlighterPrismPlugin={name:"code-highlighter-prism",slots:{CodeBlockHighlighter:PrismCodeBlockHighlighter}},detectLanguage=e=>{},PLAIN_TEXT="plaintext",useAutoDetectLanguage=(e,t=PLAIN_TEXT)=>{const[n,r]=(0,react.useState)(t);return (0,react.useEffect)((()=>{r(t)}),[t]),(0,react.useEffect)((()=>{(async()=>{if(n===PLAIN_TEXT){const e=await detectLanguage();e&&r(e)}})()}),[e,n]),n},SvgDoneIcon=e=>react.createElement("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},react.createElement("path",{d:"M9.2267 16.1272L19.9535 5.40038C20.4274 4.92644 21.1958 4.92644 21.6698 5.40038C22.1437 5.87432 22.1437 6.64272 21.6698 7.11666L10.0848 18.7016C9.61091 19.1755 8.8425 19.1755 8.36856 18.7016L2.36156 12.6946C1.88762 12.2207 1.88762 11.4522 2.36156 10.9783C2.8355 10.5044 3.6039 10.5044 4.07784 10.9783L9.2267 16.1272Z",fill:"currentColor"})),SvgCopyIcon=e=>react.createElement("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},react.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21.5 3.5V17C21.5 18.1046 20.6046 19 19.5 19H17.5V21C17.5 22.1046 16.5406 23 15.3571 23H4.64286C3.45939 23 2.5 22.1046 2.5 21V7.5C2.5 6.39543 3.45939 5.5 4.64286 5.5H6.5V3.5C6.5 2.39543 7.39543 1.5 8.5 1.5H19.5C20.6046 1.5 21.5 2.39543 21.5 3.5ZM8.5 5.5H15.3571C16.5406 5.5 17.5 6.39543 17.5 7.5V17H19.5V3.5H8.5V5.5ZM15.3571 7.5H4.64286L4.64286 21H15.3571V7.5Z",fill:"currentColor"})),SvgCodeIcon=e=>react.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},react.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 9V15H5.2V9H7ZM7 8V16H5C4.44771 16 4 15.7015 4 15.3333V8.66667C4 8.29848 4.44771 8 5 8H7Z",fill:"currentColor"}),react.createElement("path",{d:"M8.5 10L11.5 12L8.5 14",stroke:"currentColor",strokeLinejoin:"bevel"}),react.createElement("path",{d:"M15.5 15H11.5",stroke:"currentColor",strokeLinejoin:"bevel"}),react.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17 9V15H18.8V9H17ZM17 8V16H19C19.5523 16 20 15.7015 20 15.3333V8.66667C20 8.29848 19.5523 8 19 8H17Z",fill:"currentColor"})),container$3="_container_vmcsy_1",dark="_dark_vmcsy_13",all_in_one_index_header="_header_vmcsy_32",all_in_one_index_text="_text_vmcsy_44",all_in_one_index_icon="_icon_vmcsy_53",all_in_one_index_actions="_actions_vmcsy_56",all_in_one_index_item="_item_vmcsy_61",all_in_one_index_img="_img_vmcsy_82",all_in_one_index_content="_content_vmcsy_85",hoverable="_hoverable_vmcsy_98",styles$4={container:container$3,dark:dark,"code-area":"_code-area_vmcsy_20",header:all_in_one_index_header,text:all_in_one_index_text,icon:all_in_one_index_icon,actions:all_in_one_index_actions,item:all_in_one_index_item,img:all_in_one_index_img,content:all_in_one_index_content,hoverable:hoverable,"light-scrollbar":"_light-scrollbar_vmcsy_121"},CodeBlock=({className:e,style:t,code:n,language:r,onCopyCode:s,showHeader:i=!0,raw:a,parents:o})=>{const{mode:l}=useCalypsoConfig(),c="dark"===l,{CodeBlockHighlighter:u}=useCalypsoSlots(),[d,p]=(0,react.useState)(!1),m=useAutoDetectLanguage(n,r);return (0,jsx_runtime.jsx)("div",{"data-testid":"code_block",className:classnames(styles$4.container,e,"hide-indicator",{[styles$4.dark]:c}),style:t,children:(0,jsx_runtime.jsxs)("div",{className:classnames(styles$4["code-area"]),dir:"ltr",children:[i&&(0,jsx_runtime.jsxs)("div",{className:styles$4.header,children:[(0,jsx_runtime.jsxs)("div",{className:styles$4.text,children:[(0,jsx_runtime.jsx)(SvgCodeIcon,{className:styles$4.icon}),m]}),(0,jsx_runtime.jsx)("div",{className:styles$4.actions,children:(0,jsx_runtime.jsx)("div",{className:styles$4.item,onClick:()=>{d||(copy_to_clipboard(n),null==s||s(n),p(!0),setTimeout((()=>{p(!1)}),3e3))},children:(0,jsx_runtime.jsx)("div",{className:classnames(styles$4.icon,styles$4.hoverable),"data-testid":"code_block_copy",children:(0,jsx_runtime.jsx)(d?SvgDoneIcon:SvgCopyIcon,{className:styles$4.img})})})})]}),(0,jsx_runtime.jsx)("div",{className:classnames(styles$4.content,styles$4[`content--${m.toLowerCase()}`]),children:u&&(0,jsx_runtime.jsx)(u,{code:n,language:r,raw:a,parents:o,dark:c})})]})})},codeBlockPlugin={name:"code-block",slots:{CodeBlock:CodeBlock}},all_in_one_index_wrapper="_wrapper_aaa8t_1",wrapperStyles={wrapper:all_in_one_index_wrapper},container$2="_container_1lt86_9",styles$3={container:container$2},BreakLine=({className:e,style:t})=>(0,jsx_runtime.jsx)("br",{className:classnames(styles$3.container,e),style:t}),withCalypsoBreakLine=e=>function({className:t,...n}){return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:e&&(0,jsx_runtime.jsx)(e,{className:classnames(wrapperStyles.wrapper,t,{[styles$3["non-select"]]:!all_in_one_index_isSafari()}),...n})})},WrappedBreakLine=withCalypsoBreakLine(BreakLine),breakLinePlugin={name:"break-line",slots:{BreakLine:WrappedBreakLine}},Blockquote=({className:e,style:t,node:n,children:r,renderRest:s})=>(0,jsx_runtime.jsx)(BlockElement,{className:e,style:t,node:n,renderRest:s,children:r}),blockquotePlugin={name:"blockquote",slots:{Blockquote:Blockquote}},defaultPlugins=[breakLinePlugin,texLightPlugin,codeHighlighterPrismPlugin,codeBlockPlugin,tablePlugin,imagePlugin,indicatorPlugin,paragraphPlugin,linkPlugin,emphasisPlugin,strongPlugin,headerPlugin,listPlugin,blockquotePlugin],CalypsoLite=(0,react.forwardRef)((function(e,t){return (0,jsx_runtime.jsx)(CalypsoCore,{ref:t,plugins:defaultPlugins,...e})})),safeKatexTexToHtml=(e,t={})=>{try{return katex["default"].renderToString(e,{throwOnError:!1,strict:!1,output:"html",trust:!1,...t})}catch(e){return null}},adaptor=(0,liteAdaptor.liteAdaptor)();(0,handlers_html.RegisterHTMLHandler)(adaptor);const all_in_one_index_tex=new tex.TeX({packages:[...AllPackages.AllPackages.sort().join(", ").split(/\s*,\s*/),"physics","mhchem"],macros:{equalparallel:"{\\lower{2.6pt}{\\arrowvert\\hspace{-4.2pt}\\arrowvert}\\above{-2pt}\\raise{7.5pt}{=}}",number:["{#1}",1],unit:["{#1}",1],div:"{÷}"}}),all_in_one_index_svg=new output_svg.SVG({fontCache:"none"}),all_in_one_index_html=mathjax.mathjax.document("",{InputJax:all_in_one_index_tex,OutputJax:all_in_one_index_svg}),texToSvg=e=>{var t;const n=xregexp_lib.replace(e,xregexp_lib(String.raw`[^\P{C}\n\t]+`,"ug"),"");try{const e=all_in_one_index_html.convert(n,{display:!0,em:16,ex:8,containerWidth:1280});return adaptor.outerHTML(null==(t=null==e?void 0:e.children)?void 0:t[0])}catch(t){return safeKatexTexToHtml(e)??e}},container$1="_container_1dcs1_1",single$1="_single_1dcs1_16",all_in_one_index_error="_error_1dcs1_44",styles$2={container:container$1,single:single$1,error:all_in_one_index_error},RawMathjaxTex=(0,react.forwardRef)((function({className:e,style:t,tex:n,html:r},s){const i=(0,react.useMemo)((()=>/^[a-zA-Z0-9\s]+$/.test(n.trim())),[n]),a=Boolean(null==r?void 0:r.includes("data-mjx-error")),o=!lodash_es_isUndefined(r)&&!a;return (0,jsx_runtime.jsx)("span",{ref:s,className:classnames(styles$2.container,e,"math-inline",{[styles$2.single]:i,[styles$2.error]:a}),style:t,dangerouslySetInnerHTML:o?{__html:r}:void 0,"data-custom-copy-text":`\\(${n}\\)`,children:o?null:n})})),MathJaxTex=({className:e,style:t,tex:n,mode:r})=>{const s=(0,react.useMemo)((()=>purifyHtml(texToSvg(n))),[n]);return (0,jsx_runtime.jsx)(RawMathjaxTex,{className:e,style:t,tex:n,html:s})},Calypso=(0,react.forwardRef)((function({slots:e={},autoFixSyntax:t=!0,...n},r){return (0,jsx_runtime.jsx)(CalypsoLite,{ref:r,slots:lodash_es_defaults(e,{Tex:MathJaxTex,CodeBlockHighlighter:PrismCodeBlockHighlighter}),autoFixSyntax:t&&{katex:katex["default"],...lodash_es_isBoolean(t)?{}:t},...n})}));class DefaultParseError extends Error{constructor(e,t,n){super(),this.message=e,this.lexer=t,this.position=n}}const useLazyKatex=()=>{const[e,t]=(0,react.useState)(),n=(0,react.useCallback)((async()=>{if(e)return;const{default:n}=await retryLoad((()=>Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 97234))));t(n)}),[e]),r=(0,react.useMemo)((()=>{var e;return(e=class{static render(){throw n(),new DefaultParseError("DefaultKatex.render has called",{},0)}static renderToString(){throw n(),new DefaultParseError("DefaultKatex.renderToString has called",{},0)}}).ParseError=DefaultParseError,e}),[n]);return e??r},withSuspense=(e,t)=>{const n=n=>(0,jsx_runtime.jsx)(react.Suspense,{fallback:t&&(0,jsx_runtime.jsx)(t,{...n}),children:(0,jsx_runtime.jsx)(e,{...n})});return n.displayName=e.displayName??(null==t?void 0:t.displayName),n},useLazyComponent=(e,t,n={})=>{const{retryTimes:r=5,retryInterval:s=100}=n;return (0,react.useMemo)((()=>withSuspense(react.lazy(withRetry(e,{tryTimes:r,interval:s,fallback:{default:t}})),t)),[r,s])},styles$1={"light-scrollbar":"_light-scrollbar_1ks9r_1"},LightCodeBlockHighlighter=({language:e,code:t,className:n,style:r})=>(0,jsx_runtime.jsx)("pre",{className:classnames(e&&`language-${e}`,styles$1["light-scrollbar"],n),style:r,children:(0,jsx_runtime.jsx)("code",{children:t})}),CalypsoLazy=(0,react.forwardRef)((function({slots:e={},autoFixSyntax:t=!0,retryTimes:n=5,retryInterval:r=100,...s},i){const a=useLazyKatex(),o=useLazyComponent((()=>Promise.resolve().then((()=>index$1))),LightTex,{retryTimes:n,retryInterval:r}),l=useLazyComponent((()=>Promise.resolve().then((()=>all_in_one_index_index))),o,{retryTimes:n,retryInterval:r}),c=useLazyComponent((()=>Promise.resolve().then((()=>index$2))),LightCodeBlockHighlighter,{retryTimes:n,retryInterval:r});return (0,jsx_runtime.jsx)(CalypsoLite,{ref:i,slots:lodash_es_defaults(e,{Tex:l,CodeBlockHighlighter:c}),autoFixSyntax:t&&{katex:a,...lodash_es_isBoolean(t)?{}:t},...s})})),AsyncLazyMathJaxTex=({className:e,style:t,tex:n})=>{const[r,s]=useState(),[i,a]=useState(!1),o=useRef(null);return useEffect((()=>{i&&s(texToSvg(n))}),[n,i]),useEffect((()=>{const e=new IntersectionObserver((t=>{if(!(null==t?void 0:t[0]))return;const{intersectionRatio:n}=t[0];n>0&&(a(!0),e.disconnect())}));return o.current&&e.observe(o.current),()=>{e.disconnect()}}),[]),jsx(RawMathjaxTex,{ref:o,className:e,style:t,tex:n,html:r})},asyncLazyMathjaxTexPlugin=(/* unused pure expression or super */ null && ({name:"async-lazy-mathjax-tex",slots:{Tex:AsyncLazyMathJaxTex}})),codeHighlighterLightPlugin=(/* unused pure expression or super */ null && ({name:"code-highlighter-light",slots:{CodeBlockHighlighter:LightCodeBlockHighlighter}})),all_in_one_index_container="_container_imek1_1",all_in_one_index_single="_single_imek1_6",all_in_one_index_block="_block_imek1_9",all_in_one_index_styles={container:all_in_one_index_container,single:all_in_one_index_single,block:all_in_one_index_block},KatexTex=({tex:e,mode:t,className:n,style:r,fallback:s,katexOptions:i})=>{const a=useDeepCompareMemo((()=>safeKatexTexToHtml(e,i)),[e,i]),o=useDeepCompareMemo((()=>a?null:safeKatexTexToHtml(e,{...i,displayMode:!0})),[e,i,Boolean(a)]),l=(0,react.useMemo)((()=>/^[a-zA-Z0-9\s]+$/.test(e.trim())),[e]);return!s||a||o?(0,jsx_runtime.jsx)("span",{className:classnames(all_in_one_index_styles.container,n,"math-inline",{[all_in_one_index_styles.single]:l,[all_in_one_index_styles.block]:Boolean(o)}),style:r,dangerouslySetInnerHTML:{__html:purifyHtml((a||o)??e)},"data-custom-copy-text":l?e:`\\(${e}\\)`}):(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:s})},index$1=Object.freeze(Object.defineProperty({__proto__:null,KatexTex:KatexTex,default:KatexTex},Symbol.toStringTag,{value:"Module"})),katexTexPlugin=(/* unused pure expression or super */ null && ({name:"katex-tex",slots:{Tex:KatexTex}})),KatexMathjaxTex=e=>(0,jsx_runtime.jsx)(KatexTex,{...e,katexOptions:{strict:!0,throwOnError:!0},fallback:(0,jsx_runtime.jsx)(MathJaxTex,{...e})}),all_in_one_index_index=Object.freeze(Object.defineProperty({__proto__:null,KatexMathjaxTex:KatexMathjaxTex,default:KatexMathjaxTex},Symbol.toStringTag,{value:"Module"})),katexMathjaxTexPlugin=(/* unused pure expression or super */ null && ({name:"katex-mathjax-tex",slots:{Tex:KatexMathjaxTex}})),mathjaxTexPlugin=(/* unused pure expression or super */ null && ({name:"mathjax-tex",slots:{Tex:MathJaxTex}}));
|
|
296437
296216
|
;// CONCATENATED MODULE: ../../../common/chat-area/chat-uikit/src/context/onboarding/index.ts
|
|
296438
296217
|
/*
|
|
296439
296218
|
* Copyright 2025 coze-dev Authors
|
|
@@ -300337,7 +300116,7 @@ function useEventListener_useEventListener(eventName, handler, options) {
|
|
|
300337
300116
|
if (options === void 0) {
|
|
300338
300117
|
options = {};
|
|
300339
300118
|
}
|
|
300340
|
-
var handlerRef =
|
|
300119
|
+
var handlerRef = es_useLatest(handler);
|
|
300341
300120
|
utils_useEffectWithTarget(function () {
|
|
300342
300121
|
var targetElement = getTargetElement(options.target, window);
|
|
300343
300122
|
if (!(targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener)) {
|
|
@@ -300404,7 +300183,7 @@ var getShadow = function (node) {
|
|
|
300404
300183
|
}
|
|
300405
300184
|
return node.getRootNode();
|
|
300406
300185
|
};
|
|
300407
|
-
var
|
|
300186
|
+
var getDocumentOrShadow_getDocumentOrShadow = function (target) {
|
|
300408
300187
|
if (!target || !document.getRootNode) {
|
|
300409
300188
|
return document;
|
|
300410
300189
|
}
|
|
@@ -300414,7 +300193,7 @@ var getDocumentOrShadow = function (target) {
|
|
|
300414
300193
|
}
|
|
300415
300194
|
return document;
|
|
300416
300195
|
};
|
|
300417
|
-
/* ESM default export */ const
|
|
300196
|
+
/* ESM default export */ const getDocumentOrShadow = (getDocumentOrShadow_getDocumentOrShadow);
|
|
300418
300197
|
;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/ahooks@3.7.8_patch_hash=sa4ddrxdk2yhjzudeck6u5ww3i_react@18.2.0/node_modules/ahooks/es/useClickAway/index.js
|
|
300419
300198
|
|
|
300420
300199
|
|
|
@@ -300424,7 +300203,7 @@ function useClickAway(onClickAway, target, eventName) {
|
|
|
300424
300203
|
if (eventName === void 0) {
|
|
300425
300204
|
eventName = 'click';
|
|
300426
300205
|
}
|
|
300427
|
-
var onClickAwayRef =
|
|
300206
|
+
var onClickAwayRef = es_useLatest(onClickAway);
|
|
300428
300207
|
utils_useEffectWithTarget(function () {
|
|
300429
300208
|
var handler = function (event) {
|
|
300430
300209
|
var targets = Array.isArray(target) ? target : [target];
|
|
@@ -300436,7 +300215,7 @@ function useClickAway(onClickAway, target, eventName) {
|
|
|
300436
300215
|
}
|
|
300437
300216
|
onClickAwayRef.current(event);
|
|
300438
300217
|
};
|
|
300439
|
-
var documentOrShadow =
|
|
300218
|
+
var documentOrShadow = getDocumentOrShadow(target);
|
|
300440
300219
|
var eventNames = Array.isArray(eventName) ? eventName : [eventName];
|
|
300441
300220
|
eventNames.forEach(function (event) {
|
|
300442
300221
|
return documentOrShadow.addEventListener(event, handler);
|
|
@@ -300747,14 +300526,14 @@ MessageContentTime.displayName = 'MessageContentTime';
|
|
|
300747
300526
|
|
|
300748
300527
|
|
|
300749
300528
|
|
|
300750
|
-
function
|
|
300529
|
+
function useDebounceFn(fn, options) {
|
|
300751
300530
|
var _a;
|
|
300752
300531
|
if (isDev) {
|
|
300753
300532
|
if (!utils_isFunction(fn)) {
|
|
300754
300533
|
console.error("useDebounceFn expected parameter is a function, got ".concat(typeof fn));
|
|
300755
300534
|
}
|
|
300756
300535
|
}
|
|
300757
|
-
var fnRef =
|
|
300536
|
+
var fnRef = es_useLatest(fn);
|
|
300758
300537
|
var wait = (_a = options === null || options === void 0 ? void 0 : options.wait) !== null && _a !== void 0 ? _a : 1000;
|
|
300759
300538
|
var debounced = (0,react.useMemo)(function () {
|
|
300760
300539
|
return debounce_default()(function () {
|
|
@@ -300774,7 +300553,7 @@ function useDebounceFn_useDebounceFn(fn, options) {
|
|
|
300774
300553
|
flush: debounced.flush
|
|
300775
300554
|
};
|
|
300776
300555
|
}
|
|
300777
|
-
/* ESM default export */ const
|
|
300556
|
+
/* ESM default export */ const es_useDebounceFn = (useDebounceFn);
|
|
300778
300557
|
;// CONCATENATED MODULE: ../../../common/chat-area/chat-uikit/src/hooks/use-observe-card-container.ts
|
|
300779
300558
|
/*
|
|
300780
300559
|
* Copyright 2025 coze-dev Authors
|
|
@@ -300796,7 +300575,7 @@ function useDebounceFn_useDebounceFn(fn, options) {
|
|
|
300796
300575
|
const useObserveCardContainer = (param)=>{
|
|
300797
300576
|
let { messageId, cardContainerRef, onResize } = param;
|
|
300798
300577
|
const eventCenter = useUiKitEventCenter();
|
|
300799
|
-
/** If there is no change within 30s, the observer will be automatically cleared. */ const debouncedDisconnect =
|
|
300578
|
+
/** If there is no change within 30s, the observer will be automatically cleared. */ const debouncedDisconnect = es_useDebounceFn((getResizeObserver)=>{
|
|
300800
300579
|
const resizeObserver = getResizeObserver();
|
|
300801
300580
|
resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();
|
|
300802
300581
|
}, {
|
|
@@ -301732,8 +301511,8 @@ function useKeyPress_useKeyPress(keyFilter, eventHandler, option) {
|
|
|
301732
301511
|
exactMatch = _c === void 0 ? false : _c,
|
|
301733
301512
|
_d = _a.useCapture,
|
|
301734
301513
|
useCapture = _d === void 0 ? false : _d;
|
|
301735
|
-
var eventHandlerRef =
|
|
301736
|
-
var keyFilterRef =
|
|
301514
|
+
var eventHandlerRef = es_useLatest(eventHandler);
|
|
301515
|
+
var keyFilterRef = es_useLatest(keyFilter);
|
|
301737
301516
|
useDeepCompareWithTarget(function () {
|
|
301738
301517
|
var e_2, _a;
|
|
301739
301518
|
var _b;
|
|
@@ -301822,10 +301601,10 @@ const useAudioRecordInteraction = (param)=>{
|
|
|
301822
301601
|
let { target, events, options = {} } = param;
|
|
301823
301602
|
const { onStart, onEnd, onMoveEnter, onMoveLeave } = events;
|
|
301824
301603
|
const { shortcutKey = ()=>false, getIsShortcutKeyDisabled, enabled = true, getActiveZoneTarget } = options;
|
|
301825
|
-
const onStartRef =
|
|
301826
|
-
const onEndRef =
|
|
301827
|
-
const onMoveEnterRef =
|
|
301828
|
-
const onMoveLeaveRef =
|
|
301604
|
+
const onStartRef = es_useLatest(onStart);
|
|
301605
|
+
const onEndRef = es_useLatest(onEnd);
|
|
301606
|
+
const onMoveEnterRef = es_useLatest(onMoveEnter);
|
|
301607
|
+
const onMoveLeaveRef = es_useLatest(onMoveLeave);
|
|
301829
301608
|
const isKeydown = (0,react.useRef)(false);
|
|
301830
301609
|
const isMouseOrTouchDown = (0,react.useRef)(false);
|
|
301831
301610
|
const isMoveLeave = (0,react.useRef)(false);
|
|
@@ -385539,7 +385318,7 @@ var intersection_observer = __webpack_require__(3685);
|
|
|
385539
385318
|
|
|
385540
385319
|
|
|
385541
385320
|
|
|
385542
|
-
function
|
|
385321
|
+
function useInViewport_useInViewport(target, options) {
|
|
385543
385322
|
var _a = __read((0,react.useState)(), 2),
|
|
385544
385323
|
state = _a[0],
|
|
385545
385324
|
setState = _a[1];
|
|
@@ -385580,7 +385359,7 @@ function useInViewport(target, options) {
|
|
|
385580
385359
|
}, [options === null || options === void 0 ? void 0 : options.rootMargin, options === null || options === void 0 ? void 0 : options.threshold], target);
|
|
385581
385360
|
return [state, ratio];
|
|
385582
385361
|
}
|
|
385583
|
-
/* ESM default export */ const
|
|
385362
|
+
/* ESM default export */ const useInViewport = (useInViewport_useInViewport);
|
|
385584
385363
|
;// CONCATENATED MODULE: ../../../common/chat-area/chat-area/src/components/message-box/reveal-trigger.tsx
|
|
385585
385364
|
/*
|
|
385586
385365
|
* Copyright 2025 coze-dev Authors
|
|
@@ -385607,7 +385386,7 @@ const RevealTrigger = ()=>{
|
|
|
385607
385386
|
const { message } = message_box_useMessageBoxContext();
|
|
385608
385387
|
const reportMarkRead = useMarkMessageRead();
|
|
385609
385388
|
const { eventCallback } = use_chat_area_context_useChatAreaContext();
|
|
385610
|
-
const [inViewport] =
|
|
385389
|
+
const [inViewport] = useInViewport(()=>boxBottomRef.current);
|
|
385611
385390
|
(0,react.useEffect)(()=>{
|
|
385612
385391
|
var _eventCallback_onMessageBottomShow;
|
|
385613
385392
|
if (!inViewport) {
|
|
@@ -396863,7 +396642,7 @@ const LoadMore = (param)=>{
|
|
|
396863
396642
|
const { loadByScrollPrev, loadByScrollNext } = useLoadMoreClient();
|
|
396864
396643
|
const load = isForPrev ? loadByScrollPrev : loadByScrollNext;
|
|
396865
396644
|
const spinRef = (0,react.useRef)(null);
|
|
396866
|
-
const [inViewport] =
|
|
396645
|
+
const [inViewport] = useInViewport(()=>spinRef.current);
|
|
396867
396646
|
// Prevent two consecutive requests from being triggered (loading changes earlier than explicit changes in the IconSpin component)
|
|
396868
396647
|
const deferredLoading = (0,react.useDeferredValue)(loading);
|
|
396869
396648
|
(0,react.useEffect)(()=>{
|
|
@@ -399120,7 +398899,7 @@ var useCountdown = function (options) {
|
|
|
399120
398899
|
}), 2),
|
|
399121
398900
|
timeLeft = _c[0],
|
|
399122
398901
|
setTimeLeft = _c[1];
|
|
399123
|
-
var onEndRef =
|
|
398902
|
+
var onEndRef = es_useLatest(onEnd);
|
|
399124
398903
|
(0,react.useEffect)(function () {
|
|
399125
398904
|
if (!target) {
|
|
399126
398905
|
// for stop
|
|
@@ -407464,7 +407243,7 @@ var useDebouncePlugin = function (fetchInstance, _a) {
|
|
|
407464
407243
|
/* ESM default export */ const plugins_useDebouncePlugin = (useDebouncePlugin);
|
|
407465
407244
|
;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/ahooks@3.7.8_patch_hash=sa4ddrxdk2yhjzudeck6u5ww3i_react@18.2.0/node_modules/ahooks/es/useRequest/src/plugins/useLoadingDelayPlugin.js
|
|
407466
407245
|
|
|
407467
|
-
var
|
|
407246
|
+
var useLoadingDelayPlugin_useLoadingDelayPlugin = function (fetchInstance, _a) {
|
|
407468
407247
|
var loadingDelay = _a.loadingDelay,
|
|
407469
407248
|
ready = _a.ready;
|
|
407470
407249
|
var timerRef = (0,react.useRef)();
|
|
@@ -407501,7 +407280,7 @@ var useLoadingDelayPlugin = function (fetchInstance, _a) {
|
|
|
407501
407280
|
}
|
|
407502
407281
|
};
|
|
407503
407282
|
};
|
|
407504
|
-
/* ESM default export */ const
|
|
407283
|
+
/* ESM default export */ const useLoadingDelayPlugin = (useLoadingDelayPlugin_useLoadingDelayPlugin);
|
|
407505
407284
|
;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/ahooks@3.7.8_patch_hash=sa4ddrxdk2yhjzudeck6u5ww3i_react@18.2.0/node_modules/ahooks/es/useRequest/src/utils/isDocumentVisible.js
|
|
407506
407285
|
|
|
407507
407286
|
function isDocumentVisible() {
|
|
@@ -407980,8 +407759,8 @@ function useRequestImplement_useRequestImplement(service, options, plugins) {
|
|
|
407980
407759
|
var fetchOptions = tslib_es6_assign({
|
|
407981
407760
|
manual: manual
|
|
407982
407761
|
}, rest);
|
|
407983
|
-
var serviceRef =
|
|
407984
|
-
var update =
|
|
407762
|
+
var serviceRef = es_useLatest(service);
|
|
407763
|
+
var update = es_useUpdate();
|
|
407985
407764
|
var fetchInstance = useCreation(function () {
|
|
407986
407765
|
var initState = plugins.map(function (p) {
|
|
407987
407766
|
var _a;
|
|
@@ -408041,7 +407820,7 @@ function useRequestImplement_useRequestImplement(service, options, plugins) {
|
|
|
408041
407820
|
// plugins?: Plugin<TData, TParams>[],
|
|
408042
407821
|
// ): Result<TData, TParams>
|
|
408043
407822
|
function useRequest_useRequest(service, options, plugins) {
|
|
408044
|
-
return useRequestImplement(service, options, tslib_es6_spreadArray(tslib_es6_spreadArray([], __read(plugins || []), false), [plugins_useDebouncePlugin,
|
|
407823
|
+
return useRequestImplement(service, options, tslib_es6_spreadArray(tslib_es6_spreadArray([], __read(plugins || []), false), [plugins_useDebouncePlugin, useLoadingDelayPlugin, usePollingPlugin, plugins_useRefreshOnWindowFocusPlugin, useThrottlePlugin, plugins_useAutoRunPlugin, plugins_useCachePlugin, plugins_useRetryPlugin], false));
|
|
408045
407824
|
}
|
|
408046
407825
|
/* ESM default export */ const src_useRequest = (useRequest_useRequest);
|
|
408047
407826
|
;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/ahooks@3.7.8_patch_hash=sa4ddrxdk2yhjzudeck6u5ww3i_react@18.2.0/node_modules/ahooks/es/useRequest/index.js
|
|
@@ -423563,21 +423342,21 @@ const DEFAULT_FEEDBACK_OPTIONS = [
|
|
|
423563
423342
|
}
|
|
423564
423343
|
];
|
|
423565
423344
|
function findChatAreaContainer() {
|
|
423566
|
-
// 方式1:
|
|
423567
|
-
let
|
|
423568
|
-
// 方式2: 如果找不到,尝试查找包含 "chat-
|
|
423569
|
-
if (!
|
|
423345
|
+
// 方式1: 尝试通过类名查找 coze-chat-sdk 容器
|
|
423346
|
+
let cozeChatSdk = document.querySelector('.coze-chat-sdk');
|
|
423347
|
+
// 方式2: 如果找不到,尝试查找包含 "coze-chat-sdk" 的类名(部分匹配)
|
|
423348
|
+
if (!cozeChatSdk) {
|
|
423570
423349
|
const allElements = document.querySelectorAll('*');
|
|
423571
423350
|
for (const el of allElements){
|
|
423572
423351
|
const classList = Array.from(el.classList);
|
|
423573
|
-
if (classList.some((cls)=>cls.includes('chat-
|
|
423574
|
-
|
|
423352
|
+
if (classList.some((cls)=>cls.includes('coze-chat-sdk'))) {
|
|
423353
|
+
cozeChatSdk = el;
|
|
423575
423354
|
break;
|
|
423576
423355
|
}
|
|
423577
423356
|
}
|
|
423578
423357
|
}
|
|
423579
423358
|
// 方式3: 如果还是找不到,使用 document.body 作为容器(使用 fixed 定位)
|
|
423580
|
-
return
|
|
423359
|
+
return cozeChatSdk || document.body;
|
|
423581
423360
|
}
|
|
423582
423361
|
const FeedbackDialog = (param)=>{
|
|
423583
423362
|
let { visible, onConfirm, onCancel, feedbackTypes } = param;
|
|
@@ -423598,12 +423377,10 @@ const FeedbackDialog = (param)=>{
|
|
|
423598
423377
|
label: item.label
|
|
423599
423378
|
})) : DEFAULT_FEEDBACK_OPTIONS;
|
|
423600
423379
|
const handleConfirm = ()=>{
|
|
423601
|
-
|
|
423602
|
-
|
|
423603
|
-
|
|
423604
|
-
|
|
423605
|
-
setComment('');
|
|
423606
|
-
}
|
|
423380
|
+
onConfirm(selectedFeedbackType, comment);
|
|
423381
|
+
// 重置状态
|
|
423382
|
+
setSelectedFeedbackType(null);
|
|
423383
|
+
setComment('');
|
|
423607
423384
|
};
|
|
423608
423385
|
const handleCancel = ()=>{
|
|
423609
423386
|
setSelectedFeedbackType(null);
|
|
@@ -423680,7 +423457,6 @@ const FeedbackDialog = (param)=>{
|
|
|
423680
423457
|
type: "button",
|
|
423681
423458
|
className: components_comment_message_index_module["feedback-btn-confirm"],
|
|
423682
423459
|
onClick: handleConfirm,
|
|
423683
|
-
disabled: !selectedFeedbackType,
|
|
423684
423460
|
children: "确认"
|
|
423685
423461
|
})
|
|
423686
423462
|
]
|
|
@@ -423720,6 +423496,25 @@ const FeedbackDialog = (param)=>{
|
|
|
423720
423496
|
|
|
423721
423497
|
|
|
423722
423498
|
|
|
423499
|
+
|
|
423500
|
+
/**
|
|
423501
|
+
* 评论数据缓存
|
|
423502
|
+
* 使用 chatId 作为 key 来缓存每个消息的评论状态
|
|
423503
|
+
*/ const commentCache = new Map();
|
|
423504
|
+
/**
|
|
423505
|
+
* 枚举数据缓存
|
|
423506
|
+
* 枚举数据通常不会变化,可以全局共享
|
|
423507
|
+
*/ let enumsCache = null;
|
|
423508
|
+
/**
|
|
423509
|
+
* 缓存过期时间(毫秒)
|
|
423510
|
+
* 评论状态缓存 5 分钟,枚举数据缓存 30 分钟
|
|
423511
|
+
*/ const COMMENT_CACHE_TTL = 5 * 60 * 1000; // 5 分钟
|
|
423512
|
+
const ENUMS_CACHE_TTL = 30 * 60 * 1000; // 30 分钟
|
|
423513
|
+
/**
|
|
423514
|
+
* 生成缓存 key
|
|
423515
|
+
*/ function getCacheKey(chatId, appId, conversationId) {
|
|
423516
|
+
return `${appId}:${conversationId}:${chatId}`;
|
|
423517
|
+
}
|
|
423723
423518
|
/**
|
|
423724
423519
|
* 从枚举数据中获取点赞按钮文字
|
|
423725
423520
|
*/ function getLikeLabel(enumsData, currentComment) {
|
|
@@ -423744,6 +423539,25 @@ const FeedbackDialog = (param)=>{
|
|
|
423744
423539
|
}
|
|
423745
423540
|
return currentComment === 'DISLIKE' ? '取消点踩' : '点踩';
|
|
423746
423541
|
}
|
|
423542
|
+
/**
|
|
423543
|
+
* 查找 coze-chat-sdk 容器
|
|
423544
|
+
*/ function findCozeChatSdkContainer() {
|
|
423545
|
+
// 方式1: 尝试通过类名查找
|
|
423546
|
+
let container = document.querySelector('.coze-chat-sdk');
|
|
423547
|
+
// 方式2: 如果找不到,尝试查找包含 "coze-chat-sdk" 的类名(部分匹配)
|
|
423548
|
+
if (!container) {
|
|
423549
|
+
const allElements = document.querySelectorAll('*');
|
|
423550
|
+
for (const el of allElements){
|
|
423551
|
+
const classList = Array.from(el.classList);
|
|
423552
|
+
if (classList.some((cls)=>cls.includes('coze-chat-sdk'))) {
|
|
423553
|
+
container = el;
|
|
423554
|
+
break;
|
|
423555
|
+
}
|
|
423556
|
+
}
|
|
423557
|
+
}
|
|
423558
|
+
// 方式3: 如果还是找不到,使用 document.body 作为容器
|
|
423559
|
+
return container || document.body;
|
|
423560
|
+
}
|
|
423747
423561
|
const CommentMessage = (param)=>{
|
|
423748
423562
|
let { className, isMustGroupLastAnswerMessage = true, ...props } = param;
|
|
423749
423563
|
var _enumsData_feedback_types;
|
|
@@ -423763,21 +423577,43 @@ const CommentMessage = (param)=>{
|
|
|
423763
423577
|
if (!commentApiService || !messageParams) {
|
|
423764
423578
|
return;
|
|
423765
423579
|
}
|
|
423580
|
+
const cacheKey = getCacheKey(messageParams.chatId, messageParams.appId, messageParams.conversationId);
|
|
423766
423581
|
const fetchEnums = async ()=>{
|
|
423767
423582
|
if (!(commentApiService === null || commentApiService === void 0 ? void 0 : commentApiService.getCommentEnums)) {
|
|
423768
423583
|
return;
|
|
423769
423584
|
}
|
|
423585
|
+
// 检查缓存
|
|
423586
|
+
const now = Date.now();
|
|
423587
|
+
if (enumsCache && enumsCache.data && now - enumsCache.timestamp < ENUMS_CACHE_TTL) {
|
|
423588
|
+
setEnumsData(enumsCache.data);
|
|
423589
|
+
return;
|
|
423590
|
+
}
|
|
423770
423591
|
try {
|
|
423771
423592
|
const response = await commentApiService.getCommentEnums();
|
|
423593
|
+
enumsCache = {
|
|
423594
|
+
data: response.data,
|
|
423595
|
+
timestamp: now
|
|
423596
|
+
};
|
|
423772
423597
|
setEnumsData(response.data);
|
|
423773
423598
|
} catch (error) {
|
|
423774
423599
|
console.error('[Comment Message] Failed to fetch enums:', error);
|
|
423600
|
+
// 如果请求失败,尝试使用缓存数据
|
|
423601
|
+
if (enumsCache === null || enumsCache === void 0 ? void 0 : enumsCache.data) {
|
|
423602
|
+
setEnumsData(enumsCache.data);
|
|
423603
|
+
}
|
|
423775
423604
|
}
|
|
423776
423605
|
};
|
|
423777
423606
|
const fetchCommentStatus = async ()=>{
|
|
423778
423607
|
if (!(commentApiService === null || commentApiService === void 0 ? void 0 : commentApiService.getCommentsByChatID)) {
|
|
423779
423608
|
return;
|
|
423780
423609
|
}
|
|
423610
|
+
// 检查缓存
|
|
423611
|
+
const cached = commentCache.get(cacheKey);
|
|
423612
|
+
const now = Date.now();
|
|
423613
|
+
if (cached && now - cached.timestamp < COMMENT_CACHE_TTL) {
|
|
423614
|
+
setCurrentComment(cached.comment);
|
|
423615
|
+
return;
|
|
423616
|
+
}
|
|
423781
423617
|
try {
|
|
423782
423618
|
var _response_data_results, _response_data;
|
|
423783
423619
|
const requestParams = {
|
|
@@ -423789,17 +423625,28 @@ const CommentMessage = (param)=>{
|
|
|
423789
423625
|
};
|
|
423790
423626
|
const response = await commentApiService.getCommentsByChatID(requestParams);
|
|
423791
423627
|
const chatComments = (_response_data = response.data) === null || _response_data === void 0 ? void 0 : (_response_data_results = _response_data.results) === null || _response_data_results === void 0 ? void 0 : _response_data_results.find((item)=>item.chat_id === messageParams.chatId);
|
|
423628
|
+
let comment = null;
|
|
423792
423629
|
if (chatComments === null || chatComments === void 0 ? void 0 : chatComments.comments.length) {
|
|
423793
423630
|
const sortedComments = [
|
|
423794
423631
|
...chatComments.comments
|
|
423795
423632
|
].sort((a, b)=>b.created_at - a.created_at);
|
|
423796
423633
|
const latestComment = sortedComments[0];
|
|
423797
423634
|
if (latestComment) {
|
|
423798
|
-
|
|
423635
|
+
comment = latestComment.name;
|
|
423799
423636
|
}
|
|
423800
423637
|
}
|
|
423638
|
+
// 更新缓存
|
|
423639
|
+
commentCache.set(cacheKey, {
|
|
423640
|
+
comment,
|
|
423641
|
+
timestamp: now
|
|
423642
|
+
});
|
|
423643
|
+
setCurrentComment(comment);
|
|
423801
423644
|
} catch (error) {
|
|
423802
423645
|
console.error('[Comment Message] Failed to fetch comment status:', error);
|
|
423646
|
+
// 如果请求失败,尝试使用缓存数据
|
|
423647
|
+
if (cached) {
|
|
423648
|
+
setCurrentComment(cached.comment);
|
|
423649
|
+
}
|
|
423803
423650
|
}
|
|
423804
423651
|
};
|
|
423805
423652
|
fetchEnums();
|
|
@@ -423817,6 +423664,7 @@ const CommentMessage = (param)=>{
|
|
|
423817
423664
|
}
|
|
423818
423665
|
setLoading(true);
|
|
423819
423666
|
try {
|
|
423667
|
+
const cacheKey = getCacheKey(messageParams.chatId, messageParams.appId, messageParams.conversationId);
|
|
423820
423668
|
// 如果已经点赞,则取消点赞(再次点击)
|
|
423821
423669
|
if (currentComment === 'LIKE') {
|
|
423822
423670
|
if (commentApiService.cancelComment) {
|
|
@@ -423826,7 +423674,13 @@ const CommentMessage = (param)=>{
|
|
|
423826
423674
|
conversation_id: messageParams.conversationId
|
|
423827
423675
|
});
|
|
423828
423676
|
}
|
|
423829
|
-
|
|
423677
|
+
const newComment = null;
|
|
423678
|
+
setCurrentComment(newComment);
|
|
423679
|
+
// 更新缓存
|
|
423680
|
+
commentCache.set(cacheKey, {
|
|
423681
|
+
comment: newComment,
|
|
423682
|
+
timestamp: Date.now()
|
|
423683
|
+
});
|
|
423830
423684
|
} else {
|
|
423831
423685
|
await commentApiService.createComment({
|
|
423832
423686
|
chat_id: messageParams.chatId,
|
|
@@ -423834,7 +423688,20 @@ const CommentMessage = (param)=>{
|
|
|
423834
423688
|
conversation_id: messageParams.conversationId,
|
|
423835
423689
|
name: 'LIKE'
|
|
423836
423690
|
});
|
|
423837
|
-
|
|
423691
|
+
const newComment = 'LIKE';
|
|
423692
|
+
setCurrentComment(newComment);
|
|
423693
|
+
// 更新缓存
|
|
423694
|
+
commentCache.set(cacheKey, {
|
|
423695
|
+
comment: newComment,
|
|
423696
|
+
timestamp: Date.now()
|
|
423697
|
+
});
|
|
423698
|
+
// 显示成功提示
|
|
423699
|
+
const container = findCozeChatSdkContainer();
|
|
423700
|
+
esm_webpack_exports_Toast.success({
|
|
423701
|
+
content: '感谢您的反馈',
|
|
423702
|
+
getContainer: ()=>container,
|
|
423703
|
+
showClose: false
|
|
423704
|
+
});
|
|
423838
423705
|
}
|
|
423839
423706
|
} catch (error) {
|
|
423840
423707
|
console.error('[Comment Message] Failed to handle like comment:', error);
|
|
@@ -423854,6 +423721,7 @@ const CommentMessage = (param)=>{
|
|
|
423854
423721
|
}
|
|
423855
423722
|
setLoading(true);
|
|
423856
423723
|
try {
|
|
423724
|
+
const cacheKey = getCacheKey(messageParams.chatId, messageParams.appId, messageParams.conversationId);
|
|
423857
423725
|
if (commentApiService.cancelComment) {
|
|
423858
423726
|
await commentApiService.cancelComment({
|
|
423859
423727
|
chat_id: messageParams.chatId,
|
|
@@ -423861,7 +423729,13 @@ const CommentMessage = (param)=>{
|
|
|
423861
423729
|
conversation_id: messageParams.conversationId
|
|
423862
423730
|
});
|
|
423863
423731
|
}
|
|
423864
|
-
|
|
423732
|
+
const newComment = null;
|
|
423733
|
+
setCurrentComment(newComment);
|
|
423734
|
+
// 更新缓存
|
|
423735
|
+
commentCache.set(cacheKey, {
|
|
423736
|
+
comment: newComment,
|
|
423737
|
+
timestamp: Date.now()
|
|
423738
|
+
});
|
|
423865
423739
|
} catch (error) {
|
|
423866
423740
|
console.error('[Comment Message] Failed to cancel dislike comment:', error);
|
|
423867
423741
|
// 发生错误时保持当前状态
|
|
@@ -423897,15 +423771,29 @@ const CommentMessage = (param)=>{
|
|
|
423897
423771
|
setLoading(true);
|
|
423898
423772
|
setShowFeedbackDialog(false);
|
|
423899
423773
|
try {
|
|
423774
|
+
const cacheKey = getCacheKey(messageParams.chatId, messageParams.appId, messageParams.conversationId);
|
|
423900
423775
|
await commentApiService.createComment({
|
|
423901
423776
|
chat_id: messageParams.chatId,
|
|
423902
423777
|
app_id: messageParams.appId,
|
|
423903
423778
|
conversation_id: messageParams.conversationId,
|
|
423904
423779
|
name: 'DISLIKE',
|
|
423905
|
-
feedback_type: feedbackType,
|
|
423780
|
+
feedback_type: feedbackType || undefined,
|
|
423906
423781
|
comment: comment || undefined
|
|
423907
423782
|
});
|
|
423908
|
-
|
|
423783
|
+
const newComment = 'DISLIKE';
|
|
423784
|
+
setCurrentComment(newComment);
|
|
423785
|
+
// 更新缓存
|
|
423786
|
+
commentCache.set(cacheKey, {
|
|
423787
|
+
comment: newComment,
|
|
423788
|
+
timestamp: Date.now()
|
|
423789
|
+
});
|
|
423790
|
+
// 显示成功提示
|
|
423791
|
+
const container = findCozeChatSdkContainer();
|
|
423792
|
+
esm_webpack_exports_Toast.success({
|
|
423793
|
+
content: '感谢您的反馈',
|
|
423794
|
+
getContainer: ()=>container,
|
|
423795
|
+
showClose: false
|
|
423796
|
+
});
|
|
423909
423797
|
} catch (error) {
|
|
423910
423798
|
console.error('[Comment Message] Failed to create dislike comment:', error);
|
|
423911
423799
|
setCurrentComment(null);
|
|
@@ -424674,6 +424562,7 @@ const UIKitMessageBoxHoverSlotContent = ()=>{
|
|
|
424674
424562
|
const { isShowDelete, isNeedQuote } = useCurMessageInfo();
|
|
424675
424563
|
const isShowHoverContainer = isShowDelete || !!showHoverText;
|
|
424676
424564
|
const isShowQuote = message.type === 'answer' && !!showHoverText && isNeedQuote;
|
|
424565
|
+
const isShowComment = message.type === 'answer' && !!showHoverText;
|
|
424677
424566
|
const { width: actionBarSize } = es_useSize(actionBarRef) || {};
|
|
424678
424567
|
const actionBarLeft = (0,react.useMemo)(()=>{
|
|
424679
424568
|
var _actionBarRef_current_closest, _actionBarRef_current;
|
|
@@ -424698,7 +424587,7 @@ const UIKitMessageBoxHoverSlotContent = ()=>{
|
|
|
424698
424587
|
return /*#__PURE__*/ (0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
|
|
424699
424588
|
children: [
|
|
424700
424589
|
/*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
|
|
424701
|
-
className: classnames_default()('w-full flex',
|
|
424590
|
+
className: classnames_default()('w-full flex', 'justify-start'),
|
|
424702
424591
|
style: {},
|
|
424703
424592
|
children: /*#__PURE__*/ (0,jsx_runtime.jsxs)(ActionBarHoverContainer, {
|
|
424704
424593
|
style: {
|
|
@@ -424715,6 +424604,9 @@ const UIKitMessageBoxHoverSlotContent = ()=>{
|
|
|
424715
424604
|
externalContent: showHoverText,
|
|
424716
424605
|
isMustGroupLastAnswerMessage: false
|
|
424717
424606
|
}) : null,
|
|
424607
|
+
isShowComment ? /*#__PURE__*/ (0,jsx_runtime.jsx)(CommentMessage, {
|
|
424608
|
+
isMustGroupLastAnswerMessage: false
|
|
424609
|
+
}) : null,
|
|
424718
424610
|
isShowDelete ? /*#__PURE__*/ (0,jsx_runtime.jsx)(delete_message_DeleteMessage, {}) : null,
|
|
424719
424611
|
isShowQuote ? /*#__PURE__*/ (0,jsx_runtime.jsx)(QuoteMessage, {}) : null
|
|
424720
424612
|
]
|
|
@@ -441043,6 +440935,227 @@ const CozeClientWidget = (props)=>/*#__PURE__*/ (0,jsx_runtime.jsx)(GlobalStoreP
|
|
|
441043
440935
|
});
|
|
441044
440936
|
/* ESM default export */ const widget = (CozeClientWidget);
|
|
441045
440937
|
|
|
440938
|
+
;// CONCATENATED MODULE: ./src/util/webcomponent-adapter.tsx
|
|
440939
|
+
/*
|
|
440940
|
+
* Copyright 2025 coze-dev Authors
|
|
440941
|
+
*
|
|
440942
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
440943
|
+
* you may not use this file except in compliance with the License.
|
|
440944
|
+
* You may obtain a copy of the License at
|
|
440945
|
+
*
|
|
440946
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
440947
|
+
*
|
|
440948
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
440949
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
440950
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
440951
|
+
* See the License for the specific language governing permissions and
|
|
440952
|
+
* limitations under the License.
|
|
440953
|
+
*/
|
|
440954
|
+
|
|
440955
|
+
/**
|
|
440956
|
+
* 组件包装器缓存
|
|
440957
|
+
* 改进:避免重复创建相同 tagName 的包装器组件
|
|
440958
|
+
*/ const wrapperCache = new Map();
|
|
440959
|
+
/**
|
|
440960
|
+
* 将对象转换为 Web Component 的属性
|
|
440961
|
+
* 改进:处理 null、undefined、数组等特殊情况,添加错误处理
|
|
440962
|
+
*/ function setWebComponentProps(element, props) {
|
|
440963
|
+
Object.entries(props).forEach((param)=>{
|
|
440964
|
+
let [key, value] = param;
|
|
440965
|
+
try {
|
|
440966
|
+
// 跳过 undefined
|
|
440967
|
+
if (value === undefined) {
|
|
440968
|
+
return;
|
|
440969
|
+
}
|
|
440970
|
+
// null 设置为空字符串
|
|
440971
|
+
if (value === null) {
|
|
440972
|
+
element.setAttribute(key, '');
|
|
440973
|
+
return;
|
|
440974
|
+
}
|
|
440975
|
+
// 复杂对象(包括数组)设置为属性
|
|
440976
|
+
if (typeof value === 'object' || Array.isArray(value)) {
|
|
440977
|
+
element[key] = value;
|
|
440978
|
+
} else if (typeof value === 'function') {
|
|
440979
|
+
// 函数类型设置为属性(事件处理器等)
|
|
440980
|
+
element[key] = value;
|
|
440981
|
+
} else {
|
|
440982
|
+
// 基本类型设置为 attribute
|
|
440983
|
+
element.setAttribute(key, String(value));
|
|
440984
|
+
}
|
|
440985
|
+
} catch (error) {
|
|
440986
|
+
console.warn(`[WebComponent] Failed to set property "${key}" on ${element.tagName}:`, error);
|
|
440987
|
+
}
|
|
440988
|
+
});
|
|
440989
|
+
}
|
|
440990
|
+
/**
|
|
440991
|
+
* 创建一个 React 组件包装器,用于渲染 Web Component
|
|
440992
|
+
* 改进:
|
|
440993
|
+
* 1. 使用 React.memo 避免不必要的重渲染
|
|
440994
|
+
* 2. 优化 props 比较,避免无限循环
|
|
440995
|
+
* 3. 添加清理逻辑,防止内存泄漏
|
|
440996
|
+
* 4. 添加缓存机制,提升性能
|
|
440997
|
+
*/ function createWebComponentWrapper(tagName) {
|
|
440998
|
+
// 检查缓存
|
|
440999
|
+
const cachedWrapper = wrapperCache.get(tagName);
|
|
441000
|
+
if (cachedWrapper) {
|
|
441001
|
+
return cachedWrapper;
|
|
441002
|
+
}
|
|
441003
|
+
const WrapperComponent = /*#__PURE__*/ react.memo((props)=>{
|
|
441004
|
+
const elementRef = (0,react.useRef)(null);
|
|
441005
|
+
const propsRef = (0,react.useRef)(props);
|
|
441006
|
+
const cleanupRef = (0,react.useRef)(null);
|
|
441007
|
+
const isInitialMountRef = (0,react.useRef)(true);
|
|
441008
|
+
// 使用 useMemo 进行深度比较,避免每次都触发更新
|
|
441009
|
+
const propsChanged = (0,react.useMemo)(()=>{
|
|
441010
|
+
try {
|
|
441011
|
+
return JSON.stringify(propsRef.current) !== JSON.stringify(props);
|
|
441012
|
+
} catch (error) {
|
|
441013
|
+
// JSON.stringify 可能失败(循环引用等),降级为浅比较
|
|
441014
|
+
console.warn('[WebComponent] Failed to compare props:', error);
|
|
441015
|
+
return propsRef.current !== props;
|
|
441016
|
+
}
|
|
441017
|
+
}, [
|
|
441018
|
+
props
|
|
441019
|
+
]);
|
|
441020
|
+
(0,react.useEffect)(()=>{
|
|
441021
|
+
// 首次挂载或 props 变化时,都需要调用 updateProps
|
|
441022
|
+
const shouldUpdate = isInitialMountRef.current || propsChanged && elementRef.current;
|
|
441023
|
+
if (shouldUpdate && elementRef.current) {
|
|
441024
|
+
if (isInitialMountRef.current) {
|
|
441025
|
+
isInitialMountRef.current = false;
|
|
441026
|
+
}
|
|
441027
|
+
propsRef.current = props;
|
|
441028
|
+
// 设置属性
|
|
441029
|
+
setWebComponentProps(elementRef.current, props);
|
|
441030
|
+
// 如果 Web Component 定义了更新方法,调用它
|
|
441031
|
+
const customElement = elementRef.current;
|
|
441032
|
+
if (typeof customElement.updateProps === 'function') {
|
|
441033
|
+
try {
|
|
441034
|
+
customElement.updateProps(props);
|
|
441035
|
+
} catch (error) {
|
|
441036
|
+
console.error(`[WebComponent] Error calling updateProps on ${tagName}:`, error);
|
|
441037
|
+
}
|
|
441038
|
+
}
|
|
441039
|
+
// 保存清理函数
|
|
441040
|
+
if (typeof customElement.cleanup === 'function') {
|
|
441041
|
+
cleanupRef.current = ()=>{
|
|
441042
|
+
try {
|
|
441043
|
+
var _customElement_cleanup;
|
|
441044
|
+
(_customElement_cleanup = customElement.cleanup) === null || _customElement_cleanup === void 0 ? void 0 : _customElement_cleanup.call(customElement);
|
|
441045
|
+
} catch (error) {
|
|
441046
|
+
console.error(`[WebComponent] Error during cleanup of ${tagName}:`, error);
|
|
441047
|
+
}
|
|
441048
|
+
};
|
|
441049
|
+
}
|
|
441050
|
+
}
|
|
441051
|
+
// 返回清理函数
|
|
441052
|
+
return ()=>{
|
|
441053
|
+
if (cleanupRef.current) {
|
|
441054
|
+
cleanupRef.current();
|
|
441055
|
+
cleanupRef.current = null;
|
|
441056
|
+
}
|
|
441057
|
+
};
|
|
441058
|
+
// tagName 是外部作用域的值,不需要作为依赖项
|
|
441059
|
+
}, [
|
|
441060
|
+
propsChanged,
|
|
441061
|
+
props
|
|
441062
|
+
]);
|
|
441063
|
+
// 使用 React.createElement 创建自定义元素
|
|
441064
|
+
return /*#__PURE__*/ react.createElement(tagName, {
|
|
441065
|
+
ref: elementRef
|
|
441066
|
+
});
|
|
441067
|
+
}, // 自定义比较函数,使用深度比较
|
|
441068
|
+
(prevProps, nextProps)=>{
|
|
441069
|
+
try {
|
|
441070
|
+
return JSON.stringify(prevProps) === JSON.stringify(nextProps);
|
|
441071
|
+
} catch (error) {
|
|
441072
|
+
// JSON.stringify 可能失败(循环引用等),降级为浅比较
|
|
441073
|
+
console.warn('[WebComponent] Failed to compare props in memo:', error);
|
|
441074
|
+
return prevProps === nextProps;
|
|
441075
|
+
}
|
|
441076
|
+
});
|
|
441077
|
+
// 缓存组件(类型安全的 cast)
|
|
441078
|
+
wrapperCache.set(tagName, WrapperComponent);
|
|
441079
|
+
return WrapperComponent;
|
|
441080
|
+
}
|
|
441081
|
+
/**
|
|
441082
|
+
* 支持的 UIKit 组件类型
|
|
441083
|
+
* 改进:使用常量定义,便于扩展和维护
|
|
441084
|
+
* 与 UIKitCustomComponentsMap 保持对齐
|
|
441085
|
+
*/ const SUPPORTED_COMPONENTS = [
|
|
441086
|
+
'JsonItem',
|
|
441087
|
+
'MentionOperateTool',
|
|
441088
|
+
'SendButton',
|
|
441089
|
+
'AvatarWrap'
|
|
441090
|
+
];
|
|
441091
|
+
/**
|
|
441092
|
+
* 将 Web Component 配置转换为 React 组件映射
|
|
441093
|
+
* 改进:
|
|
441094
|
+
* 1. 使用循环处理,避免重复代码
|
|
441095
|
+
* 2. 添加错误处理
|
|
441096
|
+
* 3. 返回类型更明确
|
|
441097
|
+
*/ function adaptWebComponentsToReact(webComponents) {
|
|
441098
|
+
if (!webComponents) {
|
|
441099
|
+
return undefined;
|
|
441100
|
+
}
|
|
441101
|
+
try {
|
|
441102
|
+
const reactComponents = {};
|
|
441103
|
+
// 动态处理所有支持的组件
|
|
441104
|
+
SUPPORTED_COMPONENTS.forEach((componentName)=>{
|
|
441105
|
+
const tagName = webComponents[componentName];
|
|
441106
|
+
if (tagName) {
|
|
441107
|
+
// 验证 Web Component 是否已注册
|
|
441108
|
+
if (!customElements.get(tagName)) {
|
|
441109
|
+
console.warn(`[WebChatClient] Web Component "${tagName}" for ${componentName} is not registered. ` + 'Please register it using customElements.define() before initializing the chat client.');
|
|
441110
|
+
}
|
|
441111
|
+
// 创建包装器组件
|
|
441112
|
+
// 使用类型断言,因为每个组件的 props 类型不同
|
|
441113
|
+
reactComponents[componentName] = createWebComponentWrapper(tagName);
|
|
441114
|
+
}
|
|
441115
|
+
});
|
|
441116
|
+
return Object.keys(reactComponents).length > 0 ? reactComponents : undefined;
|
|
441117
|
+
} catch (error) {
|
|
441118
|
+
console.error('[WebChatClient] Failed to adapt Web Components:', error);
|
|
441119
|
+
return undefined;
|
|
441120
|
+
}
|
|
441121
|
+
}
|
|
441122
|
+
/**
|
|
441123
|
+
* 适配 contentBox Web Component
|
|
441124
|
+
* 改进:添加错误处理和类型安全
|
|
441125
|
+
*/ function adaptContentBoxWebComponent(tagName) {
|
|
441126
|
+
if (!tagName) {
|
|
441127
|
+
return undefined;
|
|
441128
|
+
}
|
|
441129
|
+
try {
|
|
441130
|
+
// 验证 Web Component 是否已注册
|
|
441131
|
+
if (!customElements.get(tagName)) {
|
|
441132
|
+
console.warn(`[WebChatClient] Web Component "${tagName}" is not registered. ` + 'Please register it using customElements.define() before initializing the chat client.');
|
|
441133
|
+
}
|
|
441134
|
+
return createWebComponentWrapper(tagName);
|
|
441135
|
+
} catch (error) {
|
|
441136
|
+
console.error(`[WebChatClient] Failed to adapt contentBox Web Component "${tagName}":`, error);
|
|
441137
|
+
return undefined;
|
|
441138
|
+
}
|
|
441139
|
+
}
|
|
441140
|
+
/**
|
|
441141
|
+
* 检查浏览器是否支持 Web Components
|
|
441142
|
+
*/ function checkWebComponentsSupport() {
|
|
441143
|
+
const missing = [];
|
|
441144
|
+
if (!window.customElements) {
|
|
441145
|
+
missing.push('Custom Elements');
|
|
441146
|
+
}
|
|
441147
|
+
if (!('attachShadow' in Element.prototype)) {
|
|
441148
|
+
missing.push('Shadow DOM');
|
|
441149
|
+
}
|
|
441150
|
+
if (!('content' in document.createElement('template'))) {
|
|
441151
|
+
missing.push('HTML Templates');
|
|
441152
|
+
}
|
|
441153
|
+
return {
|
|
441154
|
+
supported: missing.length === 0,
|
|
441155
|
+
missing
|
|
441156
|
+
};
|
|
441157
|
+
}
|
|
441158
|
+
|
|
441046
441159
|
// EXTERNAL MODULE: ../../../../../common/temp/default/node_modules/.pnpm/css-loader@6.11.0_@rspack+core@1.5.8_webpack@5.91.0/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[7].use[1]!../../../../../common/temp/default/node_modules/.pnpm/postcss-loader@7.3.4_postcss@8.5.6_typescript@5.8.2_webpack@5.91.0/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[7].use[2]!../../../../../common/temp/default/node_modules/.pnpm/less-loader@11.1.4_less@4.4.2_webpack@5.91.0/node_modules/less-loader/dist/cjs.js??ruleSet[1].rules[7].use[3]!../../../common/assets/style/index.less
|
|
441047
441160
|
var assets_style = __webpack_require__(2092);
|
|
441048
441161
|
;// CONCATENATED MODULE: ../../../common/assets/style/index.less
|