@useago/sdk 0.4.4 → 0.4.6

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/react.cjs CHANGED
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const fe=require("./rolldown-runtime-CaekUdDJ.cjs"),li=require("./AgoClient-D4EL6nva.cjs"),Ve=require("./createFormCollector-DLwgDX24.cjs"),oi=require("./createMockClient-zHQ0cjUH.cjs");let F=require("react");F=fe.__toESM(F,1);let T=require("react/jsx-runtime");function qn(e){const[n,t]=(0,F.useState)(!1),r=(0,F.useRef)(null),i=(0,F.useMemo)(()=>{r.current&&r.current.destroy();const l=new li.AgoClient(e);return r.current=l,l},[e.baseUrl,e.widgetId]);return(0,F.useEffect)(()=>(t(!0),()=>{r.current?.destroy(),r.current=null}),[i]),(0,F.useEffect)(()=>{r.current&&r.current.updateConfig({agent:e.agent,defaultAgentId:e.defaultAgentId,permission:e.permission,userEmail:e.userEmail,userJwt:e.userJwt,debug:e.debug})},[e.agent,e.defaultAgentId,e.permission,e.userEmail,e.userJwt,e.debug]),{client:i,isReady:n}}var Rt=(0,F.createContext)(null),ai=({children:e,client:n,tools:t,helpers:r,pageContext:i,...l})=>{const{client:o}=qn(n?{baseUrl:""}:l),a=n||o;return(0,F.useEffect)(()=>{if(!(!t||t.length===0)){for(const u of t)a.register(u);return()=>{for(const u of t)a.unregisterFunction(u.name)}}},[a,t]),(0,F.useEffect)(()=>{if(!r)return;const u=[];return Promise.resolve().then(()=>require("./functions-DsmzgHjC.cjs")).then(c=>c.functions_exports).then(c=>{for(const[f,s]of Object.entries(r)){const h=c[f];if(!h){console.warn(`[AGO] Unknown helper: "${f}"`);continue}const p=s===!0?h:{...h,handler:s};a.register(p),u.push(p.name)}}),()=>{for(const c of u)a.unregisterFunction(c)}},[a,r]),(0,F.useEffect)(()=>{i==="auto"&&a.enableAutoPageContext()},[a,i]),(0,T.jsx)(Rt.Provider,{value:a,children:e})};function Ye(){const e=(0,F.useContext)(Rt);if(!e)throw new Error('useAgoClient must be used within an <AgoProvider>. Wrap your component tree with <AgoProvider baseUrl="...">.');return e}function Qe(){return(0,F.useContext)(Rt)}function Ot({client:e,conversationId:n}={}){const t=Qe(),r=e||t;if(!r)throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");const[i,l]=(0,F.useState)([]),[o,a]=(0,F.useState)(n),[u,c]=(0,F.useState)(!1),[f,s]=(0,F.useState)(null);(0,F.useEffect)(()=>{n&&n!==o&&(a(n),h(n))},[n]);const h=async p=>{try{l(await r.getMessages(p))}catch(x){s(x instanceof Error?x:new Error("Failed to load messages"))}};return(0,F.useEffect)(()=>{const p=d=>{o||a(d.conversationId)},x=d=>{l(v=>{const C=v[v.length-1];return C&&C.id===d.messageId?[...v.slice(0,-1),{...C,content:C.content+d.content}]:v})},k=d=>{l(v=>{const C=v.findIndex(A=>A.id===d.id);return C>=0?[...v.slice(0,C),d,...v.slice(C+1)]:[...v,d]}),c(!1)},S=d=>{s(new Error(d.error)),c(!1)};return r.on("message:start",p),r.on("message:chunk",x),r.on("message:complete",k),r.on("message:error",S),()=>{r.off("message:start",p),r.off("message:chunk",x),r.off("message:complete",k),r.off("message:error",S)}},[r,o]),{messages:i,isLoading:u,error:f,sendMessage:(0,F.useCallback)(async(p,x)=>{c(!0),s(null);const k={id:`temp-${Date.now()}`,conversationId:o||"",content:p,role:"user",status:"DONE",createdAt:new Date},S={id:`temp-assistant-${Date.now()}`,conversationId:o||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date};l(d=>[...d,k,S]);try{const d=await r.sendMessage(p,{conversationId:o,files:x});return d.conversationId&&!o&&a(d.conversationId),l(v=>{const C=v.filter(z=>!z.id.startsWith("temp-")),A={...k,id:k.id.replace("temp-","user-"),conversationId:d.conversationId};return C.some(z=>z.id===d.id)?[...C,A].sort((z,w)=>new Date(z.createdAt).getTime()-new Date(w.createdAt).getTime()):[...C,A,d]}),d}catch(d){return s(d instanceof Error?d:new Error("Failed to send message")),c(!1),l(v=>v.filter(C=>!C.id.startsWith("temp-"))),null}},[r,o]),clearMessages:(0,F.useCallback)(()=>{l([]),a(void 0),s(null)},[]),conversationId:o}}var Un=({onSend:e,disabled:n=!1,placeholder:t="Type a message...",allowFiles:r=!1,className:i=""})=>{const[l,o]=(0,F.useState)(""),[a,u]=(0,F.useState)([]),c=(0,F.useRef)(null),f=(0,F.useCallback)(k=>{k.preventDefault(),(l.trim()||a.length>0)&&(e(l.trim(),a.length>0?a:void 0),o(""),u([]))},[l,a,e]),s=(0,F.useCallback)(k=>{k.key==="Enter"&&!k.shiftKey&&(k.preventDefault(),f(k))},[f]),h=(0,F.useCallback)(k=>{const S=Array.from(k.target.files||[]);u(d=>[...d,...S])},[]),p=(0,F.useCallback)(k=>{u(S=>S.filter((d,v)=>v!==k))},[]),x=l.trim()||a.length>0;return(0,T.jsxs)("form",{onSubmit:f,className:`ago-chat-input ${i}`,style:{display:"flex",flexDirection:"column",gap:"8px",padding:"12px 16px",borderTop:"1px solid #dee3e8",backgroundColor:"#fff"},children:[a.length>0&&(0,T.jsx)("div",{className:"ago-chat-input__files",style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:a.map((k,S)=>(0,T.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 10px",backgroundColor:"#f0f2f5",borderRadius:"6px",fontSize:"12px",color:"#30373e"},children:[(0,T.jsx)("span",{style:{maxWidth:"120px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k.name}),(0,T.jsx)("button",{type:"button",onClick:()=>p(S),style:{border:"none",background:"none",cursor:"pointer",padding:"0",color:"#6b6d6f",fontSize:"14px",lineHeight:1},children:"×"})]},S))}),(0,T.jsxs)("div",{style:{display:"flex",gap:"8px",alignItems:"flex-end"},children:[r&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)("button",{type:"button",onClick:()=>c.current?.click(),disabled:n,style:{padding:"8px",border:"1px solid #dee3e8",borderRadius:"8px",backgroundColor:"#fff",cursor:n?"not-allowed":"pointer",color:"#6b6d6f",fontSize:"16px",lineHeight:1},children:"+"}),(0,T.jsx)("input",{ref:c,type:"file",multiple:!0,onChange:h,style:{display:"none"}})]}),(0,T.jsx)("textarea",{value:l,onChange:k=>o(k.target.value),onKeyDown:s,placeholder:t,disabled:n,rows:1,style:{flex:1,padding:"10px 14px",border:"1px solid #dee3e8",borderRadius:"20px",resize:"none",outline:"none",fontFamily:"inherit",fontSize:"14px",color:"#30373e",backgroundColor:"#f8f8f8",transition:"border-color 0.15s"},onFocus:k=>{k.currentTarget.style.borderColor="#1b5fc4"},onBlur:k=>{k.currentTarget.style.borderColor="#dee3e8"}}),(0,T.jsx)("button",{type:"submit",disabled:n||!x,style:{padding:"10px 18px",border:"none",borderRadius:"20px",backgroundColor:n||!x?"#b5bfc8":"#03182f",color:"#fff",cursor:n||!x?"not-allowed":"pointer",fontWeight:500,fontSize:"14px",transition:"background-color 0.15s"},children:"Send"})]})]})};function ui(e,n){const t=n||{};return(e[e.length-1]===""?[...e,""]:e).join((t.padRight?" ":"")+","+(t.padLeft===!1?"":" ")).trim()}var si=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ci=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,fi={};function rn(e,n){return((n||fi).jsx?ci:si).test(e)}var pi=/[ \t\n\f\r]/g;function hi(e){return typeof e=="object"?e.type==="text"?ln(e.value):!1:ln(e)}function ln(e){return e.replace(pi,"")===""}var Je=class{constructor(e,n,t){this.normal=n,this.property=e,t&&(this.space=t)}};Je.prototype.normal={};Je.prototype.property={};Je.prototype.space=void 0;function $n(e,n){const t={},r={};for(const i of e)Object.assign(t,i.property),Object.assign(r,i.normal);return new Je(t,r,n)}function It(e){return e.toLowerCase()}var re=class{constructor(e,n){this.attribute=n,this.property=e}};re.prototype.attribute="";re.prototype.booleanish=!1;re.prototype.boolean=!1;re.prototype.commaOrSpaceSeparated=!1;re.prototype.commaSeparated=!1;re.prototype.defined=!1;re.prototype.mustUseProperty=!1;re.prototype.number=!1;re.prototype.overloadedBoolean=!1;re.prototype.property="";re.prototype.spaceSeparated=!1;re.prototype.space=void 0;var At=fe.__exportAll({boolean:()=>N,booleanish:()=>K,commaOrSpaceSeparated:()=>le,commaSeparated:()=>Me,number:()=>E,overloadedBoolean:()=>Tt,spaceSeparated:()=>W}),mi=0,N=Ie(),K=Ie(),Tt=Ie(),E=Ie(),W=Ie(),Me=Ie(),le=Ie();function Ie(){return 2**++mi}var ft=Object.keys(At),Nt=class extends re{constructor(e,n,t,r){let i=-1;if(super(e,n),on(this,"space",r),typeof t=="number")for(;++i<ft.length;){const l=ft[i];on(this,ft[i],(t&At[l])===At[l])}}};Nt.prototype.defined=!0;function on(e,n,t){t&&(e[n]=t)}function Re(e){const n={},t={};for(const[r,i]of Object.entries(e.properties)){const l=new Nt(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(l.mustUseProperty=!0),n[r]=l,t[It(r)]=r,t[It(l.attribute)]=r}return new Je(n,t,e.space)}var Vn=Re({properties:{ariaActiveDescendant:null,ariaAtomic:K,ariaAutoComplete:null,ariaBusy:K,ariaChecked:K,ariaColCount:E,ariaColIndex:E,ariaColSpan:E,ariaControls:W,ariaCurrent:null,ariaDescribedBy:W,ariaDetails:null,ariaDisabled:K,ariaDropEffect:W,ariaErrorMessage:null,ariaExpanded:K,ariaFlowTo:W,ariaGrabbed:K,ariaHasPopup:null,ariaHidden:K,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:W,ariaLevel:E,ariaLive:null,ariaModal:K,ariaMultiLine:K,ariaMultiSelectable:K,ariaOrientation:null,ariaOwns:W,ariaPlaceholder:null,ariaPosInSet:E,ariaPressed:K,ariaReadOnly:K,ariaRelevant:null,ariaRequired:K,ariaRoleDescription:W,ariaRowCount:E,ariaRowIndex:E,ariaRowSpan:E,ariaSelected:K,ariaSetSize:E,ariaSort:null,ariaValueMax:E,ariaValueMin:E,ariaValueNow:E,ariaValueText:null,role:null},transform(e,n){return n==="role"?n:"aria-"+n.slice(4).toLowerCase()}});function Wn(e,n){return n in e?e[n]:n}function Xn(e,n){return Wn(e,n.toLowerCase())}var gi=Re({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Me,acceptCharset:W,accessKey:W,action:null,allow:null,allowFullScreen:N,allowPaymentRequest:N,allowUserMedia:N,alt:null,as:null,async:N,autoCapitalize:null,autoComplete:W,autoFocus:N,autoPlay:N,blocking:W,capture:null,charSet:null,checked:N,cite:null,className:W,cols:E,colSpan:null,content:null,contentEditable:K,controls:N,controlsList:W,coords:E|Me,crossOrigin:null,data:null,dateTime:null,decoding:null,default:N,defer:N,dir:null,dirName:null,disabled:N,download:Tt,draggable:K,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:N,formTarget:null,headers:W,height:E,hidden:Tt,high:E,href:null,hrefLang:null,htmlFor:W,httpEquiv:W,id:null,imageSizes:null,imageSrcSet:null,inert:N,inputMode:null,integrity:null,is:null,isMap:N,itemId:null,itemProp:W,itemRef:W,itemScope:N,itemType:W,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:N,low:E,manifest:null,max:null,maxLength:E,media:null,method:null,min:null,minLength:E,multiple:N,muted:N,name:null,nonce:null,noModule:N,noValidate:N,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:N,optimum:E,pattern:null,ping:W,placeholder:null,playsInline:N,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:N,referrerPolicy:null,rel:W,required:N,reversed:N,rows:E,rowSpan:E,sandbox:W,scope:null,scoped:N,seamless:N,selected:N,shadowRootClonable:N,shadowRootDelegatesFocus:N,shadowRootMode:null,shape:null,size:E,sizes:null,slot:null,span:E,spellCheck:K,src:null,srcDoc:null,srcLang:null,srcSet:null,start:E,step:null,style:null,tabIndex:E,target:null,title:null,translate:null,type:null,typeMustMatch:N,useMap:null,value:K,width:E,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:W,axis:null,background:null,bgColor:null,border:E,borderColor:null,bottomMargin:E,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:N,declare:N,event:null,face:null,frame:null,frameBorder:null,hSpace:E,leftMargin:E,link:null,longDesc:null,lowSrc:null,marginHeight:E,marginWidth:E,noResize:N,noHref:N,noShade:N,noWrap:N,object:null,profile:null,prompt:null,rev:null,rightMargin:E,rules:null,scheme:null,scrolling:K,standby:null,summary:null,text:null,topMargin:E,valueType:null,version:null,vAlign:null,vLink:null,vSpace:E,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:N,disableRemotePlayback:N,prefix:null,property:null,results:E,security:null,unselectable:null},space:"html",transform:Xn}),di=Re({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:le,accentHeight:E,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:E,amplitude:E,arabicForm:null,ascent:E,attributeName:null,attributeType:null,azimuth:E,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:E,by:null,calcMode:null,capHeight:E,className:W,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:E,diffuseConstant:E,direction:null,display:null,dur:null,divisor:E,dominantBaseline:null,download:N,dx:null,dy:null,edgeMode:null,editable:null,elevation:E,enableBackground:null,end:null,event:null,exponent:E,externalResourcesRequired:null,fill:null,fillOpacity:E,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:Me,g2:Me,glyphName:Me,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:E,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:E,horizOriginX:E,horizOriginY:E,id:null,ideographic:E,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:E,k:E,k1:E,k2:E,k3:E,k4:E,kernelMatrix:le,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:E,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:E,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:E,overlineThickness:E,paintOrder:null,panose1:null,path:null,pathLength:E,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:W,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:E,pointsAtY:E,pointsAtZ:E,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:le,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:le,rev:le,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:le,requiredFeatures:le,requiredFonts:le,requiredFormats:le,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:E,specularExponent:E,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:E,strikethroughThickness:E,string:null,stroke:null,strokeDashArray:le,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:E,strokeOpacity:E,strokeWidth:null,style:null,surfaceScale:E,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:le,tabIndex:E,tableValues:null,target:null,targetX:E,targetY:E,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:le,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:E,underlineThickness:E,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:E,values:null,vAlphabetic:E,vMathematical:E,vectorEffect:null,vHanging:E,vIdeographic:E,version:null,vertAdvY:E,vertOriginX:E,vertOriginY:E,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:E,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Wn}),Yn=Re({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,n){return"xlink:"+n.slice(5).toLowerCase()}}),Qn=Re({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Xn}),Jn=Re({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()}}),xi={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"},yi=/[A-Z]/g,an=/-[a-z]/g,ki=/^data[-\w.:]+$/i;function bi(e,n){const t=It(n);let r=n,i=re;if(t in e.normal)return e.property[e.normal[t]];if(t.length>4&&t.slice(0,4)==="data"&&ki.test(n)){if(n.charAt(4)==="-"){const l=n.slice(5).replace(an,vi);r="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=n.slice(4);if(!an.test(l)){let o=l.replace(yi,wi);o.charAt(0)!=="-"&&(o="-"+o),n="data"+o}}i=Nt}return new i(r,n)}function wi(e){return"-"+e.toLowerCase()}function vi(e){return e.charAt(1).toUpperCase()}var Ci=$n([Vn,gi,Yn,Qn,Jn],"html"),Bt=$n([Vn,di,Yn,Qn,Jn],"svg");function Si(e){return e.join(" ").trim()}var Ei=fe.__commonJSMin(((e,n)=>{var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,l=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,c=/^\s+|\s+$/g,f=`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const fe=require("./rolldown-runtime-CaekUdDJ.cjs"),li=require("./AgoClient-D4EL6nva.cjs"),Ve=require("./createFormCollector-IO6bfPQx.cjs"),oi=require("./createMockClient-zHQ0cjUH.cjs");let F=require("react");F=fe.__toESM(F,1);let T=require("react/jsx-runtime");function qn(e){const[n,t]=(0,F.useState)(!1),r=(0,F.useRef)(null),i=(0,F.useMemo)(()=>{r.current&&r.current.destroy();const l=new li.AgoClient(e);return r.current=l,l},[e.baseUrl,e.widgetId]);return(0,F.useEffect)(()=>(t(!0),()=>{r.current?.destroy(),r.current=null}),[i]),(0,F.useEffect)(()=>{r.current&&r.current.updateConfig({agent:e.agent,defaultAgentId:e.defaultAgentId,permission:e.permission,userEmail:e.userEmail,userJwt:e.userJwt,debug:e.debug})},[e.agent,e.defaultAgentId,e.permission,e.userEmail,e.userJwt,e.debug]),{client:i,isReady:n}}var Rt=(0,F.createContext)(null),ai=({children:e,client:n,tools:t,helpers:r,pageContext:i,...l})=>{const{client:o}=qn(n?{baseUrl:""}:l),a=n||o;return(0,F.useEffect)(()=>{if(!(!t||t.length===0)){for(const u of t)a.register(u);return()=>{for(const u of t)a.unregisterFunction(u.name)}}},[a,t]),(0,F.useEffect)(()=>{if(!r)return;const u=[];return Promise.resolve().then(()=>require("./functions-DsmzgHjC.cjs")).then(c=>c.functions_exports).then(c=>{for(const[f,s]of Object.entries(r)){const h=c[f];if(!h){console.warn(`[AGO] Unknown helper: "${f}"`);continue}const p=s===!0?h:{...h,handler:s};a.register(p),u.push(p.name)}}),()=>{for(const c of u)a.unregisterFunction(c)}},[a,r]),(0,F.useEffect)(()=>{i==="auto"&&a.enableAutoPageContext()},[a,i]),(0,T.jsx)(Rt.Provider,{value:a,children:e})};function Ye(){const e=(0,F.useContext)(Rt);if(!e)throw new Error('useAgoClient must be used within an <AgoProvider>. Wrap your component tree with <AgoProvider baseUrl="...">.');return e}function Qe(){return(0,F.useContext)(Rt)}function Ot({client:e,conversationId:n}={}){const t=Qe(),r=e||t;if(!r)throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");const[i,l]=(0,F.useState)([]),[o,a]=(0,F.useState)(n),[u,c]=(0,F.useState)(!1),[f,s]=(0,F.useState)(null);(0,F.useEffect)(()=>{n&&n!==o&&(a(n),h(n))},[n]);const h=async p=>{try{l(await r.getMessages(p))}catch(x){s(x instanceof Error?x:new Error("Failed to load messages"))}};return(0,F.useEffect)(()=>{const p=d=>{o||a(d.conversationId)},x=d=>{l(v=>{const C=v[v.length-1];return C&&C.id===d.messageId?[...v.slice(0,-1),{...C,content:C.content+d.content}]:v})},k=d=>{l(v=>{const C=v.findIndex(A=>A.id===d.id);return C>=0?[...v.slice(0,C),d,...v.slice(C+1)]:[...v,d]}),c(!1)},S=d=>{s(new Error(d.error)),c(!1)};return r.on("message:start",p),r.on("message:chunk",x),r.on("message:complete",k),r.on("message:error",S),()=>{r.off("message:start",p),r.off("message:chunk",x),r.off("message:complete",k),r.off("message:error",S)}},[r,o]),{messages:i,isLoading:u,error:f,sendMessage:(0,F.useCallback)(async(p,x)=>{c(!0),s(null);const k={id:`temp-${Date.now()}`,conversationId:o||"",content:p,role:"user",status:"DONE",createdAt:new Date},S={id:`temp-assistant-${Date.now()}`,conversationId:o||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date};l(d=>[...d,k,S]);try{const d=await r.sendMessage(p,{conversationId:o,files:x});return d.conversationId&&!o&&a(d.conversationId),l(v=>{const C=v.filter(z=>!z.id.startsWith("temp-")),A={...k,id:k.id.replace("temp-","user-"),conversationId:d.conversationId};return C.some(z=>z.id===d.id)?[...C,A].sort((z,w)=>new Date(z.createdAt).getTime()-new Date(w.createdAt).getTime()):[...C,A,d]}),d}catch(d){return s(d instanceof Error?d:new Error("Failed to send message")),c(!1),l(v=>v.filter(C=>!C.id.startsWith("temp-"))),null}},[r,o]),clearMessages:(0,F.useCallback)(()=>{l([]),a(void 0),s(null)},[]),conversationId:o}}var Un=({onSend:e,disabled:n=!1,placeholder:t="Type a message...",allowFiles:r=!1,className:i=""})=>{const[l,o]=(0,F.useState)(""),[a,u]=(0,F.useState)([]),c=(0,F.useRef)(null),f=(0,F.useCallback)(k=>{k.preventDefault(),(l.trim()||a.length>0)&&(e(l.trim(),a.length>0?a:void 0),o(""),u([]))},[l,a,e]),s=(0,F.useCallback)(k=>{k.key==="Enter"&&!k.shiftKey&&(k.preventDefault(),f(k))},[f]),h=(0,F.useCallback)(k=>{const S=Array.from(k.target.files||[]);u(d=>[...d,...S])},[]),p=(0,F.useCallback)(k=>{u(S=>S.filter((d,v)=>v!==k))},[]),x=l.trim()||a.length>0;return(0,T.jsxs)("form",{onSubmit:f,className:`ago-chat-input ${i}`,style:{display:"flex",flexDirection:"column",gap:"8px",padding:"12px 16px",borderTop:"1px solid #dee3e8",backgroundColor:"#fff"},children:[a.length>0&&(0,T.jsx)("div",{className:"ago-chat-input__files",style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:a.map((k,S)=>(0,T.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 10px",backgroundColor:"#f0f2f5",borderRadius:"6px",fontSize:"12px",color:"#30373e"},children:[(0,T.jsx)("span",{style:{maxWidth:"120px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k.name}),(0,T.jsx)("button",{type:"button",onClick:()=>p(S),style:{border:"none",background:"none",cursor:"pointer",padding:"0",color:"#6b6d6f",fontSize:"14px",lineHeight:1},children:"×"})]},S))}),(0,T.jsxs)("div",{style:{display:"flex",gap:"8px",alignItems:"flex-end"},children:[r&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)("button",{type:"button",onClick:()=>c.current?.click(),disabled:n,style:{padding:"8px",border:"1px solid #dee3e8",borderRadius:"8px",backgroundColor:"#fff",cursor:n?"not-allowed":"pointer",color:"#6b6d6f",fontSize:"16px",lineHeight:1},children:"+"}),(0,T.jsx)("input",{ref:c,type:"file",multiple:!0,onChange:h,style:{display:"none"}})]}),(0,T.jsx)("textarea",{value:l,onChange:k=>o(k.target.value),onKeyDown:s,placeholder:t,disabled:n,rows:1,style:{flex:1,padding:"10px 14px",border:"1px solid #dee3e8",borderRadius:"20px",resize:"none",outline:"none",fontFamily:"inherit",fontSize:"14px",color:"#30373e",backgroundColor:"#f8f8f8",transition:"border-color 0.15s"},onFocus:k=>{k.currentTarget.style.borderColor="#1b5fc4"},onBlur:k=>{k.currentTarget.style.borderColor="#dee3e8"}}),(0,T.jsx)("button",{type:"submit",disabled:n||!x,style:{padding:"10px 18px",border:"none",borderRadius:"20px",backgroundColor:n||!x?"#b5bfc8":"#03182f",color:"#fff",cursor:n||!x?"not-allowed":"pointer",fontWeight:500,fontSize:"14px",transition:"background-color 0.15s"},children:"Send"})]})]})};function ui(e,n){const t=n||{};return(e[e.length-1]===""?[...e,""]:e).join((t.padRight?" ":"")+","+(t.padLeft===!1?"":" ")).trim()}var si=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ci=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,fi={};function rn(e,n){return((n||fi).jsx?ci:si).test(e)}var pi=/[ \t\n\f\r]/g;function hi(e){return typeof e=="object"?e.type==="text"?ln(e.value):!1:ln(e)}function ln(e){return e.replace(pi,"")===""}var Je=class{constructor(e,n,t){this.normal=n,this.property=e,t&&(this.space=t)}};Je.prototype.normal={};Je.prototype.property={};Je.prototype.space=void 0;function $n(e,n){const t={},r={};for(const i of e)Object.assign(t,i.property),Object.assign(r,i.normal);return new Je(t,r,n)}function It(e){return e.toLowerCase()}var re=class{constructor(e,n){this.attribute=n,this.property=e}};re.prototype.attribute="";re.prototype.booleanish=!1;re.prototype.boolean=!1;re.prototype.commaOrSpaceSeparated=!1;re.prototype.commaSeparated=!1;re.prototype.defined=!1;re.prototype.mustUseProperty=!1;re.prototype.number=!1;re.prototype.overloadedBoolean=!1;re.prototype.property="";re.prototype.spaceSeparated=!1;re.prototype.space=void 0;var At=fe.__exportAll({boolean:()=>N,booleanish:()=>K,commaOrSpaceSeparated:()=>le,commaSeparated:()=>Me,number:()=>E,overloadedBoolean:()=>Tt,spaceSeparated:()=>W}),mi=0,N=Ie(),K=Ie(),Tt=Ie(),E=Ie(),W=Ie(),Me=Ie(),le=Ie();function Ie(){return 2**++mi}var ft=Object.keys(At),Nt=class extends re{constructor(e,n,t,r){let i=-1;if(super(e,n),on(this,"space",r),typeof t=="number")for(;++i<ft.length;){const l=ft[i];on(this,ft[i],(t&At[l])===At[l])}}};Nt.prototype.defined=!0;function on(e,n,t){t&&(e[n]=t)}function Re(e){const n={},t={};for(const[r,i]of Object.entries(e.properties)){const l=new Nt(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(l.mustUseProperty=!0),n[r]=l,t[It(r)]=r,t[It(l.attribute)]=r}return new Je(n,t,e.space)}var Vn=Re({properties:{ariaActiveDescendant:null,ariaAtomic:K,ariaAutoComplete:null,ariaBusy:K,ariaChecked:K,ariaColCount:E,ariaColIndex:E,ariaColSpan:E,ariaControls:W,ariaCurrent:null,ariaDescribedBy:W,ariaDetails:null,ariaDisabled:K,ariaDropEffect:W,ariaErrorMessage:null,ariaExpanded:K,ariaFlowTo:W,ariaGrabbed:K,ariaHasPopup:null,ariaHidden:K,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:W,ariaLevel:E,ariaLive:null,ariaModal:K,ariaMultiLine:K,ariaMultiSelectable:K,ariaOrientation:null,ariaOwns:W,ariaPlaceholder:null,ariaPosInSet:E,ariaPressed:K,ariaReadOnly:K,ariaRelevant:null,ariaRequired:K,ariaRoleDescription:W,ariaRowCount:E,ariaRowIndex:E,ariaRowSpan:E,ariaSelected:K,ariaSetSize:E,ariaSort:null,ariaValueMax:E,ariaValueMin:E,ariaValueNow:E,ariaValueText:null,role:null},transform(e,n){return n==="role"?n:"aria-"+n.slice(4).toLowerCase()}});function Wn(e,n){return n in e?e[n]:n}function Xn(e,n){return Wn(e,n.toLowerCase())}var gi=Re({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Me,acceptCharset:W,accessKey:W,action:null,allow:null,allowFullScreen:N,allowPaymentRequest:N,allowUserMedia:N,alt:null,as:null,async:N,autoCapitalize:null,autoComplete:W,autoFocus:N,autoPlay:N,blocking:W,capture:null,charSet:null,checked:N,cite:null,className:W,cols:E,colSpan:null,content:null,contentEditable:K,controls:N,controlsList:W,coords:E|Me,crossOrigin:null,data:null,dateTime:null,decoding:null,default:N,defer:N,dir:null,dirName:null,disabled:N,download:Tt,draggable:K,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:N,formTarget:null,headers:W,height:E,hidden:Tt,high:E,href:null,hrefLang:null,htmlFor:W,httpEquiv:W,id:null,imageSizes:null,imageSrcSet:null,inert:N,inputMode:null,integrity:null,is:null,isMap:N,itemId:null,itemProp:W,itemRef:W,itemScope:N,itemType:W,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:N,low:E,manifest:null,max:null,maxLength:E,media:null,method:null,min:null,minLength:E,multiple:N,muted:N,name:null,nonce:null,noModule:N,noValidate:N,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:N,optimum:E,pattern:null,ping:W,placeholder:null,playsInline:N,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:N,referrerPolicy:null,rel:W,required:N,reversed:N,rows:E,rowSpan:E,sandbox:W,scope:null,scoped:N,seamless:N,selected:N,shadowRootClonable:N,shadowRootDelegatesFocus:N,shadowRootMode:null,shape:null,size:E,sizes:null,slot:null,span:E,spellCheck:K,src:null,srcDoc:null,srcLang:null,srcSet:null,start:E,step:null,style:null,tabIndex:E,target:null,title:null,translate:null,type:null,typeMustMatch:N,useMap:null,value:K,width:E,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:W,axis:null,background:null,bgColor:null,border:E,borderColor:null,bottomMargin:E,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:N,declare:N,event:null,face:null,frame:null,frameBorder:null,hSpace:E,leftMargin:E,link:null,longDesc:null,lowSrc:null,marginHeight:E,marginWidth:E,noResize:N,noHref:N,noShade:N,noWrap:N,object:null,profile:null,prompt:null,rev:null,rightMargin:E,rules:null,scheme:null,scrolling:K,standby:null,summary:null,text:null,topMargin:E,valueType:null,version:null,vAlign:null,vLink:null,vSpace:E,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:N,disableRemotePlayback:N,prefix:null,property:null,results:E,security:null,unselectable:null},space:"html",transform:Xn}),di=Re({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:le,accentHeight:E,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:E,amplitude:E,arabicForm:null,ascent:E,attributeName:null,attributeType:null,azimuth:E,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:E,by:null,calcMode:null,capHeight:E,className:W,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:E,diffuseConstant:E,direction:null,display:null,dur:null,divisor:E,dominantBaseline:null,download:N,dx:null,dy:null,edgeMode:null,editable:null,elevation:E,enableBackground:null,end:null,event:null,exponent:E,externalResourcesRequired:null,fill:null,fillOpacity:E,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:Me,g2:Me,glyphName:Me,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:E,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:E,horizOriginX:E,horizOriginY:E,id:null,ideographic:E,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:E,k:E,k1:E,k2:E,k3:E,k4:E,kernelMatrix:le,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:E,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:E,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:E,overlineThickness:E,paintOrder:null,panose1:null,path:null,pathLength:E,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:W,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:E,pointsAtY:E,pointsAtZ:E,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:le,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:le,rev:le,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:le,requiredFeatures:le,requiredFonts:le,requiredFormats:le,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:E,specularExponent:E,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:E,strikethroughThickness:E,string:null,stroke:null,strokeDashArray:le,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:E,strokeOpacity:E,strokeWidth:null,style:null,surfaceScale:E,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:le,tabIndex:E,tableValues:null,target:null,targetX:E,targetY:E,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:le,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:E,underlineThickness:E,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:E,values:null,vAlphabetic:E,vMathematical:E,vectorEffect:null,vHanging:E,vIdeographic:E,version:null,vertAdvY:E,vertOriginX:E,vertOriginY:E,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:E,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Wn}),Yn=Re({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,n){return"xlink:"+n.slice(5).toLowerCase()}}),Qn=Re({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Xn}),Jn=Re({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()}}),xi={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"},yi=/[A-Z]/g,an=/-[a-z]/g,ki=/^data[-\w.:]+$/i;function bi(e,n){const t=It(n);let r=n,i=re;if(t in e.normal)return e.property[e.normal[t]];if(t.length>4&&t.slice(0,4)==="data"&&ki.test(n)){if(n.charAt(4)==="-"){const l=n.slice(5).replace(an,vi);r="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=n.slice(4);if(!an.test(l)){let o=l.replace(yi,wi);o.charAt(0)!=="-"&&(o="-"+o),n="data"+o}}i=Nt}return new i(r,n)}function wi(e){return"-"+e.toLowerCase()}function vi(e){return e.charAt(1).toUpperCase()}var Ci=$n([Vn,gi,Yn,Qn,Jn],"html"),Bt=$n([Vn,di,Yn,Qn,Jn],"svg");function Si(e){return e.join(" ").trim()}var Ei=fe.__commonJSMin(((e,n)=>{var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,l=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,c=/^\s+|\s+$/g,f=`
2
2
  `,s="/",h="*",p="",x="comment",k="declaration";function S(v,C){if(typeof v!="string")throw new TypeError("First argument must be a string");if(!v)return[];C=C||{};var A=1,z=1;function w(R){var D=R.match(r);D&&(A+=D.length);var J=R.lastIndexOf(f);z=~J?R.length-J:z+R.length}function B(){var R={line:A,column:z};return function(D){return D.position=new _(R),P(),D}}function _(R){this.start=R,this.end={line:A,column:z},this.source=C.source}_.prototype.content=v;function j(R){var D=new Error(C.source+":"+A+":"+z+": "+R);if(D.reason=R,D.filename=C.source,D.line=A,D.column=z,D.source=v,!C.silent)throw D}function y(R){var D=R.exec(v);if(D){var J=D[0];return w(J),v=v.slice(J.length),D}}function P(){y(i)}function L(R){var D;for(R=R||[];D=$();)D!==!1&&R.push(D);return R}function $(){var R=B();if(!(s!=v.charAt(0)||h!=v.charAt(1))){for(var D=2;p!=v.charAt(D)&&(h!=v.charAt(D)||s!=v.charAt(D+1));)++D;if(D+=2,p===v.charAt(D-1))return j("End of comment missing");var J=v.slice(2,D-2);return z+=2,w(J),v=v.slice(D),z+=2,R({type:x,comment:J})}}function X(){var R=B(),D=y(l);if(D){if($(),!y(o))return j("property missing ':'");var J=y(a),ue=R({type:k,property:d(D[0].replace(t,p)),value:J?d(J[0].replace(t,p)):p});return y(u),ue}}function q(){var R=[];L(R);for(var D;D=X();)D!==!1&&(R.push(D),L(R));return R}return P(),q()}function d(v){return v?v.replace(c,p):p}n.exports=S})),Ii=fe.__commonJSMin((e=>{var n=e&&e.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var t=n(Ei());function r(i,l){let o=null;if(!i||typeof i!="string")return o;const a=(0,t.default)(i),u=typeof l=="function";return a.forEach(c=>{if(c.type!=="declaration")return;const{property:f,value:s}=c;u?l(f,s,c):s&&(o=o||{},o[f]=s)}),o}})),Ai=fe.__commonJSMin((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var n=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,l=/^-(ms)-/,o=function(f){return!f||r.test(f)||n.test(f)},a=function(f,s){return s.toUpperCase()},u=function(f,s){return"".concat(s,"-")},c=function(f,s){return s===void 0&&(s={}),o(f)?f:(f=f.toLowerCase(),s.reactCompat?f=f.replace(l,u):f=f.replace(i,u),f.replace(t,a))};e.camelCase=c})),Ti=fe.__commonJSMin(((e,n)=>{var t=(e&&e.__importDefault||function(l){return l&&l.__esModule?l:{default:l}})(Ii()),r=Ai();function i(l,o){var a={};return!l||typeof l!="string"||(0,t.default)(l,function(u,c){u&&c&&(a[(0,r.camelCase)(u,o)]=c)}),a}i.default=i,n.exports=i})),Kn=Gn("end"),jt=Gn("start");function Gn(e){return n;function n(t){const r=t&&t.position&&t.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Pi(e){const n=jt(e),t=Kn(e);if(n&&t)return{start:n,end:t}}function Ue(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?un(e.position):"start"in e||"end"in e?un(e):"line"in e||"column"in e?Pt(e):""}function Pt(e){return sn(e&&e.line)+":"+sn(e&&e.column)}function un(e){return Pt(e&&e.start)+"-"+Pt(e&&e.end)}function sn(e){return e&&typeof e=="number"?e:1}var ee=class extends Error{constructor(e,n,t){super(),typeof n=="string"&&(t=n,n=void 0);let r="",i={},l=!1;if(n&&("line"in n&&"column"in n?i={place:n}:"start"in n&&"end"in n?i={place:n}:"type"in n?i={ancestors:[n],place:n.position}:i={...n}),typeof e=="string"?r=e:!i.cause&&e&&(l=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof t=="string"){const a=t.indexOf(":");a===-1?i.ruleId=t:(i.source=t.slice(0,a),i.ruleId=t.slice(a+1))}if(!i.place&&i.ancestors&&i.ancestors){const a=i.ancestors[i.ancestors.length-1];a&&(i.place=a.position)}const o=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=o?o.line:void 0,this.name=Ue(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=l&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};ee.prototype.file="";ee.prototype.name="";ee.prototype.reason="";ee.prototype.message="";ee.prototype.stack="";ee.prototype.column=void 0;ee.prototype.line=void 0;ee.prototype.ancestors=void 0;ee.prototype.cause=void 0;ee.prototype.fatal=void 0;ee.prototype.place=void 0;ee.prototype.ruleId=void 0;ee.prototype.source=void 0;var Li=fe.__toESM(Ti(),1),Ht={}.hasOwnProperty,zi=new Map,Di=/[A-Z]/g,Fi=new Set(["table","tbody","thead","tfoot","tr"]),Mi=new Set(["td","th"]),Zn="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function _i(e,n){if(!n||n.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const t=n.filePath||void 0;let r;if(n.development){if(typeof n.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Ui(t,n.jsxDEV)}else{if(typeof n.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof n.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=qi(t,n.jsx,n.jsxs)}const i={Fragment:n.Fragment,ancestors:[],components:n.components||{},create:r,elementAttributeNameCase:n.elementAttributeNameCase||"react",evaluater:n.createEvaluater?n.createEvaluater():void 0,filePath:t,ignoreInvalidStyle:n.ignoreInvalidStyle||!1,passKeys:n.passKeys!==!1,passNode:n.passNode||!1,schema:n.space==="svg"?Bt:Ci,stylePropertyNameCase:n.stylePropertyNameCase||"dom",tableCellAlignToStyle:n.tableCellAlignToStyle!==!1},l=er(i,e,void 0);return l&&typeof l!="string"?l:i.create(e,i.Fragment,{children:l||void 0},void 0)}function er(e,n,t){if(n.type==="element")return Ri(e,n,t);if(n.type==="mdxFlowExpression"||n.type==="mdxTextExpression")return Oi(e,n);if(n.type==="mdxJsxFlowElement"||n.type==="mdxJsxTextElement")return Bi(e,n,t);if(n.type==="mdxjsEsm")return Ni(e,n);if(n.type==="root")return ji(e,n,t);if(n.type==="text")return Hi(e,n)}function Ri(e,n,t){const r=e.schema;let i=r;n.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Bt,e.schema=i),e.ancestors.push(n);const l=nr(e,n.tagName,!1),o=$i(e,n);let a=Ut(e,n);return Fi.has(n.tagName)&&(a=a.filter(function(u){return typeof u=="string"?!hi(u):!0})),tr(e,o,l,n),qt(o,a),e.ancestors.pop(),e.schema=r,e.create(n,l,o,t)}function Oi(e,n){if(n.data&&n.data.estree&&e.evaluater){const t=n.data.estree.body[0];return t.type,e.evaluater.evaluateExpression(t.expression)}We(e,n.position)}function Ni(e,n){if(n.data&&n.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(n.data.estree);We(e,n.position)}function Bi(e,n,t){const r=e.schema;let i=r;n.name==="svg"&&r.space==="html"&&(i=Bt,e.schema=i),e.ancestors.push(n);const l=n.name===null?e.Fragment:nr(e,n.name,!0),o=Vi(e,n),a=Ut(e,n);return tr(e,o,l,n),qt(o,a),e.ancestors.pop(),e.schema=r,e.create(n,l,o,t)}function ji(e,n,t){const r={};return qt(r,Ut(e,n)),e.create(n,e.Fragment,r,t)}function Hi(e,n){return n.value}function tr(e,n,t,r){typeof t!="string"&&t!==e.Fragment&&e.passNode&&(n.node=r)}function qt(e,n){if(n.length>0){const t=n.length>1?n:n[0];t&&(e.children=t)}}function qi(e,n,t){return r;function r(i,l,o,a){const u=Array.isArray(o.children)?t:n;return a?u(l,o,a):u(l,o)}}function Ui(e,n){return t;function t(r,i,l,o){const a=Array.isArray(l.children),u=jt(r);return n(i,l,o,a,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function $i(e,n){const t={};let r,i;for(i in n.properties)if(i!=="children"&&Ht.call(n.properties,i)){const l=Wi(e,i,n.properties[i]);if(l){const[o,a]=l;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&Mi.has(n.tagName)?r=a:t[o]=a}}if(r){const l=t.style||(t.style={});l[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return t}function Vi(e,n){const t={};for(const r of n.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const i=r.data.estree.body[0];i.type;const l=i.expression;l.type;const o=l.properties[0];o.type,Object.assign(t,e.evaluater.evaluateExpression(o.argument))}else We(e,n.position);else{const i=r.name;let l;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const o=r.value.data.estree.body[0];o.type,l=e.evaluater.evaluateExpression(o.expression)}else We(e,n.position);else l=r.value===null?!0:r.value;t[i]=l}return t}function Ut(e,n){const t=[];let r=-1;const i=e.passKeys?new Map:zi;for(;++r<n.children.length;){const l=n.children[r];let o;if(e.passKeys){const u=l.type==="element"?l.tagName:l.type==="mdxJsxFlowElement"||l.type==="mdxJsxTextElement"?l.name:void 0;if(u){const c=i.get(u)||0;o=u+"-"+c,i.set(u,c+1)}}const a=er(e,l,o);a!==void 0&&t.push(a)}return t}function Wi(e,n,t){const r=bi(e.schema,n);if(!(t==null||typeof t=="number"&&Number.isNaN(t))){if(Array.isArray(t)&&(t=r.commaSeparated?ui(t):Si(t)),r.property==="style"){let i=typeof t=="object"?t:Xi(e,String(t));return e.stylePropertyNameCase==="css"&&(i=Yi(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?xi[r.property]||r.property:r.attribute,t]}}function Xi(e,n){try{return(0,Li.default)(n,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};const r=t,i=new ee("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=Zn+"#cannot-parse-style-attribute",i}}function nr(e,n,t){let r;if(!t)r={type:"Literal",value:n};else if(n.includes(".")){const i=n.split(".");let l=-1,o;for(;++l<i.length;){const a=rn(i[l])?{type:"Identifier",name:i[l]}:{type:"Literal",value:i[l]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(l&&a.type==="Literal"),optional:!1}:a}r=o}else r=rn(n)&&!/^[a-z]/.test(n)?{type:"Identifier",name:n}:{type:"Literal",value:n};if(r.type==="Literal"){const i=r.value;return Ht.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);We(e)}function We(e,n){const t=new ee("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:n,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw t.file=e.filePath||void 0,t.url=Zn+"#cannot-handle-mdx-estrees-without-createevaluater",t}function Yi(e){const n={};let t;for(t in e)Ht.call(e,t)&&(n[Qi(t)]=e[t]);return n}function Qi(e){let n=e.replace(Di,Ji);return n.slice(0,3)==="ms-"&&(n="-"+n),n}function Ji(e){return"-"+e.toLowerCase()}var pt={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"]},Ki={};function $t(e,n){const t=n||Ki;return rr(e,typeof t.includeImageAlt=="boolean"?t.includeImageAlt:!0,typeof t.includeHtml=="boolean"?t.includeHtml:!0)}function rr(e,n,t){if(Gi(e)){if("value"in e)return e.type==="html"&&!t?"":e.value;if(n&&"alt"in e&&e.alt)return e.alt;if("children"in e)return cn(e.children,n,t)}return Array.isArray(e)?cn(e,n,t):""}function cn(e,n,t){const r=[];let i=-1;for(;++i<e.length;)r[i]=rr(e[i],n,t);return r.join("")}function Gi(e){return!!(e&&typeof e=="object")}var fn=document.createElement("i");function Vt(e){const n="&"+e+";";fn.innerHTML=n;const t=fn.textContent;return t.charCodeAt(t.length-1)===59&&e!=="semi"||t===n?!1:t}function oe(e,n,t,r){const i=e.length;let l=0,o;if(n<0?n=-n>i?0:i+n:n=n>i?i:n,t=t>0?t:0,r.length<1e4)o=Array.from(r),o.unshift(n,t),e.splice(...o);else for(t&&e.splice(n,t);l<r.length;)o=r.slice(l,l+1e4),o.unshift(n,0),e.splice(...o),l+=1e4,n+=1e4}function ae(e,n){return e.length>0?(oe(e,e.length,0,n),e):n}var pn={}.hasOwnProperty;function ir(e){const n={};let t=-1;for(;++t<e.length;)Zi(n,e[t]);return n}function Zi(e,n){let t;for(t in n){const r=(pn.call(e,t)?e[t]:void 0)||(e[t]={}),i=n[t];let l;if(i)for(l in i){pn.call(r,l)||(r[l]=[]);const o=i[l];el(r[l],Array.isArray(o)?o:o?[o]:[])}}}function el(e,n){let t=-1;const r=[];for(;++t<n.length;)(n[t].add==="after"?e:r).push(n[t]);oe(e,0,0,r)}function lr(e,n){const t=Number.parseInt(e,n);return t<9||t===11||t>13&&t<32||t>126&&t<160||t>55295&&t<57344||t>64975&&t<65008||(t&65535)===65535||(t&65535)===65534||t>1114111?"�":String.fromCodePoint(t)}function se(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var te=ve(/[A-Za-z]/),Z=ve(/[\dA-Za-z]/),tl=ve(/[#-'*+\--9=?A-Z^-~]/);function it(e){return e!==null&&(e<32||e===127)}var Lt=ve(/\d/),nl=ve(/[\dA-Fa-f]/),rl=ve(/[!-/:-@[-`{-~]/);function M(e){return e!==null&&e<-2}function V(e){return e!==null&&(e<0||e===32)}function H(e){return e===-2||e===-1||e===32}var at=ve(new RegExp("\\p{P}|\\p{S}","u")),Ee=ve(/\s/);function ve(e){return n;function n(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function Oe(e){const n=[];let t=-1,r=0,i=0;for(;++t<e.length;){const l=e.charCodeAt(t);let o="";if(l===37&&Z(e.charCodeAt(t+1))&&Z(e.charCodeAt(t+2)))i=2;else if(l<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(l))||(o=String.fromCharCode(l));else if(l>55295&&l<57344){const a=e.charCodeAt(t+1);l<56320&&a>56319&&a<57344?(o=String.fromCharCode(l,a),i=1):o="�"}else o=String.fromCharCode(l);o&&(n.push(e.slice(r,t),encodeURIComponent(o)),r=t+i+1,o=""),i&&(t+=i,i=0)}return n.join("")+e.slice(r)}function U(e,n,t,r){const i=r?r-1:Number.POSITIVE_INFINITY;let l=0;return o;function o(u){return H(u)?(e.enter(t),a(u)):n(u)}function a(u){return H(u)&&l++<i?(e.consume(u),a):(e.exit(t),n(u))}}var il={tokenize:ll};function ll(e){const n=e.attempt(this.parser.constructs.contentInitial,r,i);let t;return n;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),U(e,n,"linePrefix")}function i(a){return e.enter("paragraph"),l(a)}function l(a){const u=e.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=u),t=u,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return M(a)?(e.consume(a),e.exit("chunkText"),l):(e.consume(a),o)}}var ol={tokenize:al},hn={tokenize:ul};function al(e){const n=this,t=[];let r=0,i,l,o;return a;function a(C){if(r<t.length){const A=t[r];return n.containerState=A[1],e.attempt(A[0].continuation,u,c)(C)}return c(C)}function u(C){if(r++,n.containerState._closeFlow){n.containerState._closeFlow=void 0,i&&v();const A=n.events.length;let z=A,w;for(;z--;)if(n.events[z][0]==="exit"&&n.events[z][1].type==="chunkFlow"){w=n.events[z][1].end;break}d(r);let B=A;for(;B<n.events.length;)n.events[B][1].end={...w},B++;return oe(n.events,z+1,0,n.events.slice(A)),n.events.length=B,c(C)}return a(C)}function c(C){if(r===t.length){if(!i)return h(C);if(i.currentConstruct&&i.currentConstruct.concrete)return x(C);n.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(hn,f,s)(C)}function f(C){return i&&v(),d(r),h(C)}function s(C){return n.parser.lazy[n.now().line]=r!==t.length,o=n.now().offset,x(C)}function h(C){return n.containerState={},e.attempt(hn,p,x)(C)}function p(C){return r++,t.push([n.currentConstruct,n.containerState]),h(C)}function x(C){if(C===null){i&&v(),d(0),e.consume(C);return}return i=i||n.parser.flow(n.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:l}),k(C)}function k(C){if(C===null){S(e.exit("chunkFlow"),!0),d(0),e.consume(C);return}return M(C)?(e.consume(C),S(e.exit("chunkFlow")),r=0,n.interrupt=void 0,a):(e.consume(C),k)}function S(C,A){const z=n.sliceStream(C);if(A&&z.push(null),C.previous=l,l&&(l.next=C),l=C,i.defineSkip(C.start),i.write(z),n.parser.lazy[C.start.line]){let w=i.events.length;for(;w--;)if(i.events[w][1].start.offset<o&&(!i.events[w][1].end||i.events[w][1].end.offset>o))return;const B=n.events.length;let _=B,j,y;for(;_--;)if(n.events[_][0]==="exit"&&n.events[_][1].type==="chunkFlow"){if(j){y=n.events[_][1].end;break}j=!0}for(d(r),w=B;w<n.events.length;)n.events[w][1].end={...y},w++;oe(n.events,_+1,0,n.events.slice(B)),n.events.length=w}}function d(C){let A=t.length;for(;A-- >C;){const z=t[A];n.containerState=z[1],z[0].exit.call(n,e)}t.length=C}function v(){i.write([null]),l=void 0,i=void 0,n.containerState._closeFlow=void 0}}function ul(e,n,t){return U(e,e.attempt(this.parser.constructs.document,n,t),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function _e(e){if(e===null||V(e)||Ee(e))return 1;if(at(e))return 2}function ut(e,n,t){const r=[];let i=-1;for(;++i<e.length;){const l=e[i].resolveAll;l&&!r.includes(l)&&(n=l(n,t),r.push(l))}return n}var zt={name:"attention",resolveAll:sl,tokenize:cl};function sl(e,n){let t=-1,r,i,l,o,a,u,c,f;for(;++t<e.length;)if(e[t][0]==="enter"&&e[t][1].type==="attentionSequence"&&e[t][1]._close){for(r=t;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&n.sliceSerialize(e[r][1]).charCodeAt(0)===n.sliceSerialize(e[t][1]).charCodeAt(0)){if((e[r][1]._close||e[t][1]._open)&&(e[t][1].end.offset-e[t][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[t][1].end.offset-e[t][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[t][1].end.offset-e[t][1].start.offset>1?2:1;const s={...e[r][1].end},h={...e[t][1].start};mn(s,-u),mn(h,u),o={type:u>1?"strongSequence":"emphasisSequence",start:s,end:{...e[r][1].end}},a={type:u>1?"strongSequence":"emphasisSequence",start:{...e[t][1].start},end:h},l={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[t][1].start}},i={type:u>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[t][1].start={...a.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=ae(c,[["enter",e[r][1],n],["exit",e[r][1],n]])),c=ae(c,[["enter",i,n],["enter",o,n],["exit",o,n],["enter",l,n]]),c=ae(c,ut(n.parser.constructs.insideSpan.null,e.slice(r+1,t),n)),c=ae(c,[["exit",l,n],["enter",a,n],["exit",a,n],["exit",i,n]]),e[t][1].end.offset-e[t][1].start.offset?(f=2,c=ae(c,[["enter",e[t][1],n],["exit",e[t][1],n]])):f=0,oe(e,r-1,t-r+3,c),t=r+c.length-f-2;break}}for(t=-1;++t<e.length;)e[t][1].type==="attentionSequence"&&(e[t][1].type="data");return e}function cl(e,n){const t=this.parser.constructs.attentionMarkers.null,r=this.previous,i=_e(r);let l;return o;function o(u){return l=u,e.enter("attentionSequence"),a(u)}function a(u){if(u===l)return e.consume(u),a;const c=e.exit("attentionSequence"),f=_e(u),s=!f||f===2&&i||t.includes(u),h=!i||i===2&&f||t.includes(r);return c._open=!!(l===42?s:s&&(i||!h)),c._close=!!(l===42?h:h&&(f||!s)),n(u)}}function mn(e,n){e.column+=n,e.offset+=n,e._bufferIndex+=n}var fl={name:"autolink",tokenize:pl};function pl(e,n,t){let r=0;return i;function i(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l}function l(p){return te(p)?(e.consume(p),o):p===64?t(p):c(p)}function o(p){return p===43||p===45||p===46||Z(p)?(r=1,a(p)):c(p)}function a(p){return p===58?(e.consume(p),r=0,u):(p===43||p===45||p===46||Z(p))&&r++<32?(e.consume(p),a):(r=0,c(p))}function u(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),n):p===null||p===32||p===60||it(p)?t(p):(e.consume(p),u)}function c(p){return p===64?(e.consume(p),f):tl(p)?(e.consume(p),c):t(p)}function f(p){return Z(p)?s(p):t(p)}function s(p){return p===46?(e.consume(p),r=0,f):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),n):h(p)}function h(p){if((p===45||Z(p))&&r++<63){const x=p===45?h:s;return e.consume(p),x}return t(p)}}var Ke={partial:!0,tokenize:hl};function hl(e,n,t){return r;function r(l){return H(l)?U(e,i,"linePrefix")(l):i(l)}function i(l){return l===null||M(l)?n(l):t(l)}}var or={continuation:{tokenize:gl},exit:dl,name:"blockQuote",tokenize:ml};function ml(e,n,t){const r=this;return i;function i(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),l}return t(o)}function l(o){return H(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),n):(e.exit("blockQuotePrefix"),n(o))}}function gl(e,n,t){const r=this;return i;function i(o){return H(o)?U(e,l,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):l(o)}function l(o){return e.attempt(or,n,t)(o)}}function dl(e){e.exit("blockQuote")}var ar={name:"characterEscape",tokenize:xl};function xl(e,n,t){return r;function r(l){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(l),e.exit("escapeMarker"),i}function i(l){return rl(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),n):t(l)}}var ur={name:"characterReference",tokenize:yl};function yl(e,n,t){const r=this;let i=0,l,o;return a;function a(s){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(s),e.exit("characterReferenceMarker"),u}function u(s){return s===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(s),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),l=31,o=Z,f(s))}function c(s){return s===88||s===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(s),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,o=nl,f):(e.enter("characterReferenceValue"),l=7,o=Lt,f(s))}function f(s){if(s===59&&i){const h=e.exit("characterReferenceValue");return o===Z&&!Vt(r.sliceSerialize(h))?t(s):(e.enter("characterReferenceMarker"),e.consume(s),e.exit("characterReferenceMarker"),e.exit("characterReference"),n)}return o(s)&&i++<l?(e.consume(s),f):t(s)}}var gn={partial:!0,tokenize:bl},dn={concrete:!0,name:"codeFenced",tokenize:kl};function kl(e,n,t){const r=this,i={partial:!0,tokenize:z};let l=0,o=0,a;return u;function u(w){return c(w)}function c(w){const B=r.events[r.events.length-1];return l=B&&B[1].type==="linePrefix"?B[2].sliceSerialize(B[1],!0).length:0,a=w,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(w)}function f(w){return w===a?(o++,e.consume(w),f):o<3?t(w):(e.exit("codeFencedFenceSequence"),H(w)?U(e,s,"whitespace")(w):s(w))}function s(w){return w===null||M(w)?(e.exit("codeFencedFence"),r.interrupt?n(w):e.check(gn,k,A)(w)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),h(w))}function h(w){return w===null||M(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),s(w)):H(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),U(e,p,"whitespace")(w)):w===96&&w===a?t(w):(e.consume(w),h)}function p(w){return w===null||M(w)?s(w):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),x(w))}function x(w){return w===null||M(w)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),s(w)):w===96&&w===a?t(w):(e.consume(w),x)}function k(w){return e.attempt(i,A,S)(w)}function S(w){return e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),d}function d(w){return l>0&&H(w)?U(e,v,"linePrefix",l+1)(w):v(w)}function v(w){return w===null||M(w)?e.check(gn,k,A)(w):(e.enter("codeFlowValue"),C(w))}function C(w){return w===null||M(w)?(e.exit("codeFlowValue"),v(w)):(e.consume(w),C)}function A(w){return e.exit("codeFenced"),n(w)}function z(w,B,_){let j=0;return y;function y(q){return w.enter("lineEnding"),w.consume(q),w.exit("lineEnding"),P}function P(q){return w.enter("codeFencedFence"),H(q)?U(w,L,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(q):L(q)}function L(q){return q===a?(w.enter("codeFencedFenceSequence"),$(q)):_(q)}function $(q){return q===a?(j++,w.consume(q),$):j>=o?(w.exit("codeFencedFenceSequence"),H(q)?U(w,X,"whitespace")(q):X(q)):_(q)}function X(q){return q===null||M(q)?(w.exit("codeFencedFence"),B(q)):_(q)}}}function bl(e,n,t){const r=this;return i;function i(o){return o===null?t(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),l)}function l(o){return r.parser.lazy[r.now().line]?t(o):n(o)}}var ht={name:"codeIndented",tokenize:vl},wl={partial:!0,tokenize:Cl};function vl(e,n,t){const r=this;return i;function i(c){return e.enter("codeIndented"),U(e,l,"linePrefix",5)(c)}function l(c){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?o(c):t(c)}function o(c){return c===null?u(c):M(c)?e.attempt(wl,o,u)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||M(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),a)}function u(c){return e.exit("codeIndented"),n(c)}}function Cl(e,n,t){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?t(o):M(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):U(e,l,"linePrefix",5)(o)}function l(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?n(o):M(o)?i(o):t(o)}}var Sl={name:"codeText",previous:Il,resolve:El,tokenize:Al};function El(e){let n=e.length-4,t=3,r,i;if((e[t][1].type==="lineEnding"||e[t][1].type==="space")&&(e[n][1].type==="lineEnding"||e[n][1].type==="space")){for(r=t;++r<n;)if(e[r][1].type==="codeTextData"){e[t][1].type="codeTextPadding",e[n][1].type="codeTextPadding",t+=2,n-=2;break}}for(r=t-1,n++;++r<=n;)i===void 0?r!==n&&e[r][1].type!=="lineEnding"&&(i=r):(r===n||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),n-=r-i-2,r=i+2),i=void 0);return e}function Il(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Al(e,n,t){let r=0,i,l;return o;function o(s){return e.enter("codeText"),e.enter("codeTextSequence"),a(s)}function a(s){return s===96?(e.consume(s),r++,a):(e.exit("codeTextSequence"),u(s))}function u(s){return s===null?t(s):s===32?(e.enter("space"),e.consume(s),e.exit("space"),u):s===96?(l=e.enter("codeTextSequence"),i=0,f(s)):M(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),u):(e.enter("codeTextData"),c(s))}function c(s){return s===null||s===32||s===96||M(s)?(e.exit("codeTextData"),u(s)):(e.consume(s),c)}function f(s){return s===96?(e.consume(s),i++,f):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),n(s)):(l.type="codeTextData",c(s))}}var Tl=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,n){const t=n??Number.POSITIVE_INFINITY;return t<this.left.length?this.left.slice(e,t):e>this.left.length?this.right.slice(this.right.length-t+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-t+this.left.length).reverse())}splice(e,n,t){const r=n||0;this.setCursor(Math.trunc(e));const i=this.right.splice(this.right.length-r,Number.POSITIVE_INFINITY);return t&&He(this.left,t),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),He(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),He(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){const n=this.left.splice(e,Number.POSITIVE_INFINITY);He(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);He(this.left,n.reverse())}}};function He(e,n){let t=0;if(n.length<1e4)e.push(...n);else for(;t<n.length;)e.push(...n.slice(t,t+1e4)),t+=1e4}function sr(e){const n={};let t=-1,r,i,l,o,a,u,c;const f=new Tl(e);for(;++t<f.length;){for(;t in n;)t=n[t];if(r=f.get(t),t&&r[1].type==="chunkFlow"&&f.get(t-1)[1].type==="listItemPrefix"&&(u=r[1]._tokenizer.events,l=0,l<u.length&&u[l][1].type==="lineEndingBlank"&&(l+=2),l<u.length&&u[l][1].type==="content"))for(;++l<u.length&&u[l][1].type!=="content";)u[l][1].type==="chunkText"&&(u[l][1]._isInFirstContentOfListItem=!0,l++);if(r[0]==="enter")r[1].contentType&&(Object.assign(n,Pl(f,t)),t=n[t],c=!0);else if(r[1]._container){for(l=t,i=void 0;l--;)if(o=f.get(l),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(f.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=l);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...f.get(i)[1].start},a=f.slice(i,t),a.unshift(r),f.splice(i,t-i+1,a))}}return oe(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!c}function Pl(e,n){const t=e.get(n)[1],r=e.get(n)[2];let i=n-1;const l=[];let o=t._tokenizer;o||(o=r.parser[t.contentType](t.start),t._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,u=[],c={};let f,s,h=-1,p=t,x=0,k=0;const S=[k];for(;p;){for(;e.get(++i)[1]!==p;);l.push(i),p._tokenizer||(f=r.sliceStream(p),p.next||f.push(null),s&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(f),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),s=p,p=p.next}for(p=t;++h<a.length;)a[h][0]==="exit"&&a[h-1][0]==="enter"&&a[h][1].type===a[h-1][1].type&&a[h][1].start.line!==a[h][1].end.line&&(k=h+1,S.push(k),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):S.pop(),h=S.length;h--;){const d=a.slice(S[h],S[h+1]),v=l.pop();u.push([v,v+d.length-1]),e.splice(v,2,d)}for(u.reverse(),h=-1;++h<u.length;)c[x+u[h][0]]=x+u[h][1],x+=u[h][1]-u[h][0]-1;return c}var Ll={resolve:Dl,tokenize:Fl},zl={partial:!0,tokenize:Ml};function Dl(e){return sr(e),e}function Fl(e,n){let t;return r;function r(a){return e.enter("content"),t=e.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?l(a):M(a)?e.check(zl,o,l)(a):(e.consume(a),i)}function l(a){return e.exit("chunkContent"),e.exit("content"),n(a)}function o(a){return e.consume(a),e.exit("chunkContent"),t.next=e.enter("chunkContent",{contentType:"content",previous:t}),t=t.next,i}}function Ml(e,n,t){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),U(e,l,"linePrefix")}function l(o){if(o===null||M(o))return t(o);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?n(o):e.interrupt(r.parser.constructs.flow,t,n)(o)}}function cr(e,n,t,r,i,l,o,a,u){const c=u||Number.POSITIVE_INFINITY;let f=0;return s;function s(d){return d===60?(e.enter(r),e.enter(i),e.enter(l),e.consume(d),e.exit(l),h):d===null||d===32||d===41||it(d)?t(d):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),k(d))}function h(d){return d===62?(e.enter(l),e.consume(d),e.exit(l),e.exit(i),e.exit(r),n):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(d))}function p(d){return d===62?(e.exit("chunkString"),e.exit(a),h(d)):d===null||d===60||M(d)?t(d):(e.consume(d),d===92?x:p)}function x(d){return d===60||d===62||d===92?(e.consume(d),p):p(d)}function k(d){return!f&&(d===null||d===41||V(d))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),n(d)):f<c&&d===40?(e.consume(d),f++,k):d===41?(e.consume(d),f--,k):d===null||d===32||d===40||it(d)?t(d):(e.consume(d),d===92?S:k)}function S(d){return d===40||d===41||d===92?(e.consume(d),k):k(d)}}function fr(e,n,t,r,i,l){const o=this;let a=0,u;return c;function c(p){return e.enter(r),e.enter(i),e.consume(p),e.exit(i),e.enter(l),f}function f(p){return a>999||p===null||p===91||p===93&&!u||p===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?t(p):p===93?(e.exit(l),e.enter(i),e.consume(p),e.exit(i),e.exit(r),n):M(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),s(p))}function s(p){return p===null||p===91||p===93||M(p)||a++>999?(e.exit("chunkString"),f(p)):(e.consume(p),u||(u=!H(p)),p===92?h:s)}function h(p){return p===91||p===92||p===93?(e.consume(p),a++,s):s(p)}}function pr(e,n,t,r,i,l){let o;return a;function a(h){return h===34||h===39||h===40?(e.enter(r),e.enter(i),e.consume(h),e.exit(i),o=h===40?41:h,u):t(h)}function u(h){return h===o?(e.enter(i),e.consume(h),e.exit(i),e.exit(r),n):(e.enter(l),c(h))}function c(h){return h===o?(e.exit(l),u(o)):h===null?t(h):M(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),U(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===o||h===null||M(h)?(e.exit("chunkString"),c(h)):(e.consume(h),h===92?s:f)}function s(h){return h===o||h===92?(e.consume(h),f):f(h)}}function $e(e,n){let t;return r;function r(i){return M(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t=!0,r):H(i)?U(e,r,t?"linePrefix":"lineSuffix")(i):n(i)}}var _l={name:"definition",tokenize:Ol},Rl={partial:!0,tokenize:Nl};function Ol(e,n,t){const r=this;let i;return l;function l(p){return e.enter("definition"),o(p)}function o(p){return fr.call(r,e,a,t,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return i=se(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),u):t(p)}function u(p){return V(p)?$e(e,c)(p):c(p)}function c(p){return cr(e,f,t,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function f(p){return e.attempt(Rl,s,s)(p)}function s(p){return H(p)?U(e,h,"whitespace")(p):h(p)}function h(p){return p===null||M(p)?(e.exit("definition"),r.parser.defined.push(i),n(p)):t(p)}}function Nl(e,n,t){return r;function r(a){return V(a)?$e(e,i)(a):t(a)}function i(a){return pr(e,l,t,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function l(a){return H(a)?U(e,o,"whitespace")(a):o(a)}function o(a){return a===null||M(a)?n(a):t(a)}}var Bl={name:"hardBreakEscape",tokenize:jl};function jl(e,n,t){return r;function r(l){return e.enter("hardBreakEscape"),e.consume(l),i}function i(l){return M(l)?(e.exit("hardBreakEscape"),n(l)):t(l)}}var Hl={name:"headingAtx",resolve:ql,tokenize:Ul};function ql(e,n){let t=e.length-2,r=3,i,l;return e[r][1].type==="whitespace"&&(r+=2),t-2>r&&e[t][1].type==="whitespace"&&(t-=2),e[t][1].type==="atxHeadingSequence"&&(r===t-1||t-4>r&&e[t-2][1].type==="whitespace")&&(t-=r+1===t?2:4),t>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[t][1].end},l={type:"chunkText",start:e[r][1].start,end:e[t][1].end,contentType:"text"},oe(e,r,t-r+1,[["enter",i,n],["enter",l,n],["exit",l,n],["exit",i,n]])),e}function Ul(e,n,t){let r=0;return i;function i(f){return e.enter("atxHeading"),l(f)}function l(f){return e.enter("atxHeadingSequence"),o(f)}function o(f){return f===35&&r++<6?(e.consume(f),o):f===null||V(f)?(e.exit("atxHeadingSequence"),a(f)):t(f)}function a(f){return f===35?(e.enter("atxHeadingSequence"),u(f)):f===null||M(f)?(e.exit("atxHeading"),n(f)):H(f)?U(e,a,"whitespace")(f):(e.enter("atxHeadingText"),c(f))}function u(f){return f===35?(e.consume(f),u):(e.exit("atxHeadingSequence"),a(f))}function c(f){return f===null||f===35||V(f)?(e.exit("atxHeadingText"),a(f)):(e.consume(f),c)}}var $l=["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"],xn=["pre","script","style","textarea"],Vl={concrete:!0,name:"htmlFlow",resolveTo:Yl,tokenize:Ql},Wl={partial:!0,tokenize:Kl},Xl={partial:!0,tokenize:Jl};function Yl(e){let n=e.length;for(;n--&&!(e[n][0]==="enter"&&e[n][1].type==="htmlFlow"););return n>1&&e[n-2][1].type==="linePrefix"&&(e[n][1].start=e[n-2][1].start,e[n+1][1].start=e[n-2][1].start,e.splice(n-2,2)),e}function Ql(e,n,t){const r=this;let i,l,o,a,u;return c;function c(g){return f(g)}function f(g){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(g),s}function s(g){return g===33?(e.consume(g),h):g===47?(e.consume(g),l=!0,k):g===63?(e.consume(g),i=3,r.interrupt?n:m):te(g)?(e.consume(g),o=String.fromCharCode(g),S):t(g)}function h(g){return g===45?(e.consume(g),i=2,p):g===91?(e.consume(g),i=5,a=0,x):te(g)?(e.consume(g),i=4,r.interrupt?n:m):t(g)}function p(g){return g===45?(e.consume(g),r.interrupt?n:m):t(g)}function x(g){return g==="CDATA[".charCodeAt(a++)?(e.consume(g),a===6?r.interrupt?n:L:x):t(g)}function k(g){return te(g)?(e.consume(g),o=String.fromCharCode(g),S):t(g)}function S(g){if(g===null||g===47||g===62||V(g)){const ke=g===47,Ce=o.toLowerCase();return!ke&&!l&&xn.includes(Ce)?(i=1,r.interrupt?n(g):L(g)):$l.includes(o.toLowerCase())?(i=6,ke?(e.consume(g),d):r.interrupt?n(g):L(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?t(g):l?v(g):C(g))}return g===45||Z(g)?(e.consume(g),o+=String.fromCharCode(g),S):t(g)}function d(g){return g===62?(e.consume(g),r.interrupt?n:L):t(g)}function v(g){return H(g)?(e.consume(g),v):y(g)}function C(g){return g===47?(e.consume(g),y):g===58||g===95||te(g)?(e.consume(g),A):H(g)?(e.consume(g),C):y(g)}function A(g){return g===45||g===46||g===58||g===95||Z(g)?(e.consume(g),A):z(g)}function z(g){return g===61?(e.consume(g),w):H(g)?(e.consume(g),z):C(g)}function w(g){return g===null||g===60||g===61||g===62||g===96?t(g):g===34||g===39?(e.consume(g),u=g,B):H(g)?(e.consume(g),w):_(g)}function B(g){return g===u?(e.consume(g),u=null,j):g===null||M(g)?t(g):(e.consume(g),B)}function _(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||V(g)?z(g):(e.consume(g),_)}function j(g){return g===47||g===62||H(g)?C(g):t(g)}function y(g){return g===62?(e.consume(g),P):t(g)}function P(g){return g===null||M(g)?L(g):H(g)?(e.consume(g),P):t(g)}function L(g){return g===45&&i===2?(e.consume(g),R):g===60&&i===1?(e.consume(g),D):g===62&&i===4?(e.consume(g),ye):g===63&&i===3?(e.consume(g),m):g===93&&i===5?(e.consume(g),ue):M(g)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Wl,he,$)(g)):g===null||M(g)?(e.exit("htmlFlowData"),$(g)):(e.consume(g),L)}function $(g){return e.check(Xl,X,he)(g)}function X(g){return e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),q}function q(g){return g===null||M(g)?$(g):(e.enter("htmlFlowData"),L(g))}function R(g){return g===45?(e.consume(g),m):L(g)}function D(g){return g===47?(e.consume(g),o="",J):L(g)}function J(g){if(g===62){const ke=o.toLowerCase();return xn.includes(ke)?(e.consume(g),ye):L(g)}return te(g)&&o.length<8?(e.consume(g),o+=String.fromCharCode(g),J):L(g)}function ue(g){return g===93?(e.consume(g),m):L(g)}function m(g){return g===62?(e.consume(g),ye):g===45&&i===2?(e.consume(g),m):L(g)}function ye(g){return g===null||M(g)?(e.exit("htmlFlowData"),he(g)):(e.consume(g),ye)}function he(g){return e.exit("htmlFlow"),n(g)}}function Jl(e,n,t){const r=this;return i;function i(o){return M(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),l):t(o)}function l(o){return r.parser.lazy[r.now().line]?t(o):n(o)}}function Kl(e,n,t){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Ke,n,t)}}var Gl={name:"htmlText",tokenize:Zl};function Zl(e,n,t){const r=this;let i,l,o;return a;function a(m){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(m),u}function u(m){return m===33?(e.consume(m),c):m===47?(e.consume(m),z):m===63?(e.consume(m),C):te(m)?(e.consume(m),_):t(m)}function c(m){return m===45?(e.consume(m),f):m===91?(e.consume(m),l=0,x):te(m)?(e.consume(m),v):t(m)}function f(m){return m===45?(e.consume(m),p):t(m)}function s(m){return m===null?t(m):m===45?(e.consume(m),h):M(m)?(o=s,D(m)):(e.consume(m),s)}function h(m){return m===45?(e.consume(m),p):s(m)}function p(m){return m===62?R(m):m===45?h(m):s(m)}function x(m){return m==="CDATA[".charCodeAt(l++)?(e.consume(m),l===6?k:x):t(m)}function k(m){return m===null?t(m):m===93?(e.consume(m),S):M(m)?(o=k,D(m)):(e.consume(m),k)}function S(m){return m===93?(e.consume(m),d):k(m)}function d(m){return m===62?R(m):m===93?(e.consume(m),d):k(m)}function v(m){return m===null||m===62?R(m):M(m)?(o=v,D(m)):(e.consume(m),v)}function C(m){return m===null?t(m):m===63?(e.consume(m),A):M(m)?(o=C,D(m)):(e.consume(m),C)}function A(m){return m===62?R(m):C(m)}function z(m){return te(m)?(e.consume(m),w):t(m)}function w(m){return m===45||Z(m)?(e.consume(m),w):B(m)}function B(m){return M(m)?(o=B,D(m)):H(m)?(e.consume(m),B):R(m)}function _(m){return m===45||Z(m)?(e.consume(m),_):m===47||m===62||V(m)?j(m):t(m)}function j(m){return m===47?(e.consume(m),R):m===58||m===95||te(m)?(e.consume(m),y):M(m)?(o=j,D(m)):H(m)?(e.consume(m),j):R(m)}function y(m){return m===45||m===46||m===58||m===95||Z(m)?(e.consume(m),y):P(m)}function P(m){return m===61?(e.consume(m),L):M(m)?(o=P,D(m)):H(m)?(e.consume(m),P):j(m)}function L(m){return m===null||m===60||m===61||m===62||m===96?t(m):m===34||m===39?(e.consume(m),i=m,$):M(m)?(o=L,D(m)):H(m)?(e.consume(m),L):(e.consume(m),X)}function $(m){return m===i?(e.consume(m),i=void 0,q):m===null?t(m):M(m)?(o=$,D(m)):(e.consume(m),$)}function X(m){return m===null||m===34||m===39||m===60||m===61||m===96?t(m):m===47||m===62||V(m)?j(m):(e.consume(m),X)}function q(m){return m===47||m===62||V(m)?j(m):t(m)}function R(m){return m===62?(e.consume(m),e.exit("htmlTextData"),e.exit("htmlText"),n):t(m)}function D(m){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),J}function J(m){return H(m)?U(e,ue,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(m):ue(m)}function ue(m){return e.enter("htmlTextData"),o(m)}}var Wt={name:"labelEnd",resolveAll:ro,resolveTo:io,tokenize:lo},eo={tokenize:oo},to={tokenize:ao},no={tokenize:uo};function ro(e){let n=-1;const t=[];for(;++n<e.length;){const r=e[n][1];if(t.push(e[n]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",n+=i}}return e.length!==t.length&&oe(e,0,e.length,t),e}function io(e,n){let t=e.length,r=0,i,l,o,a;for(;t--;)if(i=e[t][1],l){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[t][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[t][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(l=t,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=t);const u={type:e[l][1].type==="labelLink"?"link":"image",start:{...e[l][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[l][1].start},end:{...e[o][1].end}},f={type:"labelText",start:{...e[l+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",u,n],["enter",c,n]],a=ae(a,e.slice(l+1,l+r+3)),a=ae(a,[["enter",f,n]]),a=ae(a,ut(n.parser.constructs.insideSpan.null,e.slice(l+r+4,o-3),n)),a=ae(a,[["exit",f,n],e[o-2],e[o-1],["exit",c,n]]),a=ae(a,e.slice(o+1)),a=ae(a,[["exit",u,n]]),oe(e,l,e.length,a),e}function lo(e,n,t){const r=this;let i=r.events.length,l,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){l=r.events[i][1];break}return a;function a(h){return l?l._inactive?s(h):(o=r.parser.defined.includes(se(r.sliceSerialize({start:l.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelEnd"),u):t(h)}function u(h){return h===40?e.attempt(eo,f,o?f:s)(h):h===91?e.attempt(to,f,o?c:s)(h):o?f(h):s(h)}function c(h){return e.attempt(no,f,s)(h)}function f(h){return n(h)}function s(h){return l._balanced=!0,t(h)}}function oo(e,n,t){return r;function r(s){return e.enter("resource"),e.enter("resourceMarker"),e.consume(s),e.exit("resourceMarker"),i}function i(s){return V(s)?$e(e,l)(s):l(s)}function l(s){return s===41?f(s):cr(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(s)}function o(s){return V(s)?$e(e,u)(s):f(s)}function a(s){return t(s)}function u(s){return s===34||s===39||s===40?pr(e,c,t,"resourceTitle","resourceTitleMarker","resourceTitleString")(s):f(s)}function c(s){return V(s)?$e(e,f)(s):f(s)}function f(s){return s===41?(e.enter("resourceMarker"),e.consume(s),e.exit("resourceMarker"),e.exit("resource"),n):t(s)}}function ao(e,n,t){const r=this;return i;function i(a){return fr.call(r,e,l,o,"reference","referenceMarker","referenceString")(a)}function l(a){return r.parser.defined.includes(se(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?n(a):t(a)}function o(a){return t(a)}}function uo(e,n,t){return r;function r(l){return e.enter("reference"),e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),i}function i(l){return l===93?(e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),e.exit("reference"),n):t(l)}}var so={name:"labelStartImage",resolveAll:Wt.resolveAll,tokenize:co};function co(e,n,t){const r=this;return i;function i(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),l}function l(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),o):t(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?t(a):n(a)}}var fo={name:"labelStartLink",resolveAll:Wt.resolveAll,tokenize:po};function po(e,n,t){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),l}function l(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?t(o):n(o)}}var mt={name:"lineEnding",tokenize:ho};function ho(e,n){return t;function t(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),U(e,n,"linePrefix")}}var rt={name:"thematicBreak",tokenize:mo};function mo(e,n,t){let r=0,i;return l;function l(c){return e.enter("thematicBreak"),o(c)}function o(c){return i=c,a(c)}function a(c){return c===i?(e.enter("thematicBreakSequence"),u(c)):r>=3&&(c===null||M(c))?(e.exit("thematicBreak"),n(c)):t(c)}function u(c){return c===i?(e.consume(c),r++,u):(e.exit("thematicBreakSequence"),H(c)?U(e,a,"whitespace")(c):a(c))}}var ne={continuation:{tokenize:ko},exit:wo,name:"list",tokenize:yo},go={partial:!0,tokenize:vo},xo={partial:!0,tokenize:bo};function yo(e,n,t){const r=this,i=r.events[r.events.length-1];let l=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return a;function a(p){const x=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(x==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:Lt(p)){if(r.containerState.type||(r.containerState.type=x,e.enter(x,{_container:!0})),x==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(rt,t,c)(p):c(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(p)}return t(p)}function u(p){return Lt(p)&&++o<10?(e.consume(p),u):(!r.interrupt||o<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),c(p)):t(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(Ke,r.interrupt?t:f,e.attempt(go,h,s))}function f(p){return r.containerState.initialBlankLine=!0,l++,h(p)}function s(p){return H(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),h):t(p)}function h(p){return r.containerState.size=l+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,n(p)}}function ko(e,n,t){const r=this;return r.containerState._closeFlow=void 0,e.check(Ke,i,l);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,U(e,n,"listItemIndent",r.containerState.size+1)(a)}function l(a){return r.containerState.furtherBlankLines||!H(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(xo,n,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,U(e,e.attempt(ne,n,t),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function bo(e,n,t){const r=this;return U(e,i,"listItemIndent",r.containerState.size+1);function i(l){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?n(l):t(l)}}function wo(e){e.exit(this.containerState.type)}function vo(e,n,t){const r=this;return U(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(l){const o=r.events[r.events.length-1];return!H(l)&&o&&o[1].type==="listItemPrefixWhitespace"?n(l):t(l)}}var yn={name:"setextUnderline",resolveTo:Co,tokenize:So};function Co(e,n){let t=e.length,r,i,l;for(;t--;)if(e[t][0]==="enter"){if(e[t][1].type==="content"){r=t;break}e[t][1].type==="paragraph"&&(i=t)}else e[t][1].type==="content"&&e.splice(t,1),!l&&e[t][1].type==="definition"&&(l=t);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",l?(e.splice(i,0,["enter",o,n]),e.splice(l+1,0,["exit",e[r][1],n]),e[r][1].end={...e[l][1].end}):e[r][1]=o,e.push(["exit",o,n]),e}function So(e,n,t){const r=this;let i;return l;function l(c){let f=r.events.length,s;for(;f--;)if(r.events[f][1].type!=="lineEnding"&&r.events[f][1].type!=="linePrefix"&&r.events[f][1].type!=="content"){s=r.events[f][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter("setextHeadingLine"),i=c,o(c)):t(c)}function o(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===i?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),H(c)?U(e,u,"lineSuffix")(c):u(c))}function u(c){return c===null||M(c)?(e.exit("setextHeadingLine"),n(c)):t(c)}}var Eo={tokenize:Io};function Io(e){const n=this,t=e.attempt(Ke,r,e.attempt(this.parser.constructs.flowInitial,i,U(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Ll,i)),"linePrefix")));return t;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEndingBlank"),e.consume(l),e.exit("lineEndingBlank"),n.currentConstruct=void 0,t}function i(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),n.currentConstruct=void 0,t}}var Ao={resolveAll:mr()},To=hr("string"),Po=hr("text");function hr(e){return{resolveAll:mr(e==="text"?Lo:void 0),tokenize:n};function n(t){const r=this,i=this.parser.constructs[e],l=t.attempt(i,o,a);return o;function o(f){return c(f)?l(f):a(f)}function a(f){if(f===null){t.consume(f);return}return t.enter("data"),t.consume(f),u}function u(f){return c(f)?(t.exit("data"),l(f)):(t.consume(f),u)}function c(f){if(f===null)return!0;const s=i[f];let h=-1;if(s)for(;++h<s.length;){const p=s[h];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function mr(e){return n;function n(t,r){let i=-1,l;for(;++i<=t.length;)l===void 0?t[i]&&t[i][1].type==="data"&&(l=i,i++):(!t[i]||t[i][1].type!=="data")&&(i!==l+2&&(t[l][1].end=t[i-1][1].end,t.splice(l+2,i-l-2),i=l+2),l=void 0);return e?e(t,r):t}}function Lo(e,n){let t=0;for(;++t<=e.length;)if((t===e.length||e[t][1].type==="lineEnding")&&e[t-1][1].type==="data"){const r=e[t-1][1],i=n.sliceStream(r);let l=i.length,o=-1,a=0,u;for(;l--;){const c=i[l];if(typeof c=="string"){for(o=c.length;c.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(c===-2)u=!0,a++;else if(c!==-1){l++;break}}if(n._contentTypeTextTrailing&&t===e.length&&(a=0),a){const c={type:t===e.length||u||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:l?o:r.start._bufferIndex+o,_index:r.start._index+l,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(t,0,["enter",c,n],["exit",c,n]),t+=2)}t++}return e}var zo=fe.__exportAll({attentionMarkers:()=>Bo,contentInitial:()=>Fo,disable:()=>jo,document:()=>Do,flow:()=>_o,flowInitial:()=>Mo,insideSpan:()=>No,string:()=>Ro,text:()=>Oo}),Do={42:ne,43:ne,45:ne,48:ne,49:ne,50:ne,51:ne,52:ne,53:ne,54:ne,55:ne,56:ne,57:ne,62:or},Fo={91:_l},Mo={[-2]:ht,[-1]:ht,32:ht},_o={35:Hl,42:rt,45:[yn,rt],60:Vl,61:yn,95:rt,96:dn,126:dn},Ro={38:ur,92:ar},Oo={[-5]:mt,[-4]:mt,[-3]:mt,33:so,38:ur,42:zt,60:[fl,Gl],91:fo,92:[Bl,ar],93:Wt,95:zt,96:Sl},No={null:[zt,Ao]},Bo={null:[42,95]},jo={null:[]};function Ho(e,n,t){let r={_bufferIndex:-1,_index:0,line:t&&t.line||1,column:t&&t.column||1,offset:t&&t.offset||0};const i={},l=[];let o=[],a=[];const u={attempt:B(z),check:B(w),consume:v,enter:C,exit:A,interrupt:B(w,{interrupt:!0})},c={code:null,containerState:{},defineSkip:k,events:[],now:x,parser:e,previous:null,sliceSerialize:h,sliceStream:p,write:s};let f=n.tokenize.call(c,u);return n.resolveAll&&l.push(n),c;function s(P){return o=ae(o,P),S(),o[o.length-1]!==null?[]:(_(n,0),c.events=ut(l,c.events,c),c.events)}function h(P,L){return Uo(p(P),L)}function p(P){return qo(o,P)}function x(){const{_bufferIndex:P,_index:L,line:$,column:X,offset:q}=r;return{_bufferIndex:P,_index:L,line:$,column:X,offset:q}}function k(P){i[P.line]=P.column,y()}function S(){let P;for(;r._index<o.length;){const L=o[r._index];if(typeof L=="string")for(P=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===P&&r._bufferIndex<L.length;)d(L.charCodeAt(r._bufferIndex));else d(L)}}function d(P){f=f(P)}function v(P){M(P)?(r.line++,r.column=1,r.offset+=P===-3?2:1,y()):P!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=P}function C(P,L){const $=L||{};return $.type=P,$.start=x(),c.events.push(["enter",$,c]),a.push($),$}function A(P){const L=a.pop();return L.end=x(),c.events.push(["exit",L,c]),L}function z(P,L){_(P,L.from)}function w(P,L){L.restore()}function B(P,L){return $;function $(X,q,R){let D,J,ue,m;return Array.isArray(X)?he(X):"tokenize"in X?he([X]):ye(X);function ye(G){return Ne;function Ne(me){const Ae=me!==null&&G[me],Te=me!==null&&G.null;return he([...Array.isArray(Ae)?Ae:Ae?[Ae]:[],...Array.isArray(Te)?Te:Te?[Te]:[]])(me)}}function he(G){return D=G,J=0,G.length===0?R:g(G[J])}function g(G){return Ne;function Ne(me){return m=j(),ue=G,G.partial||(c.currentConstruct=G),G.name&&c.parser.constructs.disable.null.includes(G.name)?Ce(me):G.tokenize.call(L?Object.assign(Object.create(c),L):c,u,ke,Ce)(me)}}function ke(G){return P(ue,m),q}function Ce(G){return m.restore(),++J<D.length?g(D[J]):R}}}function _(P,L){P.resolveAll&&!l.includes(P)&&l.push(P),P.resolve&&oe(c.events,L,c.events.length-L,P.resolve(c.events.slice(L),c)),P.resolveTo&&(c.events=P.resolveTo(c.events,c))}function j(){const P=x(),L=c.previous,$=c.currentConstruct,X=c.events.length,q=Array.from(a);return{from:X,restore:R};function R(){r=P,c.previous=L,c.currentConstruct=$,c.events.length=X,a=q,y()}}function y(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function qo(e,n){const t=n.start._index,r=n.start._bufferIndex,i=n.end._index,l=n.end._bufferIndex;let o;if(t===i)o=[e[t].slice(r,l)];else{if(o=e.slice(t,i),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}l>0&&o.push(e[i].slice(0,l))}return o}function Uo(e,n){let t=-1;const r=[];let i;for(;++t<e.length;){const l=e[t];let o;if(typeof l=="string")o=l;else switch(l){case-5:o="\r";break;case-4:o=`
3
3
  `;break;case-3:o=`\r
4
4
  `;break;case-2:o=n?" ":" ";break;case-1:if(!n&&i)continue;o=" ";break;default:o=String.fromCharCode(l)}i=l===-2,r.push(o)}return r.join("")}function $o(e){const n={constructs:ir([zo,...(e||{}).extensions||[]]),content:t(il),defined:[],document:t(ol),flow:t(Eo),lazy:{},string:t(To),text:t(Po)};return n;function t(r){return i;function i(l){return Ho(n,r,l)}}}function Vo(e){for(;!sr(e););return e}var kn=/[\0\t\n\r]/g;function Wo(){let e=1,n="",t=!0,r;return i;function i(l,o,a){const u=[];let c,f,s,h,p;for(l=n+(typeof l=="string"?l.toString():new TextDecoder(o||void 0).decode(l)),s=0,n="",t&&(l.charCodeAt(0)===65279&&s++,t=void 0);s<l.length;){if(kn.lastIndex=s,c=kn.exec(l),h=c&&c.index!==void 0?c.index:l.length,p=l.charCodeAt(h),!c){n=l.slice(s);break}if(p===10&&s===h&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),s<h&&(u.push(l.slice(s,h)),e+=h-s),p){case 0:u.push(65533),e++;break;case 9:for(f=Math.ceil(e/4)*4,u.push(-2);e++<f;)u.push(-1);break;case 10:u.push(-4),e=1;break;default:r=!0,e=1}s=h+1}return a&&(r&&u.push(-5),n&&u.push(n),u.push(null)),u}}var Xo=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Yo(e){return e.replace(Xo,Qo)}function Qo(e,n,t){if(n)return n;if(t.charCodeAt(0)===35){const r=t.charCodeAt(1),i=r===120||r===88;return lr(t.slice(i?2:1),i?16:10)}return Vt(t)||e}var gr={}.hasOwnProperty;function Jo(e,n,t){return typeof n!="string"&&(t=n,n=void 0),Ko(t)(Vo($o(t).document().write(Wo()(e,n,!0))))}function Ko(e){const n={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:l(tn),autolinkProtocol:j,autolinkEmail:j,atxHeading:l(Gt),blockQuote:l(Te),characterEscape:j,characterReference:j,codeFenced:l(Kt),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:l(Kt,o),codeText:l(Jr,o),codeTextData:j,data:j,codeFlowValue:j,definition:l(Kr),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:l(Gr),hardBreakEscape:l(Zt),hardBreakTrailing:l(Zt),htmlFlow:l(en,o),htmlFlowData:j,htmlText:l(en,o),htmlTextData:j,image:l(Zr),label:o,link:l(tn),listItem:l(ei),listItemValue:h,listOrdered:l(nn,s),listUnordered:l(nn),paragraph:l(ti),reference:g,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:l(Gt),strong:l(ni),thematicBreak:l(ii)},exit:{atxHeading:u(),atxHeadingSequence:z,autolink:u(),autolinkEmail:Ae,autolinkProtocol:me,blockQuote:u(),characterEscapeValue:y,characterReferenceMarkerHexadecimal:Ce,characterReferenceMarkerNumeric:Ce,characterReferenceValue:G,characterReference:Ne,codeFenced:u(S),codeFencedFence:k,codeFencedFenceInfo:p,codeFencedFenceMeta:x,codeFlowValue:y,codeIndented:u(d),codeText:u(q),codeTextData:y,data:y,definition:u(),definitionDestinationString:A,definitionLabelString:v,definitionTitleString:C,emphasis:u(),hardBreakEscape:u(L),hardBreakTrailing:u(L),htmlFlow:u($),htmlFlowData:y,htmlText:u(X),htmlTextData:y,image:u(D),label:ue,labelText:J,lineEnding:P,link:u(R),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:ke,resourceDestinationString:m,resourceTitleString:ye,resource:he,setextHeading:u(_),setextHeadingLineSequence:B,setextHeadingText:w,strong:u(),thematicBreak:u()}};dr(n,(e||{}).mdastExtensions||[]);const t={};return r;function r(b){let I={type:"root",children:[]};const O={stack:[I],tokenStack:[],config:n,enter:a,exit:c,buffer:o,resume:f,data:t},Y=[];let Q=-1;for(;++Q<b.length;)(b[Q][1].type==="listOrdered"||b[Q][1].type==="listUnordered")&&(b[Q][0]==="enter"?Y.push(Q):Q=i(b,Y.pop(),Q));for(Q=-1;++Q<b.length;){const be=n[b[Q][0]];gr.call(be,b[Q][1].type)&&be[b[Q][1].type].call(Object.assign({sliceSerialize:b[Q][2].sliceSerialize},O),b[Q][1])}if(O.tokenStack.length>0){const be=O.tokenStack[O.tokenStack.length-1];(be[1]||bn).call(O,void 0,be[0])}for(I.position={start:we(b.length>0?b[0][1].start:{line:1,column:1,offset:0}),end:we(b.length>0?b[b.length-2][1].end:{line:1,column:1,offset:0})},Q=-1;++Q<n.transforms.length;)I=n.transforms[Q](I)||I;return I}function i(b,I,O){let Y=I-1,Q=-1,be=!1,Pe,ge,Be,je;for(;++Y<=O;){const ie=b[Y];switch(ie[1].type){case"listUnordered":case"listOrdered":case"blockQuote":ie[0]==="enter"?Q++:Q--,je=void 0;break;case"lineEndingBlank":ie[0]==="enter"&&(Pe&&!je&&!Q&&!Be&&(Be=Y),je=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:je=void 0}if(!Q&&ie[0]==="enter"&&ie[1].type==="listItemPrefix"||Q===-1&&ie[0]==="exit"&&(ie[1].type==="listUnordered"||ie[1].type==="listOrdered")){if(Pe){let Le=Y;for(ge=void 0;Le--;){const de=b[Le];if(de[1].type==="lineEnding"||de[1].type==="lineEndingBlank"){if(de[0]==="exit")continue;ge&&(b[ge][1].type="lineEndingBlank",be=!0),de[1].type="lineEnding",ge=Le}else if(!(de[1].type==="linePrefix"||de[1].type==="blockQuotePrefix"||de[1].type==="blockQuotePrefixWhitespace"||de[1].type==="blockQuoteMarker"||de[1].type==="listItemIndent"))break}Be&&(!ge||Be<ge)&&(Pe._spread=!0),Pe.end=Object.assign({},ge?b[ge][1].start:ie[1].end),b.splice(ge||Y,0,["exit",Pe,ie[2]]),Y++,O++}if(ie[1].type==="listItemPrefix"){const Le={type:"listItem",_spread:!1,start:Object.assign({},ie[1].start),end:void 0};Pe=Le,b.splice(Y,0,["enter",Le,ie[2]]),Y++,O++,Be=void 0,je=!0}}}return b[I][1]._spread=be,O}function l(b,I){return O;function O(Y){a.call(this,b(Y),Y),I&&I.call(this,Y)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(b,I,O){this.stack[this.stack.length-1].children.push(b),this.stack.push(b),this.tokenStack.push([I,O||void 0]),b.position={start:we(I.start),end:void 0}}function u(b){return I;function I(O){b&&b.call(this,O),c.call(this,O)}}function c(b,I){const O=this.stack.pop(),Y=this.tokenStack.pop();if(Y)Y[0].type!==b.type&&(I?I.call(this,b,Y[0]):(Y[1]||bn).call(this,b,Y[0]));else throw new Error("Cannot close `"+b.type+"` ("+Ue({start:b.start,end:b.end})+"): it’s not open");O.position.end=we(b.end)}function f(){return $t(this.stack.pop())}function s(){this.data.expectingFirstListItemValue=!0}function h(b){if(this.data.expectingFirstListItemValue){const I=this.stack[this.stack.length-2];I.start=Number.parseInt(this.sliceSerialize(b),10),this.data.expectingFirstListItemValue=void 0}}function p(){const b=this.resume(),I=this.stack[this.stack.length-1];I.lang=b}function x(){const b=this.resume(),I=this.stack[this.stack.length-1];I.meta=b}function k(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const b=this.resume(),I=this.stack[this.stack.length-1];I.value=b.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function d(){const b=this.resume(),I=this.stack[this.stack.length-1];I.value=b.replace(/(\r?\n|\r)$/g,"")}function v(b){const I=this.resume(),O=this.stack[this.stack.length-1];O.label=I,O.identifier=se(this.sliceSerialize(b)).toLowerCase()}function C(){const b=this.resume(),I=this.stack[this.stack.length-1];I.title=b}function A(){const b=this.resume(),I=this.stack[this.stack.length-1];I.url=b}function z(b){const I=this.stack[this.stack.length-1];I.depth||(I.depth=this.sliceSerialize(b).length)}function w(){this.data.setextHeadingSlurpLineEnding=!0}function B(b){const I=this.stack[this.stack.length-1];I.depth=this.sliceSerialize(b).codePointAt(0)===61?1:2}function _(){this.data.setextHeadingSlurpLineEnding=void 0}function j(b){const I=this.stack[this.stack.length-1].children;let O=I[I.length-1];(!O||O.type!=="text")&&(O=ri(),O.position={start:we(b.start),end:void 0},I.push(O)),this.stack.push(O)}function y(b){const I=this.stack.pop();I.value+=this.sliceSerialize(b),I.position.end=we(b.end)}function P(b){const I=this.stack[this.stack.length-1];if(this.data.atHardBreak){const O=I.children[I.children.length-1];O.position.end=we(b.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&n.canContainEols.includes(I.type)&&(j.call(this,b),y.call(this,b))}function L(){this.data.atHardBreak=!0}function $(){const b=this.resume(),I=this.stack[this.stack.length-1];I.value=b}function X(){const b=this.resume(),I=this.stack[this.stack.length-1];I.value=b}function q(){const b=this.resume(),I=this.stack[this.stack.length-1];I.value=b}function R(){const b=this.stack[this.stack.length-1];if(this.data.inReference){const I=this.data.referenceType||"shortcut";b.type+="Reference",b.referenceType=I,delete b.url,delete b.title}else delete b.identifier,delete b.label;this.data.referenceType=void 0}function D(){const b=this.stack[this.stack.length-1];if(this.data.inReference){const I=this.data.referenceType||"shortcut";b.type+="Reference",b.referenceType=I,delete b.url,delete b.title}else delete b.identifier,delete b.label;this.data.referenceType=void 0}function J(b){const I=this.sliceSerialize(b),O=this.stack[this.stack.length-2];O.label=Yo(I),O.identifier=se(I).toLowerCase()}function ue(){const b=this.stack[this.stack.length-1],I=this.resume(),O=this.stack[this.stack.length-1];this.data.inReference=!0,O.type==="link"?O.children=b.children:O.alt=I}function m(){const b=this.resume(),I=this.stack[this.stack.length-1];I.url=b}function ye(){const b=this.resume(),I=this.stack[this.stack.length-1];I.title=b}function he(){this.data.inReference=void 0}function g(){this.data.referenceType="collapsed"}function ke(b){const I=this.resume(),O=this.stack[this.stack.length-1];O.label=I,O.identifier=se(this.sliceSerialize(b)).toLowerCase(),this.data.referenceType="full"}function Ce(b){this.data.characterReferenceType=b.type}function G(b){const I=this.sliceSerialize(b),O=this.data.characterReferenceType;let Y;O?(Y=lr(I,O==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Y=Vt(I);const Q=this.stack[this.stack.length-1];Q.value+=Y}function Ne(b){const I=this.stack.pop();I.position.end=we(b.end)}function me(b){y.call(this,b);const I=this.stack[this.stack.length-1];I.url=this.sliceSerialize(b)}function Ae(b){y.call(this,b);const I=this.stack[this.stack.length-1];I.url="mailto:"+this.sliceSerialize(b)}function Te(){return{type:"blockquote",children:[]}}function Kt(){return{type:"code",lang:null,meta:null,value:""}}function Jr(){return{type:"inlineCode",value:""}}function Kr(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Gr(){return{type:"emphasis",children:[]}}function Gt(){return{type:"heading",depth:0,children:[]}}function Zt(){return{type:"break"}}function en(){return{type:"html",value:""}}function Zr(){return{type:"image",title:null,url:"",alt:null}}function tn(){return{type:"link",title:null,url:"",children:[]}}function nn(b){return{type:"list",ordered:b.type==="listOrdered",start:null,spread:b._spread,children:[]}}function ei(b){return{type:"listItem",spread:b._spread,checked:null,children:[]}}function ti(){return{type:"paragraph",children:[]}}function ni(){return{type:"strong",children:[]}}function ri(){return{type:"text",value:""}}function ii(){return{type:"thematicBreak"}}}function we(e){return{line:e.line,column:e.column,offset:e.offset}}function dr(e,n){let t=-1;for(;++t<n.length;){const r=n[t];Array.isArray(r)?dr(e,r):Go(e,r)}}function Go(e,n){let t;for(t in n)if(gr.call(n,t))switch(t){case"canContainEols":{const r=n[t];r&&e[t].push(...r);break}case"transforms":{const r=n[t];r&&e[t].push(...r);break}case"enter":case"exit":{const r=n[t];r&&Object.assign(e[t],r);break}}}function bn(e,n){throw e?new Error("Cannot close `"+e.type+"` ("+Ue({start:e.start,end:e.end})+"): a different token (`"+n.type+"`, "+Ue({start:n.start,end:n.end})+") is open"):new Error("Cannot close document, a token (`"+n.type+"`, "+Ue({start:n.start,end:n.end})+") is still open")}function Zo(e){const n=this;n.parser=t;function t(r){return Jo(r,{...n.data("settings"),...e,extensions:n.data("micromarkExtensions")||[],mdastExtensions:n.data("fromMarkdownExtensions")||[]})}}function ea(e,n){const t={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(n),!0)};return e.patch(n,t),e.applyData(n,t)}function ta(e,n){const t={type:"element",tagName:"br",properties:{},children:[]};return e.patch(n,t),[e.applyData(n,t),{type:"text",value:`
package/dist/react.d.cts CHANGED
@@ -547,6 +547,11 @@ export declare function createMockClient(options?: MockAgoClientOptions): MockAg
547
547
  * Pure — the single home for the "required + non-empty" rule, shared by the update
548
548
  * handler, submit, the dynamic context, and the React hook. Derived on read so the
549
549
  * store only ever holds canonical state ({@link FormCollectorState}).
550
+ *
551
+ * Requiredness is answer-dependent: a field listed in `required` is required unless
552
+ * it carries a `requiredWhen` that doesn't currently hold, and any field whose
553
+ * `requiredWhen` holds becomes required. So conditional fields surface in `missing`
554
+ * exactly when the answers make them relevant.
550
555
  */
551
556
  export declare function deriveFormStatus(schema: FormCollectorSchema, values: Partial<Record<string, unknown>>): FormCollectorStatus;
552
557
 
@@ -585,11 +590,14 @@ export declare interface FormCollector<V = Record<string, unknown>> {
585
590
  }
586
591
 
587
592
  /**
588
- * JSON-schema shape of a form's fields — identical to a client function's
589
- * `parameters`, so one schema feeds the store, the update function, and the
590
- * dynamic context with no second type.
593
+ * Shape of a form's fields. Mirrors a client function's `parameters` (so the same
594
+ * object feeds the store, the update function, and the dynamic context). Additionally allows the SDK-only per-field `requiredWhen`, which {@link toWireParameters} removes before the schema reaches the LLM.
591
595
  */
592
- export declare type FormCollectorSchema = ClientFunctionSchema["parameters"];
596
+ export declare interface FormCollectorSchema {
597
+ type: "object";
598
+ properties: Record<string, FormFieldSchema>;
599
+ required?: string[];
600
+ }
593
601
 
594
602
  /** Canonical, source-of-truth state held in the collector's store. */
595
603
  export declare interface FormCollectorState<V = Record<string, unknown>> {
@@ -615,6 +623,43 @@ declare interface FormField {
615
623
  default?: unknown;
616
624
  }
617
625
 
626
+ /**
627
+ * A field's conditional-requiredness rule. The field becomes required exactly
628
+ * when the controlling `property` matches `value` against the answers collected
629
+ * so far:
630
+ * - a single `value`, no `op` — equality (compared as strings);
631
+ * - a single `value` with `op` — numeric comparison (both sides coerced to numbers);
632
+ * - an array `value`, no `op` — "one of": matches when the property equals any
633
+ * listed value.
634
+ *
635
+ * SDK-only — it is stripped from the schema before it reaches the LLM tool
636
+ */
637
+ declare interface FormFieldCondition {
638
+ /** The controlling field whose value the rule tests. */
639
+ property: string;
640
+ /** Comparison operator; omitted means equality. Ignored when `value` is an array. */
641
+ op?: ">=" | "<=" | ">" | "<";
642
+ /**
643
+ * The value(s) to test the controlling field against. A single value is an
644
+ * equality (or, with `op`, a numeric comparison); an array is an "is one of"
645
+ * membership test, e.g. `value: ["1", "2", "3"]`.
646
+ */
647
+ value: string | number | Array<string | number>;
648
+ }
649
+
650
+ /** A single field's schema: the wire-legal keys plus the SDK-only `requiredWhen`. */
651
+ declare interface FormFieldSchema {
652
+ type: string;
653
+ description?: string;
654
+ enum?: string[];
655
+ default?: unknown;
656
+ /**
657
+ * Makes the field required only while this condition holds. Drives the dynamic
658
+ * `missing` list; stripped before the LLM tool — see {@link toWireParameters}.
659
+ */
660
+ requiredWhen?: FormFieldCondition;
661
+ }
662
+
618
663
  /**
619
664
  * Form schema for tool calls requiring user input
620
665
  */
package/dist/react.d.ts CHANGED
@@ -547,6 +547,11 @@ export declare function createMockClient(options?: MockAgoClientOptions): MockAg
547
547
  * Pure — the single home for the "required + non-empty" rule, shared by the update
548
548
  * handler, submit, the dynamic context, and the React hook. Derived on read so the
549
549
  * store only ever holds canonical state ({@link FormCollectorState}).
550
+ *
551
+ * Requiredness is answer-dependent: a field listed in `required` is required unless
552
+ * it carries a `requiredWhen` that doesn't currently hold, and any field whose
553
+ * `requiredWhen` holds becomes required. So conditional fields surface in `missing`
554
+ * exactly when the answers make them relevant.
550
555
  */
551
556
  export declare function deriveFormStatus(schema: FormCollectorSchema, values: Partial<Record<string, unknown>>): FormCollectorStatus;
552
557
 
@@ -585,11 +590,14 @@ export declare interface FormCollector<V = Record<string, unknown>> {
585
590
  }
586
591
 
587
592
  /**
588
- * JSON-schema shape of a form's fields — identical to a client function's
589
- * `parameters`, so one schema feeds the store, the update function, and the
590
- * dynamic context with no second type.
593
+ * Shape of a form's fields. Mirrors a client function's `parameters` (so the same
594
+ * object feeds the store, the update function, and the dynamic context). Additionally allows the SDK-only per-field `requiredWhen`, which {@link toWireParameters} removes before the schema reaches the LLM.
591
595
  */
592
- export declare type FormCollectorSchema = ClientFunctionSchema["parameters"];
596
+ export declare interface FormCollectorSchema {
597
+ type: "object";
598
+ properties: Record<string, FormFieldSchema>;
599
+ required?: string[];
600
+ }
593
601
 
594
602
  /** Canonical, source-of-truth state held in the collector's store. */
595
603
  export declare interface FormCollectorState<V = Record<string, unknown>> {
@@ -615,6 +623,43 @@ declare interface FormField {
615
623
  default?: unknown;
616
624
  }
617
625
 
626
+ /**
627
+ * A field's conditional-requiredness rule. The field becomes required exactly
628
+ * when the controlling `property` matches `value` against the answers collected
629
+ * so far:
630
+ * - a single `value`, no `op` — equality (compared as strings);
631
+ * - a single `value` with `op` — numeric comparison (both sides coerced to numbers);
632
+ * - an array `value`, no `op` — "one of": matches when the property equals any
633
+ * listed value.
634
+ *
635
+ * SDK-only — it is stripped from the schema before it reaches the LLM tool
636
+ */
637
+ declare interface FormFieldCondition {
638
+ /** The controlling field whose value the rule tests. */
639
+ property: string;
640
+ /** Comparison operator; omitted means equality. Ignored when `value` is an array. */
641
+ op?: ">=" | "<=" | ">" | "<";
642
+ /**
643
+ * The value(s) to test the controlling field against. A single value is an
644
+ * equality (or, with `op`, a numeric comparison); an array is an "is one of"
645
+ * membership test, e.g. `value: ["1", "2", "3"]`.
646
+ */
647
+ value: string | number | Array<string | number>;
648
+ }
649
+
650
+ /** A single field's schema: the wire-legal keys plus the SDK-only `requiredWhen`. */
651
+ declare interface FormFieldSchema {
652
+ type: string;
653
+ description?: string;
654
+ enum?: string[];
655
+ default?: unknown;
656
+ /**
657
+ * Makes the field required only while this condition holds. Drives the dynamic
658
+ * `missing` list; stripped before the LLM tool — see {@link toWireParameters}.
659
+ */
660
+ requiredWhen?: FormFieldCondition;
661
+ }
662
+
618
663
  /**
619
664
  * Form schema for tool calls requiring user input
620
665
  */
package/dist/react.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { n as Vn, r as Wn, t as Ge } from "./rolldown-runtime-DxmricAu.js";
2
2
  import { t as ui } from "./AgoClient-rvTz2thR.js";
3
- import { n as si, t as Xn } from "./createFormCollector-D4-yZh1i.js";
3
+ import { n as si, t as Xn } from "./createFormCollector-DON4vdJV.js";
4
4
  import { t as sf } from "./createMockClient-DwdxNwEn.js";
5
5
  import ci, { createContext as fi, useCallback as xe, useContext as Yn, useEffect as te, useId as pi, useMemo as We, useRef as Ne, useState as se, useSyncExternalStore as hi } from "react";
6
6
  import { Fragment as Qn, jsx as M, jsxs as ce } from "react/jsx-runtime";
package/dist/widget.cjs CHANGED
@@ -1 +1,5 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ue=require("./AgoClient-D4EL6nva.cjs"),ge=require("./createFormCollector-DLwgDX24.cjs"),xe=require("./createConversationSession-DibXdxoC.cjs");var oe='var(--ago-font, "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif)',Z={font:"--ago-font",radius:"--ago-radius",messageRadius:"--ago-message-radius",brand:"--ago-brand-color",brandText:"--ago-brand-text-color",headerBg:"--ago-header-background",headerText:"--ago-header-text-color",panelBg:"--ago-panel-background",messagesBg:"--ago-messages-background",text:"--ago-text-color",mutedText:"--ago-muted-text-color",border:"--ago-border-color",accent:"--ago-accent-color"},ne="var(--ago-brand-color, #03182f)",re="var(--ago-brand-text-color, #fff)",me="var(--ago-header-background, var(--ago-brand-color, #03182f))",he="var(--ago-header-text-color, #e8f0fe)",L="var(--ago-panel-background, #fff)",be="var(--ago-messages-background, #fbfbfb)",z="var(--ago-text-color, #30373e)",ve="var(--ago-muted-text-color, #6b6d6f)",E="var(--ago-border-color, #dee3e8)",q="var(--ago-accent-color, #1b5fc4)",Ce="var(--ago-radius, 16px)",ee="var(--ago-message-radius, 16px)";function ye(i,o){if(o)for(const u of Object.keys(Z)){const w=o[u];w!=null&&i.style.setProperty(Z[u],w)}}function m(i,o){Object.assign(i.style,o)}function c(i={}){const o=document.createElement("div");return m(o,i),o}var te="ago-chat-widget-keyframes";function Ee(){if(typeof document>"u"||document.getElementById(te))return;const i=document.createElement("style");i.id=te,i.textContent="@keyframes ago-pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }",document.head.appendChild(i)}function we(i){const o=typeof i=="string"?document.querySelector(i):i;if(!o)throw new Error(`mountChatWidget: target "${String(i)}" not found.`);return o}function Se(i,o){const{title:u="Chat",welcomeMessage:w="Hello! How can I help you today?",placeholder:O="Type a message...",allowFiles:g=!1,height:x=500,logoUrl:f,showAgentName:v=!1,theme:T,loadThreads:D=!1,forms:B,onFollowUpClick:s,onMessageSent:C,onMessageReceived:$}=o;if(!o.client&&!o.config?.baseUrl)throw new Error("mountChatWidget requires either `client` or `config` (with a baseUrl).");const l=o.client??new ue.AgoClient(o.config),_=we(i),M=o.persistConversation,I=M?xe.createConversationSession(M===!0?{}:M):void 0;let h=o.conversationId??I?.getLastActiveThread()??void 0,n=[],k=!1,N=null;const U=[],A=c({display:"flex",flexDirection:"column",height:typeof x=="number"?`${x}px`:x,border:`1px solid ${E}`,borderRadius:Ce,overflow:"hidden",backgroundColor:L,fontFamily:oe,textAlign:"left",boxShadow:"rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"});A.className="ago-chat-widget",ye(A,T);const W=c({padding:"14px 16px",borderBottom:`1px solid ${E}`,backgroundColor:me,color:he,display:"flex",alignItems:"center",gap:"10px"});if(W.className="ago-chat-widget__header",f){const e=document.createElement("img");e.src=f,e.alt="Logo",m(e,{height:"24px",width:"auto"}),W.appendChild(e)}const H=document.createElement("h3");H.textContent=u,m(H,{margin:"0",fontSize:"15px",fontWeight:"600"}),W.appendChild(H);const S=c({flex:"1",overflow:"auto",padding:"16px",backgroundColor:be});S.className="ago-chat-widget__messages";const{inputRow:ae,setDisabled:se,focus:ie}=Re({placeholder:O,allowFiles:g,onSend:(e,t)=>{F(e,t)}});Ee(),A.append(W,S,ae),_.appendChild(A);const K=s!==!1,j=s===!1?void 0:s??(e=>{F(e)});function le(e){const t=e.role==="user",d=c({display:"flex",flexDirection:"column",alignItems:t?"flex-end":"flex-start",marginBottom:"16px"});if(d.className=`ago-message ago-message--${e.role}`,!t&&v&&e.agent){const r=c({fontSize:"13px",fontWeight:"500",color:z,marginBottom:"6px",padding:"0 4px"});r.className="ago-message__agent",r.textContent=e.agent.displayName||e.agent.name,d.appendChild(r)}if(!t&&e.sources&&e.sources.length>0){const r=c({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"10px",width:"100%",maxWidth:"85%"});r.className="ago-message__sources",e.sources.forEach((p,a)=>{const y=p.url?document.createElement("a"):document.createElement("div");p.url&&y instanceof HTMLAnchorElement&&(y.href=p.url,y.target="_blank",y.rel="noopener noreferrer"),m(y,{display:"flex",alignItems:"center",gap:"8px",padding:"8px 10px",border:`1px solid ${E}`,borderRadius:"8px",backgroundColor:L,textDecoration:"none",color:z,fontSize:"12px",overflow:"hidden"});const Q=c({flexShrink:"0",width:"18px",height:"18px",borderRadius:"3px",border:`1px solid ${q}`,color:q,fontSize:"11px",fontWeight:"500",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f0f4ff"});Q.textContent=String(a+1);const P=c({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});P.textContent=p.title,P.title=p.title,y.append(Q,P),r.appendChild(y)}),d.appendChild(r)}const b=c({maxWidth:t?"75%":"100%",padding:t?"10px 14px":"2px 8px",borderRadius:t?ee:"0",backgroundColor:t?ne:"transparent",color:t?re:z,wordBreak:"break-word",fontSize:"14px",lineHeight:"1.6",whiteSpace:"pre-wrap"});if(b.className="ago-message__content",e.content?b.textContent=e.content:e.status==="IN_PROGRESS"&&b.appendChild(fe()),d.appendChild(b),e.followUpReplies&&e.followUpReplies.length>0){const r=c({display:"flex",flexWrap:"wrap",gap:"8px",marginTop:"10px"});r.className="ago-message__followups";for(const p of e.followUpReplies){const a=document.createElement("button");a.type="button",a.className="ago-message__followup-btn",a.textContent=p,a.disabled=!K,m(a,{padding:"6px 14px",fontSize:"13px",borderRadius:ee,border:`1px solid ${E}`,backgroundColor:L,color:z,cursor:K?"pointer":"default",transition:"border-color 0.15s"}),j&&a.addEventListener("click",()=>j(p)),a.addEventListener("mouseenter",()=>{a.style.borderColor=q}),a.addEventListener("mouseleave",()=>{a.style.borderColor=E}),r.appendChild(a)}d.appendChild(r)}return d}function R(){if(S.replaceChildren(),n.length===0){const e=c({textAlign:"center",color:ve,padding:"24px 16px",fontSize:"14px",lineHeight:"1.5"});e.textContent=w,S.appendChild(e)}else for(const e of n)S.appendChild(le(e));if(N){const e=c({padding:"10px 14px",backgroundColor:"#fef2f2",color:"#dc2626",borderRadius:"12px",marginTop:"8px",fontSize:"13px",border:"1px solid #fecaca"});e.textContent=N,S.appendChild(e)}S.scrollTop=S.scrollHeight,se(k)}function de(){for(let e=n.length-1;e>=0;e--){const t=n[e];if(t.role==="assistant"&&t.status==="IN_PROGRESS")return t}}const X=e=>{h||(h=e.conversationId)},V=e=>{const t=de();t&&(t.content+=e.content,R())},Y=e=>{const t=n.findIndex(d=>d.id===e.id||d.role==="assistant"&&d.status==="IN_PROGRESS");t>=0?n[t]=e:n.push(e),k=!1,R(),e.status==="DONE"&&$?.({id:e.id,content:e.content})},J=e=>{N=e.error,k=!1,n=n.filter(t=>!t.id.startsWith("temp-")),R()};l.on("message:start",X),l.on("message:chunk",V),l.on("message:complete",Y),l.on("message:error",J);const ce=(B??[]).map(e=>ge.createFormCollector(e).install(l));async function F(e,t){const d=e.trim();if(!d&&!t?.length||k)return;C?.(d),k=!0,N=null;const b=Date.now();n.push({id:`temp-user-${b}`,conversationId:h||"",content:d,role:"user",status:"DONE",createdAt:new Date}),n.push({id:`temp-assistant-${b}`,conversationId:h||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date}),R();try{const r=await l.sendMessage(d,{conversationId:h,files:t});r.conversationId&&(h||(h=r.conversationId),I?.setActiveThread(r.conversationId,r.createdAt));const p=n.find(a=>a.id===`temp-user-${b}`);if(p&&(p.id=`user-${b}`,p.conversationId=r.conversationId),!n.some(a=>a.id===r.id)){const a=n.findIndex(y=>y.id===`temp-assistant-${b}`);a>=0?n[a]=r:n.push(r)}n=n.filter(a=>!a.id.startsWith("temp-")),k=!1,R(),D&&G()}catch(r){N=r instanceof Error?r.message:"Failed to send message",k=!1,n=n.filter(p=>!p.id.startsWith("temp-")),R()}}async function G(){try{const e=await l.getConversations();U.splice(0,U.length,...e)}catch{}return U}async function pe(e){try{const t=(await l.getConversation(e))?.messages??[];t.length>0&&n.length===0&&(n=t,R())}catch{n.length===0&&(I?.clear(),h=void 0)}}return R(),ie(),h&&pe(h),D&&G(),{client:l,element:A,sendMessage:F,session:I,threads:U,refreshThreads:G,destroy(){l.off("message:start",X),l.off("message:chunk",V),l.off("message:complete",Y),l.off("message:error",J),ce.forEach(e=>e()),A.remove(),o.client||l.destroy()}};function fe(){const e=c({display:"flex",gap:"4px",padding:"4px 0"});for(let t=0;t<3;t++){const d=c({width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#b5bfc8",animation:"ago-pulse 1.2s ease-in-out infinite",animationDelay:`${t*.2}s`});e.appendChild(d)}return e}}function Re(i){let o=[];const u=document.createElement("form");m(u,{display:"flex",flexDirection:"column",gap:"8px",padding:"12px",borderTop:`1px solid ${E}`,backgroundColor:L}),u.className="ago-chat-input";const w=c({display:"flex",flexWrap:"wrap",gap:"6px"}),O=c({display:"flex",gap:"8px",alignItems:"flex-end"}),g=document.createElement("textarea");g.placeholder=i.placeholder,g.rows=1,m(g,{flex:"1",resize:"none",padding:"10px 12px",border:`1px solid ${E}`,borderRadius:"12px",fontSize:"14px",fontFamily:oe,lineHeight:"1.4",maxHeight:"120px",outline:"none"});const x=document.createElement("button");x.type="submit",x.textContent="Send",m(x,{padding:"10px 16px",border:"none",borderRadius:"12px",backgroundColor:ne,color:re,fontSize:"14px",fontWeight:"500",cursor:"pointer"});let f=null,v=null;i.allowFiles&&(f=document.createElement("input"),f.type="file",f.multiple=!0,m(f,{display:"none"}),v=document.createElement("button"),v.type="button",v.textContent="📎",m(v,{padding:"10px 12px",border:`1px solid ${E}`,borderRadius:"12px",backgroundColor:L,cursor:"pointer",fontSize:"14px"}),v.addEventListener("click",()=>f?.click()),f.addEventListener("change",()=>{o=[...o,...Array.from(f?.files??[])],T()}));function T(){w.replaceChildren(),o.forEach((s,C)=>{const $=c({display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",backgroundColor:"#f0f4ff",border:`1px solid ${E}`,borderRadius:"8px",fontSize:"12px"}),l=document.createElement("span");l.textContent=s.name;const _=document.createElement("button");_.type="button",_.textContent="×",m(_,{border:"none",background:"transparent",cursor:"pointer",fontSize:"14px",lineHeight:"1"}),_.addEventListener("click",()=>{o=o.filter((M,I)=>I!==C),T()}),$.append(l,_),w.appendChild($)})}const D=()=>{const s=g.value,C=o;return g.value="",o=[],T(),{content:s,files:C}},B=()=>{const{content:s,files:C}=D();(s.trim()||C.length>0)&&i.onSend(s.trim(),C.length>0?C:void 0)};return u.addEventListener("submit",s=>{s.preventDefault(),B()}),g.addEventListener("keydown",s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),B())}),v&&O.appendChild(v),O.append(g,x),f&&u.appendChild(f),u.append(w,O),{inputRow:u,getValueAndClear:D,setDisabled:s=>{g.disabled=s,x.disabled=s,x.style.opacity=s?"0.6":"1",x.style.cursor=s?"not-allowed":"pointer"},focus:()=>g.focus()}}exports.mountChatWidget=Se;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ke=require("./AgoClient-D4EL6nva.cjs"),$e=require("./createFormCollector-IO6bfPQx.cjs"),Ie=require("./createConversationSession-DGcM_Z3f.cjs");var Te={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function M(o){return o.replace(/[&<>"']/g,n=>Te[n])}function se(o){const n=o.trim();return/^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(n)||!/^[a-z][a-z0-9+.-]*:/i.test(n)?n:null}var pe='"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace',q="";function O(o){const n=[],r=u=>(n.push(u),`${q}${n.length-1}${q}`);let e=o;return e=e.replace(/`([^`]+)`/g,(u,a)=>r(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${pe}">${M(a)}</code>`)),e=e.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g,(u,a,d)=>{const i=se(d);return i?r(`<img alt="${M(a)}" src="${M(i)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`):u}),e=e.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(u,a,d)=>{const i=se(d);return i?r(`<a href="${M(i)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${O(a)}</a>`):u}),e=M(e),e=e.replace(/\*\*([^*]+?)\*\*/g,"<strong>$1</strong>").replace(/__([^_]+?)__/g,"<strong>$1</strong>").replace(/~~([^~]+?)~~/g,"<del>$1</del>").replace(/(^|[^*])\*(?!\s)([^*]+?)\*/g,"$1<em>$2</em>").replace(/(^|[^\w_])_(?!\s)([^_]+?)_/g,"$1<em>$2</em>"),e=e.replace(new RegExp(`${q}(\\d+)${q}`,"g"),(u,a)=>n[Number(a)]),e}function y(o,n,r){const e=document.createElement(o);return Object.assign(e.style,n),r!==void 0&&(e.innerHTML=r),e}var fe=/^ {0,3}([-*_])( *\1){2,} *$/,ue=/^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/,ge=/^ {0,3}(```+|~~~+)/,j=/^ {0,3}>\s?/,H=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/,Ae=["20px","18px","16px","15px","14px","13px"],Z=o=>o.match(/^\s*/)?.[0].length??0;function Le(o){return o.trim()===""||fe.test(o)||ue.test(o)||ge.test(o)||j.test(o)||H.test(o)}function me(o){const n=o[0].match(H),r=n[1].length,e=/\d/.test(n[2]),u=y(e?"ol":"ul",{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:e?"decimal":"disc",listStylePosition:"outside"});let a=0;for(;a<o.length;){const d=o[a].match(H),i=[];for(a++;a<o.length&&Z(o[a])>r;)i.push(o[a]),a++;const c=y("li",{display:"list-item",margin:"2px 0",lineHeight:"1.6"}),l=d[3].match(/^\[([ xX])\]\s+(.*)$/);l?(c.style.listStyleType="none",c.style.marginLeft="-20px",c.innerHTML=`<span style="margin-right:6px">${l[1].toLowerCase()==="x"?"☑":"☐"}</span>${O(l[2])}`):c.innerHTML=O(d[3]),i.filter(h=>H.test(h)).length>0&&c.appendChild(me(i.filter(h=>h.trim()!==""))),u.appendChild(c)}return u}function Oe(o){const n=i=>i.replace(/^\s*\|?/,"").replace(/\|?\s*$/,"").split("|").map(c=>c.trim()),r=y("div",{overflowX:"auto",margin:"0 0 8px 0"}),e=y("table",{borderCollapse:"collapse",width:"100%",fontSize:"13px"}),u=document.createElement("thead"),a=document.createElement("tr");for(const i of n(o[0]))a.appendChild(y("th",{border:"1px solid #dee3e8",padding:"6px 10px",textAlign:"left",backgroundColor:"#f5f7fa",fontWeight:"600"},O(i)));u.appendChild(a),e.appendChild(u);const d=document.createElement("tbody");for(const i of o.slice(2)){const c=document.createElement("tr");for(const l of n(i))c.appendChild(y("td",{border:"1px solid #dee3e8",padding:"6px 10px"},O(l)));d.appendChild(c)}return e.appendChild(d),r.appendChild(e),r}var Ne=o=>!!o&&/^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(o);function J(o){const n=document.createDocumentFragment(),r=o.replace(/\r\n?/g,`
2
+ `).split(`
3
+ `);let e=0;for(;e<r.length;){const a=r[e];if(a.trim()===""){e++;continue}const d=a.match(ge);if(d){const l=d[1][0],h=[];for(e++;e<r.length&&!new RegExp(`^ {0,3}${l==="`"?"`{3,}":"~{3,}"}\\s*$`).test(r[e]);)h.push(r[e]),e++;e++;const T=y("pre",{margin:"0 0 8px 0"});T.appendChild(y("code",{display:"block",background:"#f5f5f5",padding:"8px 12px",borderRadius:"6px",fontSize:"13px",overflowX:"auto",fontFamily:pe,whiteSpace:"pre"},M(h.join(`
4
+ `)))),n.appendChild(T);continue}if(fe.test(a)){n.appendChild(y("hr",{border:"none",borderTop:"1px solid #dee3e8",margin:"12px 0"})),e++;continue}const i=a.match(ue);if(i){const l=i[1].length;n.appendChild(y(`h${l}`,{margin:"16px 0 8px 0",fontSize:Ae[l-1],fontWeight:"600",lineHeight:"1.3"},O(i[2]))),e++;continue}if(j.test(a)){const l=[];for(;e<r.length&&j.test(r[e]);)l.push(r[e].replace(j,"")),e++;const h=y("blockquote",{borderLeft:"4px solid #dee3e8",paddingLeft:"12px",margin:"0 0 8px 0",fontStyle:"italic",color:"#6b6d6f"});h.appendChild(J(l.join(`
5
+ `))),n.appendChild(h);continue}if(a.includes("|")&&Ne(r[e+1])){const l=[a,r[e+1]];for(e+=2;e<r.length&&r[e].includes("|")&&r[e].trim();)l.push(r[e]),e++;n.appendChild(Oe(l));continue}if(H.test(a)){const l=[],h=Z(a);for(;e<r.length&&r[e].trim()!=="";)if(H.test(r[e])||Z(r[e])>h)l.push(r[e]),e++;else break;n.appendChild(me(l));continue}const c=[a];for(e++;e<r.length&&!Le(r[e]);)c.push(r[e]),e++;n.appendChild(y("p",{margin:"0 0 8px 0",lineHeight:"1.6"},c.map(l=>O(l)).join("<br>")))}const u=n.lastElementChild;return u&&(u.style.marginBottom="0"),n}var he='var(--ago-font, "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif)',le={font:"--ago-font",radius:"--ago-radius",messageRadius:"--ago-message-radius",brand:"--ago-brand-color",brandText:"--ago-brand-text-color",headerBg:"--ago-header-background",headerText:"--ago-header-text-color",panelBg:"--ago-panel-background",messagesBg:"--ago-messages-background",text:"--ago-text-color",mutedText:"--ago-muted-text-color",border:"--ago-border-color",accent:"--ago-accent-color"},xe="var(--ago-brand-color, #03182f)",be="var(--ago-brand-text-color, #fff)",De="var(--ago-header-background, var(--ago-brand-color, #03182f))",Me="var(--ago-header-text-color, #e8f0fe)",z="var(--ago-panel-background, #fff)",He="var(--ago-messages-background, #fbfbfb)",G="var(--ago-text-color, #30373e)",Be="var(--ago-muted-text-color, #6b6d6f)",k="var(--ago-border-color, #dee3e8)",Y="var(--ago-accent-color, #1b5fc4)",ze="var(--ago-radius, 16px)",de="var(--ago-message-radius, 16px)";function Ue(o,n){if(n)for(const r of Object.keys(le)){const e=n[r];e!=null&&o.style.setProperty(le[r],e)}}function E(o,n){Object.assign(o.style,n)}function C(o={}){const n=document.createElement("div");return E(n,o),n}var ce="ago-chat-widget-keyframes";function Fe(){if(typeof document>"u"||document.getElementById(ce))return;const o=document.createElement("style");o.id=ce,o.textContent="@keyframes ago-pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }",document.head.appendChild(o)}function We(o){const n=typeof o=="string"?document.querySelector(o):o;if(!n)throw new Error(`mountChatWidget: target "${String(o)}" not found.`);return n}function Pe(o,n){const{title:r="Chat",welcomeMessage:e="Hello! How can I help you today?",placeholder:u="Type a message...",allowFiles:a=!1,height:d=500,logoUrl:i,showAgentName:c=!1,theme:l,loadThreads:h=!1,forms:T,onFollowUpClick:m,onMessageSent:_,onMessageReceived:U}=n;if(!n.client&&!n.config?.baseUrl)throw new Error("mountChatWidget requires either `client` or `config` (with a baseUrl).");const x=n.client??new ke.AgoClient(n.config),A=We(o),F=n.persistConversation,N=F?Ie.createConversationSession(F===!0?{}:F):void 0;let w=n.conversationId??N?.getLastActiveThread()??void 0,p=[],L=!1,B=null;const W=[],D=C({display:"flex",flexDirection:"column",height:typeof d=="number"?`${d}px`:d,border:`1px solid ${k}`,borderRadius:ze,overflow:"hidden",backgroundColor:z,fontFamily:he,textAlign:"left",boxShadow:"rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"});D.className="ago-chat-widget",Ue(D,l);const P=C({padding:"14px 16px",borderBottom:`1px solid ${k}`,backgroundColor:De,color:Me,display:"flex",alignItems:"center",gap:"10px"});if(P.className="ago-chat-widget__header",i){const t=document.createElement("img");t.src=i,t.alt="Logo",E(t,{height:"24px",width:"auto"}),P.appendChild(t)}const X=document.createElement("h3");X.textContent=r,E(X,{margin:"0",fontSize:"15px",fontWeight:"600"}),P.appendChild(X);const $=C({flex:"1",overflow:"auto",padding:"16px",backgroundColor:He});$.className="ago-chat-widget__messages";const{inputRow:Ce,setDisabled:ve,focus:ye}=qe({placeholder:u,allowFiles:a,onSend:(t,s)=>{K(t,s)}});Fe(),D.append(P,$,Ce),A.appendChild(D);const ee=m!==!1,te=m===!1?void 0:m??(t=>{K(t)});function Ee(t){const s=t.role==="user",b=C({display:"flex",flexDirection:"column",alignItems:s?"flex-end":"flex-start",marginBottom:"16px"});if(b.className=`ago-message ago-message--${t.role}`,!s&&c&&t.agent){const f=C({fontSize:"13px",fontWeight:"500",color:G,marginBottom:"6px",padding:"0 4px"});f.className="ago-message__agent",f.textContent=t.agent.displayName||t.agent.name,b.appendChild(f)}if(!s&&t.sources&&t.sources.length>0){const f=C({display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"10px",width:"100%",maxWidth:"85%"});f.className="ago-message__sources",t.sources.forEach((v,g)=>{const R=v.url?document.createElement("a"):document.createElement("div");v.url&&R instanceof HTMLAnchorElement&&(R.href=v.url,R.target="_blank",R.rel="noopener noreferrer"),E(R,{display:"flex",alignItems:"center",gap:"8px",padding:"8px 10px",border:`1px solid ${k}`,borderRadius:"8px",backgroundColor:z,textDecoration:"none",color:G,fontSize:"12px",overflow:"hidden"});const ie=C({flexShrink:"0",width:"18px",height:"18px",borderRadius:"3px",border:`1px solid ${Y}`,color:Y,fontSize:"11px",fontWeight:"500",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f0f4ff"});ie.textContent=String(g+1);const Q=C({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});Q.textContent=v.title,Q.title=v.title,R.append(ie,Q),f.appendChild(R)}),b.appendChild(f)}const S=C({maxWidth:s?"75%":"100%",padding:s?"10px 14px":"2px 8px",borderRadius:s?de:"0",backgroundColor:s?xe:"transparent",color:s?be:G,wordBreak:"break-word",fontSize:"14px",lineHeight:"1.6"});if(S.className="ago-message__content",t.content?S.appendChild(J(t.content)):t.status==="IN_PROGRESS"&&S.appendChild(Re()),b.appendChild(S),t.followUpReplies&&t.followUpReplies.length>0){const f=C({display:"flex",flexWrap:"wrap",gap:"8px",marginTop:"10px"});f.className="ago-message__followups";for(const v of t.followUpReplies){const g=document.createElement("button");g.type="button",g.className="ago-message__followup-btn",g.textContent=v,g.disabled=!ee,E(g,{padding:"6px 14px",fontSize:"13px",borderRadius:de,border:`1px solid ${k}`,backgroundColor:z,color:G,cursor:ee?"pointer":"default",transition:"border-color 0.15s"}),te&&g.addEventListener("click",()=>te(v)),g.addEventListener("mouseenter",()=>{g.style.borderColor=Y}),g.addEventListener("mouseleave",()=>{g.style.borderColor=k}),f.appendChild(g)}b.appendChild(f)}return b}function I(){if($.replaceChildren(),p.length===0){const t=C({textAlign:"center",color:Be,padding:"24px 16px",fontSize:"14px",lineHeight:"1.5"});t.textContent=e,$.appendChild(t)}else for(const t of p)$.appendChild(Ee(t));if(B){const t=C({padding:"10px 14px",backgroundColor:"#fef2f2",color:"#dc2626",borderRadius:"12px",marginTop:"8px",fontSize:"13px",border:"1px solid #fecaca"});t.textContent=B,$.appendChild(t)}$.scrollTop=$.scrollHeight,ve(L)}function we(){for(let t=p.length-1;t>=0;t--){const s=p[t];if(s.role==="assistant"&&s.status==="IN_PROGRESS")return s}}const ne=t=>{w||(w=t.conversationId)},oe=t=>{const s=we();s&&(s.content+=t.content,I())},re=t=>{const s=p.findIndex(b=>b.id===t.id||b.role==="assistant"&&b.status==="IN_PROGRESS");s>=0?p[s]=t:p.push(t),L=!1,I(),t.status==="DONE"&&U?.({id:t.id,content:t.content})},ae=t=>{B=t.error,L=!1,p=p.filter(s=>!s.id.startsWith("temp-")),I()};x.on("message:start",ne),x.on("message:chunk",oe),x.on("message:complete",re),x.on("message:error",ae);const Se=(T??[]).map(t=>$e.createFormCollector(t).install(x));async function K(t,s){const b=t.trim();if(!b&&!s?.length||L)return;_?.(b),L=!0,B=null;const S=Date.now();p.push({id:`temp-user-${S}`,conversationId:w||"",content:b,role:"user",status:"DONE",createdAt:new Date}),p.push({id:`temp-assistant-${S}`,conversationId:w||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date}),I();try{const f=await x.sendMessage(b,{conversationId:w,files:s});f.conversationId&&(w||(w=f.conversationId),N?.setActiveThread(f.conversationId,f.createdAt));const v=p.find(g=>g.id===`temp-user-${S}`);if(v&&(v.id=`user-${S}`,v.conversationId=f.conversationId),!p.some(g=>g.id===f.id)){const g=p.findIndex(R=>R.id===`temp-assistant-${S}`);g>=0?p[g]=f:p.push(f)}p=p.filter(g=>!g.id.startsWith("temp-")),L=!1,I(),h&&V()}catch(f){B=f instanceof Error?f.message:"Failed to send message",L=!1,p=p.filter(v=>!v.id.startsWith("temp-")),I()}}async function V(){try{const t=await x.getConversations();W.splice(0,W.length,...t)}catch{}return W}async function _e(t){try{const s=(await x.getConversation(t))?.messages??[];s.length>0&&p.length===0&&(p=s,I())}catch{p.length===0&&(N?.clear(),w=void 0)}}return I(),ye(),w&&_e(w),h&&V(),{client:x,element:D,sendMessage:K,session:N,threads:W,refreshThreads:V,destroy(){x.off("message:start",ne),x.off("message:chunk",oe),x.off("message:complete",re),x.off("message:error",ae),Se.forEach(t=>t()),D.remove(),n.client||x.destroy()}};function Re(){const t=C({display:"flex",gap:"4px",padding:"4px 0"});for(let s=0;s<3;s++){const b=C({width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#b5bfc8",animation:"ago-pulse 1.2s ease-in-out infinite",animationDelay:`${s*.2}s`});t.appendChild(b)}return t}}function qe(o){let n=[];const r=document.createElement("form");E(r,{display:"flex",flexDirection:"column",gap:"8px",padding:"12px",borderTop:`1px solid ${k}`,backgroundColor:z}),r.className="ago-chat-input";const e=C({display:"flex",flexWrap:"wrap",gap:"6px"}),u=C({display:"flex",gap:"8px",alignItems:"flex-end"}),a=document.createElement("textarea");a.placeholder=o.placeholder,a.rows=1,E(a,{flex:"1",resize:"none",padding:"10px 12px",border:`1px solid ${k}`,borderRadius:"12px",fontSize:"14px",fontFamily:he,lineHeight:"1.4",maxHeight:"120px",outline:"none"});const d=document.createElement("button");d.type="submit",d.textContent="Send",E(d,{padding:"10px 16px",border:"none",borderRadius:"12px",backgroundColor:xe,color:be,fontSize:"14px",fontWeight:"500",cursor:"pointer"});let i=null,c=null;o.allowFiles&&(i=document.createElement("input"),i.type="file",i.multiple=!0,E(i,{display:"none"}),c=document.createElement("button"),c.type="button",c.textContent="📎",E(c,{padding:"10px 12px",border:`1px solid ${k}`,borderRadius:"12px",backgroundColor:z,cursor:"pointer",fontSize:"14px"}),c.addEventListener("click",()=>i?.click()),i.addEventListener("change",()=>{n=[...n,...Array.from(i?.files??[])],l()}));function l(){e.replaceChildren(),n.forEach((m,_)=>{const U=C({display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",backgroundColor:"#f0f4ff",border:`1px solid ${k}`,borderRadius:"8px",fontSize:"12px"}),x=document.createElement("span");x.textContent=m.name;const A=document.createElement("button");A.type="button",A.textContent="×",E(A,{border:"none",background:"transparent",cursor:"pointer",fontSize:"14px",lineHeight:"1"}),A.addEventListener("click",()=>{n=n.filter((F,N)=>N!==_),l()}),U.append(x,A),e.appendChild(U)})}const h=()=>{const m=a.value,_=n;return a.value="",n=[],l(),{content:m,files:_}},T=()=>{const{content:m,files:_}=h();(m.trim()||_.length>0)&&o.onSend(m.trim(),_.length>0?_:void 0)};return r.addEventListener("submit",m=>{m.preventDefault(),T()}),a.addEventListener("keydown",m=>{m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),T())}),c&&u.appendChild(c),u.append(a,d),i&&r.appendChild(i),r.append(e,u),{inputRow:r,getValueAndClear:h,setDisabled:m=>{a.disabled=m,d.disabled=m,d.style.opacity=m?"0.6":"1",d.style.cursor=m?"not-allowed":"pointer"},focus:()=>a.focus()}}exports.mountChatWidget=Pe;exports.renderMarkdown=J;