ibc-ai-web-sdk 2.0.1 → 2.0.2
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/dist/index.cjs.js +3 -37
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +3 -37
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +3 -37
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/index.umd.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).AIWebSDK={})}(this,function(e){"use strict";var t="data:image/svg+xml,"+encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">\n <defs>\n <linearGradient id="g" x1="0" y1="0" x2="1" y2="1">\n <stop offset="0%" stop-color="#2563eb"/>\n <stop offset="100%" stop-color="#7c3aed"/>\n </linearGradient>\n </defs>\n <circle cx="50" cy="50" r="50" fill="url(#g)"/>\n <rect x="24" y="36" width="14" height="14" rx="4" fill="#fff" opacity=".9"/>\n <rect x="62" y="36" width="14" height="14" rx="4" fill="#fff" opacity=".9"/>\n <circle cx="28" cy="40" r="3.5" fill="#2563eb"/>\n <circle cx="66" cy="40" r="3.5" fill="#2563eb"/>\n <rect x="38" y="26" width="4" height="10" rx="2" fill="#fff" opacity=".8"/>\n <circle cx="40" cy="24" r="5" fill="#fff" opacity=".7"/>\n <path d="M36 62 Q50 76 64 62" fill="none" stroke="#fff" stroke-width="3" stroke-linecap="round" opacity=".8"/>\n</svg>');const n={AGENT_NOT_FOUND:40001,PROMPT_EMPTY:40002,AUTH_FAILED:40301,NETWORK_ERROR:500,SERVER_ERROR:50001,TIMEOUT_ERROR:50002,REQUEST_CANCELLED:0},i=new Set(["SUCCESS","000000","0","200",0,200]),r=new Set(["401","403","1005","S00001","ET0006","999990"]),s=new Set(["[START]"]),a=new Set(["[ERROR]","error"]),o=new Set(["meta"]),l=new Set(["[DONE]","done"]),c=new Set(["planning","planning_progress","plan","plan_snapshot"]),d=new Set(["message"]),h=new Set(["[THINKING]"]),p=new Set(["[PROGRESS]"]),u=new Set(["[TOOL_START]"]),g=new Set(["[TOOL_RESULT]"]),f=new Set(["[TOOL_END]"]),m=new Set(["NODE_START"]),b=new Set(["NODE_PROGRESS"]),x=new Set(["NODE_COMPLETE"]),y=new Set(["[WARNING]"]),k=new Set(["[HITL]"]),_=["请求已受理","任务已受理","正在思考","正在执行...","正在执行…","正在执行","结果处理中","已进入助手运行时","任务运行时","SSE 连接已建立"];function w(){return"req_"+Date.now().toString(36)+"_"+Math.random().toString(36).slice(2,8)}function v(e,t){return e?/^https?:\/\//i.test(t)?t:String(e||"").replace(/\/+$/,"")+"/"+String(t||"").replace(/^\/+/,""):t}function T(e){const t=String(e||"").trim();return!!t&&_.some(e=>t.includes(e))}function E(e){if(!e||"string"!=typeof e)return null;try{return JSON.parse(e)}catch(e){return null}}function S(e){const t=String(e||"").split("\n");let n="message";const i=[];for(const e of t)e.startsWith(":")||(e.startsWith("event:")?n=e.slice(6).trim():e.startsWith("data:")&&i.push(e.slice(5).replace(/^\s/,"")));return{event:n,data:i.join("\n")}}class I{constructor(e={}){this.config={apiBaseUrl:"",apiEndpoint:"/v1/app/completion",streamEndpoint:"/v1/app/completion/stream",stopEndpoint:"/v1/app/completion/stop",asyncEndpoint:"/v1/app/completion/async",attachmentUploadEndpoint:"/v1/app/attachment/upload",conversationQueryEndpoint:"/v1/app/conversation/query",conversationDeleteEndpoint:"/v1/app/conversation/delete",appDetailEndpoint:"/v1/app/{appId}",taskStatusEndpoint:"/v1/app/task/{taskId}",appListEndpoint:"/v1/app/list",runtimePermissionReplyEndpoint:"/v1/app/runtime/permission/reply",runtimeQuestionReplyEndpoint:"/v1/app/runtime/question/reply",runtimeQuestionRejectEndpoint:"/v1/app/runtime/question/reject",timeout:6e4,streamTimeout:3e5,maxRetries:3,retryDelay:1e3,enableRetry:!0,backgroundRefreshEnabled:!0,backgroundRefreshIntervalMs:3e5,...e},this.conversationId=e.conversationId||null,this.currentRequestId=null,this.abortController=null,this.refreshTokenPromise=null,this._backgroundTimer=null,this._visibilityHandler=null,this._shouldStartBackgroundRefresh()&&this.startBackgroundRefresh()}buildUrl(e){return v(this.config.apiBaseUrl||"",e)}buildHeaders(e={}){const t={...e};return this.config.token&&!t.Authorization&&(t.Authorization=/^Bearer\s+/i.test(this.config.token)?this.config.token:"Bearer "+this.config.token),this.config.headers&&"object"==typeof this.config.headers&&Object.assign(t,this.config.headers),t}createError(e,t,n={}){return{success:!1,code:e,message:t,data:null,...n}}getAuthCodes(){const e=Array.isArray(this.config.authErrorCodes)?this.config.authErrorCodes:[];return new Set([...r,...e.map(e=>String(e))])}isAuthErrorCode(e){return this.getAuthCodes().has(String(e))}isTokenExpiring(){const e=Number(this.config.tokenExpiresAt||0);if(!e)return!1;const t=Number(this.config.tokenRefreshBufferMs??6e4),n=e<1e10?1e3*e:e;return Date.now()+t>=n}applyTokenResult(e){if(!e)return"";if("string"==typeof e)return this.config.token=e,e;if("object"==typeof e){const t=e.token||e.accessToken||e.authorization||"";t&&(this.config.token=t),e.refreshToken&&(this.config.refreshToken=e.refreshToken);const n=e.expiresAt??e.expireAt,i=e.expiresIn??e.expireIn;if(n){const e=Number(n);this.config.tokenExpiresAt=e<1e10?1e3*e:e}else i&&(this.config.tokenExpiresAt=Date.now()+1e3*Number(i));return e.headers&&"object"==typeof e.headers&&(this.config.headers={...this.config.headers||{},...e.headers}),t}return""}async refreshToken(e="expired",{silent:t=!1}={}){if("function"!=typeof this.config.refreshTokenFn){const e=new Error("Token 已过期且未配置 refreshTokenFn");throw t||(this.stopBackgroundRefresh(),this.config.onTokenExpired?.(e)),e}return this.refreshTokenPromise||(this.refreshTokenPromise=Promise.resolve().then(()=>this.config.refreshTokenFn({token:this.config.token||"",refreshToken:this.config.refreshToken||"",userId:this.config.userId||"",reason:e})).then(e=>{const t=this.applyTokenResult(e);return this._shouldStartBackgroundRefresh()&&this.startBackgroundRefresh(),this.config.onTokenRefreshed?.({token:this.config.token||t,refreshToken:this.config.refreshToken||"",tokenExpiresAt:this.config.tokenExpiresAt,raw:e}),t}).catch(n=>{if(t)return console.warn("[AIChatClient] Silent token refresh failed (reason="+e+"):",n.message),this.config.token||"";throw this.stopBackgroundRefresh(),this.config.onTokenExpired?.(n),n}).finally(()=>{this.refreshTokenPromise=null})),this.refreshTokenPromise}_shouldStartBackgroundRefresh(){return!1!==this.config.backgroundRefreshEnabled&&"function"==typeof this.config.refreshTokenFn&&Number(this.config.tokenExpiresAt||0)>0}startBackgroundRefresh(){if(this._backgroundTimer||!this._shouldStartBackgroundRefresh())return;const e=Math.max(3e4,Number(this.config.backgroundRefreshIntervalMs||3e5));this._backgroundTimer=setInterval(()=>{this.isTokenExpiring()&&this.refreshToken("scheduled",{silent:!0})},e),this._visibilityHandler=()=>{"visible"===document.visibilityState&&this.isTokenExpiring()&&this.refreshToken("visibility",{silent:!0})},"undefined"!=typeof document&&document.addEventListener("visibilitychange",this._visibilityHandler)}stopBackgroundRefresh(){this._backgroundTimer&&(clearInterval(this._backgroundTimer),this._backgroundTimer=null),this._visibilityHandler&&("undefined"!=typeof document&&document.removeEventListener("visibilitychange",this._visibilityHandler),this._visibilityHandler=null)}dispose(){this.stopBackgroundRefresh(),this.cancelCurrentRequest(),this.refreshTokenPromise=null}async ensureFreshToken(){if(this.isTokenExpiring())try{await this.refreshToken("preflight",{silent:!0})}catch{}}async runAuthFn(){if(this.config.authFn)try{await this.config.authFn(this.config.token||"",this.config.userId||"")}catch(e){if("function"!=typeof this.config.refreshTokenFn)throw e;await this.refreshToken("authFn"),await this.config.authFn(this.config.token||"",this.config.userId||"")}}parseResponse(e){if(e&&"object"==typeof e&&!0===e.success&&Object.prototype.hasOwnProperty.call(e,"data"))return{success:!0,code:e.code||e.errCode||200,message:e.message||e.errMsg||"",data:e.data||null,requestId:e.requestId};if(e&&"object"==typeof e&&e.bizContent){const t="string"==typeof e.bizContent?E(e.bizContent):e.bizContent;return{success:!0,code:e.code||e.errCode||200,message:e.message||e.errMsg||"",data:t,requestId:e.requestId}}const t=e&&(void 0!==e.code?e.code:e.errCode),n=e&&(!0===e.success||"SUCCESS"===e.rtnCode||i.has(t));return{success:!!n,code:t||(n?200:0),message:e&&(e.message||e.errMsg||e.rtnMsg)||"",data:e&&(e.data||e.bizContent)||null,requestId:e&&e.requestId}}async requestJson(e,t={},i={}){if("undefined"!=typeof navigator&&!1===navigator.onLine)return this.createError(n.NETWORK_ERROR,"网络连接已断开,请检查网络后重试");const r=new AbortController,s=i.timeout||this.config.timeout||6e4,a=s>0?setTimeout(()=>r.abort(),s):null;try{await this.ensureFreshToken();const n=async()=>{const n=await fetch(this.buildUrl(e),{method:i.method||"POST",headers:this.buildHeaders({"Content-Type":"application/json"}),credentials:this.config.credentials||"include",body:"GET"===i.method?void 0:JSON.stringify(t),signal:r.signal});return n.ok?this.parseResponse(await n.json()):this.createError(n.status,`HTTP ${n.status} ${n.statusText||""}`.trim())};let s=await n();return!i.skipAuthRefresh&&this.isAuthErrorCode(s.code)&&(await this.refreshToken("response"),s=await n()),s}catch(e){return e&&"AbortError"===e.name?this.createError(n.TIMEOUT_ERROR,"请求超时,请稍后重试"):this.createError(n.NETWORK_ERROR,e.message||"网络请求失败,请稍后重试")}finally{a&&clearTimeout(a)}}buildAppPayload(e,t={}){const n=t.requestId||w(),i={appId:t.appId||this.config.appId||this.config.agentAppId||null,prompt:String(e||"").trim(),userId:t.userId||this.config.userId||null,bizType:t.bizType||this.config.bizType||null,requestId:n},r=Object.prototype.hasOwnProperty.call(t,"conversationId")?t.conversationId:this.conversationId;r&&(i.conversationId=r);const s=t.attachmentIds||this.normalizeAttachmentIds(t.attachments);s.length>0&&(i.attachmentIds=s);const a=t.bizParams||t.extendInfo||this.config.extendInfo;return a&&(i.bizParams="string"==typeof a?a:JSON.stringify(a)),i}normalizeAttachmentIds(e){return Array.isArray(e)?e.map(e=>"string"==typeof e?e:e&&(e.attachmentId||e.fileId||e.id)).filter(Boolean):[]}async sendMessage(e,t,i={}){if(!e||!String(e).trim())return this.createError(n.PROMPT_EMPTY,"提示词不能为空");t&&(this.config.token=t);try{await this.runAuthFn()}catch(e){return this.createError(n.AUTH_FAILED,"鉴权失败,无法使用智能体:"+(e.message||"未知错误"))}const r=void 0!==i.retries?i.retries:this.config.maxRetries;let s=null;for(let t=0;t<=r;t++){t>0&&await new Promise(e=>setTimeout(e,(this.config.retryDelay||1e3)*Math.pow(2,t-1)));const n=this.buildAppPayload(e,i);if(this.currentRequestId=n.requestId,s=await this.requestJson(i.endpoint||this.config.apiEndpoint,n),s.success||!this.isRetryableError(s)||!1===this.config.enableRetry)break}return s&&s.data&&s.data.conversationId&&(this.conversationId=s.data.conversationId),s}isRetryableError(e){const t=e&&e.code;return[n.NETWORK_ERROR,n.TIMEOUT_ERROR,n.SERVER_ERROR,500,502,503,504].includes(t)}async sendMessageStream(e,t={},i={}){if(!e||!String(e).trim()){const e=this.createError(n.PROMPT_EMPTY,"提示词不能为空");return t.onError?.(e.message,e),e}try{await this.runAuthFn()}catch(e){return this.createError(n.AUTH_FAILED,`鉴权失败,无法使用智能体:${e.message||"未知错误"}`)}try{return await this.executeMessageStream(e,t,i,!1)}catch(e){if(e&&"AbortError"===e.name){const i="请求超时或已取消";return t.onError?.(i,e.sseData||e),this.createError(n.REQUEST_CANCELLED,i)}if(e&&e.authError){const i=e.message||"鉴权失败";return t.onError?.(i,e.sseData||e),this.createError(n.AUTH_FAILED,i)}const i=e.message||"流式请求失败";return t.onError?.(i,e.sseData||e),this.createError(n.NETWORK_ERROR,i)}}async executeMessageStream(e,t,n,i){this.cancelCurrentRequest(),this.abortController=new AbortController;const r=n.timeout||this.config.streamTimeout||this.config.timeout||3e5,s=r>0?setTimeout(()=>this.abortController.abort(),r):null,a=this.buildAppPayload(e,n);this.currentRequestId=a.requestId;let o="",l=!1;try{await this.ensureFreshToken();const r=await fetch(this.buildUrl(n.endpoint||this.config.streamEndpoint),{method:"POST",headers:this.buildHeaders({"Content-Type":"application/json",Accept:"text/event-stream"}),credentials:this.config.credentials||"include",body:JSON.stringify(a),signal:this.abortController.signal});if(!r.ok||!r.body){if(!i&&this.isAuthErrorCode(r.status))return s&&clearTimeout(s),await this.refreshToken("response"),this.executeMessageStream(e,t,n,!0);throw new Error(`流式请求失败:HTTP ${r.status}`)}const c=r.body.getReader(),h=new TextDecoder;let p="";for(;;){const{value:e,done:n}=await c.read();if(n)break;p+=h.decode(e,{stream:!0}).replace(/\r\n/g,"\n");const i=p.split("\n\n");p=i.pop()||"";for(const e of i){if(!e.trim())continue;const{event:n,data:i}=S(e);this.handleSseEvent(n,i,t,e=>{o=e},()=>{l=!0}),!d.has(n)||!i||i.startsWith("[META]")||T(i)||this.isEventLike(i)||(o+=i)}}return l||t.onDone?.(o),{success:!0,code:200,message:"",data:{content:o,conversationId:this.conversationId,requestId:a.requestId}}}catch(r){if(!i&&r&&r.authError)return s&&clearTimeout(s),await this.refreshToken("response"),this.executeMessageStream(e,t,n,!0);throw r}finally{s&&clearTimeout(s),this.abortController=null}}handleSseEvent(e,t,n,i,r){if(s.has(e))n.onStart?.();else if(h.has(e))t&&n.onThinking?.(t);else{if(p.has(e)){const e=E(t);return void n.onProgressEvent?.(e?.stage||"",e?.message||t||"")}if(u.has(e)){const e=E(t);return void n.onToolStart?.(e?.toolName||"",e?.toolCallId||"")}if(g.has(e)){const e=E(t);return void n.onToolResult?.(e?.toolName||"",e?.text||t||"")}if(f.has(e)){const e=E(t);return void n.onToolEnd?.(e?.toolName||"",e?.toolCallId||"")}if(m.has(e)){const e=(t||"").split("\n");return void n.onNodeStart?.(e[0]||"",e.slice(1).join("\n")||t||"")}if(b.has(e)){const e=(t||"").split("\n");return void n.onNodeProgress?.(e[0]||"",e.slice(1).join("\n")||t||"")}if(x.has(e)){const e=(t||"").split("\n");return void n.onNodeComplete?.(e[0]||"",e.slice(1).join("\n")||t||"")}if(y.has(e)){const e=E(t);return void n.onWarning?.(e?.message||t||"")}if(k.has(e)){const e=E(t);return void(e&&n.onHitlInterrupt?.({type:e.type||"TOOL_CONFIRMATION",requestId:e.requestId||"",sessionId:e.sessionId||"",taskRunId:e.taskRunId||"",toolCalls:e.toolCalls||[],message:e.message||""}))}if(a.has(e)){const e=E(t),n=e&&(e.message||e.errorMessage)||t||"流式请求失败",i=e&&(e.code||e.errCode||e.status);if(i&&this.isAuthErrorCode(i)){const e=new Error(n);throw e.authError=!0,e.code=i,e}const r=new Error(n);throw r.sseData=e||t,r}if((o.has(e)||d.has(e))&&t.startsWith("[META]")){const e=E(t.slice(6));return void(e&&((e.conversationId||e.sessionId)&&(this.conversationId=e.conversationId||e.sessionId),n.onMeta?.(e)))}if(c.has(e)||!d.has(e)&&!l.has(e)){const e=E(t);return void(e&&"object"==typeof e?n.onPlanningEvent?.(e):t&&!T(t)&&n.onProgress?.(t))}if(d.has(e)){if(!t||T(t)||this.isEventLike(t))return;n.onMessage?.(t)}else if(l.has(e)){let e="";if(t.startsWith("[META]")){const e=E(t.slice(6));e&&((e.conversationId||e.sessionId)&&(this.conversationId=e.conversationId||e.sessionId),n.onMeta?.(e))}else{const i=E(t);i&&"object"==typeof i&&((i.conversationId||i.sessionId)&&(this.conversationId=i.conversationId||i.sessionId),e=i.response?.finalAnswer||i.response?.finalResult||i.response?.result||i.response?.summary||i.response?.answer||i.response?.output||i.finalAnswer||i.finalResult||i.result||i.summary||i.answer||i.output||"",n.onMeta?.({conversationId:i.conversationId||i.sessionId,taskRunId:i.taskRunId,traceId:i.traceId,inputTokens:i.inputTokens,outputTokens:i.outputTokens}))}e&&i(e),r(),n.onDone?.(e)}}}isEventLike(e){const t=String(e||"").trim();if(t.startsWith("[META]")||t.startsWith("event:"))return!0;const n=E(t);return!(!n||"object"!=typeof n||!(n.eventType||n.eventId||n.taskRunId||n.metadata||n.currentTask))}async stopCompletion(e=this.currentRequestId){return this.abortController&&this.abortController.abort(),e?this.requestJson(this.config.stopEndpoint,{requestId:e,userId:this.config.userId,appId:this.config.appId||this.config.agentAppId}):this.createError(n.REQUEST_CANCELLED,"当前没有可停止的请求")}async uploadAttachment(e,t={}){if(!e)return this.createError(n.PROMPT_EMPTY,"文件不能为空");const i=new AbortController,r=t.timeout||this.config.uploadTimeout||5*(this.config.timeout||6e4),s=r>0?setTimeout(()=>i.abort(),r):null;try{await this.ensureFreshToken();const n=async()=>{const n=new FormData;n.append("file",e),n.append("userId",t.userId||this.config.userId||""),t.fileType&&n.append("fileType",t.fileType),(t.conversationId||this.conversationId)&&n.append("conversationId",t.conversationId||this.conversationId);const r=this.buildHeaders();delete r["Content-Type"];const s=await fetch(this.buildUrl(t.endpoint||this.config.attachmentUploadEndpoint),{method:"POST",headers:r,credentials:this.config.credentials||"include",body:n,signal:i.signal});return s.ok?this.parseResponse(await s.json()):this.createError(s.status,`HTTP ${s.status} ${s.statusText||""}`.trim())};let r=await n();return!t.skipAuthRefresh&&this.isAuthErrorCode(r.code)&&(await this.refreshToken("response"),r=await n()),r}catch(e){return this.createError(e&&"AbortError"===e.name?n.TIMEOUT_ERROR:n.NETWORK_ERROR,e.message||"文件上传失败")}finally{s&&clearTimeout(s)}}async queryConversation(e={}){const t=e.conversationId||this.conversationId,i=e.appId||this.config.appId||this.config.agentAppId;return t||i?this.requestJson(this.config.conversationQueryEndpoint,{userId:e.userId||this.config.userId,requestId:e.requestId||w(),conversationId:t,appId:i,bizType:e.bizType||this.config.bizType,pageIndex:e.pageIndex||1,pageSize:e.pageSize||20}):this.createError(n.PROMPT_EMPTY,"会话ID和应用ID不能同时为空")}async deleteConversation(e=this.conversationId,t={}){if(!e)return this.createError(n.PROMPT_EMPTY,"会话ID不能为空");const i=await this.requestJson(this.config.conversationDeleteEndpoint,{userId:t.userId||this.config.userId,requestId:t.requestId||w(),conversationId:e,appId:t.appId||this.config.appId||this.config.agentAppId,bizType:t.bizType||this.config.bizType});return i.success&&e===this.conversationId&&(this.conversationId=null),i}async asyncCompletion(e,t={}){const n=this.buildAppPayload(e,t);return this.currentRequestId=n.requestId,this.requestJson(this.config.asyncEndpoint,n)}async getTaskStatus(e,t={}){if(!e)return this.createError(n.PROMPT_EMPTY,"任务ID不能为空");const i=(t.endpoint||this.config.taskStatusEndpoint).replace("{taskId}",encodeURIComponent(e));return this.requestJson(i,void 0,{method:"GET",timeout:t.timeout})}async getAppDetail(e=this.config.appId||this.config.agentAppId,t={}){if(!e)return this.createError(n.AGENT_NOT_FOUND,"智能体应用ID不能为空");const i=(t.endpoint||this.config.appDetailEndpoint).replace("{appId}",encodeURIComponent(e));return this.requestJson(i,void 0,{method:"GET",timeout:t.timeout})}async listApplications(e={}){const t={applicationType:e.applicationType,pageIndex:e.pageIndex||1,pageSize:e.pageSize||20,userId:this.config.userId,requestId:w()};return this.requestJson(e.endpoint||this.config.appListEndpoint,t)}async replyPermission(e){if(!e.sessionId||!e.requestId)return this.createError(n.PROMPT_EMPTY,"sessionId和requestId不能为空");const t={sessionId:e.sessionId,requestId:e.requestId,reply:e.reply||"once",message:e.message||"",userId:this.config.userId,replyRequestId:w()};return this.requestJson(this.config.runtimePermissionReplyEndpoint,t)}async replyQuestion(e){if(!e.sessionId||!e.requestId)return this.createError(n.PROMPT_EMPTY,"sessionId和requestId不能为空");const t={sessionId:e.sessionId,requestId:e.requestId,answers:e.answers||[],userId:this.config.userId,replyRequestId:w()};return this.requestJson(this.config.runtimeQuestionReplyEndpoint,t)}async rejectQuestion(e){if(!e.sessionId||!e.requestId)return this.createError(n.PROMPT_EMPTY,"sessionId和requestId不能为空");const t={sessionId:e.sessionId,requestId:e.requestId,userId:this.config.userId,replyRequestId:w()};return this.requestJson(this.config.runtimeQuestionRejectEndpoint,t)}setConversationId(e){this.conversationId=e||null}clearConversation(){this.conversationId=null,this.currentRequestId=null,this.cancelCurrentRequest()}cancelCurrentRequest(){this.abortController&&(this.abortController.abort(),this.abortController=null)}updateConfig(e){const t=this._shouldStartBackgroundRefresh();Object.assign(this.config,e||{});const n=this._shouldStartBackgroundRefresh();!t&&n?this.startBackgroundRefresh():t&&!n&&this.stopBackgroundRefresh()}}function R(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var A={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function C(e){A=e}var L={exec:()=>null};function M(e){let t=[];return n=>{let i=Math.max(0,Math.min(3,n-1)),r=t[i];return r||(r=e(i),t[i]=r),r}}function D(e,t=""){let n="string"==typeof e?e:e.source,i={replace:(e,t)=>{let r="string"==typeof t?t:t.source;return r=r.replace(N.caret,"$1"),n=n.replace(e,r),i},getRegex:()=>new RegExp(n,t)};return i}var O=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),N={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:M(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`)),hrRegex:M(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:M(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:M(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:M(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:M(e=>new RegExp(`^ {0,${e}}>`))},z=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,B=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,P=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,$=D(P).replace(/bull/g,B).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),q=D(P).replace(/bull/g,B).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),H=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,j=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,U=D(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",j).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),F=D(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,B).getRegex(),G="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",V=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Y=D("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",V).replace("tag",G).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),W=D(H).replace("hr",z).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",G).getRegex(),X={blockquote:D(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",W).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:U,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:z,html:Y,lheading:$,list:F,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:W,table:L,text:/^[^\n]+/},Q=D("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",z).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",G).getRegex(),Z={...X,lheading:q,table:Q,paragraph:D(H).replace("hr",z).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Q).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",G).getRegex()},K={...X,html:D("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",V).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:L,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:D(H).replace("hr",z).replace("heading"," *#{1,6} *[^\n]").replace("lheading",$).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},J=/^( {2,}|\\)\n(?!\s*$)/,ee=/[\p{P}\p{S}]/u,te=/[\s\p{P}\p{S}]/u,ne=/[^\s\p{P}\p{S}]/u,ie=D(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,te).getRegex(),re=/(?!~)[\p{P}\p{S}]/u,se=D(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",O?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),ae=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,oe=D(ae,"u").replace(/punct/g,ee).getRegex(),le=D(ae,"u").replace(/punct/g,re).getRegex(),ce="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",de=D(ce,"gu").replace(/notPunctSpace/g,ne).replace(/punctSpace/g,te).replace(/punct/g,ee).getRegex(),he=D(ce,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,re).getRegex(),pe=D("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ne).replace(/punctSpace/g,te).replace(/punct/g,ee).getRegex(),ue=D(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,ee).getRegex(),ge=D("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)","gu").replace(/notPunctSpace/g,ne).replace(/punctSpace/g,te).replace(/punct/g,ee).getRegex(),fe=D(/\\(punct)/,"gu").replace(/punct/g,ee).getRegex(),me=D(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),be=D(V).replace("(?:--\x3e|$)","--\x3e").getRegex(),xe=D("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",be).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ye=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,ke=D(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",ye).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),_e=D(/^!?\[(label)\]\[(ref)\]/).replace("label",ye).replace("ref",j).getRegex(),we=D(/^!?\[(ref)\](?:\[\])?/).replace("ref",j).getRegex(),ve=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Te={_backpedal:L,anyPunctuation:fe,autolink:me,blockSkip:se,br:J,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:L,delLDelim:L,delRDelim:L,emStrongLDelim:oe,emStrongRDelimAst:de,emStrongRDelimUnd:pe,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:ke,nolink:we,punctuation:ie,reflink:_e,reflinkSearch:D("reflink|nolink(?!\\()","g").replace("reflink",_e).replace("nolink",we).getRegex(),tag:xe,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:L},Ee={...Te,link:D(/^!?\[(label)\]\((.*?)\)/).replace("label",ye).getRegex(),reflink:D(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ye).getRegex()},Se={...Te,emStrongRDelimAst:he,emStrongLDelim:le,delLDelim:ue,delRDelim:ge,url:D(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ve).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:D(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",ve).getRegex()},Ie={...Se,br:D(J).replace("{2,}","*").getRegex(),text:D(Se.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Re={normal:X,gfm:Z,pedantic:K},Ae={normal:Te,gfm:Se,breaks:Ie,pedantic:Ee},Ce={"&":"&","<":"<",">":">",'"':""","'":"'"},Le=e=>Ce[e];function Me(e,t){if(t){if(N.escapeTest.test(e))return e.replace(N.escapeReplace,Le)}else if(N.escapeTestNoEncode.test(e))return e.replace(N.escapeReplaceNoEncode,Le);return e}function De(e){try{e=encodeURI(e).replace(N.percentDecode,"%")}catch{return null}return e}function Oe(e,t){let n=e.replace(N.findPipe,(e,t,n)=>{let i=!1,r=t;for(;--r>=0&&"\\"===n[r];)i=!i;return i?"|":" |"}).split(N.splitPipe),i=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;i<n.length;i++)n[i]=n[i].trim().replace(N.slashPipe,"|");return n}function Ne(e,t,n){let i=e.length;if(0===i)return"";let r=0;for(;r<i;){if(e.charAt(i-r-1)!==t)break;r++}return e.slice(0,i-r)}function ze(e){let t=e.split("\n"),n=t.length-1;for(;n>=0&&N.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join("\n")}function Be(e,t=0){let n=t,i="";for(let t of e)if("\t"===t){let e=4-n%4;i+=" ".repeat(e),n+=e}else i+=t,n++;return i}function Pe(e,t,n,i,r){let s=t.href,a=t.title||null,o=e[1].replace(r.other.outputLinkReplace,"$1");i.state.inLink=!0;let l={type:"!"===e[0].charAt(0)?"image":"link",raw:n,href:s,title:a,text:o,tokens:i.inlineTokens(o)};return i.state.inLink=!1,l}var $e=class{options;rules;lexer;constructor(e){this.options=e||A}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=this.options.pedantic?t[0]:ze(t[0]),n=e.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e,codeBlockStyle:"indented",text:n}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=function(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(null===i)return t;let r=i[1];return t.split("\n").map(e=>{let t=e.match(n.other.beginningSpace);if(null===t)return e;let[i]=t;return i.length>=r.length?e.slice(r.length):e}).join("\n")}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=Ne(e,"#");(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:"heading",raw:Ne(t[0],"\n"),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Ne(t[0],"\n")}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=Ne(t[0],"\n").split("\n"),n="",i="",r=[];for(;e.length>0;){let t,s=!1,a=[];for(t=0;t<e.length;t++)if(this.rules.other.blockquoteStart.test(e[t]))a.push(e[t]),s=!0;else{if(s)break;a.push(e[t])}e=e.slice(t);let o=a.join("\n"),l=o.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}\n${o}`:o,i=i?`${i}\n${l}`:l;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(l,r,!0),this.lexer.state.top=c,0===e.length)break;let d=r.at(-1);if("code"===d?.type)break;if("blockquote"===d?.type){let t=d,s=t.raw+"\n"+e.join("\n"),a=this.blockquote(s);r[r.length-1]=a,n=n.substring(0,n.length-t.raw.length)+a.raw,i=i.substring(0,i.length-t.text.length)+a.text;break}if("list"===d?.type){let t=d,s=t.raw+"\n"+e.join("\n"),a=this.list(s);r[r.length-1]=a,n=n.substring(0,n.length-d.raw.length)+a.raw,i=i.substring(0,i.length-t.raw.length)+a.raw,e=s.substring(r.at(-1).raw.length).split("\n");continue}}return{type:"blockquote",raw:n,tokens:r,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),i=n.length>1,r={type:"list",raw:"",ordered:i,start:i?+n.slice(0,-1):"",loose:!1,items:[]};n=i?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=i?n:"[*+-]");let s=this.rules.other.listItemRegex(n),a=!1;for(;e;){let n=!1,i="",o="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;i=t[0],e=e.substring(i.length);let l=Be(t[2].split("\n",1)[0],t[1].length),c=e.split("\n",1)[0],d=!l.trim(),h=0;if(this.options.pedantic?(h=2,o=l.trimStart()):d?h=t[1].length+1:(h=l.search(this.rules.other.nonSpaceChar),h=h>4?1:h,o=l.slice(h),h+=t[1].length),d&&this.rules.other.blankLine.test(c)&&(i+=c+"\n",e=e.substring(c.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(h),n=this.rules.other.hrRegex(h),r=this.rules.other.fencesBeginRegex(h),s=this.rules.other.headingBeginRegex(h),a=this.rules.other.htmlBeginRegex(h),p=this.rules.other.blockquoteBeginRegex(h);for(;e;){let u,g=e.split("\n",1)[0];if(c=g,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting," "),u=c):u=c.replace(this.rules.other.tabCharGlobal," "),r.test(c)||s.test(c)||a.test(c)||p.test(c)||t.test(c)||n.test(c))break;if(u.search(this.rules.other.nonSpaceChar)>=h||!c.trim())o+="\n"+u.slice(h);else{if(d||l.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||r.test(l)||s.test(l)||n.test(l))break;o+="\n"+c}d=!c.trim(),i+=g+"\n",e=e.substring(g.length+1),l=u.slice(h)}}r.loose||(a?r.loose=!0:this.rules.other.doubleBlankLine.test(i)&&(a=!0)),r.items.push({type:"list_item",raw:i,task:!!this.options.gfm&&this.rules.other.listIsTask.test(o),loose:!1,text:o,tokens:[]}),r.raw+=i}let o=r.items.at(-1);if(!o)return;o.raw=o.raw.trimEnd(),o.text=o.text.trimEnd(),r.raw=r.raw.trimEnd();for(let e of r.items){this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]);let t=e.tokens[0];if(!e.task||"text"!==t?.type&&"paragraph"!==t?.type)e.task&&(e.task=!1);else{e.text=e.text.replace(this.rules.other.listReplaceTask,""),t.raw=t.raw.replace(this.rules.other.listReplaceTask,""),t.text=t.text.replace(this.rules.other.listReplaceTask,"");for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,"");break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:"checkbox",raw:n[0]+" ",checked:"[ ]"!==n[0]};e.checked=t.checked,r.loose?e.tokens[0]&&["paragraph","text"].includes(e.tokens[0].type)&&"tokens"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:"paragraph",raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}if(!r.loose){let t=e.tokens.filter(e=>"space"===e.type),n=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw));r.loose=n}}if(r.loose)for(let e of r.items){e.loose=!0;for(let t of e.tokens)"text"===t.type&&(t.type="paragraph")}return r}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=ze(t[0]);return{type:"html",block:!0,raw:e,pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:Ne(t[0],"\n"),href:n,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Oe(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],s={type:"table",raw:Ne(t[0],"\n"),header:[],align:[],rows:[]};if(n.length===i.length){for(let e of i)this.rules.other.tableAlignRight.test(e)?s.align.push("right"):this.rules.other.tableAlignCenter.test(e)?s.align.push("center"):this.rules.other.tableAlignLeft.test(e)?s.align.push("left"):s.align.push(null);for(let e=0;e<n.length;e++)s.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:s.align[e]});for(let e of r)s.rows.push(Oe(e,s.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:s.align[t]})));return s}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:"heading",raw:Ne(t[0],"\n"),depth:"="===t[2].charAt(0)?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=Ne(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{let e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let i=0;i<e.length;i++)if("\\"===e[i])i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return n>0?-2:-1}(t[2],"()");if(-2===e)return;if(e>-1){let n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],i="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],i=e[3])}else i=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),Pe(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return Pe(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(i&&(i[1]||i[2]||i[3]||i[4])&&(!i[4]||!n.match(this.rules.other.unicodeAlphaNumeric))&&(!i[1]&&!i[3]||!n||this.rules.inline.punctuation.exec(n))){let n,r,s=[...i[0]].length-1,a=s,o=0,l="*"===i[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+s);null!==(i=l.exec(t));){if(n=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!n)continue;if(r=[...n].length,i[3]||i[4]){a+=r;continue}if((i[5]||i[6])&&s%3&&!((s+r)%3)){o+=r;continue}if(a-=r,a>0)continue;r=Math.min(r,r+a+o);let t=[...i[0]][0].length,l=e.slice(0,s+i.index+t+r);if(Math.min(s,r)%2){let e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}let c=l.slice(2,-2);return{type:"strong",raw:l,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(e),i=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&i&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let i=this.rules.inline.delLDelim.exec(e);if(i&&(!i[1]||!n||this.rules.inline.punctuation.exec(n))){let n,r,s=[...i[0]].length-1,a=s,o=this.rules.inline.delRDelim;for(o.lastIndex=0,t=t.slice(-1*e.length+s);null!==(i=o.exec(t));){if(n=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!n||(r=[...n].length,r!==s))continue;if(i[3]||i[4]){a+=r;continue}if(a-=r,a>0)continue;r=Math.min(r,r+a);let t=[...i[0]][0].length,o=e.slice(0,s+i.index+t+r),l=o.slice(s,-s);return{type:"del",raw:o,text:l,tokens:this.lexer.inlineTokens(l)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=t[1],n="mailto:"+e):(e=t[1],n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if("@"===t[2])e=t[0],n="mailto:"+e;else{let i;do{i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(i!==t[0]);e=t[0],n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},qe=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||A,this.options.tokenizer=this.options.tokenizer||new $e,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:N,block:Re.normal,inline:Ae.normal};this.options.pedantic?(t.block=Re.pedantic,t.inline=Ae.pedantic):this.options.gfm&&(t.block=Re.gfm,this.options.breaks?t.inline=Ae.breaks:t.inline=Ae.gfm),this.tokenizer.rules=t}static get rules(){return{block:Re,inline:Ae}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(N.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(N.tabCharGlobal," ").replace(N.spaceLine,""));let i=1/0;for(;e;){if(!(e.length<i)){this.infiniteLoopError(e.charCodeAt(0));break}let r;if(i=e.length,this.options.extensions?.block?.some(n=>!!(r=n.call({lexer:this},e,t))&&(e=e.substring(r.raw.length),t.push(r),!0)))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);1===r.raw.length&&void 0!==n?n.raw+="\n":t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.text,this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let s=e;if(this.options.extensions?.startBlock){let t,n=1/0,i=e.slice(1);this.options.extensions.startBlock.forEach(e=>{t=e.call({lexer:this},i),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(s=e.substring(0,n+1))}if(this.state.top&&(r=this.tokenizer.paragraph(s))){let i=t.at(-1);n&&"paragraph"===i?.type?(i.raw+=(i.raw.endsWith("\n")?"":"\n")+r.raw,i.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):t.push(r),n=s.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n,i=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;null!==(r=this.tokenizer.rules.inline.reflinkSearch.exec(i));)e.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!==(r=this.tokenizer.rules.inline.anyPunctuation.exec(i));)i=i.slice(0,r.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!==(r=this.tokenizer.rules.inline.blockSkip.exec(i));)n=r[2]?r[2].length:0,i=i.slice(0,r.index+n)+"["+"a".repeat(r[0].length-n-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=this.options.hooks?.emStrongMask?.call({lexer:this},i)??i;let s=!1,a="",o=1/0;for(;e;){if(!(e.length<o)){this.infiniteLoopError(e.charCodeAt(0));break}let n;if(o=e.length,s||(a=""),s=!1,this.options.extensions?.inline?.some(i=>!!(n=i.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))continue;if(n=this.tokenizer.escape(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.tag(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.link(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(n.raw.length);let i=t.at(-1);"text"===n.type&&"text"===i?.type?(i.raw+=n.raw,i.text+=n.text):t.push(n);continue}if(n=this.tokenizer.emStrong(e,i,a)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.codespan(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.br(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.del(e,i,a)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.autolink(e)){e=e.substring(n.raw.length),t.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(e))){e=e.substring(n.raw.length),t.push(n);continue}let r=e;if(this.options.extensions?.startInline){let t,n=1/0,i=e.slice(1);this.options.extensions.startInline.forEach(e=>{t=e.call({lexer:this},i),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(r=e.substring(0,n+1))}if(n=this.tokenizer.inlineText(r)){e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(a=n.raw.slice(-1)),s=!0;let i=t.at(-1);"text"===i?.type?(i.raw+=n.raw,i.text+=n.text):t.push(n);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t="Infinite loop on byte: "+e;if(!this.options.silent)throw new Error(t);console.error(t)}},He=class{options;parser;constructor(e){this.options=e||A}space(e){return""}code({text:e,lang:t,escaped:n}){let i=(t||"").match(N.notSpaceStart)?.[0],r=e.replace(N.endingNewline,"")+"\n";return i?'<pre><code class="language-'+Me(i)+'">'+(n?r:Me(r,!0))+"</code></pre>\n":"<pre><code>"+(n?r:Me(r,!0))+"</code></pre>\n"}blockquote({tokens:e}){return`<blockquote>\n${this.parser.parse(e)}</blockquote>\n`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>\n`}hr(e){return"<hr>\n"}list(e){let t=e.ordered,n=e.start,i="";for(let t=0;t<e.items.length;t++){let n=e.items[t];i+=this.listitem(n)}let r=t?"ol":"ul";return"<"+r+(t&&1!==n?' start="'+n+'"':"")+">\n"+i+"</"+r+">\n"}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>\n`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\n`}table(e){let t="",n="";for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let i="";for(let t=0;t<e.rows.length;t++){let r=e.rows[t];n="";for(let e=0;e<r.length;e++)n+=this.tablecell(r[e]);i+=this.tablerow({text:n})}return i&&(i=`<tbody>${i}</tbody>`),"<table>\n<thead>\n"+t+"</thead>\n"+i+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Me(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let i=this.parser.parseInline(n),r=De(e);if(null===r)return i;let s='<a href="'+(e=r)+'"';return t&&(s+=' title="'+Me(t)+'"'),s+=">"+i+"</a>",s}image({href:e,title:t,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let r=De(e);if(null===r)return Me(n);let s=`<img src="${e=r}" alt="${Me(n)}"`;return t&&(s+=` title="${Me(t)}"`),s+=">",s}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Me(e.text)}},je=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},Ue=class e{options;renderer;textRenderer;constructor(e){this.options=e||A,this.options.renderer=this.options.renderer||new He,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new je}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t="";for(let n=0;n<e.length;n++){let i=e[n];if(this.options.extensions?.renderers?.[i.type]){let e=i,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==n||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(e.type)){t+=n||"";continue}}let r=i;switch(r.type){case"space":t+=this.renderer.space(r);break;case"hr":t+=this.renderer.hr(r);break;case"heading":t+=this.renderer.heading(r);break;case"code":t+=this.renderer.code(r);break;case"table":t+=this.renderer.table(r);break;case"blockquote":t+=this.renderer.blockquote(r);break;case"list":t+=this.renderer.list(r);break;case"checkbox":t+=this.renderer.checkbox(r);break;case"html":t+=this.renderer.html(r);break;case"def":t+=this.renderer.def(r);break;case"paragraph":t+=this.renderer.paragraph(r);break;case"text":t+=this.renderer.text(r);break;default:{let e='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n="";for(let i=0;i<e.length;i++){let r=e[i];if(this.options.extensions?.renderers?.[r.type]){let e=this.options.extensions.renderers[r.type].call({parser:this},r);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){n+=e||"";continue}}let s=r;switch(s.type){case"escape":case"text":n+=t.text(s);break;case"html":n+=t.html(s);break;case"link":n+=t.link(s);break;case"image":n+=t.image(s);break;case"checkbox":n+=t.checkbox(s);break;case"strong":n+=t.strong(s);break;case"em":n+=t.em(s);break;case"codespan":n+=t.codespan(s);break;case"br":n+=t.br(s);break;case"del":n+=t.del(s);break;default:{let e='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}},Fe=class{options;block;constructor(e){this.options=e||A}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?qe.lex:qe.lexInline}provideParser(e=this.block){return e?Ue.parse:Ue.parseInline}},Ge=new class{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ue;Renderer=He;TextRenderer=je;Lexer=qe;Tokenizer=$e;Hooks=Fe;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let i of e)switch(n=n.concat(t.call(this,i)),i.type){case"table":{let e=i;for(let i of e.header)n=n.concat(this.walkTokens(i.tokens,t));for(let i of e.rows)for(let e of i)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":{let e=i;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=i;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(i=>{let r=e[i].flat(1/0);n=n.concat(this.walkTokens(r,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){let n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let i=e.renderer.apply(this,t);return!1===i&&(i=n.apply(this,t)),i}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new He(this.defaults);for(let n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;let i=n,r=e.renderer[i],s=t[i];t[i]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=s.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new $e(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;let i=n,r=e.tokenizer[i],s=t[i];t[i]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=s.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Fe;for(let n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;let i=n,r=e.hooks[i],s=t[i];Fe.passThroughHooks.has(n)?t[i]=e=>{if(this.defaults.async&&Fe.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await r.call(t,e);return s.call(t,n)})();let i=r.call(t,e);return s.call(t,i)}:t[i]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await r.apply(t,e);return!1===n&&(n=await s.apply(t,e)),n})();let n=r.apply(t,e);return!1===n&&(n=s.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,i=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(i.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return qe.lex(e,t??this.defaults)}parser(e,t){return Ue.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let i={...n},r={...this.defaults,...i},s=this.onError(!!r.silent,!!r.async);if(!0===this.defaults.async&&!1===i.async)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||null===t)return s(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=e),r.async)return(async()=>{let n=r.hooks?await r.hooks.preprocess(t):t,i=await(r.hooks?await r.hooks.provideLexer(e):e?qe.lex:qe.lexInline)(n,r),s=r.hooks?await r.hooks.processAllTokens(i):i;r.walkTokens&&await Promise.all(this.walkTokens(s,r.walkTokens));let a=await(r.hooks?await r.hooks.provideParser(e):e?Ue.parse:Ue.parseInline)(s,r);return r.hooks?await r.hooks.postprocess(a):a})().catch(s);try{r.hooks&&(t=r.hooks.preprocess(t));let n=(r.hooks?r.hooks.provideLexer(e):e?qe.lex:qe.lexInline)(t,r);r.hooks&&(n=r.hooks.processAllTokens(n)),r.walkTokens&&this.walkTokens(n,r.walkTokens);let i=(r.hooks?r.hooks.provideParser(e):e?Ue.parse:Ue.parseInline)(n,r);return r.hooks&&(i=r.hooks.postprocess(i)),i}catch(e){return s(e)}}}onError(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="<p>An error occurred:</p><pre>"+Me(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Ve(e,t){return Ge.parse(e,t)}function Ye(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function We(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,s,a,o=[],l=!0,c=!1;try{if(s=(n=n.call(e)).next,0===t);else for(;!(l=(i=s.call(n)).done)&&(o.push(i.value),o.length!==t);l=!0);}catch(e){c=!0,r=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw r}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Ye(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ye(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}Ve.options=Ve.setOptions=function(e){return Ge.setOptions(e),Ve.defaults=Ge.defaults,C(Ve.defaults),Ve},Ve.getDefaults=R,Ve.defaults=A,Ve.use=function(...e){return Ge.use(...e),Ve.defaults=Ge.defaults,C(Ve.defaults),Ve},Ve.walkTokens=function(e,t){return Ge.walkTokens(e,t)},Ve.parseInline=Ge.parseInline,Ve.Parser=Ue,Ve.parser=Ue.parse,Ve.Renderer=He,Ve.TextRenderer=je,Ve.Lexer=qe,Ve.lexer=qe.lex,Ve.Tokenizer=$e,Ve.Hooks=Fe,Ve.parse=Ve,Ve.options,Ve.setOptions,Ve.use,Ve.walkTokens,Ve.parseInline,Ue.parse,qe.lex;const Xe=Object.entries,Qe=Object.setPrototypeOf,Ze=Object.isFrozen,Ke=Object.getPrototypeOf,Je=Object.getOwnPropertyDescriptor;let et=Object.freeze,tt=Object.seal,nt=Object.create,it="undefined"!=typeof Reflect&&Reflect,rt=it.apply,st=it.construct;et||(et=function(e){return e}),tt||(tt=function(e){return e}),rt||(rt=function(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];return e.apply(t,i)}),st||(st=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return new e(...n)});const at=It(Array.prototype.forEach),ot=It(Array.prototype.lastIndexOf),lt=It(Array.prototype.pop),ct=It(Array.prototype.push),dt=It(Array.prototype.splice),ht=Array.isArray,pt=It(String.prototype.toLowerCase),ut=It(String.prototype.toString),gt=It(String.prototype.match),ft=It(String.prototype.replace),mt=It(String.prototype.indexOf),bt=It(String.prototype.trim),xt=It(Number.prototype.toString),yt=It(Boolean.prototype.toString),kt="undefined"==typeof BigInt?null:It(BigInt.prototype.toString),_t="undefined"==typeof Symbol?null:It(Symbol.prototype.toString),wt=It(Object.prototype.hasOwnProperty),vt=It(Object.prototype.toString),Tt=It(RegExp.prototype.test),Et=(St=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return st(St,t)});var St;function It(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return rt(e,t,i)}}function Rt(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:pt;if(Qe&&Qe(e,null),!ht(t))return e;let i=t.length;for(;i--;){let r=t[i];if("string"==typeof r){const e=n(r);e!==r&&(Ze(t)||(t[i]=e),r=e)}e[r]=!0}return e}function At(e){for(let t=0;t<e.length;t++){wt(e,t)||(e[t]=null)}return e}function Ct(e){const t=nt(null);for(const i of Xe(e)){var n=We(i,2);const r=n[0],s=n[1];wt(e,r)&&(ht(s)?t[r]=At(s):s&&"object"==typeof s&&s.constructor===Object?t[r]=Ct(s):t[r]=s)}return t}function Lt(e,t){for(;null!==e;){const n=Je(e,t);if(n){if(n.get)return It(n.get);if("function"==typeof n.value)return It(n.value)}e=Ke(e)}return function(){return null}}const Mt=et(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Dt=et(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ot=et(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Nt=et(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),zt=et(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Bt=et(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Pt=et(["#text"]),$t=et(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),qt=et(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Ht=et(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),jt=et(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ut=tt(/{{[\w\W]*|^[\w\W]*}}/g),Ft=tt(/<%[\w\W]*|^[\w\W]*%>/g),Gt=tt(/\${[\w\W]*/g),Vt=tt(/^data-[\-\w.\u00B7-\uFFFF]+$/),Yt=tt(/^aria-[\-\w]+$/),Wt=tt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Xt=tt(/^(?:\w+script|data):/i),Qt=tt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Zt=tt(/^html$/i),Kt=tt(/^[a-z][.\w]*(-[.\w]+)+$/i),Jt=1,en=3,tn=7,nn=8,rn=9,sn=11,an=function(){return"undefined"==typeof window?null:window};var on=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:an();const n=t=>e(t);if(n.version="3.4.8",n.removed=[],!t||!t.document||t.document.nodeType!==rn||!t.Element)return n.isSupported=!1,n;let i=t.document;const r=i,s=r.currentScript;t.DocumentFragment;const a=t.HTMLTemplateElement,o=t.Node,l=t.Element,c=t.NodeFilter,d=t.NamedNodeMap;void 0===d&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;const h=t.DOMParser,p=t.trustedTypes,u=l.prototype,g=Lt(u,"cloneNode"),f=Lt(u,"remove"),m=Lt(u,"nextSibling"),b=Lt(u,"childNodes"),x=Lt(u,"parentNode"),y=Lt(u,"shadowRoot"),k=Lt(u,"attributes"),_=o&&o.prototype?Lt(o.prototype,"nodeType"):null,w=o&&o.prototype?Lt(o.prototype,"nodeName"):null;if("function"==typeof a){const e=i.createElement("template");e.content&&e.content.ownerDocument&&(i=e.content.ownerDocument)}let v,T="",E=0;const S=function(e){if(E>0)throw Et('The configured TRUSTED_TYPES_POLICY.createHTML must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose createHTML wraps DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.');E++;try{return v.createHTML(e)}finally{E--}},I=i,R=I.implementation,A=I.createNodeIterator,C=I.createDocumentFragment,L=I.getElementsByTagName,M=r.importNode;let D={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof Xe&&"function"==typeof x&&R&&void 0!==R.createHTMLDocument;const O=Ut,N=Ft,z=Gt,B=Vt,P=Yt,$=Xt,q=Qt,H=Kt;let j=Wt,U=null;const F=Rt({},[...Mt,...Dt,...Ot,...zt,...Pt]);let G=null;const V=Rt({},[...$t,...qt,...Ht,...jt]);let Y=Object.seal(nt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),W=null,X=null;const Q=Object.seal(nt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Z=!0,K=!0,J=!1,ee=!0,te=!1,ne=!0,ie=!1,re=!1,se=!1,ae=!1,oe=!1,le=!1,ce=!0,de=!1;const he="user-content-";let pe=!0,ue=!1,ge={},fe=null;const me=Rt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let be=null;const xe=Rt({},["audio","video","img","source","image","track"]);let ye=null;const ke=Rt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),_e="http://www.w3.org/1998/Math/MathML",we="http://www.w3.org/2000/svg",ve="http://www.w3.org/1999/xhtml";let Te=ve,Ee=!1,Se=null;const Ie=Rt({},[_e,we,ve],ut);let Re=Rt({},["mi","mo","mn","ms","mtext"]),Ae=Rt({},["annotation-xml"]);const Ce=Rt({},["title","style","font","a","script"]);let Le=null;const Me=["application/xhtml+xml","text/html"];let De=null,Oe=null;const Ne=i.createElement("form"),ze=function(e){return e instanceof RegExp||e instanceof Function},Be=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(Oe&&Oe===e)return;e&&"object"==typeof e||(e={}),e=Ct(e),Le=-1===Me.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,De="application/xhtml+xml"===Le?ut:pt,U=wt(e,"ALLOWED_TAGS")&&ht(e.ALLOWED_TAGS)?Rt({},e.ALLOWED_TAGS,De):F,G=wt(e,"ALLOWED_ATTR")&&ht(e.ALLOWED_ATTR)?Rt({},e.ALLOWED_ATTR,De):V,Se=wt(e,"ALLOWED_NAMESPACES")&&ht(e.ALLOWED_NAMESPACES)?Rt({},e.ALLOWED_NAMESPACES,ut):Ie,ye=wt(e,"ADD_URI_SAFE_ATTR")&&ht(e.ADD_URI_SAFE_ATTR)?Rt(Ct(ke),e.ADD_URI_SAFE_ATTR,De):ke,be=wt(e,"ADD_DATA_URI_TAGS")&&ht(e.ADD_DATA_URI_TAGS)?Rt(Ct(xe),e.ADD_DATA_URI_TAGS,De):xe,fe=wt(e,"FORBID_CONTENTS")&&ht(e.FORBID_CONTENTS)?Rt({},e.FORBID_CONTENTS,De):me,W=wt(e,"FORBID_TAGS")&&ht(e.FORBID_TAGS)?Rt({},e.FORBID_TAGS,De):Ct({}),X=wt(e,"FORBID_ATTR")&&ht(e.FORBID_ATTR)?Rt({},e.FORBID_ATTR,De):Ct({}),ge=!!wt(e,"USE_PROFILES")&&(e.USE_PROFILES&&"object"==typeof e.USE_PROFILES?Ct(e.USE_PROFILES):e.USE_PROFILES),Z=!1!==e.ALLOW_ARIA_ATTR,K=!1!==e.ALLOW_DATA_ATTR,J=e.ALLOW_UNKNOWN_PROTOCOLS||!1,ee=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,te=e.SAFE_FOR_TEMPLATES||!1,ne=!1!==e.SAFE_FOR_XML,ie=e.WHOLE_DOCUMENT||!1,ae=e.RETURN_DOM||!1,oe=e.RETURN_DOM_FRAGMENT||!1,le=e.RETURN_TRUSTED_TYPE||!1,se=e.FORCE_BODY||!1,ce=!1!==e.SANITIZE_DOM,de=e.SANITIZE_NAMED_PROPS||!1,pe=!1!==e.KEEP_CONTENT,ue=e.IN_PLACE||!1,j=function(e){try{return Tt(e,""),!0}catch(e){return!1}}(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Wt,Te="string"==typeof e.NAMESPACE?e.NAMESPACE:ve,Re=wt(e,"MATHML_TEXT_INTEGRATION_POINTS")&&e.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof e.MATHML_TEXT_INTEGRATION_POINTS?Ct(e.MATHML_TEXT_INTEGRATION_POINTS):Rt({},["mi","mo","mn","ms","mtext"]),Ae=wt(e,"HTML_INTEGRATION_POINTS")&&e.HTML_INTEGRATION_POINTS&&"object"==typeof e.HTML_INTEGRATION_POINTS?Ct(e.HTML_INTEGRATION_POINTS):Rt({},["annotation-xml"]);const t=wt(e,"CUSTOM_ELEMENT_HANDLING")&&e.CUSTOM_ELEMENT_HANDLING&&"object"==typeof e.CUSTOM_ELEMENT_HANDLING?Ct(e.CUSTOM_ELEMENT_HANDLING):nt(null);if(Y=nt(null),wt(t,"tagNameCheck")&&ze(t.tagNameCheck)&&(Y.tagNameCheck=t.tagNameCheck),wt(t,"attributeNameCheck")&&ze(t.attributeNameCheck)&&(Y.attributeNameCheck=t.attributeNameCheck),wt(t,"allowCustomizedBuiltInElements")&&"boolean"==typeof t.allowCustomizedBuiltInElements&&(Y.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),te&&(K=!1),oe&&(ae=!0),ge&&(U=Rt({},Pt),G=nt(null),!0===ge.html&&(Rt(U,Mt),Rt(G,$t)),!0===ge.svg&&(Rt(U,Dt),Rt(G,qt),Rt(G,jt)),!0===ge.svgFilters&&(Rt(U,Ot),Rt(G,qt),Rt(G,jt)),!0===ge.mathMl&&(Rt(U,zt),Rt(G,Ht),Rt(G,jt))),Q.tagCheck=null,Q.attributeCheck=null,wt(e,"ADD_TAGS")&&("function"==typeof e.ADD_TAGS?Q.tagCheck=e.ADD_TAGS:ht(e.ADD_TAGS)&&(U===F&&(U=Ct(U)),Rt(U,e.ADD_TAGS,De))),wt(e,"ADD_ATTR")&&("function"==typeof e.ADD_ATTR?Q.attributeCheck=e.ADD_ATTR:ht(e.ADD_ATTR)&&(G===V&&(G=Ct(G)),Rt(G,e.ADD_ATTR,De))),wt(e,"ADD_URI_SAFE_ATTR")&&ht(e.ADD_URI_SAFE_ATTR)&&Rt(ye,e.ADD_URI_SAFE_ATTR,De),wt(e,"FORBID_CONTENTS")&&ht(e.FORBID_CONTENTS)&&(fe===me&&(fe=Ct(fe)),Rt(fe,e.FORBID_CONTENTS,De)),wt(e,"ADD_FORBID_CONTENTS")&&ht(e.ADD_FORBID_CONTENTS)&&(fe===me&&(fe=Ct(fe)),Rt(fe,e.ADD_FORBID_CONTENTS,De)),pe&&(U["#text"]=!0),ie&&Rt(U,["html","head","body"]),U.table&&(Rt(U,["tbody"]),delete W.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw Et('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw Et('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const t=v;v=e.TRUSTED_TYPES_POLICY;try{T=S("")}catch(e){throw v=t,e}}else void 0===v&&null!==e.TRUSTED_TYPES_POLICY&&(v=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(p,s)),v&&"string"==typeof T&&(T=S(""));(D.uponSanitizeElement.length>0||D.uponSanitizeAttribute.length>0)&&U===F&&(U=Ct(U)),D.uponSanitizeAttribute.length>0&&G===V&&(G=Ct(G)),et&&et(e),Oe=e},Pe=Rt({},[...Dt,...Ot,...Nt]),$e=Rt({},[...zt,...Bt]),qe=function(e){ct(n.removed,{element:e});try{x(e).removeChild(e)}catch(t){f(e)}},He=function(e,t){try{ct(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){ct(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(ae||oe)try{qe(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},je=function(e){let t=null,n=null;if(se)e="<remove></remove>"+e;else{const t=gt(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===Le&&Te===ve&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const r=v?S(e):e;if(Te===ve)try{t=(new h).parseFromString(r,Le)}catch(e){}if(!t||!t.documentElement){t=R.createDocument(Te,"template",null);try{t.documentElement.innerHTML=Ee?T:r}catch(e){}}const s=t.body||t.documentElement;return e&&n&&s.insertBefore(i.createTextNode(n),s.childNodes[0]||null),Te===ve?L.call(t,ie?"html":"body")[0]:ie?t.documentElement:s},Ue=function(e){return A.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Fe=function(e){var t,n;e.normalize();const i=A.call(e.ownerDocument||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let r=i.nextNode();for(;r;){let e=r.data;at([O,N,z],t=>{e=ft(e,t," ")}),r.data=e,r=i.nextNode()}const s=null!==(t=null===(n=e.querySelectorAll)||void 0===n?void 0:n.call(e,"template"))&&void 0!==t?t:[];at(Array.from(s),e=>{Ve(e.content)&&Fe(e.content)})},Ge=function(e){const t=w?w(e):null;return"string"==typeof t&&("form"===De(t)&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||e.attributes!==k(e)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes||e.nodeType!==_(e)||e.childNodes!==b(e)))},Ve=function(e){if(!_||"object"!=typeof e||null===e)return!1;try{return _(e)===sn}catch(e){return!1}},Ye=function(e){if(!_||"object"!=typeof e||null===e)return!1;try{return"number"==typeof _(e)}catch(e){return!1}};function We(e,t,i){at(e,e=>{e.call(n,t,i,Oe)})}const Qe=function(e){let t=null;if(We(D.beforeSanitizeElements,e,null),Ge(e))return qe(e),!0;const i=De(w?w(e):e.nodeName);if(We(D.uponSanitizeElement,e,{tagName:i,allowedTags:U}),ne&&e.hasChildNodes()&&!Ye(e.firstElementChild)&&Tt(/<[/\w!]/g,e.innerHTML)&&Tt(/<[/\w!]/g,e.textContent))return qe(e),!0;if(ne&&e.namespaceURI===ve&&"style"===i&&Ye(e.firstElementChild))return qe(e),!0;if(e.nodeType===tn)return qe(e),!0;if(ne&&e.nodeType===nn&&Tt(/<[/\w]/g,e.data))return qe(e),!0;if(W[i]||!(Q.tagCheck instanceof Function&&Q.tagCheck(i))&&!U[i]){if(!W[i]&&Je(i)){if(Y.tagNameCheck instanceof RegExp&&Tt(Y.tagNameCheck,i))return!1;if(Y.tagNameCheck instanceof Function&&Y.tagNameCheck(i))return!1}if(pe&&!fe[i]){const t=x(e),n=b(e);if(n&&t){for(let i=n.length-1;i>=0;--i){const r=g(n[i],!0);t.insertBefore(r,m(e))}}}return qe(e),!0}return((_?_(e):e.nodeType)!==Jt||function(e){let t=x(e);t&&t.tagName||(t={namespaceURI:Te,tagName:"template"});const n=pt(e.tagName),i=pt(t.tagName);return!!Se[e.namespaceURI]&&(e.namespaceURI===we?t.namespaceURI===ve?"svg"===n:t.namespaceURI===_e?"svg"===n&&("annotation-xml"===i||Re[i]):Boolean(Pe[n]):e.namespaceURI===_e?t.namespaceURI===ve?"math"===n:t.namespaceURI===we?"math"===n&&Ae[i]:Boolean($e[n]):e.namespaceURI===ve?!(t.namespaceURI===we&&!Ae[i])&&!(t.namespaceURI===_e&&!Re[i])&&!$e[n]&&(Ce[n]||!Pe[n]):!("application/xhtml+xml"!==Le||!Se[e.namespaceURI]))}(e))&&("noscript"!==i&&"noembed"!==i&&"noframes"!==i||!Tt(/<\/no(script|embed|frames)/i,e.innerHTML))?(te&&e.nodeType===en&&(t=e.textContent,at([O,N,z],e=>{t=ft(t,e," ")}),e.textContent!==t&&(ct(n.removed,{element:e.cloneNode()}),e.textContent=t)),We(D.afterSanitizeElements,e,null),!1):(qe(e),!0)},Ze=function(e,t,n){if(X[t])return!1;if(ce&&("id"===t||"name"===t)&&(n in i||n in Ne))return!1;const r=G[t]||Q.attributeCheck instanceof Function&&Q.attributeCheck(t,e);if(K&&!X[t]&&Tt(B,t));else if(Z&&Tt(P,t));else if(!r||X[t]){if(!(Je(e)&&(Y.tagNameCheck instanceof RegExp&&Tt(Y.tagNameCheck,e)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck(e))&&(Y.attributeNameCheck instanceof RegExp&&Tt(Y.attributeNameCheck,t)||Y.attributeNameCheck instanceof Function&&Y.attributeNameCheck(t,e))||"is"===t&&Y.allowCustomizedBuiltInElements&&(Y.tagNameCheck instanceof RegExp&&Tt(Y.tagNameCheck,n)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck(n))))return!1}else if(ye[t]);else if(Tt(j,ft(n,q,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==mt(n,"data:")||!be[e]){if(J&&!Tt($,ft(n,q,"")));else if(n)return!1}else;return!0},Ke=Rt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Je=function(e){return!Ke[pt(e)]&&Tt(H,e)},tt=function(e){We(D.beforeSanitizeAttributes,e,null);const t=e.attributes;if(!t||Ge(e))return;const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:G,forceKeepAttr:void 0};let r=t.length;for(;r--;){const s=t[r],a=s.name,o=s.namespaceURI,l=s.value,c=De(a),d=l;let h="value"===a?d:bt(d);if(i.attrName=c,i.attrValue=h,i.keepAttr=!0,i.forceKeepAttr=void 0,We(D.uponSanitizeAttribute,e,i),h=i.attrValue,!de||"id"!==c&&"name"!==c||0===mt(h,he)||(He(a,e),h=he+h),ne&&Tt(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,h)){He(a,e);continue}if("attributename"===c&>(h,"href")){He(a,e);continue}if(i.forceKeepAttr)continue;if(!i.keepAttr){He(a,e);continue}if(!ee&&Tt(/\/>/i,h)){He(a,e);continue}te&&at([O,N,z],e=>{h=ft(h,e," ")});const u=De(e.nodeName);if(Ze(u,c,h)){if(v&&"object"==typeof p&&"function"==typeof p.getAttributeType)if(o);else switch(p.getAttributeType(u,c)){case"TrustedHTML":h=S(h);break;case"TrustedScriptURL":h=v.createScriptURL(h)}if(h!==d)try{o?e.setAttributeNS(o,a,h):e.setAttribute(a,h),Ge(e)?qe(e):lt(n.removed)}catch(t){He(a,e)}}else He(a,e)}We(D.afterSanitizeAttributes,e,null)},it=function(e){let t=null;const n=Ue(e);for(We(D.beforeSanitizeShadowDOM,e,null);t=n.nextNode();){We(D.uponSanitizeShadowNode,t,null),Qe(t),tt(t),Ve(t.content)&&it(t.content);if((_?_(t):t.nodeType)===Jt){const e=y?y(t):t.shadowRoot;Ve(e)&&(rt(e),it(e))}}We(D.afterSanitizeShadowDOM,e,null)},rt=function(e){const t=_?_(e):e.nodeType;if(t===Jt){const t=y?y(e):e.shadowRoot;Ve(t)&&(rt(t),it(t))}const n=b?b(e):e.childNodes;if(!n)return;const i=[];at(n,e=>{ct(i,e)});for(const e of i)rt(e);if(t===Jt){const t=w?w(e):null;if("string"==typeof t&&"template"===De(t)){const t=e.content;Ve(t)&&rt(t)}}};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null,s=null,a=null,o=null;if(Ee=!e,Ee&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Ye(e)&&"string"!=typeof(e=function(e){switch(typeof e){case"string":return e;case"number":return xt(e);case"boolean":return yt(e);case"bigint":return kt?kt(e):"0";case"symbol":return _t?_t(e):"Symbol()";case"undefined":default:return vt(e);case"function":case"object":{if(null===e)return vt(e);const t=e,n=Lt(t,"toString");if("function"==typeof n){const e=n(t);return"string"==typeof e?e:vt(e)}return vt(e)}}}(e)))throw Et("dirty is not a string, aborting");if(!n.isSupported)return e;if(re||Be(t),n.removed=[],"string"==typeof e&&(ue=!1),ue){const t=w?w(e):e.nodeName;if("string"==typeof t){const e=De(t);if(!U[e]||W[e])throw Et("root node is forbidden and cannot be sanitized in-place")}if(Ge(e))throw Et("root node is clobbered and cannot be sanitized in-place");rt(e)}else if(Ye(e))i=je("\x3c!----\x3e"),s=i.ownerDocument.importNode(e,!0),s.nodeType===Jt&&"BODY"===s.nodeName||"HTML"===s.nodeName?i=s:i.appendChild(s),rt(s);else{if(!ae&&!te&&!ie&&-1===e.indexOf("<"))return v&&le?S(e):e;if(i=je(e),!i)return ae?null:le?T:""}i&&se&&qe(i.firstChild);const l=Ue(ue?e:i);for(;a=l.nextNode();)Qe(a),tt(a),Ve(a.content)&&it(a.content);if(ue)return te&&Fe(e),e;if(ae){if(te&&Fe(i),oe)for(o=C.call(i.ownerDocument);i.firstChild;)o.appendChild(i.firstChild);else o=i;return(G.shadowroot||G.shadowrootmode)&&(o=M.call(r,o,!0)),o}let c=ie?i.outerHTML:i.innerHTML;return ie&&U["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&Tt(Zt,i.ownerDocument.doctype.name)&&(c="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+c),te&&at([O,N,z],e=>{c=ft(c,e," ")}),v&&le?S(c):c},n.setConfig=function(){Be(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),re=!0},n.clearConfig=function(){Oe=null,re=!1},n.isValidAttribute=function(e,t,n){Oe||Be({});const i=De(e),r=De(t);return Ze(i,r,n)},n.addHook=function(e,t){"function"==typeof t&&ct(D[e],t)},n.removeHook=function(e,t){if(void 0!==t){const n=ot(D[e],t);return-1===n?void 0:dt(D[e],n,1)[0]}return lt(D[e])},n.removeHooks=function(e){D[e]=[]},n.removeAllHooks=function(){D={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}();const ln=["请求已受理","任务已受理","正在思考","正在执行","结果处理中","已进入助手运行时","任务运行时","SSE 连接已建立"],cn="96px";Ve.setOptions({breaks:!0,gfm:!0,headerIds:!1,mangle:!1});const dn={primary:"--ai-primary",primaryLight:"--ai-primary-light",primaryDark:"--ai-primary-dark",secondary:"--ai-secondary",background:"--ai-bg",backgroundGradient:"--ai-bg-gradient",text:"--ai-text",textSecondary:"--ai-text-secondary",userBubble:"--ai-user-bubble-gradient",aiBubble:"--ai-ai-bubble-bg",headerGradient:"--ai-header-gradient",border:"--ai-border",shadow:"--ai-shadow",inputBackground:"--ai-input-bg",inputBorder:"--ai-input-border",loading:"--ai-loading",success:"--ai-success",error:"--ai-error",warning:"--ai-warning"},hn={DEFAULT:{colors:{primary:"#1890ff",primaryLight:"#40a9ff",primaryDark:"#096dd9",secondary:"#722ed1",background:"#ffffff",backgroundGradient:"#f8fafc",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #1890ff, #40a9ff)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(24,144,255,0.08), rgba(114,46,209,0.08))",border:"rgba(24,144,255,0.15)",shadow:"rgba(24,144,255,0.12)",inputBackground:"#f8fafc",inputBorder:"#e2e8f0"}},DARK:{colors:{primary:"#40a9ff",primaryLight:"#69c0ff",primaryDark:"#1890ff",secondary:"#9254de",background:"#0f172a",backgroundGradient:"#1e293b",text:"#f1f5f9",textSecondary:"#94a3b8",userBubble:"linear-gradient(135deg, #1890ff, #40a9ff)",aiBubble:"#1e293b",headerGradient:"linear-gradient(90deg, rgba(64,169,255,0.15), rgba(146,84,222,0.15))",border:"rgba(64,169,255,0.3)",shadow:"rgba(0,0,0,0.3)",inputBackground:"#1e293b",inputBorder:"#334155"}},FRESH:{colors:{primary:"#52c41a",primaryLight:"#73d13d",primaryDark:"#389e0d",secondary:"#1890ff",background:"#ffffff",backgroundGradient:"#f6ffed",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #52c41a, #73d13d)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(82,196,26,0.08), rgba(24,144,255,0.08))",border:"rgba(82,196,26,0.15)",shadow:"rgba(82,196,26,0.12)",inputBackground:"#f6ffed",inputBorder:"#d9f7be"}},VIBRANT:{colors:{primary:"#fa8c16",primaryLight:"#ffa940",primaryDark:"#d46b08",secondary:"#f5222d",background:"#ffffff",backgroundGradient:"#fff7e6",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #fa8c16, #ffa940)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(250,140,22,0.08), rgba(245,34,45,0.08))",border:"rgba(250,140,22,0.15)",shadow:"rgba(250,140,22,0.12)",inputBackground:"#fff7e6",inputBorder:"#ffd591"}},ROMANTIC:{colors:{primary:"#eb2f96",primaryLight:"#fb6f92",primaryDark:"#c41d7f",secondary:"#722ed1",background:"#ffffff",backgroundGradient:"#fff0f6",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #eb2f96, #fb6f92)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(235,47,150,0.08), rgba(114,46,209,0.08))",border:"rgba(235,47,150,0.15)",shadow:"rgba(235,47,150,0.12)",inputBackground:"#fff0f6",inputBorder:"#ffadd2"}},PURPLE:{colors:{primary:"#722ed1",primaryLight:"#9254de",primaryDark:"#531dab",secondary:"#1890ff",background:"#ffffff",backgroundGradient:"#f9f0ff",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #722ed1, #9254de)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(114,46,209,0.08), rgba(24,144,255,0.08))",border:"rgba(114,46,209,0.15)",shadow:"rgba(114,46,209,0.12)",inputBackground:"#f9f0ff",inputBorder:"#d3adf7"}},OCEAN:{colors:{primary:"#0077b6",primaryLight:"#00b4d8",primaryDark:"#023e8a",secondary:"#00b4d8",background:"#ffffff",backgroundGradient:"#f0f9ff",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #0077b6, #00b4d8)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(0,119,182,0.08), rgba(0,180,216,0.08))",border:"rgba(0,119,182,0.15)",shadow:"rgba(0,119,182,0.12)",inputBackground:"#f0f9ff",inputBorder:"#bae6fd"}},TWILIGHT:{colors:{primary:"#9333ea",primaryLight:"#a855f7",primaryDark:"#7e22ce",secondary:"#ec4899",background:"#ffffff",backgroundGradient:"#faf5ff",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #9333ea, #ec4899)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(147,51,234,0.08), rgba(236,72,153,0.08))",border:"rgba(147,51,234,0.15)",shadow:"rgba(147,51,234,0.12)",inputBackground:"#faf5ff",inputBorder:"#e9d5ff"}},MINT:{colors:{primary:"#14b8a6",primaryLight:"#2dd4bf",primaryDark:"#0d9488",secondary:"#06b6d4",background:"#ffffff",backgroundGradient:"#f0fdfa",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #14b8a6, #2dd4bf)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(20,184,166,0.08), rgba(6,182,212,0.08))",border:"rgba(20,184,166,0.15)",shadow:"rgba(20,184,166,0.12)",inputBackground:"#f0fdfa",inputBorder:"#99f6e4"}},ROSE:{colors:{primary:"#e11d48",primaryLight:"#fb7185",primaryDark:"#be123c",secondary:"#f43f5e",background:"#ffffff",backgroundGradient:"#fff1f2",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #e11d48, #fb7185)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(225,29,72,0.08), rgba(244,63,94,0.08))",border:"rgba(225,29,72,0.15)",shadow:"rgba(225,29,72,0.12)",inputBackground:"#fff1f2",inputBorder:"#fecdd3"}},AURORA:{colors:{primary:"#0ea5e9",primaryLight:"#38bdf8",primaryDark:"#0284c7",secondary:"#10b981",background:"#ffffff",backgroundGradient:"#f0f9ff",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #0ea5e9, #10b981)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(14,165,233,0.08), rgba(16,185,129,0.08))",border:"rgba(14,165,233,0.15)",shadow:"rgba(14,165,233,0.12)",inputBackground:"#f0f9ff",inputBorder:"#bae6fd"}},LAVENDER:{colors:{primary:"#8b5cf6",primaryLight:"#a78bfa",primaryDark:"#7c3aed",secondary:"#c084fc",background:"#ffffff",backgroundGradient:"#faf5ff",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #8b5cf6, #c084fc)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(139,92,246,0.08), rgba(192,132,252,0.08))",border:"rgba(139,92,246,0.15)",shadow:"rgba(139,92,246,0.12)",inputBackground:"#faf5ff",inputBorder:"#ddd6fe"}},CORAL:{colors:{primary:"#f97316",primaryLight:"#fb923c",primaryDark:"#ea580c",secondary:"#f43f5e",background:"#ffffff",backgroundGradient:"#fff7ed",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #f97316, #fb923c)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(249,115,22,0.08), rgba(244,63,94,0.08))",border:"rgba(249,115,22,0.15)",shadow:"rgba(249,115,22,0.12)",inputBackground:"#fff7ed",inputBorder:"#fed7aa"}},JADE:{colors:{primary:"#059669",primaryLight:"#10b981",primaryDark:"#047857",secondary:"#34d399",background:"#ffffff",backgroundGradient:"#f0fdf4",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #059669, #10b981)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(5,150,105,0.08), rgba(52,211,153,0.08))",border:"rgba(5,150,105,0.15)",shadow:"rgba(5,150,105,0.12)",inputBackground:"#f0fdf4",inputBorder:"#bbf7d0"}},STARSKY:{colors:{primary:"#6366f1",primaryLight:"#818cf8",primaryDark:"#4f46e5",secondary:"#a855f7",background:"#0f172a",backgroundGradient:"#1e1b4b",text:"#e2e8f0",textSecondary:"#94a3b8",userBubble:"linear-gradient(135deg, #6366f1, #a855f7)",aiBubble:"#1e1b4b",headerGradient:"linear-gradient(90deg, rgba(99,102,241,0.15), rgba(168,85,247,0.15))",border:"rgba(99,102,241,0.3)",shadow:"rgba(0,0,0,0.3)",inputBackground:"#1e1b4b",inputBorder:"#312e81"}},SUNSET:{colors:{primary:"#ea580c",primaryLight:"#f97316",primaryDark:"#c2410c",secondary:"#dc2626",background:"#ffffff",backgroundGradient:"#fff8f0",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #ea580c, #dc2626)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(234,88,12,0.08), rgba(220,38,38,0.08))",border:"rgba(234,88,12,0.15)",shadow:"rgba(234,88,12,0.12)",inputBackground:"#fff8f0",inputBorder:"#fed7aa"}}};class pn extends HTMLElement{static get observedAttributes(){return["visible"]}constructor(){super(),this.attachShadow({mode:"open"}),this._messages=[],this._isLoading=!1,this._config=null,this._mockMode=!1,this._isDragging=!1,this._isExpanded=!1,this._chatClient=null,this._attachments=[],this._dragStartX=0,this._dragStartY=0,this._dialogX=0,this._dialogY=0,this._appDetail=null,this._historyVisible=!1,this._historyRecords=[],this._historyLoading=!1,this._historyLoaded=!1,this._historyPageIndex=1,this._historyHasMore=!1,this._isMobile=!1,this._streamTextEl=null,this._streamInitDone=!1,this._streamFullText="",this._streamVisibleLength=0,this._streamTypeRaf=null,this._streaming=!1,this._runtimePanelEl=null,this._runtimeEventsContainerEl=null,this._runtimeStatusEl=null,this._runtimeCountEl=null,this._themeVars={"--ai-primary":"#1890ff","--ai-primary-light":"#40a9ff","--ai-primary-dark":"#096dd9","--ai-secondary":"#722ed1","--ai-bg":"#ffffff","--ai-bg-gradient":"#f8fafc","--ai-text":"#1e293b","--ai-text-secondary":"#64748b","--ai-user-bubble-gradient":"linear-gradient(135deg, #1890ff, #40a9ff)","--ai-ai-bubble-bg":"#ffffff","--ai-header-gradient":"linear-gradient(90deg, rgba(24, 144, 255, 0.08), rgba(114, 46, 209, 0.08))","--ai-border":"rgba(24, 144, 255, 0.15)","--ai-shadow":"rgba(24, 144, 255, 0.12)","--ai-input-bg":"#f8fafc","--ai-input-border":"#e2e8f0","--ai-loading":"#64748b","--ai-success":"#52c41a","--ai-error":"#ff4d4f","--ai-warning":"#faad14","--ai-radius-dialog":"16px","--ai-radius-bubble":"18px","--ai-radius-button":"50%","--ai-radius-input":"28px","--ai-radius-small":"6px","--ai-radius-medium":"12px","--ai-font-title":"15px","--ai-font-welcome-text":"17px","--ai-font-welcome-desc":"13px","--ai-font-message":"14px","--ai-font-time":"11px","--ai-font-small":"11px","--ai-shadow-dialog":"0 0 30px rgba(24, 144, 255, 0.12), 0 8px 32px rgba(0, 0, 0, 0.1)","--ai-shadow-bubble":"0 2px 8px rgba(0, 0, 0, 0.06)","--ai-shadow-user-bubble":"0 4px 12px rgba(24, 144, 255, 0.25)","--ai-shadow-button":"0 4px 12px rgba(24, 144, 255, 0.35)"},this.render(),this.bindEvents()}connectedCallback(){this._handleOnline=()=>{const e=this.shadowRoot.querySelector(".network-tip");e&&e.remove()},this._handleOffline=()=>{if(!this.shadowRoot.querySelector(".network-tip")){const e=document.createElement("div");e.className="network-tip",e.textContent="网络连接已断开,请检查网络后重试",this._dialog?.prepend(e),setTimeout(()=>e.remove(),5e3)}},window.addEventListener("online",this._handleOnline),window.addEventListener("offline",this._handleOffline),this._detectMobile(),this._handleResize=()=>{const e=this._isMobile;this._detectMobile(),e!==this._isMobile&&this._dialog&&this._applyMobileLayout()},window.addEventListener("resize",this._handleResize),this._chatClient&&this._chatClient.startBackgroundRefresh()}disconnectedCallback(){this._handleOnline&&window.removeEventListener("online",this._handleOnline),this._handleOffline&&window.removeEventListener("offline",this._handleOffline),this._handleResize&&window.removeEventListener("resize",this._handleResize),this._chatClient&&(this._chatClient.stopBackgroundRefresh(),this._chatClient.cancelCurrentRequest())}_detectMobile(){if(void 0!==this._config?.mobileMode)return void(this._isMobile=!!this._config.mobileMode);if("undefined"!=typeof wx&&wx.getSystemInfoSync)return void(this._isMobile=!0);if("undefined"==typeof window)return void(this._isMobile=!1);const e=navigator.userAgent||"",t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(e),n=window.innerWidth<768,i="ontouchstart"in window||navigator.maxTouchPoints>0;this._isMobile=t||n&&i}_applyMobileLayout(){this._dialog&&(this._isMobile?(this._dialog.style.width="100vw",this._dialog.style.height="100vh",this._dialog.style.maxHeight="none",this._dialog.style.minHeight="0",this._dialog.style.left="0",this._dialog.style.top="0",this._dialog.style.right="auto",this._dialog.style.bottom="auto",this._dialog.style.borderRadius="0",this._dialog.classList.add("mobile-mode"),this._expandBtn&&(this._expandBtn.style.display="none")):(this._isExpanded||(this._dialog.style.width="min(420px, calc(100vw - 48px))",this._dialog.style.height="min(640px, 80vh)",this._dialog.style.maxHeight="",this._dialog.style.minHeight="",this._dialog.style.left=this._dialogX?this._dialogX+"px":"auto",this._dialog.style.right=this._dialogX?"auto":"24px",this._dialog.style.top=this._dialogY?this._dialogY+"px":cn,this._dialog.style.bottom="auto"),this._dialog.classList.remove("mobile-mode"),this._dialog.style.borderRadius="",this._expandBtn&&(this._expandBtn.style.display="")))}attributeChangedCallback(e,t,n){if("visible"===e){this.hasAttribute("visible")?this.showDialog():this.hideDialog()}}get visible(){return this.hasAttribute("visible")}set visible(e){e?this.setAttribute("visible",""):this.removeAttribute("visible")}get messages(){return this._messages}get isLoading(){return this._isLoading}get config(){return this._config}init(e={}){return this._config={apiBaseUrl:"",apiEndpoint:"/v1/app/completion",streamEndpoint:"/v1/app/completion/stream",stopEndpoint:"/v1/app/completion/stop",attachmentUploadEndpoint:"/v1/app/attachment/upload",conversationQueryEndpoint:"/v1/app/conversation/query",conversationDeleteEndpoint:"/v1/app/conversation/delete",appDetailEndpoint:"/v1/app/{appId}",appId:"",userId:"",bizType:"",token:"",refreshToken:"",tokenExpiresAt:0,tokenRefreshBufferMs:6e4,refreshTokenFn:null,onTokenRefreshed:null,onTokenExpired:null,authErrorCodes:[],title:"AI 助手",welcomeText:"Hi,我是智能助手 ~\n欢迎随时提问",welcomeDesc:"全新自动化能力上线:任务交给我,自动帮你搞定!",footerDisclaimer:"推荐和回答由 AI 生成,仅供参考",footerIdentity:"",theme:"default",enableDrag:!0,headers:{},extendInfo:{},timeout:6e4,maxRetries:3,maxLength:500,maxMessages:50,historyPageSize:20,historyDays:30,mobileMode:void 0,authFn:null,onLoad:null,onError:null,suggestions:[{label:"帮我购买一台轻量应用服务器用于部署应用",value:"帮我购买一台轻量应用服务器用于部署应用"},{label:"帮我为我的域名申请并配置SSL证书",value:"帮我为我的域名申请并配置SSL证书"}],...e},!this._config.appId&&this._config.agentAppId&&(this._config.appId=this._config.agentAppId),this._chatClient=new I(this._config),this._conversationId&&this._chatClient.setConversationId(this._conversationId),this.applyConfig(),this.loadAppDetail(),this._config?.onLoad&&this._config.onLoad(this),this.dispatchEvent(new CustomEvent("init",{detail:{config:this._config}})),this}open(){return this.visible=!0,this._config?.onOpen&&this._config.onOpen(),this.dispatchEvent(new CustomEvent("open")),this}close(){return this.visible=!1,this._isExpanded=!1,this._config?.onClose&&this._config.onClose(),this.dispatchEvent(new CustomEvent("close")),this}toggle(e){return this.visible=void 0!==e?!!e:!this.visible,this}destroy(){this._chatClient&&this._chatClient.dispose(),this.parentNode&&this.parentNode.removeChild(this)}addMessage(e){if(!e||!e.content)return this;const t={id:e.id||`msg_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,type:e.type||("user"===e.role?"user":"ai"),content:e.content,time:e.time||e.timestamp||this.formatTime(),copied:!1,errorType:e.errorType||null,...e};this._messages.push(t);const n=this._config?.maxMessages??50;return this._messages.length>n&&(this._messages=this._messages.slice(-n)),this.renderMessages({forceScroll:!0}),this}clearMessages(){return this._messages=[],this.renderMessages(),this}setLoading(e){return this._isLoading=e,this.updateLoadingUI(),this.dispatchEvent(new CustomEvent("loading-change",{detail:{loading:e}})),this}updateConfig(e){return this._config?(Object.assign(this._config,e),!this._config.appId&&this._config.agentAppId&&(this._config.appId=this._config.agentAppId),this._chatClient&&this._chatClient.updateConfig(this._config),this.loadAppDetail()):this.init(e),this.applyConfig(),this}enableMockMode(){return this._mockMode=!0,this}disableMockMode(){return this._mockMode=!1,this}showDialog(){const e=this.shadowRoot.querySelector(".ai-chat-dialog"),t=this.shadowRoot.querySelector(".float-button");e&&e.classList.add("dialog-visible"),t&&(t.style.display="none"),e&&this._applyMobileLayout()}hideDialog(){const e=this.shadowRoot.querySelector(".ai-chat-dialog"),t=this.shadowRoot.querySelector(".float-button");e&&e.classList.remove("dialog-visible"),t&&(t.style.display="flex")}render(){const e=Object.entries(this._themeVars).map(([e,t])=>`${e}:${t};`).join("\n ");this.shadowRoot.innerHTML=`\n<style>\n /* ====== CSS 变量(与Vue版DEFAULT_THEME一致) ====== */\n :host {\n ${e}\n display: block;\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n z-index: 1000;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;\n --ai-primary: #2563eb;\n --ai-primary-light: #3b82f6;\n --ai-primary-dark: #1d4ed8;\n --ai-secondary: #475569;\n --ai-bg: #ffffff;\n --ai-bg-gradient: #f8fafc;\n --ai-text: #111827;\n --ai-text-secondary: #64748b;\n --ai-border: #e5e7eb;\n --ai-shadow: rgba(15, 23, 42, 0.08);\n --ai-input-bg: #ffffff;\n --ai-input-border: #d8dee8;\n --ai-radius-dialog: 0;\n --ai-radius-bubble: 10px;\n }\n\n /* ====== 外层容器(与Vue .ai-float-container 一致) ====== */\n .ai-float-container { position: relative; }\n\n /* ====== 对话框主体(与Vue .ai-chat-dialog 完全一致) ====== */\n .ai-chat-dialog {\n position: fixed;\n top: 96px;\n right: 24px;\n bottom: auto;\n width: min(420px, calc(100vw - 48px));\n height: min(640px, 80vh);\n background: var(--ai-bg);\n border-radius: 16px;\n border: 1px solid rgba(226, 232, 240, 0.78);\n box-shadow: 0 18px 44px rgba(15, 23, 42, 0.16);\n display: flex;\n flex-direction: column;\n min-height: 0;\n overflow: hidden;\n transition: opacity 0.26s ease, transform 0.26s ease;\n backdrop-filter: none;\n opacity: 0;\n transform: translateX(18px);\n pointer-events: none;\n }\n /* 显示状态 */\n .ai-chat-dialog.dialog-visible {\n opacity: 1;\n transform: translateX(0);\n pointer-events: auto;\n }\n\n /* 外发光效果(::before 伪元素)*/\n .ai-chat-dialog::before {\n display: none;\n }\n .ai-chat-dialog:not(.expanded) { cursor: default; }\n .ai-chat-dialog.dragging { transition: none; }\n\n /* ========== 头部样式(与Vue .dialog-header 完全一致) ========== */\n .dialog-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n min-height: 54px;\n padding: 0 16px 0 20px;\n background: #ffffff;\n color: var(--ai-text);\n cursor: default;\n user-select: none;\n position: relative;\n flex-shrink: 0;\n }\n /* 底部微妙阴影分隔 */\n .dialog-header::after { display: none; }\n .ai-chat-dialog.expanded .dialog-header { cursor: default; }\n .dialog-header:active { cursor: grabbing; }\n .header-left {\n display: flex;\n align-items: center;\n min-width: 0;\n }\n .robot-icon {\n display: none;\n }\n @keyframes gentlePulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }\n .header-title {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: 15px;\n font-weight: 650;\n color: var(--ai-text);\n letter-spacing: 0;\n }\n .header-right { display: flex; align-items: center; gap: 8px; margin-left: 12px; }\n .header-icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 24px;\n font-size: 14px;\n cursor: pointer;\n color: var(--ai-text-secondary);\n transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);\n border-radius: 6px;\n background: transparent;\n border: none;\n }\n .new-chat-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 24px;\n border-radius: 6px;\n border: none;\n background: transparent;\n color: var(--ai-text-secondary);\n cursor: pointer;\n padding: 0;\n transition: color 0.18s ease, background 0.18s ease;\n }\n .new-chat-btn:hover {\n color: #111827;\n background: #f3f4f6;\n }\n .new-chat-btn svg {\n width: 20px;\n height: 20px;\n stroke: currentColor;\n }\n .history-btn svg {\n width: 19px;\n height: 19px;\n stroke: currentColor;\n }\n .header-icon svg {\n width: 20px;\n height: 20px;\n flex-shrink: 0;\n }\n .header-icon svg path { stroke: currentColor; fill: none; }\n .header-icon:hover {\n color: #111827;\n background: #f3f4f6;\n }\n\n /* ========== 主体样式(与Vue .dialog-body 完全一致) ========== */\n .dialog-body {\n flex: 1;\n flex-basis: 0;\n min-height: 0;\n overflow-y: auto;\n overscroll-behavior: contain;\n -webkit-overflow-scrolling: touch;\n padding: 18px 28px 22px;\n background: linear-gradient(180deg, #f7faff 0, #ffffff 184px);\n scrollbar-width: thin;\n scrollbar-color: transparent transparent;\n }\n .dialog-body::-webkit-scrollbar { width: 4px; }\n .dialog-body::-webkit-scrollbar-track { background: transparent; }\n .dialog-body::-webkit-scrollbar-thumb {\n background: var(--ai-border);\n border-radius: 10px;\n opacity: 0.3;\n }\n .dialog-body::-webkit-scrollbar-thumb:hover { opacity: 0.6; }\n\n /* ========== 欢迎页(与Vue .empty-state / .welcome-content 完全一致) ========== */\n .empty-state {\n height: 100%;\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n align-items: stretch;\n text-align: left;\n padding: 0 0 18px;\n }\n .welcome-content { margin-bottom: 0; width: 100%; }\n /* 欢迎页图标(与Vue一致:使用img而非emoji) */\n .welcome-icon {\n width: 52px;\n height: auto;\n margin-bottom: 12px;\n opacity: 1;\n animation: none;\n border-radius: 999px;\n box-shadow: 0 8px 26px rgba(15, 23, 42, 0.08);\n }\n @keyframes floatUp { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }\n\n /* 欢迎标题 - 渐变品牌色 */\n .welcome-text {\n white-space: pre-line;\n font-size: 24px;\n line-height: 1.32;\n margin-bottom: 10px;\n font-weight: 800;\n letter-spacing: 0;\n color: #111827;\n background: none;\n -webkit-text-fill-color: currentColor;\n }\n .welcome-desc {\n font-size: 14px;\n color: var(--ai-text-secondary);\n line-height: 1.58;\n max-width: 360px;\n margin: 0 0 20px;\n }\n\n /* 快捷建议按钮组(与Vue .quick-suggestions / .suggestion-chip 一致) */\n .quick-suggestions {\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n gap: 10px;\n margin-top: 0;\n max-width: none;\n animation: none;\n }\n @keyframes fadeInUp {\n from { opacity: 0; transform: translateY(12px); }\n to { opacity: 1; transform: translateY(0); }\n }\n .suggestion-chip {\n display: inline-flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n width: 100%;\n min-height: 40px;\n padding: 0 18px;\n border-radius: 30px;\n font-size: 12px;\n color: #1f2937;\n background: #ffffff;\n border: 1px solid #dfe5ee;\n cursor: pointer;\n transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;\n white-space: normal;\n user-select: none;\n box-sizing: border-box;\n box-shadow: 0 4px 12px rgba(15, 23, 42, 0.03);\n }\n .suggestion-chip::after {\n content: '→';\n color: #111827;\n font-size: 18px;\n line-height: 1;\n }\n .suggestion-chip:hover {\n color: #111827;\n background: #ffffff;\n border-color: #cbd5e1;\n box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);\n transform: translateY(-1px);\n }\n .suggestion-chip:active { transform: translateY(0) scale(0.97); }\n .suggestion-chip .chip-icon { font-size: 17px; opacity: 0.85; color: #f97316; }\n .suggestion-chip:hover .chip-icon { opacity: 1; }\n\n .history-view {\n height: 100%;\n display: flex;\n flex-direction: column;\n min-height: 0;\n }\n .history-head {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n margin-bottom: 14px;\n }\n .history-title {\n font-size: 15px;\n font-weight: 650;\n color: var(--ai-text);\n }\n .history-back {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n border: none;\n background: transparent;\n color: var(--ai-text-secondary);\n cursor: pointer;\n font-size: 13px;\n padding: 4px 0;\n }\n .history-back:hover { color: var(--ai-primary); }\n .history-list {\n flex: 1;\n min-height: 0;\n overflow-y: auto;\n display: flex;\n flex-direction: column;\n gap: 8px;\n }\n .history-item {\n width: 100%;\n text-align: left;\n border: 1px solid #e5e7eb;\n background: #fff;\n border-radius: 8px;\n padding: 10px 12px;\n cursor: pointer;\n transition: border-color 0.18s ease, background 0.18s ease;\n }\n .history-item:hover {\n border-color: #cbd5e1;\n background: #f8fafc;\n }\n .history-item-title {\n color: #111827;\n font-size: 13px;\n font-weight: 600;\n line-height: 1.45;\n overflow: hidden;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n }\n .history-item-preview {\n margin-top: 5px;\n color: var(--ai-text-secondary);\n font-size: 12px;\n line-height: 1.45;\n overflow: hidden;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n }\n .history-empty,\n .history-loading {\n color: var(--ai-text-secondary);\n font-size: 13px;\n line-height: 1.6;\n padding: 28px 0;\n text-align: center;\n }\n .history-load-more {\n display: block;\n width: 100%;\n margin: 10px 0 0;\n padding: 8px 0;\n border: none;\n border-radius: 8px;\n background: rgba(24, 144, 255, 0.06);\n color: var(--ai-primary, #1890ff);\n font-size: 13px;\n font-weight: 500;\n cursor: pointer;\n transition: background 0.18s ease;\n }\n .history-load-more:hover {\n background: rgba(24, 144, 255, 0.12);\n }\n\n /* ========== 消息列表(与Vue .message-list 一致) ==========*/\n .message-list {\n display: flex;\n flex-direction: column;\n gap: 9px;\n min-height: min-content;\n }\n .message-item {\n display: flex;\n gap: 0;\n max-width: 100%;\n width: 100%;\n animation: messageSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);\n }\n @keyframes messageSlideIn {\n from { opacity: 0; transform: translateY(10px) scale(0.98); }\n to { opacity: 1; transform: translateY(0) scale(1); }\n }\n .message-item.user { justify-content: flex-end; align-self: stretch; }\n .message-item.ai { justify-content: flex-start; align-self: stretch; }\n\n /* ========== 头像(与Vue .message-avatar 一致) ========== */\n .message-avatar {\n display: none;\n }\n .message-item.user .message-avatar {\n background: #eef2ff;\n color: #2563eb;\n box-shadow: none;\n }\n .message-item.ai .message-avatar {\n background: #f1f5f9;\n color: #334155;\n box-shadow: none;\n }\n .message-item.ai .message-avatar::after { display: none; }\n @keyframes avatarGlow {\n from { opacity: 0.4; }\n to { opacity: 0.85; }\n }\n\n .message-content {\n display: flex;\n flex-direction: column;\n gap: 5px;\n min-width: 0;\n }\n .message-item.ai .message-content { width: 100%; }\n .message-item.user .message-content { max-width: 86%; }\n .message-item.user .message-content { align-items: flex-end; }\n\n /* ========== 消息气泡(与Vue .message-bubble 一致) ========== */\n .message-bubble {\n padding: 12px 14px;\n border-radius: 8px;\n font-size: var(--ai-font-message);\n line-height: 1.65;\n word-wrap: break-word;\n }\n .message-item.user .message-bubble {\n background: #eff6ff;\n color: #1e3a8a;\n border: 1px solid #dbeafe;\n border-bottom-right-radius: 8px;\n box-shadow: none;\n }\n .message-item.ai .message-bubble {\n box-sizing: border-box;\n background: #ffffff;\n color: var(--ai-text);\n border: none;\n border-bottom-left-radius: 8px;\n box-shadow: none;\n width: 100%;\n padding: 12px 14px;\n }\n\n /* ========== Markdown 内容样式(marked渲染结果) ========== */\n .message-text {\n overflow-wrap: break-word;\n word-break: break-word;\n }\n .message-text p { margin: 4px 0; }\n .message-text p:first-child { margin-top: 0; }\n .message-text p:last-child { margin-bottom: 0; }\n\n /* 标题 */\n .message-text h1, .message-text h2, .message-text h3,\n .message-text h4, .message-text h5, .message-text h6 {\n margin: 12px 0 6px; font-weight: 600; line-height: 1.4;\n }\n .message-text h1 { font-size: 1.25em; }\n .message-text h2 { font-size: 1.15em; border-bottom: 1px solid var(--ai-border); padding-bottom: 4px; }\n .message-text h3 { font-size: 1.08em; }\n\n /* 行内代码 + 代码块 */\n .message-text code {\n font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', Consolas, monospace;\n font-size: 0.88em;\n background: rgba(24, 144, 255, 0.1);\n color: var(--ai-primary, #1890ff);\n padding: 2px 5px;\n border-radius: 4px;\n }\n .message-text pre {\n margin: 10px 0;\n border-radius: 8px;\n overflow-x: auto;\n background: #1e293b;\n color: #e2e8f0;\n }\n .message-text pre code {\n display: block;\n padding: 12px 14px;\n background: none;\n color: inherit;\n font-size: 0.85em;\n line-height: 1.55;\n border-radius: 0;\n }\n\n /* 列表 */\n .message-text ul, .message-text ol { margin: 8px 0; padding-left: 20px; }\n .message-text li { margin: 3px 0; }\n .message-text li::marker { color: var(--ai-primary, #1890ff); }\n\n /* 引用块 */\n .message-text blockquote {\n margin: 10px 0;\n padding: 8px 14px;\n border-left: 3px solid var(--ai-primary, #1890ff);\n background: rgba(24, 144, 255, 0.05);\n color: var(--ai-text-secondary, #64748b);\n border-radius: 0 6px 6px 0;\n }\n\n /* 表格 */\n .message-text table {\n width: 100%;\n margin: 10px 0;\n border-collapse: collapse;\n font-size: 0.93em;\n }\n .message-text th, .message-text td {\n padding: 7px 10px;\n border: 1px solid var(--ai-border, #e2e8f0);\n text-align: left;\n }\n .message-text th {\n background: rgba(24, 144, 255, 0.08);\n font-weight: 600;\n }\n\n /* 链接 */\n .message-text a {\n color: var(--ai-primary, #1890ff);\n text-decoration: none;\n transition: opacity 0.15s;\n }\n .message-text a:hover { text-decoration: underline; opacity: 0.85; }\n\n /* 分隔线 */\n .message-text hr {\n margin: 12px 0;\n border: none;\n border-top: 1px solid var(--ai-border, #e2e8f0);\n }\n\n /* 图片(限制宽度防撑破) */\n .message-text img {\n max-width: 100%;\n border-radius: 6px;\n margin: 8px 0;\n }\n\n /* 加载状态 - 三点脉冲动画(与Vue一致) */\n .message-bubble.loading {\n display: flex;\n align-items: center;\n gap: 6px;\n color: var(--ai-text-secondary);\n border: none;\n background: transparent;\n padding: 4px 0;\n min-height: 44px;\n }\n .message-bubble.loading .thinking-text {\n color: var(--ai-text-secondary);\n font-size: 13px;\n margin-right: 4px;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif;\n }\n .message-bubble.loading .typing-indicator {\n display: inline-flex;\n align-items: center;\n gap: 5px;\n }\n .message-bubble.loading .typing-dot {\n width: 7px;\n height: 7px;\n border-radius: 50%;\n background: var(--ai-primary);\n animation: typingBounce 1.4s ease-in-out infinite;\n }\n .message-bubble.loading .typing-dot:nth-child(2) { animation-delay: 0s; }\n .message-bubble.loading .typing-dot:nth-child(3) { animation-delay: 0.16s; }\n .message-bubble.loading .typing-dot:nth-child(4) { animation-delay: 0.32s; }\n @keyframes typingBounce {\n 0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }\n 30% { transform: translateY(-8px); opacity: 1; }\n }\n .message-text { margin: 0; word-break: break-word; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif; }\n\n /* ========== 操作栏(与Vue .message-actions-bar 一致) ========== */\n .message-actions-bar {\n display: flex;\n align-items: center;\n justify-content: flex-start;\n gap: 10px;\n margin-top: 8px;\n }\n .action-icons { display: flex; gap: 5px; }\n .action-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n border-radius: 9px;\n cursor: pointer;\n transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n color: var(--ai-text-secondary);\n background: transparent;\n font-size: 14px;\n border: none;\n }\n .action-icon svg {\n width: 16px;\n height: 16px;\n stroke: currentColor;\n flex-shrink: 0;\n }\n .action-icon:hover {\n color: var(--ai-primary);\n background: var(--ai-shadow);\n transform: translateY(-1px);\n }\n .action-icon:active { transform: translateY(0) scale(0.95); }\n .action-icon.copied {\n color: var(--ai-success);\n background: rgba(16, 185, 129, 0.08);\n }\n\n /* ========== 底部输入框(与Vue .dialog-footer 一致) ========== */\n .dialog-footer {\n padding: 8px 18px 14px;\n background: var(--ai-bg);\n position: relative;\n flex-shrink: 0;\n }\n /* 顶部微妙分隔线 */\n .dialog-footer::before {\n content: none;\n position: absolute;\n top: 0;\n left: 24px;\n right: 24px;\n height: 1px;\n background: linear-gradient(90deg, transparent, var(--ai-border), transparent);\n opacity: 0.4;\n }\n\n .input-container {\n position: relative;\n display: flex;\n flex-direction: column;\n width: 100%;\n background: #ffffff;\n border: 1px solid #dfe5ee;\n border-radius: 4px;\n overflow: hidden;\n padding: 0;\n min-height: 86px;\n cursor: text;\n z-index: 2;\n transition: border-color 0.18s ease, box-shadow 0.18s ease;\n box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);\n }\n .input-container:focus-within {\n border-color: var(--ai-primary);\n background: #ffffff;\n box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.07), 0 2px 8px rgba(15, 23, 42, 0.06);\n transform: none;\n }\n .input-container:has(.message-input:disabled) { opacity: 0.55; cursor: not-allowed; }\n\n .message-input {\n width: 100%;\n min-height: 44px;\n max-height: 132px;\n border: none;\n background: transparent;\n font-size: var(--ai-font-message);\n color: var(--ai-text);\n outline: none;\n padding: 10px 12px 6px;\n line-height: 1.5;\n resize: none;\n overflow-y: hidden;\n box-sizing: border-box;\n }\n .message-input::placeholder { color: #9ca3af; font-style: normal; }\n .message-input:disabled { cursor: not-allowed; }\n .attachment-input { display: none; }\n .input-tools {\n display: flex;\n align-items: center;\n justify-content: space-between;\n min-height: 36px;\n padding: 0 8px 8px 8px;\n }\n .input-tool {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n border-radius: 4px;\n border: none;\n color: #4b5563;\n font-size: 17px;\n cursor: pointer;\n }\n .input-tool svg {\n width: 18px;\n height: 18px;\n }\n .input-tool:hover {\n background: #f3f4f6;\n color: #111827;\n }\n .input-tool.has-attachment {\n color: var(--ai-primary);\n background: rgba(37, 99, 235, 0.08);\n }\n\n /* 发送按钮(与Vue .send-btn 完全一致,含光泽动画)*/\n .send-btn {\n flex-shrink: 0;\n width: 28px;\n height: 28px;\n border-radius: 50%;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n background: var(--ai-primary);\n color: #fff;\n transition: background 0.18s ease, transform 0.18s ease;\n box-shadow: none;\n overflow: hidden;\n padding: 0;\n }\n .send-btn::before { display: none; }\n .send-btn:hover:not(:disabled) {\n transform: none;\n background: var(--ai-primary);\n box-shadow: none;\n }\n .send-btn:active:not(:disabled) { transform: translateY(0) scale(0.95); }\n .send-btn:disabled {\n background: #e5e7eb;\n cursor: not-allowed;\n color: #94A3B8;\n box-shadow: none;\n }\n .send-btn:disabled::before { display: none; }\n .send-btn svg {\n width: 16px;\n height: 16px;\n position: relative;\n z-index: 1;\n filter: none;\n transform: rotate(-45deg);\n }\n .footer-note {\n display: flex;\n justify-content: space-between;\n gap: 12px;\n padding: 10px 2px 0;\n color: #b5bbc5;\n font-size: 12px;\n line-height: 1;\n }\n .footer-note-left,\n .footer-note-right {\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n }\n\n /* ========== 悬浮按钮(与Vue .float-button 一致,含彩虹边框动画) ========== */\n .float-button {\n position: fixed;\n right: 32px;\n bottom: 24px;\n width: auto;\n height: 44px;\n min-width: 104px;\n gap: 8px;\n padding: 0 16px;\n border-radius: 22px;\n background: #ffffff;\n border: 1px solid #dfe5ee;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n box-shadow: 0 6px 18px rgba(15, 23, 42, 0.1);\n transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;\n z-index: 1;\n overflow: hidden;\n }\n .float-button::before { content: 'AI 助手'; font-size: 14px; font-weight: 600; color: #111827; }\n @keyframes gradientRotate { to { transform: rotate(360deg); } }\n .float-button:hover {\n transform: translateY(-1px);\n border-color: #cbd5e1;\n box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);\n }\n .float-button:hover::before { opacity: 1; animation-play-state: initial; }\n .float-icon { width: 24px; height: auto; transition: none; border-radius: 50%; }\n .float-button:hover .float-icon { transform: none; }\n\n /* 错误提示toast */\n .error-toast {\n position: absolute;\n top: 60px;\n left: 50%;\n transform: translateX(-50%);\n background: #fef2f2;\n border: 1px solid #fecaca;\n color: #dc2626;\n padding: 8px 16px;\n border-radius: 10px;\n font-size: 13px;\n z-index: 10;\n white-space: nowrap;\n animation: fadeInOut 3s forwards;\n }\n\n /* P1-8: 网络状态离线提示条 */\n .network-tip {\n position: absolute;\n top: 0; left: 0; right: 0;\n background: #fef3c7;\n border-bottom: 1px solid #fcd34d;\n color: #92400e;\n padding: 8px 12px;\n font-size: 13px;\n text-align: center;\n z-index: 10;\n border-radius: var(--ai-radius-l) var(--ai-radius-l) 0 0;\n }\n\n @keyframes fadeInOut {\n 0% { opacity: 0; transform: translateX(-50%) translateY(-8px); }\n 10% { opacity: 1; transform: translateX(-50%) translateY(0); }\n 80% { opacity: 1; transform: translateX(-50%) translateY(0); }\n 100% { opacity: 0; transform: translateX(-50%) translateY(-8px); }\n }\n\n /* P2-17: JS驱动移动端全屏模式样式(与Vue dialogStyle isMobile分支一致) */\n .ai-chat-dialog.mobile-mode {\n position: fixed !important;\n width: 100vw !important;\n height: 100vh !important;\n left: 0 !important;\n top: 0 !important;\n right: auto !important;\n bottom: auto !important;\n border-radius: 0 !important;\n max-width: none !important;\n max-height: none !important;\n }\n .mobile-mode .dialog-header {\n min-height: calc(54px + env(safe-area-inset-top));\n padding: env(safe-area-inset-top) 14px 0 16px;\n }\n .mobile-mode .header-title { font-size: 15px; }\n .mobile-mode .header-icon { width: 34px; height: 34px; }\n .mobile-mode .new-chat-btn { width: 34px; height: 34px; }\n .mobile-mode .dialog-body { padding: 16px 14px; }\n .mobile-mode .message-item { max-width: 100%; width: 100%; }\n .mobile-mode .message-bubble { padding: 11px 15px; font-size: 14px; }\n .mobile-mode .dialog-footer { padding: 12px 14px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }\n .mobile-mode .input-container { border-radius: 4px; min-height: 86px; }\n .mobile-mode .message-input { font-size: 16px; padding: 10px 12px 6px; } /* iOS防自动缩放 */\n .mobile-mode .send-btn { width: 28px; height: 28px; }\n .mobile-mode .expand-btn { display: none !important; } /* 移动端隐藏展开按钮 */\n\n /* ========== 执行过程面板 ========== */\n .runtime-panel {\n margin-top: 8px;\n border: 1px solid rgba(24, 144, 255, 0.12);\n background: linear-gradient(180deg, rgba(248, 250, 252, 0.96), rgba(255, 255, 255, 0.96));\n border-radius: 10px;\n overflow: hidden;\n }\n .runtime-header {\n display: grid;\n grid-template-columns: auto 1fr auto auto;\n align-items: center;\n gap: 8px;\n padding: 9px 10px;\n font-size: 12px;\n color: var(--ai-text-secondary, #64748b);\n cursor: pointer;\n user-select: none;\n }\n .runtime-header:hover { color: var(--ai-primary, #1890ff); }\n .runtime-header .arrow { transition: transform 0.2s; font-size: 10px; }\n .runtime-header .arrow.expanded { transform: rotate(90deg); }\n .runtime-title {\n min-width: 0;\n display: flex;\n flex-direction: column;\n gap: 2px;\n }\n .runtime-title-main {\n color: var(--ai-text);\n font-weight: 600;\n line-height: 1.25;\n }\n .runtime-title-sub {\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n color: var(--ai-text-secondary);\n font-size: 11px;\n line-height: 1.25;\n }\n .runtime-status {\n padding: 2px 8px;\n border-radius: 999px;\n font-size: 10px;\n font-weight: 600;\n white-space: nowrap;\n }\n .runtime-status.running { background: #dbeafe; color: #1d4ed8; }\n .runtime-status.completed { background: #dcfce7; color: #166534; }\n .runtime-status.error { background: #fee2e2; color: #991b1b; }\n .runtime-count {\n min-width: 20px;\n color: var(--ai-text-secondary);\n font-size: 10px;\n text-align: right;\n }\n .runtime-progress {\n height: 2px;\n background: rgba(24, 144, 255, 0.08);\n overflow: hidden;\n }\n .runtime-progress-bar {\n height: 100%;\n width: 42%;\n background: linear-gradient(90deg, transparent, var(--ai-primary), transparent);\n animation: runtimeProgress 1.45s ease-in-out infinite;\n }\n .runtime-progress.completed .runtime-progress-bar,\n .runtime-progress.error .runtime-progress-bar {\n width: 100%;\n animation: none;\n background: currentColor;\n }\n .runtime-progress.completed { color: #22c55e; }\n .runtime-progress.error { color: #ef4444; }\n @keyframes runtimeProgress {\n 0% { transform: translateX(-120%); }\n 100% { transform: translateX(260%); }\n }\n .runtime-events {\n padding: 6px 10px 9px;\n border-top: 1px solid rgba(15, 23, 42, 0.05);\n max-height: 120px;\n overflow-y: auto;\n overscroll-behavior: contain;\n scrollbar-width: thin;\n scrollbar-color: rgba(148, 163, 184, 0.5) transparent;\n }\n .runtime-events::-webkit-scrollbar { width: 4px; }\n .runtime-events::-webkit-scrollbar-track { background: transparent; }\n .runtime-events::-webkit-scrollbar-thumb {\n background: rgba(148, 163, 184, 0.45);\n border-radius: 999px;\n }\n .runtime-event {\n display: grid;\n grid-template-columns: 14px 1fr;\n align-items: flex-start;\n gap: 7px;\n padding: 4px 0;\n font-size: 11px; color: var(--ai-text-secondary, #64748b);\n }\n .runtime-event-icon {\n width: 7px;\n height: 7px;\n border-radius: 50%;\n background: rgba(24, 144, 255, 0.42);\n margin: 6px auto 0;\n font-size: 0;\n }\n .runtime-event:last-child .runtime-event-icon {\n background: var(--ai-primary);\n box-shadow: 0 0 0 4px rgba(24, 144, 255, 0.1);\n }\n /* Spinner on the folded panel header indicating latest event is running */\n .runtime-title-running .runtime-title-spinner {\n display: inline-block;\n width: 10px;\n height: 10px;\n border: 2px solid rgba(24, 144, 255, 0.25);\n border-top-color: var(--ai-primary);\n border-radius: 50%;\n margin-right: 4px;\n vertical-align: middle;\n animation: runtimeSpinner 0.8s linear infinite;\n }\n .runtime-title-running .runtime-title-text {\n display: inline;\n }\n .runtime-title-not-running .runtime-title-spinner {\n display: none;\n }\n @keyframes runtimeSpinner {\n to { transform: rotate(360deg); }\n }\n .runtime-event-text { flex: 1; line-height: 1.5; }\n .hidden { display: none !important; }\n\n /* ========== 移动端适配(与Vue @media 一致) ========== */\n @media screen and (max-width: 768px) {\n :host { top: 0; right: 0; bottom: 0; }\n .ai-chat-dialog { border-radius: 0 !important; right: 0; top: 0; bottom: 0; width: 100vw; }\n .dialog-header { min-height: 54px; padding: 0 14px 0 16px; }\n .header-title { font-size: 15px; }\n .header-icon { width: 34px; height: 34px; }\n .new-chat-btn { width: 34px; height: 34px; }\n .dialog-body { padding: 16px 18px 16px; }\n .message-list { gap: 9px; }\n .message-item { max-width: 100%; width: 100%; }\n .message-bubble { padding: 11px 15px; font-size: 14px; }\n .welcome-icon { width: 48px; margin-bottom: 10px; }\n .welcome-text { font-size: 22px; line-height: 1.3; margin-bottom: 9px; }\n .welcome-desc { font-size: 13px; line-height: 1.55; margin-bottom: 18px; }\n .quick-suggestions { gap: 10px; margin-top: 0; }\n .suggestion-chip { min-height: 40px; padding: 0 16px; font-size: 12px; border-radius: 30px; box-sizing: border-box; }\n .dialog-footer { padding: 12px 14px 16px; }\n .input-container { border-radius: 4px; min-height: 86px; }\n .runtime-events { max-height: 94px; }\n .message-input { font-size: 16px; padding: 10px 12px 6px; min-height: 44px; }\n .send-btn { width: 28px; height: 28px; }\n .float-button { height: 42px; min-width: 96px; }\n .float-icon { width: 22px; }\n .action-icon { width: 30px; height: 30px; }\n }\n\n /* ========== 暗色主题覆盖(theme: 'dark') ========== */\n :host(.dark-theme) .ai-chat-dialog {\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);\n }\n :host(.dark-theme) .input-container {\n background: var(--ai-input-bg);\n border-color: var(--ai-input-border);\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);\n }\n :host(.dark-theme) .input-container:focus-within {\n background: var(--ai-input-bg);\n box-shadow: 0 0 0 2px rgba(110, 168, 254, 0.18), 0 4px 14px rgba(0, 0, 0, 0.24);\n }\n :host(.dark-theme) .message-input {\n background: transparent;\n color: var(--ai-text);\n }\n :host(.dark-theme) .message-input::placeholder { color: var(--ai-text-secondary); }\n :host(.dark-theme) .empty-state { background: var(--ai-bg-gradient); }\n :host(.dark-theme) .welcome-text { color: var(--ai-text); }\n :host(.dark-theme) .welcome-desc { color: var(--ai-text-secondary); }\n :host(.dark-theme) .dialog-body { background: var(--ai-bg-gradient); }\n :host(.dark-theme) pre code { background: #0d1117; color: #c9d1d9; }\n :host(.dark-theme) blockquote { background: rgba(110, 168, 254, 0.08); }\n :host(.dark-theme) th { background: rgba(110, 168, 254, 0.12); }\n :host(.dark-theme) hr { border-top-color: var(--ai-border); }\n</style>\n\n<div class="ai-float-container">\n \x3c!-- 对话框 --\x3e\n <div class="ai-chat-dialog">\n \x3c!-- 头部(含展开/关闭按钮) --\x3e\n <div class="dialog-header">\n <div class="header-left">\n <span class="header-title">${this.escapeHtml(this._config?.title||"AI 助手")}</span>\n </div>\n <div class="header-right">\n <button class="new-chat-btn history-btn" type="button" title="历史记录" aria-label="历史记录">\n <svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12a9 9 0 1 0 3-6.7"/><path d="M3 4v5h5"/><path d="M12 7v5l3 2"/></svg>\n </button>\n <button class="new-chat-btn new-session-btn" type="button" title="新会话" aria-label="新会话">\n <svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 5v14"/><path d="M5 12h14"/></svg>\n </button>\n <span class="header-icon expand-btn" title="放大" aria-label="放大">\n <svg viewBox="0 0 24 24" fill="none" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">\n <path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"/>\n </svg>\n </span>\n <span class="header-icon close-btn" title="关闭" aria-label="关闭">\n <svg viewBox="0 0 24 24" fill="none" stroke-width="2.5" stroke-linecap="round">\n <path d="M18 6L6 18"/><path d="M6 6l12 12"/>\n </svg>\n </span>\n </div>\n </div>\n\n \x3c!-- 消息区域 --\x3e\n <div class="dialog-body" id="messagesContainer"></div>\n\n \x3c!-- 输入区域 --\x3e\n <div class="dialog-footer">\n <div class="input-container" id="inputContainer">\n <textarea class="message-input" id="msgInput"\n placeholder="请输入您的问题..." autocomplete="off" rows="2"></textarea>\n <div class="input-tools">\n <button class="input-tool attach-tool" id="attachBtn" type="button" title="上传附件" aria-label="上传附件">\n <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05 12.25 20.24a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>\n </button>\n <input class="attachment-input" id="attachmentInput" type="file" multiple />\n <button class="send-btn" id="sendBtn" aria-label="发送" disabled>\n <svg viewBox="0 0 24 24" fill="currentColor"><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/></svg>\n </button>\n </div>\n </div>\n <div class="footer-note">\n <span class="footer-note-left">${this.escapeHtml(this._config?.footerDisclaimer||"")}</span>\n <span class="footer-note-right">${this.escapeHtml(this._config?.footerIdentity||"")}</span>\n </div>\n </div>\n </div>\n\n \x3c!-- 悬浮按钮 --\x3e\n <div class="float-button" id="floatBtn" title="打开AI助手">\n <img class="float-icon" src="${t}" alt="打开AI助手" />\n </div>\n</div>\n`,this._dialog=this.shadowRoot.querySelector(".ai-chat-dialog"),this._body=this.shadowRoot.querySelector("#messagesContainer"),this._input=this.shadowRoot.querySelector("#msgInput"),this._sendBtn=this.shadowRoot.querySelector("#sendBtn"),this._attachBtn=this.shadowRoot.querySelector("#attachBtn"),this._attachmentInput=this.shadowRoot.querySelector("#attachmentInput"),this._closeBtn=this.shadowRoot.querySelector(".close-btn"),this._expandBtn=this.shadowRoot.querySelector(".expand-btn"),this._newChatBtn=this.shadowRoot.querySelector(".new-session-btn"),this._historyBtn=this.shadowRoot.querySelector(".history-btn"),this._floatBtn=this.shadowRoot.querySelector("#floatBtn"),this._inputContainer=this.shadowRoot.querySelector("#inputContainer"),this.renderMessages({forceScroll:!0})}bindEvents(){requestAnimationFrame(()=>{this._closeBtn&&this._closeBtn.addEventListener("click",()=>this.close()),this._expandBtn&&this._expandBtn.addEventListener("click",()=>this.toggleExpand()),this._newChatBtn&&this._newChatBtn.addEventListener("click",()=>this.clearChat()),this._historyBtn&&this._historyBtn.addEventListener("click",()=>this.toggleHistory()),this._floatBtn&&this._floatBtn.addEventListener("click",()=>this.open()),this._sendBtn&&this._sendBtn.addEventListener("click",()=>this.handleSend()),this._attachBtn&&this._attachmentInput&&(this._attachBtn.addEventListener("click",()=>this._attachmentInput.click()),this._attachmentInput.addEventListener("change",()=>this._handleAttachmentSelect())),this._input&&(this._autoResizeInput(),this._updateSendButtonState(),this._input.addEventListener("input",()=>{this._autoResizeInput(),this._updateSendButtonState()}),this._input.addEventListener("keydown",e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),this.handleSend())})),this._dialog&&!1!==this._config?.enableDrag&&this.initDraggable()})}toggleExpand(){this._isExpanded=!this._isExpanded;const e=this._dialog;e&&(this._isMobile?this._isExpanded=!1:(this._isExpanded?(e.classList.add("expanded"),e.style.width="min(560px, calc(100vw - 48px))",e.style.height="min(640px, 80vh)",e.style.maxHeight="",e.style.minHeight="",e.style.left="auto",e.style.top=cn,e.style.right="24px",e.style.bottom="auto",this._expandBtn.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 00-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 002 2v3"/></svg>',this._expandBtn.title="缩小"):(e.classList.remove("expanded"),e.style.width="min(420px, calc(100vw - 48px))",e.style.height="min(640px, 80vh)",e.style.maxHeight="",e.style.minHeight="",e.style.left=this._dialogX?this._dialogX+"px":"auto",e.style.right=this._dialogX?"auto":"24px",e.style.top=this._dialogY?this._dialogY+"px":cn,e.style.bottom="auto",this._expandBtn.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"/></svg>',this._expandBtn.title="放大"),this.dispatchEvent(new CustomEvent("expand",{detail:this._isExpanded}))))}initDraggable(){const e=this.shadowRoot?.querySelector(".dialog-header");if(!e)return;const t=(e,t)=>{if(this._isExpanded||this._isMobile)return;this._isDragging=!0,this._dialog.classList.add("dragging");const n=this._dialog.getBoundingClientRect();this._dragStartX=e-n.left,this._dragStartY=t-n.top},n=(e,t)=>{this._isDragging&&(this._dialogX=e-this._dragStartX,this._dialogY=t-this._dragStartY,this._dialog.style.left=this._dialogX+"px",this._dialog.style.right="auto",this._dialog.style.top=this._dialogY+"px",this._dialog.style.bottom="auto")},i=()=>{this._isDragging&&(this._isDragging=!1,this._dialog.classList.remove("dragging"))};e.addEventListener("mousedown",e=>{e.target.closest("button, .header-icon")||(t(e.clientX,e.clientY),e.preventDefault())}),document.addEventListener("mousemove",e=>{n(e.clientX,e.clientY)}),document.addEventListener("mouseup",i),e.addEventListener("touchstart",e=>{if(this._isExpanded)return;if(e.target.closest("button, .header-icon"))return;const n=e.touches[0];t(n.clientX,n.clientY)},{passive:!0}),document.addEventListener("touchmove",e=>{if(!this._isDragging)return;const t=e.touches[0];n(t.clientX,t.clientY)},{passive:!0}),document.addEventListener("touchend",i)}applyConfig(){if(!this._config)return;const e=this.shadowRoot.querySelector(".header-title");e&&this._config.title&&(e.textContent=this._config.title),this._input&&this._config.placeholder&&(this._input.placeholder=this._config.placeholder),this._input&&this._config.maxLength&&(this._input.maxLength=this._config.maxLength);const t=this._config.theme,n=this.shadowRoot.host;if("string"==typeof t){if("default"!==t){this._resetThemeVars();const e=hn[t.toUpperCase()];e?(Object.entries(e.colors).forEach(([e,t])=>{const n=dn[e];n&&(this._themeVars[n]=t)}),e.borderRadius&&Object.entries(e.borderRadius).forEach(([e,t])=>{this._themeVars[`--ai-radius-${e}`]=t}),e.fontSize&&Object.entries(e.fontSize).forEach(([e,t])=>{this._themeVars[`--ai-font-${e}`]=t})):console.warn(`[AIChatDialog] Unknown theme: "${t}", using default`)}else this._resetThemeVars();n.classList.toggle("dark-theme",["dark","starsky"].includes(t.toLowerCase()))}t&&"object"==typeof t&&(this._resetThemeVars(),t.colors&&Object.entries(t.colors).forEach(([e,t])=>{t&&(this._themeVars[`--ai-${e}`]=t)}),t.borderRadius&&Object.entries(t.borderRadius).forEach(([e,t])=>{t&&(this._themeVars[`--ai-radius-${e}`]=t)}),t.fontSize&&Object.entries(t.fontSize).forEach(([e,t])=>{t&&(this._themeVars[`--ai-font-${e}`]=t)}),n.classList.remove("dark-theme")),Object.entries(this._themeVars).forEach(([e,t])=>n.style.setProperty(e,t))}async loadAppDetail(){const e=this._config?.appId||this._config?.agentAppId;if(e&&this._chatClient)try{const t=await this._chatClient.getAppDetail(e);if(!t?.success||!t.data)return;const n=t.data;this._appDetail=n;const i=this._parsePrologue(n.basicUsageTip||n.prologue||"");!n.name||this._config.title&&"AI 助手"!==this._config.title&&"AI 智能助手"!==this._config.title||(this._config.title=n.name),n.name&&(this._config.welcomeText=n.name);const r=i.text||n.description||n.prologue||"";r&&(this._config.welcomeDesc=r),i.questions.length>0&&(this._config.suggestions=i.questions.map(e=>({label:e,value:e}))),this.applyConfig(),0!==this._messages.length||this._historyVisible||this.renderMessages(),this.dispatchEvent(new CustomEvent("app-detail-loaded",{detail:n}))}catch(e){console.warn("[AIChatDialog] 应用信息加载失败:",e)}}_parsePrologue(e){const t=String(e||"").split(/\r?\n/).map(e=>e.trim()).filter(Boolean),n=[],i=[];return t.forEach(e=>{const t=e.replace(/^[-*]\s+/,"").trim();/^[-*]\s+/.test(e)?i.push(t):n.push(e)}),{text:n.join("\n"),questions:i}}renderMessages(e={}){if(!this._body)return;if(this._historyVisible)return void this.renderHistoryView();const n=!0===e.forceScroll||this._shouldAutoScroll(),i=this._body.scrollTop||0;if(0===this._messages.length){const e=this._config?.suggestions||[];let n="";e.length>0&&(n='<div class="quick-suggestions">'+e.map(e=>`<span class="suggestion-chip" data-value="${this.escapeAttr(e.value||e.label)}"><span class="chip-icon">💡</span>${this.escapeHtml(e.label)}</span>`).join("")+"</div>"),this._body.innerHTML=`\n <div class="empty-state">\n <div class="welcome-content">\n <img class="welcome-icon" src="${t}" alt="AI助手" />\n <p class="welcome-text">${this.escapeHtml(this._config?.welcomeText||"您好!我是 AI 智能助理")}</p>\n <p class="welcome-desc">${this.escapeHtml(this._config?.welcomeDesc||"我可以帮您解答系统使用问题")}</p>\n ${n}\n </div>\n </div>`,this._body.querySelectorAll(".suggestion-chip").forEach(e=>{e.addEventListener("click",()=>{const t=e.dataset.value||e.textContent.replace(/[💡\s]/g,"");this._input.value=t,this._autoResizeInput(),this.handleSend()})})}else{let e='<div class="message-list">';const t=this._messages.some(e=>"ai"===e.type&&e._runtimeEvents&&e._runtimeEvents.length>0);this._messages.forEach((n,i)=>{const r="ai"===n.type&&n._runtimeEvents&&n._runtimeEvents.length>0,s=n._isStreaming&&!n.content&&!r&&!t,a=["message-bubble",s?"loading":""].filter(Boolean).join(" ");let o="";if(s)o='<span class="thinking-text">思考中</span><span class="typing-indicator"><span class="typing-dot"></span><span class="typing-dot"></span><span class="typing-dot"></span></span>';else{const e=(n._isStreaming,n.content||"");o=n._isStreaming||e?`<div class="message-text">${"ai"===n.type?this.parseMarkdown(e):this.escapeHtml(e)}</div>`:""}e+=`<div class="message-item ${n.type}">\n <div class="message-content">\n ${r?this._buildRuntimePanel(n,i):""}\n ${o?`<div class="${a}">${o}</div>`:""}\n ${n._isStreaming?"":`<div class="message-actions-bar">\n ${"ai"===n.type?`<div class="action-icons">\n <span class="action-icon copy-btn${n.copied?" copied":""}" data-idx="${i}" title="${n.copied?"已复制":"复制"}">${n.copied?'<svg viewBox="0 0 24 24" fill="none" stroke-width="2"><path d="m20 6-11 11-5-5"/></svg>':'<svg viewBox="0 0 24 24" fill="none" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>'}</span>\n <span class="action-icon regenerate-btn" data-idx="${i}" title="重新回答"><svg viewBox="0 0 24 24" fill="none" stroke-width="2"><path d="M21 12a9 9 0 1 1-2.64-6.36"/><path d="M21 3v6h-6"/></svg></span>\n </div>`:""}\n </div>`}\n </div>\n </div>`}),this._isLoading&&!t&&(e+='<div class="message-item ai"><div class="message-content"><div class="message-bubble loading"><span class="thinking-text">思考中</span><span class="typing-indicator"><span class="typing-dot"></span><span class="typing-dot"></span><span class="typing-dot"></span></span></div></div></div>'),e+="</div>",this._body.innerHTML=e,this._body.querySelectorAll(".copy-btn").forEach(e=>{e.addEventListener("click",()=>{const t=parseInt(e.dataset.idx),n=this._messages[t];n&&this.copyMessage(n.content,t)})}),this._body.querySelectorAll(".regenerate-btn").forEach(e=>{e.addEventListener("click",()=>{const t=parseInt(e.dataset.idx);this.regenerate(t)})}),this._body.querySelectorAll(".runtime-header").forEach(e=>{e.addEventListener("click",()=>{const t=e.closest(".runtime-panel"),n=t?t.querySelector(".runtime-events"):null;n&&n.classList.toggle("hidden");const i=e.querySelector(".arrow");i&&i.classList.toggle("expanded")})})}n?this.scrollToBottom():requestAnimationFrame(()=>{this._body&&(this._body.scrollTop=i)})}renderHistoryView(){if(!this._body)return;const e=this._getFilteredHistoryRecords(),t=this._historyLoading?'<div class="history-loading">正在加载历史记录...</div>':e.length>0?`<div class="history-list">${e.map((e,t)=>this._buildHistoryItem(e,t)).join("")}</div>`+(this._historyHasMore?'<button class="history-load-more" type="button">加载更多...</button>':""):'<div class="history-empty">暂无历史记录</div>';this._body.innerHTML=`\n <div class="history-view">\n <div class="history-head">\n <div class="history-title">历史记录</div>\n <button class="history-back" type="button">返回对话</button>\n </div>\n ${t}\n </div>`;const n=this._body.querySelector(".history-back");n&&n.addEventListener("click",()=>{this._historyVisible=!1,this.renderMessages({forceScroll:!0})}),this._body.querySelectorAll(".history-item").forEach(t=>{t.addEventListener("click",()=>{const n=Number(t.dataset.idx),i=e[n];i&&this.openHistoryRecord(i)})});const i=this._body.querySelector(".history-load-more");i&&i.addEventListener("click",()=>{this.loadHistoryRecords(!0)})}_buildHistoryItem(e,t){const n=e.prompt||e.question||e.content||"未命名对话",i=e.replyText||e.answer||"";return`<button class="history-item" type="button" data-idx="${t}">\n <div class="history-item-title">${this.escapeHtml(n)}</div>\n ${i?`<div class="history-item-preview">${this.escapeHtml(i)}</div>`:""}\n </button>`}_getFilteredHistoryRecords(){const e=Array.isArray(this._historyRecords)?this._historyRecords:[],t=new Map;e.forEach(e=>{const n=e.conversationId||e.recordId||e.requestId;if(!n)return void t.set("_noKey_"+Math.random()+"_"+t.size,e);const i=t.get(n);if(i){const r=i.conversationId,s=e.conversationId;if(!r&&s)t.set(n,e);else if(r||!s){const r=i.createTime?Date.parse(String(i.createTime).replace(/-/g,"/")):0;(e.createTime?Date.parse(String(e.createTime).replace(/-/g,"/")):0)>r&&t.set(n,e)}}else t.set(n,e)});let n=Array.from(t.values());const i=Number(this._config?.historyDays||0);if(!i)return n;const r=Date.now()-24*i*60*60*1e3;return n.filter(e=>{const t=e.createTime?Date.parse(String(e.createTime).replace(/-/g,"/")):NaN;return Number.isNaN(t)||t>=r})}async toggleHistory(){this._historyVisible=!this._historyVisible,this._historyVisible?(this._historyLoaded&&this.renderHistoryView(),await this.loadHistoryRecords()):this.renderMessages()}async loadHistoryRecords(e=!1){this._chatClient||(this._chatClient=new I(this._config||{}));const t=this._config?.appId||this._config?.agentAppId;if(!t)return this.showToast("应用ID不能为空"),void(this._historyVisible=!1);this._historyLoading=!0,this.renderHistoryView();try{const n=this._config?.historyPageSize||20,i=e?(this._historyPageIndex||1)+1:1,r=Number(this._config?.historyDays||0),s={appId:t,bizType:this._config?.bizType,pageIndex:i,pageSize:n};r>0&&(s.startTime=new Date(Date.now()-24*r*60*60*1e3).toISOString());const a=await this._chatClient.queryConversation(s);if(a.success){const t=a.data?.records||[];this._historyRecords=e?(this._historyRecords||[]).concat(t):t,this._historyPageIndex=i,this._historyHasMore=t.length>=n,this._historyLoaded=!0}else this.showToast(a.message||"历史记录加载失败")}catch(t){this.showToast("历史记录加载失败"),console.error("loadHistoryRecords error",t),e||(this._historyRecords=[])}finally{this._historyLoading=!1,this.renderHistoryView()}}async openHistoryRecord(e){const t=e.conversationId;if(t)try{const e=await this._chatClient.queryConversation({conversationId:t,pageIndex:1,pageSize:50});if(e.success&&e.data?.records?.length)return this._conversationId=t,this._chatClient.setConversationId(t),this._messages=this._recordsToMessages(e.data.records),this._historyVisible=!1,void this.renderMessages({forceScroll:!0})}catch(e){}this._conversationId=t||null,t&&this._chatClient.setConversationId(t),this._messages=this._recordsToMessages([e]),this._historyVisible=!1,this.renderMessages({forceScroll:!0})}_recordsToMessages(e){return[...e].reverse().flatMap(e=>{const t=[],n=e.prompt||e.question||e.content,i=e.replyText||e.answer;return n&&t.push({id:`history_user_${e.recordId||e.requestId||this.generateId()}`,type:"user",content:n,attachments:e.attachments||[]}),i&&t.push({id:`history_ai_${e.recordId||e.requestId||this.generateId()}`,type:"ai",content:i,copied:!1,_status:"completed"}),t})}updateLoadingUI(){this.renderMessages(),this._input&&(this._input.disabled=this._isLoading||this._streaming),this._attachBtn&&(this._attachBtn.disabled=this._isLoading||this._streaming),this._updateSendButtonState()}scrollToBottom(){this._body&&requestAnimationFrame(()=>{this._body.scrollTop=this._body.scrollHeight})}_shouldAutoScroll(){if(!this._body)return!0;return this._body.scrollHeight-this._body.scrollTop-this._body.clientHeight<80}_autoResizeInput(){if(!this._input)return;this._input.style.height="auto";const e=Math.min(this._input.scrollHeight,132);this._input.style.height=`${e}px`,this._input.style.overflowY=this._input.scrollHeight>132?"auto":"hidden"}_updateSendButtonState(){if(!this._sendBtn)return;const e=!(!this._input||!this._input.value.trim()),t=this._attachments&&this._attachments.length>0;this._sendBtn.disabled=this._isLoading||!e&&!t}_handleAttachmentSelect(){this._attachmentInput&&(this._attachments=Array.from(this._attachmentInput.files||[]),this._attachBtn&&(this._attachBtn.classList.toggle("has-attachment",this._attachments.length>0),this._attachBtn.title=this._attachments.length>0?`已选择 ${this._attachments.length} 个附件`:"上传附件"),this._updateSendButtonState())}async handleSend(){const e=this._input?this._input.value.trim():"",t=[...this._attachments||[]];if(!e&&0===t.length)return void this.showToast(this._config?.emptyMessageError||"请输入消息内容");if(this._isLoading)return;const n=this._config?.maxLength??500;if(e.length>n)return void this.showToast(`输入内容不能超过${n}个字符(当前${e.length}字)`);const i=Date.now();if(this._lastSendTime&&i-this._lastSendTime<500)return;this._lastSendTime=i,this._input.value="",this._autoResizeInput(),this._attachments=[],this._attachmentInput&&(this._attachmentInput.value=""),this._attachBtn&&(this._attachBtn.classList.remove("has-attachment"),this._attachBtn.title="上传附件"),this._updateSendButtonState();const r=t.length>0?t.map(e=>`附件:${e.name}`).join("\n"):"",s=e||r,a={id:this.generateId(),type:"user",content:s,time:this.formatTime(),attachments:t.map(e=>({name:e.name,size:e.size,type:e.type}))};this._messages.push(a);const o=this._config?.maxMessages??50;this._messages.length>o&&(this._messages=this._messages.slice(-o)),this._config?.onMessageSend&&this._config.onMessageSend(a),this.dispatchEvent(new CustomEvent("message-send",{detail:a})),this.setLoading(!0);try{for(const e of t)await this.uploadAttachment(e).catch(e=>console.warn("[AIChatDialog] 附件上传失败:",e));await this.sendMessageToAI(e||r)}catch(e){console.error("[AIChatDialog] Error:",e),this.handleError(e)}finally{this.setLoading(!1)}}async sendMessageToAI(e,t={}){if(this._mockMode)await this.mockResponse(e);else{const n=t.messageId||this.generateId();t.messageId||this._messages.push({id:n,type:"ai",content:"",_isStreaming:!0,time:this.formatTime()}),this.renderMessages({forceScroll:!0}),this._streaming=!0,this.setLoading(!1),this.updateLoadingUI(),await this._directApiCallStream(n,e,t.streamOptions||{})}}async mockResponse(e){await new Promise(e=>setTimeout(e,600+800*Math.random()));const t=[`关于"${(e||"").substring(0,20)}"这个问题,我来为您详细解答...`,"这是一个很好的问题!根据我的理解:\n\n1. 首先,我们需要分析需求\n2. 其次,设计实现方案\n3. 最后,进行测试验证","收到您的问题。让我来帮您分析一下...\n\n根据您的描述,我建议您可以按照以下步骤操作:","感谢您的提问!以下是我的看法:\n\n• 第一点很关键,需要注意细节\n• 第二点值得关注\n• 第三点是核心所在"],n=t[Math.floor(Math.random()*t.length)],i=this.generateId();this._messages.push({id:i,type:"ai",content:"",_isStreaming:!0}),this.renderMessages();for(let e=0;e<n.length;e++){await new Promise(e=>setTimeout(e,12+20*Math.random()));const t=this._messages.findIndex(e=>e.id===i);t>=0&&(this._messages[t].content=n.substring(0,e+1),this.updateStreamingBubble(i,n.substring(0,e+1)))}this.finalizeStream(i),this._config?.onMessageReceived&&this._config.onMessageReceived({content:n,done:!0}),this.dispatchEvent(new CustomEvent("message-received",{detail:{content:n}}))}updateStreamingBubble(e,t){const n=this._shouldAutoScroll(),i=this._body?.querySelectorAll(".message-bubble.loading");if(i&&i.length>0){const e=i[i.length-1];e&&(e.innerHTML=`<div class="message-text">${this.parseMarkdown(t)}</div>`)}n&&this.scrollToBottom()}finalizeStream(e){const t=this._messages.findIndex(t=>t.id===e);t>=0&&delete this._messages[t]._isStreaming,this.renderMessages()}_conversationId=null;async _directApiCallStream(e,t,n={}){this._chatClient||(this._chatClient=new I(this._config||{})),Object.prototype.hasOwnProperty.call(n,"conversationId")?this._chatClient.setConversationId(n.conversationId||null):this._conversationId&&this._chatClient.setConversationId(this._conversationId);let i="";try{const r=await this._chatClient.sendMessageStream(t,{onMessage:t=>{this._isPlaceholder(t)||this._isEventLike(t)||(i+=t,this._updateMsg(e,i))},onProgress:t=>{t&&t.trim()&&!this._isPlaceholder(t)&&this._addRuntimeEvent(e,{_type:"PROGRESS",_text:t,_icon:"📋"})},onNodeStart:(t,n)=>{const i=t||"节点执行";this._addRuntimeEvent(e,{_type:"NODE_START",_text:i,_detail:n||"",_icon:"🚀"})},onNodeProgress:(t,n)=>{const i=t||"节点执行中";this._addRuntimeEvent(e,{_type:"NODE_PROGRESS",_text:i,_detail:n||"",_icon:"🔄"})},onNodeComplete:(t,n)=>{const i=t||"节点完成";this._addRuntimeEvent(e,{_type:"NODE_COMPLETE",_text:i,_detail:n||"",_icon:"✅"})},onToolStart:(t,n)=>{const i=t||"工具调用";this._addRuntimeEvent(e,{_type:"TOOL_START",_text:i,_icon:"🔧"})},onToolResult:(t,n)=>{const i=t?t+" 返回结果":"工具返回结果";this._addRuntimeEvent(e,{_type:"TOOL_RESULT",_text:i,_detail:n||"",_icon:"📦"})},onToolEnd:(t,n)=>{const i=t?t+" 执行完成":"工具执行完成";this._addRuntimeEvent(e,{_type:"TOOL_END",_text:i,_icon:"✅"})},onWarning:t=>{t&&t.trim()&&!this._isPlaceholder(t)&&this._addRuntimeEvent(e,{_type:"WARNING",_text:t,_icon:"⚠️"})},onPlanningEvent:t=>{const n=t?.message||t?.metadata?.title||t?.metadata?.detail||t?.currentTask?.name||"";if(n&&String(n).trim()&&!this._isPlaceholder(n)){const i=t?.metadata?.itemKind||t?.currentTask?.type||"";this._addRuntimeEvent(e,{_type:"PLANNING",_text:String(n),_icon:"reasoning"===i?"🧠":"📋"})}},onMeta:t=>{const n=t?.conversationId||t?.sessionId;n&&(this._conversationId=n);const i=t?.taskRunId;if(i){const t=this._messages.findIndex(t=>t.id===e);t>=0&&(this._messages[t].taskRunId=i)}},onDone:t=>{!t||this._isPlaceholder(t)||this._isEventLike(t)||(i=t,this._updateMsg(e,t))},onError:t=>{this._updateMsg(e,"错误: "+(t||"流式请求失败"))}},n);if(!r?.success)return;if(r.data?.conversationId?this._conversationId=r.data.conversationId:this._chatClient.conversationId&&(this._conversationId=this._chatClient.conversationId),!i.trim()&&this._conversationId){this._updateMsg(e,"(等待AI处理...)");const t=await this._fetchConversationResult(this._conversationId);i=t}this._finalizeMsg(e,i||"(无回复)"),this.dispatchEvent(new CustomEvent("message-received",{detail:{content:i}})),this._config?.onMessageReceived&&this._config.onMessageReceived(i)}catch(t){"AbortError"===t.name?this._updateMsg(e,"(请求超时或已取消)"):(console.error("[AIChatDialog] 流式失败:",t),this._updateMsg(e,"网络错误: "+(t.message||"请检查连接")))}}_getStreamTextEl(){if(this._streamTextEl&&this._body.contains(this._streamTextEl))return this._streamTextEl;const e=this._body?.querySelectorAll(".message-item.ai")||[];for(let t=e.length-1;t>=0;t--){const n=e[t].querySelector(".message-text");if(n)return this._streamTextEl=n,n;const i=e[t].querySelector(".message-bubble.loading");if(i){i.classList.remove("loading"),i.innerHTML="";const e=document.createElement("div");return e.className="message-text",i.appendChild(e),this._streamTextEl=e,e}}return null}_updateMsg(e,t){const n=this._messages.findIndex(t=>t.id===e);if(n<0)return;this._messages[n].content=t;const i=!!(this._messages[n]._runtimeEvents&&this._messages[n]._runtimeEvents.length>0);t.startsWith(this._streamFullText)?this._streamFullText=t:(this._streamFullText=t,this._streamVisibleLength=0);const r=this._getStreamTextEl();if(r){if(i){if(!this._streamTypeRaf){const e=()=>{const t=this._streamFullText;if(this._streamVisibleLength>=t.length)return void(this._streamTypeRaf=null);this._streamVisibleLength=Math.min(this._streamVisibleLength+1,t.length);const n=this._getStreamTextEl();n&&(n.innerHTML=this.parseMarkdown(t.slice(0,this._streamVisibleLength))),this._shouldAutoScroll()&&this.scrollToBottom(),this._streamTypeRaf=requestAnimationFrame(e)};this._streamTypeRaf=requestAnimationFrame(e)}}else r.innerHTML=this.parseMarkdown(t),this._streamFullText="",this._streamVisibleLength=0;this._shouldAutoScroll()&&this.scrollToBottom()}else this._streamInitDone||(this._streamInitDone=!0,this.renderMessages())}_finalizeMsg(e,t){this._streaming=!1,this.updateLoadingUI();const n=this._messages.findIndex(t=>t.id===e);n>=0&&(this._messages[n].content=t,delete this._messages[n]._isStreaming,this._messages[n].time=this.formatTime(),this._messages[n]._status=t&&!t.startsWith("(")?"completed":"error",this._streamTypeRaf&&(cancelAnimationFrame(this._streamTypeRaf),this._streamTypeRaf=null),this._streamTextEl=null,this._streamInitDone=!1,this._runtimePanelEl=null,this._runtimeEventsContainerEl=null,this.renderMessages())}_isPlaceholder(e){if(!e||"string"!=typeof e)return!1;const t=e.trim();return!t||ln.some(e=>t.includes(e))}_isEventLike(e){if(!e||"string"!=typeof e)return!1;const t=e.trim();if(t.startsWith("[META]")||t.startsWith("event:"))return!0;try{const e=JSON.parse(t);return e&&"object"==typeof e&&(e.eventType||e.metadata)}catch(e){}return!1}_addRuntimeEvent(e,t){const n=this._messages.findIndex(t=>t.id===e);if(n<0)return;this._messages[n]._runtimeEvents||(this._messages[n]._runtimeEvents=[]);const i=this._messages[n]._runtimeEvents[this._messages[n]._runtimeEvents.length-1];if(i&&i._text===t._text)return;if(this._messages[n]._runtimeEvents.push(t),["NODE_COMPLETE","TOOL_END","TOOL_RESULT"].includes(t._type),this._runtimeEventsContainerEl&&this._body.contains(this._runtimeEventsContainerEl)){const e=document.createElement("div");e.className="runtime-event",e.innerHTML='<span class="runtime-event-icon"></span><span class="runtime-event-text">'+this.escapeHtml(t._text)+"</span>",this._runtimeEventsContainerEl.appendChild(e);const i=this._runtimePanelEl?.querySelector(".runtime-title-sub");if(i){const e=!["NODE_COMPLETE","TOOL_END","TOOL_RESULT"].includes(t._type);i.className="runtime-title-sub "+(e?"runtime-title-running":"runtime-title-not-running"),i.innerHTML='<span class="runtime-title-spinner"></span><span class="runtime-title-text">'+this.escapeHtml(t._text)+"</span>"}const r=this._runtimePanelEl?.querySelector(".runtime-count");return r&&(r.textContent=this._messages[n]._runtimeEvents.length),void(this._shouldAutoScroll()&&this.scrollToBottom())}const r=this._findStreamingMessageContent();if(r){const e=r.querySelector(".message-bubble.loading");if(e){e.classList.remove("loading"),e.innerHTML="";const t=document.createElement("div");t.className="message-text",e.appendChild(t)}}if(r&&!r.querySelector(".runtime-panel")){const e=this._createRuntimePanelDOM(this._messages[n]);return r.insertBefore(e,r.firstChild),this._runtimePanelEl=e,this._runtimeEventsContainerEl=e.querySelector(".runtime-events"),void(this._shouldAutoScroll()&&this.scrollToBottom())}}_findStreamingMessageContent(){const e=this._body?.querySelectorAll(".message-item.ai")||[];for(let t=e.length-1;t>=0;t--){const n=e[t].querySelector(".message-content");if(n)return n}return null}_createRuntimePanelDOM(e){const t=e._runtimeEvents||[],n=e._isStreaming?"running":e._status||"running",i="completed"===n?"已完成":"error"===n?"错误":"执行中",r=t[t.length-1]?._text||"",s=t[t.length-1]||{},a=e._isStreaming&&!["NODE_COMPLETE","TOOL_END","TOOL_RESULT"].includes(s._type),o=document.createElement("div");o.className="runtime-panel";const l=document.createElement("div");l.className="runtime-header",l.onclick=function(){var e=o.querySelector(".runtime-events");e&&e.classList.toggle("hidden");var t=l.querySelector(".arrow");t&&t.classList.toggle("expanded")};var c=a?"runtime-title-sub runtime-title-running":"runtime-title-sub runtime-title-not-running";l.innerHTML='<span class="arrow">▶</span><span class="runtime-title"><span class="runtime-title-main">执行过程</span><span class="'+c+'"><span class="runtime-title-spinner"></span><span class="runtime-title-text">'+this.escapeHtml(r)+'</span></span></span><span class="runtime-status running">'+i+'</span><span class="runtime-count">'+t.length+"</span>",o.appendChild(l);const d=document.createElement("div");d.className="runtime-progress running",d.innerHTML='<div class="runtime-progress-bar"></div>',o.appendChild(d);const h=document.createElement("div");return h.className="runtime-events hidden",t.forEach(function(e){const t=document.createElement("div");t.className="runtime-event",t.innerHTML='<span class="runtime-event-icon"></span><span class="runtime-event-text">'+this.escapeHtml(e._text)+"</span>",h.appendChild(t)}.bind(this)),o.appendChild(h),o}_buildRuntimePanel(e,t){const n=e._runtimeEvents||[];if(0===n.length)return"";const i=e._isStreaming?"running":e._status||"running",r="completed"===i?"已完成":"error"===i?"错误":"执行中",s=!(!e.content||!String(e.content).trim())||"completed"===i||"error"===i,a=n[n.length-1]?._text||"";let o="";return n.forEach(function(e){o+='<div class="runtime-event"><span class="runtime-event-icon"></span><span class="runtime-event-text">'+this.escapeHtml(e._text)+"</span></div>"}.bind(this)),'<div class="runtime-panel"><div class="runtime-header"><span class="arrow'+(s?"":" expanded")+'">▶</span><span class="runtime-title"><span class="runtime-title-main">执行过程</span><span class="runtime-title-sub">'+this.escapeHtml(a)+'</span></span><span class="runtime-status '+i+'">'+r+'</span><span class="runtime-count">'+n.length+'</span></div><div class="runtime-progress '+i+'"><div class="runtime-progress-bar"></div></div><div class="runtime-events'+(s?" hidden":"")+'">'+o+"</div></div>"}async _fetchConversationResult(e){for(let t=0;t<8;t++){await new Promise(e=>setTimeout(e,1e3));try{const t=await this._chatClient.queryConversation({conversationId:e,pageIndex:1,pageSize:1});if(t.success&&t.data?.records?.length>0){const e=t.data.records[0],n=e.replyText||e.content||e.answer;if(n&&n.trim())return n}}catch(e){}}return"(AI 处理超时,请稍后查看对话记录)"}async regenerate(e){if(this._isLoading)return;const t=this._messages[e];if(!t||"ai"!==t.type)return;let n="";for(let t=e-1;t>=0;t--)if("user"===this._messages[t].type){n=this._messages[t].content;break}if(n){Object.assign(t,{content:"",_isStreaming:!0,_runtimeEvents:[],_status:"running",copied:!1,time:this.formatTime(),taskRunId:null}),this.renderMessages({forceScroll:!0}),this.setLoading(!0);try{await this.sendMessageToAI(n,{messageId:t.id,streamOptions:{conversationId:""}})}catch(e){console.error("[AIChatDialog] Regenerate error:",e),this.handleError(e)}finally{this.setLoading(!1)}}}showToast(e){const t=document.createElement("div");t.className="error-toast",t.textContent=e,this._dialog?.appendChild(t),setTimeout(()=>t.remove(),3e3)}handleError(e){let t="抱歉,网络请求失败,请稍后重试";const n=e?.message||"";n.includes("Failed to fetch")||n.includes("NetworkError")||n.includes("网络")?t="网络连接失败,请检查网络后重试":n.includes("AbortError")||n.includes("超时")||n.includes("timeout")?t="请求超时,请稍后重试":n.match(/HTTP 40[13]/)?t="请求参数有误,请检查后重新发送":n.includes("HTTP 403")||n.includes("鉴权失败")||n.includes("未授权")?t="鉴权失败,请重新登录后再试":n.includes("HTTP 404")?t="服务地址不存在,请联系管理员":n.match(/HTTP 4\d\d/)?t=`请求异常(${n}),请稍后重试`:n.includes("HTTP 500")||n.includes("Internal Server Error")?t="服务器内部错误,请稍后重试":n.includes("HTTP 502")||n.includes("HTTP 503")||n.includes("HTTP 504")?t="服务暂时不可用,请稍后重试":n.match(/HTTP 5\d\d/)?t=`服务器错误(${n}),请稍后重试`:n&&(t="抱歉,"+n),this.addMessage({type:"ai",content:t,time:this.formatTime(),errorType:"network_error"}),this._config?.onError&&this._config.onError(e),this.dispatchEvent(new CustomEvent("error",{detail:e}))}async copyContent(e){if("undefined"!=typeof wx&&wx.setClipboardData)return new Promise((t,n)=>{wx.setClipboardData({data:e,success:t,fail:()=>{try{this._fallbackCopy(e),t()}catch(e){n(e)}}})});if(navigator.clipboard&&navigator.clipboard.writeText)try{return void await navigator.clipboard.writeText(e)}catch(t){return void this._fallbackCopy(e)}this._fallbackCopy(e)}_fallbackCopy(e){const t=document.createElement("textarea");t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}async copyMessage(e,t){try{await this.copyContent(e),this._messages[t]&&(this._messages[t].copied=!0),this.renderMessages(),setTimeout(()=>{this._messages[t]&&(this._messages[t].copied=!1,this.renderMessages())},2e3)}catch(e){this.showToast("复制失败,请手动选择文本复制")}}clearChat(){this._messages=[],this._attachments=[],this._historyVisible=!1,this._attachmentInput&&(this._attachmentInput.value=""),this._attachBtn&&(this._attachBtn.classList.remove("has-attachment"),this._attachBtn.title="上传附件"),this._updateSendButtonState(),this._conversationId=null,this._chatClient&&this._chatClient.clearConversation(),this.renderMessages(),this.dispatchEvent(new CustomEvent("clear"))}async stopGeneration(){this._chatClient&&await this._chatClient.stopCompletion(),this.setLoading(!1);const e=[...this._messages].reverse().find(e=>"ai"===e.type&&e._isStreaming);e&&this._finalizeMsg(e.id,e.content||"(已停止)"),this.dispatchEvent(new CustomEvent("stop"))}async uploadAttachment(e,t={}){this._chatClient||(this._chatClient=new I(this._config||{}));const n=await this._chatClient.uploadAttachment(e,t);return n.success?this.dispatchEvent(new CustomEvent("attachment-uploaded",{detail:n.data})):this.dispatchEvent(new CustomEvent("error",{detail:n})),n}generateId(){return`msg_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}formatTime(){const e=new Date;return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`}escapeHtml(e){if(!e)return"";const t=document.createElement("div");return t.textContent=e,t.innerHTML.replace(/\n/g,"<br>")}escapeAttr(e){return e?e.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">"):""}_resetThemeVars(){Object.assign(this._themeVars,{"--ai-primary":"#1890ff","--ai-primary-light":"#40a9ff","--ai-primary-dark":"#096dd9","--ai-secondary":"#722ed1","--ai-bg":"#ffffff","--ai-bg-gradient":"#f8fafc","--ai-text":"#1e293b","--ai-text-secondary":"#64748b","--ai-user-bubble-gradient":"linear-gradient(135deg, #1890ff, #40a9ff)","--ai-ai-bubble-bg":"#ffffff","--ai-header-gradient":"linear-gradient(90deg, rgba(24, 144, 255, 0.08), rgba(114, 46, 209, 0.08))","--ai-border":"rgba(24, 144, 255, 0.15)","--ai-shadow":"rgba(24, 144, 255, 0.12)","--ai-input-bg":"#f8fafc","--ai-input-border":"#e2e8f0","--ai-loading":"#64748b","--ai-success":"#52c41a","--ai-error":"#ff4d4f","--ai-warning":"#faad14","--ai-radius-dialog":"16px","--ai-radius-bubble":"18px","--ai-radius-button":"50%","--ai-radius-input":"28px","--ai-radius-small":"6px","--ai-radius-medium":"12px","--ai-font-title":"15px","--ai-font-welcome-text":"17px","--ai-font-welcome-desc":"13px","--ai-font-message":"14px","--ai-font-time":"11px","--ai-font-small":"11px"})}parseMarkdown(e){if(!e)return"";try{const t=Ve.parse(e);return on.sanitize(t,{ALLOWED_TAGS:["p","br","strong","b","em","i","u","s","del","h1","h2","h3","h4","h5","h6","ul","ol","li","blockquote","pre","code","a","img","table","thead","tbody","tr","th","td","hr","div","span","sup","sub"],ALLOWED_ATTR:["href","target","src","alt","title","class","id"]})}catch(t){return console.warn("[AIChatDialog] Markdown解析失败,回退为纯文本:",t),this.escapeHtml(e)}}}function un(e={}){const t=document.createElement("ai-chat-dialog");return e.title&&t.setAttribute("title",e.title),e.placeholder&&t.setAttribute("placeholder",e.placeholder),e.width&&t.style.setProperty("--dialog-width",`${e.width}px`),e.height&&t.style.setProperty("--dialog-height",`${e.height}px`),document.body.appendChild(t),Object.keys(e).length>0&&t.init(e),t}function gn(e){e?e.component("AiChatWrapper",{props:{visible:{type:Boolean,default:!1},config:{type:Object,default:()=>({})}},data:()=>({dialogInstance:null}),watch:{visible:{immediate:!0,handler(e){this.$nextTick(()=>{e?this.open():this.close()})}},config:{deep:!0,handler(){this.dialogInstance&&this.dialogInstance.updateConfig(this.config)}}},mounted(){this.initDialog()},beforeDestroy(){this.dialogInstance&&this.dialogInstance.destroy()},beforeUnmount(){this.dialogInstance&&this.dialogInstance.destroy()},methods:{initDialog(){this.dialogInstance=un(this.config||{});["open","close","message-send","message-received","error"].forEach(e=>{this.dialogInstance.addEventListener(e,t=>{this.$emit(e,t.detail)})})},open(){this.dialogInstance&&this.dialogInstance.open()},close(){this.dialogInstance&&this.dialogInstance.close()}},render:e=>e("div",{style:"display: none;"})}):console.warn("[AI Web SDK] Vue instance not provided")}function fn(e={}){if("undefined"==typeof React)return console.warn("[AI Web SDK] React is not loaded, useAIChat skipped"),{open:()=>{},close:()=>{},isVisible:!1,messages:[],isLoading:!1};const{useState:t,useRef:n,useEffect:i}=React,[r,s]=t(!1),[a,o]=t([]),[l,c]=t(!1),d=n(null);return i(()=>(d.current||(d.current=un(e),d.current.addEventListener("message-send",e=>{o(t=>[...t,e.detail])}),d.current.addEventListener("message-received",e=>{o(t=>[...t,{id:Date.now(),role:"assistant",content:e.detail.content,timestamp:(new Date).toISOString()}]),c(!1)}),d.current.addEventListener("error",()=>{c(!1)})),()=>{d.current&&(d.current.destroy(),d.current=null)}),[]),{open:()=>{s(!0),d.current?.open()},close:()=>{s(!1),d.current?.close()},toggle:()=>{d.current?.toggle()},sendMessage:e=>{if(d.current){const t=d.current.shadowRoot?.querySelector(".ai-textarea");t&&(t.value=e,t.dispatchEvent(new Event("input"))),d.current.handleSend?.()||d.current.shadowRoot?.querySelector(".ai-send-btn")?.click()}},clearMessages:()=>{d.current?.clearMessages(),o([])},isVisible:r,messages:a,isLoading:l,ref:d}}customElements.get("ai-chat-dialog")||customElements.define("ai-chat-dialog",pn),"undefined"!=typeof window&&(window.AIChatDialog=pn);var mn={AIChatDialog:pn,AIChatClient:I,createAIChatDialog:un,installVuePlugin:gn,useAIChat:fn,version:"2.0.0"};"undefined"!=typeof window&&(window.AICreateChatDialog=un,window.AIWebSDK={version:"2.0.0",create:un,AIChatDialog:pn,AIChatClient:I,installVuePlugin:gn}),e.AIChatClient=I,e.AIChatClientDefault=I,e.AIChatDialog=pn,e.AIChatDialogDefault=pn,e.createAIChatDialog=un,e.default=mn,e.installVuePlugin=gn,e.useAIChat=fn,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).AIWebSDK={})}(this,function(e){"use strict";const t={AGENT_NOT_FOUND:40001,PROMPT_EMPTY:40002,AUTH_FAILED:40301,NETWORK_ERROR:500,SERVER_ERROR:50001,TIMEOUT_ERROR:50002,REQUEST_CANCELLED:0},n=new Set(["SUCCESS","000000","0","200",0,200]),i=new Set(["401","403","1005","S00001","ET0006","999990"]),s=new Set(["[START]"]),r=new Set(["[ERROR]","error"]),a=new Set(["meta"]),o=new Set(["[DONE]","done"]),l=new Set(["planning","planning_progress","plan","plan_snapshot"]),c=new Set(["message"]),d=new Set(["[THINKING]"]),h=new Set(["[PROGRESS]"]),p=new Set(["[TOOL_START]"]),u=new Set(["[TOOL_RESULT]"]),g=new Set(["[TOOL_END]"]),f=new Set(["NODE_START"]),m=new Set(["NODE_PROGRESS"]),b=new Set(["NODE_COMPLETE"]),x=new Set(["[WARNING]"]),y=new Set(["[HITL]"]),k=["请求已受理","任务已受理","正在思考","正在执行...","正在执行…","正在执行","结果处理中","已进入助手运行时","任务运行时","SSE 连接已建立"];function _(){return"req_"+Date.now().toString(36)+"_"+Math.random().toString(36).slice(2,8)}function w(e,t){return e?/^https?:\/\//i.test(t)?t:String(e||"").replace(/\/+$/,"")+"/"+String(t||"").replace(/^\/+/,""):t}function v(e){const t=String(e||"").trim();return!!t&&k.some(e=>t.includes(e))}function T(e){if(!e||"string"!=typeof e)return null;try{return JSON.parse(e)}catch(e){return null}}function E(e){const t=String(e||"").split("\n");let n="message";const i=[];for(const e of t)e.startsWith(":")||(e.startsWith("event:")?n=e.slice(6).trim():e.startsWith("data:")&&i.push(e.slice(5).replace(/^\s/,"")));return{event:n,data:i.join("\n")}}class S{constructor(e={}){this.config={apiBaseUrl:"",apiEndpoint:"/v1/app/completion",streamEndpoint:"/v1/app/completion/stream",stopEndpoint:"/v1/app/completion/stop",asyncEndpoint:"/v1/app/completion/async",attachmentUploadEndpoint:"/v1/app/attachment/upload",conversationQueryEndpoint:"/v1/app/conversation/query",conversationDeleteEndpoint:"/v1/app/conversation/delete",appDetailEndpoint:"/v1/app/{appId}",taskStatusEndpoint:"/v1/app/task/{taskId}",appListEndpoint:"/v1/app/list",runtimePermissionReplyEndpoint:"/v1/app/runtime/permission/reply",runtimeQuestionReplyEndpoint:"/v1/app/runtime/question/reply",runtimeQuestionRejectEndpoint:"/v1/app/runtime/question/reject",timeout:6e4,streamTimeout:3e5,maxRetries:3,retryDelay:1e3,enableRetry:!0,backgroundRefreshEnabled:!0,backgroundRefreshIntervalMs:3e5,...e},this.conversationId=e.conversationId||null,this.currentRequestId=null,this.abortController=null,this.refreshTokenPromise=null,this._backgroundTimer=null,this._visibilityHandler=null,this._shouldStartBackgroundRefresh()&&this.startBackgroundRefresh()}buildUrl(e){return w(this.config.apiBaseUrl||"",e)}buildHeaders(e={}){const t={...e};return this.config.token&&!t.Authorization&&(t.Authorization=/^Bearer\s+/i.test(this.config.token)?this.config.token:"Bearer "+this.config.token),this.config.headers&&"object"==typeof this.config.headers&&Object.assign(t,this.config.headers),t}createError(e,t,n={}){return{success:!1,code:e,message:t,data:null,...n}}getAuthCodes(){const e=Array.isArray(this.config.authErrorCodes)?this.config.authErrorCodes:[];return new Set([...i,...e.map(e=>String(e))])}isAuthErrorCode(e){return this.getAuthCodes().has(String(e))}isTokenExpiring(){const e=Number(this.config.tokenExpiresAt||0);if(!e)return!1;const t=Number(this.config.tokenRefreshBufferMs??6e4),n=e<1e10?1e3*e:e;return Date.now()+t>=n}applyTokenResult(e){if(!e)return"";if("string"==typeof e)return this.config.token=e,e;if("object"==typeof e){const t=e.token||e.accessToken||e.authorization||"";t&&(this.config.token=t),e.refreshToken&&(this.config.refreshToken=e.refreshToken);const n=e.expiresAt??e.expireAt,i=e.expiresIn??e.expireIn;if(n){const e=Number(n);this.config.tokenExpiresAt=e<1e10?1e3*e:e}else i&&(this.config.tokenExpiresAt=Date.now()+1e3*Number(i));return e.headers&&"object"==typeof e.headers&&(this.config.headers={...this.config.headers||{},...e.headers}),t}return""}async refreshToken(e="expired",{silent:t=!1}={}){if("function"!=typeof this.config.refreshTokenFn){const e=new Error("Token 已过期且未配置 refreshTokenFn");throw t||(this.stopBackgroundRefresh(),this.config.onTokenExpired?.(e)),e}return this.refreshTokenPromise||(this.refreshTokenPromise=Promise.resolve().then(()=>this.config.refreshTokenFn({token:this.config.token||"",refreshToken:this.config.refreshToken||"",userId:this.config.userId||"",reason:e})).then(e=>{const t=this.applyTokenResult(e);return this._shouldStartBackgroundRefresh()&&this.startBackgroundRefresh(),this.config.onTokenRefreshed?.({token:this.config.token||t,refreshToken:this.config.refreshToken||"",tokenExpiresAt:this.config.tokenExpiresAt,raw:e}),t}).catch(n=>{if(t)return console.warn("[AIChatClient] Silent token refresh failed (reason="+e+"):",n.message),this.config.token||"";throw this.stopBackgroundRefresh(),this.config.onTokenExpired?.(n),n}).finally(()=>{this.refreshTokenPromise=null})),this.refreshTokenPromise}_shouldStartBackgroundRefresh(){return!1!==this.config.backgroundRefreshEnabled&&"function"==typeof this.config.refreshTokenFn&&Number(this.config.tokenExpiresAt||0)>0}startBackgroundRefresh(){if(this._backgroundTimer||!this._shouldStartBackgroundRefresh())return;const e=Math.max(3e4,Number(this.config.backgroundRefreshIntervalMs||3e5));this._backgroundTimer=setInterval(()=>{this.isTokenExpiring()&&this.refreshToken("scheduled",{silent:!0})},e),this._visibilityHandler=()=>{"visible"===document.visibilityState&&this.isTokenExpiring()&&this.refreshToken("visibility",{silent:!0})},"undefined"!=typeof document&&document.addEventListener("visibilitychange",this._visibilityHandler)}stopBackgroundRefresh(){this._backgroundTimer&&(clearInterval(this._backgroundTimer),this._backgroundTimer=null),this._visibilityHandler&&("undefined"!=typeof document&&document.removeEventListener("visibilitychange",this._visibilityHandler),this._visibilityHandler=null)}dispose(){this.stopBackgroundRefresh(),this.cancelCurrentRequest(),this.refreshTokenPromise=null}async ensureFreshToken(){if(this.isTokenExpiring())try{await this.refreshToken("preflight",{silent:!0})}catch{}}async runAuthFn(){if(this.config.authFn)try{await this.config.authFn(this.config.token||"",this.config.userId||"")}catch(e){if("function"!=typeof this.config.refreshTokenFn)throw e;await this.refreshToken("authFn"),await this.config.authFn(this.config.token||"",this.config.userId||"")}}parseResponse(e){if(e&&"object"==typeof e&&!0===e.success&&Object.prototype.hasOwnProperty.call(e,"data"))return{success:!0,code:e.code||e.errCode||200,message:e.message||e.errMsg||"",data:e.data||null,requestId:e.requestId};if(e&&"object"==typeof e&&e.bizContent){const t="string"==typeof e.bizContent?T(e.bizContent):e.bizContent;return{success:!0,code:e.code||e.errCode||200,message:e.message||e.errMsg||"",data:t,requestId:e.requestId}}const t=e&&(void 0!==e.code?e.code:e.errCode),i=e&&(!0===e.success||"SUCCESS"===e.rtnCode||n.has(t));return{success:!!i,code:t||(i?200:0),message:e&&(e.message||e.errMsg||e.rtnMsg)||"",data:e&&(e.data||e.bizContent)||null,requestId:e&&e.requestId}}async requestJson(e,n={},i={}){if("undefined"!=typeof navigator&&!1===navigator.onLine)return this.createError(t.NETWORK_ERROR,"网络连接已断开,请检查网络后重试");const s=new AbortController,r=i.timeout||this.config.timeout||6e4,a=r>0?setTimeout(()=>s.abort(),r):null;try{await this.ensureFreshToken();const t=async()=>{const t=await fetch(this.buildUrl(e),{method:i.method||"POST",headers:this.buildHeaders({"Content-Type":"application/json"}),credentials:this.config.credentials||"include",body:"GET"===i.method?void 0:JSON.stringify(n),signal:s.signal});return t.ok?this.parseResponse(await t.json()):this.createError(t.status,`HTTP ${t.status} ${t.statusText||""}`.trim())};let r=await t();return!i.skipAuthRefresh&&this.isAuthErrorCode(r.code)&&(await this.refreshToken("response"),r=await t()),r}catch(e){return e&&"AbortError"===e.name?this.createError(t.TIMEOUT_ERROR,"请求超时,请稍后重试"):this.createError(t.NETWORK_ERROR,e.message||"网络请求失败,请稍后重试")}finally{a&&clearTimeout(a)}}buildAppPayload(e,t={}){const n=t.requestId||_(),i={appId:t.appId||this.config.appId||this.config.agentAppId||null,prompt:String(e||"").trim(),userId:t.userId||this.config.userId||null,bizType:t.bizType||this.config.bizType||null,requestId:n},s=Object.prototype.hasOwnProperty.call(t,"conversationId")?t.conversationId:this.conversationId;s&&(i.conversationId=s);const r=t.attachmentIds||this.normalizeAttachmentIds(t.attachments);r.length>0&&(i.attachmentIds=r);const a=t.bizParams||t.extendInfo||this.config.extendInfo;return a&&(i.bizParams="string"==typeof a?a:JSON.stringify(a)),i}normalizeAttachmentIds(e){return Array.isArray(e)?e.map(e=>"string"==typeof e?e:e&&(e.attachmentId||e.fileId||e.id)).filter(Boolean):[]}async sendMessage(e,n,i={}){if(!e||!String(e).trim())return this.createError(t.PROMPT_EMPTY,"提示词不能为空");n&&(this.config.token=n);try{await this.runAuthFn()}catch(e){return this.createError(t.AUTH_FAILED,"鉴权失败,无法使用智能体:"+(e.message||"未知错误"))}const s=void 0!==i.retries?i.retries:this.config.maxRetries;let r=null;for(let t=0;t<=s;t++){t>0&&await new Promise(e=>setTimeout(e,(this.config.retryDelay||1e3)*Math.pow(2,t-1)));const n=this.buildAppPayload(e,i);if(this.currentRequestId=n.requestId,r=await this.requestJson(i.endpoint||this.config.apiEndpoint,n),r.success||!this.isRetryableError(r)||!1===this.config.enableRetry)break}return r&&r.data&&r.data.conversationId&&(this.conversationId=r.data.conversationId),r}isRetryableError(e){const n=e&&e.code;return[t.NETWORK_ERROR,t.TIMEOUT_ERROR,t.SERVER_ERROR,500,502,503,504].includes(n)}async sendMessageStream(e,n={},i={}){if(!e||!String(e).trim()){const e=this.createError(t.PROMPT_EMPTY,"提示词不能为空");return n.onError?.(e.message,e),e}try{await this.runAuthFn()}catch(e){return this.createError(t.AUTH_FAILED,`鉴权失败,无法使用智能体:${e.message||"未知错误"}`)}try{return await this.executeMessageStream(e,n,i,!1)}catch(e){if(e&&"AbortError"===e.name){const i="请求超时或已取消";return n.onError?.(i,e.sseData||e),this.createError(t.REQUEST_CANCELLED,i)}if(e&&e.authError){const i=e.message||"鉴权失败";return n.onError?.(i,e.sseData||e),this.createError(t.AUTH_FAILED,i)}const i=e.message||"流式请求失败";return n.onError?.(i,e.sseData||e),this.createError(t.NETWORK_ERROR,i)}}async executeMessageStream(e,t,n,i){this.cancelCurrentRequest(),this.abortController=new AbortController;const s=n.timeout||this.config.streamTimeout||this.config.timeout||3e5,r=s>0?setTimeout(()=>this.abortController.abort(),s):null,a=this.buildAppPayload(e,n);this.currentRequestId=a.requestId;let o="",l=!1;try{await this.ensureFreshToken();const s=await fetch(this.buildUrl(n.endpoint||this.config.streamEndpoint),{method:"POST",headers:this.buildHeaders({"Content-Type":"application/json",Accept:"text/event-stream"}),credentials:this.config.credentials||"include",body:JSON.stringify(a),signal:this.abortController.signal});if(!s.ok||!s.body){if(!i&&this.isAuthErrorCode(s.status))return r&&clearTimeout(r),await this.refreshToken("response"),this.executeMessageStream(e,t,n,!0);throw new Error(`流式请求失败:HTTP ${s.status}`)}const d=s.body.getReader(),h=new TextDecoder;let p="";for(;;){const{value:e,done:n}=await d.read();if(n)break;p+=h.decode(e,{stream:!0}).replace(/\r\n/g,"\n");const i=p.split("\n\n");p=i.pop()||"";for(const e of i){if(!e.trim())continue;const{event:n,data:i}=E(e);this.handleSseEvent(n,i,t,e=>{o=e},()=>{l=!0}),!c.has(n)||!i||i.startsWith("[META]")||v(i)||this.isEventLike(i)||(o+=i)}}return l||t.onDone?.(o),{success:!0,code:200,message:"",data:{content:o,conversationId:this.conversationId,requestId:a.requestId}}}catch(s){if(!i&&s&&s.authError)return r&&clearTimeout(r),await this.refreshToken("response"),this.executeMessageStream(e,t,n,!0);throw s}finally{r&&clearTimeout(r),this.abortController=null}}handleSseEvent(e,t,n,i,k){if(s.has(e))n.onStart?.();else if(d.has(e))t&&n.onThinking?.(t);else{if(h.has(e)){const e=T(t);return void n.onProgressEvent?.(e?.stage||"",e?.message||t||"")}if(p.has(e)){const e=T(t);return void n.onToolStart?.(e?.toolName||"",e?.toolCallId||"")}if(u.has(e)){const e=T(t);return void n.onToolResult?.(e?.toolName||"",e?.text||t||"")}if(g.has(e)){const e=T(t);return void n.onToolEnd?.(e?.toolName||"",e?.toolCallId||"")}if(f.has(e)){const e=(t||"").split("\n");return void n.onNodeStart?.(e[0]||"",e.slice(1).join("\n")||t||"")}if(m.has(e)){const e=(t||"").split("\n");return void n.onNodeProgress?.(e[0]||"",e.slice(1).join("\n")||t||"")}if(b.has(e)){const e=(t||"").split("\n");return void n.onNodeComplete?.(e[0]||"",e.slice(1).join("\n")||t||"")}if(x.has(e)){const e=T(t);return void n.onWarning?.(e?.message||t||"")}if(y.has(e)){const e=T(t);return void(e&&n.onHitlInterrupt?.({type:e.type||"TOOL_CONFIRMATION",requestId:e.requestId||"",sessionId:e.sessionId||"",taskRunId:e.taskRunId||"",toolCalls:e.toolCalls||[],message:e.message||""}))}if(r.has(e)){const e=T(t),n=e&&(e.message||e.errorMessage)||t||"流式请求失败",i=e&&(e.code||e.errCode||e.status);if(i&&this.isAuthErrorCode(i)){const e=new Error(n);throw e.authError=!0,e.code=i,e}const s=new Error(n);throw s.sseData=e||t,s}if((a.has(e)||c.has(e))&&t.startsWith("[META]")){const e=T(t.slice(6));return void(e&&((e.conversationId||e.sessionId)&&(this.conversationId=e.conversationId||e.sessionId),n.onMeta?.(e)))}if(l.has(e)||!c.has(e)&&!o.has(e)){const e=T(t);return void(e&&"object"==typeof e?n.onPlanningEvent?.(e):t&&!v(t)&&n.onProgress?.(t))}if(c.has(e)){if(!t||v(t)||this.isEventLike(t))return;n.onMessage?.(t)}else if(o.has(e)){let e="";if(t.startsWith("[META]")){const e=T(t.slice(6));e&&((e.conversationId||e.sessionId)&&(this.conversationId=e.conversationId||e.sessionId),n.onMeta?.(e))}else{const i=T(t);i&&"object"==typeof i&&((i.conversationId||i.sessionId)&&(this.conversationId=i.conversationId||i.sessionId),e=i.response?.finalAnswer||i.response?.finalResult||i.response?.result||i.response?.summary||i.response?.answer||i.response?.output||i.finalAnswer||i.finalResult||i.result||i.summary||i.answer||i.output||"",n.onMeta?.({conversationId:i.conversationId||i.sessionId,taskRunId:i.taskRunId,traceId:i.traceId,inputTokens:i.inputTokens,outputTokens:i.outputTokens}))}e&&i(e),k(),n.onDone?.(e)}}}isEventLike(e){const t=String(e||"").trim();if(t.startsWith("[META]")||t.startsWith("event:"))return!0;const n=T(t);return!(!n||"object"!=typeof n||!(n.eventType||n.eventId||n.taskRunId||n.metadata||n.currentTask))}async stopCompletion(e=this.currentRequestId){return this.abortController&&this.abortController.abort(),e?this.requestJson(this.config.stopEndpoint,{requestId:e,userId:this.config.userId,appId:this.config.appId||this.config.agentAppId}):this.createError(t.REQUEST_CANCELLED,"当前没有可停止的请求")}async uploadAttachment(e,n={}){if(!e)return this.createError(t.PROMPT_EMPTY,"文件不能为空");const i=new AbortController,s=n.timeout||this.config.uploadTimeout||5*(this.config.timeout||6e4),r=s>0?setTimeout(()=>i.abort(),s):null;try{await this.ensureFreshToken();const t=async()=>{const t=new FormData;t.append("file",e),t.append("userId",n.userId||this.config.userId||""),n.fileType&&t.append("fileType",n.fileType),(n.conversationId||this.conversationId)&&t.append("conversationId",n.conversationId||this.conversationId);const s=this.buildHeaders();delete s["Content-Type"];const r=await fetch(this.buildUrl(n.endpoint||this.config.attachmentUploadEndpoint),{method:"POST",headers:s,credentials:this.config.credentials||"include",body:t,signal:i.signal});return r.ok?this.parseResponse(await r.json()):this.createError(r.status,`HTTP ${r.status} ${r.statusText||""}`.trim())};let s=await t();return!n.skipAuthRefresh&&this.isAuthErrorCode(s.code)&&(await this.refreshToken("response"),s=await t()),s}catch(e){return this.createError(e&&"AbortError"===e.name?t.TIMEOUT_ERROR:t.NETWORK_ERROR,e.message||"文件上传失败")}finally{r&&clearTimeout(r)}}async queryConversation(e={}){const n=e.conversationId||this.conversationId,i=e.appId||this.config.appId||this.config.agentAppId;return n||i?this.requestJson(this.config.conversationQueryEndpoint,{userId:e.userId||this.config.userId,requestId:e.requestId||_(),conversationId:n,appId:i,bizType:e.bizType||this.config.bizType,pageIndex:e.pageIndex||1,pageSize:e.pageSize||20}):this.createError(t.PROMPT_EMPTY,"会话ID和应用ID不能同时为空")}async deleteConversation(e=this.conversationId,n={}){if(!e)return this.createError(t.PROMPT_EMPTY,"会话ID不能为空");const i=await this.requestJson(this.config.conversationDeleteEndpoint,{userId:n.userId||this.config.userId,requestId:n.requestId||_(),conversationId:e,appId:n.appId||this.config.appId||this.config.agentAppId,bizType:n.bizType||this.config.bizType});return i.success&&e===this.conversationId&&(this.conversationId=null),i}async asyncCompletion(e,t={}){const n=this.buildAppPayload(e,t);return this.currentRequestId=n.requestId,this.requestJson(this.config.asyncEndpoint,n)}async getTaskStatus(e,n={}){if(!e)return this.createError(t.PROMPT_EMPTY,"任务ID不能为空");const i=(n.endpoint||this.config.taskStatusEndpoint).replace("{taskId}",encodeURIComponent(e));return this.requestJson(i,void 0,{method:"GET",timeout:n.timeout})}async getAppDetail(e=this.config.appId||this.config.agentAppId,n={}){if(!e)return this.createError(t.AGENT_NOT_FOUND,"智能体应用ID不能为空");const i=(n.endpoint||this.config.appDetailEndpoint).replace("{appId}",encodeURIComponent(e));return this.requestJson(i,void 0,{method:"GET",timeout:n.timeout})}async listApplications(e={}){const t={applicationType:e.applicationType,pageIndex:e.pageIndex||1,pageSize:e.pageSize||20,userId:this.config.userId,requestId:_()};return this.requestJson(e.endpoint||this.config.appListEndpoint,t)}async replyPermission(e){if(!e.sessionId||!e.requestId)return this.createError(t.PROMPT_EMPTY,"sessionId和requestId不能为空");const n={sessionId:e.sessionId,requestId:e.requestId,reply:e.reply||"once",message:e.message||"",userId:this.config.userId,replyRequestId:_()};return this.requestJson(this.config.runtimePermissionReplyEndpoint,n)}async replyQuestion(e){if(!e.sessionId||!e.requestId)return this.createError(t.PROMPT_EMPTY,"sessionId和requestId不能为空");const n={sessionId:e.sessionId,requestId:e.requestId,answers:e.answers||[],userId:this.config.userId,replyRequestId:_()};return this.requestJson(this.config.runtimeQuestionReplyEndpoint,n)}async rejectQuestion(e){if(!e.sessionId||!e.requestId)return this.createError(t.PROMPT_EMPTY,"sessionId和requestId不能为空");const n={sessionId:e.sessionId,requestId:e.requestId,userId:this.config.userId,replyRequestId:_()};return this.requestJson(this.config.runtimeQuestionRejectEndpoint,n)}setConversationId(e){this.conversationId=e||null}clearConversation(){this.conversationId=null,this.currentRequestId=null,this.cancelCurrentRequest()}cancelCurrentRequest(){this.abortController&&(this.abortController.abort(),this.abortController=null)}updateConfig(e){const t=this._shouldStartBackgroundRefresh();Object.assign(this.config,e||{});const n=this._shouldStartBackgroundRefresh();!t&&n?this.startBackgroundRefresh():t&&!n&&this.stopBackgroundRefresh()}}function I(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var R={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function A(e){R=e}var C={exec:()=>null};function L(e){let t=[];return n=>{let i=Math.max(0,Math.min(3,n-1)),s=t[i];return s||(s=e(i),t[i]=s),s}}function M(e,t=""){let n="string"==typeof e?e:e.source,i={replace:(e,t)=>{let s="string"==typeof t?t:t.source;return s=s.replace(O.caret,"$1"),n=n.replace(e,s),i},getRegex:()=>new RegExp(n,t)};return i}var D=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),O={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:L(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`)),hrRegex:L(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:L(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:L(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:L(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:L(e=>new RegExp(`^ {0,${e}}>`))},N=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,z=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,B=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,P=M(B).replace(/bull/g,z).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),$=M(B).replace(/bull/g,z).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),q=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,H=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,j=M(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",H).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),U=M(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,z).getRegex(),F="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",G=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,V=M("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",G).replace("tag",F).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Y=M(q).replace("hr",N).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",F).getRegex(),W={blockquote:M(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Y).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:j,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:N,html:V,lheading:P,list:U,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:Y,table:C,text:/^[^\n]+/},X=M("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",N).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",F).getRegex(),Q={...W,lheading:$,table:X,paragraph:M(q).replace("hr",N).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",X).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",F).getRegex()},Z={...W,html:M("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",G).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:C,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:M(q).replace("hr",N).replace("heading"," *#{1,6} *[^\n]").replace("lheading",P).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},K=/^( {2,}|\\)\n(?!\s*$)/,J=/[\p{P}\p{S}]/u,ee=/[\s\p{P}\p{S}]/u,te=/[^\s\p{P}\p{S}]/u,ne=M(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ee).getRegex(),ie=/(?!~)[\p{P}\p{S}]/u,se=M(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",D?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),re=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,ae=M(re,"u").replace(/punct/g,J).getRegex(),oe=M(re,"u").replace(/punct/g,ie).getRegex(),le="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",ce=M(le,"gu").replace(/notPunctSpace/g,te).replace(/punctSpace/g,ee).replace(/punct/g,J).getRegex(),de=M(le,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,ie).getRegex(),he=M("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,te).replace(/punctSpace/g,ee).replace(/punct/g,J).getRegex(),pe=M(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,J).getRegex(),ue=M("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)","gu").replace(/notPunctSpace/g,te).replace(/punctSpace/g,ee).replace(/punct/g,J).getRegex(),ge=M(/\\(punct)/,"gu").replace(/punct/g,J).getRegex(),fe=M(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),me=M(G).replace("(?:--\x3e|$)","--\x3e").getRegex(),be=M("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",me).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),xe=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,ye=M(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",xe).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ke=M(/^!?\[(label)\]\[(ref)\]/).replace("label",xe).replace("ref",H).getRegex(),_e=M(/^!?\[(ref)\](?:\[\])?/).replace("ref",H).getRegex(),we=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ve={_backpedal:C,anyPunctuation:ge,autolink:fe,blockSkip:se,br:K,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:C,delLDelim:C,delRDelim:C,emStrongLDelim:ae,emStrongRDelimAst:ce,emStrongRDelimUnd:he,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:ye,nolink:_e,punctuation:ne,reflink:ke,reflinkSearch:M("reflink|nolink(?!\\()","g").replace("reflink",ke).replace("nolink",_e).getRegex(),tag:be,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:C},Te={...ve,link:M(/^!?\[(label)\]\((.*?)\)/).replace("label",xe).getRegex(),reflink:M(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",xe).getRegex()},Ee={...ve,emStrongRDelimAst:de,emStrongLDelim:oe,delLDelim:pe,delRDelim:ue,url:M(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",we).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:M(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",we).getRegex()},Se={...Ee,br:M(K).replace("{2,}","*").getRegex(),text:M(Ee.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ie={normal:W,gfm:Q,pedantic:Z},Re={normal:ve,gfm:Ee,breaks:Se,pedantic:Te},Ae={"&":"&","<":"<",">":">",'"':""","'":"'"},Ce=e=>Ae[e];function Le(e,t){if(t){if(O.escapeTest.test(e))return e.replace(O.escapeReplace,Ce)}else if(O.escapeTestNoEncode.test(e))return e.replace(O.escapeReplaceNoEncode,Ce);return e}function Me(e){try{e=encodeURI(e).replace(O.percentDecode,"%")}catch{return null}return e}function De(e,t){let n=e.replace(O.findPipe,(e,t,n)=>{let i=!1,s=t;for(;--s>=0&&"\\"===n[s];)i=!i;return i?"|":" |"}).split(O.splitPipe),i=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;i<n.length;i++)n[i]=n[i].trim().replace(O.slashPipe,"|");return n}function Oe(e,t,n){let i=e.length;if(0===i)return"";let s=0;for(;s<i;){if(e.charAt(i-s-1)!==t)break;s++}return e.slice(0,i-s)}function Ne(e){let t=e.split("\n"),n=t.length-1;for(;n>=0&&O.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join("\n")}function ze(e,t=0){let n=t,i="";for(let t of e)if("\t"===t){let e=4-n%4;i+=" ".repeat(e),n+=e}else i+=t,n++;return i}function Be(e,t,n,i,s){let r=t.href,a=t.title||null,o=e[1].replace(s.other.outputLinkReplace,"$1");i.state.inLink=!0;let l={type:"!"===e[0].charAt(0)?"image":"link",raw:n,href:r,title:a,text:o,tokens:i.inlineTokens(o)};return i.state.inLink=!1,l}var Pe=class{options;rules;lexer;constructor(e){this.options=e||R}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=this.options.pedantic?t[0]:Ne(t[0]),n=e.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e,codeBlockStyle:"indented",text:n}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=function(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(null===i)return t;let s=i[1];return t.split("\n").map(e=>{let t=e.match(n.other.beginningSpace);if(null===t)return e;let[i]=t;return i.length>=s.length?e.slice(s.length):e}).join("\n")}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=Oe(e,"#");(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:"heading",raw:Oe(t[0],"\n"),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Oe(t[0],"\n")}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=Oe(t[0],"\n").split("\n"),n="",i="",s=[];for(;e.length>0;){let t,r=!1,a=[];for(t=0;t<e.length;t++)if(this.rules.other.blockquoteStart.test(e[t]))a.push(e[t]),r=!0;else{if(r)break;a.push(e[t])}e=e.slice(t);let o=a.join("\n"),l=o.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}\n${o}`:o,i=i?`${i}\n${l}`:l;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(l,s,!0),this.lexer.state.top=c,0===e.length)break;let d=s.at(-1);if("code"===d?.type)break;if("blockquote"===d?.type){let t=d,r=t.raw+"\n"+e.join("\n"),a=this.blockquote(r);s[s.length-1]=a,n=n.substring(0,n.length-t.raw.length)+a.raw,i=i.substring(0,i.length-t.text.length)+a.text;break}if("list"===d?.type){let t=d,r=t.raw+"\n"+e.join("\n"),a=this.list(r);s[s.length-1]=a,n=n.substring(0,n.length-d.raw.length)+a.raw,i=i.substring(0,i.length-t.raw.length)+a.raw,e=r.substring(s.at(-1).raw.length).split("\n");continue}}return{type:"blockquote",raw:n,tokens:s,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),i=n.length>1,s={type:"list",raw:"",ordered:i,start:i?+n.slice(0,-1):"",loose:!1,items:[]};n=i?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=i?n:"[*+-]");let r=this.rules.other.listItemRegex(n),a=!1;for(;e;){let n=!1,i="",o="";if(!(t=r.exec(e))||this.rules.block.hr.test(e))break;i=t[0],e=e.substring(i.length);let l=ze(t[2].split("\n",1)[0],t[1].length),c=e.split("\n",1)[0],d=!l.trim(),h=0;if(this.options.pedantic?(h=2,o=l.trimStart()):d?h=t[1].length+1:(h=l.search(this.rules.other.nonSpaceChar),h=h>4?1:h,o=l.slice(h),h+=t[1].length),d&&this.rules.other.blankLine.test(c)&&(i+=c+"\n",e=e.substring(c.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(h),n=this.rules.other.hrRegex(h),s=this.rules.other.fencesBeginRegex(h),r=this.rules.other.headingBeginRegex(h),a=this.rules.other.htmlBeginRegex(h),p=this.rules.other.blockquoteBeginRegex(h);for(;e;){let u,g=e.split("\n",1)[0];if(c=g,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting," "),u=c):u=c.replace(this.rules.other.tabCharGlobal," "),s.test(c)||r.test(c)||a.test(c)||p.test(c)||t.test(c)||n.test(c))break;if(u.search(this.rules.other.nonSpaceChar)>=h||!c.trim())o+="\n"+u.slice(h);else{if(d||l.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||s.test(l)||r.test(l)||n.test(l))break;o+="\n"+c}d=!c.trim(),i+=g+"\n",e=e.substring(g.length+1),l=u.slice(h)}}s.loose||(a?s.loose=!0:this.rules.other.doubleBlankLine.test(i)&&(a=!0)),s.items.push({type:"list_item",raw:i,task:!!this.options.gfm&&this.rules.other.listIsTask.test(o),loose:!1,text:o,tokens:[]}),s.raw+=i}let o=s.items.at(-1);if(!o)return;o.raw=o.raw.trimEnd(),o.text=o.text.trimEnd(),s.raw=s.raw.trimEnd();for(let e of s.items){this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]);let t=e.tokens[0];if(!e.task||"text"!==t?.type&&"paragraph"!==t?.type)e.task&&(e.task=!1);else{e.text=e.text.replace(this.rules.other.listReplaceTask,""),t.raw=t.raw.replace(this.rules.other.listReplaceTask,""),t.text=t.text.replace(this.rules.other.listReplaceTask,"");for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,"");break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:"checkbox",raw:n[0]+" ",checked:"[ ]"!==n[0]};e.checked=t.checked,s.loose?e.tokens[0]&&["paragraph","text"].includes(e.tokens[0].type)&&"tokens"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:"paragraph",raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}if(!s.loose){let t=e.tokens.filter(e=>"space"===e.type),n=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw));s.loose=n}}if(s.loose)for(let e of s.items){e.loose=!0;for(let t of e.tokens)"text"===t.type&&(t.type="paragraph")}return s}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=Ne(t[0]);return{type:"html",block:!0,raw:e,pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:Oe(t[0],"\n"),href:n,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=De(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],r={type:"table",raw:Oe(t[0],"\n"),header:[],align:[],rows:[]};if(n.length===i.length){for(let e of i)this.rules.other.tableAlignRight.test(e)?r.align.push("right"):this.rules.other.tableAlignCenter.test(e)?r.align.push("center"):this.rules.other.tableAlignLeft.test(e)?r.align.push("left"):r.align.push(null);for(let e=0;e<n.length;e++)r.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:r.align[e]});for(let e of s)r.rows.push(De(e,r.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:r.align[t]})));return r}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:"heading",raw:Oe(t[0],"\n"),depth:"="===t[2].charAt(0)?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=Oe(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{let e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let i=0;i<e.length;i++)if("\\"===e[i])i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return n>0?-2:-1}(t[2],"()");if(-2===e)return;if(e>-1){let n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],i="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],i=e[3])}else i=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),Be(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return Be(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(i&&(i[1]||i[2]||i[3]||i[4])&&(!i[4]||!n.match(this.rules.other.unicodeAlphaNumeric))&&(!i[1]&&!i[3]||!n||this.rules.inline.punctuation.exec(n))){let n,s,r=[...i[0]].length-1,a=r,o=0,l="*"===i[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+r);null!==(i=l.exec(t));){if(n=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!n)continue;if(s=[...n].length,i[3]||i[4]){a+=s;continue}if((i[5]||i[6])&&r%3&&!((r+s)%3)){o+=s;continue}if(a-=s,a>0)continue;s=Math.min(s,s+a+o);let t=[...i[0]][0].length,l=e.slice(0,r+i.index+t+s);if(Math.min(r,s)%2){let e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}let c=l.slice(2,-2);return{type:"strong",raw:l,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(e),i=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&i&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let i=this.rules.inline.delLDelim.exec(e);if(i&&(!i[1]||!n||this.rules.inline.punctuation.exec(n))){let n,s,r=[...i[0]].length-1,a=r,o=this.rules.inline.delRDelim;for(o.lastIndex=0,t=t.slice(-1*e.length+r);null!==(i=o.exec(t));){if(n=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!n||(s=[...n].length,s!==r))continue;if(i[3]||i[4]){a+=s;continue}if(a-=s,a>0)continue;s=Math.min(s,s+a);let t=[...i[0]][0].length,o=e.slice(0,r+i.index+t+s),l=o.slice(r,-r);return{type:"del",raw:o,text:l,tokens:this.lexer.inlineTokens(l)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=t[1],n="mailto:"+e):(e=t[1],n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if("@"===t[2])e=t[0],n="mailto:"+e;else{let i;do{i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(i!==t[0]);e=t[0],n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},$e=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||R,this.options.tokenizer=this.options.tokenizer||new Pe,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:O,block:Ie.normal,inline:Re.normal};this.options.pedantic?(t.block=Ie.pedantic,t.inline=Re.pedantic):this.options.gfm&&(t.block=Ie.gfm,this.options.breaks?t.inline=Re.breaks:t.inline=Re.gfm),this.tokenizer.rules=t}static get rules(){return{block:Ie,inline:Re}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(O.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(O.tabCharGlobal," ").replace(O.spaceLine,""));let i=1/0;for(;e;){if(!(e.length<i)){this.infiniteLoopError(e.charCodeAt(0));break}let s;if(i=e.length,this.options.extensions?.block?.some(n=>!!(s=n.call({lexer:this},e,t))&&(e=e.substring(s.raw.length),t.push(s),!0)))continue;if(s=this.tokenizer.space(e)){e=e.substring(s.raw.length);let n=t.at(-1);1===s.raw.length&&void 0!==n?n.raw+="\n":t.push(s);continue}if(s=this.tokenizer.code(e)){e=e.substring(s.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+s.raw,n.text+="\n"+s.text,this.inlineQueue.at(-1).src=n.text):t.push(s);continue}if(s=this.tokenizer.fences(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.heading(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.hr(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.blockquote(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.list(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.html(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.def(e)){e=e.substring(s.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+s.raw,n.text+="\n"+s.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title},t.push(s));continue}if(s=this.tokenizer.table(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.lheading(e)){e=e.substring(s.raw.length),t.push(s);continue}let r=e;if(this.options.extensions?.startBlock){let t,n=1/0,i=e.slice(1);this.options.extensions.startBlock.forEach(e=>{t=e.call({lexer:this},i),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(r=e.substring(0,n+1))}if(this.state.top&&(s=this.tokenizer.paragraph(r))){let i=t.at(-1);n&&"paragraph"===i?.type?(i.raw+=(i.raw.endsWith("\n")?"":"\n")+s.raw,i.text+="\n"+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):t.push(s),n=r.length!==e.length,e=e.substring(s.raw.length);continue}if(s=this.tokenizer.text(e)){e=e.substring(s.raw.length);let n=t.at(-1);"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+s.raw,n.text+="\n"+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(s);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n,i=e,s=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;null!==(s=this.tokenizer.rules.inline.reflinkSearch.exec(i));)e.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!==(s=this.tokenizer.rules.inline.anyPunctuation.exec(i));)i=i.slice(0,s.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!==(s=this.tokenizer.rules.inline.blockSkip.exec(i));)n=s[2]?s[2].length:0,i=i.slice(0,s.index+n)+"["+"a".repeat(s[0].length-n-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=this.options.hooks?.emStrongMask?.call({lexer:this},i)??i;let r=!1,a="",o=1/0;for(;e;){if(!(e.length<o)){this.infiniteLoopError(e.charCodeAt(0));break}let n;if(o=e.length,r||(a=""),r=!1,this.options.extensions?.inline?.some(i=>!!(n=i.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))continue;if(n=this.tokenizer.escape(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.tag(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.link(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(n.raw.length);let i=t.at(-1);"text"===n.type&&"text"===i?.type?(i.raw+=n.raw,i.text+=n.text):t.push(n);continue}if(n=this.tokenizer.emStrong(e,i,a)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.codespan(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.br(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.del(e,i,a)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.autolink(e)){e=e.substring(n.raw.length),t.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(e))){e=e.substring(n.raw.length),t.push(n);continue}let s=e;if(this.options.extensions?.startInline){let t,n=1/0,i=e.slice(1);this.options.extensions.startInline.forEach(e=>{t=e.call({lexer:this},i),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(s=e.substring(0,n+1))}if(n=this.tokenizer.inlineText(s)){e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(a=n.raw.slice(-1)),r=!0;let i=t.at(-1);"text"===i?.type?(i.raw+=n.raw,i.text+=n.text):t.push(n);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t="Infinite loop on byte: "+e;if(!this.options.silent)throw new Error(t);console.error(t)}},qe=class{options;parser;constructor(e){this.options=e||R}space(e){return""}code({text:e,lang:t,escaped:n}){let i=(t||"").match(O.notSpaceStart)?.[0],s=e.replace(O.endingNewline,"")+"\n";return i?'<pre><code class="language-'+Le(i)+'">'+(n?s:Le(s,!0))+"</code></pre>\n":"<pre><code>"+(n?s:Le(s,!0))+"</code></pre>\n"}blockquote({tokens:e}){return`<blockquote>\n${this.parser.parse(e)}</blockquote>\n`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>\n`}hr(e){return"<hr>\n"}list(e){let t=e.ordered,n=e.start,i="";for(let t=0;t<e.items.length;t++){let n=e.items[t];i+=this.listitem(n)}let s=t?"ol":"ul";return"<"+s+(t&&1!==n?' start="'+n+'"':"")+">\n"+i+"</"+s+">\n"}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>\n`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\n`}table(e){let t="",n="";for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let i="";for(let t=0;t<e.rows.length;t++){let s=e.rows[t];n="";for(let e=0;e<s.length;e++)n+=this.tablecell(s[e]);i+=this.tablerow({text:n})}return i&&(i=`<tbody>${i}</tbody>`),"<table>\n<thead>\n"+t+"</thead>\n"+i+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Le(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let i=this.parser.parseInline(n),s=Me(e);if(null===s)return i;let r='<a href="'+(e=s)+'"';return t&&(r+=' title="'+Le(t)+'"'),r+=">"+i+"</a>",r}image({href:e,title:t,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let s=Me(e);if(null===s)return Le(n);let r=`<img src="${e=s}" alt="${Le(n)}"`;return t&&(r+=` title="${Le(t)}"`),r+=">",r}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Le(e.text)}},He=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},je=class e{options;renderer;textRenderer;constructor(e){this.options=e||R,this.options.renderer=this.options.renderer||new qe,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new He}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t="";for(let n=0;n<e.length;n++){let i=e[n];if(this.options.extensions?.renderers?.[i.type]){let e=i,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==n||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(e.type)){t+=n||"";continue}}let s=i;switch(s.type){case"space":t+=this.renderer.space(s);break;case"hr":t+=this.renderer.hr(s);break;case"heading":t+=this.renderer.heading(s);break;case"code":t+=this.renderer.code(s);break;case"table":t+=this.renderer.table(s);break;case"blockquote":t+=this.renderer.blockquote(s);break;case"list":t+=this.renderer.list(s);break;case"checkbox":t+=this.renderer.checkbox(s);break;case"html":t+=this.renderer.html(s);break;case"def":t+=this.renderer.def(s);break;case"paragraph":t+=this.renderer.paragraph(s);break;case"text":t+=this.renderer.text(s);break;default:{let e='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n="";for(let i=0;i<e.length;i++){let s=e[i];if(this.options.extensions?.renderers?.[s.type]){let e=this.options.extensions.renderers[s.type].call({parser:this},s);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){n+=e||"";continue}}let r=s;switch(r.type){case"escape":case"text":n+=t.text(r);break;case"html":n+=t.html(r);break;case"link":n+=t.link(r);break;case"image":n+=t.image(r);break;case"checkbox":n+=t.checkbox(r);break;case"strong":n+=t.strong(r);break;case"em":n+=t.em(r);break;case"codespan":n+=t.codespan(r);break;case"br":n+=t.br(r);break;case"del":n+=t.del(r);break;default:{let e='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}},Ue=class{options;block;constructor(e){this.options=e||R}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?$e.lex:$e.lexInline}provideParser(e=this.block){return e?je.parse:je.parseInline}},Fe=new class{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=je;Renderer=qe;TextRenderer=He;Lexer=$e;Tokenizer=Pe;Hooks=Ue;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let i of e)switch(n=n.concat(t.call(this,i)),i.type){case"table":{let e=i;for(let i of e.header)n=n.concat(this.walkTokens(i.tokens,t));for(let i of e.rows)for(let e of i)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":{let e=i;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=i;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(i=>{let s=e[i].flat(1/0);n=n.concat(this.walkTokens(s,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){let n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let i=e.renderer.apply(this,t);return!1===i&&(i=n.apply(this,t)),i}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new qe(this.defaults);for(let n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;let i=n,s=e.renderer[i],r=t[i];t[i]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=r.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Pe(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;let i=n,s=e.tokenizer[i],r=t[i];t[i]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=r.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Ue;for(let n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;let i=n,s=e.hooks[i],r=t[i];Ue.passThroughHooks.has(n)?t[i]=e=>{if(this.defaults.async&&Ue.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await s.call(t,e);return r.call(t,n)})();let i=s.call(t,e);return r.call(t,i)}:t[i]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await s.apply(t,e);return!1===n&&(n=await r.apply(t,e)),n})();let n=s.apply(t,e);return!1===n&&(n=r.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,i=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(i.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return $e.lex(e,t??this.defaults)}parser(e,t){return je.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let i={...n},s={...this.defaults,...i},r=this.onError(!!s.silent,!!s.async);if(!0===this.defaults.async&&!1===i.async)return r(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||null===t)return r(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return r(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return(async()=>{let n=s.hooks?await s.hooks.preprocess(t):t,i=await(s.hooks?await s.hooks.provideLexer(e):e?$e.lex:$e.lexInline)(n,s),r=s.hooks?await s.hooks.processAllTokens(i):i;s.walkTokens&&await Promise.all(this.walkTokens(r,s.walkTokens));let a=await(s.hooks?await s.hooks.provideParser(e):e?je.parse:je.parseInline)(r,s);return s.hooks?await s.hooks.postprocess(a):a})().catch(r);try{s.hooks&&(t=s.hooks.preprocess(t));let n=(s.hooks?s.hooks.provideLexer(e):e?$e.lex:$e.lexInline)(t,s);s.hooks&&(n=s.hooks.processAllTokens(n)),s.walkTokens&&this.walkTokens(n,s.walkTokens);let i=(s.hooks?s.hooks.provideParser(e):e?je.parse:je.parseInline)(n,s);return s.hooks&&(i=s.hooks.postprocess(i)),i}catch(e){return r(e)}}}onError(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="<p>An error occurred:</p><pre>"+Le(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Ge(e,t){return Fe.parse(e,t)}function Ve(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function Ye(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,s,r,a,o=[],l=!0,c=!1;try{if(r=(n=n.call(e)).next,0===t);else for(;!(l=(i=r.call(n)).done)&&(o.push(i.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw s}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Ve(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ve(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}Ge.options=Ge.setOptions=function(e){return Fe.setOptions(e),Ge.defaults=Fe.defaults,A(Ge.defaults),Ge},Ge.getDefaults=I,Ge.defaults=R,Ge.use=function(...e){return Fe.use(...e),Ge.defaults=Fe.defaults,A(Ge.defaults),Ge},Ge.walkTokens=function(e,t){return Fe.walkTokens(e,t)},Ge.parseInline=Fe.parseInline,Ge.Parser=je,Ge.parser=je.parse,Ge.Renderer=qe,Ge.TextRenderer=He,Ge.Lexer=$e,Ge.lexer=$e.lex,Ge.Tokenizer=Pe,Ge.Hooks=Ue,Ge.parse=Ge,Ge.options,Ge.setOptions,Ge.use,Ge.walkTokens,Ge.parseInline,je.parse,$e.lex;const We=Object.entries,Xe=Object.setPrototypeOf,Qe=Object.isFrozen,Ze=Object.getPrototypeOf,Ke=Object.getOwnPropertyDescriptor;let Je=Object.freeze,et=Object.seal,tt=Object.create,nt="undefined"!=typeof Reflect&&Reflect,it=nt.apply,st=nt.construct;Je||(Je=function(e){return e}),et||(et=function(e){return e}),it||(it=function(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];return e.apply(t,i)}),st||(st=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return new e(...n)});const rt=St(Array.prototype.forEach),at=St(Array.prototype.lastIndexOf),ot=St(Array.prototype.pop),lt=St(Array.prototype.push),ct=St(Array.prototype.splice),dt=Array.isArray,ht=St(String.prototype.toLowerCase),pt=St(String.prototype.toString),ut=St(String.prototype.match),gt=St(String.prototype.replace),ft=St(String.prototype.indexOf),mt=St(String.prototype.trim),bt=St(Number.prototype.toString),xt=St(Boolean.prototype.toString),yt="undefined"==typeof BigInt?null:St(BigInt.prototype.toString),kt="undefined"==typeof Symbol?null:St(Symbol.prototype.toString),_t=St(Object.prototype.hasOwnProperty),wt=St(Object.prototype.toString),vt=St(RegExp.prototype.test),Tt=(Et=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return st(Et,t)});var Et;function St(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return it(e,t,i)}}function It(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ht;if(Xe&&Xe(e,null),!dt(t))return e;let i=t.length;for(;i--;){let s=t[i];if("string"==typeof s){const e=n(s);e!==s&&(Qe(t)||(t[i]=e),s=e)}e[s]=!0}return e}function Rt(e){for(let t=0;t<e.length;t++){_t(e,t)||(e[t]=null)}return e}function At(e){const t=tt(null);for(const i of We(e)){var n=Ye(i,2);const s=n[0],r=n[1];_t(e,s)&&(dt(r)?t[s]=Rt(r):r&&"object"==typeof r&&r.constructor===Object?t[s]=At(r):t[s]=r)}return t}function Ct(e,t){for(;null!==e;){const n=Ke(e,t);if(n){if(n.get)return St(n.get);if("function"==typeof n.value)return St(n.value)}e=Ze(e)}return function(){return null}}const Lt=Je(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Mt=Je(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Dt=Je(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Ot=Je(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Nt=Je(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),zt=Je(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Bt=Je(["#text"]),Pt=Je(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),$t=Je(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),qt=Je(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Ht=Je(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),jt=et(/{{[\w\W]*|^[\w\W]*}}/g),Ut=et(/<%[\w\W]*|^[\w\W]*%>/g),Ft=et(/\${[\w\W]*/g),Gt=et(/^data-[\-\w.\u00B7-\uFFFF]+$/),Vt=et(/^aria-[\-\w]+$/),Yt=et(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Wt=et(/^(?:\w+script|data):/i),Xt=et(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Qt=et(/^html$/i),Zt=et(/^[a-z][.\w]*(-[.\w]+)+$/i),Kt=1,Jt=3,en=7,tn=8,nn=9,sn=11,rn=function(){return"undefined"==typeof window?null:window};var an=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:rn();const n=t=>e(t);if(n.version="3.4.8",n.removed=[],!t||!t.document||t.document.nodeType!==nn||!t.Element)return n.isSupported=!1,n;let i=t.document;const s=i,r=s.currentScript;t.DocumentFragment;const a=t.HTMLTemplateElement,o=t.Node,l=t.Element,c=t.NodeFilter,d=t.NamedNodeMap;void 0===d&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;const h=t.DOMParser,p=t.trustedTypes,u=l.prototype,g=Ct(u,"cloneNode"),f=Ct(u,"remove"),m=Ct(u,"nextSibling"),b=Ct(u,"childNodes"),x=Ct(u,"parentNode"),y=Ct(u,"shadowRoot"),k=Ct(u,"attributes"),_=o&&o.prototype?Ct(o.prototype,"nodeType"):null,w=o&&o.prototype?Ct(o.prototype,"nodeName"):null;if("function"==typeof a){const e=i.createElement("template");e.content&&e.content.ownerDocument&&(i=e.content.ownerDocument)}let v,T="",E=0;const S=function(e){if(E>0)throw Tt('The configured TRUSTED_TYPES_POLICY.createHTML must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose createHTML wraps DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.');E++;try{return v.createHTML(e)}finally{E--}},I=i,R=I.implementation,A=I.createNodeIterator,C=I.createDocumentFragment,L=I.getElementsByTagName,M=s.importNode;let D={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof We&&"function"==typeof x&&R&&void 0!==R.createHTMLDocument;const O=jt,N=Ut,z=Ft,B=Gt,P=Vt,$=Wt,q=Xt,H=Zt;let j=Yt,U=null;const F=It({},[...Lt,...Mt,...Dt,...Nt,...Bt]);let G=null;const V=It({},[...Pt,...$t,...qt,...Ht]);let Y=Object.seal(tt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),W=null,X=null;const Q=Object.seal(tt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Z=!0,K=!0,J=!1,ee=!0,te=!1,ne=!0,ie=!1,se=!1,re=!1,ae=!1,oe=!1,le=!1,ce=!0,de=!1;const he="user-content-";let pe=!0,ue=!1,ge={},fe=null;const me=It({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let be=null;const xe=It({},["audio","video","img","source","image","track"]);let ye=null;const ke=It({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),_e="http://www.w3.org/1998/Math/MathML",we="http://www.w3.org/2000/svg",ve="http://www.w3.org/1999/xhtml";let Te=ve,Ee=!1,Se=null;const Ie=It({},[_e,we,ve],pt);let Re=It({},["mi","mo","mn","ms","mtext"]),Ae=It({},["annotation-xml"]);const Ce=It({},["title","style","font","a","script"]);let Le=null;const Me=["application/xhtml+xml","text/html"];let De=null,Oe=null;const Ne=i.createElement("form"),ze=function(e){return e instanceof RegExp||e instanceof Function},Be=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(Oe&&Oe===e)return;e&&"object"==typeof e||(e={}),e=At(e),Le=-1===Me.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,De="application/xhtml+xml"===Le?pt:ht,U=_t(e,"ALLOWED_TAGS")&&dt(e.ALLOWED_TAGS)?It({},e.ALLOWED_TAGS,De):F,G=_t(e,"ALLOWED_ATTR")&&dt(e.ALLOWED_ATTR)?It({},e.ALLOWED_ATTR,De):V,Se=_t(e,"ALLOWED_NAMESPACES")&&dt(e.ALLOWED_NAMESPACES)?It({},e.ALLOWED_NAMESPACES,pt):Ie,ye=_t(e,"ADD_URI_SAFE_ATTR")&&dt(e.ADD_URI_SAFE_ATTR)?It(At(ke),e.ADD_URI_SAFE_ATTR,De):ke,be=_t(e,"ADD_DATA_URI_TAGS")&&dt(e.ADD_DATA_URI_TAGS)?It(At(xe),e.ADD_DATA_URI_TAGS,De):xe,fe=_t(e,"FORBID_CONTENTS")&&dt(e.FORBID_CONTENTS)?It({},e.FORBID_CONTENTS,De):me,W=_t(e,"FORBID_TAGS")&&dt(e.FORBID_TAGS)?It({},e.FORBID_TAGS,De):At({}),X=_t(e,"FORBID_ATTR")&&dt(e.FORBID_ATTR)?It({},e.FORBID_ATTR,De):At({}),ge=!!_t(e,"USE_PROFILES")&&(e.USE_PROFILES&&"object"==typeof e.USE_PROFILES?At(e.USE_PROFILES):e.USE_PROFILES),Z=!1!==e.ALLOW_ARIA_ATTR,K=!1!==e.ALLOW_DATA_ATTR,J=e.ALLOW_UNKNOWN_PROTOCOLS||!1,ee=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,te=e.SAFE_FOR_TEMPLATES||!1,ne=!1!==e.SAFE_FOR_XML,ie=e.WHOLE_DOCUMENT||!1,ae=e.RETURN_DOM||!1,oe=e.RETURN_DOM_FRAGMENT||!1,le=e.RETURN_TRUSTED_TYPE||!1,re=e.FORCE_BODY||!1,ce=!1!==e.SANITIZE_DOM,de=e.SANITIZE_NAMED_PROPS||!1,pe=!1!==e.KEEP_CONTENT,ue=e.IN_PLACE||!1,j=function(e){try{return vt(e,""),!0}catch(e){return!1}}(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Yt,Te="string"==typeof e.NAMESPACE?e.NAMESPACE:ve,Re=_t(e,"MATHML_TEXT_INTEGRATION_POINTS")&&e.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof e.MATHML_TEXT_INTEGRATION_POINTS?At(e.MATHML_TEXT_INTEGRATION_POINTS):It({},["mi","mo","mn","ms","mtext"]),Ae=_t(e,"HTML_INTEGRATION_POINTS")&&e.HTML_INTEGRATION_POINTS&&"object"==typeof e.HTML_INTEGRATION_POINTS?At(e.HTML_INTEGRATION_POINTS):It({},["annotation-xml"]);const t=_t(e,"CUSTOM_ELEMENT_HANDLING")&&e.CUSTOM_ELEMENT_HANDLING&&"object"==typeof e.CUSTOM_ELEMENT_HANDLING?At(e.CUSTOM_ELEMENT_HANDLING):tt(null);if(Y=tt(null),_t(t,"tagNameCheck")&&ze(t.tagNameCheck)&&(Y.tagNameCheck=t.tagNameCheck),_t(t,"attributeNameCheck")&&ze(t.attributeNameCheck)&&(Y.attributeNameCheck=t.attributeNameCheck),_t(t,"allowCustomizedBuiltInElements")&&"boolean"==typeof t.allowCustomizedBuiltInElements&&(Y.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),te&&(K=!1),oe&&(ae=!0),ge&&(U=It({},Bt),G=tt(null),!0===ge.html&&(It(U,Lt),It(G,Pt)),!0===ge.svg&&(It(U,Mt),It(G,$t),It(G,Ht)),!0===ge.svgFilters&&(It(U,Dt),It(G,$t),It(G,Ht)),!0===ge.mathMl&&(It(U,Nt),It(G,qt),It(G,Ht))),Q.tagCheck=null,Q.attributeCheck=null,_t(e,"ADD_TAGS")&&("function"==typeof e.ADD_TAGS?Q.tagCheck=e.ADD_TAGS:dt(e.ADD_TAGS)&&(U===F&&(U=At(U)),It(U,e.ADD_TAGS,De))),_t(e,"ADD_ATTR")&&("function"==typeof e.ADD_ATTR?Q.attributeCheck=e.ADD_ATTR:dt(e.ADD_ATTR)&&(G===V&&(G=At(G)),It(G,e.ADD_ATTR,De))),_t(e,"ADD_URI_SAFE_ATTR")&&dt(e.ADD_URI_SAFE_ATTR)&&It(ye,e.ADD_URI_SAFE_ATTR,De),_t(e,"FORBID_CONTENTS")&&dt(e.FORBID_CONTENTS)&&(fe===me&&(fe=At(fe)),It(fe,e.FORBID_CONTENTS,De)),_t(e,"ADD_FORBID_CONTENTS")&&dt(e.ADD_FORBID_CONTENTS)&&(fe===me&&(fe=At(fe)),It(fe,e.ADD_FORBID_CONTENTS,De)),pe&&(U["#text"]=!0),ie&&It(U,["html","head","body"]),U.table&&(It(U,["tbody"]),delete W.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw Tt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw Tt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const t=v;v=e.TRUSTED_TYPES_POLICY;try{T=S("")}catch(e){throw v=t,e}}else void 0===v&&null!==e.TRUSTED_TYPES_POLICY&&(v=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const s="dompurify"+(n?"#"+n:"");try{return e.createPolicy(s,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+s+" could not be created."),null}}(p,r)),v&&"string"==typeof T&&(T=S(""));(D.uponSanitizeElement.length>0||D.uponSanitizeAttribute.length>0)&&U===F&&(U=At(U)),D.uponSanitizeAttribute.length>0&&G===V&&(G=At(G)),Je&&Je(e),Oe=e},Pe=It({},[...Mt,...Dt,...Ot]),$e=It({},[...Nt,...zt]),qe=function(e){lt(n.removed,{element:e});try{x(e).removeChild(e)}catch(t){f(e)}},He=function(e,t){try{lt(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){lt(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(ae||oe)try{qe(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},je=function(e){let t=null,n=null;if(re)e="<remove></remove>"+e;else{const t=ut(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===Le&&Te===ve&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const s=v?S(e):e;if(Te===ve)try{t=(new h).parseFromString(s,Le)}catch(e){}if(!t||!t.documentElement){t=R.createDocument(Te,"template",null);try{t.documentElement.innerHTML=Ee?T:s}catch(e){}}const r=t.body||t.documentElement;return e&&n&&r.insertBefore(i.createTextNode(n),r.childNodes[0]||null),Te===ve?L.call(t,ie?"html":"body")[0]:ie?t.documentElement:r},Ue=function(e){return A.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Fe=function(e){var t,n;e.normalize();const i=A.call(e.ownerDocument||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let s=i.nextNode();for(;s;){let e=s.data;rt([O,N,z],t=>{e=gt(e,t," ")}),s.data=e,s=i.nextNode()}const r=null!==(t=null===(n=e.querySelectorAll)||void 0===n?void 0:n.call(e,"template"))&&void 0!==t?t:[];rt(Array.from(r),e=>{Ve(e.content)&&Fe(e.content)})},Ge=function(e){const t=w?w(e):null;return"string"==typeof t&&("form"===De(t)&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||e.attributes!==k(e)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes||e.nodeType!==_(e)||e.childNodes!==b(e)))},Ve=function(e){if(!_||"object"!=typeof e||null===e)return!1;try{return _(e)===sn}catch(e){return!1}},Ye=function(e){if(!_||"object"!=typeof e||null===e)return!1;try{return"number"==typeof _(e)}catch(e){return!1}};function Xe(e,t,i){rt(e,e=>{e.call(n,t,i,Oe)})}const Qe=function(e){let t=null;if(Xe(D.beforeSanitizeElements,e,null),Ge(e))return qe(e),!0;const i=De(w?w(e):e.nodeName);if(Xe(D.uponSanitizeElement,e,{tagName:i,allowedTags:U}),ne&&e.hasChildNodes()&&!Ye(e.firstElementChild)&&vt(/<[/\w!]/g,e.innerHTML)&&vt(/<[/\w!]/g,e.textContent))return qe(e),!0;if(ne&&e.namespaceURI===ve&&"style"===i&&Ye(e.firstElementChild))return qe(e),!0;if(e.nodeType===en)return qe(e),!0;if(ne&&e.nodeType===tn&&vt(/<[/\w]/g,e.data))return qe(e),!0;if(W[i]||!(Q.tagCheck instanceof Function&&Q.tagCheck(i))&&!U[i]){if(!W[i]&&et(i)){if(Y.tagNameCheck instanceof RegExp&&vt(Y.tagNameCheck,i))return!1;if(Y.tagNameCheck instanceof Function&&Y.tagNameCheck(i))return!1}if(pe&&!fe[i]){const t=x(e),n=b(e);if(n&&t){for(let i=n.length-1;i>=0;--i){const s=g(n[i],!0);t.insertBefore(s,m(e))}}}return qe(e),!0}return((_?_(e):e.nodeType)!==Kt||function(e){let t=x(e);t&&t.tagName||(t={namespaceURI:Te,tagName:"template"});const n=ht(e.tagName),i=ht(t.tagName);return!!Se[e.namespaceURI]&&(e.namespaceURI===we?t.namespaceURI===ve?"svg"===n:t.namespaceURI===_e?"svg"===n&&("annotation-xml"===i||Re[i]):Boolean(Pe[n]):e.namespaceURI===_e?t.namespaceURI===ve?"math"===n:t.namespaceURI===we?"math"===n&&Ae[i]:Boolean($e[n]):e.namespaceURI===ve?!(t.namespaceURI===we&&!Ae[i])&&!(t.namespaceURI===_e&&!Re[i])&&!$e[n]&&(Ce[n]||!Pe[n]):!("application/xhtml+xml"!==Le||!Se[e.namespaceURI]))}(e))&&("noscript"!==i&&"noembed"!==i&&"noframes"!==i||!vt(/<\/no(script|embed|frames)/i,e.innerHTML))?(te&&e.nodeType===Jt&&(t=e.textContent,rt([O,N,z],e=>{t=gt(t,e," ")}),e.textContent!==t&&(lt(n.removed,{element:e.cloneNode()}),e.textContent=t)),Xe(D.afterSanitizeElements,e,null),!1):(qe(e),!0)},Ze=function(e,t,n){if(X[t])return!1;if(ce&&("id"===t||"name"===t)&&(n in i||n in Ne))return!1;const s=G[t]||Q.attributeCheck instanceof Function&&Q.attributeCheck(t,e);if(K&&!X[t]&&vt(B,t));else if(Z&&vt(P,t));else if(!s||X[t]){if(!(et(e)&&(Y.tagNameCheck instanceof RegExp&&vt(Y.tagNameCheck,e)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck(e))&&(Y.attributeNameCheck instanceof RegExp&&vt(Y.attributeNameCheck,t)||Y.attributeNameCheck instanceof Function&&Y.attributeNameCheck(t,e))||"is"===t&&Y.allowCustomizedBuiltInElements&&(Y.tagNameCheck instanceof RegExp&&vt(Y.tagNameCheck,n)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck(n))))return!1}else if(ye[t]);else if(vt(j,gt(n,q,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==ft(n,"data:")||!be[e]){if(J&&!vt($,gt(n,q,"")));else if(n)return!1}else;return!0},Ke=It({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),et=function(e){return!Ke[ht(e)]&&vt(H,e)},nt=function(e){Xe(D.beforeSanitizeAttributes,e,null);const t=e.attributes;if(!t||Ge(e))return;const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:G,forceKeepAttr:void 0};let s=t.length;for(;s--;){const r=t[s],a=r.name,o=r.namespaceURI,l=r.value,c=De(a),d=l;let h="value"===a?d:mt(d);if(i.attrName=c,i.attrValue=h,i.keepAttr=!0,i.forceKeepAttr=void 0,Xe(D.uponSanitizeAttribute,e,i),h=i.attrValue,!de||"id"!==c&&"name"!==c||0===ft(h,he)||(He(a,e),h=he+h),ne&&vt(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,h)){He(a,e);continue}if("attributename"===c&&ut(h,"href")){He(a,e);continue}if(i.forceKeepAttr)continue;if(!i.keepAttr){He(a,e);continue}if(!ee&&vt(/\/>/i,h)){He(a,e);continue}te&&rt([O,N,z],e=>{h=gt(h,e," ")});const u=De(e.nodeName);if(Ze(u,c,h)){if(v&&"object"==typeof p&&"function"==typeof p.getAttributeType)if(o);else switch(p.getAttributeType(u,c)){case"TrustedHTML":h=S(h);break;case"TrustedScriptURL":h=v.createScriptURL(h)}if(h!==d)try{o?e.setAttributeNS(o,a,h):e.setAttribute(a,h),Ge(e)?qe(e):ot(n.removed)}catch(t){He(a,e)}}else He(a,e)}Xe(D.afterSanitizeAttributes,e,null)},it=function(e){let t=null;const n=Ue(e);for(Xe(D.beforeSanitizeShadowDOM,e,null);t=n.nextNode();){Xe(D.uponSanitizeShadowNode,t,null),Qe(t),nt(t),Ve(t.content)&&it(t.content);if((_?_(t):t.nodeType)===Kt){const e=y?y(t):t.shadowRoot;Ve(e)&&(st(e),it(e))}}Xe(D.afterSanitizeShadowDOM,e,null)},st=function(e){const t=_?_(e):e.nodeType;if(t===Kt){const t=y?y(e):e.shadowRoot;Ve(t)&&(st(t),it(t))}const n=b?b(e):e.childNodes;if(!n)return;const i=[];rt(n,e=>{lt(i,e)});for(const e of i)st(e);if(t===Kt){const t=w?w(e):null;if("string"==typeof t&&"template"===De(t)){const t=e.content;Ve(t)&&st(t)}}};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null,r=null,a=null,o=null;if(Ee=!e,Ee&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Ye(e)&&"string"!=typeof(e=function(e){switch(typeof e){case"string":return e;case"number":return bt(e);case"boolean":return xt(e);case"bigint":return yt?yt(e):"0";case"symbol":return kt?kt(e):"Symbol()";case"undefined":default:return wt(e);case"function":case"object":{if(null===e)return wt(e);const t=e,n=Ct(t,"toString");if("function"==typeof n){const e=n(t);return"string"==typeof e?e:wt(e)}return wt(e)}}}(e)))throw Tt("dirty is not a string, aborting");if(!n.isSupported)return e;if(se||Be(t),n.removed=[],"string"==typeof e&&(ue=!1),ue){const t=w?w(e):e.nodeName;if("string"==typeof t){const e=De(t);if(!U[e]||W[e])throw Tt("root node is forbidden and cannot be sanitized in-place")}if(Ge(e))throw Tt("root node is clobbered and cannot be sanitized in-place");st(e)}else if(Ye(e))i=je("\x3c!----\x3e"),r=i.ownerDocument.importNode(e,!0),r.nodeType===Kt&&"BODY"===r.nodeName||"HTML"===r.nodeName?i=r:i.appendChild(r),st(r);else{if(!ae&&!te&&!ie&&-1===e.indexOf("<"))return v&&le?S(e):e;if(i=je(e),!i)return ae?null:le?T:""}i&&re&&qe(i.firstChild);const l=Ue(ue?e:i);for(;a=l.nextNode();)Qe(a),nt(a),Ve(a.content)&&it(a.content);if(ue)return te&&Fe(e),e;if(ae){if(te&&Fe(i),oe)for(o=C.call(i.ownerDocument);i.firstChild;)o.appendChild(i.firstChild);else o=i;return(G.shadowroot||G.shadowrootmode)&&(o=M.call(s,o,!0)),o}let c=ie?i.outerHTML:i.innerHTML;return ie&&U["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&vt(Qt,i.ownerDocument.doctype.name)&&(c="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+c),te&&rt([O,N,z],e=>{c=gt(c,e," ")}),v&&le?S(c):c},n.setConfig=function(){Be(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),se=!0},n.clearConfig=function(){Oe=null,se=!1},n.isValidAttribute=function(e,t,n){Oe||Be({});const i=De(e),s=De(t);return Ze(i,s,n)},n.addHook=function(e,t){"function"==typeof t&<(D[e],t)},n.removeHook=function(e,t){if(void 0!==t){const n=at(D[e],t);return-1===n?void 0:ct(D[e],n,1)[0]}return ot(D[e])},n.removeHooks=function(e){D[e]=[]},n.removeAllHooks=function(){D={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}();const on=["请求已受理","任务已受理","正在思考","正在执行","结果处理中","已进入助手运行时","任务运行时","SSE 连接已建立"],ln="96px";Ge.setOptions({breaks:!0,gfm:!0,headerIds:!1,mangle:!1});const cn={primary:"--ai-primary",primaryLight:"--ai-primary-light",primaryDark:"--ai-primary-dark",secondary:"--ai-secondary",background:"--ai-bg",backgroundGradient:"--ai-bg-gradient",text:"--ai-text",textSecondary:"--ai-text-secondary",userBubble:"--ai-user-bubble-gradient",aiBubble:"--ai-ai-bubble-bg",headerGradient:"--ai-header-gradient",border:"--ai-border",shadow:"--ai-shadow",inputBackground:"--ai-input-bg",inputBorder:"--ai-input-border",loading:"--ai-loading",success:"--ai-success",error:"--ai-error",warning:"--ai-warning"},dn={DEFAULT:{colors:{primary:"#1890ff",primaryLight:"#40a9ff",primaryDark:"#096dd9",secondary:"#722ed1",background:"#ffffff",backgroundGradient:"#f8fafc",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #1890ff, #40a9ff)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(24,144,255,0.08), rgba(114,46,209,0.08))",border:"rgba(24,144,255,0.15)",shadow:"rgba(24,144,255,0.12)",inputBackground:"#f8fafc",inputBorder:"#e2e8f0"}},DARK:{colors:{primary:"#40a9ff",primaryLight:"#69c0ff",primaryDark:"#1890ff",secondary:"#9254de",background:"#0f172a",backgroundGradient:"#1e293b",text:"#f1f5f9",textSecondary:"#94a3b8",userBubble:"linear-gradient(135deg, #1890ff, #40a9ff)",aiBubble:"#1e293b",headerGradient:"linear-gradient(90deg, rgba(64,169,255,0.15), rgba(146,84,222,0.15))",border:"rgba(64,169,255,0.3)",shadow:"rgba(0,0,0,0.3)",inputBackground:"#1e293b",inputBorder:"#334155"}},FRESH:{colors:{primary:"#52c41a",primaryLight:"#73d13d",primaryDark:"#389e0d",secondary:"#1890ff",background:"#ffffff",backgroundGradient:"#f6ffed",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #52c41a, #73d13d)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(82,196,26,0.08), rgba(24,144,255,0.08))",border:"rgba(82,196,26,0.15)",shadow:"rgba(82,196,26,0.12)",inputBackground:"#f6ffed",inputBorder:"#d9f7be"}},VIBRANT:{colors:{primary:"#fa8c16",primaryLight:"#ffa940",primaryDark:"#d46b08",secondary:"#f5222d",background:"#ffffff",backgroundGradient:"#fff7e6",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #fa8c16, #ffa940)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(250,140,22,0.08), rgba(245,34,45,0.08))",border:"rgba(250,140,22,0.15)",shadow:"rgba(250,140,22,0.12)",inputBackground:"#fff7e6",inputBorder:"#ffd591"}},ROMANTIC:{colors:{primary:"#eb2f96",primaryLight:"#fb6f92",primaryDark:"#c41d7f",secondary:"#722ed1",background:"#ffffff",backgroundGradient:"#fff0f6",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #eb2f96, #fb6f92)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(235,47,150,0.08), rgba(114,46,209,0.08))",border:"rgba(235,47,150,0.15)",shadow:"rgba(235,47,150,0.12)",inputBackground:"#fff0f6",inputBorder:"#ffadd2"}},PURPLE:{colors:{primary:"#722ed1",primaryLight:"#9254de",primaryDark:"#531dab",secondary:"#1890ff",background:"#ffffff",backgroundGradient:"#f9f0ff",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #722ed1, #9254de)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(114,46,209,0.08), rgba(24,144,255,0.08))",border:"rgba(114,46,209,0.15)",shadow:"rgba(114,46,209,0.12)",inputBackground:"#f9f0ff",inputBorder:"#d3adf7"}},OCEAN:{colors:{primary:"#0077b6",primaryLight:"#00b4d8",primaryDark:"#023e8a",secondary:"#00b4d8",background:"#ffffff",backgroundGradient:"#f0f9ff",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #0077b6, #00b4d8)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(0,119,182,0.08), rgba(0,180,216,0.08))",border:"rgba(0,119,182,0.15)",shadow:"rgba(0,119,182,0.12)",inputBackground:"#f0f9ff",inputBorder:"#bae6fd"}},TWILIGHT:{colors:{primary:"#9333ea",primaryLight:"#a855f7",primaryDark:"#7e22ce",secondary:"#ec4899",background:"#ffffff",backgroundGradient:"#faf5ff",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #9333ea, #ec4899)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(147,51,234,0.08), rgba(236,72,153,0.08))",border:"rgba(147,51,234,0.15)",shadow:"rgba(147,51,234,0.12)",inputBackground:"#faf5ff",inputBorder:"#e9d5ff"}},MINT:{colors:{primary:"#14b8a6",primaryLight:"#2dd4bf",primaryDark:"#0d9488",secondary:"#06b6d4",background:"#ffffff",backgroundGradient:"#f0fdfa",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #14b8a6, #2dd4bf)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(20,184,166,0.08), rgba(6,182,212,0.08))",border:"rgba(20,184,166,0.15)",shadow:"rgba(20,184,166,0.12)",inputBackground:"#f0fdfa",inputBorder:"#99f6e4"}},ROSE:{colors:{primary:"#e11d48",primaryLight:"#fb7185",primaryDark:"#be123c",secondary:"#f43f5e",background:"#ffffff",backgroundGradient:"#fff1f2",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #e11d48, #fb7185)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(225,29,72,0.08), rgba(244,63,94,0.08))",border:"rgba(225,29,72,0.15)",shadow:"rgba(225,29,72,0.12)",inputBackground:"#fff1f2",inputBorder:"#fecdd3"}},AURORA:{colors:{primary:"#0ea5e9",primaryLight:"#38bdf8",primaryDark:"#0284c7",secondary:"#10b981",background:"#ffffff",backgroundGradient:"#f0f9ff",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #0ea5e9, #10b981)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(14,165,233,0.08), rgba(16,185,129,0.08))",border:"rgba(14,165,233,0.15)",shadow:"rgba(14,165,233,0.12)",inputBackground:"#f0f9ff",inputBorder:"#bae6fd"}},LAVENDER:{colors:{primary:"#8b5cf6",primaryLight:"#a78bfa",primaryDark:"#7c3aed",secondary:"#c084fc",background:"#ffffff",backgroundGradient:"#faf5ff",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #8b5cf6, #c084fc)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(139,92,246,0.08), rgba(192,132,252,0.08))",border:"rgba(139,92,246,0.15)",shadow:"rgba(139,92,246,0.12)",inputBackground:"#faf5ff",inputBorder:"#ddd6fe"}},CORAL:{colors:{primary:"#f97316",primaryLight:"#fb923c",primaryDark:"#ea580c",secondary:"#f43f5e",background:"#ffffff",backgroundGradient:"#fff7ed",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #f97316, #fb923c)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(249,115,22,0.08), rgba(244,63,94,0.08))",border:"rgba(249,115,22,0.15)",shadow:"rgba(249,115,22,0.12)",inputBackground:"#fff7ed",inputBorder:"#fed7aa"}},JADE:{colors:{primary:"#059669",primaryLight:"#10b981",primaryDark:"#047857",secondary:"#34d399",background:"#ffffff",backgroundGradient:"#f0fdf4",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #059669, #10b981)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(5,150,105,0.08), rgba(52,211,153,0.08))",border:"rgba(5,150,105,0.15)",shadow:"rgba(5,150,105,0.12)",inputBackground:"#f0fdf4",inputBorder:"#bbf7d0"}},STARSKY:{colors:{primary:"#6366f1",primaryLight:"#818cf8",primaryDark:"#4f46e5",secondary:"#a855f7",background:"#0f172a",backgroundGradient:"#1e1b4b",text:"#e2e8f0",textSecondary:"#94a3b8",userBubble:"linear-gradient(135deg, #6366f1, #a855f7)",aiBubble:"#1e1b4b",headerGradient:"linear-gradient(90deg, rgba(99,102,241,0.15), rgba(168,85,247,0.15))",border:"rgba(99,102,241,0.3)",shadow:"rgba(0,0,0,0.3)",inputBackground:"#1e1b4b",inputBorder:"#312e81"}},SUNSET:{colors:{primary:"#ea580c",primaryLight:"#f97316",primaryDark:"#c2410c",secondary:"#dc2626",background:"#ffffff",backgroundGradient:"#fff8f0",text:"#1e293b",textSecondary:"#64748b",userBubble:"linear-gradient(135deg, #ea580c, #dc2626)",aiBubble:"#ffffff",headerGradient:"linear-gradient(90deg, rgba(234,88,12,0.08), rgba(220,38,38,0.08))",border:"rgba(234,88,12,0.15)",shadow:"rgba(234,88,12,0.12)",inputBackground:"#fff8f0",inputBorder:"#fed7aa"}}};class hn extends HTMLElement{static get observedAttributes(){return["visible"]}constructor(){super(),this.attachShadow({mode:"open"}),this._messages=[],this._isLoading=!1,this._config=null,this._mockMode=!1,this._isDragging=!1,this._isExpanded=!1,this._chatClient=null,this._attachments=[],this._dragStartX=0,this._dragStartY=0,this._dialogX=0,this._dialogY=0,this._appDetail=null,this._historyVisible=!1,this._historyRecords=[],this._historyLoading=!1,this._historyLoaded=!1,this._historyPageIndex=1,this._historyHasMore=!1,this._isMobile=!1,this._streamTextEl=null,this._streamInitDone=!1,this._streamFullText="",this._streamVisibleLength=0,this._streamTypeRaf=null,this._streaming=!1,this._runtimePanelEl=null,this._runtimeEventsContainerEl=null,this._runtimeStatusEl=null,this._runtimeCountEl=null,this._themeVars={"--ai-primary":"#1890ff","--ai-primary-light":"#40a9ff","--ai-primary-dark":"#096dd9","--ai-secondary":"#722ed1","--ai-bg":"#ffffff","--ai-bg-gradient":"#f8fafc","--ai-text":"#1e293b","--ai-text-secondary":"#64748b","--ai-user-bubble-gradient":"linear-gradient(135deg, #1890ff, #40a9ff)","--ai-ai-bubble-bg":"#ffffff","--ai-header-gradient":"linear-gradient(90deg, rgba(24, 144, 255, 0.08), rgba(114, 46, 209, 0.08))","--ai-border":"rgba(24, 144, 255, 0.15)","--ai-shadow":"rgba(24, 144, 255, 0.12)","--ai-input-bg":"#f8fafc","--ai-input-border":"#e2e8f0","--ai-loading":"#64748b","--ai-success":"#52c41a","--ai-error":"#ff4d4f","--ai-warning":"#faad14","--ai-radius-dialog":"16px","--ai-radius-bubble":"18px","--ai-radius-button":"50%","--ai-radius-input":"28px","--ai-radius-small":"6px","--ai-radius-medium":"12px","--ai-font-title":"15px","--ai-font-welcome-text":"17px","--ai-font-welcome-desc":"13px","--ai-font-message":"14px","--ai-font-time":"11px","--ai-font-small":"11px","--ai-shadow-dialog":"0 0 30px rgba(24, 144, 255, 0.12), 0 8px 32px rgba(0, 0, 0, 0.1)","--ai-shadow-bubble":"0 2px 8px rgba(0, 0, 0, 0.06)","--ai-shadow-user-bubble":"0 4px 12px rgba(24, 144, 255, 0.25)","--ai-shadow-button":"0 4px 12px rgba(24, 144, 255, 0.35)"},this.render(),this.bindEvents()}connectedCallback(){this._handleOnline=()=>{const e=this.shadowRoot.querySelector(".network-tip");e&&e.remove()},this._handleOffline=()=>{if(!this.shadowRoot.querySelector(".network-tip")){const e=document.createElement("div");e.className="network-tip",e.textContent="网络连接已断开,请检查网络后重试",this._dialog?.prepend(e),setTimeout(()=>e.remove(),5e3)}},window.addEventListener("online",this._handleOnline),window.addEventListener("offline",this._handleOffline),this._detectMobile(),this._handleResize=()=>{const e=this._isMobile;this._detectMobile(),e!==this._isMobile&&this._dialog&&this._applyMobileLayout()},window.addEventListener("resize",this._handleResize),this._chatClient&&this._chatClient.startBackgroundRefresh()}disconnectedCallback(){this._handleOnline&&window.removeEventListener("online",this._handleOnline),this._handleOffline&&window.removeEventListener("offline",this._handleOffline),this._handleResize&&window.removeEventListener("resize",this._handleResize),this._chatClient&&(this._chatClient.stopBackgroundRefresh(),this._chatClient.cancelCurrentRequest())}_detectMobile(){if(void 0!==this._config?.mobileMode)return void(this._isMobile=!!this._config.mobileMode);if("undefined"!=typeof wx&&wx.getSystemInfoSync)return void(this._isMobile=!0);if("undefined"==typeof window)return void(this._isMobile=!1);const e=navigator.userAgent||"",t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(e),n=window.innerWidth<768,i="ontouchstart"in window||navigator.maxTouchPoints>0;this._isMobile=t||n&&i}_applyMobileLayout(){this._dialog&&(this._isMobile?(this._dialog.style.width="100vw",this._dialog.style.height="100vh",this._dialog.style.maxHeight="none",this._dialog.style.minHeight="0",this._dialog.style.left="0",this._dialog.style.top="0",this._dialog.style.right="auto",this._dialog.style.bottom="auto",this._dialog.style.borderRadius="0",this._dialog.classList.add("mobile-mode"),this._expandBtn&&(this._expandBtn.style.display="none")):(this._isExpanded||(this._dialog.style.width="min(420px, calc(100vw - 48px))",this._dialog.style.height="min(640px, 80vh)",this._dialog.style.maxHeight="",this._dialog.style.minHeight="",this._dialog.style.left=this._dialogX?this._dialogX+"px":"auto",this._dialog.style.right=this._dialogX?"auto":"24px",this._dialog.style.top=this._dialogY?this._dialogY+"px":ln,this._dialog.style.bottom="auto"),this._dialog.classList.remove("mobile-mode"),this._dialog.style.borderRadius="",this._expandBtn&&(this._expandBtn.style.display="")))}attributeChangedCallback(e,t,n){if("visible"===e){this.hasAttribute("visible")?this.showDialog():this.hideDialog()}}get visible(){return this.hasAttribute("visible")}set visible(e){e?this.setAttribute("visible",""):this.removeAttribute("visible")}get messages(){return this._messages}get isLoading(){return this._isLoading}get config(){return this._config}init(e={}){return this._config={apiBaseUrl:"",apiEndpoint:"/v1/app/completion",streamEndpoint:"/v1/app/completion/stream",stopEndpoint:"/v1/app/completion/stop",attachmentUploadEndpoint:"/v1/app/attachment/upload",conversationQueryEndpoint:"/v1/app/conversation/query",conversationDeleteEndpoint:"/v1/app/conversation/delete",appDetailEndpoint:"/v1/app/{appId}",appId:"",userId:"",bizType:"",token:"",refreshToken:"",tokenExpiresAt:0,tokenRefreshBufferMs:6e4,refreshTokenFn:null,onTokenRefreshed:null,onTokenExpired:null,authErrorCodes:[],title:"AI 助手",welcomeText:"Hi,我是智能助手 ~\n欢迎随时提问",welcomeDesc:"全新自动化能力上线:任务交给我,自动帮你搞定!",footerDisclaimer:"推荐和回答由 AI 生成,仅供参考",footerIdentity:"",theme:"default",enableDrag:!0,headers:{},extendInfo:{},timeout:6e4,maxRetries:3,maxLength:500,maxMessages:50,historyPageSize:20,historyDays:30,mobileMode:void 0,authFn:null,onLoad:null,onError:null,suggestions:[{label:"帮我购买一台轻量应用服务器用于部署应用",value:"帮我购买一台轻量应用服务器用于部署应用"},{label:"帮我为我的域名申请并配置SSL证书",value:"帮我为我的域名申请并配置SSL证书"}],...e},!this._config.appId&&this._config.agentAppId&&(this._config.appId=this._config.agentAppId),this._chatClient=new S(this._config),this._conversationId&&this._chatClient.setConversationId(this._conversationId),this.applyConfig(),this.loadAppDetail(),this._config?.onLoad&&this._config.onLoad(this),this.dispatchEvent(new CustomEvent("init",{detail:{config:this._config}})),this}open(){return this.visible=!0,this._config?.onOpen&&this._config.onOpen(),this.dispatchEvent(new CustomEvent("open")),this}close(){return this.visible=!1,this._isExpanded=!1,this._config?.onClose&&this._config.onClose(),this.dispatchEvent(new CustomEvent("close")),this}toggle(e){return this.visible=void 0!==e?!!e:!this.visible,this}destroy(){this._chatClient&&this._chatClient.dispose(),this.parentNode&&this.parentNode.removeChild(this)}addMessage(e){if(!e||!e.content)return this;const t={id:e.id||`msg_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,type:e.type||("user"===e.role?"user":"ai"),content:e.content,time:e.time||e.timestamp||this.formatTime(),copied:!1,errorType:e.errorType||null,...e};this._messages.push(t);const n=this._config?.maxMessages??50;return this._messages.length>n&&(this._messages=this._messages.slice(-n)),this.renderMessages({forceScroll:!0}),this}clearMessages(){return this._messages=[],this.renderMessages(),this}setLoading(e){return this._isLoading=e,this.updateLoadingUI(),this.dispatchEvent(new CustomEvent("loading-change",{detail:{loading:e}})),this}updateConfig(e){return this._config?(Object.assign(this._config,e),!this._config.appId&&this._config.agentAppId&&(this._config.appId=this._config.agentAppId),this._chatClient&&this._chatClient.updateConfig(this._config),this.loadAppDetail()):this.init(e),this.applyConfig(),this}enableMockMode(){return this._mockMode=!0,this}disableMockMode(){return this._mockMode=!1,this}showDialog(){const e=this.shadowRoot.querySelector(".ai-chat-dialog"),t=this.shadowRoot.querySelector(".float-button");e&&e.classList.add("dialog-visible"),t&&(t.style.display="none"),e&&this._applyMobileLayout()}hideDialog(){const e=this.shadowRoot.querySelector(".ai-chat-dialog"),t=this.shadowRoot.querySelector(".float-button");e&&e.classList.remove("dialog-visible"),t&&(t.style.display="flex")}render(){const e=Object.entries(this._themeVars).map(([e,t])=>`${e}:${t};`).join("\n ");this.shadowRoot.innerHTML=`\n<style>\n /* ====== CSS 变量(与Vue版DEFAULT_THEME一致) ====== */\n :host {\n ${e}\n display: block;\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n z-index: 1000;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;\n --ai-primary: #2563eb;\n --ai-primary-light: #3b82f6;\n --ai-primary-dark: #1d4ed8;\n --ai-secondary: #475569;\n --ai-bg: #ffffff;\n --ai-bg-gradient: #f8fafc;\n --ai-text: #111827;\n --ai-text-secondary: #64748b;\n --ai-border: #e5e7eb;\n --ai-shadow: rgba(15, 23, 42, 0.08);\n --ai-input-bg: #ffffff;\n --ai-input-border: #d8dee8;\n --ai-radius-dialog: 0;\n --ai-radius-bubble: 10px;\n }\n\n /* ====== 外层容器(与Vue .ai-float-container 一致) ====== */\n .ai-float-container { position: relative; }\n\n /* ====== 对话框主体(与Vue .ai-chat-dialog 完全一致) ====== */\n .ai-chat-dialog {\n position: fixed;\n top: 96px;\n right: 24px;\n bottom: auto;\n width: min(420px, calc(100vw - 48px));\n height: min(640px, 80vh);\n background: var(--ai-bg);\n border-radius: 16px;\n border: 1px solid rgba(226, 232, 240, 0.78);\n box-shadow: 0 18px 44px rgba(15, 23, 42, 0.16);\n display: flex;\n flex-direction: column;\n min-height: 0;\n overflow: hidden;\n transition: opacity 0.26s ease, transform 0.26s ease;\n backdrop-filter: none;\n opacity: 0;\n transform: translateX(18px);\n pointer-events: none;\n }\n /* 显示状态 */\n .ai-chat-dialog.dialog-visible {\n opacity: 1;\n transform: translateX(0);\n pointer-events: auto;\n }\n\n /* 外发光效果(::before 伪元素)*/\n .ai-chat-dialog::before {\n display: none;\n }\n .ai-chat-dialog:not(.expanded) { cursor: default; }\n .ai-chat-dialog.dragging { transition: none; }\n\n /* ========== 头部样式(与Vue .dialog-header 完全一致) ========== */\n .dialog-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n min-height: 54px;\n padding: 0 16px 0 20px;\n background: #ffffff;\n color: var(--ai-text);\n cursor: default;\n user-select: none;\n position: relative;\n flex-shrink: 0;\n }\n /* 底部微妙阴影分隔 */\n .dialog-header::after { display: none; }\n .ai-chat-dialog.expanded .dialog-header { cursor: default; }\n .dialog-header:active { cursor: grabbing; }\n .header-left {\n display: flex;\n align-items: center;\n min-width: 0;\n }\n .robot-icon {\n display: none;\n }\n @keyframes gentlePulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }\n .header-title {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: 15px;\n font-weight: 650;\n color: var(--ai-text);\n letter-spacing: 0;\n }\n .header-right { display: flex; align-items: center; gap: 8px; margin-left: 12px; }\n .header-icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 24px;\n font-size: 14px;\n cursor: pointer;\n color: var(--ai-text-secondary);\n transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);\n border-radius: 6px;\n background: transparent;\n border: none;\n }\n .new-chat-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 24px;\n border-radius: 6px;\n border: none;\n background: transparent;\n color: var(--ai-text-secondary);\n cursor: pointer;\n padding: 0;\n transition: color 0.18s ease, background 0.18s ease;\n }\n .new-chat-btn:hover {\n color: #111827;\n background: #f3f4f6;\n }\n .new-chat-btn svg {\n width: 20px;\n height: 20px;\n stroke: currentColor;\n }\n .history-btn svg {\n width: 19px;\n height: 19px;\n stroke: currentColor;\n }\n .header-icon svg {\n width: 20px;\n height: 20px;\n flex-shrink: 0;\n }\n .header-icon svg path { stroke: currentColor; fill: none; }\n .header-icon:hover {\n color: #111827;\n background: #f3f4f6;\n }\n\n /* ========== 主体样式(与Vue .dialog-body 完全一致) ========== */\n .dialog-body {\n flex: 1;\n flex-basis: 0;\n min-height: 0;\n overflow-y: auto;\n overscroll-behavior: contain;\n -webkit-overflow-scrolling: touch;\n padding: 18px 28px 22px;\n background: linear-gradient(180deg, #f7faff 0, #ffffff 184px);\n scrollbar-width: thin;\n scrollbar-color: transparent transparent;\n }\n .dialog-body::-webkit-scrollbar { width: 4px; }\n .dialog-body::-webkit-scrollbar-track { background: transparent; }\n .dialog-body::-webkit-scrollbar-thumb {\n background: var(--ai-border);\n border-radius: 10px;\n opacity: 0.3;\n }\n .dialog-body::-webkit-scrollbar-thumb:hover { opacity: 0.6; }\n\n /* ========== 欢迎页(与Vue .empty-state / .welcome-content 完全一致) ========== */\n .empty-state {\n height: 100%;\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n align-items: stretch;\n text-align: left;\n padding: 0 0 18px;\n }\n .welcome-content { margin-bottom: 0; width: 100%; }\n @keyframes floatUp { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }\n\n /* 欢迎标题 - 渐变品牌色 */\n .welcome-text {\n white-space: pre-line;\n font-size: 24px;\n line-height: 1.32;\n margin-bottom: 10px;\n font-weight: 800;\n letter-spacing: 0;\n color: #111827;\n background: none;\n -webkit-text-fill-color: currentColor;\n }\n .welcome-desc {\n font-size: 14px;\n color: var(--ai-text-secondary);\n line-height: 1.58;\n max-width: 360px;\n margin: 0 0 20px;\n }\n\n /* 快捷建议按钮组(与Vue .quick-suggestions / .suggestion-chip 一致) */\n .quick-suggestions {\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n gap: 10px;\n margin-top: 0;\n max-width: none;\n animation: none;\n }\n @keyframes fadeInUp {\n from { opacity: 0; transform: translateY(12px); }\n to { opacity: 1; transform: translateY(0); }\n }\n .suggestion-chip {\n display: inline-flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n width: 100%;\n min-height: 40px;\n padding: 0 18px;\n border-radius: 30px;\n font-size: 12px;\n color: #1f2937;\n background: #ffffff;\n border: 1px solid #dfe5ee;\n cursor: pointer;\n transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;\n white-space: normal;\n user-select: none;\n box-sizing: border-box;\n box-shadow: 0 4px 12px rgba(15, 23, 42, 0.03);\n }\n .suggestion-chip::after {\n content: '→';\n color: #111827;\n font-size: 18px;\n line-height: 1;\n }\n .suggestion-chip:hover {\n color: #111827;\n background: #ffffff;\n border-color: #cbd5e1;\n box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);\n transform: translateY(-1px);\n }\n .suggestion-chip:active { transform: translateY(0) scale(0.97); }\n .suggestion-chip .chip-icon { font-size: 17px; opacity: 0.85; color: #f97316; }\n .suggestion-chip:hover .chip-icon { opacity: 1; }\n\n .history-view {\n height: 100%;\n display: flex;\n flex-direction: column;\n min-height: 0;\n }\n .history-head {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n margin-bottom: 14px;\n }\n .history-title {\n font-size: 15px;\n font-weight: 650;\n color: var(--ai-text);\n }\n .history-back {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n border: none;\n background: transparent;\n color: var(--ai-text-secondary);\n cursor: pointer;\n font-size: 13px;\n padding: 4px 0;\n }\n .history-back:hover { color: var(--ai-primary); }\n .history-list {\n flex: 1;\n min-height: 0;\n overflow-y: auto;\n display: flex;\n flex-direction: column;\n gap: 8px;\n }\n .history-item {\n width: 100%;\n text-align: left;\n border: 1px solid #e5e7eb;\n background: #fff;\n border-radius: 8px;\n padding: 10px 12px;\n cursor: pointer;\n transition: border-color 0.18s ease, background 0.18s ease;\n }\n .history-item:hover {\n border-color: #cbd5e1;\n background: #f8fafc;\n }\n .history-item-title {\n color: #111827;\n font-size: 13px;\n font-weight: 600;\n line-height: 1.45;\n overflow: hidden;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n }\n .history-item-preview {\n margin-top: 5px;\n color: var(--ai-text-secondary);\n font-size: 12px;\n line-height: 1.45;\n overflow: hidden;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n }\n .history-empty,\n .history-loading {\n color: var(--ai-text-secondary);\n font-size: 13px;\n line-height: 1.6;\n padding: 28px 0;\n text-align: center;\n }\n .history-load-more {\n display: block;\n width: 100%;\n margin: 10px 0 0;\n padding: 8px 0;\n border: none;\n border-radius: 8px;\n background: rgba(24, 144, 255, 0.06);\n color: var(--ai-primary, #1890ff);\n font-size: 13px;\n font-weight: 500;\n cursor: pointer;\n transition: background 0.18s ease;\n }\n .history-load-more:hover {\n background: rgba(24, 144, 255, 0.12);\n }\n\n /* ========== 消息列表(与Vue .message-list 一致) ==========*/\n .message-list {\n display: flex;\n flex-direction: column;\n gap: 9px;\n min-height: min-content;\n }\n .message-item {\n display: flex;\n gap: 0;\n max-width: 100%;\n width: 100%;\n animation: messageSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);\n }\n @keyframes messageSlideIn {\n from { opacity: 0; transform: translateY(10px) scale(0.98); }\n to { opacity: 1; transform: translateY(0) scale(1); }\n }\n .message-item.user { justify-content: flex-end; align-self: stretch; }\n .message-item.ai { justify-content: flex-start; align-self: stretch; }\n\n /* ========== 头像(与Vue .message-avatar 一致) ========== */\n .message-avatar {\n display: none;\n }\n .message-item.user .message-avatar {\n background: #eef2ff;\n color: #2563eb;\n box-shadow: none;\n }\n .message-item.ai .message-avatar {\n background: #f1f5f9;\n color: #334155;\n box-shadow: none;\n }\n .message-item.ai .message-avatar::after { display: none; }\n @keyframes avatarGlow {\n from { opacity: 0.4; }\n to { opacity: 0.85; }\n }\n\n .message-content {\n display: flex;\n flex-direction: column;\n gap: 5px;\n min-width: 0;\n }\n .message-item.ai .message-content { width: 100%; }\n .message-item.user .message-content { max-width: 86%; }\n .message-item.user .message-content { align-items: flex-end; }\n\n /* ========== 消息气泡(与Vue .message-bubble 一致) ========== */\n .message-bubble {\n padding: 12px 14px;\n border-radius: 8px;\n font-size: var(--ai-font-message);\n line-height: 1.65;\n word-wrap: break-word;\n }\n .message-item.user .message-bubble {\n background: #eff6ff;\n color: #1e3a8a;\n border: 1px solid #dbeafe;\n border-bottom-right-radius: 8px;\n box-shadow: none;\n }\n .message-item.ai .message-bubble {\n box-sizing: border-box;\n background: #ffffff;\n color: var(--ai-text);\n border: none;\n border-bottom-left-radius: 8px;\n box-shadow: none;\n width: 100%;\n padding: 12px 14px;\n }\n\n /* ========== Markdown 内容样式(marked渲染结果) ========== */\n .message-text {\n overflow-wrap: break-word;\n word-break: break-word;\n }\n .message-text p { margin: 4px 0; }\n .message-text p:first-child { margin-top: 0; }\n .message-text p:last-child { margin-bottom: 0; }\n\n /* 标题 */\n .message-text h1, .message-text h2, .message-text h3,\n .message-text h4, .message-text h5, .message-text h6 {\n margin: 12px 0 6px; font-weight: 600; line-height: 1.4;\n }\n .message-text h1 { font-size: 1.25em; }\n .message-text h2 { font-size: 1.15em; border-bottom: 1px solid var(--ai-border); padding-bottom: 4px; }\n .message-text h3 { font-size: 1.08em; }\n\n /* 行内代码 + 代码块 */\n .message-text code {\n font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', Consolas, monospace;\n font-size: 0.88em;\n background: rgba(24, 144, 255, 0.1);\n color: var(--ai-primary, #1890ff);\n padding: 2px 5px;\n border-radius: 4px;\n }\n .message-text pre {\n margin: 10px 0;\n border-radius: 8px;\n overflow-x: auto;\n background: #1e293b;\n color: #e2e8f0;\n }\n .message-text pre code {\n display: block;\n padding: 12px 14px;\n background: none;\n color: inherit;\n font-size: 0.85em;\n line-height: 1.55;\n border-radius: 0;\n }\n\n /* 列表 */\n .message-text ul, .message-text ol { margin: 8px 0; padding-left: 20px; }\n .message-text li { margin: 3px 0; }\n .message-text li::marker { color: var(--ai-primary, #1890ff); }\n\n /* 引用块 */\n .message-text blockquote {\n margin: 10px 0;\n padding: 8px 14px;\n border-left: 3px solid var(--ai-primary, #1890ff);\n background: rgba(24, 144, 255, 0.05);\n color: var(--ai-text-secondary, #64748b);\n border-radius: 0 6px 6px 0;\n }\n\n /* 表格 */\n .message-text table {\n width: 100%;\n margin: 10px 0;\n border-collapse: collapse;\n font-size: 0.93em;\n }\n .message-text th, .message-text td {\n padding: 7px 10px;\n border: 1px solid var(--ai-border, #e2e8f0);\n text-align: left;\n }\n .message-text th {\n background: rgba(24, 144, 255, 0.08);\n font-weight: 600;\n }\n\n /* 链接 */\n .message-text a {\n color: var(--ai-primary, #1890ff);\n text-decoration: none;\n transition: opacity 0.15s;\n }\n .message-text a:hover { text-decoration: underline; opacity: 0.85; }\n\n /* 分隔线 */\n .message-text hr {\n margin: 12px 0;\n border: none;\n border-top: 1px solid var(--ai-border, #e2e8f0);\n }\n\n /* 图片(限制宽度防撑破) */\n .message-text img {\n max-width: 100%;\n border-radius: 6px;\n margin: 8px 0;\n }\n\n /* 加载状态 - 三点脉冲动画(与Vue一致) */\n .message-bubble.loading {\n display: flex;\n align-items: center;\n gap: 6px;\n color: var(--ai-text-secondary);\n border: none;\n background: transparent;\n padding: 4px 0;\n min-height: 44px;\n }\n .message-bubble.loading .thinking-text {\n color: var(--ai-text-secondary);\n font-size: 13px;\n margin-right: 4px;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif;\n }\n .message-bubble.loading .typing-indicator {\n display: inline-flex;\n align-items: center;\n gap: 5px;\n }\n .message-bubble.loading .typing-dot {\n width: 7px;\n height: 7px;\n border-radius: 50%;\n background: var(--ai-primary);\n animation: typingBounce 1.4s ease-in-out infinite;\n }\n .message-bubble.loading .typing-dot:nth-child(2) { animation-delay: 0s; }\n .message-bubble.loading .typing-dot:nth-child(3) { animation-delay: 0.16s; }\n .message-bubble.loading .typing-dot:nth-child(4) { animation-delay: 0.32s; }\n @keyframes typingBounce {\n 0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }\n 30% { transform: translateY(-8px); opacity: 1; }\n }\n .message-text { margin: 0; word-break: break-word; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif; }\n\n /* ========== 操作栏(与Vue .message-actions-bar 一致) ========== */\n .message-actions-bar {\n display: flex;\n align-items: center;\n justify-content: flex-start;\n gap: 10px;\n margin-top: 8px;\n }\n .action-icons { display: flex; gap: 5px; }\n .action-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n border-radius: 9px;\n cursor: pointer;\n transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n color: var(--ai-text-secondary);\n background: transparent;\n font-size: 14px;\n border: none;\n }\n .action-icon svg {\n width: 16px;\n height: 16px;\n stroke: currentColor;\n flex-shrink: 0;\n }\n .action-icon:hover {\n color: var(--ai-primary);\n background: var(--ai-shadow);\n transform: translateY(-1px);\n }\n .action-icon:active { transform: translateY(0) scale(0.95); }\n .action-icon.copied {\n color: var(--ai-success);\n background: rgba(16, 185, 129, 0.08);\n }\n\n /* ========== 底部输入框(与Vue .dialog-footer 一致) ========== */\n .dialog-footer {\n padding: 8px 18px 14px;\n background: var(--ai-bg);\n position: relative;\n flex-shrink: 0;\n }\n /* 顶部微妙分隔线 */\n .dialog-footer::before {\n content: none;\n position: absolute;\n top: 0;\n left: 24px;\n right: 24px;\n height: 1px;\n background: linear-gradient(90deg, transparent, var(--ai-border), transparent);\n opacity: 0.4;\n }\n\n .input-container {\n position: relative;\n display: flex;\n flex-direction: column;\n width: 100%;\n background: #ffffff;\n border: 1px solid #dfe5ee;\n border-radius: 4px;\n overflow: hidden;\n padding: 0;\n min-height: 86px;\n cursor: text;\n z-index: 2;\n transition: border-color 0.18s ease, box-shadow 0.18s ease;\n box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);\n }\n .input-container:focus-within {\n border-color: var(--ai-primary);\n background: #ffffff;\n box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.07), 0 2px 8px rgba(15, 23, 42, 0.06);\n transform: none;\n }\n .input-container:has(.message-input:disabled) { opacity: 0.55; cursor: not-allowed; }\n\n .message-input {\n width: 100%;\n min-height: 44px;\n max-height: 132px;\n border: none;\n background: transparent;\n font-size: var(--ai-font-message);\n color: var(--ai-text);\n outline: none;\n padding: 10px 12px 6px;\n line-height: 1.5;\n resize: none;\n overflow-y: hidden;\n box-sizing: border-box;\n }\n .message-input::placeholder { color: #9ca3af; font-style: normal; }\n .message-input:disabled { cursor: not-allowed; }\n .attachment-input { display: none; }\n .input-tools {\n display: flex;\n align-items: center;\n justify-content: space-between;\n min-height: 36px;\n padding: 0 8px 8px 8px;\n }\n .input-tool {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n border-radius: 4px;\n border: none;\n color: #4b5563;\n font-size: 17px;\n cursor: pointer;\n }\n .input-tool svg {\n width: 18px;\n height: 18px;\n }\n .input-tool:hover {\n background: #f3f4f6;\n color: #111827;\n }\n .input-tool.has-attachment {\n color: var(--ai-primary);\n background: rgba(37, 99, 235, 0.08);\n }\n .input-tool.attach-tool { display: none; }\n\n /* 发送按钮(与Vue .send-btn 完全一致,含光泽动画)*/\n .send-btn {\n margin-left: auto;\n flex-shrink: 0;\n width: 28px;\n height: 28px;\n border-radius: 50%;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n background: var(--ai-primary);\n color: #fff;\n transition: background 0.18s ease, transform 0.18s ease;\n box-shadow: none;\n overflow: hidden;\n padding: 0;\n }\n .send-btn::before { display: none; }\n .send-btn:hover:not(:disabled) {\n transform: none;\n background: var(--ai-primary);\n box-shadow: none;\n }\n .send-btn:active:not(:disabled) { transform: translateY(0) scale(0.95); }\n .send-btn:disabled {\n background: #e5e7eb;\n cursor: not-allowed;\n color: #94A3B8;\n box-shadow: none;\n }\n .send-btn:disabled::before { display: none; }\n .send-btn svg {\n width: 16px;\n height: 16px;\n position: relative;\n z-index: 1;\n filter: none;\n transform: rotate(-45deg);\n }\n .footer-note {\n display: flex;\n justify-content: space-between;\n gap: 12px;\n padding: 10px 2px 0;\n color: #b5bbc5;\n font-size: 12px;\n line-height: 1;\n }\n .footer-note-left,\n .footer-note-right {\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n }\n\n /* ========== 悬浮按钮(与Vue .float-button 一致,含彩虹边框动画) ========== */\n .float-button {\n position: fixed;\n right: 32px;\n bottom: 24px;\n width: auto;\n height: 44px;\n min-width: 104px;\n gap: 8px;\n padding: 0 16px;\n border-radius: 22px;\n background: #ffffff;\n border: 1px solid #dfe5ee;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n box-shadow: 0 6px 18px rgba(15, 23, 42, 0.1);\n transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;\n z-index: 1;\n overflow: hidden;\n }\n .float-button::before { content: 'AI 助手'; font-size: 14px; font-weight: 600; color: #111827; }\n @keyframes gradientRotate { to { transform: rotate(360deg); } }\n .float-button:hover {\n transform: translateY(-1px);\n border-color: #cbd5e1;\n box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);\n }\n .float-button:hover::before { opacity: 1; animation-play-state: initial; }\n\n /* 错误提示toast */\n .error-toast {\n position: absolute;\n top: 60px;\n left: 50%;\n transform: translateX(-50%);\n background: #fef2f2;\n border: 1px solid #fecaca;\n color: #dc2626;\n padding: 8px 16px;\n border-radius: 10px;\n font-size: 13px;\n z-index: 10;\n white-space: nowrap;\n animation: fadeInOut 3s forwards;\n }\n\n /* P1-8: 网络状态离线提示条 */\n .network-tip {\n position: absolute;\n top: 0; left: 0; right: 0;\n background: #fef3c7;\n border-bottom: 1px solid #fcd34d;\n color: #92400e;\n padding: 8px 12px;\n font-size: 13px;\n text-align: center;\n z-index: 10;\n border-radius: var(--ai-radius-l) var(--ai-radius-l) 0 0;\n }\n\n @keyframes fadeInOut {\n 0% { opacity: 0; transform: translateX(-50%) translateY(-8px); }\n 10% { opacity: 1; transform: translateX(-50%) translateY(0); }\n 80% { opacity: 1; transform: translateX(-50%) translateY(0); }\n 100% { opacity: 0; transform: translateX(-50%) translateY(-8px); }\n }\n\n /* P2-17: JS驱动移动端全屏模式样式(与Vue dialogStyle isMobile分支一致) */\n .ai-chat-dialog.mobile-mode {\n position: fixed !important;\n width: 100vw !important;\n height: 100vh !important;\n left: 0 !important;\n top: 0 !important;\n right: auto !important;\n bottom: auto !important;\n border-radius: 0 !important;\n max-width: none !important;\n max-height: none !important;\n }\n .mobile-mode .dialog-header {\n min-height: calc(54px + env(safe-area-inset-top));\n padding: env(safe-area-inset-top) 14px 0 16px;\n }\n .mobile-mode .header-title { font-size: 15px; }\n .mobile-mode .header-icon { width: 34px; height: 34px; }\n .mobile-mode .new-chat-btn { width: 34px; height: 34px; }\n .mobile-mode .dialog-body { padding: 16px 14px; }\n .mobile-mode .message-item { max-width: 100%; width: 100%; }\n .mobile-mode .message-bubble { padding: 11px 15px; font-size: 14px; }\n .mobile-mode .dialog-footer { padding: 12px 14px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }\n .mobile-mode .input-container { border-radius: 4px; min-height: 86px; }\n .mobile-mode .message-input { font-size: 16px; padding: 10px 12px 6px; } /* iOS防自动缩放 */\n .mobile-mode .send-btn { width: 28px; height: 28px; }\n .mobile-mode .expand-btn { display: none !important; } /* 移动端隐藏展开按钮 */\n\n /* ========== 执行过程面板 ========== */\n .runtime-panel {\n margin-top: 8px;\n border: 1px solid rgba(24, 144, 255, 0.12);\n background: linear-gradient(180deg, rgba(248, 250, 252, 0.96), rgba(255, 255, 255, 0.96));\n border-radius: 10px;\n overflow: hidden;\n }\n .runtime-header {\n display: grid;\n grid-template-columns: auto 1fr auto auto;\n align-items: center;\n gap: 8px;\n padding: 9px 10px;\n font-size: 12px;\n color: var(--ai-text-secondary, #64748b);\n cursor: pointer;\n user-select: none;\n }\n .runtime-header:hover { color: var(--ai-primary, #1890ff); }\n .runtime-header .arrow { transition: transform 0.2s; font-size: 10px; }\n .runtime-header .arrow.expanded { transform: rotate(90deg); }\n .runtime-title {\n min-width: 0;\n display: flex;\n flex-direction: column;\n gap: 2px;\n }\n .runtime-title-main {\n color: var(--ai-text);\n font-weight: 600;\n line-height: 1.25;\n }\n .runtime-title-sub {\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n color: var(--ai-text-secondary);\n font-size: 11px;\n line-height: 1.25;\n }\n .runtime-status {\n padding: 2px 8px;\n border-radius: 999px;\n font-size: 10px;\n font-weight: 600;\n white-space: nowrap;\n }\n .runtime-status.running { background: #dbeafe; color: #1d4ed8; }\n .runtime-status.completed { background: #dcfce7; color: #166534; }\n .runtime-status.error { background: #fee2e2; color: #991b1b; }\n .runtime-count {\n min-width: 20px;\n color: var(--ai-text-secondary);\n font-size: 10px;\n text-align: right;\n }\n .runtime-progress {\n height: 2px;\n background: rgba(24, 144, 255, 0.08);\n overflow: hidden;\n }\n .runtime-progress-bar {\n height: 100%;\n width: 42%;\n background: linear-gradient(90deg, transparent, var(--ai-primary), transparent);\n animation: runtimeProgress 1.45s ease-in-out infinite;\n }\n .runtime-progress.completed .runtime-progress-bar,\n .runtime-progress.error .runtime-progress-bar {\n width: 100%;\n animation: none;\n background: currentColor;\n }\n .runtime-progress.completed { color: #22c55e; }\n .runtime-progress.error { color: #ef4444; }\n @keyframes runtimeProgress {\n 0% { transform: translateX(-120%); }\n 100% { transform: translateX(260%); }\n }\n .runtime-events {\n padding: 6px 10px 9px;\n border-top: 1px solid rgba(15, 23, 42, 0.05);\n max-height: 120px;\n overflow-y: auto;\n overscroll-behavior: contain;\n scrollbar-width: thin;\n scrollbar-color: rgba(148, 163, 184, 0.5) transparent;\n }\n .runtime-events::-webkit-scrollbar { width: 4px; }\n .runtime-events::-webkit-scrollbar-track { background: transparent; }\n .runtime-events::-webkit-scrollbar-thumb {\n background: rgba(148, 163, 184, 0.45);\n border-radius: 999px;\n }\n .runtime-event {\n display: grid;\n grid-template-columns: 14px 1fr;\n align-items: flex-start;\n gap: 7px;\n padding: 4px 0;\n font-size: 11px; color: var(--ai-text-secondary, #64748b);\n }\n .runtime-event-icon {\n width: 7px;\n height: 7px;\n border-radius: 50%;\n background: rgba(24, 144, 255, 0.42);\n margin: 6px auto 0;\n font-size: 0;\n }\n .runtime-event:last-child .runtime-event-icon {\n background: var(--ai-primary);\n box-shadow: 0 0 0 4px rgba(24, 144, 255, 0.1);\n }\n /* Spinner on the folded panel header indicating latest event is running */\n .runtime-title-running .runtime-title-spinner {\n display: inline-block;\n width: 10px;\n height: 10px;\n border: 2px solid rgba(24, 144, 255, 0.25);\n border-top-color: var(--ai-primary);\n border-radius: 50%;\n margin-right: 4px;\n vertical-align: middle;\n animation: runtimeSpinner 0.8s linear infinite;\n }\n .runtime-title-running .runtime-title-text {\n display: inline;\n }\n .runtime-title-not-running .runtime-title-spinner {\n display: none;\n }\n @keyframes runtimeSpinner {\n to { transform: rotate(360deg); }\n }\n .runtime-event-text { flex: 1; line-height: 1.5; }\n .hidden { display: none !important; }\n\n /* ========== 移动端适配(与Vue @media 一致) ========== */\n @media screen and (max-width: 768px) {\n :host { top: 0; right: 0; bottom: 0; }\n .ai-chat-dialog { border-radius: 0 !important; right: 0; top: 0; bottom: 0; width: 100vw; }\n .dialog-header { min-height: 54px; padding: 0 14px 0 16px; }\n .header-title { font-size: 15px; }\n .header-icon { width: 34px; height: 34px; }\n .new-chat-btn { width: 34px; height: 34px; }\n .dialog-body { padding: 16px 18px 16px; }\n .message-list { gap: 9px; }\n .message-item { max-width: 100%; width: 100%; }\n .message-bubble { padding: 11px 15px; font-size: 14px; }\n .welcome-text { font-size: 22px; line-height: 1.3; margin-bottom: 9px; }\n .welcome-desc { font-size: 13px; line-height: 1.55; margin-bottom: 18px; }\n .quick-suggestions { gap: 10px; margin-top: 0; }\n .suggestion-chip { min-height: 40px; padding: 0 16px; font-size: 12px; border-radius: 30px; box-sizing: border-box; }\n .dialog-footer { padding: 12px 14px 16px; }\n .input-container { border-radius: 4px; min-height: 86px; }\n .runtime-events { max-height: 94px; }\n .message-input { font-size: 16px; padding: 10px 12px 6px; min-height: 44px; }\n .send-btn { width: 28px; height: 28px; }\n .float-button { height: 42px; min-width: 96px; }\n .action-icon { width: 30px; height: 30px; }\n }\n\n /* ========== 暗色主题覆盖(theme: 'dark') ========== */\n :host(.dark-theme) .ai-chat-dialog {\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);\n }\n :host(.dark-theme) .input-container {\n background: var(--ai-input-bg);\n border-color: var(--ai-input-border);\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);\n }\n :host(.dark-theme) .input-container:focus-within {\n background: var(--ai-input-bg);\n box-shadow: 0 0 0 2px rgba(110, 168, 254, 0.18), 0 4px 14px rgba(0, 0, 0, 0.24);\n }\n :host(.dark-theme) .message-input {\n background: transparent;\n color: var(--ai-text);\n }\n :host(.dark-theme) .message-input::placeholder { color: var(--ai-text-secondary); }\n :host(.dark-theme) .empty-state { background: var(--ai-bg-gradient); }\n :host(.dark-theme) .welcome-text { color: var(--ai-text); }\n :host(.dark-theme) .welcome-desc { color: var(--ai-text-secondary); }\n :host(.dark-theme) .dialog-body { background: var(--ai-bg-gradient); }\n :host(.dark-theme) pre code { background: #0d1117; color: #c9d1d9; }\n :host(.dark-theme) blockquote { background: rgba(110, 168, 254, 0.08); }\n :host(.dark-theme) th { background: rgba(110, 168, 254, 0.12); }\n :host(.dark-theme) hr { border-top-color: var(--ai-border); }\n</style>\n\n<div class="ai-float-container">\n \x3c!-- 对话框 --\x3e\n <div class="ai-chat-dialog">\n \x3c!-- 头部(含展开/关闭按钮) --\x3e\n <div class="dialog-header">\n <div class="header-left">\n <span class="header-title">${this.escapeHtml(this._config?.title||"AI 助手")}</span>\n </div>\n <div class="header-right">\n <button class="new-chat-btn history-btn" type="button" title="历史记录" aria-label="历史记录">\n <svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12a9 9 0 1 0 3-6.7"/><path d="M3 4v5h5"/><path d="M12 7v5l3 2"/></svg>\n </button>\n <button class="new-chat-btn new-session-btn" type="button" title="新会话" aria-label="新会话">\n <svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 5v14"/><path d="M5 12h14"/></svg>\n </button>\n <span class="header-icon expand-btn" title="放大" aria-label="放大">\n <svg viewBox="0 0 24 24" fill="none" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">\n <path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"/>\n </svg>\n </span>\n <span class="header-icon close-btn" title="关闭" aria-label="关闭">\n <svg viewBox="0 0 24 24" fill="none" stroke-width="2.5" stroke-linecap="round">\n <path d="M18 6L6 18"/><path d="M6 6l12 12"/>\n </svg>\n </span>\n </div>\n </div>\n\n \x3c!-- 消息区域 --\x3e\n <div class="dialog-body" id="messagesContainer"></div>\n\n \x3c!-- 输入区域 --\x3e\n <div class="dialog-footer">\n <div class="input-container" id="inputContainer">\n <textarea class="message-input" id="msgInput"\n placeholder="请输入您的问题..." autocomplete="off" rows="2"></textarea>\n <div class="input-tools">\n <button class="input-tool attach-tool" id="attachBtn" type="button" title="上传附件" aria-label="上传附件">\n <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05 12.25 20.24a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>\n </button>\n <input class="attachment-input" id="attachmentInput" type="file" multiple />\n <button class="send-btn" id="sendBtn" aria-label="发送" disabled>\n <svg viewBox="0 0 24 24" fill="currentColor"><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/></svg>\n </button>\n </div>\n </div>\n <div class="footer-note">\n <span class="footer-note-left">${this.escapeHtml(this._config?.footerDisclaimer||"")}</span>\n <span class="footer-note-right">${this.escapeHtml(this._config?.footerIdentity||"")}</span>\n </div>\n </div>\n </div>\n\n \x3c!-- 悬浮按钮 --\x3e\n <div class="float-button" id="floatBtn" title="打开AI助手"></div>\n</div>\n`,this._dialog=this.shadowRoot.querySelector(".ai-chat-dialog"),this._body=this.shadowRoot.querySelector("#messagesContainer"),this._input=this.shadowRoot.querySelector("#msgInput"),this._sendBtn=this.shadowRoot.querySelector("#sendBtn"),this._attachBtn=this.shadowRoot.querySelector("#attachBtn"),this._attachmentInput=this.shadowRoot.querySelector("#attachmentInput"),this._closeBtn=this.shadowRoot.querySelector(".close-btn"),this._expandBtn=this.shadowRoot.querySelector(".expand-btn"),this._newChatBtn=this.shadowRoot.querySelector(".new-session-btn"),this._historyBtn=this.shadowRoot.querySelector(".history-btn"),this._floatBtn=this.shadowRoot.querySelector("#floatBtn"),this._inputContainer=this.shadowRoot.querySelector("#inputContainer"),this.renderMessages({forceScroll:!0})}bindEvents(){requestAnimationFrame(()=>{this._closeBtn&&this._closeBtn.addEventListener("click",()=>this.close()),this._expandBtn&&this._expandBtn.addEventListener("click",()=>this.toggleExpand()),this._newChatBtn&&this._newChatBtn.addEventListener("click",()=>this.clearChat()),this._historyBtn&&this._historyBtn.addEventListener("click",()=>this.toggleHistory()),this._floatBtn&&this._floatBtn.addEventListener("click",()=>this.open()),this._sendBtn&&this._sendBtn.addEventListener("click",()=>this.handleSend()),this._attachBtn&&this._attachmentInput&&(this._attachBtn.addEventListener("click",()=>this._attachmentInput.click()),this._attachmentInput.addEventListener("change",()=>this._handleAttachmentSelect())),this._input&&(this._autoResizeInput(),this._updateSendButtonState(),this._input.addEventListener("input",()=>{this._autoResizeInput(),this._updateSendButtonState()}),this._input.addEventListener("keydown",e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),this.handleSend())})),this._dialog&&!1!==this._config?.enableDrag&&this.initDraggable()})}toggleExpand(){this._isExpanded=!this._isExpanded;const e=this._dialog;e&&(this._isMobile?this._isExpanded=!1:(this._isExpanded?(e.classList.add("expanded"),e.style.width="min(560px, calc(100vw - 48px))",e.style.height="min(640px, 80vh)",e.style.maxHeight="",e.style.minHeight="",e.style.left="auto",e.style.top=ln,e.style.right="24px",e.style.bottom="auto",this._expandBtn.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 00-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 002 2v3"/></svg>',this._expandBtn.title="缩小"):(e.classList.remove("expanded"),e.style.width="min(420px, calc(100vw - 48px))",e.style.height="min(640px, 80vh)",e.style.maxHeight="",e.style.minHeight="",e.style.left=this._dialogX?this._dialogX+"px":"auto",e.style.right=this._dialogX?"auto":"24px",e.style.top=this._dialogY?this._dialogY+"px":ln,e.style.bottom="auto",this._expandBtn.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"/></svg>',this._expandBtn.title="放大"),this.dispatchEvent(new CustomEvent("expand",{detail:this._isExpanded}))))}initDraggable(){const e=this.shadowRoot?.querySelector(".dialog-header");if(!e)return;const t=(e,t)=>{if(this._isExpanded||this._isMobile)return;this._isDragging=!0,this._dialog.classList.add("dragging");const n=this._dialog.getBoundingClientRect();this._dragStartX=e-n.left,this._dragStartY=t-n.top},n=(e,t)=>{this._isDragging&&(this._dialogX=e-this._dragStartX,this._dialogY=t-this._dragStartY,this._dialog.style.left=this._dialogX+"px",this._dialog.style.right="auto",this._dialog.style.top=this._dialogY+"px",this._dialog.style.bottom="auto")},i=()=>{this._isDragging&&(this._isDragging=!1,this._dialog.classList.remove("dragging"))};e.addEventListener("mousedown",e=>{e.target.closest("button, .header-icon")||(t(e.clientX,e.clientY),e.preventDefault())}),document.addEventListener("mousemove",e=>{n(e.clientX,e.clientY)}),document.addEventListener("mouseup",i),e.addEventListener("touchstart",e=>{if(this._isExpanded)return;if(e.target.closest("button, .header-icon"))return;const n=e.touches[0];t(n.clientX,n.clientY)},{passive:!0}),document.addEventListener("touchmove",e=>{if(!this._isDragging)return;const t=e.touches[0];n(t.clientX,t.clientY)},{passive:!0}),document.addEventListener("touchend",i)}applyConfig(){if(!this._config)return;const e=this.shadowRoot.querySelector(".header-title");e&&this._config.title&&(e.textContent=this._config.title),this._input&&this._config.placeholder&&(this._input.placeholder=this._config.placeholder),this._input&&this._config.maxLength&&(this._input.maxLength=this._config.maxLength);const t=this._config.theme,n=this.shadowRoot.host;if("string"==typeof t){if("default"!==t){this._resetThemeVars();const e=dn[t.toUpperCase()];e?(Object.entries(e.colors).forEach(([e,t])=>{const n=cn[e];n&&(this._themeVars[n]=t)}),e.borderRadius&&Object.entries(e.borderRadius).forEach(([e,t])=>{this._themeVars[`--ai-radius-${e}`]=t}),e.fontSize&&Object.entries(e.fontSize).forEach(([e,t])=>{this._themeVars[`--ai-font-${e}`]=t})):console.warn(`[AIChatDialog] Unknown theme: "${t}", using default`)}else this._resetThemeVars();n.classList.toggle("dark-theme",["dark","starsky"].includes(t.toLowerCase()))}t&&"object"==typeof t&&(this._resetThemeVars(),t.colors&&Object.entries(t.colors).forEach(([e,t])=>{t&&(this._themeVars[`--ai-${e}`]=t)}),t.borderRadius&&Object.entries(t.borderRadius).forEach(([e,t])=>{t&&(this._themeVars[`--ai-radius-${e}`]=t)}),t.fontSize&&Object.entries(t.fontSize).forEach(([e,t])=>{t&&(this._themeVars[`--ai-font-${e}`]=t)}),n.classList.remove("dark-theme")),Object.entries(this._themeVars).forEach(([e,t])=>n.style.setProperty(e,t))}async loadAppDetail(){const e=this._config?.appId||this._config?.agentAppId;if(e&&this._chatClient)try{const t=await this._chatClient.getAppDetail(e);if(!t?.success||!t.data)return;const n=t.data;this._appDetail=n;const i=this._parsePrologue(n.basicUsageTip||n.prologue||"");!n.name||this._config.title&&"AI 助手"!==this._config.title&&"AI 智能助手"!==this._config.title||(this._config.title=n.name),n.name&&(this._config.welcomeText=n.name);const s=i.text||n.description||n.prologue||"";s&&(this._config.welcomeDesc=s),i.questions.length>0&&(this._config.suggestions=i.questions.map(e=>({label:e,value:e}))),this.applyConfig(),0!==this._messages.length||this._historyVisible||this.renderMessages(),this.dispatchEvent(new CustomEvent("app-detail-loaded",{detail:n}))}catch(e){console.warn("[AIChatDialog] 应用信息加载失败:",e)}}_parsePrologue(e){const t=String(e||"").split(/\r?\n/).map(e=>e.trim()).filter(Boolean),n=[],i=[];return t.forEach(e=>{const t=e.replace(/^[-*]\s+/,"").trim();/^[-*]\s+/.test(e)?i.push(t):n.push(e)}),{text:n.join("\n"),questions:i}}renderMessages(e={}){if(!this._body)return;if(this._historyVisible)return void this.renderHistoryView();const t=!0===e.forceScroll||this._shouldAutoScroll(),n=this._body.scrollTop||0;if(0===this._messages.length){const e=this._config?.suggestions||[];let t="";e.length>0&&(t='<div class="quick-suggestions">'+e.map(e=>`<span class="suggestion-chip" data-value="${this.escapeAttr(e.value||e.label)}"><span class="chip-icon">💡</span>${this.escapeHtml(e.label)}</span>`).join("")+"</div>"),this._body.innerHTML=`\n <div class="empty-state">\n <div class="welcome-content">\n <p class="welcome-text">${this.escapeHtml(this._config?.welcomeText||"您好!我是 AI 智能助理")}</p>\n <p class="welcome-desc">${this.escapeHtml(this._config?.welcomeDesc||"我可以帮您解答系统使用问题")}</p>\n ${t}\n </div>\n </div>`,this._body.querySelectorAll(".suggestion-chip").forEach(e=>{e.addEventListener("click",()=>{const t=e.dataset.value||e.textContent.replace(/[💡\s]/g,"");this._input.value=t,this._autoResizeInput(),this.handleSend()})})}else{let e='<div class="message-list">';const t=this._messages.some(e=>"ai"===e.type&&e._runtimeEvents&&e._runtimeEvents.length>0);this._messages.forEach((n,i)=>{const s="ai"===n.type&&n._runtimeEvents&&n._runtimeEvents.length>0,r=n._isStreaming&&!n.content&&!s&&!t,a=["message-bubble",r?"loading":""].filter(Boolean).join(" ");let o="";if(r)o='<span class="thinking-text">思考中</span><span class="typing-indicator"><span class="typing-dot"></span><span class="typing-dot"></span><span class="typing-dot"></span></span>';else{const e=(n._isStreaming,n.content||"");o=n._isStreaming||e?`<div class="message-text">${"ai"===n.type?this.parseMarkdown(e):this.escapeHtml(e)}</div>`:""}e+=`<div class="message-item ${n.type}">\n <div class="message-content">\n ${s?this._buildRuntimePanel(n,i):""}\n ${o?`<div class="${a}">${o}</div>`:""}\n ${n._isStreaming?"":`<div class="message-actions-bar">\n ${"ai"===n.type?`<div class="action-icons">\n <span class="action-icon copy-btn${n.copied?" copied":""}" data-idx="${i}" title="${n.copied?"已复制":"复制"}">${n.copied?'<svg viewBox="0 0 24 24" fill="none" stroke-width="2"><path d="m20 6-11 11-5-5"/></svg>':'<svg viewBox="0 0 24 24" fill="none" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>'}</span>\n <span class="action-icon regenerate-btn" data-idx="${i}" title="重新回答"><svg viewBox="0 0 24 24" fill="none" stroke-width="2"><path d="M21 12a9 9 0 1 1-2.64-6.36"/><path d="M21 3v6h-6"/></svg></span>\n </div>`:""}\n </div>`}\n </div>\n </div>`}),this._isLoading&&!t&&(e+='<div class="message-item ai"><div class="message-content"><div class="message-bubble loading"><span class="thinking-text">思考中</span><span class="typing-indicator"><span class="typing-dot"></span><span class="typing-dot"></span><span class="typing-dot"></span></span></div></div></div>'),e+="</div>",this._body.innerHTML=e,this._body.querySelectorAll(".copy-btn").forEach(e=>{e.addEventListener("click",()=>{const t=parseInt(e.dataset.idx),n=this._messages[t];n&&this.copyMessage(n.content,t)})}),this._body.querySelectorAll(".regenerate-btn").forEach(e=>{e.addEventListener("click",()=>{const t=parseInt(e.dataset.idx);this.regenerate(t)})}),this._body.querySelectorAll(".runtime-header").forEach(e=>{e.addEventListener("click",()=>{const t=e.closest(".runtime-panel"),n=t?t.querySelector(".runtime-events"):null;n&&n.classList.toggle("hidden");const i=e.querySelector(".arrow");i&&i.classList.toggle("expanded")})})}t?this.scrollToBottom():requestAnimationFrame(()=>{this._body&&(this._body.scrollTop=n)})}renderHistoryView(){if(!this._body)return;const e=this._getFilteredHistoryRecords(),t=this._historyLoading?'<div class="history-loading">正在加载历史记录...</div>':e.length>0?`<div class="history-list">${e.map((e,t)=>this._buildHistoryItem(e,t)).join("")}</div>`+(this._historyHasMore?'<button class="history-load-more" type="button">加载更多...</button>':""):'<div class="history-empty">暂无历史记录</div>';this._body.innerHTML=`\n <div class="history-view">\n <div class="history-head">\n <div class="history-title">历史记录</div>\n <button class="history-back" type="button">返回对话</button>\n </div>\n ${t}\n </div>`;const n=this._body.querySelector(".history-back");n&&n.addEventListener("click",()=>{this._historyVisible=!1,this.renderMessages({forceScroll:!0})}),this._body.querySelectorAll(".history-item").forEach(t=>{t.addEventListener("click",()=>{const n=Number(t.dataset.idx),i=e[n];i&&this.openHistoryRecord(i)})});const i=this._body.querySelector(".history-load-more");i&&i.addEventListener("click",()=>{this.loadHistoryRecords(!0)})}_buildHistoryItem(e,t){const n=e.prompt||e.question||e.content||"未命名对话",i=e.replyText||e.answer||"";return`<button class="history-item" type="button" data-idx="${t}">\n <div class="history-item-title">${this.escapeHtml(n)}</div>\n ${i?`<div class="history-item-preview">${this.escapeHtml(i)}</div>`:""}\n </button>`}_getFilteredHistoryRecords(){const e=Array.isArray(this._historyRecords)?this._historyRecords:[],t=new Map;e.forEach(e=>{const n=e.conversationId||e.recordId||e.requestId;if(!n)return void t.set("_noKey_"+Math.random()+"_"+t.size,e);const i=t.get(n);if(i){const s=i.conversationId,r=e.conversationId;if(!s&&r)t.set(n,e);else if(s||!r){const s=i.createTime?Date.parse(String(i.createTime).replace(/-/g,"/")):0;(e.createTime?Date.parse(String(e.createTime).replace(/-/g,"/")):0)>s&&t.set(n,e)}}else t.set(n,e)});let n=Array.from(t.values());const i=Number(this._config?.historyDays||0);if(!i)return n;const s=Date.now()-24*i*60*60*1e3;return n.filter(e=>{const t=e.createTime?Date.parse(String(e.createTime).replace(/-/g,"/")):NaN;return Number.isNaN(t)||t>=s})}async toggleHistory(){this._historyVisible=!this._historyVisible,this._historyVisible?(this._historyLoaded&&this.renderHistoryView(),await this.loadHistoryRecords()):this.renderMessages()}async loadHistoryRecords(e=!1){this._chatClient||(this._chatClient=new S(this._config||{}));const t=this._config?.appId||this._config?.agentAppId;if(!t)return this.showToast("应用ID不能为空"),void(this._historyVisible=!1);this._historyLoading=!0,this.renderHistoryView();try{const n=this._config?.historyPageSize||20,i=e?(this._historyPageIndex||1)+1:1,s=Number(this._config?.historyDays||0),r={appId:t,bizType:this._config?.bizType,pageIndex:i,pageSize:n};s>0&&(r.startTime=new Date(Date.now()-24*s*60*60*1e3).toISOString());const a=await this._chatClient.queryConversation(r);if(a.success){const t=a.data?.records||[];this._historyRecords=e?(this._historyRecords||[]).concat(t):t,this._historyPageIndex=i,this._historyHasMore=t.length>=n,this._historyLoaded=!0}else this.showToast(a.message||"历史记录加载失败")}catch(t){this.showToast("历史记录加载失败"),console.error("loadHistoryRecords error",t),e||(this._historyRecords=[])}finally{this._historyLoading=!1,this.renderHistoryView()}}async openHistoryRecord(e){const t=e.conversationId;if(t)try{const e=await this._chatClient.queryConversation({conversationId:t,pageIndex:1,pageSize:50});if(e.success&&e.data?.records?.length)return this._conversationId=t,this._chatClient.setConversationId(t),this._messages=this._recordsToMessages(e.data.records),this._historyVisible=!1,void this.renderMessages({forceScroll:!0})}catch(e){}this._conversationId=t||null,t&&this._chatClient.setConversationId(t),this._messages=this._recordsToMessages([e]),this._historyVisible=!1,this.renderMessages({forceScroll:!0})}_recordsToMessages(e){return[...e].reverse().flatMap(e=>{const t=[],n=e.prompt||e.question||e.content,i=e.replyText||e.answer;return n&&t.push({id:`history_user_${e.recordId||e.requestId||this.generateId()}`,type:"user",content:n,attachments:e.attachments||[]}),i&&t.push({id:`history_ai_${e.recordId||e.requestId||this.generateId()}`,type:"ai",content:i,copied:!1,_status:"completed"}),t})}updateLoadingUI(){this.renderMessages(),this._input&&(this._input.disabled=this._isLoading||this._streaming),this._attachBtn&&(this._attachBtn.disabled=this._isLoading||this._streaming),this._updateSendButtonState()}scrollToBottom(){this._body&&requestAnimationFrame(()=>{this._body.scrollTop=this._body.scrollHeight})}_shouldAutoScroll(){if(!this._body)return!0;return this._body.scrollHeight-this._body.scrollTop-this._body.clientHeight<80}_autoResizeInput(){if(!this._input)return;this._input.style.height="auto";const e=Math.min(this._input.scrollHeight,132);this._input.style.height=`${e}px`,this._input.style.overflowY=this._input.scrollHeight>132?"auto":"hidden"}_updateSendButtonState(){if(!this._sendBtn)return;const e=!(!this._input||!this._input.value.trim()),t=this._attachments&&this._attachments.length>0;this._sendBtn.disabled=this._isLoading||!e&&!t}_handleAttachmentSelect(){this._attachmentInput&&(this._attachments=Array.from(this._attachmentInput.files||[]),this._attachBtn&&(this._attachBtn.classList.toggle("has-attachment",this._attachments.length>0),this._attachBtn.title=this._attachments.length>0?`已选择 ${this._attachments.length} 个附件`:"上传附件"),this._updateSendButtonState())}async handleSend(){const e=this._input?this._input.value.trim():"",t=[...this._attachments||[]];if(!e&&0===t.length)return void this.showToast(this._config?.emptyMessageError||"请输入消息内容");if(this._isLoading)return;const n=this._config?.maxLength??500;if(e.length>n)return void this.showToast(`输入内容不能超过${n}个字符(当前${e.length}字)`);const i=Date.now();if(this._lastSendTime&&i-this._lastSendTime<500)return;this._lastSendTime=i,this._input.value="",this._autoResizeInput(),this._attachments=[],this._attachmentInput&&(this._attachmentInput.value=""),this._attachBtn&&(this._attachBtn.classList.remove("has-attachment"),this._attachBtn.title="上传附件"),this._updateSendButtonState();const s=t.length>0?t.map(e=>`附件:${e.name}`).join("\n"):"",r=e||s,a={id:this.generateId(),type:"user",content:r,time:this.formatTime(),attachments:t.map(e=>({name:e.name,size:e.size,type:e.type}))};this._messages.push(a);const o=this._config?.maxMessages??50;this._messages.length>o&&(this._messages=this._messages.slice(-o)),this._config?.onMessageSend&&this._config.onMessageSend(a),this.dispatchEvent(new CustomEvent("message-send",{detail:a})),this.setLoading(!0);try{for(const e of t)await this.uploadAttachment(e).catch(e=>console.warn("[AIChatDialog] 附件上传失败:",e));await this.sendMessageToAI(e||s)}catch(e){console.error("[AIChatDialog] Error:",e),this.handleError(e)}finally{this.setLoading(!1)}}async sendMessageToAI(e,t={}){if(this._mockMode)await this.mockResponse(e);else{const n=t.messageId||this.generateId();t.messageId||this._messages.push({id:n,type:"ai",content:"",_isStreaming:!0,time:this.formatTime()}),this.renderMessages({forceScroll:!0}),this._streaming=!0,this.setLoading(!1),this.updateLoadingUI(),await this._directApiCallStream(n,e,t.streamOptions||{})}}async mockResponse(e){await new Promise(e=>setTimeout(e,600+800*Math.random()));const t=[`关于"${(e||"").substring(0,20)}"这个问题,我来为您详细解答...`,"这是一个很好的问题!根据我的理解:\n\n1. 首先,我们需要分析需求\n2. 其次,设计实现方案\n3. 最后,进行测试验证","收到您的问题。让我来帮您分析一下...\n\n根据您的描述,我建议您可以按照以下步骤操作:","感谢您的提问!以下是我的看法:\n\n• 第一点很关键,需要注意细节\n• 第二点值得关注\n• 第三点是核心所在"],n=t[Math.floor(Math.random()*t.length)],i=this.generateId();this._messages.push({id:i,type:"ai",content:"",_isStreaming:!0}),this.renderMessages();for(let e=0;e<n.length;e++){await new Promise(e=>setTimeout(e,12+20*Math.random()));const t=this._messages.findIndex(e=>e.id===i);t>=0&&(this._messages[t].content=n.substring(0,e+1),this.updateStreamingBubble(i,n.substring(0,e+1)))}this.finalizeStream(i),this._config?.onMessageReceived&&this._config.onMessageReceived({content:n,done:!0}),this.dispatchEvent(new CustomEvent("message-received",{detail:{content:n}}))}updateStreamingBubble(e,t){const n=this._shouldAutoScroll(),i=this._body?.querySelectorAll(".message-bubble.loading");if(i&&i.length>0){const e=i[i.length-1];e&&(e.innerHTML=`<div class="message-text">${this.parseMarkdown(t)}</div>`)}n&&this.scrollToBottom()}finalizeStream(e){const t=this._messages.findIndex(t=>t.id===e);t>=0&&delete this._messages[t]._isStreaming,this.renderMessages()}_conversationId=null;async _directApiCallStream(e,t,n={}){this._chatClient||(this._chatClient=new S(this._config||{})),Object.prototype.hasOwnProperty.call(n,"conversationId")?this._chatClient.setConversationId(n.conversationId||null):this._conversationId&&this._chatClient.setConversationId(this._conversationId);let i="";try{const s=await this._chatClient.sendMessageStream(t,{onMessage:t=>{this._isPlaceholder(t)||this._isEventLike(t)||(i+=t,this._updateMsg(e,i))},onProgress:t=>{t&&t.trim()&&!this._isPlaceholder(t)&&this._addRuntimeEvent(e,{_type:"PROGRESS",_text:t,_icon:"📋"})},onNodeStart:(t,n)=>{const i=t||"节点执行";this._addRuntimeEvent(e,{_type:"NODE_START",_text:i,_detail:n||"",_icon:"🚀"})},onNodeProgress:(t,n)=>{const i=t||"节点执行中";this._addRuntimeEvent(e,{_type:"NODE_PROGRESS",_text:i,_detail:n||"",_icon:"🔄"})},onNodeComplete:(t,n)=>{const i=t||"节点完成";this._addRuntimeEvent(e,{_type:"NODE_COMPLETE",_text:i,_detail:n||"",_icon:"✅"})},onToolStart:(t,n)=>{const i=t||"工具调用";this._addRuntimeEvent(e,{_type:"TOOL_START",_text:i,_icon:"🔧"})},onToolResult:(t,n)=>{const i=t?t+" 返回结果":"工具返回结果";this._addRuntimeEvent(e,{_type:"TOOL_RESULT",_text:i,_detail:n||"",_icon:"📦"})},onToolEnd:(t,n)=>{const i=t?t+" 执行完成":"工具执行完成";this._addRuntimeEvent(e,{_type:"TOOL_END",_text:i,_icon:"✅"})},onWarning:t=>{t&&t.trim()&&!this._isPlaceholder(t)&&this._addRuntimeEvent(e,{_type:"WARNING",_text:t,_icon:"⚠️"})},onPlanningEvent:t=>{const n=t?.message||t?.metadata?.title||t?.metadata?.detail||t?.currentTask?.name||"";if(n&&String(n).trim()&&!this._isPlaceholder(n)){const i=t?.metadata?.itemKind||t?.currentTask?.type||"";this._addRuntimeEvent(e,{_type:"PLANNING",_text:String(n),_icon:"reasoning"===i?"🧠":"📋"})}},onMeta:t=>{const n=t?.conversationId||t?.sessionId;n&&(this._conversationId=n);const i=t?.taskRunId;if(i){const t=this._messages.findIndex(t=>t.id===e);t>=0&&(this._messages[t].taskRunId=i)}},onDone:t=>{!t||this._isPlaceholder(t)||this._isEventLike(t)||(i=t,this._updateMsg(e,t))},onError:t=>{this._updateMsg(e,"错误: "+(t||"流式请求失败"))}},n);if(!s?.success)return;if(s.data?.conversationId?this._conversationId=s.data.conversationId:this._chatClient.conversationId&&(this._conversationId=this._chatClient.conversationId),!i.trim()&&this._conversationId){this._updateMsg(e,"(等待AI处理...)");const t=await this._fetchConversationResult(this._conversationId);i=t}this._finalizeMsg(e,i||"(无回复)"),this.dispatchEvent(new CustomEvent("message-received",{detail:{content:i}})),this._config?.onMessageReceived&&this._config.onMessageReceived(i)}catch(t){"AbortError"===t.name?this._updateMsg(e,"(请求超时或已取消)"):(console.error("[AIChatDialog] 流式失败:",t),this._updateMsg(e,"网络错误: "+(t.message||"请检查连接")))}}_getStreamTextEl(){if(this._streamTextEl&&this._body.contains(this._streamTextEl))return this._streamTextEl;const e=this._body?.querySelectorAll(".message-item.ai")||[];for(let t=e.length-1;t>=0;t--){const n=e[t].querySelector(".message-text");if(n)return this._streamTextEl=n,n;const i=e[t].querySelector(".message-bubble.loading");if(i){i.classList.remove("loading"),i.innerHTML="";const e=document.createElement("div");return e.className="message-text",i.appendChild(e),this._streamTextEl=e,e}}return null}_updateMsg(e,t){const n=this._messages.findIndex(t=>t.id===e);if(n<0)return;this._messages[n].content=t;const i=!!(this._messages[n]._runtimeEvents&&this._messages[n]._runtimeEvents.length>0);t.startsWith(this._streamFullText)?this._streamFullText=t:(this._streamFullText=t,this._streamVisibleLength=0);const s=this._getStreamTextEl();if(s){if(i){if(!this._streamTypeRaf){const e=()=>{const t=this._streamFullText;if(this._streamVisibleLength>=t.length)return void(this._streamTypeRaf=null);this._streamVisibleLength=Math.min(this._streamVisibleLength+1,t.length);const n=this._getStreamTextEl();n&&(n.innerHTML=this.parseMarkdown(t.slice(0,this._streamVisibleLength))),this._shouldAutoScroll()&&this.scrollToBottom(),this._streamTypeRaf=requestAnimationFrame(e)};this._streamTypeRaf=requestAnimationFrame(e)}}else s.innerHTML=this.parseMarkdown(t),this._streamFullText="",this._streamVisibleLength=0;this._shouldAutoScroll()&&this.scrollToBottom()}else this._streamInitDone||(this._streamInitDone=!0,this.renderMessages())}_finalizeMsg(e,t){this._streaming=!1,this.updateLoadingUI();const n=this._messages.findIndex(t=>t.id===e);n>=0&&(this._messages[n].content=t,delete this._messages[n]._isStreaming,this._messages[n].time=this.formatTime(),this._messages[n]._status=t&&!t.startsWith("(")?"completed":"error",this._streamTypeRaf&&(cancelAnimationFrame(this._streamTypeRaf),this._streamTypeRaf=null),this._streamTextEl=null,this._streamInitDone=!1,this._runtimePanelEl=null,this._runtimeEventsContainerEl=null,this.renderMessages())}_isPlaceholder(e){if(!e||"string"!=typeof e)return!1;const t=e.trim();return!t||on.some(e=>t.includes(e))}_isEventLike(e){if(!e||"string"!=typeof e)return!1;const t=e.trim();if(t.startsWith("[META]")||t.startsWith("event:"))return!0;try{const e=JSON.parse(t);return e&&"object"==typeof e&&(e.eventType||e.metadata)}catch(e){}return!1}_addRuntimeEvent(e,t){const n=this._messages.findIndex(t=>t.id===e);if(n<0)return;this._messages[n]._runtimeEvents||(this._messages[n]._runtimeEvents=[]);const i=this._messages[n]._runtimeEvents[this._messages[n]._runtimeEvents.length-1];if(i&&i._text===t._text)return;if(this._messages[n]._runtimeEvents.push(t),["NODE_COMPLETE","TOOL_END","TOOL_RESULT"].includes(t._type),this._runtimeEventsContainerEl&&this._body.contains(this._runtimeEventsContainerEl)){const e=document.createElement("div");e.className="runtime-event",e.innerHTML='<span class="runtime-event-icon"></span><span class="runtime-event-text">'+this.escapeHtml(t._text)+"</span>",this._runtimeEventsContainerEl.appendChild(e);const i=this._runtimePanelEl?.querySelector(".runtime-title-sub");if(i){const e=!["NODE_COMPLETE","TOOL_END","TOOL_RESULT"].includes(t._type);i.className="runtime-title-sub "+(e?"runtime-title-running":"runtime-title-not-running"),i.innerHTML='<span class="runtime-title-spinner"></span><span class="runtime-title-text">'+this.escapeHtml(t._text)+"</span>"}const s=this._runtimePanelEl?.querySelector(".runtime-count");return s&&(s.textContent=this._messages[n]._runtimeEvents.length),void(this._shouldAutoScroll()&&this.scrollToBottom())}const s=this._findStreamingMessageContent();if(s){const e=s.querySelector(".message-bubble.loading");if(e){e.classList.remove("loading"),e.innerHTML="";const t=document.createElement("div");t.className="message-text",e.appendChild(t)}}if(s&&!s.querySelector(".runtime-panel")){const e=this._createRuntimePanelDOM(this._messages[n]);return s.insertBefore(e,s.firstChild),this._runtimePanelEl=e,this._runtimeEventsContainerEl=e.querySelector(".runtime-events"),void(this._shouldAutoScroll()&&this.scrollToBottom())}}_findStreamingMessageContent(){const e=this._body?.querySelectorAll(".message-item.ai")||[];for(let t=e.length-1;t>=0;t--){const n=e[t].querySelector(".message-content");if(n)return n}return null}_createRuntimePanelDOM(e){const t=e._runtimeEvents||[],n=e._isStreaming?"running":e._status||"running",i="completed"===n?"已完成":"error"===n?"错误":"执行中",s=t[t.length-1]?._text||"",r=t[t.length-1]||{},a=e._isStreaming&&!["NODE_COMPLETE","TOOL_END","TOOL_RESULT"].includes(r._type),o=document.createElement("div");o.className="runtime-panel";const l=document.createElement("div");l.className="runtime-header",l.onclick=function(){var e=o.querySelector(".runtime-events");e&&e.classList.toggle("hidden");var t=l.querySelector(".arrow");t&&t.classList.toggle("expanded")};var c=a?"runtime-title-sub runtime-title-running":"runtime-title-sub runtime-title-not-running";l.innerHTML='<span class="arrow">▶</span><span class="runtime-title"><span class="runtime-title-main">执行过程</span><span class="'+c+'"><span class="runtime-title-spinner"></span><span class="runtime-title-text">'+this.escapeHtml(s)+'</span></span></span><span class="runtime-status running">'+i+'</span><span class="runtime-count">'+t.length+"</span>",o.appendChild(l);const d=document.createElement("div");d.className="runtime-progress running",d.innerHTML='<div class="runtime-progress-bar"></div>',o.appendChild(d);const h=document.createElement("div");return h.className="runtime-events hidden",t.forEach(function(e){const t=document.createElement("div");t.className="runtime-event",t.innerHTML='<span class="runtime-event-icon"></span><span class="runtime-event-text">'+this.escapeHtml(e._text)+"</span>",h.appendChild(t)}.bind(this)),o.appendChild(h),o}_buildRuntimePanel(e,t){const n=e._runtimeEvents||[];if(0===n.length)return"";const i=e._isStreaming?"running":e._status||"running",s="completed"===i?"已完成":"error"===i?"错误":"执行中",r=!(!e.content||!String(e.content).trim())||"completed"===i||"error"===i,a=n[n.length-1]?._text||"";let o="";return n.forEach(function(e){o+='<div class="runtime-event"><span class="runtime-event-icon"></span><span class="runtime-event-text">'+this.escapeHtml(e._text)+"</span></div>"}.bind(this)),'<div class="runtime-panel"><div class="runtime-header"><span class="arrow'+(r?"":" expanded")+'">▶</span><span class="runtime-title"><span class="runtime-title-main">执行过程</span><span class="runtime-title-sub">'+this.escapeHtml(a)+'</span></span><span class="runtime-status '+i+'">'+s+'</span><span class="runtime-count">'+n.length+'</span></div><div class="runtime-progress '+i+'"><div class="runtime-progress-bar"></div></div><div class="runtime-events'+(r?" hidden":"")+'">'+o+"</div></div>"}async _fetchConversationResult(e){for(let t=0;t<8;t++){await new Promise(e=>setTimeout(e,1e3));try{const t=await this._chatClient.queryConversation({conversationId:e,pageIndex:1,pageSize:1});if(t.success&&t.data?.records?.length>0){const e=t.data.records[0],n=e.replyText||e.content||e.answer;if(n&&n.trim())return n}}catch(e){}}return"(AI 处理超时,请稍后查看对话记录)"}async regenerate(e){if(this._isLoading)return;const t=this._messages[e];if(!t||"ai"!==t.type)return;let n="";for(let t=e-1;t>=0;t--)if("user"===this._messages[t].type){n=this._messages[t].content;break}if(n){Object.assign(t,{content:"",_isStreaming:!0,_runtimeEvents:[],_status:"running",copied:!1,time:this.formatTime(),taskRunId:null}),this.renderMessages({forceScroll:!0}),this.setLoading(!0);try{await this.sendMessageToAI(n,{messageId:t.id,streamOptions:{conversationId:""}})}catch(e){console.error("[AIChatDialog] Regenerate error:",e),this.handleError(e)}finally{this.setLoading(!1)}}}showToast(e){const t=document.createElement("div");t.className="error-toast",t.textContent=e,this._dialog?.appendChild(t),setTimeout(()=>t.remove(),3e3)}handleError(e){let t="抱歉,网络请求失败,请稍后重试";const n=e?.message||"";n.includes("Failed to fetch")||n.includes("NetworkError")||n.includes("网络")?t="网络连接失败,请检查网络后重试":n.includes("AbortError")||n.includes("超时")||n.includes("timeout")?t="请求超时,请稍后重试":n.match(/HTTP 40[13]/)?t="请求参数有误,请检查后重新发送":n.includes("HTTP 403")||n.includes("鉴权失败")||n.includes("未授权")?t="鉴权失败,请重新登录后再试":n.includes("HTTP 404")?t="服务地址不存在,请联系管理员":n.match(/HTTP 4\d\d/)?t=`请求异常(${n}),请稍后重试`:n.includes("HTTP 500")||n.includes("Internal Server Error")?t="服务器内部错误,请稍后重试":n.includes("HTTP 502")||n.includes("HTTP 503")||n.includes("HTTP 504")?t="服务暂时不可用,请稍后重试":n.match(/HTTP 5\d\d/)?t=`服务器错误(${n}),请稍后重试`:n&&(t="抱歉,"+n),this.addMessage({type:"ai",content:t,time:this.formatTime(),errorType:"network_error"}),this._config?.onError&&this._config.onError(e),this.dispatchEvent(new CustomEvent("error",{detail:e}))}async copyContent(e){if("undefined"!=typeof wx&&wx.setClipboardData)return new Promise((t,n)=>{wx.setClipboardData({data:e,success:t,fail:()=>{try{this._fallbackCopy(e),t()}catch(e){n(e)}}})});if(navigator.clipboard&&navigator.clipboard.writeText)try{return void await navigator.clipboard.writeText(e)}catch(t){return void this._fallbackCopy(e)}this._fallbackCopy(e)}_fallbackCopy(e){const t=document.createElement("textarea");t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}async copyMessage(e,t){try{await this.copyContent(e),this._messages[t]&&(this._messages[t].copied=!0),this.renderMessages(),setTimeout(()=>{this._messages[t]&&(this._messages[t].copied=!1,this.renderMessages())},2e3)}catch(e){this.showToast("复制失败,请手动选择文本复制")}}clearChat(){this._messages=[],this._attachments=[],this._historyVisible=!1,this._attachmentInput&&(this._attachmentInput.value=""),this._attachBtn&&(this._attachBtn.classList.remove("has-attachment"),this._attachBtn.title="上传附件"),this._updateSendButtonState(),this._conversationId=null,this._chatClient&&this._chatClient.clearConversation(),this.renderMessages(),this.dispatchEvent(new CustomEvent("clear"))}async stopGeneration(){this._chatClient&&await this._chatClient.stopCompletion(),this.setLoading(!1);const e=[...this._messages].reverse().find(e=>"ai"===e.type&&e._isStreaming);e&&this._finalizeMsg(e.id,e.content||"(已停止)"),this.dispatchEvent(new CustomEvent("stop"))}async uploadAttachment(e,t={}){this._chatClient||(this._chatClient=new S(this._config||{}));const n=await this._chatClient.uploadAttachment(e,t);return n.success?this.dispatchEvent(new CustomEvent("attachment-uploaded",{detail:n.data})):this.dispatchEvent(new CustomEvent("error",{detail:n})),n}generateId(){return`msg_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}formatTime(){const e=new Date;return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`}escapeHtml(e){if(!e)return"";const t=document.createElement("div");return t.textContent=e,t.innerHTML.replace(/\n/g,"<br>")}escapeAttr(e){return e?e.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">"):""}_resetThemeVars(){Object.assign(this._themeVars,{"--ai-primary":"#1890ff","--ai-primary-light":"#40a9ff","--ai-primary-dark":"#096dd9","--ai-secondary":"#722ed1","--ai-bg":"#ffffff","--ai-bg-gradient":"#f8fafc","--ai-text":"#1e293b","--ai-text-secondary":"#64748b","--ai-user-bubble-gradient":"linear-gradient(135deg, #1890ff, #40a9ff)","--ai-ai-bubble-bg":"#ffffff","--ai-header-gradient":"linear-gradient(90deg, rgba(24, 144, 255, 0.08), rgba(114, 46, 209, 0.08))","--ai-border":"rgba(24, 144, 255, 0.15)","--ai-shadow":"rgba(24, 144, 255, 0.12)","--ai-input-bg":"#f8fafc","--ai-input-border":"#e2e8f0","--ai-loading":"#64748b","--ai-success":"#52c41a","--ai-error":"#ff4d4f","--ai-warning":"#faad14","--ai-radius-dialog":"16px","--ai-radius-bubble":"18px","--ai-radius-button":"50%","--ai-radius-input":"28px","--ai-radius-small":"6px","--ai-radius-medium":"12px","--ai-font-title":"15px","--ai-font-welcome-text":"17px","--ai-font-welcome-desc":"13px","--ai-font-message":"14px","--ai-font-time":"11px","--ai-font-small":"11px"})}parseMarkdown(e){if(!e)return"";try{const t=Ge.parse(e);return an.sanitize(t,{ALLOWED_TAGS:["p","br","strong","b","em","i","u","s","del","h1","h2","h3","h4","h5","h6","ul","ol","li","blockquote","pre","code","a","img","table","thead","tbody","tr","th","td","hr","div","span","sup","sub"],ALLOWED_ATTR:["href","target","src","alt","title","class","id"]})}catch(t){return console.warn("[AIChatDialog] Markdown解析失败,回退为纯文本:",t),this.escapeHtml(e)}}}function pn(e={}){const t=document.createElement("ai-chat-dialog");return e.title&&t.setAttribute("title",e.title),e.placeholder&&t.setAttribute("placeholder",e.placeholder),e.width&&t.style.setProperty("--dialog-width",`${e.width}px`),e.height&&t.style.setProperty("--dialog-height",`${e.height}px`),document.body.appendChild(t),Object.keys(e).length>0&&t.init(e),t}function un(e){e?e.component("AiChatWrapper",{props:{visible:{type:Boolean,default:!1},config:{type:Object,default:()=>({})}},data:()=>({dialogInstance:null}),watch:{visible:{immediate:!0,handler(e){this.$nextTick(()=>{e?this.open():this.close()})}},config:{deep:!0,handler(){this.dialogInstance&&this.dialogInstance.updateConfig(this.config)}}},mounted(){this.initDialog()},beforeDestroy(){this.dialogInstance&&this.dialogInstance.destroy()},beforeUnmount(){this.dialogInstance&&this.dialogInstance.destroy()},methods:{initDialog(){this.dialogInstance=pn(this.config||{});["open","close","message-send","message-received","error"].forEach(e=>{this.dialogInstance.addEventListener(e,t=>{this.$emit(e,t.detail)})})},open(){this.dialogInstance&&this.dialogInstance.open()},close(){this.dialogInstance&&this.dialogInstance.close()}},render:e=>e("div",{style:"display: none;"})}):console.warn("[AI Web SDK] Vue instance not provided")}function gn(e={}){if("undefined"==typeof React)return console.warn("[AI Web SDK] React is not loaded, useAIChat skipped"),{open:()=>{},close:()=>{},isVisible:!1,messages:[],isLoading:!1};const{useState:t,useRef:n,useEffect:i}=React,[s,r]=t(!1),[a,o]=t([]),[l,c]=t(!1),d=n(null);return i(()=>(d.current||(d.current=pn(e),d.current.addEventListener("message-send",e=>{o(t=>[...t,e.detail])}),d.current.addEventListener("message-received",e=>{o(t=>[...t,{id:Date.now(),role:"assistant",content:e.detail.content,timestamp:(new Date).toISOString()}]),c(!1)}),d.current.addEventListener("error",()=>{c(!1)})),()=>{d.current&&(d.current.destroy(),d.current=null)}),[]),{open:()=>{r(!0),d.current?.open()},close:()=>{r(!1),d.current?.close()},toggle:()=>{d.current?.toggle()},sendMessage:e=>{if(d.current){const t=d.current.shadowRoot?.querySelector(".ai-textarea");t&&(t.value=e,t.dispatchEvent(new Event("input"))),d.current.handleSend?.()||d.current.shadowRoot?.querySelector(".ai-send-btn")?.click()}},clearMessages:()=>{d.current?.clearMessages(),o([])},isVisible:s,messages:a,isLoading:l,ref:d}}customElements.get("ai-chat-dialog")||customElements.define("ai-chat-dialog",hn),"undefined"!=typeof window&&(window.AIChatDialog=hn);var fn={AIChatDialog:hn,AIChatClient:S,createAIChatDialog:pn,installVuePlugin:un,useAIChat:gn,version:"2.0.0"};"undefined"!=typeof window&&(window.AICreateChatDialog=pn,window.AIWebSDK={version:"2.0.0",create:pn,AIChatDialog:hn,AIChatClient:S,installVuePlugin:un}),e.AIChatClient=S,e.AIChatClientDefault=S,e.AIChatDialog=hn,e.AIChatDialogDefault=hn,e.createAIChatDialog=pn,e.default=fn,e.installVuePlugin=un,e.useAIChat=gn,Object.defineProperty(e,"__esModule",{value:!0})});
|