@eka-care/medassist-widget 0.0.58 → 0.0.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/medassist-widget.js +1 -1
- package/package.json +1 -1
package/dist/medassist-widget.js
CHANGED
|
@@ -39,7 +39,7 @@ Error generating stack: `+r.message+`
|
|
|
39
39
|
max-height: 100svh;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
`}),x.jsxs(si,{className:j,children:[x.jsx("div",{className:"flex-shrink-0 sticky top-0 z-50",children:x.jsx(ZS,{onClose:i,title:c,iconUrl:a,startNewConversation:o})}),x.jsx("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:s}),h&&x.jsxs("div",{className:"flex-shrink-0 sticky bottom-0 z-50",children:[x.jsx(w.Suspense,{fallback:null,children:x.jsx(WS,{value:h.value,onChange:h.onChange,onSend:h.onSend,onFileChange:h.onFileChange,onRemoveFile:h.onRemoveFile,onRecording:h.onRecording,isRecording:h.isRecording,hasAttachment:h.hasAttachment,attachmentFiles:h.attachmentFiles,isDisabled:h.isDisabled,isMobile:g,placeholder:h.placeholder,recordingStatus:h.recordingStatus})}),d&&p==="development"&&x.jsx("div",{className:"px-6 flex justify-center items-center",children:x.jsxs("p",{className:"text-[8px] text-gray-600 font-mono opacity-50",children:["Session ID: ",d]})})]})]})]})}function Kh(){const[n,i]=w.useState(typeof navigator<"u"?navigator.onLine:!0);return w.useEffect(()=>{const a=()=>i(!0),o=()=>i(!1);return window.addEventListener("online",a),window.addEventListener("offline",o),()=>{window.removeEventListener("online",a),window.removeEventListener("offline",o)}},[]),{isOnline:n}}const Vs=5,eE=10*1024*1024,tE=({environment:n,baseUrl:i,context:a,auth:o})=>{const[s,c]=w.useState([]),[d,h]=w.useState(!1),[p,m]=w.useState(0),[g,y]=w.useState(!1),[b,S]=w.useState([]),O=w.useRef(null),R=w.useRef(null),{isOnline:j}=Kh(),{agentId:_,setSessionId:q,setSessionToken:H,sessionId:K,sessionToken:$,setError:M,setConnectionStatus:z,setShowRetryButton:D,setStartNewConnection:P,setIsStreaming:te,setIsWaitingForResponse:ne,isStreaming:re,initialMessage:we,isWaitingForResponse:ce,setProgressMessage:ee,setRecordingStatus:U,clearSession:W,addMessageToSession:Z,getMessagesForSession:ie,updateMessageInSession:C,setInitialMessage:A,userId:V,fileUploadPerSession:T,setFileUploadPerSession:le}=hr();w.useEffect(()=>{j?g?de()&&(z(Me.ConnectionStatus.CONNECTED),ze()):z(Me.ConnectionStatus.CONNECTING):z(Me.ConnectionStatus.NOT_CONNECTED)},[j,g]),w.useEffect(()=>{if(K){const fe=ie(K)||[];c(fe),S([])}},[K]),w.useEffect(()=>{if(y(!1),!_)return;const fe=new Me.SynapseSDK({agentId:_,environment:n,userId:V,callbacks:{onError:ue=>{if(ue instanceof Me.SynapseError)switch(ue.code){case Me.SynapseErrorCode.SESSION:z(Me.ConnectionStatus.NOT_CONNECTED),D(!0);break;case Me.SynapseErrorCode.RECORDING:M({title:"Recording failed",description:ue?.displayMessage||"Please try again later"});break;case Me.SynapseErrorCode.CONNECTION:M({title:"Connecting..."});break;default:M({title:"Something went wrong",description:ue?.displayMessage||"Please try again later"}),D(!0);break}},onSessionRefreshed:ue=>{ue?.session_id&&ue?.session_token&&(q(ue.session_id),H(ue.session_token))}},...i&&{serverUrl:i},...a&&{context:a},...o&&{auth:o}});return O.current=fe,y(!0),()=>{y(!1),O.current?.endSession(),O.current=null,R.current&&(clearTimeout(R.current),R.current=null)}},[_,n,V,o]),w.useEffect(()=>{const fe=s[s.length-1];!fe?.role||!K||(fe?.role===Pt.USER?Z(K,fe):!re&&!fe.isStored&&(c(ue=>{const se=[...ue];return se[se.length-1]={...fe,isStored:!0},se}),Z(K,{...fe,isStored:!0})))},[s,re]),w.useEffect(()=>{const fe=s[s.length-1];return()=>{fe&&!fe?.isStored&&K&&Z(K,{...fe,isStored:!0})}},[]),w.useEffect(()=>(R.current&&(clearTimeout(R.current),R.current=null),ce&&!re?R.current=setTimeout(()=>{ne(!1),R.current=null},3e4):re&&R.current&&(clearTimeout(R.current),R.current=null),()=>{R.current&&(clearTimeout(R.current),R.current=null)}),[ce,re,ne]);const he=async(fe=!1)=>{try{if(!O.current){M({title:"SDK not initialized",description:"Please ensure agentId is configured"}),h(!1);return}h(!0);let ue;fe?(await W(),ze(),ue=await O.current.startSession()):ue=await O.current.startSession({session_id:K||"",session_token:$||""}),ue?.session_id&&ue?.session_token&&(q(ue.session_id),H(ue.session_token),(ue?.initial_message?.text||ue?.initial_message?.suggestions?.length)&&A(ue.initial_message)),ke()}catch{M({title:"Something Went wrong!",description:"Please try again later."}),h(!1);return}finally{h(!1)}},de=()=>O.current?.isConnected()??!1,ve=()=>{O.current?.endSession()},ze=()=>{m(0),D(!1),P(!1),M(null)},ke=()=>{O.current?.on(Me.SYNAPSE_REALTIME_EVENTS.MESSAGE_CHUNK,fe=>{const ue=fe;if(ue.data?.text&&ue.messageId){re||(ne(!1),te(!0));const se=ue.data.text,Ie=ue.messageId;c(He=>{const We=He[He.length-1];if(We&&We.id===Ie&&We.role===Pt.ASSISTANT){const Ge=[...He];return Ge[Ge.length-1]={...We,content:We.content+se},Ge}else return[...He,{id:Ie,content:se,role:Pt.ASSISTANT,timestamp:dr(Date.now()),isStored:!1}]})}}),O.current?.on(Me.SYNAPSE_REALTIME_EVENTS.END_OF_STREAM,()=>{te(!1),ee(null)}),O.current?.on(Me.SYNAPSE_REALTIME_EVENTS.CONNECTED,()=>{ze(),z(Me.ConnectionStatus.CONNECTED)}),O.current?.on(Me.SYNAPSE_REALTIME_EVENTS.TOOL_CALL,fe=>{const ue=fe;if(!ue?.messageId||!ue?.data||!ue?.data?.details?.component)return;const se=ue.messageId,Ie=ue.timestamp??Date.now();c(He=>{const We=He[He.length-1];if(We.id===se&&We.role===Pt.ASSISTANT){const Ge=[...He],on={...We,toolEscalationData:{...ue.data,isResponded:!1},isResponseFromTool:!0};return Ge[He.length-1]=on,C(K,se,on),Ge}else{const Ge={id:se,content:ue.data?.details?.input?.text||"",role:Pt.ASSISTANT,toolEscalationData:{...ue.data,isResponded:!1},isResponseFromTool:!0,timestamp:dr(Ie),isStored:!1};return[...He,Ge]}})}),O.current?.on(Me.SYNAPSE_REALTIME_EVENTS.DISCONNECTED,fe=>{z(Me.ConnectionStatus.NOT_CONNECTED),p<2?(m(ue=>ue+1),D(!0)):P(!0)}),O.current?.on(Me.SYNAPSE_REALTIME_EVENTS.ERROR,fe=>{const ue=fe.message||fe.displayMessage||"Something went wrong";M({title:ue,description:"Please try again later"}),D(!0),U(Ct.IDLE)}),O.current?.on(Me.SYNAPSE_REALTIME_EVENTS.AUDIO_TRANSCRIPT,async fe=>{const ue=fe;ue?.data?.text&&(c(se=>[...se,{id:Date.now().toString(),content:ue.data.text||"",role:Pt.USER,timestamp:dr(Date.now()),isStored:!0}]),U(Ct.IDLE)),te(!1),ne(!1),ee(null)}),O.current?.on(Me.SYNAPSE_REALTIME_EVENTS.PROGRESS_MESSAGE,fe=>{const ue=fe;ue.data?.text&&(ne(!1),ee(ue.data.text))}),O.current?.on(Me.SYNAPSE_REALTIME_EVENTS.TOOL_START,fe=>{const ue=fe;if(ue.data?.name&&ue.messageId){const se=ue.messageId;c(Ie=>{const He=Ie[Ie.length-1];if(He&&He.id===se&&He.role===Pt.ASSISTANT){const We=[...Ie];return We[We.length-1]={...He,toolCallStatus:`Calling tool: ${ue.data.name}...`},K&&C(K,se,{toolCallStatus:`Calling tool: ${ue.data.name}...`}),We}return Ie})}}),O.current?.on(Me.SYNAPSE_REALTIME_EVENTS.TOOL_END,fe=>{const ue=fe;if(ue.data?.name&&ue.messageId){const se=ue.messageId;c(Ie=>{const He=Ie[Ie.length-1];if(He&&He.id===se&&He.role===Pt.ASSISTANT){const We=[...Ie];return We[We.length-1]={...He,toolCallStatus:"Tool call completed."},K&&C(K,se,{toolCallStatus:"Tool call completed."}),We}return Ie})}})},lt=async({message:fe,messageId:ue,files:se,audio:Ie,toolCalled:He})=>{if(!de()||se&&se.length<0&&fe?.trim()===""&&!Ie?.audio)return;if(se&&se.length>3){M({title:"Maximum 3 files are allowed to be sent at a time",description:"Please try again"});return}if(se&&se.length>0&&se.reduce((oe,be)=>oe+be.size,0)>10*1024*1024){M({title:"Total file size limit of 10MB exceeded",description:"Please reduce the size of the files or try again with less files"});return}if(se&&se.length>0&&se.length+T>Vs){const oe=Vs-T;M({title:`You can only upload up to ${Vs} files per session`,description:`${oe<=0?"Maximum file upload limit reached":`You have ${oe} file${oe===1?"":"s"} upload${oe===1?"":"s"} left`}`});return}else se&&se.length&&le(T+se.length);M(null),D(!1);const We=s.length==2&&b.length==2?b:null,Ge=s.length-1,on=Ge>=0?s[Ge]:null,X=on?on?.isResponseFromTool||on.role===Pt.ASSISTANT&&on.toolEscalationData:null;await O.current?.sendMessage({message:fe,files:se,audio:Ie,...We&&{initial_prompts:We},...X&&!He?{tool_declined:!0,tool_id:on?.toolEscalationData?.tool_id||""}:{}}),(fe||se&&se.length>0)&&(c(oe=>{const be=[...oe],_e=be.length-1;return X&&_e>=0&&be[_e].toolEscalationData&&(be[_e]={...be[_e],toolEscalationData:{...be[_e].toolEscalationData,tool_id:null,isResponded:!0}},C(K,be[Ge].id||Date.now().toString(),be[Ge])),[...be,{id:ue||Date.now().toString(),content:fe||"",files:se||[],role:Pt.USER,timestamp:dr(Date.now()),isStored:!0}]}),ne(!0))};return{sendMessage:lt,startSession:he,incomingMessages:s,loading:d,endSession:ve,isReady:g,startRecording:async()=>{if(!de())throw new Error("Not connected to the server");try{await O.current?.startRecording({onChunks:async fe=>{U(Ct.PROCESSING),await lt({audio:fe}),U(Ct.TRANSCRIBING)},onError(fe){U(Ct.IDLE)}}),U(Ct.LISTENING)}catch(fe){throw U(Ct.IDLE),fe}},stopRecording:()=>{de()&&O.current?.endRecording()},handleRetry:async()=>{if(!de())ze(),await he(!1);else{const fe=s[s.length-1];fe&&fe.role===Pt.USER&&O.current?.sendMessage({message:fe.content,files:fe.files||[],messageId:fe.id})}},isValidFile:fe=>fe.type.toLowerCase()&&!["application/pdf","image/jpeg","image/jpg","image/png"].includes(fe.type)?(M({title:`File type not supported: ${fe.name}`,description:"Only PDF, images (JPG, JPEG, PNG) are allowed."}),!1):fe.size>3*1024*1024?(M({title:"File size limit of 3MB exceeded",description:"Please reduce the size of the file or try again with a smaller file"}),!1):!0,handleStartNewConnection:async()=>{ze(),await W(),await he(!0)},callTool:async(fe,ue)=>{try{if(!de())throw new Error("Not connected to the server");const se=await O.current?.callTool(fe,ue);if(!se)throw new Error("Failed to call tool");return se}catch(se){throw se}},handleInitialTaskClick:async fe=>{if(!we?.suggestions?.length||!fe)return;const ue=we.suggestions.find(se=>se.value===fe);if(!ue||!ue.response){await lt({message:fe});return}c(se=>[...se,{id:Date.now().toString(),content:fe,role:Pt.USER,timestamp:dr(Date.now()),isStored:!0}]),ne(!0),await F0(1e3),ne(!1),c(se=>[...se,{id:Date.now().toString(),content:ue.response||"Please try again",role:Pt.ASSISTANT,timestamp:dr(Date.now()),isStored:!1}]),S([{role:"user",text:fe},{role:"assistant",text:ue.response}])}}},nE=w.lazy(()=>Promise.resolve().then(()=>HC)),lE=w.lazy(()=>Promise.resolve().then(()=>VC)),rE=w.lazy(()=>Promise.resolve().then(()=>PC).then(n=>({default:n.ConnectionStatus})));function iE({isOpen:n,agentId:i,config:a}){const[o,s]=w.useState(""),[c,d]=w.useState(!1),[h,p]=w.useState(!1),[m,g]=w.useState([]),y=w.useRef(!1),b=w.useRef(null),S=w.useRef(null),[O,R]=w.useState(!1),{setAgentId:j,startNewConnection:_,showRetryButton:q,clearError:H,error:K,connectionStatus:$,recordingStatus:M,isWaitingForResponse:z,isStreaming:D,setError:P,initialMessage:te,sessionId:ne,setUserId:re,userId:we,setContext:ce}=hr(),{incomingMessages:ee,loading:U,sendMessage:W,startSession:Z,isReady:ie,startRecording:C,stopRecording:A,handleRetry:V,handleStartNewConnection:T,isValidFile:le,callTool:he,handleInitialTaskClick:de}=tE({environment:"production",baseUrl:a.environment==="development"&&a.baseUrl?a.baseUrl:void 0,context:a?.context,...a?.auth&&{auth:a.auth}});w.useEffect(()=>{if(i){if(j(i),!we){const se=crypto?.randomUUID?.()||Date.now().toString();re(se)}a?.context&&Object.keys(a?.context||{}).length&&ce(a.context),n&&ie&&!y.current&&(y.current=!0,Z(!1))}},[n,ie,i]);const ve=()=>b.current?.querySelector("[data-radix-scroll-area-viewport]")||null,ze=()=>{const se=ve();se&&(se.scrollTo({top:se.scrollHeight,behavior:"smooth"}),R(!1))};w.useEffect(()=>{ze()},[ee,D]);const ke=ee.length>0,lt=$===Me.ConnectionStatus.CONNECTED,yt=U||!lt||z||D,Kt=U||!lt,cl=w.useMemo(()=>M===Ct.IDLE?null:M===Ct.LISTENING?"Listening...":M===Ct.PROCESSING?"Processing...":M===Ct.TRANSCRIBING?"Transcribing...":null,[M]),an=Kt?"Connecting...":cl&&M!==Ct.IDLE?cl:z||D?"Please wait for the response...":"Ask me anything…",Ln=async()=>{if(!yt&&(o.trim()||c||h)){const se=Date.now().toString();m.length>0?(await W({files:m,message:o.trim(),messageId:se}),g([]),p(!1)):o.trim()&&await W({message:o,messageId:se}),s(""),d(!1),p(!1),setTimeout(()=>{ze()},100)}},Un=async se=>{se&&await de(se)},Yl=se=>{if(se&&se.length>0){const Ie=se.filter(He=>!!le(He));if(Ie?.length+m.length>3){P({title:"You can only upload up to 3 files at a time",description:"Please remove some files and try again."});return}if(Ie?.length>0&&Ie.reduce((He,We)=>He+We.size,0)>10*1024*1024){P({title:`Total file size limit of ${eE} MB exceeded`,description:"Please reduce the size of the files or try again with less files"});return}if(Ie?.length>0)se=Ie;else return}g(Ie=>(p((Ie?.length??0)+(se?.length??0)>0),[...Ie,...se]))},fe=se=>{g(Ie=>{const He=Ie.filter((We,Ge)=>Ge!==se);return p(He.length>0),He})},ue=async()=>{if(c)await A(),d(!1);else{if(yt)return;try{await C(),d(!0)}catch{}}};return x.jsx($S,{isOpen:n,onClose:a.onClose,title:a.title,iconUrl:a.iconUrl,onStartNewSession:()=>Z(!0),sessionId:ne,environment:a.environment,displayMode:a.displayMode??"widget",chatComposer:{value:o,onChange:s,onSend:Ln,onFileChange:Yl,onRemoveFile:fe,onRecording:ue,isRecording:c,hasAttachment:h,attachmentFiles:m,isDisabled:yt,placeholder:an,recordingStatus:M},children:!U&&x.jsx(w.Suspense,{fallback:x.jsx(aE,{}),children:x.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden bg-white backdrop-blur-2xl relative",children:[x.jsx(jd,{ref:b,className:"flex-1 min-h-0",children:x.jsxs("div",{className:Te("transition-all duration-300",ke?"p-4 space-y-3":"p-6 space-y-6"),children:[!ke&&te?.text?x.jsx(lE,{profile:a.context?.profile,tasks:te.suggestions,initialPrompt:te.text,onTaskClick:Un,disabled:yt}):x.jsx(nE,{messages:ee,onSendMessage:W,iconUrl:a.iconUrl,callTool:he}),x.jsx("div",{ref:S})]})}),O&&x.jsx("div",{className:"absolute bottom-[10px] left-1/2 transform -translate-x-1/2 z-10",children:x.jsx(St,{onClick:ze,size:"icon",className:"h-10 w-10 rounded-full bg-white/90 backdrop-blur-sm shadow-lg border border-lavender-200/60 hover:bg-white hover:shadow-xl transition-all duration-200",children:x.jsx(As,{className:"w-5 h-5 text-slate-700"})})}),x.jsx(rE,{className:"mt-2",onRetry:V,onStartNewSession:T,showRetryButton:q,startNewConnection:_,clearError:H,error:K,isConnected:lt})]})})})}function aE(){return x.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden bg-white backdrop-blur-2xl animate-pulse",children:[x.jsxs("div",{className:"flex-1 p-6 space-y-4",children:[x.jsx("div",{className:"h-16 bg-gray-100 rounded-2xl"}),x.jsx("div",{className:"h-16 bg-gray-100 rounded-2xl"}),x.jsx("div",{className:"h-16 bg-gray-100 rounded-2xl"})]}),x.jsx("div",{className:"h-24 border-t border-gray-100 bg-gray-50"})]})}function oE({agentId:n,config:i}){const[a,o]=w.useState(!1);w.useEffect(()=>{o(!0)},[]);const s=()=>{o(!1),i?.onClose?.()};return x.jsx(iE,{isOpen:a,agentId:n,config:{...i,environment:i.environment??"production",onClose:s,title:i.title??"Medi Clinic",iconUrl:i.iconUrl??"https://cdn.eka.care/bot-icon.svg"}})}const Qh=(n,i,a)=>{Mb.createRoot(n).render(x.jsx(w.StrictMode,{children:x.jsx(oE,{agentId:i,config:a||{}})}))};typeof window<"u"&&(window.renderMedAssist=Qh);const Zh=w.forwardRef(({className:n,...i},a)=>x.jsx("textarea",{className:Te("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n),ref:a,...i}));Zh.displayName="Textarea";function Jh({file:n,onRemove:i,isPreview:a=!0,className:o=""}){const[s,c]=w.useState(!1),[d,h]=w.useState(""),p=n?.type?.startsWith("image/")??!1,m=n?.type==="application/pdf";w.useEffect(()=>{if(p){const b=URL.createObjectURL(n);return h(b),()=>URL.revokeObjectURL(b)}},[n,p]),w.useEffect(()=>{c(!1)},[n]);const g=()=>p?"text-green-600":"text-gray-600",y=b=>{if(b===0)return"0 B";const S=1024,O=["B","KB","MB","GB"],R=Math.floor(Math.log(b)/Math.log(S));return`${(b/Math.pow(S,R)).toFixed(1)} ${O[R]}`.toLowerCase()};return!p||s?x.jsxs("div",{className:`relative group inline-flex flex-shrink-0 bg-white border border-neutral-300 rounded-lg flex items-center gap-3 px-3 py-2.5 max-w-full ${a?"hover:bg-neutral-50":""} ${o}`,children:[x.jsx("div",{className:`flex-shrink-0 ${g()}`,children:x.jsx(dS,{className:"h-5 w-5"})}),x.jsxs("div",{className:"flex-1 min-w-0 max-w-[200px]",children:[n?.name&&x.jsx("div",{className:"text-sm font-medium text-[var(--color-foreground)] truncate",children:n.name}),n?.size&&x.jsx("div",{className:"text-xs text-[var(--color-muted-foreground)]",children:y(n.size)})]}),a&&i&&x.jsx("button",{onClick:i,"aria-label":`Remove ${n.name}`,className:"flex-shrink-0 flex items-center justify-center w-5 h-5 text-[var(--color-muted-foreground)] hover:text-[var(--color-foreground)] transition-colors",children:x.jsx(Ns,{className:"h-4 w-4"})})]}):x.jsxs("div",{className:`relative group flex-shrink-0 ${o}`,children:[x.jsx("div",{className:`w-20 h-20 bg-white border border-neutral-300 rounded-lg flex items-center justify-center overflow-hidden ${a?"hover:bg-neutral-100 cursor-pointer":""}`,children:d&&x.jsx("img",{src:d,alt:n.name,className:"w-full h-full object-cover",onError:()=>c(!0)})}),a&&i&&x.jsx("button",{onClick:i,"aria-label":`Remove ${n.name}`,className:"absolute top-0 right-0 bg-[var(--color-muted)] text-black rounded-full w-5 h-5 flex items-center justify-center hover:bg-[var(--color-muted-foreground)] transition-colors z-10 transform translate-x-1 -translate-y-1",children:x.jsx(Ns,{className:"h-3 w-3 text-black"})})]})}function Wh({files:n,onRemoveFile:i,isPreview:a=!0,className:o=""}){if(n.length===0)return null;const s=n.filter(d=>d.type?.startsWith("image/")),c=n.filter(d=>!d.type?.startsWith("image/"));return x.jsxs("div",{className:`flex flex-wrap justify-end gap-2 max-w-full ${o}`,children:[c.map(d=>{const h=n.indexOf(d);return x.jsx(Jh,{file:d,onRemove:i?()=>i(h):void 0,isPreview:a},`${d.name}-${d.size}-${h}`)}),s.length>0&&x.jsx("div",{className:"flex gap-2 overflow-x-auto max-w-full p-1 scrollbar-hide",children:s.map(d=>{const h=n.indexOf(d);return x.jsx(Jh,{file:d,onRemove:i?()=>i(h):void 0,isPreview:a},`${d.name}-${d.size}-${h}`)})})]})}function sE({value:n,onChange:i,onSend:a,onFileChange:o,onRemoveFile:s,onRecording:c,isRecording:d,hasAttachment:h,attachmentFiles:p,isDisabled:m,placeholder:g,isMobile:y,recordingStatus:b}){const S=w.useRef(null),O=w.useRef(null),R=n.trim().length>0||h,j=(m||b!==Ct.IDLE)&&!d,_=Te("rounded-full transition-all duration-200 ",d?"bg-gradient-to-r from-rose-400 via-lavender-500 to-indigo-500 text-white ring-2 ring-white/60 animate-pulse shadow-[0_0_20px_rgba(139,92,246,0.45)]":j?"text-lavender-300 cursor-not-allowed shadow-none":"text-lavender-600 hover:bg-gray-100"),q=z=>{const D=Array.from(z.target.files||[]);D.length>0&&o(D)},H=()=>{m||S.current?.click()},K=z=>{z.key==="Enter"&&!z.shiftKey&&R&&!m&&(z.preventDefault(),a())},$=z=>{z.style.height="auto",z.style.overflow="hidden";const D=z.scrollHeight,P=40,te=120,ne=Math.max(P,Math.min(D,te));z.style.height=ne+"px",D>te?z.style.overflow="auto":z.style.overflow="hidden"},M=z=>{$(z.currentTarget)};return w.useEffect(()=>{O.current&&$(O.current)},[n]),w.useEffect(()=>{!m&&!y&&O.current?.focus()},[m]),x.jsxs("div",{className:"border-t border-white/20 bg-white/70 backdrop-blur-xl px-4 py-2",children:[h&&p.length>0&&x.jsx("div",{className:"mb-2 pb-2 border-b border-white/20",children:x.jsx(Wh,{files:p,onRemoveFile:s,isPreview:!0})}),x.jsx("input",{ref:S,type:"file",multiple:!0,max:3,accept:"image/jpeg, image/png, image/jpg, application/pdf",className:"hidden",onChange:q,disabled:m,title:"Attach file","aria-label":"Attach file"}),x.jsxs("div",{className:Te("flex items-center gap-2 bg-white/70 backdrop-blur rounded-xl px-4 py-2 shadow-md focus-within:border-lavender-100/50 focus-within:ring-2 focus-within:ring-lavender-400/50 transition-all",d||h?"ring-2 ring-lavender-200/40":"ring-2 ring-lavender-300/40 backdrop-blur-xl",m&&"opacity-60"),children:[h&&p.length>0&&x.jsxs("span",{className:"text-xs text-lavender-600 mr-2",children:[p.length," file(s)"]}),x.jsx(Zh,{ref:O,onInput:M,placeholder:g,value:n,onChange:z=>i(z.target.value),rows:1,maxLength:1e3,autoFocus:!m,style:{wordBreak:"break-word",overflowWrap:"anywhere",minHeight:"40px",maxHeight:"120px",fontSize:window.innerWidth<=768?"16px":"14px"},onKeyPress:K,disabled:m,title:"Enter your message",className:"flex-1 border-0 outline-none focus-visible:ring-0 focus-visible:ring-offset-0 text-sm !placeholder:text-gray-400 bg-transparent disabled:cursor-not-allowed rounded-none break-words overflow-wrap-anywhere whitespace-pre-wrap"}),b===Ct.IDLE&&x.jsx(St,{type:"button",variant:"ghost",size:"icon",onClick:H,disabled:m,className:`rounded-full transition-all ${h?"bg-lavender-200/30 text-lavender-600 hover:bg-lavender-200/40":"hover:bg-gray-100 text-lavender-600 hover:text-gray-700"}`,title:"Attach file",children:x.jsx(gS,{className:"w-5 h-5"})}),d?x.jsx(St,{type:"button",variant:"ghost",size:"icon",onClick:c,className:"rounded-full bg-gradient-to-r from-red-400 to-rose-500 text-white hover:from-red-500 hover:to-rose-600 shadow-lg transition-all duration-200 hover:scale-105 active:scale-95",title:"Stop recording",children:x.jsx(vS,{className:"w-4 h-4"})}):!R&&x.jsx(St,{type:"button",variant:"ghost",size:"icon",onClick:c,disabled:j,className:_,title:"Start recording",children:x.jsx(pS,{className:"w-5 h-5"})}),R&&!m&&x.jsx(St,{type:"button",size:"icon",onClick:a,className:"h-10 w-10 bg-gradient-to-r from-lavender-400 to-lavender-500 hover:from-lavender-500 hover:to-lavender-600 rounded-full text-white transition-all duration-200 shadow-lg hover:shadow-xl hover:scale-105 active:scale-95",children:x.jsx(yS,{className:"w-4 h-4"})})]})]})}const uE=Object.freeze(Object.defineProperty({__proto__:null,default:sE},Symbol.toStringTag,{value:"Module"}));function cE(n,i){const a={};return(n[n.length-1]===""?[...n,""]:n).join((a.padRight?" ":"")+","+(a.padLeft===!1?"":" ")).trim()}const fE=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,dE=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,hE={};function $h(n,i){return(hE.jsx?dE:fE).test(n)}const mE=/[ \t\n\f\r]/g;function pE(n){return typeof n=="object"?n.type==="text"?em(n.value):!1:em(n)}function em(n){return n.replace(mE,"")===""}class wi{constructor(i,a,o){this.normal=a,this.property=i,o&&(this.space=o)}}wi.prototype.normal={},wi.prototype.property={},wi.prototype.space=void 0;function tm(n,i){const a={},o={};for(const s of n)Object.assign(a,s.property),Object.assign(o,s.normal);return new wi(a,o,i)}function Gs(n){return n.toLowerCase()}class Dt{constructor(i,a){this.attribute=a,this.property=i}}Dt.prototype.attribute="",Dt.prototype.booleanish=!1,Dt.prototype.boolean=!1,Dt.prototype.commaOrSpaceSeparated=!1,Dt.prototype.commaSeparated=!1,Dt.prototype.defined=!1,Dt.prototype.mustUseProperty=!1,Dt.prototype.number=!1,Dt.prototype.overloadedBoolean=!1,Dt.prototype.property="",Dt.prototype.spaceSeparated=!1,Dt.prototype.space=void 0;let gE=0;const Ne=Hl(),ft=Hl(),Ps=Hl(),ae=Hl(),tt=Hl(),mr=Hl(),Ft=Hl();function Hl(){return 2**++gE}const Fs=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ne,booleanish:ft,commaOrSpaceSeparated:Ft,commaSeparated:mr,number:ae,overloadedBoolean:Ps,spaceSeparated:tt},Symbol.toStringTag,{value:"Module"})),Xs=Object.keys(Fs);class Ks extends Dt{constructor(i,a,o,s){let c=-1;if(super(i,a),nm(this,"space",s),typeof o=="number")for(;++c<Xs.length;){const d=Xs[c];nm(this,Xs[c],(o&Fs[d])===Fs[d])}}}Ks.prototype.defined=!0;function nm(n,i,a){a&&(n[i]=a)}function pr(n){const i={},a={};for(const[o,s]of Object.entries(n.properties)){const c=new Ks(o,n.transform(n.attributes||{},o),s,n.space);n.mustUseProperty&&n.mustUseProperty.includes(o)&&(c.mustUseProperty=!0),i[o]=c,a[Gs(o)]=o,a[Gs(c.attribute)]=o}return new wi(i,a,n.space)}const lm=pr({properties:{ariaActiveDescendant:null,ariaAtomic:ft,ariaAutoComplete:null,ariaBusy:ft,ariaChecked:ft,ariaColCount:ae,ariaColIndex:ae,ariaColSpan:ae,ariaControls:tt,ariaCurrent:null,ariaDescribedBy:tt,ariaDetails:null,ariaDisabled:ft,ariaDropEffect:tt,ariaErrorMessage:null,ariaExpanded:ft,ariaFlowTo:tt,ariaGrabbed:ft,ariaHasPopup:null,ariaHidden:ft,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:tt,ariaLevel:ae,ariaLive:null,ariaModal:ft,ariaMultiLine:ft,ariaMultiSelectable:ft,ariaOrientation:null,ariaOwns:tt,ariaPlaceholder:null,ariaPosInSet:ae,ariaPressed:ft,ariaReadOnly:ft,ariaRelevant:null,ariaRequired:ft,ariaRoleDescription:tt,ariaRowCount:ae,ariaRowIndex:ae,ariaRowSpan:ae,ariaSelected:ft,ariaSetSize:ae,ariaSort:null,ariaValueMax:ae,ariaValueMin:ae,ariaValueNow:ae,ariaValueText:null,role:null},transform(n,i){return i==="role"?i:"aria-"+i.slice(4).toLowerCase()}});function rm(n,i){return i in n?n[i]:i}function im(n,i){return rm(n,i.toLowerCase())}const yE=pr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:mr,acceptCharset:tt,accessKey:tt,action:null,allow:null,allowFullScreen:Ne,allowPaymentRequest:Ne,allowUserMedia:Ne,alt:null,as:null,async:Ne,autoCapitalize:null,autoComplete:tt,autoFocus:Ne,autoPlay:Ne,blocking:tt,capture:null,charSet:null,checked:Ne,cite:null,className:tt,cols:ae,colSpan:null,content:null,contentEditable:ft,controls:Ne,controlsList:tt,coords:ae|mr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ne,defer:Ne,dir:null,dirName:null,disabled:Ne,download:Ps,draggable:ft,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ne,formTarget:null,headers:tt,height:ae,hidden:Ps,high:ae,href:null,hrefLang:null,htmlFor:tt,httpEquiv:tt,id:null,imageSizes:null,imageSrcSet:null,inert:Ne,inputMode:null,integrity:null,is:null,isMap:Ne,itemId:null,itemProp:tt,itemRef:tt,itemScope:Ne,itemType:tt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ne,low:ae,manifest:null,max:null,maxLength:ae,media:null,method:null,min:null,minLength:ae,multiple:Ne,muted:Ne,name:null,nonce:null,noModule:Ne,noValidate:Ne,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ne,optimum:ae,pattern:null,ping:tt,placeholder:null,playsInline:Ne,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ne,referrerPolicy:null,rel:tt,required:Ne,reversed:Ne,rows:ae,rowSpan:ae,sandbox:tt,scope:null,scoped:Ne,seamless:Ne,selected:Ne,shadowRootClonable:Ne,shadowRootDelegatesFocus:Ne,shadowRootMode:null,shape:null,size:ae,sizes:null,slot:null,span:ae,spellCheck:ft,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ae,step:null,style:null,tabIndex:ae,target:null,title:null,translate:null,type:null,typeMustMatch:Ne,useMap:null,value:ft,width:ae,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:tt,axis:null,background:null,bgColor:null,border:ae,borderColor:null,bottomMargin:ae,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ne,declare:Ne,event:null,face:null,frame:null,frameBorder:null,hSpace:ae,leftMargin:ae,link:null,longDesc:null,lowSrc:null,marginHeight:ae,marginWidth:ae,noResize:Ne,noHref:Ne,noShade:Ne,noWrap:Ne,object:null,profile:null,prompt:null,rev:null,rightMargin:ae,rules:null,scheme:null,scrolling:ft,standby:null,summary:null,text:null,topMargin:ae,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ae,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ne,disableRemotePlayback:Ne,prefix:null,property:null,results:ae,security:null,unselectable:null},space:"html",transform:im}),vE=pr({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Ft,accentHeight:ae,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ae,amplitude:ae,arabicForm:null,ascent:ae,attributeName:null,attributeType:null,azimuth:ae,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ae,by:null,calcMode:null,capHeight:ae,className:tt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ae,diffuseConstant:ae,direction:null,display:null,dur:null,divisor:ae,dominantBaseline:null,download:Ne,dx:null,dy:null,edgeMode:null,editable:null,elevation:ae,enableBackground:null,end:null,event:null,exponent:ae,externalResourcesRequired:null,fill:null,fillOpacity:ae,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:mr,g2:mr,glyphName:mr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ae,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ae,horizOriginX:ae,horizOriginY:ae,id:null,ideographic:ae,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ae,k:ae,k1:ae,k2:ae,k3:ae,k4:ae,kernelMatrix:Ft,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ae,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ae,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ae,overlineThickness:ae,paintOrder:null,panose1:null,path:null,pathLength:ae,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:tt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ae,pointsAtY:ae,pointsAtZ:ae,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ft,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ft,rev:Ft,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ft,requiredFeatures:Ft,requiredFonts:Ft,requiredFormats:Ft,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ae,specularExponent:ae,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ae,strikethroughThickness:ae,string:null,stroke:null,strokeDashArray:Ft,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ae,strokeOpacity:ae,strokeWidth:null,style:null,surfaceScale:ae,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ft,tabIndex:ae,tableValues:null,target:null,targetX:ae,targetY:ae,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ft,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ae,underlineThickness:ae,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ae,values:null,vAlphabetic:ae,vMathematical:ae,vectorEffect:null,vHanging:ae,vIdeographic:ae,version:null,vertAdvY:ae,vertOriginX:ae,vertOriginY:ae,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ae,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:rm}),am=pr({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(n,i){return"xlink:"+i.slice(5).toLowerCase()}}),om=pr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:im}),sm=pr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(n,i){return"xml:"+i.slice(3).toLowerCase()}}),bE={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},SE=/[A-Z]/g,um=/-[a-z]/g,EE=/^data[-\w.:]+$/i;function xE(n,i){const a=Gs(i);let o=i,s=Dt;if(a in n.normal)return n.property[n.normal[a]];if(a.length>4&&a.slice(0,4)==="data"&&EE.test(i)){if(i.charAt(4)==="-"){const c=i.slice(5).replace(um,CE);o="data"+c.charAt(0).toUpperCase()+c.slice(1)}else{const c=i.slice(4);if(!um.test(c)){let d=c.replace(SE,TE);d.charAt(0)!=="-"&&(d="-"+d),i="data"+d}}s=Ks}return new s(o,i)}function TE(n){return"-"+n.toLowerCase()}function CE(n){return n.charAt(1).toUpperCase()}const wE=tm([lm,yE,am,om,sm],"html"),Qs=tm([lm,vE,am,om,sm],"svg");function _E(n){return n.join(" ").trim()}var gr={},Zs,cm;function AE(){if(cm)return Zs;cm=1;var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,i=/\n/g,a=/^\s*/,o=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,s=/^:\s*/,c=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,d=/^[;\s]*/,h=/^\s+|\s+$/g,p=`
|
|
42
|
+
`}),x.jsxs(si,{className:j,children:[x.jsx("div",{className:"flex-shrink-0 sticky top-0 z-50",children:x.jsx(ZS,{onClose:i,title:c,iconUrl:a,startNewConversation:o})}),x.jsx("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:s}),h&&x.jsxs("div",{className:"flex-shrink-0 sticky bottom-0 z-50",children:[x.jsx(w.Suspense,{fallback:null,children:x.jsx(WS,{value:h.value,onChange:h.onChange,onSend:h.onSend,onFileChange:h.onFileChange,onRemoveFile:h.onRemoveFile,onRecording:h.onRecording,isRecording:h.isRecording,hasAttachment:h.hasAttachment,attachmentFiles:h.attachmentFiles,isDisabled:h.isDisabled,isMobile:g,placeholder:h.placeholder,recordingStatus:h.recordingStatus})}),d&&p==="development"&&x.jsx("div",{className:"px-6 flex justify-center items-center",children:x.jsxs("p",{className:"text-[8px] text-gray-600 font-mono opacity-50",children:["Session ID: ",d]})})]})]})]})}function Kh(){const[n,i]=w.useState(typeof navigator<"u"?navigator.onLine:!0);return w.useEffect(()=>{const a=()=>i(!0),o=()=>i(!1);return window.addEventListener("online",a),window.addEventListener("offline",o),()=>{window.removeEventListener("online",a),window.removeEventListener("offline",o)}},[]),{isOnline:n}}const Vs=5,eE=10*1024*1024,tE=({environment:n,baseUrl:i,context:a,auth:o})=>{const[s,c]=w.useState([]),[d,h]=w.useState(!1),[p,m]=w.useState(0),[g,y]=w.useState(!1),[b,S]=w.useState([]),O=w.useRef(null),R=w.useRef(null),{isOnline:j}=Kh(),{agentId:_,setSessionId:q,setSessionToken:H,sessionId:K,sessionToken:$,setError:M,setConnectionStatus:z,setShowRetryButton:D,setStartNewConnection:P,setIsStreaming:te,setIsWaitingForResponse:ne,isStreaming:re,initialMessage:we,isWaitingForResponse:ce,setProgressMessage:ee,setRecordingStatus:U,clearSession:W,addMessageToSession:Z,getMessagesForSession:ie,updateMessageInSession:C,setInitialMessage:A,userId:V,fileUploadPerSession:T,setFileUploadPerSession:le}=hr();w.useEffect(()=>{j?g?de()&&(z(Me.ConnectionStatus.CONNECTED),ze()):z(Me.ConnectionStatus.CONNECTING):z(Me.ConnectionStatus.NOT_CONNECTED)},[j,g]),w.useEffect(()=>{if(K){const fe=ie(K)||[];c(fe),S([])}},[K]),w.useEffect(()=>{if(y(!1),!_)return;const fe=new Me.SynapseSDK({agentId:_,environment:n,userId:V,callbacks:{onError:ue=>{if(ue instanceof Me.SynapseError)switch(ue.code){case Me.SynapseErrorCode.SESSION:z(Me.ConnectionStatus.NOT_CONNECTED),D(!0);break;case Me.SynapseErrorCode.RECORDING:M({title:"Recording failed",description:ue?.displayMessage||"Please try again later"});break;case Me.SynapseErrorCode.CONNECTION:break;default:M({title:"Something went wrong",description:ue?.displayMessage||"Please try again later"}),D(!0);break}},onSessionRefreshed:ue=>{ue?.session_id&&ue?.session_token&&(q(ue.session_id),H(ue.session_token))}},...i&&{serverUrl:i},...a&&{context:a},...o&&{auth:o}});return O.current=fe,y(!0),()=>{y(!1),O.current?.endSession(),O.current=null,R.current&&(clearTimeout(R.current),R.current=null)}},[_,n,V,o]),w.useEffect(()=>{const fe=s[s.length-1];!fe?.role||!K||(fe?.role===Pt.USER?Z(K,fe):!re&&!fe.isStored&&(c(ue=>{const se=[...ue];return se[se.length-1]={...fe,isStored:!0},se}),Z(K,{...fe,isStored:!0})))},[s,re]),w.useEffect(()=>{const fe=s[s.length-1];return()=>{fe&&!fe?.isStored&&K&&Z(K,{...fe,isStored:!0})}},[]),w.useEffect(()=>(R.current&&(clearTimeout(R.current),R.current=null),ce&&!re?R.current=setTimeout(()=>{ne(!1),R.current=null},3e4):re&&R.current&&(clearTimeout(R.current),R.current=null),()=>{R.current&&(clearTimeout(R.current),R.current=null)}),[ce,re,ne]);const he=async(fe=!1)=>{try{if(!O.current){M({title:"SDK not initialized",description:"Please ensure agentId is configured"}),h(!1);return}h(!0);let ue;fe?(await W(),ze(),ue=await O.current.startSession()):ue=await O.current.startSession({session_id:K||"",session_token:$||""}),ue?.session_id&&ue?.session_token&&(q(ue.session_id),H(ue.session_token),(ue?.initial_message?.text||ue?.initial_message?.suggestions?.length)&&A(ue.initial_message)),ke()}catch{M({title:"Something Went wrong!",description:"Please try again later."}),h(!1);return}finally{h(!1)}},de=()=>O.current?.isConnected()??!1,ve=()=>{O.current?.endSession()},ze=()=>{m(0),D(!1),P(!1),M(null)},ke=()=>{O.current?.on(Me.SYNAPSE_REALTIME_EVENTS.MESSAGE_CHUNK,fe=>{const ue=fe;if(ue.data?.text&&ue.messageId){re||(ne(!1),te(!0));const se=ue.data.text,Ie=ue.messageId;c(He=>{const We=He[He.length-1];if(We&&We.id===Ie&&We.role===Pt.ASSISTANT){const Ge=[...He];return Ge[Ge.length-1]={...We,content:We.content+se},Ge}else return[...He,{id:Ie,content:se,role:Pt.ASSISTANT,timestamp:dr(Date.now()),isStored:!1}]})}}),O.current?.on(Me.SYNAPSE_REALTIME_EVENTS.END_OF_STREAM,()=>{te(!1),ee(null)}),O.current?.on(Me.SYNAPSE_REALTIME_EVENTS.CONNECTED,()=>{ze(),z(Me.ConnectionStatus.CONNECTED)}),O.current?.on(Me.SYNAPSE_REALTIME_EVENTS.TOOL_CALL,fe=>{const ue=fe;if(!ue?.messageId||!ue?.data||!ue?.data?.details?.component)return;const se=ue.messageId,Ie=ue.timestamp??Date.now();c(He=>{const We=He[He.length-1];if(We.id===se&&We.role===Pt.ASSISTANT){const Ge=[...He],on={...We,toolEscalationData:{...ue.data,isResponded:!1},isResponseFromTool:!0};return Ge[He.length-1]=on,C(K,se,on),Ge}else{const Ge={id:se,content:ue.data?.details?.input?.text||"",role:Pt.ASSISTANT,toolEscalationData:{...ue.data,isResponded:!1},isResponseFromTool:!0,timestamp:dr(Ie),isStored:!1};return[...He,Ge]}})}),O.current?.on(Me.SYNAPSE_REALTIME_EVENTS.DISCONNECTED,fe=>{z(Me.ConnectionStatus.NOT_CONNECTED),p<2?(m(ue=>ue+1),D(!0)):P(!0)}),O.current?.on(Me.SYNAPSE_REALTIME_EVENTS.ERROR,fe=>{const ue=fe.message||fe.displayMessage||"Something went wrong";M({title:ue,description:"Please try again later"}),D(!0),U(Ct.IDLE)}),O.current?.on(Me.SYNAPSE_REALTIME_EVENTS.AUDIO_TRANSCRIPT,async fe=>{const ue=fe;ue?.data?.text&&(c(se=>[...se,{id:Date.now().toString(),content:ue.data.text||"",role:Pt.USER,timestamp:dr(Date.now()),isStored:!0}]),U(Ct.IDLE)),te(!1),ne(!1),ee(null)}),O.current?.on(Me.SYNAPSE_REALTIME_EVENTS.PROGRESS_MESSAGE,fe=>{const ue=fe;ue.data?.text&&(ne(!1),ee(ue.data.text))}),O.current?.on(Me.SYNAPSE_REALTIME_EVENTS.TOOL_START,fe=>{const ue=fe;if(ue.data?.name&&ue.messageId){const se=ue.messageId;c(Ie=>{const He=Ie[Ie.length-1];if(He&&He.id===se&&He.role===Pt.ASSISTANT){const We=[...Ie];return We[We.length-1]={...He,toolCallStatus:`Calling tool: ${ue.data.name}...`},K&&C(K,se,{toolCallStatus:`Calling tool: ${ue.data.name}...`}),We}return Ie})}}),O.current?.on(Me.SYNAPSE_REALTIME_EVENTS.TOOL_END,fe=>{const ue=fe;if(ue.data?.name&&ue.messageId){const se=ue.messageId;c(Ie=>{const He=Ie[Ie.length-1];if(He&&He.id===se&&He.role===Pt.ASSISTANT){const We=[...Ie];return We[We.length-1]={...He,toolCallStatus:"Tool call completed."},K&&C(K,se,{toolCallStatus:"Tool call completed."}),We}return Ie})}})},lt=async({message:fe,messageId:ue,files:se,audio:Ie,toolCalled:He})=>{if(!de()||se&&se.length<0&&fe?.trim()===""&&!Ie?.audio)return;if(se&&se.length>3){M({title:"Maximum 3 files are allowed to be sent at a time",description:"Please try again"});return}if(se&&se.length>0&&se.reduce((oe,be)=>oe+be.size,0)>10*1024*1024){M({title:"Total file size limit of 10MB exceeded",description:"Please reduce the size of the files or try again with less files"});return}if(se&&se.length>0&&se.length+T>Vs){const oe=Vs-T;M({title:`You can only upload up to ${Vs} files per session`,description:`${oe<=0?"Maximum file upload limit reached":`You have ${oe} file${oe===1?"":"s"} upload${oe===1?"":"s"} left`}`});return}else se&&se.length&&le(T+se.length);M(null),D(!1);const We=s.length==2&&b.length==2?b:null,Ge=s.length-1,on=Ge>=0?s[Ge]:null,X=on?on?.isResponseFromTool||on.role===Pt.ASSISTANT&&on.toolEscalationData:null;await O.current?.sendMessage({message:fe,files:se,audio:Ie,...We&&{initial_prompts:We},...X&&!He?{tool_declined:!0,tool_id:on?.toolEscalationData?.tool_id||""}:{}}),(fe||se&&se.length>0)&&(c(oe=>{const be=[...oe],_e=be.length-1;return X&&_e>=0&&be[_e].toolEscalationData&&(be[_e]={...be[_e],toolEscalationData:{...be[_e].toolEscalationData,tool_id:null,isResponded:!0}},C(K,be[Ge].id||Date.now().toString(),be[Ge])),[...be,{id:ue||Date.now().toString(),content:fe||"",files:se||[],role:Pt.USER,timestamp:dr(Date.now()),isStored:!0}]}),ne(!0))};return{sendMessage:lt,startSession:he,incomingMessages:s,loading:d,endSession:ve,isReady:g,startRecording:async()=>{if(!de())throw new Error("Not connected to the server");try{await O.current?.startRecording({onChunks:async fe=>{U(Ct.PROCESSING),await lt({audio:fe}),U(Ct.TRANSCRIBING)},onError(fe){U(Ct.IDLE)}}),U(Ct.LISTENING)}catch(fe){throw U(Ct.IDLE),fe}},stopRecording:()=>{de()&&O.current?.endRecording()},handleRetry:async()=>{if(!de())ze(),await he(!1);else{const fe=s[s.length-1];fe&&fe.role===Pt.USER&&O.current?.sendMessage({message:fe.content,files:fe.files||[],messageId:fe.id})}},isValidFile:fe=>fe.type.toLowerCase()&&!["application/pdf","image/jpeg","image/jpg","image/png"].includes(fe.type)?(M({title:`File type not supported: ${fe.name}`,description:"Only PDF, images (JPG, JPEG, PNG) are allowed."}),!1):fe.size>3*1024*1024?(M({title:"File size limit of 3MB exceeded",description:"Please reduce the size of the file or try again with a smaller file"}),!1):!0,handleStartNewConnection:async()=>{ze(),await W(),await he(!0)},callTool:async(fe,ue)=>{try{if(!de())throw new Error("Not connected to the server");const se=await O.current?.callTool(fe,ue);if(!se)throw new Error("Failed to call tool");return se}catch(se){throw se}},handleInitialTaskClick:async fe=>{if(!we?.suggestions?.length||!fe)return;const ue=we.suggestions.find(se=>se.value===fe);if(!ue||!ue.response){await lt({message:fe});return}c(se=>[...se,{id:Date.now().toString(),content:fe,role:Pt.USER,timestamp:dr(Date.now()),isStored:!0}]),ne(!0),await F0(1e3),ne(!1),c(se=>[...se,{id:Date.now().toString(),content:ue.response||"Please try again",role:Pt.ASSISTANT,timestamp:dr(Date.now()),isStored:!1}]),S([{role:"user",text:fe},{role:"assistant",text:ue.response}])}}},nE=w.lazy(()=>Promise.resolve().then(()=>HC)),lE=w.lazy(()=>Promise.resolve().then(()=>VC)),rE=w.lazy(()=>Promise.resolve().then(()=>PC).then(n=>({default:n.ConnectionStatus})));function iE({isOpen:n,agentId:i,config:a}){const[o,s]=w.useState(""),[c,d]=w.useState(!1),[h,p]=w.useState(!1),[m,g]=w.useState([]),y=w.useRef(!1),b=w.useRef(null),S=w.useRef(null),[O,R]=w.useState(!1),{setAgentId:j,startNewConnection:_,showRetryButton:q,clearError:H,error:K,connectionStatus:$,recordingStatus:M,isWaitingForResponse:z,isStreaming:D,setError:P,initialMessage:te,sessionId:ne,setUserId:re,userId:we,setContext:ce}=hr(),{incomingMessages:ee,loading:U,sendMessage:W,startSession:Z,isReady:ie,startRecording:C,stopRecording:A,handleRetry:V,handleStartNewConnection:T,isValidFile:le,callTool:he,handleInitialTaskClick:de}=tE({environment:"production",baseUrl:a.environment==="development"&&a.baseUrl?a.baseUrl:void 0,context:a?.context,...a?.auth&&{auth:a.auth}});w.useEffect(()=>{if(i){if(j(i),!we){const se=crypto?.randomUUID?.()||Date.now().toString();re(se)}a?.context&&Object.keys(a?.context||{}).length&&ce(a.context),n&&ie&&!y.current&&(y.current=!0,Z(!1))}},[n,ie,i]);const ve=()=>b.current?.querySelector("[data-radix-scroll-area-viewport]")||null,ze=()=>{const se=ve();se&&(se.scrollTo({top:se.scrollHeight,behavior:"smooth"}),R(!1))};w.useEffect(()=>{ze()},[ee,D]);const ke=ee.length>0,lt=$===Me.ConnectionStatus.CONNECTED,yt=U||!lt||z||D,Kt=U||!lt,cl=w.useMemo(()=>M===Ct.IDLE?null:M===Ct.LISTENING?"Listening...":M===Ct.PROCESSING?"Processing...":M===Ct.TRANSCRIBING?"Transcribing...":null,[M]),an=Kt?"Connecting...":cl&&M!==Ct.IDLE?cl:z||D?"Please wait for the response...":"Ask me anything…",Ln=async()=>{if(!yt&&(o.trim()||c||h)){const se=Date.now().toString();m.length>0?(await W({files:m,message:o.trim(),messageId:se}),g([]),p(!1)):o.trim()&&await W({message:o,messageId:se}),s(""),d(!1),p(!1),setTimeout(()=>{ze()},100)}},Un=async se=>{se&&await de(se)},Yl=se=>{if(se&&se.length>0){const Ie=se.filter(He=>!!le(He));if(Ie?.length+m.length>3){P({title:"You can only upload up to 3 files at a time",description:"Please remove some files and try again."});return}if(Ie?.length>0&&Ie.reduce((He,We)=>He+We.size,0)>10*1024*1024){P({title:`Total file size limit of ${eE} MB exceeded`,description:"Please reduce the size of the files or try again with less files"});return}if(Ie?.length>0)se=Ie;else return}g(Ie=>(p((Ie?.length??0)+(se?.length??0)>0),[...Ie,...se]))},fe=se=>{g(Ie=>{const He=Ie.filter((We,Ge)=>Ge!==se);return p(He.length>0),He})},ue=async()=>{if(c)await A(),d(!1);else{if(yt)return;try{await C(),d(!0)}catch{}}};return x.jsx($S,{isOpen:n,onClose:a.onClose,title:a.title,iconUrl:a.iconUrl,onStartNewSession:()=>Z(!0),sessionId:ne,environment:a.environment,displayMode:a.displayMode??"widget",chatComposer:{value:o,onChange:s,onSend:Ln,onFileChange:Yl,onRemoveFile:fe,onRecording:ue,isRecording:c,hasAttachment:h,attachmentFiles:m,isDisabled:yt,placeholder:an,recordingStatus:M},children:!U&&x.jsx(w.Suspense,{fallback:x.jsx(aE,{}),children:x.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden bg-white backdrop-blur-2xl relative",children:[x.jsx(jd,{ref:b,className:"flex-1 min-h-0",children:x.jsxs("div",{className:Te("transition-all duration-300",ke?"p-4 space-y-3":"p-6 space-y-6"),children:[!ke&&te?.text?x.jsx(lE,{profile:a.context?.profile,tasks:te.suggestions,initialPrompt:te.text,onTaskClick:Un,disabled:yt}):x.jsx(nE,{messages:ee,onSendMessage:W,iconUrl:a.iconUrl,callTool:he}),x.jsx("div",{ref:S})]})}),O&&x.jsx("div",{className:"absolute bottom-[10px] left-1/2 transform -translate-x-1/2 z-10",children:x.jsx(St,{onClick:ze,size:"icon",className:"h-10 w-10 rounded-full bg-white/90 backdrop-blur-sm shadow-lg border border-lavender-200/60 hover:bg-white hover:shadow-xl transition-all duration-200",children:x.jsx(As,{className:"w-5 h-5 text-slate-700"})})}),x.jsx(rE,{className:"mt-2",onRetry:V,onStartNewSession:T,showRetryButton:q,startNewConnection:_,clearError:H,error:K,isConnected:lt})]})})})}function aE(){return x.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden bg-white backdrop-blur-2xl animate-pulse",children:[x.jsxs("div",{className:"flex-1 p-6 space-y-4",children:[x.jsx("div",{className:"h-16 bg-gray-100 rounded-2xl"}),x.jsx("div",{className:"h-16 bg-gray-100 rounded-2xl"}),x.jsx("div",{className:"h-16 bg-gray-100 rounded-2xl"})]}),x.jsx("div",{className:"h-24 border-t border-gray-100 bg-gray-50"})]})}function oE({agentId:n,config:i}){const[a,o]=w.useState(!1);w.useEffect(()=>{o(!0)},[]);const s=()=>{o(!1),i?.onClose?.()};return x.jsx(iE,{isOpen:a,agentId:n,config:{...i,environment:i.environment??"production",onClose:s,title:i.title??"Medi Clinic",iconUrl:i.iconUrl??"https://cdn.eka.care/bot-icon.svg"}})}const Qh=(n,i,a)=>{Mb.createRoot(n).render(x.jsx(w.StrictMode,{children:x.jsx(oE,{agentId:i,config:a||{}})}))};typeof window<"u"&&(window.renderMedAssist=Qh);const Zh=w.forwardRef(({className:n,...i},a)=>x.jsx("textarea",{className:Te("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n),ref:a,...i}));Zh.displayName="Textarea";function Jh({file:n,onRemove:i,isPreview:a=!0,className:o=""}){const[s,c]=w.useState(!1),[d,h]=w.useState(""),p=n?.type?.startsWith("image/")??!1,m=n?.type==="application/pdf";w.useEffect(()=>{if(p){const b=URL.createObjectURL(n);return h(b),()=>URL.revokeObjectURL(b)}},[n,p]),w.useEffect(()=>{c(!1)},[n]);const g=()=>p?"text-green-600":"text-gray-600",y=b=>{if(b===0)return"0 B";const S=1024,O=["B","KB","MB","GB"],R=Math.floor(Math.log(b)/Math.log(S));return`${(b/Math.pow(S,R)).toFixed(1)} ${O[R]}`.toLowerCase()};return!p||s?x.jsxs("div",{className:`relative group inline-flex flex-shrink-0 bg-white border border-neutral-300 rounded-lg flex items-center gap-3 px-3 py-2.5 max-w-full ${a?"hover:bg-neutral-50":""} ${o}`,children:[x.jsx("div",{className:`flex-shrink-0 ${g()}`,children:x.jsx(dS,{className:"h-5 w-5"})}),x.jsxs("div",{className:"flex-1 min-w-0 max-w-[200px]",children:[n?.name&&x.jsx("div",{className:"text-sm font-medium text-[var(--color-foreground)] truncate",children:n.name}),n?.size&&x.jsx("div",{className:"text-xs text-[var(--color-muted-foreground)]",children:y(n.size)})]}),a&&i&&x.jsx("button",{onClick:i,"aria-label":`Remove ${n.name}`,className:"flex-shrink-0 flex items-center justify-center w-5 h-5 text-[var(--color-muted-foreground)] hover:text-[var(--color-foreground)] transition-colors",children:x.jsx(Ns,{className:"h-4 w-4"})})]}):x.jsxs("div",{className:`relative group flex-shrink-0 ${o}`,children:[x.jsx("div",{className:`w-20 h-20 bg-white border border-neutral-300 rounded-lg flex items-center justify-center overflow-hidden ${a?"hover:bg-neutral-100 cursor-pointer":""}`,children:d&&x.jsx("img",{src:d,alt:n.name,className:"w-full h-full object-cover",onError:()=>c(!0)})}),a&&i&&x.jsx("button",{onClick:i,"aria-label":`Remove ${n.name}`,className:"absolute top-0 right-0 bg-[var(--color-muted)] text-black rounded-full w-5 h-5 flex items-center justify-center hover:bg-[var(--color-muted-foreground)] transition-colors z-10 transform translate-x-1 -translate-y-1",children:x.jsx(Ns,{className:"h-3 w-3 text-black"})})]})}function Wh({files:n,onRemoveFile:i,isPreview:a=!0,className:o=""}){if(n.length===0)return null;const s=n.filter(d=>d.type?.startsWith("image/")),c=n.filter(d=>!d.type?.startsWith("image/"));return x.jsxs("div",{className:`flex flex-wrap justify-end gap-2 max-w-full ${o}`,children:[c.map(d=>{const h=n.indexOf(d);return x.jsx(Jh,{file:d,onRemove:i?()=>i(h):void 0,isPreview:a},`${d.name}-${d.size}-${h}`)}),s.length>0&&x.jsx("div",{className:"flex gap-2 overflow-x-auto max-w-full p-1 scrollbar-hide",children:s.map(d=>{const h=n.indexOf(d);return x.jsx(Jh,{file:d,onRemove:i?()=>i(h):void 0,isPreview:a},`${d.name}-${d.size}-${h}`)})})]})}function sE({value:n,onChange:i,onSend:a,onFileChange:o,onRemoveFile:s,onRecording:c,isRecording:d,hasAttachment:h,attachmentFiles:p,isDisabled:m,placeholder:g,isMobile:y,recordingStatus:b}){const S=w.useRef(null),O=w.useRef(null),R=n.trim().length>0||h,j=(m||b!==Ct.IDLE)&&!d,_=Te("rounded-full transition-all duration-200 ",d?"bg-gradient-to-r from-rose-400 via-lavender-500 to-indigo-500 text-white ring-2 ring-white/60 animate-pulse shadow-[0_0_20px_rgba(139,92,246,0.45)]":j?"text-lavender-300 cursor-not-allowed shadow-none":"text-lavender-600 hover:bg-gray-100"),q=z=>{const D=Array.from(z.target.files||[]);D.length>0&&o(D)},H=()=>{m||S.current?.click()},K=z=>{z.key==="Enter"&&!z.shiftKey&&R&&!m&&(z.preventDefault(),a())},$=z=>{z.style.height="auto",z.style.overflow="hidden";const D=z.scrollHeight,P=40,te=120,ne=Math.max(P,Math.min(D,te));z.style.height=ne+"px",D>te?z.style.overflow="auto":z.style.overflow="hidden"},M=z=>{$(z.currentTarget)};return w.useEffect(()=>{O.current&&$(O.current)},[n]),w.useEffect(()=>{!m&&!y&&O.current?.focus()},[m]),x.jsxs("div",{className:"border-t border-white/20 bg-white/70 backdrop-blur-xl px-4 py-2",children:[h&&p.length>0&&x.jsx("div",{className:"mb-2 pb-2 border-b border-white/20",children:x.jsx(Wh,{files:p,onRemoveFile:s,isPreview:!0})}),x.jsx("input",{ref:S,type:"file",multiple:!0,max:3,accept:"image/jpeg, image/png, image/jpg, application/pdf",className:"hidden",onChange:q,disabled:m,title:"Attach file","aria-label":"Attach file"}),x.jsxs("div",{className:Te("flex items-center gap-2 bg-white/70 backdrop-blur rounded-xl px-4 py-2 shadow-md focus-within:border-lavender-100/50 focus-within:ring-2 focus-within:ring-lavender-400/50 transition-all",d||h?"ring-2 ring-lavender-200/40":"ring-2 ring-lavender-300/40 backdrop-blur-xl",m&&"opacity-60"),children:[h&&p.length>0&&x.jsxs("span",{className:"text-xs text-lavender-600 mr-2",children:[p.length," file(s)"]}),x.jsx(Zh,{ref:O,onInput:M,placeholder:g,value:n,onChange:z=>i(z.target.value),rows:1,maxLength:1e3,autoFocus:!m,style:{wordBreak:"break-word",overflowWrap:"anywhere",minHeight:"40px",maxHeight:"120px",fontSize:window.innerWidth<=768?"16px":"14px"},onKeyPress:K,disabled:m,title:"Enter your message",className:"flex-1 border-0 outline-none focus-visible:ring-0 focus-visible:ring-offset-0 text-sm !placeholder:text-gray-400 bg-transparent disabled:cursor-not-allowed rounded-none break-words overflow-wrap-anywhere whitespace-pre-wrap"}),b===Ct.IDLE&&x.jsx(St,{type:"button",variant:"ghost",size:"icon",onClick:H,disabled:m,className:`rounded-full transition-all ${h?"bg-lavender-200/30 text-lavender-600 hover:bg-lavender-200/40":"hover:bg-gray-100 text-lavender-600 hover:text-gray-700"}`,title:"Attach file",children:x.jsx(gS,{className:"w-5 h-5"})}),d?x.jsx(St,{type:"button",variant:"ghost",size:"icon",onClick:c,className:"rounded-full bg-gradient-to-r from-red-400 to-rose-500 text-white hover:from-red-500 hover:to-rose-600 shadow-lg transition-all duration-200 hover:scale-105 active:scale-95",title:"Stop recording",children:x.jsx(vS,{className:"w-4 h-4"})}):!R&&x.jsx(St,{type:"button",variant:"ghost",size:"icon",onClick:c,disabled:j,className:_,title:"Start recording",children:x.jsx(pS,{className:"w-5 h-5"})}),R&&!m&&x.jsx(St,{type:"button",size:"icon",onClick:a,className:"h-10 w-10 bg-gradient-to-r from-lavender-400 to-lavender-500 hover:from-lavender-500 hover:to-lavender-600 rounded-full text-white transition-all duration-200 shadow-lg hover:shadow-xl hover:scale-105 active:scale-95",children:x.jsx(yS,{className:"w-4 h-4"})})]})]})}const uE=Object.freeze(Object.defineProperty({__proto__:null,default:sE},Symbol.toStringTag,{value:"Module"}));function cE(n,i){const a={};return(n[n.length-1]===""?[...n,""]:n).join((a.padRight?" ":"")+","+(a.padLeft===!1?"":" ")).trim()}const fE=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,dE=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,hE={};function $h(n,i){return(hE.jsx?dE:fE).test(n)}const mE=/[ \t\n\f\r]/g;function pE(n){return typeof n=="object"?n.type==="text"?em(n.value):!1:em(n)}function em(n){return n.replace(mE,"")===""}class wi{constructor(i,a,o){this.normal=a,this.property=i,o&&(this.space=o)}}wi.prototype.normal={},wi.prototype.property={},wi.prototype.space=void 0;function tm(n,i){const a={},o={};for(const s of n)Object.assign(a,s.property),Object.assign(o,s.normal);return new wi(a,o,i)}function Gs(n){return n.toLowerCase()}class Dt{constructor(i,a){this.attribute=a,this.property=i}}Dt.prototype.attribute="",Dt.prototype.booleanish=!1,Dt.prototype.boolean=!1,Dt.prototype.commaOrSpaceSeparated=!1,Dt.prototype.commaSeparated=!1,Dt.prototype.defined=!1,Dt.prototype.mustUseProperty=!1,Dt.prototype.number=!1,Dt.prototype.overloadedBoolean=!1,Dt.prototype.property="",Dt.prototype.spaceSeparated=!1,Dt.prototype.space=void 0;let gE=0;const Ne=Hl(),ft=Hl(),Ps=Hl(),ae=Hl(),tt=Hl(),mr=Hl(),Ft=Hl();function Hl(){return 2**++gE}const Fs=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ne,booleanish:ft,commaOrSpaceSeparated:Ft,commaSeparated:mr,number:ae,overloadedBoolean:Ps,spaceSeparated:tt},Symbol.toStringTag,{value:"Module"})),Xs=Object.keys(Fs);class Ks extends Dt{constructor(i,a,o,s){let c=-1;if(super(i,a),nm(this,"space",s),typeof o=="number")for(;++c<Xs.length;){const d=Xs[c];nm(this,Xs[c],(o&Fs[d])===Fs[d])}}}Ks.prototype.defined=!0;function nm(n,i,a){a&&(n[i]=a)}function pr(n){const i={},a={};for(const[o,s]of Object.entries(n.properties)){const c=new Ks(o,n.transform(n.attributes||{},o),s,n.space);n.mustUseProperty&&n.mustUseProperty.includes(o)&&(c.mustUseProperty=!0),i[o]=c,a[Gs(o)]=o,a[Gs(c.attribute)]=o}return new wi(i,a,n.space)}const lm=pr({properties:{ariaActiveDescendant:null,ariaAtomic:ft,ariaAutoComplete:null,ariaBusy:ft,ariaChecked:ft,ariaColCount:ae,ariaColIndex:ae,ariaColSpan:ae,ariaControls:tt,ariaCurrent:null,ariaDescribedBy:tt,ariaDetails:null,ariaDisabled:ft,ariaDropEffect:tt,ariaErrorMessage:null,ariaExpanded:ft,ariaFlowTo:tt,ariaGrabbed:ft,ariaHasPopup:null,ariaHidden:ft,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:tt,ariaLevel:ae,ariaLive:null,ariaModal:ft,ariaMultiLine:ft,ariaMultiSelectable:ft,ariaOrientation:null,ariaOwns:tt,ariaPlaceholder:null,ariaPosInSet:ae,ariaPressed:ft,ariaReadOnly:ft,ariaRelevant:null,ariaRequired:ft,ariaRoleDescription:tt,ariaRowCount:ae,ariaRowIndex:ae,ariaRowSpan:ae,ariaSelected:ft,ariaSetSize:ae,ariaSort:null,ariaValueMax:ae,ariaValueMin:ae,ariaValueNow:ae,ariaValueText:null,role:null},transform(n,i){return i==="role"?i:"aria-"+i.slice(4).toLowerCase()}});function rm(n,i){return i in n?n[i]:i}function im(n,i){return rm(n,i.toLowerCase())}const yE=pr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:mr,acceptCharset:tt,accessKey:tt,action:null,allow:null,allowFullScreen:Ne,allowPaymentRequest:Ne,allowUserMedia:Ne,alt:null,as:null,async:Ne,autoCapitalize:null,autoComplete:tt,autoFocus:Ne,autoPlay:Ne,blocking:tt,capture:null,charSet:null,checked:Ne,cite:null,className:tt,cols:ae,colSpan:null,content:null,contentEditable:ft,controls:Ne,controlsList:tt,coords:ae|mr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ne,defer:Ne,dir:null,dirName:null,disabled:Ne,download:Ps,draggable:ft,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ne,formTarget:null,headers:tt,height:ae,hidden:Ps,high:ae,href:null,hrefLang:null,htmlFor:tt,httpEquiv:tt,id:null,imageSizes:null,imageSrcSet:null,inert:Ne,inputMode:null,integrity:null,is:null,isMap:Ne,itemId:null,itemProp:tt,itemRef:tt,itemScope:Ne,itemType:tt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ne,low:ae,manifest:null,max:null,maxLength:ae,media:null,method:null,min:null,minLength:ae,multiple:Ne,muted:Ne,name:null,nonce:null,noModule:Ne,noValidate:Ne,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ne,optimum:ae,pattern:null,ping:tt,placeholder:null,playsInline:Ne,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ne,referrerPolicy:null,rel:tt,required:Ne,reversed:Ne,rows:ae,rowSpan:ae,sandbox:tt,scope:null,scoped:Ne,seamless:Ne,selected:Ne,shadowRootClonable:Ne,shadowRootDelegatesFocus:Ne,shadowRootMode:null,shape:null,size:ae,sizes:null,slot:null,span:ae,spellCheck:ft,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ae,step:null,style:null,tabIndex:ae,target:null,title:null,translate:null,type:null,typeMustMatch:Ne,useMap:null,value:ft,width:ae,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:tt,axis:null,background:null,bgColor:null,border:ae,borderColor:null,bottomMargin:ae,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ne,declare:Ne,event:null,face:null,frame:null,frameBorder:null,hSpace:ae,leftMargin:ae,link:null,longDesc:null,lowSrc:null,marginHeight:ae,marginWidth:ae,noResize:Ne,noHref:Ne,noShade:Ne,noWrap:Ne,object:null,profile:null,prompt:null,rev:null,rightMargin:ae,rules:null,scheme:null,scrolling:ft,standby:null,summary:null,text:null,topMargin:ae,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ae,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ne,disableRemotePlayback:Ne,prefix:null,property:null,results:ae,security:null,unselectable:null},space:"html",transform:im}),vE=pr({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Ft,accentHeight:ae,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ae,amplitude:ae,arabicForm:null,ascent:ae,attributeName:null,attributeType:null,azimuth:ae,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ae,by:null,calcMode:null,capHeight:ae,className:tt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ae,diffuseConstant:ae,direction:null,display:null,dur:null,divisor:ae,dominantBaseline:null,download:Ne,dx:null,dy:null,edgeMode:null,editable:null,elevation:ae,enableBackground:null,end:null,event:null,exponent:ae,externalResourcesRequired:null,fill:null,fillOpacity:ae,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:mr,g2:mr,glyphName:mr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ae,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ae,horizOriginX:ae,horizOriginY:ae,id:null,ideographic:ae,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ae,k:ae,k1:ae,k2:ae,k3:ae,k4:ae,kernelMatrix:Ft,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ae,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ae,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ae,overlineThickness:ae,paintOrder:null,panose1:null,path:null,pathLength:ae,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:tt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ae,pointsAtY:ae,pointsAtZ:ae,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ft,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ft,rev:Ft,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ft,requiredFeatures:Ft,requiredFonts:Ft,requiredFormats:Ft,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ae,specularExponent:ae,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ae,strikethroughThickness:ae,string:null,stroke:null,strokeDashArray:Ft,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ae,strokeOpacity:ae,strokeWidth:null,style:null,surfaceScale:ae,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ft,tabIndex:ae,tableValues:null,target:null,targetX:ae,targetY:ae,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ft,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ae,underlineThickness:ae,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ae,values:null,vAlphabetic:ae,vMathematical:ae,vectorEffect:null,vHanging:ae,vIdeographic:ae,version:null,vertAdvY:ae,vertOriginX:ae,vertOriginY:ae,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ae,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:rm}),am=pr({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(n,i){return"xlink:"+i.slice(5).toLowerCase()}}),om=pr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:im}),sm=pr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(n,i){return"xml:"+i.slice(3).toLowerCase()}}),bE={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},SE=/[A-Z]/g,um=/-[a-z]/g,EE=/^data[-\w.:]+$/i;function xE(n,i){const a=Gs(i);let o=i,s=Dt;if(a in n.normal)return n.property[n.normal[a]];if(a.length>4&&a.slice(0,4)==="data"&&EE.test(i)){if(i.charAt(4)==="-"){const c=i.slice(5).replace(um,CE);o="data"+c.charAt(0).toUpperCase()+c.slice(1)}else{const c=i.slice(4);if(!um.test(c)){let d=c.replace(SE,TE);d.charAt(0)!=="-"&&(d="-"+d),i="data"+d}}s=Ks}return new s(o,i)}function TE(n){return"-"+n.toLowerCase()}function CE(n){return n.charAt(1).toUpperCase()}const wE=tm([lm,yE,am,om,sm],"html"),Qs=tm([lm,vE,am,om,sm],"svg");function _E(n){return n.join(" ").trim()}var gr={},Zs,cm;function AE(){if(cm)return Zs;cm=1;var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,i=/\n/g,a=/^\s*/,o=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,s=/^:\s*/,c=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,d=/^[;\s]*/,h=/^\s+|\s+$/g,p=`
|
|
43
43
|
`,m="/",g="*",y="",b="comment",S="declaration";function O(j,_){if(typeof j!="string")throw new TypeError("First argument must be a string");if(!j)return[];_=_||{};var q=1,H=1;function K(ce){var ee=ce.match(i);ee&&(q+=ee.length);var U=ce.lastIndexOf(p);H=~U?ce.length-U:H+ce.length}function $(){var ce={line:q,column:H};return function(ee){return ee.position=new M(ce),P(),ee}}function M(ce){this.start=ce,this.end={line:q,column:H},this.source=_.source}M.prototype.content=j;function z(ce){var ee=new Error(_.source+":"+q+":"+H+": "+ce);if(ee.reason=ce,ee.filename=_.source,ee.line=q,ee.column=H,ee.source=j,!_.silent)throw ee}function D(ce){var ee=ce.exec(j);if(ee){var U=ee[0];return K(U),j=j.slice(U.length),ee}}function P(){D(a)}function te(ce){var ee;for(ce=ce||[];ee=ne();)ee!==!1&&ce.push(ee);return ce}function ne(){var ce=$();if(!(m!=j.charAt(0)||g!=j.charAt(1))){for(var ee=2;y!=j.charAt(ee)&&(g!=j.charAt(ee)||m!=j.charAt(ee+1));)++ee;if(ee+=2,y===j.charAt(ee-1))return z("End of comment missing");var U=j.slice(2,ee-2);return H+=2,K(U),j=j.slice(ee),H+=2,ce({type:b,comment:U})}}function re(){var ce=$(),ee=D(o);if(ee){if(ne(),!D(s))return z("property missing ':'");var U=D(c),W=ce({type:S,property:R(ee[0].replace(n,y)),value:U?R(U[0].replace(n,y)):y});return D(d),W}}function we(){var ce=[];te(ce);for(var ee;ee=re();)ee!==!1&&(ce.push(ee),te(ce));return ce}return P(),we()}function R(j){return j?j.replace(h,y):y}return Zs=O,Zs}var fm;function NE(){if(fm)return gr;fm=1;var n=gr&&gr.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(gr,"__esModule",{value:!0}),gr.default=a;const i=n(AE());function a(o,s){let c=null;if(!o||typeof o!="string")return c;const d=(0,i.default)(o),h=typeof s=="function";return d.forEach(p=>{if(p.type!=="declaration")return;const{property:m,value:g}=p;h?s(m,g,p):g&&(c=c||{},c[m]=g)}),c}return gr}var _i={},dm;function RE(){if(dm)return _i;dm=1,Object.defineProperty(_i,"__esModule",{value:!0}),_i.camelCase=void 0;var n=/^--[a-zA-Z0-9_-]+$/,i=/-([a-z])/g,a=/^[^-]+$/,o=/^-(webkit|moz|ms|o|khtml)-/,s=/^-(ms)-/,c=function(m){return!m||a.test(m)||n.test(m)},d=function(m,g){return g.toUpperCase()},h=function(m,g){return"".concat(g,"-")},p=function(m,g){return g===void 0&&(g={}),c(m)?m:(m=m.toLowerCase(),g.reactCompat?m=m.replace(s,h):m=m.replace(o,h),m.replace(i,d))};return _i.camelCase=p,_i}var Ai,hm;function OE(){if(hm)return Ai;hm=1;var n=Ai&&Ai.__importDefault||function(s){return s&&s.__esModule?s:{default:s}},i=n(NE()),a=RE();function o(s,c){var d={};return!s||typeof s!="string"||(0,i.default)(s,function(h,p){h&&p&&(d[(0,a.camelCase)(h,c)]=p)}),d}return o.default=o,Ai=o,Ai}var ME=OE();const kE=fs(ME),mm=pm("end"),Js=pm("start");function pm(n){return i;function i(a){const o=a&&a.position&&a.position[n]||{};if(typeof o.line=="number"&&o.line>0&&typeof o.column=="number"&&o.column>0)return{line:o.line,column:o.column,offset:typeof o.offset=="number"&&o.offset>-1?o.offset:void 0}}}function zE(n){const i=Js(n),a=mm(n);if(i&&a)return{start:i,end:a}}function Ni(n){return!n||typeof n!="object"?"":"position"in n||"type"in n?gm(n.position):"start"in n||"end"in n?gm(n):"line"in n||"column"in n?Ws(n):""}function Ws(n){return ym(n&&n.line)+":"+ym(n&&n.column)}function gm(n){return Ws(n&&n.start)+"-"+Ws(n&&n.end)}function ym(n){return n&&typeof n=="number"?n:1}class Mt extends Error{constructor(i,a,o){super(),typeof a=="string"&&(o=a,a=void 0);let s="",c={},d=!1;if(a&&("line"in a&&"column"in a?c={place:a}:"start"in a&&"end"in a?c={place:a}:"type"in a?c={ancestors:[a],place:a.position}:c={...a}),typeof i=="string"?s=i:!c.cause&&i&&(d=!0,s=i.message,c.cause=i),!c.ruleId&&!c.source&&typeof o=="string"){const p=o.indexOf(":");p===-1?c.ruleId=o:(c.source=o.slice(0,p),c.ruleId=o.slice(p+1))}if(!c.place&&c.ancestors&&c.ancestors){const p=c.ancestors[c.ancestors.length-1];p&&(c.place=p.position)}const h=c.place&&"start"in c.place?c.place.start:c.place;this.ancestors=c.ancestors||void 0,this.cause=c.cause||void 0,this.column=h?h.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=h?h.line:void 0,this.name=Ni(c.place)||"1:1",this.place=c.place||void 0,this.reason=this.message,this.ruleId=c.ruleId||void 0,this.source=c.source||void 0,this.stack=d&&c.cause&&typeof c.cause.stack=="string"?c.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Mt.prototype.file="",Mt.prototype.name="",Mt.prototype.reason="",Mt.prototype.message="",Mt.prototype.stack="",Mt.prototype.column=void 0,Mt.prototype.line=void 0,Mt.prototype.ancestors=void 0,Mt.prototype.cause=void 0,Mt.prototype.fatal=void 0,Mt.prototype.place=void 0,Mt.prototype.ruleId=void 0,Mt.prototype.source=void 0;const $s={}.hasOwnProperty,DE=new Map,jE=/[A-Z]/g,LE=new Set(["table","tbody","thead","tfoot","tr"]),UE=new Set(["td","th"]),vm="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function BE(n,i){if(!i||i.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const a=i.filePath||void 0;let o;if(i.development){if(typeof i.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");o=FE(a,i.jsxDEV)}else{if(typeof i.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof i.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");o=PE(a,i.jsx,i.jsxs)}const s={Fragment:i.Fragment,ancestors:[],components:i.components||{},create:o,elementAttributeNameCase:i.elementAttributeNameCase||"react",evaluater:i.createEvaluater?i.createEvaluater():void 0,filePath:a,ignoreInvalidStyle:i.ignoreInvalidStyle||!1,passKeys:i.passKeys!==!1,passNode:i.passNode||!1,schema:i.space==="svg"?Qs:wE,stylePropertyNameCase:i.stylePropertyNameCase||"dom",tableCellAlignToStyle:i.tableCellAlignToStyle!==!1},c=bm(s,n,void 0);return c&&typeof c!="string"?c:s.create(n,s.Fragment,{children:c||void 0},void 0)}function bm(n,i,a){if(i.type==="element")return IE(n,i,a);if(i.type==="mdxFlowExpression"||i.type==="mdxTextExpression")return HE(n,i);if(i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement")return YE(n,i,a);if(i.type==="mdxjsEsm")return qE(n,i);if(i.type==="root")return VE(n,i,a);if(i.type==="text")return GE(n,i)}function IE(n,i,a){const o=n.schema;let s=o;i.tagName.toLowerCase()==="svg"&&o.space==="html"&&(s=Qs,n.schema=s),n.ancestors.push(i);const c=Em(n,i.tagName,!1),d=XE(n,i);let h=tu(n,i);return LE.has(i.tagName)&&(h=h.filter(function(p){return typeof p=="string"?!pE(p):!0})),Sm(n,d,c,i),eu(d,h),n.ancestors.pop(),n.schema=o,n.create(i,c,d,a)}function HE(n,i){if(i.data&&i.data.estree&&n.evaluater){const o=i.data.estree.body[0];return n.evaluater.evaluateExpression(o.expression)}Ri(n,i.position)}function qE(n,i){if(i.data&&i.data.estree&&n.evaluater)return n.evaluater.evaluateProgram(i.data.estree);Ri(n,i.position)}function YE(n,i,a){const o=n.schema;let s=o;i.name==="svg"&&o.space==="html"&&(s=Qs,n.schema=s),n.ancestors.push(i);const c=i.name===null?n.Fragment:Em(n,i.name,!0),d=KE(n,i),h=tu(n,i);return Sm(n,d,c,i),eu(d,h),n.ancestors.pop(),n.schema=o,n.create(i,c,d,a)}function VE(n,i,a){const o={};return eu(o,tu(n,i)),n.create(i,n.Fragment,o,a)}function GE(n,i){return i.value}function Sm(n,i,a,o){typeof a!="string"&&a!==n.Fragment&&n.passNode&&(i.node=o)}function eu(n,i){if(i.length>0){const a=i.length>1?i:i[0];a&&(n.children=a)}}function PE(n,i,a){return o;function o(s,c,d,h){const m=Array.isArray(d.children)?a:i;return h?m(c,d,h):m(c,d)}}function FE(n,i){return a;function a(o,s,c,d){const h=Array.isArray(c.children),p=Js(o);return i(s,c,d,h,{columnNumber:p?p.column-1:void 0,fileName:n,lineNumber:p?p.line:void 0},void 0)}}function XE(n,i){const a={};let o,s;for(s in i.properties)if(s!=="children"&&$s.call(i.properties,s)){const c=QE(n,s,i.properties[s]);if(c){const[d,h]=c;n.tableCellAlignToStyle&&d==="align"&&typeof h=="string"&&UE.has(i.tagName)?o=h:a[d]=h}}if(o){const c=a.style||(a.style={});c[n.stylePropertyNameCase==="css"?"text-align":"textAlign"]=o}return a}function KE(n,i){const a={};for(const o of i.attributes)if(o.type==="mdxJsxExpressionAttribute")if(o.data&&o.data.estree&&n.evaluater){const h=o.data.estree.body[0].expression.properties[0];Object.assign(a,n.evaluater.evaluateExpression(h.argument))}else Ri(n,i.position);else{const s=o.name;let c;if(o.value&&typeof o.value=="object")if(o.value.data&&o.value.data.estree&&n.evaluater){const h=o.value.data.estree.body[0];c=n.evaluater.evaluateExpression(h.expression)}else Ri(n,i.position);else c=o.value===null?!0:o.value;a[s]=c}return a}function tu(n,i){const a=[];let o=-1;const s=n.passKeys?new Map:DE;for(;++o<i.children.length;){const c=i.children[o];let d;if(n.passKeys){const p=c.type==="element"?c.tagName:c.type==="mdxJsxFlowElement"||c.type==="mdxJsxTextElement"?c.name:void 0;if(p){const m=s.get(p)||0;d=p+"-"+m,s.set(p,m+1)}}const h=bm(n,c,d);h!==void 0&&a.push(h)}return a}function QE(n,i,a){const o=xE(n.schema,i);if(!(a==null||typeof a=="number"&&Number.isNaN(a))){if(Array.isArray(a)&&(a=o.commaSeparated?cE(a):_E(a)),o.property==="style"){let s=typeof a=="object"?a:ZE(n,String(a));return n.stylePropertyNameCase==="css"&&(s=JE(s)),["style",s]}return[n.elementAttributeNameCase==="react"&&o.space?bE[o.property]||o.property:o.attribute,a]}}function ZE(n,i){try{return kE(i,{reactCompat:!0})}catch(a){if(n.ignoreInvalidStyle)return{};const o=a,s=new Mt("Cannot parse `style` attribute",{ancestors:n.ancestors,cause:o,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=n.filePath||void 0,s.url=vm+"#cannot-parse-style-attribute",s}}function Em(n,i,a){let o;if(!a)o={type:"Literal",value:i};else if(i.includes(".")){const s=i.split(".");let c=-1,d;for(;++c<s.length;){const h=$h(s[c])?{type:"Identifier",name:s[c]}:{type:"Literal",value:s[c]};d=d?{type:"MemberExpression",object:d,property:h,computed:!!(c&&h.type==="Literal"),optional:!1}:h}o=d}else o=$h(i)&&!/^[a-z]/.test(i)?{type:"Identifier",name:i}:{type:"Literal",value:i};if(o.type==="Literal"){const s=o.value;return $s.call(n.components,s)?n.components[s]:s}if(n.evaluater)return n.evaluater.evaluateExpression(o);Ri(n)}function Ri(n,i){const a=new Mt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:n.ancestors,place:i,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw a.file=n.filePath||void 0,a.url=vm+"#cannot-handle-mdx-estrees-without-createevaluater",a}function JE(n){const i={};let a;for(a in n)$s.call(n,a)&&(i[WE(a)]=n[a]);return i}function WE(n){let i=n.replace(jE,$E);return i.slice(0,3)==="ms-"&&(i="-"+i),i}function $E(n){return"-"+n.toLowerCase()}const nu={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},ex={};function tx(n,i){const a=ex,o=typeof a.includeImageAlt=="boolean"?a.includeImageAlt:!0,s=typeof a.includeHtml=="boolean"?a.includeHtml:!0;return xm(n,o,s)}function xm(n,i,a){if(nx(n)){if("value"in n)return n.type==="html"&&!a?"":n.value;if(i&&"alt"in n&&n.alt)return n.alt;if("children"in n)return Tm(n.children,i,a)}return Array.isArray(n)?Tm(n,i,a):""}function Tm(n,i,a){const o=[];let s=-1;for(;++s<n.length;)o[s]=xm(n[s],i,a);return o.join("")}function nx(n){return!!(n&&typeof n=="object")}const Cm=document.createElement("i");function lu(n){const i="&"+n+";";Cm.innerHTML=i;const a=Cm.textContent;return a.charCodeAt(a.length-1)===59&&n!=="semi"||a===i?!1:a}function wn(n,i,a,o){const s=n.length;let c=0,d;if(i<0?i=-i>s?0:s+i:i=i>s?s:i,a=a>0?a:0,o.length<1e4)d=Array.from(o),d.unshift(i,a),n.splice(...d);else for(a&&n.splice(i,a);c<o.length;)d=o.slice(c,c+1e4),d.unshift(i,0),n.splice(...d),c+=1e4,i+=1e4}function rn(n,i){return n.length>0?(wn(n,n.length,0,i),n):i}const wm={}.hasOwnProperty;function lx(n){const i={};let a=-1;for(;++a<n.length;)rx(i,n[a]);return i}function rx(n,i){let a;for(a in i){const s=(wm.call(n,a)?n[a]:void 0)||(n[a]={}),c=i[a];let d;if(c)for(d in c){wm.call(s,d)||(s[d]=[]);const h=c[d];ix(s[d],Array.isArray(h)?h:h?[h]:[])}}}function ix(n,i){let a=-1;const o=[];for(;++a<i.length;)(i[a].add==="after"?n:o).push(i[a]);wn(n,0,0,o)}function _m(n,i){const a=Number.parseInt(n,i);return a<9||a===11||a>13&&a<32||a>126&&a<160||a>55295&&a<57344||a>64975&&a<65008||(a&65535)===65535||(a&65535)===65534||a>1114111?"�":String.fromCodePoint(a)}function yr(n){return n.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const _n=ol(/[A-Za-z]/),Xt=ol(/[\dA-Za-z]/),ax=ol(/[#-'*+\--9=?A-Z^-~]/);function ru(n){return n!==null&&(n<32||n===127)}const iu=ol(/\d/),ox=ol(/[\dA-Fa-f]/),sx=ol(/[!-/:-@[-`{-~]/);function xe(n){return n!==null&&n<-2}function jt(n){return n!==null&&(n<0||n===32)}function Ve(n){return n===-2||n===-1||n===32}const ux=ol(new RegExp("\\p{P}|\\p{S}","u")),cx=ol(/\s/);function ol(n){return i;function i(a){return a!==null&&a>-1&&n.test(String.fromCharCode(a))}}function vr(n){const i=[];let a=-1,o=0,s=0;for(;++a<n.length;){const c=n.charCodeAt(a);let d="";if(c===37&&Xt(n.charCodeAt(a+1))&&Xt(n.charCodeAt(a+2)))s=2;else if(c<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(c))||(d=String.fromCharCode(c));else if(c>55295&&c<57344){const h=n.charCodeAt(a+1);c<56320&&h>56319&&h<57344?(d=String.fromCharCode(c,h),s=1):d="�"}else d=String.fromCharCode(c);d&&(i.push(n.slice(o,a),encodeURIComponent(d)),o=a+s+1,d=""),s&&(a+=s,s=0)}return i.join("")+n.slice(o)}function nt(n,i,a,o){const s=o?o-1:Number.POSITIVE_INFINITY;let c=0;return d;function d(p){return Ve(p)?(n.enter(a),h(p)):i(p)}function h(p){return Ve(p)&&c++<s?(n.consume(p),h):(n.exit(a),i(p))}}const fx={tokenize:dx};function dx(n){const i=n.attempt(this.parser.constructs.contentInitial,o,s);let a;return i;function o(h){if(h===null){n.consume(h);return}return n.enter("lineEnding"),n.consume(h),n.exit("lineEnding"),nt(n,i,"linePrefix")}function s(h){return n.enter("paragraph"),c(h)}function c(h){const p=n.enter("chunkText",{contentType:"text",previous:a});return a&&(a.next=p),a=p,d(h)}function d(h){if(h===null){n.exit("chunkText"),n.exit("paragraph"),n.consume(h);return}return xe(h)?(n.consume(h),n.exit("chunkText"),c):(n.consume(h),d)}}const hx={tokenize:mx},Am={tokenize:px};function mx(n){const i=this,a=[];let o=0,s,c,d;return h;function h(H){if(o<a.length){const K=a[o];return i.containerState=K[1],n.attempt(K[0].continuation,p,m)(H)}return m(H)}function p(H){if(o++,i.containerState._closeFlow){i.containerState._closeFlow=void 0,s&&q();const K=i.events.length;let $=K,M;for(;$--;)if(i.events[$][0]==="exit"&&i.events[$][1].type==="chunkFlow"){M=i.events[$][1].end;break}_(o);let z=K;for(;z<i.events.length;)i.events[z][1].end={...M},z++;return wn(i.events,$+1,0,i.events.slice(K)),i.events.length=z,m(H)}return h(H)}function m(H){if(o===a.length){if(!s)return b(H);if(s.currentConstruct&&s.currentConstruct.concrete)return O(H);i.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return i.containerState={},n.check(Am,g,y)(H)}function g(H){return s&&q(),_(o),b(H)}function y(H){return i.parser.lazy[i.now().line]=o!==a.length,d=i.now().offset,O(H)}function b(H){return i.containerState={},n.attempt(Am,S,O)(H)}function S(H){return o++,a.push([i.currentConstruct,i.containerState]),b(H)}function O(H){if(H===null){s&&q(),_(0),n.consume(H);return}return s=s||i.parser.flow(i.now()),n.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:c}),R(H)}function R(H){if(H===null){j(n.exit("chunkFlow"),!0),_(0),n.consume(H);return}return xe(H)?(n.consume(H),j(n.exit("chunkFlow")),o=0,i.interrupt=void 0,h):(n.consume(H),R)}function j(H,K){const $=i.sliceStream(H);if(K&&$.push(null),H.previous=c,c&&(c.next=H),c=H,s.defineSkip(H.start),s.write($),i.parser.lazy[H.start.line]){let M=s.events.length;for(;M--;)if(s.events[M][1].start.offset<d&&(!s.events[M][1].end||s.events[M][1].end.offset>d))return;const z=i.events.length;let D=z,P,te;for(;D--;)if(i.events[D][0]==="exit"&&i.events[D][1].type==="chunkFlow"){if(P){te=i.events[D][1].end;break}P=!0}for(_(o),M=z;M<i.events.length;)i.events[M][1].end={...te},M++;wn(i.events,D+1,0,i.events.slice(z)),i.events.length=M}}function _(H){let K=a.length;for(;K-- >H;){const $=a[K];i.containerState=$[1],$[0].exit.call(i,n)}a.length=H}function q(){s.write([null]),c=void 0,s=void 0,i.containerState._closeFlow=void 0}}function px(n,i,a){return nt(n,n.attempt(this.parser.constructs.document,i,a),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Nm(n){if(n===null||jt(n)||cx(n))return 1;if(ux(n))return 2}function au(n,i,a){const o=[];let s=-1;for(;++s<n.length;){const c=n[s].resolveAll;c&&!o.includes(c)&&(i=c(i,a),o.push(c))}return i}const ou={name:"attention",resolveAll:gx,tokenize:yx};function gx(n,i){let a=-1,o,s,c,d,h,p,m,g;for(;++a<n.length;)if(n[a][0]==="enter"&&n[a][1].type==="attentionSequence"&&n[a][1]._close){for(o=a;o--;)if(n[o][0]==="exit"&&n[o][1].type==="attentionSequence"&&n[o][1]._open&&i.sliceSerialize(n[o][1]).charCodeAt(0)===i.sliceSerialize(n[a][1]).charCodeAt(0)){if((n[o][1]._close||n[a][1]._open)&&(n[a][1].end.offset-n[a][1].start.offset)%3&&!((n[o][1].end.offset-n[o][1].start.offset+n[a][1].end.offset-n[a][1].start.offset)%3))continue;p=n[o][1].end.offset-n[o][1].start.offset>1&&n[a][1].end.offset-n[a][1].start.offset>1?2:1;const y={...n[o][1].end},b={...n[a][1].start};Rm(y,-p),Rm(b,p),d={type:p>1?"strongSequence":"emphasisSequence",start:y,end:{...n[o][1].end}},h={type:p>1?"strongSequence":"emphasisSequence",start:{...n[a][1].start},end:b},c={type:p>1?"strongText":"emphasisText",start:{...n[o][1].end},end:{...n[a][1].start}},s={type:p>1?"strong":"emphasis",start:{...d.start},end:{...h.end}},n[o][1].end={...d.start},n[a][1].start={...h.end},m=[],n[o][1].end.offset-n[o][1].start.offset&&(m=rn(m,[["enter",n[o][1],i],["exit",n[o][1],i]])),m=rn(m,[["enter",s,i],["enter",d,i],["exit",d,i],["enter",c,i]]),m=rn(m,au(i.parser.constructs.insideSpan.null,n.slice(o+1,a),i)),m=rn(m,[["exit",c,i],["enter",h,i],["exit",h,i],["exit",s,i]]),n[a][1].end.offset-n[a][1].start.offset?(g=2,m=rn(m,[["enter",n[a][1],i],["exit",n[a][1],i]])):g=0,wn(n,o-1,a-o+3,m),a=o+m.length-g-2;break}}for(a=-1;++a<n.length;)n[a][1].type==="attentionSequence"&&(n[a][1].type="data");return n}function yx(n,i){const a=this.parser.constructs.attentionMarkers.null,o=this.previous,s=Nm(o);let c;return d;function d(p){return c=p,n.enter("attentionSequence"),h(p)}function h(p){if(p===c)return n.consume(p),h;const m=n.exit("attentionSequence"),g=Nm(p),y=!g||g===2&&s||a.includes(p),b=!s||s===2&&g||a.includes(o);return m._open=!!(c===42?y:y&&(s||!b)),m._close=!!(c===42?b:b&&(g||!y)),i(p)}}function Rm(n,i){n.column+=i,n.offset+=i,n._bufferIndex+=i}const vx={name:"autolink",tokenize:bx};function bx(n,i,a){let o=0;return s;function s(S){return n.enter("autolink"),n.enter("autolinkMarker"),n.consume(S),n.exit("autolinkMarker"),n.enter("autolinkProtocol"),c}function c(S){return _n(S)?(n.consume(S),d):S===64?a(S):m(S)}function d(S){return S===43||S===45||S===46||Xt(S)?(o=1,h(S)):m(S)}function h(S){return S===58?(n.consume(S),o=0,p):(S===43||S===45||S===46||Xt(S))&&o++<32?(n.consume(S),h):(o=0,m(S))}function p(S){return S===62?(n.exit("autolinkProtocol"),n.enter("autolinkMarker"),n.consume(S),n.exit("autolinkMarker"),n.exit("autolink"),i):S===null||S===32||S===60||ru(S)?a(S):(n.consume(S),p)}function m(S){return S===64?(n.consume(S),g):ax(S)?(n.consume(S),m):a(S)}function g(S){return Xt(S)?y(S):a(S)}function y(S){return S===46?(n.consume(S),o=0,g):S===62?(n.exit("autolinkProtocol").type="autolinkEmail",n.enter("autolinkMarker"),n.consume(S),n.exit("autolinkMarker"),n.exit("autolink"),i):b(S)}function b(S){if((S===45||Xt(S))&&o++<63){const O=S===45?b:y;return n.consume(S),O}return a(S)}}const Ua={partial:!0,tokenize:Sx};function Sx(n,i,a){return o;function o(c){return Ve(c)?nt(n,s,"linePrefix")(c):s(c)}function s(c){return c===null||xe(c)?i(c):a(c)}}const Om={continuation:{tokenize:xx},exit:Tx,name:"blockQuote",tokenize:Ex};function Ex(n,i,a){const o=this;return s;function s(d){if(d===62){const h=o.containerState;return h.open||(n.enter("blockQuote",{_container:!0}),h.open=!0),n.enter("blockQuotePrefix"),n.enter("blockQuoteMarker"),n.consume(d),n.exit("blockQuoteMarker"),c}return a(d)}function c(d){return Ve(d)?(n.enter("blockQuotePrefixWhitespace"),n.consume(d),n.exit("blockQuotePrefixWhitespace"),n.exit("blockQuotePrefix"),i):(n.exit("blockQuotePrefix"),i(d))}}function xx(n,i,a){const o=this;return s;function s(d){return Ve(d)?nt(n,c,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d):c(d)}function c(d){return n.attempt(Om,i,a)(d)}}function Tx(n){n.exit("blockQuote")}const Mm={name:"characterEscape",tokenize:Cx};function Cx(n,i,a){return o;function o(c){return n.enter("characterEscape"),n.enter("escapeMarker"),n.consume(c),n.exit("escapeMarker"),s}function s(c){return sx(c)?(n.enter("characterEscapeValue"),n.consume(c),n.exit("characterEscapeValue"),n.exit("characterEscape"),i):a(c)}}const km={name:"characterReference",tokenize:wx};function wx(n,i,a){const o=this;let s=0,c,d;return h;function h(y){return n.enter("characterReference"),n.enter("characterReferenceMarker"),n.consume(y),n.exit("characterReferenceMarker"),p}function p(y){return y===35?(n.enter("characterReferenceMarkerNumeric"),n.consume(y),n.exit("characterReferenceMarkerNumeric"),m):(n.enter("characterReferenceValue"),c=31,d=Xt,g(y))}function m(y){return y===88||y===120?(n.enter("characterReferenceMarkerHexadecimal"),n.consume(y),n.exit("characterReferenceMarkerHexadecimal"),n.enter("characterReferenceValue"),c=6,d=ox,g):(n.enter("characterReferenceValue"),c=7,d=iu,g(y))}function g(y){if(y===59&&s){const b=n.exit("characterReferenceValue");return d===Xt&&!lu(o.sliceSerialize(b))?a(y):(n.enter("characterReferenceMarker"),n.consume(y),n.exit("characterReferenceMarker"),n.exit("characterReference"),i)}return d(y)&&s++<c?(n.consume(y),g):a(y)}}const zm={partial:!0,tokenize:Ax},Dm={concrete:!0,name:"codeFenced",tokenize:_x};function _x(n,i,a){const o=this,s={partial:!0,tokenize:$};let c=0,d=0,h;return p;function p(M){return m(M)}function m(M){const z=o.events[o.events.length-1];return c=z&&z[1].type==="linePrefix"?z[2].sliceSerialize(z[1],!0).length:0,h=M,n.enter("codeFenced"),n.enter("codeFencedFence"),n.enter("codeFencedFenceSequence"),g(M)}function g(M){return M===h?(d++,n.consume(M),g):d<3?a(M):(n.exit("codeFencedFenceSequence"),Ve(M)?nt(n,y,"whitespace")(M):y(M))}function y(M){return M===null||xe(M)?(n.exit("codeFencedFence"),o.interrupt?i(M):n.check(zm,R,K)(M)):(n.enter("codeFencedFenceInfo"),n.enter("chunkString",{contentType:"string"}),b(M))}function b(M){return M===null||xe(M)?(n.exit("chunkString"),n.exit("codeFencedFenceInfo"),y(M)):Ve(M)?(n.exit("chunkString"),n.exit("codeFencedFenceInfo"),nt(n,S,"whitespace")(M)):M===96&&M===h?a(M):(n.consume(M),b)}function S(M){return M===null||xe(M)?y(M):(n.enter("codeFencedFenceMeta"),n.enter("chunkString",{contentType:"string"}),O(M))}function O(M){return M===null||xe(M)?(n.exit("chunkString"),n.exit("codeFencedFenceMeta"),y(M)):M===96&&M===h?a(M):(n.consume(M),O)}function R(M){return n.attempt(s,K,j)(M)}function j(M){return n.enter("lineEnding"),n.consume(M),n.exit("lineEnding"),_}function _(M){return c>0&&Ve(M)?nt(n,q,"linePrefix",c+1)(M):q(M)}function q(M){return M===null||xe(M)?n.check(zm,R,K)(M):(n.enter("codeFlowValue"),H(M))}function H(M){return M===null||xe(M)?(n.exit("codeFlowValue"),q(M)):(n.consume(M),H)}function K(M){return n.exit("codeFenced"),i(M)}function $(M,z,D){let P=0;return te;function te(ee){return M.enter("lineEnding"),M.consume(ee),M.exit("lineEnding"),ne}function ne(ee){return M.enter("codeFencedFence"),Ve(ee)?nt(M,re,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(ee):re(ee)}function re(ee){return ee===h?(M.enter("codeFencedFenceSequence"),we(ee)):D(ee)}function we(ee){return ee===h?(P++,M.consume(ee),we):P>=d?(M.exit("codeFencedFenceSequence"),Ve(ee)?nt(M,ce,"whitespace")(ee):ce(ee)):D(ee)}function ce(ee){return ee===null||xe(ee)?(M.exit("codeFencedFence"),z(ee)):D(ee)}}}function Ax(n,i,a){const o=this;return s;function s(d){return d===null?a(d):(n.enter("lineEnding"),n.consume(d),n.exit("lineEnding"),c)}function c(d){return o.parser.lazy[o.now().line]?a(d):i(d)}}const su={name:"codeIndented",tokenize:Rx},Nx={partial:!0,tokenize:Ox};function Rx(n,i,a){const o=this;return s;function s(m){return n.enter("codeIndented"),nt(n,c,"linePrefix",5)(m)}function c(m){const g=o.events[o.events.length-1];return g&&g[1].type==="linePrefix"&&g[2].sliceSerialize(g[1],!0).length>=4?d(m):a(m)}function d(m){return m===null?p(m):xe(m)?n.attempt(Nx,d,p)(m):(n.enter("codeFlowValue"),h(m))}function h(m){return m===null||xe(m)?(n.exit("codeFlowValue"),d(m)):(n.consume(m),h)}function p(m){return n.exit("codeIndented"),i(m)}}function Ox(n,i,a){const o=this;return s;function s(d){return o.parser.lazy[o.now().line]?a(d):xe(d)?(n.enter("lineEnding"),n.consume(d),n.exit("lineEnding"),s):nt(n,c,"linePrefix",5)(d)}function c(d){const h=o.events[o.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?i(d):xe(d)?s(d):a(d)}}const Mx={name:"codeText",previous:zx,resolve:kx,tokenize:Dx};function kx(n){let i=n.length-4,a=3,o,s;if((n[a][1].type==="lineEnding"||n[a][1].type==="space")&&(n[i][1].type==="lineEnding"||n[i][1].type==="space")){for(o=a;++o<i;)if(n[o][1].type==="codeTextData"){n[a][1].type="codeTextPadding",n[i][1].type="codeTextPadding",a+=2,i-=2;break}}for(o=a-1,i++;++o<=i;)s===void 0?o!==i&&n[o][1].type!=="lineEnding"&&(s=o):(o===i||n[o][1].type==="lineEnding")&&(n[s][1].type="codeTextData",o!==s+2&&(n[s][1].end=n[o-1][1].end,n.splice(s+2,o-s-2),i-=o-s-2,o=s+2),s=void 0);return n}function zx(n){return n!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Dx(n,i,a){let o=0,s,c;return d;function d(y){return n.enter("codeText"),n.enter("codeTextSequence"),h(y)}function h(y){return y===96?(n.consume(y),o++,h):(n.exit("codeTextSequence"),p(y))}function p(y){return y===null?a(y):y===32?(n.enter("space"),n.consume(y),n.exit("space"),p):y===96?(c=n.enter("codeTextSequence"),s=0,g(y)):xe(y)?(n.enter("lineEnding"),n.consume(y),n.exit("lineEnding"),p):(n.enter("codeTextData"),m(y))}function m(y){return y===null||y===32||y===96||xe(y)?(n.exit("codeTextData"),p(y)):(n.consume(y),m)}function g(y){return y===96?(n.consume(y),s++,g):s===o?(n.exit("codeTextSequence"),n.exit("codeText"),i(y)):(c.type="codeTextData",m(y))}}class jx{constructor(i){this.left=i?[...i]:[],this.right=[]}get(i){if(i<0||i>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+i+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return i<this.left.length?this.left[i]:this.right[this.right.length-i+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(i,a){const o=a??Number.POSITIVE_INFINITY;return o<this.left.length?this.left.slice(i,o):i>this.left.length?this.right.slice(this.right.length-o+this.left.length,this.right.length-i+this.left.length).reverse():this.left.slice(i).concat(this.right.slice(this.right.length-o+this.left.length).reverse())}splice(i,a,o){const s=a||0;this.setCursor(Math.trunc(i));const c=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return o&&Oi(this.left,o),c.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(i){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(i)}pushMany(i){this.setCursor(Number.POSITIVE_INFINITY),Oi(this.left,i)}unshift(i){this.setCursor(0),this.right.push(i)}unshiftMany(i){this.setCursor(0),Oi(this.right,i.reverse())}setCursor(i){if(!(i===this.left.length||i>this.left.length&&this.right.length===0||i<0&&this.left.length===0))if(i<this.left.length){const a=this.left.splice(i,Number.POSITIVE_INFINITY);Oi(this.right,a.reverse())}else{const a=this.right.splice(this.left.length+this.right.length-i,Number.POSITIVE_INFINITY);Oi(this.left,a.reverse())}}}function Oi(n,i){let a=0;if(i.length<1e4)n.push(...i);else for(;a<i.length;)n.push(...i.slice(a,a+1e4)),a+=1e4}function jm(n){const i={};let a=-1,o,s,c,d,h,p,m;const g=new jx(n);for(;++a<g.length;){for(;a in i;)a=i[a];if(o=g.get(a),a&&o[1].type==="chunkFlow"&&g.get(a-1)[1].type==="listItemPrefix"&&(p=o[1]._tokenizer.events,c=0,c<p.length&&p[c][1].type==="lineEndingBlank"&&(c+=2),c<p.length&&p[c][1].type==="content"))for(;++c<p.length&&p[c][1].type!=="content";)p[c][1].type==="chunkText"&&(p[c][1]._isInFirstContentOfListItem=!0,c++);if(o[0]==="enter")o[1].contentType&&(Object.assign(i,Lx(g,a)),a=i[a],m=!0);else if(o[1]._container){for(c=a,s=void 0;c--;)if(d=g.get(c),d[1].type==="lineEnding"||d[1].type==="lineEndingBlank")d[0]==="enter"&&(s&&(g.get(s)[1].type="lineEndingBlank"),d[1].type="lineEnding",s=c);else if(!(d[1].type==="linePrefix"||d[1].type==="listItemIndent"))break;s&&(o[1].end={...g.get(s)[1].start},h=g.slice(s,a),h.unshift(o),g.splice(s,a-s+1,h))}}return wn(n,0,Number.POSITIVE_INFINITY,g.slice(0)),!m}function Lx(n,i){const a=n.get(i)[1],o=n.get(i)[2];let s=i-1;const c=[];let d=a._tokenizer;d||(d=o.parser[a.contentType](a.start),a._contentTypeTextTrailing&&(d._contentTypeTextTrailing=!0));const h=d.events,p=[],m={};let g,y,b=-1,S=a,O=0,R=0;const j=[R];for(;S;){for(;n.get(++s)[1]!==S;);c.push(s),S._tokenizer||(g=o.sliceStream(S),S.next||g.push(null),y&&d.defineSkip(S.start),S._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=!0),d.write(g),S._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=void 0)),y=S,S=S.next}for(S=a;++b<h.length;)h[b][0]==="exit"&&h[b-1][0]==="enter"&&h[b][1].type===h[b-1][1].type&&h[b][1].start.line!==h[b][1].end.line&&(R=b+1,j.push(R),S._tokenizer=void 0,S.previous=void 0,S=S.next);for(d.events=[],S?(S._tokenizer=void 0,S.previous=void 0):j.pop(),b=j.length;b--;){const _=h.slice(j[b],j[b+1]),q=c.pop();p.push([q,q+_.length-1]),n.splice(q,2,_)}for(p.reverse(),b=-1;++b<p.length;)m[O+p[b][0]]=O+p[b][1],O+=p[b][1]-p[b][0]-1;return m}const Ux={resolve:Ix,tokenize:Hx},Bx={partial:!0,tokenize:qx};function Ix(n){return jm(n),n}function Hx(n,i){let a;return o;function o(h){return n.enter("content"),a=n.enter("chunkContent",{contentType:"content"}),s(h)}function s(h){return h===null?c(h):xe(h)?n.check(Bx,d,c)(h):(n.consume(h),s)}function c(h){return n.exit("chunkContent"),n.exit("content"),i(h)}function d(h){return n.consume(h),n.exit("chunkContent"),a.next=n.enter("chunkContent",{contentType:"content",previous:a}),a=a.next,s}}function qx(n,i,a){const o=this;return s;function s(d){return n.exit("chunkContent"),n.enter("lineEnding"),n.consume(d),n.exit("lineEnding"),nt(n,c,"linePrefix")}function c(d){if(d===null||xe(d))return a(d);const h=o.events[o.events.length-1];return!o.parser.constructs.disable.null.includes("codeIndented")&&h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?i(d):n.interrupt(o.parser.constructs.flow,a,i)(d)}}function Lm(n,i,a,o,s,c,d,h,p){const m=p||Number.POSITIVE_INFINITY;let g=0;return y;function y(_){return _===60?(n.enter(o),n.enter(s),n.enter(c),n.consume(_),n.exit(c),b):_===null||_===32||_===41||ru(_)?a(_):(n.enter(o),n.enter(d),n.enter(h),n.enter("chunkString",{contentType:"string"}),R(_))}function b(_){return _===62?(n.enter(c),n.consume(_),n.exit(c),n.exit(s),n.exit(o),i):(n.enter(h),n.enter("chunkString",{contentType:"string"}),S(_))}function S(_){return _===62?(n.exit("chunkString"),n.exit(h),b(_)):_===null||_===60||xe(_)?a(_):(n.consume(_),_===92?O:S)}function O(_){return _===60||_===62||_===92?(n.consume(_),S):S(_)}function R(_){return!g&&(_===null||_===41||jt(_))?(n.exit("chunkString"),n.exit(h),n.exit(d),n.exit(o),i(_)):g<m&&_===40?(n.consume(_),g++,R):_===41?(n.consume(_),g--,R):_===null||_===32||_===40||ru(_)?a(_):(n.consume(_),_===92?j:R)}function j(_){return _===40||_===41||_===92?(n.consume(_),R):R(_)}}function Um(n,i,a,o,s,c){const d=this;let h=0,p;return m;function m(S){return n.enter(o),n.enter(s),n.consume(S),n.exit(s),n.enter(c),g}function g(S){return h>999||S===null||S===91||S===93&&!p||S===94&&!h&&"_hiddenFootnoteSupport"in d.parser.constructs?a(S):S===93?(n.exit(c),n.enter(s),n.consume(S),n.exit(s),n.exit(o),i):xe(S)?(n.enter("lineEnding"),n.consume(S),n.exit("lineEnding"),g):(n.enter("chunkString",{contentType:"string"}),y(S))}function y(S){return S===null||S===91||S===93||xe(S)||h++>999?(n.exit("chunkString"),g(S)):(n.consume(S),p||(p=!Ve(S)),S===92?b:y)}function b(S){return S===91||S===92||S===93?(n.consume(S),h++,y):y(S)}}function Bm(n,i,a,o,s,c){let d;return h;function h(b){return b===34||b===39||b===40?(n.enter(o),n.enter(s),n.consume(b),n.exit(s),d=b===40?41:b,p):a(b)}function p(b){return b===d?(n.enter(s),n.consume(b),n.exit(s),n.exit(o),i):(n.enter(c),m(b))}function m(b){return b===d?(n.exit(c),p(d)):b===null?a(b):xe(b)?(n.enter("lineEnding"),n.consume(b),n.exit("lineEnding"),nt(n,m,"linePrefix")):(n.enter("chunkString",{contentType:"string"}),g(b))}function g(b){return b===d||b===null||xe(b)?(n.exit("chunkString"),m(b)):(n.consume(b),b===92?y:g)}function y(b){return b===d||b===92?(n.consume(b),g):g(b)}}function Mi(n,i){let a;return o;function o(s){return xe(s)?(n.enter("lineEnding"),n.consume(s),n.exit("lineEnding"),a=!0,o):Ve(s)?nt(n,o,a?"linePrefix":"lineSuffix")(s):i(s)}}const Yx={name:"definition",tokenize:Gx},Vx={partial:!0,tokenize:Px};function Gx(n,i,a){const o=this;let s;return c;function c(S){return n.enter("definition"),d(S)}function d(S){return Um.call(o,n,h,a,"definitionLabel","definitionLabelMarker","definitionLabelString")(S)}function h(S){return s=yr(o.sliceSerialize(o.events[o.events.length-1][1]).slice(1,-1)),S===58?(n.enter("definitionMarker"),n.consume(S),n.exit("definitionMarker"),p):a(S)}function p(S){return jt(S)?Mi(n,m)(S):m(S)}function m(S){return Lm(n,g,a,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(S)}function g(S){return n.attempt(Vx,y,y)(S)}function y(S){return Ve(S)?nt(n,b,"whitespace")(S):b(S)}function b(S){return S===null||xe(S)?(n.exit("definition"),o.parser.defined.push(s),i(S)):a(S)}}function Px(n,i,a){return o;function o(h){return jt(h)?Mi(n,s)(h):a(h)}function s(h){return Bm(n,c,a,"definitionTitle","definitionTitleMarker","definitionTitleString")(h)}function c(h){return Ve(h)?nt(n,d,"whitespace")(h):d(h)}function d(h){return h===null||xe(h)?i(h):a(h)}}const Fx={name:"hardBreakEscape",tokenize:Xx};function Xx(n,i,a){return o;function o(c){return n.enter("hardBreakEscape"),n.consume(c),s}function s(c){return xe(c)?(n.exit("hardBreakEscape"),i(c)):a(c)}}const Kx={name:"headingAtx",resolve:Qx,tokenize:Zx};function Qx(n,i){let a=n.length-2,o=3,s,c;return n[o][1].type==="whitespace"&&(o+=2),a-2>o&&n[a][1].type==="whitespace"&&(a-=2),n[a][1].type==="atxHeadingSequence"&&(o===a-1||a-4>o&&n[a-2][1].type==="whitespace")&&(a-=o+1===a?2:4),a>o&&(s={type:"atxHeadingText",start:n[o][1].start,end:n[a][1].end},c={type:"chunkText",start:n[o][1].start,end:n[a][1].end,contentType:"text"},wn(n,o,a-o+1,[["enter",s,i],["enter",c,i],["exit",c,i],["exit",s,i]])),n}function Zx(n,i,a){let o=0;return s;function s(g){return n.enter("atxHeading"),c(g)}function c(g){return n.enter("atxHeadingSequence"),d(g)}function d(g){return g===35&&o++<6?(n.consume(g),d):g===null||jt(g)?(n.exit("atxHeadingSequence"),h(g)):a(g)}function h(g){return g===35?(n.enter("atxHeadingSequence"),p(g)):g===null||xe(g)?(n.exit("atxHeading"),i(g)):Ve(g)?nt(n,h,"whitespace")(g):(n.enter("atxHeadingText"),m(g))}function p(g){return g===35?(n.consume(g),p):(n.exit("atxHeadingSequence"),h(g))}function m(g){return g===null||g===35||jt(g)?(n.exit("atxHeadingText"),h(g)):(n.consume(g),m)}}const Jx=["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","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Im=["pre","script","style","textarea"],Wx={concrete:!0,name:"htmlFlow",resolveTo:t1,tokenize:n1},$x={partial:!0,tokenize:r1},e1={partial:!0,tokenize:l1};function t1(n){let i=n.length;for(;i--&&!(n[i][0]==="enter"&&n[i][1].type==="htmlFlow"););return i>1&&n[i-2][1].type==="linePrefix"&&(n[i][1].start=n[i-2][1].start,n[i+1][1].start=n[i-2][1].start,n.splice(i-2,2)),n}function n1(n,i,a){const o=this;let s,c,d,h,p;return m;function m(T){return g(T)}function g(T){return n.enter("htmlFlow"),n.enter("htmlFlowData"),n.consume(T),y}function y(T){return T===33?(n.consume(T),b):T===47?(n.consume(T),c=!0,R):T===63?(n.consume(T),s=3,o.interrupt?i:C):_n(T)?(n.consume(T),d=String.fromCharCode(T),j):a(T)}function b(T){return T===45?(n.consume(T),s=2,S):T===91?(n.consume(T),s=5,h=0,O):_n(T)?(n.consume(T),s=4,o.interrupt?i:C):a(T)}function S(T){return T===45?(n.consume(T),o.interrupt?i:C):a(T)}function O(T){const le="CDATA[";return T===le.charCodeAt(h++)?(n.consume(T),h===le.length?o.interrupt?i:re:O):a(T)}function R(T){return _n(T)?(n.consume(T),d=String.fromCharCode(T),j):a(T)}function j(T){if(T===null||T===47||T===62||jt(T)){const le=T===47,he=d.toLowerCase();return!le&&!c&&Im.includes(he)?(s=1,o.interrupt?i(T):re(T)):Jx.includes(d.toLowerCase())?(s=6,le?(n.consume(T),_):o.interrupt?i(T):re(T)):(s=7,o.interrupt&&!o.parser.lazy[o.now().line]?a(T):c?q(T):H(T))}return T===45||Xt(T)?(n.consume(T),d+=String.fromCharCode(T),j):a(T)}function _(T){return T===62?(n.consume(T),o.interrupt?i:re):a(T)}function q(T){return Ve(T)?(n.consume(T),q):te(T)}function H(T){return T===47?(n.consume(T),te):T===58||T===95||_n(T)?(n.consume(T),K):Ve(T)?(n.consume(T),H):te(T)}function K(T){return T===45||T===46||T===58||T===95||Xt(T)?(n.consume(T),K):$(T)}function $(T){return T===61?(n.consume(T),M):Ve(T)?(n.consume(T),$):H(T)}function M(T){return T===null||T===60||T===61||T===62||T===96?a(T):T===34||T===39?(n.consume(T),p=T,z):Ve(T)?(n.consume(T),M):D(T)}function z(T){return T===p?(n.consume(T),p=null,P):T===null||xe(T)?a(T):(n.consume(T),z)}function D(T){return T===null||T===34||T===39||T===47||T===60||T===61||T===62||T===96||jt(T)?$(T):(n.consume(T),D)}function P(T){return T===47||T===62||Ve(T)?H(T):a(T)}function te(T){return T===62?(n.consume(T),ne):a(T)}function ne(T){return T===null||xe(T)?re(T):Ve(T)?(n.consume(T),ne):a(T)}function re(T){return T===45&&s===2?(n.consume(T),U):T===60&&s===1?(n.consume(T),W):T===62&&s===4?(n.consume(T),A):T===63&&s===3?(n.consume(T),C):T===93&&s===5?(n.consume(T),ie):xe(T)&&(s===6||s===7)?(n.exit("htmlFlowData"),n.check($x,V,we)(T)):T===null||xe(T)?(n.exit("htmlFlowData"),we(T)):(n.consume(T),re)}function we(T){return n.check(e1,ce,V)(T)}function ce(T){return n.enter("lineEnding"),n.consume(T),n.exit("lineEnding"),ee}function ee(T){return T===null||xe(T)?we(T):(n.enter("htmlFlowData"),re(T))}function U(T){return T===45?(n.consume(T),C):re(T)}function W(T){return T===47?(n.consume(T),d="",Z):re(T)}function Z(T){if(T===62){const le=d.toLowerCase();return Im.includes(le)?(n.consume(T),A):re(T)}return _n(T)&&d.length<8?(n.consume(T),d+=String.fromCharCode(T),Z):re(T)}function ie(T){return T===93?(n.consume(T),C):re(T)}function C(T){return T===62?(n.consume(T),A):T===45&&s===2?(n.consume(T),C):re(T)}function A(T){return T===null||xe(T)?(n.exit("htmlFlowData"),V(T)):(n.consume(T),A)}function V(T){return n.exit("htmlFlow"),i(T)}}function l1(n,i,a){const o=this;return s;function s(d){return xe(d)?(n.enter("lineEnding"),n.consume(d),n.exit("lineEnding"),c):a(d)}function c(d){return o.parser.lazy[o.now().line]?a(d):i(d)}}function r1(n,i,a){return o;function o(s){return n.enter("lineEnding"),n.consume(s),n.exit("lineEnding"),n.attempt(Ua,i,a)}}const i1={name:"htmlText",tokenize:a1};function a1(n,i,a){const o=this;let s,c,d;return h;function h(C){return n.enter("htmlText"),n.enter("htmlTextData"),n.consume(C),p}function p(C){return C===33?(n.consume(C),m):C===47?(n.consume(C),$):C===63?(n.consume(C),H):_n(C)?(n.consume(C),D):a(C)}function m(C){return C===45?(n.consume(C),g):C===91?(n.consume(C),c=0,O):_n(C)?(n.consume(C),q):a(C)}function g(C){return C===45?(n.consume(C),S):a(C)}function y(C){return C===null?a(C):C===45?(n.consume(C),b):xe(C)?(d=y,W(C)):(n.consume(C),y)}function b(C){return C===45?(n.consume(C),S):y(C)}function S(C){return C===62?U(C):C===45?b(C):y(C)}function O(C){const A="CDATA[";return C===A.charCodeAt(c++)?(n.consume(C),c===A.length?R:O):a(C)}function R(C){return C===null?a(C):C===93?(n.consume(C),j):xe(C)?(d=R,W(C)):(n.consume(C),R)}function j(C){return C===93?(n.consume(C),_):R(C)}function _(C){return C===62?U(C):C===93?(n.consume(C),_):R(C)}function q(C){return C===null||C===62?U(C):xe(C)?(d=q,W(C)):(n.consume(C),q)}function H(C){return C===null?a(C):C===63?(n.consume(C),K):xe(C)?(d=H,W(C)):(n.consume(C),H)}function K(C){return C===62?U(C):H(C)}function $(C){return _n(C)?(n.consume(C),M):a(C)}function M(C){return C===45||Xt(C)?(n.consume(C),M):z(C)}function z(C){return xe(C)?(d=z,W(C)):Ve(C)?(n.consume(C),z):U(C)}function D(C){return C===45||Xt(C)?(n.consume(C),D):C===47||C===62||jt(C)?P(C):a(C)}function P(C){return C===47?(n.consume(C),U):C===58||C===95||_n(C)?(n.consume(C),te):xe(C)?(d=P,W(C)):Ve(C)?(n.consume(C),P):U(C)}function te(C){return C===45||C===46||C===58||C===95||Xt(C)?(n.consume(C),te):ne(C)}function ne(C){return C===61?(n.consume(C),re):xe(C)?(d=ne,W(C)):Ve(C)?(n.consume(C),ne):P(C)}function re(C){return C===null||C===60||C===61||C===62||C===96?a(C):C===34||C===39?(n.consume(C),s=C,we):xe(C)?(d=re,W(C)):Ve(C)?(n.consume(C),re):(n.consume(C),ce)}function we(C){return C===s?(n.consume(C),s=void 0,ee):C===null?a(C):xe(C)?(d=we,W(C)):(n.consume(C),we)}function ce(C){return C===null||C===34||C===39||C===60||C===61||C===96?a(C):C===47||C===62||jt(C)?P(C):(n.consume(C),ce)}function ee(C){return C===47||C===62||jt(C)?P(C):a(C)}function U(C){return C===62?(n.consume(C),n.exit("htmlTextData"),n.exit("htmlText"),i):a(C)}function W(C){return n.exit("htmlTextData"),n.enter("lineEnding"),n.consume(C),n.exit("lineEnding"),Z}function Z(C){return Ve(C)?nt(n,ie,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):ie(C)}function ie(C){return n.enter("htmlTextData"),d(C)}}const uu={name:"labelEnd",resolveAll:c1,resolveTo:f1,tokenize:d1},o1={tokenize:h1},s1={tokenize:m1},u1={tokenize:p1};function c1(n){let i=-1;const a=[];for(;++i<n.length;){const o=n[i][1];if(a.push(n[i]),o.type==="labelImage"||o.type==="labelLink"||o.type==="labelEnd"){const s=o.type==="labelImage"?4:2;o.type="data",i+=s}}return n.length!==a.length&&wn(n,0,n.length,a),n}function f1(n,i){let a=n.length,o=0,s,c,d,h;for(;a--;)if(s=n[a][1],c){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;n[a][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(d){if(n[a][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(c=a,s.type!=="labelLink")){o=2;break}}else s.type==="labelEnd"&&(d=a);const p={type:n[c][1].type==="labelLink"?"link":"image",start:{...n[c][1].start},end:{...n[n.length-1][1].end}},m={type:"label",start:{...n[c][1].start},end:{...n[d][1].end}},g={type:"labelText",start:{...n[c+o+2][1].end},end:{...n[d-2][1].start}};return h=[["enter",p,i],["enter",m,i]],h=rn(h,n.slice(c+1,c+o+3)),h=rn(h,[["enter",g,i]]),h=rn(h,au(i.parser.constructs.insideSpan.null,n.slice(c+o+4,d-3),i)),h=rn(h,[["exit",g,i],n[d-2],n[d-1],["exit",m,i]]),h=rn(h,n.slice(d+1)),h=rn(h,[["exit",p,i]]),wn(n,c,n.length,h),n}function d1(n,i,a){const o=this;let s=o.events.length,c,d;for(;s--;)if((o.events[s][1].type==="labelImage"||o.events[s][1].type==="labelLink")&&!o.events[s][1]._balanced){c=o.events[s][1];break}return h;function h(b){return c?c._inactive?y(b):(d=o.parser.defined.includes(yr(o.sliceSerialize({start:c.end,end:o.now()}))),n.enter("labelEnd"),n.enter("labelMarker"),n.consume(b),n.exit("labelMarker"),n.exit("labelEnd"),p):a(b)}function p(b){return b===40?n.attempt(o1,g,d?g:y)(b):b===91?n.attempt(s1,g,d?m:y)(b):d?g(b):y(b)}function m(b){return n.attempt(u1,g,y)(b)}function g(b){return i(b)}function y(b){return c._balanced=!0,a(b)}}function h1(n,i,a){return o;function o(y){return n.enter("resource"),n.enter("resourceMarker"),n.consume(y),n.exit("resourceMarker"),s}function s(y){return jt(y)?Mi(n,c)(y):c(y)}function c(y){return y===41?g(y):Lm(n,d,h,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(y)}function d(y){return jt(y)?Mi(n,p)(y):g(y)}function h(y){return a(y)}function p(y){return y===34||y===39||y===40?Bm(n,m,a,"resourceTitle","resourceTitleMarker","resourceTitleString")(y):g(y)}function m(y){return jt(y)?Mi(n,g)(y):g(y)}function g(y){return y===41?(n.enter("resourceMarker"),n.consume(y),n.exit("resourceMarker"),n.exit("resource"),i):a(y)}}function m1(n,i,a){const o=this;return s;function s(h){return Um.call(o,n,c,d,"reference","referenceMarker","referenceString")(h)}function c(h){return o.parser.defined.includes(yr(o.sliceSerialize(o.events[o.events.length-1][1]).slice(1,-1)))?i(h):a(h)}function d(h){return a(h)}}function p1(n,i,a){return o;function o(c){return n.enter("reference"),n.enter("referenceMarker"),n.consume(c),n.exit("referenceMarker"),s}function s(c){return c===93?(n.enter("referenceMarker"),n.consume(c),n.exit("referenceMarker"),n.exit("reference"),i):a(c)}}const g1={name:"labelStartImage",resolveAll:uu.resolveAll,tokenize:y1};function y1(n,i,a){const o=this;return s;function s(h){return n.enter("labelImage"),n.enter("labelImageMarker"),n.consume(h),n.exit("labelImageMarker"),c}function c(h){return h===91?(n.enter("labelMarker"),n.consume(h),n.exit("labelMarker"),n.exit("labelImage"),d):a(h)}function d(h){return h===94&&"_hiddenFootnoteSupport"in o.parser.constructs?a(h):i(h)}}const v1={name:"labelStartLink",resolveAll:uu.resolveAll,tokenize:b1};function b1(n,i,a){const o=this;return s;function s(d){return n.enter("labelLink"),n.enter("labelMarker"),n.consume(d),n.exit("labelMarker"),n.exit("labelLink"),c}function c(d){return d===94&&"_hiddenFootnoteSupport"in o.parser.constructs?a(d):i(d)}}const cu={name:"lineEnding",tokenize:S1};function S1(n,i){return a;function a(o){return n.enter("lineEnding"),n.consume(o),n.exit("lineEnding"),nt(n,i,"linePrefix")}}const Ba={name:"thematicBreak",tokenize:E1};function E1(n,i,a){let o=0,s;return c;function c(m){return n.enter("thematicBreak"),d(m)}function d(m){return s=m,h(m)}function h(m){return m===s?(n.enter("thematicBreakSequence"),p(m)):o>=3&&(m===null||xe(m))?(n.exit("thematicBreak"),i(m)):a(m)}function p(m){return m===s?(n.consume(m),o++,p):(n.exit("thematicBreakSequence"),Ve(m)?nt(n,h,"whitespace")(m):h(m))}}const Lt={continuation:{tokenize:w1},exit:A1,name:"list",tokenize:C1},x1={partial:!0,tokenize:N1},T1={partial:!0,tokenize:_1};function C1(n,i,a){const o=this,s=o.events[o.events.length-1];let c=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,d=0;return h;function h(S){const O=o.containerState.type||(S===42||S===43||S===45?"listUnordered":"listOrdered");if(O==="listUnordered"?!o.containerState.marker||S===o.containerState.marker:iu(S)){if(o.containerState.type||(o.containerState.type=O,n.enter(O,{_container:!0})),O==="listUnordered")return n.enter("listItemPrefix"),S===42||S===45?n.check(Ba,a,m)(S):m(S);if(!o.interrupt||S===49)return n.enter("listItemPrefix"),n.enter("listItemValue"),p(S)}return a(S)}function p(S){return iu(S)&&++d<10?(n.consume(S),p):(!o.interrupt||d<2)&&(o.containerState.marker?S===o.containerState.marker:S===41||S===46)?(n.exit("listItemValue"),m(S)):a(S)}function m(S){return n.enter("listItemMarker"),n.consume(S),n.exit("listItemMarker"),o.containerState.marker=o.containerState.marker||S,n.check(Ua,o.interrupt?a:g,n.attempt(x1,b,y))}function g(S){return o.containerState.initialBlankLine=!0,c++,b(S)}function y(S){return Ve(S)?(n.enter("listItemPrefixWhitespace"),n.consume(S),n.exit("listItemPrefixWhitespace"),b):a(S)}function b(S){return o.containerState.size=c+o.sliceSerialize(n.exit("listItemPrefix"),!0).length,i(S)}}function w1(n,i,a){const o=this;return o.containerState._closeFlow=void 0,n.check(Ua,s,c);function s(h){return o.containerState.furtherBlankLines=o.containerState.furtherBlankLines||o.containerState.initialBlankLine,nt(n,i,"listItemIndent",o.containerState.size+1)(h)}function c(h){return o.containerState.furtherBlankLines||!Ve(h)?(o.containerState.furtherBlankLines=void 0,o.containerState.initialBlankLine=void 0,d(h)):(o.containerState.furtherBlankLines=void 0,o.containerState.initialBlankLine=void 0,n.attempt(T1,i,d)(h))}function d(h){return o.containerState._closeFlow=!0,o.interrupt=void 0,nt(n,n.attempt(Lt,i,a),"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h)}}function _1(n,i,a){const o=this;return nt(n,s,"listItemIndent",o.containerState.size+1);function s(c){const d=o.events[o.events.length-1];return d&&d[1].type==="listItemIndent"&&d[2].sliceSerialize(d[1],!0).length===o.containerState.size?i(c):a(c)}}function A1(n){n.exit(this.containerState.type)}function N1(n,i,a){const o=this;return nt(n,s,"listItemPrefixWhitespace",o.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(c){const d=o.events[o.events.length-1];return!Ve(c)&&d&&d[1].type==="listItemPrefixWhitespace"?i(c):a(c)}}const Hm={name:"setextUnderline",resolveTo:R1,tokenize:O1};function R1(n,i){let a=n.length,o,s,c;for(;a--;)if(n[a][0]==="enter"){if(n[a][1].type==="content"){o=a;break}n[a][1].type==="paragraph"&&(s=a)}else n[a][1].type==="content"&&n.splice(a,1),!c&&n[a][1].type==="definition"&&(c=a);const d={type:"setextHeading",start:{...n[o][1].start},end:{...n[n.length-1][1].end}};return n[s][1].type="setextHeadingText",c?(n.splice(s,0,["enter",d,i]),n.splice(c+1,0,["exit",n[o][1],i]),n[o][1].end={...n[c][1].end}):n[o][1]=d,n.push(["exit",d,i]),n}function O1(n,i,a){const o=this;let s;return c;function c(m){let g=o.events.length,y;for(;g--;)if(o.events[g][1].type!=="lineEnding"&&o.events[g][1].type!=="linePrefix"&&o.events[g][1].type!=="content"){y=o.events[g][1].type==="paragraph";break}return!o.parser.lazy[o.now().line]&&(o.interrupt||y)?(n.enter("setextHeadingLine"),s=m,d(m)):a(m)}function d(m){return n.enter("setextHeadingLineSequence"),h(m)}function h(m){return m===s?(n.consume(m),h):(n.exit("setextHeadingLineSequence"),Ve(m)?nt(n,p,"lineSuffix")(m):p(m))}function p(m){return m===null||xe(m)?(n.exit("setextHeadingLine"),i(m)):a(m)}}const M1={tokenize:k1};function k1(n){const i=this,a=n.attempt(Ua,o,n.attempt(this.parser.constructs.flowInitial,s,nt(n,n.attempt(this.parser.constructs.flow,s,n.attempt(Ux,s)),"linePrefix")));return a;function o(c){if(c===null){n.consume(c);return}return n.enter("lineEndingBlank"),n.consume(c),n.exit("lineEndingBlank"),i.currentConstruct=void 0,a}function s(c){if(c===null){n.consume(c);return}return n.enter("lineEnding"),n.consume(c),n.exit("lineEnding"),i.currentConstruct=void 0,a}}const z1={resolveAll:Ym()},D1=qm("string"),j1=qm("text");function qm(n){return{resolveAll:Ym(n==="text"?L1:void 0),tokenize:i};function i(a){const o=this,s=this.parser.constructs[n],c=a.attempt(s,d,h);return d;function d(g){return m(g)?c(g):h(g)}function h(g){if(g===null){a.consume(g);return}return a.enter("data"),a.consume(g),p}function p(g){return m(g)?(a.exit("data"),c(g)):(a.consume(g),p)}function m(g){if(g===null)return!0;const y=s[g];let b=-1;if(y)for(;++b<y.length;){const S=y[b];if(!S.previous||S.previous.call(o,o.previous))return!0}return!1}}}function Ym(n){return i;function i(a,o){let s=-1,c;for(;++s<=a.length;)c===void 0?a[s]&&a[s][1].type==="data"&&(c=s,s++):(!a[s]||a[s][1].type!=="data")&&(s!==c+2&&(a[c][1].end=a[s-1][1].end,a.splice(c+2,s-c-2),s=c+2),c=void 0);return n?n(a,o):a}}function L1(n,i){let a=0;for(;++a<=n.length;)if((a===n.length||n[a][1].type==="lineEnding")&&n[a-1][1].type==="data"){const o=n[a-1][1],s=i.sliceStream(o);let c=s.length,d=-1,h=0,p;for(;c--;){const m=s[c];if(typeof m=="string"){for(d=m.length;m.charCodeAt(d-1)===32;)h++,d--;if(d)break;d=-1}else if(m===-2)p=!0,h++;else if(m!==-1){c++;break}}if(i._contentTypeTextTrailing&&a===n.length&&(h=0),h){const m={type:a===n.length||p||h<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:c?d:o.start._bufferIndex+d,_index:o.start._index+c,line:o.end.line,column:o.end.column-h,offset:o.end.offset-h},end:{...o.end}};o.end={...m.start},o.start.offset===o.end.offset?Object.assign(o,m):(n.splice(a,0,["enter",m,i],["exit",m,i]),a+=2)}a++}return n}const U1=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:{null:[42,95]},contentInitial:{91:Yx},disable:{null:[]},document:{42:Lt,43:Lt,45:Lt,48:Lt,49:Lt,50:Lt,51:Lt,52:Lt,53:Lt,54:Lt,55:Lt,56:Lt,57:Lt,62:Om},flow:{35:Kx,42:Ba,45:[Hm,Ba],60:Wx,61:Hm,95:Ba,96:Dm,126:Dm},flowInitial:{[-2]:su,[-1]:su,32:su},insideSpan:{null:[ou,z1]},string:{38:km,92:Mm},text:{[-5]:cu,[-4]:cu,[-3]:cu,33:g1,38:km,42:ou,60:[vx,i1],91:v1,92:[Fx,Mm],93:uu,95:ou,96:Mx}},Symbol.toStringTag,{value:"Module"}));function B1(n,i,a){let o={_bufferIndex:-1,_index:0,line:a&&a.line||1,column:a&&a.column||1,offset:a&&a.offset||0};const s={},c=[];let d=[],h=[];const p={attempt:z($),check:z(M),consume:q,enter:H,exit:K,interrupt:z(M,{interrupt:!0})},m={code:null,containerState:{},defineSkip:R,events:[],now:O,parser:n,previous:null,sliceSerialize:b,sliceStream:S,write:y};let g=i.tokenize.call(m,p);return i.resolveAll&&c.push(i),m;function y(ne){return d=rn(d,ne),j(),d[d.length-1]!==null?[]:(D(i,0),m.events=au(c,m.events,m),m.events)}function b(ne,re){return H1(S(ne),re)}function S(ne){return I1(d,ne)}function O(){const{_bufferIndex:ne,_index:re,line:we,column:ce,offset:ee}=o;return{_bufferIndex:ne,_index:re,line:we,column:ce,offset:ee}}function R(ne){s[ne.line]=ne.column,te()}function j(){let ne;for(;o._index<d.length;){const re=d[o._index];if(typeof re=="string")for(ne=o._index,o._bufferIndex<0&&(o._bufferIndex=0);o._index===ne&&o._bufferIndex<re.length;)_(re.charCodeAt(o._bufferIndex));else _(re)}}function _(ne){g=g(ne)}function q(ne){xe(ne)?(o.line++,o.column=1,o.offset+=ne===-3?2:1,te()):ne!==-1&&(o.column++,o.offset++),o._bufferIndex<0?o._index++:(o._bufferIndex++,o._bufferIndex===d[o._index].length&&(o._bufferIndex=-1,o._index++)),m.previous=ne}function H(ne,re){const we=re||{};return we.type=ne,we.start=O(),m.events.push(["enter",we,m]),h.push(we),we}function K(ne){const re=h.pop();return re.end=O(),m.events.push(["exit",re,m]),re}function $(ne,re){D(ne,re.from)}function M(ne,re){re.restore()}function z(ne,re){return we;function we(ce,ee,U){let W,Z,ie,C;return Array.isArray(ce)?V(ce):"tokenize"in ce?V([ce]):A(ce);function A(de){return ve;function ve(ze){const ke=ze!==null&&de[ze],lt=ze!==null&&de.null,yt=[...Array.isArray(ke)?ke:ke?[ke]:[],...Array.isArray(lt)?lt:lt?[lt]:[]];return V(yt)(ze)}}function V(de){return W=de,Z=0,de.length===0?U:T(de[Z])}function T(de){return ve;function ve(ze){return C=P(),ie=de,de.partial||(m.currentConstruct=de),de.name&&m.parser.constructs.disable.null.includes(de.name)?he():de.tokenize.call(re?Object.assign(Object.create(m),re):m,p,le,he)(ze)}}function le(de){return ne(ie,C),ee}function he(de){return C.restore(),++Z<W.length?T(W[Z]):U}}}function D(ne,re){ne.resolveAll&&!c.includes(ne)&&c.push(ne),ne.resolve&&wn(m.events,re,m.events.length-re,ne.resolve(m.events.slice(re),m)),ne.resolveTo&&(m.events=ne.resolveTo(m.events,m))}function P(){const ne=O(),re=m.previous,we=m.currentConstruct,ce=m.events.length,ee=Array.from(h);return{from:ce,restore:U};function U(){o=ne,m.previous=re,m.currentConstruct=we,m.events.length=ce,h=ee,te()}}function te(){o.line in s&&o.column<2&&(o.column=s[o.line],o.offset+=s[o.line]-1)}}function I1(n,i){const a=i.start._index,o=i.start._bufferIndex,s=i.end._index,c=i.end._bufferIndex;let d;if(a===s)d=[n[a].slice(o,c)];else{if(d=n.slice(a,s),o>-1){const h=d[0];typeof h=="string"?d[0]=h.slice(o):d.shift()}c>0&&d.push(n[s].slice(0,c))}return d}function H1(n,i){let a=-1;const o=[];let s;for(;++a<n.length;){const c=n[a];let d;if(typeof c=="string")d=c;else switch(c){case-5:{d="\r";break}case-4:{d=`
|
|
44
44
|
`;break}case-3:{d=`\r
|
|
45
45
|
`;break}case-2:{d=i?" ":" ";break}case-1:{if(!i&&s)continue;d=" ";break}default:d=String.fromCharCode(c)}s=c===-2,o.push(d)}return o.join("")}function q1(n){const o={constructs:lx([U1,...(n||{}).extensions||[]]),content:s(fx),defined:[],document:s(hx),flow:s(M1),lazy:{},string:s(D1),text:s(j1)};return o;function s(c){return d;function d(h){return B1(o,c,h)}}}function Y1(n){for(;!jm(n););return n}const Vm=/[\0\t\n\r]/g;function V1(){let n=1,i="",a=!0,o;return s;function s(c,d,h){const p=[];let m,g,y,b,S;for(c=i+(typeof c=="string"?c.toString():new TextDecoder(d||void 0).decode(c)),y=0,i="",a&&(c.charCodeAt(0)===65279&&y++,a=void 0);y<c.length;){if(Vm.lastIndex=y,m=Vm.exec(c),b=m&&m.index!==void 0?m.index:c.length,S=c.charCodeAt(b),!m){i=c.slice(y);break}if(S===10&&y===b&&o)p.push(-3),o=void 0;else switch(o&&(p.push(-5),o=void 0),y<b&&(p.push(c.slice(y,b)),n+=b-y),S){case 0:{p.push(65533),n++;break}case 9:{for(g=Math.ceil(n/4)*4,p.push(-2);n++<g;)p.push(-1);break}case 10:{p.push(-4),n=1;break}default:o=!0,n=1}y=b+1}return h&&(o&&p.push(-5),i&&p.push(i),p.push(null)),p}}const G1=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function P1(n){return n.replace(G1,F1)}function F1(n,i,a){if(i)return i;if(a.charCodeAt(0)===35){const s=a.charCodeAt(1),c=s===120||s===88;return _m(a.slice(c?2:1),c?16:10)}return lu(a)||n}const Gm={}.hasOwnProperty;function X1(n,i,a){return typeof i!="string"&&(a=i,i=void 0),K1(a)(Y1(q1(a).document().write(V1()(n,i,!0))))}function K1(n){const i={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:c(ue),autolinkProtocol:P,autolinkEmail:P,atxHeading:c(Ln),blockQuote:c(lt),characterEscape:P,characterReference:P,codeFenced:c(yt),codeFencedFenceInfo:d,codeFencedFenceMeta:d,codeIndented:c(yt,d),codeText:c(Kt,d),codeTextData:P,data:P,codeFlowValue:P,definition:c(cl),definitionDestinationString:d,definitionLabelString:d,definitionTitleString:d,emphasis:c(an),hardBreakEscape:c(Un),hardBreakTrailing:c(Un),htmlFlow:c(Yl,d),htmlFlowData:P,htmlText:c(Yl,d),htmlTextData:P,image:c(fe),label:d,link:c(ue),listItem:c(Ie),listItemValue:b,listOrdered:c(se,y),listUnordered:c(se),paragraph:c(He),reference:T,referenceString:d,resourceDestinationString:d,resourceTitleString:d,setextHeading:c(Ln),strong:c(We),thematicBreak:c(on)},exit:{atxHeading:p(),atxHeadingSequence:$,autolink:p(),autolinkEmail:ke,autolinkProtocol:ze,blockQuote:p(),characterEscapeValue:te,characterReferenceMarkerHexadecimal:he,characterReferenceMarkerNumeric:he,characterReferenceValue:de,characterReference:ve,codeFenced:p(j),codeFencedFence:R,codeFencedFenceInfo:S,codeFencedFenceMeta:O,codeFlowValue:te,codeIndented:p(_),codeText:p(ee),codeTextData:te,data:te,definition:p(),definitionDestinationString:K,definitionLabelString:q,definitionTitleString:H,emphasis:p(),hardBreakEscape:p(re),hardBreakTrailing:p(re),htmlFlow:p(we),htmlFlowData:te,htmlText:p(ce),htmlTextData:te,image:p(W),label:ie,labelText:Z,lineEnding:ne,link:p(U),listItem:p(),listOrdered:p(),listUnordered:p(),paragraph:p(),referenceString:le,resourceDestinationString:C,resourceTitleString:A,resource:V,setextHeading:p(D),setextHeadingLineSequence:z,setextHeadingText:M,strong:p(),thematicBreak:p()}};Pm(i,(n||{}).mdastExtensions||[]);const a={};return o;function o(X){let oe={type:"root",children:[]};const be={stack:[oe],tokenStack:[],config:i,enter:h,exit:m,buffer:d,resume:g,data:a},_e=[];let Fe=-1;for(;++Fe<X.length;)if(X[Fe][1].type==="listOrdered"||X[Fe][1].type==="listUnordered")if(X[Fe][0]==="enter")_e.push(Fe);else{const Qt=_e.pop();Fe=s(X,Qt,Fe)}for(Fe=-1;++Fe<X.length;){const Qt=i[X[Fe][0]];Gm.call(Qt,X[Fe][1].type)&&Qt[X[Fe][1].type].call(Object.assign({sliceSerialize:X[Fe][2].sliceSerialize},be),X[Fe][1])}if(be.tokenStack.length>0){const Qt=be.tokenStack[be.tokenStack.length-1];(Qt[1]||Fm).call(be,void 0,Qt[0])}for(oe.position={start:sl(X.length>0?X[0][1].start:{line:1,column:1,offset:0}),end:sl(X.length>0?X[X.length-2][1].end:{line:1,column:1,offset:0})},Fe=-1;++Fe<i.transforms.length;)oe=i.transforms[Fe](oe)||oe;return oe}function s(X,oe,be){let _e=oe-1,Fe=-1,Qt=!1,Bn,kt,vt,Ut;for(;++_e<=be;){const $e=X[_e];switch($e[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{$e[0]==="enter"?Fe++:Fe--,Ut=void 0;break}case"lineEndingBlank":{$e[0]==="enter"&&(Bn&&!Ut&&!Fe&&!vt&&(vt=_e),Ut=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Ut=void 0}if(!Fe&&$e[0]==="enter"&&$e[1].type==="listItemPrefix"||Fe===-1&&$e[0]==="exit"&&($e[1].type==="listUnordered"||$e[1].type==="listOrdered")){if(Bn){let fl=_e;for(kt=void 0;fl--;){const bn=X[fl];if(bn[1].type==="lineEnding"||bn[1].type==="lineEndingBlank"){if(bn[0]==="exit")continue;kt&&(X[kt][1].type="lineEndingBlank",Qt=!0),bn[1].type="lineEnding",kt=fl}else if(!(bn[1].type==="linePrefix"||bn[1].type==="blockQuotePrefix"||bn[1].type==="blockQuotePrefixWhitespace"||bn[1].type==="blockQuoteMarker"||bn[1].type==="listItemIndent"))break}vt&&(!kt||vt<kt)&&(Bn._spread=!0),Bn.end=Object.assign({},kt?X[kt][1].start:$e[1].end),X.splice(kt||_e,0,["exit",Bn,$e[2]]),_e++,be++}if($e[1].type==="listItemPrefix"){const fl={type:"listItem",_spread:!1,start:Object.assign({},$e[1].start),end:void 0};Bn=fl,X.splice(_e,0,["enter",fl,$e[2]]),_e++,be++,vt=void 0,Ut=!0}}}return X[oe][1]._spread=Qt,be}function c(X,oe){return be;function be(_e){h.call(this,X(_e),_e),oe&&oe.call(this,_e)}}function d(){this.stack.push({type:"fragment",children:[]})}function h(X,oe,be){this.stack[this.stack.length-1].children.push(X),this.stack.push(X),this.tokenStack.push([oe,be||void 0]),X.position={start:sl(oe.start),end:void 0}}function p(X){return oe;function oe(be){X&&X.call(this,be),m.call(this,be)}}function m(X,oe){const be=this.stack.pop(),_e=this.tokenStack.pop();if(_e)_e[0].type!==X.type&&(oe?oe.call(this,X,_e[0]):(_e[1]||Fm).call(this,X,_e[0]));else throw new Error("Cannot close `"+X.type+"` ("+Ni({start:X.start,end:X.end})+"): it’s not open");be.position.end=sl(X.end)}function g(){return tx(this.stack.pop())}function y(){this.data.expectingFirstListItemValue=!0}function b(X){if(this.data.expectingFirstListItemValue){const oe=this.stack[this.stack.length-2];oe.start=Number.parseInt(this.sliceSerialize(X),10),this.data.expectingFirstListItemValue=void 0}}function S(){const X=this.resume(),oe=this.stack[this.stack.length-1];oe.lang=X}function O(){const X=this.resume(),oe=this.stack[this.stack.length-1];oe.meta=X}function R(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function j(){const X=this.resume(),oe=this.stack[this.stack.length-1];oe.value=X.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function _(){const X=this.resume(),oe=this.stack[this.stack.length-1];oe.value=X.replace(/(\r?\n|\r)$/g,"")}function q(X){const oe=this.resume(),be=this.stack[this.stack.length-1];be.label=oe,be.identifier=yr(this.sliceSerialize(X)).toLowerCase()}function H(){const X=this.resume(),oe=this.stack[this.stack.length-1];oe.title=X}function K(){const X=this.resume(),oe=this.stack[this.stack.length-1];oe.url=X}function $(X){const oe=this.stack[this.stack.length-1];if(!oe.depth){const be=this.sliceSerialize(X).length;oe.depth=be}}function M(){this.data.setextHeadingSlurpLineEnding=!0}function z(X){const oe=this.stack[this.stack.length-1];oe.depth=this.sliceSerialize(X).codePointAt(0)===61?1:2}function D(){this.data.setextHeadingSlurpLineEnding=void 0}function P(X){const be=this.stack[this.stack.length-1].children;let _e=be[be.length-1];(!_e||_e.type!=="text")&&(_e=Ge(),_e.position={start:sl(X.start),end:void 0},be.push(_e)),this.stack.push(_e)}function te(X){const oe=this.stack.pop();oe.value+=this.sliceSerialize(X),oe.position.end=sl(X.end)}function ne(X){const oe=this.stack[this.stack.length-1];if(this.data.atHardBreak){const be=oe.children[oe.children.length-1];be.position.end=sl(X.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&i.canContainEols.includes(oe.type)&&(P.call(this,X),te.call(this,X))}function re(){this.data.atHardBreak=!0}function we(){const X=this.resume(),oe=this.stack[this.stack.length-1];oe.value=X}function ce(){const X=this.resume(),oe=this.stack[this.stack.length-1];oe.value=X}function ee(){const X=this.resume(),oe=this.stack[this.stack.length-1];oe.value=X}function U(){const X=this.stack[this.stack.length-1];if(this.data.inReference){const oe=this.data.referenceType||"shortcut";X.type+="Reference",X.referenceType=oe,delete X.url,delete X.title}else delete X.identifier,delete X.label;this.data.referenceType=void 0}function W(){const X=this.stack[this.stack.length-1];if(this.data.inReference){const oe=this.data.referenceType||"shortcut";X.type+="Reference",X.referenceType=oe,delete X.url,delete X.title}else delete X.identifier,delete X.label;this.data.referenceType=void 0}function Z(X){const oe=this.sliceSerialize(X),be=this.stack[this.stack.length-2];be.label=P1(oe),be.identifier=yr(oe).toLowerCase()}function ie(){const X=this.stack[this.stack.length-1],oe=this.resume(),be=this.stack[this.stack.length-1];if(this.data.inReference=!0,be.type==="link"){const _e=X.children;be.children=_e}else be.alt=oe}function C(){const X=this.resume(),oe=this.stack[this.stack.length-1];oe.url=X}function A(){const X=this.resume(),oe=this.stack[this.stack.length-1];oe.title=X}function V(){this.data.inReference=void 0}function T(){this.data.referenceType="collapsed"}function le(X){const oe=this.resume(),be=this.stack[this.stack.length-1];be.label=oe,be.identifier=yr(this.sliceSerialize(X)).toLowerCase(),this.data.referenceType="full"}function he(X){this.data.characterReferenceType=X.type}function de(X){const oe=this.sliceSerialize(X),be=this.data.characterReferenceType;let _e;be?(_e=_m(oe,be==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):_e=lu(oe);const Fe=this.stack[this.stack.length-1];Fe.value+=_e}function ve(X){const oe=this.stack.pop();oe.position.end=sl(X.end)}function ze(X){te.call(this,X);const oe=this.stack[this.stack.length-1];oe.url=this.sliceSerialize(X)}function ke(X){te.call(this,X);const oe=this.stack[this.stack.length-1];oe.url="mailto:"+this.sliceSerialize(X)}function lt(){return{type:"blockquote",children:[]}}function yt(){return{type:"code",lang:null,meta:null,value:""}}function Kt(){return{type:"inlineCode",value:""}}function cl(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function an(){return{type:"emphasis",children:[]}}function Ln(){return{type:"heading",depth:0,children:[]}}function Un(){return{type:"break"}}function Yl(){return{type:"html",value:""}}function fe(){return{type:"image",title:null,url:"",alt:null}}function ue(){return{type:"link",title:null,url:"",children:[]}}function se(X){return{type:"list",ordered:X.type==="listOrdered",start:null,spread:X._spread,children:[]}}function Ie(X){return{type:"listItem",spread:X._spread,checked:null,children:[]}}function He(){return{type:"paragraph",children:[]}}function We(){return{type:"strong",children:[]}}function Ge(){return{type:"text",value:""}}function on(){return{type:"thematicBreak"}}}function sl(n){return{line:n.line,column:n.column,offset:n.offset}}function Pm(n,i){let a=-1;for(;++a<i.length;){const o=i[a];Array.isArray(o)?Pm(n,o):Q1(n,o)}}function Q1(n,i){let a;for(a in i)if(Gm.call(i,a))switch(a){case"canContainEols":{const o=i[a];o&&n[a].push(...o);break}case"transforms":{const o=i[a];o&&n[a].push(...o);break}case"enter":case"exit":{const o=i[a];o&&Object.assign(n[a],o);break}}}function Fm(n,i){throw n?new Error("Cannot close `"+n.type+"` ("+Ni({start:n.start,end:n.end})+"): a different token (`"+i.type+"`, "+Ni({start:i.start,end:i.end})+") is open"):new Error("Cannot close document, a token (`"+i.type+"`, "+Ni({start:i.start,end:i.end})+") is still open")}function Z1(n){const i=this;i.parser=a;function a(o){return X1(o,{...i.data("settings"),...n,extensions:i.data("micromarkExtensions")||[],mdastExtensions:i.data("fromMarkdownExtensions")||[]})}}function J1(n,i){const a={type:"element",tagName:"blockquote",properties:{},children:n.wrap(n.all(i),!0)};return n.patch(i,a),n.applyData(i,a)}function W1(n,i){const a={type:"element",tagName:"br",properties:{},children:[]};return n.patch(i,a),[n.applyData(i,a),{type:"text",value:`
|