import{Bt as e,Er as t,N as n,Or as r,P as i,Sn as a,Sr as o,Tr as s,an as c,hr as l,i as u,in as d,n as f,nn as p,on as m,t as h,tt as g,ur as _,wn as v,wr as y,xr as b,zt as x}from"./jsx-runtime-NwRKtVrk.js";import{t as S}from"./request-Blbag3Ot.js";import{r as C}from"./CopyOutlined-bJLUKQgS.js";import{r as w}from"./statusUtils-G17j4Ng-.js";import{t as T}from"./button-CM-rzMOH.js";import{t as E}from"./space-Dvitgohy.js";import{t as D}from"./card-D7XvzVif.js";import{$ as O,St as k,ct as A,lt as ee,mt as te,o as j,st as M}from"./es-Do50EHua.js";import{t as ne}from"./flex-CfpySdsa.js";import{$ as N,M as re,S as ie,T as ae,Y as P,at as oe,g as se,h as F,it as ce,rt as I,s as L}from"./index-B7MUL4ct.js";import{t as le}from"./agent-D8tKYnoa.js";var R=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=a;var t=`accept acceptCharset accessKey action allowFullScreen allowTransparency alt async autoComplete autoFocus autoPlay capture cellPadding cellSpacing challenge charSet checked classID className colSpan cols content contentEditable contextMenu controls coords crossOrigin data dateTime default defer dir disabled download draggable encType form formAction formEncType formMethod formNoValidate formTarget frameBorder headers height hidden high href hrefLang htmlFor httpEquiv icon id inputMode integrity is keyParams keyType kind label lang list loop low manifest marginHeight marginWidth max maxLength media mediaGroup method min minLength multiple muted name noValidate nonce open optimum pattern placeholder poster preload radioGroup readOnly rel required reversed role rowSpan rows sandbox scope scoped scrolling seamless selected shape size sizes span spellCheck src srcDoc srcLang srcSet start step style summary tabIndex target title type useMap value width wmode wrap onCopy onCut onPaste onCompositionEnd onCompositionStart onCompositionUpdate onKeyDown onKeyPress onKeyUp onFocus onBlur onChange onInput onSubmit onClick onContextMenu onDoubleClick onDrag onDragEnd onDragEnter onDragExit onDragLeave onDragOver onDragStart onDrop onMouseDown onMouseEnter onMouseLeave onMouseMove onMouseOut onMouseOver onMouseUp onSelect onTouchCancel onTouchEnd onTouchMove onTouchStart onScroll onWheel onAbort onCanPlay onCanPlayThrough onDurationChange onEmptied onEncrypted onEnded onError onLoadedData onLoadedMetadata onLoadStart onPause onPlay onPlaying onProgress onRateChange onSeeked onSeeking onStalled onSuspend onTimeUpdate onVolumeChange onWaiting onLoad onError`.split(/[\s\n]+/),n=`aria-`,r=`data-`;function i(e,t){return e.indexOf(t)===0}function a(e,a=!1){let o;o=a===!1?{aria:!0,data:!0,attr:!0}:a===!0?{aria:!0}:{...a};let s={};return Object.keys(e).forEach(a=>{(o.aria&&(a===`role`||i(a,n))||o.data&&i(a,r)||o.attr&&t.includes(a))&&(s[a]=e[a])}),s}})),z=r(s()),B=z.createContext({}),ue={classNames:{},styles:{},className:``,style:{},shortcutKeys:{}},de=e=>{let t=z.useContext(B);return z.useMemo(()=>({...ue,...t[e]}),[t[e]])};function V(){let{getPrefixCls:e,direction:t,csp:n,iconPrefixCls:r,theme:i}=z.useContext(g.ConfigContext);return{theme:i,getPrefixCls:e,direction:t,csp:n,iconPrefixCls:r}}var fe=z.createContext({}),pe=t(((e,t)=>{function n(e){return e&&e.__esModule?e:{default:e}}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})),me=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default={items_per_page:`/ page`,jump_to:`Go to`,jump_to_confirm:`confirm`,page:`Page`,prev_page:`Previous Page`,next_page:`Next Page`,prev_5:`Previous 5 Pages`,next_5:`Next 5 Pages`,prev_3:`Previous 3 Pages`,next_3:`Next 3 Pages`,page_size:`Page Size`}})),he=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.commonLocale=void 0,e.commonLocale={yearFormat:`YYYY`,dayFormat:`D`,cellMeridiemFormat:`A`,monthBeforeYear:!0}})),ge=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=he();function n(e){"@babel/helpers - typeof";return n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},n(e)}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function i(e){for(var t=1;t{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default={placeholder:`Select time`,rangePlaceholder:[`Start time`,`End time`]}})),ve=t((e=>{var t=pe().default;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=t(ge()),r=t(_e());e.default={lang:{placeholder:`Select date`,yearPlaceholder:`Select year`,quarterPlaceholder:`Select quarter`,monthPlaceholder:`Select month`,weekPlaceholder:`Select week`,rangePlaceholder:[`Start date`,`End date`],rangeYearPlaceholder:[`Start year`,`End year`],rangeQuarterPlaceholder:[`Start quarter`,`End quarter`],rangeMonthPlaceholder:[`Start month`,`End month`],rangeWeekPlaceholder:[`Start week`,`End week`],...n.default},timePickerLocale:{...r.default}}})),ye=t((e=>{var t=pe().default;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default=t(ve()).default})),be=t((e=>{var t=pe().default;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=t(me()),r=t(ye()),i=t(ve()),a=t(_e()),o="${label} is not a valid ${type}";e.default={locale:`en`,Pagination:n.default,DatePicker:i.default,TimePicker:a.default,Calendar:r.default,global:{placeholder:`Please select`,close:`Close`,sortable:`sortable`,show:`Show`,hide:`Hide`},Table:{filterTitle:`Filter menu`,filterConfirm:`OK`,filterReset:`Reset`,filterEmptyText:`No filters`,filterCheckAll:`Select all items`,filterSearchPlaceholder:`Search in filters`,emptyText:`No data`,selectAll:`Select current page`,selectInvert:`Invert current page`,selectNone:`Clear all data`,selectionAll:`Select all data`,sortTitle:`Sort`,expand:`Expand row`,collapse:`Collapse row`,triggerDesc:`Click to sort descending`,triggerAsc:`Click to sort ascending`,cancelSort:`Click to cancel sorting`},Tour:{Next:`Next`,Previous:`Previous`,Finish:`Finish`},Modal:{okText:`OK`,cancelText:`Cancel`,justOkText:`OK`},Popconfirm:{okText:`OK`,cancelText:`Cancel`},Transfer:{titles:[``,``],searchPlaceholder:`Search here`,itemUnit:`item`,itemsUnit:`items`,remove:`Remove`,selectCurrent:`Select current page`,removeCurrent:`Remove current page`,selectAll:`Select all data`,deselectAll:`Deselect all data`,removeAll:`Remove all data`,selectInvert:`Invert current page`},Upload:{uploading:`Uploading...`,removeFile:`Remove file`,uploadError:`Upload error`,previewFile:`Preview file`,downloadFile:`Download file`},Empty:{description:`No data`},Icon:{icon:`icon`},Text:{edit:`Edit`,copy:`Copy`,copied:`Copied`,expand:`Expand`,collapse:`Collapse`},Form:{optional:`(optional)`,defaultValidateMessages:{default:"Field validation error for ${label}",required:"Please enter ${label}",enum:"${label} must be one of [${enum}]",whitespace:"${label} cannot be a blank character",date:{format:"${label} date format is invalid",parse:"${label} cannot be converted to a date",invalid:"${label} is an invalid date"},types:{string:o,method:o,array:o,object:o,number:o,date:o,boolean:o,integer:o,float:o,regexp:o,email:o,url:o,hex:o},string:{len:"${label} must be ${len} characters",min:"${label} must be at least ${min} characters",max:"${label} must be up to ${max} characters",range:"${label} must be between ${min}-${max} characters"},number:{len:"${label} must be equal to ${len}",min:"${label} must be minimum ${min}",max:"${label} must be maximum ${max}",range:"${label} must be between ${min}-${max}"},array:{len:"Must be ${len} ${label}",min:"At least ${min} ${label}",max:"At most ${max} ${label}",range:"The amount of ${label} must be between ${min}-${max}"},pattern:{mismatch:"${label} does not match the pattern ${pattern}"}}},QRCode:{expired:`QR code expired`,refresh:`Refresh`,scanned:`Scanned`},ColorPicker:{presetEmpty:`Empty`,transparent:`Transparent`,singleColor:`Single`,gradientColor:`Gradient`}}})),xe=t(((e,t)=>{t.exports=be()})),Se=(0,z.createContext)(void 0),H={locale:`en`,Conversations:{create:`New chat`},Sender:{stopLoading:`Stop loading`,speechRecording:`Speech recording`},Actions:{feedbackLike:`Like`,feedbackDislike:`Dislike`,audio:`Play audio`,audioRunning:`Audio playing`,audioError:`Playback error`,audioLoading:`Loading audio`},Bubble:{editableOk:`OK`,editableCancel:`Cancel`},Mermaid:{zoomIn:`Zoom in`,zoomOut:`Zoom out`,zoomReset:`Reset`,download:`Download`,code:`Code`,image:`Image`},Folder:{selectFile:`Please select a file`,loadError:`Failed to load file`,noService:`File content service not configured`,loadFailed:`Failed to load file`}},Ce=r(xe()),we=(e,t)=>{let n=z.useContext(Se);return[z.useMemo(()=>{let r=t||H?.[e]||Ce.default?.[e],i=n?.[e]??{};return{...typeof r==`function`?r():r,...i||{}}},[e,t,n]),z.useMemo(()=>{let e=n?.locale;return n?.exist&&!e?H.locale:e},[n])]};function Te(e){let t=getComputedStyle(e).display;return t===`block`||t===`flex`||t===`list-item`||t===`table`}function Ee(e){let t=[``],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);for(;n.nextNode();){let e=n.currentNode;if(e.nodeType===Node.TEXT_NODE){t[t.length-1]+=e.textContent;continue}e.tagName===`BR`&&e.parentNode?.childElementCount===1||(e.tagName===`BR`||Te(e))&&t.push(``)}return t.join(` `)}var De=({content:e,prefixCls:t,okText:n,cancelText:r,onEditConfirm:i,onEditCancel:a})=>{let o=z.useRef(null),[s]=we(`Bubble`,H.Bubble),c=l(()=>{i?.(Ee(o.current))}),u=l(()=>a?.());if(z.useEffect(()=>{o.current.textContent=e,o.current.focus();let t=window.getSelection(),n=document.createRange();n.selectNodeContents(o.current),n.collapse(!1),t.removeAllRanges(),t.addRange(n)},[]),typeof e!=`string`)throw Error(`Content of editable Bubble should be string`);let d=z.useMemo(()=>z.createElement(`div`,{ref:o,contentEditable:!0}),[]);return z.createElement(z.Fragment,null,d,z.createElement(ne,{rootClassName:`${t}-editing-opts`,gap:8},z.createElement(T,{type:`primary`,shape:`round`,size:`small`,onClick:c},n||s.editableOk),z.createElement(T,{type:`text`,shape:`round`,size:`small`,onClick:u},r||s.editableCancel)))},Oe=({prefixCls:e})=>z.createElement(`span`,{className:`${e}-dot`},z.createElement(`i`,{className:`${e}-dot-item`,key:`item-1`}),z.createElement(`i`,{className:`${e}-dot-item`,key:`item-2`}),z.createElement(`i`,{className:`${e}-dot-item`,key:`item-3`})),ke=`2.8.0`,Ae={blue:`#1677FF`,purple:`#722ED1`,cyan:`#13C2C2`,green:`#52C41A`,magenta:`#EB2F96`,pink:`#EB2F96`,red:`#F5222D`,orange:`#FA8C16`,yellow:`#FADB14`,volcano:`#FA541C`,geekblue:`#2F54EB`,gold:`#FAAD14`,lime:`#A0D911`,colorPrimary:`#1677ff`,colorSuccess:`#52c41a`,colorWarning:`#faad14`,colorError:`#ff4d4f`,colorInfo:`#1677ff`,colorLink:``,colorTextBase:``,colorBgBase:``,fontFamily:`-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'`,fontFamilyCode:`'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace`,fontSize:14,lineWidth:1,lineType:`solid`,motionUnit:.1,motionBase:0,motionEaseOutCirc:`cubic-bezier(0.08, 0.82, 0.17, 1)`,motionEaseInOutCirc:`cubic-bezier(0.78, 0.14, 0.15, 0.86)`,motionEaseOut:`cubic-bezier(0.215, 0.61, 0.355, 1)`,motionEaseInOut:`cubic-bezier(0.645, 0.045, 0.355, 1)`,motionEaseOutBack:`cubic-bezier(0.12, 0.4, 0.29, 1.46)`,motionEaseInBack:`cubic-bezier(0.71, -0.46, 0.88, 0.6)`,motionEaseInQuint:`cubic-bezier(0.755, 0.05, 0.855, 0.06)`,motionEaseOutQuint:`cubic-bezier(0.23, 1, 0.32, 1)`,borderRadius:6,sizeUnit:4,sizeStep:4,sizePopupArrow:16,controlHeight:32,zIndexBase:0,zIndexPopupBase:1e3,opacityImage:1,wireframe:!1,motion:!0};function je(e){return e>=0&&e<=255}function Me(e,t){let{r:n,g:r,b:i,a}=new b(e).toRgb();if(a<1)return e;let{r:o,g:s,b:c}=new b(t).toRgb();for(let e=.01;e<=1;e+=.01){let t=Math.round((n-o*(1-e))/e),a=Math.round((r-s*(1-e))/e),l=Math.round((i-c*(1-e))/e);if(je(t)&&je(a)&&je(l))return new b({r:t,g:a,b:l,a:Math.round(e*100)/100}).toRgbString()}return new b({r:n,g:r,b:i,a:1}).toRgbString()}function Ne(e){let{override:t,...n}=e,r={...t};Object.keys(Ae).forEach(e=>{delete r[e]});let i={...n,...r},a=1200,o=1600;return i.motion===!1&&(i.motionDurationFast=`0s`,i.motionDurationMid=`0s`,i.motionDurationSlow=`0s`),{...i,colorFillContent:i.colorFillSecondary,colorFillContentHover:i.colorFill,colorFillAlter:i.colorFillQuaternary,colorBgContainerDisabled:i.colorFillTertiary,colorBorderBg:i.colorBgContainer,colorSplit:Me(i.colorBorderSecondary,i.colorBgContainer),colorTextPlaceholder:i.colorTextQuaternary,colorTextDisabled:i.colorTextQuaternary,colorTextHeading:i.colorText,colorTextLabel:i.colorTextSecondary,colorTextDescription:i.colorTextTertiary,colorTextLightSolid:i.colorWhite,colorHighlight:i.colorError,colorBgTextHover:i.colorFillSecondary,colorBgTextActive:i.colorFill,colorIcon:i.colorTextTertiary,colorIconHover:i.colorText,colorErrorOutline:Me(i.colorErrorBg,i.colorBgContainer),colorWarningOutline:Me(i.colorWarningBg,i.colorBgContainer),fontSizeIcon:i.fontSizeSM,lineWidthFocus:i.lineWidth*3,lineWidth:i.lineWidth,controlOutlineWidth:i.lineWidth*2,controlInteractiveSize:i.controlHeight/2,controlItemBgHover:i.colorFillTertiary,controlItemBgActive:i.colorPrimaryBg,controlItemBgActiveHover:i.colorPrimaryBgHover,controlItemBgActiveDisabled:i.colorFill,controlTmpOutline:i.colorFillQuaternary,controlOutline:Me(i.colorPrimaryBg,i.colorBgContainer),lineType:i.lineType,borderRadius:i.borderRadius,borderRadiusXS:i.borderRadiusXS,borderRadiusSM:i.borderRadiusSM,borderRadiusLG:i.borderRadiusLG,fontWeightStrong:600,opacityLoading:.65,linkDecoration:`none`,linkHoverDecoration:`none`,linkFocusDecoration:`none`,controlPaddingHorizontal:12,controlPaddingHorizontalSM:8,paddingXXS:i.sizeXXS,paddingXS:i.sizeXS,paddingSM:i.sizeSM,padding:i.size,paddingMD:i.sizeMD,paddingLG:i.sizeLG,paddingXL:i.sizeXL,paddingContentHorizontalLG:i.sizeLG,paddingContentVerticalLG:i.sizeMS,paddingContentHorizontal:i.sizeMS,paddingContentVertical:i.sizeSM,paddingContentHorizontalSM:i.size,paddingContentVerticalSM:i.sizeXS,marginXXS:i.sizeXXS,marginXS:i.sizeXS,marginSM:i.sizeSM,margin:i.size,marginMD:i.sizeMD,marginLG:i.sizeLG,marginXL:i.sizeXL,marginXXL:i.sizeXXL,boxShadow:` 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05) `,boxShadowSecondary:` 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05) `,boxShadowTertiary:` 0 1px 2px 0 rgba(0, 0, 0, 0.03), 0 1px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px 0 rgba(0, 0, 0, 0.02) `,screenXS:480,screenXSMin:480,screenXSMax:575,screenSM:576,screenSMMin:576,screenSMMax:767,screenMD:768,screenMDMin:768,screenMDMax:991,screenLG:992,screenLGMin:992,screenLGMax:a-1,screenXL:a,screenXLMin:a,screenXLMax:o-1,screenXXL:o,screenXXLMin:o,boxShadowPopoverArrow:`2px 2px 5px rgba(0, 0, 0, 0.05)`,boxShadowCard:` 0 1px 2px -2px ${new b(`rgba(0, 0, 0, 0.16)`).toRgbString()}, 0 3px 6px 0 ${new b(`rgba(0, 0, 0, 0.12)`).toRgbString()}, 0 5px 12px 4px ${new b(`rgba(0, 0, 0, 0.09)`).toRgbString()} `,boxShadowDrawerRight:` -6px 0 16px 0 rgba(0, 0, 0, 0.08), -3px 0 6px -4px rgba(0, 0, 0, 0.12), -9px 0 28px 8px rgba(0, 0, 0, 0.05) `,boxShadowDrawerLeft:` 6px 0 16px 0 rgba(0, 0, 0, 0.08), 3px 0 6px -4px rgba(0, 0, 0, 0.12), 9px 0 28px 8px rgba(0, 0, 0, 0.05) `,boxShadowDrawerUp:` 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05) `,boxShadowDrawerDown:` 0 -6px 16px 0 rgba(0, 0, 0, 0.08), 0 -3px 6px -4px rgba(0, 0, 0, 0.12), 0 -9px 28px 8px rgba(0, 0, 0, 0.05) `,boxShadowTabsOverflowLeft:`inset 10px 0 8px -8px rgba(0, 0, 0, 0.08)`,boxShadowTabsOverflowRight:`inset -10px 0 8px -8px rgba(0, 0, 0, 0.08)`,boxShadowTabsOverflowTop:`inset 0 10px 8px -8px rgba(0, 0, 0, 0.08)`,boxShadowTabsOverflowBottom:`inset 0 -10px 8px -8px rgba(0, 0, 0, 0.08)`,...r}}var Pe={lineHeight:!0,lineHeightSM:!0,lineHeightLG:!0,lineHeightHeading1:!0,lineHeightHeading2:!0,lineHeightHeading3:!0,lineHeightHeading4:!0,lineHeightHeading5:!0,opacityLoading:!0,fontWeightStrong:!0,zIndexPopupBase:!0,zIndexBase:!0,opacityImage:!0},Fe={motionBase:!0,motionUnit:!0},Ie=m(se.defaultAlgorithm),Le={screenXS:!0,screenXSMin:!0,screenXSMax:!0,screenSM:!0,screenSMMin:!0,screenSMMax:!0,screenMD:!0,screenMDMin:!0,screenMDMax:!0,screenLG:!0,screenLGMin:!0,screenLGMax:!0,screenXL:!0,screenXLMin:!0,screenXLMax:!0,screenXXL:!0,screenXXLMin:!0},Re=(e,t,n)=>{let r=n.getDerivativeToken(e),{override:i,...a}=t,o={...r,override:i};return o=Ne(o),a&&Object.entries(a).forEach(([e,t])=>{let{theme:n,...r}=t,i=r;n&&(i=Re({...o,...r},{override:r},n)),o[e]=i}),o};function ze(){let{token:e,hashed:t,theme:n,override:r,cssVar:i,zeroRuntime:a}=z.useContext(se._internalContext),o={prefix:i?.prefix??`ant`,key:i?.key??`css-var-root`},s=n||Ie,[c,l,u]=d(s,[se.defaultSeed,e],{salt:`${ke}-${t||``}`,override:r,getComputedToken:Re,cssVar:{...o,unitless:Pe,ignore:Fe,preserve:Le}});return[s,u,t?l:``,c,o,!!a]}function Be(){let[e,t,n]=ze();return{theme:e,token:t,hashId:n}}var{genStyleHooks:Ve,genComponentStyleHook:He,genSubStyleComponent:Ue}=x({usePrefix:()=>{let{getPrefixCls:e,iconPrefixCls:t}=V();return{iconPrefixCls:t,rootPrefixCls:e()}},useToken:()=>{let[e,t,n,r,i,a]=ze();return{theme:e,realToken:t,hashId:n,token:r,cssVar:i,zeroRuntime:a}},useCSP:()=>{let{csp:e}=V();return e??{}},layer:{name:`antdx`}}),We=new p(`loadingMove`,{"0%":{transform:`translateY(0)`},"10%":{transform:`translateY(4px)`},"20%":{transform:`translateY(0)`},"30%":{transform:`translateY(-4px)`},"40%":{transform:`translateY(0)`}}),Ge=new p(`cursorBlink`,{"0%":{opacity:1},"50%":{opacity:0},"100%":{opacity:1}}),Ke=new p(`fadeIn`,{"0%":{opacity:0},"100%":{opacity:1}}),qe=e=>{let{componentCls:t,fontSize:n,typingContent:r,typingAnimationDuration:i,typingAnimationName:a,lineHeight:o,paddingSM:s,colorText:l,calc:u}=e;return[{[t]:{display:`flex`,columnGap:s,[`&${t}-rtl`]:{direction:`rtl`},[`&${t}-loading`]:{alignItems:`center`},[`${t}-body`]:{display:`flex`,flexDirection:`column`,maxWidth:`100%`},[`${t}-content`]:{position:`relative`,boxSizing:`border-box`,minWidth:0,maxWidth:`100%`,minHeight:u(s).mul(2).add(u(o).mul(n)).equal(),paddingInline:`${c(e.padding)}`,paddingBlock:`${c(s)}`,color:l,fontSize:e.fontSize,lineHeight:e.lineHeight,wordBreak:`break-word`,"&-string":{whiteSpace:`pre-wrap`}},[`${t}-typing:last-child::after`]:{content:r,fontWeight:900,userSelect:`none`,opacity:1,marginInlineStart:`0.1em`,animationName:a,animationDuration:c(i),animationIterationCount:`infinite`,animationTimingFunction:`linear`},[`${t}-fade-in .fade-in`]:{display:`inline`,animationName:Ke,animationDuration:`1s`,animationTimingFunction:`linear`},[`${t}-dot`]:{position:`relative`,height:e.controlHeight,display:`flex`,alignItems:`center`,columnGap:e.marginXS,padding:`0 ${c(e.paddingXXS)}`,alignSelf:`center`,"&-item":{backgroundColor:e.colorPrimary,borderRadius:`100%`,width:4,height:4,animationName:We,animationDuration:`2s`,animationIterationCount:`infinite`,animationTimingFunction:`linear`,"&:nth-child(1)":{animationDelay:`0s`},"&:nth-child(2)":{animationDelay:`0.2s`},"&:nth-child(3)":{animationDelay:`0.4s`}}},[`&${t}-start`]:{flexDirection:`row`,alignSelf:`flex-start`,[`& ${t}-header`]:{flexDirection:`row`}},[`&${t}-end`]:{flexDirection:`row-reverse`,alignSelf:`flex-end`,[`& ${t}-header`]:{flexDirection:`row-reverse`},[`& ${t}-editing-opts`]:{flexDirection:`row-reverse`}}}},Ge]},Je=e=>{let{componentCls:t}=e;return{[t]:{[`${t}-content`]:{"&-filled":{backgroundColor:e.colorFillContent},"&-outlined":{border:`1px solid ${e.colorBorderSecondary}`},"&-shadow":{boxShadow:e.boxShadowTertiary},"&-borderless":{backgroundColor:`transparent`,padding:0,minHeight:0}}}}},Ye=e=>{let{componentCls:t,fontSize:n,lineHeight:r,paddingSM:i,borderRadius:a,calc:o}=e,s=o(n).mul(r).div(2).add(i).equal(),c=o(a).mul(2).equal(),l=`${t}-content`;return{[t]:{[l]:{"&-default":{borderRadius:{_skip_check_:!0,value:c}},"&-round":{borderRadius:{_skip_check_:!0,value:s}},"&-corner":{borderRadius:{_skip_check_:!0,value:c}},"&-editing":{"div:first-child":{outline:`none`},[`${t}-editing-opts`]:{marginBlockStart:e.marginSM,"button:last-child":{backgroundColor:e.colorBgContainer,"&:hover":{backgroundColor:e.colorBgLayout}}}}},[`&${t}-start ${t}-content-corner`]:{borderStartStartRadius:e.borderRadiusXS},[`&${t}-end ${t}-content-corner`]:{borderStartEndRadius:e.borderRadiusXS}}}},Xe=e=>{let{componentCls:t}=e;return{[t]:{"&-divider":{width:`100%`,justifyContent:`center`,[`& ${t}-body`]:{width:`100%`}}}}},U=e=>{let{componentCls:t}=e;return{[`${t}-list`]:{maxHeight:`100%`,width:`100%`,boxSizing:`border-box`,[`& ${t}`]:{width:`100%`,boxSizing:`border-box`,paddingBlock:e.padding},[`& ${t}-start:not(${t}-divider):not(${t}-system)`]:{paddingInlineEnd:`15%`},[`& ${t}-end:not(${t}-divider):not(${t}-system)`]:{paddingInlineStart:`15%`},[`${t}-list-scroll-box`]:{overflowY:`auto`,display:`flex`,width:`100%`,maxHeight:`100%`,flexDirection:`column`,scrollbarWidth:`thin`,scrollbarColor:`${e.colorTextTertiary} transparent`,"&::-webkit-scrollbar":{width:8,backgroundColor:`transparent`},"&::-webkit-scrollbar-thumb":{backgroundColor:e.colorTextTertiary,borderRadius:e.borderRadiusSM}},[`${t}-list-autoscroll`]:{flexDirection:`column-reverse`},[`${t}-list-scroll-content`]:{display:`flex`,width:`100%`,height:`fit-content`,flexDirection:`column`,boxSizing:`border-box`,paddingInline:e.paddingXS}}}},Ze=e=>{let{componentCls:t,fontSize:n,lineHeight:r,paddingXXS:i,margin:a,colorText:o,fontSizeLG:s,calc:c}=e;return{[t]:{[`${t}-header`]:{display:`flex`,marginBottom:i,fontSize:n,lineHeight:r,color:o},[`${t}-footer`]:{display:`flex`,marginBlockStart:a,fontSize:n,lineHeight:r,color:o,"&-start":{flexDirection:`row`},"&-end":{flexDirection:`row-reverse`}},[`${t}-avatar`]:{minWidth:c(s).mul(2).equal()}}}},Qe=e=>{let{componentCls:t,paddingSM:n,paddingXS:r,lineHeight:i,fontSize:a,fontSizeSM:o,calc:s}=e;return{[t]:{[`&${t}-system`]:{width:`100%`,justifyContent:`center`,[`${t}-content`]:{display:`flex`,gap:`${c(o)}`,alignItems:`center`,minHeight:s(r).mul(2).add(s(i).mul(a)).equal(),fontSize:`${c(a)}`,paddingInline:`${c(n)}`,paddingBlock:`${c(r)}`},[`${t}-system-content`]:{},[`${t}-system-extra`]:{}}}}},$e=Ve(`Bubble`,t=>{let n=e(t,{});return[qe(n),Je(n),Ye(n),Ze(n),U(n),Qe(n),Xe(n)]},()=>({typingContent:`"|"`,typingAnimationName:`cursorBlink`,typingAnimationDuration:`0.8s`})),et=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=t;function t(){return!!(typeof window<`u`&&window.document&&window.document.createElement)}})),tt=r(t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.useLayoutUpdateEffect=e.default=void 0;var t=a(s()),n=r(et());function r(e){return e&&e.__esModule?e:{default:e}}function i(e){if(typeof WeakMap!=`function`)return null;var t=new WeakMap,n=new WeakMap;return(i=function(e){return e?n:t})(e)}function a(e,t){if(!t&&e&&e.__esModule)return e;if(e===null||typeof e!=`object`&&typeof e!=`function`)return{default:e};var n=i(t);if(n&&n.has(e))return n.get(e);var r={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(o!=="default"&&Object.prototype.hasOwnProperty.call(e,o)){var s=a?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}var o=(0,n.default)()?t.useLayoutEffect:t.useEffect,c=(e,n)=>{let r=t.useRef(!0);o(()=>e(r.current),n),o(()=>(r.current=!1,()=>{r.current=!0}),[])};e.useLayoutUpdateEffect=(e,t)=>{c(t=>{if(!t)return e()},t)},e.default=c}))());function nt(e){return!e||e.length===0?``:e.reduce((e,t)=>{let n=0;for(;n{let e={effect:`fade-in`,interval:100,step:6,keepPrefix:!0};if(n===!0)return e;let{step:t=6,interval:r=100}=n,i=e=>typeof e==`number`;if(!i(r)||r<=0)throw`[Bubble] invalid prop typing.interval, expect positive number.`;if(!i(t)&&!Array.isArray(t))throw`[Bubble] invalid prop typing.step, expect positive number or positive number array`;if(i(t)&&t<=0)throw`[Bubble] invalid prop typing.step, expect positive number`;if(Array.isArray(t)){if(!i(t[0])||t[0]<=0)throw`[Bubble] invalid prop typing.step[0], expect positive number`;if(!i(t[1])||t[1]<=0)throw`[Bubble] invalid prop typing.step[1], expect positive number`;if(t[0]>t[1])throw`[Bubble] invalid prop typing.step, step[0] should less than step[1]`}return{...e,...n}},[n]),p=z.useRef({content:t,interval:f.interval,step:f.step});p.current={content:t,interval:f.interval,step:f.step};let m=()=>Math.random().toString().slice(2),h=z.useCallback(e=>{let t=0;c.current=f.keepPrefix?nt([p.current.content,c.current]):``,o(c.current?[{text:c.current,id:m(),taskId:e,done:!0}]:[]);let n=()=>{if(e!==l.current)return;let a=performance.now(),{content:f,interval:h,step:g}=p.current;if(a-t[{text:t.map(({text:e})=>e).join(``),id:m(),taskId:e,done:!0}]),i?.(f),s.current=!1,l.current++;return}c.current+=y;let b={id:m(),text:y,taskId:e,done:!1};o(e=>e.concat(b)),s.current||=!0,t=a,u.current=requestAnimationFrame(n),r?.(c.current,f)};n()},[f.keepPrefix,r,i]),g=z.useCallback(()=>{cancelAnimationFrame(u.current),o([]),c.current=``,s.current=!1},[]);return(0,tt.default)(()=>{if(!t)return g();t!==c.current&&(s.current&&!t.startsWith(c.current)?(cancelAnimationFrame(u.current),s.current=!1,requestAnimationFrame(()=>h(++l.current))):s.current===!1&&h(l.current))},[t,h]),{renderedData:a,animating:s.current,memoedAnimationCfg:f}}var it=({prefixCls:e,streaming:t,content:n,typing:r,onTyping:i,onTypingComplete:a})=>{let{renderedData:s,animating:c,memoedAnimationCfg:l}=rt({streaming:t,content:n,typing:r,onTyping:i,onTypingComplete:a}),{effect:u}=l,d=s.map(e=>u===`fade-in`&&!e.done?z.createElement(`span`,{key:e.id,className:`fade-in`},e.text):e.text),f=r===!0?!1:u===`typing`;return z.createElement(`div`,{className:o({[`${e}-typing`]:f&&c,[`${e}-fade-in`]:!f})},d)},at=r(R()),ot=z.forwardRef(({prefixCls:e,rootClassName:t,style:r,className:i,styles:a={},classNames:s={},placement:c=`start`,content:l,contentRender:u,editable:d=!1,typing:f,streaming:p=!1,variant:m=`filled`,shape:h=`default`,header:g,footer:_,avatar:v,extra:y,footerPlacement:b,loading:x,loadingRender:S,onTyping:C,onTypingComplete:w,onEditConfirm:T,onEditCancel:E,...D},O)=>{let k=z.useRef(null);z.useImperativeHandle(O,()=>({nativeElement:k.current}));let A=de(`bubble`),{direction:ee,getPrefixCls:te}=V(),j=te(`bubble`,e),M=z.useContext(fe),[ne,N]=$e(j),re={...A.style,...A.styles.root,...a.root,...r},ie=o(j,A.className,A.classNames.root,s.root,t,i,ne,N,`${j}-${c}`,{[`${j}-${M.status}`]:M.status,[`${j}-rtl`]:ee===`rtl`,[`${j}-loading`]:x}),ae=(0,at.default)(D,{attr:!0,aria:!0,data:!0}),P={key:M?.key,status:M?.status,extraInfo:M?.extraInfo},oe=z.useMemo(()=>u?u(l,P):l,[l,u,P.key,P.status,P.extraInfo]),se=typeof f==`function`?f(l,P):f,F=!!se&&typeof oe==`string`;z.useEffect(()=>{F||p||l&&w?.(l)},[oe,F,p]);let ce=b||(c===`start`?`outer-start`:`outer-end`),I=typeof d==`boolean`?d:d.editing,L=()=>{if(x)return S?S():z.createElement(Oe,{prefixCls:j});let e=z.createElement(z.Fragment,null,F?z.createElement(it,{prefixCls:j,streaming:p,typing:se,content:oe,onTyping:C,onTypingComplete:w}):oe),t=ce.includes(`inner`);return z.createElement(`div`,{className:le(`body`),style:R(`body`)},me(),z.createElement(`div`,{style:{...A.styles.content,...a.content},className:o(`${j}-content`,`${j}-content-${m}`,A.classNames.content,s.content,{[`${j}-content-${M?.status}`]:M?.status,[`${j}-content-${h}`]:m!==`borderless`,[`${j}-content-editing`]:I,[`${j}-content-string`]:typeof oe==`string`})},I?z.createElement(De,{prefixCls:j,content:l,okText:d?.okText,cancelText:d?.cancelText,onEditConfirm:T,onEditCancel:E}):z.createElement(z.Fragment,null,t?z.createElement(`div`,{className:o(`${j}-content-with-footer`)},e):e,t&&he())),!I&&!t&&he())},le=e=>o(`${j}-${e}`,A.classNames[e],s[e]),R=e=>({...A.styles[e],...a[e]}),B=e=>typeof e==`function`?e(l,P):e,ue=()=>v?z.createElement(`div`,{className:le(`avatar`),style:R(`avatar`)},B(v)):null,pe=()=>y?z.createElement(`div`,{className:le(`extra`),style:R(`extra`)},B(y)):null,me=()=>g?z.createElement(`div`,{className:le(`header`),style:R(`header`)},B(g)):null,he=()=>{if(!_)return null;let e=o(le(`footer`),{[`${j}-footer-start`]:ce.includes(`start`),[`${j}-footer-end`]:ce.includes(`end`)});return z.createElement(`div`,{className:e,style:R(`footer`)},B(_))};return z.createElement(`div`,n({className:ie,style:re},D,ae,{ref:k}),ue(),L(),!I&&!x&&pe())}),st=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=t;function t(e,t){let n=Object.assign({},e);return Array.isArray(t)&&t.forEach(e=>{delete n[e]}),n}}));function ct(e,t){return(0,z.useImperativeHandle)(e,()=>{let e=t(),{nativeElement:n}=e;return new Proxy(n,{get(t,n){return e[n]?e[n]:Reflect.get(t,n)}})})}var lt=z.forwardRef(({prefixCls:e,content:t=``,rootClassName:r,style:i,className:a,styles:s={},classNames:c={},dividerProps:l,...u},d)=>{let{getPrefixCls:f}=V(),p=de(`bubble`),m=f(`bubble`,e),[h,g]=$e(m),_=o(h,g,m,`${m}-divider`,p.className,p.classNames.root,a,c.root,r);return z.createElement(ot,n({ref:d,style:i,styles:s,className:_,classNames:c,prefixCls:m,variant:`borderless`,content:t,contentRender:e=>z.createElement(re,l,e)},u))});function ut(e){return getComputedStyle(e).flexDirection===`column-reverse`}function dt(e,t){let n=(0,z.useRef)(null),r=(0,z.useRef)(!0),i=(0,z.useRef)(!1),a=(0,z.useRef)(0),o=(0,z.useRef)(void 0),s=(0,z.useRef)(!1),c=(0,z.useRef)(!1);(0,z.useLayoutEffect)(()=>{if(!e||!t)return;if(!n.current){let t=document.createElement(`div`);t.style.bottom=`0`,t.style.flexShrink=`0`,t.style.pointerEvents=`none`,t.style.height=`10px`,t.style.visibility=`hidden`,e.insertBefore(t,e.firstChild),n.current=t}let a=new IntersectionObserver(([e])=>{r.current=e.isIntersecting,i.current=!e.isIntersecting},{root:e,threshold:0});a.observe(n.current);let s=new ResizeObserver(()=>{if(e){if(o.current){c.current&&requestAnimationFrame(()=>e.scrollTo({top:ut(e)?0:e.scrollHeight,behavior:`instant`}));return}ut(e)&&i.current&&d()}});return s.observe(t),()=>{a.disconnect(),s.disconnect(),clearTimeout(o.current),n.current?.parentNode&&(n.current.parentNode.removeChild(n.current),n.current=null)}},[e,t]);let l=(0,z.useCallback)(()=>{o.current=setTimeout(()=>{clearTimeout(o.current),o.current=void 0,c.current=!1},50)},[]),u=(0,z.useCallback)(e=>{let t=e.target;if(!ut(t))return;let{scrollTop:n,scrollHeight:r}=t;if(a.current=r+n,s.current){s.current=!1;return}o.current&&clearTimeout(o.current),l()},[l]);(0,z.useLayoutEffect)(()=>{if(e)return e.addEventListener(`scroll`,u,{capture:!0}),()=>e?.removeEventListener(`scroll`,u,{capture:!0})},[e,u]);let d=(0,z.useCallback)(()=>{e.scrollTop=a.current-e.scrollHeight,s.current=!0},[e]);return{reset:(0,z.useCallback)(()=>{r.current=!0,i.current=!1,a.current=e?.scrollHeight||0},[e]),scrollTo:(0,z.useCallback)(n=>{if(!e||!t)return;let{top:r,intoView:i,intoViewDom:a}=n||{};ut(e)?r!==void 0&&r>=-10?c.current=!0:a&&i?.block===`end`?c.current=t.lastElementChild===a:c.current=!1:r!==void 0&&r>=e.scrollHeight-e.clientHeight-10?c.current=!0:a&&i?.block===`end`?c.current=t.lastElementChild===a:c.current=!1,o.current||l(),a?a.scrollIntoView(i):e.scrollTo(n)},[e,t])}}var ft=z.forwardRef(({prefixCls:e,content:t,variant:r=`shadow`,shape:i,style:a,className:s,styles:c={},classNames:l={},rootClassName:u,...d},f)=>{let p=de(`bubble`),{getPrefixCls:m}=V(),h=m(`bubble`,e),[g,_]=$e(h),v=o(g,_,`${h}-system`,h,p.className,p.classNames.root,l.root,s,u);return z.createElement(ot,n({ref:f,style:a,className:v,styles:c,classNames:l,variant:r,shape:i,content:t},d))}),pt=r(st());function mt(e){return typeof e==`function`&&e instanceof Function}var ht=z.memo(ot),gt=z.memo(lt),_t=z.memo(ft),vt=e=>{let{_key:t,bubblesRef:r,extraInfo:i,status:a,role:o,classNames:s={},styles:c={},...l}=e,u=z.useCallback(e=>{e?r.current[t]=e:delete r.current[t]},[t]),{root:d,bubble:f,divider:p,system:m,...h}=s,{root:g,bubble:_,divider:v,system:y,...b}=c,x=z.createElement(ht,n({ref:u,style:g||_,className:d||f,classNames:h,styles:b},l));return o===`divider`?x=z.createElement(gt,n({ref:u,style:g||v,className:d||p,classNames:h,styles:b},l)):o===`system`&&(x=z.createElement(_t,n({ref:u,style:g||y,className:d||m,classNames:h,styles:b},l))),z.createElement(fe.Provider,{value:{key:t,status:a,extraInfo:i}},x)};ot.List=z.forwardRef((e,t)=>{let{prefixCls:r,rootClassName:i,className:a,styles:s={},classNames:c={},style:l,items:u,autoScroll:d=!0,role:f,onScroll:p,...m}=e,h=(0,at.default)(m,{attr:!0,aria:!0}),g=z.useRef(null),_=z.useRef({}),[v,y]=z.useState(),[b,x]=z.useState(),{scrollTo:S}=dt(v,b),{getPrefixCls:C}=V(),w=C(`bubble`,r),T=`${w}-list`,[E,D]=$e(w),O=o(T,i,a,c.root,E,D),k={...s.root,...l};return ct(t,()=>({nativeElement:g.current,scrollBoxNativeElement:v,scrollTo:({key:e,top:t,behavior:n=`smooth`,block:r})=>{let{scrollHeight:i,clientHeight:a}=v;typeof t==`number`?S({top:d?-i+a+t:t,behavior:n}):t===`bottom`?S({top:d?0:i,behavior:n}):t===`top`?S({top:d?-i:0,behavior:n}):e&&_.current[e]&&S({intoView:{behavior:n,block:r},intoViewDom:_.current[e].nativeElement})}})),z.createElement(`div`,n({},h,{className:O,style:k,ref:g}),z.createElement(`div`,{className:o(`${T}-scroll-box`,c.scroll,{[`${T}-autoscroll`]:d}),style:s.scroll,ref:e=>y(e),onScroll:p},z.createElement(`div`,{ref:e=>x(e),className:o(`${T}-scroll-content`)},u.map(e=>{let t;if(e.role&&f){let n=f[e.role];t={...mt(n)?n(e):n,...e}}else t=e;return z.createElement(vt,n({classNames:(0,pt.default)(c,[`root`,`scroll`]),styles:(0,pt.default)(s,[`root`,`scroll`])},(0,pt.default)(t,[`key`]),{key:e.key,_key:e.key,bubblesRef:_}))}))))}),ot.System=ft,ot.Divider=lt;var yt=ot,bt=()=>({height:0,opacity:0}),xt=e=>{let{scrollHeight:t}=e;return{height:t,opacity:1}},St=e=>({height:e?e.offsetHeight:0}),Ct=(e,t)=>t?.deadline===!0||t.propertyName===`height`,wt=(e=`ant`)=>({motionName:`${e}-motion-collapse`,onAppearStart:bt,onEnterStart:bt,onAppearActive:xt,onEnterActive:xt,onLeaveStart:St,onLeaveActive:bt,onAppearEnd:Ct,onEnterEnd:Ct,onLeaveEnd:Ct,motionDeadline:500}),Tt=(e,t,n)=>{let r=typeof e==`boolean`||e?.expandedKeys===void 0,[i,a,o,s]=z.useMemo(()=>{let t={expandedKeys:[],defaultExpandedKeys:[],onExpand:()=>{}};return e?(typeof e==`object`&&(t={...t,...e}),[!0,t.defaultExpandedKeys,t.expandedKeys,t.onExpand]):[!1,t.defaultExpandedKeys,t.expandedKeys,t.onExpand]},[e]),[c,l]=_(a||[],r?void 0:o),u=e=>{l(t=>{let n=r?t:o,i=n.includes(e)?n.filter(t=>t!==e):[...n,e];return s?.(i),i})},d=z.useMemo(()=>i?{...wt(n),motionAppear:!1,leavedClassName:`${t}-content-hidden`}:{},[n,t,i]);return[i,c,i?u:void 0,d]},Et=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t={MAC_ENTER:3,BACKSPACE:8,TAB:9,NUM_CENTER:12,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PRINT_SCREEN:44,INSERT:45,DELETE:46,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,QUESTION_MARK:63,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,META:91,WIN_KEY_RIGHT:92,CONTEXT_MENU:93,NUM_ZERO:96,NUM_ONE:97,NUM_TWO:98,NUM_THREE:99,NUM_FOUR:100,NUM_FIVE:101,NUM_SIX:102,NUM_SEVEN:103,NUM_EIGHT:104,NUM_NINE:105,NUM_MULTIPLY:106,NUM_PLUS:107,NUM_MINUS:109,NUM_PERIOD:110,NUM_DIVISION:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,NUMLOCK:144,SEMICOLON:186,DASH:189,EQUALS:187,COMMA:188,PERIOD:190,SLASH:191,APOSTROPHE:192,SINGLE_QUOTE:222,OPEN_SQUARE_BRACKET:219,BACKSLASH:220,CLOSE_SQUARE_BRACKET:221,WIN_KEY:224,MAC_FF_META:224,WIN_IME:229,isTextModifyingKeyEvent:function(e){let{keyCode:n}=e;if(e.altKey&&!e.ctrlKey||e.metaKey||n>=t.F1&&n<=t.F12)return!1;switch(n){case t.ALT:case t.CAPS_LOCK:case t.CONTEXT_MENU:case t.CTRL:case t.DOWN:case t.END:case t.ESC:case t.HOME:case t.INSERT:case t.LEFT:case t.MAC_FF_META:case t.META:case t.NUMLOCK:case t.NUM_CENTER:case t.PAGE_DOWN:case t.PAGE_UP:case t.PAUSE:case t.PRINT_SCREEN:case t.RIGHT:case t.SHIFT:case t.UP:case t.WIN_KEY:case t.WIN_KEY_RIGHT:return!1;default:return!0}},isCharacterKey:function(e){if(e>=t.ZERO&&e<=t.NINE||e>=t.NUM_ZERO&&e<=t.NUM_MULTIPLY||e>=t.A&&e<=t.Z||window.navigator.userAgent.indexOf(`WebKit`)!==-1&&e===0)return!0;switch(e){case t.SPACE:case t.QUESTION_MARK:case t.NUM_PLUS:case t.NUM_MINUS:case t.NUM_PERIOD:case t.NUM_DIVISION:case t.SEMICOLON:case t.DASH:case t.EQUALS:case t.COMMA:case t.PERIOD:case t.SLASH:case t.APOSTROPHE:case t.SINGLE_QUOTE:case t.OPEN_SQUARE_BRACKET:case t.BACKSLASH:case t.CLOSE_SQUARE_BRACKET:return!0;default:return!1}},isEditableTarget:function(e){let t=e.target;if(!(t instanceof HTMLElement))return!1;let n=t.tagName;return!!(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t.isContentEditable)}};e.default=t}));t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.preMessage=void 0;var t={},n=[],r=e=>{n.push(e)};e.preMessage=r;function i(e,t){}function a(e,t){}function o(){t={}}function s(e,n,r){!n&&!t[r]&&(e(!1,r),t[r]=!0)}function c(e,t){s(i,e,t)}function l(e,t){s(a,e,t)}c.preMessage=r,c.resetWarned=o,c.noteOnce=l,e.default=c}))();function Dt(){}var W=Dt,Ot=r(Et()),kt={Alt:[`altKey`,`⌥`,`Alt`],Ctrl:[`ctrlKey`,`⌃`,`Ctrl`],Meta:[`metaKey`,`⌘`,`Win`],Shift:[`shiftKey`,`⇧`,`Shift`]},At=Array.from({length:9},(e,t)=>Ot.default.ONE+t),jt=/(mac|iphone|ipod|ipad)/i.test(typeof navigator<`u`?navigator?.platform:``),Mt=e=>e===`number`?e:typeof e==`string`&&kt?.[e]?.[jt?1:2]?kt[e][jt?1:2]:Object.entries(Ot.default||{})?.find(([t,n])=>n===e)?.[0]||``,Nt=(e,t)=>{let n=[...e],r=n.pop();return n.reduce((e,n)=>e&&(t[kt?.[n]?.[0]]||!1),r===t.keyCode)?{actionShortcutKey:e,actionKeyCodeNumber:At.indexOf(t.keyCode)>-1?At.indexOf(t.keyCode):!1,actionKeyCode:t.keyCode,timeStamp:t.timeStamp}:!1},Pt=e=>{let t=[...e],n=t.pop();return{keyCodeDict:n===`number`?At:[n],prefixKeys:t}},Ft=(e,t,n)=>{W(!e.find(({shortcutKey:e})=>e.toString()===t.toString()),n,`Same shortcutKey ${t.toString()}`)},It=(e,t,n)=>{let r=Object.assign({},t||{},n);return Object.keys(r).reduce(({flattenShortcutKeys:t,shortcutKeysInfo:n},i)=>{let a=r[i];if(!Array.isArray(a))return{flattenShortcutKeys:t,shortcutKeysInfo:n};if(n={...n,[i]:{shortcutKeys:a,shortcutKeysIcon:[]}},a.every(e=>Array.isArray(e)))a.forEach((r,a)=>{let o=r;Ft(t,o,e),t.push({name:i,shortcutKey:o,index:a}),n[i].shortcutKeysIcon.push(o?.map(e=>Mt(e)))});else{let{keyCodeDict:r,prefixKeys:o}=Pt(a);r.forEach(n=>{Ft(t,[...o,n],e),t.push({name:i,shortcutKey:[...o,n]})}),n[i].shortcutKeysIcon=a.map(e=>Mt(e))}return{flattenShortcutKeys:t,shortcutKeysInfo:n}},{flattenShortcutKeys:[],shortcutKeysInfo:{}})},Lt=()=>{let e=(0,z.useRef)(void 0);return[e,t=>{e.current=t}]},Rt=(e,t)=>{let{flattenShortcutKeys:n,shortcutKeysInfo:r}=It(e,de(e).shortcutKeys,t),[i,a]=(0,z.useState)(null),[o,s]=Lt(),c=(0,z.useRef)(!1),l=e=>{for(let t of n){let n=Nt(t.shortcutKey,e);if(n){let e={...n,name:t.name,index:t?.index};if(c.current)return;c.current=!0,a(e),o?.current?.(e)}}},u=()=>{c.current=!1};return(0,z.useEffect)(()=>{if(n.length!==0)return document.addEventListener(`keydown`,l),document.addEventListener(`keyup`,u),()=>{document.removeEventListener(`keydown`,l),document.removeEventListener(`keyup`,u)}},[n.length,o]),[i,r,s]},zt=({shortcutKeysIcon:e,prefixCls:t})=>{let[n]=we(`Conversations`,H.Conversations),r=!!e?.length;return z.createElement(`div`,{className:o(t,{[`${t}-shortcut-keys-show`]:r})},z.createElement(`span`,null,n.create),r&&z.createElement(`span`,{className:o(`${t}-shortcut-keys`)},e.map(e=>z.createElement(`span`,{className:o(`${t}-shortcut-key`),key:e},e))))},Bt=({icon:e,label:t,align:n,shortcutKeyInfo:r,prefixCls:i})=>{let{shortcutKeysIcon:a}=r||{},o={label:z.createElement(zt,{prefixCls:`${i}-label`,shortcutKeysIcon:a}),icon:z.createElement(f,{className:`${i}-icon`}),align:`center`};return t&&(o.label=typeof t==`function`?t({shortcutKeyInfo:r,components:{CreationLabel:zt}}):t),e&&(o.icon=typeof e==`function`?e():e),[o.icon,o.label,n||o.align]},Vt=({className:e,icon:t,label:n,align:r,style:i,disabled:a,onClick:s,prefixCls:c,shortcutKeyInfo:l})=>{let[u,d,f]=Bt({prefixCls:c,label:n,icon:t,align:r,shortcutKeyInfo:l});return z.createElement(`button`,{type:`button`,onClick:e=>{a||s?.(e)},style:i,className:o(c,e,`${c}-${f}`,{[`${c}-disabled`]:a})},u,d)},Ht=z.createContext(null),Ut=({className:e,children:t})=>{let{prefixCls:r,groupInfo:s,enableCollapse:c,expandedKeys:l,onItemExpand:u,collapseMotion:d}=z.useContext(Ht)||{},{label:f,name:p,collapsible:m}=s||{},h=typeof f==`function`?f(p,{groupInfo:s}):f||p,g=m&&c,_=()=>{g&&u?.(s.name)},v=g&&!!l?.includes?.(p);return z.createElement(`li`,{className:e},z.createElement(`div`,{className:o(`${r}-group-title`,{[`${r}-group-title-collapsible`]:g}),onClick:_},h&&z.createElement(`div`,{className:o(`${r}-group-label`)},h),g&&z.createElement(`div`,{className:o(`${r}-group-collapse-trigger `,`${r}-group-collapse-trigger-${v?`open`:`close`}`)},z.createElement(i,null))),z.createElement(a,n({},d,{visible:g?v:!0}),({className:e,style:n},r)=>z.createElement(`div`,{className:o(e),ref:r,style:n},t)))},Wt=(e,t=[])=>{let[n,r,i]=(0,z.useMemo)(()=>{let t={label:``,collapsibleHandle:!1,collapsibleOptions:{}};if(!e)return[``,t.collapsibleHandle,t.collapsibleOptions];if(typeof e==`object`){let{collapsible:n,defaultExpandedKeys:r,expandedKeys:i,onExpand:a,...o}=e;t={...t,...o,collapsibleHandle:n,collapsibleOptions:{defaultExpandedKeys:r,expandedKeys:i,onExpand:a}}}return[t.label,t.collapsibleHandle,t.collapsibleOptions]},[e]);return z.useMemo(()=>{let a=t.reduce((t,i)=>{if(i?.type===`divider`||!i.group||!e)return t.push({data:[i],name:``,label:``,enableGroup:!1,collapsible:!1}),t;let a=i,o=t.some((e,n)=>e.name===a?.group?(t[n].data.push(a),!0):!1),s=typeof r==`function`?r?.(a?.group):r;return o||t.push({data:[a],enableGroup:!0,name:a?.group,label:n,collapsible:s}),t},[]);return[a,i,a.reduce((e,t)=>(t.data.forEach(t=>{t.type!==`divider`&&e.push({key:t.key,disabled:t.disabled})}),e),[])]},[t,i])},Gt=e=>{e.stopPropagation()},Kt=e=>{let{prefixCls:t,info:r,className:i,direction:a,onClick:s,active:c,menu:l,...d}=e,f=(0,at.default)(d,{aria:!0,data:!0,attr:!0}),{disabled:p}=r,m=o(i,`${t}-item`,{[`${t}-item-active`]:c&&!p},{[`${t}-item-disabled`]:p}),h=()=>{!p&&s&&s(r.key)},{trigger:g,..._}=l||{},v=_?.getPopupContainer;return z.createElement(`li`,n({title:typeof r.label==`object`?void 0:`${r.label}`},f,{className:m,onClick:h}),r.icon&&z.createElement(`div`,{className:`${t}-icon`},r.icon),z.createElement(F.Text,{className:`${t}-label`},r.label),!p&&l&&z.createElement(`div`,{onClick:Gt},z.createElement(ae,{menu:_,placement:a===`rtl`?`bottomLeft`:`bottomRight`,trigger:[`click`],disabled:p,getPopupContainer:v},(e=>{let n=z.createElement(u,{onClick:Gt,className:`${t}-menu-icon`});return g?typeof g==`function`?g(e,{originNode:n}):g:n})(r))))},qt=e=>({[e.componentCls]:{[`${e.antCls}-motion-collapse-legacy`]:{overflow:`hidden`,"&-active":{transition:`height ${e.motionDurationMid} ${e.motionEaseInOut}, opacity ${e.motionDurationMid} ${e.motionEaseInOut} !important`}},[`${e.antCls}-motion-collapse`]:{overflow:`hidden`,transition:`height ${e.motionDurationMid} ${e.motionEaseInOut}, opacity ${e.motionDurationMid} ${e.motionEaseInOut} !important`}}}),Jt=e=>{let{componentCls:t,calc:n}=e;return{[t]:{display:`flex`,flexDirection:`column`,gap:e.paddingXXS,overflowY:`auto`,padding:e.paddingSM,margin:0,listStyle:`none`,"ul, ol":{margin:0,padding:0,listStyle:`none`},[`&${t}-rtl`]:{direction:`rtl`},[`${t}-creation`]:{backgroundColor:e.creationBgColor,color:e.colorPrimary,border:`none`,fontWeight:500,paddingBlock:e.paddingXS,paddingInline:e.paddingSM,fontSize:e.fontSize,cursor:`pointer`,display:`flex`,gap:e.paddingXS,marginBlockEnd:e.marginSM,lineHeight:e.lineHeight,borderRadius:e.borderRadiusLG,transition:`all ${e.motionDurationMid} ${e.motionEaseInOut}`,[`&:not(${t}-creation-disabled):hover`]:{color:e.colorPrimary,background:e.creationHoverColor},[`&:not(${t}-creation-disabled)`]:{border:`${c(e.lineWidth)} ${e.lineType}, ${e.creationBorderColor}`},"&-start":{justifyContent:`flex-start`},"&-center":{justifyContent:`center`},"&-end":{justifyContent:`flex-end`},"&-label":{display:`flex`,justifyContent:`space-between`,alignItems:`center`},"&-label-shortcut-keys-show":{flex:1},"&-label-shortcut-keys":{height:e.controlHeightXS,display:`flex`,alignItems:`center`,gap:c(4)},"&-label-shortcut-key":{borderRadius:e.borderRadiusSM,height:`100%`,boxSizing:`border-box`,fontSize:e.fontSizeIcon,paddingInline:`${c(n(e.paddingXXS).sub(1).equal())}`,display:`flex`,justifyContent:`center`,alignItems:`center`,color:e.shortcutKeyTextColor,border:`${c(e.lineWidth)} ${e.lineType}, ${e.creationBorderColor}`},"&-disabled":{cursor:`not-allowed`,background:e.colorBgContainerDisabled,[`& ${t}-creation-label, ${t}-creation-icon`]:{color:e.colorTextDisabled},[`& ${t}-creation-label-shortcut-keys`]:{color:e.colorTextDisabled,border:`${c(e.lineWidth)} ${e.lineType}, ${e.colorBgContainerDisabled}`}}},[`${t}-divider`]:{marginBlock:e.marginXXS},[`${t}-item`]:{display:`flex`,height:e.controlHeightLG,minHeight:e.controlHeightLG,gap:e.paddingXS,padding:`0 ${c(e.paddingXS)}`,alignItems:`center`,borderRadius:e.borderRadiusLG,cursor:`pointer`,transition:`all ${e.motionDurationMid} ${e.motionEaseInOut}`,[`&:not(${t}-item-disabled):hover`]:{backgroundColor:e.colorBgTextHover},"&-active":{backgroundColor:e.colorBgTextHover,[`& ${t}-label, ${t}-menu-icon`]:{color:e.colorText}},"&-disabled":{cursor:`not-allowed`,[`& ${t}-label, ${t}-icon, ${t}-menu-icon`]:{color:e.colorTextDisabled}},"&:hover, &-active":{[`& ${t}-menu-icon`]:{opacity:.6}},[`${t}-menu-icon:hover`]:{opacity:1}},[`${t}-content-hidden`]:{display:`none`},[`${t}-label`]:{flex:1,color:e.colorText,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},[`${t}-menu-icon`]:{opacity:0,fontSize:e.fontSizeXL},[`${t}-list`]:{display:`flex`,gap:e.paddingXXS,flexDirection:`column`},[`${t}-group-collapsible-list`]:{paddingBlockStart:e.paddingXXS,[`& ${t}-item`]:{paddingInlineStart:e.paddingXL}},[`${t}-group-title`]:{display:`flex`,alignItems:`center`,color:e.colorTextDescription,height:e.controlHeightLG,minHeight:e.controlHeightLG,padding:`0 ${c(e.paddingXS)}`},[`${t}-group-title-collapsible`]:{justifyContent:`space-between`,cursor:`pointer`,color:e.colorText,borderRadius:e.borderRadiusLG,transition:`all ${e.motionDurationMid} ${e.motionEaseInOut}`,"&:hover":{backgroundColor:e.colorBgTextHover}},[`${t}-group-collapse-trigger`]:{transition:`all ${e.motionDurationMid} ${e.motionEaseInOut}`,transform:`rotate(0deg)`,transformOrigin:`center center`},[`${t}-group-collapse-trigger-open`]:{transform:`rotate(90deg)`},[`${t}-group-collapse-trigger-close`]:{transform:`rotate(0deg)`}}}},Yt=Ve(`Conversations`,t=>{let n=e(t,{});return[Jt(n),qt(n)]},e=>{let t=new b(e.colorPrimary).setA(.15),n=new b(e.colorPrimary).setA(.22),r=new b(e.colorPrimary).setA(.25),i=new b(e.colorPrimary).setA(.65);return{creationBgColor:t.toRgbString(),creationBorderColor:n.toRgbString(),creationHoverColor:r.toRgbString(),shortcutKeyTextColor:i.toRgbString()}}),Xt=z.forwardRef((e,t)=>{let{prefixCls:r,shortcutKeys:i,rootClassName:a,items:s,activeKey:c,defaultActiveKey:l,onActiveChange:u,menu:d,styles:f={},classNames:p={},groupable:m,className:h,style:g,creation:v,...y}=e,b=(0,at.default)(y,{attr:!0,aria:!0,data:!0}),x=z.useRef(null);ct(t,()=>({nativeElement:x.current}));let[S,C]=_(l,c),[w,T,E]=Wt(m,s),{getPrefixCls:D,direction:O}=V(),k=D(`conversations`,r),A=de(`conversations`),[ee,te]=Yt(k),j=o(k,A.className,A.classNames.root,h,p.root,a,ee,te,{[`${k}-rtl`]:O===`rtl`}),M=e=>{C(e),u?.(e,s?.find(t=>t.key===e))},[ne,N,ie]=Rt(`conversations`,i);ie(e=>{switch(e?.name){case`items`:{let t=e?.actionKeyCodeNumber??e?.index;typeof t==`number`&&!E?.[t]?.disabled&&E?.[t]?.key&&(C(E?.[t]?.key),u?.(E?.[t]?.key,s?.find(e=>e.key===E?.[t]?.key)))}break;case`creation`:typeof v?.onClick==`function`&&!v?.disabled&&v.onClick();break}});let ae=e=>e.map((e,t)=>{if(e.type===`divider`)return z.createElement(re,{key:`key-divider-${t}`,className:`${k}-divider`,dashed:e.dashed});let r=e,{label:i,disabled:a,icon:s,...c}=r;return z.createElement(Kt,n({},c,{key:r.key||`key-${t}`,info:r,prefixCls:k,direction:O,className:o(p.item,A.classNames.item,r.className),style:{...A.styles.item,...f.item,...r.style},menu:typeof d==`function`?d(r):d,active:S===r.key,onClick:M}))}),[P,oe,se,F]=Tt(T,k,D());return z.createElement(`ul`,n({},b,{style:{...A.style,...g,...A.styles.root,...f.root},className:j,ref:x}),!!v&&z.createElement(Vt,n({className:o(A.classNames.creation,p.creation),style:{...A.styles.creation,...f.creation},shortcutKeyInfo:N?.creation,prefixCls:`${k}-creation`},v)),w.map((e,t)=>{let n=ae(e.data);return e.enableGroup?z.createElement(Ht.Provider,{key:e.name||`key-${t}`,value:{prefixCls:k,groupInfo:e,enableCollapse:P,expandedKeys:oe,onItemExpand:se,collapseMotion:F}},z.createElement(Ut,{className:o(A.classNames.group,p.group)},z.createElement(`ul`,{className:o(`${k}-list`,{[`${k}-group-collapsible-list`]:e.collapsible}),style:{...A.styles.group,...f.group}},n))):n}))});Xt.Creation=Vt;var Zt=z.createContext(null),Qt=z.forwardRef((e,t)=>{let{className:r,action:i,onClick:a,...s}=e,c=(0,z.useContext)(Zt),{prefixCls:l,disabled:u,setSubmitDisabled:d}=c,f=s.disabled??u??c[`${i}Disabled`];return(0,z.useEffect)(()=>{i===`onSend`&&d?.(f)},[f,i,d]),z.createElement(T,n({type:`text`},s,{ref:t,onClick:e=>{f||(c[i]?.(),a?.(e))},disabled:f,className:o(l,r,{[`${l}-disabled`]:f})}))});function $t(e,t){return z.createElement(Qt,n({icon:z.createElement(O,null)},e,{action:`onClear`,ref:t}))}var en=z.forwardRef($t),tn=(0,z.memo)(e=>{let{className:t}=e,[n]=we(`Sender`,H.Sender);return z.createElement(`svg`,{color:`currentColor`,viewBox:`0 0 1000 1000`,xmlns:`http://www.w3.org/2000/svg`,className:t},z.createElement(`title`,null,n.stopLoading),z.createElement(`rect`,{fill:`currentColor`,height:`250`,rx:`24`,ry:`24`,width:`250`,x:`375`,y:`375`}),z.createElement(`circle`,{cx:`500`,cy:`500`,fill:`none`,r:`450`,stroke:`currentColor`,strokeWidth:`100`,opacity:`0.45`}),z.createElement(`circle`,{cx:`500`,cy:`500`,fill:`none`,r:`450`,stroke:`currentColor`,strokeWidth:`100`,strokeDasharray:`600 9999999`},z.createElement(`animateTransform`,{attributeName:`transform`,dur:`1s`,from:`0 500 500`,repeatCount:`indefinite`,to:`360 500 500`,type:`rotate`})))}),nn=z.forwardRef((e,t)=>{let{prefixCls:r}=z.useContext(Zt),{className:i}=e;return z.createElement(Qt,n({icon:z.createElement(tn,{className:`${r}-loading-icon`}),color:`primary`,variant:`text`,shape:`circle`},e,{className:o(i,`${r}-loading-button`),action:`onCancel`,ref:t}))});function rn(e,t){return z.createElement(Qt,n({icon:z.createElement(ee,null),type:`primary`,shape:`circle`},e,{action:`onSend`,ref:t}))}var an=z.forwardRef(rn),on=z.createContext({}),sn=e=>{let t=(0,z.useCallback)(()=>typeof window>`u`?null:window.getSelection(),[]),n=(e,t)=>{if(!e||!t)return t;let n=e,r=null;for(n.nodeType===Node.TEXT_NODE&&(n=n.parentElement);n&&n!==t;)n instanceof HTMLElement&&n.tagName===`SPAN`&&(r=n),n=n.parentElement;return r||t},r=(0,z.useCallback)(()=>{let e=t();if(!e)return{range:null,selection:e};try{return{range:e.getRangeAt(0)||document.createRange(),selection:e}}catch{return{range:document.createRange(),selection:e}}},[t]),i=(0,z.useCallback)((e,t)=>{if(!(!e||!t))try{t.removeAllRanges(),t.addRange(e)}catch(e){W(!1,`Sender`,`Failed to set range: ${e}`)}},[]),a=(0,z.useCallback)(()=>{let e=t();if(e)try{e.removeAllRanges()}catch(e){W(!1,`Sender`,`Failed to remove all ranges: ${e}`)}},[t]),o=(0,z.useCallback)((e,t=!1)=>{if(!(!e||typeof e.focus!=`function`))try{e.focus({preventScroll:t})}catch(e){W(!1,`Sender`,`Failed to focus element: ${e}`)}},[]),s=(0,z.useCallback)((e,t)=>{if(!e)return;o(e,t);let{range:n,selection:a}=r();if(n&&a)try{n.selectNodeContents(e),n.collapse(!1),i(n,a)}catch(e){W(!1,`Sender`,`Failed to set end cursor: ${e}`)}},[o,r,i]),c=(0,z.useCallback)((e,t)=>{if(!e)return;o(e,t);let{range:n,selection:a}=r();if(n&&a)try{n.selectNodeContents(e),n.collapse(!0),i(n,a)}catch(e){W(!1,`Sender`,`Failed to set start cursor: ${e}`)}},[o,r,i]),l=(0,z.useCallback)((e,t,n)=>{if(!e)return;o(e,n);let{range:a,selection:s}=r();if(a&&s)try{a.selectNodeContents(e),t&&a.setStart(e,1),i(a,s)}catch(e){W(!1,`Sender`,`Failed to select all content: ${e}`)}},[o,r,i]),u=(0,z.useCallback)((e,t,n,a)=>{if(!e||typeof n!=`number`||n<0||!t)return{range:null,selection:null};o(t,a);let{range:s,selection:c}=r();if(s&&c)try{let t=Math.min(n,e.childNodes.length);s.setStart(e,t),s.setEnd(e,t),s.collapse(!1),i(s,c)}catch(e){W(!1,`Sender`,`Failed to set cursor position:: ${e}`)}return{range:s,selection:c}},[o,r,i]),d=(0,z.useCallback)((t,n,r=!1)=>{if(!e||!t?.current)return;let{getSlotDom:i,slotConfigMap:a}=e,o=e=>{let t=i(e);if(!t)return null;let n=a.get(e);if(!n)return null;if(n.type===`input`)return t.querySelector(`input`);let r=t?.getAttribute?.(`data-node-type`)||``;return n.type===`content`&&r!==`nbsp`?t:null},s=(e=>{let n=t.current;if(!n)return null;if(e)return o(e);for(let e of Array.from(n.childNodes)){let t=e?.getAttribute?.(`data-slot-key`);if(t){let e=o(t);if(e)return e}}return null})(n);s&&(s.nodeName===`INPUT`?s.focus({preventScroll:r}):u(s,t.current,0,r))},[e,u]),f=(0,z.useCallback)((e,t,n,r,i)=>{!n||!r||(o(t,i),n?.setStartAfter(e),n.collapse(!1),r.removeAllRanges(),r.addRange(n))},[o]),p=(0,z.useCallback)(e=>{if(!e)return{value:``,startContainer:null,startOffset:0};let n=t();if(!n||n.rangeCount===0)return{value:``,startContainer:null,startOffset:0};try{let t=n.getRangeAt(0),r=t.cloneRange();if(!e.contains(t.startContainer))return{value:``,startContainer:null,startOffset:0};if(t.endContainer===e&&t.endContainer.lastChild?.nodeType===Node.TEXT_NODE){let e=t.endContainer.lastChild;t=document.createRange(),t.setStart(e,e.length),t.setEnd(e,e.length)}return r=t.cloneRange(),r.selectNodeContents(e),r.setEnd(t.startContainer,t.startOffset),{value:r.toString().replace(/\u200B/g,``),startContainer:t.startContainer,startOffset:t.startOffset}}catch(e){return W(!1,`Sender`,`Failed to get text before cursor: ${e}`),{value:``,startContainer:null,startOffset:0}}},[t]),m=(0,z.useCallback)((i,a,o)=>{if(i===`start`||i===`end`)return{type:i,selection:t()};let l=null,u=null;if(o?.current)l=o.current,u=t();else{let e=r();l=e.range,u=e.selection}if(!l||!u)return{type:`end`,selection:u};let d=a?.current;if(!d)return{type:`end`,selection:u};let f=d.contains(l.endContainer),p=d.contains(l.startContainer);if(!f)return s(d,!0),{type:`end`,selection:u};if(!p)return c(d,!0),{type:`start`,selection:u};let m=n(l.endContainer,d),h=n(l.startContainer,d);if(m===h&&h!==d&&e?.getNodeInfo){let{slotKey:t,slotConfig:n,skillKey:r}=e.getNodeInfo(m)||{};if(t)return{type:`slot`,slotKey:n?.key,slotType:n?.type,range:l,selection:u};if(r)return{type:`start`,selection:u}}return{type:`box`,range:l,selection:u}},[e,r,t,s,c,n]),h=(0,z.useCallback)(e=>{let t=e.childNodes[e.childNodes.length-1];return u(e,e,t?.nodeType===Node.TEXT_NODE&&t.textContent===` `?e.childNodes.length-1:e.childNodes.length).range||document.createRange()},[u]),g=(0,z.useCallback)(t=>u(t,t,+!!e?.getEditorValue?.().skill).range||document.createRange(),[u,e]),_=(0,z.useCallback)(e=>e.replace(/\u200B/g,``).replace(/\n/g,``).replace(/^\n+|\n+$/g,``),[]);return{setEndCursor:s,setStartCursor:c,setAllSelectCursor:l,setCursorPosition:u,setAfterNodeFocus:f,setSlotFocus:d,getTextBeforeCursor:p,getSelection:t,removeAllRanges:a,getRange:r,getInsertPosition:m,getEndRange:h,getStartRange:g,copySelectionString:(0,z.useCallback)(async()=>{try{let e=t();if(!e)return!1;let n=e.toString();if(!n)return!1;let r=_(n);return await navigator.clipboard.writeText(r),!0}catch(e){return W(!1,`Sender`,`Failed to copy selection: ${e}`),!1}},[t,_]),getCleanedText:_}},cn=4.35,ln=(e,t,n)=>{let{token:r}=Be(),i=n.current?window.getComputedStyle(n.current):{},a=parseFloat(`${e.lineHeight||r.lineHeight}`),o=parseFloat(`${i?.fontSize||e.fontSize||r.fontSize}`),s=i?.lineHeight?parseFloat(`${i?.lineHeight}`):a*o;return t===!1||!t?{}:t===!0?{height:`auto`}:{minHeight:t.minRows?(s+cn)*t.minRows:`auto`,maxHeight:t.maxRows?(s+cn)*t.maxRows:`auto`,overflowY:`auto`}},un=e=>{let{prefixCls:t,placeholder:n,slotDomMap:r,slotConfigMap:i}=e,a=(0,z.useCallback)(e=>{let r=document.createElement(`span`);return r.setAttribute(`contenteditable`,`false`),r.dataset.skillKey=e,r.dataset.placeholder=n||``,r.className=`${t}-skill`,r},[t,n]),s=(0,z.useCallback)(e=>{let n=document.createElement(`span`);return n.setAttribute(`contenteditable`,`true`),n.dataset.slotKey=e.key,n.className=o(`${t}-slot`,`${t}-slot-content`),n},[t]),c=(0,z.useCallback)(e=>{let n=document.createElement(`span`);return n.setAttribute(`contenteditable`,`false`),n.dataset.slotKey=e,n.className=`${t}-slot`,n},[t]),l=(0,z.useCallback)((e,n)=>{let r=document.createElement(`span`);return r.setAttribute(`contenteditable`,`false`),r.dataset.slotKey=e,r.dataset.nodeType=`nbsp`,r.className=o(`${t}-slot-${n}`,`${t}-slot-no-width`),r.textContent=`\xA0`,r},[t]),u=(e,t)=>{r.current.set(e,t)},d=e=>r.current.get(e);return{buildSkillSpan:a,buildEditSlotSpan:s,buildSlotSpan:c,buildSpaceSpan:l,saveSlotDom:u,getSlotDom:d,getSlotLastDom:(e,t)=>(t??i.get(e)?.type)===`content`?d(`${e}_after`):d(e)}},dn=new Set([`input`,`select`,`custom`,`content`]),fn=e=>e?.reduce((e,t)=>{let{key:n,type:r}=t;if(!n)return e;let i=t.props||{};return e[n]=(dn.has(r)?i.defaultValue:i.value??i.label)??``,e},{})??{},pn=(e,t)=>{e?.forEach(e=>{e.key&&t.set(e.key,e)})},mn=(e,t)=>{if(!e?.dataset)return null;let{dataset:n}=e;return{slotKey:n.slotKey,placeholder:n.placeholder,nodeType:n.nodeType,skillKey:n.skillKey,slotConfig:n.slotKey?t.get(n.slotKey):void 0,targetNode:e}},hn=e=>{let[t,n]=(0,z.useState)({}),r=(0,z.useRef)(t),i=(0,z.useRef)(new Map),a=(0,z.useRef)(new Set);(0,z.useEffect)(()=>{if(!e)return;i.current.forEach((e,t)=>{a.current.has(t)||i.current.delete(t)}),pn(e,i.current);let t=fn(e);a.current.forEach(e=>{e in r.current&&(t[e]=r.current[e])}),n(t),r.current=t},[e]);let o=(0,z.useCallback)(e=>{let t=typeof e==`function`?e(r.current):e;n(t),r.current=t},[]),s=(0,z.useCallback)(e=>{let t=fn(e);e.forEach(e=>{e.key&&(i.current.set(e.key,e),a.current.add(e.key))}),n(e=>({...e,...t})),r.current={...r.current,...t}},[]),c=(0,z.useCallback)(()=>{i.current.clear(),a.current.clear(),n({}),r.current={}},[]),l=(0,z.useCallback)(e=>mn(e,i.current),[]);return[i.current,{getSlotValues:()=>r.current,setSlotValues:o,mergeSlotConfig:s,getNodeInfo:l,getNodeTextValue:e=>{let t=e.nodeType;if(t===Node.TEXT_NODE)return e.textContent||``;if(t!==Node.ELEMENT_NODE)return``;let n=e,i=l(n);if(!i)return n.innerText||``;let{slotKey:a,skillKey:o,nodeType:s,slotConfig:c}=i;if(o)return``;let u=n.innerText||``;if(a){if(s===`nbsp`)return` `;if(!c||c.type===`content`)return u;let e=r.current[a]??``;return c.formatResult?.(e)??e}return u},clear:c}]},gn=({removeSkill:e,prefixCls:t,toolTip:n,closable:r,title:i,value:a})=>{let s=`${t}-skill`,c=(0,z.useMemo)(()=>{if(!r)return[null];let t=typeof r==`boolean`?{}:r,n=n=>{t.disabled||(n.stopPropagation(),e(),t.onClose?.(n))},i=t.closeIcon||z.createElement(v,{className:`${s}-close-icon`});return z.createElement(`div`,{className:o(`${s}-close`,{[`${s}-close-disabled`]:t.disabled}),onClick:n,role:`button`,"aria-label":`Close skill`,tabIndex:0},i)},[r,e]),l=i||a,u=n?z.createElement(w,n,l):l;return z.createElement(`div`,{className:`${s}-wrapper`,contentEditable:!1},z.createElement(`div`,{className:`${s}-tag`,contentEditable:!1,role:`button`,tabIndex:0},z.createElement(`span`,{className:`${s}-tag-text`},u),c),z.createElement(`div`,{className:`${s}-holder`}))};gn.displayName=`Skill`;var _n=r(y()),vn=z.forwardRef((e,t)=>{let{onChange:r,onKeyUp:i,onKeyDown:a,onPaste:s,onPasteFile:c,disabled:l,readOnly:u,submitType:d=`enter`,prefixCls:f,styles:p={},classNames:m={},autoSize:h,triggerSend:g,placeholder:_,onFocus:v,onBlur:y,slotConfig:b,skill:x,...S}=z.useContext(on),{direction:C,getPrefixCls:w}=V(),T=`${w(`sender`,f)}`,E=de(`sender`),D=`${T}-input`,O=(0,z.useRef)(null),A=(0,z.useRef)(new Map),ee=(0,z.useRef)(!1),te=(0,z.useRef)(!1),j=(0,z.useRef)(null),M=(0,z.useRef)(null),ne=(0,z.useRef)(null),N={...E.styles?.input,...p.input},re=ln(N,h,O),P={...(0,at.default)(S,{attr:!0,aria:!0,data:!0}),ref:O},[oe,{getSlotValues:se,setSlotValues:F,getNodeInfo:ce,mergeSlotConfig:I,getNodeTextValue:L,clear:le}]=hn(b),[R,B]=(0,z.useState)(new Map),[ue,fe]=(0,z.useState)(null),{setEndCursor:pe,setStartCursor:me,setAllSelectCursor:he,setCursorPosition:ge,setSlotFocus:_e,setAfterNodeFocus:ve,getTextBeforeCursor:ye,removeAllRanges:be,getRange:xe,getInsertPosition:Se,getEndRange:H,getStartRange:Ce,getSelection:we,copySelectionString:Te,getCleanedText:Ee}=sn({prefixCls:T,getSlotDom:e=>A.current.get(e),slotConfigMap:oe,getNodeInfo:ce,getEditorValue:()=>Re()}),{buildSkillSpan:De,buildEditSlotSpan:Oe,buildSlotSpan:ke,buildSpaceSpan:Ae,getSlotDom:je,saveSlotDom:Me,getSlotLastDom:Ne}=un({prefixCls:T,placeholder:_,slotDomMap:A,slotConfigMap:oe}),Pe=e=>{let t=Re();M.current&&(!t?.value&&t.slotConfig.length===0&&_?(M.current.setAttribute(`contenteditable`,`true`),M.current.classList.add(`${T}-skill-empty`)):(M.current.setAttribute(`contenteditable`,`false`),M.current.classList.remove(`${T}-skill-empty`))),r?.(t.value,e,t.slotConfig,t.skill)},Fe=(e,t,n)=>{let r=je(e),i=oe.get(e);if(F(n=>({...n,[e]:t})),r&&i){let t=Ie(i,r);B(n=>{let r=new Map(n);return r.set(e,t),r}),Pe(n)}},Ie=(e,t)=>{if(!e.key)return null;let n=se()[e.key];return(0,_n.createPortal)((()=>{switch(e.type){case`content`:return t.innerHTML=n||``,t.setAttribute(`data-placeholder`,e.props?.placeholder||``),null;case`input`:return z.createElement(ie,{readOnly:u,className:`${T}-slot-input`,placeholder:e.props?.placeholder||``,"data-slot-input":e.key,size:`small`,variant:`borderless`,value:n||``,tabIndex:0,onKeyDown:Ze,onChange:t=>{Fe(e.key,t.target.value,t)},spellCheck:!1});case`select`:return z.createElement(ae,{disabled:u,menu:{items:e.props?.options?.map(e=>({label:e,key:e})),defaultSelectedKeys:e.props?.defaultValue?[e.props.defaultValue]:[],selectable:!0,onSelect:({key:t,domEvent:n})=>{Fe(e.key,t,n)}},trigger:[`click`]},z.createElement(`span`,{className:o(`${T}-slot-select`,{placeholder:!n,[`${T}-slot-select-selector-value`]:n})},z.createElement(`span`,{"data-placeholder":e.props?.placeholder,className:`${T}-slot-select-value`},n||``),z.createElement(`span`,{className:`${T}-slot-select-arrow`},z.createElement(k,null))));case`tag`:return z.createElement(`span`,{className:`${T}-slot-tag`},e.props?.label||e.props?.value||``);case`custom`:return e.customRender?.(n,t=>{Fe(e.key,t)},{disabled:l,readOnly:u},e);default:return null}})(),t)},Le=e=>e.reduce((e,t)=>{if(t.type===`text`)return e.push(document.createTextNode(t.value||``)),e;let n=t.key;if(W(!!n,`Sender`,`Slot key is missing: ${n}`),n){let r,i;if(t.type===`content`){i=Oe(t);let e=Ae(n,`before`),a=Ae(n,`after`);r=[e,i,a],Me(`${n}_before`,e),Me(n,i),Me(`${n}_after`,a)}else i=ke(n),r=[i],Me(n,i);if(i){let a=Ie(t,i);a&&(B(e=>{let t=new Map(e);return t.set(n,a),t}),e.push(...r))}}return e},[]),Re=()=>{let e=O.current,t={value:``,slotConfig:[],skill:void 0};if(!e)return t;let n=e.childNodes;if(n.length===0)return e.innerHTML=``,M.current=null,t;let r=!!x,i=Array(n.length),a=[],o,s=0;for(let e=0;e{let e=O.current;e&&(e.innerHTML=``,M.current=null,ne.current=null,j.current=null,be(),A?.current?.clear())},Be=e=>{e.forEach(e=>{O.current?.appendChild(e)})},Ve=(e,t)=>{let n=O.current;n&&(n.querySelectorAll(`[data-slot-key="${e}"]`).forEach(e=>{e.remove()}),A.current.delete(e),F(t=>{let{[e]:n,...r}=t;return r}),B(t=>{let n=new Map(t);return n.delete(e),n}),Pe(t))},He=()=>{if(x&&ne.current!==x){Ue(!1),ne.current=x;let e=De(x.value);fe((0,_n.createPortal)(z.createElement(gn,n({removeSkill:Ue},x,{prefixCls:T})),e));let t=document.createRange(),r=O.current;if(!r)return;t.setStart(r,0),t.insertNode(e),M.current=e,Pe()}},Ue=(e=!0)=>{!O.current||!M.current||(M.current?.remove(),M.current=null,ne.current=null,e&&Pe())},We=e=>{d!==`enter`||!e||e.querySelectorAll(`br`).forEach(e=>{e.remove()})},Ge=()=>{b&&b.length>0&&O.current&&(ze(),Be(Le(b)))},Ke=e=>{let t=a?.(e);return te.current||ee.current||t===!1},qe=(e,t)=>{if(!O.current)return!1;let{range:n,selection:r}=xe();if(!r||r.rangeCount===0)return!1;let{focusOffset:i,anchorNode:a}=r;if(!a||!O.current.contains(a))return!1;if(a.nodeType===Node.TEXT_NODE&&n){let r=a.parentNode,o=ce(r),s=n.toString(),c=a.textContent?.length===s.length,l=a.textContent?.length===1&&i===1;if(o?.slotConfig?.type===`content`&&(c||l))return e.preventDefault(),t===`cut`&&Te(),a.parentNode.innerHTML=``,!0}if(t===`backspace`&&i===0){let t=a.previousSibling;if(t){let n=ce(t);if(n){let{slotKey:t,skillKey:r}=n;if(t)return e.preventDefault(),Ve(t,e),!0;if(r)return e.preventDefault(),Ue(),!0}}}return!1},Je=e=>{let{key:t,shiftKey:n,ctrlKey:r,altKey:i,metaKey:a}=e;if(t!==`Enter`)return!1;let o=r||i||a;return d===`enter`&&!n&&!o||d===`shiftEnter`&&n&&!o},Ye=()=>{if(!M.current||!O.current||M.current.getAttribute(`contenteditable`)===`false`)return;let e=we();!e?.anchorNode||!M.current.contains(e.anchorNode)||!O.current.contains(e.anchorNode)||(M.current.setAttribute(`contenteditable`,`false`),M.current.classList.remove(`${T}-skill-empty`),dt({cursor:`end`}))},Xe=()=>{ee.current=!0},U=()=>{ee.current=!1,te.current=!1},Ze=e=>{if(!Ke(e)&&!(e.key===`Backspace`&&qe(e,`backspace`))){if(Je(e)){e.preventDefault(),te.current=!0,g?.();return}if((e.key===`a`||e.key===`A`)&&(e.ctrlKey||e.metaKey)&&!e.shiftKey&&!e.altKey){he(O.current,M.current),e.preventDefault();return}Ye()}},Qe=e=>{v?.(e)},$e=e=>{te.current&&=!1;let{range:t}=xe();j.current=t;let n=setTimeout(()=>{j.current=null,clearTimeout(n)},200);y?.(e)},et=e=>{We(O?.current),Pe(e)},tt=e=>{qe(e,`cut`)},nt=e=>{e.preventDefault();let t=e.clipboardData?.files,n=e.clipboardData?.getData(`text/plain`);if(!n&&t?.length&&c){c(t);return}if(n){let e=!1,t=Ee(n);try{e=document.execCommand(`insertText`,!1,t)}catch(e){W(!1,`Sender`,`insertText command failed: ${e}`)}e||ot([{type:`text`,value:t}])}s?.(e)},rt=e=>{e.key===`Enter`&&(te.current=!1),i?.(e)},it=()=>{let e=O.current,t=we();e&&t?.focusNode===e&&t.focusOffset===0&&Re().skill&&ge(e,O.current,1)},ot=(e,t,n,r)=>{let i=O.current;if(i)try{I(e);let a=Le(e);if(a.length===0)return;let o=st(t,i);if(!o.range||!o.selection)return;let{range:s,selection:c}=o;n?.length&&ct(s,n,i),s.deleteContents(),lt(a,s,o),ut(a,s,c,r)}catch(e){W(!1,`Sender`,`Insert operation failed: ${e}`)}},st=(e,t)=>{let{type:n,slotKey:r,slotType:i,range:a,selection:o}=Se(e,O,j);if(!o)return{range:null,selection:null,type:n};let s=null;switch(n){case`end`:s=H(t);break;case`start`:s=Ce(t);break;case`slot`:s=xe().range;break;case`box`:s=a||null,s&&M.current&&s.collapsed&&s.startOffset===0&&s.setStartAfter(M.current);break}return{range:s,selection:o,type:n,slotKey:r,slotType:i}},ct=(e,t,n)=>{let{value:r,startContainer:i,startOffset:a}=ye(n);r.length>=t.length&&r.endsWith(t)&&i&&a>=0&&(e.setStart(i,a-t.length),e.setEnd(i,a),e.deleteContents())},lt=(e,t,n)=>{let{type:r,slotKey:i,slotType:a}=n,o=!0;e.forEach(e=>{if(o&&r===`slot`&&(a!==`content`||e.nodeType!==Node.TEXT_NODE)&&i){o=!1;let e=Ne(i);e&&t.setStartAfter(e)}t.insertNode(e),t.setStartAfter(e)})},ut=(e,t,n,r)=>{let i=e[e.length-1];ve(i,O.current,t,n,r),setTimeout(()=>{et(null)},0)},dt=e=>{let t={preventScroll:e?.preventScroll??!1,cursor:e?.cursor??`end`,key:e?.key};switch(t.cursor){case`slot`:_e(O,e?.key,t.preventScroll);break;case`start`:me(O.current,t.preventScroll);break;case`all`:he(O.current,M.current,t.preventScroll);break;case`end`:pe(O.current,t.preventScroll);break}},ft=()=>{let e=O.current;e&&(e.innerHTML=``,ne.current=null,M.current=null,le(),He(),j.current=null,A?.current?.clear(),et(null))};return(0,z.useEffect)(()=>{Ge(),x?He():Pe()},[b]),(0,z.useEffect)(()=>{He()},[x]),(0,z.useImperativeHandle)(t,()=>({nativeElement:O.current,focus:dt,blur:()=>O.current?.blur(),insert:ot,clear:ft,getValue:Re})),z.createElement(z.Fragment,null,z.createElement(`div`,n({},P,{role:`textbox`,tabIndex:0,style:{...N,...re},className:o(D,`${D}-slot`,E.classNames.input,m.input,{[`${T}-rtl`]:C===`rtl`}),"data-placeholder":_,contentEditable:!u,suppressContentEditableWarning:!0,spellCheck:!1,onCut:tt,onKeyDown:Ze,onKeyUp:rt,onPaste:nt,onCompositionStart:Xe,onCompositionEnd:U,onFocus:Qe,onBlur:$e,onSelect:it,onInput:et},S)),z.createElement(`div`,{style:{display:`none`},id:`${T}-slot-placeholders`},Array.from(R.values()),ue))}),yn=1e3,bn=4,xn=140,Sn=xn/2,Cn=250,wn=500,Tn=.8;function En({className:e}){let[t]=we(`Sender`,H.Sender);return z.createElement(`svg`,{color:`currentColor`,viewBox:`0 0 ${yn} ${yn}`,xmlns:`http://www.w3.org/2000/svg`,className:e},z.createElement(`title`,null,t.speechRecording),Array.from({length:bn}).map((e,t)=>{let n=t*286.66666666666663,r=yn/2-Cn/2,i=yn/2-wn/2;return z.createElement(`rect`,{fill:`currentColor`,rx:Sn,ry:Sn,height:Cn,width:xn,x:n,y:r,key:t},z.createElement(`animate`,{attributeName:`height`,values:`${Cn}; ${wn}; ${Cn}`,keyTimes:`0; 0.5; 1`,dur:`${Tn}s`,begin:`${Tn/bn*t}s`,repeatCount:`indefinite`}),z.createElement(`animate`,{attributeName:`y`,values:`${r}; ${i}; ${r}`,keyTimes:`0; 0.5; 1`,dur:`${Tn}s`,begin:`${Tn/bn*t}s`,repeatCount:`indefinite`}))}))}var Dn=z.forwardRef((e,t)=>{let{speechRecording:r,disabled:i,onSpeechDisabled:a,prefixCls:o}=z.useContext(Zt),s=e.disabled??i??a,c=null;return c=r?z.createElement(En,{className:`${o}-recording-icon`}):s?z.createElement(A,null):z.createElement(M,null),z.createElement(Qt,n({icon:c,variant:`text`,color:`primary`},e,{action:`onSpeech`,ref:t}))}),On=r(t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=t;function t(e,t){let n=e;for(let e=0;e{let{value:r,onChange:i,onKeyUp:a,onKeyDown:s,onPaste:c,onPasteFile:l,disabled:u,readOnly:d,submitType:f=`enter`,prefixCls:p,styles:m={},classNames:h={},autoSize:g,components:_,triggerSend:v,placeholder:y,onFocus:b,onBlur:x,...S}=z.useContext(on),C=z.useRef(null),w=(e,t=`cursor`)=>{let n=C.current?.resizableTextArea?.textArea,r=n.value,a=r.length,o=r.length;t===`cursor`&&(a=n?.selectionStart,o=n?.selectionEnd),t===`start`&&(a=0,o=0),n.value=r.substring(0,a)+e+r.substring(o,r.length),n.selectionStart=a+e.length,n.selectionEnd=a+e.length,n.focus(),i?.(n.value)},T=()=>{i?.(``)},E=()=>({value:r||``,slotConfig:[]});z.useImperativeHandle(t,()=>({nativeElement:C.current?.resizableTextArea?.textArea,focus:C.current?.focus,blur:C.current?.blur,insert:w,clear:T,getValue:E}));let D=z.useRef(!1),O=()=>{D.current=!0},k=()=>{D.current=!1},A=e=>{let t=s?.(e),{key:n,shiftKey:r,ctrlKey:i,altKey:a,metaKey:o}=e;if(!(D.current||n!==`Enter`||t===!1)&&n===`Enter`){let t=i||a||o;if(f===`enter`&&!r&&!t||f===`shiftEnter`&&r&&!t){e.preventDefault(),v?.();return}}},ee=e=>{let t=e.clipboardData?.files;!e.clipboardData?.getData(`text/plain`)&&t?.length&&l&&(l(t),e.preventDefault()),c?.(e)},te=kn(_,[`input`],ie.TextArea),j={...(0,at.default)(S,{attr:!0,aria:!0,data:!0}),ref:C};return z.createElement(te,n({},j,{disabled:u,style:m.input,className:o(`${p}-input`,h.input),autoSize:g,value:r,onChange:e=>{i?.(e.target.value,e)},onKeyUp:a,onCompositionStart:O,onCompositionEnd:k,onKeyDown:A,onPaste:ee,variant:`borderless`,readOnly:d,placeholder:y,onFocus:b,onBlur:x}))});function jn(e,t){let n=l(e),[r,i,a]=z.useMemo(()=>typeof t==`object`?[t.recording,t.onRecordingChange,typeof t.recording==`boolean`]:[void 0,void 0,!1],[t]),[o,s]=z.useState(null);z.useEffect(()=>{if(!a&&`permissions`in navigator){let e=null;return navigator.permissions.query({name:`microphone`}).then(t=>{s(t.state),t.onchange=function(){s(this.state)},e=t}).catch(e=>{W(!1,`Sender`,`Browser does not support querying microphone permission. ${e instanceof Error?e.message:String(e)}`)}),()=>{e&&(e.onchange=null)}}},[a]);let c;!c&&typeof window<`u`&&(c=window.SpeechRecognition||window.webkitSpeechRecognition);let u=!!(a||c&&o!==`denied`),d=z.useRef(null),[f,p]=_(!1,r),m=z.useRef(!1),h=()=>{if(u&&!d.current){let e=new c;e.onstart=()=>{p(!0)},e.onend=()=>{p(!1)},e.onresult=e=>{if(!m.current){let t=e.results?.[0]?.[0]?.transcript;n(t)}m.current=!1},d.current=e}};return[u,l(e=>{e&&!f||(m.current=e,a?i?.(!f):(h(),d.current&&(f?(d.current.stop(),i?.(!1)):(d.current.start(),i?.(!0)))))}),f]}var Mn=z.createContext({}),Nn=()=>({height:0}),Pn=e=>({height:e.scrollHeight});function Fn(e){let{title:t,onOpenChange:n,open:r,children:i,className:s,style:c,classNames:l={},styles:u={},prefixCls:d,closable:f,forceRender:p}=e,{prefixCls:m}=z.useContext(Mn),{direction:h,getPrefixCls:g}=V(),_=g(`sender`,d||m),y=`${_}-header`,b=()=>{n?.(!r)};return z.createElement(a,{motionEnter:!0,motionLeave:!0,motionName:`${y}-motion`,leavedClassName:`${y}-motion-hidden`,onEnterStart:Nn,onEnterActive:Pn,onLeaveStart:Pn,onLeaveActive:Nn,visible:r,forceRender:p},({className:e,style:n})=>z.createElement(`div`,{className:o(_,y,e,s,{[`${y}-rtl`]:h===`rtl`}),style:{...n,...c}},(f!==!1||t)&&z.createElement(`div`,{className:o(`${y}-header`,l.header),style:{...u.header}},z.createElement(`div`,{className:`${y}-title`},t),f!==!1&&z.createElement(`div`,{className:`${y}-close`},z.createElement(T,{type:`text`,icon:z.createElement(v,null),size:`small`,onClick:b}))),i&&z.createElement(`div`,{className:o(`${y}-content`,l.content),style:{...u.content}},i)))}var In=e=>{let{componentCls:t,calc:n}=e,r=`${t}-header`;return{[t]:{[`&${r}-rtl`]:{direction:`rtl`},[`${r}`]:{borderBottomWidth:e.lineWidth,borderBottomStyle:`solid`,borderBottomColor:e.colorBorderInput,[`${r}-header`]:{background:e.colorFillAlter,fontSize:e.fontSize,lineHeight:e.lineHeight,paddingBlock:n(e.paddingSM).sub(e.lineWidthBold).equal(),paddingInlineStart:e.padding,paddingInlineEnd:e.paddingXS,display:`flex`,borderRadius:{_skip_check_:!0,value:n(e.borderRadius).mul(2).equal()},borderEndStartRadius:0,borderEndEndRadius:0,[`${r}-title`]:{flex:`auto`}},[`${r}-content`]:{padding:e.padding}},[`${r}-motion`]:{transition:[`height`,`border`].map(t=>`${t} ${e.motionDurationSlow}`).join(`,`),overflow:`hidden`,"&-enter-start, &-leave-active":{borderBottomColor:`transparent`},"&-hidden":{display:`none`}}}}},Ln=e=>{let{componentCls:t,antCls:n,calc:r}=e,i=`${t}-slot`,a=`${n}-input`,o=`${n}-dropdown-trigger`,s=`${t}-slot-input`,l=`${t}-slot-select`,u=`${t}-slot-tag`,d=`${t}-slot-content`,f=`${t}-skill`;return{[t]:{[`${t}-input-slot`]:{outline:`none`,cursor:`text`,whiteSpace:`pre-wrap`,width:`100%`,caretColor:e.colorPrimary,fontSize:e.fontSize,lineHeight:e.lineHeight,"&:empty::before":{content:`attr(data-placeholder)`,color:e.colorTextPlaceholder}},[`${i}:not(${d})`]:{display:`inline-block`,verticalAlign:`middle`,alignItems:`center`,marginBlock:1,height:r(e.fontSize).mul(e.lineHeight).add(2).equal(),wordBreak:`break-all`,marginInline:e.marginXXS},[`${a}${s}`]:{height:`100%`,background:e.colorBgSlot,outline:`none`,color:e.colorTextSlot,borderRadius:e.borderRadius,paddingInline:e.paddingXXS,fontSize:`inherit`,lineHeight:`inherit`,position:`relative`,"&::placeholder":{color:e.colorTextSlotPlaceholder,fontSize:`inherit`,lineHeight:`inherit`},[i]:{display:`inline-flex`,margin:`0 ${c(e.marginXXS)}`,verticalAlign:`bottom`,alignItems:`center`,marginBlock:c(r(e.marginXXS).div(2).equal()),minHeight:e.controlHeightSM,wordBreak:`break-all`}},[l]:{fontSize:e.fontSize,lineHeight:e.lineHeight,paddingInline:e.paddingXXS,transition:`border-color ${e.motionDurationMid}`,position:`relative`,display:`inline-flex`,alignItems:`center`,cursor:`pointer`,background:e.colorBgSlot,height:`100%`,boxSizing:`border-box`,borderRadius:e.borderRadius,color:e.colorTextSlot,border:`1px solid ${e.colorBorderSlot}`,"&.placeholder":{color:e.colorTextSlotPlaceholder},[`${l}`]:{fontSize:e.fontSize,lineHeight:e.lineHeight,padding:`0 ${c(e.paddingXXS)}`,transition:`border-color ${e.motionDurationMid}`,position:`relative`,display:`inline`,cursor:`pointer`,background:e.colorBgSlot,alignItems:`center`,justifyContent:`center`,borderRadius:e.borderRadius,color:e.colorTextSlot,border:`1px solid ${e.colorBorderSlot}`,"&.placeholder":{color:e.colorTextSlotPlaceholder},[`&${o}-open`]:{borderColor:e.colorBorderSlotHover}},[`${l}-value`]:{flex:1,fontSize:e.fontSize,lineHeight:e.lineHeight,"&:empty::before":{content:`attr(data-placeholder)`}},[`${l}-arrow`]:{marginInlineStart:e.marginXXS,fontSize:e.fontSize,lineHeight:e.lineHeight,display:`inline-flex`,alignItems:`center`,justifyContent:`center`},[`${u}`]:{background:e.colorBgSlot,border:`1px solid ${e.colorBorderSlot}`,outline:`none`,color:e.colorTextSlot,borderRadius:e.borderRadius,padding:`0 ${c(e.paddingXXS)}`,fontSize:e.fontSize,lineHeight:e.lineHeight,position:`relative`,cursor:`default`}},[`${l}-arrow`]:{marginInlineStart:e.marginXXS,fontSize:e.fontSize,lineHeight:e.lineHeight,display:`inline-flex`,alignItems:`center`,justifyContent:`center`},[u]:{background:e.colorBgSlot,border:`1px solid ${e.colorBorderSlot}`,outline:`none`,color:e.colorTextSlot,borderRadius:e.borderRadius,padding:`0 ${c(e.paddingXXS)}`,fontSize:e.fontSize,lineHeight:e.lineHeight,height:`100%`,boxSizing:`border-box`,position:`relative`,cursor:`default`},[d]:{height:r(e.fontSize).mul(e.lineHeight).add(2).equal(),caretColor:e.colorPrimary,background:e.colorBgSlot,outline:`none`,color:e.colorTextSlot,borderRadius:e.borderRadius,paddingInline:e.paddingXXS,boxSizing:`border-box`,verticalAlign:`middle`,fontSize:e.fontSize,marginBlock:1,lineHeight:e.lineHeight,display:`inline-block`,position:`relative`,cursor:`text`,"&:empty":{width:`fit-content`,"&::after":{display:`inline-block`,height:`inherit`,content:`attr(data-placeholder)`,color:e.colorTextSlotPlaceholder}}},[`${i}-no-width`]:{userSelect:`none`,width:`3px`,display:`inline-block`,lineHeight:`inherit`},[f]:{display:`inline-block`,verticalAlign:`baseline`,alignItems:`center`,marginBlock:1,height:r(e.fontSize).mul(e.lineHeight).add(2).equal(),wordBreak:`break-all`,paddingInlineEnd:0,paddingInlineStart:0,marginInlineEnd:0,marginInlineStart:-1,[`&${f}-empty`]:{"&::after":{display:`inline-block`,pointerEvents:`none`,height:`inherit`,content:`attr(data-placeholder)`,color:e.colorTextPlaceholder}}},[`${f}-wrapper`]:{height:`100%`,display:`inline-flex`},[`${f}-tag`]:{paddingInline:e.paddingXS,height:`100%`,backgroundColor:e.colorBgSkill,borderRadius:e.borderRadius,color:e.colorPrimary,alignItems:`center`,fontWeight:500,display:`inline-flex`,cursor:`pointer`,gap:e.marginXXS,transition:`background-color ${e.motionDurationMid}`,"&:hover":{backgroundColor:e.colorBgSkillHover,[`${f}-tag-close:not(${f}-tag-close-disabled)`]:{color:e.colorPrimaryHover}},"&-close":{fontSize:e.fontSizeSM,display:`inline-flex`,transition:`color ${e.motionDurationMid}`,color:e.colorPrimary},"&-close-disabled":{cursor:`not-allowed`,color:e.colorTextDisabled}},[`${f}-holder`]:{width:e.marginXS,height:`100%`}}}},Rn=e=>{let{componentCls:t,antCls:n}=e,r=`${t}-switch`;return{[t]:{[`&${r}-rtl`]:{direction:`rtl`},[`&${r}`]:{display:`inline-block`,[`${n}-btn:not(:disabled):not(${n}-btn-disabled):hover`]:{background:e.switchUncheckedHoverBg,borderColor:e.colorBorder,color:e.colorText},[`&${r}-checked`]:{[`${n}-btn:not(:disabled):not(${n}-btn-disabled):hover`]:{background:e.switchCheckedHoverBg,borderColor:e.colorPrimary,color:e.colorPrimaryText},[`${r}-content`]:{background:e.switchCheckedBg}}}}}},zn=e=>{let{antCls:t,componentCls:n,paddingSM:r,paddingXS:i,paddingXXS:a,lineWidth:o,calc:s}=e;return{[n]:{[`&${n}-main`]:{position:`relative`,width:`100%`,boxSizing:`border-box`,boxShadow:`${e.boxShadowTertiary}`,borderRadius:{_skip_check_:!0,value:s(e.borderRadius).mul(2).equal()},borderColor:e.colorBorderInput,borderWidth:o,borderStyle:`solid`},[`&${n}-disabled`]:{background:e.colorBgContainerDisabled,borderColor:`transparent`},[`&${n}-rtl`]:{direction:`rtl`},[`${n}-content`]:{display:`flex`,gap:i,width:`100%`,paddingBlock:r,paddingInlineStart:r,paddingInlineEnd:r,boxSizing:`border-box`,alignItems:`flex-end`},[`${n}-prefix`]:{flex:`none`},[`${n}-input`]:{paddingInline:0,borderRadius:0,flex:`auto`,alignSelf:`center`,caretColor:e.colorPrimary,fontSize:e.fontSize},[`${n}-actions-list`]:{flex:`none`,display:`flex`,"&-presets":{gap:e.paddingXS}},[`${n}-actions-btn`]:{[`&-disabled:where(${t}-btn-variant-text)`]:{color:e.colorTextActionsDisabled,borderColor:`transparent`},[`&-disabled:not(${t}-btn-variant-text)`]:{background:e.colorBgActionsDisabled,color:e.colorTextLightSolid,borderColor:`transparent`},"&-loading-button":{padding:0,border:0},"&-loading-icon":{height:e.controlHeight,width:e.controlHeight,verticalAlign:`top`},"&-recording-icon":{height:`1.2em`,width:`1.2em`,verticalAlign:`top`}},[`${n}-footer`]:{paddingInlineStart:r,paddingInlineEnd:r,paddingBlockEnd:r,paddingBlockStart:a,boxSizing:`border-box`}}}},Bn=Ve(`Sender`,t=>{let{paddingXS:n,calc:r}=t,i=e(t,{SenderContentMaxWidth:`calc(100% - ${c(r(n).add(32).equal())})`});return[zn(i),In(i),Rn(i),Ln(i)]},e=>{let{colorPrimary:t,colorFillTertiary:n}=e,r=new b(t).setA(.06).toRgbString(),i=new b(t).setA(.08).toRgbString(),a=new b(t).setA(.15).toRgbString(),o=t,s=new b(t).setA(.25).toRgbString(),c=new b(t).setA(.1).toRgbString(),l=r,u=new b(t).setA(.08).toRgbString(),d=new b(n).setA(.04).toRgbString(),f=new b(t).setA(.1).toRgbString(),p=new b(n).setA(.1).toRgbString(),m=`0 4px 12px 0 ${new b(t).setA(.1).toRgbString()}`,h=new b(t).setA(.45).toRgbString();return{colorBgSlot:r,colorBgSkill:i,colorBgSkillHover:a,colorTextSlot:o,colorTextSlotPlaceholder:s,colorBorderSlotHover:c,colorBorderSlot:l,switchCheckedBg:u,switchCheckedHoverBg:f,switchUncheckedHoverBg:d,colorBorderInput:p,boxShadowInput:m,colorBgActionsDisabled:h,colorTextActionsDisabled:h}}),Vn={SendButton:an,ClearButton:en,LoadingButton:nn,SpeechButton:Dn},Hn=z.forwardRef((e,t)=>{let{prefixCls:r,styles:i={},classNames:a={},className:s,rootClassName:c,style:l,defaultValue:u,value:d,slotConfig:f,readOnly:p,submitType:m=`enter`,onSubmit:h,loading:g,components:v,onCancel:y,onChange:b,suffix:x,onKeyUp:S,onKeyDown:C,disabled:w,allowSpeech:T,prefix:E,footer:D,header:O,onPaste:k,onPasteFile:A,autoSize:ee={maxRows:8},placeholder:te,onFocus:j,onBlur:M,skill:N,...re}=e,ie=(0,at.default)(re,{attr:!0,aria:!0,data:!0}),ae=z.useId(),P=Array.isArray(f)||N?.value,{direction:oe,getPrefixCls:se}=V(),F=se(`sender`,r),ce=z.useRef(null),I=z.useRef(null);ct(t,()=>({nativeElement:ce.current,inputElement:I.current?.nativeElement,focus:e=>I.current?.focus(e),blur:()=>I.current?.blur(),insert:(...e)=>I.current?.insert?.(...e),clear:()=>I.current?.clear(),getValue:()=>I.current?.getValue()??{value:``,slotConfig:[],skill:void 0}}));let L=de(`sender`),le=`${F}-input`,[R,B]=Bn(F),ue=o(F,L.className,s,c,L.classNames.root,a.root,R,B,`${F}-main`,{[`${F}-rtl`]:oe===`rtl`,[`${F}-disabled`]:w}),fe=`${F}-actions-btn`,pe=`${F}-actions-list`,[me,he]=_(u||``,d),ge=(e,t,n,r)=>{he(e),b?.(e,t,n??[],r)},[_e,ve,ye]=jn(e=>{P?I.current?.insert?.([{type:`text`,value:e}]):ge(`${me} ${e}`)},T),be=()=>{if(I?.current&&h&&!g&&!Ee){let e=I.current.getValue();h(e.value,e.slotConfig,e.skill)}},xe=()=>{ge(``),P&&I.current?.clear?.()},Se=z.createElement(ne,{className:`${pe}-presets`},T&&z.createElement(Dn,null),g?z.createElement(nn,null):z.createElement(an,null)),H=Se;typeof x==`function`?H=x(Se,{components:Vn}):(x||x===!1)&&(H=x);let Ce=typeof E==`function`?E(Se,{components:Vn}):E||null,we=typeof O==`function`?O(Se,{components:Vn}):O||null,Te=typeof D==`function`?D(Se,{components:Vn}):D||null,[Ee,De]=(0,z.useState)(!me),Oe={prefixCls:fe,onSend:be,onSendDisabled:!me,onClear:xe,onClearDisabled:!me,onCancel:y,onCancelDisabled:!g,onSpeech:()=>ve(!1),onSpeechDisabled:!_e,speechRecording:ye,disabled:w,setSubmitDisabled:De},ke=z.useMemo(()=>({value:me,onChange:ge,slotConfig:f,onKeyUp:S,onKeyDown:C,onPaste:k,onPasteFile:A,disabled:w,readOnly:p,submitType:m,prefixCls:F,styles:i,classNames:a,autoSize:ee,components:v,triggerSend:be,placeholder:te,onFocus:j,onBlur:M,skill:N,...re}),[me,ge,f,S,C,k,A,w,p,m,F,i,a,ee,v,be,te,j,M,N,re]),Ae=e=>{!P&&e.target!==ce.current?.querySelector(`.${le}`)&&e.preventDefault(),e.target===ce.current?.querySelector(`.${le}`)&&I.current?.focus()};return z.createElement(`div`,n({key:ae,ref:ce,className:ue,style:{...L.style,...l,...L.styles.root,...i.root}},ie),z.createElement(on.Provider,{value:ke},z.createElement(Zt.Provider,{value:Oe},we&&z.createElement(Mn.Provider,{value:{prefixCls:F}},we),z.createElement(`div`,{className:o(`${F}-content`,a.content),style:i.content,onMouseDown:Ae},Ce&&z.createElement(`div`,{className:o(`${F}-prefix`,L.classNames.prefix,a.prefix),style:{...L.styles.prefix,...i.prefix}},Ce),P?z.createElement(vn,{ref:I}):z.createElement(An,{ref:I}),H&&z.createElement(`div`,{className:o(pe,L.classNames.suffix,a.suffix),style:{...L.styles.suffix,...i.suffix}},H)),Te&&z.createElement(`div`,{className:o(`${F}-footer`,L.classNames.footer,a.footer),style:{...L.styles.footer,...i.footer}},Te))))}),Un=z.forwardRef((e,t)=>{let{children:r,className:i,classNames:a={},styles:s={},icon:c,style:l,onChange:u,rootClassName:d,loading:f,defaultValue:p,value:m,checkedChildren:h,unCheckedChildren:g,disabled:v,prefixCls:y,...b}=e,{styles:x={},classNames:S={},prefixCls:C}=z.useContext(on),w=(0,at.default)(b,{attr:!0,aria:!0,data:!0}),E=z.useId(),{direction:D,getPrefixCls:O}=V(),k=O(`sender`,y||C),A=`${k}-switch`,[ee,te]=Bn(k),j=z.useRef(null);ct(t,()=>({nativeElement:j.current}));let[M,ne]=_(p,m),N=de(`sender`),re=o(k,A,i,d,N.classNames.switch,S.switch,a.root,ee,te,{[`${A}-checked`]:M,[`${A}-rtl`]:D===`rtl`});return z.createElement(`div`,n({ref:j,className:re,key:E,style:{...l,...N.styles.switch,...x.switch,...s.root}},w),z.createElement(T,{disabled:v,loading:f,className:o(`${A}-content`,a.content),style:s.content,styles:{icon:s.icon,content:s.title},classNames:{icon:a.icon,content:a.title},variant:`outlined`,color:M?`primary`:`default`,icon:c,onClick:()=>{let e=!M;ne(e),u?.(e)}},M?h:g,r))}),Wn=Hn;Wn.Header=Fn,Wn.Switch=Un;var Gn=e=>{let{componentCls:t,calc:n}=e,r=n(e.fontSizeHeading3).mul(e.lineHeightHeading3).equal(),i=n(e.fontSize).mul(e.lineHeight).equal();return{[t]:{gap:e.padding,[`${t}-icon`]:{height:n(r).add(i).add(e.paddingXXS).equal(),display:`flex`,img:{height:`100%`}},[`${t}-content-wrapper`]:{gap:e.paddingXS,flex:`auto`,minWidth:0,[`${t}-title-wrapper`]:{gap:e.paddingXS},[`${t}-title`]:{margin:0},[`${t}-extra`]:{marginInlineStart:`auto`}}}}},Kn=e=>{let{componentCls:t}=e;return{[t]:{"&-filled":{paddingInline:e.padding,paddingBlock:e.paddingSM,background:e.colorFillContent,borderRadius:e.borderRadiusLG},"&-borderless":{[`${t}-title`]:{fontSize:e.fontSizeHeading3,lineHeight:e.lineHeightHeading3}}}}},qn=Ve(`Welcome`,t=>{let n=e(t,{});return[Gn(n),Kn(n)]},()=>({})),Jn=z.forwardRef((e,t)=>{let{prefixCls:n,rootClassName:r,className:i,style:a,variant:s=`filled`,classNames:c={},styles:l={},icon:u,title:d,description:f,extra:p}=e,{direction:m,getPrefixCls:h}=V(),g=h(`welcome`,n),_=de(`welcome`),[v,y]=qn(g),b=z.useMemo(()=>{if(!u)return null;let e=u;return typeof u==`string`&&u.startsWith(`http`)&&(e=z.createElement(`img`,{src:u,alt:`icon`})),z.createElement(`div`,{className:o(`${g}-icon`,_.classNames.icon,c.icon),style:l.icon},e)},[u]),x=z.useMemo(()=>d?z.createElement(F.Title,{level:4,className:o(`${g}-title`,_.classNames.title,c.title),style:l.title},d):null,[d]),S=z.useMemo(()=>p?z.createElement(`div`,{className:o(`${g}-extra`,_.classNames.extra,c.extra),style:l.extra},p):null,[p]);return z.createElement(ne,{ref:t,className:o(g,_.className,i,r,c.root,v,y,`${g}-${s}`,{[`${g}-rtl`]:m===`rtl`}),style:{...a,...l.root}},b,z.createElement(ne,{vertical:!0,className:`${g}-content-wrapper`},p?z.createElement(ne,{align:`flex-start`,className:`${g}-title-wrapper`},x,S):x,f&&z.createElement(F.Text,{className:o(`${g}-description`,_.classNames.description,c.description),style:l.description},f)))}),Yn={_chatMessagesStores:new Map,get:e=>Yn._chatMessagesStores.get(e),set:(e,t)=>{Yn._chatMessagesStores.set(e,t)},delete:e=>{Yn._chatMessagesStores.delete(e)},getMessages:e=>Yn._chatMessagesStores.get(e)?.getMessages()},Xn={_allConversationStores:new Map,set:(e,t)=>{Xn._allConversationStores.set(e,t)},delete:e=>{Xn._allConversationStores.delete(e)},getConversation:e=>{for(let t of Xn._allConversationStores.values())if(t){let n=t.getConversation(e);if(n)return n}}},Zn=class{conversations=[];listeners=[];storeKey;activeConversationKey;emitListeners(){this.listeners.forEach(e=>{e()})}constructor(e,t){this.setConversations(e),this.storeKey=Math.random().toString(),Xn.set(this.storeKey,this),this.activeConversationKey=t}setActiveConversationKey=e=>(this.activeConversationKey=e,this.emitListeners(),!0);setConversations=e=>(this.conversations=[...e],this.emitListeners(),!0);getConversation=e=>this.conversations.find(t=>t.key===e);addConversation=(e,t)=>this.getConversation(e.key)?!1:(this.setConversations(t===`prepend`?[e,...this.conversations]:[...this.conversations,e]),!0);setConversation=(e,t)=>{let n=this.getConversation(e);return n?(Object.assign(n,t),this.setConversations([...this.conversations]),!0):!1};removeConversation=e=>{let t=this.conversations.findIndex(t=>t.key===e);return t===-1?!1:(this.conversations.splice(t,1),this.setConversations([...this.conversations]),!0)};getMessages=e=>Yn.getMessages(e);getSnapshot=()=>this.conversations;getActiveConversationKey=()=>this.activeConversationKey;subscribe=e=>(this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)});destroy=()=>{Xn.delete(this.storeKey)}};function Qn(e){let[t]=(0,z.useState)(()=>new Zn(e?.defaultConversations||[],e?.defaultActiveConversationKey||``));return(0,z.useEffect)(()=>()=>{t.destroy()},[]),{conversations:(0,z.useSyncExternalStore)(t.subscribe,t.getSnapshot,t.getSnapshot),activeConversationKey:(0,z.useSyncExternalStore)(t.subscribe,t.getActiveConversationKey,t.getActiveConversationKey),setActiveConversationKey:t.setActiveConversationKey,addConversation:t.addConversation,removeConversation:t.removeConversation,setConversation:t.setConversation,getConversation:t.getConversation,setConversations:t.setConversations,getMessages:t.getMessages}}var $n=` `,er=` `,tr=`:`,nr=e=>(e??``).trim()!==``;function rr(e=$n){let t=``;return new TransformStream({transform(n,r){t+=n;let i=t.split(e);i.slice(0,-1).forEach(e=>{nr(e)&&r.enqueue(e)}),t=i[i.length-1]},flush(e){nr(t)&&e.enqueue(t)}})}function ir(e=er,t=tr){return new TransformStream({transform(n,r){let i=n.split(e).reduce((e,n)=>{let r=n.indexOf(t);if(r===-1)return console.warn(`The key-value separator "${t}" is not found in the sse line: ${n} !`),e;let i=n.slice(0,r).trim();if(!nr(i))return e;let a=n.slice(r+1).trim();return{...e,[i]:a}},{});Object.keys(i).length!==0&&r.enqueue(i)}})}function ar(){if(typeof TextDecoderStream<`u`)return new TextDecoderStream;let e=new TextDecoder(`utf-8`);return new TransformStream({transform(t,n){n.enqueue(e.decode(t,{stream:!0}))},flush(t){t.enqueue(e.decode())}})}function or(e){let{readableStream:t,transformStream:n,streamSeparator:r,partSeparator:i,kvSeparator:a}=e;if(!(t instanceof ReadableStream))throw Error(`The options.readableStream must be an instance of ReadableStream.`);let o=ar(),s=n?t.pipeThrough(o).pipeThrough(n):t.pipeThrough(o).pipeThrough(rr(r)).pipeThrough(ir(i,a));return s[Symbol.asyncIterator]=async function*(){let e=this.getReader();for(;;){let{done:t,value:n}=await e.read();if(t)break;n&&(yield n)}},s}var sr=async(e,t)=>{let{fetch:n=globalThis.fetch,middlewares:r={},...i}=t;if(typeof n!=`function`)throw Error(`The options.fetch must be a typeof fetch function!`);let a=[e,i];typeof r.onRequest==`function`&&(a=await r.onRequest(...a));let o=await n(...a);if(typeof r.onResponse==`function`){let e=await r.onResponse(o);if(!(e instanceof Response))throw Error(`The options.onResponse must return a Response instance!`);o=e}if(!o.ok)throw Error(`Fetch failed with status ${o.status}`);if(!o.body)throw Error(`The response body is empty.`);return o},cr={manual:!1,headers:{"Content-Type":`application/json`}},lr=`Last-Event-ID`,ur=class{baseURL;options;constructor(e,t){if(!e||typeof e!=`string`)throw Error(`The baseURL is not valid!`);this.baseURL=e,this.options=t||{}}},dr=class extends ur{_asyncHandler;timeoutHandler;_isTimeout=!1;streamTimeoutHandler;_isStreamTimeout=!1;abortController;_isRequesting=!1;_manual=!1;lastManualParams;retryTimes=0;retryTimer;lastEventId=void 0;get asyncHandler(){return this._asyncHandler}get isTimeout(){return this._isTimeout}set isTimeout(e){this._isTimeout=e}get isStreamTimeout(){return this._isStreamTimeout}set isStreamTimeout(e){this._isStreamTimeout=e}get isRequesting(){return this._isRequesting}get manual(){return this._manual}constructor(e,t){super(e,t),this._manual=t?.manual||!1,this.manual||this.init()}run(e){return this.manual?(this.resetRetry(),this.lastManualParams=e,this.init(e),!0):(console.warn(`The request is not manual, so it cannot be run!`),!1)}abort(){clearTimeout(this.timeoutHandler),clearTimeout(this.streamTimeoutHandler),this.abortController.abort()}init(e,t){this.abortController=new AbortController;let{callbacks:n,params:r,headers:i={},transformStream:a,fetch:o,timeout:s,streamTimeout:c,middlewares:l,streamSeparator:u,partSeparator:d,kvSeparator:f,...p}=this.options,m=Object.assign({},cr.headers||{},i,t||{}),h={...p,method:`POST`,body:JSON.stringify({...r,...e||{}}),params:{...r,...e},headers:m,signal:this.abortController.signal,middlewares:l};s&&s>0&&(this.timeoutHandler=window.setTimeout(()=>{this.isTimeout=!0,this.finishRequest(),n?.onError?.(Error(`TimeoutError`))},s)),this.startRequest(),this._asyncHandler=sr(this.baseURL,{fetch:o,...h}).then(async e=>{if(clearTimeout(this.timeoutHandler),this.isTimeout)return;if(a){let t=a;typeof a==`function`&&(t=a(this.baseURL,e.headers)),await this.customResponseHandler(e,n,t,c,u,d,f);return}let t=e.headers.get(`content-type`)||``;switch(t.split(`;`)[0].trim()){case`text/event-stream`:await this.sseResponseHandler(e,n,c,u,d,f);break;case`application/json`:await this.jsonResponseHandler(e,n);break;default:throw Error(`The response content-type: ${t} is not support!`)}}).catch(e=>{clearTimeout(this.timeoutHandler),this.finishRequest();let t=e instanceof Error||e instanceof DOMException?e:Error(`Unknown error!`),r=n?.onError?.(t);if(t.name!==`AbortError`){let e=typeof r==`number`?r:this.options.retryInterval;if(e&&e>0){if(typeof this.options.retryTimes==`number`&&this.retryTimes>=this.options.retryTimes)return;clearTimeout(this.retryTimer),this.retryTimer=setTimeout(()=>{let e={};this.lastEventId!==void 0&&(e[lr]=this.lastEventId),this.init(this.lastManualParams,e)},e),this.retryTimes+=1}}})}startRequest(){this._isRequesting=!0}finishRequest(){this._isRequesting=!1}customResponseHandler=async(e,t,n,r,i,a,o)=>{let s=or({readableStream:e.body,transformStream:n,streamSeparator:i,partSeparator:a,kvSeparator:o});await this.processStream(s,e,t,r)};sseResponseHandler=async(e,t,n,r,i,a)=>{let o=or({readableStream:e.body,streamSeparator:r,partSeparator:i,kvSeparator:a});await this.processStream(o,e,t,n)};async processStream(e,t,n,r){let i=[],a=e[Symbol.asyncIterator](),o;do{if(r&&(this.streamTimeoutHandler=window.setTimeout(()=>{this.isStreamTimeout=!0,this.finishRequest(),n?.onError?.(Error(`StreamTimeoutError`),void 0,t.headers)},r)),o=await a.next(),clearTimeout(this.streamTimeoutHandler),this.isStreamTimeout)break;o.value&&(i.push(o.value),n?.onUpdate?.(o.value,t.headers),o?.value?.id!==void 0&&(this.lastEventId=o.value.id))}while(!o.done);if(r&&(clearTimeout(this.streamTimeoutHandler),this.isStreamTimeout)){this.finishRequest();return}this.finishRequest(),n?.onSuccess?.(i,t.headers)}jsonResponseHandler=async(e,t)=>{let n=await e.json();if(n?.success===!1){let r=Error(n.message||`System error`);r.name=n.name||`SystemError`,t?.onError?.(r,n,e.headers)}else t?.onUpdate?.(n,e.headers),this.finishRequest(),t?.onSuccess?.([n],e.headers)};resetRetry(){clearTimeout(this.retryTimer),this.retryTimes=0,this.lastEventId=void 0}};function fr(e,t){return new dr(e,t)}function pr(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var mr=pr();function hr(e){mr=e}var gr={exec:()=>null};function G(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(_r.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var _r={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,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^$/,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,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`)},vr=/^(?:[ \t]*(?:\n|$))+/,yr=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,br=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,xr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Sr=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Cr=/(?:[*+-]|\d{1,9}[.)])/,wr=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Tr=G(wr).replace(/bull/g,Cr).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(),Er=G(wr).replace(/bull/g,Cr).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(),Dr=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Or=/^[^\n]+/,kr=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Ar=G(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,kr).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),jr=G(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Cr).getRegex(),Mr=`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`,Nr=/|$))/,Pr=G(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Nr).replace(`tag`,Mr).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Fr=G(Dr).replace(`hr`,xr).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[.)]) `).replace(`html`,`)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Mr).getRegex(),Ir={blockquote:G(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Fr).getRegex(),code:yr,def:Ar,fences:br,heading:Sr,hr:xr,html:Pr,lheading:Tr,list:jr,newline:vr,paragraph:Fr,table:gr,text:Or},Lr=G(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,xr).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Mr).getRegex(),Rr={...Ir,lheading:Er,table:Lr,paragraph:G(Dr).replace(`hr`,xr).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Lr).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Mr).getRegex()},zr={...Ir,html:G(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Nr).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:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:gr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:G(Dr).replace(`hr`,xr).replace(`heading`,` *#{1,6} *[^ ]`).replace(`lheading`,Tr).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Br=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Vr=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Hr=/^( {2,}|\\)\n(?!\s*$)/,Ur=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\]*?>/g,Qr=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,$r=G(Qr,`u`).replace(/punct/g,Wr).getRegex(),ei=G(Qr,`u`).replace(/punct/g,Jr).getRegex(),ti=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,ni=G(ti,`gu`).replace(/notPunctSpace/g,Kr).replace(/punctSpace/g,Gr).replace(/punct/g,Wr).getRegex(),ri=G(ti,`gu`).replace(/notPunctSpace/g,Xr).replace(/punctSpace/g,Yr).replace(/punct/g,Jr).getRegex(),ii=G(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Kr).replace(/punctSpace/g,Gr).replace(/punct/g,Wr).getRegex(),ai=G(/\\(punct)/,`gu`).replace(/punct/g,Wr).getRegex(),oi=G(/^<(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(),si=G(Nr).replace(`(?:-->|$)`,`-->`).getRegex(),ci=G(`^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^`).replace(`comment`,si).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),li=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ui=G(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,li).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),di=G(/^!?\[(label)\]\[(ref)\]/).replace(`label`,li).replace(`ref`,kr).getRegex(),fi=G(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,kr).getRegex(),pi={_backpedal:gr,anyPunctuation:ai,autolink:oi,blockSkip:Zr,br:Hr,code:Vr,del:gr,emStrongLDelim:$r,emStrongRDelimAst:ni,emStrongRDelimUnd:ii,escape:Br,link:ui,nolink:fi,punctuation:qr,reflink:di,reflinkSearch:G(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,di).replace(`nolink`,fi).getRegex(),tag:ci,text:Ur,url:gr},mi={...pi,link:G(/^!?\[(label)\]\((.*?)\)/).replace(`label`,li).getRegex(),reflink:G(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,li).getRegex()},hi={...pi,emStrongRDelimAst:ri,emStrongLDelim:ei,url:G(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,`i`).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~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\":`>`,'"':`"`,"'":`'`},bi=e=>yi[e];function xi(e,t){if(t){if(_r.escapeTest.test(e))return e.replace(_r.escapeReplace,bi)}else if(_r.escapeTestNoEncode.test(e))return e.replace(_r.escapeReplaceNoEncode,bi);return e}function Si(e){try{e=encodeURI(e).replace(_r.percentDecode,`%`)}catch{return null}return e}function Ci(e,t){let n=e.replace(_r.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(_r.splitPipe),r=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.length0?-2:-1}function Ei(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function Di(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(` `).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(` `)}var Oi=class{options;rules;lexer;constructor(e){this.options=e||mr}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=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:wi(e,` `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=Di(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=wi(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],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:wi(t[0],` `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=wi(t[0],` `).split(` `),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;o1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=t[2].split(` `,1)[0].replace(this.rules.other.listReplaceTabs,e=>` `.repeat(3*e.length)),l=e.split(` `,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=t[2].search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+` `,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d);for(;e;){let f=e.split(` `,1)[0],p;if(l=f,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),p=l):p=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||t.test(l)||n.test(l))break;if(p.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=` `+p.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=` `+l}!u&&!l.trim()&&(u=!0),r+=f+` `,e=e.substring(f.length+1),c=p.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0));let f=null,p;this.options.gfm&&(f=this.rules.other.listIsTask.exec(s),f&&(p=f[0]!==`[ ] `,s=s.replace(this.rules.other.listReplaceTask,``))),i.items.push({type:`list_item`,raw:r,task:!!f,checked:p,loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e=0;ee.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}if(i.loose)for(let e=0;e({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=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=wi(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=Ti(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?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],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=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)),Ei(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.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 Ei(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(r&&!(r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}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),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(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){let t=this.rules.inline.del.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}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 r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`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}}}},ki=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||mr,this.options.tokenizer=this.options.tokenizer||new Oi,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:_r,block:_i.normal,inline:vi.normal};this.options.pedantic?(t.block=_i.pedantic,t.inline=vi.pedantic):this.options.gfm&&(t.block=_i.gfm,this.options.breaks?t.inline=vi.breaks:t.inline=vi.gfm),this.tokenizer.rules=t}static get rules(){return{block:_i,inline:vi}}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(_r.carriageReturn,` `),this.blockTokens(e,this.tokens);for(let e=0;e(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=` `:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=` `+r.raw,n.text+=` `+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);n?.type===`paragraph`||n?.type===`text`?(n.raw+=` `+r.raw,n.text+=` `+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});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 i=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let a=t.at(-1);n&&a?.type===`paragraph`?(a.raw+=` `+r.raw,a.text+=` `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(r),n=i.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);n?.type===`text`?(n.raw+=` `+r.raw,n.text+=` `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let i=!1,a=``;for(;e;){i||(a=``),i=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,a)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let o=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(o=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(o)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(a=r.raw.slice(-1)),i=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return t}},Ai=class{options;parser;constructor(e){this.options=e||mr}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(_r.notSpaceStart)?.[0],i=e.replace(_r.endingNewline,``)+` `;return r?`
`+(n?i:xi(i,!0))+`
`:`
`+(n?i:xi(i,!0))+`
`}blockquote({tokens:e}){return`
${this.parser.parse(e)}
`}html({text:e}){return e}heading({tokens:e,depth:t}){return`${this.parser.parseInline(e)} `}hr(e){return`
`}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t `+r+` `}listitem(e){let t=``;if(e.task){let n=this.checkbox({checked:!!e.checked});e.loose?e.tokens[0]?.type===`paragraph`?(e.tokens[0].text=n+` `+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type===`text`&&(e.tokens[0].tokens[0].text=n+` `+xi(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:`text`,raw:n+` `,text:n+` `,escaped:!0}):t+=n+` `}return t+=this.parser.parse(e.tokens,!!e.loose),`
  • ${t}
  • `}checkbox({checked:e}){return``}paragraph({tokens:e}){return`

    ${this.parser.parseInline(e)}

    `}table(e){let t=``,n=``;for(let t=0;t${r}`,` `+t+` `+r+`
    `}tablerow({text:e}){return` ${e} `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+` `}strong({tokens:e}){return`${this.parser.parseInline(e)}`}em({tokens:e}){return`${this.parser.parseInline(e)}`}codespan({text:e}){return`${xi(e,!0)}`}br(e){return`
    `}del({tokens:e}){return`${this.parser.parseInline(e)}`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=Si(e);if(i===null)return r;e=i;let a=`
    `+r+``,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Si(e);if(i===null)return xi(n);e=i;let a=`${n}`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:xi(e.text)}},ji=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``}},Mi=class e{options;renderer;textRenderer;constructor(e){this.options=e||mr,this.options.renderer=this.options.renderer||new Ai,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ji}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e,t=!0){let n=``;for(let r=0;r{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,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 Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw 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&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(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 Ai(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Oi(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Ni;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];Ni.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async)return Promise.resolve(i.call(t,e)).then(e=>a.call(t,e));let n=i.call(t,e);return a.call(t,n)}:t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.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 ki.lex(e,t??this.defaults)}parser(e,t){return Mi.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(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(t==null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));i.hooks&&(i.hooks.options=i,i.hooks.block=e);let o=i.hooks?i.hooks.provideLexer():e?ki.lex:ki.lexInline,s=i.hooks?i.hooks.provideParser():e?Mi.parse:Mi.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(t):t).then(e=>o(e,i)).then(e=>i.hooks?i.hooks.processAllTokens(e):e).then(e=>i.walkTokens?Promise.all(this.walkTokens(e,i.walkTokens)).then(()=>e):e).then(e=>s(e,i)).then(e=>i.hooks?i.hooks.postprocess(e):e).catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let e=o(t,i);i.hooks&&(e=i.hooks.processAllTokens(e)),i.walkTokens&&this.walkTokens(e,i.walkTokens);let n=s(e,i);return i.hooks&&(n=i.hooks.postprocess(n)),n}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=` Please report this to https://github.com/markedjs/marked.`,e){let e=`

    An error occurred:

    `+xi(n.message+``,!0)+`
    `;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},Fi=new Pi;function K(e,t){return Fi.parse(e,t)}K.options=K.setOptions=function(e){return Fi.setOptions(e),K.defaults=Fi.defaults,hr(K.defaults),K},K.getDefaults=pr,K.defaults=mr,K.use=function(...e){return Fi.use(...e),K.defaults=Fi.defaults,hr(K.defaults),K},K.walkTokens=function(e,t){return Fi.walkTokens(e,t)},K.parseInline=Fi.parseInline,K.Parser=Mi,K.parser=Mi.parse,K.Renderer=Ai,K.TextRenderer=ji,K.Lexer=ki,K.lexer=ki.lex,K.Tokenizer=Oi,K.Hooks=Ni,K.parse=K,K.options,K.setOptions,K.use,K.walkTokens,K.parseInline,Mi.parse,ki.lex;var Ii={escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeTest:/[&<>"'/]/,notSpaceStart:/^\S*/,endingNewline:/\n$/,escapeReplace:/[&<>"'/]/g,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,completeFencedCode:/^ {0,3}(`{3,}|~{3,})([\s\S]*?)\n {0,3}\1[ \n\t]*$/},Li={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`,"/":`/`},Ri=e=>Li[e];function zi(e,t){if(t){if(Ii.escapeTest.test(e))return e.replace(Ii.escapeReplace,Ri)}else if(Ii.escapeTestNoEncode.test(e))return e.replace(Ii.escapeReplaceNoEncode,Ri);return e}var Bi=Symbol(`tailMarker`),Vi=`X_MD_NL_`,Hi=``,Ui=/\uE000X_MD_NL_\d+\uE001/g,Wi=class{options;markdownInstance;injectTail=!1;constructor(e={}){this.options=e,this.markdownInstance=new Pi,this.configureLinkRenderer(),this.configureParagraphRenderer(),this.configureCodeRenderer(),this.configureHtmlEscapeRenderer(),this.configureTailInjection(),this.markdownInstance.use(e.markedConfig||{})}configureHtmlEscapeRenderer(){this.options.escapeRawHtml&&this.markdownInstance.use({renderer:{html(e){let{raw:t=``,text:n=``}=e;return zi(t||n,!0)}}})}configureLinkRenderer(){this.options.openLinksInNewTab&&this.markdownInstance.use({renderer:{link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n);return`${r}`}}})}configureParagraphRenderer(){let{paragraphTag:e}=this.options;e&&this.markdownInstance.use({renderer:{paragraph({tokens:t}){return`<${e}>${this.parser.parseInline(t)}\n`}}})}configureCodeRenderer(){this.markdownInstance.use({renderer:{code({text:e,raw:t,lang:n,escaped:r,codeBlockStyle:i}){let a=(n||``).trim(),o=a.match(Ii.notSpaceStart)?.[0],s=`${e.replace(Ii.endingNewline,``)}\n`,c=i===`indented`||Ii.completeFencedCode.test(t)?`done`:`loading`,l=r?s:zi(s,!0),u=o?` class="language-${zi(o)}"`:``;return`
    ${l}
    \n`}}})}configureTailInjection(){let e=this;this.markdownInstance.use({hooks:{processAllTokens(t){if(!e.injectTail)return t;let n=e.findLastTextToken(t);return n&&(n[Bi]=!0),t}},renderer:{text(e){let t=`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`text`in e?e.text:``;return e[Bi]?`${t}`:t}}})}protectCustomTags(e,t){let n=new Map,r=Object.keys(this.options.components||{});if(r.length===0)return{protected:e,placeholders:n};let i=0,a=e=>e.replace(/\n/g,()=>{let e=`${Vi}${i++}${Hi}`;return n.set(e,` `),e}),o=r.map(e=>e.toLowerCase().replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`),s=RegExp(`<(${o})(?:\\s[^>]*)?>`,`gi`),c=RegExp(``,`gi`),l=[],u=s.exec(e);for(;u!==null;)l.push({index:u.index,type:`open`,tagName:u[1].toLowerCase(),match:u[0]}),u=s.exec(e);for(c.lastIndex=0,u=c.exec(e);u!==null;)l.push({index:u.index,type:`close`,tagName:u[1].toLowerCase(),match:u[0]}),u=c.exec(e);l.sort((e,t)=>e.index-t.index);let d=[],f=[],p=0;for(let n of l)if(n.type===`open`)n.match.endsWith(`/>`)||d.push({tagName:n.tagName,start:n.index,openTag:n.match});else if(n.type===`close`&&d.length>0&&d[d.length-1].tagName===n.tagName){let r=d.pop();if(d.length===0){let i=r.start,o=n.index+n.match.length,s=r.openTag,c=n.match,l=e.slice(i+s.length,n.index);if(pa(e));f.push(s+e+c)}else f.push(s+l+c);p=o}}return pt.get(e)??e)}findLastNonEmptyToken(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type===`list`&&`items`in n&&Array.isArray(n.items))for(let e=n.items.length-1;e>=0;e--){let t=n.items[e];if(`tokens`in t&&t.tokens&&t.tokens.length>0){let e=this.findLastNonEmptyToken(t.tokens);if(e)return e}}if(`tokens`in n&&n.tokens&&n.tokens.length>0){let e=this.findLastNonEmptyToken(n.tokens);if(e)return e}if(n.type===`text`){if((`text`in n?n.text:``).trim())return n}else if(n.type===`html`||n.type===`tag`)return n}return null}findLastTextToken(e){let t=this.findLastNonEmptyToken(e);return t?.type===`text`?t:null}parse(e,t){if(this.injectTail=t?.injectTail??!1,this.options.protectCustomTagNewlines||this.options.disableCustomTagBlockMarkdown){let{protected:t,placeholders:n}=this.protectCustomTags(e,!!this.options.disableCustomTagBlockMarkdown),r=this.markdownInstance.parse(t);return this.restorePlaceholders(r,n)}return this.markdownInstance.parse(e)}};function Gi(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n`u`?null:X(BigInt.prototype.toString),Sa=typeof Symbol>`u`?null:X(Symbol.prototype.toString),J=X(Object.prototype.hasOwnProperty),Ca=X(Object.prototype.toString),Y=X(RegExp.prototype.test),wa=Ta(TypeError);function X(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return aa(e,t,n)}}function Ta(e){return function(){return oa(e,[...arguments])}}function Z(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:pa;if(Qi&&Qi(e,null),!fa(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&($i(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Ea(e){for(let t=0;t/g),Wa=na(/\${[\w\W]*/g),Ga=na(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ka=na(/^aria-[\-\w]+$/),qa=na(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ja=na(/^(?:\w+script|data):/i),Ya=na(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Xa=na(/^html$/i),Za=na(/^[a-z][.\w]*(-[.\w]+)+$/i),Qa=na(/<[/\w!]/g),$a=na(/<[/\w]/g),eo=na(/<\/no(script|embed|frames)/i),to=na(/\/>/i),no={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},ro=function(){return typeof window>`u`?null:window},io=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},ao=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},oo=function(e,t,n,r){return J(e,t)&&fa(e[t])?Z(r.base?Da(r.base):{},e[t],r.transform):n};function so(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ro(),t=e=>so(e);if(t.version=`3.4.11`,t.removed=[],!e||!e.document||e.document.nodeType!==no.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=ka(d,`cloneNode`),p=ka(d,`remove`),m=ka(d,`nextSibling`),h=ka(d,`childNodes`),g=ka(d,`parentNode`),_=ka(d,`shadowRoot`),v=ka(d,`attributes`),y=o&&o.prototype?ka(o.prototype,`nodeType`):null,b=o&&o.prototype?ka(o.prototype,`nodeName`):null;if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let x,S=``,C,w=!1,T=0,E=function(){if(T>0)throw wa(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},D=function(e){E(),T++;try{return x.createHTML(e)}finally{T--}},O=function(e){E(),T++;try{return x.createScriptURL(e)}finally{T--}},k=function(){return w||=(C=io(u,i),!0),C},A=n,ee=A.implementation,te=A.createNodeIterator,j=A.createDocumentFragment,M=A.getElementsByTagName,ne=r.importNode,N=ao();t.isSupported=typeof Zi==`function`&&typeof g==`function`&&ee&&ee.createHTMLDocument!==void 0;let re=Ha,ie=Ua,ae=Wa,P=Ga,oe=Ka,se=Ja,F=Ya,ce=Za,I=qa,L=null,le=Z({},[...ja,...Ma,...Na,...Fa,...La]),R=null,z=Z({},[...Ra,...za,...Ba,...Va]),B=Object.seal(ra(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}})),ue=null,de=null,V=Object.seal(ra(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),fe=!0,pe=!0,me=!1,he=!0,ge=!1,_e=!0,ve=!1,ye=!1,be=null,xe=null,Se=!1,H=!1,Ce=!1,we=!1,Te=!0,Ee=!1,De=`user-content-`,Oe=!0,ke=!1,Ae={},je=null,Me=Z({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Ne=null,Pe=Z({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Fe=null,Ie=Z({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Le=`http://www.w3.org/1998/Math/MathML`,Re=`http://www.w3.org/2000/svg`,ze=`http://www.w3.org/1999/xhtml`,Be=ze,Ve=!1,He=null,Ue=Z({},[Le,Re,ze],ma),We=q([`mi`,`mo`,`mn`,`ms`,`mtext`]),Ge=Z({},We),Ke=q([`annotation-xml`]),qe=Z({},Ke),Je=Z({},[`title`,`style`,`font`,`a`,`script`]),Ye=null,Xe=[`application/xhtml+xml`,`text/html`],U=null,Ze=null,Qe=n.createElement(`form`),$e=function(e){return e instanceof RegExp||e instanceof Function},et=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ze&&Ze===e)return;(!e||typeof e!=`object`)&&(e={}),e=Da(e),Ye=Xe.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,U=Ye===`application/xhtml+xml`?ma:pa,L=oo(e,`ALLOWED_TAGS`,le,{transform:U}),R=oo(e,`ALLOWED_ATTR`,z,{transform:U}),He=oo(e,`ALLOWED_NAMESPACES`,Ue,{transform:ma}),Fe=oo(e,`ADD_URI_SAFE_ATTR`,Ie,{transform:U,base:Ie}),Ne=oo(e,`ADD_DATA_URI_TAGS`,Pe,{transform:U,base:Pe}),je=oo(e,`FORBID_CONTENTS`,Me,{transform:U}),ue=oo(e,`FORBID_TAGS`,Da({}),{transform:U}),de=oo(e,`FORBID_ATTR`,Da({}),{transform:U}),Ae=J(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?Da(e.USE_PROFILES):e.USE_PROFILES:!1,fe=e.ALLOW_ARIA_ATTR!==!1,pe=e.ALLOW_DATA_ATTR!==!1,me=e.ALLOW_UNKNOWN_PROTOCOLS||!1,he=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ge=e.SAFE_FOR_TEMPLATES||!1,_e=e.SAFE_FOR_XML!==!1,ve=e.WHOLE_DOCUMENT||!1,H=e.RETURN_DOM||!1,Ce=e.RETURN_DOM_FRAGMENT||!1,we=e.RETURN_TRUSTED_TYPE||!1,Se=e.FORCE_BODY||!1,Te=e.SANITIZE_DOM!==!1,Ee=e.SANITIZE_NAMED_PROPS||!1,Oe=e.KEEP_CONTENT!==!1,ke=e.IN_PLACE||!1,I=Aa(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:qa,Be=typeof e.NAMESPACE==`string`?e.NAMESPACE:ze,Ge=J(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?Da(e.MATHML_TEXT_INTEGRATION_POINTS):Z({},We),qe=J(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?Da(e.HTML_INTEGRATION_POINTS):Z({},Ke);let t=J(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?Da(e.CUSTOM_ELEMENT_HANDLING):ra(null);if(B=ra(null),J(t,`tagNameCheck`)&&$e(t.tagNameCheck)&&(B.tagNameCheck=t.tagNameCheck),J(t,`attributeNameCheck`)&&$e(t.attributeNameCheck)&&(B.attributeNameCheck=t.attributeNameCheck),J(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(B.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),na(B),ge&&(pe=!1),Ce&&(H=!0),Ae&&(L=Z({},La),R=ra(null),Ae.html===!0&&(Z(L,ja),Z(R,Ra)),Ae.svg===!0&&(Z(L,Ma),Z(R,za),Z(R,Va)),Ae.svgFilters===!0&&(Z(L,Na),Z(R,za),Z(R,Va)),Ae.mathMl===!0&&(Z(L,Fa),Z(R,Ba),Z(R,Va))),V.tagCheck=null,V.attributeCheck=null,J(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?V.tagCheck=e.ADD_TAGS:fa(e.ADD_TAGS)&&(L===le&&(L=Da(L)),Z(L,e.ADD_TAGS,U))),J(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?V.attributeCheck=e.ADD_ATTR:fa(e.ADD_ATTR)&&(R===z&&(R=Da(R)),Z(R,e.ADD_ATTR,U))),J(e,`ADD_URI_SAFE_ATTR`)&&fa(e.ADD_URI_SAFE_ATTR)&&Z(Fe,e.ADD_URI_SAFE_ATTR,U),J(e,`FORBID_CONTENTS`)&&fa(e.FORBID_CONTENTS)&&(je===Me&&(je=Da(je)),Z(je,e.FORBID_CONTENTS,U)),J(e,`ADD_FORBID_CONTENTS`)&&fa(e.ADD_FORBID_CONTENTS)&&(je===Me&&(je=Da(je)),Z(je,e.ADD_FORBID_CONTENTS,U)),Oe&&(L[`#text`]=!0),ve&&Z(L,[`html`,`head`,`body`]),L.table&&(Z(L,[`tbody`]),delete ue.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw wa(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw wa(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=x;x=e.TRUSTED_TYPES_POLICY;try{S=D(``)}catch(e){throw x=t,e}}else e.TRUSTED_TYPES_POLICY===null?(x=void 0,S=``):(x===void 0&&(x=k()),x&&typeof S==`string`&&(S=D(``)));q&&q(e),Ze=e},tt=Z({},[...Ma,...Na,...Pa]),nt=Z({},[...Fa,...Ia]),rt=function(e,t,n){return t.namespaceURI===ze?e===`svg`:t.namespaceURI===Le?e===`svg`&&(n===`annotation-xml`||Ge[n]):!!tt[e]},it=function(e,t,n){return t.namespaceURI===ze?e===`math`:t.namespaceURI===Re?e===`math`&&qe[n]:!!nt[e]},at=function(e,t,n){return t.namespaceURI===Re&&!qe[n]||t.namespaceURI===Le&&!Ge[n]?!1:!nt[e]&&(Je[e]||!tt[e])},ot=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:Be,tagName:`template`});let n=pa(e.tagName),r=pa(t.tagName);return He[e.namespaceURI]?e.namespaceURI===Re?rt(n,t,r):e.namespaceURI===Le?it(n,t,r):e.namespaceURI===ze?at(n,t,r):!!(Ye===`application/xhtml+xml`&&He[e.namespaceURI]):!1},st=function(e){ua(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw wa(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},ct=function(e){let t=h(e);if(t){let e=[];sa(t,t=>{ua(e,t)}),sa(e,e=>{try{p(e)}catch{}})}let n=v(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;if(typeof i==`string`)try{e.removeAttribute(i)}catch{}}},lt=function(e,n){try{ua(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{ua(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(H||Ce)try{st(n)}catch{}else try{n.setAttribute(e,``)}catch{}},ut=function(e){let t=v(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;if(!(typeof i!=`string`||R[U(i)]))try{e.removeAttribute(i)}catch{}}},dt=function(e){let t=[e];for(;t.length>0;){let e=t.pop();(y?y(e):e.nodeType)===no.element&&ut(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},ft=function(e){let t=null,r=null;if(Se)e=``+e;else{let t=ha(e,/^[\r\n\t ]+/);r=t&&t[0]}Ye===`application/xhtml+xml`&&Be===ze&&(e=``+e+``);let i=x?D(e):e;if(Be===ze)try{t=new l().parseFromString(i,Ye)}catch{}if(!t||!t.documentElement){t=ee.createDocument(Be,`template`,null);try{t.documentElement.innerHTML=Ve?S:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Be===ze?M.call(t,ve?`html`:`body`)[0]:ve?t.documentElement:a},pt=function(e){return te.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},mt=function(e){return e=ga(e,re,` `),e=ga(e,ie,` `),e=ga(e,ae,` `),e},ht=function(e){e.normalize();let t=te.call(e.ownerDocument||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),n=t.nextNode();for(;n;)n.data=mt(n.data),n=t.nextNode();let r=e.querySelectorAll?.call(e,`template`);r&&sa(r,e=>{_t(e.content)&&ht(e.content)})},gt=function(e){let t=b?b(e):null;return typeof t!=`string`||U(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==v(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==y(e)||e.childNodes!==h(e)},_t=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===no.documentFragment}catch{return!1}},vt=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function yt(e,n,r){e.length!==0&&sa(e,e=>{e.call(t,n,r,Ze)})}let bt=function(e,t){return!!(_e&&e.hasChildNodes()&&!vt(e.firstElementChild)&&Y(Qa,e.textContent)&&Y(Qa,e.innerHTML)||_e&&e.namespaceURI===ze&&t===`style`&&vt(e.firstElementChild)||e.nodeType===no.processingInstruction||_e&&e.nodeType===no.comment&&Y($a,e.data))},xt=function(e,t){if(!ue[t]&&Tt(t)&&(B.tagNameCheck instanceof RegExp&&Y(B.tagNameCheck,t)||B.tagNameCheck instanceof Function&&B.tagNameCheck(t)))return!1;if(Oe&&!je[t]){let t=g(e),n=h(e);if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=ke?n[i]:f(n[i],!0);t.insertBefore(r,m(e))}}}return st(e),!0},St=function(e){if(yt(N.beforeSanitizeElements,e,null),gt(e))return st(e),!0;let n=U(b?b(e):e.nodeName);if(yt(N.uponSanitizeElement,e,{tagName:n,allowedTags:L}),bt(e,n))return st(e),!0;if(ue[n]||!(V.tagCheck instanceof Function&&V.tagCheck(n))&&!L[n])return xt(e,n);if((y?y(e):e.nodeType)===no.element&&!ot(e)||(n===`noscript`||n===`noembed`||n===`noframes`)&&Y(eo,e.innerHTML))return st(e),!0;if(ge&&e.nodeType===no.text){let n=mt(e.textContent);e.textContent!==n&&(ua(t.removed,{element:e.cloneNode()}),e.textContent=n)}return yt(N.afterSanitizeElements,e,null),!1},Ct=function(e,t,r){if(de[t]||Te&&(t===`id`||t===`name`)&&(r in n||r in Qe))return!1;let i=R[t]||V.attributeCheck instanceof Function&&V.attributeCheck(t,e);if(!(pe&&Y(P,t))&&!(fe&&Y(oe,t))){if(!i){if(!(Tt(e)&&(B.tagNameCheck instanceof RegExp&&Y(B.tagNameCheck,e)||B.tagNameCheck instanceof Function&&B.tagNameCheck(e))&&(B.attributeNameCheck instanceof RegExp&&Y(B.attributeNameCheck,t)||B.attributeNameCheck instanceof Function&&B.attributeNameCheck(t,e))||t===`is`&&B.allowCustomizedBuiltInElements&&(B.tagNameCheck instanceof RegExp&&Y(B.tagNameCheck,r)||B.tagNameCheck instanceof Function&&B.tagNameCheck(r))))return!1}else if(!Fe[t]&&!Y(I,ga(r,F,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&_a(r,`data:`)===0&&Ne[e])&&!(me&&!Y(se,ga(r,F,``)))&&r)return!1}return!0},wt=Z({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Tt=function(e){return!wt[pa(e)]&&Y(ce,e)},Et=function(e,t,n,r){if(x&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return D(r);case`TrustedScriptURL`:return O(r)}return r},Dt=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),gt(e)?st(e):la(t.removed)}catch{lt(n,e)}},W=function(e){yt(N.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||gt(e))return;let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:R,forceKeepAttr:void 0},r=t.length,i=U(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=U(o),u=c,d=o===`value`?u:va(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,yt(N.uponSanitizeAttribute,e,n),d=n.attrValue,Ee&&(l===`id`||l===`name`)&&_a(d,De)!==0&&(lt(o,e),d=De+d),_e&&Y(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){lt(o,e);continue}if(l===`attributename`&&ha(d,`href`)){lt(o,e);continue}if(!n.forceKeepAttr){if(!n.keepAttr){lt(o,e);continue}if(!he&&Y(to,d)){lt(o,e);continue}if(ge&&(d=mt(d)),!Ct(i,l,d)){lt(o,e);continue}d=Et(i,l,s,d),d!==u&&Dt(e,o,s,d)}}yt(N.afterSanitizeAttributes,e,null)},Ot=function(e){let t=null,n=pt(e);for(yt(N.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(yt(N.uponSanitizeShadowNode,t,null),St(t),W(t),_t(t.content)&&Ot(t.content),(y?y(t):t.nodeType)===no.element){let e=_(t);_t(e)&&(kt(e),Ot(e))}yt(N.afterSanitizeShadowDOM,e,null)},kt=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Ot(e.shadow);continue}let n=e.node,r=(y?y(n):n.nodeType)===no.element,i=h(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=b?b(n):null;if(typeof e==`string`&&U(e)===`template`){let e=n.content;_t(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);_t(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(Ve=!e,Ve&&(e=``),typeof e!=`string`&&!vt(e)&&(e=Oa(e),typeof e!=`string`))throw wa(`dirty is not a string, aborting`);if(!t.isSupported)return e;ye?(L=be,R=xe):et(n),(N.uponSanitizeElement.length>0||N.uponSanitizeAttribute.length>0)&&(L=Da(L)),N.uponSanitizeAttribute.length>0&&(R=Da(R)),t.removed=[];let c=ke&&typeof e!=`string`&&vt(e);if(c){let t=b?b(e):e.nodeName;if(typeof t==`string`){let e=U(t);if(!L[e]||ue[e])throw wa(`root node is forbidden and cannot be sanitized in-place`)}if(gt(e))throw wa(`root node is clobbered and cannot be sanitized in-place`);try{kt(e)}catch(t){throw ct(e),t}}else if(vt(e))i=ft(``),a=i.ownerDocument.importNode(e,!0),a.nodeType===no.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),kt(a);else{if(!H&&!ge&&!ve&&e.indexOf(`<`)===-1)return x&&we?D(e):e;if(i=ft(e),!i)return H?null:we?S:``}i&&Se&&st(i.firstChild);let l=pt(c?e:i);try{for(;o=l.nextNode();)St(o),W(o),_t(o.content)&&Ot(o.content)}catch(t){throw c&&ct(e),t}if(c)return sa(t.removed,e=>{e.element&&dt(e.element)}),ge&&ht(e),e;if(H){if(ge&&ht(i),Ce)for(s=j.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(R.shadowroot||R.shadowrootmode)&&(s=ne.call(r,s,!0)),s}let u=ve?i.outerHTML:i.innerHTML;return ve&&L[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&Y(Xa,i.ownerDocument.doctype.name)&&(u=` `+u),ge&&(u=mt(u)),x&&we?D(u):u},t.setConfig=function(){et(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),ye=!0,be=L,xe=R},t.clearConfig=function(){Ze=null,ye=!1,be=null,xe=null,x=C,S=``},t.isValidAttribute=function(e,t,n){return Ze||et({}),Ct(U(e),U(t),n)},t.addHook=function(e,t){typeof t==`function`&&J(N,e)&&ua(N[e],t)},t.removeHook=function(e,t){if(J(N,e)){if(t!==void 0){let n=ca(N[e],t);return n===-1?void 0:da(N[e],n,1)[0]}return la(N[e])}},t.removeHooks=function(e){J(N,e)&&(N[e]=[])},t.removeAllHooks=function(){N=ao()},t}var co=so(),lo=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Doctype=e.CDATA=e.Tag=e.Style=e.Script=e.Comment=e.Directive=e.Text=e.Root=e.isTag=e.ElementType=void 0;var t;(function(e){e.Root=`root`,e.Text=`text`,e.Directive=`directive`,e.Comment=`comment`,e.Script=`script`,e.Style=`style`,e.Tag=`tag`,e.CDATA=`cdata`,e.Doctype=`doctype`})(t=e.ElementType||={});function n(e){return e.type===t.Tag||e.type===t.Script||e.type===t.Style}e.isTag=n,e.Root=t.Root,e.Text=t.Text,e.Directive=t.Directive,e.Comment=t.Comment,e.Script=t.Script,e.Style=t.Style,e.Tag=t.Tag,e.CDATA=t.CDATA,e.Doctype=t.Doctype})),uo=t((e=>{var t=e&&e.__extends||(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Class extends value `+String(n)+` is not a constructor or null`);e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),n=e&&e.__assign||function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0?this.children[this.children.length-1]:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"childNodes",{get:function(){return this.children},set:function(e){this.children=e},enumerable:!1,configurable:!0}),n}(i);e.NodeWithChildren=l;var u=function(e){t(n,e);function n(){var t=e!==null&&e.apply(this,arguments)||this;return t.type=r.ElementType.CDATA,t}return Object.defineProperty(n.prototype,"nodeType",{get:function(){return 4},enumerable:!1,configurable:!0}),n}(l);e.CDATA=u;var d=function(e){t(n,e);function n(){var t=e!==null&&e.apply(this,arguments)||this;return t.type=r.ElementType.Root,t}return Object.defineProperty(n.prototype,"nodeType",{get:function(){return 9},enumerable:!1,configurable:!0}),n}(l);e.Document=d;var f=function(e){t(n,e);function n(t,n,i,a){i===void 0&&(i=[]),a===void 0&&(a=t===`script`?r.ElementType.Script:t===`style`?r.ElementType.Style:r.ElementType.Tag);var o=e.call(this,i)||this;return o.name=t,o.attribs=n,o.type=a,o}return Object.defineProperty(n.prototype,"nodeType",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"tagName",{get:function(){return this.name},set:function(e){this.name=e},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"attributes",{get:function(){var e=this;return Object.keys(this.attribs).map(function(t){return{name:t,value:e.attribs[t],namespace:e[`x-attribsNamespace`]?.[t],prefix:e[`x-attribsPrefix`]?.[t]}})},enumerable:!1,configurable:!0}),n}(l);e.Element=f;function p(e){return(0,r.isTag)(e)}e.isTag=p;function m(e){return e.type===r.ElementType.CDATA}e.isCDATA=m;function h(e){return e.type===r.ElementType.Text}e.isText=h;function g(e){return e.type===r.ElementType.Comment}e.isComment=g;function _(e){return e.type===r.ElementType.Directive}e.isDirective=_;function v(e){return e.type===r.ElementType.Root}e.isDocument=v;function y(e){return Object.prototype.hasOwnProperty.call(e,`children`)}e.hasChildren=y;function b(e,t){t===void 0&&(t=!1);var r;if(h(e))r=new o(e.data);else if(g(e))r=new s(e.data);else if(p(e)){var i=t?x(e.children):[],a=new f(e.name,n({},e.attribs),i);i.forEach(function(e){return e.parent=a}),e.namespace!=null&&(a.namespace=e.namespace),e[`x-attribsNamespace`]&&(a[`x-attribsNamespace`]=n({},e[`x-attribsNamespace`])),e[`x-attribsPrefix`]&&(a[`x-attribsPrefix`]=n({},e[`x-attribsPrefix`])),r=a}else if(m(e)){var i=t?x(e.children):[],l=new u(i);i.forEach(function(e){return e.parent=l}),r=l}else if(v(e)){var i=t?x(e.children):[],y=new d(i);i.forEach(function(e){return e.parent=y}),e[`x-mode`]&&(y[`x-mode`]=e[`x-mode`]),r=y}else if(_(e)){var b=new c(e.name,e.data);e[`x-name`]!=null&&(b[`x-name`]=e[`x-name`],b[`x-publicId`]=e[`x-publicId`],b[`x-systemId`]=e[`x-systemId`]),r=b}else throw Error(`Not implemented yet: ${e.type}`);return r.startIndex=e.startIndex,r.endIndex=e.endIndex,e.sourceCodeLocation!=null&&(r.sourceCodeLocation=e.sourceCodeLocation),r}e.cloneNode=b;function x(e){for(var t=e.map(function(e){return b(e,!0)}),n=1;n{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.DomHandler=void 0;var r=lo(),i=uo();n(uo(),e);var a={withStartIndices:!1,withEndIndices:!1,xmlMode:!1},o=function(){function e(e,t,n){this.dom=[],this.root=new i.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,typeof t==`function`&&(n=t,t=a),typeof e==`object`&&(t=e,e=void 0),this.callback=e??null,this.options=t??a,this.elementCB=n??null}return e.prototype.onparserinit=function(e){this.parser=e},e.prototype.onreset=function(){this.dom=[],this.root=new i.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null},e.prototype.onend=function(){this.done||(this.done=!0,this.parser=null,this.handleCallback(null))},e.prototype.onerror=function(e){this.handleCallback(e)},e.prototype.onclosetag=function(){this.lastNode=null;var e=this.tagStack.pop();this.options.withEndIndices&&(e.endIndex=this.parser.endIndex),this.elementCB&&this.elementCB(e)},e.prototype.onopentag=function(e,t){var n=this.options.xmlMode?r.ElementType.Tag:void 0,a=new i.Element(e,t,void 0,n);this.addNode(a),this.tagStack.push(a)},e.prototype.ontext=function(e){var t=this.lastNode;if(t&&t.type===r.ElementType.Text)t.data+=e,this.options.withEndIndices&&(t.endIndex=this.parser.endIndex);else{var n=new i.Text(e);this.addNode(n),this.lastNode=n}},e.prototype.oncomment=function(e){if(this.lastNode&&this.lastNode.type===r.ElementType.Comment){this.lastNode.data+=e;return}var t=new i.Comment(e);this.addNode(t),this.lastNode=t},e.prototype.oncommentend=function(){this.lastNode=null},e.prototype.oncdatastart=function(){var e=new i.Text(``),t=new i.CDATA([e]);this.addNode(t),e.parent=t,this.lastNode=e},e.prototype.oncdataend=function(){this.lastNode=null},e.prototype.onprocessinginstruction=function(e,t){var n=new i.ProcessingInstruction(e,t);this.addNode(n)},e.prototype.handleCallback=function(e){if(typeof this.callback==`function`)this.callback(e,this.dom);else if(e)throw e},e.prototype.addNode=function(e){var t=this.tagStack[this.tagStack.length-1],n=t.children[t.children.length-1];this.options.withStartIndices&&(e.startIndex=this.parser.startIndex),this.options.withEndIndices&&(e.endIndex=this.parser.endIndex),t.children.push(e),n&&(e.prev=n,n.next=e),e.parent=t,this.lastNode=null},e}();e.DomHandler=o,e.default=o})),po=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CARRIAGE_RETURN_PLACEHOLDER_REGEX=e.CARRIAGE_RETURN_PLACEHOLDER=e.CARRIAGE_RETURN_REGEX=e.CARRIAGE_RETURN=e.CASE_SENSITIVE_TAG_NAMES_MAP=e.CASE_SENSITIVE_TAG_NAMES=void 0,e.CASE_SENSITIVE_TAG_NAMES=`animateMotion.animateTransform.clipPath.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feDropShadow.feFlood.feFuncA.feFuncB.feFuncG.feFuncR.feGaussianBlur.feImage.feMerge.feMergeNode.feMorphology.feOffset.fePointLight.feSpecularLighting.feSpotLight.feTile.feTurbulence.foreignObject.linearGradient.radialGradient.textPath`.split(`.`),e.CASE_SENSITIVE_TAG_NAMES_MAP=e.CASE_SENSITIVE_TAG_NAMES.reduce(function(e,t){return e[t.toLowerCase()]=t,e},{}),e.CARRIAGE_RETURN=`\r`,e.CARRIAGE_RETURN_REGEX=new RegExp(e.CARRIAGE_RETURN,`g`),e.CARRIAGE_RETURN_PLACEHOLDER=`__HTML_DOM_PARSER_CARRIAGE_RETURN_PLACEHOLDER_${Date.now().toString()}__`,e.CARRIAGE_RETURN_PLACEHOLDER_REGEX=new RegExp(e.CARRIAGE_RETURN_PLACEHOLDER,`g`)})),mo=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatAttributes=i,e.hasOpenTag=o,e.escapeSpecialCharacters=s,e.revertEscapedCharacters=c,e.formatDOM=l;var t=fo(),n=po();function r(e){return n.CASE_SENSITIVE_TAG_NAMES_MAP[e]}function i(e){for(var t={},n=0,r=e.length;n`||i===` `||i===` `||i===` `||i===`\r`||i===`/`}function s(e){return e.replace(n.CARRIAGE_RETURN_REGEX,n.CARRIAGE_RETURN_PLACEHOLDER)}function c(e){return e.replace(n.CARRIAGE_RETURN_PLACEHOLDER_REGEX,n.CARRIAGE_RETURN)}function l(e,n,r){n===void 0&&(n=null);for(var o=[],s,u=0,d=e.length;u{Object.defineProperty(e,"__esModule",{value:!0}),e.default=h;var t=mo(),n=`html`,r=`head`,i=`body`,a=/<([a-zA-Z]+[0-9]?)/,o=function(e,t){throw Error("This browser does not support `document.implementation.createHTMLDocument`")},s=function(e,t){throw Error("This browser does not support `DOMParser.prototype.parseFromString`")},c=typeof window==`object`&&window.DOMParser;if(typeof c==`function`){var l=new c,u=`text/html`;s=function(e,t){return t&&(e=`<${t}>${e}`),l.parseFromString(e,u)},o=s}if(typeof document==`object`&&document.implementation){var d=document.implementation.createHTMLDocument();o=function(e,t){if(t){var n=d.documentElement.querySelector(t);return n&&(n.innerHTML=e),d}return d.documentElement.innerHTML=e,d}}var f=typeof document==`object`&&document.createElement(`template`),p;f&&f.content&&(p=function(e){return f.innerHTML=e,f.content.childNodes});var m=function(){return document.createDocumentFragment().childNodes};function h(e){var c,l;e=(0,t.escapeSpecialCharacters)(e);var u=(a.exec(e)?.[1])?.toLowerCase();switch(u){case n:var d=s(e);if(!(0,t.hasOpenTag)(e,r)){var f=d.querySelector(r);(c=f?.parentNode)==null||c.removeChild(f)}if(!(0,t.hasOpenTag)(e,i)){var f=d.querySelector(i);(l=f?.parentNode)==null||l.removeChild(f)}return d.querySelectorAll(n);case r:case i:var h=o(e).querySelectorAll(u);return(0,t.hasOpenTag)(e,i)&&(0,t.hasOpenTag)(e,r)?h[0].parentNode?.childNodes??m():h;default:if(p)return p(e);var f=o(e,i).querySelector(i);return f?.childNodes??m()}}})),go=t((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=a;var n=t(ho()),r=mo(),i=/<(![a-zA-Z\s]+)>/;function a(e){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];var t=i.exec(e),a=t?t[1]:void 0;return(0,r.formatDOM)((0,n.default)(e),null,a)}})),_o=t((e=>{e.SAME=0,e.CAMELCASE=1,e.possibleStandardNames={accept:0,acceptCharset:1,"accept-charset":`acceptCharset`,accessKey:1,action:0,allowFullScreen:1,alt:0,as:0,async:0,autoCapitalize:1,autoComplete:1,autoCorrect:1,autoFocus:1,autoPlay:1,autoSave:1,capture:0,cellPadding:1,cellSpacing:1,challenge:0,charSet:1,checked:0,children:0,cite:0,class:`className`,classID:1,className:1,cols:0,colSpan:1,content:0,contentEditable:1,contextMenu:1,controls:0,controlsList:1,coords:0,crossOrigin:1,dangerouslySetInnerHTML:1,data:0,dateTime:1,default:0,defaultChecked:1,defaultValue:1,defer:0,dir:0,disabled:0,disablePictureInPicture:1,disableRemotePlayback:1,download:0,draggable:0,encType:1,enterKeyHint:1,for:`htmlFor`,form:0,formMethod:1,formAction:1,formEncType:1,formNoValidate:1,formTarget:1,frameBorder:1,headers:0,height:0,hidden:0,high:0,href:0,hrefLang:1,htmlFor:1,httpEquiv:1,"http-equiv":`httpEquiv`,icon:0,id:0,innerHTML:1,inputMode:1,integrity:0,is:0,itemID:1,itemProp:1,itemRef:1,itemScope:1,itemType:1,keyParams:1,keyType:1,kind:0,label:0,lang:0,list:0,loop:0,low:0,manifest:0,marginWidth:1,marginHeight:1,max:0,maxLength:1,media:0,mediaGroup:1,method:0,min:0,minLength:1,multiple:0,muted:0,name:0,noModule:1,nonce:0,noValidate:1,open:0,optimum:0,pattern:0,placeholder:0,playsInline:1,poster:0,preload:0,profile:0,radioGroup:1,readOnly:1,referrerPolicy:1,rel:0,required:0,reversed:0,role:0,rows:0,rowSpan:1,sandbox:0,scope:0,scoped:0,scrolling:0,seamless:0,selected:0,shape:0,size:0,sizes:0,span:0,spellCheck:1,src:0,srcDoc:1,srcLang:1,srcSet:1,start:0,step:0,style:0,summary:0,tabIndex:1,target:0,title:0,type:0,useMap:1,value:0,width:0,wmode:0,wrap:0,about:0,accentHeight:1,"accent-height":`accentHeight`,accumulate:0,additive:0,alignmentBaseline:1,"alignment-baseline":`alignmentBaseline`,allowReorder:1,alphabetic:0,amplitude:0,arabicForm:1,"arabic-form":`arabicForm`,ascent:0,attributeName:1,attributeType:1,autoReverse:1,azimuth:0,baseFrequency:1,baselineShift:1,"baseline-shift":`baselineShift`,baseProfile:1,bbox:0,begin:0,bias:0,by:0,calcMode:1,capHeight:1,"cap-height":`capHeight`,clip:0,clipPath:1,"clip-path":`clipPath`,clipPathUnits:1,clipRule:1,"clip-rule":`clipRule`,color:0,colorInterpolation:1,"color-interpolation":`colorInterpolation`,colorInterpolationFilters:1,"color-interpolation-filters":`colorInterpolationFilters`,colorProfile:1,"color-profile":`colorProfile`,colorRendering:1,"color-rendering":`colorRendering`,contentScriptType:1,contentStyleType:1,cursor:0,cx:0,cy:0,d:0,datatype:0,decelerate:0,descent:0,diffuseConstant:1,direction:0,display:0,divisor:0,dominantBaseline:1,"dominant-baseline":`dominantBaseline`,dur:0,dx:0,dy:0,edgeMode:1,elevation:0,enableBackground:1,"enable-background":`enableBackground`,end:0,exponent:0,externalResourcesRequired:1,fill:0,fillOpacity:1,"fill-opacity":`fillOpacity`,fillRule:1,"fill-rule":`fillRule`,filter:0,filterRes:1,filterUnits:1,floodOpacity:1,"flood-opacity":`floodOpacity`,floodColor:1,"flood-color":`floodColor`,focusable:0,fontFamily:1,"font-family":`fontFamily`,fontSize:1,"font-size":`fontSize`,fontSizeAdjust:1,"font-size-adjust":`fontSizeAdjust`,fontStretch:1,"font-stretch":`fontStretch`,fontStyle:1,"font-style":`fontStyle`,fontVariant:1,"font-variant":`fontVariant`,fontWeight:1,"font-weight":`fontWeight`,format:0,from:0,fx:0,fy:0,g1:0,g2:0,glyphName:1,"glyph-name":`glyphName`,glyphOrientationHorizontal:1,"glyph-orientation-horizontal":`glyphOrientationHorizontal`,glyphOrientationVertical:1,"glyph-orientation-vertical":`glyphOrientationVertical`,glyphRef:1,gradientTransform:1,gradientUnits:1,hanging:0,horizAdvX:1,"horiz-adv-x":`horizAdvX`,horizOriginX:1,"horiz-origin-x":`horizOriginX`,ideographic:0,imageRendering:1,"image-rendering":`imageRendering`,in2:0,in:0,inlist:0,intercept:0,k1:0,k2:0,k3:0,k4:0,k:0,kernelMatrix:1,kernelUnitLength:1,kerning:0,keyPoints:1,keySplines:1,keyTimes:1,lengthAdjust:1,letterSpacing:1,"letter-spacing":`letterSpacing`,lightingColor:1,"lighting-color":`lightingColor`,limitingConeAngle:1,local:0,markerEnd:1,"marker-end":`markerEnd`,markerHeight:1,markerMid:1,"marker-mid":`markerMid`,markerStart:1,"marker-start":`markerStart`,markerUnits:1,markerWidth:1,mask:0,maskContentUnits:1,maskUnits:1,mathematical:0,mode:0,numOctaves:1,offset:0,opacity:0,operator:0,order:0,orient:0,orientation:0,origin:0,overflow:0,overlinePosition:1,"overline-position":`overlinePosition`,overlineThickness:1,"overline-thickness":`overlineThickness`,paintOrder:1,"paint-order":`paintOrder`,panose1:0,"panose-1":`panose1`,pathLength:1,patternContentUnits:1,patternTransform:1,patternUnits:1,pointerEvents:1,"pointer-events":`pointerEvents`,points:0,pointsAtX:1,pointsAtY:1,pointsAtZ:1,prefix:0,preserveAlpha:1,preserveAspectRatio:1,primitiveUnits:1,property:0,r:0,radius:0,refX:1,refY:1,renderingIntent:1,"rendering-intent":`renderingIntent`,repeatCount:1,repeatDur:1,requiredExtensions:1,requiredFeatures:1,resource:0,restart:0,result:0,results:0,rotate:0,rx:0,ry:0,scale:0,security:0,seed:0,shapeRendering:1,"shape-rendering":`shapeRendering`,slope:0,spacing:0,specularConstant:1,specularExponent:1,speed:0,spreadMethod:1,startOffset:1,stdDeviation:1,stemh:0,stemv:0,stitchTiles:1,stopColor:1,"stop-color":`stopColor`,stopOpacity:1,"stop-opacity":`stopOpacity`,strikethroughPosition:1,"strikethrough-position":`strikethroughPosition`,strikethroughThickness:1,"strikethrough-thickness":`strikethroughThickness`,string:0,stroke:0,strokeDasharray:1,"stroke-dasharray":`strokeDasharray`,strokeDashoffset:1,"stroke-dashoffset":`strokeDashoffset`,strokeLinecap:1,"stroke-linecap":`strokeLinecap`,strokeLinejoin:1,"stroke-linejoin":`strokeLinejoin`,strokeMiterlimit:1,"stroke-miterlimit":`strokeMiterlimit`,strokeWidth:1,"stroke-width":`strokeWidth`,strokeOpacity:1,"stroke-opacity":`strokeOpacity`,suppressContentEditableWarning:1,suppressHydrationWarning:1,surfaceScale:1,systemLanguage:1,tableValues:1,targetX:1,targetY:1,textAnchor:1,"text-anchor":`textAnchor`,textDecoration:1,"text-decoration":`textDecoration`,textLength:1,textRendering:1,"text-rendering":`textRendering`,to:0,transform:0,typeof:0,u1:0,u2:0,underlinePosition:1,"underline-position":`underlinePosition`,underlineThickness:1,"underline-thickness":`underlineThickness`,unicode:0,unicodeBidi:1,"unicode-bidi":`unicodeBidi`,unicodeRange:1,"unicode-range":`unicodeRange`,unitsPerEm:1,"units-per-em":`unitsPerEm`,unselectable:0,vAlphabetic:1,"v-alphabetic":`vAlphabetic`,values:0,vectorEffect:1,"vector-effect":`vectorEffect`,version:0,vertAdvY:1,"vert-adv-y":`vertAdvY`,vertOriginX:1,"vert-origin-x":`vertOriginX`,vertOriginY:1,"vert-origin-y":`vertOriginY`,vHanging:1,"v-hanging":`vHanging`,vIdeographic:1,"v-ideographic":`vIdeographic`,viewBox:1,viewTarget:1,visibility:0,vMathematical:1,"v-mathematical":`vMathematical`,vocab:0,widths:0,wordSpacing:1,"word-spacing":`wordSpacing`,writingMode:1,"writing-mode":`writingMode`,x1:0,x2:0,x:0,xChannelSelector:1,xHeight:1,"x-height":`xHeight`,xlinkActuate:1,"xlink:actuate":`xlinkActuate`,xlinkArcrole:1,"xlink:arcrole":`xlinkArcrole`,xlinkHref:1,"xlink:href":`xlinkHref`,xlinkRole:1,"xlink:role":`xlinkRole`,xlinkShow:1,"xlink:show":`xlinkShow`,xlinkTitle:1,"xlink:title":`xlinkTitle`,xlinkType:1,"xlink:type":`xlinkType`,xmlBase:1,"xml:base":`xmlBase`,xmlLang:1,"xml:lang":`xmlLang`,xmlns:0,"xml:space":`xmlSpace`,xmlnsXlink:1,"xmlns:xlink":`xmlnsXlink`,xmlSpace:1,y1:0,y2:0,y:0,yChannelSelector:1,z:0,zoomAndPan:1}})),vo=t((e=>{var t=0,n=1,r=2,i=3,a=4,o=5,s=6;function c(e){return u.hasOwnProperty(e)?u[e]:null}function l(e,t,n,o,s,c,l){this.acceptsBooleans=t===r||t===i||t===a,this.attributeName=o,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=c,this.removeEmptyString=l}var u={};[`children`,`dangerouslySetInnerHTML`,`defaultValue`,`defaultChecked`,`innerHTML`,`suppressContentEditableWarning`,`suppressHydrationWarning`,`style`].forEach(e=>{u[e]=new l(e,t,!1,e,null,!1,!1)}),[[`acceptCharset`,`accept-charset`],[`className`,`class`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`]].forEach(([e,t])=>{u[e]=new l(e,n,!1,t,null,!1,!1)}),[`contentEditable`,`draggable`,`spellCheck`,`value`].forEach(e=>{u[e]=new l(e,r,!1,e.toLowerCase(),null,!1,!1)}),[`autoReverse`,`externalResourcesRequired`,`focusable`,`preserveAlpha`].forEach(e=>{u[e]=new l(e,r,!1,e,null,!1,!1)}),[`allowFullScreen`,`async`,`autoFocus`,`autoPlay`,`controls`,`default`,`defer`,`disabled`,`disablePictureInPicture`,`disableRemotePlayback`,`formNoValidate`,`hidden`,`loop`,`noModule`,`noValidate`,`open`,`playsInline`,`readOnly`,`required`,`reversed`,`scoped`,`seamless`,`itemScope`].forEach(e=>{u[e]=new l(e,i,!1,e.toLowerCase(),null,!1,!1)}),[`checked`,`multiple`,`muted`,`selected`].forEach(e=>{u[e]=new l(e,i,!0,e,null,!1,!1)}),[`capture`,`download`].forEach(e=>{u[e]=new l(e,a,!1,e,null,!1,!1)}),[`cols`,`rows`,`size`,`span`].forEach(e=>{u[e]=new l(e,s,!1,e,null,!1,!1)}),[`rowSpan`,`start`].forEach(e=>{u[e]=new l(e,o,!1,e.toLowerCase(),null,!1,!1)});var d=/[\-\:]([a-z])/g,f=e=>e[1].toUpperCase();`accent-height.alignment-baseline.arabic-form.baseline-shift.cap-height.clip-path.clip-rule.color-interpolation.color-interpolation-filters.color-profile.color-rendering.dominant-baseline.enable-background.fill-opacity.fill-rule.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.glyph-name.glyph-orientation-horizontal.glyph-orientation-vertical.horiz-adv-x.horiz-origin-x.image-rendering.letter-spacing.lighting-color.marker-end.marker-mid.marker-start.overline-position.overline-thickness.paint-order.panose-1.pointer-events.rendering-intent.shape-rendering.stop-color.stop-opacity.strikethrough-position.strikethrough-thickness.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke-width.text-anchor.text-decoration.text-rendering.underline-position.underline-thickness.unicode-bidi.unicode-range.units-per-em.v-alphabetic.v-hanging.v-ideographic.v-mathematical.vector-effect.vert-adv-y.vert-origin-x.vert-origin-y.word-spacing.writing-mode.xmlns:xlink.x-height`.split(`.`).forEach(e=>{let t=e.replace(d,f);u[t]=new l(t,n,!1,e,null,!1,!1)}),[`xlink:actuate`,`xlink:arcrole`,`xlink:role`,`xlink:show`,`xlink:title`,`xlink:type`].forEach(e=>{let t=e.replace(d,f);u[t]=new l(t,n,!1,e,`http://www.w3.org/1999/xlink`,!1,!1)}),[`xml:base`,`xml:lang`,`xml:space`].forEach(e=>{let t=e.replace(d,f);u[t]=new l(t,n,!1,e,`http://www.w3.org/XML/1998/namespace`,!1,!1)}),[`tabIndex`,`crossOrigin`].forEach(e=>{u[e]=new l(e,n,!1,e.toLowerCase(),null,!1,!1)});var p=`xlinkHref`;u[p]=new l(`xlinkHref`,n,!1,`xlink:href`,`http://www.w3.org/1999/xlink`,!0,!1),[`src`,`href`,`action`,`formAction`].forEach(e=>{u[e]=new l(e,n,!1,e.toLowerCase(),null,!0,!0)});var{CAMELCASE:m,SAME:h,possibleStandardNames:g}=_o(),_=RegExp.prototype.test.bind(RegExp(`^(data|aria)-[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`)),v=Object.keys(g).reduce((e,t)=>{let n=g[t];return n===h?e[t]=t:n===m?e[t.toLowerCase()]=t:e[t]=n,e},{});e.BOOLEAN=i,e.BOOLEANISH_STRING=r,e.NUMERIC=o,e.OVERLOADED_BOOLEAN=a,e.POSITIVE_NUMERIC=s,e.RESERVED=t,e.STRING=n,e.getPropertyInfo=c,e.isCustomAttribute=_,e.possibleStandardNames=v})),yo=t(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=`/`,d=`*`,f=``;function p(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,p=1;function h(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(` `);p=~n?e.length-n:p+e.length}function g(){var e={line:l,column:p};return function(t){return t.position=new _(e),b(),t}}function _(e){this.start=e,this.end={line:l,column:p},this.source=t.source}_.prototype.content=e;function v(n){var r=Error(t.source+`:`+l+`:`+p+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=p,r.source=e,!t.silent)throw r}function y(t){var n=t.exec(e);if(n){var r=n[0];return h(r),e=e.slice(r.length),n}}function b(){y(i)}function x(e){var t;for(e||=[];t=S();)t!==!1&&e.push(t);return e}function S(){var t=g();if(!(u!=e.charAt(0)||d!=e.charAt(1))){for(var n=2;f!=e.charAt(n)&&(d!=e.charAt(n)||u!=e.charAt(n+1));)++n;if(n+=2,f===e.charAt(n-1))return v(`End of comment missing`);var r=e.slice(2,n-2);return p+=2,h(r),e=e.slice(n),p+=2,t({type:`comment`,comment:r})}}function C(){var e=g(),t=y(a);if(t){if(S(),!y(o))return v(`property missing ':'`);var r=y(s),i=e({type:`declaration`,property:m(t[0].replace(n,f)),value:r?m(r[0].replace(n,f)):f});return y(c),i}}function w(){var e=[];x(e);for(var t;t=C();)t!==!1&&(e.push(t),x(e));return e}return b(),w()}function m(e){return e?e.replace(l,f):f}t.exports=p})),bo=t((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(yo());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),xo=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),So=t(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(bo()),r=xo();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),Co=t((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.returnFirstArg=e.canTextBeChildOfNode=e.ELEMENTS_WITH_NO_TEXT_CHILDREN=e.PRESERVE_CUSTOM_ATTRIBUTES=void 0,e.isCustomComponent=a,e.setStyleProp=c;var n=s(),r=t(So()),i=new Set([`annotation-xml`,`color-profile`,`font-face`,`font-face-src`,`font-face-uri`,`font-face-format`,`font-face-name`,`missing-glyph`]);function a(e,t){return e.includes(`-`)?!i.has(e):!!(t&&typeof t.is==`string`)}var o={reactCompat:!0};function c(e,t){if(typeof e==`string`){if(!e.trim()){t.style={};return}try{t.style=(0,r.default)(e,o)}catch{t.style={}}}}e.PRESERVE_CUSTOM_ATTRIBUTES=Number(n.version.split(`.`)[0])>=16,e.ELEMENTS_WITH_NO_TEXT_CHILDREN=new Set([`tr`,`tbody`,`thead`,`tfoot`,`colgroup`,`table`,`head`,`html`,`frameset`]),e.canTextBeChildOfNode=function(t){return!e.ELEMENTS_WITH_NO_TEXT_CHILDREN.has(t.name)},e.returnFirstArg=function(e){return e}})),wo=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=o;var t=vo(),n=Co(),r=[`checked`,`value`],i=[`input`,`select`,`textarea`],a={reset:!0,submit:!0};function o(e,o){e===void 0&&(e={});var c={},l=!!(e.type&&a[e.type]);for(var u in e){var d=e[u];if((0,t.isCustomAttribute)(u)){c[u]=d;continue}var f=u.toLowerCase(),p=s(f);if(p){var m=(0,t.getPropertyInfo)(p);switch(r.includes(p)&&i.includes(o)&&!l&&(p=s(`default`+f)),c[p]=d,m?.type){case t.BOOLEAN:c[p]=!0;break;case t.OVERLOADED_BOOLEAN:d===``&&(c[p]=!0);break}continue}n.PRESERVE_CUSTOM_ATTRIBUTES&&(c[u]=d)}return(0,n.setStyleProp)(e.style,c),c}function s(e){return t.possibleStandardNames[e]}})),To=t((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=o;var n=s(),r=t(wo()),i=Co(),a={cloneElement:n.cloneElement,createElement:n.createElement,isValidElement:n.isValidElement};function o(e,t){t===void 0&&(t={});for(var n=[],s=typeof t.replace==`function`,l=t.transform??i.returnFirstArg,u=t.library??a,d=u.cloneElement,f=u.createElement,p=u.isValidElement,m=e.length,h=0;h1&&(_=d(_,{key:_.key??h})),n.push(l(_,g,h));continue}}if(g.type===`text`){var v=!g.data.trim().length;if(v&&g.parent&&!(0,i.canTextBeChildOfNode)(g.parent)||t.trim&&v)continue;n.push(l(g.data,g,h));continue}var y=g,b={};c(y)?((0,i.setStyleProp)(y.attribs.style,y.attribs),b=y.attribs):y.attribs&&(b=(0,r.default)(y.attribs,y.name));var x=void 0;switch(g.type){case`script`:case`style`:g.children[0]&&(b.dangerouslySetInnerHTML={__html:g.children[0].data});break;case`tag`:g.name===`textarea`&&g.children[0]?b.defaultValue=g.children[0].data:g.children?.length&&(x=o(g.children,t));break;default:continue}m>1&&(b.key=h),n.push(l(f(g.name,b,x),g,h))}return n.length===1?n[0]:n}function c(e){return i.PRESERVE_CUSTOM_ATTRIBUTES&&e.type===`tag`&&(0,i.isCustomComponent)(e.name,e.attribs)}})),Eo=r(t((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.htmlToDOM=e.domToReact=e.attributesToProps=e.Text=e.ProcessingInstruction=e.Element=e.Comment=void 0,e.default=o;var n=t(go());e.htmlToDOM=n.default,e.attributesToProps=t(wo()).default;var r=t(To());e.domToReact=r.default;var i=fo();Object.defineProperty(e,"Comment",{enumerable:!0,get:function(){return i.Comment}}),Object.defineProperty(e,"Element",{enumerable:!0,get:function(){return i.Element}}),Object.defineProperty(e,"ProcessingInstruction",{enumerable:!0,get:function(){return i.ProcessingInstruction}}),Object.defineProperty(e,"Text",{enumerable:!0,get:function(){return i.Text}});var a={lowerCaseAttributeNames:!1};function o(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);return e?(0,r.default)((0,n.default)(e,t?.htmlparser2??a),t):[]}}))(),1),Do=Eo.default.default||Eo.default,Oo=z.memo(e=>{let{text:t,animationConfig:n}=e,{fadeDuration:r=200,easing:i=`ease-in-out`}=n||{},[a,o]=(0,z.useState)([]),s=(0,z.useRef)(``);(0,z.useEffect)(()=>{if(t===s.current)return;if(!(s.current&&t.indexOf(s.current)===0)){o([t]),s.current=t;return}let e=t.slice(s.current.length);e&&(o(t=>[...t,e]),s.current=t)},[t]);let c=(0,z.useMemo)(()=>({animation:`x-markdown-fade-in ${r}ms ${i} forwards`,color:`inherit`}),[r,i]);return z.createElement(z.Fragment,null,a.map((e,t)=>z.createElement(`span`,{style:c,key:`animation-text-${t}`},e)))}),ko=/\s/,Ao=/[a-zA-Z0-9-]/,jo=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),Mo=``,Po=``,Io=(e,t)=>`${e}-${t}`,Lo=(e,t)=>{if(!e.startsWith(Mo,t))return t;let n=e.indexOf(No,t+4);return n===-1?e.length:n+3},Ro=(e,t)=>{if(!e.startsWith(Po,t))return t;let n=e.indexOf(Fo,t+9);return n===-1?e.length:n+3},zo=(e,t)=>{if(e[t+1]!==`/`)return null;let n=t+2,r=``;for(;n`?null:{tagName:r.toLowerCase(),endPos:n+1}},Bo=(e,t)=>{let n=t+1,r=``;for(;n`){i=!0,a=e[n-1]===`/`;break}if(e[n]===`"`||e[n]===`'`){let t=e[n];for(n++;ne.toLowerCase()));if(n.size===0||e.length===0)return new Set;let r=new Set,i={},a={},o=0;for(;o{r.add(Io(e,t))});return r}var Ho=null;function Uo(){if(Ho)return Ho;if(typeof window<`u`&&typeof Node<`u`)try{let e=document.createElement(`template`);e.innerHTML=``;let t=e.content.firstChild;if(t){let n=Object.getOwnPropertyDescriptor(Node.prototype,`nodeName`)?.get,r=Object.getOwnPropertyDescriptor(Node.prototype,`nodeValue`)?.get,i=n&&t.nodeName&&!n.call(t);if(i){let e=n;Object.defineProperty(Node.prototype,"nodeName",{get:function(){let t=e.call(this);if(t)return t;if(this.nodeType===1&&`tagName`in this)return this.tagName;switch(this.nodeType){case 3:return`#text`;case 4:return`#cdata-section`;case 7:return`#processing-instruction`;case 8:return`#comment`;case 9:return`#document`;case 11:return`#document-fragment`}return t},configurable:!0,enumerable:!0})}let a=r&&(()=>{e.innerHTML=`
    test
    `;let t=e.content.firstChild?.firstChild;if(!t)return!1;let n=r.call(t);return t.nodeValue!=null&&n==null})();if(a){let e=r;Object.defineProperty(Node.prototype,"nodeValue",{get:function(){let t=e.call(this);return t==null&&(this.nodeType===3||this.nodeType===4||this.nodeType===8)&&`data`in this?this.data:t},configurable:!0,enumerable:!0})}if(i||a)return Ho=co(window),Ho}}catch{}return Ho=co,Ho}var Wo=class e{options;static NON_WHITESPACE_REGEX=/[^\r\n\s]+/;constructor(e){this.options=e}detectUnclosedTags(e){return Vo(e,Object.keys(this.options.components??{}))}configureDOMPurify(){let e=Object.keys(this.options.components||{}),t=this.options.dompurifyConfig||{},n=Array.isArray(t.ADD_TAGS)?t.ADD_TAGS:[],r=Array.isArray(t.ADD_ATTR)?t.ADD_ATTR:[];return{...t,ADD_TAGS:Array.from(new Set([...e,...n])),ADD_ATTR:Array.from(new Set([`target`,`rel`,...r]))}}createReplaceElement(t,n){let{enableAnimation:r,animationConfig:i}=this.options.streaming||{};return a=>{let o=`x-markdown-component-${n.current++}`,s=a.type===`text`&&a.data&&e.NON_WHITESPACE_REGEX.test(a.data),c=a.parent?.name,l=c&&this.options.components?.[c];if(r&&s&&!l)return z.createElement(Oo,{text:a.data,key:o,animationConfig:i});if(!(`name`in a))return;let{name:u,attribs:d,children:f}=a,p=this.options.components?.[u];if(p){n.tagIndexes[u]=(n.tagIndexes[u]??0)+1;let e={domNode:a,streamStatus:t?.has(Io(u,n.tagIndexes[u]))?`loading`:`done`,key:o,...d,...d.disabled!==void 0&&{disabled:!0},...d.checked!==void 0&&{checked:!0}};if(e.className=[e.className,e.classname,e.class].filter(Boolean).join(` `).trim()||``,u===`code`){let{"data-block":t=`false`,"data-state":n=`done`}=d||{};e.block=t===`true`,e.streamStatus=n===`loading`?`loading`:`done`;let r=d?.[`data-lang`],i=d?.class?.match(/(?:^|\s)language-([^\s]+)/)?.[1]??d?.class?.match(/(?:^|\s)lang-([^\s]+)/)?.[1],a=r||i;a&&(e.lang=a)}return f&&(e.children=this.processChildren(f,t,n)),z.createElement(p,e)}}}processChildren(e,t,n){return(0,Eo.domToReact)(e,{replace:this.createReplaceElement(t,n)})}processHtml(e){if(typeof co.sanitize!=`function`)return null;let t=this.detectUnclosedTags(e),n={current:0,tagIndexes:{}},r=Uo(),i=this.configureDOMPurify();return Do(r.sanitize(e,i),{replace:this.createReplaceElement(t,n)})}render(e){return this.processHtml(e)}},Go={FPS_THRESHOLD:{GOOD:55,WARNING:40},COLORS:{GOOD:`#52c41a`,WARNING:`#faad14`,DANGER:`#ff4d4f`},CHART:{WIDTH:750,HEIGHT:400,PADDING:80}},Ko=()=>typeof window>`u`?{x:12,y:12}:{x:window.innerWidth-220,y:window.innerHeight/2-100},qo=()=>{let[e,t]=(0,z.useState)(0),[n,r]=(0,z.useState)(0),[i,a]=(0,z.useState)(!1),[o,s]=(0,z.useState)(!1),[c,l]=(0,z.useState)([]),[u,d]=(0,z.useState)(Ko()),[f,p]=(0,z.useState)(!1),m=(0,z.useRef)([]),h=(0,z.useRef)([]),g=(0,z.useRef)(0),_=(0,z.useRef)(0),v=(0,z.useRef)(void 0),y=(0,z.useRef)({isDragging:!1,startX:0,startY:0,initialX:0,initialY:0});(0,z.useEffect)(()=>{if(typeof window>`u`)return;f||(p(!0),g.current=performance.now());let e=()=>{let n=performance.now(),a=n-g.current;if(h.current.push(a),h.current.length>60&&h.current.shift(),_.current++,a>=1e3){let e=Math.round(_.current*1e3/a),o=b();t(e),r(o),i&&m.current.push({timestamp:Date.now(),fps:e,memory:o}),_.current=0,g.current=n}v.current=requestAnimationFrame(e)};return v.current=requestAnimationFrame(e),()=>{v.current!==void 0&&cancelAnimationFrame(v.current)}},[i,f]);let b=()=>{let e=performance;return e.memory?Math.round(e.memory.usedJSHeapSize/1024/1024):0},x=e=>e<1?`${Math.round(e*1024)} KB`:e>=1024?`${(e/1024).toFixed(2)} GB`:`${e.toFixed(2)} MB`,S=e=>e>=Go.FPS_THRESHOLD.GOOD?Go.COLORS.GOOD:e>=Go.FPS_THRESHOLD.WARNING?Go.COLORS.WARNING:Go.COLORS.DANGER,C=(0,z.useCallback)(()=>{i?(a(!1),l([...m.current]),s(!0)):(m.current=[],a(!0))},[i]),w=(0,z.useCallback)(e=>{e.target.closest(`.x-markdown-debug-action`)||(y.current={isDragging:!0,startX:e.clientX,startY:e.clientY,initialX:u.x,initialY:u.y})},[u]),T=(0,z.useCallback)(e=>{if(!y.current.isDragging)return;let t=e.clientX-y.current.startX,n=e.clientY-y.current.startY;d({x:y.current.initialX+t,y:y.current.initialY+n})},[]),E=(0,z.useCallback)(()=>{y.current.isDragging=!1},[]);return(0,z.useEffect)(()=>{if(!(typeof window>`u`))return document.addEventListener(`mousemove`,T),document.addEventListener(`mouseup`,E),()=>{document.removeEventListener(`mousemove`,T),document.removeEventListener(`mouseup`,E)}},[T,E]),z.createElement(z.Fragment,null,z.createElement(`div`,{className:`x-markdown-debug-panel`,style:{left:u.x,top:u.y,cursor:y.current.isDragging?`grabbing`:`grab`},onMouseDown:w},z.createElement(`div`,{className:`x-markdown-debug-row`},z.createElement(`span`,{className:`x-markdown-debug-label`},`FPS`),z.createElement(`span`,{className:`x-markdown-debug-value`,style:{color:S(e)}},e)),z.createElement(`div`,{className:`x-markdown-debug-row`},z.createElement(`span`,{className:`x-markdown-debug-label`},`Memory`),z.createElement(`span`,{className:`x-markdown-debug-value`},x(n))),z.createElement(`div`,{className:`x-markdown-debug-actions`},z.createElement(`button`,{type:`button`,className:`x-markdown-debug-action x-markdown-debug-record-btn ${i?`recording`:``}`,onClick:C},i?`⏹ Stop`:`⏺ Record`),c.length>0&&!i&&z.createElement(`button`,{type:`button`,className:`x-markdown-debug-action`,onClick:()=>s(!0)},`📊 View`))),o&&c.length>0?z.createElement(`div`,{className:`x-markdown-debug-modal-overlay`,onClick:()=>s(!1)},z.createElement(`div`,{className:`x-markdown-debug-modal`,onClick:e=>e.stopPropagation()},z.createElement(`div`,{className:`x-markdown-debug-modal-header`},z.createElement(`span`,{style:{color:`#fff`,fontSize:18,fontWeight:`600`}},`Performance Recording`),z.createElement(`button`,{type:`button`,className:`x-markdown-debug-close-btn`,onClick:()=>s(!1)},`✕`)),z.createElement(()=>{if(!c.length)return null;let{WIDTH:e,HEIGHT:t,PADDING:n}=Go.CHART,r=e-n*2,i=t-n*2,a=c[0]?.timestamp??0,o=(c[c.length-1]?.timestamp??0)-a||1,s=Math.max(...c.map(e=>e.fps),60),l=Math.max(...c.map(e=>e.memory),0)*1.1,u=c.length>0?c.reduce((e,t)=>e+t.fps,0)/c.length:0,d=c.length>0?c.reduce((e,t)=>e+t.memory,0)/c.length:0,f=c.length>0?Math.min(...c.map(e=>e.fps)):0,p=c.length>0?Math.max(...c.map(e=>e.fps)):0,m=(e,t)=>c.map(s=>`${n+(s.timestamp-a)/o*r},${n+i-s[e]/t*i}`).join(` `);return z.createElement(`div`,{className:`x-markdown-debug-modal-content`},z.createElement(`div`,{className:`x-markdown-debug-stats-summary`},z.createElement(`div`,{className:`x-markdown-debug-stat-item`},z.createElement(`div`,{className:`x-markdown-debug-stat-label`},`Duration`),z.createElement(`div`,{className:`x-markdown-debug-stat-value`},(o/1e3).toFixed(2),`s`)),z.createElement(`div`,{className:`x-markdown-debug-stat-item`},z.createElement(`div`,{className:`x-markdown-debug-stat-label`},`FPS Avg`),z.createElement(`div`,{className:`x-markdown-debug-stat-value`,style:{color:S(u)}},u.toFixed(1))),z.createElement(`div`,{className:`x-markdown-debug-stat-item`},z.createElement(`div`,{className:`x-markdown-debug-stat-label`},`FPS Range`),z.createElement(`div`,{className:`x-markdown-debug-stat-value`},f,` - `,p)),z.createElement(`div`,{className:`x-markdown-debug-stat-item`},z.createElement(`div`,{className:`x-markdown-debug-stat-label`},`Memory Avg`),z.createElement(`div`,{className:`x-markdown-debug-stat-value`},x(d)))),z.createElement(`svg`,{width:e,height:t,className:`x-markdown-debug-chart-full`,role:`img`,"aria-label":`Performance chart showing FPS and memory usage over time`},z.createElement(`title`,null,`Performance Chart`),[0,.25,.5,.75,1].map(a=>z.createElement(`g`,{key:a},z.createElement(`line`,{x1:n,y1:n+i*a,x2:e-n,y2:n+i*a,stroke:`rgba(255,255,255,0.1)`,strokeWidth:`1`}),z.createElement(`line`,{x1:n+r*a,y1:n,x2:n+r*a,y2:t-n,stroke:`rgba(255,255,255,0.1)`,strokeWidth:`1`}))),z.createElement(`polyline`,{points:m(`fps`,s),fill:`none`,stroke:Go.COLORS.GOOD,strokeWidth:`2`,className:`fps-line`}),z.createElement(`polyline`,{points:m(`memory`,l),fill:`none`,stroke:`#1890ff`,strokeWidth:`2`,className:`memory-line`}),z.createElement(`text`,{x:n-10,y:n,fill:Go.COLORS.GOOD,fontSize:`12`,textAnchor:`end`},s.toFixed(0)),z.createElement(`text`,{x:n-10,y:t-n,fill:Go.COLORS.GOOD,fontSize:`12`,textAnchor:`end`},`0`),z.createElement(`text`,{x:n-10,y:n-15,fill:Go.COLORS.GOOD,fontSize:`14`,fontWeight:`bold`,textAnchor:`end`},`FPS`),z.createElement(`text`,{x:e-n+10,y:n+20,fill:`#1890ff`,fontSize:`12`,textAnchor:`start`},x(l)),z.createElement(`text`,{x:e-n+10,y:t-n,fill:`#1890ff`,fontSize:`12`,textAnchor:`start`},x(0)),z.createElement(`text`,{x:e-n+10,y:n+5,fill:`#1890ff`,fontSize:`14`,fontWeight:`bold`,textAnchor:`start`},`Memory`),z.createElement(`text`,{x:n,y:t-n+20,fill:`rgba(255,255,255,0.6)`,fontSize:`12`,textAnchor:`middle`},`0s`),z.createElement(`text`,{x:e-n,y:t-n+20,fill:`rgba(255,255,255,0.6)`,fontSize:`12`,textAnchor:`middle`},(o/1e3).toFixed(1),`s`)),z.createElement(`div`,{className:`x-markdown-debug-legend`},z.createElement(`div`,{className:`x-markdown-debug-legend-item`},z.createElement(`span`,{className:`x-markdown-debug-legend-color`,style:{backgroundColor:Go.COLORS.GOOD}}),z.createElement(`span`,null,`FPS`)),z.createElement(`div`,{className:`x-markdown-debug-legend-item`},z.createElement(`span`,{className:`x-markdown-debug-legend-color`,style:{backgroundColor:`#1890ff`}}),z.createElement(`span`,null,`Memory`))))},null))):null)},Q=function(e){return e.Text=`text`,e.Link=`link`,e.Image=`image`,e.Html=`html`,e.Emphasis=`emphasis`,e.List=`list`,e.Table=`table`,e.InlineCode=`inline-code`,e}({}),Jo={image:[/^!\[[^\]\r\n]{0,1000}$/,/^!\[[^\r\n]{0,1000}\]\(*[^)\r\n]{0,1000}$/],link:[/^\[[^\]\r\n]{0,1000}$/,/^\[[^\r\n]{0,1000}\]\(*[^)\r\n]{0,1000}$/],html:[/^<\/$/,/^<\/?[a-zA-Z][a-zA-Z0-9-]{0,100}[^>\r\n]{0,1000}$/],commonEmphasis:[/^(\*{1,3}|_{1,3})(?!\s)(?!.*\1$)[^\r\n]{0,1000}$/],list:[/^[-+*]\s{0,3}$/,/^[-+*]\s{1,3}(\*{1,3}|_{1,3})(?!\s)(?!.*\1$)[^\r\n]{0,1000}$/],"inline-code":[/^`[^`\r\n]{0,300}$/]},Yo=e=>{if(e.includes(` `))return!1;let t=e.split(` `);if(t.length<=1)return!0;let[n,r]=t,i=n.trim();if(!/^\|.*\|$/.test(i))return!1;let a=r.trim().split(`|`).map(e=>e.trim()).filter(Boolean),o=/^:?-+:?$/;return a.every((e,t)=>t===a.length-1&&e===`:`||o.test(e))},Xo={[Q.Link]:{tokenType:Q.Link,isStartOfToken:e=>e.startsWith(`[`),isStreamingValid:e=>Jo.link.some(t=>t.test(e))},[Q.Image]:{tokenType:Q.Image,isStartOfToken:e=>e.startsWith(`!`),isStreamingValid:e=>Jo.image.some(t=>t.test(e))},[Q.Html]:{tokenType:Q.Html,isStartOfToken:e=>e.startsWith(`<`),isStreamingValid:e=>Jo.html.some(t=>t.test(e))},[Q.Emphasis]:{tokenType:Q.Emphasis,isStartOfToken:e=>e.startsWith(`*`)||e.startsWith(`_`),isStreamingValid:e=>Jo.commonEmphasis.some(t=>t.test(e))},[Q.List]:{tokenType:Q.List,isStartOfToken:e=>/^[-+*]/.test(e),isStreamingValid:e=>Jo.list.some(t=>t.test(e)),getCommitPrefix:e=>{let t=e.match(/^([-+*]\s{0,3})/)?.[1],n=t?e.slice(t.length):``;return t&&n.startsWith("`")?t:null}},[Q.Table]:{tokenType:Q.Table,isStartOfToken:e=>e.startsWith(`|`),isStreamingValid:Yo},[Q.InlineCode]:{tokenType:Q.InlineCode,isStartOfToken:e=>e.startsWith("`"),isStreamingValid:e=>Jo[`inline-code`].some(t=>t.test(e))}},Zo=(e,t)=>{let n=Xo[t];if(!n)return;let{token:r,pending:i}=e;if(r===Q.Text&&n.isStartOfToken(i)){e.token=t;return}if(r===t&&!n.isStreamingValid(i)){let t=n.getCommitPrefix?.(i);if(t){e.completeMarkdown+=t,e.pending=i.slice(t.length),e.token=Q.Text;return}es(e)}},Qo=Object.values(Xo).map(e=>({tokenType:e.tokenType,recognize:t=>Zo(t,e.tokenType)})),$o=()=>({pending:``,token:Q.Text,processedLength:0,completeMarkdown:``}),es=e=>{e.pending&&=(e.completeMarkdown+=e.pending,``),e.token=Q.Text},ts=(e,t=!1)=>{let n=e.split(` `),r=!1,i=``,a=0;for(let e=0;e=a&&/^\s*$/.test(c)&&(t||e{let t=``;for(let n=0;n=55296&&r<=56319?n+1=56320&&e.charCodeAt(n+1)<=57343&&(t+=e[n]+e[n+1],n++):(r<56320||r>57343)&&(t+=e[n])}return t},rs=e=>{try{return encodeURIComponent(e)}catch(t){return t instanceof URIError?encodeURIComponent(ns(e)):``}},is=(e,t)=>{let{streaming:n,components:r={}}=t||{},{hasNextChunk:i=!1,incompleteMarkdownComponentMap:a}=n||{},[o,s]=(0,z.useState)(``),c=i?o:typeof e==`string`?e:``,l=(0,z.useRef)($o()),u=(0,z.useCallback)(e=>{let{token:t,pending:n}=e;if(t===Q.Text||t===Q.Image&&n===`!`)return;if(t===Q.Table&&n.split(` `).length>2)return n;let i=(a||{})[t]||`incomplete-${t}`,o=rs(n);return r?.[i]?`<${i} data-raw="${o}" />`:void 0},[a,r]),d=(0,z.useCallback)(e=>{if(!e){s(``),l.current=$o();return}let t=l.current.completeMarkdown+l.current.pending;e.startsWith(t)||(l.current=$o());let n=l.current,r=e.slice(n.processedLength);if(!r)return;n.processedLength+=r.length;for(let e of r){if(n.pending+=e,ts(n.completeMarkdown+n.pending)){es(n);continue}if(n.token===Q.Text)for(let e of Qo)e.recognize(n);else if(Qo.find(e=>e.tokenType===n.token)?.recognize(n),n.token===Q.Text)for(let e of Qo)e.recognize(n);n.token===Q.Text&&es(n)}let i=u(n);s(n.completeMarkdown+(i||``))},[u]);return(0,z.useEffect)(()=>{if(typeof e!=`string`){console.error(`X-Markdown: input must be string, not ${typeof e}.`),s(``);return}i&&d(e)},[e,i,d]),c},as=e=>e?typeof e==`boolean`?`▋`:e.content||`▋`:null,os=z.memo(e=>{let{streaming:t,config:n,components:r,paragraphTag:i,content:a,children:s,rootClassName:c,className:l,style:u,openLinksInNewTab:d,dompurifyConfig:f,protectCustomTagNewlines:p,disableCustomTagBlockMarkdown:m,escapeRawHtml:h,debug:g,disableDefaultStyles:_}=e,v=(0,z.useMemo)(()=>as(t?.tail),[t?.tail]),y=typeof t?.tail==`object`?t.tail.component:void 0,b=!!t?.hasNextChunk&&v,x=o(`x-markdown`,(0,z.useMemo)(()=>{if(_===!0)return`x-md-disable-all`;if(Array.isArray(_))return _.map(e=>`x-md-disable-${e}`)},[_]),c,l),S=is(a||s||``,{streaming:t,components:r}),C=(0,z.useMemo)(()=>{if(!b)return r;let e=y?z.createElement(y,{content:v}):z.createElement(`span`,{className:`xmd-tail`},v);return{...r,"xmd-tail":()=>e}},[b,r,y,v]),w=(0,z.useMemo)(()=>new Wi({markedConfig:n,paragraphTag:i,openLinksInNewTab:d,components:C,protectCustomTagNewlines:p,disableCustomTagBlockMarkdown:m,escapeRawHtml:h}),[n,i,d,C,p,m,h]),T=(0,z.useMemo)(()=>new Wo({components:C,dompurifyConfig:f,streaming:t}),[C,f,t]),E=(0,z.useMemo)(()=>S?w.parse(S,{injectTail:!!b}):``,[S,w,b]),D=(0,z.useMemo)(()=>E?T.render(E):null,[E,T]);return S?z.createElement(z.Fragment,null,z.createElement(`div`,{className:x,style:u},D),g?z.createElement(qo,null):null):null});async function ss(){return S({url:`/ai/chat/conversations`,method:`get`})}async function cs(e){return S({url:`/ai/chat/messages/${e}`,method:`get`})}async function ls(e){return S({url:`/ai/chat/conversations/${e}`,method:`delete`})}var $=h(),{Text:us}=F,ds=()=>{let{t:e}=L(),{message:t,modal:n}=N.useApp(),{token:r}=se.useToken(),i=I(e=>e.themeConfig),a=ce(),[o]=oe(),s=o.get(`agent_id`),[c,l]=(0,z.useState)(null),u=(0,z.useRef)(null),{conversations:d,setConversations:f,activeConversationKey:p,setActiveConversationKey:m}=Qn({}),[h,g]=(0,z.useState)([]),[_,v]=(0,z.useState)(!1),[y,b]=(0,z.useState)(``),[x,S]=(0,z.useState)(!1),w=async()=>{let{data:e}=await ss();e.success&&e.data&&f(e.data)},O=async e=>{let{data:t}=await cs(e);t.success&&t.data&&(g(t.data),setTimeout(()=>{u.current?.scrollTo({top:`bottom`})},100))};(0,z.useEffect)(()=>{w()},[]),(0,z.useEffect)(()=>{s&&le(Number(s)).then(({data:e})=>{e.success&&e.data&&l(e.data)})},[s]);let k=e=>{m(e),O(e)},A=()=>{m(``),g([])},ee=r=>{n.confirm({title:e(`ai.chat.delete.confirm`),okButtonProps:{danger:!0},onOk:async()=>{await ls(r),t.success(e(`ai.chat.delete.success`)),p===r&&(m(``),g([])),await w()}})},M=async e=>{if(!e.trim()||_)return;let t={key:`user-${Date.now()}`,role:`user`,content:e,status:`success`},n={key:`assistant-${Date.now()}`,role:`assistant`,content:``,loading:!0,extraInfo:{isStreaming:!0}};g(e=>[...e,t,n]),v(!0),S(!0);let r=localStorage.getItem(`token`),i=``;fr(`/index.php/ai/chat/send`,{headers:{"Content-Type":`application/json`,Authorization:`Bearer ${r}`,Accept:`text/event-stream`},method:`post`,params:{conversation_id:p,message:e,agent_id:s?Number(s):void 0},callbacks:{onSuccess:async()=>{if(v(!1),b(``),S(!1),!p){let{data:e}=await ss();if(e.success&&e.data&&e.data.length>0){f(e.data);let t=e.data[0].key;m(t)}}},onError:()=>{v(!1),S(!1)},onUpdate:e=>{console.log(`onUpdate`,e);let t=e.data;if(t!==`[DONE]`)try{let e=JSON.parse(t);e.type===`text_delta`&&e.delta&&(i+=e.delta,g(e=>e.map(e=>e.key===n.key?{...e,content:i,loading:!1}:e))),e.type===`text_end`&&g(t=>t.map(t=>t.key===n.key?{...t,key:e.message_id,loading:!1}:t))}catch{}}}})},ne={assistant:{placement:`start`,variant:`filled`,avatar:(0,$.jsx)(P,{src:c?.icon||`https://file.xinadmin.cn/file/favicons.ico`}),contentRender:(e,t)=>{if(!e)return null;let n=t?.extraInfo?.isStreaming===!0;return(0,$.jsx)(os,{content:e,streaming:{hasNextChunk:n,enableAnimation:!0,tail:n},openLinksInNewTab:!0,escapeRawHtml:!0})}},user:{placement:`end`,variant:`filled`,avatar:(0,$.jsx)(P,{icon:(0,$.jsx)(j,{}),style:{background:r.colorFillSecondary,color:r.colorTextSecondary},size:36})}},re=h.length>0;return(0,$.jsxs)(D,{styles:{body:{padding:0,overflow:`hidden`,display:`flex`,height:`calc(100vh - 180px)`}},title:(0,$.jsx)(E,{align:`center`,children:c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(P,{src:c.icon,size:36}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{style:{fontSize:18,fontWeight:600,marginRight:10},children:c.name}),c.description&&(0,$.jsx)(us,{type:`secondary`,style:{fontSize:12,lineHeight:1},children:c.description})]})]}):(0,$.jsx)(`span`,{children:e(`ai.chat.defaultTitle`)})}),extra:(0,$.jsx)(T,{onClick:()=>a(`/ai/agent`),children:e(`ai.chat.switchAgent`)}),children:[(0,$.jsx)(`div`,{style:{width:280,borderRight:`1px solid ${r.colorBorderSecondary}`},children:(0,$.jsx)(Xt,{items:d,activeKey:p,onActiveChange:k,menu:e=>({items:[{label:`Rename`,key:`Rename`,icon:(0,$.jsx)(C,{})},{type:`divider`},{label:`Delete Chat`,key:`delete`,icon:(0,$.jsx)(te,{}),danger:!0,onClick:()=>ee(e.key)}]}),creation:{onClick:A},style:{flex:1,overflow:`auto`}})}),(0,$.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 px-1`,children:[!re&&(0,$.jsx)(`div`,{className:`h-full flex items-center justify-center`,children:(0,$.jsx)(Jn,{icon:c?.icon||`https://file.xinadmin.cn/file/favicons.ico`,style:{backgroundImage:i.themeScheme===`dark`?`linear-gradient(97deg, rgba(90,196,255,0.12) 0%, rgba(174,136,255,0.12) 100%)`:`linear-gradient(97deg, #f2f9fe 0%, #f7f3ff 100%)`,borderRadius:20,width:`80%`,padding:`20px`},title:e(`ai.chat.welcome.title`),description:e(`ai.chat.welcome.description`),variant:`borderless`})}),re&&(0,$.jsx)(`div`,{style:{flex:1,overflow:`hidden`},children:(0,$.jsx)(yt.List,{ref:u,items:h,autoScroll:!0,style:{height:`100%`,padding:16},role:ne})}),(0,$.jsx)(`div`,{style:{padding:`0 16px 16px`},children:(0,$.jsx)(Wn,{loading:_,disabled:x,value:y,onChange:b,placeholder:e(`ai.chat.placeholder`),onSubmit:M,onCancel:()=>v(!1),autoSize:{minRows:1,maxRows:6}})})]})]})};export{ds as default};