@selleo/chatbot-client
Version:
Client that can be integrated with a backend created with openai
34 lines (32 loc) • 156 kB
JavaScript
(function(Ke,ge){typeof exports=="object"&&typeof module<"u"?ge(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],ge):(Ke=typeof globalThis<"u"?globalThis:Ke||self,ge(Ke["@selleo/chatbot-client"]={},Ke.React))})(this,function(Ke,ge){"use strict";function vi(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const Re=vi(ge);function tn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ln={exports:{}},fn={};/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Et;function wi(){if(Et)return fn;Et=1;var e=ge,n=Symbol.for("react.element"),t=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function o(a,s,c){var f,p={},g=null,d=null;c!==void 0&&(g=""+c),s.key!==void 0&&(g=""+s.key),s.ref!==void 0&&(d=s.ref);for(f in s)r.call(s,f)&&!l.hasOwnProperty(f)&&(p[f]=s[f]);if(a&&a.defaultProps)for(f in s=a.defaultProps,s)p[f]===void 0&&(p[f]=s[f]);return{$$typeof:n,type:a,key:g,ref:d,props:p,_owner:i.current}}return fn.Fragment=t,fn.jsx=o,fn.jsxs=o,fn}var pn={};/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var St;function ki(){return St||(St=1,process.env.NODE_ENV!=="production"&&function(){var e=ge,n=Symbol.for("react.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),a=Symbol.for("react.context"),s=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),d=Symbol.for("react.offscreen"),E=Symbol.iterator,y="@@iterator";function x(m){if(m===null||typeof m!="object")return null;var S=E&&m[E]||m[y];return typeof S=="function"?S:null}var v=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function F(m){{for(var S=arguments.length,R=new Array(S>1?S-1:0),Y=1;Y<S;Y++)R[Y-1]=arguments[Y];T("error",m,R)}}function T(m,S,R){{var Y=v.ReactDebugCurrentFrame,he=Y.getStackAddendum();he!==""&&(S+="%s",R=R.concat([he]));var me=R.map(function(ie){return String(ie)});me.unshift("Warning: "+S),Function.prototype.apply.call(console[m],console,me)}}var j=!1,k=!1,b=!1,M=!1,q=!1,Z;Z=Symbol.for("react.module.reference");function de(m){return!!(typeof m=="string"||typeof m=="function"||m===r||m===l||q||m===i||m===c||m===f||M||m===d||j||k||b||typeof m=="object"&&m!==null&&(m.$$typeof===g||m.$$typeof===p||m.$$typeof===o||m.$$typeof===a||m.$$typeof===s||m.$$typeof===Z||m.getModuleId!==void 0))}function _(m,S,R){var Y=m.displayName;if(Y)return Y;var he=S.displayName||S.name||"";return he!==""?R+"("+he+")":R}function I(m){return m.displayName||"Context"}function K(m){if(m==null)return null;if(typeof m.tag=="number"&&F("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof m=="function")return m.displayName||m.name||null;if(typeof m=="string")return m;switch(m){case r:return"Fragment";case t:return"Portal";case l:return"Profiler";case i:return"StrictMode";case c:return"Suspense";case f:return"SuspenseList"}if(typeof m=="object")switch(m.$$typeof){case a:var S=m;return I(S)+".Consumer";case o:var R=m;return I(R._context)+".Provider";case s:return _(m,m.render,"ForwardRef");case p:var Y=m.displayName||null;return Y!==null?Y:K(m.type)||"Memo";case g:{var he=m,me=he._payload,ie=he._init;try{return K(ie(me))}catch{return null}}}return null}var ne=Object.assign,D=0,ee,pe,ve,Ce,u,O,N;function h(){}h.__reactDisabledLog=!0;function B(){{if(D===0){ee=console.log,pe=console.info,ve=console.warn,Ce=console.error,u=console.group,O=console.groupCollapsed,N=console.groupEnd;var m={configurable:!0,enumerable:!0,value:h,writable:!0};Object.defineProperties(console,{info:m,log:m,warn:m,error:m,group:m,groupCollapsed:m,groupEnd:m})}D++}}function Q(){{if(D--,D===0){var m={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:ne({},m,{value:ee}),info:ne({},m,{value:pe}),warn:ne({},m,{value:ve}),error:ne({},m,{value:Ce}),group:ne({},m,{value:u}),groupCollapsed:ne({},m,{value:O}),groupEnd:ne({},m,{value:N})})}D<0&&F("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var L=v.ReactCurrentDispatcher,U;function H(m,S,R){{if(U===void 0)try{throw Error()}catch(he){var Y=he.stack.trim().match(/\n( *(at )?)/);U=Y&&Y[1]||""}return`
`+U+m}}var J=!1,W;{var we=typeof WeakMap=="function"?WeakMap:Map;W=new we}function A(m,S){if(!m||J)return"";{var R=W.get(m);if(R!==void 0)return R}var Y;J=!0;var he=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var me;me=L.current,L.current=null,B();try{if(S){var ie=function(){throw Error()};if(Object.defineProperty(ie.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ie,[])}catch(Ye){Y=Ye}Reflect.construct(m,[],ie)}else{try{ie.call()}catch(Ye){Y=Ye}m.call(ie.prototype)}}else{try{throw Error()}catch(Ye){Y=Ye}m()}}catch(Ye){if(Ye&&Y&&typeof Ye.stack=="string"){for(var re=Ye.stack.split(`
`),Pe=Y.stack.split(`
`),ke=re.length-1,Se=Pe.length-1;ke>=1&&Se>=0&&re[ke]!==Pe[Se];)Se--;for(;ke>=1&&Se>=0;ke--,Se--)if(re[ke]!==Pe[Se]){if(ke!==1||Se!==1)do if(ke--,Se--,Se<0||re[ke]!==Pe[Se]){var Ne=`
`+re[ke].replace(" at new "," at ");return m.displayName&&Ne.includes("<anonymous>")&&(Ne=Ne.replace("<anonymous>",m.displayName)),typeof m=="function"&&W.set(m,Ne),Ne}while(ke>=1&&Se>=0);break}}}finally{J=!1,L.current=me,Q(),Error.prepareStackTrace=he}var cn=m?m.displayName||m.name:"",bi=cn?H(cn):"";return typeof m=="function"&&W.set(m,bi),bi}function Te(m,S,R){return A(m,!1)}function z(m){var S=m.prototype;return!!(S&&S.isReactComponent)}function Fe(m,S,R){if(m==null)return"";if(typeof m=="function")return A(m,z(m));if(typeof m=="string")return H(m);switch(m){case c:return H("Suspense");case f:return H("SuspenseList")}if(typeof m=="object")switch(m.$$typeof){case s:return Te(m.render);case p:return Fe(m.type,S,R);case g:{var Y=m,he=Y._payload,me=Y._init;try{return Fe(me(he),S,R)}catch{}}}return""}var Be=Object.prototype.hasOwnProperty,Ge={},bn=v.ReactDebugCurrentFrame;function un(m){if(m){var S=m._owner,R=Fe(m.type,m._source,S?S.type:null);bn.setExtraStackFrame(R)}else bn.setExtraStackFrame(null)}function _n(m,S,R,Y,he){{var me=Function.call.bind(Be);for(var ie in m)if(me(m,ie)){var re=void 0;try{if(typeof m[ie]!="function"){var Pe=Error((Y||"React class")+": "+R+" type `"+ie+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof m[ie]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Pe.name="Invariant Violation",Pe}re=m[ie](S,ie,Y,R,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ke){re=ke}re&&!(re instanceof Error)&&(un(he),F("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Y||"React class",R,ie,typeof re),un(null)),re instanceof Error&&!(re.message in Ge)&&(Ge[re.message]=!0,un(he),F("Failed %s type: %s",R,re.message),un(null))}}}var In=Array.isArray;function vn(m){return In(m)}function bt(m){{var S=typeof Symbol=="function"&&Symbol.toStringTag,R=S&&m[Symbol.toStringTag]||m.constructor.name||"Object";return R}}function vt(m){try{return Fn(m),!1}catch{return!0}}function Fn(m){return""+m}function Dn(m){if(vt(m))return F("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",bt(m)),Fn(m)}var w=v.ReactCurrentOwner,P={key:!0,ref:!0,__self:!0,__source:!0},$,oe,ae;ae={};function De(m){if(Be.call(m,"ref")){var S=Object.getOwnPropertyDescriptor(m,"ref").get;if(S&&S.isReactWarning)return!1}return m.ref!==void 0}function We(m){if(Be.call(m,"key")){var S=Object.getOwnPropertyDescriptor(m,"key").get;if(S&&S.isReactWarning)return!1}return m.key!==void 0}function Ue(m,S){if(typeof m.ref=="string"&&w.current&&S&&w.current.stateNode!==S){var R=K(w.current.type);ae[R]||(F('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',K(w.current.type),m.ref),ae[R]=!0)}}function en(m,S){{var R=function(){$||($=!0,F("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",S))};R.isReactWarning=!0,Object.defineProperty(m,"key",{get:R,configurable:!0})}}function nn(m,S){{var R=function(){oe||(oe=!0,F("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",S))};R.isReactWarning=!0,Object.defineProperty(m,"ref",{get:R,configurable:!0})}}var be=function(m,S,R,Y,he,me,ie){var re={$$typeof:n,type:m,key:S,ref:R,props:ie,_owner:me};return re._store={},Object.defineProperty(re._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(re,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Y}),Object.defineProperty(re,"_source",{configurable:!1,enumerable:!1,writable:!1,value:he}),Object.freeze&&(Object.freeze(re.props),Object.freeze(re)),re};function wn(m,S,R,Y,he){{var me,ie={},re=null,Pe=null;R!==void 0&&(Dn(R),re=""+R),We(S)&&(Dn(S.key),re=""+S.key),De(S)&&(Pe=S.ref,Ue(S,he));for(me in S)Be.call(S,me)&&!P.hasOwnProperty(me)&&(ie[me]=S[me]);if(m&&m.defaultProps){var ke=m.defaultProps;for(me in ke)ie[me]===void 0&&(ie[me]=ke[me])}if(re||Pe){var Se=typeof m=="function"?m.displayName||m.name||"Unknown":m;re&&en(ie,Se),Pe&&nn(ie,Se)}return be(m,re,Pe,he,Y,w.current,ie)}}var Le=v.ReactCurrentOwner,hi=v.ReactDebugCurrentFrame;function sn(m){if(m){var S=m._owner,R=Fe(m.type,m._source,S?S.type:null);hi.setExtraStackFrame(R)}else hi.setExtraStackFrame(null)}var wt;wt=!1;function kt(m){return typeof m=="object"&&m!==null&&m.$$typeof===n}function di(){{if(Le.current){var m=K(Le.current.type);if(m)return`
Check the render method of \``+m+"`."}return""}}function $u(m){return""}var mi={};function Uu(m){{var S=di();if(!S){var R=typeof m=="string"?m:m.displayName||m.name;R&&(S=`
Check the top-level render call using <`+R+">.")}return S}}function gi(m,S){{if(!m._store||m._store.validated||m.key!=null)return;m._store.validated=!0;var R=Uu(S);if(mi[R])return;mi[R]=!0;var Y="";m&&m._owner&&m._owner!==Le.current&&(Y=" It was passed a child from "+K(m._owner.type)+"."),sn(m),F('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',R,Y),sn(null)}}function yi(m,S){{if(typeof m!="object")return;if(vn(m))for(var R=0;R<m.length;R++){var Y=m[R];kt(Y)&&gi(Y,S)}else if(kt(m))m._store&&(m._store.validated=!0);else if(m){var he=x(m);if(typeof he=="function"&&he!==m.entries)for(var me=he.call(m),ie;!(ie=me.next()).done;)kt(ie.value)&&gi(ie.value,S)}}}function Hu(m){{var S=m.type;if(S==null||typeof S=="string")return;var R;if(typeof S=="function")R=S.propTypes;else if(typeof S=="object"&&(S.$$typeof===s||S.$$typeof===p))R=S.propTypes;else return;if(R){var Y=K(S);_n(R,m.props,"prop",Y,m)}else if(S.PropTypes!==void 0&&!wt){wt=!0;var he=K(S);F("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",he||"Unknown")}typeof S.getDefaultProps=="function"&&!S.getDefaultProps.isReactClassApproved&&F("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Vu(m){{for(var S=Object.keys(m.props),R=0;R<S.length;R++){var Y=S[R];if(Y!=="children"&&Y!=="key"){sn(m),F("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Y),sn(null);break}}m.ref!==null&&(sn(m),F("Invalid attribute `ref` supplied to `React.Fragment`."),sn(null))}}function xi(m,S,R,Y,he,me){{var ie=de(m);if(!ie){var re="";(m===void 0||typeof m=="object"&&m!==null&&Object.keys(m).length===0)&&(re+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Pe=$u();Pe?re+=Pe:re+=di();var ke;m===null?ke="null":vn(m)?ke="array":m!==void 0&&m.$$typeof===n?(ke="<"+(K(m.type)||"Unknown")+" />",re=" Did you accidentally export a JSX literal instead of a component?"):ke=typeof m,F("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ke,re)}var Se=wn(m,S,R,he,me);if(Se==null)return Se;if(ie){var Ne=S.children;if(Ne!==void 0)if(Y)if(vn(Ne)){for(var cn=0;cn<Ne.length;cn++)yi(Ne[cn],m);Object.freeze&&Object.freeze(Ne)}else F("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else yi(Ne,m)}return m===r?Vu(Se):Hu(Se),Se}}function qu(m,S,R){return xi(m,S,R,!0)}function Wu(m,S,R){return xi(m,S,R,!1)}var Yu=Wu,Xu=qu;pn.Fragment=r,pn.jsx=Yu,pn.jsxs=Xu}()),pn}process.env.NODE_ENV==="production"?Ln.exports=wi():Ln.exports=ki();var te=Ln.exports;const Ei=e=>Re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",...e},Re.createElement("path",{d:"M16.293 9.293 12 13.586 7.707 9.293l-1.414 1.414L12 16.414l5.707-5.707z"}),Re.createElement("path",{d:"M16.293 9.293 12 13.586 7.707 9.293l-1.414 1.414L12 16.414l5.707-5.707z"})),Ct=e=>Re.createElement("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"none",...e},Re.createElement("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 13.5997 2.37562 15.1116 3.04346 16.4525C3.22094 16.8088 3.28001 17.2161 3.17712 17.6006L2.58151 19.8267C2.32295 20.793 3.20701 21.677 4.17335 21.4185L6.39939 20.8229C6.78393 20.72 7.19121 20.7791 7.54753 20.9565C8.88837 21.6244 10.4003 22 12 22Z",fill:"#ff6d2a"}),Re.createElement("path",{d:"M15 12C15 12.5523 15.4477 13 16 13C16.5523 13 17 12.5523 17 12C17 11.4477 16.5523 11 16 11C15.4477 11 15 11.4477 15 12Z",fill:"#5c99d2"}),Re.createElement("path",{d:"M11 12C11 12.5523 11.4477 13 12 13C12.5523 13 13 12.5523 13 12C13 11.4477 12.5523 11 12 11C11.4477 11 11 11.4477 11 12Z",fill:"#5c99d2"}),Re.createElement("path",{d:"M7 12C7 12.5523 7.44772 13 8 13C8.55228 13 9 12.5523 9 12C9 11.4477 8.55228 11 8 11C7.44772 11 7 11.4477 7 12Z",fill:"#5c99d2"})),Tt=e=>Re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#474747",...e},Re.createElement("path",{d:"M16 14h.5c.827 0 1.5-.673 1.5-1.5v-9c0-.827-.673-1.5-1.5-1.5h-13C2.673 2 2 2.673 2 3.5V18l5.333-4H16zm-9.333-2L4 14V4h12v8H6.667z"}),Re.createElement("path",{d:"M20.5 8H20v6.001c0 1.1-.893 1.993-1.99 1.999H8v.5c0 .827.673 1.5 1.5 1.5h7.167L22 22V9.5c0-.827-.673-1.5-1.5-1.5z"})),Si=e=>Re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",...e},Re.createElement("path",{d:"M11 8.414V18h2V8.414l4.293 4.293 1.414-1.414L12 4.586l-6.707 6.707 1.414 1.414z"}));var Pt={exports:{}};/*!
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/(function(e){(function(){var n={}.hasOwnProperty;function t(){for(var l="",o=0;o<arguments.length;o++){var a=arguments[o];a&&(l=i(l,r(a)))}return l}function r(l){if(typeof l=="string"||typeof l=="number")return l;if(typeof l!="object")return"";if(Array.isArray(l))return t.apply(null,l);if(l.toString!==Object.prototype.toString&&!l.toString.toString().includes("[native code]"))return l.toString();var o="";for(var a in l)n.call(l,a)&&l[a]&&(o=i(o,a));return o}function i(l,o){return o?l?l+" "+o:l+o:l}e.exports?(t.default=t,e.exports=t):window.classNames=t})()})(Pt);var Ci=Pt.exports;const $e=tn(Ci),kn=e=>({Authorization:e??"","Content-Type":"application/json"}),Ti={getMessages:async(e,n,t)=>{const r=await fetch(`${t}/api/threads/${e}/messages`,{headers:kn(n)});if(!r.ok)throw new Error("Failed to fetch messages");return(await r.json()).messages}},Ot={createThread:async(e,n)=>{const t=await fetch(`${n}/api/threads`,{method:"POST",headers:kn(e)});if(!t.ok)throw new Error("Failed to create thread");return await t.json()},deleteThread:async(e,n,t)=>{if(!(await fetch(`${t}/api/threads/${e}`,{method:"DELETE",headers:kn(n)})).ok)throw new Error("Failed to delete thread")},createMessage:async(e,n,t,r)=>{const i=await fetch(`${r}/api/threads/${e}/messages`,{method:"POST",headers:kn(t),body:JSON.stringify({content:n})});if(!i.ok)throw new Error("Failed to create message");return await i.json()}},Pi={content:"",role:"assistant",isWaiting:!0},At={content:"How can I help you?",role:"assistant"},Oi=(e,n)=>{const[t,r]=ge.useState(""),[i,l]=ge.useState([]),[o,a]=ge.useState(!1),{apiUrl:s,welcomeMessage:c}=hn(),f=async()=>{a(!0);try{const g=await Ti.getMessages(e,n,s);l([...g,c])}catch(g){console.error("Failed to fetch messages:",g),l([{content:"Server error",role:"system"},...i])}finally{a(!1)}},p=async g=>{a(!0);try{l([Pi,{content:g,role:"user"},...i]),r(""),await Ot.createMessage(e,g,n,s),await f()}catch(d){console.error("Failed to create message:",d),l([{content:"Server error",role:"system"},...i])}finally{a(!1)}};return ge.useEffect(()=>{f()},[e]),{messages:i,createMessage:p,message:t,setMessage:r,isLoading:o}},Rt=ge.createContext({logo:Ct,toggleButtonIcon:Tt,placeholder:"Let's talk",welcomeMessage:At}),Ai=e=>{const{children:n}=e;return te.jsx(Rt.Provider,{value:e,children:n})},hn=()=>ge.useContext(Rt),Ri=({threadId:e,token:n})=>{const[t,r]=ge.useState(!1),i=ge.useRef(null),l=ge.useRef(null),{messages:o,createMessage:a,message:s,setMessage:c,isLoading:f}=Oi(e,n),{chatToggleButtonClassName:p,chatMainClassName:g,topBarClassName:d,chatName:E,conversationClassName:y,inputSectionClassName:x,placeholder:v,toggleButtonIcon:F,logo:T}=hn(),j=D=>{c(D.target.value)},k=async D=>{var ee;D.preventDefault(),!(s.trim()===""||f)&&(await a(s),(ee=i.current)==null||ee.focus())},b=D=>{D.code==="Escape"&&r(ee=>!ee),D.code==="Enter"&&k(D)},M=()=>{var D;r(ee=>!ee),(D=i.current)==null||D.focus()},q=()=>o?o.slice().reverse().map((D,ee)=>te.jsx(zu,{...D},D.role+ee)):null,Z=()=>{const D=l.current;D&&D.scrollIntoView({behavior:"smooth"})};ge.useEffect(()=>{Z()},[o]);const de=$e("chat-transition-toggle-menu chat-shadow-gray-950 chat-fixed chat-flex chat-cursor-pointer chat-items-center chat-justify-center chat-rounded-full chat-bg-white chat-p-0 chat-shadow-2xl chat-z-[101]",p,{"chat-bottom-[-50px] chat-right-[-50px] chat-h-2 chat-w-2 chat-opacity-0":t,"chat-bottom-5 chat-right-4 chat-h-[60px] chat-w-[60px] chat-opacity-100":!t}),_=$e(`chat-chatbox-scroll chat-max-h-[500px] chat-shadow-gray-950 chat-transition-chatbox chat-fixed chat-w-full chat-overflow-hidden chat-rounded-t-xl chat-right-0 chat-bg-white chat-max-w-[350px] chat-shadow-xl chat-z-[101] lg:chat-max-w-[50vw] lg:chat-max-h-[60vh] ${g}`,{"chat-bottom-0 chat-h-full chat-w-full chat-opacity-100":t,"chat-bottom-[-60px] chat-h-10 chat-opacity-0":!t}),I=$e("chat-flex chat-h-[70px] chat-items-center chat-justify-between chat-pl-1 chat-shadow-md",d),K=$e("chat-m-0 chat-flex chat-h-[calc(100%-130px)] chat-min-h-0 chat-flex-col chat-overflow-y-auto chat-p-0",y),ne=$e("chat-absolute chat-bottom-3 chat-w-full",x);return te.jsxs(te.Fragment,{children:[te.jsx("div",{className:de,onClick:M,role:"button",tabIndex:0,"aria-label":"Toggle chatbox",children:te.jsx(F,{width:35})}),te.jsxs("div",{className:_,children:[te.jsxs("div",{className:I,children:[te.jsxs("div",{className:"chat-flex chat-items-center chat-p-2",children:[te.jsx(T,{width:35}),te.jsx("div",{className:"chat-ml-2",children:te.jsx("h3",{className:"chat-m-0 chat-p-0 chat-text-2xl chat-font-medium chat-text-gray",children:E})})]}),te.jsx("button",{className:"chat-absolute chat-right-2 chat-top-4 chat-flex chat-h-10 chat-w-10 chat-cursor-pointer chat-items-center chat-justify-center chat-rounded-full chat-bg-transparent chat-p-0",onClick:()=>r(D=>!D),children:te.jsx(Ei,{fill:"black",width:30})})]}),te.jsxs("div",{className:K,children:[q(),te.jsx("div",{ref:l})]}),te.jsx("div",{className:ne,children:te.jsxs("form",{autoComplete:"off",className:"chat-mx-4 chat-my-0 chat-flex chat-h-11 chat-items-center chat-overflow-hidden chat-rounded-full chat-bg-gray chat-bg-opacity-10",onSubmit:k,children:[te.jsx("input",{className:"chat-h-full chat-w-full chat-resize-none chat-border-none chat-bg-transparent chat-pl-4 chat-text-base chat-font-normal chat-text-black chat-outline-none chat-ring-0 focus:chat-border-none focus:chat-outline-none focus:chat-ring-0",type:"text",name:"message",id:"message",ref:i,placeholder:v,value:s,onChange:j,onKeyUp:b,"aria-label":"Chat message input"}),te.jsx("button",{className:"chat-mr-1 chat-flex chat-h-9 chat-w-11 chat-items-center chat-justify-center chat-rounded-full chat-border-none chat-bg-gray chat-bg-opacity-20 chat-p-0 chat-font-body hover:chat-bg-opacity-30",disabled:f,type:"submit","aria-label":"Send message",children:te.jsx(Si,{fill:"black",width:30})})]})})]})]})},_i=()=>{const[e,n]=ge.useState(localStorage.getItem("threadId")),{apiUrl:t,token:r}=hn(),i=l=>{if(l){n(l),localStorage.setItem("threadId",l);return}n(null),localStorage.removeItem("threadId")};return ge.useEffect(()=>{e||(async()=>{try{const o=await Ot.createThread(r,t);i(o.threadId)}catch(o){console.error("Failed to create thread:",o)}})()},[t,e,r]),e?te.jsx(Ri,{threadId:e,token:r}):null},_t=["http","https","mailto","tel"];function Ii(e){const n=(e||"").trim(),t=n.charAt(0);if(t==="#"||t==="/")return n;const r=n.indexOf(":");if(r===-1)return n;let i=-1;for(;++i<_t.length;){const l=_t[i];if(r===l.length&&n.slice(0,l.length).toLowerCase()===l)return n}return i=n.indexOf("?"),i!==-1&&r>i||(i=n.indexOf("#"),i!==-1&&r>i)?n:"javascript:void(0)"}/*!
* Determine if an object is a Buffer
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/var Fi=function(n){return n!=null&&n.constructor!=null&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)};const It=tn(Fi);function dn(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Ft(e.position):"start"in e||"end"in e?Ft(e):"line"in e||"column"in e?Mn(e):""}function Mn(e){return Dt(e&&e.line)+":"+Dt(e&&e.column)}function Ft(e){return Mn(e&&e.start)+"-"+Mn(e&&e.end)}function Dt(e){return e&&typeof e=="number"?e:1}class Me extends Error{constructor(n,t,r){const i=[null,null];let l={start:{line:null,column:null},end:{line:null,column:null}};if(super(),typeof t=="string"&&(r=t,t=void 0),typeof r=="string"){const o=r.indexOf(":");o===-1?i[1]=r:(i[0]=r.slice(0,o),i[1]=r.slice(o+1))}t&&("type"in t||"position"in t?t.position&&(l=t.position):"start"in t||"end"in t?l=t:("line"in t||"column"in t)&&(l.start=t)),this.name=dn(t)||"1:1",this.message=typeof n=="object"?n.message:n,this.stack="",typeof n=="object"&&n.stack&&(this.stack=n.stack),this.reason=this.message,this.fatal,this.line=l.start.line,this.column=l.start.column,this.position=l,this.source=i[0],this.ruleId=i[1],this.file,this.actual,this.expected,this.url,this.note}}Me.prototype.file="",Me.prototype.name="",Me.prototype.reason="",Me.prototype.message="",Me.prototype.stack="",Me.prototype.fatal=null,Me.prototype.column=null,Me.prototype.line=null,Me.prototype.source=null,Me.prototype.ruleId=null,Me.prototype.position=null;const He={basename:Di,dirname:Li,extname:Mi,join:ji,sep:"/"};function Di(e,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');mn(e);let t=0,r=-1,i=e.length,l;if(n===void 0||n.length===0||n.length>e.length){for(;i--;)if(e.charCodeAt(i)===47){if(l){t=i+1;break}}else r<0&&(l=!0,r=i+1);return r<0?"":e.slice(t,r)}if(n===e)return"";let o=-1,a=n.length-1;for(;i--;)if(e.charCodeAt(i)===47){if(l){t=i+1;break}}else o<0&&(l=!0,o=i+1),a>-1&&(e.charCodeAt(i)===n.charCodeAt(a--)?a<0&&(r=i):(a=-1,r=o));return t===r?r=o:r<0&&(r=e.length),e.slice(t,r)}function Li(e){if(mn(e),e.length===0)return".";let n=-1,t=e.length,r;for(;--t;)if(e.charCodeAt(t)===47){if(r){n=t;break}}else r||(r=!0);return n<0?e.charCodeAt(0)===47?"/":".":n===1&&e.charCodeAt(0)===47?"//":e.slice(0,n)}function Mi(e){mn(e);let n=e.length,t=-1,r=0,i=-1,l=0,o;for(;n--;){const a=e.charCodeAt(n);if(a===47){if(o){r=n+1;break}continue}t<0&&(o=!0,t=n+1),a===46?i<0?i=n:l!==1&&(l=1):i>-1&&(l=-1)}return i<0||t<0||l===0||l===1&&i===t-1&&i===r+1?"":e.slice(i,t)}function ji(...e){let n=-1,t;for(;++n<e.length;)mn(e[n]),e[n]&&(t=t===void 0?e[n]:t+"/"+e[n]);return t===void 0?".":zi(t)}function zi(e){mn(e);const n=e.charCodeAt(0)===47;let t=Bi(e,!n);return t.length===0&&!n&&(t="."),t.length>0&&e.charCodeAt(e.length-1)===47&&(t+="/"),n?"/"+t:t}function Bi(e,n){let t="",r=0,i=-1,l=0,o=-1,a,s;for(;++o<=e.length;){if(o<e.length)a=e.charCodeAt(o);else{if(a===47)break;a=47}if(a===47){if(!(i===o-1||l===1))if(i!==o-1&&l===2){if(t.length<2||r!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){if(s=t.lastIndexOf("/"),s!==t.length-1){s<0?(t="",r=0):(t=t.slice(0,s),r=t.length-1-t.lastIndexOf("/")),i=o,l=0;continue}}else if(t.length>0){t="",r=0,i=o,l=0;continue}}n&&(t=t.length>0?t+"/..":"..",r=2)}else t.length>0?t+="/"+e.slice(i+1,o):t=e.slice(i+1,o),r=o-i-1;i=o,l=0}else a===46&&l>-1?l++:l=-1}return t}function mn(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Ni={cwd:$i};function $i(){return"/"}function jn(e){return e!==null&&typeof e=="object"&&e.href&&e.origin}function Ui(e){if(typeof e=="string")e=new URL(e);else if(!jn(e)){const n=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw n.code="ERR_INVALID_ARG_TYPE",n}if(e.protocol!=="file:"){const n=new TypeError("The URL must be of scheme file");throw n.code="ERR_INVALID_URL_SCHEME",n}return Hi(e)}function Hi(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const n=e.pathname;let t=-1;for(;++t<n.length;)if(n.charCodeAt(t)===37&&n.charCodeAt(t+1)===50){const r=n.charCodeAt(t+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(n)}const zn=["history","path","basename","stem","extname","dirname"];class Lt{constructor(n){let t;n?typeof n=="string"||Vi(n)?t={value:n}:jn(n)?t={path:n}:t=n:t={},this.data={},this.messages=[],this.history=[],this.cwd=Ni.cwd(),this.value,this.stored,this.result,this.map;let r=-1;for(;++r<zn.length;){const l=zn[r];l in t&&t[l]!==void 0&&t[l]!==null&&(this[l]=l==="history"?[...t[l]]:t[l])}let i;for(i in t)zn.includes(i)||(this[i]=t[i])}get path(){return this.history[this.history.length-1]}set path(n){jn(n)&&(n=Ui(n)),Nn(n,"path"),this.path!==n&&this.history.push(n)}get dirname(){return typeof this.path=="string"?He.dirname(this.path):void 0}set dirname(n){Mt(this.basename,"dirname"),this.path=He.join(n||"",this.basename)}get basename(){return typeof this.path=="string"?He.basename(this.path):void 0}set basename(n){Nn(n,"basename"),Bn(n,"basename"),this.path=He.join(this.dirname||"",n)}get extname(){return typeof this.path=="string"?He.extname(this.path):void 0}set extname(n){if(Bn(n,"extname"),Mt(this.dirname,"extname"),n){if(n.charCodeAt(0)!==46)throw new Error("`extname` must start with `.`");if(n.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=He.join(this.dirname,this.stem+(n||""))}get stem(){return typeof this.path=="string"?He.basename(this.path,this.extname):void 0}set stem(n){Nn(n,"stem"),Bn(n,"stem"),this.path=He.join(this.dirname||"",n+(this.extname||""))}toString(n){return(this.value||"").toString(n||void 0)}message(n,t,r){const i=new Me(n,t,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}info(n,t,r){const i=this.message(n,t,r);return i.fatal=null,i}fail(n,t,r){const i=this.message(n,t,r);throw i.fatal=!0,i}}function Bn(e,n){if(e&&e.includes(He.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+He.sep+"`")}function Nn(e,n){if(!e)throw new Error("`"+n+"` cannot be empty")}function Mt(e,n){if(!e)throw new Error("Setting `"+n+"` requires `path` to be set too")}function Vi(e){return It(e)}function jt(e){if(e)throw e}var En=Object.prototype.hasOwnProperty,zt=Object.prototype.toString,Bt=Object.defineProperty,Nt=Object.getOwnPropertyDescriptor,$t=function(n){return typeof Array.isArray=="function"?Array.isArray(n):zt.call(n)==="[object Array]"},Ut=function(n){if(!n||zt.call(n)!=="[object Object]")return!1;var t=En.call(n,"constructor"),r=n.constructor&&n.constructor.prototype&&En.call(n.constructor.prototype,"isPrototypeOf");if(n.constructor&&!t&&!r)return!1;var i;for(i in n);return typeof i>"u"||En.call(n,i)},Ht=function(n,t){Bt&&t.name==="__proto__"?Bt(n,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):n[t.name]=t.newValue},Vt=function(n,t){if(t==="__proto__")if(En.call(n,t)){if(Nt)return Nt(n,t).value}else return;return n[t]},qi=function e(){var n,t,r,i,l,o,a=arguments[0],s=1,c=arguments.length,f=!1;for(typeof a=="boolean"&&(f=a,a=arguments[1]||{},s=2),(a==null||typeof a!="object"&&typeof a!="function")&&(a={});s<c;++s)if(n=arguments[s],n!=null)for(t in n)r=Vt(a,t),i=Vt(n,t),a!==i&&(f&&i&&(Ut(i)||(l=$t(i)))?(l?(l=!1,o=r&&$t(r)?r:[]):o=r&&Ut(r)?r:{},Ht(a,{name:t,newValue:e(f,o,i)})):typeof i<"u"&&Ht(a,{name:t,newValue:i}));return a};const qt=tn(qi);function $n(e){if(typeof e!="object"||e===null)return!1;const n=Object.getPrototypeOf(e);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Wi(){const e=[],n={run:t,use:r};return n;function t(...i){let l=-1;const o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);a(null,...i);function a(s,...c){const f=e[++l];let p=-1;if(s){o(s);return}for(;++p<i.length;)(c[p]===null||c[p]===void 0)&&(c[p]=i[p]);i=c,f?Yi(f,a)(...c):o(null,...c)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),n}}function Yi(e,n){let t;return r;function r(...o){const a=e.length>o.length;let s;a&&o.push(i);try{s=e.apply(this,o)}catch(c){const f=c;if(a&&t)throw f;return i(f)}a||(s&&s.then&&typeof s.then=="function"?s.then(l,i):s instanceof Error?i(s):l(s))}function i(o,...a){t||(t=!0,n(o,...a))}function l(o){i(null,o)}}const Xi=Yt().freeze(),Wt={}.hasOwnProperty;function Yt(){const e=Wi(),n=[];let t={},r,i=-1;return l.data=o,l.Parser=void 0,l.Compiler=void 0,l.freeze=a,l.attachers=n,l.use=s,l.parse=c,l.stringify=f,l.run=p,l.runSync=g,l.process=d,l.processSync=E,l;function l(){const y=Yt();let x=-1;for(;++x<n.length;)y.use(...n[x]);return y.data(qt(!0,{},t)),y}function o(y,x){return typeof y=="string"?arguments.length===2?(Vn("data",r),t[y]=x,l):Wt.call(t,y)&&t[y]||null:y?(Vn("data",r),t=y,l):t}function a(){if(r)return l;for(;++i<n.length;){const[y,...x]=n[i];if(x[0]===!1)continue;x[0]===!0&&(x[0]=void 0);const v=y.call(l,...x);typeof v=="function"&&e.use(v)}return r=!0,i=Number.POSITIVE_INFINITY,l}function s(y,...x){let v;if(Vn("use",r),y!=null)if(typeof y=="function")k(y,...x);else if(typeof y=="object")Array.isArray(y)?j(y):T(y);else throw new TypeError("Expected usable value, not `"+y+"`");return v&&(t.settings=Object.assign(t.settings||{},v)),l;function F(b){if(typeof b=="function")k(b);else if(typeof b=="object")if(Array.isArray(b)){const[M,...q]=b;k(M,...q)}else T(b);else throw new TypeError("Expected usable value, not `"+b+"`")}function T(b){j(b.plugins),b.settings&&(v=Object.assign(v||{},b.settings))}function j(b){let M=-1;if(b!=null)if(Array.isArray(b))for(;++M<b.length;){const q=b[M];F(q)}else throw new TypeError("Expected a list of plugins, not `"+b+"`")}function k(b,M){let q=-1,Z;for(;++q<n.length;)if(n[q][0]===b){Z=n[q];break}Z?($n(Z[1])&&$n(M)&&(M=qt(!0,Z[1],M)),Z[1]=M):n.push([...arguments])}}function c(y){l.freeze();const x=gn(y),v=l.Parser;return Un("parse",v),Xt(v,"parse")?new v(String(x),x).parse():v(String(x),x)}function f(y,x){l.freeze();const v=gn(x),F=l.Compiler;return Hn("stringify",F),Qt(y),Xt(F,"compile")?new F(y,v).compile():F(y,v)}function p(y,x,v){if(Qt(y),l.freeze(),!v&&typeof x=="function"&&(v=x,x=void 0),!v)return new Promise(F);F(null,v);function F(T,j){e.run(y,gn(x),k);function k(b,M,q){M=M||y,b?j(b):T?T(M):v(null,M,q)}}}function g(y,x){let v,F;return l.run(y,x,T),Gt("runSync","run",F),v;function T(j,k){jt(j),v=k,F=!0}}function d(y,x){if(l.freeze(),Un("process",l.Parser),Hn("process",l.Compiler),!x)return new Promise(v);v(null,x);function v(F,T){const j=gn(y);l.run(l.parse(j),j,(b,M,q)=>{if(b||!M||!q)k(b);else{const Z=l.stringify(M,q);Z==null||(Ki(Z)?q.value=Z:q.result=Z),k(b,q)}});function k(b,M){b||!M?T(b):F?F(M):x(null,M)}}}function E(y){let x;l.freeze(),Un("processSync",l.Parser),Hn("processSync",l.Compiler);const v=gn(y);return l.process(v,F),Gt("processSync","process",x),v;function F(T){x=!0,jt(T)}}}function Xt(e,n){return typeof e=="function"&&e.prototype&&(Qi(e.prototype)||n in e.prototype)}function Qi(e){let n;for(n in e)if(Wt.call(e,n))return!0;return!1}function Un(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `Parser`")}function Hn(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `Compiler`")}function Vn(e,n){if(n)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Qt(e){if(!$n(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Gt(e,n,t){if(!t)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function gn(e){return Gi(e)?e:new Lt(e)}function Gi(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Ki(e){return typeof e=="string"||It(e)}const Ji={};function Zi(e,n){const t=Ji,r=typeof t.includeImageAlt=="boolean"?t.includeImageAlt:!0,i=typeof t.includeHtml=="boolean"?t.includeHtml:!0;return Kt(e,r,i)}function Kt(e,n,t){if(el(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 Jt(e.children,n,t)}return Array.isArray(e)?Jt(e,n,t):""}function Jt(e,n,t){const r=[];let i=-1;for(;++i<e.length;)r[i]=Kt(e[i],n,t);return r.join("")}function el(e){return!!(e&&typeof e=="object")}function Ve(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 je(e,n){return e.length>0?(Ve(e,e.length,0,n),e):n}const Zt={}.hasOwnProperty;function nl(e){const n={};let t=-1;for(;++t<e.length;)tl(n,e[t]);return n}function tl(e,n){let t;for(t in n){const i=(Zt.call(e,t)?e[t]:void 0)||(e[t]={}),l=n[t];let o;if(l)for(o in l){Zt.call(i,o)||(i[o]=[]);const a=l[o];rl(i[o],Array.isArray(a)?a:a?[a]:[])}}}function rl(e,n){let t=-1;const r=[];for(;++t<n.length;)(n[t].add==="after"?e:r).push(n[t]);Ve(e,0,0,r)}const il=/[!-\/:-@\[-`\{-~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/,qe=Xe(/[A-Za-z]/),_e=Xe(/[\dA-Za-z]/),ll=Xe(/[#-'*+\--9=?A-Z^-~]/);function qn(e){return e!==null&&(e<32||e===127)}const Wn=Xe(/\d/),ol=Xe(/[\dA-Fa-f]/),al=Xe(/[!-/:-@[-`{-~]/);function V(e){return e!==null&&e<-2}function Oe(e){return e!==null&&(e<0||e===32)}function le(e){return e===-2||e===-1||e===32}const ul=Xe(il),sl=Xe(/\s/);function Xe(e){return n;function n(t){return t!==null&&e.test(String.fromCharCode(t))}}function ye(e,n,t,r){const i=r?r-1:Number.POSITIVE_INFINITY;let l=0;return o;function o(s){return le(s)?(e.enter(t),a(s)):n(s)}function a(s){return le(s)&&l++<i?(e.consume(s),a):(e.exit(t),n(s))}}const cl={tokenize:fl};function fl(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"),ye(e,n,"linePrefix")}function i(a){return e.enter("paragraph"),l(a)}function l(a){const s=e.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=s),t=s,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return V(a)?(e.consume(a),e.exit("chunkText"),l):(e.consume(a),o)}}const pl={tokenize:hl},er={tokenize:dl};function hl(e){const n=this,t=[];let r=0,i,l,o;return a;function a(T){if(r<t.length){const j=t[r];return n.containerState=j[1],e.attempt(j[0].continuation,s,c)(T)}return c(T)}function s(T){if(r++,n.containerState._closeFlow){n.containerState._closeFlow=void 0,i&&F();const j=n.events.length;let k=j,b;for(;k--;)if(n.events[k][0]==="exit"&&n.events[k][1].type==="chunkFlow"){b=n.events[k][1].end;break}v(r);let M=j;for(;M<n.events.length;)n.events[M][1].end=Object.assign({},b),M++;return Ve(n.events,k+1,0,n.events.slice(j)),n.events.length=M,c(T)}return a(T)}function c(T){if(r===t.length){if(!i)return g(T);if(i.currentConstruct&&i.currentConstruct.concrete)return E(T);n.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(er,f,p)(T)}function f(T){return i&&F(),v(r),g(T)}function p(T){return n.parser.lazy[n.now().line]=r!==t.length,o=n.now().offset,E(T)}function g(T){return n.containerState={},e.attempt(er,d,E)(T)}function d(T){return r++,t.push([n.currentConstruct,n.containerState]),g(T)}function E(T){if(T===null){i&&F(),v(0),e.consume(T);return}return i=i||n.parser.flow(n.now()),e.enter("chunkFlow",{contentType:"flow",previous:l,_tokenizer:i}),y(T)}function y(T){if(T===null){x(e.exit("chunkFlow"),!0),v(0),e.consume(T);return}return V(T)?(e.consume(T),x(e.exit("chunkFlow")),r=0,n.interrupt=void 0,a):(e.consume(T),y)}function x(T,j){const k=n.sliceStream(T);if(j&&k.push(null),T.previous=l,l&&(l.next=T),l=T,i.defineSkip(T.start),i.write(k),n.parser.lazy[T.start.line]){let b=i.events.length;for(;b--;)if(i.events[b][1].start.offset<o&&(!i.events[b][1].end||i.events[b][1].end.offset>o))return;const M=n.events.length;let q=M,Z,de;for(;q--;)if(n.events[q][0]==="exit"&&n.events[q][1].type==="chunkFlow"){if(Z){de=n.events[q][1].end;break}Z=!0}for(v(r),b=M;b<n.events.length;)n.events[b][1].end=Object.assign({},de),b++;Ve(n.events,q+1,0,n.events.slice(M)),n.events.length=b}}function v(T){let j=t.length;for(;j-- >T;){const k=t[j];n.containerState=k[1],k[0].exit.call(n,e)}t.length=T}function F(){i.write([null]),l=void 0,i=void 0,n.containerState._closeFlow=void 0}}function dl(e,n,t){return ye(e,e.attempt(this.parser.constructs.document,n,t),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function nr(e){if(e===null||Oe(e)||sl(e))return 1;if(ul(e))return 2}function Yn(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}const Xn={name:"attention",tokenize:gl,resolveAll:ml};function ml(e,n){let t=-1,r,i,l,o,a,s,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;s=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 p=Object.assign({},e[r][1].end),g=Object.assign({},e[t][1].start);tr(p,-s),tr(g,s),o={type:s>1?"strongSequence":"emphasisSequence",start:p,end:Object.assign({},e[r][1].end)},a={type:s>1?"strongSequence":"emphasisSequence",start:Object.assign({},e[t][1].start),end:g},l={type:s>1?"strongText":"emphasisText",start:Object.assign({},e[r][1].end),end:Object.assign({},e[t][1].start)},i={type:s>1?"strong":"emphasis",start:Object.assign({},o.start),end:Object.assign({},a.end)},e[r][1].end=Object.assign({},o.start),e[t][1].start=Object.assign({},a.end),c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=je(c,[["enter",e[r][1],n],["exit",e[r][1],n]])),c=je(c,[["enter",i,n],["enter",o,n],["exit",o,n],["enter",l,n]]),c=je(c,Yn(n.parser.constructs.insideSpan.null,e.slice(r+1,t),n)),c=je(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=je(c,[["enter",e[t][1],n],["exit",e[t][1],n]])):f=0,Ve(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 gl(e,n){const t=this.parser.constructs.attentionMarkers.null,r=this.previous,i=nr(r);let l;return o;function o(s){return l=s,e.enter("attentionSequence"),a(s)}function a(s){if(s===l)return e.consume(s),a;const c=e.exit("attentionSequence"),f=nr(s),p=!f||f===2&&i||t.includes(s),g=!i||i===2&&f||t.includes(r);return c._open=!!(l===42?p:p&&(i||!g)),c._close=!!(l===42?g:g&&(f||!p)),n(s)}}function tr(e,n){e.column+=n,e.offset+=n,e._bufferIndex+=n}const yl={name:"autolink",tokenize:xl};function xl(e,n,t){let r=0;return i;function i(d){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l}function l(d){return qe(d)?(e.consume(d),o):c(d)}function o(d){return d===43||d===45||d===46||_e(d)?(r=1,a(d)):c(d)}function a(d){return d===58?(e.consume(d),r=0,s):(d===43||d===45||d===46||_e(d))&&r++<32?(e.consume(d),a):(r=0,c(d))}function s(d){return d===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.exit("autolink"),n):d===null||d===32||d===60||qn(d)?t(d):(e.consume(d),s)}function c(d){return d===64?(e.consume(d),f):ll(d)?(e.consume(d),c):t(d)}function f(d){return _e(d)?p(d):t(d)}function p(d){return d===46?(e.consume(d),r=0,f):d===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(d),e.exit("autolinkMarker"),e.exit("autolink"),n):g(d)}function g(d){if((d===45||_e(d))&&r++<63){const E=d===45?g:p;return e.consume(d),E}return t(d)}}const Sn={tokenize:bl,partial:!0};function bl(e,n,t){return r;function r(l){return le(l)?ye(e,i,"linePrefix")(l):i(l)}function i(l){return l===null||V(l)?n(l):t(l)}}const rr={name:"blockQuote",tokenize:vl,continuation:{tokenize:wl},exit:kl};function vl(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 le(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),n):(e.exit("blockQuotePrefix"),n(o))}}function wl(e,n,t){const r=this;return i;function i(o){return le(o)?ye(e,l,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):l(o)}function l(o){return e.attempt(rr,n,t)(o)}}function kl(e){e.exit("blockQuote")}const ir={name:"characterEscape",tokenize:El};function El(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 al(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),n):t(l)}}const lr=document.createElement("i");function Qn(e){const n="&"+e+";";lr.innerHTML=n;const t=lr.textContent;return t.charCodeAt(t.length-1)===59&&e!=="semi"||t===n?!1:t}const or={name:"characterReference",tokenize:Sl};function Sl(e,n,t){const r=this;let i=0,l,o;return a;function a(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),s}function s(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),l=31,o=_e,f(p))}function c(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,o=ol,f):(e.enter("characterReferenceValue"),l=7,o=Wn,f(p))}function f(p){if(p===59&&i){const g=e.exit("characterReferenceValue");return o===_e&&!Qn(r.sliceSerialize(g))?t(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),n)}return o(p)&&i++<l?(e.consume(p),f):t(p)}}const ar={tokenize:Tl,partial:!0},ur={name:"codeFenced",tokenize:Cl,concrete:!0};function Cl(e,n,t){const r=this,i={tokenize:k,partial:!0};let l=0,o=0,a;return s;function s(b){return c(b)}function c(b){const M=r.events[r.events.length-1];return l=M&&M[1].type==="linePrefix"?M[2].sliceSerialize(M[1],!0).length:0,a=b,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(b)}function f(b){return b===a?(o++,e.consume(b),f):o<3?t(b):(e.exit("codeFencedFenceSequence"),le(b)?ye(e,p,"whitespace")(b):p(b))}function p(b){return b===null||V(b)?(e.exit("codeFencedFence"),r.interrupt?n(b):e.check(ar,y,j)(b)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),g(b))}function g(b){return b===null||V(b)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(b)):le(b)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ye(e,d,"whitespace")(b)):b===96&&b===a?t(b):(e.consume(b),g)}function d(b){return b===null||V(b)?p(b):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),E(b))}function E(b){return b===null||V(b)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(b)):b===96&&b===a?t(b):(e.consume(b),E)}function y(b){return e.attempt(i,j,x)(b)}function x(b){return e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),v}function v(b){return l>0&&le(b)?ye(e,F,"linePrefix",l+1)(b):F(b)}function F(b){return b===null||V(b)?e.check(ar,y,j)(b):(e.enter("codeFlowValue"),T(b))}function T(b){return b===null||V(b)?(e.exit("codeFlowValue"),F(b)):(e.consume(b),T)}function j(b){return e.exit("codeFenced"),n(b)}function k(b,M,q){let Z=0;return de;function de(D){return b.enter("lineEnding"),b.consume(D),b.exit("lineEnding"),_}function _(D){return b.enter("codeFencedFence"),le(D)?ye(b,I,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):I(D)}function I(D){return D===a?(b.enter("codeFencedFenceSequence"),K(D)):q(D)}function K(D){return D===a?(Z++,b.consume(D),K):Z>=o?(b.exit("codeFencedFenceSequence"),le(D)?ye(b,ne,"whitespace")(D):ne(D)):q(D)}function ne(D){return D===null||V(D)?(b.exit("codeFencedFence"),M(D)):q(D)}}}function Tl(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)}}const Gn={name:"codeIndented",tokenize:Ol},Pl={tokenize:Al,partial:!0};function Ol(e,n,t){const r=this;return i;function i(c){return e.enter("codeIndented"),ye(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?s(c):V(c)?e.attempt(Pl,o,s)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||V(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),a)}function s(c){return e.exit("codeIndented"),n(c)}}function Al(e,n,t){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?t(o):V(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):ye(e,l,"linePrefix",5)(o)}function l(o){const a=r.events[r.events.len